mirror of
https://github.com/pelican-dev/panel.git
synced 2025-12-17 09:11:19 +01:00
12 lines
82 KiB
JavaScript
12 lines
82 KiB
JavaScript
var Ft=Math.min,vt=Math.max,Ht=Math.round;var ot=n=>({x:n,y:n}),ji={left:"right",right:"left",bottom:"top",top:"bottom"},qi={start:"end",end:"start"};function Oe(n,t,e){return vt(n,Ft(t,e))}function Vt(n,t){return typeof n=="function"?n(t):n}function yt(n){return n.split("-")[0]}function Wt(n){return n.split("-")[1]}function De(n){return n==="x"?"y":"x"}function Ae(n){return n==="y"?"height":"width"}var Ji=new Set(["top","bottom"]);function ht(n){return Ji.has(yt(n))?"y":"x"}function Ce(n){return De(ht(n))}function Je(n,t,e){e===void 0&&(e=!1);let i=Wt(n),o=Ce(n),s=Ae(o),r=o==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(r=Bt(r)),[r,Bt(r)]}function Qe(n){let t=Bt(n);return[ee(n),t,ee(t)]}function ee(n){return n.replace(/start|end/g,t=>qi[t])}var je=["left","right"],qe=["right","left"],Qi=["top","bottom"],Zi=["bottom","top"];function tn(n,t,e){switch(n){case"top":case"bottom":return e?t?qe:je:t?je:qe;case"left":case"right":return t?Qi:Zi;default:return[]}}function Ze(n,t,e,i){let o=Wt(n),s=tn(yt(n),e==="start",i);return o&&(s=s.map(r=>r+"-"+o),t&&(s=s.concat(s.map(ee)))),s}function Bt(n){return n.replace(/left|right|bottom|top/g,t=>ji[t])}function en(n){return{top:0,right:0,bottom:0,left:0,...n}}function ti(n){return typeof n!="number"?en(n):{top:n,right:n,bottom:n,left:n}}function Et(n){let{x:t,y:e,width:i,height:o}=n;return{width:i,height:o,top:e,left:t,right:t+i,bottom:e+o,x:t,y:e}}function ei(n,t,e){let{reference:i,floating:o}=n,s=ht(t),r=Ce(t),a=Ae(r),l=yt(t),c=s==="y",f=i.x+i.width/2-o.width/2,d=i.y+i.height/2-o.height/2,p=i[a]/2-o[a]/2,u;switch(l){case"top":u={x:f,y:i.y-o.height};break;case"bottom":u={x:f,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:d};break;case"left":u={x:i.x-o.width,y:d};break;default:u={x:i.x,y:i.y}}switch(Wt(t)){case"start":u[r]-=p*(e&&c?-1:1);break;case"end":u[r]+=p*(e&&c?-1:1);break}return u}var ii=async(n,t,e)=>{let{placement:i="bottom",strategy:o="absolute",middleware:s=[],platform:r}=e,a=s.filter(Boolean),l=await(r.isRTL==null?void 0:r.isRTL(t)),c=await r.getElementRects({reference:n,floating:t,strategy:o}),{x:f,y:d}=ei(c,i,l),p=i,u={},g=0;for(let m=0;m<a.length;m++){let{name:S,fn:O}=a[m],{x:w,y:D,data:A,reset:C}=await O({x:f,y:d,initialPlacement:i,placement:p,strategy:o,middlewareData:u,rects:c,platform:r,elements:{reference:n,floating:t}});f=w??f,d=D??d,u={...u,[S]:{...u[S],...A}},C&&g<=50&&(g++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(c=C.rects===!0?await r.getElementRects({reference:n,floating:t,strategy:o}):C.rects),{x:f,y:d}=ei(c,p,l)),m=-1)}return{x:f,y:d,placement:p,strategy:o,middlewareData:u}};async function Le(n,t){var e;t===void 0&&(t={});let{x:i,y:o,platform:s,rects:r,elements:a,strategy:l}=n,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:p=!1,padding:u=0}=Vt(t,n),g=ti(u),S=a[p?d==="floating"?"reference":"floating":d],O=Et(await s.getClippingRect({element:(e=await(s.isElement==null?void 0:s.isElement(S)))==null||e?S:S.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:f,strategy:l})),w=d==="floating"?{x:i,y:o,width:r.floating.width,height:r.floating.height}:r.reference,D=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),A=await(s.isElement==null?void 0:s.isElement(D))?await(s.getScale==null?void 0:s.getScale(D))||{x:1,y:1}:{x:1,y:1},C=Et(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:D,strategy:l}):w);return{top:(O.top-C.top+g.top)/A.y,bottom:(C.bottom-O.bottom+g.bottom)/A.y,left:(O.left-C.left+g.left)/A.x,right:(C.right-O.right+g.right)/A.x}}var ni=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(t){var e,i;let{placement:o,middlewareData:s,rects:r,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...S}=Vt(n,t);if((e=s.arrow)!=null&&e.alignmentOffset)return{};let O=yt(o),w=ht(a),D=yt(a)===a,A=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=p||(D||!m?[Bt(a)]:Qe(a)),F=g!=="none";!p&&F&&C.push(...Ze(a,m,g,A));let q=[a,...C],J=await Le(t,S),T=[],V=((i=s.flip)==null?void 0:i.overflows)||[];if(f&&T.push(J[O]),d){let k=Je(o,r,A);T.push(J[k[0]],J[k[1]])}if(V=[...V,{placement:o,overflows:T}],!T.every(k=>k<=0)){var X,tt;let k=(((X=s.flip)==null?void 0:X.index)||0)+1,Y=q[k];if(Y&&(!(d==="alignment"?w!==ht(Y):!1)||V.every(B=>ht(B.placement)===w?B.overflows[0]>0:!0)))return{data:{index:k,overflows:V},reset:{placement:Y}};let P=(tt=V.filter($=>$.overflows[0]<=0).sort(($,B)=>$.overflows[1]-B.overflows[1])[0])==null?void 0:tt.placement;if(!P)switch(u){case"bestFit":{var W;let $=(W=V.filter(B=>{if(F){let lt=ht(B.placement);return lt===w||lt==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(lt=>lt>0).reduce((lt,Ue)=>lt+Ue,0)]).sort((B,lt)=>B[1]-lt[1])[0])==null?void 0:W[0];$&&(P=$);break}case"initialPlacement":P=a;break}if(o!==P)return{reset:{placement:P}}}return{}}}};var nn=new Set(["left","top"]);async function on(n,t){let{placement:e,platform:i,elements:o}=n,s=await(i.isRTL==null?void 0:i.isRTL(o.floating)),r=yt(e),a=Wt(e),l=ht(e)==="y",c=nn.has(r)?-1:1,f=s&&l?-1:1,d=Vt(t,n),{mainAxis:p,crossAxis:u,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"&&(u=a==="end"?g*-1:g),l?{x:u*f,y:p*c}:{x:p*c,y:u*f}}var oi=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(t){var e,i;let{x:o,y:s,placement:r,middlewareData:a}=t,l=await on(t,n);return r===((e=a.offset)==null?void 0:e.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:r}}}}},si=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(t){let{x:e,y:i,placement:o}=t,{mainAxis:s=!0,crossAxis:r=!1,limiter:a={fn:S=>{let{x:O,y:w}=S;return{x:O,y:w}}},...l}=Vt(n,t),c={x:e,y:i},f=await Le(t,l),d=ht(yt(o)),p=De(d),u=c[p],g=c[d];if(s){let S=p==="y"?"top":"left",O=p==="y"?"bottom":"right",w=u+f[S],D=u-f[O];u=Oe(w,u,D)}if(r){let S=d==="y"?"top":"left",O=d==="y"?"bottom":"right",w=g+f[S],D=g-f[O];g=Oe(w,g,D)}let m=a.fn({...t,[p]:u,[d]:g});return{...m,data:{x:m.x-e,y:m.y-i,enabled:{[p]:s,[d]:r}}}}}};function ne(){return typeof window<"u"}function Ot(n){return ai(n)?(n.nodeName||"").toLowerCase():"#document"}function U(n){var t;return(n==null||(t=n.ownerDocument)==null?void 0:t.defaultView)||window}function ct(n){var t;return(t=(ai(n)?n.ownerDocument:n.document)||window.document)==null?void 0:t.documentElement}function ai(n){return ne()?n instanceof Node||n instanceof U(n).Node:!1}function et(n){return ne()?n instanceof Element||n instanceof U(n).Element:!1}function st(n){return ne()?n instanceof HTMLElement||n instanceof U(n).HTMLElement:!1}function ri(n){return!ne()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof U(n).ShadowRoot}var sn=new Set(["inline","contents"]);function It(n){let{overflow:t,overflowX:e,overflowY:i,display:o}=it(n);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&!sn.has(o)}var rn=new Set(["table","td","th"]);function li(n){return rn.has(Ot(n))}var an=[":popover-open",":modal"];function zt(n){return an.some(t=>{try{return n.matches(t)}catch{return!1}})}var ln=["transform","translate","scale","rotate","perspective"],cn=["transform","translate","scale","rotate","perspective","filter"],dn=["paint","layout","strict","content"];function oe(n){let t=se(),e=et(n)?it(n):n;return ln.some(i=>e[i]?e[i]!=="none":!1)||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||cn.some(i=>(e.willChange||"").includes(i))||dn.some(i=>(e.contain||"").includes(i))}function ci(n){let t=ut(n);for(;st(t)&&!Dt(t);){if(oe(t))return t;if(zt(t))return null;t=ut(t)}return null}function se(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var fn=new Set(["html","body","#document"]);function Dt(n){return fn.has(Ot(n))}function it(n){return U(n).getComputedStyle(n)}function Xt(n){return et(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function ut(n){if(Ot(n)==="html")return n;let t=n.assignedSlot||n.parentNode||ri(n)&&n.host||ct(n);return ri(t)?t.host:t}function di(n){let t=ut(n);return Dt(t)?n.ownerDocument?n.ownerDocument.body:n.body:st(t)&&It(t)?t:di(t)}function ie(n,t,e){var i;t===void 0&&(t=[]),e===void 0&&(e=!0);let o=di(n),s=o===((i=n.ownerDocument)==null?void 0:i.body),r=U(o);if(s){let a=re(r);return t.concat(r,r.visualViewport||[],It(o)?o:[],a&&e?ie(a):[])}return t.concat(o,ie(o,[],e))}function re(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function pi(n){let t=it(n),e=parseFloat(t.width)||0,i=parseFloat(t.height)||0,o=st(n),s=o?n.offsetWidth:e,r=o?n.offsetHeight:i,a=Ht(e)!==s||Ht(i)!==r;return a&&(e=s,i=r),{width:e,height:i,$:a}}function gi(n){return et(n)?n:n.contextElement}function Tt(n){let t=gi(n);if(!st(t))return ot(1);let e=t.getBoundingClientRect(),{width:i,height:o,$:s}=pi(t),r=(s?Ht(e.width):e.width)/i,a=(s?Ht(e.height):e.height)/o;return(!r||!Number.isFinite(r))&&(r=1),(!a||!Number.isFinite(a))&&(a=1),{x:r,y:a}}var hn=ot(0);function mi(n){let t=U(n);return!se()||!t.visualViewport?hn:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function un(n,t,e){return t===void 0&&(t=!1),!e||t&&e!==U(n)?!1:t}function Kt(n,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);let o=n.getBoundingClientRect(),s=gi(n),r=ot(1);t&&(i?et(i)&&(r=Tt(i)):r=Tt(n));let a=un(s,e,i)?mi(s):ot(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 p=U(s),u=i&&et(i)?U(i):i,g=p,m=re(g);for(;m&&i&&u!==g;){let S=Tt(m),O=m.getBoundingClientRect(),w=it(m),D=O.left+(m.clientLeft+parseFloat(w.paddingLeft))*S.x,A=O.top+(m.clientTop+parseFloat(w.paddingTop))*S.y;l*=S.x,c*=S.y,f*=S.x,d*=S.y,l+=D,c+=A,g=U(m),m=re(g)}}return Et({width:f,height:d,x:l,y:c})}function ae(n,t){let e=Xt(n).scrollLeft;return t?t.left+e:Kt(ct(n)).left+e}function bi(n,t){let e=n.getBoundingClientRect(),i=e.left+t.scrollLeft-ae(n,e),o=e.top+t.scrollTop;return{x:i,y:o}}function pn(n){let{elements:t,rect:e,offsetParent:i,strategy:o}=n,s=o==="fixed",r=ct(i),a=t?zt(t.floating):!1;if(i===r||a&&s)return e;let l={scrollLeft:0,scrollTop:0},c=ot(1),f=ot(0),d=st(i);if((d||!d&&!s)&&((Ot(i)!=="body"||It(r))&&(l=Xt(i)),st(i))){let u=Kt(i);c=Tt(i),f.x=u.x+i.clientLeft,f.y=u.y+i.clientTop}let p=r&&!d&&!s?bi(r,l):ot(0);return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-l.scrollLeft*c.x+f.x+p.x,y:e.y*c.y-l.scrollTop*c.y+f.y+p.y}}function gn(n){return Array.from(n.getClientRects())}function mn(n){let t=ct(n),e=Xt(n),i=n.ownerDocument.body,o=vt(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),s=vt(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight),r=-e.scrollLeft+ae(n),a=-e.scrollTop;return it(i).direction==="rtl"&&(r+=vt(t.clientWidth,i.clientWidth)-o),{width:o,height:s,x:r,y:a}}var fi=25;function bn(n,t){let e=U(n),i=ct(n),o=e.visualViewport,s=i.clientWidth,r=i.clientHeight,a=0,l=0;if(o){s=o.width,r=o.height;let f=se();(!f||f&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}let c=ae(i);if(c<=0){let f=i.ownerDocument,d=f.body,p=getComputedStyle(d),u=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(i.clientWidth-d.clientWidth-u);g<=fi&&(s-=g)}else c<=fi&&(s+=c);return{width:s,height:r,x:a,y:l}}var vn=new Set(["absolute","fixed"]);function yn(n,t){let e=Kt(n,!0,t==="fixed"),i=e.top+n.clientTop,o=e.left+n.clientLeft,s=st(n)?Tt(n):ot(1),r=n.clientWidth*s.x,a=n.clientHeight*s.y,l=o*s.x,c=i*s.y;return{width:r,height:a,x:l,y:c}}function hi(n,t,e){let i;if(t==="viewport")i=bn(n,e);else if(t==="document")i=mn(ct(n));else if(et(t))i=yn(t,e);else{let o=mi(n);i={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Et(i)}function vi(n,t){let e=ut(n);return e===t||!et(e)||Dt(e)?!1:it(e).position==="fixed"||vi(e,t)}function wn(n,t){let e=t.get(n);if(e)return e;let i=ie(n,[],!1).filter(a=>et(a)&&Ot(a)!=="body"),o=null,s=it(n).position==="fixed",r=s?ut(n):n;for(;et(r)&&!Dt(r);){let a=it(r),l=oe(r);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&vn.has(o.position)||It(r)&&!l&&vi(n,r))?i=i.filter(f=>f!==r):o=a,r=ut(r)}return t.set(n,i),i}function Sn(n){let{element:t,boundary:e,rootBoundary:i,strategy:o}=n,r=[...e==="clippingAncestors"?zt(t)?[]:wn(t,this._c):[].concat(e),i],a=r[0],l=r.reduce((c,f)=>{let d=hi(t,f,o);return c.top=vt(d.top,c.top),c.right=Ft(d.right,c.right),c.bottom=Ft(d.bottom,c.bottom),c.left=vt(d.left,c.left),c},hi(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function xn(n){let{width:t,height:e}=pi(n);return{width:t,height:e}}function En(n,t,e){let i=st(t),o=ct(t),s=e==="fixed",r=Kt(n,!0,s,t),a={scrollLeft:0,scrollTop:0},l=ot(0);function c(){l.x=ae(o)}if(i||!i&&!s)if((Ot(t)!=="body"||It(o))&&(a=Xt(t)),i){let u=Kt(t,!0,s,t);l.x=u.x+t.clientLeft,l.y=u.y+t.clientTop}else o&&c();s&&!i&&o&&c();let f=o&&!i&&!s?bi(o,a):ot(0),d=r.left+a.scrollLeft-l.x-f.x,p=r.top+a.scrollTop-l.y-f.y;return{x:d,y:p,width:r.width,height:r.height}}function Ie(n){return it(n).position==="static"}function ui(n,t){if(!st(n)||it(n).position==="fixed")return null;if(t)return t(n);let e=n.offsetParent;return ct(n)===e&&(e=e.ownerDocument.body),e}function yi(n,t){let e=U(n);if(zt(n))return e;if(!st(n)){let o=ut(n);for(;o&&!Dt(o);){if(et(o)&&!Ie(o))return o;o=ut(o)}return e}let i=ui(n,t);for(;i&&li(i)&&Ie(i);)i=ui(i,t);return i&&Dt(i)&&Ie(i)&&!oe(i)?e:i||ci(n)||e}var On=async function(n){let t=this.getOffsetParent||yi,e=this.getDimensions,i=await e(n.floating);return{reference:En(n.reference,await t(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Dn(n){return it(n).direction==="rtl"}var An={convertOffsetParentRelativeRectToViewportRelativeRect:pn,getDocumentElement:ct,getClippingRect:Sn,getOffsetParent:yi,getElementRects:On,getClientRects:gn,getDimensions:xn,getScale:Tt,isElement:et,isRTL:Dn};var wi=oi;var Si=si,xi=ni;var Ei=(n,t,e)=>{let i=new Map,o={platform:An,...e},s={...o.platform,_c:i};return ii(n,t,{...o,platform:s})};function Oi(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(n,o).enumerable})),e.push.apply(e,i)}return e}function ft(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Oi(Object(e),!0).forEach(function(i){Cn(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Oi(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function he(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?he=function(t){return typeof t}:he=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},he(n)}function Cn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function gt(){return gt=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},gt.apply(this,arguments)}function Ln(n,t){if(n==null)return{};var e={},i=Object.keys(n),o,s;for(s=0;s<i.length;s++)o=i[s],!(t.indexOf(o)>=0)&&(e[o]=n[o]);return e}function In(n,t){if(n==null)return{};var e=Ln(n,t),i,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(o=0;o<s.length;o++)i=s[o],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(e[i]=n[i])}return e}var Tn="1.15.6";function pt(n){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(n)}var mt=pt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Zt=pt(/Edge/i),Di=pt(/firefox/i),Gt=pt(/safari/i)&&!pt(/chrome/i)&&!pt(/android/i),Xe=pt(/iP(ad|od|hone)/i),Pi=pt(/chrome/i)&&pt(/android/i),Mi={capture:!1,passive:!1};function E(n,t,e){n.addEventListener(t,e,!mt&&Mi)}function x(n,t,e){n.removeEventListener(t,e,!mt&&Mi)}function be(n,t){if(t){if(t[0]===">"&&(t=t.substring(1)),n)try{if(n.matches)return n.matches(t);if(n.msMatchesSelector)return n.msMatchesSelector(t);if(n.webkitMatchesSelector)return n.webkitMatchesSelector(t)}catch{return!1}return!1}}function Ni(n){return n.host&&n!==document&&n.host.nodeType?n.host:n.parentNode}function at(n,t,e,i){if(n){e=e||document;do{if(t!=null&&(t[0]===">"?n.parentNode===e&&be(n,t):be(n,t))||i&&n===e)return n;if(n===e)break}while(n=Ni(n))}return null}var Ai=/\s+/g;function Q(n,t,e){if(n&&t)if(n.classList)n.classList[e?"add":"remove"](t);else{var i=(" "+n.className+" ").replace(Ai," ").replace(" "+t+" "," ");n.className=(i+(e?" "+t:"")).replace(Ai," ")}}function b(n,t,e){var i=n&&n.style;if(i){if(e===void 0)return document.defaultView&&document.defaultView.getComputedStyle?e=document.defaultView.getComputedStyle(n,""):n.currentStyle&&(e=n.currentStyle),t===void 0?e:e[t];!(t in i)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),i[t]=e+(typeof e=="string"?"":"px")}}function Nt(n,t){var e="";if(typeof n=="string")e=n;else do{var i=b(n,"transform");i&&i!=="none"&&(e=i+" "+e)}while(!t&&(n=n.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(e)}function ki(n,t,e){if(n){var i=n.getElementsByTagName(t),o=0,s=i.length;if(e)for(;o<s;o++)e(i[o],o);return i}return[]}function dt(){var n=document.scrollingElement;return n||document.documentElement}function N(n,t,e,i,o){if(!(!n.getBoundingClientRect&&n!==window)){var s,r,a,l,c,f,d;if(n!==window&&n.parentNode&&n!==dt()?(s=n.getBoundingClientRect(),r=s.top,a=s.left,l=s.bottom,c=s.right,f=s.height,d=s.width):(r=0,a=0,l=window.innerHeight,c=window.innerWidth,f=window.innerHeight,d=window.innerWidth),(t||e)&&n!==window&&(o=o||n.parentNode,!mt))do if(o&&o.getBoundingClientRect&&(b(o,"transform")!=="none"||e&&b(o,"position")!=="static")){var p=o.getBoundingClientRect();r-=p.top+parseInt(b(o,"border-top-width")),a-=p.left+parseInt(b(o,"border-left-width")),l=r+s.height,c=a+s.width;break}while(o=o.parentNode);if(i&&n!==window){var u=Nt(o||n),g=u&&u.a,m=u&&u.d;u&&(r/=m,a/=g,d/=g,f/=m,l=r+f,c=a+d)}return{top:r,left:a,bottom:l,right:c,width:d,height:f}}}function Ci(n,t,e){for(var i=xt(n,!0),o=N(n)[t];i;){var s=N(i)[e],r=void 0;if(e==="top"||e==="left"?r=o>=s:r=o<=s,!r)return i;if(i===dt())break;i=xt(i,!1)}return!1}function kt(n,t,e,i){for(var o=0,s=0,r=n.children;s<r.length;){if(r[s].style.display!=="none"&&r[s]!==v.ghost&&(i||r[s]!==v.dragged)&&at(r[s],e.draggable,n,!1)){if(o===t)return r[s];o++}s++}return null}function Ke(n,t){for(var e=n.lastElementChild;e&&(e===v.ghost||b(e,"display")==="none"||t&&!be(e,t));)e=e.previousElementSibling;return e||null}function nt(n,t){var e=0;if(!n||!n.parentNode)return-1;for(;n=n.previousElementSibling;)n.nodeName.toUpperCase()!=="TEMPLATE"&&n!==v.clone&&(!t||be(n,t))&&e++;return e}function Li(n){var t=0,e=0,i=dt();if(n)do{var o=Nt(n),s=o.a,r=o.d;t+=n.scrollLeft*s,e+=n.scrollTop*r}while(n!==i&&(n=n.parentNode));return[t,e]}function _n(n,t){for(var e in n)if(n.hasOwnProperty(e)){for(var i in t)if(t.hasOwnProperty(i)&&t[i]===n[e][i])return Number(e)}return-1}function xt(n,t){if(!n||!n.getBoundingClientRect)return dt();var e=n,i=!1;do if(e.clientWidth<e.scrollWidth||e.clientHeight<e.scrollHeight){var o=b(e);if(e.clientWidth<e.scrollWidth&&(o.overflowX=="auto"||o.overflowX=="scroll")||e.clientHeight<e.scrollHeight&&(o.overflowY=="auto"||o.overflowY=="scroll")){if(!e.getBoundingClientRect||e===document.body)return dt();if(i||t)return e;i=!0}}while(e=e.parentNode);return dt()}function Rn(n,t){if(n&&t)for(var e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n}function Te(n,t){return Math.round(n.top)===Math.round(t.top)&&Math.round(n.left)===Math.round(t.left)&&Math.round(n.height)===Math.round(t.height)&&Math.round(n.width)===Math.round(t.width)}var jt;function Bi(n,t){return function(){if(!jt){var e=arguments,i=this;e.length===1?n.call(i,e[0]):n.apply(i,e),jt=setTimeout(function(){jt=void 0},t)}}}function Pn(){clearTimeout(jt),jt=void 0}function Fi(n,t,e){n.scrollLeft+=t,n.scrollTop+=e}function Hi(n){var t=window.Polymer,e=window.jQuery||window.Zepto;return t&&t.dom?t.dom(n).cloneNode(!0):e?e(n).clone(!0)[0]:n.cloneNode(!0)}function Vi(n,t,e){var i={};return Array.from(n.children).forEach(function(o){var s,r,a,l;if(!(!at(o,t.draggable,n,!1)||o.animated||o===e)){var c=N(o);i.left=Math.min((s=i.left)!==null&&s!==void 0?s:1/0,c.left),i.top=Math.min((r=i.top)!==null&&r!==void 0?r:1/0,c.top),i.right=Math.max((a=i.right)!==null&&a!==void 0?a:-1/0,c.right),i.bottom=Math.max((l=i.bottom)!==null&&l!==void 0?l:-1/0,c.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var j="Sortable"+new Date().getTime();function Mn(){var n=[],t;return{captureAnimationState:function(){if(n=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(o){if(!(b(o,"display")==="none"||o===v.ghost)){n.push({target:o,rect:N(o)});var s=ft({},n[n.length-1].rect);if(o.thisAnimationDuration){var r=Nt(o,!0);r&&(s.top-=r.f,s.left-=r.e)}o.fromRect=s}})}},addAnimationState:function(i){n.push(i)},removeAnimationState:function(i){n.splice(_n(n,{target:i}),1)},animateAll:function(i){var o=this;if(!this.options.animation){clearTimeout(t),typeof i=="function"&&i();return}var s=!1,r=0;n.forEach(function(a){var l=0,c=a.target,f=c.fromRect,d=N(c),p=c.prevFromRect,u=c.prevToRect,g=a.rect,m=Nt(c,!0);m&&(d.top-=m.f,d.left-=m.e),c.toRect=d,c.thisAnimationDuration&&Te(p,d)&&!Te(f,d)&&(g.top-d.top)/(g.left-d.left)===(f.top-d.top)/(f.left-d.left)&&(l=kn(g,p,u,o.options)),Te(d,f)||(c.prevFromRect=f,c.prevToRect=d,l||(l=o.options.animation),o.animate(c,g,d,l)),l&&(s=!0,r=Math.max(r,l),clearTimeout(c.animationResetTimer),c.animationResetTimer=setTimeout(function(){c.animationTime=0,c.prevFromRect=null,c.fromRect=null,c.prevToRect=null,c.thisAnimationDuration=null},l),c.thisAnimationDuration=l)}),clearTimeout(t),s?t=setTimeout(function(){typeof i=="function"&&i()},r):typeof i=="function"&&i(),n=[]},animate:function(i,o,s,r){if(r){b(i,"transition",""),b(i,"transform","");var a=Nt(this.el),l=a&&a.a,c=a&&a.d,f=(o.left-s.left)/(l||1),d=(o.top-s.top)/(c||1);i.animatingX=!!f,i.animatingY=!!d,b(i,"transform","translate3d("+f+"px,"+d+"px,0)"),this.forRepaintDummy=Nn(i),b(i,"transition","transform "+r+"ms"+(this.options.easing?" "+this.options.easing:"")),b(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){b(i,"transition",""),b(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},r)}}}}function Nn(n){return n.offsetWidth}function kn(n,t,e,i){return Math.sqrt(Math.pow(t.top-n.top,2)+Math.pow(t.left-n.left,2))/Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))*i.animation}var _t=[],_e={initializeByDefault:!0},te={mount:function(t){for(var e in _e)_e.hasOwnProperty(e)&&!(e in t)&&(t[e]=_e[e]);_t.forEach(function(i){if(i.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}),_t.push(t)},pluginEvent:function(t,e,i){var o=this;this.eventCanceled=!1,i.cancel=function(){o.eventCanceled=!0};var s=t+"Global";_t.forEach(function(r){e[r.pluginName]&&(e[r.pluginName][s]&&e[r.pluginName][s](ft({sortable:e},i)),e.options[r.pluginName]&&e[r.pluginName][t]&&e[r.pluginName][t](ft({sortable:e},i)))})},initializePlugins:function(t,e,i,o){_t.forEach(function(a){var l=a.pluginName;if(!(!t.options[l]&&!a.initializeByDefault)){var c=new a(t,e,t.options);c.sortable=t,c.options=t.options,t[l]=c,gt(i,c.defaults)}});for(var s in t.options)if(t.options.hasOwnProperty(s)){var r=this.modifyOption(t,s,t.options[s]);typeof r<"u"&&(t.options[s]=r)}},getEventProperties:function(t,e){var i={};return _t.forEach(function(o){typeof o.eventProperties=="function"&>(i,o.eventProperties.call(e[o.pluginName],t))}),i},modifyOption:function(t,e,i){var o;return _t.forEach(function(s){t[s.pluginName]&&s.optionListeners&&typeof s.optionListeners[e]=="function"&&(o=s.optionListeners[e].call(t[s.pluginName],i))}),o}};function Bn(n){var t=n.sortable,e=n.rootEl,i=n.name,o=n.targetEl,s=n.cloneEl,r=n.toEl,a=n.fromEl,l=n.oldIndex,c=n.newIndex,f=n.oldDraggableIndex,d=n.newDraggableIndex,p=n.originalEvent,u=n.putSortable,g=n.extraEventProperties;if(t=t||e&&e[j],!!t){var m,S=t.options,O="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!mt&&!Zt?m=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(m=document.createEvent("Event"),m.initEvent(i,!0,!0)),m.to=r||e,m.from=a||e,m.item=o||e,m.clone=s,m.oldIndex=l,m.newIndex=c,m.oldDraggableIndex=f,m.newDraggableIndex=d,m.originalEvent=p,m.pullMode=u?u.lastPutMode:void 0;var w=ft(ft({},g),te.getEventProperties(i,t));for(var D in w)m[D]=w[D];e&&e.dispatchEvent(m),S[O]&&S[O].call(t,m)}}var Fn=["evt"],G=function(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=i.evt,s=In(i,Fn);te.pluginEvent.bind(v)(t,e,ft({dragEl:h,parentEl:_,ghostEl:y,rootEl:L,nextEl:Lt,lastDownEl:ue,cloneEl:I,cloneHidden:St,dragStarted:Yt,putSortable:H,activeSortable:v.active,originalEvent:o,oldIndex:Mt,oldDraggableIndex:qt,newIndex:Z,newDraggableIndex:wt,hideGhostForTarget:Ki,unhideGhostForTarget:Yi,cloneNowHidden:function(){St=!0},cloneNowShown:function(){St=!1},dispatchSortableEvent:function(a){K({sortable:e,name:a,originalEvent:o})}},s))};function K(n){Bn(ft({putSortable:H,cloneEl:I,targetEl:h,rootEl:L,oldIndex:Mt,oldDraggableIndex:qt,newIndex:Z,newDraggableIndex:wt},n))}var h,_,y,L,Lt,ue,I,St,Mt,Z,qt,wt,le,H,Pt=!1,ve=!1,ye=[],At,rt,Re,Pe,Ii,Ti,Yt,Rt,Jt,Qt=!1,ce=!1,pe,z,Me=[],He=!1,we=[],xe=typeof document<"u",de=Xe,_i=Zt||mt?"cssFloat":"float",Hn=xe&&!Pi&&!Xe&&"draggable"in document.createElement("div"),Wi=(function(){if(xe){if(mt)return!1;var n=document.createElement("x");return n.style.cssText="pointer-events:auto",n.style.pointerEvents==="auto"}})(),zi=function(t,e){var i=b(t),o=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),s=kt(t,0,e),r=kt(t,1,e),a=s&&b(s),l=r&&b(r),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+N(s).width,f=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+N(r).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.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&&i[_i]==="none"||r&&i[_i]==="none"&&c+f>o)?"vertical":"horizontal"},Vn=function(t,e,i){var o=i?t.left:t.top,s=i?t.right:t.bottom,r=i?t.width:t.height,a=i?e.left:e.top,l=i?e.right:e.bottom,c=i?e.width:e.height;return o===a||s===l||o+r/2===a+c/2},Wn=function(t,e){var i;return ye.some(function(o){var s=o[j].options.emptyInsertThreshold;if(!(!s||Ke(o))){var r=N(o),a=t>=r.left-s&&t<=r.right+s,l=e>=r.top-s&&e<=r.bottom+s;if(a&&l)return i=o}}),i},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 p=(r?a:l).options.group.name;return s===!0||typeof s=="string"&&s===p||s.join&&s.indexOf(p)>-1}}var i={},o=t.group;(!o||he(o)!="object")&&(o={name:o}),i.name=o.name,i.checkPull=e(o.pull,!0),i.checkPut=e(o.put),i.revertClone=o.revertClone,t.group=i},Ki=function(){!Wi&&y&&b(y,"display","none")},Yi=function(){!Wi&&y&&b(y,"display","")};xe&&!Pi&&document.addEventListener("click",function(n){if(ve)return n.preventDefault(),n.stopPropagation&&n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation(),ve=!1,!1},!0);var Ct=function(t){if(h){t=t.touches?t.touches[0]:t;var e=Wn(t.clientX,t.clientY);if(e){var i={};for(var o in t)t.hasOwnProperty(o)&&(i[o]=t[o]);i.target=i.rootEl=e,i.preventDefault=void 0,i.stopPropagation=void 0,e[j]._onDragOver(i)}}},zn=function(t){h&&h.parentNode[j]._isOutsideThisEl(t.target)};function v(n,t){if(!(n&&n.nodeType&&n.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(n));this.el=n,this.options=t=gt({},t),n[j]=this;var e={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(n.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return zi(n,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};te.initializePlugins(this,n,e);for(var i in e)!(i in t)&&(t[i]=e[i]);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:Hn,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?E(n,"pointerdown",this._onTapStart):(E(n,"mousedown",this._onTapStart),E(n,"touchstart",this._onTapStart)),this.nativeDraggable&&(E(n,"dragover",this),E(n,"dragenter",this)),ye.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),gt(this,Mn())}v.prototype={constructor:v,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(Rt=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,i=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(qn(i),!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,i,!1),!(l&&l.animated)&&ue!==l)){if(Mt=nt(l),qt=nt(l,o.draggable),typeof f=="function"){if(f.call(this,t,l,this)){K({sortable:e,rootEl:c,name:"filter",targetEl:l,toEl:i,fromEl:i}),G("filter",e,{evt:t}),s&&t.preventDefault();return}}else if(f&&(f=f.split(",").some(function(d){if(d=at(c,d.trim(),i,!1),d)return K({sortable:e,rootEl:d,name:"filter",targetEl:l,fromEl:i,toEl:i}),G("filter",e,{evt:t}),!0}),f)){s&&t.preventDefault();return}o.handle&&!at(c,o.handle,i,!1)||this._prepareDragStart(t,a,l)}}},_prepareDragStart:function(t,e,i){var o=this,s=o.el,r=o.options,a=s.ownerDocument,l;if(i&&!h&&i.parentNode===s){var c=N(i);if(L=s,h=i,_=h.parentNode,Lt=h.nextSibling,ue=i,le=r.group,v.dragged=h,At={target:h,clientX:(e||t).clientX,clientY:(e||t).clientY},Ii=At.clientX-c.left,Ti=At.clientY-c.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,h.style["will-change"]="all",l=function(){if(G("delayEnded",o,{evt:t}),v.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!Di&&o.nativeDraggable&&(h.draggable=!0),o._triggerDragStart(t,e),K({sortable:o,name:"choose",originalEvent:t}),Q(h,r.chosenClass,!0)},r.ignore.split(",").forEach(function(f){ki(h,f.trim(),Ne)}),E(a,"dragover",Ct),E(a,"mousemove",Ct),E(a,"touchmove",Ct),r.supportPointer?(E(a,"pointerup",o._onDrop),!this.nativeDraggable&&E(a,"pointercancel",o._onDrop)):(E(a,"mouseup",o._onDrop),E(a,"touchend",o._onDrop),E(a,"touchcancel",o._onDrop)),Di&&this.nativeDraggable&&(this.options.touchStartThreshold=4,h.draggable=!0),G("delayStart",this,{evt:t}),r.delay&&(!r.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(Zt||mt))){if(v.eventCanceled){this._onDrop();return}r.supportPointer?(E(a,"pointerup",o._disableDelayedDrag),E(a,"pointercancel",o._disableDelayedDrag)):(E(a,"mouseup",o._disableDelayedDrag),E(a,"touchend",o._disableDelayedDrag),E(a,"touchcancel",o._disableDelayedDrag)),E(a,"mousemove",o._delayedDragTouchMoveHandler),E(a,"touchmove",o._delayedDragTouchMoveHandler),r.supportPointer&&E(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&&Ne(h),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;x(t,"mouseup",this._disableDelayedDrag),x(t,"touchend",this._disableDelayedDrag),x(t,"touchcancel",this._disableDelayedDrag),x(t,"pointerup",this._disableDelayedDrag),x(t,"pointercancel",this._disableDelayedDrag),x(t,"mousemove",this._delayedDragTouchMoveHandler),x(t,"touchmove",this._delayedDragTouchMoveHandler),x(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t,!this.nativeDraggable||e?this.options.supportPointer?E(document,"pointermove",this._onTouchMove):e?E(document,"touchmove",this._onTouchMove):E(document,"mousemove",this._onTouchMove):(E(h,"dragend",this),E(L,"dragstart",this._onDragStart));try{document.selection?ge(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(Pt=!1,L&&h){G("dragStarted",this,{evt:e}),this.nativeDraggable&&E(document,"dragover",zn);var i=this.options;!t&&Q(h,i.dragClass,!1),Q(h,i.ghostClass,!0),v.active=this,t&&this._appendGhost(),K({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(rt){this._lastX=rt.clientX,this._lastY=rt.clientY,Ki();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[j]._isOutsideThisEl(t),e)do{if(e[j]){var i=void 0;if(i=e[j]._onDragOver({clientX:rt.clientX,clientY:rt.clientY,target:t,rootEl:e}),i&&!this.options.dragoverBubble)break}t=e}while(e=Ni(e));Yi()}},_onTouchMove:function(t){if(At){var e=this.options,i=e.fallbackTolerance,o=e.fallbackOffset,s=t.touches?t.touches[0]:t,r=y&&Nt(y,!0),a=y&&r&&r.a,l=y&&r&&r.d,c=de&&z&&Li(z),f=(s.clientX-At.clientX+o.x)/(a||1)+(c?c[0]-Me[0]:0)/(a||1),d=(s.clientY-At.clientY+o.y)/(l||1)+(c?c[1]-Me[1]:0)/(l||1);if(!v.active&&!Pt){if(i&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<i)return;this._onDragStart(t,!0)}if(y){r?(r.e+=f-(Re||0),r.f+=d-(Pe||0)):r={a:1,b:0,c:0,d:1,e:f,f:d};var p="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");b(y,"webkitTransform",p),b(y,"mozTransform",p),b(y,"msTransform",p),b(y,"transform",p),Re=f,Pe=d,rt=s}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!y){var t=this.options.fallbackOnBody?document.body:L,e=N(h,!0,de,!0,t),i=this.options;if(de){for(z=t;b(z,"position")==="static"&&b(z,"transform")==="none"&&z!==document;)z=z.parentNode;z!==document.body&&z!==document.documentElement?(z===document&&(z=dt()),e.top+=z.scrollTop,e.left+=z.scrollLeft):z=dt(),Me=Li(z)}y=h.cloneNode(!0),Q(y,i.ghostClass,!1),Q(y,i.fallbackClass,!0),Q(y,i.dragClass,!0),b(y,"transition",""),b(y,"transform",""),b(y,"box-sizing","border-box"),b(y,"margin",0),b(y,"top",e.top),b(y,"left",e.left),b(y,"width",e.width),b(y,"height",e.height),b(y,"opacity","0.8"),b(y,"position",de?"absolute":"fixed"),b(y,"zIndex","100000"),b(y,"pointerEvents","none"),v.ghost=y,t.appendChild(y),b(y,"transform-origin",Ii/parseInt(y.style.width)*100+"% "+Ti/parseInt(y.style.height)*100+"%")}},_onDragStart:function(t,e){var i=this,o=t.dataTransfer,s=i.options;if(G("dragStart",this,{evt:t}),v.eventCanceled){this._onDrop();return}G("setupClone",this),v.eventCanceled||(I=Hi(h),I.removeAttribute("id"),I.draggable=!1,I.style["will-change"]="",this._hideClone(),Q(I,this.options.chosenClass,!1),v.clone=I),i.cloneId=ge(function(){G("clone",i),!v.eventCanceled&&(i.options.removeCloneOnHide||L.insertBefore(I,h),i._hideClone(),K({sortable:i,name:"clone"}))}),!e&&Q(h,s.dragClass,!0),e?(ve=!0,i._loopId=setInterval(i._emulateDragOver,50)):(x(document,"mouseup",i._onDrop),x(document,"touchend",i._onDrop),x(document,"touchcancel",i._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(i,o,h)),E(document,"drop",i),b(h,"transform","translateZ(0)")),Pt=!0,i._dragStartId=ge(i._dragStarted.bind(i,e,t)),E(document,"selectstart",i),Yt=!0,window.getSelection().removeAllRanges(),Gt&&b(document.body,"user-select","none")},_onDragOver:function(t){var e=this.el,i=t.target,o,s,r,a=this.options,l=a.group,c=v.active,f=le===l,d=a.sort,p=H||c,u,g=this,m=!1;if(He)return;function S(B,lt){G(B,g,ft({evt:t,isOwner:f,axis:u?"vertical":"horizontal",revert:r,dragRect:o,targetRect:s,canSort:d,fromSortable:p,target:i,completed:w,onMove:function(Ge,Gi){return fe(L,e,h,o,Ge,N(Ge),t,Gi)},changed:D},lt))}function O(){S("dragOverAnimationCapture"),g.captureAnimationState(),g!==p&&p.captureAnimationState()}function w(B){return S("dragOverCompleted",{insertion:B}),B&&(f?c._hideClone():c._showClone(g),g!==p&&(Q(h,H?H.options.ghostClass:c.options.ghostClass,!1),Q(h,a.ghostClass,!0)),H!==g&&g!==v.active?H=g:g===v.active&&H&&(H=null),p===g&&(g._ignoreWhileAnimating=i),g.animateAll(function(){S("dragOverAnimationComplete"),g._ignoreWhileAnimating=null}),g!==p&&(p.animateAll(),p._ignoreWhileAnimating=null)),(i===h&&!h.animated||i===e&&!i.animated)&&(Rt=null),!a.dragoverBubble&&!t.rootEl&&i!==document&&(h.parentNode[j]._isOutsideThisEl(t.target),!B&&Ct(t)),!a.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),m=!0}function D(){Z=nt(h),wt=nt(h,a.draggable),K({sortable:g,name:"change",toEl:e,newIndex:Z,newDraggableIndex:wt,originalEvent:t})}if(t.preventDefault!==void 0&&t.cancelable&&t.preventDefault(),i=at(i,a.draggable,e,!0),S("dragOver"),v.eventCanceled)return m;if(h.contains(t.target)||i.animated&&i.animatingX&&i.animatingY||g._ignoreWhileAnimating===i)return w(!1);if(ve=!1,c&&!a.disabled&&(f?d||(r=_!==L):H===this||(this.lastPutMode=le.checkPull(this,c,h,t))&&l.checkPut(this,c,h,t))){if(u=this._getDirection(t,i)==="vertical",o=N(h),S("dragOverValid"),v.eventCanceled)return m;if(r)return _=L,O(),this._hideClone(),S("revert"),v.eventCanceled||(Lt?L.insertBefore(h,Lt):L.appendChild(h)),w(!0);var A=Ke(e,a.draggable);if(!A||$n(t,u,this)&&!A.animated){if(A===h)return w(!1);if(A&&e===t.target&&(i=A),i&&(s=N(i)),fe(L,e,h,o,i,s,t,!!i)!==!1)return O(),A&&A.nextSibling?e.insertBefore(h,A.nextSibling):e.appendChild(h),_=e,D(),w(!0)}else if(A&&Yn(t,u,this)){var C=kt(e,0,a,!0);if(C===h)return w(!1);if(i=C,s=N(i),fe(L,e,h,o,i,s,t,!1)!==!1)return O(),e.insertBefore(h,C),_=e,D(),w(!0)}else if(i.parentNode===e){s=N(i);var F=0,q,J=h.parentNode!==e,T=!Vn(h.animated&&h.toRect||o,i.animated&&i.toRect||s,u),V=u?"top":"left",X=Ci(i,"top","top")||Ci(h,"top","top"),tt=X?X.scrollTop:void 0;Rt!==i&&(q=s[V],Qt=!1,ce=!T&&a.invertSwap||J),F=Un(t,i,s,u,T?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,ce,Rt===i);var W;if(F!==0){var k=nt(h);do k-=F,W=_.children[k];while(W&&(b(W,"display")==="none"||W===y))}if(F===0||W===i)return w(!1);Rt=i,Jt=F;var Y=i.nextElementSibling,P=!1;P=F===1;var $=fe(L,e,h,o,i,s,t,P);if($!==!1)return($===1||$===-1)&&(P=$===1),He=!0,setTimeout(Kn,30),O(),P&&!Y?e.appendChild(h):i.parentNode.insertBefore(h,P?Y:i),X&&Fi(X,0,tt-X.scrollTop),_=h.parentNode,q!==void 0&&!ce&&(pe=Math.abs(q-N(i)[V])),D(),w(!0)}if(e.contains(h))return w(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){x(document,"mousemove",this._onTouchMove),x(document,"touchmove",this._onTouchMove),x(document,"pointermove",this._onTouchMove),x(document,"dragover",Ct),x(document,"mousemove",Ct),x(document,"touchmove",Ct)},_offUpEvents:function(){var t=this.el.ownerDocument;x(t,"mouseup",this._onDrop),x(t,"touchend",this._onDrop),x(t,"pointerup",this._onDrop),x(t,"pointercancel",this._onDrop),x(t,"touchcancel",this._onDrop),x(document,"selectstart",this)},_onDrop:function(t){var e=this.el,i=this.options;if(Z=nt(h),wt=nt(h,i.draggable),G("drop",this,{evt:t}),_=h&&h.parentNode,Z=nt(h),wt=nt(h,i.draggable),v.eventCanceled){this._nulling();return}Pt=!1,ce=!1,Qt=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Ve(this.cloneId),Ve(this._dragStartId),this.nativeDraggable&&(x(document,"drop",this),x(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Gt&&b(document.body,"user-select",""),b(h,"transform",""),t&&(Yt&&(t.cancelable&&t.preventDefault(),!i.dropBubble&&t.stopPropagation()),y&&y.parentNode&&y.parentNode.removeChild(y),(L===_||H&&H.lastPutMode!=="clone")&&I&&I.parentNode&&I.parentNode.removeChild(I),h&&(this.nativeDraggable&&x(h,"dragend",this),Ne(h),h.style["will-change"]="",Yt&&!Pt&&Q(h,H?H.options.ghostClass:this.options.ghostClass,!1),Q(h,this.options.chosenClass,!1),K({sortable:this,name:"unchoose",toEl:_,newIndex:null,newDraggableIndex:null,originalEvent:t}),L!==_?(Z>=0&&(K({rootEl:_,name:"add",toEl:_,fromEl:L,originalEvent:t}),K({sortable:this,name:"remove",toEl:_,originalEvent:t}),K({rootEl:_,name:"sort",toEl:_,fromEl:L,originalEvent:t}),K({sortable:this,name:"sort",toEl:_,originalEvent:t})),H&&H.save()):Z!==Mt&&Z>=0&&(K({sortable:this,name:"update",toEl:_,originalEvent:t}),K({sortable:this,name:"sort",toEl:_,originalEvent:t})),v.active&&((Z==null||Z===-1)&&(Z=Mt,wt=qt),K({sortable:this,name:"end",toEl:_,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){G("nulling",this),L=h=_=y=Lt=I=ue=St=At=rt=Yt=Z=wt=Mt=qt=Rt=Jt=H=le=v.dragged=v.ghost=v.clone=v.active=null,we.forEach(function(t){t.checked=!0}),we.length=Re=Pe=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":h&&(this._onDragOver(t),Xn(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,i=this.el.children,o=0,s=i.length,r=this.options;o<s;o++)e=i[o],at(e,r.draggable,this.el,!1)&&t.push(e.getAttribute(r.dataIdAttr)||jn(e));return t},sort:function(t,e){var i={},o=this.el;this.toArray().forEach(function(s,r){var a=o.children[r];at(a,this.options.draggable,o,!1)&&(i[s]=a)},this),e&&this.captureAnimationState(),t.forEach(function(s){i[s]&&(o.removeChild(i[s]),o.appendChild(i[s]))}),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return at(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var i=this.options;if(e===void 0)return i[t];var o=te.modifyOption(this,t,e);typeof o<"u"?i[t]=o:i[t]=e,t==="group"&&Xi(i)},destroy:function(){G("destroy",this);var t=this.el;t[j]=null,x(t,"mousedown",this._onTapStart),x(t,"touchstart",this._onTapStart),x(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(x(t,"dragover",this),x(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(e){e.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),ye.splice(ye.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!St){if(G("hideClone",this),v.eventCanceled)return;b(I,"display","none"),this.options.removeCloneOnHide&&I.parentNode&&I.parentNode.removeChild(I),St=!0}},_showClone:function(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(St){if(G("showClone",this),v.eventCanceled)return;h.parentNode==L&&!this.options.group.revertClone?L.insertBefore(I,h):Lt?L.insertBefore(I,Lt):L.appendChild(I),this.options.group.revertClone&&this.animate(h,I),b(I,"display",""),St=!1}}};function Xn(n){n.dataTransfer&&(n.dataTransfer.dropEffect="move"),n.cancelable&&n.preventDefault()}function fe(n,t,e,i,o,s,r,a){var l,c=n[j],f=c.options.onMove,d;return window.CustomEvent&&!mt&&!Zt?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=t,l.from=n,l.dragged=e,l.draggedRect=i,l.related=o||t,l.relatedRect=s||N(t),l.willInsertAfter=a,l.originalEvent=r,n.dispatchEvent(l),f&&(d=f.call(c,l,r)),d}function Ne(n){n.draggable=!1}function Kn(){He=!1}function Yn(n,t,e){var i=N(kt(e.el,0,e.options,!0)),o=Vi(e.el,e.options,y),s=10;return t?n.clientX<o.left-s||n.clientY<i.top&&n.clientX<i.right:n.clientY<o.top-s||n.clientY<i.bottom&&n.clientX<i.left}function $n(n,t,e){var i=N(Ke(e.el,e.options.draggable)),o=Vi(e.el,e.options,y),s=10;return t?n.clientX>o.right+s||n.clientY>i.bottom&&n.clientX>i.left:n.clientY>o.bottom+s||n.clientX>i.right&&n.clientY>i.top}function Un(n,t,e,i,o,s,r,a){var l=i?n.clientY:n.clientX,c=i?e.height:e.width,f=i?e.top:e.left,d=i?e.bottom:e.right,p=!1;if(!r){if(a&&pe<c*o){if(!Qt&&(Jt===1?l>f+c*s/2:l<d-c*s/2)&&(Qt=!0),Qt)p=!0;else if(Jt===1?l<f+pe:l>d-pe)return-Jt}else if(l>f+c*(1-o)/2&&l<d-c*(1-o)/2)return Gn(t)}return p=p||r,p&&(l<f+c*s/2||l>d-c*s/2)?l>f+c/2?1:-1:0}function Gn(n){return nt(h)<nt(n)?1:-1}function jn(n){for(var t=n.tagName+n.className+n.src+n.href+n.textContent,e=t.length,i=0;e--;)i+=t.charCodeAt(e);return i.toString(36)}function qn(n){we.length=0;for(var t=n.getElementsByTagName("input"),e=t.length;e--;){var i=t[e];i.checked&&we.push(i)}}function ge(n){return setTimeout(n,0)}function Ve(n){return clearTimeout(n)}xe&&E(document,"touchmove",function(n){(v.active||Pt)&&n.cancelable&&n.preventDefault()});v.utils={on:E,off:x,css:b,find:ki,is:function(t,e){return!!at(t,e,t,!1)},extend:Rn,throttle:Bi,closest:at,toggleClass:Q,clone:Hi,index:nt,nextTick:ge,cancelNextTick:Ve,detectDirection:zi,getChild:kt,expando:j};v.get=function(n){return n[j]};v.mount=function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];t[0].constructor===Array&&(t=t[0]),t.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(v.utils=ft(ft({},v.utils),i.utils)),te.mount(i)})};v.create=function(n,t){return new v(n,t)};v.version=Tn;var M=[],$t,We,ze=!1,ke,Be,Se,Ut;function Jn(){function n(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this))}return n.prototype={dragStarted:function(e){var i=e.originalEvent;this.sortable.nativeDraggable?E(document,"dragover",this._handleAutoScroll):this.options.supportPointer?E(document,"pointermove",this._handleFallbackAutoScroll):i.touches?E(document,"touchmove",this._handleFallbackAutoScroll):E(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(e){var i=e.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?x(document,"dragover",this._handleAutoScroll):(x(document,"pointermove",this._handleFallbackAutoScroll),x(document,"touchmove",this._handleFallbackAutoScroll),x(document,"mousemove",this._handleFallbackAutoScroll)),Ri(),me(),Pn()},nulling:function(){Se=We=$t=ze=Ut=ke=Be=null,M.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(e,i){var o=this,s=(e.touches?e.touches[0]:e).clientX,r=(e.touches?e.touches[0]:e).clientY,a=document.elementFromPoint(s,r);if(Se=e,i||this.options.forceAutoScrollFallback||Zt||mt||Gt){Fe(e,this.options,a,i);var l=xt(a,!0);ze&&(!Ut||s!==ke||r!==Be)&&(Ut&&Ri(),Ut=setInterval(function(){var c=xt(document.elementFromPoint(s,r),!0);c!==l&&(l=c,me()),Fe(e,o.options,c,i)},10),ke=s,Be=r)}else{if(!this.options.bubbleScroll||xt(a,!0)===dt()){me();return}Fe(e,this.options,xt(a,!1),!1)}}},gt(n,{pluginName:"scroll",initializeByDefault:!0})}function me(){M.forEach(function(n){clearInterval(n.pid)}),M=[]}function Ri(){clearInterval(Ut)}var Fe=Bi(function(n,t,e,i){if(t.scroll){var o=(n.touches?n.touches[0]:n).clientX,s=(n.touches?n.touches[0]:n).clientY,r=t.scrollSensitivity,a=t.scrollSpeed,l=dt(),c=!1,f;We!==e&&(We=e,me(),$t=t.scroll,f=t.scrollFn,$t===!0&&($t=xt(e,!0)));var d=0,p=$t;do{var u=p,g=N(u),m=g.top,S=g.bottom,O=g.left,w=g.right,D=g.width,A=g.height,C=void 0,F=void 0,q=u.scrollWidth,J=u.scrollHeight,T=b(u),V=u.scrollLeft,X=u.scrollTop;u===l?(C=D<q&&(T.overflowX==="auto"||T.overflowX==="scroll"||T.overflowX==="visible"),F=A<J&&(T.overflowY==="auto"||T.overflowY==="scroll"||T.overflowY==="visible")):(C=D<q&&(T.overflowX==="auto"||T.overflowX==="scroll"),F=A<J&&(T.overflowY==="auto"||T.overflowY==="scroll"));var tt=C&&(Math.abs(w-o)<=r&&V+D<q)-(Math.abs(O-o)<=r&&!!V),W=F&&(Math.abs(S-s)<=r&&X+A<J)-(Math.abs(m-s)<=r&&!!X);if(!M[d])for(var k=0;k<=d;k++)M[k]||(M[k]={});(M[d].vx!=tt||M[d].vy!=W||M[d].el!==u)&&(M[d].el=u,M[d].vx=tt,M[d].vy=W,clearInterval(M[d].pid),(tt!=0||W!=0)&&(c=!0,M[d].pid=setInterval(function(){i&&this.layer===0&&v.active._onTouchMove(Se);var Y=M[this.layer].vy?M[this.layer].vy*a:0,P=M[this.layer].vx?M[this.layer].vx*a:0;typeof f=="function"&&f.call(v.dragged.parentNode[j],P,Y,n,Se,M[this.layer].el)!=="continue"||Fi(M[this.layer].el,P,Y)}.bind({layer:d}),24))),d++}while(t.bubbleScroll&&p!==l&&(p=xt(p,!1)));ze=c}},30),$i=function(t){var e=t.originalEvent,i=t.putSortable,o=t.dragEl,s=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,l=t.unhideGhostForTarget;if(e){var c=i||s;a();var f=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,d=document.elementFromPoint(f.clientX,f.clientY);l(),c&&!c.el.contains(d)&&(r("spill"),this.onSpill({dragEl:o,putSortable:i}))}};function Ye(){}Ye.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){var e=t.dragEl,i=t.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var o=kt(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(e,o):this.sortable.el.appendChild(e),this.sortable.animateAll(),i&&i.animateAll()},drop:$i};gt(Ye,{pluginName:"revertOnSpill"});function $e(){}$e.prototype={onSpill:function(t){var e=t.dragEl,i=t.putSortable,o=i||this.sortable;o.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),o.animateAll()},drop:$i};gt($e,{pluginName:"removeOnSpill"});v.mount(new Jn);v.mount($e,Ye);var Ui=v;function bt(n){return n==null||n===""||typeof n=="string"&&n.trim()===""}function R(n){return!bt(n)}var Ee=class{constructor({element:t,options:e,placeholder:i,state:o,canOptionLabelsWrap:s=!0,canSelectPlaceholder:r=!0,initialOptionLabel:a=null,initialOptionLabels:l=null,initialState:c=null,isHtmlAllowed:f=!1,isAutofocused:d=!1,isDisabled:p=!1,isMultiple:u=!1,isReorderable:g=!1,isSearchable:m=!1,getOptionLabelUsing:S=null,getOptionLabelsUsing:O=null,getOptionsUsing:w=null,getSearchResultsUsing:D=null,hasDynamicOptions:A=!1,hasDynamicSearchResults:C=!0,searchPrompt:F="Search...",searchDebounce:q=1e3,loadingMessage:J="Loading...",searchingMessage:T="Searching...",noSearchResultsMessage:V="No results found",maxItems:X=null,maxItemsMessage:tt="Maximum number of items selected",optionsLimit:W=null,position:k=null,searchableOptionFields:Y=["label"],livewireId:P=null,statePath:$=null,onStateChange:B=()=>{}}){this.element=t,this.options=e,this.originalOptions=JSON.parse(JSON.stringify(e)),this.placeholder=i,this.state=o,this.canOptionLabelsWrap=s,this.canSelectPlaceholder=r,this.initialOptionLabel=a,this.initialOptionLabels=l,this.initialState=c,this.isHtmlAllowed=f,this.isAutofocused=d,this.isDisabled=p,this.isMultiple=u,this.isReorderable=g,this.isSearchable=m,this.getOptionLabelUsing=S,this.getOptionLabelsUsing=O,this.getOptionsUsing=w,this.getSearchResultsUsing=D,this.hasDynamicOptions=A,this.hasDynamicSearchResults=C,this.searchPrompt=F,this.searchDebounce=q,this.loadingMessage=J,this.searchingMessage=T,this.noSearchResultsMessage=V,this.activeSearchId=0,this.maxItems=X,this.maxItemsMessage=tt,this.optionsLimit=W,this.position=k,this.searchableOptionFields=Array.isArray(Y)?Y:["label"],this.livewireId=P,this.statePath=$,this.onStateChange=B,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(i=>{i.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 i=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(!i)return;let o=i.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,i=0,o=!1;this.options.forEach(a=>{a.options&&Array.isArray(a.options)?(i+=a.options.length,o=!0):i++}),o?this.optionsList.className="fi-select-input-options-ctn":i>0&&(this.optionsList.className="fi-dropdown-list");let s=o?null:this.optionsList,r=0;for(let a of e){if(this.optionsLimit&&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){let c=this.optionsLimit-r;c<l.length&&(l=l.slice(0,c))}this.renderOptionGroup(a.label,l),r+=l.length,t+=l.length}}else{if(this.isMultiple&&Array.isArray(this.state)&&this.state.includes(a.value))continue;!s&&o&&(s=document.createElement("ul"),s.className="fi-dropdown-list",this.optionsList.appendChild(s));let l=this.createOptionElement(a.value,a);s.appendChild(l),r++,t++}}t===0?(this.searchQuery?this.showNoResultsMessage():this.isMultiple&&this.isOpen&&!this.isSearchable&&this.closeDropdown(),this.optionsList.parentNode===this.dropdown&&this.dropdown.removeChild(this.optionsList)):(this.hideLoadingState(),this.optionsList.parentNode!==this.dropdown&&this.dropdown.appendChild(this.optionsList))}renderOptionGroup(t,e){if(e.length===0)return;let i=document.createElement("li");i.className="fi-select-input-option-group";let o=document.createElement("div");o.className="fi-dropdown-header",o.textContent=t;let s=document.createElement("ul");s.className="fi-dropdown-list",e.forEach(r=>{let a=this.createOptionElement(r.value,r);s.appendChild(a)}),i.appendChild(o),i.appendChild(s),this.optionsList.appendChild(i)}createOptionElement(t,e){let i=t,o=e,s=!1;typeof e=="object"&&e!==null&&"label"in e&&"value"in e&&(i=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",i),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(i):this.state===i;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(i),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.positionDropdown());return}if(this.state===null||this.state===""){let o=document.createElement("span");o.textContent=this.placeholder,o.classList.add("fi-select-input-placeholder"),e.appendChild(o),t===this.selectedDisplayVersion&&this.selectedDisplay.replaceChildren(e);return}let i=await this.getLabelForSingleSelection();t===this.selectedDisplayVersion&&(this.addSingleSelectionDisplay(i,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(!R(this.labelRepository[o])){if(R(t[o])){this.labelRepository[o]=t[o];continue}e.push(o.toString())}}if(e.length>0&&R(this.initialOptionLabels)&&JSON.stringify(this.state)===JSON.stringify(this.initialState)){if(Array.isArray(this.initialOptionLabels))for(let o of this.initialOptionLabels)R(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)R(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 i=[];if(Array.isArray(this.state))for(let o of this.state)R(this.labelRepository[o])?i.push(this.labelRepository[o]):R(t[o])?i.push(t[o]):i.push(o);return i}createBadgeElement(t,e){let i=document.createElement("span");i.className="fi-badge fi-size-md fi-color fi-color-primary fi-text-color-600 dark:fi-text-color-200",R(t)&&i.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),i.appendChild(o);let r=this.createRemoveButton(t,e);return i.appendChild(r),i}createRemoveButton(t,e){let i=document.createElement("button");return i.type="button",i.className="fi-badge-delete-btn",i.innerHTML='<svg class="fi-icon fi-size-xs" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" data-slot="icon"><path d="M5.28 4.22a.75.75 0 0 0-1.06 1.06L6.94 8l-2.72 2.72a.75.75 0 1 0 1.06 1.06L8 9.06l2.72 2.72a.75.75 0 1 0 1.06-1.06L9.06 8l2.72-2.72a.75.75 0 0 0-1.06-1.06L8 6.94 5.28 4.22Z"></path></svg>',i.setAttribute("aria-label","Remove "+(this.isHtmlAllowed?e.replace(/<[^>]*>/g,""):e)),i.addEventListener("click",o=>{o.stopPropagation(),R(t)&&this.selectOption(t)}),i.addEventListener("keydown",o=>{(o.key===" "||o.key==="Enter")&&(o.preventDefault(),o.stopPropagation(),R(t)&&this.selectOption(t))}),i}addBadgesForSelectedOptions(t,e=this.selectedDisplay){let i=document.createElement("div");i.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);i.appendChild(a)}),e.appendChild(i),this.isReorderable&&(i.addEventListener("click",o=>{o.stopPropagation()}),i.addEventListener("mousedown",o=>{o.stopPropagation()}),new Ui(i,{animation:150,onEnd:()=>{let o=[];i.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)&&R(this.initialOptionLabel)&&this.state===this.initialState)t=this.initialOptionLabel,R(this.state)&&(this.labelRepository[this.state]=t);else if(bt(t)&&this.getOptionLabelUsing)try{t=await this.getOptionLabelUsing(),R(t)&&R(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 i=document.createElement("span");if(i.className="fi-select-input-value-label",this.isHtmlAllowed?i.innerHTML=t:i.textContent=t,e.appendChild(i),!this.canSelectPlaceholder)return;let o=document.createElement("button");o.type="button",o.className="fi-select-input-value-remove-btn",o.innerHTML='<svg class="fi-icon fi-size-sm" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd" /></svg>',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(""))}),e.appendChild(o)}getSelectedOptionLabel(t){if(R(this.labelRepository[t]))return this.labelRepository[t];let e="";for(let i of this.options)if(i.options&&Array.isArray(i.options)){for(let o of i.options)if(o.value===t){e=o.label,this.labelRepository[t]=e;break}}else if(i.value===t){e=i.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&&R(this.state))try{delete this.labelRepository[this.state];let e=await this.getOptionLabelUsing();R(e)&&(this.labelRepository[this.state]=e);let i=this.selectedDisplay.querySelector(".fi-select-input-value-label");R(i)&&(this.isHtmlAllowed?i.innerHTML=e:i.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 i=this.getVisibleOptions();for(let o of i)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(),i=Array.isArray(e)?e:e&&Array.isArray(e.options)?e.options:[];if(this.options=i,this.originalOptions=JSON.parse(JSON.stringify(i)),this.populateLabelRepositoryFromOptions(i),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()}}if(this.hideLoadingState(),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 i=0;i<e.length;i++)if(this.state.includes(e[i].getAttribute("data-value"))){this.selectedIndex=i;break}}}else for(let i=0;i<e.length;i++)if(e[i].getAttribute("data-value")===this.state){this.selectedIndex=i;break}this.selectedIndex===-1&&e.length>0&&(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=[wi(4),Si({padding:5})];this.position!=="top"&&this.position!=="bottom"&&e.push(xi());let i=this.selectButton.closest(".fi-fixed-positioning-context")!==null&&this.selectButton.closest(".fi-absolute-positioning-context")===null;Ei(this.selectButton,this.dropdown,{placement:t,middleware:e,strategy:i?"fixed":"absolute"}).then(({x:o,y:s})=>{Object.assign(this.dropdown.style,{left:`${o}px`,top:`${s}px`})})}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<t.length&&t[this.selectedIndex].classList.remove("fi-selected"),this.selectedIndex===t.length-1&&this.isSearchable&&this.searchInput){this.selectedIndex=-1,this.searchInput.focus(),this.dropdown.removeAttribute("aria-activedescendant");return}this.selectedIndex=(this.selectedIndex+1)%t.length,t[this.selectedIndex].classList.add("fi-selected"),t[this.selectedIndex].focus(),t[this.selectedIndex].id&&this.dropdown.setAttribute("aria-activedescendant",t[this.selectedIndex].id),this.scrollOptionIntoView(t[this.selectedIndex])}}focusPreviousOption(){let t=this.getVisibleOptions();if(t.length!==0){if(this.selectedIndex>=0&&this.selectedIndex<t.length&&t[this.selectedIndex].classList.remove("fi-selected"),(this.selectedIndex===0||this.selectedIndex===-1)&&this.isSearchable&&this.searchInput){this.selectedIndex=-1,this.searchInput.focus(),this.dropdown.removeAttribute("aria-activedescendant");return}this.selectedIndex=(this.selectedIndex-1+t.length)%t.length,t[this.selectedIndex].classList.add("fi-selected"),t[this.selectedIndex].focus(),t[this.selectedIndex].id&&this.dropdown.setAttribute("aria-activedescendant",t[this.selectedIndex].id),this.scrollOptionIntoView(t[this.selectedIndex])}}scrollOptionIntoView(t){if(!t)return;let e=this.dropdown.getBoundingClientRect(),i=t.getBoundingClientRect();i.bottom>e.bottom?this.dropdown.scrollTop+=i.bottom-e.bottom:i.top<e.top&&(this.dropdown.scrollTop-=e.top-i.top)}getVisibleOptions(){let t=[];this.optionsList.classList.contains("fi-dropdown-list")?t=Array.from(this.optionsList.querySelectorAll(':scope > 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 i=!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,i=!0;break}if(i)break}else if(o.value===e){t[e]=o.label,i=!0;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 i=++this.activeSearchId;this.isSearching=!0;try{this.showLoadingState(!0);let o=await this.getSearchResultsUsing(e);if(i!==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.positionDropdown(),this.options.length===0&&this.showNoResultsMessage()}catch(o){i===this.activeSearchId&&(console.error("Error fetching search results:",o),this.hideLoadingState(),this.options=JSON.parse(JSON.stringify(this.originalOptions)),this.renderOptions())}finally{i===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)}hideLoadingState(){let t=this.dropdown.querySelector(".fi-select-input-message");t&&t.remove()}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)}filterOptions(t){let e=this.searchableOptionFields.includes("label"),i=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)||i&&String(a.value).toLowerCase().includes(t));r.length>0&&o.push({label:s.label,options:r})}else(e&&s.label.toLowerCase().includes(t)||i&&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(R(o)){let s=o.parentElement;R(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.positionDropdown(),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 i=this.selectedDisplay.querySelector(".fi-select-input-value-badges-ctn");bt(i)?this.updateSelectedDisplay():this.addSingleBadge(t,i),this.renderOptions(),this.isOpen&&this.positionDropdown(),this.maintainFocusInMultipleMode(),this.onStateChange(this.state)}async addSingleBadge(t,e){let i=this.labelRepository[t];if(bt(i)&&(i=this.getSelectedOptionLabel(t),R(i)&&(this.labelRepository[t]=i)),bt(i)&&this.getOptionLabelsUsing)try{let s=await this.getOptionLabelsUsing();for(let r of s)if(R(r)&&r.value===t&&r.label!==void 0){i=r.label,this.labelRepository[t]=i;break}}catch(s){console.error("Error fetching option label:",s)}bt(i)&&(i=t);let o=this.createBadgeElement(t,i);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<t.length;e++)if(this.state.includes(t[e].getAttribute("data-value"))){this.selectedIndex=e;break}}this.selectedIndex===-1&&(this.selectedIndex=0),t[this.selectedIndex].classList.add("fi-selected"),t[this.selectedIndex].focus()}}disable(){this.isDisabled||(this.isDisabled=!0,this.applyDisabledState(),this.isOpen&&this.closeDropdown())}enable(){this.isDisabled&&(this.isDisabled=!1,this.applyDisabledState())}applyDisabledState(){if(this.isDisabled){if(this.selectButton.setAttribute("disabled","disabled"),this.selectButton.setAttribute("aria-disabled","true"),this.selectButton.classList.add("fi-disabled"),this.isMultiple&&this.container.querySelectorAll(".fi-select-input-badge-remove").forEach(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 Qn({canOptionLabelsWrap:n,canSelectPlaceholder:t,isHtmlAllowed:e,getOptionLabelUsing:i,getOptionLabelsUsing:o,getOptionsUsing:s,getSearchResultsUsing:r,initialOptionLabel:a,initialOptionLabels:l,initialState:c,isAutofocused:f,isDisabled:d,isMultiple:p,isReorderable:u,isSearchable:g,hasDynamicOptions:m,hasDynamicSearchResults:S,livewireId:O,loadingMessage:w,maxItems:D,maxItemsMessage:A,noSearchResultsMessage:C,options:F,optionsLimit:q,placeholder:J,position:T,searchDebounce:V,searchingMessage:X,searchPrompt:tt,searchableOptionFields:W,state:k,statePath:Y}){return{select:null,state:k,init(){this.select=new Ee({element:this.$refs.select,options:F,placeholder:J,state:this.state,canOptionLabelsWrap:n,canSelectPlaceholder:t,initialOptionLabel:a,initialOptionLabels:l,initialState:c,isHtmlAllowed:e,isAutofocused:f,isDisabled:d,isMultiple:p,isReorderable:u,isSearchable:g,getOptionLabelUsing:i,getOptionLabelsUsing:o,getOptionsUsing:s,getSearchResultsUsing:r,hasDynamicOptions:m,hasDynamicSearchResults:S,searchPrompt:tt,searchDebounce:V,loadingMessage:w,searchingMessage:X,noSearchResultsMessage:C,maxItems:D,maxItemsMessage:A,optionsLimit:q,position:T,searchableOptionFields:W,livewireId:O,statePath:Y,onStateChange:P=>{this.state=P}}),this.$watch("state",P=>{this.select&&this.select.state!==P&&(this.select.state=P,this.select.updateSelectedDisplay(),this.select.renderOptions())})},destroy(){this.select&&(this.select.destroy(),this.select=null)}}}export{Qn as default};
|
|
/*! Bundled license information:
|
|
|
|
sortablejs/modular/sortable.esm.js:
|
|
(**!
|
|
* Sortable 1.15.6
|
|
* @author RubaXa <trash@rubaxa.org>
|
|
* @author owenm <owen23355@gmail.com>
|
|
* @license MIT
|
|
*)
|
|
*/
|