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 { UmbDocumentDetailRepository } from '../../../repository/index.js';
import { html, customElement, css, state } from '../../../../../../external/lit/index.js';
import { UmbTextStyles } from '../../../../../core/style/index.js';
import { UmbModalBaseElement } from '../../../../../core/modal/index.js';
let UmbCreateBlueprintModalElement = class UmbCreateBlueprintModalElement extends UmbModalBaseElement {
    constructor() {
        super(...arguments);
        this.#documentRepository = new UmbDocumentDetailRepository(this);
        this.#documentUnique = '';
        this._documentName = '';
        this._blueprintName = '';
    }
    #documentRepository;
    #documentUnique;
    firstUpdated() {
        this.#documentUnique = this.data?.unique ?? '';
        this.#getDocumentData();
    }
    async #getDocumentData() {
        const { data } = await this.#documentRepository.requestByUnique(this.#documentUnique);
        if (!data)
            return;
        this._documentName = data.variants[0].name;
        this._blueprintName = data.variants[0].name;
    }
    async #handleSave() {
        this.value = { name: this._blueprintName, parent: null };
        this.modalContext?.submit();
    }
    render() {
        return html `
			<umb-body-layout headline=${this.localize.term('actions_createblueprint')}>
				<uui-box id="tree-box" headline=${this.localize.term('blueprints_createBlueprintFrom', this._documentName)}>
					<umb-localize key="blueprints_blueprintDescription"></umb-localize>
					<umb-property-layout label=${this.localize.term('general_name')} orientation="vertical">
						<div slot="editor">
							<uui-input
								id="name"
								label="name"
								.value=${this._blueprintName}
								@input=${(e) => (this._blueprintName = e.target.value)}></uui-input>
						</div>
					</umb-property-layout>
				</uui-box>
				<uui-button
					slot="actions"
					id="close"
					label=${this.localize.term('general_close')}
					@click="${this.#handleClose}"></uui-button>
				<uui-button
					slot="actions"
					id="save"
					look="primary"
					color="positive"
					label=${this.localize.term('buttons_save')}
					@click="${this.#handleSave}"></uui-button>
			</umb-body-layout>
		`;
    }
    #handleClose() {
        this.modalContext?.reject();
    }
    static { this.styles = [
        UmbTextStyles,
        css `
			strong,
			uui-label,
			uui-input {
				width: 100%;
			}

			uui-label {
				margin-top: var(--uui-size-space-6);
			}
		`,
    ]; }
};
__decorate([
    state()
], UmbCreateBlueprintModalElement.prototype, "_documentName", void 0);
__decorate([
    state()
], UmbCreateBlueprintModalElement.prototype, "_blueprintName", void 0);
UmbCreateBlueprintModalElement = __decorate([
    customElement('umb-create-blueprint-modal')
], UmbCreateBlueprintModalElement);
export { UmbCreateBlueprintModalElement };
export default UmbCreateBlueprintModalElement;
