{"version":3,"file":"index.js","sources":["../../../../src/packages/core/router/components/not-found/route-not-found.element.ts","../../../../src/packages/core/router/generate-route-path-builder.function.ts","../../../../src/packages/core/router/components/router-slot/route.context.ts","../../../../src/packages/core/router/components/router-slot/router-slot-change.event.ts","../../../../src/packages/core/router/components/router-slot/router-slot-init.event.ts","../../../../src/packages/core/router/contexts/route-path-addendum.context-token.ts","../../../../src/packages/core/router/contexts/route-path-addendum-reset.context.ts","../../../../src/packages/core/router/components/router-slot/router-slot.element.ts","../../../../src/packages/core/router/contexts/route-path-addendum.context.ts","../../../../src/packages/core/router/encode-folder-name.function.ts","../../../../src/packages/core/router/modal-registration/modal-route-registration.controller.ts"],"sourcesContent":["import { UmbTextStyles } from '@umbraco-cms/backoffice/style';\r\nimport { css, html, customElement } from '@umbraco-cms/backoffice/external/lit';\r\nimport { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';\r\n\r\n/**\r\n * A fallback view to be used in Workspace Views, maybe this can be upgraded at a later point.\r\n */\r\n// TODO: Rename and move this file to a more generic place.\r\n@customElement('umb-route-not-found')\r\nexport class UmbRouteNotFoundElement extends UmbLitElement {\r\n\toverride render() {\r\n\t\treturn html`\r\n\t\t\t
\r\n\t\t\t\t

\r\n\t\t\t\t\r\n\t\t\t
\r\n\t\t`;\r\n\t}\r\n\r\n\tstatic override styles = [\r\n\t\tUmbTextStyles,\r\n\t\tcss`\r\n\t\t\t:host {\r\n\t\t\t\tdisplay: block;\r\n\t\t\t\twidth: 100%;\r\n\t\t\t\theight: 100%;\r\n\t\t\t\tmin-width: 0;\r\n\t\t\t}\r\n\r\n\t\t\t:host > div {\r\n\t\t\t\tdisplay: flex;\r\n\t\t\t\tflex-direction: column;\r\n\t\t\t\tjustify-content: center;\r\n\t\t\t\talign-items: center;\r\n\t\t\t\theight: 100%;\r\n\t\t\t\topacity: 0;\r\n\t\t\t\tanimation: fadeIn 6s 0.2s forwards;\r\n\t\t\t}\r\n\r\n\t\t\t@keyframes fadeIn {\r\n\t\t\t\t100% {\r\n\t\t\t\t\topacity: 100%;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t`,\r\n\t];\r\n}\r\n\r\nexport default UmbRouteNotFoundElement;\r\n\r\ndeclare global {\r\n\tinterface HTMLElementTagNameMap {\r\n\t\t'umb-route-not-found': UmbRouteNotFoundElement;\r\n\t}\r\n}\r\n","import { type UrlParametersRecord, umbUrlPatternToString } from '../utils/path/url-pattern-to-string.function.js';\r\nimport { stripSlash } from '@umbraco-cms/backoffice/external/router-slot'; // This must only include the util to avoid side effects of registering the route element.\r\n\r\n/**\r\n *\r\n * @param path\r\n */\r\nexport function umbGenerateRoutePathBuilder(path: string) {\r\n\treturn (params: UrlParametersRecord | null) => {\r\n\t\treturn '/' + stripSlash(umbUrlPatternToString(path, params)) + '/';\r\n\t};\r\n}\r\n\r\n/**\r\n * @deprecated Use `umbGenerateRoutePathBuilder` instead.\r\n */\r\nexport { umbGenerateRoutePathBuilder as umbCreateRoutePathBuilder };\r\n","import { umbGenerateRoutePathBuilder } from '../../generate-route-path-builder.function.js';\r\nimport type { UmbModalRouteRegistration } from '../../modal-registration/modal-route-registration.interface.js';\r\nimport type { UmbRoute } from './route.interface.js';\r\nimport type { IRouterSlot } from '@umbraco-cms/backoffice/external/router-slot';\r\nimport { UmbContextToken } from '@umbraco-cms/backoffice/context-api';\r\nimport type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';\r\nimport { UmbContextBase } from '@umbraco-cms/backoffice/class-api';\r\nimport { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';\r\nimport { UmbStringState, mergeObservables } from '@umbraco-cms/backoffice/observable-api';\r\n\r\nconst EmptyDiv = document.createElement('div');\r\n\r\ntype UmbRoutePlusModalKey = UmbRoute & { __modalKey: string };\r\n\r\nexport class UmbRouteContext extends UmbContextBase {\r\n\t#modalRouter: IRouterSlot;\r\n\t#modalRegistrations: UmbModalRouteRegistration[] = [];\r\n\t#modalContext?: typeof UMB_MODAL_MANAGER_CONTEXT.TYPE;\r\n\t#modalRoutes: UmbRoutePlusModalKey[] = [];\r\n\t#activeModalPath?: string;\r\n\r\n\t#basePath = new UmbStringState(undefined);\r\n\tpublic readonly basePath = this.#basePath.asObservable();\r\n\r\n\t#activeLocalPath = new UmbStringState(undefined);\r\n\tpublic readonly activeLocalPath = this.#activeLocalPath.asObservable();\r\n\tpublic readonly activePath = mergeObservables([this.basePath, this.activeLocalPath], ([basePath, localPath]) => {\r\n\t\treturn basePath + '/' + localPath;\r\n\t});\r\n\r\n\tconstructor(host: UmbControllerHost, mainRouter: IRouterSlot, modalRouter: IRouterSlot) {\r\n\t\tsuper(host, UMB_ROUTE_CONTEXT);\r\n\t\tthis.#modalRouter = modalRouter;\r\n\t\tthis.consumeContext(UMB_MODAL_MANAGER_CONTEXT, (context) => {\r\n\t\t\tthis.#modalContext = context;\r\n\t\t\tthis.#generateModalRoutes();\r\n\t\t});\r\n\t}\r\n\r\n\tgetBasePath() {\r\n\t\treturn this.#basePath.getValue();\r\n\t}\r\n\tgetActivePath() {\r\n\t\treturn this.getBasePath() + '/' + this.#activeLocalPath;\r\n\t}\r\n\r\n\tpublic registerModal(registration: UmbModalRouteRegistration) {\r\n\t\tthis.#modalRegistrations.push(registration);\r\n\t\tthis.#createNewUrlBuilder(registration);\r\n\t\tthis.#generateModalRoutes();\r\n\t}\r\n\r\n\tpublic unregisterModal(registrationToken: UmbModalRouteRegistration) {\r\n\t\tconst index = this.#modalRegistrations.indexOf(registrationToken);\r\n\t\tif (index === -1) return;\r\n\t\tthis.#modalRegistrations.splice(index, 1);\r\n\t\tthis.#generateModalRoutes();\r\n\t}\r\n\r\n\t#generateRoute(modalRegistration: UmbModalRouteRegistration): UmbRoutePlusModalKey {\r\n\t\treturn {\r\n\t\t\t__modalKey: modalRegistration.key,\r\n\t\t\tpath: '/' + modalRegistration.generateModalPath(),\r\n\t\t\tcomponent: EmptyDiv,\r\n\t\t\tsetup: async (component, info) => {\r\n\t\t\t\tif (!this.#modalContext) return;\r\n\t\t\t\tconst modalContext = await modalRegistration.routeSetup(\r\n\t\t\t\t\tthis.#modalRouter,\r\n\t\t\t\t\tthis.#modalContext,\r\n\t\t\t\t\tinfo.match.params,\r\n\t\t\t\t);\r\n\t\t\t\tif (modalContext) {\r\n\t\t\t\t\tmodalContext._internal_setCurrentModalPath(info.match.fragments.consumed);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t};\r\n\t}\r\n\r\n\t_internal_removeModalPath(folderToRemove?: string) {\r\n\t\t// Reset the URL to the routerBasePath + routerActiveLocalPath [NL]\r\n\t\tif (folderToRemove && window.location.href.includes(folderToRemove)) {\r\n\t\t\tconst url = this.#basePath.getValue() + '/' + this.#activeLocalPath.getValue();\r\n\t\t\twindow.history.pushState({}, '', url);\r\n\t\t}\r\n\t}\r\n\r\n\t#generateModalRoutes() {\r\n\t\tconst newModals = this.#modalRegistrations.filter(\r\n\t\t\t(x) => !this.#modalRoutes.find((route) => x.key === route.__modalKey),\r\n\t\t);\r\n\t\tconst routesToRemove = this.#modalRoutes.filter(\r\n\t\t\t(route) => !this.#modalRegistrations.find((x) => x.key === route.__modalKey),\r\n\t\t);\r\n\t\t// If one the of the removed modals are active we should close it.\r\n\t\troutesToRemove.some((route) => {\r\n\t\t\tif (route.path === this.#activeModalPath) {\r\n\t\t\t\tthis.#modalContext?.close(route.__modalKey);\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t});\r\n\r\n\t\tconst cleanedRoutes = this.#modalRoutes.filter((route) => !routesToRemove.includes(route));\r\n\r\n\t\tthis.#modalRoutes = [\r\n\t\t\t...cleanedRoutes,\r\n\t\t\t...newModals.map((modalRegistration) => {\r\n\t\t\t\treturn this.#generateRoute(modalRegistration);\r\n\t\t\t}),\r\n\t\t];\r\n\r\n\t\t// Add an empty route, so there is a route for the router to react on when no modals are open.\r\n\t\tthis.#modalRoutes.push({\r\n\t\t\t__modalKey: '_empty_',\r\n\t\t\tpath: '',\r\n\t\t\tcomponent: EmptyDiv,\r\n\t\t});\r\n\r\n\t\t// TODO: Should we await one frame, to ensure we don't call back too much?.\r\n\t\tthis.#modalRouter.routes = this.#modalRoutes;\r\n\t\tthis.#modalRouter.render();\r\n\t}\r\n\r\n\tpublic _internal_routerGotBasePath(routerBasePath: string) {\r\n\t\tif (this.#basePath.getValue() === routerBasePath) return;\r\n\t\tthis.#basePath.setValue(routerBasePath);\r\n\t\tthis.#createNewUrlBuilders();\r\n\t}\r\n\r\n\tpublic _internal_routerGotActiveLocalPath(routerActiveLocalPath: string | undefined) {\r\n\t\tif (this.#activeLocalPath.getValue() === routerActiveLocalPath) return;\r\n\t\tthis.#activeLocalPath.setValue(routerActiveLocalPath);\r\n\t\tthis.#createNewUrlBuilders();\r\n\t}\r\n\r\n\t// Also notice each registration should now hold its handler when its active.\r\n\tpublic _internal_modalRouterChanged(activeModalPath: string | undefined) {\r\n\t\tif (this.#activeModalPath === activeModalPath) return;\r\n\t\tif (this.#activeModalPath) {\r\n\t\t\t// If if there is a modal using the old path.\r\n\t\t\tconst activeModal = this.#modalRegistrations.find((registration) => {\r\n\t\t\t\treturn '/' + registration.generateModalPath() === this.#activeModalPath;\r\n\t\t\t});\r\n\t\t\tif (activeModal) {\r\n\t\t\t\tthis.#modalContext?.close(activeModal.key);\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.#activeModalPath = activeModalPath;\r\n\t}\r\n\r\n\t#createNewUrlBuilders() {\r\n\t\tthis.#modalRegistrations.forEach(this.#createNewUrlBuilder);\r\n\t}\r\n\r\n\t#createNewUrlBuilder = (modalRegistration: UmbModalRouteRegistration) => {\r\n\t\tconst routerBasePath = this.#basePath.getValue();\r\n\t\tif (!routerBasePath) return;\r\n\r\n\t\tconst activeLocalPath = this.#activeLocalPath.getValue();\r\n\r\n\t\tconst routeBasePath = routerBasePath.endsWith('/') ? routerBasePath : routerBasePath + '/';\r\n\t\tconst routeActiveLocalPath = activeLocalPath\r\n\t\t\t? activeLocalPath.endsWith('/')\r\n\t\t\t\t? activeLocalPath\r\n\t\t\t\t: activeLocalPath + '/'\r\n\t\t\t: '';\r\n\t\tconst localPath = routeBasePath + routeActiveLocalPath + modalRegistration.generateModalPath();\r\n\t\tconst urlBuilder = umbGenerateRoutePathBuilder(localPath);\r\n\r\n\t\tmodalRegistration._internal_setRouteBuilder(urlBuilder);\r\n\t};\r\n\r\n\toverride hostDisconnected(): void {\r\n\t\tsuper.hostDisconnected();\r\n\t\tthis._internal_modalRouterChanged(undefined);\r\n\t}\r\n}\r\n\r\nexport const UMB_ROUTE_CONTEXT = new UmbContextToken('UmbRouterContext');\r\n","import type { UmbRouterSlotElement } from './router-slot.element.js';\r\nimport { UUIEvent } from '@umbraco-cms/backoffice/external/uui';\r\nexport class UmbRouterSlotChangeEvent extends UUIEvent {\r\n\tstatic readonly CHANGE = 'change';\r\n\tconstructor() {\r\n\t\tsuper(UmbRouterSlotChangeEvent.CHANGE);\r\n\t}\r\n}\r\n","import type { UmbRouterSlotElement } from './router-slot.element.js';\r\nimport { UUIEvent } from '@umbraco-cms/backoffice/external/uui';\r\nexport class UmbRouterSlotInitEvent extends UUIEvent {\r\n\tstatic readonly INIT = 'init';\r\n\tconstructor() {\r\n\t\tsuper(UmbRouterSlotInitEvent.INIT);\r\n\t}\r\n}\r\n","import type { UmbRoutePathAddendum } from './route-path-addendum.interface.js';\r\nimport { UmbContextToken } from '@umbraco-cms/backoffice/context-api';\r\n\r\nexport const UMB_ROUTE_PATH_ADDENDUM_CONTEXT = new UmbContextToken('UmbRoutePathAddendum');\r\n","import type { UmbRoutePathAddendum } from './route-path-addendum.interface.js';\r\nimport { UMB_ROUTE_PATH_ADDENDUM_CONTEXT } from './route-path-addendum.context-token.js';\r\nimport { UmbContextBase } from '@umbraco-cms/backoffice/class-api';\r\nimport { UmbStringState } from '@umbraco-cms/backoffice/observable-api';\r\nimport type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';\r\n\r\nexport class UmbRoutePathAddendumResetContext\r\n\textends UmbContextBase\r\n\timplements UmbRoutePathAddendum\r\n{\r\n\t#appendum = new UmbStringState('');\r\n\treadonly addendum = this.#appendum.asObservable();\r\n\r\n\tconstructor(host: UmbControllerHost) {\r\n\t\tsuper(host, UMB_ROUTE_PATH_ADDENDUM_CONTEXT);\r\n\t}\r\n}\r\n","import '@umbraco-cms/backoffice/external/router-slot';\r\nimport { UmbRoutePathAddendumResetContext } from '../../contexts/route-path-addendum-reset.context.js';\r\nimport { UmbRouterSlotInitEvent } from './router-slot-init.event.js';\r\nimport { UmbRouterSlotChangeEvent } from './router-slot-change.event.js';\r\nimport type { UmbRoute } from './route.interface.js';\r\nimport { UmbRouteContext } from './route.context.js';\r\nimport { css, html, type PropertyValueMap, customElement, property } from '@umbraco-cms/backoffice/external/lit';\r\nimport { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';\r\nimport type { IRouterSlot } from '@umbraco-cms/backoffice/external/router-slot';\r\n\r\n/**\r\n * @element umb-router-slot\r\n * @description - Component for wrapping Router Slot element, providing some local events for implementation.\r\n * @augments UmbLitElement\r\n * @fires {UmbRouterSlotInitEvent} init - fires when the router is connected\r\n * @fires {UmbRouterSlotChangeEvent} change - fires when a path of this router is changed\r\n */\r\n@customElement('umb-router-slot')\r\nexport class UmbRouterSlotElement extends UmbLitElement {\r\n\t#router: IRouterSlot = document.createElement('router-slot') as IRouterSlot;\r\n\t#modalRouter: IRouterSlot = document.createElement('router-slot') as IRouterSlot;\r\n\t#listening = false;\r\n\r\n\t@property({ type: Boolean, attribute: 'inherit-addendum', reflect: false })\r\n\tpublic inheritAddendum?: boolean;\r\n\r\n\t@property({ attribute: false })\r\n\tpublic get routes(): UmbRoute[] | undefined {\r\n\t\treturn this.#router.routes;\r\n\t}\r\n\tpublic set routes(value: UmbRoute[] | undefined) {\r\n\t\tvalue ??= [];\r\n\t\tconst oldValue = this.#router.routes;\r\n\t\tif (\r\n\t\t\tvalue.length !== oldValue?.length ||\r\n\t\t\tvalue.filter((route) => oldValue?.findIndex((r) => r.path === route.path) === -1).length > 0\r\n\t\t) {\r\n\t\t\tthis.#router.routes = value;\r\n\t\t}\r\n\t}\r\n\r\n\t@property({ attribute: false })\r\n\tpublic get parent(): IRouterSlot | null | undefined {\r\n\t\treturn this.#router.parent;\r\n\t}\r\n\tpublic set parent(parent: IRouterSlot | null | undefined) {\r\n\t\tthis.#router.parent = parent;\r\n\t}\r\n\r\n\tprivate _routerPath?: string;\r\n\tpublic get absoluteRouterPath() {\r\n\t\treturn this._routerPath;\r\n\t}\r\n\r\n\tprivate _activeLocalPath?: string;\r\n\tpublic get localActiveViewPath() {\r\n\t\treturn this._activeLocalPath;\r\n\t}\r\n\r\n\tpublic get absoluteActiveViewPath() {\r\n\t\treturn this._routerPath + '/' + this._activeLocalPath;\r\n\t}\r\n\r\n\t#routeContext = new UmbRouteContext(this, this.#router, this.#modalRouter);\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tthis.#modalRouter.parent = this.#router;\r\n\t\tthis.#modalRouter.style.display = 'none';\r\n\t\tthis.#router.addEventListener('changestate', this._updateRouterPath.bind(this));\r\n\t\tthis.#router.appendChild(document.createElement('slot'));\r\n\t}\r\n\r\n\tprotected _constructAbsoluteRouterPath() {\r\n\t\treturn this.#router.constructAbsolutePath('') || '';\r\n\t}\r\n\r\n\tprotected _constructLocalRouterPath() {\r\n\t\treturn this.#router.match?.fragments.consumed ?? '';\r\n\t}\r\n\r\n\toverride connectedCallback() {\r\n\t\tif (this.inheritAddendum !== true) {\r\n\t\t\tnew UmbRoutePathAddendumResetContext(this);\r\n\t\t}\r\n\r\n\t\tsuper.connectedCallback();\r\n\t\t// Currently we have to set this every time as RouteSlot looks for its parent every-time it is connected. Aka it has not way to explicitly set the parent.\r\n\t\t// And we cannot insert the modal router as a slotted-child of the router, as it flushes its children on every route change.\r\n\t\tthis.#modalRouter.parent = this.#router;\r\n\t\tif (this.#listening === false) {\r\n\t\t\twindow.addEventListener('navigationsuccess', this._onNavigationChanged);\r\n\t\t\tthis.#listening = true;\r\n\t\t}\r\n\t}\r\n\r\n\toverride disconnectedCallback() {\r\n\t\tsuper.disconnectedCallback();\r\n\t\twindow.removeEventListener('navigationsuccess', this._onNavigationChanged);\r\n\t\tthis.#listening = false;\r\n\t}\r\n\r\n\tprotected override firstUpdated(_changedProperties: PropertyValueMap | Map): void {\r\n\t\tsuper.firstUpdated(_changedProperties);\r\n\t\tthis._updateRouterPath();\r\n\t}\r\n\r\n\tprotected _updateRouterPath() {\r\n\t\tconst newAbsolutePath = this._constructAbsoluteRouterPath();\r\n\t\tif (this._routerPath !== newAbsolutePath) {\r\n\t\t\tthis._routerPath = newAbsolutePath;\r\n\t\t\tthis.#routeContext._internal_routerGotBasePath(this._routerPath);\r\n\t\t\tthis.dispatchEvent(new UmbRouterSlotInitEvent());\r\n\r\n\t\t\tconst newActiveLocalPath = this._constructLocalRouterPath();\r\n\t\t\tif (this._activeLocalPath !== newActiveLocalPath) {\r\n\t\t\t\tthis._activeLocalPath = newActiveLocalPath;\r\n\t\t\t\tthis.#routeContext._internal_routerGotActiveLocalPath(this._activeLocalPath);\r\n\t\t\t\tthis.dispatchEvent(new UmbRouterSlotChangeEvent());\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tprivate _onNavigationChanged = (event?: any) => {\r\n\t\tif (event.detail.slot === this.#router) {\r\n\t\t\tconst newActiveLocalPath = this._constructLocalRouterPath();\r\n\t\t\tif (this._activeLocalPath !== newActiveLocalPath) {\r\n\t\t\t\tthis._activeLocalPath = newActiveLocalPath;\r\n\t\t\t\tthis.#routeContext._internal_routerGotActiveLocalPath(newActiveLocalPath);\r\n\t\t\t\tthis.dispatchEvent(new UmbRouterSlotChangeEvent());\r\n\t\t\t}\r\n\t\t} else if (event.detail.slot === this.#modalRouter) {\r\n\t\t\tconst newActiveModalLocalPath = this.#modalRouter.match?.route.path ?? '';\r\n\t\t\tthis.#routeContext._internal_modalRouterChanged(newActiveModalLocalPath);\r\n\t\t}\r\n\t};\r\n\r\n\toverride render() {\r\n\t\treturn html`${this.#router}${this.#modalRouter}`;\r\n\t}\r\n\r\n\tstatic override styles = [\r\n\t\tcss`\r\n\t\t\t:host {\r\n\t\t\t\tposition: relative;\r\n\t\t\t\theight: 100%;\r\n\t\t\t}\r\n\r\n\t\t\trouter-slot {\r\n\t\t\t\theight: 100%;\r\n\t\t\t}\r\n\t\t`,\r\n\t];\r\n}\r\n\r\ndeclare global {\r\n\tinterface HTMLElementTagNameMap {\r\n\t\t'umb-router-slot': UmbRouterSlotElement;\r\n\t}\r\n}\r\n","import type { UmbRoutePathAddendum } from './route-path-addendum.interface.js';\r\nimport { UMB_ROUTE_PATH_ADDENDUM_CONTEXT } from './route-path-addendum.context-token.js';\r\nimport { UmbContextBase } from '@umbraco-cms/backoffice/class-api';\r\nimport { UmbStringState } from '@umbraco-cms/backoffice/observable-api';\r\nimport type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';\r\n\r\nexport class UmbRoutePathAddendumContext\r\n\textends UmbContextBase\r\n\timplements UmbRoutePathAddendum\r\n{\r\n\t#parent?: string;\r\n\t#current?: string;\r\n\r\n\t#addendum = new UmbStringState(undefined);\r\n\treadonly addendum = this.#addendum.asObservable();\r\n\r\n\tconstructor(host: UmbControllerHost) {\r\n\t\tsuper(host, UMB_ROUTE_PATH_ADDENDUM_CONTEXT);\r\n\r\n\t\tthis.consumeContext(UMB_ROUTE_PATH_ADDENDUM_CONTEXT, (context) => {\r\n\t\t\tthis.observe(context.addendum, (addendum) => {\r\n\t\t\t\tthis.#parent = addendum;\r\n\t\t\t\tthis.#update();\r\n\t\t\t});\r\n\t\t}).skipHost();\r\n\t}\r\n\r\n\tsetAddendum(addendum: string | undefined) {\r\n\t\tthis.#current = addendum;\r\n\t\tthis.#update();\r\n\t}\r\n\r\n\t#update() {\r\n\t\tif (this.#parent === undefined || this.#current === undefined) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// if none of the strings are empty strings, then we should add a slash in front of the currentAddendum. So we get one in between.\r\n\t\tconst add = this.#current === '' || this.#parent === '' ? this.#current : '/' + this.#current;\r\n\t\tthis.#addendum.setValue(this.#parent + add);\r\n\t}\r\n}\r\n","export const encodeFolderName = (path: string) =>\r\n\tencodeURIComponent(path.toLowerCase().replace(/\\s+/g, '-'))\r\n\t\t.replace(/_/g, '-')\r\n\t\t.replace(/\\./g, '-')\r\n\t\t.replace(/!/g, '-')\r\n\t\t.replace(/~/g, '-')\r\n\t\t.replace(/\\*/g, '-')\r\n\t\t.replace(/'/g, '')\r\n\t\t.replace(/\\(/g, '-')\r\n\t\t.replace(/\\)/g, '-');\r\n","import { UMB_ROUTE_CONTEXT, UMB_ROUTE_PATH_ADDENDUM_CONTEXT } from '../index.js';\r\nimport { encodeFolderName } from '../encode-folder-name.function.js';\r\nimport type { UmbModalRouteRegistration } from './modal-route-registration.interface.js';\r\nimport type {\r\n\tUmbModalConfig,\r\n\tUmbModalContext,\r\n\tUmbModalContextClassArgs,\r\n\tUmbModalManagerContext,\r\n\tUmbModalToken,\r\n} from '@umbraco-cms/backoffice/modal';\r\nimport type { UmbControllerAlias, UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';\r\nimport { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';\r\nimport { UmbId } from '@umbraco-cms/backoffice/id';\r\nimport type { UmbDeepPartialObject } from '@umbraco-cms/backoffice/utils';\r\nimport type { IRouterSlot, Params } from '@umbraco-cms/backoffice/external/router-slot';\r\n\r\nexport type UmbModalRouteBuilder = (params: { [key: string]: string | number } | null) => string;\r\n\r\nexport type UmbModalRouteSetupReturn = UmbModalTokenValue extends undefined\r\n\t? UmbModalTokenValue extends undefined\r\n\t\t? {\r\n\t\t\t\tmodal?: UmbDeepPartialObject;\r\n\t\t\t\tdata?: UmbDeepPartialObject;\r\n\t\t\t\tvalue?: UmbModalTokenValue;\r\n\t\t\t}\r\n\t\t: {\r\n\t\t\t\tmodal?: UmbDeepPartialObject;\r\n\t\t\t\tdata?: UmbDeepPartialObject;\r\n\t\t\t\tvalue: UmbModalTokenValue;\r\n\t\t\t}\r\n\t: UmbModalTokenValue extends undefined\r\n\t\t? {\r\n\t\t\t\tmodal?: UmbDeepPartialObject;\r\n\t\t\t\tdata: UmbDeepPartialObject;\r\n\t\t\t\tvalue?: UmbModalTokenValue;\r\n\t\t\t}\r\n\t\t: {\r\n\t\t\t\tmodal?: UmbDeepPartialObject;\r\n\t\t\t\tdata: UmbDeepPartialObject;\r\n\t\t\t\tvalue: UmbModalTokenValue;\r\n\t\t\t};\r\nexport class UmbModalRouteRegistrationController<\r\n\t\tUmbModalTokenData extends { [key: string]: any } = { [key: string]: any },\r\n\t\tUmbModalTokenValue = unknown,\r\n\t>\r\n\textends UmbControllerBase\r\n\timplements UmbModalRouteRegistration\r\n{\r\n\t//\r\n\t#init;\r\n\t#contextConsumer;\r\n\r\n\t#addendum?: string;\r\n\t#additionalPath?: string;\r\n\t#uniquePaths: Map = new Map();\r\n\r\n\t#routeContext?: typeof UMB_ROUTE_CONTEXT.TYPE;\r\n\t#modalRegistrationContext?: typeof UMB_ROUTE_CONTEXT.TYPE;\r\n\r\n\t#key: string;\r\n\t#path?: string;\r\n\t#modalAlias: UmbModalToken | string;\r\n\r\n\t#onSetupCallback?: (\r\n\t\troutingInfo: Params,\r\n\t) =>\r\n\t\t| Promise | false>\r\n\t\t| UmbModalRouteSetupReturn\r\n\t\t| false;\r\n\t#onSubmitCallback?: (value: UmbModalTokenValue, data?: UmbModalTokenData) => void;\r\n\t#onRejectCallback?: () => void;\r\n\r\n\t#modalContext: UmbModalContext | undefined;\r\n\t#routeBuilder?: UmbModalRouteBuilder;\r\n\t#urlBuilderCallback: ((urlBuilder: UmbModalRouteBuilder) => void) | undefined;\r\n\r\n\t/**\r\n\t * Creates an instance of UmbModalRouteRegistrationController.\r\n\t * @param {UmbControllerHost} host - The host element of the modal, this determine the ownership of the modal and the origin of it.\r\n\t * @param {UmbModalToken} alias - The alias of the modal, this is used to identify the modal.\r\n\t * @param {UmbControllerAlias} ctrlAlias - The alias for this controller, this is used to identify the controller.\r\n\t * @memberof UmbModalRouteRegistrationController\r\n\t */\r\n\tconstructor(\r\n\t\thost: UmbControllerHost,\r\n\t\talias: UmbModalToken | string,\r\n\t\tctrlAlias?: UmbControllerAlias,\r\n\t) {\r\n\t\tsuper(host, ctrlAlias ?? alias.toString());\r\n\t\tthis.#key = UmbId.new();\r\n\t\tthis.#modalAlias = alias;\r\n\r\n\t\tthis.consumeContext(UMB_ROUTE_PATH_ADDENDUM_CONTEXT, (context) => {\r\n\t\t\tthis.observe(\r\n\t\t\t\tcontext.addendum,\r\n\t\t\t\t(addendum) => {\r\n\t\t\t\t\tthis.#addendum = addendum;\r\n\t\t\t\t\tthis.#registerModal();\r\n\t\t\t\t},\r\n\t\t\t\t'observeAddendum',\r\n\t\t\t);\r\n\t\t});\r\n\r\n\t\tthis.#contextConsumer = this.consumeContext(UMB_ROUTE_CONTEXT, (_routeContext) => {\r\n\t\t\tthis.#routeContext = _routeContext;\r\n\t\t\tthis.#registerModal();\r\n\t\t});\r\n\t\tthis.#init = this.#contextConsumer.asPromise();\r\n\t}\r\n\r\n\t/**\r\n\t * Appends an additional path to the modal route.\r\n\t *\r\n\t * This can help specify the URL for this modal, or used to add a parameter to the URL like this: \"/modal/my-modal/:index/\"\r\n\t * A folder name starting with a colon \":\" will be interpreted as a parameter. Then this modal can open with any value in that location.\r\n\t * When modal is being setup the value of the parameter can be read from the route params. See the example:\r\n\t * @param {string} additionalPath - The additional path to be appended to the modal route\r\n\t * @returns {UmbModalRouteRegistrationController} this\r\n\t * @example Example of adding an additional path to the modal route\r\n\t * const modalRegistration = new UmbModalRouteRegistrationController(this, MY_MODAL_TOKEN)\r\n\t * modalRegistration.addAdditionalPath(':index')\r\n\t *\r\n\t * modalRegistration.onSetup((params) => {\r\n\t * \tconst index = params.index;\r\n\t * // When entering the url of: \"/modal/my-modal/hello-world/\"\r\n\t * // Then index will be \"hello-world\"\r\n\t * }\r\n\t */\r\n\tpublic addAdditionalPath(additionalPath: string) {\r\n\t\tthis.#additionalPath = additionalPath;\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Registerer one or more additional paths to the modal route, similar to addAdditionalPath. But without defining the actual path name. This enables this to be asynchronously defined and even changed later.\r\n\t * This can be useful if your modal has to be unique for this registration, avoiding collision with other registrations.\r\n\t * If you made a modal for editing one of multiple property, then you can add a unique path holding the property id.\r\n\t * Making the URL unique to this modal registration: /modal/my-modal/my-unique-value/\r\n\t *\r\n\t * Notice the modal will only be available when all unique paths have a value.\r\n\t * @param {Array} uniquePathNames - the unique path names\r\n\t * @returns {UmbModalRouteRegistrationController} this\r\n\t * @example Example of adding an additional unique path to the modal route\r\n\t * const modalRegistration = new UmbModalRouteRegistrationController(this, MY_MODAL_TOKEN)\r\n\t * modalRegistration.addUniquePaths(['myAliasForIdentifyingThisPartOfThePath'])\r\n\t *\r\n\t * // Later:\r\n\t * modalRegistration.setUniquePathValue('myAliasForIdentifyingThisPartOfThePath', 'myValue');\r\n\t */\r\n\tpublic addUniquePaths(uniquePathNames: Array) {\r\n\t\tif (uniquePathNames) {\r\n\t\t\tuniquePathNames.forEach((name) => {\r\n\t\t\t\tthis.#uniquePaths.set(name, undefined);\r\n\t\t\t});\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Set or change the value of a unique path part.\r\n\t * @param {string} identifier - the unique path part identifier\r\n\t * @param {value | undefined} value - the new value for the unique path part\r\n\t * @example Example of adding an additional unique path to the modal route\r\n\t * const modalRegistration = new UmbModalRouteRegistrationController(this, MY_MODAL_TOKEN)\r\n\t * modalRegistration.addUniquePaths(['first-one', 'another-one'])\r\n\t *\r\n\t * // Later:\r\n\t * modalRegistration.setUniquePathValue('first-one', 'myValue');\r\n\t */\r\n\tsetUniquePathValue(identifier: string, value: string | undefined) {\r\n\t\tif (!this.#uniquePaths.has(identifier)) {\r\n\t\t\tthrow new Error(\r\n\t\t\t\t`Identifier ${identifier} was not registered at the construction of the modal registration controller, it has to be.`,\r\n\t\t\t);\r\n\t\t}\r\n\t\tconst oldValue = this.#uniquePaths.get(identifier);\r\n\t\tif (oldValue === value) return;\r\n\r\n\t\tthis.#uniquePaths.set(identifier, value);\r\n\t\tthis.#registerModal();\r\n\t}\r\n\tgetUniquePathValue(identifier: string): string | undefined {\r\n\t\treturn this.#uniquePaths.get(identifier);\r\n\t}\r\n\r\n\tasync #registerModal() {\r\n\t\tawait this.#init;\r\n\t\tif (!this.#routeContext) return;\r\n\t\tif (this.#addendum === undefined) return;\r\n\r\n\t\tconst pathParts = Array.from(this.#uniquePaths.values());\r\n\r\n\t\t// Check if there is any undefined values of unique map:\r\n\t\tif (pathParts.some((value) => value === undefined)) {\r\n\t\t\tthis.#unregisterModal();\r\n\t\t}\r\n\r\n\t\tif (this.#addendum !== '') {\r\n\t\t\t// append in the start of pathParts:\r\n\t\t\tpathParts.unshift(this.#addendum);\r\n\t\t}\r\n\r\n\t\tif (this.#additionalPath) {\r\n\t\t\t// Add the configured part of the path:\r\n\t\t\tpathParts.push(this.#additionalPath);\r\n\t\t}\r\n\r\n\t\tconst newPath = pathParts.join('/') ?? '';\r\n\r\n\t\t// if no changes then break out:\r\n\t\t// We test for both path and context changes [NL]\r\n\t\tif (this.path === newPath && this.#modalRegistrationContext === this.#routeContext) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Clean up if it already exists:\r\n\t\tthis.#unregisterModal();\r\n\r\n\t\t// Make this the path of the modal registration:\r\n\t\tthis._setPath(newPath);\r\n\r\n\t\tthis.#routeContext.registerModal(this);\r\n\t\t// Store which context we used and use this as 'if registered', so we can know if it changed.\r\n\t\tthis.#modalRegistrationContext = this.#routeContext;\r\n\t}\r\n\r\n\tasync #unregisterModal() {\r\n\t\tif (!this.#routeContext) return;\r\n\t\tif (this.#modalRegistrationContext) {\r\n\t\t\tthis.#modalRegistrationContext.unregisterModal(this);\r\n\t\t\tthis.#modalRegistrationContext = undefined;\r\n\t\t}\r\n\t}\r\n\r\n\toverride hostConnected() {\r\n\t\tsuper.hostConnected();\r\n\t\tif (!this.#modalRegistrationContext) {\r\n\t\t\tthis.#registerModal();\r\n\t\t}\r\n\t}\r\n\toverride hostDisconnected(): void {\r\n\t\tsuper.hostDisconnected();\r\n\t\tif (this.#modalRegistrationContext) {\r\n\t\t\tthis.#modalRegistrationContext.unregisterModal(this);\r\n\t\t\tthis.#modalRegistrationContext = undefined;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic get key() {\r\n\t\treturn this.#key;\r\n\t}\r\n\r\n\tpublic get alias() {\r\n\t\treturn this.#modalAlias;\r\n\t}\r\n\r\n\tpublic generateModalPath() {\r\n\t\treturn `modal/${encodeFolderName(this.alias.toString())}${this.path && this.path !== '' ? `/${this.path}` : ''}`;\r\n\t}\r\n\r\n\tpublic get path() {\r\n\t\treturn this.#path;\r\n\t}\r\n\r\n\tprotected _setPath(path: string | undefined) {\r\n\t\tthis.#path = path;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns true if the modal is currently active.\r\n\t * @returns {boolean} - true if the modal is currently active, false otherwise.\r\n\t */\r\n\tpublic get active() {\r\n\t\treturn !!this.#modalContext;\r\n\t}\r\n\r\n\tpublic open(params: { [key: string]: string | number }, prepend?: string) {\r\n\t\tif (this.active || !this.#routeBuilder) return;\r\n\r\n\t\twindow.history.pushState({}, '', this.#routeBuilder(params) + (prepend ? `${prepend}` : ''));\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the modal context if the modal is currently active. Otherwise its undefined.\r\n\t * @returns {UmbModalContext | undefined} - modal context if the modal is active, otherwise undefined.\r\n\t */\r\n\tpublic get modalContext() {\r\n\t\treturn this.#modalContext;\r\n\t}\r\n\r\n\tpublic observeRouteBuilder(callback: (urlBuilder: UmbModalRouteBuilder) => void) {\r\n\t\tthis.#urlBuilderCallback = callback;\r\n\t\treturn this;\r\n\t}\r\n\tpublic _internal_setRouteBuilder(urlBuilder: UmbModalRouteBuilder) {\r\n\t\tif (!this.#routeContext) return;\r\n\t\tthis.#routeBuilder = urlBuilder;\r\n\t\tthis.#urlBuilderCallback?.(urlBuilder);\r\n\t}\r\n\r\n\tpublic onSetup(\r\n\t\tcallback: (\r\n\t\t\troutingInfo: Params,\r\n\t\t) =>\r\n\t\t\t| Promise | false>\r\n\t\t\t| UmbModalRouteSetupReturn\r\n\t\t\t| false,\r\n\t) {\r\n\t\tthis.#onSetupCallback = callback;\r\n\t\treturn this;\r\n\t}\r\n\tpublic onSubmit(callback: (value: UmbModalTokenValue, data?: UmbModalTokenData) => void) {\r\n\t\tthis.#onSubmitCallback = callback;\r\n\t\treturn this;\r\n\t}\r\n\tpublic onReject(callback: () => void) {\r\n\t\tthis.#onRejectCallback = callback;\r\n\t\treturn this;\r\n\t}\r\n\r\n\t#onSubmit = (value: UmbModalTokenValue) => {\r\n\t\tthis.#onSubmitCallback?.(value, this.#modalContext?.data);\r\n\t\tthis.#modalContext = undefined;\r\n\t};\r\n\t#onReject = () => {\r\n\t\tthis.#onRejectCallback?.();\r\n\t\tthis.#modalContext = undefined;\r\n\t};\r\n\r\n\tasync routeSetup(router: IRouterSlot, modalManagerContext: UmbModalManagerContext, params: Params) {\r\n\t\t// If already open, don't do anything:\r\n\t\tif (this.active) return;\r\n\r\n\t\tconst modalData = this.#onSetupCallback ? await this.#onSetupCallback(params) : undefined;\r\n\t\tif (modalData !== false) {\r\n\t\t\tconst args = {\r\n\t\t\t\tmodal: {},\r\n\t\t\t\t...modalData,\r\n\t\t\t\trouter,\r\n\t\t\t} as UmbModalContextClassArgs>;\r\n\t\t\targs.modal!.key = this.#key;\r\n\r\n\t\t\tthis.#modalContext = modalManagerContext.open(this, this.#modalAlias, args);\r\n\t\t\tthis.#modalContext.onSubmit().then(this.#onSubmit, this.#onReject);\r\n\t\t\treturn this.#modalContext;\r\n\t\t}\r\n\t\treturn;\r\n\t}\r\n\r\n\tpublic override destroy(): void {\r\n\t\tsuper.destroy();\r\n\t\tthis.#contextConsumer.destroy();\r\n\t\tthis.#modalRegistrationContext = undefined;\r\n\t\tthis.#uniquePaths = undefined as any;\r\n\t\tthis.#routeContext = undefined;\r\n\t}\r\n}\r\n"],"names":["UmbRouteNotFoundElement","UmbLitElement","html","UmbTextStyles","css","__decorateClass","customElement","umbGenerateRoutePathBuilder","path","params","stripSlash","umbUrlPatternToString","EmptyDiv","UmbRouteContext","UmbContextBase","host","mainRouter","modalRouter","UMB_ROUTE_CONTEXT","#modalRegistrations","#modalRoutes","#basePath","UmbStringState","#activeLocalPath","mergeObservables","basePath","localPath","#createNewUrlBuilder","modalRegistration","routerBasePath","activeLocalPath","routeBasePath","routeActiveLocalPath","urlBuilder","#modalRouter","UMB_MODAL_MANAGER_CONTEXT","context","#modalContext","#generateModalRoutes","#activeModalPath","registration","registrationToken","index","#generateRoute","component","info","modalContext","folderToRemove","url","newModals","x","route","routesToRemove","cleanedRoutes","#createNewUrlBuilders","routerActiveLocalPath","activeModalPath","activeModal","UmbContextToken","UmbRouterSlotChangeEvent","UUIEvent","UmbRouterSlotInitEvent","UMB_ROUTE_PATH_ADDENDUM_CONTEXT","UmbRoutePathAddendumResetContext","#appendum","_router","_modalRouter","_listening","_routeContext","UmbRouterSlotElement","__privateAdd","__privateGet","event","newActiveLocalPath","newActiveModalLocalPath","value","oldValue","parent","__privateSet","_changedProperties","newAbsolutePath","property","UmbRoutePathAddendumContext","#addendum","addendum","#parent","#update","#current","add","encodeFolderName","UmbModalRouteRegistrationController","UmbControllerBase","#init","#contextConsumer","#additionalPath","#uniquePaths","#routeContext","#modalRegistrationContext","#key","#path","#modalAlias","#onSetupCallback","#onSubmitCallback","#onRejectCallback","#routeBuilder","#urlBuilderCallback","alias","ctrlAlias","UmbId","#registerModal","additionalPath","uniquePathNames","name","identifier","pathParts","#unregisterModal","newPath","prepend","callback","#onSubmit","#onReject","router","modalManagerContext","modalData","args"],"mappings":";;;;;;;;;;;;;;;;;;AAS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