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AE,MAAO,GACL,EAAkB,EAAiB,UAC/B,0CAEA,QAAQ,KAAK,4LAErB,CAEJ,EAAiB,EAAe,GAChC,GAAG,WAAW,SAAS,EAAe,CAClC,aAAa,EACb,SAAU,EACV,UAAW,GAEnB,KAER,EACA,WAAA,GACS,GACD,GAAG,WAAW,WAAW,EAAI,MAAM,UAE3C,EACA,aAAA,GACI,IAAK,GAAoB,EAAI,UAAW,CACpC,MAAM,EAAI,EAAI,UACV,EAAE,WAAa,EAAE,UAAU,UAC3B,EAAE,UAAU,UACZ,EAAE,UAAU,QAAU,OAI9B,CACJ,EACH,CAET,CACA,SAAS,wCACL,0CAA2C,CAC/C,CACA,eAAe,gBAAgB,EAAK,GAQhC,GANmB,mBAAR,IAAoB,EAAM,EAAI,SAId,KAF3B,QAAY,GAEG,UAAyB,EAAM,EAAI,SAE/B,iBAAR,EAAkB,OAAO,EAEpC,MAAM,EAAM,CAAC,EAMb,aALM,QAAQ,IAAI,OAAO,KAAK,GAAK,KAAI,UACnC,MAAM,QAAU,EAAI,GAEpB,EAAI,QAA0B,IAAd,EAAE,QAA0B,EAAE,QAAU,CAAC,KAEtD,CACX","file":"/npm/@profiscience/knockout-contrib-router-plugins-component@2.0.17/dist/node/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@profiscience/knockout-contrib-router-plugins-component@2.0.17/dist/node/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n    value: true\n});\nexports.componentRoutePlugin = componentRoutePlugin;\nexports.disableUninstantiableViewModelWarning = disableUninstantiableViewModelWarning;\n\nvar _knockout = require('knockout');\n\nvar ko = _interopRequireWildcard(_knockout);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nlet UNINSTANTIABLE_VIEWMODEL_WARNING_ENABLED = true;\nconst uniqueComponentNames = function* () {\n    let i = 0;\n    while (true) yield `__router_view_${i++}__`;\n}();\n// @TODO (try to) make this type-safe, i.e. know it's void if routeConfig.component is void, and middleware if not\nfunction componentRoutePlugin({ component: componentAccessor }) {\n    if (!componentAccessor) return;\n    return ctx => {\n        let isNamedComponent;\n        return {\n            beforeRender() {\n                let _resolve;\n                const resolveComponent = (name, instance) => {\n                    const c = Object.assign({ name }, instance || {});\n                    ctx.route.component = name;\n                    ctx.component = c;\n                    _resolve(c);\n                };\n                let viewModelInstance;\n                ctx.component = new Promise(r => _resolve = r);\n                ctx.queue(normalizeConfig(ctx, componentAccessor).then(async normalizedConfig => {\n                    // named component\n                    if (typeof normalizedConfig === 'string') {\n                        isNamedComponent = true;\n                        resolveComponent(normalizedConfig);\n                        if (UNINSTANTIABLE_VIEWMODEL_WARNING_ENABLED) {\n                            // tslint:disable-next-line:no-console\n                            console.warn('[@profiscience/knockout-contrib-router-plugins-component] Unable to instantiate viewModel when using named components. This may cause unexpected behavior. View \"Subtleties/Caveats\" in the documentation.');\n                        }\n                    } else {\n                        // anonymous component\n                        const componentName = normalizedConfig.name || uniqueComponentNames.next().value;\n                        const routedComponentInstance = {\n                            name: componentName\n                        };\n                        const templateConfig = normalizedConfig.template;\n                        let viewModelConfig;\n                        if (normalizedConfig.viewModel) {\n                            try {\n                                viewModelInstance = new normalizedConfig.viewModel(ctx);\n                                viewModelConfig = { instance: viewModelInstance };\n                                routedComponentInstance.viewModel = viewModelInstance;\n                            } catch (e) {\n                                viewModelConfig = normalizedConfig.viewModel;\n                                if (UNINSTANTIABLE_VIEWMODEL_WARNING_ENABLED) {\n                                    // tslint:disable-next-line:no-console\n                                    console.warn('[@profiscience/knockout-contrib-router-plugins-component] Unable to instantiate viewModel using `new`. This may cause unexpected behavior. See \"Subtleties/Caveats\" in the documentation.');\n                                }\n                            }\n                        }\n                        resolveComponent(componentName, routedComponentInstance);\n                        ko.components.register(componentName, {\n                            synchronous: true,\n                            template: templateConfig,\n                            viewModel: viewModelConfig\n                        });\n                    }\n                }));\n            },\n            afterRender() {\n                if (!isNamedComponent) {\n                    ko.components.unregister(ctx.route.component);\n                }\n            },\n            beforeDispose() {\n                if (!isNamedComponent && ctx.component) {\n                    const c = ctx.component;\n                    if (c.viewModel && c.viewModel.dispose) {\n                        c.viewModel.dispose();\n                        c.viewModel.dispose = () => {\n                            /* noop */\n                        };\n                    }\n                }\n            }\n        };\n    };\n}\nfunction disableUninstantiableViewModelWarning() {\n    UNINSTANTIABLE_VIEWMODEL_WARNING_ENABLED = false;\n}\nasync function normalizeConfig(ctx, obj) {\n    // resolve accessors\n    if (typeof obj === 'function') obj = obj(ctx);\n    // resolve top-level promises\n    obj = await obj;\n    // top-level default exports\n    if (typeof obj.default !== 'undefined') obj = obj.default;\n    // named components\n    if (typeof obj === 'string') return obj;\n    // anonymous components, may have promised values\n    const ret = {};\n    await Promise.all(Object.keys(obj).map(async k => {\n        const v = await obj[k];\n        // property default exports\n        ret[k] = typeof v.default !== 'undefined' ? v.default : v;\n    }));\n    return ret;\n}\n"]}