@sheetxl/grid-react 0.8.0-beta.2 → 0.8.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  (function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`._grid-stage_rzp9d_1{width:100%;height:100%;position:absolute;top:0;left:0}._grid-stage_rzp9d_1>*{pointer-events:none;position:absolute;inset:0}._grid-stage_rzp9d_1>*>*{pointer-events:auto}._sheetxl-grid_5yo0n_7{box-sizing:border-box;user-select:none;contain:strict;width:100%;height:100%;position:relative}._sheetxl-grid_5yo0n_7 *{box-sizing:border-box!important}._sheetxl-grid_5yo0n_7 :focus{outline:none}._sheetxl-grid_5yo0n_7>*{contain:size layout style}._virtual-div_16eab_1{position:absolute}._tiles_ikr1b_7{will-change:transform}._tiles_ikr1b_7 .tile{white-space:pre;position:absolute}._tiles_ikr1b_7 .tile>*{contain:strict;position:absolute}._gridlines_ikr1b_26,._gridlines_ikr1b_26 *{pointer-events:none;position:absolute;overflow:visible}.cell{letter-spacing:-.25px;padding:2px 4px;font-family:Calibri;line-height:1.2}._search_b1nag_5{box-sizing:border-box;width:100%;min-width:0;font:inherit;color:inherit;background:light-dark(#fff,#2b2b2b);border:1px solid light-dark(#c4c4c4,#5a5a5a);border-radius:2px;outline:none;margin:0;padding:3px 8px}._search_b1nag_5:focus{border-color:var(--sxl-color-primary,#0078d7)}._search_b1nag_5::placeholder{opacity:.6}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
2
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(o,s,c)=>(c=o==null?{}:e(i(o)),((e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c,l=r(i),u=0,d=l.length;u<d;u++)c=l[u],a.call(e,c)||c===o||t(e,c,{get:(e=>i[e]).bind(null,c),enumerable:!(s=n(i,c))||s.enumerable});return e})(!s&&o&&o.__esModule?c:t(c,`default`,{value:o,enumerable:!0}),o));let s=require("react");s=o(s,1);let c=require("react/jsx-runtime"),l=require("@sheetxl/utils-react"),u=require("@sheetxl/utils"),d=require("react-dom");d=o(d,1);var f=(e,t)=>{if(typeof t==`number`){let n=t;return{getOffset:e=>e<=0?0:e*n,getIndex:t=>t<=0?0:Math.min(e,Math.floor(t/n))}}let n=t,r=[],i=-1,a=e=>e<=0?0:((e=>{if(e<=i)return;let t=i>=0?r[i]+n(i):0;for(let a=i+1;a<=e;a++)r[a]=t,t+=n(a);i=e})(e),r[e]),o=(e,t,n)=>{for(;e<=t;){let r=e+(t-e>>1);a(r)<=n?e=r+1:t=r-1}return e>0?e-1:0};return{getOffset:a,getIndex:t=>{if(t<=0||e<=0)return 0;if((i>0?r[i]:0)>t)return o(0,i,t);let s=i>0?i:0,c=1;for(;s<e&&a(s)<=t;)s+=c,c*=2;if(s>=e){let r=e-1;if(t>=a(r)+n(r))return e}return o(Math.floor(s/2),Math.min(s,e-1),t)}}},p=e=>{let t=e!=null,n=e?.rowCount??0,r=e?.columnCount??0,i=e?.getRowHeight,a=e?.getColumnWidth;return(0,s.useMemo)(()=>{if(!t)return null;let e=f(n,i??20),o=f(r,a??75);return{getColOffset:o.getOffset,getColIndex:o.getIndex,getRowOffset:e.getOffset,getRowIndex:e.getIndex}},[t,n,r,i,a])},m=(0,s.createContext)(null),h=()=>(0,s.useContext)(m),g=e=>{let{linePoints:t,bounds:n,propsPath:r,style:i,...a}=e;return n?(0,c.jsx)(`svg`,{width:`${n.width}`,height:`${n.height}`,viewBox:`0 0 ${n.width} ${n.height}`,style:{position:`absolute`,left:`${n.x}px`,top:`${n.y}px`,width:`${n.width}px`,height:`${n.height}px`,overflow:`visible`,pointerEvents:`none`,transitionTimingFunction:`linear`,transitionProperty:`left, top, width, height`,willChange:`left, top, width, height, stroke-dashoffset`,...i},...a,children:(0,c.jsx)(`path`,{d:`M ${t[0]} ${t[1]} L ${t[2]} ${t[3]}`,fill:`none`,vectorEffect:`non-scaling-stroke`,stroke:`black`,...r})}):null},_=(0,s.memo)(e=>{let{bounds:t,fill:n,stroke:r,alignWidth:i=1,disableAlign:a=!1,disableEdgeAware:o=!1,inset:u=0,hole:d,animatedStroke:f,animatedTransition:p,strokeDasharray:m,strokeDashoffset:g,propsFillPath:_,propsStrokePath:b,className:S,style:C,propsRoot:w}=e,T=h(),E=t??T;if((0,s.useEffect)(()=>{f&&x()},[f]),!E)return null;let D=l.ReactUtils.getDevicePixelRatio(),O=a?i:i/D,k,A,j,M,N,P,F;if(a)k=E.x,A=E.y,j=E.x+E.width,M=E.y+E.height;else{let e=e=>o?l.ReactUtils.snapLineCenter(e,O,D):l.ReactUtils.edgeCenter(e,`leading`,i,D),t=e=>o?l.ReactUtils.snapLineCenter(e,O,D):l.ReactUtils.edgeCenter(e,`trailing`,i,D),n=u/D;k=e(E.x+n),A=e(E.y+n),j=t(E.x+E.width-n),M=t(E.y+E.height-n)}if(d)if(a)N=d;else{let e=l.ReactUtils.snapDeviceEdge(d.x,D),t=l.ReactUtils.snapDeviceEdge(d.y,D);N={x:e,y:t,width:l.ReactUtils.snapDeviceEdge(d.x+d.width,D)-e,height:l.ReactUtils.snapDeviceEdge(d.y+d.height,D)-t}}if(f){let e={dashGap:2,speed:50,dashLength:8,gapColor:`var(--sxl-color-base-100, #fff)`,...typeof f==`object`?f:void 0},t=e.dashGap+e.dashLength;P={strokeDasharray:`${e.dashLength}px ${e.dashGap}px`,strokeDashoffset:`${t}px`,animation:`${y} ${e.speed*t}ms linear infinite`,willChange:`stroke-dashoffset`},F=e.gapColor}let I=p?`d 60ms ease-in-out`:`none`,L=null;if(n){let e=v({top:A,left:k,bottom:M,right:j});N&&(e+=` `+v({top:N.y,left:N.x,bottom:N.y+N.height,right:N.x+N.width})),L=(0,c.jsx)(`path`,{style:{d:`path("${e}")`,transition:I,fill:n,..._?.style},stroke:`none`,fillRule:`evenodd`},`fill`)}let R=null;if(r&&i){let e=v({top:A,left:k,right:j,bottom:M});R=(0,c.jsxs)(c.Fragment,{children:[F&&(0,c.jsx)(`path`,{fill:`none`,vectorEffect:`non-scaling-stroke`,strokeWidth:O,style:{d:`path("${e}")`,transition:I,stroke:F}},`stroke-under`),(0,c.jsx)(`path`,{fill:`none`,strokeDasharray:m,strokeDashoffset:g,vectorEffect:`non-scaling-stroke`,strokeWidth:O,...b,style:{d:`path("${e}")`,transition:I,stroke:r,...P,...b?.style}},`stroke`)]})}return(0,c.jsxs)(`svg`,{className:S,width:`100%`,height:`100%`,style:{position:`absolute`,left:0,top:0,pointerEvents:`none`,overflow:`visible`,willChange:f||p?`d, stroke-dashoffset`:void 0,...C},...w,children:[L,R]})});_.displayName=`RectangleSVG`;var v=(e,t=!0)=>`M ${e.left} ${e.top} L ${e.right} ${e.top} L ${e.right} ${e.bottom} L ${e.left} ${e.bottom} L ${e.left} ${e.top} ${t?`Z`:``}`,y=`sxl-marching-ants`,b=!1,x=()=>{if(b||typeof document>`u`)return;b=!0;let e=document.createElement(`style`);e.appendChild(document.createTextNode(`@keyframes ${y} { to { stroke-dashoffset: 0; } }`)),document.head.appendChild(e)};function S(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=S(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function C(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=S(e))&&(r&&(r+=` `),r+=t);return r}var w=(e,t,n)=>Math.min(n,Math.max(t,e)),T=(e,t,n)=>{let r=[],i=t;for(;i<=n;){let t=e?Math.max(0,e(i)):0;t===0?(r.push(i),i++):i+=t}return r},E=(e,t,n,r,i,a)=>{if(n-t>=i-r)return r;let o=r;return e===`nearest`&&(r-t>0?e=`start`:n-i>0&&(e=`end`)),e===`start`?o=t:e===`end`?o=n-(i-r):e===`center`&&(o=t+(n-t)/2-(i-r)/2),o<r?Math.max(0,o):o>r?Math.min(o,a-(i-r)):void 0},D=(e,t=!1,n,r)=>{if(!n)return 0;let i=!t,a=i?1:-1,o=n(i?e:e+1),s=n(i?e+1:e),c=e+(i?2:-1),l=0;for(;(s-o)*a<=0;){if(i&&c-1>r+1||!i&&c+1<r)return l;o=s,s=n(c),c+=a,l++}return l},O=(e,t,n)=>{if(!n)return!1;let r=n.x;if(e<r||e>r+n.width)return!1;let i=n.y;return!(t<i||t>i+n.height)},k=`_grid-stage_rzp9d_1`,A={pointerdown:`onPointerDown`,pointermove:`onPointerMove`,pointerup:`onPointerUp`,mousedown:`onMouseDown`,mousemove:`onMouseMove`,mouseup:`onMouseUp`,mouseover:`onMouseOver`,mouseout:`onMouseOut`,dblclick:`onDoubleClick`,contextmenu:`onContextMenu`},j=Object.values(A),M=[...Object.keys(A),`keydown`,`keypress`,`keyup`],N=new Set(M),P=e=>{let t=e?.getElement();return t&&typeof t.isStage==`function`&&t.isStage()?t:null},F=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{className:n,onFocus:r,onBlur:i,children:a,...o}=e,u=W(),d=(0,s.useRef)(u);d.current=u;let f=(0,s.useRef)(new Set),p=(0,s.useRef)(0),m=(0,s.useCallback)(e=>{let t={responder:e,seq:p.current++};return f.current.add(t),()=>{f.current.delete(t)}},[]),h=(0,s.useRef)(new Set),g=(0,s.useRef)(0),_=(0,s.useCallback)(e=>(h.current.add(e),e.hasHandlers&&g.current++,()=>{h.current.delete(e),e.hasHandlers&&g.current--}),[]),v=(0,s.useRef)(null),y=(0,s.useRef)(0),b=(0,s.useCallback)((e,t)=>{let n=v.current;if(n&&n.x===e&&n.y===t)return n.stack;let r=document.elementsFromPoint(e,t);return v.current={x:e,y:t,stack:r},y.current||typeof requestAnimationFrame!=`function`||(y.current=requestAnimationFrame(()=>{y.current=0,v.current=null})),r},[]);(0,s.useEffect)(()=>()=>{y.current&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(y.current)},[]);let x=(0,s.useCallback)((e,t,n)=>{if(!t&&!n)return()=>{};let r=(e,r)=>{t?.(e),n?.(e,r)};return m({getHandler:t=>t===e?r:void 0})},[m]),S=(0,s.useCallback)(e=>{if(!e||e===ce.current)return-1/0;let t=new Map;if(f.current.forEach(e=>{let n=e.responder.getElement?.();n&&t.set(n,e.responder.zIndex??0)}),t.size===0)return-1/0;let n=e;for(;n;){let e=t.get(n);if(e!==void 0)return e;if(n===ce.current)break;n=n.parentElement}return-1/0},[]),w=(0,s.useCallback)((e,t,n)=>{if(A[e]===void 0||g.current===0)return I;let r=t.nativeEvent;if(typeof r?.clientX!=`number`||typeof r?.clientY!=`number`)return I;let i=new Map;if(h.current.forEach(e=>{if(!e.hasHandlers||!e.getHandler)return;let t=e.getElement();t&&i.set(t,e)}),i.size===0)return I;let a=e=>{let t=e;for(;t;){if(i.has(t))return t;if(t===ce.current)break;t=t.parentElement}return null},o=a(t.target),s=e===`pointermove`||e===`mousemove`,c=s?b(r.clientX,r.clientY):document.elementsFromPoint(r.clientX,r.clientY),l=[],u=new Set;for(let e=0;e<c.length;e++){let t=a(c[e]);if(!t||u.has(t)||(u.add(t),t===o))continue;let r=i.get(t),s=r.zIndex??0;s>=n||l.push({slot:s,box:!0,ord:e,getHandler:r.getHandler})}return o&&!u.has(o)&&s?I:l},[b]),T=(0,s.useCallback)((e,t,n)=>{let r=ce.current;if(r&&t.target instanceof Node&&!r.contains(t.target))return;let i=N.has(e)?S(t.target):1/0,a=[...w(e,t,i)];if(f.current.forEach(e=>{let t=e.responder.zIndex??0;t>=i||a.push({slot:t,box:!1,ord:-e.seq,getHandler:t=>e.responder.getHandler(t)})}),a.length===0)return;a.sort((e,t)=>t.slot-e.slot||!e.box-+!t.box||e.ord-t.ord);let o=a.length;for(let r=0;r<o&&!t.isPropagationStopped();r++)a[r].getHandler(e)?.(t,n)},[w,S]);(0,s.useEffect)(()=>{let e=ce.current;if(!e)return;let t=t=>{let n=t.type,r=S(t.target),i=[];if(f.current.forEach(e=>{(e.responder.zIndex??0)>r&&i.push(e)}),i.length===0)return;i.sort((e,t)=>(t.responder.zIndex??0)-(e.responder.zIndex??0)||t.seq-e.seq);let a=L(t,e);for(let e=0;e<i.length&&!a.isPropagationStopped();e++)i[e].responder.getHandler(n)?.(a,d.current)};for(let n=0;n<M.length;n++)e.addEventListener(M[n],t,!0);return()=>{for(let n=0;n<M.length;n++)e.removeEventListener(M[n],t,!0)}},[S]);let E=(0,l.useCallbackRef)(e=>{T(`pointerdown`,e,d.current)},[]),D=(0,l.useCallbackRef)(e=>{T(`pointermove`,e,d.current)},[]),O=(0,l.useCallbackRef)(e=>{T(`pointerup`,e,d.current)},[]),j=(0,l.useCallbackRef)(e=>{T(`pointerleave`,e,d.current)},[]),P=(0,l.useCallbackRef)(e=>{T(`mousedown`,e,d.current)},[]),F=(0,l.useCallbackRef)(e=>{T(`mouseenter`,e,d.current)},[]),R=(0,l.useCallbackRef)(e=>{T(`mouseleave`,e,d.current)},[]),ee=(0,l.useCallbackRef)(e=>{T(`mousemove`,e,d.current)},[]),te=(0,l.useCallbackRef)(e=>{T(`mouseout`,e,d.current)},[]),ne=(0,l.useCallbackRef)(e=>{T(`mouseover`,e,d.current)},[]),re=(0,l.useCallbackRef)(e=>{T(`mouseup`,e,d.current)},[]),z=(0,l.useCallbackRef)(e=>{T(`dblclick`,e,d.current)},[]),ie=(0,l.useCallbackRef)(e=>{T(`keydown`,e,d.current)},[]),B=(0,l.useCallbackRef)(e=>{T(`keypress`,e,d.current)},[]),ae=(0,l.useCallbackRef)(e=>{T(`keyup`,e,d.current)},[]),V=(0,l.useCallbackRef)(e=>{r?.(e),T(`focus`,e,d.current)},[r]),oe=(0,l.useCallbackRef)(e=>{i?.(e),T(`blur`,e,d.current)},[i]),se=(0,l.useCallbackRef)(e=>{T(`contextmenu`,e,d.current)},[]),ce=(0,l.useImperativeElement)(t,()=>({isStage:()=>!0,addReactEventListener:x,registerResponder:m,registerLayer:_}),[]);return(0,s.useEffect)(()=>_({getElement:()=>ce.current}),[_]),(0,c.jsx)(`div`,{className:C(n,`stage`,k),ref:ce,tabIndex:0,...o,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerLeave:j,onMouseDown:P,onMouseEnter:F,onMouseLeave:R,onMouseMove:ee,onMouseOut:te,onMouseOver:ne,onMouseUp:re,onDoubleClick:z,onKeyDown:ie,onKeyUp:ae,onKeyPress:B,onFocus:V,onBlur:oe,onContextMenu:se,children:a})}));F.displayName=`Stage`;var I=Object.freeze([]),L=(e,t)=>{let n=!1;return new Proxy(e,{get(r,i){switch(i){case`nativeEvent`:return e;case`currentTarget`:return t;case`stopPropagation`:return()=>{n=!0,e.stopPropagation()};case`isPropagationStopped`:return()=>n;case`preventDefault`:return()=>e.preventDefault();case`isDefaultPrevented`:return()=>e.defaultPrevented;case`persist`:return()=>{};default:{let e=r[i];return typeof e==`function`?e.bind(r):e}}}})},R=e=>`${e.rowStart},${e.colStart},${e.rowEnd},${e.colEnd}`,ee=(0,s.createContext)(0),te=(0,s.createContext)(!1),ne=(e,t)=>{let{rowDims:n,columnDims:r,computeRowDims:i,computeColumnDims:a,viewport:o,zoom:s,containerWidth:c,containerHeight:l,getRangeFromCell:u,invalidate:d,totalRange:f,getSurfacePointFromPointer:p,scrollTo:m,scrollCellCoordsIntoView:h,getAllPanes:g}=t,_=e.anchor,v=n[e.rowIndex],y=r[e.columnIndex];if(v.minIndex>v.maxIndex||y.minIndex>y.maxIndex)return null;let b=e.scrollOrientation,x=Object.freeze({x:y.minBounds,y:v.minBounds,width:y.maxBounds,height:v.maxBounds}),S=Object.freeze({colStart:y.minCoord,rowStart:v.minCoord,colEnd:y.maxCoord,rowEnd:v.maxCoord}),C={width:y.maxVirtualBounds,height:v.maxVirtualBounds},w={left:y.freezeOffset,top:v.freezeOffset},T={width:c,height:l},E=null,D=null,k=()=>{let t=o.getSnapshot();if(D&&E===t)return D;let n=a(t.left)[e.columnIndex],r=i(t.top)[e.rowIndex],c=n.metrics,l=r.metrics,u=Object.freeze({rowStart:r.minIndex,colStart:n.minIndex,rowEnd:r.maxIndex,colEnd:n.maxIndex}),d=Object.freeze({getColIndex:e=>c.getColIndex(e),getColOffset:e=>c.getColOffset(e),getRowIndex:e=>l.getRowIndex(e),getRowOffset:e=>l.getRowOffset(e)}),f={left:n.scrollOffset,top:r.scrollOffset};return D={cellRange:u,metrics:d,scrollTopLeft:f,topLeft:{top:(w.top+(b.vertical?f.top:0))/s,left:(w.left+(b.horizontal?f.left:0))/s},colDims:n,rowDims:r},E=t,D},A=(e,t)=>{let n=k();return((e,t,n)=>{let r=e.getColOffset(t.colStart)+(n?.left??0),i=e.getRowOffset(t.rowStart)+(n?.top??0);return{x:r,y:i,width:e.getColOffset(t.colEnd+1)+(n?.right??0)-(n?.left??0)-r,height:e.getRowOffset(t.rowEnd+1)+(n?.bottom??0)-(n?.top??0)-i}})(n.metrics,e??n.cellRange,t)},j=e=>{if(e<0)return null;let t=k().colDims.metrics,n=t.getColOffset(e);return{index:e,offset:n,size:t.getColOffset(e+1)-n}},M=e=>{if(e<0)return null;let t=k().rowDims.metrics,n=t.getRowOffset(e);return{index:e,offset:n,size:t.getRowOffset(e+1)-n}},N=(e,t)=>{let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=t(e[r]);return n};return{addReactEventListener:(t,n,r)=>{let i=e.refStage;return i?i.addReactEventListener(t,n,r):()=>{}},getElement:()=>e.refStage,invalidate:d,focus(t){let n=e.refStage;n&&n.focus(t)},setPointerCapture:t=>{let n=e.refStage;n&&n.setPointerCapture(t)},releasePointerCapture(t){let n=e.refStage;n&&n.releasePointerCapture(t)},getVisibleRange:()=>k().cellRange,toClipBounds:(e,t)=>{let n,r=0;return t===void 0||typeof t==`number`?(n=A(k().cellRange),r=t):n=t,((e,t,n=0)=>{let r=e.x,i=e.y;if(r>t.width||i>t.height)return null;let a={left:r,top:i,bottom:e.height+i,right:e.width+r},o={left:t.x+n,top:t.y+n,bottom:t.height-2*n+t.y,right:t.width-2*n+t.x},s={left:Math.max(a.left,o.left),top:Math.max(a.top,o.top),bottom:Math.min(a.bottom,o.bottom),right:Math.min(a.right,o.right)},c={x:s.left,y:s.top,width:s.right-s.left,height:s.bottom-s.top};return c.height<0||c.width<0?null:c})(e??{x:0,y:0,width:x.width,height:x.height},n,r)},toPaneBounds:e=>{let t=k().topLeft;return t.left===0&&t.top===0&&s===1?e:{x:(e.x-t.left)*s,y:(e.y-t.top)*s,width:e.width*s,height:e.height*s}},toAbsoluteBounds:e=>{let t=k().topLeft;return t.left===0&&t.top===0&&s===1?e:{x:e.x/s+t.left,y:e.y/s+t.top,width:e.width/s,height:e.height/s}},getPanePointFromPointer:(e,t)=>{let n=p(e,t);return n?{x:n.x-x.x,y:n.y-x.y}:null},getMetrics:()=>k().metrics,getRangeFromCell:u,getVisibleColumns:(e,t)=>N(k().colDims.visibleIndices(e,t),j),getVisibleRows:(e,t)=>N(k().rowDims.visibleIndices(e,t),M),getColumnSize:j,getRowSize:M,getTotalRange:()=>f,getBoundsFromRange:A,getCellFromPointer:(e,t,n=!1)=>{let r=p(e,t);if(!r)return null;let i=k().metrics,a=i.getColIndex(r.x-x.x),o={rowIndex:i.getRowIndex(r.y-x.y),colIndex:a};if(n)return o;let s=u(o);return{rowIndex:s.rowStart,colIndex:s.colStart}},getPaneFromPointer:(e,t)=>{let n=p(e,t);if(!n)return null;let r=g();for(let e=0;e<re.length;e++){let t=r[re[e]];if(t&&O(n.x,n.y,t.getPaneBounds()))return t}return null},getZoom:()=>s,getAnchor:()=>_,getPaneRange:()=>S,getPaneBounds:()=>x,getInsets:()=>e.insets,getTotalSize:()=>C,getSurfaceSize:()=>T,getScrollTopLeft:()=>k().scrollTopLeft,getScrollTarget:()=>{let e=k().scrollTopLeft,t=o.getSnapshot(),n=o.getTarget();return{left:e.left+(b.horizontal?n.left-t.left:0),top:e.top+(b.vertical?n.top-t.top:0)}},getFreezeTopLeft:()=>w,getScrollOrientation:()=>b,scrollCellCoordsIntoView:(e,t)=>h(e,t,_),scrollTo:e=>m(e),getAllPanes:g}},re=[u.AnchorLocation.TopLeft,u.AnchorLocation.Top,u.AnchorLocation.Left,u.AnchorLocation.Center],z=(e,t,n)=>{let r=(t?.left??0)+(n?.x??0),i=(t?.top??0)+(n?.y??0);return{getColOffset:t=>e.getColOffset(t)-r,getColIndex:t=>e.getColIndex(t+r),getRowOffset:t=>e.getRowOffset(t)-i,getRowIndex:t=>e.getRowIndex(t+i)}},ie=Object.freeze([{minIndex:0,maxIndex:0,minCoord:0,maxCoord:0,visibleIndices:()=>u.CommonUtils.EmptyArray,minBounds:0,maxBounds:0,metrics:{getColOffset:()=>0,getColIndex:()=>0,getRowOffset:()=>0,getRowIndex:()=>0},maxVirtualBounds:0,scrollOffset:0,freezeOffset:0}]),B=(0,s.createContext)(null),ae=({pane:e,viewport:t,children:n})=>{let r=(0,s.useMemo)(()=>({pane:e}),[e,(0,l.useOptionalBoundSyncExternalStore)(t,e=>e.getSnapshot())]);return(0,c.jsx)(B.Provider,{value:r,children:n})},V=()=>{let e=new Map,t=new Map;return{has:t=>e.has(t),get:t=>e.get(t),set(n,r){if(e.has(n)&&Object.is(e.get(n),r))return;e.set(n,r);let i=t.get(n);if(i)for(let e of[...i])e()},subscribe(e,n){let r=t.get(e);return r||t.set(e,r=new Set),r.add(n),()=>{r.delete(n),r.size===0&&t.delete(e)}}}},oe=(0,s.createContext)(null),se=({store:e,children:t})=>{let n=(0,s.useContext)(oe),r=(0,s.useRef)(null),i=e??n;return i||=(r.current||=V(),r.current),(0,c.jsx)(oe.Provider,{value:i,children:t})},ce={"sheetxl-grid":`_sheetxl-grid_5yo0n_7`},H=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{rowCount:n=1,columnCount:r=1,viewport:i,metrics:a,getRangeFromCell:o=u.CoordUtils.cellToRange,hiddenRowsAt:d,hiddenColumnsAt:f,freezeLeft:p=0,freezeTop:m=0,propsFreezeLeft:h,propsFreezeTop:_,onFirstRender:v,children:y,wrapPane:b,onFocus:x,onBlur:S,className:w,style:k,...A}=e,j=(0,l.useCallbackRef)(x,[x]),M=(0,l.useCallbackRef)(S,[S]),N=(0,l.useCallbackRef)(v,[v]),[P,I]=(0,s.useState)(u.AnchorLocation.Center),[L,R]=(0,s.useReducer)(e=>e+1,0),re=(0,s.useMemo)(()=>new l.Viewport({}),[]),B=i??re,[V,oe]=(0,s.useState)(()=>{let e=B.getClient();return{zoom:B.getZoom(),w:e.width,h:e.height,ready:B.isReady()}});(0,s.useEffect)(()=>{let e=()=>oe(e=>{let t=B.getClient(),n={zoom:B.getZoom(),w:t.width,h:t.height,ready:B.isReady()};return e.zoom===n.zoom&&e.w===n.w&&e.h===n.h&&e.ready===n.ready?e:n});return e(),B.subscribe(e)},[B]);let H=V.zoom,W=(0,s.useMemo)(()=>{let e=a??le;return{getColOffset:t=>e.getColOffset(t)*H,getColIndex:t=>e.getColIndex(t/H),getRowOffset:t=>e.getRowOffset(t)*H,getRowIndex:t=>e.getRowIndex(t/H)}},[a,H]),G=(0,l.useCallbackRef)((e,t=!1)=>D(e,t,W.getRowOffset,t?0:n),[n,W?.getRowOffset]),ve=(0,l.useCallbackRef)(d??G,[d]),ye=(0,l.useCallbackRef)((e,t=!1)=>D(e,t,W.getColOffset,t?r:0),[r,W?.getColOffset]),K=(0,l.useCallbackRef)(f??ye,[f]),be=(0,s.useCallback)(()=>{R()},[]),xe=(0,s.useMemo)(()=>Math.min(V.w,W.getColOffset(r)),[L,W.getColOffset,r,V.w]),Se=(0,s.useMemo)(()=>Math.min(V.h,W.getRowOffset(n)),[L,W.getRowOffset,n,V.h]),q=(0,s.useMemo)(()=>{let e=NaN,t=null;return r=>(r===e&&t||(e=r,t=(e=>{if(Se===0)return ie;let t=[],r=0,i=0;typeof m==`number`?r=m:(r=m.index??0,i=(m.offset??0)*H);let a=i,o=W.getRowOffset(r),s=o-a;if(r>0){let e=z(W,{top:i+W.getRowOffset(0)}),n=W.getRowIndex(a),c=W.getRowIndex(o-1),l;t[1]={minIndex:n,maxIndex:c,minCoord:0,maxCoord:r-1,minBounds:0,maxBounds:s,visibleIndices:(e,t)=>e!==void 0&&t!==void 0?T(ve,e,t):l||(l=Object.freeze(T(ve,n,c)),l),metrics:e,maxVirtualBounds:o,scrollOffset:i,freezeOffset:i}}let c=Math.max(0,Se-s),l=z(W,{top:e+s}),u=l.getRowIndex(0),d=l.getRowIndex(c-1),f;return t[0]={minIndex:u,maxIndex:d,minCoord:r,maxCoord:n-1,minBounds:s,maxBounds:c,visibleIndices:(e,t)=>e!==void 0&&t!==void 0?T(ve,e,t):f||(f=Object.freeze(T(ve,u,d)),f),metrics:l,maxVirtualBounds:W.getRowOffset(n),scrollOffset:e,freezeOffset:(r>0?W.getRowOffset(r):0)-i},t})(r)),t)},[L,W.getRowIndex,W.getRowOffset,ve,Se,n,m,H]),J=(0,s.useMemo)(()=>q(0),[q]),Y=(0,s.useMemo)(()=>{let e=NaN,t=null;return n=>(n===e&&t||(e=n,t=(e=>{if(xe===0)return ie;let t=[],n=0,i=0;typeof p==`number`?n=p:(n=p.index??0,i=(p.offset??0)*H);let a=i,o=W.getColOffset(n),s=o-a;if(n>0){let e=z(W,{left:i+W.getColOffset(0)}),r=W.getColIndex(a),c=W.getColIndex(o-1),l;t[1]={minIndex:r,maxIndex:c,minCoord:0,maxCoord:n-1,minBounds:0,maxBounds:s,visibleIndices:(e,t)=>e!==void 0&&t!==void 0?T(K,e,t):l||(l=Object.freeze(T(K,r,c)),l),metrics:e,maxVirtualBounds:o,scrollOffset:i,freezeOffset:i}}let c=Math.max(0,xe-s),l=z(W,{left:e+s}),u=l.getColIndex(0),d=l.getColIndex(c-1),f;return t[0]={minIndex:u,maxIndex:d,minCoord:n,maxCoord:r-1,minBounds:s,maxBounds:c,visibleIndices:(e,t)=>e!==void 0&&t!==void 0?T(K,e,t):f||(f=Object.freeze(T(K,u,d)),f),metrics:l,maxVirtualBounds:W.getColOffset(r),scrollOffset:e,freezeOffset:(n>0?W.getColOffset(n):0)-i},t})(n)),t)},[L,W.getColIndex,W.getColOffset,K,xe,r,p,H]),X=(0,s.useMemo)(()=>Y(0),[Y]),Ce=(0,s.useRef)([]),[we,Te]=(0,s.useReducer)(e=>e+1,0),Ee=J.length,De=X.length,Oe=(0,s.useMemo)(()=>{let e=[],t=(t,n,r,i,a)=>{if(t>=De||n>=Ee)return null;let o={anchor:r,columnIndex:t,rowIndex:n,elemStage:null,refStage:null,scrollOrientation:{vertical:i?.vertical||!1,horizontal:i?.horizontal||!1},insets:Object.freeze({left:a?.left??0,top:a?.top??0,right:a?.right??0,bottom:a?.bottom??0})};o.elemStage=(0,c.jsx)(F,{ref:e=>{e?(o.refStage=e,Te()):o.refStage=null},className:`stage stage-${r}`,onFocus:e=>{I(r),j(e)},onBlur:e=>{M(e)}}),e.push(o)};return t(0,0,u.AnchorLocation.Center,me,pe),t(0,1,u.AnchorLocation.Top,he),t(1,0,u.AnchorLocation.Left,ge),t(1,1,u.AnchorLocation.TopLeft,U),e},[Ee,De]),Z=(0,s.useMemo)(()=>{let e={},t={colStart:0,rowStart:0,colEnd:r-1,rowEnd:n-1},i=n=>ne(n,{rowDims:J,columnDims:X,computeRowDims:q,computeColumnDims:Y,viewport:B,zoom:H,containerWidth:xe,containerHeight:Se,getRangeFromCell:o,invalidate:be,totalRange:t,getSurfacePointFromPointer:(e,t)=>Pe(e,t),scrollTo:e=>Be(e),scrollCellCoordsIntoView:(e,t,n)=>ze(e,t,n),getAllPanes:()=>e}),a=Oe.length;for(let t=0;t<a;t++){let n=Oe[t];e[n.anchor]=i(n)}return e=Object.freeze(e),e},[Oe,J,X,q,Y,B,o,we]),ke=X[0]?.maxVirtualBounds??0,Ae=J[0]?.maxVirtualBounds??0,je=V.ready,Me=(0,s.useMemo)(()=>{let e=X[1],t=J[1];return{left:e?e.metrics.getColOffset(e.maxIndex+1):0,top:t?t.metrics.getRowOffset(t.maxIndex+1):0}},[J,X]),Ne=(0,l.useCallbackRef)(e=>{u.DOMUtils.canUseDOM&&setTimeout(()=>{(Z[P]?.getElement()??Z[u.AnchorLocation.Center]?.getElement())?.focus({preventScroll:!0,...e})},0)},[P,Z]);(0,s.useEffect)(()=>{let e=Ce.current,t=e.length;if(t>0){for(let n=0;n<t;n++)e[n]();Ce.current=[]}},[Z]);let Pe=(0,s.useCallback)((e,t)=>{(function(e){if(!e)throw Error(`Invariant failed`)})(typeof e==`number`&&typeof t==`number`);let n=Ve.current?.getBoundingClientRect();return n?{x:e-n.x,y:t-n.y}:{x:e,y:t}},[]),Fe=(0,l.useCallbackRef)((e,t)=>{if(Object.keys(Z).length===1)return Z[u.AnchorLocation.Center];let n=Pe(e,t);if(!n)return Z[u.AnchorLocation.Center];let{x:r,y:i}=n,a=null,o=_e,s=o.length;for(let e=0;!a&&e<s;e++){let t=Z[o[e]];t&&O(r,i,t.getPaneBounds())&&(a=t)}return a||=Z[u.AnchorLocation.Center],a},[Z,o]);(0,s.useEffect)(()=>{let e=X?.[1]?.scrollOffset??0,t=J?.[1]?.scrollOffset??0;B.setContent(ke,Ae,e,t)},[B,ke,Ae,X,J]);let Ie=(0,l.useCallbackRef)(e=>{let t=e?.left??e?.[0],n=e?.top??e?.[1];if(t===void 0&&n===void 0)return;let r=e?.behavior??`auto`,i=B.getTarget();t!==void 0&&(t=i.left+(t??0)),n!==void 0&&(n=i.top+(n??0)),i.left===t&&i.top===n||Be({left:t,top:n,behavior:r})},[]),Le=(0,l.useCallbackRef)(e=>e===void 0?Z[P]??Z[u.AnchorLocation.Center]??null:Z[e]??null,[Z,P]),Re=(0,l.useCallbackRef)(e=>{let t=Z[P];if(!t)return Z[u.AnchorLocation.Center];let n=t.getScrollOrientation(),r={...t.getVisibleRange()};return n.vertical&&(r.rowStart=J[0].minCoord,r.rowEnd=J[0].maxCoord),n.horizontal&&(r.colStart=X[0].minCoord,r.colEnd=X[0].maxCoord),n&&u.CoordUtils.isCellWithinRange(e,r)?t:Z[u.AnchorLocation.Center]},[Z,P]),ze=(0,l.useCallbackRef)((e,t={inline:`nearest`,block:`nearest`},n=null)=>{let r={rowIndex:0,colIndex:0,...e},i=null;if(n!==null){if(i=Z[n],!i)return new Promise((e,t)=>{t(`Invalid view`)})}else i=Re(r);let a=o(r),s=i.getMetrics(),c=s.getColOffset(a.colStart),l=s.getRowOffset(a.rowStart),u=s.getColOffset(a.colEnd+1),d=s.getRowOffset(a.rowEnd+1),f=i.getPaneBounds(),p=i.getTotalSize(),m=i.getScrollTopLeft(),h=((e,t,n=!0)=>{n=!0===n?{block:`start`,inline:`end`}:!1===n?{block:`end`,inline:`end`}:{block:`end`,inline:`end`,...n};let r=E(n.inline??`end`,e.x,e.x+e.width,t.left,t.left+t.width,t.totalWidth),i=E(n.block??`end`,e.y,e.y+e.height,t.top,t.top+t.height,t.totalHeight);if(r!==void 0||i!==void 0)return{left:r??t.left,top:i??t.top}})({x:c+m.left,y:l+m.top,width:u-c,height:d-l},{left:m.left,top:m.top,width:f.width,height:f.height,totalWidth:p.width,totalHeight:p.height},t);if(!h)return Promise.resolve({...m});let g={...h},{left:_,top:v}=B.getScroll();g.left!==void 0&&(g.left>_?g.left+=de:g.left<_&&(g.left-=ue)),g.top!==void 0&&(g.top>v?g.top+=de:g.top<v&&(g.top-=ue));let y=i.getScrollOrientation();y.horizontal&&e.colIndex!==void 0||delete g.left,y.vertical&&e.rowIndex!==void 0||delete g.top;let b=g.left===void 0?0:Math.abs(g.left-_),x=g.top===void 0?0:Math.abs(g.top-v),S=(typeof t==`object`?t?.behavior:void 0)??(Math.max(b,x)<fe||!B.isSettled()?`instant`:`smooth`);return new Promise((e,t)=>{try{Be({...g,behavior:S}),e(g)}catch(e){t(e)}})},[ke,Ae,Z,o]),Be=(0,l.useCallbackRef)(e=>{let t=e?.left??e?.[0],n=e?.top??e?.[1],r=B.getTarget(),i=t??r.left,a=n??r.top,o=e?.behavior===`smooth`;B.setTarget(i,a,o)},[]),Ve=(0,l.useImperativeElement)(t,()=>({focus:Ne,invalidate:be,scrollTo:Be,scrollBy:Ie,scrollCellCoordsIntoView:ze,getPaneFromClient:Fe,getPaneFromCell:Re,getPane:Le,onPaneChangeOnce:e=>{Ce.current.push(e)}}),[Z]);(0,s.useEffect)(()=>B.observe(Ve.current),[B]);let He=(e,t)=>{let n=(e=>{if(!e)return null;if(!Array.isArray(e))return e;let t=e=>(0,s.isValidElement)(e)&&e.props?.zIndex!=null?e.props.zIndex:0;return[...e].sort((e,n)=>t(e)-t(n)).map((e,t)=>(0,s.isValidElement)(e)?(0,s.createElement)(ee.Provider,{key:e.key??`layer-${t}`,value:t},e):e)})(t);return n?(0,c.jsx)(te.Provider,{value:!1,children:(0,c.jsx)(ae,{pane:e,viewport:B,children:b?b(e,n):n})}):null},Ue=(0,s.useMemo)(()=>{let e={},t=Object.keys(Z),n=t.length;for(let r=0;r<n;r++){let n=t[r];e[n]=He(Z[n],y)}return e},[L,y,Z,b,n,r]),We=(0,s.useMemo)(()=>Me.left===0?null:(0,c.jsx)(g,{linePoints:[0,0,0,Se+1],bounds:{x:Me.left,y:0,width:1,height:Se+1},...h}),[L,Me.left,Se,h]),Ge=(0,s.useMemo)(()=>Me.top===0?null:(0,c.jsx)(g,{linePoints:[0,0,xe+1,0],bounds:{x:0,y:Me.top,width:xe+1,height:1},..._}),[L,Me.top,xe,_]),Ke=(0,s.useRef)(!1),qe=(0,s.useMemo)(()=>{if(!je)return null;let e=(e,t)=>{let n=e.anchor,r=t.getPaneBounds(),i=Me.left>0,a=Me.top>0,o=a&&(n===u.AnchorLocation.Center||n===u.AnchorLocation.Left),l=a&&(n===u.AnchorLocation.Top||n===u.AnchorLocation.TopLeft),d=i&&(n===u.AnchorLocation.Center||n===u.AnchorLocation.Top),f=i&&(n===u.AnchorLocation.Left||n===u.AnchorLocation.TopLeft),p=1e6,m=o?-1:-1e6,h=d?-1:-1e6,g=f?r.width+2:p,_=l?r.height+2:p,v=o||l||d||f,y={position:`absolute`,left:r.x,top:r.y,width:r.width,height:r.height,clip:v?`rect(${m}px, ${g}px, ${_}px, ${h}px)`:void 0};return(0,c.jsx)(ae,{pane:t,viewport:B,children:e.elemStage?(0,s.cloneElement)(e.elemStage,{style:y},Ue?.[n]):null},`pane:${n}`)},t=Oe.length,n=Array(t);for(let r=0;r<t;r++){let t=Oe[r],i=t.anchor,a=Z[i];n[r]=a?e(t,a):null}return(0,c.jsxs)(c.Fragment,{children:[n,We,Ge]})},[Z,Oe,Ue,xe,Se,je,Me]);return(0,s.useEffect)(()=>{!Ke.current&&qe&&je&&(Ke.current=!0,N?.(Ve.current))},[qe,je]),(0,c.jsx)(`div`,{ref:Ve,className:C(w,`grid-surface`,ce[`sheetxl-grid`]),style:{overflow:`hidden`,...k},...A,children:(0,c.jsx)(se,{children:qe})})}));H.displayName=`GridSurface`;var le=Object.freeze({getColOffset:e=>75*e,getColIndex:e=>Math.floor(e/75),getRowOffset:e=>20*e,getRowIndex:e=>Math.floor(e/20)}),ue=0,de=20,fe=150,pe=Object.freeze({bottom:-4,right:-4}),me=Object.freeze({horizontal:!0,vertical:!0}),he=Object.freeze({horizontal:!0,vertical:!1}),ge=Object.freeze({horizontal:!1,vertical:!0}),U=Object.freeze({horizontal:!1,vertical:!1}),_e=[u.AnchorLocation.TopLeft,u.AnchorLocation.Top,u.AnchorLocation.Left,u.AnchorLocation.Center];function W(){let e=(0,s.useContext)(B);if(!e)throw Error(`useGridPane must be used within a GridPaneProvider`);return e.pane}function G(){return(0,s.useContext)(B)?.pane??null}function ve(e,t){let n=(0,s.useContext)(oe),r=(0,s.useRef)(null);r.current||=V();let i=n??r.current,a=`k:${e}`,o=(0,s.useRef)(null);o.current===null&&(o.current={v:typeof t==`function`?t():t});let c=(0,s.useCallback)(()=>i.has(a)?i.get(a):o.current.v,[i,a]);return[(0,s.useSyncExternalStore)((0,s.useCallback)(e=>i.subscribe(a,e),[i,a]),c,c),(0,s.useCallback)(e=>{let t=i.has(a)?i.get(a):o.current.v;i.set(a,typeof e==`function`?e(t):e)},[i,a])]}var ye=(0,s.memo)(e=>{let{onPointerDown:t,onPointerMove:n,onPointerUp:r,onPointerLeave:i,onMouseDown:a,onMouseEnter:o,onMouseLeave:l,onMouseMove:u,onMouseOut:d,onMouseOver:f,onMouseUp:p,onDoubleClick:m,onKeyDown:h,onKeyPress:g,onKeyUp:_,onFocus:v,onBlur:y,onContextMenu:b,zIndex:x,className:S,children:C}=e,w=(0,s.useContext)(te);(0,s.useEffect)(()=>{w&&!be&&(be=!0,console.error(`<Layer> nested inside another <Layer>. Layers exist only as direct children of the grid (law 4: the stack is flat) — a composite renders exactly one Layer at its root. For a full-view container inside a layer, use <VirtualDiv fill>. This error fires once.`))},[w]);let T=P(G()),E=(0,s.useContext)(ee),D=(0,s.useRef)({});D.current={pointerdown:K(t),pointermove:K(n),pointerup:K(r),pointerleave:K(i),mousedown:K(a),mouseenter:K(o),mouseleave:K(l),mousemove:K(u),mouseout:K(d),mouseover:K(f),mouseup:K(p),dblclick:K(m),keydown:K(h),keypress:K(g),keyup:K(_),focus:K(v),blur:K(y),contextmenu:K(b)};let O=(0,s.useRef)(null);return(0,s.useEffect)(()=>{if(T)return T.registerResponder({zIndex:E,getElement:()=>O.current,getHandler:e=>D.current[e]})},[T,E]),(0,c.jsx)(`div`,{ref:O,className:S,onPointerDown:t,onPointerMove:n,onPointerUp:r,onMouseDown:a,onMouseMove:u,onMouseUp:p,onMouseOver:f,onMouseOut:d,onDoubleClick:m,onKeyDown:h,onKeyPress:g,onKeyUp:_,onContextMenu:b,children:C==null?null:(0,c.jsx)(te.Provider,{value:!0,children:C})})});ye.displayName=`Layer`;var K=e=>e?t=>e(t):void 0,be=!1,xe=!1,Se=`_virtual-div_16eab_1`,q=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{range:n,bounds:r,fill:i=!1,clipInsets:a,disableAlign:o=!1,coverGridlines:u=!1,alignWidth:d,keepMounted:f=!1,className:p,style:h,children:g,..._}=e;(0,s.useContext)(te)||J||(J=!0,console.warn(`VirtualDiv rendered outside a <Layer>. The grid's children are Layers; place VirtualDivs inside one (law 4: the stack is flat). This warning fires once.`));let v=(0,s.useRef)(null),y=(0,s.useCallback)(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]);(({getElement:e,handlerProps:t})=>{let n=P(G()),r=(0,s.useContext)(ee),i=!1;if(t){for(let e=0;e<j.length;e++)if(typeof t[j[e]]==`function`){i=!0;break}}let a=(0,s.useRef)({getElement:e,handlerProps:t});a.current={getElement:e,handlerProps:t},(0,s.useEffect)(()=>{if(n)return n.registerLayer({zIndex:r,getElement:()=>a.current.getElement(),hasHandlers:i,getHandler:i?e=>{let t=A[e];if(t===void 0)return;let n=a.current.handlerProps?.[t];return typeof n==`function`?e=>n(e):void 0}:void 0})},[n,i,r])})({getElement:()=>v.current,handlerProps:_});let b=(({range:e,bounds:t,fill:n,clipInsets:r})=>{let i=W();if(!i)return null;let a=null,o=!1;if(e)a=i.getBoundsFromRange(e),o=i.toClipBounds(a,r)===null;else if(t)o=i.toClipBounds(t,r)===null,a=t;else{if(!n)return xe||(xe=!0,console.warn(`VirtualDiv: provide exactly one of 'range' | 'bounds' | 'fill'. (The implicit "no placement = pane-sized" fallback was removed — use 'fill'.) This warning fires once.`)),null;{let e=i.getPaneBounds();a={x:0,y:0,width:e.width,height:e.height}}}return a?{pane:i,raw:a,culled:o}:null})({range:n,bounds:r,fill:i,clipInsets:a});if(!b)return null;let{raw:x,culled:S}=b;if(S&&!f)return null;let w=l.ReactUtils.getDevicePixelRatio(),T=d!=null,E=T?d/w:0,D,O,k,M;if(o)D=x.x,O=x.y,k=x.width,M=x.height;else if(T){let e=l.ReactUtils.edgeCenter(x.x,`leading`,d,w),t=l.ReactUtils.edgeCenter(x.y,`leading`,d,w);D=e-E/2,O=t-E/2,k=l.ReactUtils.edgeCenter(x.x+x.width,`trailing`,d,w)-e+E,M=l.ReactUtils.edgeCenter(x.y+x.height,`trailing`,d,w)-t+E}else{let e=u?1/w:0;D=l.ReactUtils.snapDeviceEdge(x.x,w),O=l.ReactUtils.snapDeviceEdge(x.y,w),k=l.ReactUtils.snapDeviceEdge(x.x+x.width,w)+e-D,M=l.ReactUtils.snapDeviceEdge(x.y+x.height,w)+e-O}let{transform:N,...F}=h??{},I={x:x.x-D,y:x.y-O,width:x.width,height:x.height};return(0,c.jsx)(`div`,{className:C(p,Se),style:{width:`${k}px`,height:`${M}px`,...T?{boxSizing:`border-box`,borderWidth:`${E}px`,borderStyle:`solid`}:void 0,...F,transform:`translate(${D}px, ${O}px)${N?` ${N}`:``}`},..._,ref:y,children:g==null?null:(0,c.jsx)(m.Provider,{value:I,children:g})})}));q.displayName=`VirtualDiv`;var J=!1,Y=(e,t,n,r)=>({x:e,y:t,width:n,height:r,top:t,left:e,right:e+n,bottom:t+r}),X=Y(0,0,0,0),Ce=e=>{let t=e.getElement()?.getBoundingClientRect?.();return{x:t?.left??0,y:t?.top??0}},we=e=>{let t=e.getElement()?.getBoundingClientRect?.();return t?Y(t.left,t.top,t.width,t.height):X},Te={side:`t`,align:`center`},Ee=[u.AnchorLocation.TopLeft,u.AnchorLocation.Top,u.AnchorLocation.Left,u.AnchorLocation.Center],De=new Set([u.AnchorLocation.Top,u.AnchorLocation.TopLeft]),Oe=new Set([u.AnchorLocation.Left,u.AnchorLocation.TopLeft]),Z=(e,t,n,r,i)=>{let a=null,o=null,s=1/0,c=!1;for(let l=0;l<Ee.length;l++){let u=e[Ee[l]];if(!u)continue;let d=u.getVisibleRange(),f=t===`row`?d.rowStart:d.colStart,p=t===`row`?d.rowEnd:d.colEnd;if(n>p||r<f)continue;c=!0,!a&&i>=f&&i<=p&&(a=u);let m=i<f?f-i:i>p?i-p:0;m<s&&(s=m,o=u)}return{pane:a??o,visible:c}},ke=(e,t)=>{let n=De.has(e.getAnchor()),r=Oe.has(t.getAnchor());return n&&r?u.AnchorLocation.TopLeft:n?u.AnchorLocation.Top:r?u.AnchorLocation.Left:u.AnchorLocation.Center},Ae=(e,t)=>{let n=we(e),r=e.getBoundsFromRange(t);return Y(n.left+r.x,n.top+r.y,r.width,r.height)},je=(e,t)=>{let n=(t.left+t.right)/2,r=(t.top+t.bottom)/2;return r<e.top?`t`:r>e.bottom?`b`:n<e.left?`l`:n>e.right?`r`:null},Me=(e,t,n=`data`,r=0,i=Te,a=`hide`)=>{if(!e)return{rect:X,clipped:!0,boundaryRect:X,clampedTo:null,anchorPoint:{x:0,y:0},owner:null,slid:null,outOfView:!0};let o=((e,t)=>{if(t&&typeof t==`object`){let e=t;return Y(e.x,e.y,e.width,e.height)}if(t===`viewport`){let t=e.getElement()?.ownerDocument?.documentElement;if(t)return Y(0,0,t.clientWidth,t.clientHeight)}if(t===`pane`){let t=Ce(e),n=e.getPaneBounds();return Y(t.x,t.y,n.width,n.height)}let n=e.getAllPanes(),r=1/0,i=1/0,a=-1/0,o=-1/0;for(let e of Object.keys(n)){let t=n[e]?.getElement()?.getBoundingClientRect?.();t&&(r=Math.min(r,t.left),i=Math.min(i,t.top),a=Math.max(a,t.right),o=Math.max(o,t.bottom))}if(r===1/0){let t=Ce(e),n=e.getPaneBounds();return Y(t.x,t.y,n.width,n.height)}return Y(r,i,a-r,o-i)})(e,n),s=e=>{if(r<=0)return!1;let t=(n=e,i=o,{w:Math.min(n.right,i.right)-Math.max(n.left,i.left),h:Math.min(n.bottom,i.bottom)-Math.max(n.top,i.top)});var n,i;return t.w<=r||t.h<=r};if(`point`in t){let n=Y(t.point.x,t.point.y,0,0),r=je(o,n),i=e.getPaneFromPointer(t.point.x,t.point.y);return{rect:n,clipped:r!==null,boundaryRect:o,clampedTo:r,anchorPoint:{...t.point},owner:i?.getAnchor()??null,slid:null,outOfView:!1}}if(`edge`in t){let n=Ce(e),r=e.getPaneBounds(),i=n.x+r.width/2,a=n.y+r.height/2;t.edge===`t`?a=n.y:t.edge===`b`?a=n.y+r.height:t.edge===`l`?i=n.x:t.edge===`r`&&(i=n.x+r.width);let s=e.getPaneFromPointer(i,a)??e;return{rect:Y(i,a,0,0),clipped:!1,boundaryRect:o,clampedTo:null,anchorPoint:{x:i,y:a},owner:s.getAnchor(),slid:null,outOfView:!1}}if(`bounds`in t){let n=Ce(e),r=t.bounds,a=e.toClipBounds(r,0),l=Y(n.x+r.x,n.y+r.y,r.width,r.height),u=a===null||s(l),d=((e,t)=>{let{side:n,align:r=`center`}=t;if(n===`t`||n===`b`){let t=n===`t`?e.top:e.bottom;return{x:r===`start`?e.left:r===`end`?e.right:(e.left+e.right)/2,y:t}}return{x:n===`l`?e.left:e.right,y:r===`start`?e.top:r===`end`?e.bottom:(e.top+e.bottom)/2}})(l,i);return{rect:l,clipped:u,boundaryRect:o,clampedTo:je(o,(c=d,Y(c.x,c.y,0,0))),anchorPoint:d,owner:e.getAnchor(),slid:null,outOfView:u}}var c;let l=(e=>{if(`range`in e)return e.range;if(`cell`in e){let{rowIndex:t,colIndex:n}=e.cell;return{rowStart:t,colStart:n,rowEnd:t,colEnd:n}}return null})(t),d=e.getAllPanes(),f=((e,t)=>{let{side:n,align:r=`center`}=t,i=Math.round((e.rowStart+e.rowEnd)/2),a=Math.round((e.colStart+e.colEnd)/2);if(n===`t`||n===`b`)return{rowIndex:n===`t`?e.rowStart:e.rowEnd,colIndex:r===`start`?e.colStart:r===`end`?e.colEnd:a};let o=n===`l`?e.colStart:e.colEnd;return{rowIndex:r===`start`?e.rowStart:r===`end`?e.rowEnd:i,colIndex:o}})(l,i),p=Z(d,`row`,l.rowStart,l.rowEnd,f.rowIndex),m=Z(d,`col`,l.colStart,l.colEnd,f.colIndex),h=p.visible&&m.visible,g=p.pane??d[u.AnchorLocation.Center]??e,_=m.pane??d[u.AnchorLocation.Center]??e,v=Ae(g,l),y=Ae(_,l),{side:b,align:x=`center`}=i,S,C;b===`t`||b===`b`?(C=b===`t`?v.top:v.bottom,S=x===`start`?y.left:x===`end`?y.right:(y.left+y.right)/2):(S=b===`l`?y.left:y.right,C=x===`start`?v.top:x===`end`?v.bottom:(v.top+v.bottom)/2);let w=we(_),T=we(g),E=e=>Math.max(w.left,Math.min(w.right,e)),D=e=>Math.max(T.top,Math.min(T.bottom,e)),O=E(S),k=D(C),A={x:O,y:k},j=E(y.left),M=D(v.top),N=Y(j,M,E(y.right)-j,D(v.bottom)-M),P=O-S,F=k-C,I=Math.abs(F)>=Math.abs(P)?F<0?`b`:F>0?`t`:P<0?`r`:P>0?`l`:null:P<0?`r`:P>0?`l`:F<0?`b`:F>0?`t`:null,L=P||F?{dx:P,dy:F,distance:Math.hypot(P,F),direction:I??`t`}:null;return h||a!==`hide`?{rect:N,clipped:!1,boundaryRect:o,clampedTo:I,anchorPoint:A,owner:ke(g,_),slid:L,outOfView:!h}:{rect:N,clipped:!0,boundaryRect:o,clampedTo:I,anchorPoint:A,owner:null,slid:null,outOfView:!0}},Ne=(0,s.createContext)(null),Pe=e=>{let{anchor:t,placement:n=Te,boundary:r=`data`,whenOff:i=`hide`,minVisible:a=0,children:o}=e,{reference:l,getBoundaryRect:d,anchorPoint:f,owner:p,clipped:m,slid:h,outOfView:g,pane:_}=((e,t)=>{let n=G(),r=t?.pane??n,i=t?.boundary??`data`,a=t?.minVisible??0,o=t?.placement??Te,c=t?.whenOff??`hide`,l=(0,s.useRef)({pane:r,anchor:e,boundary:i,minVisible:a,placement:o,whenOff:c});l.current={pane:r,anchor:e,boundary:i,minVisible:a,placement:o,whenOff:c};let u=(0,s.useMemo)(()=>({reference:{get contextElement(){return l.current.pane?.getElement()??void 0},getBoundingClientRect:()=>{let e=l.current;return Me(e.pane,e.anchor,e.boundary,e.minVisible,e.placement,e.whenOff).rect}},getBoundaryRect:()=>{let e=l.current;return Me(e.pane,e.anchor,e.boundary,e.minVisible,e.placement,e.whenOff).boundaryRect}}),[]),d=Me(r,e,i,a,o,c);return{reference:u.reference,getBoundaryRect:u.getBoundaryRect,clipped:d.clipped,clampedTo:d.clampedTo,anchorPoint:d.anchorPoint,owner:d.owner,slid:d.slid,outOfView:d.outOfView,pane:r}})(t,{boundary:r,whenOff:i,minVisible:a,placement:n}),v=_!=null&&(p==null?_.getAnchor()===u.AnchorLocation.Center:_.getAnchor()===p),y=null;v&&_&&(`range`in t?y=_.getBoundsFromRange(t.range):`cell`in t?y=_.getBoundsFromRange({rowStart:t.cell.rowIndex,colStart:t.cell.colIndex,rowEnd:t.cell.rowIndex,colEnd:t.cell.colIndex}):`bounds`in t&&(y=t.bounds));let b=(0,s.useRef)(t);b.current=t;let x=(0,s.useRef)(_);x.current=_;let S=(0,s.useCallback)(e=>{let t=Fe(b.current),n=x.current;return n&&t?n.scrollCellCoordsIntoView(t,e):Promise.resolve(void 0)},[]),C=(0,s.useMemo)(()=>({reference:l,getBoundaryRect:d,anchorPoint:f,bounds:y,owner:p,isOwner:v,clipped:m,slid:h,outOfView:g,placement:n,pane:_,scrollIntoView:S}),[l,d,f.x,f.y,y?.x,y?.y,y?.width,y?.height,p,v,m,h,g,n.side,n.align,_,S]),w=v&&!m&&_!=null,T=typeof o!=`function`,E=(0,s.useRef)(null),D=(0,s.useRef)(null),O=null;if(w&&!T)O=o(C);else if(w){let e=_.getElement()?.getBoundingClientRect();O=(0,c.jsx)(`div`,{ref:E,className:`sticky-layer`,style:{position:`absolute`,left:0,top:0,transform:`translate3d(${f.x-(e?.left??0)}px, ${f.y-(e?.top??0)}px, 0) ${Ie(n)}`,willChange:`transform`},children:(0,c.jsx)(`div`,{ref:D,children:o})})}return(0,s.useLayoutEffect)(()=>{let e=E.current,t=D.current;if(!(e&&t&&w&&_))return;let n=e.getBoundingClientRect(),r=_.getElement()?.getBoundingClientRect();if(!r)return;let i=0,a=0;n.left<r.left?i=r.left-n.left:n.right>r.right&&(i=Math.min(0,r.right-n.right)),n.top<r.top?a=r.top-n.top:n.bottom>r.bottom&&(a=Math.min(0,r.bottom-n.bottom)),t.style.transform=i||a?`translate(${i}px, ${a}px)`:``}),(0,c.jsx)(Ne.Provider,{value:C,children:O})},Fe=e=>`range`in e?{rowIndex:e.range.rowStart,colIndex:e.range.colStart}:`cell`in e?{rowIndex:e.cell.rowIndex,colIndex:e.cell.colIndex}:null,Ie=e=>{let{side:t,align:n=`center`}=e,r=`-50%`,i=`-50%`;t===`t`?i=`-100%`:t===`b`?i=`0%`:t===`l`?r=`-100%`:t===`r`&&(r=`0%`);let a=n===`start`?`0%`:n===`end`?`-100%`:`-50%`;return t===`t`||t===`b`?r=a:i=a,`translate(${r}, ${i})`};Pe.displayName=`StickyAnchor`;var Le=Math.min,Re=Math.max,ze=Math.round,Be=Math.floor,Ve=e=>({x:e,y:e}),He={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Ue(e,t){return typeof e==`function`?e(t):e}function We(e){return e.split(`-`)[0]}function Ge(e){return e.split(`-`)[1]}function Ke(e){return e===`x`?`y`:`x`}function qe(e){return e===`y`?`height`:`width`}function Je(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Ye(e){return Ke(Je(e))}function Xe(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Ze=[`left`,`right`],Qe=[`right`,`left`],$e=[`top`,`bottom`],et=[`bottom`,`top`];function tt(e,t,n,r){let i=Ge(e),a=function(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Qe:Ze:t?Ze:Qe;case`left`:case`right`:return t?$e:et;default:return[]}}(We(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Xe)))),a}function nt(e){let t=We(e);return He[t]+e.slice(t.length)}function rt(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function it(e,t,n){let{reference:r,floating:i}=e,a=Je(t),o=Ye(t),s=qe(o),c=We(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Ge(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function at(e,t){var n;t===void 0&&(t={});let{x:r,y:i,platform:a,rects:o,elements:s,strategy:c}=e,{boundary:l=`clippingAncestors`,rootBoundary:u=`viewport`,elementContext:d=`floating`,altBoundary:f=!1,padding:p=0}=Ue(t,e),m=function(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:function(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}(e)}(p),h=s[f?d===`floating`?`reference`:`floating`:d],g=rt(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(h)))==null||n?h:h.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:u,strategy:c})),_=d===`floating`?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,v=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),y=await(a.isElement==null?void 0:a.isElement(v))&&await(a.getScale==null?void 0:a.getScale(v))||{x:1,y:1},b=rt(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:_,offsetParent:v,strategy:c}):_);return{top:(g.top-b.top+m.top)/y.y,bottom:(b.bottom-g.bottom+m.bottom)/y.y,left:(g.left-b.left+m.left)/y.x,right:(b.right-g.right+m.right)/y.x}}var ot=new Set([`left`,`top`]);function st(){return typeof window<`u`}function ct(e){return ut(e)?(e.nodeName||``).toLowerCase():`#document`}function Q(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function lt(e){return((ut(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ut(e){return!!st()&&(e instanceof Node||e instanceof Q(e).Node)}function dt(e){return!!st()&&(e instanceof Element||e instanceof Q(e).Element)}function ft(e){return!!st()&&(e instanceof HTMLElement||e instanceof Q(e).HTMLElement)}function pt(e){return!(!st()||typeof ShadowRoot>`u`)&&(e instanceof ShadowRoot||e instanceof Q(e).ShadowRoot)}function mt(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=wt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ht(e){return/^(table|td|th)$/.test(ct(e))}function gt(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var _t,vt=/transform|translate|scale|rotate|perspective|filter/,yt=/paint|layout|strict|content/,bt=e=>!!e&&e!==`none`;function xt(e){let t=dt(e)?wt(e):e;return bt(t.transform)||bt(t.translate)||bt(t.scale)||bt(t.rotate)||bt(t.perspective)||!St()&&(bt(t.backdropFilter)||bt(t.filter))||vt.test(t.willChange||``)||yt.test(t.contain||``)}function St(){return _t??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),_t}function Ct(e){return/^(html|body|#document)$/.test(ct(e))}function wt(e){return Q(e).getComputedStyle(e)}function Tt(e){return dt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Et(e){if(ct(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||pt(e)&&e.host||lt(e);return pt(t)?t.host:t}function Dt(e){let t=Et(e);return Ct(t)?(e.ownerDocument||e).body:ft(t)&&mt(t)?t:Dt(t)}function Ot(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Dt(e),i=r===e.ownerDocument?.body,a=Q(r);if(i){let e=kt(a);return t.concat(a,a.visualViewport||[],mt(r)?r:[],e&&n?Ot(e):[])}return t.concat(r,Ot(r,[],n))}function kt(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function At(e){let t=wt(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ft(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=ze(n)!==a||ze(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function jt(e){return dt(e)?e:e.contextElement}function Mt(e){let t=jt(e);if(!ft(t))return Ve(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=At(t),o=(a?ze(n.width):n.width)/r,s=(a?ze(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var Nt=Ve(0);function Pt(e){let t=Q(e);return St()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Nt}function Ft(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=jt(e),o=Ve(1);t&&(r?dt(r)&&(o=Mt(r)):o=Mt(e));let s=function(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Q(e)}(a,n,r)?Pt(a):Ve(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Q(a),t=dt(r)?Q(r):r,n=e,i=kt(n);for(;i&&t!==n;){let e=Mt(i),t=i.getBoundingClientRect(),r=wt(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Q(i),i=kt(n)}}return rt({width:u,height:d,x:c,y:l})}function It(e,t){let n=Tt(e).scrollLeft;return t?t.left+n:Ft(lt(e)).left+n}function Lt(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-It(e,n),y:n.top+t.scrollTop}}function Rt(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=function(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Q(e),a=lt(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!St()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(It(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=25&&(s-=o)}return{width:s,height:c,x:l,y:u}}(e,n,t);else if(t===`document`)r=function(e){let t=Tt(e),n=e.ownerDocument.body,r=Re(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Re(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+It(e),o=-t.scrollTop;return wt(n).direction===`rtl`&&(a+=Re(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}(lt(e));else if(dt(t))r=function(e,t){let n=Ft(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Mt(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}(t,n);else{let n=Pt(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return rt(r)}function zt(e,t){let n=t.get(e);if(n)return n;let r=Ot(e,[],!1).filter(e=>dt(e)&&ct(e)!==`body`),i=null,a=wt(e).position===`fixed`,o=a?Et(e):e;for(;dt(o)&&!Ct(o);){let e=wt(o),t=xt(o),n=i?i.position:a?`fixed`:``;t||n!==`fixed`&&(n!==`absolute`||e.position!==`static`)?i=e:r=r.filter(e=>e!==o),o=Et(o)}return t.set(e,r),r}function Bt(e,t,n){let r=ft(t),i=lt(t),a=n===`fixed`,o=Ft(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Ve(0);if((r||!a)&&((ct(t)!==`body`||mt(i))&&(s=Tt(t)),r)){let e=Ft(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=It(i));let l=!i||r||a?Ve(0):Lt(i,s);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Vt(e){return wt(e).position===`static`}function Ht(e,t){if(!ft(e)||wt(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return lt(e)===n&&(n=n.ownerDocument.body),n}function Ut(e,t){let n=Q(e);if(gt(e))return n;if(!ft(e)){let t=Et(e);for(;t&&!Ct(t);){if(dt(t)&&!Vt(t))return t;t=Et(t)}return n}let r=Ht(e,t);for(;r&&ht(r)&&Vt(r);)r=Ht(r,t);return r&&Ct(r)&&Vt(r)&&!xt(r)?n:r||function(e){let t=Et(e);for(;ft(t)&&!Ct(t);){if(xt(t))return t;if(gt(t))return null;t=Et(t)}return null}(e)||n}var Wt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=lt(r),s=!!t&&gt(t.floating);if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Ve(1),u=Ve(0),d=ft(r);if((d||!a)&&((ct(r)!==`body`||mt(o))&&(c=Tt(r)),d)){let e=Ft(r);l=Mt(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=!o||d||a?Ve(0):Lt(o,c);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}},getDocumentElement:lt,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?gt(t)?[]:zt(t,this._c):[].concat(n),r],o=Rt(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Rt(t,a[e],i);s=Re(n.top,s),c=Le(n.right,c),l=Le(n.bottom,l),u=Re(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}},getOffsetParent:Ut,getElementRects:async function(e){let t=this.getOffsetParent||Ut,n=this.getDimensions,r=await n(e.floating);return{reference:Bt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return e.getClientRects?Array.from(e.getClientRects()):[]},getDimensions:function(e){let{width:t,height:n}=At(e);return{width:t,height:n}},getScale:Mt,isElement:dt,isRTL:function(e){return wt(e).direction===`rtl`}};function Gt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Kt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=jt(e),u=i||a?[...l?Ot(l):[],...t?Ot(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?function(e,t,n){let r,i=null,a=lt(e);function o(){var e;clearTimeout(r),(e=i)==null||e.disconnect(),i=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m={rootMargin:-Be(d)+`px `+-Be(a.clientWidth-(u+f))+`px `+-Be(a.clientHeight-(d+p))+`px `+-Be(u)+`px`,threshold:Re(0,Le(1,c))||1},h=!0;function g(t){let n=t[0].intersectionRatio;if(!Gt(l,e.getBoundingClientRect()))return s();if(n!==c){if(!h)return s();n?s(!1,n):r=setTimeout(()=>{s(!1,1e-7)},1e3)}h=!1}try{i=new IntersectionObserver(g,{...m,root:a.ownerDocument})}catch{i=new IntersectionObserver(g,m)}i.observe(e)}let c=Q(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}(l,n,a):null,f,p=-1,m=null;o&&(m=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;(e=m)==null||e.observe(t)})),n()}),l&&!c&&m.observe(l),t&&m.observe(t));let h=c?Ft(e):null;return c&&function t(){let r=Ft(e);h&&!Gt(h,r)&&n(),h=r,f=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=m)==null||e.disconnect(),m=null,c&&cancelAnimationFrame(f)}}var qt=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await async function(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=We(n),s=Ge(n),c=Je(n)===`y`,l=ot.has(o)?-1:1,u=a&&c?-1:1,d=Ue(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?-1*m:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Jt=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Ue(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Je(i),p=Ke(f),m=u[p],h=u[f],g=(e,t)=>{return n=t+d[e===`y`?`top`:`left`],r=t,i=t-d[e===`y`?`bottom`:`right`],Re(n,Le(r,i));var n,r,i};o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Yt=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Ue(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=We(r),_=Je(o),v=We(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[nt(o)]:function(e){let t=nt(e);return[Xe(e),t,Xe(t)]}(o)),x=p!==`none`;!d&&x&&b.push(...tt(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=function(e,t,n){n===void 0&&(n=!1);let r=Ge(e),i=Ye(e),a=qe(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=nt(o)),[o,nt(o)]}(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Je(t)||T.every(e=>Je(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Je(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},Xt=(e,t,n)=>{let r=new Map,i=n??{},a={...Wt,...i.platform,_c:r};return(async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:at},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=it(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<50&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=!0===x.rects?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=it(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}})(e,t,{...i,platform:a})},Zt=typeof document<`u`?s.useLayoutEffect:function(){};function Qt(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,i;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(!Qt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if((n!==`_owner`||!e.$$typeof)&&!Qt(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function $t(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function en(e,t){let n=$t(e);return Math.round(t*n)/n}function tn(e){let t=s.useRef(e);return Zt(()=>{t.current=e}),t}var nn=(e,t)=>{let n=qt(e);return{name:n.name,fn:n.fn,options:[e,t]}},rn=(e,t)=>{let n=Jt(e);return{name:n.name,fn:n.fn,options:[e,t]}},an=(e,t)=>{let n=Yt(e);return{name:n.name,fn:n.fn,options:[e,t]}},on=e=>{let t=(0,l.useFloatSurface)(),n=(0,l.useTokenThemeContext)(),r=e?.getElement(),i={},a=r?.closest(`[${l.THEME_MODE_ATTR}]`)?.getAttribute(l.THEME_MODE_ATTR),o=r?.closest(`[${l.THEME_SURFACE_ATTR}]`)?.getAttribute(l.THEME_SURFACE_ATTR);a&&(i[l.THEME_MODE_ATTR]=a),o&&(i[l.THEME_SURFACE_ATTR]=o);let s=[...t?.themeScope?.classes??[],n?.scopeClass].filter(Boolean);return{className:s.length?s.join(` `):void 0,attrs:i}},sn=e=>{let{side:t,align:n=`center`}=e;return(t===`t`?`top`:t===`b`?`bottom`:t===`l`?`left`:`right`)+(n===`start`?`-start`:n===`end`?`-end`:``)},cn=e=>{let{state:t,offset:n,alignOffset:r,open:i,container:a,className:o,style:u,zIndex:f,children:p}=e,{getPortalContainer:m}=(0,l.useFullscreenPortal)(),{className:h,attrs:g}=on(t.pane),{getBoundaryRect:_}=t,v=(0,s.useMemo)(()=>[nn({mainAxis:n,alignmentAxis:r}),an(()=>({boundary:_()})),rn(()=>({boundary:_(),padding:4}))],[n,r,_]),{refs:y,floatingStyles:b,update:x}=function(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:c=!0,whileElementsMounted:l,open:u}=e,[f,p]=s.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=s.useState(r);Qt(m,r)||h(r);let[g,_]=s.useState(null),[v,y]=s.useState(null),b=s.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=s.useCallback(e=>{e!==T.current&&(T.current=e,y(e))},[]),S=a||g,C=o||v,w=s.useRef(null),T=s.useRef(null),E=s.useRef(f),D=l!=null,O=tn(l),k=tn(i),A=tn(u),j=s.useCallback(()=>{if(!w.current||!T.current)return;let e={placement:t,strategy:n,middleware:m};k.current&&(e.platform=k.current),Xt(w.current,T.current,e).then(e=>{let t={...e,isPositioned:!1!==A.current};M.current&&!Qt(E.current,t)&&(E.current=t,d.flushSync(()=>{p(t)}))})},[m,t,n,k,A]);Zt(()=>{!1===u&&E.current.isPositioned&&(E.current.isPositioned=!1,p(e=>({...e,isPositioned:!1})))},[u]);let M=s.useRef(!1);Zt(()=>(M.current=!0,()=>{M.current=!1}),[]),Zt(()=>{if(S&&(w.current=S),C&&(T.current=C),S&&C){if(O.current)return O.current(S,C,j);j()}},[S,C,j,O,D]);let N=s.useMemo(()=>({reference:w,floating:T,setReference:b,setFloating:x}),[b,x]),P=s.useMemo(()=>({reference:S,floating:C}),[S,C]),F=s.useMemo(()=>{let e={position:n,left:0,top:0};if(!P.floating)return e;let t=en(P.floating,f.x),r=en(P.floating,f.y);return c?{...e,transform:`translate(`+t+`px, `+r+`px)`,...$t(P.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,c,P.floating,f.x,f.y]);return s.useMemo(()=>({...f,update:j,refs:N,elements:P,floatingStyles:F}),[f,j,N,P,F])}({placement:sn(t.placement),strategy:`fixed`,elements:{reference:t.reference},whileElementsMounted:Kt,middleware:v});if((0,s.useLayoutEffect)(()=>{x()},[t,x]),!i)return null;let S=typeof p==`function`?p(t):p;return(0,d.createPortal)((0,c.jsx)(`div`,{ref:y.setFloating,className:[o,h].filter(Boolean).join(` `)||void 0,...g,style:{...b,zIndex:f,...u},children:S}),a??m())},ln=e=>{let{anchor:t,placement:n,whenOff:r,boundary:i,minVisible:a,offset:o=4,alignOffset:s=0,open:l=!0,container:u,className:d,style:f,zIndex:p=1250,children:m}=e;return(0,c.jsx)(Pe,{anchor:t,placement:n,whenOff:r,boundary:i,minVisible:a,children:e=>(0,c.jsx)(cn,{state:e,offset:o,alignOffset:s,open:l,container:u,className:d,style:f,zIndex:p,children:m})})};ln.displayName=`StickyFloat`;var un=e=>{let[t,n]=(e??`bottom-start`).split(`-`);return{side:t===`top`?`t`:t===`left`?`l`:t===`right`?`r`:`b`,align:n===`start`?`start`:n===`end`?`end`:`center`}},dn={update:()=>{}},fn=e=>{let{open:t,anchorEl:n,floatReference:r,createPopupPanel:i,propsPopper:a,onMount:o,onOpening:u,onOpen:d,onClosing:f,onClose:p,children:m,className:h,label:g,anchorPosition:_,...v}=e,y=(0,s.useRef)(null),[b,x]=(0,s.useState)(),S=(0,l.useCallbackRef)(o??(()=>{}),[o]),C=(0,l.useCallbackRef)(u??(()=>{}),[u]),w=(0,l.useCallbackRef)(d??(()=>{}),[d]),T=(0,l.useCallbackRef)(f??(()=>{}),[f]),E=(0,l.useCallbackRef)(p??(()=>{}),[p]);(0,s.useEffect)(()=>{if(t){let e=y.current;if(!e)return;x(e),S(e,dn),C(),w();return}T(),E()},[t]);let D=(0,l.useCallbackRef)(()=>{r?.close(0)},[r]),O=a?.offsets;return(0,c.jsx)(ln,{anchor:n,placement:un(a?.placement),offset:O?.[1]??2,alignOffset:O?.[0]??0,zIndex:1300,children:e=>(0,c.jsxs)(`div`,{onKeyDown:a?.onKeyDown,onMouseEnter:a?.onMouseEnter,children:[(0,c.jsx)(l.FloatPanelSurface,{ref:y,className:h,floatReference:r,popupContainer:b,createPopupPanel:i,...v,children:m}),(0,c.jsx)(pn,{outOfView:t&&e.outOfView,close:D})]})})};fn.displayName=`GridFloatPanel`;var pn=({outOfView:e,close:t})=>((0,s.useEffect)(()=>{e&&t()},[e]),null),mn={pointerEvents:`auto`},hn=(e={})=>{let{openDelay:t=300,closeDelay:n=150}=e,[r,i]=(0,s.useState)(!1),a=(0,s.useRef)(!1),o=(0,s.useRef)(null),c=(0,s.useRef)(!1),l=(0,s.useRef)(null),u=(0,s.useRef)(null),d=e=>{a.current=e,i(e)},f=()=>{l.current&&=(clearTimeout(l.current),null)},p=()=>{u.current&&=(clearTimeout(u.current),null)},m=(0,s.useCallback)(()=>{f(),p(),u.current=setTimeout(()=>{u.current=null,c.current||o.current!==null||d(!1)},n)},[n]),h=(0,s.useCallback)(e=>{if(e!==o.current)if(o.current=e,e!==null){if(p(),a.current)return;f(),l.current=setTimeout(()=>{l.current=null,o.current!==null&&d(!0)},t)}else m()},[t,m]),g=(0,s.useCallback)(()=>{f(),p(),o.current=null,c.current=!1,d(!1)},[]),_=(0,s.useMemo)(()=>({onPointerEnter:()=>{c.current=!0,p()},onPointerLeave:()=>{c.current=!1,m()},style:mn}),[m]);return(0,s.useEffect)(()=>()=>{f(),p()},[]),{open:r,setTarget:h,tipProps:_,close:g}},gn={target:null,aimed:null},_n=e=>({key:e.key??R(e.range),range:e.range,data:e.data,placement:e.placement}),vn=(e,t)=>Array.isArray(e)?e.includes(t):e===t,yn=e=>{let t=e.getCoords();return t?`${t.rowIndex},${t.colIndex}`:null},bn=e=>{let{activateOn:t,name:n,probe:r,selection:i,target:a,dismiss:o,placement:u,offset:d=6,alignOffset:f=0,openDelay:p=300,closeDelay:m=150,whenOff:h=`hide`,boundary:g,zIndex:_,children:v,className:y,style:b}=e,x=W(),S=(0,s.useContext)(ee),w=vn(t,`hover`),T=vn(t,`selection`),E=a!==void 0,{open:D,setTarget:O,tipProps:k,close:A}=hn({openDelay:p,closeDelay:m}),[j,M]=ve(`range-float:${n??S}`,gn),N=(0,l.useCallbackRef)(()=>{M(e=>e.aimed===null?e:{target:e.target,aimed:null})},[M]),P=(0,l.useCallbackRef)(e=>{let t=x.getCellFromPointer(e.clientX,e.clientY),n=t?r?.(t,x):null;if(!n?.range)return void N();let i=_n(n);M(e=>e.aimed===i.key&&e.target?.key===i.key?e:{target:i,aimed:i.key})},[x,r,M,N]),F=w?j.aimed:null;(0,s.useEffect)(()=>{O(F)},[F,O]),(0,s.useEffect)(()=>{o&&(A(),M(gn))},[o,A,M]);let I=(0,l.useOptionalBoundSyncExternalStore)(T?i:void 0,yn),L=null;if(T&&!o&&i&&I!==null){let e=r?.(i.getCoords(),x);e&&e.range&&(L=_n(e))}let R=w?j.target:null,te=D&&R!==null,ne=E?a===null?null:_n(a):te?R:L??R,re=E?ne!==null:te||L!==null;return(0,c.jsx)(ye,{className:C(y,`range-float`),onPointerMove:w?P:void 0,onPointerLeave:w?N:void 0,children:ne&&(0,c.jsx)(ln,{anchor:{range:ne.range},placement:ne.placement??u,offset:d,alignOffset:f,boundary:g,zIndex:_,open:re,whenOff:h,style:b,children:e=>v({range:ne.range,data:ne.data,floatProps:k,state:e})})})};bn.displayName=`RangeFloatLayer`;var xn=e=>{let{children:t,className:n,...r}=e;return(0,c.jsx)(bn,{...r,activateOn:`hover`,className:C(n,`hover-tip`),children:({range:e,data:n,floatProps:r,state:i})=>t({range:e,data:n,tipProps:r,state:i})})};xn.displayName=`HoverTipLayer`;var Sn={t:`↑`,b:`↓`,l:`←`,r:`→`},Cn=e=>{let t=``,n=e;do t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26)-1;while(n>=0);return t},wn=e=>{let t=`${Cn(e.colStart)}${e.rowStart+1}`,n=`${Cn(e.colEnd)}${e.rowEnd+1}`;return t===n?t:`${t}:${n}`},Tn={border:`none`,background:`transparent`,color:`inherit`,cursor:`pointer`,font:`14px/1 system-ui`,padding:0,width:18,height:18,borderRadius:4,opacity:.6},En={position:`relative`,background:`var(--sxl-color-base-100, white)`,color:`var(--sxl-color-base-content, #222)`,border:`1px solid var(--sxl-color-base-300, #ccc)`,borderRadius:8,padding:`10px 12px`,boxShadow:`0 6px 24px var(--sxl-color-shadow, rgba(0,0,0,0.2))`,pointerEvents:`auto`,maxWidth:320},Dn={display:`inline-flex`,alignItems:`center`,gap:8,background:`var(--sxl-color-base-content, rgb(55,55,65))`,color:`var(--sxl-color-base-100, white)`,borderRadius:16,padding:`4px 6px 4px 12px`,boxShadow:`0 2px 10px var(--sxl-color-shadow, rgba(0,0,0,0.3))`,pointerEvents:`auto`},On=({direction:e,label:t,onGoto:n,onCancel:r})=>(0,c.jsxs)(`div`,{style:Dn,children:[(0,c.jsxs)(`button`,{onClick:n,style:{border:`none`,background:`transparent`,color:`inherit`,cursor:`pointer`,font:`12px system-ui`},children:[Sn[e],` `,t]}),r&&(0,c.jsx)(`button`,{"aria-label":`Cancel`,onClick:r,style:{...Tn,opacity:.8},children:`×`})]}),kn=e=>{let{range:t,placement:n={side:`t`,align:`start`},offset:r=8,alignOffset:i=0,address:a,onGoto:o,onCancel:s,zIndex:l,className:u,style:d,children:f}=e;return(0,c.jsx)(ln,{anchor:{range:t},placement:n,offset:r,alignOffset:i,whenOff:`clamp`,zIndex:l,open:!0,children:e=>{if(e.outOfView)return(0,c.jsx)(On,{direction:e.slid?.direction??n.side,label:a??wn(t),onGoto:()=>o?o(e):e.scrollIntoView(),onCancel:s});let r=typeof f==`function`?f(e):f;return(0,c.jsxs)(`div`,{className:u,style:{...En,...d},children:[s&&(0,c.jsx)(`button`,{"aria-label":`Cancel`,onClick:s,style:{...Tn,position:`absolute`,top:4,right:4},children:`×`}),r]})}})};kn.displayName=`RangePrompt`;var An={stroke:`var(--sxl-color-primary, rgb(33, 115, 70))`,alignWidth:2,fill:`color-mix(in srgb, var(--sxl-color-primary, rgb(33, 115, 70)) 10%, transparent)`},jn=(0,s.memo)(e=>{let{range:t,hole:n,clipInsets:r,alignWidth:i=1,animatedTransition:a,className:o,...s}=e,u=l.ReactUtils.getDevicePixelRatio(),d=i/u,f=r??-d/2,p=G(),m=p?p.getBoundsFromRange(t):null,h=d+4;if(p&&m&&!p.toClipBounds(m,f))return null;let g=p?p.getPaneBounds():null,v=g?{x:-h,y:-h,width:g.width+2*h,height:g.height+2*h}:m,y=v?l.ReactUtils.snapDeviceEdge(v.x,u):0,b=v?l.ReactUtils.snapDeviceEdge(v.y,u):0,x;if(m&&v){let e=d+2,t=Math.max(m.x,v.x-e),n=Math.max(m.y,v.y-e);x={x:t-y,y:n-b,width:Math.min(m.x+m.width,v.x+v.width+e)-t,height:Math.min(m.y+m.height,v.y+v.height+e)-n}}let S=n&&p?p.getBoundsFromRange(n):null,w=S?{x:S.x-y,y:S.y-b,width:S.width,height:S.height}:void 0;return(0,c.jsx)(q,{className:C(o),bounds:v??void 0,clipInsets:f,style:{pointerEvents:`none`},children:(0,c.jsx)(_,{bounds:x,alignWidth:i,hole:w,animatedTransition:a,...s})})});jn.displayName=`RangeRect`;var Mn=(0,s.memo)(e=>{let{range:t,axis:n,color:r=`var(--sxl-color-primary, rgb(33, 115, 70))`,alignWidth:i=3,capExtent:a=3,transitionDuration:o=100,transitionEasing:s=`cubic-bezier(0.16, 1, 0.3, 1)`,axisDuration:d=70}=e,f=G(),p=f?.getBoundsFromRange(t);if(!f||!p)return null;let m=l.ReactUtils.getDevicePixelRatio(),h=i/m,g=a/m,_=f.getPaneBounds(),v=e=>e.x>=-g&&e.y>=-g&&e.x+e.width<=_.width+g&&e.y+e.height<=_.height+g,y=o>0?`${o}ms ${s}`:null,b=d>0?`${d}ms ${s}`:null,x=[y&&`transform ${y}, width ${y}, height ${y}, background-color ${y}`,b&&`scale ${b}`].filter(Boolean).join(`, `);return(0,c.jsx)(c.Fragment,{children:[!0,!1].map(e=>(e=>{let t=e?{x:p.x,y:p.y-h/2,width:p.width,height:h}:{x:p.x-h/2,y:p.y,width:h,height:p.height},n=h+2*g,r=e?{start:{x:t.x,y:t.y-g,width:h,height:n},end:{x:t.x+t.width-h,y:t.y-g,width:h,height:n}}:{start:{x:t.x-g,y:t.y,width:n,height:h},end:{x:t.x-g,y:t.y+t.height-h,width:n,height:h}};return[[`insert-bar`,f.toClipBounds(t,-h)],[`insert-bar-cap-start`,v(r.start)?r.start:null],[`insert-bar-cap-end`,v(r.end)?r.end:null]]})(e).map(([t,i])=>i&&(0,c.jsx)(q,{className:C(t,e?`row`:`column`),bounds:i,style:{pointerEvents:`none`,background:r,scale:+(e===(n===u.RangeAxis.Row)),transformOrigin:`${p.x}px ${p.y}px`,transition:x,willChange:`transform, width, height, scale`}},`${e?`row`:`column`}-${t}`)))})});Mn.displayName=`RangeInsertBar`;var Nn=()=>typeof window<`u`?window:null,Pn=(e,t,n={x:!0,y:!0})=>{let r=e.getElement()?.getBoundingClientRect();if(!r)return!1;let i=!1===n.x?0:t.x<=r.left+24?-1:+(t.x>=r.right-24),a=!1===n.y?0:t.y<=r.top+24?-1:+(t.y>=r.bottom-24);if(!i&&!a)return!1;let o=e.getVisibleRange(),s=e.getTotalRange(),c=e.getCellFromPointer(t.x,t.y),l={};return i>0&&o.colEnd<s.colEnd?l.colIndex=Math.min(s.colEnd,Math.max(o.colEnd+1,c?.colIndex??0)):i<0&&o.colStart>s.colStart&&(l.colIndex=Math.max(s.colStart,Math.min(o.colStart-1,c?.colIndex??2**53-1))),a>0&&o.rowEnd<s.rowEnd?l.rowIndex=Math.min(s.rowEnd,Math.max(o.rowEnd+1,c?.rowIndex??0)):a<0&&o.rowStart>s.rowStart&&(l.rowIndex=Math.max(s.rowStart,Math.min(o.rowStart-1,c?.rowIndex??2**53-1))),(l.colIndex!==void 0||l.rowIndex!==void 0)&&((e.getAllPanes()[u.AnchorLocation.Center]??e).scrollCellCoordsIntoView(l),!0)},Fn=Object.freeze({ctrlKey:!1,shiftKey:!1,altKey:!1,metaKey:!1}),In=e=>({ctrlKey:!!e.ctrlKey,shiftKey:!!e.shiftKey,altKey:!!e.altKey,metaKey:!!e.metaKey}),Ln=(e,t)=>e.ctrlKey===t.ctrlKey&&e.shiftKey===t.shiftKey&&e.altKey===t.altKey&&e.metaKey===t.metaKey,Rn=(e,t,n,r)=>{let i=r??((t,n)=>e.getCellFromPointer(t,n)),a=null,o=null,s=null,c=null,l=null,d=()=>{l&&=(document.removeEventListener(`touchstart`,l,{capture:!0}),document.removeEventListener(`touchmove`,l,{capture:!0}),null)},f=()=>{c&&clearTimeout(c),c=null},p=Fn,m=null,h=e=>{if(!a)return;let t=In(e);Ln(p,t)||(p=t,a.modifiers?.(t))},g=()=>{m&&=(Nn()?.removeEventListener(`keydown`,m,!0),Nn()?.removeEventListener(`keyup`,m,!0),null)},_=(t,n,r)=>{if(!a)return!1;let s=i(t,n);return s&&(u.CoordUtils.isEqualCells(s,o)||(o=s,a.drag(s,r)),a.point?.(s,t,n,r)),(a.edgeScroll??(t=>Pn(e,t)))({x:t,y:n})};return{hasSession:()=>a!==null,captureEvents:()=>a?.captureEvents,begin:e=>{let r=i(e.clientX,e.clientY);if(!r)return null;let c=t(r,e);return c?(a=c,o=r,s=null,e.pointerType===`touch`&&!1!==c.capture&&(()=>{if(l)return;let e=e=>{e.stopImmediatePropagation(),e.preventDefault()};l=e,document.addEventListener(`touchstart`,e,{capture:!0,passive:!1}),document.addEventListener(`touchmove`,e,{capture:!0,passive:!1})})(),(e=>{if(p=In(e),m)return;let t=e=>h(e);m=t,Nn()?.addEventListener(`keydown`,t,!0),Nn()?.addEventListener(`keyup`,t,!0)})(e),n?.(c.dragMode??null),c):null},move:(e,t,n)=>{a&&(n&&h(n),s={x:e,y:t},_(e,t,n)?(f(),c=setTimeout(function e(){c=a&&s&&_(s.x,s.y)?setTimeout(e,60):null},60)):f())},reset:()=>{let e=a;return a=null,o=null,s=null,f(),d(),g(),p=Fn,e&&n?.(null),e},dispose:()=>{f(),d(),g()}}},zn=(e,t,n)=>{let r=Rn(e,t,n),i=!1,a=null,o=null,s=null,c=null,l=null,u=()=>{s&&a&&a.removeEventListener?.(`pointercancel`,s),s=null,c&&Nn()?.removeEventListener(`keydown`,c,!0),c=null},d=()=>{l&&=(Nn()?.removeEventListener(`pointerup`,l),Nn()?.removeEventListener(`pointercancel`,l),null)},f=()=>{a&&o!==null&&a.hasPointerCapture?.(o)&&a.releasePointerCapture(o),a=null,o=null},p=(e,t)=>{let n=i,a=r.reset();i=!1,u(),d(),f(),a&&(e?a.cancel?.(t):t&&(!1!==a.captureEvents&&n&&t.stopPropagation(),a.end?.(t)))};return{onPointerDown:e=>{let t=r.begin(e);if(t)if(!1!==t.capture){let t=e.currentTarget;t.setPointerCapture?.(e.pointerId),a=t,o=e.pointerId,i=!0,s=e=>p(!0,e),t.addEventListener?.(`pointercancel`,s),c=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),p(!0))},Nn()?.addEventListener(`keydown`,c,!0)}else i=!1,l=e=>p(e.type===`pointercancel`,e),Nn()?.addEventListener(`pointerup`,l),Nn()?.addEventListener(`pointercancel`,l)},onPointerMove:e=>{r.hasSession()&&i&&(!1!==r.captureEvents()&&e.stopPropagation(),r.move(e.clientX,e.clientY,e))},onPointerUp:e=>p(!1,e),onPointerCancel:e=>p(!0,e),dispose:()=>{u(),d(),f(),r.dispose()}}};function Bn(e,t,n,r){let i=Rn(e,t,n,r),a=null,o=null,s=null,c=()=>{a?.(),a=null},l=()=>{o&&s!==null&&o.hasPointerCapture?.(s)&&o.releasePointerCapture(s),o=null,s=null};return{start:(e,t)=>{c(),l();let n=i.begin(e);if(!n)return;if(!1!==n.capture){let n=t??e.currentTarget;n&&(n.setPointerCapture?.(e.pointerId),o=n,s=e.pointerId)}let r=e=>i.move(e.clientX,e.clientY,e),u=(e,t)=>{c();let n=i.reset();l(),n&&(e?n.cancel?.(t):n.end?.(t))},d=e=>u(!1,e),f=e=>u(!0,e),p=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u(!0))};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,f),window.addEventListener(`keydown`,p,!0),a=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,f),window.removeEventListener(`keydown`,p,!0)}},dispose:()=>{c(),l(),i.dispose()}}}var Vn=e=>{let t=W(),[n,r]=(0,s.useState)(null),i=(0,s.useRef)(e);i.current=e;let a=(0,s.useMemo)(()=>zn(t,(e,t)=>i.current(e,t),r),[t]);return(0,s.useEffect)(()=>()=>a.dispose(),[a]),{onPointerDown:a.onPointerDown,onPointerMove:a.onPointerMove,onPointerUp:a.onPointerUp,onPointerCancel:a.onPointerCancel,dragMode:n}},Hn=e=>{let t=W(),[n,r]=(0,s.useState)(null),i=(0,s.useRef)(e);i.current=e;let a=(0,s.useMemo)(()=>Bn(t,(e,t)=>i.current(e,t),r),[t]);return(0,s.useEffect)(()=>()=>a.dispose(),[a]),{start:a.start,dragMode:n}},Un=e=>{let t=(0,s.useRef)(null),n=(0,s.useRef)(!1);return(0,s.useEffect)(()=>{let e=e=>{n.current&&(n.current=!1,e.stopPropagation(),e.preventDefault())};return window.addEventListener(`dblclick`,e,!0),()=>window.removeEventListener(`dblclick`,e,!0)},[]),r=>{if(!e||r.button!==0)return!1;let i=t.current,a=!!i&&r.timeStamp-i.time<=500&&Math.abs(r.clientX-i.x)<=4&&Math.abs(r.clientY-i.y)<=4;return t.current=a?null:{time:r.timeStamp,x:r.clientX,y:r.clientY},!!a&&(r.stopPropagation(),n.current=!0,window.setTimeout(()=>{n.current=!1},500),!0)}},Wn=e=>{let{range:t,anchor:n,size:r=8,cursor:i,dragCursor:a,background:o=`var(--sxl-color-primary, rgb(33, 115, 70))`,onDragStart:u,onDragMove:d,onDragEnd:f,onDragCancel:p,onDoubleClick:m,onHoverChange:h,hoverStyle:g,animatedTransition:_,renderHandle:v,children:y,className:b,style:x,preserveFocus:S,clampToView:w,secondaryButton:T}=e,E=W(),[D,O]=(0,s.useState)(!1),k=Un(!!m),{start:A,dragMode:j}=Hn((e,t)=>{let n=t.button===2&&!0===T;if(t.button!==0&&!n)return null;t.stopPropagation(),S&&t.preventDefault();let r=n?Gn():null,i=e,a=e;return u?.(i,t),{dragMode:`handle`,drag:(e,n)=>{a=e,d?.(i,e,n??t)},end:e=>{r?.(),f?.(i,a,e)},cancel:()=>{r?.(),p?.()}}}),M=j!==null&&a?a:i??Yn[n],N=E.getBoundsFromRange(t);if(!N)return null;let P=l.ReactUtils.getDevicePixelRatio(),F=Jn(N.x,N.x+N.width,Kn[n],P),I=Jn(N.y,N.y+N.height,qn[n],P);if(w){if(!E.toClipBounds(E.getBoundsFromRange(t)))return null;let e=E.getPaneBounds(),n=r/2+1;!0!==w&&w!==`x`||(F=Math.max(n,Math.min(e.width-n,F))),!0!==w&&w!==`y`||(I=Math.max(n,Math.min(e.height-n,I)))}let L={position:`absolute`,cursor:M,pointerEvents:`all`,left:0,top:0,transform:`translate(${F}px, ${I}px) translate(-50%, -50%)`,..._?{transition:`transform 60ms ease-in-out`,willChange:`transform`}:void 0},R={className:C(`drag-handle`,b),onPointerDown:e=>{k(e)?m(e):A(e)},onDoubleClick:m?e=>e.stopPropagation():void 0,onPointerEnter:()=>{O(!0),h?.(!0)},onPointerLeave:()=>{O(!1),h?.(!1)}};return v?(0,c.jsx)(c.Fragment,{children:v({anchor:n,size:r,cursor:M,background:o,hovered:D,handleProps:{...R,style:L}})}):(0,c.jsx)(`div`,{...R,style:{...L,width:r,height:r,background:y==null?o:void 0,border:y==null?`1px solid var(--sxl-color-base-100, white)`:void 0,borderRadius:1,boxSizing:`border-box`,...x,...D?g:void 0},children:y})};Wn.displayName=`DragHandle`;var Gn=()=>{let e=e=>{e.preventDefault(),e.stopPropagation()};return window.addEventListener(`contextmenu`,e,!0),()=>{setTimeout(()=>window.removeEventListener(`contextmenu`,e,!0),0)}},Kn={tl:`leading`,l:`leading`,bl:`leading`,t:`center`,b:`center`,tr:`trailing`,r:`trailing`,br:`trailing`},qn={tl:`leading`,t:`leading`,tr:`leading`,l:`center`,r:`center`,bl:`trailing`,b:`trailing`,br:`trailing`},Jn=(e,t,n,r)=>n===`center`?l.ReactUtils.snapDeviceEdge((e+t)/2,r):l.ReactUtils.edgeCenter(n===`leading`?e:t,n,2,r),Yn={tl:`nwse-resize`,br:`nwse-resize`,tr:`nesw-resize`,bl:`nesw-resize`,t:`ns-resize`,b:`ns-resize`,l:`ew-resize`,r:`ew-resize`},Xn=(e,t,n,r,i,a)=>{let o=e.getPanePointFromPointer(n,r),s=e.getCellFromPointer(n,r,!0)??t,c=e.getBoundsFromRange(u.CoordUtils.cellToRange(s));if(!o||!c||c.width<=0||c.height<=0)return a;let l=(o.x-c.x)/c.width,d=(o.y-c.y)/c.height,f=i??(l<.25||l>.75?u.RangeAxis.Column:u.RangeAxis.Row);return f===u.RangeAxis.Column?{axis:f,origin:{rowIndex:s.rowIndex,colIndex:l<.5?s.colIndex:s.colIndex+1}}:{axis:f,origin:{rowIndex:d<.5?s.rowIndex:s.rowIndex+1,colIndex:s.colIndex}}},Zn=(e,t)=>e===t||!!e&&!!t&&e.axis===t.axis&&u.CoordUtils.isEqualCells(e.origin,t.origin),Qn=(e,t,n)=>{let r=e.rowEnd-e.rowStart,i=e.colEnd-e.colStart,a=w(t.origin.rowIndex,n.rowStart,n.rowEnd-r),o=w(t.origin.colIndex,n.colStart,n.colEnd-i);return{...e,rowStart:a,rowEnd:a+r,colStart:o,colEnd:o+i}},$n=e=>{let{range:t,children:n,grip:r=`entire`,hitSize:i=10,onHoverChange:a,onDragStateChange:o,onDragStart:d,onDragMove:f,onDragEnd:p,renderMove:m,dragCursor:h=`grabbing`,preserveFocus:g,onEdgeDoubleClick:v,className:y}=e,b=W(),x=t?`range-move:${t.rowStart}:${t.colStart}:${t.rowEnd}:${t.colEnd}`:`range-move`,S=(0,s.useRef)(null),[w,T]=ve(x,null),{start:E,dragMode:D}=Hn((e,n)=>{if(n.button!==0||!t)return null;n.stopPropagation(),g&&n.preventDefault();let r=e,i=t,a=i;n.clientX,n.clientY;let s=((e,t)=>e.colStart<=t.colStart&&e.colEnd>=t.colEnd?u.RangeAxis.Row:e.rowStart<=t.rowStart&&e.rowEnd>=t.rowEnd?u.RangeAxis.Column:null)(i,b.getTotalRange()),c={mods:In(n),insert:Xn(b,e,n.clientX,n.clientY,s,null)},l=c.insert,h=n;o?.(!0),d?.(i,n,c);let _=()=>{m&&T({range:a,info:c}),f?.(a,h,c)},v=!1;return{dragMode:`move`,drag:e=>{a=(e=>er(i,e.rowIndex-r.rowIndex,e.colIndex-r.colIndex,b.getTotalRange()))(e),v=!0},point:(e,t,n,r)=>{r&&(h=r);let i=Xn(b,e,t,n,s,c.insert),a=v||!Zn(i,c.insert);v=!1,a&&(c={...c,insert:i},_())},modifiers:e=>{c={...c,mods:e},_()},end:e=>{o?.(!1),m&&T(null);let t=In(e);(!u.CoordUtils.isEqualRanges(a,i)||t.shiftKey&&!Zn(c.insert,l))&&p?.(a,e,{...c,mods:t})},cancel:()=>{o?.(!1),m&&T(null)}}}),O=Un(!!v),k=D===null?`move`:h;if(!t)return null;let A={onPointerDown:e=>{if(O(e)){let n=(e=>{let n=b?.getPanePointFromPointer(e.clientX,e.clientY),r=b?.getBoundsFromRange(t);if(!n||!r)return null;let i=Math.abs(n.y-r.y),a=Math.abs(n.y-(r.y+r.height)),o=Math.abs(n.x-r.x),s=Math.abs(n.x-(r.x+r.width)),c=Math.min(i,a,o,s);return c===i?`top`:c===a?`bottom`:c===o?`left`:`right`})(e);n&&v(t,n,e);return}E(e,S.current)}},j=a?{onPointerEnter:()=>a(!0),onPointerLeave:()=>a(!1)}:void 0,M=i/l.ReactUtils.getDevicePixelRatio(),N=b?.getBoundsFromRange(t),P=N?{x:N.x-M,y:N.y-M,width:N.width+2*M,height:N.height+2*M}:void 0;return(0,c.jsxs)(c.Fragment,{children:[r===`entire`?(0,c.jsx)(q,{ref:S,className:C(`drag-grip`,y),...P?{bounds:P}:{range:t},style:{cursor:k},...A,...j}):(0,c.jsx)(q,{ref:S,className:C(`drag-grip`,y),range:t,clipInsets:-M/2,style:{pointerEvents:`none`,cursor:k},...A,children:(0,c.jsx)(_,{stroke:`transparent`,alignWidth:i,propsStrokePath:{cursor:`move`,pointerEvents:`stroke`,...j}})}),n,w&&m?.(w.range,w.info)]})};$n.displayName=`Draggable`;var er=(e,t,n,r)=>{let i=e.rowEnd-e.rowStart,a=e.colEnd-e.colStart,o=w(e.rowStart+t,r.rowStart,r.rowEnd-i),s=w(e.colStart+n,r.colStart,r.colEnd-a);return{rowStart:o,colStart:s,rowEnd:o+i,colEnd:s+a}},tr=[`tl`,`tr`,`br`,`bl`],nr=[`tl`,`t`,`tr`,`r`,`br`,`b`,`bl`,`l`],rr=e=>{let{range:t,anchors:n=nr,onDragStart:r,onDragMove:i,onDragEnd:a,onDragCancel:o,onHandleHoverChange:l,size:u=8,renderHandle:d,preserveFocus:f,...p}=e,m={...An,...p},h=m.stroke??`rgb(33, 115, 70)`,g=W(),[_,v]=(0,s.useState)(null),y=(0,s.useRef)(null);if(!t)return null;let b=_??t;return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(jn,{className:`resizer-outline`,range:b,...m}),n.map(e=>(0,c.jsx)(Wn,{className:`resize-handle ${e}`,range:b,anchor:e,size:u,animatedTransition:m.animatedTransition,dragCursor:`grabbing`,renderHandle:d,preserveFocus:f,onHoverChange:l,style:{background:h,border:`1.5px solid var(--sxl-color-base-100, white)`,borderRadius:0},hoverStyle:{border:`1.5px solid ${h}`},onDragStart:(e,n)=>{y.current=t,r?.(t,n)},onDragMove:(n,r,a)=>{let o=ir(y.current??t,e,r,g.getTotalRange());v(o),i?.(o,a)},onDragEnd:(n,r,i)=>{let o=ir(y.current??t,e,r,g.getTotalRange());y.current=null,v(null),a?.(o,i)},onDragCancel:()=>{y.current=null,v(null),o?.()}},e))]})};rr.displayName=`RangeResizer`;var ir=(e,t,n,r)=>{let{rowStart:i,colStart:a,rowEnd:o,colEnd:s}=e;return t.includes(`t`)&&(i=w(n.rowIndex,r.rowStart,r.rowEnd)),t.includes(`b`)&&(o=w(n.rowIndex,r.rowStart,r.rowEnd)),t.includes(`l`)&&(a=w(n.colIndex,r.colStart,r.colEnd)),t.includes(`r`)&&(s=w(n.colIndex,r.colStart,r.colEnd)),{rowStart:Math.min(i,o),colStart:Math.min(a,s),rowEnd:Math.max(i,o),colEnd:Math.max(a,s)}},ar=(e,t,n)=>{let r=t.rowIndex-e.rowEnd,i=e.rowStart-t.rowIndex,a=t.colIndex-e.colEnd,o=e.colStart-t.colIndex,s=Math.max(r,i,0),c=Math.max(a,o,0);if(s>0||c>0)return s>=c?r>0?{...e,rowEnd:Math.min(n.rowEnd,t.rowIndex)}:{...e,rowStart:Math.max(n.rowStart,t.rowIndex)}:a>0?{...e,colEnd:Math.min(n.colEnd,t.colIndex)}:{...e,colStart:Math.max(n.colStart,t.colIndex)};let l=e.rowStart===n.rowStart&&e.rowEnd===n.rowEnd,u=e.colStart===n.colStart&&e.colEnd===n.colEnd,d=l?0:e.rowEnd-t.rowIndex,f=u?0:e.colEnd-t.colIndex;return d<=0&&f<=0?null:d>=f?{...e,rowEnd:t.rowIndex}:{...e,colEnd:t.colIndex}},or=(e,t)=>t.rowEnd<e.rowEnd?{...e,rowStart:t.rowEnd+1}:t.colEnd<e.colEnd?{...e,colStart:t.colEnd+1}:null,sr=e=>{let{range:t,snapDestination:n,onDragStart:r,onDragMove:i,onDragEnd:a,onMenu:o,onDragDone:l,onDoubleClick:d,renderHandle:f,...p}=e,m={...An,fill:void 0,...p},h=m.stroke,g={...m,strokeDasharray:`3 2`},_=W(),v=(0,s.useRef)(null),[y,b]=ve(`range-fill`,null);if(!t)return null;let x=_.getTotalRange(),S=t.rowStart===x.rowStart&&t.rowEnd===x.rowEnd,C=t.colStart===x.colStart&&t.colEnd===x.colEnd;if(S&&C)return null;let w=Object.keys(_.getAllPanes()).length<=1,T=_.getBoundsFromRange(t),E=_.getPaneBounds(),D=w&&T.y>=0&&T.y+T.height<=E.height,O=w&&T.x>=0&&T.x+T.width<=E.width,k=S&&!D?`tr`:C&&!O?`bl`:`br`,A=k===`tr`?`y`:k===`bl`&&`x`;if(A&&!((e,t,n,r)=>{let i=e.getAllPanes();if(Object.keys(i).length<=1)return!0;let a=e.getAnchor(),o=!!i[u.AnchorLocation.TopLeft],s=!!i[u.AnchorLocation.Top],c=!!i[u.AnchorLocation.Left],l=e.getVisibleRange();if(r){if(a===u.AnchorLocation.Top&&o||a===u.AnchorLocation.Center&&c||!u.CoordUtils.isCellWithinRange({colIndex:t.colStart,rowIndex:t.rowEnd},l)&&!u.CoordUtils.isCellWithinRange({colIndex:t.colStart,rowIndex:t.rowEnd+1},l))return!1}else if(n&&(a===u.AnchorLocation.Left&&o||a===u.AnchorLocation.Center&&s||!u.CoordUtils.isCellWithinRange({colIndex:t.colEnd,rowIndex:t.rowStart},l)&&!u.CoordUtils.isCellWithinRange({colIndex:t.colEnd+1,rowIndex:t.rowStart},l)))return!1;return!0})(_,t,S,C))return null;let j=y?or(t,y):null;return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(Wn,{className:`fill-handle`,range:t,anchor:k,clampToView:A,cursor:`crosshair`,background:h,renderHandle:f,onDoubleClick:d?e=>d(t,e):void 0,secondaryButton:!!o,onDragStart:(e,n)=>{v.current=null,b(null),r?.(t,n)},onDragMove:(e,r,a)=>{let o=ar(t,r,_.getTotalRange());o&&n&&(o=n(t,o)),v.current=o,b(o),o&&i?.(o,a)},onDragEnd:(e,t,n)=>{let r=v.current;v.current=null,r&&n.button===2&&o?o(r,n,()=>b(null)):(b(null),r&&a?.(r,n)),l?.(n)},onDragCancel:()=>{v.current=null,b(null),l?.()}}),y&&(0,c.jsx)(jn,{className:`fill-preview`,range:y,...g}),j&&(0,c.jsx)(jn,{className:`fill-vacated`,range:j,fill:`rgba(128, 128, 128, 0.28)`})]})};sr.displayName=`FillHandle`;var cr=(0,s.memo)(e=>{let{value:t,zoom:n,bounds:r,cell:i,range:a,children:o,className:s,...l}=e;return(0,c.jsx)(`div`,{className:C(s,`cell`),...l,children:t})}),lr=Object.freeze({cells:[],rangesH:[],rangesV:[]}),ur=!1,dr=new WeakMap,fr=(e,t={})=>{let n=e.getVisibleRange(),r=e.getScrollTopLeft(),i=t.bufferRange,a=!!i,o=i?i.rowStart:0,s=i?i.colStart:0,c=i?i.rowEnd:0,l=i?i.colEnd:0,d=dr.get(e);if(d&&d.rowStart===n.rowStart&&d.colStart===n.colStart&&d.rowEnd===n.rowEnd&&d.colEnd===n.colEnd&&d.scrollLeft===r.left&&d.scrollTop===r.top&&d.hasBuffer===a&&d.bRowStart===o&&d.bColStart===s&&d.bRowEnd===c&&d.bColEnd===l&&d.options.cacheToken===t.cacheToken&&d.options.getVisibleCells===t.getVisibleCells&&d.options.hiddenCellAt===t.hiddenCellAt)return d.model;let f=((e,t={})=>{let{getVisibleCells:n,hiddenCellAt:r,bufferRange:i}=t,a=e.getTotalRange(),o=i?{rowStart:Math.max(i.rowStart,a.rowStart),rowEnd:Math.min(i.rowEnd,a.rowEnd),colStart:Math.max(i.colStart,a.colStart),colEnd:Math.min(i.colEnd,a.colEnd)}:null,s=o?e.getVisibleColumns(o.colStart,o.colEnd):e.getVisibleColumns(),c=o?e.getVisibleRows(o.rowStart,o.rowEnd):e.getVisibleRows();if(s.length===0||c.length===0)return lr;let l=t=>e.getRangeFromCell(t),d;if(n)d=n(e,i);else{d=[];let e=c.length,t=s.length;for(let n=0;n<e;n++){let e=c[n].index;for(let n=0;n<t;n++){let t={rowIndex:e,colIndex:s[n].index},i=l(t);u.CoordUtils.isSingleCell(i)&&r?.(t)||d.push({cell:t,range:i})}}}let f=d?d.length:0;if(f===0)return lr;let p=e.getVisibleRange(),m=i??p,h=[],g=[],_=[],v=new Set;for(let t=0;t<f;t++){let n=d[t],i=n?.cell??n;if(!i)continue;let a=n?.range??{rowStart:i.rowIndex,colStart:i.colIndex,rowEnd:i.rowIndex,colEnd:i.colIndex};if(!u.CoordUtils.isRangesIntersect(a,m)&&!u.CoordUtils.isRangeWithinRange(a,m))continue;let o=a&&!u.CoordUtils.isSingleCell(a);if(!o&&r?.(i))continue;let s=null;if(o){let t=l(i);u.CoordUtils.isSingleCell(t)||i.rowIndex===t.rowStart&&i.colIndex===t.colStart||(i={rowIndex:t.rowStart,colIndex:t.colStart});let n=gr(a.rowStart,a.colStart);if(v.has(n))continue;v.add(n),a.rowEnd-a.rowStart>0&&g.push(a),a.colEnd-a.colStart>0&&_.push(a),s=e.getBoundsFromRange(a)}else{let t=e.getRowSize(i.rowIndex),n=e.getColumnSize(i.colIndex);t&&n&&(s={x:n.offset,y:t.offset,width:n.size,height:t.size})}s||=e.getBoundsFromRange(a),s?h.push({cell:i,range:a,bounds:s,value:n?.value}):ur||(ur=!0,console.warn(`grid-react: no bounds for cell`,gr(a.rowStart,a.colStart)))}return{cells:h,rangesH:g,rangesV:_}})(e,t);return dr.set(e,{rowStart:n.rowStart,colStart:n.colStart,rowEnd:n.rowEnd,colEnd:n.colEnd,scrollLeft:r.left,scrollTop:r.top,hasBuffer:a,bRowStart:o,bColStart:s,bRowEnd:c,bColEnd:l,options:t,model:f}),f},pr=Object.freeze({rangesH:[],rangesV:[]}),mr=new WeakMap,hr=(e,t={})=>{let n=e.getVisibleRange(),r=mr.get(e);if(r&&r.rowStart===n.rowStart&&r.colStart===n.colStart&&r.rowEnd===n.rowEnd&&r.colEnd===n.colEnd&&r.cacheToken===t.cacheToken&&r.getVisibleCells===t.getVisibleCells)return r.ranges;let i=((e,t={})=>{let{getVisibleCells:n}=t,r=e.getVisibleRange(),i=[],a=[],o=new Set,s=e=>{if(u.CoordUtils.isSingleCell(e)||!u.CoordUtils.isRangesIntersect(e,r)&&!u.CoordUtils.isRangeWithinRange(e,r))return;let t=gr(e.rowStart,e.colStart);o.has(t)||(o.add(t),e.rowEnd-e.rowStart>0&&i.push(e),e.colEnd-e.colStart>0&&a.push(e))};if(n){let t=n(e),r=t?t.length:0;for(let e=0;e<r;e++){let n=t[e]?.range;n&&s(n)}}else{let t=e.getVisibleColumns(),n=e.getVisibleRows(),r=n.length,i=t.length;for(let a=0;a<r;a++){let r=n[a].index;for(let n=0;n<i;n++)s(e.getRangeFromCell({rowIndex:r,colIndex:t[n].index}))}}return i.length===0&&a.length===0?pr:{rangesH:i,rangesV:a}})(e,t);return mr.set(e,{rowStart:n.rowStart,colStart:n.colStart,rowEnd:n.rowEnd,colEnd:n.colEnd,getVisibleCells:t.getVisibleCells,cacheToken:t.cacheToken,ranges:i}),i},gr=(e,t)=>`${e}:${t}`,_r={tiles:`_tiles_ikr1b_7`,gridlines:`_gridlines_ikr1b_26`},vr=(0,s.memo)(e=>{let{renderCell:t,cacheToken:n,getVisibleCells:r,hiddenCellAt:i,suppressCell:a,className:o,style:l}=e,u=W(),d=u.getAnchor(),f=(0,s.useId)(),p=(0,s.useMemo)(()=>`sxl-cl-${f.replace(/[^a-zA-Z0-9_-]/g,``)}`,[f]),m=(0,s.useRef)({token:void 0,renderCell:void 0,getVisibleCells:void 0,hiddenCellAt:void 0,pane:null,rebaseLeft:0,rebaseTop:0,map:new Map}),h=u.getScrollTopLeft(),g=u.getFreezeTopLeft(),_=h.left+g.left,v=h.top+g.top,y=Math.floor(_/br)*br,b=Math.floor(v/br)*br,x=u.getVisibleRange(),S=0,w=-1,T=0,E=-1;x&&(S=Math.max(0,Math.floor(x.rowStart/$)-xr),w=Math.floor(x.rowEnd/$)+xr,T=Math.max(0,Math.floor(x.colStart/$)-xr),E=Math.floor(x.colEnd/$)+xr);let D=(0,s.useMemo)(()=>{if(!x||w<S)return null;let e=m.current;e.token===n&&e.pane===u&&e.renderCell===t&&e.getVisibleCells===r&&e.hiddenCellAt===i&&e.rebaseLeft===y&&e.rebaseTop===b||(e.map=new Map,e.token=n,e.pane=u,e.renderCell=t,e.getVisibleCells=r,e.hiddenCellAt=i,e.rebaseLeft=y,e.rebaseTop=b);let a=e.map,o=u.getZoom(),s=u.getTotalRange(),l={rowStart:Math.max(s.rowStart,S*$),colStart:Math.max(s.colStart,T*$),rowEnd:Math.min(s.rowEnd,(w+1)*$-1),colEnd:Math.min(s.colEnd,(E+1)*$-1)},{cells:f}=fr(u,{getVisibleCells:r,hiddenCellAt:i,bufferRange:l,cacheToken:n}),p=new Map;for(let e=0;e<f.length;e++){let t=f[e],n=`${Math.floor(t.cell.rowIndex/$)}:${Math.floor(t.cell.colIndex/$)}`,r=p.get(n);r||(r=[],p.set(n,r)),r.push(t)}let h=[],g=(e,n)=>{if(e*$>s.rowEnd||n*$>s.colEnd)return;let r=e>=S&&e<=w&&n>=T&&n<=E,i=`${e}:${n}`,l=a.get(i);if(l===void 0){let f=p.get(i);if(!f&&!Cr)return;let m=u.getBoundsFromRange({rowStart:e*$,colStart:n*$,rowEnd:Math.min(s.rowEnd,e*$+$-1),colEnd:Math.min(s.colEnd,n*$+$-1)}),h=_+m.x-y,g=v+m.y-b,x=[];if(Cr&&x.push((0,c.jsx)(`div`,{style:{position:`absolute`,left:0,top:0,width:m.width,height:m.height,background:(e+n)%2==0?`rgba(0,128,255,0.05)`:`rgba(255,140,0,0.05)`,pointerEvents:`none`}},`__bg`)),f)for(let e=0;e<f.length;e++){let{cell:n,range:r,bounds:i,value:a}=f[e];i&&x.push(t({key:`pane:${d}:cell:${gr(n.rowIndex,n.colIndex)}`,cell:n,bounds:i,range:r,zoom:o,value:a,"data-rc":gr(n.rowIndex,n.colIndex),style:{left:i.x-m.x,top:i.y-m.y,width:i.width,height:i.height}}))}if(l=(0,c.jsx)(`div`,{className:`tile`,style:{transform:`translate(${h}px, ${g}px)`},children:x},`pane:${d}:tile:${e}:${n}`),r&&(a.set(i,l),a.size>Sr)){let e=a.keys().next().value;e!==void 0&&a.delete(e)}}l&&h.push(l)};if(Cr){for(let e=S;e<=w&&!(e*$>s.rowEnd);e++)for(let t=T;t<=E&&!(t*$>s.colEnd);t++)g(e,t);for(let e of p.keys()){let t=e.indexOf(`:`),n=Number(e.slice(0,t)),r=Number(e.slice(t+1));(n<S||n>w||r<T||r>E)&&g(n,r)}}else for(let e of p.keys()){let t=e.indexOf(`:`);g(Number(e.slice(0,t)),Number(e.slice(t+1)))}return h},[`${S}:${w}:${T}:${E}`,n,t,r,i,u,d,y,b]);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(q,{fill:!0,className:C(`tiles`,_r.tiles,p,o),style:{pointerEvents:`none`,...l,transform:`translate3d(${y-_}px, ${b-v}px, 0)`,willChange:`transform`},children:D}),a?(0,c.jsx)(`style`,{children:`.${p} [data-rc="${gr(a.rowIndex,a.colIndex)}"]{visibility:hidden !important;}`}):null]})});vr.displayName=`CellTileDiv`;var yr=(0,s.memo)(e=>{let{renderCell:t,cacheToken:n,getVisibleCells:r,hiddenCellAt:i,suppressCell:a,className:o,style:s,...l}=e;return(0,c.jsx)(ye,{className:C(o,`cells`),...l,children:(0,c.jsx)(vr,{renderCell:t,cacheToken:n,getVisibleCells:r,hiddenCellAt:i,suppressCell:a,style:s})})});yr.displayName=`CellLayer`;var $=8,br=1<<19,xr=1,Sr=512,Cr=!1,wr=(e,t,n)=>{let r=l.ReactUtils.getDevicePixelRatio(),i=Or/r,a=e.getVisibleRange(),o=t=>e.getColumnSize(t).offset,s=t=>{let n=e.getColumnSize(t);return n.offset+n.size},c=t=>e.getRowSize(t).offset,d=t=>{let n=e.getRowSize(t);return n.offset+n.size},f=[],p=[],m=!1,h=``;if(t){let t=e.getVisibleRows(),c=t?t.length:0;if(c===0)return h;let g=[...n].sort(u.CoordUtils.rowFirstRangeComparator),_=l.ReactUtils.snapDeviceEdge(0,r),v=Math.min(e.getPaneBounds().width,s(a.colEnd)),y=l.ReactUtils.snapDeviceEdge(v,r);for(let e=0;e<c&&t[e].index<=a.rowEnd;e++){let n=t[e],c=n.index;if(c<a.rowStart)continue;let b=n.offset+n.size;for(let e=f.length-1;e>=0;e--)d(f[e].rowEnd)<=b&&(f.splice(e,1),m=!1);let x=!1;for(;g.length>0&&g[0].rowStart<=c;){let e=g.shift();d(e.rowEnd)>b&&(f.push(e),x=!0,m=!1)}if(x&&f.sort(u.CoordUtils.columnFirstRangeComparator),!m){p.length=0;for(let e=0;e<f.length;e++){let t=f[e];p.push(l.ReactUtils.snapDeviceEdge(Math.min(v,o(t.colStart)),r),l.ReactUtils.snapDeviceEdge(Math.min(v,s(t.colEnd)),r))}m=!0}let S=l.ReactUtils.snapLineCenter(b,i,r),C=_,w=p.length;for(let e=0;e<w;e+=2){let t=p[e];t>C&&(h+=`M ${C} ${S} L ${t} ${S} `),C=p[e+1]}y>C&&(h+=`M ${C} ${S} L ${y} ${S} `)}}else{let t=e.getVisibleColumns(),o=t?t.length:0;if(o===0)return h;let g=[...n].sort(u.CoordUtils.columnFirstRangeComparator),_=l.ReactUtils.snapDeviceEdge(0,r),v=Math.min(e.getPaneBounds().height,d(a.rowEnd)),y=l.ReactUtils.snapDeviceEdge(v,r);for(let e=0;e<o&&t[e].index<=a.colEnd;e++){let n=t[e],o=n.index;if(o<a.colStart)continue;let b=n.offset+n.size;for(let e=f.length-1;e>=0;e--)s(f[e].colEnd)<=b&&(f.splice(e,1),m=!1);let x=!1;for(;g.length>0&&g[0].colStart<=o;){let e=g.shift();s(e.colEnd)>b&&(f.push(e),x=!0,m=!1)}if(x&&f.sort(u.CoordUtils.rowFirstRangeComparator),!m){p.length=0;for(let e=0;e<f.length;e++){let t=f[e];p.push(l.ReactUtils.snapDeviceEdge(Math.min(v,c(t.rowStart)),r),l.ReactUtils.snapDeviceEdge(Math.min(v,d(t.rowEnd)),r))}m=!0}let S=l.ReactUtils.snapLineCenter(b,i,r),C=_,w=p.length;for(let e=0;e<w;e+=2){let t=p[e];t>C&&(h+=`M ${S} ${C} L ${S} ${t} `),C=p[e+1]}y>C&&(h+=`M ${S} ${C} L ${S} ${y} `)}}return h},Tr=e=>{let t=``;for(let n=0;n<e.length;n++){let r=e[n];t+=`${r.rowStart},${r.colStart},${r.rowEnd},${r.colEnd};`}return t},Er=(e,t,n,r,i)=>{if(!n)return null;let a=e.getPaneBounds(),o=Math.ceil(a.width),s=Math.ceil(a.height),u=String(Or/l.ReactUtils.getDevicePixelRatio());return(0,c.jsx)(`svg`,{className:C(t?`horizontal`:`vertical`),width:`${o}`,height:`${s}`,viewBox:`0 0 ${o} ${s}`,preserveAspectRatio:`none`,children:(0,c.jsx)(`path`,{d:n,fill:`none`,stroke:r,strokeWidth:u,vectorEffect:`non-scaling-stroke`,...i})})},Dr=(0,s.memo)(e=>{let{showGridLines:t=!0,gridLineColor:n=`var(--sxl-color-base-300, rgb(224, 224, 224))`,propsRows:r,propsColumns:i,getVisibleCells:a,hiddenCellAt:o,cacheToken:u,bufferRange:d,className:f,style:p,...m}=e,h=W(),g=t,_=!0===t||!0===g?.horizontal,v=!0===t||!0===g?.vertical,{rangesH:y,rangesV:b}=hr(h,{getVisibleCells:a,cacheToken:u}),x=l.ReactUtils.getDevicePixelRatio(),{top:S,left:w}=h.getScrollTopLeft(),T=h.getPaneBounds(),E=h.getVisibleRange(),D=h.getColumnSize(E.colEnd),O=h.getRowSize(E.rowEnd),k=Math.min(T.width,D?D.offset+D.size:T.width),A=Math.min(T.height,O?O.offset+O.size:T.height),j=y.length===0?`${S}|${k}|${x}`:`${S}|${w}|${k}|${x}|${Tr(y)}`,M=b.length===0?`${w}|${A}|${x}`:`${w}|${S}|${A}|${x}|${Tr(b)}`,N=(0,s.useMemo)(()=>_?wr(h,!0,y):null,[h,_,j]),P=(0,s.useMemo)(()=>v?wr(h,!1,b):null,[h,v,M]);return _||v?(0,c.jsx)(ye,{...m,className:C(f,`gridlines`),children:(0,c.jsxs)(q,{fill:!0,className:C(`gridlines-box`,_r.gridlines),style:{pointerEvents:`none`,...p},children:[_&&N?Er(h,!0,N,n,r):null,v&&P?Er(h,!1,P,n,i):null]})}):null});Dr.displayName=`GridlineLayer`;var Or=1,kr=class{constructor(e={}){this.listeners=new Set,this._coords=e.initial??{cell:{rowIndex:0,colIndex:0},ranges:u.CoordUtils.EmptyRanges,rangeIndex:-1},this._getBounds=e.getBounds??(()=>Mr)}getSelection(){return this._coords}setSelection(e){u.CoordUtils.isEqualSelectionCoords(this._coords,e)||(this._coords=e,this.listeners.forEach(e=>e()))}navigate(e,t=!1,n=!1,r=1){let i=this._getBounds(),{cell:a}=this._coords,o=e===u.Direction.Down?1:e===u.Direction.Up?-1:0,s=e===u.Direction.Right?1:e===u.Direction.Left?-1:0,c=e=>e===0?0:n?e>0?1/0:-1/0:e*Math.max(1,r),l=this._activeRange(),d=t?a.rowIndex===l.rowStart?l.rowEnd:l.rowStart:a.rowIndex,f=t?a.colIndex===l.colStart?l.colEnd:l.colStart:a.colIndex,p=w(d+c(o),i.rowStart,i.rowEnd),m=w(f+c(s),i.colStart,i.colEnd);if(!t)return void this.setSelection({cell:{rowIndex:p,colIndex:m},ranges:u.CoordUtils.EmptyRanges,rangeIndex:-1});let h={rowStart:Math.min(a.rowIndex,p),colStart:Math.min(a.colIndex,m),rowEnd:Math.max(a.rowIndex,p),colEnd:Math.max(a.colIndex,m)};this.setSelection({cell:a,ranges:[h],rangeIndex:0})}traverse(e=u.RangeAxis.Row,t=!1,n){let r=e===u.RangeAxis.Row?t?u.Direction.Left:u.Direction.Right:t?u.Direction.Up:u.Direction.Down,i=this._coords;if(!(i.ranges&&i.ranges.length>0)||u.CoordUtils.isEqualRangesArrays([u.CoordUtils.cellToRange(i.cell)],i.ranges)){if(n&&!u.CoordUtils.isSingleCell(n)){let e=u.SelectionTraversalUtils.findNextCellWithinSelection({ranges:[n],cell:i.cell,rangeIndex:0},r,e=>u.CoordUtils.cellToRange(e));this.setSelection({cell:e.cell,ranges:u.CommonUtils.EmptyArray,rangeIndex:-1});return}this.navigate(r);return}let a=u.SelectionTraversalUtils.findNextCellWithinSelection(i,r,e=>u.CoordUtils.cellToRange(e));this.setSelection(a)}_activeIndex(){let{ranges:e,rangeIndex:t}=this._coords;return e&&e.length!==0?t!==void 0&&t>=0&&t<e.length?t:e.length-1:-1}_activeRange(){let e=this._activeIndex();return e>=0?this._coords.ranges[e]:u.CoordUtils.cellToRange(this._coords.cell)}modify(e,t=this._coords.cell){let n=this._activeRange(),r=Ar({rowStart:Math.min(e.rowIndex??n.rowStart,t.rowIndex??n.rowStart),colStart:Math.min(e.colIndex??n.colStart,t.colIndex??n.colStart),rowEnd:Math.max(e.rowIndex??n.rowEnd,t.rowIndex??n.rowEnd),colEnd:Math.max(e.colIndex??n.colEnd,t.colIndex??n.colEnd)},this._getBounds()),i=this._coords,a=this._activeIndex(),o=a>=0?i.ranges.map((e,t)=>t===a?r:e):[r],s=jr(i.cell,r);this.setSelection({cell:s,ranges:o,rangeIndex:a>=0?a:0})}append(e,t=e){let n=Ar({rowStart:Math.min(e.rowIndex,t.rowIndex),colStart:Math.min(e.colIndex,t.colIndex),rowEnd:Math.max(e.rowIndex,t.rowIndex),colEnd:Math.max(e.colIndex,t.colIndex)},this._getBounds()),r=this._coords,i=r.ranges&&r.ranges.length>0?[...r.ranges]:[u.CoordUtils.cellToRange(r.cell)];i.push(n),this.setSelection({ranges:i,rangeIndex:i.length-1,cell:{rowIndex:n.rowStart,colIndex:n.colStart}})}deselect(e){let t=this._coords;if(!t.ranges||t.ranges.length===0)return;let n=[],r=-1,i=t.cell;for(let a of t.ranges){if(!u.CoordUtils.isRangesIntersect(a,e)){n.push(a),r===-1&&u.CoordUtils.isCellWithinRange(t.cell,a)&&(r=n.length-1);continue}let o=n.length,s=u.CommonUtils.subtractRect({top:a.rowStart,left:a.colStart,bottom:a.rowEnd+1,right:a.colEnd+1},{top:e.rowStart,left:e.colStart,bottom:e.rowEnd+1,right:e.colEnd+1});for(let e of s){let i={rowStart:e.top,colStart:e.left,rowEnd:e.bottom-1,colEnd:e.right-1};n.push(i),r===-1&&u.CoordUtils.isCellWithinRange(t.cell,i)&&(r=n.length-1)}if(r===-1&&n.length>o&&u.CoordUtils.isCellWithinRange(t.cell,a)){r=n.length-1;let e=n[n.length-1];i={rowIndex:e.rowStart,colIndex:e.colStart}}}if(r===-1&&n.length>0&&t.ranges.some(e=>u.CoordUtils.isCellWithinRange(t.cell,e))){r=n.length-1;let e=n[r];i={rowIndex:e.rowStart,colIndex:e.colStart}}this.setSelection({cell:i,rangeIndex:r,ranges:n})}getCoords(){return this._coords.cell}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}},Ar=(e,t)=>({rowStart:w(e.rowStart,t.rowStart,t.rowEnd),colStart:w(e.colStart,t.colStart,t.colEnd),rowEnd:w(e.rowEnd,t.rowStart,t.rowEnd),colEnd:w(e.colEnd,t.colStart,t.colEnd)}),jr=(e,t)=>({rowIndex:w(e.rowIndex,t.rowStart,t.rowEnd),colIndex:w(e.colIndex,t.colStart,t.colEnd)}),Mr={rowStart:0,colStart:0,rowEnd:2**53-1,colEnd:2**53-1},Nr=`var(--sxl-color-primary, rgb(33, 115, 70))`,Pr=`var(--sxl-color-base-100, rgb(255, 255, 255))`,Fr=`var(--sxl-color-warning, rgb(255, 0, 0))`,Ir=e=>`color-mix(in srgb, var(--sxl-color-primary, rgb(33, 115, 70)) ${e}%, transparent)`,Lr={fill:{fill:Ir(10)},border:{stroke:Nr,alignWidth:2,style:{filter:`drop-shadow(1px 1px 0.3px var(--sxl-color-shadow, rgba(0, 0, 0, 0.24)))`}},inner:{stroke:Pr,alignWidth:2,inset:1}},Rr={fill:{fill:Ir(6)},border:{stroke:Nr,alignWidth:1},inner:{stroke:Pr,alignWidth:1,inset:1}},zr={stroke:Nr,alignWidth:1,inset:2},Br={fill:{fill:`color-mix(in srgb, ${Fr} 10%, transparent)`},border:{stroke:Fr,alignWidth:2}},Vr={color:Nr,refusedColor:Fr,alignWidth:3,capExtent:3,transitionDuration:100,transitionEasing:`cubic-bezier(0.16, 1, 0.3, 1)`,axisDuration:70},Hr={fill:{fill:`color-mix(in srgb, ${Pr} 62%, transparent)`}},Ur=(e,t)=>{let n=W(),r=t?.allowDeselect??!0,i=t?.allowMulti??!0,a=(0,s.useRef)(null),[o,c]=(0,s.useState)(null),l=(0,s.useRef)(t?.onSelectionEnd);l.current=t?.onSelectionEnd;let d=Vn((t,o)=>{if(o.pointerType===`touch`){let t=n.getScrollTopLeft(),r={x:o.clientX,y:o.clientY};return{capture:!1,drag:()=>{},end:i=>{let a=n.getScrollTopLeft();if(a.left===t.left&&a.top===t.top){let t=n.getCellFromPointer(r.x,r.y);t&&e.setSelection({cell:t,ranges:u.CoordUtils.EmptyRanges,rangeIndex:-1})}l.current?.(i)}}}if(o.button===2){let n=e.getSelection();return u.CoordUtils.isEqualCells(n.cell,t)||n.ranges&&n.ranges.some(e=>u.CoordUtils.isCellWithinRange(t,e))||e.setSelection({cell:t,ranges:u.CoordUtils.EmptyRanges,rangeIndex:-1}),null}if(o.button!==0)return null;o.stopPropagation();let s=e=>l.current?.(e),d=e.getSelection(),f=()=>e.setSelection(d);if(o.shiftKey)return e.modify(t),{dragMode:`extend`,drag:t=>e.modify(t),end:s,cancel:f};if((o.ctrlKey||o.metaKey)&&i){let i=e.getSelection().ranges,o=!!i&&i.some(e=>u.CoordUtils.isCellWithinRange(t,e));return r&&o?(a.current=u.CoordUtils.cellToRange(t),c(a.current),{dragMode:`remove`,drag:e=>{a.current=((e,t)=>{let r=n.getTotalRange();return{rowStart:Math.max(r.rowStart,Math.min(e.rowIndex,t.rowIndex)),colStart:Math.max(r.colStart,Math.min(e.colIndex,t.colIndex)),rowEnd:Math.min(r.rowEnd,Math.max(e.rowIndex,t.rowIndex)),colEnd:Math.min(r.colEnd,Math.max(e.colIndex,t.colIndex))}})(t,e),c(a.current)},end:t=>{let n=a.current;a.current=null,c(null),n&&e.deselect(n),s(t)},cancel:()=>{a.current=null,c(null)}}):(e.append(t),{dragMode:`extend`,drag:t=>e.modify(t),end:s,cancel:f})}return e.setSelection({cell:t,ranges:u.CoordUtils.EmptyRanges,rangeIndex:-1}),{dragMode:`extend`,drag:t=>e.modify(t),end:s,cancel:f}});return{onPointerDown:d.onPointerDown,onPointerMove:d.onPointerMove,onPointerUp:d.onPointerUp,removePreview:o,dragMode:d.dragMode}},Wr=e=>{let{selection:t,color:n=`var(--sxl-color-primary, rgb(33, 115, 70))`,size:r=22}=e,i=G(),a=qr((0,l.useBoundSyncExternalStore)(t,e=>e.getSelection())),o=i?i.getAllPanes()[u.AnchorLocation.Center]??i:void 0,d=((e,t,n)=>{let r=!!t&&e.rowStart===t.rowStart&&e.rowEnd===t.rowEnd,i=!!t&&e.colStart===t.colStart&&e.colEnd===t.colEnd;if(r&&i)return[];if(r){let t=n?Math.floor((n.rowStart+n.rowEnd)/2):e.rowStart;return[{key:`l`,placement:{side:`l`,align:`center`},cell:{rowIndex:t,colIndex:e.colStart},pivot:{colIndex:e.colEnd},axis:`col`,pin:`v`},{key:`r`,placement:{side:`r`,align:`center`},cell:{rowIndex:t,colIndex:e.colEnd},pivot:{colIndex:e.colStart},axis:`col`,pin:`v`}]}if(i){let t=n?Math.floor((n.colStart+n.colEnd)/2):e.colStart;return[{key:`t`,placement:{side:`t`,align:`center`},cell:{rowIndex:e.rowStart,colIndex:t},pivot:{rowIndex:e.rowEnd},axis:`row`,pin:`h`},{key:`b`,placement:{side:`b`,align:`center`},cell:{rowIndex:e.rowEnd,colIndex:t},pivot:{rowIndex:e.rowStart},axis:`row`,pin:`h`}]}return[{key:`tl`,placement:{side:`t`,align:`start`},cell:{rowIndex:e.rowStart,colIndex:e.colStart},pivot:{rowIndex:e.rowEnd,colIndex:e.colEnd},axis:`both`},{key:`br`,placement:{side:`b`,align:`end`},cell:{rowIndex:e.rowEnd,colIndex:e.colEnd},pivot:{rowIndex:e.rowStart,colIndex:e.colStart},axis:`both`}]})(a,i?.getTotalRange(),o?.getVisibleRange()),[f,p]=(0,s.useState)(!1),m=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>m.current?.dispose(),[]);let h=(e,n,r,i)=>{m.current?.dispose();let a=r===`col`?{x:!0,y:!1}:r===`row`?{x:!1,y:!0}:{x:!0,y:!0},o=t.getSelection(),s=Bn(e,()=>(p(!0),{dragMode:`grip`,drag:e=>{let i=r===`col`?{colIndex:e.colIndex}:r===`row`?{rowIndex:e.rowIndex}:e;t.modify(i,n)},edgeScroll:t=>Pn(e,t,a),end:()=>p(!1),cancel:()=>{t.setSelection(o),p(!1)}}),void 0,(t,n)=>(e.getPaneFromPointer(t,n)??e).getCellFromPointer(t,n));m.current=s,s.start(i,i.currentTarget)};return(0,c.jsx)(c.Fragment,{children:d.map(e=>(0,c.jsx)(Gr,{spec:e,size:r,color:n,dragging:f,onBeginDrag:h},e.key))})};Wr.displayName=`SelectionTouchGrips`;var Gr=e=>{let{spec:t,size:n,color:r,dragging:i,onBeginDrag:a}=e;return(0,c.jsx)(Pe,{anchor:{cell:t.cell},placement:t.placement,whenOff:`hide`,children:e=>e.slid?null:(0,c.jsx)(Kr,{state:e,size:n,color:r,dragging:i,pin:t.pin,onBeginDrag:n=>{e.pane&&a(e.pane,t.pivot,t.axis,n)}})})},Kr=e=>{let{state:t,size:n,color:r,dragging:i,pin:a,onBeginDrag:o}=e,{getPortalContainer:s}=(0,l.useFullscreenPortal)(),{className:u,attrs:f}=on(t.pane),{x:p,y:m}=t.anchorPoint;if(a){let e=t.pane?.getElement()?.getBoundingClientRect();e&&(a===`v`?m=e.top+e.height/2:p=e.left+e.width/2)}return(0,d.createPortal)((0,c.jsx)(`div`,{className:[`touch-select-grip`,u].filter(Boolean).join(` `),...f,style:{position:`fixed`,left:p,top:m,width:n,height:n,transform:`translate(-50%, -50%)`,background:`var(--sxl-color-base-100, white)`,border:`3px solid ${r}`,borderRadius:`50%`,boxShadow:`0 0 0 1.5px var(--sxl-color-base-100, white)`,cursor:`grab`,touchAction:`none`,zIndex:1250,opacity:+!i,pointerEvents:i?`none`:`all`,transition:`opacity 160ms`},onPointerDown:e=>{e.button!==0&&e.pointerType!==`touch`||t.pane&&(e.preventDefault(),e.stopPropagation(),o(e))}}),s())},qr=e=>{let{ranges:t,rangeIndex:n,cell:r}=e;if(t&&t.length>0){let e=n??-1;return t[e>=0?e:t.length-1]}return u.CoordUtils.cellToRange(r)},Jr=[u.Direction.Left,u.Direction.Right,u.Direction.Up,u.Direction.Down],Yr={[u.Direction.Left]:`ArrowLeft`,[u.Direction.Right]:`ArrowRight`,[u.Direction.Up]:`ArrowUp`,[u.Direction.Down]:`ArrowDown`},Xr={[u.Direction.Left]:`Left`,[u.Direction.Right]:`Right`,[u.Direction.Up]:`Up`,[u.Direction.Down]:`Down`},Zr=(e,t)=>t===void 0?e:t===null?null:{...e,...t},Qr=(e,t)=>t?{fill:Zr(e.fill,t.fill),border:Zr(e.border,t.border),inner:Zr(e.inner,t.inner)}:e,$r={side:`b`,align:`end`},ei=s.default.forwardRef((e,t)=>{let{selection:n,getContentBounds:r,getRegionBounds:i,scrollIntoView:a,singleStyle:o,multiStyle:d,multiAnchorStyle:f,singleAnchorStyle:p,removePreviewStyle:m,insertBarStyle:h,isDropRefused:g,moveSourceStyle:_,singleLayer:v,multiLayer:y,enabledMove:b,onMove:x,onMoveStart:S,onMoveUpdate:C,onMoveEnd:w,moveCursor:T,enableFill:E,snapFillDestination:D,onFill:O,onFillStart:k,onFillPreview:A,onFillEnd:j,onFillMenu:M,resolveFillExtent:N,onEdgeDoubleClick:P,onSelectionEnd:F,onDragModeChange:I,renderTip:L,tipPlacement:R,disableKeyboard:ee,anchorHole:te=!0,...ne}=e,re=(0,l.useBoundSyncExternalStore)(n,e=>e.getSelection()),z=Ur(n,{onSelectionEnd:F}),ie=s.default.useRef(I);ie.current=I,s.default.useEffect(()=>{ie.current?.(z.dragMode)},[z.dragMode]);let[B,ae]=s.default.useState(null),V=W(),oe=s.default.useRef(n);oe.current=n;let se=s.default.useRef(V);se.current=V;let ce=s.default.useRef(r);ce.current=r;let H=s.default.useRef(i);H.current=i;let le=s.default.useRef(a);le.current=a;let ue=s.default.useMemo(()=>function(e){let{getSelection:t,getPane:n,getContentBounds:r,getScrollIntoView:i=()=>{},getRegionBounds:a=()=>null}=e,o=()=>t(),s=()=>n(),c=()=>s().getTotalRange(),d=r??c,f=e=>a(e),p=e=>{let t=i();t?t(e):s().scrollCellCoordsIntoView(e)},m=()=>p(o().getSelection().cell),h=()=>{let e=o().getSelection();return e.ranges&&e.ranges.length>0&&e.rangeIndex!==void 0&&e.rangeIndex>=0?e.ranges[e.rangeIndex]:u.CoordUtils.cellToRange(e.cell)},g=(e,t,n=!1)=>{if(o().navigate(e,t,n),i())return;let r=o().getSelection(),a=e===u.Direction.Left||e===u.Direction.Right;if(t){let t=c(),n=h(),i=r.cell.colIndex===n.colStart?n.colEnd:n.colStart,o=r.cell.rowIndex===n.rowStart?n.rowEnd:n.rowStart;if(e===u.Direction.Right&&i===t.colEnd||e===u.Direction.Left&&i===t.colStart||e===u.Direction.Up&&o===t.rowStart||e===u.Direction.Down&&o===t.rowEnd)return;p(a?{colIndex:i}:{rowIndex:o});return}p(a?{colIndex:r.cell.colIndex}:{rowIndex:r.cell.rowIndex})},_=(e,t)=>{let n=s(),r=n.getMetrics(),i=c(),a=n.getSurfaceSize(),l=n.getScrollTopLeft(),d=n.getScrollTarget?.()??l,f=h(),p=o().getSelection().cell,m=t?p.rowIndex===f.rowStart?f.rowEnd:f.rowStart:p.rowIndex,g=t?p.colIndex===f.colStart?f.colEnd:f.colStart:p.colIndex,_=m,v=g,y=null;switch(e){case u.Direction.Up:{let e=r.getRowOffset(m+1);_=Math.max(i.rowStart,r.getRowIndex(e-a.height)),y={top:r.getRowOffset(_+1)-(e-d.top)};break}case u.Direction.Down:{let e=r.getRowOffset(m);_=Math.min(i.rowEnd,r.getRowIndex(e+a.height)),y={top:r.getRowOffset(_)-(e-d.top)};break}case u.Direction.Left:{let e=r.getColOffset(g+1);v=Math.max(i.colStart,r.getColIndex(e-a.width)),y={left:r.getColOffset(v+1)-(e-d.left)};break}case u.Direction.Right:{let e=r.getColOffset(g);v=Math.min(i.colEnd,r.getColIndex(e+a.width)),y={left:r.getColOffset(v)-(e-d.left)};break}}let b={rowIndex:_,colIndex:v};t?o().modify(b):o().setSelection({cell:b,ranges:u.CommonUtils.EmptyArray,rangeIndex:-1}),y&&n.scrollTo({...y,behavior:`instant`})},v=(e,t)=>{if(t)o().modify(e);else{let t=o().getSelection().cell;o().setSelection({cell:{rowIndex:e.rowIndex??t.rowIndex,colIndex:e.colIndex??t.colIndex},ranges:u.CommonUtils.EmptyArray,rangeIndex:-1})}m()},y=(e,t)=>{let n=o().getSelection(),r=n.ranges&&n.ranges.length>0||e!==u.RangeAxis.Row?void 0:f(n.cell)??void 0;o().traverse(e,t,r),m()},b=e=>{let t=o().getSelection();if(!t.ranges||t.ranges.length<=1)return;let n=(t.rangeIndex??t.ranges.length-1)+(e?-1:1);n<0?n=t.ranges.length-1:n>=t.ranges.length&&(n=0);let r=t.ranges[n];o().setSelection({...t,rangeIndex:n,cell:{rowIndex:r.rowStart,colIndex:r.colStart}}),m()},x=new Map,S=(e,t,n)=>{x.set(e,{shortcut:t,run:n})},C=l.KeyModifiers.Shift,w=l.KeyModifiers.Ctrl,T=l.KeyModifiers.Alt;for(let e of Jr){let t=Xr[e],n=Yr[e];S(`move${t}`,{key:n},()=>g(e,!1)),S(`select${t}`,{key:n,modifiers:[C]},()=>g(e,!0)),S(`moveContentful${t}`,{key:n,modifiers:[w]},()=>g(e,!1,!0)),S(`selectContentful${t}`,{key:n,modifiers:[w,C]},()=>g(e,!0,!0))}S(`moveToPageDown`,{key:`PageDown`},()=>_(u.Direction.Down,!1)),S(`selectToPageDown`,{key:`PageDown`,modifiers:[C]},()=>_(u.Direction.Down,!0)),S(`moveToPageUp`,{key:`PageUp`},()=>_(u.Direction.Up,!1)),S(`selectToPageUp`,{key:`PageUp`,modifiers:[C]},()=>_(u.Direction.Up,!0)),S(`moveToPageRight`,{key:`PageDown`,modifiers:[T]},()=>_(u.Direction.Right,!1)),S(`selectToPageRight`,{key:`PageDown`,modifiers:[T,C]},()=>_(u.Direction.Right,!0)),S(`moveToPageLeft`,{key:`PageUp`,modifiers:[T]},()=>_(u.Direction.Left,!1)),S(`selectToPageLeft`,{key:`PageUp`,modifiers:[T,C]},()=>_(u.Direction.Left,!0)),S(`traverseSelectionRight`,{key:`Tab`},()=>y(u.RangeAxis.Row,!1)),S(`traverseSelectionLeft`,{key:`Tab`,modifiers:[C]},()=>y(u.RangeAxis.Row,!0)),S(`traverseSelectionDown`,[{key:`Enter`},{key:`NumpadEnter`}],()=>y(u.RangeAxis.Column,!1)),S(`traverseSelectionUp`,[{key:`Enter`,modifiers:[C]},{key:`NumpadEnter`,modifiers:[C]}],()=>y(u.RangeAxis.Column,!0)),S(`traverseSelectionNextRange`,{key:`ArrowRight`,modifiers:[w,T]},()=>b(!1)),S(`traverseSelectionPreviousRange`,{key:`ArrowLeft`,modifiers:[w,T]},()=>b(!0)),S(`moveToRowStart`,{key:`Home`},()=>v({colIndex:c().colStart},!1)),S(`moveToGridStart`,{key:`Home`,modifiers:[w]},()=>v({rowIndex:c().rowStart,colIndex:c().colStart},!1)),S(`selectToRowStart`,{key:`Home`,modifiers:[C]},()=>v({colIndex:c().colStart},!0)),S(`selectToColumnStart`,void 0,()=>v({rowIndex:c().rowStart},!0)),S(`selectToGridStart`,{key:`Home`,modifiers:[w,C]},()=>v({rowIndex:c().rowStart,colIndex:c().colStart},!0)),S(`moveToRowEnd`,{key:`End`},()=>v({colIndex:d().colEnd},!1)),S(`moveToGridEnd`,{key:`End`,modifiers:[w]},()=>v({rowIndex:d().rowEnd,colIndex:d().colEnd},!1)),S(`selectToColumnEnd`,void 0,()=>v({rowIndex:c().rowEnd},!0)),S(`selectToRowEnd`,{key:`End`,modifiers:[C]},()=>v({colIndex:d().colEnd},!0)),S(`selectToGridEnd`,{key:`End`,modifiers:[w,C]},()=>v({rowIndex:d().rowEnd,colIndex:d().colEnd},!0)),S(`selectColumn`,{key:`Space`,modifiers:[w]},()=>{let e=f(o().getSelection().cell)??c();o().modify({rowIndex:e.rowStart},{rowIndex:e.rowEnd}),m()}),S(`selectRow`,{key:`Space`,modifiers:[C]},()=>{let e=f(o().getSelection().cell)??c();o().modify({colIndex:e.colStart},{colIndex:e.colEnd}),m()}),S(`scrollToActiveCoords`,{key:`Backspace`,modifiers:[w]},()=>m()),S(`scrollToActiveCoordsClearSelection`,{key:`Backspace`,modifiers:[C]},()=>{let e=o().getSelection().cell;o().setSelection({cell:e,ranges:u.CommonUtils.EmptyArray,rangeIndex:-1}),m()});let E=(e,t)=>{let n=t.modifiers??[];return(n.includes(w)||n.includes(l.KeyModifiers.Meta))===(e.ctrlKey||e.metaKey)&&n.includes(C)===e.shiftKey&&n.includes(T)===e.altKey&&(e.key===t.key||e.code===t.key)};return{invoke(e){let t=x.get(e);return!!t&&(t.run(),!0)},supports:e=>x.has(e),getBindings:()=>x,handleKey(e){for(let t of x.values())if(t.shortcut&&(Array.isArray(t.shortcut)?t.shortcut:[t.shortcut]).some(t=>E(e,t)))return t.run(),!0;return!1}}}({getSelection:()=>oe.current,getPane:()=>se.current,getContentBounds:()=>ce.current?.()??se.current.getTotalRange(),getScrollIntoView:()=>le.current,getRegionBounds:e=>H.current?.(e)??null}),[]);s.default.useImperativeHandle(t,()=>ue,[ue]);let de=!!re.ranges&&re.ranges.length>0,fe=de?[...re.ranges]:[u.CoordUtils.cellToRange(re.cell)],pe=fe.length>1,me=re.rangeIndex??-1,he=de?me>=0?me:fe.length-1:0,ge=V.getRangeFromCell(re.cell),U=u.CoordUtils.unionRanges(fe[he]??u.CoordUtils.cellToRange(re.cell),ge),_e=fe.filter((e,t)=>t!==he),G=pe?Qr(Rr,d):Qr(Lr,o),ve={...zr,...f},K=Qr(Br,m),{refusedColor:be,...xe}={...Vr,...h},Se=_===null?null:Qr(Hr,_),q=(e,t)=>{let n=t.mods.shiftKey?t.insert:null,r=t.mods.ctrlKey||t.mods.metaKey,i=n?Qn(e,n,V.getTotalRange()):e,a={to:i,copy:r,insert:n?.axis};return a.refused=!!n&&!r&&(g?g(U,a):u.CoordUtils.isRefusedInsertCut(u.CoordUtils.classifyInsertCut(U,i,n.axis))),a},J=e=>{let t=n.getSelection(),r=t.ranges,i=!!r&&r.length>0,a=i?t.rangeIndex!==void 0&&t.rangeIndex>=0&&t.rangeIndex<r.length?t.rangeIndex:r.length-1:0,o=i?r.map((t,n)=>n===a?e:t):[e],s=u.CoordUtils.isCellWithinRange(t.cell,e)?t.cell:{rowIndex:e.rowStart,colIndex:e.colStart};n.setSelection({cell:s,ranges:o,rangeIndex:a})},Y=B??(z.dragMode===`extend`?{kind:`select`,range:U}:null),X=Y&&L?L(Y):null,Ce=s.default.Children.map(pe?y:v,e=>{if(!s.default.isValidElement(e))return e;let t=e.props;return s.default.cloneElement(e,{range:U,onDragEnd:(e,n)=>{t.onDragEnd?.(e,n),J(e)}})});return(0,c.jsxs)(ye,{...ne,onPointerDown:z.onPointerDown,onPointerMove:z.onPointerMove,onPointerUp:z.onPointerUp,onKeyDown:ee?void 0:e=>{ue.handleKey(e)&&(e.preventDefault(),e.stopPropagation())},children:[B?.kind===`move`&&!B.drop.copy&&Se&&!u.CoordUtils.isEqualRanges(B.to,B.from)&&ti(Se,B.from,void 0,!1,`move-source`),pe?(0,c.jsxs)(c.Fragment,{children:[_e.map((e,t)=>(0,c.jsx)(s.default.Fragment,{children:ti(G,e)},`other-${t}`)),ti(G,U,te?ge:void 0),(0,c.jsx)(jn,{className:`anchor`,range:ge,...ve})]}):(0,c.jsxs)(c.Fragment,{children:[ti(G,U,te?ge:void 0),p&&(0,c.jsx)(jn,{className:`anchor`,range:ge,...p})]}),!pe&&b&&(0,c.jsx)($n,{className:`move-grip`,range:U,grip:`edges`,dragCursor:T,renderMove:(e,t)=>{let n=q(e,t);return n.insert?(0,c.jsx)(Mn,{range:n.to,axis:n.insert,...xe,color:(n.refused?be:void 0)??xe.color}):G.border&&(0,c.jsx)(jn,{className:`move-ghost`,range:n.to,...G.border,animatedTransition:!0,style:{opacity:.6}})},onEdgeDoubleClick:P,onDragStart:(e,t,n)=>{let r=q(e,n);S?.(e,t,r),ae({kind:`move`,from:e,to:r.to,drop:r})},onDragMove:(e,t,n)=>{let r=q(e,n);C?.(U,r.to,t,r),ae({kind:`move`,from:U,to:r.to,drop:r})},onDragStateChange:e=>{e||(w?.(),ae(null))},onDragEnd:(e,t,r)=>{let i=q(e,r);i.refused||(x?.(U,i.to,t,i),n.modify({rowIndex:i.to.rowEnd,colIndex:i.to.colEnd},{rowIndex:i.to.rowStart,colIndex:i.to.colStart}))}}),!pe&&E&&(0,c.jsx)(sr,{range:U,snapDestination:D,...G.border,onDragStart:(e,t)=>{k?.(e,t),ae({kind:`fill`,template:e,destination:e})},onDragMove:(e,t)=>{A?.(U,e,t),ae({kind:`fill`,template:U,destination:e})},onDragEnd:(e,t)=>{O?.(U,e,t),J(e)},onMenu:M?(e,t,n)=>{M(U,e,t,n)}:void 0,onDragDone:()=>{j?.(),ae(null)},onDoubleClick:N?(e,t)=>{let n=N(e);n&&!u.CoordUtils.isEqualRanges(n,e)&&(O?.(e,n,t),J(n))}:void 0}),z.removePreview&&ti(K,z.removePreview,void 0,!1,`remove-preview`),Ce,X!=null&&Y&&(0,c.jsx)(ln,{className:`gesture-tip`,anchor:{range:(we=Y,we.kind===`move`?we.to:we.kind===`fill`?we.destination:we.range)},placement:R??$r,offset:8,whenOff:`clamp`,open:!0,style:{pointerEvents:`none`},children:X})]});var we});ei.displayName=`SelectionLayer`;var ti=(e,t,n,r=!1,i=`range`)=>(0,c.jsxs)(c.Fragment,{children:[e.fill&&(0,c.jsx)(jn,{className:`${i} fill`,animatedTransition:r,range:t,hole:n,...e.fill}),e.inner&&(0,c.jsx)(jn,{className:`${i} inner`,animatedTransition:r,range:t,...e.inner}),e.border&&(0,c.jsx)(jn,{className:`${i} border`,animatedTransition:r,range:t,...e.border})]}),ni=[`#1a73e8`,`#d93025`,`#1e8e3e`,`#9334e6`,`#e37400`,`#12a4af`,`#d01884`],ri=Array.from({length:l.SERIES_COUNT},(e,t)=>`var(--sxl-color-series-${t+1}, ${ni[t]})`),ii=`var(--sxl-color-primary, rgb(0, 120, 215))`,ai=(e,t,n)=>({rowStart:Math.max(n.rowStart,Math.min(e.rowIndex,t.rowIndex)),colStart:Math.max(n.colStart,Math.min(e.colIndex,t.colIndex)),rowEnd:Math.min(n.rowEnd,Math.max(e.rowIndex,t.rowIndex)),colEnd:Math.min(n.colEnd,Math.max(e.colIndex,t.colIndex))}),oi=e=>({stroke:ri.length?ri[e%ri.length]:ii}),si=e=>{let{selection:t,getRangeStyle:n=oi,anchors:r=tr,enabledMove:i,disableDraw:a,allowMulti:o=!0,size:d,animated:f,renderHandle:p,preserveFocus:m=!0,onDragActiveChange:h,rangeStyle:g=u.CommonUtils.EmptyObject,className:_,...v}=e,y=W(),b=(0,l.useBoundSyncExternalStore)(t,e=>e.getSelection()),x=b.ranges??u.CoordUtils.EmptyRanges,S=Math.min(Math.max(0,b.rangeIndex??x.length-1),Math.max(0,x.length-1)),[w,T]=(0,s.useState)(null),[E,D]=(0,s.useState)(null),[O,k]=(0,s.useState)(!1),A=E!==null||O,j=(0,s.useRef)(h);j.current=h,(0,s.useEffect)(()=>{j.current?.(A,E)},[A,E]),(0,s.useEffect)(()=>()=>{j.current?.(!1,null)},[]);let M=E??w,N=(e,t)=>T(n=>t?e:n===e?null:n),P=(e,n)=>{let r=t.getSelection(),i=r.ranges??u.CoordUtils.EmptyRanges,a=e<i.length?i.map((t,r)=>r===e?{...t,...n}:t):[...i,n];t.setSelection({...r,cell:{rowIndex:n.rowStart,colIndex:n.colStart},ranges:a,rangeIndex:e})},F=e=>{let n=t.getSelection();(n.rangeIndex??-1)!==e&&t.setSelection({...n,rangeIndex:e})},I=Vn((e,t)=>{if(t.button!==0)return null;let n=(b.rangeIndex??-1)>=0?b.rangeIndex:-1;if(t.shiftKey&&n>=0&&x[n]){let t={rowIndex:x[n].rowStart,colIndex:x[n].colStart};return k(!0),P(n,ai(t,e,y.getTotalRange())),{drag:e=>P(n,ai(t,e,y.getTotalRange())),end:()=>k(!1),captureEvents:!1}}let r=(!t.ctrlKey&&!t.metaKey||!o)&&n>=0?n:x.length;return k(!0),P(r,u.CoordUtils.cellToRange(e)),{drag:t=>P(r,ai(e,t,y.getTotalRange())),end:()=>k(!1),captureEvents:!1}}),L=x.map((e,t)=>n(t,t===S)),R=[];for(let e=0;e<L.length;e++)L[e]&&R.push(e);return(0,c.jsxs)(ye,{...v,children:[(!a||O)&&(0,c.jsx)(q,{fill:!0,className:C(_,`ranges-picker-draw`),onPointerDown:e=>{e.stopPropagation(),m&&e.preventDefault(),I.onPointerDown(e)},onPointerMove:I.onPointerMove,onPointerUp:e=>{e.stopPropagation(),I.onPointerUp(e)}}),i&&R.map(e=>(0,c.jsx)($n,{range:x[e],grip:`edges`,preserveFocus:m,onHoverChange:t=>N(e,t),onDragStateChange:t=>{t&&F(e),D(t?e:null)},onDragMove:t=>P(e,t),onDragEnd:t=>P(e,t)},`move-${e}`)),R.map(e=>{let t=e===S,n=e===M,i=((e,t,n)=>{let r=e.stroke??g.stroke??ii;return{...g,...e,stroke:r,fill:e.fill??g.fill??`color-mix(in srgb, ${r} 12%, transparent)`,alignWidth:n?3:e.alignWidth??g.alignWidth??2,...f&&t?{animatedStroke:!0}:void 0}})(L[e],t,n);return(0,c.jsx)(rr,{range:x[e],anchors:r,size:d,...i,renderHandle:p,preserveFocus:m,onHandleHoverChange:t=>N(e,t),onDragMove:t=>P(e,t),onDragStart:()=>{F(e),D(e)},onDragEnd:t=>{D(null),P(e,t)}},`resize-${e}`)})]})};si.displayName=`RangesPickerLayer`;var ci=0,li=class{constructor(e,t={}){this.listeners=new Set,this.commitListeners=new Set,this.cancelListeners=new Set,this.editors=new Set,this.activeEditor=null,this.activeEditorId=null,this.auxState=null,this.commitFn=e.commit,this.onCommitError=e.onCommitError,this.state={mode:t.mode??`enter`,coords:e.coords,clean:e.clean,dirty:t.dirty,initialSelection:t.initialSelection??null,autoFocus:t.autoFocus??!0,token:++ci}}getState(){return this.state}getCoords(){return this.state.coords}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}registerEditor(e){return this.editors.add(e),()=>{this.editors.delete(e),this.activeEditor===e&&(this.activeEditor=null)}}setActiveEditor(e){this.activeEditor=e}getActiveEditor(){return this.activeEditor}setActiveEditorId(e){this.activeEditorId=e}getActiveEditorId(){return this.activeEditorId}getEditors(){return[...this.editors]}getAuxState(){return this.auxState}setAuxState(e){this.auxState!==e&&(this.auxState=e,this.notify())}setDirty(e){this.state.dirty!==e&&this.emit({...this.state,dirty:e})}setMode(e){this.state.mode!==e&&this.emit({...this.state,mode:e})}commit(e){let t=this.state,n=!1,r={coords:t.coords,dirty:t.dirty,args:e,veto:()=>{n=!0}};for(let e of this.commitListeners){try{e(r)}catch(e){console.error(`EditSession beforeCommit listener threw:`,e),n=!0}if(n)break}if(n)return!1;if(t.dirty===void 0)return!0;try{if(!1===this.commitFn(t.dirty,e))return!1}catch(e){return this.onCommitError?this.onCommitError(e):console.error(`EditSession commit rejected with an error:`,e),!1}return!0}cancel(){this.cancelListeners.forEach(e=>{try{e()}catch(e){console.error(`EditSession cancel listener threw:`,e)}})}addCommitListener(e){return this.commitListeners.add(e),()=>{this.commitListeners.delete(e)}}addCancelListener(e){return this.cancelListeners.add(e),()=>{this.cancelListeners.delete(e)}}emit(e){this.state=e,this.notify()}notify(){this.listeners.forEach(e=>e())}},ui=e=>e.ctrlKey||e.metaKey||e.altKey||e.isComposing?null:e.key===`Process`||e.keyCode===229?{mode:`enter`,dirty:``}:e.key.length===1?e.key===` `&&e.shiftKey?null:{mode:`enter`,dirty:e.key}:e.shiftKey?null:e.key===`F2`?{mode:`edit`}:e.key===`Backspace`?{mode:`enter`,dirty:``}:null,di=(e,t)=>{let n=(0,s.useRef)(null);return(0,s.useLayoutEffect)(()=>{let t=n.current;t!==null&&(n.current=null,e.current?.setSelectionRange(t,t))},[t]),(0,l.useCallbackRef)(e=>{n.current=e},[])},fi=(e,t)=>{if(e.which===l.KeyCodes.Enter&&t.ctrlKey)return t.shiftKey?{arrayFixed:!0}:{broadcast:!0}},pi=e=>{let{mode:t,value:n,onDirtyChange:r,onModeChange:i,onCommit:a,onCancel:o,onNavigate:s,onTraverse:c,setCaret:d}=e;return(0,l.useCallbackRef)(e=>{let f=e.nativeEvent;if(f.isComposing)return void e.stopPropagation();if(e.which===l.KeyCodes.Escape)return e.preventDefault(),e.stopPropagation(),void o();if(!(e.which!==l.KeyCodes.F2||f.altKey||f.metaKey||f.ctrlKey||f.shiftKey))return e.preventDefault(),e.stopPropagation(),void i(t===`edit`?`enter`:`edit`);if(e.which===l.KeyCodes.Enter&&(f.altKey||f.metaKey)){e.preventDefault(),e.stopPropagation();let t=e.currentTarget,i=t.selectionStart+1;d&&d(i),r(n.substring(0,t.selectionStart)+`
3
- `+n.substring(t.selectionEnd)),d||requestAnimationFrame(()=>t.setSelectionRange(i,i));return}let p=e.which===l.KeyCodes.Left||e.which===l.KeyCodes.Right||e.which===l.KeyCodes.Up||e.which===l.KeyCodes.Down;if(p&&t===`edit`)return void e.stopPropagation();if(e.which===l.KeyCodes.Enter||e.which===l.KeyCodes.Tab||p&&t===`enter`){e.preventDefault();let t=fi(e,f);if(!a(t)||t)return void e.stopPropagation();let n=e.which===l.KeyCodes.Enter||e.which===l.KeyCodes.Tab;n&&c?(e.stopPropagation(),c(e.which===l.KeyCodes.Tab?u.RangeAxis.Row:u.RangeAxis.Column,e.shiftKey)):!n&&s&&(e.stopPropagation(),s((e=>{switch(e.which){case l.KeyCodes.Enter:return e.shiftKey?u.Direction.Up:u.Direction.Down;case l.KeyCodes.Tab:return e.shiftKey?u.Direction.Left:u.Direction.Right;case l.KeyCodes.Up:return u.Direction.Up;case l.KeyCodes.Left:return u.Direction.Left;case l.KeyCodes.Right:return u.Direction.Right;default:return u.Direction.Down}})(e)));return}let m=f.ctrlKey||f.metaKey,h=e.key.length===1?e.key.toLowerCase():``;(!m||h!==`c`&&h!==`x`&&h!==`v`&&h!==`a`&&h!==`z`&&h!==`y`)&&(e.which!==l.KeyCodes.Insert||!m&&!f.shiftKey)&&e.which!==l.KeyCodes.Delete&&e.which!==l.KeyCodes.BackSpace&&(t!==`edit`||e.which!==l.KeyCodes.Home&&e.which!==l.KeyCodes.End&&e.which!==l.KeyCodes.PageUp&&e.which!==l.KeyCodes.PageDown)||e.stopPropagation()},[t,n,a,o,i,r,s,c,d])},mi=(e,t,n,r=`left`,i=0)=>{if(!t)return null;let a=e.getRangeFromCell(t),o=e.getBoundsFromRange(a);if(!o)return null;let s=e.toClipBounds(e.getBoundsFromRange(a))!==null,c=e.getZoom(),l=n?.width?n.width*c:void 0,u=n?.height?n.height*c:void 0,d={...o};if(l!==void 0){let t=e.getPaneRange(),n=e.getMetrics(),i={...a},o=!1,s=0;for(;!o&&d.width<=l&&s<20;)s++,r===`left`?i.colEnd+1<t.colEnd?i.colEnd=n.getColIndex(d.x+l):o=!0:r===`right`?i.colStart-1>=0?i.colStart=n.getColIndex(d.x-(l-d.width)):o=!0:i.colEnd+1<t.colEnd&&i.colStart-1>=0?(i.colStart=n.getColIndex(d.x-(l-d.width)/2),i.colEnd=n.getColIndex(d.x+d.width+(l-d.width)/2)):o=!0,o||(d=e.getBoundsFromRange(i))}d.height=o.height,u!==void 0&&(d.height=Math.max(u+1,o.height));let f=e.getSurfaceSize(),p=Math.max(o.width,f.width-d.x-i);return{bounds:{x:d.x??0,y:d.y??0,width:Math.min(p,d.width),height:Math.min(f.height-d.y,d.height)},inView:s}},hi=96/72*11,gi=`Calibri, sans-serif`,_i=e=>{let{open:t,mode:n,clean:r,dirty:i,token:a,autoFocus:o,initialSelection:l,zoom:u,readOnly:d,onDirtyChange:f,onModeChange:p,onCommit:m,onCancel:h,onNaturalSize:g}=e,_=i??r??``,v=(0,s.useRef)(null),y=(0,s.useRef)(null),b=(0,s.useRef)(0);(0,s.useLayoutEffect)(()=>{if(!t||!o)return;let e=v.current;if(!e||(e.focus(),b.current===a))return;b.current=a;let n=e.value.length,r=l??{start:n,end:n,direction:`forward`};e.setSelectionRange(r.start,r.end,r.direction)},[a,t,o]),(0,s.useLayoutEffect)(()=>{let e=y.current;e&&g&&g({width:e.offsetWidth+4,height:e.offsetHeight})},[_,g]);let x=pi({mode:n,value:_,onDirtyChange:f,onModeChange:p,onCommit:m,onCancel:h,setCaret:di(v,_)});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`textarea`,{ref:v,value:_,spellCheck:!1,autoComplete:`off`,autoCapitalize:`off`,name:`cell-editor`,readOnly:d,style:{flex:`1 1 100%`,boxSizing:`border-box`,padding:`0px 2px`,margin:0,border:`none`,outline:`none`,resize:`none`,overflow:`hidden`,background:`transparent`,fontFamily:gi,fontSize:hi*u+`px`,lineHeight:1.2,whiteSpace:`pre`,userSelect:`text`},onChange:e=>f(e.target.value),onPointerDown:e=>{e.stopPropagation(),n!==`edit`&&p(`edit`)},onKeyDown:x}),(0,c.jsx)(`div`,{ref:y,"aria-hidden":!0,style:{position:`absolute`,top:0,left:0,visibility:`hidden`,pointerEvents:`none`,whiteSpace:`pre`,fontFamily:gi,fontSize:`${hi}px`,lineHeight:1.2},children:_.length===0?` `:_})]})};function vi(e){let{editable:t,renderEditor:n,idleClean:r=null,mapClean:i,editorId:a,readOnly:o,className:s,style:u}=e,d=(0,l.useBoundSyncExternalStore)(t,e=>e.getSession()),f=(0,l.useOptionalBoundSyncExternalStore)(d,e=>e.getState()),p=f?.clean??r,m=i?i(p):p,h=(0,l.useCallbackRef)(e=>t.commit(e),[t]),g=(0,l.useCallbackRef)(()=>t.cancel(),[t]),_=(0,l.useCallbackRef)(()=>{o||(t.getSession()||t.startEdit(t.getAnchor().getCoords(),{mode:`edit`,autoFocus:!1}),t.getSession()?.setActiveEditorId(a??null))},[t,a,o]),v={open:!!f,mode:f?.mode??`enter`,coords:f?.coords??t.getAnchor().getCoords(),clean:m,dirty:f?.dirty,token:f?.token??0,autoFocus:!1,readOnly:o,initialSelection:f?.initialSelection,zoom:1,onDirtyChange:e=>d?.setDirty(e),onModeChange:e=>d?.setMode(e),onCommit:h,onCancel:g};return(0,c.jsx)(`div`,{className:s,style:u,onFocus:_,children:n?n(v):(0,c.jsx)(_i,{...v})})}_i.displayName=`DefaultEditorInput`,vi.displayName=`EditorDiv`;var yi=`ew-resize`,bi=`ns-resize`,xi=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{axis:n,index:r,className:i,style:a,disabled:o=!1,disabledResize:s=!1,isNextHidden:d,isHidden:f,isSelected:p,isSelectedAll:m,showTouchDivider:h,bounds:g,onPointerDown:_,onAutoFit:v,...y}=e,b=W(),x=n===u.RangeAxis.Column,S=1/l.ReactUtils.getDevicePixelRatio(),w=p||m,T=w?`color-mix(in srgb, var(--sxl-color-primary, rgb(33, 115, 70)) 35%, var(--sxl-color-base-300, rgb(171, 171, 171)))`:`var(--sxl-color-base-300, rgb(171, 171, 171))`,E=`var(--sxl-color-base-100, #f5f5f5)`,D=l.ReactUtils.detectIt().primaryInput===`touch`,O=x?14:8,k=b.getZoom();k<1&&(O=Math.max(2,O*k*.8));let A=O/2,j=0;d&&(j=-2),f&&(j=2),f&&(O=O/2+j,A=2*j);let M=T;return w||j!==0||(M=`linear-gradient(${x?180:90}deg, ${E}, ${T} 55%, ${T} 100%)`),(0,c.jsxs)(`div`,{className:C(`header-divider`,{disabled:o},i,`index-${r}`),ref:t,onPointerDown:D?void 0:_,onDoubleClick:D?void 0:()=>v?.(),style:{top:`${x?0:-O/2+j}px`,left:`${x?-O/2+j:0}px`,width:x?O:`calc(100%)`,height:x?`calc(100%)`:O,position:`absolute`,overflow:`visible`,pointerEvents:`auto`,cursor:o||s||D?void 0:x?yi:bi,...a},...y,children:[(0,c.jsx)(`div`,{style:{position:`relative`,top:`${x?0:A}px`,left:`${x?A:0}px`,width:x?S:`100%`,height:x?`100%`:S,background:M},onDoubleClick:()=>v?.()}),h&&D?(0,c.jsx)(`div`,{style:{position:`absolute`,cursor:`grab`,zIndex:1,borderRadius:`4px`,right:x?`-6px`:`2px`,bottom:x?`2px`:`-9px`,height:`24px`,width:x?`24px`:`18px`,maxHeight:x?`calc(100% - 4px)`:void 0,maxWidth:x?void 0:`calc(100% - 4px)`,background:E,border:`1px solid var(--sxl-color-base-300, rgb(171, 171, 171))`,boxShadow:`0.5px 0.5px 0px 0px var(--sxl-color-base-content, rgba(0,0,0,0.87))`,display:`flex`,alignItems:`center`,justifyContent:`center`},onPointerDown:_,children:(0,c.jsx)(`div`,{style:{width:`6.4px`,height:`12px`,backgroundImage:`url("data:image/svg+xml,%3Csvg width='6.4' height='12' viewBox='0 0 9.6 16' version='1.1' fill='rgb(128%2C128%2C128)' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cpath d='M 9.60008,14.40009 C 9.60008,15.28374 8.88368,16 8.00003,16 7.11639,16 6.40012,15.28374 6.40012,14.40009 c 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40012 c 0,0.88364 -0.7164,1.60004 -1.60005,1.60004 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60004 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40006 c 0,0.88365 -0.7164,1.60005 -1.60005,1.60005 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60005 C 6.40012,0.71626 7.11639,0 8.00003,0 8.88368,0 9.60008,0.71626 9.60008,1.59991 M 3.19996,14.40009 C 3.19996,15.28374 2.48369,16 1.60005,16 0.7164,16 0,15.28374 0,14.40009 c 0,-0.88365 0.7164,-1.60005 1.60005,-1.60005 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40012 c 0,0.88364 -0.71627,1.60004 -1.59991,1.60004 C 0.7164,9.60001 0,8.88361 0,7.99997 0,7.11632 0.7164,6.39992 1.60005,6.39992 c 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40006 c 0,0.88365 -0.71627,1.60005 -1.59991,1.60005 C 0.7164,3.19996 0,2.48356 0,1.59991 0,0.71626 0.7164,0 1.60005,0 2.48369,0 3.19996,0.71626 3.19996,1.59991' /%3E%3C/svg%3E%0A")`,backgroundRepeat:`no-repeat`,backgroundPosition:`center`,transform:x?void 0:`rotate(90deg)`}})}):null]})})),Si=e=>(0,c.jsx)(xi,{...e}),Ci=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{axis:n,index:r,disabled:i=!1,disabledResize:a=!1,resizeThreshold:o=1,renderDivider:f=Si,onDividerMouseDown:p,onDividerResizeStart:m,onDividerResize:h,onDividerResizeEnd:g,onDividerMouseUp:_,onDividerAutoFit:v,onPointerDown:y,...b}=e,x=W(),S=(0,l.useCallbackRef)(y,[y]),w=(0,l.useCallbackRef)(v,[v]),T=n===u.RangeAxis.Column,E=T?x.getVisibleColumns():x.getVisibleRows(),D=null;E.length>0&&(D=T?x.getBoundsFromRange({rowStart:0,rowEnd:0,colStart:E[0].index,colEnd:E[E.length-1].index}):x.getBoundsFromRange({rowStart:E[0].index,rowEnd:E[E.length-1].index,colStart:0,colEnd:0}),D=x.toClipBounds(D,-10));let O=(0,s.useRef)(null),[k,A]=(0,s.useState)(null),j=(e,t)=>T?e.clientX-t.clientX:e.clientY-t.clientY,M=x.getMetrics(),N=T?M.getColOffset(r+1):M.getRowOffset(r+1),P=l.ReactUtils.getDevicePixelRatio(),F=1/P,I=l.ReactUtils.snapLineCenter(N,F,P)-F/2,L=(0,l.useSynchronizedPointerHandler)({processTouch:!0,onPointerDown:e=>{if(S?.(e),!i&&!a){let e=T?M.getColOffset(r):M.getRowOffset(r),t=N-e;O.current={isResizing:!1,startSize:t,index:r,pane:x,axis:n,onDividerMouseDown:p,onDividerResizeStart:m,onDividerResize:h,onDividerResizeEnd:g,onDividerMouseUp:_},A(O.current),p?.(r,t)}e.stopPropagation(),e.preventDefault()},onPointerUp:(e,t,n)=>{if(!O.current)return;O.current.isResizing&&O.current.onDividerResizeEnd?.(O.current.index,Math.max(0,O.current.startSize+j(e,n)),O.current.startSize);let r=O.current;O.current=null,A(O.current),r.onDividerMouseUp?.(r.index)},onPointerMoveOrWait:(e,t,n)=>{if(!O.current)return;let r=j(e,n);O.current.isResizing?O.current.onDividerResize?.(O.current.index,Math.max(0,O.current.startSize+r),O.current.startSize):Math.abs(r)>=Math.max(0,o)&&(O.current={...O.current,isResizing:!0},A(O.current),O.current.onDividerResizeStart?.(O.current.index,Math.max(0,O.current.startSize+r))),e.stopPropagation(),e.preventDefault()}}),R=(0,l.useCallbackRef)(()=>{w?.(r)},[r]),{getPortalContainer:ee}=(0,l.useFullscreenPortal)();if(!D)return;let te=f({bounds:D,axis:n,index:r,disabled:i,disabledResize:a,onAutoFit:R,onPointerDown:L,ref:t,...b},x);if(!te)return;let ne=null;return k&&k.isResizing&&k.index===r&&(ne=(0,d.createPortal)((0,c.jsx)(`div`,{style:{position:`absolute`,cursor:T?yi:bi,left:0,top:0,width:`100%`,height:`100%`}}),ee(),`divider:`+r)),(0,c.jsxs)(c.Fragment,{children:[ne,(0,c.jsx)(`div`,{className:C(`header-divider-anchor`),style:{position:`absolute`,pointerEvents:`auto`,top:`${T?D.y:I}px`,left:`${T?I:D.x}px`,width:(T?0:D.width-1)+`px`,height:(T?D.height-1:0)+`px`,display:`flex`},tabIndex:-1,children:te})]})}));Ci.displayName=`HeaderDividerAnchor`;var wi=(e,t,n)=>t===u.RangeAxis.Column?{rowIndex:n.rowStart,colIndex:e.colIndex}:{rowIndex:e.rowIndex,colIndex:n.colStart},Ti=(e,t,n,r)=>n===u.RangeAxis.Column?{rowStart:r.rowStart,rowEnd:r.rowEnd,colStart:Math.min(e.colIndex,t.colIndex),colEnd:Math.max(e.colIndex,t.colIndex)}:{colStart:r.colStart,colEnd:r.colEnd,rowStart:Math.min(e.rowIndex,t.rowIndex),rowEnd:Math.max(e.rowIndex,t.rowIndex)},Ei=(e,t,n)=>{let r=null,i=null,a=0,o=()=>t.getAllPanes()[u.AnchorLocation.Center]??t,s=(t,n,r)=>{if(!e)return;let i=e.getSelection(),a=!!i.ranges&&i.ranges.length>0;if(r===`clear`)return void e.setSelection({cell:n,ranges:[t],rangeIndex:0});if(r===`append`){let r=a?[...i.ranges]:[u.CoordUtils.cellToRange(i.cell)];r.push(t),e.setSelection({cell:n,ranges:r,rangeIndex:r.length-1});return}let o=i.rangeIndex??-1,s=a?o>=0?o:i.ranges.length-1:0,c=a?i.ranges.map((e,n)=>n===s?t:e):[t];e.setSelection({cell:n,ranges:c,rangeIndex:a?s:0})},c=(t,n,r)=>{if(!e)return;let i=e.getSelection(),a=i.ranges&&i.ranges.length>0?i.ranges:[],o=t<a.length?a.map((e,r)=>r===t?n:e):[...a,n];e.setSelection({cell:r,ranges:o,rangeIndex:t})},l=e=>{let{scrollIntoView:t}=n();t?t(e):o().scrollCellCoordsIntoView(e)},d=e=>{let{axis:t,entireRange:r}=n(),i=o().getElement()?.getBoundingClientRect();if(!i)return!1;let a=o().getVisibleRange(),s=null;return t===u.RangeAxis.Column?e.x>=i.right-24&&a.colEnd<r.colEnd?s={colIndex:a.colEnd+1}:e.x<=i.left+24&&a.colStart>r.colStart&&(s={colIndex:a.colStart-1}):e.y>=i.bottom-24&&a.rowEnd<r.rowEnd?s={rowIndex:a.rowEnd+1}:e.y<=i.top+24&&a.rowStart>r.rowStart&&(s={rowIndex:a.rowStart-1}),!!s&&(l(s),!0)},f=e=>{let{axis:t,entireRange:l,replaceActive:u=!1}=n(),d=Ti(r??e,e,t,l),f=i??wi(e,t,o().getVisibleRange());u?c(a,d,f):s(d,f,`replace`)};return zn(t,(t,p)=>{if(!e)return null;let m=p.button===0,h=p.button===2;if(!m&&!h)return null;let{axis:g,entireRange:_,allowMulti:v=!0,replaceActive:y=!1,preserveFocus:b=!1,onPointerDownInterceptor:x,onDragStart:S,onDragEnd:C,onPointerUp:w}=n();if(!1===x?.(p,t))return null;y&&p.stopPropagation(),b&&m&&p.preventDefault(),S?.();let T=wi(t,g,o().getVisibleRange()),E=p.shiftKey,D=(p.ctrlKey||p.metaKey)&&v;if(y){let n=e.getSelection(),o=n.ranges??[],s=n.rangeIndex??-1;E&&r?(a=s>=0?s:Math.max(0,o.length-1),c(a,Ti(r,t,g,_),i??T)):(r=t,i=T,a=D||s<0?o.length:s,c(a,Ti(t,t,g,_),T))}else E&&r?s(Ti(r,t,g,_),i??T,`replace`):D?(r=t,i=T,s(Ti(t,t,g,_),T,`append`)):(r=t,i=T,s(Ti(t,t,g,_),T,`clear`));return(e=>{l(n().axis===u.RangeAxis.Column?{colIndex:e.colIndex}:{rowIndex:e.rowIndex})})(t),{drag:f,edgeScroll:d,end:e=>{C?.(e),w?.(e)},cancel:e=>{C?.(e)},capture:m,captureEvents:y}})},Di=e=>e==null?[]:Array.isArray(e)?e:[e],Oi=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{rowCount:n=1,columnCount:r=1,getRowHeight:i,getColumnWidth:a,metrics:o,renderCells:u,renderBorders:d,showGridLines:f=!0,gridLineColor:m,propsGridLineRows:h,propsGridLineColumns:g,getVisibleCells:_,hiddenCellAt:v,renderBelow:y,children:b,...x}=e,S=p({rowCount:n,columnCount:r,getRowHeight:i,getColumnWidth:a}),C=o??S,[w,T]=(0,s.useReducer)(e=>e+1,0),E=(0,s.useMemo)(()=>({}),[w]),D=(0,s.useCallback)(e=>{T()},[]),O=(0,l.useImperativeElement)(t,()=>({invalidate:D}),[D]),k=(0,s.useMemo)(()=>{let e=[];return!1!==f&&e.push((0,c.jsx)(Dr,{showGridLines:f,gridLineColor:m,propsRows:h,propsColumns:g,getVisibleCells:_,hiddenCellAt:v},`__gridlines`)),e.push(...Di(y)),e.push(...Di(d)),u&&e.push((0,c.jsx)(yr,{renderCell:u,getVisibleCells:_,hiddenCellAt:v,cacheToken:E},`__cells`)),e.push(...Di(b)),e},[f,m,h,g,_,v,y,d,u,E,b]);return(0,c.jsx)(H,{ref:O,...x,rowCount:n,columnCount:r,metrics:C,children:k})}));Oi.displayName=`Grid`;var ki=function(){},Ai=typeof window<`u`,ji=Ai?s.useLayoutEffect:s.useEffect,Mi={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0},Ni=Ai&&window.ResizeObserver!==void 0?function(){var e=(0,s.useState)(null),t=e[0],n=e[1],r=(0,s.useState)(Mi),i=r[0],a=r[1],o=(0,s.useMemo)(function(){return new window.ResizeObserver(function(e){if(e[0]){var t=e[0].contentRect,n=t.x,r=t.y,i=t.width,o=t.height,s=t.top,c=t.left,l=t.bottom,u=t.right;a({x:n,y:r,width:i,height:o,top:s,left:c,bottom:l,right:u})}})},[]);return ji(function(){if(t)return o.observe(t),function(){o.disconnect()}},[t]),[n,i]}:function(){return[ki,Mi]};function Pi(e,t){if(typeof e==`function`)return e(t);e&&(e.current=t)}var Fi,Ii=parseInt(s.version.split(`.`)[0],10)>=19?function(e){return t=>{let n=[];for(let r of e){let e=Pi(r,t),i=typeof e==`function`;n.push(i?e:()=>Pi(r,null))}return()=>{for(let e of n)e()}}}:function(e){return t=>{for(let n of e)Pi(n,t)}},Li={fill:{fill:`color-mix(in srgb, var(--sxl-color-primary, rgb(0, 120, 215)) 14%, transparent)`},border:null,inner:null},Ri={stroke:`var(--sxl-color-primary, rgb(0, 120, 215))`,alignWidth:1,inset:1},zi=(0,s.forwardRef)(function(e,t){let{itemCount:n,renderCell:r,getVisibleCells:i,itemHeight:a=24,contentWidth:o,selection:u,propsLayer:d,autoFocus:f,showScrollbar:m=`auto`,scrollTo:h,viewport:g,cacheToken:_,className:v,style:y,children:b,...x}=e,S=(0,s.useMemo)(()=>new l.Viewport,[]),w=g??S,T=(0,l.useBoundSyncExternalStore)(w,e=>e.getMetrics()),E=m===`auto`?T.totalHeight>T.height:m,D=(0,s.useRef)(null);(0,s.useEffect)(()=>{f&&D.current?.focus()},[f]),(0,s.useEffect)(()=>{if(!h)return;let e=!1,t=0,n=()=>{!e&&w.isReady()&&(e=!0,t=requestAnimationFrame(()=>{D.current?.scrollCellCoordsIntoView({rowIndex:h.row})}))};n();let r=e?null:w.subscribe(n);return()=>{e=!0,t&&cancelAnimationFrame(t),r?.()}},[h,w]);let O=(0,s.useMemo)(()=>new kr({getBounds:()=>({rowStart:0,colStart:0,rowEnd:Math.max(0,n-1),colEnd:0})}),[n]),k=u??O,[A,{width:j}]=Ni(),[M,{width:N}]=Ni(),P=N>0&&j>0?Math.max(0,N-j):0,F=(0,s.useMemo)(()=>Ii([M,t]),[M,t]),I=p({rowCount:n,columnCount:1,getRowHeight:a,getColumnWidth:j||o||T.width||0});return(0,c.jsx)(`div`,{ref:F,className:C(`list-surface`,v),style:{position:`relative`,overflow:`hidden`,height:n*a,maxWidth:`100%`,maxHeight:`100%`,...y,...o==null?null:{width:o+P}},...x,children:(0,c.jsx)(l.ScrollPane,{viewport:w,showVerticalScrollbar:E,showHorizontalScrollbar:!1,style:{width:`100%`,height:`100%`},children:(0,c.jsx)(`div`,{ref:A,style:{width:`100%`,height:`100%`},children:(0,c.jsxs)(H,{ref:D,viewport:w,style:{width:`100%`,height:`100%`},rowCount:n,columnCount:1,metrics:I,children:[(0,c.jsx)(ei,{selection:k,anchorHole:!1,singleStyle:Li,singleAnchorStyle:Ri,multiAnchorStyle:Ri},`__selection`),(0,c.jsx)(yr,{renderCell:r,getVisibleCells:i,cacheToken:_},`__cells`),d?(0,c.jsx)(ye,{...d},`__taps`):null]})})})})}),Bi=(0,s.forwardRef)(function(e,t){let{itemCount:n,renderItem:r,itemHeight:i,selection:a,onKeyDown:o,cacheToken:u,scrollTo:d,autoFocus:f,viewport:p,className:m,style:h,children:g,..._}=e,v=(0,l.useImperativeElement)(t,()=>({isList:()=>!0}),[]),y=(0,s.useCallback)(e=>{let{key:t,style:n,range:i,cell:a}=e,o=i?.rowStart??a.rowIndex;return(0,c.jsx)(`div`,{style:{...n,position:`absolute`,display:`flex`,alignItems:`center`,boxSizing:`border-box`,padding:`0 8px`,overflow:`hidden`,whiteSpace:`nowrap`,userSelect:`none`,pointerEvents:`none`,background:`transparent`},children:r(o)},t)},[r]),b=(0,s.useMemo)(()=>o?{onKeyDown:o}:void 0,[o]);return(0,c.jsx)(zi,{ref:v,className:C(`list`,m),style:h,itemCount:n,itemHeight:i,selection:a,renderCell:y,propsLayer:b,cacheToken:u,scrollTo:d,autoFocus:f,viewport:p,..._})}),Vi=(e,t)=>(0,c.jsx)(`input`,{type:`checkbox`,checked:e,ref:e=>{e&&(e.indeterminate=!!t)},readOnly:!0,tabIndex:-1,style:{margin:0}}),Hi=(0,s.forwardRef)(function(e,t){let{itemCount:n,isChecked:r,onCheckedChange:i,renderValue:a,renderCheckbox:o=Vi,renderDivider:u,selectAllLabel:d,itemHeight:f,selection:p,cacheToken:m,autoFocus:h,viewport:g,className:_,style:v,children:y,...b}=e,x=(0,s.useMemo)(()=>new kr({getBounds:()=>({rowStart:0,colStart:0,rowEnd:Math.max(0,n-1),colEnd:0})}),[n]),S=p??x,w=(0,l.useCallbackRef)(()=>{if(n===0)return;let e=!r(S.getSelection().cell.rowIndex);i((e=>{let t=e.getSelection();return t.ranges&&t.ranges.length?t.ranges.flatMap(e=>Array.from({length:e.rowEnd-e.rowStart+1},(t,n)=>e.rowStart+n)):[t.cell.rowIndex]})(S),e)},[S,n,r,i]),T=(0,s.useRef)(null),[,E]=(0,s.useReducer)(e=>e+1,0),D=(0,l.useCallbackRef)(()=>n===0?-1:S.getSelection().cell.rowIndex,[S,n]),O=(0,l.useCallbackRef)(e=>{if(n===0)return;let t=Math.min(Math.max(0,S.getSelection().cell.rowIndex+e),n-1);S.setSelection({cell:{rowIndex:t,colIndex:0}}),T.current={row:t},E()},[S,n]),k=(0,l.useImperativeElement)(t,()=>({isCheckboxList:()=>!0,getHighlightIndex:D,moveHighlight:O,toggleHighlighted:w}),[D,O,w]),A=(0,s.useCallback)(e=>(0,c.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flex:1,minWidth:0,pointerEvents:`auto`,cursor:`pointer`},onMouseDown:t=>{t.preventDefault(),i([e],!r(e))},children:[(0,c.jsx)(`div`,{style:{display:`inline-flex`,pointerEvents:`none`},children:o(r(e))}),(0,c.jsx)(`div`,{style:{overflow:`hidden`,textOverflow:`ellipsis`},children:a(e)})]}),[r,i,a,o]),j=(0,s.useCallback)(e=>{e.key!==` `&&e.key!==`Enter`||(e.preventDefault(),e.stopPropagation(),w())},[w]),{allChecked:M,someChecked:N}=(0,s.useMemo)(()=>{if(d==null||n===0)return{allChecked:!1,someChecked:!1};let e=!0,t=!1;for(let i=0;i<n;i++)r(i)?t=!0:e=!1;return{allChecked:e,someChecked:t&&!e}},[d,n,r,m]);return(0,c.jsxs)(`div`,{ref:k,className:C(`checkbox-list`,_),style:{display:`flex`,flexDirection:`column`,minHeight:0,...v},...b,children:[d!=null&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,userSelect:`none`,cursor:`pointer`},onMouseDown:e=>{e.preventDefault(),i(Array.from({length:n},(e,t)=>t),!M)},children:[(0,c.jsx)(`div`,{style:{display:`inline-flex`,pointerEvents:`none`},children:o(M,N)}),d]}),u?.()]}),(0,c.jsx)(Bi,{itemCount:n,itemHeight:f,selection:S,renderItem:A,onKeyDown:j,cacheToken:m,scrollTo:T.current,autoFocus:h,viewport:g,style:{flex:`1 1 100%`,minHeight:0}})]})}),Ui=(e,t)=>{let n=(()=>{if(Fi!==void 0)return Fi;try{Fi=(typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):null)??null}catch{Fi=null}return Fi})();if(n)return n.font=t,n.measureText(e).width;let r=Number.parseFloat((/(\d+(?:\.\d+)?)px/.exec(t)??[])[1]??`16`)||16;return e.length*r*.55},Wi=(e,t)=>t<=0?-1:Math.min(Math.max(0,e),t-1),Gi=(0,s.forwardRef)(function(e,t){let{items:n,onChoose:r,highlightIndex:i,itemHeight:a=24,visibleRows:o=8,contentWidth:u,measureText:d,renderItem:f,autoFocus:p,viewport:m,className:h,style:g,children:_,...v}=e,y=n.length,b=Wi(i??0,y),x=(0,s.useMemo)(()=>new kr({initial:{cell:{rowIndex:Math.max(0,b),colIndex:0}},getBounds:()=>({rowStart:0,colStart:0,rowEnd:Math.max(0,y-1),colEnd:0})}),[n,b,y]),S=(0,s.useRef)(null),[,w]=(0,s.useReducer)(e=>e+1,0),T=(0,s.useMemo)(()=>(S.current=null,b>=0?{row:b}:null),[n,b]),E=S.current??T,D=(0,l.useCallbackRef)(e=>!(e<0||e>=y)&&(r?.(e,n[e]),!0),[r,n,y]),O=(0,l.useCallbackRef)(()=>y===0?-1:x.getSelection().cell.rowIndex,[x,y]),k=(0,l.useCallbackRef)(e=>{if(y===0)return;let t=Wi(x.getSelection().cell.rowIndex+e,y);x.setSelection({cell:{rowIndex:t,colIndex:0}}),S.current={row:t},w()},[x,y]),A=(0,l.useImperativeElement)(t,()=>({isPickList:()=>!0,getHighlightIndex:O,moveHighlight:k,chooseHighlighted:()=>D(O())}),[O,k,D]),j=(0,s.useMemo)(()=>{if(d)return d;let e=(e=>{let t=e?.fontSize,n=e?.fontFamily,r=typeof t==`number`?`${t}px`:t??`16px`,i=[];return e?.fontStyle&&e.fontStyle!==`normal`&&i.push(String(e.fontStyle)),e?.fontWeight&&e.fontWeight!==`normal`&&i.push(String(e.fontWeight)),i.push(r,n?String(n):`sans-serif`),i.join(` `)})(g);return t=>Ui(t,e)},[d,g]),M=(0,s.useMemo)(()=>{if(u!=null)return u;let e=0;for(let t=0;t<y;t++)e=Math.max(e,j(n[t].text));return Math.ceil(e)+16},[u,n,y,j]),N=(0,s.useCallback)(e=>{let{key:t,style:r,range:i,cell:a}=e,o=i?.rowStart??a.rowIndex,s=n[o];return s?(0,c.jsx)(`div`,{role:`option`,style:{...r,position:`absolute`,display:`flex`,alignItems:`center`,boxSizing:`border-box`,padding:`0 8px`,overflow:`hidden`,whiteSpace:`nowrap`,userSelect:`none`,pointerEvents:`none`,background:`transparent`},children:f?f(s,o):(0,c.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`},children:s.text||`\xA0`})},t):null},[n,f]),P=(0,s.useMemo)(()=>({onPointerUp:e=>{e.button===0&&D(O())},onKeyDown:e=>{e.which!==l.KeyCodes.Enter&&e.which!==l.KeyCodes.Space||(e.preventDefault(),e.stopPropagation(),D(O()))}}),[D,O]);return(0,c.jsx)(zi,{ref:A,className:C(`pick-list`,h),role:`listbox`,style:{maxHeight:o*a,...g},itemCount:y,itemHeight:a,contentWidth:M,selection:x,renderCell:N,propsLayer:P,scrollTo:E,viewport:m,autoFocus:p,cacheToken:n,...v})}),Ki=`_search_b1nag_5`,qi=(0,s.forwardRef)(function(e,t){let{value:n,onChange:r,onClose:i,onKeyDown:a,className:o,...u}=e,d=(0,s.useCallback)(e=>{if(e.which===l.KeyCodes.Escape)return e.preventDefault(),e.stopPropagation(),void(n?r(``):i?.());a?.(e)},[n,r,i,a]);return(0,c.jsx)(`input`,{ref:t,type:`text`,role:`searchbox`,autoComplete:`off`,spellCheck:!1,className:C(Ki,`list-search`,o),value:n,onChange:e=>r(e.target.value),onKeyDown:d,...u})}),Ji={light:{},dark:{"color-base-100":`#1e1e1e`,"color-base-300":`#3a3a3a`}},Yi={light:{"color-base-100":`#f2f2f2`,"color-base-hover":`#ececec`,"color-base-300":`rgb(171, 171, 171)`},dark:{"color-base-100":`#262626`,"color-base-hover":`#2e2e2e`,"color-base-300":`#4a4a4a`}};exports.AUTO_SCROLL_INTERVAL_MS=60,exports.CellLayer=yr,exports.CellTileDiv=vr,exports.CheckboxList=Hi,exports.DEFAULT_ANCHOR_STYLE=zr,exports.DEFAULT_HANDLE_STYLE=An,exports.DEFAULT_INSERT_BAR_STYLE=Vr,exports.DEFAULT_MOVE_SOURCE_STYLE=Hr,exports.DEFAULT_MULTI_STYLE=Rr,exports.DEFAULT_REMOVE_PREVIEW_STYLE=Br,exports.DEFAULT_SINGLE_STYLE=Lr,exports.DefaultCellRenderer=cr,exports.DefaultEditable=class{constructor(e,t,n){this.current=null,this.listeners=new Set,this.commitErrorListeners=new Set,this.anchor=e,this.createEdit=t,this.revertAnchor=n?.revertAnchor,this.unsubscribeAnchor=e.subscribe(()=>this.onAnchorChange())}onAnchorChange(){if(!this.current)return;let e=this.current.getState().coords;u.CoordUtils.isEqualCells(this.anchor.getCoords(),e)||this.commit()||(this.revertAnchor?.(e),u.CoordUtils.isEqualCells(this.anchor.getCoords(),e)||this.cancel())}getAnchor(){return this.anchor}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}subscribeCommitError(e){return this.commitErrorListeners.add(e),()=>{this.commitErrorListeners.delete(e)}}getSession(){return this.current}startEdit(e,t={}){let n=this.createEdit(e);return n?(this.current=new li({coords:e,...n,onCommitError:e=>{this.commitErrorListeners.size===0?console.error(`EditSession commit rejected with an error:`,e):this.commitErrorListeners.forEach(t=>t(e))}},t),this.notify(),!0):!1}commit(e){if(!this.current)return!1;let t=this.current.commit(e);return t&&(this.current=null,this.notify()),t}cancel(){this.current&&(this.current.cancel(),this.current=null,this.notify())}dispose(){this.unsubscribeAnchor(),this.cancel(),this.listeners.clear()}notify(){this.listeners.forEach(e=>e())}},exports.DefaultEditorInput=_i,exports.DefaultHeaderDivider=xi,exports.DefaultSelection=kr,exports.DragHandle=Wn,exports.Draggable=$n,exports.EDGE_AUTO_SCROLL_MARGIN_PX=24,exports.EditSession=li,exports.EditorDiv=vi,exports.EditorLayer=function(e){let{editable:t,renderEditor:n,alignment:r=`left`,background:i=`var(--sxl-color-base-100, rgb(255, 255, 255))`,borderColor:a=`var(--sxl-color-primary, rgb(33, 115, 70))`,borderWidth:o=2,zIndex:u,className:d,style:f,...p}=e,m=G(),h=(0,l.useBoundSyncExternalStore)(t,e=>e.getSession()),g=(0,l.useOptionalBoundSyncExternalStore)(h,e=>e.getState()),[_,v]=(0,s.useState)(null),y=(0,l.useCallbackRef)(e=>{v(t=>t&&t.width===e.width&&t.height===e.height?t:e)},[]),b=(0,l.useCallbackRef)(e=>{if(t.getSession())return;let n=t.getAnchor().getCoords();if(!n)return;let r=ui(e.nativeEvent);r&&(e.nativeEvent.key!==`Process`&&e.nativeEvent.keyCode!==229&&e.preventDefault(),e.stopPropagation(),t.startEdit(n,r))},[t]),x=(0,l.useCallbackRef)(e=>{if(t.getSession())return;let n=m?.getCellFromPointer(e.clientX,e.clientY)??t.getAnchor().getCoords();n&&t.startEdit(n,{mode:`edit`})},[m,t]),S=(0,l.useCallbackRef)(e=>{let n=t.commit(e);return n&&m?.focus(),n},[t,m]),w=(0,l.useCallbackRef)(()=>{t.cancel(),m?.focus()},[t,m]);(0,s.useEffect)(()=>{g&&m&&m.scrollCellCoordsIntoView(g.coords)},[g?.token]);let T=g?g.coords:t.getAnchor().getCoords(),E=null,D=!1,O=!1;if(m&&T){let e=m.getRangeFromCell(T);if(O=m.toClipBounds(m.getBoundsFromRange({rowStart:e.rowStart,colStart:e.colStart,rowEnd:e.rowStart,colEnd:e.colStart}))!==null,g){let e=mi(m,T,_,r,o);E=e?.bounds??null,D=e?.inView??!1}else E=m.getBoundsFromRange(e)}let k=null;if(m&&T){let e=m.getBoundsFromRange(m.getRangeFromCell(T)),t=m.getZoom()||1;e&&(k={width:e.width/t,height:e.height/t})}let A=!!g&&!!E&&D,j={open:!!g,mode:g?.mode??`enter`,coords:g?.coords??null,clean:g?.clean??null,dirty:g?.dirty,token:g?.token??0,autoFocus:(g?.autoFocus??!0)&&A&&O,initialSelection:g?.initialSelection,zoom:m?.getZoom()??1,cellSize:k,onDirtyChange:e=>h?.setDirty(e),onModeChange:e=>h?.setMode(e),onCommit:S,onCancel:w,onNaturalSize:y},M=typeof i==`function`?(T?i(T):void 0)??`transparent`:i;return(0,c.jsx)(ye,{onKeyDown:b,onDoubleClick:x,children:E?(0,c.jsx)(q,{...p,className:C(d,`editor`),bounds:E,alignWidth:o,keepMounted:!0,style:{...f,display:`flex`,overflow:`hidden`,background:M,borderColor:a,boxShadow:A?`rgba(60,64,67,.35) 2px 2px 6px 3px`:`none`,opacity:+!!A,pointerEvents:A?`auto`:`none`},children:n?n(j):(0,c.jsx)(_i,{...j})}):null})},exports.FillHandle=sr,exports.GRID_SURFACE=Ji,exports.Grid=Oi,exports.GridFloatPanel=fn,exports.GridSurface=H,exports.GridlineLayer=Dr,exports.HEADER_SURFACE=Yi,exports.HeaderDividerAnchor=Ci,exports.HoverTipLayer=xn,exports.Layer=ye,exports.LineSVG=g,exports.List=Bi,exports.ListSearch=qi,exports.ListSurface=zi,exports.NO_DRAG_MODIFIERS=Fn,exports.PICKER_COLORS=ri,exports.PickList=Gi,exports.RESIZE_ANCHORS_4=tr,exports.RESIZE_ANCHORS_8=nr,exports.RangeFloatLayer=bn,exports.RangeInsertBar=Mn,exports.RangePrompt=kn,exports.RangeRect=jn,exports.RangeResizer=rr,exports.RangesPickerLayer=si,exports.RectangleSVG=_,exports.SELECTION_CLIP_INSETS=-10,exports.SelectionLayer=ei,exports.SelectionTouchGrips=Wr,exports.ShapeBoundsContext=m,exports.StickyAnchor=Pe,exports.StickyFloat=ln,exports.SurfaceStateContext=oe,exports.SurfaceStateProvider=se,exports.VirtualDiv=q,exports.buildGridThemeCSS=({app:e,grid:t=Ji,header:n=Yi,layer:r=`sxl-defaults`,scope:i}={})=>{let a=e??l.defaultTheme,o=Object.fromEntries(Object.keys(n).map(e=>[e,{"color-base-100":a[e]?.[`color-base-200`],...n[e]}]));return(0,l.buildThemeCSS)({...e?{app:e}:{},surfaces:{grid:t,header:o},layer:r,scope:i})},exports.commitArgsFromKey=fi,exports.createAxis=f,exports.createDragCells=zn,exports.createHeaderSelectionPointer=Ei,exports.createSurfaceStateStore=V,exports.createWindowDragCells=Bn,exports.defaultRangeStyle=oi,exports.edgeScrollPane=Pn,exports.expandEditorBounds=mi,exports.filterByText=(e,t)=>{let n=t.trim().toLowerCase();return n?e.filter(e=>e.text.toLowerCase().includes(n)):e},exports.gridThemeVars=(e,...t)=>(0,l.themeVars)(e,Ji[e],...t),exports.headerAnchorCell=wi,exports.headerEntireEnd=(e,t,n)=>t===u.RangeAxis.Column?{rowIndex:n.rowEnd,colIndex:e.colIndex}:{rowIndex:e.rowIndex,colIndex:n.colEnd},exports.headerEntireStart=(e,t,n)=>t===u.RangeAxis.Column?{rowIndex:n.rowStart,colIndex:e.colIndex}:{rowIndex:e.rowIndex,colIndex:n.colStart},exports.headerRange=Ti,exports.headerThemeVars=(e,...t)=>(0,l.themeVars)(e,Yi[e],...t),exports.insertAt=Xn,exports.insertRange=Qn,exports.isSameDragModifiers=Ln,exports.readDragModifiers=In,exports.renderGridFloatPanel=e=>(0,c.jsx)(fn,{...e}),exports.resolveFillDestination=ar,exports.startEventFromKey=ui,exports.useDoubleClick=Un,exports.useDragCells=Vn,exports.useEditorKeymap=pi,exports.useGridFloatTheme=on,exports.useGridMetrics=p,exports.useGridPane=W,exports.useGridPaneOptional=G,exports.useHeaderSelectionPointer=(e,t)=>{let n=W(),r=(0,s.useRef)(t);r.current=t;let i=(0,s.useMemo)(()=>Ei(e,n,()=>r.current),[e,n]);return(0,s.useEffect)(()=>()=>i.dispose(),[i]),{onPointerDown:i.onPointerDown,onPointerMove:i.onPointerMove,onPointerUp:i.onPointerUp}},exports.useHoverIntent=hn,exports.useLayer=()=>({zIndex:(0,s.useContext)(ee),pane:G()}),exports.usePendingCaret=di,exports.useRangeHover=(e,t={})=>{let{open:n,setTarget:r,tipProps:i}=hn(t),a=G(),o=P(a),c=(0,s.useContext)(ee),l=R(e),[d,f]=ve(`range-hover:${c}:${l}`,null),p=(0,s.useRef)({});return p.current={pointermove:(t,n)=>{let r=t,i=(n??a)?.getCellFromPointer(r.clientX,r.clientY);f(i&&u.CoordUtils.isCellWithinRange(i,e)?l:null)},pointerleave:()=>f(null)},(0,s.useEffect)(()=>{r(d)},[d,r]),(0,s.useEffect)(()=>{if(o)return o.registerResponder({zIndex:c,getHandler:e=>p.current[e]})},[o,c]),{open:n,tipProps:i}},exports.useSelectionPointer=Ur,exports.useShapeBounds=h,exports.useSticky=()=>{let e=(0,s.useContext)(Ne);if(!e)throw Error(`useSticky must be used within a <StickyAnchor>`);return e},exports.useStickyOptional=()=>(0,s.useContext)(Ne),exports.useSurfaceState=ve,exports.useWindowDragCells=Hn,exports.vacatedByFill=or;
2
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(o,s,c)=>(c=o==null?{}:e(i(o)),((e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c,l=r(i),u=0,d=l.length;u<d;u++)c=l[u],a.call(e,c)||c===o||t(e,c,{get:(e=>i[e]).bind(null,c),enumerable:!(s=n(i,c))||s.enumerable});return e})(!s&&o&&o.__esModule?c:t(c,`default`,{value:o,enumerable:!0}),o));let s=require("react");s=o(s,1);let c=require("react/jsx-runtime"),l=require("@sheetxl/utils-react"),u=require("@sheetxl/utils"),d=require("react-dom");d=o(d,1);var f=(e,t)=>{if(typeof t==`number`){let n=t;return{getOffset:e=>e<=0?0:e*n,getIndex:t=>t<=0?0:Math.min(e,Math.floor(t/n))}}let n=t,r=[],i=-1,a=e=>e<=0?0:((e=>{if(e<=i)return;let t=i>=0?r[i]+n(i):0;for(let a=i+1;a<=e;a++)r[a]=t,t+=n(a);i=e})(e),r[e]),o=(e,t,n)=>{for(;e<=t;){let r=e+(t-e>>1);a(r)<=n?e=r+1:t=r-1}return e>0?e-1:0};return{getOffset:a,getIndex:t=>{if(t<=0||e<=0)return 0;if((i>0?r[i]:0)>t)return o(0,i,t);let s=i>0?i:0,c=1;for(;s<e&&a(s)<=t;)s+=c,c*=2;if(s>=e){let r=e-1;if(t>=a(r)+n(r))return e}return o(Math.floor(s/2),Math.min(s,e-1),t)}}},p=e=>{let t=e!=null,n=e?.rowCount??0,r=e?.columnCount??0,i=e?.getRowHeight,a=e?.getColumnWidth;return(0,s.useMemo)(()=>{if(!t)return null;let e=f(n,i??20),o=f(r,a??75);return{getColOffset:o.getOffset,getColIndex:o.getIndex,getRowOffset:e.getOffset,getRowIndex:e.getIndex}},[t,n,r,i,a])},m=(0,s.createContext)(null),h=()=>(0,s.useContext)(m),g=e=>{let{linePoints:t,bounds:n,propsPath:r,style:i,...a}=e;return n?(0,c.jsx)(`svg`,{width:`${n.width}`,height:`${n.height}`,viewBox:`0 0 ${n.width} ${n.height}`,style:{position:`absolute`,left:`${n.x}px`,top:`${n.y}px`,width:`${n.width}px`,height:`${n.height}px`,overflow:`visible`,pointerEvents:`none`,transitionTimingFunction:`linear`,transitionProperty:`left, top, width, height`,willChange:`left, top, width, height, stroke-dashoffset`,...i},...a,children:(0,c.jsx)(`path`,{d:`M ${t[0]} ${t[1]} L ${t[2]} ${t[3]}`,fill:`none`,vectorEffect:`non-scaling-stroke`,stroke:`black`,...r})}):null},_=(0,s.memo)(e=>{let{bounds:t,fill:n,stroke:r,alignWidth:i=1,disableAlign:a=!1,disableEdgeAware:o=!1,inset:u=0,hole:d,animatedStroke:f,animatedTransition:p,strokeDasharray:m,strokeDashoffset:g,propsFillPath:_,propsStrokePath:b,className:S,style:C,propsRoot:w}=e,T=h(),E=t??T;if((0,s.useEffect)(()=>{f&&x()},[f]),!E)return null;let D=l.ReactUtils.getDevicePixelRatio(),O=a?i:i/D,k,A,j,M,N,P,F;if(a)k=E.x,A=E.y,j=E.x+E.width,M=E.y+E.height;else{let e=e=>o?l.ReactUtils.snapLineCenter(e,O,D):l.ReactUtils.edgeCenter(e,`leading`,i,D),t=e=>o?l.ReactUtils.snapLineCenter(e,O,D):l.ReactUtils.edgeCenter(e,`trailing`,i,D),n=u/D;k=e(E.x+n),A=e(E.y+n),j=t(E.x+E.width-n),M=t(E.y+E.height-n)}if(d)if(a)N=d;else{let e=l.ReactUtils.snapDeviceEdge(d.x,D),t=l.ReactUtils.snapDeviceEdge(d.y,D);N={x:e,y:t,width:l.ReactUtils.snapDeviceEdge(d.x+d.width,D)-e,height:l.ReactUtils.snapDeviceEdge(d.y+d.height,D)-t}}if(f){let e={dashGap:2,speed:50,dashLength:8,gapColor:`var(--sxl-color-base-100, #fff)`,...typeof f==`object`?f:void 0},t=e.dashGap+e.dashLength;P={strokeDasharray:`${e.dashLength}px ${e.dashGap}px`,strokeDashoffset:`${t}px`,animation:`${y} ${e.speed*t}ms linear infinite`,willChange:`stroke-dashoffset`},F=e.gapColor}let I=p?`d 60ms ease-in-out`:`none`,L=null;if(n){let e=v({top:A,left:k,bottom:M,right:j});N&&(e+=` `+v({top:N.y,left:N.x,bottom:N.y+N.height,right:N.x+N.width})),L=(0,c.jsx)(`path`,{style:{d:`path("${e}")`,transition:I,fill:n,..._?.style},stroke:`none`,fillRule:`evenodd`},`fill`)}let R=null;if(r&&i){let e=v({top:A,left:k,right:j,bottom:M});R=(0,c.jsxs)(c.Fragment,{children:[F&&(0,c.jsx)(`path`,{fill:`none`,vectorEffect:`non-scaling-stroke`,strokeWidth:O,style:{d:`path("${e}")`,transition:I,stroke:F}},`stroke-under`),(0,c.jsx)(`path`,{fill:`none`,strokeDasharray:m,strokeDashoffset:g,vectorEffect:`non-scaling-stroke`,strokeWidth:O,...b,style:{d:`path("${e}")`,transition:I,stroke:r,...P,...b?.style}},`stroke`)]})}return(0,c.jsxs)(`svg`,{className:S,width:`100%`,height:`100%`,style:{position:`absolute`,left:0,top:0,pointerEvents:`none`,overflow:`visible`,willChange:f||p?`d, stroke-dashoffset`:void 0,...C},...w,children:[L,R]})});_.displayName=`RectangleSVG`;var v=(e,t=!0)=>`M ${e.left} ${e.top} L ${e.right} ${e.top} L ${e.right} ${e.bottom} L ${e.left} ${e.bottom} L ${e.left} ${e.top} ${t?`Z`:``}`,y=`sxl-marching-ants`,b=!1,x=()=>{if(b||typeof document>`u`)return;b=!0;let e=document.createElement(`style`);e.appendChild(document.createTextNode(`@keyframes ${y} { to { stroke-dashoffset: 0; } }`)),document.head.appendChild(e)};function S(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=S(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function C(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=S(e))&&(r&&(r+=` `),r+=t);return r}var w=(e,t,n)=>Math.min(n,Math.max(t,e)),T=(e,t,n)=>{let r=[],i=t;for(;i<=n;){let t=e?Math.max(0,e(i)):0;t===0?(r.push(i),i++):i+=t}return r},E=(e,t,n,r,i,a)=>{if(n-t>=i-r)return r;let o=r;return e===`nearest`&&(r-t>0?e=`start`:n-i>0&&(e=`end`)),e===`start`?o=t:e===`end`?o=n-(i-r):e===`center`&&(o=t+(n-t)/2-(i-r)/2),o<r?Math.max(0,o):o>r?Math.min(o,a-(i-r)):void 0},D=(e,t=!1,n,r)=>{if(!n)return 0;let i=!t,a=i?1:-1,o=n(i?e:e+1),s=n(i?e+1:e),c=e+(i?2:-1),l=0;for(;(s-o)*a<=0;){if(i&&c-1>r+1||!i&&c+1<r)return l;o=s,s=n(c),c+=a,l++}return l},O=(e,t,n)=>{if(!n)return!1;let r=n.x;if(e<r||e>r+n.width)return!1;let i=n.y;return!(t<i||t>i+n.height)},k=`_grid-stage_rzp9d_1`,A={pointerdown:`onPointerDown`,pointermove:`onPointerMove`,pointerup:`onPointerUp`,mousedown:`onMouseDown`,mousemove:`onMouseMove`,mouseup:`onMouseUp`,mouseover:`onMouseOver`,mouseout:`onMouseOut`,dblclick:`onDoubleClick`,contextmenu:`onContextMenu`},j=Object.values(A),M=[...Object.keys(A),`keydown`,`keypress`,`keyup`],N=new Set(M),P=e=>{let t=e?.getElement();return t&&typeof t.isStage==`function`&&t.isStage()?t:null},F=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{className:n,onFocus:r,onBlur:i,children:a,...o}=e,u=W(),d=(0,s.useRef)(u);d.current=u;let f=(0,s.useRef)(new Set),p=(0,s.useRef)(0),m=(0,s.useCallback)(e=>{let t={responder:e,seq:p.current++};return f.current.add(t),()=>{f.current.delete(t)}},[]),h=(0,s.useRef)(new Set),g=(0,s.useRef)(0),_=(0,s.useCallback)(e=>(h.current.add(e),e.hasHandlers&&g.current++,()=>{h.current.delete(e),e.hasHandlers&&g.current--}),[]),v=(0,s.useRef)(null),y=(0,s.useRef)(0),b=(0,s.useCallback)((e,t)=>{let n=v.current;if(n&&n.x===e&&n.y===t)return n.stack;let r=document.elementsFromPoint(e,t);return v.current={x:e,y:t,stack:r},y.current||typeof requestAnimationFrame!=`function`||(y.current=requestAnimationFrame(()=>{y.current=0,v.current=null})),r},[]);(0,s.useEffect)(()=>()=>{y.current&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(y.current)},[]);let x=(0,s.useCallback)((e,t,n)=>{if(!t&&!n)return()=>{};let r=(e,r)=>{t?.(e),n?.(e,r)};return m({getHandler:t=>t===e?r:void 0})},[m]),S=(0,s.useCallback)(e=>{if(!e||e===ce.current)return-1/0;let t=new Map;if(f.current.forEach(e=>{let n=e.responder.getElement?.();n&&t.set(n,e.responder.zIndex??0)}),t.size===0)return-1/0;let n=e;for(;n;){let e=t.get(n);if(e!==void 0)return e;if(n===ce.current)break;n=n.parentElement}return-1/0},[]),w=(0,s.useCallback)((e,t,n)=>{if(A[e]===void 0||g.current===0)return I;let r=t.nativeEvent;if(typeof r?.clientX!=`number`||typeof r?.clientY!=`number`)return I;let i=new Map;if(h.current.forEach(e=>{if(!e.hasHandlers||!e.getHandler)return;let t=e.getElement();t&&i.set(t,e)}),i.size===0)return I;let a=e=>{let t=e;for(;t;){if(i.has(t))return t;if(t===ce.current)break;t=t.parentElement}return null},o=a(t.target),s=e===`pointermove`||e===`mousemove`,c=s?b(r.clientX,r.clientY):document.elementsFromPoint(r.clientX,r.clientY),l=[],u=new Set;for(let e=0;e<c.length;e++){let t=a(c[e]);if(!t||u.has(t)||(u.add(t),t===o))continue;let r=i.get(t),s=r.zIndex??0;s>=n||l.push({slot:s,box:!0,ord:e,getHandler:r.getHandler})}return o&&!u.has(o)&&s?I:l},[b]),T=(0,s.useCallback)((e,t,n)=>{let r=ce.current;if(r&&t.target instanceof Node&&!r.contains(t.target))return;let i=N.has(e)?S(t.target):1/0,a=[...w(e,t,i)];if(f.current.forEach(e=>{let t=e.responder.zIndex??0;t>=i||a.push({slot:t,box:!1,ord:-e.seq,getHandler:t=>e.responder.getHandler(t)})}),a.length===0)return;a.sort((e,t)=>t.slot-e.slot||!e.box-+!t.box||e.ord-t.ord);let o=a.length;for(let r=0;r<o&&!t.isPropagationStopped();r++)a[r].getHandler(e)?.(t,n)},[w,S]);(0,s.useEffect)(()=>{let e=ce.current;if(!e)return;let t=t=>{let n=t.type,r=S(t.target),i=[];if(f.current.forEach(e=>{(e.responder.zIndex??0)>r&&i.push(e)}),i.length===0)return;i.sort((e,t)=>(t.responder.zIndex??0)-(e.responder.zIndex??0)||t.seq-e.seq);let a=L(t,e);for(let e=0;e<i.length&&!a.isPropagationStopped();e++)i[e].responder.getHandler(n)?.(a,d.current)};for(let n=0;n<M.length;n++)e.addEventListener(M[n],t,!0);return()=>{for(let n=0;n<M.length;n++)e.removeEventListener(M[n],t,!0)}},[S]);let E=(0,l.useCallbackRef)(e=>{T(`pointerdown`,e,d.current)},[]),D=(0,l.useCallbackRef)(e=>{T(`pointermove`,e,d.current)},[]),O=(0,l.useCallbackRef)(e=>{T(`pointerup`,e,d.current)},[]),j=(0,l.useCallbackRef)(e=>{T(`pointerleave`,e,d.current)},[]),P=(0,l.useCallbackRef)(e=>{T(`mousedown`,e,d.current)},[]),F=(0,l.useCallbackRef)(e=>{T(`mouseenter`,e,d.current)},[]),R=(0,l.useCallbackRef)(e=>{T(`mouseleave`,e,d.current)},[]),ee=(0,l.useCallbackRef)(e=>{T(`mousemove`,e,d.current)},[]),te=(0,l.useCallbackRef)(e=>{T(`mouseout`,e,d.current)},[]),ne=(0,l.useCallbackRef)(e=>{T(`mouseover`,e,d.current)},[]),re=(0,l.useCallbackRef)(e=>{T(`mouseup`,e,d.current)},[]),z=(0,l.useCallbackRef)(e=>{T(`dblclick`,e,d.current)},[]),ie=(0,l.useCallbackRef)(e=>{T(`keydown`,e,d.current)},[]),B=(0,l.useCallbackRef)(e=>{T(`keypress`,e,d.current)},[]),ae=(0,l.useCallbackRef)(e=>{T(`keyup`,e,d.current)},[]),V=(0,l.useCallbackRef)(e=>{r?.(e),T(`focus`,e,d.current)},[r]),oe=(0,l.useCallbackRef)(e=>{i?.(e),T(`blur`,e,d.current)},[i]),se=(0,l.useCallbackRef)(e=>{T(`contextmenu`,e,d.current)},[]),ce=(0,l.useImperativeElement)(t,()=>({isStage:()=>!0,addReactEventListener:x,registerResponder:m,registerLayer:_}),[]);return(0,s.useEffect)(()=>_({getElement:()=>ce.current}),[_]),(0,c.jsx)(`div`,{className:C(n,`stage`,k),ref:ce,tabIndex:0,...o,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerLeave:j,onMouseDown:P,onMouseEnter:F,onMouseLeave:R,onMouseMove:ee,onMouseOut:te,onMouseOver:ne,onMouseUp:re,onDoubleClick:z,onKeyDown:ie,onKeyUp:ae,onKeyPress:B,onFocus:V,onBlur:oe,onContextMenu:se,children:a})}));F.displayName=`Stage`;var I=Object.freeze([]),L=(e,t)=>{let n=!1;return new Proxy(e,{get(r,i){switch(i){case`nativeEvent`:return e;case`currentTarget`:return t;case`stopPropagation`:return()=>{n=!0,e.stopPropagation()};case`isPropagationStopped`:return()=>n;case`preventDefault`:return()=>e.preventDefault();case`isDefaultPrevented`:return()=>e.defaultPrevented;case`persist`:return()=>{};default:{let e=r[i];return typeof e==`function`?e.bind(r):e}}}})},R=e=>`${e.rowStart},${e.colStart},${e.rowEnd},${e.colEnd}`,ee=(0,s.createContext)(0),te=(0,s.createContext)(!1),ne=(e,t)=>{let{rowDims:n,columnDims:r,computeRowDims:i,computeColumnDims:a,viewport:o,zoom:s,containerWidth:c,containerHeight:l,getRangeFromCell:u,invalidate:d,totalRange:f,getSurfacePointFromPointer:p,scrollTo:m,scrollCellCoordsIntoView:h,getAllPanes:g}=t,_=e.anchor,v=n[e.rowIndex],y=r[e.columnIndex];if(v.minIndex>v.maxIndex||y.minIndex>y.maxIndex)return null;let b=e.scrollOrientation,x=Object.freeze({x:y.minBounds,y:v.minBounds,width:y.maxBounds,height:v.maxBounds}),S=Object.freeze({colStart:y.minCoord,rowStart:v.minCoord,colEnd:y.maxCoord,rowEnd:v.maxCoord}),C={width:y.maxVirtualBounds,height:v.maxVirtualBounds},w={left:y.freezeOffset,top:v.freezeOffset},T={width:c,height:l},E=null,D=null,k=()=>{let t=o.getSnapshot();if(D&&E===t)return D;let n=a(t.left)[e.columnIndex],r=i(t.top)[e.rowIndex],c=n.metrics,l=r.metrics,u=Object.freeze({rowStart:r.minIndex,colStart:n.minIndex,rowEnd:r.maxIndex,colEnd:n.maxIndex}),d=Object.freeze({getColIndex:e=>c.getColIndex(e),getColOffset:e=>c.getColOffset(e),getRowIndex:e=>l.getRowIndex(e),getRowOffset:e=>l.getRowOffset(e)}),f={left:n.scrollOffset,top:r.scrollOffset};return D={cellRange:u,metrics:d,scrollTopLeft:f,topLeft:{top:(w.top+(b.vertical?f.top:0))/s,left:(w.left+(b.horizontal?f.left:0))/s},colDims:n,rowDims:r},E=t,D},A=(e,t)=>{let n=k();return((e,t,n)=>{let r=e.getColOffset(t.colStart)+(n?.left??0),i=e.getRowOffset(t.rowStart)+(n?.top??0);return{x:r,y:i,width:e.getColOffset(t.colEnd+1)+(n?.right??0)-(n?.left??0)-r,height:e.getRowOffset(t.rowEnd+1)+(n?.bottom??0)-(n?.top??0)-i}})(n.metrics,e??n.cellRange,t)},j=e=>{if(e<0)return null;let t=k().colDims.metrics,n=t.getColOffset(e);return{index:e,offset:n,size:t.getColOffset(e+1)-n}},M=e=>{if(e<0)return null;let t=k().rowDims.metrics,n=t.getRowOffset(e);return{index:e,offset:n,size:t.getRowOffset(e+1)-n}},N=(e,t)=>{let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=t(e[r]);return n};return{addReactEventListener:(t,n,r)=>{let i=e.refStage;return i?i.addReactEventListener(t,n,r):()=>{}},getElement:()=>e.refStage,invalidate:d,focus(t){let n=e.refStage;n&&n.focus(t)},setPointerCapture:t=>{let n=e.refStage;n&&n.setPointerCapture(t)},releasePointerCapture(t){let n=e.refStage;n&&n.releasePointerCapture(t)},getVisibleRange:()=>k().cellRange,toClipBounds:(e,t)=>{let n,r=0;return t===void 0||typeof t==`number`?(n=A(k().cellRange),r=t):n=t,((e,t,n=0)=>{let r=e.x,i=e.y;if(r>t.width||i>t.height)return null;let a={left:r,top:i,bottom:e.height+i,right:e.width+r},o={left:t.x+n,top:t.y+n,bottom:t.height-2*n+t.y,right:t.width-2*n+t.x},s={left:Math.max(a.left,o.left),top:Math.max(a.top,o.top),bottom:Math.min(a.bottom,o.bottom),right:Math.min(a.right,o.right)},c={x:s.left,y:s.top,width:s.right-s.left,height:s.bottom-s.top};return c.height<0||c.width<0?null:c})(e??{x:0,y:0,width:x.width,height:x.height},n,r)},toPaneBounds:e=>{let t=k().topLeft;return t.left===0&&t.top===0&&s===1?e:{x:(e.x-t.left)*s,y:(e.y-t.top)*s,width:e.width*s,height:e.height*s}},toAbsoluteBounds:e=>{let t=k().topLeft;return t.left===0&&t.top===0&&s===1?e:{x:e.x/s+t.left,y:e.y/s+t.top,width:e.width/s,height:e.height/s}},getPanePointFromPointer:(e,t)=>{let n=p(e,t);return n?{x:n.x-x.x,y:n.y-x.y}:null},getMetrics:()=>k().metrics,getRangeFromCell:u,getVisibleColumns:(e,t)=>N(k().colDims.visibleIndices(e,t),j),getVisibleRows:(e,t)=>N(k().rowDims.visibleIndices(e,t),M),getColumnSize:j,getRowSize:M,getTotalRange:()=>f,getBoundsFromRange:A,getCellFromPointer:(e,t,n=!1)=>{let r=p(e,t);if(!r)return null;let i=k().metrics,a=i.getColIndex(r.x-x.x),o={rowIndex:i.getRowIndex(r.y-x.y),colIndex:a};if(n)return o;let s=u(o);return{rowIndex:s.rowStart,colIndex:s.colStart}},getPaneFromPointer:(e,t)=>{let n=p(e,t);if(!n)return null;let r=g();for(let e=0;e<re.length;e++){let t=r[re[e]];if(t&&O(n.x,n.y,t.getPaneBounds()))return t}return null},getZoom:()=>s,getAnchor:()=>_,getPaneRange:()=>S,getPaneBounds:()=>x,getInsets:()=>e.insets,getTotalSize:()=>C,getSurfaceSize:()=>T,getScrollTopLeft:()=>k().scrollTopLeft,getScrollTarget:()=>{let e=k().scrollTopLeft,t=o.getSnapshot(),n=o.getTarget();return{left:e.left+(b.horizontal?n.left-t.left:0),top:e.top+(b.vertical?n.top-t.top:0)}},getFreezeTopLeft:()=>w,getScrollOrientation:()=>b,scrollCellCoordsIntoView:(e,t)=>h(e,t,_),scrollTo:e=>m(e),getAllPanes:g}},re=[u.AnchorLocation.TopLeft,u.AnchorLocation.Top,u.AnchorLocation.Left,u.AnchorLocation.Center],z=(e,t,n)=>{let r=(t?.left??0)+(n?.x??0),i=(t?.top??0)+(n?.y??0);return{getColOffset:t=>e.getColOffset(t)-r,getColIndex:t=>e.getColIndex(t+r),getRowOffset:t=>e.getRowOffset(t)-i,getRowIndex:t=>e.getRowIndex(t+i)}},ie=Object.freeze([{minIndex:0,maxIndex:0,minCoord:0,maxCoord:0,visibleIndices:()=>u.CommonUtils.EmptyArray,minBounds:0,maxBounds:0,metrics:{getColOffset:()=>0,getColIndex:()=>0,getRowOffset:()=>0,getRowIndex:()=>0},maxVirtualBounds:0,scrollOffset:0,freezeOffset:0}]),B=(0,s.createContext)(null),ae=({pane:e,viewport:t,children:n})=>{let r=(0,s.useMemo)(()=>({pane:e}),[e,(0,l.useOptionalBoundSyncExternalStore)(t,e=>e.getSnapshot())]);return(0,c.jsx)(B.Provider,{value:r,children:n})},V=()=>{let e=new Map,t=new Map;return{has:t=>e.has(t),get:t=>e.get(t),set(n,r){if(e.has(n)&&Object.is(e.get(n),r))return;e.set(n,r);let i=t.get(n);if(i)for(let e of[...i])e()},subscribe(e,n){let r=t.get(e);return r||t.set(e,r=new Set),r.add(n),()=>{r.delete(n),r.size===0&&t.delete(e)}}}},oe=(0,s.createContext)(null),se=({store:e,children:t})=>{let n=(0,s.useContext)(oe),r=(0,s.useRef)(null),i=e??n;return i||=(r.current||=V(),r.current),(0,c.jsx)(oe.Provider,{value:i,children:t})},ce={"sheetxl-grid":`_sheetxl-grid_5yo0n_7`},H=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{rowCount:n=1,columnCount:r=1,viewport:i,metrics:a,getRangeFromCell:o=u.CoordUtils.cellToRange,hiddenRowsAt:d,hiddenColumnsAt:f,freezeLeft:p=0,freezeTop:m=0,propsFreezeLeft:h,propsFreezeTop:_,onFirstRender:v,children:y,wrapPane:b,onFocus:x,onBlur:S,className:w,style:k,...A}=e,j=(0,l.useCallbackRef)(x,[x]),M=(0,l.useCallbackRef)(S,[S]),N=(0,l.useCallbackRef)(v,[v]),[P,I]=(0,s.useState)(u.AnchorLocation.Center),[L,R]=(0,s.useReducer)(e=>e+1,0),re=(0,s.useMemo)(()=>new l.Viewport({}),[]),B=i??re,[V,oe]=(0,s.useState)(()=>{let e=B.getClient();return{zoom:B.getZoom(),w:e.width,h:e.height,ready:B.isReady()}});(0,s.useEffect)(()=>{let e=()=>oe(e=>{let t=B.getClient(),n={zoom:B.getZoom(),w:t.width,h:t.height,ready:B.isReady()};return e.zoom===n.zoom&&e.w===n.w&&e.h===n.h&&e.ready===n.ready?e:n});return e(),B.subscribe(e)},[B]);let H=V.zoom,W=(0,s.useMemo)(()=>{let e=a??le;return{getColOffset:t=>e.getColOffset(t)*H,getColIndex:t=>e.getColIndex(t/H),getRowOffset:t=>e.getRowOffset(t)*H,getRowIndex:t=>e.getRowIndex(t/H)}},[a,H]),G=(0,l.useCallbackRef)((e,t=!1)=>D(e,t,W.getRowOffset,t?0:n),[n,W?.getRowOffset]),ve=(0,l.useCallbackRef)(d??G,[d]),ye=(0,l.useCallbackRef)((e,t=!1)=>D(e,t,W.getColOffset,t?r:0),[r,W?.getColOffset]),K=(0,l.useCallbackRef)(f??ye,[f]),be=(0,s.useCallback)(()=>{R()},[]),xe=(0,s.useMemo)(()=>Math.min(V.w,W.getColOffset(r)),[L,W.getColOffset,r,V.w]),Se=(0,s.useMemo)(()=>Math.min(V.h,W.getRowOffset(n)),[L,W.getRowOffset,n,V.h]),q=(0,s.useMemo)(()=>{let e=NaN,t=null;return r=>(r===e&&t||(e=r,t=(e=>{if(Se===0)return ie;let t=[],r=0,i=0;typeof m==`number`?r=m:(r=m.index??0,i=(m.offset??0)*H);let a=i,o=W.getRowOffset(r),s=o-a;if(r>0){let e=z(W,{top:i+W.getRowOffset(0)}),n=W.getRowIndex(a),c=W.getRowIndex(o-1),l;t[1]={minIndex:n,maxIndex:c,minCoord:0,maxCoord:r-1,minBounds:0,maxBounds:s,visibleIndices:(e,t)=>e!==void 0&&t!==void 0?T(ve,e,t):l||(l=Object.freeze(T(ve,n,c)),l),metrics:e,maxVirtualBounds:o,scrollOffset:i,freezeOffset:i}}let c=Math.max(0,Se-s),l=z(W,{top:e+s}),u=l.getRowIndex(0),d=l.getRowIndex(c-1),f;return t[0]={minIndex:u,maxIndex:d,minCoord:r,maxCoord:n-1,minBounds:s,maxBounds:c,visibleIndices:(e,t)=>e!==void 0&&t!==void 0?T(ve,e,t):f||(f=Object.freeze(T(ve,u,d)),f),metrics:l,maxVirtualBounds:W.getRowOffset(n),scrollOffset:e,freezeOffset:(r>0?W.getRowOffset(r):0)-i},t})(r)),t)},[L,W.getRowIndex,W.getRowOffset,ve,Se,n,m,H]),J=(0,s.useMemo)(()=>q(0),[q]),Y=(0,s.useMemo)(()=>{let e=NaN,t=null;return n=>(n===e&&t||(e=n,t=(e=>{if(xe===0)return ie;let t=[],n=0,i=0;typeof p==`number`?n=p:(n=p.index??0,i=(p.offset??0)*H);let a=i,o=W.getColOffset(n),s=o-a;if(n>0){let e=z(W,{left:i+W.getColOffset(0)}),r=W.getColIndex(a),c=W.getColIndex(o-1),l;t[1]={minIndex:r,maxIndex:c,minCoord:0,maxCoord:n-1,minBounds:0,maxBounds:s,visibleIndices:(e,t)=>e!==void 0&&t!==void 0?T(K,e,t):l||(l=Object.freeze(T(K,r,c)),l),metrics:e,maxVirtualBounds:o,scrollOffset:i,freezeOffset:i}}let c=Math.max(0,xe-s),l=z(W,{left:e+s}),u=l.getColIndex(0),d=l.getColIndex(c-1),f;return t[0]={minIndex:u,maxIndex:d,minCoord:n,maxCoord:r-1,minBounds:s,maxBounds:c,visibleIndices:(e,t)=>e!==void 0&&t!==void 0?T(K,e,t):f||(f=Object.freeze(T(K,u,d)),f),metrics:l,maxVirtualBounds:W.getColOffset(r),scrollOffset:e,freezeOffset:(n>0?W.getColOffset(n):0)-i},t})(n)),t)},[L,W.getColIndex,W.getColOffset,K,xe,r,p,H]),X=(0,s.useMemo)(()=>Y(0),[Y]),Ce=(0,s.useRef)([]),[we,Te]=(0,s.useReducer)(e=>e+1,0),Ee=J.length,De=X.length,Oe=(0,s.useMemo)(()=>{let e=[],t=(t,n,r,i,a)=>{if(t>=De||n>=Ee)return null;let o={anchor:r,columnIndex:t,rowIndex:n,elemStage:null,refStage:null,scrollOrientation:{vertical:i?.vertical||!1,horizontal:i?.horizontal||!1},insets:Object.freeze({left:a?.left??0,top:a?.top??0,right:a?.right??0,bottom:a?.bottom??0})};o.elemStage=(0,c.jsx)(F,{ref:e=>{e?(o.refStage=e,Te()):o.refStage=null},className:`stage stage-${r}`,onFocus:e=>{I(r),j(e)},onBlur:e=>{M(e)}}),e.push(o)};return t(0,0,u.AnchorLocation.Center,me,pe),t(0,1,u.AnchorLocation.Top,he),t(1,0,u.AnchorLocation.Left,ge),t(1,1,u.AnchorLocation.TopLeft,U),e},[Ee,De]),Z=(0,s.useMemo)(()=>{let e={},t={colStart:0,rowStart:0,colEnd:r-1,rowEnd:n-1},i=n=>ne(n,{rowDims:J,columnDims:X,computeRowDims:q,computeColumnDims:Y,viewport:B,zoom:H,containerWidth:xe,containerHeight:Se,getRangeFromCell:o,invalidate:be,totalRange:t,getSurfacePointFromPointer:(e,t)=>Pe(e,t),scrollTo:e=>Be(e),scrollCellCoordsIntoView:(e,t,n)=>ze(e,t,n),getAllPanes:()=>e}),a=Oe.length;for(let t=0;t<a;t++){let n=Oe[t];e[n.anchor]=i(n)}return e=Object.freeze(e),e},[Oe,J,X,q,Y,B,o,we]),ke=X[0]?.maxVirtualBounds??0,Ae=J[0]?.maxVirtualBounds??0,je=V.ready,Me=(0,s.useMemo)(()=>{let e=X[1],t=J[1];return{left:e?e.metrics.getColOffset(e.maxIndex+1):0,top:t?t.metrics.getRowOffset(t.maxIndex+1):0}},[J,X]),Ne=(0,l.useCallbackRef)(e=>{u.DOMUtils.canUseDOM&&setTimeout(()=>{(Z[P]?.getElement()??Z[u.AnchorLocation.Center]?.getElement())?.focus({preventScroll:!0,...e})},0)},[P,Z]);(0,s.useEffect)(()=>{let e=Ce.current,t=e.length;if(t>0){for(let n=0;n<t;n++)e[n]();Ce.current=[]}},[Z]);let Pe=(0,s.useCallback)((e,t)=>{(function(e){if(!e)throw Error(`Invariant failed`)})(typeof e==`number`&&typeof t==`number`);let n=Ve.current?.getBoundingClientRect();return n?{x:e-n.x,y:t-n.y}:{x:e,y:t}},[]),Fe=(0,l.useCallbackRef)((e,t)=>{if(Object.keys(Z).length===1)return Z[u.AnchorLocation.Center];let n=Pe(e,t);if(!n)return Z[u.AnchorLocation.Center];let{x:r,y:i}=n,a=null,o=_e,s=o.length;for(let e=0;!a&&e<s;e++){let t=Z[o[e]];t&&O(r,i,t.getPaneBounds())&&(a=t)}return a||=Z[u.AnchorLocation.Center],a},[Z,o]);(0,s.useEffect)(()=>{let e=X?.[1]?.scrollOffset??0,t=J?.[1]?.scrollOffset??0;B.setContent(ke,Ae,e,t)},[B,ke,Ae,X,J]);let Ie=(0,l.useCallbackRef)(e=>{let t=e?.left??e?.[0],n=e?.top??e?.[1];if(t===void 0&&n===void 0)return;let r=e?.behavior??`auto`,i=B.getTarget();t!==void 0&&(t=i.left+(t??0)),n!==void 0&&(n=i.top+(n??0)),i.left===t&&i.top===n||Be({left:t,top:n,behavior:r})},[]),Le=(0,l.useCallbackRef)(e=>e===void 0?Z[P]??Z[u.AnchorLocation.Center]??null:Z[e]??null,[Z,P]),Re=(0,l.useCallbackRef)(e=>{let t=Z[P];if(!t)return Z[u.AnchorLocation.Center];let n=t.getScrollOrientation(),r={...t.getVisibleRange()};return n.vertical&&(r.rowStart=J[0].minCoord,r.rowEnd=J[0].maxCoord),n.horizontal&&(r.colStart=X[0].minCoord,r.colEnd=X[0].maxCoord),n&&u.CoordUtils.isCellWithinRange(e,r)?t:Z[u.AnchorLocation.Center]},[Z,P]),ze=(0,l.useCallbackRef)((e,t={inline:`nearest`,block:`nearest`},n=null)=>{let r={rowIndex:0,colIndex:0,...e},i=null;if(n!==null){if(i=Z[n],!i)return new Promise((e,t)=>{t(`Invalid view`)})}else i=Re(r);let a=o(r),s=i.getMetrics(),c=s.getColOffset(a.colStart),l=s.getRowOffset(a.rowStart),u=s.getColOffset(a.colEnd+1),d=s.getRowOffset(a.rowEnd+1),f=i.getPaneBounds(),p=i.getTotalSize(),m=i.getScrollTopLeft(),h=((e,t,n=!0)=>{n=!0===n?{block:`start`,inline:`end`}:!1===n?{block:`end`,inline:`end`}:{block:`end`,inline:`end`,...n};let r=E(n.inline??`end`,e.x,e.x+e.width,t.left,t.left+t.width,t.totalWidth),i=E(n.block??`end`,e.y,e.y+e.height,t.top,t.top+t.height,t.totalHeight);if(r!==void 0||i!==void 0)return{left:r??t.left,top:i??t.top}})({x:c+m.left,y:l+m.top,width:u-c,height:d-l},{left:m.left,top:m.top,width:f.width,height:f.height,totalWidth:p.width,totalHeight:p.height},t);if(!h)return Promise.resolve({...m});let g={...h},{left:_,top:v}=B.getScroll();g.left!==void 0&&(g.left>_?g.left+=de:g.left<_&&(g.left-=ue)),g.top!==void 0&&(g.top>v?g.top+=de:g.top<v&&(g.top-=ue));let y=i.getScrollOrientation();y.horizontal&&e.colIndex!==void 0||delete g.left,y.vertical&&e.rowIndex!==void 0||delete g.top;let b=g.left===void 0?0:Math.abs(g.left-_),x=g.top===void 0?0:Math.abs(g.top-v),S=(typeof t==`object`?t?.behavior:void 0)??(Math.max(b,x)<fe||!B.isSettled()?`instant`:`smooth`);return new Promise((e,t)=>{try{Be({...g,behavior:S}),e(g)}catch(e){t(e)}})},[ke,Ae,Z,o]),Be=(0,l.useCallbackRef)(e=>{let t=e?.left??e?.[0],n=e?.top??e?.[1],r=B.getTarget(),i=t??r.left,a=n??r.top,o=e?.behavior===`smooth`;B.setTarget(i,a,o)},[]),Ve=(0,l.useImperativeElement)(t,()=>({focus:Ne,invalidate:be,scrollTo:Be,scrollBy:Ie,scrollCellCoordsIntoView:ze,getPaneFromClient:Fe,getPaneFromCell:Re,getPane:Le,onPaneChangeOnce:e=>{Ce.current.push(e)}}),[Z]);(0,s.useEffect)(()=>B.observe(Ve.current),[B]);let He=(e,t)=>{let n=(e=>{if(!e)return null;if(!Array.isArray(e))return e;let t=e=>(0,s.isValidElement)(e)&&e.props?.zIndex!=null?e.props.zIndex:0;return[...e].sort((e,n)=>t(e)-t(n)).map((e,t)=>(0,s.isValidElement)(e)?(0,s.createElement)(ee.Provider,{key:e.key??`layer-${t}`,value:t},e):e)})(t);return n?(0,c.jsx)(te.Provider,{value:!1,children:(0,c.jsx)(ae,{pane:e,viewport:B,children:b?b(e,n):n})}):null},Ue=(0,s.useMemo)(()=>{let e={},t=Object.keys(Z),n=t.length;for(let r=0;r<n;r++){let n=t[r];e[n]=He(Z[n],y)}return e},[L,y,Z,b,n,r]),We=(0,s.useMemo)(()=>Me.left===0?null:(0,c.jsx)(g,{linePoints:[0,0,0,Se+1],bounds:{x:Me.left,y:0,width:1,height:Se+1},...h}),[L,Me.left,Se,h]),Ge=(0,s.useMemo)(()=>Me.top===0?null:(0,c.jsx)(g,{linePoints:[0,0,xe+1,0],bounds:{x:0,y:Me.top,width:xe+1,height:1},..._}),[L,Me.top,xe,_]),Ke=(0,s.useRef)(!1),qe=(0,s.useMemo)(()=>{if(!je)return null;let e=(e,t)=>{let n=e.anchor,r=t.getPaneBounds(),i=Me.left>0,a=Me.top>0,o=a&&(n===u.AnchorLocation.Center||n===u.AnchorLocation.Left),l=a&&(n===u.AnchorLocation.Top||n===u.AnchorLocation.TopLeft),d=i&&(n===u.AnchorLocation.Center||n===u.AnchorLocation.Top),f=i&&(n===u.AnchorLocation.Left||n===u.AnchorLocation.TopLeft),p=1e6,m=o?-1:-1e6,h=d?-1:-1e6,g=f?r.width+2:p,_=l?r.height+2:p,v=o||l||d||f,y={position:`absolute`,left:r.x,top:r.y,width:r.width,height:r.height,clip:v?`rect(${m}px, ${g}px, ${_}px, ${h}px)`:void 0};return(0,c.jsx)(ae,{pane:t,viewport:B,children:e.elemStage?(0,s.cloneElement)(e.elemStage,{style:y},Ue?.[n]):null},`pane:${n}`)},t=Oe.length,n=Array(t);for(let r=0;r<t;r++){let t=Oe[r],i=t.anchor,a=Z[i];n[r]=a?e(t,a):null}return(0,c.jsxs)(c.Fragment,{children:[n,We,Ge]})},[Z,Oe,Ue,xe,Se,je,Me]);return(0,s.useEffect)(()=>{!Ke.current&&qe&&je&&(Ke.current=!0,N?.(Ve.current))},[qe,je]),(0,c.jsx)(`div`,{ref:Ve,className:C(w,`grid-surface`,ce[`sheetxl-grid`]),style:{overflow:`hidden`,...k},...A,children:(0,c.jsx)(se,{children:qe})})}));H.displayName=`GridSurface`;var le=Object.freeze({getColOffset:e=>75*e,getColIndex:e=>Math.floor(e/75),getRowOffset:e=>20*e,getRowIndex:e=>Math.floor(e/20)}),ue=0,de=20,fe=150,pe=Object.freeze({bottom:-4,right:-4}),me=Object.freeze({horizontal:!0,vertical:!0}),he=Object.freeze({horizontal:!0,vertical:!1}),ge=Object.freeze({horizontal:!1,vertical:!0}),U=Object.freeze({horizontal:!1,vertical:!1}),_e=[u.AnchorLocation.TopLeft,u.AnchorLocation.Top,u.AnchorLocation.Left,u.AnchorLocation.Center];function W(){let e=(0,s.useContext)(B);if(!e)throw Error(`useGridPane must be used within a GridPaneProvider`);return e.pane}function G(){return(0,s.useContext)(B)?.pane??null}function ve(e,t){let n=(0,s.useContext)(oe),r=(0,s.useRef)(null);r.current||=V();let i=n??r.current,a=`k:${e}`,o=(0,s.useRef)(null);o.current===null&&(o.current={v:typeof t==`function`?t():t});let c=(0,s.useCallback)(()=>i.has(a)?i.get(a):o.current.v,[i,a]);return[(0,s.useSyncExternalStore)((0,s.useCallback)(e=>i.subscribe(a,e),[i,a]),c,c),(0,s.useCallback)(e=>{let t=i.has(a)?i.get(a):o.current.v;i.set(a,typeof e==`function`?e(t):e)},[i,a])]}var ye=(0,s.memo)(e=>{let{onPointerDown:t,onPointerMove:n,onPointerUp:r,onPointerLeave:i,onMouseDown:a,onMouseEnter:o,onMouseLeave:l,onMouseMove:u,onMouseOut:d,onMouseOver:f,onMouseUp:p,onDoubleClick:m,onKeyDown:h,onKeyPress:g,onKeyUp:_,onFocus:v,onBlur:y,onContextMenu:b,zIndex:x,className:S,children:C}=e,w=(0,s.useContext)(te);(0,s.useEffect)(()=>{w&&!be&&(be=!0,console.error(`<Layer> nested inside another <Layer>. Layers exist only as direct children of the grid (law 4: the stack is flat) — a composite renders exactly one Layer at its root. For a full-view container inside a layer, use <VirtualDiv fill>. This error fires once.`))},[w]);let T=P(G()),E=(0,s.useContext)(ee),D=(0,s.useRef)({});D.current={pointerdown:K(t),pointermove:K(n),pointerup:K(r),pointerleave:K(i),mousedown:K(a),mouseenter:K(o),mouseleave:K(l),mousemove:K(u),mouseout:K(d),mouseover:K(f),mouseup:K(p),dblclick:K(m),keydown:K(h),keypress:K(g),keyup:K(_),focus:K(v),blur:K(y),contextmenu:K(b)};let O=(0,s.useRef)(null);return(0,s.useEffect)(()=>{if(T)return T.registerResponder({zIndex:E,getElement:()=>O.current,getHandler:e=>D.current[e]})},[T,E]),(0,c.jsx)(`div`,{ref:O,className:S,onPointerDown:t,onPointerMove:n,onPointerUp:r,onMouseDown:a,onMouseMove:u,onMouseUp:p,onMouseOver:f,onMouseOut:d,onDoubleClick:m,onKeyDown:h,onKeyPress:g,onKeyUp:_,onContextMenu:b,children:C==null?null:(0,c.jsx)(te.Provider,{value:!0,children:C})})});ye.displayName=`Layer`;var K=e=>e?t=>e(t):void 0,be=!1,xe=!1,Se=`_virtual-div_16eab_1`,q=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{range:n,bounds:r,fill:i=!1,clipInsets:a,disableAlign:o=!1,coverGridlines:u=!1,alignWidth:d,keepMounted:f=!1,className:p,style:h,children:g,..._}=e;(0,s.useContext)(te)||J||(J=!0,console.warn(`VirtualDiv rendered outside a <Layer>. The grid's children are Layers; place VirtualDivs inside one (law 4: the stack is flat). This warning fires once.`));let v=(0,s.useRef)(null),y=(0,s.useCallback)(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]);(({getElement:e,handlerProps:t})=>{let n=P(G()),r=(0,s.useContext)(ee),i=!1;if(t){for(let e=0;e<j.length;e++)if(typeof t[j[e]]==`function`){i=!0;break}}let a=(0,s.useRef)({getElement:e,handlerProps:t});a.current={getElement:e,handlerProps:t},(0,s.useEffect)(()=>{if(n)return n.registerLayer({zIndex:r,getElement:()=>a.current.getElement(),hasHandlers:i,getHandler:i?e=>{let t=A[e];if(t===void 0)return;let n=a.current.handlerProps?.[t];return typeof n==`function`?e=>n(e):void 0}:void 0})},[n,i,r])})({getElement:()=>v.current,handlerProps:_});let b=(({range:e,bounds:t,fill:n,clipInsets:r})=>{let i=W();if(!i)return null;let a=null,o=!1;if(e)a=i.getBoundsFromRange(e),o=i.toClipBounds(a,r)===null;else if(t)o=i.toClipBounds(t,r)===null,a=t;else{if(!n)return xe||(xe=!0,console.warn(`VirtualDiv: provide exactly one of 'range' | 'bounds' | 'fill'. (The implicit "no placement = pane-sized" fallback was removed — use 'fill'.) This warning fires once.`)),null;{let e=i.getPaneBounds();a={x:0,y:0,width:e.width,height:e.height}}}return a?{pane:i,raw:a,culled:o}:null})({range:n,bounds:r,fill:i,clipInsets:a});if(!b)return null;let{raw:x,culled:S}=b;if(S&&!f)return null;let w=l.ReactUtils.getDevicePixelRatio(),T=d!=null,E=T?d/w:0,D,O,k,M;if(o)D=x.x,O=x.y,k=x.width,M=x.height;else if(T){let e=l.ReactUtils.edgeCenter(x.x,`leading`,d,w),t=l.ReactUtils.edgeCenter(x.y,`leading`,d,w);D=e-E/2,O=t-E/2,k=l.ReactUtils.edgeCenter(x.x+x.width,`trailing`,d,w)-e+E,M=l.ReactUtils.edgeCenter(x.y+x.height,`trailing`,d,w)-t+E}else{let e=u?1/w:0;D=l.ReactUtils.snapDeviceEdge(x.x,w),O=l.ReactUtils.snapDeviceEdge(x.y,w),k=l.ReactUtils.snapDeviceEdge(x.x+x.width,w)+e-D,M=l.ReactUtils.snapDeviceEdge(x.y+x.height,w)+e-O}let{transform:N,...F}=h??{},I={x:x.x-D,y:x.y-O,width:x.width,height:x.height};return(0,c.jsx)(`div`,{className:C(p,Se),style:{width:`${k}px`,height:`${M}px`,...T?{boxSizing:`border-box`,borderWidth:`${E}px`,borderStyle:`solid`}:void 0,...F,transform:`translate(${D}px, ${O}px)${N?` ${N}`:``}`},..._,ref:y,children:g==null?null:(0,c.jsx)(m.Provider,{value:I,children:g})})}));q.displayName=`VirtualDiv`;var J=!1,Y=(e,t,n,r)=>({x:e,y:t,width:n,height:r,top:t,left:e,right:e+n,bottom:t+r}),X=Y(0,0,0,0),Ce=e=>{let t=e.getElement()?.getBoundingClientRect?.();return{x:t?.left??0,y:t?.top??0}},we=e=>{let t=e.getElement()?.getBoundingClientRect?.();return t?Y(t.left,t.top,t.width,t.height):X},Te={side:`t`,align:`center`},Ee=[u.AnchorLocation.TopLeft,u.AnchorLocation.Top,u.AnchorLocation.Left,u.AnchorLocation.Center],De=new Set([u.AnchorLocation.Top,u.AnchorLocation.TopLeft]),Oe=new Set([u.AnchorLocation.Left,u.AnchorLocation.TopLeft]),Z=(e,t,n,r,i)=>{let a=null,o=null,s=1/0,c=!1;for(let l=0;l<Ee.length;l++){let u=e[Ee[l]];if(!u)continue;let d=u.getVisibleRange(),f=t===`row`?d.rowStart:d.colStart,p=t===`row`?d.rowEnd:d.colEnd;if(n>p||r<f)continue;c=!0,!a&&i>=f&&i<=p&&(a=u);let m=i<f?f-i:i>p?i-p:0;m<s&&(s=m,o=u)}return{pane:a??o,visible:c}},ke=(e,t)=>{let n=De.has(e.getAnchor()),r=Oe.has(t.getAnchor());return n&&r?u.AnchorLocation.TopLeft:n?u.AnchorLocation.Top:r?u.AnchorLocation.Left:u.AnchorLocation.Center},Ae=(e,t)=>{let n=we(e),r=e.getBoundsFromRange(t);return Y(n.left+r.x,n.top+r.y,r.width,r.height)},je=(e,t)=>{let n=(t.left+t.right)/2,r=(t.top+t.bottom)/2;return r<e.top?`t`:r>e.bottom?`b`:n<e.left?`l`:n>e.right?`r`:null},Me=(e,t,n=`data`,r=0,i=Te,a=`hide`)=>{if(!e)return{rect:X,clipped:!0,boundaryRect:X,clampedTo:null,anchorPoint:{x:0,y:0},owner:null,slid:null,outOfView:!0};let o=((e,t)=>{if(t&&typeof t==`object`){let e=t;return Y(e.x,e.y,e.width,e.height)}if(t===`viewport`){let t=e.getElement()?.ownerDocument?.documentElement;if(t)return Y(0,0,t.clientWidth,t.clientHeight)}if(t===`pane`){let t=Ce(e),n=e.getPaneBounds();return Y(t.x,t.y,n.width,n.height)}let n=e.getAllPanes(),r=1/0,i=1/0,a=-1/0,o=-1/0;for(let e of Object.keys(n)){let t=n[e]?.getElement()?.getBoundingClientRect?.();t&&(r=Math.min(r,t.left),i=Math.min(i,t.top),a=Math.max(a,t.right),o=Math.max(o,t.bottom))}if(r===1/0){let t=Ce(e),n=e.getPaneBounds();return Y(t.x,t.y,n.width,n.height)}return Y(r,i,a-r,o-i)})(e,n),s=e=>{if(r<=0)return!1;let t=(n=e,i=o,{w:Math.min(n.right,i.right)-Math.max(n.left,i.left),h:Math.min(n.bottom,i.bottom)-Math.max(n.top,i.top)});var n,i;return t.w<=r||t.h<=r};if(`point`in t){let n=Y(t.point.x,t.point.y,0,0),r=je(o,n),i=e.getPaneFromPointer(t.point.x,t.point.y);return{rect:n,clipped:r!==null,boundaryRect:o,clampedTo:r,anchorPoint:{...t.point},owner:i?.getAnchor()??null,slid:null,outOfView:!1}}if(`edge`in t){let n=Ce(e),r=e.getPaneBounds(),i=n.x+r.width/2,a=n.y+r.height/2;t.edge===`t`?a=n.y:t.edge===`b`?a=n.y+r.height:t.edge===`l`?i=n.x:t.edge===`r`&&(i=n.x+r.width);let s=e.getPaneFromPointer(i,a)??e;return{rect:Y(i,a,0,0),clipped:!1,boundaryRect:o,clampedTo:null,anchorPoint:{x:i,y:a},owner:s.getAnchor(),slid:null,outOfView:!1}}if(`bounds`in t){let n=Ce(e),r=t.bounds,a=e.toClipBounds(r,0),l=Y(n.x+r.x,n.y+r.y,r.width,r.height),u=a===null||s(l),d=((e,t)=>{let{side:n,align:r=`center`}=t;if(n===`t`||n===`b`){let t=n===`t`?e.top:e.bottom;return{x:r===`start`?e.left:r===`end`?e.right:(e.left+e.right)/2,y:t}}return{x:n===`l`?e.left:e.right,y:r===`start`?e.top:r===`end`?e.bottom:(e.top+e.bottom)/2}})(l,i);return{rect:l,clipped:u,boundaryRect:o,clampedTo:je(o,(c=d,Y(c.x,c.y,0,0))),anchorPoint:d,owner:e.getAnchor(),slid:null,outOfView:u}}var c;let l=(e=>{if(`range`in e)return e.range;if(`cell`in e){let{rowIndex:t,colIndex:n}=e.cell;return{rowStart:t,colStart:n,rowEnd:t,colEnd:n}}return null})(t),d=e.getAllPanes(),f=((e,t)=>{let{side:n,align:r=`center`}=t,i=Math.round((e.rowStart+e.rowEnd)/2),a=Math.round((e.colStart+e.colEnd)/2);if(n===`t`||n===`b`)return{rowIndex:n===`t`?e.rowStart:e.rowEnd,colIndex:r===`start`?e.colStart:r===`end`?e.colEnd:a};let o=n===`l`?e.colStart:e.colEnd;return{rowIndex:r===`start`?e.rowStart:r===`end`?e.rowEnd:i,colIndex:o}})(l,i),p=Z(d,`row`,l.rowStart,l.rowEnd,f.rowIndex),m=Z(d,`col`,l.colStart,l.colEnd,f.colIndex),h=p.visible&&m.visible,g=p.pane??d[u.AnchorLocation.Center]??e,_=m.pane??d[u.AnchorLocation.Center]??e,v=Ae(g,l),y=Ae(_,l),{side:b,align:x=`center`}=i,S,C;b===`t`||b===`b`?(C=b===`t`?v.top:v.bottom,S=x===`start`?y.left:x===`end`?y.right:(y.left+y.right)/2):(S=b===`l`?y.left:y.right,C=x===`start`?v.top:x===`end`?v.bottom:(v.top+v.bottom)/2);let w=we(_),T=we(g),E=e=>Math.max(w.left,Math.min(w.right,e)),D=e=>Math.max(T.top,Math.min(T.bottom,e)),O=E(S),k=D(C),A={x:O,y:k},j=E(y.left),M=D(v.top),N=Y(j,M,E(y.right)-j,D(v.bottom)-M),P=O-S,F=k-C,I=Math.abs(F)>=Math.abs(P)?F<0?`b`:F>0?`t`:P<0?`r`:P>0?`l`:null:P<0?`r`:P>0?`l`:F<0?`b`:F>0?`t`:null,L=P||F?{dx:P,dy:F,distance:Math.hypot(P,F),direction:I??`t`}:null;return h||a!==`hide`?{rect:N,clipped:!1,boundaryRect:o,clampedTo:I,anchorPoint:A,owner:ke(g,_),slid:L,outOfView:!h}:{rect:N,clipped:!0,boundaryRect:o,clampedTo:I,anchorPoint:A,owner:null,slid:null,outOfView:!0}},Ne=(0,s.createContext)(null),Pe=e=>{let{anchor:t,placement:n=Te,boundary:r=`data`,whenOff:i=`hide`,minVisible:a=0,children:o}=e,{reference:l,getBoundaryRect:d,getAnchorPoint:f,anchorPoint:p,owner:m,clipped:h,slid:g,outOfView:_,pane:v}=((e,t)=>{let n=G(),r=t?.pane??n,i=t?.boundary??`data`,a=t?.minVisible??0,o=t?.placement??Te,c=t?.whenOff??`hide`,l=(0,s.useRef)({pane:r,anchor:e,boundary:i,minVisible:a,placement:o,whenOff:c});l.current={pane:r,anchor:e,boundary:i,minVisible:a,placement:o,whenOff:c};let u=(0,s.useMemo)(()=>({reference:{get contextElement(){return l.current.pane?.getElement()??void 0},getBoundingClientRect:()=>{let e=l.current;return Me(e.pane,e.anchor,e.boundary,e.minVisible,e.placement,e.whenOff).rect}},getBoundaryRect:()=>{let e=l.current;return Me(e.pane,e.anchor,e.boundary,e.minVisible,e.placement,e.whenOff).boundaryRect},getAnchorPoint:()=>{let e=l.current;return Me(e.pane,e.anchor,e.boundary,e.minVisible,e.placement,e.whenOff).anchorPoint}}),[]),d=Me(r,e,i,a,o,c);return{reference:u.reference,getBoundaryRect:u.getBoundaryRect,getAnchorPoint:u.getAnchorPoint,clipped:d.clipped,clampedTo:d.clampedTo,anchorPoint:d.anchorPoint,owner:d.owner,slid:d.slid,outOfView:d.outOfView,pane:r}})(t,{boundary:r,whenOff:i,minVisible:a,placement:n}),y=v!=null&&(m==null?v.getAnchor()===u.AnchorLocation.Center:v.getAnchor()===m),b=null;y&&v&&(`range`in t?b=v.getBoundsFromRange(t.range):`cell`in t?b=v.getBoundsFromRange({rowStart:t.cell.rowIndex,colStart:t.cell.colIndex,rowEnd:t.cell.rowIndex,colEnd:t.cell.colIndex}):`bounds`in t&&(b=t.bounds));let x=(0,s.useRef)(t);x.current=t;let S=(0,s.useRef)(v);S.current=v;let C=(0,s.useCallback)(e=>{let t=Fe(x.current),n=S.current;return n&&t?n.scrollCellCoordsIntoView(t,e):Promise.resolve(void 0)},[]),w=(0,s.useMemo)(()=>({reference:l,getBoundaryRect:d,getAnchorPoint:f,anchorPoint:p,bounds:b,owner:m,isOwner:y,clipped:h,slid:g,outOfView:_,placement:n,pane:v,scrollIntoView:C}),[l,d,f,p.x,p.y,b?.x,b?.y,b?.width,b?.height,m,y,h,g,_,n.side,n.align,v,C]),T=y&&!h&&v!=null,E=typeof o!=`function`,D=(0,s.useRef)(null),O=(0,s.useRef)(null),k=null;if(T&&!E)k=o(w);else if(T){let e=v.getElement()?.getBoundingClientRect();k=(0,c.jsx)(`div`,{ref:D,className:`sticky-layer`,style:{position:`absolute`,left:0,top:0,transform:`translate3d(${p.x-(e?.left??0)}px, ${p.y-(e?.top??0)}px, 0) ${Ie(n)}`,willChange:`transform`},children:(0,c.jsx)(`div`,{ref:O,children:o})})}return(0,s.useLayoutEffect)(()=>{let e=D.current,t=O.current;if(!(e&&t&&T&&v))return;let n=e.getBoundingClientRect(),r=v.getElement()?.getBoundingClientRect();if(!r)return;let i=0,a=0;n.left<r.left?i=r.left-n.left:n.right>r.right&&(i=Math.min(0,r.right-n.right)),n.top<r.top?a=r.top-n.top:n.bottom>r.bottom&&(a=Math.min(0,r.bottom-n.bottom)),t.style.transform=i||a?`translate(${i}px, ${a}px)`:``}),(0,c.jsx)(Ne.Provider,{value:w,children:k})},Fe=e=>`range`in e?{rowIndex:e.range.rowStart,colIndex:e.range.colStart}:`cell`in e?{rowIndex:e.cell.rowIndex,colIndex:e.cell.colIndex}:null,Ie=e=>{let{side:t,align:n=`center`}=e,r=`-50%`,i=`-50%`;t===`t`?i=`-100%`:t===`b`?i=`0%`:t===`l`?r=`-100%`:t===`r`&&(r=`0%`);let a=n===`start`?`0%`:n===`end`?`-100%`:`-50%`;return t===`t`||t===`b`?r=a:i=a,`translate(${r}, ${i})`};Pe.displayName=`StickyAnchor`;var Le=Math.min,Re=Math.max,ze=Math.round,Be=Math.floor,Ve=e=>({x:e,y:e}),He={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Ue(e,t){return typeof e==`function`?e(t):e}function We(e){return e.split(`-`)[0]}function Ge(e){return e.split(`-`)[1]}function Ke(e){return e===`x`?`y`:`x`}function qe(e){return e===`y`?`height`:`width`}function Je(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Ye(e){return Ke(Je(e))}function Xe(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Ze=[`left`,`right`],Qe=[`right`,`left`],$e=[`top`,`bottom`],et=[`bottom`,`top`];function tt(e,t,n,r){let i=Ge(e),a=function(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Qe:Ze:t?Ze:Qe;case`left`:case`right`:return t?$e:et;default:return[]}}(We(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Xe)))),a}function nt(e){let t=We(e);return He[t]+e.slice(t.length)}function rt(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function it(e,t,n){let{reference:r,floating:i}=e,a=Je(t),o=Ye(t),s=qe(o),c=We(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Ge(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function at(e,t){var n;t===void 0&&(t={});let{x:r,y:i,platform:a,rects:o,elements:s,strategy:c}=e,{boundary:l=`clippingAncestors`,rootBoundary:u=`viewport`,elementContext:d=`floating`,altBoundary:f=!1,padding:p=0}=Ue(t,e),m=function(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:function(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}(e)}(p),h=s[f?d===`floating`?`reference`:`floating`:d],g=rt(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(h)))==null||n?h:h.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:u,strategy:c})),_=d===`floating`?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,v=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),y=await(a.isElement==null?void 0:a.isElement(v))&&await(a.getScale==null?void 0:a.getScale(v))||{x:1,y:1},b=rt(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:_,offsetParent:v,strategy:c}):_);return{top:(g.top-b.top+m.top)/y.y,bottom:(b.bottom-g.bottom+m.bottom)/y.y,left:(g.left-b.left+m.left)/y.x,right:(b.right-g.right+m.right)/y.x}}var ot=new Set([`left`,`top`]);function st(){return typeof window<`u`}function ct(e){return ut(e)?(e.nodeName||``).toLowerCase():`#document`}function Q(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function lt(e){return((ut(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ut(e){return!!st()&&(e instanceof Node||e instanceof Q(e).Node)}function dt(e){return!!st()&&(e instanceof Element||e instanceof Q(e).Element)}function ft(e){return!!st()&&(e instanceof HTMLElement||e instanceof Q(e).HTMLElement)}function pt(e){return!(!st()||typeof ShadowRoot>`u`)&&(e instanceof ShadowRoot||e instanceof Q(e).ShadowRoot)}function mt(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=wt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ht(e){return/^(table|td|th)$/.test(ct(e))}function gt(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var _t,vt=/transform|translate|scale|rotate|perspective|filter/,yt=/paint|layout|strict|content/,bt=e=>!!e&&e!==`none`;function xt(e){let t=dt(e)?wt(e):e;return bt(t.transform)||bt(t.translate)||bt(t.scale)||bt(t.rotate)||bt(t.perspective)||!St()&&(bt(t.backdropFilter)||bt(t.filter))||vt.test(t.willChange||``)||yt.test(t.contain||``)}function St(){return _t??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),_t}function Ct(e){return/^(html|body|#document)$/.test(ct(e))}function wt(e){return Q(e).getComputedStyle(e)}function Tt(e){return dt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Et(e){if(ct(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||pt(e)&&e.host||lt(e);return pt(t)?t.host:t}function Dt(e){let t=Et(e);return Ct(t)?(e.ownerDocument||e).body:ft(t)&&mt(t)?t:Dt(t)}function Ot(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Dt(e),i=r===e.ownerDocument?.body,a=Q(r);if(i){let e=kt(a);return t.concat(a,a.visualViewport||[],mt(r)?r:[],e&&n?Ot(e):[])}return t.concat(r,Ot(r,[],n))}function kt(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function At(e){let t=wt(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ft(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=ze(n)!==a||ze(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function jt(e){return dt(e)?e:e.contextElement}function Mt(e){let t=jt(e);if(!ft(t))return Ve(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=At(t),o=(a?ze(n.width):n.width)/r,s=(a?ze(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var Nt=Ve(0);function Pt(e){let t=Q(e);return St()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Nt}function Ft(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=jt(e),o=Ve(1);t&&(r?dt(r)&&(o=Mt(r)):o=Mt(e));let s=function(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Q(e)}(a,n,r)?Pt(a):Ve(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Q(a),t=dt(r)?Q(r):r,n=e,i=kt(n);for(;i&&t!==n;){let e=Mt(i),t=i.getBoundingClientRect(),r=wt(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Q(i),i=kt(n)}}return rt({width:u,height:d,x:c,y:l})}function It(e,t){let n=Tt(e).scrollLeft;return t?t.left+n:Ft(lt(e)).left+n}function Lt(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-It(e,n),y:n.top+t.scrollTop}}function Rt(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=function(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Q(e),a=lt(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!St()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(It(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=25&&(s-=o)}return{width:s,height:c,x:l,y:u}}(e,n,t);else if(t===`document`)r=function(e){let t=Tt(e),n=e.ownerDocument.body,r=Re(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Re(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+It(e),o=-t.scrollTop;return wt(n).direction===`rtl`&&(a+=Re(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}(lt(e));else if(dt(t))r=function(e,t){let n=Ft(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Mt(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}(t,n);else{let n=Pt(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return rt(r)}function zt(e,t){let n=t.get(e);if(n)return n;let r=Ot(e,[],!1).filter(e=>dt(e)&&ct(e)!==`body`),i=null,a=wt(e).position===`fixed`,o=a?Et(e):e;for(;dt(o)&&!Ct(o);){let e=wt(o),t=xt(o),n=i?i.position:a?`fixed`:``;t||n!==`fixed`&&(n!==`absolute`||e.position!==`static`)?i=e:r=r.filter(e=>e!==o),o=Et(o)}return t.set(e,r),r}function Bt(e,t,n){let r=ft(t),i=lt(t),a=n===`fixed`,o=Ft(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Ve(0);if((r||!a)&&((ct(t)!==`body`||mt(i))&&(s=Tt(t)),r)){let e=Ft(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=It(i));let l=!i||r||a?Ve(0):Lt(i,s);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Vt(e){return wt(e).position===`static`}function Ht(e,t){if(!ft(e)||wt(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return lt(e)===n&&(n=n.ownerDocument.body),n}function Ut(e,t){let n=Q(e);if(gt(e))return n;if(!ft(e)){let t=Et(e);for(;t&&!Ct(t);){if(dt(t)&&!Vt(t))return t;t=Et(t)}return n}let r=Ht(e,t);for(;r&&ht(r)&&Vt(r);)r=Ht(r,t);return r&&Ct(r)&&Vt(r)&&!xt(r)?n:r||function(e){let t=Et(e);for(;ft(t)&&!Ct(t);){if(xt(t))return t;if(gt(t))return null;t=Et(t)}return null}(e)||n}var Wt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=lt(r),s=!!t&&gt(t.floating);if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Ve(1),u=Ve(0),d=ft(r);if((d||!a)&&((ct(r)!==`body`||mt(o))&&(c=Tt(r)),d)){let e=Ft(r);l=Mt(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=!o||d||a?Ve(0):Lt(o,c);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}},getDocumentElement:lt,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?gt(t)?[]:zt(t,this._c):[].concat(n),r],o=Rt(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Rt(t,a[e],i);s=Re(n.top,s),c=Le(n.right,c),l=Le(n.bottom,l),u=Re(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}},getOffsetParent:Ut,getElementRects:async function(e){let t=this.getOffsetParent||Ut,n=this.getDimensions,r=await n(e.floating);return{reference:Bt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return e.getClientRects?Array.from(e.getClientRects()):[]},getDimensions:function(e){let{width:t,height:n}=At(e);return{width:t,height:n}},getScale:Mt,isElement:dt,isRTL:function(e){return wt(e).direction===`rtl`}};function Gt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Kt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=jt(e),u=i||a?[...l?Ot(l):[],...t?Ot(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?function(e,t,n){let r,i=null,a=lt(e);function o(){var e;clearTimeout(r),(e=i)==null||e.disconnect(),i=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m={rootMargin:-Be(d)+`px `+-Be(a.clientWidth-(u+f))+`px `+-Be(a.clientHeight-(d+p))+`px `+-Be(u)+`px`,threshold:Re(0,Le(1,c))||1},h=!0;function g(t){let n=t[0].intersectionRatio;if(!Gt(l,e.getBoundingClientRect()))return s();if(n!==c){if(!h)return s();n?s(!1,n):r=setTimeout(()=>{s(!1,1e-7)},1e3)}h=!1}try{i=new IntersectionObserver(g,{...m,root:a.ownerDocument})}catch{i=new IntersectionObserver(g,m)}i.observe(e)}let c=Q(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}(l,n,a):null,f,p=-1,m=null;o&&(m=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;(e=m)==null||e.observe(t)})),n()}),l&&!c&&m.observe(l),t&&m.observe(t));let h=c?Ft(e):null;return c&&function t(){let r=Ft(e);h&&!Gt(h,r)&&n(),h=r,f=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=m)==null||e.disconnect(),m=null,c&&cancelAnimationFrame(f)}}var qt=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await async function(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=We(n),s=Ge(n),c=Je(n)===`y`,l=ot.has(o)?-1:1,u=a&&c?-1:1,d=Ue(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?-1*m:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Jt=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Ue(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Je(i),p=Ke(f),m=u[p],h=u[f],g=(e,t)=>{return n=t+d[e===`y`?`top`:`left`],r=t,i=t-d[e===`y`?`bottom`:`right`],Re(n,Le(r,i));var n,r,i};o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Yt=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Ue(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=We(r),_=Je(o),v=We(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[nt(o)]:function(e){let t=nt(e);return[Xe(e),t,Xe(t)]}(o)),x=p!==`none`;!d&&x&&b.push(...tt(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=function(e,t,n){n===void 0&&(n=!1);let r=Ge(e),i=Ye(e),a=qe(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=nt(o)),[o,nt(o)]}(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Je(t)||T.every(e=>Je(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Je(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},Xt=(e,t,n)=>{let r=new Map,i=n??{},a={...Wt,...i.platform,_c:r};return(async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:at},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=it(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<50&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=!0===x.rects?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=it(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}})(e,t,{...i,platform:a})},Zt=typeof document<`u`?s.useLayoutEffect:function(){};function Qt(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,i;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(!Qt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if((n!==`_owner`||!e.$$typeof)&&!Qt(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function $t(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function en(e,t){let n=$t(e);return Math.round(t*n)/n}function tn(e){let t=s.useRef(e);return Zt(()=>{t.current=e}),t}function nn(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:c=!0,whileElementsMounted:l,open:u}=e,[f,p]=s.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=s.useState(r);Qt(m,r)||h(r);let[g,_]=s.useState(null),[v,y]=s.useState(null),b=s.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=s.useCallback(e=>{e!==T.current&&(T.current=e,y(e))},[]),S=a||g,C=o||v,w=s.useRef(null),T=s.useRef(null),E=s.useRef(f),D=l!=null,O=tn(l),k=tn(i),A=tn(u),j=s.useCallback(()=>{if(!w.current||!T.current)return;let e={placement:t,strategy:n,middleware:m};k.current&&(e.platform=k.current),Xt(w.current,T.current,e).then(e=>{let t={...e,isPositioned:!1!==A.current};M.current&&!Qt(E.current,t)&&(E.current=t,d.flushSync(()=>{p(t)}))})},[m,t,n,k,A]);Zt(()=>{!1===u&&E.current.isPositioned&&(E.current.isPositioned=!1,p(e=>({...e,isPositioned:!1})))},[u]);let M=s.useRef(!1);Zt(()=>(M.current=!0,()=>{M.current=!1}),[]),Zt(()=>{if(S&&(w.current=S),C&&(T.current=C),S&&C){if(O.current)return O.current(S,C,j);j()}},[S,C,j,O,D]);let N=s.useMemo(()=>({reference:w,floating:T,setReference:b,setFloating:x}),[b,x]),P=s.useMemo(()=>({reference:S,floating:C}),[S,C]),F=s.useMemo(()=>{let e={position:n,left:0,top:0};if(!P.floating)return e;let t=en(P.floating,f.x),r=en(P.floating,f.y);return c?{...e,transform:`translate(`+t+`px, `+r+`px)`,...$t(P.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,c,P.floating,f.x,f.y]);return s.useMemo(()=>({...f,update:j,refs:N,elements:P,floatingStyles:F}),[f,j,N,P,F])}var rn=(e,t)=>{let n=qt(e);return{name:n.name,fn:n.fn,options:[e,t]}},an=(e,t)=>{let n=Jt(e);return{name:n.name,fn:n.fn,options:[e,t]}},on=(e,t)=>{let n=Yt(e);return{name:n.name,fn:n.fn,options:[e,t]}},sn=e=>{let t=(0,l.useFloatSurface)(),n=(0,l.useTokenThemeContext)(),r=e?.getElement(),i={},a=r?.closest(`[${l.THEME_MODE_ATTR}]`)?.getAttribute(l.THEME_MODE_ATTR),o=r?.closest(`[${l.THEME_SURFACE_ATTR}]`)?.getAttribute(l.THEME_SURFACE_ATTR);a&&(i[l.THEME_MODE_ATTR]=a),o&&(i[l.THEME_SURFACE_ATTR]=o);let s=[...t?.themeScope?.classes??[],n?.scopeClass].filter(Boolean);return{className:s.length?s.join(` `):void 0,attrs:i}},cn=e=>{let{side:t,align:n=`center`}=e;return(t===`t`?`top`:t===`b`?`bottom`:t===`l`?`left`:`right`)+(n===`start`?`-start`:n===`end`?`-end`:``)},ln=e=>{let{state:t,offset:n,alignOffset:r,open:i,container:a,className:o,style:u,zIndex:f,children:p}=e,{getPortalContainer:m}=(0,l.useFullscreenPortal)(),{className:h,attrs:g}=sn(t.pane),{getBoundaryRect:_}=t,v=(0,s.useMemo)(()=>[rn({mainAxis:n,alignmentAxis:r}),on(()=>({boundary:_()})),an(()=>({boundary:_(),padding:4}))],[n,r,_]),{refs:y,floatingStyles:b,update:x}=nn({placement:cn(t.placement),strategy:`fixed`,elements:{reference:t.reference},whileElementsMounted:Kt,middleware:v});if((0,s.useLayoutEffect)(()=>{x()},[t,x]),!i)return null;let S=typeof p==`function`?p(t):p;return(0,d.createPortal)((0,c.jsx)(`div`,{ref:y.setFloating,className:[o,h].filter(Boolean).join(` `)||void 0,...g,style:{...b,zIndex:f,...u},children:S}),a??m())},un=e=>{let{anchor:t,placement:n,whenOff:r,boundary:i,minVisible:a,offset:o=4,alignOffset:s=0,open:l=!0,container:u,className:d,style:f,zIndex:p=1250,children:m}=e;return(0,c.jsx)(Pe,{anchor:t,placement:n,whenOff:r,boundary:i,minVisible:a,children:e=>(0,c.jsx)(ln,{state:e,offset:o,alignOffset:s,open:l,container:u,className:d,style:f,zIndex:p,children:m})})};un.displayName=`StickyFloat`;var dn=e=>{let[t,n]=(e??`bottom-start`).split(`-`);return{side:t===`top`?`t`:t===`left`?`l`:t===`right`?`r`:`b`,align:n===`start`?`start`:n===`end`?`end`:`center`}},fn={update:()=>{}},pn=e=>{let{open:t,anchorEl:n,floatReference:r,createPopupPanel:i,propsPopper:a,onMount:o,onOpening:u,onOpen:d,onClosing:f,onClose:p,children:m,className:h,label:g,anchorPosition:_,...v}=e,y=(0,s.useRef)(null),[b,x]=(0,s.useState)(),S=(0,l.useCallbackRef)(o??(()=>{}),[o]),C=(0,l.useCallbackRef)(u??(()=>{}),[u]),w=(0,l.useCallbackRef)(d??(()=>{}),[d]),T=(0,l.useCallbackRef)(f??(()=>{}),[f]),E=(0,l.useCallbackRef)(p??(()=>{}),[p]);(0,s.useEffect)(()=>{if(t){let e=y.current;if(!e)return;x(e),S(e,fn),C(),w();return}T(),E()},[t]);let D=(0,l.useCallbackRef)(()=>{r?.close(0)},[r]),O=a?.offsets;return(0,c.jsx)(un,{anchor:n,placement:dn(a?.placement),offset:O?.[1]??2,alignOffset:O?.[0]??0,zIndex:1300,children:e=>(0,c.jsxs)(`div`,{onKeyDown:a?.onKeyDown,onMouseEnter:a?.onMouseEnter,children:[(0,c.jsx)(l.FloatPanelSurface,{ref:y,className:h,floatReference:r,popupContainer:b,createPopupPanel:i,...v,children:m}),(0,c.jsx)(mn,{outOfView:t&&e.outOfView,close:D})]})})};pn.displayName=`GridFloatPanel`;var mn=({outOfView:e,close:t})=>((0,s.useEffect)(()=>{e&&t()},[e]),null),hn={pointerEvents:`auto`},gn=(e={})=>{let{openDelay:t=300,closeDelay:n=150}=e,[r,i]=(0,s.useState)(!1),a=(0,s.useRef)(!1),o=(0,s.useRef)(null),c=(0,s.useRef)(!1),l=(0,s.useRef)(null),u=(0,s.useRef)(null),d=e=>{a.current=e,i(e)},f=()=>{l.current&&=(clearTimeout(l.current),null)},p=()=>{u.current&&=(clearTimeout(u.current),null)},m=(0,s.useCallback)(()=>{f(),p(),u.current=setTimeout(()=>{u.current=null,c.current||o.current!==null||d(!1)},n)},[n]),h=(0,s.useCallback)(e=>{if(e!==o.current)if(o.current=e,e!==null){if(p(),a.current)return;f(),l.current=setTimeout(()=>{l.current=null,o.current!==null&&d(!0)},t)}else m()},[t,m]),g=(0,s.useCallback)(()=>{f(),p(),o.current=null,c.current=!1,d(!1)},[]),_=(0,s.useMemo)(()=>({onPointerEnter:()=>{c.current=!0,p()},onPointerLeave:()=>{c.current=!1,m()},style:hn}),[m]);return(0,s.useEffect)(()=>()=>{f(),p()},[]),{open:r,setTarget:h,tipProps:_,close:g}},_n={target:null,aimed:null},vn=e=>({key:e.key??R(e.range),range:e.range,data:e.data,placement:e.placement}),yn=(e,t)=>Array.isArray(e)?e.includes(t):e===t,bn=e=>{let t=e.getCoords();return t?`${t.rowIndex},${t.colIndex}`:null},xn=e=>{let{activateOn:t,name:n,probe:r,selection:i,target:a,dismiss:o,placement:u,offset:d=6,alignOffset:f=0,openDelay:p=300,closeDelay:m=150,whenOff:h=`hide`,boundary:g,zIndex:_,children:v,className:y,style:b}=e,x=W(),S=(0,s.useContext)(ee),w=yn(t,`hover`),T=yn(t,`selection`),E=a!==void 0,{open:D,setTarget:O,tipProps:k,close:A}=gn({openDelay:p,closeDelay:m}),[j,M]=ve(`range-float:${n??S}`,_n),N=(0,l.useCallbackRef)(()=>{M(e=>e.aimed===null?e:{target:e.target,aimed:null})},[M]),P=(0,l.useCallbackRef)(e=>{let t=x.getCellFromPointer(e.clientX,e.clientY),n=t?r?.(t,x):null;if(!n?.range)return void N();let i=vn(n);M(e=>e.aimed===i.key&&e.target?.key===i.key?e:{target:i,aimed:i.key})},[x,r,M,N]),F=w?j.aimed:null;(0,s.useEffect)(()=>{O(F)},[F,O]),(0,s.useEffect)(()=>{o&&(A(),M(_n))},[o,A,M]);let I=(0,l.useOptionalBoundSyncExternalStore)(T?i:void 0,bn),L=null;if(T&&!o&&i&&I!==null){let e=r?.(i.getCoords(),x);e&&e.range&&(L=vn(e))}let R=w?j.target:null,te=D&&R!==null,ne=E?a===null?null:vn(a):te?R:L??R,re=E?ne!==null:te||L!==null;return(0,c.jsx)(ye,{className:C(y,`range-float`),onPointerMove:w?P:void 0,onPointerLeave:w?N:void 0,children:ne&&(0,c.jsx)(un,{anchor:{range:ne.range},placement:ne.placement??u,offset:d,alignOffset:f,boundary:g,zIndex:_,open:re,whenOff:h,style:b,children:e=>v({range:ne.range,data:ne.data,floatProps:k,state:e})})})};xn.displayName=`RangeFloatLayer`;var Sn=e=>{let{children:t,className:n,...r}=e;return(0,c.jsx)(xn,{...r,activateOn:`hover`,className:C(n,`hover-tip`),children:({range:e,data:n,floatProps:r,state:i})=>t({range:e,data:n,tipProps:r,state:i})})};Sn.displayName=`HoverTipLayer`;var Cn={t:`↑`,b:`↓`,l:`←`,r:`→`},wn=e=>{let t=``,n=e;do t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26)-1;while(n>=0);return t},Tn=e=>{let t=`${wn(e.colStart)}${e.rowStart+1}`,n=`${wn(e.colEnd)}${e.rowEnd+1}`;return t===n?t:`${t}:${n}`},En={border:`none`,background:`transparent`,color:`inherit`,cursor:`pointer`,font:`14px/1 system-ui`,padding:0,width:18,height:18,borderRadius:4,opacity:.6},Dn={position:`relative`,background:`var(--sxl-color-base-100, white)`,color:`var(--sxl-color-base-content, #222)`,border:`1px solid var(--sxl-color-base-300, #ccc)`,borderRadius:8,padding:`10px 12px`,boxShadow:`0 6px 24px var(--sxl-color-shadow, rgba(0,0,0,0.2))`,pointerEvents:`auto`,maxWidth:320},On={display:`inline-flex`,alignItems:`center`,gap:8,background:`var(--sxl-color-base-content, rgb(55,55,65))`,color:`var(--sxl-color-base-100, white)`,borderRadius:16,padding:`4px 6px 4px 12px`,boxShadow:`0 2px 10px var(--sxl-color-shadow, rgba(0,0,0,0.3))`,pointerEvents:`auto`},kn=({direction:e,label:t,onGoto:n,onCancel:r})=>(0,c.jsxs)(`div`,{style:On,children:[(0,c.jsxs)(`button`,{onClick:n,style:{border:`none`,background:`transparent`,color:`inherit`,cursor:`pointer`,font:`12px system-ui`},children:[Cn[e],` `,t]}),r&&(0,c.jsx)(`button`,{"aria-label":`Cancel`,onClick:r,style:{...En,opacity:.8},children:`×`})]}),An=e=>{let{range:t,placement:n={side:`t`,align:`start`},offset:r=8,alignOffset:i=0,address:a,onGoto:o,onCancel:s,zIndex:l,className:u,style:d,children:f}=e;return(0,c.jsx)(un,{anchor:{range:t},placement:n,offset:r,alignOffset:i,whenOff:`clamp`,zIndex:l,open:!0,children:e=>{if(e.outOfView)return(0,c.jsx)(kn,{direction:e.slid?.direction??n.side,label:a??Tn(t),onGoto:()=>o?o(e):e.scrollIntoView(),onCancel:s});let r=typeof f==`function`?f(e):f;return(0,c.jsxs)(`div`,{className:u,style:{...Dn,...d},children:[s&&(0,c.jsx)(`button`,{"aria-label":`Cancel`,onClick:s,style:{...En,position:`absolute`,top:4,right:4},children:`×`}),r]})}})};An.displayName=`RangePrompt`;var jn={stroke:`var(--sxl-color-primary, rgb(33, 115, 70))`,alignWidth:2,fill:`color-mix(in srgb, var(--sxl-color-primary, rgb(33, 115, 70)) 10%, transparent)`},Mn=(0,s.memo)(e=>{let{range:t,hole:n,clipInsets:r,alignWidth:i=1,animatedTransition:a,className:o,...s}=e,u=l.ReactUtils.getDevicePixelRatio(),d=i/u,f=r??-d/2,p=G(),m=p?p.getBoundsFromRange(t):null,h=d+4;if(p&&m&&!p.toClipBounds(m,f))return null;let g=p?p.getPaneBounds():null,v=g?{x:-h,y:-h,width:g.width+2*h,height:g.height+2*h}:m,y=v?l.ReactUtils.snapDeviceEdge(v.x,u):0,b=v?l.ReactUtils.snapDeviceEdge(v.y,u):0,x;if(m&&v){let e=d+2,t=Math.max(m.x,v.x-e),n=Math.max(m.y,v.y-e);x={x:t-y,y:n-b,width:Math.min(m.x+m.width,v.x+v.width+e)-t,height:Math.min(m.y+m.height,v.y+v.height+e)-n}}let S=n&&p?p.getBoundsFromRange(n):null,w=S?{x:S.x-y,y:S.y-b,width:S.width,height:S.height}:void 0;return(0,c.jsx)(q,{className:C(o),bounds:v??void 0,clipInsets:f,style:{pointerEvents:`none`},children:(0,c.jsx)(_,{bounds:x,alignWidth:i,hole:w,animatedTransition:a,...s})})});Mn.displayName=`RangeRect`;var Nn=(0,s.memo)(e=>{let{range:t,axis:n,color:r=`var(--sxl-color-primary, rgb(33, 115, 70))`,alignWidth:i=3,capExtent:a=3,transitionDuration:o=100,transitionEasing:s=`cubic-bezier(0.16, 1, 0.3, 1)`,axisDuration:d=70}=e,f=G(),p=f?.getBoundsFromRange(t);if(!f||!p)return null;let m=l.ReactUtils.getDevicePixelRatio(),h=i/m,g=a/m,_=f.getPaneBounds(),v=e=>e.x>=-g&&e.y>=-g&&e.x+e.width<=_.width+g&&e.y+e.height<=_.height+g,y=o>0?`${o}ms ${s}`:null,b=d>0?`${d}ms ${s}`:null,x=[y&&`transform ${y}, width ${y}, height ${y}, background-color ${y}`,b&&`scale ${b}`].filter(Boolean).join(`, `);return(0,c.jsx)(c.Fragment,{children:[!0,!1].map(e=>(e=>{let t=e?{x:p.x,y:p.y-h/2,width:p.width,height:h}:{x:p.x-h/2,y:p.y,width:h,height:p.height},n=h+2*g,r=e?{start:{x:t.x,y:t.y-g,width:h,height:n},end:{x:t.x+t.width-h,y:t.y-g,width:h,height:n}}:{start:{x:t.x-g,y:t.y,width:n,height:h},end:{x:t.x-g,y:t.y+t.height-h,width:n,height:h}};return[[`insert-bar`,f.toClipBounds(t,-h)],[`insert-bar-cap-start`,v(r.start)?r.start:null],[`insert-bar-cap-end`,v(r.end)?r.end:null]]})(e).map(([t,i])=>i&&(0,c.jsx)(q,{className:C(t,e?`row`:`column`),bounds:i,style:{pointerEvents:`none`,background:r,scale:+(e===(n===u.RangeAxis.Row)),transformOrigin:`${p.x}px ${p.y}px`,transition:x,willChange:`transform, width, height, scale`}},`${e?`row`:`column`}-${t}`)))})});Nn.displayName=`RangeInsertBar`;var Pn=()=>typeof window<`u`?window:null,Fn=(e,t,n={x:!0,y:!0})=>{let r=e.getElement()?.getBoundingClientRect();if(!r)return!1;let i=!1===n.x?0:t.x<=r.left+24?-1:+(t.x>=r.right-24),a=!1===n.y?0:t.y<=r.top+24?-1:+(t.y>=r.bottom-24);if(!i&&!a)return!1;let o=e.getVisibleRange(),s=e.getTotalRange(),c=e.getCellFromPointer(t.x,t.y),l={};return i>0&&o.colEnd<s.colEnd?l.colIndex=Math.min(s.colEnd,Math.max(o.colEnd+1,c?.colIndex??0)):i<0&&o.colStart>s.colStart&&(l.colIndex=Math.max(s.colStart,Math.min(o.colStart-1,c?.colIndex??2**53-1))),a>0&&o.rowEnd<s.rowEnd?l.rowIndex=Math.min(s.rowEnd,Math.max(o.rowEnd+1,c?.rowIndex??0)):a<0&&o.rowStart>s.rowStart&&(l.rowIndex=Math.max(s.rowStart,Math.min(o.rowStart-1,c?.rowIndex??2**53-1))),(l.colIndex!==void 0||l.rowIndex!==void 0)&&((e.getAllPanes()[u.AnchorLocation.Center]??e).scrollCellCoordsIntoView(l),!0)},In=Object.freeze({ctrlKey:!1,shiftKey:!1,altKey:!1,metaKey:!1}),Ln=e=>({ctrlKey:!!e.ctrlKey,shiftKey:!!e.shiftKey,altKey:!!e.altKey,metaKey:!!e.metaKey}),Rn=(e,t)=>e.ctrlKey===t.ctrlKey&&e.shiftKey===t.shiftKey&&e.altKey===t.altKey&&e.metaKey===t.metaKey,zn=(e,t,n,r)=>{let i=r??((t,n)=>e.getCellFromPointer(t,n)),a=null,o=null,s=null,c=null,l=null,d=()=>{l&&=(document.removeEventListener(`touchstart`,l,{capture:!0}),document.removeEventListener(`touchmove`,l,{capture:!0}),null)},f=()=>{c&&clearTimeout(c),c=null},p=In,m=null,h=e=>{if(!a)return;let t=Ln(e);Rn(p,t)||(p=t,a.modifiers?.(t))},g=()=>{m&&=(Pn()?.removeEventListener(`keydown`,m,!0),Pn()?.removeEventListener(`keyup`,m,!0),null)},_=(t,n,r)=>{if(!a)return!1;let s=i(t,n);return s&&(u.CoordUtils.isEqualCells(s,o)||(o=s,a.drag(s,r)),a.point?.(s,t,n,r)),(a.edgeScroll??(t=>Fn(e,t)))({x:t,y:n})};return{hasSession:()=>a!==null,captureEvents:()=>a?.captureEvents,begin:e=>{let r=i(e.clientX,e.clientY);if(!r)return null;let c=t(r,e);return c?(a=c,o=r,s=null,e.pointerType===`touch`&&!1!==c.capture&&(()=>{if(l)return;let e=e=>{e.stopImmediatePropagation(),e.preventDefault()};l=e,document.addEventListener(`touchstart`,e,{capture:!0,passive:!1}),document.addEventListener(`touchmove`,e,{capture:!0,passive:!1})})(),(e=>{if(p=Ln(e),m)return;let t=e=>h(e);m=t,Pn()?.addEventListener(`keydown`,t,!0),Pn()?.addEventListener(`keyup`,t,!0)})(e),n?.(c.dragMode??null),c):null},move:(e,t,n)=>{a&&(n&&h(n),s={x:e,y:t},_(e,t,n)?(f(),c=setTimeout(function e(){c=a&&s&&_(s.x,s.y)?setTimeout(e,60):null},60)):f())},reset:()=>{let e=a;return a=null,o=null,s=null,f(),d(),g(),p=In,e&&n?.(null),e},dispose:()=>{f(),d(),g()}}},Bn=(e,t,n)=>{let r=zn(e,t,n),i=!1,a=null,o=null,s=null,c=null,l=null,u=()=>{s&&a&&a.removeEventListener?.(`pointercancel`,s),s=null,c&&Pn()?.removeEventListener(`keydown`,c,!0),c=null},d=()=>{l&&=(Pn()?.removeEventListener(`pointerup`,l),Pn()?.removeEventListener(`pointercancel`,l),null)},f=()=>{a&&o!==null&&a.hasPointerCapture?.(o)&&a.releasePointerCapture(o),a=null,o=null},p=(e,t)=>{let n=i,a=r.reset();i=!1,u(),d(),f(),a&&(e?a.cancel?.(t):t&&(!1!==a.captureEvents&&n&&t.stopPropagation(),a.end?.(t)))};return{onPointerDown:e=>{let t=r.begin(e);if(t)if(!1!==t.capture){let t=e.currentTarget;t.setPointerCapture?.(e.pointerId),a=t,o=e.pointerId,i=!0,s=e=>p(!0,e),t.addEventListener?.(`pointercancel`,s),c=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),p(!0))},Pn()?.addEventListener(`keydown`,c,!0)}else i=!1,l=e=>p(e.type===`pointercancel`,e),Pn()?.addEventListener(`pointerup`,l),Pn()?.addEventListener(`pointercancel`,l)},onPointerMove:e=>{r.hasSession()&&i&&(!1!==r.captureEvents()&&e.stopPropagation(),r.move(e.clientX,e.clientY,e))},onPointerUp:e=>p(!1,e),onPointerCancel:e=>p(!0,e),dispose:()=>{u(),d(),f(),r.dispose()}}};function Vn(e,t,n,r){let i=zn(e,t,n,r),a=null,o=null,s=null,c=()=>{a?.(),a=null},l=()=>{o&&s!==null&&o.hasPointerCapture?.(s)&&o.releasePointerCapture(s),o=null,s=null};return{start:(e,t)=>{c(),l();let n=i.begin(e);if(!n)return;if(!1!==n.capture){let n=t??e.currentTarget;n&&(n.setPointerCapture?.(e.pointerId),o=n,s=e.pointerId)}let r=e=>i.move(e.clientX,e.clientY,e),u=(e,t)=>{c();let n=i.reset();l(),n&&(e?n.cancel?.(t):n.end?.(t))},d=e=>u(!1,e),f=e=>u(!0,e),p=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u(!0))};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,f),window.addEventListener(`keydown`,p,!0),a=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,f),window.removeEventListener(`keydown`,p,!0)}},dispose:()=>{c(),l(),i.dispose()}}}var Hn=e=>{let t=W(),[n,r]=(0,s.useState)(null),i=(0,s.useRef)(e);i.current=e;let a=(0,s.useMemo)(()=>Bn(t,(e,t)=>i.current(e,t),r),[t]);return(0,s.useEffect)(()=>()=>a.dispose(),[a]),{onPointerDown:a.onPointerDown,onPointerMove:a.onPointerMove,onPointerUp:a.onPointerUp,onPointerCancel:a.onPointerCancel,dragMode:n}},Un=e=>{let t=W(),[n,r]=(0,s.useState)(null),i=(0,s.useRef)(e);i.current=e;let a=(0,s.useMemo)(()=>Vn(t,(e,t)=>i.current(e,t),r),[t]);return(0,s.useEffect)(()=>()=>a.dispose(),[a]),{start:a.start,dragMode:n}},Wn=e=>{let t=(0,s.useRef)(null),n=(0,s.useRef)(!1);return(0,s.useEffect)(()=>{let e=e=>{n.current&&(n.current=!1,e.stopPropagation(),e.preventDefault())};return window.addEventListener(`dblclick`,e,!0),()=>window.removeEventListener(`dblclick`,e,!0)},[]),r=>{if(!e||r.button!==0)return!1;let i=t.current,a=!!i&&r.timeStamp-i.time<=500&&Math.abs(r.clientX-i.x)<=4&&Math.abs(r.clientY-i.y)<=4;return t.current=a?null:{time:r.timeStamp,x:r.clientX,y:r.clientY},!!a&&(r.stopPropagation(),n.current=!0,window.setTimeout(()=>{n.current=!1},500),!0)}},Gn=e=>{let{range:t,anchor:n,size:r=8,cursor:i,dragCursor:a,background:o=`var(--sxl-color-primary, rgb(33, 115, 70))`,onDragStart:u,onDragMove:d,onDragEnd:f,onDragCancel:p,onDoubleClick:m,onHoverChange:h,hoverStyle:g,animatedTransition:_,renderHandle:v,children:y,className:b,style:x,preserveFocus:S,clampToView:w,secondaryButton:T}=e,E=W(),[D,O]=(0,s.useState)(!1),k=Wn(!!m),{start:A,dragMode:j}=Un((e,t)=>{let n=t.button===2&&!0===T;if(t.button!==0&&!n)return null;t.stopPropagation(),S&&t.preventDefault();let r=n?Kn():null,i=e,a=e;return u?.(i,t),{dragMode:`handle`,drag:(e,n)=>{a=e,d?.(i,e,n??t)},end:e=>{r?.(),f?.(i,a,e)},cancel:()=>{r?.(),p?.()}}}),M=j!==null&&a?a:i??Xn[n],N=E.getBoundsFromRange(t);if(!N)return null;let P=l.ReactUtils.getDevicePixelRatio(),F=Yn(N.x,N.x+N.width,qn[n],P),I=Yn(N.y,N.y+N.height,Jn[n],P);if(w){if(!E.toClipBounds(E.getBoundsFromRange(t)))return null;let e=E.getPaneBounds(),n=r/2+1;!0!==w&&w!==`x`||(F=Math.max(n,Math.min(e.width-n,F))),!0!==w&&w!==`y`||(I=Math.max(n,Math.min(e.height-n,I)))}let L={position:`absolute`,cursor:M,pointerEvents:`all`,left:0,top:0,transform:`translate(${F}px, ${I}px) translate(-50%, -50%)`,..._?{transition:`transform 60ms ease-in-out`,willChange:`transform`}:void 0},R={className:C(`drag-handle`,b),onPointerDown:e=>{k(e)?m(e):A(e)},onDoubleClick:m?e=>e.stopPropagation():void 0,onPointerEnter:()=>{O(!0),h?.(!0)},onPointerLeave:()=>{O(!1),h?.(!1)}};return v?(0,c.jsx)(c.Fragment,{children:v({anchor:n,size:r,cursor:M,background:o,hovered:D,handleProps:{...R,style:L}})}):(0,c.jsx)(`div`,{...R,style:{...L,width:r,height:r,background:y==null?o:void 0,border:y==null?`1px solid var(--sxl-color-base-100, white)`:void 0,borderRadius:1,boxSizing:`border-box`,...x,...D?g:void 0},children:y})};Gn.displayName=`DragHandle`;var Kn=()=>{let e=e=>{e.preventDefault(),e.stopPropagation()};return window.addEventListener(`contextmenu`,e,!0),()=>{setTimeout(()=>window.removeEventListener(`contextmenu`,e,!0),0)}},qn={tl:`leading`,l:`leading`,bl:`leading`,t:`center`,b:`center`,tr:`trailing`,r:`trailing`,br:`trailing`},Jn={tl:`leading`,t:`leading`,tr:`leading`,l:`center`,r:`center`,bl:`trailing`,b:`trailing`,br:`trailing`},Yn=(e,t,n,r)=>n===`center`?l.ReactUtils.snapDeviceEdge((e+t)/2,r):l.ReactUtils.edgeCenter(n===`leading`?e:t,n,2,r),Xn={tl:`nwse-resize`,br:`nwse-resize`,tr:`nesw-resize`,bl:`nesw-resize`,t:`ns-resize`,b:`ns-resize`,l:`ew-resize`,r:`ew-resize`},Zn=(e,t,n,r,i,a)=>{let o=e.getPanePointFromPointer(n,r),s=e.getCellFromPointer(n,r,!0)??t,c=e.getBoundsFromRange(u.CoordUtils.cellToRange(s));if(!o||!c||c.width<=0||c.height<=0)return a;let l=(o.x-c.x)/c.width,d=(o.y-c.y)/c.height,f=i??(l<.25||l>.75?u.RangeAxis.Column:u.RangeAxis.Row);return f===u.RangeAxis.Column?{axis:f,origin:{rowIndex:s.rowIndex,colIndex:l<.5?s.colIndex:s.colIndex+1}}:{axis:f,origin:{rowIndex:d<.5?s.rowIndex:s.rowIndex+1,colIndex:s.colIndex}}},Qn=(e,t)=>e===t||!!e&&!!t&&e.axis===t.axis&&u.CoordUtils.isEqualCells(e.origin,t.origin),$n=(e,t,n)=>{let r=e.rowEnd-e.rowStart,i=e.colEnd-e.colStart,a=w(t.origin.rowIndex,n.rowStart,n.rowEnd-r),o=w(t.origin.colIndex,n.colStart,n.colEnd-i);return{...e,rowStart:a,rowEnd:a+r,colStart:o,colEnd:o+i}},er=e=>{let{range:t,children:n,grip:r=`entire`,hitSize:i=10,onHoverChange:a,onDragStateChange:o,onDragStart:d,onDragMove:f,onDragEnd:p,renderMove:m,dragCursor:h=`grabbing`,preserveFocus:g,onEdgeDoubleClick:v,className:y}=e,b=W(),x=t?`range-move:${t.rowStart}:${t.colStart}:${t.rowEnd}:${t.colEnd}`:`range-move`,S=(0,s.useRef)(null),[w,T]=ve(x,null),{start:E,dragMode:D}=Un((e,n)=>{if(n.button!==0||!t)return null;n.stopPropagation(),g&&n.preventDefault();let r=e,i=t,a=i;n.clientX,n.clientY;let s=((e,t)=>e.colStart<=t.colStart&&e.colEnd>=t.colEnd?u.RangeAxis.Row:e.rowStart<=t.rowStart&&e.rowEnd>=t.rowEnd?u.RangeAxis.Column:null)(i,b.getTotalRange()),c={mods:Ln(n),insert:Zn(b,e,n.clientX,n.clientY,s,null)},l=c.insert,h=n;o?.(!0),d?.(i,n,c);let _=()=>{m&&T({range:a,info:c}),f?.(a,h,c)},v=!1;return{dragMode:`move`,drag:e=>{a=(e=>tr(i,e.rowIndex-r.rowIndex,e.colIndex-r.colIndex,b.getTotalRange()))(e),v=!0},point:(e,t,n,r)=>{r&&(h=r);let i=Zn(b,e,t,n,s,c.insert),a=v||!Qn(i,c.insert);v=!1,a&&(c={...c,insert:i},_())},modifiers:e=>{c={...c,mods:e},_()},end:e=>{o?.(!1),m&&T(null);let t=Ln(e);(!u.CoordUtils.isEqualRanges(a,i)||t.shiftKey&&!Qn(c.insert,l))&&p?.(a,e,{...c,mods:t})},cancel:()=>{o?.(!1),m&&T(null)}}}),O=Wn(!!v),k=D===null?`move`:h;if(!t)return null;let A={onPointerDown:e=>{if(O(e)){let n=(e=>{let n=b?.getPanePointFromPointer(e.clientX,e.clientY),r=b?.getBoundsFromRange(t);if(!n||!r)return null;let i=Math.abs(n.y-r.y),a=Math.abs(n.y-(r.y+r.height)),o=Math.abs(n.x-r.x),s=Math.abs(n.x-(r.x+r.width)),c=Math.min(i,a,o,s);return c===i?`top`:c===a?`bottom`:c===o?`left`:`right`})(e);n&&v(t,n,e);return}E(e,S.current)}},j=a?{onPointerEnter:()=>a(!0),onPointerLeave:()=>a(!1)}:void 0,M=i/l.ReactUtils.getDevicePixelRatio(),N=b?.getBoundsFromRange(t),P=N?{x:N.x-M,y:N.y-M,width:N.width+2*M,height:N.height+2*M}:void 0;return(0,c.jsxs)(c.Fragment,{children:[r===`entire`?(0,c.jsx)(q,{ref:S,className:C(`drag-grip`,y),...P?{bounds:P}:{range:t},style:{cursor:k},...A,...j}):(0,c.jsx)(q,{ref:S,className:C(`drag-grip`,y),range:t,clipInsets:-M/2,style:{pointerEvents:`none`,cursor:k},...A,children:(0,c.jsx)(_,{stroke:`transparent`,alignWidth:i,propsStrokePath:{cursor:`move`,pointerEvents:`stroke`,...j}})}),n,w&&m?.(w.range,w.info)]})};er.displayName=`Draggable`;var tr=(e,t,n,r)=>{let i=e.rowEnd-e.rowStart,a=e.colEnd-e.colStart,o=w(e.rowStart+t,r.rowStart,r.rowEnd-i),s=w(e.colStart+n,r.colStart,r.colEnd-a);return{rowStart:o,colStart:s,rowEnd:o+i,colEnd:s+a}},nr=[`tl`,`tr`,`br`,`bl`],rr=[`tl`,`t`,`tr`,`r`,`br`,`b`,`bl`,`l`],ir=e=>{let{range:t,anchors:n=rr,onDragStart:r,onDragMove:i,onDragEnd:a,onDragCancel:o,onHandleHoverChange:l,size:u=8,renderHandle:d,preserveFocus:f,...p}=e,m={...jn,...p},h=m.stroke??`rgb(33, 115, 70)`,g=W(),[_,v]=(0,s.useState)(null),y=(0,s.useRef)(null);if(!t)return null;let b=_??t;return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(Mn,{className:`resizer-outline`,range:b,...m}),n.map(e=>(0,c.jsx)(Gn,{className:`resize-handle ${e}`,range:b,anchor:e,size:u,animatedTransition:m.animatedTransition,dragCursor:`grabbing`,renderHandle:d,preserveFocus:f,onHoverChange:l,style:{background:h,border:`1.5px solid var(--sxl-color-base-100, white)`,borderRadius:0},hoverStyle:{border:`1.5px solid ${h}`},onDragStart:(e,n)=>{y.current=t,r?.(t,n)},onDragMove:(n,r,a)=>{let o=ar(y.current??t,e,r,g.getTotalRange());v(o),i?.(o,a)},onDragEnd:(n,r,i)=>{let o=ar(y.current??t,e,r,g.getTotalRange());y.current=null,v(null),a?.(o,i)},onDragCancel:()=>{y.current=null,v(null),o?.()}},e))]})};ir.displayName=`RangeResizer`;var ar=(e,t,n,r)=>{let{rowStart:i,colStart:a,rowEnd:o,colEnd:s}=e;return t.includes(`t`)&&(i=w(n.rowIndex,r.rowStart,r.rowEnd)),t.includes(`b`)&&(o=w(n.rowIndex,r.rowStart,r.rowEnd)),t.includes(`l`)&&(a=w(n.colIndex,r.colStart,r.colEnd)),t.includes(`r`)&&(s=w(n.colIndex,r.colStart,r.colEnd)),{rowStart:Math.min(i,o),colStart:Math.min(a,s),rowEnd:Math.max(i,o),colEnd:Math.max(a,s)}},or=(e,t,n)=>{let r=t.rowIndex-e.rowEnd,i=e.rowStart-t.rowIndex,a=t.colIndex-e.colEnd,o=e.colStart-t.colIndex,s=Math.max(r,i,0),c=Math.max(a,o,0);if(s>0||c>0)return s>=c?r>0?{...e,rowEnd:Math.min(n.rowEnd,t.rowIndex)}:{...e,rowStart:Math.max(n.rowStart,t.rowIndex)}:a>0?{...e,colEnd:Math.min(n.colEnd,t.colIndex)}:{...e,colStart:Math.max(n.colStart,t.colIndex)};let l=e.rowStart===n.rowStart&&e.rowEnd===n.rowEnd,u=e.colStart===n.colStart&&e.colEnd===n.colEnd,d=l?0:e.rowEnd-t.rowIndex,f=u?0:e.colEnd-t.colIndex;return d<=0&&f<=0?null:d>=f?{...e,rowEnd:t.rowIndex}:{...e,colEnd:t.colIndex}},sr=(e,t)=>t.rowEnd<e.rowEnd?{...e,rowStart:t.rowEnd+1}:t.colEnd<e.colEnd?{...e,colStart:t.colEnd+1}:null,cr=e=>{let{range:t,snapDestination:n,onDragStart:r,onDragMove:i,onDragEnd:a,onMenu:o,onDragDone:l,onDoubleClick:d,renderHandle:f,...p}=e,m={...jn,fill:void 0,...p},h=m.stroke,g={...m,strokeDasharray:`3 2`},_=W(),v=(0,s.useRef)(null),[y,b]=ve(`range-fill`,null);if(!t)return null;let x=_.getTotalRange(),S=t.rowStart===x.rowStart&&t.rowEnd===x.rowEnd,C=t.colStart===x.colStart&&t.colEnd===x.colEnd;if(S&&C)return null;let w=Object.keys(_.getAllPanes()).length<=1,T=_.getBoundsFromRange(t),E=_.getPaneBounds(),D=w&&T.y>=0&&T.y+T.height<=E.height,O=w&&T.x>=0&&T.x+T.width<=E.width,k=S&&!D?`tr`:C&&!O?`bl`:`br`,A=k===`tr`?`y`:k===`bl`&&`x`;if(A&&!((e,t,n,r)=>{let i=e.getAllPanes();if(Object.keys(i).length<=1)return!0;let a=e.getAnchor(),o=!!i[u.AnchorLocation.TopLeft],s=!!i[u.AnchorLocation.Top],c=!!i[u.AnchorLocation.Left],l=e.getVisibleRange();if(r){if(a===u.AnchorLocation.Top&&o||a===u.AnchorLocation.Center&&c||!u.CoordUtils.isCellWithinRange({colIndex:t.colStart,rowIndex:t.rowEnd},l)&&!u.CoordUtils.isCellWithinRange({colIndex:t.colStart,rowIndex:t.rowEnd+1},l))return!1}else if(n&&(a===u.AnchorLocation.Left&&o||a===u.AnchorLocation.Center&&s||!u.CoordUtils.isCellWithinRange({colIndex:t.colEnd,rowIndex:t.rowStart},l)&&!u.CoordUtils.isCellWithinRange({colIndex:t.colEnd+1,rowIndex:t.rowStart},l)))return!1;return!0})(_,t,S,C))return null;let j=y?sr(t,y):null;return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(Gn,{className:`fill-handle`,range:t,anchor:k,clampToView:A,cursor:`crosshair`,background:h,renderHandle:f,onDoubleClick:d?e=>d(t,e):void 0,secondaryButton:!!o,onDragStart:(e,n)=>{v.current=null,b(null),r?.(t,n)},onDragMove:(e,r,a)=>{let o=or(t,r,_.getTotalRange());o&&n&&(o=n(t,o)),v.current=o,b(o),o&&i?.(o,a)},onDragEnd:(e,t,n)=>{let r=v.current;v.current=null,r&&n.button===2&&o?o(r,n,()=>b(null)):(b(null),r&&a?.(r,n)),l?.(n)},onDragCancel:()=>{v.current=null,b(null),l?.()}}),y&&(0,c.jsx)(Mn,{className:`fill-preview`,range:y,...g}),j&&(0,c.jsx)(Mn,{className:`fill-vacated`,range:j,fill:`rgba(128, 128, 128, 0.28)`})]})};cr.displayName=`FillHandle`;var lr=(0,s.memo)(e=>{let{value:t,zoom:n,bounds:r,cell:i,range:a,children:o,className:s,...l}=e;return(0,c.jsx)(`div`,{className:C(s,`cell`),...l,children:t})}),ur=Object.freeze({cells:[],rangesH:[],rangesV:[]}),dr=!1,fr=new WeakMap,pr=(e,t={})=>{let n=e.getVisibleRange(),r=e.getScrollTopLeft(),i=t.bufferRange,a=!!i,o=i?i.rowStart:0,s=i?i.colStart:0,c=i?i.rowEnd:0,l=i?i.colEnd:0,d=fr.get(e);if(d&&d.rowStart===n.rowStart&&d.colStart===n.colStart&&d.rowEnd===n.rowEnd&&d.colEnd===n.colEnd&&d.scrollLeft===r.left&&d.scrollTop===r.top&&d.hasBuffer===a&&d.bRowStart===o&&d.bColStart===s&&d.bRowEnd===c&&d.bColEnd===l&&d.options.cacheToken===t.cacheToken&&d.options.getVisibleCells===t.getVisibleCells&&d.options.hiddenCellAt===t.hiddenCellAt)return d.model;let f=((e,t={})=>{let{getVisibleCells:n,hiddenCellAt:r,bufferRange:i}=t,a=e.getTotalRange(),o=i?{rowStart:Math.max(i.rowStart,a.rowStart),rowEnd:Math.min(i.rowEnd,a.rowEnd),colStart:Math.max(i.colStart,a.colStart),colEnd:Math.min(i.colEnd,a.colEnd)}:null,s=o?e.getVisibleColumns(o.colStart,o.colEnd):e.getVisibleColumns(),c=o?e.getVisibleRows(o.rowStart,o.rowEnd):e.getVisibleRows();if(s.length===0||c.length===0)return ur;let l=t=>e.getRangeFromCell(t),d;if(n)d=n(e,i);else{d=[];let e=c.length,t=s.length;for(let n=0;n<e;n++){let e=c[n].index;for(let n=0;n<t;n++){let t={rowIndex:e,colIndex:s[n].index},i=l(t);u.CoordUtils.isSingleCell(i)&&r?.(t)||d.push({cell:t,range:i})}}}let f=d?d.length:0;if(f===0)return ur;let p=e.getVisibleRange(),m=i??p,h=[],g=[],_=[],v=new Set;for(let t=0;t<f;t++){let n=d[t],i=n?.cell??n;if(!i)continue;let a=n?.range??{rowStart:i.rowIndex,colStart:i.colIndex,rowEnd:i.rowIndex,colEnd:i.colIndex};if(!u.CoordUtils.isRangesIntersect(a,m)&&!u.CoordUtils.isRangeWithinRange(a,m))continue;let o=a&&!u.CoordUtils.isSingleCell(a);if(!o&&r?.(i))continue;let s=null;if(o){let t=l(i);u.CoordUtils.isSingleCell(t)||i.rowIndex===t.rowStart&&i.colIndex===t.colStart||(i={rowIndex:t.rowStart,colIndex:t.colStart});let n=_r(a.rowStart,a.colStart);if(v.has(n))continue;v.add(n),a.rowEnd-a.rowStart>0&&g.push(a),a.colEnd-a.colStart>0&&_.push(a),s=e.getBoundsFromRange(a)}else{let t=e.getRowSize(i.rowIndex),n=e.getColumnSize(i.colIndex);t&&n&&(s={x:n.offset,y:t.offset,width:n.size,height:t.size})}s||=e.getBoundsFromRange(a),s?h.push({cell:i,range:a,bounds:s,value:n?.value}):dr||(dr=!0,console.warn(`grid-react: no bounds for cell`,_r(a.rowStart,a.colStart)))}return{cells:h,rangesH:g,rangesV:_}})(e,t);return fr.set(e,{rowStart:n.rowStart,colStart:n.colStart,rowEnd:n.rowEnd,colEnd:n.colEnd,scrollLeft:r.left,scrollTop:r.top,hasBuffer:a,bRowStart:o,bColStart:s,bRowEnd:c,bColEnd:l,options:t,model:f}),f},mr=Object.freeze({rangesH:[],rangesV:[]}),hr=new WeakMap,gr=(e,t={})=>{let n=e.getVisibleRange(),r=hr.get(e);if(r&&r.rowStart===n.rowStart&&r.colStart===n.colStart&&r.rowEnd===n.rowEnd&&r.colEnd===n.colEnd&&r.cacheToken===t.cacheToken&&r.getVisibleCells===t.getVisibleCells)return r.ranges;let i=((e,t={})=>{let{getVisibleCells:n}=t,r=e.getVisibleRange(),i=[],a=[],o=new Set,s=e=>{if(u.CoordUtils.isSingleCell(e)||!u.CoordUtils.isRangesIntersect(e,r)&&!u.CoordUtils.isRangeWithinRange(e,r))return;let t=_r(e.rowStart,e.colStart);o.has(t)||(o.add(t),e.rowEnd-e.rowStart>0&&i.push(e),e.colEnd-e.colStart>0&&a.push(e))};if(n){let t=n(e),r=t?t.length:0;for(let e=0;e<r;e++){let n=t[e]?.range;n&&s(n)}}else{let t=e.getVisibleColumns(),n=e.getVisibleRows(),r=n.length,i=t.length;for(let a=0;a<r;a++){let r=n[a].index;for(let n=0;n<i;n++)s(e.getRangeFromCell({rowIndex:r,colIndex:t[n].index}))}}return i.length===0&&a.length===0?mr:{rangesH:i,rangesV:a}})(e,t);return hr.set(e,{rowStart:n.rowStart,colStart:n.colStart,rowEnd:n.rowEnd,colEnd:n.colEnd,getVisibleCells:t.getVisibleCells,cacheToken:t.cacheToken,ranges:i}),i},_r=(e,t)=>`${e}:${t}`,vr={tiles:`_tiles_ikr1b_7`,gridlines:`_gridlines_ikr1b_26`},yr=(0,s.memo)(e=>{let{renderCell:t,cacheToken:n,getVisibleCells:r,hiddenCellAt:i,suppressCell:a,className:o,style:l}=e,u=W(),d=u.getAnchor(),f=(0,s.useId)(),p=(0,s.useMemo)(()=>`sxl-cl-${f.replace(/[^a-zA-Z0-9_-]/g,``)}`,[f]),m=(0,s.useRef)({token:void 0,renderCell:void 0,getVisibleCells:void 0,hiddenCellAt:void 0,pane:null,rebaseLeft:0,rebaseTop:0,map:new Map}),h=u.getScrollTopLeft(),g=u.getFreezeTopLeft(),_=h.left+g.left,v=h.top+g.top,y=Math.floor(_/xr)*xr,b=Math.floor(v/xr)*xr,x=u.getVisibleRange(),S=0,w=-1,T=0,E=-1;x&&(S=Math.max(0,Math.floor(x.rowStart/$)-Sr),w=Math.floor(x.rowEnd/$)+Sr,T=Math.max(0,Math.floor(x.colStart/$)-Sr),E=Math.floor(x.colEnd/$)+Sr);let D=(0,s.useMemo)(()=>{if(!x||w<S)return null;let e=m.current;e.token===n&&e.pane===u&&e.renderCell===t&&e.getVisibleCells===r&&e.hiddenCellAt===i&&e.rebaseLeft===y&&e.rebaseTop===b||(e.map=new Map,e.token=n,e.pane=u,e.renderCell=t,e.getVisibleCells=r,e.hiddenCellAt=i,e.rebaseLeft=y,e.rebaseTop=b);let a=e.map,o=u.getZoom(),s=u.getTotalRange(),l={rowStart:Math.max(s.rowStart,S*$),colStart:Math.max(s.colStart,T*$),rowEnd:Math.min(s.rowEnd,(w+1)*$-1),colEnd:Math.min(s.colEnd,(E+1)*$-1)},{cells:f}=pr(u,{getVisibleCells:r,hiddenCellAt:i,bufferRange:l,cacheToken:n}),p=new Map;for(let e=0;e<f.length;e++){let t=f[e],n=`${Math.floor(t.cell.rowIndex/$)}:${Math.floor(t.cell.colIndex/$)}`,r=p.get(n);r||(r=[],p.set(n,r)),r.push(t)}let h=[],g=(e,n)=>{if(e*$>s.rowEnd||n*$>s.colEnd)return;let r=e>=S&&e<=w&&n>=T&&n<=E,i=`${e}:${n}`,l=a.get(i);if(l===void 0){let f=p.get(i);if(!f&&!wr)return;let m=u.getBoundsFromRange({rowStart:e*$,colStart:n*$,rowEnd:Math.min(s.rowEnd,e*$+$-1),colEnd:Math.min(s.colEnd,n*$+$-1)}),h=_+m.x-y,g=v+m.y-b,x=[];if(wr&&x.push((0,c.jsx)(`div`,{style:{position:`absolute`,left:0,top:0,width:m.width,height:m.height,background:(e+n)%2==0?`rgba(0,128,255,0.05)`:`rgba(255,140,0,0.05)`,pointerEvents:`none`}},`__bg`)),f)for(let e=0;e<f.length;e++){let{cell:n,range:r,bounds:i,value:a}=f[e];i&&x.push(t({key:`pane:${d}:cell:${_r(n.rowIndex,n.colIndex)}`,cell:n,bounds:i,range:r,zoom:o,value:a,"data-rc":_r(n.rowIndex,n.colIndex),style:{left:i.x-m.x,top:i.y-m.y,width:i.width,height:i.height}}))}if(l=(0,c.jsx)(`div`,{className:`tile`,style:{transform:`translate(${h}px, ${g}px)`},children:x},`pane:${d}:tile:${e}:${n}`),r&&(a.set(i,l),a.size>Cr)){let e=a.keys().next().value;e!==void 0&&a.delete(e)}}l&&h.push(l)};if(wr){for(let e=S;e<=w&&!(e*$>s.rowEnd);e++)for(let t=T;t<=E&&!(t*$>s.colEnd);t++)g(e,t);for(let e of p.keys()){let t=e.indexOf(`:`),n=Number(e.slice(0,t)),r=Number(e.slice(t+1));(n<S||n>w||r<T||r>E)&&g(n,r)}}else for(let e of p.keys()){let t=e.indexOf(`:`);g(Number(e.slice(0,t)),Number(e.slice(t+1)))}return h},[`${S}:${w}:${T}:${E}`,n,t,r,i,u,d,y,b]);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(q,{fill:!0,className:C(`tiles`,vr.tiles,p,o),style:{pointerEvents:`none`,...l,transform:`translate3d(${y-_}px, ${b-v}px, 0)`,willChange:`transform`},children:D}),a?(0,c.jsx)(`style`,{children:`.${p} [data-rc="${_r(a.rowIndex,a.colIndex)}"]{visibility:hidden !important;}`}):null]})});yr.displayName=`CellTileDiv`;var br=(0,s.memo)(e=>{let{renderCell:t,cacheToken:n,getVisibleCells:r,hiddenCellAt:i,suppressCell:a,className:o,style:s,...l}=e;return(0,c.jsx)(ye,{className:C(o,`cells`),...l,children:(0,c.jsx)(yr,{renderCell:t,cacheToken:n,getVisibleCells:r,hiddenCellAt:i,suppressCell:a,style:s})})});br.displayName=`CellLayer`;var $=8,xr=1<<19,Sr=1,Cr=512,wr=!1,Tr=(e,t,n)=>{let r=l.ReactUtils.getDevicePixelRatio(),i=kr/r,a=e.getVisibleRange(),o=t=>e.getColumnSize(t).offset,s=t=>{let n=e.getColumnSize(t);return n.offset+n.size},c=t=>e.getRowSize(t).offset,d=t=>{let n=e.getRowSize(t);return n.offset+n.size},f=[],p=[],m=!1,h=``;if(t){let t=e.getVisibleRows(),c=t?t.length:0;if(c===0)return h;let g=[...n].sort(u.CoordUtils.rowFirstRangeComparator),_=l.ReactUtils.snapDeviceEdge(0,r),v=Math.min(e.getPaneBounds().width,s(a.colEnd)),y=l.ReactUtils.snapDeviceEdge(v,r);for(let e=0;e<c&&t[e].index<=a.rowEnd;e++){let n=t[e],c=n.index;if(c<a.rowStart)continue;let b=n.offset+n.size;for(let e=f.length-1;e>=0;e--)d(f[e].rowEnd)<=b&&(f.splice(e,1),m=!1);let x=!1;for(;g.length>0&&g[0].rowStart<=c;){let e=g.shift();d(e.rowEnd)>b&&(f.push(e),x=!0,m=!1)}if(x&&f.sort(u.CoordUtils.columnFirstRangeComparator),!m){p.length=0;for(let e=0;e<f.length;e++){let t=f[e];p.push(l.ReactUtils.snapDeviceEdge(Math.min(v,o(t.colStart)),r),l.ReactUtils.snapDeviceEdge(Math.min(v,s(t.colEnd)),r))}m=!0}let S=l.ReactUtils.snapLineCenter(b,i,r),C=_,w=p.length;for(let e=0;e<w;e+=2){let t=p[e];t>C&&(h+=`M ${C} ${S} L ${t} ${S} `),C=p[e+1]}y>C&&(h+=`M ${C} ${S} L ${y} ${S} `)}}else{let t=e.getVisibleColumns(),o=t?t.length:0;if(o===0)return h;let g=[...n].sort(u.CoordUtils.columnFirstRangeComparator),_=l.ReactUtils.snapDeviceEdge(0,r),v=Math.min(e.getPaneBounds().height,d(a.rowEnd)),y=l.ReactUtils.snapDeviceEdge(v,r);for(let e=0;e<o&&t[e].index<=a.colEnd;e++){let n=t[e],o=n.index;if(o<a.colStart)continue;let b=n.offset+n.size;for(let e=f.length-1;e>=0;e--)s(f[e].colEnd)<=b&&(f.splice(e,1),m=!1);let x=!1;for(;g.length>0&&g[0].colStart<=o;){let e=g.shift();s(e.colEnd)>b&&(f.push(e),x=!0,m=!1)}if(x&&f.sort(u.CoordUtils.rowFirstRangeComparator),!m){p.length=0;for(let e=0;e<f.length;e++){let t=f[e];p.push(l.ReactUtils.snapDeviceEdge(Math.min(v,c(t.rowStart)),r),l.ReactUtils.snapDeviceEdge(Math.min(v,d(t.rowEnd)),r))}m=!0}let S=l.ReactUtils.snapLineCenter(b,i,r),C=_,w=p.length;for(let e=0;e<w;e+=2){let t=p[e];t>C&&(h+=`M ${S} ${C} L ${S} ${t} `),C=p[e+1]}y>C&&(h+=`M ${S} ${C} L ${S} ${y} `)}}return h},Er=e=>{let t=``;for(let n=0;n<e.length;n++){let r=e[n];t+=`${r.rowStart},${r.colStart},${r.rowEnd},${r.colEnd};`}return t},Dr=(e,t,n,r,i)=>{if(!n)return null;let a=e.getPaneBounds(),o=Math.ceil(a.width),s=Math.ceil(a.height),u=String(kr/l.ReactUtils.getDevicePixelRatio());return(0,c.jsx)(`svg`,{className:C(t?`horizontal`:`vertical`),width:`${o}`,height:`${s}`,viewBox:`0 0 ${o} ${s}`,preserveAspectRatio:`none`,children:(0,c.jsx)(`path`,{d:n,fill:`none`,stroke:r,strokeWidth:u,vectorEffect:`non-scaling-stroke`,...i})})},Or=(0,s.memo)(e=>{let{showGridLines:t=!0,gridLineColor:n=`var(--sxl-color-base-300, rgb(224, 224, 224))`,propsRows:r,propsColumns:i,getVisibleCells:a,hiddenCellAt:o,cacheToken:u,bufferRange:d,className:f,style:p,...m}=e,h=W(),g=t,_=!0===t||!0===g?.horizontal,v=!0===t||!0===g?.vertical,{rangesH:y,rangesV:b}=gr(h,{getVisibleCells:a,cacheToken:u}),x=l.ReactUtils.getDevicePixelRatio(),{top:S,left:w}=h.getScrollTopLeft(),T=h.getPaneBounds(),E=h.getVisibleRange(),D=h.getColumnSize(E.colEnd),O=h.getRowSize(E.rowEnd),k=Math.min(T.width,D?D.offset+D.size:T.width),A=Math.min(T.height,O?O.offset+O.size:T.height),j=y.length===0?`${S}|${k}|${x}`:`${S}|${w}|${k}|${x}|${Er(y)}`,M=b.length===0?`${w}|${A}|${x}`:`${w}|${S}|${A}|${x}|${Er(b)}`,N=(0,s.useMemo)(()=>_?Tr(h,!0,y):null,[h,_,j]),P=(0,s.useMemo)(()=>v?Tr(h,!1,b):null,[h,v,M]);return _||v?(0,c.jsx)(ye,{...m,className:C(f,`gridlines`),children:(0,c.jsxs)(q,{fill:!0,className:C(`gridlines-box`,vr.gridlines),style:{pointerEvents:`none`,...p},children:[_&&N?Dr(h,!0,N,n,r):null,v&&P?Dr(h,!1,P,n,i):null]})}):null});Or.displayName=`GridlineLayer`;var kr=1,Ar=class{constructor(e={}){this.listeners=new Set,this._coords=e.initial??{cell:{rowIndex:0,colIndex:0},ranges:u.CoordUtils.EmptyRanges,rangeIndex:-1},this._getBounds=e.getBounds??(()=>Nr)}getSelection(){return this._coords}setSelection(e){u.CoordUtils.isEqualSelectionCoords(this._coords,e)||(this._coords=e,this.listeners.forEach(e=>e()))}navigate(e,t=!1,n=!1,r=1){let i=this._getBounds(),{cell:a}=this._coords,o=e===u.Direction.Down?1:e===u.Direction.Up?-1:0,s=e===u.Direction.Right?1:e===u.Direction.Left?-1:0,c=e=>e===0?0:n?e>0?1/0:-1/0:e*Math.max(1,r),l=this._activeRange(),d=t?a.rowIndex===l.rowStart?l.rowEnd:l.rowStart:a.rowIndex,f=t?a.colIndex===l.colStart?l.colEnd:l.colStart:a.colIndex,p=w(d+c(o),i.rowStart,i.rowEnd),m=w(f+c(s),i.colStart,i.colEnd);if(!t)return void this.setSelection({cell:{rowIndex:p,colIndex:m},ranges:u.CoordUtils.EmptyRanges,rangeIndex:-1});let h={rowStart:Math.min(a.rowIndex,p),colStart:Math.min(a.colIndex,m),rowEnd:Math.max(a.rowIndex,p),colEnd:Math.max(a.colIndex,m)};this.setSelection({cell:a,ranges:[h],rangeIndex:0})}traverse(e=u.RangeAxis.Row,t=!1,n){let r=e===u.RangeAxis.Row?t?u.Direction.Left:u.Direction.Right:t?u.Direction.Up:u.Direction.Down,i=this._coords;if(!(i.ranges&&i.ranges.length>0)||u.CoordUtils.isEqualRangesArrays([u.CoordUtils.cellToRange(i.cell)],i.ranges)){if(n&&!u.CoordUtils.isSingleCell(n)){let e=u.SelectionTraversalUtils.findNextCellWithinSelection({ranges:[n],cell:i.cell,rangeIndex:0},r,e=>u.CoordUtils.cellToRange(e));this.setSelection({cell:e.cell,ranges:u.CommonUtils.EmptyArray,rangeIndex:-1});return}this.navigate(r);return}let a=u.SelectionTraversalUtils.findNextCellWithinSelection(i,r,e=>u.CoordUtils.cellToRange(e));this.setSelection(a)}_activeIndex(){let{ranges:e,rangeIndex:t}=this._coords;return e&&e.length!==0?t!==void 0&&t>=0&&t<e.length?t:e.length-1:-1}_activeRange(){let e=this._activeIndex();return e>=0?this._coords.ranges[e]:u.CoordUtils.cellToRange(this._coords.cell)}modify(e,t=this._coords.cell){let n=this._activeRange(),r=jr({rowStart:Math.min(e.rowIndex??n.rowStart,t.rowIndex??n.rowStart),colStart:Math.min(e.colIndex??n.colStart,t.colIndex??n.colStart),rowEnd:Math.max(e.rowIndex??n.rowEnd,t.rowIndex??n.rowEnd),colEnd:Math.max(e.colIndex??n.colEnd,t.colIndex??n.colEnd)},this._getBounds()),i=this._coords,a=this._activeIndex(),o=a>=0?i.ranges.map((e,t)=>t===a?r:e):[r],s=Mr(i.cell,r);this.setSelection({cell:s,ranges:o,rangeIndex:a>=0?a:0})}append(e,t=e){let n=jr({rowStart:Math.min(e.rowIndex,t.rowIndex),colStart:Math.min(e.colIndex,t.colIndex),rowEnd:Math.max(e.rowIndex,t.rowIndex),colEnd:Math.max(e.colIndex,t.colIndex)},this._getBounds()),r=this._coords,i=r.ranges&&r.ranges.length>0?[...r.ranges]:[u.CoordUtils.cellToRange(r.cell)];i.push(n),this.setSelection({ranges:i,rangeIndex:i.length-1,cell:{rowIndex:n.rowStart,colIndex:n.colStart}})}deselect(e){let t=this._coords;if(!t.ranges||t.ranges.length===0)return;let n=[],r=-1,i=t.cell;for(let a of t.ranges){if(!u.CoordUtils.isRangesIntersect(a,e)){n.push(a),r===-1&&u.CoordUtils.isCellWithinRange(t.cell,a)&&(r=n.length-1);continue}let o=n.length,s=u.CommonUtils.subtractRect({top:a.rowStart,left:a.colStart,bottom:a.rowEnd+1,right:a.colEnd+1},{top:e.rowStart,left:e.colStart,bottom:e.rowEnd+1,right:e.colEnd+1});for(let e of s){let i={rowStart:e.top,colStart:e.left,rowEnd:e.bottom-1,colEnd:e.right-1};n.push(i),r===-1&&u.CoordUtils.isCellWithinRange(t.cell,i)&&(r=n.length-1)}if(r===-1&&n.length>o&&u.CoordUtils.isCellWithinRange(t.cell,a)){r=n.length-1;let e=n[n.length-1];i={rowIndex:e.rowStart,colIndex:e.colStart}}}if(r===-1&&n.length>0&&t.ranges.some(e=>u.CoordUtils.isCellWithinRange(t.cell,e))){r=n.length-1;let e=n[r];i={rowIndex:e.rowStart,colIndex:e.colStart}}this.setSelection({cell:i,rangeIndex:r,ranges:n})}getCoords(){return this._coords.cell}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}},jr=(e,t)=>({rowStart:w(e.rowStart,t.rowStart,t.rowEnd),colStart:w(e.colStart,t.colStart,t.colEnd),rowEnd:w(e.rowEnd,t.rowStart,t.rowEnd),colEnd:w(e.colEnd,t.colStart,t.colEnd)}),Mr=(e,t)=>({rowIndex:w(e.rowIndex,t.rowStart,t.rowEnd),colIndex:w(e.colIndex,t.colStart,t.colEnd)}),Nr={rowStart:0,colStart:0,rowEnd:2**53-1,colEnd:2**53-1},Pr=`var(--sxl-color-primary, rgb(33, 115, 70))`,Fr=`var(--sxl-color-base-100, rgb(255, 255, 255))`,Ir=`var(--sxl-color-warning, rgb(255, 0, 0))`,Lr=e=>`color-mix(in srgb, var(--sxl-color-primary, rgb(33, 115, 70)) ${e}%, transparent)`,Rr={fill:{fill:Lr(10)},border:{stroke:Pr,alignWidth:2,style:{filter:`drop-shadow(1px 1px 0.3px var(--sxl-color-shadow, rgba(0, 0, 0, 0.24)))`}},inner:{stroke:Fr,alignWidth:2,inset:1}},zr={fill:{fill:Lr(6)},border:{stroke:Pr,alignWidth:1},inner:{stroke:Fr,alignWidth:1,inset:1}},Br={stroke:Pr,alignWidth:1,inset:2},Vr={fill:{fill:`color-mix(in srgb, ${Ir} 10%, transparent)`},border:{stroke:Ir,alignWidth:2}},Hr={color:Pr,refusedColor:Ir,alignWidth:3,capExtent:3,transitionDuration:100,transitionEasing:`cubic-bezier(0.16, 1, 0.3, 1)`,axisDuration:70},Ur={fill:{fill:`color-mix(in srgb, ${Fr} 62%, transparent)`}},Wr=(e,t)=>{let n=W(),r=t?.allowDeselect??!0,i=t?.allowMulti??!0,a=(0,s.useRef)(null),[o,c]=(0,s.useState)(null),l=(0,s.useRef)(t?.onSelectionEnd);l.current=t?.onSelectionEnd;let d=Hn((t,o)=>{if(o.pointerType===`touch`){let t=n.getScrollTopLeft(),r={x:o.clientX,y:o.clientY};return{capture:!1,drag:()=>{},end:i=>{let a=n.getScrollTopLeft();if(a.left===t.left&&a.top===t.top){let t=n.getCellFromPointer(r.x,r.y);t&&e.setSelection({cell:t,ranges:u.CoordUtils.EmptyRanges,rangeIndex:-1})}l.current?.(i)}}}if(o.button===2){let n=e.getSelection();return u.CoordUtils.isEqualCells(n.cell,t)||n.ranges&&n.ranges.some(e=>u.CoordUtils.isCellWithinRange(t,e))||e.setSelection({cell:t,ranges:u.CoordUtils.EmptyRanges,rangeIndex:-1}),null}if(o.button!==0)return null;o.stopPropagation();let s=e=>l.current?.(e),d=e.getSelection(),f=()=>e.setSelection(d);if(o.shiftKey)return e.modify(t),{dragMode:`extend`,drag:t=>e.modify(t),end:s,cancel:f};if((o.ctrlKey||o.metaKey)&&i){let i=e.getSelection().ranges,o=!!i&&i.some(e=>u.CoordUtils.isCellWithinRange(t,e));return r&&o?(a.current=u.CoordUtils.cellToRange(t),c(a.current),{dragMode:`remove`,drag:e=>{a.current=((e,t)=>{let r=n.getTotalRange();return{rowStart:Math.max(r.rowStart,Math.min(e.rowIndex,t.rowIndex)),colStart:Math.max(r.colStart,Math.min(e.colIndex,t.colIndex)),rowEnd:Math.min(r.rowEnd,Math.max(e.rowIndex,t.rowIndex)),colEnd:Math.min(r.colEnd,Math.max(e.colIndex,t.colIndex))}})(t,e),c(a.current)},end:t=>{let n=a.current;a.current=null,c(null),n&&e.deselect(n),s(t)},cancel:()=>{a.current=null,c(null)}}):(e.append(t),{dragMode:`extend`,drag:t=>e.modify(t),end:s,cancel:f})}return e.setSelection({cell:t,ranges:u.CoordUtils.EmptyRanges,rangeIndex:-1}),{dragMode:`extend`,drag:t=>e.modify(t),end:s,cancel:f}});return{onPointerDown:d.onPointerDown,onPointerMove:d.onPointerMove,onPointerUp:d.onPointerUp,removePreview:o,dragMode:d.dragMode}},Gr=e=>{let{selection:t,color:n=`var(--sxl-color-primary, rgb(33, 115, 70))`,size:r=22}=e,i=G(),a=Jr((0,l.useBoundSyncExternalStore)(t,e=>e.getSelection())),o=i?i.getAllPanes()[u.AnchorLocation.Center]??i:void 0,d=((e,t,n)=>{let r=!!t&&e.rowStart===t.rowStart&&e.rowEnd===t.rowEnd,i=!!t&&e.colStart===t.colStart&&e.colEnd===t.colEnd;if(r&&i)return[];if(r){let t=n?Math.floor((n.rowStart+n.rowEnd)/2):e.rowStart;return[{key:`l`,placement:{side:`l`,align:`center`},cell:{rowIndex:t,colIndex:e.colStart},pivot:{colIndex:e.colEnd},axis:`col`,pin:`v`},{key:`r`,placement:{side:`r`,align:`center`},cell:{rowIndex:t,colIndex:e.colEnd},pivot:{colIndex:e.colStart},axis:`col`,pin:`v`}]}if(i){let t=n?Math.floor((n.colStart+n.colEnd)/2):e.colStart;return[{key:`t`,placement:{side:`t`,align:`center`},cell:{rowIndex:e.rowStart,colIndex:t},pivot:{rowIndex:e.rowEnd},axis:`row`,pin:`h`},{key:`b`,placement:{side:`b`,align:`center`},cell:{rowIndex:e.rowEnd,colIndex:t},pivot:{rowIndex:e.rowStart},axis:`row`,pin:`h`}]}return[{key:`tl`,placement:{side:`t`,align:`start`},cell:{rowIndex:e.rowStart,colIndex:e.colStart},pivot:{rowIndex:e.rowEnd,colIndex:e.colEnd},axis:`both`},{key:`br`,placement:{side:`b`,align:`end`},cell:{rowIndex:e.rowEnd,colIndex:e.colEnd},pivot:{rowIndex:e.rowStart,colIndex:e.colStart},axis:`both`}]})(a,i?.getTotalRange(),o?.getVisibleRange()),[f,p]=(0,s.useState)(!1),m=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>m.current?.dispose(),[]);let h=(e,n,r,i)=>{m.current?.dispose();let a=r===`col`?{x:!0,y:!1}:r===`row`?{x:!1,y:!0}:{x:!0,y:!0},o=t.getSelection(),s=Vn(e,()=>(p(!0),{dragMode:`grip`,drag:e=>{let i=r===`col`?{colIndex:e.colIndex}:r===`row`?{rowIndex:e.rowIndex}:e;t.modify(i,n)},edgeScroll:t=>Fn(e,t,a),end:()=>p(!1),cancel:()=>{t.setSelection(o),p(!1)}}),void 0,(t,n)=>(e.getPaneFromPointer(t,n)??e).getCellFromPointer(t,n));m.current=s,s.start(i,i.currentTarget)};return(0,c.jsx)(c.Fragment,{children:d.map(e=>(0,c.jsx)(Kr,{spec:e,size:r,color:n,dragging:f,onBeginDrag:h},e.key))})};Gr.displayName=`SelectionTouchGrips`;var Kr=e=>{let{spec:t,size:n,color:r,dragging:i,onBeginDrag:a}=e;return(0,c.jsx)(Pe,{anchor:{cell:t.cell},placement:t.placement,whenOff:`hide`,children:e=>e.slid?null:(0,c.jsx)(qr,{state:e,size:n,color:r,dragging:i,pin:t.pin,onBeginDrag:n=>{e.pane&&a(e.pane,t.pivot,t.axis,n)}})})},qr=e=>{let{state:t,size:n,color:r,dragging:i,pin:a,onBeginDrag:o}=e,{getPortalContainer:u}=(0,l.useFullscreenPortal)(),{className:f,attrs:p}=sn(t.pane),m=(0,s.useRef)({state:t,pin:a});m.current={state:t,pin:a};let h=(0,s.useMemo)(()=>({get contextElement(){return m.current.state.reference.contextElement},getBoundingClientRect:()=>{let{state:e,pin:t}=m.current,{x:n,y:r}=e.getAnchorPoint();if(t){let i=e.pane?.getElement()?.getBoundingClientRect();i&&(t===`v`?r=i.top+i.height/2:n=i.left+i.width/2)}return{x:n,y:r,width:0,height:0,top:r,left:n,right:n,bottom:r}}}),[]),g=(0,s.useMemo)(()=>[rn(({rects:e})=>-e.floating.height/2)],[]),{refs:_,floatingStyles:v,update:y}=nn({placement:`bottom`,strategy:`fixed`,elements:{reference:h},whileElementsMounted:Kt,middleware:g});return(0,s.useLayoutEffect)(()=>{y()},[t,y]),(0,d.createPortal)((0,c.jsx)(`div`,{ref:_.setFloating,className:[`touch-select-grip`,f].filter(Boolean).join(` `),...p,style:{...v,width:n,height:n,background:`var(--sxl-color-base-100, white)`,border:`3px solid ${r}`,borderRadius:`50%`,boxShadow:`0 0 0 1.5px var(--sxl-color-base-100, white)`,cursor:`grab`,touchAction:`none`,zIndex:1250,opacity:+!i,pointerEvents:i?`none`:`all`,transition:`opacity 160ms`},onPointerDown:e=>{e.button!==0&&e.pointerType!==`touch`||t.pane&&(e.preventDefault(),e.stopPropagation(),o(e))}}),u())},Jr=e=>{let{ranges:t,rangeIndex:n,cell:r}=e;if(t&&t.length>0){let e=n??-1;return t[e>=0?e:t.length-1]}return u.CoordUtils.cellToRange(r)},Yr=[u.Direction.Left,u.Direction.Right,u.Direction.Up,u.Direction.Down],Xr={[u.Direction.Left]:`ArrowLeft`,[u.Direction.Right]:`ArrowRight`,[u.Direction.Up]:`ArrowUp`,[u.Direction.Down]:`ArrowDown`},Zr={[u.Direction.Left]:`Left`,[u.Direction.Right]:`Right`,[u.Direction.Up]:`Up`,[u.Direction.Down]:`Down`},Qr=(e,t)=>t===void 0?e:t===null?null:{...e,...t},$r=(e,t)=>t?{fill:Qr(e.fill,t.fill),border:Qr(e.border,t.border),inner:Qr(e.inner,t.inner)}:e,ei={side:`b`,align:`end`},ti=s.default.forwardRef((e,t)=>{let{selection:n,getContentBounds:r,getRegionBounds:i,scrollIntoView:a,singleStyle:o,multiStyle:d,multiAnchorStyle:f,singleAnchorStyle:p,removePreviewStyle:m,insertBarStyle:h,isDropRefused:g,moveSourceStyle:_,singleLayer:v,multiLayer:y,enabledMove:b,onMove:x,onMoveStart:S,onMoveUpdate:C,onMoveEnd:w,moveCursor:T,enableFill:E,snapFillDestination:D,onFill:O,onFillStart:k,onFillPreview:A,onFillEnd:j,onFillMenu:M,resolveFillExtent:N,onEdgeDoubleClick:P,onSelectionEnd:F,onDragModeChange:I,renderTip:L,tipPlacement:R,disableKeyboard:ee,anchorHole:te=!0,...ne}=e,re=(0,l.useBoundSyncExternalStore)(n,e=>e.getSelection()),z=Wr(n,{onSelectionEnd:F}),ie=s.default.useRef(I);ie.current=I,s.default.useEffect(()=>{ie.current?.(z.dragMode)},[z.dragMode]);let[B,ae]=s.default.useState(null),V=W(),oe=s.default.useRef(n);oe.current=n;let se=s.default.useRef(V);se.current=V;let ce=s.default.useRef(r);ce.current=r;let H=s.default.useRef(i);H.current=i;let le=s.default.useRef(a);le.current=a;let ue=s.default.useMemo(()=>function(e){let{getSelection:t,getPane:n,getContentBounds:r,getScrollIntoView:i=()=>{},getRegionBounds:a=()=>null}=e,o=()=>t(),s=()=>n(),c=()=>s().getTotalRange(),d=r??c,f=e=>a(e),p=e=>{let t=i();t?t(e):s().scrollCellCoordsIntoView(e)},m=()=>p(o().getSelection().cell),h=()=>{let e=o().getSelection();return e.ranges&&e.ranges.length>0&&e.rangeIndex!==void 0&&e.rangeIndex>=0?e.ranges[e.rangeIndex]:u.CoordUtils.cellToRange(e.cell)},g=(e,t,n=!1)=>{if(o().navigate(e,t,n),i())return;let r=o().getSelection(),a=e===u.Direction.Left||e===u.Direction.Right;if(t){let t=c(),n=h(),i=r.cell.colIndex===n.colStart?n.colEnd:n.colStart,o=r.cell.rowIndex===n.rowStart?n.rowEnd:n.rowStart;if(e===u.Direction.Right&&i===t.colEnd||e===u.Direction.Left&&i===t.colStart||e===u.Direction.Up&&o===t.rowStart||e===u.Direction.Down&&o===t.rowEnd)return;p(a?{colIndex:i}:{rowIndex:o});return}p(a?{colIndex:r.cell.colIndex}:{rowIndex:r.cell.rowIndex})},_=(e,t)=>{let n=s(),r=n.getMetrics(),i=c(),a=n.getSurfaceSize(),l=n.getScrollTopLeft(),d=n.getScrollTarget?.()??l,f=h(),p=o().getSelection().cell,m=t?p.rowIndex===f.rowStart?f.rowEnd:f.rowStart:p.rowIndex,g=t?p.colIndex===f.colStart?f.colEnd:f.colStart:p.colIndex,_=m,v=g,y=null;switch(e){case u.Direction.Up:{let e=r.getRowOffset(m+1);_=Math.max(i.rowStart,r.getRowIndex(e-a.height)),y={top:r.getRowOffset(_+1)-(e-d.top)};break}case u.Direction.Down:{let e=r.getRowOffset(m);_=Math.min(i.rowEnd,r.getRowIndex(e+a.height)),y={top:r.getRowOffset(_)-(e-d.top)};break}case u.Direction.Left:{let e=r.getColOffset(g+1);v=Math.max(i.colStart,r.getColIndex(e-a.width)),y={left:r.getColOffset(v+1)-(e-d.left)};break}case u.Direction.Right:{let e=r.getColOffset(g);v=Math.min(i.colEnd,r.getColIndex(e+a.width)),y={left:r.getColOffset(v)-(e-d.left)};break}}let b={rowIndex:_,colIndex:v};t?o().modify(b):o().setSelection({cell:b,ranges:u.CommonUtils.EmptyArray,rangeIndex:-1}),y&&n.scrollTo({...y,behavior:`instant`})},v=(e,t)=>{if(t)o().modify(e);else{let t=o().getSelection().cell;o().setSelection({cell:{rowIndex:e.rowIndex??t.rowIndex,colIndex:e.colIndex??t.colIndex},ranges:u.CommonUtils.EmptyArray,rangeIndex:-1})}m()},y=(e,t)=>{let n=o().getSelection(),r=n.ranges&&n.ranges.length>0||e!==u.RangeAxis.Row?void 0:f(n.cell)??void 0;o().traverse(e,t,r),m()},b=e=>{let t=o().getSelection();if(!t.ranges||t.ranges.length<=1)return;let n=(t.rangeIndex??t.ranges.length-1)+(e?-1:1);n<0?n=t.ranges.length-1:n>=t.ranges.length&&(n=0);let r=t.ranges[n];o().setSelection({...t,rangeIndex:n,cell:{rowIndex:r.rowStart,colIndex:r.colStart}}),m()},x=new Map,S=(e,t,n)=>{x.set(e,{shortcut:t,run:n})},C=l.KeyModifiers.Shift,w=l.KeyModifiers.Ctrl,T=l.KeyModifiers.Alt;for(let e of Yr){let t=Zr[e],n=Xr[e];S(`move${t}`,{key:n},()=>g(e,!1)),S(`select${t}`,{key:n,modifiers:[C]},()=>g(e,!0)),S(`moveContentful${t}`,{key:n,modifiers:[w]},()=>g(e,!1,!0)),S(`selectContentful${t}`,{key:n,modifiers:[w,C]},()=>g(e,!0,!0))}S(`moveToPageDown`,{key:`PageDown`},()=>_(u.Direction.Down,!1)),S(`selectToPageDown`,{key:`PageDown`,modifiers:[C]},()=>_(u.Direction.Down,!0)),S(`moveToPageUp`,{key:`PageUp`},()=>_(u.Direction.Up,!1)),S(`selectToPageUp`,{key:`PageUp`,modifiers:[C]},()=>_(u.Direction.Up,!0)),S(`moveToPageRight`,{key:`PageDown`,modifiers:[T]},()=>_(u.Direction.Right,!1)),S(`selectToPageRight`,{key:`PageDown`,modifiers:[T,C]},()=>_(u.Direction.Right,!0)),S(`moveToPageLeft`,{key:`PageUp`,modifiers:[T]},()=>_(u.Direction.Left,!1)),S(`selectToPageLeft`,{key:`PageUp`,modifiers:[T,C]},()=>_(u.Direction.Left,!0)),S(`traverseSelectionRight`,{key:`Tab`},()=>y(u.RangeAxis.Row,!1)),S(`traverseSelectionLeft`,{key:`Tab`,modifiers:[C]},()=>y(u.RangeAxis.Row,!0)),S(`traverseSelectionDown`,[{key:`Enter`},{key:`NumpadEnter`}],()=>y(u.RangeAxis.Column,!1)),S(`traverseSelectionUp`,[{key:`Enter`,modifiers:[C]},{key:`NumpadEnter`,modifiers:[C]}],()=>y(u.RangeAxis.Column,!0)),S(`traverseSelectionNextRange`,{key:`ArrowRight`,modifiers:[w,T]},()=>b(!1)),S(`traverseSelectionPreviousRange`,{key:`ArrowLeft`,modifiers:[w,T]},()=>b(!0)),S(`moveToRowStart`,{key:`Home`},()=>v({colIndex:c().colStart},!1)),S(`moveToGridStart`,{key:`Home`,modifiers:[w]},()=>v({rowIndex:c().rowStart,colIndex:c().colStart},!1)),S(`selectToRowStart`,{key:`Home`,modifiers:[C]},()=>v({colIndex:c().colStart},!0)),S(`selectToColumnStart`,void 0,()=>v({rowIndex:c().rowStart},!0)),S(`selectToGridStart`,{key:`Home`,modifiers:[w,C]},()=>v({rowIndex:c().rowStart,colIndex:c().colStart},!0)),S(`moveToRowEnd`,{key:`End`},()=>v({colIndex:d().colEnd},!1)),S(`moveToGridEnd`,{key:`End`,modifiers:[w]},()=>v({rowIndex:d().rowEnd,colIndex:d().colEnd},!1)),S(`selectToColumnEnd`,void 0,()=>v({rowIndex:c().rowEnd},!0)),S(`selectToRowEnd`,{key:`End`,modifiers:[C]},()=>v({colIndex:d().colEnd},!0)),S(`selectToGridEnd`,{key:`End`,modifiers:[w,C]},()=>v({rowIndex:d().rowEnd,colIndex:d().colEnd},!0)),S(`selectColumn`,{key:`Space`,modifiers:[w]},()=>{let e=f(o().getSelection().cell)??c();o().modify({rowIndex:e.rowStart},{rowIndex:e.rowEnd}),m()}),S(`selectRow`,{key:`Space`,modifiers:[C]},()=>{let e=f(o().getSelection().cell)??c();o().modify({colIndex:e.colStart},{colIndex:e.colEnd}),m()}),S(`scrollToActiveCoords`,{key:`Backspace`,modifiers:[w]},()=>m()),S(`scrollToActiveCoordsClearSelection`,{key:`Backspace`,modifiers:[C]},()=>{let e=o().getSelection().cell;o().setSelection({cell:e,ranges:u.CommonUtils.EmptyArray,rangeIndex:-1}),m()});let E=(e,t)=>{let n=t.modifiers??[];return(n.includes(w)||n.includes(l.KeyModifiers.Meta))===(e.ctrlKey||e.metaKey)&&n.includes(C)===e.shiftKey&&n.includes(T)===e.altKey&&(e.key===t.key||e.code===t.key)};return{invoke(e){let t=x.get(e);return!!t&&(t.run(),!0)},supports:e=>x.has(e),getBindings:()=>x,handleKey(e){for(let t of x.values())if(t.shortcut&&(Array.isArray(t.shortcut)?t.shortcut:[t.shortcut]).some(t=>E(e,t)))return t.run(),!0;return!1}}}({getSelection:()=>oe.current,getPane:()=>se.current,getContentBounds:()=>ce.current?.()??se.current.getTotalRange(),getScrollIntoView:()=>le.current,getRegionBounds:e=>H.current?.(e)??null}),[]);s.default.useImperativeHandle(t,()=>ue,[ue]);let de=!!re.ranges&&re.ranges.length>0,fe=de?[...re.ranges]:[u.CoordUtils.cellToRange(re.cell)],pe=fe.length>1,me=re.rangeIndex??-1,he=de?me>=0?me:fe.length-1:0,ge=V.getRangeFromCell(re.cell),U=u.CoordUtils.unionRanges(fe[he]??u.CoordUtils.cellToRange(re.cell),ge),_e=fe.filter((e,t)=>t!==he),G=pe?$r(zr,d):$r(Rr,o),ve={...Br,...f},K=$r(Vr,m),{refusedColor:be,...xe}={...Hr,...h},Se=_===null?null:$r(Ur,_),q=(e,t)=>{let n=t.mods.shiftKey?t.insert:null,r=t.mods.ctrlKey||t.mods.metaKey,i=n?$n(e,n,V.getTotalRange()):e,a={to:i,copy:r,insert:n?.axis};return a.refused=!!n&&!r&&(g?g(U,a):u.CoordUtils.isRefusedInsertCut(u.CoordUtils.classifyInsertCut(U,i,n.axis))),a},J=e=>{let t=n.getSelection(),r=t.ranges,i=!!r&&r.length>0,a=i?t.rangeIndex!==void 0&&t.rangeIndex>=0&&t.rangeIndex<r.length?t.rangeIndex:r.length-1:0,o=i?r.map((t,n)=>n===a?e:t):[e],s=u.CoordUtils.isCellWithinRange(t.cell,e)?t.cell:{rowIndex:e.rowStart,colIndex:e.colStart};n.setSelection({cell:s,ranges:o,rangeIndex:a})},Y=B??(z.dragMode===`extend`?{kind:`select`,range:U}:null),X=Y&&L?L(Y):null,Ce=s.default.Children.map(pe?y:v,e=>{if(!s.default.isValidElement(e))return e;let t=e.props;return s.default.cloneElement(e,{range:U,onDragEnd:(e,n)=>{t.onDragEnd?.(e,n),J(e)}})});return(0,c.jsxs)(ye,{...ne,onPointerDown:z.onPointerDown,onPointerMove:z.onPointerMove,onPointerUp:z.onPointerUp,onKeyDown:ee?void 0:e=>{ue.handleKey(e)&&(e.preventDefault(),e.stopPropagation())},children:[B?.kind===`move`&&!B.drop.copy&&Se&&!u.CoordUtils.isEqualRanges(B.to,B.from)&&ni(Se,B.from,void 0,!1,`move-source`),pe?(0,c.jsxs)(c.Fragment,{children:[_e.map((e,t)=>(0,c.jsx)(s.default.Fragment,{children:ni(G,e)},`other-${t}`)),ni(G,U,te?ge:void 0),(0,c.jsx)(Mn,{className:`anchor`,range:ge,...ve})]}):(0,c.jsxs)(c.Fragment,{children:[ni(G,U,te?ge:void 0),p&&(0,c.jsx)(Mn,{className:`anchor`,range:ge,...p})]}),!pe&&b&&(0,c.jsx)(er,{className:`move-grip`,range:U,grip:`edges`,dragCursor:T,renderMove:(e,t)=>{let n=q(e,t);return n.insert?(0,c.jsx)(Nn,{range:n.to,axis:n.insert,...xe,color:(n.refused?be:void 0)??xe.color}):G.border&&(0,c.jsx)(Mn,{className:`move-ghost`,range:n.to,...G.border,animatedTransition:!0,style:{opacity:.6}})},onEdgeDoubleClick:P,onDragStart:(e,t,n)=>{let r=q(e,n);S?.(e,t,r),ae({kind:`move`,from:e,to:r.to,drop:r})},onDragMove:(e,t,n)=>{let r=q(e,n);C?.(U,r.to,t,r),ae({kind:`move`,from:U,to:r.to,drop:r})},onDragStateChange:e=>{e||(w?.(),ae(null))},onDragEnd:(e,t,r)=>{let i=q(e,r);i.refused||(x?.(U,i.to,t,i),n.modify({rowIndex:i.to.rowEnd,colIndex:i.to.colEnd},{rowIndex:i.to.rowStart,colIndex:i.to.colStart}))}}),!pe&&E&&(0,c.jsx)(cr,{range:U,snapDestination:D,...G.border,onDragStart:(e,t)=>{k?.(e,t),ae({kind:`fill`,template:e,destination:e})},onDragMove:(e,t)=>{A?.(U,e,t),ae({kind:`fill`,template:U,destination:e})},onDragEnd:(e,t)=>{O?.(U,e,t),J(e)},onMenu:M?(e,t,n)=>{M(U,e,t,n)}:void 0,onDragDone:()=>{j?.(),ae(null)},onDoubleClick:N?(e,t)=>{let n=N(e);n&&!u.CoordUtils.isEqualRanges(n,e)&&(O?.(e,n,t),J(n))}:void 0}),z.removePreview&&ni(K,z.removePreview,void 0,!1,`remove-preview`),Ce,X!=null&&Y&&(0,c.jsx)(un,{className:`gesture-tip`,anchor:{range:(we=Y,we.kind===`move`?we.to:we.kind===`fill`?we.destination:we.range)},placement:R??ei,offset:8,whenOff:`clamp`,open:!0,style:{pointerEvents:`none`},children:X})]});var we});ti.displayName=`SelectionLayer`;var ni=(e,t,n,r=!1,i=`range`)=>(0,c.jsxs)(c.Fragment,{children:[e.fill&&(0,c.jsx)(Mn,{className:`${i} fill`,animatedTransition:r,range:t,hole:n,...e.fill}),e.inner&&(0,c.jsx)(Mn,{className:`${i} inner`,animatedTransition:r,range:t,...e.inner}),e.border&&(0,c.jsx)(Mn,{className:`${i} border`,animatedTransition:r,range:t,...e.border})]}),ri=[`#1a73e8`,`#d93025`,`#1e8e3e`,`#9334e6`,`#e37400`,`#12a4af`,`#d01884`],ii=Array.from({length:l.SERIES_COUNT},(e,t)=>`var(--sxl-color-series-${t+1}, ${ri[t]})`),ai=`var(--sxl-color-primary, rgb(0, 120, 215))`,oi=(e,t,n)=>({rowStart:Math.max(n.rowStart,Math.min(e.rowIndex,t.rowIndex)),colStart:Math.max(n.colStart,Math.min(e.colIndex,t.colIndex)),rowEnd:Math.min(n.rowEnd,Math.max(e.rowIndex,t.rowIndex)),colEnd:Math.min(n.colEnd,Math.max(e.colIndex,t.colIndex))}),si=e=>({stroke:ii.length?ii[e%ii.length]:ai}),ci=e=>{let{selection:t,getRangeStyle:n=si,anchors:r=nr,enabledMove:i,disableDraw:a,allowMulti:o=!0,size:d,animated:f,renderHandle:p,preserveFocus:m=!0,onDragActiveChange:h,rangeStyle:g=u.CommonUtils.EmptyObject,className:_,...v}=e,y=W(),b=(0,l.useBoundSyncExternalStore)(t,e=>e.getSelection()),x=b.ranges??u.CoordUtils.EmptyRanges,S=Math.min(Math.max(0,b.rangeIndex??x.length-1),Math.max(0,x.length-1)),[w,T]=(0,s.useState)(null),[E,D]=(0,s.useState)(null),[O,k]=(0,s.useState)(!1),A=E!==null||O,j=(0,s.useRef)(h);j.current=h,(0,s.useEffect)(()=>{j.current?.(A,E)},[A,E]),(0,s.useEffect)(()=>()=>{j.current?.(!1,null)},[]);let M=E??w,N=(e,t)=>T(n=>t?e:n===e?null:n),P=(e,n)=>{let r=t.getSelection(),i=r.ranges??u.CoordUtils.EmptyRanges,a=e<i.length?i.map((t,r)=>r===e?{...t,...n}:t):[...i,n];t.setSelection({...r,cell:{rowIndex:n.rowStart,colIndex:n.colStart},ranges:a,rangeIndex:e})},F=e=>{let n=t.getSelection();(n.rangeIndex??-1)!==e&&t.setSelection({...n,rangeIndex:e})},I=Hn((e,t)=>{if(t.button!==0)return null;let n=(b.rangeIndex??-1)>=0?b.rangeIndex:-1;if(t.shiftKey&&n>=0&&x[n]){let t={rowIndex:x[n].rowStart,colIndex:x[n].colStart};return k(!0),P(n,oi(t,e,y.getTotalRange())),{drag:e=>P(n,oi(t,e,y.getTotalRange())),end:()=>k(!1),captureEvents:!1}}let r=(!t.ctrlKey&&!t.metaKey||!o)&&n>=0?n:x.length;return k(!0),P(r,u.CoordUtils.cellToRange(e)),{drag:t=>P(r,oi(e,t,y.getTotalRange())),end:()=>k(!1),captureEvents:!1}}),L=x.map((e,t)=>n(t,t===S)),R=[];for(let e=0;e<L.length;e++)L[e]&&R.push(e);return(0,c.jsxs)(ye,{...v,children:[(!a||O)&&(0,c.jsx)(q,{fill:!0,className:C(_,`ranges-picker-draw`),onPointerDown:e=>{e.stopPropagation(),m&&e.preventDefault(),I.onPointerDown(e)},onPointerMove:I.onPointerMove,onPointerUp:e=>{e.stopPropagation(),I.onPointerUp(e)}}),i&&R.map(e=>(0,c.jsx)(er,{range:x[e],grip:`edges`,preserveFocus:m,onHoverChange:t=>N(e,t),onDragStateChange:t=>{t&&F(e),D(t?e:null)},onDragMove:t=>P(e,t),onDragEnd:t=>P(e,t)},`move-${e}`)),R.map(e=>{let t=e===S,n=e===M,i=((e,t,n)=>{let r=e.stroke??g.stroke??ai;return{...g,...e,stroke:r,fill:e.fill??g.fill??`color-mix(in srgb, ${r} 12%, transparent)`,alignWidth:n?3:e.alignWidth??g.alignWidth??2,...f&&t?{animatedStroke:!0}:void 0}})(L[e],t,n);return(0,c.jsx)(ir,{range:x[e],anchors:r,size:d,...i,renderHandle:p,preserveFocus:m,onHandleHoverChange:t=>N(e,t),onDragMove:t=>P(e,t),onDragStart:()=>{F(e),D(e)},onDragEnd:t=>{D(null),P(e,t)}},`resize-${e}`)})]})};ci.displayName=`RangesPickerLayer`;var li=0,ui=class{constructor(e,t={}){this.listeners=new Set,this.commitListeners=new Set,this.cancelListeners=new Set,this.editors=new Set,this.activeEditor=null,this.activeEditorId=null,this.auxState=null,this.commitFn=e.commit,this.onCommitError=e.onCommitError,this.state={mode:t.mode??`enter`,coords:e.coords,clean:e.clean,dirty:t.dirty,initialSelection:t.initialSelection??null,autoFocus:t.autoFocus??!0,token:++li}}getState(){return this.state}getCoords(){return this.state.coords}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}registerEditor(e){return this.editors.add(e),()=>{this.editors.delete(e),this.activeEditor===e&&(this.activeEditor=null)}}setActiveEditor(e){this.activeEditor=e}getActiveEditor(){return this.activeEditor}setActiveEditorId(e){this.activeEditorId=e}getActiveEditorId(){return this.activeEditorId}getEditors(){return[...this.editors]}getAuxState(){return this.auxState}setAuxState(e){this.auxState!==e&&(this.auxState=e,this.notify())}setDirty(e){this.state.dirty!==e&&this.emit({...this.state,dirty:e})}setMode(e){this.state.mode!==e&&this.emit({...this.state,mode:e})}commit(e){let t=this.state,n=!1,r={coords:t.coords,dirty:t.dirty,args:e,veto:()=>{n=!0}};for(let e of this.commitListeners){try{e(r)}catch(e){console.error(`EditSession beforeCommit listener threw:`,e),n=!0}if(n)break}if(n)return!1;if(t.dirty===void 0)return!0;try{if(!1===this.commitFn(t.dirty,e))return!1}catch(e){return this.onCommitError?this.onCommitError(e):console.error(`EditSession commit rejected with an error:`,e),!1}return!0}cancel(){this.cancelListeners.forEach(e=>{try{e()}catch(e){console.error(`EditSession cancel listener threw:`,e)}})}addCommitListener(e){return this.commitListeners.add(e),()=>{this.commitListeners.delete(e)}}addCancelListener(e){return this.cancelListeners.add(e),()=>{this.cancelListeners.delete(e)}}emit(e){this.state=e,this.notify()}notify(){this.listeners.forEach(e=>e())}},di=e=>e.ctrlKey||e.metaKey||e.altKey||e.isComposing?null:e.key===`Process`||e.keyCode===229?{mode:`enter`,dirty:``}:e.key.length===1?e.key===` `&&e.shiftKey?null:{mode:`enter`,dirty:e.key}:e.shiftKey?null:e.key===`F2`?{mode:`edit`}:e.key===`Backspace`?{mode:`enter`,dirty:``}:null,fi=(e,t)=>{let n=(0,s.useRef)(null);return(0,s.useLayoutEffect)(()=>{let t=n.current;t!==null&&(n.current=null,e.current?.setSelectionRange(t,t))},[t]),(0,l.useCallbackRef)(e=>{n.current=e},[])},pi=(e,t)=>{if(e.which===l.KeyCodes.Enter&&t.ctrlKey)return t.shiftKey?{arrayFixed:!0}:{broadcast:!0}},mi=e=>{let{mode:t,value:n,onDirtyChange:r,onModeChange:i,onCommit:a,onCancel:o,onNavigate:s,onTraverse:c,setCaret:d}=e;return(0,l.useCallbackRef)(e=>{let f=e.nativeEvent;if(f.isComposing)return void e.stopPropagation();if(e.which===l.KeyCodes.Escape)return e.preventDefault(),e.stopPropagation(),void o();if(!(e.which!==l.KeyCodes.F2||f.altKey||f.metaKey||f.ctrlKey||f.shiftKey))return e.preventDefault(),e.stopPropagation(),void i(t===`edit`?`enter`:`edit`);if(e.which===l.KeyCodes.Enter&&(f.altKey||f.metaKey)){e.preventDefault(),e.stopPropagation();let t=e.currentTarget,i=t.selectionStart+1;d&&d(i),r(n.substring(0,t.selectionStart)+`
3
+ `+n.substring(t.selectionEnd)),d||requestAnimationFrame(()=>t.setSelectionRange(i,i));return}let p=e.which===l.KeyCodes.Left||e.which===l.KeyCodes.Right||e.which===l.KeyCodes.Up||e.which===l.KeyCodes.Down;if(p&&t===`edit`)return void e.stopPropagation();if(e.which===l.KeyCodes.Enter||e.which===l.KeyCodes.Tab||p&&t===`enter`){e.preventDefault();let t=pi(e,f);if(!a(t)||t)return void e.stopPropagation();let n=e.which===l.KeyCodes.Enter||e.which===l.KeyCodes.Tab;n&&c?(e.stopPropagation(),c(e.which===l.KeyCodes.Tab?u.RangeAxis.Row:u.RangeAxis.Column,e.shiftKey)):!n&&s&&(e.stopPropagation(),s((e=>{switch(e.which){case l.KeyCodes.Enter:return e.shiftKey?u.Direction.Up:u.Direction.Down;case l.KeyCodes.Tab:return e.shiftKey?u.Direction.Left:u.Direction.Right;case l.KeyCodes.Up:return u.Direction.Up;case l.KeyCodes.Left:return u.Direction.Left;case l.KeyCodes.Right:return u.Direction.Right;default:return u.Direction.Down}})(e)));return}let m=f.ctrlKey||f.metaKey,h=e.key.length===1?e.key.toLowerCase():``;(!m||h!==`c`&&h!==`x`&&h!==`v`&&h!==`a`&&h!==`z`&&h!==`y`)&&(e.which!==l.KeyCodes.Insert||!m&&!f.shiftKey)&&e.which!==l.KeyCodes.Delete&&e.which!==l.KeyCodes.BackSpace&&(t!==`edit`||e.which!==l.KeyCodes.Home&&e.which!==l.KeyCodes.End&&e.which!==l.KeyCodes.PageUp&&e.which!==l.KeyCodes.PageDown)||e.stopPropagation()},[t,n,a,o,i,r,s,c,d])},hi=(e,t,n,r=`left`,i=0)=>{if(!t)return null;let a=e.getRangeFromCell(t),o=e.getBoundsFromRange(a);if(!o)return null;let s=e.toClipBounds(e.getBoundsFromRange(a))!==null,c=e.getZoom(),l=n?.width?n.width*c:void 0,u=n?.height?n.height*c:void 0,d={...o};if(l!==void 0){let t=e.getPaneRange(),n=e.getMetrics(),i={...a},o=!1,s=0;for(;!o&&d.width<=l&&s<20;)s++,r===`left`?i.colEnd+1<t.colEnd?i.colEnd=n.getColIndex(d.x+l):o=!0:r===`right`?i.colStart-1>=0?i.colStart=n.getColIndex(d.x-(l-d.width)):o=!0:i.colEnd+1<t.colEnd&&i.colStart-1>=0?(i.colStart=n.getColIndex(d.x-(l-d.width)/2),i.colEnd=n.getColIndex(d.x+d.width+(l-d.width)/2)):o=!0,o||(d=e.getBoundsFromRange(i))}d.height=o.height,u!==void 0&&(d.height=Math.max(u+1,o.height));let f=e.getSurfaceSize(),p=Math.max(o.width,f.width-d.x-i);return{bounds:{x:d.x??0,y:d.y??0,width:Math.min(p,d.width),height:Math.min(f.height-d.y,d.height)},inView:s}},gi=96/72*11,_i=`Calibri, sans-serif`,vi=e=>{let{open:t,mode:n,clean:r,dirty:i,token:a,autoFocus:o,initialSelection:l,zoom:u,readOnly:d,onDirtyChange:f,onModeChange:p,onCommit:m,onCancel:h,onNaturalSize:g}=e,_=i??r??``,v=(0,s.useRef)(null),y=(0,s.useRef)(null),b=(0,s.useRef)(0);(0,s.useLayoutEffect)(()=>{if(!t||!o)return;let e=v.current;if(!e||(e.focus(),b.current===a))return;b.current=a;let n=e.value.length,r=l??{start:n,end:n,direction:`forward`};e.setSelectionRange(r.start,r.end,r.direction)},[a,t,o]),(0,s.useLayoutEffect)(()=>{let e=y.current;e&&g&&g({width:e.offsetWidth+4,height:e.offsetHeight})},[_,g]);let x=mi({mode:n,value:_,onDirtyChange:f,onModeChange:p,onCommit:m,onCancel:h,setCaret:fi(v,_)});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`textarea`,{ref:v,value:_,spellCheck:!1,autoComplete:`off`,autoCapitalize:`off`,name:`cell-editor`,readOnly:d,style:{flex:`1 1 100%`,boxSizing:`border-box`,padding:`0px 2px`,margin:0,border:`none`,outline:`none`,resize:`none`,overflow:`hidden`,background:`transparent`,fontFamily:_i,fontSize:gi*u+`px`,lineHeight:1.2,whiteSpace:`pre`,userSelect:`text`},onChange:e=>f(e.target.value),onPointerDown:e=>{e.stopPropagation(),n!==`edit`&&p(`edit`)},onKeyDown:x}),(0,c.jsx)(`div`,{ref:y,"aria-hidden":!0,style:{position:`absolute`,top:0,left:0,visibility:`hidden`,pointerEvents:`none`,whiteSpace:`pre`,fontFamily:_i,fontSize:`${gi}px`,lineHeight:1.2},children:_.length===0?` `:_})]})};function yi(e){let{editable:t,renderEditor:n,idleClean:r=null,mapClean:i,editorId:a,readOnly:o,className:s,style:u}=e,d=(0,l.useBoundSyncExternalStore)(t,e=>e.getSession()),f=(0,l.useOptionalBoundSyncExternalStore)(d,e=>e.getState()),p=f?.clean??r,m=i?i(p):p,h=(0,l.useCallbackRef)(e=>t.commit(e),[t]),g=(0,l.useCallbackRef)(()=>t.cancel(),[t]),_=(0,l.useCallbackRef)(()=>{o||(t.getSession()||t.startEdit(t.getAnchor().getCoords(),{mode:`edit`,autoFocus:!1}),t.getSession()?.setActiveEditorId(a??null))},[t,a,o]),v={open:!!f,mode:f?.mode??`enter`,coords:f?.coords??t.getAnchor().getCoords(),clean:m,dirty:f?.dirty,token:f?.token??0,autoFocus:!1,readOnly:o,initialSelection:f?.initialSelection,zoom:1,onDirtyChange:e=>d?.setDirty(e),onModeChange:e=>d?.setMode(e),onCommit:h,onCancel:g};return(0,c.jsx)(`div`,{className:s,style:u,onFocus:_,children:n?n(v):(0,c.jsx)(vi,{...v})})}vi.displayName=`DefaultEditorInput`,yi.displayName=`EditorDiv`;var bi=`ew-resize`,xi=`ns-resize`,Si=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{axis:n,index:r,className:i,style:a,disabled:o=!1,disabledResize:s=!1,isNextHidden:d,isHidden:f,isSelected:p,isSelectedAll:m,showTouchDivider:h,bounds:g,onPointerDown:_,onAutoFit:v,...y}=e,b=W(),x=n===u.RangeAxis.Column,S=1/l.ReactUtils.getDevicePixelRatio(),w=p||m,T=w?`color-mix(in srgb, var(--sxl-color-primary, rgb(33, 115, 70)) 35%, var(--sxl-color-base-300, rgb(171, 171, 171)))`:`var(--sxl-color-base-300, rgb(171, 171, 171))`,E=`var(--sxl-color-base-100, #f5f5f5)`,D=l.ReactUtils.detectIt().primaryInput===`touch`,O=x?14:8,k=b.getZoom();k<1&&(O=Math.max(2,O*k*.8));let A=O/2,j=0;d&&(j=-2),f&&(j=2),f&&(O=O/2+j,A=2*j);let M=T;return w||j!==0||(M=`linear-gradient(${x?180:90}deg, ${E}, ${T} 55%, ${T} 100%)`),(0,c.jsxs)(`div`,{className:C(`header-divider`,{disabled:o},i,`index-${r}`),ref:t,onPointerDown:D?void 0:_,onDoubleClick:D?void 0:()=>v?.(),style:{top:`${x?0:-O/2+j}px`,left:`${x?-O/2+j:0}px`,width:x?O:`calc(100%)`,height:x?`calc(100%)`:O,position:`absolute`,overflow:`visible`,pointerEvents:`auto`,cursor:o||s||D?void 0:x?bi:xi,...a},...y,children:[(0,c.jsx)(`div`,{style:{position:`relative`,top:`${x?0:A}px`,left:`${x?A:0}px`,width:x?S:`100%`,height:x?`100%`:S,background:M},onDoubleClick:()=>v?.()}),h&&D?(0,c.jsx)(`div`,{style:{position:`absolute`,cursor:`grab`,zIndex:1,borderRadius:`4px`,right:x?`-6px`:`2px`,bottom:x?`2px`:`-9px`,height:`24px`,width:x?`24px`:`18px`,maxHeight:x?`calc(100% - 4px)`:void 0,maxWidth:x?void 0:`calc(100% - 4px)`,background:E,border:`1px solid var(--sxl-color-base-300, rgb(171, 171, 171))`,boxShadow:`0.5px 0.5px 0px 0px var(--sxl-color-base-content, rgba(0,0,0,0.87))`,display:`flex`,alignItems:`center`,justifyContent:`center`},onPointerDown:_,children:(0,c.jsx)(`div`,{style:{width:`6.4px`,height:`12px`,backgroundImage:`url("data:image/svg+xml,%3Csvg width='6.4' height='12' viewBox='0 0 9.6 16' version='1.1' fill='rgb(128%2C128%2C128)' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cpath d='M 9.60008,14.40009 C 9.60008,15.28374 8.88368,16 8.00003,16 7.11639,16 6.40012,15.28374 6.40012,14.40009 c 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40012 c 0,0.88364 -0.7164,1.60004 -1.60005,1.60004 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60004 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40006 c 0,0.88365 -0.7164,1.60005 -1.60005,1.60005 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60005 C 6.40012,0.71626 7.11639,0 8.00003,0 8.88368,0 9.60008,0.71626 9.60008,1.59991 M 3.19996,14.40009 C 3.19996,15.28374 2.48369,16 1.60005,16 0.7164,16 0,15.28374 0,14.40009 c 0,-0.88365 0.7164,-1.60005 1.60005,-1.60005 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40012 c 0,0.88364 -0.71627,1.60004 -1.59991,1.60004 C 0.7164,9.60001 0,8.88361 0,7.99997 0,7.11632 0.7164,6.39992 1.60005,6.39992 c 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40006 c 0,0.88365 -0.71627,1.60005 -1.59991,1.60005 C 0.7164,3.19996 0,2.48356 0,1.59991 0,0.71626 0.7164,0 1.60005,0 2.48369,0 3.19996,0.71626 3.19996,1.59991' /%3E%3C/svg%3E%0A")`,backgroundRepeat:`no-repeat`,backgroundPosition:`center`,transform:x?void 0:`rotate(90deg)`}})}):null]})})),Ci=e=>(0,c.jsx)(Si,{...e}),wi=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{axis:n,index:r,disabled:i=!1,disabledResize:a=!1,resizeThreshold:o=1,renderDivider:f=Ci,onDividerMouseDown:p,onDividerResizeStart:m,onDividerResize:h,onDividerResizeEnd:g,onDividerMouseUp:_,onDividerAutoFit:v,onPointerDown:y,...b}=e,x=W(),S=(0,l.useCallbackRef)(y,[y]),w=(0,l.useCallbackRef)(v,[v]),T=n===u.RangeAxis.Column,E=T?x.getVisibleColumns():x.getVisibleRows(),D=null;E.length>0&&(D=T?x.getBoundsFromRange({rowStart:0,rowEnd:0,colStart:E[0].index,colEnd:E[E.length-1].index}):x.getBoundsFromRange({rowStart:E[0].index,rowEnd:E[E.length-1].index,colStart:0,colEnd:0}),D=x.toClipBounds(D,-10));let O=(0,s.useRef)(null),[k,A]=(0,s.useState)(null),j=(e,t)=>T?e.clientX-t.clientX:e.clientY-t.clientY,M=x.getMetrics(),N=T?M.getColOffset(r+1):M.getRowOffset(r+1),P=l.ReactUtils.getDevicePixelRatio(),F=1/P,I=l.ReactUtils.snapLineCenter(N,F,P)-F/2,L=(0,l.useSynchronizedPointerHandler)({processTouch:!0,onPointerDown:e=>{if(S?.(e),!i&&!a){let e=T?M.getColOffset(r):M.getRowOffset(r),t=N-e;O.current={isResizing:!1,startSize:t,index:r,pane:x,axis:n,onDividerMouseDown:p,onDividerResizeStart:m,onDividerResize:h,onDividerResizeEnd:g,onDividerMouseUp:_},A(O.current),p?.(r,t)}e.stopPropagation(),e.preventDefault()},onPointerUp:(e,t,n)=>{if(!O.current)return;O.current.isResizing&&O.current.onDividerResizeEnd?.(O.current.index,Math.max(0,O.current.startSize+j(e,n)),O.current.startSize);let r=O.current;O.current=null,A(O.current),r.onDividerMouseUp?.(r.index)},onPointerMoveOrWait:(e,t,n)=>{if(!O.current)return;let r=j(e,n);O.current.isResizing?O.current.onDividerResize?.(O.current.index,Math.max(0,O.current.startSize+r),O.current.startSize):Math.abs(r)>=Math.max(0,o)&&(O.current={...O.current,isResizing:!0},A(O.current),O.current.onDividerResizeStart?.(O.current.index,Math.max(0,O.current.startSize+r))),e.stopPropagation(),e.preventDefault()}}),R=(0,l.useCallbackRef)(()=>{w?.(r)},[r]),{getPortalContainer:ee}=(0,l.useFullscreenPortal)();if(!D)return;let te=f({bounds:D,axis:n,index:r,disabled:i,disabledResize:a,onAutoFit:R,onPointerDown:L,ref:t,...b},x);if(!te)return;let ne=null;return k&&k.isResizing&&k.index===r&&(ne=(0,d.createPortal)((0,c.jsx)(`div`,{style:{position:`absolute`,cursor:T?bi:xi,left:0,top:0,width:`100%`,height:`100%`}}),ee(),`divider:`+r)),(0,c.jsxs)(c.Fragment,{children:[ne,(0,c.jsx)(`div`,{className:C(`header-divider-anchor`),style:{position:`absolute`,pointerEvents:`auto`,top:`${T?D.y:I}px`,left:`${T?I:D.x}px`,width:(T?0:D.width-1)+`px`,height:(T?D.height-1:0)+`px`,display:`flex`},tabIndex:-1,children:te})]})}));wi.displayName=`HeaderDividerAnchor`;var Ti=(e,t,n)=>t===u.RangeAxis.Column?{rowIndex:n.rowStart,colIndex:e.colIndex}:{rowIndex:e.rowIndex,colIndex:n.colStart},Ei=(e,t,n,r)=>n===u.RangeAxis.Column?{rowStart:r.rowStart,rowEnd:r.rowEnd,colStart:Math.min(e.colIndex,t.colIndex),colEnd:Math.max(e.colIndex,t.colIndex)}:{colStart:r.colStart,colEnd:r.colEnd,rowStart:Math.min(e.rowIndex,t.rowIndex),rowEnd:Math.max(e.rowIndex,t.rowIndex)},Di=(e,t,n)=>{let r=null,i=null,a=0,o=()=>t.getAllPanes()[u.AnchorLocation.Center]??t,s=(t,n,r)=>{if(!e)return;let i=e.getSelection(),a=!!i.ranges&&i.ranges.length>0;if(r===`clear`)return void e.setSelection({cell:n,ranges:[t],rangeIndex:0});if(r===`append`){let r=a?[...i.ranges]:[u.CoordUtils.cellToRange(i.cell)];r.push(t),e.setSelection({cell:n,ranges:r,rangeIndex:r.length-1});return}let o=i.rangeIndex??-1,s=a?o>=0?o:i.ranges.length-1:0,c=a?i.ranges.map((e,n)=>n===s?t:e):[t];e.setSelection({cell:n,ranges:c,rangeIndex:a?s:0})},c=(t,n,r)=>{if(!e)return;let i=e.getSelection(),a=i.ranges&&i.ranges.length>0?i.ranges:[],o=t<a.length?a.map((e,r)=>r===t?n:e):[...a,n];e.setSelection({cell:r,ranges:o,rangeIndex:t})},l=e=>{let{scrollIntoView:t}=n();t?t(e):o().scrollCellCoordsIntoView(e)},d=e=>{let{axis:t,entireRange:r}=n(),i=o().getElement()?.getBoundingClientRect();if(!i)return!1;let a=o().getVisibleRange(),s=null;return t===u.RangeAxis.Column?e.x>=i.right-24&&a.colEnd<r.colEnd?s={colIndex:a.colEnd+1}:e.x<=i.left+24&&a.colStart>r.colStart&&(s={colIndex:a.colStart-1}):e.y>=i.bottom-24&&a.rowEnd<r.rowEnd?s={rowIndex:a.rowEnd+1}:e.y<=i.top+24&&a.rowStart>r.rowStart&&(s={rowIndex:a.rowStart-1}),!!s&&(l(s),!0)},f=e=>{let{axis:t,entireRange:l,replaceActive:u=!1}=n(),d=Ei(r??e,e,t,l),f=i??Ti(e,t,o().getVisibleRange());u?c(a,d,f):s(d,f,`replace`)};return Bn(t,(t,p)=>{if(!e)return null;let m=p.button===0,h=p.button===2;if(!m&&!h)return null;let{axis:g,entireRange:_,allowMulti:v=!0,replaceActive:y=!1,preserveFocus:b=!1,onPointerDownInterceptor:x,onDragStart:S,onDragEnd:C,onPointerUp:w}=n();if(!1===x?.(p,t))return null;y&&p.stopPropagation(),b&&m&&p.preventDefault(),S?.();let T=Ti(t,g,o().getVisibleRange()),E=p.shiftKey,D=(p.ctrlKey||p.metaKey)&&v;if(y){let n=e.getSelection(),o=n.ranges??[],s=n.rangeIndex??-1;E&&r?(a=s>=0?s:Math.max(0,o.length-1),c(a,Ei(r,t,g,_),i??T)):(r=t,i=T,a=D||s<0?o.length:s,c(a,Ei(t,t,g,_),T))}else E&&r?s(Ei(r,t,g,_),i??T,`replace`):D?(r=t,i=T,s(Ei(t,t,g,_),T,`append`)):(r=t,i=T,s(Ei(t,t,g,_),T,`clear`));return(e=>{l(n().axis===u.RangeAxis.Column?{colIndex:e.colIndex}:{rowIndex:e.rowIndex})})(t),{drag:f,edgeScroll:d,end:e=>{C?.(e),w?.(e)},cancel:e=>{C?.(e)},capture:m,captureEvents:y}})},Oi=e=>e==null?[]:Array.isArray(e)?e:[e],ki=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{rowCount:n=1,columnCount:r=1,getRowHeight:i,getColumnWidth:a,metrics:o,renderCells:u,renderBorders:d,showGridLines:f=!0,gridLineColor:m,propsGridLineRows:h,propsGridLineColumns:g,getVisibleCells:_,hiddenCellAt:v,renderBelow:y,children:b,...x}=e,S=p({rowCount:n,columnCount:r,getRowHeight:i,getColumnWidth:a}),C=o??S,[w,T]=(0,s.useReducer)(e=>e+1,0),E=(0,s.useMemo)(()=>({}),[w]),D=(0,s.useCallback)(e=>{T()},[]),O=(0,l.useImperativeElement)(t,()=>({invalidate:D}),[D]),k=(0,s.useMemo)(()=>{let e=[];return!1!==f&&e.push((0,c.jsx)(Or,{showGridLines:f,gridLineColor:m,propsRows:h,propsColumns:g,getVisibleCells:_,hiddenCellAt:v},`__gridlines`)),e.push(...Oi(y)),e.push(...Oi(d)),u&&e.push((0,c.jsx)(br,{renderCell:u,getVisibleCells:_,hiddenCellAt:v,cacheToken:E},`__cells`)),e.push(...Oi(b)),e},[f,m,h,g,_,v,y,d,u,E,b]);return(0,c.jsx)(H,{ref:O,...x,rowCount:n,columnCount:r,metrics:C,children:k})}));ki.displayName=`Grid`;var Ai=function(){},ji=typeof window<`u`,Mi=ji?s.useLayoutEffect:s.useEffect,Ni={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0},Pi=ji&&window.ResizeObserver!==void 0?function(){var e=(0,s.useState)(null),t=e[0],n=e[1],r=(0,s.useState)(Ni),i=r[0],a=r[1],o=(0,s.useMemo)(function(){return new window.ResizeObserver(function(e){if(e[0]){var t=e[0].contentRect,n=t.x,r=t.y,i=t.width,o=t.height,s=t.top,c=t.left,l=t.bottom,u=t.right;a({x:n,y:r,width:i,height:o,top:s,left:c,bottom:l,right:u})}})},[]);return Mi(function(){if(t)return o.observe(t),function(){o.disconnect()}},[t]),[n,i]}:function(){return[Ai,Ni]};function Fi(e,t){if(typeof e==`function`)return e(t);e&&(e.current=t)}var Ii,Li=parseInt(s.version.split(`.`)[0],10)>=19?function(e){return t=>{let n=[];for(let r of e){let e=Fi(r,t),i=typeof e==`function`;n.push(i?e:()=>Fi(r,null))}return()=>{for(let e of n)e()}}}:function(e){return t=>{for(let n of e)Fi(n,t)}},Ri={fill:{fill:`color-mix(in srgb, var(--sxl-color-primary, rgb(0, 120, 215)) 14%, transparent)`},border:null,inner:null},zi={stroke:`var(--sxl-color-primary, rgb(0, 120, 215))`,alignWidth:1,inset:1},Bi=(0,s.forwardRef)(function(e,t){let{itemCount:n,renderCell:r,getVisibleCells:i,itemHeight:a=24,contentWidth:o,selection:u,propsLayer:d,autoFocus:f,showScrollbar:m=`auto`,scrollTo:h,viewport:g,cacheToken:_,className:v,style:y,children:b,...x}=e,S=(0,s.useMemo)(()=>new l.Viewport,[]),w=g??S,T=(0,l.useBoundSyncExternalStore)(w,e=>e.getMetrics()),E=m===`auto`?T.totalHeight>T.height:m,D=(0,s.useRef)(null);(0,s.useEffect)(()=>{f&&D.current?.focus()},[f]),(0,s.useEffect)(()=>{if(!h)return;let e=!1,t=0,n=()=>{!e&&w.isReady()&&(e=!0,t=requestAnimationFrame(()=>{D.current?.scrollCellCoordsIntoView({rowIndex:h.row})}))};n();let r=e?null:w.subscribe(n);return()=>{e=!0,t&&cancelAnimationFrame(t),r?.()}},[h,w]);let O=(0,s.useMemo)(()=>new Ar({getBounds:()=>({rowStart:0,colStart:0,rowEnd:Math.max(0,n-1),colEnd:0})}),[n]),k=u??O,[A,{width:j}]=Pi(),[M,{width:N}]=Pi(),P=N>0&&j>0?Math.max(0,N-j):0,F=(0,s.useMemo)(()=>Li([M,t]),[M,t]),I=p({rowCount:n,columnCount:1,getRowHeight:a,getColumnWidth:j||o||T.width||0});return(0,c.jsx)(`div`,{ref:F,className:C(`list-surface`,v),style:{position:`relative`,overflow:`hidden`,height:n*a,maxWidth:`100%`,maxHeight:`100%`,...y,...o==null?null:{width:o+P}},...x,children:(0,c.jsx)(l.ScrollPane,{viewport:w,showVerticalScrollbar:E,showHorizontalScrollbar:!1,style:{width:`100%`,height:`100%`},children:(0,c.jsx)(`div`,{ref:A,style:{width:`100%`,height:`100%`},children:(0,c.jsxs)(H,{ref:D,viewport:w,style:{width:`100%`,height:`100%`},rowCount:n,columnCount:1,metrics:I,children:[(0,c.jsx)(ti,{selection:k,anchorHole:!1,singleStyle:Ri,singleAnchorStyle:zi,multiAnchorStyle:zi},`__selection`),(0,c.jsx)(br,{renderCell:r,getVisibleCells:i,cacheToken:_},`__cells`),d?(0,c.jsx)(ye,{...d},`__taps`):null]})})})})}),Vi=(0,s.forwardRef)(function(e,t){let{itemCount:n,renderItem:r,itemHeight:i,selection:a,onKeyDown:o,cacheToken:u,scrollTo:d,autoFocus:f,viewport:p,className:m,style:h,children:g,..._}=e,v=(0,l.useImperativeElement)(t,()=>({isList:()=>!0}),[]),y=(0,s.useCallback)(e=>{let{key:t,style:n,range:i,cell:a}=e,o=i?.rowStart??a.rowIndex;return(0,c.jsx)(`div`,{style:{...n,position:`absolute`,display:`flex`,alignItems:`center`,boxSizing:`border-box`,padding:`0 8px`,overflow:`hidden`,whiteSpace:`nowrap`,userSelect:`none`,pointerEvents:`none`,background:`transparent`},children:r(o)},t)},[r]),b=(0,s.useMemo)(()=>o?{onKeyDown:o}:void 0,[o]);return(0,c.jsx)(Bi,{ref:v,className:C(`list`,m),style:h,itemCount:n,itemHeight:i,selection:a,renderCell:y,propsLayer:b,cacheToken:u,scrollTo:d,autoFocus:f,viewport:p,..._})}),Hi=(e,t)=>(0,c.jsx)(`input`,{type:`checkbox`,checked:e,ref:e=>{e&&(e.indeterminate=!!t)},readOnly:!0,tabIndex:-1,style:{margin:0}}),Ui=(0,s.forwardRef)(function(e,t){let{itemCount:n,isChecked:r,onCheckedChange:i,renderValue:a,renderCheckbox:o=Hi,renderDivider:u,selectAllLabel:d,itemHeight:f,selection:p,cacheToken:m,autoFocus:h,viewport:g,className:_,style:v,children:y,...b}=e,x=(0,s.useMemo)(()=>new Ar({getBounds:()=>({rowStart:0,colStart:0,rowEnd:Math.max(0,n-1),colEnd:0})}),[n]),S=p??x,w=(0,l.useCallbackRef)(()=>{if(n===0)return;let e=!r(S.getSelection().cell.rowIndex);i((e=>{let t=e.getSelection();return t.ranges&&t.ranges.length?t.ranges.flatMap(e=>Array.from({length:e.rowEnd-e.rowStart+1},(t,n)=>e.rowStart+n)):[t.cell.rowIndex]})(S),e)},[S,n,r,i]),T=(0,s.useRef)(null),[,E]=(0,s.useReducer)(e=>e+1,0),D=(0,l.useCallbackRef)(()=>n===0?-1:S.getSelection().cell.rowIndex,[S,n]),O=(0,l.useCallbackRef)(e=>{if(n===0)return;let t=Math.min(Math.max(0,S.getSelection().cell.rowIndex+e),n-1);S.setSelection({cell:{rowIndex:t,colIndex:0}}),T.current={row:t},E()},[S,n]),k=(0,l.useImperativeElement)(t,()=>({isCheckboxList:()=>!0,getHighlightIndex:D,moveHighlight:O,toggleHighlighted:w}),[D,O,w]),A=(0,s.useCallback)(e=>(0,c.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flex:1,minWidth:0,pointerEvents:`auto`,cursor:`pointer`},onMouseDown:t=>{t.preventDefault(),i([e],!r(e))},children:[(0,c.jsx)(`div`,{style:{display:`inline-flex`,pointerEvents:`none`},children:o(r(e))}),(0,c.jsx)(`div`,{style:{overflow:`hidden`,textOverflow:`ellipsis`},children:a(e)})]}),[r,i,a,o]),j=(0,s.useCallback)(e=>{e.key!==` `&&e.key!==`Enter`||(e.preventDefault(),e.stopPropagation(),w())},[w]),{allChecked:M,someChecked:N}=(0,s.useMemo)(()=>{if(d==null||n===0)return{allChecked:!1,someChecked:!1};let e=!0,t=!1;for(let i=0;i<n;i++)r(i)?t=!0:e=!1;return{allChecked:e,someChecked:t&&!e}},[d,n,r,m]);return(0,c.jsxs)(`div`,{ref:k,className:C(`checkbox-list`,_),style:{display:`flex`,flexDirection:`column`,minHeight:0,...v},...b,children:[d!=null&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,userSelect:`none`,cursor:`pointer`},onMouseDown:e=>{e.preventDefault(),i(Array.from({length:n},(e,t)=>t),!M)},children:[(0,c.jsx)(`div`,{style:{display:`inline-flex`,pointerEvents:`none`},children:o(M,N)}),d]}),u?.()]}),(0,c.jsx)(Vi,{itemCount:n,itemHeight:f,selection:S,renderItem:A,onKeyDown:j,cacheToken:m,scrollTo:T.current,autoFocus:h,viewport:g,style:{flex:`1 1 100%`,minHeight:0}})]})}),Wi=(e,t)=>{let n=(()=>{if(Ii!==void 0)return Ii;try{Ii=(typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):null)??null}catch{Ii=null}return Ii})();if(n)return n.font=t,n.measureText(e).width;let r=Number.parseFloat((/(\d+(?:\.\d+)?)px/.exec(t)??[])[1]??`16`)||16;return e.length*r*.55},Gi=(e,t)=>t<=0?-1:Math.min(Math.max(0,e),t-1),Ki=(0,s.forwardRef)(function(e,t){let{items:n,onChoose:r,highlightIndex:i,itemHeight:a=24,visibleRows:o=8,contentWidth:u,measureText:d,renderItem:f,autoFocus:p,viewport:m,className:h,style:g,children:_,...v}=e,y=n.length,b=Gi(i??0,y),x=(0,s.useMemo)(()=>new Ar({initial:{cell:{rowIndex:Math.max(0,b),colIndex:0}},getBounds:()=>({rowStart:0,colStart:0,rowEnd:Math.max(0,y-1),colEnd:0})}),[n,b,y]),S=(0,s.useRef)(null),[,w]=(0,s.useReducer)(e=>e+1,0),T=(0,s.useMemo)(()=>(S.current=null,b>=0?{row:b}:null),[n,b]),E=S.current??T,D=(0,l.useCallbackRef)(e=>!(e<0||e>=y)&&(r?.(e,n[e]),!0),[r,n,y]),O=(0,l.useCallbackRef)(()=>y===0?-1:x.getSelection().cell.rowIndex,[x,y]),k=(0,l.useCallbackRef)(e=>{if(y===0)return;let t=Gi(x.getSelection().cell.rowIndex+e,y);x.setSelection({cell:{rowIndex:t,colIndex:0}}),S.current={row:t},w()},[x,y]),A=(0,l.useImperativeElement)(t,()=>({isPickList:()=>!0,getHighlightIndex:O,moveHighlight:k,chooseHighlighted:()=>D(O())}),[O,k,D]),j=(0,s.useMemo)(()=>{if(d)return d;let e=(e=>{let t=e?.fontSize,n=e?.fontFamily,r=typeof t==`number`?`${t}px`:t??`16px`,i=[];return e?.fontStyle&&e.fontStyle!==`normal`&&i.push(String(e.fontStyle)),e?.fontWeight&&e.fontWeight!==`normal`&&i.push(String(e.fontWeight)),i.push(r,n?String(n):`sans-serif`),i.join(` `)})(g);return t=>Wi(t,e)},[d,g]),M=(0,s.useMemo)(()=>{if(u!=null)return u;let e=0;for(let t=0;t<y;t++)e=Math.max(e,j(n[t].text));return Math.ceil(e)+16},[u,n,y,j]),N=(0,s.useCallback)(e=>{let{key:t,style:r,range:i,cell:a}=e,o=i?.rowStart??a.rowIndex,s=n[o];return s?(0,c.jsx)(`div`,{role:`option`,style:{...r,position:`absolute`,display:`flex`,alignItems:`center`,boxSizing:`border-box`,padding:`0 8px`,overflow:`hidden`,whiteSpace:`nowrap`,userSelect:`none`,pointerEvents:`none`,background:`transparent`},children:f?f(s,o):(0,c.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`},children:s.text||`\xA0`})},t):null},[n,f]),P=(0,s.useMemo)(()=>({onPointerUp:e=>{e.button===0&&D(O())},onKeyDown:e=>{e.which!==l.KeyCodes.Enter&&e.which!==l.KeyCodes.Space||(e.preventDefault(),e.stopPropagation(),D(O()))}}),[D,O]);return(0,c.jsx)(Bi,{ref:A,className:C(`pick-list`,h),role:`listbox`,style:{maxHeight:o*a,...g},itemCount:y,itemHeight:a,contentWidth:M,selection:x,renderCell:N,propsLayer:P,scrollTo:E,viewport:m,autoFocus:p,cacheToken:n,...v})}),qi=`_search_b1nag_5`,Ji=(0,s.forwardRef)(function(e,t){let{value:n,onChange:r,onClose:i,onKeyDown:a,className:o,...u}=e,d=(0,s.useCallback)(e=>{if(e.which===l.KeyCodes.Escape)return e.preventDefault(),e.stopPropagation(),void(n?r(``):i?.());a?.(e)},[n,r,i,a]);return(0,c.jsx)(`input`,{ref:t,type:`text`,role:`searchbox`,autoComplete:`off`,spellCheck:!1,className:C(qi,`list-search`,o),value:n,onChange:e=>r(e.target.value),onKeyDown:d,...u})}),Yi={light:{},dark:{"color-base-100":`#1e1e1e`,"color-base-300":`#3a3a3a`}},Xi={light:{"color-base-100":`#f2f2f2`,"color-base-hover":`#ececec`,"color-base-300":`rgb(171, 171, 171)`},dark:{"color-base-100":`#262626`,"color-base-hover":`#2e2e2e`,"color-base-300":`#4a4a4a`}};exports.AUTO_SCROLL_INTERVAL_MS=60,exports.CellLayer=br,exports.CellTileDiv=yr,exports.CheckboxList=Ui,exports.DEFAULT_ANCHOR_STYLE=Br,exports.DEFAULT_HANDLE_STYLE=jn,exports.DEFAULT_INSERT_BAR_STYLE=Hr,exports.DEFAULT_MOVE_SOURCE_STYLE=Ur,exports.DEFAULT_MULTI_STYLE=zr,exports.DEFAULT_REMOVE_PREVIEW_STYLE=Vr,exports.DEFAULT_SINGLE_STYLE=Rr,exports.DefaultCellRenderer=lr,exports.DefaultEditable=class{constructor(e,t,n){this.current=null,this.listeners=new Set,this.commitErrorListeners=new Set,this.anchor=e,this.createEdit=t,this.revertAnchor=n?.revertAnchor,this.unsubscribeAnchor=e.subscribe(()=>this.onAnchorChange())}onAnchorChange(){if(!this.current)return;let e=this.current.getState().coords;u.CoordUtils.isEqualCells(this.anchor.getCoords(),e)||this.commit()||(this.revertAnchor?.(e),u.CoordUtils.isEqualCells(this.anchor.getCoords(),e)||this.cancel())}getAnchor(){return this.anchor}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}subscribeCommitError(e){return this.commitErrorListeners.add(e),()=>{this.commitErrorListeners.delete(e)}}getSession(){return this.current}startEdit(e,t={}){let n=this.createEdit(e);return n?(this.current=new ui({coords:e,...n,onCommitError:e=>{this.commitErrorListeners.size===0?console.error(`EditSession commit rejected with an error:`,e):this.commitErrorListeners.forEach(t=>t(e))}},t),this.notify(),!0):!1}commit(e){if(!this.current)return!1;let t=this.current.commit(e);return t&&(this.current=null,this.notify()),t}cancel(){this.current&&(this.current.cancel(),this.current=null,this.notify())}dispose(){this.unsubscribeAnchor(),this.cancel(),this.listeners.clear()}notify(){this.listeners.forEach(e=>e())}},exports.DefaultEditorInput=vi,exports.DefaultHeaderDivider=Si,exports.DefaultSelection=Ar,exports.DragHandle=Gn,exports.Draggable=er,exports.EDGE_AUTO_SCROLL_MARGIN_PX=24,exports.EditSession=ui,exports.EditorDiv=yi,exports.EditorLayer=function(e){let{editable:t,renderEditor:n,alignment:r=`left`,background:i=`var(--sxl-color-base-100, rgb(255, 255, 255))`,borderColor:a=`var(--sxl-color-primary, rgb(33, 115, 70))`,borderWidth:o=2,zIndex:u,className:d,style:f,...p}=e,m=G(),h=(0,l.useBoundSyncExternalStore)(t,e=>e.getSession()),g=(0,l.useOptionalBoundSyncExternalStore)(h,e=>e.getState()),[_,v]=(0,s.useState)(null),y=(0,l.useCallbackRef)(e=>{v(t=>t&&t.width===e.width&&t.height===e.height?t:e)},[]),b=(0,l.useCallbackRef)(e=>{if(t.getSession())return;let n=t.getAnchor().getCoords();if(!n)return;let r=di(e.nativeEvent);r&&(e.nativeEvent.key!==`Process`&&e.nativeEvent.keyCode!==229&&e.preventDefault(),e.stopPropagation(),t.startEdit(n,r))},[t]),x=(0,l.useCallbackRef)(e=>{if(t.getSession())return;let n=m?.getCellFromPointer(e.clientX,e.clientY)??t.getAnchor().getCoords();n&&t.startEdit(n,{mode:`edit`})},[m,t]),S=(0,l.useCallbackRef)(e=>{let n=t.commit(e);return n&&m?.focus(),n},[t,m]),w=(0,l.useCallbackRef)(()=>{t.cancel(),m?.focus()},[t,m]);(0,s.useEffect)(()=>{g&&m&&m.scrollCellCoordsIntoView(g.coords)},[g?.token]);let T=g?g.coords:t.getAnchor().getCoords(),E=null,D=!1,O=!1;if(m&&T){let e=m.getRangeFromCell(T);if(O=m.toClipBounds(m.getBoundsFromRange({rowStart:e.rowStart,colStart:e.colStart,rowEnd:e.rowStart,colEnd:e.colStart}))!==null,g){let e=hi(m,T,_,r,o);E=e?.bounds??null,D=e?.inView??!1}else E=m.getBoundsFromRange(e)}let k=null;if(m&&T){let e=m.getBoundsFromRange(m.getRangeFromCell(T)),t=m.getZoom()||1;e&&(k={width:e.width/t,height:e.height/t})}let A=!!g&&!!E&&D,j={open:!!g,mode:g?.mode??`enter`,coords:g?.coords??null,clean:g?.clean??null,dirty:g?.dirty,token:g?.token??0,autoFocus:(g?.autoFocus??!0)&&A&&O,initialSelection:g?.initialSelection,zoom:m?.getZoom()??1,cellSize:k,onDirtyChange:e=>h?.setDirty(e),onModeChange:e=>h?.setMode(e),onCommit:S,onCancel:w,onNaturalSize:y},M=typeof i==`function`?(T?i(T):void 0)??`transparent`:i;return(0,c.jsx)(ye,{onKeyDown:b,onDoubleClick:x,children:E?(0,c.jsx)(q,{...p,className:C(d,`editor`),bounds:E,alignWidth:o,keepMounted:!0,style:{...f,display:`flex`,overflow:`hidden`,background:M,borderColor:a,boxShadow:A?`rgba(60,64,67,.35) 2px 2px 6px 3px`:`none`,opacity:+!!A,pointerEvents:A?`auto`:`none`},children:n?n(j):(0,c.jsx)(vi,{...j})}):null})},exports.FillHandle=cr,exports.GRID_SURFACE=Yi,exports.Grid=ki,exports.GridFloatPanel=pn,exports.GridSurface=H,exports.GridlineLayer=Or,exports.HEADER_SURFACE=Xi,exports.HeaderDividerAnchor=wi,exports.HoverTipLayer=Sn,exports.Layer=ye,exports.LineSVG=g,exports.List=Vi,exports.ListSearch=Ji,exports.ListSurface=Bi,exports.NO_DRAG_MODIFIERS=In,exports.PICKER_COLORS=ii,exports.PickList=Ki,exports.RESIZE_ANCHORS_4=nr,exports.RESIZE_ANCHORS_8=rr,exports.RangeFloatLayer=xn,exports.RangeInsertBar=Nn,exports.RangePrompt=An,exports.RangeRect=Mn,exports.RangeResizer=ir,exports.RangesPickerLayer=ci,exports.RectangleSVG=_,exports.SELECTION_CLIP_INSETS=-10,exports.SelectionLayer=ti,exports.SelectionTouchGrips=Gr,exports.ShapeBoundsContext=m,exports.StickyAnchor=Pe,exports.StickyFloat=un,exports.SurfaceStateContext=oe,exports.SurfaceStateProvider=se,exports.VirtualDiv=q,exports.buildGridThemeCSS=({app:e,grid:t=Yi,header:n=Xi,layer:r=`sxl-defaults`,scope:i}={})=>{let a=e??l.defaultTheme,o=Object.fromEntries(Object.keys(n).map(e=>[e,{"color-base-100":a[e]?.[`color-base-200`],...n[e]}]));return(0,l.buildThemeCSS)({...e?{app:e}:{},surfaces:{grid:t,header:o},layer:r,scope:i})},exports.commitArgsFromKey=pi,exports.createAxis=f,exports.createDragCells=Bn,exports.createHeaderSelectionPointer=Di,exports.createSurfaceStateStore=V,exports.createWindowDragCells=Vn,exports.defaultRangeStyle=si,exports.edgeScrollPane=Fn,exports.expandEditorBounds=hi,exports.filterByText=(e,t)=>{let n=t.trim().toLowerCase();return n?e.filter(e=>e.text.toLowerCase().includes(n)):e},exports.gridThemeVars=(e,...t)=>(0,l.themeVars)(e,Yi[e],...t),exports.headerAnchorCell=Ti,exports.headerEntireEnd=(e,t,n)=>t===u.RangeAxis.Column?{rowIndex:n.rowEnd,colIndex:e.colIndex}:{rowIndex:e.rowIndex,colIndex:n.colEnd},exports.headerEntireStart=(e,t,n)=>t===u.RangeAxis.Column?{rowIndex:n.rowStart,colIndex:e.colIndex}:{rowIndex:e.rowIndex,colIndex:n.colStart},exports.headerRange=Ei,exports.headerThemeVars=(e,...t)=>(0,l.themeVars)(e,Xi[e],...t),exports.insertAt=Zn,exports.insertRange=$n,exports.isSameDragModifiers=Rn,exports.readDragModifiers=Ln,exports.renderGridFloatPanel=e=>(0,c.jsx)(pn,{...e}),exports.resolveFillDestination=or,exports.startEventFromKey=di,exports.useDoubleClick=Wn,exports.useDragCells=Hn,exports.useEditorKeymap=mi,exports.useGridFloatTheme=sn,exports.useGridMetrics=p,exports.useGridPane=W,exports.useGridPaneOptional=G,exports.useHeaderSelectionPointer=(e,t)=>{let n=W(),r=(0,s.useRef)(t);r.current=t;let i=(0,s.useMemo)(()=>Di(e,n,()=>r.current),[e,n]);return(0,s.useEffect)(()=>()=>i.dispose(),[i]),{onPointerDown:i.onPointerDown,onPointerMove:i.onPointerMove,onPointerUp:i.onPointerUp}},exports.useHoverIntent=gn,exports.useLayer=()=>({zIndex:(0,s.useContext)(ee),pane:G()}),exports.usePendingCaret=fi,exports.useRangeHover=(e,t={})=>{let{open:n,setTarget:r,tipProps:i}=gn(t),a=G(),o=P(a),c=(0,s.useContext)(ee),l=R(e),[d,f]=ve(`range-hover:${c}:${l}`,null),p=(0,s.useRef)({});return p.current={pointermove:(t,n)=>{let r=t,i=(n??a)?.getCellFromPointer(r.clientX,r.clientY);f(i&&u.CoordUtils.isCellWithinRange(i,e)?l:null)},pointerleave:()=>f(null)},(0,s.useEffect)(()=>{r(d)},[d,r]),(0,s.useEffect)(()=>{if(o)return o.registerResponder({zIndex:c,getHandler:e=>p.current[e]})},[o,c]),{open:n,tipProps:i}},exports.useSelectionPointer=Wr,exports.useShapeBounds=h,exports.useSticky=()=>{let e=(0,s.useContext)(Ne);if(!e)throw Error(`useSticky must be used within a <StickyAnchor>`);return e},exports.useStickyOptional=()=>(0,s.useContext)(Ne),exports.useSurfaceState=ve,exports.useWindowDragCells=Un,exports.vacatedByFill=sr;