{"version":3,"file":"workspace-menu-breadcrumb.element-Cdut6iUv.js","sources":["../../../src/packages/core/workspace/components/workspace-breadcrumb/workspace-menu-breadcrumb/workspace-menu-breadcrumb.element.ts"],"sourcesContent":["import { css, customElement, html, ifDefined, map, state } from '@umbraco-cms/backoffice/external/lit';\nimport { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';\nimport { UmbTextStyles } from '@umbraco-cms/backoffice/style';\nimport { UMB_SECTION_CONTEXT } from '@umbraco-cms/backoffice/section';\nimport { UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace';\nimport type { UmbMenuStructureWorkspaceContext, UmbStructureItemModel } from '@umbraco-cms/backoffice/menu';\n\n@customElement('umb-workspace-breadcrumb')\nexport class UmbWorkspaceBreadcrumbElement extends UmbLitElement {\n\t@state()\n\t_name: string = '';\n\n\t@state()\n\t_structure: UmbStructureItemModel[] = [];\n\n\t// TODO: figure out the correct context type\n\t#workspaceContext?: any;\n\t#sectionContext?: typeof UMB_SECTION_CONTEXT.TYPE;\n\t#structureContext?: UmbMenuStructureWorkspaceContext;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.consumeContext(UMB_SECTION_CONTEXT, (instance) => {\n\t\t\tthis.#sectionContext = instance;\n\t\t});\n\n\t\tthis.consumeContext(UMB_WORKSPACE_CONTEXT, (instance) => {\n\t\t\tthis.#workspaceContext = instance as any;\n\t\t\tthis.#observeStructure();\n\t\t\tthis.#observeName();\n\t\t});\n\n\t\t// TODO: set up context token\n\t\tthis.consumeContext('UmbMenuStructureWorkspaceContext', (instance) => {\n\t\t\t// TODO: get the correct interface from the context token\n\t\t\tthis.#structureContext = instance as UmbMenuStructureWorkspaceContext;\n\t\t\tthis.#observeStructure();\n\t\t});\n\t}\n\n\t#observeStructure() {\n\t\tif (!this.#structureContext || !this.#workspaceContext) return;\n\t\tconst isNew = this.#workspaceContext.getIsNew();\n\n\t\tthis.observe(\n\t\t\tthis.#structureContext.structure,\n\t\t\t(value) => {\n\t\t\t\t// TODO: get the type from the context\n\t\t\t\tconst structure = value as Array;\n\t\t\t\tthis._structure = isNew ? structure : structure.slice(0, -1);\n\t\t\t},\n\t\t\t'menuStructureObserver',\n\t\t);\n\t}\n\n\t#observeName() {\n\t\tthis.observe(\n\t\t\tthis.#workspaceContext?.name,\n\t\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t\t// @ts-ignore\n\t\t\t(value) => (this._name = value || ''),\n\t\t\t'breadcrumbWorkspaceNameObserver',\n\t\t);\n\t}\n\n\t#getHref(structureItem: UmbStructureItemModel) {\n\t\tconst workspaceBasePath = `section/${this.#sectionContext?.getPathname()}/workspace/${structureItem.entityType}/edit`;\n\t\treturn structureItem.isFolder ? undefined : `${workspaceBasePath}/${structureItem.unique}`;\n\t}\n\n\toverride render() {\n\t\treturn html`\n\t\t\t\n\t\t\t\t${map(\n\t\t\t\t\tthis._structure,\n\t\t\t\t\t(structureItem) =>\n\t\t\t\t\t\thtml`${this.localize.string(structureItem.name)}`,\n\t\t\t\t)}\n\t\t\t\t${this._name}\n\t\t\t\n\t\t`;\n\t}\n\n\tstatic override styles = [\n\t\tUmbTextStyles,\n\t\tcss`\n\t\t\t:host {\n\t\t\t\tmargin-left: var(--uui-size-layout-1);\n\t\t\t}\n\t\t`,\n\t];\n}\n\nexport default UmbWorkspaceBreadcrumbElement;\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'umb-workspace-breadcrumb': UmbWorkspaceBreadcrumbElement;\n\t}\n}\n"],"names":["_workspaceContext","_sectionContext","_structureContext","_UmbWorkspaceBreadcrumbElement_instances","observeStructure_fn","observeName_fn","getHref_fn","UmbWorkspaceBreadcrumbElement","UmbLitElement","__privateAdd","UMB_SECTION_CONTEXT","instance","__privateSet","UMB_WORKSPACE_CONTEXT","__privateMethod","html","map","structureItem","ifDefined","__privateGet","isNew","value","structure","workspaceBasePath","UmbTextStyles","css","__decorateClass","state","customElement","UmbWorkspaceBreadcrumbElement$1"],"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