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uB,CAAC,CAAC,CAAU,EAAE,EAAE;IACnC,MAAM,QAAQ,GAAG,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAC5C,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC1D,IAAI,IAAI,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,GAAG,QAAQ,CAAC,CAAC;IACrF,IAAI,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IAC7B,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACxB,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC,CAAC","file":"","sourceRoot":"/","sourcesContent":["import { Presenter, setPresenterViewFactory, Subpresenter, setSubpresenterwFactory } from \"../../common/classbase/PresenterBase\";\nimport { ResUtils } from \"../../common/utils/ResUtils\";\nimport { CCView, CCSubview } from \"../../common/classbase/CCViewBase\";\nimport { Subview } from \"../../common/classbase/ViewBase\";\n\nconst PresenterMap: { [key: string]: string } = {};\nconst ViewMap: { [key: string]: { cls: { new(): CCView }, prefab: string } } = {};\n\nexport function RegPresenter(viewType: string) {\n    return function (target: { new(): Presenter<any, any>, uuid: string }) {\n        PresenterMap[target.uuid] = viewType;\n    }\n}\n\nexport function RegView(viewType: string, prefabPath: string) {\n    return function (target: { new(): CCView }) {\n        ViewMap[viewType] = { cls: target, prefab: prefabPath };\n    }\n}\n\nconst ViewTypeSubviewMap: { [key: string]: { cls: { new(): CCSubview } } } = {};\nconst ViewTypeSubpresenterMap: { [key: string]: { cls: { new(): Subpresenter } } } = {};\n\nexport function RegSubpresenter(viewType: string) {\n    return function (target: { new(): Subpresenter }) {\n        ViewTypeSubpresenterMap[viewType] = { cls: target };\n        Object.defineProperty(target, \"_viewType\", { configurable: false, enumerable: false, value: viewType, writable: false });\n    }\n}\n\nexport function RegSubview(viewType: string) {\n    return function (target: { new(): CCSubview }) {\n        ViewTypeSubviewMap[viewType] = { cls: target };\n        Object.defineProperty(target, \"_viewType\", { configurable: false, enumerable: false, value: viewType, writable: false });\n    }\n}\n\nlet factory: any = async (presenterCls) => {\n    let ret = ViewMap[PresenterMap[presenterCls.uuid]];\n    if (ret) {\n        let node = await ResUtils.createWithPrefab(ret.prefab);\n        let comp = node.getComponent(ret.cls);\n        if (!comp) {\n            comp = node.addComponent(ret.cls);\n        }\n        return comp;\n    }\n\n    throw new Error(\"Create view failed. \" + presenterCls.uuid);\n};\n\nfactory.preloadView = async (presenterCls: { new(): Presenter, uuid: string }) => {\n    let ret = ViewMap[PresenterMap[presenterCls.uuid]];\n    if (ret) {\n        await ResUtils.loadRes(ret.prefab, cc.Prefab);\n    }\n}\n\nsetPresenterViewFactory(factory);\n\n// setSubviewFactory(async (p: Subpresenter) => {\n//     if (p.view) throw new Error(\"Subpresenter already has view.\");\n//     const viewType = p.constructor[\"_viewType\"];\n//     if (!viewType) throw new Error(\"Subpresenter not registered.\");\n//     if (!ViewTypeSubviewMap[viewType]) throw new Error(\"Subview not registered. \" + viewType);\n//     const data = ViewTypeSubviewMap[viewType];\n//     if (!data.prefab) throw new Error(\"Subview prefab not registered. \" + viewType);\n//     let node = await ResUtils.createWithPrefab(data.prefab);\n//     let ret = node.getComponent(data.cls);\n//     if (!ret) {\n//         ret = node.addComponent(data.cls);\n//     }\n//     p.attachView(ret);\n//     return ret;\n// });\n\nsetSubpresenterwFactory((v: Subview) => {\n    const viewType = v.constructor[\"_viewType\"];\n    if (!viewType) throw new Error(\"Subview not registered.\");\n    let data = ViewTypeSubpresenterMap[viewType];\n    if (!data) throw new Error(\"Subpresenter not registered for view type. \" + viewType);\n    let presenter = new data.cls;\n    presenter.attachView(v);\n    return presenter;\n});"]}