lumarc-grid
Version:
lumArc Grid는 고성능, 유연하고 프레임워크에 구애받지 않는 데이터 그리드 라이브러리
181 lines • 213 kB
JavaScript
"use strict";const u=require("react/jsx-runtime"),C=require("react"),zn=require("react-dom"),Y=require("./pagination-BQuFe8eW.js");function so(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const d=so(C),Kt=so(zn);class ao{constructor(t){this.isDirty=!1,this.getRowId=t.getRowId,this.rows=[],this.rowMap=new Map,this.initializeFromData(t.data||[])}initializeFromData(t){this.rows=t.map((n,r)=>{const o=this.getRowId?this.getRowId(n,r):r,s={id:o,data:n,state:{isDeleted:!1,isCreated:!1,isModified:!1},originalData:{...n}};return this.rowMap.set(o,s),s}),this.invalidateCache()}invalidateCache(){this.sortedIndices=void 0,this.filteredIndices=void 0,this.isDirty=!0}getData(){return this.rows.map(t=>t.data)}getLength(){return this.rows.length}getManagedRow(t){return this.rowMap.get(t)}getRowById(t){const n=this.rowMap.get(t);return n?n.data:void 0}getRowByIndex(t){var n;return(n=this.rows[t])==null?void 0:n.data}getIndexByRowId(t){if(this.rowMap.get(t))return this.rows.findIndex(r=>r.id===t)}getRowIdByIndex(t){var n;return(n=this.rows[t])==null?void 0:n.id}updateRow(t,n){const r=this.rowMap.get(t);return r?(r.originalData||(r.originalData={...r.data}),Object.assign(r.data,n),r.state.isCreated||(r.state.isModified=!0,r.state.modifiedAt=new Date),this.invalidateCache(),!0):!1}addRow(t){const n=`new_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,r={id:n,data:t,state:{isDeleted:!1,isCreated:!0,isModified:!1,createdAt:new Date}};return this.rows.push(r),this.rowMap.set(n,r),this.invalidateCache(),n}addRowAtPosition(t,n){const r=Math.min(n,this.rows.length),o=`new_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,s={id:o,data:t,state:{isDeleted:!1,isCreated:!0,isModified:!1,createdAt:new Date}};return this.rows.splice(r,0,s),this.rowMap.set(o,s),this.invalidateCache(),o}deleteRow(t){const n=this.rowMap.get(t);if(!n)return!1;if(n.state.isCreated){const r=this.rows.indexOf(n);return r!==-1?(this.rows.splice(r,1),this.rowMap.delete(t),this.invalidateCache(),!0):!1}return n.state.isDeleted=!0,n.state.deletedAt=new Date,this.invalidateCache(),!0}deleteRows(t){let n=0;return t.forEach(r=>{this.deleteRow(r)&&n++}),n}restoreRow(t){const n=this.rowMap.get(t);return!n||!n.state.isDeleted?!1:(n.state.isDeleted=!1,n.state.deletedAt=void 0,!0)}sort(t){if(!this.sortedIndices||this.isDirty){const n=Array.from({length:this.rows.length},(r,o)=>o);this.sortedIndices=n.sort((r,o)=>t(this.rows[r].data,this.rows[o].data)),this.isDirty=!1}return this.sortedIndices}filter(t){const n=this.sortedIndices||Array.from({length:this.rows.length},(r,o)=>o);return this.filteredIndices=n.filter(r=>t(this.rows[r].data,r)),this.filteredIndices}getRowByDisplayIndex(t){var o;const n=this.filteredIndices||this.sortedIndices,r=n?n[t]:t;return(o=this.rows[r])==null?void 0:o.data}getRowIdByDisplayIndex(t){var o;const n=this.filteredIndices||this.sortedIndices,r=n?n[t]:t;return(o=this.rows[r])==null?void 0:o.id}getDisplayLength(){const t=this.filteredIndices||this.sortedIndices;return t?t.length:this.rows.length}getChanges(){const t=[],n=[],r=[];return this.rows.forEach(o=>{if(o.state.isCreated&&!o.state.isDeleted)t.push(o.data);else if(o.state.isModified&&!o.state.isDeleted&&o.originalData){const s=this.getChangedFields(o.originalData,o.data);n.push({original:o.originalData,current:o.data,changedFields:s})}else o.state.isDeleted&&!o.state.isCreated&&r.push(o.originalData||o.data)}),{created:t,modified:n,deleted:r}}getChangedFields(t,n){const r=[];for(const o in n)t[o]!==n[o]&&r.push(o);return r}commitChanges(){this.rows=this.rows.filter(t=>t.state.isDeleted?(this.rowMap.delete(t.id),!1):!0),this.rows.forEach(t=>{(t.state.isCreated||t.state.isModified)&&(t.originalData={...t.data}),t.state={isDeleted:!1,isCreated:!1,isModified:!1}}),this.invalidateCache()}resetChanges(){this.rows=this.rows.filter(t=>t.state.isCreated&&t.state.isDeleted?(this.rowMap.delete(t.id),!1):t.state.isCreated&&!t.state.isDeleted?(this.rowMap.delete(t.id),!1):(t.state.isDeleted&&(t.state.isDeleted=!1,t.state.deletedAt=void 0),t.state.isModified&&t.originalData&&(t.data={...t.originalData},t.state.isModified=!1,t.state.modifiedAt=void 0),!0)),this.invalidateCache()}isRowCreated(t){const n=this.rowMap.get(t);return(n==null?void 0:n.state.isCreated)||!1}isRowModified(t){const n=this.rowMap.get(t);return(n==null?void 0:n.state.isModified)||!1}isRowDeleted(t){const n=this.rowMap.get(t);return(n==null?void 0:n.state.isDeleted)||!1}getModifiedFields(t){const n=this.rowMap.get(t);return!n||!n.state.isModified||!n.originalData?[]:this.getChangedFields(n.originalData,n.data)}getChangesSummary(){let t=0,n=0,r=0;return this.rows.forEach(o=>{o.state.isCreated&&!o.state.isDeleted?t++:o.state.isModified&&!o.state.isDeleted?n++:o.state.isDeleted&&!o.state.isCreated&&r++}),{created:t,modified:n,deleted:r}}hasChanges(){return this.rows.some(t=>t.state.isCreated&&!t.state.isDeleted||t.state.isModified&&!t.state.isDeleted||t.state.isDeleted&&!t.state.isCreated)}getStats(){var s,a;const t=this.rows.length,n=this.rows.filter(i=>i.state.isDeleted).length,r=this.rows.filter(i=>i.state.isCreated).length,o=this.rows.filter(i=>i.state.isModified).length;return{dataLength:t,total:t,deleted:n,created:r,modified:o,sortedLength:((s=this.sortedIndices)==null?void 0:s.length)||0,filteredLength:((a=this.filteredIndices)==null?void 0:a.length)||0,displayLength:this.getDisplayLength(),isDirty:this.isDirty,memoryUsage:{rows:this.rows.length,rowMap:this.rowMap.size}}}getAllRowIds(){return this.rows.map(t=>t.id)}getDisplayRowIds(){const t=this.filteredIndices||this.sortedIndices;return t?t.map(n=>this.rows[n].id):this.rows.map(n=>n.id)}setData(t){this.rowMap.clear(),this.initializeFromData(t)}getRowByRowId(t){return this.getRowById(t)}getRowIdByData(t){for(const[n,r]of this.rowMap)if(r.data===t)return n}updateData(t,n){n!==void 0&&(this.getRowId=n),this.setData(t)}}function Ci(e){const{rowManager:t,isServerSide:n,onDataChange:r}=e,o=C.useCallback((h={})=>{if(n)return-1;const v=t.addRow(h),g=t.getData();return r==null||r(g),v},[t,r,n]),s=C.useCallback((h,v)=>{if(n)return!1;const g=t.updateRow(h,v);if(g){const b=t.getData();r==null||r(b)}return g},[t,r,n]),a=C.useCallback(h=>{if(n)return;h.forEach(({id:g,data:b})=>{t.updateRow(g,b)});const v=t.getData();r==null||r(v)},[t,r,n]),i=C.useCallback(h=>{if(n)return!1;const v=t.deleteRow(h);if(v){const g=t.getData();r==null||r(g)}return v},[t,r,n]),l=C.useCallback(h=>{if(n)return 0;const v=t.deleteRows(h);if(v>0){const g=t.getData();r==null||r(g)}return v},[t,r,n]),c=C.useCallback((h={},v)=>{if(n)return-1;const g=t.addRowAtPosition(h,v),b=t.getData();return r==null||r(b),g},[t,r,n]),f=C.useCallback(()=>t.getData(),[t]);return{addRow:o,addRowAtPosition:c,updateRow:s,updateRows:a,deleteRow:i,deleteRows:l,getData:f}}function Si(e){const{rowManager:t,isServerSide:n}=e,[r,o]=C.useState(0),s=C.useCallback(()=>{o(p=>p+1)},[]),a=C.useCallback(()=>n?{created:[],modified:[],deleted:[]}:t.getChanges(),[t,n,r]),i=C.useCallback(()=>n?{created:0,modified:0,deleted:0}:t.getChangesSummary(),[t,n,r]),l=C.useMemo(()=>n?!1:t.hasChanges(),[t,n,r]),c=C.useCallback(()=>{n||(t.commitChanges(),s())},[t,n,s]),f=C.useCallback(()=>{n||(t.resetChanges(),s())},[t,n,s]),h=C.useCallback(p=>n?!1:t.isRowCreated(p),[t,n]),v=C.useCallback(p=>n?!1:t.isRowModified(p),[t,n]),g=C.useCallback(p=>n?!1:t.isRowDeleted(p),[t,n]),b=C.useCallback(p=>n?[]:t.getModifiedFields(p),[t,n]),m=C.useCallback((p,w,y)=>{n||s()},[n,s]);return{changes:C.useMemo(()=>a(),[a]),hasChanges:l,getChanges:a,getChangesSummary:i,commitChanges:c,resetChanges:f,isRowCreated:h,isRowModified:v,isRowDeleted:g,getModifiedFields:b,updateChangeTracking:m}}function Vn(e){return`row-${e}`}function Ri(e){if(e.startsWith("row-")){const t=e.replace("row-",""),n=Number(t);return!isNaN(n)&&isFinite(n)?n:t}return e}function Ii(e,t){const n=t.map(o=>Vn(o.id)),r=n.indexOf(e);return r>=0&&r<n.length-1?n[r+1]:null}function Ei(e,t){const n=t.map(o=>Vn(o.id)),r=n.indexOf(e);return r>0?n[r-1]:null}function io(e){return Vn(e)}function Ni(e,t){const n=Ri(e);return typeof n=="number"&&Number.isInteger(n)?n:t.findIndex(r=>r.id===n)}function Mi(e){const{columns:t,data:n}=e,[r,o]=C.useState({}),s=C.useCallback((h,v,g,b)=>{const m=isNaN(Number(h))?h:Number(h);let x;if(typeof m=="number"?x=n[m]:x=n.find(S=>{var R;return((R=S.id)==null?void 0:R.toString())===h}),!x)return null;const p=t.find(S=>S.accessorKey===v);if(!p||!Y.shouldValidateOnEvent(p,b))return null;const w=Y.validateCellValue(g,p,x),y=`${h}-${v}`;return o(w?S=>({...S,[y]:w}):S=>{const R={...S};return delete R[y],R}),w},[n,t]),a=C.useCallback((h,v="submit")=>{const g=n.find(m=>typeof h=="number"?n.indexOf(m)===h:m.id===h);if(!g)return{};const b=Y.validateRowData(g,t);return Object.keys(b).length>0&&o(m=>({...m,...Object.fromEntries(Object.entries(b).map(([x,p])=>[`${h}-${x}`,p]))})),b},[n,t]),i=C.useCallback((h,v,g)=>s(h,v,g,"realtime"),[s]),l=C.useCallback((h,v)=>{const g=`${h}-${v}`;o(b=>{const m={...b};return delete m[g],m})},[]),c=C.useCallback(()=>{o({})},[]),f=Object.keys(r).length>0;return{validationErrors:r,hasValidationErrors:f,clearValidationError:l,clearAllValidationErrors:c,validateCell:s,validateRow:a,handleCellValueChange:i}}function ki(e){const{gridSelection:t}=e,n=C.useCallback((f,h=!0)=>{const v=`row-${f}`;t.handleRowSelect(v,h)},[t]),r=C.useCallback(f=>{f.forEach(h=>n(h,!0))},[n]);C.useCallback(f=>{t.handleSelectAll(f)},[t]);const o=C.useCallback(()=>{const f=!t.isAllSelected;t.handleSelectAll(f)},[t]),s=C.useCallback(()=>{t.clearSelection()},[t]),a=C.useCallback(()=>t.getSelectedRowIds(),[t]),i=C.useCallback(()=>t.getSelectedData(),[t]),l=C.useCallback((f,h)=>{const v=f.replace("row-","");n(v,h)},[n]),c=C.useMemo(()=>new Set(a().map(f=>`row-${f}`)),[a]);return{selectRow:n,selectRows:r,selectAll:o,clearSelection:s,getSelectedIds:a,getSelectedRows:i,selectedRows:c,isAllSelected:t.isAllSelected,isIndeterminate:t.isIndeterminate,handleSelectAll:t.handleSelectAll,handleRowSelectChange:l}}function Pi(e){const{rowManager:t,gridEditing:n,validationAPI:r,isServerSide:o,updateRow:s,onEditComplete:a}=e,i=C.useCallback((c,f,h)=>{const v=c.replace("row-",""),g=isNaN(Number(v))?v:Number(v),b=t.getRowById(g);if(b){const m=b[f];let x=!1;typeof m=="number"||!isNaN(Number(h))?x=Number(m)!==Number(h):x=String(m||"")!==String(h||""),x?(r.validateCell(v,f,h,"blur"),o||s(g,{[f]:h}),n.handleCellEdit(c,f,h)):n.handleEditCancel(),a==null||a(c,f)}else n.handleEditCancel(),a==null||a(c,f)},[t,r,o,s,n,a]),l=C.useCallback(()=>{const c=n.editingCell;n.handleEditCancel(),c&&(a==null||a(c.rowId,c.field))},[n,a]);return{editingCell:n.editingCell,recentlySavedCells:n.recentlySavedCells,singleClickEdit:n.singleClickEdit,setSingleClickEdit:n.setSingleClickEdit,startEdit:n.handleEditStart,cancelEdit:n.handleEditCancel,handleCellEditComplete:i,handleEditCancel:l}}function Ti({totalRows:e,totalColumns:t,onCellFocus:n,onEditStart:r,onTabNext:o,onTabPrevious:s,disabled:a=!1}){const[i,l]=C.useState(null),c=C.useRef(new Map),f=C.useCallback((b,m)=>{const x=`${b.rowIndex}-${b.columnIndex}`;m?c.current.set(x,m):c.current.delete(x)},[]),h=C.useCallback(b=>{if(b.rowIndex<0||b.rowIndex>=e||b.columnIndex<0||b.columnIndex>=t)return;l(b);const m=`${b.rowIndex}-${b.columnIndex}`,x=c.current.get(m);if(x)try{x.focus(),n==null||n(b)}catch(p){console.error(p)}},[e,t,n]),v=C.useCallback(b=>{const m=i||{rowIndex:0,columnIndex:0};let x=m.rowIndex,p=m.columnIndex;switch(b){case"up":x=Math.max(0,x-1);break;case"down":x=Math.min(e-1,x+1);break;case"left":p=Math.max(0,p-1);break;case"right":p=Math.min(t-1,p+1);break}(x!==m.rowIndex||p!==m.columnIndex)&&h({rowIndex:x,columnIndex:p})},[i,e,t,h]),g=C.useCallback((b,m)=>{if(!a){if(b.key==="Escape"){b.preventDefault(),b.stopPropagation(),l(null);return}switch(i||l(m),b.key){case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":b.preventDefault(),b.stopPropagation(),v(b.key.replace("Arrow","").toLowerCase());break;case"Enter":b.preventDefault(),b.stopPropagation(),r==null||r(i||m);break;case"Tab":b.preventDefault(),b.stopPropagation(),b.shiftKey?s==null||s(i||m):o==null||o(i||m);break}}},[a,i,v,r,o,s]);return{currentPosition:i,setCurrentPosition:l,handleKeyDown:g,focusCell:h,moveTo:v,registerCellRef:f}}const yn=e=>`${e.rowIndex}-${e.columnIndex}`,wr=e=>{const[t,n]=e.split("-").map(Number);return{rowIndex:t,columnIndex:n}},br=(e,t)=>{const n=new Set,r=Math.min(e.rowIndex,t.rowIndex),o=Math.max(e.rowIndex,t.rowIndex),s=Math.min(e.columnIndex,t.columnIndex),a=Math.max(e.columnIndex,t.columnIndex);for(let i=r;i<=o;i++)for(let l=s;l<=a;l++)n.add(yn({rowIndex:i,columnIndex:l}));return n};function Ai({totalRows:e,totalColumns:t,onSelectionChange:n,disabled:r=!1}){const[o,s]=C.useState(null),[a,i]=C.useState(new Set),[l,c]=C.useState(!1),f=C.useCallback(y=>y.rowIndex>=0&&y.rowIndex<e&&y.columnIndex>=0&&y.columnIndex<t,[e,t]),h=C.useCallback(y=>{const S=Array.from(y).map(wr);n==null||n(S)},[n]),v=C.useCallback(y=>{if(r||!f(y))return;c(!0),s({start:y,end:y});const S=yn(y),R=new Set([S]);i(R),h(R)},[r,f,h]),g=C.useCallback(y=>{if(r||!l||!o||!f(y))return;const S={...o,end:y};s(S);const R=br(o.start,y);i(R),h(R)},[r,l,o,f,h]),b=C.useCallback(()=>{c(!1)},[]),m=C.useCallback(()=>{s(null),i(new Set),c(!1),h(new Set)},[h]),x=C.useCallback((y,S)=>{if(r||!f(y)||!f(S))return;const R=br(y,S);s({start:y,end:S}),i(R),h(R)},[r,f,h]),p=C.useCallback(y=>r||!f(y)?!1:a.has(yn(y)),[r,f,a]),w=C.useCallback(()=>Array.from(a).map(wr),[a]);return{selectedRange:o,selectedCells:a,isSelecting:l,startSelection:v,updateSelection:g,endSelection:b,clearSelection:m,selectRange:x,isCellSelected:p,getSelectedPositions:w}}function ji({data:e,columns:t,selectedPositions:n,onCellUpdate:r,onPasteComplete:o}){const[s,a]=C.useState(null),i=C.useCallback(()=>{var w,y;if(n.length===0)return[];const g=Math.min(...n.map(S=>S.rowIndex)),b=Math.max(...n.map(S=>S.rowIndex)),m=Math.min(...n.map(S=>S.columnIndex)),x=Math.max(...n.map(S=>S.columnIndex)),p=[];for(let S=g;S<=b;S++){const R=[];for(let I=m;I<=x;I++)if(n.find(A=>A.rowIndex===S&&A.columnIndex===I)&&S<e.length&&I<t.length){const A=((w=t[I])==null?void 0:w.accessorKey)||((y=t[I])==null?void 0:y.id),V=e[S],D=V==null?void 0:V[A];R.push(D!=null?String(D):"")}else R.push("");p.push(R)}return p},[n,e,t]),l=C.useCallback(async()=>{if(n.length===0)return;const g=i();a({values:g,positions:n,type:"copy"});try{const b=g.map(m=>m.join(" ")).join(`
`);await navigator.clipboard.writeText(b)}catch(b){console.error("Failed to copy to clipboard:",b)}},[n,i]),c=C.useCallback(async()=>{n.length!==0&&(await l(),a({values:i(),positions:n,type:"cut"}),n.forEach(g=>{var m,x;const b=((m=t[g.columnIndex])==null?void 0:m.accessorKey)||((x=t[g.columnIndex])==null?void 0:x.id);b&&r&&r(g.rowIndex,b,"")}),o&&o(n))},[n,l,r]),f=C.useCallback(async g=>{var b,m;try{const x=await navigator.clipboard.readText();if(!x.trim())return;const w=x.split(`
`).map(S=>S.split(" ")),y=[];for(let S=0;S<w.length;S++){const R=g.rowIndex+S;if(R>=e.length)break;for(let I=0;I<w[S].length;I++){const N=g.columnIndex+I;if(N>=t.length)break;const A=w[S][I],V=((b=t[N])==null?void 0:b.accessorKey)||((m=t[N])==null?void 0:m.id);V&&r&&(r(R,V,A),y.push({rowIndex:R,columnIndex:N}))}}o&&o(y)}catch(x){console.error("Failed to paste from clipboard:",x)}},[e,t,r,o]),h=C.useCallback((g,b)=>{if(navigator.platform.toUpperCase().indexOf("MAC")>=0?g.metaKey:g.ctrlKey)switch(g.key.toLowerCase()){case"c":g.preventDefault(),l();break;case"x":g.preventDefault(),c();break;case"v":g.preventDefault();const p=b||(n.length>0?n[0]:{rowIndex:0,columnIndex:0});f(p);break}},[l,c,f,n]);return{clipboardData:s,copySelection:l,cutSelection:c,paste:f,handleKeyboardShortcuts:h,canPaste:!!s}}function Di({data:e,columns:t,onCellEdit:n,onEditStart:r,incrementDataVersion:o}){const s=e.length,a=t.length,i=Ti({totalRows:s,totalColumns:a,onCellFocus:C.useCallback(p=>{},[]),onEditStart:C.useCallback(p=>{const w=t[p.columnIndex];w&&n&&n(p.rowIndex,String(w.accessorKey),"")},[t,n]),disabled:!1}),l=Ai({totalRows:s,totalColumns:a,onSelectionChange:C.useCallback(()=>{},[]),disabled:!1}),c=ji({data:e,columns:t.map(p=>({id:p.id,accessorKey:String(p.accessorKey)})),selectedPositions:l.getSelectedPositions(),onCellUpdate:C.useCallback((p,w,y)=>{n&&n(p,w,y)},[n]),onPasteComplete:C.useCallback(p=>{o()},[o])}),f=C.useRef(0),h=C.useRef(null),v=C.useCallback((p,w)=>{w.preventDefault(),w.stopPropagation(),h.current=p,i.focusCell(p),w.shiftKey&&i.currentPosition?l.selectRange(i.currentPosition,p):w.ctrlKey||w.metaKey?l.isCellSelected(p)?l.clearSelection():l.startSelection(p):(l.clearSelection(),l.startSelection(p),l.endSelection())},[l,i]),g=C.useCallback((p,w)=>{!l.isSelecting||!h.current||w.buttons===1&&l.updateSelection(p)},[l]),b=C.useCallback(p=>{l.endSelection(),h.current=null},[l]),m=C.useCallback((p,w)=>{if(/Mac|iPod|iPhone|iPad/.test(navigator.userAgent)?w.metaKey:w.ctrlKey){c.handleKeyboardShortcuts(w,p);return}if(w.key==="Enter"||w.key==="F2"){if(w.preventDefault(),w.stopPropagation(),n){const R=t[p.columnIndex];R&&n(p.rowIndex,String(R.accessorKey),"")}return}switch(w.key){case"Escape":w.preventDefault(),l.clearSelection();return;case"Delete":case"Backspace":w.preventDefault();const R=l.getSelectedPositions();if(R.length>0)R.forEach(I=>{const N=t[I.columnIndex];N&&n&&n(I.rowIndex,String(N.accessorKey),"")});else{const I=t[p.columnIndex];I&&n&&n(p.rowIndex,String(I.accessorKey),"")}return}if(w.shiftKey){let R=null;switch(w.key){case"ArrowUp":R={rowIndex:Math.max(0,p.rowIndex-1),columnIndex:p.columnIndex};break;case"ArrowDown":R={rowIndex:Math.min(s-1,p.rowIndex+1),columnIndex:p.columnIndex};break;case"ArrowLeft":R={rowIndex:p.rowIndex,columnIndex:Math.max(0,p.columnIndex-1)};break;case"ArrowRight":R={rowIndex:p.rowIndex,columnIndex:Math.min(a-1,p.columnIndex+1)};break}if(R){w.preventDefault(),l.selectedRange||l.startSelection(p),l.updateSelection(R),i.focusCell(R);return}}i.handleKeyDown(w,p)},[i,c,l,t,n,r,s,a]),x=C.useCallback((p,w)=>{const y=Date.now(),S=y-f.current;if(f.current=y,S<300&&n){const R=t[p.columnIndex];R&&n(p.rowIndex,String(R.accessorKey),"")}},[i,l,t,n,r]);return{currentPosition:i.currentPosition,focusCell:i.focusCell,registerCellRef:i.registerCellRef,selectedCells:l.selectedCells,selectedRange:l.selectedRange,isSelecting:l.isSelecting,isCellSelected:l.isCellSelected,clearCellSelection:l.clearSelection,canPaste:c.canPaste,copySelection:c.copySelection,cutSelection:c.cutSelection,paste:c.paste,handleCellMouseDown:v,handleCellMouseEnter:g,handleCellMouseUp:b,handleCellKeyDown:m,handleCellClick:x}}function lo(e){var J,te,X;const t=C.useRef(e.data||e.initialData||[]),[n,r]=C.useState(0),o=C.useCallback(()=>r(M=>M+1),[]),s=C.useMemo(()=>new ao({data:[...t.current],getRowId:e.getRowId}),[]),a=!!((J=e.serverSide)!=null&&J.enabled),i=C.useMemo(()=>{var $;const M=($=e.features)==null?void 0:$.pagination;return M?M===!0?{pageSize:e.pageSize||10}:{pageSize:M.pageSize||e.pageSize||10}:{pageSize:e.pageSize||10}},[(te=e.features)==null?void 0:te.pagination,e.pageSize]),l=bi({config:e.serverSide||{enabled:!1,onDataLoad:async()=>({data:[],totalCount:0,filteredCount:0,page:0,pageSize:10,totalPages:0})},initialPagination:i}),c=gi({rowManager:s,columns:e.columns,initialSorting:e.initialSorting,initialFiltering:e.initialFiltering,initialPagination:i,dataVersion:n}),f=a?l.data:s.getData(),h=C.useMemo(()=>a?l.data:c.displayIndices.map($=>{const Q=s.getRowByIndex($);if(!Q)return null;const ne=s.getRowIdByIndex($);return{...Q,id:ne}}).filter($=>$!==null),[a,l.data,c.displayIndices,n]),v=vi({rowManager:s,displayData:h,onRowSelect:e.onSelectionChange}),g=xi({columns:e.columns,onCellEdit:e.onCellEdit,data:f}),b=wi({onRowAction:e.onRowAction}),m=Ci({rowManager:s,isServerSide:a,onDataChange:e.onDataChange}),x=Si({rowManager:s,initialData:t.current,isServerSide:a}),p=Mi({columns:e.columns,data:f}),w=ki({gridSelection:v,onSelectionChange:e.onSelectionChange}),y=C.useCallback((M,$)=>{const Q=m.updateRow(M,$);return Q&&(x.updateChangeTracking(m.getData(),"update"),o()),Q},[m,x,o]),S=Di({data:h,columns:e.columns,onCellEdit:e.onCellEdit,onEditStart:void 0,incrementDataVersion:o}),R=Pi({rowManager:s,gridEditing:g,validationAPI:p,isServerSide:a,updateRow:y,onEditComplete:C.useCallback((M,$)=>{const Q=M.replace("row-",""),ne=isNaN(Number(Q))?Q:Number(Q),re=h.findIndex(le=>String(le.id||le)===String(ne)),ie=e.columns.findIndex(le=>le.id===$);re>=0&&ie>=0&&setTimeout(()=>{S.focusCell({rowIndex:re,columnIndex:ie})},100)},[h,e.columns,S])}),I={...S,handleCellKeyDown:C.useCallback((M,$)=>{if(!(/Mac|iPod|iPhone|iPad/.test(navigator.userAgent)?$.metaKey:$.ctrlKey)){if($.key==="Enter"||$.key==="F2"){$.preventDefault(),$.stopPropagation();const re=`row-${M.rowIndex}`,ie=e.columns[M.columnIndex];ie&&R.startEdit(re,ie.id);return}S.handleCellKeyDown(M,$)}},[R,e.columns,S])},N=C.useCallback((M={})=>{const $=c.pagination.pageIndex,Q=c.pagination.pageSize,re=$*Q+Q,ie=m.addRowAtPosition(M,re);return ie!==-1&&(x.updateChangeTracking(m.getData(),"create"),c.handleTemporaryPageSizeIncrease()),ie},[m,x,c]),A=C.useCallback(M=>{m.updateRows(M),x.updateChangeTracking(m.getData(),"update")},[m,x]),V=C.useCallback(M=>{const $=s.getRowByRowId(M),Q=x.isRowCreated(M),ne=m.deleteRow(M);return ne&&$&&(w.selectRow(M,!1),x.updateChangeTracking(m.getData(),"delete",[$]),Q&&c.handleTemporaryPageSizeDecrease(),o()),ne},[m,x,s,w,c,o]),D=C.useCallback(M=>{const $=M.map(re=>s.getRowByRowId(re)).filter(Boolean),Q=M.filter(re=>x.isRowCreated(re)).length,ne=m.deleteRows(M);if(ne>0){M.forEach(re=>{w.selectRow(re,!1)}),x.updateChangeTracking(m.getData(),"delete",$);for(let re=0;re<Q;re++)c.handleTemporaryPageSizeDecrease();o()}return ne},[m,x,s,w,c,o]),P=C.useCallback(M=>{c.handleSort(M)},[c]),O=C.useCallback((M,$)=>{c.handleFilter(M,$)},[c]),F=C.useCallback(M=>{c.handlePageChange(M)},[c]),T=C.useCallback(M=>{c.handlePageSizeChange(M)},[c]),W=C.useCallback(()=>{c.clearSorting()},[c]),_=C.useCallback(()=>{c.clearFiltering()},[c]),G=C.useCallback(()=>f,[f]),z=C.useCallback(()=>h,[h]),k=C.useCallback(()=>a?l.totalCount:s.getLength(),[a,l.totalCount,s]),Z=C.useCallback(()=>a?l.filteredCount:c.filteredCount,[a,l.filteredCount,c.filteredCount]),j=C.useCallback(()=>{console.log("Export to CSV - Coming soon!")},[]),H=C.useCallback(()=>s.getStats(),[s]),L=C.useCallback((M,$,Q)=>{b.handleRowAction(M,$,Q)},[b]),B=C.useMemo(()=>({sorting:c.sorting,filtering:c.filtering,pagination:{pageIndex:c.pagination.pageIndex,pageSize:c.pagination.pageSize,totalCount:c.pagination.totalCount},selection:{selectedCount:w.getSelectedRows().length,isAllSelected:w.isAllSelected,isIndeterminate:w.isIndeterminate}}),[c,w]),U=C.useMemo(()=>{const $=w.getSelectedIds().map(Q=>`row-${Q}`);return new Set($)},[w]),ee=C.useMemo(()=>{var M;return{data:h,columns:e.columns,features:{sorting:e.sortable!==!1,filtering:e.filterable!==!1,pagination:e.showPagination!==!1?{enabled:!0,pageSize:e.pageSize||10,showPageSizeSelector:!0,showPageInfo:!0,showFirstLast:!0,siblingCount:1}:!1,editing:e.editable!==!1,selection:e.selectable!==!1,globalSearch:!0,...e.features},loading:a?l.serverState.loading:!1,error:a&&((M=l.serverState.error)==null?void 0:M.message)||null,sorting:c.sorting,selectedRows:U,isAllSelected:w.isAllSelected,isIndeterminate:w.isIndeterminate,selectedCount:w.getSelectedRows().length,totalCount:k(),filteredCount:Z(),currentPage:c.pagination.pageIndex,totalPages:Math.ceil(Z()/c.pagination.pageSize),currentPageSize:c.pagination.pageSize,editingCell:R.editingCell,recentlySavedCells:R.recentlySavedCells,singleClickEdit:R.singleClickEdit,validationErrors:p.validationErrors,onRowSelect:e.onSelectionChange,onCellEdit:e.onCellEdit,onRowAction:e.onRowAction,onSelectAll:w.handleSelectAll,onRowSelectChange:w.handleRowSelectChange,onSort:P,onPageChange:F,onPageSizeChange:T,onEditStart:R.startEdit,onEditCancel:R.handleEditCancel,onCellEditComplete:R.handleCellEditComplete,onCellValueChange:p.handleCellValueChange,isRowCreated:x.isRowCreated,isRowModified:x.isRowModified,isRowDeleted:x.isRowDeleted,getModifiedFields:x.getModifiedFields,validateCell:p.validateCell,currentPosition:I.currentPosition,selectedCell:I.currentPosition,isCellSelected:I.isCellSelected,registerCellRef:I.registerCellRef,onCellMouseDown:I.handleCellMouseDown,onCellKeyDown:I.handleCellKeyDown,onCellClick:I.handleCellClick}},[h,e,a,l,c,U,w,R,p,x,P,F,T,k,Z,I]),E=C.useCallback(()=>{x.resetChanges(),w.clearSelection(),I.clearCellSelection(),c.clearAll(),p.clearAllValidationErrors(),o()},[x,w,I,c,p,o]);return{...I,addRow:N,updateRow:y,updateRows:A,deleteRow:V,deleteRows:D,selectRow:w.selectRow,selectRows:w.selectRows,selectAll:w.selectAll,clearSelection:w.clearSelection,getSelectedIds:w.getSelectedIds,getSelectedRows:w.getSelectedRows,selectedRows:U,isAllSelected:w.isAllSelected,isIndeterminate:w.isIndeterminate,editingCell:R.editingCell,recentlySavedCells:R.recentlySavedCells,singleClickEdit:R.singleClickEdit,setSingleClickEdit:R.setSingleClickEdit,startEdit:R.startEdit,cancelEdit:R.handleEditCancel,paste:I.paste,changes:x.changes,hasChanges:x.hasChanges,getChanges:x.getChanges,getChangesSummary:x.getChangesSummary,commitChanges:x.commitChanges,resetChanges:E,isRowCreated:x.isRowCreated,isRowModified:x.isRowModified,isRowDeleted:x.isRowDeleted,getModifiedFields:x.getModifiedFields,validationErrors:p.validationErrors,clearValidationError:p.clearValidationError,clearAllValidationErrors:p.clearAllValidationErrors,hasValidationErrors:p.hasValidationErrors,validateCell:p.validateCell,validateRow:p.validateRow,handleCellValueChange:p.handleCellValueChange,sort:P,filter:O,goToPage:F,setPageSize:T,clearSorting:W,clearFiltering:_,getData:G,getDisplayData:z,getTotalCount:k,getFilteredCount:Z,data:f,processedData:h,isServerSide:a,loading:a?l.serverState.loading:!1,error:a&&((X=l.serverState.error)==null?void 0:X.message)||null,refresh:a?l.refresh:void 0,retry:a?l.retry:void 0,clearError:a?l.clearError:void 0,state:B,exportToCSV:j,getStats:H,handleRowAction:L,tableProps:ee}}function Ze(e,t,n){let r=n.initialDeps??[],o;function s(){var a,i,l,c;let f;n.key&&((a=n.debug)!=null&&a.call(n))&&(f=Date.now());const h=e();if(!(h.length!==r.length||h.some((b,m)=>r[m]!==b)))return o;r=h;let g;if(n.key&&((i=n.debug)!=null&&i.call(n))&&(g=Date.now()),o=t(...h),n.key&&((l=n.debug)!=null&&l.call(n))){const b=Math.round((Date.now()-f)*100)/100,m=Math.round((Date.now()-g)*100)/100,x=m/16,p=(w,y)=>{for(w=String(w);w.length<y;)w=" "+w;return w};console.info(`%c⏱ ${p(m,5)} /${p(b,5)} ms`,`
font-size: .6rem;
font-weight: bold;
color: hsl(${Math.max(0,Math.min(120-120*x,120))}deg 100% 31%);`,n==null?void 0:n.key)}return(c=n==null?void 0:n.onChange)==null||c.call(n,o),o}return s.updateDeps=a=>{r=a},s}function yr(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Oi=(e,t)=>Math.abs(e-t)<1.01,_i=(e,t,n)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,o),n)}},Cr=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Li=e=>e,Fi=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let o=t;o<=n;o++)r.push(o);return r},$i=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const o=a=>{const{width:i,height:l}=a;t({width:Math.round(i),height:Math.round(l)})};if(o(Cr(n)),!r.ResizeObserver)return()=>{};const s=new r.ResizeObserver(a=>{const i=()=>{const l=a[0];if(l!=null&&l.borderBoxSize){const c=l.borderBoxSize[0];if(c){o({width:c.inlineSize,height:c.blockSize});return}}o(Cr(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},Sr={passive:!0},Rr=typeof window>"u"?!0:"onscrollend"in window,zi=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let o=0;const s=e.options.useScrollendEvent&&Rr?()=>{}:_i(r,()=>{t(o,!1)},e.options.isScrollingResetDelay),a=f=>()=>{const{horizontal:h,isRtl:v}=e.options;o=h?n.scrollLeft*(v&&-1||1):n.scrollTop,s(),t(o,f)},i=a(!0),l=a(!1);l(),n.addEventListener("scroll",i,Sr);const c=e.options.useScrollendEvent&&Rr;return c&&n.addEventListener("scrollend",l,Sr),()=>{n.removeEventListener("scroll",i),c&&n.removeEventListener("scrollend",l)}},Vi=(e,t,n)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},Bi=(e,{adjustments:t=0,behavior:n},r)=>{var o,s;const a=e+t;(s=(o=r.scrollElement)==null?void 0:o.scrollTo)==null||s.call(o,{[r.options.horizontal?"left":"top"]:a,behavior:n})};class Wi{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(o=>{o.forEach(s=>{const a=()=>{this._measureElement(s.target,s)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var o;(o=r())==null||o.disconnect(),n=null},observe:o=>{var s;return(s=r())==null?void 0:s.observe(o,{box:"border-box"})},unobserve:o=>{var s;return(s=r())==null?void 0:s.unobserve(o)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,o])=>{typeof o>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Li,rangeExtractor:Fi,onChange:()=>{},measureElement:Vi,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,o;(o=(r=this.options).onChange)==null||o.call(r,this,n)},this.maybeNotify=Ze(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,s)=>{this.scrollAdjustments=0,this.scrollDirection=s?this.getScrollOffset()<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=s,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const o=new Map,s=new Map;for(let a=r-1;a>=0;a--){const i=n[a];if(o.has(i.lane))continue;const l=s.get(i.lane);if(l==null||i.end>l.end?s.set(i.lane,i):i.end<l.end&&o.set(i.lane,!0),o.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((a,i)=>a.end===i.end?a.index-i.index:a.end-i.end)[0]:void 0},this.getMeasurementOptions=Ze(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(n,r,o,s,a)=>(this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:o,getItemKey:s,enabled:a}),{key:!1}),this.getMeasurements=Ze(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:o,getItemKey:s,enabled:a},i)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(f=>{this.itemSizeCache.set(f.key,f.size)}));const l=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const c=this.measurementsCache.slice(0,l);for(let f=l;f<n;f++){const h=s(f),v=this.options.lanes===1?c[f-1]:this.getFurthestMeasurement(c,f),g=v?v.end+this.options.gap:r+o,b=i.get(h),m=typeof b=="number"?b:this.options.estimateSize(f),x=g+m,p=v?v.lane:f%this.options.lanes;c[f]={index:f,start:g,size:m,end:x,key:h,lane:p}}return this.measurementsCache=c,c},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=Ze(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,o,s)=>this.range=n.length>0&&r>0?Ki({measurements:n,outerSize:r,scrollOffset:o,lanes:s}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=Ze(()=>{let n=null,r=null;const o=this.calculateRange();return o&&(n=o.startIndex,r=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,o,s,a)=>s===null||a===null?[]:n({startIndex:s,endIndex:a,overscan:r,count:o}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,o=n.getAttribute(r);return o?parseInt(o,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const o=this.indexFromElement(n),s=this.measurementsCache[o];if(!s)return;const a=s.key,i=this.elementsCache.get(a);i!==n&&(i&&this.observer.unobserve(i),this.observer.observe(n),this.elementsCache.set(a,n)),n.isConnected&&this.resizeItem(o,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const o=this.measurementsCache[n];if(!o)return;const s=this.itemSizeCache.get(o.key)??o.size,a=r-s;a!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(o,a,this):o.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",a),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=a,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(o.index),this.itemSizeCache=new Map(this.itemSizeCache.set(o.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,o)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(o))});return}this._measureElement(n,void 0)},this.getVirtualItems=Ze(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const o=[];for(let s=0,a=n.length;s<a;s++){const i=n[s],l=r[i];o.push(l)}return o},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return yr(r[co(0,r.length-1,o=>yr(r[o]).start,n)])},this.getOffsetForAlignment=(n,r,o=0)=>{const s=this.getSize(),a=this.getScrollOffset();r==="auto"&&(r=n>=a+s?"end":"start"),r==="center"?n+=(o-s)/2:r==="end"&&(n-=s);const i=this.getTotalSize()+this.options.scrollMargin-s;return Math.max(Math.min(i,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const o=this.measurementsCache[n];if(!o)return;const s=this.getSize(),a=this.getScrollOffset();if(r==="auto")if(o.end>=a+s-this.options.scrollPaddingEnd)r="end";else if(o.start<=a+this.options.scrollPaddingStart)r="start";else return[a,r];const i=r==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(i,r,o.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(n,{align:r="start",behavior:o}={})=>{o==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:o})},this.scrollToIndex=(n,{align:r="auto",behavior:o}={})=>{o==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),n=Math.max(0,Math.min(n,this.options.count-1));let s=0;const a=10,i=c=>{if(!this.targetWindow)return;const f=this.getOffsetForIndex(n,c);if(!f){console.warn("Failed to get offset for index:",n);return}const[h,v]=f;this._scrollToOffset(h,{adjustments:void 0,behavior:o}),this.targetWindow.requestAnimationFrame(()=>{const g=this.getScrollOffset(),b=this.getOffsetForIndex(n,v);if(!b){console.warn("Failed to get offset for index:",n);return}Oi(b[0],g)||l(v)})},l=c=>{this.targetWindow&&(s++,s<a?(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("Schedule retry",s,a),this.targetWindow.requestAnimationFrame(()=>i(c))):console.warn(`Failed to scroll to index ${n} after ${a} attempts.`))};i(r)},this.scrollBy=(n,{behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let o;if(r.length===0)o=this.options.paddingStart;else if(this.options.lanes===1)o=((n=r[r.length-1])==null?void 0:n.end)??0;else{const s=Array(this.options.lanes).fill(null);let a=r.length-1;for(;a>=0&&s.some(i=>i===null);){const i=r[a];s[i.lane]===null&&(s[i.lane]=i.end),a--}o=Math.max(...s.filter(i=>i!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:o})=>{this.options.scrollToFn(n,{behavior:o,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(t)}}const co=(e,t,n,r)=>{for(;e<=t;){const o=(e+t)/2|0,s=n(o);if(s<r)e=o+1;else if(s>r)t=o-1;else return o}return e>0?e-1:0};function Ki({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const o=e.length-1,s=l=>e[l].start;if(e.length<=r)return{startIndex:0,endIndex:o};let a=co(0,o,s,n),i=a;if(r===1)for(;i<o&&e[i].end<n+t;)i++;else if(r>1){const l=Array(r).fill(0);for(;i<o&&l.some(f=>f<n+t);){const f=e[i];l[f.lane]=f.end,i++}const c=Array(r).fill(n+t);for(;a>=0&&c.some(f=>f>=n);){const f=e[a];c[f.lane]=f.start,a--}a=Math.max(0,a-a%r),i=Math.min(o,i+(r-1-i%r))}return{startIndex:a,endIndex:i}}const Ir=typeof document<"u"?d.useLayoutEffect:d.useEffect;function Hi(e){const t=d.useReducer(()=>({}),{})[1],n={...e,onChange:(o,s)=>{var a;s?zn.flushSync(t):t(),(a=e.onChange)==null||a.call(e,o,s)}},[r]=d.useState(()=>new Wi(n));return r.setOptions(n),Ir(()=>r._didMount(),[]),Ir(()=>r._willUpdate()),r}function Gi(e){return Hi({observeElementRect:$i,observeElementOffset:zi,scrollToFn:Bi,...e})}function Ui({data:e,config:t,containerRef:n,enabled:r=!0}){const o=r&&t.enabled,[s,a]=C.useState(!1);C.useEffect(()=>{n.current?a(!0):a(!1)},[n.current]);const i=Gi({count:e.length,getScrollElement:()=>n.current,estimateSize:C.useCallback(()=>typeof t.rowHeight=="number"?t.rowHeight:t.estimatedRowHeight||50,[t.rowHeight,t.estimatedRowHeight]),overscan:t.overscan||10,horizontal:!1,measureElement:void 0,scrollMargin:0}),[l,c]=C.useState(0);C.useEffect(()=>{if(o&&n.current){const p=n.current,w=()=>{c(y=>y+1)};return p.addEventListener("scroll",w,{passive:!0}),setTimeout(()=>{p&&w()},100),()=>{p.removeEventListener("scroll",w)}}},[o,n.current]);const f=C.useMemo(()=>{if(!o)return[];if(!s||!n.current)return[];try{return i.getVirtualItems().map(y=>({index:y.index,start:y.start,size:y.size,end:y.end,key:String(y.key)}))}catch{return[]}},[i,o,s,n,e.length,l]),h=C.useMemo(()=>!o||f.length===0?e:f.map(p=>e[p.index]).filter(Boolean),[e,f,o]),v=C.useMemo(()=>({height:`${i.getTotalSize()}px`,width:"100%",position:"relative"}),[i]),g=C.useMemo(()=>{var p,w;return{scrollOffset:i.scrollOffset||0,totalHeight:i.getTotalSize(),containerHeight:t.containerHeight||500,visibleStartIndex:((p=f[0])==null?void 0:p.index)||0,visibleEndIndex:((w=f[f.length-1])==null?void 0:w.index)||0,isVirtualizing:!!o}},[i,f,t.containerHeight,o]),b=C.useCallback((p,w)=>{!o||!i||i.scrollToIndex(p,{align:(w==null?void 0:w.align)||"start"})},[i,o]),m=C.useCallback(()=>{!o||!i||i.scrollToIndex(0)},[i,o]),x=C.useCallback(()=>{!o||!i||i.scrollToIndex(e.length-1)},[i,o,e.length]);return{virtualItems:f,visibleData:h,containerStyle:v,virtualizer:i,scrollInfo:g,scrollToIndex:b,scrollToTop:m,scrollToBottom:x}}/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Yi=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),uo=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var Xi={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const qi=C.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:a,...i},l)=>C.createElement("svg",{ref:l,...Xi,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:uo("lucide",o),...i},[...a.map(([c,f])=>C.createElement(c,f)),...Array.isArray(s)?s:[s]]));/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const fe=(e,t)=>{const n=C.forwardRef(({className:r,...o},s)=>C.createElement(qi,{ref:s,iconNode:t,className:uo(`lucide-${Yi(e)}`,r),...o}));return n.displayName=`${e}`,n};/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ht=fe("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const fo=fe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Zi=fe("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ho=fe("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ji=fe("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Qi=fe("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const el=fe("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Er=fe("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const tl=fe("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Bn=fe("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const nl=fe("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rl=fe("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ol=fe("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const sl=fe("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function Nr(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Gt(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Nr(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Nr(e[o],null)}}}}function se(...e){return d.useCallback(Gt(...e),e)}function rt(e){const t=il(e),n=d.forwardRef((r,o)=>{const{children:s,...a}=r,i=d.Children.toArray(s),l=i.find(cl);if(l){const c=l.props.children,f=i.map(h=>h===l?d.Children.count(c)>1?d.Children.only(null):d.isValidElement(c)?c.props.children:null:h);return u.jsx(t,{...a,ref:o,children:d.isValidElement(c)?d.cloneElement(c,void 0,f):null})}return u.jsx(t,{...a,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}var al=rt("Slot");function il(e){const t=d.forwardRef((n,r)=>{const{children:o,...s}=n;if(d.isValidElement(o)){const a=ul(o),i=dl(s,o.props);return o.type!==d.Fragment&&(i.ref=r?Gt(r,a):a),d.cloneElement(o,i)}return d.Children.count(o)>1?d.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var mo=Symbol("radix.slottable");function ll(e){const t=({children:n})=>u.jsx(u.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=mo,t}function cl(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===mo}function dl(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...i)=>{const l=s(...i);return o(...i),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function ul(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const Mr=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,kr=Y.clsx,_e=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return kr(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=t,a=Object.keys(o).map(c=>{const f=n==null?void 0:n[c],h=s==null?void 0:s[c];if(f===null)return null;const v=Mr(f)||Mr(h);return o[c][v]}),i=n&&Object.entries(n).reduce((c,f)=>{let[h,v]=f;return v===void 0||(c[h]=v),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,f)=>{let{class:h,className:v,...g}=f;return Object.entries(g).every(b=>{let[m,x]=b;return Array.isArray(x)?x.includes({...s,...i}[m]):{...s,...i}[m]===x})?[...c,h,v]:c},[]);return kr(e,a,l,n==null?void 0:n.class,n==null?void 0:n.className)},po=_e("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline",sort:"hover:bg-muted/50 text-muted-foreground hover:text-foreground",filter:"border border-dashed border-input bg-background hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10",xs:"h-8 rounded px-2 text-xs"}},defaultVariants:{variant:"default",size:"default"}}),we=d.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,loading:o=!1,icon:s,iconPosition:a="left",children:i,disabled:l,...c},f)=>{const h=r?al:"button";return u.jsxs(h,{className:Y.cn(po({variant:t,size:n,className:e})),ref:f,disabled:l||o,...c,children:[o&&u.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[u.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),u.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),!o&&s&&a==="left"&&s,i,!o&&s&&a==="right"&&s]})});we.displayName="Button";const go=({className:e,...t})=>u.jsx("nav",{role:"navigation","aria-label":"pagination",className:Y.cn("mx-auto flex w-full justify-center",e),...t});go.displayName="Pagination";const vo=d.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,className:Y.cn("flex flex-row items-center gap-1",e),...t}));vo.displayName="PaginationContent";const Ve=d.forwardRef(({className:e,...t},n)=>u.jsx("li",{ref:n,className:Y.cn("",e),...t}));Ve.displayName="PaginationItem";const Ut=({className:e,isActive:t,size:n="icon",...r})=>u.jsx("a",{"aria-current":t?"page":void 0,className:Y.cn(po({variant:t?"outline":"ghost",size:n}),e),...r});Ut.displayName="PaginationLink";const xo=({className:e,...t})=>u.jsxs(Ut,{"aria-label":"Go to previous page",size:"default",className:Y.cn("gap-1 pl-2.5",e),...t,children:[u.jsx(Zi,{className:"h-4 w-4"}),u.jsx("span",{children:"Previous"})]});xo.displayName="PaginationPrevious";const wo=({className:e,...t})=>u.jsxs(Ut,{"aria-label":"Go to next page",size:"default",className:Y.cn("gap-1 pr-2.5",e),...t,children:[u.jsx("span",{children:"Next"}),u.jsx(ho,{className:"h-4 w-4"})]});wo.displayName="PaginationNext";const bo=({className:e,...t})=>u.jsxs("span",{"aria-hidden":!0,className:Y.cn("flex h-9 w-9 items-center justify-center",e),...t,children:[u.jsx(Bn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"More pages"})]});bo.displayName="PaginationEllipsis";function yo({currentPage:e,totalPages:t,pageSize:n,totalCount:r,onPageChange:o,showInfo:s=!0,showFirstLast:a=!0,siblingCount:i=1,className:l}){const c=e+1,f=Y.getPaginationRange(c,t,i),h=Y.formatPaginationInfo(c,n,r),v=d.useCallback(x=>{if(typeof x=="number"){const p=x-1;p>=0&&p<t&&o(p)}},[o,t]),g=d.useMemo(()=>e===0,[e]),b=d.useMemo(()=>e>=t-1,[e,t]),m=t>1&&f.length>0;return u.jsxs("div",{className:`${m?"flex flex-col sm:flex-row items-center justify-between gap-4":"flex items-center justify-between"} ${l}`,children:[s&&u.jsx("div",{className:`text-sm text-muted-foreground ${m?"order-2 sm:order-1":""}`,children:h.description}),m&&u.jsx("div",{className:"flex items-center space-x-2 order-1 sm:order-2",children:u.jsx(go,{children:u.jsxs(vo,{children:[a&&!g&&u.jsx(Ve,{children:u.jsx(we,{variant:"outline",size:"icon",onClick:()=>v(1),disabled:g,"aria-label":"Go to first page",children:u.jsx(Qi,{className:"h-4 w-4"})})}),u.jsx(Ve,{children:u.jsx(xo,{onClick:()=>v(c-1),className:g?"pointer-events-none opacity-50":"cursor-pointer"})}),f.map((x,p)=>{if(x==="...")return u.jsx(Ve,{children:u.jsx(bo,{})},`ellipsis-${p}`);const w=x,y=w===c;return u.jsx(Ve,{children:u.jsx(Ut,{onClick:()=>v(w),isActive:y,className:"cursor-pointer",children:w})},w)}),u.jsx(Ve,{children:u.jsx(wo,{onClick:()=>v(c+1),className:b?"pointer-events-none opacity-50":"cursor-pointer"})}),a&&!b&&u.jsx(Ve,{children:u.jsx(we,{variant:"outline",size:"icon",onClick:()=>v(t),disabled:b,"aria-label":"Go to last page",children:u.jsx(el,{className:"h-4 w-4"})})})]})})})]})}function fl({title:e}){return u.jsx("div",{className:"flex items-center justify-between",children:u.jsx("h1",{className:"text-2xl font-bold",children:e})})}function Pr(e,[t,n]){return Math.min(n,Math.max(t,e))}function K(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Le(e,t=[]){let n=[];function r(s,a){const i=d.createContext(a),l=n.length;n=[...n,a];const c=h=>{var p;const{scope:v,children:g,...b}=h,m=((p=v==null?void 0:v[e])==null?void 0:p[l])||i,x=d.useMemo(()=>b,Object.values(b));return u.jsx(m.Provider,{value:x,children:g})};c.displayName=s+"Provider";function f(h,v){var m;const g=((m=v==null?void 0:v[e])==null?void 0:m[l])||i,b=d.useContext(g);if(b)return b;if(a!==void 0)return a;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[c,f]}const o=()=>{const s=n.map(a=>d.createContext(a));return function(i){const l=(i==null?void 0:i[e])||s;return d.useMemo(()=>({[`__scope${e}`]:{...i,[e]:l}}),[i,l])}};return o.scopeName=e,[r,hl(o,...t)]}function hl(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const a=r.reduce((i,{useScope:l,scopeName:c})=>{const h=l(s)[`__scope${c}`];return{...i,...h}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function Wn(e){const t=e+"CollectionProvider",[n,r]=Le(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=m=>{const{scope:x,children:p}=m,w=C.useRef(null),y=C.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:y,collectionRef:w,children:p})};a.displayName=t;const i=e+"CollectionSlot",l=rt(i),c=C.forwardRef((m,x)=>{const{scope:p,children:w}=m,y=s(i,p),S=se(x,y.collectionRef);return u.jsx(l,{ref:S,children:w})});c.displayName=i;const f=e+"CollectionItemSlot",h="data-radix-collection-item",v=rt(f),g=C.forwardRef((m,x)=>{const{scope:p,children:w,...y}=m,S=C.useRef(null),R=se(x,S),I=s(f,p);return C.useEffect(()=>(I.itemMap.set(S,{ref:S,...y}),()=>void I.itemMap.delete(S))),u.jsx(v,{[h]:"",ref:R,children:w})});g.displayName=f;function b(m){const x=s(e+"CollectionConsumer",m);return C.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const y=Array.from(w.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((I,N)=>y.indexOf(I.ref.current)-y.indexOf(N.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:a,Slot:c,ItemSlot:g},b,r]}var ml=d.createContext(void 0);function Kn(e){const t=d.useContext(ml);return e||t||"ltr"}var pl=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],oe=pl.reduce((e,t)=>{const n=rt(`Primitive.${t}`),r=d.forwardRef((o,s)=>{const{asChild:a,...i}=o,l=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...i,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Co(e,t){e&&Kt.flushSync(()=>e.dispatchEvent(t))}function Ie(e){const t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function gl(e,t=globalThis==null?void 0:globalThis.document){const n=Ie(e);d.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var vl="DismissableLayer",Cn="dismissableLayer.update",xl="dismissableLayer.pointerDownOutside",wl="dismissableLayer.focusOutside",Tr,So=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Yt=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:i,...l}=e,c=d.useContext(So),[f,h]=d.useState(null),v=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=d.useState({}),b=se(t,N=>h(N)),m=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),p=m.indexOf(x),w=f?m.indexOf(f):-1,y=c.layersWithOutsidePointerEventsDisabled.size>0,S=w>=p,R=Cl(N=>{const A=N.target,V=[...c.branches].some(D=>D.contains(A));!S||V||(o==null||o(N),a==null||a(N),N.defaultPrevented||i==null||i())},v),I=Sl(N=>{const A=N.target;[...c.branches].some(D=>D.contains(A))||(s==null||s(N),a==null||a(N),N.defaultPrevented||i==null||i())},v);return gl(N=>{w===c.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&i&&(N.preventDefault(),i()))},v),d.useEffect(()=>{if(f)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Tr=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(f)),c.layers.add(f),Ar(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=Tr)}},[f,v,n,c]),d.useEffect(()=>()=>{f&&(c.layers.delete(f),c.layersWithOutsidePointerEventsDisabled.delete(f),Ar())},[f,c]),d.useEffect(()=>{const N=()=>g({});return document.addEventListener(Cn,N),()=>document.removeEventListener(Cn,N)},[]),u.jsx(oe.div,{...l,ref:b,style:{pointerEvents:y?S?"auto":"none":void 0,...e.style},onFocusCapture:K(e.onFocusCapture,I.onFocusCapture),onBlurCapture:K(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:K(e.onPointerDownCapture,R.onPointerDownCapture)})});Yt.displayName=vl;var bl="DismissableLayerBranch",yl=d.forwardRef((e,t)=>{const n=d.useContext(So),r=d.useRef(null),o=se(t,r);return d.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(oe.div,{...e,ref:o})});yl.displayName=bl;function Cl(e,t=globalThis==null?void 0:globalThis.document){const n=Ie(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const s=i=>{if(i.target&&!r.current){let l=function(){Ro(xl,n,c,{discrete:!0})};const c={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Sl(e,t=globalThis==null?void 0:globalThis.document){const n=Ie(e),r=d.useRef(!1);return d.useEffect(()=>{const o=s=>{s.target&&!r.current&&Ro(wl,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Ar(){const e=new CustomEvent(Cn);document.dispatchEvent(e)}function Ro(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Co(o,s):o.dispatchEvent(s)}var dn=0;function Io(){d.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??jr()),document.body.insertAdjacentElement("beforeend",e[1]??jr()),dn++,()=>{dn===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),dn--}},[])}function jr(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var un="focusScope.autoFocusOnMount",fn="focusScope.autoFocusOnUnmount",Dr={bubbles:!1,cancelable:!0},Rl="FocusScope",Hn=d.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=e,[i,l]=d.useState(null),c=Ie(o),f=Ie(s),h=d.useRef(null),v=se(t,m=>l(m)),g=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(r){let m=function(y){if(g.paused||!i)return;const S=y.target;i.contains(S)?h.current=S:Ae(h.current,{select:!0})},x=function(y){if(g.paused||!i)return;const S=y.relatedTarget;S!==null&&(i.contains(S)||Ae(h.current,{select:!0}))},p=function(y){if(document.activeElement===document.body)for(const R of y)R.removedNodes.length>0&&Ae(i)};document.addEventListener("focusin",m),document.addEventListener("focusout",x);const w=new MutationObserver(p);return i&&w.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",x),w.disconnect()}}},[r,i,g.paused]),d.useEffect(()=>{if(i){_r.add(g);const m=document.activeElement;if(!i.contains(m)){const p=new CustomEvent(un,Dr);i.addEventListener(un,c),i.dispatchEvent(p),p.defaultPrevented||(Il(Pl(Eo(i)),{select:!0}),document.activeElement===m&&Ae(i))}return()=>{i.removeEventListener(un,c),setTimeout(()=>{const p=new CustomEvent(fn,Dr);i.addEventListener(fn,f),i.dispatchEvent(p),p.defaultPrevented||Ae(m??document.body,{select:!0}),i.removeEventListener(fn,f),_r.remove(g)},0)}}},[i,c,f,g]);const b=d.useCallback(m=>{if(!n&&!r||g.paused)return;const x=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,p=document.activeElement;if(x&&p){const w=m.currentTarget,[y,S]=El(w);y&&S?!m.shiftKey&&p===S?(m.preventDefault(),n&&Ae(y,{select:!0})):m.shiftKey&&p===y&&(m.preventDefault(),n&&Ae(S,{select:!0})):p===w&&m.preventDefault()}},[n,r,g.paused]);return u.jsx(oe.div,{tabIndex:-1,...a,ref:v,onKeyDown:b})});Hn.displayName=Rl;function Il(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ae(r,{select:t}),document.activeElement!==n)return}function El(e){const t=Eo(e),n=Or(t,e),r=Or(t.reverse(),e);return[n,r]}function Eo(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Or(e,t){for(const n of e)if(!Nl(n,{upTo:t}))return n}function Nl(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Ml(e){return e instanceof HTMLInputElement&&"select"in e}function Ae(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ml(e)&&t&&e.select()}}var _r=kl();function kl(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Lr(e,t),e.unshift(t)},remove(t){var n;e=Lr(e,t),(n=e[0])==null||n.resume()}}}function Lr(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Pl(e){return e.filter(t=>t.tagName!=="A")}var ce=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},Tl=d[" useId ".trim().toString()]||(()=>{}),Al=0;function We(e){const[t,n]=d.useState(Tl());return ce(()=>{n(r=>r??String(Al++))},[e]),t?`radix-${t}`:""}const jl=["top","right","bottom","left"],De=Math.min,he=Math.max,Lt=Math.round,Et=Math.floor,Re=e=>({x:e,y:e}),Dl={left:"right",right:"left",bottom:"top",top:"bottom"},Ol={start:"end",end:"start"};function Sn(e,t,n){return he(e,De(t,n))}function Me(e,t){return typeof e=="function"?e(t):e}function ke(e){return e.split("-")[0]}function it(e){return e.split("-")[1]}function Gn(e){return e==="x"?"y":"x"}function Un(e){return e==="y"?"height":"width"}const _l=new Set(["top","bottom"]);function Se(e){return _l.has(ke(e))?"y":"x"}function Yn(e){return Gn(Se(e))}function Ll(e,t,n){n===void 0&&(n=!1);const r=it(e),o=Yn(e),s=Un(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Ft(a)),[a,Ft(a)]}function Fl(e){const t=Ft(e);return[Rn(e),t,Rn(t)]}function Rn(e){return e.replace(/start|end/g,t=>Ol[t])}const Fr=["left","right"],$r=["right","left"],$l=["top","bottom"],zl=["bottom","top"];function Vl(e,t,n){switch(e){case"top":case"bottom":return n?t?$r:Fr:t?Fr:$r;case"left":case"right":return t?$l:zl;default:return[]}}function Bl(e,t,n,r){const o=it(e);let s=Vl(ke(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(Rn)))),s}function Ft(e){return e.replace(/left|right|bottom|top/g,t=>Dl[t])}function Wl(e){return{top:0,right:0,bottom:0,left:0,...e}}function No(e){return typeof e!="number"?Wl(e):{top:e,right:e,bottom:e,left:e}}function $t(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function zr(e,t,n){let{reference:r,floating:o}=e;const s=Se(t),a=Yn(t),i=Un(a),l=ke(t),c=s==="y",f=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,v=r[i]/2-o[i]/2;let g;switch(l){case"top":g={x:f,y:r.y-o.height};break;case"bottom":g={x:f,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:h};break;case"left":g={x:r.x-o.width,y:h};break;default:g={x:r.x,y:r.y}}switch(it(t)){case"start":g[a]-=v*(n&&c?-1:1);break;case"end":g[a]+=v*(n&&c?-1:1);break}return g}const Kl=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,i=s.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:h}=zr(c,r,l),v=r,g={},b=0;for(let m=0;m<i.length;m++){const{name:x,fn:p}=i[m],{x:w,y,data:S,reset:R}=await p({x:f,y:h,initialPlacement:r,placement:v,strategy:o,middlewareData:g,rects:c,platform:a,elements:{reference:e,floating:t}});f=w??f,h=y??h,g={...g,[x]:{...g[x],...S}},R&&b<=50&&(b++,typeof R=="object"&&(R.placement&&(v=R.placement),R.rects&&(c=R.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):R.rects),{x:f,y:h}=zr(c,v,l)),m=-1)}return{x:f,y:h,placement:v,strategy:o,middlewareData:g}};async function gt(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:a,elements:i,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:v=!1,padding:g=0}=Me(t,e),b=No(g),x=i[v?h==="floating"?"reference":"floating":h],p=$t(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(i.floating)),boundary:c,rootBoundary:f,strategy:l})),w=h==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(i.floating)),S=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},R=$t(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:w,offsetParent:y,strategy:l}):w);return{top:(p.top-R.top+b.top)/S.y,bottom:(R.bottom-p.bottom+b.bottom)/S.y,left:(p.left-R.left+b.left)/S.x,right:(R.right-p.right+b.right)/S.x}}const Hl=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:a,elements:i,middlewareData:l}=t,{element:c,padding:f=0}=Me(e,t)||{};if(c==null)return{};const h=No(f),v={x:n,y:r},g=Yn(o),b=Un(g),m=await a.getDimensions(c),x=g==="y",p=x?"top":"left",w=x?"bottom":"right",y=x?"clientHeight":"clientWidth",S=s.reference[b]+s.reference[g]-v[g]-s.floating[b],R=v[g]-s.reference[g],I=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c));let N=I?I[y]:0;(!N||!await(a.isElement==null?void 0:a.isElement(I)))&&(N=i.floating[y]||s.floating[b]);const A=S/2-R/2,V=N/2-m[b]/2-1,D=De(h[p],V),P=De(h[w],V),O=D,F=N-m[b]-P,T=N/2-m[b]/2+A,W=Sn(O,T,F),_=!l.arrow&&it(o)!=null&&T!==W&&s.reference[b]/2-(T<O?D:P)-m[b]/2<0,G=_?T<O?T-O:T-F:0;return{[g]:v[g]+G,data:{[g]:W,centerOffset:T-W-G,..._&&{alignmentOffset:G}},reset:_}}}),Gl=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:a,initialPlacement:i,platform:l,elements:c}=t,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:v,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:m=!0,...x}=Me(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const p=ke(o),w=Se(i),y=ke(i)===i,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),R=v||(y||!m?[Ft(i)]:Fl(i)),I=b!=="none";!v&&I&&R.push(...Bl(i,m,b,S));const N=[i,...R],A=await gt(t,x),V=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&V.push(A[p]),h){const T=Ll(o,a,S);V.push(A[T[0]],A[T[1]])}if(D=[...D,{placement:o,overflows:V}],!V.every(T=>T<=0)){var P,O;const T=(((P=s.flip)==null?void 0:P.index)||0)+1,W=N[T];if(W&&(!(h==="alignment"?w!==Se(W):!1)||D.every(z=>z.overflows[0]>0&&Se(z.placement)===w)))return{data:{index:T,overflows:D},reset:{placement:W}};let _=(O=D.filter(G=>G.overflows[0]<=0).sort((G,z)=>G.overflows[1]-z.overflows[1])[0])==null?void 0:O.placement;if(!_)switch(g){case"bestFit":{var F;const G=(F=D.filter(z=>{if(I){const k=Se(z.placement);return k===w||k==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(k=>k>0).reduce((k,Z)=>k+Z,0)]).sort((z,k)=>z[1]-k[1])[0])==null?void 0:F[0];G&&(_=G);break}case"initialPlacement":_=i;break}if(o!==_)return{reset:{placement:_}}}return{}}}};function Vr(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Br(e){return jl.some(t=>e[t]>=0)}const Ul=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Me(e,t);switch(r){case"referenceHidden":{const s=await gt(t,{...o,elementContext:"reference"}),a=Vr(s,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Br(a)}}}case"escaped":{const s=await gt(t,{...o,altBoundary:!0}),a=Vr(s,n.floating);return{data:{escapedOffsets:a,escaped:Br(a)}}}default:return{}}}}},Mo=new Set(["left","top"]);async function Yl(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=ke(n),i=it(n),l=Se(n)==="y",c=Mo.has(a)?-1:1,f=s&&l?-1:1,h=Me(t,e);let{mainAxis:v,crossAxis:g,alignmentAxis:b}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return i&&typeof b=="number"&&(g=i==="end"?b*-1:b),l?{x:g*f,y:v*c}:{x:v*c,y:g*f}}const Xl=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:a,middlewareData:i}=t,l=await Yl(t,e);return a===((n=i.offset)==null?void 0:n.placement)&&(r=i.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:a}}}}},ql=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:i={fn:x=>{let{x:p,y:w}=x;return{x:p,y:w}}},...l}=Me(e,t),c={x:n,y:r},f=await gt(t,l),h=Se(ke(o)),v=Gn(h);let g=c[v],b=c[h];if(s){const x=v==="y"?"top":"left",p=v==="y"?"bottom":"right",w=g+f[x],y=g-f[p];g=Sn(w,g,y)}if(a){const x=h==="y"?"top":"left",p=h==="y"?"bottom":"right",w=b+f[x],y=b-f[p];b=Sn(w,b,y)}const m=i.fn({...t,[v]:g,[h]:b});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[v]:s,[h]:a}}}}}},Zl=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:a}=t,{offset:i=0,mainAxis:l=!0,crossAxis:c=!0}=Me(e,t),f={x:n,y:r},h=Se(o),v=Gn(h);let g=f[v],b=f[h];const m=Me(i,t),x=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const y=v==="y"?"height":"width",S=s.reference[v]-s.floating[y]+x.mainAxis,R=s.reference[v]+s.reference[y]-x.mainAxis;g<S?g=S:g>R&&(g=R)}if(c){var p,w;const y=v==="y"?"width":"height",S=Mo.has(ke(o)),R=s.reference[h]-s.floating[y]+(S&&((p=a.offset)==null?void 0:p[h])||0)+(S?0:x.crossAxis),I=s.reference[h]+s.reference[y]+(S?0:((w=a.offset)==null?void 0:w[h])||0)-(S?x.crossAxis:0);b<R?b=R:b>I&&(b=I)}return{[v]:g,[h]:b}}}},Jl=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:a,elements:i}=t,{apply:l=()=>{},...c}=Me(e,t),f=await gt(t,c),h=ke(o),v=it(o),g=Se(o)==="y",{width:b,height:m}=s.floating;let x,p;h==="top"||h==="bottom"?(x=h,p=v===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(p=h,x=v==="end"?"top":"bottom");const w=m-f.top-f.bottom,y=b-f.left-f.right,S=De(m-f[x],w),R=De(b-f[p],y),I=!t.middlewareData.shift;let N=S,A=R;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(N=w),I&&!v){const D=he(f.left,0),P=he(f.right,0),O=he(f.top,0),F=he(f.bottom,0);g?A=b-2*(D!==0||P!==0?D+P:he(f.left,f.right)):N=m-2*(O!==0||F!==0?O+F:he(f.top,f.bottom))}await l({...t,availableWidth:A,availableHeight:N});const V=await a.getDimensions(i.floating);return b!==V.width||m!==V.height?{reset:{rects:!0}}:{}}}};function Xt(){return typeof window<"u"}function lt(e){return ko(e)?(e.nodeName||"").toLowerCase():"#document"}function me(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ne(e){var t;return(t=(ko(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ko(e){return Xt()?e instanceof Node||e instanceof me(e).Node:!1}function be(e){return Xt()?e instanceof Element||e instanceof me(e).Element:!1}function Ee(e){return Xt()?e instanceof HTMLElement||e instanceof me(e).HTMLElement:!1}function Wr(e){return!Xt()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof me(e).ShadowRoot}const Ql=new Set(["inline","contents"]);function Ct(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ye(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Ql.has(o)}const ec=new Set(["table","td","th"]);function tc(e){return ec.has(lt(e))}const nc=[":popover-open",":modal"];function qt(e){return nc.some(t=>{try{return e.matches(t)}catch{return!1}})}const rc=["transform","translate","scale","rotate","perspective"],oc=["transform","translate","scale","rotate","perspective","filter"],sc=["paint","layout","strict","content"];function Xn(e){const t=qn(),n=be(e)?ye(e):e;return rc.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||oc.some(r=>(n.willChange||"").includes(r))||sc.some(r=>(n.contain||"").includes(r))}function ac(e){let t=Oe(e);for(;Ee(t)&&!ot(t);){if(Xn(t))return t;if(qt(t))return null;t=Oe(t)}return null}function qn(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ic=new Set(["html","body","#document"]);function ot(e){return ic.has(lt(e))}function ye(e){return me(e).getComputedStyle(e)}function Zt(e){return be(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Oe(e){if(lt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Wr(e)&&e.host||Ne(e);return Wr(t)?t.host:t}function Po(e){const t=Oe(e);return ot(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ee(t)&&Ct(t)?t:Po(t)}function vt(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Po(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),a=me(o);if(s){const i=In(a);return t.concat(a,a.visualViewport||[],Ct(o)?o:[],i&&n?vt(i):[])}return t.concat(o,vt(o,[],n))}function In(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function To(e){const t=ye(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ee(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,i=Lt(n)!==s||Lt(r)!==a;return i&&(n=s,r=a),{width:n,height:r,$:i}}function Zn(e){return be(e)?e:e.contextElement}function tt(e){const t=Zn(e);if(!Ee(t))return Re(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=To(t);let a=(s?Lt(n.width):n.width)/r,i=(s?Lt(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const lc=Re(0);function Ao(e){const t=me(e);return!qn()||!t.visualViewport?lc:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function cc(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==me(e)?!1:t}function Ke(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Zn(e);let a=Re(1);t&&(r?be(r)&&(a=tt(r)):a=tt(e));const i=cc(s,n,r)?Ao(s):Re(0);let l=(o.left+i.x)/a.x,c=(o.top+i.y)/a.y,f=o.width/a.x,h=o.height/a.y;if(s){const v=me(s),g=r&&be(r)?me(r):r;let b=v,m=In(b);for(;m&&r&&g!==b;){const x=tt(m),p=m.getBoundingClientRect(),w=ye(m),y=p.left+(m.clientLeft+parseFloat(w.paddingLeft))*x.x,S=p.top+(m.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,f*=x.x,h*=x.y,l+=y,c+=S,b=me(m),m=In(b)}}return $t({width:f,height:h,x:l,y:c})}function Jn(e,t){const n=Zt(e).scrollLeft;return t?t.left+n:Ke(Ne(e)).left+n}function jo(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:Jn(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function dc(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=Ne(r),i=t?qt(t.floating):!1;if(r===a||i&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Re(1);const f=Re(0),h=Ee(r);if((h||!h&&!s)&&((lt(r)!=="body"||Ct(a))&&(l=Zt(r)),Ee(r))){const g=Ke(r);c=tt(r),f.x=g.x+r.clientLeft,f.y=g.y+r.clientTop}const v=a&&!h&&!s?jo(a,l,!0):Re(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+f.x+v.x,y:n.y*c.y-l.scrollTop*c.y+f.y+v.y}}function uc(e){return Array.from(e.getClientRects())}function fc(e){const t=Ne(e),n=Zt(e),r=e.ownerDocument.body,o=he(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=he(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Jn(e);const i=-n.scrollTop;return ye(r).direction==="rtl"&&(a+=he(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:i}}function hc(e,t){const n=me(e),r=Ne(e),o=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,i=0,l=0;if(o){s=o.width,a=o.height;const c=qn();(!c||c&&t==="fixed")&&(i=o.offsetLeft,l=o.offsetTop)}return{width:s,height:a,x:i,y:l}}const mc=new Set(["absolute","fixed"]);function pc(e,t){const n=Ke(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Ee(e)?tt(e):Re(1),a=e.clientWidth*s.x,i=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:a,height:i,x:l,y:c}}function Kr(e,t,n){let r;if(t==="viewport")r=hc(e,n);else if(t==="document")r=fc(Ne(e));else if(be(t))r=pc(t,n);else{const o=Ao(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return $t(r)}function Do(e,t){const n=Oe(e);return n===t||!be(n)||ot(n)?!1:ye(n).position==="fixed"||Do(n,t)}function gc(e,t){const n=t.get(e);if(n)return n;let r=vt(e,[],!1).filter(i=>be(i)&<(i)!=="body"),o=null;const s=ye(e).position==="fixed";let a=s?Oe(e):e;for(;be(a)&&!ot(a);){const i=ye(a),l=Xn(a);!l&&i.position==="fixed"&&(o=null),(s?!l&&!o:!l&&i.position==="static"&&!!o&&mc.has(o.position)||Ct(a)&&!l&&Do(e,a))?r=r.filter(f=>f!==a):o=i,a=Oe(a)}return t.set(e,r),r}function vc(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?qt(t)?[]:gc(t,this._c):[].concat(n),r],i=a[0],l=a.reduce((c,f)=>{const h=Kr(t,f,o);return c.top=he(h.top,c.top),c.right=De(h.right,c.right),c.bottom=De(h.bottom,c.bottom),c.left=he(h.left,c.left),c},Kr(t,i,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function xc(e){const{width:t,height:n}=To(e);return{width:t,height:n}}function wc(e,t,n){const r=Ee(t),o=Ne(t),s=n==="fixed",a=Ke(e,!0,s,t);let i={scrollLeft:0,scrollTop:0};const l=Re(0);function c(){l.x=Jn(o)}if(r||!r&&!s)if((lt(t)!=="body"||Ct(o))&&(i=Zt(t)),r){const g=Ke(t,!0,s,t);l.x=g.x+t.clientLeft,l.y=g.y+t.clientTop}else o&&c();s&&!r&&o&&c();const f=o&&!r&&!s?jo(o,i):Re(0),h=a.left+i.scrollLeft-l.x-f.x,v=a.top+i.scrollTop-l.y-f.y;return{x:h,y:v,width:a.width,height:a.height}}function hn(e){return ye(e).position==="static"}function Hr(e,t){if(!Ee(e)||ye(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ne(e)===n&&(n=n.ownerDocument.body),n}function Oo(e,t){const n=me(e);if(qt(e))return n;if(!Ee(e)){let o=Oe(e);for(;o&&!ot(o);){if(be(o)&&!hn(o))return o;o=Oe(o)}return n}let r=Hr(e,t);for(;r&&tc(r)&&hn(r);)r=Hr(r,t);return r&&ot(r)&&hn(r)&&!Xn(r)?n:r||ac(e)||n}const bc=async function(e){const t=this.getOffsetParent||Oo,n=this.getDimensions,r=await n(e.floating);return{reference:wc(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yc(e){return ye(e).direction==="rtl"}const Cc={convertOffsetParentRelativeRectToViewportRelativeRect:dc,getDocumentElement:Ne,getClippingRect:vc,getOffsetParent:Oo,getElementRects:bc,getClientRects:uc,getDimensions:xc,getScale:tt,isElement:be,isRTL:yc};function _o(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Sc(e,t){let n=null,r;const o=Ne(e);function s(){var i;clearTimeout(r),(i=n)==null||i.disconnect(),n=null}function a(i,l){i===void 0&&(i=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:f,top:h,width:v,height:g}=c;if(i||t(),!v||!g)return;const b=Et(h),m=Et(o.clientWidth-(f+v)),x=Et(o.clientHeight-(h+g)),p=Et(f),y={rootMargin:-b+"px "+-m+"px "+-x+"px "+-p+"px",threshold:he(0,De(1,l))||1};let S=!0;function R(I){const N=I[0].intersectionRatio;if(N!==l){if(!S)return a();N?a(!1,N):r=setTimeout(()=>{a(!1,1e-7)},1e3)}N===1&&!_o(c,e.getBoundingClientRect())&&a(),S=!1}try{n=new IntersectionObserver(R,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(R,y)}n.observe(e)}return a(!0),s}function Rc(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Zn(e),f=o||s?[...c?vt(c):[],...vt(t)]:[];f.forEach(p=>{o&&p.addEventListener("scroll",n,{passive:!0}),s&&p.addEventListener("resize",n)});const h=c&&i?Sc(c,n):null;let v=-1,g=null;a&&(g=new ResizeObserver(p=>{let[w]=p;w&&w.target===c&&g&&(g.unobserve(t),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var y;(y=g)==null||y.observe(t)})),n()}),c&&!l&&g.observe(c),g.observe(t));let b,m=l?Ke(e):null;l&&x();function x(){const p=Ke(e);m&&!_o(m,p)&&n(),m=p,b=requestAnimationFrame(x)}return n(),()=>{var p;f.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),h==null||h(),(p=g)==null||p.disconnect(),g=null,l&&cancelAnimationFrame(b)}}const Ic=Xl,Ec=ql,Nc=Gl,Mc=Jl,kc=Ul,Gr=Hl,Pc=Zl,Tc=(e,t,n)=>{const r=new Map,o={platform:Cc,...n},s={...o.platform,_c:r};return Kl(e,t,{...o,platform:s})};var Ac=typeof document<"u",jc=function(){},jt=Ac?C.useLayoutEffect:jc;function zt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!zt(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!zt(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Lo(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ur(e,t){const n=Lo(e);return Math.round(t*n)/n}function mn(e){const t=d.useRef(e);return jt(()=>{t.current=e}),t}function Dc(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:a}={},transform:i=!0,whileElementsMounted:l,open:c}=e,[f,h]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[v,g]=d.useState(r);zt(v,r)||g(r);const[b,m]=d.useState(null),[x,p]=d.useState(null),w=d.useCallback(z=>{z!==I.current&&(I.current=z,m(z))},[]),y=d.useCallback(z=>{z!==N.current&&(N.current=z,p(z))},[]),S=s||b,R=a||x,I=d.useRef(null),N=d.useRef(null),A=d.useRef(f),V=l!=null,D=mn(l),P=mn(o),O=mn(c),F=d.useCallback(()=>{if(!I.current||!N.current)return;const z={placement:t,strategy:n,middleware:v};P.current&&(z.platform=P.current),Tc(I.current,N.current,z).then(k=>{const Z={...k,isPositioned:O.current!==!1};T.current&&!zt(A.current,Z)&&(A.current=Z,Kt.flushSync(()=>{h(Z)}))})},[v,t,n,P,O]);jt(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,h(z=>({...z,isPositioned:!1})))},[c]);const T=d.useRef(!1);jt(()=>(T.current=!0,()=>{T.current=!1}),[]),jt(()=>{if(S&&(I.current=S),R&&(N.current=R),S&&R){if(D.current)return D.current(S,R,F);F()}},[S,R,F,D,V]);const W=d.useMemo(()=>({reference:I,floating:N,setReference:w,setFloating:y}),[w,y]),_=d.useMemo(()=>({reference:S,floating:R}),[S,R]),G=d.useMemo(()=>{const z={position:n,left:0,top:0};if(!_.floating)return z;const k=Ur(_.floating,f.x),Z=Ur(_.floating,f.y);return i?{...z,transform:"translate("+k+"px, "+Z+"px)",...Lo(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:k,top:Z}},[n,i,_.floating,f.x,f.y]);return d.useMemo(()=>({...f,update:F,refs:W,elements:_,floatingStyles:G}),[f,F,W,_,G])}const Oc=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Gr({element:r.current,padding:o}).fn(n):{}:r?Gr({element:r,padding:o}).fn(n):{}}}},_c=(e,t)=>({...Ic(e),options:[e,t]}),Lc=(e,t)=>({...Ec(e),options:[e,t]}),Fc=(e,t)=>({...Pc(e),options:[e,t]}),$c=(e,t)=>({...Nc(e),options:[e,t]}),zc=(e,t)=>({...Mc(e),options:[e,t]}),Vc=(e,t)=>({...kc(e),options:[e,t]}),Bc=(e,t)=>({...Oc(e),options:[e,t]});var Wc="Arrow",Fo=d.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(oe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Fo.displayName=Wc;var Kc=Fo;function $o(e){const[t,n]=d.useState(void 0);return ce(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let a,i;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;a=c.inlineSize,i=c.blockSize}else a=e.offsetWidth,i=e.offsetHeight;n({width:a,height:i})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Qn="Popper",[zo,ct]=Le(Qn),[Hc,Vo]=zo(Qn),Bo=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return u.jsx(Hc,{scope:t,anchor:r,onAnchorChange:o,children:n})};Bo.displayName=Qn;var Wo="PopperAnchor",Ko=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Vo(Wo,n),a=d.useRef(null),i=se(t,a);return d.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||a.current)}),r?null:u.jsx(oe.div,{...o,ref:i})});Ko.displayName=Wo;var er="PopperContent",[Gc,Uc]=zo(er),Ho=d.forwardRef((e,t)=>{var E,J,te,X,M,$;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:i=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:v=!1,updatePositionStrategy:g="optimized",onPlaced:b,...m}=e,x=Vo(er,n),[p,w]=d.useState(null),y=se(t,Q=>w(Q)),[S,R]=d.useState(null),I=$o(S),N=(I==null?void 0:I.width)??0,A=(I==null?void 0:I.height)??0,V=r+(s!=="center"?"-"+s:""),D=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},P=Array.isArray(c)?c:[c],O=P.length>0,F={padding:D,boundary:P.filter(Xc),altBoundary:O},{refs:T,floatingStyles:W,placement:_,isPositioned:G,middlewareData:z}=Dc({strategy:"fixed",placement:V,whileElementsMounted:(...Q)=>Rc(...Q,{animationFrame:g==="always"}),elements:{reference:x.anchor},middleware:[_c({mainAxis:o+A,alignmentAxis:a}),l&&Lc({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Fc():void 0,...F}),l&&$c({...F}),zc({...F,apply:({elements:Q,rects:ne,availableWidth:re,availableHeight:ie})=>{const{width:le,height:ue}=ne.reference,ve=Q.floating.style;ve.setProperty("--radix-popper-available-width",`${re}px`),ve.setProperty("--radix-popper-available-height",`${ie}px`),ve.setProperty("--radix-popper-anchor-width",`${le}px`),ve.setProperty("--radix-popper-anchor-height",`${ue}px`)}}),S&&Bc({element:S,padding:i}),qc({arrowWidth:N,arrowHeight:A}),v&&Vc({strategy:"referenceHidden",...F})]}),[k,Z]=Yo(_),j=Ie(b);ce(()=>{G&&(j==null||j())},[G,j]);const H=(E=z.arrow)==null?void 0:E.x,L=(J=z.arrow)==null?void 0:J.y,B=((te=z.arrow)==null?void 0:te.centerOffset)!==0,[U,ee]=d.useState();return ce(()=>{p&&ee(window.getComputedStyle(p).zIndex)},[p]),u.jsx("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:G?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:U,"--radix-popper-transform-origin":[(X=z.transformOrigin)==null?void 0:X.x,(M=z.transformOrigin)==null?void 0:M.y].join(" "),...(($=z.hide)==null?void 0:$.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(Gc,{scope:n,placedSide:k,onArrowChange:R,arrowX:H,arrowY:L,shouldHideArrow:B,children:u.jsx(oe.div,{"data-side":k,"data-align":Z,...m,ref:y,style:{...m.style,animation:G?void 0:"none"}})})})});Ho.displayName=er;var Go="PopperArrow",Yc={top:"bottom",right:"left",bottom:"top",left:"right"},Uo=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Uc(Go,r),a=Yc[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(Kc,{...o,ref:n,style:{...o.style,display:"block"}})})});Uo.displayName=Go;function Xc(e){return e!==null}var qc=e=>({name:"transformOrigin",options:e,fn(t){var x,p,w;const{placement:n,rects:r,middlewareData:o}=t,a=((x=o.arrow)==null?void 0:x.centerOffset)!==0,i=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[c,f]=Yo(n),h={start:"0%",center:"50%",end:"100%"}[f],v=(((p=o.arrow)==null?void 0:p.x)??0)+i/2,g=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let b="",m="";return c==="bottom"?(b=a?h:`${v}px`,m=`${-l}px`):c==="top"?(b=a?h:`${v}px`,m=`${r.floating.height+l}px`):c==="right"?(b=`${-l}px`,m=a?h:`${g}px`):c==="left"&&(b=`${r.floating.width+l}px`,m=a?h:`${g}px`),{data:{x:b,y:m}}}});function Yo(e){const[t,n="center"]=e.split("-");return[t,n]}var tr=Bo,nr=Ko,rr=Ho,or=Uo,Zc="Portal",sr=d.forwardRef((e,t)=>{var i;const{container:n,...r}=e,[o,s]=d.useState(!1);ce(()=>s(!0),[]);const a=n||o&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return a?zn.createPortal(u.jsx(oe.div,{...r,ref:t}),a):null});sr.displayName=Zc;var Jc=d[" useInsertionEffect ".trim().toString()]||ce;function st({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,a]=Qc({defaultProp:t,onChange:n}),i=e!==void 0,l=i?e:o;{const f=d.useRef(e!==void 0);d.useEffect(()=>{const h=f.current;h!==i&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=i},[i,r])}const c=d.useCallback(f=>{var h;if(i){const v=ed(f)?f(e):f;v!==e&&((h=a.current)==null||h.call(a,v))}else s(f)},[i,e,s,a]);return[l,c]}function Qc({defaultProp:e,onChange:t}){const[n,r]=d.useState(e),o=d.useRef(n),s=d.useRef(t);return Jc(()=>{s.current=t},[t]),d.useEffect(()=>{var a;o.current!==n&&((a=s.current)==null||a.call(s,n),o.current=n)},[n,o]),[n,r,s]}function ed(e){return typeof e=="function"}function Xo(e){const t=d.useRef({value:e,previous:e});return d.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var qo=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),td="VisuallyHidden",Zo=d.forwardRef((e,t)=>u.jsx(oe.span,{...e,ref:t,style:{...qo,...e.style}}));Zo.displayName=td;var nd=Zo,rd=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Je=new WeakMap,Nt=new WeakMap,Mt={},pn=0,Jo=function(e){return e&&(e.host||Jo(e.parentNode))},od=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Jo(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},sd=function(e,t,n,r){var o=od(t,Array.isArray(e)?e:[e]);Mt[n]||(Mt[n]=new WeakMap);var s=Mt[n],a=[],i=new Set,l=new Set(o),c=function(h){!h||i.has(h)||(i.add(h),c(h.parentNode))};o.forEach(c);var f=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(v){if(i.has(v))f(v);else try{var g=v.getAttribute(r),b=g!==null&&g!=="false",m=(Je.get(v)||0)+1,x=(s.get(v)||0)+1;Je.set(v,m),s.set(v,x),a.push(v),m===1&&b&&Nt.set(v,!0),x===1&&v.setAttribute(n,"true"),b||v.setAttribute(r,"true")}catch(p){console.error("aria-hidden: cannot operate on ",v,p)}})};return f(t),i.clear(),pn++,function(){a.forEach(function(h){var v=Je.get(h)-1,g=s.get(h)-1;Je.set(h,v),s.set(h,g),v||(Nt.has(h)||h.removeAttribute(r),Nt.delete(h)),g||h.removeAttribute(n)}),pn--,pn||(Je=new WeakMap,Je=new WeakMap,Nt=new WeakMap,Mt={})}},Qo=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=rd(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),sd(r,o,n,"aria-hidden")):function(){return null}},Ce=function(){return Ce=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Ce.apply(this,arguments)};function es(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function ad(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var Dt="right-scroll-bar-position",Ot="width-before-scroll-bar",id="with-scroll-bars-hidden",ld="--removed-body-scroll-bar-size";function gn(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function cd(e,t){var n=C.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var dd=typeof window<"u"?d.useLayoutEffect:d.useEffect,Yr=new WeakMap;function ud(e,t){var n=cd(null,function(r){return e.forEach(function(o){return gn(o,r)})});return dd(function(){var r=Yr.get(n);if(r){var o=new Set(r),s=new Set(e),a=n.current;o.forEach(function(i){s.has(i)||gn(i,null)}),s.forEach(function(i){o.has(i)||gn(i,a)})}Yr.set(n,e)},[e]),n}function fd(e){return e}function hd(e,t){t===void 0&&(t=fd);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var a=t(s,r);return n.push(a),function(){n=n.filter(function(i){return i!==a})}},assignSyncMedium:function(s){for(r=!0;n.length;){var a=n;n=[],a.forEach(s)}n={push:function(i){return s(i)},filter:function(){return n}}},assignMedium:function(s){r=!0;var a=[];if(n.length){var i=n;n=[],i.forEach(s),a=n}var l=function(){var f=a;a=[],f.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(f){a.push(f),c()},filter:function(f){return a=a.filter(f),n}}}};return o}function md(e){e===void 0&&(e={});var t=hd(null);return t.options=Ce({async:!0,ssr:!1},e),t}var ts=function(e){var t=e.sideCar,n=es(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return d.createElement(r,Ce({},n))};ts.isSideCarExport=!0;function pd(e,t){return e.useMedium(t),ts}var ns=md(),vn=function(){},Jt=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:vn,onWheelCapture:vn,onTouchMoveCapture:vn}),o=r[0],s=r[1],a=e.forwardProps,i=e.children,l=e.className,c=e.removeScrollBar,f=e.enabled,h=e.shards,v=e.sideCar,g=e.noRelative,b=e.noIsolation,m=e.inert,x=e.allowPinchZoom,p=e.as,w=p===void 0?"div":p,y=e.gapMode,S=es(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),R=v,I=ud([n,t]),N=Ce(Ce({},S),o);return d.createElement(d.Fragment,null,f&&d.createElement(R,{sideCar:ns,removeScrollBar:c,shards:h,noRelative:g,noIsolation:b,inert:m,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:y}),a?d.cloneElement(d.Children.only(i),Ce(Ce({},N),{ref:I})):d.createElement(w,Ce({},N,{className:l,ref:I}),i))});Jt.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Jt.classNames={fullWidth:Ot,zeroRight:Dt};var gd=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function vd(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=gd();return t&&e.setAttribute("nonce",t),e}function xd(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function wd(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var bd=function(){var e=0,t=null;return{add:function(n){e==0&&(t=vd())&&(xd(t,n),wd(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},yd=function(){var e=bd();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},rs=function(){var e=yd(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Cd={left:0,top:0,right:0,gap:0},xn=function(e){return parseInt(e||"",10)||0},Sd=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[xn(n),xn(r),xn(o)]},Rd=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Cd;var t=Sd(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Id=rs(),nt="data-scroll-locked",Ed=function(e,t,n,r){var o=e.left,s=e.top,a=e.right,i=e.gap;return n===void 0&&(n="margin"),`
.`.concat(id,` {
overflow: hidden `).concat(r,`;
padding-right: `).concat(i,"px ").concat(r,`;
}
body[`).concat(nt,`] {
overflow: hidden `).concat(r,`;
overscroll-behavior: contain;
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
padding-left: `.concat(o,`px;
padding-top: `).concat(s,`px;
padding-right: `).concat(a,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(i,"px ").concat(r,`;
`),n==="padding"&&"padding-right: ".concat(i,"px ").concat(r,";")].filter(Boolean).join(""),`
}
.`).concat(Dt,` {
right: `).concat(i,"px ").concat(r,`;
}
.`).concat(Ot,` {
margin-right: `).concat(i,"px ").concat(r,`;
}
.`).concat(Dt," .").concat(Dt,` {
right: 0 `).concat(r,`;
}
.`).concat(Ot," .").concat(Ot,` {
margin-right: 0 `).concat(r,`;
}
body[`).concat(nt,`] {
`).concat(ld,": ").concat(i,`px;
}
`)},Xr=function(){var e=parseInt(document.body.getAttribute(nt)||"0",10);return isFinite(e)?e:0},Nd=function(){d.useEffect(function(){return document.body.setAttribute(nt,(Xr()+1).toString()),function(){var e=Xr()-1;e<=0?document.body.removeAttribute(nt):document.body.setAttribute(nt,e.toString())}},[])},Md=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Nd();var s=d.useMemo(function(){return Rd(o)},[o]);return d.createElement(Id,{styles:Ed(s,!t,o,n?"":"!important")})},En=!1;if(typeof window<"u")try{var kt=Object.defineProperty({},"passive",{get:function(){return En=!0,!0}});window.addEventListener("test",kt,kt),window.removeEventListener("test",kt,kt)}catch{En=!1}var Qe=En?{passive:!1}:!1,kd=function(e){return e.tagName==="TEXTAREA"},os=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!kd(e)&&n[t]==="visible")},Pd=function(e){return os(e,"overflowY")},Td=function(e){return os(e,"overflowX")},qr=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=ss(e,r);if(o){var s=as(e,r),a=s[1],i=s[2];if(a>i)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ad=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},jd=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},ss=function(e,t){return e==="v"?Pd(t):Td(t)},as=function(e,t){return e==="v"?Ad(t):jd(t)},Dd=function(e,t){return e==="h"&&t==="rtl"?-1:1},Od=function(e,t,n,r,o){var s=Dd(e,window.getComputedStyle(t).direction),a=s*r,i=n.target,l=t.contains(i),c=!1,f=a>0,h=0,v=0;do{if(!i)break;var g=as(e,i),b=g[0],m=g[1],x=g[2],p=m-x-s*b;(b||p)&&ss(e,i)&&(h+=p,v+=b);var w=i.parentNode;i=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&i!==document.body||l&&(t.contains(i)||t===i));return(f&&Math.abs(h)<1||!f&&Math.abs(v)<1)&&(c=!0),c},Pt=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Zr=function(e){return[e.deltaX,e.deltaY]},Jr=function(e){return e&&"current"in e?e.current:e},_d=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ld=function(e){return`
.block-interactivity-`.concat(e,` {pointer-events: none;}
.allow-interactivity-`).concat(e,` {pointer-events: all;}
`)},Fd=0,et=[];function $d(e){var t=d.useRef([]),n=d.useRef([0,0]),r=d.useRef(),o=d.useState(Fd++)[0],s=d.useState(rs)[0],a=d.useRef(e);d.useEffect(function(){a.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var m=ad([e.lockRef.current],(e.shards||[]).map(Jr),!0).filter(Boolean);return m.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var i=d.useCallback(function(m,x){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!a.current.allowPinchZoom;var p=Pt(m),w=n.current,y="deltaX"in m?m.deltaX:w[0]-p[0],S="deltaY"in m?m.deltaY:w[1]-p[1],R,I=m.target,N=Math.abs(y)>Math.abs(S)?"h":"v";if("touches"in m&&N==="h"&&I.type==="range")return!1;var A=qr(N,I);if(!A)return!0;if(A?R=N:(R=N==="v"?"h":"v",A=qr(N,I)),!A)return!1;if(!r.current&&"changedTouches"in m&&(y||S)&&(r.current=R),!R)return!0;var V=r.current||R;return Od(V,x,m,V==="h"?y:S)},[]),l=d.useCallback(function(m){var x=m;if(!(!et.length||et[et.length-1]!==s)){var p="deltaY"in x?Zr(x):Pt(x),w=t.current.filter(function(R){return R.name===x.type&&(R.target===x.target||x.target===R.shadowParent)&&_d(R.delta,p)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var y=(a.current.shards||[]).map(Jr).filter(Boolean).filter(function(R){return R.contains(x.target)}),S=y.length>0?i(x,y[0]):!a.current.noIsolation;S&&x.cancelable&&x.preventDefault()}}},[]),c=d.useCallback(function(m,x,p,w){var y={name:m,delta:x,target:p,should:w,shadowParent:zd(p)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(S){return S!==y})},1)},[]),f=d.useCallback(function(m){n.current=Pt(m),r.current=void 0},[]),h=d.useCallback(function(m){c(m.type,Zr(m),m.target,i(m,e.lockRef.current))},[]),v=d.useCallback(function(m){c(m.type,Pt(m),m.target,i(m,e.lockRef.current))},[]);d.useEffect(function(){return et.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:v}),document.addEventListener("wheel",l,Qe),document.addEventListener("touchmove",l,Qe),document.addEventListener("touchstart",f,Qe),function(){et=et.filter(function(m){return m!==s}),document.removeEventListener("wheel",l,Qe),document.removeEventListener("touchmove",l,Qe),document.removeEventListener("touchstart",f,Qe)}},[]);var g=e.removeScrollBar,b=e.inert;return d.createElement(d.Fragment,null,b?d.createElement(s,{styles:Ld(o)}):null,g?d.createElement(Md,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function zd(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Vd=pd(ns,$d);var ar=d.forwardRef(function(e,t){return d.createElement(Jt,Ce({},e,{ref:t,sideCar:Vd}))});ar.classNames=Jt.classNames;var Bd=[" ","Enter","ArrowUp","ArrowDown"],Wd=[" ","Enter"],He="Select",[Qt,en,Kd]=Wn(He),[dt,Zh]=Le(He,[Kd,ct]),tn=ct(),[Hd,Fe]=dt(He),[Gd,Ud]=dt(He),is=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:a,defaultValue:i,onValueChange:l,dir:c,name:f,autoComplete:h,disabled:v,required:g,form:b}=e,m=tn(t),[x,p]=d.useState(null),[w,y]=d.useState(null),[S,R]=d.useState(!1),I=Kn(c),[N,A]=st({prop:r,defaultProp:o??!1,onChange:s,caller:He}),[V,D]=st({prop:a,defaultProp:i,onChange:l,caller:He}),P=d.useRef(null),O=x?b||!!x.closest("form"):!0,[F,T]=d.useState(new Set),W=Array.from(F).map(_=>_.props.value).join(";");return u.jsx(tr,{...m,children:u.jsxs(Hd,{required:g,scope:t,trigger:x,onTriggerChange:p,valueNode:w,onValueNodeChange:y,valueNodeHasChildren:S,onValueNodeHasChildrenChange:R,contentId:We(),value:V,onValueChange:D,open:N,onOpenChange:A,dir:I,triggerPointerDownPosRef:P,disabled:v,children:[u.jsx(Qt.Provider,{scope:t,children:u.jsx(Gd,{scope:e.__scopeSelect,onNativeOptionAdd:d.useCallback(_=>{T(G=>new Set(G).add(_))},[]),onNativeOptionRemove:d.useCallback(_=>{T(G=>{const z=new Set(G);return z.delete(_),z})},[]),children:n})}),O?u.jsxs(Ts,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:h,value:V,onChange:_=>D(_.target.value),disabled:v,form:b,children:[V===void 0?u.jsx("option",{value:""}):null,Array.from(F)]},W):null]})})};is.displayName=He;var ls="SelectTrigger",cs=d.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=tn(n),a=Fe(ls,n),i=a.disabled||r,l=se(t,a.onTriggerChange),c=en(n),f=d.useRef("touch"),[h,v,g]=js(m=>{const x=c().filter(y=>!y.disabled),p=x.find(y=>y.value===a.value),w=Ds(x,m,p);w!==void 0&&a.onValueChange(w.value)}),b=m=>{i||(a.onOpenChange(!0),g()),m&&(a.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})};return u.jsx(nr,{asChild:!0,...s,children:u.jsx(oe.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:i,"data-disabled":i?"":void 0,"data-placeholder":As(a.value)?"":void 0,...o,ref:l,onClick:K(o.onClick,m=>{m.currentTarget.focus(),f.current!=="mouse"&&b(m)}),onPointerDown:K(o.onPointerDown,m=>{f.current=m.pointerType;const x=m.target;x.hasPointerCapture(m.pointerId)&&x.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(b(m),m.preventDefault())}),onKeyDown:K(o.onKeyDown,m=>{const x=h.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&v(m.key),!(x&&m.key===" ")&&Bd.includes(m.key)&&(b(),m.preventDefault())})})})});cs.displayName=ls;var ds="SelectValue",us=d.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:a="",...i}=e,l=Fe(ds,n),{onValueNodeHasChildrenChange:c}=l,f=s!==void 0,h=se(t,l.onValueNodeChange);return ce(()=>{c(f)},[c,f]),u.jsx(oe.span,{...i,ref:h,style:{pointerEvents:"none"},children:As(l.value)?u.jsx(u.Fragment,{children:a}):s})});us.displayName=ds;var Yd="SelectIcon",fs=d.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(oe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});fs.displayName=Yd;var Xd="SelectPortal",hs=e=>u.jsx(sr,{asChild:!0,...e});hs.displayName=Xd;var Ge="SelectContent",ms=d.forwardRef((e,t)=>{const n=Fe(Ge,e.__scopeSelect),[r,o]=d.useState();if(ce(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Kt.createPortal(u.jsx(ps,{scope:e.__scopeSelect,children:u.jsx(Qt.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(gs,{...e,ref:t})});ms.displayName=Ge;var xe=10,[ps,$e]=dt(Ge),qd="SelectContentImpl",Zd=rt("SelectContent.RemoveScroll"),gs=d.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:a,side:i,sideOffset:l,align:c,alignOffset:f,arrowPadding:h,collisionBoundary:v,collisionPadding:g,sticky:b,hideWhenDetached:m,avoidCollisions:x,...p}=e,w=Fe(Ge,n),[y,S]=d.useState(null),[R,I]=d.useState(null),N=se(t,E=>S(E)),[A,V]=d.useState(null),[D,P]=d.useState(null),O=en(n),[F,T]=d.useState(!1),W=d.useRef(!1);d.useEffect(()=>{if(y)return Qo(y)},[y]),Io();const _=d.useCallback(E=>{const[J,...te]=O().map($=>$.ref.current),[X]=te.slice(-1),M=document.activeElement;for(const $ of E)if($===M||($==null||$.scrollIntoView({block:"nearest"}),$===J&&R&&(R.scrollTop=0),$===X&&R&&(R.scrollTop=R.scrollHeight),$==null||$.focus(),document.activeElement!==M))return},[O,R]),G=d.useCallback(()=>_([A,y]),[_,A,y]);d.useEffect(()=>{F&&G()},[F,G]);const{onOpenChange:z,triggerPointerDownPosRef:k}=w;d.useEffect(()=>{if(y){let E={x:0,y:0};const J=X=>{var M,$;E={x:Math.abs(Math.round(X.pageX)-(((M=k.current)==null?void 0:M.x)??0)),y:Math.abs(Math.round(X.pageY)-((($=k.current)==null?void 0:$.y)??0))}},te=X=>{E.x<=10&&E.y<=10?X.preventDefault():y.contains(X.target)||z(!1),document.removeEventListener("pointermove",J),k.current=null};return k.current!==null&&(document.addEventListener("pointermove",J),document.addEventListener("pointerup",te,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",te,{capture:!0})}}},[y,z,k]),d.useEffect(()=>{const E=()=>z(!1);return window.addEventListener("blur",E),window.addEventListener("resize",E),()=>{window.removeEventListener("blur",E),window.removeEventListener("resize",E)}},[z]);const[Z,j]=js(E=>{const J=O().filter(M=>!M.disabled),te=J.find(M=>M.ref.current===document.activeElement),X=Ds(J,E,te);X&&setTimeout(()=>X.ref.current.focus())}),H=d.useCallback((E,J,te)=>{const X=!W.current&&!te;(w.value!==void 0&&w.value===J||X)&&(V(E),X&&(W.current=!0))},[w.value]),L=d.useCallback(()=>y==null?void 0:y.focus(),[y]),B=d.useCallback((E,J,te)=>{const X=!W.current&&!te;(w.value!==void 0&&w.value===J||X)&&P(E)},[w.value]),U=r==="popper"?Nn:vs,ee=U===Nn?{side:i,sideOffset:l,align:c,alignOffset:f,arrowPadding:h,collisionBoundary:v,collisionPadding:g,sticky:b,hideWhenDetached:m,avoidCollisions:x}:{};return u.jsx(ps,{scope:n,content:y,viewport:R,onViewportChange:I,itemRefCallback:H,selectedItem:A,onItemLeave:L,itemTextRefCallback:B,focusSelectedItem:G,selectedItemText:D,position:r,isPositioned:F,searchRef:Z,children:u.jsx(ar,{as:Zd,allowPinchZoom:!0,children:u.jsx(Hn,{asChild:!0,trapped:w.open,onMountAutoFocus:E=>{E.preventDefault()},onUnmountAutoFocus:K(o,E=>{var J;(J=w.trigger)==null||J.focus({preventScroll:!0}),E.preventDefault()}),children:u.jsx(Yt,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:E=>E.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(U,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:E=>E.preventDefault(),...p,...ee,onPlaced:()=>T(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...p.style},onKeyDown:K(p.onKeyDown,E=>{const J=E.ctrlKey||E.altKey||E.metaKey;if(E.key==="Tab"&&E.preventDefault(),!J&&E.key.length===1&&j(E.key),["ArrowUp","ArrowDown","Home","End"].includes(E.key)){let X=O().filter(M=>!M.disabled).map(M=>M.ref.current);if(["ArrowUp","End"].includes(E.key)&&(X=X.slice().reverse()),["ArrowUp","ArrowDown"].includes(E.key)){const M=E.target,$=X.indexOf(M);X=X.slice($+1)}setTimeout(()=>_(X)),E.preventDefault()}})})})})})})});gs.displayName=qd;var Jd="SelectItemAlignedPosition",vs=d.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Fe(Ge,n),a=$e(Ge,n),[i,l]=d.useState(null),[c,f]=d.useState(null),h=se(t,N=>f(N)),v=en(n),g=d.useRef(!1),b=d.useRef(!0),{viewport:m,selectedItem:x,selectedItemText:p,focusSelectedItem:w}=a,y=d.useCallback(()=>{if(s.trigger&&s.valueNode&&i&&c&&m&&x&&p){const N=s.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),V=s.valueNode.getBoundingClientRect(),D=p.getBoundingClientRect();if(s.dir!=="rtl"){const M=D.left-A.left,$=V.left-M,Q=N.left-$,ne=N.width+Q,re=Math.max(ne,A.width),ie=window.innerWidth-xe,le=Pr($,[xe,Math.max(xe,ie-re)]);i.style.minWidth=ne+"px",i.style.left=le+"px"}else{const M=A.right-D.right,$=window.innerWidth-V.right-M,Q=window.innerWidth-N.right-$,ne=N.width+Q,re=Math.max(ne,A.width),ie=window.innerWidth-xe,le=Pr($,[xe,Math.max(xe,ie-re)]);i.style.minWidth=ne+"px",i.style.right=le+"px"}const P=v(),O=window.innerHeight-xe*2,F=m.scrollHeight,T=window.getComputedStyle(c),W=parseInt(T.borderTopWidth,10),_=parseInt(T.paddingTop,10),G=parseInt(T.borderBottomWidth,10),z=parseInt(T.paddingBottom,10),k=W+_+F+z+G,Z=Math.min(x.offsetHeight*5,k),j=window.getComputedStyle(m),H=parseInt(j.paddingTop,10),L=parseInt(j.paddingBottom,10),B=N.top+N.height/2-xe,U=O-B,ee=x.offsetHeight/2,E=x.offsetTop+ee,J=W+_+E,te=k-J;if(J<=B){const M=P.length>0&&x===P[P.length-1].ref.current;i.style.bottom="0px";const $=c.clientHeight-m.offsetTop-m.offsetHeight,Q=Math.max(U,ee+(M?L:0)+$+G),ne=J+Q;i.style.height=ne+"px"}else{const M=P.length>0&&x===P[0].ref.current;i.style.top="0px";const Q=Math.max(B,W+m.offsetTop+(M?H:0)+ee)+te;i.style.height=Q+"px",m.scrollTop=J-B+m.offsetTop}i.style.margin=`${xe}px 0`,i.style.minHeight=Z+"px",i.style.maxHeight=O+"px",r==null||r(),requestAnimationFrame(()=>g.current=!0)}},[v,s.trigger,s.valueNode,i,c,m,x,p,s.dir,r]);ce(()=>y(),[y]);const[S,R]=d.useState();ce(()=>{c&&R(window.getComputedStyle(c).zIndex)},[c]);const I=d.useCallback(N=>{N&&b.current===!0&&(y(),w==null||w(),b.current=!1)},[y,w]);return u.jsx(eu,{scope:n,contentWrapper:i,shouldExpandOnScrollRef:g,onScrollButtonChange:I,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:u.jsx(oe.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});vs.displayName=Jd;var Qd="SelectPopperPosition",Nn=d.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=xe,...s}=e,a=tn(n);return u.jsx(rr,{...a,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Nn.displayName=Qd;var[eu,ir]=dt(Ge,{}),Mn="SelectViewport",xs=d.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=$e(Mn,n),a=ir(Mn,n),i=se(t,s.onViewportChange),l=d.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(Qt.Slot,{scope:n,children:u.jsx(oe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:K(o.onScroll,c=>{const f=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:v}=a;if(v!=null&&v.current&&h){const g=Math.abs(l.current-f.scrollTop);if(g>0){const b=window.innerHeight-xe*2,m=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),p=Math.max(m,x);if(p<b){const w=p+g,y=Math.min(b,w),S=w-y;h.style.height=y+"px",h.style.bottom==="0px"&&(f.scrollTop=S>0?S:0,h.style.justifyContent="flex-end")}}}l.current=f.scrollTop})})})]})});xs.displayName=Mn;var ws="SelectGroup",[tu,nu]=dt(ws),ru=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=We();return u.jsx(tu,{scope:n,id:o,children:u.jsx(oe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});ru.displayName=ws;var bs="SelectLabel",ys=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=nu(bs,n);return u.jsx(oe.div,{id:o.id,...r,ref:t})});ys.displayName=bs;var Vt="SelectItem",[ou,Cs]=dt(Vt),Ss=d.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...a}=e,i=Fe(Vt,n),l=$e(Vt,n),c=i.value===r,[f,h]=d.useState(s??""),[v,g]=d.useState(!1),b=se(t,w=>{var y;return(y=l.itemRefCallback)==null?void 0:y.call(l,w,r,o)}),m=We(),x=d.useRef("touch"),p=()=>{o||(i.onValueChange(r),i.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(ou,{scope:n,value:r,disabled:o,textId:m,isSelected:c,onItemTextChange:d.useCallback(w=>{h(y=>y||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(Qt.ItemSlot,{scope:n,value:r,disabled:o,textValue:f,children:u.jsx(oe.div,{role:"option","aria-labelledby":m,"data-highlighted":v?"":void 0,"aria-selected":c&&v,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:b,onFocus:K(a.onFocus,()=>g(!0)),onBlur:K(a.onBlur,()=>g(!1)),onClick:K(a.onClick,()=>{x.current!=="mouse"&&p()}),onPointerUp:K(a.onPointerUp,()=>{x.current==="mouse"&&p()}),onPointerDown:K(a.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:K(a.onPointerMove,w=>{var y;x.current=w.pointerType,o?(y=l.onItemLeave)==null||y.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:K(a.onPointerLeave,w=>{var y;w.currentTarget===document.activeElement&&((y=l.onItemLeave)==null||y.call(l))}),onKeyDown:K(a.onKeyDown,w=>{var S;((S=l.searchRef)==null?void 0:S.current)!==""&&w.key===" "||(Wd.includes(w.key)&&p(),w.key===" "&&w.preventDefault())})})})})});Ss.displayName=Vt;var mt="SelectItemText",Rs=d.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,a=Fe(mt,n),i=$e(mt,n),l=Cs(mt,n),c=Ud(mt,n),[f,h]=d.useState(null),v=se(t,p=>h(p),l.onItemTextChange,p=>{var w;return(w=i.itemTextRefCallback)==null?void 0:w.call(i,p,l.value,l.disabled)}),g=f==null?void 0:f.textContent,b=d.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:g},l.value),[l.disabled,l.value,g]),{onNativeOptionAdd:m,onNativeOptionRemove:x}=c;return ce(()=>(m(b),()=>x(b)),[m,x,b]),u.jsxs(u.Fragment,{children:[u.jsx(oe.span,{id:l.textId,...s,ref:v}),l.isSelected&&a.valueNode&&!a.valueNodeHasChildren?Kt.createPortal(s.children,a.valueNode):null]})});Rs.displayName=mt;var Is="SelectItemIndicator",Es=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Cs(Is,n).isSelected?u.jsx(oe.span,{"aria-hidden":!0,...r,ref:t}):null});Es.displayName=Is;var kn="SelectScrollUpButton",Ns=d.forwardRef((e,t)=>{const n=$e(kn,e.__scopeSelect),r=ir(kn,e.__scopeSelect),[o,s]=d.useState(!1),a=se(t,r.onScrollButtonChange);return ce(()=>{if(n.viewport&&n.isPositioned){let i=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return i(),l.addEventListener("scroll",i),()=>l.removeEventListener("scroll",i)}},[n.viewport,n.isPositioned]),o?u.jsx(ks,{...e,ref:a,onAutoScroll:()=>{const{viewport:i,selectedItem:l}=n;i&&l&&(i.scrollTop=i.scrollTop-l.offsetHeight)}}):null});Ns.displayName=kn;var Pn="SelectScrollDownButton",Ms=d.forwardRef((e,t)=>{const n=$e(Pn,e.__scopeSelect),r=ir(Pn,e.__scopeSelect),[o,s]=d.useState(!1),a=se(t,r.onScrollButtonChange);return ce(()=>{if(n.viewport&&n.isPositioned){let i=function(){const c=l.scrollHeight-l.clientHeight,f=Math.ceil(l.scrollTop)<c;s(f)};const l=n.viewport;return i(),l.addEventListener("scroll",i),()=>l.removeEventListener("scroll",i)}},[n.viewport,n.isPositioned]),o?u.jsx(ks,{...e,ref:a,onAutoScroll:()=>{const{viewport:i,selectedItem:l}=n;i&&l&&(i.scrollTop=i.scrollTop+l.offsetHeight)}}):null});Ms.displayName=Pn;var ks=d.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=$e("SelectScrollButton",n),a=d.useRef(null),i=en(n),l=d.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return d.useEffect(()=>()=>l(),[l]),ce(()=>{var f;const c=i().find(h=>h.ref.current===document.activeElement);(f=c==null?void 0:c.ref.current)==null||f.scrollIntoView({block:"nearest"})},[i]),u.jsx(oe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:K(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:K(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:K(o.onPointerLeave,()=>{l()})})}),su="SelectSeparator",Ps=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(oe.div,{"aria-hidden":!0,...r,ref:t})});Ps.displayName=su;var Tn="SelectArrow",au=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=tn(n),s=Fe(Tn,n),a=$e(Tn,n);return s.open&&a.position==="popper"?u.jsx(or,{...o,...r,ref:t}):null});au.displayName=Tn;var iu="SelectBubbleInput",Ts=d.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=d.useRef(null),s=se(r,o),a=Xo(t);return d.useEffect(()=>{const i=o.current;if(!i)return;const l=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(l,"value").set;if(a!==t&&f){const h=new Event("change",{bubbles:!0});f.call(i,t),i.dispatchEvent(h)}},[a,t]),u.jsx(oe.select,{...n,style:{...qo,...n.style},ref:s,defaultValue:t})});Ts.displayName=iu;function As(e){return e===""||e===void 0}function js(e){const t=Ie(e),n=d.useRef(""),r=d.useRef(0),o=d.useCallback(a=>{const i=n.current+a;t(i),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(i)},[t]),s=d.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return d.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Ds(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=lu(e,Math.max(s,0));o.length===1&&(a=a.filter(c=>c!==n));const l=a.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function lu(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var cu=is,Os=cs,du=us,uu=fs,fu=hs,_s=ms,hu=xs,Ls=ys,Fs=Ss,mu=Rs,pu=Es,$s=Ns,zs=Ms,Vs=Ps;const gu=_e("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",{variants:{variant:{default:"",ghost:"border-transparent bg-transparent",filled:"bg-muted border-transparent"},size:{default:"h-10",sm:"h-9",lg:"h-11"}},defaultVariants:{variant:"default",size:"default"}}),vu=cu,xu=du,Bs=d.forwardRef(({className:e,variant:t,size:n,children:r,...o},s)=>u.jsxs(Os,{ref:s,className:Y.cn(gu({variant:t,size:n}),e),...o,children:[r,u.jsx(uu,{asChild:!0,children:u.jsx(fo,{className:"h-4 w-4 opacity-50"})})]}));Bs.displayName=Os.displayName;const Ws=d.forwardRef(({className:e,...t},n)=>u.jsx($s,{ref:n,className:Y.cn("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(Ji,{className:"h-4 w-4"})}));Ws.displayName=$s.displayName;const Ks=d.forwardRef(({className:e,...t},n)=>u.jsx(zs,{ref:n,className:Y.cn("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(fo,{className:"h-4 w-4"})}));Ks.displayName=zs.displayName;const Hs=d.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(fu,{children:u.jsxs(_s,{ref:o,className:Y.cn("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Ws,{}),u.jsx(hu,{className:Y.cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Ks,{})]})}));Hs.displayName=_s.displayName;const wu=d.forwardRef(({className:e,...t},n)=>u.jsx(Ls,{ref:n,className:Y.cn("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));wu.displayName=Ls.displayName;const Gs=d.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Fs,{ref:r,className:Y.cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(pu,{children:u.jsx(Ht,{className:"h-4 w-4"})})}),u.jsx(mu,{children:t})]}));Gs.displayName=Fs.displayName;const bu=d.forwardRef(({className:e,...t},n)=>u.jsx(Vs,{ref:n,className:Y.cn("-mx-1 my-1 h-px bg-muted",e),...t}));bu.displayName=Vs.displayName;function yu({totalCount:e,features:t={},currentPageSize:n=10,pageSizeOptions:r=[5,10,20,50,100],onPageSizeChange:o,leftSlot:s,rightSlot:a,centerSlot:i,className:l=""}){const{pageSizeSelector:c=!1}=t;return u.jsxs("div",{className:`flex items-center justify-between gap-4 p-4 bg-muted/30 rounded-lg ${l}`,children:[u.jsxs("div",{className:"flex items-center gap-4",children:[u.jsx("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Total: ",e.toLocaleString()]})}),s]}),i&&u.jsx("div",{className:"flex items-center gap-4",children:i}),u.jsxs("div",{className:"flex items-center gap-4",children:[c&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Show:"}),u.jsxs(vu,{value:n.toString(),onValueChange:f=>o==null?void 0:o(Number(f)),children:[u.jsx(Bs,{className:"w-20",children:u.jsx(xu,{})}),u.jsx(Hs,{children:r.map(f=>u.jsx(Gs,{value:f.toString(),children:f},f))})]})]}),a]})]})}function Cu({totalCount:e,visibleCount:t,scrollInfo:n,onScrollToTop:r,onScrollToMiddle:o,onScrollToBottom:s,onScrollToRandom:a}){return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"p-3 bg-blue-100 dark:bg-blue-900/20 rounded border border-blue-300 dark:border-blue-700 text-sm",children:[u.jsx("div",{className:"font-semibold text-blue-800 dark:text-blue-200 mb-1",children:"Virtual Scrolling Active"}),u.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 text-xs text-blue-700 dark:text-blue-300",children:[u.jsxs("div",{children:["Total: ",e]}),u.jsxs("div",{children:["Visible: ",t]}),u.jsxs("div",{children:["Range: ",n.visibleStartIndex,"-",n.visibleEndIndex]}),u.jsxs("div",{children:["Height: ",n.totalHeight,"px"]})]})]}),u.jsxs("div",{className:"flex gap-2 items-center p-3 bg-gray-100 dark:bg-gray-800 rounded",children:[u.jsx("span",{className:"text-sm font-medium",children:"Virtual Scroll Controls:"}),u.jsx(we,{size:"sm",variant:"outline",onClick:r,children:"↑ Top"}),u.jsx(we,{size:"sm",variant:"outline",onClick:o,children:"↕ Middle"}),u.jsx(we,{size:"sm",variant:"outline",onClick:s,children:"↓ Bottom"}),u.jsx(we,{size:"sm",variant:"outline",onClick:a,children:"🎲 Random"})]})]})}function Su(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var Ue=e=>{const{present:t,children:n}=e,r=Ru(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),s=se(r.ref,Iu(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:s}):null};Ue.displayName="Presence";function Ru(e){const[t,n]=d.useState(),r=d.useRef(null),o=d.useRef(e),s=d.useRef("none"),a=e?"mounted":"unmounted",[i,l]=Su(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const c=Tt(r.current);s.current=i==="mounted"?c:"none"},[i]),ce(()=>{const c=r.current,f=o.current;if(f!==e){const v=s.current,g=Tt(c);e?l("MOUNT"):g==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(f&&v!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),ce(()=>{if(t){let c;const f=t.ownerDocument.defaultView??window,h=g=>{const m=Tt(r.current).includes(g.animationName);if(g.target===t&&m&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},v=g=>{g.target===t&&(s.current=Tt(r.current))};return t.addEventListener("animationstart",v),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{f.clearTimeout(c),t.removeEventListener("animationstart",v),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:d.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Tt(e){return(e==null?void 0:e.animationName)||"none"}function Iu(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var nn="Checkbox",[Eu,Jh]=Le(nn),[Nu,lr]=Eu(nn);function Mu(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:o,disabled:s,form:a,name:i,onCheckedChange:l,required:c,value:f="on",internal_do_not_use_render:h}=e,[v,g]=st({prop:n,defaultProp:o??!1,onChange:l,caller:nn}),[b,m]=d.useState(null),[x,p]=d.useState(null),w=d.useRef(!1),y=b?!!a||!!b.closest("form"):!0,S={checked:v,disabled:s,setChecked:g,control:b,setControl:m,name:i,form:a,value:f,hasConsumerStoppedPropagationRef:w,required:c,defaultChecked:je(o)?!1:o,isFormControl:y,bubbleInput:x,setBubbleInput:p};return u.jsx(Nu,{scope:t,...S,children:ku(h)?h(S):r})}var Us="CheckboxTrigger",Ys=d.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},o)=>{const{control:s,value:a,disabled:i,checked:l,required:c,setControl:f,setChecked:h,hasConsumerStoppedPropagationRef:v,isFormControl:g,bubbleInput:b}=lr(Us,e),m=se(o,f),x=d.useRef(l);return d.useEffect(()=>{const p=s==null?void 0:s.form;if(p){const w=()=>h(x.current);return p.addEventListener("reset",w),()=>p.removeEventListener("reset",w)}},[s,h]),u.jsx(oe.button,{type:"button",role:"checkbox","aria-checked":je(l)?"mixed":l,"aria-required":c,"data-state":Qs(l),"data-disabled":i?"":void 0,disabled:i,value:a,...r,ref:m,onKeyDown:K(t,p=>{p.key==="Enter"&&p.preventDefault()}),onClick:K(n,p=>{h(w=>je(w)?!0:!w),b&&g&&(v.current=p.isPropagationStopped(),v.current||p.stopPropagation())})})});Ys.displayName=Us;var cr=d.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:s,required:a,disabled:i,value:l,onCheckedChange:c,form:f,...h}=e;return u.jsx(Mu,{__scopeCheckbox:n,checked:o,defaultChecked:s,disabled:i,required:a,onCheckedChange:c,name:r,form:f,value:l,internal_do_not_use_render:({isFormControl:v})=>u.jsxs(u.Fragment,{children:[u.jsx(Ys,{...h,ref:t,__scopeCheckbox:n}),v&&u.jsx(Js,{__scopeCheckbox:n})]})})});cr.displayName=nn;var Xs="CheckboxIndicator",qs=d.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,s=lr(Xs,n);return u.jsx(Ue,{present:r||je(s.checked)||s.checked===!0,children:u.jsx(oe.span,{"data-state":Qs(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});qs.displayName=Xs;var Zs="CheckboxBubbleInput",Js=d.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:o,checked:s,defaultChecked:a,required:i,disabled:l,name:c,value:f,form:h,bubbleInput:v,setBubbleInput:g}=lr(Zs,e),b=se(n,g),m=Xo(s),x=$o(r);d.useEffect(()=>{const w=v;if(!w)return;const y=window.HTMLInputElement.prototype,R=Object.getOwnPropertyDescriptor(y,"checked").set,I=!o.current;if(m!==s&&R){const N=new Event("click",{bubbles:I});w.indeterminate=je(s),R.call(w,je(s)?!1:s),w.dispatchEvent(N)}},[v,m,s,o]);const p=d.useRef(je(s)?!1:s);return u.jsx(oe.input,{type:"checkbox","aria-hidden":!0,defaultChecked:a??p.current,required:i,disabled:l,name:c,value:f,form:h,...t,tabIndex:-1,ref:b,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Js.displayName=Zs;function ku(e){return typeof e=="function"}function je(e){return e==="indeterminate"}function Qs(e){return je(e)?"indeterminate":e?"checked":"unchecked"}const Pu=_e("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",{variants:{variant:{default:"",destructive:"border-destructive data-[state=checked]:bg-destructive",success:"border-green-500 data-[state=checked]:bg-green-500"},size:{default:"h-4 w-4",sm:"h-3 w-3",lg:"h-5 w-5"}},defaultVariants:{variant:"default",size:"default"}}),xt=d.forwardRef(({className:e,variant:t,size:n,indeterminate:r,...o},s)=>u.jsx(cr,{ref:s,className:Y.cn(Pu({variant:t,size:n}),e),...o,children:u.jsx(qs,{className:Y.cn("flex items-center justify-center text-current"),children:r?u.jsx(nl,{className:"h-3 w-3"}):u.jsx(Ht,{className:"h-3 w-3"})})}));xt.displayName=cr.displayName;function Tu({columns:e,sorting:t,showSelection:n=!0,showActions:r=!0,isAllSelected:o,isIndeterminate:s,onSelectAll:a,onSort:i,sortable:l=!0}){return u.jsx("div",{className:"bg-muted/50 sticky top-0 z-10",children:u.jsxs("div",{className:"flex border-b",children:[n&&u.jsx("div",{className:"flex items-center justify-center w-12 p-3 border-r font-medium text-sm bg-muted/50",children:u.jsx(xt,{checked:o,indeterminate:s,onCheckedChange:a,"aria-label":"Select all rows"})}),e.map(c=>{const f=t.find(h=>h.id===c.id);return u.jsxs("div",{className:`
flex items-center p-3 font-medium text-sm border-r hover:bg-muted/50 bg-muted/50
${l&&c.sortable?"cursor-pointer":""}
${c.headerClassName||""}
`,style:{textAlign:c.headerAlign||c.align||"left",width:c.width?`${c.width}px`:void 0,minWidth:c.minWidth?`${c.minWidth}px`:void 0,maxWidth:c.maxWidth?`${c.maxWidth}px`:void 0,flex:c.flex?c.flex:void 0},onClick:()=>{l&&c.sortable&&i(c.id)},children:[u.jsx("span",{className:c.ellipsis?"truncate":"",children:c.header}),l&&c.sortable&&u.jsx("span",{className:"ml-1 text-muted-foreground",children:f?f.desc?"↓":"↑":"↕️"})]},c.id)}),r&&u.jsx("div",{className:"flex items-center justify-center w-12 p-3 font-medium text-sm bg-muted/50",children:"Actions"})]})})}var wn="rovingFocusGroup.onEntryFocus",Au={bubbles:!1,cancelable:!0},St="RovingFocusGroup",[An,ea,ju]=Wn(St),[Du,ta]=Le(St,[ju]),[Ou,_u]=Du(St),na=d.forwardRef((e,t)=>u.jsx(An.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(An.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Lu,{...e,ref:t})})}));na.displayName=St;var Lu=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:f=!1,...h}=e,v=d.useRef(null),g=se(t,v),b=Kn(s),[m,x]=st({prop:a,defaultProp:i??null,onChange:l,caller:St}),[p,w]=d.useState(!1),y=Ie(c),S=ea(n),R=d.useRef(!1),[I,N]=d.useState(0);return d.useEffect(()=>{const A=v.current;if(A)return A.addEventListener(wn,y),()=>A.removeEventListener(wn,y)},[y]),u.jsx(Ou,{scope:n,orientation:r,dir:b,loop:o,currentTabStopId:m,onItemFocus:d.useCallback(A=>x(A),[x]),onItemShiftTab:d.useCallback(()=>w(!0),[]),onFocusableItemAdd:d.useCallback(()=>N(A=>A+1),[]),onFocusableItemRemove:d.useCallback(()=>N(A=>A-1),[]),children:u.jsx(oe.div,{tabIndex:p||I===0?-1:0,"data-orientation":r,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:K(e.onMouseDown,()=>{R.current=!0}),onFocus:K(e.onFocus,A=>{const V=!R.current;if(A.target===A.currentTarget&&V&&!p){const D=new CustomEvent(wn,Au);if(A.currentTarget.dispatchEvent(D),!D.defaultPrevented){const P=S().filter(_=>_.focusable),O=P.find(_=>_.active),F=P.find(_=>_.id===m),W=[O,F,...P].filter(Boolean).map(_=>_.ref.current);sa(W,f)}}R.current=!1}),onBlur:K(e.onBlur,()=>w(!1))})})}),ra="RovingFocusGroupItem",oa=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:a,...i}=e,l=We(),c=s||l,f=_u(ra,n),h=f.currentTabStopId===c,v=ea(n),{onFocusableItemAdd:g,onFocusableItemRemove:b,currentTabStopId:m}=f;return d.useEffect(()=>{if(r)return g(),()=>b()},[r,g,b]),u.jsx(An.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(oe.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...i,ref:t,onMouseDown:K(e.onMouseDown,x=>{r?f.onItemFocus(c):x.preventDefault()}),onFocus:K(e.onFocus,()=>f.onItemFocus(c)),onKeyDown:K(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){f.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const p=zu(x,f.orientation,f.dir);if(p!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let y=v().filter(S=>S.focusable).map(S=>S.ref.current);if(p==="last")y.reverse();else if(p==="prev"||p==="next"){p==="prev"&&y.reverse();const S=y.indexOf(x.currentTarget);y=f.loop?Vu(y,S+1):y.slice(S+1)}setTimeout(()=>sa(y))}}),children:typeof a=="function"?a({isCurrentTabStop:h,hasTabStop:m!=null}):a})})});oa.displayName=ra;var Fu={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function $u(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function zu(e,t,n){const r=$u(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Fu[r]}function sa(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Vu(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Bu=na,Wu=oa,jn=["Enter"," "],Ku=["ArrowDown","PageUp","Home"],aa=["ArrowUp","PageDown","End"],Hu=[...Ku,...aa],Gu={ltr:[...jn,"ArrowRight"],rtl:[...jn,"ArrowLeft"]},Uu={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Rt="Menu",[wt,Yu,Xu]=Wn(Rt),[Ye,ia]=Le(Rt,[Xu,ct,ta]),rn=ct(),la=ta(),[qu,Xe]=Ye(Rt),[Zu,It]=Ye(Rt),ca=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:a=!0}=e,i=rn(t),[l,c]=d.useState(null),f=d.useRef(!1),h=Ie(s),v=Kn(o);return d.useEffect(()=>{const g=()=>{f.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>f.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),u.jsx(tr,{...i,children:u.jsx(qu,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(Zu,{scope:t,onClose:d.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:f,dir:v,modal:a,children:r})})})};ca.displayName=Rt;var Ju="MenuAnchor",dr=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=rn(n);return u.jsx(nr,{...o,...r,ref:t})});dr.displayName=Ju;var ur="MenuPortal",[Qu,da]=Ye(ur,{forceMount:void 0}),ua=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Xe(ur,t);return u.jsx(Qu,{scope:t,forceMount:n,children:u.jsx(Ue,{present:n||s.open,children:u.jsx(sr,{asChild:!0,container:o,children:r})})})};ua.displayName=ur;var ge="MenuContent",[ef,fr]=Ye(ge),fa=d.forwardRef((e,t)=>{const n=da(ge,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Xe(ge,e.__scopeMenu),a=It(ge,e.__scopeMenu);return u.jsx(wt.Provider,{scope:e.__scopeMenu,children:u.jsx(Ue,{present:r||s.open,children:u.jsx(wt.Slot,{scope:e.__scopeMenu,children:a.modal?u.jsx(tf,{...o,ref:t}):u.jsx(nf,{...o,ref:t})})})})}),tf=d.forwardRef((e,t)=>{const n=Xe(ge,e.__scopeMenu),r=d.useRef(null),o=se(t,r);return d.useEffect(()=>{const s=r.current;if(s)return Qo(s)},[]),u.jsx(hr,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:K(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),nf=d.forwardRef((e,t)=>{const n=Xe(ge,e.__scopeMenu);return u.jsx(hr,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),rf=rt("MenuContent.ScrollLock"),hr=d.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:i,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:v,onDismiss:g,disableOutsideScroll:b,...m}=e,x=Xe(ge,n),p=It(ge,n),w=rn(n),y=la(n),S=Yu(n),[R,I]=d.useState(null),N=d.useRef(null),A=se(t,N,x.onContentChange),V=d.useRef(0),D=d.useRef(""),P=d.useRef(0),O=d.useRef(null),F=d.useRef("right"),T=d.useRef(0),W=b?ar:d.Fragment,_=b?{as:rf,allowPinchZoom:!0}:void 0,G=k=>{var E,J;const Z=D.current+k,j=S().filter(te=>!te.disabled),H=document.activeElement,L=(E=j.find(te=>te.ref.current===H))==null?void 0:E.textValue,B=j.map(te=>te.textValue),U=gf(B,Z,L),ee=(J=j.find(te=>te.textValue===U))==null?void 0:J.ref.current;(function te(X){D.current=X,window.clearTimeout(V.current),X!==""&&(V.current=window.setTimeout(()=>te(""),1e3))})(Z),ee&&setTimeout(()=>ee.focus())};d.useEffect(()=>()=>window.clearTimeout(V.current),[]),Io();const z=d.useCallback(k=>{var j,H;return F.current===((j=O.current)==null?void 0:j.side)&&xf(k,(H=O.current)==null?void 0:H.area)},[]);return u.jsx(ef,{scope:n,searchRef:D,onItemEnter:d.useCallback(k=>{z(k)&&k.preventDefault()},[z]),onItemLeave:d.useCallback(k=>{var Z;z(k)||((Z=N.current)==null||Z.focus(),I(null))},[z]),onTriggerLeave:d.useCallback(k=>{z(k)&&k.preventDefault()},[z]),pointerGraceTimerRef:P,onPointerGraceIntentChange:d.useCallback(k=>{O.current=k},[]),children:u.jsx(W,{..._,children:u.jsx(Hn,{asChild:!0,trapped:o,onMountAutoFocus:K(s,k=>{var Z;k.preventDefault(),(Z=N.current)==null||Z.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:u.jsx(Yt,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:c,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:v,onDismiss:g,children:u.jsx(Bu,{asChild:!0,...y,dir:p.dir,orientation:"vertical",loop:r,currentTabStopId:R,onCurrentTabStopIdChange:I,onEntryFocus:K(l,k=>{p.isUsingKeyboardRef.current||k.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(rr,{role:"menu","aria-orientation":"vertical","data-state":Ma(x.open),"data-radix-menu-content":"",dir:p.dir,...w,...m,ref:A,style:{outline:"none",...m.style},onKeyDown:K(m.onKeyDown,k=>{const j=k.target.closest("[data-radix-menu-content]")===k.currentTarget,H=k.ctrlKey||k.altKey||k.metaKey,L=k.key.length===1;j&&(k.key==="Tab"&&k.preventDefault(),!H&&L&&G(k.key));const B=N.current;if(k.target!==B||!Hu.includes(k.key))return;k.preventDefault();const ee=S().filter(E=>!E.disabled).map(E=>E.ref.current);aa.includes(k.key)&&ee.reverse(),mf(ee)}),onBlur:K(e.onBlur,k=>{k.currentTarget.contains(k.target)||(window.clearTimeout(V.current),D.current="")}),onPointerMove:K(e.onPointerMove,bt(k=>{const Z=k.target,j=T.current!==k.clientX;if(k.currentTarget.contains(Z)&&j){const H=k.clientX>T.current?"right":"left";F.current=H,T.current=k.clientX}}))})})})})})})});fa.displayName=ge;var of="MenuGroup",mr=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(oe.div,{role:"group",...r,ref:t})});mr.displayName=of;var sf="MenuLabel",ha=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(oe.div,{...r,ref:t})});ha.displayName=sf;var Bt="MenuItem",Qr="menu.itemSelect",on=d.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=d.useRef(null),a=It(Bt,e.__scopeMenu),i=fr(Bt,e.__scopeMenu),l=se(t,s),c=d.useRef(!1),f=()=>{const h=s.current;if(!n&&h){const v=new CustomEvent(Qr,{bubbles:!0,cancelable:!0});h.addEventListener(Qr,g=>r==null?void 0:r(g),{once:!0}),Co(h,v),v.defaultPrevented?c.current=!1:a.onClose()}};return u.jsx(ma,{...o,ref:l,disabled:n,onClick:K(e.onClick,f),onPointerDown:h=>{var v;(v=e.onPointerDown)==null||v.call(e,h),c.current=!0},onPointerUp:K(e.onPointerUp,h=>{var v;c.current||(v=h.currentTarget)==null||v.click()}),onKeyDown:K(e.onKeyDown,h=>{const v=i.searchRef.current!=="";n||v&&h.key===" "||jn.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});on.displayName=Bt;var ma=d.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,a=fr(Bt,n),i=la(n),l=d.useRef(null),c=se(t,l),[f,h]=d.useState(!1),[v,g]=d.useState("");return d.useEffect(()=>{const b=l.current;b&&g((b.textContent??"").trim())},[s.children]),u.jsx(wt.ItemSlot,{scope:n,disabled:r,textValue:o??v,children:u.jsx(Wu,{asChild:!0,...i,focusable:!r,children:u.jsx(oe.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:K(e.onPointerMove,bt(b=>{r?a.onItemLeave(b):(a.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:K(e.onPointerLeave,bt(b=>a.onItemLeave(b))),onFocus:K(e.onFocus,()=>h(!0)),onBlur:K(e.onBlur,()=>h(!1))})})})}),af="MenuCheckboxItem",pa=d.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(ba,{scope:e.__scopeMenu,checked:n,children:u.jsx(on,{role:"menuitemcheckbox","aria-checked":Wt(n)?"mixed":n,...o,ref:t,"data-state":gr(n),onSelect:K(o.onSelect,()=>r==null?void 0:r(Wt(n)?!0:!n),{checkForDefaultPrevented:!1})})})});pa.displayName=af;var ga="MenuRadioGroup",[lf,cf]=Ye(ga,{value:void 0,onValueChange:()=>{}}),va=d.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Ie(r);return u.jsx(lf,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(mr,{...o,ref:t})})});va.displayName=ga;var xa="MenuRadioItem",wa=d.forwardRef((e,t)=>{const{value:n,...r}=e,o=cf(xa,e.__scopeMenu),s=n===o.value;return u.jsx(ba,{scope:e.__scopeMenu,checked:s,children:u.jsx(on,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":gr(s),onSelect:K(r.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,n)},{checkForDefaultPrevented:!1})})})});wa.displayName=xa;var pr="MenuItemIndicator",[ba,df]=Ye(pr,{checked:!1}),ya=d.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=df(pr,n);return u.jsx(Ue,{present:r||Wt(s.checked)||s.checked===!0,children:u.jsx(oe.span,{...o,ref:t,"data-state":gr(s.checked)})})});ya.displayName=pr;var uf="MenuSeparator",Ca=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(oe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Ca.displayName=uf;var ff="MenuArrow",Sa=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=rn(n);return u.jsx(or,{...o,...r,ref:t})});Sa.displayName=ff;var hf="MenuSub",[Qh,Ra]=Ye(hf),pt="MenuSubTrigger",Ia=d.forwardRef((e,t)=>{const n=Xe(pt,e.__scopeMenu),r=It(pt,e.__scopeMenu),o=Ra(pt,e.__scopeMenu),s=fr(pt,e.__scopeMenu),a=d.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},f=d.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return d.useEffect(()=>f,[f]),d.useEffect(()=>{const h=i.current;return()=>{window.clearTimeout(h),l(null)}},[i,l]),u.jsx(dr,{asChild:!0,...c,children:u.jsx(ma,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Ma(n.open),...e,ref:Gt(t,o.onTriggerChange),onClick:h=>{var v;(v=e.onClick)==null||v.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:K(e.onPointerMove,bt(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:K(e.onPointerLeave,bt(h=>{var g,b;f();const v=(g=n.content)==null?void 0:g.getBoundingClientRect();if(v){const m=(b=n.content)==null?void 0:b.dataset.side,x=m==="right",p=x?-5:5,w=v[x?"left":"right"],y=v[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+p,y:h.clientY},{x:w,y:v.top},{x:y,y:v.top},{x:y,y:v.bottom},{x:w,y:v.bottom}],side:m}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:K(e.onKeyDown,h=>{var g;const v=s.searchRef.current!=="";e.disabled||v&&h.key===" "||Gu[r.dir].includes(h.key)&&(n.onOpenChange(!0),(g=n.content)==null||g.focus(),h.preventDefault())})})})});Ia.displayName=pt;var Ea="MenuSubContent",Na=d.forwardRef((e,t)=>{const n=da(ge,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Xe(ge,e.__scopeMenu),a=It(ge,e.__scopeMenu),i=Ra(Ea,e.__scopeMenu),l=d.useRef(null),c=se(t,l);return u.jsx(wt.Provider,{scope:e.__scopeMenu,children:u.jsx(Ue,{present:r||s.open,children:u.jsx(wt.Slot,{scope:e.__scopeMenu,children:u.jsx(hr,{id:i.contentId,"aria-labelledby":i.triggerId,...o,ref:c,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var h;a.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:K(e.onFocusOutside,f=>{f.target!==i.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:K(e.onEscapeKeyDown,f=>{a.onClose(),f.preventDefault()}),onKeyDown:K(e.onKeyDown,f=>{var g;const h=f.currentTarget.contains(f.target),v=Uu[a.dir].includes(f.key);h&&v&&(s.onOpenChange(!1),(g=i.trigger)==null||g.focus(),f.preventDefault())})})})})})});Na.displayName=Ea;function Ma(e){return e?"open":"closed"}function Wt(e){return e==="indeterminate"}function gr(e){return Wt(e)?"indeterminate":e?"checked":"unchecked"}function mf(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function pf(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function gf(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=pf(e,Math.max(s,0));o.length===1&&(a=a.filter(c=>c!==n));const l=a.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function vf(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const i=t[s],l=t[a],c=i.x,f=i.y,h=l.x,v=l.y;f>r!=v>r&&n<(h-c)*(r-f)/(v-f)+c&&(o=!o)}return o}function xf(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return vf(n,t)}function bt(e){return t=>t.pointerType==="mouse"?e(t):void 0}var wf=ca,bf=dr,yf=ua,Cf=fa,Sf=mr,Rf=ha,If=on,Ef=pa,Nf=va,Mf=wa,kf=ya,Pf=Ca,Tf=Sa,Af=Ia,jf=Na,sn="DropdownMenu",[Df,em]=Le(sn,[ia]),de=ia(),[Of,ka]=Df(sn),Pa=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:a,modal:i=!0}=e,l=de(t),c=d.useRef(null),[f,h]=st({prop:o,defaultProp:s??!1,onChange:a,caller:sn});return u.jsx(Of,{scope:t,triggerId:We(),triggerRef:c,contentId:We(),open:f,onOpenChange:h,onOpenToggle:d.useCallback(()=>h(v=>!v),[h]),modal:i,children:u.jsx(wf,{...l,open:f,onOpenChange:h,dir:r,modal:i,children:n})})};Pa.displayName=sn;var Ta="DropdownMenuTrigger",Aa=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=ka(Ta,n),a=de(n);return u.jsx(bf,{asChild:!0,...a,children:u.jsx(oe.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Gt(t,s.triggerRef),onPointerDown:K(e.onPointerDown,i=>{!r&&i.button===0&&i.ctrlKey===!1&&(s.onOpenToggle(),s.open||i.preventDefault())}),onKeyDown:K(e.onKeyDown,i=>{r||(["Enter"," "].includes(i.key)&&s.onOpenToggle(),i.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});Aa.displayName=Ta;var _f="DropdownMenuPortal",ja=e=>{const{__scopeDropdownMenu:t,...n}=e,r=de(t);return u.jsx(yf,{...r,...n})};ja.displayName=_f;var Da="DropdownMenuContent",Oa=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ka(Da,n),s=de(n),a=d.useRef(!1);return u.jsx(Cf,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:K(e.onCloseAutoFocus,i=>{var l;a.current||(l=o.triggerRef.current)==null||l.focus(),a.current=!1,i.preventDefault()}),onInteractOutside:K(e.onInteractOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,f=l.button===2||c;(!o.modal||f)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Oa.displayName=Da;var Lf="DropdownMenuGroup",Ff=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=de(n);return u.jsx(Sf,{...o,...r,ref:t})});Ff.displayName=Lf;var $f="DropdownMenuLabel",_a=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=de(n);return u.jsx(Rf,{...o,...r,ref:t})});_a.displayName=$f;var zf="DropdownMenuItem",La=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=de(n);return u.jsx(If,{...o,...r,ref:t})});La.displayName=zf;var Vf="DropdownMenuCheckboxItem",Fa=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=de(n);return u.jsx(Ef,{...o,...r,ref:t})});Fa.displayName=Vf;var Bf="DropdownMenuRadioGroup",Wf=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=de(n);return u.jsx(Nf,{...o,...r,ref:t})});Wf.displayName=Bf;var Kf="DropdownMenuRadioItem",$a=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=de(n);return u.jsx(Mf,{...o,...r,ref:t})});$a.displayName=Kf;var Hf="DropdownMenuItemIndicator",za=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=de(n);return u.jsx(kf,{...o,...r,ref:t})});za.displayName=Hf;var Gf="DropdownMenuSeparator",Va=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=de(n);return u.jsx(Pf,{...o,...r,ref:t})});Va.displayName=Gf;var Uf="DropdownMenuArrow",Yf=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=de(n);return u.jsx(Tf,{...o,...r,ref:t})});Yf.displayName=Uf;var Xf="DropdownMenuSubTrigger",Ba=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=de(n);return u.jsx(Af,{...o,...r,ref:t})});Ba.displayName=Xf;var qf="DropdownMenuSubContent",Wa=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=de(n);return u.jsx(jf,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Wa.displayName=qf;var Zf=Pa,Jf=Aa,Qf=ja,Ka=Oa,Ha=_a,Ga=La,Ua=Fa,Ya=$a,Xa=za,qa=Va,Za=Ba,Ja=Wa;const Qa=Zf,ei=Jf,eh=d.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Za,{ref:o,className:Y.cn("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(ho,{className:"ml-auto h-4 w-4"})]}));eh.displayName=Za.displayName;const th=d.forwardRef(({className:e,...t},n)=>u.jsx(Ja,{ref:n,className:Y.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));th.displayName=Ja.displayName;const vr=d.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Qf,{children:u.jsx(Ka,{ref:r,sideOffset:t,className:Y.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));vr.displayName=Ka.displayName;const Be=d.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Ga,{ref:r,className:Y.cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Be.displayName=Ga.displayName;const nh=d.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Ua,{ref:o,className:Y.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Xa,{children:u.jsx(Ht,{className:"h-4 w-4"})})}),t]}));nh.displayName=Ua.displayName;const rh=d.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ya,{ref:r,className:Y.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Xa,{children:u.jsx(tl,{className:"h-2 w-2 fill-current"})})}),t]}));rh.displayName=Ya.displayName;const oh=d.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Ha,{ref:r,className:Y.cn("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));oh.displayName=Ha.displayName;const sh=d.forwardRef(({className:e,...t},n)=>u.jsx(qa,{ref:n,className:Y.cn("-mx-1 my-1 h-px bg-muted",e),...t}));sh.displayName=qa.displayName;function ah({virtualItem:e,rowData:t,columns:n,showSelection:r=!0,showActions:o=!0,isSelected:s,isRowCreated:a,isRowModified:i,isRowDeleted:l,onRowSelect:c,onRowAction:f}){if(!t)return u.jsx("div",{className:"absolute left-0 right-0 flex border-b bg-red-100 dark:bg-red-900/20",style:{top:`${e.start}px`,height:`${e.size}px`,display:"flex",alignItems:"center",justifyContent:"center"},children:u.jsxs("div",{className:"text-red-600 text-sm",children:["Missing data for index ",e.index]})},`missing-${e.key}`);const h=t.id,v=io(h),g=d.useMemo(()=>{let p="absolute left-0 right-0 flex border-b hover:bg-muted/30 transition-colors bg-white dark:bg-gray-800";return l&&h!==void 0&&h!==null&&l(h)?p+=" bg-gray-100 dark:bg-gray-800/60 opacity-60 !border-l-4 !border-l-red-500":i&&h!==void 0&&h!==null&&i(h)?p+=" bg-green-50 dark:bg-green-950/30 !border-l-4 !border-l-green-500":a&&h!==void 0&&h!==null&&a(h)&&(p+=" bg-blue-50 dark:bg-blue-950/30 !border-l-4 !border-l-blue-500"),p},[a,i,l,h]),b=()=>f("edit",t,e.index),m=()=>f("duplicate",t,e.index),x=()=>f("delete",t,e.index);return u.jsxs("div",{className:g,style:{top:`${e.start}px`,height:`${e.size}px`,minHeight:`${e.size}px`,maxHeight:`${e.size}px`,overflow:"hidden",display:"flex",alignItems:"center",zIndex:1},children:[r&&u.jsx("div",{className:"flex items-center justify-center w-12 border-r px-3 bg-inherit",children:u.jsx(xt,{checked:s,onCheckedChange:p=>c(v,p)})}),n.map(p=>{const w=t[p.accessorKey],y=p.cellClassName?typeof p.cellClassName=="function"?p.cellClassName(w,t):p.cellClassName:"",R=l&&h!==void 0&&h!==null&&l(h)?"line-through text-gray-500":"";return u.jsx("div",{className:`flex items-center border-r px-3 py-2 text-sm bg-inherit ${y} ${R}`,style:{textAlign:p.align||"left",width:p.width?`${p.width}px`:void 0,minWidth:p.minWidth?`${p.minWidth}px`:void 0,maxWidth:p.maxWidth?`${p.maxWidth}px`:void 0,flex:p.flex?p.flex:void 0},children:u.jsx("div",{className:`${p.ellipsis?"truncate":""} ${R}`,title:p.showTooltip&&p.ellipsis?String(w):void 0,children:p.type==="text"&&p.id==="status"?u.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${w==="active"?"bg-green-100 text-green-800 dark:bg-green-900/20 dark:text-green-400":"bg-gray-100 text-gray-800 dark:bg-gray-900/20 dark:text-gray-400"}`,children:w}):String(w||"")})},p.id)}),o&&u.jsx("div",{className:"flex items-center justify-center w-12 px-3 bg-inherit",children:u.jsxs(Qa,{children:[u.jsx(ei,{asChild:!0,children:u.jsx(we,{variant:"ghost",size:"icon",className:"h-6 w-6",children:u.jsx(Bn,{className:"h-3 w-3"})})}),u.jsxs(vr,{align:"end",children:[u.jsx(Be,{onClick:b,children:"Edit"}),u.jsx(Be,{onClick:m,children:"Duplicate"}),u.jsx(Be,{className:"text-destructive",onClick:x,children:"Delete"})]})]})})]},`virt-${e.key}-${h}`)}const ih=_e("w-full caption-bottom text-sm border-collapse",{variants:{variant:{default:"border border-border rounded-lg overflow-hidden",ghost:"",bordered:"border-2 border-border"},size:{sm:"text-xs",default:"text-sm",lg:"text-base"}},defaultVariants:{variant:"default",size:"default"}}),ti=d.forwardRef(({className:e,variant:t,size:n,virtualScrolling:r,height:o,style:s,...a},i)=>{const l=r?{...s,height:typeof o=="number"?`${o}px`:o}:s;return u.jsx("div",{className:Y.cn("relative overflow-auto",r&&"max-h-full"),children:u.jsx("table",{ref:i,className:Y.cn(ih({variant:t,size:n}),e),style:l,...a})})});ti.displayName="Table";const ni=d.forwardRef(({className:e,sticky:t,...n},r)=>u.jsx("thead",{ref:r,className:Y.cn("border-b border-border bg-muted/50",t&&"sticky top-0 z-10",e),...n}));ni.displayName="TableHeader";const ri=d.forwardRef(({className:e,...t},n)=>u.jsx("tbody",{ref:n,className:Y.cn("[&_tr:last-child]:border-b-0",e),...t}));ri.displayName="TableBody";const lh=d.forwardRef(({className:e,...t},n)=>u.jsx("tfoot",{ref:n,className:Y.cn("border-t border-border bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));lh.displayName="TableFooter";const ch=_e("border-b border-border transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",{variants:{variant:{default:"",ghost:"border-transparent"},state:{default:"",selected:"bg-muted",hover:"hover:bg-muted/50"}},defaultVariants:{variant:"default",state:"default"}}),Dn=d.forwardRef(({className:e,variant:t,state:n,selected:r,disableHover:o,...s},a)=>u.jsx("tr",{ref:a,className:Y.cn(ch({variant:t,state:n}),r&&"data-[state=selected]:bg-muted",o&&"hover:bg-transparent",e),"data-state":r?"selected":void 0,...s}));Dn.displayName="TableRow";const dh=_e("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",{variants:{sortable:{true:"cursor-pointer select-none hover:text-foreground transition-colors",false:""},resizable:{true:"relative",false:""}},defaultVariants:{sortable:!1,resizable:!1}}),_t=d.forwardRef(({className:e,sortable:t,resizable:n,sortDirection:r,minWidth:o,maxWidth:s,children:a,onClick:i,...l},c)=>{const f=h=>{t&&i&&i(h)};return u.jsxs("th",{ref:c,className:Y.cn(dh({sortable:t,resizable:n}),e),onClick:f,role:t?"columnheader button":"columnheader","aria-sort":r==="asc"?"ascending":r==="desc"?"descending":"none",style:{minWidth:o?`${o}px`:void 0,maxWidth:s?`${s}px`:void 0},...l,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[a,t&&r&&u.jsx(uh,{direction:r})]}),n&&u.jsx("div",{className:"absolute right-0 top-0 h-full w-1 cursor-col-resize bg-border opacity-0 hover:opacity-100 transition-opacity"})]})});_t.displayName="TableHead";const uh=({direction:e,className:t})=>u.jsx("svg",{className:Y.cn("h-4 w-4",t),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e==="asc"?u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}):u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),On=d.forwardRef(({className:e,...t},n)=>u.jsx("td",{ref:n,className:Y.cn("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));On.displayName="TableCell";const eo=_e("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",{variants:{variant:{default:"",ghost:"border-transparent bg-transparent",filled:"bg-muted border-transparent"},inputSize:{default:"h-10",sm:"h-9",lg:"h-11"},state:{default:"",error:"border-destructive focus-visible:ring-destructive",success:"border-green-500 focus-visible:ring-green-500"}},defaultVariants:{variant:"default",inputSize:"default",state:"default"}}),oi=d.forwardRef(({className:e,type:t="text",variant:n,inputSize:r,state:o,error:s,success:a,leftIcon:i,rightIcon:l,...c},f)=>{const h=d.useMemo(()=>s?"error":a?"success":o||"default",[s,a,o]);return i||l?u.jsxs("div",{className:"relative",children:[i&&u.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:i}),u.jsx("input",{type:t,className:Y.cn(eo({variant:n,inputSize:r,state:h}),i&&"pl-10",l&&"pr-10",e),ref:f,...c}),l&&u.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:l})]}):u.jsx("input",{type:t,className:Y.cn(eo({variant:n,inputSize:r,state:h}),e),ref:f,...c})});oi.displayName="Input";var[an,tm]=Le("Tooltip",[ct]),ln=ct(),si="TooltipProvider",fh=700,_n="tooltip.open",[hh,xr]=an(si),ai=e=>{const{__scopeTooltip:t,delayDuration:n=fh,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,a=d.useRef(!0),i=d.useRef(!1),l=d.useRef(0);return d.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(hh,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:d.useCallback(()=>{window.clearTimeout(l.current),a.current=!1},[]),onClose:d.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:i,onPointerInTransitChange:d.useCallback(c=>{i.current=c},[]),disableHoverableContent:o,children:s})};ai.displayName=si;var yt="Tooltip",[mh,cn]=an(yt),ii=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:i}=e,l=xr(yt,e.__scopeTooltip),c=ln(t),[f,h]=d.useState(null),v=We(),g=d.useRef(0),b=a??l.disableHoverableContent,m=i??l.delayDuration,x=d.useRef(!1),[p,w]=st({prop:r,defaultProp:o??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(_n))):l.onClose(),s==null||s(N)},caller:yt}),y=d.useMemo(()=>p?x.current?"delayed-open":"instant-open":"closed",[p]),S=d.useCallback(()=>{window.clearTimeout(g.current),g.current=0,x.current=!1,w(!0)},[w]),R=d.useCallback(()=>{window.clearTimeout(g.current),g.current=0,w(!1)},[w]),I=d.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{x.current=!0,w(!0),g.current=0},m)},[m,w]);return d.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),u.jsx(tr,{...c,children:u.jsx(mh,{scope:t,contentId:v,open:p,stateAttribute:y,trigger:f,onTriggerChange:h,onTriggerEnter:d.useCallback(()=>{l.isOpenDelayedRef.current?I():S()},[l.isOpenDelayedRef,I,S]),onTriggerLeave:d.useCallback(()=>{b?R():(window.clearTimeout(g.current),g.current=0)},[R,b]),onOpen:S,onClose:R,disableHoverableContent:b,children:n})})};ii.displayName=yt;var Ln="TooltipTrigger",li=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=cn(Ln,n),s=xr(Ln,n),a=ln(n),i=d.useRef(null),l=se(t,i,o.onTriggerChange),c=d.useRef(!1),f=d.useRef(!1),h=d.useCallback(()=>c.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(nr,{asChild:!0,...a,children:u.jsx(oe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:K(e.onPointerMove,v=>{v.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:K(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:K(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:K(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:K(e.onBlur,o.onClose),onClick:K(e.onClick,o.onClose)})})});li.displayName=Ln;var ph="TooltipPortal",[nm,gh]=an(ph,{forceMount:void 0}),at="TooltipContent",ci=d.forwardRef((e,t)=>{const n=gh(at,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,a=cn(at,e.__scopeTooltip);return u.jsx(Ue,{present:r||a.open,children:a.disableHoverableContent?u.jsx(di,{side:o,...s,ref:t}):u.jsx(vh,{side:o,...s,ref:t})})}),vh=d.forwardRef((e,t)=>{const n=cn(at,e.__scopeTooltip),r=xr(at,e.__scopeTooltip),o=d.useRef(null),s=se(t,o),[a,i]=d.useState(null),{trigger:l,onClose:c}=n,f=o.current,{onPointerInTransitChange:h}=r,v=d.useCallback(()=>{i(null),h(!1)},[h]),g=d.useCallback((b,m)=>{const x=b.currentTarget,p={x:b.clientX,y:b.clientY},w=Ch(p,x.getBoundingClientRect()),y=Sh(p,w),S=Rh(m.getBoundingClientRect()),R=Eh([...y,...S]);i(R),h(!0)},[h]);return d.useEffect(()=>()=>v(),[v]),d.useEffect(()=>{if(l&&f){const b=x=>g(x,f),m=x=>g(x,l);return l.addEventListener("pointerleave",b),f.addEventListener("pointerleave",m),()=>{l.removeEventListener("pointerleave",b),f.removeEventListener("pointerleave",m)}}},[l,f,g,v]),d.useEffect(()=>{if(a){const b=m=>{const x=m.target,p={x:m.clientX,y:m.clientY},w=(l==null?void 0:l.contains(x))||(f==null?void 0:f.contains(x)),y=!Ih(p,a);w?v():y&&(v(),c())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[l,f,a,c,v]),u.jsx(di,{...e,ref:s})}),[xh,wh]=an(yt,{isInside:!1}),bh=ll("TooltipContent"),di=d.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...i}=e,l=cn(at,n),c=ln(n),{onClose:f}=l;return d.useEffect(()=>(document.addEventListener(_n,f),()=>document.removeEventListener(_n,f)),[f]),d.useEffect(()=>{if(l.trigger){const h=v=>{const g=v.target;g!=null&&g.contains(l.trigger)&&f()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,f]),u.jsx(Yt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:h=>h.preventDefault(),onDismiss:f,children:u.jsxs(rr,{"data-state":l.stateAttribute,...c,...i,ref:t,style:{...i.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(bh,{children:r}),u.jsx(xh,{scope:n,isInside:!0,children:u.jsx(nd,{id:l.contentId,role:"tooltip",children:o||r})})]})})});ci.displayName=at;var ui="TooltipArrow",yh=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ln(n);return wh(ui,n).isInside?null:u.jsx(or,{...o,...r,ref:t})});yh.displayName=ui;function Ch(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Sh(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Rh(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function Ih(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const i=t[s],l=t[a],c=i.x,f=i.y,h=l.x,v=l.y;f>r!=v>r&&n<(h-c)*(r-f)/(v-f)+c&&(o=!o)}return o}function Eh(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Nh(t)}function Nh(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Mh=ai,kh=ii,Ph=li,fi=ci;const Th=Mh,to=kh,no=Ph,Fn=d.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(fi,{ref:r,sideOffset:t,className:Y.cn("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Fn.displayName=fi.displayName;const Ah=_e("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0 transition-all duration-200 relative",{variants:{variant:{default:"",numeric:"text-right font-mono",center:"text-center"},state:{default:"",editing:"ring-2 ring-primary ring-offset-1 bg-background shadow-sm scale-[1.02] z-10 relative",error:"ring-2 ring-destructive ring-offset-1 bg-destructive/5 border-destructive/20",success:"ring-2 ring-green-500 ring-offset-1 bg-green-50 dark:bg-green-950/20",saved:"bg-green-200 dark:bg-green-800/50 ring-1 ring-green-300 dark:ring-green-700 transition-all duration-1200 ease-out"},size:{sm:"px-2 py-1 text-xs",default:"px-4 py-3 text-sm",lg:"px-6 py-4 text-base"},editable:{true:"cursor-pointer hover:bg-muted/30 hover:ring-1 hover:ring-muted-foreground/20 group relative",false:""}},defaultVariants:{variant:"default",state:"default",size:"default",editable:!1}}),hi=d.forwardRef(({className:e,variant:t,state:n,size:r,editable:o=!1,isEditing:s=!1,value:a="",inputType:i="text",hasError:l=!1,errorMessage:c,hasSuccess:f=!1,recentlySaved:h=!1,placeholder:v,onEditStart:g,onEditEnd:b,onEditCancel:m,validate:x,disabled:p=!1,singleClickEdit:w=!1,onTabToNext:y,onTabToPrevious:S,onValueChange:R,enhancedMode:I=!1,onEnhancedMouseDown:N,onEnhancedMouseEnter:A,onEnhancedClick:V,onEnhancedKeyDown:D,children:P,onClick:O,onDoubleClick:F,onKeyDown:T,onMouseDown:W,onMouseEnter:_,...G},z)=>{const[k,Z]=d.useState(a),[j,H]=d.useState(null),[L,B]=d.useState(!1),[U,ee]=d.useState(!1),E=d.useRef(null),J=d.useRef(null);d.useEffect(()=>{Z(a)},[a]),d.useEffect(()=>{if(s&&E.current){const q=E.current,Te=setTimeout(()=>{q.focus(),q.select()},50);return()=>clearTimeout(Te)}},[s]),d.useEffect(()=>{if(h){B(!0);const q=setTimeout(()=>{B(!1)},1200);return()=>clearTimeout(q)}else B(!1)},[h]);const te=d.useMemo(()=>{const q=j||l||c;return s?"editing":q?"error":L?"saved":f&&!q?"success":n||"default"},[s,l,f,L,j,c,n,a,h]),X=d.useMemo(()=>j||c,[j,c]),M=d.useCallback(q=>{I&&V&&V(q),o&&!p&&!s&&w&&(g==null||g()),O==null||O(q)},[I,V,o,p,s,w,g,O]),$=d.useCallback(q=>{I&&N&&N(q),W==null||W(q)},[I,N,W]),Q=d.useCallback(q=>{ee(!0),I&&A&&A(q),_==null||_(q)},[I,A,_]),ne=d.useCallback(q=>{o&&!p&&!s&&(g==null||g()),F==null||F(q)},[o,p,s,g,F]),re=d.useCallback(q=>{if(s){T==null||T(q);return}if(I&&D){D(q);return}!I&&o&&!p&&!s&&(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),g==null||g()),T==null||T(q)},[I,D,o,p,s,g,T]),ie=d.useCallback(q=>{const Te=i==="number"?Number(q.target.value):q.target.value;if(Z(Te),R){const ht=R(Te);H(ht)}},[i,R]),le=d.useCallback(()=>{let q=!1;if(i==="number"){const Te=Number(a),ht=Number(k);q=Te!==ht}else{const Te=String(a||""),ht=String(k||"");q=Te!==ht}q?(H(null),b==null||b(k)):(H(null),m==null||m())},[i,a,k,b,m]),ue=d.useCallback(()=>{Z(a),H(null),m==null||m()},[a,m]),ve=d.useCallback(q=>{q.key==="Enter"?(q.preventDefault(),q.stopPropagation(),le()):q.key==="Escape"?(q.preventDefault(),q.stopPropagation(),ue()):q.key==="Tab"&&(q.preventDefault(),q.shiftKey?S==null||S():y==null||y(),le())},[le,ue,y,S]),ut=d.useCallback(q=>{q.stopPropagation(),le()},[le]),ze=d.useCallback(()=>{ee(!1)},[]),qe=d.useCallback(q=>{J.current=q,typeof z=="function"?z(q):z&&(z.current=q)},[z]),Pe=d.useMemo(()=>({variant:t,state:te,size:r,editable:o&&!p}),[t,te,r,o,p]),ae=d.useMemo(()=>Y.cn(Ah(Pe),p&&"opacity-50 cursor-not-allowed",e),[Pe,p,e]),ft=d.useMemo(()=>Y.cn("w-full h-8 border-none bg-transparent p-1 focus:ring-0 focus:ring-offset-0 text-sm",(j||l||c)&&"text-destructive"),[j,l,c]),yi=d.useMemo(()=>Y.cn("h-3 w-3 text-muted-foreground transition-opacity duration-200",U?"opacity-60":"opacity-0"),[U]);return u.jsxs("td",{ref:qe,className:ae,onClick:M,onDoubleClick:ne,onKeyDown:re,onMouseDown:$,onMouseEnter:Q,onMouseLeave:ze,tabIndex:I||o&&!p?0:void 0,role:I||o?"gridcell":"cell","aria-label":o&&!I?w?"Click to edit":"Double-click to edit":I?"Grid cell":void 0,title:X||void 0,style:{userSelect:I?"none":void 0,cursor:I?"cell":void 0,...G.style},...G,children:[s?u.jsxs("div",{className:"relative flex items-center gap-2",children:[u.jsx(oi,{ref:E,type:i,value:k,onChange:ie,onKeyDown:ve,onBlur:ut,placeholder:v,className:ft,"aria-invalid":!!X,"aria-describedby":X?`${G.id}-error`:void 0}),u.jsxs("div",{className:"flex items-center gap-1 opacity-40 text-xs",children:[u.jsx("span",{className:"text-green-600",children:"↵"}),u.jsx("span",{className:"text-red-600",children:"Esc"})]}),X&&u.jsxs(to,{children:[u.jsx(no,{asChild:!0,children:u.jsx(Er,{className:"h-4 w-4 text-destructive flex-shrink-0"})}),u.jsx(Fn,{side:"top",className:"max-w-xs",children:u.jsx("p",{className:"text-sm",children:X})})]})]}):u.jsxs("div",{className:"relative flex items-center justify-between group min-h-[1.5rem]",children:[u.jsx("span",{className:"flex-1 pr-8",children:P||a}),u.jsxs("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[X&&!s&&u.jsxs(to,{children:[u.jsx(no,{asChild:!0,children:u.jsx(Er,{className:"h-4 w-4 text-destructive flex-shrink-0"})}),u.jsx(Fn,{side:"top",className:"max-w-xs",children:u.jsx("p",{className:"text-sm",children:X})})]}),o&&!p&&!X&&u.jsx(rl,{className:yi})]})]}),X&&u.jsx("div",{id:`${G.id}-error`,className:"sr-only",role:"alert","aria-live":"polite",children:X}),L&&!X&&u.jsx("div",{className:"absolute top-1 right-1 pointer-events-none",children:u.jsx("div",{className:"bg-green-500 text-white rounded-full p-1 shadow-sm animate-in fade-in-0 zoom-in-95 duration-300",children:u.jsx(Ht,{className:"h-3 w-3"})})})]})});hi.displayName="TableCell";function jh({data:e,columns:t,sorting:n,selectedRows:r,showSelection:o=!0,showActions:s=!0,sortable:a=!0,isAllSelected:i,isIndeterminate:l,editingCell:c,recentlySavedCells:f=new Set,singleClickEdit:h=!1,validationErrors:v={},isRowCreated:g,isRowModified:b,isRowDeleted:m,onSelectAll:x,onRowSelectChange:p,onSort:w,onRowAction:y,onEditStart:S,onEditCancel:R,onCellEditComplete:I,onCellValueChange:N,onTabToNext:A,onTabToPrevious:V,currentPosition:D,isCellSelected:P,registerCellRef:O,onCellMouseDown:F,onCellKeyDown:T,onCellClick:W}){const _=(j,H)=>y("edit",j,H),G=(j,H)=>y("duplicate",j,H),z=(j,H)=>y("delete",j,H),k=d.useRef(null);d.useEffect(()=>{k.current&&D&&k.current.focus()},[D]),d.useEffect(()=>{const j=H=>{var E;const B=/Mac|iPod|iPhone|iPad/.test(navigator.userAgent)?H.metaKey:H.ctrlKey,U=document.activeElement;if((U===k.current||((E=k.current)==null?void 0:E.contains(U)))&&B&&T&&D&&["c","v","x"].includes(H.key.toLowerCase())){const J={key:H.key,code:H.code,ctrlKey:H.ctrlKey,metaKey:H.metaKey,shiftKey:H.shiftKey,altKey:H.altKey,preventDefault:()=>H.preventDefault(),stopPropagation:()=>H.stopPropagation(),currentTarget:U,target:U};T(D,J)}};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[T,D]);const Z=j=>`row-${j}`;return u.jsxs("div",{className:"rounded-lg border overflow-auto",children:[u.jsx("style",{children:`
.enhanced-grid {
user-select: none;
outline: none;
}
.enhanced-grid:focus {
outline: none;
}
.enhanced-grid .cell-selected {
background-color: #dbeafe !important;
}
.enhanced-grid .dark .cell-selected {
background-color: rgba(59, 130, 246, 0.3) !important;
}
.enhanced-grid .cell-range-selecting {
background-color: #bfdbfe !important;
}
.enhanced-grid .dark .cell-range-selecting {
background-color: rgba(59, 130, 246, 0.5) !important;
}
.enhanced-grid td {
cursor: cell;
position: relative;
}
/* 브라우저 기본 포커스 스타일 제거 - JavaScript로 제어 */
.enhanced-grid td:focus {
outline: none !important;
background-color: transparent !important;
}
.enhanced-grid td[tabindex="0"] {
outline: none !important;
}
.enhanced-grid td[tabindex="0"]:focus {
outline: none !important;
background-color: transparent !important;
}
`}),u.jsxs(ti,{ref:k,className:"enhanced-grid",tabIndex:0,role:"grid",onKeyDown:j=>{D&&T&&T(D,j)},children:[u.jsx(ni,{children:u.jsxs(Dn,{children:[o&&u.jsx(_t,{className:"w-12",children:u.jsx(xt,{checked:i,indeterminate:l,onCheckedChange:j=>{typeof j=="boolean"&&x(j)},"aria-label":"Select all rows"})}),t.map(j=>{const H=n.find(L=>L.id===j.id);return u.jsx(_t,{className:`
${a&&j.sortable?"cursor-pointer hover:bg-muted/50":""}
${j.headerClassName||""}
`,style:{textAlign:j.headerAlign||j.align||"left",width:j.width?`${j.width}px`:void 0,minWidth:j.minWidth?`${j.minWidth}px`:void 0,maxWidth:j.maxWidth?`${j.maxWidth}px`:void 0,flex:j.flex?j.flex:void 0},onClick:()=>{a&&j.sortable&&w(j.id)},children:u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx("span",{className:j.ellipsis?"truncate":"",children:j.header}),a&&j.sortable&&u.jsx("span",{className:"text-muted-foreground",children:H?H.desc?"↓":"↑":"↕️"})]})},j.id)}),s&&u.jsx(_t,{className:"w-12",children:"Actions"})]})}),u.jsx(ri,{children:e.map((j,H)=>{const L=j.id??H,B=Z(L);let U="transition-colors duration-200";return t.some(E=>{const J=`${L}-${E.id}`;return!!(v!=null&&v[J])})?U+=" bg-red-50 dark:bg-red-950/30 !border-l-4 !border-l-red-500 hover:bg-red-100 dark:hover:bg-red-950/50":m&&L!==void 0&&L!==null&&m(L)?U+=" bg-gray-100 dark:bg-gray-800/60 !border-l-4 !border-l-gray-400 opacity-60 hover:bg-gray-200 dark:hover:bg-gray-800/80":b&&L!==void 0&&L!==null&&b(L)?U+=" bg-green-50 dark:bg-green-950/30 !border-l-4 !border-l-green-500 hover:bg-green-100 dark:hover:bg-green-950/50":g&&L!==void 0&&L!==null&&g(L)&&(U+=" bg-blue-50 dark:bg-blue-950/30 !border-l-4 !border-l-blue-500 hover:bg-blue-100 dark:hover:bg-blue-950/50"),u.jsxs(Dn,{className:U,children:[o&&u.jsx(On,{children:u.jsx(xt,{checked:r.has(B),onCheckedChange:E=>{typeof E=="boolean"&&(p==null||p(B,E))},onClick:E=>{E.stopPropagation()},"aria-label":`Select row ${H+1}`})}),t.map((E,J)=>{var qe,Pe;const te=j[E.accessorKey],X=(c==null?void 0:c.rowId)===B&&(c==null?void 0:c.field)===E.id;let M=E.type&&["text","number","email"].includes(E.type);E.editable!==void 0&&(typeof E.editable=="function"?M=M&&E.editable(j,H):M=M&&E.editable);const $=`${L}-${E.id}`,Q=!!(v!=null&&v[$]),ne=v==null?void 0:v[$],re=E.cellClassName?typeof E.cellClassName=="function"?E.cellClassName(te,j):E.cellClassName:"",le=m&&L!==void 0&&L!==null&&m(L)?"line-through text-gray-500":"",ue={rowIndex:H,columnIndex:J},ve=(D==null?void 0:D.rowIndex)===H&&(D==null?void 0:D.columnIndex)===J,ut=P?P(ue):!1;let ze=`${re} ${le}`;return ve&&(ze+=" ring-2 ring-blue-500 ring-inset bg-blue-50 dark:bg-blue-900/20"),ut&&!ve&&(ze+=" bg-blue-100 dark:bg-blue-900/30"),u.jsx(hi,{ref:ae=>{O&&O(ue,ae)},tabIndex:0,variant:E.type==="number"?"numeric":"default",editable:M,value:te,inputType:E.type==="email"?"email":E.type==="number"?"number":"text",singleClickEdit:h,recentlySaved:f.has(`${B}-${E.id}`),isEditing:X,onEditStart:()=>M&&(S==null?void 0:S(B,E.id)),onEditEnd:ae=>I==null?void 0:I(B,E.id,ae),onEditCancel:R,onTabToNext:()=>A==null?void 0:A(B,E.id,e.length),onTabToPrevious:()=>V==null?void 0:V(B,E.id),validate:M&&E.validation?ae=>{const ft=Y.validateCellValue(ae,E,j);return ft||!0}:void 0,placeholder:`Enter ${E.header.toLowerCase()}`,hasError:Q,errorMessage:ne,onValueChange:N&&(((qe=E==null?void 0:E.validation)==null?void 0:qe.validateOn)==="realtime"||((Pe=E==null?void 0:E.validation)==null?void 0:Pe.validateOn)==="both")?ae=>(N(B,E.id,ae),E.validation&&Y.validateCellValue(ae,E,j)||null):void 0,enhancedMode:!0,onEnhancedMouseDown:ae=>{F&&F(ue,ae)},onEnhancedClick:ae=>{W&&W(ue,ae)},onEnhancedKeyDown:ae=>{T&&T(ue,ae)},className:ze,style:{textAlign:E.align||"left",width:E.width?`${E.width}px`:void 0,minWidth:E.minWidth?`${E.minWidth}px`:void 0,maxWidth:E.maxWidth?`${E.maxWidth}px`:void 0,flex:E.flex?E.flex:void 0},children:u.jsx("div",{className:`${E.ellipsis?"truncate":""} ${le}`,title:E.showTooltip&&E.ellipsis?String(te):void 0,children:E.type==="text"&&E.id==="status"?u.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${te==="active"?"bg-green-100 text-green-800 dark:bg-green-900/20 dark:text-green-400":"bg-gray-100 text-gray-800 dark:bg-gray-900/20 dark:text-gray-400"}`,children:te}):te})},E.id)}),s&&u.jsx(On,{children:u.jsxs(Qa,{children:[u.jsx(ei,{asChild:!0,children:u.jsx(we,{variant:"ghost",size:"icon",children:u.jsx(Bn,{className:"h-4 w-4"})})}),u.jsxs(vr,{align:"end",children:[u.jsx(Be,{onClick:()=>_(j,H),children:"Edit"}),u.jsx(Be,{onClick:()=>G(j,H),children:"Duplicate"}),u.jsx(Be,{className:"text-destructive",onClick:()=>z(j,H),children:"Delete"})]})]})})]},B)})})]})]})}function Dh({data:e,columns:t,sorting:n,selectedRows:r,virtualizationConfig:o,virtualization:s,containerRef:a,showSelection:i=!0,showActions:l=!0,sortable:c=!0,isAllSelected:f,isIndeterminate:h,isRowCreated:v,isRowModified:g,isRowDeleted:b,onSelectAll:m,onRowSelect:x,onSort:p,onRowAction:w}){return u.jsxs("div",{className:"rounded-lg border overflow-hidden",children:[u.jsx(Tu,{columns:t,sorting:n,showSelection:i,showActions:l,isAllSelected:f,isIndeterminate:h,onSelectAll:m,onSort:p,sortable:c}),u.jsx("div",{ref:a,className:"relative",style:{height:`${o.containerHeight}px`,overflowY:"auto",overflowX:"hidden"},children:u.jsx("div",{style:{height:`${s.scrollInfo.totalHeight}px`,position:"relative",width:"100%"},children:s.virtualItems.length===0?u.jsxs("div",{className:"p-4 text-center text-muted-foreground",children:[u.jsx("div",{children:"No virtual items to display"}),u.jsxs("div",{className:"text-xs mt-2",children:["Data length: ",e.length," | Container ref:"," ",a.current?"Yes":"No"]})]}):s.virtualItems.map(y=>{const S=e[y.index],R=S?S.id??y.index:y.index,I=io(R),N=r.has(I);return u.jsx(ah,{virtualItem:y,rowData:S,columns:t,showSelection:i,showActions:l,isSelected:N,isRowCreated:v,isRowModified:g,isRowDeleted:b,onRowSelect:x,onRowAction:w},`virt-${y.key}-${R}`)})})})]})}function pe({className:e,...t}){return u.jsx("div",{className:Y.cn("animate-pulse rounded-md bg-muted",e),...t})}function Oh({rows:e=5,columns:t=4,showHeader:n=!0,showControls:r=!0,className:o=""}){return u.jsxs("div",{className:`space-y-4 ${o}`,children:[n&&u.jsx("div",{className:"flex items-center justify-between",children:u.jsx(pe,{className:"h-6 w-48"})}),r&&u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(pe,{className:"h-4 w-16"}),u.jsx(pe,{className:"h-4 w-24"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(pe,{className:"h-8 w-20"}),u.jsx(pe,{className:"h-8 w-24"})]})]}),u.jsxs("div",{className:"border rounded-md",children:[u.jsx("div",{className:"border-b p-4",children:u.jsx("div",{className:"flex items-center gap-4",children:Array.from({length:t}).map((s,a)=>u.jsx(pe,{className:"h-4 flex-1"},`header-${a}`))})}),u.jsx("div",{className:"divide-y",children:Array.from({length:e}).map((s,a)=>u.jsx("div",{className:"p-4",children:u.jsx("div",{className:"flex items-center gap-4",children:Array.from({length:t}).map((i,l)=>u.jsx(pe,{className:"h-4 flex-1"},`cell-${a}-${l}`))})},`row-${a}`))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(pe,{className:"h-4 w-32"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(pe,{className:"h-8 w-8"}),u.jsx(pe,{className:"h-8 w-8"}),u.jsx(pe,{className:"h-8 w-8"}),u.jsx(pe,{className:"h-8 w-8"})]})]})]})}function _h({error:e,title:t="Something went wrong",onRetry:n,className:r=""}){return u.jsxs("div",{className:`flex flex-col items-center justify-center py-16 ${r} border rounded-md`,children:[u.jsx("div",{className:"mb-4 text-destructive",children:u.jsx(sl,{className:"h-12 w-12"})}),u.jsxs("div",{className:"text-center space-y-2",children:[u.jsx("h3",{className:"text-lg font-semibold text-foreground",children:t}),u.jsx("p",{className:"text-sm text-muted-foreground max-w-sm",children:e})]}),n&&u.jsx("div",{className:"mt-6",children:u.jsxs(we,{onClick:n,variant:"outline",className:"gap-2",children:[u.jsx(ol,{className:"h-4 w-4"}),"Try again"]})})]})}function Lh({title:e="No data available",description:t="There is no data to display at the moment.",icon:n,className:r=""}){return u.jsxs("div",{className:`flex flex-col items-center justify-center py-16 ${r} border rounded-md`,children:[n&&u.jsx("div",{className:"mb-4 text-muted-foreground",children:n}),!n&&u.jsx("div",{className:"mb-4 text-muted-foreground",children:u.jsx("svg",{className:"h-12 w-12",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-4.586a1 1 0 00-.707.293L16 14H8l-2.707-1.414A1 1 0 004.586 13H0"})})}),u.jsxs("div",{className:"text-center space-y-2",children:[u.jsx("h3",{className:"text-lg font-semibold text-foreground",children:e}),u.jsx("p",{className:"text-sm text-muted-foreground max-w-sm",children:t})]})]})}const At={sorting:!0,filtering:!0,pagination:{enabled:!0,pageSize:10,showPageSizeSelector:!0,showPageInfo:!0,showFirstLast:!0,siblingCount:1},editing:!0,selection:!0,globalSearch:!0},$n={enabled:!0,rowHeight:50,overscan:10,estimatedRowHeight:50,containerHeight:600};function Fh(e){return e?e===!0?$n:{...$n,...e}:null}function $h(e){const{data:t,columns:n,editable:r=!0,selectable:o=!0,sortable:s=!0,filterable:a=!0,pageSize:i=10,showPagination:l=!0,showGlobalSearch:c=!0,showPageSizeSelector:f=!0,pageSizeOptions:h,virtualized:v=!1,virtualRowHeight:g=50,virtualContainerHeight:b=600,onRowSelect:m,onCellEdit:x,onRowAction:p,...w}=e;return{initialData:t,columns:n,features:{sorting:s,filtering:a,pagination:l?{enabled:!0,pageSize:i,showPageSizeSelector:f,pageSizeOptions:h,showPageInfo:!0,showFirstLast:!0,siblingCount:1}:!1,editing:r,selection:o,globalSearch:c,virtualization:v?{enabled:!0,rowHeight:g,containerHeight:b,overscan:10}:!1},onRowSelect:m,onCellEdit:x,onRowAction:p,...w}}function zh(e){return{addRow:e.addRow,deleteRow:e.deleteRow,deleteRows:e.deleteRows,updateRow:e.updateRow,updateRows:e.updateRows,getSelectedRows:e.getSelectedRows,getSelectedIds:e.getSelectedIds,selectRow:e.selectRow,selectAll:e.selectAll,clearSelection:e.clearSelection,startEdit:e.startEdit,cancelEdit:e.cancelEdit,getChanges:e.getChanges,getChangesSummary:e.getChangesSummary,commitChanges:e.commitChanges,resetChanges:e.resetChanges,hasChanges:e.hasChanges,validateRow:t=>e.validateRow(t,"submit"),clearValidationErrors:e.clearAllValidationErrors,hasValidationErrors:e.hasValidationErrors}}const Vh=d.forwardRef((e,t)=>{if(!("features"in e)){const r=e,o=$h(r),s=lo(o),a=zh(s);return d.useImperativeHandle(t,()=>a,[a]),d.useEffect(()=>{r.onGridReady&&r.onGridReady(a)},[a,r.onGridReady]),u.jsx(ro,{...s.tableProps})}else return u.jsx(ro,{...e})});function ro({data:e,columns:t,features:n=At,className:r,style:o,title:s="LumGrid - Simple by Design, Profound by Nature",showHeader:a=!0,showControls:i=!0,loading:l,error:c,sorting:f=[],selectedRows:h=new Set,isAllSelected:v=!1,isIndeterminate:g=!1,selectedCount:b=0,totalCount:m=0,filteredCount:x=0,currentPage:p=0,totalPages:w=1,currentPageSize:y=10,editingCell:S,recentlySavedCells:R=new Set,singleClickEdit:I=!1,validationErrors:N={},onRowSelect:A,onSelectAll:V,onRowSelectChange:D,onSort:P,onPageChange:O,onPageSizeChange:F,onEditStart:T,onEditCancel:W,onCellEditComplete:_,onCellValueChange:G,isRowCreated:z,isRowModified:k,isRowDeleted:Z,leftSlot:j,rightSlot:H,centerSlot:L,currentPosition:B,selectedCell:U,isCellSelected:ee,registerCellRef:E,onCellMouseDown:J,onCellKeyDown:te,onCellClick:X}){var Pe;const M={...At,...n},$=Fh(M.virtualization),Q=!!($!=null&&$.enabled),ne=d.useRef(null),re=Ui({data:e,config:$||$n,containerRef:ne,enabled:Q}),ie=d.useMemo(()=>({totalCount:m||e.length,filteredCount:x||e.length}),[m,x,e.length]),le=d.useMemo(()=>!Q&&!!M.pagination&&(M.pagination===!0||typeof M.pagination=="object"&&M.pagination.enabled),[M.pagination,Q]),ue=d.useMemo(()=>{const ae=M.pagination;return ae?ae===!0?At.pagination:{...At.pagination,...ae}:{enabled:!1,pageSize:10,showPageSizeSelector:!1,showPageInfo:!1,showFirstLast:!1,siblingCount:1}},[M.pagination]),ve=()=>{ne.current&&(ne.current.scrollTop=0,re.scrollToTop())},ut=()=>{const ae=Math.floor(e.length/2);ne.current&&(ne.current.scrollTop=ae*50,re.scrollToIndex(ae))},ze=()=>{ne.current&&(ne.current.scrollTop=ne.current.scrollHeight-ne.current.clientHeight,re.scrollToBottom())},qe=()=>{const ae=Math.floor(Math.random()*e.length);ne.current&&(ne.current.scrollTop=ae*50,re.scrollToIndex(ae))};return l?u.jsx(Oh,{columns:t.length}):c?u.jsx(_h,{error:c}):e.length===0?u.jsx(Lh,{}):u.jsxs("div",{className:`space-y-4 ${r}`,style:o,children:[a&&u.jsx(fl,{title:s}),i&&u.jsx(yu,{totalCount:ie.totalCount,filteredCount:ie.filteredCount,selectedCount:b||0,features:{pageSizeSelector:typeof M.pagination=="object"&&((Pe=M.pagination)==null?void 0:Pe.showPageSizeSelector)},currentPageSize:y||10,pageSizeOptions:[5,10,20,50,100],onPageSizeChange:F,leftSlot:j,centerSlot:L,rightSlot:H}),Q&&u.jsx(Cu,{totalCount:e.length,visibleCount:re.virtualItems.length,scrollInfo:{visibleStartIndex:re.scrollInfo.visibleStartIndex,visibleEndIndex:re.scrollInfo.visibleEndIndex,totalHeight:re.scrollInfo.totalHeight},onScrollToTop:ve,onScrollToMiddle:ut,onScrollToBottom:ze,onScrollToRandom:qe}),Q?u.jsx(Dh,{data:e,columns:t,sorting:f,selectedRows:h,virtualizationConfig:$,virtualization:re,containerRef:ne,showSelection:M.selection,showActions:!0,sortable:M.sorting,isAllSelected:v,isIndeterminate:g,isRowCreated:z,isRowModified:k,isRowDeleted:Z,onSelectAll:V||(()=>{}),onRowSelect:D||(()=>{}),onSort:P||(()=>{}),onRowAction:()=>{}}):u.jsx(jh,{data:e,columns:t,sorting:f,selectedRows:h,showSelection:M.selection,showActions:!0,sortable:M.sorting,isAllSelected:v,isIndeterminate:g,editingCell:S,recentlySavedCells:R,singleClickEdit:I,validationErrors:N,isRowCreated:z,isRowModified:k,isRowDeleted:Z,onSelectAll:V||(()=>{}),onRowSelect:A||(()=>{}),onRowSelectChange:D||(()=>{}),onSort:P||(()=>{}),onRowAction:()=>{},onEditStart:T||(()=>{}),onEditCancel:W||(()=>{}),onCellEditComplete:_||(()=>{}),onCellValueChange:G,onTabToNext:()=>{},onTabToPrevious:()=>{},currentPosition:B,selectedCell:U,isCellSelected:ee,registerCellRef:E,onCellMouseDown:J,onCellKeyDown:te,onCellClick:X}),le&&u.jsx(yo,{currentPage:p||0,totalPages:w||1,pageSize:y||10,totalCount:ie.filteredCount,onPageChange:O||(()=>{}),onPageSizeChange:F||(()=>{}),showInfo:ue.showPageInfo,showFirstLast:ue.showFirstLast,siblingCount:ue.siblingCount})]})}var Bh=(e,t,n,r,o,s,a,i)=>{let l=document.documentElement,c=["light","dark"];function f(g){(Array.isArray(e)?e:[e]).forEach(b=>{let m=b==="class",x=m&&s?o.map(p=>s[p]||p):o;m?(l.classList.remove(...x),l.classList.add(s&&s[g]?s[g]:g)):l.setAttribute(b,g)}),h(g)}function h(g){i&&c.includes(g)&&(l.style.colorScheme=g)}function v(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)f(r);else try{let g=localStorage.getItem(t)||n,b=a&&g==="system"?v():g;f(b)}catch{}},oo=["light","dark"],mi="(prefers-color-scheme: dark)",Wh=typeof window>"u",pi=d.createContext(void 0),Kh=e=>d.useContext(pi)?d.createElement(d.Fragment,null,e.children):d.createElement(Gh,{...e}),Hh=["light","dark"],Gh=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:n=!0,enableColorScheme:r=!0,storageKey:o="theme",themes:s=Hh,defaultTheme:a=n?"system":"light",attribute:i="data-theme",value:l,children:c,nonce:f,scriptProps:h})=>{let[v,g]=d.useState(()=>Yh(o,a)),[b,m]=d.useState(()=>v==="system"?bn():v),x=l?Object.values(l):s,p=d.useCallback(R=>{let I=R;if(!I)return;R==="system"&&n&&(I=bn());let N=l?l[I]:I,A=t?Xh(f):null,V=document.documentElement,D=P=>{P==="class"?(V.classList.remove(...x),N&&V.classList.add(N)):P.startsWith("data-")&&(N?V.setAttribute(P,N):V.removeAttribute(P))};if(Array.isArray(i)?i.forEach(D):D(i),r){let P=oo.includes(a)?a:null,O=oo.includes(I)?I:P;V.style.colorScheme=O}A==null||A()},[f]),w=d.useCallback(R=>{let I=typeof R=="function"?R(v):R;g(I);try{localStorage.setItem(o,I)}catch{}},[v]),y=d.useCallback(R=>{let I=bn(R);m(I),v==="system"&&n&&!e&&p("system")},[v,e]);d.useEffect(()=>{let R=window.matchMedia(mi);return R.addListener(y),y(R),()=>R.removeListener(y)},[y]),d.useEffect(()=>{let R=I=>{I.key===o&&(I.newValue?g(I.newValue):w(a))};return window.addEventListener("storage",R),()=>window.removeEventListener("storage",R)},[w]),d.useEffect(()=>{p(e??v)},[e,v]);let S=d.useMemo(()=>({theme:v,setTheme:w,forcedTheme:e,resolvedTheme:v==="system"?b:v,themes:n?[...s,"system"]:s,systemTheme:n?b:void 0}),[v,w,e,b,n,s]);return d.createElement(pi.Provider,{value:S},d.createElement(Uh,{forcedTheme:e,storageKey:o,attribute:i,enableSystem:n,enableColorScheme:r,defaultTheme:a,value:l,themes:s,nonce:f,scriptProps:h}),c)},Uh=d.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:a,themes:i,nonce:l,scriptProps:c})=>{let f=JSON.stringify([n,t,s,e,i,a,r,o]).slice(1,-1);return d.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${Bh.toString()})(${f})`}})}),Yh=(e,t)=>{if(Wh)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},Xh=e=>{let t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},bn=e=>(e||(e=window.matchMedia(mi)),e.matches?"dark":"light");function qh({children:e,...t}){return u.jsx(Kh,{...t,children:e})}function gi(e){var D;if(!e.rowManager)throw new Error("useGridState: rowManager is required");const t=C.useMemo(()=>e.initialSorting||[],[e.initialSorting]),n=C.useMemo(()=>e.initialFiltering||{},[e.initialFiltering]),r=C.useMemo(()=>{var P;return{pageIndex:0,pageSize:10,totalCount:((P=e.rowManager)==null?void 0:P.getLength())||0,...e.initialPagination}},[e.initialPagination,e.rowManager]),[o,s]=C.useState(t),[a,i]=C.useState(n),[l,c]=C.useState(r),[f,h]=C.useState(0),v=C.useMemo(()=>{if(o.length===0)return;const P=o[0],O=e.columns.find(F=>F.id===P.id);if(O)return e.rowManager.sort((F,T)=>{let W=F[O.accessorKey],_=T[O.accessorKey];if(O.sortFn){const G=O.sortFn(W,_);return P.desc?-G:G}return W==null&&(W=""),_==null&&(_=""),W<_?P.desc?1:-1:W>_?P.desc?-1:1:0})},[e.rowManager,e.columns,o,e.dataVersion]),g=C.useMemo(()=>{const P=Object.keys(a);return P.length===0?v:e.rowManager.filter((O,F)=>P.every(T=>{const W=e.columns.find(Z=>Z.id===T);if(!W)return!0;const _=O[W.accessorKey],G=a[T];if(W.filterFn)return W.filterFn(_,G);if(G==null||G==="")return!0;const z=String(_||"").toLowerCase(),k=String(G).toLowerCase();return z.includes(k)}))},[e.rowManager,e.columns,a,v,e.dataVersion]),{displayIndices:b,filteredCount:m}=C.useMemo(()=>{var z;const P=((z=e.rowManager)==null?void 0:z.getLength())||0,O=g||Array.from({length:P},(k,Z)=>Z),F=O.length,T=l.pageSize+f,W=l.pageIndex*l.pageSize,_=W+T;return{displayIndices:O.slice(W,_),filteredCount:F}},[g,e.rowManager,l,f,e.dataVersion]),x=C.useMemo(()=>Math.ceil(m/l.pageSize),[m,l.pageSize]);C.useEffect(()=>{var O;const P=(g==null?void 0:g.length)||((O=e.rowManager)==null?void 0:O.getLength())||0;if(P>0){const F=Math.max(0,Math.ceil(P/l.pageSize)-1);l.pageIndex>F&&c(T=>({...T,pageIndex:F}))}},[g,l.pageSize,l.pageIndex,e.rowManager,e.dataVersion]);const p=C.useCallback(P=>{s(O=>{const F=O.find(T=>T.id===P);return F?F.desc?[]:[{id:P,desc:!0}]:[{id:P,desc:!1}]})},[]),w=C.useCallback((P,O)=>{i(F=>{const T={...F};return!O||O===""?delete T[P]:T[P]=O,T}),c(F=>({...F,pageIndex:0}))},[]),y=C.useCallback(P=>{c(O=>{var _;const F=(g==null?void 0:g.length)||((_=e.rowManager)==null?void 0:_.getLength())||0,T=Math.max(0,Math.ceil(F/P)-1),W=Math.max(0,Math.min(O.pageIndex,T));return{...O,pageSize:P,pageIndex:W}})},[g,e.rowManager,e.dataVersion]),S=C.useCallback(()=>{s([])},[]),R=C.useCallback(()=>{i({}),c(P=>({...P,pageIndex:0}))},[]),I=C.useCallback(()=>{h(P=>P+1)},[]),N=C.useCallback(()=>{h(P=>Math.max(0,P-1))},[]),A=C.useCallback(()=>{s([]),i({}),c(P=>({...P,pageIndex:0})),h(0)},[]),V=C.useCallback(P=>{h(0),c(O=>{var _;const F=(g==null?void 0:g.length)||((_=e.rowManager)==null?void 0:_.getLength())||0,T=Math.max(0,Math.ceil(F/O.pageSize)-1),W=Math.max(0,Math.min(P,T));return{...O,pageIndex:W}})},[g,e.rowManager,e.dataVersion]);return{sorting:o,filtering:a,pagination:l,displayIndices:b,totalCount:((D=e.rowManager)==null?void 0:D.getLength())||0,filteredCount:m,totalPages:x,temporaryPageSizeIncrease:f,handleSort:p,handleFilter:w,handlePageChange:V,handlePageSizeChange:y,handleTemporaryPageSizeIncrease:I,handleTemporaryPageSizeDecrease:N,clearSorting:S,clearFiltering:R,clearAll:A}}function vi({rowManager:e,displayData:t=[],onRowSelect:n}){const[r,o]=C.useState(new Set),s=C.useCallback(()=>{const v=[];return r.forEach(g=>{let b;if(g.startsWith("row-")){const x=g.replace("row-","");b=isNaN(Number(x))?x:Number(x)}else b=isNaN(Number(g))?g:Number(g);const m=e.getRowById(b);m?v.push(m):process.env.NODE_ENV==="development"&&console.warn("Could not find data for selected key:",g,"actual ID:",b)}),v},[e,r]),a=C.useCallback(()=>{const v=[];return r.forEach(g=>{if(g.startsWith("row-")){const b=g.replace("row-",""),m=isNaN(Number(b))?b:Number(b);v.push(m)}else{const b=isNaN(Number(g))?g:Number(g);v.push(b)}}),v},[r]),i=C.useCallback((v,g)=>{o(b=>{const m=new Set(b);if(g?m.add(v):m.delete(v),n){const x=[];m.forEach(p=>{const w=p.replace("row-",""),y=isNaN(Number(w))?w:Number(w),S=e.getRowById(y);S?x.push(S):console.warn("Could not find row for key:",p,"parsed ID:",y)}),n(x)}return m})},[e,n]),l=C.useCallback(v=>{if(v){const g=t.map((b,m)=>{const x=e.getRowIdByData(b);return x?`row-${x}`:`row-${m}`});o(b=>{const m=new Set(b);return g.forEach(x=>m.add(x)),m})}else{const g=t.map((b,m)=>{const x=e.getRowIdByData(b);return x?`row-${x}`:`row-${m}`});o(b=>{const m=new Set(b);return g.forEach(x=>m.delete(x)),m})}if(n){const g=s();n(g)}},[t,e,n,s]),c=C.useCallback(()=>{o(new Set),n&&n([])},[n]),{isAllSelected:f,isIndeterminate:h}=C.useMemo(()=>{const g=t.map(y=>e.getRowIdByData(y)).filter(y=>y!==void 0).map(y=>`row-${y}`),b=Array.from(r),m=g.filter(y=>b.includes(y)).length,x=g.length;if(x===0)return{isAllSelected:!1,isIndeterminate:!1};const p=m===x&&m>0,w=m>0&&m<x;return{isAllSelected:p,isIndeterminate:w}},[t,e,r]);return{selectedRowIds:r,isAllSelected:f,isIndeterminate:h,handleRowSelect:i,handleSelectAll:l,clearSelection:c,getSelectedData:s,getSelectedRowIds:a}}function xi({columns:e,onCellEdit:t,data:n=[]}){const[r,o]=C.useState(null),[s,a]=C.useState(new Set),[i,l]=C.useState(!1),c=C.useCallback(()=>e.filter(p=>p.type&&["text","number","email"].includes(p.type)),[e]),f=C.useCallback((p,w,y)=>{const S=Ni(p,n);t&&S>=0&&t(S,w,y),o(null);const R=`${p}-${w}`;a(I=>new Set([...I,R])),setTimeout(()=>{a(I=>{const N=new Set(I);return N.delete(R),N})},1e3)},[t,n]),h=C.useCallback((p,w)=>{o({rowId:p,field:w})},[]),v=C.useCallback(()=>{o(null)},[]),g=C.useCallback((p,w,y)=>{const S=c(),R=S.findIndex(I=>I.id===w);if(R<S.length-1)o({rowId:p,field:S[R+1].id});else{const I=Ii(p,n);I&&o({rowId:I,field:S[0].id})}},[c,n]),b=C.useCallback((p,w)=>{const y=c(),S=y.findIndex(R=>R.id===w);if(S>0)o({rowId:p,field:y[S-1].id});else{const R=Ei(p,n);R&&o({rowId:R,field:y[y.length-1].id})}},[c,n]),m=C.useCallback(p=>{const w=String(p);return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w)||"Please enter a valid email address"},[]),x=C.useCallback(p=>{const w=Number(p);return w>0&&w<120||"Age must be between 1 and 119"},[]);return{editingCell:r,recentlySavedCells:s,singleClickEdit:i,setEditingCell:o,setSingleClickEdit:l,handleCellEdit:f,handleEditStart:h,handleEditCancel:v,handleTabToNext:g,handleTabToPrevious:b,getEditableColumns:c,validateEmail:m,validateAge:x}}function wi({onRowAction:e}){const t=C.useCallback((a,i,l)=>{e&&e(a,i,l)},[e]),n=C.useCallback((a,i)=>{t("edit",a,i)},[t]),r=C.useCallback((a,i)=>{t("duplicate",a,i)},[t]),o=C.useCallback((a,i)=>{t("delete",a,i)},[t]),s=C.useCallback((a,i,l)=>{t(a,i,l)},[t]);return{handleRowAction:t,handleEdit:n,handleDuplicate:r,handleDelete:o,handleCustomAction:s}}function bi({config:e,initialPagination:t={},initialSorting:n=[],initialFiltering:r={},initialGlobalSearch:o=""}){const[s,a]=C.useState([]),[i,l]=C.useState(0),[c,f]=C.useState(0),[h,v]=C.useState({pageIndex:0,pageSize:10,...t}),[g,b]=C.useState(n),[m,x]=C.useState(r),[p,w]=C.useState(o),[y,S]=C.useState({loading:!1,error:null,lastRequest:null,retryCount:0}),R=C.useRef(new Map),I=C.useRef(null),N=C.useRef(null),A=C.useMemo(()=>Math.ceil(c/h.pageSize),[c,h.pageSize]),V=C.useCallback(()=>({pagination:{page:h.pageIndex,pageSize:h.pageSize},sorting:g,filtering:m,globalSearch:p}),[h,g,m,p]),D=C.useCallback(L=>{var B;return(B=e.caching)!=null&&B.keyGenerator?e.caching.keyGenerator(L):JSON.stringify({page:L.pagination.page,pageSize:L.pagination.pageSize,sorting:L.sorting,filtering:L.filtering,globalSearch:L.globalSearch})},[e.caching]),P=C.useCallback(L=>{var J;if(!((J=e.caching)!=null&&J.enabled))return null;const B=D(L),U=R.current.get(B);if(!U)return null;const ee=e.caching.ttl||5*60*1e3;return Date.now()-U.timestamp>ee?(R.current.delete(B),null):U.data},[e.caching,D]),O=C.useCallback((L,B)=>{var ee;if(!((ee=e.caching)!=null&&ee.enabled))return;const U=D(L);R.current.set(U,{data:B,timestamp:Date.now()})},[e.caching,D]),F=C.useCallback(L=>{var U;const B={message:L.message||"An error occurred while loading data",code:L.code,details:L};S(ee=>({...ee,loading:!1,error:B,retryCount:ee.retryCount+1})),(U=e.onError)==null||U.call(e,B)},[e.onError]),T=C.useCallback(async()=>{var U,ee;const L=V(),B=P(L);if(B){a(B.data),l(B.totalCount),f(B.filteredCount);return}N.current&&N.current.abort(),N.current=new AbortController,S(E=>({...E,loading:!0,error:null,lastRequest:L})),(U=e.onLoadingChange)==null||U.call(e,!0);try{const E=await e.onDataLoad(L);if(!E||typeof E!="object")throw new Error("Invalid response format");a(E.data||[]),l(E.totalCount||0),f(E.filteredCount||E.totalCount||0),O(L,E),S(J=>({...J,loading:!1,error:null,retryCount:0}))}catch(E){E.name!=="AbortError"&&F(E)}finally{(ee=e.onLoadingChange)==null||ee.call(e,!1),N.current=null}},[V,P,O,e,F]),W=C.useCallback(async L=>{b(B=>{const U=B.find(E=>E.id===L);let ee;return U?U.desc?ee=[]:ee=[{id:L,desc:!0}]:ee=[{id:L,desc:!1}],ee}),v(B=>({...B,pageIndex:0}))},[]),_=C.useCallback(async(L,B)=>{x(U=>{const ee={...U};return!B||B===""?delete ee[L]:ee[L]=B,ee}),v(U=>({...U,pageIndex:0}))},[]),G=C.useCallback(async L=>{v(B=>({...B,pageIndex:L}))},[]),z=C.useCallback(async L=>{v(B=>({...B,pageSize:L,pageIndex:0}))},[]),k=C.useCallback(async L=>{I.current&&clearTimeout(I.current);const B=e.debounceMs||300;w(L),I.current=setTimeout(()=>{v(U=>({...U,pageIndex:0}))},B)},[e.debounceMs]),Z=C.useCallback(async()=>{var L;(L=e.caching)!=null&&L.enabled&&R.current.clear(),await T()},[T,e.caching]),j=C.useCallback(async()=>{await T()},[T]),H=C.useCallback(()=>{S(L=>({...L,error:null}))},[]);return C.useEffect(()=>{e.enabled&&T()},[e.enabled,h,g,m,p,T]),C.useEffect(()=>()=>{I.current&&clearTimeout(I.current),N.current&&N.current.abort()},[]),{data:s,totalCount:i,filteredCount:c,totalPages:A,pagination:h,sorting:g,filtering:m,globalSearch:p,serverState:y,loadData:T,handleSort:W,handleFilter:_,handlePageChange:G,handlePageSizeChange:z,handleGlobalSearch:k,refresh:Z,retry:j,clearError:H,getCurrentRequest:V}}exports.Button=we;exports.LumGrid=Vh;exports.LumPagination=yo;exports.RowManager=ao;exports.ThemeProvider=qh;exports.TooltipProvider=Th;exports.useGridAPI=lo;exports.useGridActions=wi;exports.useGridEditing=xi;exports.useGridSelection=vi;exports.useGridState=gi;exports.useServerSide=bi;
//# sourceMappingURL=use-server-side-EJTVvoFd.js.map