var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { UmbWorkspaceSplitViewContext } from './workspace-split-view.context.js';
import { css, customElement, html, ifDefined, nothing, property, state, when, } from '../../../../../external/lit/index.js';
import { UmbLitElement } from '../../../lit-element/index.js';
import { UmbTextStyles } from '../../../style/index.js';
// import local components
import './workspace-split-view-variant-selector.element.js';
/**
 *
 * Example. Document Workspace would use a Variant-component(variant component would talk directly to the workspace-context)
 * As well breadcrumbs etc.
 *
 */
let UmbWorkspaceSplitViewElement = class UmbWorkspaceSplitViewElement extends UmbLitElement {
    set splitViewIndex(index) {
        this.splitViewContext.setSplitViewIndex(index);
    }
    get splitViewIndex() {
        return this.splitViewContext.getSplitViewIndex();
    }
    #onVariantSelectorSlotChanged(e) {
        this._variantSelectorSlotHasContent = e.target.assignedNodes({ flatten: true }).length > 0;
    }
    constructor() {
        super();
        this.loading = false;
        this.displayNavigation = false;
        this._variantSelectorSlotHasContent = false;
        this._isNew = false;
        this.splitViewContext = new UmbWorkspaceSplitViewContext(this);
        this.observe(this.splitViewContext.isNew, (isNew) => {
            this._isNew = isNew ?? false;
        }, null);
        this.observe(this.splitViewContext.variantId, (variantId) => {
            this._variantId = variantId;
        }, null);
    }
    render() {
        return html `
			<umb-workspace-editor
				.loading=${this.loading}
				back-path=${ifDefined(this.backPath)}
				.hideNavigation=${!this.displayNavigation}
				.variantId=${this._variantId}
				.overrides=${this.overrides}
				.enforceNoFooter=${true}>
				<slot id="icon" name="icon" slot="header"></slot>
				<slot id="header" name="variant-selector" slot="header" @slotchange=${this.#onVariantSelectorSlotChanged}>
					${when(!this._variantSelectorSlotHasContent, () => html `<umb-workspace-split-view-variant-selector></umb-workspace-split-view-variant-selector>`)}
				</slot>
				${this.#renderEntityActions()}
				<slot name="action-menu" slot="action-menu"></slot>
			</umb-workspace-editor>
		`;
    }
    #renderEntityActions() {
        if (this._isNew)
            return nothing;
        if (!this.displayNavigation)
            return nothing;
        return html `<umb-workspace-entity-action-menu
			slot="action-menu"
			data-mark="workspace:action-menu"></umb-workspace-entity-action-menu>`;
    }
    static { this.styles = [
        UmbTextStyles,
        css `
			:host {
				display: block;
				width: 100%;
				height: 100%;
				min-width: 0;
			}

			:host(:not(:last-child)) {
				border-right: 1px solid var(--uui-color-border);
			}

			#header {
				flex: 1 1 auto;
				display: block;
			}

			#icon {
				display: inline-block;
				font-size: var(--uui-size-6);
				margin-right: var(--uui-size-space-4);
			}
		`,
    ]; }
};
__decorate([
    property({ type: Boolean })
], UmbWorkspaceSplitViewElement.prototype, "loading", void 0);
__decorate([
    property({ type: Boolean })
], UmbWorkspaceSplitViewElement.prototype, "displayNavigation", void 0);
__decorate([
    property({ attribute: 'back-path' })
], UmbWorkspaceSplitViewElement.prototype, "backPath", void 0);
__decorate([
    property({ attribute: false })
], UmbWorkspaceSplitViewElement.prototype, "overrides", void 0);
__decorate([
    property({ type: Number })
], UmbWorkspaceSplitViewElement.prototype, "splitViewIndex", null);
__decorate([
    state()
], UmbWorkspaceSplitViewElement.prototype, "_variantSelectorSlotHasContent", void 0);
__decorate([
    state()
], UmbWorkspaceSplitViewElement.prototype, "_isNew", void 0);
__decorate([
    state()
], UmbWorkspaceSplitViewElement.prototype, "_variantId", void 0);
UmbWorkspaceSplitViewElement = __decorate([
    customElement('umb-workspace-split-view')
], UmbWorkspaceSplitViewElement);
export { UmbWorkspaceSplitViewElement };
export default UmbWorkspaceSplitViewElement;
