import { c as E } from "../../chunks/runtime.js";
import { css as L, html as n } from "lit";
import { keyed as C } from "lit/directives/keyed.js";
import P from "@arcgis/core/widgets/Features/FeaturesViewModel.js";
import { u as R } from "../../chunks/useT9n.js";
import { classes as x } from "@arcgis/toolkit/dom";
import { usePropertyChange as V } from "@arcgis/lumina/controllers";
import { m as H } from "../../chunks/useViewModel.js";
import { LitElement as S, createEvent as y, renderElement as z, safeClassMap as c, nothing as p } from "@arcgis/lumina";
import { substitute as g, formatNumber as F } from "@arcgis/core/intl.js";
import { watch as f } from "@arcgis/core/core/reactiveUtils.js";
import { t as Z, z as G, b as j } from "../../chunks/action-utils.js";
import { stripHTML as A } from "@arcgis/core/applications/Components/stringUtils.js";
import I from "@arcgis/core/core/Collection.js";
import { g as K } from "../../chunks/feature-utils.js";
import { renderingSanitizer as T } from "@arcgis/core/applications/Components/sanitizerUtils.js";
import { createRef as M, ref as w } from "lit-html/directives/ref.js";
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
v4.34.7 */
const d = "arcgis-features", o = {
  // Features
  base: d,
  container: `${d}__container`,
  contentContainer: `${d}__content-container`,
  contentFeature: `${d}__content-feature`,
  flowItemCollapsed: `${d}__flow-item--collapsed`,
  header: `${d}__header`,
  footer: `${d}__footer`,
  featureMenuObserver: `${d}__feature-menu-observer`,
  actionExit: `${d}__action--exit`,
  loader: `${d}__loader`,
  paginationText: `${d}__pagination-text`,
  paginationActionBar: `${d}__pagination-action-bar`,
  paginationMenuButton: `${d}__pagination-menu-button`,
  paginationPrevious: `${d}__pagination-previous`
}, U = L`:host{display:flex;overflow:hidden;flex:1 1 auto}.arcgis-features{--calcite-color-background: var(--calcite-color-foreground-1);display:flex;overflow:hidden;flex:1 1 auto;flex-direction:column}.arcgis-features img{image-orientation:from-image}.arcgis-features__flow-item--collapsed{--calcite-flow-item-header-border-block-end: none}.arcgis-features__container{display:flex;flex:1 1 auto;background-color:var(--calcite-color-foreground-1)}.arcgis-features__container calcite-list{width:100%}.arcgis-features__container:not(:empty){padding:var(--calcite-spacing-md)}.arcgis-features .arcgis-feature,.arcgis-features .arcgis-feature-relationship,.arcgis-features .arcgis-feature-utility-network-associations{background-color:transparent}.arcgis-features__heading{word-break:break-word;word-wrap:break-word}.arcgis-features__header,.arcgis-features__footer{display:flex;align-items:center;justify-content:flex-end;background-color:var(--calcite-color-foreground-1)}.arcgis-features__footer{flex:1}.arcgis-features__pagination-text{padding-inline:var(--calcite-spacing-sm);color:var(--calcite-color-text-3);font-size:var(--calcite-font-size-sm)}.arcgis-features__loader{align-self:center;padding-inline:var(--calcite-spacing-lg)}.arcgis-features__pagination-action-bar{flex:1}.arcgis-features__pagination-menu-button{border-inline-start:var(--calcite-border-width-sm) solid var(--calcite-color-border-3)}.arcgis-features__icon{display:inline-block;flex:0 0 var(--calcite-spacing-lg);width:var(--calcite-spacing-lg);height:var(--calcite-spacing-lg)}.arcgis-features__action-image{flex:0 0 var(--calcite-spacing-lg);background-position:50% 50%;background-repeat:no-repeat;background-size:contain;width:var(--calcite-spacing-lg);height:var(--calcite-spacing-lg)}.arcgis-features__header{border-block-end:var(--calcite-border-width-sm) solid var(--calcite-color-border-3)}.arcgis-features__content-feature{--calcite-flow-item-footer-padding: 0}.arcgis-features__feature-menu-observer{position:relative;bottom:var(--calcite-spacing-xxl);z-index:2;text-align:center}.arcgis-features__action--exit{transform:scaleX(-1)}`;
function W(h) {
  switch (h?.type) {
    case "point":
      return h;
    case "extent":
      return h.center;
    case "polygon":
      return h.centroid;
    case "multipoint":
    case "polyline":
      return h.extent?.center;
    default:
      return null;
  }
}
const $ = G.clone();
function X(h) {
  return h?.declaredClass.startsWith("esri.layers.") ?? !1;
}
const q = H(P);
class J extends S {
  constructor() {
    super(...arguments), this._featureMenuIntersectionObserverCallback = ([e]) => {
      e?.isIntersecting && this.viewModel.featurePage != null && this.viewModel.featurePage++;
    }, this._featureMenuIntersectionObserver = new IntersectionObserver(this._featureMenuIntersectionObserverCallback, {
      root: window.document
    }), this._featureMenuIntersectionObserverNode = null, this._rootFlowItemNode = M(), this._featureMenuViewportNode = M(), this._actionBarMenuNode = M(), this._flowContainerNode = M(), this.messages = R(), this._selectedFeatureComponent = M(), this._cancelOpenRelatedFeature = () => {
      const { _openRelatedFeatureAbortController: e } = this;
      e && e.abort(), this._openRelatedFeatureAbortController = null;
    }, this._openRelatedFeatureAbortController = null, this.flowItems = new I(), this.viewModel = q(this), this.actions = this.viewModel.actions, this.active = this.viewModel.active, this.autoDestroyDisabled = !1, this.collapsed = !1, this.content = this.viewModel.content, this.defaultPopupTemplateEnabled = this.viewModel.defaultPopupTemplateEnabled, this.featureCount = this.viewModel.featureCount, this.featureMenuOpen = this.viewModel.featureMenuOpen, this.featureMenuTitle = this.viewModel.featureMenuTitle, this.featureNavigationTop = !1, this.features = this.viewModel.features, this.featuresPerPage = this.viewModel.featuresPerPage, this.featureViewModelAbilities = this.viewModel.featureViewModelAbilities, this.goToOverride = this.viewModel.goToOverride, this.headerActions = new I(), this.heading = this.viewModel.title, this.headingLevel = 2, this.hideActionBar = !1, this.hideCloseButton = !1, this.hideFeatureMenuHeading = !1, this.hideFeatureNavigation = !1, this.hideFeatureListLayerTitle = !1, this.hideFlow = !1, this.hideHeading = !1, this.hideSpinner = !1, this.highlightDisabled = this.viewModel.highlightEnabled, this.includeDefaultActionsDisabled = this.viewModel.includeDefaultActions, this.initialDisplayMode = this.viewModel.initialDisplayMode, this.location = this.viewModel.location, this.map = this.viewModel.map, this.promises = this.viewModel.promises, this.responsiveActionsEnabled = !1, this.selectedFeature = this.viewModel.selectedFeature, this.selectedFeatureIndex = this.viewModel.selectedFeatureIndex, this.showCollapseButton = !1, this.spatialReference = this.viewModel.spatialReference, this.state = this.viewModel.state, this.timeZone = this.viewModel.timeZone, this.updateLocationEnabled = this.viewModel.updateLocationEnabled, this.view = this.viewModel.view, this.visible = this.viewModel.visible, this.arcgisPropertyChange = V()("active", "collapsed", "featureCount", "featureMenuOpen", "features", "promises", "selectedDrillInFeature", "selectedFeature", "selectedFeatureComponent", "selectedFeatureIndex", "state", "visible"), this.arcgisReady = y(), this.arcgisClose = y(), this.arcgisTriggerAction = y();
  }
  static {
    this.properties = { _openRelatedFeatureAbortController: 16, flowItems: 16, _hideActionText: 16, _featureNavigationVisible: 16, _isCollapsed: 16, _collapseEnabled: 16, viewModel: 0, actions: 0, active: 0, autoDestroyDisabled: 5, collapsed: 5, content: 1, defaultPopupTemplateEnabled: 5, featureCount: 0, featureMenuOpen: 5, featureMenuTitle: 1, featureNavigationTop: 5, features: 0, featuresPerPage: 9, featureViewModelAbilities: 0, goToOverride: 0, headerActions: 0, heading: 1, featuresTitle: 1, headingLevel: 9, hideActionBar: 5, hideCloseButton: 5, hideFeatureMenuHeading: 5, hideFeatureNavigation: 5, hideFeatureListLayerTitle: 5, hideFlow: 5, hideHeading: 5, hideSpinner: 5, highlightDisabled: 5, icon: 1, includeDefaultActionsDisabled: 5, initialDisplayMode: 1, label: 1, location: 0, map: 0, messageOverrides: 0, position: 1, referenceElement: 1, promises: 0, responsiveActionsEnabled: 5, selectedDrillInFeature: 32, selectedFeature: 0, selectedFeatureComponent: 32, selectedFeatureIndex: 9, showCollapseButton: 5, spatialReference: 0, state: 3, timeZone: 1, updateLocationEnabled: 5, view: 0, visible: 5, closed: 5 };
  }
  static {
    this.styles = U;
  }
  get _hideActionText() {
    if (!this.responsiveActionsEnabled)
      return !1;
    const e = this.viewModel.view?.widthBreakpoint;
    return e === "xsmall" || e === "small" || e === "medium";
  }
  get _featureNavigationVisible() {
    return this.viewModel.active && this.viewModel.featureCount > 1 && !!this.viewModel.selectedFeature && !this.hideFeatureNavigation;
  }
  get _isCollapsed() {
    return this._collapseEnabled && this.collapsed;
  }
  get _collapseEnabled() {
    return this.showCollapseButton && (this.initialDisplayMode === "list" || !!(this.heading || this.viewModel.selectedFeatureViewModel?.title) && !!(this.content || this.viewModel.selectedFeatureViewModel?.content));
  }
  get featuresTitle() {
    return this.heading;
  }
  set featuresTitle(e) {
    this.heading = e;
  }
  get selectedDrillInFeature() {
    const e = Array.from(this.flowItems).at(-1);
    return e && "graphic" in e ? e.graphic ?? null : null;
  }
  get selectedFeatureComponent() {
    return this._selectedFeatureComponent.value ?? null;
  }
  get closed() {
    return !this.visible;
  }
  set closed(e) {
    this.visible = !e;
  }
  async clear() {
    return this.viewModel.clear();
  }
  async close() {
    this.viewModel.visible = !1;
  }
  async destroy() {
    await this.manager.destroy(), await this._destroySpinner(this.referenceElement), this._cancelOpenRelatedFeature(), this._removeFlowItems(), this._unobserveFeatureMenuObserver(), this._featureMenuIntersectionObserver?.disconnect();
  }
  async fetchFeatures(e, t) {
    return await this.viewModel.fetchFeatures(e, t);
  }
  async open(e) {
    this.viewModel.open(e);
  }
  async next() {
    return this.viewModel.next();
  }
  async previous() {
    return this.viewModel.previous();
  }
  async setFocus() {
    this._flowContainerNode.value?.setFocus();
  }
  async triggerAction(e) {
    if (!e.disabled)
      return e && e.type === "toggle" && (e.value = !e.value), await Z(e, this.viewModel);
  }
  loaded() {
    this.manager.onLifecycle(() => [
      f(() => this.viewModel?.selectedFeatureIndex, (e, t) => this._selectedFeatureIndexUpdated(e, t)),
      f(() => this.viewModel?.view, () => this._viewChange()),
      f(() => this._spinnerEl?.screenLocation, () => this._closeOpenActionMenu()),
      f(() => this.selectedFeatureComponent?.viewModel, () => this._removeFlowItems()),
      f(() => this.viewModel?.featureViewModels, () => this._featureMenuViewportScrollTop()),
      f(() => [this.flowItems?.length, this.featureMenuOpen], () => {
        this.setFocus();
      }),
      f(() => this.referenceElement, (e, t) => {
        this._destroySpinner(t), this._createSpinner();
      }, { initial: !0 }),
      f(() => [
        this.hideSpinner,
        this.viewModel?.view,
        this.viewModel?.location,
        this.viewModel?.waitingForResult,
        this.viewModel?.view
      ], () => void this._createSpinner(), { initial: !0 })
    ]);
  }
  _handleClose() {
    this.close(), this.arcgisClose.emit();
  }
  _groupResultsByLayer() {
    const { featureViewModels: e } = this.viewModel, t = /* @__PURE__ */ new Map();
    return e.forEach((i) => {
      const a = i?.graphic;
      if (!a)
        return;
      const s = K(a), r = X(s) ? s : null, l = t.get(r) ?? [];
      t.set(r, [...l, i]);
    }), t;
  }
  _handleCollapseToggle() {
    this.collapsed = !this.collapsed;
  }
  async _openRelatedFeature(e) {
    this._cancelOpenRelatedFeature();
    const t = new AbortController();
    this._openRelatedFeatureAbortController = t, await e.updateGeometry();
    const i = e.graphic, a = i?.geometry;
    if (a == null || i == null)
      return;
    this._removeFlowItems(), await this.viewModel.zoomTo({ target: a });
    const s = W(a);
    s != null && (this.location = s), this.features = [i], this.visible = !0, await this.setFocus(), this._openRelatedFeatureAbortController === t && (this._openRelatedFeatureAbortController = null);
  }
  _handlePaginationMenuButton() {
    this._updateFeatureMenu();
  }
  _openFeatureMenu() {
    this._updateFeatureMenu(!0);
  }
  _closeFeatureMenu() {
    this._updateFeatureMenu(!1);
  }
  _updateFeatureMenu(e = !this.featureMenuOpen) {
    this.featureMenuOpen = e;
  }
  _previousFeature() {
    this.viewModel.previous();
  }
  _nextFeature() {
    this.viewModel.next();
  }
  _handleFeatureBack() {
    this.initialDisplayMode === "list" ? (this.selectedFeatureIndex = -1, this.setFocus()) : this._openFeatureMenu();
  }
  _handleFeatureMenuBack() {
    this.initialDisplayMode === "list" ? (this.selectedFeatureIndex = -1, this.setFocus()) : this.featureMenuOpen && this._closeFeatureMenu();
  }
  _setActiveFeature(e) {
    const { viewModel: t } = this;
    t.activeFeature = t.features?.[e] || null;
  }
  _removeActiveFeature() {
    this.viewModel.activeFeature = null;
  }
  _selectFeature(e) {
    this.viewModel.selectedFeatureIndex = e, this.initialDisplayMode === "feature" ? this._handleFeatureMenuBack() : this.setFocus();
  }
  _unobserveFeatureMenuObserver() {
    this._featureMenuIntersectionObserverNode && this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode);
  }
  _featureMenuIntersectionObserverCreated(e) {
    this._unobserveFeatureMenuObserver(), e && this._featureMenuIntersectionObserver.observe(e), this._featureMenuIntersectionObserverNode = e;
  }
  _getActionTitle(e) {
    const { messages: t, selectedFeature: i } = this, { id: a } = e, s = i?.attributes, r = e.title ?? "", l = a === "zoom-to-feature" ? g(r, { messages: t }) : a === "remove-selected-feature" ? g(r, { messages: t }) : a === "zoom-to-clustered-features" ? g(r, { messages: t }) : a === "browse-clustered-features" ? g(r, { messages: t }) : e.title;
    return l && s ? g(l, s) : l ?? "";
  }
  _onMainKeydown(e) {
    const { key: t } = e;
    t === "ArrowLeft" && (e.stopPropagation(), this._handleFeatureMenuBack(), this.previous(), this.setFocus()), t === "ArrowRight" && (e.stopPropagation(), this._handleFeatureMenuBack(), this.next(), this.setFocus());
  }
  _featureMenuViewportScrollTop() {
    this._featureMenuViewportNode && this._featureMenuViewportNode.value?.scrollContentTo({ top: 0 });
  }
  _selectedFeatureIndexUpdated(e, t) {
    const { featureCount: i, waitingForResult: a } = this.viewModel;
    a || !i || e === t || e === -1 || (this._removeFlowItems(), this._rootFlowItemNode.value?.scrollContentTo({ top: 0 }));
  }
  _triggerAction(e) {
    this.triggerAction(e), this.arcgisTriggerAction.emit({ action: e });
  }
  _viewChange() {
    this.viewModel.clear(), this.viewModel.visible = !1;
  }
  _closeOpenActionMenu() {
    const { _actionBarMenuNode: e } = this;
    e.value && (e.value.menuOpen = !1);
  }
  _removeFlowItems() {
    this.flowItems.removeAll();
  }
  _getDrillInFlowItemDescription(e) {
    switch (e.flowType) {
      case "feature":
      case "feature-association":
      case "feature-utility-network-associations":
        return "";
      // flowItem.description ?? "";
      case "feature-relationship":
        return e.allItemsDescription;
      case "feature-utility-network-association-type":
        return "";
    }
  }
  _handleDrillInBackClick() {
    this.flowItems?.pop();
  }
  _getHeading() {
    const { hideHeading: e } = this, { title: t, selectedFeatureViewModel: i } = this.viewModel;
    return i && !e ? i?.state === "error" ? this.messages?.errorMessage ?? "" : i?.title || "" : !e && t ? t : "";
  }
  async _destroySpinner(e) {
    e?.manager?.component?.extraContent?.remove(this._spinnerEl);
  }
  async _createSpinner() {
    const e = this.referenceElement;
    e && (await this._destroySpinner(e), this._spinnerEl = z(n`<arcgis-spinner .label=${this.messages.loading ?? ""} .trackLocation=${!this.hideSpinner && this.viewModel?.waitingForResult} .location=${this.viewModel?.location ?? void 0} .view=${this.viewModel?.view ?? void 0}></arcgis-spinner>`), e.manager?.component?.extraContent?.add(this._spinnerEl));
  }
  render() {
    return n`<div class=${c(o.base)} @keydown=${this._onMainKeydown}>${this._renderHeader()}${this._renderContentContainer()}</div>`;
  }
  _renderFeatureNavigation() {
    return [
      this._renderPagination(),
      this.initialDisplayMode === "list" ? this._renderFeaturePaginationText() : this._renderFeatureMenuButton()
    ];
  }
  _renderHeader() {
    return this.featureNavigationTop && this._featureNavigationVisible ? n`<div class=${c(o.header)}>${this._renderFeatureNavigation()}</div>` : null;
  }
  _renderFooter() {
    return !this.featureNavigationTop && this._featureNavigationVisible ? n`<div class=${c(o.footer)} slot=footer>${this._renderFeatureNavigation()}</div>` : null;
  }
  _renderFeaturePaginationText() {
    const { messages: e, viewModel: t } = this, { featureCount: i, selectedFeatureIndex: a } = t;
    return n`<div class=${c(o.paginationText)}>${g(e.pageText ?? "", {
      index: F(a + 1),
      total: F(i)
    })}</div>`;
  }
  _renderFeatureMenuButton() {
    const { messages: e, viewModel: t } = this, { featureCount: i, selectedFeatureIndex: a, pendingPromisesCount: s } = t;
    return n`<calcite-action appearance=solid class=${c(o.paginationMenuButton)} icon=list .label=${e.selectFeature} .loading=${s > 0} @click=${this._handlePaginationMenuButton} scale=s .text=${g(e.pageText ?? "", {
      index: F(a + 1),
      total: F(i)
    })} text-enabled title=${e.selectFeature ?? p}></calcite-action>`;
  }
  _renderPagination() {
    const { previous: e, next: t } = this.messages;
    return n`<calcite-action-bar class=${c(o.paginationActionBar)} expand-disabled layout=horizontal overflow-actions-disabled scale=s><calcite-action-group scale=s><calcite-action appearance=solid class=${c(o.paginationPrevious)} icon=chevron-left icon-flip-rtl .label=${e ?? ""} @click=${this._previousFeature} scale=s .text=${e ?? ""} title=${e ?? "" ?? p}></calcite-action><calcite-action appearance=solid icon=chevron-right icon-flip-rtl .label=${t ?? ""} @click=${this._nextFeature} scale=s .text=${t ?? ""} title=${t ?? "" ?? p}></calcite-action></calcite-action-group></calcite-action-bar>`;
  }
  _renderFeatureMenuItem(e) {
    const { initialDisplayMode: t } = this, { selectedFeatureViewModel: i, featureViewModels: a } = this.viewModel, s = e === i, r = a.indexOf(e);
    return n`<calcite-list-item @blur=${this._removeActiveFeature} @focus=${() => this._setActiveFeature(r)} @mouseleave=${this._removeActiveFeature} @mouseover=${() => this._setActiveFeature(r)} .selected=${s} @calciteListItemSelect=${() => this._selectFeature(r)}><span .innerHTML=${(T.sanitize(e.title) || this.messages.untitled) ?? ""} slot=content></span>${t === "list" ? n`<calcite-icon flip-rtl icon=chevron-right scale=s slot=content-end></calcite-icon>` : null}</calcite-list-item>`;
  }
  _renderFeatureMenu() {
    const { messages: e, viewModel: t } = this, i = this._groupResultsByLayer(), a = this.initialDisplayMode === "list" ? "none" : "single";
    return t.featureViewModels.length ? n`<calcite-list display-mode=flat .label=${e?.featuresList ?? ""} selection-appearance=icon .selectionMode=${a}>${Array.from(i.keys(), (s) => {
      const r = i.get(s)?.map((u) => this._renderFeatureMenuItem(u)), l = s ? s.title ?? this.messages.untitled : null;
      return !this.hideFeatureListLayerTitle && l !== null ? C(s ?? "map-graphics", n`<calcite-list-item-group .heading=${l}>${r}</calcite-list-item-group>`) : r;
    })}</calcite-list>` : null;
  }
  _renderHeaderAction(e) {
    const t = e.title || "";
    return e.visible ? n`<calcite-action .active=${e.type === "toggle" ? e.value : !1} appearance=solid .disabled=${e.disabled} .icon=${e.icon ?? void 0} .indicator=${e.active} .loading=${e.active} @click=${() => this._triggerAction(e)} slot=header-actions-end .text=${t} title=${t ?? p}></calcite-action>` : null;
  }
  _renderHeaderActions() {
    return this.headerActions.map((e) => this._renderHeaderAction(e)).toArray();
  }
  _renderContentFeature() {
    const { headingLevel: e, hideCloseButton: t, _isCollapsed: i, _collapseEnabled: a, featureNavigationTop: s, flowItems: r, initialDisplayMode: l, selectedFeature: u, featureMenuOpen: v } = this, { active: _ } = this.viewModel, m = this._getHeading();
    if (l === "list" && !u)
      return null;
    const b = r.length === 0 && (l === "list" ? !!u : !v);
    return n`<calcite-flow-item class=${c(x({
      [o.contentFeature]: !0,
      [o.flowItemCollapsed]: i
    }))} .closable=${!t} .closed=${!_} .collapsed=${i} .collapseDirection=${s ? "down" : "up"} .collapsible=${a} .headingLevel=${e} .selected=${b} @calciteFlowItemBack=${this._handleFeatureBack} .loading=${!!this._openRelatedFeatureAbortController} @calciteFlowItemClose=${this._handleClose} @calciteFlowItemToggle=${this._handleCollapseToggle} .heading=${A(m)} ${w(this._rootFlowItemNode)}>${this._renderHeaderActions()}${this._renderActionBar()}<div class=${c(x(o.container, o.contentContainer))}>${this._renderContent()}</div>${this._renderFooter()}</calcite-flow-item>`;
  }
  _renderFeatureMenuContainer() {
    const { viewModel: e, hideCloseButton: t, featureMenuTitle: i, messages: a, initialDisplayMode: s, featureMenuOpen: r, selectedFeature: l, _collapseEnabled: u, _isCollapsed: v, featureNavigationTop: _, headingLevel: m } = this, { active: b, featureViewModels: k, pendingPromisesCount: B } = e, O = i ?? a.selectFeature;
    if (s === "feature" && !r)
      return null;
    const D = s === "list" ? !l : r;
    return n`<calcite-flow-item class=${c(x({
      [o.flowItemCollapsed]: v
    }))} .closable=${s === "list" && !t} .closed=${!b} .collapsed=${s === "list" && v} .collapseDirection=${_ ? "down" : "up"} .collapsible=${s === "list" && u} .description=${this.hideFeatureMenuHeading ? void 0 : g(a.total ?? "", {
      total: k.length
    })} .heading=${this.hideFeatureMenuHeading ? void 0 : O} .headingLevel=${m} .loading=${e.waitingForContents} .selected=${D} @calciteFlowItemBack=${(N) => {
      N.preventDefault(), this._handleFeatureMenuBack();
    }} @calciteFlowItemClose=${this._handleClose} @calciteFlowItemToggle=${this._handleCollapseToggle} ${w(this._featureMenuViewportNode)}>${s === "list" ? this._renderHeaderActions() : null}${B > 0 ? n`<calcite-loader class=${c(o.loader)} inline .label=${a.loading ?? ""} slot=header-actions-end></calcite-loader>` : null}<div class=${c(o.container)}>${this._renderFeatureMenu()}</div><div class=${c(o.featureMenuObserver)} ${w(this._featureMenuIntersectionObserverCreated)}></div>${s === "feature" ? n`<calcite-button appearance=transparent @click=${this._handleFeatureMenuBack} slot=footer-actions width=full>${a.back}</calcite-button>` : null}</calcite-flow-item>`;
  }
  _renderFlowItem(e, t) {
    const { messages: i, hideCloseButton: a, active: s } = this, r = "graphic" in e && "isFeatureFromTable" in e && !e.isFeatureFromTable, l = e.flowType === "feature-association", u = i.returnToInitialFeature ?? "", v = i?.selectFeature, _ = this._getActionTitle($);
    return n`<calcite-flow-item .closable=${!a} .closed=${!s} .description=${A(this._getDrillInFlowItemDescription(e) ?? "")} .heading=${this.hideHeading ? void 0 : A(e.heading ?? "")} .selected=${t} @calciteFlowItemBack=${(m) => {
      m.preventDefault(), this._handleDrillInBackClick();
    }} .loading=${!!this._openRelatedFeatureAbortController} @calciteFlowItemClose=${this._handleClose}><calcite-action appearance=transparent class=${c(o.actionExit)} icon=move-up @click=${this._removeFlowItems} slot=header-actions-start .text=${u ?? ""} title=${u ?? "" ?? p}></calcite-action>${r ? n`<calcite-action appearance=transparent icon=zoom-to-object @click=${() => this._openRelatedFeature(e)} slot=header-actions-end .text=${v ?? ""} title=${v ?? p}></calcite-action>` : null}${l ? n`<calcite-action-bar expand-disabled expanded scale=s slot=action-bar><calcite-action-group overlay-positioning=fixed scale=s><calcite-action appearance=solid .disabled=${$.disabled} .icon=${$.icon ?? void 0} .loading=${$.active} scale=s text-enabled .text=${_} title=${_ ?? p} @click=${() => j(this.viewModel, e)}></calcite-action></calcite-action-group></calcite-action-bar>` : null}<div class=${c(o.container)}>${e}</div></calcite-flow-item>`;
  }
  _renderContentContainer() {
    const e = this.flowItems?.toArray(), t = e?.map((a, s) => this._renderFlowItem(a, this.initialDisplayMode === "list" || !this.featureMenuOpen && s === e.length - 1)), i = this.initialDisplayMode === "list" ? [this._renderFeatureMenuContainer(), this._renderContentFeature(), t] : [this._renderContentFeature(), t, this._renderFeatureMenuContainer()];
    return this.hideFlow ? i : n`<calcite-flow ${w(this._flowContainerNode)}>${i}</calcite-flow>`;
  }
  _renderActionBar() {
    return !this._isCollapsed && !this.hideActionBar && this.viewModel.allActions?.length ? n`<calcite-action-bar expand-disabled .expanded=${!this._hideActionText} scale=s slot=action-bar><calcite-action-group overlay-positioning=fixed scale=s ${w(this._actionBarMenuNode)}>${this._renderActions()}</calcite-action-group></calcite-action-bar>` : null;
  }
  _renderActions() {
    return this.viewModel.allActions.toArray().map((e) => {
      const t = this._getActionTitle(e);
      return n`<calcite-action .active=${e.type === "toggle" ? e.value : !1} appearance=solid .disabled=${e.disabled} .icon=${e.icon ?? void 0} .loading=${e.active} scale=s .textEnabled=${!this._hideActionText} .text=${t ?? ""} title=${t ?? p} .hidden=${!e.visible} @click=${() => this._triggerAction(e)}></calcite-action>`;
    });
  }
  _renderContent() {
    const { content: e, selectedFeatureViewModel: t } = this.viewModel;
    return t ? C(t, n`<arcgis-feature .defaultPopupTemplateEnabled=${this.defaultPopupTemplateEnabled} .flowItems=${this.flowItems} .location=${this.location} .graphic=${t.graphic} .headingLevel=${this.headingLevel + 1} hide-heading .map=${this.map} .referenceElement=${this.referenceElement} show-relationship-content show-utility-network-content .spatialReference=${this.spatialReference} .timeZone=${this.timeZone} ${w(this._selectedFeatureComponent)}></arcgis-feature>`) : typeof e == "string" ? C(e, n`<div .innerHTML=${T.sanitize(e) ?? ""}></div>`) : e ?? null;
  }
}
E("arcgis-features", J);
export {
  J as ArcgisFeatures
};
