/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import{a as i}from"./AE6WIDBA.js";import"./XPV23QFC.js";import{a as v}from"./QUFMR3GW.js";import{a as g}from"./OKEUM3YZ.js";import{a as m}from"./CQMH7FNX.js";import{a as b}from"./D7WOEWO3.js";import{a as f}from"./TLYY3J5P.js";import"./WGGFNK4Z.js";import"./EH5Y2TRK.js";import"./UANLRLKZ.js";import"./DVG3NA3H.js";import"./OAOQ5BXS.js";import{E as o,F as n,G as d,H as u,N as h,S as p,g as s,h as c,p as r}from"./PGOMURMZ.js";var y={container:"container"},x={search:"search"},k=s`:host{box-sizing:border-box;background-color:var(--calcite-color-foreground-1);color:var(--calcite-color-text-2);font-size:var(--calcite-font-size--1)}:host *{box-sizing:border-box}:host([disabled]){cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-opacity-disabled)}:host([disabled]) *,:host([disabled]) ::slotted(*){pointer-events:none}:host{display:flex;inline-size:100%}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.interaction-container{display:contents}.container{display:flex;inline-size:100%}:host([scale=s]) .container{padding:var(--calcite-filter-content-space, var(--calcite-spacing-sm))}:host([scale=m]) .container{padding:var(--calcite-filter-content-space, var(--calcite-spacing-md))}:host([scale=l]) .container{padding:var(--calcite-filter-content-space, var(--calcite-spacing-lg))}label{position:relative;margin-block:0px;display:flex;inline-size:100%;align-items:center;overflow:hidden}calcite-input{inline-size:100%;--calcite-input-background-color: var(--calcite-filter-input-background-color);--calcite-input-border-color: var(--calcite-filter-input-border-color);--calcite-input-corner-radius: var(--calcite-filter-input-corner-radius);--calcite-input-shadow: var(--calcite-filter-input-shadow);--calcite-input-icon-color: var(--calcite-filter-input-icon-color);--calcite-input-text-color: var(--calcite-filter-input-text-color);--calcite-input-placeholder-text-color: var(--calcite-filter-input-placeholder-text-color);--calcite-input-actions-background-color: var(--calcite-filter-input-actions-background-color);--calcite-input-actions-background-color-hover: var(--calcite-filter-input-actions-background-color-hover);--calcite-input-actions-background-color-press: var(--calcite-filter-input-actions-background-color-press);--calcite-input-actions-icon-color: var(--calcite-filter-input-actions-icon-color);--calcite-input-actions-icon-color-hover: var(--calcite-filter-input-actions-icon-color-hover);--calcite-input-actions-icon-color-press: var(--calcite-filter-input-actions-icon-color-press)}:host([hidden]){display:none}[hidden]{display:none}`,l=class extends d{constructor(){super(...arguments),this.cancelable=g()(this),this.filterDebounced=m((e,t=!1,a)=>this.updateFiltered(i(this.items??[],e,this.filterProps),t,a),h.filter),this.textInputRef=o(),this._value="",this.messages=b(),this.focusSetter=f()(this),this.interactiveContainer=v(this),this.disabled=!1,this.filteredItems=[],this.items=[],this.scale="m",this.calciteFilterChange=r({cancelable:!1})}static{this.properties={disabled:[7,{},{reflect:!0,type:Boolean}],filterProps:[0,{},{attribute:!1}],filteredItems:[0,{},{attribute:!1}],items:[0,{},{attribute:!1}],label:1,messageOverrides:[0,{},{attribute:!1}],placeholder:1,scale:[3,{},{reflect:!0}],value:1}}static{this.shadowRootOptions={mode:"open",delegatesFocus:!0}}static{this.styles=k}get value(){return this._value}set value(e){let t=this._value;e!==t&&(this._value=e,this.valueHandler(e))}async filter(e=this.value){return new Promise(t=>{this.value=e,this.updateFiltered(i(this.items??[],e,this.filterProps),!1,t)})}async setFocus(e){return this.focusSetter(()=>this.textInputRef.value,e)}connectedCallback(){super.connectedCallback(),this.cancelable.add(this.filterDebounced)}async load(){this.updateFiltered(i(this.items??[],this.value,this.filterProps))}willUpdate(e){(e.has("items")&&(this.hasUpdated||this.items?.length>0)||e.has("filterProps"))&&this.filterDebounced(this.value)}valueHandler(e){this.filterDebounced(e)}inputHandler(e){let t=e.target;this.value=t.value,this.filterDebounced(t.value,!0)}keyDownHandler(e){e.defaultPrevented||(e.key==="Escape"&&this.value.length>0&&(this.clear(),e.preventDefault()),e.key==="Enter"&&e.preventDefault())}clear(){this.value="",this.filterDebounced("",!0),this.setFocus()}updateFiltered(e,t=!1,a){this.filteredItems=e,t&&this.calciteFilterChange.emit(),a?.()}render(){let{disabled:e,scale:t}=this;return this.interactiveContainer({disabled:e,children:c`<div class=${u(y.container)}><label><calcite-input clearable .disabled=${e} .icon=${x.search} .label=${this.label??this.messages.label} .messageOverrides=${{clear:this.messages.clear}} @keydown=${this.keyDownHandler} @calciteInputInput=${this.inputHandler} .placeholder=${this.placeholder} .scale=${t} type=text .value=${this.value} ${n(this.textInputRef)}></calcite-input></label></div>`})}};p("calcite-filter",l);export{l as Filter};
