@sheetxl/grid-react 0.1.120 → 0.2.5
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/{build/LICENSE.md → LICENSE.md} +11 -11
- package/README.md +8 -9
- package/{build/browser → browser}/cjs/index.cjs +8 -8
- package/{build/browser → browser}/esm/index.mjs +198 -198
- package/{build/licenses → licenses}/dependencies.txt +22 -24
- package/node/assets/style.css +1 -0
- package/{build/node → node}/esm/index.mjs +94 -94
- package/package.json +22 -38
- package/build/README.md +0 -9
- package/build/node/assets/style.css +0 -1
- package/build/package.json +0 -48
- /package/{build/types → types}/index.d.ts +0 -0
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-grid_h9wwa_7{position:relative;box-sizing:border-box;user-select:none}._sheetxl-grid_h9wwa_7 *{box-sizing:border-box!important}._sheetxl-grid_h9wwa_7 *:focus{outline:none}._sheetxl-grid_h9wwa_7 .cell-container{position:absolute;overflow:visible;white-space:pre}._sheetxl-grid_h9wwa_7 .cell-container>*{inset:0;position:absolute}._sheetxl-grid_h9wwa_7 .sheetxl-stage{contain:strict}._sheetxl-grid_h9wwa_7 .sheetxl-stage>*{contain:strict}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
2
|
"use strict";/**
|
|
3
|
-
* @license @sheetxl/grid-react - Grid - Advanced data grid component for React - v0.
|
|
3
|
+
* @license @sheetxl/grid-react - Grid - Advanced data grid component for React - v0.2.5
|
|
4
4
|
*
|
|
5
5
|
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
6
6
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
7
|
-
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react/jsx-runtime"),c=require("react"),Ci=require("react-dom/client"),No=require("react-dom"),nt="up",ot="down",et="left",Ue="right",to="tl",Ln="t",Dn="l",Ht="c",Lt="text/html",rn="text/plain",xo="image/png",Ii=Object.freeze({left:0,top:0}),Mi=Object.freeze({left:0,top:0,bottom:0,right:0}),Ri=Object.freeze({x:0,y:0,width:0,height:0});Object.freeze(Object.defineProperty({__proto__:null,EmptyBounds:Ri,EmptyRect:Mi,EmptyTopLeft:Ii},Symbol.toStringTag,{value:"Module"}));const Bt="column",Qt="row",ki=Object.freeze({colIndex:0,rowIndex:0}),Ti=Object.freeze({colStart:0,rowStart:0,colEnd:0,rowEnd:0}),Fr=(e,t)=>e.colStart===t.colStart?e.rowStart-t.rowStart:e.colStart-t.colStart,Vr=(e,t)=>e.rowStart===t.rowStart?e.colStart-t.colStart:e.rowStart-t.rowStart,Pi=(e,t)=>e.rowEnd===t.rowEnd?t.colEnd-e.colEnd:t.rowEnd-e.rowEnd,Oi=(e,t)=>e.colEnd===t.colEnd?t.rowEnd-e.rowEnd:t.colEnd-e.colEnd,Jo=(e,t)=>e.colIndex===t.colIndex?e.rowIndex-t.rowIndex:e.colIndex-t.colIndex,Qo=(e,t)=>e.rowIndex===t.rowIndex?e.colIndex-t.colIndex:e.rowIndex-t.rowIndex,Wr=(e=Qt,t=!1)=>t?e!==Bt?Pi:Oi:e!==Bt?Vr:Fr,er=(e,t)=>e===t||!(!e||!t)&&e.rowIndex===t.rowIndex&&e.colIndex===t.colIndex,Po=(e,t)=>e===t||!(!e||!t)&&e.rowStart===t.rowStart&&e.rowEnd===t.rowEnd&&e.colStart===t.colStart&&e.colEnd===t.colEnd,Oo=(e,t)=>!(!e||!t||e.colStart>t.colEnd||t.colStart>e.colEnd||e.rowStart>t.rowEnd||t.rowStart>e.rowEnd),tr=(e,t)=>{if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Po(e[n],t[n]))return!1;return!0},yo=(e,t,n)=>{if(!e&&!t)return null;if(!e)return n?t:{...t};if(!t)return n?e:{...e};const o=Math.min(e.colStart,t.colStart),r=Math.min(e.rowStart,t.rowStart),i=Math.max(e.colEnd,t.colEnd),l=Math.max(e.rowEnd,t.rowEnd);let s=n;return s?(s.colStart=o,s.rowStart=r,s.colEnd=i,s.rowEnd=l):s={colStart:o,rowStart:r,colEnd:i,rowEnd:l},s},nr=(e,t)=>{if(!t||t.length===0)return e;const n={...e};for(let o=0;o<t.length;o++){const r=t[o];Oo(n,r)&&(n.rowStart=Math.min(n.rowStart,r.rowStart),n.colStart=Math.min(n.colStart,r.colStart),n.rowEnd=Math.max(n.rowEnd,r.rowEnd),n.colEnd=Math.max(n.colEnd,r.colEnd))}return n},Li=[null,null],Di=(e,t,n)=>{if(e[0].value===e[1].value)return t};function or(e,t=2,n,o=Qt,r){let i=[...e];if(t<=0||e.length<=1)return i;let l=o===Bt,s=0,u=!1;do{const d=i.sort(Wr(l?Qt:Bt));i=[],i.push(d[0]);const w=d.length;let x=0,p=d[0],y=p.colStart,_=p.rowStart,I=p.colEnd,R=p.rowEnd;for(let ce=1;ce<w;ce++){const P=d[ce];let C=!1;if(C=l?p&&_===P.rowStart&&R===P.rowEnd&&I+1===P.colStart:p&&y===P.colStart&&I===P.colEnd&&R+1===P.rowStart,C){let D={colStart:y,rowStart:_,colEnd:l?P.colEnd:I,rowEnd:l?R:P.rowEnd};if(p.value!==void 0&&(D.value=p.value),n){const ie=r??[null,null];ie[0]=p,ie[1]=P,D=n(ie,D,o)}if(D){i[x]=D,u=!0,p=D,y=p.colStart,_=p.rowStart,I=p.colEnd,R=p.rowEnd;continue}}i[++x]=P,p=P,y=p.colStart,_=p.rowStart,I=p.colEnd,R=p.rowEnd}s++,l=!l,s===1&&(u=!0)}while(s<t&&u&&i.length>1);return i}const Z=Object.freeze(Object.defineProperty({__proto__:null,EmptyCell:ki,EmptyRange:Ti,cellToRange:(e,t)=>{if(!e)return null;let n=t;return n||(n={...e},delete n.colIndex,delete n.rowIndex),n.colStart=e.colIndex??0,n.rowStart=e.rowIndex??0,n.colEnd=e.colIndex??0,n.rowEnd=e.rowIndex??0,n},columnFirstCellComparator:Jo,columnFirstRangeComparator:Fr,createCellComparator:(e=Qt,t=!1)=>t?e!==Bt?(n,o)=>n.rowIndex===o.rowIndex?o.colIndex-n.colIndex:o.rowIndex-n.rowIndex:(n,o)=>n.colIndex===o.colIndex?o.rowIndex-n.rowIndex:o.colIndex-n.colIndex:e!==Bt?Qo:Jo,createConflatingRanges:(e,t=!1)=>{const n=[];let o,r,i=Number.MIN_SAFE_INTEGER,l=Number.MIN_SAFE_INTEGER;return{append:(s,u,d)=>{let w=!0;const x=d!==void 0;if(x){const _=e?e(r,d,t):r===d?d:void 0;_===void 0?w=!1:d=_}if(w&&u===l+1&&s===i)return t?o.rowEnd=u:o.colEnd=u,l=u,void(r=d);o&&n.push(o);const p=t?s:u,y=t?u:s;o={colStart:p,rowStart:y,colEnd:p,rowEnd:y},x&&(o.value=d),i=s,l=u,r=d},done:s=>(o&&(n.push(o),o=null),s?or(n,3,s===!0?Di:s,t?Bt:Qt,Li):n)}},createRangeComparator:Wr,defaultRange:(e,t,n)=>e?n?(n.colStart=e.colStart??t.colStart,n.rowStart=e.rowStart??t.rowStart,n.colEnd=e.colEnd??t.colEnd,n.rowEnd=e.rowEnd??t.rowEnd,n):{colStart:e.colStart??t.colStart,rowStart:e.rowStart??t.rowStart,colEnd:e.colEnd??t.colEnd,rowEnd:e.rowEnd??t.rowEnd}:t,extendRangeToIntersectingRanges:nr,extendRangeToUnionRanges:(e,t)=>{if(!t||t.length===0)return e;let n=e,o=null;for(;!Po(n,o);)o=n,n=nr(o,t);return n},indexOfCoords:(e,t)=>{const n={colStart:e.colIndex,rowStart:e.rowIndex,colEnd:e.colIndex,rowEnd:e.rowIndex};for(let o=t.length-1;o>=0;o--)if(Oo(n,t[o]))return o;return-1},intersectRanges:(e,t,n)=>{if(!e)return n?t:{...t};if(!t)return n?e:{...e};if(!e&&!t||e.rowStart>t.rowEnd||e.rowEnd<t.rowStart||e.colStart>t.colEnd||e.colEnd<t.colStart)return null;const o=Math.max(e.colStart,t.colStart),r=Math.max(e.rowStart,t.rowStart),i=Math.min(e.colEnd,t.colEnd),l=Math.min(e.rowEnd,t.rowEnd);let s=n;return s?(s.colStart=o,s.rowStart=r,s.colEnd=i,s.rowEnd=l):s={colStart:o,rowStart:r,colEnd:i,rowEnd:l},s},isCellWithinRange:(e,t)=>!(!e||!t||e.rowIndex<t.rowStart||e.rowIndex>t.rowEnd||e.colIndex<t.colStart||e.colIndex>t.colEnd),isEqualCells:er,isEqualRanges:Po,isEqualRangesArrays:tr,isEqualSelectionCoords:(e,t)=>e===t||!(!e||!t)&&e.rangeIndex===t.rangeIndex&&!!er(e.cell,t.cell)&&tr(e.ranges,t.ranges),isRangeWithinRange:(e,t)=>!(e.rowStart<t.rowStart||e.rowEnd>t.rowEnd||e.colStart<t.colStart||e.colEnd>t.colEnd),isRangesIntersect:Oo,isSingleCell:e=>!!e&&e.rowEnd===e.rowStart&&e.colStart===e.colEnd,isValidRange:e=>!(!e||typeof e.colStart!="number"||e.colStart<0||typeof e.colEnd!="number"||e.colEnd<e.colStart||typeof e.rowStart!="number"||e.rowStart<0||typeof e.rowEnd!="number"||e.rowEnd<e.rowStart),mergeRangedValues:or,rowFirstCellComparator:Qo,rowFirstRangeComparator:Vr,sanitizeRange:e=>e?{colStart:e.colIndex??e.colStart??0,rowStart:e.rowIndex??e.rowStart??0,colEnd:e.colIndex??e.colEnd??0,rowEnd:e.rowIndex??e.rowEnd??0}:null,translateRange:(e,t=-e.rowStart,n=-e.colStart,o)=>o?(o.colStart=e.colStart+n,o.rowStart=e.rowStart+t,o.colEnd=e.colEnd+n,o.rowEnd=e.rowEnd+t,o):{colStart:e.colStart+n,rowStart:e.rowStart+t,colEnd:e.colEnd+n,rowEnd:e.rowEnd+t},unionRanges:yo,unionRangesArrays:(e,t,n)=>{if(!e||e.length===0)return null;if(e.length===1&&!t)return e[0];let o=e[0];for(let r=1;r<e.length;r++)o=yo(o,e[r],n);return t&&(o=yo(o,t,n)),o}},Symbol.toStringTag,{value:"Module"})),zi=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function ji(e){return function(t){return!!t&&typeof t=="object"}(e)&&!function(t){const n=Object.prototype.toString.call(t);return n==="[object RegExp]"||n==="[object Date]"||t.$$typeof===zi}(e)}function Pn(e,t){return t.clone!==!1&&t.isMergeableObject(e)?pn((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function Ai(e,t,n){return e.concat(t).map(function(o){return Pn(o,n)})}function rr(e){return Object.keys(e).concat((t=e,Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(n){return Object.propertyIsEnumerable.call(t,n)}):[]));var t}function ir(e,t){try{return t in e}catch{return!1}}function pn(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||Ai,n.isMergeableObject=n.isMergeableObject||ji,n.cloneUnlessOtherwiseSpecified=Pn;const o=Array.isArray(t);return o===Array.isArray(e)?o?n.arrayMerge(e,t,n):function(r,i,l){const s={};return l.isMergeableObject(r)&&rr(r).forEach(function(u){s[u]=Pn(r[u],l)}),rr(i).forEach(function(u){var d,w;ir(d=r,w=u)&&(!Object.hasOwnProperty.call(d,w)||!Object.propertyIsEnumerable.call(d,w))||(ir(r,u)&&l.isMergeableObject(i[u])?s[u]=function(x,p){if(!p.customMerge)return pn;const y=p.customMerge(x);return typeof y=="function"?y:pn}(u,l)(r[u],i[u],l):s[u]=Pn(i[u],l))}),s}(e,t,n):Pn(t,n)}pn.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(n,o){return pn(n,o,t)},{})};const $i=Object.freeze([]),Bi=Object.freeze({}),lr=e=>e,Zn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return(e==="x"?t:3&t|8).toString(16)}),Hr=(e,t)=>e===t||!(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)&&e.every((n,o)=>n===t[o]),kn=e=>typeof e=="object"&&!Array.isArray(e)&&e!==null,Nr=e=>typeof e!="object"||Array.isArray(e)||e===null?e:(Object.keys(e).forEach(function(t){e[t]&&typeof e[t]=="object"?Nr(e[t]):e[t]!==null&&e[t]!==void 0||delete e[t],typeof e[t]=="object"&&Object.keys(e[t]).length===0&&delete e[t]}),Object.keys(e).length===0?null:e),Fi=(e,t)=>!(e!==t&&!Hr(e,t)&&!e.isEqual?.(t)),Ur=(e,t,n=Fi)=>{if(e==null||e===t)return null;if(!e||typeof e!="object"||Array.isArray(e)||e.isImmutable?.())return n(e,t)?null:e;const o=Object.keys(e);if(o.length===0)return null;let r=!1;for(let i=0;i<o.length;i++){const l=o[i];Ur(e[l],t?.[l],n)===null&&(r=!0,delete e[l])}return r&&Object.keys(e).length===0?null:void 0},sr=typeof performance=="object"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now(),cr=e=>e==null,ar=(e,t)=>!(t.left>e.right||t.right<e.left||t.top>e.bottom||t.bottom<e.top),ur=!(typeof window>"u"||!window.document||!window.document.createElement),Dt={Windows:"windows",MacOS:"macos",IOS:"ios",Linux:"linux",Android:"android",Safari:"safari",Firefox:"firefox",Node:"node",Unknown:"unknown"},zn=()=>{if(qr())return Dt.Node;const e=globalThis.navigator!==void 0&&globalThis.navigator.userAgent?globalThis.navigator.userAgent.toLowerCase():"";return e?/(win32|win64|windows|wince)/i.test(e)?Dt.Windows:/(macintosh|macintel|macppc|mac68k|macos)/i.test(e)?Dt.MacOS:/(iphone|ipad|ipod)/i.test(e)?Dt.IOS:/android/.test(e)?Dt.Android:/linux/.test(e)?Dt.Linux:/^((?!chrome|android|).)*safari/i.test(e)?Dt.Safari:/^((?!chrome|android|Seamonkey).)*firefox/i.test(e)?Dt.Firefox:Dt.Unknown:Dt.Unknown};function qr(){return typeof process<"u"&&process.release?.name==="node"||(typeof process<"u"&&process.browser,!1)}const dr=(e,t=!1)=>(document.hasFocus()||t)&&(e===document.activeElement||e?.contains(document.activeElement)),St=Object.freeze(Object.defineProperty({__proto__:null,EmptyArray:$i,EmptyObject:Bi,OSType:Dt,arrayMove:function(e,t,n){const o=e.slice();return o.splice(n<0?o.length+n:n,0,o.splice(t,1)[0]),o},asNumber:e=>{const t=(n=>1*n)(e);return Number.isFinite(t)?t:0},camelToPrettyCase:e=>e.length===1?e.toUpperCase():e.replace(/([A-Z])/g," $1").replace(/^./,function(t){return t.toUpperCase()}).trim(),canUseDOM:ur,cancelTimeout:e=>{cancelAnimationFrame(e.id)},castToString:e=>e==null||e===void 0?"":typeof e!="string"?""+e:e,cloneObject:e=>cr(e)?e:JSON.parse(JSON.stringify(e)),consoleWithNoSource:(...e)=>new Promise(t=>{setTimeout(()=>{Function("console.log.apply(console, arguments)").apply(null,e),t()})}),debounce:function(e,t=300,n=!1){let o,r,i,l,s=0;function u(){let w=Date.now()-s;w<t&&w>=0?o=setTimeout(u,t-w):(o=null,n||(l=e.apply(i,r),i=r=null))}t==null&&(t=100);const d=function(){i=globalThis,r=arguments,s=Date.now();var w=n&&!o;return o||(o=setTimeout(u,t)),w&&(l=e.apply(i,r),i=r=null),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=e.apply(i,r),i=r=null,clearTimeout(o),o=null)},d},deepEqual:function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;let o,r,i;if(Array.isArray(t)){if(o=t.length,o!=n.length)return!1;for(r=o;r--!==0;)if(!e(t[r],n[r]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(r of t.entries())if(!n.has(r[0]))return!1;for(r of t.entries())if(!e(r[1],n.get(r[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(r of t.entries())if(!n.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if(o=t.length,o!=n.length)return!1;for(r=o;r--!==0;)if(t[r]!==n[r])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(i=Object.keys(t),o=i.length,o!==Object.keys(n).length)return!1;for(r=o;r--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[r]))return!1;for(r=o;r--!==0;){let l=i[r];if(!(l==="_owner"&&t.$$typeof||e(t[l],n[l])))return!1}return!0}return t!=t&&n!=n},deepFreeze:function e(t){return Object.freeze(t),Object.keys(t).forEach(n=>{typeof t[n]!="object"||t[n]===null||Object.isFrozen(t[n])||e(t[n])}),t},deepMerge:pn,diffValues:(e,t)=>{const n={},o=Object.keys(t),r=o.length;for(let i=0;i<r;i++){const l=o[i];e[l]!==t[l]&&(e[l]===void 0?n[l]=t[l]:n[l]=e[l])}return Object.keys(n).length===0?null:n},findEqualOrGreater:function(e,t,n=lr){let o=0,r=e.length-1;for(;o<=r;){let i=Math.floor((o+r)/2),l=n(e[i]);if(l===t)return i;l<t?o=i+1:r=i-1}return o},findEqualOrLesser:function(e,t,n=lr){let o=e.length-1,r=0;for(;o>=r;){let i=Math.floor((o+r)/2),l=n(e[i]);if(l===t)return i;l>t?o=i-1:r=i+1}return o},findNextStep:(e,t=!0,n=15,o=10,r=400)=>{const i=Math.max(e-o,0)+(t?1:-1);return Math.min(r,Math[t?"ceil":"floor"](i/n)*n+o)},getBuildEnv:()=>"browser2-build",getDPI:()=>{let e=1;return typeof window=="object"&&(e=window.devicePixelRatio||1),e},getFromPath:(e,t)=>{const n=t.split(".");let o=e;for(let r=0;r<n.length;r++){const i=n[r];if(!o)return null;let l=o[i];if(typeof l=="function"&&(l=l.bind(o)()),!l||!kn(l))return l;o=l}return o??null},getOS:zn,hasFocus:dr,isDefined:e=>e!=null,isEmpty:e=>e==null||e==="",isEqualArrays:Hr,isEqualBounds:(e,t)=>e===t||!(e&&!t||t&&!e)&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,isEqualObjectKeys:(e,t)=>{if(e===t)return!0;if(e&&!t||t&&!e)return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o=0;o<n.length;o++)if(e[n[o]]!==t[n[o]])return!1;return!0},isNode:qr,isNullOrUndefined:cr,isNumeric:e=>{const t=1*e;return Number.isFinite(t)&&typeof t=="number"},isObject:kn,isPromiseLike:e=>!!e&&typeof e.then=="function",isRectInsideRect:(e,t)=>e.top>=t.top&&e.bottom<=t.bottom&&e.left>=t.left&&e.right<=t.right,isRectIntersect:ar,mergeContentful:(...e)=>{const t=e.length;if(t>0&&e[t-1]!==void 0&&!kn(e[t-1]))return e[t-1];let n=e[0]||{};for(let o=1;o<t;o++)n=pn(n,e[o]||{},{arrayMerge:(r,i)=>[...i]});return n},nextTick:e=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(()=>{e()}):(typeof setImmediate=="function"?setImmediate:setTimeout)(()=>{e()})},openFileDialog:(e="*.*")=>new Promise((t,n)=>{if(!ur)return void n("Unable to open dialog with no dom.");const o=document.createElement("input");o.type="file",o.accept=e;let r=null,i=!1;globalThis.addEventListener?.("focus",()=>{setTimeout(()=>{r||i||(i=!0,t(null))},1e3)},{once:!0,passive:!0}),o.onchange=()=>{if(r=o.files[0],r){if(i)return void console.warn("File open detected after faux cancel.",r);t(r)}},o.autofocus=!0,o.click()}),rafThrottle:e=>{let t,n=!1,o=function(){n=!1,e(t)};return function(r){t=r,t&&t.persist&&t.persist(),n||(n=!0,requestAnimationFrame(o))}},removeEmptyProperties:Nr,removeEqualValues:Ur,removeListenerAll:e=>{if(!e)return[];for(let t=0;t<e.length;t++)e[t]&&e[t]();return[]},requestTimeout:(e,t)=>{const n=sr(),o={id:requestAnimationFrame(function r(){sr()-n>=t?e.call(null):o.id=requestAnimationFrame(r)})};return o},roundAccurately:(e,t=0)=>{if(e==null||!isFinite(e))return null;const n=10**t;return Number(Math.round(e*n)/n)},setToPath:(e,t,n)=>{const o=t.split(".");let r=e;if(!r)throw new Error("Can not set path to a null path.");for(let i=0;r&&i<o.length-1;i++){const l=o[i];let s=r[l];if(s==null&&(s={},r[l]=s),!kn(s))throw new Error("Can not set path to a non object path.");r=s}if(typeof n!="number"&&typeof n!="boolean"&&typeof n!="string"&&!kn(n))throw new Error(`Can not set path to ${n} that is not a a supported primitive.`);return r[o[o.length-1]]=n,e},splitNumber:e=>{let t=Math.abs(e);if(isNaN(t)||!isFinite(e))return null;let n=0|t,o=t-n,r=0,i=0,l=1;if(o>5e-8)for(;i<8&&Math.abs(r/l-o)>5e-8;)i++,l*=10,r=Math.round(o*l);return{ip:Math.trunc(e),fp:r,ipLength:Math.ceil(Math.log10(n+1)),fpLength:i}},subtractRect:(e,t,n=!1)=>{if(!t)return[e];if(!ar(e,t))return[];const o=[];let r=e;const i=()=>{t.top>r.top&&t.top<r.bottom&&(o.push({...r,bottom:t.top}),r={...r,top:t.top})},l=()=>{t.bottom>r.top&&t.bottom<r.bottom&&(o.push({...r,top:t.bottom}),r={...r,bottom:t.bottom})},s=()=>{t.right>r.left&&t.right<r.right&&(o.push({...r,left:t.right}),r={...r,right:t.right})},u=()=>{t.left>r.left&&t.left<r.right&&(o.push({...r,right:t.left}),r={...r,left:t.left})};return n?(u(),s(),i(),l()):(i(),l(),s(),u()),o},textToKey:e=>e.replace(/[^a-zA-Z0-9]/g,"").toLowerCase(),throttle:function(e,t){let n=null;return(...o)=>{const r=Date.now();(!n||r-n>=t)&&(n=r,e(...o))}},toSafeJSON:function e(t){if(t===null||typeof t!="object")return t;if(typeof t.toJSON=="function")return t.toJSON();if(Array.isArray(t))return t.map(o=>e(o));if(typeof t.toString=="function"&&t.toString!==Object.prototype.toString)return t.toString();const n={};for(const o in t)t.hasOwnProperty(o)&&(n[o]=e(t[o]));return n},transpose:e=>{if(!e)return e;const t=e.length,n=e[0].length,o=[];for(let r=0;r<n;r++)o[r]=Array(t);for(let r=0;r<t;r++)for(let i=0;i<n;i++)o[i][r]=e[r][i];return o},uuidV4:Zn,validEnumValue:(e,t)=>{if(!Object.values(e).includes(t))throw new Error(`Invalid type: ${t??"null"}. Must be one of: ${Object.values(t).join(", ")}.`)},whenFocus:async(e,t=!1)=>new Promise(n=>{dr(e,t)?n(!0):e.addEventListener("focusin",()=>{n(!0)},{once:!0}),e.focus()})},Symbol.toStringTag,{value:"Module"}));Object.freeze(Object.defineProperty({__proto__:null,MESSAGE_ERROR_INVALID_ARG:e=>`Invalid argument: '${e}'.`},Symbol.toStringTag,{value:"Module"}));const Kr=e=>{const t=new Uint8Array(e),n=t.byteLength;let o="";for(let r=0;r<n;r++)o+=String.fromCharCode(t[r]);if(typeof window<"u"&&typeof globalThis.btoa=="function")return globalThis.btoa(o);if(typeof Buffer<"u")return Buffer.from(o,"binary").toString("base64");throw new Error("Unsupported environment")},Lo=e=>new Promise((t,n)=>{if(e)if(typeof FileReader<"u"){const o=new FileReader;o.onload=()=>{t(o.result)},o.onerror=()=>{n(o.error)},o.readAsText(e)}else if(typeof Buffer<"u"){const o=r=>Buffer.from(r).toString("utf-8");e.arrayBuffer().then(r=>{t(o(r))}).catch(r=>{n(r)})}else n(new Error("Unsupported environment"));else t("")});Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIME_TYPE:"*/*",arrayBufferToBase64:Kr,base64ToArrayBuffer:e=>{const t=typeof window<"u"&&typeof globalThis.atob=="function"?globalThis.atob(e):Buffer.from(e,"base64").toString("binary"),n=t.length,o=new Uint8Array(n);for(let r=0;r<n;r++)o[r]=t.charCodeAt(r);return o.buffer},blobToString:Lo},Symbol.toStringTag,{value:"Module"}));const Xr="data:image/png;base64,",Yr="Unable to resolve image.",hr=e=>new Promise(async(t,n)=>{let o=null;try{o=new Image,o.src=e,o.addEventListener("load",function(){t({width:o.naturalWidth,height:o.naturalHeight})},{once:!0}),o.addEventListener("error",function(){URL.revokeObjectURL(e),n("Invalid Image")},{once:!0}),await o.decode("sync")}catch{o?.src&&URL.revokeObjectURL(o.src)}o||n(Yr)}),vo="image/svg+xml";var fr,pr;Object.freeze(Object.defineProperty({__proto__:null,DATA_URL_PNG_PREFIX:Xr,getImageDataUrl:(e,t=1)=>new Promise(async(n,o)=>{let r=null;try{r=new Image,r.src=e,r.addEventListener("load",function(){try{const i=document.createElement("canvas");i.width=r.naturalWidth,i.height=r.naturalHeight,i.getContext("2d").drawImage(r,0,0);const l=i.toDataURL("image/png",t);n({elemImg:r,dataUrl:l})}catch(i){URL.revokeObjectURL(e),o(i)}},{once:!0}),r.addEventListener("error",function(){URL.revokeObjectURL(e),o("Invalid Image")},{once:!0}),await r.decode("sync")}catch{r?.src&&URL.revokeObjectURL(r.src)}r||o(Yr)}),loadImageDetails:async(e,t=null)=>{let n=null;const o=async()=>{try{const i=t??"image/*",l=URL.createObjectURL(new Blob([e],{type:i})),s=await hr(l);n={mimeType:i,naturalDimensions:s,asUrl:l}}catch{}},r=async()=>{try{const i=new TextDecoder().decode(e),l=URL.createObjectURL(new Blob([i],{type:vo})),s=await hr(l);n={mimeType:t??vo,naturalDimensions:s,asUrl:l,asSVGText:i}}catch{}};if(t===vo?await r():t.startsWith("image/")?await o():(await o(),n||await r()),!n)throw new Error("Failed to load image");return n}},Symbol.toStringTag,{value:"Module"})),(pr=fr||(fr={})).resolveTypedUpdates=(e,t,n,o)=>{if(e===null)return e;if(e===void 0)return o;let r=e;if(t?.shorthand){const u=t?.shorthand(e,n);u!==void 0&&(r=u)}if(r!==null&&t?.getSubType){const u=t.getSubType(r);u&&(t=u)}const i=t?.properties,l=t?.arrayType??!1;let s=r;if(t&&t.merge&&s&&o)s=t.merge(s,o,n);else if(!l&&i){const u=Object.keys({...r,...o});s=null;for(let d=0;d<u.length;d++){const w=u[d];let x,p=r[w];if(p!==void 0){const y=i[w];x=y?(0,pr.resolveTypedUpdates)(p,y,n,o?.[w]):p}else x=o?.[w];x!=null&&(s=s??{},s[w]=x)}}return s};const gr=`The Safari browser does not support advanced copy and paste.
|
|
7
|
+
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react/jsx-runtime"),c=require("react"),Ci=require("react-dom/client"),No=require("react-dom"),nt="up",ot="down",et="left",Ue="right",to="tl",Ln="t",Dn="l",Ht="c",Lt="text/html",rn="text/plain",xo="image/png",Ii=Object.freeze({left:0,top:0}),Mi=Object.freeze({left:0,top:0,bottom:0,right:0}),Ri=Object.freeze({x:0,y:0,width:0,height:0});Object.freeze(Object.defineProperty({__proto__:null,EmptyBounds:Ri,EmptyRect:Mi,EmptyTopLeft:Ii},Symbol.toStringTag,{value:"Module"}));const Bt="column",Qt="row",ki=Object.freeze({colIndex:0,rowIndex:0}),Ti=Object.freeze({colStart:0,rowStart:0,colEnd:0,rowEnd:0}),Fr=(e,t)=>e.colStart===t.colStart?e.rowStart-t.rowStart:e.colStart-t.colStart,Vr=(e,t)=>e.rowStart===t.rowStart?e.colStart-t.colStart:e.rowStart-t.rowStart,Pi=(e,t)=>e.rowEnd===t.rowEnd?t.colEnd-e.colEnd:t.rowEnd-e.rowEnd,Oi=(e,t)=>e.colEnd===t.colEnd?t.rowEnd-e.rowEnd:t.colEnd-e.colEnd,Jo=(e,t)=>e.colIndex===t.colIndex?e.rowIndex-t.rowIndex:e.colIndex-t.colIndex,Qo=(e,t)=>e.rowIndex===t.rowIndex?e.colIndex-t.colIndex:e.rowIndex-t.rowIndex,Wr=(e=Qt,t=!1)=>t?e!==Bt?Pi:Oi:e!==Bt?Vr:Fr,er=(e,t)=>e===t||!(!e||!t)&&e.rowIndex===t.rowIndex&&e.colIndex===t.colIndex,Po=(e,t)=>e===t||!(!e||!t)&&e.rowStart===t.rowStart&&e.rowEnd===t.rowEnd&&e.colStart===t.colStart&&e.colEnd===t.colEnd,Oo=(e,t)=>!(!e||!t||e.colStart>t.colEnd||t.colStart>e.colEnd||e.rowStart>t.rowEnd||t.rowStart>e.rowEnd),tr=(e,t)=>{if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Po(e[n],t[n]))return!1;return!0},yo=(e,t,n)=>{if(!e&&!t)return null;if(!e)return n?t:{...t};if(!t)return n?e:{...e};const o=Math.min(e.colStart,t.colStart),r=Math.min(e.rowStart,t.rowStart),i=Math.max(e.colEnd,t.colEnd),l=Math.max(e.rowEnd,t.rowEnd);let s=n;return s?(s.colStart=o,s.rowStart=r,s.colEnd=i,s.rowEnd=l):s={colStart:o,rowStart:r,colEnd:i,rowEnd:l},s},nr=(e,t)=>{if(!t||t.length===0)return e;const n={...e};for(let o=0;o<t.length;o++){const r=t[o];Oo(n,r)&&(n.rowStart=Math.min(n.rowStart,r.rowStart),n.colStart=Math.min(n.colStart,r.colStart),n.rowEnd=Math.max(n.rowEnd,r.rowEnd),n.colEnd=Math.max(n.colEnd,r.colEnd))}return n},Li=[null,null],Di=(e,t,n)=>{if(e[0].value===e[1].value)return t};function or(e,t=2,n,o=Qt,r){let i=[...e];if(t<=0||e.length<=1)return i;let l=o===Bt,s=0,u=!1;do{const d=i.sort(Wr(l?Qt:Bt));i=[],i.push(d[0]);const w=d.length;let x=0,p=d[0],y=p.colStart,_=p.rowStart,I=p.colEnd,R=p.rowEnd;for(let ce=1;ce<w;ce++){const P=d[ce];let C=!1;if(C=l?p&&_===P.rowStart&&R===P.rowEnd&&I+1===P.colStart:p&&y===P.colStart&&I===P.colEnd&&R+1===P.rowStart,C){let D={colStart:y,rowStart:_,colEnd:l?P.colEnd:I,rowEnd:l?R:P.rowEnd};if(p.value!==void 0&&(D.value=p.value),n){const ie=r??[null,null];ie[0]=p,ie[1]=P,D=n(ie,D,o)}if(D){i[x]=D,u=!0,p=D,y=p.colStart,_=p.rowStart,I=p.colEnd,R=p.rowEnd;continue}}i[++x]=P,p=P,y=p.colStart,_=p.rowStart,I=p.colEnd,R=p.rowEnd}s++,l=!l,s===1&&(u=!0)}while(s<t&&u&&i.length>1);return i}const Z=Object.freeze(Object.defineProperty({__proto__:null,EmptyCell:ki,EmptyRange:Ti,cellToRange:(e,t)=>{if(!e)return null;let n=t;return n||(n={...e},delete n.colIndex,delete n.rowIndex),n.colStart=e.colIndex??0,n.rowStart=e.rowIndex??0,n.colEnd=e.colIndex??0,n.rowEnd=e.rowIndex??0,n},columnFirstCellComparator:Jo,columnFirstRangeComparator:Fr,createCellComparator:(e=Qt,t=!1)=>t?e!==Bt?(n,o)=>n.rowIndex===o.rowIndex?o.colIndex-n.colIndex:o.rowIndex-n.rowIndex:(n,o)=>n.colIndex===o.colIndex?o.rowIndex-n.rowIndex:o.colIndex-n.colIndex:e!==Bt?Qo:Jo,createConflatingRanges:(e,t=!1)=>{const n=[];let o,r,i=Number.MIN_SAFE_INTEGER,l=Number.MIN_SAFE_INTEGER;return{append:(s,u,d)=>{let w=!0;const x=d!==void 0;if(x){const _=e?e(r,d,t):r===d?d:void 0;_===void 0?w=!1:d=_}if(w&&u===l+1&&s===i)return t?o.rowEnd=u:o.colEnd=u,l=u,void(r=d);o&&n.push(o);const p=t?s:u,y=t?u:s;o={colStart:p,rowStart:y,colEnd:p,rowEnd:y},x&&(o.value=d),i=s,l=u,r=d},done:s=>(o&&(n.push(o),o=null),s?or(n,3,s===!0?Di:s,t?Bt:Qt,Li):n)}},createRangeComparator:Wr,defaultRange:(e,t,n)=>e?n?(n.colStart=e.colStart??t.colStart,n.rowStart=e.rowStart??t.rowStart,n.colEnd=e.colEnd??t.colEnd,n.rowEnd=e.rowEnd??t.rowEnd,n):{colStart:e.colStart??t.colStart,rowStart:e.rowStart??t.rowStart,colEnd:e.colEnd??t.colEnd,rowEnd:e.rowEnd??t.rowEnd}:t,extendRangeToIntersectingRanges:nr,extendRangeToUnionRanges:(e,t)=>{if(!t||t.length===0)return e;let n=e,o=null;for(;!Po(n,o);)o=n,n=nr(o,t);return n},indexOfCoords:(e,t)=>{const n={colStart:e.colIndex,rowStart:e.rowIndex,colEnd:e.colIndex,rowEnd:e.rowIndex};for(let o=t.length-1;o>=0;o--)if(Oo(n,t[o]))return o;return-1},intersectRanges:(e,t,n)=>{if(!e)return n?t:{...t};if(!t)return n?e:{...e};if(!e&&!t||e.rowStart>t.rowEnd||e.rowEnd<t.rowStart||e.colStart>t.colEnd||e.colEnd<t.colStart)return null;const o=Math.max(e.colStart,t.colStart),r=Math.max(e.rowStart,t.rowStart),i=Math.min(e.colEnd,t.colEnd),l=Math.min(e.rowEnd,t.rowEnd);let s=n;return s?(s.colStart=o,s.rowStart=r,s.colEnd=i,s.rowEnd=l):s={colStart:o,rowStart:r,colEnd:i,rowEnd:l},s},isCellWithinRange:(e,t)=>!(!e||!t||e.rowIndex<t.rowStart||e.rowIndex>t.rowEnd||e.colIndex<t.colStart||e.colIndex>t.colEnd),isEqualCells:er,isEqualRanges:Po,isEqualRangesArrays:tr,isEqualSelectionCoords:(e,t)=>e===t||!(!e||!t)&&e.rangeIndex===t.rangeIndex&&!!er(e.cell,t.cell)&&tr(e.ranges,t.ranges),isRangeWithinRange:(e,t)=>!(e.rowStart<t.rowStart||e.rowEnd>t.rowEnd||e.colStart<t.colStart||e.colEnd>t.colEnd),isRangesIntersect:Oo,isSingleCell:e=>!!e&&e.rowEnd===e.rowStart&&e.colStart===e.colEnd,isValidRange:e=>!(!e||typeof e.colStart!="number"||e.colStart<0||typeof e.colEnd!="number"||e.colEnd<e.colStart||typeof e.rowStart!="number"||e.rowStart<0||typeof e.rowEnd!="number"||e.rowEnd<e.rowStart),mergeRangedValues:or,rowFirstCellComparator:Qo,rowFirstRangeComparator:Vr,sanitizeRange:e=>e?{colStart:e.colIndex??e.colStart??0,rowStart:e.rowIndex??e.rowStart??0,colEnd:e.colIndex??e.colEnd??0,rowEnd:e.rowIndex??e.rowEnd??0}:null,translateRange:(e,t=-e.rowStart,n=-e.colStart,o)=>o?(o.colStart=e.colStart+n,o.rowStart=e.rowStart+t,o.colEnd=e.colEnd+n,o.rowEnd=e.rowEnd+t,o):{colStart:e.colStart+n,rowStart:e.rowStart+t,colEnd:e.colEnd+n,rowEnd:e.rowEnd+t},unionRanges:yo,unionRangesArrays:(e,t,n)=>{if(!e||e.length===0)return null;if(e.length===1&&!t)return e[0];let o=e[0];for(let r=1;r<e.length;r++)o=yo(o,e[r],n);return t&&(o=yo(o,t,n)),o}},Symbol.toStringTag,{value:"Module"})),zi=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function ji(e){return function(t){return!!t&&typeof t=="object"}(e)&&!function(t){const n=Object.prototype.toString.call(t);return n==="[object RegExp]"||n==="[object Date]"||t.$$typeof===zi}(e)}function Pn(e,t){return t.clone!==!1&&t.isMergeableObject(e)?pn((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function Ai(e,t,n){return e.concat(t).map(function(o){return Pn(o,n)})}function rr(e){return Object.keys(e).concat((t=e,Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(n){return Object.propertyIsEnumerable.call(t,n)}):[]));var t}function ir(e,t){try{return t in e}catch{return!1}}function pn(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||Ai,n.isMergeableObject=n.isMergeableObject||ji,n.cloneUnlessOtherwiseSpecified=Pn;const o=Array.isArray(t);return o===Array.isArray(e)?o?n.arrayMerge(e,t,n):function(r,i,l){const s={};return l.isMergeableObject(r)&&rr(r).forEach(function(u){s[u]=Pn(r[u],l)}),rr(i).forEach(function(u){var d,w;ir(d=r,w=u)&&(!Object.hasOwnProperty.call(d,w)||!Object.propertyIsEnumerable.call(d,w))||(ir(r,u)&&l.isMergeableObject(i[u])?s[u]=function(x,p){if(!p.customMerge)return pn;const y=p.customMerge(x);return typeof y=="function"?y:pn}(u,l)(r[u],i[u],l):s[u]=Pn(i[u],l))}),s}(e,t,n):Pn(t,n)}pn.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(n,o){return pn(n,o,t)},{})};const $i=Object.freeze([]),Bi=Object.freeze({}),lr=e=>e,Zn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return(e==="x"?t:3&t|8).toString(16)}),Hr=(e,t)=>e===t||!(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)&&e.every((n,o)=>n===t[o]),kn=e=>typeof e=="object"&&!Array.isArray(e)&&e!==null,Nr=e=>typeof e!="object"||Array.isArray(e)||e===null?e:(Object.keys(e).forEach(function(t){e[t]&&typeof e[t]=="object"?Nr(e[t]):e[t]!==null&&e[t]!==void 0||delete e[t],typeof e[t]=="object"&&Object.keys(e[t]).length===0&&delete e[t]}),Object.keys(e).length===0?null:e),Fi=(e,t)=>!(e!==t&&!Hr(e,t)&&!e.isEqual?.(t)),Ur=(e,t,n=Fi)=>{if(e==null||e===t)return null;if(!e||typeof e!="object"||Array.isArray(e)||e.isImmutable?.())return n(e,t)?null:e;const o=Object.keys(e);if(o.length===0)return null;let r=!1;for(let i=0;i<o.length;i++){const l=o[i];Ur(e[l],t?.[l],n)===null&&(r=!0,delete e[l])}return r&&Object.keys(e).length===0?null:void 0},sr=typeof performance=="object"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now(),cr=e=>e==null,ar=(e,t)=>!(t.left>e.right||t.right<e.left||t.top>e.bottom||t.bottom<e.top),ur=!(typeof window>"u"||!window.document||!window.document.createElement),Dt={Windows:"windows",MacOS:"macos",IOS:"ios",Linux:"linux",Android:"android",Safari:"safari",Firefox:"firefox",Node:"node",Unknown:"unknown"},zn=()=>{if(Kr())return Dt.Node;const e=globalThis.navigator!==void 0&&globalThis.navigator.userAgent?globalThis.navigator.userAgent.toLowerCase():"";return e?/(win32|win64|windows|wince)/i.test(e)?Dt.Windows:/(macintosh|macintel|macppc|mac68k|macos)/i.test(e)?Dt.MacOS:/(iphone|ipad|ipod)/i.test(e)?Dt.IOS:/android/.test(e)?Dt.Android:/linux/.test(e)?Dt.Linux:/^((?!chrome|android|).)*safari/i.test(e)?Dt.Safari:/^((?!chrome|android|Seamonkey).)*firefox/i.test(e)?Dt.Firefox:Dt.Unknown:Dt.Unknown};function Kr(){return typeof process<"u"&&process.release?.name==="node"||(typeof process<"u"&&process.browser,!1)}const dr=(e,t=!1)=>(document.hasFocus()||t)&&(e===document.activeElement||e?.contains(document.activeElement)),St=Object.freeze(Object.defineProperty({__proto__:null,EmptyArray:$i,EmptyObject:Bi,OSType:Dt,arrayMove:function(e,t,n){const o=e.slice();return o.splice(n<0?o.length+n:n,0,o.splice(t,1)[0]),o},asNumber:e=>{const t=(n=>1*n)(e);return Number.isFinite(t)?t:0},camelToPrettyCase:e=>e.length===1?e.toUpperCase():e.replace(/([A-Z])/g," $1").replace(/^./,function(t){return t.toUpperCase()}).trim(),canUseDOM:ur,cancelTimeout:e=>{cancelAnimationFrame(e.id)},castToString:e=>e==null||e===void 0?"":typeof e!="string"?""+e:e,cloneObject:e=>cr(e)?e:JSON.parse(JSON.stringify(e)),consoleWithNoSource:(...e)=>new Promise(t=>{setTimeout(()=>{Function("console.log.apply(console, arguments)").apply(null,e),t()})}),debounce:function(e,t=300,n=!1){let o,r,i,l,s=0;function u(){let w=Date.now()-s;w<t&&w>=0?o=setTimeout(u,t-w):(o=null,n||(l=e.apply(i,r),i=r=null))}t==null&&(t=100);const d=function(){i=globalThis,r=arguments,s=Date.now();var w=n&&!o;return o||(o=setTimeout(u,t)),w&&(l=e.apply(i,r),i=r=null),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=e.apply(i,r),i=r=null,clearTimeout(o),o=null)},d},deepEqual:function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;let o,r,i;if(Array.isArray(t)){if(o=t.length,o!=n.length)return!1;for(r=o;r--!==0;)if(!e(t[r],n[r]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(r of t.entries())if(!n.has(r[0]))return!1;for(r of t.entries())if(!e(r[1],n.get(r[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(r of t.entries())if(!n.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if(o=t.length,o!=n.length)return!1;for(r=o;r--!==0;)if(t[r]!==n[r])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(i=Object.keys(t),o=i.length,o!==Object.keys(n).length)return!1;for(r=o;r--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[r]))return!1;for(r=o;r--!==0;){let l=i[r];if(!(l==="_owner"&&t.$$typeof||e(t[l],n[l])))return!1}return!0}return t!=t&&n!=n},deepFreeze:function e(t){return Object.freeze(t),Object.keys(t).forEach(n=>{typeof t[n]!="object"||t[n]===null||Object.isFrozen(t[n])||e(t[n])}),t},deepMerge:pn,diffValues:(e,t)=>{const n={},o=Object.keys(t),r=o.length;for(let i=0;i<r;i++){const l=o[i];e[l]!==t[l]&&(e[l]===void 0?n[l]=t[l]:n[l]=e[l])}return Object.keys(n).length===0?null:n},findEqualOrGreater:function(e,t,n=lr){let o=0,r=e.length-1;for(;o<=r;){let i=Math.floor((o+r)/2),l=n(e[i]);if(l===t)return i;l<t?o=i+1:r=i-1}return o},findEqualOrLesser:function(e,t,n=lr){let o=e.length-1,r=0;for(;o>=r;){let i=Math.floor((o+r)/2),l=n(e[i]);if(l===t)return i;l>t?o=i-1:r=i+1}return o},findNextStep:(e,t=!0,n=15,o=10,r=400)=>{const i=Math.max(e-o,0)+(t?1:-1);return Math.min(r,Math[t?"ceil":"floor"](i/n)*n+o)},getBuildEnv:()=>"browser2-build",getDPI:()=>{let e=1;return typeof window=="object"&&(e=window.devicePixelRatio||1),e},getFromPath:(e,t)=>{const n=t.split(".");let o=e;for(let r=0;r<n.length;r++){const i=n[r];if(!o)return null;let l=o[i];if(typeof l=="function"&&(l=l.bind(o)()),!l||!kn(l))return l;o=l}return o??null},getOS:zn,hasFocus:dr,isDefined:e=>e!=null,isEmpty:e=>e==null||e==="",isEqualArrays:Hr,isEqualBounds:(e,t)=>e===t||!(e&&!t||t&&!e)&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,isEqualObjectKeys:(e,t)=>{if(e===t)return!0;if(e&&!t||t&&!e)return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o=0;o<n.length;o++)if(e[n[o]]!==t[n[o]])return!1;return!0},isNode:Kr,isNullOrUndefined:cr,isNumeric:e=>{const t=1*e;return Number.isFinite(t)&&typeof t=="number"},isObject:kn,isPromiseLike:e=>!!e&&typeof e.then=="function",isRectInsideRect:(e,t)=>e.top>=t.top&&e.bottom<=t.bottom&&e.left>=t.left&&e.right<=t.right,isRectIntersect:ar,mergeContentful:(...e)=>{const t=e.length;if(t>0&&e[t-1]!==void 0&&!kn(e[t-1]))return e[t-1];let n=e[0]||{};for(let o=1;o<t;o++)n=pn(n,e[o]||{},{arrayMerge:(r,i)=>[...i]});return n},nextTick:e=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(()=>{e()}):(typeof setImmediate=="function"?setImmediate:setTimeout)(()=>{e()})},openFileDialog:(e="*.*")=>new Promise((t,n)=>{if(!ur)return void n("Unable to open dialog with no dom.");const o=document.createElement("input");o.type="file",o.accept=e;let r=null,i=!1;globalThis.addEventListener?.("focus",()=>{setTimeout(()=>{r||i||(i=!0,t(null))},1e3)},{once:!0,passive:!0}),o.onchange=()=>{if(r=o.files[0],r){if(i)return void console.warn("File open detected after faux cancel.",r);t(r)}},o.autofocus=!0,o.click()}),rafThrottle:e=>{let t,n=!1,o=function(){n=!1,e(t)};return function(r){t=r,t&&t.persist&&t.persist(),n||(n=!0,requestAnimationFrame(o))}},removeEmptyProperties:Nr,removeEqualValues:Ur,removeListenerAll:e=>{if(!e)return[];for(let t=0;t<e.length;t++)e[t]&&e[t]();return[]},requestTimeout:(e,t)=>{const n=sr(),o={id:requestAnimationFrame(function r(){sr()-n>=t?e.call(null):o.id=requestAnimationFrame(r)})};return o},roundAccurately:(e,t=0)=>{if(e==null||!isFinite(e))return null;const n=10**t;return Number(Math.round(e*n)/n)},setToPath:(e,t,n)=>{const o=t.split(".");let r=e;if(!r)throw new Error("Can not set path to a null path.");for(let i=0;r&&i<o.length-1;i++){const l=o[i];let s=r[l];if(s==null&&(s={},r[l]=s),!kn(s))throw new Error("Can not set path to a non object path.");r=s}if(typeof n!="number"&&typeof n!="boolean"&&typeof n!="string"&&!kn(n))throw new Error(`Can not set path to ${n} that is not a a supported primitive.`);return r[o[o.length-1]]=n,e},splitNumber:e=>{let t=Math.abs(e);if(isNaN(t)||!isFinite(e))return null;let n=0|t,o=t-n,r=0,i=0,l=1;if(o>5e-8)for(;i<8&&Math.abs(r/l-o)>5e-8;)i++,l*=10,r=Math.round(o*l);return{ip:Math.trunc(e),fp:r,ipLength:Math.ceil(Math.log10(n+1)),fpLength:i}},subtractRect:(e,t,n=!1)=>{if(!t)return[e];if(!ar(e,t))return[];const o=[];let r=e;const i=()=>{t.top>r.top&&t.top<r.bottom&&(o.push({...r,bottom:t.top}),r={...r,top:t.top})},l=()=>{t.bottom>r.top&&t.bottom<r.bottom&&(o.push({...r,top:t.bottom}),r={...r,bottom:t.bottom})},s=()=>{t.right>r.left&&t.right<r.right&&(o.push({...r,left:t.right}),r={...r,right:t.right})},u=()=>{t.left>r.left&&t.left<r.right&&(o.push({...r,right:t.left}),r={...r,left:t.left})};return n?(u(),s(),i(),l()):(i(),l(),s(),u()),o},textToKey:e=>e.replace(/[^a-zA-Z0-9]/g,"").toLowerCase(),throttle:function(e,t){let n=null;return(...o)=>{const r=Date.now();(!n||r-n>=t)&&(n=r,e(...o))}},toSafeJSON:function e(t){if(t===null||typeof t!="object")return t;if(typeof t.toJSON=="function")return t.toJSON();if(Array.isArray(t))return t.map(o=>e(o));if(typeof t.toString=="function"&&t.toString!==Object.prototype.toString)return t.toString();const n={};for(const o in t)t.hasOwnProperty(o)&&(n[o]=e(t[o]));return n},transpose:e=>{if(!e)return e;const t=e.length,n=e[0].length,o=[];for(let r=0;r<n;r++)o[r]=Array(t);for(let r=0;r<t;r++)for(let i=0;i<n;i++)o[i][r]=e[r][i];return o},uuidV4:Zn,validEnumValue:(e,t)=>{if(!Object.values(e).includes(t))throw new Error(`Invalid type: ${t??"null"}. Must be one of: ${Object.values(t).join(", ")}.`)},whenFocus:async(e,t=!1)=>new Promise(n=>{dr(e,t)?n(!0):e.addEventListener("focusin",()=>{n(!0)},{once:!0}),e.focus()})},Symbol.toStringTag,{value:"Module"}));Object.freeze(Object.defineProperty({__proto__:null,MESSAGE_ERROR_INVALID_ARG:e=>`Invalid argument: '${e}'.`},Symbol.toStringTag,{value:"Module"}));const qr=e=>{const t=new Uint8Array(e),n=t.byteLength;let o="";for(let r=0;r<n;r++)o+=String.fromCharCode(t[r]);if(typeof window<"u"&&typeof globalThis.btoa=="function")return globalThis.btoa(o);if(typeof Buffer<"u")return Buffer.from(o,"binary").toString("base64");throw new Error("Unsupported environment")},Lo=e=>new Promise((t,n)=>{if(e)if(typeof FileReader<"u"){const o=new FileReader;o.onload=()=>{t(o.result)},o.onerror=()=>{n(o.error)},o.readAsText(e)}else if(typeof Buffer<"u"){const o=r=>Buffer.from(r).toString("utf-8");e.arrayBuffer().then(r=>{t(o(r))}).catch(r=>{n(r)})}else n(new Error("Unsupported environment"));else t("")});Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIME_TYPE:"*/*",arrayBufferToBase64:qr,base64ToArrayBuffer:e=>{const t=typeof window<"u"&&typeof globalThis.atob=="function"?globalThis.atob(e):Buffer.from(e,"base64").toString("binary"),n=t.length,o=new Uint8Array(n);for(let r=0;r<n;r++)o[r]=t.charCodeAt(r);return o.buffer},blobToString:Lo},Symbol.toStringTag,{value:"Module"}));const Xr="data:image/png;base64,",Yr="Unable to resolve image.",hr=e=>new Promise(async(t,n)=>{let o=null;try{o=new Image,o.src=e,o.addEventListener("load",function(){t({width:o.naturalWidth,height:o.naturalHeight})},{once:!0}),o.addEventListener("error",function(){URL.revokeObjectURL(e),n("Invalid Image")},{once:!0}),await o.decode("sync")}catch{o?.src&&URL.revokeObjectURL(o.src)}o||n(Yr)}),vo="image/svg+xml";var fr,pr;Object.freeze(Object.defineProperty({__proto__:null,DATA_URL_PNG_PREFIX:Xr,getImageDataUrl:(e,t=1)=>new Promise(async(n,o)=>{let r=null;try{r=new Image,r.src=e,r.addEventListener("load",function(){try{const i=document.createElement("canvas");i.width=r.naturalWidth,i.height=r.naturalHeight,i.getContext("2d").drawImage(r,0,0);const l=i.toDataURL("image/png",t);n({elemImg:r,dataUrl:l})}catch(i){URL.revokeObjectURL(e),o(i)}},{once:!0}),r.addEventListener("error",function(){URL.revokeObjectURL(e),o("Invalid Image")},{once:!0}),await r.decode("sync")}catch{r?.src&&URL.revokeObjectURL(r.src)}r||o(Yr)}),loadImageDetails:async(e,t=null)=>{let n=null;const o=async()=>{try{const i=t??"image/*",l=URL.createObjectURL(new Blob([e],{type:i})),s=await hr(l);n={mimeType:i,naturalDimensions:s,asUrl:l}}catch{}},r=async()=>{try{const i=new TextDecoder().decode(e),l=URL.createObjectURL(new Blob([i],{type:vo})),s=await hr(l);n={mimeType:t??vo,naturalDimensions:s,asUrl:l,asSVGText:i}}catch{}};if(t===vo?await r():t.startsWith("image/")?await o():(await o(),n||await r()),!n)throw new Error("Failed to load image");return n}},Symbol.toStringTag,{value:"Module"})),(pr=fr||(fr={})).resolveTypedUpdates=(e,t,n,o)=>{if(e===null)return e;if(e===void 0)return o;let r=e;if(t?.shorthand){const u=t?.shorthand(e,n);u!==void 0&&(r=u)}if(r!==null&&t?.getSubType){const u=t.getSubType(r);u&&(t=u)}const i=t?.properties,l=t?.arrayType??!1;let s=r;if(t&&t.merge&&s&&o)s=t.merge(s,o,n);else if(!l&&i){const u=Object.keys({...r,...o});s=null;for(let d=0;d<u.length;d++){const w=u[d];let x,p=r[w];if(p!==void 0){const y=i[w];x=y?(0,pr.resolveTypedUpdates)(p,y,n,o?.[w]):p}else x=o?.[w];x!=null&&(s=s??{},s[w]=x)}}return s};const gr=`The Safari browser does not support advanced copy and paste.
|
|
8
8
|
Copy and paste will be limited to within the browser tab.
|
|
9
9
|
|
|
10
10
|
Please use Chrome or Edge if external copy and paste is required.`,bo=`You do not have permissions to access the clipboard.
|
|
11
11
|
All copy and paste operations will be limited to the browser tab.`,Gr={Safari:`The Safari browser does not support advanced copy and paste.
|
|
12
12
|
Copy and paste will be limited to within the browser tab.
|
|
13
13
|
|
|
14
|
-
Please use Chrome or Edge if external copy and paste is required.`,Perms:bo,PermsWrite:zn()===Dt.Safari?gr:bo,PermsRead:zn()===Dt.Safari?gr:bo},So=async()=>new Promise(e=>{document.hasFocus()?e():globalThis.addEventListener?.("focus",()=>{e()},{once:!0}),document.activeElement.focus?.()}),Eo=async(e,t,n)=>{if(zn()===Dt.Safari)return await n(new Error(Gr.Safari));try{const o=async l=>{try{return await l()}catch(s){if(s.message?.includes("Document is not focused"))return!1;throw s}},r=await globalThis?.navigator?.permissions?.query({name:e,allowWithoutGesture:!0,allowWithoutSanitization:!0});let i=!1;if(r.state==="prompt"&&(i=await o(t)),i||r.state!=="granted"||(i=await t()),!i)return await n(new Error(r.state))}catch(o){return o.message==="No valid data on clipboard"||o.name==="DataError"?void 0:await n(o)}},Zr=async e=>{try{return await e.read({unsanitized:[Lt]})}catch{}return await e.read()};if(!globalThis.ClipboardItem){const e=(n,o)=>new Blob([o],{type:n});class t{constructor(o,r){this._items={},this._types=Object.keys(o);const i={},l=Object.keys(o);for(let s=0;s<l.length;s++){const u=l[s];let d=o[u];i[u]=typeof d=="string"?e(u,d):d}this._items=i,this._presentationStyle=r?.presentationStyle??"unspecified"}get types(){return this._types}getType(o){return Promise.resolve(this._items[o])}supports(o){return!0}}globalThis.ClipboardItem=t}const Do=async(e,t=Lt)=>new Promise(async(n,o)=>{try{const r=await(async(i,l)=>{if(!i)return null;const s=await Zr(i);let u=!1;for(let d=0;!u&&s&&d<s.length;d++)if(u=s[d].types.includes(l),u)return await s[d].getType(l);return u?void 0:null})(e,t);if(r){const i=new FileReader;i.onload=()=>{n(i.result)},i.onerror=()=>{n("")},i.readAsText(r)}else n("")}catch(r){o(r)}}),wr=async(e,t=Lt)=>{const n=await Do(e,t);if(!n)return null;let o=null;try{o=new DOMParser().parseFromString(n,Lt)}catch{console.warn("Can't parse html from clipboard.")}return o},jn="clipboard-uuid",xn="web text/uuid",mr=e=>`<div style="display:none" ${jn}="${e}"/>`,Vi=(e,t)=>{let n=null;try{const o=new DOMParser().parseFromString(t,Lt);o.body.firstElementChild.setAttribute(jn,e),n=o.getElementsByTagName("body")[0].innerHTML}catch(o){console.warn("Can't embed uuid.",o)}return n},xr=(e,t)=>{if(!t||!e)return!1;try{const n=t.querySelectorAll(`[${jn}="${e}"]`);if(n&&n.length===1)return!0;if(t.querySelector("parsererror"))throw new Error("We are unable to parse node");return!1}catch{return!1}};let no=class{constructor(e){if(e?.nativeClipboard===void 0||e?.nativeClipboard===!0)try{this._nativeClipboard=globalThis?.navigator.clipboard}catch{e?.nativeClipboard===!0&&console.warn("NativeClipboard option set to true but no native clipboard available.")}else this._nativeClipboard=e?.nativeClipboard===!1?null:e?.nativeClipboard;this._disableCheckOnFocus=e?.disableCheckOnFocus??!1,this._init()}async _checkForChanges(){this._nativeClipboard&&this._state&&!this._disableCheckOnFocus&&await Eo("clipboard-read",async()=>{await So();const e=await Do(this._nativeClipboard,xn);if(!this._state||e&&e===this._state.uuid)return!0;const t=await wr(this._nativeClipboard,Lt);return!this._state||(xr(this._state.uuid,t)||this.clear(),!0)},async e=>{e?.message==="denied"||e.message?.includes("Document is not focused")||zn()===Dt.Safari||console.warn("Unable to detect clipboard changes: ",e)})}_init(){const e=this;this._listeners=new Map,this._listenersCapture=new Map,this._state=null,this._nativeClipboard&&(this._onFocus=()=>{e._checkForChanges()},this._onBlur=()=>{globalThis.addEventListener?.("focus",e._onFocus,{once:!0})},globalThis.addEventListener?.("blur",this._onBlur),this._nativeClipboard.addEventListener("clipboardchange",t=>{e._checkForChanges()}))}async read(){if(!this._nativeClipboard)return this._state?.items??null;const e=this;return await Eo("clipboard-read",async()=>{if(await So(),this._state?.uuid){const t=await Do(this._nativeClipboard,xn);if(t&&t===e._state.uuid)return!0;const n=await wr(this._nativeClipboard,Lt);if(xr(e._state?.uuid,n))return!0}return e._state={items:await Zr(this._nativeClipboard),uuid:null,ref:null},this.dispatchEvent(new Event("clipboardread")),!0},async t=>{this.dispatchEvent(new Event("clipboarderrorread"))}),this._state?.items??[]}async write(e){return this._write({uuid:Zn(),items:e,ref:null})}async _write(e){if(!this._nativeClipboard)return this._state=e,this.dispatchEvent(new Event("clipboardwrite")),this.dispatchEvent(new Event("clipboardchange")),null;const t=this,n=[],o=e.uuid;let r=e.items??[];const i=()=>{t._state={uuid:o,ref:e.ref,items:n},t.dispatchEvent(new Event("clipboardwrite")),t.dispatchEvent(new Event("clipboardchange"))};await Eo("clipboard-write",async()=>{await So(),o&&r.length===0&&(r.push(new ClipboardItem({[xn]:new Blob([o],{type:xn})})),r.push(new ClipboardItem({[Lt]:new Blob([mr(o)],{type:Lt})})));for(let l=0;l<Math.min(1,r.length);l++){const s=r[l];let u=s.types.indexOf(Lt),d=null;if(u!==-1){const p=await s.getType(Lt);d=await Lo(p),d&&(d=Vi(o,d))}if(!d&&s.types.includes(rn)){const p=await s.getType(rn);if(p){let y=null;typeof p=="string"?(console.warn("text as string",p),y=p):y=await Lo(p),y&&(d=`<div ${jn}="${o}">${y}</div>`)}}if(!d&&s.types.includes(xo)){const p=await s.getType(xo),y=
|
|
15
|
-
* @license @sheetxl/utils-react - Utils React - Utilities for React capabilities needed for all SheetXL components. - v0.
|
|
14
|
+
Please use Chrome or Edge if external copy and paste is required.`,Perms:bo,PermsWrite:zn()===Dt.Safari?gr:bo,PermsRead:zn()===Dt.Safari?gr:bo},So=async()=>new Promise(e=>{document.hasFocus()?e():globalThis.addEventListener?.("focus",()=>{e()},{once:!0}),document.activeElement.focus?.()}),Eo=async(e,t,n)=>{if(zn()===Dt.Safari)return await n(new Error(Gr.Safari));try{const o=async l=>{try{return await l()}catch(s){if(s.message?.includes("Document is not focused"))return!1;throw s}},r=await globalThis?.navigator?.permissions?.query({name:e,allowWithoutGesture:!0,allowWithoutSanitization:!0});let i=!1;if(r.state==="prompt"&&(i=await o(t)),i||r.state!=="granted"||(i=await t()),!i)return await n(new Error(r.state))}catch(o){return o.message==="No valid data on clipboard"||o.name==="DataError"?void 0:await n(o)}},Zr=async e=>{try{return await e.read({unsanitized:[Lt]})}catch{}return await e.read()};if(!globalThis.ClipboardItem){const e=(n,o)=>new Blob([o],{type:n});class t{constructor(o,r){this._items={},this._types=Object.keys(o);const i={},l=Object.keys(o);for(let s=0;s<l.length;s++){const u=l[s];let d=o[u];i[u]=typeof d=="string"?e(u,d):d}this._items=i,this._presentationStyle=r?.presentationStyle??"unspecified"}get types(){return this._types}getType(o){return Promise.resolve(this._items[o])}supports(o){return!0}}globalThis.ClipboardItem=t}const Do=async(e,t=Lt)=>new Promise(async(n,o)=>{try{const r=await(async(i,l)=>{if(!i)return null;const s=await Zr(i);let u=!1;for(let d=0;!u&&s&&d<s.length;d++)if(u=s[d].types.includes(l),u)return await s[d].getType(l);return u?void 0:null})(e,t);if(r){const i=new FileReader;i.onload=()=>{n(i.result)},i.onerror=()=>{n("")},i.readAsText(r)}else n("")}catch(r){o(r)}}),wr=async(e,t=Lt)=>{const n=await Do(e,t);if(!n)return null;let o=null;try{o=new DOMParser().parseFromString(n,Lt)}catch{console.warn("Can't parse html from clipboard.")}return o},jn="clipboard-uuid",xn="web text/uuid",mr=e=>`<div style="display:none" ${jn}="${e}"/>`,Vi=(e,t)=>{let n=null;try{const o=new DOMParser().parseFromString(t,Lt);o.body.firstElementChild.setAttribute(jn,e),n=o.getElementsByTagName("body")[0].innerHTML}catch(o){console.warn("Can't embed uuid.",o)}return n},xr=(e,t)=>{if(!t||!e)return!1;try{const n=t.querySelectorAll(`[${jn}="${e}"]`);if(n&&n.length===1)return!0;if(t.querySelector("parsererror"))throw new Error("We are unable to parse node");return!1}catch{return!1}};let no=class{constructor(e){if(e?.nativeClipboard===void 0||e?.nativeClipboard===!0)try{this._nativeClipboard=globalThis?.navigator.clipboard}catch{e?.nativeClipboard===!0&&console.warn("NativeClipboard option set to true but no native clipboard available.")}else this._nativeClipboard=e?.nativeClipboard===!1?null:e?.nativeClipboard;this._disableCheckOnFocus=e?.disableCheckOnFocus??!1,this._init()}async _checkForChanges(){this._nativeClipboard&&this._state&&!this._disableCheckOnFocus&&await Eo("clipboard-read",async()=>{await So();const e=await Do(this._nativeClipboard,xn);if(!this._state||e&&e===this._state.uuid)return!0;const t=await wr(this._nativeClipboard,Lt);return!this._state||(xr(this._state.uuid,t)||this.clear(),!0)},async e=>{e?.message==="denied"||e.message?.includes("Document is not focused")||zn()===Dt.Safari||console.warn("Unable to detect clipboard changes: ",e)})}_init(){const e=this;this._listeners=new Map,this._listenersCapture=new Map,this._state=null,this._nativeClipboard&&(this._onFocus=()=>{e._checkForChanges()},this._onBlur=()=>{globalThis.addEventListener?.("focus",e._onFocus,{once:!0})},globalThis.addEventListener?.("blur",this._onBlur),this._nativeClipboard.addEventListener("clipboardchange",t=>{e._checkForChanges()}))}async read(){if(!this._nativeClipboard)return this._state?.items??null;const e=this;return await Eo("clipboard-read",async()=>{if(await So(),this._state?.uuid){const t=await Do(this._nativeClipboard,xn);if(t&&t===e._state.uuid)return!0;const n=await wr(this._nativeClipboard,Lt);if(xr(e._state?.uuid,n))return!0}return e._state={items:await Zr(this._nativeClipboard),uuid:null,ref:null},this.dispatchEvent(new Event("clipboardread")),!0},async t=>{this.dispatchEvent(new Event("clipboarderrorread"))}),this._state?.items??[]}async write(e){return this._write({uuid:Zn(),items:e,ref:null})}async _write(e){if(!this._nativeClipboard)return this._state=e,this.dispatchEvent(new Event("clipboardwrite")),this.dispatchEvent(new Event("clipboardchange")),null;const t=this,n=[],o=e.uuid;let r=e.items??[];const i=()=>{t._state={uuid:o,ref:e.ref,items:n},t.dispatchEvent(new Event("clipboardwrite")),t.dispatchEvent(new Event("clipboardchange"))};await Eo("clipboard-write",async()=>{await So(),o&&r.length===0&&(r.push(new ClipboardItem({[xn]:new Blob([o],{type:xn})})),r.push(new ClipboardItem({[Lt]:new Blob([mr(o)],{type:Lt})})));for(let l=0;l<Math.min(1,r.length);l++){const s=r[l];let u=s.types.indexOf(Lt),d=null;if(u!==-1){const p=await s.getType(Lt);d=await Lo(p),d&&(d=Vi(o,d))}if(!d&&s.types.includes(rn)){const p=await s.getType(rn);if(p){let y=null;typeof p=="string"?(console.warn("text as string",p),y=p):y=await Lo(p),y&&(d=`<div ${jn}="${o}">${y}</div>`)}}if(!d&&s.types.includes(xo)){const p=await s.getType(xo),y=qr(await p.arrayBuffer());d=`<div ${jn}="${o}"><img src="${Xr+y}"/></div>`}!d&&o&&(d=mr(o));const w=new Blob([d??""],{type:Lt}),x={};for(let p=0;p<s.types.length;p++){const y=s.types[p];x[y]=p===u?w:s.getType(y)}d&&u===-1&&(x[Lt]=w),o&&(x[xn]=new Blob([o],{type:xn})),n.push(new ClipboardItem(x))}try{n&&n.length!==0?await this._nativeClipboard.write(n):await(async l=>{l&&await l.writeText("")})(this._nativeClipboard)}catch(l){l.message?.includes("Document is not focused")||console.warn("Unable to write to native clipboard: ",l)}return i(),!0},async l=>{this.dispatchEvent(new Event("clipboarderrorwrite")),i()})}async writeReference(e){if(!e)return void this.clear();let t=null;const n={};try{const r=await e.toText?.()??null;r&&(n[rn]=new Blob([r??""],{type:rn}))}catch(r){t=r}try{const r=await e.toHtml?.()??null;r&&(n[Lt]=new Blob([r],{type:Lt}))}catch(r){t=r,console.warn("export to html",r)}try{const r=await e.toImage?.()??null;r&&(n[xo]=r)}catch(r){t=r,console.warn("export to png",r)}const o=this._write({uuid:Zn(),ref:e,items:Object.keys(n).length>0?[new ClipboardItem(n)]:null});if(t)throw t;return o}clear(e=!1){this._state&&(this._state=null,e&&this._write({uuid:null,ref:null,items:null}),this.dispatchEvent(new Event("clipboardwrite")),this.dispatchEvent(new Event("clipboardchange")))}async readReference(){return await this.read(),this._state?.ref??null}readText(){return new Promise(async(e,t)=>{const n=await this.read();let o=null;for(let i=0;!o&&n&&i<n.length;i++)n[i].types.includes(rn)&&(o=await n[i].getType(rn));if(!o)return void e("");const r=new FileReader;r.onload=()=>{e(r.result)},r.readAsText(o),r.onerror=i=>{t(i)}})}async writeText(e){const t=[new ClipboardItem({[rn]:new Blob([e],{type:rn})})];return this._write({uuid:Zn(),items:t,ref:null})}addEventListener(e,t,n={}){const o=n?.capture?this._listenersCapture:this._listeners;let r=o.get(e);r||(r=new Map,o.set(e,r)),r.set(t,typeof n=="boolean"?{}:n)}dispatchEvent(e){if(!e)return;const t=n=>{const o=n.get(e.type);o&&o.forEach((r,i)=>{try{typeof i=="function"?i(e):i.handleEvent&&i.handleEvent(e),r.once&&o.delete(i)}catch(l){console.warn(l)}})};return t(this._listenersCapture),t(this._listeners),!0}removeEventListener(e,t,n){const o=n?.capture?this._listenersCapture:this._listeners,r=o.get(e);r&&(r.delete(t),r.size===0&&o.delete(e))}close(){globalThis.removeEventListener?.("focus",this._onFocus),globalThis.removeEventListener?.("blur",this._onBlur)}};var _o;(_o=no||(no={})).ErrorMessages=Gr,_o.Global=new _o,function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-scrollbar_eblx4_6 ::-webkit-scrollbar-button{background:transparent}._fullscreen-portal-root_1mjsr_4{pointer-events:none;position:absolute;inset:0;width:100%;height:100%;z-index:1200}._fullscreen-portal-root_1mjsr_4>*{pointer-events:auto}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();/**
|
|
15
|
+
* @license @sheetxl/utils-react - Utils React - Utilities for React capabilities needed for all SheetXL components. - v0.2.5
|
|
16
16
|
*
|
|
17
17
|
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
18
18
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
19
|
-
*/const On={Left:"left",Right:"right",Center:"center"},bt="shift",dn="alt",kt="ctrl",Wi=9,Hi=13,Ni=27,Ui=37,qi=38,Ki=39,Xi=40,Yi=113,yr=3,cn={Horizontal:"horizontal",Vertical:"vertical"};function Jr(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=Jr(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function yn(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Jr(e))&&(o&&(o+=" "),o+=t);return o}var Gi=function(){},Qr=typeof window<"u",Zi=Qr?c.useLayoutEffect:c.useEffect,vr={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const gn=Qr&&window.ResizeObserver!==void 0?function(){var e=c.useState(null),t=e[0],n=e[1],o=c.useState(vr),r=o[0],i=o[1],l=c.useMemo(function(){return new window.ResizeObserver(function(s){if(s[0]){var u=s[0].contentRect,d=u.x,w=u.y,x=u.width,p=u.height,y=u.top,_=u.left,I=u.bottom,R=u.right;i({x:d,y:w,width:x,height:p,top:y,left:_,bottom:I,right:R})}})},[]);return Zi(function(){if(t)return l.observe(t),function(){l.disconnect()}},[t]),[n,r]}:function(){return[Gi,vr]},k=(e,t)=>{const n=c.useCallback((...i)=>e?.(...i),t),o=c.useRef(null);o.current=n;const r=c.useCallback((...i)=>o.current?.(...i),[]);if(o.current)return r},Ji=e=>{const{style:t,orientation:n=cn.Vertical,...o}=e,r=n===cn.Vertical;return T.jsx("div",{style:{paddingBottom:"0px",paddingRight:"0px",paddingLeft:r?"0px":"3px",paddingTop:r?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...t},...o,children:T.jsx("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${r?"vertical":"horizontal"} single-button start`,children:T.jsx("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:T.jsx("path",{d:r?"m 3.7274761,0.68060577 1.11969,1.93863003 1.12075,1.93912 c 0.0895,0.155 0.12152,0.33658 0.0904,0.51283 -0.0311,0.17625 -0.12336,0.33591 -0.26054,0.45091 -0.13715,0.11495 -0.31044,0.17793 -0.4894,0.17781 H 0.83095614 c -0.20186,0 -0.39542,-0.0802 -0.53814,-0.2229 -0.14272,-0.14272 -0.22291,-0.33629 -0.22291,-0.53814 -3e-4,-0.13308 0.0347,-0.26385 0.10147,-0.379 l 1.11872996,-1.94066 1.11921,-1.93864003 c 0.13594,-0.23541 0.38717,-0.38047 0.65905,-0.38047 0.27188,0 0.52311,0.14506 0.65905,0.38047 z":"m 0.75051,2.3424298 1.93863,-1.11969 1.93912,-1.12075 c 0.155,-0.0895 0.33658,-0.12152 0.51283,-0.0904 0.17625,0.0311 0.33591,0.12336 0.45091,0.26054 0.11495,0.13715 0.17793,0.31044 0.17781,0.4894 v 4.47742 c 0,0.20186 -0.0802,0.39542 -0.2229,0.53814 -0.14272,0.14272 -0.33629,0.22291 -0.53814,0.22291 -0.13308,3e-4 -0.26385,-0.0347 -0.379,-0.10147 L 2.68911,4.7797998 0.75047,3.6605898 C 0.51506,3.5246498 0.37,3.2734198 0.37,3.0015398 c 0,-0.27188 0.14506,-0.52311 0.38047,-0.65905 z"})})})})},Qi=e=>{const{style:t,orientation:n=cn.Vertical,...o}=e,r=n===cn.Vertical;return T.jsx("div",{style:{paddingLeft:"0px",paddingTop:"0px",paddingRight:r?"0px":"3px",paddingBottom:r?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...t},...o,children:T.jsx("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${r?"vertical":"horizontal"} single-button end`,children:T.jsx("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:T.jsx("path",{d:r?"M 2.412334,5.319396 1.292644,3.3807659 0.17189405,1.4416459 c -0.0895,-0.155 -0.12152,-0.33658 -0.0904,-0.51282998 0.0311,-0.17625 0.12336,-0.33591 0.26054,-0.45091 0.13715,-0.11495 0.31044,-0.17793 0.4894,-0.17781 H 5.308854 c 0.20186,0 0.39542,0.0802 0.53814,0.2229 0.14272,0.14272 0.22291,0.33629 0.22291,0.53813998 3e-4,0.13308 -0.0347,0.26385 -0.10147,0.379 l -1.11873,1.94066 -1.11921,1.9386401 c -0.13594,0.23541 -0.38717,0.38047 -0.65905,0.38047 -0.27188,0 -0.52311,-0.14506 -0.65905,-0.38047 z":"m 5.3893002,3.6575719 -1.9386301,1.11969 -1.93912,1.12075 c -0.155,0.0895 -0.33658,0.12152 -0.51282997,0.0904 -0.17625,-0.0311 -0.33591,-0.12336 -0.45091,-0.26054 -0.11495,-0.13715 -0.17793,-0.31044 -0.17781,-0.4894 V 0.76105195 c 0,-0.20186 0.0802,-0.39542 0.2229,-0.53814 C 0.73562013,0.08019195 0.92919013,1.9467784e-6 1.1310401,1.9467784e-6 1.2641201,-2.9805322e-4 1.3948901,0.03470195 1.5100401,0.10147195 l 1.94066,1.11872995 1.9386401,1.11921 c 0.23541,0.13594 0.38047,0.38717 0.38047,0.65905 0,0.27188 -0.14506,0.52311 -0.38047,0.65905 z"})})})})},zo=(e,t,n,o,r=0)=>{for(let i=0;i<n.length;i++){const l=n[i].getBoundingClientRect();let s=l.left-t,u=s+l.width;if(o){if(s<e&&u>=e)return s}else if(Math.ceil(u)>Math.ceil(e)+2)return u}return r};Object.freeze(Object.defineProperty({__proto__:null,getScrollTo:zo},Symbol.toStringTag,{value:"Module"}));const Uo=c.memo(c.forwardRef((e,t)=>{const{offset:n=0,totalSize:o=0,viewportSize:r=0,style:i,className:l,orientation:s=cn.Vertical,onScrollOffset:u,onScroll:d,showCustomScrollButtons:w=!1,scrollButtonIncrement:x=200,scrollButtonInitialRepeatDelay:p=260,scrollButtonAdditionalRepeatDelay:y=120,createScrollStartButton:_=Ji,createScrollEndButton:I=Qi,...R}=e,ce=k(d,[d]),P=c.useRef(null),[C,{width:D,height:ie}]=gn(),[$,{width:ne,height:ve}]=gn(),q=s===cn.Vertical,N=q?"top":"left",Y=q?"scrollTop":"scrollLeft",O=q?ie:D,h=q?ve:ne,[M,Q]=c.useState(null);c.useEffect(()=>{M!==null&&P.current&&P.current.scrollTo({behavior:"smooth",[N]:M})},[M,q]);const H=c.useCallback((E,ue=!1)=>{if(!P.current)return 0;const X=P.current.querySelector(".scrollbar-viewport"),fe=X.getBoundingClientRect(),ee=X.children,Me=ue?0:zo(E,fe[N],ee,!0,Math.max(0,E-x));return Q(Me),Math.max(0,Me)},[]),A=c.useCallback((E,ue=!1)=>{if(!P.current)return 0;const X=P.current.querySelector(".scrollbar-viewport"),fe=X.getBoundingClientRect(),ee=X.children,Me=Math.ceil(h-O),it=ue?Me:zo(E,fe[N],ee,!1,Math.max(0,E+x));return Q(it),Math.min(Me,it)},[h,O]),K=c.useRef(null),U=c.useCallback(E=>{K.current=n;const ue=E.target[Y];u(ue,r,o),ce?.(E)},[u,r,o,n]);c.useEffect(()=>{const E=K.current;K.current=null,n!==E&&(P.current[Y]=n)},[n,Y]);const me=c.useRef(null),G=c.useRef(null),Ve=c.useCallback(()=>{me.current&&(clearTimeout(me.current),me.current=null,G.current=null)},[]),He=c.useCallback((E,ue,X,fe=p)=>{G.current=E,me.current=setTimeout(()=>{const ee=X?H(G.current||E):A(G.current||E);ee!==G.current?He(ee,!1,X,y):Ve()},ue?0:fe)},[H,A,Ve]);c.useEffect(()=>()=>Ve(),[Ve]);const Fe=n,ct=c.useMemo(()=>{if(!w)return null;const E={orientation:s,disabled:Math.floor(Fe)<=0||Math.floor(h-O)===0,onMouseUp:Ve,onMouseLeave:Ve,onMouseDown:()=>He(Fe,!0,!0)};return _?.(E)},[w,s,Fe,M,h,O]),Se=c.useMemo(()=>{if(!w)return null;const E={orientation:s,disabled:Math.floor(h-O)<=Math.ceil(Fe),onMouseUp:Ve,onMouseLeave:Ve,onMouseDown:()=>He(Fe,!0,!1)};return I?.(E)},[w,s,Fe,M,h,O]);return T.jsxs("div",{ref:t,style:{display:"flex",flex:"1",flexDirection:q?"column":"row",padding:"0",...i},className:yn("_sheetxl-scrollbar_18qzf_11",l),...R,children:[ct,T.jsx("div",{className:"pseudo-scrollbar",style:{flex:"1 1 100%",display:"flex",boxSizing:"content-box",flexDirection:q?"column":"row",justifyContent:"center",alignItems:"center"},ref:C,children:T.jsx("div",{tabIndex:-1,style:{flex:"1 1 100%",overflowY:q?"scroll":"hidden",overflowX:q?"hidden":"scroll",position:"relative",willChange:"transform"},onScroll:U,ref:P,children:T.jsx("div",{ref:$,style:{position:"absolute",height:q?o-r+(ie??0):1,width:q?1:o-r+(D??0)},className:"scrollbar-viewport"})})}),Se]})}));Uo.displayName="Scrollbar";let br=Date.now,sn={},el=1;const Tn=e=>{let t=sn[e]!==null;return t&&(sn[e]=null),t},Sr=(e,t,n,o=0,r)=>{let i=br(),l=i,s=0,u=0,d=el++;if(d%20==0){const x={};for(let p in sn)x[p]=!0;sn=x}const w=function(x){const p=x!==!0,y=br();if(!sn[d]||t&&!t(d))return sn[d]=null,void n(60-u/((y-i)/1e3),d,!1);if(p){const I=Math.round((y-l)/16.666666666666668)-1;for(let R=0;R<Math.min(I,4);R++)w(!0),u++}o&&(s=(y-i)/o,s>1&&(s=1));const _=r?r(s):s;e(_,y,p)!==!1&&s!==1||!p?p&&(l=y,requestAnimationFrame(w)):(sn[d]=null,n(60-u/((y-i)/1e3),d,s===1||o===void 0))};return sn[d]=!0,requestAnimationFrame(w),d};var tl=function(){},nl=function(e){return Math.pow(e-1,3)+1},ol=function(e){return(e/=.5)<1?.5*Math.pow(e,3):.5*(Math.pow(e-2,3)+2)},ei=function(e,t){for(var n in this.__callback=e,this.options={scrollingX:!0,scrollingY:!0,animating:!0,animationDuration:250,bouncing:!0,locking:!0,paging:!1,snapping:!1,zooming:!1,minZoom:.5,maxZoom:3,speedMultiplier:1,scrollingComplete:tl,penetrationDeceleration:.03,penetrationAcceleration:.08},t)this.options[n]=t[n]};ei.prototype={__isSingleTouch:!1,__isTracking:!1,__didDecelerationComplete:!1,__isGesturing:!1,__isDragging:!1,__isDecelerating:!1,__isAnimating:!1,__clientLeft:0,__clientTop:0,__clientWidth:0,__clientHeight:0,__contentWidth:0,__contentHeight:0,__snapWidth:100,__snapHeight:100,__zoomLevel:1,__scrollLeft:0,__scrollTop:0,__maxScrollLeft:0,__maxScrollTop:0,__scheduledLeft:0,__scheduledTop:0,__scheduledZoom:0,__lastTouchLeft:null,__lastTouchTop:null,__lastTouchMove:null,__positions:null,__minDecelerationScrollLeft:null,__minDecelerationScrollTop:null,__maxDecelerationScrollLeft:null,__maxDecelerationScrollTop:null,__decelerationVelocityX:null,__decelerationVelocityY:null,setDimensions:function(e,t,n,o){e!==null&&(this.__clientWidth=e),t!==null&&(this.__clientHeight=t),n!==null&&(this.__contentWidth=n),o!==null&&(this.__contentHeight=o),this.__computeScrollMax(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0)},setPosition:function(e,t){this.__clientLeft=e||0,this.__clientTop=t||0},setSnapSize:function(e,t){this.__snapWidth=e,this.__snapHeight=t},getValues:function(){return{left:this.__scrollLeft,top:this.__scrollTop,right:this.__scrollLeft+this.__clientWidth/this.__zoomLevel,bottom:this.__scrollTop+this.__clientHeight/this.__zoomLevel,zoom:this.__zoomLevel}},getPoint:function(e,t){var n=this.getValues();return{left:e/n.zoom,top:t/n.zoom}},getScrollMax:function(){return{left:this.__maxScrollLeft,top:this.__maxScrollTop}},zoomTo:function(e,t,n,o,r){if(!this.options.zooming)throw new Error("Zooming is not enabled!");r&&(this.__zoomComplete=r),this.__isDecelerating&&(Tn(this.__isDecelerating),this.__isDecelerating=!1);var i=this.__zoomLevel;n===void 0&&(n=this.__clientWidth/2),o===void 0&&(o=this.__clientHeight/2),e=Math.max(Math.min(e,this.options.maxZoom),this.options.minZoom),this.__computeScrollMax(e);var l=e/i,s=l*(this.__scrollLeft+n)-n,u=l*(this.__scrollTop+o)-o;s>this.__maxScrollLeft?s=this.__maxScrollLeft:s<0&&(s=0),u>this.__maxScrollTop?u=this.__maxScrollTop:u<0&&(u=0),this.__publish(s,u,e,t)},zoomBy:function(e,t,n,o,r){this.zoomTo(this.__zoomLevel*e,t,n,o,r)},scrollTo:function(e,t,n,o){if(this.__isDecelerating&&(Tn(this.__isDecelerating),this.__isDecelerating=!1),o!==void 0&&o!==this.__zoomLevel){if(!this.options.zooming)throw new Error("Zooming is not enabled!");e*=o,t*=o,this.__computeScrollMax(o)}else o=this.__zoomLevel;this.options.scrollingX?this.options.paging?e=Math.round(e/this.__clientWidth)*this.__clientWidth:this.options.snapping&&(e=Math.round(e/this.__snapWidth)*this.__snapWidth):e=this.__scrollLeft,this.options.scrollingY?this.options.paging?t=Math.round(t/this.__clientHeight)*this.__clientHeight:this.options.snapping&&(t=Math.round(t/this.__snapHeight)*this.__snapHeight):t=this.__scrollTop,e=Math.max(Math.min(this.__maxScrollLeft,e),0),t=Math.max(Math.min(this.__maxScrollTop,t),0),e===this.__scrollLeft&&t===this.__scrollTop&&(n=!1),this.__publish(e,t,o,n)},scrollBy:function(e,t,n){var o=this.__isAnimating?this.__scheduledLeft:this.__scrollLeft,r=this.__isAnimating?this.__scheduledTop:this.__scrollTop;this.scrollTo(o+(e||0),r+(t||0),n)},doMouseZoom:function(e,t,n,o){var r=e>0?.97:1.03;return this.zoomTo(this.__zoomLevel*r,!1,n-this.__clientLeft,o-this.__clientTop)},doTouchStart:function(e,t){if(e.length===void 0)throw new Error("Invalid touch list: "+e);if(t instanceof Date&&(t=t.valueOf()),typeof t!="number")throw new Error("Invalid timestamp value: "+t);var n,o;this.__interruptedAnimation=!0,this.__isDecelerating&&(Tn(this.__isDecelerating),this.__isDecelerating=!1,this.__interruptedAnimation=!0),this.__isAnimating&&(Tn(this.__isAnimating),this.__isAnimating=!1,this.__interruptedAnimation=!0);var r=e.length===1;r?(n=e[0].pageX,o=e[0].pageY):(n=Math.abs(e[0].pageX+e[1].pageX)/2,o=Math.abs(e[0].pageY+e[1].pageY)/2),this.__initialTouchLeft=n,this.__initialTouchTop=o,this.__zoomLevelStart=this.__zoomLevel,this.__lastTouchLeft=n,this.__lastTouchTop=o,this.__lastTouchMove=t,this.__lastScale=1,this.__enableScrollX=!r&&this.options.scrollingX,this.__enableScrollY=!r&&this.options.scrollingY,this.__isTracking=!0,this.__didDecelerationComplete=!1,this.__isDragging=!r,this.__isSingleTouch=r,this.__positions=[]},doTouchMove:function(e,t,n){if(e.length===void 0)throw new Error("Invalid touch list: "+e);if(t instanceof Date&&(t=t.valueOf()),typeof t!="number")throw new Error("Invalid timestamp value: "+t);if(this.__isTracking){var o,r;e.length===2?(o=Math.abs(e[0].pageX+e[1].pageX)/2,r=Math.abs(e[0].pageY+e[1].pageY)/2):(o=e[0].pageX,r=e[0].pageY);var i=this.__positions;if(this.__isDragging){var l=o-this.__lastTouchLeft,s=r-this.__lastTouchTop,u=this.__scrollLeft,d=this.__scrollTop,w=this.__zoomLevel;if(n!==void 0&&this.options.zooming){var x=w;if(w=w/this.__lastScale*n,x!==(w=Math.max(Math.min(w,this.options.maxZoom),this.options.minZoom))){var p=o-this.__clientLeft,y=r-this.__clientTop;u=(p+u)*w/x-p,d=(y+d)*w/x-y,this.__computeScrollMax(w)}}if(this.__enableScrollX){u-=l*this.options.speedMultiplier;var _=this.__maxScrollLeft;(u>_||u<0)&&(this.options.bouncing?u+=l/2*this.options.speedMultiplier:u=u>_?_:0)}if(this.__enableScrollY){d-=s*this.options.speedMultiplier;var I=this.__maxScrollTop;(d>I||d<0)&&(this.options.bouncing?d+=s/2*this.options.speedMultiplier:d=d>I?I:0)}i.length>60&&i.splice(0,30),i.push(u,d,t),this.__publish(u,d,w)}else{var R=this.options.locking?3:0,ce=Math.abs(o-this.__initialTouchLeft),P=Math.abs(r-this.__initialTouchTop);this.__enableScrollX=this.options.scrollingX&&ce>=R,this.__enableScrollY=this.options.scrollingY&&P>=R,i.push(this.__scrollLeft,this.__scrollTop,t),this.__isDragging=(this.__enableScrollX||this.__enableScrollY)&&(ce>=5||P>=5),this.__isDragging&&(this.__interruptedAnimation=!1)}this.__lastTouchLeft=o,this.__lastTouchTop=r,this.__lastTouchMove=t,this.__lastScale=n}},doTouchEnd:function(e){if(e instanceof Date&&(e=e.valueOf()),typeof e!="number")throw new Error("Invalid timestamp value: "+e);if(this.__isTracking){if(this.__isTracking=!1,this.__isDragging)if(this.__isDragging=!1,this.__isSingleTouch&&this.options.animating&&e-this.__lastTouchMove<=100){for(var t=this.__positions,n=t.length-1,o=n,r=n;r>0&&t[r]>this.__lastTouchMove-100;r-=3)o=r;if(o!==n){var i=t[n]-t[o],l=this.__scrollLeft-t[o-2],s=this.__scrollTop-t[o-1];this.__decelerationVelocityX=l/i*(1e3/60),this.__decelerationVelocityY=s/i*(1e3/60);var u=this.options.paging||this.options.snapping?4:1;(Math.abs(this.__decelerationVelocityX)>u||Math.abs(this.__decelerationVelocityY)>u)&&this.__startDeceleration(e)}else this.options.scrollingComplete()}else e-this.__lastTouchMove>100&&this.options.scrollingComplete();this.__isDecelerating||((this.__interruptedAnimation||this.__isDragging)&&this.options.scrollingComplete(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0,this.__zoomLevel)),this.__positions.length=0}},__publish:function(e,t,n,o){var r=this.__isAnimating;if(r&&(Tn(r),this.__isAnimating=!1),o&&this.options.animating){this.__scheduledLeft=e,this.__scheduledTop=t,this.__scheduledZoom=n;var i=this.__scrollLeft,l=this.__scrollTop,s=this.__zoomLevel,u=e-i,d=t-l,w=n-s,x=function(_,I,R){R&&(this.__scrollLeft=i+u*_,this.__scrollTop=l+d*_,this.__zoomLevel=s+w*_,this.__callback&&this.__callback(this.__scrollLeft,this.__scrollTop,this.__zoomLevel))}.bind(this),p=function(_){return this.__isAnimating===_}.bind(this),y=function(_,I,R){I===this.__isAnimating&&(this.__isAnimating=!1),(this.__didDecelerationComplete||R)&&this.options.scrollingComplete(),this.options.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))}.bind(this);this.__isAnimating=Sr(x,p,y,this.options.animationDuration,r?nl:ol)}else this.__scheduledLeft=this.__scrollLeft=e,this.__scheduledTop=this.__scrollTop=t,this.__scheduledZoom=this.__zoomLevel=n,this.__callback&&this.__callback(e,t,n),this.options.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))},__computeScrollMax:function(e){e===void 0&&(e=this.__zoomLevel),this.__maxScrollLeft=Math.max(this.__contentWidth*e-this.__clientWidth,0),this.__maxScrollTop=Math.max(this.__contentHeight*e-this.__clientHeight,0)},__startDeceleration:function(e){if(this.options.paging){var t=Math.max(Math.min(this.__scrollLeft,this.__maxScrollLeft),0),n=Math.max(Math.min(this.__scrollTop,this.__maxScrollTop),0),o=this.__clientWidth,r=this.__clientHeight;this.__minDecelerationScrollLeft=Math.floor(t/o)*o,this.__minDecelerationScrollTop=Math.floor(n/r)*r,this.__maxDecelerationScrollLeft=Math.ceil(t/o)*o,this.__maxDecelerationScrollTop=Math.ceil(n/r)*r}else this.__minDecelerationScrollLeft=0,this.__minDecelerationScrollTop=0,this.__maxDecelerationScrollLeft=this.__maxScrollLeft,this.__maxDecelerationScrollTop=this.__maxScrollTop;var i=function(d,w,x){this.__stepThroughDeceleration(x)}.bind(this),l=this.options.snapping?4:.1,s=function(){var d=Math.abs(this.__decelerationVelocityX)>=l||Math.abs(this.__decelerationVelocityY)>=l;return d||(this.__didDecelerationComplete=!0),d}.bind(this),u=function(d,w,x){this.__isDecelerating=!1,this.__didDecelerationComplete&&this.options.scrollingComplete(),this.scrollTo(this.__scrollLeft,this.__scrollTop,this.options.snapping)}.bind(this);this.__isDecelerating=Sr(i,s,u)},__stepThroughDeceleration:function(e){var t=this.__scrollLeft+this.__decelerationVelocityX,n=this.__scrollTop+this.__decelerationVelocityY;if(!this.options.bouncing){var o=Math.max(Math.min(this.__maxDecelerationScrollLeft,t),this.__minDecelerationScrollLeft);o!==t&&(t=o,this.__decelerationVelocityX=0);var r=Math.max(Math.min(this.__maxDecelerationScrollTop,n),this.__minDecelerationScrollTop);r!==n&&(n=r,this.__decelerationVelocityY=0)}if(e?this.__publish(t,n,this.__zoomLevel):(this.__scrollLeft=t,this.__scrollTop=n),!this.options.paging&&(this.__decelerationVelocityX*=.95,this.__decelerationVelocityY*=.95),this.options.bouncing){var i=0,l=0,s=this.options.penetrationDeceleration,u=this.options.penetrationAcceleration;t<this.__minDecelerationScrollLeft?i=this.__minDecelerationScrollLeft-t:t>this.__maxDecelerationScrollLeft&&(i=this.__maxDecelerationScrollLeft-t),n<this.__minDecelerationScrollTop?l=this.__minDecelerationScrollTop-n:n>this.__maxDecelerationScrollTop&&(l=this.__maxDecelerationScrollTop-n),i!==0&&(i*this.__decelerationVelocityX<=0?this.__decelerationVelocityX+=i*s:this.__decelerationVelocityX=i*u),l!==0&&(l*this.__decelerationVelocityY<=0?this.__decelerationVelocityY+=l*s:this.__decelerationVelocityY=l*u)}}};var Nt=typeof window<"u"?window:{screen:{},navigator:{}},En=(Nt.matchMedia||function(){return{matches:!1}}).bind(Nt),ti=!1,rl={get passive(){return ti=!0}},Er=function(){};Nt.addEventListener&&Nt.addEventListener("p",Er,rl),Nt.removeEventListener&&Nt.removeEventListener("p",Er,!1);var il=ti,ll="PointerEvent"in Nt,qo="ontouchstart"in Nt,ni=qo||"TouchEvent"in Nt&&En("(any-pointer: coarse)").matches,_r=(Nt.navigator.maxTouchPoints||0)>0||ni,oi=Nt.navigator.userAgent||"",sl=En("(pointer: coarse)").matches&&/iPad|Macintosh/.test(oi)&&Math.min(Nt.screen.width||0,Nt.screen.height||0)>=768,ri=(En("(pointer: coarse)").matches||!En("(pointer: fine)").matches&&qo)&&!/Windows.*Firefox/.test(oi),cl=En("(any-pointer: fine)").matches||En("(any-hover: hover)").matches||sl||!qo,jo=!_r||!cl&&ri?_r?"touchOnly":"mouseOnly":"hybrid",al=jo==="mouseOnly"?"mouse":jo==="touchOnly"||ri?"touch":"mouse";const ul=Object.freeze(Object.defineProperty({__proto__:null,deviceType:jo,primaryInput:al,supportsPassiveEvents:il,supportsPointerEvents:ll,supportsTouchEvents:ni},Symbol.toStringTag,{value:"Module"})),dl=new Set(["INPUT","TEXTAREA","SELECT"]),ii={};function Ao(){return ul}const we=Object.freeze(Object.defineProperty({__proto__:null,EmptyCssProperties:ii,boundPixel:function(e,t=!1,n=0){return e},createSyntheticEvent:e=>{let t=!1,n=!1;return{nativeEvent:e,currentTarget:e.currentTarget,target:e.target,bubbles:e.bubbles,cancelable:e.cancelable,defaultPrevented:e.defaultPrevented,eventPhase:e.eventPhase,isTrusted:e.isTrusted,preventDefault:()=>{t=!0,e.preventDefault()},isDefaultPrevented:()=>t,stopPropagation:()=>{n=!0,e.stopPropagation()},isPropagationStopped:()=>n,persist:()=>{},timeStamp:e.timeStamp,type:e.type}},detectIt:Ao,focusableNodeNames:dl,toPrettyKeyCode:e=>e==="BracketLeft"?"[":e==="BracketRight"?"]":St.camelToPrettyCase(e)},Symbol.toStringTag,{value:"Module"})),hl=[];function lo(e,t,n=hl){const o=c.useRef(null);return c.useImperativeHandle(e,()=>{if(!o.current)return;const r=o.current,i=t?.();if(!i||typeof i!="object")throw new Error("attributes must return a plain object of values");const l=Object.keys(i),s=l.length;for(let u=0;u<s;u++){const d=l[u],w=i[d];Object.defineProperty(r,d,{value:w,writable:!0,configurable:!0,enumerable:!0})}return r},n),o}const Cr=e=>T.jsx(Uo,{...e}),fl=({width:e,height:t})=>T.jsx("div",{className:"corner",style:{minWidth:`${e}px`,width:`${e}px`,minHeight:`${t}px`,height:`${t}px`}}),li=c.memo(c.forwardRef((e,t)=>{const{children:n,viewport:o,onScrollViewport:r,showHorizontalScrollbar:i=!0,showVerticalScrollbar:l=!0,createScrollCorner:s=fl,createHorizontalScrollbar:u=Cr,createVerticalScrollbar:d=Cr,style:w,touchElement:x,disableTouch:p,...y}=e,_=k(r,[r]),I=lo(t,()=>({isScrollPane:()=>!0}),[]),R=c.useRef(null);c.useEffect(()=>{R.current&&(R.current.__scrollTop===o?.top&&R.current.__scrollLeft!==!o?.left||R.current?.scrollTo(o?.left,o?.top,!1))},[o?.left,o?.top,x]);const ce=c.useCallback((O,h)=>{_?.({left:O,top:h})},[]),P=c.useCallback(O=>{R.current?.doTouchStart(O.touches,O.timeStamp)},[]),C=c.useCallback(O=>{O.preventDefault(),R.current?.doTouchMove(O.touches,O.timeStamp)},[]),D=c.useCallback(O=>{R.current?.doTouchEnd(O.timeStamp)},[]),ie=c.useCallback(({containerWidth:O,containerHeight:h,totalWidth:M,totalHeight:Q})=>{R.current.setDimensions(O,h,M,Q)},[]);c.useEffect(()=>{const O=x??I.current;if(!p&&Ao().supportsTouchEvents&&O&&o){if(!R.current){const h={scrollingX:!0,scrollingY:!0,decelerationRate:.95,penetrationAcceleration:.08};R.current=new ei(ce,h)}Ao().supportsTouchEvents&&(O.addEventListener("touchstart",P),O.addEventListener("touchend",D),O.addEventListener("touchmove",C)),ie({containerWidth:o?.width,containerHeight:o?.height,totalWidth:o?.totalWidth,totalHeight:o?.totalHeight})}return()=>{O?.removeEventListener("touchstart",P),O?.removeEventListener("touchend",D),O?.removeEventListener("touchmove",C)}},[o?.width,o?.height,o?.totalWidth,o?.totalHeight,p,x]);const[$,{width:ne}]=gn(),[ve,{height:q}]=gn(),N=c.useMemo(()=>{const O=d({orientation:cn.Vertical,offset:o?.top,viewportSize:o?.height,totalSize:o?.totalHeight,onScrollOffset:h=>{_?.({top:h})}});return T.jsx("div",{style:{display:"flex",flex:"0"},ref:$,children:O})},[d,o?.top,o?.height,o?.totalHeight]),Y=c.useMemo(()=>{const O=u({orientation:cn.Horizontal,offset:o?.left,viewportSize:o?.width,totalSize:o?.totalWidth,onScrollOffset:h=>_?.({left:h})});return T.jsxs("div",{style:{display:"flex",flex:"none",flexDirection:"row",alignItems:"stretch",justifyContent:"center"},children:[T.jsx("div",{style:{display:"flex",flex:"1 1 100%",flexDirection:"column",width:`calc(100% - ${ne}px)`},children:T.jsx("div",{ref:ve,className:"sizer",children:O})}),l?s({width:ne,height:q}):T.jsx(T.Fragment,{})]})},[u,o?.left,o?.width,o?.totalWidth,l,s,ne,q]);return T.jsx("div",{style:{position:"relative",display:"flex",minWidth:l?`${ne}px`:void 0,minHeight:i?`${q}px`:void 0,...w},...y,ref:I,children:T.jsxs("div",{style:{position:"relative",width:"100%",flex:"1 1 100%",display:"flex",flexDirection:"column",boxSizing:"border-box"},children:[T.jsxs("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:[T.jsx("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:n}),l?N:T.jsx(T.Fragment,{})]}),i?Y:T.jsx(T.Fragment,{})]})})}));li.displayName="ScrollPane";const pl=()=>{const e=document.fullscreenElement;return e?e.querySelector(".fullscreen-portal-root")||e:document.body};let qn=0;function si(){return c.useEffect(()=>{function e(){const t=document.fullscreenElement;if(!t)return;let n=t.querySelector(".fullscreen-portal-root");n||(n=document.createElement("div"),n.className="fullscreen-portal-root _fullscreen-portal-root_5qk7s_7",t.appendChild(n))}return qn++,e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e),qn--,qn<=0&&(document.querySelectorAll(".fullscreen-portal-root").forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),qn=0)}},[]),{getPortalContainer:pl}}const gl=100,wl=100,ml=1e6,xl=100,yl=50,vl=c.memo(c.forwardRef((e,t)=>{const{offset:n=0,viewportSize:o=0,totalSize:r=0,minSize:i=0,endGap:l=gl,endScrollIncrement:s=wl,style:u=ii,onMouseDown:d,onScrollOffset:w,onScroll:x,scaleLimit:p=ml,scaleFactor:y=xl,precisionFactor:_=yl,...I}=e;x&&console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");const R=k(d,[d]),ce=()=>({offset:n,totalSize:p===0?r:Math.min(r??0,Math.max(i??0,(n??0)+(o??0))+(l??0))}),[P,C]=c.useState(ce),D=p!==0&&P.totalSize>p?y:1,ie=D/_,$=Math.ceil(P.totalSize/D),ne=Math.ceil(P.offset/D),ve=Math.ceil(o/D),q=c.useCallback(H=>{},[]),[N,Y]=c.useState(!1),O=c.useRef(null);c.useLayoutEffect(()=>{if(!N){O.current={propTotalSize:r,propViewportSize:o,propOffset:n};const H=ce();C(H)}},[r,o,n,N,i,l,s]);const h=k((H,A,K)=>{const U=O.current;O.current=null,U&&U.propTotalSize===r&&U.propViewportSize===o&&U.propOffset===n||(Math.abs(H-ne)<ie&&(H=ne),w?.(H*D,ne,ve))},[w,D,ie,ne,ve]),M=c.useCallback(H=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",M),Y(!1)},[]),Q=c.useCallback(H=>{R?.(H),Y(!0),document.addEventListener("mousemove",q,{passive:!0}),document.addEventListener("mouseup",M,{passive:!0})},[q,M]);return T.jsx(Uo,{ref:t,style:{...u},...I,offset:ne,totalSize:$,viewportSize:ve,onMouseDown:Q,onScrollOffset:h})}));function Co(e,t){if(typeof e=="function")return e(t);e&&(e.current=t)}vl.displayName="VirtualScrollbar";var oo=parseInt(c.version.split(".")[0],10)>=19?function(e){return t=>{const n=[];for(const o of e){const r=Co(o,t),i=typeof r=="function";n.push(i?r:()=>Co(o,null))}return()=>{for(const o of n)o()}}}:function(e){return t=>{for(const n of e)Co(n,t)}};c.memo(c.forwardRef((e,t)=>{const{refFocusStart:n,...o}=e,r=c.useRef(null),i=c.useCallback(()=>{if(n)return void n?.current?.focus();const l=r.current.parentElement.children;let s=[];for(let u=0;u<l.length&&l[u]!==r.current;u++){const d=l[u].getAttribute("tabindex");if(d==null||d==="-1"||l[u].getAttribute("disabled")==="true")continue;const w=l[u];w.focus&&s.push({tabindex:parseInt(d),child:w})}s.length!==0&&(s.sort(function(u,d){return u.tabindex-d.tabindex}),s[0].child.focus())},[n]);return T.jsx("div",{tabIndex:0,ref:oo([r,t]),onFocus:i,...o})})),c.memo(c.forwardRef((e,t)=>{const{className:n,style:o,children:r,radius:i=4,strokeWidth:l=1,strokeColor:s="grey",...u}=e,[d,{width:w,height:x}]=gn(),p=c.useRef(null),y=(ce,P=0)=>{const C=ce/2,D=x-C+P;return function(ie,$,ne=!1){if($===0)return ie;function ve(M,Q,H){let A=Q.x-M.x,K=Q.y-M.y,U=Math.sqrt(A*A+K*K);return q(M,Q,Math.min(1,H/U))}function q(M,Q,H){return{x:M.x+(Q.x-M.x)*H,y:M.y+(Q.y-M.y)*H}}function N(M,Q){M.length>2&&(M[M.length-2]=Q.x,M[M.length-1]=Q.y)}function Y(M){return{x:parseFloat(M[M.length-2]),y:parseFloat(M[M.length-1])}}let O=ie.split(/[,\s]/).reduce(function(M,Q){let H=Q.match("([a-zA-Z])(.+)");return H?(M.push(H[1]),M.push(H[2])):M.push(Q),M},[]).reduce(function(M,Q){return parseFloat(Q)==Q&&M.length?M[M.length-1].push(Q):M.push([Q]),M},[]),h=[];if(O.length>1){let M=Y(O[0]),Q=null;O[O.length-1][0]==="Z"&&O[0].length>2&&(Q=["L",M.x,M.y],O[O.length-1]=Q),h.push(O[0]);for(let H=1;H<O.length;H++){let A=h[h.length-1],K=O[H],U=K===Q?O[1]:O[H+1];if(U&&A&&A.length>2&&K[0]==="L"&&U.length>2&&U[0]==="L"){let me,G,Ve=Y(A),He=Y(K),Fe=Y(U);ne?(me=q(He,A.origPoint||Ve,$),G=q(He,U.origPoint||Fe,$)):(me=ve(He,Ve,$),G=ve(He,Fe,$)),N(K,me),K.origPoint=He,h.push(K);let ct=q(me,He,.5),Se=q(He,G,.5),E=["C",ct.x,ct.y,Se.x,Se.y,G.x,G.y];E.origPoint=He,h.push(E)}else h.push(K)}if(Q){let H=Y(h[h.length-1]);h.push(["Z"]),N(h[0],H)}}else h=O;return h.reduce(function(M,Q){return M+Q.join(" ")+" "},"")}(`M 0 ${C} L ${i-.5} ${C} L ${i-.5} ${D} L ${2*i} ${D} L ${w-2*i} ${D} M ${w-2*i} ${D} L ${w-i} ${D} L ${w-i} ${C} L ${w} ${C}`,i)},_=c.useMemo(()=>y(l),[w,x,i,l]),I=c.useMemo(()=>{if(i===0)return;const ce=i/2;return y(i)+`L ${w} 0 L 0 0 L 0 ${ce}`},[_,i,l]),R=c.useMemo(()=>({style:{clipPath:`path('${I}')`}}),[I]);return T.jsxs("div",{className:n,style:{display:"flex",flexDirection:"row",...o},...u,ref:oo([p,d,t]),children:[c.isValidElement(r)?c.cloneElement(r,R):T.jsx(T.Fragment,{}),T.jsx("svg",{style:{position:"absolute",top:0,left:0,pointerEvents:"none"},width:w,height:x,viewBox:`0 0 ${w} ${x}`,children:T.jsx("path",{d:_,stroke:s,fill:"none",vectorEffect:"non-scaling-stroke",strokeWidth:l})})]})}));const bl={},Sl=e=>{const{onPointerDown:t,style:n,splitDirection:o,paddingBefore:r=0,paddingAfter:i=0,disabled:l,key:s,hitAreaProps:u=bl,...d}=e,w=o==="row",{style:x,className:p,...y}=u;return T.jsx("div",{style:{...n,position:"relative"},...d,children:T.jsx("div",{className:yn("hit-box",p),style:{left:(w?-r:0)+"px",width:`calc(100% + ${w?r+i:0}px)`,top:(w?0:-r)+"px",height:`calc(100% + ${w?0:r+i}px)`,position:"absolute",...x},onPointerDown:l?void 0:t,...y})},s)},Kn={},hn=(e,t,n=!0)=>e===null?null:e.pixels!==null?n?e.pixels:t-e.pixels:(n?e.percent:100-e.percent)/100*t,Xn=(e,t=!0)=>e?.percent?`${t?e.percent:100-e.percent}%`:e?.pixels?`${e.pixels}px`:void 0,ln=(e,t)=>{if(e==null)return null;const n={percent:null,pixels:null};let o=t;return typeof e=="string"&&((e=e.trim().toLowerCase()).endsWith("px")?(e=e.substring(0,e.length-2),o=!1):e.endsWith("%")&&(e=e.substring(0,e.length-1),o=!0),e=parseFloat(e)),o?n.percent=e:n.pixels=e,Object.freeze(n)};function vn(e){if(!e)throw new Error("must have a PointerHandlerOptions");const{onPointerDown:t,onPointerUp:n,onPointerMoveOrWait:o,processTouch:r=!1,consumeTouch:i=!0}=e,l=k(t,[t]),s=k(n,[n]),u=k(o,[o]),d=c.useRef(!1),w=e?.timerInitial??230,x=e?.timerContinuous??w/2,p=c.useRef(null),y=c.useRef(null),_=c.useRef(null),I=c.useRef(null),R=c.useCallback(()=>{I.current&&(clearTimeout(I.current),I.current=null)},[]),ce=c.useCallback(N=>{I.current=setTimeout(()=>{window.requestAnimationFrame(()=>{d.current!==!1&&u?.(y.current,_.current,p.current)}),ce(x)},N??w)},[]);c.useEffect(()=>()=>R(),[]);const P=r?"pointer":"mouse",C=c.useCallback(N=>{N.stopPropagation(),N.stopImmediatePropagation(),N.preventDefault()},[]),D=k(N=>{document.removeEventListener(`${P}move`,ne),document.removeEventListener(`${P}up`,D),document.removeEventListener("keydown",ve),document.removeEventListener("keyup",q),document.removeEventListener("touchstart",C,{capture:!0}),document.removeEventListener("touchmove",C,{capture:!0}),window.removeEventListener("blur",ie),R(),window.requestAnimationFrame(()=>{d.current!==!1&&(d.current=!1,s?.(N,_.current,p.current),_.current=null)})},[]),ie=c.useCallback(()=>{d.current!==!1&&(d.current=!1,D(y.current))},[]),$=k(()=>{R(),ce(x),window.requestAnimationFrame(()=>{d.current!==!1&&u?.(y.current,_.current,p.current)})},[x]),ne=k(N=>{y.current=N,$()},[]),ve=k(N=>{_.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},$()},[]),q=k(N=>{_.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},$()},[x]);return k(N=>{N.isDefaultPrevented()||(_.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},l(N,_.current)!==!1&&(p.current=N,y.current=N.nativeEvent,document.addEventListener(`${P}up`,D,{passive:!1}),document.addEventListener(`${P}move`,ne,{passive:!1}),document.addEventListener("keydown",ve,{passive:!1}),document.addEventListener("keyup",q,{passive:!1}),window.addEventListener("blur",ie,{passive:!0}),r&&i&&(document.addEventListener("touchstart",C,{passive:!1,capture:!0}),document.addEventListener("touchmove",C,{passive:!1,capture:!0})),d.current=!0,ce(w)))},[w,r])}c.memo(c.forwardRef((e,t)=>{const{elementBefore:n,elementAfter:o,splitDirection:r="row",fixedPane:i=null,position:l,onPositionChange:s,minBefore:u,maxBefore:d,minAfter:w,maxAfter:x,children:p,className:y,style:_,disabled:I=!1,onDragStart:R,onDragResize:ce,onDragFinish:P,resizerProps:C=Kn,paneProps:D=Kn,paneBeforeProps:ie=Kn,paneAfterProps:$=Kn,createResizer:ne=Sl}=e;if(p)throw new Error("Use elementBefore and elementAfter instead of children.");const ve=c.useMemo(()=>c.isValidElement(o)&&c.isValidElement(n),[o,n]),q=c.useMemo(()=>{let J=null;i&&(i==="before"?J=0:i==="after"&&(J=1));const Ze=J===null;return{fixedPaneOffset:J,isPercent:Ze,minBefore:ln(u,Ze),maxBefore:ln(d,Ze),minAfter:ln(w,Ze),maxAfter:ln(x,Ze)}},[u,d,w,x]),N=k(s,[s]),[Y,O]=c.useState(()=>ln(l,i===null));c.useEffect(()=>{O(ln(l,i===null))},[l,i]);const[h,{width:M,height:Q}]=gn(),[H,{width:A,height:K}]=gn(),U=r==="row"?A:K,me=r==="row"?M:Q,G=c.useMemo(()=>((J,Ze,Ne,lt)=>{const Ee=[null,null],Pe=[null,null];if(J||(J={percent:lt.fixedPaneOffset===null?50:null,pixels:lt.fixedPaneOffset===null?null:0}),Ze===0)return J?.pixels!=null?lt.fixedPaneOffset!==1?(Ee[0]=J?.pixels,Pe[1]=100):(Ee[1]=J?.pixels-Ne,Pe[0]=100):J?.percent!=null&&(lt.fixedPaneOffset!==1?(Pe[0]=J?.percent,Pe[1]=100-J?.percent):(Pe[1]=J?.percent,Pe[0]=100-J?.percent)),{percents:Pe,pixels:Ee,minBefore:Xn(lt.minBefore,!0),maxBefore:Xn(lt.maxBefore,!0),minAfter:Xn(lt.minAfter),maxAfter:Xn(lt.maxAfter)};let tt=hn(J,Ze,lt.fixedPaneOffset!==1),Je=Ze-Ne,De=hn(lt.minBefore,Je,!0)??0,Gt=hn(lt.maxBefore,Je,!0)??Je,Et=0,Qe=0,_t=0,It=Je;Et=(hn(lt.maxAfter,Ze,!1)??Ne)-Ne,Qe=hn(lt.minAfter,Ze,!1)??Ze,_t=Math.max(De,Et),It=Math.min(Gt,Qe),tt=Math.max(_t,Math.min(tt,It)),Qe=Math.min(Je-tt,hn(lt.maxAfter,Je-tt,!0)??Je),Et=Math.min(Je-tt,hn(lt.minAfter,Je-tt,!0)??Je),Ee[0]=tt,Ee[1]=Je-Ee[0];const on=Math.max(0,Math.min(100,tt/Je*100));return Pe[0]=on,Pe[1]=100-Pe[0],{percents:Pe,pixels:Ee,minBefore:`${De}px`,minAfter:`${Et}px`,maxBefore:`${Ee[0]}px`,maxAfter:`${Ee[1]}px`}})(Y,me,U,q),[q,Y,me,U,r]),[Ve,He]=c.useState(!1),Fe=k(R,[R]),ct=k(ce,[ce]),Se=k(P,[P]),E=c.useRef(null),ue=c.useRef(null),X=c.useRef(null),{style:fe,className:ee,...Me}=D,it={minWidth:0,minHeight:0,maxWidth:"100%",maxHeight:"100%",display:"flex",overflow:"hidden",...fe},{className:ut,style:Tt,...dt}=ie,{className:Ut,style:je,...j}=$,Re={flex:"1 1 100%",width:"100%",..._,flexDirection:r,display:"flex"},{className:Ge,style:Ke,onPointerDown:ht,...en}=C,qt=k(J=>{const Ze=ln(J,i===null);O(Ze)},[i]),zt=k(J=>{if(I||!Ve)return;const Ze=Le.current?.getBoundingClientRect();let Ne=0;Ne=r==="row"?(J.clientX??J.touches?.[0]?.clientX)-Ze.x:(J.clientY??J.touches?.[0]?.clientY)-Ze.y,Ne=Math.max(0,Math.min(me,Ne)),q.fixedPaneOffset===1&&(Ne=me-Ne),l&&Y.pixels===Ne||O({pixels:Ne,percent:null}),ct?.(Ne),J.stopPropagation(),J.preventDefault()},[q,r,I,Ve,Y,me]),tn=k(J=>{if(document.removeEventListener("pointermove",zt),document.removeEventListener("touchmove",zt),document.removeEventListener("pointerup",tn),Ve&&(He(!1),Y)){if(Se(Y.pixels),!ln(l,i===null)||Y.pixels!==l){const Ze={...Y};Ze.percent===null&&(Ze.percent=Ze.pixels/me*100),N(Ze)}J.stopPropagation(),J.preventDefault()}},[Y,Ve,l,i,me]),Yt=k(J=>{ht?.(J),J.defaultPrevented||I||Ve||(He(!0),Fe(),document.addEventListener("pointermove",zt,{passive:!1}),document.addEventListener("touchmove",zt,{passive:!1}),document.addEventListener("pointerup",tn,{passive:!1}))},[ht]),Le=lo(t,()=>({setPosition:qt,isSplitPane:()=>!0}),[]),Ft=c.useMemo(()=>ve?ne?.({key:"resizer",ref:oo([H,ue]),className:yn("resizer",Ge),onPointerDownCapture:Yt,style:{cursor:I?void 0:r==="row"?"ew-resize":"ns-resize",minWidth:r==="row"?"2px":void 0,minHeight:r!=="row"?"2px":void 0,boxSizing:"border-box",pointerEvents:"all",zIndex:1,...Ke},splitDirection:r,disabled:I,...en}):null,[ve,Ge,en,r,Ke,I]),gt=r==="row"?"Width":"Height",jt={...it,...Tt,flex:q.fixedPaneOffset===0&&G?.pixels[0]!==null?`0 0 ${Math.round(G?.pixels[0])}px`:`1 1 ${Math.round(G?.percents[0]??100)}%`,[`min${gt}`]:G?.minBefore,[`max${gt}`]:o?G?.maxBefore:"100%"},wn={...it,...je,flex:q.fixedPaneOffset===1&&G?.pixels[1]!==null?`0 0 ${Math.round(G?.pixels[1])}px`:`1 1 ${Math.round(G?.percents[1]??100)}%`,[`min${gt}`]:G?.minAfter,[`max${gt}`]:n?G?.maxAfter:"100%"},nn=c.useMemo(()=>n?T.jsx("div",{ref:E,className:yn("before",ee,ut),style:jt,...Me,...dt,children:n},"before"):null,[n,D,ie,q,G]),We=c.useMemo(()=>o?T.jsx("div",{ref:X,className:yn("after",ee,Ut),style:wn,...Me,...j,children:o},"after"):null,[o,D,$,q,G]);return T.jsxs("div",{ref:oo([h,Le]),className:yn("splitPane",r==="row"?"vertical":"horizontal",{dragging:Ve},y),style:Re,children:[nn,Ft,We]})}));const El=({initValue:e,useHookBody:t,applyStateChange:n})=>{const o=c.useRef(e);if(typeof t!="function")throw new Error("function expected as hook body parameter. got "+typeof t);const r=t();return c.useLayoutEffect(()=>{o.current!==r&&(o.current=r,n(r))},[n,r]),null},$o=e=>{console&&console.warn&&console.warn(e)},Io=typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global||void 0;let _l=1,Bo=!1,ci=!1;const Jn=[],bn=[],ro=()=>{bn.forEach(e=>e())},Cl=({automaticContainerInternalUseOnly:e})=>{const[t,n]=c.useState([]),o=c.useRef([]);return o.current=t,e||Bo!==!1||(ci=!0),c.useEffect(()=>{let r=!0;function i(){if(r)return bn[0]!==i?(e||Bo!==!0||$o("SingletonHooksContainer is mounted after some singleton hook has been used.Your SingletonHooksContainer will not be used in favor of internal one."),void n(l=>[])):void n([...Jn])}return bn.push(i),ro(),()=>{r=!1,o.current?.length>0&&$o("SingletonHooksContainer is unmounted, but it has active singleton hooks. They will be reevaluated once SingletonHooksContainer is mounted again"),bn.splice(bn.indexOf(i),1),ro()}},[e]),T.jsx(T.Fragment,{children:t.map(({hook:r,key:i})=>c.createElement(El,{...r,key:i}))})},ai=(e,t,n={})=>{let o,r,i=!1,l=!1,s=[],{unmountIfNoConsumers:u=!1}=n;const d=x=>{r=x,No.unstable_batchedUpdates(()=>s.forEach(p=>p(x)))},w=()=>(l||(r=typeof e=="function"?e():e,l=!0),r);return()=>{const[x,p]=c.useState(w);return c.useEffect(()=>(i||(i=!0,o=(y=>{const _=_l++;return Jn.push({hook:y,key:_}),bn.length===0&&ci===!1&&(Bo=!0,(I=>{if(Io.document&&Io.document.createElement){const R=Io.document.createElement("div");Ci.createRoot(R).render(T.jsx(I,{automaticContainerInternalUseOnly:!0}))}else $o("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.")})(Cl)),ro(),()=>{Jn.splice(Jn.findIndex(I=>I.key===_),1),ro()}})({initValue:e,useHookBody:t,applyStateChange:d})),s.push(p),r!==x&&p(r),()=>{s.splice(s.indexOf(p),1),s.length===0&&u&&(o(),i=!1)}),[]),x}};ai(null,()=>{const[e,t]=c.useState(null);return e});class Il{constructor(t,n,o,r){this._listenersProperties=new Set,this._listenersExecute=new Set,this._key=t,this._target=n,this._applyProps(o||{}),this._callback=r,r===void 0&&(this._callback=()=>{console.log(`implement: ${this.label()} : ${this.description()}`)})}key(){return this._key}_resolve(t,n){if(typeof t=="function"){const o=n??this._context;return t(typeof o=="function"?o():o)}return t}target(){return typeof this._target=="function"?this._target():this._target}label(t,n){const o=this._scopedLabels?.[t]||this._label;let r=null;if(typeof o=="function"){const i=n??this._context;r=o(typeof i=="function"?i():i)}else r=o;return r}description(t){return this._resolve(this._description,t)}tags(t){return this._resolve(this._tags,t)}icon(t){return this._resolve(this._icon,t)}shortcut(){return this._resolve(this._shortcut)}disabled(){return this._resolve(this._disabled)||!this._callback}state(){return this._resolve(this._state)}context(){return typeof this._context=="function"?this._context():this._context}async execute(t,n){if(!this.disabled()&&this._callback){try{let o=!0;if(n?.beforeExecute&&(o=n?.beforeExecute(this,t)),await Promise.resolve(o)===!1)return!1;const r=this._callback.bind(this)(t,this);if(await Promise.resolve(r)===!1)return!1;n?.onExecute?.(this,t),this._notifyExecute(t)}catch(o){return console.warn(o),n?.onError(this,o,t),this._notifyError(t,o),!1}return!0}}addPropertyListener(t,n=!1){if(!t)throw new Error("listener must be specified");const o=this._listenersProperties;return o.add(t),n&&t({},this),()=>{o.delete(t)}}addExecuteListener(t){if(!t)throw new Error("listener must be specified");const n=this._listenersExecute;return n.add(t),function(){n.delete(t)}}_notifyExecute(t){const n=this;this._listenersExecute.forEach(o=>{o.onExecute(n,t)})}_notifyError(t,n){const o=this;this._listenersExecute.forEach(r=>{r.onError?.(o,t,n)})}updateCallback(t){return this._callback=t||null,this}update(t){if(!t)return;const n=this._applyProps(t);return Object.keys(n).length>0&&this._notifyPropertyChange(n),this}_notifyPropertyChange(t){const n=this;this._listenersProperties.forEach(o=>{o(t,n)})}_applyProps(t){let n={},o=this;return Object.keys(t).forEach(r=>{let i=t[r];o["_"+r]!==i&&(o["_"+r]=n[r]=i)}),n}}class be extends Il{}St.getOS()===St.OSType.MacOS||(St.getOS(),St.OSType.IOS),St.getOS()===St.OSType.MacOS||(St.getOS(),St.OSType.IOS),ai({setClipboard:e=>{throw new Error("This is only available via the useClipboard.")},getClipboard:()=>no.Global,refNativeCopy:{current:null},refNativeLastKey:{current:null}},()=>{const[e,t]=c.useState(no.Global);return{setClipboard:n=>t(n),getClipboard:()=>e,refNativeCopy:c.useRef(null),refNativeLastKey:c.useRef(null)}});let Mo=!1,Ml=0;var Rl=typeof document<"u"?c.useLayoutEffect:c.useEffect;const Ir=()=>"sheetxl-ui-"+Ml++,kl=c.useId??function(){const[e,t]=c.useState(()=>Mo?Ir():void 0);return Rl(()=>{e==null&&t(Ir())},[]),c.useEffect(()=>{Mo||(Mo=!0)},[]),e},Sn=({itemType:e,index:t,itemSize:n,instanceProps:o,scale:r=1})=>{let i,l,s;e==="column"?(i=o.columnMetadataMap,l=o.lastMeasuredColumnIndex,s=o.recalcColumnIndices):(i=o.rowMetadataMap,l=o.lastMeasuredRowIndex,s=o.recalcRowIndices);const u=s.length>0;if(t>l){let d=0;if(l>=0){const w=i[l];d=w.offset+w.size}for(let w=l+1;w<=t;w++){let x=u?s.includes(w)?n(w)*r:i[w]?.size||n(w)*r:n(w)*r;i[w]={offset:d,size:x},d+=x}e==="column"?o.lastMeasuredColumnIndex=t:o.lastMeasuredRowIndex=t}return i[t],i[t]},Mr=({itemType:e,itemSize:t,itemCount:n,instanceProps:o,offset:r,scale:i})=>{let l,s;e==="column"?(l=o.columnMetadataMap,s=o.lastMeasuredColumnIndex):(l=o.rowMetadataMap,s=o.lastMeasuredRowIndex);let u=0;return u=(s>0?l[s].offset:0)>=r?ui({itemType:e,itemSize:t,instanceProps:o,high:s,low:0,offset:r,scale:i}):Tl({itemType:e,itemSize:t,itemCount:n,instanceProps:o,index:Math.max(0,s),offset:r,scale:i}),u=Math.min(u,n),u},ui=({itemType:e,itemSize:t,instanceProps:n,high:o,low:r,offset:i,scale:l})=>{for(;r<=o;){const s=r+Math.floor((o-r)/2),u=Sn({itemType:e,itemSize:t,index:s,instanceProps:n,scale:l}).offset;if(u===i)return s;u<i?r=s+1:u>i&&(o=s-1)}return r>0?r-1:0},Tl=({itemType:e,itemSize:t,itemCount:n,instanceProps:o,index:r,offset:i,scale:l})=>{let s=1;for(;r<n&&Sn({itemType:e,itemSize:t,index:r,instanceProps:o,scale:l}).offset<i;)r+=s,s*=2;return ui({itemType:e,itemSize:t,instanceProps:o,high:Math.min(r,n-1),low:Math.floor(r/2),offset:i,scale:l})},di=e=>{const{rowCount:t,columnCount:n,defaultRowHeight:o,getRowHeight:r,defaultColumnWidth:i,getColumnWidth:l}=e||{},s=c.useRef({columnMetadataMap:{},rowMetadataMap:{},lastMeasuredColumnIndex:-1,lastMeasuredRowIndex:-1,recalcColumnIndices:[],recalcRowIndices:[]}),u=k(C=>Mr({itemType:"row",itemCount:t,itemSize:r??(()=>o??20),instanceProps:s.current,offset:C}),[t,r,o]),d=k(C=>C===-1?0:Sn({itemType:"row",index:C,itemSize:r??(()=>o??20),instanceProps:s.current}).offset,[r,o]),w=k(C=>Sn({itemType:"row",index:C,itemSize:r??(()=>o??20),instanceProps:s.current}).size,[r,o]),x=k(C=>Mr({itemType:"column",itemCount:n,itemSize:l??(()=>i??75),instanceProps:s.current,offset:C}),[n,l,i]),p=k(C=>C===-1?0:Sn({itemType:"column",index:C,itemSize:l??(()=>i??75),instanceProps:s.current}).offset,[l,i]),y=k(C=>Sn({itemType:"column",index:C,itemSize:l??(()=>i??75),instanceProps:s.current}).size,[l,i]),[_,I]=c.useReducer(C=>C+1,0),R=()=>({getRowOffset:d,getColOffset:p,getRowIndex:u,getColIndex:x}),[ce,P]=c.useState(()=>e?R():null);return c.useEffect(()=>{P(e?R():null)},[_,t,n,i,o,w,y]),ce},Ko="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\",Rr=e=>{if(!e)return null;if(e.eventType==="start")return{type:e.eventType};if(e.eventType==="submit")return{type:e.eventType};if(e.eventType==="cancel")return{type:e.eventType};if(e.eventType==="keyboard")return{type:e.eventType,key:e.event.key};if(e.eventType==="pointer")return{type:e.eventType};if(e.eventType==="coordsChange"){const t={type:e.eventType};return e.activeCoords&&(t.activeCoords=e.activeCoords),t}return{type:e.eventType??"unknown"}},Pl=e=>!0,Ol=e=>!!e&&!(e.ctrlKey||e.metaKey||e.altKey||e.isComposing)&&(!(e.shiftKey||e.key!=="F2"&&e.key!==" "&&e.key!=="Backspace")||(!e.shiftKey||e.key!==" ")&&Ko.indexOf(e.key)!==-1),Ll=e=>!!e&&e.type==="dblclick"&&{editMode:!0},Dl=e=>{const{session:t,refLatestCoords:n,handleSubmitEdit:o,handleCancelEdit:r,cellBounds:i,isInBounds:l,getCellEditor:s,propsEditor:u,borderStrokeFill:d="rgb(33, 115, 70)",borderStrokeWidth:w=2,alignment:x=On.Left,style:p,...y}=e,_=c.useRef(null),I=c.useRef(null),[R,ce]=c.useState(!1),P=t.coords,C=c.useCallback(async Y=>{if(_.current?.getBoundingClientRect()){if(Y.eventType==="keyboard"){const h=Y.event,M=new KeyboardEvent(h.type,{bubbles:!0,cancelable:!0,view:window,key:h.key,code:h.code,location:h.location,repeat:h.repeat,isComposing:h.isComposing,charCode:h.charCode,keyCode:h.keyCode,which:h.which,ctrlKey:h.ctrlKey,shiftKey:h.shiftKey,altKey:h.altKey,metaKey:h.metaKey});M.isSynthetic=!0,M.key,I.current?.dispatchEvent(M)}else Y.eventType==="pointer"||console.warn("unsupported event type",Y);await new Promise(h=>requestAnimationFrame(h))}},[]);c.useEffect(()=>{const Y=I.current;return ce(!0),I.current.startEdit?.(t.startEvent),(async()=>{t.editorRefs.push(Y),t.editorRefsDispatchEditorEvent.push(C);const O=[...t.events];for(let h=0;h<O.length;h++)await C(O[h]);t.onMount(Y)})(),()=>{const O=t.editorRefs.indexOf(Y);O!==-1&&t.editorRefs.splice(O,1),t.onUnmount(Y)}},[]);const D=c.useCallback(()=>o(t),[]),ie=c.useCallback(()=>{r(t)},[]),$=n.current&&Z.isEqualCells(n.current,P),ne=l&&$&&R,ve=s({autoFocus:!!t.startEvent?.autoFocus,...u,onSubmitEdit:D,onCancelEdit:ie,ref:I},P),q=i.x+we.boundPixel(-w/2),N=we.boundPixel(i.width+w/2,!0);return T.jsx("div",{tabIndex:0,ref:_,style:{background:void 0,...p,opacity:ne?p?.opacity??1:0,pointerEvents:"auto",position:"absolute",boxSizing:"border-box",top:`${i.y+we.boundPixel(-w/2)}px`,height:we.boundPixel(i.height+w/2,!0),left:`${q}px`,width:N},...y,children:T.jsx("div",{className:"editor-container",style:{position:"absolute",boxSizing:"border-box",left:`${we.boundPixel(1)}px`,top:`${we.boundPixel(1)}px`,width:we.boundPixel(i.width-2,!0),height:we.boundPixel(i.height-2,!0),outline:`${w}px ${d} solid`,boxShadow:"rgba(60,64,67,.35) 2px 2px 6px 3px",maxHeight:"100%",overflow:"hidden",display:"flex"},children:ve})})},qe=(e,t,n)=>{if(!e)return t;let o=t;const r=n===Ue||n===ot;for(;;){const i=e(o,!r);if(i===0)return o;r?o+=i:o-=i}},Yn=(e,t,n)=>{const o=[];let r=t;for(;r<=n;){const i=Math.max(0,e(r));i===0?(o.push(r),r++):r+=i}return o},zl=(e,t,n,o,r,i)=>{if(!t)return i;let{rowIndex:l,colIndex:s}=e;switch(o){case ot:{l=qe(n,Math.min(l+1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&l<i;)l=qe(n,Math.min(++l,i),o),u=t({rowIndex:l,colIndex:s});return l}case nt:{l=qe(n,Math.max(l-1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&l>i;)l=qe(n,Math.max(--l,i),o),u=t({rowIndex:l,colIndex:s});return l}case Ue:{s=qe(n,Math.min(s+1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&s<i;)s=qe(n,Math.min(++s,i),o),u=t({rowIndex:l,colIndex:s});return s}case et:{s=qe(n,Math.max(s-1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&s>i;)s=qe(n,Math.max(--s,i),o),u=t({rowIndex:l,colIndex:s});return s}default:return i}},jl=(e,t=()=>!0,n,o,r,i)=>{let{rowIndex:l,colIndex:s}=e;switch(o){case ot:{l=qe(n,Math.min(l+1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&l<i;)l=qe(n,Math.min(++l,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?l:l-1}case nt:{l=qe(n,Math.max(l-1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&l>i;)l=qe(n,Math.max(--l,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?l:l+1}case Ue:{s=qe(n,Math.min(s+1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&s<i;)s=qe(n,Math.min(++s,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?s:s-1}case et:{s=qe(n,Math.max(s-1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&s>i;)s=qe(n,Math.max(--s,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?s:s+1}default:return null}},Al=(e,t,n,o,r,i)=>{if(!t)return i;let l,{rowIndex:s,colIndex:u}=e;o===ot?l={rowIndex:s+1,colIndex:u}:o===nt?l={rowIndex:s-1,colIndex:u}:o===Ue?l={rowIndex:s,colIndex:u+1}:o===et&&(l={rowIndex:s,colIndex:u-1});const d=t(e),w=t(l);var x,p;return(p=w,!(x=d)&&!p||!x&&p||x&&!p?zl:jl)(e,t,n,o,!1,i)??i},kr=(e,t)=>`${e}:${t}`,Tr=(e,t,n,o,r,i)=>{if(n-t>=r-o)return o;let l=o;return e==="nearest"&&(o-t>0?e="start":n-r>0&&(e="end")),e==="start"?l=t:e==="end"?l=n-(r-o):e==="center"&&(l=t+(n-t)/2-(r-o)/2),Math.max(0,Math.min(l,i-(r-o)))},Pr=(e,t,n,o)=>(console.log("todo: implement convertToVisibleRanges"),e),Fo=(e,t=Ue,n,o,r,i=null)=>{if(i&&Z.isEqualSelectionCoords(i,e))return e;const l=e.ranges[e.rangeIndex];if(!Z.isRangesIntersect({rowStart:e.cell.rowIndex,colStart:e.cell.colIndex,rowEnd:e.cell.rowIndex,colEnd:e.cell.colIndex},l))return e;let s={...e.cell},u=e.rangeIndex;switch(t){case Ue:s.colIndex=qe(r,s.colIndex+1,t);break;case et:s.colIndex=qe(r,s.colIndex-1,t);break;case ot:s.rowIndex=qe(o,s.rowIndex+1,t);break;case nt:s.rowIndex=qe(o,s.rowIndex-1,t)}const d=p=>{if(p){u=e.rangeIndex>=e.ranges.length-1?0:e.rangeIndex+1;const y=e.ranges[u];s={colIndex:y.colStart,rowIndex:y.rowStart}}else{u=e.rangeIndex<=0?e.ranges.length-1:e.rangeIndex-1;const y=e.ranges[u];s={colIndex:y.colEnd,rowIndex:y.rowEnd}}};if(t===Ue&&s.colIndex>l.colEnd&&s.rowIndex===l.rowEnd)d(!0);else if(t===et&&s.colIndex<l.colStart&&s.rowIndex===l.rowStart)d(!1);else if(t===ot&&s.colIndex===l.colEnd&&s.rowIndex>l.rowEnd)d(!0);else if(t===nt&&s.colIndex===l.colStart&&s.rowIndex<l.rowStart)d(!1);else{let p=s.rowIndex,y=s.colIndex;switch(t){case Ue:y>l.colEnd&&(p=qe(o,p+1,t),y=l.colStart,p>l.rowEnd&&(p=l.rowStart));break;case et:y<l.colStart&&(p=qe(o,p-1,t),y=l.colEnd,p<l.rowStart&&(p=l.rowEnd));break;case ot:p>l.rowEnd&&(y=qe(r,y+1,t),p=l.rowStart,y>l.colEnd&&(y=l.colStart));break;case nt:p<l.rowStart&&(y=qe(r,y-1,t),p=l.rowEnd,y<l.colStart&&(y=l.colEnd))}s={rowIndex:p,colIndex:y}}let w=n(s);if(!Z.isRangeWithinRange(w,l)){const p=Z.intersectRanges(w,l);p&&(w=p)}let x={rowStart:qe(o,w.rowStart,ot),colStart:qe(r,w.colStart,Ue),rowEnd:qe(o,w.rowEnd,nt),colEnd:qe(r,w.colEnd,et)};if(x.rowStart!==s.rowIndex||x.colStart!==s.colIndex){switch(t){case Ue:e.ranges[u].colStart===x.colStart&&e.ranges[u].colEnd===x.colEnd&&(s.rowIndex=x.rowEnd),s.colIndex=x.colEnd;break;case et:e.ranges[u].colStart===x.colStart&&e.ranges[u].colEnd===x.colEnd&&(s.rowIndex=x.rowStart),s.rowIndex===x.rowStart?s.colIndex=x.colStart+1:s.colIndex=x.colStart;break;case ot:e.ranges[u].rowStart===x.rowStart&&e.ranges[u].rowEnd===x.rowEnd&&(s.colIndex=x.colEnd),s.rowIndex=x.rowEnd;break;case nt:e.ranges[u].rowStart===x.rowStart&&e.ranges[u].rowEnd===x.rowEnd&&(s.colIndex=x.colStart),s.colIndex===x.colStart?s.rowIndex=x.rowStart+1:s.rowIndex=x.rowStart}return Fo({cell:s,ranges:e.ranges,rangeIndex:u},t,n,o,r,i??e)}return{ranges:e.ranges,cell:s,rangeIndex:u}},Or=(e,t)=>{let n,o=0,r=0;return t.colStart<e.colStart?(n=et,o=e.colStart-t.colStart,r=t.colStart):t.colEnd>e.colEnd?(n=Ue,o=t.colEnd-e.colEnd,r=t.colEnd):t.rowStart<e.rowStart?(n=nt,o=e.rowStart-t.rowStart,r=t.rowStart):t.rowEnd>e.rowEnd&&(n=ot,o=t.rowEnd-e.rowEnd,r=t.rowEnd),{direction:n,amount:o,index:r}},io=(e,t=!1,n,o)=>{if(!n)return 0;const r=!t,i=r?1:-1;let l=n(r?e:e+1),s=n(r?e+1:e),u=e+(r?2:-1),d=0;for(;(s-l)*i<=0;){if(r&&u-1>o+1||!r&&u+1<o)return d;l=s,s=n(u),u+=i,d++}return d},Lr=(e,t,n,o,r)=>{const i={};let l=null,s=null;for(let u=0;u<=n.length&&n[u]<=r;u++){const d=n[u];if(d<o)continue;const w=l===d?s:t?e.getColOffset(d):e.getRowOffset(d),x=t?e.getColOffset(d+1):e.getRowOffset(d+1);l=d+1,s=x,i[d]=Object.freeze({offset:w,size:x-w,spanIndex:u})}return Object.freeze(i)},Dr=(e,t,n)=>{const o=e.getColOffset(t.colStart)+(n?.left??0),r=e.getRowOffset(t.rowStart)+(n?.top??0);return{x:o,y:r,width:e.getColOffset(t.colEnd+1)+(n?.right??0)-(n?.left??0)-o,height:e.getRowOffset(t.rowEnd+1)+(n?.bottom??0)-(n?.top??0)-r}},$l=(e,t,n)=>!!n&&!(e<n.x||e>n.x+n.width)&&!(t<n.y||t>n.y+n.height),Ro=(e,t=!0)=>`M ${we.boundPixel(e.left)} ${we.boundPixel(e.top)} L ${we.boundPixel(e.right,!0)} ${we.boundPixel(e.top)} L ${we.boundPixel(e.right,!0)} ${we.boundPixel(e.bottom,!0)} L ${we.boundPixel(e.left)} ${we.boundPixel(e.bottom,!0)} L ${we.boundPixel(e.left)} ${we.boundPixel(e.top)} ${t?"Z":""}`,Vo=e=>{const{linePoints:t,bounds:n,pathProps:o,style:r,...i}=e;return T.jsx("svg",{width:`${we.boundPixel(n.width,!0)}`,height:`${we.boundPixel(n.height,!0)}`,viewBox:`0 0 ${we.boundPixel(n.width,!0)} ${we.boundPixel(n.height,!0)}`,style:{position:"absolute",left:`${we.boundPixel(n.x)}px`,top:`${we.boundPixel(n.y)}px`,width:`${we.boundPixel(n.width,!0)}px`,height:`${we.boundPixel(n.height,!0)}px`,pointerEvents:"none",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top, width, height",willChange:"left, top, width, height, stroke-dashoffset",...r},...i,children:T.jsx("path",{d:`M ${we.boundPixel(t[0])} ${we.boundPixel(t[1])} L ${we.boundPixel(t[2])} ${we.boundPixel(t[3])}`,fill:"none",vectorEffect:"non-scaling-stroke",stroke:"black",...o})})},hi=e=>{const{x:t=0,y:n=0,width:o=0,height:r=0,fill:i,stroke:l,strokeWidth:s=0,strokeDasharray:u,strokeDashoffset:d,clipPath:w,pathBounds:x,pathProps:p,style:y,..._}=e,I=n,R=t,ce=o,P=r;let C=null;if(i){let D=Ro({top:0,left:0,bottom:P,right:ce});x&&(D=D+" "+Ro({top:x.y-I,left:x.x-R,bottom:x.height+x.y-I,right:x.width+x.x-R})),C=[T.jsx("path",{d:D,fill:i,stroke:"none",fillRule:"evenodd"},"fill")]}return T.jsxs("svg",{width:`${we.boundPixel(o,!0)}`,height:`${we.boundPixel(r,!0)}`,viewBox:`0 0 ${we.boundPixel(o,!0)} ${we.boundPixel(r,!0)}`,preserveAspectRatio:"none",style:{position:"absolute",left:`${we.boundPixel(t)}px`,top:`${we.boundPixel(n)}px`,pointerEvents:"none",transitionDuration:"0ms",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top, width, height",willChange:"left, top, width, height, stroke-dashoffset",boxShadow:"rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px",overflow:"visible",...y},..._,children:[C,T.jsx("path",{d:Ro({top:0,left:0,right:ce,bottom:P}),fill:"none",strokeDasharray:u,strokeDashoffset:d,stroke:l,vectorEffect:"non-scaling-stroke",strokeWidth:s,...p})]})},zr=e=>{const{key:t,...n}=e;return T.jsx(Xo,{...n},t)},Xo=c.memo(e=>{const{stroke:t,fill:n,x:o=0,y:r=0,width:i=0,height:l=0,style:s,isAnimatedStroke:u,animatedStrokeProps:d,range:w,cell:x,...p}=e,y=u||!!d,_={name:"walking-offset",dashGap:2,speed:50,dashLength:8,...d};let I=_.dashGap+_.dashLength;const R=_.speed*I,ce=kl().replaceAll(":",""),P=`${_.name}-${ce}`;let C;return c.useEffect(()=>{if(!y)return;const D=`@keyframes ${P} {
|
|
19
|
+
*/const On={Left:"left",Right:"right",Center:"center"},bt="shift",dn="alt",kt="ctrl",Wi=9,Hi=13,Ni=27,Ui=37,Ki=38,qi=39,Xi=40,Yi=113,yr=3,cn={Horizontal:"horizontal",Vertical:"vertical"};function Jr(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=Jr(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function yn(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Jr(e))&&(o&&(o+=" "),o+=t);return o}var Gi=function(){},Qr=typeof window<"u",Zi=Qr?c.useLayoutEffect:c.useEffect,vr={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const gn=Qr&&window.ResizeObserver!==void 0?function(){var e=c.useState(null),t=e[0],n=e[1],o=c.useState(vr),r=o[0],i=o[1],l=c.useMemo(function(){return new window.ResizeObserver(function(s){if(s[0]){var u=s[0].contentRect,d=u.x,w=u.y,x=u.width,p=u.height,y=u.top,_=u.left,I=u.bottom,R=u.right;i({x:d,y:w,width:x,height:p,top:y,left:_,bottom:I,right:R})}})},[]);return Zi(function(){if(t)return l.observe(t),function(){l.disconnect()}},[t]),[n,r]}:function(){return[Gi,vr]},k=(e,t)=>{const n=c.useCallback((...i)=>e?.(...i),t),o=c.useRef(null);o.current=n;const r=c.useCallback((...i)=>o.current?.(...i),[]);if(o.current)return r},Ji=e=>{const{style:t,orientation:n=cn.Vertical,...o}=e,r=n===cn.Vertical;return T.jsx("div",{style:{paddingBottom:"0px",paddingRight:"0px",paddingLeft:r?"0px":"3px",paddingTop:r?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...t},...o,children:T.jsx("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${r?"vertical":"horizontal"} single-button start`,children:T.jsx("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:T.jsx("path",{d:r?"m 3.7274761,0.68060577 1.11969,1.93863003 1.12075,1.93912 c 0.0895,0.155 0.12152,0.33658 0.0904,0.51283 -0.0311,0.17625 -0.12336,0.33591 -0.26054,0.45091 -0.13715,0.11495 -0.31044,0.17793 -0.4894,0.17781 H 0.83095614 c -0.20186,0 -0.39542,-0.0802 -0.53814,-0.2229 -0.14272,-0.14272 -0.22291,-0.33629 -0.22291,-0.53814 -3e-4,-0.13308 0.0347,-0.26385 0.10147,-0.379 l 1.11872996,-1.94066 1.11921,-1.93864003 c 0.13594,-0.23541 0.38717,-0.38047 0.65905,-0.38047 0.27188,0 0.52311,0.14506 0.65905,0.38047 z":"m 0.75051,2.3424298 1.93863,-1.11969 1.93912,-1.12075 c 0.155,-0.0895 0.33658,-0.12152 0.51283,-0.0904 0.17625,0.0311 0.33591,0.12336 0.45091,0.26054 0.11495,0.13715 0.17793,0.31044 0.17781,0.4894 v 4.47742 c 0,0.20186 -0.0802,0.39542 -0.2229,0.53814 -0.14272,0.14272 -0.33629,0.22291 -0.53814,0.22291 -0.13308,3e-4 -0.26385,-0.0347 -0.379,-0.10147 L 2.68911,4.7797998 0.75047,3.6605898 C 0.51506,3.5246498 0.37,3.2734198 0.37,3.0015398 c 0,-0.27188 0.14506,-0.52311 0.38047,-0.65905 z"})})})})},Qi=e=>{const{style:t,orientation:n=cn.Vertical,...o}=e,r=n===cn.Vertical;return T.jsx("div",{style:{paddingLeft:"0px",paddingTop:"0px",paddingRight:r?"0px":"3px",paddingBottom:r?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...t},...o,children:T.jsx("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${r?"vertical":"horizontal"} single-button end`,children:T.jsx("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:T.jsx("path",{d:r?"M 2.412334,5.319396 1.292644,3.3807659 0.17189405,1.4416459 c -0.0895,-0.155 -0.12152,-0.33658 -0.0904,-0.51282998 0.0311,-0.17625 0.12336,-0.33591 0.26054,-0.45091 0.13715,-0.11495 0.31044,-0.17793 0.4894,-0.17781 H 5.308854 c 0.20186,0 0.39542,0.0802 0.53814,0.2229 0.14272,0.14272 0.22291,0.33629 0.22291,0.53813998 3e-4,0.13308 -0.0347,0.26385 -0.10147,0.379 l -1.11873,1.94066 -1.11921,1.9386401 c -0.13594,0.23541 -0.38717,0.38047 -0.65905,0.38047 -0.27188,0 -0.52311,-0.14506 -0.65905,-0.38047 z":"m 5.3893002,3.6575719 -1.9386301,1.11969 -1.93912,1.12075 c -0.155,0.0895 -0.33658,0.12152 -0.51282997,0.0904 -0.17625,-0.0311 -0.33591,-0.12336 -0.45091,-0.26054 -0.11495,-0.13715 -0.17793,-0.31044 -0.17781,-0.4894 V 0.76105195 c 0,-0.20186 0.0802,-0.39542 0.2229,-0.53814 C 0.73562013,0.08019195 0.92919013,1.9467784e-6 1.1310401,1.9467784e-6 1.2641201,-2.9805322e-4 1.3948901,0.03470195 1.5100401,0.10147195 l 1.94066,1.11872995 1.9386401,1.11921 c 0.23541,0.13594 0.38047,0.38717 0.38047,0.65905 0,0.27188 -0.14506,0.52311 -0.38047,0.65905 z"})})})})},zo=(e,t,n,o,r=0)=>{for(let i=0;i<n.length;i++){const l=n[i].getBoundingClientRect();let s=l.left-t,u=s+l.width;if(o){if(s<e&&u>=e)return s}else if(Math.ceil(u)>Math.ceil(e)+2)return u}return r};Object.freeze(Object.defineProperty({__proto__:null,getScrollTo:zo},Symbol.toStringTag,{value:"Module"}));const Uo=c.memo(c.forwardRef((e,t)=>{const{offset:n=0,totalSize:o=0,viewportSize:r=0,style:i,className:l,orientation:s=cn.Vertical,onScrollOffset:u,onScroll:d,showCustomScrollButtons:w=!1,scrollButtonIncrement:x=200,scrollButtonInitialRepeatDelay:p=260,scrollButtonAdditionalRepeatDelay:y=120,createScrollStartButton:_=Ji,createScrollEndButton:I=Qi,...R}=e,ce=k(d,[d]),P=c.useRef(null),[C,{width:D,height:ie}]=gn(),[$,{width:ne,height:ve}]=gn(),K=s===cn.Vertical,N=K?"top":"left",Y=K?"scrollTop":"scrollLeft",O=K?ie:D,h=K?ve:ne,[M,Q]=c.useState(null);c.useEffect(()=>{M!==null&&P.current&&P.current.scrollTo({behavior:"smooth",[N]:M})},[M,K]);const H=c.useCallback((E,ue=!1)=>{if(!P.current)return 0;const X=P.current.querySelector(".scrollbar-viewport"),fe=X.getBoundingClientRect(),ee=X.children,Me=ue?0:zo(E,fe[N],ee,!0,Math.max(0,E-x));return Q(Me),Math.max(0,Me)},[]),A=c.useCallback((E,ue=!1)=>{if(!P.current)return 0;const X=P.current.querySelector(".scrollbar-viewport"),fe=X.getBoundingClientRect(),ee=X.children,Me=Math.ceil(h-O),it=ue?Me:zo(E,fe[N],ee,!1,Math.max(0,E+x));return Q(it),Math.min(Me,it)},[h,O]),q=c.useRef(null),U=c.useCallback(E=>{q.current=n;const ue=E.target[Y];u(ue,r,o),ce?.(E)},[u,r,o,n]);c.useEffect(()=>{const E=q.current;q.current=null,n!==E&&(P.current[Y]=n)},[n,Y]);const me=c.useRef(null),G=c.useRef(null),Ve=c.useCallback(()=>{me.current&&(clearTimeout(me.current),me.current=null,G.current=null)},[]),He=c.useCallback((E,ue,X,fe=p)=>{G.current=E,me.current=setTimeout(()=>{const ee=X?H(G.current||E):A(G.current||E);ee!==G.current?He(ee,!1,X,y):Ve()},ue?0:fe)},[H,A,Ve]);c.useEffect(()=>()=>Ve(),[Ve]);const Fe=n,ct=c.useMemo(()=>{if(!w)return null;const E={orientation:s,disabled:Math.floor(Fe)<=0||Math.floor(h-O)===0,onMouseUp:Ve,onMouseLeave:Ve,onMouseDown:()=>He(Fe,!0,!0)};return _?.(E)},[w,s,Fe,M,h,O]),Se=c.useMemo(()=>{if(!w)return null;const E={orientation:s,disabled:Math.floor(h-O)<=Math.ceil(Fe),onMouseUp:Ve,onMouseLeave:Ve,onMouseDown:()=>He(Fe,!0,!1)};return I?.(E)},[w,s,Fe,M,h,O]);return T.jsxs("div",{ref:t,style:{display:"flex",flex:"1",flexDirection:K?"column":"row",padding:"0",...i},className:yn("_sheetxl-scrollbar_eblx4_6",l),...R,children:[ct,T.jsx("div",{className:"pseudo-scrollbar",style:{flex:"1 1 100%",display:"flex",boxSizing:"content-box",flexDirection:K?"column":"row",justifyContent:"center",alignItems:"center"},ref:C,children:T.jsx("div",{tabIndex:-1,style:{flex:"1 1 100%",overflowY:K?"scroll":"hidden",overflowX:K?"hidden":"scroll",position:"relative",willChange:"transform"},onScroll:U,ref:P,children:T.jsx("div",{ref:$,style:{position:"absolute",height:K?o-r+(ie??0):1,width:K?1:o-r+(D??0)},className:"scrollbar-viewport"})})}),Se]})}));Uo.displayName="Scrollbar";let br=Date.now,sn={},el=1;const Tn=e=>{let t=sn[e]!==null;return t&&(sn[e]=null),t},Sr=(e,t,n,o=0,r)=>{let i=br(),l=i,s=0,u=0,d=el++;if(d%20==0){const x={};for(let p in sn)x[p]=!0;sn=x}const w=function(x){const p=x!==!0,y=br();if(!sn[d]||t&&!t(d))return sn[d]=null,void n(60-u/((y-i)/1e3),d,!1);if(p){const I=Math.round((y-l)/16.666666666666668)-1;for(let R=0;R<Math.min(I,4);R++)w(!0),u++}o&&(s=(y-i)/o,s>1&&(s=1));const _=r?r(s):s;e(_,y,p)!==!1&&s!==1||!p?p&&(l=y,requestAnimationFrame(w)):(sn[d]=null,n(60-u/((y-i)/1e3),d,s===1||o===void 0))};return sn[d]=!0,requestAnimationFrame(w),d};var tl=function(){},nl=function(e){return Math.pow(e-1,3)+1},ol=function(e){return(e/=.5)<1?.5*Math.pow(e,3):.5*(Math.pow(e-2,3)+2)},ei=function(e,t){for(var n in this.__callback=e,this.options={scrollingX:!0,scrollingY:!0,animating:!0,animationDuration:250,bouncing:!0,locking:!0,paging:!1,snapping:!1,zooming:!1,minZoom:.5,maxZoom:3,speedMultiplier:1,scrollingComplete:tl,penetrationDeceleration:.03,penetrationAcceleration:.08},t)this.options[n]=t[n]};ei.prototype={__isSingleTouch:!1,__isTracking:!1,__didDecelerationComplete:!1,__isGesturing:!1,__isDragging:!1,__isDecelerating:!1,__isAnimating:!1,__clientLeft:0,__clientTop:0,__clientWidth:0,__clientHeight:0,__contentWidth:0,__contentHeight:0,__snapWidth:100,__snapHeight:100,__zoomLevel:1,__scrollLeft:0,__scrollTop:0,__maxScrollLeft:0,__maxScrollTop:0,__scheduledLeft:0,__scheduledTop:0,__scheduledZoom:0,__lastTouchLeft:null,__lastTouchTop:null,__lastTouchMove:null,__positions:null,__minDecelerationScrollLeft:null,__minDecelerationScrollTop:null,__maxDecelerationScrollLeft:null,__maxDecelerationScrollTop:null,__decelerationVelocityX:null,__decelerationVelocityY:null,setDimensions:function(e,t,n,o){e!==null&&(this.__clientWidth=e),t!==null&&(this.__clientHeight=t),n!==null&&(this.__contentWidth=n),o!==null&&(this.__contentHeight=o),this.__computeScrollMax(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0)},setPosition:function(e,t){this.__clientLeft=e||0,this.__clientTop=t||0},setSnapSize:function(e,t){this.__snapWidth=e,this.__snapHeight=t},getValues:function(){return{left:this.__scrollLeft,top:this.__scrollTop,right:this.__scrollLeft+this.__clientWidth/this.__zoomLevel,bottom:this.__scrollTop+this.__clientHeight/this.__zoomLevel,zoom:this.__zoomLevel}},getPoint:function(e,t){var n=this.getValues();return{left:e/n.zoom,top:t/n.zoom}},getScrollMax:function(){return{left:this.__maxScrollLeft,top:this.__maxScrollTop}},zoomTo:function(e,t,n,o,r){if(!this.options.zooming)throw new Error("Zooming is not enabled!");r&&(this.__zoomComplete=r),this.__isDecelerating&&(Tn(this.__isDecelerating),this.__isDecelerating=!1);var i=this.__zoomLevel;n===void 0&&(n=this.__clientWidth/2),o===void 0&&(o=this.__clientHeight/2),e=Math.max(Math.min(e,this.options.maxZoom),this.options.minZoom),this.__computeScrollMax(e);var l=e/i,s=l*(this.__scrollLeft+n)-n,u=l*(this.__scrollTop+o)-o;s>this.__maxScrollLeft?s=this.__maxScrollLeft:s<0&&(s=0),u>this.__maxScrollTop?u=this.__maxScrollTop:u<0&&(u=0),this.__publish(s,u,e,t)},zoomBy:function(e,t,n,o,r){this.zoomTo(this.__zoomLevel*e,t,n,o,r)},scrollTo:function(e,t,n,o){if(this.__isDecelerating&&(Tn(this.__isDecelerating),this.__isDecelerating=!1),o!==void 0&&o!==this.__zoomLevel){if(!this.options.zooming)throw new Error("Zooming is not enabled!");e*=o,t*=o,this.__computeScrollMax(o)}else o=this.__zoomLevel;this.options.scrollingX?this.options.paging?e=Math.round(e/this.__clientWidth)*this.__clientWidth:this.options.snapping&&(e=Math.round(e/this.__snapWidth)*this.__snapWidth):e=this.__scrollLeft,this.options.scrollingY?this.options.paging?t=Math.round(t/this.__clientHeight)*this.__clientHeight:this.options.snapping&&(t=Math.round(t/this.__snapHeight)*this.__snapHeight):t=this.__scrollTop,e=Math.max(Math.min(this.__maxScrollLeft,e),0),t=Math.max(Math.min(this.__maxScrollTop,t),0),e===this.__scrollLeft&&t===this.__scrollTop&&(n=!1),this.__publish(e,t,o,n)},scrollBy:function(e,t,n){var o=this.__isAnimating?this.__scheduledLeft:this.__scrollLeft,r=this.__isAnimating?this.__scheduledTop:this.__scrollTop;this.scrollTo(o+(e||0),r+(t||0),n)},doMouseZoom:function(e,t,n,o){var r=e>0?.97:1.03;return this.zoomTo(this.__zoomLevel*r,!1,n-this.__clientLeft,o-this.__clientTop)},doTouchStart:function(e,t){if(e.length===void 0)throw new Error("Invalid touch list: "+e);if(t instanceof Date&&(t=t.valueOf()),typeof t!="number")throw new Error("Invalid timestamp value: "+t);var n,o;this.__interruptedAnimation=!0,this.__isDecelerating&&(Tn(this.__isDecelerating),this.__isDecelerating=!1,this.__interruptedAnimation=!0),this.__isAnimating&&(Tn(this.__isAnimating),this.__isAnimating=!1,this.__interruptedAnimation=!0);var r=e.length===1;r?(n=e[0].pageX,o=e[0].pageY):(n=Math.abs(e[0].pageX+e[1].pageX)/2,o=Math.abs(e[0].pageY+e[1].pageY)/2),this.__initialTouchLeft=n,this.__initialTouchTop=o,this.__zoomLevelStart=this.__zoomLevel,this.__lastTouchLeft=n,this.__lastTouchTop=o,this.__lastTouchMove=t,this.__lastScale=1,this.__enableScrollX=!r&&this.options.scrollingX,this.__enableScrollY=!r&&this.options.scrollingY,this.__isTracking=!0,this.__didDecelerationComplete=!1,this.__isDragging=!r,this.__isSingleTouch=r,this.__positions=[]},doTouchMove:function(e,t,n){if(e.length===void 0)throw new Error("Invalid touch list: "+e);if(t instanceof Date&&(t=t.valueOf()),typeof t!="number")throw new Error("Invalid timestamp value: "+t);if(this.__isTracking){var o,r;e.length===2?(o=Math.abs(e[0].pageX+e[1].pageX)/2,r=Math.abs(e[0].pageY+e[1].pageY)/2):(o=e[0].pageX,r=e[0].pageY);var i=this.__positions;if(this.__isDragging){var l=o-this.__lastTouchLeft,s=r-this.__lastTouchTop,u=this.__scrollLeft,d=this.__scrollTop,w=this.__zoomLevel;if(n!==void 0&&this.options.zooming){var x=w;if(w=w/this.__lastScale*n,x!==(w=Math.max(Math.min(w,this.options.maxZoom),this.options.minZoom))){var p=o-this.__clientLeft,y=r-this.__clientTop;u=(p+u)*w/x-p,d=(y+d)*w/x-y,this.__computeScrollMax(w)}}if(this.__enableScrollX){u-=l*this.options.speedMultiplier;var _=this.__maxScrollLeft;(u>_||u<0)&&(this.options.bouncing?u+=l/2*this.options.speedMultiplier:u=u>_?_:0)}if(this.__enableScrollY){d-=s*this.options.speedMultiplier;var I=this.__maxScrollTop;(d>I||d<0)&&(this.options.bouncing?d+=s/2*this.options.speedMultiplier:d=d>I?I:0)}i.length>60&&i.splice(0,30),i.push(u,d,t),this.__publish(u,d,w)}else{var R=this.options.locking?3:0,ce=Math.abs(o-this.__initialTouchLeft),P=Math.abs(r-this.__initialTouchTop);this.__enableScrollX=this.options.scrollingX&&ce>=R,this.__enableScrollY=this.options.scrollingY&&P>=R,i.push(this.__scrollLeft,this.__scrollTop,t),this.__isDragging=(this.__enableScrollX||this.__enableScrollY)&&(ce>=5||P>=5),this.__isDragging&&(this.__interruptedAnimation=!1)}this.__lastTouchLeft=o,this.__lastTouchTop=r,this.__lastTouchMove=t,this.__lastScale=n}},doTouchEnd:function(e){if(e instanceof Date&&(e=e.valueOf()),typeof e!="number")throw new Error("Invalid timestamp value: "+e);if(this.__isTracking){if(this.__isTracking=!1,this.__isDragging)if(this.__isDragging=!1,this.__isSingleTouch&&this.options.animating&&e-this.__lastTouchMove<=100){for(var t=this.__positions,n=t.length-1,o=n,r=n;r>0&&t[r]>this.__lastTouchMove-100;r-=3)o=r;if(o!==n){var i=t[n]-t[o],l=this.__scrollLeft-t[o-2],s=this.__scrollTop-t[o-1];this.__decelerationVelocityX=l/i*(1e3/60),this.__decelerationVelocityY=s/i*(1e3/60);var u=this.options.paging||this.options.snapping?4:1;(Math.abs(this.__decelerationVelocityX)>u||Math.abs(this.__decelerationVelocityY)>u)&&this.__startDeceleration(e)}else this.options.scrollingComplete()}else e-this.__lastTouchMove>100&&this.options.scrollingComplete();this.__isDecelerating||((this.__interruptedAnimation||this.__isDragging)&&this.options.scrollingComplete(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0,this.__zoomLevel)),this.__positions.length=0}},__publish:function(e,t,n,o){var r=this.__isAnimating;if(r&&(Tn(r),this.__isAnimating=!1),o&&this.options.animating){this.__scheduledLeft=e,this.__scheduledTop=t,this.__scheduledZoom=n;var i=this.__scrollLeft,l=this.__scrollTop,s=this.__zoomLevel,u=e-i,d=t-l,w=n-s,x=function(_,I,R){R&&(this.__scrollLeft=i+u*_,this.__scrollTop=l+d*_,this.__zoomLevel=s+w*_,this.__callback&&this.__callback(this.__scrollLeft,this.__scrollTop,this.__zoomLevel))}.bind(this),p=function(_){return this.__isAnimating===_}.bind(this),y=function(_,I,R){I===this.__isAnimating&&(this.__isAnimating=!1),(this.__didDecelerationComplete||R)&&this.options.scrollingComplete(),this.options.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))}.bind(this);this.__isAnimating=Sr(x,p,y,this.options.animationDuration,r?nl:ol)}else this.__scheduledLeft=this.__scrollLeft=e,this.__scheduledTop=this.__scrollTop=t,this.__scheduledZoom=this.__zoomLevel=n,this.__callback&&this.__callback(e,t,n),this.options.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))},__computeScrollMax:function(e){e===void 0&&(e=this.__zoomLevel),this.__maxScrollLeft=Math.max(this.__contentWidth*e-this.__clientWidth,0),this.__maxScrollTop=Math.max(this.__contentHeight*e-this.__clientHeight,0)},__startDeceleration:function(e){if(this.options.paging){var t=Math.max(Math.min(this.__scrollLeft,this.__maxScrollLeft),0),n=Math.max(Math.min(this.__scrollTop,this.__maxScrollTop),0),o=this.__clientWidth,r=this.__clientHeight;this.__minDecelerationScrollLeft=Math.floor(t/o)*o,this.__minDecelerationScrollTop=Math.floor(n/r)*r,this.__maxDecelerationScrollLeft=Math.ceil(t/o)*o,this.__maxDecelerationScrollTop=Math.ceil(n/r)*r}else this.__minDecelerationScrollLeft=0,this.__minDecelerationScrollTop=0,this.__maxDecelerationScrollLeft=this.__maxScrollLeft,this.__maxDecelerationScrollTop=this.__maxScrollTop;var i=function(d,w,x){this.__stepThroughDeceleration(x)}.bind(this),l=this.options.snapping?4:.1,s=function(){var d=Math.abs(this.__decelerationVelocityX)>=l||Math.abs(this.__decelerationVelocityY)>=l;return d||(this.__didDecelerationComplete=!0),d}.bind(this),u=function(d,w,x){this.__isDecelerating=!1,this.__didDecelerationComplete&&this.options.scrollingComplete(),this.scrollTo(this.__scrollLeft,this.__scrollTop,this.options.snapping)}.bind(this);this.__isDecelerating=Sr(i,s,u)},__stepThroughDeceleration:function(e){var t=this.__scrollLeft+this.__decelerationVelocityX,n=this.__scrollTop+this.__decelerationVelocityY;if(!this.options.bouncing){var o=Math.max(Math.min(this.__maxDecelerationScrollLeft,t),this.__minDecelerationScrollLeft);o!==t&&(t=o,this.__decelerationVelocityX=0);var r=Math.max(Math.min(this.__maxDecelerationScrollTop,n),this.__minDecelerationScrollTop);r!==n&&(n=r,this.__decelerationVelocityY=0)}if(e?this.__publish(t,n,this.__zoomLevel):(this.__scrollLeft=t,this.__scrollTop=n),!this.options.paging&&(this.__decelerationVelocityX*=.95,this.__decelerationVelocityY*=.95),this.options.bouncing){var i=0,l=0,s=this.options.penetrationDeceleration,u=this.options.penetrationAcceleration;t<this.__minDecelerationScrollLeft?i=this.__minDecelerationScrollLeft-t:t>this.__maxDecelerationScrollLeft&&(i=this.__maxDecelerationScrollLeft-t),n<this.__minDecelerationScrollTop?l=this.__minDecelerationScrollTop-n:n>this.__maxDecelerationScrollTop&&(l=this.__maxDecelerationScrollTop-n),i!==0&&(i*this.__decelerationVelocityX<=0?this.__decelerationVelocityX+=i*s:this.__decelerationVelocityX=i*u),l!==0&&(l*this.__decelerationVelocityY<=0?this.__decelerationVelocityY+=l*s:this.__decelerationVelocityY=l*u)}}};var Nt=typeof window<"u"?window:{screen:{},navigator:{}},En=(Nt.matchMedia||function(){return{matches:!1}}).bind(Nt),ti=!1,rl={get passive(){return ti=!0}},Er=function(){};Nt.addEventListener&&Nt.addEventListener("p",Er,rl),Nt.removeEventListener&&Nt.removeEventListener("p",Er,!1);var il=ti,ll="PointerEvent"in Nt,Ko="ontouchstart"in Nt,ni=Ko||"TouchEvent"in Nt&&En("(any-pointer: coarse)").matches,_r=(Nt.navigator.maxTouchPoints||0)>0||ni,oi=Nt.navigator.userAgent||"",sl=En("(pointer: coarse)").matches&&/iPad|Macintosh/.test(oi)&&Math.min(Nt.screen.width||0,Nt.screen.height||0)>=768,ri=(En("(pointer: coarse)").matches||!En("(pointer: fine)").matches&&Ko)&&!/Windows.*Firefox/.test(oi),cl=En("(any-pointer: fine)").matches||En("(any-hover: hover)").matches||sl||!Ko,jo=!_r||!cl&&ri?_r?"touchOnly":"mouseOnly":"hybrid",al=jo==="mouseOnly"?"mouse":jo==="touchOnly"||ri?"touch":"mouse";const ul=Object.freeze(Object.defineProperty({__proto__:null,deviceType:jo,primaryInput:al,supportsPassiveEvents:il,supportsPointerEvents:ll,supportsTouchEvents:ni},Symbol.toStringTag,{value:"Module"})),dl=new Set(["INPUT","TEXTAREA","SELECT"]),ii={};function Ao(){return ul}const we=Object.freeze(Object.defineProperty({__proto__:null,EmptyCssProperties:ii,boundPixel:function(e,t=!1,n=0){return e},createSyntheticEvent:e=>{let t=!1,n=!1;return{nativeEvent:e,currentTarget:e.currentTarget,target:e.target,bubbles:e.bubbles,cancelable:e.cancelable,defaultPrevented:e.defaultPrevented,eventPhase:e.eventPhase,isTrusted:e.isTrusted,preventDefault:()=>{t=!0,e.preventDefault()},isDefaultPrevented:()=>t,stopPropagation:()=>{n=!0,e.stopPropagation()},isPropagationStopped:()=>n,persist:()=>{},timeStamp:e.timeStamp,type:e.type}},detectIt:Ao,focusableNodeNames:dl,toPrettyKeyCode:e=>e==="BracketLeft"?"[":e==="BracketRight"?"]":St.camelToPrettyCase(e)},Symbol.toStringTag,{value:"Module"})),hl=[];function lo(e,t,n=hl){const o=c.useRef(null);return c.useImperativeHandle(e,()=>{if(!o.current)return;const r=o.current,i=t?.();if(!i||typeof i!="object")throw new Error("attributes must return a plain object of values");const l=Object.keys(i),s=l.length;for(let u=0;u<s;u++){const d=l[u],w=i[d];Object.defineProperty(r,d,{value:w,writable:!0,configurable:!0,enumerable:!0})}return r},n),o}const Cr=e=>T.jsx(Uo,{...e}),fl=({width:e,height:t})=>T.jsx("div",{className:"corner",style:{minWidth:`${e}px`,width:`${e}px`,minHeight:`${t}px`,height:`${t}px`}}),li=c.memo(c.forwardRef((e,t)=>{const{children:n,viewport:o,onScrollViewport:r,showHorizontalScrollbar:i=!0,showVerticalScrollbar:l=!0,createScrollCorner:s=fl,createHorizontalScrollbar:u=Cr,createVerticalScrollbar:d=Cr,style:w,touchElement:x,disableTouch:p,...y}=e,_=k(r,[r]),I=lo(t,()=>({isScrollPane:()=>!0}),[]),R=c.useRef(null);c.useEffect(()=>{R.current&&(R.current.__scrollTop===o?.top&&R.current.__scrollLeft!==!o?.left||R.current?.scrollTo(o?.left,o?.top,!1))},[o?.left,o?.top,x]);const ce=c.useCallback((O,h)=>{_?.({left:O,top:h})},[]),P=c.useCallback(O=>{R.current?.doTouchStart(O.touches,O.timeStamp)},[]),C=c.useCallback(O=>{O.preventDefault(),R.current?.doTouchMove(O.touches,O.timeStamp)},[]),D=c.useCallback(O=>{R.current?.doTouchEnd(O.timeStamp)},[]),ie=c.useCallback(({containerWidth:O,containerHeight:h,totalWidth:M,totalHeight:Q})=>{R.current.setDimensions(O,h,M,Q)},[]);c.useEffect(()=>{const O=x??I.current;if(!p&&Ao().supportsTouchEvents&&O&&o){if(!R.current){const h={scrollingX:!0,scrollingY:!0,decelerationRate:.95,penetrationAcceleration:.08};R.current=new ei(ce,h)}Ao().supportsTouchEvents&&(O.addEventListener("touchstart",P),O.addEventListener("touchend",D),O.addEventListener("touchmove",C)),ie({containerWidth:o?.width,containerHeight:o?.height,totalWidth:o?.totalWidth,totalHeight:o?.totalHeight})}return()=>{O?.removeEventListener("touchstart",P),O?.removeEventListener("touchend",D),O?.removeEventListener("touchmove",C)}},[o?.width,o?.height,o?.totalWidth,o?.totalHeight,p,x]);const[$,{width:ne}]=gn(),[ve,{height:K}]=gn(),N=c.useMemo(()=>{const O=d({orientation:cn.Vertical,offset:o?.top,viewportSize:o?.height,totalSize:o?.totalHeight,onScrollOffset:h=>{_?.({top:h})}});return T.jsx("div",{style:{display:"flex",flex:"0"},ref:$,children:O})},[d,o?.top,o?.height,o?.totalHeight]),Y=c.useMemo(()=>{const O=u({orientation:cn.Horizontal,offset:o?.left,viewportSize:o?.width,totalSize:o?.totalWidth,onScrollOffset:h=>_?.({left:h})});return T.jsxs("div",{style:{display:"flex",flex:"none",flexDirection:"row",alignItems:"stretch",justifyContent:"center"},children:[T.jsx("div",{style:{display:"flex",flex:"1 1 100%",flexDirection:"column",width:`calc(100% - ${ne}px)`},children:T.jsx("div",{ref:ve,className:"sizer",children:O})}),l?s({width:ne,height:K}):T.jsx(T.Fragment,{})]})},[u,o?.left,o?.width,o?.totalWidth,l,s,ne,K]);return T.jsx("div",{style:{position:"relative",display:"flex",minWidth:l?`${ne}px`:void 0,minHeight:i?`${K}px`:void 0,...w},...y,ref:I,children:T.jsxs("div",{style:{position:"relative",width:"100%",flex:"1 1 100%",display:"flex",flexDirection:"column",boxSizing:"border-box"},children:[T.jsxs("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:[T.jsx("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:n}),l?N:T.jsx(T.Fragment,{})]}),i?Y:T.jsx(T.Fragment,{})]})})}));li.displayName="ScrollPane";const pl=()=>{const e=document.fullscreenElement;return e?e.querySelector(".fullscreen-portal-root")||e:document.body};let Kn=0;function si(){return c.useEffect(()=>{function e(){const t=document.fullscreenElement;if(!t)return;let n=t.querySelector(".fullscreen-portal-root");n||(n=document.createElement("div"),n.className="fullscreen-portal-root _fullscreen-portal-root_1mjsr_4",t.appendChild(n))}return Kn++,e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e),Kn--,Kn<=0&&(document.querySelectorAll(".fullscreen-portal-root").forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),Kn=0)}},[]),{getPortalContainer:pl}}const gl=100,wl=100,ml=1e6,xl=100,yl=50,vl=c.memo(c.forwardRef((e,t)=>{const{offset:n=0,viewportSize:o=0,totalSize:r=0,minSize:i=0,endGap:l=gl,endScrollIncrement:s=wl,style:u=ii,onMouseDown:d,onScrollOffset:w,onScroll:x,scaleLimit:p=ml,scaleFactor:y=xl,precisionFactor:_=yl,...I}=e;x&&console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");const R=k(d,[d]),ce=()=>({offset:n,totalSize:p===0?r:Math.min(r??0,Math.max(i??0,(n??0)+(o??0))+(l??0))}),[P,C]=c.useState(ce),D=p!==0&&P.totalSize>p?y:1,ie=D/_,$=Math.ceil(P.totalSize/D),ne=Math.ceil(P.offset/D),ve=Math.ceil(o/D),K=c.useCallback(H=>{},[]),[N,Y]=c.useState(!1),O=c.useRef(null);c.useLayoutEffect(()=>{if(!N){O.current={propTotalSize:r,propViewportSize:o,propOffset:n};const H=ce();C(H)}},[r,o,n,N,i,l,s]);const h=k((H,A,q)=>{const U=O.current;O.current=null,U&&U.propTotalSize===r&&U.propViewportSize===o&&U.propOffset===n||(Math.abs(H-ne)<ie&&(H=ne),w?.(H*D,ne,ve))},[w,D,ie,ne,ve]),M=c.useCallback(H=>{document.removeEventListener("mousemove",K),document.removeEventListener("mouseup",M),Y(!1)},[]),Q=c.useCallback(H=>{R?.(H),Y(!0),document.addEventListener("mousemove",K,{passive:!0}),document.addEventListener("mouseup",M,{passive:!0})},[K,M]);return T.jsx(Uo,{ref:t,style:{...u},...I,offset:ne,totalSize:$,viewportSize:ve,onMouseDown:Q,onScrollOffset:h})}));function Co(e,t){if(typeof e=="function")return e(t);e&&(e.current=t)}vl.displayName="VirtualScrollbar";var oo=parseInt(c.version.split(".")[0],10)>=19?function(e){return t=>{const n=[];for(const o of e){const r=Co(o,t),i=typeof r=="function";n.push(i?r:()=>Co(o,null))}return()=>{for(const o of n)o()}}}:function(e){return t=>{for(const n of e)Co(n,t)}};c.memo(c.forwardRef((e,t)=>{const{refFocusStart:n,...o}=e,r=c.useRef(null),i=c.useCallback(()=>{if(n)return void n?.current?.focus();const l=r.current.parentElement.children;let s=[];for(let u=0;u<l.length&&l[u]!==r.current;u++){const d=l[u].getAttribute("tabindex");if(d==null||d==="-1"||l[u].getAttribute("disabled")==="true")continue;const w=l[u];w.focus&&s.push({tabindex:parseInt(d),child:w})}s.length!==0&&(s.sort(function(u,d){return u.tabindex-d.tabindex}),s[0].child.focus())},[n]);return T.jsx("div",{tabIndex:0,ref:oo([r,t]),onFocus:i,...o})})),c.memo(c.forwardRef((e,t)=>{const{className:n,style:o,children:r,radius:i=4,strokeWidth:l=1,strokeColor:s="grey",...u}=e,[d,{width:w,height:x}]=gn(),p=c.useRef(null),y=(ce,P=0)=>{const C=ce/2,D=x-C+P;return function(ie,$,ne=!1){if($===0)return ie;function ve(M,Q,H){let A=Q.x-M.x,q=Q.y-M.y,U=Math.sqrt(A*A+q*q);return K(M,Q,Math.min(1,H/U))}function K(M,Q,H){return{x:M.x+(Q.x-M.x)*H,y:M.y+(Q.y-M.y)*H}}function N(M,Q){M.length>2&&(M[M.length-2]=Q.x,M[M.length-1]=Q.y)}function Y(M){return{x:parseFloat(M[M.length-2]),y:parseFloat(M[M.length-1])}}let O=ie.split(/[,\s]/).reduce(function(M,Q){let H=Q.match("([a-zA-Z])(.+)");return H?(M.push(H[1]),M.push(H[2])):M.push(Q),M},[]).reduce(function(M,Q){return parseFloat(Q)==Q&&M.length?M[M.length-1].push(Q):M.push([Q]),M},[]),h=[];if(O.length>1){let M=Y(O[0]),Q=null;O[O.length-1][0]==="Z"&&O[0].length>2&&(Q=["L",M.x,M.y],O[O.length-1]=Q),h.push(O[0]);for(let H=1;H<O.length;H++){let A=h[h.length-1],q=O[H],U=q===Q?O[1]:O[H+1];if(U&&A&&A.length>2&&q[0]==="L"&&U.length>2&&U[0]==="L"){let me,G,Ve=Y(A),He=Y(q),Fe=Y(U);ne?(me=K(He,A.origPoint||Ve,$),G=K(He,U.origPoint||Fe,$)):(me=ve(He,Ve,$),G=ve(He,Fe,$)),N(q,me),q.origPoint=He,h.push(q);let ct=K(me,He,.5),Se=K(He,G,.5),E=["C",ct.x,ct.y,Se.x,Se.y,G.x,G.y];E.origPoint=He,h.push(E)}else h.push(q)}if(Q){let H=Y(h[h.length-1]);h.push(["Z"]),N(h[0],H)}}else h=O;return h.reduce(function(M,Q){return M+Q.join(" ")+" "},"")}(`M 0 ${C} L ${i-.5} ${C} L ${i-.5} ${D} L ${2*i} ${D} L ${w-2*i} ${D} M ${w-2*i} ${D} L ${w-i} ${D} L ${w-i} ${C} L ${w} ${C}`,i)},_=c.useMemo(()=>y(l),[w,x,i,l]),I=c.useMemo(()=>{if(i===0)return;const ce=i/2;return y(i)+`L ${w} 0 L 0 0 L 0 ${ce}`},[_,i,l]),R=c.useMemo(()=>({style:{clipPath:`path('${I}')`}}),[I]);return T.jsxs("div",{className:n,style:{display:"flex",flexDirection:"row",...o},...u,ref:oo([p,d,t]),children:[c.isValidElement(r)?c.cloneElement(r,R):T.jsx(T.Fragment,{}),T.jsx("svg",{style:{position:"absolute",top:0,left:0,pointerEvents:"none"},width:w,height:x,viewBox:`0 0 ${w} ${x}`,children:T.jsx("path",{d:_,stroke:s,fill:"none",vectorEffect:"non-scaling-stroke",strokeWidth:l})})]})}));const bl={},Sl=e=>{const{onPointerDown:t,style:n,splitDirection:o,paddingBefore:r=0,paddingAfter:i=0,disabled:l,key:s,hitAreaProps:u=bl,...d}=e,w=o==="row",{style:x,className:p,...y}=u;return T.jsx("div",{style:{...n,position:"relative"},...d,children:T.jsx("div",{className:yn("hit-box",p),style:{left:(w?-r:0)+"px",width:`calc(100% + ${w?r+i:0}px)`,top:(w?0:-r)+"px",height:`calc(100% + ${w?0:r+i}px)`,position:"absolute",...x},onPointerDown:l?void 0:t,...y})},s)},qn={},hn=(e,t,n=!0)=>e===null?null:e.pixels!==null?n?e.pixels:t-e.pixels:(n?e.percent:100-e.percent)/100*t,Xn=(e,t=!0)=>e?.percent?`${t?e.percent:100-e.percent}%`:e?.pixels?`${e.pixels}px`:void 0,ln=(e,t)=>{if(e==null)return null;const n={percent:null,pixels:null};let o=t;return typeof e=="string"&&((e=e.trim().toLowerCase()).endsWith("px")?(e=e.substring(0,e.length-2),o=!1):e.endsWith("%")&&(e=e.substring(0,e.length-1),o=!0),e=parseFloat(e)),o?n.percent=e:n.pixels=e,Object.freeze(n)};function vn(e){if(!e)throw new Error("must have a PointerHandlerOptions");const{onPointerDown:t,onPointerUp:n,onPointerMoveOrWait:o,processTouch:r=!1,consumeTouch:i=!0}=e,l=k(t,[t]),s=k(n,[n]),u=k(o,[o]),d=c.useRef(!1),w=e?.timerInitial??230,x=e?.timerContinuous??w/2,p=c.useRef(null),y=c.useRef(null),_=c.useRef(null),I=c.useRef(null),R=c.useCallback(()=>{I.current&&(clearTimeout(I.current),I.current=null)},[]),ce=c.useCallback(N=>{I.current=setTimeout(()=>{window.requestAnimationFrame(()=>{d.current!==!1&&u?.(y.current,_.current,p.current)}),ce(x)},N??w)},[]);c.useEffect(()=>()=>R(),[]);const P=r?"pointer":"mouse",C=c.useCallback(N=>{N.stopPropagation(),N.stopImmediatePropagation(),N.preventDefault()},[]),D=k(N=>{document.removeEventListener(`${P}move`,ne),document.removeEventListener(`${P}up`,D),document.removeEventListener("keydown",ve),document.removeEventListener("keyup",K),document.removeEventListener("touchstart",C,{capture:!0}),document.removeEventListener("touchmove",C,{capture:!0}),window.removeEventListener("blur",ie),R(),window.requestAnimationFrame(()=>{d.current!==!1&&(d.current=!1,s?.(N,_.current,p.current),_.current=null)})},[]),ie=c.useCallback(()=>{d.current!==!1&&(d.current=!1,D(y.current))},[]),$=k(()=>{R(),ce(x),window.requestAnimationFrame(()=>{d.current!==!1&&u?.(y.current,_.current,p.current)})},[x]),ne=k(N=>{y.current=N,$()},[]),ve=k(N=>{_.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},$()},[]),K=k(N=>{_.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},$()},[x]);return k(N=>{N.isDefaultPrevented()||(_.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},l(N,_.current)!==!1&&(p.current=N,y.current=N.nativeEvent,document.addEventListener(`${P}up`,D,{passive:!1}),document.addEventListener(`${P}move`,ne,{passive:!1}),document.addEventListener("keydown",ve,{passive:!1}),document.addEventListener("keyup",K,{passive:!1}),window.addEventListener("blur",ie,{passive:!0}),r&&i&&(document.addEventListener("touchstart",C,{passive:!1,capture:!0}),document.addEventListener("touchmove",C,{passive:!1,capture:!0})),d.current=!0,ce(w)))},[w,r])}c.memo(c.forwardRef((e,t)=>{const{elementBefore:n,elementAfter:o,splitDirection:r="row",fixedPane:i=null,position:l,onPositionChange:s,minBefore:u,maxBefore:d,minAfter:w,maxAfter:x,children:p,className:y,style:_,disabled:I=!1,onDragStart:R,onDragResize:ce,onDragFinish:P,resizerProps:C=qn,paneProps:D=qn,paneBeforeProps:ie=qn,paneAfterProps:$=qn,createResizer:ne=Sl}=e;if(p)throw new Error("Use elementBefore and elementAfter instead of children.");const ve=c.useMemo(()=>c.isValidElement(o)&&c.isValidElement(n),[o,n]),K=c.useMemo(()=>{let J=null;i&&(i==="before"?J=0:i==="after"&&(J=1));const Ze=J===null;return{fixedPaneOffset:J,isPercent:Ze,minBefore:ln(u,Ze),maxBefore:ln(d,Ze),minAfter:ln(w,Ze),maxAfter:ln(x,Ze)}},[u,d,w,x]),N=k(s,[s]),[Y,O]=c.useState(()=>ln(l,i===null));c.useEffect(()=>{O(ln(l,i===null))},[l,i]);const[h,{width:M,height:Q}]=gn(),[H,{width:A,height:q}]=gn(),U=r==="row"?A:q,me=r==="row"?M:Q,G=c.useMemo(()=>((J,Ze,Ne,lt)=>{const Ee=[null,null],Pe=[null,null];if(J||(J={percent:lt.fixedPaneOffset===null?50:null,pixels:lt.fixedPaneOffset===null?null:0}),Ze===0)return J?.pixels!=null?lt.fixedPaneOffset!==1?(Ee[0]=J?.pixels,Pe[1]=100):(Ee[1]=J?.pixels-Ne,Pe[0]=100):J?.percent!=null&&(lt.fixedPaneOffset!==1?(Pe[0]=J?.percent,Pe[1]=100-J?.percent):(Pe[1]=J?.percent,Pe[0]=100-J?.percent)),{percents:Pe,pixels:Ee,minBefore:Xn(lt.minBefore,!0),maxBefore:Xn(lt.maxBefore,!0),minAfter:Xn(lt.minAfter),maxAfter:Xn(lt.maxAfter)};let tt=hn(J,Ze,lt.fixedPaneOffset!==1),Je=Ze-Ne,De=hn(lt.minBefore,Je,!0)??0,Gt=hn(lt.maxBefore,Je,!0)??Je,Et=0,Qe=0,_t=0,It=Je;Et=(hn(lt.maxAfter,Ze,!1)??Ne)-Ne,Qe=hn(lt.minAfter,Ze,!1)??Ze,_t=Math.max(De,Et),It=Math.min(Gt,Qe),tt=Math.max(_t,Math.min(tt,It)),Qe=Math.min(Je-tt,hn(lt.maxAfter,Je-tt,!0)??Je),Et=Math.min(Je-tt,hn(lt.minAfter,Je-tt,!0)??Je),Ee[0]=tt,Ee[1]=Je-Ee[0];const on=Math.max(0,Math.min(100,tt/Je*100));return Pe[0]=on,Pe[1]=100-Pe[0],{percents:Pe,pixels:Ee,minBefore:`${De}px`,minAfter:`${Et}px`,maxBefore:`${Ee[0]}px`,maxAfter:`${Ee[1]}px`}})(Y,me,U,K),[K,Y,me,U,r]),[Ve,He]=c.useState(!1),Fe=k(R,[R]),ct=k(ce,[ce]),Se=k(P,[P]),E=c.useRef(null),ue=c.useRef(null),X=c.useRef(null),{style:fe,className:ee,...Me}=D,it={minWidth:0,minHeight:0,maxWidth:"100%",maxHeight:"100%",display:"flex",overflow:"hidden",...fe},{className:ut,style:Tt,...dt}=ie,{className:Ut,style:je,...j}=$,Re={flex:"1 1 100%",width:"100%",..._,flexDirection:r,display:"flex"},{className:Ge,style:qe,onPointerDown:ht,...en}=C,Kt=k(J=>{const Ze=ln(J,i===null);O(Ze)},[i]),zt=k(J=>{if(I||!Ve)return;const Ze=Le.current?.getBoundingClientRect();let Ne=0;Ne=r==="row"?(J.clientX??J.touches?.[0]?.clientX)-Ze.x:(J.clientY??J.touches?.[0]?.clientY)-Ze.y,Ne=Math.max(0,Math.min(me,Ne)),K.fixedPaneOffset===1&&(Ne=me-Ne),l&&Y.pixels===Ne||O({pixels:Ne,percent:null}),ct?.(Ne),J.stopPropagation(),J.preventDefault()},[K,r,I,Ve,Y,me]),tn=k(J=>{if(document.removeEventListener("pointermove",zt),document.removeEventListener("touchmove",zt),document.removeEventListener("pointerup",tn),Ve&&(He(!1),Y)){if(Se(Y.pixels),!ln(l,i===null)||Y.pixels!==l){const Ze={...Y};Ze.percent===null&&(Ze.percent=Ze.pixels/me*100),N(Ze)}J.stopPropagation(),J.preventDefault()}},[Y,Ve,l,i,me]),Yt=k(J=>{ht?.(J),J.defaultPrevented||I||Ve||(He(!0),Fe(),document.addEventListener("pointermove",zt,{passive:!1}),document.addEventListener("touchmove",zt,{passive:!1}),document.addEventListener("pointerup",tn,{passive:!1}))},[ht]),Le=lo(t,()=>({setPosition:Kt,isSplitPane:()=>!0}),[]),Ft=c.useMemo(()=>ve?ne?.({key:"resizer",ref:oo([H,ue]),className:yn("resizer",Ge),onPointerDownCapture:Yt,style:{cursor:I?void 0:r==="row"?"ew-resize":"ns-resize",minWidth:r==="row"?"2px":void 0,minHeight:r!=="row"?"2px":void 0,boxSizing:"border-box",pointerEvents:"all",zIndex:1,...qe},splitDirection:r,disabled:I,...en}):null,[ve,Ge,en,r,qe,I]),gt=r==="row"?"Width":"Height",jt={...it,...Tt,flex:K.fixedPaneOffset===0&&G?.pixels[0]!==null?`0 0 ${Math.round(G?.pixels[0])}px`:`1 1 ${Math.round(G?.percents[0]??100)}%`,[`min${gt}`]:G?.minBefore,[`max${gt}`]:o?G?.maxBefore:"100%"},wn={...it,...je,flex:K.fixedPaneOffset===1&&G?.pixels[1]!==null?`0 0 ${Math.round(G?.pixels[1])}px`:`1 1 ${Math.round(G?.percents[1]??100)}%`,[`min${gt}`]:G?.minAfter,[`max${gt}`]:n?G?.maxAfter:"100%"},nn=c.useMemo(()=>n?T.jsx("div",{ref:E,className:yn("before",ee,ut),style:jt,...Me,...dt,children:n},"before"):null,[n,D,ie,K,G]),We=c.useMemo(()=>o?T.jsx("div",{ref:X,className:yn("after",ee,Ut),style:wn,...Me,...j,children:o},"after"):null,[o,D,$,K,G]);return T.jsxs("div",{ref:oo([h,Le]),className:yn("splitPane",r==="row"?"vertical":"horizontal",{dragging:Ve},y),style:Re,children:[nn,Ft,We]})}));const El=({initValue:e,useHookBody:t,applyStateChange:n})=>{const o=c.useRef(e);if(typeof t!="function")throw new Error("function expected as hook body parameter. got "+typeof t);const r=t();return c.useLayoutEffect(()=>{o.current!==r&&(o.current=r,n(r))},[n,r]),null},$o=e=>{console&&console.warn&&console.warn(e)},Io=typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global||void 0;let _l=1,Bo=!1,ci=!1;const Jn=[],bn=[],ro=()=>{bn.forEach(e=>e())},Cl=({automaticContainerInternalUseOnly:e})=>{const[t,n]=c.useState([]),o=c.useRef([]);return o.current=t,e||Bo!==!1||(ci=!0),c.useEffect(()=>{let r=!0;function i(){if(r)return bn[0]!==i?(e||Bo!==!0||$o("SingletonHooksContainer is mounted after some singleton hook has been used.Your SingletonHooksContainer will not be used in favor of internal one."),void n(l=>[])):void n([...Jn])}return bn.push(i),ro(),()=>{r=!1,o.current?.length>0&&$o("SingletonHooksContainer is unmounted, but it has active singleton hooks. They will be reevaluated once SingletonHooksContainer is mounted again"),bn.splice(bn.indexOf(i),1),ro()}},[e]),T.jsx(T.Fragment,{children:t.map(({hook:r,key:i})=>c.createElement(El,{...r,key:i}))})},ai=(e,t,n={})=>{let o,r,i=!1,l=!1,s=[],{unmountIfNoConsumers:u=!1}=n;const d=x=>{r=x,No.unstable_batchedUpdates(()=>s.forEach(p=>p(x)))},w=()=>(l||(r=typeof e=="function"?e():e,l=!0),r);return()=>{const[x,p]=c.useState(w);return c.useEffect(()=>(i||(i=!0,o=(y=>{const _=_l++;return Jn.push({hook:y,key:_}),bn.length===0&&ci===!1&&(Bo=!0,(I=>{if(Io.document&&Io.document.createElement){const R=Io.document.createElement("div");Ci.createRoot(R).render(T.jsx(I,{automaticContainerInternalUseOnly:!0}))}else $o("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.")})(Cl)),ro(),()=>{Jn.splice(Jn.findIndex(I=>I.key===_),1),ro()}})({initValue:e,useHookBody:t,applyStateChange:d})),s.push(p),r!==x&&p(r),()=>{s.splice(s.indexOf(p),1),s.length===0&&u&&(o(),i=!1)}),[]),x}};ai(null,()=>{const[e,t]=c.useState(null);return e});class Il{constructor(t,n,o,r){this._listenersProperties=new Set,this._listenersExecute=new Set,this._key=t,this._target=n,this._applyProps(o||{}),this._callback=r,r===void 0&&(this._callback=()=>{console.log(`implement: ${this.label()} : ${this.description()}`)})}key(){return this._key}_resolve(t,n){if(typeof t=="function"){const o=n??this._context;return t(typeof o=="function"?o():o)}return t}target(){return typeof this._target=="function"?this._target():this._target}label(t,n){const o=this._scopedLabels?.[t]||this._label;let r=null;if(typeof o=="function"){const i=n??this._context;r=o(typeof i=="function"?i():i)}else r=o;return r}description(t){return this._resolve(this._description,t)}tags(t){return this._resolve(this._tags,t)}icon(t){return this._resolve(this._icon,t)}shortcut(){return this._resolve(this._shortcut)}disabled(){return this._resolve(this._disabled)||!this._callback}state(){return this._resolve(this._state)}context(){return typeof this._context=="function"?this._context():this._context}async execute(t,n){if(!this.disabled()&&this._callback){try{let o=!0;if(n?.beforeExecute&&(o=n?.beforeExecute(this,t)),await Promise.resolve(o)===!1)return!1;const r=this._callback.bind(this)(t,this);if(await Promise.resolve(r)===!1)return!1;n?.onExecute?.(this,t),this._notifyExecute(t)}catch(o){return console.warn(o),n?.onError(this,o,t),this._notifyError(t,o),!1}return!0}}addPropertyListener(t,n=!1){if(!t)throw new Error("listener must be specified");const o=this._listenersProperties;return o.add(t),n&&t({},this),()=>{o.delete(t)}}addExecuteListener(t){if(!t)throw new Error("listener must be specified");const n=this._listenersExecute;return n.add(t),function(){n.delete(t)}}_notifyExecute(t){const n=this;this._listenersExecute.forEach(o=>{o.onExecute(n,t)})}_notifyError(t,n){const o=this;this._listenersExecute.forEach(r=>{r.onError?.(o,t,n)})}updateCallback(t){return this._callback=t||null,this}update(t){if(!t)return;const n=this._applyProps(t);return Object.keys(n).length>0&&this._notifyPropertyChange(n),this}_notifyPropertyChange(t){const n=this;this._listenersProperties.forEach(o=>{o(t,n)})}_applyProps(t){let n={},o=this;return Object.keys(t).forEach(r=>{let i=t[r];o["_"+r]!==i&&(o["_"+r]=n[r]=i)}),n}}class be extends Il{}St.getOS()===St.OSType.MacOS||(St.getOS(),St.OSType.IOS),St.getOS()===St.OSType.MacOS||(St.getOS(),St.OSType.IOS),ai({setClipboard:e=>{throw new Error("This is only available via the useClipboard.")},getClipboard:()=>no.Global,refNativeCopy:{current:null},refNativeLastKey:{current:null}},()=>{const[e,t]=c.useState(no.Global);return{setClipboard:n=>t(n),getClipboard:()=>e,refNativeCopy:c.useRef(null),refNativeLastKey:c.useRef(null)}});let Mo=!1,Ml=0;var Rl=typeof document<"u"?c.useLayoutEffect:c.useEffect;const Ir=()=>"sheetxl-ui-"+Ml++,kl=c.useId??function(){const[e,t]=c.useState(()=>Mo?Ir():void 0);return Rl(()=>{e==null&&t(Ir())},[]),c.useEffect(()=>{Mo||(Mo=!0)},[]),e},Sn=({itemType:e,index:t,itemSize:n,instanceProps:o,scale:r=1})=>{let i,l,s;e==="column"?(i=o.columnMetadataMap,l=o.lastMeasuredColumnIndex,s=o.recalcColumnIndices):(i=o.rowMetadataMap,l=o.lastMeasuredRowIndex,s=o.recalcRowIndices);const u=s.length>0;if(t>l){let d=0;if(l>=0){const w=i[l];d=w.offset+w.size}for(let w=l+1;w<=t;w++){let x=u?s.includes(w)?n(w)*r:i[w]?.size||n(w)*r:n(w)*r;i[w]={offset:d,size:x},d+=x}e==="column"?o.lastMeasuredColumnIndex=t:o.lastMeasuredRowIndex=t}return i[t],i[t]},Mr=({itemType:e,itemSize:t,itemCount:n,instanceProps:o,offset:r,scale:i})=>{let l,s;e==="column"?(l=o.columnMetadataMap,s=o.lastMeasuredColumnIndex):(l=o.rowMetadataMap,s=o.lastMeasuredRowIndex);let u=0;return u=(s>0?l[s].offset:0)>=r?ui({itemType:e,itemSize:t,instanceProps:o,high:s,low:0,offset:r,scale:i}):Tl({itemType:e,itemSize:t,itemCount:n,instanceProps:o,index:Math.max(0,s),offset:r,scale:i}),u=Math.min(u,n),u},ui=({itemType:e,itemSize:t,instanceProps:n,high:o,low:r,offset:i,scale:l})=>{for(;r<=o;){const s=r+Math.floor((o-r)/2),u=Sn({itemType:e,itemSize:t,index:s,instanceProps:n,scale:l}).offset;if(u===i)return s;u<i?r=s+1:u>i&&(o=s-1)}return r>0?r-1:0},Tl=({itemType:e,itemSize:t,itemCount:n,instanceProps:o,index:r,offset:i,scale:l})=>{let s=1;for(;r<n&&Sn({itemType:e,itemSize:t,index:r,instanceProps:o,scale:l}).offset<i;)r+=s,s*=2;return ui({itemType:e,itemSize:t,instanceProps:o,high:Math.min(r,n-1),low:Math.floor(r/2),offset:i,scale:l})},di=e=>{const{rowCount:t,columnCount:n,defaultRowHeight:o,getRowHeight:r,defaultColumnWidth:i,getColumnWidth:l}=e||{},s=c.useRef({columnMetadataMap:{},rowMetadataMap:{},lastMeasuredColumnIndex:-1,lastMeasuredRowIndex:-1,recalcColumnIndices:[],recalcRowIndices:[]}),u=k(C=>Mr({itemType:"row",itemCount:t,itemSize:r??(()=>o??20),instanceProps:s.current,offset:C}),[t,r,o]),d=k(C=>C===-1?0:Sn({itemType:"row",index:C,itemSize:r??(()=>o??20),instanceProps:s.current}).offset,[r,o]),w=k(C=>Sn({itemType:"row",index:C,itemSize:r??(()=>o??20),instanceProps:s.current}).size,[r,o]),x=k(C=>Mr({itemType:"column",itemCount:n,itemSize:l??(()=>i??75),instanceProps:s.current,offset:C}),[n,l,i]),p=k(C=>C===-1?0:Sn({itemType:"column",index:C,itemSize:l??(()=>i??75),instanceProps:s.current}).offset,[l,i]),y=k(C=>Sn({itemType:"column",index:C,itemSize:l??(()=>i??75),instanceProps:s.current}).size,[l,i]),[_,I]=c.useReducer(C=>C+1,0),R=()=>({getRowOffset:d,getColOffset:p,getRowIndex:u,getColIndex:x}),[ce,P]=c.useState(()=>e?R():null);return c.useEffect(()=>{P(e?R():null)},[_,t,n,i,o,w,y]),ce},qo="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\",Rr=e=>{if(!e)return null;if(e.eventType==="start")return{type:e.eventType};if(e.eventType==="submit")return{type:e.eventType};if(e.eventType==="cancel")return{type:e.eventType};if(e.eventType==="keyboard")return{type:e.eventType,key:e.event.key};if(e.eventType==="pointer")return{type:e.eventType};if(e.eventType==="coordsChange"){const t={type:e.eventType};return e.activeCoords&&(t.activeCoords=e.activeCoords),t}return{type:e.eventType??"unknown"}},Pl=e=>!0,Ol=e=>!!e&&!(e.ctrlKey||e.metaKey||e.altKey||e.isComposing)&&(!(e.shiftKey||e.key!=="F2"&&e.key!==" "&&e.key!=="Backspace")||(!e.shiftKey||e.key!==" ")&&qo.indexOf(e.key)!==-1),Ll=e=>!!e&&e.type==="dblclick"&&{editMode:!0},Dl=e=>{const{session:t,refLatestCoords:n,handleSubmitEdit:o,handleCancelEdit:r,cellBounds:i,isInBounds:l,getCellEditor:s,propsEditor:u,borderStrokeFill:d="rgb(33, 115, 70)",borderStrokeWidth:w=2,alignment:x=On.Left,style:p,...y}=e,_=c.useRef(null),I=c.useRef(null),[R,ce]=c.useState(!1),P=t.coords,C=c.useCallback(async Y=>{if(_.current?.getBoundingClientRect()){if(Y.eventType==="keyboard"){const h=Y.event,M=new KeyboardEvent(h.type,{bubbles:!0,cancelable:!0,view:window,key:h.key,code:h.code,location:h.location,repeat:h.repeat,isComposing:h.isComposing,charCode:h.charCode,keyCode:h.keyCode,which:h.which,ctrlKey:h.ctrlKey,shiftKey:h.shiftKey,altKey:h.altKey,metaKey:h.metaKey});M.isSynthetic=!0,M.key,I.current?.dispatchEvent(M)}else Y.eventType==="pointer"||console.warn("unsupported event type",Y);await new Promise(h=>requestAnimationFrame(h))}},[]);c.useEffect(()=>{const Y=I.current;return ce(!0),I.current.startEdit?.(t.startEvent),(async()=>{t.editorRefs.push(Y),t.editorRefsDispatchEditorEvent.push(C);const O=[...t.events];for(let h=0;h<O.length;h++)await C(O[h]);t.onMount(Y)})(),()=>{const O=t.editorRefs.indexOf(Y);O!==-1&&t.editorRefs.splice(O,1),t.onUnmount(Y)}},[]);const D=c.useCallback(()=>o(t),[]),ie=c.useCallback(()=>{r(t)},[]),$=n.current&&Z.isEqualCells(n.current,P),ne=l&&$&&R,ve=s({autoFocus:!!t.startEvent?.autoFocus,...u,onSubmitEdit:D,onCancelEdit:ie,ref:I},P),K=i.x+we.boundPixel(-w/2),N=we.boundPixel(i.width+w/2,!0);return T.jsx("div",{tabIndex:0,ref:_,style:{background:void 0,...p,opacity:ne?p?.opacity??1:0,pointerEvents:"auto",position:"absolute",boxSizing:"border-box",top:`${i.y+we.boundPixel(-w/2)}px`,height:we.boundPixel(i.height+w/2,!0),left:`${K}px`,width:N},...y,children:T.jsx("div",{className:"editor-container",style:{position:"absolute",boxSizing:"border-box",left:`${we.boundPixel(1)}px`,top:`${we.boundPixel(1)}px`,width:we.boundPixel(i.width-2,!0),height:we.boundPixel(i.height-2,!0),outline:`${w}px ${d} solid`,boxShadow:"rgba(60,64,67,.35) 2px 2px 6px 3px",maxHeight:"100%",overflow:"hidden",display:"flex"},children:ve})})},Ke=(e,t,n)=>{if(!e)return t;let o=t;const r=n===Ue||n===ot;for(;;){const i=e(o,!r);if(i===0)return o;r?o+=i:o-=i}},Yn=(e,t,n)=>{const o=[];let r=t;for(;r<=n;){const i=Math.max(0,e(r));i===0?(o.push(r),r++):r+=i}return o},zl=(e,t,n,o,r,i)=>{if(!t)return i;let{rowIndex:l,colIndex:s}=e;switch(o){case ot:{l=Ke(n,Math.min(l+1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&l<i;)l=Ke(n,Math.min(++l,i),o),u=t({rowIndex:l,colIndex:s});return l}case nt:{l=Ke(n,Math.max(l-1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&l>i;)l=Ke(n,Math.max(--l,i),o),u=t({rowIndex:l,colIndex:s});return l}case Ue:{s=Ke(n,Math.min(s+1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&s<i;)s=Ke(n,Math.min(++s,i),o),u=t({rowIndex:l,colIndex:s});return s}case et:{s=Ke(n,Math.max(s-1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&s>i;)s=Ke(n,Math.max(--s,i),o),u=t({rowIndex:l,colIndex:s});return s}default:return i}},jl=(e,t=()=>!0,n,o,r,i)=>{let{rowIndex:l,colIndex:s}=e;switch(o){case ot:{l=Ke(n,Math.min(l+1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&l<i;)l=Ke(n,Math.min(++l,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?l:l-1}case nt:{l=Ke(n,Math.max(l-1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&l>i;)l=Ke(n,Math.max(--l,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?l:l+1}case Ue:{s=Ke(n,Math.min(s+1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&s<i;)s=Ke(n,Math.min(++s,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?s:s-1}case et:{s=Ke(n,Math.max(s-1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&s>i;)s=Ke(n,Math.max(--s,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?s:s+1}default:return null}},Al=(e,t,n,o,r,i)=>{if(!t)return i;let l,{rowIndex:s,colIndex:u}=e;o===ot?l={rowIndex:s+1,colIndex:u}:o===nt?l={rowIndex:s-1,colIndex:u}:o===Ue?l={rowIndex:s,colIndex:u+1}:o===et&&(l={rowIndex:s,colIndex:u-1});const d=t(e),w=t(l);var x,p;return(p=w,!(x=d)&&!p||!x&&p||x&&!p?zl:jl)(e,t,n,o,!1,i)??i},kr=(e,t)=>`${e}:${t}`,Tr=(e,t,n,o,r,i)=>{if(n-t>=r-o)return o;let l=o;return e==="nearest"&&(o-t>0?e="start":n-r>0&&(e="end")),e==="start"?l=t:e==="end"?l=n-(r-o):e==="center"&&(l=t+(n-t)/2-(r-o)/2),Math.max(0,Math.min(l,i-(r-o)))},Pr=(e,t,n,o)=>(console.log("todo: implement convertToVisibleRanges"),e),Fo=(e,t=Ue,n,o,r,i=null)=>{if(i&&Z.isEqualSelectionCoords(i,e))return e;const l=e.ranges[e.rangeIndex];if(!Z.isRangesIntersect({rowStart:e.cell.rowIndex,colStart:e.cell.colIndex,rowEnd:e.cell.rowIndex,colEnd:e.cell.colIndex},l))return e;let s={...e.cell},u=e.rangeIndex;switch(t){case Ue:s.colIndex=Ke(r,s.colIndex+1,t);break;case et:s.colIndex=Ke(r,s.colIndex-1,t);break;case ot:s.rowIndex=Ke(o,s.rowIndex+1,t);break;case nt:s.rowIndex=Ke(o,s.rowIndex-1,t)}const d=p=>{if(p){u=e.rangeIndex>=e.ranges.length-1?0:e.rangeIndex+1;const y=e.ranges[u];s={colIndex:y.colStart,rowIndex:y.rowStart}}else{u=e.rangeIndex<=0?e.ranges.length-1:e.rangeIndex-1;const y=e.ranges[u];s={colIndex:y.colEnd,rowIndex:y.rowEnd}}};if(t===Ue&&s.colIndex>l.colEnd&&s.rowIndex===l.rowEnd)d(!0);else if(t===et&&s.colIndex<l.colStart&&s.rowIndex===l.rowStart)d(!1);else if(t===ot&&s.colIndex===l.colEnd&&s.rowIndex>l.rowEnd)d(!0);else if(t===nt&&s.colIndex===l.colStart&&s.rowIndex<l.rowStart)d(!1);else{let p=s.rowIndex,y=s.colIndex;switch(t){case Ue:y>l.colEnd&&(p=Ke(o,p+1,t),y=l.colStart,p>l.rowEnd&&(p=l.rowStart));break;case et:y<l.colStart&&(p=Ke(o,p-1,t),y=l.colEnd,p<l.rowStart&&(p=l.rowEnd));break;case ot:p>l.rowEnd&&(y=Ke(r,y+1,t),p=l.rowStart,y>l.colEnd&&(y=l.colStart));break;case nt:p<l.rowStart&&(y=Ke(r,y-1,t),p=l.rowEnd,y<l.colStart&&(y=l.colEnd))}s={rowIndex:p,colIndex:y}}let w=n(s);if(!Z.isRangeWithinRange(w,l)){const p=Z.intersectRanges(w,l);p&&(w=p)}let x={rowStart:Ke(o,w.rowStart,ot),colStart:Ke(r,w.colStart,Ue),rowEnd:Ke(o,w.rowEnd,nt),colEnd:Ke(r,w.colEnd,et)};if(x.rowStart!==s.rowIndex||x.colStart!==s.colIndex){switch(t){case Ue:e.ranges[u].colStart===x.colStart&&e.ranges[u].colEnd===x.colEnd&&(s.rowIndex=x.rowEnd),s.colIndex=x.colEnd;break;case et:e.ranges[u].colStart===x.colStart&&e.ranges[u].colEnd===x.colEnd&&(s.rowIndex=x.rowStart),s.rowIndex===x.rowStart?s.colIndex=x.colStart+1:s.colIndex=x.colStart;break;case ot:e.ranges[u].rowStart===x.rowStart&&e.ranges[u].rowEnd===x.rowEnd&&(s.colIndex=x.colEnd),s.rowIndex=x.rowEnd;break;case nt:e.ranges[u].rowStart===x.rowStart&&e.ranges[u].rowEnd===x.rowEnd&&(s.colIndex=x.colStart),s.colIndex===x.colStart?s.rowIndex=x.rowStart+1:s.rowIndex=x.rowStart}return Fo({cell:s,ranges:e.ranges,rangeIndex:u},t,n,o,r,i??e)}return{ranges:e.ranges,cell:s,rangeIndex:u}},Or=(e,t)=>{let n,o=0,r=0;return t.colStart<e.colStart?(n=et,o=e.colStart-t.colStart,r=t.colStart):t.colEnd>e.colEnd?(n=Ue,o=t.colEnd-e.colEnd,r=t.colEnd):t.rowStart<e.rowStart?(n=nt,o=e.rowStart-t.rowStart,r=t.rowStart):t.rowEnd>e.rowEnd&&(n=ot,o=t.rowEnd-e.rowEnd,r=t.rowEnd),{direction:n,amount:o,index:r}},io=(e,t=!1,n,o)=>{if(!n)return 0;const r=!t,i=r?1:-1;let l=n(r?e:e+1),s=n(r?e+1:e),u=e+(r?2:-1),d=0;for(;(s-l)*i<=0;){if(r&&u-1>o+1||!r&&u+1<o)return d;l=s,s=n(u),u+=i,d++}return d},Lr=(e,t,n,o,r)=>{const i={};let l=null,s=null;for(let u=0;u<=n.length&&n[u]<=r;u++){const d=n[u];if(d<o)continue;const w=l===d?s:t?e.getColOffset(d):e.getRowOffset(d),x=t?e.getColOffset(d+1):e.getRowOffset(d+1);l=d+1,s=x,i[d]=Object.freeze({offset:w,size:x-w,spanIndex:u})}return Object.freeze(i)},Dr=(e,t,n)=>{const o=e.getColOffset(t.colStart)+(n?.left??0),r=e.getRowOffset(t.rowStart)+(n?.top??0);return{x:o,y:r,width:e.getColOffset(t.colEnd+1)+(n?.right??0)-(n?.left??0)-o,height:e.getRowOffset(t.rowEnd+1)+(n?.bottom??0)-(n?.top??0)-r}},$l=(e,t,n)=>!!n&&!(e<n.x||e>n.x+n.width)&&!(t<n.y||t>n.y+n.height),Ro=(e,t=!0)=>`M ${we.boundPixel(e.left)} ${we.boundPixel(e.top)} L ${we.boundPixel(e.right,!0)} ${we.boundPixel(e.top)} L ${we.boundPixel(e.right,!0)} ${we.boundPixel(e.bottom,!0)} L ${we.boundPixel(e.left)} ${we.boundPixel(e.bottom,!0)} L ${we.boundPixel(e.left)} ${we.boundPixel(e.top)} ${t?"Z":""}`,Vo=e=>{const{linePoints:t,bounds:n,pathProps:o,style:r,...i}=e;return T.jsx("svg",{width:`${we.boundPixel(n.width,!0)}`,height:`${we.boundPixel(n.height,!0)}`,viewBox:`0 0 ${we.boundPixel(n.width,!0)} ${we.boundPixel(n.height,!0)}`,style:{position:"absolute",left:`${we.boundPixel(n.x)}px`,top:`${we.boundPixel(n.y)}px`,width:`${we.boundPixel(n.width,!0)}px`,height:`${we.boundPixel(n.height,!0)}px`,pointerEvents:"none",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top, width, height",willChange:"left, top, width, height, stroke-dashoffset",...r},...i,children:T.jsx("path",{d:`M ${we.boundPixel(t[0])} ${we.boundPixel(t[1])} L ${we.boundPixel(t[2])} ${we.boundPixel(t[3])}`,fill:"none",vectorEffect:"non-scaling-stroke",stroke:"black",...o})})},hi=e=>{const{x:t=0,y:n=0,width:o=0,height:r=0,fill:i,stroke:l,strokeWidth:s=0,strokeDasharray:u,strokeDashoffset:d,clipPath:w,pathBounds:x,pathProps:p,style:y,..._}=e,I=n,R=t,ce=o,P=r;let C=null;if(i){let D=Ro({top:0,left:0,bottom:P,right:ce});x&&(D=D+" "+Ro({top:x.y-I,left:x.x-R,bottom:x.height+x.y-I,right:x.width+x.x-R})),C=[T.jsx("path",{d:D,fill:i,stroke:"none",fillRule:"evenodd"},"fill")]}return T.jsxs("svg",{width:`${we.boundPixel(o,!0)}`,height:`${we.boundPixel(r,!0)}`,viewBox:`0 0 ${we.boundPixel(o,!0)} ${we.boundPixel(r,!0)}`,preserveAspectRatio:"none",style:{position:"absolute",left:`${we.boundPixel(t)}px`,top:`${we.boundPixel(n)}px`,pointerEvents:"none",transitionDuration:"0ms",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top, width, height",willChange:"left, top, width, height, stroke-dashoffset",boxShadow:"rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px",overflow:"visible",...y},..._,children:[C,T.jsx("path",{d:Ro({top:0,left:0,right:ce,bottom:P}),fill:"none",strokeDasharray:u,strokeDashoffset:d,stroke:l,vectorEffect:"non-scaling-stroke",strokeWidth:s,...p})]})},zr=e=>{const{key:t,...n}=e;return T.jsx(Xo,{...n},t)},Xo=c.memo(e=>{const{stroke:t,fill:n,x:o=0,y:r=0,width:i=0,height:l=0,style:s,isAnimatedStroke:u,animatedStrokeProps:d,range:w,cell:x,...p}=e,y=u||!!d,_={name:"walking-offset",dashGap:2,speed:50,dashLength:8,...d};let I=_.dashGap+_.dashLength;const R=_.speed*I,ce=kl().replaceAll(":",""),P=`${_.name}-${ce}`;let C;return c.useEffect(()=>{if(!y)return;const D=`@keyframes ${P} {
|
|
20
20
|
to {
|
|
21
21
|
stroke-dashoffset: 0px;
|
|
22
22
|
}
|
|
23
|
-
}`,ie=document.createElement("style");return ie.appendChild(document.createTextNode(D)),document.head.appendChild(ie),ie.sheet.insertRule(D,0),()=>{document.head.removeChild(ie)}},[y]),y&&(C={strokeDasharray:`${_.dashLength}px ${_.dashGap}px`,strokeDashoffset:`${I}px`,animation:`${P} ${R}ms linear infinite`,willChange:"stroke-dashoffset"}),T.jsx(hi,{x:o,y:r,width:i,height:l,stroke:t,fill:n,shapeRendering:"crispEdges",style:{...C,...s},...p})});function fi(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=fi(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function fn(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=fi(e))&&(o&&(o+=" "),o+=t);return o}Xo.displayName="Selection";const Wo=c.memo(c.forwardRef((e,t)=>{const{x:n=0,y:o=0,borderWidth:r=1,size:i=6,borderStroke:l,corner:s,style:u,className:d,background:w,...x}=e;if(n===0||o===0)return null;let p=!0,y=!0,_=!0,I=!0;switch(s){case"tl":p=!1,y=!1;break;case"bl":p=!1,I=!1;break;case"br":_=!1,I=!1;break;case"tr":y=!1,_=!1}return T.jsx("div",{className:fn("fill-handle",d),style:{position:"absolute",left:n-(i+(p?r:0))/2,top:o-(i+(y?r:0))/2,width:i,height:i,borderLeft:p?`${r}px ${l}`:void 0,borderTop:y?`${r}px ${l}`:void 0,borderRight:_?`${r}px ${l}`:void 0,borderBottom:I?`${r}px ${l}`:void 0,background:w,cursor:"crosshair",pointerEvents:"all",transitionDuration:"0ms",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top",willChange:"left, top",...u},tabIndex:-1,...x})}));Wo.displayName="FillHandle";var Bl=function(){},pi=typeof window<"u",Fl=pi?c.useLayoutEffect:c.useEffect,jr={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const gi=pi&&window.ResizeObserver!==void 0?function(){var e=c.useState(null),t=e[0],n=e[1],o=c.useState(jr),r=o[0],i=o[1],l=c.useMemo(function(){return new window.ResizeObserver(function(s){if(s[0]){var u=s[0].contentRect,d=u.x,w=u.y,x=u.width,p=u.height,y=u.top,_=u.left,I=u.bottom,R=u.right;i({x:d,y:w,width:x,height:p,top:y,left:_,bottom:I,right:R})}})},[]);return Fl(function(){if(t)return l.observe(t),function(){l.disconnect()}},[t]),[n,r]}:function(){return[Bl,jr]};function ko(e,t){if(typeof e=="function")return e(t);e&&(e.current=t)}var Vl=parseInt(c.version.split(".")[0],10)>=19?function(e){return t=>{const n=[];for(const o of e){const r=ko(o,t),i=typeof r=="function";n.push(i?r:()=>ko(o,null))}return()=>{for(const o of n)o()}}}:function(e){return t=>{for(const n of e)ko(n,t)}};const Qn=c.memo(c.forwardRef((e,t)=>{const{range:n,view:o,anchor:r,borderStroke:i="rgb(33, 115, 70)",background:l="white",borderWidth:s=1.5,size:u=22,style:d,className:w,selectionTouchPointerHandler:x,onTouchSelectStart:p,onTouchSelectEnd:y,currentTouchAnchor:_,scrollableElement:I,scrollableRoot:R=document.body,...ce}=e,P=k(p,[p]),C=k(y,[y]),{bounds:D,coordsPivot:ie,key:$}=c.useMemo(()=>{if(!n||!o)return null;let H=null,A=null;switch(r){case"tl":H={colIndex:n.colEnd,rowIndex:n.rowEnd},A={colIndex:n.colStart,rowIndex:n.rowStart};break;case"br":H={colIndex:n.colStart,rowIndex:n.rowStart},A={colIndex:n.colEnd,rowIndex:n.rowEnd};break;case"t":case"l":H={colIndex:n.colEnd,rowIndex:n.rowEnd};break;case"b":H={colIndex:n.colStart,rowIndex:n.rowStart};break;case"r":H={colIndex:n.colStart,rowIndex:n.rowEnd}}let K=o.getRangeCoordsBounds(A?{rowStart:A.rowIndex,colStart:A.colIndex,rowEnd:A.rowIndex,colEnd:A.colIndex}:n);const U=o.getBounds(),me=o.getViewportSize(),G=U.x,Ve=U.y,He=me.width,Fe=me.height;switch(r){case"tl":break;case"br":K.x=K.x+K.width,K.y=K.y+K.height;break;case"t":K.x=He/2-G;break;case"b":K.x=He/2-G,K.y=K.y+K.height;break;case"l":K.y=Fe/2-Ve;break;case"r":K.x=K.x+K.width,K.y=Fe/2-Ve}const ct=o.toClipBounds(K,0);return!ct||ct.width<=0||ct.height<=0||K.x<0||K.y<0||K.x>He||K.y>Fe?{bounds:null,coordsAnchor:null,coordsPivot:null,key:null}:{bounds:K,coordsAnchor:null,coordsPivot:H,key:"touchSelect-"+o.getAnchor()+"-"+r}},[n,o,r]),ne=c.useRef(null),ve=vn(c.useMemo(()=>{const H=A=>r==="t"||r==="b"?{...A,colIndex:void 0}:r==="l"||r==="r"?{...A,rowIndex:void 0}:A;return{processTouch:!0,consumeTouch:!0,onPointerDown:(A,K)=>{const U=H(o.getCellCoordsFromClient(A.clientX,A.clientY));return ne.current={coordsPivot:ie},P?.(r),x.onSelectionPointerDown(A,K,o,U,ie,!1,!0)},onPointerMoveOrWait:(A,K,U)=>{const me=H(o.getCellCoordsFromClient(A.clientX,A.clientY));return x.onSelectionPointerMoveOrWait(A,K,U,o,me,ne.current?.coordsPivot,!0,!0)},onPointerUp:(A,K,U)=>(ne.current=null,C?.(r),x.onPointerUp(A,K,U))}},[x,n,o,r])),[q,{y:N,x:Y}]=gi(),O=c.useRef(null),{getPortalContainer:h}=si(),[M,Q]=c.useState(null);return c.useEffect(()=>{const H=O.current?.getBoundingClientRect();if(!H||!D)return void Q(null);let A=0,K=0,U=I;for(;U;)A+=U.scrollLeft,K+=U.scrollTop,U=R&&U===R.parentElement?null:U.parentElement;Q(No.createPortal(T.jsx("div",{className:fn("touch-select-handle",w),ref:t,style:{position:"absolute",left:A+(H?.x??0)-(u+s)/2,top:K+(H?.y??0)-(u+s)/2,width:u,height:u,borderWidth:`${s}px`,border:i,borderRadius:"50%",background:l,boxShadow:`0 0 0 1.5px ${l}`,cursor:"grab",pointerEvents:"all",opacity:_?0:1,transitionDuration:"160ms",transitionProperty:"opacity",...d},tabIndex:-1,onPointerDown:ve,...ce}),R??h(),$))},[N,Y,D?.x,D?.y,D?.width,D?.height,w,_,l,u,s,i,I]),D?T.jsxs(T.Fragment,{children:[T.jsx("div",{ref:Vl([q,O]),style:{position:"absolute",left:D.x,top:D.y,opacity:0}}),M]}):null}));Qn.displayName="TouchSelectHandle";const Wt=-10,Wl=Object.freeze({rowStart:0,colStart:0,rowEnd:0,colEnd:0}),wi=Object.freeze({colIndex:0,rowIndex:0}),Ho=Object.freeze([]),$t=e=>{if(e&&e.cell&&e.ranges&&e.rangeIndex>-1&&e.rangeIndex<=e.ranges.length)return e;const t={cell:null,ranges:e?.ranges??Ho};return t.rangeIndex=e?.rangeIndex??t.ranges.length-1,t.cell=e?.cell,!t.cell&&t.ranges.length>0&&(t.cell={rowIndex:t.ranges[t.rangeIndex].rowStart,colIndex:t.ranges[t.rangeIndex].colStart}),t.cell||(t.cell=wi),Z.isEqualSelectionCoords(t,e)?e:t},Gn=(e,t,n)=>{const o=e.getVisibleRangeCoords(),r=e.getScrollOrientation();!r.horizontal&&(t.colIndex>o.colEnd||t.colIndex<o.colStart)&&(t={...t,colIndex:t.colIndex>o.colEnd?o.colEnd+1:o.colEnd-1},e=n.current.getViewFromLocation(Ht)),!r.vertical&&(t.rowIndex>o.rowEnd||t.rowIndex<o.rowStart)&&(t={...t,rowIndex:t.rowIndex>o.rowEnd?o.rowEnd+1:o.rowEnd-1},e=n.current.getViewFromLocation(Ht)),e.scrollCellCoordsIntoView(t)},Hl=()=>!1;function eo(e,t){if(!e)throw new Error("Invariant failed")}const Ar={"sheetxl-grid":"_sheetxl-grid_11irg_13"},Nl=Object.freeze({top:0,left:0}),Ul=Object.freeze({bottom:-4,right:-4}),ql=Object.freeze({horizontal:!0,vertical:!0}),$r=[to,Ln,Dn,Ht],Jt=3e3,To={},Yo=c.memo(c.forwardRef((e,t)=>{const{width:n,height:o,rowCount:r=1,columnCount:i=1,defaultRowHeight:l,defaultColumnWidth:s,getRowHeight:u,getColumnWidth:d,layout:w,onViewportScroll:x,onImmediateScroll:p,showGridLines:y=!0,gridLineColor:_="rgb(224, 224, 224)",gridLineRowsProps:I,gridLineColumnsProps:R,clipCells:ce=!0,cursor:P,freezeLeft:C=0,freezeTop:D=0,freezeLeftProps:ie,freezeTopProps:$,cellRenderer:ne,onViewportChange:ve,onFirstRender:q,overlayRenderer:N,overlayProps:Y,overlays:O,overlaysProps:h,allowOverlaysOverflow:M=!1,stageProps:Q,stageWrapper:H=null,hiddenRowsAt:A,hiddenColumnsAt:K,hiddenCellAt:U,getVisibleCells:me,zoom:G=1,enableMouseWheel:Ve=!0,onWheelScroll:He,getCellCoordsAsRangeCoords:Fe=Z.cellToRange,scrollPoint:ct=Nl,style:Se={},...E}=e;eo(ne),eo(!e?.children);const ue=k(p,[p]),X=k(ve,[ve]),fe=k(x,[x]),ee=k(He,[He]),Me=k(q,[q]),it=c.useRef(null),ut=c.useRef(null),Tt=c.useRef(null),[dt,Ut]=c.useReducer(v=>v+1,0),[je,j]=c.useState({left:ct?.left??0,top:ct?.top??0,horizontalScrollDirection:null,verticalScrollDirection:null}),Re=c.useRef(null),Ge=c.useRef(je),{top:Ke,left:ht,verticalScrollDirection:en,horizontalScrollDirection:qt}=je,zt=c.useRef(!1),tn=di({rowCount:r,columnCount:i,defaultRowHeight:l,defaultColumnWidth:s,getRowHeight:u,getColumnWidth:d}),Yt=c.useRef(null),Le=c.useMemo(()=>{const v=w||tn;return Yt.current=null,{getColOffset:L=>v.getColOffset(L)*G,getColIndex:L=>v.getColIndex(L/G),getRowOffset:L=>v.getRowOffset(L)*G,getRowIndex:L=>v.getRowIndex(L/G)}},[tn,w,G]),Ft=(v,L,z)=>{const F=(L?.left??0)+0,V=(L?.top??0)+0;return{getColOffset:he=>v.getColOffset(he)-F,getColIndex:he=>v.getColIndex(he+F),getRowOffset:he=>v.getRowOffset(he)-V,getRowIndex:he=>v.getRowIndex(he+V)}},gt=c.useCallback((v,L=!1)=>io(v,L,Le.getRowOffset,L?0:r),[r,Le?.getRowOffset]),jt=k(A??gt,[A]),wn=c.useCallback((v,L=!1)=>io(v,L,Le.getColOffset,L?i:0),[i,Le?.getColOffset]),nn=k(K??wn,[K]),We=c.useMemo(()=>Math.min(n??800,Le.getColOffset(i)),[Le.getColOffset,i,n]),J=c.useMemo(()=>Math.min(o??600,Le.getRowOffset(r)),[Le.getRowOffset,r,o]),Ze=c.useCallback(v=>{St.canUseDOM&&setTimeout(()=>{it.current?.focus({preventScroll:!0,...v})},0)},[]),Ne=c.useCallback(v=>it.current?.contains(v)||ut.current?.contains(v),[]);c.useEffect(()=>{zt.current&&(Re.current&&Re.current.left!==Ge.current?.left&&Re.current.top!==Ge.current?.top||(Re.current=null,fe?.({left:ht,top:Ke})))},[ht,Ke]);const lt=k(()=>({top:Ke,left:ht}),[Ke,ht]),Ee=c.useMemo(()=>{const v=[];let L=0,z=0;typeof D=="number"?L=D:(L=D.index??0,z=(D.scrollOffset??0)*G);const F=z,V=Le.getRowOffset(L),he=V-F;if(L>0){const st=Ft(Le,{top:z+Le.getRowOffset(0)}),Ae=Le.getRowIndex(F),$e=Le.getRowIndex(V-1);let ft;v[1]={minIndex:Ae,maxIndex:$e,minCoord:0,maxCoord:L-1,minBounds:0,maxBounds:he,visibleIndices:()=>ft||(ft=Object.freeze(Yn(jt,Ae,$e)),ft),layout:st,maxVirtualBounds:V,scrollOffset:z,freezeOffset:z}}const le=Math.max(0,J-he),xe=Ft(Le,{top:Ke+he}),ye=xe.getRowIndex(0),se=xe.getRowIndex(le);let Be;return v[0]={minIndex:ye,maxIndex:se,minCoord:L,maxCoord:r-1,minBounds:he,maxBounds:le,visibleIndices:()=>Be||(Be=Object.freeze(Yn(jt,ye,se)),Be),layout:xe,maxVirtualBounds:Le.getRowOffset(r),scrollOffset:Ke,freezeOffset:(L>0?Le.getRowOffset(L):0)-z},v},[Le.getRowIndex,Le.getRowOffset,jt,J,r,D,Ke,G]),Pe=c.useMemo(()=>{const v=[];let L=0,z=0;typeof C=="number"?L=C:(L=C.index??0,z=(C.scrollOffset??0)*G);const F=z,V=Le.getColOffset(L),he=V-F;if(L>0){const st=Ft(Le,{left:z+Le.getColOffset(0)}),Ae=Le.getColIndex(F),$e=Le.getColIndex(V-1);let ft;v[1]={minIndex:Ae,maxIndex:$e,minCoord:0,maxCoord:L-1,minBounds:0,maxBounds:he,visibleIndices:()=>ft||(ft=Object.freeze(Yn(nn,Ae,$e)),ft),layout:st,maxVirtualBounds:V,scrollOffset:z,freezeOffset:z}}const le=Math.max(0,We-he),xe=Ft(Le,{left:ht+he}),ye=xe.getColIndex(0),se=xe.getColIndex(le);let Be;return v[0]={minIndex:ye,maxIndex:se,minCoord:L,maxCoord:i-1,minBounds:he,maxBounds:le,visibleIndices:()=>Be||(Be=Object.freeze(Yn(nn,ye,se)),Be),layout:xe,maxVirtualBounds:Le.getColOffset(i),scrollOffset:ht,freezeOffset:(L>0?Le.getColOffset(L):0)-z},v},[Le.getColIndex,Le.getColOffset,nn,We,i,C,ht,G]),tt=c.useRef({}),Je=c.useRef([]),De=c.useMemo(()=>{let v={};const L=(F,V,he,le,xe)=>{const ye={vertical:le?.vertical||!1,horizontal:le?.horizontal||!1};if(F>=Pe.length||V>=Ee.length)return null;const se={rowStart:Ee[V].minIndex,colStart:Pe[F].minIndex,rowEnd:Ee[V].maxIndex,colEnd:Pe[F].maxIndex};if(se.rowStart>se.rowEnd||se.colStart>se.colEnd)return null;const Be={getColIndex:_e=>Pe[F].layout.getColIndex(_e),getColOffset:_e=>Pe[F].layout.getColOffset(_e),getRowIndex:_e=>Ee[V].layout.getRowIndex(_e),getRowOffset:_e=>Ee[V].layout.getRowOffset(_e)},st=Object.freeze({left:xe?.left??0,top:xe?.top??0,right:xe?.right??0,bottom:xe?.bottom??0}),Ae=Object.freeze({x:Pe[F].minBounds,y:Ee[V].minBounds,width:Pe[F].maxBounds,height:Ee[V].maxBounds}),$e=(_e,Ye)=>Dr(Be,_e??se,Ye),ft={width:Pe[F].maxVirtualBounds,height:Ee[V].maxVirtualBounds},Xe={left:Pe[F].scrollOffset,top:Ee[V].scrollOffset},Mt={left:Pe[F].freezeOffset,top:Ee[V].freezeOffset},wt={width:We,height:J};let pe=null,pt=null;const Pt=(Mt.top+(le.vertical?Xe.top:0))/G,At=(Mt.left+(le.horizontal?Xe.left:0))/G;return{getStage:()=>it.current??null,getVisibleRangeCoords:()=>se,toClipBounds:(_e,Ye)=>{let ze,rt=0;return Ye===void 0||typeof Ye=="number"?(ze=$e(se),rt=Ye):ze=Ye,((Te,yt,mt=0)=>{if(Te.x>yt.width||Te.y>yt.height)return null;const Ot={left:Te.x,top:Te.y,bottom:Te.height+Te.y,right:Te.width+Te.x},Vt={left:yt.x+mt,top:yt.y+mt,bottom:yt.height-2*mt+yt.y,right:yt.width-2*mt+yt.x},Rt={left:Math.max(Ot.left,Vt.left),top:Math.max(Ot.top,Vt.top),bottom:Math.min(Ot.bottom,Vt.bottom),right:Math.min(Ot.right,Vt.right)},a={x:Rt.left,y:Rt.top,width:Rt.right-Rt.left,height:Rt.bottom-Rt.top};return a.height<0||a.width<0?null:a})(_e??{x:0,y:0,width:Ae.width,height:Ae.height},ze,rt)},toViewBounds:_e=>At===0&&Pt===0&&G===1?_e:{x:(_e.x-At)*G,y:(_e.y-Pt)*G,width:_e.width*G,height:_e.height*G},toAbsoluteBounds:_e=>At===0&&Pt===0&&G===1?_e:{x:_e.x/G+At,y:_e.y/G+Pt,width:_e.width/G,height:_e.height/G},getRelativePointFromClient:(_e,Ye)=>{const ze=on(_e,Ye);return{x:ze.x-Ae.x,y:ze.y-Ae.y}},getLayout:()=>Be,getCellCoordsAsRangeCoords:Fe,getVisibleColumns:()=>Pe[F].visibleIndices(),getVisibleRows:()=>Ee[V].visibleIndices(),getVisibleColumnOffsets:()=>(pe||(pe=Lr(Pe[F].layout,!0,Pe[F].visibleIndices(),se.colStart,se.colEnd)),pe),getVisibleRowOffsets:()=>(pt||(pt=Lr(Ee[V].layout,!1,Ee[V].visibleIndices(),se.rowStart,se.rowEnd)),pt),getTotalRangeCoords:()=>({colStart:Pe[F].minCoord,colEnd:Pe[F].maxCoord,rowStart:Ee[V].minCoord,rowEnd:Ee[V].maxCoord}),getRangeCoordsBounds:$e,scrollCellCoordsIntoView:(_e,Ye)=>_n(_e,Ye,he),getCellCoordsFromClient:(_e,Ye,ze=!1)=>{const rt=on(_e,Ye);if(!rt)return null;const Te=Be.getColIndex(rt.x-Ae.x),yt={rowIndex:Be.getRowIndex(rt.y-Ae.y),colIndex:Te};if(ze)return yt;const mt=Fe(yt);return{rowIndex:mt.rowStart,colIndex:mt.colStart}},getZoom:()=>G,getAnchor:()=>he,getBounds:()=>Ae,getInsets:()=>st,getTotalSize:()=>ft,getViewportSize:()=>wt,getScrollTopLeft:()=>Xe,getFreezeTopLeft:()=>Mt,getScrollOrientation:()=>ye,allViews:()=>v}};let z=v[Ht]=L(0,0,Ht,ql,Ul);return z&&(v[Ht]=z),z=L(0,1,Ln,{horizontal:!0}),z&&(v[Ln]=z),z=L(1,0,Dn,{vertical:!0}),z&&(v[Dn]=z),z=L(1,1,to,{}),z&&(v[to]=z),tt.current=null,v=Object.freeze(v)},[Ee,Pe,Fe]),Gt=Object.keys(De),Et=Pe[0]?.maxVirtualBounds??0,Qe=Ee[0]?.maxVirtualBounds??0,_t=c.useMemo(()=>({left:Pe[1]?Pe[1].layout.getColOffset(Pe[1].maxIndex+1):0,top:Ee[1]?Ee[1].layout.getRowOffset(Ee[1].maxIndex+1):0}),[De]);c.useEffect(()=>{if(Je.current.length>0){for(let v=0;v<Je.current.length;v++)Je.current[v]();Je.current=[]}},[De]);const It=k(()=>({containerWidth:We,containerHeight:J,totalWidth:Et,totalHeight:Qe}),[We,J,Le]);c.useEffect(()=>{!Re.current&&zt.current&&X({top:Ke,left:ht,width:We,height:J,totalWidth:Et,totalHeight:Qe})},[Ke,ht,Et,Qe]),c.useEffect(()=>{zt.current&&X({top:Ke,left:ht,width:We,height:J,totalWidth:Et,totalHeight:Qe})},[We,J]);const on=c.useCallback((v,L)=>{eo(typeof v=="number"&&typeof L=="number");const z=it.current?.getBoundingClientRect();return z?{x:v-z.x,y:L-z.y}:{x:v,y:L}},[]),so=k(v=>De[v]||null,[De]),co=k((v,L)=>{if(Object.keys(De).length===1)return De[Ht];const z=on(v,L);if(!z)return null;const{x:F,y:V}=z;let he=null;const le=$r;for(let xe=0;!he&&xe<le.length;xe++){const ye=De[le[xe]];ye&&$l(F,V,ye.getBounds())&&(he=ye)}return he||(he=De[Ht]),he},[De,Fe]),at=k(()=>De[Ht].getVisibleRangeCoords(),[De[Ht]]),Zt=c.useRef(null),ao=c.useCallback(()=>{Zt.current!==null&&St.cancelTimeout(Zt.current),Zt.current=St.requestTimeout(uo,150)},[]),uo=c.useCallback(()=>{Zt.current=null,j(v=>{const L={...v,verticalScrollDirection:null,horizontalScrollDirection:null};return Ge.current=L,L})},[]),an=k(v=>{const L=v?.left??v?.[0],z=v?.top??v?.[1],F=L!==void 0?Math.min(Et-We,Math.max(Pe?.[1]?.scrollOffset??0,L)):Ge.current.left,V=z!==void 0?Math.min(Qe-J,Math.max(Ee?.[1]?.scrollOffset??0,z)):Ge.current.top;if(Ge.current.left===F&&Ge.current.top===V)return;let he=null,le=null;Ge.current.left>F?he=et:Ge.current.left<F&&(he=Ue),Ge.current.top>V?le=nt:Ge.current.top<V&&(le=ot),St.throttle(()=>{j(xe=>{const ye={...xe,left:F,top:V,horizontalScrollDirection:he,verticalScrollDirection:le};return Ge.current=ye,ye})},17)(),Re.current?.top===V&&Re.current?.left===F||(Re.current={left:F,top:V},ue({left:F,top:V}),X({left:F,top:V,width:We,height:J,totalWidth:Et,totalHeight:Qe})),ao()},[Et,Qe,Ee,Pe]);c.useEffect(()=>{Re.current||an({left:ht,top:Ke})},[Et,We,Qe,J]),c.useLayoutEffect(()=>{Re.current={left:ct?.left,top:ct?.top},an(Re.current)},[ct?.left,ct?.top]);const An=k(v=>{const L=v?.left??v?.[0],z=v?.top??v?.[1],F=v?.behavior??"auto",V={left:Ge.current.left+(L??0),top:Ge.current.top+(z??0)};F&&(V.behavior=F),an(V)},[Et,We,Qe,J]),$n=c.useCallback(v=>{let L=null;if(Object.keys(De).length>1){const z=$r;for(let F=0;!L&&F<z.length;F++){const V=De[z[F]];V&&Z.isCellWithinRange(v,V.getVisibleRangeCoords())&&(L=V)}}return L||(L=De[Ht]),L},[De]),_n=k((v,L={inline:"nearest",block:"nearest"},z=null)=>{const F={rowIndex:0,colIndex:0,...v};let V=null;if(z!==null){if(V=De[z],V===null)return new Promise((wt,pe)=>{pe("Invalid view")})}else V=$n(F);const he=Fe(F),le=V.getLayout(),xe=le.getColOffset(he.colStart),ye=le.getRowOffset(he.rowStart),se=le.getColOffset(he.colEnd+1),Be=le.getRowOffset(he.rowEnd+1),st=V.getBounds(),Ae=V.getTotalSize(),$e=V.getScrollTopLeft(),ft=((wt,pe,pt=!0)=>(pt=pt===!0?{block:"start",inline:"end"}:pt===!1?{block:"end",inline:"end"}:{block:"end",inline:"end",...pt},{left:Tr(pt.inline,wt.x,wt.x+wt.width,pe.left,pe.left+pe.width,pe.totalWidth),top:Tr(pt.block,wt.y,wt.y+wt.height,pe.top,pe.top+pe.height,pe.totalHeight)}))({x:xe+$e.left,y:ye+$e.top,width:se-xe,height:Be-ye},{left:$e.left,top:$e.top,width:st.width,height:st.height,totalWidth:Ae.width,totalHeight:Ae.height},L),Xe={...ft};Xe.left>ht?Xe.left+=20:Xe.left<ht&&(Xe.left-=0),Xe.top>Ke?Xe.top+=20:Xe.top<Ke&&(Xe.top-=0);const Mt=V.getScrollOrientation();return Mt.horizontal&&v.colIndex!==void 0||delete Xe.left,Mt.vertical&&v.rowIndex!==void 0||delete Xe.top,new Promise((wt,pe)=>{try{an(Xe),wt(Xe)}catch(pt){pe(pt)}})},[Et,Qe,De,Fe]),mn=k(v=>{const L=v.shiftKey;v.preventDefault();const{deltaX:z,deltaY:F,deltaMode:V}=v;if(Tt.current||ee?.(v)===!1)return;let le=L?F:z,xe=F;const ye=L||Math.abs(le)>Math.abs(xe);V===1&&(xe*=0),Tt.current=window.requestAnimationFrame(()=>{Tt.current=null,An(ye?{left:le}:{top:xe})})},[Et,We,Qe,J,ee]),Cn=c.useCallback((v=null)=>{Yt.current=null,tt.current=null,Ut()},[]);c.useLayoutEffect(()=>{Cn()},[ne]);const un=lo(t,()=>({stage:it.current,focus:Ze,contains:Ne,invalidate:Cn,scrollTo:an,scrollBy:An,scrollCellCoordsIntoView:_n,getScrollPosition:lt,getDimensions:It,getViewport:at,handleWheel:mn,rowCount:r,columnCount:i,getLayout:()=>Le,getRelativePointFromClient:on,getViewFromClient:co,getViewFromCellCoords:$n,getViewFromLocation:so,onViewChangeOnce:v=>{Je.current.push(v)}}),[r,i,De]);c.useEffect(()=>(Ve&&un.current?.addEventListener("wheel",mn,{passive:!1}),zt.current=!0,Re.current=null,()=>{un.current?.removeEventListener("wheel",mn)}),[Ve]);const In=c.useRef([]),ho=(v,L)=>{!v||!N||(In.current=[],L.push(((z,F)=>{const V=`view:${z.getAnchor()}:overlay:${L.length}`,he=N?.({key:V,view:z},xe=>In.current[F]=xe);if(!he)return null;const le=z.getBounds();return T.jsx("div",{style:{position:"absolute",left:"0px",top:"0px",width:`${le.width}px`,height:`${le.height}px`,overflow:"hidden"},children:he},`overlay-${z.getAnchor()}-${F}`)})(v,0)))},fo=c.useMemo(()=>{const v={},L=Object.keys(De);for(let z=0;z<L.length;z++){const F=L[z],V=[];ho(De[F],V),v[F]={overlays:V}}return v},[dt,N,r,i,Ee,Pe]),Bn=(v,L,z,F,V,he,le)=>{if(!v)return;const xe=v.getVisibleColumns(),ye=v.getVisibleRows();if(xe.length===0||ye.length===0)return;let se=null;if(me)se=me(v);else{se=[];for(let Ye=0;Ye<ye.length;Ye++)for(let ze=0;ze<xe.length;ze++){const rt={rowIndex:ye[Ye],colIndex:xe[ze]};if(U?.(rt))continue;const Te={coords:rt,range:Fe(rt)};se.push(Te)}}const Be=v.getVisibleColumnOffsets(),st=v.getVisibleRowOffsets(),Ae=v.getScrollTopLeft(),$e=v.getFreezeTopLeft(),ft=Ae.left+$e.left,Xe=Ae.top+$e.top,Mt=Math.trunc(ft/Jt),wt=Math.trunc(Xe/Jt),pe={},pt=(Ye,ze,rt,Te,yt)=>{const mt=`view:${Ye.getAnchor()}:cell:${kr(ze.rowIndex,ze.colIndex)}`,Ot=Te.x,Vt=Te.y,Rt=Math.trunc((ft+Ot)/Jt)-Mt,a=Math.trunc((Xe+Vt)/Jt)-wt;pe[a]||(pe[a]={});let f=pe[a][Rt];f||(f=pe[a][Rt]=[]);let m=he?.get(mt);if(!m){const g=(ft+Ot)%Jt,b=(Xe+Vt)%Jt;m=ne({key:mt,coords:ze,bounds:Te,zoom:G,range:rt,view:Ye,value:yt,style:{left:we.boundPixel(g),top:we.boundPixel(b),width:we.boundPixel(Te.width,!0),height:we.boundPixel(Te.height,!0)}})}le?.set(mt,m),f.push(m)};for(let Ye=0;se&&Ye<se.length;Ye++){const ze=se[Ye],rt=ze?.coords??ze;if(!rt)continue;const Te=ze?.range??{rowStart:rt.rowIndex,colStart:rt.colIndex,rowEnd:rt.rowIndex,colEnd:rt.colIndex},yt=v.getVisibleRangeCoords();if(!Z.isRangesIntersect(Te,yt)&&!Z.isRangeWithinRange(Te,yt))continue;const mt=Te&&!Z.isSingleCell(Te);if(!mt&&U?.(rt))continue;const Ot=rt.rowIndex,Vt=rt.colIndex,Rt=st[Ot],a=Be[Vt];let f=null;Rt&&a&&(f={x:a.offset,y:Rt.offset,width:a.size,height:Rt.size});const m=kr(Te.rowStart,Te.colStart);if(mt){if(V.has(m))continue;V.add(m),Te.rowEnd-Te.rowStart>0&&z.push(Te),Te.colEnd-Te.colStart>0&&F.push(Te)}if(mt&&(f=Dr(v.getLayout(),Te)),!f){console.warn("no bounds for cell",m);continue}const g=ze?.value;pt(v,rt,Te,f,g)}const Pt=ft%Jt,At=Xe%Jt,_e=Object.keys(pe);for(let Ye=0;Ye<_e.length;Ye++){const ze=pe[_e[Ye]];if(!ze)continue;const rt=Object.keys(ze);for(let Te=0;Te<rt.length;Te++){const yt=ze[rt[Te]];if(!yt)continue;const mt=parseInt(_e[Ye]),Ot=parseInt(rt[Te]),Vt=mt+wt,Rt=Ot+Mt,a=`view:${v.getAnchor()}:segment:${Rt}:${Vt}`;L.push(T.jsx("div",{className:"cell-container",style:{transform:`translate(${we.boundPixel(Ot*Jt-Pt,!0)}px, ${we.boundPixel(mt*Jt-At,!0)}px)`,willChange:"transform"},children:yt},a))}}},Kt=c.useMemo(()=>{const v=Yt.current,L=new Map,z={},F=Object.keys(De);for(let V=0;V<F.length;V++){const he=F[V],le=[],xe=[],ye=[];Bn(De[he],ye,le,xe,new Set,v,L),z[he]={cells:ye,rangesH:le,rangesV:xe}}return Yt.current=L,z},[dt,r,i,Ee,Pe,y,Se,ce,U,me,Fe]),Fn=(v,L,z,F,V)=>{if(v)if(L){const he=`view:${v.getAnchor()}:hl:`,le=v.getVisibleRows();if(!le||le.length===0)return;const xe=0,ye=v.getBounds().width;let se=[];const Be=V.sort(Z.rowFirstRangeComparator),st=v.getVisibleRangeCoords();for(let Ae=0;Ae<le.length&&le[Ae]<=st.rowEnd;Ae++){const $e=le[Ae];if($e<st.rowStart)continue;let ft=!1;for(;Be.length>0&&Be[0].rowStart<=$e;){const pe=Be.shift();pe.rowEnd>$e&&(se.push(pe),ft=!0)}ft&&(se=se.sort(Z.columnFirstRangeComparator));const Xe=v.getLayout(),Mt=Xe.getRowOffset($e+1);let wt=xe;for(let pe=0;pe<se.length+1;pe++){let pt=wt,Pt=ye;const At=se[pe];pe<se.length&&(Pt=Math.min(ye,Xe.getColOffset(At.colStart)),wt=Math.min(ye,Xe.getColOffset(At.colEnd+1))),F.push(c.createElement("path",{d:`M ${we.boundPixel(pt)} ${we.boundPixel(Mt,!1,z)} L ${we.boundPixel(Pt)} ${we.boundPixel(Mt,!1,z)}`,stroke:_,strokeWidth:1,vectorEffect:"non-scaling-stroke",...I,key:he+$e+":"+pe}))}for(let pe=se.length-1;pe>=0;pe--)se[pe].rowEnd<=le[Ae+1]&&se.splice(pe,1)}}else{const he=`view:${v.getAnchor()}:vl:`,le=v.getVisibleColumns();if(!le||le.length===0)return;const xe=0,ye=v.getBounds().height;let se=[];const Be=V.sort(Z.columnFirstRangeComparator),st=v.getVisibleRangeCoords();for(let Ae=0;Ae<le.length&&le[Ae]<=st.colEnd;Ae++){const $e=le[Ae];if($e<st.colStart)continue;let ft=!1;for(;Be.length>0&&Be[0].colStart<=$e;){const pe=Be.shift();pe.colEnd>$e&&(se.push(pe),ft=!0)}ft&&(se=se.sort(Z.rowFirstRangeComparator));const Xe=v.getLayout(),Mt=Xe.getColOffset($e+1);let wt=xe;for(let pe=0;pe<se.length+1;pe++){let pt=wt,Pt=ye;const At=se[pe];pe<se.length&&(Pt=Math.min(ye,Xe.getRowOffset(At.rowStart)),wt=Math.min(ye,Xe.getRowOffset(At.rowEnd+1)));let _e=_;F.push(T.jsx("path",{d:`M ${we.boundPixel(Mt,!1,z)} ${we.boundPixel(pt)} L ${we.boundPixel(Mt,!1,z)} ${we.boundPixel(Pt)}`,stroke:_e,strokeWidth:1,vectorEffect:"non-scaling-stroke",...R},he+$e+":"+pe))}for(let pe=se.length-1;pe>=0;pe--)se[pe].colEnd<=le[Ae+1]&&se.splice(pe,1)}}},Mn=v=>{if(!Kt)return;const L={};for(let z=0;z<Gt.length;z++){const F=Gt[z],V=De[F],he=[];Fn(V,v,0,he,v?Kt[F].rangesH:Kt[F].rangesV);const le=V.getRangeCoordsBounds(),xe=Math.ceil(le.width),ye=Math.ceil(le.height);L[F]=T.jsx("svg",{width:`${xe}`,height:`${ye}`,viewBox:`0 0 ${xe} ${ye}`,preserveAspectRatio:"none",shapeRendering:"crispEdges",style:{position:"absolute"},children:he})}return L},Vn=c.useMemo(()=>y===!0||y?.horizontal===!0?Mn(!0):null,[dt,y,Ee,D,C,_,I,r,i,We,Et,Kt]),Wn=c.useMemo(()=>y===!0||y?.vertical===!0?Mn(!1):null,[dt,y,Pe,D,C,_,R,r,i,J,Qe,Kt]),po=c.useMemo(()=>_t.left===0?null:T.jsx(Vo,{linePoints:[0,0,0,J+1],bounds:{x:_t.left,y:0,width:1,height:J+1},...ie}),[dt,_t.left,J,ie]),go=c.useMemo(()=>_t.top===0?null:T.jsx(Vo,{linePoints:[0,0,We+1,0],bounds:{x:0,y:_t.top,width:We+1,height:1},...$}),[dt,_t.top,We,$]),Rn=c.useMemo(()=>{const v=[],L=z=>{if(!z||!De[z])return;const F=De[z].getBounds();return T.jsxs("div",{style:{position:"absolute",pointerEvents:"none",left:F.x,top:F.y,width:F.width,height:F.height,clip:`rect(0, ${F.width+1}px, ${F.height+1}px, 0)`},className:`view view-${z}`,children:[Vn?.[z],Wn?.[z],Kt?.[z].cells]},`view:${z}`)};for(let z=0;z<Gt.length;z++)v.push(L(Gt[z]));return T.jsx(T.Fragment,{children:v})},[De,Vn,Wn,Kt]),wo=c.useMemo(()=>{if(!t)return;const v=(le,xe,ye,se)=>{if(!se||se.length===0)return;const Be=[];for(let st=0;st<se.length;st++){const Ae=se[st];let $e=le?.get(Ae);$e!==To&&($e=Ae(ye)??To),xe.set(Ae,$e),$e&&$e!==To&&Be.push($e)}return Be},L=(le,xe,ye)=>{if(!ye)return;const se=ye.getBounds(),Be=ye.getInsets(),st=ye.getAnchor();return T.jsxs("div",{className:fn("view",`view-${st}`,Ar.view),style:{position:"absolute",pointerEvents:"none",left:se.x-Be.left,top:se.y-Be.top,width:se.width-(Be.left+Be.right),height:se.height-(Be.top+Be.bottom),clipPath:M?"inset(-2px)":"inset(0px)"},children:[v(le,xe,ye,O),fo?.[st].overlays]},`view:${st}`)},z=tt.current,F={},V=[],he=Object.keys(De);for(let le=0;le<he.length;le++){const xe=he[le],ye=z?.[xe],se=F[xe]=new Map;V.push(L(ye,se,De[xe]))}return tt.current=F,V},[dt,De,M,O]),mo=c.useMemo(()=>{const{style:v,...L}=Q??{};return T.jsx("div",{style:{width:We,height:J,...v},className:"sheetxl-stage",tabIndex:0,ref:it,...L,...E,children:H?H(Rn):Rn})},[We,J,Rn,Q,H]),Hn=c.useRef(!1);return c.useEffect(()=>{!Hn.current&&Kt&&(Hn.current=!0,Me?.(un.current))},[Kt]),T.jsxs("div",{className:fn("sheetxl-grid",Ar["sheetxl-grid"]),style:{overflow:"visible",cursor:P,maxWidth:We,maxHeight:J,width:We,height:J,...Se},ref:un,children:[mo,T.jsxs("div",{className:fn("sheetxl-overlays"),ref:ut,...h,children:[wo,po,go]})]})}));Yo.displayName="BaseGrid";const Go=c.memo(c.forwardRef((e,t)=>{const{width:n,height:o,style:r={},className:i,...l}=e,[s,{width:u,height:d}]=gi(),w=n??u,x=o??d;return T.jsx("div",{className:i,style:{...r},children:T.jsx("div",{style:{position:"relative",top:"0px",left:"0px",width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",boxSizing:"content-box"},ref:s,children:T.jsx(Yo,{ref:t,width:w,height:x,...l})})})}));Go.displayName="Grid";const mi=c.memo(c.forwardRef((e,t)=>{const{showVerticalScrollbar:n,showHorizontalScrollbar:o,createHorizontalScrollbar:r,createVerticalScrollbar:i,createScrollCorner:l,viewport:s,onScrollViewport:u,style:d={},className:w,onScroll:x,...p}=e,[y,_]=c.useState(null),I=c.useRef(null),R=c.useRef(null);eo(!s),c.useImperativeHandle(t,()=>R.current&&I.current?Object.assign(R.current,I.current):null);const ce=c.useCallback(P=>{R.current?.scrollTo(P),u?.(P)},[]);return T.jsx(li,{className:w,style:d,ref:I,showVerticalScrollbar:n,showHorizontalScrollbar:o,createHorizontalScrollbar:r,createVerticalScrollbar:i,createScrollCorner:l,viewport:y,onScrollViewport:ce,children:T.jsx(Go,{style:{width:"100%",height:"100%"},...p,onViewportChange:P=>_(P),ref:R})})}));mi.displayName="ScrollableGrid";const Br=()=>!1,xi=c.memo(e=>{const{index:t,value:n,zoom:o,zoomScale:r=100,headerText:i=O=>`${O}`,headerStyle:l,headerStyleSelect:s=l,headerStyleSelectAll:u=s,headerStyleHover:d=u,verticalPadding:w=0,horizontalPadding:x=0,isSelected:p=Br,isSelectedAll:y=Br,coords:_,bounds:I,range:R,orientation:ce,view:P,style:C,...D}=e,ie=r/100,$=c.useRef(null),[ne,ve]=c.useState(!1),q=p?.(t)||!1,N=y?.(t)?u:q?s:l;let Y=N;if(ne){let O=d;typeof d=="function"&&(O=d(N)),Y=St.mergeContentful(N,O)}return T.jsx("div",{ref:$,style:{background:Y.fill,color:Y.text?.fill,fontFamily:Y.text?.fontFamily??l.text?.fontFamily,fontSize:96*(Y.text?.fontSize??11)/72*ie,fontStyle:Y.text?.fontStyle,fontWeight:Y.text?.fontWeight,lineHeight:1.2,display:"flex",justifyContent:"center",alignItems:"end",pointerEvents:"auto",paddingBottom:`${ie}px`,...C,left:C.left-(ce===Bt?1:0),top:C.top-(ce===Qt?1:0),width:C.width+1,height:C.height+1,overflow:"hidden"},...D,onMouseMove:O=>{we.detectIt().primaryInput!=="touch"&&O.buttons===0&&ve(!0)},onMouseOut:O=>{ve(!1)},children:i(t)})});xi.displayName="HeaderRenderer";const yi="ew-resize",vi="ns-resize",bi=c.memo(c.forwardRef((e,t)=>{const{orientation:n,view:o,index:r,className:i,style:l,disabled:s=!1,disabledResize:u=!1,isNextHidden:d,isHidden:w,isSelected:x,isSelectedAll:p,showTouchDivider:y,headerStyle:_,headerStyleSelect:I,headerStyleSelectAll:R,headerStyleHover:ce,bounds:P,onPointerDown:C,onAutoFit:D,...ie}=e,$=n===Bt;let ne=_;x&&I&&(ne=I),p&&R&&(ne=R);const ve=we.detectIt().primaryInput==="touch";let q=$?14:8,N=q/2,Y=0;d&&(Y=-2),w&&(Y=2),w&&(q=q/2+Y,N=2*Y);let O=ne.dividerStrokeFill??ne.strokeFill;return!(x||p)&&Y===0&&(O=`linear-gradient(${$?180:90}deg, ${ne.fill}, ${O} 55%, ${O} 100%)`),T.jsxs("div",{className:fn("header-divider",{disabled:s},i,`index-${r}`),ref:t,onPointerDown:ve?void 0:C,onDoubleClick:ve?void 0:()=>D?.(),style:{top:($?0:-q/2+(Y-1))+"px",left:($?-q/2+(Y-1):0)+"px",width:$?q:"calc(100% + 1px)",height:$?"calc(100% + 1px)":q,position:"absolute",overflow:"visible",pointerEvents:"all",cursor:s||u||ve?void 0:$?yi:vi,...l},...ie,children:[T.jsx("div",{style:{position:"relative",top:`${$?0:N}px`,left:`${$?N:0}px`,width:$?1:"100%",height:$?"100%":1,background:O},onDoubleClick:()=>D?.()}),y&&ve?T.jsx("div",{style:{position:"absolute",cursor:"grab",zIndex:1,borderRadius:"4px",right:$?"-6px":"2px",bottom:$?"2px":"-9px",height:"24px",width:$?"24px":"18px",maxHeight:$?"calc(100% - 4px)":void 0,maxWidth:$?void 0:"calc(100% - 4px)",background:ne.fill,border:`${R.edgeStrokeFill} solid 1px`,boxShadow:`0.5px 0.5px 0px 0px ${_.text.fill}`,display:"flex",alignItems:"center",justifyContent:"center"},onPointerDown:C,children:T.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='${encodeURIComponent(I.text.fill)}' 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:$?void 0:"rotate(90deg)"}})}):null]})})),Kl=(e,t)=>T.jsx(bi,{...e,ref:t}),Xl=c.memo(c.forwardRef((e,t)=>{const{orientation:n,view:o,index:r,disabled:i=!1,disabledResize:l=!1,resizeThreshold:s=1,dividerRenderer:u=Kl,onDividerMouseDown:d,onDividerResizeStart:w,onDividerResize:x,onDividerResizeEnd:p,onDividerMouseUp:y,onDividerAutoFit:_,onPointerDown:I,...R}=e,ce=k(I,[I]),P=k(_,[_]),C=n===Bt;let D=C?o.getVisibleColumns():o.getVisibleRows(),ie=null;D.length>0&&(C?ie=o.getRangeCoordsBounds({rowStart:0,rowEnd:0,colStart:D[0],colEnd:D[D.length-1]}):o.getRangeCoordsBounds({rowStart:D[0],rowEnd:D[D.length-1],colStart:0,colEnd:0}),ie=o.toClipBounds(ie,Wt));const $=c.useRef(null),[ne,ve]=c.useState(null),q=(A,K)=>C?A.clientX-K.clientX:A.clientY-K.clientY,N=o.getLayout(),Y=C?N.getColOffset(r+1):N.getRowOffset(r+1),O=vn({processTouch:!0,onPointerDown:A=>{if(ce?.(A),!i&&!l){const K=C?N.getColOffset(r):N.getRowOffset(r),U=Y-K;$.current={isResizing:!1,startSize:U,index:r,view:o,orientation:n,onDividerMouseDown:d,onDividerResizeStart:w,onDividerResize:x,onDividerResizeEnd:p,onDividerMouseUp:y},ve($.current),d?.(r,U)}A.stopPropagation(),A.preventDefault()},onPointerUp:(A,K,U)=>{if(!$.current)return;$.current.isResizing&&$.current.onDividerResizeEnd?.($.current.index,Math.max(0,$.current.startSize+q(A,U)),$.current.startSize);const me=$.current;$.current=null,ve($.current),me.onDividerMouseUp?.(me.index)},onPointerMoveOrWait:(A,K,U)=>{if(!$.current)return;const me=q(A,U);$.current.isResizing?$.current.onDividerResize?.($.current.index,Math.max(0,$.current.startSize+me),$.current.startSize):Math.abs(me)>Math.max(1,s)&&($.current={...$.current,isResizing:!0},ve($.current),$.current.onDividerResizeStart?.($.current.index,Math.max(0,$.current.startSize+me))),A.stopPropagation(),A.preventDefault()}}),h=k(()=>{P?.(r)},[r]);if(!ie)return;const M=u({bounds:ie,orientation:n,view:o,index:r,disabled:i,disabledResize:l,onAutoFit:h,onPointerDown:O,...R},t);if(!M)return;const{getPortalContainer:Q}=si();let H=null;return ne&&ne.isResizing&&ne.index===r&&(H=No.createPortal(T.jsx("div",{style:{position:"absolute",cursor:C?yi:vi,left:0,top:0,width:"100%",height:"100%"}}),Q(),"divider:"+r)),T.jsxs(T.Fragment,{children:[H,T.jsx("div",{className:fn("header-divider-anchor"),style:{position:"absolute",pointerEvents:"auto",top:`${C?ie.y:Y}px`,left:`${C?Y:ie.x}px`,width:(C?0:ie.width-1)+"px",height:(C?ie.height-1:0)+"px",display:"flex"},tabIndex:-1,children:M})]})}));class Yl{naturalDimensions(t,n={}){const o=document.createElement("div");let r=n?.lineHeight??"1";!n?.lineHeight&&n.paintableText?.fontSize&&(r=Math.ceil(1.2*n.paintableText.fontSize)+"px");const i=document.createElement("div");i.style.visibility="hidden",i.style.position="absolute",i.style.textRendering="geometricprecision",i.style.display="inline-grid",i.style.overflowWrap="break-word",i.style.maxWidth=n.maxWidth?n.maxWidth+"px":"100%",i.style.lineHeight=r,i.style.letterSpacing=(n.paintableText?.letterSpacing??0)+"px",i.style.fontSize=n.paintableText?.fontSize?n.paintableText.fontSize+"px":"unset",i.style.fontFamily=n.paintableText?.fontSize?n.paintableText.fontFamily:"unset",i.style.fontWeight=n.paintableText?.fontWeight?""+n.paintableText.fontWeight:"400",i.style.fontStyle=n.paintableText?.fontStyle?n.paintableText.fontStyle:"normal",i.style.whiteSpace=n.paintableText?.wrap==="wrap"?"break-spaces":"pre",o.appendChild(i);const l=t.split(`
|
|
24
|
-
`);for(let u=0;u<l.length;u++){let d=document.createElement("span");i.appendChild(d),d.textContent=l[u]}l.length!==0&&l[l.length-1].length!==0||i.appendChild(document.createElement("br")),document.body.appendChild(i);let s=i.getBoundingClientRect();return i.remove(),{width:s.width,height:s.height,maxLineHeight:1.2*(n.paintableText?.fontSize||1056/72)}}}const Si=(e=void 0)=>Object.freeze({clean:e,dirty:void 0,editMode:!1}),Gl=Si(),Zl=c.memo(c.forwardRef((e,t)=>{const{editState:n=Gl,defaultTextStyle:o,onStartEdit:r,onChangeEdit:i,onSubmitEdit:l,onCancelEdit:s,onDoneEdit:u,containerBounds:d,setNaturalDimensions:w,onNavigate:x,textProperties:p,style:y,autoFocus:_,...I}=e,R=c.useRef(null),{width:ce=0}=d??{},[P,C]=c.useState(()=>n);c.useEffect(()=>{C(n)},[n]);const D=p?.align||"left",ie=p?.vAlign||"middle",$=p?.fill||"#040404",ne=p?.wrap||"wrap",ve=p?.fontFamily||"Calibri",q=p?.fontSize||11,N=p?.fontWeight||400,Y=p?.fontStyle||"normal",O=P.dirty??P.clean??"";let h=2;const M=96*q/72,Q=1.2*M;ie==="right"&&(h+=1);const H=c.useMemo(()=>new Yl().naturalDimensions(O,{maxWidth:ne==="wrap"?ce-h:void 0,lineHeight:`${Q}px`,paintableText:{fontStyle:Y,wrap:ne,letterSpacing:-.25}}),[O,ne,h,M,ve,N,Y,w,ce]),A=c.useCallback(()=>H.maxLineHeight?H.maxLineHeight+"px":"1.2",[H]),[K,U]=c.useState(A);c.useLayoutEffect(()=>{U(A())},[d,H]),c.useLayoutEffect(()=>{w?.({width:ne==="wrap"?void 0:H.width+h,height:H.height})},[H,w]);const me=k(i,[i]),G=k(X=>{if(P.dirty===X)return;const fe={...P};fe.dirty=X,R.current,C(fe),me?.(fe)},[P]),Ve=k(X=>{if(P.editMode===X)return;const fe={...P};fe.editMode=X,C(fe),me?.(fe)},[P]),He=k(()=>{try{return l?.(P),u?.(),!0}catch{return!1}},[l,P]),Fe=k(()=>{C(n),s?.(),u?.()},[s,n]),ct=k(X=>{if(!R.current)return;if(X.isDefaultPrevented(),!(X.isTrusted||X.nativeEvent.ctrlKey||X.nativeEvent.metaKey||X.nativeEvent.altKey||X.nativeEvent.isComposing)&&Ko.indexOf(X.nativeEvent.key)!==-1){const ee={...P};return ee.dirty=X.nativeEvent.key==="Backspace"?"":(ee.dirty??"")+X.key,C(ee),me?.(ee),void X.preventDefault()}const fe=X.nativeEvent.shiftKey;if(X.which===Ni)return X.preventDefault(),void Fe();if(X.which===Yi)return Ve(!0),void X.preventDefault();if(X.which===Hi&&(X.preventDefault(),He()&&x?.(fe?nt:ot)),X.which===Wi)return X.preventDefault(),void(He()&&x?.(fe?et:Ue));if(!P.editMode){let ee=null;switch(X.which){case Ui:ee=et;break;case Ki:ee=Ue;break;case qi:ee=nt;break;case Xi:ee=ot}if(ee)return void He()}},[P,x]),[Se,E]=c.useState(!_);c.useEffect(()=>{E(!1)},[]);const ue=lo(t,()=>({startEdit(X){let fe=X?.initialSelection;if(!fe){const Me=R.current.value.length??0;fe={start:Me,end:Me,direction:"forward"}}R.current?.setSelectionRange(fe.start,fe.end,fe.direction);const ee={...n,editMode:X?.editMode??!1};X?.text!==void 0&&(ee.dirty=X.text),ee.editMode===n.editMode&&ee.dirty===n.dirty||(C(ee),me?.(ee))},submitEdit:()=>He(),cancelEdit(){Fe()},autoFocus(){R.current?.focus()},getLineHeight:()=>H?.maxLineHeight??Q,dispatchEvent:X=>R.current.dispatchEvent(X)}),[n,r]);return T.jsx("div",{ref:ue,...I,style:{background:"transparent",display:"flex",flexGrow:1,alignSelf:"center",height:H.height,maxWidth:"100%",maxHeight:"100%",...y},children:T.jsx("textarea",{spellCheck:"false",ref:R,value:O,autoFocus:!1,disabled:Se,name:"cell-editor",autoComplete:"off",autoCapitalize:"off",style:{flex:"1 1 100%",position:"relative",fontSize:`${M}px`,fontFamily:`${ve}`,fontWeight:`${N}`,fontStyle:`${Y}`,padding:"0px",marginRight:D==="right"?"3px":"0px",marginLeft:D==="left"?"2px":"0px",lineHeight:K,height:H.height,textRendering:"geometricPrecision",letterSpacing:"-0.25px",boxSizing:"border-box",borderWidth:0,outline:"none",resize:"none",overflow:"hidden",verticalAlign:"baseline",textAlign:D,background:"transparent",color:$,marginBottom:"0px",userSelect:"text",maxHeight:"100%",whiteSpace:ne==="wrap"?"break-spaces":"pre",wordWrap:"break-word"},onChange:X=>{G(X.target.value)},onDoubleClick:X=>{X.isTrusted},onMouseDown:X=>{Ve(!0)},onKeyDown:ct})})})),Jl=c.memo(e=>{const{value:t,view:n,bounds:o,range:r,zoom:i,children:l,style:s,...u}=e,d=s?.fontSize||1056/72;return T.jsx("div",{style:{padding:"2px 4px",fontFamily:"Calibri",letterSpacing:-.25,lineHeight:1.2,fontSize:d,...s},...u,children:t})});exports.BaseGrid=Yo,exports.DefaultCellEditor=Zl,exports.DefaultCellRenderer=Jl,exports.DefaultHeaderDivider=bi,exports.FillHandle=Wo,exports.Grid=Go,exports.HeaderDivider=Xl,exports.HeaderRenderer=xi,exports.RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL=150,exports.SELECTION_CLIP_INSETS=Wt,exports.STANDARD_KEY_CHARS=Ko,exports.SVGLine=Vo,exports.SVGRect=hi,exports.ScrollableGrid=mi,exports.Selection=Xo,exports.TouchSelectHandle=Qn,exports.defaultSelectionRenderer=zr,exports.getDefaultStringEditState=Si,exports.safeSelectionCoords=$t,exports.useCellLayout=di,exports.useHeaderSelection=({gridRef:e,gridMainRef:t,orientation:n=Qt,headerCount:o,selectionPolicy:r="multiple",newSelectionMode:i="clear",alwaysScrollToActiveCoords:l=!0,onDragStart:s,onDragEnd:u,pointerDownInterceptor:d,pointerMoveInterceptor:w,onPointerUp:x,newSelection:p,modifySelection:y,appendSelection:_,clearSelections:I})=>{const R=o??((n===Qt?e.current?.rowCount:e.current?.columnCount)||0),ce=c.useRef(null),P=c.useRef(null),C=c.useRef(!1),D=c.useRef(null),ie=c.useCallback(h=>n===Bt?{rowIndex:0,colIndex:h.colIndex}:{rowIndex:h.rowIndex,colIndex:0},[n]),$=c.useCallback(h=>n===Bt?{rowIndex:t.current?t.current.rowCount-1:0,colIndex:h.colIndex}:{rowIndex:h.rowIndex,colIndex:t.current?t.current.columnCount-1:0},[n]),ne=h=>{P.current=$(h),y(P.current,ce.current)},ve=c.useCallback((h,M)=>{if(!e.current)return;const Q=e.current.getViewFromClient(h,M)?.getCellCoordsFromClient(h,M);return Q?(n===Bt?Q.rowIndex=t.current.getViewport().rowStart:Q.colIndex=t.current.getViewport().colStart,Q):void 0},[]),q=c.useCallback((h,M=!1)=>{let Q=h;return M||(Q={...h},n===Qt?delete Q.colIndex:delete Q.rowIndex),t.current?.scrollCellCoordsIntoView(Q)},[n]),N=k(u,[u]),Y=k(s,[s]),O=c.useMemo(()=>({onPointerDown:h=>{if(!e||!e.current||h.nativeEvent.defaultPrevented)return;const M=ve(h.nativeEvent.clientX,h.nativeEvent.clientY);if(!M)return;h.nativeEvent.which;const Q=h.nativeEvent.shiftKey,H=h.nativeEvent.ctrlKey||h.nativeEvent.metaKey;if(d?.(h,M)===!1)return;Y?.(),C.current=!0;const A=t.current?.getViewFromClient(h.nativeEvent.clientX,h.nativeEvent.clientY),K=((U,me)=>n===Bt?{...U,rowIndex:me.rowStart}:{...U,colIndex:me.colStart})(M,A.getVisibleRangeCoords());if(Q)ne(M);else{if(H)return((U,me=U,G)=>{ce.current=ie(U),P.current=$(me),_(ce.current,P.current,G)})(M,M,K),void(l&&q(K,!0));((U,me=U,G)=>{ce.current=ie(U),P.current=$(me),p(ce.current,P.current,G)})(M,M,K),ne(M),l&&q(K,!0)}},onPointerMoveOrWait:St.throttle(h=>{if(!C.current||!e?.current)return;const M=ve(h.clientX,h.clientY);if(M&&w?.(h,M)!==!1){if(Z.isEqualCells(D.current,M))return I();ne(M),q(M)}},60),onPointerUp:h=>{C.current=!1,N?.(),x?.(h)},processTouch:!0,consumeTouch:!0}),[r,l,R,i,I,d,x]);return{onPointerDown:k(vn(O),[]),getCellCoordsFromClient:ve}},exports.useKeyboardEditorOverlay=e=>{const{view:t,canEdit:n=Pl,getCellEditor:o,onBeforeStartEdit:r,onStartEdit:i,onSubmitEdit:l,onCancelEdit:s,onDoneEdit:u,isEditorStartKeyEvent:d=Ol,isEditorStartPointerEvent:w=Ll,containerProps:x,borderStrokeFill:p,borderStrokeWidth:y=2,getRangeCoords:_=null,activeCoords:I,alignment:R=On.Left}=e,[ce,P]=c.useState(!1),[C,D]=c.useState(void 0),ie=k((E,ue,X,fe,ee,Me)=>{if(!ue)return null;const it=ee?.(ue,E),ut=E.getRangeCoordsBounds(it),Tt=E.toClipBounds(ut),dt=ut,Ut=E.getZoom();if(!Tt)return null;X&&(X*=Ut),fe&&(fe*=Ut);let je=dt,j=!1;if(X!==void 0){let Ke={...it},ht=0;for(;!j&&je.width<=X&&ht<20;){ht++,ht>19&&console.warn("max width reached");const en=E.getTotalRangeCoords(),qt=E.getLayout();Me===On.Left?Ke.colEnd+1<en.colEnd?Ke.colEnd=qt.getColIndex(je.x+X):j=!0:Me===On.Right?Ke.colStart-1>=0?Ke.colStart=qt.getColIndex(je.x-(X-je.width)):j=!0:Me===On.Center&&Ke.colEnd+1<en.colEnd&&Ke.colStart-1>=0?(Ke.colStart=qt.getColIndex(je.x-(X-je.width)/2),Ke.colEnd=qt.getColIndex(je.x+je.width+(X-je.width)/2)):j=!0,j||(je=E.getRangeCoordsBounds(Ke))}}je.height=dt.height,fe!==void 0&&(je.height=Math.max(fe+1,dt.height));const{width:Re,height:Ge}=E.getViewportSize();return{x:je.x??0,y:je.y??0,height:Math.min(Ge-je.y,je.height)+1,width:Math.min(Re-je.x,je.width)+1}},[R]),$=k(n,[n]),ne=c.useCallback(()=>{t?.getStage()?.focus()},[t]),ve=k(E=>{r?.(E),U(),P(!0)},[r]),q=k(E=>{i?.(E.coords)},[i]),N=k(E=>{E.isSubmitted||E.isCancelled||(h.current.isEditorClosed=!0,ne(),E.isCancelled=!0,s?.(E.coords),U())},[s]),Y=k(E=>{if(E.isSubmitted||E.isCancelled)return!1;try{return E.isEditorClosing=!0,E.isSubmitted=!0,E.isEditorSubmitted||(E.isEditorSubmitted=!0,E.editorRefs[0]?.submitEdit?.()),E.coords,l?.(E.coords),E.isEditorClosed=!0,ne(),U(),!0}catch(ue){throw E.isEditorClosing=!1,E.isSubmitted=!1,ue}},[l]),O=k(E=>{P(!1),u?.(E.coords),U()},[u]),h=c.useRef(null),M=c.useRef(null),Q=c.useRef(null),H=c.useRef([]),[A,K]=c.useReducer(E=>E+1,0),U=c.useCallback(E=>{E&&H.current.push(E),K()},[]),me=k(E=>{if(E.defaultPrevented||E.isSynthetic||!t)return;const ue=t?.getCellCoordsFromClient(E.clientX,E.clientY);ue&&U({eventType:"pointer",event:E,coords:ue})},[t]),G=k(E=>{const ue=E.nativeEvent;me(ue)},[t]),Ve=k(E=>{if(E.defaultPrevented||E.isSynthetic||!t?.getStage())return;const ue=M.current;d(E,ue)&&(E.stopPropagation(),E.preventDefault()),E.key,U({eventType:"keyboard",event:E,coords:ue})},[t]);c.useLayoutEffect(()=>{const E=(fe,ee)=>{const Me=ee?.cell??fe;if(!Me)return null;const it=Me;if(!$(Me))return null;ve?.(Me);const ut=St.uuidV4();ee=Object.freeze({autoFocus:!0,...ee}),Q.current=Me;const Tt={coords:it,startEvent:ee,uuid:ut,isMounted:!1,isStarted:!1,isSubmitted:!1,isEditorSubmitted:!1,isEditorClosing:!1,isEditorClosed:!1,isCancelled:!1,events:[],editorRefsDispatchEditorEvent:[],editorRefs:[],onMount:dt=>{Tt.isMounted||(Tt.isMounted=!0,U())},onUnmount:dt=>{if(Tt.editorRefs.length===0){const Ut=()=>{Tt.isMounted=!1,U()};if(document.activeElement!==document.body)Ut();else{const je=j=>{j.defaultPrevented||j.target!==document.body||Ve(j)};window.addEventListener("keydown",je,!0),t.getStage()?.addEventListener("focusin",()=>{window.removeEventListener("keydown",je),Ut()},{once:!0}),ne()}}}};return Tt};if(H.current.length<=0&&!h.current)return;const ue=H.current[0];Rr(ue),(fe=>{const ee=[],Me=fe?.length??0;for(let it=0;it<Me;it++){const ut=fe[it];ee.push(Rr(ut))}})(H.current),h.current,h.current;let X=h.current;if(h.current){if(h.current.isDone)h.current=null;else if(h.current.isSubmitted||h.current.isCancelled){if(h.current.isMounted)return;h.current.isDone||(O(h.current),h.current.isDone=!0)}}if(ue){if(ue.eventType==="start"){const fe=ue,ee=fe.startEvent?.cell??M.current;h.current&&Z.isEqualCells(h.current.coords,ee)||(h.current=E(ee,fe.startEvent))}else if(ue.eventType==="keyboard"){const fe=ue.event;if(h.current){fe.key,h.current.events,h.current.events.push(ue);for(let ee=0;ee<h.current.editorRefsDispatchEditorEvent.length;ee++)h.current.editorRefsDispatchEditorEvent[ee](ue)}else if(d(fe,ue.coords)){let ee;const Me=E(ee?.cell??M.current,ee);Me&&Me.events.push(ue),h.current=Me}}else if(ue.eventType==="pointer"){const fe=ue.event;if(h.current){h.current.events.push(ue);for(let ee=0;ee<h.current.editorRefsDispatchEditorEvent.length;ee++)h.current.editorRefsDispatchEditorEvent[ee](ue)}else{const ee=ue?.coords??M.current,Me=w(fe,ee);if(Me){let it;typeof it!="boolean"&&(it=Me);const ut=E(ee,it);ut&&ut.events.push(ue),h.current=ut}}}else if(ue.eventType==="submit"){if(h.current&&!h.current.isSubmitted&&!h.current.isCancelled){if(!h.current.isMounted)return;Y(h.current)}}else if(ue.eventType==="cancel"){if(h.current&&!h.current.isSubmitted&&!h.current.isCancelled){if(!h.current.isMounted)return;N(h.current)}}else if(ue.eventType==="coordsChange"){const fe=ue;if(M.current=fe.activeCoords,h.current,h.current&&!h.current.isSubmitted&&!h.current.isCancelled){if(!h.current.isMounted)return;try{Y(h.current)}catch{}}}}H.current.length>0&&(H.current.shift(),U()),H.current.length===0&&(!h.current||h.current.isEditorClosing||h.current.isEditorClosed?!h.current&&X&&ne():h.current.isMounted&&!h.current.isStarted&&(h.current.isStarted=!0,h.current.startEvent.autoFocus&&(typeof h.current.startEvent.autoFocus=="string"?h.current.editorRefs[0]?.autoFocus(h.current.startEvent.autoFocus):h.current.editorRefs[0]?.autoFocus()),q?.(h.current),requestAnimationFrame(()=>{t&&h.current?.coords&&t.scrollCellCoordsIntoView(h.current.coords)})))},[A]),c.useEffect(()=>{Q.current=I;const E=h.current?.coords;Z.isEqualCells(E,I)||(h.current&&(h.current.isEditorClosing=!0),U({eventType:"coordsChange",activeCoords:I}))},[I]);const He=c.useCallback(E=>{Ve(E.nativeEvent)},[]),{width:Fe=0,height:ct=0}=C??{width:0,height:0},Se=k(o,[o]);return{overlay:k(E=>{if(!h.current||h.current.isEditorClosed)return h.current,null;h.current.coords;let ue=ie(E,h.current.coords,Fe,ct,_,R),X=!0;ue&&ue.width!==0&&ue.height!==0||(ue={x:0,y:0,width:Fe,height:Fe},X=!1);const fe=E.getZoom(),ee={containerBounds:{x:0,y:0,width:ue.width/fe,height:ue.height/fe},setNaturalDimensions:D,zoom:fe};return T.jsx(Dl,{session:h.current,refLatestCoords:Q,handleSubmitEdit:Y,handleCancelEdit:N,cellBounds:ue,borderStrokeWidth:y,borderStrokeFill:p,isInBounds:X,getCellEditor:Se,propsEditor:ee,alignment:R,...x},"editor:"+h.current.uuid)},[o,_,A,Fe,ct,R,y,p]),startEdit:c.useCallback(E=>{U({eventType:"start",startEvent:E})},[]),submitEdit:c.useCallback(()=>{U({eventType:"submit"})},[]),cancelEdit:c.useCallback(()=>{U({eventType:"cancel"})},[]),onKeyboardEvent:He,onPointerEvent:G,onKeyboardEventNative:Ve,onPointerEventNative:me,isEditing:ce}},exports.useSelection=({gridRef:e,commands:t,layout:n,selection:o,onSelectionChange:r,onSelectionDragStart:i,onSelectionDragEnd:l,selectionPolicy:s="multiple",newSelectionMode:u="clear",allowDeselectSelection:d=!0,onFillPreview:w,onFillCancel:x,onFillDone:p,onFill:y,disableFillDrag:_=!y,fillHandleBorderColor:I="white",hiddenRowsAt:R,hiddenColumnsAt:ce,isContentfulCell:P,contentfulCellFinder:C=Al,getDataCoords:D,alwaysScrollToActiveCoords:ie=!1,selectionBounds:$,pointerDownInterceptor:ne,pointerMoveInterceptor:ve,mergedRanges:q,canSelectionSpanMergedCells:N=Hl,onMoveDragStart:Y,onMoveDragUpdate:O,onMoveDragEnd:h,onMoveDragDone:M,selectionRenderer:Q=zr,disableMoveDrag:H=!h,getCellCoordsAsRangeCoords:A=Z.cellToRange,moveDragHitSize:K=6,moveDragOutlineSize:U=4,selectionBackgroundColor:me="rgba(16, 124, 65, 0.1)",selectionBorderColor:G="rgb(33, 115, 70)",selectionRemoveBorderColor:Ve="rgb(255, 0, 0)",selectionRemoveBackgroundColor:He="rgba(250, 10, 10, 0.1)",disableTouchSelection:Fe=!1,touchSelectHandleProps:ct})=>{const Se=c.useCallback(()=>({top:$?.top??0,left:$?.left??0,bottom:e.current?.rowCount-1||0,right:e.current?.columnCount-1||0}),[]),E=k(y,[y]),ue=k(w,[w]),X=k(x,[x]),fe=k(p,[p]),ee=k(P,[P]),Me=k(Q,[Q]),it=k((a,f=!1)=>io(a,f,n.getRowOffset,f?Se().bottom:Se().top),[n?.getRowOffset]),ut=k(R??it,[R]),Tt=k((a,f=!1)=>io(a,f,n.getColOffset,f?Se().right:Se().left),[n?.getColOffset]),dt=k(ce??Tt,[ce]),[Ut,je]=c.useState(()=>$t(o)),j=c.useMemo(()=>$t(Ut),[Ut]),Re=c.useRef(j),Ge=c.useRef(!0);c.useLayoutEffect(St.throttle(()=>{je(a=>{Ge.current=!0;const f=$t(o);return Z.isEqualSelectionCoords(f,a)?a:f})},0),[o]),c.useLayoutEffect(()=>{Re.current=j},[j]),c.useEffect(()=>{Ge.current||!r||Z.isEqualSelectionCoords(o,j)||r(j)},[j]);const Ke=c.useCallback(a=>{je(f=>{Ge.current=!1,f=$t(f);let m=typeof a=="function"?a(f.ranges):a??Ho;if(Z.isEqualRangesArrays(m,f.ranges))return f;let g=Math.max(m.length?0:-1,Math.min(f.rangeIndex,m.length-1)),b=f.cell;g===-1||Z.isCellWithinRange(b,m[g])||(b={rowIndex:m[g].rowStart,colIndex:m[g].colStart}),m.length===1&&Z.isSingleCell(m[0])&&Z.isCellWithinRange(b,m[0])&&(m=[],g=-1);const W={cell:b,ranges:m,rangeIndex:g};return Z.isEqualSelectionCoords(W,f)?f:W})},[]),ht=k(a=>{je(f=>{Ge.current=!1,f=$t(f);const m=a??wi,g=A(m);if(!Z.isSingleCell(g)&&f.ranges.length===0)return{ranges:[g],rangeIndex:0,cell:m};if(Z.isEqualCells(m,f.cell))return f;let b=f.ranges,W=f.rangeIndex;f.ranges.length===1&&(Z.isSingleCell(f.ranges[0])&&Z.isCellWithinRange(m,f.ranges[0])||!Z.isCellWithinRange(m,f.ranges[0]))&&(b=[],W=-1);const S={ranges:b,rangeIndex:W,cell:m};return Z.isEqualSelectionCoords(S,f)?f:S})},[A]),[en,qt]=c.useState(null),[zt,tn]=c.useState(null),Yt=c.useRef(null),[Le,Ft]=c.useState(null),gt=c.useRef(null),jt=c.useRef(null),[wn,nn]=c.useState(null),We=c.useRef(null),J=c.useRef(null),Ze=c.useRef(q);c.useEffect(()=>{Ze.current=q},[q]);const Ne=k((a,f={inline:"nearest",block:"nearest"})=>{let{rowIndex:m,colIndex:g}=a;m===void 0&&j?.cell&&(m=j.cell.rowIndex),g===void 0&&j?.cell&&(g=j.cell.colIndex),m!==void 0&&g!==void 0&&e.current?.scrollCellCoordsIntoView({rowIndex:m,colIndex:g},f)},[j]),lt=c.useCallback(a=>{const f=Se();return a.rowIndex<f.top||a.colIndex<f.left||a.colIndex>f.right||a.rowIndex>f.bottom},[]),Ee=k((a,f)=>{if(!e?.current)return null;const m={rowStart:Math.min(a.rowIndex,f.rowIndex),colStart:Math.min(a.colIndex,f.colIndex),rowEnd:Math.max(a.rowIndex,f.rowIndex),colEnd:Math.max(a.colIndex,f.colIndex)};if(N?.(m))return m;const b=A(a),W=A(f),S={rowStart:Math.min(b.rowStart,W.rowStart),colStart:Math.min(b.colStart,W.colStart),rowEnd:Math.max(b.rowEnd,W.rowEnd),colEnd:Math.max(b.colEnd,W.colEnd)};let de;return typeof Ze.current=="function"?de=Ze.current(S):q&&(de=q),de?Z.extendRangeToUnionRanges(S,de):S},[N,A]),Pe=k((a,f,m)=>{const g=a.ranges.length>0?a.ranges[a.rangeIndex]:{rowStart:a.cell.rowIndex,colStart:a.cell.colIndex,rowEnd:a.cell.rowIndex,colEnd:a.cell.colIndex},b={rowStart:Math.min(f.rowIndex??g.rowStart,m.rowIndex??g.rowStart),colStart:Math.min(f.colIndex??g.colStart,m.colIndex??g.colStart),rowEnd:Math.max(f.rowIndex??g.rowEnd,m.rowIndex??g.rowEnd),colEnd:Math.max(f.colIndex??g.colEnd,m.colIndex??g.colEnd)},W={rowIndex:b.rowStart,colIndex:b.colStart},S={rowIndex:b.rowEnd,colIndex:b.colEnd};if(!(lt(W)||lt(S)))return Ee(W,S)},[Ee]),tt=k((a,f,m)=>{if(s==="single"||!Re.current)return;const g=Pe(Re.current,a,f??Re.current.cell);if(!g)return;const b=Re.current.rangeIndex;Ke(W=>W.length?W.map((S,de)=>b===de?g:S):[g]),m&&g&&ht({colIndex:g.colStart,rowIndex:g.rowStart})},[]),Je=c.useCallback((a,f,m)=>{if(!Re.current)return;a={...Re.current?.cell,...a},f=f??a;const g=Pe(Re.current,a,f);if(!g)return;const b={rowIndex:g.rowStart,colIndex:g.colStart},W={...b,...m};u==="clear"?(We.current=W,Gt()):u==="modify"?tt(b):De(b),ht(W)},[]),De=c.useCallback((a,f=a,m)=>{s!=="multiple"||!a||lt(a)||lt(f)||je(g=>{Ge.current=!1,g=$t(g);const b=Ee(a,f);if(!b)return g;let W=g.ranges.length>0?[...g.ranges]:[Ee(g.cell,g.cell)];W.push(b);const S={ranges:W,cell:{rowIndex:b.rowStart,colIndex:b.colStart,...m},rangeIndex:W.length-1};return Z.isEqualSelectionCoords(S,g)?g:S})},[]),Gt=()=>{Ke(Ho)},Et=we.detectIt().primaryInput==="touch",Qe=c.useRef(null),_t=c.useRef(null),It=c.useRef(null),on=c.useMemo(()=>({onPointerDown:a=>{if(!e||!e.current)return!1;const f=a.nativeEvent,m=e.current.getViewFromClient(f.clientX,f.clientY);if(f.pointerType==="touch"||f.type==="touchstart")return _t.current={topLeft:m.getScrollTopLeft(),point:{x:f.clientX,y:f.clientY}},!0;const g=m.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);if(!g)return!1;Qe.current={anchor:m.getAnchor(),coords:g},J.current=null;const b=a.nativeEvent.which===yr;if(b&&Z.indexOfCoords(g,j.ranges)!==-1)return!1;const W=a.nativeEvent.shiftKey,S=a.nativeEvent.ctrlKey||a.nativeEvent.metaKey,de=S,te=d,oe=j.ranges.length>0,ge=S&&te;if(ne?.(a,g,j)===!1)return!1;i?.(Re.current,a.nativeEvent);const Oe=!b&&s!=="single";if(W)return tt(g),Oe;const ae=Z.isEqualCells(g,j.cell);if(de){if(ae&&(!ge||!oe))return Oe;if(S&&Z.indexOfCoords(g,j.ranges)!==-1&&te){gt.current=g;const re=Ee(g,g);return jt.current=re,Ft(re),Oe}return De(g),Oe}ie&&Ne(g),ae&&j.ranges.length===0||Je(g)},onPointerMoveOrWait:St.throttle((a,f)=>{if(!e?.current||a.pointerType==="touch"||a.type==="touchmove"||!Qe.current)return;const m=Qe.current.anchor;let g=e.current.getViewFromLocation(m),b=g.getCellCoordsFromClient(a.clientX,a.clientY);if(!Z.isEqualCells(b,Qe.current?.coords)&&(Qe.current={anchor:m,coords:b},b&&ve?.(a,b,Re.current)!==!1)){if(gt.current){const W={rowStart:Math.min(b.rowIndex,gt.current.rowIndex),colStart:Math.min(b.colIndex,gt.current.colIndex),rowEnd:Math.max(b.rowIndex,gt.current.rowIndex),colEnd:Math.max(b.colIndex,gt.current.colIndex)},S={rowIndex:W.rowStart,colIndex:W.colStart},de={rowIndex:W.rowEnd,colIndex:W.colEnd};if(lt(S)||lt(de))return;const te=Ee(S,de);jt.current=te,Ft(te)}else tt(b);It.current=f,Gn(g,b,e)}},60),onPointerUp:a=>{if(Qe.current=null,a.pointerType==="touch"||a.type==="touchend"){if(_t.current){const m=e.current.getViewFromClient(_t.current.point.x,_t.current.point.y),g=m.getScrollTopLeft();if(g.left===_t.current.topLeft.left&&g.top===_t.current.topLeft.top){const b=m.getCellCoordsFromClient(_t.current.point.x,_t.current.point.y);Je(b)}}return _t.current=null,void(Qe.current=null)}try{l?.(Re.current,a)}catch(m){console.warn(m)}if(!gt.current)return;const f=jt.current;gt.current=null,jt.current=null,Ft(null),je(m=>{if(Ge.current=!1,(m=$t(m)).ranges.length===0)return m;let g=[],b=-1,W=m.cell;for(let de=0;de<m.ranges.length;de++){const te=m.ranges[de];if(Z.isRangesIntersect(te,f)){const oe=St.subtractRect({top:te.rowStart,left:te.colStart,bottom:te.rowEnd+1,right:te.colEnd+1},{top:f.rowStart,left:f.colStart,bottom:f.rowEnd+1,right:f.colEnd+1});for(let ge=0;ge<oe.length;ge++){const Oe={rowStart:oe[ge].top,colStart:oe[ge].left,rowEnd:oe[ge].bottom-1,colEnd:oe[ge].right-1};g.push(Oe),Z.isCellWithinRange(m.cell,Oe)&&(b=g.length-1)}}else g.push(te);g.length>0&&b===-1&&Z.isCellWithinRange(m.cell,te)&&(b=g.length-1,W={rowIndex:g[g.length-1].rowStart,colIndex:g[g.length-1].colStart})}const S={cell:W,rangeIndex:b,ranges:g};return Z.isEqualSelectionCoords(S,m)?m:S})},processTouch:!0,consumeTouch:!1}),[j,s,d,ie,u]),so=k(vn(on),[]),co=c.useMemo(()=>({onSelectionPointerDown:(a,f,m,g,b=j.cell,W=ie,S=a.nativeEvent.shiftKey,de=!1)=>{if(!e||!e.current)return!1;a.stopPropagation(),a.preventDefault(),a.nativeEvent.stopImmediatePropagation();const te=m??e.current.getViewFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY),oe=g??te.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);if(!oe)return!1;Qe.current={anchor:te.getAnchor(),coords:oe},J.current=null;const ge=a.nativeEvent.which===yr;if(ge&&Z.indexOfCoords(oe,j.ranges)!==-1)return!1;const Oe=a.nativeEvent.ctrlKey||a.nativeEvent.metaKey,ae=Oe,re=d,vt=j.ranges.length>0,B=Oe&&re;if(ne?.(a,oe,j)===!1)return!1;i?.(Re.current,a.nativeEvent);const ke=!ge&&s!=="single";if(S)return tt(oe,b,de),ke;const Ct=Z.isEqualCells(oe,b);if(ae){if(Ct&&(!B||!vt))return ke;if(B&&Z.indexOfCoords(oe,j.ranges)!==-1&&re){gt.current=oe;const Ie=Ee(oe,oe);return jt.current=Ie,Ft(Ie),ke}return De(oe),ke}W&&Ne(oe),Ct&&j.ranges.length===0||Je(oe)},onSelectionPointerMoveOrWait:(a,f,m,g,b,W=j.cell,S=!0,de=!1)=>{if(!e?.current||(a.stopPropagation(),a.preventDefault(),a.stopImmediatePropagation(),!Qe.current))return;const te=Qe.current.anchor;let oe=g??e.current.getViewFromLocation(te),ge=b??oe.getCellCoordsFromClient(a.clientX,a.clientY);if(!Z.isEqualCells(ge,Qe.current?.coords)&&(Qe.current={anchor:te,coords:ge},ge&&ve?.(a,ge,Re.current)!==!1)){if(gt.current){const Oe={rowStart:Math.min(ge.rowIndex,gt.current.rowIndex),colStart:Math.min(ge.colIndex,gt.current.colIndex),rowEnd:Math.max(ge.rowIndex,gt.current.rowIndex),colEnd:Math.max(ge.colIndex,gt.current.colIndex)},ae={rowIndex:Oe.rowStart,colIndex:Oe.colStart},re={rowIndex:Oe.rowEnd,colIndex:Oe.colEnd};if(lt(ae)||lt(re))return;const vt=Ee(ae,re);jt.current=vt,Ft(vt)}else tt(ge,W,de);S&&Gn(oe,ge,e)}},onPointerUp:a=>{Qe.current=null,a.stopPropagation(),a.preventDefault(),a.stopImmediatePropagation();try{l?.(Re.current,a)}catch(m){console.warn(m)}if(!gt.current)return;const f=jt.current;gt.current=null,jt.current=null,Ft(null),je(m=>{if(Ge.current=!1,(m=$t(m)).ranges.length===0)return m;let g=[],b=-1,W=m.cell;for(let de=0;de<m.ranges.length;de++){const te=m.ranges[de];if(Z.isRangesIntersect(te,f)){const oe=St.subtractRect({top:te.rowStart,left:te.colStart,bottom:te.rowEnd+1,right:te.colEnd+1},{top:f.rowStart,left:f.colStart,bottom:f.rowEnd+1,right:f.colEnd+1});for(let ge=0;ge<oe.length;ge++){const Oe={rowStart:oe[ge].top,colStart:oe[ge].left,rowEnd:oe[ge].bottom-1,colEnd:oe[ge].right-1};g.push(Oe),Z.isCellWithinRange(m.cell,Oe)&&(b=g.length-1)}}else g.push(te);g.length>0&&b===-1&&Z.isCellWithinRange(m.cell,te)&&(b=g.length-1,W={rowIndex:g[g.length-1].rowStart,colIndex:g[g.length-1].colStart})}const S={cell:W,rangeIndex:b,ranges:g};return Z.isEqualSelectionCoords(S,m)?m:S})}}),[j,s,d,ie,u]),at=k((a,f=!1,m=!1,g=0)=>{if(!e.current||!j.cell)return;let b=j.cell,W=j.cell;if(f&&j.ranges.length>0){const B=j.ranges[j.rangeIndex],ke=j.cell;switch(a){case nt:W={rowIndex:ke.rowIndex===B.rowStart?B.rowEnd:B.rowStart,colIndex:B.colEnd},b={rowIndex:ke.rowIndex===B.rowStart?B.rowStart:B.rowEnd,colIndex:B.colStart};break;case ot:W={rowIndex:ke.rowIndex===B.rowEnd?B.rowStart:B.rowEnd,colIndex:B.colEnd},b={rowIndex:ke.rowIndex===B.rowEnd?B.rowEnd:B.rowStart,colIndex:B.colStart};break;case et:W={rowIndex:B.rowEnd,colIndex:ke.colIndex===B.colStart?B.colEnd:B.colStart},b={rowIndex:B.rowStart,colIndex:ke.colIndex===B.colStart?B.colStart:B.colEnd};break;case Ue:W={rowIndex:B.rowEnd,colIndex:ke.colIndex===B.colEnd?B.colStart:B.colEnd},b={rowIndex:B.rowStart,colIndex:ke.colIndex===B.colEnd?B.colEnd:B.colStart}}}const S=A(W);let{rowStart:de,colStart:te}=S;const oe=Se();if(J.current)switch(a){case nt:case ot:J.current.colIndex>=S.colStart&&J.current.colIndex<=S.colEnd&&(te=J.current.colIndex);break;case et:case Ue:J.current.rowIndex>=S.rowStart&&J.current.rowIndex<=S.rowEnd&&(de=J.current.rowIndex)}if(!g){switch(a){case nt:de=qe(ut,Math.max(S.rowStart-1,oe.top),a);break;case ot:de=qe(ut,Math.min(S.rowEnd+1,oe.bottom),a);break;case et:te=qe(dt,Math.max(S.colStart-1,oe.left),a);break;case Ue:te=qe(dt,Math.min(S.colEnd+1,oe.right),a)}if(m)switch(a){case nt:de=C({...W,colIndex:j.cell.colIndex},ee,ut,a,!1,Math.max(oe.top,ut(oe.top,!1)));break;case ot:de=C({...W,colIndex:j.cell.colIndex},ee,ut,a,!1,Math.min(oe.bottom,oe.bottom-ut(oe.bottom,!0)));break;case et:te=C({...W,rowIndex:j.cell.rowIndex},ee,dt,a,!1,Math.max(oe.left,dt(oe.left,!1)));break;case Ue:te=C({...W,rowIndex:j.cell.rowIndex},ee,dt,a,!1,Math.min(oe.right,oe.right-dt(oe.right,!0)))}}let ge=null;if(g){let B=0;switch(a){case nt:B=n.getRowOffset(de+1),de=Math.max(oe.top,n.getRowIndex(B-g)),ge={top:n.getRowOffset(de+1)-(B-e.current.getScrollPosition().top)};break;case ot:B=n.getRowOffset(de),de=Math.min(oe.bottom,n.getRowIndex(B+g)),ge={top:n.getRowOffset(de)-(B-e.current.getScrollPosition().top)};break;case et:B=n.getColOffset(te+1),te=Math.max(oe.left,n.getColIndex(B-g)),ge={left:n.getColOffset(te+1)-(B-e.current.getScrollPosition().left)};break;case Ue:B=n.getColOffset(te),te=Math.min(oe.right,n.getColIndex(B+g)),ge={left:n.getColOffset(te)-(B-e.current.getScrollPosition().left)}}}const Oe={rowIndex:de,colIndex:te},ae=A(Oe),re={rowIndex:ae.rowStart,colIndex:ae.colStart};f||(J.current=Oe);const vt=Z.isEqualCells(We.current,re)&&Z.isEqualCells(We.current,b);if(f&&!vt?tt(re,b):Je(re),ge)e.current.scrollTo(ge);else{if(f&&We.current){const B=Se();if(a===Ue&&We.current.colIndex===B.left||a===et&&We.current.colIndex===B.right||a===nt&&We.current.rowIndex===B.bottom||a===ot&&We.current.rowIndex===B.top)return}a===et||a===Ue?Ne({colIndex:Oe.colIndex}):a!==nt&&a!==ot||Ne({rowIndex:Oe.rowIndex})}},[j,A]),Zt=k(a=>{if(!e.current)return;if(j.ranges.length===0)return void at(a);const f=A(j.cell);if(Z.isEqualRangesArrays([f],j.ranges))return void at(a);const m=Fo(j,a,A,ut,dt);je(g=>{Ge.current=!1,g=$t(g);const b={...g,cell:m.cell,rangeIndex:m.rangeIndex};return Z.isEqualSelectionCoords(b,g)?g:b}),m.cell&&Ne(m.cell)},[j,A]),ao=c.useCallback(()=>{const a=Se();tt({rowIndex:a.top},{rowIndex:a.bottom})},[]),uo=c.useCallback(()=>{const a=Se();tt({colIndex:a.left},{colIndex:a.right})},[]),an=k(()=>{j.cell&&e?.current&&Ne(j.cell)},[j.cell]),An=c.useCallback((a=!1)=>{const f={rowIndex:Se().top};a?tt(f):Je(f),Ne(f)},[]),$n=c.useCallback((a=!1)=>{const f={rowIndex:Se().bottom};a?tt(f):Je(f),Ne(f)},[]),_n=c.useCallback((a=!1)=>{const f={colIndex:Se().left};a?tt(f):Je(f),Ne(f)},[]),mn=c.useCallback((a=!1)=>{const f=Se(),m={rowIndex:f.top,colIndex:f.left};a?tt(m):Je(m),Ne(m)},[]),Cn=c.useCallback((a=!1)=>{const f=Se(),m={colIndex:D?.()?.colEnd??f.right};a?tt(m):Je(m),Ne(m)},[D]),un=c.useCallback((a=!1)=>{const f=Se(),m={rowIndex:D?.()?.rowEnd??f.bottom,colIndex:D?.()?.colEnd??f.right};a?tt(m):Je(m),Ne(m)},[D]),In=k(a=>{if(!e.current||j.ranges.length<=1)return;const f=a===et||a===nt;let m=j.rangeIndex+(f?-1:1);m<0?m=j.ranges.length-1:m>j.ranges.length-1&&(m=0);const g=j.ranges[m],b=Fo({cell:{rowIndex:g.rowEnd,colIndex:g.colEnd},rangeIndex:0,ranges:[g]},Ue,A,ut,dt);je(W=>{Ge.current=!1,W=$t(W);const S={...W,cell:b.cell,rangeIndex:m};return Z.isEqualSelectionCoords(S,W)?W:S}),b.cell&&Ne(b.cell)},[j,A]),ho=k(()=>{const a=Pr(j);je(f=>{Ge.current=!1,f=$t(f);const m={...f,visibleSelection:a};return Z.isEqualSelectionCoords(m,f)?f:m}),a.cell&&Ne(a.cell)},[j,A]),fo=k(()=>{if(!e.current||j.ranges.length===0)return;const a=j.cell,f=j.ranges[j.rangeIndex],m=Pr({cell:a,rangeIndex:0,ranges:[f]}),g=m.ranges[m.rangeIndex];let b;b=g.rowStart===a.rowIndex&&g.colStart===a.colIndex?{rowIndex:g.rowStart,colIndex:g.colEnd}:g.rowStart===a.rowIndex&&g.colEnd===a.colIndex?{rowIndex:g.rowEnd,colIndex:g.colStart}:g.rowEnd===a.rowIndex&&g.colStart===a.colIndex?{rowIndex:g.rowEnd,colIndex:g.colEnd}:{rowIndex:g.rowStart,colIndex:g.colStart},je(W=>{W=$t(W);const S={...W,cell:b};return Z.isEqualSelectionCoords(S,W)?W:S}),b&&Ne(b)},[j,A]),Bn=c.useCallback((a=!1)=>{at(ot,a,!1,e.current.getDimensions().containerHeight)},[]),Kt=c.useCallback((a=!1)=>{at(nt,a,!1,e.current.getDimensions().containerHeight)},[]),Fn=c.useCallback((a=!1)=>{at(Ue,a,!1,e.current.getDimensions().containerWidth)},[]),Mn=c.useCallback((a=!1)=>{at(et,a,!1,e.current.getDimensions().containerWidth)},[]),Vn=c.useCallback(()=>{Zt(et)},[]),Wn=c.useCallback(()=>{Zt(Ue)},[]),po=c.useCallback(()=>{Zt(nt)},[]),go=c.useCallback(()=>{Zt(ot)},[]),Rn=c.useCallback(()=>{In(et)},[]),wo=c.useCallback(()=>{In(Ue)},[]),mo=c.useCallback(()=>{fo()},[]),Hn=c.useCallback(()=>{at(et,!1,!1)},[]),v=c.useCallback(()=>{at(et,!0,!1)},[]),L=c.useCallback(()=>{at(et,!1,!0)},[]),z=c.useCallback(()=>{at(et,!0,!0)},[]),F=c.useCallback(()=>{at(Ue,!1,!1)},[]),V=c.useCallback(()=>{at(Ue,!0,!1)},[]),he=c.useCallback(()=>{at(Ue,!1,!0)},[]),le=c.useCallback(()=>{at(Ue,!0,!0)},[]),xe=c.useCallback(()=>{at(nt,!1,!1)},[]),ye=c.useCallback(()=>{at(nt,!0,!1)},[]),se=c.useCallback(()=>{at(nt,!1,!0)},[]),Be=c.useCallback(()=>{at(nt,!0,!0)},[]),st=c.useCallback(()=>{at(ot,!1,!1)},[]),Ae=c.useCallback(()=>{at(ot,!0,!1)},[]),$e=c.useCallback(()=>{at(ot,!1,!0)},[]),ft=c.useCallback(()=>{at(ot,!0,!0)},[]),Xe=c.useCallback(()=>{Ke(a=>a.slice(0,-1))},[]),Mt=c.useMemo(()=>{const a=Se();return((f,m,g,b,W)=>{for(let S=0;S<f.length;S++){const de=f[S];if(de.rowStart===m&&de.colStart===g&&de.rowEnd===b&&de.colEnd===W)return!0}return!1})(j.ranges,a.top,a.left,a.bottom,a.right)},[$,j.ranges]),wt=c.useCallback((a,f=!0)=>{We.current=a,ht(a),f&&a&&e?.current&&Ne(a)},[]),pe=k((a=!0)=>{const f=Yt.current;if(!Re.current?.cell)return;const m=Re.current?.ranges,g=Re.current?.cell;if(!g||!f||!f)return;let b=null;if(b=m.length>0?m[m.length-1]:A(g),b.colEnd>=b.colStart&&b.rowEnd>=b.rowStart){const W=Or(b,f);let S=a?E:ue;try{S?.(b,f,W.direction)}catch(de){console.warn(de)}finally{a&&fe?.()}}},[A]),pt=c.useRef(null),Pt=vn(c.useMemo(()=>({onPointerDown:(a,f)=>{if(It.current=f,!e||!e.current)return!1;const m=e.current.getViewFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY),g=m?.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);g&&(a.stopPropagation(),qt("crosshair"),pt.current={anchor:m.getAnchor(),coords:g})},onPointerMoveOrWait:(a,f)=>{if(_||!e?.current||!Re.current||!pt.current)return;const m=pt.current.anchor;let g=e.current.getViewFromLocation(m),b=g.getCellCoordsFromClient(a.clientX,a.clientY);if(!b)return;pt.current={anchor:m,coords:b};const W=Re.current.ranges;let S=Ee(Re.current.cell,b);if(!S)return;const de=W.length>0,te=de?W[W.length-1]:A(Re.current.cell);if(!S)return;const oe=S.rowStart<te.rowStart?nt:S.rowEnd>te.rowEnd?ot:S.colEnd>te.colEnd?Ue:et,ge=Se();oe===et&&(S={...te,colStart:Math.max(ge.left,S.colStart)}),oe===nt&&(S={...te,rowStart:Math.max(ge.top,S.rowStart)}),oe===Ue&&(S={...te,colEnd:Math.min(ge.right,S.colEnd)}),oe===ot&&(S={...te,rowEnd:Math.min(ge.bottom,S.rowEnd)});const Oe=Or(te,S);if(!N?.(te)){let ae;typeof Ze.current=="function"?ae=Ze.current(te):q&&(ae=q),S=((re,vt,B,ke,Ct,Ie)=>{const Ce={...vt};if(B.length===0)return Ce;if(Ct===et){const xt=re.colEnd+1-re.colStart;Ce.colStart=re.colStart-Math.ceil(Ie/xt)*xt,Ce.colStart<ke.left&&(Ce.colStart=Ce.colStart+Math.ceil((ke.left-Ce.colStart)/xt)*xt)}else if(Ct===Ue){const xt=re.colEnd+1-re.colStart;Ce.colEnd=re.colEnd+Math.ceil(Ie/xt)*xt,Ce.colEnd>ke.right&&(Ce.colEnd=Ce.colEnd-Math.ceil((ke.right-Ce.colEnd)/xt)*xt)}else if(Ct===nt){const xt=re.rowEnd+1-re.rowStart;Ce.rowStart=re.rowStart-Math.ceil(Ie/xt)*xt,Ce.rowStart<ke.top&&(Ce.rowStart=Ce.rowStart+Math.ceil((ke.top-Ce.rowStart)/xt)*xt)}else if(Ct===ot){const xt=re.rowEnd+1-re.rowStart;Ce.rowEnd=re.rowEnd+Math.ceil(Ie/xt)*xt,Ce.rowEnd>ke.bottom&&(Ce.rowEnd=Ce.rowEnd-Math.ceil((ke.bottom-Ce.rowEnd)/xt)*xt)}return Ce})(te,S,ae,ge,Oe.direction,Oe.amount)}if(de&&Z.isRangeWithinRange(S,te)&&(S=null),!Z.isEqualRanges(S,Yt.current)){if(tn(S),Yt.current=S,!S){try{X?.()}catch{}return void fe?.()}pe(!1)}It.current=f,Gn(g,b,e)},onPointerUp:(a,f)=>{It.current=f,Promise.resolve(pe(!0)).finally(()=>{fe?.(),tn(null),Yt.current=null,pt.current=null,qt(null),e.current?.focus()})}}),[A])),At=c.useMemo(()=>({onPointerDown:Pt}),[Pt]),[_e,Ye]=c.useState(null),ze=c.useRef(null),rt=c.useMemo(()=>({onPointerDown:(a,f)=>{if(It.current=f,!e||!e.current)return!1;const m=e.current.getViewFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY),g=m?.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);if(!g)return;if(ne?.(a,g,j)===!1)return!1;a.stopPropagation(),qt("default");const b=m.getRelativePointFromClient(0,0),W=Re.current?.ranges[Re.current?.ranges.length-1]??Z.cellToRange(Re.current?.cell),S=m.toClipBounds(m.getRangeCoordsBounds(W)),de={x:0,y:0};S.x-b.x>a.nativeEvent.clientX?de.x=a.nativeEvent.clientX-(S.x-b.x):a.nativeEvent.clientX>=S.x-b.x+S.width&&(de.x=Math.max(0,a.nativeEvent.clientX-(S.x-b.x+S.width))+1),S.y-b.y>a.nativeEvent.clientY?de.y=a.nativeEvent.clientY-(S.y-b.y):a.nativeEvent.clientY>=S.y-b.y+S.height&&(de.y=Math.max(0,a.nativeEvent.clientY-(S.y-b.y+S.height))+1),Y?.(W,a.nativeEvent,f),ze.current={range:W,anchor:m.getAnchor(),cell:g,isMoving:!1,extrusion:de}},onPointerMoveOrWait:(a,f,m)=>{if(H||!e?.current||!Re.current||!ze.current)return;const g=a.clientX-m.clientX,b=a.clientY-m.clientY;if(ze.current.isMoving=ze.current.isMoving||Math.abs(g)>Math.max(1,2)||Math.abs(b)>Math.max(1,2)||performance.now()-m.timeStamp>500,!ze.current.isMoving)return;const W=ze.current.anchor,S=ze.current.extrusion;let de=e.current.getViewFromLocation(W),te=de.getCellCoordsFromClient(a.clientX-S.x,a.clientY-S.y,!0);if(!te)return;const oe=ze.current.cell,ge=ze.current.range,Oe=Se(),ae=ge.colEnd-ge.colStart+1,re=Math.min(Math.max(0,oe.colIndex-ge.colStart),ae-1),vt=Math.min(Oe.right-ae+1,Math.max(Oe.left,te.colIndex-re)),B=ge.rowEnd-ge.rowStart+1,ke=Math.min(Math.max(0,oe.rowIndex-ge.rowStart),B-1),Ct=Math.min(Oe.bottom-B+1,Math.max(Oe.top,te.rowIndex-ke)),Ie={colStart:vt,colEnd:vt+ae-1,rowStart:Ct,rowEnd:Ct+B-1};Z.isEqualRanges(_e,Ie)&&!(Ce=>!Ce||!It.current||It.current.ctrlKey!==Ce.ctrlKey||It.current.shiftKey!==Ce.shiftKey||It.current.altKey!==Ce.altKey||It.current.metaKey!==Ce.metaKey)(a)||(Ye(Ie),O?.(Ie,a,f)),It.current=f,Gn(de,te,e)},onPointerUp:(a,f)=>{It.current=f;const m=()=>{Ye(null),ze.current=null,qt(null),e.current?.focus()};if(!ze.current)return void m();const g=ze.current.range,b=_e;h?.(g,a,f),Promise.resolve(g&&b&&M?.(g,b,a,f)).finally(()=>{m()})}}),[_e]),Te=vn(rt),yt=c.useMemo(()=>({onPointerDown:Te}),[Te]),mt=c.useRef(null),Ot=c.useMemo(()=>{const a=Z.isEqualSelectionCoords(j,mt.current)?mt.current:j;return mt.current=a,a},[j]),Vt=c.useCallback(a=>{let f=null,m="br";const g=[],b={stroke:I,fill:me,strokeWidth:.5},W=(ae,re,vt)=>{const B=a.toClipBounds(a.getRangeCoordsBounds(ae),Wt);if(!B)return;B.x=B.width>0?B.x:B.x-b.strokeWidth/2,B.y=B.height>0?B.y:B.y-b.strokeWidth/2,B.width=Math.max(B.width,b.strokeWidth),B.height=Math.max(B.height,b.strokeWidth);const ke={key:`selection-fill-${re}`,range:ae,...B,...b};if(vt){const Ct=a.getCellCoordsAsRangeCoords(vt);ke.cell=vt,ke.pathBounds=a.toClipBounds(a.getRangeCoordsBounds(Ct),Wt),ke.pathBounds&&(ke.pathBounds.width<=0||ke.pathBounds.height<=0)&&(delete ke.pathBounds,delete ke.cell)}return Me(ke)};let S=j?$t(j):null;const de=S?.cell?a.getCellCoordsAsRangeCoords(S?.cell):Wl;!S||S.ranges&&S.ranges.length!==0||(S={ranges:[de],rangeIndex:0,cell:S.cell});for(let ae=0;S&&ae<S.ranges.length;ae++){const re=S.ranges[ae],vt=W(re,ae,ae===S.rangeIndex?S.cell:null);vt&&g.push(vt);const B=2,ke=.5,Ct=a.toClipBounds(a.getRangeCoordsBounds(re,{top:0,left:0,right:0,bottom:0}),Wt);if(Ct){const Ie=(S.ranges.length,4);g.push(Me({range:re,key:`selection-inside-edge-${ae}`,x:Ct.x-1,y:Ct.y-1,width:Math.max(Ct.width+1,0),height:Math.max(Ct.height+1,0),style:{overflow:"hidden"},stroke:I,strokeWidth:Ie}))}if(S.ranges.length===1){const Ie=a.toClipBounds(a.getRangeCoordsBounds(re),Wt);if(Ie){H||g.push(Me({range:re,key:`move-selection-hit-box-${ae}`,x:Ie.width>1?Ie.x:Ie.x-(K/2+1),y:Ie.height>1?Ie.y:Ie.y-(K/2+1),width:Math.max(Ie.width+2,1),height:Math.max(Ie.height+2,1),stroke:"transparent",style:{boxShadow:"none"},pathProps:{cursor:_e?void 0:"move",pointerEvents:"stroke"},strokeWidth:K,...yt}));const Ce=B;g.push(Me({range:re,key:`selection-single-${ae}`,x:Ie.x-Ce/2,y:Ie.y-Ce/2,width:Math.max(Ie.width+Ce/2,1),height:Math.max(Ie.height+Ce/2,1),stroke:G,strokeWidth:Ce}))}}else{const Ie=a.toClipBounds(a.getRangeCoordsBounds(re,{top:-1,left:-1,right:-2,bottom:-2}),Wt);Ie&&g.push(Me({range:re,key:`selection-multi-${ae}`,x:Ie.width>1?Ie.x:Ie.x-ke/2,y:Ie.height>1?Ie.y:Ie.y-ke/2,width:Math.max(Ie.width,ke)+1,height:Math.max(Ie.height,ke)+1,stroke:G,style:{overflow:"hidden"},strokeWidth:2}))}if(S.ranges.length>1&&ae===S.rangeIndex){const Ie=a.getCellCoordsAsRangeCoords(S.cell),Ce=a.toClipBounds(a.getRangeCoordsBounds(Ie,{top:1,left:1,right:-1,bottom:-1}),Wt);Ce&&g.push(Me({range:re,key:`selection-anchor-${ae}`,x:Ce.x,y:Ce.y,width:Math.max(Ce.width,ke),height:Math.max(Ce.height,ke),stroke:G,style:{overflow:"hidden"},strokeWidth:2}))}if(ae===S.ranges.length-1){f=null,m=null;const Ie=re.rowStart===Se().top&&re.rowEnd===Se().bottom,Ce=re.colStart===Se().left&&re.colEnd===Se().right,xt=a.getRangeCoordsBounds(re);let Xt=null;if(Ie||Ce){if(Xt=a.toClipBounds(xt,Wt),Object.keys(a.allViews()).length>1){const Nn=a.getVisibleRangeCoords(),Zo=a.allViews()[to],Ei=a.allViews()[Ln],_i=a.allViews()[Dn],Un=a.getAnchor();(Ce&&(Un===Ln&&Zo||Un===Ht&&_i||!Z.isCellWithinRange({colIndex:re.colStart,rowIndex:re.rowEnd},Nn)&&!Z.isCellWithinRange({colIndex:re.colStart,rowIndex:re.rowEnd+1},Nn))||Ie&&(Un===Dn&&Zo||Un===Ht&&Ei||!Z.isCellWithinRange({colIndex:re.colEnd,rowIndex:re.rowStart},Nn)&&!Z.isCellWithinRange({colIndex:re.colEnd+1,rowIndex:re.rowStart},Nn)))&&(Xt=null)}}else Xt=a.toClipBounds(xt,Wt);if(!Xt||Xt.width===0||Xt.height===0)continue;f={x:Xt.x+Xt.width+1,y:Xt.y+Xt.height+1},Xt.width===0||Xt.height===0||re.rowStart===Se().top&&re.colStart===Se().left&&re.rowEnd===Se().bottom&&re.colEnd===Se().right||(Ie?(f.y=B,m="tr"):Ce&&(f.x=B,m="bl"))}}let te=null;if(Le){const ae=a.toClipBounds(a.getRangeCoordsBounds(Le,{top:0,left:0,right:0,bottom:0}),Wt);ae&&(te=Me({...b,range:Le,key:"remove-selection",x:ae.x,y:ae.y,width:ae.width,height:ae.height,strokeWidth:2,stroke:Ve,fill:He}))}let oe=null;if(zt){const ae=a.toClipBounds(a.getRangeCoordsBounds(zt,{top:0,left:0,right:0,bottom:0}),Wt);ae&&(oe=Me({range:zt,key:"selection-fill-outline",x:ae.x-2/2,y:ae.y-2/2,width:ae.width+2/2,height:ae.height+2/2,strokeWidth:2,stroke:G,strokeDasharray:"3 2"}))}let ge=null;!_&&f&&!_e&&(ge=c.createElement(Wo,{...f,corner:m,size:7.5,borderStroke:`${I} solid`,style:{borderRadius:1},background:G,...At,key:"fillHandle"}));const Oe=[...g];if(te&&Oe.push(te),oe&&Oe.push(oe),ge&&Oe.push(ge),!Fe&&Et&&S?.ranges.length===1&&S.ranges[S.ranges.length-1]){const ae=S.ranges[S.ranges.length-1],re=ae.rowStart===Se().top&&ae.rowEnd===Se().bottom,vt=ae.colStart===Se().left&&ae.colEnd===Se().right,B={view:a,range:ae,borderStroke:`${G} solid`,background:I,selectionTouchPointerHandler:co,...ct,onTouchSelectStart:ke=>nn(ke),onTouchSelectEnd:()=>nn(null),currentTouchAnchor:wn};Oe.push(T.jsx(Qn,{anchor:vt?"b":re?"r":"br",scrollableElement:e.current,...B},"touch-select-handle-after")),Oe.push(T.jsx(Qn,{anchor:vt?"t":re?"l":"tl",scrollableElement:e.current,...B},"touch-select-handle-before"))}if(_e){const ae=a.toClipBounds(a.getRangeCoordsBounds(_e,{top:1,left:1,right:1,bottom:1}),Wt);ae&&Oe.push(Me({range:_e,key:"selection-move-outline",x:ae.x-U/2,y:ae.y-U/2,width:Math.max(ae.width+U/2,1),height:Math.max(ae.height+U/2,1),stroke:G,style:{boxShadow:"none",transitionDuration:"70ms",transitionTimingFunction:"ease-in",transitionProperty:"left, top, width, height",willChange:"left, top, width, height"},strokeWidth:U}))}return T.jsx("div",{children:Oe},"selection")},[Ot,Le,_,zt,H,_e,Se,I,G,me,Ve,He,Fe,ct,wn]),Rt=c.useMemo(()=>{const a=()=>e.current;return[new be("moveToPageDown",a,{label:"Page Down",description:"Shift viewport down one page.",shortcut:[{key:"PageDown"}]},()=>Bn(!1)),new be("selectToPageDown",a,{label:"Select To Page Down",description:"Shift viewport and select down one page.",shortcut:[{key:"PageDown",modifiers:[bt]}]},()=>Bn(!0)),new be("moveToPageRight",a,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[dn]}]},()=>Fn(!1)),new be("selectToPageRight",a,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[dn,bt]}]},()=>Fn(!0)),new be("moveToPageUp",a,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp"}]},()=>Kt(!1)),new be("selectToPageUp",a,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp",modifiers:[bt]}]},()=>Kt(!0)),new be("moveToPageLeft",a,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[dn]}]},()=>Mn(!1)),new be("selectToPageLeft",a,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[dn,bt]}]},()=>Mn(!0)),new be("selectColumn",a,{label:"Select Column",description:"Select the columns for the selected cells.",shortcut:{key:"Space",modifiers:[kt]}},ao),new be("selectRow",a,{label:"Select Row",description:"Select the rows for the selected cells.",shortcut:{key:"Space",modifiers:[bt]}},uo),new be("selectToColumnStart",a,{label:"Select To Column Start",description:"Select the columns to the beginning of the sheet."},()=>An(!0)),new be("selectToColumnEnd",a,{label:"Select To Column End",description:"Select the columns to the end of the sheet."},()=>$n(!0)),new be("moveToRowStart",a,{label:"Move to Row Home",description:"Move to the beginning of the row.",shortcut:[{key:"Home"}]},()=>_n(!1)),new be("selectToRowStart",a,{label:"Select to Row Home",description:"Select to the beginning of the row.",shortcut:[{key:"Home",modifiers:[bt]}]},()=>_n(!0)),new be("moveToSheetStart",a,{label:"Move to Sheet Home",description:"Move to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[kt]}]},()=>mn(!1)),new be("selectToSheetStart",a,{label:"Select to Sheet Home",description:"Select to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[kt,bt]}]},()=>mn(!0)),new be("moveToRowEnd",a,{label:"Move to Row End",description:"Move to the end of the row.",shortcut:[{key:"End"}]},()=>Cn(!1)),new be("selectToRowEnd",a,{label:"Select to Row End",description:"Select to the end of the row.",shortcut:[{key:"End",modifiers:[bt]}]},()=>Cn(!0)),new be("moveToSheetEnd",a,{label:"Move to Sheet End",description:"Move to the end of the sheet.",shortcut:[{key:"End",modifiers:[kt]}]},()=>un(!1)),new be("selectToSheetEnd",a,{label:"Select to Sheet End",description:"Select to the end of the sheet.",shortcut:[{key:"End",modifiers:[kt,bt]}]},()=>un(!0)),new be("scrollToActiveCoords",a,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell.",shortcut:{key:"Backspace",modifiers:[kt]}},an),new be("scrollToActiveCoordsClearSelection",a,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell and clear selection.",shortcut:{key:"Backspace",modifiers:[bt]}},()=>{Gt(),wt(j.cell,!0)}),new be("traverseSelectionRight",a,{label:"Traverse Right",description:"Traverse the selection moving rightward.",shortcut:{key:"Tab"}},Wn),new be("traverseSelectionLeft",a,{label:"Traverse Left",description:"Traverse the selection moving leftward.",shortcut:{key:"Tab",modifiers:[bt]}},Vn),new be("traverseSelectionDown",a,{label:"Traverse Down",description:"Traverse the selection moving downward.",shortcut:[{key:"Enter"},{key:"NumpadEnter"}]},go),new be("traverseSelectionUp",a,{label:"Traverse Up",description:"Traverse the selection moving upward.",shortcut:[{key:"Enter",modifiers:[bt]},{key:"NumpadEnter",modifiers:[bt]}]},po),new be("moveLeft",a,{label:"Move Left",description:"Move active cell to the left.",shortcut:[{key:"ArrowLeft"}]},Hn),new be("selectLeft",a,{label:"Select Left",description:"Extend selection left.",shortcut:[{key:"ArrowLeft",modifiers:[bt]}]},v),new be("moveContentfulLeft",a,{label:"Move Left Contentful",description:"Move left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[kt]}]},L),new be("selectContentfulLeft",a,{label:"Select Left Contentful",description:"Extend selection left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[kt,bt]}]},z),new be("moveRight",a,{label:"Move Right",description:"Move active cell to the right.",shortcut:[{key:"ArrowRight"}]},F),new be("selectRight",a,{label:"Select Right",description:"Extend selection right.",shortcut:[{key:"ArrowRight",modifiers:[bt]}]},V),new be("moveContentfulRight",a,{label:"Move Right Contentful",description:"Move right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[kt]}]},he),new be("selectContentfulRight",a,{label:"Select Right Contentful",description:"Extend selection right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[kt,bt]}]},le),new be("moveUp",a,{label:"Move Up",description:"Move active cell to the up.",shortcut:[{key:"ArrowUp"}]},xe),new be("selectUp",a,{label:"Select Up",description:"Extend selection up.",shortcut:[{key:"ArrowUp",modifiers:[bt]}]},ye),new be("moveContentfulUp",a,{label:"Move Up Contentful",description:"Move up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[kt]}]},se),new be("selectContentfulUp",a,{label:"Select Up Contentful",description:"Extend selection up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[kt,bt]}]},Be),new be("moveDown",a,{label:"Move Down",description:"Move active cell to the down.",shortcut:[{key:"ArrowDown"}]},st),new be("selectDown",a,{label:"Select Down",description:"Extend selection down.",shortcut:[{key:"ArrowDown",modifiers:[bt]}]},Ae),new be("moveContentfulDown",a,{label:"Move Down Contentful",description:"Move down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[kt]}]},$e),new be("selectContentfulDown",a,{label:"Select Down Contentful",description:"Extend selection down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[kt,bt]}]},ft),new be("selectVisible",a,{label:"Select Visible",description:"Select visible cells only.",shortcut:{key:";",modifiers:[dn]}},ho),new be("traverseSelectionPreviousRange",a,{label:"Traverse Previous Range",description:"Traverse the selection to the previous range.",shortcut:{key:"ArrowLeft",modifiers:[kt,dn]}},Rn),new be("traverseSelectionNextRange",a,{label:"Traverse Next Range",description:"Traverse the selection to the next range.",shortcut:{key:"ArrowRight",modifiers:[kt,dn]}},wo),new be("traverseSelectionCorners",a,{label:"Traverse Corners",description:"Traverse the selection through the corners of the selected range.",shortcut:{key:".",modifiers:[kt]}},mo)]},[]);return c.useMemo(()=>{t?.addCommands(Rt,!0)},[t]),{selection:Ot,setSelectionCell:wt,setSelectionRanges:Ke,overlay:Vt,cursor:en,onPointerDown:so,clearLastSelection:Xe,newSelection:Je,modifySelection:tt,appendSelection:De,clearSelections:Gt,isEntire:Mt,navigate:at,navigateSelection:Zt}};
|
|
23
|
+
}`,ie=document.createElement("style");return ie.appendChild(document.createTextNode(D)),document.head.appendChild(ie),ie.sheet.insertRule(D,0),()=>{document.head.removeChild(ie)}},[y]),y&&(C={strokeDasharray:`${_.dashLength}px ${_.dashGap}px`,strokeDashoffset:`${I}px`,animation:`${P} ${R}ms linear infinite`,willChange:"stroke-dashoffset"}),T.jsx(hi,{x:o,y:r,width:i,height:l,stroke:t,fill:n,shapeRendering:"crispEdges",style:{...C,...s},...p})});function fi(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=fi(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function fn(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=fi(e))&&(o&&(o+=" "),o+=t);return o}Xo.displayName="Selection";const Wo=c.memo(c.forwardRef((e,t)=>{const{x:n=0,y:o=0,borderWidth:r=1,size:i=6,borderStroke:l,corner:s,style:u,className:d,background:w,...x}=e;if(n===0||o===0)return null;let p=!0,y=!0,_=!0,I=!0;switch(s){case"tl":p=!1,y=!1;break;case"bl":p=!1,I=!1;break;case"br":_=!1,I=!1;break;case"tr":y=!1,_=!1}return T.jsx("div",{className:fn("fill-handle",d),style:{position:"absolute",left:n-(i+(p?r:0))/2,top:o-(i+(y?r:0))/2,width:i,height:i,borderLeft:p?`${r}px ${l}`:void 0,borderTop:y?`${r}px ${l}`:void 0,borderRight:_?`${r}px ${l}`:void 0,borderBottom:I?`${r}px ${l}`:void 0,background:w,cursor:"crosshair",pointerEvents:"all",transitionDuration:"0ms",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top",willChange:"left, top",...u},tabIndex:-1,...x})}));Wo.displayName="FillHandle";var Bl=function(){},pi=typeof window<"u",Fl=pi?c.useLayoutEffect:c.useEffect,jr={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const gi=pi&&window.ResizeObserver!==void 0?function(){var e=c.useState(null),t=e[0],n=e[1],o=c.useState(jr),r=o[0],i=o[1],l=c.useMemo(function(){return new window.ResizeObserver(function(s){if(s[0]){var u=s[0].contentRect,d=u.x,w=u.y,x=u.width,p=u.height,y=u.top,_=u.left,I=u.bottom,R=u.right;i({x:d,y:w,width:x,height:p,top:y,left:_,bottom:I,right:R})}})},[]);return Fl(function(){if(t)return l.observe(t),function(){l.disconnect()}},[t]),[n,r]}:function(){return[Bl,jr]};function ko(e,t){if(typeof e=="function")return e(t);e&&(e.current=t)}var Vl=parseInt(c.version.split(".")[0],10)>=19?function(e){return t=>{const n=[];for(const o of e){const r=ko(o,t),i=typeof r=="function";n.push(i?r:()=>ko(o,null))}return()=>{for(const o of n)o()}}}:function(e){return t=>{for(const n of e)ko(n,t)}};const Qn=c.memo(c.forwardRef((e,t)=>{const{range:n,view:o,anchor:r,borderStroke:i="rgb(33, 115, 70)",background:l="white",borderWidth:s=1.5,size:u=22,style:d,className:w,selectionTouchPointerHandler:x,onTouchSelectStart:p,onTouchSelectEnd:y,currentTouchAnchor:_,scrollableElement:I,scrollableRoot:R=document.body,...ce}=e,P=k(p,[p]),C=k(y,[y]),{bounds:D,coordsPivot:ie,key:$}=c.useMemo(()=>{if(!n||!o)return null;let H=null,A=null;switch(r){case"tl":H={colIndex:n.colEnd,rowIndex:n.rowEnd},A={colIndex:n.colStart,rowIndex:n.rowStart};break;case"br":H={colIndex:n.colStart,rowIndex:n.rowStart},A={colIndex:n.colEnd,rowIndex:n.rowEnd};break;case"t":case"l":H={colIndex:n.colEnd,rowIndex:n.rowEnd};break;case"b":H={colIndex:n.colStart,rowIndex:n.rowStart};break;case"r":H={colIndex:n.colStart,rowIndex:n.rowEnd}}let q=o.getRangeCoordsBounds(A?{rowStart:A.rowIndex,colStart:A.colIndex,rowEnd:A.rowIndex,colEnd:A.colIndex}:n);const U=o.getBounds(),me=o.getViewportSize(),G=U.x,Ve=U.y,He=me.width,Fe=me.height;switch(r){case"tl":break;case"br":q.x=q.x+q.width,q.y=q.y+q.height;break;case"t":q.x=He/2-G;break;case"b":q.x=He/2-G,q.y=q.y+q.height;break;case"l":q.y=Fe/2-Ve;break;case"r":q.x=q.x+q.width,q.y=Fe/2-Ve}const ct=o.toClipBounds(q,0);return!ct||ct.width<=0||ct.height<=0||q.x<0||q.y<0||q.x>He||q.y>Fe?{bounds:null,coordsAnchor:null,coordsPivot:null,key:null}:{bounds:q,coordsAnchor:null,coordsPivot:H,key:"touchSelect-"+o.getAnchor()+"-"+r}},[n,o,r]),ne=c.useRef(null),ve=vn(c.useMemo(()=>{const H=A=>r==="t"||r==="b"?{...A,colIndex:void 0}:r==="l"||r==="r"?{...A,rowIndex:void 0}:A;return{processTouch:!0,consumeTouch:!0,onPointerDown:(A,q)=>{const U=H(o.getCellCoordsFromClient(A.clientX,A.clientY));return ne.current={coordsPivot:ie},P?.(r),x.onSelectionPointerDown(A,q,o,U,ie,!1,!0)},onPointerMoveOrWait:(A,q,U)=>{const me=H(o.getCellCoordsFromClient(A.clientX,A.clientY));return x.onSelectionPointerMoveOrWait(A,q,U,o,me,ne.current?.coordsPivot,!0,!0)},onPointerUp:(A,q,U)=>(ne.current=null,C?.(r),x.onPointerUp(A,q,U))}},[x,n,o,r])),[K,{y:N,x:Y}]=gi(),O=c.useRef(null),{getPortalContainer:h}=si(),[M,Q]=c.useState(null);return c.useEffect(()=>{const H=O.current?.getBoundingClientRect();if(!H||!D)return void Q(null);let A=0,q=0,U=I;for(;U;)A+=U.scrollLeft,q+=U.scrollTop,U=R&&U===R.parentElement?null:U.parentElement;Q(No.createPortal(T.jsx("div",{className:fn("touch-select-handle",w),ref:t,style:{position:"absolute",left:A+(H?.x??0)-(u+s)/2,top:q+(H?.y??0)-(u+s)/2,width:u,height:u,borderWidth:`${s}px`,border:i,borderRadius:"50%",background:l,boxShadow:`0 0 0 1.5px ${l}`,cursor:"grab",pointerEvents:"all",opacity:_?0:1,transitionDuration:"160ms",transitionProperty:"opacity",...d},tabIndex:-1,onPointerDown:ve,...ce}),R??h(),$))},[N,Y,D?.x,D?.y,D?.width,D?.height,w,_,l,u,s,i,I]),D?T.jsxs(T.Fragment,{children:[T.jsx("div",{ref:Vl([K,O]),style:{position:"absolute",left:D.x,top:D.y,opacity:0}}),M]}):null}));Qn.displayName="TouchSelectHandle";const Wt=-10,Wl=Object.freeze({rowStart:0,colStart:0,rowEnd:0,colEnd:0}),wi=Object.freeze({colIndex:0,rowIndex:0}),Ho=Object.freeze([]),$t=e=>{if(e&&e.cell&&e.ranges&&e.rangeIndex>-1&&e.rangeIndex<=e.ranges.length)return e;const t={cell:null,ranges:e?.ranges??Ho};return t.rangeIndex=e?.rangeIndex??t.ranges.length-1,t.cell=e?.cell,!t.cell&&t.ranges.length>0&&(t.cell={rowIndex:t.ranges[t.rangeIndex].rowStart,colIndex:t.ranges[t.rangeIndex].colStart}),t.cell||(t.cell=wi),Z.isEqualSelectionCoords(t,e)?e:t},Gn=(e,t,n)=>{const o=e.getVisibleRangeCoords(),r=e.getScrollOrientation();!r.horizontal&&(t.colIndex>o.colEnd||t.colIndex<o.colStart)&&(t={...t,colIndex:t.colIndex>o.colEnd?o.colEnd+1:o.colEnd-1},e=n.current.getViewFromLocation(Ht)),!r.vertical&&(t.rowIndex>o.rowEnd||t.rowIndex<o.rowStart)&&(t={...t,rowIndex:t.rowIndex>o.rowEnd?o.rowEnd+1:o.rowEnd-1},e=n.current.getViewFromLocation(Ht)),e.scrollCellCoordsIntoView(t)},Hl=()=>!1;function eo(e,t){if(!e)throw new Error("Invariant failed")}const Ar={"sheetxl-grid":"_sheetxl-grid_h9wwa_7"},Nl=Object.freeze({top:0,left:0}),Ul=Object.freeze({bottom:-4,right:-4}),Kl=Object.freeze({horizontal:!0,vertical:!0}),$r=[to,Ln,Dn,Ht],Jt=3e3,To={},Yo=c.memo(c.forwardRef((e,t)=>{const{width:n,height:o,rowCount:r=1,columnCount:i=1,defaultRowHeight:l,defaultColumnWidth:s,getRowHeight:u,getColumnWidth:d,layout:w,onViewportScroll:x,onImmediateScroll:p,showGridLines:y=!0,gridLineColor:_="rgb(224, 224, 224)",gridLineRowsProps:I,gridLineColumnsProps:R,clipCells:ce=!0,cursor:P,freezeLeft:C=0,freezeTop:D=0,freezeLeftProps:ie,freezeTopProps:$,cellRenderer:ne,onViewportChange:ve,onFirstRender:K,overlayRenderer:N,overlayProps:Y,overlays:O,overlaysProps:h,allowOverlaysOverflow:M=!1,stageProps:Q,stageWrapper:H=null,hiddenRowsAt:A,hiddenColumnsAt:q,hiddenCellAt:U,getVisibleCells:me,zoom:G=1,enableMouseWheel:Ve=!0,onWheelScroll:He,getCellCoordsAsRangeCoords:Fe=Z.cellToRange,scrollPoint:ct=Nl,style:Se={},...E}=e;eo(ne),eo(!e?.children);const ue=k(p,[p]),X=k(ve,[ve]),fe=k(x,[x]),ee=k(He,[He]),Me=k(K,[K]),it=c.useRef(null),ut=c.useRef(null),Tt=c.useRef(null),[dt,Ut]=c.useReducer(v=>v+1,0),[je,j]=c.useState({left:ct?.left??0,top:ct?.top??0,horizontalScrollDirection:null,verticalScrollDirection:null}),Re=c.useRef(null),Ge=c.useRef(je),{top:qe,left:ht,verticalScrollDirection:en,horizontalScrollDirection:Kt}=je,zt=c.useRef(!1),tn=di({rowCount:r,columnCount:i,defaultRowHeight:l,defaultColumnWidth:s,getRowHeight:u,getColumnWidth:d}),Yt=c.useRef(null),Le=c.useMemo(()=>{const v=w||tn;return Yt.current=null,{getColOffset:L=>v.getColOffset(L)*G,getColIndex:L=>v.getColIndex(L/G),getRowOffset:L=>v.getRowOffset(L)*G,getRowIndex:L=>v.getRowIndex(L/G)}},[tn,w,G]),Ft=(v,L,z)=>{const F=(L?.left??0)+0,V=(L?.top??0)+0;return{getColOffset:he=>v.getColOffset(he)-F,getColIndex:he=>v.getColIndex(he+F),getRowOffset:he=>v.getRowOffset(he)-V,getRowIndex:he=>v.getRowIndex(he+V)}},gt=c.useCallback((v,L=!1)=>io(v,L,Le.getRowOffset,L?0:r),[r,Le?.getRowOffset]),jt=k(A??gt,[A]),wn=c.useCallback((v,L=!1)=>io(v,L,Le.getColOffset,L?i:0),[i,Le?.getColOffset]),nn=k(q??wn,[q]),We=c.useMemo(()=>Math.min(n??800,Le.getColOffset(i)),[Le.getColOffset,i,n]),J=c.useMemo(()=>Math.min(o??600,Le.getRowOffset(r)),[Le.getRowOffset,r,o]),Ze=c.useCallback(v=>{St.canUseDOM&&setTimeout(()=>{it.current?.focus({preventScroll:!0,...v})},0)},[]),Ne=c.useCallback(v=>it.current?.contains(v)||ut.current?.contains(v),[]);c.useEffect(()=>{zt.current&&(Re.current&&Re.current.left!==Ge.current?.left&&Re.current.top!==Ge.current?.top||(Re.current=null,fe?.({left:ht,top:qe})))},[ht,qe]);const lt=k(()=>({top:qe,left:ht}),[qe,ht]),Ee=c.useMemo(()=>{const v=[];let L=0,z=0;typeof D=="number"?L=D:(L=D.index??0,z=(D.scrollOffset??0)*G);const F=z,V=Le.getRowOffset(L),he=V-F;if(L>0){const st=Ft(Le,{top:z+Le.getRowOffset(0)}),Ae=Le.getRowIndex(F),$e=Le.getRowIndex(V-1);let ft;v[1]={minIndex:Ae,maxIndex:$e,minCoord:0,maxCoord:L-1,minBounds:0,maxBounds:he,visibleIndices:()=>ft||(ft=Object.freeze(Yn(jt,Ae,$e)),ft),layout:st,maxVirtualBounds:V,scrollOffset:z,freezeOffset:z}}const le=Math.max(0,J-he),xe=Ft(Le,{top:qe+he}),ye=xe.getRowIndex(0),se=xe.getRowIndex(le);let Be;return v[0]={minIndex:ye,maxIndex:se,minCoord:L,maxCoord:r-1,minBounds:he,maxBounds:le,visibleIndices:()=>Be||(Be=Object.freeze(Yn(jt,ye,se)),Be),layout:xe,maxVirtualBounds:Le.getRowOffset(r),scrollOffset:qe,freezeOffset:(L>0?Le.getRowOffset(L):0)-z},v},[Le.getRowIndex,Le.getRowOffset,jt,J,r,D,qe,G]),Pe=c.useMemo(()=>{const v=[];let L=0,z=0;typeof C=="number"?L=C:(L=C.index??0,z=(C.scrollOffset??0)*G);const F=z,V=Le.getColOffset(L),he=V-F;if(L>0){const st=Ft(Le,{left:z+Le.getColOffset(0)}),Ae=Le.getColIndex(F),$e=Le.getColIndex(V-1);let ft;v[1]={minIndex:Ae,maxIndex:$e,minCoord:0,maxCoord:L-1,minBounds:0,maxBounds:he,visibleIndices:()=>ft||(ft=Object.freeze(Yn(nn,Ae,$e)),ft),layout:st,maxVirtualBounds:V,scrollOffset:z,freezeOffset:z}}const le=Math.max(0,We-he),xe=Ft(Le,{left:ht+he}),ye=xe.getColIndex(0),se=xe.getColIndex(le);let Be;return v[0]={minIndex:ye,maxIndex:se,minCoord:L,maxCoord:i-1,minBounds:he,maxBounds:le,visibleIndices:()=>Be||(Be=Object.freeze(Yn(nn,ye,se)),Be),layout:xe,maxVirtualBounds:Le.getColOffset(i),scrollOffset:ht,freezeOffset:(L>0?Le.getColOffset(L):0)-z},v},[Le.getColIndex,Le.getColOffset,nn,We,i,C,ht,G]),tt=c.useRef({}),Je=c.useRef([]),De=c.useMemo(()=>{let v={};const L=(F,V,he,le,xe)=>{const ye={vertical:le?.vertical||!1,horizontal:le?.horizontal||!1};if(F>=Pe.length||V>=Ee.length)return null;const se={rowStart:Ee[V].minIndex,colStart:Pe[F].minIndex,rowEnd:Ee[V].maxIndex,colEnd:Pe[F].maxIndex};if(se.rowStart>se.rowEnd||se.colStart>se.colEnd)return null;const Be={getColIndex:_e=>Pe[F].layout.getColIndex(_e),getColOffset:_e=>Pe[F].layout.getColOffset(_e),getRowIndex:_e=>Ee[V].layout.getRowIndex(_e),getRowOffset:_e=>Ee[V].layout.getRowOffset(_e)},st=Object.freeze({left:xe?.left??0,top:xe?.top??0,right:xe?.right??0,bottom:xe?.bottom??0}),Ae=Object.freeze({x:Pe[F].minBounds,y:Ee[V].minBounds,width:Pe[F].maxBounds,height:Ee[V].maxBounds}),$e=(_e,Ye)=>Dr(Be,_e??se,Ye),ft={width:Pe[F].maxVirtualBounds,height:Ee[V].maxVirtualBounds},Xe={left:Pe[F].scrollOffset,top:Ee[V].scrollOffset},Mt={left:Pe[F].freezeOffset,top:Ee[V].freezeOffset},wt={width:We,height:J};let pe=null,pt=null;const Pt=(Mt.top+(le.vertical?Xe.top:0))/G,At=(Mt.left+(le.horizontal?Xe.left:0))/G;return{getStage:()=>it.current??null,getVisibleRangeCoords:()=>se,toClipBounds:(_e,Ye)=>{let ze,rt=0;return Ye===void 0||typeof Ye=="number"?(ze=$e(se),rt=Ye):ze=Ye,((Te,yt,mt=0)=>{if(Te.x>yt.width||Te.y>yt.height)return null;const Ot={left:Te.x,top:Te.y,bottom:Te.height+Te.y,right:Te.width+Te.x},Vt={left:yt.x+mt,top:yt.y+mt,bottom:yt.height-2*mt+yt.y,right:yt.width-2*mt+yt.x},Rt={left:Math.max(Ot.left,Vt.left),top:Math.max(Ot.top,Vt.top),bottom:Math.min(Ot.bottom,Vt.bottom),right:Math.min(Ot.right,Vt.right)},a={x:Rt.left,y:Rt.top,width:Rt.right-Rt.left,height:Rt.bottom-Rt.top};return a.height<0||a.width<0?null:a})(_e??{x:0,y:0,width:Ae.width,height:Ae.height},ze,rt)},toViewBounds:_e=>At===0&&Pt===0&&G===1?_e:{x:(_e.x-At)*G,y:(_e.y-Pt)*G,width:_e.width*G,height:_e.height*G},toAbsoluteBounds:_e=>At===0&&Pt===0&&G===1?_e:{x:_e.x/G+At,y:_e.y/G+Pt,width:_e.width/G,height:_e.height/G},getRelativePointFromClient:(_e,Ye)=>{const ze=on(_e,Ye);return{x:ze.x-Ae.x,y:ze.y-Ae.y}},getLayout:()=>Be,getCellCoordsAsRangeCoords:Fe,getVisibleColumns:()=>Pe[F].visibleIndices(),getVisibleRows:()=>Ee[V].visibleIndices(),getVisibleColumnOffsets:()=>(pe||(pe=Lr(Pe[F].layout,!0,Pe[F].visibleIndices(),se.colStart,se.colEnd)),pe),getVisibleRowOffsets:()=>(pt||(pt=Lr(Ee[V].layout,!1,Ee[V].visibleIndices(),se.rowStart,se.rowEnd)),pt),getTotalRangeCoords:()=>({colStart:Pe[F].minCoord,colEnd:Pe[F].maxCoord,rowStart:Ee[V].minCoord,rowEnd:Ee[V].maxCoord}),getRangeCoordsBounds:$e,scrollCellCoordsIntoView:(_e,Ye)=>_n(_e,Ye,he),getCellCoordsFromClient:(_e,Ye,ze=!1)=>{const rt=on(_e,Ye);if(!rt)return null;const Te=Be.getColIndex(rt.x-Ae.x),yt={rowIndex:Be.getRowIndex(rt.y-Ae.y),colIndex:Te};if(ze)return yt;const mt=Fe(yt);return{rowIndex:mt.rowStart,colIndex:mt.colStart}},getZoom:()=>G,getAnchor:()=>he,getBounds:()=>Ae,getInsets:()=>st,getTotalSize:()=>ft,getViewportSize:()=>wt,getScrollTopLeft:()=>Xe,getFreezeTopLeft:()=>Mt,getScrollOrientation:()=>ye,allViews:()=>v}};let z=v[Ht]=L(0,0,Ht,Kl,Ul);return z&&(v[Ht]=z),z=L(0,1,Ln,{horizontal:!0}),z&&(v[Ln]=z),z=L(1,0,Dn,{vertical:!0}),z&&(v[Dn]=z),z=L(1,1,to,{}),z&&(v[to]=z),tt.current=null,v=Object.freeze(v)},[Ee,Pe,Fe]),Gt=Object.keys(De),Et=Pe[0]?.maxVirtualBounds??0,Qe=Ee[0]?.maxVirtualBounds??0,_t=c.useMemo(()=>({left:Pe[1]?Pe[1].layout.getColOffset(Pe[1].maxIndex+1):0,top:Ee[1]?Ee[1].layout.getRowOffset(Ee[1].maxIndex+1):0}),[De]);c.useEffect(()=>{if(Je.current.length>0){for(let v=0;v<Je.current.length;v++)Je.current[v]();Je.current=[]}},[De]);const It=k(()=>({containerWidth:We,containerHeight:J,totalWidth:Et,totalHeight:Qe}),[We,J,Le]);c.useEffect(()=>{!Re.current&&zt.current&&X({top:qe,left:ht,width:We,height:J,totalWidth:Et,totalHeight:Qe})},[qe,ht,Et,Qe]),c.useEffect(()=>{zt.current&&X({top:qe,left:ht,width:We,height:J,totalWidth:Et,totalHeight:Qe})},[We,J]);const on=c.useCallback((v,L)=>{eo(typeof v=="number"&&typeof L=="number");const z=it.current?.getBoundingClientRect();return z?{x:v-z.x,y:L-z.y}:{x:v,y:L}},[]),so=k(v=>De[v]||null,[De]),co=k((v,L)=>{if(Object.keys(De).length===1)return De[Ht];const z=on(v,L);if(!z)return null;const{x:F,y:V}=z;let he=null;const le=$r;for(let xe=0;!he&&xe<le.length;xe++){const ye=De[le[xe]];ye&&$l(F,V,ye.getBounds())&&(he=ye)}return he||(he=De[Ht]),he},[De,Fe]),at=k(()=>De[Ht].getVisibleRangeCoords(),[De[Ht]]),Zt=c.useRef(null),ao=c.useCallback(()=>{Zt.current!==null&&St.cancelTimeout(Zt.current),Zt.current=St.requestTimeout(uo,150)},[]),uo=c.useCallback(()=>{Zt.current=null,j(v=>{const L={...v,verticalScrollDirection:null,horizontalScrollDirection:null};return Ge.current=L,L})},[]),an=k(v=>{const L=v?.left??v?.[0],z=v?.top??v?.[1],F=L!==void 0?Math.min(Et-We,Math.max(Pe?.[1]?.scrollOffset??0,L)):Ge.current.left,V=z!==void 0?Math.min(Qe-J,Math.max(Ee?.[1]?.scrollOffset??0,z)):Ge.current.top;if(Ge.current.left===F&&Ge.current.top===V)return;let he=null,le=null;Ge.current.left>F?he=et:Ge.current.left<F&&(he=Ue),Ge.current.top>V?le=nt:Ge.current.top<V&&(le=ot),St.throttle(()=>{j(xe=>{const ye={...xe,left:F,top:V,horizontalScrollDirection:he,verticalScrollDirection:le};return Ge.current=ye,ye})},17)(),Re.current?.top===V&&Re.current?.left===F||(Re.current={left:F,top:V},ue({left:F,top:V}),X({left:F,top:V,width:We,height:J,totalWidth:Et,totalHeight:Qe})),ao()},[Et,Qe,Ee,Pe]);c.useEffect(()=>{Re.current||an({left:ht,top:qe})},[Et,We,Qe,J]),c.useLayoutEffect(()=>{Re.current={left:ct?.left,top:ct?.top},an(Re.current)},[ct?.left,ct?.top]);const An=k(v=>{const L=v?.left??v?.[0],z=v?.top??v?.[1],F=v?.behavior??"auto",V={left:Ge.current.left+(L??0),top:Ge.current.top+(z??0)};F&&(V.behavior=F),an(V)},[Et,We,Qe,J]),$n=c.useCallback(v=>{let L=null;if(Object.keys(De).length>1){const z=$r;for(let F=0;!L&&F<z.length;F++){const V=De[z[F]];V&&Z.isCellWithinRange(v,V.getVisibleRangeCoords())&&(L=V)}}return L||(L=De[Ht]),L},[De]),_n=k((v,L={inline:"nearest",block:"nearest"},z=null)=>{const F={rowIndex:0,colIndex:0,...v};let V=null;if(z!==null){if(V=De[z],V===null)return new Promise((wt,pe)=>{pe("Invalid view")})}else V=$n(F);const he=Fe(F),le=V.getLayout(),xe=le.getColOffset(he.colStart),ye=le.getRowOffset(he.rowStart),se=le.getColOffset(he.colEnd+1),Be=le.getRowOffset(he.rowEnd+1),st=V.getBounds(),Ae=V.getTotalSize(),$e=V.getScrollTopLeft(),ft=((wt,pe,pt=!0)=>(pt=pt===!0?{block:"start",inline:"end"}:pt===!1?{block:"end",inline:"end"}:{block:"end",inline:"end",...pt},{left:Tr(pt.inline,wt.x,wt.x+wt.width,pe.left,pe.left+pe.width,pe.totalWidth),top:Tr(pt.block,wt.y,wt.y+wt.height,pe.top,pe.top+pe.height,pe.totalHeight)}))({x:xe+$e.left,y:ye+$e.top,width:se-xe,height:Be-ye},{left:$e.left,top:$e.top,width:st.width,height:st.height,totalWidth:Ae.width,totalHeight:Ae.height},L),Xe={...ft};Xe.left>ht?Xe.left+=20:Xe.left<ht&&(Xe.left-=0),Xe.top>qe?Xe.top+=20:Xe.top<qe&&(Xe.top-=0);const Mt=V.getScrollOrientation();return Mt.horizontal&&v.colIndex!==void 0||delete Xe.left,Mt.vertical&&v.rowIndex!==void 0||delete Xe.top,new Promise((wt,pe)=>{try{an(Xe),wt(Xe)}catch(pt){pe(pt)}})},[Et,Qe,De,Fe]),mn=k(v=>{const L=v.shiftKey;v.preventDefault();const{deltaX:z,deltaY:F,deltaMode:V}=v;if(Tt.current||ee?.(v)===!1)return;let le=L?F:z,xe=F;const ye=L||Math.abs(le)>Math.abs(xe);V===1&&(xe*=0),Tt.current=window.requestAnimationFrame(()=>{Tt.current=null,An(ye?{left:le}:{top:xe})})},[Et,We,Qe,J,ee]),Cn=c.useCallback((v=null)=>{Yt.current=null,tt.current=null,Ut()},[]);c.useLayoutEffect(()=>{Cn()},[ne]);const un=lo(t,()=>({stage:it.current,focus:Ze,contains:Ne,invalidate:Cn,scrollTo:an,scrollBy:An,scrollCellCoordsIntoView:_n,getScrollPosition:lt,getDimensions:It,getViewport:at,handleWheel:mn,rowCount:r,columnCount:i,getLayout:()=>Le,getRelativePointFromClient:on,getViewFromClient:co,getViewFromCellCoords:$n,getViewFromLocation:so,onViewChangeOnce:v=>{Je.current.push(v)}}),[r,i,De]);c.useEffect(()=>(Ve&&un.current?.addEventListener("wheel",mn,{passive:!1}),zt.current=!0,Re.current=null,()=>{un.current?.removeEventListener("wheel",mn)}),[Ve]);const In=c.useRef([]),ho=(v,L)=>{!v||!N||(In.current=[],L.push(((z,F)=>{const V=`view:${z.getAnchor()}:overlay:${L.length}`,he=N?.({key:V,view:z},xe=>In.current[F]=xe);if(!he)return null;const le=z.getBounds();return T.jsx("div",{style:{position:"absolute",left:"0px",top:"0px",width:`${le.width}px`,height:`${le.height}px`,overflow:"hidden"},children:he},`overlay-${z.getAnchor()}-${F}`)})(v,0)))},fo=c.useMemo(()=>{const v={},L=Object.keys(De);for(let z=0;z<L.length;z++){const F=L[z],V=[];ho(De[F],V),v[F]={overlays:V}}return v},[dt,N,r,i,Ee,Pe]),Bn=(v,L,z,F,V,he,le)=>{if(!v)return;const xe=v.getVisibleColumns(),ye=v.getVisibleRows();if(xe.length===0||ye.length===0)return;let se=null;if(me)se=me(v);else{se=[];for(let Ye=0;Ye<ye.length;Ye++)for(let ze=0;ze<xe.length;ze++){const rt={rowIndex:ye[Ye],colIndex:xe[ze]};if(U?.(rt))continue;const Te={coords:rt,range:Fe(rt)};se.push(Te)}}const Be=v.getVisibleColumnOffsets(),st=v.getVisibleRowOffsets(),Ae=v.getScrollTopLeft(),$e=v.getFreezeTopLeft(),ft=Ae.left+$e.left,Xe=Ae.top+$e.top,Mt=Math.trunc(ft/Jt),wt=Math.trunc(Xe/Jt),pe={},pt=(Ye,ze,rt,Te,yt)=>{const mt=`view:${Ye.getAnchor()}:cell:${kr(ze.rowIndex,ze.colIndex)}`,Ot=Te.x,Vt=Te.y,Rt=Math.trunc((ft+Ot)/Jt)-Mt,a=Math.trunc((Xe+Vt)/Jt)-wt;pe[a]||(pe[a]={});let f=pe[a][Rt];f||(f=pe[a][Rt]=[]);let m=he?.get(mt);if(!m){const g=(ft+Ot)%Jt,b=(Xe+Vt)%Jt;m=ne({key:mt,coords:ze,bounds:Te,zoom:G,range:rt,view:Ye,value:yt,style:{left:we.boundPixel(g),top:we.boundPixel(b),width:we.boundPixel(Te.width,!0),height:we.boundPixel(Te.height,!0)}})}le?.set(mt,m),f.push(m)};for(let Ye=0;se&&Ye<se.length;Ye++){const ze=se[Ye],rt=ze?.coords??ze;if(!rt)continue;const Te=ze?.range??{rowStart:rt.rowIndex,colStart:rt.colIndex,rowEnd:rt.rowIndex,colEnd:rt.colIndex},yt=v.getVisibleRangeCoords();if(!Z.isRangesIntersect(Te,yt)&&!Z.isRangeWithinRange(Te,yt))continue;const mt=Te&&!Z.isSingleCell(Te);if(!mt&&U?.(rt))continue;const Ot=rt.rowIndex,Vt=rt.colIndex,Rt=st[Ot],a=Be[Vt];let f=null;Rt&&a&&(f={x:a.offset,y:Rt.offset,width:a.size,height:Rt.size});const m=kr(Te.rowStart,Te.colStart);if(mt){if(V.has(m))continue;V.add(m),Te.rowEnd-Te.rowStart>0&&z.push(Te),Te.colEnd-Te.colStart>0&&F.push(Te)}if(mt&&(f=Dr(v.getLayout(),Te)),!f){console.warn("no bounds for cell",m);continue}const g=ze?.value;pt(v,rt,Te,f,g)}const Pt=ft%Jt,At=Xe%Jt,_e=Object.keys(pe);for(let Ye=0;Ye<_e.length;Ye++){const ze=pe[_e[Ye]];if(!ze)continue;const rt=Object.keys(ze);for(let Te=0;Te<rt.length;Te++){const yt=ze[rt[Te]];if(!yt)continue;const mt=parseInt(_e[Ye]),Ot=parseInt(rt[Te]),Vt=mt+wt,Rt=Ot+Mt,a=`view:${v.getAnchor()}:segment:${Rt}:${Vt}`;L.push(T.jsx("div",{className:"cell-container",style:{transform:`translate(${we.boundPixel(Ot*Jt-Pt,!0)}px, ${we.boundPixel(mt*Jt-At,!0)}px)`,willChange:"transform"},children:yt},a))}}},qt=c.useMemo(()=>{const v=Yt.current,L=new Map,z={},F=Object.keys(De);for(let V=0;V<F.length;V++){const he=F[V],le=[],xe=[],ye=[];Bn(De[he],ye,le,xe,new Set,v,L),z[he]={cells:ye,rangesH:le,rangesV:xe}}return Yt.current=L,z},[dt,r,i,Ee,Pe,y,Se,ce,U,me,Fe]),Fn=(v,L,z,F,V)=>{if(v)if(L){const he=`view:${v.getAnchor()}:hl:`,le=v.getVisibleRows();if(!le||le.length===0)return;const xe=0,ye=v.getBounds().width;let se=[];const Be=V.sort(Z.rowFirstRangeComparator),st=v.getVisibleRangeCoords();for(let Ae=0;Ae<le.length&&le[Ae]<=st.rowEnd;Ae++){const $e=le[Ae];if($e<st.rowStart)continue;let ft=!1;for(;Be.length>0&&Be[0].rowStart<=$e;){const pe=Be.shift();pe.rowEnd>$e&&(se.push(pe),ft=!0)}ft&&(se=se.sort(Z.columnFirstRangeComparator));const Xe=v.getLayout(),Mt=Xe.getRowOffset($e+1);let wt=xe;for(let pe=0;pe<se.length+1;pe++){let pt=wt,Pt=ye;const At=se[pe];pe<se.length&&(Pt=Math.min(ye,Xe.getColOffset(At.colStart)),wt=Math.min(ye,Xe.getColOffset(At.colEnd+1))),F.push(c.createElement("path",{d:`M ${we.boundPixel(pt)} ${we.boundPixel(Mt,!1,z)} L ${we.boundPixel(Pt)} ${we.boundPixel(Mt,!1,z)}`,stroke:_,strokeWidth:1,vectorEffect:"non-scaling-stroke",...I,key:he+$e+":"+pe}))}for(let pe=se.length-1;pe>=0;pe--)se[pe].rowEnd<=le[Ae+1]&&se.splice(pe,1)}}else{const he=`view:${v.getAnchor()}:vl:`,le=v.getVisibleColumns();if(!le||le.length===0)return;const xe=0,ye=v.getBounds().height;let se=[];const Be=V.sort(Z.columnFirstRangeComparator),st=v.getVisibleRangeCoords();for(let Ae=0;Ae<le.length&&le[Ae]<=st.colEnd;Ae++){const $e=le[Ae];if($e<st.colStart)continue;let ft=!1;for(;Be.length>0&&Be[0].colStart<=$e;){const pe=Be.shift();pe.colEnd>$e&&(se.push(pe),ft=!0)}ft&&(se=se.sort(Z.rowFirstRangeComparator));const Xe=v.getLayout(),Mt=Xe.getColOffset($e+1);let wt=xe;for(let pe=0;pe<se.length+1;pe++){let pt=wt,Pt=ye;const At=se[pe];pe<se.length&&(Pt=Math.min(ye,Xe.getRowOffset(At.rowStart)),wt=Math.min(ye,Xe.getRowOffset(At.rowEnd+1)));let _e=_;F.push(T.jsx("path",{d:`M ${we.boundPixel(Mt,!1,z)} ${we.boundPixel(pt)} L ${we.boundPixel(Mt,!1,z)} ${we.boundPixel(Pt)}`,stroke:_e,strokeWidth:1,vectorEffect:"non-scaling-stroke",...R},he+$e+":"+pe))}for(let pe=se.length-1;pe>=0;pe--)se[pe].colEnd<=le[Ae+1]&&se.splice(pe,1)}}},Mn=v=>{if(!qt)return;const L={};for(let z=0;z<Gt.length;z++){const F=Gt[z],V=De[F],he=[];Fn(V,v,0,he,v?qt[F].rangesH:qt[F].rangesV);const le=V.getRangeCoordsBounds(),xe=Math.ceil(le.width),ye=Math.ceil(le.height);L[F]=T.jsx("svg",{width:`${xe}`,height:`${ye}`,viewBox:`0 0 ${xe} ${ye}`,preserveAspectRatio:"none",shapeRendering:"crispEdges",style:{position:"absolute"},children:he})}return L},Vn=c.useMemo(()=>y===!0||y?.horizontal===!0?Mn(!0):null,[dt,y,Ee,D,C,_,I,r,i,We,Et,qt]),Wn=c.useMemo(()=>y===!0||y?.vertical===!0?Mn(!1):null,[dt,y,Pe,D,C,_,R,r,i,J,Qe,qt]),po=c.useMemo(()=>_t.left===0?null:T.jsx(Vo,{linePoints:[0,0,0,J+1],bounds:{x:_t.left,y:0,width:1,height:J+1},...ie}),[dt,_t.left,J,ie]),go=c.useMemo(()=>_t.top===0?null:T.jsx(Vo,{linePoints:[0,0,We+1,0],bounds:{x:0,y:_t.top,width:We+1,height:1},...$}),[dt,_t.top,We,$]),Rn=c.useMemo(()=>{const v=[],L=z=>{if(!z||!De[z])return;const F=De[z].getBounds();return T.jsxs("div",{style:{position:"absolute",pointerEvents:"none",left:F.x,top:F.y,width:F.width,height:F.height,clip:`rect(0, ${F.width+1}px, ${F.height+1}px, 0)`},className:`view view-${z}`,children:[Vn?.[z],Wn?.[z],qt?.[z].cells]},`view:${z}`)};for(let z=0;z<Gt.length;z++)v.push(L(Gt[z]));return T.jsx(T.Fragment,{children:v})},[De,Vn,Wn,qt]),wo=c.useMemo(()=>{if(!t)return;const v=(le,xe,ye,se)=>{if(!se||se.length===0)return;const Be=[];for(let st=0;st<se.length;st++){const Ae=se[st];let $e=le?.get(Ae);$e!==To&&($e=Ae(ye)??To),xe.set(Ae,$e),$e&&$e!==To&&Be.push($e)}return Be},L=(le,xe,ye)=>{if(!ye)return;const se=ye.getBounds(),Be=ye.getInsets(),st=ye.getAnchor();return T.jsxs("div",{className:fn("view",`view-${st}`,Ar.view),style:{position:"absolute",pointerEvents:"none",left:se.x-Be.left,top:se.y-Be.top,width:se.width-(Be.left+Be.right),height:se.height-(Be.top+Be.bottom),clipPath:M?"inset(-2px)":"inset(0px)"},children:[v(le,xe,ye,O),fo?.[st].overlays]},`view:${st}`)},z=tt.current,F={},V=[],he=Object.keys(De);for(let le=0;le<he.length;le++){const xe=he[le],ye=z?.[xe],se=F[xe]=new Map;V.push(L(ye,se,De[xe]))}return tt.current=F,V},[dt,De,M,O]),mo=c.useMemo(()=>{const{style:v,...L}=Q??{};return T.jsx("div",{style:{width:We,height:J,...v},className:"sheetxl-stage",tabIndex:0,ref:it,...L,...E,children:H?H(Rn):Rn})},[We,J,Rn,Q,H]),Hn=c.useRef(!1);return c.useEffect(()=>{!Hn.current&&qt&&(Hn.current=!0,Me?.(un.current))},[qt]),T.jsxs("div",{className:fn("sheetxl-grid",Ar["sheetxl-grid"]),style:{overflow:"visible",cursor:P,maxWidth:We,maxHeight:J,width:We,height:J,...Se},ref:un,children:[mo,T.jsxs("div",{className:fn("sheetxl-overlays"),ref:ut,...h,children:[wo,po,go]})]})}));Yo.displayName="BaseGrid";const Go=c.memo(c.forwardRef((e,t)=>{const{width:n,height:o,style:r={},className:i,...l}=e,[s,{width:u,height:d}]=gi(),w=n??u,x=o??d;return T.jsx("div",{className:i,style:{...r},children:T.jsx("div",{style:{position:"relative",top:"0px",left:"0px",width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",boxSizing:"content-box"},ref:s,children:T.jsx(Yo,{ref:t,width:w,height:x,...l})})})}));Go.displayName="Grid";const mi=c.memo(c.forwardRef((e,t)=>{const{showVerticalScrollbar:n,showHorizontalScrollbar:o,createHorizontalScrollbar:r,createVerticalScrollbar:i,createScrollCorner:l,viewport:s,onScrollViewport:u,style:d={},className:w,onScroll:x,...p}=e,[y,_]=c.useState(null),I=c.useRef(null),R=c.useRef(null);eo(!s),c.useImperativeHandle(t,()=>R.current&&I.current?Object.assign(R.current,I.current):null);const ce=c.useCallback(P=>{R.current?.scrollTo(P),u?.(P)},[]);return T.jsx(li,{className:w,style:d,ref:I,showVerticalScrollbar:n,showHorizontalScrollbar:o,createHorizontalScrollbar:r,createVerticalScrollbar:i,createScrollCorner:l,viewport:y,onScrollViewport:ce,children:T.jsx(Go,{style:{width:"100%",height:"100%"},...p,onViewportChange:P=>_(P),ref:R})})}));mi.displayName="ScrollableGrid";const Br=()=>!1,xi=c.memo(e=>{const{index:t,value:n,zoom:o,zoomScale:r=100,headerText:i=O=>`${O}`,headerStyle:l,headerStyleSelect:s=l,headerStyleSelectAll:u=s,headerStyleHover:d=u,verticalPadding:w=0,horizontalPadding:x=0,isSelected:p=Br,isSelectedAll:y=Br,coords:_,bounds:I,range:R,orientation:ce,view:P,style:C,...D}=e,ie=r/100,$=c.useRef(null),[ne,ve]=c.useState(!1),K=p?.(t)||!1,N=y?.(t)?u:K?s:l;let Y=N;if(ne){let O=d;typeof d=="function"&&(O=d(N)),Y=St.mergeContentful(N,O)}return T.jsx("div",{ref:$,style:{background:Y.fill,color:Y.text?.fill,fontFamily:Y.text?.fontFamily??l.text?.fontFamily,fontSize:96*(Y.text?.fontSize??11)/72*ie,fontStyle:Y.text?.fontStyle,fontWeight:Y.text?.fontWeight,lineHeight:1.2,display:"flex",justifyContent:"center",alignItems:"end",pointerEvents:"auto",paddingBottom:`${ie}px`,...C,left:C.left-(ce===Bt?1:0),top:C.top-(ce===Qt?1:0),width:C.width+1,height:C.height+1,overflow:"hidden"},...D,onMouseMove:O=>{we.detectIt().primaryInput!=="touch"&&O.buttons===0&&ve(!0)},onMouseOut:O=>{ve(!1)},children:i(t)})});xi.displayName="HeaderRenderer";const yi="ew-resize",vi="ns-resize",bi=c.memo(c.forwardRef((e,t)=>{const{orientation:n,view:o,index:r,className:i,style:l,disabled:s=!1,disabledResize:u=!1,isNextHidden:d,isHidden:w,isSelected:x,isSelectedAll:p,showTouchDivider:y,headerStyle:_,headerStyleSelect:I,headerStyleSelectAll:R,headerStyleHover:ce,bounds:P,onPointerDown:C,onAutoFit:D,...ie}=e,$=n===Bt;let ne=_;x&&I&&(ne=I),p&&R&&(ne=R);const ve=we.detectIt().primaryInput==="touch";let K=$?14:8,N=K/2,Y=0;d&&(Y=-2),w&&(Y=2),w&&(K=K/2+Y,N=2*Y);let O=ne.dividerStrokeFill??ne.strokeFill;return!(x||p)&&Y===0&&(O=`linear-gradient(${$?180:90}deg, ${ne.fill}, ${O} 55%, ${O} 100%)`),T.jsxs("div",{className:fn("header-divider",{disabled:s},i,`index-${r}`),ref:t,onPointerDown:ve?void 0:C,onDoubleClick:ve?void 0:()=>D?.(),style:{top:($?0:-K/2+(Y-1))+"px",left:($?-K/2+(Y-1):0)+"px",width:$?K:"calc(100% + 1px)",height:$?"calc(100% + 1px)":K,position:"absolute",overflow:"visible",pointerEvents:"all",cursor:s||u||ve?void 0:$?yi:vi,...l},...ie,children:[T.jsx("div",{style:{position:"relative",top:`${$?0:N}px`,left:`${$?N:0}px`,width:$?1:"100%",height:$?"100%":1,background:O},onDoubleClick:()=>D?.()}),y&&ve?T.jsx("div",{style:{position:"absolute",cursor:"grab",zIndex:1,borderRadius:"4px",right:$?"-6px":"2px",bottom:$?"2px":"-9px",height:"24px",width:$?"24px":"18px",maxHeight:$?"calc(100% - 4px)":void 0,maxWidth:$?void 0:"calc(100% - 4px)",background:ne.fill,border:`${R.edgeStrokeFill} solid 1px`,boxShadow:`0.5px 0.5px 0px 0px ${_.text.fill}`,display:"flex",alignItems:"center",justifyContent:"center"},onPointerDown:C,children:T.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='${encodeURIComponent(I.text.fill)}' 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:$?void 0:"rotate(90deg)"}})}):null]})})),ql=(e,t)=>T.jsx(bi,{...e,ref:t}),Xl=c.memo(c.forwardRef((e,t)=>{const{orientation:n,view:o,index:r,disabled:i=!1,disabledResize:l=!1,resizeThreshold:s=1,dividerRenderer:u=ql,onDividerMouseDown:d,onDividerResizeStart:w,onDividerResize:x,onDividerResizeEnd:p,onDividerMouseUp:y,onDividerAutoFit:_,onPointerDown:I,...R}=e,ce=k(I,[I]),P=k(_,[_]),C=n===Bt;let D=C?o.getVisibleColumns():o.getVisibleRows(),ie=null;D.length>0&&(C?ie=o.getRangeCoordsBounds({rowStart:0,rowEnd:0,colStart:D[0],colEnd:D[D.length-1]}):o.getRangeCoordsBounds({rowStart:D[0],rowEnd:D[D.length-1],colStart:0,colEnd:0}),ie=o.toClipBounds(ie,Wt));const $=c.useRef(null),[ne,ve]=c.useState(null),K=(A,q)=>C?A.clientX-q.clientX:A.clientY-q.clientY,N=o.getLayout(),Y=C?N.getColOffset(r+1):N.getRowOffset(r+1),O=vn({processTouch:!0,onPointerDown:A=>{if(ce?.(A),!i&&!l){const q=C?N.getColOffset(r):N.getRowOffset(r),U=Y-q;$.current={isResizing:!1,startSize:U,index:r,view:o,orientation:n,onDividerMouseDown:d,onDividerResizeStart:w,onDividerResize:x,onDividerResizeEnd:p,onDividerMouseUp:y},ve($.current),d?.(r,U)}A.stopPropagation(),A.preventDefault()},onPointerUp:(A,q,U)=>{if(!$.current)return;$.current.isResizing&&$.current.onDividerResizeEnd?.($.current.index,Math.max(0,$.current.startSize+K(A,U)),$.current.startSize);const me=$.current;$.current=null,ve($.current),me.onDividerMouseUp?.(me.index)},onPointerMoveOrWait:(A,q,U)=>{if(!$.current)return;const me=K(A,U);$.current.isResizing?$.current.onDividerResize?.($.current.index,Math.max(0,$.current.startSize+me),$.current.startSize):Math.abs(me)>Math.max(1,s)&&($.current={...$.current,isResizing:!0},ve($.current),$.current.onDividerResizeStart?.($.current.index,Math.max(0,$.current.startSize+me))),A.stopPropagation(),A.preventDefault()}}),h=k(()=>{P?.(r)},[r]);if(!ie)return;const M=u({bounds:ie,orientation:n,view:o,index:r,disabled:i,disabledResize:l,onAutoFit:h,onPointerDown:O,...R},t);if(!M)return;const{getPortalContainer:Q}=si();let H=null;return ne&&ne.isResizing&&ne.index===r&&(H=No.createPortal(T.jsx("div",{style:{position:"absolute",cursor:C?yi:vi,left:0,top:0,width:"100%",height:"100%"}}),Q(),"divider:"+r)),T.jsxs(T.Fragment,{children:[H,T.jsx("div",{className:fn("header-divider-anchor"),style:{position:"absolute",pointerEvents:"auto",top:`${C?ie.y:Y}px`,left:`${C?Y:ie.x}px`,width:(C?0:ie.width-1)+"px",height:(C?ie.height-1:0)+"px",display:"flex"},tabIndex:-1,children:M})]})}));class Yl{naturalDimensions(t,n={}){const o=document.createElement("div");let r=n?.lineHeight??"1";!n?.lineHeight&&n.paintableText?.fontSize&&(r=Math.ceil(1.2*n.paintableText.fontSize)+"px");const i=document.createElement("div");i.style.visibility="hidden",i.style.position="absolute",i.style.textRendering="geometricprecision",i.style.display="inline-grid",i.style.overflowWrap="break-word",i.style.maxWidth=n.maxWidth?n.maxWidth+"px":"100%",i.style.lineHeight=r,i.style.letterSpacing=(n.paintableText?.letterSpacing??0)+"px",i.style.fontSize=n.paintableText?.fontSize?n.paintableText.fontSize+"px":"unset",i.style.fontFamily=n.paintableText?.fontSize?n.paintableText.fontFamily:"unset",i.style.fontWeight=n.paintableText?.fontWeight?""+n.paintableText.fontWeight:"400",i.style.fontStyle=n.paintableText?.fontStyle?n.paintableText.fontStyle:"normal",i.style.whiteSpace=n.paintableText?.wrap==="wrap"?"break-spaces":"pre",o.appendChild(i);const l=t.split(`
|
|
24
|
+
`);for(let u=0;u<l.length;u++){let d=document.createElement("span");i.appendChild(d),d.textContent=l[u]}l.length!==0&&l[l.length-1].length!==0||i.appendChild(document.createElement("br")),document.body.appendChild(i);let s=i.getBoundingClientRect();return i.remove(),{width:s.width,height:s.height,maxLineHeight:1.2*(n.paintableText?.fontSize||1056/72)}}}const Si=(e=void 0)=>Object.freeze({clean:e,dirty:void 0,editMode:!1}),Gl=Si(),Zl=c.memo(c.forwardRef((e,t)=>{const{editState:n=Gl,defaultTextStyle:o,onStartEdit:r,onChangeEdit:i,onSubmitEdit:l,onCancelEdit:s,onDoneEdit:u,containerBounds:d,setNaturalDimensions:w,onNavigate:x,textProperties:p,style:y,autoFocus:_,...I}=e,R=c.useRef(null),{width:ce=0}=d??{},[P,C]=c.useState(()=>n);c.useEffect(()=>{C(n)},[n]);const D=p?.align||"left",ie=p?.vAlign||"middle",$=p?.fill||"#040404",ne=p?.wrap||"wrap",ve=p?.fontFamily||"Calibri",K=p?.fontSize||11,N=p?.fontWeight||400,Y=p?.fontStyle||"normal",O=P.dirty??P.clean??"";let h=2;const M=96*K/72,Q=1.2*M;ie==="right"&&(h+=1);const H=c.useMemo(()=>new Yl().naturalDimensions(O,{maxWidth:ne==="wrap"?ce-h:void 0,lineHeight:`${Q}px`,paintableText:{fontStyle:Y,wrap:ne,letterSpacing:-.25}}),[O,ne,h,M,ve,N,Y,w,ce]),A=c.useCallback(()=>H.maxLineHeight?H.maxLineHeight+"px":"1.2",[H]),[q,U]=c.useState(A);c.useLayoutEffect(()=>{U(A())},[d,H]),c.useLayoutEffect(()=>{w?.({width:ne==="wrap"?void 0:H.width+h,height:H.height})},[H,w]);const me=k(i,[i]),G=k(X=>{if(P.dirty===X)return;const fe={...P};fe.dirty=X,R.current,C(fe),me?.(fe)},[P]),Ve=k(X=>{if(P.editMode===X)return;const fe={...P};fe.editMode=X,C(fe),me?.(fe)},[P]),He=k(()=>{try{return l?.(P),u?.(),!0}catch{return!1}},[l,P]),Fe=k(()=>{C(n),s?.(),u?.()},[s,n]),ct=k(X=>{if(!R.current)return;if(X.isDefaultPrevented(),!(X.isTrusted||X.nativeEvent.ctrlKey||X.nativeEvent.metaKey||X.nativeEvent.altKey||X.nativeEvent.isComposing)&&qo.indexOf(X.nativeEvent.key)!==-1){const ee={...P};return ee.dirty=X.nativeEvent.key==="Backspace"?"":(ee.dirty??"")+X.key,C(ee),me?.(ee),void X.preventDefault()}const fe=X.nativeEvent.shiftKey;if(X.which===Ni)return X.preventDefault(),void Fe();if(X.which===Yi)return Ve(!0),void X.preventDefault();if(X.which===Hi&&(X.preventDefault(),He()&&x?.(fe?nt:ot)),X.which===Wi)return X.preventDefault(),void(He()&&x?.(fe?et:Ue));if(!P.editMode){let ee=null;switch(X.which){case Ui:ee=et;break;case qi:ee=Ue;break;case Ki:ee=nt;break;case Xi:ee=ot}if(ee)return void He()}},[P,x]),[Se,E]=c.useState(!_);c.useEffect(()=>{E(!1)},[]);const ue=lo(t,()=>({startEdit(X){let fe=X?.initialSelection;if(!fe){const Me=R.current.value.length??0;fe={start:Me,end:Me,direction:"forward"}}R.current?.setSelectionRange(fe.start,fe.end,fe.direction);const ee={...n,editMode:X?.editMode??!1};X?.text!==void 0&&(ee.dirty=X.text),ee.editMode===n.editMode&&ee.dirty===n.dirty||(C(ee),me?.(ee))},submitEdit:()=>He(),cancelEdit(){Fe()},autoFocus(){R.current?.focus()},getLineHeight:()=>H?.maxLineHeight??Q,dispatchEvent:X=>R.current.dispatchEvent(X)}),[n,r]);return T.jsx("div",{ref:ue,...I,style:{background:"transparent",display:"flex",flexGrow:1,alignSelf:"center",height:H.height,maxWidth:"100%",maxHeight:"100%",...y},children:T.jsx("textarea",{spellCheck:"false",ref:R,value:O,autoFocus:!1,disabled:Se,name:"cell-editor",autoComplete:"off",autoCapitalize:"off",style:{flex:"1 1 100%",position:"relative",fontSize:`${M}px`,fontFamily:`${ve}`,fontWeight:`${N}`,fontStyle:`${Y}`,padding:"0px",marginRight:D==="right"?"3px":"0px",marginLeft:D==="left"?"2px":"0px",lineHeight:q,height:H.height,textRendering:"geometricPrecision",letterSpacing:"-0.25px",boxSizing:"border-box",borderWidth:0,outline:"none",resize:"none",overflow:"hidden",verticalAlign:"baseline",textAlign:D,background:"transparent",color:$,marginBottom:"0px",userSelect:"text",maxHeight:"100%",whiteSpace:ne==="wrap"?"break-spaces":"pre",wordWrap:"break-word"},onChange:X=>{G(X.target.value)},onDoubleClick:X=>{X.isTrusted},onMouseDown:X=>{Ve(!0)},onKeyDown:ct})})})),Jl=c.memo(e=>{const{value:t,view:n,bounds:o,range:r,zoom:i,children:l,style:s,...u}=e,d=s?.fontSize||1056/72;return T.jsx("div",{style:{padding:"2px 4px",fontFamily:"Calibri",letterSpacing:-.25,lineHeight:1.2,fontSize:d,...s},...u,children:t})});exports.BaseGrid=Yo,exports.DefaultCellEditor=Zl,exports.DefaultCellRenderer=Jl,exports.DefaultHeaderDivider=bi,exports.FillHandle=Wo,exports.Grid=Go,exports.HeaderDivider=Xl,exports.HeaderRenderer=xi,exports.RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL=150,exports.SELECTION_CLIP_INSETS=Wt,exports.STANDARD_KEY_CHARS=qo,exports.SVGLine=Vo,exports.SVGRect=hi,exports.ScrollableGrid=mi,exports.Selection=Xo,exports.TouchSelectHandle=Qn,exports.defaultSelectionRenderer=zr,exports.getDefaultStringEditState=Si,exports.safeSelectionCoords=$t,exports.useCellLayout=di,exports.useHeaderSelection=({gridRef:e,gridMainRef:t,orientation:n=Qt,headerCount:o,selectionPolicy:r="multiple",newSelectionMode:i="clear",alwaysScrollToActiveCoords:l=!0,onDragStart:s,onDragEnd:u,pointerDownInterceptor:d,pointerMoveInterceptor:w,onPointerUp:x,newSelection:p,modifySelection:y,appendSelection:_,clearSelections:I})=>{const R=o??((n===Qt?e.current?.rowCount:e.current?.columnCount)||0),ce=c.useRef(null),P=c.useRef(null),C=c.useRef(!1),D=c.useRef(null),ie=c.useCallback(h=>n===Bt?{rowIndex:0,colIndex:h.colIndex}:{rowIndex:h.rowIndex,colIndex:0},[n]),$=c.useCallback(h=>n===Bt?{rowIndex:t.current?t.current.rowCount-1:0,colIndex:h.colIndex}:{rowIndex:h.rowIndex,colIndex:t.current?t.current.columnCount-1:0},[n]),ne=h=>{P.current=$(h),y(P.current,ce.current)},ve=c.useCallback((h,M)=>{if(!e.current)return;const Q=e.current.getViewFromClient(h,M)?.getCellCoordsFromClient(h,M);return Q?(n===Bt?Q.rowIndex=t.current.getViewport().rowStart:Q.colIndex=t.current.getViewport().colStart,Q):void 0},[]),K=c.useCallback((h,M=!1)=>{let Q=h;return M||(Q={...h},n===Qt?delete Q.colIndex:delete Q.rowIndex),t.current?.scrollCellCoordsIntoView(Q)},[n]),N=k(u,[u]),Y=k(s,[s]),O=c.useMemo(()=>({onPointerDown:h=>{if(!e||!e.current||h.nativeEvent.defaultPrevented)return;const M=ve(h.nativeEvent.clientX,h.nativeEvent.clientY);if(!M)return;h.nativeEvent.which;const Q=h.nativeEvent.shiftKey,H=h.nativeEvent.ctrlKey||h.nativeEvent.metaKey;if(d?.(h,M)===!1)return;Y?.(),C.current=!0;const A=t.current?.getViewFromClient(h.nativeEvent.clientX,h.nativeEvent.clientY),q=((U,me)=>n===Bt?{...U,rowIndex:me.rowStart}:{...U,colIndex:me.colStart})(M,A.getVisibleRangeCoords());if(Q)ne(M);else{if(H)return((U,me=U,G)=>{ce.current=ie(U),P.current=$(me),_(ce.current,P.current,G)})(M,M,q),void(l&&K(q,!0));((U,me=U,G)=>{ce.current=ie(U),P.current=$(me),p(ce.current,P.current,G)})(M,M,q),ne(M),l&&K(q,!0)}},onPointerMoveOrWait:St.throttle(h=>{if(!C.current||!e?.current)return;const M=ve(h.clientX,h.clientY);if(M&&w?.(h,M)!==!1){if(Z.isEqualCells(D.current,M))return I();ne(M),K(M)}},60),onPointerUp:h=>{C.current=!1,N?.(),x?.(h)},processTouch:!0,consumeTouch:!0}),[r,l,R,i,I,d,x]);return{onPointerDown:k(vn(O),[]),getCellCoordsFromClient:ve}},exports.useKeyboardEditorOverlay=e=>{const{view:t,canEdit:n=Pl,getCellEditor:o,onBeforeStartEdit:r,onStartEdit:i,onSubmitEdit:l,onCancelEdit:s,onDoneEdit:u,isEditorStartKeyEvent:d=Ol,isEditorStartPointerEvent:w=Ll,containerProps:x,borderStrokeFill:p,borderStrokeWidth:y=2,getRangeCoords:_=null,activeCoords:I,alignment:R=On.Left}=e,[ce,P]=c.useState(!1),[C,D]=c.useState(void 0),ie=k((E,ue,X,fe,ee,Me)=>{if(!ue)return null;const it=ee?.(ue,E),ut=E.getRangeCoordsBounds(it),Tt=E.toClipBounds(ut),dt=ut,Ut=E.getZoom();if(!Tt)return null;X&&(X*=Ut),fe&&(fe*=Ut);let je=dt,j=!1;if(X!==void 0){let qe={...it},ht=0;for(;!j&&je.width<=X&&ht<20;){ht++,ht>19&&console.warn("max width reached");const en=E.getTotalRangeCoords(),Kt=E.getLayout();Me===On.Left?qe.colEnd+1<en.colEnd?qe.colEnd=Kt.getColIndex(je.x+X):j=!0:Me===On.Right?qe.colStart-1>=0?qe.colStart=Kt.getColIndex(je.x-(X-je.width)):j=!0:Me===On.Center&&qe.colEnd+1<en.colEnd&&qe.colStart-1>=0?(qe.colStart=Kt.getColIndex(je.x-(X-je.width)/2),qe.colEnd=Kt.getColIndex(je.x+je.width+(X-je.width)/2)):j=!0,j||(je=E.getRangeCoordsBounds(qe))}}je.height=dt.height,fe!==void 0&&(je.height=Math.max(fe+1,dt.height));const{width:Re,height:Ge}=E.getViewportSize();return{x:je.x??0,y:je.y??0,height:Math.min(Ge-je.y,je.height)+1,width:Math.min(Re-je.x,je.width)+1}},[R]),$=k(n,[n]),ne=c.useCallback(()=>{t?.getStage()?.focus()},[t]),ve=k(E=>{r?.(E),U(),P(!0)},[r]),K=k(E=>{i?.(E.coords)},[i]),N=k(E=>{E.isSubmitted||E.isCancelled||(h.current.isEditorClosed=!0,ne(),E.isCancelled=!0,s?.(E.coords),U())},[s]),Y=k(E=>{if(E.isSubmitted||E.isCancelled)return!1;try{return E.isEditorClosing=!0,E.isSubmitted=!0,E.isEditorSubmitted||(E.isEditorSubmitted=!0,E.editorRefs[0]?.submitEdit?.()),E.coords,l?.(E.coords),E.isEditorClosed=!0,ne(),U(),!0}catch(ue){throw E.isEditorClosing=!1,E.isSubmitted=!1,ue}},[l]),O=k(E=>{P(!1),u?.(E.coords),U()},[u]),h=c.useRef(null),M=c.useRef(null),Q=c.useRef(null),H=c.useRef([]),[A,q]=c.useReducer(E=>E+1,0),U=c.useCallback(E=>{E&&H.current.push(E),q()},[]),me=k(E=>{if(E.defaultPrevented||E.isSynthetic||!t)return;const ue=t?.getCellCoordsFromClient(E.clientX,E.clientY);ue&&U({eventType:"pointer",event:E,coords:ue})},[t]),G=k(E=>{const ue=E.nativeEvent;me(ue)},[t]),Ve=k(E=>{if(E.defaultPrevented||E.isSynthetic||!t?.getStage())return;const ue=M.current;d(E,ue)&&(E.stopPropagation(),E.preventDefault()),E.key,U({eventType:"keyboard",event:E,coords:ue})},[t]);c.useLayoutEffect(()=>{const E=(fe,ee)=>{const Me=ee?.cell??fe;if(!Me)return null;const it=Me;if(!$(Me))return null;ve?.(Me);const ut=St.uuidV4();ee=Object.freeze({autoFocus:!0,...ee}),Q.current=Me;const Tt={coords:it,startEvent:ee,uuid:ut,isMounted:!1,isStarted:!1,isSubmitted:!1,isEditorSubmitted:!1,isEditorClosing:!1,isEditorClosed:!1,isCancelled:!1,events:[],editorRefsDispatchEditorEvent:[],editorRefs:[],onMount:dt=>{Tt.isMounted||(Tt.isMounted=!0,U())},onUnmount:dt=>{if(Tt.editorRefs.length===0){const Ut=()=>{Tt.isMounted=!1,U()};if(document.activeElement!==document.body)Ut();else{const je=j=>{j.defaultPrevented||j.target!==document.body||Ve(j)};window.addEventListener("keydown",je,!0),t.getStage()?.addEventListener("focusin",()=>{window.removeEventListener("keydown",je),Ut()},{once:!0}),ne()}}}};return Tt};if(H.current.length<=0&&!h.current)return;const ue=H.current[0];Rr(ue),(fe=>{const ee=[],Me=fe?.length??0;for(let it=0;it<Me;it++){const ut=fe[it];ee.push(Rr(ut))}})(H.current),h.current,h.current;let X=h.current;if(h.current){if(h.current.isDone)h.current=null;else if(h.current.isSubmitted||h.current.isCancelled){if(h.current.isMounted)return;h.current.isDone||(O(h.current),h.current.isDone=!0)}}if(ue){if(ue.eventType==="start"){const fe=ue,ee=fe.startEvent?.cell??M.current;h.current&&Z.isEqualCells(h.current.coords,ee)||(h.current=E(ee,fe.startEvent))}else if(ue.eventType==="keyboard"){const fe=ue.event;if(h.current){fe.key,h.current.events,h.current.events.push(ue);for(let ee=0;ee<h.current.editorRefsDispatchEditorEvent.length;ee++)h.current.editorRefsDispatchEditorEvent[ee](ue)}else if(d(fe,ue.coords)){let ee;const Me=E(ee?.cell??M.current,ee);Me&&Me.events.push(ue),h.current=Me}}else if(ue.eventType==="pointer"){const fe=ue.event;if(h.current){h.current.events.push(ue);for(let ee=0;ee<h.current.editorRefsDispatchEditorEvent.length;ee++)h.current.editorRefsDispatchEditorEvent[ee](ue)}else{const ee=ue?.coords??M.current,Me=w(fe,ee);if(Me){let it;typeof it!="boolean"&&(it=Me);const ut=E(ee,it);ut&&ut.events.push(ue),h.current=ut}}}else if(ue.eventType==="submit"){if(h.current&&!h.current.isSubmitted&&!h.current.isCancelled){if(!h.current.isMounted)return;Y(h.current)}}else if(ue.eventType==="cancel"){if(h.current&&!h.current.isSubmitted&&!h.current.isCancelled){if(!h.current.isMounted)return;N(h.current)}}else if(ue.eventType==="coordsChange"){const fe=ue;if(M.current=fe.activeCoords,h.current,h.current&&!h.current.isSubmitted&&!h.current.isCancelled){if(!h.current.isMounted)return;try{Y(h.current)}catch{}}}}H.current.length>0&&(H.current.shift(),U()),H.current.length===0&&(!h.current||h.current.isEditorClosing||h.current.isEditorClosed?!h.current&&X&&ne():h.current.isMounted&&!h.current.isStarted&&(h.current.isStarted=!0,h.current.startEvent.autoFocus&&(typeof h.current.startEvent.autoFocus=="string"?h.current.editorRefs[0]?.autoFocus(h.current.startEvent.autoFocus):h.current.editorRefs[0]?.autoFocus()),K?.(h.current),requestAnimationFrame(()=>{t&&h.current?.coords&&t.scrollCellCoordsIntoView(h.current.coords)})))},[A]),c.useEffect(()=>{Q.current=I;const E=h.current?.coords;Z.isEqualCells(E,I)||(h.current&&(h.current.isEditorClosing=!0),U({eventType:"coordsChange",activeCoords:I}))},[I]);const He=c.useCallback(E=>{Ve(E.nativeEvent)},[]),{width:Fe=0,height:ct=0}=C??{width:0,height:0},Se=k(o,[o]);return{overlay:k(E=>{if(!h.current||h.current.isEditorClosed)return h.current,null;h.current.coords;let ue=ie(E,h.current.coords,Fe,ct,_,R),X=!0;ue&&ue.width!==0&&ue.height!==0||(ue={x:0,y:0,width:Fe,height:Fe},X=!1);const fe=E.getZoom(),ee={containerBounds:{x:0,y:0,width:ue.width/fe,height:ue.height/fe},setNaturalDimensions:D,zoom:fe};return T.jsx(Dl,{session:h.current,refLatestCoords:Q,handleSubmitEdit:Y,handleCancelEdit:N,cellBounds:ue,borderStrokeWidth:y,borderStrokeFill:p,isInBounds:X,getCellEditor:Se,propsEditor:ee,alignment:R,...x},"editor:"+h.current.uuid)},[o,_,A,Fe,ct,R,y,p]),startEdit:c.useCallback(E=>{U({eventType:"start",startEvent:E})},[]),submitEdit:c.useCallback(()=>{U({eventType:"submit"})},[]),cancelEdit:c.useCallback(()=>{U({eventType:"cancel"})},[]),onKeyboardEvent:He,onPointerEvent:G,onKeyboardEventNative:Ve,onPointerEventNative:me,isEditing:ce}},exports.useSelection=({gridRef:e,commands:t,layout:n,selection:o,onSelectionChange:r,onSelectionDragStart:i,onSelectionDragEnd:l,selectionPolicy:s="multiple",newSelectionMode:u="clear",allowDeselectSelection:d=!0,onFillPreview:w,onFillCancel:x,onFillDone:p,onFill:y,disableFillDrag:_=!y,fillHandleBorderColor:I="white",hiddenRowsAt:R,hiddenColumnsAt:ce,isContentfulCell:P,contentfulCellFinder:C=Al,getDataCoords:D,alwaysScrollToActiveCoords:ie=!1,selectionBounds:$,pointerDownInterceptor:ne,pointerMoveInterceptor:ve,mergedRanges:K,canSelectionSpanMergedCells:N=Hl,onMoveDragStart:Y,onMoveDragUpdate:O,onMoveDragEnd:h,onMoveDragDone:M,selectionRenderer:Q=zr,disableMoveDrag:H=!h,getCellCoordsAsRangeCoords:A=Z.cellToRange,moveDragHitSize:q=6,moveDragOutlineSize:U=4,selectionBackgroundColor:me="rgba(16, 124, 65, 0.1)",selectionBorderColor:G="rgb(33, 115, 70)",selectionRemoveBorderColor:Ve="rgb(255, 0, 0)",selectionRemoveBackgroundColor:He="rgba(250, 10, 10, 0.1)",disableTouchSelection:Fe=!1,touchSelectHandleProps:ct})=>{const Se=c.useCallback(()=>({top:$?.top??0,left:$?.left??0,bottom:e.current?.rowCount-1||0,right:e.current?.columnCount-1||0}),[]),E=k(y,[y]),ue=k(w,[w]),X=k(x,[x]),fe=k(p,[p]),ee=k(P,[P]),Me=k(Q,[Q]),it=k((a,f=!1)=>io(a,f,n.getRowOffset,f?Se().bottom:Se().top),[n?.getRowOffset]),ut=k(R??it,[R]),Tt=k((a,f=!1)=>io(a,f,n.getColOffset,f?Se().right:Se().left),[n?.getColOffset]),dt=k(ce??Tt,[ce]),[Ut,je]=c.useState(()=>$t(o)),j=c.useMemo(()=>$t(Ut),[Ut]),Re=c.useRef(j),Ge=c.useRef(!0);c.useLayoutEffect(St.throttle(()=>{je(a=>{Ge.current=!0;const f=$t(o);return Z.isEqualSelectionCoords(f,a)?a:f})},0),[o]),c.useLayoutEffect(()=>{Re.current=j},[j]),c.useEffect(()=>{Ge.current||!r||Z.isEqualSelectionCoords(o,j)||r(j)},[j]);const qe=c.useCallback(a=>{je(f=>{Ge.current=!1,f=$t(f);let m=typeof a=="function"?a(f.ranges):a??Ho;if(Z.isEqualRangesArrays(m,f.ranges))return f;let g=Math.max(m.length?0:-1,Math.min(f.rangeIndex,m.length-1)),b=f.cell;g===-1||Z.isCellWithinRange(b,m[g])||(b={rowIndex:m[g].rowStart,colIndex:m[g].colStart}),m.length===1&&Z.isSingleCell(m[0])&&Z.isCellWithinRange(b,m[0])&&(m=[],g=-1);const W={cell:b,ranges:m,rangeIndex:g};return Z.isEqualSelectionCoords(W,f)?f:W})},[]),ht=k(a=>{je(f=>{Ge.current=!1,f=$t(f);const m=a??wi,g=A(m);if(!Z.isSingleCell(g)&&f.ranges.length===0)return{ranges:[g],rangeIndex:0,cell:m};if(Z.isEqualCells(m,f.cell))return f;let b=f.ranges,W=f.rangeIndex;f.ranges.length===1&&(Z.isSingleCell(f.ranges[0])&&Z.isCellWithinRange(m,f.ranges[0])||!Z.isCellWithinRange(m,f.ranges[0]))&&(b=[],W=-1);const S={ranges:b,rangeIndex:W,cell:m};return Z.isEqualSelectionCoords(S,f)?f:S})},[A]),[en,Kt]=c.useState(null),[zt,tn]=c.useState(null),Yt=c.useRef(null),[Le,Ft]=c.useState(null),gt=c.useRef(null),jt=c.useRef(null),[wn,nn]=c.useState(null),We=c.useRef(null),J=c.useRef(null),Ze=c.useRef(K);c.useEffect(()=>{Ze.current=K},[K]);const Ne=k((a,f={inline:"nearest",block:"nearest"})=>{let{rowIndex:m,colIndex:g}=a;m===void 0&&j?.cell&&(m=j.cell.rowIndex),g===void 0&&j?.cell&&(g=j.cell.colIndex),m!==void 0&&g!==void 0&&e.current?.scrollCellCoordsIntoView({rowIndex:m,colIndex:g},f)},[j]),lt=c.useCallback(a=>{const f=Se();return a.rowIndex<f.top||a.colIndex<f.left||a.colIndex>f.right||a.rowIndex>f.bottom},[]),Ee=k((a,f)=>{if(!e?.current)return null;const m={rowStart:Math.min(a.rowIndex,f.rowIndex),colStart:Math.min(a.colIndex,f.colIndex),rowEnd:Math.max(a.rowIndex,f.rowIndex),colEnd:Math.max(a.colIndex,f.colIndex)};if(N?.(m))return m;const b=A(a),W=A(f),S={rowStart:Math.min(b.rowStart,W.rowStart),colStart:Math.min(b.colStart,W.colStart),rowEnd:Math.max(b.rowEnd,W.rowEnd),colEnd:Math.max(b.colEnd,W.colEnd)};let de;return typeof Ze.current=="function"?de=Ze.current(S):K&&(de=K),de?Z.extendRangeToUnionRanges(S,de):S},[N,A]),Pe=k((a,f,m)=>{const g=a.ranges.length>0?a.ranges[a.rangeIndex]:{rowStart:a.cell.rowIndex,colStart:a.cell.colIndex,rowEnd:a.cell.rowIndex,colEnd:a.cell.colIndex},b={rowStart:Math.min(f.rowIndex??g.rowStart,m.rowIndex??g.rowStart),colStart:Math.min(f.colIndex??g.colStart,m.colIndex??g.colStart),rowEnd:Math.max(f.rowIndex??g.rowEnd,m.rowIndex??g.rowEnd),colEnd:Math.max(f.colIndex??g.colEnd,m.colIndex??g.colEnd)},W={rowIndex:b.rowStart,colIndex:b.colStart},S={rowIndex:b.rowEnd,colIndex:b.colEnd};if(!(lt(W)||lt(S)))return Ee(W,S)},[Ee]),tt=k((a,f,m)=>{if(s==="single"||!Re.current)return;const g=Pe(Re.current,a,f??Re.current.cell);if(!g)return;const b=Re.current.rangeIndex;qe(W=>W.length?W.map((S,de)=>b===de?g:S):[g]),m&&g&&ht({colIndex:g.colStart,rowIndex:g.rowStart})},[]),Je=c.useCallback((a,f,m)=>{if(!Re.current)return;a={...Re.current?.cell,...a},f=f??a;const g=Pe(Re.current,a,f);if(!g)return;const b={rowIndex:g.rowStart,colIndex:g.colStart},W={...b,...m};u==="clear"?(We.current=W,Gt()):u==="modify"?tt(b):De(b),ht(W)},[]),De=c.useCallback((a,f=a,m)=>{s!=="multiple"||!a||lt(a)||lt(f)||je(g=>{Ge.current=!1,g=$t(g);const b=Ee(a,f);if(!b)return g;let W=g.ranges.length>0?[...g.ranges]:[Ee(g.cell,g.cell)];W.push(b);const S={ranges:W,cell:{rowIndex:b.rowStart,colIndex:b.colStart,...m},rangeIndex:W.length-1};return Z.isEqualSelectionCoords(S,g)?g:S})},[]),Gt=()=>{qe(Ho)},Et=we.detectIt().primaryInput==="touch",Qe=c.useRef(null),_t=c.useRef(null),It=c.useRef(null),on=c.useMemo(()=>({onPointerDown:a=>{if(!e||!e.current)return!1;const f=a.nativeEvent,m=e.current.getViewFromClient(f.clientX,f.clientY);if(f.pointerType==="touch"||f.type==="touchstart")return _t.current={topLeft:m.getScrollTopLeft(),point:{x:f.clientX,y:f.clientY}},!0;const g=m.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);if(!g)return!1;Qe.current={anchor:m.getAnchor(),coords:g},J.current=null;const b=a.nativeEvent.which===yr;if(b&&Z.indexOfCoords(g,j.ranges)!==-1)return!1;const W=a.nativeEvent.shiftKey,S=a.nativeEvent.ctrlKey||a.nativeEvent.metaKey,de=S,te=d,oe=j.ranges.length>0,ge=S&&te;if(ne?.(a,g,j)===!1)return!1;i?.(Re.current,a.nativeEvent);const Oe=!b&&s!=="single";if(W)return tt(g),Oe;const ae=Z.isEqualCells(g,j.cell);if(de){if(ae&&(!ge||!oe))return Oe;if(S&&Z.indexOfCoords(g,j.ranges)!==-1&&te){gt.current=g;const re=Ee(g,g);return jt.current=re,Ft(re),Oe}return De(g),Oe}ie&&Ne(g),ae&&j.ranges.length===0||Je(g)},onPointerMoveOrWait:St.throttle((a,f)=>{if(!e?.current||a.pointerType==="touch"||a.type==="touchmove"||!Qe.current)return;const m=Qe.current.anchor;let g=e.current.getViewFromLocation(m),b=g.getCellCoordsFromClient(a.clientX,a.clientY);if(!Z.isEqualCells(b,Qe.current?.coords)&&(Qe.current={anchor:m,coords:b},b&&ve?.(a,b,Re.current)!==!1)){if(gt.current){const W={rowStart:Math.min(b.rowIndex,gt.current.rowIndex),colStart:Math.min(b.colIndex,gt.current.colIndex),rowEnd:Math.max(b.rowIndex,gt.current.rowIndex),colEnd:Math.max(b.colIndex,gt.current.colIndex)},S={rowIndex:W.rowStart,colIndex:W.colStart},de={rowIndex:W.rowEnd,colIndex:W.colEnd};if(lt(S)||lt(de))return;const te=Ee(S,de);jt.current=te,Ft(te)}else tt(b);It.current=f,Gn(g,b,e)}},60),onPointerUp:a=>{if(Qe.current=null,a.pointerType==="touch"||a.type==="touchend"){if(_t.current){const m=e.current.getViewFromClient(_t.current.point.x,_t.current.point.y),g=m.getScrollTopLeft();if(g.left===_t.current.topLeft.left&&g.top===_t.current.topLeft.top){const b=m.getCellCoordsFromClient(_t.current.point.x,_t.current.point.y);Je(b)}}return _t.current=null,void(Qe.current=null)}try{l?.(Re.current,a)}catch(m){console.warn(m)}if(!gt.current)return;const f=jt.current;gt.current=null,jt.current=null,Ft(null),je(m=>{if(Ge.current=!1,(m=$t(m)).ranges.length===0)return m;let g=[],b=-1,W=m.cell;for(let de=0;de<m.ranges.length;de++){const te=m.ranges[de];if(Z.isRangesIntersect(te,f)){const oe=St.subtractRect({top:te.rowStart,left:te.colStart,bottom:te.rowEnd+1,right:te.colEnd+1},{top:f.rowStart,left:f.colStart,bottom:f.rowEnd+1,right:f.colEnd+1});for(let ge=0;ge<oe.length;ge++){const Oe={rowStart:oe[ge].top,colStart:oe[ge].left,rowEnd:oe[ge].bottom-1,colEnd:oe[ge].right-1};g.push(Oe),Z.isCellWithinRange(m.cell,Oe)&&(b=g.length-1)}}else g.push(te);g.length>0&&b===-1&&Z.isCellWithinRange(m.cell,te)&&(b=g.length-1,W={rowIndex:g[g.length-1].rowStart,colIndex:g[g.length-1].colStart})}const S={cell:W,rangeIndex:b,ranges:g};return Z.isEqualSelectionCoords(S,m)?m:S})},processTouch:!0,consumeTouch:!1}),[j,s,d,ie,u]),so=k(vn(on),[]),co=c.useMemo(()=>({onSelectionPointerDown:(a,f,m,g,b=j.cell,W=ie,S=a.nativeEvent.shiftKey,de=!1)=>{if(!e||!e.current)return!1;a.stopPropagation(),a.preventDefault(),a.nativeEvent.stopImmediatePropagation();const te=m??e.current.getViewFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY),oe=g??te.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);if(!oe)return!1;Qe.current={anchor:te.getAnchor(),coords:oe},J.current=null;const ge=a.nativeEvent.which===yr;if(ge&&Z.indexOfCoords(oe,j.ranges)!==-1)return!1;const Oe=a.nativeEvent.ctrlKey||a.nativeEvent.metaKey,ae=Oe,re=d,vt=j.ranges.length>0,B=Oe&&re;if(ne?.(a,oe,j)===!1)return!1;i?.(Re.current,a.nativeEvent);const ke=!ge&&s!=="single";if(S)return tt(oe,b,de),ke;const Ct=Z.isEqualCells(oe,b);if(ae){if(Ct&&(!B||!vt))return ke;if(B&&Z.indexOfCoords(oe,j.ranges)!==-1&&re){gt.current=oe;const Ie=Ee(oe,oe);return jt.current=Ie,Ft(Ie),ke}return De(oe),ke}W&&Ne(oe),Ct&&j.ranges.length===0||Je(oe)},onSelectionPointerMoveOrWait:(a,f,m,g,b,W=j.cell,S=!0,de=!1)=>{if(!e?.current||(a.stopPropagation(),a.preventDefault(),a.stopImmediatePropagation(),!Qe.current))return;const te=Qe.current.anchor;let oe=g??e.current.getViewFromLocation(te),ge=b??oe.getCellCoordsFromClient(a.clientX,a.clientY);if(!Z.isEqualCells(ge,Qe.current?.coords)&&(Qe.current={anchor:te,coords:ge},ge&&ve?.(a,ge,Re.current)!==!1)){if(gt.current){const Oe={rowStart:Math.min(ge.rowIndex,gt.current.rowIndex),colStart:Math.min(ge.colIndex,gt.current.colIndex),rowEnd:Math.max(ge.rowIndex,gt.current.rowIndex),colEnd:Math.max(ge.colIndex,gt.current.colIndex)},ae={rowIndex:Oe.rowStart,colIndex:Oe.colStart},re={rowIndex:Oe.rowEnd,colIndex:Oe.colEnd};if(lt(ae)||lt(re))return;const vt=Ee(ae,re);jt.current=vt,Ft(vt)}else tt(ge,W,de);S&&Gn(oe,ge,e)}},onPointerUp:a=>{Qe.current=null,a.stopPropagation(),a.preventDefault(),a.stopImmediatePropagation();try{l?.(Re.current,a)}catch(m){console.warn(m)}if(!gt.current)return;const f=jt.current;gt.current=null,jt.current=null,Ft(null),je(m=>{if(Ge.current=!1,(m=$t(m)).ranges.length===0)return m;let g=[],b=-1,W=m.cell;for(let de=0;de<m.ranges.length;de++){const te=m.ranges[de];if(Z.isRangesIntersect(te,f)){const oe=St.subtractRect({top:te.rowStart,left:te.colStart,bottom:te.rowEnd+1,right:te.colEnd+1},{top:f.rowStart,left:f.colStart,bottom:f.rowEnd+1,right:f.colEnd+1});for(let ge=0;ge<oe.length;ge++){const Oe={rowStart:oe[ge].top,colStart:oe[ge].left,rowEnd:oe[ge].bottom-1,colEnd:oe[ge].right-1};g.push(Oe),Z.isCellWithinRange(m.cell,Oe)&&(b=g.length-1)}}else g.push(te);g.length>0&&b===-1&&Z.isCellWithinRange(m.cell,te)&&(b=g.length-1,W={rowIndex:g[g.length-1].rowStart,colIndex:g[g.length-1].colStart})}const S={cell:W,rangeIndex:b,ranges:g};return Z.isEqualSelectionCoords(S,m)?m:S})}}),[j,s,d,ie,u]),at=k((a,f=!1,m=!1,g=0)=>{if(!e.current||!j.cell)return;let b=j.cell,W=j.cell;if(f&&j.ranges.length>0){const B=j.ranges[j.rangeIndex],ke=j.cell;switch(a){case nt:W={rowIndex:ke.rowIndex===B.rowStart?B.rowEnd:B.rowStart,colIndex:B.colEnd},b={rowIndex:ke.rowIndex===B.rowStart?B.rowStart:B.rowEnd,colIndex:B.colStart};break;case ot:W={rowIndex:ke.rowIndex===B.rowEnd?B.rowStart:B.rowEnd,colIndex:B.colEnd},b={rowIndex:ke.rowIndex===B.rowEnd?B.rowEnd:B.rowStart,colIndex:B.colStart};break;case et:W={rowIndex:B.rowEnd,colIndex:ke.colIndex===B.colStart?B.colEnd:B.colStart},b={rowIndex:B.rowStart,colIndex:ke.colIndex===B.colStart?B.colStart:B.colEnd};break;case Ue:W={rowIndex:B.rowEnd,colIndex:ke.colIndex===B.colEnd?B.colStart:B.colEnd},b={rowIndex:B.rowStart,colIndex:ke.colIndex===B.colEnd?B.colEnd:B.colStart}}}const S=A(W);let{rowStart:de,colStart:te}=S;const oe=Se();if(J.current)switch(a){case nt:case ot:J.current.colIndex>=S.colStart&&J.current.colIndex<=S.colEnd&&(te=J.current.colIndex);break;case et:case Ue:J.current.rowIndex>=S.rowStart&&J.current.rowIndex<=S.rowEnd&&(de=J.current.rowIndex)}if(!g){switch(a){case nt:de=Ke(ut,Math.max(S.rowStart-1,oe.top),a);break;case ot:de=Ke(ut,Math.min(S.rowEnd+1,oe.bottom),a);break;case et:te=Ke(dt,Math.max(S.colStart-1,oe.left),a);break;case Ue:te=Ke(dt,Math.min(S.colEnd+1,oe.right),a)}if(m)switch(a){case nt:de=C({...W,colIndex:j.cell.colIndex},ee,ut,a,!1,Math.max(oe.top,ut(oe.top,!1)));break;case ot:de=C({...W,colIndex:j.cell.colIndex},ee,ut,a,!1,Math.min(oe.bottom,oe.bottom-ut(oe.bottom,!0)));break;case et:te=C({...W,rowIndex:j.cell.rowIndex},ee,dt,a,!1,Math.max(oe.left,dt(oe.left,!1)));break;case Ue:te=C({...W,rowIndex:j.cell.rowIndex},ee,dt,a,!1,Math.min(oe.right,oe.right-dt(oe.right,!0)))}}let ge=null;if(g){let B=0;switch(a){case nt:B=n.getRowOffset(de+1),de=Math.max(oe.top,n.getRowIndex(B-g)),ge={top:n.getRowOffset(de+1)-(B-e.current.getScrollPosition().top)};break;case ot:B=n.getRowOffset(de),de=Math.min(oe.bottom,n.getRowIndex(B+g)),ge={top:n.getRowOffset(de)-(B-e.current.getScrollPosition().top)};break;case et:B=n.getColOffset(te+1),te=Math.max(oe.left,n.getColIndex(B-g)),ge={left:n.getColOffset(te+1)-(B-e.current.getScrollPosition().left)};break;case Ue:B=n.getColOffset(te),te=Math.min(oe.right,n.getColIndex(B+g)),ge={left:n.getColOffset(te)-(B-e.current.getScrollPosition().left)}}}const Oe={rowIndex:de,colIndex:te},ae=A(Oe),re={rowIndex:ae.rowStart,colIndex:ae.colStart};f||(J.current=Oe);const vt=Z.isEqualCells(We.current,re)&&Z.isEqualCells(We.current,b);if(f&&!vt?tt(re,b):Je(re),ge)e.current.scrollTo(ge);else{if(f&&We.current){const B=Se();if(a===Ue&&We.current.colIndex===B.left||a===et&&We.current.colIndex===B.right||a===nt&&We.current.rowIndex===B.bottom||a===ot&&We.current.rowIndex===B.top)return}a===et||a===Ue?Ne({colIndex:Oe.colIndex}):a!==nt&&a!==ot||Ne({rowIndex:Oe.rowIndex})}},[j,A]),Zt=k(a=>{if(!e.current)return;if(j.ranges.length===0)return void at(a);const f=A(j.cell);if(Z.isEqualRangesArrays([f],j.ranges))return void at(a);const m=Fo(j,a,A,ut,dt);je(g=>{Ge.current=!1,g=$t(g);const b={...g,cell:m.cell,rangeIndex:m.rangeIndex};return Z.isEqualSelectionCoords(b,g)?g:b}),m.cell&&Ne(m.cell)},[j,A]),ao=c.useCallback(()=>{const a=Se();tt({rowIndex:a.top},{rowIndex:a.bottom})},[]),uo=c.useCallback(()=>{const a=Se();tt({colIndex:a.left},{colIndex:a.right})},[]),an=k(()=>{j.cell&&e?.current&&Ne(j.cell)},[j.cell]),An=c.useCallback((a=!1)=>{const f={rowIndex:Se().top};a?tt(f):Je(f),Ne(f)},[]),$n=c.useCallback((a=!1)=>{const f={rowIndex:Se().bottom};a?tt(f):Je(f),Ne(f)},[]),_n=c.useCallback((a=!1)=>{const f={colIndex:Se().left};a?tt(f):Je(f),Ne(f)},[]),mn=c.useCallback((a=!1)=>{const f=Se(),m={rowIndex:f.top,colIndex:f.left};a?tt(m):Je(m),Ne(m)},[]),Cn=c.useCallback((a=!1)=>{const f=Se(),m={colIndex:D?.()?.colEnd??f.right};a?tt(m):Je(m),Ne(m)},[D]),un=c.useCallback((a=!1)=>{const f=Se(),m={rowIndex:D?.()?.rowEnd??f.bottom,colIndex:D?.()?.colEnd??f.right};a?tt(m):Je(m),Ne(m)},[D]),In=k(a=>{if(!e.current||j.ranges.length<=1)return;const f=a===et||a===nt;let m=j.rangeIndex+(f?-1:1);m<0?m=j.ranges.length-1:m>j.ranges.length-1&&(m=0);const g=j.ranges[m],b=Fo({cell:{rowIndex:g.rowEnd,colIndex:g.colEnd},rangeIndex:0,ranges:[g]},Ue,A,ut,dt);je(W=>{Ge.current=!1,W=$t(W);const S={...W,cell:b.cell,rangeIndex:m};return Z.isEqualSelectionCoords(S,W)?W:S}),b.cell&&Ne(b.cell)},[j,A]),ho=k(()=>{const a=Pr(j);je(f=>{Ge.current=!1,f=$t(f);const m={...f,visibleSelection:a};return Z.isEqualSelectionCoords(m,f)?f:m}),a.cell&&Ne(a.cell)},[j,A]),fo=k(()=>{if(!e.current||j.ranges.length===0)return;const a=j.cell,f=j.ranges[j.rangeIndex],m=Pr({cell:a,rangeIndex:0,ranges:[f]}),g=m.ranges[m.rangeIndex];let b;b=g.rowStart===a.rowIndex&&g.colStart===a.colIndex?{rowIndex:g.rowStart,colIndex:g.colEnd}:g.rowStart===a.rowIndex&&g.colEnd===a.colIndex?{rowIndex:g.rowEnd,colIndex:g.colStart}:g.rowEnd===a.rowIndex&&g.colStart===a.colIndex?{rowIndex:g.rowEnd,colIndex:g.colEnd}:{rowIndex:g.rowStart,colIndex:g.colStart},je(W=>{W=$t(W);const S={...W,cell:b};return Z.isEqualSelectionCoords(S,W)?W:S}),b&&Ne(b)},[j,A]),Bn=c.useCallback((a=!1)=>{at(ot,a,!1,e.current.getDimensions().containerHeight)},[]),qt=c.useCallback((a=!1)=>{at(nt,a,!1,e.current.getDimensions().containerHeight)},[]),Fn=c.useCallback((a=!1)=>{at(Ue,a,!1,e.current.getDimensions().containerWidth)},[]),Mn=c.useCallback((a=!1)=>{at(et,a,!1,e.current.getDimensions().containerWidth)},[]),Vn=c.useCallback(()=>{Zt(et)},[]),Wn=c.useCallback(()=>{Zt(Ue)},[]),po=c.useCallback(()=>{Zt(nt)},[]),go=c.useCallback(()=>{Zt(ot)},[]),Rn=c.useCallback(()=>{In(et)},[]),wo=c.useCallback(()=>{In(Ue)},[]),mo=c.useCallback(()=>{fo()},[]),Hn=c.useCallback(()=>{at(et,!1,!1)},[]),v=c.useCallback(()=>{at(et,!0,!1)},[]),L=c.useCallback(()=>{at(et,!1,!0)},[]),z=c.useCallback(()=>{at(et,!0,!0)},[]),F=c.useCallback(()=>{at(Ue,!1,!1)},[]),V=c.useCallback(()=>{at(Ue,!0,!1)},[]),he=c.useCallback(()=>{at(Ue,!1,!0)},[]),le=c.useCallback(()=>{at(Ue,!0,!0)},[]),xe=c.useCallback(()=>{at(nt,!1,!1)},[]),ye=c.useCallback(()=>{at(nt,!0,!1)},[]),se=c.useCallback(()=>{at(nt,!1,!0)},[]),Be=c.useCallback(()=>{at(nt,!0,!0)},[]),st=c.useCallback(()=>{at(ot,!1,!1)},[]),Ae=c.useCallback(()=>{at(ot,!0,!1)},[]),$e=c.useCallback(()=>{at(ot,!1,!0)},[]),ft=c.useCallback(()=>{at(ot,!0,!0)},[]),Xe=c.useCallback(()=>{qe(a=>a.slice(0,-1))},[]),Mt=c.useMemo(()=>{const a=Se();return((f,m,g,b,W)=>{for(let S=0;S<f.length;S++){const de=f[S];if(de.rowStart===m&&de.colStart===g&&de.rowEnd===b&&de.colEnd===W)return!0}return!1})(j.ranges,a.top,a.left,a.bottom,a.right)},[$,j.ranges]),wt=c.useCallback((a,f=!0)=>{We.current=a,ht(a),f&&a&&e?.current&&Ne(a)},[]),pe=k((a=!0)=>{const f=Yt.current;if(!Re.current?.cell)return;const m=Re.current?.ranges,g=Re.current?.cell;if(!g||!f||!f)return;let b=null;if(b=m.length>0?m[m.length-1]:A(g),b.colEnd>=b.colStart&&b.rowEnd>=b.rowStart){const W=Or(b,f);let S=a?E:ue;try{S?.(b,f,W.direction)}catch(de){console.warn(de)}finally{a&&fe?.()}}},[A]),pt=c.useRef(null),Pt=vn(c.useMemo(()=>({onPointerDown:(a,f)=>{if(It.current=f,!e||!e.current)return!1;const m=e.current.getViewFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY),g=m?.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);g&&(a.stopPropagation(),Kt("crosshair"),pt.current={anchor:m.getAnchor(),coords:g})},onPointerMoveOrWait:(a,f)=>{if(_||!e?.current||!Re.current||!pt.current)return;const m=pt.current.anchor;let g=e.current.getViewFromLocation(m),b=g.getCellCoordsFromClient(a.clientX,a.clientY);if(!b)return;pt.current={anchor:m,coords:b};const W=Re.current.ranges;let S=Ee(Re.current.cell,b);if(!S)return;const de=W.length>0,te=de?W[W.length-1]:A(Re.current.cell);if(!S)return;const oe=S.rowStart<te.rowStart?nt:S.rowEnd>te.rowEnd?ot:S.colEnd>te.colEnd?Ue:et,ge=Se();oe===et&&(S={...te,colStart:Math.max(ge.left,S.colStart)}),oe===nt&&(S={...te,rowStart:Math.max(ge.top,S.rowStart)}),oe===Ue&&(S={...te,colEnd:Math.min(ge.right,S.colEnd)}),oe===ot&&(S={...te,rowEnd:Math.min(ge.bottom,S.rowEnd)});const Oe=Or(te,S);if(!N?.(te)){let ae;typeof Ze.current=="function"?ae=Ze.current(te):K&&(ae=K),S=((re,vt,B,ke,Ct,Ie)=>{const Ce={...vt};if(B.length===0)return Ce;if(Ct===et){const xt=re.colEnd+1-re.colStart;Ce.colStart=re.colStart-Math.ceil(Ie/xt)*xt,Ce.colStart<ke.left&&(Ce.colStart=Ce.colStart+Math.ceil((ke.left-Ce.colStart)/xt)*xt)}else if(Ct===Ue){const xt=re.colEnd+1-re.colStart;Ce.colEnd=re.colEnd+Math.ceil(Ie/xt)*xt,Ce.colEnd>ke.right&&(Ce.colEnd=Ce.colEnd-Math.ceil((ke.right-Ce.colEnd)/xt)*xt)}else if(Ct===nt){const xt=re.rowEnd+1-re.rowStart;Ce.rowStart=re.rowStart-Math.ceil(Ie/xt)*xt,Ce.rowStart<ke.top&&(Ce.rowStart=Ce.rowStart+Math.ceil((ke.top-Ce.rowStart)/xt)*xt)}else if(Ct===ot){const xt=re.rowEnd+1-re.rowStart;Ce.rowEnd=re.rowEnd+Math.ceil(Ie/xt)*xt,Ce.rowEnd>ke.bottom&&(Ce.rowEnd=Ce.rowEnd-Math.ceil((ke.bottom-Ce.rowEnd)/xt)*xt)}return Ce})(te,S,ae,ge,Oe.direction,Oe.amount)}if(de&&Z.isRangeWithinRange(S,te)&&(S=null),!Z.isEqualRanges(S,Yt.current)){if(tn(S),Yt.current=S,!S){try{X?.()}catch{}return void fe?.()}pe(!1)}It.current=f,Gn(g,b,e)},onPointerUp:(a,f)=>{It.current=f,Promise.resolve(pe(!0)).finally(()=>{fe?.(),tn(null),Yt.current=null,pt.current=null,Kt(null),e.current?.focus()})}}),[A])),At=c.useMemo(()=>({onPointerDown:Pt}),[Pt]),[_e,Ye]=c.useState(null),ze=c.useRef(null),rt=c.useMemo(()=>({onPointerDown:(a,f)=>{if(It.current=f,!e||!e.current)return!1;const m=e.current.getViewFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY),g=m?.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);if(!g)return;if(ne?.(a,g,j)===!1)return!1;a.stopPropagation(),Kt("default");const b=m.getRelativePointFromClient(0,0),W=Re.current?.ranges[Re.current?.ranges.length-1]??Z.cellToRange(Re.current?.cell),S=m.toClipBounds(m.getRangeCoordsBounds(W)),de={x:0,y:0};S.x-b.x>a.nativeEvent.clientX?de.x=a.nativeEvent.clientX-(S.x-b.x):a.nativeEvent.clientX>=S.x-b.x+S.width&&(de.x=Math.max(0,a.nativeEvent.clientX-(S.x-b.x+S.width))+1),S.y-b.y>a.nativeEvent.clientY?de.y=a.nativeEvent.clientY-(S.y-b.y):a.nativeEvent.clientY>=S.y-b.y+S.height&&(de.y=Math.max(0,a.nativeEvent.clientY-(S.y-b.y+S.height))+1),Y?.(W,a.nativeEvent,f),ze.current={range:W,anchor:m.getAnchor(),cell:g,isMoving:!1,extrusion:de}},onPointerMoveOrWait:(a,f,m)=>{if(H||!e?.current||!Re.current||!ze.current)return;const g=a.clientX-m.clientX,b=a.clientY-m.clientY;if(ze.current.isMoving=ze.current.isMoving||Math.abs(g)>Math.max(1,2)||Math.abs(b)>Math.max(1,2)||performance.now()-m.timeStamp>500,!ze.current.isMoving)return;const W=ze.current.anchor,S=ze.current.extrusion;let de=e.current.getViewFromLocation(W),te=de.getCellCoordsFromClient(a.clientX-S.x,a.clientY-S.y,!0);if(!te)return;const oe=ze.current.cell,ge=ze.current.range,Oe=Se(),ae=ge.colEnd-ge.colStart+1,re=Math.min(Math.max(0,oe.colIndex-ge.colStart),ae-1),vt=Math.min(Oe.right-ae+1,Math.max(Oe.left,te.colIndex-re)),B=ge.rowEnd-ge.rowStart+1,ke=Math.min(Math.max(0,oe.rowIndex-ge.rowStart),B-1),Ct=Math.min(Oe.bottom-B+1,Math.max(Oe.top,te.rowIndex-ke)),Ie={colStart:vt,colEnd:vt+ae-1,rowStart:Ct,rowEnd:Ct+B-1};Z.isEqualRanges(_e,Ie)&&!(Ce=>!Ce||!It.current||It.current.ctrlKey!==Ce.ctrlKey||It.current.shiftKey!==Ce.shiftKey||It.current.altKey!==Ce.altKey||It.current.metaKey!==Ce.metaKey)(a)||(Ye(Ie),O?.(Ie,a,f)),It.current=f,Gn(de,te,e)},onPointerUp:(a,f)=>{It.current=f;const m=()=>{Ye(null),ze.current=null,Kt(null),e.current?.focus()};if(!ze.current)return void m();const g=ze.current.range,b=_e;h?.(g,a,f),Promise.resolve(g&&b&&M?.(g,b,a,f)).finally(()=>{m()})}}),[_e]),Te=vn(rt),yt=c.useMemo(()=>({onPointerDown:Te}),[Te]),mt=c.useRef(null),Ot=c.useMemo(()=>{const a=Z.isEqualSelectionCoords(j,mt.current)?mt.current:j;return mt.current=a,a},[j]),Vt=c.useCallback(a=>{let f=null,m="br";const g=[],b={stroke:I,fill:me,strokeWidth:.5},W=(ae,re,vt)=>{const B=a.toClipBounds(a.getRangeCoordsBounds(ae),Wt);if(!B)return;B.x=B.width>0?B.x:B.x-b.strokeWidth/2,B.y=B.height>0?B.y:B.y-b.strokeWidth/2,B.width=Math.max(B.width,b.strokeWidth),B.height=Math.max(B.height,b.strokeWidth);const ke={key:`selection-fill-${re}`,range:ae,...B,...b};if(vt){const Ct=a.getCellCoordsAsRangeCoords(vt);ke.cell=vt,ke.pathBounds=a.toClipBounds(a.getRangeCoordsBounds(Ct),Wt),ke.pathBounds&&(ke.pathBounds.width<=0||ke.pathBounds.height<=0)&&(delete ke.pathBounds,delete ke.cell)}return Me(ke)};let S=j?$t(j):null;const de=S?.cell?a.getCellCoordsAsRangeCoords(S?.cell):Wl;!S||S.ranges&&S.ranges.length!==0||(S={ranges:[de],rangeIndex:0,cell:S.cell});for(let ae=0;S&&ae<S.ranges.length;ae++){const re=S.ranges[ae],vt=W(re,ae,ae===S.rangeIndex?S.cell:null);vt&&g.push(vt);const B=2,ke=.5,Ct=a.toClipBounds(a.getRangeCoordsBounds(re,{top:0,left:0,right:0,bottom:0}),Wt);if(Ct){const Ie=(S.ranges.length,4);g.push(Me({range:re,key:`selection-inside-edge-${ae}`,x:Ct.x-1,y:Ct.y-1,width:Math.max(Ct.width+1,0),height:Math.max(Ct.height+1,0),style:{overflow:"hidden"},stroke:I,strokeWidth:Ie}))}if(S.ranges.length===1){const Ie=a.toClipBounds(a.getRangeCoordsBounds(re),Wt);if(Ie){H||g.push(Me({range:re,key:`move-selection-hit-box-${ae}`,x:Ie.width>1?Ie.x:Ie.x-(q/2+1),y:Ie.height>1?Ie.y:Ie.y-(q/2+1),width:Math.max(Ie.width+2,1),height:Math.max(Ie.height+2,1),stroke:"transparent",style:{boxShadow:"none"},pathProps:{cursor:_e?void 0:"move",pointerEvents:"stroke"},strokeWidth:q,...yt}));const Ce=B;g.push(Me({range:re,key:`selection-single-${ae}`,x:Ie.x-Ce/2,y:Ie.y-Ce/2,width:Math.max(Ie.width+Ce/2,1),height:Math.max(Ie.height+Ce/2,1),stroke:G,strokeWidth:Ce}))}}else{const Ie=a.toClipBounds(a.getRangeCoordsBounds(re,{top:-1,left:-1,right:-2,bottom:-2}),Wt);Ie&&g.push(Me({range:re,key:`selection-multi-${ae}`,x:Ie.width>1?Ie.x:Ie.x-ke/2,y:Ie.height>1?Ie.y:Ie.y-ke/2,width:Math.max(Ie.width,ke)+1,height:Math.max(Ie.height,ke)+1,stroke:G,style:{overflow:"hidden"},strokeWidth:2}))}if(S.ranges.length>1&&ae===S.rangeIndex){const Ie=a.getCellCoordsAsRangeCoords(S.cell),Ce=a.toClipBounds(a.getRangeCoordsBounds(Ie,{top:1,left:1,right:-1,bottom:-1}),Wt);Ce&&g.push(Me({range:re,key:`selection-anchor-${ae}`,x:Ce.x,y:Ce.y,width:Math.max(Ce.width,ke),height:Math.max(Ce.height,ke),stroke:G,style:{overflow:"hidden"},strokeWidth:2}))}if(ae===S.ranges.length-1){f=null,m=null;const Ie=re.rowStart===Se().top&&re.rowEnd===Se().bottom,Ce=re.colStart===Se().left&&re.colEnd===Se().right,xt=a.getRangeCoordsBounds(re);let Xt=null;if(Ie||Ce){if(Xt=a.toClipBounds(xt,Wt),Object.keys(a.allViews()).length>1){const Nn=a.getVisibleRangeCoords(),Zo=a.allViews()[to],Ei=a.allViews()[Ln],_i=a.allViews()[Dn],Un=a.getAnchor();(Ce&&(Un===Ln&&Zo||Un===Ht&&_i||!Z.isCellWithinRange({colIndex:re.colStart,rowIndex:re.rowEnd},Nn)&&!Z.isCellWithinRange({colIndex:re.colStart,rowIndex:re.rowEnd+1},Nn))||Ie&&(Un===Dn&&Zo||Un===Ht&&Ei||!Z.isCellWithinRange({colIndex:re.colEnd,rowIndex:re.rowStart},Nn)&&!Z.isCellWithinRange({colIndex:re.colEnd+1,rowIndex:re.rowStart},Nn)))&&(Xt=null)}}else Xt=a.toClipBounds(xt,Wt);if(!Xt||Xt.width===0||Xt.height===0)continue;f={x:Xt.x+Xt.width+1,y:Xt.y+Xt.height+1},Xt.width===0||Xt.height===0||re.rowStart===Se().top&&re.colStart===Se().left&&re.rowEnd===Se().bottom&&re.colEnd===Se().right||(Ie?(f.y=B,m="tr"):Ce&&(f.x=B,m="bl"))}}let te=null;if(Le){const ae=a.toClipBounds(a.getRangeCoordsBounds(Le,{top:0,left:0,right:0,bottom:0}),Wt);ae&&(te=Me({...b,range:Le,key:"remove-selection",x:ae.x,y:ae.y,width:ae.width,height:ae.height,strokeWidth:2,stroke:Ve,fill:He}))}let oe=null;if(zt){const ae=a.toClipBounds(a.getRangeCoordsBounds(zt,{top:0,left:0,right:0,bottom:0}),Wt);ae&&(oe=Me({range:zt,key:"selection-fill-outline",x:ae.x-2/2,y:ae.y-2/2,width:ae.width+2/2,height:ae.height+2/2,strokeWidth:2,stroke:G,strokeDasharray:"3 2"}))}let ge=null;!_&&f&&!_e&&(ge=c.createElement(Wo,{...f,corner:m,size:7.5,borderStroke:`${I} solid`,style:{borderRadius:1},background:G,...At,key:"fillHandle"}));const Oe=[...g];if(te&&Oe.push(te),oe&&Oe.push(oe),ge&&Oe.push(ge),!Fe&&Et&&S?.ranges.length===1&&S.ranges[S.ranges.length-1]){const ae=S.ranges[S.ranges.length-1],re=ae.rowStart===Se().top&&ae.rowEnd===Se().bottom,vt=ae.colStart===Se().left&&ae.colEnd===Se().right,B={view:a,range:ae,borderStroke:`${G} solid`,background:I,selectionTouchPointerHandler:co,...ct,onTouchSelectStart:ke=>nn(ke),onTouchSelectEnd:()=>nn(null),currentTouchAnchor:wn};Oe.push(T.jsx(Qn,{anchor:vt?"b":re?"r":"br",scrollableElement:e.current,...B},"touch-select-handle-after")),Oe.push(T.jsx(Qn,{anchor:vt?"t":re?"l":"tl",scrollableElement:e.current,...B},"touch-select-handle-before"))}if(_e){const ae=a.toClipBounds(a.getRangeCoordsBounds(_e,{top:1,left:1,right:1,bottom:1}),Wt);ae&&Oe.push(Me({range:_e,key:"selection-move-outline",x:ae.x-U/2,y:ae.y-U/2,width:Math.max(ae.width+U/2,1),height:Math.max(ae.height+U/2,1),stroke:G,style:{boxShadow:"none",transitionDuration:"70ms",transitionTimingFunction:"ease-in",transitionProperty:"left, top, width, height",willChange:"left, top, width, height"},strokeWidth:U}))}return T.jsx("div",{children:Oe},"selection")},[Ot,Le,_,zt,H,_e,Se,I,G,me,Ve,He,Fe,ct,wn]),Rt=c.useMemo(()=>{const a=()=>e.current;return[new be("moveToPageDown",a,{label:"Page Down",description:"Shift viewport down one page.",shortcut:[{key:"PageDown"}]},()=>Bn(!1)),new be("selectToPageDown",a,{label:"Select To Page Down",description:"Shift viewport and select down one page.",shortcut:[{key:"PageDown",modifiers:[bt]}]},()=>Bn(!0)),new be("moveToPageRight",a,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[dn]}]},()=>Fn(!1)),new be("selectToPageRight",a,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[dn,bt]}]},()=>Fn(!0)),new be("moveToPageUp",a,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp"}]},()=>qt(!1)),new be("selectToPageUp",a,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp",modifiers:[bt]}]},()=>qt(!0)),new be("moveToPageLeft",a,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[dn]}]},()=>Mn(!1)),new be("selectToPageLeft",a,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[dn,bt]}]},()=>Mn(!0)),new be("selectColumn",a,{label:"Select Column",description:"Select the columns for the selected cells.",shortcut:{key:"Space",modifiers:[kt]}},ao),new be("selectRow",a,{label:"Select Row",description:"Select the rows for the selected cells.",shortcut:{key:"Space",modifiers:[bt]}},uo),new be("selectToColumnStart",a,{label:"Select To Column Start",description:"Select the columns to the beginning of the sheet."},()=>An(!0)),new be("selectToColumnEnd",a,{label:"Select To Column End",description:"Select the columns to the end of the sheet."},()=>$n(!0)),new be("moveToRowStart",a,{label:"Move to Row Home",description:"Move to the beginning of the row.",shortcut:[{key:"Home"}]},()=>_n(!1)),new be("selectToRowStart",a,{label:"Select to Row Home",description:"Select to the beginning of the row.",shortcut:[{key:"Home",modifiers:[bt]}]},()=>_n(!0)),new be("moveToSheetStart",a,{label:"Move to Sheet Home",description:"Move to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[kt]}]},()=>mn(!1)),new be("selectToSheetStart",a,{label:"Select to Sheet Home",description:"Select to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[kt,bt]}]},()=>mn(!0)),new be("moveToRowEnd",a,{label:"Move to Row End",description:"Move to the end of the row.",shortcut:[{key:"End"}]},()=>Cn(!1)),new be("selectToRowEnd",a,{label:"Select to Row End",description:"Select to the end of the row.",shortcut:[{key:"End",modifiers:[bt]}]},()=>Cn(!0)),new be("moveToSheetEnd",a,{label:"Move to Sheet End",description:"Move to the end of the sheet.",shortcut:[{key:"End",modifiers:[kt]}]},()=>un(!1)),new be("selectToSheetEnd",a,{label:"Select to Sheet End",description:"Select to the end of the sheet.",shortcut:[{key:"End",modifiers:[kt,bt]}]},()=>un(!0)),new be("scrollToActiveCoords",a,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell.",shortcut:{key:"Backspace",modifiers:[kt]}},an),new be("scrollToActiveCoordsClearSelection",a,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell and clear selection.",shortcut:{key:"Backspace",modifiers:[bt]}},()=>{Gt(),wt(j.cell,!0)}),new be("traverseSelectionRight",a,{label:"Traverse Right",description:"Traverse the selection moving rightward.",shortcut:{key:"Tab"}},Wn),new be("traverseSelectionLeft",a,{label:"Traverse Left",description:"Traverse the selection moving leftward.",shortcut:{key:"Tab",modifiers:[bt]}},Vn),new be("traverseSelectionDown",a,{label:"Traverse Down",description:"Traverse the selection moving downward.",shortcut:[{key:"Enter"},{key:"NumpadEnter"}]},go),new be("traverseSelectionUp",a,{label:"Traverse Up",description:"Traverse the selection moving upward.",shortcut:[{key:"Enter",modifiers:[bt]},{key:"NumpadEnter",modifiers:[bt]}]},po),new be("moveLeft",a,{label:"Move Left",description:"Move active cell to the left.",shortcut:[{key:"ArrowLeft"}]},Hn),new be("selectLeft",a,{label:"Select Left",description:"Extend selection left.",shortcut:[{key:"ArrowLeft",modifiers:[bt]}]},v),new be("moveContentfulLeft",a,{label:"Move Left Contentful",description:"Move left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[kt]}]},L),new be("selectContentfulLeft",a,{label:"Select Left Contentful",description:"Extend selection left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[kt,bt]}]},z),new be("moveRight",a,{label:"Move Right",description:"Move active cell to the right.",shortcut:[{key:"ArrowRight"}]},F),new be("selectRight",a,{label:"Select Right",description:"Extend selection right.",shortcut:[{key:"ArrowRight",modifiers:[bt]}]},V),new be("moveContentfulRight",a,{label:"Move Right Contentful",description:"Move right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[kt]}]},he),new be("selectContentfulRight",a,{label:"Select Right Contentful",description:"Extend selection right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[kt,bt]}]},le),new be("moveUp",a,{label:"Move Up",description:"Move active cell to the up.",shortcut:[{key:"ArrowUp"}]},xe),new be("selectUp",a,{label:"Select Up",description:"Extend selection up.",shortcut:[{key:"ArrowUp",modifiers:[bt]}]},ye),new be("moveContentfulUp",a,{label:"Move Up Contentful",description:"Move up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[kt]}]},se),new be("selectContentfulUp",a,{label:"Select Up Contentful",description:"Extend selection up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[kt,bt]}]},Be),new be("moveDown",a,{label:"Move Down",description:"Move active cell to the down.",shortcut:[{key:"ArrowDown"}]},st),new be("selectDown",a,{label:"Select Down",description:"Extend selection down.",shortcut:[{key:"ArrowDown",modifiers:[bt]}]},Ae),new be("moveContentfulDown",a,{label:"Move Down Contentful",description:"Move down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[kt]}]},$e),new be("selectContentfulDown",a,{label:"Select Down Contentful",description:"Extend selection down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[kt,bt]}]},ft),new be("selectVisible",a,{label:"Select Visible",description:"Select visible cells only.",shortcut:{key:";",modifiers:[dn]}},ho),new be("traverseSelectionPreviousRange",a,{label:"Traverse Previous Range",description:"Traverse the selection to the previous range.",shortcut:{key:"ArrowLeft",modifiers:[kt,dn]}},Rn),new be("traverseSelectionNextRange",a,{label:"Traverse Next Range",description:"Traverse the selection to the next range.",shortcut:{key:"ArrowRight",modifiers:[kt,dn]}},wo),new be("traverseSelectionCorners",a,{label:"Traverse Corners",description:"Traverse the selection through the corners of the selected range.",shortcut:{key:".",modifiers:[kt]}},mo)]},[]);return c.useMemo(()=>{t?.addCommands(Rt,!0)},[t]),{selection:Ot,setSelectionCell:wt,setSelectionRanges:qe,overlay:Vt,cursor:en,onPointerDown:so,clearLastSelection:Xe,newSelection:Je,modifySelection:tt,appendSelection:De,clearSelections:Gt,isEntire:Mt,navigate:at,navigateSelection:Zt}};
|