var Ht=Math.min,vt=Math.max,Wt=Math.round;var st=i=>({x:i,y:i}),Ji={left:"right",right:"left",bottom:"top",top:"bottom"};function De(i,t,e){return vt(i,Ht(t,e))}function Vt(i,t){return typeof i=="function"?i(t):i}function yt(i){return i.split("-")[0]}function zt(i){return i.split("-")[1]}function Ae(i){return i==="x"?"y":"x"}function Ce(i){return i==="y"?"height":"width"}function ht(i){let t=i[0];return t==="t"||t==="b"?"y":"x"}function Le(i){return Ae(ht(i))}function Qe(i,t,e){e===void 0&&(e=!1);let n=zt(i),o=Le(i),s=Ce(o),r=o==="x"?n===(e?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(r=Ft(r)),[r,Ft(r)]}function Ze(i){let t=Ft(i);return[ne(i),t,ne(t)]}function ne(i){return i.includes("start")?i.replace("start","end"):i.replace("end","start")}var qe=["left","right"],Je=["right","left"],Qi=["top","bottom"],Zi=["bottom","top"];function tn(i,t,e){switch(i){case"top":case"bottom":return e?t?Je:qe:t?qe:Je;case"left":case"right":return t?Qi:Zi;default:return[]}}function ti(i,t,e,n){let o=zt(i),s=tn(yt(i),e==="start",n);return o&&(s=s.map(r=>r+"-"+o),t&&(s=s.concat(s.map(ne)))),s}function Ft(i){let t=yt(i);return Ji[t]+i.slice(t.length)}function en(i){return{top:0,right:0,bottom:0,left:0,...i}}function ei(i){return typeof i!="number"?en(i):{top:i,right:i,bottom:i,left:i}}function Ot(i){let{x:t,y:e,width:n,height:o}=i;return{width:n,height:o,top:e,left:t,right:t+n,bottom:e+o,x:t,y:e}}function ii(i,t,e){let{reference:n,floating:o}=i,s=ht(t),r=Le(t),a=Ce(r),l=yt(t),c=s==="y",f=n.x+n.width/2-o.width/2,d=n.y+n.height/2-o.height/2,u=n[a]/2-o[a]/2,p;switch(l){case"top":p={x:f,y:n.y-o.height};break;case"bottom":p={x:f,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:d};break;case"left":p={x:n.x-o.width,y:d};break;default:p={x:n.x,y:n.y}}switch(zt(t)){case"start":p[r]-=u*(e&&c?-1:1);break;case"end":p[r]+=u*(e&&c?-1:1);break}return p}async function ni(i,t){var e;t===void 0&&(t={});let{x:n,y:o,platform:s,rects:r,elements:a,strategy:l}=i,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:u=!1,padding:p=0}=Vt(t,i),g=ei(p),x=a[u?d==="floating"?"reference":"floating":d],D=Ot(await s.getClippingRect({element:(e=await(s.isElement==null?void 0:s.isElement(x)))==null||e?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:f,strategy:l})),w=d==="floating"?{x:n,y:o,width:r.floating.width,height:r.floating.height}:r.reference,A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(A))?await(s.getScale==null?void 0:s.getScale(A))||{x:1,y:1}:{x:1,y:1},M=Ot(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:A,strategy:l}):w);return{top:(D.top-M.top+g.top)/E.y,bottom:(M.bottom-D.bottom+g.bottom)/E.y,left:(D.left-M.left+g.left)/E.x,right:(M.right-D.right+g.right)/E.x}}var nn=50,oi=async(i,t,e)=>{let{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:r}=e,a=r.detectOverflow?r:{...r,detectOverflow:ni},l=await(r.isRTL==null?void 0:r.isRTL(t)),c=await r.getElementRects({reference:i,floating:t,strategy:o}),{x:f,y:d}=ii(c,n,l),u=n,p=0,g={};for(let m=0;mH<=0)){var L,K;let H=(((L=s.flip)==null?void 0:L.index)||0)+1,tt=q[H];if(tt&&(!(d==="alignment"?w!==ht(tt):!1)||V.every(F=>ht(F.placement)===w?F.overflows[0]>0:!0)))return{data:{index:H,overflows:V},reset:{placement:tt}};let z=(K=V.filter(Y=>Y.overflows[0]<=0).sort((Y,F)=>Y.overflows[1]-F.overflows[1])[0])==null?void 0:K.placement;if(!z)switch(p){case"bestFit":{var N;let Y=(N=V.filter(F=>{if(C){let et=ht(F.placement);return et===w||et==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(et=>et>0).reduce((et,ie)=>et+ie,0)]).sort((F,et)=>F[1]-et[1])[0])==null?void 0:N[0];Y&&(z=Y);break}case"initialPlacement":z=a;break}if(o!==z)return{reset:{placement:z}}}return{}}}};var on=new Set(["left","top"]);async function sn(i,t){let{placement:e,platform:n,elements:o}=i,s=await(n.isRTL==null?void 0:n.isRTL(o.floating)),r=yt(e),a=zt(e),l=ht(e)==="y",c=on.has(r)?-1:1,f=s&&l?-1:1,d=Vt(t,i),{mainAxis:u,crossAxis:p,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof g=="number"&&(p=a==="end"?g*-1:g),l?{x:p*f,y:u*c}:{x:u*c,y:p*f}}var ri=function(i){return i===void 0&&(i=0),{name:"offset",options:i,async fn(t){var e,n;let{x:o,y:s,placement:r,middlewareData:a}=t,l=await sn(t,i);return r===((e=a.offset)==null?void 0:e.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:r}}}}},ai=function(i){return i===void 0&&(i={}),{name:"shift",options:i,async fn(t){let{x:e,y:n,placement:o,platform:s}=t,{mainAxis:r=!0,crossAxis:a=!1,limiter:l={fn:D=>{let{x:w,y:A}=D;return{x:w,y:A}}},...c}=Vt(i,t),f={x:e,y:n},d=await s.detectOverflow(t,c),u=ht(yt(o)),p=Ae(u),g=f[p],m=f[u];if(r){let D=p==="y"?"top":"left",w=p==="y"?"bottom":"right",A=g+d[D],E=g-d[w];g=De(A,g,E)}if(a){let D=u==="y"?"top":"left",w=u==="y"?"bottom":"right",A=m+d[D],E=m-d[w];m=De(A,m,E)}let x=l.fn({...t,[p]:g,[u]:m});return{...x,data:{x:x.x-e,y:x.y-n,enabled:{[p]:r,[u]:a}}}}}};function se(){return typeof window<"u"}function Dt(i){return ci(i)?(i.nodeName||"").toLowerCase():"#document"}function U(i){var t;return(i==null||(t=i.ownerDocument)==null?void 0:t.defaultView)||window}function lt(i){var t;return(t=(ci(i)?i.ownerDocument:i.document)||window.document)==null?void 0:t.documentElement}function ci(i){return se()?i instanceof Node||i instanceof U(i).Node:!1}function it(i){return se()?i instanceof Element||i instanceof U(i).Element:!1}function ct(i){return se()?i instanceof HTMLElement||i instanceof U(i).HTMLElement:!1}function li(i){return!se()||typeof ShadowRoot>"u"?!1:i instanceof ShadowRoot||i instanceof U(i).ShadowRoot}function Tt(i){let{overflow:t,overflowX:e,overflowY:n,display:o}=nt(i);return/auto|scroll|overlay|hidden|clip/.test(t+n+e)&&o!=="inline"&&o!=="contents"}function di(i){return/^(table|td|th)$/.test(Dt(i))}function $t(i){try{if(i.matches(":popover-open"))return!0}catch{}try{return i.matches(":modal")}catch{return!1}}var rn=/transform|translate|scale|rotate|perspective|filter/,an=/paint|layout|strict|content/,Et=i=>!!i&&i!=="none",Ie;function re(i){let t=it(i)?nt(i):i;return Et(t.transform)||Et(t.translate)||Et(t.scale)||Et(t.rotate)||Et(t.perspective)||!ae()&&(Et(t.backdropFilter)||Et(t.filter))||rn.test(t.willChange||"")||an.test(t.contain||"")}function fi(i){let t=ut(i);for(;ct(t)&&!At(t);){if(re(t))return t;if($t(t))return null;t=ut(t)}return null}function ae(){return Ie==null&&(Ie=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ie}function At(i){return/^(html|body|#document)$/.test(Dt(i))}function nt(i){return U(i).getComputedStyle(i)}function Kt(i){return it(i)?{scrollLeft:i.scrollLeft,scrollTop:i.scrollTop}:{scrollLeft:i.scrollX,scrollTop:i.scrollY}}function ut(i){if(Dt(i)==="html")return i;let t=i.assignedSlot||i.parentNode||li(i)&&i.host||lt(i);return li(t)?t.host:t}function hi(i){let t=ut(i);return At(t)?i.ownerDocument?i.ownerDocument.body:i.body:ct(t)&&Tt(t)?t:hi(t)}function oe(i,t,e){var n;t===void 0&&(t=[]),e===void 0&&(e=!0);let o=hi(i),s=o===((n=i.ownerDocument)==null?void 0:n.body),r=U(o);if(s){let a=le(r);return t.concat(r,r.visualViewport||[],Tt(o)?o:[],a&&e?oe(a):[])}else return t.concat(o,oe(o,[],e))}function le(i){return i.parent&&Object.getPrototypeOf(i.parent)?i.frameElement:null}function mi(i){let t=nt(i),e=parseFloat(t.width)||0,n=parseFloat(t.height)||0,o=ct(i),s=o?i.offsetWidth:e,r=o?i.offsetHeight:n,a=Wt(e)!==s||Wt(n)!==r;return a&&(e=s,n=r),{width:e,height:n,$:a}}function bi(i){return it(i)?i:i.contextElement}function Rt(i){let t=bi(i);if(!ct(t))return st(1);let e=t.getBoundingClientRect(),{width:n,height:o,$:s}=mi(t),r=(s?Wt(e.width):e.width)/n,a=(s?Wt(e.height):e.height)/o;return(!r||!Number.isFinite(r))&&(r=1),(!a||!Number.isFinite(a))&&(a=1),{x:r,y:a}}var ln=st(0);function vi(i){let t=U(i);return!ae()||!t.visualViewport?ln:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function cn(i,t,e){return t===void 0&&(t=!1),!e||t&&e!==U(i)?!1:t}function Xt(i,t,e,n){t===void 0&&(t=!1),e===void 0&&(e=!1);let o=i.getBoundingClientRect(),s=bi(i),r=st(1);t&&(n?it(n)&&(r=Rt(n)):r=Rt(i));let a=cn(s,e,n)?vi(s):st(0),l=(o.left+a.x)/r.x,c=(o.top+a.y)/r.y,f=o.width/r.x,d=o.height/r.y;if(s){let u=U(s),p=n&&it(n)?U(n):n,g=u,m=le(g);for(;m&&n&&p!==g;){let x=Rt(m),D=m.getBoundingClientRect(),w=nt(m),A=D.left+(m.clientLeft+parseFloat(w.paddingLeft))*x.x,E=D.top+(m.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,f*=x.x,d*=x.y,l+=A,c+=E,g=U(m),m=le(g)}}return Ot({width:f,height:d,x:l,y:c})}function ce(i,t){let e=Kt(i).scrollLeft;return t?t.left+e:Xt(lt(i)).left+e}function yi(i,t){let e=i.getBoundingClientRect(),n=e.left+t.scrollLeft-ce(i,e),o=e.top+t.scrollTop;return{x:n,y:o}}function dn(i){let{elements:t,rect:e,offsetParent:n,strategy:o}=i,s=o==="fixed",r=lt(n),a=t?$t(t.floating):!1;if(n===r||a&&s)return e;let l={scrollLeft:0,scrollTop:0},c=st(1),f=st(0),d=ct(n);if((d||!d&&!s)&&((Dt(n)!=="body"||Tt(r))&&(l=Kt(n)),d)){let p=Xt(n);c=Rt(n),f.x=p.x+n.clientLeft,f.y=p.y+n.clientTop}let u=r&&!d&&!s?yi(r,l):st(0);return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-l.scrollLeft*c.x+f.x+u.x,y:e.y*c.y-l.scrollTop*c.y+f.y+u.y}}function fn(i){return Array.from(i.getClientRects())}function hn(i){let t=lt(i),e=Kt(i),n=i.ownerDocument.body,o=vt(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=vt(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight),r=-e.scrollLeft+ce(i),a=-e.scrollTop;return nt(n).direction==="rtl"&&(r+=vt(t.clientWidth,n.clientWidth)-o),{width:o,height:s,x:r,y:a}}var ui=25;function un(i,t){let e=U(i),n=lt(i),o=e.visualViewport,s=n.clientWidth,r=n.clientHeight,a=0,l=0;if(o){s=o.width,r=o.height;let f=ae();(!f||f&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}let c=ce(n);if(c<=0){let f=n.ownerDocument,d=f.body,u=getComputedStyle(d),p=f.compatMode==="CSS1Compat"&&parseFloat(u.marginLeft)+parseFloat(u.marginRight)||0,g=Math.abs(n.clientWidth-d.clientWidth-p);g<=ui&&(s-=g)}else c<=ui&&(s+=c);return{width:s,height:r,x:a,y:l}}function pn(i,t){let e=Xt(i,!0,t==="fixed"),n=e.top+i.clientTop,o=e.left+i.clientLeft,s=ct(i)?Rt(i):st(1),r=i.clientWidth*s.x,a=i.clientHeight*s.y,l=o*s.x,c=n*s.y;return{width:r,height:a,x:l,y:c}}function pi(i,t,e){let n;if(t==="viewport")n=un(i,e);else if(t==="document")n=hn(lt(i));else if(it(t))n=pn(t,e);else{let o=vi(i);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ot(n)}function wi(i,t){let e=ut(i);return e===t||!it(e)||At(e)?!1:nt(e).position==="fixed"||wi(e,t)}function gn(i,t){let e=t.get(i);if(e)return e;let n=oe(i,[],!1).filter(a=>it(a)&&Dt(a)!=="body"),o=null,s=nt(i).position==="fixed",r=s?ut(i):i;for(;it(r)&&!At(r);){let a=nt(r),l=re(r);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Tt(r)&&!l&&wi(i,r))?n=n.filter(f=>f!==r):o=a,r=ut(r)}return t.set(i,n),n}function mn(i){let{element:t,boundary:e,rootBoundary:n,strategy:o}=i,r=[...e==="clippingAncestors"?$t(t)?[]:gn(t,this._c):[].concat(e),n],a=pi(t,r[0],o),l=a.top,c=a.right,f=a.bottom,d=a.left;for(let u=1;u{let n=new Map,o={platform:Sn,...e},s={...o.platform,_c:n};return oi(i,t,{...o,platform:s})};function xn(i,t,e){return(t=An(t))in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}function gt(){return gt=Object.assign?Object.assign.bind():function(i){for(var t=1;t"&&(t=t.substring(1)),i)try{if(i.matches)return i.matches(t);if(i.msMatchesSelector)return i.msMatchesSelector(t);if(i.webkitMatchesSelector)return i.webkitMatchesSelector(t)}catch{return!1}return!1}}function Bi(i){return i.host&&i!==document&&i.host.nodeType&&i.host!==i?i.host:i.parentNode}function at(i,t,e,n){if(i){e=e||document;do{if(t!=null&&(t[0]===">"?i.parentNode===e&&ve(i,t):ve(i,t))||n&&i===e)return i;if(i===e)break}while(i=Bi(i))}return null}var Li=/\s+/g;function Q(i,t,e){if(i&&t)if(i.classList)i.classList[e?"add":"remove"](t);else{var n=(" "+i.className+" ").replace(Li," ").replace(" "+t+" "," ");i.className=(n+(e?" "+t:"")).replace(Li," ")}}function b(i,t,e){var n=i&&i.style;if(n){if(e===void 0)return document.defaultView&&document.defaultView.getComputedStyle?e=document.defaultView.getComputedStyle(i,""):i.currentStyle&&(e=i.currentStyle),t===void 0?e:e[t];!(t in n)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),n[t]=e+(typeof e=="string"?"":"px")}}function kt(i,t){var e="";if(typeof i=="string")e=i;else do{var n=b(i,"transform");n&&n!=="none"&&(e=n+" "+e)}while(!t&&(i=i.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(e)}function Fi(i,t,e){if(i){var n=i.getElementsByTagName(t),o=0,s=n.length;if(e)for(;o=s:r=o<=s,!r)return n;if(n===dt())break;n=xt(n,!1)}return!1}function Bt(i,t,e,n){for(var o=0,s=0,r=i.children;s2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=On(n,Nn);ee.pluginEvent.bind(v)(t,e,ft({dragEl:h,parentEl:_,ghostEl:y,rootEl:I,nextEl:It,lastDownEl:pe,cloneEl:T,cloneHidden:St,dragStarted:Yt,putSortable:W,activeSortable:v.active,originalEvent:o,oldIndex:Nt,oldDraggableIndex:Jt,newIndex:Z,newDraggableIndex:wt,hideGhostForTarget:Yi,unhideGhostForTarget:Ui,cloneNowHidden:function(){St=!0},cloneNowShown:function(){St=!1},dispatchSortableEvent:function(a){X({sortable:e,name:a,originalEvent:o})}},s))};function X(i){Mn(ft({putSortable:W,cloneEl:T,targetEl:h,rootEl:I,oldIndex:Nt,oldDraggableIndex:Jt,newIndex:Z,newDraggableIndex:wt},i))}var h,_,y,I,It,pe,T,St,Nt,Z,Jt,wt,de,W,Mt=!1,ye=!1,we=[],Ct,rt,Pe,Me,Ri,_i,Yt,Pt,Qt,Zt=!1,fe=!1,ge,$,Ne=[],Ve=!1,Se=[],Oe=typeof document<"u",he=Xe,Pi=te||mt?"cssFloat":"float",kn=Oe&&!Ni&&!Xe&&"draggable"in document.createElement("div"),$i=(function(){if(Oe){if(mt)return!1;var i=document.createElement("x");return i.style.cssText="pointer-events:auto",i.style.pointerEvents==="auto"}})(),Ki=function(t,e){var n=b(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=Bt(t,0,e),r=Bt(t,1,e),a=s&&b(s),l=r&&b(r),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+B(s).width,f=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+B(r).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var d=a.float==="left"?"left":"right";return r&&(l.clear==="both"||l.clear===d)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=o&&n[Pi]==="none"||r&&n[Pi]==="none"&&c+f>o)?"vertical":"horizontal"},Bn=function(t,e,n){var o=n?t.left:t.top,s=n?t.right:t.bottom,r=n?t.width:t.height,a=n?e.left:e.top,l=n?e.right:e.bottom,c=n?e.width:e.height;return o===a||s===l||o+r/2===a+c/2},Fn=function(t,e){var n;return we.some(function(o){var s=o[G].options.emptyInsertThreshold;if(!(!s||Ye(o))){var r=B(o),a=t>=r.left-s&&t<=r.right+s,l=e>=r.top-s&&e<=r.bottom+s;if(a&&l)return n=o}}),n},Xi=function(t){function e(s,r){return function(a,l,c,f){var d=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(r||d))return!0;if(s==null||s===!1)return!1;if(r&&s==="clone")return s;if(typeof s=="function")return e(s(a,l,c,f),r)(a,l,c,f);var u=(r?a:l).options.group.name;return s===!0||typeof s=="string"&&s===u||s.join&&s.indexOf(u)>-1}}var n={},o=t.group;(!o||We(o)!="object")&&(o={name:o}),n.name=o.name,n.checkPull=e(o.pull,!0),n.checkPut=e(o.put),n.revertClone=o.revertClone,t.group=n},Yi=function(){!$i&&y&&b(y,"display","none")},Ui=function(){!$i&&y&&b(y,"display","")};Oe&&!Ni&&document.addEventListener("click",function(i){if(ye)return i.preventDefault(),i.stopPropagation&&i.stopPropagation(),i.stopImmediatePropagation&&i.stopImmediatePropagation(),ye=!1,!1},!0);var Lt=function(t){if(h){t=t.touches?t.touches[0]:t;var e=Fn(t.clientX,t.clientY);if(e){var n={};for(var o in t)t.hasOwnProperty(o)&&(n[o]=t[o]);n.target=n.rootEl=e,n.preventDefault=void 0,n.stopPropagation=void 0,e[G]._onDragOver(n)}}},Hn=function(t){h&&h.parentNode[G]._isOutsideThisEl(t.target)};function v(i,t){if(!(i&&i.nodeType&&i.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(i));this.el=i,this.options=t=gt({},t),i[G]=this;var e={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(i.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Ki(i,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(r,a){r.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:v.supportPointer!==!1&&"PointerEvent"in window&&(!Gt||Xe),emptyInsertThreshold:5};ee.initializePlugins(this,i,e);for(var n in e)!(n in t)&&(t[n]=e[n]);Xi(t);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=t.forceFallback?!1:kn,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?O(i,"pointerdown",this._onTapStart):(O(i,"mousedown",this._onTapStart),O(i,"touchstart",this._onTapStart)),this.nativeDraggable&&(O(i,"dragover",this),O(i,"dragenter",this)),we.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),gt(this,Rn())}v.prototype={constructor:v,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(Pt=null)},_getDirection:function(t,e){return typeof this.options.direction=="function"?this.options.direction.call(this,t,e,h):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,n=this.el,o=this.options,s=o.preventOnFilter,r=t.type,a=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,l=(a||t).target,c=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||l,f=o.filter;if(Un(n),!h&&!(/mousedown|pointerdown/.test(r)&&t.button!==0||o.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Gt&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=at(l,o.draggable,n,!1),!(l&&l.animated)&&pe!==l)){if(Nt=ot(l),Jt=ot(l,o.draggable),typeof f=="function"){if(f.call(this,t,l,this)){X({sortable:e,rootEl:c,name:"filter",targetEl:l,toEl:n,fromEl:n}),j("filter",e,{evt:t}),s&&t.preventDefault();return}}else if(f&&(f=f.split(",").some(function(d){if(d=at(c,d.trim(),n,!1),d)return X({sortable:e,rootEl:d,name:"filter",targetEl:l,fromEl:n,toEl:n}),j("filter",e,{evt:t}),!0}),f)){s&&t.preventDefault();return}o.handle&&!at(c,o.handle,n,!1)||this._prepareDragStart(t,a,l)}}},_prepareDragStart:function(t,e,n){var o=this,s=o.el,r=o.options,a=s.ownerDocument,l;if(n&&!h&&n.parentNode===s){var c=B(n);if(I=s,h=n,_=h.parentNode,It=h.nextSibling,pe=n,de=r.group,v.dragged=h,Ct={target:h,clientX:(e||t).clientX,clientY:(e||t).clientY},Ri=Ct.clientX-c.left,_i=Ct.clientY-c.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,h.style["will-change"]="all",l=function(){if(j("delayEnded",o,{evt:t}),v.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!Ci&&o.nativeDraggable&&(h.draggable=!0),o._triggerDragStart(t,e),X({sortable:o,name:"choose",originalEvent:t}),Q(h,r.chosenClass,!0)},r.ignore.split(",").forEach(function(f){Fi(h,f.trim(),ke)}),O(a,"dragover",Lt),O(a,"mousemove",Lt),O(a,"touchmove",Lt),r.supportPointer?(O(a,"pointerup",o._onDrop),!this.nativeDraggable&&O(a,"pointercancel",o._onDrop)):(O(a,"mouseup",o._onDrop),O(a,"touchend",o._onDrop),O(a,"touchcancel",o._onDrop)),Ci&&this.nativeDraggable&&(this.options.touchStartThreshold=4,h.draggable=!0),j("delayStart",this,{evt:t}),r.delay&&(!r.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(te||mt))){if(v.eventCanceled){this._onDrop();return}r.supportPointer?(O(a,"pointerup",o._disableDelayedDrag),O(a,"pointercancel",o._disableDelayedDrag)):(O(a,"mouseup",o._disableDelayedDrag),O(a,"touchend",o._disableDelayedDrag),O(a,"touchcancel",o._disableDelayedDrag)),O(a,"mousemove",o._delayedDragTouchMoveHandler),O(a,"touchmove",o._delayedDragTouchMoveHandler),r.supportPointer&&O(a,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(l,r.delay)}else l()}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){h&&ke(h),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;S(t,"mouseup",this._disableDelayedDrag),S(t,"touchend",this._disableDelayedDrag),S(t,"touchcancel",this._disableDelayedDrag),S(t,"pointerup",this._disableDelayedDrag),S(t,"pointercancel",this._disableDelayedDrag),S(t,"mousemove",this._delayedDragTouchMoveHandler),S(t,"touchmove",this._delayedDragTouchMoveHandler),S(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t,!this.nativeDraggable||e?this.options.supportPointer?O(document,"pointermove",this._onTouchMove):e?O(document,"touchmove",this._onTouchMove):O(document,"mousemove",this._onTouchMove):(O(h,"dragend",this),O(I,"dragstart",this._onDragStart));try{document.selection?me(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(Mt=!1,I&&h){j("dragStarted",this,{evt:e}),this.nativeDraggable&&O(document,"dragover",Hn);var n=this.options;!t&&Q(h,n.dragClass,!1),Q(h,n.ghostClass,!0),v.active=this,t&&this._appendGhost(),X({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(rt){this._lastX=rt.clientX,this._lastY=rt.clientY,Yi();for(var t=document.elementFromPoint(rt.clientX,rt.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(rt.clientX,rt.clientY),t!==e);)e=t;if(h.parentNode[G]._isOutsideThisEl(t),e)do{if(e[G]){var n=void 0;if(n=e[G]._onDragOver({clientX:rt.clientX,clientY:rt.clientY,target:t,rootEl:e}),n&&!this.options.dragoverBubble)break}t=e}while(e=Bi(e));Ui()}},_onTouchMove:function(t){if(Ct){var e=this.options,n=e.fallbackTolerance,o=e.fallbackOffset,s=t.touches?t.touches[0]:t,r=y&&kt(y,!0),a=y&&r&&r.a,l=y&&r&&r.d,c=he&&$&&Ti($),f=(s.clientX-Ct.clientX+o.x)/(a||1)+(c?c[0]-Ne[0]:0)/(a||1),d=(s.clientY-Ct.clientY+o.y)/(l||1)+(c?c[1]-Ne[1]:0)/(l||1);if(!v.active&&!Mt){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))=0&&(X({rootEl:_,name:"add",toEl:_,fromEl:I,originalEvent:t}),X({sortable:this,name:"remove",toEl:_,originalEvent:t}),X({rootEl:_,name:"sort",toEl:_,fromEl:I,originalEvent:t}),X({sortable:this,name:"sort",toEl:_,originalEvent:t})),W&&W.save()):Z!==Nt&&Z>=0&&(X({sortable:this,name:"update",toEl:_,originalEvent:t}),X({sortable:this,name:"sort",toEl:_,originalEvent:t})),v.active&&((Z==null||Z===-1)&&(Z=Nt,wt=Jt),X({sortable:this,name:"end",toEl:_,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){j("nulling",this),I=h=_=y=It=T=pe=St=Ct=rt=Yt=Z=wt=Nt=Jt=Pt=Qt=W=de=v.dragged=v.ghost=v.clone=v.active=null;var t=this.el;Se.forEach(function(e){t.contains(e)&&(e.checked=!0)}),Se.length=Pe=Me=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":h&&(this._onDragOver(t),Wn(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,n=this.el.children,o=0,s=n.length,r=this.options;oo.right+s||i.clientY>n.bottom&&i.clientX>n.left:i.clientY>o.bottom+s||i.clientX>n.right&&i.clientY>n.top}function Kn(i,t,e,n,o,s,r,a){var l=n?i.clientY:i.clientX,c=n?e.height:e.width,f=n?e.top:e.left,d=n?e.bottom:e.right,u=!1;if(!r){if(a&&gef+c*s/2:ld-ge)return-Qt}else if(l>f+c*(1-o)/2&&ld-c*s/2)?l>f+c/2?1:-1:0}function Xn(i){return ot(h){},options:L,optionsLimit:K=null,placeholder:N,position:H=null,searchableOptionFields:tt=["label"],searchDebounce:z=1e3,searchingMessage:Y="Searching...",searchPrompt:F="Search...",state:et,statePath:ie=null}){this.canOptionLabelsWrap=t,this.canSelectPlaceholder=e,this.element=n,this.getOptionLabelUsing=o,this.getOptionLabelsUsing=s,this.getOptionsUsing=r,this.getSearchResultsUsing=a,this.hasDynamicOptions=l,this.hasDynamicSearchResults=c,this.hasInitialNoOptionsMessage=f,this.initialOptionLabel=d,this.initialOptionLabels=u,this.initialState=p,this.isAutofocused=g,this.isDisabled=m,this.isHtmlAllowed=x,this.isMultiple=D,this.isReorderable=w,this.isSearchable=A,this.livewireId=E,this.loadingMessage=M,this.maxItems=C,this.maxItemsMessage=q,this.noOptionsMessage=J,this.noSearchResultsMessage=R,this.onStateChange=V,this.options=L,this.optionsLimit=K,this.originalOptions=JSON.parse(JSON.stringify(L)),this.placeholder=N,this.position=H,this.searchableOptionFields=Array.isArray(tt)?tt:["label"],this.searchDebounce=z,this.searchingMessage=Y,this.searchPrompt=F,this.state=et,this.statePath=ie,this.activeSearchId=0,this.labelRepository={},this.isOpen=!1,this.selectedIndex=-1,this.searchQuery="",this.searchTimeout=null,this.isSearching=!1,this.selectedDisplayVersion=0,this.render(),this.setUpEventListeners(),this.isAutofocused&&this.selectButton.focus()}populateLabelRepositoryFromOptions(t){if(!(!t||!Array.isArray(t)))for(let e of t)e.options&&Array.isArray(e.options)?this.populateLabelRepositoryFromOptions(e.options):e.value!==void 0&&e.label!==void 0&&(this.labelRepository[e.value]=e.label)}render(){this.populateLabelRepositoryFromOptions(this.options),this.container=document.createElement("div"),this.container.className="fi-select-input-ctn",this.canOptionLabelsWrap||this.container.classList.add("fi-select-input-ctn-option-labels-not-wrapped"),this.container.setAttribute("aria-haspopup","listbox"),this.selectButton=document.createElement("button"),this.selectButton.className="fi-select-input-btn",this.selectButton.type="button",this.selectButton.setAttribute("aria-expanded","false"),this.selectedDisplay=document.createElement("div"),this.selectedDisplay.className="fi-select-input-value-ctn",this.updateSelectedDisplay(),this.selectButton.appendChild(this.selectedDisplay),this.dropdown=document.createElement("div"),this.dropdown.className="fi-dropdown-panel fi-scrollable",this.dropdown.setAttribute("role","listbox"),this.dropdown.setAttribute("tabindex","-1"),this.dropdown.style.display="none",this.dropdownId=`fi-select-input-dropdown-${Math.random().toString(36).substring(2,11)}`,this.dropdown.id=this.dropdownId,this.isMultiple&&this.dropdown.setAttribute("aria-multiselectable","true"),this.isSearchable&&(this.searchContainer=document.createElement("div"),this.searchContainer.className="fi-select-input-search-ctn",this.searchInput=document.createElement("input"),this.searchInput.className="fi-input",this.searchInput.type="text",this.searchInput.placeholder=this.searchPrompt,this.searchInput.setAttribute("aria-label","Search"),this.searchContainer.appendChild(this.searchInput),this.dropdown.appendChild(this.searchContainer),this.searchInput.addEventListener("input",t=>{this.isDisabled||this.handleSearch(t)}),this.searchInput.addEventListener("keydown",t=>{if(!this.isDisabled){if(t.key==="Tab"){t.preventDefault();let e=this.getVisibleOptions();if(e.length===0)return;t.shiftKey?this.selectedIndex=e.length-1:this.selectedIndex=0,e.forEach(n=>{n.classList.remove("fi-selected")}),e[this.selectedIndex].classList.add("fi-selected"),e[this.selectedIndex].focus()}else if(t.key==="ArrowDown"){if(t.preventDefault(),t.stopPropagation(),this.getVisibleOptions().length===0)return;this.selectedIndex=-1,this.searchInput.blur(),this.focusNextOption()}else if(t.key==="ArrowUp"){t.preventDefault(),t.stopPropagation();let e=this.getVisibleOptions();if(e.length===0)return;this.selectedIndex=e.length-1,this.searchInput.blur(),e[this.selectedIndex].classList.add("fi-selected"),e[this.selectedIndex].focus(),e[this.selectedIndex].id&&this.dropdown.setAttribute("aria-activedescendant",e[this.selectedIndex].id),this.scrollOptionIntoView(e[this.selectedIndex])}else if(t.key==="Enter"){if(t.preventDefault(),t.stopPropagation(),this.isSearching)return;let e=this.getVisibleOptions();if(e.length===0)return;let n=e.find(s=>{let r=s.getAttribute("aria-disabled")==="true",a=s.classList.contains("fi-disabled"),l=s.offsetParent===null;return!(r||a||l)});if(!n)return;let o=n.getAttribute("data-value");if(o===null)return;this.selectOption(o)}}})),this.optionsList=document.createElement("ul"),this.renderOptions(),this.container.appendChild(this.selectButton),this.container.appendChild(this.dropdown),this.element.appendChild(this.container),this.applyDisabledState()}renderOptions(){this.optionsList.innerHTML="";let t=0,e=this.options,n=0,o=!1;this.options.forEach(a=>{a.options&&Array.isArray(a.options)?(n+=a.options.length,o=!0):n++}),o?this.optionsList.className="fi-select-input-options-ctn":n>0&&(this.optionsList.className="fi-dropdown-list");let s=o?null:this.optionsList,r=0;for(let a of e){if(this.optionsLimit>0&&r>=this.optionsLimit)break;if(a.options&&Array.isArray(a.options)){let l=a.options;if(this.isMultiple&&Array.isArray(this.state)&&this.state.length>0&&(l=a.options.filter(c=>!this.state.includes(c.value))),l.length>0){if(this.optionsLimit>0){let c=this.optionsLimit-r;c{let a=this.createOptionElement(r.value,r);s.appendChild(a)}),n.appendChild(o),n.appendChild(s),this.optionsList.appendChild(n)}createOptionElement(t,e){let n=t,o=e,s=!1;typeof e=="object"&&e!==null&&"label"in e&&"value"in e&&(n=e.value,o=e.label,s=e.isDisabled||!1);let r=document.createElement("li");r.className="fi-dropdown-list-item fi-select-input-option",s&&r.classList.add("fi-disabled");let a=`fi-select-input-option-${Math.random().toString(36).substring(2,11)}`;if(r.id=a,r.setAttribute("role","option"),r.setAttribute("data-value",n),r.setAttribute("tabindex","0"),s&&r.setAttribute("aria-disabled","true"),this.isHtmlAllowed&&typeof o=="string"){let f=document.createElement("div");f.innerHTML=o;let d=f.textContent||f.innerText||o;r.setAttribute("aria-label",d)}let l=this.isMultiple?Array.isArray(this.state)&&this.state.includes(n):this.state===n;r.setAttribute("aria-selected",l?"true":"false"),l&&r.classList.add("fi-selected");let c=document.createElement("span");return this.isHtmlAllowed?c.innerHTML=o:c.textContent=o,r.appendChild(c),s||r.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),this.selectOption(n),this.isMultiple&&(this.isSearchable&&this.searchInput?setTimeout(()=>{this.searchInput.focus()},0):setTimeout(()=>{r.focus()},0))}),r}async updateSelectedDisplay(){this.selectedDisplayVersion=this.selectedDisplayVersion+1;let t=this.selectedDisplayVersion,e=document.createDocumentFragment();if(this.isMultiple){if(!Array.isArray(this.state)||this.state.length===0){let o=document.createElement("span");o.textContent=this.placeholder,o.classList.add("fi-select-input-placeholder"),e.appendChild(o)}else{let o=await this.getLabelsForMultipleSelection();if(t!==this.selectedDisplayVersion)return;this.addBadgesForSelectedOptions(o,e)}t===this.selectedDisplayVersion&&(this.selectedDisplay.replaceChildren(e),this.isOpen&&this.deferPositionDropdown());return}if(this.state===null||this.state===""){let o=document.createElement("span");if(o.textContent=this.placeholder,o.classList.add("fi-select-input-placeholder"),e.appendChild(o),t===this.selectedDisplayVersion){this.selectedDisplay.replaceChildren(e);let s=this.container.querySelector(".fi-select-input-value-remove-btn");s&&s.remove(),this.container.classList.remove("fi-select-input-ctn-clearable")}return}let n=await this.getLabelForSingleSelection();t===this.selectedDisplayVersion&&(this.addSingleSelectionDisplay(n,e),t===this.selectedDisplayVersion&&this.selectedDisplay.replaceChildren(e))}async getLabelsForMultipleSelection(){let t=this.getSelectedOptionLabels(),e=[];if(Array.isArray(this.state)){for(let o of this.state)if(!P(this.labelRepository[o])){if(P(t[o])){this.labelRepository[o]=t[o];continue}e.push(o.toString())}}if(e.length>0&&P(this.initialOptionLabels)&&JSON.stringify(this.state)===JSON.stringify(this.initialState)){if(Array.isArray(this.initialOptionLabels))for(let o of this.initialOptionLabels)P(o)&&o.value!==void 0&&o.label!==void 0&&e.includes(o.value)&&(this.labelRepository[o.value]=o.label)}else if(e.length>0&&this.getOptionLabelsUsing)try{let o=await this.getOptionLabelsUsing();for(let s of o)P(s)&&s.value!==void 0&&s.label!==void 0&&(this.labelRepository[s.value]=s.label)}catch(o){console.error("Error fetching option labels:",o)}let n=[];if(Array.isArray(this.state))for(let o of this.state)P(this.labelRepository[o])?n.push(this.labelRepository[o]):P(t[o])?n.push(t[o]):n.push(o);return n}createBadgeElement(t,e){let n=document.createElement("span");n.className="fi-badge fi-size-md fi-color fi-color-primary fi-text-color-600 dark:fi-text-color-200",P(t)&&n.setAttribute("data-value",t);let o=document.createElement("span");o.className="fi-badge-label-ctn";let s=document.createElement("span");s.className="fi-badge-label",this.canOptionLabelsWrap&&s.classList.add("fi-wrapped"),this.isHtmlAllowed?s.innerHTML=e:s.textContent=e,o.appendChild(s),n.appendChild(o);let r=this.createRemoveButton(t,e);return n.appendChild(r),n}createRemoveButton(t,e){let n=document.createElement("button");return n.type="button",n.className="fi-badge-delete-btn",n.innerHTML='',n.setAttribute("aria-label","Remove "+(this.isHtmlAllowed?e.replace(/<[^>]*>/g,""):e)),n.addEventListener("click",o=>{o.stopPropagation(),P(t)&&this.selectOption(t)}),n.addEventListener("keydown",o=>{(o.key===" "||o.key==="Enter")&&(o.preventDefault(),o.stopPropagation(),P(t)&&this.selectOption(t))}),n}addBadgesForSelectedOptions(t,e=this.selectedDisplay){let n=document.createElement("div");n.className="fi-select-input-value-badges-ctn",t.forEach((o,s)=>{let r=Array.isArray(this.state)?this.state[s]:null,a=this.createBadgeElement(r,o);n.appendChild(a)}),e.appendChild(n),this.isReorderable&&(n.addEventListener("click",o=>{o.stopPropagation()}),n.addEventListener("mousedown",o=>{o.stopPropagation()}),new Gi(n,{animation:150,onEnd:()=>{let o=[];n.querySelectorAll("[data-value]").forEach(s=>{o.push(s.getAttribute("data-value"))}),this.state=o,this.onStateChange(this.state)}}))}async getLabelForSingleSelection(){let t=this.labelRepository[this.state];if(bt(t)&&(t=this.getSelectedOptionLabel(this.state)),bt(t)&&P(this.initialOptionLabel)&&this.state===this.initialState)t=this.initialOptionLabel,P(this.state)&&(this.labelRepository[this.state]=t);else if(bt(t)&&this.getOptionLabelUsing)try{t=await this.getOptionLabelUsing(),P(t)&&P(this.state)&&(this.labelRepository[this.state]=t)}catch(e){console.error("Error fetching option label:",e),t=this.state}else bt(t)&&(t=this.state);return t}addSingleSelectionDisplay(t,e=this.selectedDisplay){let n=document.createElement("span");if(n.className="fi-select-input-value-label",this.isHtmlAllowed?n.innerHTML=t:n.textContent=t,e.appendChild(n),!this.canSelectPlaceholder||this.container.querySelector(".fi-select-input-value-remove-btn"))return;let o=document.createElement("button");o.type="button",o.className="fi-select-input-value-remove-btn",o.innerHTML='',o.setAttribute("aria-label","Clear selection"),o.addEventListener("click",s=>{s.stopPropagation(),this.selectOption("")}),o.addEventListener("keydown",s=>{(s.key===" "||s.key==="Enter")&&(s.preventDefault(),s.stopPropagation(),this.selectOption(""))}),this.container.appendChild(o),this.container.classList.add("fi-select-input-ctn-clearable")}getSelectedOptionLabel(t){if(P(this.labelRepository[t]))return this.labelRepository[t];let e="";for(let n of this.options)if(n.options&&Array.isArray(n.options)){for(let o of n.options)if(o.value===t){e=o.label,this.labelRepository[t]=e;break}}else if(n.value===t){e=n.label,this.labelRepository[t]=e;break}return e}setUpEventListeners(){this.buttonClickListener=()=>{this.toggleDropdown()},this.documentClickListener=t=>{!this.container.contains(t.target)&&this.isOpen&&this.closeDropdown()},this.buttonKeydownListener=t=>{this.isDisabled||this.handleSelectButtonKeydown(t)},this.dropdownKeydownListener=t=>{this.isDisabled||this.isSearchable&&document.activeElement===this.searchInput&&!["Tab","Escape"].includes(t.key)||this.handleDropdownKeydown(t)},this.selectButton.addEventListener("click",this.buttonClickListener),document.addEventListener("click",this.documentClickListener),this.selectButton.addEventListener("keydown",this.buttonKeydownListener),this.dropdown.addEventListener("keydown",this.dropdownKeydownListener),!this.isMultiple&&this.livewireId&&this.statePath&&this.getOptionLabelUsing&&(this.refreshOptionLabelListener=async t=>{if(t.detail.livewireId===this.livewireId&&t.detail.statePath===this.statePath&&P(this.state))try{delete this.labelRepository[this.state];let e=await this.getOptionLabelUsing();P(e)&&(this.labelRepository[this.state]=e);let n=this.selectedDisplay.querySelector(".fi-select-input-value-label");P(n)&&(this.isHtmlAllowed?n.innerHTML=e:n.textContent=e),this.updateOptionLabelInList(this.state,e)}catch(e){console.error("Error refreshing option label:",e)}},window.addEventListener("filament-forms::select.refreshSelectedOptionLabel",this.refreshOptionLabelListener))}updateOptionLabelInList(t,e){this.labelRepository[t]=e;let n=this.getVisibleOptions();for(let o of n)if(o.getAttribute("data-value")===String(t)){if(o.innerHTML="",this.isHtmlAllowed){let s=document.createElement("span");s.innerHTML=e,o.appendChild(s)}else o.appendChild(document.createTextNode(e));break}for(let o of this.options)if(o.options&&Array.isArray(o.options)){for(let s of o.options)if(s.value===t){s.label=e;break}}else if(o.value===t){o.label=e;break}for(let o of this.originalOptions)if(o.options&&Array.isArray(o.options)){for(let s of o.options)if(s.value===t){s.label=e;break}}else if(o.value===t){o.label=e;break}}handleSelectButtonKeydown(t){switch(t.key){case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.isOpen?this.focusNextOption():this.openDropdown();break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),this.isOpen?this.focusPreviousOption():this.openDropdown();break;case" ":if(t.preventDefault(),this.isOpen){if(this.selectedIndex>=0){let e=this.getVisibleOptions()[this.selectedIndex];e&&e.click()}}else this.openDropdown();break;case"Enter":break;case"Escape":this.isOpen&&(t.preventDefault(),this.closeDropdown());break;case"Tab":this.isOpen&&this.closeDropdown();break;default:if(this.isSearchable&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&typeof t.key=="string"&&t.key.length===1){t.preventDefault();let e=t.key;this.isOpen||this.openDropdown(),this.searchInput&&(this.searchInput.focus(),this.searchInput.value=(this.searchInput.value||"")+e,this.searchInput.dispatchEvent(new Event("input",{bubbles:!0})))}break}}handleDropdownKeydown(t){switch(t.key){case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.focusNextOption();break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),this.focusPreviousOption();break;case" ":if(t.preventDefault(),this.selectedIndex>=0){let e=this.getVisibleOptions()[this.selectedIndex];e&&e.click()}break;case"Enter":if(t.preventDefault(),this.selectedIndex>=0){let e=this.getVisibleOptions()[this.selectedIndex];e&&e.click()}else{let e=this.element.closest("form");e&&e.submit()}break;case"Escape":t.preventDefault(),this.closeDropdown(),this.selectButton.focus();break;case"Tab":this.closeDropdown();break;default:if(this.isSearchable&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&typeof t.key=="string"&&t.key.length===1){t.preventDefault();let e=t.key;this.searchInput&&(this.searchInput.focus(),this.searchInput.value=(this.searchInput.value||"")+e,this.searchInput.dispatchEvent(new Event("input",{bubbles:!0})))}break}}toggleDropdown(){if(!this.isDisabled){if(this.isOpen){this.closeDropdown();return}this.isMultiple&&!this.isSearchable&&!this.hasAvailableOptions()||this.openDropdown()}}hasAvailableOptions(){for(let t of this.options)if(t.options&&Array.isArray(t.options)){for(let e of t.options)if(!Array.isArray(this.state)||!this.state.includes(e.value))return!0}else if(!Array.isArray(this.state)||!this.state.includes(t.value))return!0;return!1}async openDropdown(){this.dropdown.style.display="block",this.dropdown.style.opacity="0";let t=this.selectButton.closest(".fi-fixed-positioning-context")!==null&&this.selectButton.closest(".fi-absolute-positioning-context")===null;if(this.dropdown.style.position=t?"fixed":"absolute",this.dropdown.style.width=`${this.selectButton.offsetWidth}px`,this.selectButton.setAttribute("aria-expanded","true"),this.isOpen=!0,this.positionDropdown(),this.resizeListener||(this.resizeListener=()=>{this.dropdown.style.width=`${this.selectButton.offsetWidth}px`,this.positionDropdown()},window.addEventListener("resize",this.resizeListener)),this.scrollListener||(this.scrollListener=()=>this.positionDropdown(),window.addEventListener("scroll",this.scrollListener,!0)),this.dropdown.style.opacity="1",this.isSearchable&&this.searchInput&&(this.searchInput.value="",this.searchQuery="",this.hasDynamicOptions||(this.options=JSON.parse(JSON.stringify(this.originalOptions)),this.renderOptions())),this.hasDynamicOptions&&this.getOptionsUsing){this.showLoadingState(!1);try{let e=await this.getOptionsUsing(),n=Array.isArray(e)?e:e&&Array.isArray(e.options)?e.options:[];if(this.options=n,this.originalOptions=JSON.parse(JSON.stringify(n)),this.populateLabelRepositoryFromOptions(n),this.isSearchable&&this.searchInput&&(this.searchInput.value&&this.searchInput.value.trim()!==""||this.searchQuery&&this.searchQuery.trim()!=="")){let o=(this.searchInput.value||this.searchQuery||"").trim().toLowerCase();this.hideLoadingState(),this.filterOptions(o)}else this.renderOptions()}catch(e){console.error("Error fetching options:",e),this.hideLoadingState()}}else(!this.hasInitialNoOptionsMessage||this.searchQuery)&&this.hideLoadingState();if(this.isSearchable&&this.searchInput)this.searchInput.focus();else{this.selectedIndex=-1;let e=this.getVisibleOptions();if(this.isMultiple){if(Array.isArray(this.state)&&this.state.length>0){for(let n=0;n0&&(this.selectedIndex=0),this.selectedIndex>=0&&(e[this.selectedIndex].classList.add("fi-selected"),e[this.selectedIndex].focus())}}positionDropdown(){let t=this.position==="top"?"top-start":"bottom-start",e=[xi(4),Oi({padding:5})];this.position!=="top"&&this.position!=="bottom"&&e.push(Ei());let n=this.selectButton.closest(".fi-fixed-positioning-context")!==null&&this.selectButton.closest(".fi-absolute-positioning-context")===null;Di(this.selectButton,this.dropdown,{placement:t,middleware:e,strategy:n?"fixed":"absolute"}).then(({x:o,y:s})=>{Object.assign(this.dropdown.style,{left:`${o}px`,top:`${s}px`})})}deferPositionDropdown(){this.isOpen&&(this.positioningRequestAnimationFrame&&(cancelAnimationFrame(this.positioningRequestAnimationFrame),this.positioningRequestAnimationFrame=null),this.positioningRequestAnimationFrame=requestAnimationFrame(()=>{this.positionDropdown(),this.positioningRequestAnimationFrame=null}))}closeDropdown(){this.dropdown.style.display="none",this.selectButton.setAttribute("aria-expanded","false"),this.isOpen=!1,this.searchTimeout&&(clearTimeout(this.searchTimeout),this.searchTimeout=null),this.activeSearchId++,this.isSearching=!1,this.hideLoadingState(),this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null),this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener,!0),this.scrollListener=null),this.getVisibleOptions().forEach(e=>{e.classList.remove("fi-selected")}),this.dropdown.removeAttribute("aria-activedescendant")}focusNextOption(){let t=this.getVisibleOptions();if(t.length!==0){if(this.selectedIndex>=0&&this.selectedIndex=0&&this.selectedIndexe.bottom?this.dropdown.scrollTop+=n.bottom-e.bottom:n.top li[role="option"]')):t=Array.from(this.optionsList.querySelectorAll(':scope > ul.fi-dropdown-list > li[role="option"]'));let e=Array.from(this.optionsList.querySelectorAll('li.fi-select-input-option-group > ul > li[role="option"]'));return[...t,...e]}getSelectedOptionLabels(){if(!Array.isArray(this.state)||this.state.length===0)return{};let t={};for(let e of this.state){let n=!1;for(let o of this.options)if(o.options&&Array.isArray(o.options)){for(let s of o.options)if(s.value===e){t[e]=s.label,n=!0;break}if(n)break}else if(o.value===e){t[e]=o.label;break}}return t}handleSearch(t){let e=t.target.value.trim();if(this.searchQuery=e,this.searchTimeout&&clearTimeout(this.searchTimeout),e===""){this.options=JSON.parse(JSON.stringify(this.originalOptions)),this.renderOptions();return}if(!this.getSearchResultsUsing||typeof this.getSearchResultsUsing!="function"||!this.hasDynamicSearchResults){this.filterOptions(e);return}this.searchTimeout=setTimeout(async()=>{this.searchTimeout=null;let n=++this.activeSearchId;this.isSearching=!0;try{this.showLoadingState(!0);let o=await this.getSearchResultsUsing(e);if(n!==this.activeSearchId||!this.isOpen)return;let s=Array.isArray(o)?o:o&&Array.isArray(o.options)?o.options:[];this.options=s,this.populateLabelRepositoryFromOptions(s),this.hideLoadingState(),this.renderOptions(),this.isOpen&&this.deferPositionDropdown(),this.options.length===0&&this.showNoResultsMessage()}catch(o){n===this.activeSearchId&&(console.error("Error fetching search results:",o),this.hideLoadingState(),this.options=JSON.parse(JSON.stringify(this.originalOptions)),this.renderOptions())}finally{n===this.activeSearchId&&(this.isSearching=!1)}},this.searchDebounce)}showLoadingState(t=!1){this.optionsList.parentNode===this.dropdown&&this.dropdown.removeChild(this.optionsList),this.hideLoadingState();let e=document.createElement("div");e.className="fi-select-input-message",e.textContent=t?this.searchingMessage:this.loadingMessage,this.dropdown.appendChild(e),this.isOpen&&this.deferPositionDropdown()}hideLoadingState(){let t=this.dropdown.querySelector(".fi-select-input-message");t&&t.remove()}showNoOptionsMessage(){this.optionsList.parentNode===this.dropdown&&this.dropdown.removeChild(this.optionsList),this.hideLoadingState();let t=document.createElement("div");t.className="fi-select-input-message",t.textContent=this.noOptionsMessage,this.dropdown.appendChild(t),this.isOpen&&this.deferPositionDropdown()}showNoResultsMessage(){this.optionsList.parentNode===this.dropdown&&this.dropdown.removeChild(this.optionsList),this.hideLoadingState();let t=document.createElement("div");t.className="fi-select-input-message",t.textContent=this.noSearchResultsMessage,this.dropdown.appendChild(t),this.isOpen&&this.deferPositionDropdown()}filterOptions(t){let e=this.searchableOptionFields.includes("label"),n=this.searchableOptionFields.includes("value");t=t.toLowerCase();let o=[];for(let s of this.originalOptions)if(s.options&&Array.isArray(s.options)){let r=s.options.filter(a=>e&&a.label.toLowerCase().includes(t)||n&&String(a.value).toLowerCase().includes(t));r.length>0&&o.push({label:s.label,options:r})}else(e&&s.label.toLowerCase().includes(t)||n&&String(s.value).toLowerCase().includes(t))&&o.push(s);this.options=o,this.renderOptions(),this.options.length===0&&this.showNoResultsMessage(),this.isOpen&&this.positionDropdown()}selectOption(t){if(this.isDisabled)return;if(!this.isMultiple){this.state=t,this.updateSelectedDisplay(),this.renderOptions(),this.closeDropdown(),this.selectButton.focus(),this.onStateChange(this.state);return}let e=Array.isArray(this.state)?[...this.state]:[];if(e.includes(t)){let o=this.selectedDisplay.querySelector(`[data-value="${t}"]`);if(P(o)){let s=o.parentElement;P(s)&&s.children.length===1?(e=e.filter(r=>r!==t),this.state=e,this.updateSelectedDisplay()):(o.remove(),e=e.filter(r=>r!==t),this.state=e)}else e=e.filter(s=>s!==t),this.state=e,this.updateSelectedDisplay();this.renderOptions(),this.isOpen&&this.deferPositionDropdown(),this.maintainFocusInMultipleMode(),this.onStateChange(this.state);return}if(this.maxItems&&e.length>=this.maxItems){this.maxItemsMessage&&alert(this.maxItemsMessage);return}e.push(t),this.state=e;let n=this.selectedDisplay.querySelector(".fi-select-input-value-badges-ctn");bt(n)?this.updateSelectedDisplay():this.addSingleBadge(t,n),this.renderOptions(),this.isOpen&&this.deferPositionDropdown(),this.maintainFocusInMultipleMode(),this.onStateChange(this.state)}async addSingleBadge(t,e){let n=this.labelRepository[t];if(bt(n)&&(n=this.getSelectedOptionLabel(t),P(n)&&(this.labelRepository[t]=n)),bt(n)&&this.getOptionLabelsUsing)try{let s=await this.getOptionLabelsUsing();for(let r of s)if(P(r)&&r.value===t&&r.label!==void 0){n=r.label,this.labelRepository[t]=n;break}}catch(s){console.error("Error fetching option label:",s)}bt(n)&&(n=t);let o=this.createBadgeElement(t,n);e.appendChild(o)}maintainFocusInMultipleMode(){if(this.isSearchable&&this.searchInput){this.searchInput.focus();return}let t=this.getVisibleOptions();if(t.length!==0){if(this.selectedIndex=-1,Array.isArray(this.state)&&this.state.length>0){for(let e=0;e{e.setAttribute("disabled","disabled"),e.classList.add("fi-disabled")}),!this.isMultiple&&this.canSelectPlaceholder){let t=this.container.querySelector(".fi-select-input-value-remove-btn");t&&(t.setAttribute("disabled","disabled"),t.classList.add("fi-disabled"))}this.isSearchable&&this.searchInput&&(this.searchInput.setAttribute("disabled","disabled"),this.searchInput.classList.add("fi-disabled"))}else{if(this.selectButton.removeAttribute("disabled"),this.selectButton.removeAttribute("aria-disabled"),this.selectButton.classList.remove("fi-disabled"),this.isMultiple&&this.container.querySelectorAll(".fi-select-input-badge-remove").forEach(e=>{e.removeAttribute("disabled"),e.classList.remove("fi-disabled")}),!this.isMultiple&&this.canSelectPlaceholder){let t=this.container.querySelector(".fi-select-input-value-remove-btn");t&&(t.removeAttribute("disabled"),t.classList.add("fi-disabled"))}this.isSearchable&&this.searchInput&&(this.searchInput.removeAttribute("disabled"),this.searchInput.classList.remove("fi-disabled"))}}destroy(){this.selectButton&&this.buttonClickListener&&this.selectButton.removeEventListener("click",this.buttonClickListener),this.documentClickListener&&document.removeEventListener("click",this.documentClickListener),this.selectButton&&this.buttonKeydownListener&&this.selectButton.removeEventListener("keydown",this.buttonKeydownListener),this.dropdown&&this.dropdownKeydownListener&&this.dropdown.removeEventListener("keydown",this.dropdownKeydownListener),this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null),this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener,!0),this.scrollListener=null),this.refreshOptionLabelListener&&window.removeEventListener("filament-forms::select.refreshSelectedOptionLabel",this.refreshOptionLabelListener),this.isOpen&&this.closeDropdown(),this.searchTimeout&&(clearTimeout(this.searchTimeout),this.searchTimeout=null),this.container&&this.container.remove()}};function Gn({canOptionLabelsWrap:i,canSelectPlaceholder:t,getOptionLabelUsing:e,getOptionsUsing:n,getSearchResultsUsing:o,hasDynamicOptions:s,hasDynamicSearchResults:r,hasInitialNoOptionsMessage:a,initialOptionLabel:l,isDisabled:c,isHtmlAllowed:f,isNative:d,isSearchable:u,loadingMessage:p,name:g,noOptionsMessage:m,noSearchResultsMessage:x,options:D,optionsLimit:w,placeholder:A,position:E,recordKey:M,searchableOptionFields:C,searchDebounce:q,searchingMessage:J,searchPrompt:R,state:V}){return{error:void 0,isLoading:!1,select:null,state:V,unsubscribeLivewireHook:null,init(){d||(this.select=new Ee({canOptionLabelsWrap:i,canSelectPlaceholder:t,element:this.$refs.select,getOptionLabelUsing:e,getOptionsUsing:n,getSearchResultsUsing:o,hasDynamicOptions:s,hasDynamicSearchResults:r,hasInitialNoOptionsMessage:a,initialOptionLabel:l,isDisabled:c,isHtmlAllowed:f,isSearchable:u,loadingMessage:p,noOptionsMessage:m,noSearchResultsMessage:x,onStateChange:L=>{this.state=L},options:D,optionsLimit:w,placeholder:A,position:E,searchableOptionFields:C,searchDebounce:q,searchingMessage:J,searchPrompt:R,state:this.state})),this.unsubscribeLivewireHook=Livewire.interceptMessage(({message:L,onSuccess:K})=>{K(()=>{this.$nextTick(()=>{if(this.isLoading||L.component.id!==this.$root.closest("[wire\\:id]")?.attributes["wire:id"].value)return;let N=this.getServerState();N===void 0||this.getNormalizedState()===N||(this.state=N)})})}),this.$watch("state",async L=>{!d&&this.select&&this.select.state!==L&&(this.select.state=L,this.select.updateSelectedDisplay(),this.select.renderOptions());let K=this.getServerState();if(K===void 0||this.getNormalizedState()===K)return;this.isLoading=!0;let N=await this.$wire.updateTableColumnState(g,M,this.state);this.error=N?.error??void 0,!this.error&&this.$refs.serverState&&(this.$refs.serverState.value=this.getNormalizedState()),this.isLoading=!1})},getServerState(){if(this.$refs.serverState)return[null,void 0].includes(this.$refs.serverState.value)?"":this.$refs.serverState.value.replaceAll('\\"','"')},getNormalizedState(){let L=Alpine.raw(this.state);return[null,void 0].includes(L)?"":L},destroy(){this.unsubscribeLivewireHook?.(),this.select&&(this.select.destroy(),this.select=null)}}}export{Gn as default}; /*! Bundled license information: sortablejs/modular/sortable.esm.js: (**! * Sortable 1.15.7 * @author RubaXa * @author owenm * @license MIT *) */