@keenmate/web-multiselect 2.0.0-rc01 → 2.0.0-rc02

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- (function(O,P){typeof exports=="object"&&typeof module<"u"?P(exports):typeof define=="function"&&define.amd?define(["exports"],P):(O=typeof globalThis<"u"?globalThis:O||self,P(O.MultiSelect={}))})(this,function(O){"use strict";var Wi=Object.defineProperty;var To=O=>{throw TypeError(O)};var ji=(O,P,D)=>P in O?Wi(O,P,{enumerable:!0,configurable:!0,writable:!0,value:D}):O[P]=D;var y=(O,P,D)=>ji(O,typeof P!="symbol"?P+"":P,D),St=(O,P,D)=>P.has(O)||To("Cannot "+D);var f=(O,P,D)=>(St(O,P,"read from private field"),D?D.call(O):P.get(O)),R=(O,P,D)=>P.has(O)?To("Cannot add the same private member more than once"):P instanceof WeakSet?P.add(O):P.set(O,D),B=(O,P,D,$)=>(St(O,P,"write to private field"),$?$.call(O,D):P.set(O,D),D),C=(O,P,D)=>(St(O,P,"access private method"),D);var pe,He,Me,Fe,we,We,at,xe,me,_e,Ae,Le,Ee,lt,ae,$e,A,Io,Oo,Po,Q,Mo,Ao,Tt,It,qe,Ot,Lo,X,K,ue,ct,je,Ge,Ue,Ve,De,ke,M,Pt,Mt,Eo,$o,Vo,dt,At,Do,zo,No,Lt,Ro,Bo,Et,$t;function P(o,e={}){const t=new Set(o),i=e.shouldNullOnInvalid?null:e.default??null;return{values:o,fromAttribute(s){return s===null?e.default??i:t.has(s)?s:i},validate(s){return typeof s=="string"&&t.has(s)},toAttribute(s){return s==null?null:String(s)}}}function D(o={}){const e=i=>(o.min==null||i>=o.min)&&(o.max==null||i<=o.max),t=o.default;return{fromAttribute(i){if(i===null)return t;const s=Number.parseInt(i,10);return Number.isNaN(s)||!e(s)?t:s},validate(i){return typeof i=="number"&&Number.isInteger(i)&&e(i)},toAttribute(i){return i==null?null:String(i)}}}function $(o={}){const e=o.isNullable===!0,t=o.default??(e?null:""),i=s=>o.shouldTrim?s.trim():s;return{fromAttribute(s){if(s===null)return t;const r=i(s);return!o.isEmptyAllowed&&r===""?t:r},validate(s){return s===null?e:typeof s=="string"&&(o.isEmptyAllowed===!0||s!=="")},toAttribute(s){return s==null?null:String(s)}}}const Ko=new Set(["","true","1","yes","on"]),Ho=new Set(["false","0","no","off"]);function W(o="presence"){const e=t=>{const i=t.trim().toLowerCase();return Ko.has(i)?!0:Ho.has(i)?!1:null};return{fromAttribute(t){switch(o){case"presence":return t!==null;case"default-true":return t===null?!0:e(t)??!0;case"default-false":return t===null?!1:e(t)??!1;case"tristate":return t===null?null:e(t)}},validate(t){return o==="tristate"?t===!0||t===!1||t===null:typeof t=="boolean"},toAttribute(t){return o==="presence"?t?"":null:t==null?null:String(t)}}}function Fo(o={}){const e=o.default;return{fromAttribute(t){if(t===null||t.trim()==="")return e;let i;try{i=JSON.parse(t)}catch{return e}return o.validate&&!o.validate(i)?e:i},validate:o.validate,toAttribute(t){return t==null?null:JSON.stringify(t)}}}function Wo(o={}){const e=o.default??[],t=i=>Array.isArray(i)&&(!o.validateItem||i.every(o.validateItem));return{fromAttribute(i){if(i===null||i.trim()==="")return e;let s;try{s=JSON.parse(i)}catch{return e}return t(s)?s:e},validate:t,toAttribute(i){return Array.isArray(i)?JSON.stringify(i):null}}}function jo(){return{validate(o){return o==null||typeof o=="function"}}}function Go(o,e,t){const i=o.converter,s=i!=null&&i.fromAttribute?i.fromAttribute(e,t,o.attribute??o.configKey):e??o.default;return{configKey:o.configKey,field:o.field,value:s,on:o.on??"update"}}function Uo(o,e){const t=o.converter;return t!=null&&t.validate&&!t.validate(e)?null:{configKey:o.configKey,field:o.field,value:e,on:o.on??"update"}}function qo(){const o=new Set;let e=!1;const t=()=>{e=!1;const i=[...o];o.clear();for(const s of i)s()};return{schedule(i){o.add(i),e||(e=!0,queueMicrotask(t))},flush(){if(o.size===0)return;e=!1;const i=[...o];o.clear();for(const s of i)s()},cancel(){o.clear(),e=!1}}}const Je=new Map;function Jo(o,e){let t=Je.get(o);t||Je.set(o,t=new Set),t.add(e)}function Xo(o,e){var t;(t=Je.get(o))==null||t.delete(e)}function Yo(o){return Array.from(Je.get(o)??[])}const Vt=new Map;function Qo(o,e){Vt.set(o.toLowerCase(),e)}function Zo(o){return Vt.get(o.toLowerCase())}function es(o,e,t,i={}){return o.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:i.bubbles??!0,composed:i.composed??!0,cancelable:i.cancelable??!1}))}function ts(o){return o.split(/[-_]/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join("")}function os(o){return`on${ts(o)}`}function ss(o){return o?o.map(e=>{const t=typeof e=="string"?{name:e}:e,i=t.property===!1?null:t.property??os(t.name);return{name:t.name,property:i,bubbles:t.bubbles,composed:t.composed,cancelable:t.cancelable}}):[]}const is=typeof HTMLElement<"u"?HTMLElement:class{},Dt=new WeakSet;let rs=0;const ns={trace(){},debug(){},info(){},warn(){},error(){}},as=new Proxy({},{get:()=>ns});class ht extends is{constructor(){super();R(this,A);R(this,pe,{});R(this,He,new Map);R(this,Me,new Map);R(this,Fe,new Map);R(this,we,new Map);R(this,We,qo());R(this,at,()=>C(this,A,Ot).call(this));R(this,xe,null);R(this,me,!1);R(this,_e,[]);R(this,Ae,!1);R(this,Le,null);R(this,Ee,!1);R(this,lt);R(this,ae);R(this,$e);const t=this.constructor,i=t.inputs??[],s=ss(t.events);C(this,A,Po).call(this,i,s);for(const r of i)f(this,He).set(r.configKey,r),r.attribute&&f(this,Me).set(r.attribute,r);for(const r of s)f(this,Fe).set(r.name,r);C(this,A,Io).call(this,i),C(this,A,Mo).call(this,i),C(this,A,Ao).call(this,s)}static get observedAttributes(){return(this.inputs??[]).filter(t=>t.attribute).map(t=>t.attribute)}attributeChangedCallback(t,i,s){var a;if(f(this,Ee))return;const r=f(this,Me).get(t);if(!r||!f(this,Ae)&&((a=f(this,Le))!=null&&a.has(r.configKey)))return;let n;try{n=Go(r,s,this)}catch(l){C(this,A,Q).call(this,`converter for "${r.configKey}" threw parsing attribute ${t}="${s}"; using default`,l),n=C(this,A,Oo).call(this,r)}C(this,A,It).call(this,n)}connectedCallback(){Jo(this.localName,this),f(this,Ae)||(B(this,Ae,!0),B(this,Le,null),B(this,me,!0)),C(this,A,qe).call(this),this.connect()}disconnectedCallback(){Xo(this.localName,this),this.disconnect()}setAttributes(t){for(const[i,s]of Object.entries(t)){const r=f(this,He).get(i)??f(this,Me).get(i);r&&C(this,A,Tt).call(this,r,s)}C(this,A,qe).call(this)}batch(t){t(),C(this,A,qe).call(this)}flush(){C(this,A,qe).call(this)}whenSettled(){return!f(this,xe)&&!f(this,me)?Promise.resolve():new Promise(t=>f(this,_e).push(t))}get config(){return f(this,pe)}get log(){if(f(this,$e))return f(this,$e);const t=Zo(this.localName);if(!t)return as;const i=f(this,lt)??B(this,lt,`${this.localName}#${this.id||++rs}`);return B(this,$e,t.forInstance(i,()=>f(this,ae)))}enableLogging(t="debug"){B(this,ae,t)}disableLogging(){B(this,ae,void 0)}get isLoggingEnabled(){return f(this,ae)!=null&&f(this,ae)!=="silent"&&f(this,ae)!==5}reinit(){}update(t){}connect(){}disconnect(){}emit(t,i,s){const r=f(this,Fe).get(t);return es(this,t,i,{bubbles:(s==null?void 0:s.bubbles)??(r==null?void 0:r.bubbles),composed:(s==null?void 0:s.composed)??(r==null?void 0:r.composed),cancelable:(s==null?void 0:s.cancelable)??(r==null?void 0:r.cancelable)})}on(t,i,s){const r=i;return this.addEventListener(t,r,s),()=>this.removeEventListener(t,r,s)}async runHook(t,i,s){const r=f(this,pe)[t];if(typeof r!="function")return s.whenUnset;try{return await Promise.resolve(r(i))}catch(n){if(s.onError)return s.onError(n);throw n}}}pe=new WeakMap,He=new WeakMap,Me=new WeakMap,Fe=new WeakMap,we=new WeakMap,We=new WeakMap,at=new WeakMap,xe=new WeakMap,me=new WeakMap,_e=new WeakMap,Ae=new WeakMap,Le=new WeakMap,Ee=new WeakMap,lt=new WeakMap,ae=new WeakMap,$e=new WeakMap,A=new WeakSet,Io=function(t){var i;for(const s of t){let r=s.default;if((i=s.converter)!=null&&i.fromAttribute)try{r=s.converter.fromAttribute(null,this,s.attribute??s.configKey)}catch(n){C(this,A,Q).call(this,`converter for "${s.configKey}" threw computing its default; using \`default\``,n),r=s.default}f(this,pe)[s.configKey]=r,s.field&&(this[s.field]=r)}},Oo=function(t){return{configKey:t.configKey,field:t.field,value:t.default,on:t.on??"update"}},Po=function(t,i){var l;const s=this.constructor;if(Dt.has(s))return;Dt.add(s);const r=new Set,n=new Set;for(const c of t)r.has(c.configKey)&&C(this,A,Q).call(this,`invalid input table: duplicate configKey "${c.configKey}"`),r.add(c.configKey),c.attribute&&(n.has(c.attribute)&&C(this,A,Q).call(this,`invalid input table: duplicate attribute "${c.attribute}"`),n.add(c.attribute)),c.reflect&&!c.attribute&&C(this,A,Q).call(this,`invalid input table: "${c.configKey}" has reflect:true but no attribute to reflect to`),c.reflect&&!((l=c.converter)!=null&&l.toAttribute)&&C(this,A,Q).call(this,`invalid input table: "${c.configKey}" has reflect:true but its converter has no toAttribute`);const a=new Set;for(const c of i)a.has(c.name)&&C(this,A,Q).call(this,`invalid event table: duplicate event "${c.name}"`),a.add(c.name),/^[a-z][a-z0-9-]*$/.test(c.name)||C(this,A,Q).call(this,`invalid event table: event "${c.name}" should be lowercase kebab-case (e.g. "date-select")`),c.property&&r.has(c.property)&&C(this,A,Q).call(this,`invalid event table: event "${c.name}" property "${c.property}" collides with an input configKey`)},Q=function(t,...i){console.warn(`[BlissElement] <${this.localName??"unknown"}> ${t}`,...i)},Mo=function(t){for(const i of t){const s=i.configKey,r=Object.prototype.hasOwnProperty.call(this,s),n=r?this[s]:void 0;r&&delete this[s],Object.defineProperty(this,s,{configurable:!0,enumerable:!0,get:()=>f(this,pe)[s],set:a=>C(this,A,Tt).call(this,i,a)}),r&&((f(this,Le)??B(this,Le,new Set)).add(s),this[s]=n)}},Ao=function(t){for(const i of t){const s=i.property;if(!s)continue;const r=i.name,n=Object.prototype.hasOwnProperty.call(this,s),a=n?this[s]:void 0;n&&delete this[s],Object.defineProperty(this,s,{configurable:!0,enumerable:!0,get:()=>f(this,we).get(r)??null,set:l=>{const c=f(this,we).get(r);if(c&&this.removeEventListener(r,c),typeof l=="function"){const d=l;f(this,we).set(r,d),this.addEventListener(r,d)}else f(this,we).delete(r)}}),n&&(this[s]=a)}},Tt=function(t,i){var r;const s=Uo(t,i);if(!s){C(this,A,Q).call(this,`rejected invalid value for property "${t.configKey}"; keeping previous value`,i);return}if(C(this,A,It).call(this,s),t.reflect&&t.attribute&&((r=t.converter)!=null&&r.toAttribute)){const n=t.converter.toAttribute(s.value);B(this,Ee,!0);try{n===null?this.removeAttribute(t.attribute):this.setAttribute(t.attribute,n)}finally{B(this,Ee,!1)}}},It=function(t){f(this,pe)[t.configKey]=t.value,t.field&&(this[t.field]=t.value),t.on!=="none"&&(t.on==="reinit"&&B(this,me,!0),(f(this,xe)??B(this,xe,{}))[t.configKey]=t.value,f(this,We).schedule(f(this,at)))},qe=function(){f(this,We).cancel(),C(this,A,Ot).call(this)},Ot=function(){if(!this.isConnected)return;const t=f(this,me),i=f(this,xe);B(this,me,!1),B(this,xe,null),t?this.reinit():i&&Object.keys(i).length>0&&this.update(i),C(this,A,Lo).call(this)},Lo=function(){if(f(this,_e).length===0)return;const t=f(this,_e);B(this,_e,[]);for(const i of t)i()},y(ht,"inputs"),y(ht,"events");function zt(o,e,t){typeof customElements>"u"||customElements.get(o)||customElements.define(o,e,t)}function ls(o){return{enableLogging:e=>o.enableLogging(e),disableLogging:()=>o.disableLogging(),setLogLevel:e=>o.setLogLevel(e),setCategoryLevel:(e,t)=>o.setCategoryLevel(e,t),getCategories:()=>[...o.LOGGING_CATEGORIES]}}function cs(o,e,t){const{config:i,logging:s,shouldAutoDefine:r=!0}=t;s&&Qo(o,s);const n={version:()=>i.version,config:i,...s?{logging:ls(s)}:{},register:()=>zt(o,e),getInstances:()=>Yo(o)};return typeof window<"u"&&((window.components??(window.components={}))[o]=n),r&&zt(o,e),n}const Nt=new Map,Rt=new WeakMap;let Xe;function ds(o){if(typeof CSSStyleSheet>"u"||!("adoptedStyleSheets"in o))return!1;if(Xe===void 0)try{new CSSStyleSheet().replaceSync(""),Xe=!0}catch{Xe=!1}return Xe}function hs(o,...e){if(typeof document>"u")return;let t=Rt.get(o);t||Rt.set(o,t=new Set);const i=e.filter(r=>r&&!t.has(r));if(i.length===0)return;for(const r of i)t.add(r);if(ds(o)){const r=i.map(n=>{let a=Nt.get(n);return a||(a=new CSSStyleSheet,a.replaceSync(n),Nt.set(n,a)),a});o.adoptedStyleSheets=[...o.adoptedStyleSheets,...r];return}const s=o.head??o;for(const r of i){const n=document.createElement("style");n.textContent=r,s.appendChild(n)}}function ps(o,e={}){const t=e.position??"last",i=o.head??o;let s=null;const r=()=>typeof document>"u"?null:(s||(s=document.createElement("style"),e.className&&(s.className=e.className)),s.parentNode!==i&&(t==="first"&&i.firstChild?i.insertBefore(s,i.firstChild):i.appendChild(s)),s),n=()=>{s==null||s.remove()};return{set(a){if(!a){n();return}const l=r();l&&(l.textContent=a)},clear:n,destroy(){s==null||s.remove(),s=null}}}function Bt(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ms(o,e){const t=new Set,i=new RegExp(`var\\(\\s*(${Bt(e)}[a-z0-9-]+)`,"gi");let s;for(;s=i.exec(o);)s[1]&&t.add(s[1]);return t}function us(o,e){const t=new Set,i=new RegExp(`(${Bt(e)}[a-z0-9-]+)\\s*:`,"gi");let s;for(;s=i.exec(o);)s[1]&&t.add(s[1]);return[...t]}function fs(o,e,t={}){const i=t.minScore??3,s=t.limit??3,r=new Set(o.split("-").filter(Boolean));return[...e].map(n=>({k:n,score:n.split("-").filter(a=>r.has(a)).length})).filter(n=>n.score>=i).sort((n,a)=>a.score-n.score).slice(0,s).map(n=>n.k)}function gs(o,e){if(e.consumed.size===0)return[];const t=[];for(const i of us(o,e.prefix))e.consumed.has(i)||t.push({name:i,suggestions:fs(i,e.consumed,{minScore:e.minScore})});return t}var bs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Kt={exports:{}};(function(o){(function(e,t){o.exports?o.exports=t():e.log=t()})(bs,function(){var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],r={},n=null;function a(u,v){var p=u[v];if(typeof p.bind=="function")return p.bind(u);try{return Function.prototype.bind.call(p,u)}catch{return function(){return Function.prototype.apply.apply(p,[u,arguments])}}}function l(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(u){return u==="debug"&&(u="log"),typeof console===t?!1:u==="trace"&&i?l:console[u]!==void 0?a(console,u):console.log!==void 0?a(console,"log"):e}function d(){for(var u=this.getLevel(),v=0;v<s.length;v++){var p=s[v];this[p]=v<u?e:this.methodFactory(p,u,this.name)}if(this.log=this.debug,typeof console===t&&u<this.levels.SILENT)return"No console available for logging"}function h(u){return function(){typeof console!==t&&(d.call(this),this[u].apply(this,arguments))}}function g(u,v,p){return c(u)||h.apply(this,arguments)}function m(u,v){var p=this,x,S,k,E="loglevel";typeof u=="string"?E+=":"+u:typeof u=="symbol"&&(E=void 0);function V(w){var _=(s[w]||"silent").toUpperCase();if(!(typeof window===t||!E)){try{window.localStorage[E]=_;return}catch{}try{window.document.cookie=encodeURIComponent(E)+"="+_+";"}catch{}}}function F(){var w;if(!(typeof window===t||!E)){try{w=window.localStorage[E]}catch{}if(typeof w===t)try{var _=window.document.cookie,N=encodeURIComponent(E),I=_.indexOf(N+"=");I!==-1&&(w=/^([^;]+)/.exec(_.slice(I+N.length+1))[1])}catch{}return p.levels[w]===void 0&&(w=void 0),w}}function U(){if(!(typeof window===t||!E)){try{window.localStorage.removeItem(E)}catch{}try{window.document.cookie=encodeURIComponent(E)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function L(w){var _=w;if(typeof _=="string"&&p.levels[_.toUpperCase()]!==void 0&&(_=p.levels[_.toUpperCase()]),typeof _=="number"&&_>=0&&_<=p.levels.SILENT)return _;throw new TypeError("log.setLevel() called with invalid level: "+w)}p.name=u,p.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},p.methodFactory=v||g,p.getLevel=function(){return k??S??x},p.setLevel=function(w,_){return k=L(w),_!==!1&&V(k),d.call(p)},p.setDefaultLevel=function(w){S=L(w),F()||p.setLevel(w,!1)},p.resetLevel=function(){k=null,U(),d.call(p)},p.enableAll=function(w){p.setLevel(p.levels.TRACE,w)},p.disableAll=function(w){p.setLevel(p.levels.SILENT,w)},p.rebuild=function(){if(n!==p&&(x=L(n.getLevel())),d.call(p),n===p)for(var w in r)r[w].rebuild()},x=L(n?n.getLevel():"WARN");var T=F();T!=null&&(k=L(T)),d.call(p)}n=new m,n.getLogger=function(v){if(typeof v!="symbol"&&typeof v!="string"||v==="")throw new TypeError("You must supply a name when creating a logger.");var p=r[v];return p||(p=r[v]=new m(v,n.methodFactory)),p};var b=typeof window!==t?window.log:void 0;return n.noConflict=function(){return typeof window!==t&&window.log===n&&(window.log=b),n},n.getLoggers=function(){return r},n.default=n,n})})(Kt);var te=Kt.exports;const vs=["INIT","DATA","UI"],ys="debug",Ht=["#4c8bf5","#2ea043","#d29922","#a371f7","#db61a2","#e5534b","#3fb0ac","#8a6d3b"],Ft=new WeakSet;function ws(o,e,t){if(Ft.has(o))return;Ft.add(o);const i=o.methodFactory,s=`color:${t};font-weight:bold`;o.methodFactory=(r,n,a)=>{const l=i(r,n,a);return(...c)=>l(`%c[${e}]`,s,...c)},o.setLevel(o.getLevel(),!1)}function xs(o){return typeof o=="number"?o:te.levels[o.toUpperCase()]??te.levels.SILENT}const _s=[["trace",te.levels.TRACE,"debug"],["debug",te.levels.DEBUG,"debug"],["info",te.levels.INFO,"info"],["warn",te.levels.WARN,"warn"],["error",te.levels.ERROR,"error"]];function ks(o,e,t){const i=`color:${o.color};font-weight:bold`,s="color:#888",r={};for(const[n,a,l]of _s)r[n]=(...c)=>{const d=t(),h=Math.min(o.logger.getLevel(),d==null?te.levels.SILENT:xs(d));if(a<h)return;(console[l]??console.log).bind(console)(`%c[${o.label}]%c ${e}`,i,s,...c)};return r}function Cs(o,e=vs){const t={},i={};e.forEach((r,n)=>{const a=`${o}:${r}`,l=Ht[n%Ht.length],c=te.getLogger(a);ws(c,a,l),t[r]=c,i[r]={label:a,color:l,logger:c}});const s=r=>{for(const n of e)t[n].setLevel(r,!1)};return{loggers:t,LOGGING_CATEGORIES:e,enableLogging(r=ys){s(r)},disableLogging(){s("silent")},setLogLevel(r){s(r)},setCategoryLevel(r,n){var a;(a=t[r])==null||a.setLevel(n,!1)},forInstance(r,n){const a={};for(const l of e)a[l]=ks(i[l],r,n);return a}}}const ce=Math.min,oe=Math.max,Ye=Math.round,Qe=Math.floor,se=o=>({x:o,y:o}),Ss={left:"right",right:"left",bottom:"top",top:"bottom"};function Wt(o,e,t){return oe(o,ce(e,t))}function Se(o,e){return typeof o=="function"?o(e):o}function ge(o){return o.split("-")[0]}function Te(o){return o.split("-")[1]}function jt(o){return o==="x"?"y":"x"}function pt(o){return o==="y"?"height":"width"}function ie(o){const e=o[0];return e==="t"||e==="b"?"y":"x"}function mt(o){return jt(ie(o))}function Ts(o,e,t){t===void 0&&(t=!1);const i=Te(o),s=mt(o),r=pt(s);let n=s==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(n=Ze(n)),[n,Ze(n)]}function Is(o){const e=Ze(o);return[ut(o),e,ut(e)]}function ut(o){return o.includes("start")?o.replace("start","end"):o.replace("end","start")}const Gt=["left","right"],Ut=["right","left"],Os=["top","bottom"],Ps=["bottom","top"];function Ms(o,e,t){switch(o){case"top":case"bottom":return t?e?Ut:Gt:e?Gt:Ut;case"left":case"right":return e?Os:Ps;default:return[]}}function As(o,e,t,i){const s=Te(o);let r=Ms(ge(o),t==="start",i);return s&&(r=r.map(n=>n+"-"+s),e&&(r=r.concat(r.map(ut)))),r}function Ze(o){const e=ge(o);return Ss[e]+o.slice(e.length)}function Ls(o){var e,t,i,s;return{top:(e=o.top)!=null?e:0,right:(t=o.right)!=null?t:0,bottom:(i=o.bottom)!=null?i:0,left:(s=o.left)!=null?s:0}}function qt(o){return typeof o!="number"?Ls(o):{top:o,right:o,bottom:o,left:o}}function et(o){const{x:e,y:t,width:i,height:s}=o;return{width:i,height:s,top:t,left:e,right:e+i,bottom:t+s,x:e,y:t}}function Jt(o,e,t){let{reference:i,floating:s}=o;const r=ie(e),n=mt(e),a=pt(n),l=ge(e),c=r==="y",d=i.x+i.width/2-s.width/2,h=i.y+i.height/2-s.height/2,g=i[a]/2-s[a]/2;let m;switch(l){case"top":m={x:d,y:i.y-s.height};break;case"bottom":m={x:d,y:i.y+i.height};break;case"right":m={x:i.x+i.width,y:h};break;case"left":m={x:i.x-s.width,y:h};break;default:m={x:i.x,y:i.y}}const b=Te(e);return b&&(m[n]+=g*(b==="end"?1:-1)*(t&&c?-1:1)),m}async function Es(o,e){var t;e===void 0&&(e={});const{x:i,y:s,platform:r,rects:n,elements:a,strategy:l}=o,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:g=!1,padding:m=0}=Se(e,o),b=qt(m),v=a[g?h==="floating"?"reference":"floating":h],p=et(await r.getClippingRect({element:(t=await(r.isElement==null?void 0:r.isElement(v)))==null||t?v:v.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),x=h==="floating"?{x:i,y:s,width:n.floating.width,height:n.floating.height}:n.reference,S=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),k=await(r.isElement==null?void 0:r.isElement(S))&&await(r.getScale==null?void 0:r.getScale(S))||{x:1,y:1},E=et(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:S,strategy:l}):x);return{top:(p.top-E.top+b.top)/k.y,bottom:(E.bottom-p.bottom+b.bottom)/k.y,left:(p.left-E.left+b.left)/k.x,right:(E.right-p.right+b.right)/k.x}}const $s=50,Vs=async(o,e,t)=>{const{placement:i="bottom",strategy:s="absolute",middleware:r=[],platform:n}=t,a=n.detectOverflow?n:{...n,detectOverflow:Es},l=await(n.isRTL==null?void 0:n.isRTL(e));let c=await n.getElementRects({reference:o,floating:e,strategy:s}),{x:d,y:h}=Jt(c,i,l),g=i,m=0;const b={};for(let u=0;u<r.length;u++){const v=r[u];if(!v)continue;const{name:p,fn:x}=v,{x:S,y:k,data:E,reset:V}=await x({x:d,y:h,initialPlacement:i,placement:g,strategy:s,middlewareData:b,rects:c,platform:a,elements:{reference:o,floating:e}});d=S??d,h=k??h,b[p]={...b[p],...E},V&&m<$s&&(m++,typeof V=="object"&&(V.placement&&(g=V.placement),V.rects&&(c=V.rects===!0?await n.getElementRects({reference:o,floating:e,strategy:s}):V.rects),{x:d,y:h}=Jt(c,g,l)),u=-1)}return{x:d,y:h,placement:g,strategy:s,middlewareData:b}},Ds=o=>({name:"arrow",options:o,async fn(e){const{x:t,y:i,placement:s,rects:r,platform:n,elements:a,middlewareData:l}=e,{element:c,padding:d=0}=Se(o,e)||{};if(c==null)return{};const h=qt(d),g={x:t,y:i},m=mt(s),b=pt(m),u=await n.getDimensions(c),v=m==="y",p=v?"top":"left",x=v?"bottom":"right",S=v?"clientHeight":"clientWidth",k=r.reference[b]+r.reference[m]-g[m]-r.floating[b],E=g[m]-r.reference[m],V=await(n.getOffsetParent==null?void 0:n.getOffsetParent(c));let F=V?V[S]:0;(!F||!await(n.isElement==null?void 0:n.isElement(V)))&&(F=a.floating[S]||r.floating[b]);const U=k/2-E/2,L=F/2-u[b]/2-1,T=ce(h[p],L),w=ce(h[x],L),_=F-u[b]-w,N=F/2-u[b]/2+U,I=Wt(T,N,_),H=!l.arrow&&Te(s)!=null&&N!==I&&r.reference[b]/2-(N<T?T:w)-u[b]/2<0,le=H?N<T?N-T:N-_:0;return{[m]:g[m]+le,data:{[m]:I,centerOffset:N-I-le,...H&&{alignmentOffset:le}},reset:H}}}),zs=function(o){return o===void 0&&(o={}),{name:"flip",options:o,async fn(e){var t,i;const{placement:s,middlewareData:r,rects:n,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:u=!0,...v}=Se(o,e);if((t=r.arrow)!=null&&t.alignmentOffset)return{};const p=ge(s),x=ie(a),S=ge(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),E=g||(S||!u?[Ze(a)]:Is(a)),V=b!=="none";!g&&V&&E.push(...As(a,u,b,k));const F=[a,...E],U=await l.detectOverflow(e,v),L=[];let T=((i=r.flip)==null?void 0:i.overflows)||[];if(d&&L.push(U[p]),h){const I=Ts(s,n,k);L.push(U[I[0]],U[I[1]])}if(T=[...T,{placement:s,overflows:L}],!L.every(I=>I<=0)){var w,_;const I=(((w=r.flip)==null?void 0:w.index)||0)+1,H=F[I];if(H&&(!(h==="alignment"?x!==ie(H):!1)||T.every(Y=>ie(Y.placement)===x?Y.overflows[0]>0:!0)))return{data:{index:I,overflows:T},reset:{placement:H}};let le=(_=T.filter(Ce=>Ce.overflows[0]<=0).sort((Ce,Y)=>Ce.overflows[1]-Y.overflows[1])[0])==null?void 0:_.placement;if(!le)switch(m){case"bestFit":{var N;const Ce=(N=T.filter(Y=>{if(V){const fe=ie(Y.placement);return fe===x||fe==="y"}return!0}).map(Y=>[Y.placement,Y.overflows.filter(fe=>fe>0).reduce((fe,Fi)=>fe+Fi,0)]).sort((Y,fe)=>Y[1]-fe[1])[0])==null?void 0:N[0];Ce&&(le=Ce);break}case"initialPlacement":le=a;break}if(s!==le)return{reset:{placement:le}}}return{}}}},Ns=new Set(["left","top"]);async function Rs(o,e){const{placement:t,platform:i,elements:s}=o,r=await(i.isRTL==null?void 0:i.isRTL(s.floating)),n=ge(t),a=Te(t),l=ie(t)==="y",c=Ns.has(n)?-1:1,d=r&&l?-1:1,h=Se(e,o);let{mainAxis:g,crossAxis:m,alignmentAxis:b}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof b=="number"&&(m=a==="end"?b*-1:b),l?{x:m*d,y:g*c}:{x:g*c,y:m*d}}const Bs=function(o){return o===void 0&&(o=0),{name:"offset",options:o,async fn(e){var t,i;const{x:s,y:r,placement:n,middlewareData:a}=e,l=await Rs(e,o);return n===((t=a.offset)==null?void 0:t.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:s+l.x,y:r+l.y,data:{...l,placement:n}}}}},Ks=function(o){return o===void 0&&(o={}),{name:"shift",options:o,async fn(e){const{x:t,y:i,placement:s,platform:r}=e,{mainAxis:n=!0,crossAxis:a=!1,limiter:l={fn:x=>{let{x:S,y:k}=x;return{x:S,y:k}}},...c}=Se(o,e),d={x:t,y:i},h=await r.detectOverflow(e,c),g=ie(s),m=jt(g);let b=d[m],u=d[g];const v=(x,S)=>Wt(S+h[x==="y"?"top":"left"],S,S-h[x==="y"?"bottom":"right"]);n&&(b=v(m,b)),a&&(u=v(g,u));const p=l.fn({...e,[m]:b,[g]:u});return{...p,data:{x:p.x-t,y:p.y-i,enabled:{[m]:n,[g]:a}}}}}},Hs=function(o){return o===void 0&&(o={}),{name:"size",options:o,async fn(e){const{placement:t,rects:i,platform:s,elements:r}=e,{apply:n=()=>{},...a}=Se(o,e),l=await s.detectOverflow(e,a),c=ge(t),d=Te(t),h=ie(t)==="y",{width:g,height:m}=i.floating;let b,u;c==="top"||c==="bottom"?(b=c,u=d===(await(s.isRTL==null?void 0:s.isRTL(r.floating))?"start":"end")?"left":"right"):(u=c,b=d==="end"?"top":"bottom");const v=m-l.top-l.bottom,p=g-l.left-l.right,x=ce(m-l[b],v),S=ce(g-l[u],p),k=e.middlewareData.shift,E=!k;let V=x,F=S;k!=null&&k.enabled.x&&(F=p),k!=null&&k.enabled.y&&(V=v),E&&!d&&(h?F=g-2*oe(l.left,l.right):V=m-2*oe(l.top,l.bottom)),await n({...e,availableWidth:F,availableHeight:V});const U=await s.getDimensions(r.floating);return g!==U.width||m!==U.height?{reset:{rects:!0}}:{}}}};function tt(){return typeof window<"u"}function Ie(o){return Xt(o)?(o.nodeName||"").toLowerCase():"#document"}function q(o){var e;return(o==null||(e=o.ownerDocument)==null?void 0:e.defaultView)||window}function re(o){var e;return(e=(Xt(o)?o.ownerDocument:o.document)||window.document)==null?void 0:e.documentElement}function Xt(o){return tt()?o instanceof Node||o instanceof q(o).Node:!1}function Z(o){return tt()?o instanceof Element||o instanceof q(o).Element:!1}function de(o){return tt()?o instanceof HTMLElement||o instanceof q(o).HTMLElement:!1}function Yt(o){return!tt()||typeof ShadowRoot>"u"?!1:o instanceof ShadowRoot||o instanceof q(o).ShadowRoot}function ot(o){const{overflow:e,overflowX:t,overflowY:i,display:s}=ee(o);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&s!=="inline"&&s!=="contents"}function Fs(o){return/^(table|td|th)$/.test(Ie(o))}function st(o){try{if(o.matches(":popover-open"))return!0}catch{}try{return o.matches(":modal")}catch{return!1}}const Ws=/transform|translate|scale|rotate|perspective|filter/,js=/paint|layout|strict|content/,be=o=>!!o&&o!=="none";let ft;function gt(o){const e=Z(o)?ee(o):o;return be(e.transform)||be(e.translate)||be(e.scale)||be(e.rotate)||be(e.perspective)||!bt()&&(be(e.backdropFilter)||be(e.filter))||Ws.test(e.willChange||"")||js.test(e.contain||"")}function Gs(o){let e=ve(o);for(;de(e)&&!ze(e);){if(gt(e))return e;if(st(e))return null;e=ve(e)}return null}function bt(){return ft==null&&(ft=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ft}function ze(o){return/^(html|body|#document)$/.test(Ie(o))}function ee(o){return q(o).getComputedStyle(o)}function it(o){return Z(o)?{scrollLeft:o.scrollLeft,scrollTop:o.scrollTop}:{scrollLeft:o.scrollX,scrollTop:o.scrollY}}function ve(o){if(Ie(o)==="html")return o;const e=o.assignedSlot||o.parentNode||Yt(o)&&o.host||re(o);return Yt(e)?e.host:e}function Qt(o){const e=ve(o);return ze(e)?(o.ownerDocument||o).body:de(e)&&ot(e)?e:Qt(e)}function Ne(o,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);const s=Qt(o),r=s===((i=o.ownerDocument)==null?void 0:i.body),n=q(s);if(r){const a=vt(n);return e.concat(n,n.visualViewport||[],ot(s)?s:[],a&&t?Ne(a):[])}else return e.concat(s,Ne(s,[],t))}function vt(o){return o.parent&&Object.getPrototypeOf(o.parent)?o.frameElement:null}function Zt(o){const e=ee(o);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const s=de(o),r=s?o.offsetWidth:t,n=s?o.offsetHeight:i,a=Ye(t)!==r||Ye(i)!==n;return a&&(t=r,i=n),{width:t,height:i,$:a}}function yt(o){return Z(o)?o:o.contextElement}function Oe(o){const e=yt(o);if(!de(e))return se(1);const t=e.getBoundingClientRect(),{width:i,height:s,$:r}=Zt(e);let n=(r?Ye(t.width):t.width)/i,a=(r?Ye(t.height):t.height)/s;return(!n||!Number.isFinite(n))&&(n=1),(!a||!Number.isFinite(a))&&(a=1),{x:n,y:a}}const Us=se(0);function eo(o){const e=q(o);return!bt()||!e.visualViewport?Us:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function qs(o,e,t){return e===void 0&&(e=!1),!!t&&e&&t===q(o)}function ye(o,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const s=o.getBoundingClientRect(),r=yt(o);let n=se(1);e&&(i?Z(i)&&(n=Oe(i)):n=Oe(o));const a=qs(r,t,i)?eo(r):se(0);let l=(s.left+a.x)/n.x,c=(s.top+a.y)/n.y,d=s.width/n.x,h=s.height/n.y;if(r&&i){const g=q(r),m=Z(i)?q(i):i;let b=g,u=vt(b);for(;u&&m!==b;){const v=Oe(u),p=u.getBoundingClientRect(),x=ee(u),S=p.left+(u.clientLeft+parseFloat(x.paddingLeft))*v.x,k=p.top+(u.clientTop+parseFloat(x.paddingTop))*v.y;l*=v.x,c*=v.y,d*=v.x,h*=v.y,l+=S,c+=k,b=q(u),u=vt(b)}}return et({width:d,height:h,x:l,y:c})}function rt(o,e){const t=it(o).scrollLeft;return e?e.left+t:ye(re(o)).left+t}function to(o,e){const t=o.getBoundingClientRect(),i=t.left+e.scrollLeft-rt(o,t),s=t.top+e.scrollTop;return{x:i,y:s}}function Js(o){let{elements:e,rect:t,offsetParent:i,strategy:s}=o;const r=s==="fixed",n=re(i),a=e?st(e.floating):!1;if(i===n||a&&r)return t;let l={scrollLeft:0,scrollTop:0},c=se(1);const d=se(0),h=de(i);if((h||!r)&&((Ie(i)!=="body"||ot(n))&&(l=it(i)),h)){const m=ye(i);c=Oe(i),d.x=m.x+i.clientLeft,d.y=m.y+i.clientTop}const g=n&&!h&&!r?to(n,l):se(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+d.x+g.x,y:t.y*c.y-l.scrollTop*c.y+d.y+g.y}}function Xs(o){return o.getClientRects?Array.from(o.getClientRects()):[]}function Ys(o){const e=it(o),t=o.ownerDocument.body,i=oe(o.scrollWidth,o.clientWidth,t.scrollWidth,t.clientWidth),s=oe(o.scrollHeight,o.clientHeight,t.scrollHeight,t.clientHeight);let r=-e.scrollLeft+rt(o);const n=-e.scrollTop;return ee(t).direction==="rtl"&&(r+=oe(o.clientWidth,t.clientWidth)-i),{width:i,height:s,x:r,y:n}}const Qs=25;function Zs(o,e,t){t===void 0&&(t="viewport");const i=t==="layoutViewport",s=q(o),r=re(o),n=s.visualViewport;let a=r.clientWidth,l=r.clientHeight,c=0,d=0;if(n){const g=!bt()||e==="fixed";i?g||(c=-n.offsetLeft,d=-n.offsetTop):(a=n.width,l=n.height,g&&(c=n.offsetLeft,d=n.offsetTop))}if(rt(r)<=0){const g=r.ownerDocument,m=g.body,b=getComputedStyle(m),u=g.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,v=Math.abs(r.clientWidth-m.clientWidth-u),p=getComputedStyle(r).scrollbarGutter==="stable both-edges"?v/2:v;p<=Qs&&(a-=p)}return{width:a,height:l,x:c,y:d}}function ei(o,e){const t=ye(o,!0,e==="fixed"),i=t.top+o.clientTop,s=t.left+o.clientLeft,r=Oe(o),n=o.clientWidth*r.x,a=o.clientHeight*r.y,l=s*r.x,c=i*r.y;return{width:n,height:a,x:l,y:c}}function oo(o,e,t){let i;if(e==="viewport"||e==="layoutViewport")i=Zs(o,t,e);else if(e==="document")i=Ys(re(o));else if(Z(e))i=ei(e,t);else{const s=eo(o);i={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return et(i)}function ti(o,e){const t=e.get(o);if(t)return t;let i=Ne(o,[],!1).filter(a=>Z(a)&&Ie(a)!=="body"),s=null;const r=ee(o).position==="fixed";let n=r?ve(o):o;for(;Z(n)&&!ze(n);){const a=ee(n),l=gt(n),c=s?s.position:r?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?i=i.filter(h=>h!==n):s=a,n=ve(n)}return e.set(o,i),i}function oi(o){let{element:e,boundary:t,rootBoundary:i,strategy:s}=o;const n=[...t==="clippingAncestors"?st(e)?[]:ti(e,this._c):[].concat(t),i],a=oo(e,n[0],s);let l=a.top,c=a.right,d=a.bottom,h=a.left;for(let g=1;g<n.length;g++){const m=oo(e,n[g],s);l=oe(m.top,l),c=ce(m.right,c),d=ce(m.bottom,d),h=oe(m.left,h)}return{width:c-h,height:d-l,x:h,y:l}}function si(o){const{width:e,height:t}=Zt(o);return{width:e,height:t}}function ii(o,e,t){const i=de(e),s=re(e),r=t==="fixed",n=ye(o,!0,r,e);let a={scrollLeft:0,scrollTop:0};const l=se(0);if((i||!r)&&((Ie(e)!=="body"||ot(s))&&(a=it(e)),i)){const g=ye(e,!0,r,e);l.x=g.x+e.clientLeft,l.y=g.y+e.clientTop}!i&&s&&(l.x=rt(s));const c=s&&!i&&!r?to(s,a):se(0),d=n.left+a.scrollLeft-l.x-c.x,h=n.top+a.scrollTop-l.y-c.y;return{x:d,y:h,width:n.width,height:n.height}}function wt(o){return ee(o).position==="static"}function so(o,e){if(!de(o)||ee(o).position==="fixed")return null;if(e)return e(o);let t=o.offsetParent;return re(o)===t&&(t=t.ownerDocument.body),t}function io(o,e){const t=q(o);if(st(o))return t;if(!de(o)){let s=ve(o);for(;s&&!ze(s);){if(Z(s)&&!wt(s))return s;s=ve(s)}return t}let i=so(o,e);for(;i&&Fs(i)&&wt(i);)i=so(i,e);return i&&ze(i)&&wt(i)&&!gt(i)?t:i||Gs(o)||t}const ri=async function(o){const e=this.getOffsetParent||io,t=this.getDimensions,i=await t(o.floating);return{reference:ii(o.reference,await e(o.floating),o.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ni(o){return ee(o).direction==="rtl"}const ro={convertOffsetParentRelativeRectToViewportRelativeRect:Js,getDocumentElement:re,getClippingRect:oi,getOffsetParent:io,getElementRects:ri,getClientRects:Xs,getDimensions:si,getScale:Oe,isElement:Z,isRTL:ni};function no(o,e){return o.x===e.x&&o.y===e.y&&o.width===e.width&&o.height===e.height}function ai(o,e,t){let i=null,s;const r=re(o);function n(){var d;clearTimeout(s),(d=i)==null||d.disconnect(),i=null}function a(d,h){d===void 0&&(d=!1),h===void 0&&(h=1),n();const g=o.getBoundingClientRect(),{left:m,top:b,width:u,height:v}=g;if(d||e(),!u||!v)return;const p=Qe(b),x=Qe(r.clientWidth-(m+u)),S=Qe(r.clientHeight-(b+v)),k=Qe(m),V={rootMargin:-p+"px "+-x+"px "+-S+"px "+-k+"px",threshold:oe(0,ce(1,h))||1};let F=!0;function U(L){const T=L[0].intersectionRatio;if(!no(g,o.getBoundingClientRect()))return a();if(T!==h){if(!F)return a();T?a(!1,T):s=setTimeout(()=>{a(!1,1e-7)},1e3)}F=!1}try{i=new IntersectionObserver(U,{...V,root:r.ownerDocument})}catch{i=new IntersectionObserver(U,V)}i.observe(o)}const l=q(o),c=()=>a(t);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),n()}}function li(o,e,t,i){i===void 0&&(i={});const{ancestorScroll:s=!0,ancestorResize:r=!0,elementResize:n=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,c=yt(o),d=s||r?[...c?Ne(c):[],...e?Ne(e):[]]:[];d.forEach(p=>{s&&p.addEventListener("scroll",t),r&&p.addEventListener("resize",t)});const h=c&&a?ai(c,t,r):null;let g=-1,m=null;n&&(m=new ResizeObserver(p=>{let[x]=p;x&&x.target===c&&m&&e&&(m.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var S;(S=m)==null||S.observe(e)})),t()}),c&&!l&&m.observe(c),e&&m.observe(e));let b,u=l?ye(o):null;l&&v();function v(){const p=ye(o);u&&!no(u,p)&&t(),u=p,b=requestAnimationFrame(v)}return t(),()=>{var p;d.forEach(x=>{s&&x.removeEventListener("scroll",t),r&&x.removeEventListener("resize",t)}),h==null||h(),(p=m)==null||p.disconnect(),m=null,l&&cancelAnimationFrame(b)}}const ci=Bs,di=Ks,hi=zs,ao=Hs,pi=Ds,mi=(o,e,t)=>{const i=new Map,s=t??{},r={...ro,...s.platform,_c:i};return Vs(o,e,{...s,platform:r})};function xt(o){const e=o.parentNode??null;return e instanceof ShadowRoot?e.host:e}function ui(o){if(o.transform!=="none"||o.perspective!=="none"||o.filter!=="none")return!0;const e=o.backdropFilter;return!!(e&&e!=="none"||o.willChange&&/\b(transform|filter|perspective)\b/.test(o.willChange))}function lo(o){let e=xt(o);for(;e&&!(e===document.body||e===document.documentElement);){if(e instanceof Element&&ui(getComputedStyle(e)))return e;e=xt(e)}return window}function fi(o,e,t){let i=o;for(;i&&!(i===document.body||i===document.documentElement);){if(i instanceof Element){const s=i.getBoundingClientRect();if(Math.abs(s.x-e)<2&&Math.abs(s.y-t)<2)return i}i=xt(i)}return null}function gi(o){const e=getComputedStyle(o),t=[];e.transform!=="none"&&t.push(`transform: ${e.transform}`),e.perspective!=="none"&&t.push(`perspective: ${e.perspective}`),e.filter!=="none"&&t.push(`filter: ${e.filter}`);const i=e.backdropFilter;i&&i!=="none"&&t.push(`backdrop-filter: ${i}`),e.willChange&&/\b(transform|filter|perspective)\b/.test(e.willChange)&&t.push(`will-change: ${e.willChange}`),e.contain&&/\b(paint|layout|strict|content)\b/.test(e.contain)&&t.push(`contain: ${e.contain}`);const s=e.containerType;return s&&s!=="normal"&&t.push(`container-type: ${s}`),t.join("; ")}function bi(o){const e=o.id?`#${o.id}`:"",t=typeof o.className=="string"&&o.className?"."+o.className.split(/\s+/).filter(Boolean).slice(0,2).join("."):"";return`<${o.tagName.toLowerCase()}${e}${t}>`}function vi(o){const e=o.tolerance??1.5;let t=0,i=0;if(o.offsetParent instanceof Element){const l=o.offsetParent.getBoundingClientRect(),c=getComputedStyle(o.offsetParent);t=l.x+(parseFloat(c.borderLeftWidth)||0),i=l.y+(parseFloat(c.borderTopWidth)||0)}const s=o.panel.getBoundingClientRect(),r=s.x-(t+o.expectedX),n=s.y-(i+o.expectedY);if(Math.abs(r)<e&&Math.abs(n)<e)return null;const a=fi(o.reference,r,n);return{driftX:r,driftY:n,culprit:a,culpritDescription:a?bi(a):"an ancestor element (could not auto-identify)",culpritCss:a?gi(a):""}}function yi(o,e){var s;const t=(s=o.closest)==null?void 0:s.call(o,"[data-theme]"),i=t==null?void 0:t.getAttribute("data-theme");i!=null&&e.setAttribute("data-theme",i)}const wi={top:"bottom",right:"left",bottom:"top",left:"right"};function xi(o,e,t){if(!t)return;const i=e.split("-")[0],s=wi[i];o.style.left=t.x!=null?`${t.x}px`:"",o.style.top=t.y!=null?`${t.y}px`:"",o.style.right="",o.style.bottom="",o.style[s]=`-${o.offsetWidth/2}px`}function co(o,e){const t=[ci(o.offset??4)];if(o.matchWidth){const s=o.matchWidth;t.push(ao({apply({rects:r,elements:n}){const a=`${r.reference.width}px`;s==="exact"?n.floating.style.width=a:n.floating.style.minWidth=a}}))}e&&t.push(hi({...o.lockPlacement===!0?{fallbackStrategy:"initialPlacement"}:{},...o.flipPadding!=null?{padding:o.flipPadding}:{}}));const i=o.shift??8;if(i!==!1&&t.push(di({padding:i})),o.maxHeight){const s=typeof o.maxHeight=="object"?o.maxHeight.padding:void 0;t.push(ao({padding:s,apply({availableHeight:r,elements:n}){n.floating.style.maxHeight=`${Math.max(0,r)}px`}}))}return o.arrow&&t.push(pi({element:o.arrow.element,padding:o.arrow.padding})),t}function _t(o,e,t={}){const i=t.strategy??"fixed";t.inheritThemeFrom&&yi(t.inheritThemeFrom,o),o.style.position=i,o.style.left="0",o.style.top="0";let s=t.placement??"bottom-start",r=t.flip??!0,n=co(t,r);const a=t.lockPlacement==="freeze";let l=!1;const c=!!t.fixedContainingBlock&&!t.platform,d=t.platform??(c?{...ro,getOffsetParent:()=>lo(o)}:void 0),h=()=>{var m;(m=t.beforeCompute)==null||m.call(t),mi(e,o,{placement:s,strategy:i,middleware:n,...d?{platform:d}:{}}).then(({x:b,y:u,placement:v,middlewareData:p})=>{var x,S;if(o.style.left=`${b}px`,o.style.top=`${u}px`,t.arrow&&xi(t.arrow.element,v,p.arrow),a&&!l&&(l=!0,s=v,r=!1,n=co(t,!1)),(x=t.onPlaced)==null||x.call(t,v),(S=t.onComputed)==null||S.call(t,{x:b,y:u,placement:v}),t.onDrift&&e instanceof Element){const k=c?lo(o):window,E=vi({panel:o,reference:e,expectedX:b,expectedY:u,offsetParent:k});E&&t.onDrift(E)}})};let g;return t.autoUpdate??!0?g=li(e,o,h,t.autoUpdateOptions):h(),{update:h,destroy(){g==null||g(),g=void 0}}}function _i(o){return typeof o=="number"?{show:o,hide:o}:{show:(o==null?void 0:o.show)??0,hide:(o==null?void 0:o.hide)??0}}function ki(o){const e=o.container??document.body,t=o.placement??"top",i=o.visibleClass??"is-visible",s=_i(o.delay),r=document.createElement("div");r.setAttribute("role","tooltip"),o.cssClass&&(r.className=o.cssClass),typeof o.content=="string"?r.textContent=o.content:r.append(o.content);let n,a=!1,l,c,d;const h={getBoundingClientRect:()=>d??o.trigger.getBoundingClientRect(),contextElement:o.trigger},g=x=>{d=new DOMRect(x.clientX,x.clientY,0,0),n==null||n.update()},m=()=>{l&&clearTimeout(l),c&&clearTimeout(c),l=c=void 0},b=()=>{var S;if(m(),a)return;(S=o.onBeforeShow)==null||S.call(o),a=!0,e.append(r);const x=o.followCursor?h:o.trigger;n=_t(r,x,{placement:t,strategy:o.strategy,offset:o.offset??8,inheritThemeFrom:o.inheritThemeFrom??o.trigger}),o.followCursor&&o.trigger.addEventListener("mousemove",g),r.classList.add(i)},u=()=>{m(),a&&(a=!1,r.classList.remove(i),o.followCursor&&o.trigger.removeEventListener("mousemove",g),n==null||n.destroy(),n=void 0,r.remove())},v=()=>{m(),s.show>0?l=setTimeout(b,s.show):b()},p=()=>{m(),s.hide>0?c=setTimeout(u,s.hide):u()};return o.trigger.addEventListener("mouseenter",v),o.trigger.addEventListener("mouseleave",p),o.trigger.addEventListener("focusin",v),o.trigger.addEventListener("focusout",p),{element:r,get isVisible(){return a},show:b,hide:u,destroy(){o.trigger.removeEventListener("mouseenter",v),o.trigger.removeEventListener("mouseleave",p),o.trigger.removeEventListener("focusin",v),o.trigger.removeEventListener("focusout",p),u()}}}const ho=["INIT","DATA","UI","INTERACTION"],ne=Cs("MULTISELECT",ho),Re=ne.loggers.INIT,j=ne.loggers.DATA,J=ne.loggers.UI,G=ne.loggers.INTERACTION,Ci=ho.map(o=>`MULTISELECT:${o}`);function Si(){ne.enableLogging()}function Ti(){ne.disableLogging()}function Ii(o){ne.setLogLevel(o)}function Oi(o,e){const t=o.includes(":")?o.split(":").pop():o;ne.setCategoryLevel(t,e)}class po{constructor(e){y(this,"container");y(this,"wrapper");y(this,"viewport");y(this,"itemHeight");y(this,"items");y(this,"renderItem");y(this,"bufferSize");y(this,"onVisibleRangeChange");y(this,"onScroll");y(this,"scrollTop",0);y(this,"viewportHeight",0);y(this,"visibleStart",0);y(this,"visibleEnd",0);y(this,"scrollHandler");y(this,"resizeObserver");this.container=e.container,this.itemHeight=e.itemHeight,this.items=e.items,this.renderItem=e.renderItem,this.bufferSize=e.bufferSize??10,this.onVisibleRangeChange=e.onVisibleRangeChange,this.onScroll=e.onScroll,this.scrollHandler=this.handleScroll.bind(this),this.init()}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.style.position="relative",this.wrapper.style.width="100%",this.wrapper.style.height=`${this.items.length*this.itemHeight}px`,this.wrapper.className="ms__virtual-scroll-wrapper",this.viewport=document.createElement("div"),this.viewport.style.position="absolute",this.viewport.style.top="0",this.viewport.style.left="0",this.viewport.style.right="0",this.viewport.style.width="100%",this.viewport.className="ms__virtual-scroll-viewport",this.wrapper.appendChild(this.viewport),this.container.appendChild(this.wrapper),this.container.addEventListener("scroll",this.scrollHandler),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{this.updateViewportHeight(),this.render()}),this.resizeObserver.observe(this.container)),this.updateViewportHeight(),this.render()}updateViewportHeight(){const e=this.container.clientHeight;e>0&&(this.viewportHeight=e)}handleScroll(){this.scrollTop=this.container.scrollTop,this.onScroll&&this.onScroll(this.scrollTop),this.render()}calculateVisibleRange(){const e=Math.floor(this.scrollTop/this.itemHeight),t=Math.ceil((this.scrollTop+this.viewportHeight)/this.itemHeight),i=Math.max(0,e-this.bufferSize),s=Math.min(this.items.length,t+this.bufferSize);return{start:i,end:s}}render(){const{start:e,end:t}=this.calculateVisibleRange();if(e===this.visibleStart&&t===this.visibleEnd)return;this.visibleStart=e,this.visibleEnd=t,this.onVisibleRangeChange&&this.onVisibleRangeChange(e,t);let i="";for(let s=e;s<t;s++){const r=this.items[s],n=this.renderItem(r,s),a=s*this.itemHeight;i+=`<div class="ms__virtual-item" style="position: absolute; top: ${a}px; left: 0; right: 0; height: ${this.itemHeight}px;" data-index="${s}">`,i+=n,i+="</div>"}this.viewport.innerHTML=i}setItems(e){const t=e!==this.items||e.length!==this.items.length;this.items=e,this.wrapper.style.height=`${e.length*this.itemHeight}px`,this.updateViewportHeight(),t&&(this.scrollTop=0,this.container.scrollTop=0),this.visibleStart=-1,this.visibleEnd=-1,this.render()}scrollToIndex(e){if(e<0||e>=this.items.length)return;const t=e*this.itemHeight,i=t+this.itemHeight,s=this.container.scrollTop,r=s+this.viewportHeight;t<s?this.container.scrollTop=t:i>r&&(this.container.scrollTop=i-this.viewportHeight)}getVisibleRange(){return{start:this.visibleStart,end:this.visibleEnd}}getItemCount(){return this.items.length}setItemHeight(e){this.itemHeight=e,this.wrapper.style.height=`${this.items.length*e}px`,this.visibleStart=-1,this.visibleEnd=-1,this.render()}setBufferSize(e){this.bufferSize=e,this.visibleStart=-1,this.visibleEnd=-1,this.render()}refresh(){this.visibleStart=-1,this.visibleEnd=-1,this.render()}destroy(){this.container.removeEventListener("scroll",this.scrollHandler),this.resizeObserver&&this.resizeObserver.disconnect(),this.container.innerHTML=""}}function mo(o){return{treeId:"",id:-1,path:"",pathSegment:"",parentPath:void 0,level:void 0,children:{},hasChildren:!1,isSelectable:!0,data:void 0,...o}}const Be=o=>!o||typeof o=="string"&&o.trim()==="";function Pi(o,e="."){if(!o||typeof o!="string")return null;const t=o.lastIndexOf(e);return t===-1?"":o.substring(0,t)}function uo(o,e,t="."){return Be(e)?o:o.startsWith(e+t)?o.substring(e.length+t.length):o}function fo(o,e=0,t=1,i="."){return o.split(i).slice(e,e+t).join(i)}function Mi(o,e){return o.split(e).length}function he(o,e){return o[e]}function Ai(o={}){const e=o.idMember,t=o.pathMember,i=o.getPathCallback,s=o.parentPathMember,r=o.levelMember,n=o.hasChildrenMember,a=o.isSelectableMember,l=o.getIsSelectableCallback,c=o.treeId||"multiselect-tree",d=o.orderMember,h=o.getDisplayValueCallback,g=Be(s),m=Be(r),b=Be(n),u=Be(a),v="x",p=o.treePathSeparator||".",x=mo();let S=0,k=null;const E=L=>i?i(L):t?he(L,t):void 0,V={treePathSeparator:p,root:x,get tree(){return Object.values(x.children)},get flatNodes(){if(k)return k;const L=[],T=o.isSorted??!1,w=o.sortCallback;function _(N){let I=Object.values(N.children);T&&w&&I.length>0&&(I=w(I));for(const H of I)L.push(H),H.hasChildren&&_(H)}return _(x),k=L,L},insertArray(L){L=L||[],x.children={},S=0,k=null;const T=[];let w=L.map((_,N)=>{const I=mo();I.treeId=c,I.id=e?he(_,e):void 0;const H=E(_);return H==null||H===""||typeof H!="string"?(T.push(`index ${N}`),null):(I.path=H,(I.id===void 0||I.id===-1)&&(I.id=H),g?I.parentPath=Pi(I.path,p):I.parentPath=he(_,s),I.pathSegment=fo(uo(I.path,I.parentPath??"",p),0,1,p),m?I.level=Mi(I.path,p):I.level=he(_,r),b||(I.hasChildren=he(_,n)),I.data=_,I)}).filter(_=>_!==null);o.isSorted||(o.sortCallback?w=o.sortCallback(w):w=U(w));for(const _ of w)F(_.parentPath??"",_);if(l||!u)for(const _ of w)if(l)_.isSelectable=l(_)!==!1;else{const N=he(_.data,a);_.isSelectable=N==null?!0:!!N}T.length>0&&console.warn(`[ltree ${c}] ${T.length} option(s) had an invalid path and were skipped (pathMember="${t}"). Offending: ${T.slice(0,5).join(", ")}`+(T.length>5?", …":""))},getNodeByPath(L,T){let w=T||x;if(L){const _=L.split(p);for(let N=0;N<_.length;N++){const I=v+_[N];if(!w.children.hasOwnProperty(I))return null;w=w.children[I]}}return w}};function F(L,T){const w=V.getNodeByPath(L);if(!w)return`Node: ${T.path} - Could not find parent node: ${L}`;m&&(T.level=(w.level||0)+1);const _=v+fo(uo(T.path,L,p),0,1,p);return w.children.hasOwnProperty(_)||(w.children[_]=T,b&&!w.hasChildren&&(w.hasChildren=!0),S=Math.max(S,T.level||0)),null}function U(L){return L.sort((T,w)=>{const _=T.level||0,N=w.level||0;if(_!==N)return _-N;if(T.parentPath!==w.parentPath)return T.parentPath?w.parentPath?T.parentPath.localeCompare(w.parentPath):1:-1;if(d&&T.data&&w.data){const I=he(T.data,d)??0,H=he(w.data,d)??0;if(I!==H)return I-H}return h?h(T).localeCompare(h(w)):T.path.localeCompare(w.path)})}return V}function go(o,e){const t=new Map,i=new Map,s=new Set,r=l=>String(e(l.data)),n=l=>{t.set(r(l),l);const c=[];for(const h of Object.values(l.children))c.push(...n(h));let d;return c.length>0?d=c:l.isSelectable!==!1?(d=[r(l)],s.add(l.path)):d=[],i.set(l.path,d),d},a=o.tree;for(const l of a)n(l);return{nodeByValue:t,atomsUnder:i,atomPaths:s,roots:a}}function kt(o,e,t){const i=o.atomsUnder.get(e.path);if(!i||i.length===0)return"unchecked";let s=0;for(const r of i)t.has(r)&&s++;return s===0?"unchecked":s===i.length?"checked":"indeterminate"}function Ke(o,e){const t=new Set;for(const i of e){const s=o.nodeByValue.get(String(i));if(s)for(const r of o.atomsUnder.get(s.path)??[])t.add(r)}return t}function Li(o,e,t){const i=o.atomsUnder.get(e.path)??[],s=new Set(t),r=kt(o,e,t),n=[],a=[];if(r==="checked")for(const l of i)s.delete(l)&&a.push(l);else for(const l of i)s.has(l)||(s.add(l),n.push(l));return{checkedAtoms:s,addedAtoms:n,removedAtoms:a}}function Ct(o,e,t,i){const s=a=>String(i(a.data)),r=[],n=a=>{const l=kt(o,a,e);if(l==="unchecked")return;const c=a.isSelectable!==!1,d=Object.values(a.children);if(t==="leaves"){o.atomPaths.has(a.path)&&l==="checked"&&r.push(s(a));for(const h of d)n(h);return}if(t==="all"){l==="checked"&&c&&r.push(s(a));for(const h of d)n(h);return}if(l==="checked"&&c){r.push(s(a));return}for(const h of d)n(h)};for(const a of o.roots)n(a);return r}class bo{constructor(e,t={}){y(this,"element");y(this,"instanceId");y(this,"options");y(this,"isOpen",!1);y(this,"selectedValues",new Set);y(this,"selectedOptions",new Map);y(this,"allOptions",[]);y(this,"filteredOptions",[]);y(this,"tree",null);y(this,"treeNodes",[]);y(this,"cascadeIndex",null);y(this,"cascadeCheckedAtoms",new Set);y(this,"hiddenInputs",[]);y(this,"focusedIndex",-1);y(this,"matchingIndices",new Set);y(this,"searchTerm","");y(this,"isLoading",!1);y(this,"searchDebounceTimer");y(this,"searchAbortController");y(this,"showSelectedPopover",!1);y(this,"selectedPopoverPlacement",null);y(this,"dropdownPlacement",null);y(this,"isRTL",!1);y(this,"effectiveBadgesPosition","bottom");y(this,"justClosedViaClick",!1);y(this,"positioningDriftWarned",!1);y(this,"dropdownCleanup",null);y(this,"hintCleanup",null);y(this,"selectedPopoverCleanup",null);y(this,"tooltips",new Map);y(this,"onDropdownScroll",()=>this.hideOptionTooltips());y(this,"virtualScroll",null);y(this,"optionsContainer",null);y(this,"selectedPopoverVirtualScroll",null);y(this,"selectedPopoverContainer",null);y(this,"input");y(this,"dropdown");y(this,"dropdownInner");y(this,"badgesContainer");y(this,"counter");y(this,"hint");y(this,"selectedPopover");y(this,"documentKeydownHandler",null);y(this,"documentClickHandler",null);this.element=e,this.instanceId=`MS-${Math.random().toString(36).slice(2,11)}`,this.options={searchHint:e.dataset.searchHint||"",searchPlaceholder:e.dataset.searchPlaceholder||"Search...",selectPlaceholder:e.dataset.selectPlaceholder||"Pick an option...",noDataPlaceholder:e.dataset.noDataPlaceholder||void 0,dropdownMinWidth:e.dataset.dropdownMinWidth||void 0,dropdownMaxWidth:e.dataset.dropdownMaxWidth||void 0,badgesDisplayMode:e.dataset.badgesDisplayMode||"badges",badgesPosition:e.dataset.badgesPosition||"bottom",badgesThresholdMode:e.dataset.badgesThresholdMode||"count",maxHeight:e.dataset.maxHeight||"20rem",emptyMessage:e.dataset.emptyMessage||"No results found",loadingMessage:e.dataset.loadingMessage||"Loading...",searchInputMode:e.dataset.searchInputMode||"normal",searchMode:e.dataset.searchMode||"filter",badgesThreshold:e.dataset.badgesThreshold?parseInt(e.dataset.badgesThreshold):void 0,minSearchLength:parseInt(e.dataset.minSearchLength||"0")||0,searchDebounce:parseInt(e.dataset.searchDebounce||"0")||0,isMultipleEnabled:e.dataset.multiple!=="false",isGroupsAllowed:e.dataset.allowGroups!=="false",isCheckboxesShown:e.dataset.showCheckboxes!=="false",isActionsSticky:e.dataset.stickyActions!=="false",isCloseOnSelect:e.dataset.closeOnSelect==="true",isPlacementLocked:e.dataset.lockPlacement!=="false",isSearchEnabled:e.dataset.enableSearch!=="false",isAddNewAllowed:e.dataset.allowAddNew==="true",isCounterShown:e.dataset.showCounter==="true",isKeepOptionsOnSearch:e.dataset.keepOptionsOnSearch!=="false",shouldKeepSearchOnClose:e.dataset.keepSearchOnClose!=="false",options:[],container:void 0,...t},this.init()}extractField(e,t){if(Array.isArray(e)&&e.length===2){if(t.tupleSkip)return typeof t.fallback=="function"?t.fallback():t.fallback;if(t.tupleIndex!==void 0){const s=e[t.tupleIndex];return t.transform?t.transform(s):s}}if(t.member&&e[t.member]!==void 0){const s=e[t.member];return t.transform?t.transform(s):s}return t.callback?t.callback(e):typeof t.fallback=="function"?t.fallback():t.fallback}getItemValue(e){return this.extractField(e,{tupleIndex:0,member:this.options.valueMember,callback:this.options.getValueCallback,fallback:"[N/A]"})}getItemDisplayValue(e){return this.extractField(e,{tupleIndex:1,member:this.options.displayValueMember,callback:this.options.getDisplayValueCallback,transform:String,fallback:"[N/A]"})}getItemBadgeDisplayValue(e){if(this.options.getBadgeDisplayCallback)return this.options.getBadgeDisplayCallback(e);if(this.options.isBadgeFullTitleShown){const t=this.getItemFullTitle(e);if(t)return t}return this.getItemDisplayValue(e)}getItemFullTitle(e){return this.extractField(e,{tupleSkip:!0,member:this.options.fullTitleMember,callback:this.options.getFullTitleCallback,transform:String,fallback:void 0})}getItemSearchValue(e){return this.extractField(e,{member:this.options.searchValueMember,callback:this.options.getSearchValueCallback,transform:String,fallback:()=>this.getItemDisplayValue(e)})}getItemIcon(e){return this.extractField(e,{tupleSkip:!0,member:this.options.iconMember,callback:this.options.getIconCallback,transform:String,fallback:void 0})}getItemSubtitle(e){return this.extractField(e,{tupleSkip:!0,member:this.options.subtitleMember,callback:this.options.getSubtitleCallback,transform:String,fallback:void 0})}getItemGroup(e){return this.extractField(e,{tupleSkip:!0,member:this.options.groupMember,callback:this.options.getGroupCallback,transform:String,fallback:void 0})}getItemDisabled(e){return this.extractField(e,{tupleSkip:!0,member:this.options.disabledMember,callback:this.options.getDisabledCallback,transform:Boolean,fallback:!1})}isIndexSelectable(e){if(!this.isTreeMode())return!0;const t=this.treeNodes[e];return t?t.isSelectable!==!1:!0}isOptionSelectable(e){if(!this.isTreeMode())return!0;const t=this.filteredOptions.indexOf(e);if(t>=0)return this.isIndexSelectable(t);const i=String(this.getItemValue(e)),s=this.treeNodes.find(r=>String(this.getItemValue(r.data))===i);return s?s.isSelectable!==!1:!0}init(){this.parseOptions(),this.buildHTML(),this.attachEvents(),this.parseInitialSelection(),Re.debug(`Initialized [${this.instanceId}] with options:`,{placeholder:this.options.searchPlaceholder,totalOptions:this.allOptions.length,isCloseOnSelect:this.options.isCloseOnSelect,dataAttribute:this.element.dataset.closeOnSelect})}parseOptions(){const e=this.element.dataset.options;if(e)try{this.allOptions=JSON.parse(e)}catch(t){j.error(`[${this.instanceId}] Failed to parse data-options:`,t),this.allOptions=[]}else this.options.options&&(this.allOptions=this.options.options);this.filteredOptions=[...this.allOptions],this.isTreeMode()&&this.buildTree()}isTreeMode(){return this.options.isTreeEnabled===!1?!1:!!(this.options.isTreeEnabled||this.options.pathMember||this.options.getPathCallback)}buildTree(){this.tree=Ai({idMember:this.options.valueMember,pathMember:this.options.pathMember,getPathCallback:this.options.getPathCallback,parentPathMember:this.options.parentPathMember,levelMember:this.options.levelMember,hasChildrenMember:this.options.hasChildrenMember,isSelectableMember:this.options.isSelectableMember,getIsSelectableCallback:this.options.getIsSelectableCallback,treePathSeparator:this.options.treePathSeparator,treeId:this.instanceId,getDisplayValueCallback:e=>this.getItemDisplayValue(e.data)}),this.tree.insertArray(this.allOptions),this.cascadeIndex=this.isCascadeMode()?go(this.tree,e=>String(this.getItemValue(e))):null,this.rebuildTreeVisible()}isCascadeMode(){return this.isTreeMode()&&this.options.isMultipleEnabled!==!1&&this.options.checkboxMode==="cascade"}cascadePolicy(){return this.options.cascadeSelectPolicy??"rolled-up"}refreshCascadeAtoms(){this.isCascadeMode()&&this.cascadeIndex&&(this.cascadeCheckedAtoms=Ke(this.cascadeIndex,this.selectedValues))}toggleTreeCascade(e){const t=this.cascadeIndex,i=Ke(t,this.selectedValues),{checkedAtoms:s}=Li(t,e,i);this.commitCascadeAtoms(s)}commitCascadeAtoms(e){var l;const t=this.cascadeIndex,i=Ct(t,e,this.cascadePolicy(),c=>String(this.getItemValue(c))),s=new Set(i),r=[],n=[];for(const[c,d]of this.selectedOptions)s.has(c)||n.push(d);const a=new Map;for(const c of i){const h=((l=t.nodeByValue.get(c))==null?void 0:l.data)??this.selectedOptions.get(c);h!==void 0&&(a.set(c,h),this.selectedValues.has(c)||r.push(h))}this.selectedValues=s,this.selectedOptions=a,this.cascadeCheckedAtoms=e,this.commit({added:r,removed:n})}counterSelection(){if(this.isCascadeMode()&&this.cascadeIndex){const e=Ct(this.cascadeIndex,this.cascadeCheckedAtoms,"rolled-up",i=>String(this.getItemValue(i))),t=[];for(const i of e){const s=this.cascadeIndex.nodeByValue.get(i),r=(s==null?void 0:s.data)??this.selectedOptions.get(i);r!==void 0&&t.push(r)}return t}return Array.from(this.selectedOptions.values())}buildCounterTooltip(e){const i=e.slice(0,12).map(s=>this.getItemBadgeDisplayValue(s));return e.length>12&&i.push(`…and ${e.length-12} more`),i.join(`
2
- `)}rebuildTreeVisible(){if(!this.tree){this.treeNodes=[];return}const e=this.tree.flatNodes,t=this.options.isSearchEnabled?(this.searchTerm||"").trim().toLowerCase():"";let i;if(!t)i=e;else{const s=this.tree.treePathSeparator,r=new Set;for(const n of e)if(this.getItemSearchValue(n.data).toLowerCase().includes(t)){const l=n.path.split(s);for(let c=1;c<=l.length;c++)r.add(l.slice(0,c).join(s))}i=e.filter(n=>r.has(n.path))}this.treeNodes=i,this.filteredOptions=i.map(s=>s.data)}resetVisibleToAll(){this.isTreeMode()?this.rebuildTreeVisible():this.filteredOptions=[...this.allOptions]}rebuildTreeVisibleFromMatches(e){if(!this.tree){this.treeNodes=[],this.filteredOptions=[];return}const t=this.tree.flatNodes,i=this.tree.treePathSeparator,s=new Set((e||[]).map(a=>String(this.getItemValue(a)))),r=new Set;for(const a of t)if(s.has(String(this.getItemValue(a.data)))){const l=a.path.split(i);for(let c=1;c<=l.length;c++)r.add(l.slice(0,c).join(i))}const n=t.filter(a=>r.has(a.path));this.treeNodes=n,this.filteredOptions=n.map(a=>a.data)}buildHTML(){const e=this.options.container||document.body,t=this.element.getRootNode(),i=t instanceof ShadowRoot?t.host:this.element,s=i.getAttribute("dir")==="rtl",r=i.closest('[dir="rtl"]')!==null;this.isRTL=s||r,Re.debug(`[${this.instanceId}] RTL Debug:`,{isShadowRoot:t instanceof ShadowRoot,hostElement:i,elementDir:i.getAttribute("dir"),hasElementDir:s,hasAncestorDir:r,isRTL:this.isRTL}),this.effectiveBadgesPosition=this.options.badgesPosition||"bottom",this.isRTL&&(this.effectiveBadgesPosition==="left"?this.effectiveBadgesPosition="right":this.effectiveBadgesPosition==="right"&&(this.effectiveBadgesPosition="left")),this.element.classList.add("ms"),this.isRTL&&(this.element.classList.add("ms--rtl"),Re.debug(`[${this.instanceId}] Added ms--rtl class to element`)),(!this.options.isCheckboxesShown||!this.options.isMultipleEnabled)&&this.element.classList.add("ms--no-checkboxes");const n=document.createElement("div");n.className="ms__input-wrapper",this.input=document.createElement("input"),this.input.type="text",this.input.className="ms__input",this.input.placeholder=this.getPlaceholderText(),this.input.autocomplete="off",this.options.searchInputMode==="readonly"?this.input.readOnly=!0:this.options.searchInputMode==="hidden"&&(this.input.style.display="none");const a=document.createElement("span");a.className="ms__toggle",a.innerHTML="▼",this.counter=document.createElement("span"),this.counter.className="ms__counter",this.counter.style.display="none",n.appendChild(this.input),n.appendChild(this.counter),n.appendChild(a),this.badgesContainer=document.createElement("div"),this.badgesContainer.className="ms__badges";const l=document.createElement("div");l.className="ms__wrapper",(this.effectiveBadgesPosition==="left"||this.effectiveBadgesPosition==="right")&&l.classList.add("ms__wrapper--inline"),l.appendChild(n),l.appendChild(this.badgesContainer),this.element.appendChild(l),this.dropdown=document.createElement("div"),this.dropdown.className="ms__dropdown",this.dropdownInner=document.createElement("div"),this.dropdownInner.className="ms__dropdown-inner",this.dropdown.appendChild(this.dropdownInner),e.appendChild(this.dropdown),this.options.searchHint&&(this.hint=document.createElement("div"),this.hint.className="ms__hint",this.hint.textContent=this.options.searchHint,e.appendChild(this.hint)),this.selectedPopover=document.createElement("div"),this.selectedPopover.className="ms__selected-popover",e.appendChild(this.selectedPopover),this.renderDropdown()}shouldUseVirtualScroll(){if(!this.options.isVirtualScrollEnabled||this.options.isGroupsAllowed&&this.hasGroups())return!1;const e=this.options.virtualScrollThreshold??100;return this.filteredOptions.length>=e}hasGroups(){return this.filteredOptions.some(e=>{const t=this.getItemGroup(e);return t&&t.trim()!==""})}renderDropdown(){if(this.destroyAllActionButtonTooltips(),this.refreshCascadeAtoms(),this.shouldUseVirtualScroll()){this.dropdown.classList.add("ms__dropdown--virtual"),this.renderDropdownVirtual();return}this.dropdown.classList.remove("ms__dropdown--virtual"),this.virtualScroll&&(this.virtualScroll.destroy(),this.virtualScroll=null,this.optionsContainer=null);let e="";if(this.isLoading){e+='<div class="ms__loader">',e+='<div class="pa-loader pa-loader--sm"></div>',e+=`<div class="ms__loading-text">${this.options.loadingMessage}</div>`,e+="</div>",this.dropdownInner.innerHTML=e;return}const t=this.renderActionsHTML(),i=this.options.actionsPosition==="bottom";if(i||(e+=t),this.options.isVirtualScrollEnabled){const s=this.options.optionHeight??50;e+=`<div class="ms__options ms__options--fixed-height" style="--ms-option-height: ${s}px;">`}else e+='<div class="ms__options">';if(this.filteredOptions.length===0)e+=`<div class="ms__empty">${this.options.emptyMessage}</div>`;else if(this.isTreeMode())this.treeNodes.forEach((s,r)=>{e+=this.renderTreeNode(s,r)});else if(this.options.isGroupsAllowed){const s=this.groupOptions(this.filteredOptions),r=new Map;this.filteredOptions.forEach((n,a)=>r.set(n,a)),Object.keys(s).forEach(n=>{if(e+='<div class="ms__group">',n!=="__ungrouped__")if(this.options.renderGroupLabelContentCallback){const a=this.options.renderGroupLabelContentCallback(n);if(a instanceof HTMLElement){const l=document.createElement("div");l.className="ms__group-label",l.appendChild(a),e+=l.outerHTML}else e+=`<div class="ms__group-label">${a}</div>`}else e+=`<div class="ms__group-label">${n}</div>`;s[n].forEach(a=>{e+=this.renderOption(a,r.get(a)??-1)}),e+="</div>"})}else this.filteredOptions.forEach((s,r)=>{e+=this.renderOption(s,r)});e+="</div>",i&&(e+=t),this.dropdownInner.innerHTML=e,this.attachActionButtonTooltips(),this.attachOptionTooltips()}renderDropdownVirtual(){if(this.destroyAllActionButtonTooltips(),!this.virtualScroll){let i="";const s=this.renderActionsHTML(),r=this.options.actionsPosition==="bottom";r||(i+=s);const n=this.options.maxHeight||"20rem",a=this.options.optionHeight??50;i+=`<div class="ms__options ms__options--virtual" style="height: ${n}; max-height: ${n}; overflow-y: auto; position: relative; --ms-option-height: ${a}px;"></div>`,r&&(i+=s),this.dropdownInner.innerHTML=i,this.optionsContainer=this.dropdownInner.querySelector(".ms__options")}if(this.filteredOptions.length===0){this.virtualScroll&&(this.virtualScroll.destroy(),this.virtualScroll=null),this.optionsContainer.innerHTML=`<div class="ms__empty">${this.options.emptyMessage}</div>`;return}const e=this.options.optionHeight??50,t=this.options.virtualScrollBuffer??10;requestAnimationFrame(()=>{this.optionsContainer&&(this.virtualScroll?this.virtualScroll.setItems(this.filteredOptions):this.virtualScroll=new po({container:this.optionsContainer,itemHeight:e,items:this.filteredOptions,renderItem:(i,s)=>this.isTreeMode()?this.renderTreeNode(this.treeNodes[s],s):this.renderOption(i,s),bufferSize:t,onVisibleRangeChange:()=>{this.attachOptionTooltips()}}),this.attachActionButtonTooltips())})}getBuiltInActionDisabled(e){return e==="select-all"?!this.filteredOptions.some(t=>!this.getItemDisabled(t)&&!this.selectedValues.has(String(this.getItemValue(t)))):e==="clear-all"?this.selectedValues.size===0:!1}renderActionsHTML(){const e=this.options.actionButtons;if(!this.options.isMultipleEnabled||!e||e.length===0)return"";const t=this.options.actionsPosition==="bottom"?"bottom":"top",i=this.options.actionsAlign??"stretch",s=` ms__actions--${t}`,r=this.options.isActionsSticky?" ms__actions--sticky":"",n=this.options.actionsLayout==="wrap"?" ms__actions--wrap":"",a=` ms__actions--align-${i}`,l=new Map;if(e.forEach((d,h)=>{if(!(d.getIsVisibleCallback?d.getIsVisibleCallback(this):d.isVisible??!0))return;let m;d.getIsDisabledCallback?m=d.getIsDisabledCallback(this):d.isDisabled!==void 0?m=d.isDisabled:m=this.getBuiltInActionDisabled(d.action);const b=m?" disabled":"",u=d.getTextCallback?d.getTextCallback(this):d.text;let v="";if(d.getClassCallback){const S=d.getClassCallback(this);v=Array.isArray(S)?` ${S.join(" ")}`:S?` ${S}`:""}else d.cssClass&&(v=` ${d.cssClass}`);const p=Math.max(1,Math.floor(d.row??1)),x=`<button type="button"${b} class="ms__action-btn${v}" data-action="${d.action}" data-button-index="${h}">${u}</button>`;l.has(p)||l.set(p,[]),l.get(p).push(x)}),l.size===0)return"";const c=Array.from(l.keys()).sort((d,h)=>d-h).map(d=>`<div class="ms__actions-row" data-row="${d}">${l.get(d).join("")}</div>`).join("");return`<div class="ms__actions${s}${r}${n}${a}">${c}</div>`}renderOption(e,t){const i=this.getItemValue(e),s=this.getItemDisplayValue(e),r=this.getItemIcon(e),n=this.getItemSubtitle(e),a=this.getItemDisabled(e),l=this.selectedValues.has(String(i)),c=t===this.focusedIndex,d=this.matchingIndices.has(t),h=["ms__option"];l&&h.push("ms__option--selected"),c&&h.push("ms__option--focused"),d&&h.push("ms__option--matched"),a&&h.push("ms__option--disabled");const g=this.options.checkboxAlign&&this.options.checkboxAlign!=="center"?` data-checkbox-align="${this.options.checkboxAlign}"`:"";let m=`<div class="${h.join(" ")}" data-value="${i}" data-index="${t}"${g}>`;if(this.options.isCheckboxesShown&&this.options.isMultipleEnabled&&(m+=`<input type="checkbox" class="ms__checkbox" ${l?"checked":""} ${a?"disabled":""}>`),m+='<div class="ms__option-content">',this.options.renderOptionContentCallback){const b={index:t,isSelected:l,isFocused:c,isMatched:d,isDisabled:a,isTreeNode:!1},u=this.options.renderOptionContentCallback(e,b);typeof u=="string"?m+=u:m+=u.outerHTML}else r&&(m+=`<span class="ms__option-icon">${r}</span>`),m+='<div class="ms__option-text">',m+=`<div class="ms__option-title">${this.highlightMatch(s,this.searchTerm)}</div>`,n&&(m+=`<div class="ms__option-subtitle">${n}</div>`),m+="</div>";return m+="</div>",m+="</div>",m}renderTreeNode(e,t){const i=e.data,s=this.getItemValue(i),r=this.getItemDisplayValue(i),n=this.getItemIcon(i),a=this.getItemSubtitle(i),l=this.getItemDisabled(i),c=this.isCascadeMode()&&this.cascadeIndex,d=c?kt(this.cascadeIndex,e,this.cascadeCheckedAtoms):null,h=c?d==="checked":this.selectedValues.has(String(s)),g=d==="indeterminate",m=t===this.focusedIndex,b=e.isSelectable!==!1,u=e.level??1,v=Math.max(0,u-1),p=["ms__option","ms__option--tree"];p.push(e.hasChildren?"ms__option--tree-branch":"ms__option--tree-leaf"),h&&p.push("ms__option--selected"),g&&p.push("ms__option--indeterminate"),m&&p.push("ms__option--focused"),l&&p.push("ms__option--disabled"),b||p.push("ms__option--tree-unselectable");const x=this.options.checkboxAlign&&this.options.checkboxAlign!=="center"?` data-checkbox-align="${this.options.checkboxAlign}"`:"",S=b?"":' data-selectable="false"';let k=`<div class="${p.join(" ")}" data-value="${s}" data-index="${t}" data-path="${e.path}" data-level="${u}" style="--ms-tree-depth: ${v};"${x}${S}>`;if(this.options.isCheckboxesShown&&this.options.isMultipleEnabled&&b&&(k+=`<input type="checkbox" class="${g?"ms__checkbox ms__checkbox--indeterminate":"ms__checkbox"}" ${h?"checked":""}${g?' aria-checked="mixed"':""} ${l?"disabled":""}>`),k+='<div class="ms__option-content">',this.options.renderOptionContentCallback){const E={index:t,isSelected:h,isFocused:m,isMatched:!1,isDisabled:l,isTreeNode:!0,isBranch:e.hasChildren,isLeaf:!e.hasChildren,childCount:Object.keys(e.children).length,level:u,depth:v,path:e.path,isSelectable:b,isIndeterminate:g},V=this.options.renderOptionContentCallback(i,E);k+=typeof V=="string"?V:V.outerHTML}else n&&(k+=`<span class="ms__option-icon">${n}</span>`),k+='<div class="ms__option-text">',k+=`<div class="ms__option-title">${this.highlightMatch(r,this.searchTerm)}</div>`,a&&(k+=`<div class="ms__option-subtitle">${a}</div>`),k+="</div>";return k+="</div>",k+="</div>",k}highlightMatch(e,t){if(!t)return e;const i=new RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return e.replace(i,"<mark>$1</mark>")}groupOptions(e){const t={};return e.forEach(i=>{const s=this.getItemGroup(i)||"__ungrouped__";t[s]||(t[s]=[]),t[s].push(i)}),t}get isSearchUsable(){return!!this.options.isSearchEnabled&&this.options.searchInputMode!=="readonly"&&this.options.searchInputMode!=="hidden"}getPlaceholderText(){return this.options.noDataPlaceholder&&this.allOptions.length===0?this.options.noDataPlaceholder:this.isSearchUsable?this.options.searchPlaceholder:this.options.selectPlaceholder||this.options.searchPlaceholder}renderBadges(){this.destroyAllBadgeTooltips();const e=Array.from(this.selectedOptions.values()),t=this.selectedValues.size;if(!this.options.isMultipleEnabled){this.badgesContainer.innerHTML="",this.counter.style.display="none";let r;e[0]&&(this.options.renderSelectedContentCallback?r=this.options.renderSelectedContentCallback(e[0]):r=this.getItemDisplayValue(e[0])),!this.isOpen&&t>0&&e.length>0?this.input.value=r:this.isOpen||(this.input.value="");return}let i=this.options.badgesDisplayMode;if(this.options.badgesThreshold!==null&&t>this.options.badgesThreshold&&i!=="none"&&(i=this.options.badgesThresholdMode||"count"),!this.isOpen)if(t>0&&i==="count"){const r=this.options.getCounterCallback?this.options.getCounterCallback(t):`${t} selected`;this.input.placeholder=r}else this.input.placeholder=this.getPlaceholderText();if(this.options.isCounterShown&&t>0){const r=this.counterSelection(),n=r.length;this.counter.textContent=`[${n}]`,this.counter.title=this.buildCounterTooltip(r),this.counter.style.display=n>0?"":"none"}else this.counter.title="",this.counter.style.display="none";if(i==="none"){this.badgesContainer.innerHTML="";return}if(i==="badges")this.badgesContainer.className=`ms__badges ms__badges--${this.effectiveBadgesPosition}`,this.badgesContainer.innerHTML=e.map(r=>this.renderBadgeHTML(r,{displayMode:"badges",isInPopover:!1})).join("");else if(i==="partial"){this.badgesContainer.className=`ms__badges ms__badges--${this.effectiveBadgesPosition}`;const r=this.options.badgesMaxVisible||3,n=e.slice(0,r),a=t-r,l=n.map(d=>this.renderBadgeHTML(d,{displayMode:"partial",isInPopover:!1})).join("");let c="";a>0&&(c=`
1
+ (function(O,P){typeof exports=="object"&&typeof module<"u"?P(exports):typeof define=="function"&&define.amd?define(["exports"],P):(O=typeof globalThis<"u"?globalThis:O||self,P(O.MultiSelect={}))})(this,function(O){"use strict";var Wi=Object.defineProperty;var To=O=>{throw TypeError(O)};var ji=(O,P,D)=>P in O?Wi(O,P,{enumerable:!0,configurable:!0,writable:!0,value:D}):O[P]=D;var y=(O,P,D)=>ji(O,typeof P!="symbol"?P+"":P,D),St=(O,P,D)=>P.has(O)||To("Cannot "+D);var f=(O,P,D)=>(St(O,P,"read from private field"),D?D.call(O):P.get(O)),R=(O,P,D)=>P.has(O)?To("Cannot add the same private member more than once"):P instanceof WeakSet?P.add(O):P.set(O,D),B=(O,P,D,$)=>(St(O,P,"write to private field"),$?$.call(O,D):P.set(O,D),D),C=(O,P,D)=>(St(O,P,"access private method"),D);var pe,Fe,Me,We,we,je,lt,xe,me,_e,Ae,Le,Ee,$e,ct,ae,Ve,A,Io,Oo,Po,Q,Mo,Ao,Tt,It,Je,Ot,Lo,X,K,ue,Ge,Ue,qe,De,ze,ke,M,Pt,Mt,Eo,$o,Vo,dt,At,Do,zo,No,Lt,Ro,Bo,Et,$t;function P(o,e={}){const t=new Set(o),i=e.shouldNullOnInvalid?null:e.default??null;return{values:o,fromAttribute(s){return s===null?e.default??i:t.has(s)?s:i},validate(s){return typeof s=="string"&&t.has(s)},toAttribute(s){return s==null?null:String(s)}}}function D(o={}){const e=i=>(o.min==null||i>=o.min)&&(o.max==null||i<=o.max),t=o.default;return{fromAttribute(i){if(i===null)return t;const s=Number.parseInt(i,10);return Number.isNaN(s)||!e(s)?t:s},validate(i){return typeof i=="number"&&Number.isInteger(i)&&e(i)},toAttribute(i){return i==null?null:String(i)}}}function $(o={}){const e=o.isNullable===!0,t=o.default??(e?null:""),i=s=>o.shouldTrim?s.trim():s;return{fromAttribute(s){if(s===null)return t;const r=i(s);return!o.isEmptyAllowed&&r===""?t:r},validate(s){return s===null?e:typeof s=="string"&&(o.isEmptyAllowed===!0||s!=="")},toAttribute(s){return s==null?null:String(s)}}}const Ko=new Set(["","true","1","yes","on"]),Ho=new Set(["false","0","no","off"]);function W(o="presence"){const e=t=>{const i=t.trim().toLowerCase();return Ko.has(i)?!0:Ho.has(i)?!1:null};return{fromAttribute(t){switch(o){case"presence":return t!==null;case"default-true":return t===null?!0:e(t)??!0;case"default-false":return t===null?!1:e(t)??!1;case"tristate":return t===null?null:e(t)}},validate(t){return o==="tristate"?t===!0||t===!1||t===null:typeof t=="boolean"},toAttribute(t){return o==="presence"?t?"":null:t==null?null:String(t)}}}function Fo(o={}){const e=o.default;return{fromAttribute(t){if(t===null||t.trim()==="")return e;let i;try{i=JSON.parse(t)}catch{return e}return o.validate&&!o.validate(i)?e:i},validate:o.validate,toAttribute(t){return t==null?null:JSON.stringify(t)}}}function Wo(o={}){const e=o.default??[],t=i=>Array.isArray(i)&&(!o.validateItem||i.every(o.validateItem));return{fromAttribute(i){if(i===null||i.trim()==="")return e;let s;try{s=JSON.parse(i)}catch{return e}return t(s)?s:e},validate:t,toAttribute(i){return Array.isArray(i)?JSON.stringify(i):null}}}function jo(){return{validate(o){return o==null||typeof o=="function"}}}function Go(o,e,t){const i=o.converter,s=i!=null&&i.fromAttribute?i.fromAttribute(e,t,o.attribute??o.configKey):e??o.default;return{configKey:o.configKey,field:o.field,value:s,on:o.on??"update"}}function Uo(o,e){const t=o.converter;return t!=null&&t.validate&&!t.validate(e)?null:{configKey:o.configKey,field:o.field,value:e,on:o.on??"update"}}function qo(){const o=new Set;let e=!1;const t=()=>{e=!1;const i=[...o];o.clear();for(const s of i)s()};return{schedule(i){o.add(i),e||(e=!0,queueMicrotask(t))},flush(){if(o.size===0)return;e=!1;const i=[...o];o.clear();for(const s of i)s()},cancel(){o.clear(),e=!1}}}const Xe=new Map;function Jo(o,e){let t=Xe.get(o);t||Xe.set(o,t=new Set),t.add(e)}function Xo(o,e){var t;(t=Xe.get(o))==null||t.delete(e)}function Yo(o){return Array.from(Xe.get(o)??[])}const Vt=new Map;function Qo(o,e){Vt.set(o.toLowerCase(),e)}function Zo(o){return Vt.get(o.toLowerCase())}function es(o,e,t,i={}){return o.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:i.bubbles??!0,composed:i.composed??!0,cancelable:i.cancelable??!1}))}function ts(o){return o.split(/[-_]/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join("")}function os(o){return`on${ts(o)}`}function ss(o){return o?o.map(e=>{const t=typeof e=="string"?{name:e}:e,i=t.property===!1?null:t.property??os(t.name);return{name:t.name,property:i,bubbles:t.bubbles,composed:t.composed,cancelable:t.cancelable}}):[]}const is=typeof HTMLElement<"u"?HTMLElement:class{},Dt=new WeakSet;let rs=0;const ns={trace(){},debug(){},info(){},warn(){},error(){}},as=new Proxy({},{get:()=>ns});class ht extends is{constructor(){super();R(this,A);R(this,pe,{});R(this,Fe,new Map);R(this,Me,new Map);R(this,We,new Map);R(this,we,new Map);R(this,je,qo());R(this,lt,()=>C(this,A,Ot).call(this));R(this,xe,null);R(this,me,!1);R(this,_e,[]);R(this,Ae,!1);R(this,Le,null);R(this,Ee,!1);R(this,$e);R(this,ct);R(this,ae);R(this,Ve);const t=this.constructor,i=t.inputs??[],s=ss(t.events);C(this,A,Po).call(this,i,s);for(const r of i)f(this,Fe).set(r.configKey,r),r.attribute&&f(this,Me).set(r.attribute,r);for(const r of s)f(this,We).set(r.name,r);C(this,A,Io).call(this,i),C(this,A,Mo).call(this,i),C(this,A,Ao).call(this,s)}static get observedAttributes(){return(this.inputs??[]).filter(t=>t.attribute).map(t=>t.attribute)}attributeChangedCallback(t,i,s){var a;if(f(this,Ee))return;const r=f(this,Me).get(t);if(!r||!f(this,Ae)&&((a=f(this,Le))!=null&&a.has(r.configKey)))return;let n;try{n=Go(r,s,this)}catch(l){C(this,A,Q).call(this,`converter for "${r.configKey}" threw parsing attribute ${t}="${s}"; using default`,l),n=C(this,A,Oo).call(this,r)}C(this,A,It).call(this,n)}connectedCallback(){Jo(this.localName,this),f(this,Ae)||(B(this,Ae,!0),B(this,Le,null),B(this,me,!0)),C(this,A,Je).call(this),this.connect()}disconnectedCallback(){Xo(this.localName,this),this.disconnect()}setAttributes(t){for(const[i,s]of Object.entries(t)){const r=f(this,Fe).get(i)??f(this,Me).get(i);r&&C(this,A,Tt).call(this,r,s)}C(this,A,Je).call(this)}batch(t){t(),C(this,A,Je).call(this)}flush(){C(this,A,Je).call(this)}whenSettled(){return!f(this,xe)&&!f(this,me)?Promise.resolve():new Promise(t=>f(this,_e).push(t))}get config(){return f(this,pe)}get log(){if(f(this,Ve))return f(this,Ve);const t=Zo(this.localName);if(!t)return as;const i=f(this,ct)??B(this,ct,`${this.localName}#${this.id||++rs}`);return B(this,Ve,t.forInstance(i,()=>f(this,ae)))}enableLogging(t="debug"){B(this,ae,t)}disableLogging(){B(this,ae,void 0)}get isLoggingEnabled(){return f(this,ae)!=null&&f(this,ae)!=="silent"&&f(this,ae)!==5}reinit(){}update(t){}connect(){}disconnect(){}get internals(){if(f(this,$e))return f(this,$e);if(typeof this.attachInternals!="function")return null;try{return B(this,$e,this.attachInternals())}catch{return null}}get form(){var t;return((t=this.internals)==null?void 0:t.form)??null}emit(t,i,s){const r=f(this,We).get(t);return es(this,t,i,{bubbles:(s==null?void 0:s.bubbles)??(r==null?void 0:r.bubbles),composed:(s==null?void 0:s.composed)??(r==null?void 0:r.composed),cancelable:(s==null?void 0:s.cancelable)??(r==null?void 0:r.cancelable)})}on(t,i,s){const r=i;return this.addEventListener(t,r,s),()=>this.removeEventListener(t,r,s)}async runHook(t,i,s){const r=f(this,pe)[t];if(typeof r!="function")return s.whenUnset;try{return await Promise.resolve(r(i))}catch(n){if(s.onError)return s.onError(n);throw n}}}pe=new WeakMap,Fe=new WeakMap,Me=new WeakMap,We=new WeakMap,we=new WeakMap,je=new WeakMap,lt=new WeakMap,xe=new WeakMap,me=new WeakMap,_e=new WeakMap,Ae=new WeakMap,Le=new WeakMap,Ee=new WeakMap,$e=new WeakMap,ct=new WeakMap,ae=new WeakMap,Ve=new WeakMap,A=new WeakSet,Io=function(t){var i;for(const s of t){let r=s.default;if((i=s.converter)!=null&&i.fromAttribute)try{r=s.converter.fromAttribute(null,this,s.attribute??s.configKey)}catch(n){C(this,A,Q).call(this,`converter for "${s.configKey}" threw computing its default; using \`default\``,n),r=s.default}f(this,pe)[s.configKey]=r,s.field&&(this[s.field]=r)}},Oo=function(t){return{configKey:t.configKey,field:t.field,value:t.default,on:t.on??"update"}},Po=function(t,i){var l;const s=this.constructor;if(Dt.has(s))return;Dt.add(s);const r=new Set,n=new Set;for(const c of t)r.has(c.configKey)&&C(this,A,Q).call(this,`invalid input table: duplicate configKey "${c.configKey}"`),r.add(c.configKey),c.attribute&&(n.has(c.attribute)&&C(this,A,Q).call(this,`invalid input table: duplicate attribute "${c.attribute}"`),n.add(c.attribute)),c.reflect&&!c.attribute&&C(this,A,Q).call(this,`invalid input table: "${c.configKey}" has reflect:true but no attribute to reflect to`),c.reflect&&!((l=c.converter)!=null&&l.toAttribute)&&C(this,A,Q).call(this,`invalid input table: "${c.configKey}" has reflect:true but its converter has no toAttribute`);const a=new Set;for(const c of i)a.has(c.name)&&C(this,A,Q).call(this,`invalid event table: duplicate event "${c.name}"`),a.add(c.name),/^[a-z][a-z0-9-]*$/.test(c.name)||C(this,A,Q).call(this,`invalid event table: event "${c.name}" should be lowercase kebab-case (e.g. "date-select")`),c.property&&r.has(c.property)&&C(this,A,Q).call(this,`invalid event table: event "${c.name}" property "${c.property}" collides with an input configKey`)},Q=function(t,...i){console.warn(`[BlissElement] <${this.localName??"unknown"}> ${t}`,...i)},Mo=function(t){for(const i of t){const s=i.configKey,r=Object.prototype.hasOwnProperty.call(this,s),n=r?this[s]:void 0;r&&delete this[s],Object.defineProperty(this,s,{configurable:!0,enumerable:!0,get:()=>f(this,pe)[s],set:a=>C(this,A,Tt).call(this,i,a)}),r&&((f(this,Le)??B(this,Le,new Set)).add(s),this[s]=n)}},Ao=function(t){for(const i of t){const s=i.property;if(!s)continue;const r=i.name,n=Object.prototype.hasOwnProperty.call(this,s),a=n?this[s]:void 0;n&&delete this[s],Object.defineProperty(this,s,{configurable:!0,enumerable:!0,get:()=>f(this,we).get(r)??null,set:l=>{const c=f(this,we).get(r);if(c&&this.removeEventListener(r,c),typeof l=="function"){const d=l;f(this,we).set(r,d),this.addEventListener(r,d)}else f(this,we).delete(r)}}),n&&(this[s]=a)}},Tt=function(t,i){var r;const s=Uo(t,i);if(!s){C(this,A,Q).call(this,`rejected invalid value for property "${t.configKey}"; keeping previous value`,i);return}if(C(this,A,It).call(this,s),t.reflect&&t.attribute&&((r=t.converter)!=null&&r.toAttribute)){const n=t.converter.toAttribute(s.value);B(this,Ee,!0);try{n===null?this.removeAttribute(t.attribute):this.setAttribute(t.attribute,n)}finally{B(this,Ee,!1)}}},It=function(t){f(this,pe)[t.configKey]=t.value,t.field&&(this[t.field]=t.value),t.on!=="none"&&(t.on==="reinit"&&B(this,me,!0),(f(this,xe)??B(this,xe,{}))[t.configKey]=t.value,f(this,je).schedule(f(this,lt)))},Je=function(){f(this,je).cancel(),C(this,A,Ot).call(this)},Ot=function(){if(!this.isConnected)return;const t=f(this,me),i=f(this,xe);B(this,me,!1),B(this,xe,null),t?this.reinit():i&&Object.keys(i).length>0&&this.update(i),C(this,A,Lo).call(this)},Lo=function(){if(f(this,_e).length===0)return;const t=f(this,_e);B(this,_e,[]);for(const i of t)i()},y(ht,"inputs"),y(ht,"events");function zt(o,e,t){typeof customElements>"u"||customElements.get(o)||customElements.define(o,e,t)}function ls(o){return{enableLogging:e=>o.enableLogging(e),disableLogging:()=>o.disableLogging(),setLogLevel:e=>o.setLogLevel(e),setCategoryLevel:(e,t)=>o.setCategoryLevel(e,t),getCategories:()=>[...o.LOGGING_CATEGORIES]}}function cs(o,e,t){const{config:i,logging:s,shouldAutoDefine:r=!0}=t;s&&Qo(o,s);const n={version:()=>i.version,config:i,...s?{logging:ls(s)}:{},register:()=>zt(o,e),getInstances:()=>Yo(o)};return typeof window<"u"&&((window.components??(window.components={}))[o]=n),r&&zt(o,e),n}const Nt=new Map,Rt=new WeakMap;let Ye;function ds(o){if(typeof CSSStyleSheet>"u"||!("adoptedStyleSheets"in o))return!1;if(Ye===void 0)try{new CSSStyleSheet().replaceSync(""),Ye=!0}catch{Ye=!1}return Ye}function hs(o,...e){if(typeof document>"u")return;let t=Rt.get(o);t||Rt.set(o,t=new Set);const i=e.filter(r=>r&&!t.has(r));if(i.length===0)return;for(const r of i)t.add(r);if(ds(o)){const r=i.map(n=>{let a=Nt.get(n);return a||(a=new CSSStyleSheet,a.replaceSync(n),Nt.set(n,a)),a});o.adoptedStyleSheets=[...o.adoptedStyleSheets,...r];return}const s=o.head??o;for(const r of i){const n=document.createElement("style");n.textContent=r,s.appendChild(n)}}function ps(o,e={}){const t=e.position??"last",i=o.head??o;let s=null;const r=()=>typeof document>"u"?null:(s||(s=document.createElement("style"),e.className&&(s.className=e.className)),s.parentNode!==i&&(t==="first"&&i.firstChild?i.insertBefore(s,i.firstChild):i.appendChild(s)),s),n=()=>{s==null||s.remove()};return{set(a){if(!a){n();return}const l=r();l&&(l.textContent=a)},clear:n,destroy(){s==null||s.remove(),s=null}}}function Bt(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ms(o,e){const t=new Set,i=new RegExp(`var\\(\\s*(${Bt(e)}[a-z0-9-]+)`,"gi");let s;for(;s=i.exec(o);)s[1]&&t.add(s[1]);return t}function us(o,e){const t=new Set,i=new RegExp(`(${Bt(e)}[a-z0-9-]+)\\s*:`,"gi");let s;for(;s=i.exec(o);)s[1]&&t.add(s[1]);return[...t]}function fs(o,e,t={}){const i=t.minScore??3,s=t.limit??3,r=new Set(o.split("-").filter(Boolean));return[...e].map(n=>({k:n,score:n.split("-").filter(a=>r.has(a)).length})).filter(n=>n.score>=i).sort((n,a)=>a.score-n.score).slice(0,s).map(n=>n.k)}function gs(o,e){if(e.consumed.size===0)return[];const t=[];for(const i of us(o,e.prefix))e.consumed.has(i)||t.push({name:i,suggestions:fs(i,e.consumed,{minScore:e.minScore})});return t}var bs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Kt={exports:{}};(function(o){(function(e,t){o.exports?o.exports=t():e.log=t()})(bs,function(){var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],r={},n=null;function a(u,v){var p=u[v];if(typeof p.bind=="function")return p.bind(u);try{return Function.prototype.bind.call(p,u)}catch{return function(){return Function.prototype.apply.apply(p,[u,arguments])}}}function l(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(u){return u==="debug"&&(u="log"),typeof console===t?!1:u==="trace"&&i?l:console[u]!==void 0?a(console,u):console.log!==void 0?a(console,"log"):e}function d(){for(var u=this.getLevel(),v=0;v<s.length;v++){var p=s[v];this[p]=v<u?e:this.methodFactory(p,u,this.name)}if(this.log=this.debug,typeof console===t&&u<this.levels.SILENT)return"No console available for logging"}function h(u){return function(){typeof console!==t&&(d.call(this),this[u].apply(this,arguments))}}function g(u,v,p){return c(u)||h.apply(this,arguments)}function m(u,v){var p=this,x,S,k,E="loglevel";typeof u=="string"?E+=":"+u:typeof u=="symbol"&&(E=void 0);function V(w){var _=(s[w]||"silent").toUpperCase();if(!(typeof window===t||!E)){try{window.localStorage[E]=_;return}catch{}try{window.document.cookie=encodeURIComponent(E)+"="+_+";"}catch{}}}function F(){var w;if(!(typeof window===t||!E)){try{w=window.localStorage[E]}catch{}if(typeof w===t)try{var _=window.document.cookie,N=encodeURIComponent(E),I=_.indexOf(N+"=");I!==-1&&(w=/^([^;]+)/.exec(_.slice(I+N.length+1))[1])}catch{}return p.levels[w]===void 0&&(w=void 0),w}}function U(){if(!(typeof window===t||!E)){try{window.localStorage.removeItem(E)}catch{}try{window.document.cookie=encodeURIComponent(E)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function L(w){var _=w;if(typeof _=="string"&&p.levels[_.toUpperCase()]!==void 0&&(_=p.levels[_.toUpperCase()]),typeof _=="number"&&_>=0&&_<=p.levels.SILENT)return _;throw new TypeError("log.setLevel() called with invalid level: "+w)}p.name=u,p.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},p.methodFactory=v||g,p.getLevel=function(){return k??S??x},p.setLevel=function(w,_){return k=L(w),_!==!1&&V(k),d.call(p)},p.setDefaultLevel=function(w){S=L(w),F()||p.setLevel(w,!1)},p.resetLevel=function(){k=null,U(),d.call(p)},p.enableAll=function(w){p.setLevel(p.levels.TRACE,w)},p.disableAll=function(w){p.setLevel(p.levels.SILENT,w)},p.rebuild=function(){if(n!==p&&(x=L(n.getLevel())),d.call(p),n===p)for(var w in r)r[w].rebuild()},x=L(n?n.getLevel():"WARN");var T=F();T!=null&&(k=L(T)),d.call(p)}n=new m,n.getLogger=function(v){if(typeof v!="symbol"&&typeof v!="string"||v==="")throw new TypeError("You must supply a name when creating a logger.");var p=r[v];return p||(p=r[v]=new m(v,n.methodFactory)),p};var b=typeof window!==t?window.log:void 0;return n.noConflict=function(){return typeof window!==t&&window.log===n&&(window.log=b),n},n.getLoggers=function(){return r},n.default=n,n})})(Kt);var te=Kt.exports;const vs=["INIT","DATA","UI"],ys="debug",Ht=["#4c8bf5","#2ea043","#d29922","#a371f7","#db61a2","#e5534b","#3fb0ac","#8a6d3b"],Ft=new WeakSet;function ws(o,e,t){if(Ft.has(o))return;Ft.add(o);const i=o.methodFactory,s=`color:${t};font-weight:bold`;o.methodFactory=(r,n,a)=>{const l=i(r,n,a);return(...c)=>l(`%c[${e}]`,s,...c)},o.setLevel(o.getLevel(),!1)}function xs(o){return typeof o=="number"?o:te.levels[o.toUpperCase()]??te.levels.SILENT}const _s=[["trace",te.levels.TRACE,"debug"],["debug",te.levels.DEBUG,"debug"],["info",te.levels.INFO,"info"],["warn",te.levels.WARN,"warn"],["error",te.levels.ERROR,"error"]];function ks(o,e,t){const i=`color:${o.color};font-weight:bold`,s="color:#888",r={};for(const[n,a,l]of _s)r[n]=(...c)=>{const d=t(),h=Math.min(o.logger.getLevel(),d==null?te.levels.SILENT:xs(d));if(a<h)return;(console[l]??console.log).bind(console)(`%c[${o.label}]%c ${e}`,i,s,...c)};return r}function Cs(o,e=vs){const t={},i={};e.forEach((r,n)=>{const a=`${o}:${r}`,l=Ht[n%Ht.length],c=te.getLogger(a);ws(c,a,l),t[r]=c,i[r]={label:a,color:l,logger:c}});const s=r=>{for(const n of e)t[n].setLevel(r,!1)};return{loggers:t,LOGGING_CATEGORIES:e,enableLogging(r=ys){s(r)},disableLogging(){s("silent")},setLogLevel(r){s(r)},setCategoryLevel(r,n){var a;(a=t[r])==null||a.setLevel(n,!1)},forInstance(r,n){const a={};for(const l of e)a[l]=ks(i[l],r,n);return a}}}const ce=Math.min,oe=Math.max,Qe=Math.round,Ze=Math.floor,se=o=>({x:o,y:o}),Ss={left:"right",right:"left",bottom:"top",top:"bottom"};function Wt(o,e,t){return oe(o,ce(e,t))}function Se(o,e){return typeof o=="function"?o(e):o}function ge(o){return o.split("-")[0]}function Te(o){return o.split("-")[1]}function jt(o){return o==="x"?"y":"x"}function pt(o){return o==="y"?"height":"width"}function ie(o){const e=o[0];return e==="t"||e==="b"?"y":"x"}function mt(o){return jt(ie(o))}function Ts(o,e,t){t===void 0&&(t=!1);const i=Te(o),s=mt(o),r=pt(s);let n=s==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(n=et(n)),[n,et(n)]}function Is(o){const e=et(o);return[ut(o),e,ut(e)]}function ut(o){return o.includes("start")?o.replace("start","end"):o.replace("end","start")}const Gt=["left","right"],Ut=["right","left"],Os=["top","bottom"],Ps=["bottom","top"];function Ms(o,e,t){switch(o){case"top":case"bottom":return t?e?Ut:Gt:e?Gt:Ut;case"left":case"right":return e?Os:Ps;default:return[]}}function As(o,e,t,i){const s=Te(o);let r=Ms(ge(o),t==="start",i);return s&&(r=r.map(n=>n+"-"+s),e&&(r=r.concat(r.map(ut)))),r}function et(o){const e=ge(o);return Ss[e]+o.slice(e.length)}function Ls(o){var e,t,i,s;return{top:(e=o.top)!=null?e:0,right:(t=o.right)!=null?t:0,bottom:(i=o.bottom)!=null?i:0,left:(s=o.left)!=null?s:0}}function qt(o){return typeof o!="number"?Ls(o):{top:o,right:o,bottom:o,left:o}}function tt(o){const{x:e,y:t,width:i,height:s}=o;return{width:i,height:s,top:t,left:e,right:e+i,bottom:t+s,x:e,y:t}}function Jt(o,e,t){let{reference:i,floating:s}=o;const r=ie(e),n=mt(e),a=pt(n),l=ge(e),c=r==="y",d=i.x+i.width/2-s.width/2,h=i.y+i.height/2-s.height/2,g=i[a]/2-s[a]/2;let m;switch(l){case"top":m={x:d,y:i.y-s.height};break;case"bottom":m={x:d,y:i.y+i.height};break;case"right":m={x:i.x+i.width,y:h};break;case"left":m={x:i.x-s.width,y:h};break;default:m={x:i.x,y:i.y}}const b=Te(e);return b&&(m[n]+=g*(b==="end"?1:-1)*(t&&c?-1:1)),m}async function Es(o,e){var t;e===void 0&&(e={});const{x:i,y:s,platform:r,rects:n,elements:a,strategy:l}=o,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:g=!1,padding:m=0}=Se(e,o),b=qt(m),v=a[g?h==="floating"?"reference":"floating":h],p=tt(await r.getClippingRect({element:(t=await(r.isElement==null?void 0:r.isElement(v)))==null||t?v:v.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),x=h==="floating"?{x:i,y:s,width:n.floating.width,height:n.floating.height}:n.reference,S=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),k=await(r.isElement==null?void 0:r.isElement(S))&&await(r.getScale==null?void 0:r.getScale(S))||{x:1,y:1},E=tt(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:S,strategy:l}):x);return{top:(p.top-E.top+b.top)/k.y,bottom:(E.bottom-p.bottom+b.bottom)/k.y,left:(p.left-E.left+b.left)/k.x,right:(E.right-p.right+b.right)/k.x}}const $s=50,Vs=async(o,e,t)=>{const{placement:i="bottom",strategy:s="absolute",middleware:r=[],platform:n}=t,a=n.detectOverflow?n:{...n,detectOverflow:Es},l=await(n.isRTL==null?void 0:n.isRTL(e));let c=await n.getElementRects({reference:o,floating:e,strategy:s}),{x:d,y:h}=Jt(c,i,l),g=i,m=0;const b={};for(let u=0;u<r.length;u++){const v=r[u];if(!v)continue;const{name:p,fn:x}=v,{x:S,y:k,data:E,reset:V}=await x({x:d,y:h,initialPlacement:i,placement:g,strategy:s,middlewareData:b,rects:c,platform:a,elements:{reference:o,floating:e}});d=S??d,h=k??h,b[p]={...b[p],...E},V&&m<$s&&(m++,typeof V=="object"&&(V.placement&&(g=V.placement),V.rects&&(c=V.rects===!0?await n.getElementRects({reference:o,floating:e,strategy:s}):V.rects),{x:d,y:h}=Jt(c,g,l)),u=-1)}return{x:d,y:h,placement:g,strategy:s,middlewareData:b}},Ds=o=>({name:"arrow",options:o,async fn(e){const{x:t,y:i,placement:s,rects:r,platform:n,elements:a,middlewareData:l}=e,{element:c,padding:d=0}=Se(o,e)||{};if(c==null)return{};const h=qt(d),g={x:t,y:i},m=mt(s),b=pt(m),u=await n.getDimensions(c),v=m==="y",p=v?"top":"left",x=v?"bottom":"right",S=v?"clientHeight":"clientWidth",k=r.reference[b]+r.reference[m]-g[m]-r.floating[b],E=g[m]-r.reference[m],V=await(n.getOffsetParent==null?void 0:n.getOffsetParent(c));let F=V?V[S]:0;(!F||!await(n.isElement==null?void 0:n.isElement(V)))&&(F=a.floating[S]||r.floating[b]);const U=k/2-E/2,L=F/2-u[b]/2-1,T=ce(h[p],L),w=ce(h[x],L),_=F-u[b]-w,N=F/2-u[b]/2+U,I=Wt(T,N,_),H=!l.arrow&&Te(s)!=null&&N!==I&&r.reference[b]/2-(N<T?T:w)-u[b]/2<0,le=H?N<T?N-T:N-_:0;return{[m]:g[m]+le,data:{[m]:I,centerOffset:N-I-le,...H&&{alignmentOffset:le}},reset:H}}}),zs=function(o){return o===void 0&&(o={}),{name:"flip",options:o,async fn(e){var t,i;const{placement:s,middlewareData:r,rects:n,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:u=!0,...v}=Se(o,e);if((t=r.arrow)!=null&&t.alignmentOffset)return{};const p=ge(s),x=ie(a),S=ge(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),E=g||(S||!u?[et(a)]:Is(a)),V=b!=="none";!g&&V&&E.push(...As(a,u,b,k));const F=[a,...E],U=await l.detectOverflow(e,v),L=[];let T=((i=r.flip)==null?void 0:i.overflows)||[];if(d&&L.push(U[p]),h){const I=Ts(s,n,k);L.push(U[I[0]],U[I[1]])}if(T=[...T,{placement:s,overflows:L}],!L.every(I=>I<=0)){var w,_;const I=(((w=r.flip)==null?void 0:w.index)||0)+1,H=F[I];if(H&&(!(h==="alignment"?x!==ie(H):!1)||T.every(Y=>ie(Y.placement)===x?Y.overflows[0]>0:!0)))return{data:{index:I,overflows:T},reset:{placement:H}};let le=(_=T.filter(Ce=>Ce.overflows[0]<=0).sort((Ce,Y)=>Ce.overflows[1]-Y.overflows[1])[0])==null?void 0:_.placement;if(!le)switch(m){case"bestFit":{var N;const Ce=(N=T.filter(Y=>{if(V){const fe=ie(Y.placement);return fe===x||fe==="y"}return!0}).map(Y=>[Y.placement,Y.overflows.filter(fe=>fe>0).reduce((fe,Fi)=>fe+Fi,0)]).sort((Y,fe)=>Y[1]-fe[1])[0])==null?void 0:N[0];Ce&&(le=Ce);break}case"initialPlacement":le=a;break}if(s!==le)return{reset:{placement:le}}}return{}}}},Ns=new Set(["left","top"]);async function Rs(o,e){const{placement:t,platform:i,elements:s}=o,r=await(i.isRTL==null?void 0:i.isRTL(s.floating)),n=ge(t),a=Te(t),l=ie(t)==="y",c=Ns.has(n)?-1:1,d=r&&l?-1:1,h=Se(e,o);let{mainAxis:g,crossAxis:m,alignmentAxis:b}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof b=="number"&&(m=a==="end"?b*-1:b),l?{x:m*d,y:g*c}:{x:g*c,y:m*d}}const Bs=function(o){return o===void 0&&(o=0),{name:"offset",options:o,async fn(e){var t,i;const{x:s,y:r,placement:n,middlewareData:a}=e,l=await Rs(e,o);return n===((t=a.offset)==null?void 0:t.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:s+l.x,y:r+l.y,data:{...l,placement:n}}}}},Ks=function(o){return o===void 0&&(o={}),{name:"shift",options:o,async fn(e){const{x:t,y:i,placement:s,platform:r}=e,{mainAxis:n=!0,crossAxis:a=!1,limiter:l={fn:x=>{let{x:S,y:k}=x;return{x:S,y:k}}},...c}=Se(o,e),d={x:t,y:i},h=await r.detectOverflow(e,c),g=ie(s),m=jt(g);let b=d[m],u=d[g];const v=(x,S)=>Wt(S+h[x==="y"?"top":"left"],S,S-h[x==="y"?"bottom":"right"]);n&&(b=v(m,b)),a&&(u=v(g,u));const p=l.fn({...e,[m]:b,[g]:u});return{...p,data:{x:p.x-t,y:p.y-i,enabled:{[m]:n,[g]:a}}}}}},Hs=function(o){return o===void 0&&(o={}),{name:"size",options:o,async fn(e){const{placement:t,rects:i,platform:s,elements:r}=e,{apply:n=()=>{},...a}=Se(o,e),l=await s.detectOverflow(e,a),c=ge(t),d=Te(t),h=ie(t)==="y",{width:g,height:m}=i.floating;let b,u;c==="top"||c==="bottom"?(b=c,u=d===(await(s.isRTL==null?void 0:s.isRTL(r.floating))?"start":"end")?"left":"right"):(u=c,b=d==="end"?"top":"bottom");const v=m-l.top-l.bottom,p=g-l.left-l.right,x=ce(m-l[b],v),S=ce(g-l[u],p),k=e.middlewareData.shift,E=!k;let V=x,F=S;k!=null&&k.enabled.x&&(F=p),k!=null&&k.enabled.y&&(V=v),E&&!d&&(h?F=g-2*oe(l.left,l.right):V=m-2*oe(l.top,l.bottom)),await n({...e,availableWidth:F,availableHeight:V});const U=await s.getDimensions(r.floating);return g!==U.width||m!==U.height?{reset:{rects:!0}}:{}}}};function ot(){return typeof window<"u"}function Ie(o){return Xt(o)?(o.nodeName||"").toLowerCase():"#document"}function q(o){var e;return(o==null||(e=o.ownerDocument)==null?void 0:e.defaultView)||window}function re(o){var e;return(e=(Xt(o)?o.ownerDocument:o.document)||window.document)==null?void 0:e.documentElement}function Xt(o){return ot()?o instanceof Node||o instanceof q(o).Node:!1}function Z(o){return ot()?o instanceof Element||o instanceof q(o).Element:!1}function de(o){return ot()?o instanceof HTMLElement||o instanceof q(o).HTMLElement:!1}function Yt(o){return!ot()||typeof ShadowRoot>"u"?!1:o instanceof ShadowRoot||o instanceof q(o).ShadowRoot}function st(o){const{overflow:e,overflowX:t,overflowY:i,display:s}=ee(o);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&s!=="inline"&&s!=="contents"}function Fs(o){return/^(table|td|th)$/.test(Ie(o))}function it(o){try{if(o.matches(":popover-open"))return!0}catch{}try{return o.matches(":modal")}catch{return!1}}const Ws=/transform|translate|scale|rotate|perspective|filter/,js=/paint|layout|strict|content/,be=o=>!!o&&o!=="none";let ft;function gt(o){const e=Z(o)?ee(o):o;return be(e.transform)||be(e.translate)||be(e.scale)||be(e.rotate)||be(e.perspective)||!bt()&&(be(e.backdropFilter)||be(e.filter))||Ws.test(e.willChange||"")||js.test(e.contain||"")}function Gs(o){let e=ve(o);for(;de(e)&&!Ne(e);){if(gt(e))return e;if(it(e))return null;e=ve(e)}return null}function bt(){return ft==null&&(ft=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ft}function Ne(o){return/^(html|body|#document)$/.test(Ie(o))}function ee(o){return q(o).getComputedStyle(o)}function rt(o){return Z(o)?{scrollLeft:o.scrollLeft,scrollTop:o.scrollTop}:{scrollLeft:o.scrollX,scrollTop:o.scrollY}}function ve(o){if(Ie(o)==="html")return o;const e=o.assignedSlot||o.parentNode||Yt(o)&&o.host||re(o);return Yt(e)?e.host:e}function Qt(o){const e=ve(o);return Ne(e)?(o.ownerDocument||o).body:de(e)&&st(e)?e:Qt(e)}function Re(o,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);const s=Qt(o),r=s===((i=o.ownerDocument)==null?void 0:i.body),n=q(s);if(r){const a=vt(n);return e.concat(n,n.visualViewport||[],st(s)?s:[],a&&t?Re(a):[])}else return e.concat(s,Re(s,[],t))}function vt(o){return o.parent&&Object.getPrototypeOf(o.parent)?o.frameElement:null}function Zt(o){const e=ee(o);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const s=de(o),r=s?o.offsetWidth:t,n=s?o.offsetHeight:i,a=Qe(t)!==r||Qe(i)!==n;return a&&(t=r,i=n),{width:t,height:i,$:a}}function yt(o){return Z(o)?o:o.contextElement}function Oe(o){const e=yt(o);if(!de(e))return se(1);const t=e.getBoundingClientRect(),{width:i,height:s,$:r}=Zt(e);let n=(r?Qe(t.width):t.width)/i,a=(r?Qe(t.height):t.height)/s;return(!n||!Number.isFinite(n))&&(n=1),(!a||!Number.isFinite(a))&&(a=1),{x:n,y:a}}const Us=se(0);function eo(o){const e=q(o);return!bt()||!e.visualViewport?Us:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function qs(o,e,t){return e===void 0&&(e=!1),!!t&&e&&t===q(o)}function ye(o,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const s=o.getBoundingClientRect(),r=yt(o);let n=se(1);e&&(i?Z(i)&&(n=Oe(i)):n=Oe(o));const a=qs(r,t,i)?eo(r):se(0);let l=(s.left+a.x)/n.x,c=(s.top+a.y)/n.y,d=s.width/n.x,h=s.height/n.y;if(r&&i){const g=q(r),m=Z(i)?q(i):i;let b=g,u=vt(b);for(;u&&m!==b;){const v=Oe(u),p=u.getBoundingClientRect(),x=ee(u),S=p.left+(u.clientLeft+parseFloat(x.paddingLeft))*v.x,k=p.top+(u.clientTop+parseFloat(x.paddingTop))*v.y;l*=v.x,c*=v.y,d*=v.x,h*=v.y,l+=S,c+=k,b=q(u),u=vt(b)}}return tt({width:d,height:h,x:l,y:c})}function nt(o,e){const t=rt(o).scrollLeft;return e?e.left+t:ye(re(o)).left+t}function to(o,e){const t=o.getBoundingClientRect(),i=t.left+e.scrollLeft-nt(o,t),s=t.top+e.scrollTop;return{x:i,y:s}}function Js(o){let{elements:e,rect:t,offsetParent:i,strategy:s}=o;const r=s==="fixed",n=re(i),a=e?it(e.floating):!1;if(i===n||a&&r)return t;let l={scrollLeft:0,scrollTop:0},c=se(1);const d=se(0),h=de(i);if((h||!r)&&((Ie(i)!=="body"||st(n))&&(l=rt(i)),h)){const m=ye(i);c=Oe(i),d.x=m.x+i.clientLeft,d.y=m.y+i.clientTop}const g=n&&!h&&!r?to(n,l):se(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+d.x+g.x,y:t.y*c.y-l.scrollTop*c.y+d.y+g.y}}function Xs(o){return o.getClientRects?Array.from(o.getClientRects()):[]}function Ys(o){const e=rt(o),t=o.ownerDocument.body,i=oe(o.scrollWidth,o.clientWidth,t.scrollWidth,t.clientWidth),s=oe(o.scrollHeight,o.clientHeight,t.scrollHeight,t.clientHeight);let r=-e.scrollLeft+nt(o);const n=-e.scrollTop;return ee(t).direction==="rtl"&&(r+=oe(o.clientWidth,t.clientWidth)-i),{width:i,height:s,x:r,y:n}}const Qs=25;function Zs(o,e,t){t===void 0&&(t="viewport");const i=t==="layoutViewport",s=q(o),r=re(o),n=s.visualViewport;let a=r.clientWidth,l=r.clientHeight,c=0,d=0;if(n){const g=!bt()||e==="fixed";i?g||(c=-n.offsetLeft,d=-n.offsetTop):(a=n.width,l=n.height,g&&(c=n.offsetLeft,d=n.offsetTop))}if(nt(r)<=0){const g=r.ownerDocument,m=g.body,b=getComputedStyle(m),u=g.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,v=Math.abs(r.clientWidth-m.clientWidth-u),p=getComputedStyle(r).scrollbarGutter==="stable both-edges"?v/2:v;p<=Qs&&(a-=p)}return{width:a,height:l,x:c,y:d}}function ei(o,e){const t=ye(o,!0,e==="fixed"),i=t.top+o.clientTop,s=t.left+o.clientLeft,r=Oe(o),n=o.clientWidth*r.x,a=o.clientHeight*r.y,l=s*r.x,c=i*r.y;return{width:n,height:a,x:l,y:c}}function oo(o,e,t){let i;if(e==="viewport"||e==="layoutViewport")i=Zs(o,t,e);else if(e==="document")i=Ys(re(o));else if(Z(e))i=ei(e,t);else{const s=eo(o);i={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return tt(i)}function ti(o,e){const t=e.get(o);if(t)return t;let i=Re(o,[],!1).filter(a=>Z(a)&&Ie(a)!=="body"),s=null;const r=ee(o).position==="fixed";let n=r?ve(o):o;for(;Z(n)&&!Ne(n);){const a=ee(n),l=gt(n),c=s?s.position:r?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?i=i.filter(h=>h!==n):s=a,n=ve(n)}return e.set(o,i),i}function oi(o){let{element:e,boundary:t,rootBoundary:i,strategy:s}=o;const n=[...t==="clippingAncestors"?it(e)?[]:ti(e,this._c):[].concat(t),i],a=oo(e,n[0],s);let l=a.top,c=a.right,d=a.bottom,h=a.left;for(let g=1;g<n.length;g++){const m=oo(e,n[g],s);l=oe(m.top,l),c=ce(m.right,c),d=ce(m.bottom,d),h=oe(m.left,h)}return{width:c-h,height:d-l,x:h,y:l}}function si(o){const{width:e,height:t}=Zt(o);return{width:e,height:t}}function ii(o,e,t){const i=de(e),s=re(e),r=t==="fixed",n=ye(o,!0,r,e);let a={scrollLeft:0,scrollTop:0};const l=se(0);if((i||!r)&&((Ie(e)!=="body"||st(s))&&(a=rt(e)),i)){const g=ye(e,!0,r,e);l.x=g.x+e.clientLeft,l.y=g.y+e.clientTop}!i&&s&&(l.x=nt(s));const c=s&&!i&&!r?to(s,a):se(0),d=n.left+a.scrollLeft-l.x-c.x,h=n.top+a.scrollTop-l.y-c.y;return{x:d,y:h,width:n.width,height:n.height}}function wt(o){return ee(o).position==="static"}function so(o,e){if(!de(o)||ee(o).position==="fixed")return null;if(e)return e(o);let t=o.offsetParent;return re(o)===t&&(t=t.ownerDocument.body),t}function io(o,e){const t=q(o);if(it(o))return t;if(!de(o)){let s=ve(o);for(;s&&!Ne(s);){if(Z(s)&&!wt(s))return s;s=ve(s)}return t}let i=so(o,e);for(;i&&Fs(i)&&wt(i);)i=so(i,e);return i&&Ne(i)&&wt(i)&&!gt(i)?t:i||Gs(o)||t}const ri=async function(o){const e=this.getOffsetParent||io,t=this.getDimensions,i=await t(o.floating);return{reference:ii(o.reference,await e(o.floating),o.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ni(o){return ee(o).direction==="rtl"}const ro={convertOffsetParentRelativeRectToViewportRelativeRect:Js,getDocumentElement:re,getClippingRect:oi,getOffsetParent:io,getElementRects:ri,getClientRects:Xs,getDimensions:si,getScale:Oe,isElement:Z,isRTL:ni};function no(o,e){return o.x===e.x&&o.y===e.y&&o.width===e.width&&o.height===e.height}function ai(o,e,t){let i=null,s;const r=re(o);function n(){var d;clearTimeout(s),(d=i)==null||d.disconnect(),i=null}function a(d,h){d===void 0&&(d=!1),h===void 0&&(h=1),n();const g=o.getBoundingClientRect(),{left:m,top:b,width:u,height:v}=g;if(d||e(),!u||!v)return;const p=Ze(b),x=Ze(r.clientWidth-(m+u)),S=Ze(r.clientHeight-(b+v)),k=Ze(m),V={rootMargin:-p+"px "+-x+"px "+-S+"px "+-k+"px",threshold:oe(0,ce(1,h))||1};let F=!0;function U(L){const T=L[0].intersectionRatio;if(!no(g,o.getBoundingClientRect()))return a();if(T!==h){if(!F)return a();T?a(!1,T):s=setTimeout(()=>{a(!1,1e-7)},1e3)}F=!1}try{i=new IntersectionObserver(U,{...V,root:r.ownerDocument})}catch{i=new IntersectionObserver(U,V)}i.observe(o)}const l=q(o),c=()=>a(t);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),n()}}function li(o,e,t,i){i===void 0&&(i={});const{ancestorScroll:s=!0,ancestorResize:r=!0,elementResize:n=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,c=yt(o),d=s||r?[...c?Re(c):[],...e?Re(e):[]]:[];d.forEach(p=>{s&&p.addEventListener("scroll",t),r&&p.addEventListener("resize",t)});const h=c&&a?ai(c,t,r):null;let g=-1,m=null;n&&(m=new ResizeObserver(p=>{let[x]=p;x&&x.target===c&&m&&e&&(m.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var S;(S=m)==null||S.observe(e)})),t()}),c&&!l&&m.observe(c),e&&m.observe(e));let b,u=l?ye(o):null;l&&v();function v(){const p=ye(o);u&&!no(u,p)&&t(),u=p,b=requestAnimationFrame(v)}return t(),()=>{var p;d.forEach(x=>{s&&x.removeEventListener("scroll",t),r&&x.removeEventListener("resize",t)}),h==null||h(),(p=m)==null||p.disconnect(),m=null,l&&cancelAnimationFrame(b)}}const ci=Bs,di=Ks,hi=zs,ao=Hs,pi=Ds,mi=(o,e,t)=>{const i=new Map,s=t??{},r={...ro,...s.platform,_c:i};return Vs(o,e,{...s,platform:r})};function xt(o){const e=o.parentNode??null;return e instanceof ShadowRoot?e.host:e}function ui(o){if(o.transform!=="none"||o.perspective!=="none"||o.filter!=="none")return!0;const e=o.backdropFilter;return!!(e&&e!=="none"||o.willChange&&/\b(transform|filter|perspective)\b/.test(o.willChange))}function lo(o){let e=xt(o);for(;e&&!(e===document.body||e===document.documentElement);){if(e instanceof Element&&ui(getComputedStyle(e)))return e;e=xt(e)}return window}function fi(o,e,t){let i=o;for(;i&&!(i===document.body||i===document.documentElement);){if(i instanceof Element){const s=i.getBoundingClientRect();if(Math.abs(s.x-e)<2&&Math.abs(s.y-t)<2)return i}i=xt(i)}return null}function gi(o){const e=getComputedStyle(o),t=[];e.transform!=="none"&&t.push(`transform: ${e.transform}`),e.perspective!=="none"&&t.push(`perspective: ${e.perspective}`),e.filter!=="none"&&t.push(`filter: ${e.filter}`);const i=e.backdropFilter;i&&i!=="none"&&t.push(`backdrop-filter: ${i}`),e.willChange&&/\b(transform|filter|perspective)\b/.test(e.willChange)&&t.push(`will-change: ${e.willChange}`),e.contain&&/\b(paint|layout|strict|content)\b/.test(e.contain)&&t.push(`contain: ${e.contain}`);const s=e.containerType;return s&&s!=="normal"&&t.push(`container-type: ${s}`),t.join("; ")}function bi(o){const e=o.id?`#${o.id}`:"",t=typeof o.className=="string"&&o.className?"."+o.className.split(/\s+/).filter(Boolean).slice(0,2).join("."):"";return`<${o.tagName.toLowerCase()}${e}${t}>`}function vi(o){const e=o.tolerance??1.5;let t=0,i=0;if(o.offsetParent instanceof Element){const l=o.offsetParent.getBoundingClientRect(),c=getComputedStyle(o.offsetParent);t=l.x+(parseFloat(c.borderLeftWidth)||0),i=l.y+(parseFloat(c.borderTopWidth)||0)}const s=o.panel.getBoundingClientRect(),r=s.x-(t+o.expectedX),n=s.y-(i+o.expectedY);if(Math.abs(r)<e&&Math.abs(n)<e)return null;const a=fi(o.reference,r,n);return{driftX:r,driftY:n,culprit:a,culpritDescription:a?bi(a):"an ancestor element (could not auto-identify)",culpritCss:a?gi(a):""}}function yi(o,e){var s;const t=(s=o.closest)==null?void 0:s.call(o,"[data-theme]"),i=t==null?void 0:t.getAttribute("data-theme");i!=null&&e.setAttribute("data-theme",i)}const wi={top:"bottom",right:"left",bottom:"top",left:"right"};function xi(o,e,t){if(!t)return;const i=e.split("-")[0],s=wi[i];o.style.left=t.x!=null?`${t.x}px`:"",o.style.top=t.y!=null?`${t.y}px`:"",o.style.right="",o.style.bottom="",o.style[s]=`-${o.offsetWidth/2}px`}function co(o,e){const t=[ci(o.offset??4)];if(o.matchWidth){const s=o.matchWidth;t.push(ao({apply({rects:r,elements:n}){const a=`${r.reference.width}px`;s==="exact"?n.floating.style.width=a:n.floating.style.minWidth=a}}))}e&&t.push(hi({...o.lockPlacement===!0?{fallbackStrategy:"initialPlacement"}:{},...o.flipPadding!=null?{padding:o.flipPadding}:{}}));const i=o.shift??8;if(i!==!1&&t.push(di({padding:i})),o.maxHeight){const s=typeof o.maxHeight=="object"?o.maxHeight.padding:void 0;t.push(ao({padding:s,apply({availableHeight:r,elements:n}){n.floating.style.maxHeight=`${Math.max(0,r)}px`}}))}return o.arrow&&t.push(pi({element:o.arrow.element,padding:o.arrow.padding})),t}function _t(o,e,t={}){const i=t.strategy??"fixed";t.inheritThemeFrom&&yi(t.inheritThemeFrom,o),o.style.position=i,o.style.left="0",o.style.top="0";let s=t.placement??"bottom-start",r=t.flip??!0,n=co(t,r);const a=t.lockPlacement==="freeze";let l=!1;const c=!!t.fixedContainingBlock&&!t.platform,d=t.platform??(c?{...ro,getOffsetParent:()=>lo(o)}:void 0),h=()=>{var m;(m=t.beforeCompute)==null||m.call(t),mi(e,o,{placement:s,strategy:i,middleware:n,...d?{platform:d}:{}}).then(({x:b,y:u,placement:v,middlewareData:p})=>{var x,S;if(o.style.left=`${b}px`,o.style.top=`${u}px`,t.arrow&&xi(t.arrow.element,v,p.arrow),a&&!l&&(l=!0,s=v,r=!1,n=co(t,!1)),(x=t.onPlaced)==null||x.call(t,v),(S=t.onComputed)==null||S.call(t,{x:b,y:u,placement:v}),t.onDrift&&e instanceof Element){const k=c?lo(o):window,E=vi({panel:o,reference:e,expectedX:b,expectedY:u,offsetParent:k});E&&t.onDrift(E)}})};let g;return t.autoUpdate??!0?g=li(e,o,h,t.autoUpdateOptions):h(),{update:h,destroy(){g==null||g(),g=void 0}}}function _i(o){return typeof o=="number"?{show:o,hide:o}:{show:(o==null?void 0:o.show)??0,hide:(o==null?void 0:o.hide)??0}}function ki(o){const e=o.container??document.body,t=o.placement??"top",i=o.visibleClass??"is-visible",s=_i(o.delay),r=document.createElement("div");r.setAttribute("role","tooltip"),o.cssClass&&(r.className=o.cssClass),typeof o.content=="string"?r.textContent=o.content:r.append(o.content);let n,a=!1,l,c,d;const h={getBoundingClientRect:()=>d??o.trigger.getBoundingClientRect(),contextElement:o.trigger},g=x=>{d=new DOMRect(x.clientX,x.clientY,0,0),n==null||n.update()},m=()=>{l&&clearTimeout(l),c&&clearTimeout(c),l=c=void 0},b=()=>{var S;if(m(),a)return;(S=o.onBeforeShow)==null||S.call(o),a=!0,e.append(r);const x=o.followCursor?h:o.trigger;n=_t(r,x,{placement:t,strategy:o.strategy,offset:o.offset??8,inheritThemeFrom:o.inheritThemeFrom??o.trigger}),o.followCursor&&o.trigger.addEventListener("mousemove",g),r.classList.add(i)},u=()=>{m(),a&&(a=!1,r.classList.remove(i),o.followCursor&&o.trigger.removeEventListener("mousemove",g),n==null||n.destroy(),n=void 0,r.remove())},v=()=>{m(),s.show>0?l=setTimeout(b,s.show):b()},p=()=>{m(),s.hide>0?c=setTimeout(u,s.hide):u()};return o.trigger.addEventListener("mouseenter",v),o.trigger.addEventListener("mouseleave",p),o.trigger.addEventListener("focusin",v),o.trigger.addEventListener("focusout",p),{element:r,get isVisible(){return a},show:b,hide:u,destroy(){o.trigger.removeEventListener("mouseenter",v),o.trigger.removeEventListener("mouseleave",p),o.trigger.removeEventListener("focusin",v),o.trigger.removeEventListener("focusout",p),u()}}}const ho=["INIT","DATA","UI","INTERACTION"],ne=Cs("MULTISELECT",ho),Be=ne.loggers.INIT,j=ne.loggers.DATA,J=ne.loggers.UI,G=ne.loggers.INTERACTION,Ci=ho.map(o=>`MULTISELECT:${o}`);function Si(){ne.enableLogging()}function Ti(){ne.disableLogging()}function Ii(o){ne.setLogLevel(o)}function Oi(o,e){const t=o.includes(":")?o.split(":").pop():o;ne.setCategoryLevel(t,e)}class po{constructor(e){y(this,"container");y(this,"wrapper");y(this,"viewport");y(this,"itemHeight");y(this,"items");y(this,"renderItem");y(this,"bufferSize");y(this,"onVisibleRangeChange");y(this,"onScroll");y(this,"scrollTop",0);y(this,"viewportHeight",0);y(this,"visibleStart",0);y(this,"visibleEnd",0);y(this,"scrollHandler");y(this,"resizeObserver");this.container=e.container,this.itemHeight=e.itemHeight,this.items=e.items,this.renderItem=e.renderItem,this.bufferSize=e.bufferSize??10,this.onVisibleRangeChange=e.onVisibleRangeChange,this.onScroll=e.onScroll,this.scrollHandler=this.handleScroll.bind(this),this.init()}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.style.position="relative",this.wrapper.style.width="100%",this.wrapper.style.height=`${this.items.length*this.itemHeight}px`,this.wrapper.className="ms__virtual-scroll-wrapper",this.viewport=document.createElement("div"),this.viewport.style.position="absolute",this.viewport.style.top="0",this.viewport.style.left="0",this.viewport.style.right="0",this.viewport.style.width="100%",this.viewport.className="ms__virtual-scroll-viewport",this.wrapper.appendChild(this.viewport),this.container.appendChild(this.wrapper),this.container.addEventListener("scroll",this.scrollHandler),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{this.updateViewportHeight(),this.render()}),this.resizeObserver.observe(this.container)),this.updateViewportHeight(),this.render()}updateViewportHeight(){const e=this.container.clientHeight;e>0&&(this.viewportHeight=e)}handleScroll(){this.scrollTop=this.container.scrollTop,this.onScroll&&this.onScroll(this.scrollTop),this.render()}calculateVisibleRange(){const e=Math.floor(this.scrollTop/this.itemHeight),t=Math.ceil((this.scrollTop+this.viewportHeight)/this.itemHeight),i=Math.max(0,e-this.bufferSize),s=Math.min(this.items.length,t+this.bufferSize);return{start:i,end:s}}render(){const{start:e,end:t}=this.calculateVisibleRange();if(e===this.visibleStart&&t===this.visibleEnd)return;this.visibleStart=e,this.visibleEnd=t,this.onVisibleRangeChange&&this.onVisibleRangeChange(e,t);let i="";for(let s=e;s<t;s++){const r=this.items[s],n=this.renderItem(r,s),a=s*this.itemHeight;i+=`<div class="ms__virtual-item" style="position: absolute; top: ${a}px; left: 0; right: 0; height: ${this.itemHeight}px;" data-index="${s}">`,i+=n,i+="</div>"}this.viewport.innerHTML=i}setItems(e){const t=e!==this.items||e.length!==this.items.length;this.items=e,this.wrapper.style.height=`${e.length*this.itemHeight}px`,this.updateViewportHeight(),t&&(this.scrollTop=0,this.container.scrollTop=0),this.visibleStart=-1,this.visibleEnd=-1,this.render()}scrollToIndex(e){if(e<0||e>=this.items.length)return;const t=e*this.itemHeight,i=t+this.itemHeight,s=this.container.scrollTop,r=s+this.viewportHeight;t<s?this.container.scrollTop=t:i>r&&(this.container.scrollTop=i-this.viewportHeight)}getVisibleRange(){return{start:this.visibleStart,end:this.visibleEnd}}getItemCount(){return this.items.length}setItemHeight(e){this.itemHeight=e,this.wrapper.style.height=`${this.items.length*e}px`,this.visibleStart=-1,this.visibleEnd=-1,this.render()}setBufferSize(e){this.bufferSize=e,this.visibleStart=-1,this.visibleEnd=-1,this.render()}refresh(){this.visibleStart=-1,this.visibleEnd=-1,this.render()}destroy(){this.container.removeEventListener("scroll",this.scrollHandler),this.resizeObserver&&this.resizeObserver.disconnect(),this.container.innerHTML=""}}function mo(o){return{treeId:"",id:-1,path:"",pathSegment:"",parentPath:void 0,level:void 0,children:{},hasChildren:!1,isSelectable:!0,data:void 0,...o}}const Ke=o=>!o||typeof o=="string"&&o.trim()==="";function Pi(o,e="."){if(!o||typeof o!="string")return null;const t=o.lastIndexOf(e);return t===-1?"":o.substring(0,t)}function uo(o,e,t="."){return Ke(e)?o:o.startsWith(e+t)?o.substring(e.length+t.length):o}function fo(o,e=0,t=1,i="."){return o.split(i).slice(e,e+t).join(i)}function Mi(o,e){return o.split(e).length}function he(o,e){return o[e]}function Ai(o={}){const e=o.idMember,t=o.pathMember,i=o.getPathCallback,s=o.parentPathMember,r=o.levelMember,n=o.hasChildrenMember,a=o.isSelectableMember,l=o.getIsSelectableCallback,c=o.treeId||"multiselect-tree",d=o.orderMember,h=o.getDisplayValueCallback,g=Ke(s),m=Ke(r),b=Ke(n),u=Ke(a),v="x",p=o.treePathSeparator||".",x=mo();let S=0,k=null;const E=L=>i?i(L):t?he(L,t):void 0,V={treePathSeparator:p,root:x,get tree(){return Object.values(x.children)},get flatNodes(){if(k)return k;const L=[],T=o.isSorted??!1,w=o.sortCallback;function _(N){let I=Object.values(N.children);T&&w&&I.length>0&&(I=w(I));for(const H of I)L.push(H),H.hasChildren&&_(H)}return _(x),k=L,L},insertArray(L){L=L||[],x.children={},S=0,k=null;const T=[];let w=L.map((_,N)=>{const I=mo();I.treeId=c,I.id=e?he(_,e):void 0;const H=E(_);return H==null||H===""||typeof H!="string"?(T.push(`index ${N}`),null):(I.path=H,(I.id===void 0||I.id===-1)&&(I.id=H),g?I.parentPath=Pi(I.path,p):I.parentPath=he(_,s),I.pathSegment=fo(uo(I.path,I.parentPath??"",p),0,1,p),m?I.level=Mi(I.path,p):I.level=he(_,r),b||(I.hasChildren=he(_,n)),I.data=_,I)}).filter(_=>_!==null);o.isSorted||(o.sortCallback?w=o.sortCallback(w):w=U(w));for(const _ of w)F(_.parentPath??"",_);if(l||!u)for(const _ of w)if(l)_.isSelectable=l(_)!==!1;else{const N=he(_.data,a);_.isSelectable=N==null?!0:!!N}T.length>0&&console.warn(`[ltree ${c}] ${T.length} option(s) had an invalid path and were skipped (pathMember="${t}"). Offending: ${T.slice(0,5).join(", ")}`+(T.length>5?", …":""))},getNodeByPath(L,T){let w=T||x;if(L){const _=L.split(p);for(let N=0;N<_.length;N++){const I=v+_[N];if(!w.children.hasOwnProperty(I))return null;w=w.children[I]}}return w}};function F(L,T){const w=V.getNodeByPath(L);if(!w)return`Node: ${T.path} - Could not find parent node: ${L}`;m&&(T.level=(w.level||0)+1);const _=v+fo(uo(T.path,L,p),0,1,p);return w.children.hasOwnProperty(_)||(w.children[_]=T,b&&!w.hasChildren&&(w.hasChildren=!0),S=Math.max(S,T.level||0)),null}function U(L){return L.sort((T,w)=>{const _=T.level||0,N=w.level||0;if(_!==N)return _-N;if(T.parentPath!==w.parentPath)return T.parentPath?w.parentPath?T.parentPath.localeCompare(w.parentPath):1:-1;if(d&&T.data&&w.data){const I=he(T.data,d)??0,H=he(w.data,d)??0;if(I!==H)return I-H}return h?h(T).localeCompare(h(w)):T.path.localeCompare(w.path)})}return V}function go(o,e){const t=new Map,i=new Map,s=new Set,r=l=>String(e(l.data)),n=l=>{t.set(r(l),l);const c=[];for(const h of Object.values(l.children))c.push(...n(h));let d;return c.length>0?d=c:l.isSelectable!==!1?(d=[r(l)],s.add(l.path)):d=[],i.set(l.path,d),d},a=o.tree;for(const l of a)n(l);return{nodeByValue:t,atomsUnder:i,atomPaths:s,roots:a}}function kt(o,e,t){const i=o.atomsUnder.get(e.path);if(!i||i.length===0)return"unchecked";let s=0;for(const r of i)t.has(r)&&s++;return s===0?"unchecked":s===i.length?"checked":"indeterminate"}function He(o,e){const t=new Set;for(const i of e){const s=o.nodeByValue.get(String(i));if(s)for(const r of o.atomsUnder.get(s.path)??[])t.add(r)}return t}function Li(o,e,t){const i=o.atomsUnder.get(e.path)??[],s=new Set(t),r=kt(o,e,t),n=[],a=[];if(r==="checked")for(const l of i)s.delete(l)&&a.push(l);else for(const l of i)s.has(l)||(s.add(l),n.push(l));return{checkedAtoms:s,addedAtoms:n,removedAtoms:a}}function Ct(o,e,t,i){const s=a=>String(i(a.data)),r=[],n=a=>{const l=kt(o,a,e);if(l==="unchecked")return;const c=a.isSelectable!==!1,d=Object.values(a.children);if(t==="leaves"){o.atomPaths.has(a.path)&&l==="checked"&&r.push(s(a));for(const h of d)n(h);return}if(t==="all"){l==="checked"&&c&&r.push(s(a));for(const h of d)n(h);return}if(l==="checked"&&c){r.push(s(a));return}for(const h of d)n(h)};for(const a of o.roots)n(a);return r}class bo{constructor(e,t={}){y(this,"element");y(this,"instanceId");y(this,"options");y(this,"isOpen",!1);y(this,"selectedValues",new Set);y(this,"selectedOptions",new Map);y(this,"allOptions",[]);y(this,"filteredOptions",[]);y(this,"tree",null);y(this,"treeNodes",[]);y(this,"cascadeIndex",null);y(this,"cascadeCheckedAtoms",new Set);y(this,"hiddenInputs",[]);y(this,"focusedIndex",-1);y(this,"matchingIndices",new Set);y(this,"searchTerm","");y(this,"isLoading",!1);y(this,"searchDebounceTimer");y(this,"searchAbortController");y(this,"showSelectedPopover",!1);y(this,"selectedPopoverPlacement",null);y(this,"dropdownPlacement",null);y(this,"isRTL",!1);y(this,"effectiveBadgesPosition","bottom");y(this,"justClosedViaClick",!1);y(this,"positioningDriftWarned",!1);y(this,"dropdownCleanup",null);y(this,"hintCleanup",null);y(this,"selectedPopoverCleanup",null);y(this,"tooltips",new Map);y(this,"onDropdownScroll",()=>this.hideOptionTooltips());y(this,"virtualScroll",null);y(this,"optionsContainer",null);y(this,"selectedPopoverVirtualScroll",null);y(this,"selectedPopoverContainer",null);y(this,"input");y(this,"dropdown");y(this,"dropdownInner");y(this,"badgesContainer");y(this,"counter");y(this,"hint");y(this,"selectedPopover");y(this,"documentKeydownHandler",null);y(this,"documentClickHandler",null);this.element=e,this.instanceId=`MS-${Math.random().toString(36).slice(2,11)}`,this.options={searchHint:e.dataset.searchHint||"",searchPlaceholder:e.dataset.searchPlaceholder||"Search...",selectPlaceholder:e.dataset.selectPlaceholder||"Pick an option...",noDataPlaceholder:e.dataset.noDataPlaceholder||void 0,dropdownMinWidth:e.dataset.dropdownMinWidth||void 0,dropdownMaxWidth:e.dataset.dropdownMaxWidth||void 0,badgesDisplayMode:e.dataset.badgesDisplayMode||"badges",badgesPosition:e.dataset.badgesPosition||"bottom",badgesThresholdMode:e.dataset.badgesThresholdMode||"count",maxHeight:e.dataset.maxHeight||"20rem",emptyMessage:e.dataset.emptyMessage||"No results found",loadingMessage:e.dataset.loadingMessage||"Loading...",searchInputMode:e.dataset.searchInputMode||"normal",searchMode:e.dataset.searchMode||"filter",badgesThreshold:e.dataset.badgesThreshold?parseInt(e.dataset.badgesThreshold):void 0,minSearchLength:parseInt(e.dataset.minSearchLength||"0")||0,searchDebounce:parseInt(e.dataset.searchDebounce||"0")||0,isMultipleEnabled:e.dataset.multiple!=="false",isGroupsAllowed:e.dataset.allowGroups!=="false",isCheckboxesShown:e.dataset.showCheckboxes!=="false",isActionsSticky:e.dataset.stickyActions!=="false",isCloseOnSelect:e.dataset.closeOnSelect==="true",isPlacementLocked:e.dataset.lockPlacement!=="false",isSearchEnabled:e.dataset.enableSearch!=="false",isAddNewAllowed:e.dataset.allowAddNew==="true",isCounterShown:e.dataset.showCounter==="true",isKeepOptionsOnSearch:e.dataset.keepOptionsOnSearch!=="false",shouldKeepSearchOnClose:e.dataset.keepSearchOnClose!=="false",options:[],container:void 0,...t},this.init()}extractField(e,t){if(Array.isArray(e)&&e.length===2){if(t.tupleSkip)return typeof t.fallback=="function"?t.fallback():t.fallback;if(t.tupleIndex!==void 0){const s=e[t.tupleIndex];return t.transform?t.transform(s):s}}if(t.member&&e[t.member]!==void 0){const s=e[t.member];return t.transform?t.transform(s):s}return t.callback?t.callback(e):typeof t.fallback=="function"?t.fallback():t.fallback}getItemValue(e){return this.extractField(e,{tupleIndex:0,member:this.options.valueMember,callback:this.options.getValueCallback,fallback:"[N/A]"})}getItemDisplayValue(e){return this.extractField(e,{tupleIndex:1,member:this.options.displayValueMember,callback:this.options.getDisplayValueCallback,transform:String,fallback:"[N/A]"})}getItemBadgeDisplayValue(e){if(this.options.getBadgeDisplayCallback)return this.options.getBadgeDisplayCallback(e);if(this.options.isBadgeFullTitleShown){const t=this.getItemFullTitle(e);if(t)return t}return this.getItemDisplayValue(e)}getItemFullTitle(e){return this.extractField(e,{tupleSkip:!0,member:this.options.fullTitleMember,callback:this.options.getFullTitleCallback,transform:String,fallback:void 0})}getItemSearchValue(e){return this.extractField(e,{member:this.options.searchValueMember,callback:this.options.getSearchValueCallback,transform:String,fallback:()=>this.getItemDisplayValue(e)})}getItemIcon(e){return this.extractField(e,{tupleSkip:!0,member:this.options.iconMember,callback:this.options.getIconCallback,transform:String,fallback:void 0})}getItemSubtitle(e){return this.extractField(e,{tupleSkip:!0,member:this.options.subtitleMember,callback:this.options.getSubtitleCallback,transform:String,fallback:void 0})}getItemGroup(e){return this.extractField(e,{tupleSkip:!0,member:this.options.groupMember,callback:this.options.getGroupCallback,transform:String,fallback:void 0})}getItemDisabled(e){return this.extractField(e,{tupleSkip:!0,member:this.options.disabledMember,callback:this.options.getDisabledCallback,transform:Boolean,fallback:!1})}isIndexSelectable(e){if(!this.isTreeMode())return!0;const t=this.treeNodes[e];return t?t.isSelectable!==!1:!0}isOptionSelectable(e){if(!this.isTreeMode())return!0;const t=this.filteredOptions.indexOf(e);if(t>=0)return this.isIndexSelectable(t);const i=String(this.getItemValue(e)),s=this.treeNodes.find(r=>String(this.getItemValue(r.data))===i);return s?s.isSelectable!==!1:!0}init(){this.parseOptions(),this.buildHTML(),this.attachEvents(),this.parseInitialSelection(),Be.debug(`Initialized [${this.instanceId}] with options:`,{placeholder:this.options.searchPlaceholder,totalOptions:this.allOptions.length,isCloseOnSelect:this.options.isCloseOnSelect,dataAttribute:this.element.dataset.closeOnSelect})}parseOptions(){const e=this.element.dataset.options;if(e)try{this.allOptions=JSON.parse(e)}catch(t){j.error(`[${this.instanceId}] Failed to parse data-options:`,t),this.allOptions=[]}else this.options.options&&(this.allOptions=this.options.options);this.filteredOptions=[...this.allOptions],this.isTreeMode()&&this.buildTree()}isTreeMode(){return this.options.isTreeEnabled===!1?!1:!!(this.options.isTreeEnabled||this.options.pathMember||this.options.getPathCallback)}buildTree(){this.tree=Ai({idMember:this.options.valueMember,pathMember:this.options.pathMember,getPathCallback:this.options.getPathCallback,parentPathMember:this.options.parentPathMember,levelMember:this.options.levelMember,hasChildrenMember:this.options.hasChildrenMember,isSelectableMember:this.options.isSelectableMember,getIsSelectableCallback:this.options.getIsSelectableCallback,treePathSeparator:this.options.treePathSeparator,treeId:this.instanceId,getDisplayValueCallback:e=>this.getItemDisplayValue(e.data)}),this.tree.insertArray(this.allOptions),this.cascadeIndex=this.isCascadeMode()?go(this.tree,e=>String(this.getItemValue(e))):null,this.rebuildTreeVisible()}isCascadeMode(){return this.isTreeMode()&&this.options.isMultipleEnabled!==!1&&this.options.checkboxMode==="cascade"}cascadePolicy(){return this.options.cascadeSelectPolicy??"rolled-up"}refreshCascadeAtoms(){this.isCascadeMode()&&this.cascadeIndex&&(this.cascadeCheckedAtoms=He(this.cascadeIndex,this.selectedValues))}toggleTreeCascade(e){const t=this.cascadeIndex,i=He(t,this.selectedValues),{checkedAtoms:s}=Li(t,e,i);this.commitCascadeAtoms(s)}commitCascadeAtoms(e){var l;const t=this.cascadeIndex,i=Ct(t,e,this.cascadePolicy(),c=>String(this.getItemValue(c))),s=new Set(i),r=[],n=[];for(const[c,d]of this.selectedOptions)s.has(c)||n.push(d);const a=new Map;for(const c of i){const h=((l=t.nodeByValue.get(c))==null?void 0:l.data)??this.selectedOptions.get(c);h!==void 0&&(a.set(c,h),this.selectedValues.has(c)||r.push(h))}this.selectedValues=s,this.selectedOptions=a,this.cascadeCheckedAtoms=e,this.commit({added:r,removed:n})}counterSelection(){if(this.isCascadeMode()&&this.cascadeIndex){const e=Ct(this.cascadeIndex,this.cascadeCheckedAtoms,"rolled-up",i=>String(this.getItemValue(i))),t=[];for(const i of e){const s=this.cascadeIndex.nodeByValue.get(i),r=(s==null?void 0:s.data)??this.selectedOptions.get(i);r!==void 0&&t.push(r)}return t}return Array.from(this.selectedOptions.values())}buildCounterTooltip(e){const i=e.slice(0,12).map(s=>this.getItemBadgeDisplayValue(s));return e.length>12&&i.push(`…and ${e.length-12} more`),i.join(`
2
+ `)}rebuildTreeVisible(){if(!this.tree){this.treeNodes=[];return}const e=this.tree.flatNodes,t=this.options.isSearchEnabled?(this.searchTerm||"").trim().toLowerCase():"";let i;if(!t)i=e;else{const s=this.tree.treePathSeparator,r=new Set;for(const n of e)if(this.getItemSearchValue(n.data).toLowerCase().includes(t)){const l=n.path.split(s);for(let c=1;c<=l.length;c++)r.add(l.slice(0,c).join(s))}i=e.filter(n=>r.has(n.path))}this.treeNodes=i,this.filteredOptions=i.map(s=>s.data)}resetVisibleToAll(){this.isTreeMode()?this.rebuildTreeVisible():this.filteredOptions=[...this.allOptions]}rebuildTreeVisibleFromMatches(e){if(!this.tree){this.treeNodes=[],this.filteredOptions=[];return}const t=this.tree.flatNodes,i=this.tree.treePathSeparator,s=new Set((e||[]).map(a=>String(this.getItemValue(a)))),r=new Set;for(const a of t)if(s.has(String(this.getItemValue(a.data)))){const l=a.path.split(i);for(let c=1;c<=l.length;c++)r.add(l.slice(0,c).join(i))}const n=t.filter(a=>r.has(a.path));this.treeNodes=n,this.filteredOptions=n.map(a=>a.data)}buildHTML(){const e=this.options.container||document.body,t=this.element.getRootNode(),i=t instanceof ShadowRoot?t.host:this.element,s=i.getAttribute("dir")==="rtl",r=i.closest('[dir="rtl"]')!==null;this.isRTL=s||r,Be.debug(`[${this.instanceId}] RTL Debug:`,{isShadowRoot:t instanceof ShadowRoot,hostElement:i,elementDir:i.getAttribute("dir"),hasElementDir:s,hasAncestorDir:r,isRTL:this.isRTL}),this.effectiveBadgesPosition=this.options.badgesPosition||"bottom",this.isRTL&&(this.effectiveBadgesPosition==="left"?this.effectiveBadgesPosition="right":this.effectiveBadgesPosition==="right"&&(this.effectiveBadgesPosition="left")),this.element.classList.add("ms"),this.isRTL&&(this.element.classList.add("ms--rtl"),Be.debug(`[${this.instanceId}] Added ms--rtl class to element`)),(!this.options.isCheckboxesShown||!this.options.isMultipleEnabled)&&this.element.classList.add("ms--no-checkboxes");const n=document.createElement("div");n.className="ms__input-wrapper",this.input=document.createElement("input"),this.input.type="text",this.input.className="ms__input",this.input.placeholder=this.getPlaceholderText(),this.input.autocomplete="off",this.options.searchInputMode==="readonly"?this.input.readOnly=!0:this.options.searchInputMode==="hidden"&&(this.input.style.display="none");const a=document.createElement("span");a.className="ms__toggle",a.innerHTML="▼",this.counter=document.createElement("span"),this.counter.className="ms__counter",this.counter.style.display="none",n.appendChild(this.input),n.appendChild(this.counter),n.appendChild(a),this.badgesContainer=document.createElement("div"),this.badgesContainer.className="ms__badges";const l=document.createElement("div");l.className="ms__wrapper",(this.effectiveBadgesPosition==="left"||this.effectiveBadgesPosition==="right")&&l.classList.add("ms__wrapper--inline"),l.appendChild(n),l.appendChild(this.badgesContainer),this.element.appendChild(l),this.dropdown=document.createElement("div"),this.dropdown.className="ms__dropdown",this.dropdownInner=document.createElement("div"),this.dropdownInner.className="ms__dropdown-inner",this.dropdown.appendChild(this.dropdownInner),e.appendChild(this.dropdown),this.options.searchHint&&(this.hint=document.createElement("div"),this.hint.className="ms__hint",this.hint.textContent=this.options.searchHint,e.appendChild(this.hint)),this.selectedPopover=document.createElement("div"),this.selectedPopover.className="ms__selected-popover",e.appendChild(this.selectedPopover),this.renderDropdown()}shouldUseVirtualScroll(){if(!this.options.isVirtualScrollEnabled||this.options.isGroupsAllowed&&this.hasGroups())return!1;const e=this.options.virtualScrollThreshold??100;return this.filteredOptions.length>=e}hasGroups(){return this.filteredOptions.some(e=>{const t=this.getItemGroup(e);return t&&t.trim()!==""})}renderDropdown(){if(this.destroyAllActionButtonTooltips(),this.refreshCascadeAtoms(),this.shouldUseVirtualScroll()){this.dropdown.classList.add("ms__dropdown--virtual"),this.renderDropdownVirtual();return}this.dropdown.classList.remove("ms__dropdown--virtual"),this.virtualScroll&&(this.virtualScroll.destroy(),this.virtualScroll=null,this.optionsContainer=null);let e="";if(this.isLoading){e+='<div class="ms__loader">',e+='<div class="pa-loader pa-loader--sm"></div>',e+=`<div class="ms__loading-text">${this.options.loadingMessage}</div>`,e+="</div>",this.dropdownInner.innerHTML=e;return}const t=this.renderActionsHTML(),i=this.options.actionsPosition==="bottom";if(i||(e+=t),this.options.isVirtualScrollEnabled){const s=this.options.optionHeight??50;e+=`<div class="ms__options ms__options--fixed-height" style="--ms-option-height: ${s}px;">`}else e+='<div class="ms__options">';if(this.filteredOptions.length===0)e+=`<div class="ms__empty">${this.options.emptyMessage}</div>`;else if(this.isTreeMode())this.treeNodes.forEach((s,r)=>{e+=this.renderTreeNode(s,r)});else if(this.options.isGroupsAllowed){const s=this.groupOptions(this.filteredOptions),r=new Map;this.filteredOptions.forEach((n,a)=>r.set(n,a)),Object.keys(s).forEach(n=>{if(e+='<div class="ms__group">',n!=="__ungrouped__")if(this.options.renderGroupLabelContentCallback){const a=this.options.renderGroupLabelContentCallback(n);if(a instanceof HTMLElement){const l=document.createElement("div");l.className="ms__group-label",l.appendChild(a),e+=l.outerHTML}else e+=`<div class="ms__group-label">${a}</div>`}else e+=`<div class="ms__group-label">${n}</div>`;s[n].forEach(a=>{e+=this.renderOption(a,r.get(a)??-1)}),e+="</div>"})}else this.filteredOptions.forEach((s,r)=>{e+=this.renderOption(s,r)});e+="</div>",i&&(e+=t),this.dropdownInner.innerHTML=e,this.attachActionButtonTooltips(),this.attachOptionTooltips()}renderDropdownVirtual(){if(this.destroyAllActionButtonTooltips(),!this.virtualScroll){let i="";const s=this.renderActionsHTML(),r=this.options.actionsPosition==="bottom";r||(i+=s);const n=this.options.maxHeight||"20rem",a=this.options.optionHeight??50;i+=`<div class="ms__options ms__options--virtual" style="height: ${n}; max-height: ${n}; overflow-y: auto; position: relative; --ms-option-height: ${a}px;"></div>`,r&&(i+=s),this.dropdownInner.innerHTML=i,this.optionsContainer=this.dropdownInner.querySelector(".ms__options")}if(this.filteredOptions.length===0){this.virtualScroll&&(this.virtualScroll.destroy(),this.virtualScroll=null),this.optionsContainer.innerHTML=`<div class="ms__empty">${this.options.emptyMessage}</div>`;return}const e=this.options.optionHeight??50,t=this.options.virtualScrollBuffer??10;requestAnimationFrame(()=>{this.optionsContainer&&(this.virtualScroll?this.virtualScroll.setItems(this.filteredOptions):this.virtualScroll=new po({container:this.optionsContainer,itemHeight:e,items:this.filteredOptions,renderItem:(i,s)=>this.isTreeMode()?this.renderTreeNode(this.treeNodes[s],s):this.renderOption(i,s),bufferSize:t,onVisibleRangeChange:()=>{this.attachOptionTooltips()}}),this.attachActionButtonTooltips())})}getBuiltInActionDisabled(e){return e==="select-all"?!this.filteredOptions.some(t=>!this.getItemDisabled(t)&&!this.selectedValues.has(String(this.getItemValue(t)))):e==="clear-all"?this.selectedValues.size===0:!1}renderActionsHTML(){const e=this.options.actionButtons;if(!this.options.isMultipleEnabled||!e||e.length===0)return"";const t=this.options.actionsPosition==="bottom"?"bottom":"top",i=this.options.actionsAlign??"stretch",s=` ms__actions--${t}`,r=this.options.isActionsSticky?" ms__actions--sticky":"",n=this.options.actionsLayout==="wrap"?" ms__actions--wrap":"",a=` ms__actions--align-${i}`,l=new Map;if(e.forEach((d,h)=>{if(!(d.getIsVisibleCallback?d.getIsVisibleCallback(this):d.isVisible??!0))return;let m;d.getIsDisabledCallback?m=d.getIsDisabledCallback(this):d.isDisabled!==void 0?m=d.isDisabled:m=this.getBuiltInActionDisabled(d.action);const b=m?" disabled":"",u=d.getTextCallback?d.getTextCallback(this):d.text;let v="";if(d.getClassCallback){const S=d.getClassCallback(this);v=Array.isArray(S)?` ${S.join(" ")}`:S?` ${S}`:""}else d.cssClass&&(v=` ${d.cssClass}`);const p=Math.max(1,Math.floor(d.row??1)),x=`<button type="button"${b} class="ms__action-btn${v}" data-action="${d.action}" data-button-index="${h}">${u}</button>`;l.has(p)||l.set(p,[]),l.get(p).push(x)}),l.size===0)return"";const c=Array.from(l.keys()).sort((d,h)=>d-h).map(d=>`<div class="ms__actions-row" data-row="${d}">${l.get(d).join("")}</div>`).join("");return`<div class="ms__actions${s}${r}${n}${a}">${c}</div>`}renderOption(e,t){const i=this.getItemValue(e),s=this.getItemDisplayValue(e),r=this.getItemIcon(e),n=this.getItemSubtitle(e),a=this.getItemDisabled(e),l=this.selectedValues.has(String(i)),c=t===this.focusedIndex,d=this.matchingIndices.has(t),h=["ms__option"];l&&h.push("ms__option--selected"),c&&h.push("ms__option--focused"),d&&h.push("ms__option--matched"),a&&h.push("ms__option--disabled");const g=this.options.checkboxAlign&&this.options.checkboxAlign!=="center"?` data-checkbox-align="${this.options.checkboxAlign}"`:"";let m=`<div class="${h.join(" ")}" data-value="${i}" data-index="${t}"${g}>`;if(this.options.isCheckboxesShown&&this.options.isMultipleEnabled&&(m+=`<input type="checkbox" class="ms__checkbox" ${l?"checked":""} ${a?"disabled":""}>`),m+='<div class="ms__option-content">',this.options.renderOptionContentCallback){const b={index:t,isSelected:l,isFocused:c,isMatched:d,isDisabled:a,isTreeNode:!1},u=this.options.renderOptionContentCallback(e,b);typeof u=="string"?m+=u:m+=u.outerHTML}else r&&(m+=`<span class="ms__option-icon">${r}</span>`),m+='<div class="ms__option-text">',m+=`<div class="ms__option-title">${this.highlightMatch(s,this.searchTerm)}</div>`,n&&(m+=`<div class="ms__option-subtitle">${n}</div>`),m+="</div>";return m+="</div>",m+="</div>",m}renderTreeNode(e,t){const i=e.data,s=this.getItemValue(i),r=this.getItemDisplayValue(i),n=this.getItemIcon(i),a=this.getItemSubtitle(i),l=this.getItemDisabled(i),c=this.isCascadeMode()&&this.cascadeIndex,d=c?kt(this.cascadeIndex,e,this.cascadeCheckedAtoms):null,h=c?d==="checked":this.selectedValues.has(String(s)),g=d==="indeterminate",m=t===this.focusedIndex,b=e.isSelectable!==!1,u=e.level??1,v=Math.max(0,u-1),p=["ms__option","ms__option--tree"];p.push(e.hasChildren?"ms__option--tree-branch":"ms__option--tree-leaf"),h&&p.push("ms__option--selected"),g&&p.push("ms__option--indeterminate"),m&&p.push("ms__option--focused"),l&&p.push("ms__option--disabled"),b||p.push("ms__option--tree-unselectable");const x=this.options.checkboxAlign&&this.options.checkboxAlign!=="center"?` data-checkbox-align="${this.options.checkboxAlign}"`:"",S=b?"":' data-selectable="false"';let k=`<div class="${p.join(" ")}" data-value="${s}" data-index="${t}" data-path="${e.path}" data-level="${u}" style="--ms-tree-depth: ${v};"${x}${S}>`;if(this.options.isCheckboxesShown&&this.options.isMultipleEnabled&&b&&(k+=`<input type="checkbox" class="${g?"ms__checkbox ms__checkbox--indeterminate":"ms__checkbox"}" ${h?"checked":""}${g?' aria-checked="mixed"':""} ${l?"disabled":""}>`),k+='<div class="ms__option-content">',this.options.renderOptionContentCallback){const E={index:t,isSelected:h,isFocused:m,isMatched:!1,isDisabled:l,isTreeNode:!0,isBranch:e.hasChildren,isLeaf:!e.hasChildren,childCount:Object.keys(e.children).length,level:u,depth:v,path:e.path,isSelectable:b,isIndeterminate:g},V=this.options.renderOptionContentCallback(i,E);k+=typeof V=="string"?V:V.outerHTML}else n&&(k+=`<span class="ms__option-icon">${n}</span>`),k+='<div class="ms__option-text">',k+=`<div class="ms__option-title">${this.highlightMatch(r,this.searchTerm)}</div>`,a&&(k+=`<div class="ms__option-subtitle">${a}</div>`),k+="</div>";return k+="</div>",k+="</div>",k}highlightMatch(e,t){if(!t)return e;const i=new RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return e.replace(i,"<mark>$1</mark>")}groupOptions(e){const t={};return e.forEach(i=>{const s=this.getItemGroup(i)||"__ungrouped__";t[s]||(t[s]=[]),t[s].push(i)}),t}get isSearchUsable(){return!!this.options.isSearchEnabled&&this.options.searchInputMode!=="readonly"&&this.options.searchInputMode!=="hidden"}getPlaceholderText(){return this.options.noDataPlaceholder&&this.allOptions.length===0?this.options.noDataPlaceholder:this.isSearchUsable?this.options.searchPlaceholder:this.options.selectPlaceholder||this.options.searchPlaceholder}renderBadges(){this.destroyAllBadgeTooltips();const e=Array.from(this.selectedOptions.values()),t=this.selectedValues.size;if(!this.options.isMultipleEnabled){this.badgesContainer.innerHTML="",this.counter.style.display="none";let r;e[0]&&(this.options.renderSelectedContentCallback?r=this.options.renderSelectedContentCallback(e[0]):r=this.getItemDisplayValue(e[0])),!this.isOpen&&t>0&&e.length>0?this.input.value=r:this.isOpen||(this.input.value="");return}let i=this.options.badgesDisplayMode;if(this.options.badgesThreshold!==null&&t>this.options.badgesThreshold&&i!=="none"&&(i=this.options.badgesThresholdMode||"count"),!this.isOpen)if(t>0&&i==="count"){const r=this.options.getCounterCallback?this.options.getCounterCallback(t):`${t} selected`;this.input.placeholder=r}else this.input.placeholder=this.getPlaceholderText();if(this.options.isCounterShown&&t>0){const r=this.counterSelection(),n=r.length;this.counter.textContent=`[${n}]`,this.counter.title=this.buildCounterTooltip(r),this.counter.style.display=n>0?"":"none"}else this.counter.title="",this.counter.style.display="none";if(i==="none"){this.badgesContainer.innerHTML="";return}if(i==="badges")this.badgesContainer.className=`ms__badges ms__badges--${this.effectiveBadgesPosition}`,this.badgesContainer.innerHTML=e.map(r=>this.renderBadgeHTML(r,{displayMode:"badges",isInPopover:!1})).join("");else if(i==="partial"){this.badgesContainer.className=`ms__badges ms__badges--${this.effectiveBadgesPosition}`;const r=this.options.badgesMaxVisible||3,n=e.slice(0,r),a=t-r,l=n.map(d=>this.renderBadgeHTML(d,{displayMode:"partial",isInPopover:!1})).join("");let c="";a>0&&(c=`
3
3
  <div class="ms__badge ms__badge--counter ms__badge--more" data-action="show-selected">
4
4
  <span class="ms__badge-text">${this.options.getCounterCallback?this.options.getCounterCallback(t,a):`+${a} more`}</span>
5
5
  <button type="button" class="ms__badge-remove" data-action="remove-hidden" aria-label="Remove ${a} hidden items"></button>
@@ -14,7 +14,7 @@
14
14
  <span class="ms__badge-text">${r}</span>
15
15
  <button type="button" class="ms__badge-remove" data-action="clear-count" aria-label="Clear all selections"></button>
16
16
  </div>
17
- `}else this.badgesContainer.innerHTML="";this.attachBadgeTooltips()}attachEvents(){this.input.addEventListener("mousedown",e=>{e.stopPropagation(),this.isOpen?(this.justClosedViaClick=!0,this.close(),setTimeout(()=>{this.justClosedViaClick=!1},0)):this.open()}),this.input.addEventListener("focus",()=>{!this.isOpen&&!this.justClosedViaClick&&this.open()}),this.input.addEventListener("input",e=>{const t=e.target.value;this.options.isSearchEnabled&&!this.isOpen&&this.open(),this.handleSearch(t)}),this.input.addEventListener("keydown",e=>this.handleKeydown(e)),this.documentClickHandler=e=>this.handleClickOutside(e),setTimeout(()=>{document.addEventListener("click",this.documentClickHandler)},0),this.documentKeydownHandler=e=>{e.key==="Escape"&&this.showSelectedPopover&&(e.preventDefault(),this.hideSelectedPopover())},document.addEventListener("keydown",this.documentKeydownHandler),this.dropdown.addEventListener("click",e=>this.handleDropdownClick(e)),this.dropdownInner.addEventListener("wheel",e=>{if(this.virtualScroll)return;const t=e.currentTarget,i=t.scrollTop===0,s=t.scrollTop+t.clientHeight>=t.scrollHeight;(e.deltaY<0&&i||e.deltaY>0&&s)&&e.preventDefault(),e.stopPropagation()},{passive:!1}),this.badgesContainer.addEventListener("mousedown",e=>{e.target.closest('[data-action="show-selected"]')&&!this.showSelectedPopover&&e.stopPropagation()}),this.badgesContainer.addEventListener("click",e=>this.handleBadgeClick(e)),this.counter.addEventListener("mousedown",e=>{this.showSelectedPopover||e.stopPropagation()}),this.counter.addEventListener("click",e=>{e.stopPropagation(),this.toggleSelectedPopover()}),this.selectedPopover.addEventListener("click",e=>this.handleSelectedPopoverClick(e))}async handleSearch(e){if(this.searchTerm=e,!this.options.isSearchEnabled)return;let t=e;if(this.options.beforeSearchCallback){const i=this.options.beforeSearchCallback(e);if(i===null){j.debug(`[${this.instanceId}] beforeSearchCallback blocked search for term:`,e),this.abortInFlightSearch(),this.matchingIndices.clear(),this.isTreeMode()?(this.searchTerm="",this.rebuildTreeVisible()):this.filteredOptions=[...this.allOptions],this.renderDropdown();return}t=i,t!==e&&j.debug(`[${this.instanceId}] beforeSearchCallback transformed: "${e}" -> "${t}"`)}if(this.options.searchCallback){if(t.length<this.options.minSearchLength){this.abortInFlightSearch(),this.isLoading=!1,this.options.isKeepOptionsOnSearch?(this.isTreeMode()?this.rebuildTreeVisibleFromMatches(this.allOptions):this.filteredOptions=[...this.allOptions],j.debug(`[${this.instanceId}] Search term below minimum, showing ${this.allOptions.length} initial options`)):(this.filteredOptions=[],this.isTreeMode()&&(this.treeNodes=[])),this.matchingIndices.clear(),this.renderDropdown();return}this.searchDebounceTimer&&(clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=void 0);const i=this.options.searchDebounce||0;i>0?this.searchDebounceTimer=setTimeout(()=>{this.searchDebounceTimer=void 0,this.searchTerm===e&&this.performAsyncSearch(e,t)},i):await this.performAsyncSearch(e,t)}else{if(this.isTreeMode()){this.rebuildTreeVisible(),this.matchingIndices.clear(),this.focusedIndex=this.filteredOptions.length>0?0:-1,this.renderDropdown();return}if(!t)this.filteredOptions=[...this.allOptions],this.matchingIndices.clear(),this.focusedIndex=this.filteredOptions.length>0?0:-1;else{const i=this.options.searchMode||"filter",s=t.toLowerCase();if(i==="filter")this.filteredOptions=this.allOptions.filter(r=>this.getItemSearchValue(r).toLowerCase().includes(s)),this.matchingIndices.clear(),this.focusedIndex=this.filteredOptions.length>0?0:-1,j.debug(`[${this.instanceId}] Filter mode: ${this.filteredOptions.length} matches for "${t}"`);else{this.filteredOptions=[...this.allOptions],this.matchingIndices.clear();let r=-1;this.allOptions.forEach((n,a)=>{this.getItemSearchValue(n).toLowerCase().includes(s)&&(this.matchingIndices.add(a),r===-1&&(r=a))}),r>=0?(this.focusedIndex=r,j.debug(`[${this.instanceId}] Navigate mode: ${this.matchingIndices.size} matches, jumped to index ${r}`)):j.debug(`[${this.instanceId}] Navigate mode: No matches found, keeping previous focus`)}}this.renderDropdown(),this.options.searchMode==="navigate"&&this.focusedIndex>=0&&this.scrollToFocused()}}abortInFlightSearch(){this.searchAbortController&&(this.searchAbortController.abort(),this.searchAbortController=void 0)}async performAsyncSearch(e,t){this.abortInFlightSearch();const i=new AbortController;this.searchAbortController=i,this.isLoading=!0,this.renderDropdown(),j.debug(`[${this.instanceId}] Loading data for search term:`,t);try{const s=await this.options.searchCallback(t,i.signal);if(i.signal.aborted||this.searchTerm!==e)return;const r=s||[];this.isTreeMode()?this.rebuildTreeVisibleFromMatches(r):this.filteredOptions=[...r],this.isLoading=!1,this.matchingIndices.clear(),this.focusedIndex=this.options.isSearchEnabled&&this.filteredOptions.length>0?0:-1,this.renderDropdown(),j.debug(`[${this.instanceId}] Loaded ${r.length} results`)}catch(s){if(i.signal.aborted)return;j.error(`[${this.instanceId}] Error loading data:`,s),this.isLoading=!1,this.options.isKeepOptionsOnSearch?this.isTreeMode()?this.rebuildTreeVisibleFromMatches(this.allOptions):this.filteredOptions=[...this.allOptions]:(this.filteredOptions=[],this.isTreeMode()&&(this.treeNodes=[])),this.matchingIndices.clear(),this.renderDropdown()}finally{this.searchAbortController===i&&(this.searchAbortController=void 0)}}handleKeydown(e){if(!this.isOpen){(e.key==="Enter"||e.key==="ArrowDown")&&(e.preventDefault(),this.open());return}if(!this.options.isSearchEnabled){const t=e.key.length===1||e.key==="Backspace"||e.key==="Delete",i=["ArrowUp","ArrowDown","PageUp","PageDown","Home","End","Enter","Escape","Tab"].includes(e.key);if(t&&!i){e.preventDefault();return}}switch(e.key){case"ArrowDown":e.preventDefault(),e.ctrlKey||e.metaKey?this.focusNextMatch():this.focusNext();break;case"ArrowUp":e.preventDefault(),e.ctrlKey||e.metaKey?this.focusPreviousMatch():this.focusPrevious();break;case"Enter":e.preventDefault(),this.focusedIndex>=0?this.toggleOption(this.filteredOptions[this.focusedIndex]):this.options.isAddNewAllowed&&this.options.addNewCallback&&this.input.value.trim()&&this.handleAddNew(this.input.value.trim());break;case"Escape":e.preventDefault(),this.showSelectedPopover?this.hideSelectedPopover():this.input.value?(this.input.value="",this.searchTerm="",this.resetVisibleToAll(),this.matchingIndices.clear(),this.focusedIndex=-1,this.renderDropdown()):this.close();break;case"Tab":this.close();break;case"PageUp":e.preventDefault(),this.focusPageUp();break;case"PageDown":e.preventDefault(),this.focusPageDown();break;case"Home":e.preventDefault(),this.focusFirst();break;case"End":e.preventDefault(),this.focusLast();break}}handleDropdownClick(e){var s;G.debug(`[${this.instanceId}] Dropdown clicked`,{target:e.target.className}),e.stopPropagation();const t=e.target.closest("[data-action]");if(t){e.preventDefault();const r=t.dataset.action;if(G.debug(`[${this.instanceId}] Action button clicked:`,r),r==="select-all")this.selectAll();else if(r==="clear-all")this.clearAll();else if(r==="custom"){const n=parseInt(t.dataset.buttonIndex||"-1"),a=(s=this.options.actionButtons)==null?void 0:s[n];a!=null&&a.onClick&&a.onClick(this)}return}const i=e.target.closest(".ms__option");if(i&&!i.classList.contains("ms__option--disabled")){e.preventDefault();const r=i.dataset.value,n=this.filteredOptions.findIndex(a=>String(this.getItemValue(a))===r);G.debug(`[${this.instanceId}] Option clicked:`,{value:r,optionIndex:n,closeOnSelect:this.options.isCloseOnSelect,placeholder:this.options.searchPlaceholder}),n>=0&&(this.focusedIndex=n,this.toggleOption(this.filteredOptions[n]),this.isOpen&&this.input.focus())}}handleBadgeClick(e){if(e.target.closest('[data-action="clear-count"]')){e.preventDefault(),e.stopPropagation(),G.debug(`[${this.instanceId}] Clear count button clicked`),this.clearAll();return}if(e.target.closest('[data-action="show-selected"]')){e.preventDefault(),e.stopPropagation(),this.toggleSelectedPopover();return}const s=e.target.closest(".ms__badge-remove");if(s){if(e.preventDefault(),e.stopPropagation(),s.dataset.action==="remove-hidden"){G.debug(`[${this.instanceId}] Remove hidden items button clicked`);const l=this.options.badgesMaxVisible||3;Array.from(this.selectedOptions.values()).slice(l).forEach(h=>this.interactiveDeselect(h));return}const n=s.dataset.value,a=this.selectedOptions.get(n);a&&this.interactiveDeselect(a);return}if(e.target.closest(".ms__badge--more")&&!e.target.closest(".ms__badge-remove")){e.preventDefault(),e.stopPropagation(),G.debug(`[${this.instanceId}] '+X more' badge clicked, showing popover`),this.toggleSelectedPopover();return}}handleClickOutside(e){var s;const t=e.composedPath();if(this.showSelectedPopover&&!t.some(n=>n instanceof Node&&(this.selectedPopover.contains(n)||this.counter.contains(n)||n.closest&&n.closest('[data-action="show-selected"]')))){J.debug(`[${this.instanceId}] Closing selected popover due to click outside`),this.hideSelectedPopover();return}if(!this.isOpen)return;const i=t.some(r=>r instanceof Node&&(this.element.contains(r)||this.dropdown.contains(r)||this.hint&&this.hint.contains(r)));G.debug(`[${this.instanceId}] handleClickOutside`,{target:e.target.className,targetTag:e.target.tagName,clickedInside:i,pathLength:t.length,firstInPath:(s=t[0])==null?void 0:s.tagName,elementContains:t.some(r=>r instanceof Node&&this.element.contains(r)),dropdownContains:t.some(r=>r instanceof Node&&this.dropdown.contains(r)),isConnected:this.dropdown.isConnected}),i||(G.warn(`[${this.instanceId}] Closing dropdown due to click outside`),this.close())}focusBy(e,t=1){const i=this.filteredOptions.length;if(i===0)return;const s=e(this.focusedIndex,i);if(s<0)return;const r=this.resolveSelectableIndex(s,t,i);r<0||(this.focusedIndex=r,this.renderDropdown(),this.scrollToFocused())}resolveSelectableIndex(e,t,i){if(!this.isTreeMode())return e;let s=e;for(;s>=0&&s<i&&!this.isIndexSelectable(s);)s+=t;if(s<0||s>=i)for(s=e-t;s>=0&&s<i&&!this.isIndexSelectable(s);)s-=t;return s>=0&&s<i?s:-1}focusNext(){this.focusBy((e,t)=>Math.min(t-1,e+1),1)}focusPrevious(){this.focusBy(e=>Math.max(0,e-1),-1)}focusFirst(){this.focusBy(()=>0,1)}focusLast(){this.focusBy((e,t)=>t-1,-1)}focusPageUp(){this.focusBy(e=>Math.max(0,e-10),-1)}focusPageDown(){this.focusBy((e,t)=>Math.min(t-1,e+10),1)}focusNextMatch(){if(this.matchingIndices.size===0)return;const e=Array.from(this.matchingIndices).sort((s,r)=>s-r),t=e.findIndex(s=>s===this.focusedIndex),i=(t+1)%e.length;this.focusBy(()=>e[i]),G.debug(`[${this.instanceId}] Jumped to next match: index ${this.focusedIndex} (${t+1} of ${e.length})`)}focusPreviousMatch(){if(this.matchingIndices.size===0)return;const e=Array.from(this.matchingIndices).sort((s,r)=>s-r),t=e.findIndex(s=>s===this.focusedIndex),i=t<=0?e.length-1:t-1;this.focusBy(()=>e[i]),G.debug(`[${this.instanceId}] Jumped to previous match: index ${this.focusedIndex} (${t+1} of ${e.length})`)}scrollToFocused(){if(this.virtualScroll&&this.focusedIndex>=0)this.virtualScroll.scrollToIndex(this.focusedIndex);else{const e=this.dropdown.querySelector(".ms__option--focused");e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}}toggleOption(e){if(this.getItemDisabled(e)){G.debug(`[${this.instanceId}] toggleOption ignored — option is disabled`);return}if(!this.isOptionSelectable(e)){G.debug(`[${this.instanceId}] toggleOption ignored — node is not selectable`);return}const t=this.getItemValue(e),i=String(t);if(G.debug(`[${this.instanceId}] toggleOption called`,{value:t,multiple:this.options.isMultipleEnabled}),this.isCascadeMode()&&this.cascadeIndex){const n=this.cascadeIndex.nodeByValue.get(i);if(n){this.toggleTreeCascade(n),this.options.isCloseOnSelect&&this.close();return}}(this.selectedValues.has(i)?this.interactiveDeselect(e):this.interactiveSelect(e))&&(this.options.isMultipleEnabled?this.options.isCloseOnSelect&&this.close():this.close())}interactiveSelect(e){return this.options.beforeSelectCallback&&this.options.beforeSelectCallback(e,this.getSelected())===!1?(G.debug(`[${this.instanceId}] Selection blocked by beforeSelectCallback`),!1):(this.options.isMultipleEnabled||(this.selectedValues.clear(),this.selectedOptions.clear()),this.selectOption(e),!0)}interactiveDeselect(e){return this.options.beforeDeselectCallback&&this.options.beforeDeselectCallback(e,this.getSelected())===!1?(G.debug(`[${this.instanceId}] Deselection blocked by beforeDeselectCallback`),!1):(this.deselectOption(e),!0)}async handleAddNew(e){if(this.options.addNewCallback)try{j.debug(`[${this.instanceId}] Adding new option:`,e);const t=await this.options.addNewCallback(e);this.allOptions.push(t),this.filteredOptions.push(t),this.selectOption(t),this.input.value="",this.renderDropdown(),this.renderBadges(),this.options.isCloseOnSelect&&this.close()}catch(t){j.error(`[${this.instanceId}] Error adding new option:`,t)}}selectOption(e){const t=this.getItemValue(e),i=String(t);this.selectedValues.add(i),this.selectedOptions.set(i,e),this.commit({added:[e]})}deselectOption(e){const t=this.getItemValue(e),i=String(t);if(this.isCascadeMode()&&this.cascadeIndex){const s=this.cascadeIndex.nodeByValue.get(i);if(s){const r=this.cascadeIndex.atomsUnder.get(s.path)??[],n=new Set(Ke(this.cascadeIndex,this.selectedValues));for(const a of r)n.delete(a);this.commitCascadeAtoms(n);return}}this.selectedValues.delete(i),this.selectedOptions.delete(i),this.commit({removed:[e]})}selectAll(){if(this.isCascadeMode()&&this.cascadeIndex){const t=this.cascadeIndex,i=new Set(Ke(t,this.selectedValues));for(const s of this.treeNodes)t.atomPaths.has(s.path)&&(this.getItemDisabled(s.data)||i.add(String(this.getItemValue(s.data))));this.commitCascadeAtoms(i);return}const e=[];this.filteredOptions.forEach((t,i)=>{if(this.getItemDisabled(t)||!this.isIndexSelectable(i))return;const s=String(this.getItemValue(t));this.selectedValues.has(s)||(this.selectedValues.add(s),this.selectedOptions.set(s,t),e.push(t))}),this.commit({added:e})}clearAll(){const e=Array.from(this.selectedOptions.values());this.selectedValues.clear(),this.selectedOptions.clear(),this.commit({removed:e})}commit(e){this.renderDropdown(),this.renderBadges(),this.updateHiddenInput();const t=e.added??[],i=e.removed??[];this.options.onSelect&&t.forEach(s=>this.options.onSelect(s)),this.options.onDeselect&&i.forEach(s=>this.options.onDeselect(s)),(t.length>0||i.length>0)&&this.options.onChange&&this.options.onChange(this.getSelected())}open(){J.debug(`[${this.instanceId}] open() called`,{isOpen:this.isOpen}),!this.isOpen&&(this.isOpen=!0,this.element.classList.add("ms--open"),this.dropdown.classList.add("ms__dropdown--visible"),J.info(`[${this.instanceId}] Dropdown opened`),this.input.placeholder=this.getPlaceholderText(),!this.options.isMultipleEnabled&&this.options.isSearchEnabled&&(this.input.value=this.searchTerm),this.options.searchCallback&&this.options.isKeepOptionsOnSearch&&!this.searchTerm&&(this.filteredOptions=[...this.allOptions],J.debug(`[${this.instanceId}] Showing ${this.allOptions.length} initial options on open`)),this.renderDropdown(),this.positionDropdown(),this.dropdown.addEventListener("scroll",this.onDropdownScroll,!0),this.hint&&(this.hint.classList.add("ms__hint--visible"),this.positionHint()))}close(){J.debug(`[${this.instanceId}] close() called`,{isOpen:this.isOpen}),this.isOpen&&(this.isOpen=!1,this.element.classList.remove("ms--open"),this.dropdown.classList.remove("ms__dropdown--visible"),this.hint&&this.hint.classList.remove("ms__hint--visible"),this.options.shouldKeepSearchOnClose||(this.searchTerm="",(this.options.isMultipleEnabled||this.options.isSearchEnabled)&&(this.input.value=""),this.resetVisibleToAll()),this.focusedIndex=-1,this.dropdown.removeEventListener("scroll",this.onDropdownScroll,!0),this.destroyAllOptionTooltips(),this.renderBadges(),this.dropdownCleanup&&(this.dropdownCleanup(),this.dropdownCleanup=null),this.hintCleanup&&(this.hintCleanup(),this.hintCleanup=null),this.dropdownPlacement=null,J.debug(`[${this.instanceId}] Dropdown closed`))}anchorFloatingPanel(e,t){var r;const i=((r=t.isLocked)==null?void 0:r.call(t))??!0,s=_t(e,this.input,{strategy:"fixed",placement:"bottom-start",offset:4,shift:8,lockPlacement:i?"freeze":!1,fixedContainingBlock:!0,onDrift:n=>this.warnDrift(n),beforeCompute:()=>{(this.options.hostElement??this.element).style.setProperty("--ms-input-current-width",`${this.input.offsetWidth}px`),this.options.dropdownMinWidth&&(e.style.minWidth=this.options.dropdownMinWidth),t.applyMaxWidth&&this.options.dropdownMaxWidth&&(e.style.maxWidth=this.options.dropdownMaxWidth)},onPlaced:n=>{var a;t.getPlacement()||t.setPlacement(n),(a=t.afterPosition)==null||a.call(t)}});return()=>s.destroy()}warnDrift(e){this.positioningDriftWarned||(this.positioningDriftWarned=!0,console.warn(`[@keenmate/web-multiselect] Dropdown panel rendered ${e.driftX.toFixed(0)}px / ${e.driftY.toFixed(0)}px away from where the library positioned it. Most likely culprit: ${e.culpritDescription}`+(e.culpritCss?` (has ${e.culpritCss})`:"")+".\nAn ancestor of <web-multiselect> establishes a fixed-positioning containing block that the library's heuristic doesn't recognize. Fix on your side: replace the property with `transform: translateZ(0)` on that ancestor, OR move the trigger out of that ancestor's subtree. If neither is acceptable, please file an issue at https://github.com/keenmate/web-multiselect/issues with the ancestor's computed CSS."))}positionDropdown(){this.dropdownCleanup=this.anchorFloatingPanel(this.dropdown,{getPlacement:()=>this.dropdownPlacement,setPlacement:e=>{this.dropdownPlacement=e,J.debug(`[${this.instanceId}] Locked dropdown placement:`,e)},isLocked:()=>!!this.options.isPlacementLocked,applyMaxWidth:!0,afterPosition:()=>{this.hint&&this.isOpen&&this.positionHint()}})}positionHint(){if(!this.hint)return;this.hintCleanup&&this.hintCleanup();let e="top-start";this.dropdownPlacement&&(this.dropdownPlacement.startsWith("bottom")?e=this.dropdownPlacement.replace("bottom","top"):this.dropdownPlacement.startsWith("top")&&(e=this.dropdownPlacement.replace("top","bottom")));const t=_t(this.hint,this.input,{strategy:"fixed",placement:e,offset:4,shift:8,flip:!1});this.hintCleanup=()=>t.destroy()}parseInitialSelection(){const e=this.element.dataset.initialValues;if(e)try{JSON.parse(e).forEach(i=>{this.selectedValues.add(String(i))}),this.reconcileSelectedOptions(),this.renderBadges()}catch(t){j.error(`[${this.instanceId}] Failed to parse initial values:`,t)}}reconcileSelectedOptions(){this.selectedValues.size===0||this.allOptions.length===0||this.selectedValues.forEach(e=>{if(this.selectedOptions.has(e))return;const t=this.allOptions.find(i=>String(this.getItemValue(i))===e);t&&this.selectedOptions.set(e,t)})}toggleSelectedPopover(){this.showSelectedPopover?this.hideSelectedPopover():this.showPopover()}showPopover(){J.debug(`[${this.instanceId}] showPopover() called`),this.isOpen&&this.close(),this.showSelectedPopover=!0,this.renderSelectedPopover(),this.selectedPopover.classList.add("ms__selected-popover--visible");const e=this.options.virtualScrollThreshold??100;this.selectedValues.size>=e&&this.selectedPopover.classList.add("ms__selected-popover--virtual"),this.positionSelectedPopover()}hideSelectedPopover(){var e;J.debug(`[${this.instanceId}] hideSelectedPopover() called`),this.showSelectedPopover=!1,this.selectedPopover.classList.remove("ms__selected-popover--visible"),this.selectedPopover.classList.remove("ms__selected-popover--virtual"),this.selectedPopoverPlacement=null,this.selectedPopoverVirtualScroll&&(this.selectedPopoverVirtualScroll.destroy(),this.selectedPopoverVirtualScroll=null,this.selectedPopoverContainer=null),this.selectedPopoverCleanup&&(this.selectedPopoverCleanup(),this.selectedPopoverCleanup=null);for(const t of Array.from(this.tooltips.keys()))t.startsWith("popover-")&&((e=this.tooltips.get(t))==null||e.destroy(),this.tooltips.delete(t))}renderSelectedPopover(){const e=Array.from(this.selectedOptions.values()),t=this.selectedValues.size,i=this.options.virtualScrollThreshold??100;if(t>=i){this.renderSelectedPopoverVirtual(e,t);return}this.selectedPopover.innerHTML=`
17
+ `}else this.badgesContainer.innerHTML="";this.attachBadgeTooltips()}attachEvents(){this.input.addEventListener("mousedown",e=>{e.stopPropagation(),this.isOpen?(this.justClosedViaClick=!0,this.close(),setTimeout(()=>{this.justClosedViaClick=!1},0)):this.open()}),this.input.addEventListener("focus",()=>{!this.isOpen&&!this.justClosedViaClick&&this.open()}),this.input.addEventListener("input",e=>{const t=e.target.value;this.options.isSearchEnabled&&!this.isOpen&&this.open(),this.handleSearch(t)}),this.input.addEventListener("keydown",e=>this.handleKeydown(e)),this.documentClickHandler=e=>this.handleClickOutside(e),setTimeout(()=>{document.addEventListener("click",this.documentClickHandler)},0),this.documentKeydownHandler=e=>{e.key==="Escape"&&this.showSelectedPopover&&(e.preventDefault(),this.hideSelectedPopover())},document.addEventListener("keydown",this.documentKeydownHandler),this.dropdown.addEventListener("click",e=>this.handleDropdownClick(e)),this.dropdownInner.addEventListener("wheel",e=>{if(this.virtualScroll)return;const t=e.currentTarget,i=t.scrollTop===0,s=t.scrollTop+t.clientHeight>=t.scrollHeight;(e.deltaY<0&&i||e.deltaY>0&&s)&&e.preventDefault(),e.stopPropagation()},{passive:!1}),this.badgesContainer.addEventListener("mousedown",e=>{e.target.closest('[data-action="show-selected"]')&&!this.showSelectedPopover&&e.stopPropagation()}),this.badgesContainer.addEventListener("click",e=>this.handleBadgeClick(e)),this.counter.addEventListener("mousedown",e=>{this.showSelectedPopover||e.stopPropagation()}),this.counter.addEventListener("click",e=>{e.stopPropagation(),this.toggleSelectedPopover()}),this.selectedPopover.addEventListener("click",e=>this.handleSelectedPopoverClick(e))}async handleSearch(e){if(this.searchTerm=e,!this.options.isSearchEnabled)return;let t=e;if(this.options.beforeSearchCallback){const i=this.options.beforeSearchCallback(e);if(i===null){j.debug(`[${this.instanceId}] beforeSearchCallback blocked search for term:`,e),this.abortInFlightSearch(),this.matchingIndices.clear(),this.isTreeMode()?(this.searchTerm="",this.rebuildTreeVisible()):this.filteredOptions=[...this.allOptions],this.renderDropdown();return}t=i,t!==e&&j.debug(`[${this.instanceId}] beforeSearchCallback transformed: "${e}" -> "${t}"`)}if(this.options.searchCallback){if(t.length<this.options.minSearchLength){this.abortInFlightSearch(),this.isLoading=!1,this.options.isKeepOptionsOnSearch?(this.isTreeMode()?this.rebuildTreeVisibleFromMatches(this.allOptions):this.filteredOptions=[...this.allOptions],j.debug(`[${this.instanceId}] Search term below minimum, showing ${this.allOptions.length} initial options`)):(this.filteredOptions=[],this.isTreeMode()&&(this.treeNodes=[])),this.matchingIndices.clear(),this.renderDropdown();return}this.searchDebounceTimer&&(clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=void 0);const i=this.options.searchDebounce||0;i>0?this.searchDebounceTimer=setTimeout(()=>{this.searchDebounceTimer=void 0,this.searchTerm===e&&this.performAsyncSearch(e,t)},i):await this.performAsyncSearch(e,t)}else{if(this.isTreeMode()){this.rebuildTreeVisible(),this.matchingIndices.clear(),this.focusedIndex=this.filteredOptions.length>0?0:-1,this.renderDropdown();return}if(!t)this.filteredOptions=[...this.allOptions],this.matchingIndices.clear(),this.focusedIndex=this.filteredOptions.length>0?0:-1;else{const i=this.options.searchMode||"filter",s=t.toLowerCase();if(i==="filter")this.filteredOptions=this.allOptions.filter(r=>this.getItemSearchValue(r).toLowerCase().includes(s)),this.matchingIndices.clear(),this.focusedIndex=this.filteredOptions.length>0?0:-1,j.debug(`[${this.instanceId}] Filter mode: ${this.filteredOptions.length} matches for "${t}"`);else{this.filteredOptions=[...this.allOptions],this.matchingIndices.clear();let r=-1;this.allOptions.forEach((n,a)=>{this.getItemSearchValue(n).toLowerCase().includes(s)&&(this.matchingIndices.add(a),r===-1&&(r=a))}),r>=0?(this.focusedIndex=r,j.debug(`[${this.instanceId}] Navigate mode: ${this.matchingIndices.size} matches, jumped to index ${r}`)):j.debug(`[${this.instanceId}] Navigate mode: No matches found, keeping previous focus`)}}this.renderDropdown(),this.options.searchMode==="navigate"&&this.focusedIndex>=0&&this.scrollToFocused()}}abortInFlightSearch(){this.searchAbortController&&(this.searchAbortController.abort(),this.searchAbortController=void 0)}async performAsyncSearch(e,t){this.abortInFlightSearch();const i=new AbortController;this.searchAbortController=i,this.isLoading=!0,this.renderDropdown(),j.debug(`[${this.instanceId}] Loading data for search term:`,t);try{const s=await this.options.searchCallback(t,i.signal);if(i.signal.aborted||this.searchTerm!==e)return;const r=s||[];this.isTreeMode()?this.rebuildTreeVisibleFromMatches(r):this.filteredOptions=[...r],this.isLoading=!1,this.matchingIndices.clear(),this.focusedIndex=this.options.isSearchEnabled&&this.filteredOptions.length>0?0:-1,this.renderDropdown(),j.debug(`[${this.instanceId}] Loaded ${r.length} results`)}catch(s){if(i.signal.aborted)return;j.error(`[${this.instanceId}] Error loading data:`,s),this.isLoading=!1,this.options.isKeepOptionsOnSearch?this.isTreeMode()?this.rebuildTreeVisibleFromMatches(this.allOptions):this.filteredOptions=[...this.allOptions]:(this.filteredOptions=[],this.isTreeMode()&&(this.treeNodes=[])),this.matchingIndices.clear(),this.renderDropdown()}finally{this.searchAbortController===i&&(this.searchAbortController=void 0)}}handleKeydown(e){if(!this.isOpen){(e.key==="Enter"||e.key==="ArrowDown")&&(e.preventDefault(),this.open());return}if(!this.options.isSearchEnabled){const t=e.key.length===1||e.key==="Backspace"||e.key==="Delete",i=["ArrowUp","ArrowDown","PageUp","PageDown","Home","End","Enter","Escape","Tab"].includes(e.key);if(t&&!i){e.preventDefault();return}}switch(e.key){case"ArrowDown":e.preventDefault(),e.ctrlKey||e.metaKey?this.focusNextMatch():this.focusNext();break;case"ArrowUp":e.preventDefault(),e.ctrlKey||e.metaKey?this.focusPreviousMatch():this.focusPrevious();break;case"Enter":e.preventDefault(),this.focusedIndex>=0?this.toggleOption(this.filteredOptions[this.focusedIndex]):this.options.isAddNewAllowed&&this.options.addNewCallback&&this.input.value.trim()&&this.handleAddNew(this.input.value.trim());break;case"Escape":e.preventDefault(),this.showSelectedPopover?this.hideSelectedPopover():this.input.value?(this.input.value="",this.searchTerm="",this.resetVisibleToAll(),this.matchingIndices.clear(),this.focusedIndex=-1,this.renderDropdown()):this.close();break;case"Tab":this.close();break;case"PageUp":e.preventDefault(),this.focusPageUp();break;case"PageDown":e.preventDefault(),this.focusPageDown();break;case"Home":e.preventDefault(),this.focusFirst();break;case"End":e.preventDefault(),this.focusLast();break}}handleDropdownClick(e){var s;G.debug(`[${this.instanceId}] Dropdown clicked`,{target:e.target.className}),e.stopPropagation();const t=e.target.closest("[data-action]");if(t){e.preventDefault();const r=t.dataset.action;if(G.debug(`[${this.instanceId}] Action button clicked:`,r),r==="select-all")this.selectAll();else if(r==="clear-all")this.clearAll();else if(r==="custom"){const n=parseInt(t.dataset.buttonIndex||"-1"),a=(s=this.options.actionButtons)==null?void 0:s[n];a!=null&&a.onClick&&a.onClick(this)}return}const i=e.target.closest(".ms__option");if(i&&!i.classList.contains("ms__option--disabled")){e.preventDefault();const r=i.dataset.value,n=this.filteredOptions.findIndex(a=>String(this.getItemValue(a))===r);G.debug(`[${this.instanceId}] Option clicked:`,{value:r,optionIndex:n,closeOnSelect:this.options.isCloseOnSelect,placeholder:this.options.searchPlaceholder}),n>=0&&(this.focusedIndex=n,this.toggleOption(this.filteredOptions[n]),this.isOpen&&this.input.focus())}}handleBadgeClick(e){if(e.target.closest('[data-action="clear-count"]')){e.preventDefault(),e.stopPropagation(),G.debug(`[${this.instanceId}] Clear count button clicked`),this.clearAll();return}if(e.target.closest('[data-action="show-selected"]')){e.preventDefault(),e.stopPropagation(),this.toggleSelectedPopover();return}const s=e.target.closest(".ms__badge-remove");if(s){if(e.preventDefault(),e.stopPropagation(),s.dataset.action==="remove-hidden"){G.debug(`[${this.instanceId}] Remove hidden items button clicked`);const l=this.options.badgesMaxVisible||3;Array.from(this.selectedOptions.values()).slice(l).forEach(h=>this.interactiveDeselect(h));return}const n=s.dataset.value,a=this.selectedOptions.get(n);a&&this.interactiveDeselect(a);return}if(e.target.closest(".ms__badge--more")&&!e.target.closest(".ms__badge-remove")){e.preventDefault(),e.stopPropagation(),G.debug(`[${this.instanceId}] '+X more' badge clicked, showing popover`),this.toggleSelectedPopover();return}}handleClickOutside(e){var s;const t=e.composedPath();if(this.showSelectedPopover&&!t.some(n=>n instanceof Node&&(this.selectedPopover.contains(n)||this.counter.contains(n)||n.closest&&n.closest('[data-action="show-selected"]')))){J.debug(`[${this.instanceId}] Closing selected popover due to click outside`),this.hideSelectedPopover();return}if(!this.isOpen)return;const i=t.some(r=>r instanceof Node&&(this.element.contains(r)||this.dropdown.contains(r)||this.hint&&this.hint.contains(r)));G.debug(`[${this.instanceId}] handleClickOutside`,{target:e.target.className,targetTag:e.target.tagName,clickedInside:i,pathLength:t.length,firstInPath:(s=t[0])==null?void 0:s.tagName,elementContains:t.some(r=>r instanceof Node&&this.element.contains(r)),dropdownContains:t.some(r=>r instanceof Node&&this.dropdown.contains(r)),isConnected:this.dropdown.isConnected}),i||(G.warn(`[${this.instanceId}] Closing dropdown due to click outside`),this.close())}focusBy(e,t=1){const i=this.filteredOptions.length;if(i===0)return;const s=e(this.focusedIndex,i);if(s<0)return;const r=this.resolveSelectableIndex(s,t,i);r<0||(this.focusedIndex=r,this.renderDropdown(),this.scrollToFocused())}resolveSelectableIndex(e,t,i){if(!this.isTreeMode())return e;let s=e;for(;s>=0&&s<i&&!this.isIndexSelectable(s);)s+=t;if(s<0||s>=i)for(s=e-t;s>=0&&s<i&&!this.isIndexSelectable(s);)s-=t;return s>=0&&s<i?s:-1}focusNext(){this.focusBy((e,t)=>Math.min(t-1,e+1),1)}focusPrevious(){this.focusBy(e=>Math.max(0,e-1),-1)}focusFirst(){this.focusBy(()=>0,1)}focusLast(){this.focusBy((e,t)=>t-1,-1)}focusPageUp(){this.focusBy(e=>Math.max(0,e-10),-1)}focusPageDown(){this.focusBy((e,t)=>Math.min(t-1,e+10),1)}focusNextMatch(){if(this.matchingIndices.size===0)return;const e=Array.from(this.matchingIndices).sort((s,r)=>s-r),t=e.findIndex(s=>s===this.focusedIndex),i=(t+1)%e.length;this.focusBy(()=>e[i]),G.debug(`[${this.instanceId}] Jumped to next match: index ${this.focusedIndex} (${t+1} of ${e.length})`)}focusPreviousMatch(){if(this.matchingIndices.size===0)return;const e=Array.from(this.matchingIndices).sort((s,r)=>s-r),t=e.findIndex(s=>s===this.focusedIndex),i=t<=0?e.length-1:t-1;this.focusBy(()=>e[i]),G.debug(`[${this.instanceId}] Jumped to previous match: index ${this.focusedIndex} (${t+1} of ${e.length})`)}scrollToFocused(){if(this.virtualScroll&&this.focusedIndex>=0)this.virtualScroll.scrollToIndex(this.focusedIndex);else{const e=this.dropdown.querySelector(".ms__option--focused");e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}}toggleOption(e){if(this.getItemDisabled(e)){G.debug(`[${this.instanceId}] toggleOption ignored — option is disabled`);return}if(!this.isOptionSelectable(e)){G.debug(`[${this.instanceId}] toggleOption ignored — node is not selectable`);return}const t=this.getItemValue(e),i=String(t);if(G.debug(`[${this.instanceId}] toggleOption called`,{value:t,multiple:this.options.isMultipleEnabled}),this.isCascadeMode()&&this.cascadeIndex){const n=this.cascadeIndex.nodeByValue.get(i);if(n){this.toggleTreeCascade(n),this.options.isCloseOnSelect&&this.close();return}}(this.selectedValues.has(i)?this.interactiveDeselect(e):this.interactiveSelect(e))&&(this.options.isMultipleEnabled?this.options.isCloseOnSelect&&this.close():this.close())}interactiveSelect(e){return this.options.beforeSelectCallback&&this.options.beforeSelectCallback(e,this.getSelected())===!1?(G.debug(`[${this.instanceId}] Selection blocked by beforeSelectCallback`),!1):(this.options.isMultipleEnabled||(this.selectedValues.clear(),this.selectedOptions.clear()),this.selectOption(e),!0)}interactiveDeselect(e){return this.options.beforeDeselectCallback&&this.options.beforeDeselectCallback(e,this.getSelected())===!1?(G.debug(`[${this.instanceId}] Deselection blocked by beforeDeselectCallback`),!1):(this.deselectOption(e),!0)}async handleAddNew(e){if(this.options.addNewCallback)try{j.debug(`[${this.instanceId}] Adding new option:`,e);const t=await this.options.addNewCallback(e);this.allOptions.push(t),this.filteredOptions.push(t),this.selectOption(t),this.input.value="",this.renderDropdown(),this.renderBadges(),this.options.isCloseOnSelect&&this.close()}catch(t){j.error(`[${this.instanceId}] Error adding new option:`,t)}}selectOption(e){const t=this.getItemValue(e),i=String(t);this.selectedValues.add(i),this.selectedOptions.set(i,e),this.commit({added:[e]})}deselectOption(e){const t=this.getItemValue(e),i=String(t);if(this.isCascadeMode()&&this.cascadeIndex){const s=this.cascadeIndex.nodeByValue.get(i);if(s){const r=this.cascadeIndex.atomsUnder.get(s.path)??[],n=new Set(He(this.cascadeIndex,this.selectedValues));for(const a of r)n.delete(a);this.commitCascadeAtoms(n);return}}this.selectedValues.delete(i),this.selectedOptions.delete(i),this.commit({removed:[e]})}selectAll(){if(this.isCascadeMode()&&this.cascadeIndex){const t=this.cascadeIndex,i=new Set(He(t,this.selectedValues));for(const s of this.treeNodes)t.atomPaths.has(s.path)&&(this.getItemDisabled(s.data)||i.add(String(this.getItemValue(s.data))));this.commitCascadeAtoms(i);return}const e=[];this.filteredOptions.forEach((t,i)=>{if(this.getItemDisabled(t)||!this.isIndexSelectable(i))return;const s=String(this.getItemValue(t));this.selectedValues.has(s)||(this.selectedValues.add(s),this.selectedOptions.set(s,t),e.push(t))}),this.commit({added:e})}clearAll(){const e=Array.from(this.selectedOptions.values());this.selectedValues.clear(),this.selectedOptions.clear(),this.commit({removed:e})}commit(e){this.renderDropdown(),this.renderBadges(),this.updateHiddenInput();const t=e.added??[],i=e.removed??[];this.options.onSelect&&t.forEach(s=>this.options.onSelect(s)),this.options.onDeselect&&i.forEach(s=>this.options.onDeselect(s)),(t.length>0||i.length>0)&&this.options.onChange&&this.options.onChange(this.getSelected())}open(){J.debug(`[${this.instanceId}] open() called`,{isOpen:this.isOpen}),!this.isOpen&&(this.isOpen=!0,this.element.classList.add("ms--open"),this.dropdown.classList.add("ms__dropdown--visible"),J.info(`[${this.instanceId}] Dropdown opened`),this.input.placeholder=this.getPlaceholderText(),!this.options.isMultipleEnabled&&this.options.isSearchEnabled&&(this.input.value=this.searchTerm),this.options.searchCallback&&this.options.isKeepOptionsOnSearch&&!this.searchTerm&&(this.filteredOptions=[...this.allOptions],J.debug(`[${this.instanceId}] Showing ${this.allOptions.length} initial options on open`)),this.renderDropdown(),this.positionDropdown(),this.dropdown.addEventListener("scroll",this.onDropdownScroll,!0),this.hint&&(this.hint.classList.add("ms__hint--visible"),this.positionHint()))}close(){J.debug(`[${this.instanceId}] close() called`,{isOpen:this.isOpen}),this.isOpen&&(this.isOpen=!1,this.element.classList.remove("ms--open"),this.dropdown.classList.remove("ms__dropdown--visible"),this.hint&&this.hint.classList.remove("ms__hint--visible"),this.options.shouldKeepSearchOnClose||(this.searchTerm="",(this.options.isMultipleEnabled||this.options.isSearchEnabled)&&(this.input.value=""),this.resetVisibleToAll()),this.focusedIndex=-1,this.dropdown.removeEventListener("scroll",this.onDropdownScroll,!0),this.destroyAllOptionTooltips(),this.renderBadges(),this.dropdownCleanup&&(this.dropdownCleanup(),this.dropdownCleanup=null),this.hintCleanup&&(this.hintCleanup(),this.hintCleanup=null),this.dropdownPlacement=null,J.debug(`[${this.instanceId}] Dropdown closed`))}anchorFloatingPanel(e,t){var r;const i=((r=t.isLocked)==null?void 0:r.call(t))??!0,s=_t(e,this.input,{strategy:"fixed",placement:"bottom-start",offset:4,shift:8,lockPlacement:i?"freeze":!1,fixedContainingBlock:!0,onDrift:n=>this.warnDrift(n),beforeCompute:()=>{(this.options.hostElement??this.element).style.setProperty("--ms-input-current-width",`${this.input.offsetWidth}px`),this.options.dropdownMinWidth&&(e.style.minWidth=this.options.dropdownMinWidth),t.applyMaxWidth&&this.options.dropdownMaxWidth&&(e.style.maxWidth=this.options.dropdownMaxWidth)},onPlaced:n=>{var a;t.getPlacement()||t.setPlacement(n),(a=t.afterPosition)==null||a.call(t)}});return()=>s.destroy()}warnDrift(e){this.positioningDriftWarned||(this.positioningDriftWarned=!0,console.warn(`[@keenmate/web-multiselect] Dropdown panel rendered ${e.driftX.toFixed(0)}px / ${e.driftY.toFixed(0)}px away from where the library positioned it. Most likely culprit: ${e.culpritDescription}`+(e.culpritCss?` (has ${e.culpritCss})`:"")+".\nAn ancestor of <web-multiselect> establishes a fixed-positioning containing block that the library's heuristic doesn't recognize. Fix on your side: replace the property with `transform: translateZ(0)` on that ancestor, OR move the trigger out of that ancestor's subtree. If neither is acceptable, please file an issue at https://github.com/keenmate/web-multiselect/issues with the ancestor's computed CSS."))}positionDropdown(){this.dropdownCleanup=this.anchorFloatingPanel(this.dropdown,{getPlacement:()=>this.dropdownPlacement,setPlacement:e=>{this.dropdownPlacement=e,J.debug(`[${this.instanceId}] Locked dropdown placement:`,e)},isLocked:()=>!!this.options.isPlacementLocked,applyMaxWidth:!0,afterPosition:()=>{this.hint&&this.isOpen&&this.positionHint()}})}positionHint(){if(!this.hint)return;this.hintCleanup&&this.hintCleanup();let e="top-start";this.dropdownPlacement&&(this.dropdownPlacement.startsWith("bottom")?e=this.dropdownPlacement.replace("bottom","top"):this.dropdownPlacement.startsWith("top")&&(e=this.dropdownPlacement.replace("top","bottom")));const t=_t(this.hint,this.input,{strategy:"fixed",placement:e,offset:4,shift:8,flip:!1});this.hintCleanup=()=>t.destroy()}parseInitialSelection(){const e=this.element.dataset.initialValues;if(e)try{JSON.parse(e).forEach(i=>{this.selectedValues.add(String(i))}),this.reconcileSelectedOptions(),this.renderBadges()}catch(t){j.error(`[${this.instanceId}] Failed to parse initial values:`,t)}}reconcileSelectedOptions(){this.selectedValues.size===0||this.allOptions.length===0||this.selectedValues.forEach(e=>{if(this.selectedOptions.has(e))return;const t=this.allOptions.find(i=>String(this.getItemValue(i))===e);t&&this.selectedOptions.set(e,t)})}toggleSelectedPopover(){this.showSelectedPopover?this.hideSelectedPopover():this.showPopover()}showPopover(){J.debug(`[${this.instanceId}] showPopover() called`),this.isOpen&&this.close(),this.showSelectedPopover=!0,this.renderSelectedPopover(),this.selectedPopover.classList.add("ms__selected-popover--visible");const e=this.options.virtualScrollThreshold??100;this.selectedValues.size>=e&&this.selectedPopover.classList.add("ms__selected-popover--virtual"),this.positionSelectedPopover()}hideSelectedPopover(){var e;J.debug(`[${this.instanceId}] hideSelectedPopover() called`),this.showSelectedPopover=!1,this.selectedPopover.classList.remove("ms__selected-popover--visible"),this.selectedPopover.classList.remove("ms__selected-popover--virtual"),this.selectedPopoverPlacement=null,this.selectedPopoverVirtualScroll&&(this.selectedPopoverVirtualScroll.destroy(),this.selectedPopoverVirtualScroll=null,this.selectedPopoverContainer=null),this.selectedPopoverCleanup&&(this.selectedPopoverCleanup(),this.selectedPopoverCleanup=null);for(const t of Array.from(this.tooltips.keys()))t.startsWith("popover-")&&((e=this.tooltips.get(t))==null||e.destroy(),this.tooltips.delete(t))}renderSelectedPopover(){const e=Array.from(this.selectedOptions.values()),t=this.selectedValues.size,i=this.options.virtualScrollThreshold??100;if(t>=i){this.renderSelectedPopoverVirtual(e,t);return}this.selectedPopover.innerHTML=`
18
18
  <div class="ms__selected-popover-header">
19
19
  <span>Selected Items (${t})</span>
20
20
  <button type="button" class="ms__selected-popover-close" aria-label="Close"></button>
@@ -33,12 +33,12 @@
33
33
  <span class="ms__badge-text">${s}</span>
34
34
  <button type="button" class="ms__badge-remove" data-value="${i}" aria-label="Remove ${l}"></button>
35
35
  </div>
36
- `}handleSelectedPopoverClick(e){if(e.stopPropagation(),e.target.closest(".ms__selected-popover-close")){e.preventDefault(),this.hideSelectedPopover();return}const i=e.target.closest(".ms__badge-remove");if(i){e.preventDefault();const s=i.dataset.value,r=this.selectedOptions.get(s);r&&this.interactiveDeselect(r)&&(this.renderSelectedPopover(),this.selectedValues.size===0&&this.hideSelectedPopover())}}positionSelectedPopover(){this.selectedPopoverCleanup=this.anchorFloatingPanel(this.selectedPopover,{getPlacement:()=>this.selectedPopoverPlacement,setPlacement:e=>{this.selectedPopoverPlacement=e,J.debug(`[${this.instanceId}] Locked popover placement:`,e)}})}updateHiddenInput(){if(!this.options.formFieldId)return;this.hiddenInputs.forEach(s=>s.remove()),this.hiddenInputs=[];const e=this.options.valueFormat||"json",t=Array.from(this.selectedOptions.values()).map(s=>this.getItemValue(s)),i=this.options.hostElement||this.element;if(e==="array")t.forEach(s=>{const r=document.createElement("input");r.type="hidden",r.name=`${this.options.formFieldId}[]`,r.value=String(s),i.appendChild(r),this.hiddenInputs.push(r)});else{const s=document.createElement("input");s.type="hidden",s.name=this.options.formFieldId,s.id=this.options.formFieldId,s.value=this.getFormValue(),i.appendChild(s),this.hiddenInputs.push(s)}}getFormValue(){const e=Array.from(this.selectedOptions.values()).map(i=>this.getItemValue(i));return this.options.getValueFormatCallback?this.options.getValueFormatCallback(e):(this.options.valueFormat||"json")==="csv"?e.join(","):JSON.stringify(e)}getSelected(){return Array.from(this.selectedOptions.values())}setSelected(e,t={}){this.selectedValues=new Set(e.map(i=>String(i))),this.selectedOptions.clear(),e.forEach(i=>{const s=String(i),r=this.allOptions.find(n=>String(this.getItemValue(n))===s);r&&this.selectedOptions.set(s,r)}),this.renderDropdown(),this.renderBadges(),this.updateHiddenInput(),t.notify&&this.options.onChange&&this.options.onChange(this.getSelected())}updateOptions(e){var n;const t=!!this.hint,i="searchHint"in e?!!e.searchHint:t;if(t!==i)return!1;Object.assign(this.options,e);const s="pathMember"in e||"getPathCallback"in e||"parentPathMember"in e||"levelMember"in e||"hasChildrenMember"in e||"treePathSeparator"in e||"isTreeEnabled"in e||"isSelectableMember"in e||"getIsSelectableCallback"in e;if("options"in e&&e.options!==void 0?(this.allOptions=e.options,this.reconcileSelectedOptions(),this.isTreeMode()?this.buildTree():this.filteredOptions=this.searchTerm?this.filteredOptions:[...this.allOptions]):s&&(this.isTreeMode()?this.buildTree():this.filteredOptions=this.searchTerm?this.filteredOptions:[...this.allOptions]),("checkboxMode"in e||"cascadeSelectPolicy"in e)&&!s&&!("options"in e)&&this.isTreeMode()&&(this.cascadeIndex=this.isCascadeMode()?go(this.tree,a=>String(this.getItemValue(a))):null,this.isCascadeMode()&&this.cascadeIndex)){this.cascadeCheckedAtoms=Ke(this.cascadeIndex,this.selectedValues);const a=Ct(this.cascadeIndex,this.cascadeCheckedAtoms,this.cascadePolicy(),c=>String(this.getItemValue(c))),l=new Map;for(const c of a){const d=((n=this.cascadeIndex.nodeByValue.get(c))==null?void 0:n.data)??this.selectedOptions.get(c);d!==void 0&&l.set(c,d)}this.selectedValues=new Set(a),this.selectedOptions=l}if(this.element.classList.toggle("ms--no-checkboxes",!this.options.isCheckboxesShown||!this.options.isMultipleEnabled),"badgesPosition"in e){this.effectiveBadgesPosition=this.options.badgesPosition||"bottom",this.isRTL&&(this.effectiveBadgesPosition==="left"?this.effectiveBadgesPosition="right":this.effectiveBadgesPosition==="right"&&(this.effectiveBadgesPosition="left"));const a=this.element.querySelector(".ms__wrapper");a==null||a.classList.toggle("ms__wrapper--inline",this.effectiveBadgesPosition==="left"||this.effectiveBadgesPosition==="right")}return this.isOpen||(this.input.placeholder=this.getPlaceholderText()),"searchInputMode"in e&&(this.input.readOnly=this.options.searchInputMode==="readonly",this.input.style.display=this.options.searchInputMode==="hidden"?"none":""),"searchHint"in e&&this.hint&&(this.hint.textContent=this.options.searchHint||""),this.renderDropdown(),this.renderBadges(),this.updateHiddenInput(),!0}get selectedItem(){return this.selectedOptions.size===0?null:Array.from(this.selectedOptions.values())[0]}get selectedValue(){if(!this.options.valueMember&&!this.options.getValueCallback)return null;if(this.selectedOptions.size===0)return this.options.isMultipleEnabled?[]:null;const e=Array.from(this.selectedOptions.values()).map(t=>this.getItemValue(t));return this.options.isMultipleEnabled?e:e[0]??null}getValue(){if(this.selectedOptions.size===0)return this.options.isMultipleEnabled?[]:null;const e=Array.from(this.selectedOptions.values()).map(t=>this.getItemValue(t));return this.options.isMultipleEnabled?e:e[0]??null}spawnTooltip(e){var r;(r=this.tooltips.get(e.id))==null||r.destroy();const t=this.element.getRootNode(),i=t instanceof ShadowRoot?t:null,s=ki({trigger:e.trigger,container:this.options.container??i??document.body,content:e.content,placement:e.placement??this.options.badgeTooltipPlacement??"top",offset:e.offsetDistance??this.options.badgeTooltipOffset??8,delay:{show:e.showDelay??this.options.badgeTooltipDelay??100,hide:100},cssClass:e.cssClass??"ms__badge-tooltip",visibleClass:e.visibleClass??"ms__badge-tooltip--visible",followCursor:e.followCursor,onBeforeShow:e.onBeforeShow});this.tooltips.set(e.id,s)}destroyAllTooltips(){this.tooltips.forEach(e=>e.destroy()),this.tooltips.clear()}buildBadgeTooltipContent(e){if(this.options.getBadgeTooltipCallback)return this.options.getBadgeTooltipCallback(e);const t=this.getItemBadgeDisplayValue(e),i=this.getItemSubtitle(e);return i?`${t}
36
+ `}handleSelectedPopoverClick(e){if(e.stopPropagation(),e.target.closest(".ms__selected-popover-close")){e.preventDefault(),this.hideSelectedPopover();return}const i=e.target.closest(".ms__badge-remove");if(i){e.preventDefault();const s=i.dataset.value,r=this.selectedOptions.get(s);r&&this.interactiveDeselect(r)&&(this.renderSelectedPopover(),this.selectedValues.size===0&&this.hideSelectedPopover())}}positionSelectedPopover(){this.selectedPopoverCleanup=this.anchorFloatingPanel(this.selectedPopover,{getPlacement:()=>this.selectedPopoverPlacement,setPlacement:e=>{this.selectedPopoverPlacement=e,J.debug(`[${this.instanceId}] Locked popover placement:`,e)}})}updateHiddenInput(){if(!this.options.formFieldId)return;this.hiddenInputs.forEach(s=>s.remove()),this.hiddenInputs=[];const e=this.options.valueFormat||"json",t=Array.from(this.selectedOptions.values()).map(s=>this.getItemValue(s)),i=this.options.hostElement||this.element;if(e==="array")t.forEach(s=>{const r=document.createElement("input");r.type="hidden",r.name=`${this.options.formFieldId}[]`,r.value=String(s),i.appendChild(r),this.hiddenInputs.push(r)});else{const s=document.createElement("input");s.type="hidden",s.name=this.options.formFieldId,s.id=this.options.formFieldId,s.value=this.getFormValue(),i.appendChild(s),this.hiddenInputs.push(s)}}getFormValue(){const e=Array.from(this.selectedOptions.values()).map(i=>this.getItemValue(i));return this.options.getValueFormatCallback?this.options.getValueFormatCallback(e):(this.options.valueFormat||"json")==="csv"?e.join(","):JSON.stringify(e)}getSelected(){return Array.from(this.selectedOptions.values())}setSelected(e,t={}){this.selectedValues=new Set(e.map(i=>String(i))),this.selectedOptions.clear(),e.forEach(i=>{const s=String(i),r=this.allOptions.find(n=>String(this.getItemValue(n))===s);r&&this.selectedOptions.set(s,r)}),this.renderDropdown(),this.renderBadges(),this.updateHiddenInput(),t.notify&&this.options.onChange&&this.options.onChange(this.getSelected())}updateOptions(e){var n;const t=!!this.hint,i="searchHint"in e?!!e.searchHint:t;if(t!==i)return!1;Object.assign(this.options,e);const s="pathMember"in e||"getPathCallback"in e||"parentPathMember"in e||"levelMember"in e||"hasChildrenMember"in e||"treePathSeparator"in e||"isTreeEnabled"in e||"isSelectableMember"in e||"getIsSelectableCallback"in e;if("options"in e&&e.options!==void 0?(this.allOptions=e.options,this.reconcileSelectedOptions(),this.isTreeMode()?this.buildTree():this.filteredOptions=this.searchTerm?this.filteredOptions:[...this.allOptions]):s&&(this.isTreeMode()?this.buildTree():this.filteredOptions=this.searchTerm?this.filteredOptions:[...this.allOptions]),("checkboxMode"in e||"cascadeSelectPolicy"in e)&&!s&&!("options"in e)&&this.isTreeMode()&&(this.cascadeIndex=this.isCascadeMode()?go(this.tree,a=>String(this.getItemValue(a))):null,this.isCascadeMode()&&this.cascadeIndex)){this.cascadeCheckedAtoms=He(this.cascadeIndex,this.selectedValues);const a=Ct(this.cascadeIndex,this.cascadeCheckedAtoms,this.cascadePolicy(),c=>String(this.getItemValue(c))),l=new Map;for(const c of a){const d=((n=this.cascadeIndex.nodeByValue.get(c))==null?void 0:n.data)??this.selectedOptions.get(c);d!==void 0&&l.set(c,d)}this.selectedValues=new Set(a),this.selectedOptions=l}if(this.element.classList.toggle("ms--no-checkboxes",!this.options.isCheckboxesShown||!this.options.isMultipleEnabled),"badgesPosition"in e){this.effectiveBadgesPosition=this.options.badgesPosition||"bottom",this.isRTL&&(this.effectiveBadgesPosition==="left"?this.effectiveBadgesPosition="right":this.effectiveBadgesPosition==="right"&&(this.effectiveBadgesPosition="left"));const a=this.element.querySelector(".ms__wrapper");a==null||a.classList.toggle("ms__wrapper--inline",this.effectiveBadgesPosition==="left"||this.effectiveBadgesPosition==="right")}return this.isOpen||(this.input.placeholder=this.getPlaceholderText()),"searchInputMode"in e&&(this.input.readOnly=this.options.searchInputMode==="readonly",this.input.style.display=this.options.searchInputMode==="hidden"?"none":""),"searchHint"in e&&this.hint&&(this.hint.textContent=this.options.searchHint||""),this.renderDropdown(),this.renderBadges(),this.updateHiddenInput(),!0}get selectedItem(){return this.selectedOptions.size===0?null:Array.from(this.selectedOptions.values())[0]}get selectedValue(){if(!this.options.valueMember&&!this.options.getValueCallback)return null;if(this.selectedOptions.size===0)return this.options.isMultipleEnabled?[]:null;const e=Array.from(this.selectedOptions.values()).map(t=>this.getItemValue(t));return this.options.isMultipleEnabled?e:e[0]??null}getValue(){if(this.selectedOptions.size===0)return this.options.isMultipleEnabled?[]:null;const e=Array.from(this.selectedOptions.values()).map(t=>this.getItemValue(t));return this.options.isMultipleEnabled?e:e[0]??null}spawnTooltip(e){var r;(r=this.tooltips.get(e.id))==null||r.destroy();const t=this.element.getRootNode(),i=t instanceof ShadowRoot?t:null,s=ki({trigger:e.trigger,container:this.options.container??i??document.body,content:e.content,placement:e.placement??this.options.badgeTooltipPlacement??"top",offset:e.offsetDistance??this.options.badgeTooltipOffset??8,delay:{show:e.showDelay??this.options.badgeTooltipDelay??100,hide:100},cssClass:e.cssClass??"ms__badge-tooltip",visibleClass:e.visibleClass??"ms__badge-tooltip--visible",followCursor:e.followCursor,onBeforeShow:e.onBeforeShow});this.tooltips.set(e.id,s)}destroyAllTooltips(){this.tooltips.forEach(e=>e.destroy()),this.tooltips.clear()}buildBadgeTooltipContent(e){if(this.options.getBadgeTooltipCallback)return this.options.getBadgeTooltipCallback(e);const t=this.getItemBadgeDisplayValue(e),i=this.getItemSubtitle(e);return i?`${t}
37
37
  ${i}`:t}buildRemoveButtonTooltipText(e,t){return t&&this.options.getRemoveButtonTooltipCallback?this.options.getRemoveButtonTooltipCallback(t):this.options.removeButtonTooltipText?this.options.removeButtonTooltipText.replace("{0}",e):`Remove ${e}`}attachBadgeTooltips(e){if(!this.options.isBadgeTooltipsEnabled)return;const t=!!e,i=e||this.badgesContainer,s=t?"popover-":"";if(i.querySelectorAll(".ms__badge:not(.ms__badge--more)").forEach(n=>{const a=n.querySelector(".ms__badge-remove");if(!a)return;const l=a.dataset.value,c=this.selectedOptions.get(l);if(!c)return;const d=`${s}${l}`,h=`${s}${l}-remove`,g=n.querySelector(".ms__badge-text");g&&this.spawnTooltip({id:d,trigger:g,content:this.buildBadgeTooltipContent(c)});const m=this.getItemBadgeDisplayValue(c);this.spawnTooltip({id:h,trigger:a,content:this.buildRemoveButtonTooltipText(m,c),onBeforeShow:()=>{var b;return(b=this.tooltips.get(d))==null?void 0:b.hide()}})}),!t){const n=this.badgesContainer.querySelector(".ms__badge--more"),a=n==null?void 0:n.querySelector(".ms__badge-remove");if(a&&a.dataset.action==="remove-hidden"){const l=this.options.badgesMaxVisible||3,c=this.selectedOptions.size-l;this.spawnTooltip({id:"more-badge-remove",trigger:a,content:this.buildRemoveButtonTooltipText(`${c} hidden items`)})}}}buildOptionTooltipContent(e){if(this.options.getOptionTooltipCallback)return this.options.getOptionTooltipCallback(e);const t=this.getItemDisplayValue(e),i=this.getItemSubtitle(e);return i?`${t}
38
- ${i}`:t}attachOptionTooltips(){if(this.destroyAllOptionTooltips(),!this.options.isOptionTooltipsEnabled)return;this.dropdown.querySelectorAll(".ms__option").forEach(t=>{const i=t,s=parseInt(i.dataset.index??"-1",10);if(s<0)return;const r=this.filteredOptions[s];if(!r)return;const n=this.buildOptionTooltipContent(r);n&&this.spawnTooltip({id:`option-${s}`,trigger:i,content:n,placement:this.options.optionTooltipPlacement??"top-start",offsetDistance:this.options.optionTooltipOffset??this.options.badgeTooltipOffset??8,showDelay:this.options.optionTooltipDelay??this.options.badgeTooltipDelay??100,cssClass:"ms__option-tooltip",visibleClass:"ms__option-tooltip--visible",followCursor:this.options.isOptionTooltipFollowCursor})})}hideOptionTooltips(){for(const[e,t]of this.tooltips)e.startsWith("option-")&&t.hide()}destroyAllOptionTooltips(){var e;for(const t of Array.from(this.tooltips.keys()))t.startsWith("option-")&&((e=this.tooltips.get(t))==null||e.destroy(),this.tooltips.delete(t))}attachActionButtonTooltips(){this.dropdown.querySelectorAll(".ms__action-btn").forEach(t=>{var c,d;const i=t,s=i.dataset.action;if(!s)return;const r=parseInt(i.dataset.buttonIndex||"-1"),n=r>=0?(c=this.options.actionButtons)==null?void 0:c[r]:(d=this.options.actionButtons)==null?void 0:d.find(h=>h.action===s);if(!n)return;const a=n.getTooltipCallback?n.getTooltipCallback(this):n.tooltip;if(!a)return;const l=`action-${r>=0?r:s}`;this.spawnTooltip({id:l,trigger:i,content:a})})}destroyAllActionButtonTooltips(){var e;for(const t of Array.from(this.tooltips.keys()))t.startsWith("action-")&&((e=this.tooltips.get(t))==null||e.destroy(),this.tooltips.delete(t))}destroyAllBadgeTooltips(){var e;for(const t of Array.from(this.tooltips.keys()))!t.startsWith("action-")&&!t.startsWith("popover-")&&((e=this.tooltips.get(t))==null||e.destroy(),this.tooltips.delete(t))}destroy(){this.destroyAllTooltips(),this.searchDebounceTimer&&(clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=void 0),this.abortInFlightSearch(),this.dropdownCleanup&&this.dropdownCleanup(),this.hintCleanup&&this.hintCleanup(),this.selectedPopoverCleanup&&this.selectedPopoverCleanup(),this.documentClickHandler&&(document.removeEventListener("click",this.documentClickHandler),this.documentClickHandler=null),this.documentKeydownHandler&&(document.removeEventListener("keydown",this.documentKeydownHandler),this.documentKeydownHandler=null),this.virtualScroll&&(this.virtualScroll.destroy(),this.virtualScroll=null),this.dropdown&&this.dropdown.remove(),this.hint&&this.hint.remove(),this.selectedPopover&&this.selectedPopover.remove(),this.element.innerHTML="",this.element.classList.remove("ms","ms--open","ms--no-checkboxes"),Re.info(`[${this.instanceId}] Component destroyed`)}}function Ei(){return{fromAttribute(o){if(o===null||o.trim()==="")return[];const e=o.trim();if(e.startsWith("["))try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e.split(",").map(t=>t.trim())},validate(o){return Array.isArray(o)&&o.every(e=>typeof e=="string"||typeof e=="number")},toAttribute(o){return Array.isArray(o)?JSON.stringify(o):null}}}const vo=["json","csv","plain"],yo=",",wo=`
38
+ ${i}`:t}attachOptionTooltips(){if(this.destroyAllOptionTooltips(),!this.options.isOptionTooltipsEnabled)return;this.dropdown.querySelectorAll(".ms__option").forEach(t=>{const i=t,s=parseInt(i.dataset.index??"-1",10);if(s<0)return;const r=this.filteredOptions[s];if(!r)return;const n=this.buildOptionTooltipContent(r);n&&this.spawnTooltip({id:`option-${s}`,trigger:i,content:n,placement:this.options.optionTooltipPlacement??"top-start",offsetDistance:this.options.optionTooltipOffset??this.options.badgeTooltipOffset??8,showDelay:this.options.optionTooltipDelay??this.options.badgeTooltipDelay??100,cssClass:"ms__option-tooltip",visibleClass:"ms__option-tooltip--visible",followCursor:this.options.isOptionTooltipFollowCursor})})}hideOptionTooltips(){for(const[e,t]of this.tooltips)e.startsWith("option-")&&t.hide()}destroyAllOptionTooltips(){var e;for(const t of Array.from(this.tooltips.keys()))t.startsWith("option-")&&((e=this.tooltips.get(t))==null||e.destroy(),this.tooltips.delete(t))}attachActionButtonTooltips(){this.dropdown.querySelectorAll(".ms__action-btn").forEach(t=>{var c,d;const i=t,s=i.dataset.action;if(!s)return;const r=parseInt(i.dataset.buttonIndex||"-1"),n=r>=0?(c=this.options.actionButtons)==null?void 0:c[r]:(d=this.options.actionButtons)==null?void 0:d.find(h=>h.action===s);if(!n)return;const a=n.getTooltipCallback?n.getTooltipCallback(this):n.tooltip;if(!a)return;const l=`action-${r>=0?r:s}`;this.spawnTooltip({id:l,trigger:i,content:a})})}destroyAllActionButtonTooltips(){var e;for(const t of Array.from(this.tooltips.keys()))t.startsWith("action-")&&((e=this.tooltips.get(t))==null||e.destroy(),this.tooltips.delete(t))}destroyAllBadgeTooltips(){var e;for(const t of Array.from(this.tooltips.keys()))!t.startsWith("action-")&&!t.startsWith("popover-")&&((e=this.tooltips.get(t))==null||e.destroy(),this.tooltips.delete(t))}destroy(){this.destroyAllTooltips(),this.searchDebounceTimer&&(clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=void 0),this.abortInFlightSearch(),this.dropdownCleanup&&this.dropdownCleanup(),this.hintCleanup&&this.hintCleanup(),this.selectedPopoverCleanup&&this.selectedPopoverCleanup(),this.documentClickHandler&&(document.removeEventListener("click",this.documentClickHandler),this.documentClickHandler=null),this.documentKeydownHandler&&(document.removeEventListener("keydown",this.documentKeydownHandler),this.documentKeydownHandler=null),this.virtualScroll&&(this.virtualScroll.destroy(),this.virtualScroll=null),this.dropdown&&this.dropdown.remove(),this.hint&&this.hint.remove(),this.selectedPopover&&this.selectedPopover.remove(),this.element.innerHTML="",this.element.classList.remove("ms","ms--open","ms--no-checkboxes"),Be.info(`[${this.instanceId}] Component destroyed`)}}function Ei(){return{fromAttribute(o){if(o===null||o.trim()==="")return[];const e=o.trim();if(e.startsWith("["))try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e.split(",").map(t=>t.trim())},validate(o){return Array.isArray(o)&&o.every(e=>typeof e=="string"||typeof e=="number")},toAttribute(o){return Array.isArray(o)?JSON.stringify(o):null}}}const vo=["json","csv","plain"],yo=",",wo=`
39
39
  `;function xo(o,e,t={}){if(o==null||o.trim()==="")return{options:[]};const i=_o(t.splitter??yo)||yo,s=_o(t.rowSplitter??wo)||wo;switch(e){case"csv":return Di(o,i,s);case"plain":return Vi(o,i,s);case"json":default:return $i(o)}}function _o(o){return o.replace(/\\[ntr\\]/g,e=>e==="\\n"?`
40
40
  `:e==="\\t"?" ":e==="\\r"?"\r":"\\")}function $i(o){let e;try{e=JSON.parse(o)}catch(t){return{options:[],error:`data-options is not valid JSON: ${t.message}`}}return Array.isArray(e)?{options:e}:{options:[],error:"data-options JSON must be an array"}}function Vi(o,e,t){return{options:o.split(t).flatMap(s=>s.split(e)).map(s=>s.trim()).filter(s=>s.length>0).map(s=>[s,s])}}function Di(o,e,t){const i=zi(o,e,t).filter(n=>!(n.length===1&&n[0].trim()===""));if(i.length<2)return{options:[],error:"data-options CSV needs a header row and at least one data row"};const s=i[0].map(n=>n.trim());return{options:i.slice(1).map(n=>{const a={};return s.forEach((l,c)=>{a[l]=(n[c]??"").trim()}),a})}}function zi(o,e,t){const i=[];let s=[],r="",n=!1;for(let a=0;a<o.length;){const l=o[a];if(n){l==='"'?o[a+1]==='"'?(r+='"',a+=2):(n=!1,a+=1):(r+=l,a+=1);continue}l==='"'?(n=!0,a+=1):o.startsWith(e,a)?(s.push(r),r="",a+=e.length):o.startsWith(t,a)?(s.push(r),i.push(s),s=[],r="",a+=t.length):(l==="\r"||(r+=l),a+=1)}return s.push(r),i.push(s),i}const ko=`@layer variables,component,overrides;@layer variables{:host{display:block;--ms-rem: 10px;font-family:var(--ms-font-family, var(--base-font-family, inherit));--ms-accent-color: var(--base-accent-color, #3b82f6);--ms-accent-color-hover: var(--base-accent-color-hover, #2563eb);--ms-accent-color-active: var(--base-accent-color-active, #1d4ed8);--ms-accent-color-light: var(--base-accent-color-light, light-dark(#eff6ff, #1e3a5f));--ms-accent-color-light-hover: var(--base-accent-color-light-hover, light-dark(#e0f2fe, #264a73));--ms-text-color-1: var(--base-text-color-1, light-dark(#111827, #f5f5f5));--ms-text-color-2: var(--base-text-color-2, light-dark(#353b47, #d4d4d4));--ms-text-color-3: var(--base-text-color-3, light-dark(#6b7280, #a3a3a3));--ms-text-color-4: var(--base-text-color-4, light-dark(#a0a3a9, #737373));--ms-text-color-on-accent: var(--base-text-color-on-accent, #ffffff);--ms-text-primary: var(--ms-text-color-1);--ms-text-secondary: var(--ms-text-color-3);--ms-primary-bg: var(--base-hover-bg, color-mix(in srgb, var(--ms-text-color-1) 8%, var(--base-main-bg, light-dark(#ffffff, #1a1a1a))));--ms-primary-bg-hover: var(--base-active-bg, color-mix(in srgb, var(--ms-text-color-1) 14%, var(--base-main-bg, light-dark(#ffffff, #1a1a1a))));--ms-border-color: var(--base-border-color, light-dark(#e5e7eb, #3a3a3a));--ms-border: var(--base-border, 1px solid var(--ms-border-color));--ms-input-bg: var(--base-input-bg, light-dark(#ffffff, #1a1a1a));--ms-input-color: var(--base-input-color, var(--ms-text-color-1));--ms-input-border: var(--base-input-border, 1px solid var(--ms-border-color));--ms-input-border-hover: var(--base-input-border-hover, 1px solid var(--ms-accent-color));--ms-input-border-focus: var(--base-input-border-focus, 1px solid var(--ms-accent-color));--ms-input-placeholder-color: var(--base-input-placeholder-color, var(--ms-text-color-4));--ms-input-bg-disabled: var(--base-input-bg-disabled, rgba(107, 114, 128, .05));--ms-toggle-icon-color: var(--ms-text-color-3);--ms-toggle-icon-color-open: var(--ms-text-color-3);--ms-counter-badge-bg: var(--ms-accent-color);--ms-counter-badge-bg-hover: var(--ms-accent-color-hover);--ms-counter-badge-color: var(--ms-text-color-on-accent);--ms-hint-bg: var(--base-main-bg, light-dark(#ffffff, #1a1a1a));--ms-hint-color: var(--ms-text-color-4);--ms-hint-border-color: var(--ms-border-color);--ms-dropdown-bg: var(--base-dropdown-bg, var(--base-elevated-bg, light-dark(#ffffff, #1a1a1a)));--ms-dropdown-text-color: var(--ms-text-color-1);--ms-dropdown-border-color: var(--ms-border-color);--ms-dropdown-box-shadow-semantic: var(--base-dropdown-box-shadow, 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1));--ms-actions-bg: var(--base-main-bg, light-dark(#ffffff, #1a1a1a));--ms-actions-border-color: var(--ms-border-color);--ms-action-button-bg: transparent;--ms-action-button-bg-hover: var(--ms-primary-bg);--ms-action-button-border-color: var(--ms-border-color);--ms-action-button-border-color-hover: var(--ms-accent-color);--ms-action-button-color: var(--ms-text-color-1);--ms-group-border-color: var(--ms-border-color);--ms-option-text-color: var(--ms-text-color-1);--ms-option-bg: transparent;--ms-option-bg-hover: var(--ms-primary-bg);--ms-option-color-hover: inherit;--ms-option-bg-focused: var(--ms-primary-bg);--ms-option-color-focused: inherit;--ms-option-outline-color-focused: var(--ms-accent-color);--ms-option-bg-selected: color-mix(in srgb, var(--ms-accent-color) 10%, transparent);--ms-option-bg-matched: color-mix(in srgb, var(--ms-accent-color) 8%, transparent);--ms-option-color-matched: inherit;--ms-option-border-matched-color: color-mix(in srgb, var(--ms-accent-color) 40%, transparent);--ms-option-title-color: var(--ms-text-color-1);--ms-option-subtitle-color: var(--ms-text-color-3);--ms-option-mark-bg: color-mix(in srgb, var(--ms-accent-color) 20%, transparent);--ms-option-mark-color: inherit;--ms-loading-color: var(--ms-text-color-3);--ms-badge-bg: var(--ms-accent-color-light);--ms-badge-bg-hover: var(--base-hover-bg, var(--ms-accent-color-light-hover));--ms-badge-bg-active: var(--ms-accent-color-light-hover);--ms-badge-text-bg-hover: var(--base-hover-bg, var(--ms-accent-color-light-hover));--ms-badge-text-color-hover: var(--ms-badge-text-color);--ms-badge-counter-border-color: var(--ms-border-color);--ms-badge-counter-text-bg: var(--ms-primary-bg-hover);--ms-badge-counter-text-color: var(--ms-text-color-1);--ms-badge-counter-remove-bg: var(--ms-text-color-3);--ms-badge-counter-remove-bg-hover: var(--ms-text-color-1);--ms-badge-counter-remove-color: var(--ms-text-color-on-accent);--ms-counter-wrapper-border-color: var(--ms-border-color);--ms-count-clear-bg-hover: var(--ms-accent-color);--ms-tooltip-bg: var(--base-tooltip-bg, var(--base-inverse-bg, light-dark(#333333, #f5f5f5)));--ms-tooltip-text-color: var(--base-tooltip-text-color, light-dark(#ffffff, #1a1a1a));--ms-selected-popover-bg: var(--base-dropdown-bg, var(--base-elevated-bg, light-dark(#ffffff, #1a1a1a)));--ms-selected-popover-border-color: var(--ms-border-color);--ms-selected-popover-header-border-color: var(--ms-border-color);--ms-selected-popover-close-bg-hover: var(--ms-accent-color);--ms-input-padding: calc(.8 * var(--ms-rem)) calc(1.2 * var(--ms-rem));--ms-input-padding-right: calc(4 * var(--ms-rem));--ms-input-padding-h: calc(1.2 * var(--ms-rem));--ms-input-height: calc(var(--base-input-size-md-height, 3.5) * var(--ms-rem));--ms-input-font-size: calc(var(--base-font-size-sm, 1.4) * var(--ms-rem));--ms-input-border-width: 1px;--ms-input-border-radius: var(--ms-border-radius-md);--ms-input-text: var(--ms-text-color-1);--ms-input-bg-disabled: rgba(107, 114, 128, .05);--ms-toggle-right: calc(1.2 * var(--ms-rem));--ms-toggle-color: var(--ms-text-color-3);--ms-transform-center-y: translateY(-50%);--ms-transform-rotate-180: 180deg;--ms-counter-offset: calc(3.2 * var(--ms-rem));--ms-counter-padding: calc(.2 * var(--ms-rem)) calc(.4 * var(--ms-rem));--ms-counter-bg: var(--ms-accent-color);--ms-counter-color: var(--ms-text-color-on-accent);--ms-counter-font-size: calc(var(--base-font-size-xs, 1.2) * var(--ms-rem));--ms-counter-font-weight: var(--base-font-weight-semibold, 600);--ms-counter-border-radius: var(--ms-border-radius-sm);--ms-counter-bg-hover: var(--ms-accent-color-hover);--ms-transform-scale-hover: 1.1;--ms-hint-padding: calc(.8 * var(--ms-rem)) calc(1.2 * var(--ms-rem));--ms-hint-border: 1px solid var(--ms-hint-border-color);--ms-hint-border-radius: var(--ms-border-radius-lg);--ms-hint-box-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--ms-hint-font-size: calc(var(--base-font-size-xs, 1.2) * var(--ms-rem));--ms-dropdown-border: var(--base-dropdown-border, 1px solid var(--ms-dropdown-border-color));--ms-dropdown-border-radius: var(--ms-border-radius-lg);--ms-dropdown-box-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--ms-input-current-width: auto;--ms-dropdown-width: var(--ms-input-current-width);--ms-options-max-height: calc(32 * var(--ms-rem));--ms-option-color: var(--ms-text-color-1);--ms-z-index-dropdown: 9999;--ms-z-index-sticky: 1;--ms-actions-gap: calc(.4 * var(--ms-rem));--ms-actions-padding: calc(.8 * var(--ms-rem));--ms-actions-border-bottom: 1px solid var(--ms-actions-border-color);--ms-action-btn-padding: calc(.4 * var(--ms-rem)) calc(.8 * var(--ms-rem));--ms-action-btn-font-size: calc(var(--base-font-size-xs, 1.2) * var(--ms-rem));--ms-action-btn-border: var(--ms-border);--ms-action-btn-border-radius: var(--ms-border-radius-sm);--ms-action-btn-bg: transparent;--ms-action-btn-color: inherit;--ms-action-btn-bg-hover: var(--ms-primary-bg);--ms-action-btn-border-color-hover: var(--ms-accent-color);--ms-transform-scale-active: .98;--ms-options-padding: 0;--ms-group-border-top: 1px solid var(--ms-group-border-color);--ms-group-margin-top: calc(.4 * var(--ms-rem));--ms-group-padding-top: calc(.4 * var(--ms-rem));--ms-group-label-padding: calc(.4 * var(--ms-rem)) calc(1.2 * var(--ms-rem));--ms-group-label-font-size: calc(var(--base-font-size-xs, 1.2) * var(--ms-rem));--ms-group-label-font-weight: var(--base-font-weight-semibold, 600);--ms-group-label-color: var(--ms-text-color-3);--ms-group-label-transform: uppercase;--ms-group-label-letter-spacing: .05em;--ms-option-gap: calc(.8 * var(--ms-rem));--ms-option-padding: calc(.8 * var(--ms-rem)) calc(1.2 * var(--ms-rem));--ms-option-padding-h: calc(1.2 * var(--ms-rem));--ms-option-min-height: auto;--ms-option-outline-focused: 2px solid var(--ms-option-outline-color-focused);--ms-option-focus-outline-offset: -2px;--ms-option-border-matched: 3px solid var(--ms-option-border-matched-color);--ms-option-bg-focused-hover: var(--ms-primary-bg);--ms-option-bg-matched-hover: color-mix(in srgb, var(--ms-accent-color) 12%, transparent);--ms-option-bg-selected-focused: color-mix(in srgb, var(--ms-accent-color) 15%, transparent);--ms-option-bg-selected-matched: color-mix(in srgb, var(--ms-accent-color) 15%, transparent);--ms-option-disabled-bg: var(--base-disabled-bg, transparent);--ms-option-bg-disabled-selected: color-mix(in srgb, var(--ms-accent-color) 10%, transparent);--ms-disabled-opacity: .5;--ms-option-content-gap: calc(.8 * var(--ms-rem));--ms-option-icon-size: calc(2 * var(--ms-rem));--ms-option-icon-font-size: calc(var(--base-font-size-base, 1.6) * var(--ms-rem));--ms-option-title-font-size: calc(var(--base-font-size-sm, 1.4) * var(--ms-rem));--ms-option-mark-font-weight: var(--base-font-weight-semibold, 600);--ms-option-title-white-space: normal;--ms-option-title-overflow: visible;--ms-option-title-text-overflow: clip;--ms-option-subtitle-margin-top: calc(.4 * var(--ms-rem));--ms-option-subtitle-font-size: calc(var(--base-font-size-xs, 1.2) * var(--ms-rem));--ms-option-subtitle-line-height: var(--base-line-height-tight, 1.25);--ms-checkbox-margin-top: calc(.2 * var(--ms-rem));--ms-checkbox-margin-right: 0;--ms-checkbox-margin-bottom: 0;--ms-checkbox-margin-left: 0;--ms-checkbox-size: calc(1.6 * var(--ms-rem));--ms-checkbox-scale: 1;--ms-checkbox-align: center;--ms-checkbox-bg: var(--ms-input-bg);--ms-checkbox-border-width: 1px;--ms-checkbox-border-color: var(--base-checkbox-border-color, #8f8f8f);--ms-checkbox-border: var(--ms-checkbox-border-width) solid var(--ms-checkbox-border-color);--ms-checkbox-border-radius: calc(.3 * var(--ms-rem));--ms-checkbox-checkmark-thickness: 2.5px;--ms-checkbox-checked-bg: var(--ms-accent-color);--ms-checkbox-checked-border: var(--ms-checkbox-border-width) solid var(--ms-accent-color);--ms-checkbox-checkmark-color: var(--ms-text-color-on-accent);--ms-checkbox-hover-border-color: var(--ms-accent-color);--ms-checkbox-disabled-bg: var(--ms-primary-bg);--ms-checkbox-disabled-border: var(--ms-checkbox-border-width) solid var(--ms-border-color);--ms-checkbox-checked-bg-hover: var(--ms-accent-color-hover);--ms-checkbox-checked-border-color-hover: var(--ms-accent-color-hover);--ms-state-min-height: calc(8 * var(--ms-rem));--ms-empty-padding: calc(1.6 * var(--ms-rem)) calc(1.2 * var(--ms-rem));--ms-empty-font-size: calc(var(--base-font-size-sm, 1.4) * var(--ms-rem));--ms-empty-color: var(--ms-text-color-3);--ms-loader-padding: calc(1.6 * var(--ms-rem)) calc(1.2 * var(--ms-rem));--ms-loader-gap: calc(.8 * var(--ms-rem));--ms-loading-text-font-size: calc(var(--base-font-size-sm, 1.4) * var(--ms-rem));--ms-loading-text-color: var(--ms-text-color-3);--ms-badges-gap: calc(.8 * var(--ms-rem));--ms-badges-margin-bottom: calc(.8 * var(--ms-rem));--ms-badges-margin-top: calc(.8 * var(--ms-rem));--ms-badges-margin-left: calc(.4 * var(--ms-rem));--ms-badges-margin-right: calc(.4 * var(--ms-rem));--ms-inline-align: center;--ms-badge-gap: calc(.8 * var(--ms-rem));--ms-badge-height: calc(2.7 * var(--ms-rem));--ms-badge-font-size: calc(var(--base-font-size-xs, 1.2) * var(--ms-rem));--ms-badge-font-weight: var(--base-font-weight-semibold, 600);--ms-badge-border-radius: var(--ms-border-radius-sm);--ms-order-first: -1;--ms-badge-text-padding: 0 calc(.8 * var(--ms-rem));--ms-badge-text-bg: var(--ms-accent-color-light);--ms-badge-text-color: var(--ms-accent-color);--ms-badge-text-border: none;--ms-badge-remove-width: calc(2.7 * var(--ms-rem));--ms-badge-remove-bg: var(--ms-accent-color);--ms-badge-remove-color: var(--ms-text-color-on-accent);--ms-badge-remove-border: none;--ms-badge-remove-font-size: calc(var(--base-font-size-xs, 1.2) * var(--ms-rem));--ms-badge-remove-bg-hover: var(--ms-accent-color-hover);--ms-badge-remove-box-shadow-focus: 0 0 0 2px color-mix(in srgb, var(--ms-accent-color) 50%, transparent);--ms-badge-remove-icon-size: calc(1 * var(--ms-rem));--ms-icon-remove: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 6L18 18M18 6L6 18' stroke='black' stroke-width='2.5' stroke-linecap='round' fill='none'/></svg>");--ms-badge-counter-bg: transparent;--ms-badge-counter-border: 1px solid var(--ms-badge-counter-border-color);--ms-badge-counter-border-radius: var(--ms-border-radius-sm);--ms-more-badge-bg: var(--ms-accent-color-light);--ms-more-badge-hover-bg: var(--ms-badge-bg-hover);--ms-more-badge-active-bg: var(--ms-accent-color-light-hover);--ms-count-display-margin-bottom: calc(.8 * var(--ms-rem));--ms-count-display-margin-top: calc(.8 * var(--ms-rem));--ms-count-display-margin-left: calc(.8 * var(--ms-rem));--ms-count-display-margin-right: calc(.8 * var(--ms-rem));--ms-counter-wrapper-bg: transparent;--ms-counter-wrapper-border: var(--ms-border);--ms-counter-wrapper-border-radius: var(--ms-border-radius-sm);--ms-counter-wrapper-padding: calc(.4 * var(--ms-rem)) calc(.8 * var(--ms-rem));--ms-counter-wrapper-gap: calc(.4 * var(--ms-rem));--ms-counter-wrapper-bg-hover: var(--ms-primary-bg);--ms-counter-wrapper-border-color-hover: var(--ms-accent-color);--ms-count-text-bg: transparent;--ms-count-text-border: none;--ms-count-text-font-size: calc(var(--base-font-size-sm, 1.4) * var(--ms-rem));--ms-count-text-color: var(--ms-text-color-1);--ms-count-clear-size: calc(1.6 * var(--ms-rem));--ms-count-clear-bg: transparent;--ms-count-clear-color: var(--ms-text-color-3);--ms-count-clear-font-size: calc(var(--base-font-size-lg, 1.8) * var(--ms-rem));--ms-count-clear-border-radius: var(--ms-border-radius-sm);--ms-count-clear-bg-hover: color-mix(in srgb, var(--ms-accent-color) 20%, transparent);--ms-count-clear-color-hover: var(--ms-accent-color);--ms-count-clear-icon-size: calc(1.4 * var(--ms-rem));--ms-icon-clear: var(--ms-icon-remove);--ms-tooltip-color: var(--ms-tooltip-text-color);--ms-tooltip-padding: calc(.8 * var(--ms-rem)) calc(1.2 * var(--ms-rem));--ms-tooltip-border-radius: var(--ms-border-radius-lg);--ms-tooltip-font-size: calc(var(--base-font-size-sm, 1.4) * var(--ms-rem));--ms-tooltip-max-width: calc(32 * var(--ms-rem));--ms-tooltip-shadow: 0 2px 8px rgba(0, 0, 0, .15);--ms-tooltip-z-index: 10000;--ms-option-tooltip-bg: var(--ms-tooltip-bg);--ms-option-tooltip-text-color: var(--ms-tooltip-text-color);--ms-option-tooltip-padding: var(--ms-tooltip-padding);--ms-option-tooltip-border-radius: var(--ms-tooltip-border-radius);--ms-option-tooltip-font-size: var(--ms-tooltip-font-size);--ms-option-tooltip-max-width: var(--ms-tooltip-max-width);--ms-option-tooltip-shadow: var(--ms-tooltip-shadow);--ms-option-tooltip-z-index: var(--ms-tooltip-z-index);--ms-z-index-popover: 10000;--ms-selected-popover-width: calc(32 * var(--ms-rem));--ms-selected-popover-max-height: calc(32 * var(--ms-rem));--ms-selected-popover-border: 1px solid var(--ms-selected-popover-border-color);--ms-selected-popover-border-radius: var(--ms-border-radius-lg);--ms-selected-popover-box-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--ms-selected-popover-header-padding: calc(.8 * var(--ms-rem)) calc(1.2 * var(--ms-rem));--ms-selected-popover-header-bg: color-mix(in srgb, var(--ms-accent-color) 10%, transparent);--ms-selected-popover-header-border-bottom: 1px solid var(--ms-selected-popover-header-border-color);--ms-selected-popover-header-font-size: calc(var(--base-font-size-sm, 1.4) * var(--ms-rem));--ms-selected-popover-header-font-weight: var(--base-font-weight-semibold, 600);--ms-selected-popover-header-color: var(--ms-text-color-1);--ms-popover-close-size: calc(2.4 * var(--ms-rem));--ms-selected-popover-close-bg: transparent;--ms-selected-popover-close-color: var(--ms-text-color-3);--ms-selected-popover-close-font-size: calc(var(--base-font-size-xl, 2) * var(--ms-rem));--ms-selected-popover-close-border-radius: var(--ms-border-radius-sm);--ms-selected-popover-close-bg-hover: color-mix(in srgb, var(--ms-accent-color) 20%, transparent);--ms-selected-popover-close-color-hover: var(--ms-accent-color);--ms-selected-popover-close-icon-size: calc(1.4 * var(--ms-rem));--ms-selected-popover-body-gap: calc(.4 * var(--ms-rem));--ms-selected-popover-body-padding: calc(.8 * var(--ms-rem));--ms-selected-popover-body-max-height: calc(28.8 * var(--ms-rem));--ms-font-size-2xs: calc(var(--base-font-size-2xs, 1) * var(--ms-rem));--ms-font-size-xs: calc(var(--base-font-size-xs, 1.2) * var(--ms-rem));--ms-font-size-sm: calc(var(--base-font-size-sm, 1.4) * var(--ms-rem));--ms-font-size-base: calc(var(--base-font-size-base, 1.6) * var(--ms-rem));--ms-font-size-lg: calc(var(--base-font-size-lg, 1.8) * var(--ms-rem));--ms-font-weight-normal: var(--base-font-weight-normal, 400);--ms-font-weight-medium: var(--base-font-weight-medium, 500);--ms-font-weight-semibold: var(--base-font-weight-semibold, 600);--ms-line-height-none: 1;--ms-line-height-tight: var(--base-line-height-tight, 1.25);--ms-line-height-normal: var(--base-line-height-normal, 1.5);--ms-line-height-relaxed: var(--base-line-height-relaxed, 1.75);--ms-border-radius-sm: calc(var(--base-border-radius-sm, .4) * var(--ms-rem));--ms-border-radius-md: calc(var(--base-border-radius-md, .6) * var(--ms-rem));--ms-border-radius-lg: calc(var(--base-border-radius-lg, .8) * var(--ms-rem));--ms-border-radius: var(--ms-border-radius-md);--ms-spacing-xs: calc(.4 * var(--ms-rem));--ms-spacing-sm: calc(.8 * var(--ms-rem));--ms-spacing-md: calc(1.2 * var(--ms-rem));--ms-spacing-lg: calc(1.6 * var(--ms-rem));--ms-transition-fast: .15s;--ms-transition-normal: .2s;--ms-easing-snappy: cubic-bezier(.4, 0, .2, 1);--ms-placeholder-opacity: .6;--ms-disabled-input-opacity: .6;--ms-scrollbar-width: 8px;--ms-scrollbar-track-bg: transparent;--ms-scrollbar-thumb-bg: var(--ms-border-color);--ms-scrollbar-thumb-bg-hover: var(--ms-text-color-3);--ms-scrollbar-thumb-border-radius: 4px;--ms-debug-bg: var(--base-elevated-bg, light-dark(#f9fafb, #2b2b2b));--ms-debug-border-color: var(--ms-border-color);--ms-debug-text-color: var(--ms-text-color-1);--ms-debug-border-radius: var(--ms-border-radius-md);--ms-debug-summary-color: var(--ms-accent-color);--ms-debug-summary-bg-hover: var(--ms-primary-bg);--ms-debug-summary-outline-color: var(--ms-accent-color);--ms-debug-summary-border-radius: var(--ms-border-radius-sm);--ms-debug-stats-bg: var(--base-main-bg, light-dark(#ffffff, #1a1a1a));--ms-debug-stats-border-radius: var(--ms-border-radius-sm);--ms-debug-bullet-color: var(--ms-accent-color)}}@layer component{web-multiselect:not(:defined){display:block;min-height:calc(3.5 * var(--ms-rem));color:transparent!important;background:transparent}.ms__wrapper{display:flex;flex-direction:column;align-items:stretch}.ms__wrapper--inline{flex-direction:row;align-items:var(--ms-inline-align, center)}.ms{position:relative;width:100%}}@layer component{.ms__input-wrapper{position:relative;display:flex;align-items:center}.ms__input{box-sizing:border-box;width:100%;font-family:inherit;height:var(--ms-input-height);padding:var(--ms-input-padding);padding-right:var(--ms-input-padding-right);font-size:var(--ms-input-font-size);border:var(--ms-input-border);border-radius:var(--ms-input-border-radius);background:var(--ms-input-bg);color:var(--ms-input-color);cursor:pointer;transition:border var(--ms-transition-fast) var(--ms-easing-snappy)}.ms__input:hover:not(:focus):not(:disabled){border:var(--ms-input-border-hover)}.ms__input:focus{outline:none;border:var(--ms-input-border-focus)}.ms__input::placeholder{color:var(--ms-input-placeholder-color);opacity:0;transition:opacity var(--ms-transition-fast) var(--ms-easing-snappy)}:host([data-ready]) .ms__input::placeholder{opacity:var(--ms-placeholder-opacity)}.ms__toggle{position:absolute;right:var(--ms-toggle-right);top:50%;transform:var(--ms-transform-center-y);pointer-events:none;color:var(--ms-toggle-icon-color);transition:transform var(--ms-transition-fast) var(--ms-easing-snappy)}.ms--open .ms__toggle{transform:var(--ms-transform-center-y) rotate(var(--ms-transform-rotate-180));color:var(--ms-toggle-icon-color-open)}.ms__counter{position:absolute;right:var(--ms-counter-offset);top:50%;transform:var(--ms-transform-center-y);padding:var(--ms-counter-padding);background:var(--ms-counter-badge-bg);color:var(--ms-counter-badge-color);font-size:var(--ms-counter-font-size);font-weight:var(--ms-counter-font-weight);border-radius:var(--ms-counter-border-radius);cursor:pointer;transition:all var(--ms-transition-fast) var(--ms-easing-snappy)}.ms__counter:hover{background:var(--ms-counter-badge-bg-hover);transform:var(--ms-transform-center-y) scale(var(--ms-transform-scale-hover))}.ms__actions{display:flex;flex-direction:column;gap:var(--ms-actions-gap);padding:var(--ms-actions-padding)}.ms__actions--top{border-bottom:var(--ms-actions-border-bottom)}.ms__actions--bottom{flex-direction:column-reverse;border-top:var(--ms-actions-border-bottom)}.ms__actions-row{display:flex;flex-wrap:nowrap;gap:var(--ms-actions-gap)}.ms__actions--wrap .ms__actions-row{flex-wrap:wrap}.ms__actions--sticky{position:sticky;z-index:var(--ms-z-index-sticky);background:var(--ms-actions-bg)}.ms__actions--sticky.ms__actions--top{top:0}.ms__actions--sticky.ms__actions--bottom{bottom:0}.ms__actions--align-stretch .ms__action-btn{flex:1}.ms__actions--align-left .ms__actions-row{justify-content:flex-start}.ms__actions--align-right .ms__actions-row{justify-content:flex-end}.ms__actions--align-center .ms__actions-row{justify-content:center}.ms__actions--align-space-between .ms__actions-row{justify-content:space-between}.ms__action-btn{font-family:inherit;padding:var(--ms-action-btn-padding);font-size:var(--ms-action-btn-font-size);border:var(--ms-action-btn-border);border-radius:var(--ms-action-btn-border-radius);background:var(--ms-action-button-bg);color:var(--ms-action-button-color);cursor:pointer;transition:all var(--ms-transition-fast) var(--ms-easing-snappy)}.ms__action-btn:hover{background:var(--ms-action-button-bg-hover);border-color:var(--ms-action-button-border-color-hover)}.ms__action-btn:active{transform:scale(var(--ms-transform-scale-active))}.ms__action-btn:disabled,.ms__action-btn[disabled]{opacity:var(--ms-disabled-opacity);cursor:not-allowed;pointer-events:none}}@layer component{.ms__hint{display:none;position:fixed;z-index:var(--ms-z-index-popover);padding:var(--ms-hint-padding);background:var(--ms-hint-bg);border:var(--ms-hint-border);border-radius:var(--ms-hint-border-radius);box-shadow:var(--ms-hint-box-shadow);font-size:var(--ms-hint-font-size);color:var(--ms-hint-color);line-height:var(--ms-line-height-relaxed);max-width:100%}.ms__hint--visible{display:block}.ms__dropdown{display:none;position:fixed;font-family:inherit;z-index:var(--ms-z-index-dropdown);background:var(--ms-dropdown-bg);border:var(--ms-dropdown-border);border-radius:var(--ms-dropdown-border-radius);box-shadow:var(--ms-dropdown-box-shadow);width:var(--ms-dropdown-width);max-height:var(--ms-options-max-height);overflow:hidden;color:var(--ms-dropdown-text-color)}.ms__dropdown--visible{display:flex;flex-direction:column}.ms__dropdown-inner{flex:1;overflow-y:auto;overscroll-behavior:contain;touch-action:pan-y;-webkit-overflow-scrolling:touch;scrollbar-width:thin;scrollbar-color:var(--ms-scrollbar-thumb-bg) var(--ms-scrollbar-track-bg)}.ms__dropdown-inner::-webkit-scrollbar{width:var(--ms-scrollbar-width)}.ms__dropdown-inner::-webkit-scrollbar-track{background:var(--ms-scrollbar-track-bg)}.ms__dropdown-inner::-webkit-scrollbar-thumb{background:var(--ms-scrollbar-thumb-bg);border-radius:var(--ms-scrollbar-thumb-border-radius)}.ms__dropdown-inner::-webkit-scrollbar-thumb:hover{background:var(--ms-scrollbar-thumb-bg-hover)}.ms__dropdown--virtual{max-height:none}.ms__dropdown--virtual .ms__dropdown-inner{overflow-y:visible}.ms__badge-tooltip{position:fixed;z-index:var(--ms-tooltip-z-index);opacity:0;visibility:hidden;transition:opacity var(--ms-transition-normal) ease,visibility var(--ms-transition-normal) ease;background:var(--ms-tooltip-bg);color:var(--ms-tooltip-text-color);padding:var(--ms-tooltip-padding);border-radius:var(--ms-tooltip-border-radius);font-size:var(--ms-tooltip-font-size);line-height:var(--ms-line-height-relaxed);max-width:var(--ms-tooltip-max-width);word-wrap:break-word;white-space:pre-wrap;box-shadow:var(--ms-tooltip-shadow);pointer-events:none}.ms__badge-tooltip--visible{opacity:1;visibility:visible}.ms__option-tooltip{position:fixed;z-index:var(--ms-option-tooltip-z-index);opacity:0;visibility:hidden;transition:opacity var(--ms-transition-normal) ease,visibility var(--ms-transition-normal) ease;background:var(--ms-option-tooltip-bg);color:var(--ms-option-tooltip-text-color);padding:var(--ms-option-tooltip-padding);border-radius:var(--ms-option-tooltip-border-radius);font-size:var(--ms-option-tooltip-font-size);line-height:var(--ms-line-height-relaxed);max-width:var(--ms-option-tooltip-max-width);word-wrap:break-word;white-space:pre-wrap;box-shadow:var(--ms-option-tooltip-shadow);pointer-events:none}.ms__option-tooltip--visible{opacity:1;visibility:visible}.ms__selected-popover{display:none;position:fixed;z-index:var(--ms-z-index-popover);background:var(--ms-selected-popover-bg);border:var(--ms-selected-popover-border);border-radius:var(--ms-selected-popover-border-radius);box-shadow:var(--ms-selected-popover-box-shadow);width:var(--ms-selected-popover-width);max-height:var(--ms-selected-popover-max-height);overflow:hidden}.ms__selected-popover--visible{display:flex;flex-direction:column}.ms__selected-popover--virtual{display:block;overflow:visible;max-height:none}.ms__selected-popover-header{display:flex;align-items:center;justify-content:space-between;padding:var(--ms-selected-popover-header-padding);background:var(--ms-selected-popover-header-bg);border-bottom:var(--ms-selected-popover-header-border-bottom);font-size:var(--ms-selected-popover-header-font-size);font-weight:var(--ms-selected-popover-header-font-weight);color:var(--ms-selected-popover-header-color)}.ms__selected-popover-close{display:flex;align-items:center;justify-content:center;width:var(--ms-popover-close-size);height:var(--ms-popover-close-size);padding:0;border:none;background:var(--ms-selected-popover-close-bg);color:var(--ms-selected-popover-close-color);font-size:var(--ms-selected-popover-close-font-size);line-height:var(--ms-line-height-none);cursor:pointer;border-radius:var(--ms-selected-popover-close-border-radius);transition:all var(--ms-transition-fast) var(--ms-easing-snappy)}.ms__selected-popover-close:hover{background:var(--ms-selected-popover-close-bg-hover);color:var(--ms-selected-popover-close-color-hover)}.ms__selected-popover-close:before{content:"";display:block;width:var(--ms-selected-popover-close-icon-size);height:var(--ms-selected-popover-close-icon-size);background-color:currentColor;-webkit-mask:var(--ms-icon-remove) center / contain no-repeat;mask:var(--ms-icon-remove) center / contain no-repeat}.ms__selected-popover-body{display:flex;flex-direction:column;gap:var(--ms-selected-popover-body-gap);padding:var(--ms-selected-popover-body-padding);overflow-y:auto;max-height:var(--ms-selected-popover-body-max-height);scrollbar-width:thin;scrollbar-color:var(--ms-scrollbar-thumb-bg) var(--ms-scrollbar-track-bg)}.ms__selected-popover-body::-webkit-scrollbar{width:var(--ms-scrollbar-width)}.ms__selected-popover-body::-webkit-scrollbar-track{background:var(--ms-scrollbar-track-bg)}.ms__selected-popover-body::-webkit-scrollbar-thumb{background:var(--ms-scrollbar-thumb-bg);border-radius:var(--ms-scrollbar-thumb-border-radius)}.ms__selected-popover-body::-webkit-scrollbar-thumb:hover{background:var(--ms-scrollbar-thumb-bg-hover)}.ms__selected-popover-body .ms__badge{width:100%;min-height:fit-content;line-height:var(--ms-line-height-relaxed)}.ms__selected-popover-body .ms__badge-text{flex:1;min-width:0;white-space:normal;word-wrap:break-word}.ms__selected-popover-body--virtual{display:block;max-height:none;padding:0}.ms__selected-popover-body--virtual .ms__badge{height:var(--ms-badge-height-virtual, 36px);min-height:var(--ms-badge-height-virtual, 36px);max-height:var(--ms-badge-height-virtual, 36px);margin-bottom:var(--ms-selected-popover-body-gap);overflow:hidden;box-sizing:border-box}.ms__selected-popover-body--virtual .ms__badge-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}}@layer component{.ms--disabled .ms__input{opacity:var(--ms-disabled-input-opacity);cursor:not-allowed;background:var(--ms-input-bg-disabled)}.ms--disabled .ms__toggle{opacity:var(--ms-disabled-input-opacity)}.ms--no-checkboxes .ms__option{gap:0;padding-left:var(--ms-option-padding-h)}.ms--no-checkboxes .ms__option-content{padding-left:0}}@layer component;@layer component{.ms__badges{display:flex;flex-wrap:wrap;gap:var(--ms-badges-gap);padding:0}.ms__badges:empty{display:none}.ms__badges--bottom{margin-top:var(--ms-badges-margin-bottom)}.ms__badges--top{margin-bottom:var(--ms-badges-margin-top);order:var(--ms-order-first)}.ms__badges--left{order:var(--ms-order-first);margin-right:var(--ms-badges-margin-left);justify-content:flex-end}.ms__badges--right{margin-left:var(--ms-badges-margin-right);justify-content:flex-start}.ms__badge{display:inline-flex;align-items:center;height:var(--ms-badge-height);font-size:var(--ms-badge-font-size);font-weight:var(--ms-badge-font-weight);line-height:var(--ms-line-height-none);border-radius:var(--ms-badge-border-radius);overflow:hidden;max-width:100%}.ms__badge-text{display:flex;align-items:center;box-sizing:border-box;height:100%;padding:var(--ms-badge-text-padding);background:var(--ms-badge-text-bg);color:var(--ms-badge-text-color);border:var(--ms-badge-text-border);border-right:none;border-radius:var(--ms-badge-border-radius) 0 0 var(--ms-badge-border-radius);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:background-color var(--ms-transition-normal) ease,color var(--ms-transition-normal) ease}.ms__badge:hover .ms__badge-text{background:var(--ms-badge-text-bg-hover, var(--ms-badge-text-bg));color:var(--ms-badge-text-color-hover, var(--ms-badge-text-color))}.ms__badge-remove{display:flex;align-items:center;justify-content:center;box-sizing:border-box;font-family:inherit;width:var(--ms-badge-remove-width);height:100%;flex-shrink:0;background:var(--ms-badge-remove-bg);color:var(--ms-badge-remove-color);border:var(--ms-badge-remove-border);border-left:none;border-radius:0 var(--ms-badge-border-radius) var(--ms-badge-border-radius) 0;cursor:pointer;transition:background-color var(--ms-transition-normal) ease;font-size:var(--ms-badge-remove-font-size)}.ms__badge-remove:hover{background:var(--ms-badge-remove-bg-hover)}.ms__badge-remove:focus{outline:none}.ms__badge-remove:focus-visible{outline:none;box-shadow:var(--ms-badge-remove-box-shadow-focus)}.ms__badge-remove:before{content:"";display:block;width:var(--ms-badge-remove-icon-size);height:var(--ms-badge-remove-icon-size);background-color:currentColor;-webkit-mask:var(--ms-icon-remove) center / contain no-repeat;mask:var(--ms-icon-remove) center / contain no-repeat}.ms__badge--counter{cursor:pointer}.ms__badge--counter .ms__badge-text{background:var(--ms-badge-counter-text-bg);color:var(--ms-badge-counter-text-color);border:var(--ms-badge-counter-border);border-right:none}.ms__badge--counter .ms__badge-remove{background:var(--ms-badge-counter-remove-bg);color:var(--ms-badge-counter-remove-color);border:var(--ms-badge-counter-border);border-left:none}.ms__badge--counter .ms__badge-remove:hover{background:var(--ms-badge-counter-remove-bg-hover)}.ms__badge--more,.ms__badge[data-action=show-selected]{cursor:pointer}}@layer component{.ms__count-display{display:flex;align-items:center}.ms__count-display:empty{display:none}.ms__count-display--bottom{margin-top:var(--ms-count-display-margin-bottom)}.ms__count-display--top{margin-bottom:var(--ms-count-display-margin-top);order:var(--ms-order-first)}.ms__count-display--left{order:var(--ms-order-first);margin-right:var(--ms-count-display-margin-left);justify-content:flex-start}.ms__count-display--right{margin-left:var(--ms-count-display-margin-right);justify-content:flex-end}.ms__counter-wrapper{display:inline-flex;align-items:center;gap:var(--ms-counter-wrapper-gap);background:var(--ms-counter-wrapper-bg);border:var(--ms-counter-wrapper-border);border-radius:var(--ms-counter-wrapper-border-radius);padding:var(--ms-counter-wrapper-padding);transition:all var(--ms-transition-fast) var(--ms-easing-snappy)}.ms__counter-wrapper:hover{background:var(--ms-counter-wrapper-bg-hover);border-color:var(--ms-counter-wrapper-border-color-hover)}.ms__count-text{display:inline-flex;align-items:center;background:var(--ms-count-text-bg);border:var(--ms-count-text-border);padding:0;font-size:var(--ms-count-text-font-size);color:var(--ms-count-text-color);cursor:pointer;transition:color var(--ms-transition-fast) var(--ms-easing-snappy)}.ms__count-clear{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:var(--ms-count-clear-size);height:var(--ms-count-clear-size);padding:0;border:none;background:var(--ms-count-clear-bg);color:var(--ms-count-clear-color);font-size:var(--ms-count-clear-font-size);line-height:var(--ms-line-height-none);cursor:pointer;border-radius:var(--ms-count-clear-border-radius);transition:all var(--ms-transition-fast) var(--ms-easing-snappy)}.ms__count-clear:hover{background:var(--ms-count-clear-bg-hover);color:var(--ms-count-clear-color-hover)}.ms__count-clear:before{content:"";display:block;width:var(--ms-count-clear-icon-size);height:var(--ms-count-clear-icon-size);background-color:currentColor;-webkit-mask:var(--ms-icon-clear) center / contain no-repeat;mask:var(--ms-icon-clear) center / contain no-repeat}}@layer component{.ms__debug-info{margin-top:calc(.4 * var(--ms-rem));padding:calc(.4 * var(--ms-rem));background-color:var(--ms-debug-bg);border:1px solid var(--ms-debug-border-color);border-radius:var(--ms-debug-border-radius);font-size:calc(1.2 * var(--ms-rem));color:var(--ms-debug-text-color)}.ms__debug-info details summary{cursor:pointer;font-weight:600;color:var(--ms-debug-summary-color);-webkit-user-select:none;user-select:none;padding:calc(.4 * var(--ms-rem));border-radius:var(--ms-debug-summary-border-radius)}.ms__debug-info details summary:hover{background-color:var(--ms-debug-summary-bg-hover)}.ms__debug-info details summary:focus{outline:2px solid var(--ms-debug-summary-outline-color);outline-offset:2px}.ms__debug-info .ms__debug-stats{display:flex;flex-direction:column;gap:calc(.4 * var(--ms-rem));margin-top:calc(.4 * var(--ms-rem));padding:calc(.4 * var(--ms-rem));background-color:var(--ms-debug-stats-bg);border-radius:var(--ms-debug-stats-border-radius)}.ms__debug-info .ms__debug-stats span{display:flex;justify-content:space-between;padding:2px 4px;font-family:monospace;font-size:calc(1 * var(--ms-rem))}.ms__debug-info .ms__debug-stats span:before{content:"•";margin-right:calc(.4 * var(--ms-rem));color:var(--ms-debug-bullet-color)}}@layer component{.ms__options{padding:var(--ms-options-padding);scrollbar-width:thin;scrollbar-color:var(--ms-scrollbar-thumb-bg) var(--ms-scrollbar-track-bg)}.ms__options::-webkit-scrollbar{width:var(--ms-scrollbar-width)}.ms__options::-webkit-scrollbar-track{background:var(--ms-scrollbar-track-bg)}.ms__options::-webkit-scrollbar-thumb{background:var(--ms-scrollbar-thumb-bg);border-radius:var(--ms-scrollbar-thumb-border-radius)}.ms__options::-webkit-scrollbar-thumb:hover{background:var(--ms-scrollbar-thumb-bg-hover)}.ms__options--virtual .ms__option,.ms__options--fixed-height .ms__option{height:var(--ms-option-height, 50px);min-height:var(--ms-option-height, 50px);max-height:var(--ms-option-height, 50px);overflow:hidden;box-sizing:border-box}.ms__group+.ms__group{border-top:var(--ms-group-border-top);margin-top:var(--ms-group-margin-top);padding-top:var(--ms-group-padding-top)}.ms__group-label{padding:var(--ms-group-label-padding);font-size:var(--ms-group-label-font-size);font-weight:var(--ms-group-label-font-weight);color:var(--ms-group-label-color);text-transform:var(--ms-group-label-transform);letter-spacing:var(--ms-group-label-letter-spacing)}.ms__option{display:flex;align-items:var(--ms-checkbox-align, center);gap:var(--ms-option-gap);padding:var(--ms-option-padding);min-height:var(--ms-option-min-height, auto);color:var(--ms-option-text-color);background:var(--ms-option-bg);cursor:pointer;user-select:none;-webkit-user-select:none}.ms__option:hover{background:var(--ms-option-bg-hover);color:var(--ms-option-color-hover, inherit)}.ms__option--focused{background:var(--ms-option-bg-focused);color:var(--ms-option-color-focused, inherit);outline:var(--ms-option-outline-focused);outline-offset:var(--ms-option-focus-outline-offset)}.ms__option--matched{background:var(--ms-option-bg-matched);color:var(--ms-option-color-matched, inherit);border-left:var(--ms-option-border-matched)}.ms__option--selected{background:var(--ms-option-bg-selected)}.ms__option--selected:hover{background:var(--ms-option-bg-selected-hover, var(--ms-option-bg-selected))}.ms__option--disabled{opacity:var(--ms-disabled-opacity);cursor:not-allowed;background:var(--ms-option-disabled-bg)}.ms__option--disabled:hover{background:var(--ms-option-disabled-bg)}.ms__option--focused:hover{background:var(--ms-option-bg-focused-hover);color:var(--ms-option-color-focused-hover, var(--ms-option-color-focused, var(--ms-option-text-color)))}.ms__option--matched:hover{background:var(--ms-option-bg-matched-hover);color:var(--ms-option-color-matched-hover, var(--ms-option-color-matched, var(--ms-option-text-color)))}.ms__option--selected.ms__option--focused{background:var(--ms-option-bg-selected-focused);outline:var(--ms-option-outline-focused);outline-offset:var(--ms-option-focus-outline-offset)}.ms__option--selected.ms__option--matched{background:var(--ms-option-bg-selected-matched);border-left:var(--ms-option-border-matched)}.ms__option--disabled.ms__option--selected{background:var(--ms-option-bg-disabled-selected)}.ms__option--disabled.ms__option--focused{outline:none}.ms__option[data-checkbox-align=top]{--ms-checkbox-align: flex-start}.ms__option[data-checkbox-align=bottom]{--ms-checkbox-align: flex-end}.ms__checkbox{appearance:none;-webkit-appearance:none;-moz-appearance:none;flex-shrink:0;position:relative;margin-top:var(--ms-checkbox-margin-top);margin-right:var(--ms-checkbox-margin-right);margin-bottom:var(--ms-checkbox-margin-bottom);margin-left:var(--ms-checkbox-margin-left);width:var(--ms-checkbox-size);height:var(--ms-checkbox-size);transform:scale(var(--ms-checkbox-scale));transform-origin:top left;cursor:pointer;background:var(--ms-checkbox-bg);border:var(--ms-checkbox-border);border-radius:var(--ms-checkbox-border-radius);transition:background-color .15s ease,border-color .15s ease}.ms__checkbox:after{content:"";position:absolute;display:none;left:50%;top:40%;width:30%;height:55%;transform:translate(-50%,-50%) rotate(45deg);border:solid var(--ms-checkbox-checkmark-color);border-width:0 var(--ms-checkbox-checkmark-thickness, 2px) var(--ms-checkbox-checkmark-thickness, 2px) 0}.ms__checkbox:hover:not(:disabled){border-color:var(--ms-checkbox-hover-border-color)}.ms__checkbox:checked{background:var(--ms-checkbox-checked-bg);border:var(--ms-checkbox-checked-border)}.ms__checkbox:checked:after{display:block}.ms__checkbox--indeterminate{background:var(--ms-checkbox-checked-bg);border:var(--ms-checkbox-checked-border)}.ms__checkbox--indeterminate:after{display:block;top:50%;left:50%;width:55%;height:0;transform:translate(-50%,-50%);border:none;border-bottom:var(--ms-checkbox-checkmark-thickness, 2px) solid var(--ms-checkbox-checkmark-color)}.ms__checkbox--indeterminate:hover:not(:disabled){background:var(--ms-checkbox-checked-bg-hover);border-color:var(--ms-checkbox-checked-border-color-hover)}.ms__checkbox:checked:hover:not(:disabled){background:var(--ms-checkbox-checked-bg-hover);border-color:var(--ms-checkbox-checked-border-color-hover)}.ms__checkbox:focus-visible{outline:2px solid var(--ms-checkbox-checked-bg);outline-offset:2px}.ms__checkbox:disabled{cursor:not-allowed;background:var(--ms-checkbox-disabled-bg);border:var(--ms-checkbox-disabled-border);opacity:.6}.ms__checkbox:disabled:checked{background:var(--ms-checkbox-disabled-bg)}.ms__option--disabled .ms__checkbox{cursor:not-allowed}.ms__option-content{flex:1;display:flex;align-items:center;gap:var(--ms-option-content-gap);min-width:0}.ms__option-icon{flex-shrink:0;width:var(--ms-option-icon-size);height:var(--ms-option-icon-size);display:flex;align-items:center;justify-content:center;font-size:var(--ms-option-icon-font-size)}.ms__option-icon svg{width:100%;height:100%;fill:currentColor}.ms__option-text{flex:1;min-width:0}.ms__option-title{font-size:var(--ms-option-title-font-size);color:var(--ms-option-title-color);line-height:var(--ms-line-height-relaxed);white-space:var(--ms-option-title-white-space, normal);overflow:var(--ms-option-title-overflow, visible);text-overflow:var(--ms-option-title-text-overflow, clip)}.ms__option:hover .ms__option-title{color:var(--ms-option-title-color-hover, var(--ms-option-title-color))}.ms__option--selected .ms__option-title{color:var(--ms-option-title-color-selected, var(--ms-option-title-color))}.ms__option--selected:hover .ms__option-title{color:var(--ms-option-title-color-selected-hover, var(--ms-option-title-color-selected, var(--ms-option-title-color)))}.ms__option-title mark{background:var(--ms-option-mark-bg);color:var(--ms-option-mark-color);font-weight:var(--ms-option-mark-font-weight)}.ms__option-subtitle{margin-top:var(--ms-option-subtitle-margin-top);font-size:var(--ms-option-subtitle-font-size);color:var(--ms-option-subtitle-color);line-height:var(--ms-option-subtitle-line-height)}.ms__option:hover .ms__option-subtitle{color:var(--ms-option-subtitle-color-hover, var(--ms-option-subtitle-color))}.ms__option--selected .ms__option-subtitle{color:var(--ms-option-subtitle-color-selected, var(--ms-option-subtitle-color))}.ms__option--selected:hover .ms__option-subtitle{color:var(--ms-option-subtitle-color-selected-hover, var(--ms-option-subtitle-color-selected, var(--ms-option-subtitle-color)))}.ms__empty{display:flex;align-items:center;justify-content:center;min-height:var(--ms-state-min-height);padding:var(--ms-empty-padding);text-align:center;font-size:var(--ms-empty-font-size);color:var(--ms-empty-color)}.ms__loader{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:var(--ms-state-min-height);padding:var(--ms-loader-padding);gap:var(--ms-loader-gap)}.ms__loading-text{font-size:var(--ms-loading-text-font-size);color:var(--ms-loading-color)}}@layer component{.ms--rtl .ms__input-wrapper{direction:rtl}.ms--rtl .ms__input{text-align:right;padding-left:var(--ms-input-padding-right);padding-right:var(--ms-input-padding-h)}.ms--rtl .ms__toggle{left:var(--ms-toggle-right)!important;right:auto!important}.ms--rtl .ms__counter{left:var(--ms-counter-offset)!important;right:auto!important}.ms--rtl .ms__dropdown{direction:rtl;text-align:right}.ms--rtl .ms__option{flex-direction:row-reverse}.ms--rtl .ms__checkbox{margin-left:var(--ms-spacing-sm);margin-right:0}.ms--rtl .ms__option-content{text-align:right}.ms--rtl .ms__option-icon{margin-left:var(--ms-spacing-xs);margin-right:0}.ms--rtl .ms__badges{direction:rtl}.ms--rtl .ms__badges--right{margin-left:0;margin-right:var(--ms-badges-margin-right)}.ms--rtl .ms__badges--left{margin-right:0;margin-left:var(--ms-badges-margin-left)}.ms--rtl .ms__badge{flex-direction:row-reverse}.ms--rtl .ms__badge-remove{border-radius:var(--ms-badge-border-radius) 0 0 var(--ms-badge-border-radius);border-left:var(--ms-badge-remove-border);border-right:none}.ms--rtl .ms__badge-text{border-radius:0 var(--ms-badge-border-radius) var(--ms-badge-border-radius) 0;border-right:var(--ms-badge-text-border);border-left:none}.ms--rtl .ms__count-display{direction:rtl}.ms--rtl .ms__count-display--right{margin-left:0;margin-right:var(--ms-count-display-margin-right)}.ms--rtl .ms__count-display--left{margin-right:0;margin-left:var(--ms-count-display-margin-left)}.ms--rtl .ms__counter-wrapper{flex-direction:row-reverse}.ms--rtl .ms__selected-popover{direction:rtl;text-align:right}.ms--rtl .ms__actions{direction:rtl}.ms--rtl .ms__group-label,.ms--rtl .ms__empty{text-align:right}.ms--rtl .ms__hint{direction:rtl;text-align:right}}@layer component{.ms__option--tree{padding-inline-start:calc(var(--ms-tree-base-indent, .75rem) + var(--ms-tree-depth, 0) * var(--ms-tree-indent, 1.25rem))}.ms__option--tree-unselectable{cursor:default}.ms__option--tree-unselectable:hover{background:transparent}}@layer overrides{:host-context([data-theme="dark"]),:host-context([data-bs-theme="dark"]),:host-context(.dark){color-scheme:dark}:host-context([data-theme="light"]),:host-context([data-bs-theme="light"]),:host-context(.light){color-scheme:light}:host([data-theme="dark"]){color-scheme:dark}:host([data-theme="light"]){color-scheme:light}}`,Co=["top","top-start","top-end","bottom","bottom-start","bottom-end","left","left-start","left-end","right","right-start","right-end"],z=()=>jo(),Ni=[{configKey:"searchHint",attribute:"search-hint",converter:$({isNullable:!0}),on:"update",description:"Small hint text shown beneath the search input."},{configKey:"searchPlaceholder",attribute:"search-placeholder",converter:$({default:"Search..."}),on:"update",description:"Placeholder text for the search input."},{configKey:"selectPlaceholder",attribute:"select-placeholder",converter:$({default:"Pick an option..."}),on:"update",description:"Placeholder shown on the control when nothing is selected."},{configKey:"noDataPlaceholder",attribute:"no-data-placeholder",converter:$({isNullable:!0}),on:"update",description:"Text shown when there are no options at all."},{configKey:"dropdownMinWidth",attribute:"dropdown-min-width",converter:$({isNullable:!0}),on:"update",description:"Minimum width of the dropdown panel (any CSS length)."},{configKey:"dropdownMaxWidth",attribute:"dropdown-max-width",converter:$({isNullable:!0}),on:"update",description:"Maximum width of the dropdown panel (any CSS length)."},{configKey:"maxHeight",attribute:"max-height",converter:$({default:"20rem"}),on:"update",description:"Maximum height of the dropdown list before it scrolls."},{configKey:"emptyMessage",attribute:"empty-message",converter:$({default:"No results found"}),on:"update",description:"Message shown when a search yields no matches."},{configKey:"loadingMessage",attribute:"loading-message",converter:$({default:"Loading..."}),on:"update",description:"Message shown while options are loading."},{configKey:"removeButtonTooltipText",attribute:"remove-button-tooltip-text",converter:$({isNullable:!0}),on:"update",description:"Tooltip text for a badge remove (×) button."},{configKey:"formFieldId",attribute:"name",converter:$({isNullable:!0}),on:"reinit",description:"HTML form field name/id used for the hidden input(s)."},{configKey:"dropdownWidth",attribute:"dropdown-width",converter:$({isNullable:!0}),on:"update",description:"Fixed dropdown width; mirrored to the `--ms-dropdown-width` CSS variable."},{configKey:"selectedPopoverWidth",attribute:"selected-popover-width",converter:$({isNullable:!0}),on:"update",description:"Selected-items popover width; mirrored to `--ms-selected-popover-width`."},{configKey:"valueMember",attribute:"value-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name on an option object that holds its value."},{configKey:"displayValueMember",attribute:"display-value-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name that holds an option display label."},{configKey:"searchValueMember",attribute:"search-value-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name searched against (falls back to the display value)."},{configKey:"iconMember",attribute:"icon-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name that holds an option icon."},{configKey:"subtitleMember",attribute:"subtitle-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name that holds an option subtitle."},{configKey:"fullTitleMember",attribute:"full-title-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name that holds an option full/long title."},{configKey:"groupMember",attribute:"group-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name used to group options under headers."},{configKey:"disabledMember",attribute:"disabled-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name that marks an option disabled."},{configKey:"pathMember",attribute:"path-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name holding a node materialized tree path."},{configKey:"parentPathMember",attribute:"parent-path-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name holding a node parent path."},{configKey:"levelMember",attribute:"level-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name holding a node depth level."},{configKey:"hasChildrenMember",attribute:"has-children-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name flagging that a node has children."},{configKey:"isSelectableMember",attribute:"is-selectable-member",converter:$({isNullable:!0}),reflect:!0,on:"reinit",description:"Property name marking whether a node can be selected."},{configKey:"treePathSeparator",attribute:"tree-path-separator",converter:$({default:"."}),reflect:!0,on:"reinit",description:"Separator between segments in a materialized tree path."},{configKey:"isTreeEnabled",converter:W("tristate"),on:"reinit",type:"boolean",description:"Force tree mode on/off. Property-only; when unset (null) tree mode auto-enables if a path source (path-member / getPathCallback) is present."},{configKey:"checkboxMode",attribute:"checkbox-mode",converter:P(["independent","cascade"],{default:"independent"}),reflect:!0,on:"update",description:"Tree checkbox interaction.\n- `independent` (default) — toggles only the clicked node.\n- `cascade` — checks a node whole subtree and shows a tristate (checked / indeterminate / unchecked) box on branches.\n\nTree + multiple only."},{configKey:"cascadeSelectPolicy",attribute:"cascade-select-policy",converter:P(["rolled-up","leaves","all"],{default:"rolled-up"}),reflect:!0,on:"update",description:"In `cascade` mode, which values a selection emits (badges / form / change):\n- `rolled-up` (default) — minimal cover: a fully-selected subtree collapses to its root; partially-selected branches emit their individually-checked descendants.\n- `leaves` — only the checked leaf-level nodes.\n- `all` — every fully-checked node (branches and leaves)."},{configKey:"badgesDisplayMode",attribute:"badges-display-mode",converter:P(["badges","count","compact","partial","none"],{default:"badges"}),on:"reinit",description:"How the current selection is shown in the control."},{configKey:"badgesPosition",attribute:"badges-position",converter:P(["top","bottom","left","right"],{default:"bottom"}),on:"reinit",description:"Where the badges/selection appear relative to the input."},{configKey:"badgesThresholdMode",attribute:"badges-threshold-mode",converter:P(["count","partial"],{default:"count"}),on:"update",description:'How `badgesThreshold` is interpreted: collapse to a count badge, or keep partial badges + a "more" badge.'},{configKey:"searchInputMode",attribute:"search-input-mode",converter:P(["normal","readonly","hidden"],{default:"normal"}),on:"reinit",description:"Search field mode: editable, read-only, or hidden."},{configKey:"searchMode",attribute:"search-mode",converter:P(["filter","navigate"],{default:"filter"}),on:"reinit",description:"Whether typing filters the list or navigates it."},{configKey:"actionsLayout",attribute:"actions-layout",converter:P(["nowrap","wrap"],{default:"nowrap"}),on:"reinit",description:"Whether the action bar wraps or stays on one line."},{configKey:"actionsPosition",attribute:"actions-position",converter:P(["top","bottom"],{default:"top"}),on:"reinit",description:"Whether the action bar sits above or below the list."},{configKey:"actionsAlign",attribute:"actions-align",converter:P(["stretch","left","right","center","space-between"],{default:"stretch"}),on:"update",description:"Horizontal alignment of the action buttons."},{configKey:"checkboxAlign",attribute:"checkbox-align",converter:P(["top","center","bottom"],{default:"center"}),on:"update",description:"Vertical alignment of an option checkbox."},{configKey:"valueFormat",attribute:"value-format",converter:P(["json","csv","array"],{default:"json"}),on:"reinit",description:"Serialization format the control emits its value in."},{configKey:"badgeTooltipPlacement",attribute:"badge-tooltip-placement",converter:P(Co,{default:"top"}),on:"update",description:"Preferred placement of a badge tooltip relative to its badge (floating-ui placement)."},{configKey:"optionTooltipPlacement",attribute:"option-tooltip-placement",converter:P(Co,{default:"top-start"}),on:"update",description:"Preferred placement of an option tooltip (floating-ui placement)."},{configKey:"badgesThreshold",attribute:"badges-threshold",converter:D(),on:"update",description:"Threshold at which badges collapse to a count/compact view."},{configKey:"badgesMaxVisible",attribute:"badges-max-visible",converter:D(),on:"update",description:"Maximum number of badges rendered before overflow."},{configKey:"minSearchLength",attribute:"min-search-length",converter:D({default:0}),on:"update",description:"Minimum characters before searching/filtering starts."},{configKey:"searchDebounce",attribute:"search-debounce",converter:D({default:0}),on:"update",description:"Debounce delay in ms applied to the search input."},{configKey:"virtualScrollThreshold",attribute:"virtual-scroll-threshold",converter:D({default:100}),on:"reinit",description:"Option count above which virtual scrolling turns on."},{configKey:"optionHeight",attribute:"option-height",converter:D({default:50}),on:"update",description:"Fixed row height in px used by virtual scrolling."},{configKey:"badgeHeight",attribute:"badge-height",converter:D({default:36}),on:"update",description:"Fixed badge height in px used for layout/virtualization."},{configKey:"virtualScrollBuffer",attribute:"virtual-scroll-buffer",converter:D({default:10}),on:"update",description:"Extra rows rendered above/below the viewport when virtualizing."},{configKey:"badgeTooltipDelay",attribute:"badge-tooltip-delay",converter:D({default:100}),on:"update",description:"Delay in ms before a badge tooltip appears."},{configKey:"badgeTooltipOffset",attribute:"badge-tooltip-offset",converter:D({default:8}),on:"update",description:"Gap in px between a badge and its tooltip."},{configKey:"optionTooltipDelay",attribute:"option-tooltip-delay",converter:D(),on:"update",description:"Delay in ms before an option tooltip appears (falls back to badgeTooltipDelay)."},{configKey:"optionTooltipOffset",attribute:"option-tooltip-offset",converter:D(),on:"update",description:"Gap in px between an option and its tooltip."},{configKey:"isMultipleEnabled",attribute:"multiple",converter:W("default-true"),on:"reinit",description:"Allow selecting multiple options. When off, selecting one replaces the previous."},{configKey:"isGroupsAllowed",attribute:"allow-groups",converter:W("default-true"),on:"reinit",description:"Allow grouping options under group headers."},{configKey:"isCheckboxesShown",attribute:"show-checkboxes",converter:W("default-true"),on:"reinit",description:"Show a checkbox on each option."},{configKey:"isActionsSticky",attribute:"sticky-actions",converter:W("default-true"),on:"update",description:"Keep the action bar pinned while the list scrolls."},{configKey:"isPlacementLocked",attribute:"lock-placement",converter:W("default-true"),on:"update",description:"Keep the dropdown initial placement instead of flipping when it fits."},{configKey:"isSearchEnabled",attribute:"enable-search",converter:W("default-true"),on:"reinit",description:"Show the search input."},{configKey:"isKeepOptionsOnSearch",attribute:"keep-options-on-search",converter:W("default-true"),on:"update",description:"Keep already-selected options visible while filtering."},{configKey:"shouldKeepSearchOnClose",attribute:"should-keep-search-on-close",converter:W("default-true"),on:"update",description:"Preserve the search text after the dropdown closes."},{configKey:"isCloseOnSelect",attribute:"close-on-select",converter:W("default-false"),on:"update",description:"Close the dropdown immediately after a selection."},{configKey:"isAddNewAllowed",attribute:"allow-add-new",converter:W("default-false"),on:"reinit",description:"Allow adding a new option from the search text."},{configKey:"isCounterShown",attribute:"show-counter",converter:W("default-false"),on:"update",description:"Show a selected-count indicator."},{configKey:"isBadgeFullTitleShown",attribute:"show-badge-full-title",converter:W("default-false"),on:"update",description:"Show the full title on badges instead of the short label."},{configKey:"isVirtualScrollEnabled",attribute:"enable-virtual-scroll",converter:W("default-false"),on:"reinit",description:"Force virtual scrolling on regardless of the threshold."},{configKey:"isBadgeTooltipsEnabled",attribute:"enable-badge-tooltips",converter:W("default-false"),on:"update",description:"Enable tooltips on badges."},{configKey:"isOptionTooltipsEnabled",attribute:"enable-option-tooltips",converter:W("default-false"),on:"update",description:"Enable tooltips on options."},{configKey:"isOptionTooltipFollowCursor",attribute:"option-tooltip-follow-cursor",converter:W("default-false"),on:"update",description:"Make option tooltips follow the pointer."},{configKey:"initialValues",attribute:"initial-values",converter:Ei(),default:[],on:"reinit",type:"Array<string | number>",description:'Values selected on first render. Accepts a JSON array (`["a","b"]`) or a bare CSV (`a,b,c`).'},{configKey:"showDebugInfo",attribute:"show-debug-info",converter:W("default-false"),on:"update",description:"Render an in-component debug panel.",deprecated:"Use per-instance logging (el.enableLogging()) instead."},{configKey:"options",converter:Wo(),on:"reinit",type:"ReadonlyArray<Record<string, unknown>>",description:"The array of option objects to render. The JS API — assign `el.options` directly. For HTML authoring use the `data-options` attribute (parsed per `data-options-format`) or declarative <option> children; both feed the same list and take precedence over this property in the order: <option> children > property > data-options."},{configKey:"optionsSource",attribute:"data-options",converter:$({isNullable:!0}),on:"reinit",type:"string",description:"HTML-authoring source for the option list, parsed per `data-options-format`. Reactive: changing either attribute re-renders. Prefer the `options` property in JS; a set `options` property and declarative <option> children both win over this."},{configKey:"optionsFormat",attribute:"data-options-format",converter:P(vo,{default:"json"}),on:"reinit",type:"'json' | 'csv' | 'plain'",description:"How to parse the `data-options` attribute: `json` (a JSON array of objects or [value, label] tuples), `csv` (rows split on `data-options-row-splitter`, cells on `data-options-splitter`; the first row is a header — map columns via *-member), or `plain` (bare values split on both splitters -> [value, label] tuples, value === label). Default `json`."},{configKey:"optionsSplitter",attribute:"data-options-splitter",converter:$({default:","}),on:"reinit",type:"string",description:'Field/cell delimiter for the `csv` and `plain` `data-options` formats. Default `,`. Escapes `\\t` `\\n` `\\r` are honoured (e.g. `data-options-splitter="\\t"` for TSV). Ignored for `json`.'},{configKey:"optionsRowSplitter",attribute:"data-options-row-splitter",converter:$({default:`
41
- `}),on:"reinit",type:"string",description:'Row/record delimiter for the `csv` and `plain` `data-options` formats. Default newline. Escapes honoured (e.g. `data-options-row-splitter=";"` for single-line data). Ignored for `json`.'},{configKey:"actionButtons",converter:Fo({validate:o=>Array.isArray(o)}),on:"reinit",type:"Array<Record<string, unknown>>",description:"Custom action buttons for the dropdown footer/header. Property-only; when unset the default Select-All / Clear buttons apply."},{configKey:"getValueCallback",converter:z(),on:"reinit",type:"(item: unknown) => string | number",description:"Extract an option value (overrides valueMember)."},{configKey:"getPathCallback",converter:z(),on:"reinit",type:"(item: unknown) => string",description:"Extract a node tree path (enables tree mode; overrides pathMember)."},{configKey:"getGroupCallback",converter:z(),on:"reinit",type:"(item: unknown) => string",description:"Extract the group name from an option (overrides groupMember)."},{configKey:"getDisabledCallback",converter:z(),on:"reinit",type:"(item: unknown) => boolean",description:"Whether an option is disabled (overrides disabledMember)."},{configKey:"getIsSelectableCallback",converter:z(),on:"reinit",type:"(node: unknown) => boolean",description:"Whether a tree node can be selected (overrides is-selectable-member)."},{configKey:"getSearchValueCallback",converter:z(),on:"reinit",type:"(item: unknown) => string",description:"Text an option is searched against (overrides searchValueMember)."},{configKey:"searchCallback",converter:z(),on:"reinit",type:"(searchTerm: string, signal?: AbortSignal) => Promise<unknown[]>",description:"Custom / async search; return the filtered options."},{configKey:"getDisplayValueCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Compute the display label for an option (overrides displayValueMember)."},{configKey:"getBadgeDisplayCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Compute the text shown on an option badge."},{configKey:"getBadgeClassCallback",converter:z(),on:"update",type:"(item: unknown) => string | string[]",description:"Extra CSS class(es) for an option badge."},{configKey:"getIconCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Icon for an option (overrides iconMember)."},{configKey:"getSubtitleCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Subtitle for an option (overrides subtitleMember)."},{configKey:"getFullTitleCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Full title for an option (used by badges when show-badge-full-title is on)."},{configKey:"getCounterCallback",converter:z(),on:"update",type:"(count: number, moreCount?: number) => string",description:"Render the selected-count label."},{configKey:"getValueFormatCallback",converter:z(),on:"update",type:"(selectedValues: (string | number)[]) => string",description:"Serialize the selected values for form submission."},{configKey:"getBadgeTooltipCallback",converter:z(),on:"update",type:"(item: unknown) => string | HTMLElement",description:"Tooltip content for an option badge."},{configKey:"getOptionTooltipCallback",converter:z(),on:"update",type:"(item: unknown) => string | HTMLElement",description:"Tooltip content for an option row."},{configKey:"getRemoveButtonTooltipCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Tooltip text for a badge remove button."},{configKey:"getSelectedItemClassCallback",converter:z(),on:"update",type:"(item: unknown) => string | string[]",description:"Extra CSS class(es) for a selected item."},{configKey:"renderOptionContentCallback",converter:z(),on:"update",type:"(item: unknown, context: OptionContentRenderContext) => string | HTMLElement",description:"Custom render for an option row; may return HTML or an element."},{configKey:"renderBadgeContentCallback",converter:z(),on:"update",type:"(item: unknown, context: BadgeContentRenderContext) => string | HTMLElement",description:"Custom render for a badge; may return HTML or an element."},{configKey:"renderGroupLabelContentCallback",converter:z(),on:"update",type:"(groupName: string) => string | HTMLElement",description:"Customize a group label; may return an HTML string or element."},{configKey:"renderSelectedContentCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Custom render for the whole selected area."},{configKey:"renderSelectedItemContentCallback",converter:z(),on:"update",type:"(item: unknown) => string | HTMLElement",description:"Custom render for one selected item."},{configKey:"customStylesCallback",converter:z(),on:"update",type:"() => string",description:"Returns a CSS string injected into the component via a replaceable style slot (§12.8)."},{configKey:"beforeSearchCallback",converter:z(),on:"update",type:"(searchTerm: string) => string | null",description:"Runs before a search; return a rewritten term or null to veto."},{configKey:"beforeSelectCallback",converter:z(),on:"update",type:"(option: unknown, selectedOptions: unknown[]) => boolean | void",description:"Runs before selecting; return false to veto."},{configKey:"beforeDeselectCallback",converter:z(),on:"update",type:"(option: unknown, selectedOptions: unknown[]) => boolean | void",description:"Runs before deselecting; return false to veto."},{configKey:"addNewCallback",converter:z(),on:"update",type:"(value: string) => unknown | Promise<unknown>",description:"Create a new option from the typed text."}],Ri=[{name:"select",description:"An option was selected. `detail.option` is the selected option; `detail.selectedOptions`/`detail.selectedValues` are the full selection."},{name:"deselect",description:"An option was removed from the selection. `detail.option` is that option."},{name:"change",description:"The selection changed. `detail.selectedOptions`/`detail.selectedValues` are the full selection."}],So=new Set(["dropdownWidth","selectedPopoverWidth","showDebugInfo","initialValues","optionsSource","optionsFormat","optionsSplitter","optionsRowSplitter"]),nt={dropdownWidth:"--ms-dropdown-width",selectedPopoverWidth:"--ms-selected-popover-width"};let Bi=null;function Ki(){return Bi??(Bi=ms(ko,"--ms-"))}const Hi=[{key:"valueMember",member:"value",callbackKey:"getValueCallback"},{key:"displayValueMember",member:"label",callbackKey:"getDisplayValueCallback"},{key:"groupMember",member:"group",callbackKey:"getGroupCallback"},{key:"iconMember",member:"icon",callbackKey:"getIconCallback"},{key:"subtitleMember",member:"subtitle",callbackKey:"getSubtitleCallback"},{key:"disabledMember",member:"disabled",callbackKey:"getDisabledCallback"}];class Pe extends ht{constructor(){super();R(this,M);R(this,X);R(this,K);R(this,ue);R(this,ct);R(this,je,null);R(this,Ge,new Set);R(this,Ue,!1);R(this,Ve,!1);R(this,De);R(this,ke);if(B(this,X,this.attachShadow({mode:"open"})),typeof this.attachInternals=="function")try{B(this,ct,this.attachInternals())}catch{}hs(f(this,X),ko),typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>this.setAttribute("data-ready","")):this.setAttribute("data-ready","")}formResetCallback(){var t;(t=f(this,K))==null||t.clearAll()}reinit(){C(this,M,zo).call(this),this.isConnected&&C(this,M,Pt).call(this)}update(t){C(this,M,No).call(this,t),"customStylesCallback"in t&&C(this,M,At).call(this),"showDebugInfo"in t&&C(this,M,Et).call(this);const i={};for(const[s,r]of Object.entries(t))So.has(s)||(i[s]=r===null?void 0:r);f(this,K)&&Object.keys(i).length>0&&(f(this,K).updateOptions(i)||C(this,M,Pt).call(this))}connect(){f(this,K)||C(this,M,Mt).call(this)}disconnect(){var t;(t=f(this,K))==null||t.destroy(),B(this,K,void 0)}get name(){return this.getAttribute("name")}set name(t){t?this.setAttribute("name",t):this.removeAttribute("name")}get selectedValue(){var t;return this.flush(),((t=f(this,K))==null?void 0:t.selectedValue)??null}get selectedItem(){var t;return this.flush(),((t=f(this,K))==null?void 0:t.selectedItem)??null}getSelected(){return this.flush(),f(this,K)?f(this,K).getSelected():[]}setSelected(t,i={}){var s;this.flush(),(s=f(this,K))==null||s.setSelected(t,i)}getValue(){return this.flush(),f(this,K)?f(this,K).getValue():null}destroy(){var t;(t=f(this,K))==null||t.destroy()}}X=new WeakMap,K=new WeakMap,ue=new WeakMap,ct=new WeakMap,je=new WeakMap,Ge=new WeakMap,Ue=new WeakMap,Ve=new WeakMap,De=new WeakMap,ke=new WeakMap,M=new WeakSet,Pt=function(){var t;(t=f(this,K))==null||t.destroy(),B(this,K,void 0),C(this,M,Mt).call(this)},Mt=function(){C(this,M,Eo).call(this),C(this,M,Ro).call(this);const t=C(this,M,$o).call(this),i=C(this,M,Vo).call(this);i&&i.length>0?f(this,ue).dataset.initialValues=JSON.stringify(i):delete f(this,ue).dataset.initialValues,B(this,K,new bo(f(this,ue),t)),C(this,M,At).call(this),C(this,M,Et).call(this)},Eo=function(){if(f(this,ue))return;const t=document.createElement("div");t.setAttribute("data-multiselect",""),this.className&&(t.className=this.className),f(this,X).appendChild(t),B(this,je,ps(f(this,X),{position:"first",className:"ms-custom-styles"})),B(this,ue,t)},$o=function(){const t={...this.config};for(const s of So)delete t[s];for(const s of Object.keys(t))t[s]===null&&delete t[s];let i=t.options;if(f(this,Ve)&&f(this,De))i&&i.length>0&&j.warn("[MultiSelectElement] Both declarative <option> elements and programmatic .options detected. Using declarative options."),i=f(this,De);else if(!i||i.length===0){const s=this.config.optionsSource;if(s!=null){const r=this.config.optionsFormat??"json",{options:n,error:a}=xo(s,r,{splitter:this.config.optionsSplitter,rowSplitter:this.config.optionsRowSplitter});a&&j.error(`[MultiSelectElement] ${a}`),i=n}}if(t.options=i,f(this,Ve))for(const{key:s,member:r,callbackKey:n}of Hi)t[s]===void 0&&!t[n]&&(t[s]=r);return t.getCounterCallback||(t.getCounterCallback=(s,r)=>r!==void 0?`+${r} more`:`${s} selected`),t.onSelect=s=>{var r;this.emit("select",{option:s,selectedOptions:((r=f(this,K))==null?void 0:r.getSelected())??[],selectedValues:C(this,M,dt).call(this)})},t.onDeselect=s=>{var r;this.emit("deselect",{option:s,selectedOptions:((r=f(this,K))==null?void 0:r.getSelected())??[],selectedValues:C(this,M,dt).call(this)})},t.onChange=s=>{this.emit("change",{selectedOptions:s,selectedValues:C(this,M,dt).call(this)})},t.container=f(this,X),t.hostElement=this,t},Vo=function(){if(f(this,ke)&&f(this,ke).length>0)return f(this,ke);const t=this.config.initialValues;return t&&t.length>0?t:void 0},dt=function(){var i;const t=(i=f(this,K))==null?void 0:i.getValue();return t==null?[]:Array.isArray(t)?t:[t]},At=function(){const t=f(this,je);if(!t)return;const i=this.config.customStylesCallback;if(typeof i!="function"){t.clear();return}try{const s=i();t.set(s),s&&C(this,M,Do).call(this,s)}catch(s){j.warn("[MultiSelectElement] customStylesCallback threw",s),t.clear()}},Do=function(t){const i=Ki();if(i.size!==0)for(const{name:s,suggestions:r}of gs(t,{prefix:"--ms-",consumed:i}))f(this,Ge).has(s)||(f(this,Ge).add(s),console.warn(`[web-multiselect] customStylesCallback sets "${s}", which no web-multiselect style consumes — it will have no effect.`+(r.length?` Did you mean: ${r.join(", ")}?`:"")+" (If it's for your own custom-rendered content, ignore this.)"))},zo=function(){for(const t of Object.keys(nt))C(this,M,Lt).call(this,nt[t],this.config[t])},No=function(t){for(const i of Object.keys(nt))i in t&&C(this,M,Lt).call(this,nt[i],t[i])},Lt=function(t,i){i==null||i===""?this.style.removeProperty(t):this.style.setProperty(t,String(i))},Ro=function(){if(f(this,Ue))return;B(this,Ue,!0);const t=C(this,M,Bo).call(this);t&&(B(this,De,t),B(this,Ve,!0))},Bo=function(){const t=Array.from(this.children);if(t.length===0)return null;const i=[];let s=!1;const r=(n,a)=>{var c,d;const l={value:n.value||((c=n.textContent)==null?void 0:c.trim())||"",label:((d=n.textContent)==null?void 0:d.trim())||n.value||""};a&&(l.group=a),n.hasAttribute("selected")&&(f(this,ke)??B(this,ke,[])).push(l.value),n.hasAttribute("disabled")&&(l.disabled=!0),n.hasAttribute("data-icon")&&(l.icon=n.getAttribute("data-icon")),n.hasAttribute("data-subtitle")&&(l.subtitle=n.getAttribute("data-subtitle")),i.push(l),s=!0};for(const n of t)if(n.tagName==="OPTION")r(n);else if(n.tagName==="OPTGROUP"){const a=n,l=a.label||a.getAttribute("label")||"Group";for(const c of Array.from(a.querySelectorAll("option")))r(c,l)}if(!s)return null;j.debug(`[MultiSelectElement] Parsed ${i.length} declarative options from Light DOM`);for(const n of t)(n.tagName==="OPTION"||n.tagName==="OPTGROUP")&&n.remove();return i},Et=function(){const t=f(this,X).querySelector(".ms__debug-info");if(t&&t.remove(),!this.config.showDebugInfo)return;const i=document.createElement("div");i.className="ms__debug-info";const s=document.createElement("details"),r=document.createElement("summary");r.textContent="Debug Info";const n=document.createElement("div");n.className="ms__debug-stats",s.appendChild(r),s.appendChild(n),i.appendChild(s),f(this,X).appendChild(i),C(this,M,$t).call(this)},$t=function(){var l,c,d,h;const t=f(this,X).querySelector(".ms__debug-stats");if(!t||!f(this,K))return;const i="2.0.0-rc01",s=typeof window<"u"&&((c=(l=window.components)==null?void 0:l["web-multiselect"])==null?void 0:c.getInstances().length)||0,r=f(this,K).getSelected().length,n=((d=this.config.options)==null?void 0:d.length)||0,a=f(this,K);t.innerHTML=`
41
+ `}),on:"reinit",type:"string",description:'Row/record delimiter for the `csv` and `plain` `data-options` formats. Default newline. Escapes honoured (e.g. `data-options-row-splitter=";"` for single-line data). Ignored for `json`.'},{configKey:"actionButtons",converter:Fo({validate:o=>Array.isArray(o)}),on:"reinit",type:"Array<Record<string, unknown>>",description:"Custom action buttons for the dropdown footer/header. Property-only; when unset the default Select-All / Clear buttons apply."},{configKey:"getValueCallback",converter:z(),on:"reinit",type:"(item: unknown) => string | number",description:"Extract an option value (overrides valueMember)."},{configKey:"getPathCallback",converter:z(),on:"reinit",type:"(item: unknown) => string",description:"Extract a node tree path (enables tree mode; overrides pathMember)."},{configKey:"getGroupCallback",converter:z(),on:"reinit",type:"(item: unknown) => string",description:"Extract the group name from an option (overrides groupMember)."},{configKey:"getDisabledCallback",converter:z(),on:"reinit",type:"(item: unknown) => boolean",description:"Whether an option is disabled (overrides disabledMember)."},{configKey:"getIsSelectableCallback",converter:z(),on:"reinit",type:"(node: unknown) => boolean",description:"Whether a tree node can be selected (overrides is-selectable-member)."},{configKey:"getSearchValueCallback",converter:z(),on:"reinit",type:"(item: unknown) => string",description:"Text an option is searched against (overrides searchValueMember)."},{configKey:"searchCallback",converter:z(),on:"reinit",type:"(searchTerm: string, signal?: AbortSignal) => Promise<unknown[]>",description:"Custom / async search; return the filtered options."},{configKey:"getDisplayValueCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Compute the display label for an option (overrides displayValueMember)."},{configKey:"getBadgeDisplayCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Compute the text shown on an option badge."},{configKey:"getBadgeClassCallback",converter:z(),on:"update",type:"(item: unknown) => string | string[]",description:"Extra CSS class(es) for an option badge."},{configKey:"getIconCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Icon for an option (overrides iconMember)."},{configKey:"getSubtitleCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Subtitle for an option (overrides subtitleMember)."},{configKey:"getFullTitleCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Full title for an option (used by badges when show-badge-full-title is on)."},{configKey:"getCounterCallback",converter:z(),on:"update",type:"(count: number, moreCount?: number) => string",description:"Render the selected-count label."},{configKey:"getValueFormatCallback",converter:z(),on:"update",type:"(selectedValues: (string | number)[]) => string",description:"Serialize the selected values for form submission."},{configKey:"getBadgeTooltipCallback",converter:z(),on:"update",type:"(item: unknown) => string | HTMLElement",description:"Tooltip content for an option badge."},{configKey:"getOptionTooltipCallback",converter:z(),on:"update",type:"(item: unknown) => string | HTMLElement",description:"Tooltip content for an option row."},{configKey:"getRemoveButtonTooltipCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Tooltip text for a badge remove button."},{configKey:"getSelectedItemClassCallback",converter:z(),on:"update",type:"(item: unknown) => string | string[]",description:"Extra CSS class(es) for a selected item."},{configKey:"renderOptionContentCallback",converter:z(),on:"update",type:"(item: unknown, context: OptionContentRenderContext) => string | HTMLElement",description:"Custom render for an option row; may return HTML or an element."},{configKey:"renderBadgeContentCallback",converter:z(),on:"update",type:"(item: unknown, context: BadgeContentRenderContext) => string | HTMLElement",description:"Custom render for a badge; may return HTML or an element."},{configKey:"renderGroupLabelContentCallback",converter:z(),on:"update",type:"(groupName: string) => string | HTMLElement",description:"Customize a group label; may return an HTML string or element."},{configKey:"renderSelectedContentCallback",converter:z(),on:"update",type:"(item: unknown) => string",description:"Custom render for the whole selected area."},{configKey:"renderSelectedItemContentCallback",converter:z(),on:"update",type:"(item: unknown) => string | HTMLElement",description:"Custom render for one selected item."},{configKey:"customStylesCallback",converter:z(),on:"update",type:"() => string",description:"Returns a CSS string injected into the component via a replaceable style slot (§12.8)."},{configKey:"beforeSearchCallback",converter:z(),on:"update",type:"(searchTerm: string) => string | null",description:"Runs before a search; return a rewritten term or null to veto."},{configKey:"beforeSelectCallback",converter:z(),on:"update",type:"(option: unknown, selectedOptions: unknown[]) => boolean | void",description:"Runs before selecting; return false to veto."},{configKey:"beforeDeselectCallback",converter:z(),on:"update",type:"(option: unknown, selectedOptions: unknown[]) => boolean | void",description:"Runs before deselecting; return false to veto."},{configKey:"addNewCallback",converter:z(),on:"update",type:"(value: string) => unknown | Promise<unknown>",description:"Create a new option from the typed text."}],Ri=[{name:"select",description:"An option was selected. `detail.option` is the selected option; `detail.selectedOptions`/`detail.selectedValues` are the full selection."},{name:"deselect",description:"An option was removed from the selection. `detail.option` is that option."},{name:"change",description:"The selection changed. `detail.selectedOptions`/`detail.selectedValues` are the full selection."}],So=new Set(["dropdownWidth","selectedPopoverWidth","showDebugInfo","initialValues","optionsSource","optionsFormat","optionsSplitter","optionsRowSplitter"]),at={dropdownWidth:"--ms-dropdown-width",selectedPopoverWidth:"--ms-selected-popover-width"};let Bi=null;function Ki(){return Bi??(Bi=ms(ko,"--ms-"))}const Hi=[{key:"valueMember",member:"value",callbackKey:"getValueCallback"},{key:"displayValueMember",member:"label",callbackKey:"getDisplayValueCallback"},{key:"groupMember",member:"group",callbackKey:"getGroupCallback"},{key:"iconMember",member:"icon",callbackKey:"getIconCallback"},{key:"subtitleMember",member:"subtitle",callbackKey:"getSubtitleCallback"},{key:"disabledMember",member:"disabled",callbackKey:"getDisabledCallback"}];class Pe extends ht{constructor(){super();R(this,M);R(this,X);R(this,K);R(this,ue);R(this,Ge,null);R(this,Ue,new Set);R(this,qe,!1);R(this,De,!1);R(this,ze);R(this,ke);B(this,X,this.attachShadow({mode:"open"})),hs(f(this,X),ko),typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>this.setAttribute("data-ready","")):this.setAttribute("data-ready","")}formResetCallback(){var t;(t=f(this,K))==null||t.clearAll()}reinit(){C(this,M,zo).call(this),this.isConnected&&C(this,M,Pt).call(this)}update(t){C(this,M,No).call(this,t),"customStylesCallback"in t&&C(this,M,At).call(this),"showDebugInfo"in t&&C(this,M,Et).call(this);const i={};for(const[s,r]of Object.entries(t))So.has(s)||(i[s]=r===null?void 0:r);f(this,K)&&Object.keys(i).length>0&&(f(this,K).updateOptions(i)||C(this,M,Pt).call(this))}connect(){f(this,K)||C(this,M,Mt).call(this)}disconnect(){var t;(t=f(this,K))==null||t.destroy(),B(this,K,void 0)}get name(){return this.getAttribute("name")}set name(t){t?this.setAttribute("name",t):this.removeAttribute("name")}get selectedValue(){var t;return this.flush(),((t=f(this,K))==null?void 0:t.selectedValue)??null}get selectedItem(){var t;return this.flush(),((t=f(this,K))==null?void 0:t.selectedItem)??null}getSelected(){return this.flush(),f(this,K)?f(this,K).getSelected():[]}setSelected(t,i={}){var s;this.flush(),(s=f(this,K))==null||s.setSelected(t,i)}getValue(){return this.flush(),f(this,K)?f(this,K).getValue():null}destroy(){var t;(t=f(this,K))==null||t.destroy()}}X=new WeakMap,K=new WeakMap,ue=new WeakMap,Ge=new WeakMap,Ue=new WeakMap,qe=new WeakMap,De=new WeakMap,ze=new WeakMap,ke=new WeakMap,M=new WeakSet,Pt=function(){var t;(t=f(this,K))==null||t.destroy(),B(this,K,void 0),C(this,M,Mt).call(this)},Mt=function(){C(this,M,Eo).call(this),C(this,M,Ro).call(this);const t=C(this,M,$o).call(this),i=C(this,M,Vo).call(this);i&&i.length>0?f(this,ue).dataset.initialValues=JSON.stringify(i):delete f(this,ue).dataset.initialValues,B(this,K,new bo(f(this,ue),t)),C(this,M,At).call(this),C(this,M,Et).call(this)},Eo=function(){if(f(this,ue))return;const t=document.createElement("div");t.setAttribute("data-multiselect",""),this.className&&(t.className=this.className),f(this,X).appendChild(t),B(this,Ge,ps(f(this,X),{position:"first",className:"ms-custom-styles"})),B(this,ue,t)},$o=function(){const t={...this.config};for(const s of So)delete t[s];for(const s of Object.keys(t))t[s]===null&&delete t[s];let i=t.options;if(f(this,De)&&f(this,ze))i&&i.length>0&&j.warn("[MultiSelectElement] Both declarative <option> elements and programmatic .options detected. Using declarative options."),i=f(this,ze);else if(!i||i.length===0){const s=this.config.optionsSource;if(s!=null){const r=this.config.optionsFormat??"json",{options:n,error:a}=xo(s,r,{splitter:this.config.optionsSplitter,rowSplitter:this.config.optionsRowSplitter});a&&j.error(`[MultiSelectElement] ${a}`),i=n}}if(t.options=i,f(this,De))for(const{key:s,member:r,callbackKey:n}of Hi)t[s]===void 0&&!t[n]&&(t[s]=r);return t.getCounterCallback||(t.getCounterCallback=(s,r)=>r!==void 0?`+${r} more`:`${s} selected`),t.onSelect=s=>{var r;this.emit("select",{option:s,selectedOptions:((r=f(this,K))==null?void 0:r.getSelected())??[],selectedValues:C(this,M,dt).call(this)})},t.onDeselect=s=>{var r;this.emit("deselect",{option:s,selectedOptions:((r=f(this,K))==null?void 0:r.getSelected())??[],selectedValues:C(this,M,dt).call(this)})},t.onChange=s=>{this.emit("change",{selectedOptions:s,selectedValues:C(this,M,dt).call(this)})},t.container=f(this,X),t.hostElement=this,t},Vo=function(){if(f(this,ke)&&f(this,ke).length>0)return f(this,ke);const t=this.config.initialValues;return t&&t.length>0?t:void 0},dt=function(){var i;const t=(i=f(this,K))==null?void 0:i.getValue();return t==null?[]:Array.isArray(t)?t:[t]},At=function(){const t=f(this,Ge);if(!t)return;const i=this.config.customStylesCallback;if(typeof i!="function"){t.clear();return}try{const s=i();t.set(s),s&&C(this,M,Do).call(this,s)}catch(s){j.warn("[MultiSelectElement] customStylesCallback threw",s),t.clear()}},Do=function(t){const i=Ki();if(i.size!==0)for(const{name:s,suggestions:r}of gs(t,{prefix:"--ms-",consumed:i}))f(this,Ue).has(s)||(f(this,Ue).add(s),console.warn(`[web-multiselect] customStylesCallback sets "${s}", which no web-multiselect style consumes — it will have no effect.`+(r.length?` Did you mean: ${r.join(", ")}?`:"")+" (If it's for your own custom-rendered content, ignore this.)"))},zo=function(){for(const t of Object.keys(at))C(this,M,Lt).call(this,at[t],this.config[t])},No=function(t){for(const i of Object.keys(at))i in t&&C(this,M,Lt).call(this,at[i],t[i])},Lt=function(t,i){i==null||i===""?this.style.removeProperty(t):this.style.setProperty(t,String(i))},Ro=function(){if(f(this,qe))return;B(this,qe,!0);const t=C(this,M,Bo).call(this);t&&(B(this,ze,t),B(this,De,!0))},Bo=function(){const t=Array.from(this.children);if(t.length===0)return null;const i=[];let s=!1;const r=(n,a)=>{var c,d;const l={value:n.value||((c=n.textContent)==null?void 0:c.trim())||"",label:((d=n.textContent)==null?void 0:d.trim())||n.value||""};a&&(l.group=a),n.hasAttribute("selected")&&(f(this,ke)??B(this,ke,[])).push(l.value),n.hasAttribute("disabled")&&(l.disabled=!0),n.hasAttribute("data-icon")&&(l.icon=n.getAttribute("data-icon")),n.hasAttribute("data-subtitle")&&(l.subtitle=n.getAttribute("data-subtitle")),i.push(l),s=!0};for(const n of t)if(n.tagName==="OPTION")r(n);else if(n.tagName==="OPTGROUP"){const a=n,l=a.label||a.getAttribute("label")||"Group";for(const c of Array.from(a.querySelectorAll("option")))r(c,l)}if(!s)return null;j.debug(`[MultiSelectElement] Parsed ${i.length} declarative options from Light DOM`);for(const n of t)(n.tagName==="OPTION"||n.tagName==="OPTGROUP")&&n.remove();return i},Et=function(){const t=f(this,X).querySelector(".ms__debug-info");if(t&&t.remove(),!this.config.showDebugInfo)return;const i=document.createElement("div");i.className="ms__debug-info";const s=document.createElement("details"),r=document.createElement("summary");r.textContent="Debug Info";const n=document.createElement("div");n.className="ms__debug-stats",s.appendChild(r),s.appendChild(n),i.appendChild(s),f(this,X).appendChild(i),C(this,M,$t).call(this)},$t=function(){var l,c,d,h;const t=f(this,X).querySelector(".ms__debug-stats");if(!t||!f(this,K))return;const i="2.0.0-rc02",s=typeof window<"u"&&((c=(l=window.components)==null?void 0:l["web-multiselect"])==null?void 0:c.getInstances().length)||0,r=f(this,K).getSelected().length,n=((d=this.config.options)==null?void 0:d.length)||0,a=f(this,K);t.innerHTML=`
42
42
  <span>Version: ${i}</span>
43
43
  <span>Total Instances: ${s}</span>
44
44
  <span>Options: ${n}</span>
@@ -47,4 +47,4 @@ ${i}`:t}attachOptionTooltips(){if(this.destroyAllOptionTooltips(),!this.options.
47
47
  <span>Dropdown: ${a.isOpen?"Open":"Closed"}</span>
48
48
  <span>Search: ${a.searchTerm||"none"}</span>
49
49
  <span>Loading: ${a.isLoading?"Yes":"No"}</span>
50
- `,setTimeout(()=>{this.config.showDebugInfo&&C(this,M,$t).call(this)},500)},y(Pe,"formAssociated",!0),y(Pe,"inputs",Ni),y(Pe,"events",Ri),typeof customElements<"u"&&!customElements.get("web-multiselect")&&customElements.define("web-multiselect",Pe),cs("web-multiselect",Pe,{config:{name:"@keenmate/web-multiselect",version:"2.0.0-rc01",author:"Keenmate",license:"MIT",repository:"git+https://github.com/keenmate/web-multiselect.git",homepage:"https://web-multiselect.keenmate.dev"},logging:ne}),O.LOGGING_CATEGORIES=Ci,O.MultiSelectElement=Pe,O.OPTIONS_FORMATS=vo,O.WebMultiSelect=bo,O.dataLogger=j,O.disableLogging=Ti,O.enableLogging=Si,O.initLogger=Re,O.interactionLogger=G,O.parseOptionsData=xo,O.setCategoryLevel=Oi,O.setLogLevel=Ii,O.uiLogger=J,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
50
+ `,setTimeout(()=>{this.config.showDebugInfo&&C(this,M,$t).call(this)},500)},y(Pe,"formAssociated",!0),y(Pe,"inputs",Ni),y(Pe,"events",Ri),typeof customElements<"u"&&!customElements.get("web-multiselect")&&customElements.define("web-multiselect",Pe),cs("web-multiselect",Pe,{config:{name:"@keenmate/web-multiselect",version:"2.0.0-rc02",author:"Keenmate",license:"MIT",repository:"git+https://github.com/keenmate/web-multiselect.git",homepage:"https://web-multiselect.keenmate.dev"},logging:ne}),O.LOGGING_CATEGORIES=Ci,O.MultiSelectElement=Pe,O.OPTIONS_FORMATS=vo,O.WebMultiSelect=bo,O.dataLogger=j,O.disableLogging=Ti,O.enableLogging=Si,O.initLogger=Be,O.interactionLogger=G,O.parseOptionsData=xo,O.setCategoryLevel=Oi,O.setLogLevel=Ii,O.uiLogger=J,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});