@sheetxl/grid-react 0.3.18 → 0.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,19 @@
1
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.18
3
+ * @license @sheetxl/grid-react - Grid - Advanced data grid component for React - v0.3.20
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 O=require("react/jsx-runtime"),c=require("react"),Pi=require("react-dom/client"),No=require("react-dom"),nt="up",ot="down",et="left",Ne="right",to="tl",Ln="t",Dn="l",Ht="c",Dt="text/html",rn="text/plain",xo="image/png",Oi=Object.freeze({left:0,top:0}),Li=Object.freeze({left:0,top:0,bottom:0,right:0}),Di=Object.freeze({x:0,y:0,width:0,height:0});Object.freeze(Object.defineProperty({__proto__:null,EmptyBounds:Di,EmptyRect:Li,EmptyTopLeft:Oi},Symbol.toStringTag,{value:"Module"}));const Bt="column",en="row",zi=Object.freeze({colIndex:0,rowIndex:0}),ji=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,Ai=(e,t)=>e.rowEnd===t.rowEnd?t.colEnd-e.colEnd:t.rowEnd-e.rowEnd,$i=(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=en,t=!1)=>t?e!==Bt?Ai:$i: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},Bi=[null,null],Fi=(e,t,n)=>{if(e[0].value===e[1].value)return t};function or(e,t=2,n,o=en,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?en:Bt));i=[],i.push(d[0]);const w=d.length;let x=0,p=d[0],y=p.colStart,C=p.rowStart,R=p.colEnd,T=p.rowEnd;for(let ce=1;ce<w;ce++){const L=d[ce];let I=!1;if(I=l?p&&C===L.rowStart&&T===L.rowEnd&&R+1===L.colStart:p&&y===L.colStart&&R===L.colEnd&&T+1===L.rowStart,I){let j={colStart:y,rowStart:C,colEnd:l?L.colEnd:R,rowEnd:l?T:L.rowEnd};if(p.value!==void 0&&(j.value=p.value),n){const ie=r??[null,null];ie[0]=p,ie[1]=L,j=n(ie,j,o)}if(j){i[x]=j,u=!0,p=j,y=p.colStart,C=p.rowStart,R=p.colEnd,T=p.rowEnd;continue}}i[++x]=L,p=L,y=p.colStart,C=p.rowStart,R=p.colEnd,T=p.rowEnd}s++,l=!l,s===1&&(u=!0)}while(s<t&&u&&i.length>1);return i}const G=Object.freeze(Object.defineProperty({__proto__:null,EmptyCell:zi,EmptyRange:ji,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=en,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 C=e?e(r,d,t):r===d?d:void 0;C===void 0?w=!1:d=C}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?Fi:s,t?Bt:en,Bi):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"})),Vi=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function Wi(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===Vi}(e)}function Pn(e,t){return t.clone!==!1&&t.isMergeableObject(e)?pn((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function Hi(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||Hi,n.isMergeableObject=n.isMergeableObject||Wi,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 Ni=Object.freeze([]),Ui=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),Ki=(e,t)=>!(e!==t&&!Hr(e,t)&&!e.isEqual?.(t)),Ur=(e,t,n=Ki)=>{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),zt={Windows:"windows",MacOS:"macos",IOS:"ios",Linux:"linux",Android:"android",Safari:"safari",Firefox:"firefox",Node:"node",Unknown:"unknown"},zn=()=>{if(Kr())return zt.Node;const e=globalThis.navigator!==void 0&&globalThis.navigator.userAgent?globalThis.navigator.userAgent.toLowerCase():"";return e?/(win32|win64|windows|wince)/i.test(e)?zt.Windows:/(macintosh|macintel|macppc|mac68k|macos)/i.test(e)?zt.MacOS:/(iphone|ipad|ipod)/i.test(e)?zt.IOS:/android/.test(e)?zt.Android:/linux/.test(e)?zt.Linux:/^((?!chrome|android|).)*safari/i.test(e)?zt.Safari:/^((?!chrome|android|Seamonkey).)*firefox/i.test(e)?zt.Firefox:zt.Unknown:zt.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:Ni,EmptyObject:Ui,OSType:zt,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)},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.
7
+ */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),c=require("react"),Ti=require("react-dom/client"),No=require("react-dom"),nt="up",ot="down",et="left",Ne="right",to="tl",Ln="t",Dn="l",Ht="c",Dt="text/html",rn="text/plain",xo="image/png",Pi=Object.freeze({left:0,top:0}),Oi=Object.freeze({left:0,top:0,bottom:0,right:0}),Li=Object.freeze({x:0,y:0,width:0,height:0});Object.freeze(Object.defineProperty({__proto__:null,EmptyBounds:Li,EmptyRect:Oi,EmptyTopLeft:Pi},Symbol.toStringTag,{value:"Module"}));const Bt="column",en="row",Di=Object.freeze({colIndex:0,rowIndex:0}),zi=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,ji=(e,t)=>e.rowEnd===t.rowEnd?t.colEnd-e.colEnd:t.rowEnd-e.rowEnd,Ai=(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=en,t=!1)=>t?e!==Bt?ji:Ai: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},$i=[null,null],Bi=(e,t,n)=>{if(e[0].value===e[1].value)return t};function or(e,t=2,n,o=en,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?en:Bt));i=[],i.push(d[0]);const p=d.length;let x=0,h=d[0],y=h.colStart,R=h.rowStart,C=h.colEnd,L=h.rowEnd;for(let J=1;J<p;J++){const O=d[J];let I=!1;if(I=l?h&&R===O.rowStart&&L===O.rowEnd&&C+1===O.colStart:h&&y===O.colStart&&C===O.colEnd&&L+1===O.rowStart,I){let j={colStart:y,rowStart:R,colEnd:l?O.colEnd:C,rowEnd:l?L:O.rowEnd};if(h.value!==void 0&&(j.value=h.value),n){const le=r??[null,null];le[0]=h,le[1]=O,j=n(le,j,o)}if(j){i[x]=j,u=!0,h=j,y=h.colStart,R=h.rowStart,C=h.colEnd,L=h.rowEnd;continue}}i[++x]=O,h=O,y=h.colStart,R=h.rowStart,C=h.colEnd,L=h.rowEnd}s++,l=!l,s===1&&(u=!0)}while(s<t&&u&&i.length>1);return i}const G=Object.freeze(Object.defineProperty({__proto__:null,EmptyCell:Di,EmptyRange:zi,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=en,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 p=!0;const x=d!==void 0;if(x){const R=e?e(r,d,t):r===d?d:void 0;R===void 0?p=!1:d=R}if(p&&u===l+1&&s===i)return t?o.rowEnd=u:o.colEnd=u,l=u,void(r=d);o&&n.push(o);const h=t?s:u,y=t?u:s;o={colStart:h,rowStart:y,colEnd:h,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?Bi:s,t?Bt:en,$i):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"})),Fi=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function Vi(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===Fi}(e)}function Pn(e,t){return t.clone!==!1&&t.isMergeableObject(e)?pn((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function Wi(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||Wi,n.isMergeableObject=n.isMergeableObject||Vi,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,p;ir(d=r,p=u)&&(!Object.hasOwnProperty.call(d,p)||!Object.propertyIsEnumerable.call(d,p))||(ir(r,u)&&l.isMergeableObject(i[u])?s[u]=function(x,h){if(!h.customMerge)return pn;const y=h.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 Hi=Object.freeze([]),Ni=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),Ui=(e,t)=>!(e!==t&&!Hr(e,t)&&!e.isEqual?.(t)),Ur=(e,t,n=Ui)=>{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),zt={Windows:"windows",MacOS:"macos",IOS:"ios",Linux:"linux",Android:"android",Safari:"safari",Firefox:"firefox",Node:"node",Unknown:"unknown"},zn=()=>{if(Kr())return zt.Node;const e=globalThis.navigator!==void 0&&globalThis.navigator.userAgent?globalThis.navigator.userAgent.toLowerCase():"";return e?/(win32|win64|windows|wince)/i.test(e)?zt.Windows:/(macintosh|macintel|macppc|mac68k|macos)/i.test(e)?zt.MacOS:/(iphone|ipad|ipod)/i.test(e)?zt.IOS:/android/.test(e)?zt.Android:/linux/.test(e)?zt.Linux:/^((?!chrome|android|).)*safari/i.test(e)?zt.Safari:/^((?!chrome|android|Seamonkey).)*firefox/i.test(e)?zt.Firefox:zt.Unknown:zt.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:Hi,EmptyObject:Ni,OSType:zt,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 p=Date.now()-s;p<t&&p>=0?o=setTimeout(u,t-p):(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 p=n&&!o;return o||(o=setTimeout(u,t)),p&&(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)},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)}),bo="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:bo})),s=await hr(l);n={mimeType:t??bo,naturalDimensions:s,asUrl:l,asSVGText:i}}catch{}};if(t===bo?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 p=u[d];let x,h=r[p];if(h!==void 0){const y=i[p];x=y?(0,pr.resolveTypedUpdates)(h,y,n,o?.[p]):h}else x=o?.[p];x!=null&&(s=s??{},s[p]=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
- Please use Chrome or Edge if external copy and paste is required.`,bo=`You do not have permissions to access the clipboard.
10
+ Please use Chrome or Edge if external copy and paste is required.`,vo=`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()===zt.Safari?gr:bo,PermsRead:zn()===zt.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()===zt.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:[Dt]})}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=Dt)=>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=Dt)=>{const n=await Do(e,t);if(!n)return null;let o=null;try{o=new DOMParser().parseFromString(n,Dt)}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}"/>`,qi=(e,t)=>{let n=null;try{const o=new DOMParser().parseFromString(t,Dt);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,Dt);return!this._state||(xr(this._state.uuid,t)||this.clear(),!0)},async e=>{e?.message==="denied"||e.message?.includes("Document is not focused")||zn()===zt.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,Dt);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({[Dt]:new Blob([mr(o)],{type:Dt})})));for(let l=0;l<Math.min(1,r.length);l++){const s=r[l];let u=s.types.indexOf(Dt),d=null;if(u!==-1){const p=await s.getType(Dt);d=await Lo(p),d&&(d=qi(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:Dt}),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[Dt]=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[Dt]=new Blob([r],{type:Dt}))}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)}}();const On={Left:"left",Right:"right",Center:"center"},bt="shift",dn="alt",Pt="ctrl",Jr=9,Qr=13,Xi=27,ei=37,ti=38,ni=39,oi=40,Yi=113,yr=3,cn={Horizontal:"horizontal",Vertical:"vertical"};function ri(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=ri(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=ri(e))&&(o&&(o+=" "),o+=t);return o}var Gi=function(){},ii=typeof window<"u",Zi=ii?c.useLayoutEffect:c.useEffect,vr={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const gn=ii&&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,C=u.left,R=u.bottom,T=u.right;i({x:d,y:w,width:x,height:p,top:y,left:C,bottom:R,right:T})}})},[]);return Zi(function(){if(t)return l.observe(t),function(){l.disconnect()}},[t]),[n,r]}:function(){return[Gi,vr]},P=(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 O.jsx("div",{style:{paddingBottom:"0px",paddingRight:"0px",paddingLeft:r?"0px":"3px",paddingTop:r?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...t},...o,children:O.jsx("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${r?"vertical":"horizontal"} single-button start`,children:O.jsx("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:O.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 O.jsx("div",{style:{paddingLeft:"0px",paddingTop:"0px",paddingRight:r?"0px":"3px",paddingBottom:r?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...t},...o,children:O.jsx("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${r?"vertical":"horizontal"} single-button end`,children:O.jsx("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:O.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:C=Ji,createScrollEndButton:R=Qi,...T}=e,ce=P(d,[d]),L=c.useRef(null),[I,{width:j,height:ie}]=gn(),[B,{width:ne,height:ve}]=gn(),U=s===cn.Vertical,N=U?"top":"left",Y=U?"scrollTop":"scrollLeft",k=U?ie:j,E=U?ve:ne,[f,Z]=c.useState(null);c.useEffect(()=>{f!==null&&L.current&&L.current.scrollTo({behavior:"smooth",[N]:f})},[f,U]);const q=c.useCallback((Ke,$=!1)=>{if(!L.current)return 0;const _=L.current.querySelector(".scrollbar-viewport"),Ce=_.getBoundingClientRect(),ue=_.children,we=$?0:zo(Ke,Ce[N],ue,!0,Math.max(0,Ke-x));return Z(we),Math.max(0,we)},[]),z=c.useCallback((Ke,$=!1)=>{if(!L.current)return 0;const _=L.current.querySelector(".scrollbar-viewport"),Ce=_.getBoundingClientRect(),ue=_.children,we=Math.ceil(E-k),ze=$?we:zo(Ke,Ce[N],ue,!1,Math.max(0,Ke+x));return Z(ze),Math.min(we,ze)},[E,k]),K=c.useRef(null),Q=c.useCallback(Ke=>{K.current=n;const $=Ke.target[Y];u($,r,o),ce?.(Ke)},[u,r,o,n]);c.useEffect(()=>{const Ke=K.current;K.current=null,n!==Ke&&(L.current[Y]=n)},[n,Y]);const ee=c.useRef(null),X=c.useRef(null),Ve=c.useCallback(()=>{ee.current&&(clearTimeout(ee.current),ee.current=null,X.current=null)},[]),Be=c.useCallback((Ke,$,_,Ce=p)=>{X.current=Ke,ee.current=setTimeout(()=>{const ue=_?q(X.current||Ke):z(X.current||Ke);ue!==X.current?Be(ue,!1,_,y):Ve()},$?0:Ce)},[q,z,Ve]);c.useEffect(()=>()=>Ve(),[Ve]);const We=n,it=c.useMemo(()=>{if(!w)return null;const Ke={orientation:s,disabled:Math.floor(We)<=0||Math.floor(E-k)===0,onMouseUp:Ve,onMouseLeave:Ve,onMouseDown:()=>Be(We,!0,!0)};return C?.(Ke)},[w,s,We,f,E,k]),be=c.useMemo(()=>{if(!w)return null;const Ke={orientation:s,disabled:Math.floor(E-k)<=Math.ceil(We),onMouseUp:Ve,onMouseLeave:Ve,onMouseDown:()=>Be(We,!0,!1)};return R?.(Ke)},[w,s,We,f,E,k]);return O.jsxs("div",{ref:t,style:{display:"flex",flex:"1",flexDirection:U?"column":"row",padding:"0",...i},className:yn("_sheetxl-scrollbar_eblx4_6",l),...T,children:[it,O.jsx("div",{className:"pseudo-scrollbar",style:{flex:"1 1 100%",display:"flex",boxSizing:"content-box",flexDirection:U?"column":"row",justifyContent:"center",alignItems:"center"},ref:I,children:O.jsx("div",{tabIndex:-1,style:{flex:"1 1 100%",overflowY:U?"scroll":"hidden",overflowX:U?"hidden":"scroll",position:"relative",willChange:"transform"},onScroll:Q,ref:L,children:O.jsx("div",{ref:B,style:{position:"absolute",height:U?o-r+(ie??0):1,width:U?1:o-r+(j??0)},className:"scrollbar-viewport"})})}),be]})}));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 R=Math.round((y-l)/16.666666666666668)-1;for(let T=0;T<Math.min(R,4);T++)w(!0),u++}o&&(s=(y-i)/o,s>1&&(s=1));const C=r?r(s):s;e(C,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)},li=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]};li.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 C=this.__maxScrollLeft;(u>C||u<0)&&(this.options.bouncing?u+=l/2*this.options.speedMultiplier:u=u>C?C:0)}if(this.__enableScrollY){d-=s*this.options.speedMultiplier;var R=this.__maxScrollTop;(d>R||d<0)&&(this.options.bouncing?d+=s/2*this.options.speedMultiplier:d=d>R?R:0)}i.length>60&&i.splice(0,30),i.push(u,d,t),this.__publish(u,d,w)}else{var T=this.options.locking?3:0,ce=Math.abs(o-this.__initialTouchLeft),L=Math.abs(r-this.__initialTouchTop);this.__enableScrollX=this.options.scrollingX&&ce>=T,this.__enableScrollY=this.options.scrollingY&&L>=T,i.push(this.__scrollLeft,this.__scrollTop,t),this.__isDragging=(this.__enableScrollX||this.__enableScrollY)&&(ce>=5||L>=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(C,R,T){T&&(this.__scrollLeft=i+u*C,this.__scrollTop=l+d*C,this.__zoomLevel=s+w*C,this.__callback&&this.__callback(this.__scrollLeft,this.__scrollTop,this.__zoomLevel))}.bind(this),p=function(C){return this.__isAnimating===C}.bind(this),y=function(C,R,T){R===this.__isAnimating&&(this.__isAnimating=!1),(this.__didDecelerationComplete||T)&&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),si=!1,rl={get passive(){return si=!0}},Er=function(){};Nt.addEventListener&&Nt.addEventListener("p",Er,rl),Nt.removeEventListener&&Nt.removeEventListener("p",Er,!1);var il=si,ll="PointerEvent"in Nt,Ko="ontouchstart"in Nt,ci=Ko||"TouchEvent"in Nt&&En("(any-pointer: coarse)").matches,_r=(Nt.navigator.maxTouchPoints||0)>0||ci,ai=Nt.navigator.userAgent||"",sl=En("(pointer: coarse)").matches&&/iPad|Macintosh/.test(ai)&&Math.min(Nt.screen.width||0,Nt.screen.height||0)>=768,ui=(En("(pointer: coarse)").matches||!En("(pointer: fine)").matches&&Ko)&&!/Windows.*Firefox/.test(ai),cl=En("(any-pointer: fine)").matches||En("(any-hover: hover)").matches||sl||!Ko,jo=!_r||!cl&&ui?_r?"touchOnly":"mouseOnly":"hybrid",al=jo==="mouseOnly"?"mouse":jo==="touchOnly"||ui?"touch":"mouse";const ul=Object.freeze(Object.defineProperty({__proto__:null,deviceType:jo,primaryInput:al,supportsPassiveEvents:il,supportsPointerEvents:ll,supportsTouchEvents:ci},Symbol.toStringTag,{value:"Module"})),dl=new Set(["INPUT","TEXTAREA","SELECT"]),di={};function Ao(){return ul}const ge=Object.freeze(Object.defineProperty({__proto__:null,EmptyCssProperties:di,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=>O.jsx(Uo,{...e}),fl=({width:e,height:t})=>O.jsx("div",{className:"corner",style:{minWidth:`${e}px`,width:`${e}px`,minHeight:`${t}px`,height:`${t}px`}}),hi=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,C=P(r,[r]),R=lo(t,()=>({isScrollPane:()=>!0}),[]),T=c.useRef(null);c.useEffect(()=>{T.current&&(T.current.__scrollTop===o?.top&&T.current.__scrollLeft!==!o?.left||T.current?.scrollTo(o?.left,o?.top,!1))},[o?.left,o?.top,x]);const ce=c.useCallback((k,E)=>{C?.({left:k,top:E})},[]),L=c.useCallback(k=>{T.current?.doTouchStart(k.touches,k.timeStamp)},[]),I=c.useCallback(k=>{k.preventDefault(),T.current?.doTouchMove(k.touches,k.timeStamp)},[]),j=c.useCallback(k=>{T.current?.doTouchEnd(k.timeStamp)},[]),ie=c.useCallback(({containerWidth:k,containerHeight:E,totalWidth:f,totalHeight:Z})=>{T.current.setDimensions(k,E,f,Z)},[]);c.useEffect(()=>{const k=x??R.current;if(!p&&Ao().supportsTouchEvents&&k&&o){if(!T.current){const E={scrollingX:!0,scrollingY:!0,decelerationRate:.95,penetrationAcceleration:.08};T.current=new li(ce,E)}Ao().supportsTouchEvents&&(k.addEventListener("touchstart",L),k.addEventListener("touchend",j),k.addEventListener("touchmove",I)),ie({containerWidth:o?.width,containerHeight:o?.height,totalWidth:o?.totalWidth,totalHeight:o?.totalHeight})}return()=>{k?.removeEventListener("touchstart",L),k?.removeEventListener("touchend",j),k?.removeEventListener("touchmove",I)}},[o?.width,o?.height,o?.totalWidth,o?.totalHeight,p,x]);const[B,{width:ne}]=gn(),[ve,{height:U}]=gn(),N=c.useMemo(()=>{const k=d({orientation:cn.Vertical,offset:o?.top,viewportSize:o?.height,totalSize:o?.totalHeight,onScrollOffset:E=>{C?.({top:E})}});return O.jsx("div",{style:{display:"flex",flex:"0"},ref:B,children:k})},[d,o?.top,o?.height,o?.totalHeight]),Y=c.useMemo(()=>{const k=u({orientation:cn.Horizontal,offset:o?.left,viewportSize:o?.width,totalSize:o?.totalWidth,onScrollOffset:E=>C?.({left:E})});return O.jsxs("div",{style:{display:"flex",flex:"none",flexDirection:"row",alignItems:"stretch",justifyContent:"center"},children:[O.jsx("div",{style:{display:"flex",flex:"1 1 100%",flexDirection:"column",width:`calc(100% - ${ne}px)`},children:O.jsx("div",{ref:ve,className:"sizer",children:k})}),l?s({width:ne,height:U}):O.jsx(O.Fragment,{})]})},[u,o?.left,o?.width,o?.totalWidth,l,s,ne,U]);return O.jsx("div",{style:{position:"relative",display:"flex",minWidth:l?`${ne}px`:void 0,minHeight:i?`${U}px`:void 0,...w},...y,ref:R,children:O.jsxs("div",{style:{position:"relative",width:"100%",flex:"1 1 100%",display:"flex",flexDirection:"column",boxSizing:"border-box"},children:[O.jsxs("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:[O.jsx("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:n}),l?N:O.jsx(O.Fragment,{})]}),i?Y:O.jsx(O.Fragment,{})]})})}));hi.displayName="ScrollPane";const pl=()=>{const e=document.fullscreenElement;return e?e.querySelector(".fullscreen-portal-root")||e:document.body};let Kn=0;function fi(){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=di,onMouseDown:d,onScrollOffset:w,onScroll:x,scaleLimit:p=ml,scaleFactor:y=xl,precisionFactor:C=yl,...R}=e;x&&console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");const T=P(d,[d]),ce=()=>({offset:n,totalSize:p===0?r:Math.min(r??0,Math.max(i??0,(n??0)+(o??0))+(l??0))}),[L,I]=c.useState(ce),j=p!==0&&L.totalSize>p?y:1,ie=j/C,B=Math.ceil(L.totalSize/j),ne=Math.ceil(L.offset/j),ve=Math.ceil(o/j),U=c.useCallback(q=>{},[]),[N,Y]=c.useState(!1),k=c.useRef(null);c.useLayoutEffect(()=>{if(!N){k.current={propTotalSize:r,propViewportSize:o,propOffset:n};const q=ce();I(q)}},[r,o,n,N,i,l,s]);const E=P((q,z,K)=>{const Q=k.current;k.current=null,Q&&Q.propTotalSize===r&&Q.propViewportSize===o&&Q.propOffset===n||(Math.abs(q-ne)<ie&&(q=ne),w?.(q*j,ne,ve))},[w,j,ie,ne,ve]),f=c.useCallback(q=>{document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",f),Y(!1)},[]),Z=c.useCallback(q=>{T?.(q),Y(!0),document.addEventListener("mousemove",U,{passive:!0}),document.addEventListener("mouseup",f,{passive:!0})},[U,f]);return O.jsx(Uo,{ref:t,style:{...u},...R,offset:ne,totalSize:B,viewportSize:ve,onMouseDown:Z,onScrollOffset:E})}));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 O.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,L=0)=>{const I=ce/2,j=x-I+L;return function(ie,B,ne=!1){if(B===0)return ie;function ve(f,Z,q){let z=Z.x-f.x,K=Z.y-f.y,Q=Math.sqrt(z*z+K*K);return U(f,Z,Math.min(1,q/Q))}function U(f,Z,q){return{x:f.x+(Z.x-f.x)*q,y:f.y+(Z.y-f.y)*q}}function N(f,Z){f.length>2&&(f[f.length-2]=Z.x,f[f.length-1]=Z.y)}function Y(f){return{x:parseFloat(f[f.length-2]),y:parseFloat(f[f.length-1])}}let k=ie.split(/[,\s]/).reduce(function(f,Z){let q=Z.match("([a-zA-Z])(.+)");return q?(f.push(q[1]),f.push(q[2])):f.push(Z),f},[]).reduce(function(f,Z){return parseFloat(Z)==Z&&f.length?f[f.length-1].push(Z):f.push([Z]),f},[]),E=[];if(k.length>1){let f=Y(k[0]),Z=null;k[k.length-1][0]==="Z"&&k[0].length>2&&(Z=["L",f.x,f.y],k[k.length-1]=Z),E.push(k[0]);for(let q=1;q<k.length;q++){let z=E[E.length-1],K=k[q],Q=K===Z?k[1]:k[q+1];if(Q&&z&&z.length>2&&K[0]==="L"&&Q.length>2&&Q[0]==="L"){let ee,X,Ve=Y(z),Be=Y(K),We=Y(Q);ne?(ee=U(Be,z.origPoint||Ve,B),X=U(Be,Q.origPoint||We,B)):(ee=ve(Be,Ve,B),X=ve(Be,We,B)),N(K,ee),K.origPoint=Be,E.push(K);let it=U(ee,Be,.5),be=U(Be,X,.5),Ke=["C",it.x,it.y,be.x,be.y,X.x,X.y];Ke.origPoint=Be,E.push(Ke)}else E.push(K)}if(Z){let q=Y(E[E.length-1]);E.push(["Z"]),N(E[0],q)}}else E=k;return E.reduce(function(f,Z){return f+Z.join(" ")+" "},"")}(`M 0 ${I} L ${i-.5} ${I} L ${i-.5} ${j} L ${2*i} ${j} L ${w-2*i} ${j} M ${w-2*i} ${j} L ${w-i} ${j} L ${w-i} ${I} L ${w} ${I}`,i)},C=c.useMemo(()=>y(l),[w,x,i,l]),R=c.useMemo(()=>{if(i===0)return;const ce=i/2;return y(i)+`L ${w} 0 L 0 0 L 0 ${ce}`},[C,i,l]),T=c.useMemo(()=>({style:{clipPath:`path('${R}')`}}),[R]);return O.jsxs("div",{className:n,style:{display:"flex",flexDirection:"row",...o},...u,ref:oo([p,d,t]),children:[c.isValidElement(r)?c.cloneElement(r,T):O.jsx(O.Fragment,{}),O.jsx("svg",{style:{position:"absolute",top:0,left:0,pointerEvents:"none"},width:w,height:x,viewBox:`0 0 ${w} ${x}`,children:O.jsx("path",{d:C,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 O.jsx("div",{style:{...n,position:"relative"},...d,children:O.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=P(t,[t]),s=P(n,[n]),u=P(o,[o]),d=c.useRef(!1),w=e?.timerInitial??230,x=e?.timerContinuous??w/2,p=c.useRef(null),y=c.useRef(null),C=c.useRef(null),R=c.useRef(null),T=c.useCallback(()=>{R.current&&(clearTimeout(R.current),R.current=null)},[]),ce=c.useCallback(N=>{R.current=setTimeout(()=>{window.requestAnimationFrame(()=>{d.current!==!1&&u?.(y.current,C.current,p.current)}),ce(x)},N??w)},[]);c.useEffect(()=>()=>T(),[]);const L=r?"pointer":"mouse",I=c.useCallback(N=>{N.stopPropagation(),N.stopImmediatePropagation(),N.preventDefault()},[]),j=P(N=>{document.removeEventListener(`${L}move`,ne),document.removeEventListener(`${L}up`,j),document.removeEventListener("keydown",ve),document.removeEventListener("keyup",U),document.removeEventListener("touchstart",I,{capture:!0}),document.removeEventListener("touchmove",I,{capture:!0}),window.removeEventListener("blur",ie),T(),window.requestAnimationFrame(()=>{d.current!==!1&&(d.current=!1,s?.(N,C.current,p.current),C.current=null)})},[]),ie=c.useCallback(()=>{d.current!==!1&&(d.current=!1,j(y.current))},[]),B=P(()=>{T(),ce(x),window.requestAnimationFrame(()=>{d.current!==!1&&u?.(y.current,C.current,p.current)})},[x]),ne=P(N=>{y.current=N,B()},[]),ve=P(N=>{C.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},B()},[]),U=P(N=>{C.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},B()},[x]);return P(N=>{N.isDefaultPrevented()||(C.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},l(N,C.current)!==!1&&(p.current=N,y.current=N.nativeEvent,document.addEventListener(`${L}up`,j,{passive:!1}),document.addEventListener(`${L}move`,ne,{passive:!1}),document.addEventListener("keydown",ve,{passive:!1}),document.addEventListener("keyup",U,{passive:!1}),window.addEventListener("blur",ie,{passive:!0}),r&&i&&(document.addEventListener("touchstart",I,{passive:!1,capture:!0}),document.addEventListener("touchmove",I,{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:C,disabled:R=!1,onDragStart:T,onDragResize:ce,onDragFinish:L,resizerProps:I=qn,paneProps:j=qn,paneBeforeProps:ie=qn,paneAfterProps:B=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]),U=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=P(s,[s]),[Y,k]=c.useState(()=>ln(l,i===null));c.useEffect(()=>{k(ln(l,i===null))},[l,i]);const[E,{width:f,height:Z}]=gn(),[q,{width:z,height:K}]=gn(),Q=r==="row"?z:K,ee=r==="row"?f:Z,X=c.useMemo(()=>((J,Ze,He,ct)=>{const Ee=[null,null],Te=[null,null];if(J||(J={percent:ct.fixedPaneOffset===null?50:null,pixels:ct.fixedPaneOffset===null?null:0}),Ze===0)return J?.pixels!=null?ct.fixedPaneOffset!==1?(Ee[0]=J?.pixels,Te[1]=100):(Ee[1]=J?.pixels-He,Te[0]=100):J?.percent!=null&&(ct.fixedPaneOffset!==1?(Te[0]=J?.percent,Te[1]=100-J?.percent):(Te[1]=J?.percent,Te[0]=100-J?.percent)),{percents:Te,pixels:Ee,minBefore:Xn(ct.minBefore,!0),maxBefore:Xn(ct.maxBefore,!0),minAfter:Xn(ct.minAfter),maxAfter:Xn(ct.maxAfter)};let tt=hn(J,Ze,ct.fixedPaneOffset!==1),Je=Ze-He,Le=hn(ct.minBefore,Je,!0)??0,Gt=hn(ct.maxBefore,Je,!0)??Je,_t=0,Qe=0,Ct=0,Rt=Je;_t=(hn(ct.maxAfter,Ze,!1)??He)-He,Qe=hn(ct.minAfter,Ze,!1)??Ze,Ct=Math.max(Le,_t),Rt=Math.min(Gt,Qe),tt=Math.max(Ct,Math.min(tt,Rt)),Qe=Math.min(Je-tt,hn(ct.maxAfter,Je-tt,!0)??Je),_t=Math.min(Je-tt,hn(ct.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 Te[0]=on,Te[1]=100-Te[0],{percents:Te,pixels:Ee,minBefore:`${Le}px`,minAfter:`${_t}px`,maxBefore:`${Ee[0]}px`,maxAfter:`${Ee[1]}px`}})(Y,ee,Q,U),[U,Y,ee,Q,r]),[Ve,Be]=c.useState(!1),We=P(T,[T]),it=P(ce,[ce]),be=P(L,[L]),Ke=c.useRef(null),$=c.useRef(null),_=c.useRef(null),{style:Ce,className:ue,...we}=j,ze={minWidth:0,minHeight:0,maxWidth:"100%",maxHeight:"100%",display:"flex",overflow:"hidden",...Ce},{className:lt,style:It,...st}=ie,{className:Ut,style:xt,...M}=B,xe={flex:"1 1 100%",width:"100%",...C,flexDirection:r,display:"flex"},{className:Ye,style:ft,onPointerDown:Ge,...Qt}=I,Yt=P(J=>{const Ze=ln(J,i===null);k(Ze)},[i]),Et=P(J=>{if(R||!Ve)return;const Ze=Oe.current?.getBoundingClientRect();let He=0;He=r==="row"?(J.clientX??J.touches?.[0]?.clientX)-Ze.x:(J.clientY??J.touches?.[0]?.clientY)-Ze.y,He=Math.max(0,Math.min(ee,He)),U.fixedPaneOffset===1&&(He=ee-He),l&&Y.pixels===He||k({pixels:He,percent:null}),it?.(He),J.stopPropagation(),J.preventDefault()},[U,r,R,Ve,Y,ee]),tn=P(J=>{if(document.removeEventListener("pointermove",Et),document.removeEventListener("touchmove",Et),document.removeEventListener("pointerup",tn),Ve&&(Be(!1),Y)){if(be(Y.pixels),!ln(l,i===null)||Y.pixels!==l){const Ze={...Y};Ze.percent===null&&(Ze.percent=Ze.pixels/ee*100),N(Ze)}J.stopPropagation(),J.preventDefault()}},[Y,Ve,l,i,ee]),Xt=P(J=>{Ge?.(J),J.defaultPrevented||R||Ve||(Be(!0),We(),document.addEventListener("pointermove",Et,{passive:!1}),document.addEventListener("touchmove",Et,{passive:!1}),document.addEventListener("pointerup",tn,{passive:!1}))},[Ge]),Oe=lo(t,()=>({setPosition:Yt,isSplitPane:()=>!0}),[]),Ft=c.useMemo(()=>ve?ne?.({key:"resizer",ref:oo([q,$]),className:yn("resizer",Ye),onPointerDownCapture:Xt,style:{cursor:R?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,...ft},splitDirection:r,disabled:R,...Qt}):null,[ve,Ye,Qt,r,ft,R]),pt=r==="row"?"Width":"Height",jt={...ze,...It,flex:U.fixedPaneOffset===0&&X?.pixels[0]!==null?`0 0 ${Math.round(X?.pixels[0])}px`:`1 1 ${Math.round(X?.percents[0]??100)}%`,[`min${pt}`]:X?.minBefore,[`max${pt}`]:o?X?.maxBefore:"100%"},wn={...ze,...xt,flex:U.fixedPaneOffset===1&&X?.pixels[1]!==null?`0 0 ${Math.round(X?.pixels[1])}px`:`1 1 ${Math.round(X?.percents[1]??100)}%`,[`min${pt}`]:X?.minAfter,[`max${pt}`]:n?X?.maxAfter:"100%"},nn=c.useMemo(()=>n?O.jsx("div",{ref:Ke,className:yn("before",ue,lt),style:jt,...we,...st,children:n},"before"):null,[n,j,ie,U,X]),Fe=c.useMemo(()=>o?O.jsx("div",{ref:_,className:yn("after",ue,Ut),style:wn,...we,...M,children:o},"after"):null,[o,j,B,U,X]);return O.jsxs("div",{ref:oo([E,Oe]),className:yn("splitPane",r==="row"?"vertical":"horizontal",{dragging:Ve},y),style:xe,children:[nn,Ft,Fe]})}));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,pi=!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||(pi=!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]),O.jsx(O.Fragment,{children:t.map(({hook:r,key:i})=>c.createElement(El,{...r,key:i}))})},gi=(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 C=_l++;return Jn.push({hook:y,key:C}),bn.length===0&&pi===!1&&(Bo=!0,(R=>{if(Io.document&&Io.document.createElement){const T=Io.document.createElement("div");Pi.createRoot(T).render(O.jsx(R,{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(R=>R.key===C),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}};gi(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 Se extends Il{}St.getOS()===St.OSType.MacOS||(St.getOS(),St.OSType.IOS),St.getOS()===St.OSType.MacOS||(St.getOS(),St.OSType.IOS),gi({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?wi({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},wi=({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 wi({itemType:e,itemSize:t,instanceProps:o,high:Math.min(r,n-1),low:Math.floor(r/2),offset:i,scale:l})},mi=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=P(I=>Mr({itemType:"row",itemCount:t,itemSize:r??(()=>o??20),instanceProps:s.current,offset:I}),[t,r,o]),d=P(I=>I===-1?0:Sn({itemType:"row",index:I,itemSize:r??(()=>o??20),instanceProps:s.current}).offset,[r,o]),w=P(I=>Sn({itemType:"row",index:I,itemSize:r??(()=>o??20),instanceProps:s.current}).size,[r,o]),x=P(I=>Mr({itemType:"column",itemCount:n,itemSize:l??(()=>i??75),instanceProps:s.current,offset:I}),[n,l,i]),p=P(I=>I===-1?0:Sn({itemType:"column",index:I,itemSize:l??(()=>i??75),instanceProps:s.current}).offset,[l,i]),y=P(I=>Sn({itemType:"column",index:I,itemSize:l??(()=>i??75),instanceProps:s.current}).size,[l,i]),[C,R]=c.useReducer(I=>I+1,0),T=()=>({getRowOffset:d,getColOffset:p,getRowIndex:u,getColIndex:x}),[ce,L]=c.useState(()=>e?T():null);return c.useEffect(()=>{L(e?T():null)},[C,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=c.useRef(null),R=c.useRef(null),[T,ce]=c.useState(!1),L=t.coords,I=c.useCallback(async Y=>{if(C.current?.getBoundingClientRect()){if(Y.eventType==="keyboard"){const E=Y.event,f=new KeyboardEvent(E.type,{bubbles:!0,cancelable:!0,view:window,key:E.key,code:E.code,location:E.location,repeat:E.repeat,isComposing:E.isComposing,charCode:E.charCode,keyCode:E.keyCode,which:E.which,ctrlKey:E.ctrlKey,shiftKey:E.shiftKey,altKey:E.altKey,metaKey:E.metaKey});f.isSynthetic=!0,f.key,R.current?.dispatchEvent(f)}else Y.eventType==="pointer"||console.warn("unsupported event type",Y);await new Promise(E=>requestAnimationFrame(E))}},[]);c.useEffect(()=>{const Y=R.current;return ce(!0),R.current.startEdit?.(t.startEvent),(async()=>{t.editorRefs.push(Y),t.editorRefsDispatchEditorEvent.push(I);const k=[...t.events];for(let E=0;E<k.length;E++)await I(k[E]);t.onMount(Y)})(),()=>{const k=t.editorRefs.indexOf(Y);k!==-1&&t.editorRefs.splice(k,1),t.onUnmount(Y)}},[]);const j=c.useCallback(()=>o(t),[]),ie=c.useCallback(()=>{r(t)},[]),B=n.current&&G.isEqualCells(n.current,L),ne=l&&B&&T,ve=s({autoFocus:!!t.startEvent?.autoFocus,...u,onSubmitEdit:j,onCancelEdit:ie,ref:R},L),U=i.x+ge.boundPixel(-w/2),N=ge.boundPixel(i.width+w/2,!0);return O.jsx("div",{tabIndex:0,ref:C,style:{background:void 0,...p,opacity:ne?p?.opacity??1:0,pointerEvents:"auto",position:"absolute",boxSizing:"border-box",top:`${i.y+ge.boundPixel(-w/2)}px`,height:ge.boundPixel(i.height+w/2,!0),left:`${U}px`,width:N},...y,children:O.jsx("div",{className:"editor-container",style:{position:"absolute",boxSizing:"border-box",left:`${ge.boundPixel(1)}px`,top:`${ge.boundPixel(1)}px`,width:ge.boundPixel(i.width-2,!0),height:ge.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})})},Ue=(e,t,n)=>{if(!e)return t;let o=t;const r=n===Ne||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=Ue(n,Math.min(l+1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&l<i;)l=Ue(n,Math.min(++l,i),o),u=t({rowIndex:l,colIndex:s});return l}case nt:{l=Ue(n,Math.max(l-1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&l>i;)l=Ue(n,Math.max(--l,i),o),u=t({rowIndex:l,colIndex:s});return l}case Ne:{s=Ue(n,Math.min(s+1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&s<i;)s=Ue(n,Math.min(++s,i),o),u=t({rowIndex:l,colIndex:s});return s}case et:{s=Ue(n,Math.max(s-1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&s>i;)s=Ue(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=Ue(n,Math.min(l+1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&l<i;)l=Ue(n,Math.min(++l,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?l:l-1}case nt:{l=Ue(n,Math.max(l-1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&l>i;)l=Ue(n,Math.max(--l,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?l:l+1}case Ne:{s=Ue(n,Math.min(s+1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&s<i;)s=Ue(n,Math.min(++s,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?s:s-1}case et:{s=Ue(n,Math.max(s-1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&s>i;)s=Ue(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===Ne?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=Ne,n,o,r,i=null)=>{if(i&&G.isEqualSelectionCoords(i,e))return e;const l=e.ranges[e.rangeIndex];if(!G.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 Ne:s.colIndex=Ue(r,s.colIndex+1,t);break;case et:s.colIndex=Ue(r,s.colIndex-1,t);break;case ot:s.rowIndex=Ue(o,s.rowIndex+1,t);break;case nt:s.rowIndex=Ue(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===Ne&&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 Ne:y>l.colEnd&&(p=Ue(o,p+1,t),y=l.colStart,p>l.rowEnd&&(p=l.rowStart));break;case et:y<l.colStart&&(p=Ue(o,p-1,t),y=l.colEnd,p<l.rowStart&&(p=l.rowEnd));break;case ot:p>l.rowEnd&&(y=Ue(r,y+1,t),p=l.rowStart,y>l.colEnd&&(y=l.colStart));break;case nt:p<l.rowStart&&(y=Ue(r,y-1,t),p=l.rowEnd,y<l.colStart&&(y=l.colEnd))}s={rowIndex:p,colIndex:y}}let w=n(s);if(!G.isRangeWithinRange(w,l)){const p=G.intersectRanges(w,l);p&&(w=p)}let x={rowStart:Ue(o,w.rowStart,ot),colStart:Ue(r,w.colStart,Ne),rowEnd:Ue(o,w.rowEnd,nt),colEnd:Ue(r,w.colEnd,et)};if(x.rowStart!==s.rowIndex||x.colStart!==s.colIndex){switch(t){case Ne: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=Ne,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 ${ge.boundPixel(e.left)} ${ge.boundPixel(e.top)} L ${ge.boundPixel(e.right,!0)} ${ge.boundPixel(e.top)} L ${ge.boundPixel(e.right,!0)} ${ge.boundPixel(e.bottom,!0)} L ${ge.boundPixel(e.left)} ${ge.boundPixel(e.bottom,!0)} L ${ge.boundPixel(e.left)} ${ge.boundPixel(e.top)} ${t?"Z":""}`,Vo=e=>{const{linePoints:t,bounds:n,pathProps:o,style:r,...i}=e;return O.jsx("svg",{width:`${ge.boundPixel(n.width,!0)}`,height:`${ge.boundPixel(n.height,!0)}`,viewBox:`0 0 ${ge.boundPixel(n.width,!0)} ${ge.boundPixel(n.height,!0)}`,style:{position:"absolute",left:`${ge.boundPixel(n.x)}px`,top:`${ge.boundPixel(n.y)}px`,width:`${ge.boundPixel(n.width,!0)}px`,height:`${ge.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:O.jsx("path",{d:`M ${ge.boundPixel(t[0])} ${ge.boundPixel(t[1])} L ${ge.boundPixel(t[2])} ${ge.boundPixel(t[3])}`,fill:"none",vectorEffect:"non-scaling-stroke",stroke:"black",...o})})},xi=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,...C}=e,R=n,T=t,ce=o,L=r;let I=null;if(i){let j=Ro({top:0,left:0,bottom:L,right:ce});x&&(j=j+" "+Ro({top:x.y-R,left:x.x-T,bottom:x.height+x.y-R,right:x.width+x.x-T})),I=[O.jsx("path",{d:j,fill:i,stroke:"none",fillRule:"evenodd"},"fill")]}return O.jsxs("svg",{width:`${ge.boundPixel(o,!0)}`,height:`${ge.boundPixel(r,!0)}`,viewBox:`0 0 ${ge.boundPixel(o,!0)} ${ge.boundPixel(r,!0)}`,preserveAspectRatio:"none",style:{position:"absolute",left:`${ge.boundPixel(t)}px`,top:`${ge.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},...C,children:[I,O.jsx("path",{d:Ro({top:0,left:0,right:ce,bottom:L}),fill:"none",strokeDasharray:u,strokeDashoffset:d,stroke:l,vectorEffect:"non-scaling-stroke",strokeWidth:s,...p})]})},zr=e=>{const{key:t,...n}=e;return O.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,C={name:"walking-offset",dashGap:2,speed:50,dashLength:8,...d};let R=C.dashGap+C.dashLength;const T=C.speed*R,ce=kl().replaceAll(":",""),L=`${C.name}-${ce}`;let I;return c.useEffect(()=>{if(!y)return;const j=`@keyframes ${L} {
14
+ Please use Chrome or Edge if external copy and paste is required.`,Perms:vo,PermsWrite:zn()===zt.Safari?gr:vo,PermsRead:zn()===zt.Safari?gr:vo},So=async()=>new Promise(e=>{document.hasFocus()?e():globalThis.addEventListener?.("focus",()=>{e()},{once:!0}),document.activeElement.focus?.()}),Eo=async(e,t,n)=>{if(zn()===zt.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:[Dt]})}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=Dt)=>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=Dt)=>{const n=await Do(e,t);if(!n)return null;let o=null;try{o=new DOMParser().parseFromString(n,Dt)}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}"/>`,Ki=(e,t)=>{let n=null;try{const o=new DOMParser().parseFromString(t,Dt);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,Dt);return!this._state||(xr(this._state.uuid,t)||this.clear(),!0)},async e=>{e?.message==="denied"||e.message?.includes("Document is not focused")||zn()===zt.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,Dt);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({[Dt]:new Blob([mr(o)],{type:Dt})})));for(let l=0;l<Math.min(1,r.length);l++){const s=r[l];let u=s.types.indexOf(Dt),d=null;if(u!==-1){const h=await s.getType(Dt);d=await Lo(h),d&&(d=Ki(o,d))}if(!d&&s.types.includes(rn)){const h=await s.getType(rn);if(h){let y=null;typeof h=="string"?(console.warn("text as string",h),y=h):y=await Lo(h),y&&(d=`<div ${jn}="${o}">${y}</div>`)}}if(!d&&s.types.includes(xo)){const h=await s.getType(xo),y=qr(await h.arrayBuffer());d=`<div ${jn}="${o}"><img src="${Xr+y}"/></div>`}!d&&o&&(d=mr(o));const p=new Blob([d??""],{type:Dt}),x={};for(let h=0;h<s.types.length;h++){const y=s.types[h];x[y]=h===u?p:s.getType(y)}d&&u===-1&&(x[Dt]=p),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[Dt]=new Blob([r],{type:Dt}))}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)}}();const On={Left:"left",Right:"right",Center:"center"},vt="shift",dn="alt",Pt="ctrl",Jr=9,Qr=13,qi=27,ei=37,ti=38,ni=39,oi=40,Xi=113,yr=3,cn={Horizontal:"horizontal",Vertical:"vertical"};function ri(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=ri(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=ri(e))&&(o&&(o+=" "),o+=t);return o}var Yi=function(){},ii=typeof window<"u",Gi=ii?c.useLayoutEffect:c.useEffect,br={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const gn=ii&&window.ResizeObserver!==void 0?function(){var e=c.useState(null),t=e[0],n=e[1],o=c.useState(br),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,p=u.y,x=u.width,h=u.height,y=u.top,R=u.left,C=u.bottom,L=u.right;i({x:d,y:p,width:x,height:h,top:y,left:R,bottom:C,right:L})}})},[]);return Gi(function(){if(t)return l.observe(t),function(){l.disconnect()}},[t]),[n,r]}:function(){return[Yi,br]},T=(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},Zi=e=>{const{style:t,orientation:n=cn.Vertical,...o}=e,r=n===cn.Vertical;return P.jsx("div",{style:{paddingBottom:"0px",paddingRight:"0px",paddingLeft:r?"0px":"3px",paddingTop:r?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...t},...o,children:P.jsx("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${r?"vertical":"horizontal"} single-button start`,children:P.jsx("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:P.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"})})})})},Ji=e=>{const{style:t,orientation:n=cn.Vertical,...o}=e,r=n===cn.Vertical;return P.jsx("div",{style:{paddingLeft:"0px",paddingTop:"0px",paddingRight:r?"0px":"3px",paddingBottom:r?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...t},...o,children:P.jsx("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${r?"vertical":"horizontal"} single-button end`,children:P.jsx("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:P.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:p=!1,scrollButtonIncrement:x=200,scrollButtonInitialRepeatDelay:h=260,scrollButtonAdditionalRepeatDelay:y=120,createScrollStartButton:R=Zi,createScrollEndButton:C=Ji,...L}=e,J=T(d,[d]),O=c.useRef(null),[I,{width:j,height:le}]=gn(),[B,{width:oe,height:be}]=gn(),U=s===cn.Vertical,N=U?"top":"left",Y=U?"scrollTop":"scrollLeft",k=U?le:j,E=U?be:oe,[g,Z]=c.useState(null);c.useEffect(()=>{g!==null&&O.current&&O.current.scrollTo({behavior:"smooth",[N]:g})},[g,U]);const q=c.useCallback((Ke,$=!1)=>{if(!O.current)return 0;const _=O.current.querySelector(".scrollbar-viewport"),Ce=_.getBoundingClientRect(),ue=_.children,we=$?0:zo(Ke,Ce[N],ue,!0,Math.max(0,Ke-x));return Z(we),Math.max(0,we)},[]),z=c.useCallback((Ke,$=!1)=>{if(!O.current)return 0;const _=O.current.querySelector(".scrollbar-viewport"),Ce=_.getBoundingClientRect(),ue=_.children,we=Math.ceil(E-k),ze=$?we:zo(Ke,Ce[N],ue,!1,Math.max(0,Ke+x));return Z(ze),Math.min(we,ze)},[E,k]),K=c.useRef(null),ee=c.useCallback(Ke=>{K.current=n;const $=Ke.target[Y];u($,r,o),J?.(Ke)},[u,r,o,n]);c.useEffect(()=>{const Ke=K.current;K.current=null,n!==Ke&&(O.current[Y]=n)},[n,Y]);const te=c.useRef(null),X=c.useRef(null),Ve=c.useCallback(()=>{te.current&&(clearTimeout(te.current),te.current=null,X.current=null)},[]),Be=c.useCallback((Ke,$,_,Ce=h)=>{X.current=Ke,te.current=setTimeout(()=>{const ue=_?q(X.current||Ke):z(X.current||Ke);ue!==X.current?Be(ue,!1,_,y):Ve()},$?0:Ce)},[q,z,Ve]);c.useEffect(()=>()=>Ve(),[Ve]);const We=n,it=c.useMemo(()=>{if(!p)return null;const Ke={orientation:s,disabled:Math.floor(We)<=0||Math.floor(E-k)===0,onMouseUp:Ve,onMouseLeave:Ve,onMouseDown:()=>Be(We,!0,!0)};return R?.(Ke)},[p,s,We,g,E,k]),ve=c.useMemo(()=>{if(!p)return null;const Ke={orientation:s,disabled:Math.floor(E-k)<=Math.ceil(We),onMouseUp:Ve,onMouseLeave:Ve,onMouseDown:()=>Be(We,!0,!1)};return C?.(Ke)},[p,s,We,g,E,k]);return P.jsxs("div",{ref:t,style:{display:"flex",flex:"1",flexDirection:U?"column":"row",padding:"0",...i},className:yn("_sheetxl-scrollbar_eblx4_6",l),...L,children:[it,P.jsx("div",{className:"pseudo-scrollbar",style:{flex:"1 1 100%",display:"flex",boxSizing:"content-box",flexDirection:U?"column":"row",justifyContent:"center",alignItems:"center"},ref:I,children:P.jsx("div",{tabIndex:-1,style:{flex:"1 1 100%",overflowY:U?"scroll":"hidden",overflowX:U?"hidden":"scroll",position:"relative",willChange:"transform"},onScroll:ee,ref:O,children:P.jsx("div",{ref:B,style:{position:"absolute",height:U?o-r+(le??0):1,width:U?1:o-r+(j??0)},className:"scrollbar-viewport"})})}),ve]})}));Uo.displayName="Scrollbar";let vr=Date.now,sn={},Qi=1;const Tn=e=>{let t=sn[e]!==null;return t&&(sn[e]=null),t},Sr=(e,t,n,o=0,r)=>{let i=vr(),l=i,s=0,u=0,d=0,p=Qi++;if(p%20==0){const h={};for(let y in sn)h[y]=!0;sn=h}const x=function(h){let y=h!==!0,R=vr(),C=!0;try{C=(!t||t(p))??!0}catch{C=!1}if(!sn[p]||!C)return sn[p]=null,void n?.(60-u/((R-i)/1e3),p,!1);if(y){d=Math.round((R-l)/16.666666666666668)-1;for(let O=0;O<Math.min(d,4);O++)x(!0),u++}o&&(s=(R-i)/o,s>1&&(s=1));let L=r?r(s):s,J=!1;try{J=e(L,R,y)}catch{J=!1}J!==!1&&s!==1||!y?y&&(l=R,requestAnimationFrame(x)):(sn[p]=null,n?.(60-u/((R-i)/1e3),p,s===1||o==null))};return sn[p]=!0,requestAnimationFrame(x),p},el=function(e){return Math.pow(e-1,3)+1},tl=function(e){return(e/=.5)<1?.5*Math.pow(e,3):.5*(Math.pow(e-2,3)+2)};class nl{constructor(t,n){this.__isSingleTouch=!1,this.__isTracking=!1,this.__didDecelerationComplete=!1,this.__isGesturing=!1,this.__isDragging=!1,this.__isDecelerating=0,this.__isAnimating=0,this.__interruptedAnimation=!1,this.__lastScale=1,this.__enableScrollX=!0,this.__enableScrollY=!0,this.__clientLeft=0,this.__clientTop=0,this.__clientWidth=0,this.__clientHeight=0,this.__contentWidth=0,this.__contentHeight=0,this.__snapWidth=100,this.__snapHeight=100,this.__zoomLevel=1,this.__scrollLeft=0,this.__scrollTop=0,this.__maxScrollLeft=0,this.__maxScrollTop=0,this.__scheduledLeft=0,this.__scheduledTop=0,this.__scheduledZoom=0,this.__lastTouchLeft=0,this.__lastTouchTop=0,this.__lastTouchMove=0,this.__positions=[],this.__initialTouchLeft=0,this.__initialTouchTop=0,this.__zoomLevelStart=1,this.__minDecelerationScrollLeft=null,this.__minDecelerationScrollTop=null,this.__maxDecelerationScrollLeft=null,this.__maxDecelerationScrollTop=null,this.__decelerationVelocityX=null,this.__decelerationVelocityY=0,this.__callback=t,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:void 0,penetrationDeceleration:.03,penetrationAcceleration:.08,...n}}setDimensions(t,n,o,r){t!==null&&(this.__clientWidth=t),n!==null&&(this.__clientHeight=n),o!==null&&(this.__contentWidth=o),r!==null&&(this.__contentHeight=r),this.__computeScrollMax(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0)}setPosition(t,n){this.__clientLeft=t||0,this.__clientTop=n||0}setSnapSize(t,n){this.__snapWidth=t,this.__snapHeight=n}getValues(){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(t,n){const o=this.getValues();return{left:t/o.zoom,top:n/o.zoom}}getScrollMax(){return{left:this.__maxScrollLeft,top:this.__maxScrollTop}}zoomTo(t,n=!1,o,r,i){if(!this.options.zooming)throw new Error("Zooming is not enabled!");i&&(this.__zoomComplete=i),this.__isDecelerating&&(Tn(this.__isDecelerating),this.__isDecelerating=0);const l=this.__zoomLevel;o===void 0&&(o=this.__clientWidth/2),r===void 0&&(r=this.__clientHeight/2),t=Math.max(Math.min(t,this.options.maxZoom),this.options.minZoom),this.__computeScrollMax(t);const s=t/l;let u=s*(this.__scrollLeft+o)-o,d=s*(this.__scrollTop+r)-r;u>this.__maxScrollLeft?u=this.__maxScrollLeft:u<0&&(u=0),d>this.__maxScrollTop?d=this.__maxScrollTop:d<0&&(d=0),this.__publish(u,d,t,n)}zoomBy(t,n=!1,o=0,r=0,i){this.zoomTo(this.__zoomLevel*t,n,o,r,i)}scrollTo(t,n,o=!1,r=1){if(this.__isDecelerating&&(Tn(this.__isDecelerating),this.__isDecelerating=0),r!==void 0&&r!==this.__zoomLevel){if(!this.options.zooming)throw new Error("Zooming is not enabled!");t*=r,n*=r,this.__computeScrollMax(r)}else r=this.__zoomLevel;this.options.scrollingX?this.options.paging?t=Math.round(t/this.__clientWidth)*this.__clientWidth:this.options.snapping&&(t=Math.round(t/this.__snapWidth)*this.__snapWidth):t=this.__scrollLeft,this.options.scrollingY?this.options.paging?n=Math.round(n/this.__clientHeight)*this.__clientHeight:this.options.snapping&&(n=Math.round(n/this.__snapHeight)*this.__snapHeight):n=this.__scrollTop,t=Math.max(Math.min(this.__maxScrollLeft,t),0),n=Math.max(Math.min(this.__maxScrollTop,n),0),t===this.__scrollLeft&&n===this.__scrollTop&&(o=!1),this.__publish(t,n,r,o)}scrollBy(t=0,n=0,o=!1){const r=this.__isAnimating?this.__scheduledLeft:this.__scrollLeft,i=this.__isAnimating?this.__scheduledTop:this.__scrollTop;this.scrollTo(r+(t||0),i+(n||0),o)}doMouseZoom(t,n,o,r){const i=t>0?.97:1.03;return this.zoomTo(this.__zoomLevel*i,!1,o-this.__clientLeft,r-this.__clientTop)}doTouchStart(t,n){if(t.length===void 0)throw new Error("Invalid touch list: "+t);if(n instanceof Date&&(n=n.valueOf()),typeof n!="number")throw new Error("Invalid timestamp value: "+n);let o,r;this.__interruptedAnimation=!0,this.__isDecelerating&&(Tn(this.__isDecelerating),this.__isDecelerating=0,this.__interruptedAnimation=!0),this.__isAnimating&&(Tn(this.__isAnimating),this.__isAnimating=0,this.__interruptedAnimation=!0);let i=t.length===1;i?(o=t[0].pageX,r=t[0].pageY):(o=Math.abs(t[0].pageX+t[1].pageX)/2,r=Math.abs(t[0].pageY+t[1].pageY)/2),this.__initialTouchLeft=o,this.__initialTouchTop=r,this.__zoomLevelStart=this.__zoomLevel,this.__lastTouchLeft=o,this.__lastTouchTop=r,this.__lastTouchMove=n,this.__lastScale=1,this.__enableScrollX=!i&&this.options.scrollingX,this.__enableScrollY=!i&&this.options.scrollingY,this.__isTracking=!0,this.__didDecelerationComplete=!1,this.__isDragging=!i,this.__isSingleTouch=i,this.__positions=[]}doTouchMove(t,n,o=1){if(t.length===void 0)throw new Error("Invalid touch list: "+t);if(n instanceof Date&&(n=n.valueOf()),typeof n!="number")throw new Error("Invalid timestamp value: "+n);if(!this.__isTracking)return;let r,i;t.length===2?(r=Math.abs(t[0].pageX+t[1].pageX)/2,i=Math.abs(t[0].pageY+t[1].pageY)/2):(r=t[0].pageX,i=t[0].pageY);let l=this.__positions;if(this.__isDragging){let s=r-this.__lastTouchLeft,u=i-this.__lastTouchTop,d=this.__scrollLeft,p=this.__scrollTop,x=this.__zoomLevel;if(o!==void 0&&this.options.zooming){let h=x;if(x=x/this.__lastScale*o,x=Math.max(Math.min(x,this.options.maxZoom),this.options.minZoom),h!==x){let y=r-this.__clientLeft,R=i-this.__clientTop;d=(y+d)*x/h-y,p=(R+p)*x/h-R,this.__computeScrollMax(x)}}if(this.__enableScrollX){d-=s*this.options.speedMultiplier;let h=this.__maxScrollLeft;(d>h||d<0)&&(this.options.bouncing?d+=s/2*this.options.speedMultiplier:d=d>h?h:0)}if(this.__enableScrollY){p-=u*this.options.speedMultiplier;const h=this.__maxScrollTop;(p>h||p<0)&&(this.options.bouncing?p+=u/2*this.options.speedMultiplier:p=p>h?h:0)}l.length>60&&l.splice(0,30),l.push(d,p,n),this.__publish(d,p,x)}else{let s=this.options.locking?3:0,u=5,d=Math.abs(r-this.__initialTouchLeft),p=Math.abs(i-this.__initialTouchTop);this.__enableScrollX=this.options.scrollingX&&d>=s,this.__enableScrollY=this.options.scrollingY&&p>=s,l.push(this.__scrollLeft,this.__scrollTop,n),this.__isDragging=(this.__enableScrollX||this.__enableScrollY)&&(d>=u||p>=u),this.__isDragging&&(this.__interruptedAnimation=!1)}this.__lastTouchLeft=r,this.__lastTouchTop=i,this.__lastTouchMove=n,this.__lastScale=o}doTouchEnd(t){if(t instanceof Date&&(t=t.valueOf()),typeof t!="number")throw new Error("Invalid timestamp value: "+t);if(this.__isTracking){if(this.__isTracking=!1,this.__isDragging)if(this.__isDragging=!1,this.__isSingleTouch&&this.options.animating&&t-this.__lastTouchMove<=100){let n=this.__positions,o=n.length-1,r=o;for(let i=o;i>0&&n[i]>this.__lastTouchMove-100;i-=3)r=i;if(r!==o){const i=n[o]-n[r],l=this.__scrollLeft-n[r-2],s=this.__scrollTop-n[r-1];this.__decelerationVelocityX=l/i*(1e3/60),this.__decelerationVelocityY=s/i*(1e3/60);const u=this.options.paging||this.options.snapping?4:1;(Math.abs(this.__decelerationVelocityX)>u||Math.abs(this.__decelerationVelocityY)>u)&&this.__startDeceleration(t)}else this.options.scrollingComplete?.()}else t-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(t,n,o,r=!1){const i=this.__isAnimating;if(i&&(Tn(i),this.__isAnimating=0),r&&this.options.animating){this.__scheduledLeft=t,this.__scheduledTop=n,this.__scheduledZoom=o;const l=this.__scrollLeft,s=this.__scrollTop,u=this.__zoomLevel,d=t-l,p=n-s,x=o-u,h=function(C,L,J){J&&(this.__scrollLeft=l+d*C,this.__scrollTop=s+p*C,this.__zoomLevel=u+x*C,this.__callback&&this.__callback(this.__scrollLeft,this.__scrollTop,this.__zoomLevel))}.bind(this),y=function(C){return this.__isAnimating===C}.bind(this),R=function(C,L,J){L===this.__isAnimating&&(this.__isAnimating=!1),(this.__didDecelerationComplete||J)&&this.options.scrollingComplete?.(),this.options.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))}.bind(this);this.__isAnimating=Sr(h,y,R,this.options.animationDuration,i?el:tl)}else this.__scheduledLeft=this.__scrollLeft=t,this.__scheduledTop=this.__scrollTop=n,this.__scheduledZoom=this.__zoomLevel=o,this.__callback&&this.__callback(t,n,o),this.options.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))}__computeScrollMax(t=this.__zoomLevel){this.__maxScrollLeft=Math.max(this.__contentWidth*t-this.__clientWidth,0),this.__maxScrollTop=Math.max(this.__contentHeight*t-this.__clientHeight,0)}__startDeceleration(t){if(this.options.paging){const l=Math.max(Math.min(this.__scrollLeft,this.__maxScrollLeft),0),s=Math.max(Math.min(this.__scrollTop,this.__maxScrollTop),0),u=this.__clientWidth,d=this.__clientHeight;this.__minDecelerationScrollLeft=Math.floor(l/u)*u,this.__minDecelerationScrollTop=Math.floor(s/d)*d,this.__maxDecelerationScrollLeft=Math.ceil(l/u)*u,this.__maxDecelerationScrollTop=Math.ceil(s/d)*d}else this.__minDecelerationScrollLeft=0,this.__minDecelerationScrollTop=0,this.__maxDecelerationScrollLeft=this.__maxScrollLeft,this.__maxDecelerationScrollTop=this.__maxScrollTop;const n=function(l,s,u){this.__stepThroughDeceleration(u)}.bind(this),o=this.options.snapping?4:.1,r=function(){const l=Math.abs(this.__decelerationVelocityX)>=o||Math.abs(this.__decelerationVelocityY)>=o;return l||(this.__didDecelerationComplete=!0),l}.bind(this),i=function(l,s,u){this.__isDecelerating=0,this.__didDecelerationComplete&&this.options.scrollingComplete?.(),this.scrollTo(this.__scrollLeft,this.__scrollTop,this.options.snapping)}.bind(this);this.__isDecelerating=Sr(n,r,i)}__stepThroughDeceleration(t){let n=this.__scrollLeft+this.__decelerationVelocityX,o=this.__scrollTop+this.__decelerationVelocityY;if(!this.options.bouncing){const r=Math.max(Math.min(this.__maxDecelerationScrollLeft,n),this.__minDecelerationScrollLeft);r!==n&&(n=r,this.__decelerationVelocityX=0);const i=Math.max(Math.min(this.__maxDecelerationScrollTop,o),this.__minDecelerationScrollTop);i!==o&&(o=i,this.__decelerationVelocityY=0)}if(t?this.__publish(n,o,this.__zoomLevel):(this.__scrollLeft=n,this.__scrollTop=o),!this.options.paging&&(this.__decelerationVelocityX*=.95,this.__decelerationVelocityY*=.95),this.options.bouncing){let r=0,i=0,l=this.options.penetrationDeceleration,s=this.options.penetrationAcceleration;n<this.__minDecelerationScrollLeft?r=this.__minDecelerationScrollLeft-n:n>this.__maxDecelerationScrollLeft&&(r=this.__maxDecelerationScrollLeft-n),o<this.__minDecelerationScrollTop?i=this.__minDecelerationScrollTop-o:o>this.__maxDecelerationScrollTop&&(i=this.__maxDecelerationScrollTop-o),r!==0&&(r*this.__decelerationVelocityX<=0?this.__decelerationVelocityX+=r*l:this.__decelerationVelocityX=r*s),i!==0&&(i*this.__decelerationVelocityY<=0?this.__decelerationVelocityY+=i*l:this.__decelerationVelocityY=i*s)}}}var Nt=typeof window<"u"?window:{screen:{},navigator:{}},En=(Nt.matchMedia||function(){return{matches:!1}}).bind(Nt),li=!1,ol={get passive(){return li=!0}},Er=function(){};Nt.addEventListener&&Nt.addEventListener("p",Er,ol),Nt.removeEventListener&&Nt.removeEventListener("p",Er,!1);var rl=li,il="PointerEvent"in Nt,Ko="ontouchstart"in Nt,si=Ko||"TouchEvent"in Nt&&En("(any-pointer: coarse)").matches,_r=(Nt.navigator.maxTouchPoints||0)>0||si,ci=Nt.navigator.userAgent||"",ll=En("(pointer: coarse)").matches&&/iPad|Macintosh/.test(ci)&&Math.min(Nt.screen.width||0,Nt.screen.height||0)>=768,ai=(En("(pointer: coarse)").matches||!En("(pointer: fine)").matches&&Ko)&&!/Windows.*Firefox/.test(ci),sl=En("(any-pointer: fine)").matches||En("(any-hover: hover)").matches||ll||!Ko,jo=!_r||!sl&&ai?_r?"touchOnly":"mouseOnly":"hybrid",cl=jo==="mouseOnly"?"mouse":jo==="touchOnly"||ai?"touch":"mouse";const al=Object.freeze(Object.defineProperty({__proto__:null,deviceType:jo,primaryInput:cl,supportsPassiveEvents:rl,supportsPointerEvents:il,supportsTouchEvents:si},Symbol.toStringTag,{value:"Module"})),ul=new Set(["INPUT","TEXTAREA","SELECT"]),ui={};function Ao(){return al}const ge=Object.freeze(Object.defineProperty({__proto__:null,EmptyCssProperties:ui,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:ul,toPrettyKeyCode:e=>e==="BracketLeft"?"[":e==="BracketRight"?"]":St.camelToPrettyCase(e)},Symbol.toStringTag,{value:"Module"})),dl=[];function lo(e,t,n=dl){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],p=i[d];Object.defineProperty(r,d,{value:p,writable:!0,configurable:!0,enumerable:!0})}return r},n),o}const Cr=e=>P.jsx(Uo,{...e}),hl=({width:e,height:t})=>P.jsx("div",{className:"corner",style:{minWidth:`${e}px`,width:`${e}px`,minHeight:`${t}px`,height:`${t}px`}}),di=c.memo(c.forwardRef((e,t)=>{const{children:n,viewport:o,onScrollViewport:r,showHorizontalScrollbar:i=!0,showVerticalScrollbar:l=!0,createScrollCorner:s=hl,createHorizontalScrollbar:u=Cr,createVerticalScrollbar:d=Cr,style:p,touchElement:x,disableTouch:h,...y}=e,R=T(r,[r]),C=lo(t,()=>({isScrollPane:()=>!0}),[]),L=c.useRef(null);c.useEffect(()=>{L.current&&(L.current.__scrollTop===o?.top&&L.current.__scrollLeft===o?.left||L.current.__isDecelerating||L.current?.scrollTo(o?.left,o?.top,!1))},[o?.left,o?.top,x]);const J=c.useCallback((k,E)=>{R?.({left:k,top:E})},[]),O=c.useCallback(k=>{L.current?.doTouchStart(k.touches,k.timeStamp)},[]),I=c.useCallback(k=>{k.preventDefault(),L.current?.doTouchMove(k.touches,k.timeStamp)},[]),j=c.useCallback(k=>{L.current?.doTouchEnd(k.timeStamp)},[]),le=c.useCallback(({containerWidth:k,containerHeight:E,totalWidth:g,totalHeight:Z})=>{L.current.setDimensions(k,E,g,Z)},[]);c.useEffect(()=>{const k=x??C.current;if(!h&&Ao().supportsTouchEvents&&k&&o){if(!L.current){const E={scrollingX:!0,scrollingY:!0,decelerationRate:.95,penetrationAcceleration:.08};L.current=new nl(J,E)}Ao().supportsTouchEvents&&(k.addEventListener("touchstart",O),k.addEventListener("touchend",j),k.addEventListener("touchmove",I)),le({containerWidth:o?.width,containerHeight:o?.height,totalWidth:o?.totalWidth,totalHeight:o?.totalHeight})}return()=>{k?.removeEventListener("touchstart",O),k?.removeEventListener("touchend",j),k?.removeEventListener("touchmove",I)}},[o?.width,o?.height,o?.totalWidth,o?.totalHeight,h,x]);const[B,{width:oe}]=gn(),[be,{height:U}]=gn(),N=c.useMemo(()=>{const k=d({orientation:cn.Vertical,offset:o?.top,viewportSize:o?.height,totalSize:o?.totalHeight,onScrollOffset:E=>{R?.({top:E})}});return P.jsx("div",{style:{display:"flex",flex:"0"},ref:B,children:k})},[d,o?.top,o?.height,o?.totalHeight]),Y=c.useMemo(()=>{const k=u({orientation:cn.Horizontal,offset:o?.left,viewportSize:o?.width,totalSize:o?.totalWidth,onScrollOffset:E=>R?.({left:E})});return P.jsxs("div",{style:{display:"flex",flex:"none",flexDirection:"row",alignItems:"stretch",justifyContent:"center"},children:[P.jsx("div",{style:{display:"flex",flex:"1 1 100%",flexDirection:"column",width:`calc(100% - ${oe}px)`},children:P.jsx("div",{ref:be,className:"sizer",children:k})}),l?s({width:oe,height:U}):P.jsx(P.Fragment,{})]})},[u,o?.left,o?.width,o?.totalWidth,l,s,oe,U]);return P.jsx("div",{style:{position:"relative",display:"flex",minWidth:l?`${oe}px`:void 0,minHeight:i?`${U}px`:void 0,...p},...y,ref:C,children:P.jsxs("div",{style:{position:"relative",width:"100%",flex:"1 1 100%",display:"flex",flexDirection:"column",boxSizing:"border-box"},children:[P.jsxs("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:[P.jsx("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:n}),l?N:P.jsx(P.Fragment,{})]}),i?Y:P.jsx(P.Fragment,{})]})})}));di.displayName="ScrollPane";const fl=()=>{const e=document.fullscreenElement;return e?e.querySelector(".fullscreen-portal-root")||e:document.body};let Kn=0;function hi(){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:fl}}const pl=100,gl=100,wl=1e6,ml=100,xl=50,yl=c.memo(c.forwardRef((e,t)=>{const{offset:n=0,viewportSize:o=0,totalSize:r=0,minSize:i=0,endGap:l=pl,endScrollIncrement:s=gl,style:u=ui,onMouseDown:d,onScrollOffset:p,onScroll:x,scaleLimit:h=wl,scaleFactor:y=ml,precisionFactor:R=xl,...C}=e;x&&console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");const L=T(d,[d]),J=()=>({offset:n,totalSize:h===0?r:Math.min(r??0,Math.max(i??0,(n??0)+(o??0))+(l??0))}),[O,I]=c.useState(J),j=h!==0&&O.totalSize>h?y:1,le=j/R,B=Math.ceil(O.totalSize/j),oe=Math.ceil(O.offset/j),be=Math.ceil(o/j),U=c.useCallback(q=>{},[]),[N,Y]=c.useState(!1),k=c.useRef(null);c.useLayoutEffect(()=>{if(!N){k.current={propTotalSize:r,propViewportSize:o,propOffset:n};const q=J();I(q)}},[r,o,n,N,i,l,s]);const E=T((q,z,K)=>{const ee=k.current;k.current=null,ee&&ee.propTotalSize===r&&ee.propViewportSize===o&&ee.propOffset===n||(Math.abs(q-oe)<le&&(q=oe),p?.(q*j,oe,be))},[p,j,le,oe,be]),g=c.useCallback(q=>{document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",g),Y(!1)},[]),Z=c.useCallback(q=>{L?.(q),Y(!0),document.addEventListener("mousemove",U,{passive:!0}),document.addEventListener("mouseup",g,{passive:!0})},[U,g]);return P.jsx(Uo,{ref:t,style:{...u},...C,offset:oe,totalSize:B,viewportSize:be,onMouseDown:Z,onScrollOffset:E})}));function Co(e,t){if(typeof e=="function")return e(t);e&&(e.current=t)}yl.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 p=l[u];p.focus&&s.push({tabindex:parseInt(d),child:p})}s.length!==0&&(s.sort(function(u,d){return u.tabindex-d.tabindex}),s[0].child.focus())},[n]);return P.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:p,height:x}]=gn(),h=c.useRef(null),y=(J,O=0)=>{const I=J/2,j=x-I+O;return function(le,B,oe=!1){if(B===0)return le;function be(g,Z,q){let z=Z.x-g.x,K=Z.y-g.y,ee=Math.sqrt(z*z+K*K);return U(g,Z,Math.min(1,q/ee))}function U(g,Z,q){return{x:g.x+(Z.x-g.x)*q,y:g.y+(Z.y-g.y)*q}}function N(g,Z){g.length>2&&(g[g.length-2]=Z.x,g[g.length-1]=Z.y)}function Y(g){return{x:parseFloat(g[g.length-2]),y:parseFloat(g[g.length-1])}}let k=le.split(/[,\s]/).reduce(function(g,Z){let q=Z.match("([a-zA-Z])(.+)");return q?(g.push(q[1]),g.push(q[2])):g.push(Z),g},[]).reduce(function(g,Z){return parseFloat(Z)==Z&&g.length?g[g.length-1].push(Z):g.push([Z]),g},[]),E=[];if(k.length>1){let g=Y(k[0]),Z=null;k[k.length-1][0]==="Z"&&k[0].length>2&&(Z=["L",g.x,g.y],k[k.length-1]=Z),E.push(k[0]);for(let q=1;q<k.length;q++){let z=E[E.length-1],K=k[q],ee=K===Z?k[1]:k[q+1];if(ee&&z&&z.length>2&&K[0]==="L"&&ee.length>2&&ee[0]==="L"){let te,X,Ve=Y(z),Be=Y(K),We=Y(ee);oe?(te=U(Be,z.origPoint||Ve,B),X=U(Be,ee.origPoint||We,B)):(te=be(Be,Ve,B),X=be(Be,We,B)),N(K,te),K.origPoint=Be,E.push(K);let it=U(te,Be,.5),ve=U(Be,X,.5),Ke=["C",it.x,it.y,ve.x,ve.y,X.x,X.y];Ke.origPoint=Be,E.push(Ke)}else E.push(K)}if(Z){let q=Y(E[E.length-1]);E.push(["Z"]),N(E[0],q)}}else E=k;return E.reduce(function(g,Z){return g+Z.join(" ")+" "},"")}(`M 0 ${I} L ${i-.5} ${I} L ${i-.5} ${j} L ${2*i} ${j} L ${p-2*i} ${j} M ${p-2*i} ${j} L ${p-i} ${j} L ${p-i} ${I} L ${p} ${I}`,i)},R=c.useMemo(()=>y(l),[p,x,i,l]),C=c.useMemo(()=>{if(i===0)return;const J=i/2;return y(i)+`L ${p} 0 L 0 0 L 0 ${J}`},[R,i,l]),L=c.useMemo(()=>({style:{clipPath:`path('${C}')`}}),[C]);return P.jsxs("div",{className:n,style:{display:"flex",flexDirection:"row",...o},...u,ref:oo([h,d,t]),children:[c.isValidElement(r)?c.cloneElement(r,L):P.jsx(P.Fragment,{}),P.jsx("svg",{style:{position:"absolute",top:0,left:0,pointerEvents:"none"},width:p,height:x,viewBox:`0 0 ${p} ${x}`,children:P.jsx("path",{d:R,stroke:s,fill:"none",vectorEffect:"non-scaling-stroke",strokeWidth:l})})]})}));const bl={},vl=e=>{const{onPointerDown:t,style:n,splitDirection:o,paddingBefore:r=0,paddingAfter:i=0,disabled:l,key:s,hitAreaProps:u=bl,...d}=e,p=o==="row",{style:x,className:h,...y}=u;return P.jsx("div",{style:{...n,position:"relative"},...d,children:P.jsx("div",{className:yn("hit-box",h),style:{left:(p?-r:0)+"px",width:`calc(100% + ${p?r+i:0}px)`,top:(p?0:-r)+"px",height:`calc(100% + ${p?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 bn(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=T(t,[t]),s=T(n,[n]),u=T(o,[o]),d=c.useRef(!1),p=e?.timerInitial??230,x=e?.timerContinuous??p/2,h=c.useRef(null),y=c.useRef(null),R=c.useRef(null),C=c.useRef(null),L=c.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),J=c.useCallback(N=>{C.current=setTimeout(()=>{window.requestAnimationFrame(()=>{d.current!==!1&&u?.(y.current,R.current,h.current)}),J(x)},N??p)},[]);c.useEffect(()=>()=>L(),[]);const O=r?"pointer":"mouse",I=c.useCallback(N=>{N.stopPropagation(),N.stopImmediatePropagation(),N.preventDefault()},[]),j=T(N=>{document.removeEventListener(`${O}move`,oe),document.removeEventListener(`${O}up`,j),document.removeEventListener("keydown",be),document.removeEventListener("keyup",U),document.removeEventListener("touchstart",I,{capture:!0}),document.removeEventListener("touchmove",I,{capture:!0}),window.removeEventListener("blur",le),L(),window.requestAnimationFrame(()=>{d.current!==!1&&(d.current=!1,s?.(N,R.current,h.current),R.current=null)})},[]),le=c.useCallback(()=>{d.current!==!1&&(d.current=!1,j(y.current))},[]),B=T(()=>{L(),J(x),window.requestAnimationFrame(()=>{d.current!==!1&&u?.(y.current,R.current,h.current)})},[x]),oe=T(N=>{y.current=N,B()},[]),be=T(N=>{R.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},B()},[]),U=T(N=>{R.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},B()},[x]);return T(N=>{N.isDefaultPrevented()||(R.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},l(N,R.current)!==!1&&(h.current=N,y.current=N.nativeEvent,document.addEventListener(`${O}up`,j,{passive:!1}),document.addEventListener(`${O}move`,oe,{passive:!1}),document.addEventListener("keydown",be,{passive:!1}),document.addEventListener("keyup",U,{passive:!1}),window.addEventListener("blur",le,{passive:!0}),r&&i&&(document.addEventListener("touchstart",I,{passive:!1,capture:!0}),document.addEventListener("touchmove",I,{passive:!1,capture:!0})),d.current=!0,J(p)))},[p,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:p,maxAfter:x,children:h,className:y,style:R,disabled:C=!1,onDragStart:L,onDragResize:J,onDragFinish:O,resizerProps:I=qn,paneProps:j=qn,paneBeforeProps:le=qn,paneAfterProps:B=qn,createResizer:oe=vl}=e;if(h)throw new Error("Use elementBefore and elementAfter instead of children.");const be=c.useMemo(()=>c.isValidElement(o)&&c.isValidElement(n),[o,n]),U=c.useMemo(()=>{let Q=null;i&&(i==="before"?Q=0:i==="after"&&(Q=1));const Ze=Q===null;return{fixedPaneOffset:Q,isPercent:Ze,minBefore:ln(u,Ze),maxBefore:ln(d,Ze),minAfter:ln(p,Ze),maxAfter:ln(x,Ze)}},[u,d,p,x]),N=T(s,[s]),[Y,k]=c.useState(()=>ln(l,i===null));c.useEffect(()=>{k(ln(l,i===null))},[l,i]);const[E,{width:g,height:Z}]=gn(),[q,{width:z,height:K}]=gn(),ee=r==="row"?z:K,te=r==="row"?g:Z,X=c.useMemo(()=>((Q,Ze,He,ct)=>{const Ee=[null,null],Te=[null,null];if(Q||(Q={percent:ct.fixedPaneOffset===null?50:null,pixels:ct.fixedPaneOffset===null?null:0}),Ze===0)return Q?.pixels!=null?ct.fixedPaneOffset!==1?(Ee[0]=Q?.pixels,Te[1]=100):(Ee[1]=Q?.pixels-He,Te[0]=100):Q?.percent!=null&&(ct.fixedPaneOffset!==1?(Te[0]=Q?.percent,Te[1]=100-Q?.percent):(Te[1]=Q?.percent,Te[0]=100-Q?.percent)),{percents:Te,pixels:Ee,minBefore:Xn(ct.minBefore,!0),maxBefore:Xn(ct.maxBefore,!0),minAfter:Xn(ct.minAfter),maxAfter:Xn(ct.maxAfter)};let tt=hn(Q,Ze,ct.fixedPaneOffset!==1),Je=Ze-He,Le=hn(ct.minBefore,Je,!0)??0,Gt=hn(ct.maxBefore,Je,!0)??Je,_t=0,Qe=0,Ct=0,Rt=Je;_t=(hn(ct.maxAfter,Ze,!1)??He)-He,Qe=hn(ct.minAfter,Ze,!1)??Ze,Ct=Math.max(Le,_t),Rt=Math.min(Gt,Qe),tt=Math.max(Ct,Math.min(tt,Rt)),Qe=Math.min(Je-tt,hn(ct.maxAfter,Je-tt,!0)??Je),_t=Math.min(Je-tt,hn(ct.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 Te[0]=on,Te[1]=100-Te[0],{percents:Te,pixels:Ee,minBefore:`${Le}px`,minAfter:`${_t}px`,maxBefore:`${Ee[0]}px`,maxAfter:`${Ee[1]}px`}})(Y,te,ee,U),[U,Y,te,ee,r]),[Ve,Be]=c.useState(!1),We=T(L,[L]),it=T(J,[J]),ve=T(O,[O]),Ke=c.useRef(null),$=c.useRef(null),_=c.useRef(null),{style:Ce,className:ue,...we}=j,ze={minWidth:0,minHeight:0,maxWidth:"100%",maxHeight:"100%",display:"flex",overflow:"hidden",...Ce},{className:lt,style:It,...st}=le,{className:Ut,style:xt,...M}=B,xe={flex:"1 1 100%",width:"100%",...R,flexDirection:r,display:"flex"},{className:Ye,style:ft,onPointerDown:Ge,...Qt}=I,Yt=T(Q=>{const Ze=ln(Q,i===null);k(Ze)},[i]),Et=T(Q=>{if(C||!Ve)return;const Ze=Oe.current?.getBoundingClientRect();let He=0;He=r==="row"?(Q.clientX??Q.touches?.[0]?.clientX)-Ze.x:(Q.clientY??Q.touches?.[0]?.clientY)-Ze.y,He=Math.max(0,Math.min(te,He)),U.fixedPaneOffset===1&&(He=te-He),l&&Y.pixels===He||k({pixels:He,percent:null}),it?.(He),Q.stopPropagation(),Q.preventDefault()},[U,r,C,Ve,Y,te]),tn=T(Q=>{if(document.removeEventListener("pointermove",Et),document.removeEventListener("touchmove",Et),document.removeEventListener("pointerup",tn),Ve&&(Be(!1),Y)){if(ve(Y.pixels),!ln(l,i===null)||Y.pixels!==l){const Ze={...Y};Ze.percent===null&&(Ze.percent=Ze.pixels/te*100),N(Ze)}Q.stopPropagation(),Q.preventDefault()}},[Y,Ve,l,i,te]),Xt=T(Q=>{Ge?.(Q),Q.defaultPrevented||C||Ve||(Be(!0),We(),document.addEventListener("pointermove",Et,{passive:!1}),document.addEventListener("touchmove",Et,{passive:!1}),document.addEventListener("pointerup",tn,{passive:!1}))},[Ge]),Oe=lo(t,()=>({setPosition:Yt,isSplitPane:()=>!0}),[]),Ft=c.useMemo(()=>be?oe?.({key:"resizer",ref:oo([q,$]),className:yn("resizer",Ye),onPointerDownCapture:Xt,style:{cursor:C?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,...ft},splitDirection:r,disabled:C,...Qt}):null,[be,Ye,Qt,r,ft,C]),pt=r==="row"?"Width":"Height",jt={...ze,...It,flex:U.fixedPaneOffset===0&&X?.pixels[0]!==null?`0 0 ${Math.round(X?.pixels[0])}px`:`1 1 ${Math.round(X?.percents[0]??100)}%`,[`min${pt}`]:X?.minBefore,[`max${pt}`]:o?X?.maxBefore:"100%"},wn={...ze,...xt,flex:U.fixedPaneOffset===1&&X?.pixels[1]!==null?`0 0 ${Math.round(X?.pixels[1])}px`:`1 1 ${Math.round(X?.percents[1]??100)}%`,[`min${pt}`]:X?.minAfter,[`max${pt}`]:n?X?.maxAfter:"100%"},nn=c.useMemo(()=>n?P.jsx("div",{ref:Ke,className:yn("before",ue,lt),style:jt,...we,...st,children:n},"before"):null,[n,j,le,U,X]),Fe=c.useMemo(()=>o?P.jsx("div",{ref:_,className:yn("after",ue,Ut),style:wn,...we,...M,children:o},"after"):null,[o,j,B,U,X]);return P.jsxs("div",{ref:oo([E,Oe]),className:yn("splitPane",r==="row"?"vertical":"horizontal",{dragging:Ve},y),style:xe,children:[nn,Ft,Fe]})}));const Sl=({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 El=1,Bo=!1,fi=!1;const Jn=[],vn=[],ro=()=>{vn.forEach(e=>e())},_l=({automaticContainerInternalUseOnly:e})=>{const[t,n]=c.useState([]),o=c.useRef([]);return o.current=t,e||Bo!==!1||(fi=!0),c.useEffect(()=>{let r=!0;function i(){if(r)return vn[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 vn.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"),vn.splice(vn.indexOf(i),1),ro()}},[e]),P.jsx(P.Fragment,{children:t.map(({hook:r,key:i})=>c.createElement(Sl,{...r,key:i}))})},pi=(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(h=>h(x)))},p=()=>(l||(r=typeof e=="function"?e():e,l=!0),r);return()=>{const[x,h]=c.useState(p);return c.useEffect(()=>(i||(i=!0,o=(y=>{const R=El++;return Jn.push({hook:y,key:R}),vn.length===0&&fi===!1&&(Bo=!0,(C=>{if(Io.document&&Io.document.createElement){const L=Io.document.createElement("div");Ti.createRoot(L).render(P.jsx(C,{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.")})(_l)),ro(),()=>{Jn.splice(Jn.findIndex(C=>C.key===R),1),ro()}})({initValue:e,useHookBody:t,applyStateChange:d})),s.push(h),r!==x&&h(r),()=>{s.splice(s.indexOf(h),1),s.length===0&&u&&(o(),i=!1)}),[]),x}};pi(null,()=>{const[e,t]=c.useState(null);return e});class Cl{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 Se extends Cl{}St.getOS()===St.OSType.MacOS||(St.getOS(),St.OSType.IOS),St.getOS()===St.OSType.MacOS||(St.getOS(),St.OSType.IOS),pi({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,Il=0;var Ml=typeof document<"u"?c.useLayoutEffect:c.useEffect;const Ir=()=>"sheetxl-ui-"+Il++,Rl=c.useId??function(){const[e,t]=c.useState(()=>Mo?Ir():void 0);return Ml(()=>{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 p=i[l];d=p.offset+p.size}for(let p=l+1;p<=t;p++){let x=u?s.includes(p)?n(p)*r:i[p]?.size||n(p)*r:n(p)*r;i[p]={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?gi({itemType:e,itemSize:t,instanceProps:o,high:s,low:0,offset:r,scale:i}):kl({itemType:e,itemSize:t,itemCount:n,instanceProps:o,index:Math.max(0,s),offset:r,scale:i}),u=Math.min(u,n),u},gi=({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},kl=({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 gi({itemType:e,itemSize:t,instanceProps:o,high:Math.min(r,n-1),low:Math.floor(r/2),offset:i,scale:l})},wi=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=T(I=>Mr({itemType:"row",itemCount:t,itemSize:r??(()=>o??20),instanceProps:s.current,offset:I}),[t,r,o]),d=T(I=>I===-1?0:Sn({itemType:"row",index:I,itemSize:r??(()=>o??20),instanceProps:s.current}).offset,[r,o]),p=T(I=>Sn({itemType:"row",index:I,itemSize:r??(()=>o??20),instanceProps:s.current}).size,[r,o]),x=T(I=>Mr({itemType:"column",itemCount:n,itemSize:l??(()=>i??75),instanceProps:s.current,offset:I}),[n,l,i]),h=T(I=>I===-1?0:Sn({itemType:"column",index:I,itemSize:l??(()=>i??75),instanceProps:s.current}).offset,[l,i]),y=T(I=>Sn({itemType:"column",index:I,itemSize:l??(()=>i??75),instanceProps:s.current}).size,[l,i]),[R,C]=c.useReducer(I=>I+1,0),L=()=>({getRowOffset:d,getColOffset:h,getRowIndex:u,getColIndex:x}),[J,O]=c.useState(()=>e?L():null);return c.useEffect(()=>{O(e?L():null)},[R,t,n,i,o,p,y]),J},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"}},Tl=e=>!0,Pl=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),Ol=e=>!!e&&e.type==="dblclick"&&{editMode:!0},Ll=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:p=2,alignment:x=On.Left,style:h,...y}=e,R=c.useRef(null),C=c.useRef(null),[L,J]=c.useState(!1),O=t.coords,I=c.useCallback(async Y=>{if(R.current?.getBoundingClientRect()){if(Y.eventType==="keyboard"){const E=Y.event,g=new KeyboardEvent(E.type,{bubbles:!0,cancelable:!0,view:window,key:E.key,code:E.code,location:E.location,repeat:E.repeat,isComposing:E.isComposing,charCode:E.charCode,keyCode:E.keyCode,which:E.which,ctrlKey:E.ctrlKey,shiftKey:E.shiftKey,altKey:E.altKey,metaKey:E.metaKey});g.isSynthetic=!0,g.key,C.current?.dispatchEvent(g)}else Y.eventType==="pointer"||console.warn("unsupported event type",Y);await new Promise(E=>requestAnimationFrame(E))}},[]);c.useEffect(()=>{const Y=C.current;return J(!0),C.current.startEdit?.(t.startEvent),(async()=>{t.editorRefs.push(Y),t.editorRefsDispatchEditorEvent.push(I);const k=[...t.events];for(let E=0;E<k.length;E++)await I(k[E]);t.onMount(Y)})(),()=>{const k=t.editorRefs.indexOf(Y);k!==-1&&t.editorRefs.splice(k,1),t.onUnmount(Y)}},[]);const j=c.useCallback(()=>o(t),[]),le=c.useCallback(()=>{r(t)},[]),B=n.current&&G.isEqualCells(n.current,O),oe=l&&B&&L,be=s({autoFocus:!!t.startEvent?.autoFocus,...u,onSubmitEdit:j,onCancelEdit:le,ref:C},O),U=i.x+ge.boundPixel(-p/2),N=ge.boundPixel(i.width+p/2,!0);return P.jsx("div",{tabIndex:0,ref:R,style:{background:void 0,...h,opacity:oe?h?.opacity??1:0,pointerEvents:"auto",position:"absolute",boxSizing:"border-box",top:`${i.y+ge.boundPixel(-p/2)}px`,height:ge.boundPixel(i.height+p/2,!0),left:`${U}px`,width:N},...y,children:P.jsx("div",{className:"editor-container",style:{position:"absolute",boxSizing:"border-box",left:`${ge.boundPixel(1)}px`,top:`${ge.boundPixel(1)}px`,width:ge.boundPixel(i.width-2,!0),height:ge.boundPixel(i.height-2,!0),outline:`${p}px ${d} solid`,boxShadow:"rgba(60,64,67,.35) 2px 2px 6px 3px",maxHeight:"100%",overflow:"hidden",display:"flex"},children:be})})},Ue=(e,t,n)=>{if(!e)return t;let o=t;const r=n===Ne||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},Dl=(e,t,n,o,r,i)=>{if(!t)return i;let{rowIndex:l,colIndex:s}=e;switch(o){case ot:{l=Ue(n,Math.min(l+1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&l<i;)l=Ue(n,Math.min(++l,i),o),u=t({rowIndex:l,colIndex:s});return l}case nt:{l=Ue(n,Math.max(l-1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&l>i;)l=Ue(n,Math.max(--l,i),o),u=t({rowIndex:l,colIndex:s});return l}case Ne:{s=Ue(n,Math.min(s+1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&s<i;)s=Ue(n,Math.min(++s,i),o),u=t({rowIndex:l,colIndex:s});return s}case et:{s=Ue(n,Math.max(s-1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&s>i;)s=Ue(n,Math.max(--s,i),o),u=t({rowIndex:l,colIndex:s});return s}default:return i}},zl=(e,t=()=>!0,n,o,r,i)=>{let{rowIndex:l,colIndex:s}=e;switch(o){case ot:{l=Ue(n,Math.min(l+1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&l<i;)l=Ue(n,Math.min(++l,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?l:l-1}case nt:{l=Ue(n,Math.max(l-1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&l>i;)l=Ue(n,Math.max(--l,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?l:l+1}case Ne:{s=Ue(n,Math.min(s+1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&s<i;)s=Ue(n,Math.min(++s,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?s:s-1}case et:{s=Ue(n,Math.max(s-1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&s>i;)s=Ue(n,Math.max(--s,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?s:s+1}default:return null}},jl=(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===Ne?l={rowIndex:s,colIndex:u+1}:o===et&&(l={rowIndex:s,colIndex:u-1});const d=t(e),p=t(l);var x,h;return(h=p,!(x=d)&&!h||!x&&h||x&&!h?Dl:zl)(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=Ne,n,o,r,i=null)=>{if(i&&G.isEqualSelectionCoords(i,e))return e;const l=e.ranges[e.rangeIndex];if(!G.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 Ne:s.colIndex=Ue(r,s.colIndex+1,t);break;case et:s.colIndex=Ue(r,s.colIndex-1,t);break;case ot:s.rowIndex=Ue(o,s.rowIndex+1,t);break;case nt:s.rowIndex=Ue(o,s.rowIndex-1,t)}const d=h=>{if(h){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===Ne&&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 h=s.rowIndex,y=s.colIndex;switch(t){case Ne:y>l.colEnd&&(h=Ue(o,h+1,t),y=l.colStart,h>l.rowEnd&&(h=l.rowStart));break;case et:y<l.colStart&&(h=Ue(o,h-1,t),y=l.colEnd,h<l.rowStart&&(h=l.rowEnd));break;case ot:h>l.rowEnd&&(y=Ue(r,y+1,t),h=l.rowStart,y>l.colEnd&&(y=l.colStart));break;case nt:h<l.rowStart&&(y=Ue(r,y-1,t),h=l.rowEnd,y<l.colStart&&(y=l.colEnd))}s={rowIndex:h,colIndex:y}}let p=n(s);if(!G.isRangeWithinRange(p,l)){const h=G.intersectRanges(p,l);h&&(p=h)}let x={rowStart:Ue(o,p.rowStart,ot),colStart:Ue(r,p.colStart,Ne),rowEnd:Ue(o,p.rowEnd,nt),colEnd:Ue(r,p.colEnd,et)};if(x.rowStart!==s.rowIndex||x.colStart!==s.colIndex){switch(t){case Ne: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=Ne,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 p=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:p,size:x-p,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}},Al=(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 ${ge.boundPixel(e.left)} ${ge.boundPixel(e.top)} L ${ge.boundPixel(e.right,!0)} ${ge.boundPixel(e.top)} L ${ge.boundPixel(e.right,!0)} ${ge.boundPixel(e.bottom,!0)} L ${ge.boundPixel(e.left)} ${ge.boundPixel(e.bottom,!0)} L ${ge.boundPixel(e.left)} ${ge.boundPixel(e.top)} ${t?"Z":""}`,Vo=e=>{const{linePoints:t,bounds:n,pathProps:o,style:r,...i}=e;return P.jsx("svg",{width:`${ge.boundPixel(n.width,!0)}`,height:`${ge.boundPixel(n.height,!0)}`,viewBox:`0 0 ${ge.boundPixel(n.width,!0)} ${ge.boundPixel(n.height,!0)}`,style:{position:"absolute",left:`${ge.boundPixel(n.x)}px`,top:`${ge.boundPixel(n.y)}px`,width:`${ge.boundPixel(n.width,!0)}px`,height:`${ge.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:P.jsx("path",{d:`M ${ge.boundPixel(t[0])} ${ge.boundPixel(t[1])} L ${ge.boundPixel(t[2])} ${ge.boundPixel(t[3])}`,fill:"none",vectorEffect:"non-scaling-stroke",stroke:"black",...o})})},mi=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:p,pathBounds:x,pathProps:h,style:y,...R}=e,C=n,L=t,J=o,O=r;let I=null;if(i){let j=Ro({top:0,left:0,bottom:O,right:J});x&&(j=j+" "+Ro({top:x.y-C,left:x.x-L,bottom:x.height+x.y-C,right:x.width+x.x-L})),I=[P.jsx("path",{d:j,fill:i,stroke:"none",fillRule:"evenodd"},"fill")]}return P.jsxs("svg",{width:`${ge.boundPixel(o,!0)}`,height:`${ge.boundPixel(r,!0)}`,viewBox:`0 0 ${ge.boundPixel(o,!0)} ${ge.boundPixel(r,!0)}`,preserveAspectRatio:"none",style:{position:"absolute",left:`${ge.boundPixel(t)}px`,top:`${ge.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},...R,children:[I,P.jsx("path",{d:Ro({top:0,left:0,right:J,bottom:O}),fill:"none",strokeDasharray:u,strokeDashoffset:d,stroke:l,vectorEffect:"non-scaling-stroke",strokeWidth:s,...h})]})},zr=e=>{const{key:t,...n}=e;return P.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:p,cell:x,...h}=e,y=u||!!d,R={name:"walking-offset",dashGap:2,speed:50,dashLength:8,...d};let C=R.dashGap+R.dashLength;const L=R.speed*C,J=Rl().replaceAll(":",""),O=`${R.name}-${J}`;let I;return c.useEffect(()=>{if(!y)return;const j=`@keyframes ${O} {
15
15
  to {
16
16
  stroke-dashoffset: 0px;
17
17
  }
18
- }`,ie=document.createElement("style");return ie.appendChild(document.createTextNode(j)),document.head.appendChild(ie),ie.sheet.insertRule(j,0),()=>{document.head.removeChild(ie)}},[y]),y&&(I={strokeDasharray:`${C.dashLength}px ${C.dashGap}px`,strokeDashoffset:`${R}px`,animation:`${L} ${T}ms linear infinite`,willChange:"stroke-dashoffset"}),O.jsx(xi,{x:o,y:r,width:i,height:l,stroke:t,fill:n,shapeRendering:"crispEdges",style:{...I,...s},...p})});function yi(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=yi(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=yi(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,C=!0,R=!0;switch(s){case"tl":p=!1,y=!1;break;case"bl":p=!1,R=!1;break;case"br":C=!1,R=!1;break;case"tr":y=!1,C=!1}return O.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:C?`${r}px ${l}`:void 0,borderBottom:R?`${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(){},vi=typeof window<"u",Fl=vi?c.useLayoutEffect:c.useEffect,jr={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const bi=vi&&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,C=u.left,R=u.bottom,T=u.right;i({x:d,y:w,width:x,height:p,top:y,left:C,bottom:R,right:T})}})},[]);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:C,scrollableElement:R,scrollableRoot:T=document.body,...ce}=e,L=P(p,[p]),I=P(y,[y]),{bounds:j,coordsPivot:ie,key:B}=c.useMemo(()=>{if(!n||!o)return null;let q=null,z=null;switch(r){case"tl":q={colIndex:n.colEnd,rowIndex:n.rowEnd},z={colIndex:n.colStart,rowIndex:n.rowStart};break;case"br":q={colIndex:n.colStart,rowIndex:n.rowStart},z={colIndex:n.colEnd,rowIndex:n.rowEnd};break;case"t":case"l":q={colIndex:n.colEnd,rowIndex:n.rowEnd};break;case"b":q={colIndex:n.colStart,rowIndex:n.rowStart};break;case"r":q={colIndex:n.colStart,rowIndex:n.rowEnd}}let K=o.getRangeCoordsBounds(z?{rowStart:z.rowIndex,colStart:z.colIndex,rowEnd:z.rowIndex,colEnd:z.colIndex}:n);const Q=o.getBounds(),ee=o.getViewportSize(),X=Q.x,Ve=Q.y,Be=ee.width,We=ee.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=Be/2-X;break;case"b":K.x=Be/2-X,K.y=K.y+K.height;break;case"l":K.y=We/2-Ve;break;case"r":K.x=K.x+K.width,K.y=We/2-Ve}const it=o.toClipBounds(K,0);return!it||it.width<=0||it.height<=0||K.x<0||K.y<0||K.x>Be||K.y>We?{bounds:null,coordsAnchor:null,coordsPivot:null,key:null}:{bounds:K,coordsAnchor:null,coordsPivot:q,key:"touchSelect-"+o.getAnchor()+"-"+r}},[n,o,r]),ne=c.useRef(null),ve=vn(c.useMemo(()=>{const q=z=>r==="t"||r==="b"?{...z,colIndex:void 0}:r==="l"||r==="r"?{...z,rowIndex:void 0}:z;return{processTouch:!0,consumeTouch:!0,onPointerDown:(z,K)=>{const Q=q(o.getCellCoordsFromClient(z.clientX,z.clientY));return ne.current={coordsPivot:ie},L?.(r),x.onSelectionPointerDown(z,K,o,Q,ie,!1,!0)},onPointerMoveOrWait:(z,K,Q)=>{const ee=q(o.getCellCoordsFromClient(z.clientX,z.clientY));return x.onSelectionPointerMoveOrWait(z,K,Q,o,ee,ne.current?.coordsPivot,!0,!0)},onPointerUp:(z,K,Q)=>(ne.current=null,I?.(r),x.onPointerUp(z,K,Q))}},[x,n,o,r])),[U,{y:N,x:Y}]=bi(),k=c.useRef(null),{getPortalContainer:E}=fi(),[f,Z]=c.useState(null);return c.useEffect(()=>{const q=k.current?.getBoundingClientRect();if(!q||!j)return void Z(null);let z=0,K=0,Q=R;for(;Q;)z+=Q.scrollLeft,K+=Q.scrollTop,Q=T&&Q===T.parentElement?null:Q.parentElement;Z(No.createPortal(O.jsx("div",{className:fn("touch-select-handle",w),ref:t,style:{position:"absolute",left:z+(q?.x??0)-(u+s)/2,top:K+(q?.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:C?0:1,transitionDuration:"160ms",transitionProperty:"opacity",...d},tabIndex:-1,onPointerDown:ve,...ce}),T??E(),B))},[N,Y,j?.x,j?.y,j?.width,j?.height,w,C,l,u,s,i,R]),j?O.jsxs(O.Fragment,{children:[O.jsx("div",{ref:Vl([U,k]),style:{position:"absolute",left:j.x,top:j.y,opacity:0}}),f]}):null}));Qn.displayName="TouchSelectHandle";const Wt=-10,Wl=Object.freeze({rowStart:0,colStart:0,rowEnd:0,colEnd:0}),Si=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=Si),G.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:C="rgb(224, 224, 224)",gridLineRowsProps:R,gridLineColumnsProps:T,clipCells:ce=!0,cursor:L,freezeLeft:I=0,freezeTop:j=0,freezeLeftProps:ie,freezeTopProps:B,cellRenderer:ne,onViewportChange:ve,onFirstRender:U,overlayRenderer:N,overlayProps:Y,overlays:k,overlaysProps:E,allowOverlaysOverflow:f=!1,stageProps:Z,stageWrapper:q=null,hiddenRowsAt:z,hiddenColumnsAt:K,hiddenCellAt:Q,getVisibleCells:ee,zoom:X=1,enableMouseWheel:Ve=!0,onWheelScroll:Be,getCellCoordsAsRangeCoords:We=G.cellToRange,scrollPoint:it=Nl,style:be={},...Ke}=e;eo(ne),eo(!e?.children);const $=P(p,[p]),_=P(ve,[ve]),Ce=P(x,[x]),ue=P(Be,[Be]),we=P(U,[U]),ze=c.useRef(null),lt=c.useRef(null),It=c.useRef(null),[st,Ut]=c.useReducer(v=>v+1,0),[xt,M]=c.useState({left:it?.left??0,top:it?.top??0,horizontalScrollDirection:null,verticalScrollDirection:null}),xe=c.useRef(null),Ye=c.useRef(xt),{top:ft,left:Ge,verticalScrollDirection:Qt,horizontalScrollDirection:Yt}=xt,Et=c.useRef(!1),tn=mi({rowCount:r,columnCount:i,defaultRowHeight:l,defaultColumnWidth:s,getRowHeight:u,getColumnWidth:d}),Xt=c.useRef(null),Oe=c.useMemo(()=>{const v=w||tn;return Xt.current=null,{getColOffset:D=>v.getColOffset(D)*X,getColIndex:D=>v.getColIndex(D/X),getRowOffset:D=>v.getRowOffset(D)*X,getRowIndex:D=>v.getRowIndex(D/X)}},[tn,w,X]),Ft=(v,D,A)=>{const V=(D?.left??0)+0,W=(D?.top??0)+0;return{getColOffset:he=>v.getColOffset(he)-V,getColIndex:he=>v.getColIndex(he+V),getRowOffset:he=>v.getRowOffset(he)-W,getRowIndex:he=>v.getRowIndex(he+W)}},pt=c.useCallback((v,D=!1)=>io(v,D,Oe.getRowOffset,D?0:r),[r,Oe?.getRowOffset]),jt=P(z??pt,[z]),wn=c.useCallback((v,D=!1)=>io(v,D,Oe.getColOffset,D?i:0),[i,Oe?.getColOffset]),nn=P(K??wn,[K]),Fe=c.useMemo(()=>Math.min(n??800,Oe.getColOffset(i)),[Oe.getColOffset,i,n]),J=c.useMemo(()=>Math.min(o??600,Oe.getRowOffset(r)),[Oe.getRowOffset,r,o]),Ze=c.useCallback(v=>{St.canUseDOM&&setTimeout(()=>{ze.current?.focus({preventScroll:!0,...v})},0)},[]),He=c.useCallback(v=>ze.current?.contains(v)||lt.current?.contains(v),[]);c.useEffect(()=>{Et.current&&(xe.current&&xe.current.left!==Ye.current?.left&&xe.current.top!==Ye.current?.top||(xe.current=null,Ce?.({left:Ge,top:ft})))},[Ge,ft]);const ct=P(()=>({top:ft,left:Ge}),[ft,Ge]),Ee=c.useMemo(()=>{const v=[];let D=0,A=0;typeof j=="number"?D=j:(D=j.index??0,A=(j.scrollOffset??0)*X);const V=A,W=Oe.getRowOffset(D),he=W-V;if(D>0){const at=Ft(Oe,{top:A+Oe.getRowOffset(0)}),je=Oe.getRowIndex(V),Ae=Oe.getRowIndex(W-1);let dt;v[1]={minIndex:je,maxIndex:Ae,minCoord:0,maxCoord:D-1,minBounds:0,maxBounds:he,visibleIndices:()=>dt||(dt=Object.freeze(Yn(jt,je,Ae)),dt),layout:at,maxVirtualBounds:W,scrollOffset:A,freezeOffset:A}}const le=Math.max(0,J-he),me=Ft(Oe,{top:ft+he}),ye=me.getRowIndex(0),se=me.getRowIndex(le);let $e;return v[0]={minIndex:ye,maxIndex:se,minCoord:D,maxCoord:r-1,minBounds:he,maxBounds:le,visibleIndices:()=>$e||($e=Object.freeze(Yn(jt,ye,se)),$e),layout:me,maxVirtualBounds:Oe.getRowOffset(r),scrollOffset:ft,freezeOffset:(D>0?Oe.getRowOffset(D):0)-A},v},[Oe.getRowIndex,Oe.getRowOffset,jt,J,r,j,ft,X]),Te=c.useMemo(()=>{const v=[];let D=0,A=0;typeof I=="number"?D=I:(D=I.index??0,A=(I.scrollOffset??0)*X);const V=A,W=Oe.getColOffset(D),he=W-V;if(D>0){const at=Ft(Oe,{left:A+Oe.getColOffset(0)}),je=Oe.getColIndex(V),Ae=Oe.getColIndex(W-1);let dt;v[1]={minIndex:je,maxIndex:Ae,minCoord:0,maxCoord:D-1,minBounds:0,maxBounds:he,visibleIndices:()=>dt||(dt=Object.freeze(Yn(nn,je,Ae)),dt),layout:at,maxVirtualBounds:W,scrollOffset:A,freezeOffset:A}}const le=Math.max(0,Fe-he),me=Ft(Oe,{left:Ge+he}),ye=me.getColIndex(0),se=me.getColIndex(le);let $e;return v[0]={minIndex:ye,maxIndex:se,minCoord:D,maxCoord:i-1,minBounds:he,maxBounds:le,visibleIndices:()=>$e||($e=Object.freeze(Yn(nn,ye,se)),$e),layout:me,maxVirtualBounds:Oe.getColOffset(i),scrollOffset:Ge,freezeOffset:(D>0?Oe.getColOffset(D):0)-A},v},[Oe.getColIndex,Oe.getColOffset,nn,Fe,i,I,Ge,X]),tt=c.useRef({}),Je=c.useRef([]),Le=c.useMemo(()=>{let v={};const D=(V,W,he,le,me)=>{const ye={vertical:le?.vertical||!1,horizontal:le?.horizontal||!1};if(V>=Te.length||W>=Ee.length)return null;const se={rowStart:Ee[W].minIndex,colStart:Te[V].minIndex,rowEnd:Ee[W].maxIndex,colEnd:Te[V].maxIndex};if(se.rowStart>se.rowEnd||se.colStart>se.colEnd)return null;const $e={getColIndex:_e=>Te[V].layout.getColIndex(_e),getColOffset:_e=>Te[V].layout.getColOffset(_e),getRowIndex:_e=>Ee[W].layout.getRowIndex(_e),getRowOffset:_e=>Ee[W].layout.getRowOffset(_e)},at=Object.freeze({left:me?.left??0,top:me?.top??0,right:me?.right??0,bottom:me?.bottom??0}),je=Object.freeze({x:Te[V].minBounds,y:Ee[W].minBounds,width:Te[V].maxBounds,height:Ee[W].maxBounds}),Ae=(_e,Xe)=>Dr($e,_e??se,Xe),dt={width:Te[V].maxVirtualBounds,height:Ee[W].maxVirtualBounds},qe={left:Te[V].scrollOffset,top:Ee[W].scrollOffset},kt={left:Te[V].freezeOffset,top:Ee[W].freezeOffset},gt={width:Fe,height:J};let fe=null,ht=null;const Ot=(kt.top+(le.vertical?qe.top:0))/X,At=(kt.left+(le.horizontal?qe.left:0))/X;return{getStage:()=>ze.current??null,getVisibleRangeCoords:()=>se,toClipBounds:(_e,Xe)=>{let De,rt=0;return Xe===void 0||typeof Xe=="number"?(De=Ae(se),rt=Xe):De=Xe,((ke,yt,wt=0)=>{if(ke.x>yt.width||ke.y>yt.height)return null;const Lt={left:ke.x,top:ke.y,bottom:ke.height+ke.y,right:ke.width+ke.x},Vt={left:yt.x+wt,top:yt.y+wt,bottom:yt.height-2*wt+yt.y,right:yt.width-2*wt+yt.x},Tt={left:Math.max(Lt.left,Vt.left),top:Math.max(Lt.top,Vt.top),bottom:Math.min(Lt.bottom,Vt.bottom),right:Math.min(Lt.right,Vt.right)},a={x:Tt.left,y:Tt.top,width:Tt.right-Tt.left,height:Tt.bottom-Tt.top};return a.height<0||a.width<0?null:a})(_e??{x:0,y:0,width:je.width,height:je.height},De,rt)},toViewBounds:_e=>At===0&&Ot===0&&X===1?_e:{x:(_e.x-At)*X,y:(_e.y-Ot)*X,width:_e.width*X,height:_e.height*X},toAbsoluteBounds:_e=>At===0&&Ot===0&&X===1?_e:{x:_e.x/X+At,y:_e.y/X+Ot,width:_e.width/X,height:_e.height/X},getRelativePointFromClient:(_e,Xe)=>{const De=on(_e,Xe);return{x:De.x-je.x,y:De.y-je.y}},getLayout:()=>$e,getCellCoordsAsRangeCoords:We,getVisibleColumns:()=>Te[V].visibleIndices(),getVisibleRows:()=>Ee[W].visibleIndices(),getVisibleColumnOffsets:()=>(fe||(fe=Lr(Te[V].layout,!0,Te[V].visibleIndices(),se.colStart,se.colEnd)),fe),getVisibleRowOffsets:()=>(ht||(ht=Lr(Ee[W].layout,!1,Ee[W].visibleIndices(),se.rowStart,se.rowEnd)),ht),getTotalRangeCoords:()=>({colStart:Te[V].minCoord,colEnd:Te[V].maxCoord,rowStart:Ee[W].minCoord,rowEnd:Ee[W].maxCoord}),getRangeCoordsBounds:Ae,scrollCellCoordsIntoView:(_e,Xe)=>_n(_e,Xe,he),getCellCoordsFromClient:(_e,Xe,De=!1)=>{const rt=on(_e,Xe);if(!rt)return null;const ke=$e.getColIndex(rt.x-je.x),yt={rowIndex:$e.getRowIndex(rt.y-je.y),colIndex:ke};if(De)return yt;const wt=We(yt);return{rowIndex:wt.rowStart,colIndex:wt.colStart}},getZoom:()=>X,getAnchor:()=>he,getBounds:()=>je,getInsets:()=>at,getTotalSize:()=>dt,getViewportSize:()=>gt,getScrollTopLeft:()=>qe,getFreezeTopLeft:()=>kt,getScrollOrientation:()=>ye,allViews:()=>v}};let A=v[Ht]=D(0,0,Ht,Kl,Ul);return A&&(v[Ht]=A),A=D(0,1,Ln,{horizontal:!0}),A&&(v[Ln]=A),A=D(1,0,Dn,{vertical:!0}),A&&(v[Dn]=A),A=D(1,1,to,{}),A&&(v[to]=A),tt.current=null,v=Object.freeze(v)},[Ee,Te,We]),Gt=Object.keys(Le),_t=Te[0]?.maxVirtualBounds??0,Qe=Ee[0]?.maxVirtualBounds??0,Ct=c.useMemo(()=>({left:Te[1]?Te[1].layout.getColOffset(Te[1].maxIndex+1):0,top:Ee[1]?Ee[1].layout.getRowOffset(Ee[1].maxIndex+1):0}),[Le]);c.useEffect(()=>{if(Je.current.length>0){for(let v=0;v<Je.current.length;v++)Je.current[v]();Je.current=[]}},[Le]);const Rt=P(()=>({containerWidth:Fe,containerHeight:J,totalWidth:_t,totalHeight:Qe}),[Fe,J,Oe]);c.useEffect(()=>{!xe.current&&Et.current&&_({top:ft,left:Ge,width:Fe,height:J,totalWidth:_t,totalHeight:Qe})},[ft,Ge,_t,Qe]),c.useEffect(()=>{Et.current&&_({top:ft,left:Ge,width:Fe,height:J,totalWidth:_t,totalHeight:Qe})},[Fe,J]);const on=c.useCallback((v,D)=>{eo(typeof v=="number"&&typeof D=="number");const A=ze.current?.getBoundingClientRect();return A?{x:v-A.x,y:D-A.y}:{x:v,y:D}},[]),so=P(v=>Le[v]||null,[Le]),co=P((v,D)=>{if(Object.keys(Le).length===1)return Le[Ht];const A=on(v,D);if(!A)return null;const{x:V,y:W}=A;let he=null;const le=$r;for(let me=0;!he&&me<le.length;me++){const ye=Le[le[me]];ye&&$l(V,W,ye.getBounds())&&(he=ye)}return he||(he=Le[Ht]),he},[Le,We]),ut=P(()=>Le[Ht].getVisibleRangeCoords(),[Le[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,M(v=>{const D={...v,verticalScrollDirection:null,horizontalScrollDirection:null};return Ye.current=D,D})},[]),an=P(v=>{const D=v?.left??v?.[0],A=v?.top??v?.[1],V=D!==void 0?Math.min(_t-Fe,Math.max(Te?.[1]?.scrollOffset??0,D)):Ye.current.left,W=A!==void 0?Math.min(Qe-J,Math.max(Ee?.[1]?.scrollOffset??0,A)):Ye.current.top;if(Ye.current.left===V&&Ye.current.top===W)return;let he=null,le=null;Ye.current.left>V?he=et:Ye.current.left<V&&(he=Ne),Ye.current.top>W?le=nt:Ye.current.top<W&&(le=ot),St.throttle(()=>{M(me=>{const ye={...me,left:V,top:W,horizontalScrollDirection:he,verticalScrollDirection:le};return Ye.current=ye,ye})},17)(),xe.current?.top===W&&xe.current?.left===V||(xe.current={left:V,top:W},$({left:V,top:W}),_({left:V,top:W,width:Fe,height:J,totalWidth:_t,totalHeight:Qe})),ao()},[_t,Qe,Ee,Te]);c.useEffect(()=>{xe.current||an({left:Ge,top:ft})},[_t,Fe,Qe,J]),c.useLayoutEffect(()=>{xe.current={left:it?.left,top:it?.top},an(xe.current)},[it?.left,it?.top]);const An=P(v=>{const D=v?.left??v?.[0],A=v?.top??v?.[1],V=v?.behavior??"auto",W={left:Ye.current.left+(D??0),top:Ye.current.top+(A??0)};V&&(W.behavior=V),an(W)},[_t,Fe,Qe,J]),$n=c.useCallback(v=>{let D=null;if(Object.keys(Le).length>1){const A=$r;for(let V=0;!D&&V<A.length;V++){const W=Le[A[V]];W&&G.isCellWithinRange(v,W.getVisibleRangeCoords())&&(D=W)}}return D||(D=Le[Ht]),D},[Le]),_n=P((v,D={inline:"nearest",block:"nearest"},A=null)=>{const V={rowIndex:0,colIndex:0,...v};let W=null;if(A!==null){if(W=Le[A],W===null)return new Promise((gt,fe)=>{fe("Invalid view")})}else W=$n(V);const he=We(V),le=W.getLayout(),me=le.getColOffset(he.colStart),ye=le.getRowOffset(he.rowStart),se=le.getColOffset(he.colEnd+1),$e=le.getRowOffset(he.rowEnd+1),at=W.getBounds(),je=W.getTotalSize(),Ae=W.getScrollTopLeft(),dt=((gt,fe,ht=!0)=>(ht=ht===!0?{block:"start",inline:"end"}:ht===!1?{block:"end",inline:"end"}:{block:"end",inline:"end",...ht},{left:Tr(ht.inline,gt.x,gt.x+gt.width,fe.left,fe.left+fe.width,fe.totalWidth),top:Tr(ht.block,gt.y,gt.y+gt.height,fe.top,fe.top+fe.height,fe.totalHeight)}))({x:me+Ae.left,y:ye+Ae.top,width:se-me,height:$e-ye},{left:Ae.left,top:Ae.top,width:at.width,height:at.height,totalWidth:je.width,totalHeight:je.height},D),qe={...dt};qe.left>Ge?qe.left+=20:qe.left<Ge&&(qe.left-=0),qe.top>ft?qe.top+=20:qe.top<ft&&(qe.top-=0);const kt=W.getScrollOrientation();return kt.horizontal&&v.colIndex!==void 0||delete qe.left,kt.vertical&&v.rowIndex!==void 0||delete qe.top,new Promise((gt,fe)=>{try{an(qe),gt(qe)}catch(ht){fe(ht)}})},[_t,Qe,Le,We]),mn=P(v=>{const D=v.shiftKey;v.preventDefault();const{deltaX:A,deltaY:V,deltaMode:W}=v;if(It.current||ue?.(v)===!1)return;let le=D?V:A,me=V;const ye=D||Math.abs(le)>Math.abs(me);W===1&&(me*=0),It.current=window.requestAnimationFrame(()=>{It.current=null,An(ye?{left:le}:{top:me})})},[_t,Fe,Qe,J,ue]),Cn=c.useCallback((v=null)=>{Xt.current=null,tt.current=null,Ut()},[]);c.useLayoutEffect(()=>{Cn()},[ne]);const un=lo(t,()=>({stage:ze.current,focus:Ze,contains:He,invalidate:Cn,scrollTo:an,scrollBy:An,scrollCellCoordsIntoView:_n,getScrollPosition:ct,getDimensions:Rt,getViewport:ut,handleWheel:mn,rowCount:r,columnCount:i,getLayout:()=>Oe,getRelativePointFromClient:on,getViewFromClient:co,getViewFromCellCoords:$n,getViewFromLocation:so,onViewChangeOnce:v=>{Je.current.push(v)}}),[r,i,Le]);c.useEffect(()=>(Ve&&un.current?.addEventListener("wheel",mn,{passive:!1}),Et.current=!0,xe.current=null,()=>{un.current?.removeEventListener("wheel",mn)}),[Ve]);const In=c.useRef([]),ho=(v,D)=>{!v||!N||(In.current=[],D.push(((A,V)=>{const W=`view:${A.getAnchor()}:overlay:${D.length}`,he=N?.({key:W,view:A},me=>In.current[V]=me);if(!he)return null;const le=A.getBounds();return O.jsx("div",{style:{position:"absolute",left:"0px",top:"0px",width:`${le.width}px`,height:`${le.height}px`,overflow:"hidden"},children:he},`overlay-${A.getAnchor()}-${V}`)})(v,0)))},fo=c.useMemo(()=>{const v={},D=Object.keys(Le);for(let A=0;A<D.length;A++){const V=D[A],W=[];ho(Le[V],W),v[V]={overlays:W}}return v},[st,N,r,i,Ee,Te]),Bn=(v,D,A,V,W,he,le)=>{if(!v)return;const me=v.getVisibleColumns(),ye=v.getVisibleRows();if(me.length===0||ye.length===0)return;let se=null;if(ee)se=ee(v);else{se=[];for(let Xe=0;Xe<ye.length;Xe++)for(let De=0;De<me.length;De++){const rt={rowIndex:ye[Xe],colIndex:me[De]};if(Q?.(rt))continue;const ke={coords:rt,range:We(rt)};se.push(ke)}}const $e=v.getVisibleColumnOffsets(),at=v.getVisibleRowOffsets(),je=v.getScrollTopLeft(),Ae=v.getFreezeTopLeft(),dt=je.left+Ae.left,qe=je.top+Ae.top,kt=Math.trunc(dt/Jt),gt=Math.trunc(qe/Jt),fe={},ht=(Xe,De,rt,ke,yt)=>{const wt=`view:${Xe.getAnchor()}:cell:${kr(De.rowIndex,De.colIndex)}`,Lt=ke.x,Vt=ke.y,Tt=Math.trunc((dt+Lt)/Jt)-kt,a=Math.trunc((qe+Vt)/Jt)-gt;fe[a]||(fe[a]={});let h=fe[a][Tt];h||(h=fe[a][Tt]=[]);let m=he?.get(wt);if(!m){const g=(dt+Lt)%Jt,b=(qe+Vt)%Jt;m=ne({key:wt,coords:De,bounds:ke,zoom:X,range:rt,view:Xe,value:yt,style:{left:ge.boundPixel(g),top:ge.boundPixel(b),width:ge.boundPixel(ke.width,!0),height:ge.boundPixel(ke.height,!0)}})}le?.set(wt,m),h.push(m)};for(let Xe=0;se&&Xe<se.length;Xe++){const De=se[Xe],rt=De?.coords??De;if(!rt)continue;const ke=De?.range??{rowStart:rt.rowIndex,colStart:rt.colIndex,rowEnd:rt.rowIndex,colEnd:rt.colIndex},yt=v.getVisibleRangeCoords();if(!G.isRangesIntersect(ke,yt)&&!G.isRangeWithinRange(ke,yt))continue;const wt=ke&&!G.isSingleCell(ke);if(!wt&&Q?.(rt))continue;const Lt=rt.rowIndex,Vt=rt.colIndex,Tt=at[Lt],a=$e[Vt];let h=null;Tt&&a&&(h={x:a.offset,y:Tt.offset,width:a.size,height:Tt.size});const m=kr(ke.rowStart,ke.colStart);if(wt){if(W.has(m))continue;W.add(m),ke.rowEnd-ke.rowStart>0&&A.push(ke),ke.colEnd-ke.colStart>0&&V.push(ke)}if(wt&&(h=Dr(v.getLayout(),ke)),!h){console.warn("no bounds for cell",m);continue}const g=De?.value;ht(v,rt,ke,h,g)}const Ot=dt%Jt,At=qe%Jt,_e=Object.keys(fe);for(let Xe=0;Xe<_e.length;Xe++){const De=fe[_e[Xe]];if(!De)continue;const rt=Object.keys(De);for(let ke=0;ke<rt.length;ke++){const yt=De[rt[ke]];if(!yt)continue;const wt=parseInt(_e[Xe]),Lt=parseInt(rt[ke]),Vt=wt+gt,Tt=Lt+kt,a=`view:${v.getAnchor()}:segment:${Tt}:${Vt}`;D.push(O.jsx("div",{className:"cell-container",style:{transform:`translate(${ge.boundPixel(Lt*Jt-Ot,!0)}px, ${ge.boundPixel(wt*Jt-At,!0)}px)`,willChange:"transform"},children:yt},a))}}},Kt=c.useMemo(()=>{const v=Xt.current,D=new Map,A={},V=Object.keys(Le);for(let W=0;W<V.length;W++){const he=V[W],le=[],me=[],ye=[];Bn(Le[he],ye,le,me,new Set,v,D),A[he]={cells:ye,rangesH:le,rangesV:me}}return Xt.current=D,A},[st,r,i,Ee,Te,y,be,ce,Q,ee,We]),Fn=(v,D,A,V,W)=>{if(v)if(D){const he=`view:${v.getAnchor()}:hl:`,le=v.getVisibleRows();if(!le||le.length===0)return;const me=0,ye=v.getBounds().width;let se=[];const $e=W.sort(G.rowFirstRangeComparator),at=v.getVisibleRangeCoords();for(let je=0;je<le.length&&le[je]<=at.rowEnd;je++){const Ae=le[je];if(Ae<at.rowStart)continue;let dt=!1;for(;$e.length>0&&$e[0].rowStart<=Ae;){const fe=$e.shift();fe.rowEnd>Ae&&(se.push(fe),dt=!0)}dt&&(se=se.sort(G.columnFirstRangeComparator));const qe=v.getLayout(),kt=qe.getRowOffset(Ae+1);let gt=me;for(let fe=0;fe<se.length+1;fe++){let ht=gt,Ot=ye;const At=se[fe];fe<se.length&&(Ot=Math.min(ye,qe.getColOffset(At.colStart)),gt=Math.min(ye,qe.getColOffset(At.colEnd+1))),V.push(c.createElement("path",{d:`M ${ge.boundPixel(ht)} ${ge.boundPixel(kt,!1,A)} L ${ge.boundPixel(Ot)} ${ge.boundPixel(kt,!1,A)}`,stroke:C,strokeWidth:1,vectorEffect:"non-scaling-stroke",...R,key:he+Ae+":"+fe}))}for(let fe=se.length-1;fe>=0;fe--)se[fe].rowEnd<=le[je+1]&&se.splice(fe,1)}}else{const he=`view:${v.getAnchor()}:vl:`,le=v.getVisibleColumns();if(!le||le.length===0)return;const me=0,ye=v.getBounds().height;let se=[];const $e=W.sort(G.columnFirstRangeComparator),at=v.getVisibleRangeCoords();for(let je=0;je<le.length&&le[je]<=at.colEnd;je++){const Ae=le[je];if(Ae<at.colStart)continue;let dt=!1;for(;$e.length>0&&$e[0].colStart<=Ae;){const fe=$e.shift();fe.colEnd>Ae&&(se.push(fe),dt=!0)}dt&&(se=se.sort(G.rowFirstRangeComparator));const qe=v.getLayout(),kt=qe.getColOffset(Ae+1);let gt=me;for(let fe=0;fe<se.length+1;fe++){let ht=gt,Ot=ye;const At=se[fe];fe<se.length&&(Ot=Math.min(ye,qe.getRowOffset(At.rowStart)),gt=Math.min(ye,qe.getRowOffset(At.rowEnd+1)));let _e=C;V.push(O.jsx("path",{d:`M ${ge.boundPixel(kt,!1,A)} ${ge.boundPixel(ht)} L ${ge.boundPixel(kt,!1,A)} ${ge.boundPixel(Ot)}`,stroke:_e,strokeWidth:1,vectorEffect:"non-scaling-stroke",...T},he+Ae+":"+fe))}for(let fe=se.length-1;fe>=0;fe--)se[fe].colEnd<=le[je+1]&&se.splice(fe,1)}}},Mn=v=>{if(!Kt)return;const D={};for(let A=0;A<Gt.length;A++){const V=Gt[A],W=Le[V],he=[];Fn(W,v,0,he,v?Kt[V].rangesH:Kt[V].rangesV);const le=W.getRangeCoordsBounds(),me=Math.ceil(le.width),ye=Math.ceil(le.height);D[V]=O.jsx("svg",{width:`${me}`,height:`${ye}`,viewBox:`0 0 ${me} ${ye}`,preserveAspectRatio:"none",shapeRendering:"crispEdges",style:{position:"absolute"},children:he})}return D},Vn=c.useMemo(()=>y===!0||y?.horizontal===!0?Mn(!0):null,[st,y,Ee,j,I,C,R,r,i,Fe,_t,Kt]),Wn=c.useMemo(()=>y===!0||y?.vertical===!0?Mn(!1):null,[st,y,Te,j,I,C,T,r,i,J,Qe,Kt]),po=c.useMemo(()=>Ct.left===0?null:O.jsx(Vo,{linePoints:[0,0,0,J+1],bounds:{x:Ct.left,y:0,width:1,height:J+1},...ie}),[st,Ct.left,J,ie]),go=c.useMemo(()=>Ct.top===0?null:O.jsx(Vo,{linePoints:[0,0,Fe+1,0],bounds:{x:0,y:Ct.top,width:Fe+1,height:1},...B}),[st,Ct.top,Fe,B]),Rn=c.useMemo(()=>{const v=[],D=A=>{if(!A||!Le[A])return;const V=Le[A].getBounds();return O.jsxs("div",{style:{position:"absolute",pointerEvents:"none",left:V.x,top:V.y,width:V.width,height:V.height,clip:`rect(0, ${V.width+1}px, ${V.height+1}px, 0)`},className:`view view-${A}`,children:[Vn?.[A],Wn?.[A],Kt?.[A].cells]},`view:${A}`)};for(let A=0;A<Gt.length;A++)v.push(D(Gt[A]));return O.jsx(O.Fragment,{children:v})},[Le,Vn,Wn,Kt]),wo=c.useMemo(()=>{if(!t)return;const v=(le,me,ye,se)=>{if(!se||se.length===0)return;const $e=[];for(let at=0;at<se.length;at++){const je=se[at];let Ae=le?.get(je);Ae!==To&&(Ae=je(ye)??To),me.set(je,Ae),Ae&&Ae!==To&&$e.push(Ae)}return $e},D=(le,me,ye)=>{if(!ye)return;const se=ye.getBounds(),$e=ye.getInsets(),at=ye.getAnchor();return O.jsxs("div",{className:fn("view",`view-${at}`,Ar.view),style:{position:"absolute",pointerEvents:"none",left:se.x-$e.left,top:se.y-$e.top,width:se.width-($e.left+$e.right),height:se.height-($e.top+$e.bottom),clipPath:f?"inset(-2px)":"inset(0px)"},children:[v(le,me,ye,k),fo?.[at].overlays]},`view:${at}`)},A=tt.current,V={},W=[],he=Object.keys(Le);for(let le=0;le<he.length;le++){const me=he[le],ye=A?.[me],se=V[me]=new Map;W.push(D(ye,se,Le[me]))}return tt.current=V,W},[st,Le,f,k]),mo=c.useMemo(()=>{const{style:v,...D}=Z??{};return O.jsx("div",{style:{width:Fe,height:J,...v},className:"sheetxl-stage",tabIndex:0,ref:ze,...D,...Ke,children:q?q(Rn):Rn})},[Fe,J,Rn,Z,q]),Hn=c.useRef(!1);return c.useEffect(()=>{!Hn.current&&Kt&&(Hn.current=!0,we?.(un.current))},[Kt]),O.jsxs("div",{className:fn("sheetxl-grid",Ar["sheetxl-grid"]),style:{overflow:"visible",cursor:L,maxWidth:Fe,maxHeight:J,width:Fe,height:J,...be},ref:un,children:[mo,O.jsxs("div",{className:fn("sheetxl-overlays"),ref:lt,...E,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}]=bi(),w=n??u,x=o??d;return O.jsx("div",{className:i,style:{...r},children:O.jsx("div",{style:{position:"relative",top:"0px",left:"0px",width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",boxSizing:"content-box"},ref:s,children:O.jsx(Yo,{ref:t,width:w,height:x,...l})})})}));Go.displayName="Grid";const Ei=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]=c.useState(null),R=c.useRef(null),T=c.useRef(null);eo(!s),c.useImperativeHandle(t,()=>T.current&&R.current?Object.assign(T.current,R.current):null);const ce=c.useCallback(L=>{T.current?.scrollTo(L),u?.(L)},[]);return O.jsx(hi,{className:w,style:d,ref:R,showVerticalScrollbar:n,showHorizontalScrollbar:o,createHorizontalScrollbar:r,createVerticalScrollbar:i,createScrollCorner:l,viewport:y,onScrollViewport:ce,children:O.jsx(Go,{style:{width:"100%",height:"100%"},...p,onViewportChange:L=>C(L),ref:T})})}));Ei.displayName="ScrollableGrid";const Br=()=>!1,_i=c.memo(e=>{const{index:t,value:n,zoom:o,zoomScale:r=100,headerText:i=k=>`${k}`,headerStyle:l,headerStyleSelect:s=l,headerStyleSelectAll:u=s,headerStyleHover:d=u,verticalPadding:w=0,horizontalPadding:x=0,isSelected:p=Br,isSelectedAll:y=Br,coords:C,bounds:R,range:T,orientation:ce,view:L,style:I,...j}=e,ie=r/100,B=c.useRef(null),[ne,ve]=c.useState(!1),U=p?.(t)||!1,N=y?.(t)?u:U?s:l;let Y=N;if(ne){let k=d;typeof d=="function"&&(k=d(N)),Y=St.mergeContentful(N,k)}return O.jsx("div",{ref:B,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`,...I,left:I.left-(ce===Bt?1:0),top:I.top-(ce===en?1:0),width:I.width+1,height:I.height+1,overflow:"hidden"},...j,onMouseMove:k=>{ge.detectIt().primaryInput!=="touch"&&k.buttons===0&&ve(!0)},onMouseOut:k=>{ve(!1)},children:i(t)})});_i.displayName="HeaderRenderer";const Ci="ew-resize",Ii="ns-resize",Mi=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:C,headerStyleSelect:R,headerStyleSelectAll:T,headerStyleHover:ce,bounds:L,onPointerDown:I,onAutoFit:j,...ie}=e,B=n===Bt;let ne=C;x&&R&&(ne=R),p&&T&&(ne=T);const ve=ge.detectIt().primaryInput==="touch";let U=B?14:8,N=U/2,Y=0;d&&(Y=-2),w&&(Y=2),w&&(U=U/2+Y,N=2*Y);let k=ne.dividerStrokeFill??ne.strokeFill;return!(x||p)&&Y===0&&(k=`linear-gradient(${B?180:90}deg, ${ne.fill}, ${k} 55%, ${k} 100%)`),O.jsxs("div",{className:fn("header-divider",{disabled:s},i,`index-${r}`),ref:t,onPointerDown:ve?void 0:I,onDoubleClick:ve?void 0:()=>j?.(),style:{top:(B?0:-U/2+(Y-1))+"px",left:(B?-U/2+(Y-1):0)+"px",width:B?U:"calc(100% + 1px)",height:B?"calc(100% + 1px)":U,position:"absolute",overflow:"visible",pointerEvents:"all",cursor:s||u||ve?void 0:B?Ci:Ii,...l},...ie,children:[O.jsx("div",{style:{position:"relative",top:`${B?0:N}px`,left:`${B?N:0}px`,width:B?1:"100%",height:B?"100%":1,background:k},onDoubleClick:()=>j?.()}),y&&ve?O.jsx("div",{style:{position:"absolute",cursor:"grab",zIndex:1,borderRadius:"4px",right:B?"-6px":"2px",bottom:B?"2px":"-9px",height:"24px",width:B?"24px":"18px",maxHeight:B?"calc(100% - 4px)":void 0,maxWidth:B?void 0:"calc(100% - 4px)",background:ne.fill,border:`${T.edgeStrokeFill} solid 1px`,boxShadow:`0.5px 0.5px 0px 0px ${C.text.fill}`,display:"flex",alignItems:"center",justifyContent:"center"},onPointerDown:I,children:O.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(R.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:B?void 0:"rotate(90deg)"}})}):null]})})),ql=(e,t)=>O.jsx(Mi,{...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:C,onPointerDown:R,...T}=e,ce=P(R,[R]),L=P(C,[C]),I=n===Bt;let j=I?o.getVisibleColumns():o.getVisibleRows(),ie=null;j.length>0&&(I?ie=o.getRangeCoordsBounds({rowStart:0,rowEnd:0,colStart:j[0],colEnd:j[j.length-1]}):o.getRangeCoordsBounds({rowStart:j[0],rowEnd:j[j.length-1],colStart:0,colEnd:0}),ie=o.toClipBounds(ie,Wt));const B=c.useRef(null),[ne,ve]=c.useState(null),U=(z,K)=>I?z.clientX-K.clientX:z.clientY-K.clientY,N=o.getLayout(),Y=I?N.getColOffset(r+1):N.getRowOffset(r+1),k=vn({processTouch:!0,onPointerDown:z=>{if(ce?.(z),!i&&!l){const K=I?N.getColOffset(r):N.getRowOffset(r),Q=Y-K;B.current={isResizing:!1,startSize:Q,index:r,view:o,orientation:n,onDividerMouseDown:d,onDividerResizeStart:w,onDividerResize:x,onDividerResizeEnd:p,onDividerMouseUp:y},ve(B.current),d?.(r,Q)}z.stopPropagation(),z.preventDefault()},onPointerUp:(z,K,Q)=>{if(!B.current)return;B.current.isResizing&&B.current.onDividerResizeEnd?.(B.current.index,Math.max(0,B.current.startSize+U(z,Q)),B.current.startSize);const ee=B.current;B.current=null,ve(B.current),ee.onDividerMouseUp?.(ee.index)},onPointerMoveOrWait:(z,K,Q)=>{if(!B.current)return;const ee=U(z,Q);B.current.isResizing?B.current.onDividerResize?.(B.current.index,Math.max(0,B.current.startSize+ee),B.current.startSize):Math.abs(ee)>Math.max(1,s)&&(B.current={...B.current,isResizing:!0},ve(B.current),B.current.onDividerResizeStart?.(B.current.index,Math.max(0,B.current.startSize+ee))),z.stopPropagation(),z.preventDefault()}}),E=P(()=>{L?.(r)},[r]);if(!ie)return;const f=u({bounds:ie,orientation:n,view:o,index:r,disabled:i,disabledResize:l,onAutoFit:E,onPointerDown:k,...T},t);if(!f)return;const{getPortalContainer:Z}=fi();let q=null;return ne&&ne.isResizing&&ne.index===r&&(q=No.createPortal(O.jsx("div",{style:{position:"absolute",cursor:I?Ci:Ii,left:0,top:0,width:"100%",height:"100%"}}),Z(),"divider:"+r)),O.jsxs(O.Fragment,{children:[q,O.jsx("div",{className:fn("header-divider-anchor"),style:{position:"absolute",pointerEvents:"auto",top:`${I?ie.y:Y}px`,left:`${I?Y:ie.x}px`,width:(I?0:ie.width-1)+"px",height:(I?ie.height-1:0)+"px",display:"flex"},tabIndex:-1,children:f})]})}));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(`
19
- `);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 Ri=(e=void 0)=>Object.freeze({clean:e,dirty:void 0,editMode:!1}),Gl=Ri(),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:C,...R}=e,T=c.useRef(null),{width:ce=0}=d??{},[L,I]=c.useState(()=>n);c.useEffect(()=>{I(n)},[n]);const j=p?.align||"left",ie=p?.vAlign||"middle",B=p?.fill||"#040404",ne=p?.wrap||"wrap",ve=p?.fontFamily||"Calibri",U=p?.fontSize||11,N=p?.fontWeight||400,Y=p?.fontStyle||"normal",k=L.dirty??L.clean??"";let E=2;const f=96*U/72,Z=1.2*f;ie==="right"&&(E+=1);const q=c.useMemo(()=>new Yl().naturalDimensions(k,{maxWidth:ne==="wrap"?ce-E:void 0,lineHeight:`${Z}px`,paintableText:{fontStyle:Y,wrap:ne,letterSpacing:-.25}}),[k,ne,E,f,ve,N,Y,w,ce]),z=c.useCallback(()=>q.maxLineHeight?q.maxLineHeight+"px":"1.2",[q]),[K,Q]=c.useState(z);c.useLayoutEffect(()=>{Q(z())},[d,q]),c.useLayoutEffect(()=>{w?.({width:ne==="wrap"?void 0:q.width+E,height:q.height})},[q,w]);const ee=P(i,[i]),X=P(_=>{if(L.dirty===_)return;const Ce={...L};Ce.dirty=_,T.current,I(Ce),ee?.(Ce)},[L]),Ve=P(_=>{if(L.editMode===_)return;const Ce={...L};Ce.editMode=_,I(Ce),ee?.(Ce)},[L]),Be=P(()=>{try{return l?.(L),u?.(),!0}catch{return!1}},[l,L]),We=P(()=>{I(n),s?.(),u?.()},[s,n]),it=P(_=>{if(!T.current)return;if(_.isDefaultPrevented(),!(_.isTrusted||_.nativeEvent.ctrlKey||_.nativeEvent.metaKey||_.nativeEvent.altKey||_.nativeEvent.isComposing)&&qo.indexOf(_.nativeEvent.key)!==-1){const ue={...L};return ue.dirty=_.nativeEvent.key==="Backspace"?"":(ue.dirty??"")+_.key,I(ue),ee?.(ue),void _.preventDefault()}const Ce=_.nativeEvent.shiftKey;if(_.which===Xi)return _.preventDefault(),void We();if(_.which===Yi)return Ve(!0),void _.preventDefault();if(_.which===Qr&&(_.preventDefault(),Be()&&x?.(Ce?nt:ot)),_.which===Jr)return _.preventDefault(),void(Be()&&x?.(Ce?et:Ne));if(!L.editMode){let ue=null;switch(_.which){case ei:ue=et;break;case ni:ue=Ne;break;case ti:ue=nt;break;case oi:ue=ot}if(ue)return void Be()}},[L,x]),[be,Ke]=c.useState(!C);c.useEffect(()=>{Ke(!1)},[]);const $=lo(t,()=>({startEdit(_){let Ce=_?.initialSelection;if(!Ce){const we=T.current.value.length??0;Ce={start:we,end:we,direction:"forward"}}T.current?.setSelectionRange(Ce.start,Ce.end,Ce.direction);const ue={...n,editMode:_?.editMode??!1};_?.text!==void 0&&(ue.dirty=_.text),ue.editMode===n.editMode&&ue.dirty===n.dirty||(I(ue),ee?.(ue))},submitEdit:()=>Be(),cancelEdit(){We()},autoFocus(){T.current?.focus()},getLineHeight:()=>q?.maxLineHeight??Z,dispatchEvent:_=>T.current.dispatchEvent(_)}),[n,r]);return O.jsx("div",{ref:$,...R,style:{background:"transparent",display:"flex",flexGrow:1,alignSelf:"center",height:q.height,maxWidth:"100%",maxHeight:"100%",...y},children:O.jsx("textarea",{spellCheck:"false",ref:T,value:k,autoFocus:!1,disabled:be,name:"cell-editor",autoComplete:"off",autoCapitalize:"off",style:{flex:"1 1 100%",position:"relative",fontSize:`${f}px`,fontFamily:`${ve}`,fontWeight:`${N}`,fontStyle:`${Y}`,padding:"0px",marginRight:j==="right"?"3px":"0px",marginLeft:j==="left"?"2px":"0px",lineHeight:K,height:q.height,textRendering:"geometricPrecision",letterSpacing:"-0.25px",boxSizing:"border-box",borderWidth:0,outline:"none",resize:"none",overflow:"hidden",verticalAlign:"baseline",textAlign:j,background:"transparent",color:B,marginBottom:"0px",userSelect:"text",maxHeight:"100%",whiteSpace:ne==="wrap"?"break-spaces":"pre",wordWrap:"break-word"},onChange:_=>{X(_.target.value)},onDoubleClick:_=>{_.isTrusted},onMouseDown:_=>{Ve(!0)},onKeyDown:it})})})),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 O.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=Mi,exports.FillHandle=Wo,exports.Grid=Go,exports.HeaderDivider=Xl,exports.HeaderRenderer=_i,exports.RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL=150,exports.SELECTION_CLIP_INSETS=Wt,exports.STANDARD_KEY_CHARS=qo,exports.SVGLine=Vo,exports.SVGRect=xi,exports.ScrollableGrid=Ei,exports.Selection=Xo,exports.TouchSelectHandle=Qn,exports.defaultSelectionRenderer=zr,exports.getDefaultStringEditState=Ri,exports.safeSelectionCoords=$t,exports.useCellLayout=mi,exports.useHeaderSelection=({gridRef:e,gridMainRef:t,orientation:n=en,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:C,clearSelections:R})=>{const T=o??((n===en?e.current?.rowCount:e.current?.columnCount)||0),ce=c.useRef(null),L=c.useRef(null),I=c.useRef(!1),j=c.useRef(null),ie=c.useCallback(E=>n===Bt?{rowIndex:0,colIndex:E.colIndex}:{rowIndex:E.rowIndex,colIndex:0},[n]),B=c.useCallback(E=>n===Bt?{rowIndex:t.current?t.current.rowCount-1:0,colIndex:E.colIndex}:{rowIndex:E.rowIndex,colIndex:t.current?t.current.columnCount-1:0},[n]),ne=E=>{L.current=B(E),y(L.current,ce.current)},ve=c.useCallback((E,f)=>{if(!e.current)return;const Z=e.current.getViewFromClient(E,f)?.getCellCoordsFromClient(E,f);return Z?(n===Bt?Z.rowIndex=t.current.getViewport().rowStart:Z.colIndex=t.current.getViewport().colStart,Z):void 0},[]),U=c.useCallback((E,f=!1)=>{let Z=E;return f||(Z={...E},n===en?delete Z.colIndex:delete Z.rowIndex),t.current?.scrollCellCoordsIntoView(Z)},[n]),N=P(u,[u]),Y=P(s,[s]),k=c.useMemo(()=>({onPointerDown:E=>{if(!e||!e.current||E.nativeEvent.defaultPrevented)return;const f=ve(E.nativeEvent.clientX,E.nativeEvent.clientY);if(!f)return;E.nativeEvent.which;const Z=E.nativeEvent.shiftKey,q=E.nativeEvent.ctrlKey||E.nativeEvent.metaKey;if(d?.(E,f)===!1)return;Y?.(),I.current=!0;const z=t.current?.getViewFromClient(E.nativeEvent.clientX,E.nativeEvent.clientY),K=((Q,ee)=>n===Bt?{...Q,rowIndex:ee.rowStart}:{...Q,colIndex:ee.colStart})(f,z.getVisibleRangeCoords());if(Z)ne(f);else{if(q)return((Q,ee=Q,X)=>{ce.current=ie(Q),L.current=B(ee),C(ce.current,L.current,X)})(f,f,K),void(l&&U(K,!0));((Q,ee=Q,X)=>{ce.current=ie(Q),L.current=B(ee),p(ce.current,L.current,X)})(f,f,K),ne(f),l&&U(K,!0)}},onPointerMoveOrWait:St.throttle(E=>{if(!I.current||!e?.current)return;const f=ve(E.clientX,E.clientY);if(f&&w?.(E,f)!==!1){if(G.isEqualCells(j.current,f))return R();ne(f),U(f)}},60),onPointerUp:E=>{I.current=!1,N?.(),x?.(E)},processTouch:!0,consumeTouch:!0}),[r,l,T,i,R,d,x]);return{onPointerDown:P(vn(k),[]),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:C=null,activeCoords:R,alignment:T=On.Left}=e,[ce,L]=c.useState(!1),[I,j]=c.useState(void 0),ie=P(($,_,Ce,ue,we,ze)=>{if(!_)return null;const lt=we?.(_,$),It=$.getRangeCoordsBounds(lt),st=$.toClipBounds(It),Ut=It,xt=$.getZoom();if(!st)return null;Ce&&(Ce*=xt),ue&&(ue*=xt);let M=Ut,xe=!1;if(Ce!==void 0){let Ge={...lt},Qt=0;for(;!xe&&M.width<=Ce&&Qt<20;){Qt++,Qt>19&&console.warn("max width reached");const Yt=$.getTotalRangeCoords(),Et=$.getLayout();ze===On.Left?Ge.colEnd+1<Yt.colEnd?Ge.colEnd=Et.getColIndex(M.x+Ce):xe=!0:ze===On.Right?Ge.colStart-1>=0?Ge.colStart=Et.getColIndex(M.x-(Ce-M.width)):xe=!0:ze===On.Center&&Ge.colEnd+1<Yt.colEnd&&Ge.colStart-1>=0?(Ge.colStart=Et.getColIndex(M.x-(Ce-M.width)/2),Ge.colEnd=Et.getColIndex(M.x+M.width+(Ce-M.width)/2)):xe=!0,xe||(M=$.getRangeCoordsBounds(Ge))}}M.height=Ut.height,ue!==void 0&&(M.height=Math.max(ue+1,Ut.height));const{width:Ye,height:ft}=$.getViewportSize();return{x:M.x??0,y:M.y??0,height:Math.min(ft-M.y,M.height)+1,width:Math.min(Ye-M.x,M.width)+1}},[T]),B=P(n,[n]),ne=c.useCallback(()=>{t?.getStage()?.focus()},[t]),ve=c.useRef(null),U=P($=>{r?.($),ee(),L(!0),ve.current=null},[r]),N=P($=>{i?.($.coords)},[i]),Y=P($=>{$.isSubmitted||$.isCancelled||(f.current.isEditorClosed=!0,ne(),$.isCancelled=!0,s?.($.coords),ee())},[s]),k=P($=>{if($.isSubmitted||$.isCancelled)return!1;try{return ve.current=$.coords,$.isEditorClosing=!0,$.isSubmitted=!0,$.isEditorSubmitted||($.isEditorSubmitted=!0,$.editorRefs[0]?.submitEdit?.()),$.coords,l?.($.coords),$.isEditorClosed=!0,ne(),ee(),!0}catch(_){throw $.isEditorClosing=!1,$.isSubmitted=!1,_}},[l]),E=P($=>{L(!1),u?.($.coords),ee()},[u]),f=c.useRef(null),Z=c.useRef(null),q=c.useRef(null),z=c.useRef([]),[K,Q]=c.useReducer($=>$+1,0),ee=c.useCallback($=>{$&&z.current.push($),Q()},[]),X=P($=>{if($.defaultPrevented||$.isSynthetic||!t)return;const _=t?.getCellCoordsFromClient($.clientX,$.clientY);_&&ee({eventType:"pointer",event:$,coords:_})},[t]),Ve=P($=>{const _=$.nativeEvent;X(_)},[t]),Be=P($=>{if($.defaultPrevented||$.isSynthetic||!t?.getStage())return;const _=Z.current;d($,_)&&($.stopPropagation(),$.preventDefault()),$.key,ee({eventType:"keyboard",event:$,coords:_})},[t]);c.useLayoutEffect(()=>{const $=(ue,we)=>{const ze=we?.cell??ue;if(!ze)return null;const lt=ze;if(!B(ze))return null;U?.(ze);const It=St.uuidV4();we=Object.freeze({autoFocus:!0,...we}),q.current=ze;const st={coords:lt,startEvent:we,uuid:It,isMounted:!1,isStarted:!1,isSubmitted:!1,isEditorSubmitted:!1,isEditorClosing:!1,isEditorClosed:!1,isCancelled:!1,events:[],editorRefsDispatchEditorEvent:[],editorRefs:[],onMount:Ut=>{st.isMounted||(st.isMounted=!0,ee())},onUnmount:Ut=>{if(st.editorRefs.length===0){const xt=()=>{st.isMounted=!1,ee()};if(document.activeElement!==document.body)xt();else{const M=xe=>{xe.defaultPrevented||xe.target!==document.body||Be(xe)};window.addEventListener("keydown",M,!0),t.getStage()?.addEventListener("focusin",()=>{window.removeEventListener("keydown",M),xt()},{once:!0}),ne()}}}};return st};if(z.current.length<=0&&!f.current)return;const _=z.current[0];Rr(_),(ue=>{const we=[],ze=ue?.length??0;for(let lt=0;lt<ze;lt++){const It=ue[lt];we.push(Rr(It))}})(z.current),f.current,f.current;let Ce=f.current;if(f.current){if(f.current.isDone)f.current=null;else if(f.current.isSubmitted||f.current.isCancelled){if(f.current.isMounted)return;f.current.isDone||(E(f.current),f.current.isDone=!0)}}if(_){if(_.eventType==="start"){const ue=_,we=ue.startEvent?.cell??Z.current;f.current&&G.isEqualCells(f.current.coords,we)||(f.current=$(we,ue.startEvent))}else if(_.eventType==="keyboard"){const ue=_.event;if(f.current){let we=!1;switch(ue.which){case ei:case ni:case ti:case oi:case Qr:case Jr:we=!0}if(!we){f.current.events.push(_);for(let ze=0;ze<f.current.editorRefsDispatchEditorEvent.length;ze++)f.current.editorRefsDispatchEditorEvent[ze](_)}}else if(d(ue,_.coords)){let we;const ze=$(we?.cell??Z.current,we);ze&&ze.events.push(_),f.current=ze}}else if(_.eventType==="pointer"){const ue=_.event;if(f.current){f.current.events.push(_);for(let we=0;we<f.current.editorRefsDispatchEditorEvent.length;we++)f.current.editorRefsDispatchEditorEvent[we](_)}else{const we=_?.coords??Z.current,ze=w(ue,we);if(ze){let lt;typeof lt!="boolean"&&(lt=ze);const It=$(we,lt);It&&It.events.push(_),f.current=It}}}else if(_.eventType==="submit"){if(f.current&&!f.current.isSubmitted&&!f.current.isCancelled){if(!f.current.isMounted)return;k(f.current)}}else if(_.eventType==="cancel"){if(f.current&&!f.current.isSubmitted&&!f.current.isCancelled){if(!f.current.isMounted)return;Y(f.current)}}else if(_.eventType==="coordsChange"){const ue=_;if(Z.current=ue.activeCoords,f.current,f.current&&!f.current.isSubmitted&&!f.current.isCancelled){if(!f.current.isMounted)return;try{k(f.current)}catch{}}}}z.current.length>0&&(z.current.shift(),ee()),z.current.length===0&&(!f.current||f.current.isEditorClosing||f.current.isEditorClosed?!f.current&&Ce&&ne():f.current.isMounted&&!f.current.isStarted&&(f.current.isStarted=!0,f.current.startEvent.autoFocus&&(typeof f.current.startEvent.autoFocus=="string"?f.current.editorRefs[0]?.autoFocus(f.current.startEvent.autoFocus):f.current.editorRefs[0]?.autoFocus()),N?.(f.current),requestAnimationFrame(()=>{t&&f.current?.coords&&t.scrollCellCoordsIntoView(f.current.coords)})))},[K]),c.useEffect(()=>{q.current=R;const $=f.current?.coords;G.isEqualCells($,R)||(f.current&&(f.current.isEditorClosing=!0),ee({eventType:"coordsChange",activeCoords:R}))},[R]);const We=c.useCallback($=>{Be($.nativeEvent)},[]),{width:it=0,height:be=0}=I??{width:0,height:0},Ke=P(o,[o]);return{overlay:P($=>{if(!f.current||f.current.isEditorClosed)return f.current,null;f.current.coords;let _=ie($,f.current.coords,it,be,C,T),Ce=!0;_&&_.width!==0&&_.height!==0||(_={x:0,y:0,width:it,height:it},Ce=!1);const ue=$.getZoom(),we={containerBounds:{x:0,y:0,width:_.width/ue,height:_.height/ue},setNaturalDimensions:j,zoom:ue};return O.jsx(Dl,{session:f.current,refLatestCoords:q,handleSubmitEdit:k,handleCancelEdit:Y,cellBounds:_,borderStrokeWidth:y,borderStrokeFill:p,isInBounds:Ce,getCellEditor:Ke,propsEditor:we,alignment:T,...x},"editor:"+f.current.uuid)},[o,C,K,it,be,T,y,p]),startEdit:c.useCallback($=>{ee({eventType:"start",startEvent:$})},[]),submitEdit:c.useCallback(()=>{ee({eventType:"submit"})},[]),cancelEdit:c.useCallback(()=>{ee({eventType:"cancel"})},[]),onKeyboardEvent:We,onPointerEvent:Ve,onKeyboardEventNative:Be,onPointerEventNative:X,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:C=!y,fillHandleBorderColor:R="white",hiddenRowsAt:T,hiddenColumnsAt:ce,isContentfulCell:L,contentfulCellFinder:I=Al,getDataCoords:j,alwaysScrollToActiveCoords:ie=!1,selectionBounds:B,pointerDownInterceptor:ne,pointerMoveInterceptor:ve,mergedRanges:U,canSelectionSpanMergedCells:N=Hl,onMoveDragStart:Y,onMoveDragUpdate:k,onMoveDragEnd:E,onMoveDragDone:f,selectionRenderer:Z=zr,disableMoveDrag:q=!E,getCellCoordsAsRangeCoords:z=G.cellToRange,moveDragHitSize:K=6,moveDragOutlineSize:Q=4,selectionBackgroundColor:ee="rgba(16, 124, 65, 0.1)",selectionBorderColor:X="rgb(33, 115, 70)",selectionRemoveBorderColor:Ve="rgb(255, 0, 0)",selectionRemoveBackgroundColor:Be="rgba(250, 10, 10, 0.1)",disableTouchSelection:We=!1,touchSelectHandleProps:it})=>{const be=c.useCallback(()=>({top:B?.top??0,left:B?.left??0,bottom:e.current?.rowCount-1||0,right:e.current?.columnCount-1||0}),[]),Ke=P(y,[y]),$=P(w,[w]),_=P(x,[x]),Ce=P(p,[p]),ue=P(L,[L]),we=P(Z,[Z]),ze=P((a,h=!1)=>io(a,h,n.getRowOffset,h?be().bottom:be().top),[n?.getRowOffset]),lt=P(T??ze,[T]),It=P((a,h=!1)=>io(a,h,n.getColOffset,h?be().right:be().left),[n?.getColOffset]),st=P(ce??It,[ce]),[Ut,xt]=c.useState(()=>$t(o)),M=c.useMemo(()=>$t(Ut),[Ut]),xe=c.useRef(M),Ye=c.useRef(!0);c.useLayoutEffect(St.throttle(()=>{xt(a=>{Ye.current=!0;const h=$t(o);return G.isEqualSelectionCoords(h,a)?a:h})},0),[o]),c.useLayoutEffect(()=>{xe.current=M},[M]),c.useEffect(()=>{Ye.current||!r||G.isEqualSelectionCoords(o,M)||r(M)},[M]);const ft=c.useCallback(a=>{xt(h=>{Ye.current=!1,h=$t(h);let m=typeof a=="function"?a(h.ranges):a??Ho;if(G.isEqualRangesArrays(m,h.ranges))return h;let g=Math.max(m.length?0:-1,Math.min(h.rangeIndex,m.length-1)),b=h.cell;g===-1||G.isCellWithinRange(b,m[g])||(b={rowIndex:m[g].rowStart,colIndex:m[g].colStart}),m.length===1&&G.isSingleCell(m[0])&&G.isCellWithinRange(b,m[0])&&(m=[],g=-1);const H={cell:b,ranges:m,rangeIndex:g};return G.isEqualSelectionCoords(H,h)?h:H})},[]),Ge=P(a=>{xt(h=>{Ye.current=!1,h=$t(h);const m=a??Si,g=z(m);if(!G.isSingleCell(g)&&h.ranges.length===0)return{ranges:[g],rangeIndex:0,cell:m};if(G.isEqualCells(m,h.cell))return h;let b=h.ranges,H=h.rangeIndex;h.ranges.length===1&&(G.isSingleCell(h.ranges[0])&&G.isCellWithinRange(m,h.ranges[0])||!G.isCellWithinRange(m,h.ranges[0]))&&(b=[],H=-1);const S={ranges:b,rangeIndex:H,cell:m};return G.isEqualSelectionCoords(S,h)?h:S})},[z]),[Qt,Yt]=c.useState(null),[Et,tn]=c.useState(null),Xt=c.useRef(null),[Oe,Ft]=c.useState(null),pt=c.useRef(null),jt=c.useRef(null),[wn,nn]=c.useState(null),Fe=c.useRef(null),J=c.useRef(null),Ze=c.useRef(U);c.useEffect(()=>{Ze.current=U},[U]);const He=P((a,h={inline:"nearest",block:"nearest"})=>{let{rowIndex:m,colIndex:g}=a;m===void 0&&M?.cell&&(m=M.cell.rowIndex),g===void 0&&M?.cell&&(g=M.cell.colIndex),m!==void 0&&g!==void 0&&e.current?.scrollCellCoordsIntoView({rowIndex:m,colIndex:g},h)},[M]),ct=c.useCallback(a=>{const h=be();return a.rowIndex<h.top||a.colIndex<h.left||a.colIndex>h.right||a.rowIndex>h.bottom},[]),Ee=P((a,h)=>{if(!e?.current)return null;const m={rowStart:Math.min(a.rowIndex,h.rowIndex),colStart:Math.min(a.colIndex,h.colIndex),rowEnd:Math.max(a.rowIndex,h.rowIndex),colEnd:Math.max(a.colIndex,h.colIndex)};if(N?.(m))return m;const b=z(a),H=z(h),S={rowStart:Math.min(b.rowStart,H.rowStart),colStart:Math.min(b.colStart,H.colStart),rowEnd:Math.max(b.rowEnd,H.rowEnd),colEnd:Math.max(b.colEnd,H.colEnd)};let de;return typeof Ze.current=="function"?de=Ze.current(S):U&&(de=U),de?G.extendRangeToUnionRanges(S,de):S},[N,z]),Te=P((a,h,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(h.rowIndex??g.rowStart,m.rowIndex??g.rowStart),colStart:Math.min(h.colIndex??g.colStart,m.colIndex??g.colStart),rowEnd:Math.max(h.rowIndex??g.rowEnd,m.rowIndex??g.rowEnd),colEnd:Math.max(h.colIndex??g.colEnd,m.colIndex??g.colEnd)},H={rowIndex:b.rowStart,colIndex:b.colStart},S={rowIndex:b.rowEnd,colIndex:b.colEnd};if(!(ct(H)||ct(S)))return Ee(H,S)},[Ee]),tt=P((a,h,m)=>{if(s==="single"||!xe.current)return;const g=Te(xe.current,a,h??xe.current.cell);if(!g)return;const b=xe.current.rangeIndex;ft(H=>H.length?H.map((S,de)=>b===de?g:S):[g]),m&&g&&Ge({colIndex:g.colStart,rowIndex:g.rowStart})},[]),Je=c.useCallback((a,h,m)=>{if(!xe.current)return;a={...xe.current?.cell,...a},h=h??a;const g=Te(xe.current,a,h);if(!g)return;const b={rowIndex:g.rowStart,colIndex:g.colStart},H={...b,...m};u==="clear"?(Fe.current=H,Gt()):u==="modify"?tt(b):Le(b),Ge(H)},[]),Le=c.useCallback((a,h=a,m)=>{s!=="multiple"||!a||ct(a)||ct(h)||xt(g=>{Ye.current=!1,g=$t(g);const b=Ee(a,h);if(!b)return g;let H=g.ranges.length>0?[...g.ranges]:[Ee(g.cell,g.cell)];H.push(b);const S={ranges:H,cell:{rowIndex:b.rowStart,colIndex:b.colStart,...m},rangeIndex:H.length-1};return G.isEqualSelectionCoords(S,g)?g:S})},[]),Gt=()=>{ft(Ho)},_t=ge.detectIt().primaryInput==="touch",Qe=c.useRef(null),Ct=c.useRef(null),Rt=c.useRef(null),on=c.useMemo(()=>({onPointerDown:a=>{if(!e||!e.current)return!1;const h=a.nativeEvent,m=e.current.getViewFromClient(h.clientX,h.clientY);if(h.pointerType==="touch"||h.type==="touchstart")return Ct.current={topLeft:m.getScrollTopLeft(),point:{x:h.clientX,y:h.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&&G.indexOfCoords(g,M.ranges)!==-1)return!1;const H=a.nativeEvent.shiftKey,S=a.nativeEvent.ctrlKey||a.nativeEvent.metaKey,de=S,te=d,oe=M.ranges.length>0,pe=S&&te;if(ne?.(a,g,M)===!1)return!1;i?.(xe.current,a.nativeEvent);const Pe=!b&&s!=="single";if(H)return tt(g),Pe;const ae=G.isEqualCells(g,M.cell);if(de){if(ae&&(!pe||!oe))return Pe;if(S&&G.indexOfCoords(g,M.ranges)!==-1&&te){pt.current=g;const re=Ee(g,g);return jt.current=re,Ft(re),Pe}return Le(g),Pe}ie&&He(g),ae&&M.ranges.length===0||Je(g)},onPointerMoveOrWait:St.throttle((a,h)=>{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(!G.isEqualCells(b,Qe.current?.coords)&&(Qe.current={anchor:m,coords:b},b&&ve?.(a,b,xe.current)!==!1)){if(pt.current){const H={rowStart:Math.min(b.rowIndex,pt.current.rowIndex),colStart:Math.min(b.colIndex,pt.current.colIndex),rowEnd:Math.max(b.rowIndex,pt.current.rowIndex),colEnd:Math.max(b.colIndex,pt.current.colIndex)},S={rowIndex:H.rowStart,colIndex:H.colStart},de={rowIndex:H.rowEnd,colIndex:H.colEnd};if(ct(S)||ct(de))return;const te=Ee(S,de);jt.current=te,Ft(te)}else tt(b);Rt.current=h,Gn(g,b,e)}},60),onPointerUp:a=>{if(Qe.current=null,a.pointerType==="touch"||a.type==="touchend"){if(Ct.current){const m=e.current.getViewFromClient(Ct.current.point.x,Ct.current.point.y),g=m.getScrollTopLeft();if(g.left===Ct.current.topLeft.left&&g.top===Ct.current.topLeft.top){const b=m.getCellCoordsFromClient(Ct.current.point.x,Ct.current.point.y);Je(b)}}return Ct.current=null,void(Qe.current=null)}try{l?.(xe.current,a)}catch(m){console.warn(m)}if(!pt.current)return;const h=jt.current;pt.current=null,jt.current=null,Ft(null),xt(m=>{if(Ye.current=!1,(m=$t(m)).ranges.length===0)return m;let g=[],b=-1,H=m.cell;for(let de=0;de<m.ranges.length;de++){const te=m.ranges[de];if(G.isRangesIntersect(te,h)){const oe=St.subtractRect({top:te.rowStart,left:te.colStart,bottom:te.rowEnd+1,right:te.colEnd+1},{top:h.rowStart,left:h.colStart,bottom:h.rowEnd+1,right:h.colEnd+1});for(let pe=0;pe<oe.length;pe++){const Pe={rowStart:oe[pe].top,colStart:oe[pe].left,rowEnd:oe[pe].bottom-1,colEnd:oe[pe].right-1};g.push(Pe),G.isCellWithinRange(m.cell,Pe)&&(b=g.length-1)}}else g.push(te);g.length>0&&b===-1&&G.isCellWithinRange(m.cell,te)&&(b=g.length-1,H={rowIndex:g[g.length-1].rowStart,colIndex:g[g.length-1].colStart})}const S={cell:H,rangeIndex:b,ranges:g};return G.isEqualSelectionCoords(S,m)?m:S})},processTouch:!0,consumeTouch:!1}),[M,s,d,ie,u]),so=P(vn(on),[]),co=c.useMemo(()=>({onSelectionPointerDown:(a,h,m,g,b=M.cell,H=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 pe=a.nativeEvent.which===yr;if(pe&&G.indexOfCoords(oe,M.ranges)!==-1)return!1;const Pe=a.nativeEvent.ctrlKey||a.nativeEvent.metaKey,ae=Pe,re=d,vt=M.ranges.length>0,F=Pe&&re;if(ne?.(a,oe,M)===!1)return!1;i?.(xe.current,a.nativeEvent);const Re=!pe&&s!=="single";if(S)return tt(oe,b,de),Re;const Mt=G.isEqualCells(oe,b);if(ae){if(Mt&&(!F||!vt))return Re;if(F&&G.indexOfCoords(oe,M.ranges)!==-1&&re){pt.current=oe;const Me=Ee(oe,oe);return jt.current=Me,Ft(Me),Re}return Le(oe),Re}H&&He(oe),Mt&&M.ranges.length===0||Je(oe)},onSelectionPointerMoveOrWait:(a,h,m,g,b,H=M.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),pe=b??oe.getCellCoordsFromClient(a.clientX,a.clientY);if(!G.isEqualCells(pe,Qe.current?.coords)&&(Qe.current={anchor:te,coords:pe},pe&&ve?.(a,pe,xe.current)!==!1)){if(pt.current){const Pe={rowStart:Math.min(pe.rowIndex,pt.current.rowIndex),colStart:Math.min(pe.colIndex,pt.current.colIndex),rowEnd:Math.max(pe.rowIndex,pt.current.rowIndex),colEnd:Math.max(pe.colIndex,pt.current.colIndex)},ae={rowIndex:Pe.rowStart,colIndex:Pe.colStart},re={rowIndex:Pe.rowEnd,colIndex:Pe.colEnd};if(ct(ae)||ct(re))return;const vt=Ee(ae,re);jt.current=vt,Ft(vt)}else tt(pe,H,de);S&&Gn(oe,pe,e)}},onPointerUp:a=>{Qe.current=null,a.stopPropagation(),a.preventDefault(),a.stopImmediatePropagation();try{l?.(xe.current,a)}catch(m){console.warn(m)}if(!pt.current)return;const h=jt.current;pt.current=null,jt.current=null,Ft(null),xt(m=>{if(Ye.current=!1,(m=$t(m)).ranges.length===0)return m;let g=[],b=-1,H=m.cell;for(let de=0;de<m.ranges.length;de++){const te=m.ranges[de];if(G.isRangesIntersect(te,h)){const oe=St.subtractRect({top:te.rowStart,left:te.colStart,bottom:te.rowEnd+1,right:te.colEnd+1},{top:h.rowStart,left:h.colStart,bottom:h.rowEnd+1,right:h.colEnd+1});for(let pe=0;pe<oe.length;pe++){const Pe={rowStart:oe[pe].top,colStart:oe[pe].left,rowEnd:oe[pe].bottom-1,colEnd:oe[pe].right-1};g.push(Pe),G.isCellWithinRange(m.cell,Pe)&&(b=g.length-1)}}else g.push(te);g.length>0&&b===-1&&G.isCellWithinRange(m.cell,te)&&(b=g.length-1,H={rowIndex:g[g.length-1].rowStart,colIndex:g[g.length-1].colStart})}const S={cell:H,rangeIndex:b,ranges:g};return G.isEqualSelectionCoords(S,m)?m:S})}}),[M,s,d,ie,u]),ut=P((a,h=!1,m=!1,g=0)=>{if(!e.current||!M.cell)return;let b=M.cell,H=M.cell;if(h&&M.ranges.length>0){const F=M.ranges[M.rangeIndex],Re=M.cell;switch(a){case nt:H={rowIndex:Re.rowIndex===F.rowStart?F.rowEnd:F.rowStart,colIndex:F.colEnd},b={rowIndex:Re.rowIndex===F.rowStart?F.rowStart:F.rowEnd,colIndex:F.colStart};break;case ot:H={rowIndex:Re.rowIndex===F.rowEnd?F.rowStart:F.rowEnd,colIndex:F.colEnd},b={rowIndex:Re.rowIndex===F.rowEnd?F.rowEnd:F.rowStart,colIndex:F.colStart};break;case et:H={rowIndex:F.rowEnd,colIndex:Re.colIndex===F.colStart?F.colEnd:F.colStart},b={rowIndex:F.rowStart,colIndex:Re.colIndex===F.colStart?F.colStart:F.colEnd};break;case Ne:H={rowIndex:F.rowEnd,colIndex:Re.colIndex===F.colEnd?F.colStart:F.colEnd},b={rowIndex:F.rowStart,colIndex:Re.colIndex===F.colEnd?F.colEnd:F.colStart}}}const S=z(H);let{rowStart:de,colStart:te}=S;const oe=be();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 Ne:J.current.rowIndex>=S.rowStart&&J.current.rowIndex<=S.rowEnd&&(de=J.current.rowIndex)}if(!g){switch(a){case nt:de=Ue(lt,Math.max(S.rowStart-1,oe.top),a);break;case ot:de=Ue(lt,Math.min(S.rowEnd+1,oe.bottom),a);break;case et:te=Ue(st,Math.max(S.colStart-1,oe.left),a);break;case Ne:te=Ue(st,Math.min(S.colEnd+1,oe.right),a)}if(m)switch(a){case nt:de=I({...H,colIndex:M.cell.colIndex},ue,lt,a,!1,Math.max(oe.top,lt(oe.top,!1)));break;case ot:de=I({...H,colIndex:M.cell.colIndex},ue,lt,a,!1,Math.min(oe.bottom,oe.bottom-lt(oe.bottom,!0)));break;case et:te=I({...H,rowIndex:M.cell.rowIndex},ue,st,a,!1,Math.max(oe.left,st(oe.left,!1)));break;case Ne:te=I({...H,rowIndex:M.cell.rowIndex},ue,st,a,!1,Math.min(oe.right,oe.right-st(oe.right,!0)))}}let pe=null;if(g){let F=0;switch(a){case nt:F=n.getRowOffset(de+1),de=Math.max(oe.top,n.getRowIndex(F-g)),pe={top:n.getRowOffset(de+1)-(F-e.current.getScrollPosition().top)};break;case ot:F=n.getRowOffset(de),de=Math.min(oe.bottom,n.getRowIndex(F+g)),pe={top:n.getRowOffset(de)-(F-e.current.getScrollPosition().top)};break;case et:F=n.getColOffset(te+1),te=Math.max(oe.left,n.getColIndex(F-g)),pe={left:n.getColOffset(te+1)-(F-e.current.getScrollPosition().left)};break;case Ne:F=n.getColOffset(te),te=Math.min(oe.right,n.getColIndex(F+g)),pe={left:n.getColOffset(te)-(F-e.current.getScrollPosition().left)}}}const Pe={rowIndex:de,colIndex:te},ae=z(Pe),re={rowIndex:ae.rowStart,colIndex:ae.colStart};h||(J.current=Pe);const vt=G.isEqualCells(Fe.current,re)&&G.isEqualCells(Fe.current,b);if(h&&!vt?tt(re,b):Je(re),pe)e.current.scrollTo(pe);else{if(h&&Fe.current){const F=be();if(a===Ne&&Fe.current.colIndex===F.left||a===et&&Fe.current.colIndex===F.right||a===nt&&Fe.current.rowIndex===F.bottom||a===ot&&Fe.current.rowIndex===F.top)return}a===et||a===Ne?He({colIndex:Pe.colIndex}):a!==nt&&a!==ot||He({rowIndex:Pe.rowIndex})}},[M,z]),Zt=P(a=>{if(!e.current)return;if(M.ranges.length===0)return void ut(a);const h=z(M.cell);if(G.isEqualRangesArrays([h],M.ranges))return void ut(a);const m=Fo(M,a,z,lt,st);xt(g=>{Ye.current=!1,g=$t(g);const b={...g,cell:m.cell,rangeIndex:m.rangeIndex};return G.isEqualSelectionCoords(b,g)?g:b}),m.cell&&He(m.cell)},[M,z]),ao=c.useCallback(()=>{const a=be();tt({rowIndex:a.top},{rowIndex:a.bottom})},[]),uo=c.useCallback(()=>{const a=be();tt({colIndex:a.left},{colIndex:a.right})},[]),an=P(()=>{M.cell&&e?.current&&He(M.cell)},[M.cell]),An=c.useCallback((a=!1)=>{const h={rowIndex:be().top};a?tt(h):Je(h),He(h)},[]),$n=c.useCallback((a=!1)=>{const h={rowIndex:be().bottom};a?tt(h):Je(h),He(h)},[]),_n=c.useCallback((a=!1)=>{const h={colIndex:be().left};a?tt(h):Je(h),He(h)},[]),mn=c.useCallback((a=!1)=>{const h=be(),m={rowIndex:h.top,colIndex:h.left};a?tt(m):Je(m),He(m)},[]),Cn=c.useCallback((a=!1)=>{const h=be(),m={colIndex:j?.()?.colEnd??h.right};a?tt(m):Je(m),He(m)},[j]),un=c.useCallback((a=!1)=>{const h=be(),m={rowIndex:j?.()?.rowEnd??h.bottom,colIndex:j?.()?.colEnd??h.right};a?tt(m):Je(m),He(m)},[j]),In=P(a=>{if(!e.current||M.ranges.length<=1)return;const h=a===et||a===nt;let m=M.rangeIndex+(h?-1:1);m<0?m=M.ranges.length-1:m>M.ranges.length-1&&(m=0);const g=M.ranges[m],b=Fo({cell:{rowIndex:g.rowEnd,colIndex:g.colEnd},rangeIndex:0,ranges:[g]},Ne,z,lt,st);xt(H=>{Ye.current=!1,H=$t(H);const S={...H,cell:b.cell,rangeIndex:m};return G.isEqualSelectionCoords(S,H)?H:S}),b.cell&&He(b.cell)},[M,z]),ho=P(()=>{const a=Pr(M);xt(h=>{Ye.current=!1,h=$t(h);const m={...h,visibleSelection:a};return G.isEqualSelectionCoords(m,h)?h:m}),a.cell&&He(a.cell)},[M,z]),fo=P(()=>{if(!e.current||M.ranges.length===0)return;const a=M.cell,h=M.ranges[M.rangeIndex],m=Pr({cell:a,rangeIndex:0,ranges:[h]}),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},xt(H=>{H=$t(H);const S={...H,cell:b};return G.isEqualSelectionCoords(S,H)?H:S}),b&&He(b)},[M,z]),Bn=c.useCallback((a=!1)=>{ut(ot,a,!1,e.current.getDimensions().containerHeight)},[]),Kt=c.useCallback((a=!1)=>{ut(nt,a,!1,e.current.getDimensions().containerHeight)},[]),Fn=c.useCallback((a=!1)=>{ut(Ne,a,!1,e.current.getDimensions().containerWidth)},[]),Mn=c.useCallback((a=!1)=>{ut(et,a,!1,e.current.getDimensions().containerWidth)},[]),Vn=c.useCallback(()=>{Zt(et)},[]),Wn=c.useCallback(()=>{Zt(Ne)},[]),po=c.useCallback(()=>{Zt(nt)},[]),go=c.useCallback(()=>{Zt(ot)},[]),Rn=c.useCallback(()=>{In(et)},[]),wo=c.useCallback(()=>{In(Ne)},[]),mo=c.useCallback(()=>{fo()},[]),Hn=c.useCallback(()=>{ut(et,!1,!1)},[]),v=c.useCallback(()=>{ut(et,!0,!1)},[]),D=c.useCallback(()=>{ut(et,!1,!0)},[]),A=c.useCallback(()=>{ut(et,!0,!0)},[]),V=c.useCallback(()=>{ut(Ne,!1,!1)},[]),W=c.useCallback(()=>{ut(Ne,!0,!1)},[]),he=c.useCallback(()=>{ut(Ne,!1,!0)},[]),le=c.useCallback(()=>{ut(Ne,!0,!0)},[]),me=c.useCallback(()=>{ut(nt,!1,!1)},[]),ye=c.useCallback(()=>{ut(nt,!0,!1)},[]),se=c.useCallback(()=>{ut(nt,!1,!0)},[]),$e=c.useCallback(()=>{ut(nt,!0,!0)},[]),at=c.useCallback(()=>{ut(ot,!1,!1)},[]),je=c.useCallback(()=>{ut(ot,!0,!1)},[]),Ae=c.useCallback(()=>{ut(ot,!1,!0)},[]),dt=c.useCallback(()=>{ut(ot,!0,!0)},[]),qe=c.useCallback(()=>{ft(a=>a.slice(0,-1))},[]),kt=c.useMemo(()=>{const a=be();return((h,m,g,b,H)=>{for(let S=0;S<h.length;S++){const de=h[S];if(de.rowStart===m&&de.colStart===g&&de.rowEnd===b&&de.colEnd===H)return!0}return!1})(M.ranges,a.top,a.left,a.bottom,a.right)},[B,M.ranges]),gt=c.useCallback((a,h=!0)=>{Fe.current=a,Ge(a),h&&a&&e?.current&&He(a)},[]),fe=P((a=!0)=>{const h=Xt.current;if(!xe.current?.cell)return;const m=xe.current?.ranges,g=xe.current?.cell;if(!g||!h||!h)return;let b=null;if(b=m.length>0?m[m.length-1]:z(g),b.colEnd>=b.colStart&&b.rowEnd>=b.rowStart){const H=Or(b,h);let S=a?Ke:$;try{S?.(b,h,H.direction)}catch(de){console.warn(de)}finally{a&&Ce?.()}}},[z]),ht=c.useRef(null),Ot=vn(c.useMemo(()=>({onPointerDown:(a,h)=>{if(Rt.current=h,!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(),Yt("crosshair"),ht.current={anchor:m.getAnchor(),coords:g})},onPointerMoveOrWait:(a,h)=>{if(C||!e?.current||!xe.current||!ht.current)return;const m=ht.current.anchor;let g=e.current.getViewFromLocation(m),b=g.getCellCoordsFromClient(a.clientX,a.clientY);if(!b)return;ht.current={anchor:m,coords:b};const H=xe.current.ranges;let S=Ee(xe.current.cell,b);if(!S)return;const de=H.length>0,te=de?H[H.length-1]:z(xe.current.cell);if(!S)return;const oe=S.rowStart<te.rowStart?nt:S.rowEnd>te.rowEnd?ot:S.colEnd>te.colEnd?Ne:et,pe=be();oe===et&&(S={...te,colStart:Math.max(pe.left,S.colStart)}),oe===nt&&(S={...te,rowStart:Math.max(pe.top,S.rowStart)}),oe===Ne&&(S={...te,colEnd:Math.min(pe.right,S.colEnd)}),oe===ot&&(S={...te,rowEnd:Math.min(pe.bottom,S.rowEnd)});const Pe=Or(te,S);if(!N?.(te)){let ae;typeof Ze.current=="function"?ae=Ze.current(te):U&&(ae=U),S=((re,vt,F,Re,Mt,Me)=>{const Ie={...vt};if(F.length===0)return Ie;if(Mt===et){const mt=re.colEnd+1-re.colStart;Ie.colStart=re.colStart-Math.ceil(Me/mt)*mt,Ie.colStart<Re.left&&(Ie.colStart=Ie.colStart+Math.ceil((Re.left-Ie.colStart)/mt)*mt)}else if(Mt===Ne){const mt=re.colEnd+1-re.colStart;Ie.colEnd=re.colEnd+Math.ceil(Me/mt)*mt,Ie.colEnd>Re.right&&(Ie.colEnd=Ie.colEnd-Math.ceil((Re.right-Ie.colEnd)/mt)*mt)}else if(Mt===nt){const mt=re.rowEnd+1-re.rowStart;Ie.rowStart=re.rowStart-Math.ceil(Me/mt)*mt,Ie.rowStart<Re.top&&(Ie.rowStart=Ie.rowStart+Math.ceil((Re.top-Ie.rowStart)/mt)*mt)}else if(Mt===ot){const mt=re.rowEnd+1-re.rowStart;Ie.rowEnd=re.rowEnd+Math.ceil(Me/mt)*mt,Ie.rowEnd>Re.bottom&&(Ie.rowEnd=Ie.rowEnd-Math.ceil((Re.bottom-Ie.rowEnd)/mt)*mt)}return Ie})(te,S,ae,pe,Pe.direction,Pe.amount)}if(de&&G.isRangeWithinRange(S,te)&&(S=null),!G.isEqualRanges(S,Xt.current)){if(tn(S),Xt.current=S,!S){try{_?.()}catch{}return void Ce?.()}fe(!1)}Rt.current=h,Gn(g,b,e)},onPointerUp:(a,h)=>{Rt.current=h,Promise.resolve(fe(!0)).finally(()=>{Ce?.(),tn(null),Xt.current=null,ht.current=null,Yt(null),e.current?.focus()})}}),[z])),At=c.useMemo(()=>({onPointerDown:Ot}),[Ot]),[_e,Xe]=c.useState(null),De=c.useRef(null),rt=c.useMemo(()=>({onPointerDown:(a,h)=>{if(Rt.current=h,!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,M)===!1)return!1;a.stopPropagation(),Yt("default");const b=m.getRelativePointFromClient(0,0),H=xe.current?.ranges[xe.current?.ranges.length-1]??G.cellToRange(xe.current?.cell),S=m.toClipBounds(m.getRangeCoordsBounds(H)),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?.(H,a.nativeEvent,h),De.current={range:H,anchor:m.getAnchor(),cell:g,isMoving:!1,extrusion:de}},onPointerMoveOrWait:(a,h,m)=>{if(q||!e?.current||!xe.current||!De.current)return;const g=a.clientX-m.clientX,b=a.clientY-m.clientY;if(De.current.isMoving=De.current.isMoving||Math.abs(g)>Math.max(1,2)||Math.abs(b)>Math.max(1,2)||performance.now()-m.timeStamp>500,!De.current.isMoving)return;const H=De.current.anchor,S=De.current.extrusion;let de=e.current.getViewFromLocation(H),te=de.getCellCoordsFromClient(a.clientX-S.x,a.clientY-S.y,!0);if(!te)return;const oe=De.current.cell,pe=De.current.range,Pe=be(),ae=pe.colEnd-pe.colStart+1,re=Math.min(Math.max(0,oe.colIndex-pe.colStart),ae-1),vt=Math.min(Pe.right-ae+1,Math.max(Pe.left,te.colIndex-re)),F=pe.rowEnd-pe.rowStart+1,Re=Math.min(Math.max(0,oe.rowIndex-pe.rowStart),F-1),Mt=Math.min(Pe.bottom-F+1,Math.max(Pe.top,te.rowIndex-Re)),Me={colStart:vt,colEnd:vt+ae-1,rowStart:Mt,rowEnd:Mt+F-1};G.isEqualRanges(_e,Me)&&!(Ie=>!Ie||!Rt.current||Rt.current.ctrlKey!==Ie.ctrlKey||Rt.current.shiftKey!==Ie.shiftKey||Rt.current.altKey!==Ie.altKey||Rt.current.metaKey!==Ie.metaKey)(a)||(Xe(Me),k?.(Me,a,h)),Rt.current=h,Gn(de,te,e)},onPointerUp:(a,h)=>{Rt.current=h;const m=()=>{Xe(null),De.current=null,Yt(null),e.current?.focus()};if(!De.current)return void m();const g=De.current.range,b=_e;E?.(g,a,h),Promise.resolve(g&&b&&f?.(g,b,a,h)).finally(()=>{m()})}}),[_e]),ke=vn(rt),yt=c.useMemo(()=>({onPointerDown:ke}),[ke]),wt=c.useRef(null),Lt=c.useMemo(()=>{const a=G.isEqualSelectionCoords(M,wt.current)?wt.current:M;return wt.current=a,a},[M]),Vt=c.useCallback(a=>{let h=null,m="br";const g=[],b={stroke:R,fill:ee,strokeWidth:.5},H=(ae,re,vt)=>{const F=a.toClipBounds(a.getRangeCoordsBounds(ae),Wt);if(!F)return;F.x=F.width>0?F.x:F.x-b.strokeWidth/2,F.y=F.height>0?F.y:F.y-b.strokeWidth/2,F.width=Math.max(F.width,b.strokeWidth),F.height=Math.max(F.height,b.strokeWidth);const Re={key:`selection-fill-${re}`,range:ae,...F,...b};if(vt){const Mt=a.getCellCoordsAsRangeCoords(vt);Re.cell=vt,Re.pathBounds=a.toClipBounds(a.getRangeCoordsBounds(Mt),Wt),Re.pathBounds&&(Re.pathBounds.width<=0||Re.pathBounds.height<=0)&&(delete Re.pathBounds,delete Re.cell)}return we(Re)};let S=M?$t(M):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=H(re,ae,ae===S.rangeIndex?S.cell:null);vt&&g.push(vt);const F=2,Re=.5,Mt=a.toClipBounds(a.getRangeCoordsBounds(re,{top:0,left:0,right:0,bottom:0}),Wt);if(Mt){const Me=(S.ranges.length,4);g.push(we({range:re,key:`selection-inside-edge-${ae}`,x:Mt.x-1,y:Mt.y-1,width:Math.max(Mt.width+1,0),height:Math.max(Mt.height+1,0),style:{overflow:"hidden"},stroke:R,strokeWidth:Me}))}if(S.ranges.length===1){const Me=a.toClipBounds(a.getRangeCoordsBounds(re),Wt);if(Me){q||g.push(we({range:re,key:`move-selection-hit-box-${ae}`,x:Me.width>1?Me.x:Me.x-(K/2+1),y:Me.height>1?Me.y:Me.y-(K/2+1),width:Math.max(Me.width+2,1),height:Math.max(Me.height+2,1),stroke:"transparent",style:{boxShadow:"none"},pathProps:{cursor:_e?void 0:"move",pointerEvents:"stroke"},strokeWidth:K,...yt}));const Ie=F;g.push(we({range:re,key:`selection-single-${ae}`,x:Me.x-Ie/2,y:Me.y-Ie/2,width:Math.max(Me.width+Ie/2,1),height:Math.max(Me.height+Ie/2,1),stroke:X,strokeWidth:Ie}))}}else{const Me=a.toClipBounds(a.getRangeCoordsBounds(re,{top:-1,left:-1,right:-2,bottom:-2}),Wt);Me&&g.push(we({range:re,key:`selection-multi-${ae}`,x:Me.width>1?Me.x:Me.x-Re/2,y:Me.height>1?Me.y:Me.y-Re/2,width:Math.max(Me.width,Re)+1,height:Math.max(Me.height,Re)+1,stroke:X,style:{overflow:"hidden"},strokeWidth:2}))}if(S.ranges.length>1&&ae===S.rangeIndex){const Me=a.getCellCoordsAsRangeCoords(S.cell),Ie=a.toClipBounds(a.getRangeCoordsBounds(Me,{top:1,left:1,right:-1,bottom:-1}),Wt);Ie&&g.push(we({range:re,key:`selection-anchor-${ae}`,x:Ie.x,y:Ie.y,width:Math.max(Ie.width,Re),height:Math.max(Ie.height,Re),stroke:X,style:{overflow:"hidden"},strokeWidth:2}))}if(ae===S.ranges.length-1){h=null,m=null;const Me=re.rowStart===be().top&&re.rowEnd===be().bottom,Ie=re.colStart===be().left&&re.colEnd===be().right,mt=a.getRangeCoordsBounds(re);let qt=null;if(Me||Ie){if(qt=a.toClipBounds(mt,Wt),Object.keys(a.allViews()).length>1){const Nn=a.getVisibleRangeCoords(),Zo=a.allViews()[to],ki=a.allViews()[Ln],Ti=a.allViews()[Dn],Un=a.getAnchor();(Ie&&(Un===Ln&&Zo||Un===Ht&&Ti||!G.isCellWithinRange({colIndex:re.colStart,rowIndex:re.rowEnd},Nn)&&!G.isCellWithinRange({colIndex:re.colStart,rowIndex:re.rowEnd+1},Nn))||Me&&(Un===Dn&&Zo||Un===Ht&&ki||!G.isCellWithinRange({colIndex:re.colEnd,rowIndex:re.rowStart},Nn)&&!G.isCellWithinRange({colIndex:re.colEnd+1,rowIndex:re.rowStart},Nn)))&&(qt=null)}}else qt=a.toClipBounds(mt,Wt);if(!qt||qt.width===0||qt.height===0)continue;h={x:qt.x+qt.width+1,y:qt.y+qt.height+1},qt.width===0||qt.height===0||re.rowStart===be().top&&re.colStart===be().left&&re.rowEnd===be().bottom&&re.colEnd===be().right||(Me?(h.y=F,m="tr"):Ie&&(h.x=F,m="bl"))}}let te=null;if(Oe){const ae=a.toClipBounds(a.getRangeCoordsBounds(Oe,{top:0,left:0,right:0,bottom:0}),Wt);ae&&(te=we({...b,range:Oe,key:"remove-selection",x:ae.x,y:ae.y,width:ae.width,height:ae.height,strokeWidth:2,stroke:Ve,fill:Be}))}let oe=null;if(Et){const ae=a.toClipBounds(a.getRangeCoordsBounds(Et,{top:0,left:0,right:0,bottom:0}),Wt);ae&&(oe=we({range:Et,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:X,strokeDasharray:"3 2"}))}let pe=null;!C&&h&&!_e&&(pe=c.createElement(Wo,{...h,corner:m,size:7.5,borderStroke:`${R} solid`,style:{borderRadius:1},background:X,...At,key:"fillHandle"}));const Pe=[...g];if(te&&Pe.push(te),oe&&Pe.push(oe),pe&&Pe.push(pe),!We&&_t&&S?.ranges.length===1&&S.ranges[S.ranges.length-1]){const ae=S.ranges[S.ranges.length-1],re=ae.rowStart===be().top&&ae.rowEnd===be().bottom,vt=ae.colStart===be().left&&ae.colEnd===be().right,F={view:a,range:ae,borderStroke:`${X} solid`,background:R,selectionTouchPointerHandler:co,...it,onTouchSelectStart:Re=>nn(Re),onTouchSelectEnd:()=>nn(null),currentTouchAnchor:wn};Pe.push(O.jsx(Qn,{anchor:vt?"b":re?"r":"br",scrollableElement:e.current,...F},"touch-select-handle-after")),Pe.push(O.jsx(Qn,{anchor:vt?"t":re?"l":"tl",scrollableElement:e.current,...F},"touch-select-handle-before"))}if(_e){const ae=a.toClipBounds(a.getRangeCoordsBounds(_e,{top:1,left:1,right:1,bottom:1}),Wt);ae&&Pe.push(we({range:_e,key:"selection-move-outline",x:ae.x-Q/2,y:ae.y-Q/2,width:Math.max(ae.width+Q/2,1),height:Math.max(ae.height+Q/2,1),stroke:X,style:{boxShadow:"none",transitionDuration:"70ms",transitionTimingFunction:"ease-in",transitionProperty:"left, top, width, height",willChange:"left, top, width, height"},strokeWidth:Q}))}return O.jsx("div",{children:Pe},"selection")},[Lt,Oe,C,Et,q,_e,be,R,X,ee,Ve,Be,We,it,wn]),Tt=c.useMemo(()=>{const a=()=>e.current;return[new Se("moveToPageDown",a,{label:"Page Down",description:"Shift viewport down one page.",shortcut:[{key:"PageDown"}]},()=>Bn(!1)),new Se("selectToPageDown",a,{label:"Select To Page Down",description:"Shift viewport and select down one page.",shortcut:[{key:"PageDown",modifiers:[bt]}]},()=>Bn(!0)),new Se("moveToPageRight",a,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[dn]}]},()=>Fn(!1)),new Se("selectToPageRight",a,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[dn,bt]}]},()=>Fn(!0)),new Se("moveToPageUp",a,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp"}]},()=>Kt(!1)),new Se("selectToPageUp",a,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp",modifiers:[bt]}]},()=>Kt(!0)),new Se("moveToPageLeft",a,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[dn]}]},()=>Mn(!1)),new Se("selectToPageLeft",a,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[dn,bt]}]},()=>Mn(!0)),new Se("selectColumn",a,{label:"Select Column",description:"Select the columns for the selected cells.",shortcut:{key:"Space",modifiers:[Pt]}},ao),new Se("selectRow",a,{label:"Select Row",description:"Select the rows for the selected cells.",shortcut:{key:"Space",modifiers:[bt]}},uo),new Se("selectToColumnStart",a,{label:"Select To Column Start",description:"Select the columns to the beginning of the sheet."},()=>An(!0)),new Se("selectToColumnEnd",a,{label:"Select To Column End",description:"Select the columns to the end of the sheet."},()=>$n(!0)),new Se("moveToRowStart",a,{label:"Move to Row Home",description:"Move to the beginning of the row.",shortcut:[{key:"Home"}]},()=>_n(!1)),new Se("selectToRowStart",a,{label:"Select to Row Home",description:"Select to the beginning of the row.",shortcut:[{key:"Home",modifiers:[bt]}]},()=>_n(!0)),new Se("moveToSheetStart",a,{label:"Move to Sheet Home",description:"Move to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[Pt]}]},()=>mn(!1)),new Se("selectToSheetStart",a,{label:"Select to Sheet Home",description:"Select to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[Pt,bt]}]},()=>mn(!0)),new Se("moveToRowEnd",a,{label:"Move to Row End",description:"Move to the end of the row.",shortcut:[{key:"End"}]},()=>Cn(!1)),new Se("selectToRowEnd",a,{label:"Select to Row End",description:"Select to the end of the row.",shortcut:[{key:"End",modifiers:[bt]}]},()=>Cn(!0)),new Se("moveToSheetEnd",a,{label:"Move to Sheet End",description:"Move to the end of the sheet.",shortcut:[{key:"End",modifiers:[Pt]}]},()=>un(!1)),new Se("selectToSheetEnd",a,{label:"Select to Sheet End",description:"Select to the end of the sheet.",shortcut:[{key:"End",modifiers:[Pt,bt]}]},()=>un(!0)),new Se("scrollToActiveCoords",a,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell.",shortcut:{key:"Backspace",modifiers:[Pt]}},an),new Se("scrollToActiveCoordsClearSelection",a,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell and clear selection.",shortcut:{key:"Backspace",modifiers:[bt]}},()=>{Gt(),gt(M.cell,!0)}),new Se("traverseSelectionRight",a,{label:"Traverse Right",description:"Traverse the selection moving rightward.",shortcut:{key:"Tab"}},Wn),new Se("traverseSelectionLeft",a,{label:"Traverse Left",description:"Traverse the selection moving leftward.",shortcut:{key:"Tab",modifiers:[bt]}},Vn),new Se("traverseSelectionDown",a,{label:"Traverse Down",description:"Traverse the selection moving downward.",shortcut:[{key:"Enter"},{key:"NumpadEnter"}]},go),new Se("traverseSelectionUp",a,{label:"Traverse Up",description:"Traverse the selection moving upward.",shortcut:[{key:"Enter",modifiers:[bt]},{key:"NumpadEnter",modifiers:[bt]}]},po),new Se("moveLeft",a,{label:"Move Left",description:"Move active cell to the left.",shortcut:[{key:"ArrowLeft"}]},Hn),new Se("selectLeft",a,{label:"Select Left",description:"Extend selection left.",shortcut:[{key:"ArrowLeft",modifiers:[bt]}]},v),new Se("moveContentfulLeft",a,{label:"Move Left Contentful",description:"Move left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[Pt]}]},D),new Se("selectContentfulLeft",a,{label:"Select Left Contentful",description:"Extend selection left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[Pt,bt]}]},A),new Se("moveRight",a,{label:"Move Right",description:"Move active cell to the right.",shortcut:[{key:"ArrowRight"}]},V),new Se("selectRight",a,{label:"Select Right",description:"Extend selection right.",shortcut:[{key:"ArrowRight",modifiers:[bt]}]},W),new Se("moveContentfulRight",a,{label:"Move Right Contentful",description:"Move right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[Pt]}]},he),new Se("selectContentfulRight",a,{label:"Select Right Contentful",description:"Extend selection right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[Pt,bt]}]},le),new Se("moveUp",a,{label:"Move Up",description:"Move active cell to the up.",shortcut:[{key:"ArrowUp"}]},me),new Se("selectUp",a,{label:"Select Up",description:"Extend selection up.",shortcut:[{key:"ArrowUp",modifiers:[bt]}]},ye),new Se("moveContentfulUp",a,{label:"Move Up Contentful",description:"Move up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[Pt]}]},se),new Se("selectContentfulUp",a,{label:"Select Up Contentful",description:"Extend selection up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[Pt,bt]}]},$e),new Se("moveDown",a,{label:"Move Down",description:"Move active cell to the down.",shortcut:[{key:"ArrowDown"}]},at),new Se("selectDown",a,{label:"Select Down",description:"Extend selection down.",shortcut:[{key:"ArrowDown",modifiers:[bt]}]},je),new Se("moveContentfulDown",a,{label:"Move Down Contentful",description:"Move down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[Pt]}]},Ae),new Se("selectContentfulDown",a,{label:"Select Down Contentful",description:"Extend selection down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[Pt,bt]}]},dt),new Se("selectVisible",a,{label:"Select Visible",description:"Select visible cells only.",shortcut:{key:";",modifiers:[dn]}},ho),new Se("traverseSelectionPreviousRange",a,{label:"Traverse Previous Range",description:"Traverse the selection to the previous range.",shortcut:{key:"ArrowLeft",modifiers:[Pt,dn]}},Rn),new Se("traverseSelectionNextRange",a,{label:"Traverse Next Range",description:"Traverse the selection to the next range.",shortcut:{key:"ArrowRight",modifiers:[Pt,dn]}},wo),new Se("traverseSelectionCorners",a,{label:"Traverse Corners",description:"Traverse the selection through the corners of the selected range.",shortcut:{key:".",modifiers:[Pt]}},mo)]},[]);return c.useMemo(()=>{t?.addCommands(Tt,!0)},[t]),{selection:Lt,setSelectionCell:gt,setSelectionRanges:ft,overlay:Vt,cursor:Qt,onPointerDown:so,clearLastSelection:qe,newSelection:Je,modifySelection:tt,appendSelection:Le,clearSelections:Gt,isEntire:kt,navigate:ut,navigateSelection:Zt}};
18
+ }`,le=document.createElement("style");return le.appendChild(document.createTextNode(j)),document.head.appendChild(le),le.sheet.insertRule(j,0),()=>{document.head.removeChild(le)}},[y]),y&&(I={strokeDasharray:`${R.dashLength}px ${R.dashGap}px`,strokeDashoffset:`${C}px`,animation:`${O} ${L}ms linear infinite`,willChange:"stroke-dashoffset"}),P.jsx(mi,{x:o,y:r,width:i,height:l,stroke:t,fill:n,shapeRendering:"crispEdges",style:{...I,...s},...h})});function xi(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=xi(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=xi(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:p,...x}=e;if(n===0||o===0)return null;let h=!0,y=!0,R=!0,C=!0;switch(s){case"tl":h=!1,y=!1;break;case"bl":h=!1,C=!1;break;case"br":R=!1,C=!1;break;case"tr":y=!1,R=!1}return P.jsx("div",{className:fn("fill-handle",d),style:{position:"absolute",left:n-(i+(h?r:0))/2,top:o-(i+(y?r:0))/2,width:i,height:i,borderLeft:h?`${r}px ${l}`:void 0,borderTop:y?`${r}px ${l}`:void 0,borderRight:R?`${r}px ${l}`:void 0,borderBottom:C?`${r}px ${l}`:void 0,background:p,cursor:"crosshair",pointerEvents:"all",transitionDuration:"0ms",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top",willChange:"left, top",...u},tabIndex:-1,...x})}));Wo.displayName="FillHandle";var $l=function(){},yi=typeof window<"u",Bl=yi?c.useLayoutEffect:c.useEffect,jr={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const bi=yi&&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,p=u.y,x=u.width,h=u.height,y=u.top,R=u.left,C=u.bottom,L=u.right;i({x:d,y:p,width:x,height:h,top:y,left:R,bottom:C,right:L})}})},[]);return Bl(function(){if(t)return l.observe(t),function(){l.disconnect()}},[t]),[n,r]}:function(){return[$l,jr]};function ko(e,t){if(typeof e=="function")return e(t);e&&(e.current=t)}var Fl=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:p,selectionTouchPointerHandler:x,onTouchSelectStart:h,onTouchSelectEnd:y,currentTouchAnchor:R,scrollableElement:C,scrollableRoot:L=document.body,...J}=e,O=T(h,[h]),I=T(y,[y]),{bounds:j,coordsPivot:le,key:B}=c.useMemo(()=>{if(!n||!o)return null;let q=null,z=null;switch(r){case"tl":q={colIndex:n.colEnd,rowIndex:n.rowEnd},z={colIndex:n.colStart,rowIndex:n.rowStart};break;case"br":q={colIndex:n.colStart,rowIndex:n.rowStart},z={colIndex:n.colEnd,rowIndex:n.rowEnd};break;case"t":case"l":q={colIndex:n.colEnd,rowIndex:n.rowEnd};break;case"b":q={colIndex:n.colStart,rowIndex:n.rowStart};break;case"r":q={colIndex:n.colStart,rowIndex:n.rowEnd}}let K=o.getRangeCoordsBounds(z?{rowStart:z.rowIndex,colStart:z.colIndex,rowEnd:z.rowIndex,colEnd:z.colIndex}:n);const ee=o.getBounds(),te=o.getViewportSize(),X=ee.x,Ve=ee.y,Be=te.width,We=te.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=Be/2-X;break;case"b":K.x=Be/2-X,K.y=K.y+K.height;break;case"l":K.y=We/2-Ve;break;case"r":K.x=K.x+K.width,K.y=We/2-Ve}const it=o.toClipBounds(K,0);return!it||it.width<=0||it.height<=0||K.x<0||K.y<0||K.x>Be||K.y>We?{bounds:null,coordsAnchor:null,coordsPivot:null,key:null}:{bounds:K,coordsAnchor:null,coordsPivot:q,key:"touchSelect-"+o.getAnchor()+"-"+r}},[n,o,r]),oe=c.useRef(null),be=bn(c.useMemo(()=>{const q=z=>r==="t"||r==="b"?{...z,colIndex:void 0}:r==="l"||r==="r"?{...z,rowIndex:void 0}:z;return{processTouch:!0,consumeTouch:!0,onPointerDown:(z,K)=>{const ee=q(o.getCellCoordsFromClient(z.clientX,z.clientY));return oe.current={coordsPivot:le},O?.(r),x.onSelectionPointerDown(z,K,o,ee,le,!1,!0)},onPointerMoveOrWait:(z,K,ee)=>{const te=q(o.getCellCoordsFromClient(z.clientX,z.clientY));return x.onSelectionPointerMoveOrWait(z,K,ee,o,te,oe.current?.coordsPivot,!0,!0)},onPointerUp:(z,K,ee)=>(oe.current=null,I?.(r),x.onPointerUp(z,K,ee))}},[x,n,o,r])),[U,{y:N,x:Y}]=bi(),k=c.useRef(null),{getPortalContainer:E}=hi(),[g,Z]=c.useState(null);return c.useEffect(()=>{const q=k.current?.getBoundingClientRect();if(!q||!j)return void Z(null);let z=0,K=0,ee=C;for(;ee;)z+=ee.scrollLeft,K+=ee.scrollTop,ee=L&&ee===L.parentElement?null:ee.parentElement;Z(No.createPortal(P.jsx("div",{className:fn("touch-select-handle",p),ref:t,style:{position:"absolute",left:z+(q?.x??0)-(u+s)/2,top:K+(q?.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:R?0:1,transitionDuration:"160ms",transitionProperty:"opacity",...d},tabIndex:-1,onPointerDown:be,...J}),L??E(),B))},[N,Y,j?.x,j?.y,j?.width,j?.height,p,R,l,u,s,i,C]),j?P.jsxs(P.Fragment,{children:[P.jsx("div",{ref:Fl([U,k]),style:{position:"absolute",left:j.x,top:j.y,opacity:0}}),g]}):null}));Qn.displayName="TouchSelectHandle";const Wt=-10,Vl=Object.freeze({rowStart:0,colStart:0,rowEnd:0,colEnd:0}),vi=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=vi),G.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)},Wl=()=>!1;function eo(e,t){if(!e)throw new Error("Invariant failed")}const Ar={"sheetxl-grid":"_sheetxl-grid_h9wwa_7"},Hl=Object.freeze({top:0,left:0}),Nl=Object.freeze({bottom:-4,right:-4}),Ul=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:p,onViewportScroll:x,onImmediateScroll:h,showGridLines:y=!0,gridLineColor:R="rgb(224, 224, 224)",gridLineRowsProps:C,gridLineColumnsProps:L,clipCells:J=!0,cursor:O,freezeLeft:I=0,freezeTop:j=0,freezeLeftProps:le,freezeTopProps:B,cellRenderer:oe,onViewportChange:be,onFirstRender:U,overlayRenderer:N,overlayProps:Y,overlays:k,overlaysProps:E,allowOverlaysOverflow:g=!1,stageProps:Z,stageWrapper:q=null,hiddenRowsAt:z,hiddenColumnsAt:K,hiddenCellAt:ee,getVisibleCells:te,zoom:X=1,enableMouseWheel:Ve=!0,onWheelScroll:Be,getCellCoordsAsRangeCoords:We=G.cellToRange,scrollPoint:it=Hl,style:ve={},...Ke}=e;eo(oe),eo(!e?.children);const $=T(h,[h]),_=T(be,[be]),Ce=T(x,[x]),ue=T(Be,[Be]),we=T(U,[U]),ze=c.useRef(null),lt=c.useRef(null),It=c.useRef(null),[st,Ut]=c.useReducer(b=>b+1,0),[xt,M]=c.useState({left:it?.left??0,top:it?.top??0,horizontalScrollDirection:null,verticalScrollDirection:null}),xe=c.useRef(null),Ye=c.useRef(xt),{top:ft,left:Ge,verticalScrollDirection:Qt,horizontalScrollDirection:Yt}=xt,Et=c.useRef(!1),tn=wi({rowCount:r,columnCount:i,defaultRowHeight:l,defaultColumnWidth:s,getRowHeight:u,getColumnWidth:d}),Xt=c.useRef(null),Oe=c.useMemo(()=>{const b=p||tn;return Xt.current=null,{getColOffset:D=>b.getColOffset(D)*X,getColIndex:D=>b.getColIndex(D/X),getRowOffset:D=>b.getRowOffset(D)*X,getRowIndex:D=>b.getRowIndex(D/X)}},[tn,p,X]),Ft=(b,D,A)=>{const V=(D?.left??0)+0,W=(D?.top??0)+0;return{getColOffset:he=>b.getColOffset(he)-V,getColIndex:he=>b.getColIndex(he+V),getRowOffset:he=>b.getRowOffset(he)-W,getRowIndex:he=>b.getRowIndex(he+W)}},pt=c.useCallback((b,D=!1)=>io(b,D,Oe.getRowOffset,D?0:r),[r,Oe?.getRowOffset]),jt=T(z??pt,[z]),wn=c.useCallback((b,D=!1)=>io(b,D,Oe.getColOffset,D?i:0),[i,Oe?.getColOffset]),nn=T(K??wn,[K]),Fe=c.useMemo(()=>Math.min(n??800,Oe.getColOffset(i)),[Oe.getColOffset,i,n]),Q=c.useMemo(()=>Math.min(o??600,Oe.getRowOffset(r)),[Oe.getRowOffset,r,o]),Ze=c.useCallback(b=>{St.canUseDOM&&setTimeout(()=>{ze.current?.focus({preventScroll:!0,...b})},0)},[]),He=c.useCallback(b=>ze.current?.contains(b)||lt.current?.contains(b),[]);c.useEffect(()=>{Et.current&&(xe.current&&xe.current.left!==Ye.current?.left&&xe.current.top!==Ye.current?.top||(xe.current=null,Ce?.({left:Ge,top:ft})))},[Ge,ft]);const ct=T(()=>({top:ft,left:Ge}),[ft,Ge]),Ee=c.useMemo(()=>{const b=[];let D=0,A=0;typeof j=="number"?D=j:(D=j.index??0,A=(j.scrollOffset??0)*X);const V=A,W=Oe.getRowOffset(D),he=W-V;if(D>0){const at=Ft(Oe,{top:A+Oe.getRowOffset(0)}),je=Oe.getRowIndex(V),Ae=Oe.getRowIndex(W-1);let dt;b[1]={minIndex:je,maxIndex:Ae,minCoord:0,maxCoord:D-1,minBounds:0,maxBounds:he,visibleIndices:()=>dt||(dt=Object.freeze(Yn(jt,je,Ae)),dt),layout:at,maxVirtualBounds:W,scrollOffset:A,freezeOffset:A}}const se=Math.max(0,Q-he),me=Ft(Oe,{top:ft+he}),ye=me.getRowIndex(0),ce=me.getRowIndex(se);let $e;return b[0]={minIndex:ye,maxIndex:ce,minCoord:D,maxCoord:r-1,minBounds:he,maxBounds:se,visibleIndices:()=>$e||($e=Object.freeze(Yn(jt,ye,ce)),$e),layout:me,maxVirtualBounds:Oe.getRowOffset(r),scrollOffset:ft,freezeOffset:(D>0?Oe.getRowOffset(D):0)-A},b},[Oe.getRowIndex,Oe.getRowOffset,jt,Q,r,j,ft,X]),Te=c.useMemo(()=>{const b=[];let D=0,A=0;typeof I=="number"?D=I:(D=I.index??0,A=(I.scrollOffset??0)*X);const V=A,W=Oe.getColOffset(D),he=W-V;if(D>0){const at=Ft(Oe,{left:A+Oe.getColOffset(0)}),je=Oe.getColIndex(V),Ae=Oe.getColIndex(W-1);let dt;b[1]={minIndex:je,maxIndex:Ae,minCoord:0,maxCoord:D-1,minBounds:0,maxBounds:he,visibleIndices:()=>dt||(dt=Object.freeze(Yn(nn,je,Ae)),dt),layout:at,maxVirtualBounds:W,scrollOffset:A,freezeOffset:A}}const se=Math.max(0,Fe-he),me=Ft(Oe,{left:Ge+he}),ye=me.getColIndex(0),ce=me.getColIndex(se);let $e;return b[0]={minIndex:ye,maxIndex:ce,minCoord:D,maxCoord:i-1,minBounds:he,maxBounds:se,visibleIndices:()=>$e||($e=Object.freeze(Yn(nn,ye,ce)),$e),layout:me,maxVirtualBounds:Oe.getColOffset(i),scrollOffset:Ge,freezeOffset:(D>0?Oe.getColOffset(D):0)-A},b},[Oe.getColIndex,Oe.getColOffset,nn,Fe,i,I,Ge,X]),tt=c.useRef({}),Je=c.useRef([]),Le=c.useMemo(()=>{let b={};const D=(V,W,he,se,me)=>{const ye={vertical:se?.vertical||!1,horizontal:se?.horizontal||!1};if(V>=Te.length||W>=Ee.length)return null;const ce={rowStart:Ee[W].minIndex,colStart:Te[V].minIndex,rowEnd:Ee[W].maxIndex,colEnd:Te[V].maxIndex};if(ce.rowStart>ce.rowEnd||ce.colStart>ce.colEnd)return null;const $e={getColIndex:_e=>Te[V].layout.getColIndex(_e),getColOffset:_e=>Te[V].layout.getColOffset(_e),getRowIndex:_e=>Ee[W].layout.getRowIndex(_e),getRowOffset:_e=>Ee[W].layout.getRowOffset(_e)},at=Object.freeze({left:me?.left??0,top:me?.top??0,right:me?.right??0,bottom:me?.bottom??0}),je=Object.freeze({x:Te[V].minBounds,y:Ee[W].minBounds,width:Te[V].maxBounds,height:Ee[W].maxBounds}),Ae=(_e,Xe)=>Dr($e,_e??ce,Xe),dt={width:Te[V].maxVirtualBounds,height:Ee[W].maxVirtualBounds},qe={left:Te[V].scrollOffset,top:Ee[W].scrollOffset},kt={left:Te[V].freezeOffset,top:Ee[W].freezeOffset},gt={width:Fe,height:Q};let fe=null,ht=null;const Ot=(kt.top+(se.vertical?qe.top:0))/X,At=(kt.left+(se.horizontal?qe.left:0))/X;return{getStage:()=>ze.current??null,getVisibleRangeCoords:()=>ce,toClipBounds:(_e,Xe)=>{let De,rt=0;return Xe===void 0||typeof Xe=="number"?(De=Ae(ce),rt=Xe):De=Xe,((ke,yt,wt=0)=>{if(ke.x>yt.width||ke.y>yt.height)return null;const Lt={left:ke.x,top:ke.y,bottom:ke.height+ke.y,right:ke.width+ke.x},Vt={left:yt.x+wt,top:yt.y+wt,bottom:yt.height-2*wt+yt.y,right:yt.width-2*wt+yt.x},Tt={left:Math.max(Lt.left,Vt.left),top:Math.max(Lt.top,Vt.top),bottom:Math.min(Lt.bottom,Vt.bottom),right:Math.min(Lt.right,Vt.right)},a={x:Tt.left,y:Tt.top,width:Tt.right-Tt.left,height:Tt.bottom-Tt.top};return a.height<0||a.width<0?null:a})(_e??{x:0,y:0,width:je.width,height:je.height},De,rt)},toViewBounds:_e=>At===0&&Ot===0&&X===1?_e:{x:(_e.x-At)*X,y:(_e.y-Ot)*X,width:_e.width*X,height:_e.height*X},toAbsoluteBounds:_e=>At===0&&Ot===0&&X===1?_e:{x:_e.x/X+At,y:_e.y/X+Ot,width:_e.width/X,height:_e.height/X},getRelativePointFromClient:(_e,Xe)=>{const De=on(_e,Xe);return{x:De.x-je.x,y:De.y-je.y}},getLayout:()=>$e,getCellCoordsAsRangeCoords:We,getVisibleColumns:()=>Te[V].visibleIndices(),getVisibleRows:()=>Ee[W].visibleIndices(),getVisibleColumnOffsets:()=>(fe||(fe=Lr(Te[V].layout,!0,Te[V].visibleIndices(),ce.colStart,ce.colEnd)),fe),getVisibleRowOffsets:()=>(ht||(ht=Lr(Ee[W].layout,!1,Ee[W].visibleIndices(),ce.rowStart,ce.rowEnd)),ht),getTotalRangeCoords:()=>({colStart:Te[V].minCoord,colEnd:Te[V].maxCoord,rowStart:Ee[W].minCoord,rowEnd:Ee[W].maxCoord}),getRangeCoordsBounds:Ae,scrollCellCoordsIntoView:(_e,Xe)=>_n(_e,Xe,he),getCellCoordsFromClient:(_e,Xe,De=!1)=>{const rt=on(_e,Xe);if(!rt)return null;const ke=$e.getColIndex(rt.x-je.x),yt={rowIndex:$e.getRowIndex(rt.y-je.y),colIndex:ke};if(De)return yt;const wt=We(yt);return{rowIndex:wt.rowStart,colIndex:wt.colStart}},getZoom:()=>X,getAnchor:()=>he,getBounds:()=>je,getInsets:()=>at,getTotalSize:()=>dt,getViewportSize:()=>gt,getScrollTopLeft:()=>qe,getFreezeTopLeft:()=>kt,getScrollOrientation:()=>ye,allViews:()=>b}};let A=b[Ht]=D(0,0,Ht,Ul,Nl);return A&&(b[Ht]=A),A=D(0,1,Ln,{horizontal:!0}),A&&(b[Ln]=A),A=D(1,0,Dn,{vertical:!0}),A&&(b[Dn]=A),A=D(1,1,to,{}),A&&(b[to]=A),tt.current=null,b=Object.freeze(b)},[Ee,Te,We]),Gt=Object.keys(Le),_t=Te[0]?.maxVirtualBounds??0,Qe=Ee[0]?.maxVirtualBounds??0,Ct=c.useMemo(()=>({left:Te[1]?Te[1].layout.getColOffset(Te[1].maxIndex+1):0,top:Ee[1]?Ee[1].layout.getRowOffset(Ee[1].maxIndex+1):0}),[Le]);c.useEffect(()=>{if(Je.current.length>0){for(let b=0;b<Je.current.length;b++)Je.current[b]();Je.current=[]}},[Le]);const Rt=T(()=>({containerWidth:Fe,containerHeight:Q,totalWidth:_t,totalHeight:Qe}),[Fe,Q,Oe]);c.useEffect(()=>{!xe.current&&Et.current&&_({top:ft,left:Ge,width:Fe,height:Q,totalWidth:_t,totalHeight:Qe})},[ft,Ge,_t,Qe]),c.useEffect(()=>{Et.current&&_({top:ft,left:Ge,width:Fe,height:Q,totalWidth:_t,totalHeight:Qe})},[Fe,Q]);const on=c.useCallback((b,D)=>{eo(typeof b=="number"&&typeof D=="number");const A=ze.current?.getBoundingClientRect();return A?{x:b-A.x,y:D-A.y}:{x:b,y:D}},[]),so=T(b=>Le[b]||null,[Le]),co=T((b,D)=>{if(Object.keys(Le).length===1)return Le[Ht];const A=on(b,D);if(!A)return null;const{x:V,y:W}=A;let he=null;const se=$r;for(let me=0;!he&&me<se.length;me++){const ye=Le[se[me]];ye&&Al(V,W,ye.getBounds())&&(he=ye)}return he||(he=Le[Ht]),he},[Le,We]),ut=T(()=>Le[Ht].getVisibleRangeCoords(),[Le[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,M(b=>{const D={...b,verticalScrollDirection:null,horizontalScrollDirection:null};return Ye.current=D,D})},[]),an=T(b=>{const D=b?.left??b?.[0],A=b?.top??b?.[1],V=D!==void 0?Math.min(_t-Fe,Math.max(Te?.[1]?.scrollOffset??0,D)):Ye.current.left,W=A!==void 0?Math.min(Qe-Q,Math.max(Ee?.[1]?.scrollOffset??0,A)):Ye.current.top;if(Ye.current.left===V&&Ye.current.top===W)return;let he=null,se=null;Ye.current.left>V?he=et:Ye.current.left<V&&(he=Ne),Ye.current.top>W?se=nt:Ye.current.top<W&&(se=ot),St.throttle(()=>{M(me=>{const ye={...me,left:V,top:W,horizontalScrollDirection:he,verticalScrollDirection:se};return Ye.current=ye,ye})},17)(),xe.current?.top===W&&xe.current?.left===V||(xe.current={left:V,top:W},$({left:V,top:W}),_({left:V,top:W,width:Fe,height:Q,totalWidth:_t,totalHeight:Qe})),ao()},[_t,Qe,Ee,Te]);c.useEffect(()=>{xe.current||an({left:Ge,top:ft})},[_t,Fe,Qe,Q]),c.useLayoutEffect(()=>{xe.current={left:it?.left,top:it?.top},an(xe.current)},[it?.left,it?.top]);const An=T(b=>{const D=b?.left??b?.[0],A=b?.top??b?.[1],V=b?.behavior??"auto",W={left:Ye.current.left+(D??0),top:Ye.current.top+(A??0)};V&&(W.behavior=V),an(W)},[_t,Fe,Qe,Q]),$n=c.useCallback(b=>{let D=null;if(Object.keys(Le).length>1){const A=$r;for(let V=0;!D&&V<A.length;V++){const W=Le[A[V]];W&&G.isCellWithinRange(b,W.getVisibleRangeCoords())&&(D=W)}}return D||(D=Le[Ht]),D},[Le]),_n=T((b,D={inline:"nearest",block:"nearest"},A=null)=>{const V={rowIndex:0,colIndex:0,...b};let W=null;if(A!==null){if(W=Le[A],W===null)return new Promise((gt,fe)=>{fe("Invalid view")})}else W=$n(V);const he=We(V),se=W.getLayout(),me=se.getColOffset(he.colStart),ye=se.getRowOffset(he.rowStart),ce=se.getColOffset(he.colEnd+1),$e=se.getRowOffset(he.rowEnd+1),at=W.getBounds(),je=W.getTotalSize(),Ae=W.getScrollTopLeft(),dt=((gt,fe,ht=!0)=>(ht=ht===!0?{block:"start",inline:"end"}:ht===!1?{block:"end",inline:"end"}:{block:"end",inline:"end",...ht},{left:Tr(ht.inline,gt.x,gt.x+gt.width,fe.left,fe.left+fe.width,fe.totalWidth),top:Tr(ht.block,gt.y,gt.y+gt.height,fe.top,fe.top+fe.height,fe.totalHeight)}))({x:me+Ae.left,y:ye+Ae.top,width:ce-me,height:$e-ye},{left:Ae.left,top:Ae.top,width:at.width,height:at.height,totalWidth:je.width,totalHeight:je.height},D),qe={...dt};qe.left>Ge?qe.left+=20:qe.left<Ge&&(qe.left-=0),qe.top>ft?qe.top+=20:qe.top<ft&&(qe.top-=0);const kt=W.getScrollOrientation();return kt.horizontal&&b.colIndex!==void 0||delete qe.left,kt.vertical&&b.rowIndex!==void 0||delete qe.top,new Promise((gt,fe)=>{try{an(qe),gt(qe)}catch(ht){fe(ht)}})},[_t,Qe,Le,We]),mn=T(b=>{const D=b.shiftKey;b.preventDefault();const{deltaX:A,deltaY:V,deltaMode:W}=b;if(It.current||ue?.(b)===!1)return;let se=D?V:A,me=V;const ye=D||Math.abs(se)>Math.abs(me);W===1&&(me*=0),It.current=window.requestAnimationFrame(()=>{It.current=null,An(ye?{left:se}:{top:me})})},[_t,Fe,Qe,Q,ue]),Cn=c.useCallback((b=null)=>{Xt.current=null,tt.current=null,Ut()},[]);c.useLayoutEffect(()=>{Cn()},[oe]);const un=lo(t,()=>({stage:ze.current,focus:Ze,contains:He,invalidate:Cn,scrollTo:an,scrollBy:An,scrollCellCoordsIntoView:_n,getScrollPosition:ct,getDimensions:Rt,getViewport:ut,handleWheel:mn,rowCount:r,columnCount:i,getLayout:()=>Oe,getRelativePointFromClient:on,getViewFromClient:co,getViewFromCellCoords:$n,getViewFromLocation:so,onViewChangeOnce:b=>{Je.current.push(b)}}),[r,i,Le]);c.useEffect(()=>(Ve&&un.current?.addEventListener("wheel",mn,{passive:!1}),Et.current=!0,xe.current=null,()=>{un.current?.removeEventListener("wheel",mn)}),[Ve]);const In=c.useRef([]),ho=(b,D)=>{!b||!N||(In.current=[],D.push(((A,V)=>{const W=`view:${A.getAnchor()}:overlay:${D.length}`,he=N?.({key:W,view:A},me=>In.current[V]=me);if(!he)return null;const se=A.getBounds();return P.jsx("div",{style:{position:"absolute",left:"0px",top:"0px",width:`${se.width}px`,height:`${se.height}px`,overflow:"hidden"},children:he},`overlay-${A.getAnchor()}-${V}`)})(b,0)))},fo=c.useMemo(()=>{const b={},D=Object.keys(Le);for(let A=0;A<D.length;A++){const V=D[A],W=[];ho(Le[V],W),b[V]={overlays:W}}return b},[st,N,r,i,Ee,Te]),Bn=(b,D,A,V,W,he,se)=>{if(!b)return;const me=b.getVisibleColumns(),ye=b.getVisibleRows();if(me.length===0||ye.length===0)return;let ce=null;if(te)ce=te(b);else{ce=[];for(let Xe=0;Xe<ye.length;Xe++)for(let De=0;De<me.length;De++){const rt={rowIndex:ye[Xe],colIndex:me[De]};if(ee?.(rt))continue;const ke={coords:rt,range:We(rt)};ce.push(ke)}}const $e=b.getVisibleColumnOffsets(),at=b.getVisibleRowOffsets(),je=b.getScrollTopLeft(),Ae=b.getFreezeTopLeft(),dt=je.left+Ae.left,qe=je.top+Ae.top,kt=Math.trunc(dt/Jt),gt=Math.trunc(qe/Jt),fe={},ht=(Xe,De,rt,ke,yt)=>{const wt=`view:${Xe.getAnchor()}:cell:${kr(De.rowIndex,De.colIndex)}`,Lt=ke.x,Vt=ke.y,Tt=Math.trunc((dt+Lt)/Jt)-kt,a=Math.trunc((qe+Vt)/Jt)-gt;fe[a]||(fe[a]={});let f=fe[a][Tt];f||(f=fe[a][Tt]=[]);let m=he?.get(wt);if(!m){const w=(dt+Lt)%Jt,v=(qe+Vt)%Jt;m=oe({key:wt,coords:De,bounds:ke,zoom:X,range:rt,view:Xe,value:yt,style:{left:ge.boundPixel(w),top:ge.boundPixel(v),width:ge.boundPixel(ke.width,!0),height:ge.boundPixel(ke.height,!0)}})}se?.set(wt,m),f.push(m)};for(let Xe=0;ce&&Xe<ce.length;Xe++){const De=ce[Xe],rt=De?.coords??De;if(!rt)continue;const ke=De?.range??{rowStart:rt.rowIndex,colStart:rt.colIndex,rowEnd:rt.rowIndex,colEnd:rt.colIndex},yt=b.getVisibleRangeCoords();if(!G.isRangesIntersect(ke,yt)&&!G.isRangeWithinRange(ke,yt))continue;const wt=ke&&!G.isSingleCell(ke);if(!wt&&ee?.(rt))continue;const Lt=rt.rowIndex,Vt=rt.colIndex,Tt=at[Lt],a=$e[Vt];let f=null;Tt&&a&&(f={x:a.offset,y:Tt.offset,width:a.size,height:Tt.size});const m=kr(ke.rowStart,ke.colStart);if(wt){if(W.has(m))continue;W.add(m),ke.rowEnd-ke.rowStart>0&&A.push(ke),ke.colEnd-ke.colStart>0&&V.push(ke)}if(wt&&(f=Dr(b.getLayout(),ke)),!f){console.warn("no bounds for cell",m);continue}const w=De?.value;ht(b,rt,ke,f,w)}const Ot=dt%Jt,At=qe%Jt,_e=Object.keys(fe);for(let Xe=0;Xe<_e.length;Xe++){const De=fe[_e[Xe]];if(!De)continue;const rt=Object.keys(De);for(let ke=0;ke<rt.length;ke++){const yt=De[rt[ke]];if(!yt)continue;const wt=parseInt(_e[Xe]),Lt=parseInt(rt[ke]),Vt=wt+gt,Tt=Lt+kt,a=`view:${b.getAnchor()}:segment:${Tt}:${Vt}`;D.push(P.jsx("div",{className:"cell-container",style:{transform:`translate(${ge.boundPixel(Lt*Jt-Ot,!0)}px, ${ge.boundPixel(wt*Jt-At,!0)}px)`,willChange:"transform"},children:yt},a))}}},Kt=c.useMemo(()=>{const b=Xt.current,D=new Map,A={},V=Object.keys(Le);for(let W=0;W<V.length;W++){const he=V[W],se=[],me=[],ye=[];Bn(Le[he],ye,se,me,new Set,b,D),A[he]={cells:ye,rangesH:se,rangesV:me}}return Xt.current=D,A},[st,r,i,Ee,Te,y,ve,J,ee,te,We]),Fn=(b,D,A,V,W)=>{if(b)if(D){const he=`view:${b.getAnchor()}:hl:`,se=b.getVisibleRows();if(!se||se.length===0)return;const me=0,ye=b.getBounds().width;let ce=[];const $e=W.sort(G.rowFirstRangeComparator),at=b.getVisibleRangeCoords();for(let je=0;je<se.length&&se[je]<=at.rowEnd;je++){const Ae=se[je];if(Ae<at.rowStart)continue;let dt=!1;for(;$e.length>0&&$e[0].rowStart<=Ae;){const fe=$e.shift();fe.rowEnd>Ae&&(ce.push(fe),dt=!0)}dt&&(ce=ce.sort(G.columnFirstRangeComparator));const qe=b.getLayout(),kt=qe.getRowOffset(Ae+1);let gt=me;for(let fe=0;fe<ce.length+1;fe++){let ht=gt,Ot=ye;const At=ce[fe];fe<ce.length&&(Ot=Math.min(ye,qe.getColOffset(At.colStart)),gt=Math.min(ye,qe.getColOffset(At.colEnd+1))),V.push(c.createElement("path",{d:`M ${ge.boundPixel(ht)} ${ge.boundPixel(kt,!1,A)} L ${ge.boundPixel(Ot)} ${ge.boundPixel(kt,!1,A)}`,stroke:R,strokeWidth:1,vectorEffect:"non-scaling-stroke",...C,key:he+Ae+":"+fe}))}for(let fe=ce.length-1;fe>=0;fe--)ce[fe].rowEnd<=se[je+1]&&ce.splice(fe,1)}}else{const he=`view:${b.getAnchor()}:vl:`,se=b.getVisibleColumns();if(!se||se.length===0)return;const me=0,ye=b.getBounds().height;let ce=[];const $e=W.sort(G.columnFirstRangeComparator),at=b.getVisibleRangeCoords();for(let je=0;je<se.length&&se[je]<=at.colEnd;je++){const Ae=se[je];if(Ae<at.colStart)continue;let dt=!1;for(;$e.length>0&&$e[0].colStart<=Ae;){const fe=$e.shift();fe.colEnd>Ae&&(ce.push(fe),dt=!0)}dt&&(ce=ce.sort(G.rowFirstRangeComparator));const qe=b.getLayout(),kt=qe.getColOffset(Ae+1);let gt=me;for(let fe=0;fe<ce.length+1;fe++){let ht=gt,Ot=ye;const At=ce[fe];fe<ce.length&&(Ot=Math.min(ye,qe.getRowOffset(At.rowStart)),gt=Math.min(ye,qe.getRowOffset(At.rowEnd+1)));let _e=R;V.push(P.jsx("path",{d:`M ${ge.boundPixel(kt,!1,A)} ${ge.boundPixel(ht)} L ${ge.boundPixel(kt,!1,A)} ${ge.boundPixel(Ot)}`,stroke:_e,strokeWidth:1,vectorEffect:"non-scaling-stroke",...L},he+Ae+":"+fe))}for(let fe=ce.length-1;fe>=0;fe--)ce[fe].colEnd<=se[je+1]&&ce.splice(fe,1)}}},Mn=b=>{if(!Kt)return;const D={};for(let A=0;A<Gt.length;A++){const V=Gt[A],W=Le[V],he=[];Fn(W,b,0,he,b?Kt[V].rangesH:Kt[V].rangesV);const se=W.getRangeCoordsBounds(),me=Math.ceil(se.width),ye=Math.ceil(se.height);D[V]=P.jsx("svg",{width:`${me}`,height:`${ye}`,viewBox:`0 0 ${me} ${ye}`,preserveAspectRatio:"none",shapeRendering:"crispEdges",style:{position:"absolute"},children:he})}return D},Vn=c.useMemo(()=>y===!0||y?.horizontal===!0?Mn(!0):null,[st,y,Ee,j,I,R,C,r,i,Fe,_t,Kt]),Wn=c.useMemo(()=>y===!0||y?.vertical===!0?Mn(!1):null,[st,y,Te,j,I,R,L,r,i,Q,Qe,Kt]),po=c.useMemo(()=>Ct.left===0?null:P.jsx(Vo,{linePoints:[0,0,0,Q+1],bounds:{x:Ct.left,y:0,width:1,height:Q+1},...le}),[st,Ct.left,Q,le]),go=c.useMemo(()=>Ct.top===0?null:P.jsx(Vo,{linePoints:[0,0,Fe+1,0],bounds:{x:0,y:Ct.top,width:Fe+1,height:1},...B}),[st,Ct.top,Fe,B]),Rn=c.useMemo(()=>{const b=[],D=A=>{if(!A||!Le[A])return;const V=Le[A].getBounds();return P.jsxs("div",{style:{position:"absolute",pointerEvents:"none",left:V.x,top:V.y,width:V.width,height:V.height,clip:`rect(0, ${V.width+1}px, ${V.height+1}px, 0)`},className:`view view-${A}`,children:[Vn?.[A],Wn?.[A],Kt?.[A].cells]},`view:${A}`)};for(let A=0;A<Gt.length;A++)b.push(D(Gt[A]));return P.jsx(P.Fragment,{children:b})},[Le,Vn,Wn,Kt]),wo=c.useMemo(()=>{if(!t)return;const b=(se,me,ye,ce)=>{if(!ce||ce.length===0)return;const $e=[];for(let at=0;at<ce.length;at++){const je=ce[at];let Ae=se?.get(je);Ae!==To&&(Ae=je(ye)??To),me.set(je,Ae),Ae&&Ae!==To&&$e.push(Ae)}return $e},D=(se,me,ye)=>{if(!ye)return;const ce=ye.getBounds(),$e=ye.getInsets(),at=ye.getAnchor();return P.jsxs("div",{className:fn("view",`view-${at}`,Ar.view),style:{position:"absolute",pointerEvents:"none",left:ce.x-$e.left,top:ce.y-$e.top,width:ce.width-($e.left+$e.right),height:ce.height-($e.top+$e.bottom),clipPath:g?"inset(-2px)":"inset(0px)"},children:[b(se,me,ye,k),fo?.[at].overlays]},`view:${at}`)},A=tt.current,V={},W=[],he=Object.keys(Le);for(let se=0;se<he.length;se++){const me=he[se],ye=A?.[me],ce=V[me]=new Map;W.push(D(ye,ce,Le[me]))}return tt.current=V,W},[st,Le,g,k]),mo=c.useMemo(()=>{const{style:b,...D}=Z??{};return P.jsx("div",{style:{width:Fe,height:Q,...b},className:"sheetxl-stage",tabIndex:0,ref:ze,...D,...Ke,children:q?q(Rn):Rn})},[Fe,Q,Rn,Z,q]),Hn=c.useRef(!1);return c.useEffect(()=>{!Hn.current&&Kt&&(Hn.current=!0,we?.(un.current))},[Kt]),P.jsxs("div",{className:fn("sheetxl-grid",Ar["sheetxl-grid"]),style:{overflow:"visible",cursor:O,maxWidth:Fe,maxHeight:Q,width:Fe,height:Q,...ve},ref:un,children:[mo,P.jsxs("div",{className:fn("sheetxl-overlays"),ref:lt,...E,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}]=bi(),p=n??u,x=o??d;return P.jsx("div",{className:i,style:{...r},children:P.jsx("div",{style:{position:"relative",top:"0px",left:"0px",width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",boxSizing:"content-box"},ref:s,children:P.jsx(Yo,{ref:t,width:p,height:x,...l})})})}));Go.displayName="Grid";const Si=c.memo(c.forwardRef((e,t)=>{const{showVerticalScrollbar:n,showHorizontalScrollbar:o,createHorizontalScrollbar:r,createVerticalScrollbar:i,createScrollCorner:l,viewport:s,onScrollViewport:u,style:d={},className:p,onScroll:x,...h}=e,[y,R]=c.useState(null),C=c.useRef(null),L=c.useRef(null);eo(!s),c.useImperativeHandle(t,()=>L.current&&C.current?Object.assign(L.current,C.current):null);const J=c.useCallback(O=>{L.current?.scrollTo(O),u?.(O)},[]);return P.jsx(di,{className:p,style:d,ref:C,showVerticalScrollbar:n,showHorizontalScrollbar:o,createHorizontalScrollbar:r,createVerticalScrollbar:i,createScrollCorner:l,viewport:y,onScrollViewport:J,children:P.jsx(Go,{style:{width:"100%",height:"100%"},...h,onViewportChange:O=>R(O),ref:L})})}));Si.displayName="ScrollableGrid";const Br=()=>!1,Ei=c.memo(e=>{const{index:t,value:n,zoom:o,zoomScale:r=100,headerText:i=k=>`${k}`,headerStyle:l,headerStyleSelect:s=l,headerStyleSelectAll:u=s,headerStyleHover:d=u,verticalPadding:p=0,horizontalPadding:x=0,isSelected:h=Br,isSelectedAll:y=Br,coords:R,bounds:C,range:L,orientation:J,view:O,style:I,...j}=e,le=r/100,B=c.useRef(null),[oe,be]=c.useState(!1),U=h?.(t)||!1,N=y?.(t)?u:U?s:l;let Y=N;if(oe){let k=d;typeof d=="function"&&(k=d(N)),Y=St.mergeContentful(N,k)}return P.jsx("div",{ref:B,style:{background:Y.fill,color:Y.text?.fill,fontFamily:Y.text?.fontFamily??l.text?.fontFamily,fontSize:96*(Y.text?.fontSize??11)/72*le,fontStyle:Y.text?.fontStyle,fontWeight:Y.text?.fontWeight,lineHeight:1.2,display:"flex",justifyContent:"center",alignItems:"end",pointerEvents:"auto",paddingBottom:`${le}px`,...I,left:I.left-(J===Bt?1:0),top:I.top-(J===en?1:0),width:I.width+1,height:I.height+1,overflow:"hidden"},...j,onMouseMove:k=>{ge.detectIt().primaryInput!=="touch"&&k.buttons===0&&be(!0)},onMouseOut:k=>{be(!1)},children:i(t)})});Ei.displayName="HeaderRenderer";const _i="ew-resize",Ci="ns-resize",Ii=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:p,isSelected:x,isSelectedAll:h,showTouchDivider:y,headerStyle:R,headerStyleSelect:C,headerStyleSelectAll:L,headerStyleHover:J,bounds:O,onPointerDown:I,onAutoFit:j,...le}=e,B=n===Bt;let oe=R;x&&C&&(oe=C),h&&L&&(oe=L);const be=ge.detectIt().primaryInput==="touch";let U=B?14:8,N=U/2,Y=0;d&&(Y=-2),p&&(Y=2),p&&(U=U/2+Y,N=2*Y);let k=oe.dividerStrokeFill??oe.strokeFill;return!(x||h)&&Y===0&&(k=`linear-gradient(${B?180:90}deg, ${oe.fill}, ${k} 55%, ${k} 100%)`),P.jsxs("div",{className:fn("header-divider",{disabled:s},i,`index-${r}`),ref:t,onPointerDown:be?void 0:I,onDoubleClick:be?void 0:()=>j?.(),style:{top:(B?0:-U/2+(Y-1))+"px",left:(B?-U/2+(Y-1):0)+"px",width:B?U:"calc(100% + 1px)",height:B?"calc(100% + 1px)":U,position:"absolute",overflow:"visible",pointerEvents:"all",cursor:s||u||be?void 0:B?_i:Ci,...l},...le,children:[P.jsx("div",{style:{position:"relative",top:`${B?0:N}px`,left:`${B?N:0}px`,width:B?1:"100%",height:B?"100%":1,background:k},onDoubleClick:()=>j?.()}),y&&be?P.jsx("div",{style:{position:"absolute",cursor:"grab",zIndex:1,borderRadius:"4px",right:B?"-6px":"2px",bottom:B?"2px":"-9px",height:"24px",width:B?"24px":"18px",maxHeight:B?"calc(100% - 4px)":void 0,maxWidth:B?void 0:"calc(100% - 4px)",background:oe.fill,border:`${L.edgeStrokeFill} solid 1px`,boxShadow:`0.5px 0.5px 0px 0px ${R.text.fill}`,display:"flex",alignItems:"center",justifyContent:"center"},onPointerDown:I,children:P.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(C.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:B?void 0:"rotate(90deg)"}})}):null]})})),Kl=(e,t)=>P.jsx(Ii,{...e,ref:t}),ql=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:p,onDividerResize:x,onDividerResizeEnd:h,onDividerMouseUp:y,onDividerAutoFit:R,onPointerDown:C,...L}=e,J=T(C,[C]),O=T(R,[R]),I=n===Bt;let j=I?o.getVisibleColumns():o.getVisibleRows(),le=null;j.length>0&&(I?le=o.getRangeCoordsBounds({rowStart:0,rowEnd:0,colStart:j[0],colEnd:j[j.length-1]}):o.getRangeCoordsBounds({rowStart:j[0],rowEnd:j[j.length-1],colStart:0,colEnd:0}),le=o.toClipBounds(le,Wt));const B=c.useRef(null),[oe,be]=c.useState(null),U=(z,K)=>I?z.clientX-K.clientX:z.clientY-K.clientY,N=o.getLayout(),Y=I?N.getColOffset(r+1):N.getRowOffset(r+1),k=bn({processTouch:!0,onPointerDown:z=>{if(J?.(z),!i&&!l){const K=I?N.getColOffset(r):N.getRowOffset(r),ee=Y-K;B.current={isResizing:!1,startSize:ee,index:r,view:o,orientation:n,onDividerMouseDown:d,onDividerResizeStart:p,onDividerResize:x,onDividerResizeEnd:h,onDividerMouseUp:y},be(B.current),d?.(r,ee)}z.stopPropagation(),z.preventDefault()},onPointerUp:(z,K,ee)=>{if(!B.current)return;B.current.isResizing&&B.current.onDividerResizeEnd?.(B.current.index,Math.max(0,B.current.startSize+U(z,ee)),B.current.startSize);const te=B.current;B.current=null,be(B.current),te.onDividerMouseUp?.(te.index)},onPointerMoveOrWait:(z,K,ee)=>{if(!B.current)return;const te=U(z,ee);B.current.isResizing?B.current.onDividerResize?.(B.current.index,Math.max(0,B.current.startSize+te),B.current.startSize):Math.abs(te)>Math.max(1,s)&&(B.current={...B.current,isResizing:!0},be(B.current),B.current.onDividerResizeStart?.(B.current.index,Math.max(0,B.current.startSize+te))),z.stopPropagation(),z.preventDefault()}}),E=T(()=>{O?.(r)},[r]);if(!le)return;const g=u({bounds:le,orientation:n,view:o,index:r,disabled:i,disabledResize:l,onAutoFit:E,onPointerDown:k,...L},t);if(!g)return;const{getPortalContainer:Z}=hi();let q=null;return oe&&oe.isResizing&&oe.index===r&&(q=No.createPortal(P.jsx("div",{style:{position:"absolute",cursor:I?_i:Ci,left:0,top:0,width:"100%",height:"100%"}}),Z(),"divider:"+r)),P.jsxs(P.Fragment,{children:[q,P.jsx("div",{className:fn("header-divider-anchor"),style:{position:"absolute",pointerEvents:"auto",top:`${I?le.y:Y}px`,left:`${I?Y:le.x}px`,width:(I?0:le.width-1)+"px",height:(I?le.height-1:0)+"px",display:"flex"},tabIndex:-1,children:g})]})}));class Xl{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(`
19
+ `);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 Mi=(e=void 0)=>Object.freeze({clean:e,dirty:void 0,editMode:!1}),Yl=Mi(),Gl=c.memo(c.forwardRef((e,t)=>{const{editState:n=Yl,defaultTextStyle:o,onStartEdit:r,onChangeEdit:i,onSubmitEdit:l,onCancelEdit:s,onDoneEdit:u,containerBounds:d,setNaturalDimensions:p,onNavigate:x,textProperties:h,style:y,autoFocus:R,...C}=e,L=c.useRef(null),{width:J=0}=d??{},[O,I]=c.useState(()=>n);c.useEffect(()=>{I(n)},[n]);const j=h?.align||"left",le=h?.vAlign||"middle",B=h?.fill||"#040404",oe=h?.wrap||"wrap",be=h?.fontFamily||"Calibri",U=h?.fontSize||11,N=h?.fontWeight||400,Y=h?.fontStyle||"normal",k=O.dirty??O.clean??"";let E=2;const g=96*U/72,Z=1.2*g;le==="right"&&(E+=1);const q=c.useMemo(()=>new Xl().naturalDimensions(k,{maxWidth:oe==="wrap"?J-E:void 0,lineHeight:`${Z}px`,paintableText:{fontStyle:Y,wrap:oe,letterSpacing:-.25}}),[k,oe,E,g,be,N,Y,p,J]),z=c.useCallback(()=>q.maxLineHeight?q.maxLineHeight+"px":"1.2",[q]),[K,ee]=c.useState(z);c.useLayoutEffect(()=>{ee(z())},[d,q]),c.useLayoutEffect(()=>{p?.({width:oe==="wrap"?void 0:q.width+E,height:q.height})},[q,p]);const te=T(i,[i]),X=T(_=>{if(O.dirty===_)return;const Ce={...O};Ce.dirty=_,L.current,I(Ce),te?.(Ce)},[O]),Ve=T(_=>{if(O.editMode===_)return;const Ce={...O};Ce.editMode=_,I(Ce),te?.(Ce)},[O]),Be=T(()=>{try{return l?.(O),u?.(),!0}catch{return!1}},[l,O]),We=T(()=>{I(n),s?.(),u?.()},[s,n]),it=T(_=>{if(!L.current)return;if(_.isDefaultPrevented(),!(_.isTrusted||_.nativeEvent.ctrlKey||_.nativeEvent.metaKey||_.nativeEvent.altKey||_.nativeEvent.isComposing)&&qo.indexOf(_.nativeEvent.key)!==-1){const ue={...O};return ue.dirty=_.nativeEvent.key==="Backspace"?"":(ue.dirty??"")+_.key,I(ue),te?.(ue),void _.preventDefault()}const Ce=_.nativeEvent.shiftKey;if(_.which===qi)return _.preventDefault(),void We();if(_.which===Xi)return Ve(!0),void _.preventDefault();if(_.which===Qr&&(_.preventDefault(),Be()&&x?.(Ce?nt:ot)),_.which===Jr)return _.preventDefault(),void(Be()&&x?.(Ce?et:Ne));if(!O.editMode){let ue=null;switch(_.which){case ei:ue=et;break;case ni:ue=Ne;break;case ti:ue=nt;break;case oi:ue=ot}if(ue)return void Be()}},[O,x]),[ve,Ke]=c.useState(!R);c.useEffect(()=>{Ke(!1)},[]);const $=lo(t,()=>({startEdit(_){let Ce=_?.initialSelection;if(!Ce){const we=L.current.value.length??0;Ce={start:we,end:we,direction:"forward"}}L.current?.setSelectionRange(Ce.start,Ce.end,Ce.direction);const ue={...n,editMode:_?.editMode??!1};_?.text!==void 0&&(ue.dirty=_.text),ue.editMode===n.editMode&&ue.dirty===n.dirty||(I(ue),te?.(ue))},submitEdit:()=>Be(),cancelEdit(){We()},autoFocus(){L.current?.focus()},getLineHeight:()=>q?.maxLineHeight??Z,dispatchEvent:_=>L.current.dispatchEvent(_)}),[n,r]);return P.jsx("div",{ref:$,...C,style:{background:"transparent",display:"flex",flexGrow:1,alignSelf:"center",height:q.height,maxWidth:"100%",maxHeight:"100%",...y},children:P.jsx("textarea",{spellCheck:"false",ref:L,value:k,autoFocus:!1,disabled:ve,name:"cell-editor",autoComplete:"off",autoCapitalize:"off",style:{flex:"1 1 100%",position:"relative",fontSize:`${g}px`,fontFamily:`${be}`,fontWeight:`${N}`,fontStyle:`${Y}`,padding:"0px",marginRight:j==="right"?"3px":"0px",marginLeft:j==="left"?"2px":"0px",lineHeight:K,height:q.height,textRendering:"geometricPrecision",letterSpacing:"-0.25px",boxSizing:"border-box",borderWidth:0,outline:"none",resize:"none",overflow:"hidden",verticalAlign:"baseline",textAlign:j,background:"transparent",color:B,marginBottom:"0px",userSelect:"text",maxHeight:"100%",whiteSpace:oe==="wrap"?"break-spaces":"pre",wordWrap:"break-word"},onChange:_=>{X(_.target.value)},onDoubleClick:_=>{_.isTrusted},onMouseDown:_=>{Ve(!0)},onKeyDown:it})})})),Zl=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 P.jsx("div",{style:{padding:"2px 4px",fontFamily:"Calibri",letterSpacing:-.25,lineHeight:1.2,fontSize:d,...s},...u,children:t})});exports.BaseGrid=Yo,exports.DefaultCellEditor=Gl,exports.DefaultCellRenderer=Zl,exports.DefaultHeaderDivider=Ii,exports.FillHandle=Wo,exports.Grid=Go,exports.HeaderDivider=ql,exports.HeaderRenderer=Ei,exports.RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL=150,exports.SELECTION_CLIP_INSETS=Wt,exports.STANDARD_KEY_CHARS=qo,exports.SVGLine=Vo,exports.SVGRect=mi,exports.ScrollableGrid=Si,exports.Selection=Xo,exports.TouchSelectHandle=Qn,exports.defaultSelectionRenderer=zr,exports.getDefaultStringEditState=Mi,exports.safeSelectionCoords=$t,exports.useCellLayout=wi,exports.useHeaderSelection=({gridRef:e,gridMainRef:t,orientation:n=en,headerCount:o,selectionPolicy:r="multiple",newSelectionMode:i="clear",alwaysScrollToActiveCoords:l=!0,onDragStart:s,onDragEnd:u,pointerDownInterceptor:d,pointerMoveInterceptor:p,onPointerUp:x,newSelection:h,modifySelection:y,appendSelection:R,clearSelections:C})=>{const L=o??((n===en?e.current?.rowCount:e.current?.columnCount)||0),J=c.useRef(null),O=c.useRef(null),I=c.useRef(!1),j=c.useRef(null),le=c.useCallback(E=>n===Bt?{rowIndex:0,colIndex:E.colIndex}:{rowIndex:E.rowIndex,colIndex:0},[n]),B=c.useCallback(E=>n===Bt?{rowIndex:t.current?t.current.rowCount-1:0,colIndex:E.colIndex}:{rowIndex:E.rowIndex,colIndex:t.current?t.current.columnCount-1:0},[n]),oe=E=>{O.current=B(E),y(O.current,J.current)},be=c.useCallback((E,g)=>{if(!e.current)return;const Z=e.current.getViewFromClient(E,g)?.getCellCoordsFromClient(E,g);return Z?(n===Bt?Z.rowIndex=t.current.getViewport().rowStart:Z.colIndex=t.current.getViewport().colStart,Z):void 0},[]),U=c.useCallback((E,g=!1)=>{let Z=E;return g||(Z={...E},n===en?delete Z.colIndex:delete Z.rowIndex),t.current?.scrollCellCoordsIntoView(Z)},[n]),N=T(u,[u]),Y=T(s,[s]),k=c.useMemo(()=>({onPointerDown:E=>{if(!e||!e.current||E.nativeEvent.defaultPrevented)return;const g=be(E.nativeEvent.clientX,E.nativeEvent.clientY);if(!g)return;E.nativeEvent.which;const Z=E.nativeEvent.shiftKey,q=E.nativeEvent.ctrlKey||E.nativeEvent.metaKey;if(d?.(E,g)===!1)return;Y?.(),I.current=!0;const z=t.current?.getViewFromClient(E.nativeEvent.clientX,E.nativeEvent.clientY),K=((ee,te)=>n===Bt?{...ee,rowIndex:te.rowStart}:{...ee,colIndex:te.colStart})(g,z.getVisibleRangeCoords());if(Z)oe(g);else{if(q)return((ee,te=ee,X)=>{J.current=le(ee),O.current=B(te),R(J.current,O.current,X)})(g,g,K),void(l&&U(K,!0));((ee,te=ee,X)=>{J.current=le(ee),O.current=B(te),h(J.current,O.current,X)})(g,g,K),oe(g),l&&U(K,!0)}},onPointerMoveOrWait:St.throttle(E=>{if(!I.current||!e?.current)return;const g=be(E.clientX,E.clientY);if(g&&p?.(E,g)!==!1){if(G.isEqualCells(j.current,g))return C();oe(g),U(g)}},60),onPointerUp:E=>{I.current=!1,N?.(),x?.(E)},processTouch:!0,consumeTouch:!0}),[r,l,L,i,C,d,x]);return{onPointerDown:T(bn(k),[]),getCellCoordsFromClient:be}},exports.useKeyboardEditorOverlay=e=>{const{view:t,canEdit:n=Tl,getCellEditor:o,onBeforeStartEdit:r,onStartEdit:i,onSubmitEdit:l,onCancelEdit:s,onDoneEdit:u,isEditorStartKeyEvent:d=Pl,isEditorStartPointerEvent:p=Ol,containerProps:x,borderStrokeFill:h,borderStrokeWidth:y=2,getRangeCoords:R=null,activeCoords:C,alignment:L=On.Left}=e,[J,O]=c.useState(!1),[I,j]=c.useState(void 0),le=T(($,_,Ce,ue,we,ze)=>{if(!_)return null;const lt=we?.(_,$),It=$.getRangeCoordsBounds(lt),st=$.toClipBounds(It),Ut=It,xt=$.getZoom();if(!st)return null;Ce&&(Ce*=xt),ue&&(ue*=xt);let M=Ut,xe=!1;if(Ce!==void 0){let Ge={...lt},Qt=0;for(;!xe&&M.width<=Ce&&Qt<20;){Qt++,Qt>19&&console.warn("max width reached");const Yt=$.getTotalRangeCoords(),Et=$.getLayout();ze===On.Left?Ge.colEnd+1<Yt.colEnd?Ge.colEnd=Et.getColIndex(M.x+Ce):xe=!0:ze===On.Right?Ge.colStart-1>=0?Ge.colStart=Et.getColIndex(M.x-(Ce-M.width)):xe=!0:ze===On.Center&&Ge.colEnd+1<Yt.colEnd&&Ge.colStart-1>=0?(Ge.colStart=Et.getColIndex(M.x-(Ce-M.width)/2),Ge.colEnd=Et.getColIndex(M.x+M.width+(Ce-M.width)/2)):xe=!0,xe||(M=$.getRangeCoordsBounds(Ge))}}M.height=Ut.height,ue!==void 0&&(M.height=Math.max(ue+1,Ut.height));const{width:Ye,height:ft}=$.getViewportSize();return{x:M.x??0,y:M.y??0,height:Math.min(ft-M.y,M.height)+1,width:Math.min(Ye-M.x,M.width)+1}},[L]),B=T(n,[n]),oe=c.useCallback(()=>{t?.getStage()?.focus()},[t]),be=c.useRef(null),U=T($=>{r?.($),te(),O(!0),be.current=null},[r]),N=T($=>{i?.($.coords)},[i]),Y=T($=>{$.isSubmitted||$.isCancelled||(g.current.isEditorClosed=!0,oe(),$.isCancelled=!0,s?.($.coords),te())},[s]),k=T($=>{if($.isSubmitted||$.isCancelled)return!1;try{return be.current=$.coords,$.isEditorClosing=!0,$.isSubmitted=!0,$.isEditorSubmitted||($.isEditorSubmitted=!0,$.editorRefs[0]?.submitEdit?.()),$.coords,l?.($.coords),$.isEditorClosed=!0,oe(),te(),!0}catch(_){throw $.isEditorClosing=!1,$.isSubmitted=!1,_}},[l]),E=T($=>{O(!1),u?.($.coords),te()},[u]),g=c.useRef(null),Z=c.useRef(null),q=c.useRef(null),z=c.useRef([]),[K,ee]=c.useReducer($=>$+1,0),te=c.useCallback($=>{$&&z.current.push($),ee()},[]),X=T($=>{if($.defaultPrevented||$.isSynthetic||!t)return;const _=t?.getCellCoordsFromClient($.clientX,$.clientY);_&&te({eventType:"pointer",event:$,coords:_})},[t]),Ve=T($=>{const _=$.nativeEvent;X(_)},[t]),Be=T($=>{if($.defaultPrevented||$.isSynthetic||!t?.getStage())return;const _=Z.current;d($,_)&&($.stopPropagation(),$.preventDefault()),$.key,te({eventType:"keyboard",event:$,coords:_})},[t]);c.useLayoutEffect(()=>{const $=(ue,we)=>{const ze=we?.cell??ue;if(!ze)return null;const lt=ze;if(!B(ze))return null;U?.(ze);const It=St.uuidV4();we=Object.freeze({autoFocus:!0,...we}),q.current=ze;const st={coords:lt,startEvent:we,uuid:It,isMounted:!1,isStarted:!1,isSubmitted:!1,isEditorSubmitted:!1,isEditorClosing:!1,isEditorClosed:!1,isCancelled:!1,events:[],editorRefsDispatchEditorEvent:[],editorRefs:[],onMount:Ut=>{st.isMounted||(st.isMounted=!0,te())},onUnmount:Ut=>{if(st.editorRefs.length===0){const xt=()=>{st.isMounted=!1,te()};if(document.activeElement!==document.body)xt();else{const M=xe=>{xe.defaultPrevented||xe.target!==document.body||Be(xe)};window.addEventListener("keydown",M,!0),t.getStage()?.addEventListener("focusin",()=>{window.removeEventListener("keydown",M),xt()},{once:!0}),oe()}}}};return st};if(z.current.length<=0&&!g.current)return;const _=z.current[0];Rr(_),(ue=>{const we=[],ze=ue?.length??0;for(let lt=0;lt<ze;lt++){const It=ue[lt];we.push(Rr(It))}})(z.current),g.current,g.current;let Ce=g.current;if(g.current){if(g.current.isDone)g.current=null;else if(g.current.isSubmitted||g.current.isCancelled){if(g.current.isMounted)return;g.current.isDone||(E(g.current),g.current.isDone=!0)}}if(_){if(_.eventType==="start"){const ue=_,we=ue.startEvent?.cell??Z.current;g.current&&G.isEqualCells(g.current.coords,we)||(g.current=$(we,ue.startEvent))}else if(_.eventType==="keyboard"){const ue=_.event;if(g.current){let we=!1;switch(ue.which){case ei:case ni:case ti:case oi:case Qr:case Jr:we=!0}if(!we){g.current.events.push(_);for(let ze=0;ze<g.current.editorRefsDispatchEditorEvent.length;ze++)g.current.editorRefsDispatchEditorEvent[ze](_)}}else if(d(ue,_.coords)){let we;const ze=$(we?.cell??Z.current,we);ze&&ze.events.push(_),g.current=ze}}else if(_.eventType==="pointer"){const ue=_.event;if(g.current){g.current.events.push(_);for(let we=0;we<g.current.editorRefsDispatchEditorEvent.length;we++)g.current.editorRefsDispatchEditorEvent[we](_)}else{const we=_?.coords??Z.current,ze=p(ue,we);if(ze){let lt;typeof lt!="boolean"&&(lt=ze);const It=$(we,lt);It&&It.events.push(_),g.current=It}}}else if(_.eventType==="submit"){if(g.current&&!g.current.isSubmitted&&!g.current.isCancelled){if(!g.current.isMounted)return;k(g.current)}}else if(_.eventType==="cancel"){if(g.current&&!g.current.isSubmitted&&!g.current.isCancelled){if(!g.current.isMounted)return;Y(g.current)}}else if(_.eventType==="coordsChange"){const ue=_;if(Z.current=ue.activeCoords,g.current,g.current&&!g.current.isSubmitted&&!g.current.isCancelled){if(!g.current.isMounted)return;try{k(g.current)}catch{}}}}z.current.length>0&&(z.current.shift(),te()),z.current.length===0&&(!g.current||g.current.isEditorClosing||g.current.isEditorClosed?!g.current&&Ce&&oe():g.current.isMounted&&!g.current.isStarted&&(g.current.isStarted=!0,g.current.startEvent.autoFocus&&(typeof g.current.startEvent.autoFocus=="string"?g.current.editorRefs[0]?.autoFocus(g.current.startEvent.autoFocus):g.current.editorRefs[0]?.autoFocus()),N?.(g.current),requestAnimationFrame(()=>{t&&g.current?.coords&&t.scrollCellCoordsIntoView(g.current.coords)})))},[K]),c.useEffect(()=>{q.current=C;const $=g.current?.coords;G.isEqualCells($,C)||(g.current&&(g.current.isEditorClosing=!0),te({eventType:"coordsChange",activeCoords:C}))},[C]);const We=c.useCallback($=>{Be($.nativeEvent)},[]),{width:it=0,height:ve=0}=I??{width:0,height:0},Ke=T(o,[o]);return{overlay:T($=>{if(!g.current||g.current.isEditorClosed)return g.current,null;g.current.coords;let _=le($,g.current.coords,it,ve,R,L),Ce=!0;_&&_.width!==0&&_.height!==0||(_={x:0,y:0,width:it,height:it},Ce=!1);const ue=$.getZoom(),we={containerBounds:{x:0,y:0,width:_.width/ue,height:_.height/ue},setNaturalDimensions:j,zoom:ue};return P.jsx(Ll,{session:g.current,refLatestCoords:q,handleSubmitEdit:k,handleCancelEdit:Y,cellBounds:_,borderStrokeWidth:y,borderStrokeFill:h,isInBounds:Ce,getCellEditor:Ke,propsEditor:we,alignment:L,...x},"editor:"+g.current.uuid)},[o,R,K,it,ve,L,y,h]),startEdit:c.useCallback($=>{te({eventType:"start",startEvent:$})},[]),submitEdit:c.useCallback(()=>{te({eventType:"submit"})},[]),cancelEdit:c.useCallback(()=>{te({eventType:"cancel"})},[]),onKeyboardEvent:We,onPointerEvent:Ve,onKeyboardEventNative:Be,onPointerEventNative:X,isEditing:J}},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:p,onFillCancel:x,onFillDone:h,onFill:y,disableFillDrag:R=!y,fillHandleBorderColor:C="white",hiddenRowsAt:L,hiddenColumnsAt:J,isContentfulCell:O,contentfulCellFinder:I=jl,getDataCoords:j,alwaysScrollToActiveCoords:le=!1,selectionBounds:B,pointerDownInterceptor:oe,pointerMoveInterceptor:be,mergedRanges:U,canSelectionSpanMergedCells:N=Wl,onMoveDragStart:Y,onMoveDragUpdate:k,onMoveDragEnd:E,onMoveDragDone:g,selectionRenderer:Z=zr,disableMoveDrag:q=!E,getCellCoordsAsRangeCoords:z=G.cellToRange,moveDragHitSize:K=6,moveDragOutlineSize:ee=4,selectionBackgroundColor:te="rgba(16, 124, 65, 0.1)",selectionBorderColor:X="rgb(33, 115, 70)",selectionRemoveBorderColor:Ve="rgb(255, 0, 0)",selectionRemoveBackgroundColor:Be="rgba(250, 10, 10, 0.1)",disableTouchSelection:We=!1,touchSelectHandleProps:it})=>{const ve=c.useCallback(()=>({top:B?.top??0,left:B?.left??0,bottom:e.current?.rowCount-1||0,right:e.current?.columnCount-1||0}),[]),Ke=T(y,[y]),$=T(p,[p]),_=T(x,[x]),Ce=T(h,[h]),ue=T(O,[O]),we=T(Z,[Z]),ze=T((a,f=!1)=>io(a,f,n.getRowOffset,f?ve().bottom:ve().top),[n?.getRowOffset]),lt=T(L??ze,[L]),It=T((a,f=!1)=>io(a,f,n.getColOffset,f?ve().right:ve().left),[n?.getColOffset]),st=T(J??It,[J]),[Ut,xt]=c.useState(()=>$t(o)),M=c.useMemo(()=>$t(Ut),[Ut]),xe=c.useRef(M),Ye=c.useRef(!0);c.useLayoutEffect(St.throttle(()=>{xt(a=>{Ye.current=!0;const f=$t(o);return G.isEqualSelectionCoords(f,a)?a:f})},0),[o]),c.useLayoutEffect(()=>{xe.current=M},[M]),c.useEffect(()=>{Ye.current||!r||G.isEqualSelectionCoords(o,M)||r(M)},[M]);const ft=c.useCallback(a=>{xt(f=>{Ye.current=!1,f=$t(f);let m=typeof a=="function"?a(f.ranges):a??Ho;if(G.isEqualRangesArrays(m,f.ranges))return f;let w=Math.max(m.length?0:-1,Math.min(f.rangeIndex,m.length-1)),v=f.cell;w===-1||G.isCellWithinRange(v,m[w])||(v={rowIndex:m[w].rowStart,colIndex:m[w].colStart}),m.length===1&&G.isSingleCell(m[0])&&G.isCellWithinRange(v,m[0])&&(m=[],w=-1);const H={cell:v,ranges:m,rangeIndex:w};return G.isEqualSelectionCoords(H,f)?f:H})},[]),Ge=T(a=>{xt(f=>{Ye.current=!1,f=$t(f);const m=a??vi,w=z(m);if(!G.isSingleCell(w)&&f.ranges.length===0)return{ranges:[w],rangeIndex:0,cell:m};if(G.isEqualCells(m,f.cell))return f;let v=f.ranges,H=f.rangeIndex;f.ranges.length===1&&(G.isSingleCell(f.ranges[0])&&G.isCellWithinRange(m,f.ranges[0])||!G.isCellWithinRange(m,f.ranges[0]))&&(v=[],H=-1);const S={ranges:v,rangeIndex:H,cell:m};return G.isEqualSelectionCoords(S,f)?f:S})},[z]),[Qt,Yt]=c.useState(null),[Et,tn]=c.useState(null),Xt=c.useRef(null),[Oe,Ft]=c.useState(null),pt=c.useRef(null),jt=c.useRef(null),[wn,nn]=c.useState(null),Fe=c.useRef(null),Q=c.useRef(null),Ze=c.useRef(U);c.useEffect(()=>{Ze.current=U},[U]);const He=T((a,f={inline:"nearest",block:"nearest"})=>{let{rowIndex:m,colIndex:w}=a;m===void 0&&M?.cell&&(m=M.cell.rowIndex),w===void 0&&M?.cell&&(w=M.cell.colIndex),m!==void 0&&w!==void 0&&e.current?.scrollCellCoordsIntoView({rowIndex:m,colIndex:w},f)},[M]),ct=c.useCallback(a=>{const f=ve();return a.rowIndex<f.top||a.colIndex<f.left||a.colIndex>f.right||a.rowIndex>f.bottom},[]),Ee=T((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 v=z(a),H=z(f),S={rowStart:Math.min(v.rowStart,H.rowStart),colStart:Math.min(v.colStart,H.colStart),rowEnd:Math.max(v.rowEnd,H.rowEnd),colEnd:Math.max(v.colEnd,H.colEnd)};let de;return typeof Ze.current=="function"?de=Ze.current(S):U&&(de=U),de?G.extendRangeToUnionRanges(S,de):S},[N,z]),Te=T((a,f,m)=>{const w=a.ranges.length>0?a.ranges[a.rangeIndex]:{rowStart:a.cell.rowIndex,colStart:a.cell.colIndex,rowEnd:a.cell.rowIndex,colEnd:a.cell.colIndex},v={rowStart:Math.min(f.rowIndex??w.rowStart,m.rowIndex??w.rowStart),colStart:Math.min(f.colIndex??w.colStart,m.colIndex??w.colStart),rowEnd:Math.max(f.rowIndex??w.rowEnd,m.rowIndex??w.rowEnd),colEnd:Math.max(f.colIndex??w.colEnd,m.colIndex??w.colEnd)},H={rowIndex:v.rowStart,colIndex:v.colStart},S={rowIndex:v.rowEnd,colIndex:v.colEnd};if(!(ct(H)||ct(S)))return Ee(H,S)},[Ee]),tt=T((a,f,m)=>{if(s==="single"||!xe.current)return;const w=Te(xe.current,a,f??xe.current.cell);if(!w)return;const v=xe.current.rangeIndex;ft(H=>H.length?H.map((S,de)=>v===de?w:S):[w]),m&&w&&Ge({colIndex:w.colStart,rowIndex:w.rowStart})},[]),Je=c.useCallback((a,f,m)=>{if(!xe.current)return;a={...xe.current?.cell,...a},f=f??a;const w=Te(xe.current,a,f);if(!w)return;const v={rowIndex:w.rowStart,colIndex:w.colStart},H={...v,...m};u==="clear"?(Fe.current=H,Gt()):u==="modify"?tt(v):Le(v),Ge(H)},[]),Le=c.useCallback((a,f=a,m)=>{s!=="multiple"||!a||ct(a)||ct(f)||xt(w=>{Ye.current=!1,w=$t(w);const v=Ee(a,f);if(!v)return w;let H=w.ranges.length>0?[...w.ranges]:[Ee(w.cell,w.cell)];H.push(v);const S={ranges:H,cell:{rowIndex:v.rowStart,colIndex:v.colStart,...m},rangeIndex:H.length-1};return G.isEqualSelectionCoords(S,w)?w:S})},[]),Gt=()=>{ft(Ho)},_t=ge.detectIt().primaryInput==="touch",Qe=c.useRef(null),Ct=c.useRef(null),Rt=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 Ct.current={topLeft:m.getScrollTopLeft(),point:{x:f.clientX,y:f.clientY}},!0;const w=m.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);if(!w)return!1;Qe.current={anchor:m.getAnchor(),coords:w},Q.current=null;const v=a.nativeEvent.which===yr;if(v&&G.indexOfCoords(w,M.ranges)!==-1)return!1;const H=a.nativeEvent.shiftKey,S=a.nativeEvent.ctrlKey||a.nativeEvent.metaKey,de=S,ne=d,re=M.ranges.length>0,pe=S&&ne;if(oe?.(a,w,M)===!1)return!1;i?.(xe.current,a.nativeEvent);const Pe=!v&&s!=="single";if(H)return tt(w),Pe;const ae=G.isEqualCells(w,M.cell);if(de){if(ae&&(!pe||!re))return Pe;if(S&&G.indexOfCoords(w,M.ranges)!==-1&&ne){pt.current=w;const ie=Ee(w,w);return jt.current=ie,Ft(ie),Pe}return Le(w),Pe}le&&He(w),ae&&M.ranges.length===0||Je(w)},onPointerMoveOrWait:St.throttle((a,f)=>{if(!e?.current||a.pointerType==="touch"||a.type==="touchmove"||!Qe.current)return;const m=Qe.current.anchor;let w=e.current.getViewFromLocation(m),v=w.getCellCoordsFromClient(a.clientX,a.clientY);if(!G.isEqualCells(v,Qe.current?.coords)&&(Qe.current={anchor:m,coords:v},v&&be?.(a,v,xe.current)!==!1)){if(pt.current){const H={rowStart:Math.min(v.rowIndex,pt.current.rowIndex),colStart:Math.min(v.colIndex,pt.current.colIndex),rowEnd:Math.max(v.rowIndex,pt.current.rowIndex),colEnd:Math.max(v.colIndex,pt.current.colIndex)},S={rowIndex:H.rowStart,colIndex:H.colStart},de={rowIndex:H.rowEnd,colIndex:H.colEnd};if(ct(S)||ct(de))return;const ne=Ee(S,de);jt.current=ne,Ft(ne)}else tt(v);Rt.current=f,Gn(w,v,e)}},60),onPointerUp:a=>{if(Qe.current=null,a.pointerType==="touch"||a.type==="touchend"){if(Ct.current){const m=e.current.getViewFromClient(Ct.current.point.x,Ct.current.point.y),w=m.getScrollTopLeft();if(w.left===Ct.current.topLeft.left&&w.top===Ct.current.topLeft.top){const v=m.getCellCoordsFromClient(Ct.current.point.x,Ct.current.point.y);Je(v)}}return Ct.current=null,void(Qe.current=null)}try{l?.(xe.current,a)}catch(m){console.warn(m)}if(!pt.current)return;const f=jt.current;pt.current=null,jt.current=null,Ft(null),xt(m=>{if(Ye.current=!1,(m=$t(m)).ranges.length===0)return m;let w=[],v=-1,H=m.cell;for(let de=0;de<m.ranges.length;de++){const ne=m.ranges[de];if(G.isRangesIntersect(ne,f)){const re=St.subtractRect({top:ne.rowStart,left:ne.colStart,bottom:ne.rowEnd+1,right:ne.colEnd+1},{top:f.rowStart,left:f.colStart,bottom:f.rowEnd+1,right:f.colEnd+1});for(let pe=0;pe<re.length;pe++){const Pe={rowStart:re[pe].top,colStart:re[pe].left,rowEnd:re[pe].bottom-1,colEnd:re[pe].right-1};w.push(Pe),G.isCellWithinRange(m.cell,Pe)&&(v=w.length-1)}}else w.push(ne);w.length>0&&v===-1&&G.isCellWithinRange(m.cell,ne)&&(v=w.length-1,H={rowIndex:w[w.length-1].rowStart,colIndex:w[w.length-1].colStart})}const S={cell:H,rangeIndex:v,ranges:w};return G.isEqualSelectionCoords(S,m)?m:S})},processTouch:!0,consumeTouch:!1}),[M,s,d,le,u]),so=T(bn(on),[]),co=c.useMemo(()=>({onSelectionPointerDown:(a,f,m,w,v=M.cell,H=le,S=a.nativeEvent.shiftKey,de=!1)=>{if(!e||!e.current)return!1;a.stopPropagation(),a.preventDefault(),a.nativeEvent.stopImmediatePropagation();const ne=m??e.current.getViewFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY),re=w??ne.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);if(!re)return!1;Qe.current={anchor:ne.getAnchor(),coords:re},Q.current=null;const pe=a.nativeEvent.which===yr;if(pe&&G.indexOfCoords(re,M.ranges)!==-1)return!1;const Pe=a.nativeEvent.ctrlKey||a.nativeEvent.metaKey,ae=Pe,ie=d,bt=M.ranges.length>0,F=Pe&&ie;if(oe?.(a,re,M)===!1)return!1;i?.(xe.current,a.nativeEvent);const Re=!pe&&s!=="single";if(S)return tt(re,v,de),Re;const Mt=G.isEqualCells(re,v);if(ae){if(Mt&&(!F||!bt))return Re;if(F&&G.indexOfCoords(re,M.ranges)!==-1&&ie){pt.current=re;const Me=Ee(re,re);return jt.current=Me,Ft(Me),Re}return Le(re),Re}H&&He(re),Mt&&M.ranges.length===0||Je(re)},onSelectionPointerMoveOrWait:(a,f,m,w,v,H=M.cell,S=!0,de=!1)=>{if(!e?.current||(a.stopPropagation(),a.preventDefault(),a.stopImmediatePropagation(),!Qe.current))return;const ne=Qe.current.anchor;let re=w??e.current.getViewFromLocation(ne),pe=v??re.getCellCoordsFromClient(a.clientX,a.clientY);if(!G.isEqualCells(pe,Qe.current?.coords)&&(Qe.current={anchor:ne,coords:pe},pe&&be?.(a,pe,xe.current)!==!1)){if(pt.current){const Pe={rowStart:Math.min(pe.rowIndex,pt.current.rowIndex),colStart:Math.min(pe.colIndex,pt.current.colIndex),rowEnd:Math.max(pe.rowIndex,pt.current.rowIndex),colEnd:Math.max(pe.colIndex,pt.current.colIndex)},ae={rowIndex:Pe.rowStart,colIndex:Pe.colStart},ie={rowIndex:Pe.rowEnd,colIndex:Pe.colEnd};if(ct(ae)||ct(ie))return;const bt=Ee(ae,ie);jt.current=bt,Ft(bt)}else tt(pe,H,de);S&&Gn(re,pe,e)}},onPointerUp:a=>{Qe.current=null,a.stopPropagation(),a.preventDefault(),a.stopImmediatePropagation();try{l?.(xe.current,a)}catch(m){console.warn(m)}if(!pt.current)return;const f=jt.current;pt.current=null,jt.current=null,Ft(null),xt(m=>{if(Ye.current=!1,(m=$t(m)).ranges.length===0)return m;let w=[],v=-1,H=m.cell;for(let de=0;de<m.ranges.length;de++){const ne=m.ranges[de];if(G.isRangesIntersect(ne,f)){const re=St.subtractRect({top:ne.rowStart,left:ne.colStart,bottom:ne.rowEnd+1,right:ne.colEnd+1},{top:f.rowStart,left:f.colStart,bottom:f.rowEnd+1,right:f.colEnd+1});for(let pe=0;pe<re.length;pe++){const Pe={rowStart:re[pe].top,colStart:re[pe].left,rowEnd:re[pe].bottom-1,colEnd:re[pe].right-1};w.push(Pe),G.isCellWithinRange(m.cell,Pe)&&(v=w.length-1)}}else w.push(ne);w.length>0&&v===-1&&G.isCellWithinRange(m.cell,ne)&&(v=w.length-1,H={rowIndex:w[w.length-1].rowStart,colIndex:w[w.length-1].colStart})}const S={cell:H,rangeIndex:v,ranges:w};return G.isEqualSelectionCoords(S,m)?m:S})}}),[M,s,d,le,u]),ut=T((a,f=!1,m=!1,w=0)=>{if(!e.current||!M.cell)return;let v=M.cell,H=M.cell;if(f&&M.ranges.length>0){const F=M.ranges[M.rangeIndex],Re=M.cell;switch(a){case nt:H={rowIndex:Re.rowIndex===F.rowStart?F.rowEnd:F.rowStart,colIndex:F.colEnd},v={rowIndex:Re.rowIndex===F.rowStart?F.rowStart:F.rowEnd,colIndex:F.colStart};break;case ot:H={rowIndex:Re.rowIndex===F.rowEnd?F.rowStart:F.rowEnd,colIndex:F.colEnd},v={rowIndex:Re.rowIndex===F.rowEnd?F.rowEnd:F.rowStart,colIndex:F.colStart};break;case et:H={rowIndex:F.rowEnd,colIndex:Re.colIndex===F.colStart?F.colEnd:F.colStart},v={rowIndex:F.rowStart,colIndex:Re.colIndex===F.colStart?F.colStart:F.colEnd};break;case Ne:H={rowIndex:F.rowEnd,colIndex:Re.colIndex===F.colEnd?F.colStart:F.colEnd},v={rowIndex:F.rowStart,colIndex:Re.colIndex===F.colEnd?F.colEnd:F.colStart}}}const S=z(H);let{rowStart:de,colStart:ne}=S;const re=ve();if(Q.current)switch(a){case nt:case ot:Q.current.colIndex>=S.colStart&&Q.current.colIndex<=S.colEnd&&(ne=Q.current.colIndex);break;case et:case Ne:Q.current.rowIndex>=S.rowStart&&Q.current.rowIndex<=S.rowEnd&&(de=Q.current.rowIndex)}if(!w){switch(a){case nt:de=Ue(lt,Math.max(S.rowStart-1,re.top),a);break;case ot:de=Ue(lt,Math.min(S.rowEnd+1,re.bottom),a);break;case et:ne=Ue(st,Math.max(S.colStart-1,re.left),a);break;case Ne:ne=Ue(st,Math.min(S.colEnd+1,re.right),a)}if(m)switch(a){case nt:de=I({...H,colIndex:M.cell.colIndex},ue,lt,a,!1,Math.max(re.top,lt(re.top,!1)));break;case ot:de=I({...H,colIndex:M.cell.colIndex},ue,lt,a,!1,Math.min(re.bottom,re.bottom-lt(re.bottom,!0)));break;case et:ne=I({...H,rowIndex:M.cell.rowIndex},ue,st,a,!1,Math.max(re.left,st(re.left,!1)));break;case Ne:ne=I({...H,rowIndex:M.cell.rowIndex},ue,st,a,!1,Math.min(re.right,re.right-st(re.right,!0)))}}let pe=null;if(w){let F=0;switch(a){case nt:F=n.getRowOffset(de+1),de=Math.max(re.top,n.getRowIndex(F-w)),pe={top:n.getRowOffset(de+1)-(F-e.current.getScrollPosition().top)};break;case ot:F=n.getRowOffset(de),de=Math.min(re.bottom,n.getRowIndex(F+w)),pe={top:n.getRowOffset(de)-(F-e.current.getScrollPosition().top)};break;case et:F=n.getColOffset(ne+1),ne=Math.max(re.left,n.getColIndex(F-w)),pe={left:n.getColOffset(ne+1)-(F-e.current.getScrollPosition().left)};break;case Ne:F=n.getColOffset(ne),ne=Math.min(re.right,n.getColIndex(F+w)),pe={left:n.getColOffset(ne)-(F-e.current.getScrollPosition().left)}}}const Pe={rowIndex:de,colIndex:ne},ae=z(Pe),ie={rowIndex:ae.rowStart,colIndex:ae.colStart};f||(Q.current=Pe);const bt=G.isEqualCells(Fe.current,ie)&&G.isEqualCells(Fe.current,v);if(f&&!bt?tt(ie,v):Je(ie),pe)e.current.scrollTo(pe);else{if(f&&Fe.current){const F=ve();if(a===Ne&&Fe.current.colIndex===F.left||a===et&&Fe.current.colIndex===F.right||a===nt&&Fe.current.rowIndex===F.bottom||a===ot&&Fe.current.rowIndex===F.top)return}a===et||a===Ne?He({colIndex:Pe.colIndex}):a!==nt&&a!==ot||He({rowIndex:Pe.rowIndex})}},[M,z]),Zt=T(a=>{if(!e.current)return;if(M.ranges.length===0)return void ut(a);const f=z(M.cell);if(G.isEqualRangesArrays([f],M.ranges))return void ut(a);const m=Fo(M,a,z,lt,st);xt(w=>{Ye.current=!1,w=$t(w);const v={...w,cell:m.cell,rangeIndex:m.rangeIndex};return G.isEqualSelectionCoords(v,w)?w:v}),m.cell&&He(m.cell)},[M,z]),ao=c.useCallback(()=>{const a=ve();tt({rowIndex:a.top},{rowIndex:a.bottom})},[]),uo=c.useCallback(()=>{const a=ve();tt({colIndex:a.left},{colIndex:a.right})},[]),an=T(()=>{M.cell&&e?.current&&He(M.cell)},[M.cell]),An=c.useCallback((a=!1)=>{const f={rowIndex:ve().top};a?tt(f):Je(f),He(f)},[]),$n=c.useCallback((a=!1)=>{const f={rowIndex:ve().bottom};a?tt(f):Je(f),He(f)},[]),_n=c.useCallback((a=!1)=>{const f={colIndex:ve().left};a?tt(f):Je(f),He(f)},[]),mn=c.useCallback((a=!1)=>{const f=ve(),m={rowIndex:f.top,colIndex:f.left};a?tt(m):Je(m),He(m)},[]),Cn=c.useCallback((a=!1)=>{const f=ve(),m={colIndex:j?.()?.colEnd??f.right};a?tt(m):Je(m),He(m)},[j]),un=c.useCallback((a=!1)=>{const f=ve(),m={rowIndex:j?.()?.rowEnd??f.bottom,colIndex:j?.()?.colEnd??f.right};a?tt(m):Je(m),He(m)},[j]),In=T(a=>{if(!e.current||M.ranges.length<=1)return;const f=a===et||a===nt;let m=M.rangeIndex+(f?-1:1);m<0?m=M.ranges.length-1:m>M.ranges.length-1&&(m=0);const w=M.ranges[m],v=Fo({cell:{rowIndex:w.rowEnd,colIndex:w.colEnd},rangeIndex:0,ranges:[w]},Ne,z,lt,st);xt(H=>{Ye.current=!1,H=$t(H);const S={...H,cell:v.cell,rangeIndex:m};return G.isEqualSelectionCoords(S,H)?H:S}),v.cell&&He(v.cell)},[M,z]),ho=T(()=>{const a=Pr(M);xt(f=>{Ye.current=!1,f=$t(f);const m={...f,visibleSelection:a};return G.isEqualSelectionCoords(m,f)?f:m}),a.cell&&He(a.cell)},[M,z]),fo=T(()=>{if(!e.current||M.ranges.length===0)return;const a=M.cell,f=M.ranges[M.rangeIndex],m=Pr({cell:a,rangeIndex:0,ranges:[f]}),w=m.ranges[m.rangeIndex];let v;v=w.rowStart===a.rowIndex&&w.colStart===a.colIndex?{rowIndex:w.rowStart,colIndex:w.colEnd}:w.rowStart===a.rowIndex&&w.colEnd===a.colIndex?{rowIndex:w.rowEnd,colIndex:w.colStart}:w.rowEnd===a.rowIndex&&w.colStart===a.colIndex?{rowIndex:w.rowEnd,colIndex:w.colEnd}:{rowIndex:w.rowStart,colIndex:w.colStart},xt(H=>{H=$t(H);const S={...H,cell:v};return G.isEqualSelectionCoords(S,H)?H:S}),v&&He(v)},[M,z]),Bn=c.useCallback((a=!1)=>{ut(ot,a,!1,e.current.getDimensions().containerHeight)},[]),Kt=c.useCallback((a=!1)=>{ut(nt,a,!1,e.current.getDimensions().containerHeight)},[]),Fn=c.useCallback((a=!1)=>{ut(Ne,a,!1,e.current.getDimensions().containerWidth)},[]),Mn=c.useCallback((a=!1)=>{ut(et,a,!1,e.current.getDimensions().containerWidth)},[]),Vn=c.useCallback(()=>{Zt(et)},[]),Wn=c.useCallback(()=>{Zt(Ne)},[]),po=c.useCallback(()=>{Zt(nt)},[]),go=c.useCallback(()=>{Zt(ot)},[]),Rn=c.useCallback(()=>{In(et)},[]),wo=c.useCallback(()=>{In(Ne)},[]),mo=c.useCallback(()=>{fo()},[]),Hn=c.useCallback(()=>{ut(et,!1,!1)},[]),b=c.useCallback(()=>{ut(et,!0,!1)},[]),D=c.useCallback(()=>{ut(et,!1,!0)},[]),A=c.useCallback(()=>{ut(et,!0,!0)},[]),V=c.useCallback(()=>{ut(Ne,!1,!1)},[]),W=c.useCallback(()=>{ut(Ne,!0,!1)},[]),he=c.useCallback(()=>{ut(Ne,!1,!0)},[]),se=c.useCallback(()=>{ut(Ne,!0,!0)},[]),me=c.useCallback(()=>{ut(nt,!1,!1)},[]),ye=c.useCallback(()=>{ut(nt,!0,!1)},[]),ce=c.useCallback(()=>{ut(nt,!1,!0)},[]),$e=c.useCallback(()=>{ut(nt,!0,!0)},[]),at=c.useCallback(()=>{ut(ot,!1,!1)},[]),je=c.useCallback(()=>{ut(ot,!0,!1)},[]),Ae=c.useCallback(()=>{ut(ot,!1,!0)},[]),dt=c.useCallback(()=>{ut(ot,!0,!0)},[]),qe=c.useCallback(()=>{ft(a=>a.slice(0,-1))},[]),kt=c.useMemo(()=>{const a=ve();return((f,m,w,v,H)=>{for(let S=0;S<f.length;S++){const de=f[S];if(de.rowStart===m&&de.colStart===w&&de.rowEnd===v&&de.colEnd===H)return!0}return!1})(M.ranges,a.top,a.left,a.bottom,a.right)},[B,M.ranges]),gt=c.useCallback((a,f=!0)=>{Fe.current=a,Ge(a),f&&a&&e?.current&&He(a)},[]),fe=T((a=!0)=>{const f=Xt.current;if(!xe.current?.cell)return;const m=xe.current?.ranges,w=xe.current?.cell;if(!w||!f||!f)return;let v=null;if(v=m.length>0?m[m.length-1]:z(w),v.colEnd>=v.colStart&&v.rowEnd>=v.rowStart){const H=Or(v,f);let S=a?Ke:$;try{S?.(v,f,H.direction)}catch(de){console.warn(de)}finally{a&&Ce?.()}}},[z]),ht=c.useRef(null),Ot=bn(c.useMemo(()=>({onPointerDown:(a,f)=>{if(Rt.current=f,!e||!e.current)return!1;const m=e.current.getViewFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY),w=m?.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);w&&(a.stopPropagation(),Yt("crosshair"),ht.current={anchor:m.getAnchor(),coords:w})},onPointerMoveOrWait:(a,f)=>{if(R||!e?.current||!xe.current||!ht.current)return;const m=ht.current.anchor;let w=e.current.getViewFromLocation(m),v=w.getCellCoordsFromClient(a.clientX,a.clientY);if(!v)return;ht.current={anchor:m,coords:v};const H=xe.current.ranges;let S=Ee(xe.current.cell,v);if(!S)return;const de=H.length>0,ne=de?H[H.length-1]:z(xe.current.cell);if(!S)return;const re=S.rowStart<ne.rowStart?nt:S.rowEnd>ne.rowEnd?ot:S.colEnd>ne.colEnd?Ne:et,pe=ve();re===et&&(S={...ne,colStart:Math.max(pe.left,S.colStart)}),re===nt&&(S={...ne,rowStart:Math.max(pe.top,S.rowStart)}),re===Ne&&(S={...ne,colEnd:Math.min(pe.right,S.colEnd)}),re===ot&&(S={...ne,rowEnd:Math.min(pe.bottom,S.rowEnd)});const Pe=Or(ne,S);if(!N?.(ne)){let ae;typeof Ze.current=="function"?ae=Ze.current(ne):U&&(ae=U),S=((ie,bt,F,Re,Mt,Me)=>{const Ie={...bt};if(F.length===0)return Ie;if(Mt===et){const mt=ie.colEnd+1-ie.colStart;Ie.colStart=ie.colStart-Math.ceil(Me/mt)*mt,Ie.colStart<Re.left&&(Ie.colStart=Ie.colStart+Math.ceil((Re.left-Ie.colStart)/mt)*mt)}else if(Mt===Ne){const mt=ie.colEnd+1-ie.colStart;Ie.colEnd=ie.colEnd+Math.ceil(Me/mt)*mt,Ie.colEnd>Re.right&&(Ie.colEnd=Ie.colEnd-Math.ceil((Re.right-Ie.colEnd)/mt)*mt)}else if(Mt===nt){const mt=ie.rowEnd+1-ie.rowStart;Ie.rowStart=ie.rowStart-Math.ceil(Me/mt)*mt,Ie.rowStart<Re.top&&(Ie.rowStart=Ie.rowStart+Math.ceil((Re.top-Ie.rowStart)/mt)*mt)}else if(Mt===ot){const mt=ie.rowEnd+1-ie.rowStart;Ie.rowEnd=ie.rowEnd+Math.ceil(Me/mt)*mt,Ie.rowEnd>Re.bottom&&(Ie.rowEnd=Ie.rowEnd-Math.ceil((Re.bottom-Ie.rowEnd)/mt)*mt)}return Ie})(ne,S,ae,pe,Pe.direction,Pe.amount)}if(de&&G.isRangeWithinRange(S,ne)&&(S=null),!G.isEqualRanges(S,Xt.current)){if(tn(S),Xt.current=S,!S){try{_?.()}catch{}return void Ce?.()}fe(!1)}Rt.current=f,Gn(w,v,e)},onPointerUp:(a,f)=>{Rt.current=f,Promise.resolve(fe(!0)).finally(()=>{Ce?.(),tn(null),Xt.current=null,ht.current=null,Yt(null),e.current?.focus()})}}),[z])),At=c.useMemo(()=>({onPointerDown:Ot}),[Ot]),[_e,Xe]=c.useState(null),De=c.useRef(null),rt=c.useMemo(()=>({onPointerDown:(a,f)=>{if(Rt.current=f,!e||!e.current)return!1;const m=e.current.getViewFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY),w=m?.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);if(!w)return;if(oe?.(a,w,M)===!1)return!1;a.stopPropagation(),Yt("default");const v=m.getRelativePointFromClient(0,0),H=xe.current?.ranges[xe.current?.ranges.length-1]??G.cellToRange(xe.current?.cell),S=m.toClipBounds(m.getRangeCoordsBounds(H)),de={x:0,y:0};S.x-v.x>a.nativeEvent.clientX?de.x=a.nativeEvent.clientX-(S.x-v.x):a.nativeEvent.clientX>=S.x-v.x+S.width&&(de.x=Math.max(0,a.nativeEvent.clientX-(S.x-v.x+S.width))+1),S.y-v.y>a.nativeEvent.clientY?de.y=a.nativeEvent.clientY-(S.y-v.y):a.nativeEvent.clientY>=S.y-v.y+S.height&&(de.y=Math.max(0,a.nativeEvent.clientY-(S.y-v.y+S.height))+1),Y?.(H,a.nativeEvent,f),De.current={range:H,anchor:m.getAnchor(),cell:w,isMoving:!1,extrusion:de}},onPointerMoveOrWait:(a,f,m)=>{if(q||!e?.current||!xe.current||!De.current)return;const w=a.clientX-m.clientX,v=a.clientY-m.clientY;if(De.current.isMoving=De.current.isMoving||Math.abs(w)>Math.max(1,2)||Math.abs(v)>Math.max(1,2)||performance.now()-m.timeStamp>500,!De.current.isMoving)return;const H=De.current.anchor,S=De.current.extrusion;let de=e.current.getViewFromLocation(H),ne=de.getCellCoordsFromClient(a.clientX-S.x,a.clientY-S.y,!0);if(!ne)return;const re=De.current.cell,pe=De.current.range,Pe=ve(),ae=pe.colEnd-pe.colStart+1,ie=Math.min(Math.max(0,re.colIndex-pe.colStart),ae-1),bt=Math.min(Pe.right-ae+1,Math.max(Pe.left,ne.colIndex-ie)),F=pe.rowEnd-pe.rowStart+1,Re=Math.min(Math.max(0,re.rowIndex-pe.rowStart),F-1),Mt=Math.min(Pe.bottom-F+1,Math.max(Pe.top,ne.rowIndex-Re)),Me={colStart:bt,colEnd:bt+ae-1,rowStart:Mt,rowEnd:Mt+F-1};G.isEqualRanges(_e,Me)&&!(Ie=>!Ie||!Rt.current||Rt.current.ctrlKey!==Ie.ctrlKey||Rt.current.shiftKey!==Ie.shiftKey||Rt.current.altKey!==Ie.altKey||Rt.current.metaKey!==Ie.metaKey)(a)||(Xe(Me),k?.(Me,a,f)),Rt.current=f,Gn(de,ne,e)},onPointerUp:(a,f)=>{Rt.current=f;const m=()=>{Xe(null),De.current=null,Yt(null),e.current?.focus()};if(!De.current)return void m();const w=De.current.range,v=_e;E?.(w,a,f),Promise.resolve(w&&v&&g?.(w,v,a,f)).finally(()=>{m()})}}),[_e]),ke=bn(rt),yt=c.useMemo(()=>({onPointerDown:ke}),[ke]),wt=c.useRef(null),Lt=c.useMemo(()=>{const a=G.isEqualSelectionCoords(M,wt.current)?wt.current:M;return wt.current=a,a},[M]),Vt=c.useCallback(a=>{let f=null,m="br";const w=[],v={stroke:C,fill:te,strokeWidth:.5},H=(ae,ie,bt)=>{const F=a.toClipBounds(a.getRangeCoordsBounds(ae),Wt);if(!F)return;F.x=F.width>0?F.x:F.x-v.strokeWidth/2,F.y=F.height>0?F.y:F.y-v.strokeWidth/2,F.width=Math.max(F.width,v.strokeWidth),F.height=Math.max(F.height,v.strokeWidth);const Re={key:`selection-fill-${ie}`,range:ae,...F,...v};if(bt){const Mt=a.getCellCoordsAsRangeCoords(bt);Re.cell=bt,Re.pathBounds=a.toClipBounds(a.getRangeCoordsBounds(Mt),Wt),Re.pathBounds&&(Re.pathBounds.width<=0||Re.pathBounds.height<=0)&&(delete Re.pathBounds,delete Re.cell)}return we(Re)};let S=M?$t(M):null;const de=S?.cell?a.getCellCoordsAsRangeCoords(S?.cell):Vl;!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 ie=S.ranges[ae],bt=H(ie,ae,ae===S.rangeIndex?S.cell:null);bt&&w.push(bt);const F=2,Re=.5,Mt=a.toClipBounds(a.getRangeCoordsBounds(ie,{top:0,left:0,right:0,bottom:0}),Wt);if(Mt){const Me=(S.ranges.length,4);w.push(we({range:ie,key:`selection-inside-edge-${ae}`,x:Mt.x-1,y:Mt.y-1,width:Math.max(Mt.width+1,0),height:Math.max(Mt.height+1,0),style:{overflow:"hidden"},stroke:C,strokeWidth:Me}))}if(S.ranges.length===1){const Me=a.toClipBounds(a.getRangeCoordsBounds(ie),Wt);if(Me){q||w.push(we({range:ie,key:`move-selection-hit-box-${ae}`,x:Me.width>1?Me.x:Me.x-(K/2+1),y:Me.height>1?Me.y:Me.y-(K/2+1),width:Math.max(Me.width+2,1),height:Math.max(Me.height+2,1),stroke:"transparent",style:{boxShadow:"none"},pathProps:{cursor:_e?void 0:"move",pointerEvents:"stroke"},strokeWidth:K,...yt}));const Ie=F;w.push(we({range:ie,key:`selection-single-${ae}`,x:Me.x-Ie/2,y:Me.y-Ie/2,width:Math.max(Me.width+Ie/2,1),height:Math.max(Me.height+Ie/2,1),stroke:X,strokeWidth:Ie}))}}else{const Me=a.toClipBounds(a.getRangeCoordsBounds(ie,{top:-1,left:-1,right:-2,bottom:-2}),Wt);Me&&w.push(we({range:ie,key:`selection-multi-${ae}`,x:Me.width>1?Me.x:Me.x-Re/2,y:Me.height>1?Me.y:Me.y-Re/2,width:Math.max(Me.width,Re)+1,height:Math.max(Me.height,Re)+1,stroke:X,style:{overflow:"hidden"},strokeWidth:2}))}if(S.ranges.length>1&&ae===S.rangeIndex){const Me=a.getCellCoordsAsRangeCoords(S.cell),Ie=a.toClipBounds(a.getRangeCoordsBounds(Me,{top:1,left:1,right:-1,bottom:-1}),Wt);Ie&&w.push(we({range:ie,key:`selection-anchor-${ae}`,x:Ie.x,y:Ie.y,width:Math.max(Ie.width,Re),height:Math.max(Ie.height,Re),stroke:X,style:{overflow:"hidden"},strokeWidth:2}))}if(ae===S.ranges.length-1){f=null,m=null;const Me=ie.rowStart===ve().top&&ie.rowEnd===ve().bottom,Ie=ie.colStart===ve().left&&ie.colEnd===ve().right,mt=a.getRangeCoordsBounds(ie);let qt=null;if(Me||Ie){if(qt=a.toClipBounds(mt,Wt),Object.keys(a.allViews()).length>1){const Nn=a.getVisibleRangeCoords(),Zo=a.allViews()[to],Ri=a.allViews()[Ln],ki=a.allViews()[Dn],Un=a.getAnchor();(Ie&&(Un===Ln&&Zo||Un===Ht&&ki||!G.isCellWithinRange({colIndex:ie.colStart,rowIndex:ie.rowEnd},Nn)&&!G.isCellWithinRange({colIndex:ie.colStart,rowIndex:ie.rowEnd+1},Nn))||Me&&(Un===Dn&&Zo||Un===Ht&&Ri||!G.isCellWithinRange({colIndex:ie.colEnd,rowIndex:ie.rowStart},Nn)&&!G.isCellWithinRange({colIndex:ie.colEnd+1,rowIndex:ie.rowStart},Nn)))&&(qt=null)}}else qt=a.toClipBounds(mt,Wt);if(!qt||qt.width===0||qt.height===0)continue;f={x:qt.x+qt.width+1,y:qt.y+qt.height+1},qt.width===0||qt.height===0||ie.rowStart===ve().top&&ie.colStart===ve().left&&ie.rowEnd===ve().bottom&&ie.colEnd===ve().right||(Me?(f.y=F,m="tr"):Ie&&(f.x=F,m="bl"))}}let ne=null;if(Oe){const ae=a.toClipBounds(a.getRangeCoordsBounds(Oe,{top:0,left:0,right:0,bottom:0}),Wt);ae&&(ne=we({...v,range:Oe,key:"remove-selection",x:ae.x,y:ae.y,width:ae.width,height:ae.height,strokeWidth:2,stroke:Ve,fill:Be}))}let re=null;if(Et){const ae=a.toClipBounds(a.getRangeCoordsBounds(Et,{top:0,left:0,right:0,bottom:0}),Wt);ae&&(re=we({range:Et,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:X,strokeDasharray:"3 2"}))}let pe=null;!R&&f&&!_e&&(pe=c.createElement(Wo,{...f,corner:m,size:7.5,borderStroke:`${C} solid`,style:{borderRadius:1},background:X,...At,key:"fillHandle"}));const Pe=[...w];if(ne&&Pe.push(ne),re&&Pe.push(re),pe&&Pe.push(pe),!We&&_t&&S?.ranges.length===1&&S.ranges[S.ranges.length-1]){const ae=S.ranges[S.ranges.length-1],ie=ae.rowStart===ve().top&&ae.rowEnd===ve().bottom,bt=ae.colStart===ve().left&&ae.colEnd===ve().right,F={view:a,range:ae,borderStroke:`${X} solid`,background:C,selectionTouchPointerHandler:co,...it,onTouchSelectStart:Re=>nn(Re),onTouchSelectEnd:()=>nn(null),currentTouchAnchor:wn};Pe.push(P.jsx(Qn,{anchor:bt?"b":ie?"r":"br",scrollableElement:e.current,...F},"touch-select-handle-after")),Pe.push(P.jsx(Qn,{anchor:bt?"t":ie?"l":"tl",scrollableElement:e.current,...F},"touch-select-handle-before"))}if(_e){const ae=a.toClipBounds(a.getRangeCoordsBounds(_e,{top:1,left:1,right:1,bottom:1}),Wt);ae&&Pe.push(we({range:_e,key:"selection-move-outline",x:ae.x-ee/2,y:ae.y-ee/2,width:Math.max(ae.width+ee/2,1),height:Math.max(ae.height+ee/2,1),stroke:X,style:{boxShadow:"none",transitionDuration:"70ms",transitionTimingFunction:"ease-in",transitionProperty:"left, top, width, height",willChange:"left, top, width, height"},strokeWidth:ee}))}return P.jsx("div",{children:Pe},"selection")},[Lt,Oe,R,Et,q,_e,ve,C,X,te,Ve,Be,We,it,wn]),Tt=c.useMemo(()=>{const a=()=>e.current;return[new Se("moveToPageDown",a,{label:"Page Down",description:"Shift viewport down one page.",shortcut:[{key:"PageDown"}]},()=>Bn(!1)),new Se("selectToPageDown",a,{label:"Select To Page Down",description:"Shift viewport and select down one page.",shortcut:[{key:"PageDown",modifiers:[vt]}]},()=>Bn(!0)),new Se("moveToPageRight",a,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[dn]}]},()=>Fn(!1)),new Se("selectToPageRight",a,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[dn,vt]}]},()=>Fn(!0)),new Se("moveToPageUp",a,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp"}]},()=>Kt(!1)),new Se("selectToPageUp",a,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp",modifiers:[vt]}]},()=>Kt(!0)),new Se("moveToPageLeft",a,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[dn]}]},()=>Mn(!1)),new Se("selectToPageLeft",a,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[dn,vt]}]},()=>Mn(!0)),new Se("selectColumn",a,{label:"Select Column",description:"Select the columns for the selected cells.",shortcut:{key:"Space",modifiers:[Pt]}},ao),new Se("selectRow",a,{label:"Select Row",description:"Select the rows for the selected cells.",shortcut:{key:"Space",modifiers:[vt]}},uo),new Se("selectToColumnStart",a,{label:"Select To Column Start",description:"Select the columns to the beginning of the sheet."},()=>An(!0)),new Se("selectToColumnEnd",a,{label:"Select To Column End",description:"Select the columns to the end of the sheet."},()=>$n(!0)),new Se("moveToRowStart",a,{label:"Move to Row Home",description:"Move to the beginning of the row.",shortcut:[{key:"Home"}]},()=>_n(!1)),new Se("selectToRowStart",a,{label:"Select to Row Home",description:"Select to the beginning of the row.",shortcut:[{key:"Home",modifiers:[vt]}]},()=>_n(!0)),new Se("moveToSheetStart",a,{label:"Move to Sheet Home",description:"Move to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[Pt]}]},()=>mn(!1)),new Se("selectToSheetStart",a,{label:"Select to Sheet Home",description:"Select to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[Pt,vt]}]},()=>mn(!0)),new Se("moveToRowEnd",a,{label:"Move to Row End",description:"Move to the end of the row.",shortcut:[{key:"End"}]},()=>Cn(!1)),new Se("selectToRowEnd",a,{label:"Select to Row End",description:"Select to the end of the row.",shortcut:[{key:"End",modifiers:[vt]}]},()=>Cn(!0)),new Se("moveToSheetEnd",a,{label:"Move to Sheet End",description:"Move to the end of the sheet.",shortcut:[{key:"End",modifiers:[Pt]}]},()=>un(!1)),new Se("selectToSheetEnd",a,{label:"Select to Sheet End",description:"Select to the end of the sheet.",shortcut:[{key:"End",modifiers:[Pt,vt]}]},()=>un(!0)),new Se("scrollToActiveCoords",a,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell.",shortcut:{key:"Backspace",modifiers:[Pt]}},an),new Se("scrollToActiveCoordsClearSelection",a,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell and clear selection.",shortcut:{key:"Backspace",modifiers:[vt]}},()=>{Gt(),gt(M.cell,!0)}),new Se("traverseSelectionRight",a,{label:"Traverse Right",description:"Traverse the selection moving rightward.",shortcut:{key:"Tab"}},Wn),new Se("traverseSelectionLeft",a,{label:"Traverse Left",description:"Traverse the selection moving leftward.",shortcut:{key:"Tab",modifiers:[vt]}},Vn),new Se("traverseSelectionDown",a,{label:"Traverse Down",description:"Traverse the selection moving downward.",shortcut:[{key:"Enter"},{key:"NumpadEnter"}]},go),new Se("traverseSelectionUp",a,{label:"Traverse Up",description:"Traverse the selection moving upward.",shortcut:[{key:"Enter",modifiers:[vt]},{key:"NumpadEnter",modifiers:[vt]}]},po),new Se("moveLeft",a,{label:"Move Left",description:"Move active cell to the left.",shortcut:[{key:"ArrowLeft"}]},Hn),new Se("selectLeft",a,{label:"Select Left",description:"Extend selection left.",shortcut:[{key:"ArrowLeft",modifiers:[vt]}]},b),new Se("moveContentfulLeft",a,{label:"Move Left Contentful",description:"Move left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[Pt]}]},D),new Se("selectContentfulLeft",a,{label:"Select Left Contentful",description:"Extend selection left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[Pt,vt]}]},A),new Se("moveRight",a,{label:"Move Right",description:"Move active cell to the right.",shortcut:[{key:"ArrowRight"}]},V),new Se("selectRight",a,{label:"Select Right",description:"Extend selection right.",shortcut:[{key:"ArrowRight",modifiers:[vt]}]},W),new Se("moveContentfulRight",a,{label:"Move Right Contentful",description:"Move right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[Pt]}]},he),new Se("selectContentfulRight",a,{label:"Select Right Contentful",description:"Extend selection right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[Pt,vt]}]},se),new Se("moveUp",a,{label:"Move Up",description:"Move active cell to the up.",shortcut:[{key:"ArrowUp"}]},me),new Se("selectUp",a,{label:"Select Up",description:"Extend selection up.",shortcut:[{key:"ArrowUp",modifiers:[vt]}]},ye),new Se("moveContentfulUp",a,{label:"Move Up Contentful",description:"Move up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[Pt]}]},ce),new Se("selectContentfulUp",a,{label:"Select Up Contentful",description:"Extend selection up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[Pt,vt]}]},$e),new Se("moveDown",a,{label:"Move Down",description:"Move active cell to the down.",shortcut:[{key:"ArrowDown"}]},at),new Se("selectDown",a,{label:"Select Down",description:"Extend selection down.",shortcut:[{key:"ArrowDown",modifiers:[vt]}]},je),new Se("moveContentfulDown",a,{label:"Move Down Contentful",description:"Move down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[Pt]}]},Ae),new Se("selectContentfulDown",a,{label:"Select Down Contentful",description:"Extend selection down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[Pt,vt]}]},dt),new Se("selectVisible",a,{label:"Select Visible",description:"Select visible cells only.",shortcut:{key:";",modifiers:[dn]}},ho),new Se("traverseSelectionPreviousRange",a,{label:"Traverse Previous Range",description:"Traverse the selection to the previous range.",shortcut:{key:"ArrowLeft",modifiers:[Pt,dn]}},Rn),new Se("traverseSelectionNextRange",a,{label:"Traverse Next Range",description:"Traverse the selection to the next range.",shortcut:{key:"ArrowRight",modifiers:[Pt,dn]}},wo),new Se("traverseSelectionCorners",a,{label:"Traverse Corners",description:"Traverse the selection through the corners of the selected range.",shortcut:{key:".",modifiers:[Pt]}},mo)]},[]);return c.useMemo(()=>{t?.addCommands(Tt,!0)},[t]),{selection:Lt,setSelectionCell:gt,setSelectionRanges:ft,overlay:Vt,cursor:Qt,onPointerDown:so,clearLastSelection:qe,newSelection:Je,modifySelection:tt,appendSelection:Le,clearSelections:Gt,isEntire:kt,navigate:ut,navigateSelection:Zt}};