@sheetxl/grid-react 0.7.28-beta.2 → 0.7.28-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.
- package/browser/cjs/index.cjs +2 -2
- package/browser/esm/index.mjs +766 -727
- package/node/esm/index.mjs +368 -329
- package/package.json +3 -3
- package/types/src/range/DragHandle.d.ts +8 -0
- package/types/src/range/Draggable.d.ts +12 -0
- package/types/src/range/FillHandle.d.ts +7 -0
- package/types/src/range/useDoubleClick.d.ts +19 -0
- package/types/src/selection/SelectionLayer.d.ts +17 -1
package/browser/cjs/index.cjs
CHANGED
|
@@ -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}/*$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===H.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===H.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===H.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=H.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=H.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)},[]),z=(0,l.useCallbackRef)(e=>{T(`mouseup`,e,d.current)},[]),re=(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)},[]),oe=(0,l.useCallbackRef)(e=>{r?.(e),T(`focus`,e,d.current)},[r]),V=(0,l.useCallbackRef)(e=>{i?.(e),T(`blur`,e,d.current)},[i]),se=(0,l.useCallbackRef)(e=>{T(`contextmenu`,e,d.current)},[]),H=(0,l.useImperativeElement)(t,()=>({isStage:()=>!0,addReactEventListener:x,registerResponder:m,registerLayer:_}),[]);return(0,s.useEffect)(()=>_({getElement:()=>H.current}),[_]),(0,c.jsx)(`div`,{className:C(n,`stage`,k),ref:H,tabIndex:0,...o,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerLeave:j,onMouseDown:P,onMouseEnter:F,onMouseLeave:R,onMouseMove:ee,onMouseOut:te,onMouseOver:ne,onMouseUp:z,onDoubleClick:re,onKeyDown:ie,onKeyUp:ae,onKeyPress:B,onFocus:oe,onBlur:V,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<z.length;e++){let t=r[z[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}},z=[u.AnchorLocation.TopLeft,u.AnchorLocation.Top,u.AnchorLocation.Left,u.AnchorLocation.Center],re=(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})},oe=()=>{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)}}}},V=(0,s.createContext)(null),se=({store:e,children:t})=>{let n=(0,s.useContext)(V),r=(0,s.useRef)(null),i=e??n;return i||=(r.current||=oe(),r.current),(0,c.jsx)(V.Provider,{value:i,children:t})},H={"sheetxl-grid":`_sheetxl-grid_5yo0n_7`},U=(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),te=(0,s.useMemo)(()=>new l.Viewport({}),[]),z=i??te,[B,oe]=(0,s.useState)(()=>{let e=z.getClient();return{zoom:z.getZoom(),w:e.width,h:e.height,ready:z.isReady()}});(0,s.useEffect)(()=>{let e=()=>oe(e=>{let t=z.getClient(),n={zoom:z.getZoom(),w:t.width,h:t.height,ready:z.isReady()};return e.zoom===n.zoom&&e.w===n.w&&e.h===n.h&&e.ready===n.ready?e:n});return e(),z.subscribe(e)},[z]);let V=B.zoom,U=(0,s.useMemo)(()=>{let e=a??ce;return{getColOffset:t=>e.getColOffset(t)*V,getColIndex:t=>e.getColIndex(t/V),getRowOffset:t=>e.getRowOffset(t)*V,getRowIndex:t=>e.getRowIndex(t/V)}},[a,V]),W=(0,l.useCallbackRef)((e,t=!1)=>D(e,t,U.getRowOffset,t?0:n),[n,U?.getRowOffset]),G=(0,l.useCallbackRef)(d??W,[d]),ve=(0,l.useCallbackRef)((e,t=!1)=>D(e,t,U.getColOffset,t?r:0),[r,U?.getColOffset]),K=(0,l.useCallbackRef)(f??ve,[f]),q=(0,s.useCallback)(()=>{R()},[]),ye=(0,s.useMemo)(()=>Math.min(B.w,U.getColOffset(r)),[L,U.getColOffset,r,B.w]),be=(0,s.useMemo)(()=>Math.min(B.h,U.getRowOffset(n)),[L,U.getRowOffset,n,B.h]),xe=(0,s.useMemo)(()=>{let e=NaN,t=null;return r=>(r===e&&t||(e=r,t=(e=>{if(be===0)return ie;let t=[],r=0,i=0;typeof m==`number`?r=m:(r=m.index??0,i=(m.offset??0)*V);let a=i,o=U.getRowOffset(r),s=o-a;if(r>0){let e=re(U,{top:i+U.getRowOffset(0)}),n=U.getRowIndex(a),c=U.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(G,e,t):l||(l=Object.freeze(T(G,n,c)),l),metrics:e,maxVirtualBounds:o,scrollOffset:i,freezeOffset:i}}let c=Math.max(0,be-s),l=re(U,{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(G,e,t):f||(f=Object.freeze(T(G,u,d)),f),metrics:l,maxVirtualBounds:U.getRowOffset(n),scrollOffset:e,freezeOffset:(r>0?U.getRowOffset(r):0)-i},t})(r)),t)},[L,U.getRowIndex,U.getRowOffset,G,be,n,m,V]),J=(0,s.useMemo)(()=>xe(0),[xe]),Se=(0,s.useMemo)(()=>{let e=NaN,t=null;return n=>(n===e&&t||(e=n,t=(e=>{if(ye===0)return ie;let t=[],n=0,i=0;typeof p==`number`?n=p:(n=p.index??0,i=(p.offset??0)*V);let a=i,o=U.getColOffset(n),s=o-a;if(n>0){let e=re(U,{left:i+U.getColOffset(0)}),r=U.getColIndex(a),c=U.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,ye-s),l=re(U,{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:U.getColOffset(r),scrollOffset:e,freezeOffset:(n>0?U.getColOffset(n):0)-i},t})(n)),t)},[L,U.getColIndex,U.getColOffset,K,ye,r,p,V]),Y=(0,s.useMemo)(()=>Se(0),[Se]),Ce=(0,s.useRef)([]),[we,Te]=(0,s.useReducer)(e=>e+1,0),Ee=J.length,De=Y.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,pe,fe),t(0,1,u.AnchorLocation.Top,me),t(1,0,u.AnchorLocation.Left,he),t(1,1,u.AnchorLocation.TopLeft,ge),e},[Ee,De]),X=(0,s.useMemo)(()=>{let e={},t={colStart:0,rowStart:0,colEnd:r-1,rowEnd:n-1},i=n=>ne(n,{rowDims:J,columnDims:Y,computeRowDims:xe,computeColumnDims:Se,viewport:z,zoom:V,containerWidth:ye,containerHeight:be,getRangeFromCell:o,invalidate:q,totalRange:t,getSurfacePointFromPointer:(e,t)=>Ne(e,t),scrollTo:e=>ze(e),scrollCellCoordsIntoView:(e,t,n)=>Re(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,Y,xe,Se,z,o,we]),ke=Y[0]?.maxVirtualBounds??0,Ae=J[0]?.maxVirtualBounds??0,je=B.ready,Z=(0,s.useMemo)(()=>{let e=Y[1],t=J[1];return{left:e?e.metrics.getColOffset(e.maxIndex+1):0,top:t?t.metrics.getRowOffset(t.maxIndex+1):0}},[J,Y]),Me=(0,l.useCallbackRef)(e=>{u.DOMUtils.canUseDOM&&setTimeout(()=>{(X[P]?.getElement()??X[u.AnchorLocation.Center]?.getElement())?.focus({preventScroll:!0,...e})},0)},[P,X]);(0,s.useEffect)(()=>{let e=Ce.current,t=e.length;if(t>0){for(let n=0;n<t;n++)e[n]();Ce.current=[]}},[X]);let Ne=(0,s.useCallback)((e,t)=>{(function(e){if(!e)throw Error(`Invariant failed`)})(typeof e==`number`&&typeof t==`number`);let n=Be.current?.getBoundingClientRect();return n?{x:e-n.x,y:t-n.y}:{x:e,y:t}},[]),Pe=(0,l.useCallbackRef)((e,t)=>{if(Object.keys(X).length===1)return X[u.AnchorLocation.Center];let n=Ne(e,t);if(!n)return X[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=X[o[e]];t&&O(r,i,t.getPaneBounds())&&(a=t)}return a||=X[u.AnchorLocation.Center],a},[X,o]);(0,s.useEffect)(()=>{let e=Y?.[1]?.scrollOffset??0,t=J?.[1]?.scrollOffset??0;z.setContent(ke,Ae,e,t)},[z,ke,Ae,Y,J]);let Fe=(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=z.getTarget();t!==void 0&&(t=i.left+(t??0)),n!==void 0&&(n=i.top+(n??0)),i.left===t&&i.top===n||ze({left:t,top:n,behavior:r})},[]),Ie=(0,l.useCallbackRef)(e=>e===void 0?X[P]??X[u.AnchorLocation.Center]??null:X[e]??null,[X,P]),Le=(0,l.useCallbackRef)(e=>{let t=X[P];if(!t)return X[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=Y[0].minCoord,r.colEnd=Y[0].maxCoord),n&&u.CoordUtils.isCellWithinRange(e,r)?t:X[u.AnchorLocation.Center]},[X,P]),Re=(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=X[n],!i)return new Promise((e,t)=>{t(`Invalid view`)})}else i=Le(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}=z.getScroll();g.left!==void 0&&(g.left>_?g.left+=ue:g.left<_&&(g.left-=le)),g.top!==void 0&&(g.top>v?g.top+=ue:g.top<v&&(g.top-=le));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)<de||!z.isSettled()?`instant`:`smooth`);return new Promise((e,t)=>{try{ze({...g,behavior:S}),e(g)}catch(e){t(e)}})},[ke,Ae,X,o]),ze=(0,l.useCallbackRef)(e=>{let t=e?.left??e?.[0],n=e?.top??e?.[1],r=z.getTarget(),i=t??r.left,a=n??r.top,o=e?.behavior===`smooth`;z.setTarget(i,a,o)},[]),Be=(0,l.useImperativeElement)(t,()=>({focus:Me,invalidate:q,scrollTo:ze,scrollBy:Fe,scrollCellCoordsIntoView:Re,getPaneFromClient:Pe,getPaneFromCell:Le,getPane:Ie,onPaneChangeOnce:e=>{Ce.current.push(e)}}),[X]);(0,s.useEffect)(()=>z.observe(Be.current),[z]);let Ve=(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)(ae,{pane:e,viewport:z,children:b?b(e,n):n}):null},He=(0,s.useMemo)(()=>{let e={},t=Object.keys(X),n=t.length;for(let r=0;r<n;r++){let n=t[r];e[n]=Ve(X[n],y)}return e},[L,y,X,b,n,r]),Ue=(0,s.useMemo)(()=>Z.left===0?null:(0,c.jsx)(g,{linePoints:[0,0,0,be+1],bounds:{x:Z.left,y:0,width:1,height:be+1},...h}),[L,Z.left,be,h]),We=(0,s.useMemo)(()=>Z.top===0?null:(0,c.jsx)(g,{linePoints:[0,0,ye+1,0],bounds:{x:0,y:Z.top,width:ye+1,height:1},..._}),[L,Z.top,ye,_]),Ge=(0,s.useRef)(!1),Ke=(0,s.useMemo)(()=>{if(!je)return null;let e=(e,t)=>{let n=e.anchor,r=t.getPaneBounds(),i=Z.left>0,a=Z.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:z,children:e.elemStage?(0,s.cloneElement)(e.elemStage,{style:y},He?.[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=X[i];n[r]=a?e(t,a):null}return(0,c.jsxs)(c.Fragment,{children:[n,Ue,We]})},[X,Oe,He,ye,be,je,Z]);return(0,s.useEffect)(()=>{!Ge.current&&Ke&&je&&(Ge.current=!0,N?.(Be.current))},[Ke,je]),(0,c.jsx)(`div`,{ref:Be,className:C(w,`grid-surface`,H[`sheetxl-grid`]),style:{overflow:`hidden`,...k},...A,children:(0,c.jsx)(se,{children:Ke})})}));U.displayName=`GridSurface`;var ce=Object.freeze({getColOffset:e=>75*e,getColIndex:e=>Math.floor(e/75),getRowOffset:e=>20*e,getRowIndex:e=>Math.floor(e/20)}),le=0,ue=20,de=150,fe=Object.freeze({bottom:-4,right:-4}),pe=Object.freeze({horizontal:!0,vertical:!0}),me=Object.freeze({horizontal:!0,vertical:!1}),he=Object.freeze({horizontal:!1,vertical:!0}),ge=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)(V),r=(0,s.useRef)(null);r.current||=oe();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 K=(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&&!ye&&(ye=!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:q(t),pointermove:q(n),pointerup:q(r),pointerleave:q(i),mousedown:q(a),mouseenter:q(o),mouseleave:q(l),mousemove:q(u),mouseout:q(d),mouseover:q(f),mouseup:q(p),dblclick:q(m),keydown:q(h),keypress:q(g),keyup:q(_),focus:q(v),blur:q(y),contextmenu:q(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})})});K.displayName=`Layer`;var q=e=>e?t=>e(t):void 0,ye=!1,be=!1,xe=`_virtual-div_16eab_1`,J=(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)||Se||(Se=!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 be||(be=!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,xe),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})})}));J.displayName=`VirtualDiv`;var Se=!1,Y=(e,t,n,r)=>({x:e,y:t,width:n,height:r,top:t,left:e,right:e+n,bottom:t+r}),Ce=Y(0,0,0,0),we=e=>{let t=e.getElement()?.getBoundingClientRect?.();return{x:t?.left??0,y:t?.top??0}},Te=e=>{let t=e.getElement()?.getBoundingClientRect?.();return t?Y(t.left,t.top,t.width,t.height):Ce},Ee={side:`t`,align:`center`},De=[u.AnchorLocation.TopLeft,u.AnchorLocation.Top,u.AnchorLocation.Left,u.AnchorLocation.Center],Oe=new Set([u.AnchorLocation.Top,u.AnchorLocation.TopLeft]),X=new Set([u.AnchorLocation.Left,u.AnchorLocation.TopLeft]),ke=(e,t,n,r,i)=>{let a=null,o=null,s=1/0,c=!1;for(let l=0;l<De.length;l++){let u=e[De[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}},Ae=(e,t)=>{let n=Oe.has(e.getAnchor()),r=X.has(t.getAnchor());return n&&r?u.AnchorLocation.TopLeft:n?u.AnchorLocation.Top:r?u.AnchorLocation.Left:u.AnchorLocation.Center},je=(e,t)=>{let n=Te(e),r=e.getBoundsFromRange(t);return Y(n.left+r.x,n.top+r.y,r.width,r.height)},Z=(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=Ee,a=`hide`)=>{if(!e)return{rect:Ce,clipped:!0,boundaryRect:Ce,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===`pane`){let t=we(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=we(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=Z(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=we(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=we(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:Z(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=ke(d,`row`,l.rowStart,l.rowEnd,f.rowIndex),m=ke(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=je(g,l),y=je(_,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=Te(_),T=Te(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:Ae(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=Ee,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??Ee,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:{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&>(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),{refs:_,floatingStyles:v}=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:(e,t,n)=>Kt(e,t,n,{animationFrame:!0}),middleware:[nn({mainAxis:n,alignmentAxis:r}),an(),rn({padding:4})]});if(!i)return null;let y=typeof p==`function`?p(t):p;return(0,d.createPortal)((0,c.jsx)(`div`,{ref:_.setFloating,className:[o,h].filter(Boolean).join(` `)||void 0,...g,style:{...v,zIndex:f,...u},children:y}),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={pointerEvents:`auto`},dn=(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:un}),[m]);return(0,s.useEffect)(()=>()=>{f(),p()},[]),{open:r,setTarget:h,tipProps:_,close:g}},fn=e=>{let{probe:t,placement:n,offset:r=6,alignOffset:i=0,openDelay:a=300,closeDelay:o=150,whenOff:u=`hide`,boundary:d,zIndex:f,dismiss:p,children:m,className:h,style:g}=e,_=W(),{open:v,setTarget:y,tipProps:b,close:x}=dn({openDelay:a,closeDelay:o}),[S,w]=(0,s.useState)(null),T=(0,s.useRef)(null),E=(0,l.useCallbackRef)(e=>{let n=_.getCellFromPointer(e.clientX,e.clientY);if(n){let e=t(n,_);if(e&&e.range){let t=e.key??R(e.range);t!==T.current&&(T.current=t,w({key:t,range:e.range,data:e.data})),y(t);return}}T.current=null,y(null)},[_,t,y]),D=(0,l.useCallbackRef)(()=>{T.current=null,y(null)},[y]);return(0,s.useEffect)(()=>{p&&(T.current=null,x(),w(null))},[p,x]),(0,c.jsx)(K,{className:C(h,`hover-tip`),onPointerMove:E,onPointerLeave:D,children:S&&(0,c.jsx)(ln,{anchor:{range:S.range},placement:n,offset:r,alignOffset:i,boundary:d,zIndex:f,open:v,whenOff:u,style:g,children:e=>m({range:S.range,data:S.data,tipProps:b,state:e})})})};fn.displayName=`HoverTipLayer`;var pn={t:`↑`,b:`↓`,l:`←`,r:`→`},mn=e=>{let t=``,n=e;do t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26)-1;while(n>=0);return t},hn=e=>{let t=`${mn(e.colStart)}${e.rowStart+1}`,n=`${mn(e.colEnd)}${e.rowEnd+1}`;return t===n?t:`${t}:${n}`},gn={border:`none`,background:`transparent`,color:`inherit`,cursor:`pointer`,font:`14px/1 system-ui`,padding:0,width:18,height:18,borderRadius:4,opacity:.6},_n={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},vn={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`},yn=({direction:e,label:t,onGoto:n,onCancel:r})=>(0,c.jsxs)(`div`,{style:vn,children:[(0,c.jsxs)(`button`,{onClick:n,style:{border:`none`,background:`transparent`,color:`inherit`,cursor:`pointer`,font:`12px system-ui`},children:[pn[e],` `,t]}),r&&(0,c.jsx)(`button`,{"aria-label":`Cancel`,onClick:r,style:{...gn,opacity:.8},children:`×`})]}),bn=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)(yn,{direction:e.slid?.direction??n.side,label:a??hn(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:{..._n,...d},children:[s&&(0,c.jsx)(`button`,{"aria-label":`Cancel`,onClick:s,style:{...gn,position:`absolute`,top:4,right:4},children:`×`}),r]})}})};bn.displayName=`RangePrompt`;var xn={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)`},Sn=(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)(J,{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})})});Sn.displayName=`RangeRect`;var Cn=()=>typeof window<`u`?window:null,wn=(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)},Tn=(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=(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.edgeScroll??(t=>wn(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})})(),n?.(c.dragMode??null),c):null},move:(e,t,n)=>{a&&(s={x:e,y:t},p(e,t,n)?(f(),c=setTimeout(function e(){c=a&&s&&p(s.x,s.y)?setTimeout(e,60):null},60)):f())},reset:()=>{let e=a;return a=null,o=null,s=null,f(),d(),e&&n?.(null),e},dispose:()=>{f(),d()}}},En=(e,t,n)=>{let r=Tn(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&&Cn()?.removeEventListener(`keydown`,c,!0),c=null},d=()=>{l&&=(Cn()?.removeEventListener(`pointerup`,l),Cn()?.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))},Cn()?.addEventListener(`keydown`,c,!0)}else i=!1,l=e=>p(e.type===`pointercancel`,e),Cn()?.addEventListener(`pointerup`,l),Cn()?.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 Dn(e,t,n,r){let i=Tn(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 On=e=>{let t=W(),[n,r]=(0,s.useState)(null),i=(0,s.useRef)(e);i.current=e;let a=(0,s.useMemo)(()=>En(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}},kn=e=>{let t=W(),[n,r]=(0,s.useState)(null),i=(0,s.useRef)(e);i.current=e;let a=(0,s.useMemo)(()=>Dn(t,(e,t)=>i.current(e,t),r),[t]);return(0,s.useEffect)(()=>()=>a.dispose(),[a]),{start:a.start,dragMode:n}},An=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,onHoverChange:m,hoverStyle:h,animatedTransition:g,renderHandle:_,children:v,className:y,style:b,preserveFocus:x,clampToView:S}=e,C=W(),[w,T]=(0,s.useState)(!1),{start:E,dragMode:D}=kn((e,t)=>{if(t.button!==0)return null;t.stopPropagation(),x&&t.preventDefault();let n=e,r=e;return u?.(n,t),{dragMode:`handle`,drag:(e,i)=>{r=e,d?.(n,e,i??t)},end:e=>{f?.(n,r,e)},cancel:()=>{p?.()}}}),O=D!==null&&a?a:i??Pn[n],k=C.getBoundsFromRange(t);if(!k)return null;let A=l.ReactUtils.getDevicePixelRatio(),j=Nn(k.x,k.x+k.width,jn[n],A),M=Nn(k.y,k.y+k.height,Mn[n],A);if(S){if(!C.toClipBounds(C.getBoundsFromRange(t)))return null;let e=C.getPaneBounds(),n=r/2+1;!0!==S&&S!==`x`||(j=Math.max(n,Math.min(e.width-n,j))),!0!==S&&S!==`y`||(M=Math.max(n,Math.min(e.height-n,M)))}let N={position:`absolute`,cursor:O,pointerEvents:`all`,left:0,top:0,transform:`translate(${j}px, ${M}px) translate(-50%, -50%)`,...g?{transition:`transform 60ms ease-in-out`,willChange:`transform`}:void 0},P={onPointerDown:e=>E(e),onPointerEnter:()=>{T(!0),m?.(!0)},onPointerLeave:()=>{T(!1),m?.(!1)}};return _?(0,c.jsx)(c.Fragment,{children:_({anchor:n,size:r,cursor:O,background:o,hovered:w,handleProps:{...P,style:N}})}):(0,c.jsx)(`div`,{className:y,...P,style:{...N,width:r,height:r,background:v==null?o:void 0,border:v==null?`1px solid var(--sxl-color-base-100, white)`:void 0,borderRadius:1,boxSizing:`border-box`,...b,...w?h:void 0},children:v})};An.displayName=`DragHandle`;var jn={tl:`leading`,l:`leading`,bl:`leading`,t:`center`,b:`center`,tr:`trailing`,r:`trailing`,br:`trailing`},Mn={tl:`leading`,t:`leading`,tr:`leading`,l:`center`,r:`center`,bl:`trailing`,b:`trailing`,br:`trailing`},Nn=(e,t,n,r)=>n===`center`?l.ReactUtils.snapDeviceEdge((e+t)/2,r):l.ReactUtils.edgeCenter(n===`leading`?e:t,n,2,r),Pn={tl:`nwse-resize`,br:`nwse-resize`,tr:`nesw-resize`,bl:`nesw-resize`,t:`ns-resize`,b:`ns-resize`,l:`ew-resize`,r:`ew-resize`},Fn=e=>{let{range:t,children:n,grip:r=`entire`,hitSize:i=10,onHoverChange:a,onDragStateChange:o,onDragStart:d,onDragMove:f,onDragEnd:p,renderMove:m,preserveFocus:h}=e,g=W(),v=t?`range-move:${t.rowStart}:${t.colStart}:${t.rowEnd}:${t.colEnd}`:`range-move`,y=(0,s.useRef)(null),[b,x]=ve(v,null),{start:S,dragMode:C}=kn((e,n)=>{if(n.button!==0||!t)return null;n.stopPropagation(),h&&n.preventDefault();let r=e,i=t,a=i;return o?.(!0),d?.(i,n),{dragMode:`move`,drag:(e,t)=>{a=(e=>In(i,e.rowIndex-r.rowIndex,e.colIndex-r.colIndex,g.getTotalRange()))(e),m&&x(a),f?.(a,t??n)},end:e=>{o?.(!1),m&&x(null),u.CoordUtils.isEqualRanges(a,i)||p?.(a,e)},cancel:()=>{o?.(!1),m&&x(null)}}}),w=C===null?`move`:`grabbing`;if(!t)return null;let T={onPointerDown:e=>S(e,y.current)},E=a?{onPointerEnter:()=>a(!0),onPointerLeave:()=>a(!1)}:void 0,D=i/l.ReactUtils.getDevicePixelRatio(),O=g?.getBoundsFromRange(t),k=O?{x:O.x-D,y:O.y-D,width:O.width+2*D,height:O.height+2*D}:void 0;return(0,c.jsxs)(c.Fragment,{children:[r===`entire`?(0,c.jsx)(J,{ref:y,...k?{bounds:k}:{range:t},style:{cursor:w},...T,...E}):(0,c.jsx)(J,{ref:y,range:t,clipInsets:-D/2,style:{pointerEvents:`none`,cursor:w},...T,children:(0,c.jsx)(_,{stroke:`transparent`,alignWidth:i,propsStrokePath:{cursor:`move`,pointerEvents:`stroke`,...E}})}),n,b&&m?.(b)]})};Fn.displayName=`Draggable`;var In=(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}},Ln=[`tl`,`tr`,`br`,`bl`],Rn=[`tl`,`t`,`tr`,`r`,`br`,`b`,`bl`,`l`],zn=e=>{let{range:t,anchors:n=Rn,onDragStart:r,onDragMove:i,onDragEnd:a,onDragCancel:o,onHandleHoverChange:l,size:u=8,renderHandle:d,preserveFocus:f,...p}=e,m={...xn,...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)(Sn,{range:b,...m}),n.map(e=>(0,c.jsx)(An,{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=Bn(y.current??t,e,r,g.getTotalRange());v(o),i?.(o,a)},onDragEnd:(n,r,i)=>{let o=Bn(y.current??t,e,r,g.getTotalRange());y.current=null,v(null),a?.(o,i)},onDragCancel:()=>{y.current=null,v(null),o?.()}},e))]})};zn.displayName=`RangeResizer`;var Bn=(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)}},Vn=e=>{let{range:t,snapDestination:n,onDragStart:r,onDragMove:i,onDragEnd:a,onDragDone:o,renderHandle:l,...d}=e,f={...xn,fill:void 0,...d},p=f.stroke,m={...f,strokeDasharray:`3 2`},h=W(),g=(0,s.useRef)(null),[_,v]=ve(`range-fill`,null);if(!t)return null;let y=h.getTotalRange(),b=t.rowStart===y.rowStart&&t.rowEnd===y.rowEnd,x=t.colStart===y.colStart&&t.colEnd===y.colEnd;if(b&&x)return null;let S=Object.keys(h.getAllPanes()).length<=1,C=h.getBoundsFromRange(t),w=h.getPaneBounds(),T=S&&C.y>=0&&C.y+C.height<=w.height,E=S&&C.x>=0&&C.x+C.width<=w.width,D=b&&!T?`tr`:x&&!E?`bl`:`br`,O=D===`tr`?`y`:D===`bl`&&`x`;return O&&!((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})(h,t,b,x)?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(An,{range:t,anchor:D,clampToView:O,cursor:`crosshair`,background:p,renderHandle:l,onDragStart:(e,n)=>{g.current=null,v(null),r?.(t,n)},onDragMove:(e,r,a)=>{let o=((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);return s===0&&c===0?null: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)}})(t,r,h.getTotalRange());o&&n&&(o=n(t,o)),g.current=o,v(o),o&&i?.(o,a)},onDragEnd:(e,t,n)=>{let r=g.current;g.current=null,v(null),r&&a?.(r,n),o?.(n)},onDragCancel:()=>{g.current=null,v(null),o?.()}}),_&&(0,c.jsx)(Sn,{range:_,...m})]})};Vn.displayName=`FillHandle`;var Hn=(0,s.memo)(e=>{let{value:t,pane: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})}),Un=Object.freeze({cells:[],rangesH:[],rangesV:[]}),Wn=!1,Gn=new WeakMap,Kn=(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=Gn.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 Un;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 Un;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=Xn(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}):Wn||(Wn=!0,console.warn(`grid-react: no bounds for cell`,Xn(a.rowStart,a.colStart)))}return{cells:h,rangesH:g,rangesV:_}})(e,t);return Gn.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},qn=Object.freeze({rangesH:[],rangesV:[]}),Jn=new WeakMap,Yn=(e,t={})=>{let n=e.getVisibleRange(),r=Jn.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=Xn(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?qn:{rangesH:i,rangesV:a}})(e,t);return Jn.set(e,{rowStart:n.rowStart,colStart:n.colStart,rowEnd:n.rowEnd,colEnd:n.colEnd,getVisibleCells:t.getVisibleCells,cacheToken:t.cacheToken,ranges:i}),i},Xn=(e,t)=>`${e}:${t}`,Zn={tiles:`_tiles_ikr1b_7`,gridlines:`_gridlines_ikr1b_26`},Qn=(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(_/er)*er,b=Math.floor(v/er)*er,x=u.getVisibleRange(),S=0,w=-1,T=0,E=-1;x&&(S=Math.max(0,Math.floor(x.rowStart/$)-tr),w=Math.floor(x.rowEnd/$)+tr,T=Math.max(0,Math.floor(x.colStart/$)-tr),E=Math.floor(x.colEnd/$)+tr);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.getTotalRange(),s={rowStart:Math.max(o.rowStart,S*$),colStart:Math.max(o.colStart,T*$),rowEnd:Math.min(o.rowEnd,(w+1)*$-1),colEnd:Math.min(o.colEnd,(E+1)*$-1)},{cells:l}=Kn(u,{getVisibleCells:r,hiddenCellAt:i,bufferRange:s,cacheToken:n}),f=new Map;for(let e=0;e<l.length;e++){let t=l[e],n=`${Math.floor(t.cell.rowIndex/$)}:${Math.floor(t.cell.colIndex/$)}`,r=f.get(n);r||(r=[],f.set(n,r)),r.push(t)}let p=[],h=(e,n)=>{if(e*$>o.rowEnd||n*$>o.colEnd)return;let r=e>=S&&e<=w&&n>=T&&n<=E,i=`${e}:${n}`,s=a.get(i);if(s===void 0){let l=f.get(i);if(!l&&!rr)return;let p=u.getBoundsFromRange({rowStart:e*$,colStart:n*$,rowEnd:Math.min(o.rowEnd,e*$+$-1),colEnd:Math.min(o.colEnd,n*$+$-1)}),m=_+p.x-y,h=v+p.y-b,g=[];if(rr&&g.push((0,c.jsx)(`div`,{style:{position:`absolute`,left:0,top:0,width:p.width,height:p.height,background:(e+n)%2==0?`rgba(0,128,255,0.05)`:`rgba(255,140,0,0.05)`,pointerEvents:`none`}},`__bg`)),l)for(let e=0;e<l.length;e++){let{cell:n,range:r,bounds:i,value:a}=l[e];i&&g.push(t({key:`pane:${d}:cell:${Xn(n.rowIndex,n.colIndex)}`,cell:n,bounds:i,range:r,pane:u,value:a,"data-rc":Xn(n.rowIndex,n.colIndex),style:{left:i.x-p.x,top:i.y-p.y,width:i.width,height:i.height}}))}if(s=(0,c.jsx)(`div`,{className:`tile`,style:{transform:`translate(${m}px, ${h}px)`},children:g},`pane:${d}:tile:${e}:${n}`),r&&(a.set(i,s),a.size>nr)){let e=a.keys().next().value;e!==void 0&&a.delete(e)}}s&&p.push(s)};if(rr){for(let e=S;e<=w&&!(e*$>o.rowEnd);e++)for(let t=T;t<=E&&!(t*$>o.colEnd);t++)h(e,t);for(let e of f.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)&&h(n,r)}}else for(let e of f.keys()){let t=e.indexOf(`:`);h(Number(e.slice(0,t)),Number(e.slice(t+1)))}return p},[`${S}:${w}:${T}:${E}`,n,t,r,i,u,d,y,b]);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(J,{fill:!0,className:C(Zn.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="${Xn(a.rowIndex,a.colIndex)}"]{visibility:hidden !important;}`}):null]})});Qn.displayName=`CellTileDiv`;var $n=(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)(K,{className:C(o,`tiles`),...l,children:(0,c.jsx)(Qn,{renderCell:t,cacheToken:n,getVisibleCells:r,hiddenCellAt:i,suppressCell:a,style:s})})});$n.displayName=`CellLayer`;var $=8,er=1<<19,tr=1,nr=512,rr=!1,ir=(e,t,n)=>{let r=l.ReactUtils.getDevicePixelRatio(),i=cr/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},ar=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},or=(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(cr/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})})},sr=(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}=Yn(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}|${ar(y)}`,M=b.length===0?`${w}|${A}|${x}`:`${w}|${S}|${A}|${x}|${ar(b)}`,N=(0,s.useMemo)(()=>_?ir(h,!0,y):null,[h,_,j]),P=(0,s.useMemo)(()=>v?ir(h,!1,b):null,[h,v,M]);return _||v?(0,c.jsx)(K,{...m,className:C(f,`gridlines`),children:(0,c.jsxs)(J,{fill:!0,className:Zn.gridlines,style:{pointerEvents:`none`,...p},children:[_&&N?or(h,!0,N,n,r):null,v&&P?or(h,!1,P,n,i):null]})}):null});sr.displayName=`GridlineLayer`;var cr=1,lr=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??(()=>fr)}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=ur({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=dr(i.cell,r);this.setSelection({cell:s,ranges:o,rangeIndex:a>=0?a:0})}append(e,t=e){let n=ur({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)}}},ur=(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)}),dr=(e,t)=>({rowIndex:w(e.rowIndex,t.rowStart,t.rowEnd),colIndex:w(e.colIndex,t.colStart,t.colEnd)}),fr={rowStart:0,colStart:0,rowEnd:2**53-1,colEnd:2**53-1},pr=`var(--sxl-color-primary, rgb(33, 115, 70))`,mr=`var(--sxl-color-base-100, rgb(255, 255, 255))`,hr=`var(--sxl-color-warning, rgb(255, 0, 0))`,gr=e=>`color-mix(in srgb, var(--sxl-color-primary, rgb(33, 115, 70)) ${e}%, transparent)`,_r={fill:{fill:gr(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:mr,alignWidth:2,inset:1}},vr={fill:{fill:gr(6)},border:{stroke:pr,alignWidth:1},inner:{stroke:mr,alignWidth:1,inset:1}},yr={stroke:pr,alignWidth:1,inset:2},br={fill:{fill:`color-mix(in srgb, ${hr} 10%, transparent)`},border:{stroke:hr,alignWidth:2}},xr=(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=On((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}},Sr=e=>{let{selection:t,color:n=`var(--sxl-color-primary, rgb(33, 115, 70))`,size:r=22}=e,i=G(),a=Tr((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=Dn(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=>wn(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)(Cr,{spec:e,size:r,color:n,dragging:f,onBeginDrag:h},e.key))})};Sr.displayName=`SelectionTouchGrips`;var Cr=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)(wr,{state:e,size:n,color:r,dragging:i,pin:t.pin,onBeginDrag:n=>{e.pane&&a(e.pane,t.pivot,t.axis,n)}})})},wr=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())},Tr=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)},Er=[u.Direction.Left,u.Direction.Right,u.Direction.Up,u.Direction.Down],Dr={[u.Direction.Left]:`ArrowLeft`,[u.Direction.Right]:`ArrowRight`,[u.Direction.Up]:`ArrowUp`,[u.Direction.Down]:`ArrowDown`},Or={[u.Direction.Left]:`Left`,[u.Direction.Right]:`Right`,[u.Direction.Up]:`Up`,[u.Direction.Down]:`Down`},kr=(e,t)=>t===void 0?e:t===null?null:{...e,...t},Ar=(e,t)=>t?{fill:kr(e.fill,t.fill),border:kr(e.border,t.border),inner:kr(e.inner,t.inner)}:e,jr={side:`b`,align:`end`},Mr=s.default.forwardRef((e,t)=>{let{selection:n,getContentBounds:r,getRegionBounds:i,scrollIntoView:a,singleStyle:o,multiStyle:d,multiAnchorStyle:f,singleAnchorStyle:p,removePreviewStyle:m,singleLayer:h,multiLayer:g,enabledMove:_,onMove:v,onMoveStart:y,onMoveUpdate:b,onMoveEnd:x,enableFill:S,snapFillDestination:C,onFill:w,onFillStart:T,onFillPreview:E,onFillEnd:D,onSelectionEnd:O,renderTip:k,tipPlacement:A,disableKeyboard:j,anchorHole:M=!0,...N}=e,P=(0,l.useBoundSyncExternalStore)(n,e=>e.getSelection()),F=xr(n,{onSelectionEnd:O}),[I,L]=s.default.useState(null),R=W(),ee=s.default.useRef(n);ee.current=n;let te=s.default.useRef(R);te.current=R;let ne=s.default.useRef(r);ne.current=r;let z=s.default.useRef(i);z.current=i;let re=s.default.useRef(a);re.current=a;let ie=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?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 Er){let t=Or[e],n=Dr[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:()=>ee.current,getPane:()=>te.current,getContentBounds:()=>ne.current?.()??te.current.getTotalRange(),getScrollIntoView:()=>re.current,getRegionBounds:e=>z.current?.(e)??null}),[]);s.default.useImperativeHandle(t,()=>ie,[ie]);let B=!!P.ranges&&P.ranges.length>0,ae=B?[...P.ranges]:[u.CoordUtils.cellToRange(P.cell)],oe=ae.length>1,V=P.rangeIndex??-1,se=B?V>=0?V:ae.length-1:0,H=R.getRangeFromCell(P.cell),U=u.CoordUtils.unionRanges(ae[se]??u.CoordUtils.cellToRange(P.cell),H),ce=ae.filter((e,t)=>t!==se),le=oe?Ar(vr,d):Ar(_r,o),ue={...yr,...f},de=Ar(br,m),fe=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})},pe=I??(F.dragMode===`extend`?{kind:`select`,range:U}:null),me=pe&&k?k(pe):null,he=s.default.Children.map(oe?g:h,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),fe(e)}})});return(0,c.jsxs)(K,{...N,onPointerDown:F.onPointerDown,onPointerMove:F.onPointerMove,onPointerUp:F.onPointerUp,onKeyDown:j?void 0:e=>{ie.handleKey(e)&&(e.preventDefault(),e.stopPropagation())},children:[oe?(0,c.jsxs)(c.Fragment,{children:[ce.map((e,t)=>(0,c.jsx)(s.default.Fragment,{children:Nr(le,e)},`other-${t}`)),Nr(le,U,M?H:void 0),(0,c.jsx)(Sn,{range:H,...ue})]}):(0,c.jsxs)(c.Fragment,{children:[Nr(le,U,M?H:void 0),p&&(0,c.jsx)(Sn,{range:H,...p})]}),!oe&&_&&(0,c.jsx)(Fn,{range:U,grip:`edges`,renderMove:e=>le.border&&(0,c.jsx)(Sn,{range:e,...le.border,animatedTransition:!0,style:{opacity:.6}}),onDragStart:(e,t)=>{y?.(e,t),L({kind:`move`,from:e,to:e})},onDragMove:(e,t)=>{b?.(U,e,t),L({kind:`move`,from:U,to:e})},onDragStateChange:e=>{e||(x?.(),L(null))},onDragEnd:(e,t)=>{v?.(U,e,t),n.modify({rowIndex:e.rowEnd,colIndex:e.colEnd},{rowIndex:e.rowStart,colIndex:e.colStart})}}),!oe&&S&&(0,c.jsx)(Vn,{range:U,snapDestination:C,...le.border,onDragStart:(e,t)=>{T?.(e,t),L({kind:`fill`,template:e,destination:e})},onDragMove:(e,t)=>{E?.(U,e,t),L({kind:`fill`,template:U,destination:e})},onDragEnd:(e,t)=>{w?.(U,e,t),fe(e)},onDragDone:()=>{D?.(),L(null)}}),F.removePreview&&Nr(de,F.removePreview),he,me!=null&&pe&&(0,c.jsx)(ln,{anchor:{range:(ge=pe,ge.kind===`move`?ge.to:ge.kind===`fill`?ge.destination:ge.range)},placement:A??jr,offset:8,whenOff:`clamp`,open:!0,style:{pointerEvents:`none`},children:me})]});var ge});Mr.displayName=`SelectionLayer`;var Nr=(e,t,n,r=!1)=>(0,c.jsxs)(c.Fragment,{children:[e.fill&&(0,c.jsx)(Sn,{className:`fill`,animatedTransition:r,range:t,hole:n,...e.fill}),e.inner&&(0,c.jsx)(Sn,{className:`inner`,animatedTransition:r,range:t,...e.inner}),e.border&&(0,c.jsx)(Sn,{className:`border`,animatedTransition:r,range:t,...e.border})]}),Pr=[`#1a73e8`,`#d93025`,`#1e8e3e`,`#9334e6`,`#e37400`,`#12a4af`,`#d01884`],Fr=Array.from({length:l.SERIES_COUNT},(e,t)=>`var(--sxl-color-series-${t+1}, ${Pr[t]})`),Ir=`var(--sxl-color-primary, rgb(0, 120, 215))`,Lr=(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))}),Rr=e=>({stroke:Fr.length?Fr[e%Fr.length]:Ir}),zr=e=>{let{selection:t,getRangeStyle:n=Rr,anchors:r=Ln,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=On((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,Lr(t,e,y.getTotalRange())),{drag:e=>P(n,Lr(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,Lr(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)(K,{...v,children:[(!a||O)&&(0,c.jsx)(J,{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)(Fn,{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??Ir;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)(zn,{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}`)})]})};zr.displayName=`RangesPickerLayer`;var Br=0,Vr=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.state={mode:t.mode??`enter`,coords:e.coords,clean:e.clean,dirty:t.dirty,initialSelection:t.initialSelection??null,autoFocus:t.autoFocus??!0,token:++Br}}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 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())}},Hr=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,Ur=(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},[])},Wr=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=e.which===l.KeyCodes.Enter&&f.ctrlKey;if(!a(t?{broadcast:!0}:void 0)||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])},Gr=(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}},Kr=96/72*11,qr=`Calibri, sans-serif`,Jr=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=Wr({mode:n,value:_,onDirtyChange:f,onModeChange:p,onCommit:m,onCancel:h,setCaret:Ur(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:qr,fontSize:Kr*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:qr,fontSize:`${Kr}px`,lineHeight:1.2},children:_.length===0?` `:_})]})};function Yr(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)(Jr,{...v})})}Jr.displayName=`DefaultEditorInput`,Yr.displayName=`EditorDiv`;var Xr=`ew-resize`,Zr=`ns-resize`,Qr=(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?Xr:Zr,...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]})})),$r=e=>(0,c.jsx)(Qr,{...e}),ei=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{axis:n,index:r,disabled:i=!1,disabledResize:a=!1,resizeThreshold:o=1,renderDivider:f=$r,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?Xr:Zr,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})]})}));ei.displayName=`HeaderDividerAnchor`;var ti=(e,t,n)=>t===u.RangeAxis.Column?{rowIndex:n.rowStart,colIndex:e.colIndex}:{rowIndex:e.rowIndex,colIndex:n.colStart},ni=(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)},ri=(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=ni(r??e,e,t,l),f=i??ti(e,t,o().getVisibleRange());u?c(a,d,f):s(d,f,`replace`)};return En(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,ni(r,t,g,_),i??T)):(r=t,i=T,a=D||s<0?o.length:s,c(a,ni(t,t,g,_),T))}else E&&r?s(ni(r,t,g,_),i??T,`replace`):D?(r=t,i=T,s(ni(t,t,g,_),T,`append`)):(r=t,i=T,s(ni(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)},capture:m,captureEvents:y}})},ii=e=>e==null?[]:Array.isArray(e)?e:[e],ai=(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)(sr,{showGridLines:f,gridLineColor:m,propsRows:h,propsColumns:g,getVisibleCells:_,hiddenCellAt:v},`__gridlines`)),e.push(...ii(y)),e.push(...ii(d)),u&&e.push((0,c.jsx)($n,{renderCell:u,getVisibleCells:_,hiddenCellAt:v,cacheToken:E},`__cells`)),e.push(...ii(b)),e},[f,m,h,g,_,v,y,d,u,E,b]);return(0,c.jsx)(U,{ref:O,...x,rowCount:n,columnCount:r,metrics:C,children:k})}));ai.displayName=`Grid`;var oi=function(){},si=typeof window<`u`,ci=si?s.useLayoutEffect:s.useEffect,li={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0},ui=si&&window.ResizeObserver!==void 0?function(){var e=(0,s.useState)(null),t=e[0],n=e[1],r=(0,s.useState)(li),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 ci(function(){if(t)return o.observe(t),function(){o.disconnect()}},[t]),[n,i]}:function(){return[oi,li]},di={fill:{fill:`color-mix(in srgb, var(--sxl-color-primary, rgb(0, 120, 215)) 14%, transparent)`},border:null,inner:null},fi={stroke:`var(--sxl-color-primary, rgb(0, 120, 215))`,alignWidth:1,inset:1},pi=(0,s.forwardRef)(function(e,t){let{itemCount:n,renderItem:r,itemHeight:i=24,selection:a,onKeyDown:o,cacheToken:u,className:d,style:f,children:m,...h}=e,g=(0,l.useImperativeElement)(t,()=>({isList:()=>!0}),[]),_=(0,s.useMemo)(()=>new l.Viewport,[]),v=(0,s.useMemo)(()=>new lr({getBounds:()=>({rowStart:0,colStart:0,rowEnd:Math.max(0,n-1),colEnd:0})}),[n]),y=a??v,[b,{width:x}]=ui(),S=p({rowCount:n,columnCount:1,getRowHeight:i,getColumnWidth:x}),w=(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]);return(0,c.jsx)(`div`,{ref:g,className:C(`list`,d),style:{position:`relative`,overflow:`hidden`,...f},...h,children:(0,c.jsx)(l.ScrollPane,{viewport:_,showVerticalScrollbar:!0,showHorizontalScrollbar:!1,style:{width:`100%`,height:`100%`},children:(0,c.jsx)(`div`,{ref:b,style:{width:`100%`,height:`100%`},children:(0,c.jsxs)(U,{viewport:_,style:{width:`100%`,height:`100%`},rowCount:n,columnCount:1,metrics:S,children:[(0,c.jsx)(Mr,{selection:y,anchorHole:!1,singleStyle:di,singleAnchorStyle:fi,multiAnchorStyle:fi},`__selection`),(0,c.jsx)($n,{renderCell:w,cacheToken:u},`__cells`),o?(0,c.jsx)(K,{onKeyDown:o},`__keys`):null]})})})})}),mi=(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=mi,renderDivider:u,selectAllLabel:d,itemHeight:f,selection:p,cacheToken:m,className:h,style:g,children:_,...v}=e,y=(0,l.useImperativeElement)(t,()=>({isCheckboxList:()=>!0}),[]),b=(0,s.useMemo)(()=>new lr({getBounds:()=>({rowStart:0,colStart:0,rowEnd:Math.max(0,n-1),colEnd:0})}),[n]),x=p??b,S=(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]),w=(0,s.useCallback)(e=>{if(e.key!==` `&&e.key!==`Enter`)return;e.preventDefault(),e.stopPropagation();let t=!r(x.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]})(x),t)},[x,r,i]),{allChecked:T,someChecked:E}=(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:y,className:C(`checkbox-list`,h),style:{display:`flex`,flexDirection:`column`,minHeight:0,...g},...v,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),!T)},children:[(0,c.jsx)(`div`,{style:{display:`inline-flex`,pointerEvents:`none`},children:o(T,E)}),d]}),u?.()]}),(0,c.jsx)(pi,{itemCount:n,itemHeight:f,selection:x,renderItem:S,onKeyDown:w,cacheToken:m,style:{flex:`1 1 100%`,minHeight:0}})]})}),gi={light:{},dark:{"color-base-100":`#1e1e1e`,"color-base-300":`#3a3a3a`}},_i={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=$n,exports.CellTileDiv=Qn,exports.CheckboxList=hi,exports.DEFAULT_ANCHOR_STYLE=yr,exports.DEFAULT_HANDLE_STYLE=xn,exports.DEFAULT_MULTI_STYLE=vr,exports.DEFAULT_REMOVE_PREVIEW_STYLE=br,exports.DEFAULT_SINGLE_STYLE=_r,exports.DefaultCellRenderer=Hn,exports.DefaultEditable=class{constructor(e,t,n){this.current=null,this.listeners=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)}}getSession(){return this.current}startEdit(e,t={}){let n=this.createEdit(e);return!!n&&(this.current=new Vr({coords:e,...n},t),this.notify(),!0)}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=Jr,exports.DefaultHeaderDivider=Qr,exports.DefaultSelection=lr,exports.DragHandle=An,exports.Draggable=Fn,exports.EDGE_AUTO_SCROLL_MARGIN_PX=24,exports.EditSession=Vr,exports.EditorDiv=Yr,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=Hr(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=Gr(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)(K,{onKeyDown:b,onDoubleClick:x,children:E?(0,c.jsx)(J,{...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)(Jr,{...j})}):null})},exports.FillHandle=Vn,exports.GRID_SURFACE=gi,exports.Grid=ai,exports.GridSurface=U,exports.GridlineLayer=sr,exports.HEADER_SURFACE=_i,exports.HeaderDividerAnchor=ei,exports.HoverTipLayer=fn,exports.Layer=K,exports.LineSVG=g,exports.List=pi,exports.PICKER_COLORS=Fr,exports.RESIZE_ANCHORS_4=Ln,exports.RESIZE_ANCHORS_8=Rn,exports.RangePrompt=bn,exports.RangeRect=Sn,exports.RangeResizer=zn,exports.RangesPickerLayer=zr,exports.RectangleSVG=_,exports.SELECTION_CLIP_INSETS=-10,exports.SelectionLayer=Mr,exports.SelectionTouchGrips=Sr,exports.ShapeBoundsContext=m,exports.StickyAnchor=Pe,exports.StickyFloat=ln,exports.SurfaceStateContext=V,exports.SurfaceStateProvider=se,exports.VirtualDiv=J,exports.buildGridThemeCSS=({app:e,grid:t=gi,header:n=_i,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.createAxis=f,exports.createDragCells=En,exports.createHeaderSelectionPointer=ri,exports.createSurfaceStateStore=oe,exports.createWindowDragCells=Dn,exports.defaultRangeStyle=Rr,exports.edgeScrollPane=wn,exports.expandEditorBounds=Gr,exports.gridThemeVars=(e,...t)=>(0,l.themeVars)(e,gi[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=ni,exports.headerThemeVars=(e,...t)=>(0,l.themeVars)(e,_i[e],...t),exports.startEventFromKey=Hr,exports.useDragCells=On,exports.useEditorKeymap=Wr,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)(()=>ri(e,n,()=>r.current),[e,n]);return(0,s.useEffect)(()=>()=>i.dispose(),[i]),{onPointerDown:i.onPointerDown,onPointerMove:i.onPointerMove,onPointerUp:i.onPointerUp}},exports.useHoverIntent=dn,exports.useLayer=()=>({zIndex:(0,s.useContext)(ee),pane:G()}),exports.usePendingCaret=Ur,exports.useRangeHover=(e,t={})=>{let{open:n,setTarget:r,tipProps:i}=dn(t),a=G(),o=P(a),c=(0,s.useContext)(ee),l=(0,s.useRef)({}),d=R(e);return l.current={pointermove:(t,n)=>{let i=t,o=(n??a)?.getCellFromPointer(i.clientX,i.clientY);r(o&&u.CoordUtils.isCellWithinRange(o,e)?d:null)},pointerleave:()=>r(null)},(0,s.useEffect)(()=>{if(o)return o.registerResponder({zIndex:c,getHandler:e=>l.current[e]})},[o,c]),{open:n,tipProps:i}},exports.useSelectionPointer=xr,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=kn;
|
|
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=G(),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===se.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===se.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===se.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=se.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=se.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)},[]),z=(0,l.useCallbackRef)(e=>{T(`mousemove`,e,d.current)},[]),ee=(0,l.useCallbackRef)(e=>{T(`mouseout`,e,d.current)},[]),te=(0,l.useCallbackRef)(e=>{T(`mouseover`,e,d.current)},[]),B=(0,l.useCallbackRef)(e=>{T(`mouseup`,e,d.current)},[]),ne=(0,l.useCallbackRef)(e=>{T(`dblclick`,e,d.current)},[]),re=(0,l.useCallbackRef)(e=>{T(`keydown`,e,d.current)},[]),V=(0,l.useCallbackRef)(e=>{T(`keypress`,e,d.current)},[]),ie=(0,l.useCallbackRef)(e=>{T(`keyup`,e,d.current)},[]),ae=(0,l.useCallbackRef)(e=>{r?.(e),T(`focus`,e,d.current)},[r]),H=(0,l.useCallbackRef)(e=>{i?.(e),T(`blur`,e,d.current)},[i]),oe=(0,l.useCallbackRef)(e=>{T(`contextmenu`,e,d.current)},[]),se=(0,l.useImperativeElement)(t,()=>({isStage:()=>!0,addReactEventListener:x,registerResponder:m,registerLayer:_}),[]);return(0,s.useEffect)(()=>_({getElement:()=>se.current}),[_]),(0,c.jsx)(`div`,{className:C(n,`stage`,k),ref:se,tabIndex:0,...o,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerLeave:j,onMouseDown:P,onMouseEnter:F,onMouseLeave:R,onMouseMove:z,onMouseOut:ee,onMouseOver:te,onMouseUp:B,onDoubleClick:ne,onKeyDown:re,onKeyUp:ie,onKeyPress:V,onFocus:ae,onBlur:H,onContextMenu:oe,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}`,z=(0,s.createContext)(0),ee=(0,s.createContext)(!1),te=(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<B.length;e++){let t=r[B[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}},B=[u.AnchorLocation.TopLeft,u.AnchorLocation.Top,u.AnchorLocation.Left,u.AnchorLocation.Center],ne=(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)}},re=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}]),V=(0,s.createContext)(null),ie=({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)(V.Provider,{value:r,children:n})},ae=()=>{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)}}}},H=(0,s.createContext)(null),oe=({store:e,children:t})=>{let n=(0,s.useContext)(H),r=(0,s.useRef)(null),i=e??n;return i||=(r.current||=ae(),r.current),(0,c.jsx)(H.Provider,{value:i,children:t})},se={"sheetxl-grid":`_sheetxl-grid_5yo0n_7`},U=(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),ee=(0,s.useMemo)(()=>new l.Viewport({}),[]),B=i??ee,[V,ae]=(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=()=>ae(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,U=(0,s.useMemo)(()=>{let e=a??ce;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,U.getRowOffset,t?0:n),[n,U?.getRowOffset]),K=(0,l.useCallbackRef)(d??G,[d]),_e=(0,l.useCallbackRef)((e,t=!1)=>D(e,t,U.getColOffset,t?r:0),[r,U?.getColOffset]),q=(0,l.useCallbackRef)(f??_e,[f]),J=(0,s.useCallback)(()=>{R()},[]),ve=(0,s.useMemo)(()=>Math.min(V.w,U.getColOffset(r)),[L,U.getColOffset,r,V.w]),ye=(0,s.useMemo)(()=>Math.min(V.h,U.getRowOffset(n)),[L,U.getRowOffset,n,V.h]),be=(0,s.useMemo)(()=>{let e=NaN,t=null;return r=>(r===e&&t||(e=r,t=(e=>{if(ye===0)return re;let t=[],r=0,i=0;typeof m==`number`?r=m:(r=m.index??0,i=(m.offset??0)*H);let a=i,o=U.getRowOffset(r),s=o-a;if(r>0){let e=ne(U,{top:i+U.getRowOffset(0)}),n=U.getRowIndex(a),c=U.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(K,e,t):l||(l=Object.freeze(T(K,n,c)),l),metrics:e,maxVirtualBounds:o,scrollOffset:i,freezeOffset:i}}let c=Math.max(0,ye-s),l=ne(U,{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(K,e,t):f||(f=Object.freeze(T(K,u,d)),f),metrics:l,maxVirtualBounds:U.getRowOffset(n),scrollOffset:e,freezeOffset:(r>0?U.getRowOffset(r):0)-i},t})(r)),t)},[L,U.getRowIndex,U.getRowOffset,K,ye,n,m,H]),Y=(0,s.useMemo)(()=>be(0),[be]),xe=(0,s.useMemo)(()=>{let e=NaN,t=null;return n=>(n===e&&t||(e=n,t=(e=>{if(ve===0)return re;let t=[],n=0,i=0;typeof p==`number`?n=p:(n=p.index??0,i=(p.offset??0)*H);let a=i,o=U.getColOffset(n),s=o-a;if(n>0){let e=ne(U,{left:i+U.getColOffset(0)}),r=U.getColIndex(a),c=U.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(q,e,t):l||(l=Object.freeze(T(q,r,c)),l),metrics:e,maxVirtualBounds:o,scrollOffset:i,freezeOffset:i}}let c=Math.max(0,ve-s),l=ne(U,{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(q,e,t):f||(f=Object.freeze(T(q,u,d)),f),metrics:l,maxVirtualBounds:U.getColOffset(r),scrollOffset:e,freezeOffset:(n>0?U.getColOffset(n):0)-i},t})(n)),t)},[L,U.getColIndex,U.getColOffset,q,ve,r,p,H]),X=(0,s.useMemo)(()=>xe(0),[xe]),Se=(0,s.useRef)([]),[Ce,we]=(0,s.useReducer)(e=>e+1,0),Te=Y.length,Ee=X.length,De=(0,s.useMemo)(()=>{let e=[],t=(t,n,r,i,a)=>{if(t>=Ee||n>=Te)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,we()):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,fe,de),t(0,1,u.AnchorLocation.Top,pe),t(1,0,u.AnchorLocation.Left,me),t(1,1,u.AnchorLocation.TopLeft,he),e},[Te,Ee]),Z=(0,s.useMemo)(()=>{let e={},t={colStart:0,rowStart:0,colEnd:r-1,rowEnd:n-1},i=n=>te(n,{rowDims:Y,columnDims:X,computeRowDims:be,computeColumnDims:xe,viewport:B,zoom:H,containerWidth:ve,containerHeight:ye,getRangeFromCell:o,invalidate:J,totalRange:t,getSurfacePointFromPointer:(e,t)=>Ne(e,t),scrollTo:e=>ze(e),scrollCellCoordsIntoView:(e,t,n)=>Re(e,t,n),getAllPanes:()=>e}),a=De.length;for(let t=0;t<a;t++){let n=De[t];e[n.anchor]=i(n)}return e=Object.freeze(e),e},[De,Y,X,be,xe,B,o,Ce]),Oe=X[0]?.maxVirtualBounds??0,ke=Y[0]?.maxVirtualBounds??0,Ae=V.ready,je=(0,s.useMemo)(()=>{let e=X[1],t=Y[1];return{left:e?e.metrics.getColOffset(e.maxIndex+1):0,top:t?t.metrics.getRowOffset(t.maxIndex+1):0}},[Y,X]),Me=(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=Se.current,t=e.length;if(t>0){for(let n=0;n<t;n++)e[n]();Se.current=[]}},[Z]);let Ne=(0,s.useCallback)((e,t)=>{(function(e){if(!e)throw Error(`Invariant failed`)})(typeof e==`number`&&typeof t==`number`);let n=Be.current?.getBoundingClientRect();return n?{x:e-n.x,y:t-n.y}:{x:e,y:t}},[]),Pe=(0,l.useCallbackRef)((e,t)=>{if(Object.keys(Z).length===1)return Z[u.AnchorLocation.Center];let n=Ne(e,t);if(!n)return Z[u.AnchorLocation.Center];let{x:r,y:i}=n,a=null,o=ge,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=Y?.[1]?.scrollOffset??0;B.setContent(Oe,ke,e,t)},[B,Oe,ke,X,Y]);let Fe=(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||ze({left:t,top:n,behavior:r})},[]),Ie=(0,l.useCallbackRef)(e=>e===void 0?Z[P]??Z[u.AnchorLocation.Center]??null:Z[e]??null,[Z,P]),Le=(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=Y[0].minCoord,r.rowEnd=Y[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]),Re=(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=Le(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+=le:g.left<_&&(g.left-=W)),g.top!==void 0&&(g.top>v?g.top+=le:g.top<v&&(g.top-=W));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)<ue||!B.isSettled()?`instant`:`smooth`);return new Promise((e,t)=>{try{ze({...g,behavior:S}),e(g)}catch(e){t(e)}})},[Oe,ke,Z,o]),ze=(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)},[]),Be=(0,l.useImperativeElement)(t,()=>({focus:Me,invalidate:J,scrollTo:ze,scrollBy:Fe,scrollCellCoordsIntoView:Re,getPaneFromClient:Pe,getPaneFromCell:Le,getPane:Ie,onPaneChangeOnce:e=>{Se.current.push(e)}}),[Z]);(0,s.useEffect)(()=>B.observe(Be.current),[B]);let Ve=(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)(z.Provider,{key:e.key??`layer-${t}`,value:t},e):e)})(t);return n?(0,c.jsx)(ie,{pane:e,viewport:B,children:b?b(e,n):n}):null},He=(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]=Ve(Z[n],y)}return e},[L,y,Z,b,n,r]),Ue=(0,s.useMemo)(()=>je.left===0?null:(0,c.jsx)(g,{linePoints:[0,0,0,ye+1],bounds:{x:je.left,y:0,width:1,height:ye+1},...h}),[L,je.left,ye,h]),We=(0,s.useMemo)(()=>je.top===0?null:(0,c.jsx)(g,{linePoints:[0,0,ve+1,0],bounds:{x:0,y:je.top,width:ve+1,height:1},..._}),[L,je.top,ve,_]),Ge=(0,s.useRef)(!1),Ke=(0,s.useMemo)(()=>{if(!Ae)return null;let e=(e,t)=>{let n=e.anchor,r=t.getPaneBounds(),i=je.left>0,a=je.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)(ie,{pane:t,viewport:B,children:e.elemStage?(0,s.cloneElement)(e.elemStage,{style:y},He?.[n]):null},`pane:${n}`)},t=De.length,n=Array(t);for(let r=0;r<t;r++){let t=De[r],i=t.anchor,a=Z[i];n[r]=a?e(t,a):null}return(0,c.jsxs)(c.Fragment,{children:[n,Ue,We]})},[Z,De,He,ve,ye,Ae,je]);return(0,s.useEffect)(()=>{!Ge.current&&Ke&&Ae&&(Ge.current=!0,N?.(Be.current))},[Ke,Ae]),(0,c.jsx)(`div`,{ref:Be,className:C(w,`grid-surface`,se[`sheetxl-grid`]),style:{overflow:`hidden`,...k},...A,children:(0,c.jsx)(oe,{children:Ke})})}));U.displayName=`GridSurface`;var ce=Object.freeze({getColOffset:e=>75*e,getColIndex:e=>Math.floor(e/75),getRowOffset:e=>20*e,getRowIndex:e=>Math.floor(e/20)}),W=0,le=20,ue=150,de=Object.freeze({bottom:-4,right:-4}),fe=Object.freeze({horizontal:!0,vertical:!0}),pe=Object.freeze({horizontal:!0,vertical:!1}),me=Object.freeze({horizontal:!1,vertical:!0}),he=Object.freeze({horizontal:!1,vertical:!1}),ge=[u.AnchorLocation.TopLeft,u.AnchorLocation.Top,u.AnchorLocation.Left,u.AnchorLocation.Center];function G(){let e=(0,s.useContext)(V);if(!e)throw Error(`useGridPane must be used within a GridPaneProvider`);return e.pane}function K(){return(0,s.useContext)(V)?.pane??null}function _e(e,t){let n=(0,s.useContext)(H),r=(0,s.useRef)(null);r.current||=ae();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 q=(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)(ee);(0,s.useEffect)(()=>{w&&!ve&&(ve=!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(K()),E=(0,s.useContext)(z),D=(0,s.useRef)({});D.current={pointerdown:J(t),pointermove:J(n),pointerup:J(r),pointerleave:J(i),mousedown:J(a),mouseenter:J(o),mouseleave:J(l),mousemove:J(u),mouseout:J(d),mouseover:J(f),mouseup:J(p),dblclick:J(m),keydown:J(h),keypress:J(g),keyup:J(_),focus:J(v),blur:J(y),contextmenu:J(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)(ee.Provider,{value:!0,children:C})})});q.displayName=`Layer`;var J=e=>e?t=>e(t):void 0,ve=!1,ye=!1,be=`_virtual-div_16eab_1`,Y=(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)(ee)||xe||(xe=!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(K()),r=(0,s.useContext)(z),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=G();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 ye||(ye=!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,be),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})})}));Y.displayName=`VirtualDiv`;var xe=!1,X=(e,t,n,r)=>({x:e,y:t,width:n,height:r,top:t,left:e,right:e+n,bottom:t+r}),Se=X(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?X(t.left,t.top,t.width,t.height):Se},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]),Z=new Set([u.AnchorLocation.Left,u.AnchorLocation.TopLeft]),Oe=(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=Z.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 X(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:Se,clipped:!0,boundaryRect:Se,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 X(e.x,e.y,e.width,e.height)}if(t===`pane`){let t=Ce(e),n=e.getPaneBounds();return X(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 X(t.x,t.y,n.width,n.height)}return X(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=X(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:X(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=X(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,X(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=Oe(d,`row`,l.rowStart,l.rowEnd,f.rowIndex),m=Oe(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=X(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=K(),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:{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&>(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),{refs:_,floatingStyles:v}=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:(e,t,n)=>Kt(e,t,n,{animationFrame:!0}),middleware:[nn({mainAxis:n,alignmentAxis:r}),an(),rn({padding:4})]});if(!i)return null;let y=typeof p==`function`?p(t):p;return(0,d.createPortal)((0,c.jsx)(`div`,{ref:_.setFloating,className:[o,h].filter(Boolean).join(` `)||void 0,...g,style:{...v,zIndex:f,...u},children:y}),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={pointerEvents:`auto`},dn=(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:un}),[m]);return(0,s.useEffect)(()=>()=>{f(),p()},[]),{open:r,setTarget:h,tipProps:_,close:g}},fn=e=>{let{probe:t,placement:n,offset:r=6,alignOffset:i=0,openDelay:a=300,closeDelay:o=150,whenOff:u=`hide`,boundary:d,zIndex:f,dismiss:p,children:m,className:h,style:g}=e,_=G(),{open:v,setTarget:y,tipProps:b,close:x}=dn({openDelay:a,closeDelay:o}),[S,w]=(0,s.useState)(null),T=(0,s.useRef)(null),E=(0,l.useCallbackRef)(e=>{let n=_.getCellFromPointer(e.clientX,e.clientY);if(n){let e=t(n,_);if(e&&e.range){let t=e.key??R(e.range);t!==T.current&&(T.current=t,w({key:t,range:e.range,data:e.data})),y(t);return}}T.current=null,y(null)},[_,t,y]),D=(0,l.useCallbackRef)(()=>{T.current=null,y(null)},[y]);return(0,s.useEffect)(()=>{p&&(T.current=null,x(),w(null))},[p,x]),(0,c.jsx)(q,{className:C(h,`hover-tip`),onPointerMove:E,onPointerLeave:D,children:S&&(0,c.jsx)(ln,{anchor:{range:S.range},placement:n,offset:r,alignOffset:i,boundary:d,zIndex:f,open:v,whenOff:u,style:g,children:e=>m({range:S.range,data:S.data,tipProps:b,state:e})})})};fn.displayName=`HoverTipLayer`;var pn={t:`↑`,b:`↓`,l:`←`,r:`→`},mn=e=>{let t=``,n=e;do t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26)-1;while(n>=0);return t},hn=e=>{let t=`${mn(e.colStart)}${e.rowStart+1}`,n=`${mn(e.colEnd)}${e.rowEnd+1}`;return t===n?t:`${t}:${n}`},gn={border:`none`,background:`transparent`,color:`inherit`,cursor:`pointer`,font:`14px/1 system-ui`,padding:0,width:18,height:18,borderRadius:4,opacity:.6},_n={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},vn={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`},yn=({direction:e,label:t,onGoto:n,onCancel:r})=>(0,c.jsxs)(`div`,{style:vn,children:[(0,c.jsxs)(`button`,{onClick:n,style:{border:`none`,background:`transparent`,color:`inherit`,cursor:`pointer`,font:`12px system-ui`},children:[pn[e],` `,t]}),r&&(0,c.jsx)(`button`,{"aria-label":`Cancel`,onClick:r,style:{...gn,opacity:.8},children:`×`})]}),bn=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)(yn,{direction:e.slid?.direction??n.side,label:a??hn(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:{..._n,...d},children:[s&&(0,c.jsx)(`button`,{"aria-label":`Cancel`,onClick:s,style:{...gn,position:`absolute`,top:4,right:4},children:`×`}),r]})}})};bn.displayName=`RangePrompt`;var xn={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)`},Sn=(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=K(),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)(Y,{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})})});Sn.displayName=`RangeRect`;var Cn=()=>typeof window<`u`?window:null,wn=(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)},Tn=(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=(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.edgeScroll??(t=>wn(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})})(),n?.(c.dragMode??null),c):null},move:(e,t,n)=>{a&&(s={x:e,y:t},p(e,t,n)?(f(),c=setTimeout(function e(){c=a&&s&&p(s.x,s.y)?setTimeout(e,60):null},60)):f())},reset:()=>{let e=a;return a=null,o=null,s=null,f(),d(),e&&n?.(null),e},dispose:()=>{f(),d()}}},En=(e,t,n)=>{let r=Tn(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&&Cn()?.removeEventListener(`keydown`,c,!0),c=null},d=()=>{l&&=(Cn()?.removeEventListener(`pointerup`,l),Cn()?.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))},Cn()?.addEventListener(`keydown`,c,!0)}else i=!1,l=e=>p(e.type===`pointercancel`,e),Cn()?.addEventListener(`pointerup`,l),Cn()?.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 Dn(e,t,n,r){let i=Tn(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 On=e=>{let t=G(),[n,r]=(0,s.useState)(null),i=(0,s.useRef)(e);i.current=e;let a=(0,s.useMemo)(()=>En(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}},kn=e=>{let t=G(),[n,r]=(0,s.useState)(null),i=(0,s.useRef)(e);i.current=e;let a=(0,s.useMemo)(()=>Dn(t,(e,t)=>i.current(e,t),r),[t]);return(0,s.useEffect)(()=>()=>a.dispose(),[a]),{start:a.start,dragMode:n}},An=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)}},jn=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:C}=e,w=G(),[T,E]=(0,s.useState)(!1),D=An(!!m),{start:O,dragMode:k}=kn((e,t)=>{if(t.button!==0)return null;t.stopPropagation(),S&&t.preventDefault();let n=e,r=e;return u?.(n,t),{dragMode:`handle`,drag:(e,i)=>{r=e,d?.(n,e,i??t)},end:e=>{f?.(n,r,e)},cancel:()=>{p?.()}}}),A=k!==null&&a?a:i??Fn[n],j=w.getBoundsFromRange(t);if(!j)return null;let M=l.ReactUtils.getDevicePixelRatio(),N=Pn(j.x,j.x+j.width,Mn[n],M),P=Pn(j.y,j.y+j.height,Nn[n],M);if(C){if(!w.toClipBounds(w.getBoundsFromRange(t)))return null;let e=w.getPaneBounds(),n=r/2+1;!0!==C&&C!==`x`||(N=Math.max(n,Math.min(e.width-n,N))),!0!==C&&C!==`y`||(P=Math.max(n,Math.min(e.height-n,P)))}let F={position:`absolute`,cursor:A,pointerEvents:`all`,left:0,top:0,transform:`translate(${N}px, ${P}px) translate(-50%, -50%)`,..._?{transition:`transform 60ms ease-in-out`,willChange:`transform`}:void 0},I={onPointerDown:e=>{D(e)?m(e):O(e)},onDoubleClick:m?e=>e.stopPropagation():void 0,onPointerEnter:()=>{E(!0),h?.(!0)},onPointerLeave:()=>{E(!1),h?.(!1)}};return v?(0,c.jsx)(c.Fragment,{children:v({anchor:n,size:r,cursor:A,background:o,hovered:T,handleProps:{...I,style:F}})}):(0,c.jsx)(`div`,{className:b,...I,style:{...F,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,...T?g:void 0},children:y})};jn.displayName=`DragHandle`;var Mn={tl:`leading`,l:`leading`,bl:`leading`,t:`center`,b:`center`,tr:`trailing`,r:`trailing`,br:`trailing`},Nn={tl:`leading`,t:`leading`,tr:`leading`,l:`center`,r:`center`,bl:`trailing`,b:`trailing`,br:`trailing`},Pn=(e,t,n,r)=>n===`center`?l.ReactUtils.snapDeviceEdge((e+t)/2,r):l.ReactUtils.edgeCenter(n===`leading`?e:t,n,2,r),Fn={tl:`nwse-resize`,br:`nwse-resize`,tr:`nesw-resize`,bl:`nesw-resize`,t:`ns-resize`,b:`ns-resize`,l:`ew-resize`,r:`ew-resize`},In=e=>{let{range:t,children:n,grip:r=`entire`,hitSize:i=10,onHoverChange:a,onDragStateChange:o,onDragStart:d,onDragMove:f,onDragEnd:p,renderMove:m,preserveFocus:h,onEdgeDoubleClick:g}=e,v=G(),y=t?`range-move:${t.rowStart}:${t.colStart}:${t.rowEnd}:${t.colEnd}`:`range-move`,b=(0,s.useRef)(null),[x,S]=_e(y,null),{start:C,dragMode:w}=kn((e,n)=>{if(n.button!==0||!t)return null;n.stopPropagation(),h&&n.preventDefault();let r=e,i=t,a=i;return o?.(!0),d?.(i,n),{dragMode:`move`,drag:(e,t)=>{a=(e=>Ln(i,e.rowIndex-r.rowIndex,e.colIndex-r.colIndex,v.getTotalRange()))(e),m&&S(a),f?.(a,t??n)},end:e=>{o?.(!1),m&&S(null),u.CoordUtils.isEqualRanges(a,i)||p?.(a,e)},cancel:()=>{o?.(!1),m&&S(null)}}}),T=An(!!g),E=w===null?`move`:`grabbing`;if(!t)return null;let D={onPointerDown:e=>{if(T(e)){let n=(e=>{let n=v?.getPanePointFromPointer(e.clientX,e.clientY),r=v?.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&&g(t,n,e);return}C(e,b.current)}},O=a?{onPointerEnter:()=>a(!0),onPointerLeave:()=>a(!1)}:void 0,k=i/l.ReactUtils.getDevicePixelRatio(),A=v?.getBoundsFromRange(t),j=A?{x:A.x-k,y:A.y-k,width:A.width+2*k,height:A.height+2*k}:void 0;return(0,c.jsxs)(c.Fragment,{children:[r===`entire`?(0,c.jsx)(Y,{ref:b,...j?{bounds:j}:{range:t},style:{cursor:E},...D,...O}):(0,c.jsx)(Y,{ref:b,range:t,clipInsets:-k/2,style:{pointerEvents:`none`,cursor:E},...D,children:(0,c.jsx)(_,{stroke:`transparent`,alignWidth:i,propsStrokePath:{cursor:`move`,pointerEvents:`stroke`,...O}})}),n,x&&m?.(x)]})};In.displayName=`Draggable`;var Ln=(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}},Rn=[`tl`,`tr`,`br`,`bl`],zn=[`tl`,`t`,`tr`,`r`,`br`,`b`,`bl`,`l`],Bn=e=>{let{range:t,anchors:n=zn,onDragStart:r,onDragMove:i,onDragEnd:a,onDragCancel:o,onHandleHoverChange:l,size:u=8,renderHandle:d,preserveFocus:f,...p}=e,m={...xn,...p},h=m.stroke??`rgb(33, 115, 70)`,g=G(),[_,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)(Sn,{range:b,...m}),n.map(e=>(0,c.jsx)(jn,{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=Vn(y.current??t,e,r,g.getTotalRange());v(o),i?.(o,a)},onDragEnd:(n,r,i)=>{let o=Vn(y.current??t,e,r,g.getTotalRange());y.current=null,v(null),a?.(o,i)},onDragCancel:()=>{y.current=null,v(null),o?.()}},e))]})};Bn.displayName=`RangeResizer`;var Vn=(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)}},Hn=e=>{let{range:t,snapDestination:n,onDragStart:r,onDragMove:i,onDragEnd:a,onDragDone:o,onDoubleClick:l,renderHandle:d,...f}=e,p={...xn,fill:void 0,...f},m=p.stroke,h={...p,strokeDasharray:`3 2`},g=G(),_=(0,s.useRef)(null),[v,y]=_e(`range-fill`,null);if(!t)return null;let b=g.getTotalRange(),x=t.rowStart===b.rowStart&&t.rowEnd===b.rowEnd,S=t.colStart===b.colStart&&t.colEnd===b.colEnd;if(x&&S)return null;let C=Object.keys(g.getAllPanes()).length<=1,w=g.getBoundsFromRange(t),T=g.getPaneBounds(),E=C&&w.y>=0&&w.y+w.height<=T.height,D=C&&w.x>=0&&w.x+w.width<=T.width,O=x&&!E?`tr`:S&&!D?`bl`:`br`,k=O===`tr`?`y`:O===`bl`&&`x`;return k&&!((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})(g,t,x,S)?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(jn,{range:t,anchor:O,clampToView:k,cursor:`crosshair`,background:m,renderHandle:d,onDoubleClick:l?e=>l(t,e):void 0,onDragStart:(e,n)=>{_.current=null,y(null),r?.(t,n)},onDragMove:(e,r,a)=>{let o=((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);return s===0&&c===0?null: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)}})(t,r,g.getTotalRange());o&&n&&(o=n(t,o)),_.current=o,y(o),o&&i?.(o,a)},onDragEnd:(e,t,n)=>{let r=_.current;_.current=null,y(null),r&&a?.(r,n),o?.(n)},onDragCancel:()=>{_.current=null,y(null),o?.()}}),v&&(0,c.jsx)(Sn,{range:v,...h})]})};Hn.displayName=`FillHandle`;var Un=(0,s.memo)(e=>{let{value:t,pane: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})}),Wn=Object.freeze({cells:[],rangesH:[],rangesV:[]}),Gn=!1,Kn=new WeakMap,qn=(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=Kn.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 Wn;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 Wn;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=Zn(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}):Gn||(Gn=!0,console.warn(`grid-react: no bounds for cell`,Zn(a.rowStart,a.colStart)))}return{cells:h,rangesH:g,rangesV:_}})(e,t);return Kn.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},Jn=Object.freeze({rangesH:[],rangesV:[]}),Yn=new WeakMap,Xn=(e,t={})=>{let n=e.getVisibleRange(),r=Yn.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=Zn(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?Jn:{rangesH:i,rangesV:a}})(e,t);return Yn.set(e,{rowStart:n.rowStart,colStart:n.colStart,rowEnd:n.rowEnd,colEnd:n.colEnd,getVisibleCells:t.getVisibleCells,cacheToken:t.cacheToken,ranges:i}),i},Zn=(e,t)=>`${e}:${t}`,Qn={tiles:`_tiles_ikr1b_7`,gridlines:`_gridlines_ikr1b_26`},$n=(0,s.memo)(e=>{let{renderCell:t,cacheToken:n,getVisibleCells:r,hiddenCellAt:i,suppressCell:a,className:o,style:l}=e,u=G(),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(_/tr)*tr,b=Math.floor(v/tr)*tr,x=u.getVisibleRange(),S=0,w=-1,T=0,E=-1;x&&(S=Math.max(0,Math.floor(x.rowStart/$)-nr),w=Math.floor(x.rowEnd/$)+nr,T=Math.max(0,Math.floor(x.colStart/$)-nr),E=Math.floor(x.colEnd/$)+nr);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.getTotalRange(),s={rowStart:Math.max(o.rowStart,S*$),colStart:Math.max(o.colStart,T*$),rowEnd:Math.min(o.rowEnd,(w+1)*$-1),colEnd:Math.min(o.colEnd,(E+1)*$-1)},{cells:l}=qn(u,{getVisibleCells:r,hiddenCellAt:i,bufferRange:s,cacheToken:n}),f=new Map;for(let e=0;e<l.length;e++){let t=l[e],n=`${Math.floor(t.cell.rowIndex/$)}:${Math.floor(t.cell.colIndex/$)}`,r=f.get(n);r||(r=[],f.set(n,r)),r.push(t)}let p=[],h=(e,n)=>{if(e*$>o.rowEnd||n*$>o.colEnd)return;let r=e>=S&&e<=w&&n>=T&&n<=E,i=`${e}:${n}`,s=a.get(i);if(s===void 0){let l=f.get(i);if(!l&&!ir)return;let p=u.getBoundsFromRange({rowStart:e*$,colStart:n*$,rowEnd:Math.min(o.rowEnd,e*$+$-1),colEnd:Math.min(o.colEnd,n*$+$-1)}),m=_+p.x-y,h=v+p.y-b,g=[];if(ir&&g.push((0,c.jsx)(`div`,{style:{position:`absolute`,left:0,top:0,width:p.width,height:p.height,background:(e+n)%2==0?`rgba(0,128,255,0.05)`:`rgba(255,140,0,0.05)`,pointerEvents:`none`}},`__bg`)),l)for(let e=0;e<l.length;e++){let{cell:n,range:r,bounds:i,value:a}=l[e];i&&g.push(t({key:`pane:${d}:cell:${Zn(n.rowIndex,n.colIndex)}`,cell:n,bounds:i,range:r,pane:u,value:a,"data-rc":Zn(n.rowIndex,n.colIndex),style:{left:i.x-p.x,top:i.y-p.y,width:i.width,height:i.height}}))}if(s=(0,c.jsx)(`div`,{className:`tile`,style:{transform:`translate(${m}px, ${h}px)`},children:g},`pane:${d}:tile:${e}:${n}`),r&&(a.set(i,s),a.size>rr)){let e=a.keys().next().value;e!==void 0&&a.delete(e)}}s&&p.push(s)};if(ir){for(let e=S;e<=w&&!(e*$>o.rowEnd);e++)for(let t=T;t<=E&&!(t*$>o.colEnd);t++)h(e,t);for(let e of f.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)&&h(n,r)}}else for(let e of f.keys()){let t=e.indexOf(`:`);h(Number(e.slice(0,t)),Number(e.slice(t+1)))}return p},[`${S}:${w}:${T}:${E}`,n,t,r,i,u,d,y,b]);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(Y,{fill:!0,className:C(Qn.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="${Zn(a.rowIndex,a.colIndex)}"]{visibility:hidden !important;}`}):null]})});$n.displayName=`CellTileDiv`;var er=(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)(q,{className:C(o,`tiles`),...l,children:(0,c.jsx)($n,{renderCell:t,cacheToken:n,getVisibleCells:r,hiddenCellAt:i,suppressCell:a,style:s})})});er.displayName=`CellLayer`;var $=8,tr=1<<19,nr=1,rr=512,ir=!1,ar=(e,t,n)=>{let r=l.ReactUtils.getDevicePixelRatio(),i=lr/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},or=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},sr=(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(lr/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})})},cr=(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=G(),g=t,_=!0===t||!0===g?.horizontal,v=!0===t||!0===g?.vertical,{rangesH:y,rangesV:b}=Xn(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}|${or(y)}`,M=b.length===0?`${w}|${A}|${x}`:`${w}|${S}|${A}|${x}|${or(b)}`,N=(0,s.useMemo)(()=>_?ar(h,!0,y):null,[h,_,j]),P=(0,s.useMemo)(()=>v?ar(h,!1,b):null,[h,v,M]);return _||v?(0,c.jsx)(q,{...m,className:C(f,`gridlines`),children:(0,c.jsxs)(Y,{fill:!0,className:Qn.gridlines,style:{pointerEvents:`none`,...p},children:[_&&N?sr(h,!0,N,n,r):null,v&&P?sr(h,!1,P,n,i):null]})}):null});cr.displayName=`GridlineLayer`;var lr=1,ur=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??(()=>pr)}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=dr({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=fr(i.cell,r);this.setSelection({cell:s,ranges:o,rangeIndex:a>=0?a:0})}append(e,t=e){let n=dr({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)}}},dr=(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)}),fr=(e,t)=>({rowIndex:w(e.rowIndex,t.rowStart,t.rowEnd),colIndex:w(e.colIndex,t.colStart,t.colEnd)}),pr={rowStart:0,colStart:0,rowEnd:2**53-1,colEnd:2**53-1},mr=`var(--sxl-color-primary, rgb(33, 115, 70))`,hr=`var(--sxl-color-base-100, rgb(255, 255, 255))`,gr=`var(--sxl-color-warning, rgb(255, 0, 0))`,_r=e=>`color-mix(in srgb, var(--sxl-color-primary, rgb(33, 115, 70)) ${e}%, transparent)`,vr={fill:{fill:_r(10)},border:{stroke:mr,alignWidth:2,style:{filter:`drop-shadow(1px 1px 0.3px var(--sxl-color-shadow, rgba(0, 0, 0, 0.24)))`}},inner:{stroke:hr,alignWidth:2,inset:1}},yr={fill:{fill:_r(6)},border:{stroke:mr,alignWidth:1},inner:{stroke:hr,alignWidth:1,inset:1}},br={stroke:mr,alignWidth:1,inset:2},xr={fill:{fill:`color-mix(in srgb, ${gr} 10%, transparent)`},border:{stroke:gr,alignWidth:2}},Sr=(e,t)=>{let n=G(),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=On((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}},Cr=e=>{let{selection:t,color:n=`var(--sxl-color-primary, rgb(33, 115, 70))`,size:r=22}=e,i=K(),a=Er((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=Dn(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=>wn(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)(wr,{spec:e,size:r,color:n,dragging:f,onBeginDrag:h},e.key))})};Cr.displayName=`SelectionTouchGrips`;var wr=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)(Tr,{state:e,size:n,color:r,dragging:i,pin:t.pin,onBeginDrag:n=>{e.pane&&a(e.pane,t.pivot,t.axis,n)}})})},Tr=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())},Er=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)},Dr=[u.Direction.Left,u.Direction.Right,u.Direction.Up,u.Direction.Down],Or={[u.Direction.Left]:`ArrowLeft`,[u.Direction.Right]:`ArrowRight`,[u.Direction.Up]:`ArrowUp`,[u.Direction.Down]:`ArrowDown`},kr={[u.Direction.Left]:`Left`,[u.Direction.Right]:`Right`,[u.Direction.Up]:`Up`,[u.Direction.Down]:`Down`},Ar=(e,t)=>t===void 0?e:t===null?null:{...e,...t},jr=(e,t)=>t?{fill:Ar(e.fill,t.fill),border:Ar(e.border,t.border),inner:Ar(e.inner,t.inner)}:e,Mr={side:`b`,align:`end`},Nr=s.default.forwardRef((e,t)=>{let{selection:n,getContentBounds:r,getRegionBounds:i,scrollIntoView:a,singleStyle:o,multiStyle:d,multiAnchorStyle:f,singleAnchorStyle:p,removePreviewStyle:m,singleLayer:h,multiLayer:g,enabledMove:_,onMove:v,onMoveStart:y,onMoveUpdate:b,onMoveEnd:x,enableFill:S,snapFillDestination:C,onFill:w,onFillStart:T,onFillPreview:E,onFillEnd:D,resolveFillExtent:O,onEdgeDoubleClick:k,onSelectionEnd:A,renderTip:j,tipPlacement:M,disableKeyboard:N,anchorHole:P=!0,...F}=e,I=(0,l.useBoundSyncExternalStore)(n,e=>e.getSelection()),L=Sr(n,{onSelectionEnd:A}),[R,z]=s.default.useState(null),ee=G(),te=s.default.useRef(n);te.current=n;let B=s.default.useRef(ee);B.current=ee;let ne=s.default.useRef(r);ne.current=r;let re=s.default.useRef(i);re.current=i;let V=s.default.useRef(a);V.current=a;let ie=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?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 Dr){let t=kr[e],n=Or[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:()=>te.current,getPane:()=>B.current,getContentBounds:()=>ne.current?.()??B.current.getTotalRange(),getScrollIntoView:()=>V.current,getRegionBounds:e=>re.current?.(e)??null}),[]);s.default.useImperativeHandle(t,()=>ie,[ie]);let ae=!!I.ranges&&I.ranges.length>0,H=ae?[...I.ranges]:[u.CoordUtils.cellToRange(I.cell)],oe=H.length>1,se=I.rangeIndex??-1,U=ae?se>=0?se:H.length-1:0,ce=ee.getRangeFromCell(I.cell),W=u.CoordUtils.unionRanges(H[U]??u.CoordUtils.cellToRange(I.cell),ce),le=H.filter((e,t)=>t!==U),ue=oe?jr(yr,d):jr(vr,o),de={...br,...f},fe=jr(xr,m),pe=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})},me=R??(L.dragMode===`extend`?{kind:`select`,range:W}:null),he=me&&j?j(me):null,ge=s.default.Children.map(oe?g:h,e=>{if(!s.default.isValidElement(e))return e;let t=e.props;return s.default.cloneElement(e,{range:W,onDragEnd:(e,n)=>{t.onDragEnd?.(e,n),pe(e)}})});return(0,c.jsxs)(q,{...F,onPointerDown:L.onPointerDown,onPointerMove:L.onPointerMove,onPointerUp:L.onPointerUp,onKeyDown:N?void 0:e=>{ie.handleKey(e)&&(e.preventDefault(),e.stopPropagation())},children:[oe?(0,c.jsxs)(c.Fragment,{children:[le.map((e,t)=>(0,c.jsx)(s.default.Fragment,{children:Pr(ue,e)},`other-${t}`)),Pr(ue,W,P?ce:void 0),(0,c.jsx)(Sn,{range:ce,...de})]}):(0,c.jsxs)(c.Fragment,{children:[Pr(ue,W,P?ce:void 0),p&&(0,c.jsx)(Sn,{range:ce,...p})]}),!oe&&_&&(0,c.jsx)(In,{range:W,grip:`edges`,renderMove:e=>ue.border&&(0,c.jsx)(Sn,{range:e,...ue.border,animatedTransition:!0,style:{opacity:.6}}),onEdgeDoubleClick:k,onDragStart:(e,t)=>{y?.(e,t),z({kind:`move`,from:e,to:e})},onDragMove:(e,t)=>{b?.(W,e,t),z({kind:`move`,from:W,to:e})},onDragStateChange:e=>{e||(x?.(),z(null))},onDragEnd:(e,t)=>{v?.(W,e,t),n.modify({rowIndex:e.rowEnd,colIndex:e.colEnd},{rowIndex:e.rowStart,colIndex:e.colStart})}}),!oe&&S&&(0,c.jsx)(Hn,{range:W,snapDestination:C,...ue.border,onDragStart:(e,t)=>{T?.(e,t),z({kind:`fill`,template:e,destination:e})},onDragMove:(e,t)=>{E?.(W,e,t),z({kind:`fill`,template:W,destination:e})},onDragEnd:(e,t)=>{w?.(W,e,t),pe(e)},onDragDone:()=>{D?.(),z(null)},onDoubleClick:O?(e,t)=>{let n=O(e);n&&!u.CoordUtils.isEqualRanges(n,e)&&(w?.(e,n,t),pe(n))}:void 0}),L.removePreview&&Pr(fe,L.removePreview),ge,he!=null&&me&&(0,c.jsx)(ln,{anchor:{range:(K=me,K.kind===`move`?K.to:K.kind===`fill`?K.destination:K.range)},placement:M??Mr,offset:8,whenOff:`clamp`,open:!0,style:{pointerEvents:`none`},children:he})]});var K});Nr.displayName=`SelectionLayer`;var Pr=(e,t,n,r=!1)=>(0,c.jsxs)(c.Fragment,{children:[e.fill&&(0,c.jsx)(Sn,{className:`fill`,animatedTransition:r,range:t,hole:n,...e.fill}),e.inner&&(0,c.jsx)(Sn,{className:`inner`,animatedTransition:r,range:t,...e.inner}),e.border&&(0,c.jsx)(Sn,{className:`border`,animatedTransition:r,range:t,...e.border})]}),Fr=[`#1a73e8`,`#d93025`,`#1e8e3e`,`#9334e6`,`#e37400`,`#12a4af`,`#d01884`],Ir=Array.from({length:l.SERIES_COUNT},(e,t)=>`var(--sxl-color-series-${t+1}, ${Fr[t]})`),Lr=`var(--sxl-color-primary, rgb(0, 120, 215))`,Rr=(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))}),zr=e=>({stroke:Ir.length?Ir[e%Ir.length]:Lr}),Br=e=>{let{selection:t,getRangeStyle:n=zr,anchors:r=Rn,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=G(),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=On((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,Rr(t,e,y.getTotalRange())),{drag:e=>P(n,Rr(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,Rr(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)(q,{...v,children:[(!a||O)&&(0,c.jsx)(Y,{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)(In,{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??Lr;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)(Bn,{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}`)})]})};Br.displayName=`RangesPickerLayer`;var Vr=0,Hr=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.state={mode:t.mode??`enter`,coords:e.coords,clean:e.clean,dirty:t.dirty,initialSelection:t.initialSelection??null,autoFocus:t.autoFocus??!0,token:++Vr}}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 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())}},Ur=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,Wr=(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},[])},Gr=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=e.which===l.KeyCodes.Enter&&f.ctrlKey;if(!a(t?{broadcast:!0}:void 0)||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])},Kr=(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}},qr=96/72*11,Jr=`Calibri, sans-serif`,Yr=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=Gr({mode:n,value:_,onDirtyChange:f,onModeChange:p,onCommit:m,onCancel:h,setCaret:Wr(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:Jr,fontSize:qr*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:Jr,fontSize:`${qr}px`,lineHeight:1.2},children:_.length===0?` `:_})]})};function Xr(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)(Yr,{...v})})}Yr.displayName=`DefaultEditorInput`,Xr.displayName=`EditorDiv`;var Zr=`ew-resize`,Qr=`ns-resize`,$r=(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=G(),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?Zr:Qr,...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]})})),ei=e=>(0,c.jsx)($r,{...e}),ti=(0,s.memo)((0,s.forwardRef)((e,t)=>{let{axis:n,index:r,disabled:i=!1,disabledResize:a=!1,resizeThreshold:o=1,renderDivider:f=ei,onDividerMouseDown:p,onDividerResizeStart:m,onDividerResize:h,onDividerResizeEnd:g,onDividerMouseUp:_,onDividerAutoFit:v,onPointerDown:y,...b}=e,x=G(),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:z}=(0,l.useFullscreenPortal)();if(!D)return;let ee=f({bounds:D,axis:n,index:r,disabled:i,disabledResize:a,onAutoFit:R,onPointerDown:L,ref:t,...b},x);if(!ee)return;let te=null;return k&&k.isResizing&&k.index===r&&(te=(0,d.createPortal)((0,c.jsx)(`div`,{style:{position:`absolute`,cursor:T?Zr:Qr,left:0,top:0,width:`100%`,height:`100%`}}),z(),`divider:`+r)),(0,c.jsxs)(c.Fragment,{children:[te,(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:ee})]})}));ti.displayName=`HeaderDividerAnchor`;var ni=(e,t,n)=>t===u.RangeAxis.Column?{rowIndex:n.rowStart,colIndex:e.colIndex}:{rowIndex:e.rowIndex,colIndex:n.colStart},ri=(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)},ii=(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=ri(r??e,e,t,l),f=i??ni(e,t,o().getVisibleRange());u?c(a,d,f):s(d,f,`replace`)};return En(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=ni(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,ri(r,t,g,_),i??T)):(r=t,i=T,a=D||s<0?o.length:s,c(a,ri(t,t,g,_),T))}else E&&r?s(ri(r,t,g,_),i??T,`replace`):D?(r=t,i=T,s(ri(t,t,g,_),T,`append`)):(r=t,i=T,s(ri(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)},capture:m,captureEvents:y}})},ai=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)(cr,{showGridLines:f,gridLineColor:m,propsRows:h,propsColumns:g,getVisibleCells:_,hiddenCellAt:v},`__gridlines`)),e.push(...ai(y)),e.push(...ai(d)),u&&e.push((0,c.jsx)(er,{renderCell:u,getVisibleCells:_,hiddenCellAt:v,cacheToken:E},`__cells`)),e.push(...ai(b)),e},[f,m,h,g,_,v,y,d,u,E,b]);return(0,c.jsx)(U,{ref:O,...x,rowCount:n,columnCount:r,metrics:C,children:k})}));oi.displayName=`Grid`;var si=function(){},ci=typeof window<`u`,li=ci?s.useLayoutEffect:s.useEffect,ui={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0},di=ci&&window.ResizeObserver!==void 0?function(){var e=(0,s.useState)(null),t=e[0],n=e[1],r=(0,s.useState)(ui),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 li(function(){if(t)return o.observe(t),function(){o.disconnect()}},[t]),[n,i]}:function(){return[si,ui]},fi={fill:{fill:`color-mix(in srgb, var(--sxl-color-primary, rgb(0, 120, 215)) 14%, transparent)`},border:null,inner:null},pi={stroke:`var(--sxl-color-primary, rgb(0, 120, 215))`,alignWidth:1,inset:1},mi=(0,s.forwardRef)(function(e,t){let{itemCount:n,renderItem:r,itemHeight:i=24,selection:a,onKeyDown:o,cacheToken:u,className:d,style:f,children:m,...h}=e,g=(0,l.useImperativeElement)(t,()=>({isList:()=>!0}),[]),_=(0,s.useMemo)(()=>new l.Viewport,[]),v=(0,s.useMemo)(()=>new ur({getBounds:()=>({rowStart:0,colStart:0,rowEnd:Math.max(0,n-1),colEnd:0})}),[n]),y=a??v,[b,{width:x}]=di(),S=p({rowCount:n,columnCount:1,getRowHeight:i,getColumnWidth:x}),w=(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]);return(0,c.jsx)(`div`,{ref:g,className:C(`list`,d),style:{position:`relative`,overflow:`hidden`,...f},...h,children:(0,c.jsx)(l.ScrollPane,{viewport:_,showVerticalScrollbar:!0,showHorizontalScrollbar:!1,style:{width:`100%`,height:`100%`},children:(0,c.jsx)(`div`,{ref:b,style:{width:`100%`,height:`100%`},children:(0,c.jsxs)(U,{viewport:_,style:{width:`100%`,height:`100%`},rowCount:n,columnCount:1,metrics:S,children:[(0,c.jsx)(Nr,{selection:y,anchorHole:!1,singleStyle:fi,singleAnchorStyle:pi,multiAnchorStyle:pi},`__selection`),(0,c.jsx)(er,{renderCell:w,cacheToken:u},`__cells`),o?(0,c.jsx)(q,{onKeyDown:o},`__keys`):null]})})})})}),hi=(e,t)=>(0,c.jsx)(`input`,{type:`checkbox`,checked:e,ref:e=>{e&&(e.indeterminate=!!t)},readOnly:!0,tabIndex:-1,style:{margin:0}}),gi=(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,className:h,style:g,children:_,...v}=e,y=(0,l.useImperativeElement)(t,()=>({isCheckboxList:()=>!0}),[]),b=(0,s.useMemo)(()=>new ur({getBounds:()=>({rowStart:0,colStart:0,rowEnd:Math.max(0,n-1),colEnd:0})}),[n]),x=p??b,S=(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]),w=(0,s.useCallback)(e=>{if(e.key!==` `&&e.key!==`Enter`)return;e.preventDefault(),e.stopPropagation();let t=!r(x.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]})(x),t)},[x,r,i]),{allChecked:T,someChecked:E}=(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:y,className:C(`checkbox-list`,h),style:{display:`flex`,flexDirection:`column`,minHeight:0,...g},...v,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),!T)},children:[(0,c.jsx)(`div`,{style:{display:`inline-flex`,pointerEvents:`none`},children:o(T,E)}),d]}),u?.()]}),(0,c.jsx)(mi,{itemCount:n,itemHeight:f,selection:x,renderItem:S,onKeyDown:w,cacheToken:m,style:{flex:`1 1 100%`,minHeight:0}})]})}),_i={light:{},dark:{"color-base-100":`#1e1e1e`,"color-base-300":`#3a3a3a`}},vi={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=er,exports.CellTileDiv=$n,exports.CheckboxList=gi,exports.DEFAULT_ANCHOR_STYLE=br,exports.DEFAULT_HANDLE_STYLE=xn,exports.DEFAULT_MULTI_STYLE=yr,exports.DEFAULT_REMOVE_PREVIEW_STYLE=xr,exports.DEFAULT_SINGLE_STYLE=vr,exports.DefaultCellRenderer=Un,exports.DefaultEditable=class{constructor(e,t,n){this.current=null,this.listeners=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)}}getSession(){return this.current}startEdit(e,t={}){let n=this.createEdit(e);return!!n&&(this.current=new Hr({coords:e,...n},t),this.notify(),!0)}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=Yr,exports.DefaultHeaderDivider=$r,exports.DefaultSelection=ur,exports.DragHandle=jn,exports.Draggable=In,exports.EDGE_AUTO_SCROLL_MARGIN_PX=24,exports.EditSession=Hr,exports.EditorDiv=Xr,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=K(),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=Ur(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=Kr(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)(q,{onKeyDown:b,onDoubleClick:x,children:E?(0,c.jsx)(Y,{...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)(Yr,{...j})}):null})},exports.FillHandle=Hn,exports.GRID_SURFACE=_i,exports.Grid=oi,exports.GridSurface=U,exports.GridlineLayer=cr,exports.HEADER_SURFACE=vi,exports.HeaderDividerAnchor=ti,exports.HoverTipLayer=fn,exports.Layer=q,exports.LineSVG=g,exports.List=mi,exports.PICKER_COLORS=Ir,exports.RESIZE_ANCHORS_4=Rn,exports.RESIZE_ANCHORS_8=zn,exports.RangePrompt=bn,exports.RangeRect=Sn,exports.RangeResizer=Bn,exports.RangesPickerLayer=Br,exports.RectangleSVG=_,exports.SELECTION_CLIP_INSETS=-10,exports.SelectionLayer=Nr,exports.SelectionTouchGrips=Cr,exports.ShapeBoundsContext=m,exports.StickyAnchor=Pe,exports.StickyFloat=ln,exports.SurfaceStateContext=H,exports.SurfaceStateProvider=oe,exports.VirtualDiv=Y,exports.buildGridThemeCSS=({app:e,grid:t=_i,header:n=vi,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.createAxis=f,exports.createDragCells=En,exports.createHeaderSelectionPointer=ii,exports.createSurfaceStateStore=ae,exports.createWindowDragCells=Dn,exports.defaultRangeStyle=zr,exports.edgeScrollPane=wn,exports.expandEditorBounds=Kr,exports.gridThemeVars=(e,...t)=>(0,l.themeVars)(e,_i[e],...t),exports.headerAnchorCell=ni,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=ri,exports.headerThemeVars=(e,...t)=>(0,l.themeVars)(e,vi[e],...t),exports.startEventFromKey=Ur,exports.useDragCells=On,exports.useEditorKeymap=Gr,exports.useGridFloatTheme=on,exports.useGridMetrics=p,exports.useGridPane=G,exports.useGridPaneOptional=K,exports.useHeaderSelectionPointer=(e,t)=>{let n=G(),r=(0,s.useRef)(t);r.current=t;let i=(0,s.useMemo)(()=>ii(e,n,()=>r.current),[e,n]);return(0,s.useEffect)(()=>()=>i.dispose(),[i]),{onPointerDown:i.onPointerDown,onPointerMove:i.onPointerMove,onPointerUp:i.onPointerUp}},exports.useHoverIntent=dn,exports.useLayer=()=>({zIndex:(0,s.useContext)(z),pane:K()}),exports.usePendingCaret=Wr,exports.useRangeHover=(e,t={})=>{let{open:n,setTarget:r,tipProps:i}=dn(t),a=K(),o=P(a),c=(0,s.useContext)(z),l=(0,s.useRef)({}),d=R(e);return l.current={pointermove:(t,n)=>{let i=t,o=(n??a)?.getCellFromPointer(i.clientX,i.clientY);r(o&&u.CoordUtils.isCellWithinRange(o,e)?d:null)},pointerleave:()=>r(null)},(0,s.useEffect)(()=>{if(o)return o.registerResponder({zIndex:c,getHandler:e=>l.current[e]})},[o,c]),{open:n,tipProps:i}},exports.useSelectionPointer=Sr,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=_e,exports.useWindowDragCells=kn;
|