Files
app-agent/public/js/filament/forms/components/select.js
T
2026-11-25 21:50:39 +03:30

12 lines
87 KiB
JavaScript

var Wt=Math.min,yt=Math.max,$t=Math.round;var rt=i=>({x:i,y:i}),sn={left:"right",right:"left",bottom:"top",top:"bottom"};function Le(i,t,e){return yt(i,Wt(t,e))}function zt(i,t){return typeof i=="function"?i(t):i}function wt(i){return i.split("-")[0]}function Xt(i){return i.split("-")[1]}function Te(i){return i==="x"?"y":"x"}function Ie(i){return i==="y"?"height":"width"}function pt(i){let t=i[0];return t==="t"||t==="b"?"y":"x"}function Re(i){return Te(pt(i))}function ti(i,t,e){e===void 0&&(e=!1);let n=Xt(i),s=Re(i),o=Ie(s),r=s==="x"?n===(e?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(r=Vt(r)),[r,Vt(r)]}function ei(i){let t=Vt(i);return[oe(i),t,oe(t)]}function oe(i){return i.includes("start")?i.replace("start","end"):i.replace("end","start")}var Qe=["left","right"],Ze=["right","left"],on=["top","bottom"],rn=["bottom","top"];function an(i,t,e){switch(i){case"top":case"bottom":return e?t?Ze:Qe:t?Qe:Ze;case"left":case"right":return t?on:rn;default:return[]}}function ii(i,t,e,n){let s=Xt(i),o=an(wt(i),e==="start",n);return s&&(o=o.map(r=>r+"-"+s),t&&(o=o.concat(o.map(oe)))),o}function Vt(i){let t=wt(i);return sn[t]+i.slice(t.length)}function ln(i){return{top:0,right:0,bottom:0,left:0,...i}}function ni(i){return typeof i!="number"?ln(i):{top:i,right:i,bottom:i,left:i}}function Dt(i){let{x:t,y:e,width:n,height:s}=i;return{width:n,height:s,top:e,left:t,right:t+n,bottom:e+s,x:t,y:e}}function si(i,t,e){let{reference:n,floating:s}=i,o=pt(t),r=Re(t),a=Ie(r),l=wt(t),c=o==="y",u=n.x+n.width/2-s.width/2,h=n.y+n.height/2-s.height/2,f=n[a]/2-s[a]/2,p;switch(l){case"top":p={x:u,y:n.y-s.height};break;case"bottom":p={x:u,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:h};break;case"left":p={x:n.x-s.width,y:h};break;default:p={x:n.x,y:n.y}}switch(Xt(t)){case"start":p[r]-=f*(e&&c?-1:1);break;case"end":p[r]+=f*(e&&c?-1:1);break}return p}async function oi(i,t){var e;t===void 0&&(t={});let{x:n,y:s,platform:o,rects:r,elements:a,strategy:l}=i,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:f=!1,padding:p=0}=zt(t,i),m=ni(p),O=a[f?h==="floating"?"reference":"floating":h],x=Dt(await o.getClippingRect({element:(e=await(o.isElement==null?void 0:o.isElement(O)))==null||e?O:O.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),w=h==="floating"?{x:n,y:s,width:r.floating.width,height:r.floating.height}:r.reference,A=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),D=await(o.isElement==null?void 0:o.isElement(A))?await(o.getScale==null?void 0:o.getScale(A))||{x:1,y:1}:{x:1,y:1},M=Dt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:A,strategy:l}):w);return{top:(x.top-M.top+m.top)/D.y,bottom:(M.bottom-x.bottom+m.bottom)/D.y,left:(x.left-M.left+m.left)/D.x,right:(M.right-x.right+m.right)/D.x}}var cn=50,ri=async(i,t,e)=>{let{placement:n="bottom",strategy:s="absolute",middleware:o=[],platform:r}=e,a=r.detectOverflow?r:{...r,detectOverflow:oi},l=await(r.isRTL==null?void 0:r.isRTL(t)),c=await r.getElementRects({reference:i,floating:t,strategy:s}),{x:u,y:h}=si(c,n,l),f=n,p=0,m={};for(let g=0;g<o.length;g++){let O=o[g];if(!O)continue;let{name:x,fn:w}=O,{x:A,y:D,data:M,reset:C}=await w({x:u,y:h,initialPlacement:n,placement:f,strategy:s,middlewareData:m,rects:c,platform:a,elements:{reference:i,floating:t}});u=A??u,h=D??h,m[x]={...m[x],...M},C&&p<cn&&(p++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await r.getElementRects({reference:i,floating:t,strategy:s}):C.rects),{x:u,y:h}=si(c,f,l)),g=-1)}return{x:u,y:h,placement:f,strategy:s,middlewareData:m}};var ai=function(i){return i===void 0&&(i={}),{name:"flip",options:i,async fn(t){var e,n;let{placement:s,middlewareData:o,rects:r,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...O}=zt(i,t);if((e=o.arrow)!=null&&e.alignmentOffset)return{};let x=wt(s),w=pt(a),A=wt(a)===a,D=await(l.isRTL==null?void 0:l.isRTL(c.floating)),M=f||(A||!g?[Vt(a)]:ei(a)),C=m!=="none";!f&&C&&M.push(...ii(a,g,m,D));let J=[a,...M],Q=await l.detectOverflow(t,O),I=[],V=((n=o.flip)==null?void 0:n.overflows)||[];if(u&&I.push(Q[x]),h){let B=ti(s,r,D);I.push(Q[B[0]],Q[B[1]])}if(V=[...V,{placement:s,overflows:I}],!I.every(B=>B<=0)){var Y,it;let B=(((Y=o.flip)==null?void 0:Y.index)||0)+1,Z=J[B];if(Z&&(!(h==="alignment"?w!==pt(Z):!1)||V.every(_=>pt(_.placement)===w?_.overflows[0]>0:!0)))return{data:{index:B,overflows:V},reset:{placement:Z}};let k=(it=V.filter($=>$.overflows[0]<=0).sort(($,_)=>$.overflows[1]-_.overflows[1])[0])==null?void 0:it.placement;if(!k)switch(p){case"bestFit":{var W;let $=(W=V.filter(_=>{if(C){let z=pt(_.placement);return z===w||z==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(z=>z>0).reduce((z,j)=>z+j,0)]).sort((_,z)=>_[1]-z[1])[0])==null?void 0:W[0];$&&(k=$);break}case"initialPlacement":k=a;break}if(s!==k)return{reset:{placement:k}}}return{}}}};var hn=new Set(["left","top"]);async function un(i,t){let{placement:e,platform:n,elements:s}=i,o=await(n.isRTL==null?void 0:n.isRTL(s.floating)),r=wt(e),a=Xt(e),l=pt(e)==="y",c=hn.has(r)?-1:1,u=o&&l?-1:1,h=zt(t,i),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}var li=function(i){return i===void 0&&(i=0),{name:"offset",options:i,async fn(t){var e,n;let{x:s,y:o,placement:r,middlewareData:a}=t,l=await un(t,i);return r===((e=a.offset)==null?void 0:e.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:r}}}}},ci=function(i){return i===void 0&&(i={}),{name:"shift",options:i,async fn(t){let{x:e,y:n,placement:s,platform:o}=t,{mainAxis:r=!0,crossAxis:a=!1,limiter:l={fn:x=>{let{x:w,y:A}=x;return{x:w,y:A}}},...c}=zt(i,t),u={x:e,y:n},h=await o.detectOverflow(t,c),f=pt(wt(s)),p=Te(f),m=u[p],g=u[f];if(r){let x=p==="y"?"top":"left",w=p==="y"?"bottom":"right",A=m+h[x],D=m-h[w];m=Le(A,m,D)}if(a){let x=f==="y"?"top":"left",w=f==="y"?"bottom":"right",A=g+h[x],D=g-h[w];g=Le(A,g,D)}let O=l.fn({...t,[p]:m,[f]:g});return{...O,data:{x:O.x-e,y:O.y-n,enabled:{[p]:r,[f]:a}}}}}};function ae(){return typeof window<"u"}function At(i){return ui(i)?(i.nodeName||"").toLowerCase():"#document"}function U(i){var t;return(i==null||(t=i.ownerDocument)==null?void 0:t.defaultView)||window}function ct(i){var t;return(t=(ui(i)?i.ownerDocument:i.document)||window.document)==null?void 0:t.documentElement}function ui(i){return ae()?i instanceof Node||i instanceof U(i).Node:!1}function nt(i){return ae()?i instanceof Element||i instanceof U(i).Element:!1}function ht(i){return ae()?i instanceof HTMLElement||i instanceof U(i).HTMLElement:!1}function hi(i){return!ae()||typeof ShadowRoot>"u"?!1:i instanceof ShadowRoot||i instanceof U(i).ShadowRoot}function Rt(i){let{overflow:t,overflowX:e,overflowY:n,display:s}=st(i);return/auto|scroll|overlay|hidden|clip/.test(t+n+e)&&s!=="inline"&&s!=="contents"}function di(i){return/^(table|td|th)$/.test(At(i))}function Yt(i){try{if(i.matches(":popover-open"))return!0}catch{}try{return i.matches(":modal")}catch{return!1}}var dn=/transform|translate|scale|rotate|perspective|filter/,fn=/paint|layout|strict|content/,xt=i=>!!i&&i!=="none",Me;function le(i){let t=nt(i)?st(i):i;return xt(t.transform)||xt(t.translate)||xt(t.scale)||xt(t.rotate)||xt(t.perspective)||!ce()&&(xt(t.backdropFilter)||xt(t.filter))||dn.test(t.willChange||"")||fn.test(t.contain||"")}function fi(i){let t=mt(i);for(;ht(t)&&!Ct(t);){if(le(t))return t;if(Yt(t))return null;t=mt(t)}return null}function ce(){return Me==null&&(Me=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Me}function Ct(i){return/^(html|body|#document)$/.test(At(i))}function st(i){return U(i).getComputedStyle(i)}function Kt(i){return nt(i)?{scrollLeft:i.scrollLeft,scrollTop:i.scrollTop}:{scrollLeft:i.scrollX,scrollTop:i.scrollY}}function mt(i){if(At(i)==="html")return i;let t=i.assignedSlot||i.parentNode||hi(i)&&i.host||ct(i);return hi(t)?t.host:t}function pi(i){let t=mt(i);return Ct(t)?i.ownerDocument?i.ownerDocument.body:i.body:ht(t)&&Rt(t)?t:pi(t)}function re(i,t,e){var n;t===void 0&&(t=[]),e===void 0&&(e=!0);let s=pi(i),o=s===((n=i.ownerDocument)==null?void 0:n.body),r=U(s);if(o){let a=he(r);return t.concat(r,r.visualViewport||[],Rt(s)?s:[],a&&e?re(a):[])}else return t.concat(s,re(s,[],e))}function he(i){return i.parent&&Object.getPrototypeOf(i.parent)?i.frameElement:null}function vi(i){let t=st(i),e=parseFloat(t.width)||0,n=parseFloat(t.height)||0,s=ht(i),o=s?i.offsetWidth:e,r=s?i.offsetHeight:n,a=$t(e)!==o||$t(n)!==r;return a&&(e=o,n=r),{width:e,height:n,$:a}}function yi(i){return nt(i)?i:i.contextElement}function Mt(i){let t=yi(i);if(!ht(t))return rt(1);let e=t.getBoundingClientRect(),{width:n,height:s,$:o}=vi(t),r=(o?$t(e.width):e.width)/n,a=(o?$t(e.height):e.height)/s;return(!r||!Number.isFinite(r))&&(r=1),(!a||!Number.isFinite(a))&&(a=1),{x:r,y:a}}var pn=rt(0);function wi(i){let t=U(i);return!ce()||!t.visualViewport?pn:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function mn(i,t,e){return t===void 0&&(t=!1),!e||t&&e!==U(i)?!1:t}function jt(i,t,e,n){t===void 0&&(t=!1),e===void 0&&(e=!1);let s=i.getBoundingClientRect(),o=yi(i),r=rt(1);t&&(n?nt(n)&&(r=Mt(n)):r=Mt(i));let a=mn(o,e,n)?wi(o):rt(0),l=(s.left+a.x)/r.x,c=(s.top+a.y)/r.y,u=s.width/r.x,h=s.height/r.y;if(o){let f=U(o),p=n&&nt(n)?U(n):n,m=f,g=he(m);for(;g&&n&&p!==m;){let O=Mt(g),x=g.getBoundingClientRect(),w=st(g),A=x.left+(g.clientLeft+parseFloat(w.paddingLeft))*O.x,D=x.top+(g.clientTop+parseFloat(w.paddingTop))*O.y;l*=O.x,c*=O.y,u*=O.x,h*=O.y,l+=A,c+=D,m=U(g),g=he(m)}}return Dt({width:u,height:h,x:l,y:c})}function ue(i,t){let e=Kt(i).scrollLeft;return t?t.left+e:jt(ct(i)).left+e}function Si(i,t){let e=i.getBoundingClientRect(),n=e.left+t.scrollLeft-ue(i,e),s=e.top+t.scrollTop;return{x:n,y:s}}function gn(i){let{elements:t,rect:e,offsetParent:n,strategy:s}=i,o=s==="fixed",r=ct(n),a=t?Yt(t.floating):!1;if(n===r||a&&o)return e;let l={scrollLeft:0,scrollTop:0},c=rt(1),u=rt(0),h=ht(n);if((h||!h&&!o)&&((At(n)!=="body"||Rt(r))&&(l=Kt(n)),h)){let p=jt(n);c=Mt(n),u.x=p.x+n.clientLeft,u.y=p.y+n.clientTop}let f=r&&!h&&!o?Si(r,l):rt(0);return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:e.y*c.y-l.scrollTop*c.y+u.y+f.y}}function bn(i){return Array.from(i.getClientRects())}function vn(i){let t=ct(i),e=Kt(i),n=i.ownerDocument.body,s=yt(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),o=yt(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight),r=-e.scrollLeft+ue(i),a=-e.scrollTop;return st(n).direction==="rtl"&&(r+=yt(t.clientWidth,n.clientWidth)-s),{width:s,height:o,x:r,y:a}}var mi=25;function yn(i,t){let e=U(i),n=ct(i),s=e.visualViewport,o=n.clientWidth,r=n.clientHeight,a=0,l=0;if(s){o=s.width,r=s.height;let u=ce();(!u||u&&t==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}let c=ue(n);if(c<=0){let u=n.ownerDocument,h=u.body,f=getComputedStyle(h),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(n.clientWidth-h.clientWidth-p);m<=mi&&(o-=m)}else c<=mi&&(o+=c);return{width:o,height:r,x:a,y:l}}function wn(i,t){let e=jt(i,!0,t==="fixed"),n=e.top+i.clientTop,s=e.left+i.clientLeft,o=ht(i)?Mt(i):rt(1),r=i.clientWidth*o.x,a=i.clientHeight*o.y,l=s*o.x,c=n*o.y;return{width:r,height:a,x:l,y:c}}function gi(i,t,e){let n;if(t==="viewport")n=yn(i,e);else if(t==="document")n=vn(ct(i));else if(nt(t))n=wn(t,e);else{let s=wi(i);n={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Dt(n)}function Oi(i,t){let e=mt(i);return e===t||!nt(e)||Ct(e)?!1:st(e).position==="fixed"||Oi(e,t)}function Sn(i,t){let e=t.get(i);if(e)return e;let n=re(i,[],!1).filter(a=>nt(a)&&At(a)!=="body"),s=null,o=st(i).position==="fixed",r=o?mt(i):i;for(;nt(r)&&!Ct(r);){let a=st(r),l=le(r);!l&&a.position==="fixed"&&(s=null),(o?!l&&!s:!l&&a.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Rt(r)&&!l&&Oi(i,r))?n=n.filter(u=>u!==r):s=a,r=mt(r)}return t.set(i,n),n}function On(i){let{element:t,boundary:e,rootBoundary:n,strategy:s}=i,r=[...e==="clippingAncestors"?Yt(t)?[]:Sn(t,this._c):[].concat(e),n],a=gi(t,r[0],s),l=a.top,c=a.right,u=a.bottom,h=a.left;for(let f=1;f<r.length;f++){let p=gi(t,r[f],s);l=yt(p.top,l),c=Wt(p.right,c),u=Wt(p.bottom,u),h=yt(p.left,h)}return{width:c-h,height:u-l,x:h,y:l}}function En(i){let{width:t,height:e}=vi(i);return{width:t,height:e}}function Dn(i,t,e){let n=ht(t),s=ct(t),o=e==="fixed",r=jt(i,!0,o,t),a={scrollLeft:0,scrollTop:0},l=rt(0);function c(){l.x=ue(s)}if(n||!n&&!o)if((At(t)!=="body"||Rt(s))&&(a=Kt(t)),n){let p=jt(t,!0,o,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else s&&c();o&&!n&&s&&c();let u=s&&!n&&!o?Si(s,a):rt(0),h=r.left+a.scrollLeft-l.x-u.x,f=r.top+a.scrollTop-l.y-u.y;return{x:h,y:f,width:r.width,height:r.height}}function _e(i){return st(i).position==="static"}function bi(i,t){if(!ht(i)||st(i).position==="fixed")return null;if(t)return t(i);let e=i.offsetParent;return ct(i)===e&&(e=e.ownerDocument.body),e}function Ei(i,t){let e=U(i);if(Yt(i))return e;if(!ht(i)){let s=mt(i);for(;s&&!Ct(s);){if(nt(s)&&!_e(s))return s;s=mt(s)}return e}let n=bi(i,t);for(;n&&di(n)&&_e(n);)n=bi(n,t);return n&&Ct(n)&&_e(n)&&!le(n)?e:n||fi(i)||e}var xn=async function(i){let t=this.getOffsetParent||Ei,e=this.getDimensions,n=await e(i.floating);return{reference:Dn(i.reference,await t(i.floating),i.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function An(i){return st(i).direction==="rtl"}var Cn={convertOffsetParentRelativeRectToViewportRelativeRect:gn,getDocumentElement:ct,getClippingRect:On,getOffsetParent:Ei,getElementRects:xn,getClientRects:bn,getDimensions:En,getScale:Mt,isElement:nt,isRTL:An};var Di=li;var xi=ci,Ai=ai;var Ci=(i,t,e)=>{let n=new Map,s={platform:Cn,...e},o={...s.platform,_c:n};return ri(i,t,{...s,platform:o})};function Ln(i,t,e){return(t=Mn(t))in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}function bt(){return bt=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},bt.apply(null,arguments)}function Li(i,t){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),e.push.apply(e,n)}return e}function dt(i){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Li(Object(e),!0).forEach(function(n){Ln(i,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):Li(Object(e)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(e,n))})}return i}function Tn(i,t){if(i==null)return{};var e,n,s=In(i,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(i);for(n=0;n<o.length;n++)e=o[n],t.indexOf(e)===-1&&{}.propertyIsEnumerable.call(i,e)&&(s[e]=i[e])}return s}function In(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 Rn(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 Mn(i){var t=Rn(i,"string");return typeof t=="symbol"?t:t+""}function ze(i){"@babel/helpers - typeof";return ze=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},ze(i)}var _n="1.15.7";function gt(i){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(i)}var vt=gt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),ie=gt(/Edge/i),Ti=gt(/firefox/i),Jt=gt(/safari/i)&&!gt(/chrome/i)&&!gt(/android/i),Ue=gt(/iP(ad|od|hone)/i),ki=gt(/chrome/i)&&gt(/android/i),Fi={capture:!1,passive:!1};function E(i,t,e){i.addEventListener(t,e,!vt&&Fi)}function S(i,t,e){i.removeEventListener(t,e,!vt&&Fi)}function we(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 Hi(i){return i.host&&i!==document&&i.host.nodeType&&i.host!==i?i.host:i.parentNode}function lt(i,t,e,n){if(i){e=e||document;do{if(t!=null&&(t[0]===">"?i.parentNode===e&&we(i,t):we(i,t))||n&&i===e)return i;if(i===e)break}while(i=Hi(i))}return null}var Ii=/\s+/g;function tt(i,t,e){if(i&&t)if(i.classList)i.classList[e?"add":"remove"](t);else{var n=(" "+i.className+" ").replace(Ii," ").replace(" "+t+" "," ");i.className=(n+(e?" "+t:"")).replace(Ii," ")}}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 s=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return s&&new s(e)}function Vi(i,t,e){if(i){var n=i.getElementsByTagName(t),s=0,o=n.length;if(e)for(;s<o;s++)e(n[s],s);return n}return[]}function ut(){var i=document.scrollingElement;return i||document.documentElement}function N(i,t,e,n,s){if(!(!i.getBoundingClientRect&&i!==window)){var o,r,a,l,c,u,h;if(i!==window&&i.parentNode&&i!==ut()?(o=i.getBoundingClientRect(),r=o.top,a=o.left,l=o.bottom,c=o.right,u=o.height,h=o.width):(r=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,h=window.innerWidth),(t||e)&&i!==window&&(s=s||i.parentNode,!vt))do if(s&&s.getBoundingClientRect&&(b(s,"transform")!=="none"||e&&b(s,"position")!=="static")){var f=s.getBoundingClientRect();r-=f.top+parseInt(b(s,"border-top-width")),a-=f.left+parseInt(b(s,"border-left-width")),l=r+o.height,c=a+o.width;break}while(s=s.parentNode);if(n&&i!==window){var p=kt(s||i),m=p&&p.a,g=p&&p.d;p&&(r/=g,a/=m,h/=m,u/=g,l=r+u,c=a+h)}return{top:r,left:a,bottom:l,right:c,width:h,height:u}}}function Ri(i,t,e){for(var n=Et(i,!0),s=N(i)[t];n;){var o=N(n)[e],r=void 0;if(e==="top"||e==="left"?r=s>=o:r=s<=o,!r)return n;if(n===ut())break;n=Et(n,!1)}return!1}function Ft(i,t,e,n){for(var s=0,o=0,r=i.children;o<r.length;){if(r[o].style.display!=="none"&&r[o]!==v.ghost&&(n||r[o]!==v.dragged)&&lt(r[o],e.draggable,i,!1)){if(s===t)return r[o];s++}o++}return null}function Ge(i,t){for(var e=i.lastElementChild;e&&(e===v.ghost||b(e,"display")==="none"||t&&!we(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||we(i,t))&&e++;return e}function Mi(i){var t=0,e=0,n=ut();if(i)do{var s=kt(i),o=s.a,r=s.d;t+=i.scrollLeft*o,e+=i.scrollTop*r}while(i!==n&&(i=i.parentNode));return[t,e]}function Pn(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 Et(i,t){if(!i||!i.getBoundingClientRect)return ut();var e=i,n=!1;do if(e.clientWidth<e.scrollWidth||e.clientHeight<e.scrollHeight){var s=b(e);if(e.clientWidth<e.scrollWidth&&(s.overflowX=="auto"||s.overflowX=="scroll")||e.clientHeight<e.scrollHeight&&(s.overflowY=="auto"||s.overflowY=="scroll")){if(!e.getBoundingClientRect||e===document.body)return ut();if(n||t)return e;n=!0}}while(e=e.parentNode);return ut()}function Nn(i,t){if(i&&t)for(var e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i}function Pe(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 Wi(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 Bn(){clearTimeout(Qt),Qt=void 0}function $i(i,t,e){i.scrollLeft+=t,i.scrollTop+=e}function zi(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 Xi(i,t,e){var n={};return Array.from(i.children).forEach(function(s){var o,r,a,l;if(!(!lt(s,t.draggable,i,!1)||s.animated||s===e)){var c=N(s);n.left=Math.min((o=n.left)!==null&&o!==void 0?o: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 q="Sortable"+new Date().getTime();function kn(){var i=[],t;return{captureAnimationState:function(){if(i=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(s){if(!(b(s,"display")==="none"||s===v.ghost)){i.push({target:s,rect:N(s)});var o=dt({},i[i.length-1].rect);if(s.thisAnimationDuration){var r=kt(s,!0);r&&(o.top-=r.f,o.left-=r.e)}s.fromRect=o}})}},addAnimationState:function(n){i.push(n)},removeAnimationState:function(n){i.splice(Pn(i,{target:n}),1)},animateAll:function(n){var s=this;if(!this.options.animation){clearTimeout(t),typeof n=="function"&&n();return}var o=!1,r=0;i.forEach(function(a){var l=0,c=a.target,u=c.fromRect,h=N(c),f=c.prevFromRect,p=c.prevToRect,m=a.rect,g=kt(c,!0);g&&(h.top-=g.f,h.left-=g.e),c.toRect=h,c.thisAnimationDuration&&Pe(f,h)&&!Pe(u,h)&&(m.top-h.top)/(m.left-h.left)===(u.top-h.top)/(u.left-h.left)&&(l=Hn(m,f,p,s.options)),Pe(h,u)||(c.prevFromRect=u,c.prevToRect=h,l||(l=s.options.animation),s.animate(c,m,h,l)),l&&(o=!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),o?t=setTimeout(function(){typeof n=="function"&&n()},r):typeof n=="function"&&n(),i=[]},animate:function(n,s,o,r){if(r){b(n,"transition",""),b(n,"transform","");var a=kt(this.el),l=a&&a.a,c=a&&a.d,u=(s.left-o.left)/(l||1),h=(s.top-o.top)/(c||1);n.animatingX=!!u,n.animatingY=!!h,b(n,"transform","translate3d("+u+"px,"+h+"px,0)"),this.forRepaintDummy=Fn(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 Fn(i){return i.offsetWidth}function Hn(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=[],Ne={initializeByDefault:!0},ne={mount:function(t){for(var e in Ne)Ne.hasOwnProperty(e)&&!(e in t)&&(t[e]=Ne[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 s=this;this.eventCanceled=!1,n.cancel=function(){s.eventCanceled=!0};var o=t+"Global";_t.forEach(function(r){e[r.pluginName]&&(e[r.pluginName][o]&&e[r.pluginName][o](dt({sortable:e},n)),e.options[r.pluginName]&&e[r.pluginName][t]&&e[r.pluginName][t](dt({sortable:e},n)))})},initializePlugins:function(t,e,n,s){_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,bt(n,c.defaults)}});for(var o in t.options)if(t.options.hasOwnProperty(o)){var r=this.modifyOption(t,o,t.options[o]);typeof r<"u"&&(t.options[o]=r)}},getEventProperties:function(t,e){var n={};return _t.forEach(function(s){typeof s.eventProperties=="function"&&bt(n,s.eventProperties.call(e[s.pluginName],t))}),n},modifyOption:function(t,e,n){var s;return _t.forEach(function(o){t[o.pluginName]&&o.optionListeners&&typeof o.optionListeners[e]=="function"&&(s=o.optionListeners[e].call(t[o.pluginName],n))}),s}};function Vn(i){var t=i.sortable,e=i.rootEl,n=i.name,s=i.targetEl,o=i.cloneEl,r=i.toEl,a=i.fromEl,l=i.oldIndex,c=i.newIndex,u=i.oldDraggableIndex,h=i.newDraggableIndex,f=i.originalEvent,p=i.putSortable,m=i.extraEventProperties;if(t=t||e&&e[q],!!t){var g,O=t.options,x="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!vt&&!ie?g=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(g=document.createEvent("Event"),g.initEvent(n,!0,!0)),g.to=r||e,g.from=a||e,g.item=s||e,g.clone=o,g.oldIndex=l,g.newIndex=c,g.oldDraggableIndex=u,g.newDraggableIndex=h,g.originalEvent=f,g.pullMode=p?p.lastPutMode:void 0;var w=dt(dt({},m),ne.getEventProperties(n,t));for(var A in w)g[A]=w[A];e&&e.dispatchEvent(g),O[x]&&O[x].call(t,g)}}var Wn=["evt"],G=function(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=n.evt,o=Tn(n,Wn);ne.pluginEvent.bind(v)(t,e,dt({dragEl:d,parentEl:R,ghostEl:y,rootEl:L,nextEl:It,lastDownEl:ge,cloneEl:T,cloneHidden:Ot,dragStarted:Ut,putSortable:H,activeSortable:v.active,originalEvent:s,oldIndex:Bt,oldDraggableIndex:Zt,newIndex:et,newDraggableIndex:St,hideGhostForTarget:Ui,unhideGhostForTarget:Gi,cloneNowHidden:function(){Ot=!0},cloneNowShown:function(){Ot=!1},dispatchSortableEvent:function(a){K({sortable:e,name:a,originalEvent:s})}},o))};function K(i){Vn(dt({putSortable:H,cloneEl:T,targetEl:d,rootEl:L,oldIndex:Bt,oldDraggableIndex:Zt,newIndex:et,newDraggableIndex:St},i))}var d,R,y,L,It,ge,T,Ot,Bt,et,Zt,St,de,H,Nt=!1,Se=!1,Oe=[],Lt,at,Be,ke,_i,Pi,Ut,Pt,te,ee=!1,fe=!1,be,X,Fe=[],Xe=!1,Ee=[],xe=typeof document<"u",pe=Ue,Ni=ie||vt?"cssFloat":"float",$n=xe&&!ki&&!Ue&&"draggable"in document.createElement("div"),Yi=(function(){if(xe){if(vt)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),s=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),o=Ft(t,0,e),r=Ft(t,1,e),a=o&&b(o),l=r&&b(r),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+N(o).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+N(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(o&&a.float&&a.float!=="none"){var h=a.float==="left"?"left":"right";return r&&(l.clear==="both"||l.clear===h)?"vertical":"horizontal"}return o&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=s&&n[Ni]==="none"||r&&n[Ni]==="none"&&c+u>s)?"vertical":"horizontal"},zn=function(t,e,n){var s=n?t.left:t.top,o=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 s===a||o===l||s+r/2===a+c/2},Xn=function(t,e){var n;return Oe.some(function(s){var o=s[q].options.emptyInsertThreshold;if(!(!o||Ge(s))){var r=N(s),a=t>=r.left-o&&t<=r.right+o,l=e>=r.top-o&&e<=r.bottom+o;if(a&&l)return n=s}}),n},ji=function(t){function e(o,r){return function(a,l,c,u){var h=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(o==null&&(r||h))return!0;if(o==null||o===!1)return!1;if(r&&o==="clone")return o;if(typeof o=="function")return e(o(a,l,c,u),r)(a,l,c,u);var f=(r?a:l).options.group.name;return o===!0||typeof o=="string"&&o===f||o.join&&o.indexOf(f)>-1}}var n={},s=t.group;(!s||ze(s)!="object")&&(s={name:s}),n.name=s.name,n.checkPull=e(s.pull,!0),n.checkPut=e(s.put),n.revertClone=s.revertClone,t.group=n},Ui=function(){!Yi&&y&&b(y,"display","none")},Gi=function(){!Yi&&y&&b(y,"display","")};xe&&!ki&&document.addEventListener("click",function(i){if(Se)return i.preventDefault(),i.stopPropagation&&i.stopPropagation(),i.stopImmediatePropagation&&i.stopImmediatePropagation(),Se=!1,!1},!0);var Tt=function(t){if(d){t=t.touches?t.touches[0]:t;var e=Xn(t.clientX,t.clientY);if(e){var n={};for(var s in t)t.hasOwnProperty(s)&&(n[s]=t[s]);n.target=n.rootEl=e,n.preventDefault=void 0,n.stopPropagation=void 0,e[q]._onDragOver(n)}}},Yn=function(t){d&&d.parentNode[q]._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=bt({},t),i[q]=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&&(!Jt||Ue),emptyInsertThreshold:5};ne.initializePlugins(this,i,e);for(var n in e)!(n in t)&&(t[n]=e[n]);ji(t);for(var s in this)s.charAt(0)==="_"&&typeof this[s]=="function"&&(this[s]=this[s].bind(this));this.nativeDraggable=t.forceFallback?!1:$n,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?E(i,"pointerdown",this._onTapStart):(E(i,"mousedown",this._onTapStart),E(i,"touchstart",this._onTapStart)),this.nativeDraggable&&(E(i,"dragover",this),E(i,"dragenter",this)),Oe.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),bt(this,kn())}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,d):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,n=this.el,s=this.options,o=s.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,u=s.filter;if(Zn(n),!d&&!(/mousedown|pointerdown/.test(r)&&t.button!==0||s.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Jt&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=lt(l,s.draggable,n,!1),!(l&&l.animated)&&ge!==l)){if(Bt=ot(l),Zt=ot(l,s.draggable),typeof u=="function"){if(u.call(this,t,l,this)){K({sortable:e,rootEl:c,name:"filter",targetEl:l,toEl:n,fromEl:n}),G("filter",e,{evt:t}),o&&t.preventDefault();return}}else if(u&&(u=u.split(",").some(function(h){if(h=lt(c,h.trim(),n,!1),h)return K({sortable:e,rootEl:h,name:"filter",targetEl:l,fromEl:n,toEl:n}),G("filter",e,{evt:t}),!0}),u)){o&&t.preventDefault();return}s.handle&&!lt(c,s.handle,n,!1)||this._prepareDragStart(t,a,l)}}},_prepareDragStart:function(t,e,n){var s=this,o=s.el,r=s.options,a=o.ownerDocument,l;if(n&&!d&&n.parentNode===o){var c=N(n);if(L=o,d=n,R=d.parentNode,It=d.nextSibling,ge=n,de=r.group,v.dragged=d,Lt={target:d,clientX:(e||t).clientX,clientY:(e||t).clientY},_i=Lt.clientX-c.left,Pi=Lt.clientY-c.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,d.style["will-change"]="all",l=function(){if(G("delayEnded",s,{evt:t}),v.eventCanceled){s._onDrop();return}s._disableDelayedDragEvents(),!Ti&&s.nativeDraggable&&(d.draggable=!0),s._triggerDragStart(t,e),K({sortable:s,name:"choose",originalEvent:t}),tt(d,r.chosenClass,!0)},r.ignore.split(",").forEach(function(u){Vi(d,u.trim(),He)}),E(a,"dragover",Tt),E(a,"mousemove",Tt),E(a,"touchmove",Tt),r.supportPointer?(E(a,"pointerup",s._onDrop),!this.nativeDraggable&&E(a,"pointercancel",s._onDrop)):(E(a,"mouseup",s._onDrop),E(a,"touchend",s._onDrop),E(a,"touchcancel",s._onDrop)),Ti&&this.nativeDraggable&&(this.options.touchStartThreshold=4,d.draggable=!0),G("delayStart",this,{evt:t}),r.delay&&(!r.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(ie||vt))){if(v.eventCanceled){this._onDrop();return}r.supportPointer?(E(a,"pointerup",s._disableDelayedDrag),E(a,"pointercancel",s._disableDelayedDrag)):(E(a,"mouseup",s._disableDelayedDrag),E(a,"touchend",s._disableDelayedDrag),E(a,"touchcancel",s._disableDelayedDrag)),E(a,"mousemove",s._delayedDragTouchMoveHandler),E(a,"touchmove",s._delayedDragTouchMoveHandler),r.supportPointer&&E(a,"pointermove",s._delayedDragTouchMoveHandler),s._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(){d&&He(d),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?E(document,"pointermove",this._onTouchMove):e?E(document,"touchmove",this._onTouchMove):E(document,"mousemove",this._onTouchMove):(E(d,"dragend",this),E(L,"dragstart",this._onDragStart));try{document.selection?ve(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(Nt=!1,L&&d){G("dragStarted",this,{evt:e}),this.nativeDraggable&&E(document,"dragover",Yn);var n=this.options;!t&&tt(d,n.dragClass,!1),tt(d,n.ghostClass,!0),v.active=this,t&&this._appendGhost(),K({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(at){this._lastX=at.clientX,this._lastY=at.clientY,Ui();for(var t=document.elementFromPoint(at.clientX,at.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(at.clientX,at.clientY),t!==e);)e=t;if(d.parentNode[q]._isOutsideThisEl(t),e)do{if(e[q]){var n=void 0;if(n=e[q]._onDragOver({clientX:at.clientX,clientY:at.clientY,target:t,rootEl:e}),n&&!this.options.dragoverBubble)break}t=e}while(e=Hi(e));Gi()}},_onTouchMove:function(t){if(Lt){var e=this.options,n=e.fallbackTolerance,s=e.fallbackOffset,o=t.touches?t.touches[0]:t,r=y&&kt(y,!0),a=y&&r&&r.a,l=y&&r&&r.d,c=pe&&X&&Mi(X),u=(o.clientX-Lt.clientX+s.x)/(a||1)+(c?c[0]-Fe[0]:0)/(a||1),h=(o.clientY-Lt.clientY+s.y)/(l||1)+(c?c[1]-Fe[1]:0)/(l||1);if(!v.active&&!Nt){if(n&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<n)return;this._onDragStart(t,!0)}if(y){r?(r.e+=u-(Be||0),r.f+=h-(ke||0)):r={a:1,b:0,c:0,d:1,e:u,f:h};var f="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");b(y,"webkitTransform",f),b(y,"mozTransform",f),b(y,"msTransform",f),b(y,"transform",f),Be=u,ke=h,at=o}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!y){var t=this.options.fallbackOnBody?document.body:L,e=N(d,!0,pe,!0,t),n=this.options;if(pe){for(X=t;b(X,"position")==="static"&&b(X,"transform")==="none"&&X!==document;)X=X.parentNode;X!==document.body&&X!==document.documentElement?(X===document&&(X=ut()),e.top+=X.scrollTop,e.left+=X.scrollLeft):X=ut(),Fe=Mi(X)}y=d.cloneNode(!0),tt(y,n.ghostClass,!1),tt(y,n.fallbackClass,!0),tt(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",pe?"absolute":"fixed"),b(y,"zIndex","100000"),b(y,"pointerEvents","none"),v.ghost=y,t.appendChild(y),b(y,"transform-origin",_i/parseInt(y.style.width)*100+"% "+Pi/parseInt(y.style.height)*100+"%")}},_onDragStart:function(t,e){var n=this,s=t.dataTransfer,o=n.options;if(G("dragStart",this,{evt:t}),v.eventCanceled){this._onDrop();return}G("setupClone",this),v.eventCanceled||(T=zi(d),T.removeAttribute("id"),T.draggable=!1,T.style["will-change"]="",this._hideClone(),tt(T,this.options.chosenClass,!1),v.clone=T),n.cloneId=ve(function(){G("clone",n),!v.eventCanceled&&(n.options.removeCloneOnHide||L.insertBefore(T,d),n._hideClone(),K({sortable:n,name:"clone"}))}),!e&&tt(d,o.dragClass,!0),e?(Se=!0,n._loopId=setInterval(n._emulateDragOver,50)):(S(document,"mouseup",n._onDrop),S(document,"touchend",n._onDrop),S(document,"touchcancel",n._onDrop),s&&(s.effectAllowed="move",o.setData&&o.setData.call(n,s,d)),E(document,"drop",n),b(d,"transform","translateZ(0)")),Nt=!0,n._dragStartId=ve(n._dragStarted.bind(n,e,t)),E(document,"selectstart",n),Ut=!0,window.getSelection().removeAllRanges(),Jt&&b(document.body,"user-select","none")},_onDragOver:function(t){var e=this.el,n=t.target,s,o,r,a=this.options,l=a.group,c=v.active,u=de===l,h=a.sort,f=H||c,p,m=this,g=!1;if(Xe)return;function O(_,z){G(_,m,dt({evt:t,isOwner:u,axis:p?"vertical":"horizontal",revert:r,dragRect:s,targetRect:o,canSort:h,fromSortable:f,target:n,completed:w,onMove:function(Ht,Ce){return me(L,e,d,s,Ht,N(Ht),t,Ce)},changed:A},z))}function x(){O("dragOverAnimationCapture"),m.captureAnimationState(),m!==f&&f.captureAnimationState()}function w(_){return O("dragOverCompleted",{insertion:_}),_&&(u?c._hideClone():c._showClone(m),m!==f&&(tt(d,H?H.options.ghostClass:c.options.ghostClass,!1),tt(d,a.ghostClass,!0)),H!==m&&m!==v.active?H=m:m===v.active&&H&&(H=null),f===m&&(m._ignoreWhileAnimating=n),m.animateAll(function(){O("dragOverAnimationComplete"),m._ignoreWhileAnimating=null}),m!==f&&(f.animateAll(),f._ignoreWhileAnimating=null)),(n===d&&!d.animated||n===e&&!n.animated)&&(Pt=null),!a.dragoverBubble&&!t.rootEl&&n!==document&&(d.parentNode[q]._isOutsideThisEl(t.target),!_&&Tt(t)),!a.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),g=!0}function A(){et=ot(d),St=ot(d,a.draggable),K({sortable:m,name:"change",toEl:e,newIndex:et,newDraggableIndex:St,originalEvent:t})}if(t.preventDefault!==void 0&&t.cancelable&&t.preventDefault(),n=lt(n,a.draggable,e,!0),O("dragOver"),v.eventCanceled)return g;if(d.contains(t.target)||n.animated&&n.animatingX&&n.animatingY||m._ignoreWhileAnimating===n)return w(!1);if(Se=!1,c&&!a.disabled&&(u?h||(r=R!==L):H===this||(this.lastPutMode=de.checkPull(this,c,d,t))&&l.checkPut(this,c,d,t))){if(p=this._getDirection(t,n)==="vertical",s=N(d),O("dragOverValid"),v.eventCanceled)return g;if(r)return R=L,x(),this._hideClone(),O("revert"),v.eventCanceled||(It?L.insertBefore(d,It):L.appendChild(d)),w(!0);var D=Ge(e,a.draggable);if(!D||Gn(t,p,this)&&!D.animated){if(D===d)return w(!1);if(D&&e===t.target&&(n=D),n&&(o=N(n)),me(L,e,d,s,n,o,t,!!n)!==!1)return x(),D&&D.nextSibling?e.insertBefore(d,D.nextSibling):e.appendChild(d),R=e,A(),w(!0)}else if(D&&Un(t,p,this)){var M=Ft(e,0,a,!0);if(M===d)return w(!1);if(n=M,o=N(n),me(L,e,d,s,n,o,t,!1)!==!1)return x(),e.insertBefore(d,M),R=e,A(),w(!0)}else if(n.parentNode===e){o=N(n);var C=0,J,Q=d.parentNode!==e,I=!zn(d.animated&&d.toRect||s,n.animated&&n.toRect||o,p),V=p?"top":"left",Y=Ri(n,"top","top")||Ri(d,"top","top"),it=Y?Y.scrollTop:void 0;Pt!==n&&(J=o[V],ee=!1,fe=!I&&a.invertSwap||Q),C=qn(t,n,o,p,I?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,fe,Pt===n);var W;if(C!==0){var B=ot(d);do B-=C,W=R.children[B];while(W&&(b(W,"display")==="none"||W===y))}if(C===0||W===n)return w(!1);Pt=n,te=C;var Z=n.nextElementSibling,k=!1;k=C===1;var $=me(L,e,d,s,n,o,t,k);if($!==!1)return($===1||$===-1)&&(k=$===1),Xe=!0,setTimeout(jn,30),x(),k&&!Z?e.appendChild(d):n.parentNode.insertBefore(d,k?Z:n),Y&&$i(Y,0,it-Y.scrollTop),R=d.parentNode,J!==void 0&&!fe&&(be=Math.abs(J-N(n)[V])),A(),w(!0)}if(e.contains(d))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",Tt),S(document,"mousemove",Tt),S(document,"touchmove",Tt)},_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(et=ot(d),St=ot(d,n.draggable),G("drop",this,{evt:t}),R=d&&d.parentNode,et=ot(d),St=ot(d,n.draggable),v.eventCanceled){this._nulling();return}Nt=!1,fe=!1,ee=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Ye(this.cloneId),Ye(this._dragStartId),this.nativeDraggable&&(S(document,"drop",this),S(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Jt&&b(document.body,"user-select",""),b(d,"transform",""),t&&(Ut&&(t.cancelable&&t.preventDefault(),!n.dropBubble&&t.stopPropagation()),y&&y.parentNode&&y.parentNode.removeChild(y),(L===R||H&&H.lastPutMode!=="clone")&&T&&T.parentNode&&T.parentNode.removeChild(T),d&&(this.nativeDraggable&&S(d,"dragend",this),He(d),d.style["will-change"]="",Ut&&!Nt&&tt(d,H?H.options.ghostClass:this.options.ghostClass,!1),tt(d,this.options.chosenClass,!1),K({sortable:this,name:"unchoose",toEl:R,newIndex:null,newDraggableIndex:null,originalEvent:t}),L!==R?(et>=0&&(K({rootEl:R,name:"add",toEl:R,fromEl:L,originalEvent:t}),K({sortable:this,name:"remove",toEl:R,originalEvent:t}),K({rootEl:R,name:"sort",toEl:R,fromEl:L,originalEvent:t}),K({sortable:this,name:"sort",toEl:R,originalEvent:t})),H&&H.save()):et!==Bt&&et>=0&&(K({sortable:this,name:"update",toEl:R,originalEvent:t}),K({sortable:this,name:"sort",toEl:R,originalEvent:t})),v.active&&((et==null||et===-1)&&(et=Bt,St=Zt),K({sortable:this,name:"end",toEl:R,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){G("nulling",this),L=d=R=y=It=T=ge=Ot=Lt=at=Ut=et=St=Bt=Zt=Pt=te=H=de=v.dragged=v.ghost=v.clone=v.active=null;var t=this.el;Ee.forEach(function(e){t.contains(e)&&(e.checked=!0)}),Ee.length=Be=ke=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":d&&(this._onDragOver(t),Kn(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,n=this.el.children,s=0,o=n.length,r=this.options;s<o;s++)e=n[s],lt(e,r.draggable,this.el,!1)&&t.push(e.getAttribute(r.dataIdAttr)||Qn(e));return t},sort:function(t,e){var n={},s=this.el;this.toArray().forEach(function(o,r){var a=s.children[r];lt(a,this.options.draggable,s,!1)&&(n[o]=a)},this),e&&this.captureAnimationState(),t.forEach(function(o){n[o]&&(s.removeChild(n[o]),s.appendChild(n[o]))}),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return lt(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var n=this.options;if(e===void 0)return n[t];var s=ne.modifyOption(this,t,e);typeof s<"u"?n[t]=s:n[t]=e,t==="group"&&ji(n)},destroy:function(){G("destroy",this);var t=this.el;t[q]=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(),Oe.splice(Oe.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!Ot){if(G("hideClone",this),v.eventCanceled)return;b(T,"display","none"),this.options.removeCloneOnHide&&T.parentNode&&T.parentNode.removeChild(T),Ot=!0}},_showClone:function(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(Ot){if(G("showClone",this),v.eventCanceled)return;d.parentNode==L&&!this.options.group.revertClone?L.insertBefore(T,d):It?L.insertBefore(T,It):L.appendChild(T),this.options.group.revertClone&&this.animate(d,T),b(T,"display",""),Ot=!1}}};function Kn(i){i.dataTransfer&&(i.dataTransfer.dropEffect="move"),i.cancelable&&i.preventDefault()}function me(i,t,e,n,s,o,r,a){var l,c=i[q],u=c.options.onMove,h;return window.CustomEvent&&!vt&&!ie?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=s||t,l.relatedRect=o||N(t),l.willInsertAfter=a,l.originalEvent=r,i.dispatchEvent(l),u&&(h=u.call(c,l,r)),h}function He(i){i.draggable=!1}function jn(){Xe=!1}function Un(i,t,e){var n=N(Ft(e.el,0,e.options,!0)),s=Xi(e.el,e.options,y),o=10;return t?i.clientX<s.left-o||i.clientY<n.top&&i.clientX<n.right:i.clientY<s.top-o||i.clientY<n.bottom&&i.clientX<n.left}function Gn(i,t,e){var n=N(Ge(e.el,e.options.draggable)),s=Xi(e.el,e.options,y),o=10;return t?i.clientX>s.right+o||i.clientY>n.bottom&&i.clientX>n.left:i.clientY>s.bottom+o||i.clientX>n.right&&i.clientY>n.top}function qn(i,t,e,n,s,o,r,a){var l=n?i.clientY:i.clientX,c=n?e.height:e.width,u=n?e.top:e.left,h=n?e.bottom:e.right,f=!1;if(!r){if(a&&be<c*s){if(!ee&&(te===1?l>u+c*o/2:l<h-c*o/2)&&(ee=!0),ee)f=!0;else if(te===1?l<u+be:l>h-be)return-te}else if(l>u+c*(1-s)/2&&l<h-c*(1-s)/2)return Jn(t)}return f=f||r,f&&(l<u+c*o/2||l>h-c*o/2)?l>u+c/2?1:-1:0}function Jn(i){return ot(d)<ot(i)?1:-1}function Qn(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 Zn(i){Ee.length=0;for(var t=i.getElementsByTagName("input"),e=t.length;e--;){var n=t[e];n.checked&&Ee.push(n)}}function ve(i){return setTimeout(i,0)}function Ye(i){return clearTimeout(i)}xe&&E(document,"touchmove",function(i){(v.active||Nt)&&i.cancelable&&i.preventDefault()});v.utils={on:E,off:S,css:b,find:Vi,is:function(t,e){return!!lt(t,e,t,!1)},extend:Nn,throttle:Wi,closest:lt,toggleClass:tt,clone:zi,index:ot,nextTick:ve,cancelNextTick:Ye,detectDirection:Ki,getChild:Ft,expando:q};v.get=function(i){return i[q]};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=dt(dt({},v.utils),n.utils)),ne.mount(n)})};v.create=function(i,t){return new v(i,t)};v.version=_n;var P=[],Gt,Ke,je=!1,Ve,We,De,qt;function ts(){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?E(document,"dragover",this._handleAutoScroll):this.options.supportPointer?E(document,"pointermove",this._handleFallbackAutoScroll):n.touches?E(document,"touchmove",this._handleFallbackAutoScroll):E(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)),Bi(),ye(),Bn()},nulling:function(){De=Ke=Gt=je=qt=Ve=We=null,P.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(e,n){var s=this,o=(e.touches?e.touches[0]:e).clientX,r=(e.touches?e.touches[0]:e).clientY,a=document.elementFromPoint(o,r);if(De=e,n||this.options.forceAutoScrollFallback||ie||vt||Jt){$e(e,this.options,a,n);var l=Et(a,!0);je&&(!qt||o!==Ve||r!==We)&&(qt&&Bi(),qt=setInterval(function(){var c=Et(document.elementFromPoint(o,r),!0);c!==l&&(l=c,ye()),$e(e,s.options,c,n)},10),Ve=o,We=r)}else{if(!this.options.bubbleScroll||Et(a,!0)===ut()){ye();return}$e(e,this.options,Et(a,!1),!1)}}},bt(i,{pluginName:"scroll",initializeByDefault:!0})}function ye(){P.forEach(function(i){clearInterval(i.pid)}),P=[]}function Bi(){clearInterval(qt)}var $e=Wi(function(i,t,e,n){if(t.scroll){var s=(i.touches?i.touches[0]:i).clientX,o=(i.touches?i.touches[0]:i).clientY,r=t.scrollSensitivity,a=t.scrollSpeed,l=ut(),c=!1,u;Ke!==e&&(Ke=e,ye(),Gt=t.scroll,u=t.scrollFn,Gt===!0&&(Gt=Et(e,!0)));var h=0,f=Gt;do{var p=f,m=N(p),g=m.top,O=m.bottom,x=m.left,w=m.right,A=m.width,D=m.height,M=void 0,C=void 0,J=p.scrollWidth,Q=p.scrollHeight,I=b(p),V=p.scrollLeft,Y=p.scrollTop;p===l?(M=A<J&&(I.overflowX==="auto"||I.overflowX==="scroll"||I.overflowX==="visible"),C=D<Q&&(I.overflowY==="auto"||I.overflowY==="scroll"||I.overflowY==="visible")):(M=A<J&&(I.overflowX==="auto"||I.overflowX==="scroll"),C=D<Q&&(I.overflowY==="auto"||I.overflowY==="scroll"));var it=M&&(Math.abs(w-s)<=r&&V+A<J)-(Math.abs(x-s)<=r&&!!V),W=C&&(Math.abs(O-o)<=r&&Y+D<Q)-(Math.abs(g-o)<=r&&!!Y);if(!P[h])for(var B=0;B<=h;B++)P[B]||(P[B]={});(P[h].vx!=it||P[h].vy!=W||P[h].el!==p)&&(P[h].el=p,P[h].vx=it,P[h].vy=W,clearInterval(P[h].pid),(it!=0||W!=0)&&(c=!0,P[h].pid=setInterval(function(){n&&this.layer===0&&v.active._onTouchMove(De);var Z=P[this.layer].vy?P[this.layer].vy*a:0,k=P[this.layer].vx?P[this.layer].vx*a:0;typeof u=="function"&&u.call(v.dragged.parentNode[q],k,Z,i,De,P[this.layer].el)!=="continue"||$i(P[this.layer].el,k,Z)}.bind({layer:h}),24))),h++}while(t.bubbleScroll&&f!==l&&(f=Et(f,!1)));je=c}},30),qi=function(t){var e=t.originalEvent,n=t.putSortable,s=t.dragEl,o=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,l=t.unhideGhostForTarget;if(e){var c=n||o;a();var u=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,h=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(h)&&(r("spill"),this.onSpill({dragEl:s,putSortable:n}))}};function qe(){}qe.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 s=Ft(this.sortable.el,this.startIndex,this.options);s?this.sortable.el.insertBefore(e,s):this.sortable.el.appendChild(e),this.sortable.animateAll(),n&&n.animateAll()},drop:qi};bt(qe,{pluginName:"revertOnSpill"});function Je(){}Je.prototype={onSpill:function(t){var e=t.dragEl,n=t.putSortable,s=n||this.sortable;s.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),s.animateAll()},drop:qi};bt(Je,{pluginName:"removeOnSpill"});v.mount(new ts);v.mount(Je,qe);var Ji=v;function ft(i){return i.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function se(i){return i==null||i===""||typeof i=="string"&&i.trim()===""}function F(i){return!se(i)}var Ae=class{constructor({accessibilityAttributes:t={},ariaLabel:e=null,canOptionLabelsWrap:n=!0,canSelectPlaceholder:s=!0,clearButtonLabel:o="Clear selection",element:r,errorMessage:a="The options could not be loaded. Please try again.",getOptionLabelUsing:l=null,getOptionLabelsUsing:c=null,getOptionsUsing:u=null,getSearchResultsUsing:h=null,hasDynamicOptions:f=!1,hasDynamicSearchResults:p=!0,hasInitialNoOptionsMessage:m=!1,id:g=null,initialOptionLabel:O=null,initialOptionLabels:x=null,initialState:w=null,isAutofocused:A=!1,isDisabled:D=!1,isHtmlAllowed:M=!1,isMultiple:C=!1,isReorderable:J=!1,isSearchable:Q=!1,livewireId:I=null,loadingMessage:V="Loading...",maxItems:Y=null,maxItemsMessage:it="Maximum number of items selected",noOptionsMessage:W="No options available",noSearchResultsMessage:B="No results found",onStateChange:Z=()=>{},options:k,optionsLimit:$=null,placeholder:_,position:z=null,removeButtonLabel:j="Remove :label",searchableOptionFields:Ht=["label"],searchDebounce:Ce=1e3,searchingMessage:Qi="Searching...",searchLabel:Zi="Search",searchPrompt:tn="Search...",state:en,statePath:nn=null}){this.accessibilityAttributes=t,this.ariaLabel=e,this.canOptionLabelsWrap=n,this.canSelectPlaceholder=s,this.clearButtonLabel=o,this.element=r,this.errorMessage=a,this.getOptionLabelUsing=l,this.getOptionLabelsUsing=c,this.getOptionsUsing=u,this.getSearchResultsUsing=h,this.hasDynamicOptions=f,this.hasDynamicSearchResults=p&&typeof h=="function",this.hasInitialNoOptionsMessage=m,this.id=g,this.initialOptionLabel=O,this.initialOptionLabels=x,this.initialState=w,this.isAutofocused=A,this.isDisabled=D,this.isHtmlAllowed=M,this.isMultiple=C,this.isReorderable=J,this.isSearchable=Q,this.livewireId=I,this.loadingMessage=V,this.maxItems=Y,this.maxItemsMessage=it,this.noOptionsMessage=W,this.noSearchResultsMessage=B,this.onStateChange=Z,this.options=k,this.optionsLimit=$,this.originalOptions=JSON.parse(JSON.stringify(k)),this.placeholder=_,this.position=z,this.removeButtonLabel=j,this.searchableOptionFields=Array.isArray(Ht)?Ht:["label"],this.searchDebounce=Ce,this.searchingMessage=Qi,this.searchLabel=Zi,this.searchPrompt=tn,this.state=en,this.statePath=nn,this.activeSearchId=0,this.openId=0,this.isDestroyed=!1,this.labelRepository={},this.isOpen=!1,this.activeValue=null,this.typeahead="",this.typeaheadTime=0,this.searchQuery="",this.searchTimeout=null,this.isSearching=!1,this.isLoadingOptions=!1,this.hasOptionsError=!1,this.maxItemsMessageElement=null,this.badgesSortable=null,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.selectButton=document.createElement("button"),this.selectButton.className="fi-select-input-btn",this.selectButton.type="button",this.isSearchable||this.selectButton.setAttribute("role","combobox"),this.selectButton.setAttribute("aria-haspopup","listbox"),this.selectButton.setAttribute("aria-expanded","false"),F(this.id)&&(this.selectButton.id=this.id),F(this.ariaLabel)&&this.selectButton.setAttribute("aria-label",this.ariaLabel),this.selectedDisplay=document.createElement("div"),this.selectedDisplay.className="fi-select-input-value-ctn",this.isMultiple?(this.container.classList.add("fi-select-input-ctn-multiple"),this.isReorderable&&this.container.classList.add("fi-select-input-ctn-reorderable"),this.selectionSummary=document.createElement("span"),this.selectionSummary.className="fi-sr-only",this.selectButton.appendChild(this.selectionSummary)):this.selectButton.appendChild(this.selectedDisplay),this.dropdown=document.createElement("div"),this.dropdown.className="fi-dropdown-panel fi-scrollable",this.dropdown.style.display="none",this.dropdownId=`fi-select-input-dropdown-${Math.random().toString(36).substring(2,11)}`,this.selectButton.setAttribute("aria-controls",this.dropdownId),this.selectionSummary||(this.selectionSummary=document.createElement("span"),this.selectionSummary.className="fi-sr-only",this.container.appendChild(this.selectionSummary)),this.selectionSummary.id=`${this.dropdownId}-value`,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("role","combobox"),this.searchInput.setAttribute("aria-autocomplete","list"),this.searchInput.setAttribute("aria-expanded","false"),this.searchInput.setAttribute("aria-controls",this.dropdownId),this.searchContainer.appendChild(this.searchInput),this.dropdown.appendChild(this.searchContainer),this.searchInput.addEventListener("input",t=>{this.isDisabled||this.handleSearch(t)})),this.optionsList=document.createElement("ul"),this.optionsList.id=this.dropdownId,this.optionsList.setAttribute("role","listbox"),this.isMultiple&&this.optionsList.setAttribute("aria-multiselectable","true"),this.optionsList.addEventListener("mousedown",t=>t.preventDefault()),this.dropdown.addEventListener("mousedown",t=>{t.target===this.dropdown&&t.preventDefault()}),this.statusRegion=document.createElement("div"),this.statusRegion.className="fi-sr-only",this.statusRegion.setAttribute("role","status"),this.statusRegion.setAttribute("aria-live","polite"),this.statusRegion.setAttribute("aria-atomic","true"),this.renderOptions(),this.container.appendChild(this.selectButton),this.isMultiple&&this.container.appendChild(this.selectedDisplay),this.container.appendChild(this.dropdown),this.container.appendChild(this.statusRegion),this.element.appendChild(this.container),this.setAccessibilityAttributes(this.accessibilityAttributes),this.updateSelectedDisplay(),this.applyDisabledState()}renderOptions(){if(this.isSearching||this.hasOptionsError||this.isLoadingOptions&&(!this.searchQuery||!this.hasDynamicSearchResults))return;let t=this.activeValue;this.setActiveOption(null),this.optionsList.innerHTML="";let e=0,n=this.options,s=0,o=!1;this.options.forEach(l=>{l.options&&Array.isArray(l.options)?(s+=l.options.length,o=!0):s++}),o?this.optionsList.className="fi-select-input-options-ctn":s>0&&(this.optionsList.className="fi-dropdown-list");let r=o?null:this.optionsList,a=0;for(let l of n){if(this.optionsLimit>0&&a>=this.optionsLimit)break;if(l.options&&Array.isArray(l.options)){let c=l.options;if(this.isMultiple&&Array.isArray(this.state)&&this.state.length>0&&(c=l.options.filter(u=>!this.state.includes(u.value))),c.length>0){if(this.optionsLimit>0){let u=this.optionsLimit-a;u<c.length&&(c=c.slice(0,u))}this.renderOptionGroup(l.label,c),r=null,a+=c.length,e+=c.length}}else{if(this.isMultiple&&Array.isArray(this.state)&&this.state.includes(l.value))continue;!r&&o&&(r=document.createElement("ul"),r.className="fi-dropdown-list",r.setAttribute("role","presentation"),this.optionsList.appendChild(r));let c=this.createOptionElement(l.value,l);r.appendChild(c),a++,e++}}if(e===0?(this.searchQuery?this.showNoResultsMessage():(this.hasInitialNoOptionsMessage||this.hasDynamicOptions)&&this.showNoOptionsMessage(),this.optionsList.hidden=!0):(this.optionsList.hidden=!1,this.hideLoadingState(),this.optionsList.parentNode!==this.dropdown&&this.dropdown.appendChild(this.optionsList)),this.optionsList.parentNode!==this.dropdown&&this.dropdown.appendChild(this.optionsList),this.isOpen){let l=this.getEnabledOptions();this.setActiveOption(l.find(c=>c.dataset.value===t)??(t!==null||!this.isSearchable?l.find(c=>this.typeahead&&ft(c.textContent.trim()).startsWith(this.typeahead))??l.find(c=>c.dataset.value===this.state)??l[0]:null))}}renderOptionGroup(t,e){if(e.length===0)return;let n=document.createElement("li");n.className="fi-select-input-option-group",n.setAttribute("role","presentation");let s=document.createElement("div");s.className="fi-dropdown-header",s.textContent=t;let o=document.createElement("ul");o.className="fi-dropdown-list",o.setAttribute("role","group"),o.setAttribute("aria-label",t),e.forEach(r=>{let a=this.createOptionElement(r.value,r);o.appendChild(a)}),n.appendChild(s),n.appendChild(o),this.optionsList.appendChild(n)}createOptionElement(t,e){let n=t,s=e,o=!1;typeof e=="object"&&e!==null&&"label"in e&&"value"in e&&(n=e.value,s=e.label,o=e.isDisabled||!1);let r=document.createElement("li");r.className="fi-dropdown-list-item fi-select-input-option",o&&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),o&&r.setAttribute("aria-disabled","true"),this.isHtmlAllowed&&typeof s=="string"){let u=document.createElement("div");u.innerHTML=s;let h=u.textContent||u.innerText||s;r.setAttribute("aria-label",h)}let l=this.isMultiple?Array.isArray(this.state)&&this.state.includes(n):this.state===n;r.setAttribute("aria-selected",l?"true":"false");let c=document.createElement("span");return this.isHtmlAllowed?c.innerHTML=s:c.textContent=s,r.appendChild(c),o||r.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),this.selectOption(n)}),r}async updateSelectedDisplay(){if(this.isDestroyed)return;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 s=document.createElement("span");s.textContent=this.placeholder,s.classList.add("fi-select-input-placeholder"),e.appendChild(s)}else{let s=await this.getLabelsForMultipleSelection();if(t!==this.selectedDisplayVersion)return;this.addBadgesForSelectedOptions(s,e)}t===this.selectedDisplayVersion&&(e.querySelector(".fi-select-input-value-badges-ctn")||this.destroyBadgesSortable(),this.commitSelectedDisplay(e),this.isOpen&&this.deferPositionDropdown());return}if(this.state===null||this.state===""){let s=document.createElement("span");if(s.textContent=this.placeholder,s.classList.add("fi-select-input-placeholder"),e.appendChild(s),t===this.selectedDisplayVersion){this.destroyBadgesSortable(),this.commitSelectedDisplay(e);let o=this.container.querySelector(".fi-select-input-value-remove-btn");o&&o.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.destroyBadgesSortable(),this.commitSelectedDisplay(e)))}commitSelectedDisplay(t){let e=this.selectedDisplay.contains(document.activeElement)?document.activeElement:null,n=e?.closest("[data-value]")?.dataset.value;this.selectedDisplay.replaceChildren(t),this.updateSelectionSummary(),e&&(this.isOpen?this.getFocusOwner():this.selectedDisplay.querySelector(`[data-value="${CSS.escape(n??"")}"] button`)??this.selectButton).focus()}updateSelectionSummary(){this.selectionSummary.textContent=Array.from(this.selectedDisplay.querySelectorAll(".fi-badge-label, .fi-select-input-value-label, .fi-select-input-placeholder"),t=>t.textContent).join(", ")}async getLabelsForMultipleSelection(){let t=this.selectedDisplayVersion,e=this.getSelectedOptionLabels(),n=[];if(Array.isArray(this.state)){for(let o of this.state)if(!F(this.labelRepository[o])){if(F(e[o])){this.labelRepository[o]=e[o];continue}n.push(o.toString())}}if(n.length>0&&F(this.initialOptionLabels)&&JSON.stringify(this.state)===JSON.stringify(this.initialState)){if(Array.isArray(this.initialOptionLabels))for(let o of this.initialOptionLabels)F(o)&&o.value!==void 0&&o.label!==void 0&&n.includes(o.value)&&(this.labelRepository[o.value]=o.label)}else if(n.length>0&&this.getOptionLabelsUsing)try{let o=await this.getOptionLabelsUsing();if(this.isDestroyed||t!==this.selectedDisplayVersion)return[];for(let r of o)F(r)&&r.value!==void 0&&r.label!==void 0&&(this.labelRepository[r.value]=r.label)}catch(o){console.error("Error fetching option labels:",o)}let s=[];if(Array.isArray(this.state))for(let o of this.state)F(this.labelRepository[o])?s.push(this.labelRepository[o]):F(e[o])?s.push(e[o]):s.push(o);return s}createBadgeElement(t,e){let n=document.createElement("span");n.className="fi-badge fi-size-md fi-color fi-color-primary fi-text-color-700 dark:fi-text-color-200",F(t)&&n.setAttribute("data-value",t);let s=document.createElement("span");s.className="fi-badge-label-ctn";let o=document.createElement("span");o.className="fi-badge-label",this.canOptionLabelsWrap&&o.classList.add("fi-wrapped"),this.isHtmlAllowed?o.innerHTML=e:o.textContent=e,s.appendChild(o),n.appendChild(s);let r=this.createRemoveButton(t,e);return n.appendChild(r),n}createRemoveButton(t,e){let n=document.createElement("button");n.type="button",n.className="fi-badge-delete-btn",n.setAttribute("aria-label",this.removeButtonLabel.replace(":label",this.isHtmlAllowed?e.replace(/<[^>]*>/g,""):e));let s=document.createElement("span");return s.className="fi-badge-delete-btn-icon",s.setAttribute("aria-hidden","true"),n.appendChild(s),this.isDisabled&&(n.setAttribute("disabled","disabled"),n.classList.add("fi-disabled")),n.addEventListener("click",o=>{if(o.stopPropagation(),F(t)){let r=Array.from(this.selectedDisplay.querySelectorAll(".fi-badge-delete-btn")),a=r.indexOf(n),l=this.isOpen?this.getFocusOwner():r[a+1]??r[a-1]??this.selectButton;this.selectOption(t),this.isDisabled||l.focus()}}),n.addEventListener("keydown",o=>{(o.key===" "||o.key==="Enter")&&(o.preventDefault(),o.stopPropagation(),n.click())}),n}addBadgesForSelectedOptions(t,e=this.selectedDisplay){let n=document.createElement("div");n.className="fi-select-input-value-badges-ctn",t.forEach((s,o)=>{let r=Array.isArray(this.state)?this.state[o]:null,a=this.createBadgeElement(r,s);n.appendChild(a)}),e.appendChild(n),this.isReorderable&&(n.addEventListener("click",s=>{s.stopPropagation()}),n.addEventListener("mousedown",s=>{s.stopPropagation()}),this.destroyBadgesSortable(),this.badgesSortable=new Ji(n,{animation:150,disabled:this.isDisabled,onEnd:()=>{let s=[];n.querySelectorAll("[data-value]").forEach(o=>{s.push(o.getAttribute("data-value"))}),this.state=s,this.updateSelectionSummary(),this.onStateChange(this.state)}}))}destroyBadgesSortable(){this.badgesSortable?.destroy(),this.badgesSortable=null}async getLabelForSingleSelection(){let t=this.state,e=this.selectedDisplayVersion,n=this.labelRepository[this.state];if(se(n)&&(n=this.getSelectedOptionLabel(this.state)),se(n)&&F(this.initialOptionLabel)&&this.state===this.initialState)n=this.initialOptionLabel,F(this.state)&&(this.labelRepository[this.state]=n);else if(se(n)&&this.getOptionLabelUsing)try{if(n=await this.getOptionLabelUsing(),this.isDestroyed||e!==this.selectedDisplayVersion||t!==this.state)return null;F(n)&&F(this.state)&&(this.labelRepository[t]=n)}catch(s){console.error("Error fetching option label:",s),n=this.state}else se(n)&&(n=this.state);return n}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 s=document.createElement("button");s.type="button",s.className="fi-select-input-value-remove-btn",s.setAttribute("aria-label",this.clearButtonLabel),this.isDisabled&&(s.setAttribute("disabled","disabled"),s.classList.add("fi-disabled")),s.addEventListener("click",o=>{o.stopPropagation(),this.selectOption("")}),s.addEventListener("keydown",o=>{(o.key===" "||o.key==="Enter")&&(o.preventDefault(),o.stopPropagation(),this.selectOption(""))}),this.container.appendChild(s),this.container.classList.add("fi-select-input-ctn-clearable")}getSelectedOptionLabel(t){if(F(this.labelRepository[t]))return this.labelRepository[t];let e="";for(let n of this.options)if(n.options&&Array.isArray(n.options)){for(let s of n.options)if(s.value===t){e=s.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.handleDropdownKeydown(t)},this.focusinListener=()=>this.syncActiveDescendant(),this.focusoutListener=t=>{this.selectButton.removeAttribute("aria-activedescendant"),this.searchInput?.removeAttribute("aria-activedescendant"),queueMicrotask(()=>{this.isDestroyed||!this.isOpen||(this.isTabbing||!this.container.contains(t.relatedTarget))&&(this.isTabbing=!1,this.closeDropdown())})},this.dropdownEscapeListener=t=>{this.isOpen&&(this.closeDropdown(),this.selectButton.focus(),t.preventDefault(),t.stopPropagation())},this.selectButton.addEventListener("click",this.buttonClickListener),document.addEventListener("click",this.documentClickListener),this.selectButton.addEventListener("keydown",this.buttonKeydownListener),this.dropdown.addEventListener("keydown",this.dropdownKeydownListener),this.container.addEventListener("focusin",this.focusinListener),this.container.addEventListener("focusout",this.focusoutListener),this.element.addEventListener("dropdown-escape",this.dropdownEscapeListener),!this.isMultiple&&this.livewireId&&this.statePath&&this.getOptionLabelUsing&&(this.refreshOptionLabelListener=async t=>{if(t.detail.livewireId===this.livewireId&&t.detail.statePath===this.statePath&&F(this.state))try{let e=this.state,n=++this.selectedDisplayVersion;delete this.labelRepository[this.state];let s=await this.getOptionLabelUsing();if(this.isDestroyed||e!==this.state||n!==this.selectedDisplayVersion)return;this.updateOptionLabelInList(this.state,s),this.updateSelectedDisplay()}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 s of n)if(s.getAttribute("data-value")===String(t)){if(s.innerHTML="",this.isHtmlAllowed){let o=document.createElement("span");o.innerHTML=e,s.appendChild(o),s.setAttribute("aria-label",o.textContent||o.innerText||e)}else s.appendChild(document.createTextNode(e));break}for(let s of this.options)if(s.options&&Array.isArray(s.options)){for(let o of s.options)if(o.value===t){o.label=e;break}}else if(s.value===t){s.label=e;break}for(let s of this.originalOptions)if(s.options&&Array.isArray(s.options)){for(let o of s.options)if(o.value===t){o.label=e;break}}else if(s.value===t){s.label=e;break}}handleSelectButtonKeydown(t){if(!(t.isComposing||t.keyCode===229)){if((!this.isOpen||this.isSearchable)&&["Enter"," ","ArrowDown","ArrowUp"].includes(t.key)){t.preventDefault(),t.stopPropagation(),this.openDropdown();return}this.handleDropdownKeydown(t)}}handleDropdownKeydown(t){if(t.isComposing||t.keyCode===229)return;let e=t.target===this.searchInput,n=this.getEnabledOptions();switch(t.key){case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.focusNextOption();break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),this.focusPreviousOption();break;case" ":if(e)return;case"Enter":if(!this.isOpen)return;t.preventDefault(),t.stopPropagation();let s=n.find(o=>o.dataset.value===this.activeValue)??(e?n[0]:null);s&&this.selectOption(s.dataset.value);break;case"Escape":if(!this.isOpen)return;t.preventDefault(),t.stopPropagation(),this.closeDropdown(),this.selectButton.focus();break;case"Tab":this.isTabbing=this.isOpen;break;case"Home":case"End":if(e||!this.isOpen)return;t.preventDefault(),t.stopPropagation(),this.setActiveOption(t.key==="Home"?n[0]:n.at(-1));break;default:if(!e&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&typeof t.key=="string"&&t.key.length===1)if(t.preventDefault(),this.isOpen||this.openDropdown(),this.isSearchable)this.searchInput.value=(this.searchInput.value||"")+t.key,this.searchInput.dispatchEvent(new Event("input",{bubbles:!0}));else{let o=Date.now();this.typeahead=(o-this.typeaheadTime<1e3?this.typeahead:"")+ft(t.key),this.typeaheadTime=o;let r=this.getEnabledOptions().find(a=>ft(a.textContent.trim()).startsWith(this.typeahead));r&&this.setActiveOption(r)}break}}toggleDropdown(){if(!this.isDisabled){if(this.isOpen){this.closeDropdown();return}this.openDropdown()}}async openDropdown(){if(this.isDestroyed||this.isDisabled)return;if(this.isOpen){this.getFocusOwner().focus();return}let t=++this.openId,e=++this.activeSearchId;this.typeahead="",this.hasOptionsError=!1;let n=`${this.selectButton.offsetWidth}px`;this.dropdown.style.display="block",this.dropdown.style.opacity="0";let s=this.selectButton.closest(".fi-fixed-positioning-context")!==null&&this.selectButton.closest(".fi-absolute-positioning-context")===null;if(this.dropdown.style.position=s?"fixed":"absolute",this.dropdown.style.width=n,this.selectButton.setAttribute("aria-expanded","true"),this.searchInput?.setAttribute("aria-expanded","true"),this.isOpen=!0,this.isTabbing=!1,this.getFocusOwner().focus(),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.isLoadingOptions=!0,this.showLoadingState(!1);try{let o=await this.getOptionsUsing();if(this.isDestroyed||!this.isOpen||t!==this.openId)return;this.isLoadingOptions=!1;let r=Array.isArray(o)?o:o&&Array.isArray(o.options)?o.options:[];this.originalOptions=JSON.parse(JSON.stringify(r)),(!this.searchQuery||!this.hasDynamicSearchResults)&&(this.populateLabelRepositoryFromOptions(r),this.searchQuery?this.filterOptions(this.searchQuery):(this.options=r,this.renderOptions(),this.positionDropdown()))}catch(o){if(this.isDestroyed||!this.isOpen||t!==this.openId||(this.isLoadingOptions=!1,this.searchQuery&&this.hasDynamicSearchResults&&e!==this.activeSearchId))return;console.error("Error fetching options:",o),this.showErrorMessage()}}else(!this.hasInitialNoOptionsMessage||this.searchQuery)&&this.hideLoadingState()}positionDropdown(){if(this.isDestroyed||!this.isOpen)return;let t=this.openId,e=this.position==="top"?"top-start":"bottom-start",n=[Di(4),xi({padding:5})];this.position!=="top"&&this.position!=="bottom"&&n.push(Ai());let s=this.selectButton.closest(".fi-fixed-positioning-context")!==null&&this.selectButton.closest(".fi-absolute-positioning-context")===null;Ci(this.selectButton,this.dropdown,{placement:e,middleware:n,strategy:s?"fixed":"absolute"}).then(({x:o,y:r})=>{this.isDestroyed||!this.isOpen||t!==this.openId||Object.assign(this.dropdown.style,{left:`${o}px`,top:`${r}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.searchInput?.setAttribute("aria-expanded","false"),this.isOpen=!1,this.openId++,this.searchTimeout&&(clearTimeout(this.searchTimeout),this.searchTimeout=null),this.activeSearchId++,this.isSearching=!1,this.isLoadingOptions=!1,this.hideLoadingState(),this.hideMaxItemsMessage(),this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null),this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener,!0),this.scrollListener=null),this.setActiveOption(null)}focusNextOption(){let t=this.getEnabledOptions();if(t.length===0)return;let e=t.findIndex(n=>n.dataset.value===this.activeValue);this.setActiveOption(t[Math.min(e+1,t.length-1)])}focusPreviousOption(){let t=this.getEnabledOptions();if(t.length===0)return;let e=t.findIndex(n=>n.dataset.value===this.activeValue);this.setActiveOption(t[e<0?t.length-1:Math.max(e-1,0)])}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(){return Array.from(this.optionsList.querySelectorAll('[role="option"]'))}getEnabledOptions(){return this.isSearching||this.optionsList.hidden||!this.optionsList.isConnected?[]:this.getVisibleOptions().filter(t=>t.getAttribute("aria-disabled")!=="true")}getFocusOwner(){return this.searchInput??this.selectButton}setActiveOption(t){this.activeValue=t?.dataset.value??null,this.getVisibleOptions().forEach(e=>e.classList.toggle("fi-selected",e===t)),this.syncActiveDescendant(),t&&this.isOpen&&this.scrollOptionIntoView(t)}syncActiveDescendant(){this.selectButton.removeAttribute("aria-activedescendant"),this.searchInput?.removeAttribute("aria-activedescendant");let t=this.getFocusOwner();if(!this.isOpen||document.activeElement!==t)return;let e=this.getEnabledOptions().find(n=>n.dataset.value===this.activeValue);e&&t.setAttribute("aria-activedescendant",e.id)}setAccessibilityAttributes(t){this.accessibilityAttributes=t;for(let s of["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-busy","aria-required"]){let o=t[s];for(let r of[this.selectButton,this.searchInput].filter(Boolean))F(o)?r.setAttribute(s,o):r.removeAttribute(s)}!this.selectButton.hasAttribute("aria-label")&&!this.selectButton.hasAttribute("aria-labelledby")&&F(this.ariaLabel)&&this.selectButton.setAttribute("aria-label",this.ariaLabel);let e=(this.selectButton.getAttribute("aria-labelledby")??"").split(/\s+/).map(s=>document.getElementById(s)?.textContent??"").join(" ").trim()||this.selectButton.getAttribute("aria-label")||Array.from(this.selectButton.labels??[],s=>s.textContent).join(" ").trim();this.optionsList.setAttribute("aria-label",e),this.isSearchable&&(this.searchInput.removeAttribute("aria-labelledby"),this.searchInput.setAttribute("aria-label",`${e}: ${this.searchLabel}`),this.selectButton.removeAttribute("aria-required"));let n=[t["aria-describedby"],this.selectionSummary.id].filter(Boolean).join(" ").split(/\s+/);this.selectButton.setAttribute("aria-describedby",[...new Set(n)].join(" "))}getSelectedOptionLabels(){if(!Array.isArray(this.state)||this.state.length===0)return{};let t={};for(let e of this.state){let n=!1;for(let s of this.options)if(s.options&&Array.isArray(s.options)){for(let o of s.options)if(o.value===e){t[e]=o.label,n=!0;break}if(n)break}else if(s.value===e){t[e]=s.label;break}}return t}handleSearch(t){if(this.isDestroyed||!this.isOpen)return;let e=t.target.value.trim();this.searchQuery=e,this.hasOptionsError=!1;let n=++this.activeSearchId;if(this.setActiveOption(null),this.searchTimeout&&clearTimeout(this.searchTimeout),e===""){if(this.isSearching=!1,this.isLoadingOptions){this.showLoadingState();return}this.hideLoadingState(),this.options=JSON.parse(JSON.stringify(this.originalOptions)),this.renderOptions(),this.positionDropdown();return}if(!this.getSearchResultsUsing||typeof this.getSearchResultsUsing!="function"||!this.hasDynamicSearchResults){this.isSearching=!1,this.filterOptions(e);return}this.isSearching=!0,this.showLoadingState(!0),this.searchTimeout=setTimeout(async()=>{this.searchTimeout=null;try{let s=await this.getSearchResultsUsing(e);if(this.isDestroyed||n!==this.activeSearchId||!this.isOpen)return;let o=Array.isArray(s)?s:s&&Array.isArray(s.options)?s.options:[];this.options=o,this.populateLabelRepositoryFromOptions(o),this.isSearching=!1,this.hideLoadingState(),this.renderOptions(),this.isOpen&&this.deferPositionDropdown(),this.options.length===0&&this.showNoResultsMessage()}catch(s){!this.isDestroyed&&this.isOpen&&n===this.activeSearchId&&(console.error("Error fetching search results:",s),this.showErrorMessage())}finally{n===this.activeSearchId&&(this.isSearching=!1)}},this.searchDebounce)}showLoadingState(t=!1){this.setActiveOption(null),this.optionsList.hidden=!0,this.hideLoadingState(),this.optionsList.setAttribute("aria-busy","true");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(),this.statusRegion.textContent=e.textContent),this.positionDropdown()}hideLoadingState(){this.optionsList.removeAttribute("aria-busy");let t=this.dropdown.querySelector(".fi-select-input-message");t&&(t.remove(),this.statusRegion.textContent="")}showNoOptionsMessage(){this.setActiveOption(null),this.optionsList.hidden=!0,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(),this.statusRegion.textContent=this.noOptionsMessage)}showNoResultsMessage(){this.setActiveOption(null),this.optionsList.hidden=!0,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(),this.statusRegion.textContent=this.noSearchResultsMessage)}showErrorMessage(){this.hasOptionsError=!0,this.showLoadingState(),this.optionsList.removeAttribute("aria-busy"),this.dropdown.querySelector(".fi-select-input-message").textContent=this.errorMessage,this.statusRegion.textContent=this.errorMessage,this.positionDropdown()}showMaxItemsMessage(){this.hideMaxItemsMessage(),this.maxItemsMessageElement=document.createElement("div"),this.maxItemsMessageElement.className="fi-select-input-max-items-message",this.maxItemsMessageElement.textContent=this.maxItemsMessage,this.optionsList.parentNode===this.dropdown?this.dropdown.insertBefore(this.maxItemsMessageElement,this.optionsList):this.dropdown.appendChild(this.maxItemsMessageElement),this.deferPositionDropdown(),this.statusRegion.textContent=this.maxItemsMessage}hideMaxItemsMessage(){this.maxItemsMessageElement&&(this.maxItemsMessageElement.remove(),this.maxItemsMessageElement=null,this.statusRegion.textContent===this.maxItemsMessage&&(this.statusRegion.textContent=""))}filterOptions(t){let e=this.searchableOptionFields.includes("label"),n=this.searchableOptionFields.includes("value");t=ft(t);let s=[];for(let o of this.originalOptions)if(o.options&&Array.isArray(o.options)){let r=o.options.filter(a=>e&&ft(a.label).includes(t)||n&&ft(String(a.value)).includes(t));r.length>0&&s.push({label:o.label,options:r})}else(e&&ft(o.label).includes(t)||n&&ft(String(o.value)).includes(t))&&s.push(o);this.options=s,this.renderOptions(),this.isOpen&&this.positionDropdown()}selectOption(t){if(this.isDisabled)return;if(!this.isMultiple){let n=this.container.contains(document.activeElement);this.state=t,this.updateSelectedDisplay(),this.renderOptions(),this.closeDropdown(),n&&this.selectButton.focus(),this.onStateChange(this.state);return}let e=Array.isArray(this.state)?[...this.state]:[];if(e.includes(t)){this.state=e.filter(n=>n!==t),this.updateSelectedDisplay(),this.hideMaxItemsMessage(),this.renderOptions(),this.isOpen&&this.deferPositionDropdown(),this.maintainFocusInMultipleMode(),this.updateSelectionSummary(),this.onStateChange(this.state);return}if(this.maxItems&&e.length>=this.maxItems){this.maxItemsMessage&&this.showMaxItemsMessage();return}this.hideMaxItemsMessage(),e.push(t),this.state=e,this.updateSelectedDisplay(),this.renderOptions(),this.isOpen&&this.deferPositionDropdown(),this.maintainFocusInMultipleMode(),this.onStateChange(this.state)}maintainFocusInMultipleMode(){this.isOpen&&this.container.contains(document.activeElement)&&this.getFocusOwner().focus()}disable(){this.isDisabled||(this.isDisabled=!0,this.applyDisabledState(),this.isOpen&&this.closeDropdown())}enable(){this.isDisabled&&(this.isDisabled=!1,this.applyDisabledState())}applyDisabledState(){if(this.badgesSortable?.option("disabled",this.isDisabled),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-badge-delete-btn").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-badge-delete-btn").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.remove("fi-disabled"))}this.isSearchable&&this.searchInput&&(this.searchInput.removeAttribute("disabled"),this.searchInput.classList.remove("fi-disabled"))}}destroy(){this.isDestroyed=!0,this.openId++,this.activeSearchId++,this.selectedDisplayVersion++,this.destroyBadgesSortable(),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.dropdownEscapeListener&&this.element.removeEventListener("dropdown-escape",this.dropdownEscapeListener),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 es({canOptionLabelsWrap:i,canSelectPlaceholder:t,clearButtonLabel:e,errorMessage:n,hasDynamicOptions:s,hasDynamicSearchResults:o,hasInitialNoOptionsMessage:r,id:a,initialOptionLabel:l,initialOptionLabels:c,initialState:u,isAutofocused:h,isDisabled:f,isHtmlAllowed:p,isMultiple:m,isReorderable:g,isSearchable:O,livewireId:x,loadingMessage:w,maxItems:A,maxItemsMessage:D,noOptionsMessage:M,noSearchResultsMessage:C,options:J,optionsLimit:Q,placeholder:I,position:V,removeButtonLabel:Y,searchDebounce:it,searchingMessage:W,searchLabel:B,searchPrompt:Z,searchableOptionFields:k,state:$,statePath:_}){return{select:null,accessibilityObserver:null,state:$,init(){this.select=new Ae({canOptionLabelsWrap:i,canSelectPlaceholder:t,clearButtonLabel:e,element:this.$refs.select,errorMessage:n,getOptionLabelUsing:()=>this.$callSchemaComponentMethod("getOptionLabel",{},{async:!0}),getOptionLabelsUsing:()=>this.$callSchemaComponentMethod("getOptionLabelsForJs",{},{async:!0}),getOptionsUsing:()=>this.$callSchemaComponentMethod("getOptionsForJs",{},{async:!0}),getSearchResultsUsing:j=>this.$callSchemaComponentMethod("getSearchResultsForJs",{search:j},{async:!0}),hasDynamicOptions:s,hasDynamicSearchResults:o,hasInitialNoOptionsMessage:r,id:a,initialOptionLabel:l,initialOptionLabels:c,initialState:u,isAutofocused:h,isDisabled:f,isHtmlAllowed:p,isMultiple:m,isReorderable:g,isSearchable:O,livewireId:x,loadingMessage:w,maxItems:A,maxItemsMessage:D,noOptionsMessage:M,noSearchResultsMessage:C,onStateChange:j=>{this.state=j},options:J,optionsLimit:Q,placeholder:I,position:V,removeButtonLabel:Y,searchableOptionFields:k,searchDebounce:it,searchingMessage:W,searchLabel:B,searchPrompt:Z,state:this.state,statePath:_});let z=this.$el.previousElementSibling;if(z?.hasAttribute("data-select-accessibility")){let j=()=>this.select?.setAccessibilityAttributes(JSON.parse(z.dataset.selectAccessibility));j(),this.accessibilityObserver=new MutationObserver(j),this.accessibilityObserver.observe(z,{attributes:!0,attributeFilter:["data-select-accessibility"]})}this.$watch("state",j=>{this.$nextTick(()=>{this.select&&this.select.state!==j&&(this.select.state=j,this.select.updateSelectedDisplay(),this.select.renderOptions())})}),this.$dispatch("async-component-ready"),h&&this.$nextTick(()=>this.select?.selectButton.focus())},destroy(){this.accessibilityObserver?.disconnect(),this.select&&(this.select.destroy(),this.select=null)}}}export{es 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
*)
*/