// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("exports ./componentsUtils ./core ./filter ./dom ./floating-ui ./form ./guid ./interactive ./label2 ./loadable ./locale ./observers ./openCloseComponent ./t9n ./component ./Validation ./utils2 ./chip ./combobox-item ./icon ./input-message ./debounce".split(" "),function(z,f,J,K,p,n,q,L,t,y,u,A,B,C,v,w,M,h,N,O,P,Q,D){function R({disabled:a,key:b,label:c,onClick:d,ref:e,scale:g}){return f.h("button",{"aria-label":c,class:E.button,disabled:a,key:b,onClick:d,tabIndex:-1,type:"button",ref:e},f.h("calcite-icon", {icon:"x",scale:w.getIconScale(g)}))}function F(){"undefined"!==typeof customElements&&["calcite-combobox","calcite-chip","calcite-combobox-item","calcite-icon","calcite-input-message"].forEach(a=>{switch(a){case "calcite-combobox":customElements.get(a)||customElements.define(a,G);break;case "calcite-chip":customElements.get(a)||N.defineCustomElement();break;case "calcite-combobox-item":customElements.get(a)||O.defineCustomElement();break;case "calcite-icon":customElements.get(a)||P.defineCustomElement(); break;case "calcite-input-message":customElements.get(a)||Q.defineCustomElement()}})}const E={button:"x-button"},G=f.proxyCustomElement(class extends f.H{constructor(){super();this.__registerHost();this.__attachShadow();this.calciteComboboxChange=f.createEvent(this,"calciteComboboxChange",6);this.calciteComboboxFilterChange=f.createEvent(this,"calciteComboboxFilterChange",6);this.calciteComboboxChipClose=f.createEvent(this,"calciteComboboxChipClose",6);this.calciteComboboxBeforeClose=f.createEvent(this, "calciteComboboxBeforeClose",6);this.calciteComboboxClose=f.createEvent(this,"calciteComboboxClose",6);this.calciteComboboxBeforeOpen=f.createEvent(this,"calciteComboboxBeforeOpen",6);this.calciteComboboxOpen=f.createEvent(this,"calciteComboboxOpen",6);this.placement=n.defaultMenuPlacement;this.internalValueChangeFlag=!1;this.textInput=null;this.mutationObserver=B.createObserver("mutation",()=>this.updateItems());this.resizeObserver=B.createObserver("resize",()=>{this.setMaxScrollerHeight();this.refreshSelectionDisplay()}); this.guid=L.guid();this.inputHeight=0;this.ignoreSelectedEventsFlag=!1;this.openTransitionProp="opacity";this.setFilteredPlacements=()=>{const {el:a,flipPlacements:b}=this;this.filteredFlipPlacements=b?n.filterComputedPlacements(b,a):null};this.getValue=()=>{const a=this.selectedItems.map(b=>b?.value?.toString());return a?.length?1{this.setFocus()};this.keyDownHandler=a=>{if(!this.readOnly){var {key:b}=a;switch(b){case "Tab":this.activeItemIndex=this.activeChipIndex= -1;this.allowCustomValues&&this.text?(this.addCustomChip(this.text,!0),a.preventDefault()):this.open?(this.open=!1,a.preventDefault()):!this.allowCustomValues&&this.text&&(this.clearInputValue(),this.filterItems(""),this.updateActiveItemIndex(-1));break;case "ArrowLeft":this.previousChip();a.preventDefault();break;case "ArrowRight":this.nextChip();a.preventDefault();break;case "ArrowUp":a.preventDefault();this.open&&this.shiftActiveItemIndex(-1);this.comboboxInViewport()||this.el.scrollIntoView(); break;case "ArrowDown":a.preventDefault();this.open?this.shiftActiveItemIndex(1):(this.open=!0,this.ensureRecentSelectedItemIsActive());this.comboboxInViewport()||this.el.scrollIntoView();break;case " ":this.textInput.value||a.defaultPrevented||(this.open||(this.open=!0,this.shiftActiveItemIndex(1)),a.preventDefault());break;case "Home":if(!this.open)break;a.preventDefault();this.updateActiveItemIndex(0);this.scrollToActiveItem();this.comboboxInViewport()||this.el.scrollIntoView();break;case "End":if(!this.open)break; a.preventDefault();this.updateActiveItemIndex(this.filteredItems.length-1);this.scrollToActiveItem();this.comboboxInViewport()||this.el.scrollIntoView();break;case "Escape":this.clearDisabled||this.open||this.clearValue();this.open=!1;a.preventDefault();break;case "Enter":this.open&&-1{this.open=!1;this.el.removeEventListener("calciteComboboxClose",this.toggleCloseEnd)};this.toggleOpenEnd=()=>{this.open= !1;this.el.removeEventListener("calciteComboboxOpen",this.toggleOpenEnd)};this.setMaxScrollerHeight=async()=>{const {listContainerEl:a,open:b,referenceEl:c}=this;if(a&&b){await this.reposition(!0);var d=this.getMaxScrollerHeight();a.style.maxHeight=0{this.open=!1;const b=this.items.find(c=>c===a);b&&this.toggleSelection(b,!1);this.calciteComboboxChipClose.emit()};this.clickHandler=a=>{if(!this.readOnly){var b= a.composedPath();b.some(c=>"CALCITE-CHIP"===c.tagName)?(this.open=!1,a.preventDefault()):b.some(c=>c.classList?.contains(E.button))?(this.clearValue(),a.preventDefault()):(this.open=!this.open,this.ensureRecentSelectedItemIsActive())}};this.refreshSelectionDisplay=async()=>{await u.componentLoaded(this);if(!h.isSingleLike(this.selectionMode)&&this.textInput){var {allSelectedIndicatorChipEl:a,chipContainerEl:b,selectionDisplay:c,placeholder:d,selectedIndicatorChipEl:e,textInput:g}=this,k=parseInt(getComputedStyle(b).gap.replace("px", "")),l=p.getElementWidth(b),{fontSize:m,fontFamily:r}=getComputedStyle(g),H=(p.getTextWidth(d,`${m} ${r}`)||parseInt(J.calciteSize48))+k,x=p.getElementWidth(a),I=p.getElementWidth(e);this.setCompactSelectionDisplay({chipContainerElGap:k,chipContainerElWidth:l,inputWidth:H,largestSelectedIndicatorChipWidth:Math.max(x,I)});"fit"===c&&(x=Array.from(this.el.shadowRoot.querySelectorAll("calcite-chip")).filter(S=>S.closable),this.refreshChipDisplay({availableHorizontalChipElSpace:Math.round(l-((0{this.floatingEl=a;n.connectFloatingUI(this,this.referenceEl,this.floatingEl)};this.setContainerEl=a=>{this.resizeObserver.observe(a);this.transitionEl=this.listContainerEl=a};this.setChipContainerEl=a=>{this.resizeObserver.observe(a);this.chipContainerEl=a};this.setReferenceEl=a=>{this.referenceEl=a;n.connectFloatingUI(this,this.referenceEl,this.floatingEl)};this.setAllSelectedIndicatorChipEl= a=>{this.allSelectedIndicatorChipEl=a};this.setSelectedIndicatorChipEl=a=>{this.selectedIndicatorChipEl=a};this.inputHandler=a=>{this.text=a=a.target.value;this.filterItems(a);a&&(this.activeChipIndex=-1)};this.filterItems=(()=>{const a=(b,c)=>b&&c.some(({label:d,value:e})=>b.tagName===h.ComboboxItemGroup?d===b.label:e===b.value&&d===b.textLabel);return D.debounce(b=>{const c=K.filter(this.data,b);this.getItemsAndGroups().forEach(d=>{const e=!a(d,c);d.hidden=e;const [g,k]=d.ancestors;if(a(g,c)||a(k, c))d.hidden=!1;e||d.ancestors.forEach(l=>l.hidden=!1)});this.filteredItems=this.getFilteredItems();this.calciteComboboxFilterChange.emit()},100)})();this.internalComboboxChangeEvent=()=>{this.calciteComboboxChange.emit()};this.emitComboboxChange=D.debounce(this.internalComboboxChangeEvent,0);this.getSelectedItems=()=>{if(!this.isMulti()){const a=this.items.find(({selected:b})=>b);return a?[a]:[]}return this.items.filter(a=>a.selected&&("ancestors"!==this.selectionMode||!h.hasActiveChildren(a))).sort((a, b)=>{a=this.selectedItems.indexOf(a);b=this.selectedItems.indexOf(b);return-1{this.items=this.getItems();this.groupItems=this.getGroupItems();this.data=this.getData();this.selectedItems=this.getSelectedItems();this.filteredItems=this.getFilteredItems();this.needsIcon=this.getNeedsIcon();this.items.forEach(a=>{a.selectionMode=this.selectionMode;a.scale=this.scale});this.allowCustomValues||this.setMaxScrollerHeight();this.groupItems.forEach((a,b,c)=>{0===b&& (a.afterEmptyGroup=!1);if(b=c[b+1])b.afterEmptyGroup=0===a.children.length})};this.scrollToActiveItem=()=>{const a=this.filteredItems[this.activeItemIndex];if(a){var b=this.calculateSingleItemHeight(a),{offsetHeight:c,scrollTop:d}=this.listContainerEl;c+d{this.disabled||this.textInput?.focus()};this.clearDisabled=!1;this.selectionDisplay="all";this.disabled= this.open=!1;this.placeholderIcon=this.placeholder=this.label=this.form=void 0;this.placeholderIconFlipRtl=!1;this.maxItems=0;this.validationIcon=this.validationMessage=void 0;this.validity={valid:!1,badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valueMissing:!1};this.allowCustomValues=this.name=void 0;this.overlayPositioning="absolute";this.required=!1;this.selectionMode="multiple";this.scale="m";this.status= "idle";this.value=null;this.messageOverrides=this.messages=this.flipPlacements=void 0;this.selectedItems=[];this.filteredItems=[];this.readOnly=!1;this.items=[];this.groupItems=[];this.needsIcon=void 0;this.activeChipIndex=this.activeItemIndex=-1;this.activeDescendant="";this.compactSelectionDisplay=!1;this.selectedVisibleChipsCount=this.selectedHiddenChipsCount=0;this.text="";this.defaultMessages=this.effectiveLocale=void 0}openHandler(){C.onToggleOpenCloseComponent(this);this.disabled?this.open= !1:this.setMaxScrollerHeight()}handleDisabledChange(a){a||(this.open=!1)}maxItemsHandler(){this.setMaxScrollerHeight()}overlayPositioningHandler(){this.reposition(!0)}handlePropsChange(){this.updateItems()}valueHandler(a){if(!this.internalValueChangeFlag){const b=this.getItems();Array.isArray(a)?b.forEach(c=>c.selected=a.includes(c.value)):a?b.forEach(c=>c.selected=a===c.value):b.forEach(c=>c.selected=!1);this.updateItems()}}onMessagesChange(){}flipPlacementsHandler(){this.setFilteredPlacements(); this.reposition(!0)}selectedItemsHandler(){this.internalValueChangeFlag=!0;this.value=this.getValue();this.internalValueChangeFlag=!1}async documentClickHandler(a){this.disabled||a.composedPath().includes(this.el)||(await w.componentOnReady(this.el),!this.allowCustomValues&&this.text&&(this.clearInputValue(),this.filterItems(""),this.updateActiveItemIndex(-1)),this.allowCustomValues&&this.text.trim().length&&this.addCustomChip(this.text),this.open=!1)}calciteComboboxItemChangeHandler(a){if(!this.ignoreSelectedEventsFlag){a= a.target;var b=this.filteredItems.indexOf(a);this.updateActiveItemIndex(b);this.toggleSelection(a,a.selected)}}async reposition(a=!1){const {floatingEl:b,referenceEl:c,placement:d,overlayPositioning:e,filteredFlipPlacements:g}=this;return n.reposition(this,{floatingEl:b,referenceEl:c,overlayPositioning:e,placement:d,flipPlacements:g,type:"menu"},a)}async setFocus(){await u.componentFocusable(this);this.textInput?.focus();this.activeItemIndex=this.activeChipIndex=-1}connectedCallback(){t.connectInteractive(this); A.connectLocalized(this);v.connectMessages(this);y.connectLabel(this);q.connectForm(this);this.internalValueChangeFlag=!0;this.value=this.getValue();this.internalValueChangeFlag=!1;this.mutationObserver?.observe(this.el,{childList:!0,subtree:!0});this.updateItems();this.setFilteredPlacements();this.open&&(this.openHandler(),C.onToggleOpenCloseComponent(this));n.connectFloatingUI(this,this.referenceEl,this.floatingEl)}async componentWillLoad(){u.setUpLoadableComponent(this);this.updateItems();await v.setUpMessages(this)}componentDidLoad(){q.afterConnectDefaultValueSet(this, this.getValue());n.connectFloatingUI(this,this.referenceEl,this.floatingEl);u.setComponentLoaded(this)}componentDidRender(){this.el.offsetHeight!==this.inputHeight&&(this.reposition(!0),this.inputHeight=this.el.offsetHeight);t.updateHostInteraction(this)}componentDidUpdate(){this.refreshSelectionDisplay()}disconnectedCallback(){this.mutationObserver?.disconnect();this.resizeObserver?.disconnect();t.disconnectInteractive(this);y.disconnectLabel(this);q.disconnectForm(this);n.disconnectFloatingUI(this, this.referenceEl,this.floatingEl);A.disconnectLocalized(this);v.disconnectMessages(this)}textHandler(){this.updateActiveItemIndex(-1)}effectiveLocaleChange(){v.updateMessages(this,this.effectiveLocale)}clearValue(){this.ignoreSelectedEventsFlag=!0;this.items.forEach(a=>a.selected=!1);this.ignoreSelectedEventsFlag=!1;this.selectedItems=[];this.emitComboboxChange();this.open=!1;this.updateActiveItemIndex(-1);this.resetText();this.filterItems("");this.setFocus()}clearInputValue(){this.text=this.textInput.value= ""}comboboxInViewport(){const a=this.el.getBoundingClientRect();return 0<=a.top&&0<=a.left&&a.right<=(window.innerWidth||document.documentElement.clientWidth)&&a.bottom<=(window.innerHeight||document.documentElement.clientHeight)}onBeforeOpen(){this.scrollToActiveItem();this.calciteComboboxBeforeOpen.emit()}onOpen(){this.calciteComboboxOpen.emit()}onBeforeClose(){this.calciteComboboxBeforeClose.emit()}onClose(){this.calciteComboboxClose.emit()}ensureRecentSelectedItemIsActive(){var {selectedItems:a}= this;a=0===a.length?0:this.items.indexOf(a[a.length-1]);this.updateActiveItemIndex(a)}hideChip(a){a.classList.add(h.CSS.chipInvisible)}showChip(a){a.classList.remove(h.CSS.chipInvisible)}refreshChipDisplay({chipEls:a,availableHorizontalChipElSpace:b,chipContainerElGap:c}){a.forEach(d=>{if(d.selected){const e=p.getElementWidth(d);if(e&&e{c.selected&&!c.classList.contains(h.CSS.chipInvisible)&&b++});b!==this.selectedVisibleChipsCount&&(this.selectedVisibleChipsCount=b);a=this.getSelectedItems().length-b;a!==this.selectedHiddenChipsCount&&(this.selectedHiddenChipsCount=a)}getMaxScrollerHeight(){const a=this.getItemsAndGroups().filter(e=> !e.hidden),{maxItems:b}=this;let c=0,d=0;a.length>b&&a.forEach(e=>{cc?.offsetHeight).forEach(c=>{b-=c});return b}}getItemsAndGroups(){return[...this.groupItems,...this.items]}toggleSelection(a,b=!a.selected){!a||"single-persist"===this.selectionMode&&a.selected&&a.value===this.value||(this.isMulti()?(a.selected= b,this.updateAncestors(a),this.selectedItems=this.getSelectedItems(),this.emitComboboxChange()):(this.ignoreSelectedEventsFlag=!0,this.items.forEach(c=>c.selected=c===a?b:!1),this.ignoreSelectedEventsFlag=!1,this.selectedItems=this.getSelectedItems(),this.emitComboboxChange(),this.textInput&&(this.textInput.value=a.textLabel),this.open=!1,this.updateActiveItemIndex(-1)),this.resetText(),this.filterItems(""))}updateAncestors(a){if("ancestors"===this.selectionMode){var b=h.getItemAncestors(a),c=h.getItemChildren(a); a.selected?b.forEach(d=>{d.selected=!0}):(c.forEach(d=>d.selected=!1),[...b].forEach(d=>{h.hasActiveChildren(d)||(d.selected=!1)}))}}getFilteredItems(){return this.items.filter(a=>!a.hidden)}getData(){return this.items.map(a=>({filterDisabled:a.filterDisabled,value:a.value,label:a.textLabel}))}getNeedsIcon(){return h.isSingleLike(this.selectionMode)&&this.items.some(a=>a.icon)}resetText(){this.textInput&&(this.textInput.value="");this.text=""}getItems(){return Array.from(this.el.querySelectorAll(h.ComboboxItem)).filter(a=> !a.disabled)}getGroupItems(){return Array.from(this.el.querySelectorAll(h.ComboboxItemGroup))}addCustomChip(a,b){var c=this.items.find(d=>d.textLabel===a);c?this.toggleSelection(c,!0):(this.isMulti()||this.toggleSelection(this.selectedItems[this.selectedItems.length-1],!1),c=document.createElement("calcite-combobox-item"),c.value=a,c.textLabel=a,c.selected=!0,this.el.appendChild(c),this.resetText(),b&&this.setFocus(),this.updateItems(),this.filterItems(""),this.emitComboboxChange())}removeActiveChip(){this.toggleSelection(this.selectedItems[this.activeChipIndex], !1);this.setFocus()}removeLastChip(){this.toggleSelection(this.selectedItems[this.selectedItems.length-1],!1);this.setFocus()}previousChip(){if(!this.text){var a=this.selectedItems.length-1,b=this.activeChipIndex;this.activeChipIndex=-1===b?a:Math.max(b-1,0);this.updateActiveItemIndex(-1);this.focusChip()}}nextChip(){if(!this.text&&-1!==this.activeChipIndex){var a=this.activeChipIndex+1;a>this.selectedItems.length-1?(this.activeChipIndex=-1,this.setFocus()):(this.activeChipIndex=a,this.focusChip()); this.updateActiveItemIndex(-1)}}focusChip(){const a=this.selectedItems[this.activeChipIndex]?.guid;(a?this.referenceEl.querySelector(`#${"combobox-chip-"}${a}`):null)?.setFocus()}shiftActiveItemIndex(a){const {length:b}=this.filteredItems;this.updateActiveItemIndex((this.activeItemIndex+b+a)%b);this.scrollToActiveItem()}updateActiveItemIndex(a){this.activeItemIndex=a;let b=null;this.filteredItems.forEach((c,d)=>{d===a?(c.active=!0,b=`${"combobox-item-"}${c.guid}`):c.active=!1});this.activeDescendant= b;-1{k={chip:!0,"chip--active":a===k};var l=[...[...h.getItemAncestors(g)].reverse(),g].map(m=>m.textLabel);l="ancestors"!==d?g.textLabel:l.join(" / ");return f.h("calcite-chip",{appearance:b?"outline": "solid",class:k,closable:!b,icon:g.icon,iconFlipRtl:g.iconFlipRtl,id:g.guid?`${"combobox-chip-"}${g.guid}`:null,key:g.textLabel,messageOverrides:{dismissLabel:e.removeTag},onCalciteChipClose:()=>this.calciteChipCloseHandler(g),scale:c,selected:g.selected,title:l,value:g.value},l)})}renderAllSelectedIndicatorChip(){const {compactSelectionDisplay:a,scale:b,selectedVisibleChipsCount:c,setAllSelectedIndicatorChipEl:d}=this,e=this.messages.allSelected;return f.h("calcite-chip",{class:{chip:!0,[h.CSS.chipInvisible]:!(this.isAllSelected()&& !c&&!a)},scale:b,title:e,value:"",ref:d},e)}renderAllSelectedIndicatorChipCompact(){const {compactSelectionDisplay:a,scale:b,selectedVisibleChipsCount:c}=this,d=this.messages.all||"All";return f.h("calcite-chip",{class:{chip:!0,[h.CSS.chipInvisible]:!(this.isAllSelected()&&!c&&a)},scale:b,title:d,value:""},d)}renderSelectedIndicatorChip(){const {compactSelectionDisplay:a,selectionDisplay:b,getSelectedItems:c,scale:d,selectedHiddenChipsCount:e,selectedVisibleChipsCount:g,setSelectedIndicatorChipEl:k}= this;let l;if(a)l=!0;else if("single"===b){var m=c().length;l=this.isAllSelected()?!0:0this.textInput=r}))}renderListBoxOptions(){return this.filteredItems.map(a=>f.h("li",{"aria-selected":p.toAriaBoolean(a.selected),id:a.guid?`${"combobox-item-"}${a.guid}`:null,role:"option",tabindex:"-1"},a.textLabel))}renderFloatingUIContainer(){const {setFloatingEl:a, setContainerEl:b,open:c}=this;return f.h("div",{"aria-hidden":"true",class:{"floating-ui-container":!0,"floating-ui-container--active":c},ref:a},f.h("div",{class:{[h.CSS.listContainer]:!0,[n.FloatingCSS.animation]:!0,[n.FloatingCSS.animationActive]:c},ref:b},f.h("ul",{class:{list:!0,"list--hide":!c}},f.h("slot",null))))}renderSelectedOrPlaceholderIcon(){const {selectedItems:a,placeholderIcon:b,placeholderIconFlipRtl:c}=this,d=a[0];return this.showingInlineIcon&&f.h("span",{class:"icon-start",key:"selected-placeholder-icon"}, f.h("calcite-icon",{class:"selected-icon",flipRtl:this.open&&d?d.iconFlipRtl:c,icon:!this.open&&d?d?.icon:b,scale:w.getIconScale(this.scale)}))}renderChevronIcon(){const {open:a}=this;return f.h("span",{class:"icon-end",key:"chevron"},f.h("calcite-icon",{class:h.CSS.icon,icon:a?"chevron-up":"chevron-down",scale:w.getIconScale(this.scale)}))}render(){const {selectionDisplay:a,guid:b,label:c,open:d,readOnly:e}=this,g=h.isSingleLike(this.selectionMode),k="all"===a,l="single"===a,m=!g&&"fit"===a,r=!this.clearDisabled&& 0