/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { c as w } from "../../chunks/runtime.js";
import { g as $ } from "../../chunks/mapViewUtils.js";
import { defineCustomElements as v } from "@arcgis/instant-apps-components/dist/loader";
import { u as C } from "../../chunks/useT9n.js";
import { css as I, html as s, nothing as L } from "lit";
import { createRef as c, ref as u } from "lit-html/directives/ref.js";
import { LitElement as M, createEvent as _, noShadowRoot as x, safeClassMap as f, safeStyleMap as T } from "@arcgis/lumina";
import { setupViewFocusKeyboardWatcher as S } from "templates-common-library/functionality/keyboardUtils";
const F = I`@layer{:host{display:block;--calcite-label-margin-bottom: 0px;--solutions-theme-foreground-color: var(--calcite-color-surface-2)}.padding-1-2{padding:.5rem}.display-flex{display:flex}.width-full{width:100%}.width-1-2{position:relative;width:50%}.width-1-3{position:relative;width:33.33%}.width-2-3{position:relative;width:66.66%}.width-0{width:0}.z-index-2{z-index:2!important}.height-full{height:100%}.height-1-2{position:relative;height:50%}.height-0{height:0}.toggle-node{width:51px;height:51px}.overflow-hidden{overflow:hidden}.flex-column{flex-direction:column}.border{border:1px solid var(--calcite-color-border-3)}.border-top{border-top:1px solid var(--calcite-color-border-3)}.border-bottom{border-bottom:1px solid var(--calcite-color-border-3)}.border-sides{border-left:1px solid var(--calcite-color-border-3);border-right:1px solid var(--calcite-color-border-3)}.position-relative{position:relative}.position-absolute{position:absolute}.position-sticky{position:sticky}.height-50{height:50%}.top-51{top:51px}.adjusted-height-50{height:calc(50% - 25px)}.adjusted-height-100{height:calc(100% - 50px)}.adjusted-height-100-51{height:calc(100% - 51px)}.display-none{display:none!important}.adjusted-height-50_25{height:calc(50% + 25px)}.display-grid{display:grid}.padding-inline-start-75{padding-inline-start:.75rem}.align-items-center{align-items:center}.esri-floor-filter__close-levels-button,.esri-floor-filter__level-button,.esri-floor-filter__browse-button{width:40px!important;height:40px!important}.position-absolute-0{position:absolute;inset:0}.visibility-hidden{visibility:hidden;height:0px}.border-width-0{border-width:0px}.floating-container{position:fixed;width:100px;height:10px;bottom:0;margin:100px 0;z-index:1}.left-0{left:0}.right-0{right:0}.floating-container .floating-button{box-shadow:0 10px 25px #5c5d5e99;-webkit-transform:translatey(5px);transform:translatey(5px);-webkit-transition:all .3s;transition:all .3s}.z-index-0{z-index:0!important}.z-index-1{z-index:1!important}.filter-content-space{--calcite-dialog-content-space: 0px}.background-dark{background:var(--calcite-color-surface-1)}.filter-extent-container{display:flex;justify-content:space-between;align-items:center;padding:10px 0}.filter-modal-buttons{display:flex;padding:12px;gap:10px}.filter-extent-message{align-items:center;display:flex;gap:5px}calcite-action-bar{--calcite-internal-action-bar-gap: 0px;--calcite-internal-action-bar-padding: 0px}}`;
class V extends M {
  constructor() {
    super(), this.coverPageEnabled = !1, this.customInfoText = "", this.defaultCenter = "", this.defaultGlobalId = "", this.defaultLayer = "", this.defaultLevel = "", this.defaultOid = "", this.defaultWebmap = "", this.honorMapFieldSettings = !1, this.introductionWindowEnabled = !1, this.enableAutoRefresh = !1, this.enableBasemap = !0, this.enableColumnReorder = !0, this.enableCSV = !0, this.enableFloorFilter = !0, this.enableFullscreen = !0, this.enableHome = !0, this.enableLegend = !0, this.enableLayerList = !0, this.enableMapList = !0, this.visibilityIcon = "eyeball", this.enableSearch = !0, this.enableShare = !1, this.enableSnapping = !0, this.enableZoom = !0, this.mapInfos = [], this.onlyShowUpdatableLayers = !1, this.popupHeaderColor = "", this.popupHeaderHoverColor = "", this.popupHeaderHoverTextColor = "", this.popupHeaderTextColor = "", this.shareIncludeEmbed = !1, this.shareIncludeSocial = !1, this.showNewestFirst = !0, this.theme = "light", this.zoomAndScrollToSelected = !1, this.enableSelectionTool = !0, this.featureSelectionMode = "multiple", this.enableCopyPaste = !0, this._deleteDialogOpen = !1, this._enableCreateFeatures = !0, this._hideFooter = !1, this._hideTable = !1, this._isMobile = !1, this._translations = C({ name: "crowdsource-manager", blocking: !0 }), this._layoutMode = "GRID", this._panelOpen = !0, this._numSelected = 0, this._filterOpen = !1, this._showInformationHeader = !0, this._layerExpressions = [], this._layerIds = [], this._isLoading = !0, this._mapExtentFilterChecked = !1, this._deleteIds = [], this._showInvalidMapAlert = !1, this._currentMapInfos = [], this._pasteEnabled = !1, this._showCopyPasteActions = !1, this._defaultAppLayoutHonored = !1, this._defaultCenterHonored = !1, this._defaultLevelHonored = !1, this._layerTable = c(), this._shouldSetMapView = !1, this._filterList = c(), this._mapCard = c(), this._isMapViewOnLoad = !1, this.showIntroductionWindow = _(), this.showCoverPage = _(), this.listenOn(window, "featureSelectionChange", this.featureSelectionChange), this.listenOn(window, "popupClosed", this.popupClosed), this.listenOn(window, "layoutChanged", this.layoutChanged), this.listenOn(window, "mapChanged", this.mapChanged), this.listenOn(window, "layerSelectionChange", this.layerSelectionChange), this.listenOn(window, "showDelete", this.showDelete), this.listenOn(window, "noLayersFound", this.noLayersFound), this.listenOn(window, "clearSelection", this.clearSelection), this.listenOn(window, "relatedRecordToggled", this.relatedRecordToggled), this.listenOn(window, "creatingFeature", this.creatingFeature), this.listenOn(window, "featuresCopied", this.featuresCopied), this.listenOn(window, "disablePaste", this.disablePaste), this.listenOn(window, "idsFound", this.idsFound), v(window);
  }
  static {
    this.properties = { appLayout: 1, appProxies: 1, basemapConfig: 0, coverPageEnabled: 5, customInfoText: 1, defaultAppLayout: 1, defaultCenter: 1, defaultGlobalId: 1, defaultLayer: 1, defaultLevel: 1, defaultOid: 1, defaultWebmap: 1, honorMapFieldSettings: 5, introductionWindowEnabled: 5, enableAutoRefresh: 5, enableBasemap: 5, enableColumnReorder: 5, enableCSV: 5, enableFloorFilter: 5, enableFullscreen: 5, enableHome: 5, enableLegend: 5, enableLayerList: 5, enableMapList: 5, visibilityIcon: 1, enableSearch: 5, enableShare: 5, enableSnapping: 5, enableZoom: 5, mapInfos: 0, onlyShowUpdatableLayers: 5, popupHeaderColor: 1, popupHeaderHoverColor: 1, popupHeaderHoverTextColor: 1, popupHeaderTextColor: 1, searchConfiguration: 0, shareIncludeEmbed: 5, shareIncludeSocial: 5, showNewestFirst: 5, theme: 1, zoomAndScrollToSelected: 5, zoomToScale: 9, enableSelectionTool: 5, featureSelectionMode: 1, enableCopyPaste: 5, _deleteDialogOpen: 16, _enableCreateFeatures: 16, _hideFooter: 16, _hideTable: 16, _isMobile: 16, _translations: 16, _layer: 16, _layoutMode: 16, _mapInfo: 16, _mapView: 16, _panelOpen: 16, _numSelected: 16, _filterOpen: 16, _showInformationHeader: 16, _layerExpressions: 16, _layerIds: 16, _isLoading: 16, _mapExtentFilterChecked: 16, _deleteIds: 16, _showInvalidMapAlert: 16, _currentMapInfos: 16, _pasteEnabled: 16, _showCopyPasteActions: 16 };
  }
  static {
    this.styles = F;
  }
  static {
    this.shadowRootOptions = x;
  }
  willUpdate(e) {
    e.has("appLayout") && this.appLayout && this.appLayoutWatchHandler(this.appLayout, e.get("appLayout")), e.has("enableZoom") && (this.hasUpdated || this.enableZoom !== !0) && this.enableZoomWatchHandler(), e.has("mapInfos") && this.hasUpdated && this.mapInfosWatchHandler(), e.has("_isMobile") && this.hasUpdated && this._handleCopyPasteActions(), e.has("enableCopyPaste") && this.hasUpdated && this._handleCopyPasteActions();
  }
  appLayoutWatchHandler(e, t) {
    e !== t && (this._layerTable.value?.validateTableUpdate(e === "splitView"), this._setActiveLayout(e), this.appLayout === "mapView" && this._layer?.isTable && this._mapCard.value && this._mapCard.value.updateLayer(), this._isMapViewOnLoad && this._layerTable.value && this._layerTable.value.refresh());
  }
  enableZoomWatchHandler() {
    this._initMapZoom();
  }
  mapInfosWatchHandler() {
    this.updateCurrentMapInfos();
  }
  async featureSelectionChange(e) {
    this._numSelected = e.detail?.length;
  }
  async popupClosed() {
    this._isMobile && this.showHideMapPopupAndTable(!1);
  }
  async layoutChanged(e) {
    this._layoutMode = e.detail;
  }
  async mapChanged(e) {
    this._isMapViewOnLoad && (this._showMapInFullView(), this._isMapViewOnLoad = !1), this._mapChange = e.detail, this.showHideMapPopupAndTable(!1), this._pasteEnabled = !1, this._mapChange?.isValid ? await this._mapChange.mapView?.when(async () => {
      await this._setMapView();
    }) : (this._mapInfo = this._mapChange && this._getMapInfo(this._mapChange.id), this._showInvalidMapAlert = !0);
  }
  async layerSelectionChange(e) {
    const t = e.detail[0], i = this._mapView && await $(this._mapView, t);
    i && await i.when(() => {
      i.isTable && !this._isMobile && (this.appLayout = "tableView"), this._layer = i, this._pasteEnabled = !1, this._handleCopyPasteActions(), this._initLayerExpressions(), this._handleFilterListReset(), this._isLoading = !1;
    });
  }
  async showDelete(e) {
    this._deleteIds = e.detail.ids, this._deleteDialogOpen = !0;
  }
  async noLayersFound() {
    this._layer = void 0, this._isLoading = !1;
  }
  async clearSelection() {
    this.showHideMapPopupAndTable(!1);
  }
  async relatedRecordToggled(e) {
    const t = e.detail;
    this._relatedTableLayer = t;
  }
  async creatingFeature() {
    this.appLayout = "splitView";
  }
  featuresCopied() {
    this._pasteEnabled = !0;
  }
  disablePaste() {
    this._pasteEnabled = !1;
  }
  idsFound(e) {
    this._layerIds = e.detail;
  }
  load() {
    this.updateCurrentMapInfos(), this._resizeObserver = new ResizeObserver(() => this._onResize());
  }
  render() {
    const e = this.popupHeaderColor && this.popupHeaderColor !== "#FFFFFF" ? "border-width-0" : "", t = this.theme === "dark" ? "calcite-mode-dark" : "calcite-mode-light", i = this._translations.invalidWebMapMsg?.replace("{{web_map}}", this._mapInfo?.name || "");
    return s`${this._showInvalidMapAlert && s`<calcite-alert auto-close class=${f(t)} icon=check-circle kind=danger label @calciteAlertClose=${() => {
      this._showInvalidMapAlert = !1;
    }} open placement=top><div slot=message>${i}</div></calcite-alert>` || ""}<calcite-shell class="position-relative"><calcite-panel class=${`width-full height-full ${e}`} .loading=${this._isLoading}>${this._getBody(this._layoutMode, this._panelOpen, this._hideTable)}</calcite-panel>${this._getFooter()}</calcite-shell>${this._filterModal()}${!this._isMobile && this._deleteModal() || ""}`;
  }
  async updated() {
    this._shouldSetMapView && (this._shouldSetMapView = !1, this._mapChange && await this._setMapView());
  }
  loaded() {
    this._resizeObserver?.observe(this.el), !this._defaultAppLayoutHonored && this.defaultAppLayout ? (this._defaultAppLayoutHonored = !0, this.appLayout = this.defaultAppLayout) : this.appLayout || (this.appLayout = "splitView"), this._isMapViewOnLoad = this.appLayout === "mapView", this._setActiveLayout(this.appLayout);
  }
  _getFooter() {
    const e = this._numSelected > 0, t = this._layerTable.value && this._layerTable.value.selectedRelatedIds?.length > 0 ? this._relatedTableLayer : this._layer, i = this._layer?.editingEnabled && this._layer.capabilities?.operations.supportsDelete;
    return this._isMobile && e && !this._hideFooter ? s`<div class=${"width-100"} slot=footer><div class="display-flex padding-1-2"><calcite-button appearance=solid id=solutions-show @click=${() => this.showHideMapPopupAndTable(!0)} width=full>${this._translations.view.replace("{{n}}", this._numSelected.toString())}</calcite-button>${i ? s`<delete-button class="padding-inline-start-1 width-full" id=solutions-delete .ids=${this.updateIdsToBeDeleted()} @deleteClicked=${this.updateIdsToBeDeleted} .layer=${t}></delete-button>` : void 0}</div></div>` : void 0;
  }
  updateIdsToBeDeleted() {
    return this._deleteIds = this._layerTable.value && this._layerTable.value.selectedRelatedIds?.length > 0 ? this._layerTable.value.selectedRelatedIds : this._layerTable.value?.selectedIds, this._deleteIds;
  }
  _setActiveLayout(e) {
    e === "splitView" && !this._panelOpen && this._toggleLayout(), e === "mapView" ? this._showMapInFullView() : this._showMapInCardView();
  }
  _getDividerIcon(e, t) {
    return e === "HORIZONTAL" ? t ? "chevrons-up" : "chevrons-down" : e === "VERTICAL" || e === "GRID" ? t ? "chevrons-left" : "chevrons-right" : void 0;
  }
  _getMapSizeClass(e, t, i) {
    let a = "";
    switch (e) {
      case "HORIZONTAL":
        a = `${t && !i ? "height-1-2 display-grid" : t && i ? "height-full" : "height-0"} width-full position-relative`;
        break;
      case "GRID":
        a = `height-full position-relative ${t ? "width-1-3" : "width-0"}`;
        break;
      case "VERTICAL":
        a = `height-full position-relative ${t ? "width-1-2" : "width-0"}`;
        break;
    }
    return a;
  }
  _getTableSizeClass(e, t) {
    let i = "";
    switch (e) {
      case "HORIZONTAL":
        i = `${t ? "height-1-2" : "height-full"} width-full display-flex flex-column`;
        break;
      case "GRID":
        i = `${t ? "width-2-3" : "width-full"} height-full display-flex`;
        break;
      case "VERTICAL":
        i = `${t ? "width-1-2" : "width-full"} height-full display-flex`;
        break;
    }
    return i;
  }
  _getBody(e, t, i) {
    const a = e === "HORIZONTAL" ? "" : "display-flex", l = this.theme === "dark" ? "calcite-mode-dark" : "calcite-mode-light", o = document.dir === "rtl" ? "left-0" : "right-0";
    return s`<calcite-panel class="width-full height-full position-absolute"><div class=${`width-full height-full overflow-hidden ${a}`}>${this._getMapAndCard(e, t, i)}${this._getTable(e, t, i)}</div>${this.coverPageEnabled && s`<div class=${`floating-container ${o}`} @click=${this.coverPageButtonClick}><calcite-button appearance=solid class=${`floating-button ${l}`} icon-start=content-minimal kind=neutral .label=${this._translations.coverPage} round scale=l split-child=primary width=auto></calcite-button></div>` || ""}${this.introductionWindowEnabled && s`<div class=${`floating-container ${o}`} @click=${this.infoButtonClick}><calcite-button appearance=solid class=${`floating-button ${l}`} icon-start=information-letter kind=neutral .label=${this._translations.information} round scale=l split-child=primary width=auto></calcite-button></div>` || ""}</calcite-panel>`;
  }
  infoButtonClick() {
    this.showIntroductionWindow.emit();
  }
  coverPageButtonClick() {
    this.showCoverPage.emit();
  }
  _getMapAndCard(e, t, i) {
    const a = this._getMapSizeClass(e, t, i);
    return s`<div class=${`${a} overflow-hidden z-index-2`}>${this._getMapNode(t)}${this._getPopupExpandNode()}</div>`;
  }
  _getMapNode(e) {
    const t = this.appLayout === "mapView", i = this.appLayout === "tableView", a = this._isMobile ? "height-full" : t || i ? "position-absolute-0" : this._layoutMode === "HORIZONTAL" && (!this._isMobile || e) ? "" : "adjusted-height-50", l = this.defaultWebmap && this.defaultLayer, o = this.enableSelectionTool && this.featureSelectionMode === "multiple" && !this._layer?.isTable, r = ["home", "legend", "search", "fullscreen", "basemap", "floorfilter", "layers-list", "selectiontool"], h = ["map-picker", "map-layer-picker"], n = document.dir || "ltr";
    return s`<div class=${`${a} overflow-hidden`} id=card-mapView><map-card .appLayout=${this.appLayout} .appProxies=${this.appProxies} .basemapConfig=${this.basemapConfig} class="width-full" .defaultLayerId=${l ? this.defaultLayer : ""} .defaultWebmapId=${this.defaultWebmap} .enableBasemap=${this.enableBasemap} .enableFloorFilter=${this.enableFloorFilter} .enableFullscreen=${this.enableFullscreen} .enableHome=${this.enableHome} .enableLegend=${this.enableLegend} .enableLayerList=${this.enableLayerList} .enableSearch=${this.enableSearch} .enableSelectionTool=${o} .enableShare=${this.enableShare} enable-single-expand enable-map-layer-picker enable-map-picker .featureSelectionMode=${this.featureSelectionMode} .hide=${!this._isMobile && i} zoom-tools-size=s .isMapLayout=${t} .isMobile=${this._isMobile} .mapInfo=${this._mapInfo} .mapInfos=${this._currentMapInfos.filter((d) => d.visible !== !1)} map-widgets-index=0 .mapWidgetsPosition=${n === "rtl" ? "top-right" : "top-left"} .mobileMapWidgetsPosition=${n === "rtl" ? "top-left" : "top-right"} map-component-id=arcgis-map map-widgets-size=s .showOnlyUpdatableLayers=${this.onlyShowUpdatableLayers} .pasteEnabled=${this._pasteEnabled} @toggleFilter=${this._toggleFilter} .selectedFeaturesIds=${this._layerTable.value?.selectedIds ?? []} .selectedLayer=${this._layer} .shareIncludeEmbed=${this.shareIncludeEmbed} .shareIncludeSocial=${this.shareIncludeSocial} .showCopyPasteActions=${this._showCopyPasteActions} stack-tools .theme=${this.theme} .visibilityIcon=${this.visibilityIcon} .mapToolsOrder=${r} .mobileToolsOrder=${h} .zoomToScale=${this.zoomToScale} ${u(this._mapCard)}></map-card></div>`;
  }
  _getPopupExpandNode() {
    const e = this._isMobile ? "height-full" : "height-full position-relative", t = this._isMobile && this._showInformationHeader ? "display-none height-0" : "", i = this.popupHeaderColor ? "" : this._isMobile ? "calcite-mode-light" : "calcite-mode-dark", a = this._isMobile && this._hideTable ? "position-absolute-0 width-full height-full" : this._isMobile ? "display-none height-0" : "", l = this._currentMapInfos?.length > 1 && this.appLayout === "tableView" ? "position-relative top-51" : "", o = this.appLayout !== "tableView" ? "position-sticky" : "";
    return s`<div class=${`${i} ${e} ${a} ${l} ${o}`} style=${T({
      "--calcite-color-surface-2": this.popupHeaderColor,
      "--calcite-color-surface-3": this.popupHeaderHoverColor,
      "--calcite-color-text-3": this.popupHeaderTextColor,
      "--calcite-color-text-2": this.popupHeaderTextColor
    })}><calcite-panel>${!this._isMobile && this._showInformationHeader || this._numSelected > 0 && !this._isMobile ? s`<div class=${`display-flex align-items-center ${t}`} slot=header-content><calcite-icon aria-hidden=true icon=information scale=s></calcite-icon><div class="padding-inline-start-75">${this._translations.information}</div></div>` : s`<div></div>`}${this._getCardNode()}</calcite-panel></div>`;
  }
  _getCardNode() {
    const e = this.appLayout === "mapView", t = this.appLayout === "tableView", i = this._isMobile ? "height-full" : t && this._currentMapInfos?.length > 1 ? "adjusted-height-100-51" : e || t ? "height-full" : this._numSelected > 0 && !this._isMobile ? "height-50" : this._showInformationHeader ? this._isMobile ? "height-full" : "height-50" : "adjusted-height-50_25", a = this.theme === "dark" ? "calcite-mode-dark" : "calcite-mode-light", l = this._layerTable.value && this._layerTable.value.selectedRelatedIds?.length > 0 ? this._relatedTableLayer : this._layer;
    return s`<div class=${`width-50 height-full ${a}`}><card-manager class=${`${i} width-full`} .allowedPasteLayerIds=${this._layerIds} .customInfoText=${this.customInfoText} .enableCreateFeatures=${this._enableCreateFeatures && !this._isMobile} .createBtnLabel=${this._mapInfo?.createFeatureButtonLabel} .enableEditGeometry=${this._mapInfo?.enableEditGeometry} .enableSnapping=${this.enableSnapping} .isMobile=${this._isMobile} .layerOrTable=${l} .mapView=${this?._mapView} map-component-id=arcgis-map @backFromCreateWorkFlow=${() => {
      this._showInformationHeader = !0;
    }} @createWorkFlowStarted=${() => {
      this.appLayout = l?.isTable ? "tableView" : "mapView", this._showInformationHeader = !1;
    }} @featureOrRecordSubmitted=${() => this._layerTable.value && void this._layerTable.value.refresh()} .pasteEnabled=${this._pasteEnabled} .selectedFeaturesIds=${this._layerTable.value?.selectedIds} .selectingFeatureFromMap=${this.appLayout === "mapView"} .showCopyPasteActions=${this._showCopyPasteActions} .showSketchWidgets=${l?.geometryType !== "point"} .zoomAndScrollToSelected=${this.zoomAndScrollToSelected}></card-manager></div>`;
  }
  _getTable(e, t, i) {
    const a = this.appLayout === "mapView", l = this.appLayout === "tableView", o = i && this._isMobile ? "visibility-hidden" : a ? "display-none" : "", r = a ? "height-full width-full z-index-0" : "display-none", h = this._getTableSizeClass(e, t), n = e === "HORIZONTAL" ? "horizontal" : "vertical", d = e === "HORIZONTAL" ? "header" : "panel-start", p = this.defaultWebmap && this.defaultLayer, m = this._isMobile ? "border-top" : "", b = this.defaultGlobalId ? this.defaultGlobalId?.indexOf(",") > -1 ? this.defaultGlobalId.split(",") : [this.defaultGlobalId] : void 0, g = this.defaultOid ? this.defaultOid?.indexOf(",") > -1 ? this.defaultOid.split(",").map((y) => Number.parseInt(y, 10)) : [Number.parseInt(this.defaultOid, 10)] : void 0;
    return s`<calcite-shell class=${`${h} ${m} border-bottom z-index-1`}>${this._isMobile ? void 0 : s`<calcite-action-bar class="border-sides" expand-disabled .layout=${n} slot=${d ?? L}>${this.getActions(e, t)}</calcite-action-bar>`}<div class=${`width-full height-full position-relative z-index-0 ${o}`}><layer-table .appLayout=${this.appLayout} .defaultGlobalId=${p ? b : void 0} .defaultLayerId=${p ? this.defaultLayer : ""} .defaultOid=${p && !b ? g : void 0} .enableAutoRefresh=${this.enableAutoRefresh} .enableCSV=${this.enableCSV} .enableColumnReorder=${this.enableColumnReorder} .enableInlineEdit=${this?._mapInfo?.enableInlineEdit} .enableTableAutosave=${this._mapInfo?.enableTableAutosave !== void 0 ? this._mapInfo?.enableTableAutosave : !0} .enableShare=${this.enableShare} .featureSelectionMode=${this.featureSelectionMode} .honorMapFieldSettings=${this.honorMapFieldSettings} .isMobile=${this._isMobile} .mapHidden=${l} .mapInfo=${this._mapInfo} .mapView=${this?._mapView} .pasteEnabled=${this._pasteEnabled} .showOnlyUpdatableLayers=${this.onlyShowUpdatableLayers} @toggleFilter=${this._toggleFilter} .shareIncludeEmbed=${this.shareIncludeEmbed} .shareIncludeSocial=${this.shareIncludeSocial} .showNewestFirst=${this.showNewestFirst} .zoomAndScrollToSelected=${this.zoomAndScrollToSelected} .zoomToScale=${this.zoomToScale} .showCopyPasteActions=${this._showCopyPasteActions} .layerIds=${this._layerIds} ${u(this._layerTable)}></layer-table></div><div class=${f(r)} id=full-map-view></div></calcite-shell>`;
  }
  getActions(e, t) {
    const i = this._getDividerIcon(e, t), a = t ? this._translations.close : this._translations.open, l = "toggle-layout";
    return s`<calcite-action .active=${this.appLayout === "splitView"} alignment=center class="toggle-node" icon=browser id=browser-action @click=${() => {
      this.appLayout = "splitView";
    }} .text=${this._translations.splitView}></calcite-action><calcite-tooltip placement=right reference-element=browser-action><span>${this._translations.splitView}</span></calcite-tooltip><calcite-action .active=${this.appLayout === "tableView"} alignment=center class="toggle-node" icon=dock-left id=dock-left-action @click=${() => {
      this.appLayout = "tableView";
    }} .text=${this._translations.tableView}></calcite-action><calcite-tooltip placement=right reference-element=dock-left-action><span>${this._translations.tableView}</span></calcite-tooltip><calcite-action .active=${this.appLayout === "mapView"} alignment=center class="toggle-node" .disabled=${this._layer?.isTable} icon=browser-map id=browser-map-action @click=${() => {
      this.appLayout = "mapView";
    }} .text=${this._translations.mapView}></calcite-action><calcite-tooltip placement=right reference-element=browser-map-action><span>${this._translations.mapView}</span></calcite-tooltip><calcite-action alignment=center class="toggle-node" .icon=${i} id=${l} @click=${() => this._toggleLayout()} slot=actions-end .text=${a}></calcite-action><calcite-tooltip placement=bottom .referenceElement=${l}><span>${a}</span></calcite-tooltip>`;
  }
  _deleteModal() {
    const e = (this._layerTable.value?.selectedRelatedIds?.length ?? 0) > 0 ? this._relatedTableLayer : this._layer;
    return s`<delete-dialog id=deleteDialogId .ids=${this._deleteIds} .layer=${e} @deleteDialogClose=${() => this._deleteDialogOpen = !1} .open=${this._deleteDialogOpen}></delete-dialog>`;
  }
  _mapExtentFilter() {
    const e = this._layerExpressions?.length === 0;
    return s`<calcite-panel><div><calcite-block class=${f(this.theme === "dark" ? "background-dark" : "")} heading menu-placement=bottom-end open><div class="filter-extent-container"><div class="filter-extent-message"><span>${this._translations.filterByExtentMsg}</span><calcite-icon icon=information id=filter-message-info scale=s></calcite-icon><calcite-tooltip overlay-positioning=fixed placement=top reference-element=filter-message-info>${this._translations.filterByExtentTooltipMsg}</calcite-tooltip></div><calcite-switch .checked=${this._mapExtentFilterChecked} @calciteSwitchChange=${(t) => {
      const a = !!(t.target.checked || this._filterList.value?.filterCount && this._filterList.value?.filterCount > 0);
      this._layerTable.value && this._layerTable.value?.filterUpdate(a, t.target.checked), this._mapCard.value && this._mapCard.value?.updateFilterState(a), this._mapExtentFilterChecked = t.target.checked;
    }} scale=m></calcite-switch></div></calcite-block>${e && s`<div class="filter-modal-buttons" slot=footer><calcite-button appearance=outline @click=${this._handleFilterListReset} width=full>${this._translations.Resetfilter}</calcite-button><calcite-button @click=${this._closeFilter} width=full>${this._translations.close}</calcite-button></div>` || ""}</div></calcite-panel>`;
  }
  _filterModal() {
    const e = this._layerExpressions?.length > 0, t = this.theme === "dark" ? "calcite-mode-dark" : "calcite-mode-light";
    return s`<calcite-dialog class=${`filter-content-space ${t}`} .heading=${this._translations.filter.replace("{{title}}", this._layer?.title || "")} id=solutions-filter-dialog-manager kind=brand modal @calciteDialogClose=${() => {
      this._closeFilter();
    }} .open=${this._filterOpen} width=s>${!this._layer?.isTable && this._mapExtentFilter() || ""}${e && this._mapView && s`<instant-apps-filter-list close-btn .closeBtnOnClick=${() => {
      this._closeFilter();
    }} combobox-overlay-positioning=fixed .layerExpressions=${this._layerExpressions} @filterListReset=${this._handleFilterListReset} @filterUpdate=${() => {
      this._updateFilter();
    }} .view=${this._mapView} ${u(this._filterList)}></instant-apps-filter-list>` || ""}</calcite-dialog>`;
  }
  _updateFilter() {
    const e = this._filterList?.value?.filterCount && this._filterList.value.filterCount > 0 || this._mapExtentFilterChecked;
    this._layerTable.value && this._layerTable.value?.filterUpdate(e), this._mapCard.value && this._mapCard.value.updateFilterState(e);
  }
  _initLayerExpressions() {
    const e = this._mapInfo?.filterConfig?.layerExpressions;
    this._layerExpressions = e ? e.filter((t) => t.id === this._layer?.id) : [];
  }
  _toggleFilter() {
    this._filterOpen = !this._filterOpen;
  }
  _handleFilterListReset() {
    this._mapExtentFilterChecked = !1, this._mapCard.value && this._mapCard.value.resetFilter(), this._layerTable.value && this._layerTable.value.filterReset();
  }
  async _closeFilter() {
    this._filterOpen && (this._filterOpen = !1, this._layerTable.value && this._layerTable.value.closeFilter());
  }
  _onResize() {
    const e = this.el.offsetWidth <= 1024, t = !this._isMobile && e;
    this._isMobile = e, t && (this._panelOpen = !0), this._isMobile ? (this.showHideMapPopupAndTable(!this._isMobile), this.appLayout = "splitView") : (this._layer?.isTable && (this.appLayout = "tableView"), this._isMobile = !1), this._layoutMode = this._isMobile ? "HORIZONTAL" : "GRID";
  }
  updateCurrentMapInfos() {
    this._currentMapInfos = this.mapInfos, !this.enableMapList && this.defaultWebmap && (this._currentMapInfos = this.mapInfos.filter((e) => e.id === this.defaultWebmap));
  }
  _handleCopyPasteActions() {
    this._layer && (this._showCopyPasteActions = this.enableCopyPaste && !this._isMobile);
  }
  _toggleLayout() {
    this._panelOpen = !this._panelOpen;
  }
  _showMapInCardView() {
    if (this.appLayout !== "mapView") {
      const e = document.getElementById("full-map-view")?.childNodes[0], t = document.getElementById("card-mapView");
      e && t && t.appendChild(e);
    }
  }
  _showMapInFullView() {
    const e = document.getElementById("card-mapView")?.childNodes;
    let t;
    e?.forEach((a) => {
      !t && a.mapView && (t = a);
    });
    const i = document.getElementById("full-map-view");
    t && i && i.appendChild(t);
  }
  showHideMapPopupAndTable(e) {
    this._hideTable = e, this._hideFooter = e;
  }
  _getMapInfo(e) {
    let t;
    return this._currentMapInfos.some((i) => i.id === e ? (t = { ...i }, !0) : !1), t;
  }
  async _setMapView() {
    const e = this._mapChange && this._getMapInfo(this._mapChange.id);
    if (e && this._mapChange) {
      this._mapInfo = e, this._initLayerExpressions(), this._enableCreateFeatures = this._mapInfo.enableCreateFeatures, this._mapView = this._mapChange.mapView, this._initMapZoom(), this._mapView && (this._mapView.popupEnabled = !1, S(this._mapView));
      const t = !this.defaultCenter || this._defaultCenterHonored ? void 0 : this.defaultCenter?.split(";").map((a) => Number.parseFloat(a)), i = !this.defaultLevel || this._defaultLevelHonored ? void 0 : Number.parseInt(this.defaultLevel, 10);
      t && i && (await this._mapView?.goTo({
        center: t,
        zoom: i
      }), this._defaultCenterHonored = !0, this._defaultLevelHonored = !0);
    }
  }
  _initMapZoom() {
    this.enableZoom ? this.enableZoom && this._mapView?.ui.add({
      component: "zoom",
      position: "top-left",
      index: 0
    }) : this._mapView?.ui.remove("zoom");
  }
}
w("crowdsource-manager", V);
export {
  V as CrowdsourceManager
};
