@keenmate/web-multiselect 1.0.0 → 1.1.0
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.
- package/dist/multiselect.js +1146 -1135
- package/dist/multiselect.umd.js +42 -42
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/scss/_badges-display.scss +76 -76
- package/src/scss/_css-variables.scss +358 -215
- package/src/scss/_input-dropdown.scss +71 -70
- package/src/scss/_modifiers.scss +38 -38
- package/src/scss/_options.scss +75 -70
- package/src/scss/_rtl.scss +31 -31
- package/src/scss/_tooltips-popover.scss +51 -51
- package/src/scss/_variables.scss +5 -2
package/dist/multiselect.umd.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
(function(x,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(x=typeof globalThis<"u"?globalThis:x||self,T(x.MultiSelect={}))})(this,function(x){"use strict";var bi=Object.defineProperty;var fi=(x,T,L)=>T in x?bi(x,T,{enumerable:!0,configurable:!0,writable:!0,value:L}):x[T]=L;var m=(x,T,L)=>fi(x,typeof T!="symbol"?T+"":T,L);const T=Math.min,L=Math.max,ae=Math.round,ce=Math.floor,P=o=>({x:o,y:o}),ut={left:"right",right:"left",bottom:"top",top:"bottom"},gt={start:"end",end:"start"};function Ee(o,e,t){return L(o,T(e,t))}function de(o,e){return typeof o=="function"?o(e):o}function F(o){return o.split("-")[0]}function he(o){return o.split("-")[1]}function $e(o){return o==="x"?"y":"x"}function Ve(o){return o==="y"?"height":"width"}const bt=new Set(["top","bottom"]);function z(o){return bt.has(F(o))?"y":"x"}function Me(o){return $e(z(o))}function ft(o,e,t){t===void 0&&(t=!1);const i=he(o),s=Me(o),n=Ve(s);let l=s==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[n]>e.floating[n]&&(l=pe(l)),[l,pe(l)]}function vt(o){const e=pe(o);return[Ce(o),e,Ce(e)]}function Ce(o){return o.replace(/start|end/g,e=>gt[e])}const Pe=["left","right"],Be=["right","left"],wt=["top","bottom"],Ct=["bottom","top"];function _t(o,e,t){switch(o){case"top":case"bottom":return t?e?Be:Pe:e?Pe:Be;case"left":case"right":return e?wt:Ct;default:return[]}}function yt(o,e,t,i){const s=he(o);let n=_t(F(o),t==="start",i);return s&&(n=n.map(l=>l+"-"+s),e&&(n=n.concat(n.map(Ce)))),n}function pe(o){return o.replace(/left|right|bottom|top/g,e=>ut[e])}function xt(o){return{top:0,right:0,bottom:0,left:0,...o}}function kt(o){return typeof o!="number"?xt(o):{top:o,right:o,bottom:o,left:o}}function me(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 De(o,e,t){let{reference:i,floating:s}=o;const n=z(e),l=Me(e),r=Ve(l),a=F(e),d=n==="y",c=i.x+i.width/2-s.width/2,p=i.y+i.height/2-s.height/2,u=i[r]/2-s[r]/2;let h;switch(a){case"top":h={x:c,y:i.y-s.height};break;case"bottom":h={x:c,y:i.y+i.height};break;case"right":h={x:i.x+i.width,y:p};break;case"left":h={x:i.x-s.width,y:p};break;default:h={x:i.x,y:i.y}}switch(he(e)){case"start":h[l]-=u*(t&&d?-1:1);break;case"end":h[l]+=u*(t&&d?-1:1);break}return h}const St=async(o,e,t)=>{const{placement:i="bottom",strategy:s="absolute",middleware:n=[],platform:l}=t,r=n.filter(Boolean),a=await(l.isRTL==null?void 0:l.isRTL(e));let d=await l.getElementRects({reference:o,floating:e,strategy:s}),{x:c,y:p}=De(d,i,a),u=i,h={},g=0;for(let b=0;b<r.length;b++){const{name:v,fn:w}=r[b],{x:C,y,data:A,reset:S}=await w({x:c,y:p,initialPlacement:i,placement:u,strategy:s,middlewareData:h,rects:d,platform:l,elements:{reference:o,floating:e}});c=C??c,p=y??p,h={...h,[v]:{...h[v],...A}},S&&g<=50&&(g++,typeof S=="object"&&(S.placement&&(u=S.placement),S.rects&&(d=S.rects===!0?await l.getElementRects({reference:o,floating:e,strategy:s}):S.rects),{x:c,y:p}=De(d,u,a)),b=-1)}return{x:c,y:p,placement:u,strategy:s,middlewareData:h}};async function ze(o,e){var t;e===void 0&&(e={});const{x:i,y:s,platform:n,rects:l,elements:r,strategy:a}=o,{boundary:d="clippingAncestors",rootBoundary:c="viewport",elementContext:p="floating",altBoundary:u=!1,padding:h=0}=de(e,o),g=kt(h),v=r[u?p==="floating"?"reference":"floating":p],w=me(await n.getClippingRect({element:(t=await(n.isElement==null?void 0:n.isElement(v)))==null||t?v:v.contextElement||await(n.getDocumentElement==null?void 0:n.getDocumentElement(r.floating)),boundary:d,rootBoundary:c,strategy:a})),C=p==="floating"?{x:i,y:s,width:l.floating.width,height:l.floating.height}:l.reference,y=await(n.getOffsetParent==null?void 0:n.getOffsetParent(r.floating)),A=await(n.isElement==null?void 0:n.isElement(y))?await(n.getScale==null?void 0:n.getScale(y))||{x:1,y:1}:{x:1,y:1},S=me(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({elements:r,rect:C,offsetParent:y,strategy:a}):C);return{top:(w.top-S.top+g.top)/A.y,bottom:(S.bottom-w.bottom+g.bottom)/A.y,left:(w.left-S.left+g.left)/A.x,right:(S.right-w.right+g.right)/A.x}}const It=function(o){return o===void 0&&(o={}),{name:"flip",options:o,async fn(e){var t,i;const{placement:s,middlewareData:n,rects:l,initialPlacement:r,platform:a,elements:d}=e,{mainAxis:c=!0,crossAxis:p=!0,fallbackPlacements:u,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...v}=de(o,e);if((t=n.arrow)!=null&&t.alignmentOffset)return{};const w=F(s),C=z(r),y=F(r)===r,A=await(a.isRTL==null?void 0:a.isRTL(d.floating)),S=u||(y||!b?[pe(r)]:vt(r)),le=g!=="none";!u&&le&&S.push(...yt(r,b,g,A));const X=[r,...S],Oe=await ze(e,v),we=[];let J=((i=n.flip)==null?void 0:i.overflows)||[];if(c&&we.push(Oe[w]),p){const G=ft(s,l,A);we.push(Oe[G[0]],Oe[G[1]])}if(J=[...J,{placement:s,overflows:we}],!we.every(G=>G<=0)){var ht,pt;const G=(((ht=n.flip)==null?void 0:ht.index)||0)+1,Le=X[G];if(Le&&(!(p==="alignment"?C!==z(Le):!1)||J.every(M=>z(M.placement)===C?M.overflows[0]>0:!0)))return{data:{index:G,overflows:J},reset:{placement:Le}};let re=(pt=J.filter(j=>j.overflows[0]<=0).sort((j,M)=>j.overflows[1]-M.overflows[1])[0])==null?void 0:pt.placement;if(!re)switch(h){case"bestFit":{var mt;const j=(mt=J.filter(M=>{if(le){const N=z(M.placement);return N===C||N==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(N=>N>0).reduce((N,gi)=>N+gi,0)]).sort((M,N)=>M[1]-N[1])[0])==null?void 0:mt[0];j&&(re=j);break}case"initialPlacement":re=r;break}if(s!==re)return{reset:{placement:re}}}return{}}}},At=new Set(["left","top"]);async function Tt(o,e){const{placement:t,platform:i,elements:s}=o,n=await(i.isRTL==null?void 0:i.isRTL(s.floating)),l=F(t),r=he(t),a=z(t)==="y",d=At.has(l)?-1:1,c=n&&a?-1:1,p=de(e,o);let{mainAxis:u,crossAxis:h,alignmentAxis:g}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return r&&typeof g=="number"&&(h=r==="end"?g*-1:g),a?{x:h*c,y:u*d}:{x:u*d,y:h*c}}const Ot=function(o){return o===void 0&&(o=0),{name:"offset",options:o,async fn(e){var t,i;const{x:s,y:n,placement:l,middlewareData:r}=e,a=await Tt(e,o);return l===((t=r.offset)==null?void 0:t.placement)&&(i=r.arrow)!=null&&i.alignmentOffset?{}:{x:s+a.x,y:n+a.y,data:{...a,placement:l}}}}},Lt=function(o){return o===void 0&&(o={}),{name:"shift",options:o,async fn(e){const{x:t,y:i,placement:s}=e,{mainAxis:n=!0,crossAxis:l=!1,limiter:r={fn:v=>{let{x:w,y:C}=v;return{x:w,y:C}}},...a}=de(o,e),d={x:t,y:i},c=await ze(e,a),p=z(F(s)),u=$e(p);let h=d[u],g=d[p];if(n){const v=u==="y"?"top":"left",w=u==="y"?"bottom":"right",C=h+c[v],y=h-c[w];h=Ee(C,h,y)}if(l){const v=p==="y"?"top":"left",w=p==="y"?"bottom":"right",C=g+c[v],y=g-c[w];g=Ee(C,g,y)}const b=r.fn({...e,[u]:h,[p]:g});return{...b,data:{x:b.x-t,y:b.y-i,enabled:{[u]:n,[p]:l}}}}}};function ue(){return typeof window<"u"}function W(o){return Re(o)?(o.nodeName||"").toLowerCase():"#document"}function O(o){var e;return(o==null||(e=o.ownerDocument)==null?void 0:e.defaultView)||window}function B(o){var e;return(e=(Re(o)?o.ownerDocument:o.document)||window.document)==null?void 0:e.documentElement}function Re(o){return ue()?o instanceof Node||o instanceof O(o).Node:!1}function E(o){return ue()?o instanceof Element||o instanceof O(o).Element:!1}function D(o){return ue()?o instanceof HTMLElement||o instanceof O(o).HTMLElement:!1}function Ne(o){return!ue()||typeof ShadowRoot>"u"?!1:o instanceof ShadowRoot||o instanceof O(o).ShadowRoot}const Et=new Set(["inline","contents"]);function q(o){const{overflow:e,overflowX:t,overflowY:i,display:s}=$(o);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&!Et.has(s)}const $t=new Set(["table","td","th"]);function Vt(o){return $t.has(W(o))}const Mt=[":popover-open",":modal"];function ge(o){return Mt.some(e=>{try{return o.matches(e)}catch{return!1}})}const Pt=["transform","translate","scale","rotate","perspective"],Bt=["transform","translate","scale","rotate","perspective","filter"],Dt=["paint","layout","strict","content"];function _e(o){const e=ye(),t=E(o)?$(o):o;return Pt.some(i=>t[i]?t[i]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||Bt.some(i=>(t.willChange||"").includes(i))||Dt.some(i=>(t.contain||"").includes(i))}function zt(o){let e=R(o);for(;D(e)&&!K(e);){if(_e(e))return e;if(ge(e))return null;e=R(e)}return null}function ye(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Rt=new Set(["html","body","#document"]);function K(o){return Rt.has(W(o))}function $(o){return O(o).getComputedStyle(o)}function be(o){return E(o)?{scrollLeft:o.scrollLeft,scrollTop:o.scrollTop}:{scrollLeft:o.scrollX,scrollTop:o.scrollY}}function R(o){if(W(o)==="html")return o;const e=o.assignedSlot||o.parentNode||Ne(o)&&o.host||B(o);return Ne(e)?e.host:e}function Fe(o){const e=R(o);return K(e)?o.ownerDocument?o.ownerDocument.body:o.body:D(e)&&q(e)?e:Fe(e)}function Z(o,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);const s=Fe(o),n=s===((i=o.ownerDocument)==null?void 0:i.body),l=O(s);if(n){const r=xe(l);return e.concat(l,l.visualViewport||[],q(s)?s:[],r&&t?Z(r):[])}return e.concat(s,Z(s,[],t))}function xe(o){return o.parent&&Object.getPrototypeOf(o.parent)?o.frameElement:null}function He(o){const e=$(o);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const s=D(o),n=s?o.offsetWidth:t,l=s?o.offsetHeight:i,r=ae(t)!==n||ae(i)!==l;return r&&(t=n,i=l),{width:t,height:i,$:r}}function ke(o){return E(o)?o:o.contextElement}function Y(o){const e=ke(o);if(!D(e))return P(1);const t=e.getBoundingClientRect(),{width:i,height:s,$:n}=He(e);let l=(n?ae(t.width):t.width)/i,r=(n?ae(t.height):t.height)/s;return(!l||!Number.isFinite(l))&&(l=1),(!r||!Number.isFinite(r))&&(r=1),{x:l,y:r}}const Nt=P(0);function Ue(o){const e=O(o);return!ye()||!e.visualViewport?Nt:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Ft(o,e,t){return e===void 0&&(e=!1),!t||e&&t!==O(o)?!1:e}function H(o,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const s=o.getBoundingClientRect(),n=ke(o);let l=P(1);e&&(i?E(i)&&(l=Y(i)):l=Y(o));const r=Ft(n,t,i)?Ue(n):P(0);let a=(s.left+r.x)/l.x,d=(s.top+r.y)/l.y,c=s.width/l.x,p=s.height/l.y;if(n){const u=O(n),h=i&&E(i)?O(i):i;let g=u,b=xe(g);for(;b&&i&&h!==g;){const v=Y(b),w=b.getBoundingClientRect(),C=$(b),y=w.left+(b.clientLeft+parseFloat(C.paddingLeft))*v.x,A=w.top+(b.clientTop+parseFloat(C.paddingTop))*v.y;a*=v.x,d*=v.y,c*=v.x,p*=v.y,a+=y,d+=A,g=O(b),b=xe(g)}}return me({width:c,height:p,x:a,y:d})}function fe(o,e){const t=be(o).scrollLeft;return e?e.left+t:H(B(o)).left+t}function Ge(o,e){const t=o.getBoundingClientRect(),i=t.left+e.scrollLeft-fe(o,t),s=t.top+e.scrollTop;return{x:i,y:s}}function Ht(o){let{elements:e,rect:t,offsetParent:i,strategy:s}=o;const n=s==="fixed",l=B(i),r=e?ge(e.floating):!1;if(i===l||r&&n)return t;let a={scrollLeft:0,scrollTop:0},d=P(1);const c=P(0),p=D(i);if((p||!p&&!n)&&((W(i)!=="body"||q(l))&&(a=be(i)),D(i))){const h=H(i);d=Y(i),c.x=h.x+i.clientLeft,c.y=h.y+i.clientTop}const u=l&&!p&&!n?Ge(l,a):P(0);return{width:t.width*d.x,height:t.height*d.y,x:t.x*d.x-a.scrollLeft*d.x+c.x+u.x,y:t.y*d.y-a.scrollTop*d.y+c.y+u.y}}function Ut(o){return Array.from(o.getClientRects())}function Gt(o){const e=B(o),t=be(o),i=o.ownerDocument.body,s=L(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),n=L(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let l=-t.scrollLeft+fe(o);const r=-t.scrollTop;return $(i).direction==="rtl"&&(l+=L(e.clientWidth,i.clientWidth)-s),{width:s,height:n,x:l,y:r}}const je=25;function jt(o,e){const t=O(o),i=B(o),s=t.visualViewport;let n=i.clientWidth,l=i.clientHeight,r=0,a=0;if(s){n=s.width,l=s.height;const c=ye();(!c||c&&e==="fixed")&&(r=s.offsetLeft,a=s.offsetTop)}const d=fe(i);if(d<=0){const c=i.ownerDocument,p=c.body,u=getComputedStyle(p),h=c.compatMode==="CSS1Compat"&&parseFloat(u.marginLeft)+parseFloat(u.marginRight)||0,g=Math.abs(i.clientWidth-p.clientWidth-h);g<=je&&(n-=g)}else d<=je&&(n+=d);return{width:n,height:l,x:r,y:a}}const Wt=new Set(["absolute","fixed"]);function Kt(o,e){const t=H(o,!0,e==="fixed"),i=t.top+o.clientTop,s=t.left+o.clientLeft,n=D(o)?Y(o):P(1),l=o.clientWidth*n.x,r=o.clientHeight*n.y,a=s*n.x,d=i*n.y;return{width:l,height:r,x:a,y:d}}function We(o,e,t){let i;if(e==="viewport")i=jt(o,t);else if(e==="document")i=Gt(B(o));else if(E(e))i=Kt(e,t);else{const s=Ue(o);i={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return me(i)}function Ke(o,e){const t=R(o);return t===e||!E(t)||K(t)?!1:$(t).position==="fixed"||Ke(t,e)}function Yt(o,e){const t=e.get(o);if(t)return t;let i=Z(o,[],!1).filter(r=>E(r)&&W(r)!=="body"),s=null;const n=$(o).position==="fixed";let l=n?R(o):o;for(;E(l)&&!K(l);){const r=$(l),a=_e(l);!a&&r.position==="fixed"&&(s=null),(n?!a&&!s:!a&&r.position==="static"&&!!s&&Wt.has(s.position)||q(l)&&!a&&Ke(o,l))?i=i.filter(c=>c!==l):s=r,l=R(l)}return e.set(o,i),i}function Xt(o){let{element:e,boundary:t,rootBoundary:i,strategy:s}=o;const l=[...t==="clippingAncestors"?ge(e)?[]:Yt(e,this._c):[].concat(t),i],r=l[0],a=l.reduce((d,c)=>{const p=We(e,c,s);return d.top=L(p.top,d.top),d.right=T(p.right,d.right),d.bottom=T(p.bottom,d.bottom),d.left=L(p.left,d.left),d},We(e,r,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Jt(o){const{width:e,height:t}=He(o);return{width:e,height:t}}function qt(o,e,t){const i=D(e),s=B(e),n=t==="fixed",l=H(o,!0,n,e);let r={scrollLeft:0,scrollTop:0};const a=P(0);function d(){a.x=fe(s)}if(i||!i&&!n)if((W(e)!=="body"||q(s))&&(r=be(e)),i){const h=H(e,!0,n,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else s&&d();n&&!i&&s&&d();const c=s&&!i&&!n?Ge(s,r):P(0),p=l.left+r.scrollLeft-a.x-c.x,u=l.top+r.scrollTop-a.y-c.y;return{x:p,y:u,width:l.width,height:l.height}}function Se(o){return $(o).position==="static"}function Ye(o,e){if(!D(o)||$(o).position==="fixed")return null;if(e)return e(o);let t=o.offsetParent;return B(o)===t&&(t=t.ownerDocument.body),t}function Xe(o,e){const t=O(o);if(ge(o))return t;if(!D(o)){let s=R(o);for(;s&&!K(s);){if(E(s)&&!Se(s))return s;s=R(s)}return t}let i=Ye(o,e);for(;i&&Vt(i)&&Se(i);)i=Ye(i,e);return i&&K(i)&&Se(i)&&!_e(i)?t:i||zt(o)||t}const Zt=async function(o){const e=this.getOffsetParent||Xe,t=this.getDimensions,i=await t(o.floating);return{reference:qt(o.reference,await e(o.floating),o.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Qt(o){return $(o).direction==="rtl"}const ei={convertOffsetParentRelativeRectToViewportRelativeRect:Ht,getDocumentElement:B,getClippingRect:Xt,getOffsetParent:Xe,getElementRects:Zt,getClientRects:Ut,getDimensions:Jt,getScale:Y,isElement:E,isRTL:Qt};function Je(o,e){return o.x===e.x&&o.y===e.y&&o.width===e.width&&o.height===e.height}function ti(o,e){let t=null,i;const s=B(o);function n(){var r;clearTimeout(i),(r=t)==null||r.disconnect(),t=null}function l(r,a){r===void 0&&(r=!1),a===void 0&&(a=1),n();const d=o.getBoundingClientRect(),{left:c,top:p,width:u,height:h}=d;if(r||e(),!u||!h)return;const g=ce(p),b=ce(s.clientWidth-(c+u)),v=ce(s.clientHeight-(p+h)),w=ce(c),y={rootMargin:-g+"px "+-b+"px "+-v+"px "+-w+"px",threshold:L(0,T(1,a))||1};let A=!0;function S(le){const X=le[0].intersectionRatio;if(X!==a){if(!A)return l();X?l(!1,X):i=setTimeout(()=>{l(!1,1e-7)},1e3)}X===1&&!Je(d,o.getBoundingClientRect())&&l(),A=!1}try{t=new IntersectionObserver(S,{...y,root:s.ownerDocument})}catch{t=new IntersectionObserver(S,y)}t.observe(o)}return l(!0),n}function Q(o,e,t,i){i===void 0&&(i={});const{ancestorScroll:s=!0,ancestorResize:n=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:r=typeof IntersectionObserver=="function",animationFrame:a=!1}=i,d=ke(o),c=s||n?[...d?Z(d):[],...Z(e)]:[];c.forEach(w=>{s&&w.addEventListener("scroll",t,{passive:!0}),n&&w.addEventListener("resize",t)});const p=d&&r?ti(d,t):null;let u=-1,h=null;l&&(h=new ResizeObserver(w=>{let[C]=w;C&&C.target===d&&h&&(h.unobserve(e),cancelAnimationFrame(u),u=requestAnimationFrame(()=>{var y;(y=h)==null||y.observe(e)})),t()}),d&&!a&&h.observe(d),h.observe(e));let g,b=a?H(o):null;a&&v();function v(){const w=H(o);b&&!Je(b,w)&&t(),b=w,g=requestAnimationFrame(v)}return t(),()=>{var w;c.forEach(C=>{s&&C.removeEventListener("scroll",t),n&&C.removeEventListener("resize",t)}),p==null||p(),(w=h)==null||w.disconnect(),h=null,a&&cancelAnimationFrame(g)}}const ee=Ot,te=Lt,ve=It,ie=(o,e,t)=>{const i=new Map,s={platform:ei,...t},n={...s.platform,_c:i};return St(o,e,{...s,platform:n})};var qe=function(){},V="undefined",ii=typeof window!==V&&typeof window.navigator!==V&&/Trident\/|MSIE /.test(window.navigator.userAgent),Ie=["trace","debug","info","warn","error"],oe={},_=null;function Ze(o,e){var t=o[e];if(typeof t.bind=="function")return t.bind(o);try{return Function.prototype.bind.call(t,o)}catch{return function(){return Function.prototype.apply.apply(t,[o,arguments])}}}function oi(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function si(o){return o==="debug"&&(o="log"),typeof console===V?!1:o==="trace"&&ii?oi:console[o]!==void 0?Ze(console,o):console.log!==void 0?Ze(console,"log"):qe}function se(){for(var o=this.getLevel(),e=0;e<Ie.length;e++){var t=Ie[e];this[t]=e<o?qe:this.methodFactory(t,o,this.name)}if(this.log=this.debug,typeof console===V&&o<this.levels.SILENT)return"No console available for logging"}function ni(o){return function(){typeof console!==V&&(se.call(this),this[o].apply(this,arguments))}}function li(o,e,t){return si(o)||ni.apply(this,arguments)}function Qe(o,e){var t=this,i,s,n,l="loglevel";typeof o=="string"?l+=":"+o:typeof o=="symbol"&&(l=void 0);function r(u){var h=(Ie[u]||"silent").toUpperCase();if(!(typeof window===V||!l)){try{window.localStorage[l]=h;return}catch{}try{window.document.cookie=encodeURIComponent(l)+"="+h+";"}catch{}}}function a(){var u;if(!(typeof window===V||!l)){try{u=window.localStorage[l]}catch{}if(typeof u===V)try{var h=window.document.cookie,g=encodeURIComponent(l),b=h.indexOf(g+"=");b!==-1&&(u=/^([^;]+)/.exec(h.slice(b+g.length+1))[1])}catch{}return t.levels[u]===void 0&&(u=void 0),u}}function d(){if(!(typeof window===V||!l)){try{window.localStorage.removeItem(l)}catch{}try{window.document.cookie=encodeURIComponent(l)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function c(u){var h=u;if(typeof h=="string"&&t.levels[h.toUpperCase()]!==void 0&&(h=t.levels[h.toUpperCase()]),typeof h=="number"&&h>=0&&h<=t.levels.SILENT)return h;throw new TypeError("log.setLevel() called with invalid level: "+u)}t.name=o,t.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},t.methodFactory=e||li,t.getLevel=function(){return n??s??i},t.setLevel=function(u,h){return n=c(u),h!==!1&&r(n),se.call(t)},t.setDefaultLevel=function(u){s=c(u),a()||t.setLevel(u,!1)},t.resetLevel=function(){n=null,d(),se.call(t)},t.enableAll=function(u){t.setLevel(t.levels.TRACE,u)},t.disableAll=function(u){t.setLevel(t.levels.SILENT,u)},t.rebuild=function(){if(_!==t&&(i=c(_.getLevel())),se.call(t),_===t)for(var u in oe)oe[u].rebuild()},i=c(_?_.getLevel():"WARN");var p=a();p!=null&&(n=c(p)),se.call(t)}_=new Qe,_.getLogger=function(e){if(typeof e!="symbol"&&typeof e!="string"||e==="")throw new TypeError("You must supply a name when creating a logger.");var t=oe[e];return t||(t=oe[e]=new Qe(e,_.methodFactory)),t};var ri=typeof window!==V?window.log:void 0;_.noConflict=function(){return typeof window!==V&&window.log===_&&(window.log=ri),_},_.getLoggers=function(){return oe},_.default=_;var ai=function(o){for(var e=1,t=arguments.length,i;e<t;e++)for(i in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],i)&&(o[i]=arguments[e][i]);return o},ci={template:"[%t] %l:",levelFormatter:function(o){return o.toUpperCase()},nameFormatter:function(o){return o||"root"},timestampFormatter:function(o){return o.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},et,U={},di=function(o){if(!o||!o.getLogger)throw new TypeError("Argument is not a root logger");et=o},hi=function(o,e){if(!o||!o.setLevel)throw new TypeError("Argument is not a logger");var t=o.methodFactory,i=o.name||"",s=U[i]||U[""]||ci;function n(l,r,a){var d=t(l,r,a),c=U[a]||U[""],p=c.template.indexOf("%t")!==-1,u=c.template.indexOf("%l")!==-1,h=c.template.indexOf("%n")!==-1;return function(){for(var g="",b=arguments.length,v=Array(b),w=0;w<b;w++)v[w]=arguments[w];if(i||!U[a]){var C=c.timestampFormatter(new Date),y=c.levelFormatter(l),A=c.nameFormatter(a);c.format?g+=c.format(y,A,C):(g+=c.template,p&&(g=g.replace(/%t/,C)),u&&(g=g.replace(/%l/,y)),h&&(g=g.replace(/%n/,A))),v.length&&typeof v[0]=="string"?v[0]=g+" "+v[0]:v.unshift(g)}d.apply(void 0,v)}}return U[i]||(o.methodFactory=n),e=e||{},e.template&&(e.format=void 0),U[i]=ai({},s,e),o.setLevel(o.getLevel()),et||o.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),o},tt={reg:di,apply:hi};const it={debug:"#0ea5e9",info:"#10b981",warn:"#f59e0b",error:"#ef4444"};tt.reg(_),tt.apply(_,{format(o,e,t){return it[o.toLowerCase()],`%c[${t}]%c %c[${o}]%c ${e?`%c[${e}]%c `:""}`},timestampFormatter(o){return o.toTimeString().split(" ")[0]+"."+o.getMilliseconds().toString().padStart(3,"0")}});const pi=_.methodFactory;_.methodFactory=function(o,e,t){const i=pi(o,e,t);return function(...s){if(s.length>0&&typeof s[0]=="string"&&s[0].includes("%c")){const n=it[o]||"#666",l=[s[0],`color: ${n}; font-weight: bold;`,"color: inherit;",`color: ${n}; font-weight: bold;`,"color: inherit;",...t?[`color: ${n}; font-weight: bold;`,"color: inherit;"]:[],...s.slice(1)];i(...l)}else i(...s)}},_.setLevel("silent");const ne=_.getLogger("MULTISELECT:INIT"),k=_.getLogger("MULTISELECT:DATA"),f=_.getLogger("MULTISELECT:UI"),I=_.getLogger("MULTISELECT:INTERACTION"),ot=["MULTISELECT:INIT","MULTISELECT:DATA","MULTISELECT:UI","MULTISELECT:INTERACTION"];function st(){_.setLevel("debug")}function nt(){_.setLevel("silent")}function lt(o){_.setLevel(o)}function rt(o,e){_.getLogger(o).setLevel(e)}class at{constructor(e){m(this,"container");m(this,"wrapper");m(this,"viewport");m(this,"itemHeight");m(this,"items");m(this,"renderItem");m(this,"bufferSize");m(this,"onVisibleRangeChange");m(this,"onScroll");m(this,"scrollTop",0);m(this,"viewportHeight",0);m(this,"visibleStart",0);m(this,"visibleEnd",0);m(this,"scrollHandler");m(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="ml__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="ml__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(){this.viewportHeight=this.container.clientHeight}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 n=this.items[s],l=this.renderItem(n,s),r=s*this.itemHeight;i+=`<div class="ml__virtual-item" style="position: absolute; top: ${r}px; left: 0; right: 0; height: ${this.itemHeight}px;" data-index="${s}">`,i+=l,i+="</div>"}this.viewport.innerHTML=i}setItems(e){this.items=e,this.wrapper.style.height=`${e.length*this.itemHeight}px`,this.updateViewportHeight(),this.visibleStart=-1,this.visibleEnd=-1,this.render()}scrollToIndex(e){if(e<0||e>=this.items.length)return;const t=e*this.itemHeight;this.container.scrollTop=t}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=""}}class ct{constructor(e,t={}){m(this,"element");m(this,"instanceId");m(this,"options");m(this,"isOpen",!1);m(this,"selectedValues",new Set);m(this,"selectedOptions",new Map);m(this,"allOptions",[]);m(this,"filteredOptions",[]);m(this,"hiddenInputs",[]);m(this,"focusedIndex",-1);m(this,"matchingIndices",new Set);m(this,"searchTerm","");m(this,"isLoading",!1);m(this,"showSelectedPopover",!1);m(this,"selectedPopoverPlacement",null);m(this,"dropdownPlacement",null);m(this,"isRTL",!1);m(this,"effectiveBadgesPosition","bottom");m(this,"justClosedViaClick",!1);m(this,"dropdownCleanup",null);m(this,"hintCleanup",null);m(this,"selectedPopoverCleanup",null);m(this,"badgeTooltips",new Map);m(this,"badgeTooltipCleanups",new Map);m(this,"actionButtonTooltips",new Map);m(this,"actionButtonTooltipCleanups",new Map);m(this,"virtualScroll",null);m(this,"optionsContainer",null);m(this,"selectedPopoverVirtualScroll",null);m(this,"selectedPopoverContainer",null);m(this,"input");m(this,"dropdown");m(this,"badgesContainer");m(this,"counter");m(this,"hint");m(this,"selectedPopover");this.element=e,this.instanceId=`MS-${Math.random().toString(36).substr(2,9)}`,this.options={searchHint:e.dataset.searchHint||"",searchPlaceholder:e.dataset.searchPlaceholder||"Search...",dropdownMinWidth:e.dataset.dropdownMinWidth||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,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",options:[],container:void 0,...t},this.init()}getItemValue(e){return Array.isArray(e)&&e.length===2?e[0]:this.options.valueMember&&e[this.options.valueMember]!==void 0?e[this.options.valueMember]:this.options.getValueCallback?this.options.getValueCallback(e):"[N/A]"}getItemDisplayValue(e){return Array.isArray(e)&&e.length===2?String(e[1]):this.options.displayValueMember&&e[this.options.displayValueMember]!==void 0?String(e[this.options.displayValueMember]):this.options.getDisplayValueCallback?this.options.getDisplayValueCallback(e):"[N/A]"}getItemBadgeDisplayValue(e){return this.options.getBadgeDisplayCallback?this.options.getBadgeDisplayCallback(e):this.getItemDisplayValue(e)}getItemSearchValue(e){return this.options.searchValueMember&&e[this.options.searchValueMember]!==void 0?String(e[this.options.searchValueMember]):this.options.getSearchValueCallback?this.options.getSearchValueCallback(e):this.getItemDisplayValue(e)}getItemIcon(e){if(!Array.isArray(e)){if(this.options.iconMember&&e[this.options.iconMember]!==void 0)return String(e[this.options.iconMember]);if(this.options.getIconCallback)return this.options.getIconCallback(e)}}getItemSubtitle(e){if(!Array.isArray(e)){if(this.options.subtitleMember&&e[this.options.subtitleMember]!==void 0)return String(e[this.options.subtitleMember]);if(this.options.getSubtitleCallback)return this.options.getSubtitleCallback(e)}}getItemGroup(e){if(!Array.isArray(e)){if(this.options.groupMember&&e[this.options.groupMember]!==void 0)return String(e[this.options.groupMember]);if(this.options.getGroupCallback)return this.options.getGroupCallback(e)}}getItemDisabled(e){return Array.isArray(e)?!1:this.options.disabledMember&&e[this.options.disabledMember]!==void 0?!!e[this.options.disabledMember]:this.options.getDisabledCallback?this.options.getDisabledCallback(e):!1}init(){this.parseOptions(),this.buildHTML(),this.attachEvents(),this.parseInitialSelection(),ne.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){k.error(`[${this.instanceId}] Failed to parse data-options:`,t),this.allOptions=[]}else this.options.options&&(this.allOptions=this.options.options);this.filteredOptions=[...this.allOptions]}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",n=i.closest('[dir="rtl"]')!==null;this.isRTL=s||n,ne.debug(`[${this.instanceId}] RTL Debug:`,{isShadowRoot:t instanceof ShadowRoot,hostElement:i,elementDir:i.getAttribute("dir"),hasElementDir:s,hasAncestorDir:n,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("ml"),this.isRTL&&(this.element.classList.add("ml--rtl"),ne.debug(`[${this.instanceId}] Added ml--rtl class to element`)),(!this.options.isCheckboxesShown||!this.options.isMultipleEnabled)&&this.element.classList.add("ml--no-checkboxes");const l=document.createElement("div");l.className="ml__input-wrapper",this.input=document.createElement("input"),this.input.type="text",this.input.className="ml__input",this.input.placeholder=this.options.searchPlaceholder,this.input.autocomplete="off",this.options.searchInputMode==="readonly"?this.input.readOnly=!0:this.options.searchInputMode==="hidden"&&(this.input.style.display="none");const r=document.createElement("span");r.className="ml__toggle",r.innerHTML="▼",this.counter=document.createElement("span"),this.counter.className="ml__counter",this.counter.style.display="none",l.appendChild(this.input),l.appendChild(this.counter),l.appendChild(r),this.badgesContainer=document.createElement("div"),this.badgesContainer.className="ml__badges";const a=document.createElement("div");a.className="ml-wrapper",(this.effectiveBadgesPosition==="left"||this.effectiveBadgesPosition==="right")&&a.classList.add("ml-wrapper--inline"),a.appendChild(l),a.appendChild(this.badgesContainer),this.element.appendChild(a),this.dropdown=document.createElement("div"),this.dropdown.className="ml__dropdown",e.appendChild(this.dropdown),this.options.searchHint&&(this.hint=document.createElement("div"),this.hint.className="ml__hint",this.hint.textContent=this.options.searchHint,e.appendChild(this.hint)),this.selectedPopover=document.createElement("div"),this.selectedPopover.className="ml__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(){var t;if(this.destroyAllActionButtonTooltips(),this.shouldUseVirtualScroll()){this.dropdown.classList.add("ml__dropdown--virtual"),this.renderDropdownVirtual();return}this.dropdown.classList.remove("ml__dropdown--virtual");let e="";if(this.isLoading){e+='<div class="ml__loader">',e+='<div class="pa-loader pa-loader--sm"></div>',e+=`<div class="ml__loading-text">${this.options.loadingMessage}</div>`,e+="</div>",this.dropdown.innerHTML=e;return}if(console.log("[DEBUG] renderDropdown() - isMultipleEnabled:",this.options.isMultipleEnabled),console.log("[DEBUG] renderDropdown() - actionButtons:",this.options.actionButtons),console.log("[DEBUG] renderDropdown() - actionButtons.length:",(t=this.options.actionButtons)==null?void 0:t.length),this.options.isMultipleEnabled&&this.options.actionButtons&&this.options.actionButtons.length>0){console.log("[DEBUG] About to render action buttons!");const i=this.options.isActionsSticky?" ml__actions--sticky":"",s=this.options.actionsLayout==="wrap"?" ml__actions--wrap":"";e+=`<div class="ml__actions${i}${s}">`,this.options.actionButtons.forEach(n=>{console.log("[ACTION BUTTON DEBUG] Processing button:",n.text,n),console.log("[VISIBILITY] Checking isVisibleCallback:",!!n.isVisibleCallback);const l=n.isVisibleCallback?n.isVisibleCallback(this):n.isVisible??!0;if(console.log("[VISIBILITY] Result:",l),!l)return;console.log("[DISABLED] Checking isDisabledCallback:",!!n.isDisabledCallback);const r=n.isDisabledCallback?n.isDisabledCallback(this):n.isDisabled??!1;console.log("[DISABLED] Result:",r);const a=r?" disabled":"";console.log("[TEXT] Checking getTextCallback:",!!n.getTextCallback);const d=n.getTextCallback?n.getTextCallback(this):n.text;console.log("[TEXT] Result:",d),console.log("[CLASS] Checking getClassCallback:",!!n.getClassCallback);let c="";if(n.getClassCallback){const p=n.getClassCallback(this);console.log("[CLASS] Callback returned:",p),c=Array.isArray(p)?` ${p.join(" ")}`:p?` ${p}`:""}else n.cssClass&&(c=` ${n.cssClass}`);console.log("[CLASS] Final cssClass:",c),e+=`<button type="button"${a} class="ml__action-btn${c}" data-action="${n.action}">${d}</button>`}),e+="</div>"}if(e+='<div class="ml__options">',this.filteredOptions.length===0)e+=`<div class="ml__empty">${this.options.emptyMessage}</div>`;else if(this.options.isGroupsAllowed){const i=this.groupOptions(this.filteredOptions);Object.keys(i).forEach(s=>{e+='<div class="ml__group">',s!=="__ungrouped__"&&(e+=`<div class="ml__group-label">${s}</div>`),i[s].forEach((n,l)=>{e+=this.renderOption(n,l)}),e+="</div>"})}else this.filteredOptions.forEach((i,s)=>{e+=this.renderOption(i,s)});e+="</div>",this.dropdown.innerHTML=e,this.attachActionButtonTooltips()}renderDropdownVirtual(){if(this.destroyAllActionButtonTooltips(),!this.virtualScroll){let i="";if(this.options.isMultipleEnabled&&this.options.actionButtons&&this.options.actionButtons.length>0){const l=this.options.isActionsSticky?" ml__actions--sticky":"",r=this.options.actionsLayout==="wrap"?" ml__actions--wrap":"";i+=`<div class="ml__actions${l}${r}">`,this.options.actionButtons.forEach(a=>{console.log("[ACTION BUTTON DEBUG - VIRTUAL] Processing button:",a.text,a),console.log("[VISIBILITY - VIRTUAL] Checking isVisibleCallback:",!!a.isVisibleCallback);const d=a.isVisibleCallback?a.isVisibleCallback(this):a.isVisible??!0;if(console.log("[VISIBILITY - VIRTUAL] Result:",d),!d)return;console.log("[DISABLED - VIRTUAL] Checking isDisabledCallback:",!!a.isDisabledCallback);const c=a.isDisabledCallback?a.isDisabledCallback(this):a.isDisabled??!1;console.log("[DISABLED - VIRTUAL] Result:",c);const p=c?" disabled":"";console.log("[TEXT - VIRTUAL] Checking getTextCallback:",!!a.getTextCallback);const u=a.getTextCallback?a.getTextCallback(this):a.text;console.log("[TEXT - VIRTUAL] Result:",u),console.log("[CLASS - VIRTUAL] Checking getClassCallback:",!!a.getClassCallback);let h="";if(a.getClassCallback){const g=a.getClassCallback(this);console.log("[CLASS - VIRTUAL] Callback returned:",g),h=Array.isArray(g)?` ${g.join(" ")}`:g?` ${g}`:""}else a.cssClass&&(h=` ${a.cssClass}`);console.log("[CLASS - VIRTUAL] Final cssClass:",h),i+=`<button type="button"${p} class="ml__action-btn${h}" data-action="${a.action}">${u}</button>`}),i+="</div>"}const s=this.options.maxHeight||"20rem",n=this.options.optionHeight??50;i+=`<div class="ml__options ml__options--virtual" style="height: ${s}; max-height: ${s}; overflow-y: auto; position: relative; --ml-option-height: ${n}px;"></div>`,this.dropdown.innerHTML=i,this.optionsContainer=this.dropdown.querySelector(".ml__options")}if(this.filteredOptions.length===0){this.optionsContainer.innerHTML=`<div class="ml__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 at({container:this.optionsContainer,itemHeight:e,items:this.filteredOptions,renderItem:(i,s)=>this.renderOption(i,s),bufferSize:t}),this.attachActionButtonTooltips())})}renderOption(e,t){const i=this.getItemValue(e),s=this.getItemDisplayValue(e),n=this.getItemIcon(e),l=this.getItemSubtitle(e),r=this.getItemDisabled(e),a=this.selectedValues.has(String(i)),d=t===this.focusedIndex,c=this.matchingIndices.has(t),p=["ml__option"];a&&p.push("ml__option--selected"),d&&p.push("ml__option--focused"),c&&p.push("ml__option--matched"),r&&p.push("ml__option--disabled");const u=this.options.checkboxAlign&&this.options.checkboxAlign!=="top"?` data-checkbox-align="${this.options.checkboxAlign}"`:"";let h=`<div class="${p.join(" ")}" data-value="${i}" data-index="${t}"${u}>`;if(this.options.isCheckboxesShown&&this.options.isMultipleEnabled&&(h+=`<input type="checkbox" class="ml__checkbox" ${a?"checked":""} ${r?"disabled":""}>`),h+='<div class="ml__option-content">',this.options.renderOptionContentCallback){const g={index:t,isSelected:a,isFocused:d,isMatched:c,isDisabled:r},b=this.options.renderOptionContentCallback(e,g);typeof b=="string"?h+=b:h+=b.outerHTML}else n&&(h+=`<span class="ml__option-icon">${n}</span>`),h+='<div class="ml__option-text">',h+=`<div class="ml__option-title">${this.highlightMatch(s,this.searchTerm)}</div>`,l&&(h+=`<div class="ml__option-subtitle">${l}</div>`),h+="</div>";return h+="</div>",h+="</div>",h}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}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 n;e[0]&&(this.options.renderSelectedContentCallback?n=this.options.renderSelectedContentCallback(e[0]):n=this.getItemDisplayValue(e[0])),f.warn(`[${this.instanceId}] renderBadges() single-select mode`,{isOpen:this.isOpen,count:t,selectedOptionsLength:e.length,willSetValue:!this.isOpen&&t>0&&e.length>0,selectedLabel:n}),!this.isOpen&&t>0&&e.length>0?(f.info(`[${this.instanceId}] ✅ SETTING input.value = "${n}"`),this.input.value=n,f.info(`[${this.instanceId}] 🔍 VERIFY input.value = "${this.input.value}"`)):this.isOpen?f.info(`[${this.instanceId}] ⏭️ SKIPPING input update (dropdown is open)`):(f.info(`[${this.instanceId}] ❌ CLEARING input.value (no selection)`),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 n=this.options.getCounterCallback?this.options.getCounterCallback(t):`${t} selected`;this.input.placeholder=n}else this.input.placeholder=this.options.searchPlaceholder;if(this.options.isCounterShown&&t>0?(this.counter.textContent=`[${t}]`,this.counter.style.display=""):this.counter.style.display="none",i==="none"){this.badgesContainer.innerHTML="";return}if(i==="badges")this.badgesContainer.className=`ml__badges ml__badges--${this.effectiveBadgesPosition}`,this.badgesContainer.innerHTML=e.map(n=>{const l=this.getItemValue(n);let r;if(this.options.renderBadgeContentCallback){const d={displayMode:"badges",isInPopover:!1},c=this.options.renderBadgeContentCallback(n,d);r=typeof c=="string"?c:c.outerHTML}else r=this.getItemBadgeDisplayValue(n);let a="ml__badge";if(this.options.getBadgeClassCallback){const d=this.options.getBadgeClassCallback(n),c=Array.isArray(d)?d:[d];a+=" "+c.filter(p=>p).join(" ")}return`
|
|
2
|
-
<div class="${
|
|
3
|
-
<span class="
|
|
4
|
-
<button type="button" class="
|
|
1
|
+
(function(x,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(x=typeof globalThis<"u"?globalThis:x||self,T(x.MultiSelect={}))})(this,function(x){"use strict";var bs=Object.defineProperty;var fs=(x,T,L)=>T in x?bs(x,T,{enumerable:!0,configurable:!0,writable:!0,value:L}):x[T]=L;var p=(x,T,L)=>fs(x,typeof T!="symbol"?T+"":T,L);const T=Math.min,L=Math.max,le=Math.round,ce=Math.floor,P=i=>({x:i,y:i}),ut={left:"right",right:"left",bottom:"top",top:"bottom"},gt={start:"end",end:"start"};function Ee(i,e,t){return L(i,T(e,t))}function de(i,e){return typeof i=="function"?i(e):i}function H(i){return i.split("-")[0]}function he(i){return i.split("-")[1]}function $e(i){return i==="x"?"y":"x"}function Me(i){return i==="y"?"height":"width"}const bt=new Set(["top","bottom"]);function z(i){return bt.has(H(i))?"y":"x"}function Ve(i){return $e(z(i))}function ft(i,e,t){t===void 0&&(t=!1);const s=he(i),o=Ve(i),n=Me(o);let r=o==="x"?s===(t?"end":"start")?"right":"left":s==="start"?"bottom":"top";return e.reference[n]>e.floating[n]&&(r=pe(r)),[r,pe(r)]}function vt(i){const e=pe(i);return[ye(i),e,ye(e)]}function ye(i){return i.replace(/start|end/g,e=>gt[e])}const Pe=["left","right"],Be=["right","left"],wt=["top","bottom"],yt=["bottom","top"];function _t(i,e,t){switch(i){case"top":case"bottom":return t?e?Be:Pe:e?Pe:Be;case"left":case"right":return e?wt:yt;default:return[]}}function Ct(i,e,t,s){const o=he(i);let n=_t(H(i),t==="start",s);return o&&(n=n.map(r=>r+"-"+o),e&&(n=n.concat(n.map(ye)))),n}function pe(i){return i.replace(/left|right|bottom|top/g,e=>ut[e])}function xt(i){return{top:0,right:0,bottom:0,left:0,...i}}function kt(i){return typeof i!="number"?xt(i):{top:i,right:i,bottom:i,left:i}}function me(i){const{x:e,y:t,width:s,height:o}=i;return{width:s,height:o,top:t,left:e,right:e+s,bottom:t+o,x:e,y:t}}function De(i,e,t){let{reference:s,floating:o}=i;const n=z(e),r=Ve(e),a=Me(r),l=H(e),c=n==="y",d=s.x+s.width/2-o.width/2,m=s.y+s.height/2-o.height/2,u=s[a]/2-o[a]/2;let h;switch(l){case"top":h={x:d,y:s.y-o.height};break;case"bottom":h={x:d,y:s.y+s.height};break;case"right":h={x:s.x+s.width,y:m};break;case"left":h={x:s.x-o.width,y:m};break;default:h={x:s.x,y:s.y}}switch(he(e)){case"start":h[r]-=u*(t&&c?-1:1);break;case"end":h[r]+=u*(t&&c?-1:1);break}return h}const St=async(i,e,t)=>{const{placement:s="bottom",strategy:o="absolute",middleware:n=[],platform:r}=t,a=n.filter(Boolean),l=await(r.isRTL==null?void 0:r.isRTL(e));let c=await r.getElementRects({reference:i,floating:e,strategy:o}),{x:d,y:m}=De(c,s,l),u=s,h={},g=0;for(let b=0;b<a.length;b++){const{name:v,fn:w}=a[b],{x:y,y:C,data:I,reset:S}=await w({x:d,y:m,initialPlacement:s,placement:u,strategy:o,middlewareData:h,rects:c,platform:r,elements:{reference:i,floating:e}});d=y??d,m=C??m,h={...h,[v]:{...h[v],...I}},S&&g<=50&&(g++,typeof S=="object"&&(S.placement&&(u=S.placement),S.rects&&(c=S.rects===!0?await r.getElementRects({reference:i,floating:e,strategy:o}):S.rects),{x:d,y:m}=De(c,u,l)),b=-1)}return{x:d,y:m,placement:u,strategy:o,middlewareData:h}};async function ze(i,e){var t;e===void 0&&(e={});const{x:s,y:o,platform:n,rects:r,elements:a,strategy:l}=i,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:m="floating",altBoundary:u=!1,padding:h=0}=de(e,i),g=kt(h),v=a[u?m==="floating"?"reference":"floating":m],w=me(await n.getClippingRect({element:(t=await(n.isElement==null?void 0:n.isElement(v)))==null||t?v:v.contextElement||await(n.getDocumentElement==null?void 0:n.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),y=m==="floating"?{x:s,y:o,width:r.floating.width,height:r.floating.height}:r.reference,C=await(n.getOffsetParent==null?void 0:n.getOffsetParent(a.floating)),I=await(n.isElement==null?void 0:n.isElement(C))?await(n.getScale==null?void 0:n.getScale(C))||{x:1,y:1}:{x:1,y:1},S=me(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:C,strategy:l}):y);return{top:(w.top-S.top+g.top)/I.y,bottom:(S.bottom-w.bottom+g.bottom)/I.y,left:(w.left-S.left+g.left)/I.x,right:(S.right-w.right+g.right)/I.x}}const At=function(i){return i===void 0&&(i={}),{name:"flip",options:i,async fn(e){var t,s;const{placement:o,middlewareData:n,rects:r,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:d=!0,crossAxis:m=!0,fallbackPlacements:u,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...v}=de(i,e);if((t=n.arrow)!=null&&t.alignmentOffset)return{};const w=H(o),y=z(a),C=H(a)===a,I=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=u||(C||!b?[pe(a)]:vt(a)),re=g!=="none";!u&&re&&S.push(...Ct(a,b,g,I));const J=[a,...S],Oe=await ze(e,v),we=[];let X=((s=n.flip)==null?void 0:s.overflows)||[];if(d&&we.push(Oe[w]),m){const j=ft(o,r,I);we.push(Oe[j[0]],Oe[j[1]])}if(X=[...X,{placement:o,overflows:we}],!we.every(j=>j<=0)){var ht,pt;const j=(((ht=n.flip)==null?void 0:ht.index)||0)+1,Le=J[j];if(Le&&(!(m==="alignment"?y!==z(Le):!1)||X.every(V=>z(V.placement)===y?V.overflows[0]>0:!0)))return{data:{index:j,overflows:X},reset:{placement:Le}};let ae=(pt=X.filter(W=>W.overflows[0]<=0).sort((W,V)=>W.overflows[1]-V.overflows[1])[0])==null?void 0:pt.placement;if(!ae)switch(h){case"bestFit":{var mt;const W=(mt=X.filter(V=>{if(re){const N=z(V.placement);return N===y||N==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(N=>N>0).reduce((N,gs)=>N+gs,0)]).sort((V,N)=>V[1]-N[1])[0])==null?void 0:mt[0];W&&(ae=W);break}case"initialPlacement":ae=a;break}if(o!==ae)return{reset:{placement:ae}}}return{}}}},It=new Set(["left","top"]);async function Tt(i,e){const{placement:t,platform:s,elements:o}=i,n=await(s.isRTL==null?void 0:s.isRTL(o.floating)),r=H(t),a=he(t),l=z(t)==="y",c=It.has(r)?-1:1,d=n&&l?-1:1,m=de(e,i);let{mainAxis:u,crossAxis:h,alignmentAxis:g}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return a&&typeof g=="number"&&(h=a==="end"?g*-1:g),l?{x:h*d,y:u*c}:{x:u*c,y:h*d}}const Ot=function(i){return i===void 0&&(i=0),{name:"offset",options:i,async fn(e){var t,s;const{x:o,y:n,placement:r,middlewareData:a}=e,l=await Tt(e,i);return r===((t=a.offset)==null?void 0:t.placement)&&(s=a.arrow)!=null&&s.alignmentOffset?{}:{x:o+l.x,y:n+l.y,data:{...l,placement:r}}}}},Lt=function(i){return i===void 0&&(i={}),{name:"shift",options:i,async fn(e){const{x:t,y:s,placement:o}=e,{mainAxis:n=!0,crossAxis:r=!1,limiter:a={fn:v=>{let{x:w,y}=v;return{x:w,y}}},...l}=de(i,e),c={x:t,y:s},d=await ze(e,l),m=z(H(o)),u=$e(m);let h=c[u],g=c[m];if(n){const v=u==="y"?"top":"left",w=u==="y"?"bottom":"right",y=h+d[v],C=h-d[w];h=Ee(y,h,C)}if(r){const v=m==="y"?"top":"left",w=m==="y"?"bottom":"right",y=g+d[v],C=g-d[w];g=Ee(y,g,C)}const b=a.fn({...e,[u]:h,[m]:g});return{...b,data:{x:b.x-t,y:b.y-s,enabled:{[u]:n,[m]:r}}}}}};function ue(){return typeof window<"u"}function U(i){return Re(i)?(i.nodeName||"").toLowerCase():"#document"}function O(i){var e;return(i==null||(e=i.ownerDocument)==null?void 0:e.defaultView)||window}function B(i){var e;return(e=(Re(i)?i.ownerDocument:i.document)||window.document)==null?void 0:e.documentElement}function Re(i){return ue()?i instanceof Node||i instanceof O(i).Node:!1}function E(i){return ue()?i instanceof Element||i instanceof O(i).Element:!1}function D(i){return ue()?i instanceof HTMLElement||i instanceof O(i).HTMLElement:!1}function Ne(i){return!ue()||typeof ShadowRoot>"u"?!1:i instanceof ShadowRoot||i instanceof O(i).ShadowRoot}const Et=new Set(["inline","contents"]);function q(i){const{overflow:e,overflowX:t,overflowY:s,display:o}=$(i);return/auto|scroll|overlay|hidden|clip/.test(e+s+t)&&!Et.has(o)}const $t=new Set(["table","td","th"]);function Mt(i){return $t.has(U(i))}const Vt=[":popover-open",":modal"];function ge(i){return Vt.some(e=>{try{return i.matches(e)}catch{return!1}})}const Pt=["transform","translate","scale","rotate","perspective"],Bt=["transform","translate","scale","rotate","perspective","filter"],Dt=["paint","layout","strict","content"];function _e(i){const e=Ce(),t=E(i)?$(i):i;return Pt.some(s=>t[s]?t[s]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||Bt.some(s=>(t.willChange||"").includes(s))||Dt.some(s=>(t.contain||"").includes(s))}function zt(i){let e=R(i);for(;D(e)&&!K(e);){if(_e(e))return e;if(ge(e))return null;e=R(e)}return null}function Ce(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Rt=new Set(["html","body","#document"]);function K(i){return Rt.has(U(i))}function $(i){return O(i).getComputedStyle(i)}function be(i){return E(i)?{scrollLeft:i.scrollLeft,scrollTop:i.scrollTop}:{scrollLeft:i.scrollX,scrollTop:i.scrollY}}function R(i){if(U(i)==="html")return i;const e=i.assignedSlot||i.parentNode||Ne(i)&&i.host||B(i);return Ne(e)?e.host:e}function He(i){const e=R(i);return K(e)?i.ownerDocument?i.ownerDocument.body:i.body:D(e)&&q(e)?e:He(e)}function Z(i,e,t){var s;e===void 0&&(e=[]),t===void 0&&(t=!0);const o=He(i),n=o===((s=i.ownerDocument)==null?void 0:s.body),r=O(o);if(n){const a=xe(r);return e.concat(r,r.visualViewport||[],q(o)?o:[],a&&t?Z(a):[])}return e.concat(o,Z(o,[],t))}function xe(i){return i.parent&&Object.getPrototypeOf(i.parent)?i.frameElement:null}function Fe(i){const e=$(i);let t=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const o=D(i),n=o?i.offsetWidth:t,r=o?i.offsetHeight:s,a=le(t)!==n||le(s)!==r;return a&&(t=n,s=r),{width:t,height:s,$:a}}function ke(i){return E(i)?i:i.contextElement}function Y(i){const e=ke(i);if(!D(e))return P(1);const t=e.getBoundingClientRect(),{width:s,height:o,$:n}=Fe(e);let r=(n?le(t.width):t.width)/s,a=(n?le(t.height):t.height)/o;return(!r||!Number.isFinite(r))&&(r=1),(!a||!Number.isFinite(a))&&(a=1),{x:r,y:a}}const Nt=P(0);function Ge(i){const e=O(i);return!Ce()||!e.visualViewport?Nt:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Ht(i,e,t){return e===void 0&&(e=!1),!t||e&&t!==O(i)?!1:e}function F(i,e,t,s){e===void 0&&(e=!1),t===void 0&&(t=!1);const o=i.getBoundingClientRect(),n=ke(i);let r=P(1);e&&(s?E(s)&&(r=Y(s)):r=Y(i));const a=Ht(n,t,s)?Ge(n):P(0);let l=(o.left+a.x)/r.x,c=(o.top+a.y)/r.y,d=o.width/r.x,m=o.height/r.y;if(n){const u=O(n),h=s&&E(s)?O(s):s;let g=u,b=xe(g);for(;b&&s&&h!==g;){const v=Y(b),w=b.getBoundingClientRect(),y=$(b),C=w.left+(b.clientLeft+parseFloat(y.paddingLeft))*v.x,I=w.top+(b.clientTop+parseFloat(y.paddingTop))*v.y;l*=v.x,c*=v.y,d*=v.x,m*=v.y,l+=C,c+=I,g=O(b),b=xe(g)}}return me({width:d,height:m,x:l,y:c})}function fe(i,e){const t=be(i).scrollLeft;return e?e.left+t:F(B(i)).left+t}function je(i,e){const t=i.getBoundingClientRect(),s=t.left+e.scrollLeft-fe(i,t),o=t.top+e.scrollTop;return{x:s,y:o}}function Ft(i){let{elements:e,rect:t,offsetParent:s,strategy:o}=i;const n=o==="fixed",r=B(s),a=e?ge(e.floating):!1;if(s===r||a&&n)return t;let l={scrollLeft:0,scrollTop:0},c=P(1);const d=P(0),m=D(s);if((m||!m&&!n)&&((U(s)!=="body"||q(r))&&(l=be(s)),D(s))){const h=F(s);c=Y(s),d.x=h.x+s.clientLeft,d.y=h.y+s.clientTop}const u=r&&!m&&!n?je(r,l):P(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+d.x+u.x,y:t.y*c.y-l.scrollTop*c.y+d.y+u.y}}function Gt(i){return Array.from(i.getClientRects())}function jt(i){const e=B(i),t=be(i),s=i.ownerDocument.body,o=L(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),n=L(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let r=-t.scrollLeft+fe(i);const a=-t.scrollTop;return $(s).direction==="rtl"&&(r+=L(e.clientWidth,s.clientWidth)-o),{width:o,height:n,x:r,y:a}}const We=25;function Wt(i,e){const t=O(i),s=B(i),o=t.visualViewport;let n=s.clientWidth,r=s.clientHeight,a=0,l=0;if(o){n=o.width,r=o.height;const d=Ce();(!d||d&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=fe(s);if(c<=0){const d=s.ownerDocument,m=d.body,u=getComputedStyle(m),h=d.compatMode==="CSS1Compat"&&parseFloat(u.marginLeft)+parseFloat(u.marginRight)||0,g=Math.abs(s.clientWidth-m.clientWidth-h);g<=We&&(n-=g)}else c<=We&&(n+=c);return{width:n,height:r,x:a,y:l}}const Ut=new Set(["absolute","fixed"]);function Kt(i,e){const t=F(i,!0,e==="fixed"),s=t.top+i.clientTop,o=t.left+i.clientLeft,n=D(i)?Y(i):P(1),r=i.clientWidth*n.x,a=i.clientHeight*n.y,l=o*n.x,c=s*n.y;return{width:r,height:a,x:l,y:c}}function Ue(i,e,t){let s;if(e==="viewport")s=Wt(i,t);else if(e==="document")s=jt(B(i));else if(E(e))s=Kt(e,t);else{const o=Ge(i);s={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return me(s)}function Ke(i,e){const t=R(i);return t===e||!E(t)||K(t)?!1:$(t).position==="fixed"||Ke(t,e)}function Yt(i,e){const t=e.get(i);if(t)return t;let s=Z(i,[],!1).filter(a=>E(a)&&U(a)!=="body"),o=null;const n=$(i).position==="fixed";let r=n?R(i):i;for(;E(r)&&!K(r);){const a=$(r),l=_e(r);!l&&a.position==="fixed"&&(o=null),(n?!l&&!o:!l&&a.position==="static"&&!!o&&Ut.has(o.position)||q(r)&&!l&&Ke(i,r))?s=s.filter(d=>d!==r):o=a,r=R(r)}return e.set(i,s),s}function Jt(i){let{element:e,boundary:t,rootBoundary:s,strategy:o}=i;const r=[...t==="clippingAncestors"?ge(e)?[]:Yt(e,this._c):[].concat(t),s],a=r[0],l=r.reduce((c,d)=>{const m=Ue(e,d,o);return c.top=L(m.top,c.top),c.right=T(m.right,c.right),c.bottom=T(m.bottom,c.bottom),c.left=L(m.left,c.left),c},Ue(e,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Xt(i){const{width:e,height:t}=Fe(i);return{width:e,height:t}}function qt(i,e,t){const s=D(e),o=B(e),n=t==="fixed",r=F(i,!0,n,e);let a={scrollLeft:0,scrollTop:0};const l=P(0);function c(){l.x=fe(o)}if(s||!s&&!n)if((U(e)!=="body"||q(o))&&(a=be(e)),s){const h=F(e,!0,n,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop}else o&&c();n&&!s&&o&&c();const d=o&&!s&&!n?je(o,a):P(0),m=r.left+a.scrollLeft-l.x-d.x,u=r.top+a.scrollTop-l.y-d.y;return{x:m,y:u,width:r.width,height:r.height}}function Se(i){return $(i).position==="static"}function Ye(i,e){if(!D(i)||$(i).position==="fixed")return null;if(e)return e(i);let t=i.offsetParent;return B(i)===t&&(t=t.ownerDocument.body),t}function Je(i,e){const t=O(i);if(ge(i))return t;if(!D(i)){let o=R(i);for(;o&&!K(o);){if(E(o)&&!Se(o))return o;o=R(o)}return t}let s=Ye(i,e);for(;s&&Mt(s)&&Se(s);)s=Ye(s,e);return s&&K(s)&&Se(s)&&!_e(s)?t:s||zt(i)||t}const Zt=async function(i){const e=this.getOffsetParent||Je,t=this.getDimensions,s=await t(i.floating);return{reference:qt(i.reference,await e(i.floating),i.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Qt(i){return $(i).direction==="rtl"}const es={convertOffsetParentRelativeRectToViewportRelativeRect:Ft,getDocumentElement:B,getClippingRect:Jt,getOffsetParent:Je,getElementRects:Zt,getClientRects:Gt,getDimensions:Xt,getScale:Y,isElement:E,isRTL:Qt};function Xe(i,e){return i.x===e.x&&i.y===e.y&&i.width===e.width&&i.height===e.height}function ts(i,e){let t=null,s;const o=B(i);function n(){var a;clearTimeout(s),(a=t)==null||a.disconnect(),t=null}function r(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),n();const c=i.getBoundingClientRect(),{left:d,top:m,width:u,height:h}=c;if(a||e(),!u||!h)return;const g=ce(m),b=ce(o.clientWidth-(d+u)),v=ce(o.clientHeight-(m+h)),w=ce(d),C={rootMargin:-g+"px "+-b+"px "+-v+"px "+-w+"px",threshold:L(0,T(1,l))||1};let I=!0;function S(re){const J=re[0].intersectionRatio;if(J!==l){if(!I)return r();J?r(!1,J):s=setTimeout(()=>{r(!1,1e-7)},1e3)}J===1&&!Xe(c,i.getBoundingClientRect())&&r(),I=!1}try{t=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{t=new IntersectionObserver(S,C)}t.observe(i)}return r(!0),n}function Q(i,e,t,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:n=!0,elementResize:r=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=s,c=ke(i),d=o||n?[...c?Z(c):[],...Z(e)]:[];d.forEach(w=>{o&&w.addEventListener("scroll",t,{passive:!0}),n&&w.addEventListener("resize",t)});const m=c&&a?ts(c,t):null;let u=-1,h=null;r&&(h=new ResizeObserver(w=>{let[y]=w;y&&y.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(u),u=requestAnimationFrame(()=>{var C;(C=h)==null||C.observe(e)})),t()}),c&&!l&&h.observe(c),h.observe(e));let g,b=l?F(i):null;l&&v();function v(){const w=F(i);b&&!Xe(b,w)&&t(),b=w,g=requestAnimationFrame(v)}return t(),()=>{var w;d.forEach(y=>{o&&y.removeEventListener("scroll",t),n&&y.removeEventListener("resize",t)}),m==null||m(),(w=h)==null||w.disconnect(),h=null,l&&cancelAnimationFrame(g)}}const ee=Ot,te=Lt,ve=At,se=(i,e,t)=>{const s=new Map,o={platform:es,...t},n={...o.platform,_c:s};return St(i,e,{...o,platform:n})};var qe=function(){},M="undefined",ss=typeof window!==M&&typeof window.navigator!==M&&/Trident\/|MSIE /.test(window.navigator.userAgent),Ae=["trace","debug","info","warn","error"],ie={},_=null;function Ze(i,e){var t=i[e];if(typeof t.bind=="function")return t.bind(i);try{return Function.prototype.bind.call(t,i)}catch{return function(){return Function.prototype.apply.apply(t,[i,arguments])}}}function is(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function os(i){return i==="debug"&&(i="log"),typeof console===M?!1:i==="trace"&&ss?is:console[i]!==void 0?Ze(console,i):console.log!==void 0?Ze(console,"log"):qe}function oe(){for(var i=this.getLevel(),e=0;e<Ae.length;e++){var t=Ae[e];this[t]=e<i?qe:this.methodFactory(t,i,this.name)}if(this.log=this.debug,typeof console===M&&i<this.levels.SILENT)return"No console available for logging"}function ns(i){return function(){typeof console!==M&&(oe.call(this),this[i].apply(this,arguments))}}function rs(i,e,t){return os(i)||ns.apply(this,arguments)}function Qe(i,e){var t=this,s,o,n,r="loglevel";typeof i=="string"?r+=":"+i:typeof i=="symbol"&&(r=void 0);function a(u){var h=(Ae[u]||"silent").toUpperCase();if(!(typeof window===M||!r)){try{window.localStorage[r]=h;return}catch{}try{window.document.cookie=encodeURIComponent(r)+"="+h+";"}catch{}}}function l(){var u;if(!(typeof window===M||!r)){try{u=window.localStorage[r]}catch{}if(typeof u===M)try{var h=window.document.cookie,g=encodeURIComponent(r),b=h.indexOf(g+"=");b!==-1&&(u=/^([^;]+)/.exec(h.slice(b+g.length+1))[1])}catch{}return t.levels[u]===void 0&&(u=void 0),u}}function c(){if(!(typeof window===M||!r)){try{window.localStorage.removeItem(r)}catch{}try{window.document.cookie=encodeURIComponent(r)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function d(u){var h=u;if(typeof h=="string"&&t.levels[h.toUpperCase()]!==void 0&&(h=t.levels[h.toUpperCase()]),typeof h=="number"&&h>=0&&h<=t.levels.SILENT)return h;throw new TypeError("log.setLevel() called with invalid level: "+u)}t.name=i,t.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},t.methodFactory=e||rs,t.getLevel=function(){return n??o??s},t.setLevel=function(u,h){return n=d(u),h!==!1&&a(n),oe.call(t)},t.setDefaultLevel=function(u){o=d(u),l()||t.setLevel(u,!1)},t.resetLevel=function(){n=null,c(),oe.call(t)},t.enableAll=function(u){t.setLevel(t.levels.TRACE,u)},t.disableAll=function(u){t.setLevel(t.levels.SILENT,u)},t.rebuild=function(){if(_!==t&&(s=d(_.getLevel())),oe.call(t),_===t)for(var u in ie)ie[u].rebuild()},s=d(_?_.getLevel():"WARN");var m=l();m!=null&&(n=d(m)),oe.call(t)}_=new Qe,_.getLogger=function(e){if(typeof e!="symbol"&&typeof e!="string"||e==="")throw new TypeError("You must supply a name when creating a logger.");var t=ie[e];return t||(t=ie[e]=new Qe(e,_.methodFactory)),t};var as=typeof window!==M?window.log:void 0;_.noConflict=function(){return typeof window!==M&&window.log===_&&(window.log=as),_},_.getLoggers=function(){return ie},_.default=_;var ls=function(i){for(var e=1,t=arguments.length,s;e<t;e++)for(s in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],s)&&(i[s]=arguments[e][s]);return i},cs={template:"[%t] %l:",levelFormatter:function(i){return i.toUpperCase()},nameFormatter:function(i){return i||"root"},timestampFormatter:function(i){return i.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},et,G={},ds=function(i){if(!i||!i.getLogger)throw new TypeError("Argument is not a root logger");et=i},hs=function(i,e){if(!i||!i.setLevel)throw new TypeError("Argument is not a logger");var t=i.methodFactory,s=i.name||"",o=G[s]||G[""]||cs;function n(r,a,l){var c=t(r,a,l),d=G[l]||G[""],m=d.template.indexOf("%t")!==-1,u=d.template.indexOf("%l")!==-1,h=d.template.indexOf("%n")!==-1;return function(){for(var g="",b=arguments.length,v=Array(b),w=0;w<b;w++)v[w]=arguments[w];if(s||!G[l]){var y=d.timestampFormatter(new Date),C=d.levelFormatter(r),I=d.nameFormatter(l);d.format?g+=d.format(C,I,y):(g+=d.template,m&&(g=g.replace(/%t/,y)),u&&(g=g.replace(/%l/,C)),h&&(g=g.replace(/%n/,I))),v.length&&typeof v[0]=="string"?v[0]=g+" "+v[0]:v.unshift(g)}c.apply(void 0,v)}}return G[s]||(i.methodFactory=n),e=e||{},e.template&&(e.format=void 0),G[s]=ls({},o,e),i.setLevel(i.getLevel()),et||i.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),i},tt={reg:ds,apply:hs};const st={debug:"#0ea5e9",info:"#10b981",warn:"#f59e0b",error:"#ef4444"};tt.reg(_),tt.apply(_,{format(i,e,t){return st[i.toLowerCase()],`%c[${t}]%c %c[${i}]%c ${e?`%c[${e}]%c `:""}`},timestampFormatter(i){return i.toTimeString().split(" ")[0]+"."+i.getMilliseconds().toString().padStart(3,"0")}});const ps=_.methodFactory;_.methodFactory=function(i,e,t){const s=ps(i,e,t);return function(...o){if(o.length>0&&typeof o[0]=="string"&&o[0].includes("%c")){const n=st[i]||"#666",r=[o[0],`color: ${n}; font-weight: bold;`,"color: inherit;",`color: ${n}; font-weight: bold;`,"color: inherit;",...t?[`color: ${n}; font-weight: bold;`,"color: inherit;"]:[],...o.slice(1)];s(...r)}else s(...o)}},_.setLevel("silent");const ne=_.getLogger("MULTISELECT:INIT"),k=_.getLogger("MULTISELECT:DATA"),f=_.getLogger("MULTISELECT:UI"),A=_.getLogger("MULTISELECT:INTERACTION"),it=["MULTISELECT:INIT","MULTISELECT:DATA","MULTISELECT:UI","MULTISELECT:INTERACTION"];function ot(){_.setLevel("debug")}function nt(){_.setLevel("silent")}function rt(i){_.setLevel(i)}function at(i,e){_.getLogger(i).setLevel(e)}class lt{constructor(e){p(this,"container");p(this,"wrapper");p(this,"viewport");p(this,"itemHeight");p(this,"items");p(this,"renderItem");p(this,"bufferSize");p(this,"onVisibleRangeChange");p(this,"onScroll");p(this,"scrollTop",0);p(this,"viewportHeight",0);p(this,"visibleStart",0);p(this,"visibleEnd",0);p(this,"scrollHandler");p(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(){this.viewportHeight=this.container.clientHeight}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),s=Math.max(0,e-this.bufferSize),o=Math.min(this.items.length,t+this.bufferSize);return{start:s,end:o}}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 s="";for(let o=e;o<t;o++){const n=this.items[o],r=this.renderItem(n,o),a=o*this.itemHeight;s+=`<div class="ms__virtual-item" style="position: absolute; top: ${a}px; left: 0; right: 0; height: ${this.itemHeight}px;" data-index="${o}">`,s+=r,s+="</div>"}this.viewport.innerHTML=s}setItems(e){this.items=e,this.wrapper.style.height=`${e.length*this.itemHeight}px`,this.updateViewportHeight(),this.visibleStart=-1,this.visibleEnd=-1,this.render()}scrollToIndex(e){if(e<0||e>=this.items.length)return;const t=e*this.itemHeight;this.container.scrollTop=t}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=""}}class ct{constructor(e,t={}){p(this,"element");p(this,"instanceId");p(this,"options");p(this,"isOpen",!1);p(this,"selectedValues",new Set);p(this,"selectedOptions",new Map);p(this,"allOptions",[]);p(this,"filteredOptions",[]);p(this,"hiddenInputs",[]);p(this,"focusedIndex",-1);p(this,"matchingIndices",new Set);p(this,"searchTerm","");p(this,"isLoading",!1);p(this,"showSelectedPopover",!1);p(this,"selectedPopoverPlacement",null);p(this,"dropdownPlacement",null);p(this,"isRTL",!1);p(this,"effectiveBadgesPosition","bottom");p(this,"justClosedViaClick",!1);p(this,"dropdownCleanup",null);p(this,"hintCleanup",null);p(this,"selectedPopoverCleanup",null);p(this,"badgeTooltips",new Map);p(this,"badgeTooltipCleanups",new Map);p(this,"actionButtonTooltips",new Map);p(this,"actionButtonTooltipCleanups",new Map);p(this,"virtualScroll",null);p(this,"optionsContainer",null);p(this,"selectedPopoverVirtualScroll",null);p(this,"selectedPopoverContainer",null);p(this,"input");p(this,"dropdown");p(this,"badgesContainer");p(this,"counter");p(this,"hint");p(this,"selectedPopover");this.element=e,this.instanceId=`MS-${Math.random().toString(36).substr(2,9)}`,this.options={searchHint:e.dataset.searchHint||"",searchPlaceholder:e.dataset.searchPlaceholder||"Search...",dropdownMinWidth:e.dataset.dropdownMinWidth||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,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",options:[],container:void 0,...t},this.init()}getItemValue(e){return Array.isArray(e)&&e.length===2?e[0]:this.options.valueMember&&e[this.options.valueMember]!==void 0?e[this.options.valueMember]:this.options.getValueCallback?this.options.getValueCallback(e):"[N/A]"}getItemDisplayValue(e){return Array.isArray(e)&&e.length===2?String(e[1]):this.options.displayValueMember&&e[this.options.displayValueMember]!==void 0?String(e[this.options.displayValueMember]):this.options.getDisplayValueCallback?this.options.getDisplayValueCallback(e):"[N/A]"}getItemBadgeDisplayValue(e){return this.options.getBadgeDisplayCallback?this.options.getBadgeDisplayCallback(e):this.getItemDisplayValue(e)}getItemSearchValue(e){return this.options.searchValueMember&&e[this.options.searchValueMember]!==void 0?String(e[this.options.searchValueMember]):this.options.getSearchValueCallback?this.options.getSearchValueCallback(e):this.getItemDisplayValue(e)}getItemIcon(e){if(!Array.isArray(e)){if(this.options.iconMember&&e[this.options.iconMember]!==void 0)return String(e[this.options.iconMember]);if(this.options.getIconCallback)return this.options.getIconCallback(e)}}getItemSubtitle(e){if(!Array.isArray(e)){if(this.options.subtitleMember&&e[this.options.subtitleMember]!==void 0)return String(e[this.options.subtitleMember]);if(this.options.getSubtitleCallback)return this.options.getSubtitleCallback(e)}}getItemGroup(e){if(!Array.isArray(e)){if(this.options.groupMember&&e[this.options.groupMember]!==void 0)return String(e[this.options.groupMember]);if(this.options.getGroupCallback)return this.options.getGroupCallback(e)}}getItemDisabled(e){return Array.isArray(e)?!1:this.options.disabledMember&&e[this.options.disabledMember]!==void 0?!!e[this.options.disabledMember]:this.options.getDisabledCallback?this.options.getDisabledCallback(e):!1}init(){this.parseOptions(),this.buildHTML(),this.attachEvents(),this.parseInitialSelection(),ne.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){k.error(`[${this.instanceId}] Failed to parse data-options:`,t),this.allOptions=[]}else this.options.options&&(this.allOptions=this.options.options);this.filteredOptions=[...this.allOptions]}buildHTML(){const e=this.options.container||document.body,t=this.element.getRootNode(),s=t instanceof ShadowRoot?t.host:this.element,o=s.getAttribute("dir")==="rtl",n=s.closest('[dir="rtl"]')!==null;this.isRTL=o||n,ne.debug(`[${this.instanceId}] RTL Debug:`,{isShadowRoot:t instanceof ShadowRoot,hostElement:s,elementDir:s.getAttribute("dir"),hasElementDir:o,hasAncestorDir:n,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("ml"),this.isRTL&&(this.element.classList.add("ms--rtl"),ne.debug(`[${this.instanceId}] Added ms--rtl class to element`)),(!this.options.isCheckboxesShown||!this.options.isMultipleEnabled)&&this.element.classList.add("ms--no-checkboxes");const r=document.createElement("div");r.className="ms__input-wrapper",this.input=document.createElement("input"),this.input.type="text",this.input.className="ms__input",this.input.placeholder=this.options.searchPlaceholder,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",r.appendChild(this.input),r.appendChild(this.counter),r.appendChild(a),this.badgesContainer=document.createElement("div"),this.badgesContainer.className="ms__badges";const l=document.createElement("div");l.className="ml-wrapper",(this.effectiveBadgesPosition==="left"||this.effectiveBadgesPosition==="right")&&l.classList.add("ml-wrapper--inline"),l.appendChild(r),l.appendChild(this.badgesContainer),this.element.appendChild(l),this.dropdown=document.createElement("div"),this.dropdown.className="ms__dropdown",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.shouldUseVirtualScroll()){this.dropdown.classList.add("ms__dropdown--virtual"),this.renderDropdownVirtual();return}this.dropdown.classList.remove("ms__dropdown--virtual");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.dropdown.innerHTML=e;return}if(this.options.isMultipleEnabled&&this.options.actionButtons&&this.options.actionButtons.length>0){const t=this.options.isActionsSticky?" ms__actions--sticky":"",s=this.options.actionsLayout==="wrap"?" ms__actions--wrap":"";e+=`<div class="ms__actions${t}${s}">`,this.options.actionButtons.forEach(o=>{if(!(o.isVisibleCallback?o.isVisibleCallback(this):o.isVisible??!0))return;const a=(o.isDisabledCallback?o.isDisabledCallback(this):o.isDisabled??!1)?" disabled":"",l=o.getTextCallback?o.getTextCallback(this):o.text;let c="";if(o.getClassCallback){const d=o.getClassCallback(this);c=Array.isArray(d)?` ${d.join(" ")}`:d?` ${d}`:""}else o.cssClass&&(c=` ${o.cssClass}`);e+=`<button type="button"${a} class="ms__action-btn${c}" data-action="${o.action}">${l}</button>`}),e+="</div>"}if(e+='<div class="ms__options">',this.filteredOptions.length===0)e+=`<div class="ms__empty">${this.options.emptyMessage}</div>`;else if(this.options.isGroupsAllowed){const t=this.groupOptions(this.filteredOptions);Object.keys(t).forEach(s=>{if(e+='<div class="ms__group">',s!=="__ungrouped__")if(this.options.renderGroupLabelContentCallback){const o=this.options.renderGroupLabelContentCallback(s);if(o instanceof HTMLElement){const n=document.createElement("div");n.className="ms__group-label",n.appendChild(o),e+=n.outerHTML}else e+=`<div class="ms__group-label">${o}</div>`}else e+=`<div class="ms__group-label">${s}</div>`;t[s].forEach((o,n)=>{e+=this.renderOption(o,n)}),e+="</div>"})}else this.filteredOptions.forEach((t,s)=>{e+=this.renderOption(t,s)});e+="</div>",this.dropdown.innerHTML=e,this.attachActionButtonTooltips()}renderDropdownVirtual(){if(this.destroyAllActionButtonTooltips(),!this.virtualScroll){let s="";if(this.options.isMultipleEnabled&&this.options.actionButtons&&this.options.actionButtons.length>0){const r=this.options.isActionsSticky?" ms__actions--sticky":"",a=this.options.actionsLayout==="wrap"?" ms__actions--wrap":"";s+=`<div class="ms__actions${r}${a}">`,this.options.actionButtons.forEach(l=>{if(!(l.isVisibleCallback?l.isVisibleCallback(this):l.isVisible??!0))return;const m=(l.isDisabledCallback?l.isDisabledCallback(this):l.isDisabled??!1)?" disabled":"",u=l.getTextCallback?l.getTextCallback(this):l.text;let h="";if(l.getClassCallback){const g=l.getClassCallback(this);h=Array.isArray(g)?` ${g.join(" ")}`:g?` ${g}`:""}else l.cssClass&&(h=` ${l.cssClass}`);s+=`<button type="button"${m} class="ms__action-btn${h}" data-action="${l.action}">${u}</button>`}),s+="</div>"}const o=this.options.maxHeight||"20rem",n=this.options.optionHeight??50;s+=`<div class="ms__options ms__options--virtual" style="height: ${o}; max-height: ${o}; overflow-y: auto; position: relative; --ml-option-height: ${n}px;"></div>`,this.dropdown.innerHTML=s,this.optionsContainer=this.dropdown.querySelector(".ms__options")}if(this.filteredOptions.length===0){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 lt({container:this.optionsContainer,itemHeight:e,items:this.filteredOptions,renderItem:(s,o)=>this.renderOption(s,o),bufferSize:t}),this.attachActionButtonTooltips())})}renderOption(e,t){const s=this.getItemValue(e),o=this.getItemDisplayValue(e),n=this.getItemIcon(e),r=this.getItemSubtitle(e),a=this.getItemDisabled(e),l=this.selectedValues.has(String(s)),c=t===this.focusedIndex,d=this.matchingIndices.has(t),m=["ms__option"];l&&m.push("ms__option--selected"),c&&m.push("ms__option--focused"),d&&m.push("ms__option--matched"),a&&m.push("ms__option--disabled");const u=this.options.checkboxAlign&&this.options.checkboxAlign!=="top"?` data-checkbox-align="${this.options.checkboxAlign}"`:"";let h=`<div class="${m.join(" ")}" data-value="${s}" data-index="${t}"${u}>`;if(this.options.isCheckboxesShown&&this.options.isMultipleEnabled&&(h+=`<input type="checkbox" class="ms__checkbox" ${l?"checked":""} ${a?"disabled":""}>`),h+='<div class="ms__option-content">',this.options.renderOptionContentCallback){const g={index:t,isSelected:l,isFocused:c,isMatched:d,isDisabled:a},b=this.options.renderOptionContentCallback(e,g);typeof b=="string"?h+=b:h+=b.outerHTML}else n&&(h+=`<span class="ms__option-icon">${n}</span>`),h+='<div class="ms__option-text">',h+=`<div class="ms__option-title">${this.highlightMatch(o,this.searchTerm)}</div>`,r&&(h+=`<div class="ms__option-subtitle">${r}</div>`),h+="</div>";return h+="</div>",h+="</div>",h}highlightMatch(e,t){if(!t)return e;const s=new RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return e.replace(s,"<mark>$1</mark>")}groupOptions(e){const t={};return e.forEach(s=>{const o=this.getItemGroup(s)||"__ungrouped__";t[o]||(t[o]=[]),t[o].push(s)}),t}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 n;e[0]&&(this.options.renderSelectedContentCallback?n=this.options.renderSelectedContentCallback(e[0]):n=this.getItemDisplayValue(e[0])),f.warn(`[${this.instanceId}] renderBadges() single-select mode`,{isOpen:this.isOpen,count:t,selectedOptionsLength:e.length,willSetValue:!this.isOpen&&t>0&&e.length>0,selectedLabel:n}),!this.isOpen&&t>0&&e.length>0?(f.info(`[${this.instanceId}] ✅ SETTING input.value = "${n}"`),this.input.value=n,f.info(`[${this.instanceId}] 🔍 VERIFY input.value = "${this.input.value}"`)):this.isOpen?f.info(`[${this.instanceId}] ⏭️ SKIPPING input update (dropdown is open)`):(f.info(`[${this.instanceId}] ❌ CLEARING input.value (no selection)`),this.input.value="");return}let s=this.options.badgesDisplayMode;if(this.options.badgesThreshold!==null&&t>this.options.badgesThreshold&&s!=="none"&&(s=this.options.badgesThresholdMode||"count"),!this.isOpen)if(t>0&&s==="count"){const n=this.options.getCounterCallback?this.options.getCounterCallback(t):`${t} selected`;this.input.placeholder=n}else this.input.placeholder=this.options.searchPlaceholder;if(this.options.isCounterShown&&t>0?(this.counter.textContent=`[${t}]`,this.counter.style.display=""):this.counter.style.display="none",s==="none"){this.badgesContainer.innerHTML="";return}if(s==="badges")this.badgesContainer.className=`ms__badges ms__badges--${this.effectiveBadgesPosition}`,this.badgesContainer.innerHTML=e.map(n=>{const r=this.getItemValue(n);let a;if(this.options.renderBadgeContentCallback){const c={displayMode:"badges",isInPopover:!1},d=this.options.renderBadgeContentCallback(n,c);a=typeof d=="string"?d:d.outerHTML}else a=this.getItemBadgeDisplayValue(n);let l="ms__badge";if(this.options.getBadgeClassCallback){const c=this.options.getBadgeClassCallback(n),d=Array.isArray(c)?c:[c];l+=" "+d.filter(m=>m).join(" ")}return`
|
|
2
|
+
<div class="${l}">
|
|
3
|
+
<span class="ms__badge-text">${a}</span>
|
|
4
|
+
<button type="button" class="ms__badge-remove" data-value="${r}" aria-label="Remove ${this.getItemBadgeDisplayValue(n)}"></button>
|
|
5
5
|
</div>
|
|
6
|
-
`}).join("");else if(
|
|
6
|
+
`}).join("");else if(s==="partial"){this.badgesContainer.className=`ms__badges ms__badges--${this.effectiveBadgesPosition}`;const n=this.options.badgesMaxVisible||3,r=e.slice(0,n),a=t-n,l=r.map(d=>{const m=this.getItemValue(d);let u;if(this.options.renderBadgeContentCallback){const g={displayMode:"partial",isInPopover:!1},b=this.options.renderBadgeContentCallback(d,g);u=typeof b=="string"?b:b.outerHTML}else u=this.getItemBadgeDisplayValue(d);let h="ms__badge";if(this.options.getBadgeClassCallback){const g=this.options.getBadgeClassCallback(d),b=Array.isArray(g)?g:[g];h+=" "+b.filter(v=>v).join(" ")}return`
|
|
7
7
|
<div class="${h}">
|
|
8
|
-
<span class="
|
|
9
|
-
<button type="button" class="
|
|
8
|
+
<span class="ms__badge-text">${u}</span>
|
|
9
|
+
<button type="button" class="ms__badge-remove" data-value="${m}" aria-label="Remove ${this.getItemBadgeDisplayValue(d)}"></button>
|
|
10
10
|
</div>
|
|
11
|
-
`}).join("");let
|
|
12
|
-
<div class="
|
|
13
|
-
<span class="
|
|
14
|
-
<button type="button" class="
|
|
11
|
+
`}).join("");let c="";a>0&&(c=`
|
|
12
|
+
<div class="ms__badge ms__badge--counter ms__badge--more" data-action="show-selected">
|
|
13
|
+
<span class="ms__badge-text">${this.options.getCounterCallback?this.options.getCounterCallback(t,a):`+${a} more`}</span>
|
|
14
|
+
<button type="button" class="ms__badge-remove" data-action="remove-hidden" aria-label="Remove ${a} hidden items"></button>
|
|
15
15
|
</div>
|
|
16
|
-
`),this.badgesContainer.innerHTML=
|
|
17
|
-
<div class="
|
|
18
|
-
<span class="
|
|
19
|
-
<button type="button" class="
|
|
16
|
+
`),this.badgesContainer.innerHTML=l+c}else if(s==="compact")if(this.badgesContainer.className=`ms__badges ms__badges--${this.effectiveBadgesPosition}`,t>0){const n=e[0],r=this.getItemBadgeDisplayValue(n),a=t-1;let l=r;if(a>0){const c=this.options.getCounterCallback?this.options.getCounterCallback(t,a):`+${a} more`;l=`${r} (${c})`}this.badgesContainer.innerHTML=`
|
|
17
|
+
<div class="ms__badge ms__badge--counter" data-action="show-selected">
|
|
18
|
+
<span class="ms__badge-text">${l}</span>
|
|
19
|
+
<button type="button" class="ms__badge-remove" data-action="clear-count" aria-label="Clear all selections"></button>
|
|
20
20
|
</div>
|
|
21
|
-
`}else this.badgesContainer.innerHTML="";else if(this.badgesContainer.className=`
|
|
22
|
-
<div class="
|
|
23
|
-
<span class="
|
|
24
|
-
<button type="button" class="
|
|
21
|
+
`}else this.badgesContainer.innerHTML="";else if(this.badgesContainer.className=`ms__badges ms__badges--${this.effectiveBadgesPosition}`,t>0){const n=this.options.getCounterCallback?this.options.getCounterCallback(t):`${t} selected`;this.badgesContainer.innerHTML=`
|
|
22
|
+
<div class="ms__badge ms__badge--counter" data-action="show-selected">
|
|
23
|
+
<span class="ms__badge-text">${n}</span>
|
|
24
|
+
<button type="button" class="ms__badge-remove" data-action="clear-count" aria-label="Clear all selections"></button>
|
|
25
25
|
</div>
|
|
26
|
-
`}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)),setTimeout(()=>{document.addEventListener("click",e=>this.handleClickOutside(e))},0),this.dropdown.addEventListener("click",e=>this.handleDropdownClick(e)),this.dropdown.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){k.debug(`[${this.instanceId}] beforeSearchCallback blocked search for term:`,e),this.filteredOptions=[...this.allOptions],this.matchingIndices.clear(),this.renderDropdown();return}t=i,t!==e&&k.debug(`[${this.instanceId}] beforeSearchCallback transformed: "${e}" -> "${t}"`)}if(this.options.searchCallback){if(t.length<this.options.minSearchLength){this.isLoading=!1,this.options.isKeepOptionsOnSearch?(this.filteredOptions=[...this.allOptions],k.debug(`[${this.instanceId}] Search term below minimum, showing ${this.allOptions.length} initial options`)):this.filteredOptions=[],this.matchingIndices.clear(),this.renderDropdown();return}this.isLoading=!0,this.renderDropdown(),k.debug(`[${this.instanceId}] Loading data for search term:`,t);try{const i=await this.options.searchCallback(t);if(this.searchTerm===e){const s=i||[];this.filteredOptions=[...s],this.isLoading=!1,this.matchingIndices.clear(),this.focusedIndex=this.options.isSearchEnabled&&this.filteredOptions.length>0?0:-1,this.renderDropdown(),k.debug(`[${this.instanceId}] Loaded ${s.length} results`)}}catch(i){k.error(`[${this.instanceId}] Error loading data:`,i),this.isLoading=!1,this.options.isKeepOptionsOnSearch?this.filteredOptions=[...this.allOptions]:this.filteredOptions=[],this.matchingIndices.clear(),this.renderDropdown()}}else{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(n=>this.getItemSearchValue(n).toLowerCase().includes(s)),this.matchingIndices.clear(),this.focusedIndex=this.filteredOptions.length>0?0:-1,k.debug(`[${this.instanceId}] Filter mode: ${this.filteredOptions.length} matches for "${t}"`);else{this.filteredOptions=[...this.allOptions],this.matchingIndices.clear();let n=-1;this.allOptions.forEach((l,r)=>{this.getItemSearchValue(l).toLowerCase().includes(s)&&(this.matchingIndices.add(r),n===-1&&(n=r))}),n>=0?(this.focusedIndex=n,k.debug(`[${this.instanceId}] Navigate mode: ${this.matchingIndices.size} matches, jumped to index ${n}`)):k.debug(`[${this.instanceId}] Navigate mode: No matches found, keeping previous focus`)}}this.renderDropdown(),this.options.searchMode==="navigate"&&this.focusedIndex>=0&&this.scrollToFocused()}}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.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;I.debug(`[${this.instanceId}] Dropdown clicked`,{target:e.target.className}),e.stopPropagation();const t=e.target.closest("[data-action]");if(t){e.preventDefault();const n=t.dataset.action;if(I.debug(`[${this.instanceId}] Action button clicked:`,n),n==="select-all")this.selectAll();else if(n==="clear-all")this.clearAll();else if(n==="custom"){const l=(s=this.options.actionButtons)==null?void 0:s.find(r=>{var a;return r.action==="custom"&&r.text===((a=t.textContent)==null?void 0:a.trim())});l!=null&&l.onClick&&l.onClick(this)}return}const i=e.target.closest(".ml__option");if(i&&!i.classList.contains("ml__option--disabled")){e.preventDefault();const n=i.dataset.value,l=this.filteredOptions.find(r=>String(this.getItemValue(r))===n);I.debug(`[${this.instanceId}] Option clicked:`,{value:n,closeOnSelect:this.options.isCloseOnSelect,placeholder:this.options.searchPlaceholder}),l&&this.toggleOption(l)}}handleBadgeClick(e){if(e.target.closest('[data-action="clear-count"]')){e.preventDefault(),e.stopPropagation(),I.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(".ml__badge-remove");if(s){if(e.preventDefault(),e.stopPropagation(),s.dataset.action==="remove-hidden"){I.debug(`[${this.instanceId}] Remove hidden items button clicked`);const a=this.options.badgesMaxVisible||3;Array.from(this.selectedOptions.values()).slice(a).forEach(p=>this.deselectOption(p));return}const l=s.dataset.value,r=this.selectedOptions.get(l);r&&this.deselectOption(r);return}if(e.target.closest(".ml__badge--more")&&!e.target.closest(".ml__badge-remove")){e.preventDefault(),e.stopPropagation(),I.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(l=>l instanceof Node&&(this.selectedPopover.contains(l)||this.counter.contains(l)||l.closest&&l.closest('[data-action="show-selected"]')))){f.debug(`[${this.instanceId}] Closing selected popover due to click outside`),this.hideSelectedPopover();return}if(!this.isOpen)return;const i=t.some(n=>n instanceof Node&&(this.element.contains(n)||this.dropdown.contains(n)||this.hint&&this.hint.contains(n)));I.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(n=>n instanceof Node&&this.element.contains(n)),dropdownContains:t.some(n=>n instanceof Node&&this.dropdown.contains(n)),isConnected:this.dropdown.isConnected}),i||(I.warn(`[${this.instanceId}] Closing dropdown due to click outside`),this.close())}focusNext(){this.filteredOptions.length!==0&&(this.focusedIndex=Math.min(this.filteredOptions.length-1,this.focusedIndex+1),this.renderDropdown(),this.scrollToFocused())}focusPrevious(){this.filteredOptions.length!==0&&(this.focusedIndex=this.focusedIndex<=0?this.filteredOptions.length-1:this.focusedIndex-1,this.renderDropdown(),this.scrollToFocused())}focusFirst(){this.filteredOptions.length!==0&&(this.focusedIndex=0,this.renderDropdown(),this.scrollToFocused())}focusLast(){this.filteredOptions.length!==0&&(this.focusedIndex=this.filteredOptions.length-1,this.renderDropdown(),this.scrollToFocused())}focusNextMatch(){if(this.matchingIndices.size===0)return;const e=Array.from(this.matchingIndices).sort((s,n)=>s-n),t=e.findIndex(s=>s===this.focusedIndex),i=(t+1)%e.length;this.focusedIndex=e[i],this.renderDropdown(),this.scrollToFocused(),I.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,n)=>s-n),t=e.findIndex(s=>s===this.focusedIndex),i=t<=0?e.length-1:t-1;this.focusedIndex=e[i],this.renderDropdown(),this.scrollToFocused(),I.debug(`[${this.instanceId}] Jumped to previous match: index ${this.focusedIndex} (${t+1} of ${e.length})`)}focusPageUp(){this.filteredOptions.length!==0&&(this.focusedIndex=Math.max(0,this.focusedIndex-10),this.renderDropdown(),this.scrollToFocused())}focusPageDown(){this.filteredOptions.length!==0&&(this.focusedIndex=Math.min(this.filteredOptions.length-1,this.focusedIndex+10),this.renderDropdown(),this.scrollToFocused())}scrollToFocused(){if(this.virtualScroll&&this.focusedIndex>=0)this.virtualScroll.scrollToIndex(this.focusedIndex);else{const e=this.dropdown.querySelector(".ml__option--focused");e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}}toggleOption(e){const t=this.getItemValue(e),i=String(t);if(I.debug(`[${this.instanceId}] toggleOption called`,{value:t,multiple:this.options.isMultipleEnabled}),!this.options.isMultipleEnabled){this.selectedValues.has(i)?(I.debug(`[${this.instanceId}] Deselecting option in single-select mode`,{value:t}),this.deselectOption(e)):(I.debug(`[${this.instanceId}] Clearing previous selections and selecting new option`,{value:t}),this.selectedValues.clear(),this.selectedOptions.clear(),this.selectOption(e)),f.info(`[${this.instanceId}] ❌ Closing dropdown (single-select mode)`),this.close();return}this.selectedValues.has(i)?(I.debug(`[${this.instanceId}] Deselecting option`,{value:t}),this.deselectOption(e)):(I.debug(`[${this.instanceId}] Selecting option`,{value:t}),this.selectOption(e)),I.debug(`[${this.instanceId}] Checking closeOnSelect`,{closeOnSelect:this.options.isCloseOnSelect,willClose:this.options.isCloseOnSelect===!0,placeholder:this.options.searchPlaceholder}),this.options.isCloseOnSelect?(f.info(`[${this.instanceId}] ❌ Closing dropdown (closeOnSelect=true)`),this.close()):f.info(`[${this.instanceId}] ✅ Keeping dropdown open (closeOnSelect=false)`)}async handleAddNew(e){if(this.options.addNewCallback)try{k.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){k.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.renderDropdown(),this.renderBadges(),this.updateHiddenInput(),this.options.selectCallback&&this.options.selectCallback(e),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}deselectOption(e){const t=this.getItemValue(e),i=String(t);this.selectedValues.delete(i),this.selectedOptions.delete(i),this.renderDropdown(),this.renderBadges(),this.updateHiddenInput(),this.options.deselectCallback&&this.options.deselectCallback(e),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}selectAll(){this.filteredOptions.forEach(e=>{if(!this.getItemDisabled(e)){const t=this.getItemValue(e),i=String(t);this.selectedValues.add(i),this.selectedOptions.set(i,e)}}),this.renderDropdown(),this.renderBadges(),this.updateHiddenInput(),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}clearAll(){this.selectedValues.clear(),this.selectedOptions.clear(),this.renderDropdown(),this.renderBadges(),this.updateHiddenInput(),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}open(){f.debug(`[${this.instanceId}] open() called`,{isOpen:this.isOpen}),!this.isOpen&&(this.isOpen=!0,this.element.classList.add("ml--open"),this.dropdown.classList.add("ml__dropdown--visible"),f.info(`[${this.instanceId}] Dropdown opened`),this.input.placeholder=this.options.searchPlaceholder,!this.options.isMultipleEnabled&&this.options.isSearchEnabled&&(this.input.value=""),this.options.searchCallback&&this.options.isKeepOptionsOnSearch&&!this.searchTerm&&(this.filteredOptions=[...this.allOptions],f.debug(`[${this.instanceId}] Showing ${this.allOptions.length} initial options on open`)),this.renderDropdown(),this.positionDropdown(),this.hint&&(this.hint.classList.add("ml__hint--visible"),this.positionHint()))}close(){if(f.debug(`[${this.instanceId}] close() called`,{isOpen:this.isOpen}),!this.isOpen)return;this.isOpen=!1,this.element.classList.remove("ml--open"),this.dropdown.classList.remove("ml__dropdown--visible"),this.hint&&this.hint.classList.remove("ml__hint--visible"),this.searchTerm="";const e=this.options.isMultipleEnabled||this.options.isSearchEnabled;f.warn(`[${this.instanceId}] close() - input clearing decision`,{multiple:this.options.isMultipleEnabled,enableSearch:this.options.isSearchEnabled,willClearInput:e,currentInputValue:this.input.value}),e?(f.info(`[${this.instanceId}] 🧹 close() CLEARING input.value`),this.input.value=""):f.info(`[${this.instanceId}] 🔒 close() KEEPING input.value = "${this.input.value}"`),this.filteredOptions=[...this.allOptions],this.focusedIndex=-1,f.info(`[${this.instanceId}] 📞 close() CALLING renderBadges()`),this.renderBadges(),f.info(`[${this.instanceId}] ✅ close() AFTER renderBadges(), input.value = "${this.input.value}"`),this.dropdownCleanup&&(this.dropdownCleanup(),this.dropdownCleanup=null),this.hintCleanup&&(this.hintCleanup(),this.hintCleanup=null),this.dropdownPlacement=null,f.info(`[${this.instanceId}] Dropdown closed. Stack trace:`),f.trace()}positionDropdown(){this.dropdownCleanup=Q(this.input,this.dropdown,()=>{const e=this.options.isPlacementLocked&&this.dropdownPlacement?this.dropdownPlacement:"bottom-start",t=[ee(4),...this.options.isPlacementLocked&&this.dropdownPlacement?[]:[ve()],te({padding:8})];ie(this.input,this.dropdown,{placement:e,middleware:t}).then(({x:i,y:s,placement:n})=>{this.options.isPlacementLocked&&!this.dropdownPlacement&&(this.dropdownPlacement=n,f.debug(`[${this.instanceId}] Locked dropdown placement:`,n));const l={left:`${i}px`,top:`${s}px`,width:`${this.input.offsetWidth}px`};this.options.dropdownMinWidth&&(l.minWidth=this.options.dropdownMinWidth),Object.assign(this.dropdown.style,l),this.hint&&this.isOpen&&this.positionHint()})})}positionHint(){this.hint&&(this.hintCleanup&&this.hintCleanup(),this.hintCleanup=Q(this.input,this.hint,()=>{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"))),ie(this.input,this.hint,{placement:e,middleware:[ee(4),te({padding:8})]}).then(({x:t,y:i})=>{Object.assign(this.hint.style,{left:`${t}px`,top:`${i}px`})})}))}parseInitialSelection(){const e=this.element.dataset.initialValues;if(e)try{JSON.parse(e).forEach(i=>{const s=String(i);this.selectedValues.add(s);const n=this.allOptions.find(l=>String(this.getItemValue(l))===s);n&&this.selectedOptions.set(s,n)}),this.renderBadges()}catch(t){k.error(`[${this.instanceId}] Failed to parse initial values:`,t)}}toggleSelectedPopover(){this.showSelectedPopover?this.hideSelectedPopover():this.showPopover()}showPopover(){f.debug(`[${this.instanceId}] showPopover() called`),this.isOpen&&this.close(),this.showSelectedPopover=!0,this.renderSelectedPopover(),this.selectedPopover.classList.add("ml__selected-popover--visible"),this.selectedValues.size>=100&&this.selectedPopover.classList.add("ml__selected-popover--virtual"),this.positionSelectedPopover()}hideSelectedPopover(){f.debug(`[${this.instanceId}] hideSelectedPopover() called`),this.showSelectedPopover=!1,this.selectedPopover.classList.remove("ml__selected-popover--visible"),this.selectedPopover.classList.remove("ml__selected-popover--virtual"),this.selectedPopoverPlacement=null,this.selectedPopoverVirtualScroll&&(this.selectedPopoverVirtualScroll.destroy(),this.selectedPopoverVirtualScroll=null,this.selectedPopoverContainer=null),this.selectedPopoverCleanup&&(this.selectedPopoverCleanup(),this.selectedPopoverCleanup=null)}renderSelectedPopover(){const e=Array.from(this.selectedOptions.values()),t=this.selectedValues.size;if(t>=100){this.renderSelectedPopoverVirtual(e,t);return}this.selectedPopover.innerHTML=`
|
|
27
|
-
<div class="
|
|
26
|
+
`}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)),setTimeout(()=>{document.addEventListener("click",e=>this.handleClickOutside(e))},0),this.dropdown.addEventListener("click",e=>this.handleDropdownClick(e)),this.dropdown.addEventListener("wheel",e=>{if(this.virtualScroll)return;const t=e.currentTarget,s=t.scrollTop===0,o=t.scrollTop+t.clientHeight>=t.scrollHeight;(e.deltaY<0&&s||e.deltaY>0&&o)&&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 s=this.options.beforeSearchCallback(e);if(s===null){k.debug(`[${this.instanceId}] beforeSearchCallback blocked search for term:`,e),this.filteredOptions=[...this.allOptions],this.matchingIndices.clear(),this.renderDropdown();return}t=s,t!==e&&k.debug(`[${this.instanceId}] beforeSearchCallback transformed: "${e}" -> "${t}"`)}if(this.options.searchCallback){if(t.length<this.options.minSearchLength){this.isLoading=!1,this.options.isKeepOptionsOnSearch?(this.filteredOptions=[...this.allOptions],k.debug(`[${this.instanceId}] Search term below minimum, showing ${this.allOptions.length} initial options`)):this.filteredOptions=[],this.matchingIndices.clear(),this.renderDropdown();return}this.isLoading=!0,this.renderDropdown(),k.debug(`[${this.instanceId}] Loading data for search term:`,t);try{const s=await this.options.searchCallback(t);if(this.searchTerm===e){const o=s||[];this.filteredOptions=[...o],this.isLoading=!1,this.matchingIndices.clear(),this.focusedIndex=this.options.isSearchEnabled&&this.filteredOptions.length>0?0:-1,this.renderDropdown(),k.debug(`[${this.instanceId}] Loaded ${o.length} results`)}}catch(s){k.error(`[${this.instanceId}] Error loading data:`,s),this.isLoading=!1,this.options.isKeepOptionsOnSearch?this.filteredOptions=[...this.allOptions]:this.filteredOptions=[],this.matchingIndices.clear(),this.renderDropdown()}}else{if(!t)this.filteredOptions=[...this.allOptions],this.matchingIndices.clear(),this.focusedIndex=this.filteredOptions.length>0?0:-1;else{const s=this.options.searchMode||"filter",o=t.toLowerCase();if(s==="filter")this.filteredOptions=this.allOptions.filter(n=>this.getItemSearchValue(n).toLowerCase().includes(o)),this.matchingIndices.clear(),this.focusedIndex=this.filteredOptions.length>0?0:-1,k.debug(`[${this.instanceId}] Filter mode: ${this.filteredOptions.length} matches for "${t}"`);else{this.filteredOptions=[...this.allOptions],this.matchingIndices.clear();let n=-1;this.allOptions.forEach((r,a)=>{this.getItemSearchValue(r).toLowerCase().includes(o)&&(this.matchingIndices.add(a),n===-1&&(n=a))}),n>=0?(this.focusedIndex=n,k.debug(`[${this.instanceId}] Navigate mode: ${this.matchingIndices.size} matches, jumped to index ${n}`)):k.debug(`[${this.instanceId}] Navigate mode: No matches found, keeping previous focus`)}}this.renderDropdown(),this.options.searchMode==="navigate"&&this.focusedIndex>=0&&this.scrollToFocused()}}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",s=["ArrowUp","ArrowDown","PageUp","PageDown","Home","End","Enter","Escape","Tab"].includes(e.key);if(t&&!s){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.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 o;A.debug(`[${this.instanceId}] Dropdown clicked`,{target:e.target.className}),e.stopPropagation();const t=e.target.closest("[data-action]");if(t){e.preventDefault();const n=t.dataset.action;if(A.debug(`[${this.instanceId}] Action button clicked:`,n),n==="select-all")this.selectAll();else if(n==="clear-all")this.clearAll();else if(n==="custom"){const r=(o=this.options.actionButtons)==null?void 0:o.find(a=>{var l;return a.action==="custom"&&a.text===((l=t.textContent)==null?void 0:l.trim())});r!=null&&r.onClick&&r.onClick(this)}return}const s=e.target.closest(".ms__option");if(s&&!s.classList.contains("ms__option--disabled")){e.preventDefault();const n=s.dataset.value,r=this.filteredOptions.find(a=>String(this.getItemValue(a))===n);A.debug(`[${this.instanceId}] Option clicked:`,{value:n,closeOnSelect:this.options.isCloseOnSelect,placeholder:this.options.searchPlaceholder}),r&&this.toggleOption(r)}}handleBadgeClick(e){if(e.target.closest('[data-action="clear-count"]')){e.preventDefault(),e.stopPropagation(),A.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 o=e.target.closest(".ms__badge-remove");if(o){if(e.preventDefault(),e.stopPropagation(),o.dataset.action==="remove-hidden"){A.debug(`[${this.instanceId}] Remove hidden items button clicked`);const l=this.options.badgesMaxVisible||3;Array.from(this.selectedOptions.values()).slice(l).forEach(m=>this.deselectOption(m));return}const r=o.dataset.value,a=this.selectedOptions.get(r);a&&this.deselectOption(a);return}if(e.target.closest(".ms__badge--more")&&!e.target.closest(".ms__badge-remove")){e.preventDefault(),e.stopPropagation(),A.debug(`[${this.instanceId}] '+X more' badge clicked, showing popover`),this.toggleSelectedPopover();return}}handleClickOutside(e){var o;const t=e.composedPath();if(this.showSelectedPopover&&!t.some(r=>r instanceof Node&&(this.selectedPopover.contains(r)||this.counter.contains(r)||r.closest&&r.closest('[data-action="show-selected"]')))){f.debug(`[${this.instanceId}] Closing selected popover due to click outside`),this.hideSelectedPopover();return}if(!this.isOpen)return;const s=t.some(n=>n instanceof Node&&(this.element.contains(n)||this.dropdown.contains(n)||this.hint&&this.hint.contains(n)));A.debug(`[${this.instanceId}] handleClickOutside`,{target:e.target.className,targetTag:e.target.tagName,clickedInside:s,pathLength:t.length,firstInPath:(o=t[0])==null?void 0:o.tagName,elementContains:t.some(n=>n instanceof Node&&this.element.contains(n)),dropdownContains:t.some(n=>n instanceof Node&&this.dropdown.contains(n)),isConnected:this.dropdown.isConnected}),s||(A.warn(`[${this.instanceId}] Closing dropdown due to click outside`),this.close())}focusNext(){this.filteredOptions.length!==0&&(this.focusedIndex=Math.min(this.filteredOptions.length-1,this.focusedIndex+1),this.renderDropdown(),this.scrollToFocused())}focusPrevious(){this.filteredOptions.length!==0&&(this.focusedIndex=this.focusedIndex<=0?this.filteredOptions.length-1:this.focusedIndex-1,this.renderDropdown(),this.scrollToFocused())}focusFirst(){this.filteredOptions.length!==0&&(this.focusedIndex=0,this.renderDropdown(),this.scrollToFocused())}focusLast(){this.filteredOptions.length!==0&&(this.focusedIndex=this.filteredOptions.length-1,this.renderDropdown(),this.scrollToFocused())}focusNextMatch(){if(this.matchingIndices.size===0)return;const e=Array.from(this.matchingIndices).sort((o,n)=>o-n),t=e.findIndex(o=>o===this.focusedIndex),s=(t+1)%e.length;this.focusedIndex=e[s],this.renderDropdown(),this.scrollToFocused(),A.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((o,n)=>o-n),t=e.findIndex(o=>o===this.focusedIndex),s=t<=0?e.length-1:t-1;this.focusedIndex=e[s],this.renderDropdown(),this.scrollToFocused(),A.debug(`[${this.instanceId}] Jumped to previous match: index ${this.focusedIndex} (${t+1} of ${e.length})`)}focusPageUp(){this.filteredOptions.length!==0&&(this.focusedIndex=Math.max(0,this.focusedIndex-10),this.renderDropdown(),this.scrollToFocused())}focusPageDown(){this.filteredOptions.length!==0&&(this.focusedIndex=Math.min(this.filteredOptions.length-1,this.focusedIndex+10),this.renderDropdown(),this.scrollToFocused())}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){const t=this.getItemValue(e),s=String(t);if(A.debug(`[${this.instanceId}] toggleOption called`,{value:t,multiple:this.options.isMultipleEnabled}),!this.options.isMultipleEnabled){this.selectedValues.has(s)?(A.debug(`[${this.instanceId}] Deselecting option in single-select mode`,{value:t}),this.deselectOption(e)):(A.debug(`[${this.instanceId}] Clearing previous selections and selecting new option`,{value:t}),this.selectedValues.clear(),this.selectedOptions.clear(),this.selectOption(e)),f.info(`[${this.instanceId}] ❌ Closing dropdown (single-select mode)`),this.close();return}this.selectedValues.has(s)?(A.debug(`[${this.instanceId}] Deselecting option`,{value:t}),this.deselectOption(e)):(A.debug(`[${this.instanceId}] Selecting option`,{value:t}),this.selectOption(e)),A.debug(`[${this.instanceId}] Checking closeOnSelect`,{closeOnSelect:this.options.isCloseOnSelect,willClose:this.options.isCloseOnSelect===!0,placeholder:this.options.searchPlaceholder}),this.options.isCloseOnSelect?(f.info(`[${this.instanceId}] ❌ Closing dropdown (closeOnSelect=true)`),this.close()):f.info(`[${this.instanceId}] ✅ Keeping dropdown open (closeOnSelect=false)`)}async handleAddNew(e){if(this.options.addNewCallback)try{k.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){k.error(`[${this.instanceId}] Error adding new option:`,t)}}selectOption(e){const t=this.getItemValue(e),s=String(t);this.selectedValues.add(s),this.selectedOptions.set(s,e),this.renderDropdown(),this.renderBadges(),this.updateHiddenInput(),this.options.selectCallback&&this.options.selectCallback(e),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}deselectOption(e){const t=this.getItemValue(e),s=String(t);this.selectedValues.delete(s),this.selectedOptions.delete(s),this.renderDropdown(),this.renderBadges(),this.updateHiddenInput(),this.options.deselectCallback&&this.options.deselectCallback(e),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}selectAll(){this.filteredOptions.forEach(e=>{if(!this.getItemDisabled(e)){const t=this.getItemValue(e),s=String(t);this.selectedValues.add(s),this.selectedOptions.set(s,e)}}),this.renderDropdown(),this.renderBadges(),this.updateHiddenInput(),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}clearAll(){this.selectedValues.clear(),this.selectedOptions.clear(),this.renderDropdown(),this.renderBadges(),this.updateHiddenInput(),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}open(){f.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"),f.info(`[${this.instanceId}] Dropdown opened`),this.input.placeholder=this.options.searchPlaceholder,!this.options.isMultipleEnabled&&this.options.isSearchEnabled&&(this.input.value=""),this.options.searchCallback&&this.options.isKeepOptionsOnSearch&&!this.searchTerm&&(this.filteredOptions=[...this.allOptions],f.debug(`[${this.instanceId}] Showing ${this.allOptions.length} initial options on open`)),this.renderDropdown(),this.positionDropdown(),this.hint&&(this.hint.classList.add("ms__hint--visible"),this.positionHint()))}close(){if(f.debug(`[${this.instanceId}] close() called`,{isOpen:this.isOpen}),!this.isOpen)return;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.searchTerm="";const e=this.options.isMultipleEnabled||this.options.isSearchEnabled;f.warn(`[${this.instanceId}] close() - input clearing decision`,{multiple:this.options.isMultipleEnabled,enableSearch:this.options.isSearchEnabled,willClearInput:e,currentInputValue:this.input.value}),e?(f.info(`[${this.instanceId}] 🧹 close() CLEARING input.value`),this.input.value=""):f.info(`[${this.instanceId}] 🔒 close() KEEPING input.value = "${this.input.value}"`),this.filteredOptions=[...this.allOptions],this.focusedIndex=-1,f.info(`[${this.instanceId}] 📞 close() CALLING renderBadges()`),this.renderBadges(),f.info(`[${this.instanceId}] ✅ close() AFTER renderBadges(), input.value = "${this.input.value}"`),this.dropdownCleanup&&(this.dropdownCleanup(),this.dropdownCleanup=null),this.hintCleanup&&(this.hintCleanup(),this.hintCleanup=null),this.dropdownPlacement=null,f.info(`[${this.instanceId}] Dropdown closed. Stack trace:`),f.trace()}positionDropdown(){this.dropdownCleanup=Q(this.input,this.dropdown,()=>{const e=this.options.isPlacementLocked&&this.dropdownPlacement?this.dropdownPlacement:"bottom-start",t=[ee(4),...this.options.isPlacementLocked&&this.dropdownPlacement?[]:[ve()],te({padding:8})];se(this.input,this.dropdown,{placement:e,middleware:t}).then(({x:s,y:o,placement:n})=>{this.options.isPlacementLocked&&!this.dropdownPlacement&&(this.dropdownPlacement=n,f.debug(`[${this.instanceId}] Locked dropdown placement:`,n));const r={left:`${s}px`,top:`${o}px`,width:`${this.input.offsetWidth}px`};this.options.dropdownMinWidth&&(r.minWidth=this.options.dropdownMinWidth),Object.assign(this.dropdown.style,r),this.hint&&this.isOpen&&this.positionHint()})})}positionHint(){this.hint&&(this.hintCleanup&&this.hintCleanup(),this.hintCleanup=Q(this.input,this.hint,()=>{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"))),se(this.input,this.hint,{placement:e,middleware:[ee(4),te({padding:8})]}).then(({x:t,y:s})=>{Object.assign(this.hint.style,{left:`${t}px`,top:`${s}px`})})}))}parseInitialSelection(){const e=this.element.dataset.initialValues;if(e)try{JSON.parse(e).forEach(s=>{const o=String(s);this.selectedValues.add(o);const n=this.allOptions.find(r=>String(this.getItemValue(r))===o);n&&this.selectedOptions.set(o,n)}),this.renderBadges()}catch(t){k.error(`[${this.instanceId}] Failed to parse initial values:`,t)}}toggleSelectedPopover(){this.showSelectedPopover?this.hideSelectedPopover():this.showPopover()}showPopover(){f.debug(`[${this.instanceId}] showPopover() called`),this.isOpen&&this.close(),this.showSelectedPopover=!0,this.renderSelectedPopover(),this.selectedPopover.classList.add("ms__selected-popover--visible"),this.selectedValues.size>=100&&this.selectedPopover.classList.add("ms__selected-popover--virtual"),this.positionSelectedPopover()}hideSelectedPopover(){f.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)}renderSelectedPopover(){const e=Array.from(this.selectedOptions.values()),t=this.selectedValues.size;if(t>=100){this.renderSelectedPopoverVirtual(e,t);return}this.selectedPopover.innerHTML=`
|
|
27
|
+
<div class="ms__selected-popover-header">
|
|
28
28
|
<span>Selected Items (${t})</span>
|
|
29
|
-
<button type="button" class="
|
|
29
|
+
<button type="button" class="ms__selected-popover-close" aria-label="Close">×</button>
|
|
30
30
|
</div>
|
|
31
|
-
<div class="
|
|
32
|
-
${e.map(
|
|
31
|
+
<div class="ms__selected-popover-body">
|
|
32
|
+
${e.map(o=>this.renderBadgeForPopover(o)).join("")}
|
|
33
33
|
</div>
|
|
34
|
-
`}renderSelectedPopoverVirtual(e,t){if(this.selectedPopoverVirtualScroll){const
|
|
35
|
-
<div class="
|
|
34
|
+
`}renderSelectedPopoverVirtual(e,t){if(this.selectedPopoverVirtualScroll){const a=this.selectedPopover.querySelector(".ms__selected-popover-header span");a&&(a.textContent=`Selected Items (${t})`)}else{const a=this.options.badgeHeight??36,l=`
|
|
35
|
+
<div class="ms__selected-popover-header">
|
|
36
36
|
<span>Selected Items (${t})</span>
|
|
37
|
-
<button type="button" class="
|
|
37
|
+
<button type="button" class="ms__selected-popover-close" aria-label="Close">×</button>
|
|
38
38
|
</div>
|
|
39
|
-
<div class="
|
|
40
|
-
`;this.selectedPopover.innerHTML=
|
|
41
|
-
<div class="${
|
|
42
|
-
<span class="
|
|
43
|
-
<button type="button" class="
|
|
39
|
+
<div class="ms__selected-popover-body ms__selected-popover-body--virtual" style="height: 18rem; overflow-y: auto; position: relative; --ml-badge-height-virtual: ${a}px;"></div>
|
|
40
|
+
`;this.selectedPopover.innerHTML=l,this.selectedPopoverContainer=this.selectedPopover.querySelector(".ms__selected-popover-body")}if(!this.selectedPopoverContainer)return;const n=(this.options.badgeHeight??36)+4,r=this.options.virtualScrollBuffer??10;requestAnimationFrame(()=>{this.selectedPopoverContainer&&(this.selectedPopoverVirtualScroll?this.selectedPopoverVirtualScroll.setItems(e):this.selectedPopoverVirtualScroll=new lt({container:this.selectedPopoverContainer,itemHeight:n,items:e,renderItem:a=>this.renderBadgeForPopover(a),bufferSize:r}))})}renderBadgeForPopover(e){const t=this.getItemValue(e);let s;if(this.options.renderSelectedItemContentCallback){const r=this.options.renderSelectedItemContentCallback(e);s=typeof r=="string"?r:r.outerHTML}else if(this.options.renderBadgeContentCallback){const r={displayMode:this.options.badgesDisplayMode||"badges",isInPopover:!0},a=this.options.renderBadgeContentCallback(e,r);s=typeof a=="string"?a:a.outerHTML}else s=this.getItemBadgeDisplayValue(e);let o="ms__badge";const n=this.options.getSelectedItemClassCallback||this.options.getBadgeClassCallback;if(n){const r=n(e),a=Array.isArray(r)?r:[r];o+=" "+a.filter(l=>l).join(" ")}return`
|
|
41
|
+
<div class="${o}">
|
|
42
|
+
<span class="ms__badge-text">${s}</span>
|
|
43
|
+
<button type="button" class="ms__badge-remove" data-value="${t}" aria-label="Remove ${this.getItemBadgeDisplayValue(e)}"></button>
|
|
44
44
|
</div>
|
|
45
|
-
`}handleSelectedPopoverClick(e){if(e.stopPropagation(),e.target.closest(".
|
|
46
|
-
${u}`:p,f.debug(`[${this.instanceId}] Using default content: "${n}"`)}typeof n=="string"?s.textContent=n:s.appendChild(n),(this.options.container||document.body).appendChild(s),f.debug(`[${this.instanceId}] Tooltip element created and appended for "${i}"`),this.badgeTooltips.set(i,s);let r,a;const d=()=>{clearTimeout(a),f.debug(`[${this.instanceId}] Mouse entered badge "${i}", will show tooltip in ${this.options.badgeTooltipDelay||300}ms`),r=window.setTimeout(()=>{f.debug(`[${this.instanceId}] Showing tooltip for "${i}"`),s.classList.add("ml__badge-tooltip--visible"),this.positionBadgeTooltip(e,s,i)},this.options.badgeTooltipDelay||300)},c=()=>{clearTimeout(r),a=window.setTimeout(()=>{s.classList.remove("ml__badge-tooltip--visible"),this.cleanupBadgeTooltip(i)},100)};e.addEventListener("mouseenter",d),e.addEventListener("mouseleave",c)}createRemoveButtonTooltip(e,t,i){const s=document.createElement("div");s.className="ml__badge-tooltip",s.textContent=`Remove ${t}`,(this.options.container||document.body).appendChild(s);const l=`${i}-remove`;this.badgeTooltips.set(l,s);let r,a;const d=()=>{clearTimeout(a);const p=this.badgeTooltips.get(i);p&&p.classList.remove("ml__badge-tooltip--visible"),r=window.setTimeout(()=>{s.classList.add("ml__badge-tooltip--visible"),this.positionBadgeTooltip(e,s,l)},this.options.badgeTooltipDelay||300)},c=()=>{clearTimeout(r),a=window.setTimeout(()=>{s.classList.remove("ml__badge-tooltip--visible"),this.cleanupBadgeTooltip(l)},100)};e.addEventListener("mouseenter",d),e.addEventListener("mouseleave",c)}positionBadgeTooltip(e,t,i){const s=Q(e,t,()=>{ie(e,t,{placement:this.options.badgeTooltipPlacement||"top",strategy:"fixed",middleware:[ee(this.options.badgeTooltipOffset||8),ve(),te({padding:8})]}).then(({x:n,y:l})=>{Object.assign(t.style,{left:`${n}px`,top:`${l}px`}),f.debug(`[${this.instanceId}] Positioned tooltip "${i}" at x:${n}, y:${l}`,{placement:this.options.badgeTooltipPlacement||"top",tooltipClasses:t.className,tooltipDisplay:window.getComputedStyle(t).display,tooltipOpacity:window.getComputedStyle(t).opacity,tooltipVisibility:window.getComputedStyle(t).visibility,tooltipZIndex:window.getComputedStyle(t).zIndex,tooltipPosition:window.getComputedStyle(t).position})})});this.badgeTooltipCleanups.set(i,s)}cleanupBadgeTooltip(e){const t=this.badgeTooltipCleanups.get(e);t&&(t(),this.badgeTooltipCleanups.delete(e))}destroyAllBadgeTooltips(){this.badgeTooltipCleanups.forEach(e=>e()),this.badgeTooltipCleanups.clear(),this.badgeTooltips.forEach(e=>e.remove()),this.badgeTooltips.clear()}attachActionButtonTooltips(){const e=this.dropdown.querySelectorAll(".ml__action-btn");f.debug(`[${this.instanceId}] Found ${e.length} action buttons to attach tooltips to`),e.forEach(t=>{var a;const i=t,s=i.dataset.action;if(!s)return;const n=(a=this.options.actionButtons)==null?void 0:a.find(d=>d.action==="custom"?i.dataset.customAction===i.dataset.action:d.action===s);if(!n)return;let l;if(n.getTooltipCallback?(l=n.getTooltipCallback(this),f.debug(`[${this.instanceId}] Using getTooltipCallback for action button "${s}": "${l}"`)):(l=n.tooltip,f.debug(`[${this.instanceId}] Using static tooltip for action button "${s}": "${l}"`)),!l){f.debug(`[${this.instanceId}] No tooltip for action button "${s}"`);return}const r=`action-${s}-${Date.now()}`;this.createActionButtonTooltip(i,l,r)})}createActionButtonTooltip(e,t,i){const s=document.createElement("div");s.className="ml__badge-tooltip",s.textContent=t,(this.options.container||document.body).appendChild(s),f.debug(`[${this.instanceId}] Tooltip element created for action button "${i}"`),this.actionButtonTooltips.set(i,s);let l,r;const a=()=>{clearTimeout(r),f.debug(`[${this.instanceId}] Mouse entered action button "${i}", will show tooltip in ${this.options.badgeTooltipDelay||300}ms`),l=window.setTimeout(()=>{f.debug(`[${this.instanceId}] Showing tooltip for action button "${i}"`),s.classList.add("ml__badge-tooltip--visible"),this.positionActionButtonTooltip(e,s,i)},this.options.badgeTooltipDelay||300)},d=()=>{clearTimeout(l),r=window.setTimeout(()=>{s.classList.remove("ml__badge-tooltip--visible"),this.cleanupActionButtonTooltip(i)},100)};e.addEventListener("mouseenter",a),e.addEventListener("mouseleave",d)}positionActionButtonTooltip(e,t,i){const s=Q(e,t,()=>{ie(e,t,{placement:this.options.badgeTooltipPlacement||"top",strategy:"fixed",middleware:[ee(this.options.badgeTooltipOffset||8),ve(),te({padding:8})]}).then(({x:n,y:l})=>{Object.assign(t.style,{left:`${n}px`,top:`${l}px`}),f.debug(`[${this.instanceId}] Positioned action button tooltip "${i}" at x:${n}, y:${l}`)})});this.actionButtonTooltipCleanups.set(i,s)}cleanupActionButtonTooltip(e){const t=this.actionButtonTooltipCleanups.get(e);t&&(t(),this.actionButtonTooltipCleanups.delete(e))}destroyAllActionButtonTooltips(){this.actionButtonTooltipCleanups.forEach(e=>e()),this.actionButtonTooltipCleanups.clear(),this.actionButtonTooltips.forEach(e=>e.remove()),this.actionButtonTooltips.clear()}destroy(){this.destroyAllBadgeTooltips(),this.destroyAllActionButtonTooltips(),this.dropdownCleanup&&this.dropdownCleanup(),this.hintCleanup&&this.hintCleanup(),this.selectedPopoverCleanup&&this.selectedPopoverCleanup(),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("ml","ml--open","ml--no-checkboxes"),ne.info(`[${this.instanceId}] Component destroyed`)}}const mi='@charset "UTF-8";:host{--ml-accent-color: #3b82f6;--ml-accent-color-hover: #2563eb;--ml-accent-color-active: #1d4ed8;--ml-text-primary: #111827;--ml-text-secondary: #6b7280;--ml-text-white: #ffffff;--ml-primary-bg: #f3f4f6;--ml-primary-bg-hover: #e5e7eb;--ml-border-color: #e5e7eb;--ml-input-padding: .5rem .75rem;--ml-input-padding-right: 2.5rem;--ml-input-font-size: .875rem;--ml-input-border-style: 1px solid #d1d5db;--ml-input-border-radius: .375rem;--ml-input-bg: #ffffff;--ml-input-text: #111827;--ml-input-focus-border-color: #3b82f6;--ml-input-placeholder-color: #6b7280;--ml-input-bg-disabled: rgba(107, 114, 128, .05);--ml-toggle-right: .75rem;--ml-toggle-color: #6b7280;--ml-transform-center-y: translateY(-50%);--ml-transform-rotate-180: 180deg;--ml-counter-offset: 2rem;--ml-counter-padding: .125rem .25rem;--ml-counter-bg: #3b82f6;--ml-counter-color: #ffffff;--ml-counter-font-size: .75rem;--ml-counter-font-weight: 600;--ml-counter-border-radius: .25rem;--ml-counter-bg-hover: #2563eb;--ml-transform-scale-hover: 1.1;--ml-hint-padding: .5rem .75rem;--ml-hint-bg: #ffffff;--ml-hint-border: 1px solid #e5e7eb;--ml-hint-border-radius: .375rem;--ml-hint-box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1);--ml-hint-font-size: .75rem;--ml-hint-color: #6b7280;--ml-line-height-relaxed: 1.4;--ml-dropdown-bg: #ffffff;--ml-dropdown-border: 1px solid #e5e7eb;--ml-dropdown-border-radius: .375rem;--ml-dropdown-box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1);--ml-options-max-height: 20rem;--ml-option-color: #111827;--ml-z-index-dropdown: 9999;--ml-z-index-sticky: 1;--ml-actions-gap: .25rem;--ml-actions-padding: .5rem;--ml-actions-border-bottom: 1px solid #e5e7eb;--ml-actions-bg: #ffffff;--ml-action-btn-padding: .25rem .5rem;--ml-action-btn-font-size: .75rem;--ml-action-btn-border: 1px solid #e5e7eb;--ml-action-btn-border-radius: .25rem;--ml-action-btn-bg: transparent;--ml-action-btn-color: inherit;--ml-action-btn-bg-hover: #f3f4f6;--ml-action-btn-border-color-hover: #3b82f6;--ml-transform-scale-active: .98;--ml-options-padding: .25rem 0;--ml-group-border-top: 1px solid #e5e7eb;--ml-group-margin-top: .25rem;--ml-group-padding-top: .25rem;--ml-group-label-padding: .25rem .75rem;--ml-group-label-font-size: .75rem;--ml-group-label-font-weight: 600;--ml-group-label-color: #6b7280;--ml-group-label-transform: uppercase;--ml-group-label-letter-spacing: .05em;--ml-option-gap: .5rem;--ml-option-padding: .5rem .75rem;--ml-option-padding-h: .75rem;--ml-option-bg: transparent;--ml-option-bg-hover: #f9fafb;--ml-option-bg-focused: #f9fafb;--ml-option-outline-focused: 2px solid #3b82f6;--ml-option-focus-outline-offset: -2px;--ml-option-bg-matched: rgba(59, 130, 246, .08);--ml-option-border-matched: 3px solid rgba(59, 130, 246, .4);--ml-option-bg-selected: rgba(59, 130, 246, .1);--ml-disabled-opacity: .5;--ml-option-content-gap: .5rem;--ml-option-icon-size: 1.25rem;--ml-option-icon-font-size: 1rem;--ml-option-title-font-size: .875rem;--ml-option-title-color: inherit;--ml-option-mark-bg: rgba(59, 130, 246, .2);--ml-option-mark-color: inherit;--ml-option-mark-font-weight: 600;--ml-option-subtitle-margin-top: .25rem;--ml-option-subtitle-font-size: .75rem;--ml-option-subtitle-color: #6b7280;--ml-option-subtitle-line-height: 1.3;--ml-checkbox-margin-top: .125rem;--ml-checkbox-size: 16px;--ml-checkbox-scale: 1;--ml-checkbox-align: flex-start;--ml-empty-padding: 1rem .75rem;--ml-empty-font-size: .875rem;--ml-empty-color: #6b7280;--ml-loader-padding: 1rem;--ml-loader-gap: .5rem;--ml-loading-text-font-size: .875rem;--ml-loading-text-color: #6b7280;--ml-badges-gap: .5rem;--ml-badges-margin-bottom: .5rem;--ml-badges-margin-top: .5rem;--ml-badges-margin-left: .25rem;--ml-badges-margin-right: .25rem;--ml-badge-gap: .5rem;--ml-badge-height: 1.5rem;--ml-badge-font-size: .75rem;--ml-badge-font-weight: 600;--ml-badge-border-radius: .375rem;--ml-badge-bg: #eff6ff;--ml-badge-bg-hover: #ffffff;--ml-badge-bg-active: #e0f2fe;--ml-order-first: -1;--ml-badge-text-padding: 0 .5rem;--ml-badge-text-bg: #eff6ff;--ml-badge-text-color: #3b82f6;--ml-badge-remove-width: 1.5rem;--ml-badge-remove-bg: #3b82f6;--ml-badge-remove-color: #ffffff;--ml-badge-remove-border: none;--ml-badge-remove-font-size: .75rem;--ml-badge-remove-bg-hover: #2563eb;--ml-badge-remove-box-shadow-focus: 0 0 0 2px rgba(59, 130, 246, .5);--ml-icon-remove: "×";--ml-badge-counter-bg: transparent;--ml-badge-counter-border: 1px solid #e5e7eb;--ml-badge-counter-border-radius: .25rem;--ml-badge-counter-text-color: #6b7280;--ml-badge-counter-text-bg: #d1d5db;--ml-badge-counter-remove-bg: #6b7280;--ml-badge-counter-remove-color: #ffffff;--ml-badge-counter-remove-bg-hover: #111827;--ml-more-badge-bg: #eff6ff;--ml-more-badge-hover-bg: #ffffff;--ml-more-badge-active-bg: #e0f2fe;--ml-count-display-margin-bottom: .5rem;--ml-count-display-margin-top: .5rem;--ml-count-display-margin-left: .5rem;--ml-count-display-margin-right: .5rem;--ml-counter-wrapper-bg: transparent;--ml-counter-wrapper-border: 1px solid #e5e7eb;--ml-counter-wrapper-border-radius: .25rem;--ml-counter-wrapper-padding: .25rem .5rem;--ml-counter-wrapper-gap: .25rem;--ml-counter-wrapper-bg-hover: #f9fafb;--ml-counter-wrapper-border-color-hover: #3b82f6;--ml-count-text-bg: transparent;--ml-count-text-border: none;--ml-count-text-font-size: .875rem;--ml-count-text-color: #111827;--ml-count-clear-size: 1rem;--ml-count-clear-bg: transparent;--ml-count-clear-color: #6b7280;--ml-count-clear-font-size: 1.125rem;--ml-count-clear-border-radius: 50%;--ml-count-clear-bg-hover: rgba(59, 130, 246, .2);--ml-count-clear-color-hover: #3b82f6;--ml-icon-clear: "×";--ml-tooltip-bg: #333;--ml-tooltip-color: #fff;--ml-tooltip-padding: .5rem .75rem;--ml-tooltip-border-radius: .375rem;--ml-tooltip-font-size: .875rem;--ml-tooltip-max-width: 20rem;--ml-tooltip-shadow: 0 2px 8px rgba(0, 0, 0, .15);--ml-tooltip-z-index: 10000;--ml-z-index-popover: 10000;--ml-selected-popover-width: 20rem;--ml-selected-popover-max-height: 20rem;--ml-selected-popover-bg: #ffffff;--ml-selected-popover-border: 1px solid #e5e7eb;--ml-selected-popover-border-radius: .375rem;--ml-selected-popover-box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1);--ml-selected-popover-header-padding: .5rem .75rem;--ml-selected-popover-header-bg: rgba(59, 130, 246, .1);--ml-selected-popover-header-border-bottom: 1px solid #e5e7eb;--ml-selected-popover-header-font-size: .875rem;--ml-selected-popover-header-font-weight: 600;--ml-selected-popover-header-color: #111827;--ml-popover-close-size: 1.5rem;--ml-selected-popover-close-bg: transparent;--ml-selected-popover-close-color: #6b7280;--ml-selected-popover-close-font-size: 1.25rem;--ml-selected-popover-close-border-radius: 50%;--ml-selected-popover-close-bg-hover: rgba(59, 130, 246, .2);--ml-selected-popover-close-color-hover: #3b82f6;--ml-selected-popover-body-gap: .25rem;--ml-selected-popover-body-padding: .5rem;--ml-selected-popover-body-max-height: 18rem;--ml-font-size-2xs: .625rem;--ml-font-size-xs: .75rem;--ml-font-size-sm: .875rem;--ml-font-size-base: 1rem;--ml-font-size-lg: 1.125rem;--ml-font-weight-medium: 500;--ml-font-weight-semibold: 600;--ml-line-height-none: 1;--ml-spacing-xs: .25rem;--ml-spacing-sm: .5rem;--ml-spacing-md: .75rem;--ml-spacing-lg: 1rem;--ml-transition-fast: .15s;--ml-transition-normal: .2s;--ml-easing-snappy: cubic-bezier(.4, 0, .2, 1);--ml-placeholder-opacity: .6;--ml-disabled-input-opacity: .6}multi-select:not(:defined){display:block;min-height:2.5rem;color:transparent!important;background:transparent}.ml-wrapper{display:flex;flex-direction:column;align-items:stretch}.ml-wrapper--inline{flex-direction:row;align-items:flex-start}.ml{position:relative;width:100%}.ml__input-wrapper{position:relative;display:flex;align-items:center}.ml__input{width:100%;padding:var(--ml-input-padding, .5rem .75rem);padding-right:var(--ml-input-padding-right, 2.5rem);font-size:var(--ml-input-font-size, .875rem);border:var(--ml-input-border-style, 1px solid #d1d5db);border-radius:var(--ml-input-border-radius, .375rem);background:var(--ml-input-bg, #ffffff);color:var(--ml-input-text, #111827);cursor:pointer;transition:border-color var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__input:focus{outline:none;border-color:var(--ml-input-focus-border-color, #3b82f6)}.ml__input::placeholder{color:var(--ml-input-placeholder-color, #6b7280);opacity:0;transition:opacity var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}:host([data-ready]) .ml__input::placeholder{opacity:var(--ml-placeholder-opacity, .6)}.ml__toggle{position:absolute;right:var(--ml-toggle-right, .75rem);top:50%;transform:var(--ml-transform-center-y, translateY(-50%));pointer-events:none;color:var(--ml-toggle-color, #6b7280);transition:transform var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml--open .ml__toggle{transform:var(--ml-transform-center-y, translateY(-50%)) rotate(var(--ml-transform-rotate-180, 180deg))}.ml__counter{position:absolute;right:var(--ml-counter-offset, 2rem);top:50%;transform:var(--ml-transform-center-y, translateY(-50%));padding:var(--ml-counter-padding, .125rem .25rem);background:var(--ml-counter-bg, #3b82f6);color:var(--ml-counter-color, #ffffff);font-size:var(--ml-counter-font-size, .75rem);font-weight:var(--ml-counter-font-weight, 600);border-radius:var(--ml-counter-border-radius, .25rem);cursor:pointer;transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__counter:hover{background:var(--ml-counter-bg-hover, #2563eb);transform:var(--ml-transform-center-y, translateY(-50%)) scale(var(--ml-transform-scale-hover, 1.1))}.ml__hint{display:none;position:absolute;z-index:var(--ml-z-index-popover, 10000);padding:var(--ml-hint-padding, .5rem .75rem);background:var(--ml-hint-bg, #ffffff);border:var(--ml-hint-border, 1px solid #e5e7eb);border-radius:var(--ml-hint-border-radius, .375rem);box-shadow:var(--ml-hint-box-shadow, 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1));font-size:var(--ml-hint-font-size, .75rem);color:var(--ml-hint-color, #6b7280);line-height:var(--ml-line-height-relaxed, 1.4);max-width:100%}.ml__hint--visible{display:block}.ml__dropdown{display:none;position:absolute;z-index:var(--ml-z-index-dropdown, 9999);background:var(--ml-dropdown-bg, #ffffff);border:var(--ml-dropdown-border, 1px solid #e5e7eb);border-radius:var(--ml-dropdown-border-radius, .375rem);box-shadow:var(--ml-dropdown-box-shadow, 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1));max-height:var(--ml-options-max-height, 20rem);overflow-y:auto;overscroll-behavior:contain;touch-action:pan-y;-webkit-overflow-scrolling:touch;color:var(--ml-option-color, #111827)}.ml__dropdown--visible{display:block}.ml__dropdown--virtual{overflow-y:visible;max-height:none}.ml__actions{display:flex;flex-wrap:nowrap;gap:var(--ml-actions-gap, .25rem);padding:var(--ml-actions-padding, .5rem);border-bottom:var(--ml-actions-border-bottom, 1px solid #e5e7eb)}.ml__actions--wrap{flex-wrap:wrap}.ml__actions--sticky{position:sticky;top:0;z-index:var(--ml-z-index-sticky, 1);background:var(--ml-actions-bg, #ffffff)}.ml__action-btn{flex:1;padding:var(--ml-action-btn-padding, .25rem .5rem);font-size:var(--ml-action-btn-font-size, .75rem);border:var(--ml-action-btn-border, 1px solid #e5e7eb);border-radius:var(--ml-action-btn-border-radius, .25rem);background:var(--ml-action-btn-bg, transparent);color:var(--ml-action-btn-color, inherit);cursor:pointer;transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__action-btn:hover{background:var(--ml-action-btn-bg-hover, #f3f4f6);border-color:var(--ml-action-btn-border-color-hover, #3b82f6)}.ml__action-btn:active{transform:scale(var(--ml-transform-scale-active, .98))}.ml__action-btn:disabled,.ml__action-btn[disabled]{opacity:var(--ml-disabled-opacity, .5);cursor:not-allowed;pointer-events:none}.ml__options{padding:var(--ml-options-padding, .25rem 0)}.ml__options--virtual .ml__option{height:var(--ml-option-height, 50px);min-height:var(--ml-option-height, 50px);max-height:var(--ml-option-height, 50px);overflow:hidden;box-sizing:border-box}.ml__group+.ml__group{border-top:var(--ml-group-border-top, 1px solid #e5e7eb);margin-top:var(--ml-group-margin-top, .25rem);padding-top:var(--ml-group-padding-top, .25rem)}.ml__group-label{padding:var(--ml-group-label-padding, .25rem .75rem);font-size:var(--ml-group-label-font-size, .75rem);font-weight:var(--ml-group-label-font-weight, 600);color:var(--ml-group-label-color, #6b7280);text-transform:var(--ml-group-label-transform, uppercase);letter-spacing:var(--ml-group-label-letter-spacing, .05em)}.ml__option{display:flex;align-items:var(--ml-checkbox-align, flex-start);gap:var(--ml-option-gap, .5rem);padding:var(--ml-option-padding, .5rem .75rem);cursor:pointer;transition:background-color var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__option:hover{background:var(--ml-option-bg-hover, #f9fafb)}.ml__option--focused{background:var(--ml-option-bg-focused, #f9fafb);outline:var(--ml-option-outline-focused, 2px solid #3b82f6);outline-offset:var(--ml-option-focus-outline-offset, -2px)}.ml__option--matched{background:var(--ml-option-bg-matched, rgba(59, 130, 246, .08));border-left:var(--ml-option-border-matched, 3px solid rgba(59, 130, 246, .4))}.ml__option--selected{background:var(--ml-option-bg-selected, rgba(59, 130, 246, .1))}.ml__option--selected:hover{background:var(--ml-option-bg-selected-hover, var(--ml-option-bg-selected, rgba(59, 130, 246, .1)))}.ml__option--disabled{opacity:var(--ml-disabled-opacity, .5);cursor:not-allowed}.ml__option--disabled:hover{background:var(--ml-option-bg, transparent)}.ml__option[data-checkbox-align=center]{--ml-checkbox-align: center}.ml__option[data-checkbox-align=bottom]{--ml-checkbox-align: flex-end}.ml__checkbox{flex-shrink:0;margin-top:var(--ml-checkbox-margin-top, .125rem);width:var(--ml-checkbox-size, 16px);height:var(--ml-checkbox-size, 16px);transform:scale(var(--ml-checkbox-scale, 1));transform-origin:top left;cursor:pointer}.ml__option--disabled .ml__checkbox{cursor:not-allowed}.ml__option-content{flex:1;display:flex;align-items:flex-start;gap:var(--ml-option-content-gap, .5rem);min-width:0}.ml__option-icon{flex-shrink:0;width:var(--ml-option-icon-size, 1.25rem);height:var(--ml-option-icon-size, 1.25rem);display:flex;align-items:center;justify-content:center;font-size:var(--ml-option-icon-font-size, 1rem)}.ml__option-icon svg{width:100%;height:100%;fill:currentColor}.ml__option-text{flex:1;min-width:0}.ml__option-title{font-size:var(--ml-option-title-font-size, .875rem);color:var(--ml-option-title-color, inherit);line-height:var(--ml-line-height-relaxed, 1.4)}.ml__option-title mark{background:var(--ml-option-mark-bg, rgba(59, 130, 246, .2));color:var(--ml-option-mark-color, inherit);font-weight:var(--ml-option-mark-font-weight, 600)}.ml__option-subtitle{margin-top:var(--ml-option-subtitle-margin-top, .25rem);font-size:var(--ml-option-subtitle-font-size, .75rem);color:var(--ml-option-subtitle-color, #6b7280);line-height:var(--ml-option-subtitle-line-height, 1.3)}.ml__empty{padding:var(--ml-empty-padding, 1rem .75rem);text-align:center;font-size:var(--ml-empty-font-size, .875rem);color:var(--ml-empty-color, #6b7280)}.ml__loader{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--ml-loader-padding, 1rem);gap:var(--ml-loader-gap, .5rem)}.ml__loading-text{font-size:var(--ml-loading-text-font-size, .875rem);color:var(--ml-loading-text-color, #6b7280)}.ml__badges{display:flex;flex-wrap:wrap;gap:var(--ml-badges-gap, .5rem);padding:0}.ml__badges:empty{display:none}.ml__badges--bottom{margin-top:var(--ml-badges-margin-bottom, .5rem)}.ml__badges--top{margin-bottom:var(--ml-badges-margin-top, .5rem);order:var(--ml-order-first, -1)}.ml__badges--left{order:var(--ml-order-first, -1);margin-right:var(--ml-badges-margin-left, .25rem);justify-content:flex-end}.ml__badges--right{margin-left:var(--ml-badges-margin-right, .25rem);justify-content:flex-start}.ml__count-display{display:flex;align-items:center}.ml__count-display:empty{display:none}.ml__count-display--bottom{margin-top:var(--ml-count-display-margin-bottom, .5rem)}.ml__count-display--top{margin-bottom:var(--ml-count-display-margin-top, .5rem);order:var(--ml-order-first, -1)}.ml__count-display--left{order:var(--ml-order-first, -1);margin-right:var(--ml-count-display-margin-left, .5rem);justify-content:flex-start}.ml__count-display--right{margin-left:var(--ml-count-display-margin-right, .5rem);justify-content:flex-end}.ml__counter-wrapper{display:inline-flex;align-items:center;gap:var(--ml-counter-wrapper-gap, .25rem);background:var(--ml-counter-wrapper-bg, transparent);border:var(--ml-counter-wrapper-border, 1px solid #e5e7eb);border-radius:var(--ml-counter-wrapper-border-radius, .25rem);padding:var(--ml-counter-wrapper-padding, .25rem .5rem);transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__counter-wrapper:hover{background:var(--ml-counter-wrapper-bg-hover, #f9fafb);border-color:var(--ml-counter-wrapper-border-color-hover, #3b82f6)}.ml__count-text{display:inline-flex;align-items:center;background:var(--ml-count-text-bg, transparent);border:var(--ml-count-text-border, none);padding:0;font-size:var(--ml-count-text-font-size, .875rem);color:var(--ml-count-text-color, #111827);cursor:pointer;transition:color var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-clear{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:var(--ml-count-clear-size, 1rem);height:var(--ml-count-clear-size, 1rem);padding:0;border:none;background:var(--ml-count-clear-bg, transparent);color:var(--ml-count-clear-color, #6b7280);font-size:var(--ml-count-clear-font-size, 1.125rem);line-height:var(--ml-line-height-none, 1);cursor:pointer;border-radius:var(--ml-count-clear-border-radius, 50%);transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-clear:hover{background:var(--ml-count-clear-bg-hover, rgba(59, 130, 246, .2));color:var(--ml-count-clear-color-hover, #3b82f6)}.ml__count-clear:before{content:var(--ml-icon-clear, "×")}.ml__badge{display:inline-flex;align-items:center;height:var(--ml-badge-height, 1.5rem);font-size:var(--ml-badge-font-size, .75rem);font-weight:var(--ml-badge-font-weight, 600);line-height:var(--ml-line-height-none, 1);border-radius:var(--ml-badge-border-radius, .375rem);overflow:hidden;max-width:100%}.ml__badge-text{display:flex;align-items:center;height:100%;padding:var(--ml-badge-text-padding, 0 .5rem);background:var(--ml-badge-text-bg, #eff6ff);color:var(--ml-badge-text-color, #3b82f6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:background-color var(--ml-transition-normal, .2s) ease}.ml__badge-remove{display:flex;align-items:center;justify-content:center;width:var(--ml-badge-remove-width, 1.5rem);height:100%;flex-shrink:0;background:var(--ml-badge-remove-bg, #3b82f6);color:var(--ml-badge-remove-color, #ffffff);border:var(--ml-badge-remove-border, none);cursor:pointer;transition:background-color var(--ml-transition-normal, .2s) ease;font-size:var(--ml-badge-remove-font-size, .75rem)}.ml__badge-remove:hover{background:var(--ml-badge-remove-bg-hover, #2563eb)}.ml__badge-remove:focus{outline:none;box-shadow:var(--ml-badge-remove-box-shadow-focus, 0 0 0 2px rgba(59, 130, 246, .5))}.ml__badge-remove:before{content:var(--ml-icon-remove, "×");font-size:var(--ml-font-size-base, 1rem);line-height:var(--ml-line-height-none, 1)}.ml__badge--counter{border:var(--ml-badge-counter-border, 1px solid #e5e7eb);cursor:pointer}.ml__badge--counter .ml__badge-text{background:var(--ml-badge-counter-text-bg, #d1d5db);color:var(--ml-badge-counter-text-color, #6b7280)}.ml__badge--counter .ml__badge-remove{background:var(--ml-badge-counter-remove-bg, #6b7280);color:var(--ml-badge-counter-remove-color, #ffffff)}.ml__badge--counter .ml__badge-remove:hover{background:var(--ml-badge-counter-remove-bg-hover, #111827)}.ml__badge--more{cursor:pointer}.ml__badge-tooltip{position:fixed;z-index:var(--ml-tooltip-z-index, 10000);opacity:0;visibility:hidden;transition:opacity var(--ml-transition-normal, .2s) ease,visibility var(--ml-transition-normal, .2s) ease;background:var(--ml-tooltip-bg, #333);color:var(--ml-tooltip-color, #fff);padding:var(--ml-tooltip-padding, .5rem .75rem);border-radius:var(--ml-tooltip-border-radius, .375rem);font-size:var(--ml-tooltip-font-size, .875rem);line-height:var(--ml-line-height-relaxed, 1.4);max-width:var(--ml-tooltip-max-width, 20rem);word-wrap:break-word;white-space:pre-wrap;box-shadow:var(--ml-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, .15));pointer-events:none}.ml__badge-tooltip--visible{opacity:1;visibility:visible}.ml__selected-popover{display:none;position:absolute;z-index:var(--ml-z-index-popover, 10000);background:var(--ml-selected-popover-bg, #ffffff);border:var(--ml-selected-popover-border, 1px solid #e5e7eb);border-radius:var(--ml-selected-popover-border-radius, .375rem);box-shadow:var(--ml-selected-popover-box-shadow, 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1));width:var(--ml-selected-popover-width, 20rem);max-height:var(--ml-selected-popover-max-height, 20rem);overflow:hidden}.ml__selected-popover--visible{display:flex;flex-direction:column}.ml__selected-popover--virtual{display:block;overflow:visible;max-height:none}.ml__selected-popover-header{display:flex;align-items:center;justify-content:space-between;padding:var(--ml-selected-popover-header-padding, .5rem .75rem);background:var(--ml-selected-popover-header-bg, rgba(59, 130, 246, .1));border-bottom:var(--ml-selected-popover-header-border-bottom, 1px solid #e5e7eb);font-size:var(--ml-selected-popover-header-font-size, .875rem);font-weight:var(--ml-selected-popover-header-font-weight, 600);color:var(--ml-selected-popover-header-color, #111827)}.ml__selected-popover-close{display:flex;align-items:center;justify-content:center;width:var(--ml-popover-close-size, 1.5rem);height:var(--ml-popover-close-size, 1.5rem);padding:0;border:none;background:var(--ml-selected-popover-close-bg, transparent);color:var(--ml-selected-popover-close-color, #6b7280);font-size:var(--ml-selected-popover-close-font-size, 1.25rem);line-height:var(--ml-line-height-none, 1);cursor:pointer;border-radius:var(--ml-selected-popover-close-border-radius, 50%);transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__selected-popover-close:hover{background:var(--ml-selected-popover-close-bg-hover, rgba(59, 130, 246, .2));color:var(--ml-selected-popover-close-color-hover, #3b82f6)}.ml__selected-popover-body{display:flex;flex-direction:column;gap:var(--ml-selected-popover-body-gap, .25rem);padding:var(--ml-selected-popover-body-padding, .5rem);overflow-y:auto;max-height:var(--ml-selected-popover-body-max-height, 18rem)}.ml__selected-popover-body .ml__badge{width:100%;min-height:fit-content;line-height:var(--ml-line-height-relaxed, 1.4)}.ml__selected-popover-body .ml__badge-text{flex:1;min-width:0;white-space:normal;word-wrap:break-word}.ml__selected-popover-body--virtual{display:block;max-height:none;padding:0}.ml__selected-popover-body--virtual .ml__badge{height:var(--ml-badge-height-virtual, 36px);min-height:var(--ml-badge-height-virtual, 36px);max-height:var(--ml-badge-height-virtual, 36px);margin-bottom:var(--ml-selected-popover-body-gap, .25rem);overflow:hidden;box-sizing:border-box}.ml__selected-popover-body--virtual .ml__badge-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ml--rtl .ml__input-wrapper{direction:rtl}.ml--rtl .ml__input{text-align:right;padding-left:var(--ml-input-padding-right, 2.5rem);padding-right:var(--ml-input-padding-h, .75rem)}.ml--rtl .ml__toggle{left:var(--ml-toggle-right, .75rem)!important;right:auto!important}.ml--rtl .ml__counter{left:var(--ml-counter-offset, 2rem)!important;right:auto!important}.ml--rtl .ml__dropdown{direction:rtl;text-align:right}.ml--rtl .ml__option{flex-direction:row-reverse}.ml--rtl .ml__checkbox{margin-left:var(--ml-spacing-sm, .5rem);margin-right:0}.ml--rtl .ml__option-content{text-align:right}.ml--rtl .ml__option-icon{margin-left:var(--ml-spacing-xs, .25rem);margin-right:0}.ml--rtl .ml__badges{direction:rtl}.ml--rtl .ml__badge{flex-direction:row-reverse}.ml--rtl .ml__badge-remove{border-radius:var(--ml-badge-remove-border-radius-rtl, .375rem) 0 0 var(--ml-badge-remove-border-radius-rtl, .375rem);border-left:var(--ml-badge-remove-border, none);border-right:none}.ml--rtl .ml__badge-text{border-radius:0 var(--ml-badge-text-border-radius-rtl, .375rem) var(--ml-badge-text-border-radius-rtl, .375rem) 0}.ml--rtl .ml__count-display{direction:rtl}.ml--rtl .ml__counter-wrapper{flex-direction:row-reverse}.ml--rtl .ml__selected-popover{direction:rtl;text-align:right}.ml--rtl .ml__actions{direction:rtl}.ml--rtl .ml__group-label,.ml--rtl .ml__empty{text-align:right}.ml--rtl .ml__hint{direction:rtl;text-align:right}.ml--xs .ml__input{font-size:var(--ml-font-size-xs, .75rem)}.ml--xs .ml__option{padding:var(--ml-spacing-xs, .25rem) var(--ml-spacing-sm, .5rem)}.ml--xs .ml__option-title{font-size:var(--ml-font-size-xs, .75rem)}.ml--xs .ml__badge{font-size:var(--ml-font-size-2xs, .625rem)}.ml--sm .ml__input,.ml--sm .ml__option-title{font-size:var(--ml-font-size-xs, .75rem)}.ml--lg .ml__input,.ml--lg .ml__option-title{font-size:var(--ml-font-size-base, 1rem)}.ml--lg .ml__badge{font-size:var(--ml-font-size-sm, .875rem)}.ml--xl .ml__input,.ml--xl .ml__option-title{font-size:var(--ml-font-size-lg, 1.125rem)}.ml--xl .ml__badge{font-size:var(--ml-font-size-base, 1rem)}.ml--disabled .ml__input{opacity:var(--ml-disabled-input-opacity, .6);cursor:not-allowed;background:var(--ml-input-bg-disabled, rgba(107, 114, 128, .05))}.ml--disabled .ml__toggle{opacity:var(--ml-disabled-input-opacity, .6)}.ml--no-checkboxes .ml__option{gap:0;padding-left:var(--ml-option-padding-h, .75rem)}.ml--no-checkboxes .ml__option-content{padding-left:0}.ml-debug-info{margin-top:.25rem;padding:.25rem;background-color:#f9fafb;border:1px solid #e5e7eb;border-radius:.375rem;font-size:.75rem;color:#111827}.ml-debug-info details summary{cursor:pointer;font-weight:600;color:#2563eb;-webkit-user-select:none;user-select:none;padding:.25rem;border-radius:.25rem}.ml-debug-info details summary:hover{background-color:#f3f4f6}.ml-debug-info details summary:focus{outline:2px solid #3b82f6;outline-offset:2px}.ml-debug-info .ml-debug-stats{display:flex;flex-direction:column;gap:.25rem;margin-top:.25rem;padding:.25rem;background-color:#fff;border-radius:.25rem}.ml-debug-info .ml-debug-stats span{display:flex;justify-content:space-between;padding:2px 4px;font-family:monospace;font-size:.625rem}.ml-debug-info .ml-debug-stats span:before{content:"•";margin-right:.25rem;color:#3b82f6}',ui=typeof HTMLElement<"u"?HTMLElement:class{},Ae=new Set;function dt(){return Array.from(Ae)}class Te extends ui{constructor(){super();m(this,"picker");m(this,"containerElement");m(this,"shadow");m(this,"_options");m(this,"_valueMember");m(this,"_getValueCallback");m(this,"_displayValueMember");m(this,"_getDisplayValueCallback");m(this,"_getBadgeDisplayCallback");m(this,"_getBadgeClassCallback");m(this,"_customStylesCallback");m(this,"_searchValueMember");m(this,"_getSearchValueCallback");m(this,"_iconMember");m(this,"_getIconCallback");m(this,"_subtitleMember");m(this,"_getSubtitleCallback");m(this,"_groupMember");m(this,"_getGroupCallback");m(this,"_disabledMember");m(this,"_getDisabledCallback");m(this,"_getValueFormatCallback");m(this,"_getBadgeTooltipCallback");m(this,"_renderOptionContentCallback");m(this,"_renderBadgeContentCallback");m(this,"_renderSelectedItemContentCallback");m(this,"_getSelectedItemClassCallback");m(this,"_renderSelectedContentCallback");m(this,"_getCounterCallback");m(this,"_actionButtons");m(this,"_beforeSearchCallback");m(this,"_searchCallback");m(this,"_addNewCallback");m(this,"_selectCallback");m(this,"_deselectCallback");m(this,"_changeCallback");m(this,"_declarativeSelectedValues");this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=mi,this.shadow.appendChild(t),requestAnimationFrame(()=>{this.setAttribute("data-ready","")})}static get observedAttributes(){return["search-hint","search-placeholder","multiple","allow-groups","show-checkboxes","sticky-actions","close-on-select","lock-placement","dropdown-min-width","badges-display-mode","badges-threshold","badges-max-visible","badges-threshold-mode","badges-position","show-counter","keep-options-on-search","max-height","empty-message","loading-message","min-search-length","enable-search","search-input-mode","search-mode","actions-layout","allow-add-new","initial-values","enable-virtual-scroll","virtual-scroll-threshold","option-height","badge-height","virtual-scroll-buffer","value-member","display-value-member","search-value-member","icon-member","subtitle-member","group-member","disabled-member","name","value-format","enable-badge-tooltips","badge-tooltip-placement","show-debug-info"]}connectedCallback(){Ae.add(this),this.render();const t=this.parseDeclarativeOptions();t&&(this._options&&this._options.length>0&&k.warn("[MultiSelectElement] Both declarative <option> elements and programmatic .options detected. Using declarative options."),this._options=t),this.initializePicker()}disconnectedCallback(){Ae.delete(this),this.picker&&this.picker.destroy()}attributeChangedCallback(t,i,s){i!==s&&this.picker&&t!=="initial-values"&&(this.picker.destroy(),this.initializePicker())}render(){this.containerElement=document.createElement("div"),this.containerElement.setAttribute("data-multiselect",""),this.className&&(this.containerElement.className=this.className),this.shadow.appendChild(this.containerElement),this.getAttribute("show-debug-info")==="true"&&this.renderDebugInfo()}renderDebugInfo(){const t=this.shadow.querySelector(".ml-debug-info");t&&t.remove();const i=document.createElement("div");i.className="ml-debug-info";const s=document.createElement("details"),n=document.createElement("summary");n.textContent="Debug Info";const l=document.createElement("div");l.className="ml-debug-stats",s.appendChild(n),s.appendChild(l),i.appendChild(s),this.shadow.appendChild(i),this.updateDebugInfo()}updateDebugInfo(){var h,g;const t=this.shadow.querySelector(".ml-debug-stats");if(!t||!this.picker)return;const i="1.0.0",s=dt().length,l=this.picker.getSelected().length,r=((h=this._options)==null?void 0:h.length)||0,a=this.picker,d=a.isOpen||!1,c=a.searchTerm||"",p=a.isLoading||!1,u=((g=a.filteredOptions)==null?void 0:g.length)||0;t.innerHTML=`
|
|
47
|
-
<span>Version: ${
|
|
48
|
-
<span>Total Instances: ${
|
|
49
|
-
<span>Options: ${
|
|
45
|
+
`}handleSelectedPopoverClick(e){if(e.stopPropagation(),e.target.closest(".ms__selected-popover-close")){e.preventDefault(),this.hideSelectedPopover();return}const s=e.target.closest(".ms__badge-remove");if(s){e.preventDefault();const o=s.dataset.value,n=this.selectedOptions.get(o);n&&(this.deselectOption(n),this.renderSelectedPopover(),this.selectedValues.size===0&&this.hideSelectedPopover())}}positionSelectedPopover(){this.selectedPopoverCleanup=Q(this.input,this.selectedPopover,()=>{const e=this.selectedPopoverPlacement||"bottom-start";se(this.input,this.selectedPopover,{placement:e,middleware:[ee(4),...this.selectedPopoverPlacement?[]:[ve()],te({padding:8})]}).then(({x:t,y:s,placement:o})=>{this.selectedPopoverPlacement||(this.selectedPopoverPlacement=o,f.debug(`[${this.instanceId}] Locked popover placement:`,o));const n={left:`${t}px`,top:`${s}px`,width:`${this.input.offsetWidth}px`};this.options.dropdownMinWidth&&(n.minWidth=this.options.dropdownMinWidth),Object.assign(this.selectedPopover.style,n)})})}updateHiddenInput(){if(!this.options.formFieldId)return;this.hiddenInputs.forEach(o=>o.remove()),this.hiddenInputs=[];const e=this.options.valueFormat||"json",t=Array.from(this.selectedOptions.values()).map(o=>this.getItemValue(o)),s=this.options.hostElement||this.element;if(e==="array")t.forEach(o=>{const n=document.createElement("input");n.type="hidden",n.name=`${this.options.formFieldId}[]`,n.value=String(o),s.appendChild(n),this.hiddenInputs.push(n)});else{const o=document.createElement("input");o.type="hidden",o.name=this.options.formFieldId,o.id=this.options.formFieldId,o.value=this.getFormValue(),s.appendChild(o),this.hiddenInputs.push(o)}}getFormValue(){const e=Array.from(this.selectedOptions.values()).map(s=>this.getItemValue(s));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){this.selectedValues=new Set(e.map(t=>String(t))),this.selectedOptions.clear(),e.forEach(t=>{const s=String(t),o=this.allOptions.find(n=>String(this.getItemValue(n))===s);o&&this.selectedOptions.set(s,o)}),this.renderDropdown(),this.renderBadges(),this.updateHiddenInput()}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}attachBadgeTooltips(){if(!this.options.isBadgeTooltipsEnabled){f.debug(`[${this.instanceId}] Tooltips disabled - isBadgeTooltipsEnabled is false`);return}const e=this.badgesContainer.querySelectorAll(".ms__badge:not(.ms__badge--more)");f.debug(`[${this.instanceId}] Found ${e.length} badges to attach tooltips to`),e.forEach(s=>{const o=s,n=o.querySelector(".ms__badge-remove");if(!n)return;const r=n.dataset.value,a=this.selectedOptions.get(r);if(!a)return;const l=o.querySelector(".ms__badge-text");l&&this.createTooltipForElement(l,a,r);const c=this.getItemBadgeDisplayValue(a);this.createRemoveButtonTooltip(n,c,r)});const t=this.badgesContainer.querySelector(".ms__badge--more");if(t){const s=t.querySelector(".ms__badge-remove");if(s&&s.dataset.action==="remove-hidden"){const o=this.options.badgesMaxVisible||3,r=Array.from(this.selectedOptions.values()).length-o;this.createRemoveButtonTooltip(s,`${r} hidden items`,"more-badge-remove")}}}createTooltipForElement(e,t,s){const o=document.createElement("div");o.className="ms__badge-tooltip";let n;if(this.options.getBadgeTooltipCallback)n=this.options.getBadgeTooltipCallback(t),f.debug(`[${this.instanceId}] Using custom callback for tooltip content`);else{const m=this.getItemBadgeDisplayValue(t),u=this.getItemSubtitle(t);n=u?`${m}
|
|
46
|
+
${u}`:m,f.debug(`[${this.instanceId}] Using default content: "${n}"`)}typeof n=="string"?o.textContent=n:o.appendChild(n),(this.options.container||document.body).appendChild(o),f.debug(`[${this.instanceId}] Tooltip element created and appended for "${s}"`),this.badgeTooltips.set(s,o);let a,l;const c=()=>{clearTimeout(l),f.debug(`[${this.instanceId}] Mouse entered badge "${s}", will show tooltip in ${this.options.badgeTooltipDelay||300}ms`),a=window.setTimeout(()=>{f.debug(`[${this.instanceId}] Showing tooltip for "${s}"`),o.classList.add("ms__badge-tooltip--visible"),this.positionBadgeTooltip(e,o,s)},this.options.badgeTooltipDelay||300)},d=()=>{clearTimeout(a),l=window.setTimeout(()=>{o.classList.remove("ms__badge-tooltip--visible"),this.cleanupBadgeTooltip(s)},100)};e.addEventListener("mouseenter",c),e.addEventListener("mouseleave",d)}createRemoveButtonTooltip(e,t,s){const o=document.createElement("div");o.className="ms__badge-tooltip",o.textContent=`Remove ${t}`,(this.options.container||document.body).appendChild(o);const r=`${s}-remove`;this.badgeTooltips.set(r,o);let a,l;const c=()=>{clearTimeout(l);const m=this.badgeTooltips.get(s);m&&m.classList.remove("ms__badge-tooltip--visible"),a=window.setTimeout(()=>{o.classList.add("ms__badge-tooltip--visible"),this.positionBadgeTooltip(e,o,r)},this.options.badgeTooltipDelay||300)},d=()=>{clearTimeout(a),l=window.setTimeout(()=>{o.classList.remove("ms__badge-tooltip--visible"),this.cleanupBadgeTooltip(r)},100)};e.addEventListener("mouseenter",c),e.addEventListener("mouseleave",d)}positionBadgeTooltip(e,t,s){const o=Q(e,t,()=>{se(e,t,{placement:this.options.badgeTooltipPlacement||"top",strategy:"fixed",middleware:[ee(this.options.badgeTooltipOffset||8),ve(),te({padding:8})]}).then(({x:n,y:r})=>{Object.assign(t.style,{left:`${n}px`,top:`${r}px`}),f.debug(`[${this.instanceId}] Positioned tooltip "${s}" at x:${n}, y:${r}`,{placement:this.options.badgeTooltipPlacement||"top",tooltipClasses:t.className,tooltipDisplay:window.getComputedStyle(t).display,tooltipOpacity:window.getComputedStyle(t).opacity,tooltipVisibility:window.getComputedStyle(t).visibility,tooltipZIndex:window.getComputedStyle(t).zIndex,tooltipPosition:window.getComputedStyle(t).position})})});this.badgeTooltipCleanups.set(s,o)}cleanupBadgeTooltip(e){const t=this.badgeTooltipCleanups.get(e);t&&(t(),this.badgeTooltipCleanups.delete(e))}destroyAllBadgeTooltips(){this.badgeTooltipCleanups.forEach(e=>e()),this.badgeTooltipCleanups.clear(),this.badgeTooltips.forEach(e=>e.remove()),this.badgeTooltips.clear()}attachActionButtonTooltips(){const e=this.dropdown.querySelectorAll(".ms__action-btn");f.debug(`[${this.instanceId}] Found ${e.length} action buttons to attach tooltips to`),e.forEach(t=>{var l;const s=t,o=s.dataset.action;if(!o)return;const n=(l=this.options.actionButtons)==null?void 0:l.find(c=>c.action==="custom"?s.dataset.customAction===s.dataset.action:c.action===o);if(!n)return;let r;if(n.getTooltipCallback?(r=n.getTooltipCallback(this),f.debug(`[${this.instanceId}] Using getTooltipCallback for action button "${o}": "${r}"`)):(r=n.tooltip,f.debug(`[${this.instanceId}] Using static tooltip for action button "${o}": "${r}"`)),!r){f.debug(`[${this.instanceId}] No tooltip for action button "${o}"`);return}const a=`action-${o}-${Date.now()}`;this.createActionButtonTooltip(s,r,a)})}createActionButtonTooltip(e,t,s){const o=document.createElement("div");o.className="ms__badge-tooltip",o.textContent=t,(this.options.container||document.body).appendChild(o),f.debug(`[${this.instanceId}] Tooltip element created for action button "${s}"`),this.actionButtonTooltips.set(s,o);let r,a;const l=()=>{clearTimeout(a),f.debug(`[${this.instanceId}] Mouse entered action button "${s}", will show tooltip in ${this.options.badgeTooltipDelay||300}ms`),r=window.setTimeout(()=>{f.debug(`[${this.instanceId}] Showing tooltip for action button "${s}"`),o.classList.add("ms__badge-tooltip--visible"),this.positionActionButtonTooltip(e,o,s)},this.options.badgeTooltipDelay||300)},c=()=>{clearTimeout(r),a=window.setTimeout(()=>{o.classList.remove("ms__badge-tooltip--visible"),this.cleanupActionButtonTooltip(s)},100)};e.addEventListener("mouseenter",l),e.addEventListener("mouseleave",c)}positionActionButtonTooltip(e,t,s){const o=Q(e,t,()=>{se(e,t,{placement:this.options.badgeTooltipPlacement||"top",strategy:"fixed",middleware:[ee(this.options.badgeTooltipOffset||8),ve(),te({padding:8})]}).then(({x:n,y:r})=>{Object.assign(t.style,{left:`${n}px`,top:`${r}px`}),f.debug(`[${this.instanceId}] Positioned action button tooltip "${s}" at x:${n}, y:${r}`)})});this.actionButtonTooltipCleanups.set(s,o)}cleanupActionButtonTooltip(e){const t=this.actionButtonTooltipCleanups.get(e);t&&(t(),this.actionButtonTooltipCleanups.delete(e))}destroyAllActionButtonTooltips(){this.actionButtonTooltipCleanups.forEach(e=>e()),this.actionButtonTooltipCleanups.clear(),this.actionButtonTooltips.forEach(e=>e.remove()),this.actionButtonTooltips.clear()}destroy(){this.destroyAllBadgeTooltips(),this.destroyAllActionButtonTooltips(),this.dropdownCleanup&&this.dropdownCleanup(),this.hintCleanup&&this.hintCleanup(),this.selectedPopoverCleanup&&this.selectedPopoverCleanup(),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("ml","ms--open","ms--no-checkboxes"),ne.info(`[${this.instanceId}] Component destroyed`)}}const ms='@charset "UTF-8";:host{--ms-accent-color: #3b82f6;--ms-accent-color-hover: #2563eb;--ms-accent-color-active: #1d4ed8;--ms-text-primary: #111827;--ms-text-secondary: #6b7280;--ms-text-white: #ffffff;--ms-primary-bg: #f3f4f6;--ms-primary-bg-hover: #e5e7eb;--ms-border-color: #e5e7eb;--ms-input-background: var(--ms-input-bg);--ms-input-color: var(--ms-text-primary);--ms-input-border-color: var(--ms-border-color);--ms-input-border-color-focus: var(--ms-accent-color);--ms-input-placeholder-color: var(--ms-text-secondary);--ms-input-background-disabled: var(--ms-input-bg-disabled);--ms-toggle-icon-color: var(--ms-text-secondary);--ms-toggle-icon-color-open: var(--ms-text-secondary);--ms-counter-badge-background: var(--ms-accent-color);--ms-counter-badge-background-hover: var(--ms-accent-color-hover);--ms-counter-badge-color: var(--ms-text-white);--ms-hint-background: var(--ms-hint-bg);--ms-hint-color: var(--ms-text-secondary);--ms-hint-border-color: var(--ms-border-color);--ms-dropdown-background: var(--ms-dropdown-bg);--ms-dropdown-text-color: var(--ms-text-primary);--ms-dropdown-border-color: var(--ms-border-color);--ms-actions-background: var(--ms-dropdown-bg);--ms-actions-border-color: var(--ms-border-color);--ms-action-button-background: transparent;--ms-action-button-background-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-primary);--ms-group-border-color: var(--ms-border-color);--ms-group-label-color: var(--ms-text-secondary);--ms-option-text-color: var(--ms-text-primary);--ms-option-background: transparent;--ms-option-background-hover: var(--ms-primary-bg);--ms-option-background-focused: var(--ms-primary-bg);--ms-option-outline-color-focused: var(--ms-accent-color);--ms-option-background-selected: var(--ms-option-bg-selected);--ms-option-background-matched: var(--ms-option-bg-matched);--ms-option-border-matched-color: var(--ms-option-border-matched);--ms-option-title-color: var(--ms-text-primary);--ms-option-subtitle-color: var(--ms-text-secondary);--ms-option-mark-background: var(--ms-option-mark-bg);--ms-empty-color: var(--ms-text-secondary);--ms-loading-color: var(--ms-text-secondary);--ms-badge-background: var(--ms-badge-bg);--ms-badge-background-hover: var(--ms-badge-bg-hover);--ms-badge-background-active: var(--ms-badge-bg-active);--ms-badge-text-background: var(--ms-badge-text-bg);--ms-badge-text-color: var(--ms-accent-color);--ms-badge-remove-background: var(--ms-accent-color);--ms-badge-remove-background-hover: var(--ms-accent-color-hover);--ms-badge-remove-color: var(--ms-text-white);--ms-badge-counter-border-color: var(--ms-border-color);--ms-badge-counter-text-background: var(--ms-badge-counter-text-bg);--ms-badge-counter-text-color: var(--ms-text-secondary);--ms-badge-counter-remove-background: var(--ms-badge-counter-remove-bg);--ms-badge-counter-remove-background-hover: var(--ms-badge-counter-remove-bg-hover);--ms-badge-counter-remove-color: var(--ms-badge-counter-remove-color);--ms-counter-wrapper-background: transparent;--ms-counter-wrapper-background-hover: var(--ms-primary-bg);--ms-counter-wrapper-border-color: var(--ms-border-color);--ms-counter-wrapper-border-color-hover: var(--ms-accent-color);--ms-count-text-color: var(--ms-text-primary);--ms-count-clear-background: transparent;--ms-count-clear-background-hover: var(--ms-accent-color);--ms-count-clear-color: var(--ms-text-secondary);--ms-count-clear-color-hover: var(--ms-accent-color);--ms-tooltip-background: var(--ms-tooltip-bg);--ms-tooltip-text-color: var(--ms-tooltip-color);--ms-selected-popover-background: var(--ms-dropdown-bg);--ms-selected-popover-border-color: var(--ms-border-color);--ms-selected-popover-header-background: var(--ms-selected-popover-header-bg);--ms-selected-popover-header-color: var(--ms-text-primary);--ms-selected-popover-header-border-color: var(--ms-border-color);--ms-selected-popover-close-background: transparent;--ms-selected-popover-close-background-hover: var(--ms-accent-color);--ms-selected-popover-close-color: var(--ms-text-secondary);--ms-selected-popover-close-color-hover: var(--ms-accent-color);--ms-input-padding: .5rem .75rem;--ms-input-padding-right: 2.5rem;--ms-input-font-size: .875rem;--ms-input-border-style: 1px solid #d1d5db;--ms-input-border-radius: .375rem;--ms-input-bg: #ffffff;--ms-input-text: #111827;--ms-input-focus-border-color: #3b82f6;--ms-input-placeholder-color: #6b7280;--ms-input-bg-disabled: rgba(107, 114, 128, .05);--ms-toggle-right: .75rem;--ms-toggle-color: #6b7280;--ms-transform-center-y: translateY(-50%);--ms-transform-rotate-180: 180deg;--ms-counter-offset: 2rem;--ms-counter-padding: .125rem .25rem;--ms-counter-bg: #3b82f6;--ms-counter-color: #ffffff;--ms-counter-font-size: .75rem;--ms-counter-font-weight: 600;--ms-counter-border-radius: .25rem;--ms-counter-bg-hover: #2563eb;--ms-transform-scale-hover: 1.1;--ms-hint-padding: .5rem .75rem;--ms-hint-bg: #ffffff;--ms-hint-border: 1px solid #e5e7eb;--ms-hint-border-radius: .375rem;--ms-hint-box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1);--ms-hint-font-size: .75rem;--ms-hint-color: #6b7280;--ms-line-height-relaxed: 1.4;--ms-dropdown-bg: #ffffff;--ms-dropdown-border: 1px solid #e5e7eb;--ms-dropdown-border-radius: .375rem;--ms-dropdown-box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1);--ms-options-max-height: 20rem;--ms-option-color: #111827;--ms-z-index-dropdown: 9999;--ms-z-index-sticky: 1;--ms-actions-gap: .25rem;--ms-actions-padding: .5rem;--ms-actions-border-bottom: 1px solid #e5e7eb;--ms-actions-bg: #ffffff;--ms-action-btn-padding: .25rem .5rem;--ms-action-btn-font-size: .75rem;--ms-action-btn-border: 1px solid #e5e7eb;--ms-action-btn-border-radius: .25rem;--ms-action-btn-bg: transparent;--ms-action-btn-color: inherit;--ms-action-btn-bg-hover: #f3f4f6;--ms-action-btn-border-color-hover: #3b82f6;--ms-transform-scale-active: .98;--ms-options-padding: .25rem 0;--ms-group-border-top: 1px solid #e5e7eb;--ms-group-margin-top: .25rem;--ms-group-padding-top: .25rem;--ms-group-label-padding: .25rem .75rem;--ms-group-label-font-size: .75rem;--ms-group-label-font-weight: 600;--ms-group-label-color: #6b7280;--ms-group-label-transform: uppercase;--ms-group-label-letter-spacing: .05em;--ms-option-gap: .5rem;--ms-option-padding: .5rem .75rem;--ms-option-padding-h: .75rem;--ms-option-bg: transparent;--ms-option-bg-hover: #f9fafb;--ms-option-bg-focused: #f9fafb;--ms-option-outline-focused: 2px solid #3b82f6;--ms-option-focus-outline-offset: -2px;--ms-option-bg-matched: rgba(59, 130, 246, .08);--ms-option-border-matched: 3px solid rgba(59, 130, 246, .4);--ms-option-bg-selected: rgba(59, 130, 246, .1);--ms-disabled-opacity: .5;--ms-option-content-gap: .5rem;--ms-option-icon-size: 1.25rem;--ms-option-icon-font-size: 1rem;--ms-option-title-font-size: .875rem;--ms-option-title-color: inherit;--ms-option-mark-bg: rgba(59, 130, 246, .2);--ms-option-mark-color: inherit;--ms-option-mark-font-weight: 600;--ms-option-subtitle-margin-top: .25rem;--ms-option-subtitle-font-size: .75rem;--ms-option-subtitle-color: #6b7280;--ms-option-subtitle-line-height: 1.3;--ms-checkbox-margin-top: .125rem;--ms-checkbox-margin-right: 0;--ms-checkbox-margin-bottom: 0;--ms-checkbox-margin-left: 0;--ms-checkbox-size: 16px;--ms-checkbox-scale: 1;--ms-checkbox-align: flex-start;--ms-empty-padding: 1rem .75rem;--ms-empty-font-size: .875rem;--ms-empty-color: #6b7280;--ms-loader-padding: 1rem;--ms-loader-gap: .5rem;--ms-loading-text-font-size: .875rem;--ms-loading-text-color: #6b7280;--ms-badges-gap: .5rem;--ms-badges-margin-bottom: .5rem;--ms-badges-margin-top: .5rem;--ms-badges-margin-left: .25rem;--ms-badges-margin-right: .25rem;--ms-badge-gap: .5rem;--ms-badge-height: 1.7rem;--ms-badge-font-size: .75rem;--ms-badge-font-weight: 600;--ms-badge-border-radius: .375rem;--ms-badge-bg: #eff6ff;--ms-badge-bg-hover: #ffffff;--ms-badge-bg-active: #e0f2fe;--ms-order-first: -1;--ms-badge-text-padding: 0 .5rem;--ms-badge-text-bg: #eff6ff;--ms-badge-text-color: #3b82f6;--ms-badge-remove-width: 1.7rem;--ms-badge-remove-bg: #3b82f6;--ms-badge-remove-color: #ffffff;--ms-badge-remove-border: none;--ms-badge-remove-font-size: .75rem;--ms-badge-remove-bg-hover: #2563eb;--ms-badge-remove-box-shadow-focus: 0 0 0 2px rgba(59, 130, 246, .5);--ms-icon-remove: "×";--ms-badge-counter-bg: transparent;--ms-badge-counter-border: 1px solid #e5e7eb;--ms-badge-counter-border-radius: .25rem;--ms-badge-counter-text-color: #6b7280;--ms-badge-counter-text-bg: #d1d5db;--ms-badge-counter-remove-bg: #6b7280;--ms-badge-counter-remove-color: #ffffff;--ms-badge-counter-remove-bg-hover: #111827;--ms-more-badge-bg: #eff6ff;--ms-more-badge-hover-bg: #ffffff;--ms-more-badge-active-bg: #e0f2fe;--ms-count-display-margin-bottom: .5rem;--ms-count-display-margin-top: .5rem;--ms-count-display-margin-left: .5rem;--ms-count-display-margin-right: .5rem;--ms-counter-wrapper-bg: transparent;--ms-counter-wrapper-border: 1px solid #e5e7eb;--ms-counter-wrapper-border-radius: .25rem;--ms-counter-wrapper-padding: .25rem .5rem;--ms-counter-wrapper-gap: .25rem;--ms-counter-wrapper-bg-hover: #f9fafb;--ms-counter-wrapper-border-color-hover: #3b82f6;--ms-count-text-bg: transparent;--ms-count-text-border: none;--ms-count-text-font-size: .875rem;--ms-count-text-color: #111827;--ms-count-clear-size: 1rem;--ms-count-clear-bg: transparent;--ms-count-clear-color: #6b7280;--ms-count-clear-font-size: 1.125rem;--ms-count-clear-border-radius: 50%;--ms-count-clear-bg-hover: rgba(59, 130, 246, .2);--ms-count-clear-color-hover: #3b82f6;--ms-icon-clear: "×";--ms-tooltip-bg: #333;--ms-tooltip-color: #fff;--ms-tooltip-padding: .5rem .75rem;--ms-tooltip-border-radius: .375rem;--ms-tooltip-font-size: .875rem;--ms-tooltip-max-width: 20rem;--ms-tooltip-shadow: 0 2px 8px rgba(0, 0, 0, .15);--ms-tooltip-z-index: 10000;--ms-z-index-popover: 10000;--ms-selected-popover-width: 20rem;--ms-selected-popover-max-height: 20rem;--ms-selected-popover-bg: #ffffff;--ms-selected-popover-border: 1px solid #e5e7eb;--ms-selected-popover-border-radius: .375rem;--ms-selected-popover-box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1);--ms-selected-popover-header-padding: .5rem .75rem;--ms-selected-popover-header-bg: rgba(59, 130, 246, .1);--ms-selected-popover-header-border-bottom: 1px solid #e5e7eb;--ms-selected-popover-header-font-size: .875rem;--ms-selected-popover-header-font-weight: 600;--ms-selected-popover-header-color: #111827;--ms-popover-close-size: 1.5rem;--ms-selected-popover-close-bg: transparent;--ms-selected-popover-close-color: #6b7280;--ms-selected-popover-close-font-size: 1.25rem;--ms-selected-popover-close-border-radius: 50%;--ms-selected-popover-close-bg-hover: rgba(59, 130, 246, .2);--ms-selected-popover-close-color-hover: #3b82f6;--ms-selected-popover-body-gap: .25rem;--ms-selected-popover-body-padding: .5rem;--ms-selected-popover-body-max-height: 18rem;--ms-font-size-2xs: .625rem;--ms-font-size-xs: .75rem;--ms-font-size-sm: .875rem;--ms-font-size-base: 1rem;--ms-font-size-lg: 1.125rem;--ms-font-weight-medium: 500;--ms-font-weight-semibold: 600;--ms-line-height-none: 1;--ms-spacing-xs: .25rem;--ms-spacing-sm: .5rem;--ms-spacing-md: .75rem;--ms-spacing-lg: 1rem;--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}multi-select:not(:defined){display:block;min-height:2.5rem;color:transparent!important;background:transparent}.ml-wrapper{display:flex;flex-direction:column;align-items:stretch}.ml-wrapper--inline{flex-direction:row;align-items:flex-start}.ml{position:relative;width:100%}.ms__input-wrapper{position:relative;display:flex;align-items:center}.ms__input{width:100%;padding:var(--ms-input-padding, .5rem .75rem);padding-right:var(--ms-input-padding-right, 2.5rem);font-size:var(--ms-input-font-size, .875rem);border:var(--ms-input-border-style, 1px solid #d1d5db);border-radius:var(--ms-input-border-radius, .375rem);background:var(--ms-input-background, #ffffff);color:var(--ms-input-color, #111827);cursor:pointer;transition:border-color var(--ms-transition-fast, .15s) var(--ms-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ms__input:focus{outline:none;border-color:var(--ms-input-border-color-focus, #3b82f6)}.ms__input::placeholder{color:var(--ms-input-placeholder-color, #6b7280);opacity:0;transition:opacity var(--ms-transition-fast, .15s) var(--ms-easing-snappy, cubic-bezier(.4, 0, .2, 1))}:host([data-ready]) .ms__input::placeholder{opacity:var(--ms-placeholder-opacity, .6)}.ms__toggle{position:absolute;right:var(--ms-toggle-right, .75rem);top:50%;transform:var(--ms-transform-center-y, translateY(-50%));pointer-events:none;color:var(--ms-toggle-icon-color, #6b7280);transition:transform var(--ms-transition-fast, .15s) var(--ms-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ms--open .ms__toggle{transform:var(--ms-transform-center-y, translateY(-50%)) rotate(var(--ms-transform-rotate-180, 180deg));color:var(--ms-toggle-icon-color-open, #6b7280)}.ms__counter{position:absolute;right:var(--ms-counter-offset, 2rem);top:50%;transform:var(--ms-transform-center-y, translateY(-50%));padding:var(--ms-counter-padding, .125rem .25rem);background:var(--ms-counter-badge-background, #3b82f6);color:var(--ms-counter-badge-color, #ffffff);font-size:var(--ms-counter-font-size, .75rem);font-weight:var(--ms-counter-font-weight, 600);border-radius:var(--ms-counter-border-radius, .25rem);cursor:pointer;transition:all var(--ms-transition-fast, .15s) var(--ms-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ms__counter:hover{background:var(--ms-counter-badge-background-hover, #2563eb);transform:var(--ms-transform-center-y, translateY(-50%)) scale(var(--ms-transform-scale-hover, 1.1))}.ms__hint{display:none;position:absolute;z-index:var(--ms-z-index-popover, 10000);padding:var(--ms-hint-padding, .5rem .75rem);background:var(--ms-hint-background, #ffffff);border:var(--ms-hint-border, 1px solid #e5e7eb);border-radius:var(--ms-hint-border-radius, .375rem);box-shadow:var(--ms-hint-box-shadow, 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1));font-size:var(--ms-hint-font-size, .75rem);color:var(--ms-hint-color, #6b7280);line-height:var(--ms-line-height-relaxed, 1.4);max-width:100%}.ms__hint--visible{display:block}.ms__dropdown{display:none;position:absolute;z-index:var(--ms-z-index-dropdown, 9999);background:var(--ms-dropdown-background, #ffffff);border:var(--ms-dropdown-border, 1px solid #e5e7eb);border-radius:var(--ms-dropdown-border-radius, .375rem);box-shadow:var(--ms-dropdown-box-shadow, 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1));max-height:var(--ms-options-max-height, 20rem);overflow-y:auto;overscroll-behavior:contain;touch-action:pan-y;-webkit-overflow-scrolling:touch;color:var(--ms-dropdown-text-color, #111827)}.ms__dropdown--visible{display:block}.ms__dropdown--virtual{overflow-y:visible;max-height:none}.ms__actions{display:flex;flex-wrap:nowrap;gap:var(--ms-actions-gap, .25rem);padding:var(--ms-actions-padding, .5rem);border-bottom:var(--ms-actions-border-bottom, 1px solid #e5e7eb)}.ms__actions--wrap{flex-wrap:wrap}.ms__actions--sticky{position:sticky;top:0;z-index:var(--ms-z-index-sticky, 1);background:var(--ms-actions-background, #ffffff)}.ms__action-btn{flex:1;padding:var(--ms-action-btn-padding, .25rem .5rem);font-size:var(--ms-action-btn-font-size, .75rem);border:var(--ms-action-btn-border, 1px solid #e5e7eb);border-radius:var(--ms-action-btn-border-radius, .25rem);background:var(--ms-action-button-background, transparent);color:var(--ms-action-button-color, inherit);cursor:pointer;transition:all var(--ms-transition-fast, .15s) var(--ms-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ms__action-btn:hover{background:var(--ms-action-button-background-hover, #f3f4f6);border-color:var(--ms-action-button-border-color-hover, #3b82f6)}.ms__action-btn:active{transform:scale(var(--ms-transform-scale-active, .98))}.ms__action-btn:disabled,.ms__action-btn[disabled]{opacity:var(--ms-disabled-opacity, .5);cursor:not-allowed;pointer-events:none}.ms__options{padding:var(--ms-options-padding, .25rem 0)}.ms__options--virtual .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, 1px solid #e5e7eb);margin-top:var(--ms-group-margin-top, .25rem);padding-top:var(--ms-group-padding-top, .25rem)}.ms__group-label{padding:var(--ms-group-label-padding, .25rem .75rem);font-size:var(--ms-group-label-font-size, .75rem);font-weight:var(--ms-group-label-font-weight, 600);color:var(--ms-group-label-color, #6b7280);text-transform:var(--ms-group-label-transform, uppercase);letter-spacing:var(--ms-group-label-letter-spacing, .05em)}.ms__option{display:flex;align-items:var(--ms-checkbox-align, flex-start);gap:var(--ms-option-gap, .5rem);padding:var(--ms-option-padding, .5rem .75rem);color:var(--ms-option-text-color, #111827);background:var(--ms-option-background, transparent);cursor:pointer;transition:background-color var(--ms-transition-fast, .15s) var(--ms-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ms__option:hover{background:var(--ms-option-background-hover, #f9fafb)}.ms__option--focused{background:var(--ms-option-background-focused, #f9fafb);outline:var(--ms-option-outline-focused, 2px solid #3b82f6);outline-offset:var(--ms-option-focus-outline-offset, -2px)}.ms__option--matched{background:var(--ms-option-background-matched, rgba(59, 130, 246, .08));border-left:var(--ms-option-border-matched, 3px solid rgba(59, 130, 246, .4))}.ms__option--selected{background:var(--ms-option-background-selected, rgba(59, 130, 246, .1))}.ms__option--selected:hover{background:var(--ms-option-bg-selected-hover, var(--ms-option-background-selected, rgba(59, 130, 246, .1)))}.ms__option--disabled{opacity:var(--ms-disabled-opacity, .5);cursor:not-allowed}.ms__option--disabled:hover{background:var(--ms-option-background, transparent)}.ms__option[data-checkbox-align=center]{--ms-checkbox-align: center}.ms__option[data-checkbox-align=bottom]{--ms-checkbox-align: flex-end}.ms__checkbox{flex-shrink:0;margin-top:var(--ms-checkbox-margin-top, .125rem);margin-right:var(--ms-checkbox-margin-right, 0);margin-bottom:var(--ms-checkbox-margin-bottom, 0);margin-left:var(--ms-checkbox-margin-left, 0);width:var(--ms-checkbox-size, 16px);height:var(--ms-checkbox-size, 16px);transform:scale(var(--ms-checkbox-scale, 1));transform-origin:top left;cursor:pointer}.ms__option--disabled .ms__checkbox{cursor:not-allowed}.ms__option-content{flex:1;display:flex;align-items:flex-start;gap:var(--ms-option-content-gap, .5rem);min-width:0}.ms__option-icon{flex-shrink:0;width:var(--ms-option-icon-size, 1.25rem);height:var(--ms-option-icon-size, 1.25rem);display:flex;align-items:center;justify-content:center;font-size:var(--ms-option-icon-font-size, 1rem)}.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, .875rem);color:var(--ms-option-title-color, inherit);line-height:var(--ms-line-height-relaxed, 1.4)}.ms__option-title mark{background:var(--ms-option-mark-background, rgba(59, 130, 246, .2));color:var(--ms-option-mark-color, inherit);font-weight:var(--ms-option-mark-font-weight, 600)}.ms__option-subtitle{margin-top:var(--ms-option-subtitle-margin-top, .25rem);font-size:var(--ms-option-subtitle-font-size, .75rem);color:var(--ms-option-subtitle-color, #6b7280);line-height:var(--ms-option-subtitle-line-height, 1.3)}.ms__empty{padding:var(--ms-empty-padding, 1rem .75rem);text-align:center;font-size:var(--ms-empty-font-size, .875rem);color:var(--ms-empty-color, #6b7280)}.ms__loader{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--ms-loader-padding, 1rem);gap:var(--ms-loader-gap, .5rem)}.ms__loading-text{font-size:var(--ms-loading-text-font-size, .875rem);color:var(--ms-loading-color, #6b7280)}.ms__badges{display:flex;flex-wrap:wrap;gap:var(--ms-badges-gap, .5rem);padding:0}.ms__badges:empty{display:none}.ms__badges--bottom{margin-top:var(--ms-badges-margin-bottom, .5rem)}.ms__badges--top{margin-bottom:var(--ms-badges-margin-top, .5rem);order:var(--ms-order-first, -1)}.ms__badges--left{order:var(--ms-order-first, -1);margin-right:var(--ms-badges-margin-left, .25rem);justify-content:flex-end}.ms__badges--right{margin-left:var(--ms-badges-margin-right, .25rem);justify-content:flex-start}.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, .5rem)}.ms__count-display--top{margin-bottom:var(--ms-count-display-margin-top, .5rem);order:var(--ms-order-first, -1)}.ms__count-display--left{order:var(--ms-order-first, -1);margin-right:var(--ms-count-display-margin-left, .5rem);justify-content:flex-start}.ms__count-display--right{margin-left:var(--ms-count-display-margin-right, .5rem);justify-content:flex-end}.ms__counter-wrapper{display:inline-flex;align-items:center;gap:var(--ms-counter-wrapper-gap, .25rem);background:var(--ms-counter-wrapper-background, transparent);border:var(--ms-counter-wrapper-border, 1px solid #e5e7eb);border-radius:var(--ms-counter-wrapper-border-radius, .25rem);padding:var(--ms-counter-wrapper-padding, .25rem .5rem);transition:all var(--ms-transition-fast, .15s) var(--ms-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ms__counter-wrapper:hover{background:var(--ms-counter-wrapper-background-hover, #f9fafb);border-color:var(--ms-counter-wrapper-border-color-hover, #3b82f6)}.ms__count-text{display:inline-flex;align-items:center;background:var(--ms-count-text-bg, transparent);border:var(--ms-count-text-border, none);padding:0;font-size:var(--ms-count-text-font-size, .875rem);color:var(--ms-count-text-color, #111827);cursor:pointer;transition:color var(--ms-transition-fast, .15s) var(--ms-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ms__count-clear{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:var(--ms-count-clear-size, 1rem);height:var(--ms-count-clear-size, 1rem);padding:0;border:none;background:var(--ms-count-clear-background, transparent);color:var(--ms-count-clear-color, #6b7280);font-size:var(--ms-count-clear-font-size, 1.125rem);line-height:var(--ms-line-height-none, 1);cursor:pointer;border-radius:var(--ms-count-clear-border-radius, 50%);transition:all var(--ms-transition-fast, .15s) var(--ms-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ms__count-clear:hover{background:var(--ms-count-clear-background-hover, rgba(59, 130, 246, .2));color:var(--ms-count-clear-color-hover, #3b82f6)}.ms__count-clear:before{content:var(--ms-icon-clear, "×")}.ms__badge{display:inline-flex;align-items:center;height:var(--ms-badge-height, 1.7rem);font-size:var(--ms-badge-font-size, .75rem);font-weight:var(--ms-badge-font-weight, 600);line-height:var(--ms-line-height-none, 1);border-radius:var(--ms-badge-border-radius, .375rem);overflow:hidden;max-width:100%}.ms__badge-text{display:flex;align-items:center;height:100%;padding:var(--ms-badge-text-padding, 0 .5rem);background:var(--ms-badge-text-background, #eff6ff);color:var(--ms-badge-text-color, #3b82f6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:background-color var(--ms-transition-normal, .2s) ease}.ms__badge-remove{display:flex;align-items:center;justify-content:center;width:var(--ms-badge-remove-width, 1.7rem);height:100%;flex-shrink:0;background:var(--ms-badge-remove-background, #3b82f6);color:var(--ms-badge-remove-color, #ffffff);border:var(--ms-badge-remove-border, none);cursor:pointer;transition:background-color var(--ms-transition-normal, .2s) ease;font-size:var(--ms-badge-remove-font-size, .75rem)}.ms__badge-remove:hover{background:var(--ms-badge-remove-background-hover, #2563eb)}.ms__badge-remove:focus{outline:none;box-shadow:var(--ms-badge-remove-box-shadow-focus, 0 0 0 2px rgba(59, 130, 246, .5))}.ms__badge-remove:before{content:var(--ms-icon-remove, "×");font-size:var(--ms-font-size-base, 1rem);line-height:var(--ms-line-height-none, 1)}.ms__badge--counter{border:var(--ms-badge-counter-border, 1px solid #e5e7eb);cursor:pointer}.ms__badge--counter .ms__badge-text{background:var(--ms-badge-counter-text-background, #d1d5db);color:var(--ms-badge-counter-text-color, #6b7280)}.ms__badge--counter .ms__badge-remove{background:var(--ms-badge-counter-remove-background, #6b7280);color:var(--ms-badge-counter-remove-color, #ffffff)}.ms__badge--counter .ms__badge-remove:hover{background:var(--ms-badge-counter-remove-background-hover, #111827)}.ms__badge--more{cursor:pointer}.ms__badge-tooltip{position:fixed;z-index:var(--ms-tooltip-z-index, 10000);opacity:0;visibility:hidden;transition:opacity var(--ms-transition-normal, .2s) ease,visibility var(--ms-transition-normal, .2s) ease;background:var(--ms-tooltip-background, #333);color:var(--ms-tooltip-text-color, #fff);padding:var(--ms-tooltip-padding, .5rem .75rem);border-radius:var(--ms-tooltip-border-radius, .375rem);font-size:var(--ms-tooltip-font-size, .875rem);line-height:var(--ms-line-height-relaxed, 1.4);max-width:var(--ms-tooltip-max-width, 20rem);word-wrap:break-word;white-space:pre-wrap;box-shadow:var(--ms-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, .15));pointer-events:none}.ms__badge-tooltip--visible{opacity:1;visibility:visible}.ms__selected-popover{display:none;position:absolute;z-index:var(--ms-z-index-popover, 10000);background:var(--ms-selected-popover-background, #ffffff);border:var(--ms-selected-popover-border, 1px solid #e5e7eb);border-radius:var(--ms-selected-popover-border-radius, .375rem);box-shadow:var(--ms-selected-popover-box-shadow, 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1));width:var(--ms-selected-popover-width, 20rem);max-height:var(--ms-selected-popover-max-height, 20rem);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, .5rem .75rem);background:var(--ms-selected-popover-header-background, rgba(59, 130, 246, .1));border-bottom:var(--ms-selected-popover-header-border-bottom, 1px solid #e5e7eb);font-size:var(--ms-selected-popover-header-font-size, .875rem);font-weight:var(--ms-selected-popover-header-font-weight, 600);color:var(--ms-selected-popover-header-color, #111827)}.ms__selected-popover-close{display:flex;align-items:center;justify-content:center;width:var(--ms-popover-close-size, 1.5rem);height:var(--ms-popover-close-size, 1.5rem);padding:0;border:none;background:var(--ms-selected-popover-close-background, transparent);color:var(--ms-selected-popover-close-color, #6b7280);font-size:var(--ms-selected-popover-close-font-size, 1.25rem);line-height:var(--ms-line-height-none, 1);cursor:pointer;border-radius:var(--ms-selected-popover-close-border-radius, 50%);transition:all var(--ms-transition-fast, .15s) var(--ms-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ms__selected-popover-close:hover{background:var(--ms-selected-popover-close-background-hover, rgba(59, 130, 246, .2));color:var(--ms-selected-popover-close-color-hover, #3b82f6)}.ms__selected-popover-body{display:flex;flex-direction:column;gap:var(--ms-selected-popover-body-gap, .25rem);padding:var(--ms-selected-popover-body-padding, .5rem);overflow-y:auto;max-height:var(--ms-selected-popover-body-max-height, 18rem)}.ms__selected-popover-body .ms__badge{width:100%;min-height:fit-content;line-height:var(--ms-line-height-relaxed, 1.4)}.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, .25rem);overflow:hidden;box-sizing:border-box}.ms__selected-popover-body--virtual .ms__badge-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ms--rtl .ms__input-wrapper{direction:rtl}.ms--rtl .ms__input{text-align:right;padding-left:var(--ms-input-padding-right, 2.5rem);padding-right:var(--ms-input-padding-h, .75rem)}.ms--rtl .ms__toggle{left:var(--ms-toggle-right, .75rem)!important;right:auto!important}.ms--rtl .ms__counter{left:var(--ms-counter-offset, 2rem)!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, .5rem);margin-right:0}.ms--rtl .ms__option-content{text-align:right}.ms--rtl .ms__option-icon{margin-left:var(--ms-spacing-xs, .25rem);margin-right:0}.ms--rtl .ms__badges{direction:rtl}.ms--rtl .ms__badge{flex-direction:row-reverse}.ms--rtl .ms__badge-remove{border-radius:var(--ms-badge-remove-border-radius-rtl, .375rem) 0 0 var(--ms-badge-remove-border-radius-rtl, .375rem);border-left:var(--ms-badge-remove-border, none);border-right:none}.ms--rtl .ms__badge-text{border-radius:0 var(--ms-badge-text-border-radius-rtl, .375rem) var(--ms-badge-text-border-radius-rtl, .375rem) 0}.ms--rtl .ms__count-display{direction:rtl}.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}.ms--xs .ms__input{font-size:var(--ms-font-size-xs, .75rem)}.ms--xs .ms__option{padding:var(--ms-spacing-xs, .25rem) var(--ms-spacing-sm, .5rem)}.ms--xs .ms__option-title{font-size:var(--ms-font-size-xs, .75rem)}.ms--xs .ms__badge{font-size:var(--ms-font-size-2xs, .625rem)}.ms--sm .ms__input,.ms--sm .ms__option-title{font-size:var(--ms-font-size-xs, .75rem)}.ms--lg .ms__input,.ms--lg .ms__option-title{font-size:var(--ms-font-size-base, 1rem)}.ms--lg .ms__badge{font-size:var(--ms-font-size-sm, .875rem)}.ms--xl .ms__input,.ms--xl .ms__option-title{font-size:var(--ms-font-size-lg, 1.125rem)}.ms--xl .ms__badge{font-size:var(--ms-font-size-base, 1rem)}.ms--disabled .ms__input{opacity:var(--ms-disabled-input-opacity, .6);cursor:not-allowed;background:var(--ms-input-bg-disabled, rgba(107, 114, 128, .05))}.ms--disabled .ms__toggle{opacity:var(--ms-disabled-input-opacity, .6)}.ms--no-checkboxes .ms__option{gap:0;padding-left:var(--ms-option-padding-h, .75rem)}.ms--no-checkboxes .ms__option-content{padding-left:0}.ml-debug-info{margin-top:.25rem;padding:.25rem;background-color:#f9fafb;border:1px solid #e5e7eb;border-radius:.375rem;font-size:.75rem;color:#111827}.ml-debug-info details summary{cursor:pointer;font-weight:600;color:#2563eb;-webkit-user-select:none;user-select:none;padding:.25rem;border-radius:.25rem}.ml-debug-info details summary:hover{background-color:#f3f4f6}.ml-debug-info details summary:focus{outline:2px solid #3b82f6;outline-offset:2px}.ml-debug-info .ml-debug-stats{display:flex;flex-direction:column;gap:.25rem;margin-top:.25rem;padding:.25rem;background-color:#fff;border-radius:.25rem}.ml-debug-info .ml-debug-stats span{display:flex;justify-content:space-between;padding:2px 4px;font-family:monospace;font-size:.625rem}.ml-debug-info .ml-debug-stats span:before{content:"•";margin-right:.25rem;color:#3b82f6}',us=typeof HTMLElement<"u"?HTMLElement:class{},Ie=new Set;function dt(){return Array.from(Ie)}class Te extends us{constructor(){super();p(this,"picker");p(this,"containerElement");p(this,"shadow");p(this,"_options");p(this,"_valueMember");p(this,"_getValueCallback");p(this,"_displayValueMember");p(this,"_getDisplayValueCallback");p(this,"_getBadgeDisplayCallback");p(this,"_getBadgeClassCallback");p(this,"_customStylesCallback");p(this,"_searchValueMember");p(this,"_getSearchValueCallback");p(this,"_iconMember");p(this,"_getIconCallback");p(this,"_subtitleMember");p(this,"_getSubtitleCallback");p(this,"_groupMember");p(this,"_getGroupCallback");p(this,"_renderGroupLabelContentCallback");p(this,"_disabledMember");p(this,"_getDisabledCallback");p(this,"_getValueFormatCallback");p(this,"_getBadgeTooltipCallback");p(this,"_renderOptionContentCallback");p(this,"_renderBadgeContentCallback");p(this,"_renderSelectedItemContentCallback");p(this,"_getSelectedItemClassCallback");p(this,"_renderSelectedContentCallback");p(this,"_getCounterCallback");p(this,"_actionButtons");p(this,"_beforeSearchCallback");p(this,"_searchCallback");p(this,"_addNewCallback");p(this,"_selectCallback");p(this,"_deselectCallback");p(this,"_changeCallback");p(this,"_declarativeSelectedValues");this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=ms,this.shadow.appendChild(t),requestAnimationFrame(()=>{this.setAttribute("data-ready","")})}static get observedAttributes(){return["search-hint","search-placeholder","multiple","allow-groups","show-checkboxes","sticky-actions","close-on-select","lock-placement","dropdown-min-width","badges-display-mode","badges-threshold","badges-max-visible","badges-threshold-mode","badges-position","show-counter","keep-options-on-search","max-height","empty-message","loading-message","min-search-length","enable-search","search-input-mode","search-mode","actions-layout","allow-add-new","initial-values","enable-virtual-scroll","virtual-scroll-threshold","option-height","badge-height","virtual-scroll-buffer","value-member","display-value-member","search-value-member","icon-member","subtitle-member","group-member","disabled-member","name","value-format","enable-badge-tooltips","badge-tooltip-placement","show-debug-info"]}connectedCallback(){Ie.add(this),this.render();const t=this.parseDeclarativeOptions();t&&(this._options&&this._options.length>0&&k.warn("[MultiSelectElement] Both declarative <option> elements and programmatic .options detected. Using declarative options."),this._options=t),this.initializePicker()}disconnectedCallback(){Ie.delete(this),this.picker&&this.picker.destroy()}attributeChangedCallback(t,s,o){s!==o&&this.picker&&t!=="initial-values"&&(this.picker.destroy(),this.initializePicker())}render(){this.containerElement=document.createElement("div"),this.containerElement.setAttribute("data-multiselect",""),this.className&&(this.containerElement.className=this.className),this.shadow.appendChild(this.containerElement),this.getAttribute("show-debug-info")==="true"&&this.renderDebugInfo()}renderDebugInfo(){const t=this.shadow.querySelector(".ml-debug-info");t&&t.remove();const s=document.createElement("div");s.className="ml-debug-info";const o=document.createElement("details"),n=document.createElement("summary");n.textContent="Debug Info";const r=document.createElement("div");r.className="ml-debug-stats",o.appendChild(n),o.appendChild(r),s.appendChild(o),this.shadow.appendChild(s),this.updateDebugInfo()}updateDebugInfo(){var h,g;const t=this.shadow.querySelector(".ml-debug-stats");if(!t||!this.picker)return;const s="1.1.0",o=dt().length,r=this.picker.getSelected().length,a=((h=this._options)==null?void 0:h.length)||0,l=this.picker,c=l.isOpen||!1,d=l.searchTerm||"",m=l.isLoading||!1,u=((g=l.filteredOptions)==null?void 0:g.length)||0;t.innerHTML=`
|
|
47
|
+
<span>Version: ${s}</span>
|
|
48
|
+
<span>Total Instances: ${o}</span>
|
|
49
|
+
<span>Options: ${a}</span>
|
|
50
50
|
<span>Filtered: ${u}</span>
|
|
51
|
-
<span>Selected: ${
|
|
52
|
-
<span>Dropdown: ${
|
|
53
|
-
<span>Search: ${
|
|
54
|
-
<span>Loading: ${
|
|
55
|
-
`,setTimeout(()=>{this.getAttribute("show-debug-info")==="true"&&this.updateDebugInfo()},500)}parseDeclarativeOptions(){var n,l,r,a;const t=[],i=Array.from(this.children);if(i.length===0)return null;let s=!1;for(const d of i)if(d.tagName==="OPTION"){const c=d,p={value:c.value||((n=c.textContent)==null?void 0:n.trim())||"",label:((l=c.textContent)==null?void 0:l.trim())||c.value||""};c.hasAttribute("selected")&&(this._declarativeSelectedValues||(this._declarativeSelectedValues=[]),this._declarativeSelectedValues.push(p.value)),c.hasAttribute("disabled")&&(p.disabled=!0),c.hasAttribute("data-icon")&&(p.icon=c.getAttribute("data-icon")),c.hasAttribute("data-subtitle")&&(p.subtitle=c.getAttribute("data-subtitle")),t.push(p),s=!0}else if(d.tagName==="OPTGROUP"){const c=d,p=c.label||c.getAttribute("label")||"Group",u=Array.from(c.querySelectorAll("option"));for(const h of u){const g={value:h.value||((r=h.textContent)==null?void 0:r.trim())||"",label:((a=h.textContent)==null?void 0:a.trim())||h.value||"",group:p};h.hasAttribute("selected")&&(this._declarativeSelectedValues||(this._declarativeSelectedValues=[]),this._declarativeSelectedValues.push(g.value)),h.hasAttribute("disabled")&&(g.disabled=!0),h.hasAttribute("data-icon")&&(g.icon=h.getAttribute("data-icon")),h.hasAttribute("data-subtitle")&&(g.subtitle=h.getAttribute("data-subtitle")),t.push(g),s=!0}}return s?(k.debug(`[MultiSelectElement] Parsed ${t.length} declarative options from Light DOM`),i.forEach(d=>{(d.tagName==="OPTION"||d.tagName==="OPTGROUP")&&d.remove()}),t):null}initializePicker(){if(!this.containerElement)return;let t;if(this._declarativeSelectedValues&&this._declarativeSelectedValues.length>0)t=this._declarativeSelectedValues,k.debug(`[MultiSelectElement] Using ${t.length} declaratively selected values`);else{const s=this.getAttribute("initial-values");if(s)try{t=JSON.parse(s)}catch(n){k.error("[MultiSelectElement] Failed to parse initial-values:",n)}}const i={searchHint:this.getAttribute("search-hint")||void 0,searchPlaceholder:this.getAttribute("search-placeholder")||"Search...",dropdownMinWidth:this.getAttribute("dropdown-min-width")||void 0,badgesDisplayMode:this.getAttribute("badges-display-mode")||"badges",badgesPosition:this.getAttribute("badges-position")||"bottom",badgesThresholdMode:this.getAttribute("badges-threshold-mode")||"count",maxHeight:this.getAttribute("max-height")||"20rem",emptyMessage:this.getAttribute("empty-message")||"No results found",loadingMessage:this.getAttribute("loading-message")||"Loading...",searchInputMode:this.getAttribute("search-input-mode")||"normal",searchMode:this.getAttribute("search-mode")||"filter",actionsLayout:this.getAttribute("actions-layout")||"nowrap",badgesThreshold:this.getAttribute("badges-threshold")?parseInt(this.getAttribute("badges-threshold")):void 0,badgesMaxVisible:this.getAttribute("badges-max-visible")?parseInt(this.getAttribute("badges-max-visible")):void 0,minSearchLength:this.getAttribute("min-search-length")?parseInt(this.getAttribute("min-search-length")):0,isMultipleEnabled:this.getAttribute("multiple")!=="false",isGroupsAllowed:this.getAttribute("allow-groups")!=="false",isCheckboxesShown:this.getAttribute("show-checkboxes")!=="false",isActionsSticky:this.getAttribute("sticky-actions")!=="false",isCloseOnSelect:this.getAttribute("close-on-select")==="true",isPlacementLocked:this.getAttribute("lock-placement")!=="false",isSearchEnabled:this.getAttribute("enable-search")!=="false",isAddNewAllowed:this.getAttribute("allow-add-new")==="true",isCounterShown:this.getAttribute("show-counter")==="true",isKeepOptionsOnSearch:this.getAttribute("keep-options-on-search")!=="false",isVirtualScrollEnabled:this.getAttribute("enable-virtual-scroll")==="true",actionButtons:this._actionButtons,checkboxAlign:this.getAttribute("checkbox-align")||"center",virtualScrollThreshold:this.getAttribute("virtual-scroll-threshold")?parseInt(this.getAttribute("virtual-scroll-threshold")):100,optionHeight:this.getAttribute("option-height")?parseInt(this.getAttribute("option-height")):50,badgeHeight:this.getAttribute("badge-height")?parseInt(this.getAttribute("badge-height")):36,virtualScrollBuffer:this.getAttribute("virtual-scroll-buffer")?parseInt(this.getAttribute("virtual-scroll-buffer")):10,valueMember:this.getAttribute("value-member")||this._valueMember,displayValueMember:this.getAttribute("display-value-member")||this._displayValueMember,searchValueMember:this.getAttribute("search-value-member")||this._searchValueMember,iconMember:this.getAttribute("icon-member")||this._iconMember,subtitleMember:this.getAttribute("subtitle-member")||this._subtitleMember,groupMember:this.getAttribute("group-member")||this._groupMember,disabledMember:this.getAttribute("disabled-member")||this._disabledMember,getValueCallback:this._getValueCallback,getDisplayValueCallback:this._getDisplayValueCallback,getBadgeDisplayCallback:this._getBadgeDisplayCallback,getBadgeClassCallback:this._getBadgeClassCallback,customStylesCallback:this._customStylesCallback,getSearchValueCallback:this._getSearchValueCallback,getIconCallback:this._getIconCallback,getSubtitleCallback:this._getSubtitleCallback,getGroupCallback:this._getGroupCallback,getDisabledCallback:this._getDisabledCallback,renderOptionContentCallback:this._renderOptionContentCallback,renderBadgeContentCallback:this._renderBadgeContentCallback,renderSelectedItemContentCallback:this._renderSelectedItemContentCallback,getSelectedItemClassCallback:this._getSelectedItemClassCallback,renderSelectedContentCallback:this._renderSelectedContentCallback,formFieldId:this.getAttribute("name")||void 0,valueFormat:this.getAttribute("value-format")||"json",getValueFormatCallback:this._getValueFormatCallback,isBadgeTooltipsEnabled:this.getAttribute("enable-badge-tooltips")==="true",getBadgeTooltipCallback:this._getBadgeTooltipCallback,badgeTooltipPlacement:this.getAttribute("badge-tooltip-placement")||"top",badgeTooltipDelay:parseInt(this.getAttribute("badge-tooltip-delay")||"300"),badgeTooltipOffset:parseInt(this.getAttribute("badge-tooltip-offset")||"8"),getCounterCallback:this._getCounterCallback||((s,n)=>n!==void 0?`+${n} more`:`${s} selected`),options:this._options,beforeSearchCallback:this._beforeSearchCallback,searchCallback:this._searchCallback,addNewCallback:this._addNewCallback,selectCallback:s=>{var n,l;this._selectCallback&&this._selectCallback(s),this.dispatchEvent(new CustomEvent("select",{detail:{option:s,selectedOptions:(n=this.picker)==null?void 0:n.getSelected(),selectedValues:Array.from(((l=this.picker)==null?void 0:l.getValue())||[])}}))},deselectCallback:s=>{var n,l;this._deselectCallback&&this._deselectCallback(s),this.dispatchEvent(new CustomEvent("deselect",{detail:{option:s,selectedOptions:(n=this.picker)==null?void 0:n.getSelected(),selectedValues:Array.from(((l=this.picker)==null?void 0:l.getValue())||[])}}))},changeCallback:s=>{var n;this._changeCallback&&this._changeCallback(s),this.dispatchEvent(new CustomEvent("change",{detail:{selectedOptions:s,selectedValues:Array.from(((n=this.picker)==null?void 0:n.getValue())||[])}}))},container:this.shadow,hostElement:this};if(t&&(this.containerElement.dataset.initialValues=JSON.stringify(t)),this.picker=new ct(this.containerElement,i),this._customStylesCallback){const s=this._customStylesCallback();if(s){const n=document.createElement("style");n.className="ml-custom-styles",n.textContent=s,this.shadow.appendChild(n)}}}reinitialize(){this.picker&&(this.picker.destroy(),this.initializePicker())}get options(){return this._options}set options(t){this._options=t,this.reinitialize()}set valueMember(t){this._valueMember=t||void 0,t?this.setAttribute("value-member",t):this.removeAttribute("value-member")}get valueMember(){return this.getAttribute("value-member")}set displayValueMember(t){this._displayValueMember=t||void 0,t?this.setAttribute("display-value-member",t):this.removeAttribute("display-value-member")}get displayValueMember(){return this.getAttribute("display-value-member")}set searchValueMember(t){this._searchValueMember=t||void 0,t?this.setAttribute("search-value-member",t):this.removeAttribute("search-value-member")}get searchValueMember(){return this.getAttribute("search-value-member")}set iconMember(t){this._iconMember=t||void 0,t?this.setAttribute("icon-member",t):this.removeAttribute("icon-member")}get iconMember(){return this.getAttribute("icon-member")}set subtitleMember(t){this._subtitleMember=t||void 0,t?this.setAttribute("subtitle-member",t):this.removeAttribute("subtitle-member")}get subtitleMember(){return this.getAttribute("subtitle-member")}set groupMember(t){this._groupMember=t||void 0,t?this.setAttribute("group-member",t):this.removeAttribute("group-member")}get groupMember(){return this.getAttribute("group-member")}set disabledMember(t){this._disabledMember=t||void 0,t?this.setAttribute("disabled-member",t):this.removeAttribute("disabled-member")}get disabledMember(){return this.getAttribute("disabled-member")}set getValueCallback(t){this._getValueCallback=t,this.reinitialize()}get getValueCallback(){return this._getValueCallback}set getDisplayValueCallback(t){this._getDisplayValueCallback=t,this.reinitialize()}get getDisplayValueCallback(){return this._getDisplayValueCallback}set getBadgeDisplayCallback(t){this._getBadgeDisplayCallback=t,this.reinitialize()}get getBadgeDisplayCallback(){return this._getBadgeDisplayCallback}set getBadgeClassCallback(t){this._getBadgeClassCallback=t,this.reinitialize()}get getBadgeClassCallback(){return this._getBadgeClassCallback}set customStylesCallback(t){if(this._customStylesCallback=t,this.picker&&t){const i=t();if(i){const s=this.shadow.querySelector("style.ml-custom-styles");s&&s.remove();const n=document.createElement("style");n.className="ml-custom-styles",n.textContent=i,this.shadow.appendChild(n),this.picker.renderBadges()}}}get customStylesCallback(){return this._customStylesCallback}set getSearchValueCallback(t){this._getSearchValueCallback=t,this.reinitialize()}get getSearchValueCallback(){return this._getSearchValueCallback}set getIconCallback(t){this._getIconCallback=t,this.reinitialize()}get getIconCallback(){return this._getIconCallback}set getSubtitleCallback(t){this._getSubtitleCallback=t,this.reinitialize()}get getSubtitleCallback(){return this._getSubtitleCallback}set getGroupCallback(t){this._getGroupCallback=t,this.reinitialize()}get getGroupCallback(){return this._getGroupCallback}set getDisabledCallback(t){this._getDisabledCallback=t,this.reinitialize()}get getDisabledCallback(){return this._getDisabledCallback}set renderOptionContentCallback(t){this._renderOptionContentCallback=t,this.reinitialize()}get renderOptionContentCallback(){return this._renderOptionContentCallback}set renderBadgeContentCallback(t){this._renderBadgeContentCallback=t,this.reinitialize()}get renderBadgeContentCallback(){return this._renderBadgeContentCallback}set renderSelectedItemContentCallback(t){this._renderSelectedItemContentCallback=t,this.reinitialize()}get renderSelectedItemContentCallback(){return this._renderSelectedItemContentCallback}set getSelectedItemClassCallback(t){this._getSelectedItemClassCallback=t,this.reinitialize()}get getSelectedItemClassCallback(){return this._getSelectedItemClassCallback}set renderSelectedContentCallback(t){this._renderSelectedContentCallback=t,this.reinitialize()}get renderSelectedContentCallback(){return this._renderSelectedContentCallback}set name(t){t?this.setAttribute("name",t):this.removeAttribute("name")}get name(){return this.getAttribute("name")}set valueFormat(t){t?this.setAttribute("value-format",t):this.removeAttribute("value-format")}get valueFormat(){return this.getAttribute("value-format")}set getValueFormatCallback(t){this._getValueFormatCallback=t,this.reinitialize()}get getValueFormatCallback(){return this._getValueFormatCallback}set thresholdMode(t){t?this.setAttribute("threshold-mode",t):this.removeAttribute("threshold-mode")}get thresholdMode(){return this.getAttribute("threshold-mode")}set badgesMaxVisible(t){t!==null?this.setAttribute("badges-max-visible",String(t)):this.removeAttribute("badges-max-visible")}get badgesMaxVisible(){const t=this.getAttribute("badges-max-visible");return t?parseInt(t):null}set checkboxAlign(t){t?this.setAttribute("checkbox-align",t):this.removeAttribute("checkbox-align")}get checkboxAlign(){return this.getAttribute("checkbox-align")}set enableBadgeTooltips(t){t?this.setAttribute("enable-badge-tooltips","true"):this.removeAttribute("enable-badge-tooltips")}get enableBadgeTooltips(){return this.getAttribute("enable-badge-tooltips")==="true"}set badgeTooltipPlacement(t){t?this.setAttribute("badge-tooltip-placement",t):this.removeAttribute("badge-tooltip-placement")}get badgeTooltipPlacement(){return this.getAttribute("badge-tooltip-placement")}set getBadgeTooltipCallback(t){this._getBadgeTooltipCallback=t,this.reinitialize()}get getBadgeTooltipCallback(){return this._getBadgeTooltipCallback}set getCounterCallback(t){this._getCounterCallback=t,this.reinitialize()}get getCounterCallback(){return this._getCounterCallback}get beforeSearchCallback(){return this._beforeSearchCallback}set beforeSearchCallback(t){this._beforeSearchCallback=t,this.reinitialize()}get searchCallback(){return this._searchCallback}set searchCallback(t){this._searchCallback=t,this.reinitialize()}get addNewCallback(){return this._addNewCallback}set addNewCallback(t){this._addNewCallback=t,this.reinitialize()}get selectCallback(){return this._selectCallback}set selectCallback(t){this._selectCallback=t}get deselectCallback(){return this._deselectCallback}set deselectCallback(t){this._deselectCallback=t}get changeCallback(){return this._changeCallback}set changeCallback(t){this._changeCallback=t}get actionButtons(){return this._actionButtons}set actionButtons(t){this._actionButtons=t,this.reinitialize()}get selectedValue(){var t;return((t=this.picker)==null?void 0:t.selectedValue)??null}get selectedItem(){var t;return((t=this.picker)==null?void 0:t.selectedItem)??null}getSelected(){return this.picker?this.picker.getSelected():[]}setSelected(t){this.picker&&this.picker.setSelected(t)}getValue(){return this.picker?this.picker.getValue():null}destroy(){this.picker&&this.picker.destroy()}}typeof window<"u"&&typeof customElements<"u"&&(customElements.get("web-multiselect")||customElements.define("web-multiselect",Te)),typeof window<"u"&&(window.components=window.components||{},window.components["web-multiselect"]={version:()=>"1.0.0",config:{name:"@keenmate/web-multiselect",version:"1.0.0",author:"Keenmate",license:"MIT",repository:"git+https://github.com/keenmate/web-multiselect.git",homepage:"https://github.com/keenmate/web-multiselect#readme"},logging:{enableLogging:st,disableLogging:nt,setLogLevel:lt,setCategoryLevel:rt,getCategories:()=>[...ot]},register:()=>{typeof customElements<"u"&&!customElements.get("web-multiselect")&&customElements.define("web-multiselect",Te)},getInstances:()=>dt()}),x.LOGGING_CATEGORIES=ot,x.MultiSelectElement=Te,x.WebMultiSelect=ct,x.dataLogger=k,x.disableLogging=nt,x.enableLogging=st,x.initLogger=ne,x.interactionLogger=I,x.setCategoryLevel=rt,x.setLogLevel=lt,x.uiLogger=f,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
|
|
51
|
+
<span>Selected: ${r}</span>
|
|
52
|
+
<span>Dropdown: ${c?"Open":"Closed"}</span>
|
|
53
|
+
<span>Search: ${d||"none"}</span>
|
|
54
|
+
<span>Loading: ${m?"Yes":"No"}</span>
|
|
55
|
+
`,setTimeout(()=>{this.getAttribute("show-debug-info")==="true"&&this.updateDebugInfo()},500)}parseDeclarativeOptions(){var n,r,a,l;const t=[],s=Array.from(this.children);if(s.length===0)return null;let o=!1;for(const c of s)if(c.tagName==="OPTION"){const d=c,m={value:d.value||((n=d.textContent)==null?void 0:n.trim())||"",label:((r=d.textContent)==null?void 0:r.trim())||d.value||""};d.hasAttribute("selected")&&(this._declarativeSelectedValues||(this._declarativeSelectedValues=[]),this._declarativeSelectedValues.push(m.value)),d.hasAttribute("disabled")&&(m.disabled=!0),d.hasAttribute("data-icon")&&(m.icon=d.getAttribute("data-icon")),d.hasAttribute("data-subtitle")&&(m.subtitle=d.getAttribute("data-subtitle")),t.push(m),o=!0}else if(c.tagName==="OPTGROUP"){const d=c,m=d.label||d.getAttribute("label")||"Group",u=Array.from(d.querySelectorAll("option"));for(const h of u){const g={value:h.value||((a=h.textContent)==null?void 0:a.trim())||"",label:((l=h.textContent)==null?void 0:l.trim())||h.value||"",group:m};h.hasAttribute("selected")&&(this._declarativeSelectedValues||(this._declarativeSelectedValues=[]),this._declarativeSelectedValues.push(g.value)),h.hasAttribute("disabled")&&(g.disabled=!0),h.hasAttribute("data-icon")&&(g.icon=h.getAttribute("data-icon")),h.hasAttribute("data-subtitle")&&(g.subtitle=h.getAttribute("data-subtitle")),t.push(g),o=!0}}return o?(k.debug(`[MultiSelectElement] Parsed ${t.length} declarative options from Light DOM`),s.forEach(c=>{(c.tagName==="OPTION"||c.tagName==="OPTGROUP")&&c.remove()}),t):null}initializePicker(){if(!this.containerElement)return;let t;if(this._declarativeSelectedValues&&this._declarativeSelectedValues.length>0)t=this._declarativeSelectedValues,k.debug(`[MultiSelectElement] Using ${t.length} declaratively selected values`);else{const o=this.getAttribute("initial-values");if(o)try{t=JSON.parse(o)}catch(n){k.error("[MultiSelectElement] Failed to parse initial-values:",n)}}const s={searchHint:this.getAttribute("search-hint")||void 0,searchPlaceholder:this.getAttribute("search-placeholder")||"Search...",dropdownMinWidth:this.getAttribute("dropdown-min-width")||void 0,badgesDisplayMode:this.getAttribute("badges-display-mode")||"badges",badgesPosition:this.getAttribute("badges-position")||"bottom",badgesThresholdMode:this.getAttribute("badges-threshold-mode")||"count",maxHeight:this.getAttribute("max-height")||"20rem",emptyMessage:this.getAttribute("empty-message")||"No results found",loadingMessage:this.getAttribute("loading-message")||"Loading...",searchInputMode:this.getAttribute("search-input-mode")||"normal",searchMode:this.getAttribute("search-mode")||"filter",actionsLayout:this.getAttribute("actions-layout")||"nowrap",badgesThreshold:this.getAttribute("badges-threshold")?parseInt(this.getAttribute("badges-threshold")):void 0,badgesMaxVisible:this.getAttribute("badges-max-visible")?parseInt(this.getAttribute("badges-max-visible")):void 0,minSearchLength:this.getAttribute("min-search-length")?parseInt(this.getAttribute("min-search-length")):0,isMultipleEnabled:this.getAttribute("multiple")!=="false",isGroupsAllowed:this.getAttribute("allow-groups")!=="false",isCheckboxesShown:this.getAttribute("show-checkboxes")!=="false",isActionsSticky:this.getAttribute("sticky-actions")!=="false",isCloseOnSelect:this.getAttribute("close-on-select")==="true",isPlacementLocked:this.getAttribute("lock-placement")!=="false",isSearchEnabled:this.getAttribute("enable-search")!=="false",isAddNewAllowed:this.getAttribute("allow-add-new")==="true",isCounterShown:this.getAttribute("show-counter")==="true",isKeepOptionsOnSearch:this.getAttribute("keep-options-on-search")!=="false",isVirtualScrollEnabled:this.getAttribute("enable-virtual-scroll")==="true",actionButtons:this._actionButtons,checkboxAlign:this.getAttribute("checkbox-align")||"center",virtualScrollThreshold:this.getAttribute("virtual-scroll-threshold")?parseInt(this.getAttribute("virtual-scroll-threshold")):100,optionHeight:this.getAttribute("option-height")?parseInt(this.getAttribute("option-height")):50,badgeHeight:this.getAttribute("badge-height")?parseInt(this.getAttribute("badge-height")):36,virtualScrollBuffer:this.getAttribute("virtual-scroll-buffer")?parseInt(this.getAttribute("virtual-scroll-buffer")):10,valueMember:this.getAttribute("value-member")||this._valueMember,displayValueMember:this.getAttribute("display-value-member")||this._displayValueMember,searchValueMember:this.getAttribute("search-value-member")||this._searchValueMember,iconMember:this.getAttribute("icon-member")||this._iconMember,subtitleMember:this.getAttribute("subtitle-member")||this._subtitleMember,groupMember:this.getAttribute("group-member")||this._groupMember,disabledMember:this.getAttribute("disabled-member")||this._disabledMember,getValueCallback:this._getValueCallback,getDisplayValueCallback:this._getDisplayValueCallback,getBadgeDisplayCallback:this._getBadgeDisplayCallback,getBadgeClassCallback:this._getBadgeClassCallback,customStylesCallback:this._customStylesCallback,getSearchValueCallback:this._getSearchValueCallback,getIconCallback:this._getIconCallback,getSubtitleCallback:this._getSubtitleCallback,getGroupCallback:this._getGroupCallback,renderGroupLabelContentCallback:this._renderGroupLabelContentCallback,getDisabledCallback:this._getDisabledCallback,renderOptionContentCallback:this._renderOptionContentCallback,renderBadgeContentCallback:this._renderBadgeContentCallback,renderSelectedItemContentCallback:this._renderSelectedItemContentCallback,getSelectedItemClassCallback:this._getSelectedItemClassCallback,renderSelectedContentCallback:this._renderSelectedContentCallback,formFieldId:this.getAttribute("name")||void 0,valueFormat:this.getAttribute("value-format")||"json",getValueFormatCallback:this._getValueFormatCallback,isBadgeTooltipsEnabled:this.getAttribute("enable-badge-tooltips")==="true",getBadgeTooltipCallback:this._getBadgeTooltipCallback,badgeTooltipPlacement:this.getAttribute("badge-tooltip-placement")||"top",badgeTooltipDelay:parseInt(this.getAttribute("badge-tooltip-delay")||"300"),badgeTooltipOffset:parseInt(this.getAttribute("badge-tooltip-offset")||"8"),getCounterCallback:this._getCounterCallback||((o,n)=>n!==void 0?`+${n} more`:`${o} selected`),options:this._options,beforeSearchCallback:this._beforeSearchCallback,searchCallback:this._searchCallback,addNewCallback:this._addNewCallback,selectCallback:o=>{var n;this._selectCallback&&this._selectCallback(o),this.dispatchEvent(new CustomEvent("select",{detail:{option:o,selectedOptions:(n=this.picker)==null?void 0:n.getSelected(),selectedValues:(()=>{var a;const r=(a=this.picker)==null?void 0:a.getValue();return r==null?[]:Array.isArray(r)?r:[r]})()}}))},deselectCallback:o=>{var n;this._deselectCallback&&this._deselectCallback(o),this.dispatchEvent(new CustomEvent("deselect",{detail:{option:o,selectedOptions:(n=this.picker)==null?void 0:n.getSelected(),selectedValues:(()=>{var a;const r=(a=this.picker)==null?void 0:a.getValue();return r==null?[]:Array.isArray(r)?r:[r]})()}}))},changeCallback:o=>{this._changeCallback&&this._changeCallback(o),this.dispatchEvent(new CustomEvent("change",{detail:{selectedOptions:o,selectedValues:(()=>{var r;const n=(r=this.picker)==null?void 0:r.getValue();return n==null?[]:Array.isArray(n)?n:[n]})()}}))},container:this.shadow,hostElement:this};if(t&&(this.containerElement.dataset.initialValues=JSON.stringify(t)),this.picker=new ct(this.containerElement,s),this._customStylesCallback){const o=this._customStylesCallback();if(o){const n=document.createElement("style");n.className="ml-custom-styles",n.textContent=o,this.shadow.appendChild(n)}}}reinitialize(){this.picker&&(this.picker.destroy(),this.initializePicker())}get options(){return this._options}set options(t){this._options=t,this.reinitialize()}set valueMember(t){this._valueMember=t||void 0,t?this.setAttribute("value-member",t):this.removeAttribute("value-member")}get valueMember(){return this.getAttribute("value-member")}set displayValueMember(t){this._displayValueMember=t||void 0,t?this.setAttribute("display-value-member",t):this.removeAttribute("display-value-member")}get displayValueMember(){return this.getAttribute("display-value-member")}set searchValueMember(t){this._searchValueMember=t||void 0,t?this.setAttribute("search-value-member",t):this.removeAttribute("search-value-member")}get searchValueMember(){return this.getAttribute("search-value-member")}set iconMember(t){this._iconMember=t||void 0,t?this.setAttribute("icon-member",t):this.removeAttribute("icon-member")}get iconMember(){return this.getAttribute("icon-member")}set subtitleMember(t){this._subtitleMember=t||void 0,t?this.setAttribute("subtitle-member",t):this.removeAttribute("subtitle-member")}get subtitleMember(){return this.getAttribute("subtitle-member")}set groupMember(t){this._groupMember=t||void 0,t?this.setAttribute("group-member",t):this.removeAttribute("group-member")}get groupMember(){return this.getAttribute("group-member")}set disabledMember(t){this._disabledMember=t||void 0,t?this.setAttribute("disabled-member",t):this.removeAttribute("disabled-member")}get disabledMember(){return this.getAttribute("disabled-member")}set getValueCallback(t){this._getValueCallback=t,this.reinitialize()}get getValueCallback(){return this._getValueCallback}set getDisplayValueCallback(t){this._getDisplayValueCallback=t,this.reinitialize()}get getDisplayValueCallback(){return this._getDisplayValueCallback}set getBadgeDisplayCallback(t){this._getBadgeDisplayCallback=t,this.reinitialize()}get getBadgeDisplayCallback(){return this._getBadgeDisplayCallback}set getBadgeClassCallback(t){this._getBadgeClassCallback=t,this.reinitialize()}get getBadgeClassCallback(){return this._getBadgeClassCallback}set customStylesCallback(t){if(this._customStylesCallback=t,this.picker&&t){const s=t();if(s){const o=this.shadow.querySelector("style.ml-custom-styles");o&&o.remove();const n=document.createElement("style");n.className="ml-custom-styles",n.textContent=s,this.shadow.appendChild(n),this.picker.renderBadges()}}}get customStylesCallback(){return this._customStylesCallback}set getSearchValueCallback(t){this._getSearchValueCallback=t,this.reinitialize()}get getSearchValueCallback(){return this._getSearchValueCallback}set getIconCallback(t){this._getIconCallback=t,this.reinitialize()}get getIconCallback(){return this._getIconCallback}set getSubtitleCallback(t){this._getSubtitleCallback=t,this.reinitialize()}get getSubtitleCallback(){return this._getSubtitleCallback}set getGroupCallback(t){this._getGroupCallback=t,this.reinitialize()}get getGroupCallback(){return this._getGroupCallback}set renderGroupLabelContentCallback(t){this._renderGroupLabelContentCallback=t,this.reinitialize()}get renderGroupLabelContentCallback(){return this._renderGroupLabelContentCallback}set getDisabledCallback(t){this._getDisabledCallback=t,this.reinitialize()}get getDisabledCallback(){return this._getDisabledCallback}set renderOptionContentCallback(t){this._renderOptionContentCallback=t,this.reinitialize()}get renderOptionContentCallback(){return this._renderOptionContentCallback}set renderBadgeContentCallback(t){this._renderBadgeContentCallback=t,this.reinitialize()}get renderBadgeContentCallback(){return this._renderBadgeContentCallback}set renderSelectedItemContentCallback(t){this._renderSelectedItemContentCallback=t,this.reinitialize()}get renderSelectedItemContentCallback(){return this._renderSelectedItemContentCallback}set getSelectedItemClassCallback(t){this._getSelectedItemClassCallback=t,this.reinitialize()}get getSelectedItemClassCallback(){return this._getSelectedItemClassCallback}set renderSelectedContentCallback(t){this._renderSelectedContentCallback=t,this.reinitialize()}get renderSelectedContentCallback(){return this._renderSelectedContentCallback}set name(t){t?this.setAttribute("name",t):this.removeAttribute("name")}get name(){return this.getAttribute("name")}set valueFormat(t){t?this.setAttribute("value-format",t):this.removeAttribute("value-format")}get valueFormat(){return this.getAttribute("value-format")}set getValueFormatCallback(t){this._getValueFormatCallback=t,this.reinitialize()}get getValueFormatCallback(){return this._getValueFormatCallback}set thresholdMode(t){t?this.setAttribute("threshold-mode",t):this.removeAttribute("threshold-mode")}get thresholdMode(){return this.getAttribute("threshold-mode")}set badgesMaxVisible(t){t!==null?this.setAttribute("badges-max-visible",String(t)):this.removeAttribute("badges-max-visible")}get badgesMaxVisible(){const t=this.getAttribute("badges-max-visible");return t?parseInt(t):null}set checkboxAlign(t){t?this.setAttribute("checkbox-align",t):this.removeAttribute("checkbox-align")}get checkboxAlign(){return this.getAttribute("checkbox-align")}set enableBadgeTooltips(t){t?this.setAttribute("enable-badge-tooltips","true"):this.removeAttribute("enable-badge-tooltips")}get enableBadgeTooltips(){return this.getAttribute("enable-badge-tooltips")==="true"}set badgeTooltipPlacement(t){t?this.setAttribute("badge-tooltip-placement",t):this.removeAttribute("badge-tooltip-placement")}get badgeTooltipPlacement(){return this.getAttribute("badge-tooltip-placement")}set getBadgeTooltipCallback(t){this._getBadgeTooltipCallback=t,this.reinitialize()}get getBadgeTooltipCallback(){return this._getBadgeTooltipCallback}set getCounterCallback(t){this._getCounterCallback=t,this.reinitialize()}get getCounterCallback(){return this._getCounterCallback}get beforeSearchCallback(){return this._beforeSearchCallback}set beforeSearchCallback(t){this._beforeSearchCallback=t,this.reinitialize()}get searchCallback(){return this._searchCallback}set searchCallback(t){this._searchCallback=t,this.reinitialize()}get addNewCallback(){return this._addNewCallback}set addNewCallback(t){this._addNewCallback=t,this.reinitialize()}get selectCallback(){return this._selectCallback}set selectCallback(t){this._selectCallback=t}get deselectCallback(){return this._deselectCallback}set deselectCallback(t){this._deselectCallback=t}get changeCallback(){return this._changeCallback}set changeCallback(t){this._changeCallback=t}get actionButtons(){return this._actionButtons}set actionButtons(t){this._actionButtons=t,this.reinitialize()}get selectedValue(){var t;return((t=this.picker)==null?void 0:t.selectedValue)??null}get selectedItem(){var t;return((t=this.picker)==null?void 0:t.selectedItem)??null}getSelected(){return this.picker?this.picker.getSelected():[]}setSelected(t){this.picker&&this.picker.setSelected(t)}getValue(){return this.picker?this.picker.getValue():null}destroy(){this.picker&&this.picker.destroy()}}typeof window<"u"&&typeof customElements<"u"&&(customElements.get("web-multiselect")||customElements.define("web-multiselect",Te)),typeof window<"u"&&(window.components=window.components||{},window.components["web-multiselect"]={version:()=>"1.1.0",config:{name:"@keenmate/web-multiselect",version:"1.1.0",author:"Keenmate",license:"MIT",repository:"git+https://github.com/keenmate/web-multiselect.git",homepage:"https://github.com/keenmate/web-multiselect#readme"},logging:{enableLogging:ot,disableLogging:nt,setLogLevel:rt,setCategoryLevel:at,getCategories:()=>[...it]},register:()=>{typeof customElements<"u"&&!customElements.get("web-multiselect")&&customElements.define("web-multiselect",Te)},getInstances:()=>dt()}),x.LOGGING_CATEGORIES=it,x.MultiSelectElement=Te,x.WebMultiSelect=ct,x.dataLogger=k,x.disableLogging=nt,x.enableLogging=ot,x.initLogger=ne,x.interactionLogger=A,x.setCategoryLevel=at,x.setLogLevel=rt,x.uiLogger=f,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
|