/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import { c as P } from "../../chunks/runtime.js";
import { css as F, html as d } from "lit";
import { keyed as w } from "lit/directives/keyed.js";
import { repeat as D } from "lit/directives/repeat.js";
import O from "@arcgis/core/widgets/LayerList/LayerListViewModel.js";
import { classes as R } from "@arcgis/toolkit/dom";
import { generateGuid as B } from "@arcgis/toolkit/string";
import { createRef as y, ref as x } from "lit/directives/ref.js";
import { u as U } from "../../chunks/useT9n.js";
import { m as S } from "../../chunks/useViewModel.js";
import { g as L } from "../../chunks/globalCss.js";
import { c as u } from "../../chunks/layer-list-item-indicator.js";
import { g as p, a as C, m as N, b as G, r as j, s as Y, c as H, d as V, e as Z } from "../../chunks/layer-list-utils.js";
import g from "@arcgis/core/core/Collection.js";
import { on as $, watch as q } from "@arcgis/core/core/reactiveUtils.js";
import { LitElement as J, createEvent as K, renderElement as E, safeClassMap as I, nothing as T } from "@arcgis/lumina";
import { usePropertyChange as Q } from "@arcgis/lumina/controllers";
import { reEmitEvent as W } from "@arcgis/lumina/controllers/accessor";
import "@arcgis/toolkit/function";
import { u as X } from "../../chunks/useCloseEvent.js";
import { ArcgisLayerListItem as ee } from "./layer-list-item/customElement.js";
const te = F`.esri-widget__heading{color:var(--calcite-color-text-2);margin:0 0 .5rem;font-weight:var(--calcite-font-weight-semibold)}h1.esri-widget__heading{font-size:var(--calcite-font-size-xl)}h2.esri-widget__heading{font-size:var(--calcite-font-size-md)}h3.esri-widget__heading,h4.esri-widget__heading,h5.esri-widget__heading,h6.esri-widget__heading{font-size:var(--calcite-font-size)}.esri-widget{box-sizing:border-box;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);font-size:var(--calcite-font-size);line-height:var(--calcite-font-line-height-relative-tight)}.esri-widget *,.esri-widget :before,.esri-widget :after{box-sizing:inherit}.esri-widget.esri-widget--disabled>*{opacity:.4;pointer-events:none}.esri-widget.esri-widget--compact{--esri-widget-padding-y: 0;--esri-widget-padding-x: 0}.esri-widget__anchor{color:var(--calcite-color-text-2)}.esri-widget__anchor:hover{color:var(--calcite-color-text-3)}.esri-widget__anchor:hover,.esri-widget__anchor:focus{text-decoration:underline}.esri-widget__anchor--disabled{opacity:.4;pointer-events:none}.esri-widget__header{background-color:var(--calcite-color-foreground-1);flex:1 0 100%;justify-content:space-between;align-items:center;width:100%;min-height:48px;padding:12px 0 12px 15px;display:flex}.esri-widget__heading{word-break:break-word}.esri-widget__header .esri-widget__heading{width:calc(100% - 48px);text-align:initial;color:var(--calcite-color-text-1);align-items:center;margin:0;padding:0;display:flex}.esri-widget__header-button{appearance:none;cursor:pointer;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);border:none;flex:0 0 48px;justify-content:center;align-self:stretch;align-items:center;width:48px;padding:0;display:flex}.esri-widget__footer{background-color:var(--calcite-color-foreground-1);justify-content:center;align-items:center;width:100%;min-height:48px;display:flex}.esri-widget__footer-pagination{color:var(--calcite-color-text-2);justify-content:space-between;align-items:center;display:flex}.esri-widget__footer-pagination-previous-button,.esri-widget__footer-pagination-next-button{cursor:pointer;background-color:var(--calcite-color-foreground-1);border:0;margin:0 7px;padding:12px 15px;transition:background-color .125s ease-in-out}.esri-widget__footer-pagination-previous-button:hover,.esri-widget__footer-pagination-previous-button:focus,.esri-widget__footer-pagination-next-button:hover,.esri-widget__footer-pagination-next-button:focus{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1)}.esri-menu{visibility:hidden;z-index:1;background-clip:padding;background-color:var(--calcite-color-foreground-1);background-clip:padding-box;width:100%;max-height:0;margin:2px 0 0;padding:0;font-size:var(--calcite-font-size);line-height:var(--calcite-spacing-xl);position:absolute;top:100%;left:0;overflow:hidden;box-shadow:0 1px 2px #0000004d}.esri-menu .esri-menu__header{color:var(--calcite-color-text-inverse);background-color:var(--calcite-color-inverse);padding:6px 12px}.esri-menu__list{margin:0;padding:0;list-style:none}.esri-menu__list-item{cursor:pointer;border-top:1px solid #adadad4d;border-left:3px solid #0000;padding:.8em 1em}.esri-menu__list-item [class^=esri-icon-],.esri-menu__list-item [class*=" esri-icon-"]{padding-right:2.8px}.esri-menu__list-item:first-child{border-top:none}.esri-menu__list-item--focus,.esri-menu__list-item:hover,.esri-menu__list-item:focus{background-color:var(--calcite-color-foreground-1)}.esri-menu__list-item:active{background-color:var(--calcite-color-foreground-current)}.esri-menu__list-item--active,.esri-menu__list-item--active:hover,.esri-menu__list-item--active:focus{background-color:var(--calcite-color-foreground-1);border-left-color:var(--calcite-color-brand)}.esri-widget__table{border-collapse:collapse;color:var(--calcite-color-text-1);border:none;width:100%;line-height:var(--calcite-font-line-height-relative-tight)}.esri-widget__table tr:nth-child(odd){background-color:var(--calcite-color-transparent)}.esri-widget__table tr:nth-child(2n){background-color:var(--calcite-color-transparent-press)}.esri-widget__table tr a{color:var(--calcite-color-text-2)}.esri-widget__table tr a:hover,.esri-widget__table tr a:focus{color:var(--calcite-color-text-1)}.esri-widget__table tr td,.esri-widget__table tr th{vertical-align:top;word-break:break-word;padding:.5em .7em;font-size:var(--calcite-font-size-sm);font-weight:var(--calcite-font-weight-regular)}.esri-widget__table tr th{text-align:left;border-right:3px solid #0000000d;width:50%}.esri-widget__table tr td{width:50%}.esri-input{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1);border:1px solid #959595;font-size:var(--calcite-font-size)}.esri-input::-ms-clear{display:none}.esri-input::placeholder{opacity:1;color:var(--calcite-color-text-2)}.esri-input:placeholder-shown{text-overflow:ellipsis}.esri-input[type=text],.esri-input[type=password],.esri-input[type=number]{height:32px;padding:0 .5em}calcite-combobox.esri-input{border:none}.esri-widget__content--empty{text-align:center;color:var(--calcite-color-border-input);flex-flow:column wrap;align-items:center;padding:18px 22px;display:flex}.esri-widget__content--empty h1.esri-widget__heading,.esri-widget__content--empty h2.esri-widget__heading,.esri-widget__content--empty h3.esri-widget__heading,.esri-widget__content--empty h4.esri-widget__heading,.esri-widget__content--empty h5.esri-widget__heading{font-weight:var(--calcite-font-weight-regular)}.esri-widget__content-illustration--empty{width:128px;padding:1rem 0}.esri-widget__content-icon--empty{width:32px;padding:.5rem 0}.esri-select{appearance:none;cursor:pointer;color:var(--calcite-color-text-2);background:var(--calcite-color-foreground-1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-8 -8 32 32' width='32' height='32'%3E%3Cpath d='M8 11.207l-4-4V5.793l4 4 4-4v1.414z' fill='%23adadad' fillrule='nonzero'/%3E%3C/svg%3E") 100% no-repeat;border:1px solid #959595;border-radius:0;width:100%;height:32px;margin:0;padding:0 .5em;font-family:inherit;font-size:.85em;display:block}.esri-select[disabled]{cursor:auto}.esri-select::-ms-expand{display:none}.esri-disabled a,.esri-disabled [role=menu],.esri-disabled [role=checkbox],.esri-disabled [class^=esri-icon-],.esri-disabled [class*=" esri-icon-"]{color:var(--calcite-color-text-3)}.keynav-mode .esri-widget:focus,.keynav-mode .esri-widget :focus{z-index:1;outline-offset:2px;outline:2px solid #adadad}.esri-widget__loader-animation{border:.15em solid #adadad4d;border-top-color:var(--calcite-color-border-input);border-radius:100%;width:1em;height:1em;font-size:var(--calcite-font-size-md);animation:1.25s linear infinite esri-rotate;display:block;transform:translateZ(0)}:dir(rtl) .esri-widget__table th{text-align:right;border-left:3px solid #0000000d;border-right:none}:dir(rtl) .esri-select{background-position:0}:dir(rtl) .esri-menu__list-item{border-left:none;border-right:3px solid #0000}:dir(rtl) .esri-menu__list-item [class^=esri-icon-],:dir(rtl) .esri-menu__list-item [class*=" esri-icon-"]{padding-left:2px;padding-right:0}:dir(rtl) .esri-menu__list-item--active{border-right-color:var(--calcite-color-brand)}.esri-icon-font-fallback-text{clip:rect(0 0 0 0);width:1px;height:1px;position:absolute;overflow:hidden}.esri-rotating{animation:1.25s linear infinite esri-rotate;transform:translateZ(0)}.esri-clearfix:before,.esri-clearfix:after{content:" ";display:table}.esri-clearfix:after{clear:both}.esri-interactive{cursor:pointer}.esri-hidden{display:none!important}.esri-invisible{visibility:hidden!important}.esri-offscreen{position:absolute;top:-999em;left:-999em}.esri-match-height{flex-direction:column;flex:auto;display:flex;overflow:hidden}:host{width:100%;--arcgis-internal-layer-list-item-scroller-max-height: var(--arcgis-internal-panel-height-md)}.item{--calcite-list-item-icon-center: var(--calcite-space-sm)}.table-icon,.catalog-icon{margin-inline-end:0}.action-image{text-align:center;background-position:50%;background-repeat:no-repeat;background-size:contain;flex:0 0 var(--calcite-spacing-xl);width:var(--calcite-spacing-xl);height:var(--calcite-spacing-xl);font-size:14px}.item__filter-container--sticky{z-index:1;position:sticky;top:0}.item__group{margin-top:var(--calcite-spacing-md)}.item__scroller{overflow-y:auto;z-index:0;position:relative}.item__scroller--enabled{max-height:var(--arcgis-internal-layer-list-item-scroller-max-height)}.item__group__header{color:var(--calcite-color-text-2);font-weight:var(--calcite-font-weight-medium)}.item__list-item{cursor:pointer;min-height:var(--calcite-spacing-xxxl)}.item__list-item[class^=esri-icon-],.item__list-item[class*=" esri-icon-"]{padding-inline-end:2.8px}.item__list-item--disabled{cursor:default}.item__list-item-icon{justify-content:center;align-items:center;min-width:var(--calcite-spacing-xxxl);height:var(--calcite-spacing-xxxl);display:flex}.item__list-item-icon span{line-height:0}.arcgis-thumbnail-preview{background-position:50%;width:22px;height:22px}.item__no-matches-message{justify-content:center;align-items:center;height:96px;display:flex}.content-bottom{margin:var(--calcite-spacing-md) 15px}.content-bottom .arcgis-legend__service{padding:0 0 var(--calcite-spacing-md)}.message{margin:var(--calcite-spacing-md) 15px}.visible-icon{visibility:hidden}.item:hover>.visible-toggle>.visible-icon,.item:focus>.visible-toggle>.visible-icon,.item:focus-within>.visible-toggle>.visible-icon{visibility:visible}`, ie = F`@keyframes esri-basemap-slide{0%{opacity:0;margin-top:0;margin-left:0}75%{opacity:0;margin-top:0;margin-left:0}to{opacity:1;margin-top:5px;margin-left:5px}}@keyframes esri-docking-animation{0%{opacity:0}25%{opacity:0}to{opacity:1}}@keyframes popup-intro-animation-down{0%{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:translate(0)}}@keyframes popup-intro-animation-up{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translate(0)}}@supports (-ms-ime-align: auto){.esri-slider__anchor:focus{outline:1px dotted #000}}@keyframes esri-spinner--start-animation{0%{opacity:0;transform:scale(0)}to{opacity:1;transform:scale(1)}}@keyframes esri-spinner--finish-animation{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(0)}}@keyframes esri-spinner--rotate-animation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@media(prefers-reduced-motion){.esri-utility-network-trace__reset-prompt{animation:none!important}}@media(prefers-reduced-motion){.esri-popup--aligned-top-center,.esri-popup--aligned-top-left,.esri-popup--aligned-top-right,.esri-popup--aligned-bottom-center,.esri-popup--aligned-bottom-left,.esri-popup--aligned-bottom-right,.esri-popup--is-docked{animation:none!important}}@media(prefers-reduced-motion:reduce){.esri-fov-overlay{animation:none!important}}@keyframes esri-fade-in-down{0%{opacity:0;transform:translateY(-5px)}25%{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:translate(0)}}@keyframes esri-fade-in-up{0%{opacity:0;transform:translateY(5px)}25%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translate(0)}}@keyframes esri-fade-in{0%{opacity:0}25%{opacity:0}to{opacity:1}}@keyframes esri-fade-in-scale{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes looping-progresss-bar-ani{0%{width:0;left:0}20%{width:20%;left:0}80%{width:20%;left:80%}to{width:0;left:100%}}@keyframes esri-rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes panel-advance{0%{opacity:0;transform:translate(50px) scale(.99)}to{opacity:1;transform:translate(0) scale(1)}}@keyframes panel-retreat{0%{opacity:0;transform:translate(-50px) scale(.99)}to{opacity:1;transform:translate(0) scale(1)}}@keyframes panel-advance--rtl{0%{opacity:0;transform:translate(-50px) scale(.99)}to{opacity:1;transform:translate(0) scale(1)}}@keyframes panel-retreat--rtl{0%{opacity:0;transform:translate(50px) scale(.99)}to{opacity:1;transform:translate(0) scale(1)}}.esri-widget__heading{color:var(--calcite-color-text-2);margin:0 0 .5rem;font-weight:var(--calcite-font-weight-semibold)}h1.esri-widget__heading{font-size:var(--calcite-font-size-xl)}h2.esri-widget__heading{font-size:var(--calcite-font-size-md)}h3.esri-widget__heading,h4.esri-widget__heading,h5.esri-widget__heading,h6.esri-widget__heading{font-size:var(--calcite-font-size)}.esri-widget{box-sizing:border-box;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);font-size:var(--calcite-font-size);line-height:var(--calcite-font-line-height-relative-tight)}.esri-widget *,.esri-widget :before,.esri-widget :after{box-sizing:inherit}.esri-widget.esri-widget--disabled>*{opacity:.4;pointer-events:none}.esri-widget.esri-widget--compact{--esri-widget-padding-y: 0;--esri-widget-padding-x: 0}.esri-widget__anchor{color:var(--calcite-color-text-2)}.esri-widget__anchor:hover{color:var(--calcite-color-text-3)}.esri-widget__anchor:hover,.esri-widget__anchor:focus{text-decoration:underline}.esri-widget__anchor--disabled{opacity:.4;pointer-events:none}.esri-widget__header{background-color:var(--calcite-color-foreground-1);flex:1 0 100%;justify-content:space-between;align-items:center;width:100%;min-height:48px;padding:12px 0 12px 15px;display:flex}.esri-widget__heading{word-break:break-word}.esri-widget__header .esri-widget__heading{width:calc(100% - 48px);text-align:initial;color:var(--calcite-color-text-1);align-items:center;margin:0;padding:0;display:flex}.esri-widget__header-button{appearance:none;cursor:pointer;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);border:none;flex:0 0 48px;justify-content:center;align-self:stretch;align-items:center;width:48px;padding:0;display:flex}.esri-widget__footer{background-color:var(--calcite-color-foreground-1);justify-content:center;align-items:center;width:100%;min-height:48px;display:flex}.esri-widget__footer-pagination{color:var(--calcite-color-text-2);justify-content:space-between;align-items:center;display:flex}.esri-widget__footer-pagination-previous-button,.esri-widget__footer-pagination-next-button{cursor:pointer;background-color:var(--calcite-color-foreground-1);border:0;margin:0 7px;padding:12px 15px;transition:background-color .125s ease-in-out}.esri-widget__footer-pagination-previous-button:hover,.esri-widget__footer-pagination-previous-button:focus,.esri-widget__footer-pagination-next-button:hover,.esri-widget__footer-pagination-next-button:focus{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1)}.esri-menu{visibility:hidden;z-index:1;background-clip:padding;background-color:var(--calcite-color-foreground-1);background-clip:padding-box;width:100%;max-height:0;margin:2px 0 0;padding:0;font-size:var(--calcite-font-size);line-height:var(--calcite-spacing-xl);position:absolute;top:100%;left:0;overflow:hidden;box-shadow:0 1px 2px #0000004d}.esri-menu .esri-menu__header{color:var(--calcite-color-text-inverse);background-color:var(--calcite-color-inverse);padding:6px 12px}.esri-menu__list{margin:0;padding:0;list-style:none}.esri-menu__list-item{cursor:pointer;border-top:1px solid #adadad4d;border-left:3px solid #0000;padding:.8em 1em}.esri-menu__list-item [class^=esri-icon-],.esri-menu__list-item [class*=" esri-icon-"]{padding-right:2.8px}.esri-menu__list-item:first-child{border-top:none}.esri-menu__list-item--focus,.esri-menu__list-item:hover,.esri-menu__list-item:focus{background-color:var(--calcite-color-foreground-1)}.esri-menu__list-item:active{background-color:var(--calcite-color-foreground-current)}.esri-menu__list-item--active,.esri-menu__list-item--active:hover,.esri-menu__list-item--active:focus{background-color:var(--calcite-color-foreground-1);border-left-color:var(--calcite-color-brand)}.esri-widget__table{border-collapse:collapse;color:var(--calcite-color-text-1);border:none;width:100%;line-height:var(--calcite-font-line-height-relative-tight)}.esri-widget__table tr:nth-child(odd){background-color:var(--calcite-color-transparent)}.esri-widget__table tr:nth-child(2n){background-color:var(--calcite-color-transparent-press)}.esri-widget__table tr a{color:var(--calcite-color-text-2)}.esri-widget__table tr a:hover,.esri-widget__table tr a:focus{color:var(--calcite-color-text-1)}.esri-widget__table tr td,.esri-widget__table tr th{vertical-align:top;word-break:break-word;padding:.5em .7em;font-size:var(--calcite-font-size-sm);font-weight:var(--calcite-font-weight-regular)}.esri-widget__table tr th{text-align:left;border-right:3px solid #0000000d;width:50%}.esri-widget__table tr td{width:50%}.esri-input{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1);border:1px solid #959595;font-size:var(--calcite-font-size)}.esri-input::-ms-clear{display:none}.esri-input::placeholder{opacity:1;color:var(--calcite-color-text-2)}.esri-input:placeholder-shown{text-overflow:ellipsis}.esri-input[type=text],.esri-input[type=password],.esri-input[type=number]{height:32px;padding:0 .5em}calcite-combobox.esri-input{border:none}.esri-widget__content--empty{text-align:center;color:var(--calcite-color-border-input);flex-flow:column wrap;align-items:center;padding:18px 22px;display:flex}.esri-widget__content--empty h1.esri-widget__heading,.esri-widget__content--empty h2.esri-widget__heading,.esri-widget__content--empty h3.esri-widget__heading,.esri-widget__content--empty h4.esri-widget__heading,.esri-widget__content--empty h5.esri-widget__heading{font-weight:var(--calcite-font-weight-regular)}.esri-widget__content-illustration--empty{width:128px;padding:1rem 0}.esri-widget__content-icon--empty{width:32px;padding:.5rem 0}.esri-select{appearance:none;cursor:pointer;color:var(--calcite-color-text-2);background:var(--calcite-color-foreground-1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-8 -8 32 32' width='32' height='32'%3E%3Cpath d='M8 11.207l-4-4V5.793l4 4 4-4v1.414z' fill='%23adadad' fillrule='nonzero'/%3E%3C/svg%3E") 100% no-repeat;border:1px solid #959595;border-radius:0;width:100%;height:32px;margin:0;padding:0 .5em;font-family:inherit;font-size:.85em;display:block}.esri-select[disabled]{cursor:auto}.esri-select::-ms-expand{display:none}.esri-disabled a,.esri-disabled [role=menu],.esri-disabled [role=checkbox],.esri-disabled [class^=esri-icon-],.esri-disabled [class*=" esri-icon-"]{color:var(--calcite-color-text-3)}.keynav-mode .esri-widget:focus,.keynav-mode .esri-widget :focus{z-index:1;outline-offset:2px;outline:2px solid #adadad}.esri-widget__loader-animation{border:.15em solid #adadad4d;border-top-color:var(--calcite-color-border-input);border-radius:100%;width:1em;height:1em;font-size:var(--calcite-font-size-md);animation:1.25s linear infinite esri-rotate;display:block;transform:translateZ(0)}:dir(rtl) .esri-widget__table th{text-align:right;border-left:3px solid #0000000d;border-right:none}:dir(rtl) .esri-select{background-position:0}:dir(rtl) .esri-menu__list-item{border-left:none;border-right:3px solid #0000}:dir(rtl) .esri-menu__list-item [class^=esri-icon-],:dir(rtl) .esri-menu__list-item [class*=" esri-icon-"]{padding-left:2px;padding-right:0}:dir(rtl) .esri-menu__list-item--active{border-right-color:var(--calcite-color-brand)}.esri-icon-font-fallback-text{clip:rect(0 0 0 0);width:1px;height:1px;position:absolute;overflow:hidden}.esri-rotating{animation:1.25s linear infinite esri-rotate;transform:translateZ(0)}.esri-clearfix:before,.esri-clearfix:after{content:" ";display:table}.esri-clearfix:after{clear:both}.esri-interactive{cursor:pointer}.esri-hidden{display:none!important}.esri-invisible{visibility:hidden!important}.esri-offscreen{position:absolute;top:-999em;left:-999em}.esri-match-height{flex-direction:column;flex:auto;display:flex;overflow:hidden}.esri-widget--panel{min-width:300px;min-height:32px;padding:var(--arcgis-internal-padding);transition:max-height .25s ease-in-out;overflow-y:auto}:host{display:flex;min-height:var(--calcite-space-3xl);transition:max-height .25s ease-in-out;overflow-y:auto}:host>div{display:flex;width:100%}.filter-no-results{padding:var(--calcite-spacing-md) var(--calcite-space-md-plus)}.table-icon,.catalog-icon{margin-inline-end:0}.action-image{text-align:center;background-position:50%;background-repeat:no-repeat;background-size:contain;flex:0 0 var(--calcite-spacing-xl);width:var(--calcite-spacing-xl);height:var(--calcite-spacing-xl);font-size:var(--calcite-font-size)}.action-menu .action-group{display:none}.action-menu[open] .action-group{display:flex}.active:hover>.visible-toggle>.visible-icon,.active:focus>.visible-toggle>.visible-icon,.active:focus-within>.visible-toggle>.visible-icon{visibility:visible}.status-indicator{margin-inline:0}`, M = "nested", re = S(O);
class oe extends J {
  constructor() {
    super(...arguments), this._lastDragDetail = null, this._rootListRef = y(), this._layerFlowItemRef = y(), this._panelFlowItemRef = y(), this._selectedDragItemLayerUid = null, this._rootGroupUid = `operational-${B()}`, this._openedLayersController = null, this.messages = U(), this._canMove = ({ dragEl: e, fromEl: t, toEl: i }, o) => {
      const r = o === "pull" ? this.listItemCanGiveFunction : this.listItemCanReceiveFunction, a = p(e, this.operationalItems);
      if (!a?.sortable)
        return !1;
      const s = this._resolveListContainer(t), n = this._resolveListContainer(i), l = this._getContainerItem(s), h = C(s), m = this._getContainerItem(n), f = C(n), v = !!h && !!f && h === f, _ = {
        selected: a,
        from: l,
        to: m
      }, b = s?.group, c = n?.group, z = l?.layer?.type ?? "", A = m?.layer?.type ?? "", k = /* @__PURE__ */ new Set(["map-image", "catalog", "knowledge-graph"]);
      return b && c && typeof r == "function" ? r(_) : v && !k.has(z) && !k.has(A) && a?.layer?.type !== "sublayer";
    }, this._onCatalogOpen = (e) => {
      this.openedLayers.push(e.layer?.parent);
    }, this._onTablesOpen = (e) => {
      this.openedLayers.push(e.layer);
    }, this._clearActiveItem = () => {
      this._activeItem = null;
    }, this._setCurrentActiveItem = (e) => {
      this._activeItem = e;
    }, this._setActiveItem = (e) => {
      if (this.visibilityAppearance !== "default")
        return;
      const t = Array.from(e.composedPath()).find((o) => o.classList?.contains(u.item)), i = p(t, this.operationalItems);
      this._activeItem = i;
    }, this.viewModel = re(this), this.arcgisClose = X(this), this._activeItem = null, this._onTooltipReferenceChange = (e, t) => {
      t ? this._tooltipReferenceMap.set(e, t) : this._tooltipReferenceMap.delete(e);
    }, this._onSelectedDragItemLayerUidChange = (e) => {
      this._selectedDragItemLayerUid = e;
    }, this._onTriggerAction = (e, t) => {
      this.triggerAction(e, t);
    }, this._tooltipReferenceMap = /* @__PURE__ */ new Map(), this._layerListMap = /* @__PURE__ */ new Map(), this.layerTablesEnabled = new g(["knowledge-graph"]), this.mapImageOptions = null, this.openedLayerLists = new g(), this.tileOptions = null, this.view = this.viewModel.view, this.autoDestroyDisabled = !1, this.closed = !1, this.icon = "layers", this.collapsed = !1, this.dragEnabled = !1, this.filterPlaceholder = "", this.filterText = "", this.headingLevel = 2, this.layerTablesAvailable = new g(["knowledge-graph"]), this.listItemCreatedFunction = this.viewModel.listItemCreatedFunction, this.minDragEnabledItems = N, this.minFilterItems = G, this.openedLayers = new g(), this.operationalItems = this.viewModel.operationalItems, this.selectedItems = new g(), this.selectionMode = "none", this.visibilityAppearance = "default", this.hideCatalogLayerList = !1, this.showCloseButton = !1, this.showCollapseButton = !1, this.showErrors = !1, this.showFilter = !1, this.showHeading = !1, this.hideStatusIndicators = !1, this.showTemporaryLayerIndicators = !1, this.state = this.viewModel.state, this.arcgisPropertyChange = Q()("state"), this.arcgisReady = K(), this.arcgisTriggerAction = W(() => this.viewModel, "trigger-action");
  }
  static {
    this.properties = { _catalogLayerList: 16, _tableList: 16, _tooltipReferenceMap: 16, _layerListMap: 16, _totalItems: 16, _visibleItems: 16, _openedPanelItems: 16, _dragEnabled: 16, _filterEnabled: 16, layerTablesEnabled: 16, mapImageOptions: 16, openedLayerLists: 16, tileOptions: 16, _renderedOpenLayerFlowItems: 16, view: 0, autoDestroyDisabled: 5, closed: 5, referenceElement: 1, icon: 1, catalogLayerList: 32, catalogOptions: 0, collapsed: 5, dragEnabled: 5, filterPlaceholder: 1, filterPredicate: 0, filterText: 1, headingLevel: 9, knowledgeGraphOptions: 0, layerTablesAvailable: 0, listItemCanGiveFunction: 0, listItemCanReceiveFunction: 0, listItemCreatedFunction: 0, minDragEnabledItems: 9, minFilterItems: 9, openedLayers: 32, operationalItems: 0, selectedItems: 0, selectionMode: 1, tableList: 32, visibilityAppearance: 1, hideCatalogLayerList: 5, showCloseButton: 5, showCollapseButton: 5, showErrors: 5, showFilter: 5, showHeading: 5, hideStatusIndicators: 5, showTemporaryLayerIndicators: 5, messageOverrides: 0, label: 1, state: 32 };
  }
  static {
    this.styles = [ie, te];
  }
  get _totalItems() {
    return this.viewModel.operationalItems.flatten((e) => e.children.filter((t) => t.layer?.type !== "catalog-dynamic-group")).length;
  }
  get _visibleItems() {
    return this.operationalItems?.filter((e) => !e.hidden && (this.showErrors || !e.error));
  }
  get _openedPanelItems() {
    return this._visibleItems.flatten((e) => e.children).filter(({ hidden: e, panel: t }) => !e && t?.open && !t.disabled && t.flowEnabled);
  }
  get _dragEnabled() {
    return this._totalItems >= this.minDragEnabledItems && this.dragEnabled;
  }
  get _filterEnabled() {
    return this._totalItems >= this.minFilterItems && this.showFilter;
  }
  get _renderedOpenLayerFlowItems() {
    const { openedLayers: e } = this;
    return e.toArray().map((t, i) => this._renderLayerFlowItem(t, i === e.length - 1));
  }
  get catalogLayerList() {
    return this._catalogLayerList;
  }
  get tableList() {
    return this._tableList;
  }
  async destroy() {
    await this.manager.destroy(), this._destroyOpenedLayerLists(), this._tooltipReferenceMap.clear();
  }
  loaded() {
    this.manager.onLifecycle(() => [
      $(() => this.openedLayers, "change", () => {
        this._handleOpenedLayersChange();
      }, { initial: !0 }),
      $(() => this.viewModel.operationalItems, "change", () => j(this.selectedItems), { initial: !0 }),
      q(() => [this.filterPredicate, this._rootListRef.value], () => Y(this._rootListRef.value, this.filterPredicate, this.operationalItems))
    ]);
  }
  triggerAction(e, t) {
    return this.viewModel.triggerAction(e, t);
  }
  _resolveListContainer(e) {
    if (!e)
      return null;
    if (e.matches("calcite-list"))
      return e;
    const t = e.closest("calcite-list[data-item]");
    return t || (this._rootListRef.value?.contains(e) ? this._rootListRef.value : null);
  }
  _getContainerItem(e) {
    const t = e?.getAttribute("data-item");
    return t ? this._findItemByUid(t) : null;
  }
  _findItemByUid(e) {
    const t = this.operationalItems?.toArray() ?? [];
    for (; t.length; ) {
      const i = t.shift();
      if (!i)
        continue;
      if (i.uid === e)
        return i;
      const o = i.children?.toArray() ?? [];
      t.push(...o);
    }
    return null;
  }
  async _createFlowList(e, t) {
    const { _layerListMap: i } = this, o = i.get(e);
    if (o)
      return o;
    const r = e.type === "catalog" ? await this._createCatalogLayerList(e) : await this._createTableList(e);
    return t.aborted || i.set(e, r), r;
  }
  async _handleOpenedLayersChange() {
    const { _layerListMap: e, openedLayers: t, openedLayerLists: i } = this;
    this._openedLayersController?.abort();
    const o = new AbortController(), { signal: r } = o;
    this._openedLayersController = o, e.forEach((n, l) => {
      t.includes(l) || (n?.destroy?.(), e.delete(l));
    });
    const a = await Promise.all(t.map((n) => this._createFlowList(n, r)));
    if (r.aborted)
      return;
    i.removeAll(), i.addMany(a);
    const s = i.at(-1);
    s ? "catalogLayer" in s ? (this._catalogLayerList = s, this._tableList = void 0) : (this._catalogLayerList = void 0, this._tableList = s) : (this._catalogLayerList = void 0, this._tableList = void 0);
  }
  _destroyOpenedLayerLists() {
    this.openedLayerLists.destroyAll(), this.openedLayers.removeAll(), this._layerListMap.clear();
  }
  async _createCatalogLayerList(e) {
    const { headingLevel: t, catalogOptions: i, filterPlaceholder: o, listItemCreatedFunction: r, minFilterItems: a, selectionMode: s, visibilityAppearance: n } = this;
    return E(d`<arcgis-catalog-layer-list .headingLevel=${t} .filterPlaceholder=${i?.filterPlaceholder ?? o} .listItemCreatedFunction=${i?.listItemCreatedFunction ?? r} .minFilterItems=${i?.minFilterItems ?? a} .selectionMode=${i?.selectionMode ?? s} .visibilityAppearance=${i?.visibilityAppearance ?? n} .showErrors=${i?.visibleElements?.errors ?? this.showErrors} .showFilter=${i?.visibleElements?.filter ?? this.showFilter} .hideStatusIndicators=${i?.visibleElements?.statusIndicators ?? this.hideStatusIndicators} .showTemporaryLayerIndicators=${i?.visibleElements?.temporaryLayerIndicators ?? this.showTemporaryLayerIndicators} @arcgisReady=${(l) => l.stopPropagation()} .catalogLayer=${e} .view=${this.view} .referenceElement=${this.referenceElement} @catalogOpen=${this._onCatalogOpen} @tablesOpen=${this._onTablesOpen}></arcgis-catalog-layer-list>`);
  }
  _getTableListParams(e) {
    switch (e.type) {
      case "knowledge-graph":
        return { ...this.knowledgeGraphOptions, tables: e.tables };
      case "map-image":
        return {
          ...this.mapImageOptions,
          tables: e.subtables
        };
      case "tile":
        return {
          ...this.tileOptions,
          tables: e.subtables
        };
      default:
        return null;
    }
  }
  async _createTableList(e) {
    const { headingLevel: t, selectionMode: i, dragEnabled: o } = this, r = this._getTableListParams(e);
    return E(d`<arcgis-table-list .headingLevel=${r?.headingLevel ?? t} .selectionMode=${r?.selectionMode ?? i} .dragEnabled=${r?.dragEnabled ?? o} .collapsed=${r?.collapsed} .filterPlaceholder=${r?.filterPlaceholder} .filterText=${r?.filterText} .icon=${r?.icon ?? void 0} .label=${r?.label ?? void 0} .listItemCreatedFunction=${r?.listItemCreatedFunction} .tables=${r?.tables} .referenceElement=${this.referenceElement} @arcgisReady=${(a) => a.stopPropagation()}></arcgis-table-list>`);
  }
  _handlePanelFlowItemBack(e) {
    e.open = !1;
  }
  _moveLayerFromChildList({ toEl: e, fromEl: t, dragEl: i, newIndex: o }) {
    const r = this._resolveListContainer(e), a = this._resolveListContainer(t), s = p(i, this.operationalItems), n = this._getContainerItem(r), l = this._getContainerItem(a);
    o == null || !s || this.viewModel.moveListItem(s, l, n, o);
  }
  _onCalciteListDragEnd(e) {
    const { fromEl: t, toEl: i, dragEl: o, oldIndex: r } = e;
    if (t !== i) {
      o.remove();
      return;
    }
    r == null || !t || !o || t.insertBefore(o, t.children[r]);
  }
  _onCalciteListOrderChange(e) {
    const { _lastDragDetail: t } = this, { dragEl: i, newIndex: o } = e, r = this._resolveListContainer(e.fromEl), a = this._resolveListContainer(e.toEl), s = t?.newIndex === o && t?.dragEl === i && t?.toEl === a && t?.fromEl === r;
    if (!(!r || !a || s)) {
      if (this._lastDragDetail = {
        ...e,
        fromEl: r,
        toEl: a
      }, this._selectedDragItemLayerUid = i.value, r === a) {
        const n = Array.from(r.children).filter((l) => l?.matches("calcite-list-item")).map((l) => l.value.layer?.uid ?? "");
        this._sortLayers(r, n);
        return;
      }
      this._moveLayerFromChildList({
        toEl: a,
        fromEl: r,
        dragEl: i,
        newIndex: o
      });
    }
  }
  _sortLayers(e, t) {
    if (e)
      if (e === this._rootListRef.value)
        H(this.el.view?.map?.layers, t);
      else {
        const i = p(e, this.operationalItems);
        if (!i)
          return;
        V(i, t);
      }
  }
  _handleCalciteListChange(e) {
    const { selectionMode: t, selectedItems: i } = this;
    if (t === "none")
      return;
    const r = e.target.selectedItems.map((a) => p(a, this.operationalItems)).filter(Boolean);
    i.removeAll(), i.addMany(r);
  }
  render() {
    const { _visibleItems: e, state: t } = this, i = {
      [L.hidden]: t === "loading",
      [L.disabled]: t === "disabled"
    };
    return d`<div class=${I(R(L.widget, i))}>${e?.length ? [this._renderItemTooltips(), this._renderItems()] : this._renderNoItems()}</div>`;
  }
  _renderItemTooltip(e) {
    const { _tooltipReferenceMap: t, messages: i } = this;
    return e ? d`<calcite-tooltip overlay-positioning=fixed .referenceElement=${t.get(e.layer?.uid ?? "")}>${i.layerIncompatibleTooltip}</calcite-tooltip>` : null;
  }
  _renderItemTooltipNodes(e) {
    if (e.incompatible)
      return this._renderItemTooltip(e);
    const t = e.children?.filter((i) => !i.hidden).toArray().map((i) => this._renderItemTooltipNodes(i)) ?? [];
    return t.length ? t : null;
  }
  _renderItemTooltips() {
    return this._visibleItems?.toArray().map((t) => this._renderItemTooltipNodes(t));
  }
  _renderNoItemsMessage() {
    return d`<div slot=message>${this.messages.noItemsToDisplay}</div>`;
  }
  _renderNoItems() {
    return d`<div class=${I(u.itemMessage)}><calcite-notice icon=information kind=info open width=full>${this._renderNoItemsMessage()}</calcite-notice></div>`;
  }
  _renderLayerFlowItem(e, t) {
    const { messages: i, openedLayers: o } = this, r = e.title || this.messages.untitledLayer;
    return w(e?.uid ?? r, d`<calcite-flow-item data-layer-uid=${e?.uid ?? "" ?? T} .description=${r} .heading=${i[e.type === "catalog" ? "catalogLayers" : "tables"]} .headingLevel=${this.headingLevel} .selected=${t} @calciteFlowItemBack=${(a) => {
      a.preventDefault(), o.pop(), o.at(-1) && this._layerFlowItemRef.value?.setFocus();
    }} ${x(this._layerFlowItemRef)}>${this._layerListMap.get(e)}</calcite-flow-item>`);
  }
  _renderPanelFlowItems() {
    const { _openedPanelItems: e, openedLayers: t } = this;
    return D(e.toArray(), (o) => o.uid, (o, r) => {
      const { panel: a, title: s } = o, n = () => this._handlePanelFlowItemBack(a);
      return d`<calcite-flow-item .description=${s} .heading=${a.title} .headingLevel=${this.headingLevel} .selected=${!t.length && r === e.length - 1} @calciteFlowItemBack=${(l) => {
        l.preventDefault(), n();
      }} ${x(this._panelFlowItemRef)}><arcgis-layer-list-item-panel .item=${o} .view=${this.view}></arcgis-layer-list-item-panel><calcite-button appearance=transparent @click=${n} slot=footer-actions width=full>${this.messages.back}</calcite-button></calcite-flow-item>`;
    });
  }
  _renderItems() {
    const { collapsed: e, _visibleItems: t, _openedPanelItems: i, _filterEnabled: o, _rootGroupUid: r, showCloseButton: a, showCollapseButton: s, showHeading: n, _dragEnabled: l, selectionMode: h, filterText: m, openedLayers: f, filterPlaceholder: v, messages: _ } = this, b = [
      d`<calcite-flow-item .closable=${a} .closed=${this.closed} .collapsed=${e} .collapsible=${s} .heading=${n ? _.componentLabel : void 0} .headingLevel=${this.headingLevel} .selected=${!f.length && !i.length} @calciteFlowItemClose=${() => this.closed = !1}><calcite-list @focusin=${this._setActiveItem} @focusout=${this._clearActiveItem} .canPull=${(c) => this._canMove(c, "pull")} .canPut=${(c) => this._canMove(c, "put")} data-layer-type=${r ?? T} .displayMode=${M} .dragEnabled=${l} .filterEnabled=${o} .filterPlaceholder=${v} .filterProps=${Z} .filterText=${o ? m : ""} .group=${r} .label=${_.componentLabel} @mouseleave=${this._clearActiveItem} @mouseover=${this._setActiveItem} selection-appearance=highlight .selectionMode=${h} @calciteListChange=${this._handleCalciteListChange} @calciteListFilter=${(c) => this.filterText = c.currentTarget?.filterText ?? ""} @calciteListOrderChange=${(c) => this._onCalciteListOrderChange(c.detail)} @calciteListDragEnd=${(c) => this._onCalciteListDragEnd(c.detail)} ${x(this._rootListRef)}>${t?.toArray().map((c) => this._renderItem(c)) ?? []}${t?.length && o ? d`<div class=${I(u.filterNoResults)} slot=filter-no-results><calcite-notice kind=info open width=full>${this._renderNoItemsMessage()}</calcite-notice></div>` : null}</calcite-list></calcite-flow-item>`,
      this._renderPanelFlowItems(),
      this._renderedOpenLayerFlowItems
    ];
    return this.closed ? null : w("root-flow", d`<calcite-flow>${b}</calcite-flow>`);
  }
  _renderItem(e, t, i) {
    return w(e.uid, ee({ activeItem: this._activeItem, canMove: this._canMove, css: u, displayMode: M, dragEnabled: this.dragEnabled, hideStatusIndicators: this.hideStatusIndicators, hideCatalogLayerList: this.hideCatalogLayerList, item: e, messages: this.messages, layerTablesEnabled: this.layerTablesEnabled, listModeDisabled: this.viewModel.listModeDisabled, operationalItems: this.operationalItems, parent: t, parentTitles: i, rootGroupUid: this._rootGroupUid, selectedDragItemLayerUid: this._selectedDragItemLayerUid, selectedItems: this.selectedItems, selectionMode: this.selectionMode, setCurrentActiveItem: this._setCurrentActiveItem, showTemporaryLayerIndicators: this.showTemporaryLayerIndicators, showCloseButton: this.showCloseButton, showCollapseButton: this.showCollapseButton, showErrors: this.showErrors, showHeading: this.showHeading, showFilter: this.showFilter, clearActiveItem: this._clearActiveItem, visibilityAppearance: this.visibilityAppearance, handleAction: this._onTriggerAction, handleCatalogOpen: this._onCatalogOpen, handleSelectedDragItemLayerUidChange: this._onSelectedDragItemLayerUidChange, handleTablesOpen: this._onTablesOpen, handleTooltipReferenceChange: this._onTooltipReferenceChange, view: this.view }));
  }
}
P("arcgis-layer-list-next", oe);
export {
  oe as ArcgisLayerListNext
};
