import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
import { L as Locale } from './locale.js';
import { d as defineCustomElement$2 } from './gx-ide-empty-state2.js';

const KB_OBJECT_TYPE = "type";
const KB_OBJECT = "object";
const convertObjectDataToTreeItem = (objectTypeIcon, objectItems) => {
    return objectItems.map(objectItem => ({
        id: objectItem.id,
        caption: objectItem.name,
        startImgSrc: objectTypeIcon,
        expanded: true,
        leaf: true,
        metadata: KB_OBJECT
    }));
};
const convertObjectTypeDataToTreeView = (objectTypeData) => {
    const treeData = [];
    if (!objectTypeData) {
        return treeData;
    }
    for (const objectType of objectTypeData) {
        if (objectType.items.length > 0) {
            treeData.push({
                id: objectType.id,
                caption: objectType.name,
                startImgSrc: objectType.icon,
                expanded: true,
                leaf: false,
                metadata: KB_OBJECT_TYPE,
                items: convertObjectDataToTreeItem(objectType.icon, objectType.items)
            });
        }
    }
    return treeData;
};
const createArrayOfItems = (objectItems, objectTypes) => {
    // The resulting array with 'items' property added to each type
    const objectTypesWithItems = objectTypes.map(type => {
        // Filter objects that match the current type id
        const items = objectItems.filter(object => object.type === type.id);
        // Return a new object type with the 'items' property
        return Object.assign(Object.assign({}, type), { items: items });
    });
    const treeView = convertObjectTypeDataToTreeView(objectTypesWithItems);
    return treeView;
};

const deploymentToolCss = ":host{display:grid;block-size:100%}.opacity-0{opacity:0}.gxi-hidden{display:none !important}.align-center{display:flex;align-items:center}.align-end{display:flex;align-items:end}.overflow-auto{overflow:auto}:host(.gx-ide-component){height:100% !important;display:flex !important;flex-direction:column !important}.gx-ide-main-wrapper{color:var(--gx-ide-component-text-color);font-weight:var(--font-style-regular);font-size:var(--font-size-body-m);font-family:var(--font-family-body);height:100%;display:flex;flex-direction:column;flex-grow:1;box-sizing:border-box}.buttons-container{display:flex;gap:var(--spacing-gap-m)}.giu-static-pill-icon-and-text,.giu-static-pill{background-color:var(--elevation-background-color, var(--color-accent-surface-elevation-1));padding-inline:var(--spacing-padding-m);color:var(--color-text-neutral-default);font-size:var(--font-size-body-s);line-height:var(--line-height-relaxed);font-weight:var(--font-style-regular);border-radius:4px;min-block-size:25px;display:inline-grid;align-items:center;pointer-events:none;inline-size:max-content}.giu-static-pill-icon-and-text{display:inline-grid;grid-auto-flow:column;grid-auto-columns:max-content;gap:var(--spacing-gap-m)}.tab-full-width-buttons::part(tab-list block-start),.tab-full-width-buttons::part(tab-list block-end){grid-auto-columns:1fr}.tab-full-width-buttons::part(tab block-start){justify-content:center}.tree-view::part(item__header){--icon__system_warning_warning--disabled:var(\n    --icon__system_warning_warning--enabled\n  )}.tabular-grid{--focus-outline-width:1px}:host{display:grid;block-size:100%;grid-template-rows:max-content 1fr max-content}.header{display:grid;padding:var(--gxg-container--padding);gap:var(--spacing-gap-l);grid-template-columns:1fr auto;margin-block-end:16px}.header :nth-child(2){align-self:self-end}.deploy-properties{display:grid;grid-auto-rows:max-content;grid-template-columns:max-content 1fr max-content;align-items:center;border-block-start:var(--section-common-border);padding-block-start:16px}.label.target-types{grid-column:1}.target-types-combo{grid-column:2}.target-types-button-checkbox-wrapper{grid-column:3}.label.application-server{grid-column:1}.application-server-combo{grid-column:2}.label.generator{grid-column:1}.generator-combo{grid-column:2}.target-type__description{grid-column:2}.label.display-name{grid-column:1}.display-name-input{grid-column:2}.footer{margin-block-start:16px}";

var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m")
        throw new TypeError("Private method is not writable");
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _GxIdeDeploymentTool_instances, _GxIdeDeploymentTool_componentLocale, _GxIdeDeploymentTool_renderedFirstTime, _GxIdeDeploymentTool_flattenedObjectTypeData, _GxIdeDeploymentTool_currentDeploymentUnitId, _GxIdeDeploymentTool_onlyPackageCheckboxEl, _GxIdeDeploymentTool_targetTypesEl, _GxIdeDeploymentTool_applicationServerEl, _GxIdeDeploymentTool_generatorEl, _GxIdeDeploymentTool_deploymentUnitsEl, _GxIdeDeploymentTool_displayNameEl, _GxIdeDeploymentTool_getInitialSelectedTarget, _GxIdeDeploymentTool_evaluateObjects, _GxIdeDeploymentTool_handleGetDeploymentUnitObjectsCallback, _GxIdeDeploymentTool_loadDeploymentUnits, _GxIdeDeploymentTool_handleCreateDeploymentUnit, _GxIdeDeploymentTool_optionsCallbackHandler, _GxIdeDeploymentTool_addNewTypesToModel, _GxIdeDeploymentTool_addObjectsCallbackHandler, _GxIdeDeploymentTool_deployCallbackHandler, _GxIdeDeploymentTool_getApplicationServer, _GxIdeDeploymentTool_handleTargetTypesChange, _GxIdeDeploymentTool_flattenObjectTypes, _GxIdeDeploymentTool_objectsTreeCheckedItemsChangedHandler, _GxIdeDeploymentTool_evaluateContentToDisplay, _GxIdeDeploymentTool_getComboModel, _GxIdeDeploymentTool_getComboModelItem, _GxIdeDeploymentTool_renderComboSelector, _GxIdeDeploymentTool_renderHeader, _GxIdeDeploymentTool_renderApplicationServerSelector, _GxIdeDeploymentTool_renderGeneratorSelector, _GxIdeDeploymentTool_renderTargetSelector, _GxIdeDeploymentTool_renderDisplayNameInput, _GxIdeDeploymentTool_renderFooter;
const CSS_BUNDLES = [
    "resets/box-sizing",
    "utils/form",
    "utils/layout",
    "utils/typography",
    "components/button",
    "components/checkbox",
    "components/edit",
    "components/tree-view",
    "components/combo-box",
    "components/icon",
    "utils/spacing"
];
const CHECKBOX_CHECKED_VALUE = "true";
const CHECKBOX_UNCHECKED_VALUE = "false";
const GxIdeDeploymentTool$1 = /*@__PURE__*/ proxyCustomElement(class GxIdeDeploymentTool extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.componentDidLoadEvent = createEvent(this, "componentDidLoadEvent", 7);
        this.componentDidRenderFirstTime = createEvent(this, "componentDidRenderFirstTime", 7);
        _GxIdeDeploymentTool_instances.add(this);
        /**
         * The component hard-coded strings translations.
         */
        // eslint-disable-next-line @stencil-community/own-props-must-be-private
        _GxIdeDeploymentTool_componentLocale.set(this, void 0);
        _GxIdeDeploymentTool_renderedFirstTime.set(this, false);
        _GxIdeDeploymentTool_flattenedObjectTypeData.set(this, new Map());
        _GxIdeDeploymentTool_currentDeploymentUnitId.set(this, void 0);
        _GxIdeDeploymentTool_onlyPackageCheckboxEl.set(this, void 0);
        _GxIdeDeploymentTool_targetTypesEl.set(this, void 0);
        _GxIdeDeploymentTool_applicationServerEl.set(this, void 0);
        _GxIdeDeploymentTool_generatorEl.set(this, void 0);
        _GxIdeDeploymentTool_deploymentUnitsEl.set(this, void 0);
        _GxIdeDeploymentTool_displayNameEl.set(this, void 0);
        _GxIdeDeploymentTool_getInitialSelectedTarget.set(this, () => {
            if (this.defaultTargetTypeId) {
                const target = this.targetTypes.find(itTarget => itTarget.id === this.defaultTargetTypeId);
                if (target) {
                    return target;
                }
            }
            return this.targetTypes[0];
        });
        _GxIdeDeploymentTool_evaluateObjects.set(this, () => {
            var _a;
            this.noObjects = !!(((_a = this.treeModel) === null || _a === void 0 ? void 0 : _a.length) === 0 || !this.treeModel);
        });
        _GxIdeDeploymentTool_handleGetDeploymentUnitObjectsCallback.set(this, async (ev) => {
            await __classPrivateFieldGet(this, _GxIdeDeploymentTool_loadDeploymentUnits, "f").call(this, ev.detail);
            __classPrivateFieldGet(this, _GxIdeDeploymentTool_optionsCallbackHandler, "f").call(this);
        });
        _GxIdeDeploymentTool_loadDeploymentUnits.set(this, async (id) => {
            if (id === this.newDeploymentUnitId) {
                // New deployment unit should be created before executing the deploy action.
                return;
            }
            __classPrivateFieldSet(this, _GxIdeDeploymentTool_currentDeploymentUnitId, id, "f");
            const objectData = await this.getDeploymentUnitObjectsCallback(id);
            this.addedObjects = [...objectData];
            this.treeModel = createArrayOfItems(this.addedObjects, this.allObjectTypes);
        });
        _GxIdeDeploymentTool_handleCreateDeploymentUnit.set(this, async () => {
            if (this.createDeploymentUnitCallback) {
                const deploymentUnitData = await this.createDeploymentUnitCallback();
                if (!deploymentUnitData) {
                    return;
                }
                if (!this.deploymentUnits.find(du => du.id === deploymentUnitData.id)) {
                    // Update deployment units:
                    this.deploymentUnits.unshift(deploymentUnitData);
                    // Update combo:
                    const deploymentUnitComboBoxItem = __classPrivateFieldGet(this, _GxIdeDeploymentTool_getComboModelItem, "f").call(this, deploymentUnitData);
                    const updatedDeploymentUnitsModel = [
                        deploymentUnitComboBoxItem,
                        ...__classPrivateFieldGet(this, _GxIdeDeploymentTool_deploymentUnitsEl, "f").model
                    ];
                    __classPrivateFieldGet(this, _GxIdeDeploymentTool_deploymentUnitsEl, "f").model = updatedDeploymentUnitsModel;
                }
                __classPrivateFieldGet(this, _GxIdeDeploymentTool_deploymentUnitsEl, "f").value = deploymentUnitData.id;
                // Trigger selection callback:
                await __classPrivateFieldGet(this, _GxIdeDeploymentTool_loadDeploymentUnits, "f").call(this, deploymentUnitData.id);
            }
        });
        _GxIdeDeploymentTool_optionsCallbackHandler.set(this, () => {
            if (this.optionsCallback) {
                this.optionsCallback(__classPrivateFieldGet(this, _GxIdeDeploymentTool_deploymentUnitsEl, "f").value, __classPrivateFieldGet(this, _GxIdeDeploymentTool_targetTypesEl, "f").value);
            }
        });
        _GxIdeDeploymentTool_addNewTypesToModel.set(this, () => {
            const allTypes = [...this.allObjectTypes];
            this.addedObjects.forEach(addedObject => {
                const matchingType = this.allObjectTypes.find(objectType => objectType.id === addedObject.type);
                if (!matchingType) {
                    allTypes.push({
                        id: addedObject.type,
                        name: addedObject.type,
                        icon: ""
                    });
                }
            });
            this.allObjectTypes = [...allTypes];
        });
        _GxIdeDeploymentTool_addObjectsCallbackHandler.set(this, async () => {
            if (this.addObjectsCallback) {
                const objects = await this.addObjectsCallback();
                this.addedObjects = [...objects, ...this.addedObjects];
                __classPrivateFieldGet(this, _GxIdeDeploymentTool_addNewTypesToModel, "f").call(this);
                this.treeModel = createArrayOfItems(this.addedObjects, this.allObjectTypes);
            }
        });
        _GxIdeDeploymentTool_deployCallbackHandler.set(this, async () => {
            var _a, _b;
            if (__classPrivateFieldGet(this, _GxIdeDeploymentTool_deploymentUnitsEl, "f").value === this.newDeploymentUnitId) {
                await __classPrivateFieldGet(this, _GxIdeDeploymentTool_handleCreateDeploymentUnit, "f").call(this);
            }
            const data = {
                targetId: __classPrivateFieldGet(this, _GxIdeDeploymentTool_targetTypesEl, "f").value,
                applicationServerId: __classPrivateFieldGet(this, _GxIdeDeploymentTool_getApplicationServer, "f").call(this),
                displayName: (_a = __classPrivateFieldGet(this, _GxIdeDeploymentTool_displayNameEl, "f")) === null || _a === void 0 ? void 0 : _a.value,
                generatorId: (_b = __classPrivateFieldGet(this, _GxIdeDeploymentTool_generatorEl, "f")) === null || _b === void 0 ? void 0 : _b.value,
                onlyPackage: __classPrivateFieldGet(this, _GxIdeDeploymentTool_onlyPackageCheckboxEl, "f")
                    ? __classPrivateFieldGet(this, _GxIdeDeploymentTool_onlyPackageCheckboxEl, "f").value === CHECKBOX_CHECKED_VALUE
                    : undefined,
                objects: this.checkedObjectsIds
            };
            if (this.deployCallback) {
                this.allowDeploy = false;
                await this.deployCallback(data);
                this.allowDeploy = true;
            }
        });
        _GxIdeDeploymentTool_getApplicationServer.set(this, () => {
            var _a, _b, _c;
            if ((_a = __classPrivateFieldGet(this, _GxIdeDeploymentTool_applicationServerEl, "f")) === null || _a === void 0 ? void 0 : _a.value) {
                return __classPrivateFieldGet(this, _GxIdeDeploymentTool_applicationServerEl, "f").value;
            }
            return ((_b = this.selectedDeployTargetData) === null || _b === void 0 ? void 0 : _b.applicationServers.length) > 0
                ? (_c = this.selectedDeployTargetData) === null || _c === void 0 ? void 0 : _c.applicationServers[0].id
                : undefined;
        });
        _GxIdeDeploymentTool_handleTargetTypesChange.set(this, (ev) => {
            const selectedId = ev.detail;
            this.selectedDeployTargetData =
                this.targetTypes.find(targetType => targetType.id === selectedId) || null;
            if (!this.selectedDeployTargetData.canCreatePackage &&
                __classPrivateFieldGet(this, _GxIdeDeploymentTool_onlyPackageCheckboxEl, "f").value === CHECKBOX_CHECKED_VALUE) {
                __classPrivateFieldGet(this, _GxIdeDeploymentTool_onlyPackageCheckboxEl, "f").value = CHECKBOX_UNCHECKED_VALUE;
            }
            __classPrivateFieldGet(this, _GxIdeDeploymentTool_optionsCallbackHandler, "f").call(this);
        });
        _GxIdeDeploymentTool_objectsTreeCheckedItemsChangedHandler.set(this, (event) => {
            const allItemsWithCheckbox = [...event.detail.values()];
            this.checkedObjectsIds = allItemsWithCheckbox
                .filter(checkedItem => checkedItem.item.checked && checkedItem.item.metadata === KB_OBJECT)
                .map(checkedItem => checkedItem.item.id);
        });
        _GxIdeDeploymentTool_evaluateContentToDisplay.set(this, () => {
            if (this.noObjects) {
                return (h("gx-ide-empty-state", { isAnimated: false, stateTitle: __classPrivateFieldGet(this, _GxIdeDeploymentTool_componentLocale, "f").main.noObjectsToDisplay, key: "no-objects-empty-state", stateIconSrc: "objects/object" }));
            }
            return (h("ch-tree-view-render", { class: "tree-view", model: this.treeModel, dragDisabled: true, dropDisabled: true, toggleCheckboxes: true, showLines: "last", checked: true, checkbox: true, onCheckedItemsChange: __classPrivateFieldGet(this, _GxIdeDeploymentTool_objectsTreeCheckedItemsChangedHandler, "f") }));
        });
        _GxIdeDeploymentTool_getComboModel.set(this, (baseCollection) => {
            return baseCollection.map(obj => __classPrivateFieldGet(this, _GxIdeDeploymentTool_getComboModelItem, "f").call(this, obj));
        });
        _GxIdeDeploymentTool_getComboModelItem.set(this, (baseCollectionItem) => {
            return {
                caption: baseCollectionItem.name,
                value: baseCollectionItem.id
            };
        });
        _GxIdeDeploymentTool_renderComboSelector.set(this, (properties, withField = false) => {
            var _a;
            const controlId = properties.label.replace(/ /g, "-").toLowerCase();
            const labelClasses = `label ${controlId}`;
            const comboBoxClasses = properties.class
                ? `combo-box ${properties.class}`
                : "combo-box";
            const labelAndComboBox = [
                h("label", { class: labelClasses, htmlFor: controlId }, properties.label),
                h("ch-combo-box-render", { class: comboBoxClasses, value: properties.value ? properties.value : (_a = properties.baseModel[0]) === null || _a === void 0 ? void 0 : _a.id, model: __classPrivateFieldGet(this, _GxIdeDeploymentTool_getComboModel, "f").call(this, properties.baseModel), id: controlId, ref: properties.refCallback, onInput: properties.onInputCallback })
            ];
            return withField ? (h("div", { class: "field field-inline" }, labelAndComboBox)) : (labelAndComboBox);
        });
        _GxIdeDeploymentTool_renderHeader.set(this, () => {
            return (h("div", { slot: "header", class: "header dialog-header-with-border" }, __classPrivateFieldGet(this, _GxIdeDeploymentTool_renderComboSelector, "f").call(this, {
                id: "deploymentUnits",
                baseModel: this.deploymentUnits,
                label: __classPrivateFieldGet(this, _GxIdeDeploymentTool_componentLocale, "f").header.objectsToDeploy,
                value: __classPrivateFieldGet(this, _GxIdeDeploymentTool_currentDeploymentUnitId, "f"),
                refCallback: (el) => {
                    __classPrivateFieldSet(this, _GxIdeDeploymentTool_deploymentUnitsEl, el, "f");
                },
                onInputCallback: __classPrivateFieldGet(this, _GxIdeDeploymentTool_handleGetDeploymentUnitObjectsCallback, "f")
            }, true), h("button", { class: "button-primary", onClick: __classPrivateFieldGet(this, _GxIdeDeploymentTool_addObjectsCallbackHandler, "f") }, __classPrivateFieldGet(this, _GxIdeDeploymentTool_componentLocale, "f").main.addButton)));
        });
        _GxIdeDeploymentTool_renderApplicationServerSelector.set(this, () => {
            var _a;
            return __classPrivateFieldGet(this, _GxIdeDeploymentTool_renderComboSelector, "f").call(this, {
                id: "application-servers",
                class: "application-server-combo",
                baseModel: (_a = this.selectedDeployTargetData) === null || _a === void 0 ? void 0 : _a.applicationServers,
                label: __classPrivateFieldGet(this, _GxIdeDeploymentTool_componentLocale, "f").main.applicationServer,
                refCallback: (el) => {
                    __classPrivateFieldSet(this, _GxIdeDeploymentTool_applicationServerEl, el, "f");
                }
            });
        });
        _GxIdeDeploymentTool_renderGeneratorSelector.set(this, () => {
            var _a;
            return __classPrivateFieldGet(this, _GxIdeDeploymentTool_renderComboSelector, "f").call(this, {
                id: "generator",
                class: "generator-combo",
                baseModel: (_a = this.selectedDeployTargetData) === null || _a === void 0 ? void 0 : _a.generators,
                label: __classPrivateFieldGet(this, _GxIdeDeploymentTool_componentLocale, "f").main.generator,
                refCallback: (el) => {
                    __classPrivateFieldSet(this, _GxIdeDeploymentTool_generatorEl, el, "f");
                }
            });
        });
        _GxIdeDeploymentTool_renderTargetSelector.set(this, () => {
            var _a;
            return [
                __classPrivateFieldGet(this, _GxIdeDeploymentTool_renderComboSelector, "f").call(this, {
                    id: "targetTypes",
                    class: "target-types-combo",
                    baseModel: this.targetTypes,
                    label: __classPrivateFieldGet(this, _GxIdeDeploymentTool_componentLocale, "f").main.targetTypes,
                    value: this.selectedDeployTargetData
                        ? this.selectedDeployTargetData.id
                        : this.defaultTargetTypeId,
                    refCallback: (el) => {
                        __classPrivateFieldSet(this, _GxIdeDeploymentTool_targetTypesEl, el, "f");
                    },
                    onInputCallback: __classPrivateFieldGet(this, _GxIdeDeploymentTool_handleTargetTypesChange, "f")
                }),
                h("div", { class: "target-types-button-checkbox-wrapper buttons-spacer" }, h("button", { class: "button-tertiary button-icon-only", onClick: __classPrivateFieldGet(this, _GxIdeDeploymentTool_optionsCallbackHandler, "f") }, h("ch-image", { class: "icon-m", src: "system/settings/primary" })), h("ch-checkbox", { disabled: !((_a = this.selectedDeployTargetData) === null || _a === void 0 ? void 0 : _a.canCreatePackage), class: "checkbox", caption: __classPrivateFieldGet(this, _GxIdeDeploymentTool_componentLocale, "f").main.onlyPackageLabel, part: "only-package-checkbox", checkedValue: CHECKBOX_CHECKED_VALUE, unCheckedValue: CHECKBOX_UNCHECKED_VALUE, value: CHECKBOX_UNCHECKED_VALUE, ref: (el) => (__classPrivateFieldSet(this, _GxIdeDeploymentTool_onlyPackageCheckboxEl, el, "f")) }))
            ];
        });
        _GxIdeDeploymentTool_renderDisplayNameInput.set(this, () => {
            return [
                h("label", { class: "label display-name", htmlFor: "display-name" }, __classPrivateFieldGet(this, _GxIdeDeploymentTool_componentLocale, "f").main.displayName),
                h("ch-edit", { class: "input display-name-input", id: "display-name", ref: (el) => {
                        if (el) {
                            __classPrivateFieldSet(this, _GxIdeDeploymentTool_displayNameEl, el, "f");
                        }
                    } })
            ];
        });
        _GxIdeDeploymentTool_renderFooter.set(this, () => {
            return (h("div", { slot: "footer-end", class: "footer dialog-footer-with-border" }, h("button", { class: "button-primary", onClick: __classPrivateFieldGet(this, _GxIdeDeploymentTool_deployCallbackHandler, "f"), disabled: !this.allowDeploy }, __classPrivateFieldGet(this, _GxIdeDeploymentTool_componentLocale, "f").main.deployButton)));
        });
        this.checkedObjectsIds = [];
        this.noObjects = undefined;
        this.selectedDeployTargetData = null;
        this.addedObjects = [];
        this.allObjectTypes = undefined;
        this.treeModel = [];
        this.allowDeploy = true;
        this.deploymentUnits = undefined;
        this.targetTypes = undefined;
        this.defaultTargetTypeId = undefined;
        this.newDeploymentUnitId = undefined;
        this.objectTypes = undefined;
        this.getDeploymentUnitObjectsCallback = undefined;
        this.optionsCallback = undefined;
        this.deployCallback = undefined;
        this.addObjectsCallback = undefined;
        this.createDeploymentUnitCallback = undefined;
    }
    watchTreeModelHandler(newState) {
        this.noObjects = !!(newState.length === 0 || !newState);
    }
    watchObjectTypesHandler(newState) {
        __classPrivateFieldGet(this, _GxIdeDeploymentTool_instances, "m", _GxIdeDeploymentTool_flattenObjectTypes).call(this, newState);
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeDeploymentTool_componentLocale, await Locale.getComponentStrings(this.el), "f");
        this.selectedDeployTargetData = __classPrivateFieldGet(this, _GxIdeDeploymentTool_getInitialSelectedTarget, "f").call(this);
        this.allObjectTypes = [...this.objectTypes];
        __classPrivateFieldGet(this, _GxIdeDeploymentTool_evaluateObjects, "f").call(this);
        __classPrivateFieldGet(this, _GxIdeDeploymentTool_instances, "m", _GxIdeDeploymentTool_flattenObjectTypes).call(this, this.allObjectTypes);
        if (this.deploymentUnits.length > 0) {
            __classPrivateFieldGet(this, _GxIdeDeploymentTool_loadDeploymentUnits, "f").call(this, this.deploymentUnits[0].id);
            if (this.targetTypes.length > 0 && this.optionsCallback) {
                this.optionsCallback(this.deploymentUnits[0].id, this.targetTypes[0].id);
            }
        }
    }
    componentDidRender() {
        if (!__classPrivateFieldGet(this, _GxIdeDeploymentTool_renderedFirstTime, "f")) {
            this.componentDidRenderFirstTime.emit(__classPrivateFieldGet(this, _GxIdeDeploymentTool_componentLocale, "f").componentName);
            __classPrivateFieldSet(this, _GxIdeDeploymentTool_renderedFirstTime, true, "f");
        }
    }
    render() {
        var _a, _b, _c, _d, _e, _f, _g;
        return (h(Host, { class: "widget spacing-body" }, h("ch-theme", { model: CSS_BUNDLES }), __classPrivateFieldGet(this, _GxIdeDeploymentTool_renderHeader, "f").call(this), __classPrivateFieldGet(this, _GxIdeDeploymentTool_evaluateContentToDisplay, "f").call(this), h("div", { class: "deploy-properties field-group" }, __classPrivateFieldGet(this, _GxIdeDeploymentTool_renderTargetSelector, "f").call(this), ((_b = (_a = this.selectedDeployTargetData) === null || _a === void 0 ? void 0 : _a.applicationServers) === null || _b === void 0 ? void 0 : _b.length) > 1 &&
            this.selectedDeployTargetData.canSelectApplicationServer
            ? __classPrivateFieldGet(this, _GxIdeDeploymentTool_renderApplicationServerSelector, "f").call(this)
            : [], ((_d = (_c = this.selectedDeployTargetData) === null || _c === void 0 ? void 0 : _c.generators) === null || _d === void 0 ? void 0 : _d.length) > 0
            ? __classPrivateFieldGet(this, _GxIdeDeploymentTool_renderGeneratorSelector, "f").call(this)
            : [], ((_e = this.selectedDeployTargetData) === null || _e === void 0 ? void 0 : _e.description) && (h("p", { class: "body-italic-s target-type__description" }, (_f = this.selectedDeployTargetData) === null || _f === void 0 ? void 0 : _f.description)), ((_g = this.selectedDeployTargetData) === null || _g === void 0 ? void 0 : _g.canDefineDisplayName)
            ? __classPrivateFieldGet(this, _GxIdeDeploymentTool_renderDisplayNameInput, "f").call(this)
            : []), __classPrivateFieldGet(this, _GxIdeDeploymentTool_renderFooter, "f").call(this)));
    }
    static get assetsDirs() { return ["gx-ide-assets/deployment-tool"]; }
    get el() { return this; }
    static get watchers() { return {
        "treeModel": ["watchTreeModelHandler"],
        "objectTypes": ["watchObjectTypesHandler"]
    }; }
    static get style() { return deploymentToolCss; }
}, [1, "gx-ide-deployment-tool", {
        "deploymentUnits": [16],
        "targetTypes": [16],
        "defaultTargetTypeId": [1, "default-target-type-id"],
        "newDeploymentUnitId": [1, "new-deployment-unit-id"],
        "objectTypes": [16],
        "getDeploymentUnitObjectsCallback": [16],
        "optionsCallback": [16],
        "deployCallback": [16],
        "addObjectsCallback": [16],
        "createDeploymentUnitCallback": [16],
        "checkedObjectsIds": [32],
        "noObjects": [32],
        "selectedDeployTargetData": [32],
        "addedObjects": [32],
        "allObjectTypes": [32],
        "treeModel": [32],
        "allowDeploy": [32]
    }, undefined, {
        "treeModel": ["watchTreeModelHandler"],
        "objectTypes": ["watchObjectTypesHandler"]
    }]);
_GxIdeDeploymentTool_componentLocale = new WeakMap(), _GxIdeDeploymentTool_renderedFirstTime = new WeakMap(), _GxIdeDeploymentTool_flattenedObjectTypeData = new WeakMap(), _GxIdeDeploymentTool_currentDeploymentUnitId = new WeakMap(), _GxIdeDeploymentTool_onlyPackageCheckboxEl = new WeakMap(), _GxIdeDeploymentTool_targetTypesEl = new WeakMap(), _GxIdeDeploymentTool_applicationServerEl = new WeakMap(), _GxIdeDeploymentTool_generatorEl = new WeakMap(), _GxIdeDeploymentTool_deploymentUnitsEl = new WeakMap(), _GxIdeDeploymentTool_displayNameEl = new WeakMap(), _GxIdeDeploymentTool_getInitialSelectedTarget = new WeakMap(), _GxIdeDeploymentTool_evaluateObjects = new WeakMap(), _GxIdeDeploymentTool_handleGetDeploymentUnitObjectsCallback = new WeakMap(), _GxIdeDeploymentTool_loadDeploymentUnits = new WeakMap(), _GxIdeDeploymentTool_handleCreateDeploymentUnit = new WeakMap(), _GxIdeDeploymentTool_optionsCallbackHandler = new WeakMap(), _GxIdeDeploymentTool_addNewTypesToModel = new WeakMap(), _GxIdeDeploymentTool_addObjectsCallbackHandler = new WeakMap(), _GxIdeDeploymentTool_deployCallbackHandler = new WeakMap(), _GxIdeDeploymentTool_getApplicationServer = new WeakMap(), _GxIdeDeploymentTool_handleTargetTypesChange = new WeakMap(), _GxIdeDeploymentTool_objectsTreeCheckedItemsChangedHandler = new WeakMap(), _GxIdeDeploymentTool_evaluateContentToDisplay = new WeakMap(), _GxIdeDeploymentTool_getComboModel = new WeakMap(), _GxIdeDeploymentTool_getComboModelItem = new WeakMap(), _GxIdeDeploymentTool_renderComboSelector = new WeakMap(), _GxIdeDeploymentTool_renderHeader = new WeakMap(), _GxIdeDeploymentTool_renderApplicationServerSelector = new WeakMap(), _GxIdeDeploymentTool_renderGeneratorSelector = new WeakMap(), _GxIdeDeploymentTool_renderTargetSelector = new WeakMap(), _GxIdeDeploymentTool_renderDisplayNameInput = new WeakMap(), _GxIdeDeploymentTool_renderFooter = new WeakMap(), _GxIdeDeploymentTool_instances = new WeakSet(), _GxIdeDeploymentTool_flattenObjectTypes = function _GxIdeDeploymentTool_flattenObjectTypes(newState) {
    newState.forEach(objectType => {
        __classPrivateFieldGet(this, _GxIdeDeploymentTool_flattenedObjectTypeData, "f").set(objectType.id, objectType);
    });
};
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["gx-ide-deployment-tool", "gx-ide-empty-state"];
    components.forEach(tagName => { switch (tagName) {
        case "gx-ide-deployment-tool":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, GxIdeDeploymentTool$1);
            }
            break;
        case "gx-ide-empty-state":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}

const GxIdeDeploymentTool = GxIdeDeploymentTool$1;
const defineCustomElement = defineCustomElement$1;

export { GxIdeDeploymentTool, defineCustomElement };

//# sourceMappingURL=gx-ide-deployment-tool.js.map