2025-11-02 18:53:24 -05:00

2 lines
22 KiB
JavaScript

(()=>{var M=Math.min,L=Math.max,N=Math.round,W=Math.floor,S=e=>({x:e,y:e});function J(e,t,i){return L(e,M(t,i))}function j(e,t){return typeof e=="function"?e(t):e}function H(e){return e.split("-")[0]}function Q(e){return e.split("-")[1]}function Z(e){return e==="x"?"y":"x"}function oe(e){return e==="y"?"height":"width"}var Pe=new Set(["top","bottom"]);function z(e){return Pe.has(H(e))?"y":"x"}function se(e){return Z(z(e))}function De(e){return{top:0,right:0,bottom:0,left:0,...e}}function re(e){return typeof e!="number"?De(e):{top:e,right:e,bottom:e,left:e}}function E(e){let{x:t,y:i,width:n,height:s}=e;return{width:n,height:s,top:i,left:t,right:t+n,bottom:i+s,x:t,y:i}}function le(e,t,i){let{reference:n,floating:s}=e,l=z(t),o=se(t),r=oe(o),c=H(t),a=l==="y",f=n.x+n.width/2-s.width/2,d=n.y+n.height/2-s.height/2,h=n[r]/2-s[r]/2,u;switch(c){case"top":u={x:f,y:n.y-s.height};break;case"bottom":u={x:f,y:n.y+n.height};break;case"right":u={x:n.x+n.width,y:d};break;case"left":u={x:n.x-s.width,y:d};break;default:u={x:n.x,y:n.y}}switch(Q(t)){case"start":u[o]-=h*(i&&a?-1:1);break;case"end":u[o]+=h*(i&&a?-1:1);break}return u}var ce=async(e,t,i)=>{let{placement:n="bottom",strategy:s="absolute",middleware:l=[],platform:o}=i,r=l.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),a=await o.getElementRects({reference:e,floating:t,strategy:s}),{x:f,y:d}=le(a,n,c),h=n,u={},m=0;for(let p=0;p<r.length;p++){let{name:w,fn:g}=r[p],{x,y,data:A,reset:b}=await g({x:f,y:d,initialPlacement:n,placement:h,strategy:s,middlewareData:u,rects:a,platform:o,elements:{reference:e,floating:t}});f=x??f,d=y??d,u={...u,[w]:{...u[w],...A}},b&&m<=50&&(m++,typeof b=="object"&&(b.placement&&(h=b.placement),b.rects&&(a=b.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:s}):b.rects),{x:f,y:d}=le(a,h,c)),p=-1)}return{x:f,y:d,placement:h,strategy:s,middlewareData:u}};async function ae(e,t){var i;t===void 0&&(t={});let{x:n,y:s,platform:l,rects:o,elements:r,strategy:c}=e,{boundary:a="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:h=!1,padding:u=0}=j(t,e),m=re(u),w=r[h?d==="floating"?"reference":"floating":d],g=E(await l.getClippingRect({element:(i=await(l.isElement==null?void 0:l.isElement(w)))==null||i?w:w.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(r.floating)),boundary:a,rootBoundary:f,strategy:c})),x=d==="floating"?{x:n,y:s,width:o.floating.width,height:o.floating.height}:o.reference,y=await(l.getOffsetParent==null?void 0:l.getOffsetParent(r.floating)),A=await(l.isElement==null?void 0:l.isElement(y))?await(l.getScale==null?void 0:l.getScale(y))||{x:1,y:1}:{x:1,y:1},b=E(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:r,rect:x,offsetParent:y,strategy:c}):x);return{top:(g.top-b.top+m.top)/A.y,bottom:(b.bottom-g.bottom+m.bottom)/A.y,left:(g.left-b.left+m.left)/A.x,right:(b.right-g.right+m.right)/A.x}}var Fe=new Set(["left","top"]);async function Me(e,t){let{placement:i,platform:n,elements:s}=e,l=await(n.isRTL==null?void 0:n.isRTL(s.floating)),o=H(i),r=Q(i),c=z(i)==="y",a=Fe.has(o)?-1:1,f=l&&c?-1:1,d=j(t,e),{mainAxis:h,crossAxis:u,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return r&&typeof m=="number"&&(u=r==="end"?m*-1:m),c?{x:u*f,y:h*a}:{x:h*a,y:u*f}}var fe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var i,n;let{x:s,y:l,placement:o,middlewareData:r}=t,c=await Me(t,e);return o===((i=r.offset)==null?void 0:i.placement)&&(n=r.arrow)!=null&&n.alignmentOffset?{}:{x:s+c.x,y:l+c.y,data:{...c,placement:o}}}}},de=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:i,y:n,placement:s}=t,{mainAxis:l=!0,crossAxis:o=!1,limiter:r={fn:w=>{let{x:g,y:x}=w;return{x:g,y:x}}},...c}=j(e,t),a={x:i,y:n},f=await ae(t,c),d=z(H(s)),h=Z(d),u=a[h],m=a[d];if(l){let w=h==="y"?"top":"left",g=h==="y"?"bottom":"right",x=u+f[w],y=u-f[g];u=J(x,u,y)}if(o){let w=d==="y"?"top":"left",g=d==="y"?"bottom":"right",x=m+f[w],y=m-f[g];m=J(x,m,y)}let p=r.fn({...t,[h]:u,[d]:m});return{...p,data:{x:p.x-i,y:p.y-n,enabled:{[h]:l,[d]:o}}}}}};function X(){return typeof window<"u"}function P(e){return he(e)?(e.nodeName||"").toLowerCase():"#document"}function v(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function O(e){var t;return(t=(he(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function he(e){return X()?e instanceof Node||e instanceof v(e).Node:!1}function R(e){return X()?e instanceof Element||e instanceof v(e).Element:!1}function T(e){return X()?e instanceof HTMLElement||e instanceof v(e).HTMLElement:!1}function ue(e){return!X()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof v(e).ShadowRoot}var $e=new Set(["inline","contents"]);function V(e){let{overflow:t,overflowX:i,overflowY:n,display:s}=C(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+i)&&!$e.has(s)}var Ve=new Set(["table","td","th"]);function me(e){return Ve.has(P(e))}var Be=[":popover-open",":modal"];function _(e){return Be.some(t=>{try{return e.matches(t)}catch{return!1}})}var Ne=["transform","translate","scale","rotate","perspective"],We=["transform","translate","scale","rotate","perspective","filter"],He=["paint","layout","strict","content"];function Y(e){let t=G(),i=R(e)?C(e):e;return Ne.some(n=>i[n]?i[n]!=="none":!1)||(i.containerType?i.containerType!=="normal":!1)||!t&&(i.backdropFilter?i.backdropFilter!=="none":!1)||!t&&(i.filter?i.filter!=="none":!1)||We.some(n=>(i.willChange||"").includes(n))||He.some(n=>(i.contain||"").includes(n))}function ge(e){let t=k(e);for(;T(t)&&!D(t);){if(Y(t))return t;if(_(t))return null;t=k(t)}return null}function G(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var ze=new Set(["html","body","#document"]);function D(e){return ze.has(P(e))}function C(e){return v(e).getComputedStyle(e)}function I(e){return R(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function k(e){if(P(e)==="html")return e;let t=e.assignedSlot||e.parentNode||ue(e)&&e.host||O(e);return ue(t)?t.host:t}function pe(e){let t=k(e);return D(t)?e.ownerDocument?e.ownerDocument.body:e.body:T(t)&&V(t)?t:pe(t)}function $(e,t,i){var n;t===void 0&&(t=[]),i===void 0&&(i=!0);let s=pe(e),l=s===((n=e.ownerDocument)==null?void 0:n.body),o=v(s);if(l){let r=K(o);return t.concat(o,o.visualViewport||[],V(s)?s:[],r&&i?$(r):[])}return t.concat(s,$(s,[],i))}function K(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function be(e){let t=C(e),i=parseFloat(t.width)||0,n=parseFloat(t.height)||0,s=T(e),l=s?e.offsetWidth:i,o=s?e.offsetHeight:n,r=N(i)!==l||N(n)!==o;return r&&(i=l,n=o),{width:i,height:n,$:r}}function te(e){return R(e)?e:e.contextElement}function B(e){let t=te(e);if(!T(t))return S(1);let i=t.getBoundingClientRect(),{width:n,height:s,$:l}=be(t),o=(l?N(i.width):i.width)/n,r=(l?N(i.height):i.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!r||!Number.isFinite(r))&&(r=1),{x:o,y:r}}var _e=S(0);function ve(e){let t=v(e);return!G()||!t.visualViewport?_e:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ie(e,t,i){return t===void 0&&(t=!1),!i||t&&i!==v(e)?!1:t}function F(e,t,i,n){t===void 0&&(t=!1),i===void 0&&(i=!1);let s=e.getBoundingClientRect(),l=te(e),o=S(1);t&&(n?R(n)&&(o=B(n)):o=B(e));let r=Ie(l,i,n)?ve(l):S(0),c=(s.left+r.x)/o.x,a=(s.top+r.y)/o.y,f=s.width/o.x,d=s.height/o.y;if(l){let h=v(l),u=n&&R(n)?v(n):n,m=h,p=K(m);for(;p&&n&&u!==m;){let w=B(p),g=p.getBoundingClientRect(),x=C(p),y=g.left+(p.clientLeft+parseFloat(x.paddingLeft))*w.x,A=g.top+(p.clientTop+parseFloat(x.paddingTop))*w.y;c*=w.x,a*=w.y,f*=w.x,d*=w.y,c+=y,a+=A,m=v(p),p=K(m)}}return E({width:f,height:d,x:c,y:a})}function q(e,t){let i=I(e).scrollLeft;return t?t.left+i:F(O(e)).left+i}function Re(e,t){let i=e.getBoundingClientRect(),n=i.left+t.scrollLeft-q(e,i),s=i.top+t.scrollTop;return{x:n,y:s}}function Ue(e){let{elements:t,rect:i,offsetParent:n,strategy:s}=e,l=s==="fixed",o=O(n),r=t?_(t.floating):!1;if(n===o||r&&l)return i;let c={scrollLeft:0,scrollTop:0},a=S(1),f=S(0),d=T(n);if((d||!d&&!l)&&((P(n)!=="body"||V(o))&&(c=I(n)),T(n))){let u=F(n);a=B(n),f.x=u.x+n.clientLeft,f.y=u.y+n.clientTop}let h=o&&!d&&!l?Re(o,c):S(0);return{width:i.width*a.x,height:i.height*a.y,x:i.x*a.x-c.scrollLeft*a.x+f.x+h.x,y:i.y*a.y-c.scrollTop*a.y+f.y+h.y}}function je(e){return Array.from(e.getClientRects())}function Xe(e){let t=O(e),i=I(e),n=e.ownerDocument.body,s=L(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),l=L(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight),o=-i.scrollLeft+q(e),r=-i.scrollTop;return C(n).direction==="rtl"&&(o+=L(t.clientWidth,n.clientWidth)-s),{width:s,height:l,x:o,y:r}}var we=25;function Ye(e,t){let i=v(e),n=O(e),s=i.visualViewport,l=n.clientWidth,o=n.clientHeight,r=0,c=0;if(s){l=s.width,o=s.height;let f=G();(!f||f&&t==="fixed")&&(r=s.offsetLeft,c=s.offsetTop)}let a=q(n);if(a<=0){let f=n.ownerDocument,d=f.body,h=getComputedStyle(d),u=f.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(n.clientWidth-d.clientWidth-u);m<=we&&(l-=m)}else a<=we&&(l+=a);return{width:l,height:o,x:r,y:c}}var Ge=new Set(["absolute","fixed"]);function Ke(e,t){let i=F(e,!0,t==="fixed"),n=i.top+e.clientTop,s=i.left+e.clientLeft,l=T(e)?B(e):S(1),o=e.clientWidth*l.x,r=e.clientHeight*l.y,c=s*l.x,a=n*l.y;return{width:o,height:r,x:c,y:a}}function xe(e,t,i){let n;if(t==="viewport")n=Ye(e,i);else if(t==="document")n=Xe(O(e));else if(R(t))n=Ke(t,i);else{let s=ve(e);n={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return E(n)}function Ce(e,t){let i=k(e);return i===t||!R(i)||D(i)?!1:C(i).position==="fixed"||Ce(i,t)}function qe(e,t){let i=t.get(e);if(i)return i;let n=$(e,[],!1).filter(r=>R(r)&&P(r)!=="body"),s=null,l=C(e).position==="fixed",o=l?k(e):e;for(;R(o)&&!D(o);){let r=C(o),c=Y(o);!c&&r.position==="fixed"&&(s=null),(l?!c&&!s:!c&&r.position==="static"&&!!s&&Ge.has(s.position)||V(o)&&!c&&Ce(e,o))?n=n.filter(f=>f!==o):s=r,o=k(o)}return t.set(e,n),n}function Je(e){let{element:t,boundary:i,rootBoundary:n,strategy:s}=e,o=[...i==="clippingAncestors"?_(t)?[]:qe(t,this._c):[].concat(i),n],r=o[0],c=o.reduce((a,f)=>{let d=xe(t,f,s);return a.top=L(d.top,a.top),a.right=M(d.right,a.right),a.bottom=M(d.bottom,a.bottom),a.left=L(d.left,a.left),a},xe(t,r,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Qe(e){let{width:t,height:i}=be(e);return{width:t,height:i}}function Ze(e,t,i){let n=T(t),s=O(t),l=i==="fixed",o=F(e,!0,l,t),r={scrollLeft:0,scrollTop:0},c=S(0);function a(){c.x=q(s)}if(n||!n&&!l)if((P(t)!=="body"||V(s))&&(r=I(t)),n){let u=F(t,!0,l,t);c.x=u.x+t.clientLeft,c.y=u.y+t.clientTop}else s&&a();l&&!n&&s&&a();let f=s&&!n&&!l?Re(s,r):S(0),d=o.left+r.scrollLeft-c.x-f.x,h=o.top+r.scrollTop-c.y-f.y;return{x:d,y:h,width:o.width,height:o.height}}function ee(e){return C(e).position==="static"}function ye(e,t){if(!T(e)||C(e).position==="fixed")return null;if(t)return t(e);let i=e.offsetParent;return O(e)===i&&(i=i.ownerDocument.body),i}function Ae(e,t){let i=v(e);if(_(e))return i;if(!T(e)){let s=k(e);for(;s&&!D(s);){if(R(s)&&!ee(s))return s;s=k(s)}return i}let n=ye(e,t);for(;n&&me(n)&&ee(n);)n=ye(n,t);return n&&D(n)&&ee(n)&&!Y(n)?i:n||ge(e)||i}var et=async function(e){let t=this.getOffsetParent||Ae,i=this.getDimensions,n=await i(e.floating);return{reference:Ze(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function tt(e){return C(e).direction==="rtl"}var nt={convertOffsetParentRelativeRectToViewportRelativeRect:Ue,getDocumentElement:O,getClippingRect:Je,getOffsetParent:Ae,getElementRects:et,getClientRects:je,getDimensions:Qe,getScale:B,isElement:R,isRTL:tt};function Se(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function it(e,t){let i=null,n,s=O(e);function l(){var r;clearTimeout(n),(r=i)==null||r.disconnect(),i=null}function o(r,c){r===void 0&&(r=!1),c===void 0&&(c=1),l();let a=e.getBoundingClientRect(),{left:f,top:d,width:h,height:u}=a;if(r||t(),!h||!u)return;let m=W(d),p=W(s.clientWidth-(f+h)),w=W(s.clientHeight-(d+u)),g=W(f),y={rootMargin:-m+"px "+-p+"px "+-w+"px "+-g+"px",threshold:L(0,M(1,c))||1},A=!0;function b(ie){let U=ie[0].intersectionRatio;if(U!==c){if(!A)return o();U?o(!1,U):n=setTimeout(()=>{o(!1,1e-7)},1e3)}U===1&&!Se(a,e.getBoundingClientRect())&&o(),A=!1}try{i=new IntersectionObserver(b,{...y,root:s.ownerDocument})}catch{i=new IntersectionObserver(b,y)}i.observe(e)}return o(!0),l}function Oe(e,t,i,n){n===void 0&&(n={});let{ancestorScroll:s=!0,ancestorResize:l=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:r=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,a=te(e),f=s||l?[...a?$(a):[],...$(t)]:[];f.forEach(g=>{s&&g.addEventListener("scroll",i,{passive:!0}),l&&g.addEventListener("resize",i)});let d=a&&r?it(a,i):null,h=-1,u=null;o&&(u=new ResizeObserver(g=>{let[x]=g;x&&x.target===a&&u&&(u.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=u)==null||y.observe(t)})),i()}),a&&!c&&u.observe(a),u.observe(t));let m,p=c?F(e):null;c&&w();function w(){let g=F(e);p&&!Se(p,g)&&i(),p=g,m=requestAnimationFrame(w)}return i(),()=>{var g;f.forEach(x=>{s&&x.removeEventListener("scroll",i),l&&x.removeEventListener("resize",i)}),d?.(),(g=u)==null||g.disconnect(),u=null,c&&cancelAnimationFrame(m)}}var Te=fe;var Le=de;var ke=(e,t,i)=>{let n=new Map,s={platform:nt,...i},l={...s.platform,_c:n};return ce(e,t,{...s,platform:l})};var Ee=({areGroupsCollapsedByDefault:e,canTrackDeselectedRecords:t,currentSelectionLivewireProperty:i,maxSelectableRecords:n,selectsCurrentPageOnly:s,$wire:l})=>({areFiltersOpen:!1,checkboxClickController:null,groupVisibility:[],isLoading:!1,selectedRecords:new Set,deselectedRecords:new Set,isTrackingDeselectedRecords:!1,shouldCheckUniqueSelection:!0,lastCheckedRecord:null,livewireId:null,entangledSelectedRecords:i?l.$entangle(i):null,cleanUpFiltersDropdown:null,init(){this.livewireId=this.$root.closest("[wire\\:id]")?.attributes["wire:id"].value,l.$on("deselectAllTableRecords",()=>this.deselectAllRecords()),l.$on("scrollToTopOfTable",()=>this.$root.scrollIntoView({block:"start",inline:"nearest"})),i&&(n!==1?this.selectedRecords=new Set(this.entangledSelectedRecords):this.selectedRecords=new Set(this.entangledSelectedRecords?[this.entangledSelectedRecords]:[])),this.$nextTick(()=>this.watchForCheckboxClicks()),Livewire.hook("element.init",({component:o})=>{o.id===this.livewireId&&this.watchForCheckboxClicks()})},mountAction(...o){l.set("isTrackingDeselectedTableRecords",this.isTrackingDeselectedRecords,!1),l.set("selectedTableRecords",[...this.selectedRecords],!1),l.set("deselectedTableRecords",[...this.deselectedRecords],!1),l.mountAction(...o)},toggleSelectRecordsOnPage(){let o=this.getRecordsOnPage();if(this.areRecordsSelected(o)){this.deselectRecords(o);return}this.selectRecords(o)},toggleSelectRecords(o){this.areRecordsSelected(o)?this.deselectRecords(o):this.selectRecords(o)},getSelectedRecordsCount(){return this.isTrackingDeselectedRecords?(this.$refs.allSelectableRecordsCount?.value??this.deselectedRecords.size)-this.deselectedRecords.size:this.selectedRecords.size},getRecordsOnPage(){let o=[];for(let r of this.$root?.getElementsByClassName("fi-ta-record-checkbox")??[])o.push(r.value);return o},selectRecords(o){n===1&&(this.deselectAllRecords(),o=o.slice(0,1));for(let r of o)if(!this.isRecordSelected(r)){if(this.isTrackingDeselectedRecords){this.deselectedRecords.delete(r);continue}this.selectedRecords.add(r)}this.updatedSelectedRecords()},deselectRecords(o){for(let r of o){if(this.isTrackingDeselectedRecords){this.deselectedRecords.add(r);continue}this.selectedRecords.delete(r)}this.updatedSelectedRecords()},updatedSelectedRecords(){if(n!==1){this.entangledSelectedRecords=[...this.selectedRecords];return}this.entangledSelectedRecords=[...this.selectedRecords][0]??null},toggleSelectedRecord(o){if(this.isRecordSelected(o)){this.deselectRecords([o]);return}this.selectRecords([o])},async selectAllRecords(){if(!t||s){this.isLoading=!0,this.selectedRecords=new Set(await l.getAllSelectableTableRecordKeys()),this.updatedSelectedRecords(),this.isLoading=!1;return}this.isTrackingDeselectedRecords=!0,this.selectedRecords=new Set,this.deselectedRecords=new Set,this.updatedSelectedRecords()},canSelectAllRecords(){if(s){let c=this.getRecordsOnPage();return!this.areRecordsSelected(c)&&this.areRecordsToggleable(c)}let o=parseInt(this.$refs.allSelectableRecordsCount?.value);if(!o)return!1;let r=this.getSelectedRecordsCount();return o===r?!1:n===null||o<=n},deselectAllRecords(){this.isTrackingDeselectedRecords=!1,this.selectedRecords=new Set,this.deselectedRecords=new Set,this.updatedSelectedRecords()},isRecordSelected(o){return this.isTrackingDeselectedRecords?!this.deselectedRecords.has(o):this.selectedRecords.has(o)},areRecordsSelected(o){return o.every(r=>this.isRecordSelected(r))},areRecordsToggleable(o){if(n===null||n===1)return!0;let r=o.filter(c=>this.isRecordSelected(c));return r.length===o.length?!0:this.getSelectedRecordsCount()+(o.length-r.length)<=n},toggleCollapseGroup(o){this.isGroupCollapsed(o)?e?this.groupVisibility.push(o):this.groupVisibility.splice(this.groupVisibility.indexOf(o),1):e?this.groupVisibility.splice(this.groupVisibility.indexOf(o),1):this.groupVisibility.push(o)},isGroupCollapsed(o){return e?!this.groupVisibility.includes(o):this.groupVisibility.includes(o)},resetCollapsedGroups(){this.groupVisibility=[]},watchForCheckboxClicks(){this.checkboxClickController&&this.checkboxClickController.abort(),this.checkboxClickController=new AbortController;let{signal:o}=this.checkboxClickController;this.$root?.addEventListener("click",r=>r.target?.matches(".fi-ta-record-checkbox")&&this.handleCheckboxClick(r,r.target),{signal:o})},handleCheckboxClick(o,r){if(!this.lastChecked){this.lastChecked=r;return}if(o.shiftKey){let c=Array.from(this.$root?.getElementsByClassName("fi-ta-record-checkbox")??[]);if(!c.includes(this.lastChecked)){this.lastChecked=r;return}let a=c.indexOf(this.lastChecked),f=c.indexOf(r),d=[a,f].sort((u,m)=>u-m),h=[];for(let u=d[0];u<=d[1];u++)h.push(c[u].value);if(r.checked){if(!this.areRecordsToggleable(h)){r.checked=!1,this.deselectRecords([r.value]);return}this.selectRecords(h)}else this.deselectRecords(h)}this.lastChecked=r},toggleFiltersDropdown(){if(this.areFiltersOpen=!this.areFiltersOpen,this.areFiltersOpen){let o=Oe(this.$refs.filtersTriggerActionContainer,this.$refs.filtersContentContainer,async()=>{let{x:a,y:f}=await ke(this.$refs.filtersTriggerActionContainer,this.$refs.filtersContentContainer,{placement:"bottom-end",middleware:[Te(8),Le({padding:8})]});Object.assign(this.$refs.filtersContentContainer.style,{left:`${a}px`,top:`${f}px`})}),r=a=>{let f=this.$refs.filtersTriggerActionContainer,d=this.$refs.filtersContentContainer;d&&d.contains(a.target)||f&&f.contains(a.target)||(this.areFiltersOpen=!1,this.cleanUpFiltersDropdown&&(this.cleanUpFiltersDropdown(),this.cleanUpFiltersDropdown=null))};document.addEventListener("mousedown",r),document.addEventListener("touchstart",r,{passive:!0});let c=a=>{a.key==="Escape"&&r(a)};document.addEventListener("keydown",c),this.cleanUpFiltersDropdown=()=>{o(),document.removeEventListener("mousedown",r),document.removeEventListener("touchstart",r,{passive:!0}),document.removeEventListener("keydown",c)}}else this.cleanUpFiltersDropdown&&(this.cleanUpFiltersDropdown(),this.cleanUpFiltersDropdown=null)}});function ne({columns:e,isLive:t}){return{error:void 0,isLoading:!1,columns:e,isLive:t,init(){if(!this.columns||this.columns.length===0){this.columns=[];return}},get groupedColumns(){let i={};return this.columns.filter(n=>n.type==="group").forEach(n=>{i[n.name]=this.calculateGroupedColumns(n)}),i},calculateGroupedColumns(i){if((i?.columns?.filter(r=>!r.isHidden)??[]).length===0)return{hidden:!0,checked:!1,disabled:!1,indeterminate:!1};let s=i.columns.filter(r=>!r.isHidden&&r.isToggleable!==!1);if(s.length===0)return{checked:!0,disabled:!0,indeterminate:!1};let l=s.filter(r=>r.isToggled).length,o=i.columns.filter(r=>!r.isHidden&&r.isToggleable===!1);return l===0&&o.length>0?{checked:!0,disabled:!1,indeterminate:!0}:l===0?{checked:!1,disabled:!1,indeterminate:!1}:l===s.length?{checked:!0,disabled:!1,indeterminate:!1}:{checked:!0,disabled:!1,indeterminate:!0}},getColumn(i,n=null){return n?this.columns.find(l=>l.type==="group"&&l.name===n)?.columns?.find(l=>l.name===i):this.columns.find(s=>s.name===i)},toggleGroup(i){let n=this.columns.find(c=>c.type==="group"&&c.name===i);if(!n?.columns)return;let s=this.calculateGroupedColumns(n);if(s.disabled)return;let o=n.columns.filter(c=>c.isToggleable!==!1).some(c=>c.isToggled),r=s.indeterminate?!0:!o;n.columns.filter(c=>c.isToggleable!==!1).forEach(c=>{c.isToggled=r}),this.columns=[...this.columns],this.isLive&&this.applyTableColumnManager()},toggleColumn(i,n=null){let s=this.getColumn(i,n);!s||s.isToggleable===!1||(s.isToggled=!s.isToggled,this.columns=[...this.columns],this.isLive&&this.applyTableColumnManager())},reorderColumns(i){let n=i.map(s=>s.split("::"));this.reorderTopLevel(n),this.isLive&&this.applyTableColumnManager()},reorderGroupColumns(i,n){let s=this.columns.find(r=>r.type==="group"&&r.name===n);if(!s)return;let l=i.map(r=>r.split("::")),o=[];l.forEach(([r,c])=>{let a=s.columns.find(f=>f.name===c);a&&o.push(a)}),s.columns=o,this.columns=[...this.columns],this.isLive&&this.applyTableColumnManager()},reorderTopLevel(i){let n=this.columns,s=[];i.forEach(([l,o])=>{let r=n.find(c=>l==="group"?c.type==="group"&&c.name===o:l==="column"?c.type!=="group"&&c.name===o:!1);r&&s.push(r)}),this.columns=s},async applyTableColumnManager(){this.isLoading=!0;try{await this.$wire.call("applyTableColumnManager",this.columns),this.error=void 0}catch(i){this.error="Failed to update column visibility",console.error("Table toggle columns error:",i)}finally{this.isLoading=!1}}}}document.addEventListener("alpine:init",()=>{window.Alpine.data("filamentTable",Ee),window.Alpine.data("filamentTableColumnManager",ne)});})();