import { c as k } from "../../chunks/runtime.js";
import { LitElement as A, createEvent as t, noShadowRoot as _, safeClassMap as v } from "@arcgis/lumina";
import { html as s, render as S } from "lit-html";
/*! All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
v4.33.18 */
class U extends A {
  constructor() {
    super(...arguments), this._showInvalidVersionNotice = !0, this.geosceneCreateVersionList = t(), this.geosceneFlowItemBack = t(), this.geosceneFlowItemClose = t(), this.geosceneGetVersions = t(), this.geosceneManageVersion = t(), this.geosceneNewVersion = t();
  }
  static {
    this.properties = { _showInvalidVersionNotice: 16, serviceItemElementProps: 0 };
  }
  static {
    this.shadowRootOptions = _;
  }
  disconnectedCallback() {
    super.disconnectedCallback(), this.versionListContainer?.remove();
  }
  render() {
    const { serviceItemElementProps: { allowEditing: h, closable: p, currentUser: V, executionError: I, currentVersionIdentifier: r, flowElement: $, heading: b, isInitialVersionInvalid: w, isVersionAdministrator: f, isVersioningApiAvailable: u, mode: N, pageSize: E, serviceName: o, serviceUrl: c, state: C, strings: n, versionInfos: a } } = this;
    let { _versionList: l } = this;
    const x = w.get(c) && this._showInvalidVersionNotice ? s`<calcite-notice class=${v(this._showInvalidVersionNotice ? "invalid-initial-version-notice" : "")} closable kind=warning open scale=s width=full icon @calciteNoticeClose=${() => this._showInvalidVersionNotice = !1}><div slot=title>${n.headers.invalidInitialVersion}</div><div slot=message>${n.loadErrors.invalidInitialVersion}</div></calcite-notice>` : void 0, L = s`<calcite-combobox clear-disabled .label=${o} max-items=5 overlay-positioning=fixed selection-mode=single-persist @calciteComboboxChange=${(i) => {
      const m = i.target, e = a.find((M) => M.versionIdentifier.guid === m.value);
      this.geosceneManageVersion.emit({ actionType: "changeVersion", serviceUrl: c, versionInfo: e });
    }}>${a ? a.map((i) => s`<calcite-combobox-item class=${v(N === "dialog" ? "" : "calcite-combobox-item")} .selected=${r.guid === i.versionIdentifier.guid && r.name === i.versionIdentifier.name} .textLabel=${i.versionIdentifier.name} .value=${i.versionIdentifier.guid}></calcite-combobox-item>`) : void 0}</calcite-combobox>`;
    let d, g;
    return h && (d = s`<calcite-action .id=${`actionManageVersions_${o}`} icon=list scale=s slot=control text @click=${async () => {
      const i = {
        closable: p,
        currentUser: V,
        currentVersionIdentifier: r,
        executionError: I,
        heading: b,
        isVersionAdministrator: f,
        isVersioningApiAvailable: u,
        pageSize: E,
        serviceName: o,
        serviceUrl: c,
        state: C,
        strings: n,
        versionInfos: a
      };
      this.versionListContainer = document.createElement("div");
      const m = S(s`<geoscene-version-management-version-list .versionListElementProps=${i} selected show-back-button @geosceneFlowItemBack=${(e) => {
        e.preventDefault(), this.geosceneFlowItemBack.emit();
      }} @geosceneFlowItemClose=${() => this.geosceneFlowItemClose.emit()} @geosceneGetVersions=${(e) => this.geosceneGetVersions.emit({ serviceUrl: e.detail.serviceUrl })} @geosceneManageVersion=${(e) => this.geosceneManageVersion.emit(e.detail)} @geosceneNewVersion=${(e) => this.geosceneNewVersion.emit({ serviceUrl: e.detail.serviceUrl })}></geoscene-version-management-version-list>`, this.versionListContainer);
      l = Array.from(m.parentNode.childNodes).find((e) => e.nodeName.toUpperCase() === "GEOSCENE-VERSION-MANAGEMENT-VERSION-LIST"), $?.append(l), this.geosceneCreateVersionList.emit(l);
    }}></calcite-action>`, g = s`<calcite-tooltip overlay-positioning=fixed .referenceElement=${`actionManageVersions_${o}`}><span>${n.headers.manageVersions}</span></calcite-tooltip>`), s`<calcite-block open .heading=${o}>${x}${L}${d}${g}</calcite-block>`;
  }
}
k("geoscene-version-management-service-item", U);
export {
  U as GeosceneVersionManagementServiceItem
};