You've already forked Atomcms-edit
12 lines
84 KiB
JavaScript
Executable File
12 lines
84 KiB
JavaScript
Executable File
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;m<s.length;m++){let x=s[m];if(!x)continue;let{name:D,fn:w}=x,{x:A,y:E,data:M,reset:C}=await w({x:f,y:d,initialPlacement:n,placement:u,strategy:o,middlewareData:g,rects:c,platform:a,elements:{reference:i,floating:t}});f=A??f,d=E??d,g[D]={...g[D],...M},C&&p<nn&&(p++,typeof C=="object"&&(C.placement&&(u=C.placement),C.rects&&(c=C.rects===!0?await r.getElementRects({reference:i,floating:t,strategy:o}):C.rects),{x:f,y:d}=ii(c,u,l)),m=-1)}return{x:f,y:d,placement:u,strategy:o,middlewareData:g}};var si=function(i){return i===void 0&&(i={}),{name:"flip",options:i,async fn(t){var e,n;let{placement:o,middlewareData:s,rects:r,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:u,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...x}=Vt(i,t);if((e=s.arrow)!=null&&e.alignmentOffset)return{};let D=yt(o),w=ht(a),A=yt(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(c.floating)),M=u||(A||!m?[Ft(a)]:Ze(a)),C=g!=="none";!u&&C&&M.push(...ti(a,m,g,E));let q=[a,...M],J=await l.detectOverflow(t,x),R=[],V=((n=s.flip)==null?void 0:n.overflows)||[];if(f&&R.push(J[D]),d){let H=Qe(o,r,E);R.push(J[H[0]],J[H[1]])}if(V=[...V,{placement:o,overflows:R}],!R.every(H=>H<=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<r.length;u++){let p=pi(t,r[u],o);l=vt(p.top,l),c=Ht(p.right,c),f=Ht(p.bottom,f),d=vt(p.left,d)}return{width:c-d,height:f-l,x:d,y:l}}function bn(i){let{width:t,height:e}=mi(i);return{width:t,height:e}}function vn(i,t,e){let n=ct(t),o=lt(t),s=e==="fixed",r=Xt(i,!0,s,t),a={scrollLeft:0,scrollTop:0},l=st(0);function c(){l.x=ce(o)}if(n||!n&&!s)if((Dt(t)!=="body"||Tt(o))&&(a=Kt(t)),n){let p=Xt(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!n&&o&&c();let f=o&&!n&&!s?yi(o,a):st(0),d=r.left+a.scrollLeft-l.x-f.x,u=r.top+a.scrollTop-l.y-f.y;return{x:d,y:u,width:r.width,height:r.height}}function Te(i){return nt(i).position==="static"}function gi(i,t){if(!ct(i)||nt(i).position==="fixed")return null;if(t)return t(i);let e=i.offsetParent;return lt(i)===e&&(e=e.ownerDocument.body),e}function Si(i,t){let e=U(i);if($t(i))return e;if(!ct(i)){let o=ut(i);for(;o&&!At(o);){if(it(o)&&!Te(o))return o;o=ut(o)}return e}let n=gi(i,t);for(;n&&di(n)&&Te(n);)n=gi(n,t);return n&&At(n)&&Te(n)&&!re(n)?e:n||fi(i)||e}var yn=async function(i){let t=this.getOffsetParent||Si,e=this.getDimensions,n=await e(i.floating);return{reference:vn(i.reference,await t(i.floating),i.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function wn(i){return nt(i).direction==="rtl"}var Sn={convertOffsetParentRelativeRectToViewportRelativeRect:dn,getDocumentElement:lt,getClippingRect:mn,getOffsetParent:Si,getElementRects:yn,getClientRects:fn,getDimensions:bn,getScale:Rt,isElement:it,isRTL:wn};var xi=ri;var Oi=ai,Ei=si;var Di=(i,t,e)=>{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<arguments.length;t++){var e=arguments[t];for(var n in e)({}).hasOwnProperty.call(e,n)&&(i[n]=e[n])}return i},gt.apply(null,arguments)}function Ai(i,t){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(i,o).enumerable})),e.push.apply(e,n)}return e}function ft(i){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Ai(Object(e),!0).forEach(function(n){xn(i,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):Ai(Object(e)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(e,n))})}return i}function On(i,t){if(i==null)return{};var e,n,o=En(i,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);for(n=0;n<s.length;n++)e=s[n],t.indexOf(e)===-1&&{}.propertyIsEnumerable.call(i,e)&&(o[e]=i[e])}return o}function En(i,t){if(i==null)return{};var e={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(t.indexOf(n)!==-1)continue;e[n]=i[n]}return e}function Dn(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var n=e.call(i,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function An(i){var t=Dn(i,"string");return typeof t=="symbol"?t:t+""}function We(i){"@babel/helpers - typeof";return We=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},We(i)}var Cn="1.15.7";function pt(i){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(i)}var mt=pt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),te=pt(/Edge/i),Ci=pt(/firefox/i),Gt=pt(/safari/i)&&!pt(/chrome/i)&&!pt(/android/i),Xe=pt(/iP(ad|od|hone)/i),Ni=pt(/chrome/i)&&pt(/android/i),ki={capture:!1,passive:!1};function O(i,t,e){i.addEventListener(t,e,!mt&&ki)}function S(i,t,e){i.removeEventListener(t,e,!mt&&ki)}function ve(i,t){if(t){if(t[0]===">"&&(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;o++)e(n[o],o);return n}return[]}function dt(){var i=document.scrollingElement;return i||document.documentElement}function B(i,t,e,n,o){if(!(!i.getBoundingClientRect&&i!==window)){var s,r,a,l,c,f,d;if(i!==window&&i.parentNode&&i!==dt()?(s=i.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)&&i!==window&&(o=o||i.parentNode,!mt))do if(o&&o.getBoundingClientRect&&(b(o,"transform")!=="none"||e&&b(o,"position")!=="static")){var u=o.getBoundingClientRect();r-=u.top+parseInt(b(o,"border-top-width")),a-=u.left+parseInt(b(o,"border-left-width")),l=r+s.height,c=a+s.width;break}while(o=o.parentNode);if(n&&i!==window){var p=kt(o||i),g=p&&p.a,m=p&&p.d;p&&(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 Ii(i,t,e){for(var n=xt(i,!0),o=B(i)[t];n;){var s=B(n)[e],r=void 0;if(e==="top"||e==="left"?r=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;s<r.length;){if(r[s].style.display!=="none"&&r[s]!==v.ghost&&(n||r[s]!==v.dragged)&&at(r[s],e.draggable,i,!1)){if(o===t)return r[s];o++}s++}return null}function Ye(i,t){for(var e=i.lastElementChild;e&&(e===v.ghost||b(e,"display")==="none"||t&&!ve(e,t));)e=e.previousElementSibling;return e||null}function ot(i,t){var e=0;if(!i||!i.parentNode)return-1;for(;i=i.previousElementSibling;)i.nodeName.toUpperCase()!=="TEMPLATE"&&i!==v.clone&&(!t||ve(i,t))&&e++;return e}function Ti(i){var t=0,e=0,n=dt();if(i)do{var o=kt(i),s=o.a,r=o.d;t+=i.scrollLeft*s,e+=i.scrollTop*r}while(i!==n&&(i=i.parentNode));return[t,e]}function Ln(i,t){for(var e in i)if(i.hasOwnProperty(e)){for(var n in t)if(t.hasOwnProperty(n)&&t[n]===i[e][n])return Number(e)}return-1}function xt(i,t){if(!i||!i.getBoundingClientRect)return dt();var e=i,n=!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(n||t)return e;n=!0}}while(e=e.parentNode);return dt()}function In(i,t){if(i&&t)for(var e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i}function Re(i,t){return Math.round(i.top)===Math.round(t.top)&&Math.round(i.left)===Math.round(t.left)&&Math.round(i.height)===Math.round(t.height)&&Math.round(i.width)===Math.round(t.width)}var qt;function Hi(i,t){return function(){if(!qt){var e=arguments,n=this;e.length===1?i.call(n,e[0]):i.apply(n,e),qt=setTimeout(function(){qt=void 0},t)}}}function Tn(){clearTimeout(qt),qt=void 0}function Wi(i,t,e){i.scrollLeft+=t,i.scrollTop+=e}function Vi(i){var t=window.Polymer,e=window.jQuery||window.Zepto;return t&&t.dom?t.dom(i).cloneNode(!0):e?e(i).clone(!0)[0]:i.cloneNode(!0)}function zi(i,t,e){var n={};return Array.from(i.children).forEach(function(o){var s,r,a,l;if(!(!at(o,t.draggable,i,!1)||o.animated||o===e)){var c=B(o);n.left=Math.min((s=n.left)!==null&&s!==void 0?s:1/0,c.left),n.top=Math.min((r=n.top)!==null&&r!==void 0?r:1/0,c.top),n.right=Math.max((a=n.right)!==null&&a!==void 0?a:-1/0,c.right),n.bottom=Math.max((l=n.bottom)!==null&&l!==void 0?l:-1/0,c.bottom)}}),n.width=n.right-n.left,n.height=n.bottom-n.top,n.x=n.left,n.y=n.top,n}var G="Sortable"+new Date().getTime();function Rn(){var i=[],t;return{captureAnimationState:function(){if(i=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(o){if(!(b(o,"display")==="none"||o===v.ghost)){i.push({target:o,rect:B(o)});var s=ft({},i[i.length-1].rect);if(o.thisAnimationDuration){var r=kt(o,!0);r&&(s.top-=r.f,s.left-=r.e)}o.fromRect=s}})}},addAnimationState:function(n){i.push(n)},removeAnimationState:function(n){i.splice(Ln(i,{target:n}),1)},animateAll:function(n){var o=this;if(!this.options.animation){clearTimeout(t),typeof n=="function"&&n();return}var s=!1,r=0;i.forEach(function(a){var l=0,c=a.target,f=c.fromRect,d=B(c),u=c.prevFromRect,p=c.prevToRect,g=a.rect,m=kt(c,!0);m&&(d.top-=m.f,d.left-=m.e),c.toRect=d,c.thisAnimationDuration&&Re(u,d)&&!Re(f,d)&&(g.top-d.top)/(g.left-d.left)===(f.top-d.top)/(f.left-d.left)&&(l=Pn(g,u,p,o.options)),Re(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 n=="function"&&n()},r):typeof n=="function"&&n(),i=[]},animate:function(n,o,s,r){if(r){b(n,"transition",""),b(n,"transform","");var a=kt(this.el),l=a&&a.a,c=a&&a.d,f=(o.left-s.left)/(l||1),d=(o.top-s.top)/(c||1);n.animatingX=!!f,n.animatingY=!!d,b(n,"transform","translate3d("+f+"px,"+d+"px,0)"),this.forRepaintDummy=_n(n),b(n,"transition","transform "+r+"ms"+(this.options.easing?" "+this.options.easing:"")),b(n,"transform","translate3d(0,0,0)"),typeof n.animated=="number"&&clearTimeout(n.animated),n.animated=setTimeout(function(){b(n,"transition",""),b(n,"transform",""),n.animated=!1,n.animatingX=!1,n.animatingY=!1},r)}}}}function _n(i){return i.offsetWidth}function Pn(i,t,e,n){return Math.sqrt(Math.pow(t.top-i.top,2)+Math.pow(t.left-i.left,2))/Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))*n.animation}var _t=[],_e={initializeByDefault:!0},ee={mount:function(t){for(var e in _e)_e.hasOwnProperty(e)&&!(e in t)&&(t[e]=_e[e]);_t.forEach(function(n){if(n.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}),_t.push(t)},pluginEvent:function(t,e,n){var o=this;this.eventCanceled=!1,n.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},n)),e.options[r.pluginName]&&e[r.pluginName][t]&&e[r.pluginName][t](ft({sortable:e},n)))})},initializePlugins:function(t,e,n,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(n,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 n={};return _t.forEach(function(o){typeof o.eventProperties=="function"&>(n,o.eventProperties.call(e[o.pluginName],t))}),n},modifyOption:function(t,e,n){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],n))}),o}};function Mn(i){var t=i.sortable,e=i.rootEl,n=i.name,o=i.targetEl,s=i.cloneEl,r=i.toEl,a=i.fromEl,l=i.oldIndex,c=i.newIndex,f=i.oldDraggableIndex,d=i.newDraggableIndex,u=i.originalEvent,p=i.putSortable,g=i.extraEventProperties;if(t=t||e&&e[G],!!t){var m,x=t.options,D="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!mt&&!te?m=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(m=document.createEvent("Event"),m.initEvent(n,!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=u,m.pullMode=p?p.lastPutMode:void 0;var w=ft(ft({},g),ee.getEventProperties(n,t));for(var A in w)m[A]=w[A];e&&e.dispatchEvent(m),x[D]&&x[D].call(t,m)}}var Nn=["evt"],j=function(t,e){var n=arguments.length>2&&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))<n)return;this._onDragStart(t,!0)}if(y){r?(r.e+=f-(Pe||0),r.f+=d-(Me||0)):r={a:1,b:0,c:0,d:1,e:f,f:d};var u="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");b(y,"webkitTransform",u),b(y,"mozTransform",u),b(y,"msTransform",u),b(y,"transform",u),Pe=f,Me=d,rt=s}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!y){var t=this.options.fallbackOnBody?document.body:I,e=B(h,!0,he,!0,t),n=this.options;if(he){for($=t;b($,"position")==="static"&&b($,"transform")==="none"&&$!==document;)$=$.parentNode;$!==document.body&&$!==document.documentElement?($===document&&($=dt()),e.top+=$.scrollTop,e.left+=$.scrollLeft):$=dt(),Ne=Ti($)}y=h.cloneNode(!0),Q(y,n.ghostClass,!1),Q(y,n.fallbackClass,!0),Q(y,n.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",he?"absolute":"fixed"),b(y,"zIndex","100000"),b(y,"pointerEvents","none"),v.ghost=y,t.appendChild(y),b(y,"transform-origin",Ri/parseInt(y.style.width)*100+"% "+_i/parseInt(y.style.height)*100+"%")}},_onDragStart:function(t,e){var n=this,o=t.dataTransfer,s=n.options;if(j("dragStart",this,{evt:t}),v.eventCanceled){this._onDrop();return}j("setupClone",this),v.eventCanceled||(T=Vi(h),T.removeAttribute("id"),T.draggable=!1,T.style["will-change"]="",this._hideClone(),Q(T,this.options.chosenClass,!1),v.clone=T),n.cloneId=me(function(){j("clone",n),!v.eventCanceled&&(n.options.removeCloneOnHide||I.insertBefore(T,h),n._hideClone(),X({sortable:n,name:"clone"}))}),!e&&Q(h,s.dragClass,!0),e?(ye=!0,n._loopId=setInterval(n._emulateDragOver,50)):(S(document,"mouseup",n._onDrop),S(document,"touchend",n._onDrop),S(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(n,o,h)),O(document,"drop",n),b(h,"transform","translateZ(0)")),Mt=!0,n._dragStartId=me(n._dragStarted.bind(n,e,t)),O(document,"selectstart",n),Yt=!0,window.getSelection().removeAllRanges(),Gt&&b(document.body,"user-select","none")},_onDragOver:function(t){var e=this.el,n=t.target,o,s,r,a=this.options,l=a.group,c=v.active,f=de===l,d=a.sort,u=W||c,p,g=this,m=!1;if(Ve)return;function x(F,et){j(F,g,ft({evt:t,isOwner:f,axis:p?"vertical":"horizontal",revert:r,dragRect:o,targetRect:s,canSort:d,fromSortable:u,target:n,completed:w,onMove:function(Ge,qi){return ue(I,e,h,o,Ge,B(Ge),t,qi)},changed:A},et))}function D(){x("dragOverAnimationCapture"),g.captureAnimationState(),g!==u&&u.captureAnimationState()}function w(F){return x("dragOverCompleted",{insertion:F}),F&&(f?c._hideClone():c._showClone(g),g!==u&&(Q(h,W?W.options.ghostClass:c.options.ghostClass,!1),Q(h,a.ghostClass,!0)),W!==g&&g!==v.active?W=g:g===v.active&&W&&(W=null),u===g&&(g._ignoreWhileAnimating=n),g.animateAll(function(){x("dragOverAnimationComplete"),g._ignoreWhileAnimating=null}),g!==u&&(u.animateAll(),u._ignoreWhileAnimating=null)),(n===h&&!h.animated||n===e&&!n.animated)&&(Pt=null),!a.dragoverBubble&&!t.rootEl&&n!==document&&(h.parentNode[G]._isOutsideThisEl(t.target),!F&&Lt(t)),!a.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),m=!0}function A(){Z=ot(h),wt=ot(h,a.draggable),X({sortable:g,name:"change",toEl:e,newIndex:Z,newDraggableIndex:wt,originalEvent:t})}if(t.preventDefault!==void 0&&t.cancelable&&t.preventDefault(),n=at(n,a.draggable,e,!0),x("dragOver"),v.eventCanceled)return m;if(h.contains(t.target)||n.animated&&n.animatingX&&n.animatingY||g._ignoreWhileAnimating===n)return w(!1);if(ye=!1,c&&!a.disabled&&(f?d||(r=_!==I):W===this||(this.lastPutMode=de.checkPull(this,c,h,t))&&l.checkPut(this,c,h,t))){if(p=this._getDirection(t,n)==="vertical",o=B(h),x("dragOverValid"),v.eventCanceled)return m;if(r)return _=I,D(),this._hideClone(),x("revert"),v.eventCanceled||(It?I.insertBefore(h,It):I.appendChild(h)),w(!0);var E=Ye(e,a.draggable);if(!E||$n(t,p,this)&&!E.animated){if(E===h)return w(!1);if(E&&e===t.target&&(n=E),n&&(s=B(n)),ue(I,e,h,o,n,s,t,!!n)!==!1)return D(),E&&E.nextSibling?e.insertBefore(h,E.nextSibling):e.appendChild(h),_=e,A(),w(!0)}else if(E&&zn(t,p,this)){var M=Bt(e,0,a,!0);if(M===h)return w(!1);if(n=M,s=B(n),ue(I,e,h,o,n,s,t,!1)!==!1)return D(),e.insertBefore(h,M),_=e,A(),w(!0)}else if(n.parentNode===e){s=B(n);var C=0,q,J=h.parentNode!==e,R=!Bn(h.animated&&h.toRect||o,n.animated&&n.toRect||s,p),V=p?"top":"left",L=Ii(n,"top","top")||Ii(h,"top","top"),K=L?L.scrollTop:void 0;Pt!==n&&(q=s[V],Zt=!1,fe=!R&&a.invertSwap||J),C=Kn(t,n,s,p,R?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,fe,Pt===n);var N;if(C!==0){var H=ot(h);do H-=C,N=_.children[H];while(N&&(b(N,"display")==="none"||N===y))}if(C===0||N===n)return w(!1);Pt=n,Qt=C;var tt=n.nextElementSibling,z=!1;z=C===1;var Y=ue(I,e,h,o,n,s,t,z);if(Y!==!1)return(Y===1||Y===-1)&&(z=Y===1),Ve=!0,setTimeout(Vn,30),D(),z&&!tt?e.appendChild(h):n.parentNode.insertBefore(h,z?tt:n),L&&Wi(L,0,K-L.scrollTop),_=h.parentNode,q!==void 0&&!fe&&(ge=Math.abs(q-B(n)[V])),A(),w(!0)}if(e.contains(h))return w(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){S(document,"mousemove",this._onTouchMove),S(document,"touchmove",this._onTouchMove),S(document,"pointermove",this._onTouchMove),S(document,"dragover",Lt),S(document,"mousemove",Lt),S(document,"touchmove",Lt)},_offUpEvents:function(){var t=this.el.ownerDocument;S(t,"mouseup",this._onDrop),S(t,"touchend",this._onDrop),S(t,"pointerup",this._onDrop),S(t,"pointercancel",this._onDrop),S(t,"touchcancel",this._onDrop),S(document,"selectstart",this)},_onDrop:function(t){var e=this.el,n=this.options;if(Z=ot(h),wt=ot(h,n.draggable),j("drop",this,{evt:t}),_=h&&h.parentNode,Z=ot(h),wt=ot(h,n.draggable),v.eventCanceled){this._nulling();return}Mt=!1,fe=!1,Zt=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),ze(this.cloneId),ze(this._dragStartId),this.nativeDraggable&&(S(document,"drop",this),S(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Gt&&b(document.body,"user-select",""),b(h,"transform",""),t&&(Yt&&(t.cancelable&&t.preventDefault(),!n.dropBubble&&t.stopPropagation()),y&&y.parentNode&&y.parentNode.removeChild(y),(I===_||W&&W.lastPutMode!=="clone")&&T&&T.parentNode&&T.parentNode.removeChild(T),h&&(this.nativeDraggable&&S(h,"dragend",this),ke(h),h.style["will-change"]="",Yt&&!Mt&&Q(h,W?W.options.ghostClass:this.options.ghostClass,!1),Q(h,this.options.chosenClass,!1),X({sortable:this,name:"unchoose",toEl:_,newIndex:null,newDraggableIndex:null,originalEvent:t}),I!==_?(Z>=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;o<s;o++)e=n[o],at(e,r.draggable,this.el,!1)&&t.push(e.getAttribute(r.dataIdAttr)||Yn(e));return t},sort:function(t,e){var n={},o=this.el;this.toArray().forEach(function(s,r){var a=o.children[r];at(a,this.options.draggable,o,!1)&&(n[s]=a)},this),e&&this.captureAnimationState(),t.forEach(function(s){n[s]&&(o.removeChild(n[s]),o.appendChild(n[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 n=this.options;if(e===void 0)return n[t];var o=ee.modifyOption(this,t,e);typeof o<"u"?n[t]=o:n[t]=e,t==="group"&&Xi(n)},destroy:function(){j("destroy",this);var t=this.el;t[G]=null,S(t,"mousedown",this._onTapStart),S(t,"touchstart",this._onTapStart),S(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(S(t,"dragover",this),S(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(e){e.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),we.splice(we.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!St){if(j("hideClone",this),v.eventCanceled)return;b(T,"display","none"),this.options.removeCloneOnHide&&T.parentNode&&T.parentNode.removeChild(T),St=!0}},_showClone:function(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(St){if(j("showClone",this),v.eventCanceled)return;h.parentNode==I&&!this.options.group.revertClone?I.insertBefore(T,h):It?I.insertBefore(T,It):I.appendChild(T),this.options.group.revertClone&&this.animate(h,T),b(T,"display",""),St=!1}}};function Wn(i){i.dataTransfer&&(i.dataTransfer.dropEffect="move"),i.cancelable&&i.preventDefault()}function ue(i,t,e,n,o,s,r,a){var l,c=i[G],f=c.options.onMove,d;return window.CustomEvent&&!mt&&!te?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=t,l.from=i,l.dragged=e,l.draggedRect=n,l.related=o||t,l.relatedRect=s||B(t),l.willInsertAfter=a,l.originalEvent=r,i.dispatchEvent(l),f&&(d=f.call(c,l,r)),d}function ke(i){i.draggable=!1}function Vn(){Ve=!1}function zn(i,t,e){var n=B(Bt(e.el,0,e.options,!0)),o=zi(e.el,e.options,y),s=10;return t?i.clientX<o.left-s||i.clientY<n.top&&i.clientX<n.right:i.clientY<o.top-s||i.clientY<n.bottom&&i.clientX<n.left}function $n(i,t,e){var n=B(Ye(e.el,e.options.draggable)),o=zi(e.el,e.options,y),s=10;return t?i.clientX>o.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&&ge<c*o){if(!Zt&&(Qt===1?l>f+c*s/2:l<d-c*s/2)&&(Zt=!0),Zt)u=!0;else if(Qt===1?l<f+ge:l>d-ge)return-Qt}else if(l>f+c*(1-o)/2&&l<d-c*(1-o)/2)return Xn(t)}return u=u||r,u&&(l<f+c*s/2||l>d-c*s/2)?l>f+c/2?1:-1:0}function Xn(i){return ot(h)<ot(i)?1:-1}function Yn(i){for(var t=i.tagName+i.className+i.src+i.href+i.textContent,e=t.length,n=0;e--;)n+=t.charCodeAt(e);return n.toString(36)}function Un(i){Se.length=0;for(var t=i.getElementsByTagName("input"),e=t.length;e--;){var n=t[e];n.checked&&Se.push(n)}}function me(i){return setTimeout(i,0)}function ze(i){return clearTimeout(i)}Oe&&O(document,"touchmove",function(i){(v.active||Mt)&&i.cancelable&&i.preventDefault()});v.utils={on:O,off:S,css:b,find:Fi,is:function(t,e){return!!at(t,e,t,!1)},extend:In,throttle:Hi,closest:at,toggleClass:Q,clone:Vi,index:ot,nextTick:me,cancelNextTick:ze,detectDirection:Ki,getChild:Bt,expando:G};v.get=function(i){return i[G]};v.mount=function(){for(var i=arguments.length,t=new Array(i),e=0;e<i;e++)t[e]=arguments[e];t[0].constructor===Array&&(t=t[0]),t.forEach(function(n){if(!n.prototype||!n.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(n));n.utils&&(v.utils=ft(ft({},v.utils),n.utils)),ee.mount(n)})};v.create=function(i,t){return new v(i,t)};v.version=Cn;var k=[],Ut,$e,Ke=!1,Be,Fe,xe,jt;function jn(){function i(){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 i.prototype={dragStarted:function(e){var n=e.originalEvent;this.sortable.nativeDraggable?O(document,"dragover",this._handleAutoScroll):this.options.supportPointer?O(document,"pointermove",this._handleFallbackAutoScroll):n.touches?O(document,"touchmove",this._handleFallbackAutoScroll):O(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(e){var n=e.originalEvent;!this.options.dragOverBubble&&!n.rootEl&&this._handleAutoScroll(n)},drop:function(){this.sortable.nativeDraggable?S(document,"dragover",this._handleAutoScroll):(S(document,"pointermove",this._handleFallbackAutoScroll),S(document,"touchmove",this._handleFallbackAutoScroll),S(document,"mousemove",this._handleFallbackAutoScroll)),Mi(),be(),Tn()},nulling:function(){xe=$e=Ut=Ke=jt=Be=Fe=null,k.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(e,n){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(xe=e,n||this.options.forceAutoScrollFallback||te||mt||Gt){He(e,this.options,a,n);var l=xt(a,!0);Ke&&(!jt||s!==Be||r!==Fe)&&(jt&&Mi(),jt=setInterval(function(){var c=xt(document.elementFromPoint(s,r),!0);c!==l&&(l=c,be()),He(e,o.options,c,n)},10),Be=s,Fe=r)}else{if(!this.options.bubbleScroll||xt(a,!0)===dt()){be();return}He(e,this.options,xt(a,!1),!1)}}},gt(i,{pluginName:"scroll",initializeByDefault:!0})}function be(){k.forEach(function(i){clearInterval(i.pid)}),k=[]}function Mi(){clearInterval(jt)}var He=Hi(function(i,t,e,n){if(t.scroll){var o=(i.touches?i.touches[0]:i).clientX,s=(i.touches?i.touches[0]:i).clientY,r=t.scrollSensitivity,a=t.scrollSpeed,l=dt(),c=!1,f;$e!==e&&($e=e,be(),Ut=t.scroll,f=t.scrollFn,Ut===!0&&(Ut=xt(e,!0)));var d=0,u=Ut;do{var p=u,g=B(p),m=g.top,x=g.bottom,D=g.left,w=g.right,A=g.width,E=g.height,M=void 0,C=void 0,q=p.scrollWidth,J=p.scrollHeight,R=b(p),V=p.scrollLeft,L=p.scrollTop;p===l?(M=A<q&&(R.overflowX==="auto"||R.overflowX==="scroll"||R.overflowX==="visible"),C=E<J&&(R.overflowY==="auto"||R.overflowY==="scroll"||R.overflowY==="visible")):(M=A<q&&(R.overflowX==="auto"||R.overflowX==="scroll"),C=E<J&&(R.overflowY==="auto"||R.overflowY==="scroll"));var K=M&&(Math.abs(w-o)<=r&&V+A<q)-(Math.abs(D-o)<=r&&!!V),N=C&&(Math.abs(x-s)<=r&&L+E<J)-(Math.abs(m-s)<=r&&!!L);if(!k[d])for(var H=0;H<=d;H++)k[H]||(k[H]={});(k[d].vx!=K||k[d].vy!=N||k[d].el!==p)&&(k[d].el=p,k[d].vx=K,k[d].vy=N,clearInterval(k[d].pid),(K!=0||N!=0)&&(c=!0,k[d].pid=setInterval(function(){n&&this.layer===0&&v.active._onTouchMove(xe);var tt=k[this.layer].vy?k[this.layer].vy*a:0,z=k[this.layer].vx?k[this.layer].vx*a:0;typeof f=="function"&&f.call(v.dragged.parentNode[G],z,tt,i,xe,k[this.layer].el)!=="continue"||Wi(k[this.layer].el,z,tt)}.bind({layer:d}),24))),d++}while(t.bubbleScroll&&u!==l&&(u=xt(u,!1)));Ke=c}},30),ji=function(t){var e=t.originalEvent,n=t.putSortable,o=t.dragEl,s=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,l=t.unhideGhostForTarget;if(e){var c=n||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:n}))}};function Ue(){}Ue.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){var e=t.dragEl,n=t.putSortable;this.sortable.captureAnimationState(),n&&n.captureAnimationState();var o=Bt(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(e,o):this.sortable.el.appendChild(e),this.sortable.animateAll(),n&&n.animateAll()},drop:ji};gt(Ue,{pluginName:"revertOnSpill"});function je(){}je.prototype={onSpill:function(t){var e=t.dragEl,n=t.putSortable,o=n||this.sortable;o.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),o.animateAll()},drop:ji};gt(je,{pluginName:"removeOnSpill"});v.mount(new jn);v.mount(je,Ue);var Gi=v;function bt(i){return i==null||i===""||typeof i=="string"&&i.trim()===""}function P(i){return!bt(i)}var Ee=class{constructor({canOptionLabelsWrap:t=!0,canSelectPlaceholder:e=!0,element:n,getOptionLabelUsing:o=null,getOptionLabelsUsing:s=null,getOptionsUsing:r=null,getSearchResultsUsing:a=null,hasDynamicOptions:l=!1,hasDynamicSearchResults:c=!0,hasInitialNoOptionsMessage:f=!1,initialOptionLabel:d=null,initialOptionLabels:u=null,initialState:p=null,isAutofocused:g=!1,isDisabled:m=!1,isHtmlAllowed:x=!1,isMultiple:D=!1,isReorderable:w=!1,isSearchable:A=!1,livewireId:E=null,loadingMessage:M="Loading...",maxItems:C=null,maxItemsMessage:q="Maximum number of items selected",noOptionsMessage:J="No options available",noSearchResultsMessage:R="No results found",onStateChange:V=()=>{},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<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.hasInitialNoOptionsMessage||this.hasDynamicOptions?this.showNoOptionsMessage():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 n=document.createElement("li");n.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)}),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='<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>',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='<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(""))}),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;n<e.length;n++)if(this.state.includes(e[n].getAttribute("data-value"))){this.selectedIndex=n;break}}}else for(let n=0;n<e.length;n++)if(e[n].getAttribute("data-value")===this.state){this.selectedIndex=n;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=[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<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(),n=t.getBoundingClientRect();n.bottom>e.bottom?this.dropdown.scrollTop+=n.bottom-e.bottom:n.top<e.top&&(this.dropdown.scrollTop-=e.top-n.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 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<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 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 <trash@rubaxa.org>
|
|
* @author owenm <owen23355@gmail.com>
|
|
* @license MIT
|
|
*)
|
|
*/
|