@betteroffice/xlsx-react 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,7 +42,7 @@ The default props are described by `XlsxAsyncEditorProps`:
42
42
  | `downloadOnSave` | `boolean` | Save also downloads; defaults to `!onSave`. |
43
43
  | `onDocumentChange` | `(change: XlsxDocumentChange) => void` | Receives `{ version }` after a committed edit. |
44
44
  | `initialZoom` | `number` | Initial scale, clamped to 0.1 through 5; defaults to 1. |
45
- | `loadingIndicator` | `React.ReactNode` | Shown while a supplied file opens. |
45
+ | `loadingIndicator` | `React.ReactNode` | Shown while a supplied file opens. Until the editor's code has loaded it is shown in normal flow, as before. Once the editor has mounted it is shown over the grid area, in an overlay whose size does not affect the editor's layout; there it is not interactive by default: pointer input passes through it to the grid, and a control inside it that re-enables pointer input takes that input instead of the grid. |
46
46
  | `style` | `React.CSSProperties` | Overrides root inline styles. |
47
47
  | `onChange` | `() => void` | Called after a user edit changes the workbook. |
48
48
  | `onError` | `(error: Error) => void` | Receive engine errors. |
@@ -59,7 +59,7 @@ The default props are described by `XlsxAsyncEditorProps`:
59
59
  All listed props are optional. The default toolbar is hidden when `readOnly`; a supplied `toolbar`
60
60
  remains visible unless `showToolbar` is `false`.
61
61
 
62
- Deprecated: `legacySyncApi` keeps the synchronous API on the in-thread engine and is removed in 0.6.0; omit it
62
+ Deprecated: `legacySyncApi` keeps the synchronous API on the in-thread engine and is removed in 0.7.0; omit it
63
63
  for the default asynchronous editor API.
64
64
 
65
65
  ## Editor API
@@ -77,7 +77,7 @@ workbook, and its command store is shared with the toolbar and host controls.
77
77
  | `validateEdits`, `applyEdits` | Validate or apply version-checked batches; refuse while read-only. |
78
78
  | `save()` | Commit input, return bytes and call `onSave` without downloading or consulting `onSaveRequest`. |
79
79
  | `focus()` | Focus the editor. |
80
- | `renderPng`, `renderRangePng`, `printDisplayList` | Render asynchronously. |
80
+ | `renderPng`, `printDisplayList` | Render asynchronously. `renderPng` takes `{ sheet, viewport }` or `{ sheet, range }`. |
81
81
  | `exportStructured`, `exportMarkdown` | Export content asynchronously. |
82
82
  | `proposeChanges` | Optional method for staging tracked cell edits on worker editors. |
83
83
  | `collaboration` | Asynchronous collaboration replica, or `null`. |
@@ -102,19 +102,52 @@ returns `{ bytes, recovery: true }`.
102
102
 
103
103
  ## Toolbar
104
104
 
105
- The toolbar composition API is experimental. Use `toolbar` to supply controls connected to the
106
- editor's command store. See
105
+ The toolbar composition API can change in minor releases. Use `toolbar` to supply controls
106
+ connected to the editor's command store. See
107
107
  [Compose the XLSX toolbar](https://docs.betteroffice.dev/docs/javascript#compose-the-xlsx-toolbar)
108
108
  for built-in parts, custom controls, and command results.
109
109
 
110
110
  ## Plugins and edit batches
111
111
 
112
- The plugin API is experimental and may change in minor releases. Plugins contribute panels,
112
+ The plugin API can change in minor releases. Plugins contribute panels,
113
113
  overlays, and commands through restricted clients; their read and edit
114
114
  clients support version-checked operations. See
115
115
  [Host XLSX editor plugins](https://docs.betteroffice.dev/docs/javascript#host-xlsx-editor-plugins)
116
116
  and [Edit XLSX in version-checked batches](https://docs.betteroffice.dev/docs/javascript#edit-xlsx-in-version-checked-batches).
117
117
 
118
+ Plugins read `snapshot.focused` and `snapshot.locale`, and receive
119
+ `focus-change` and `locale-change`. Focus covers the document surface; docked panels
120
+ and toolbar controls are outside. Locale is the canonical `i18n._lang`, defaulting to `en`.
121
+ `layout.viewport` remains the grid viewport in sheet pixels.
122
+
123
+ `proposal-change` carries `generation`, `version` and `previewVersion` when host
124
+ proposals or their stale-decision state change, including committed edits while
125
+ proposals remain. `geometry.getAnchorGeometry({ kind: 'proposal', id })` returns
126
+ visible cell `rects`, their bounding `anchor` and the grid's `pageRect` in overlay
127
+ pixels, alongside `version`, `previewVersion` and `layoutId`. XLSX does not expose
128
+ `layout.previewVersion`; use the event's or anchor result's value for proposal state.
129
+ Failures carry `{ code, message }`: `unknown-proposal` for an unregistered id,
130
+ `missing-target` for no visible cells, `pending` while proposals refresh,
131
+ `read-failed` when they cannot be read, and `layout-unavailable` for a superseded
132
+ context or unpainted layout. The result type also allows `stale-version`,
133
+ `ambiguous-target` and `unsupported`.
134
+
135
+ `selection-settle` reports the current selection after a minimum quiet window of
136
+ 350 ms; engines may wait up to 1.5 seconds longer for paint. Sources are `pointer`,
137
+ `touch` and `keyboard`; programmatic changes use `keyboard`. `snapshot.selectionSettled`
138
+ is false while the selection changes. These experimental signals are on for installed
139
+ plugins. `geometry.getAnchorGeometry({ kind: "selection" })` anchors to the live
140
+ selection. Superseded retained contexts or unpainted layouts return `layout-unavailable`
141
+ before the missing-selection check. Charts and absent selections return `missing-target`;
142
+ cells on another sheet or offscreen return `layout-unavailable`. `readAnchorGeometries`
143
+ returns the same answers in a promise. In-cell editing anchors to the cell.
144
+
145
+ Granted mutating built-in commands require `document: "write"`. A trusted `click`, `keydown`,
146
+ or `pointerup` in the plugin's own UI, including its contributed toolbar buttons, admits
147
+ that plugin's mutating calls until the event finishes dispatching, including the handler
148
+ and microtasks queued before it settles, whichever of the plugin's code paths makes them.
149
+ Another plugin's calls and calls after the window closes refuse with `unsupported-policy`.
150
+
118
151
  ## Structured export
119
152
 
120
153
  Await `api.exportStructured()` or `api.exportMarkdown()` for content with positional anchors and
@@ -0,0 +1,5 @@
1
+ import {c,g,E,N,u,a as a$2,v,w,i,L,M,O,t,s,l,I,J,G,U,P,Q as Q$1,X,e,y,k,m,z,la,n,ma,j,f}from'./chunk-NLAF4WIP.js';import {a as a$1,o}from'./chunk-WTQ7SZBY.js';import {a}from'./chunk-O2XFH626.js';import {memo,useSyncExternalStore,useEffect,useRef,useCallback,useLayoutEffect,useMemo,useState,useReducer,useId,Component}from'react';import {normalizeRange,selectionKeyReducer,toTsv,fromTsv,chartRegionAtPoint,cellAtPoint,cellRect,translateFormulasOn,rangeRect}from'@betteroffice/xlsx';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function Il(e){useEffect(()=>{if(e.current)return g(e.current)},[e]);}var Hn=1048576,zn=16384,or=1e5,Et=e=>e.bottom>=Hn-1||e.right>=zn-1;function rr(e,t){if(!Et(e))return e;let n=t(),o=(r,i,l,u)=>i>=u-1?Math.max(r,Math.min(i,l??r)):i;return {...e,bottom:o(e.top,e.bottom,n?.bottom,Hn),right:o(e.left,e.right,n?.right,zn)}}async function Tl(e,t,n){let o=normalizeRange(n);if(!Et(o))return o;let{usedRange:r}=await e.call.selectionData(t,0,0,"usedRange");return rr(o,()=>r)}function Dl(e,t){let n=Et(e),o=n?t():e,r=[];if(!o)return r;let i=Math.max(e.top,o.top),l=Math.min(e.bottom,o.bottom),u=Math.max(e.left,o.left),a=Math.min(e.right,o.right);if(i>l||u>a)return r;if(n&&(l-i+1)*(a-u+1)>or)return null;for(let f=i;f<=l;f++)for(let p=u;p<=a;p++)r.push({row:f,col:p,input:""});return r}function Al(e){let t=(n,o)=>{let r=0,i=n?.length??0;for(;r<i;){let l=r+i>>>1;n[l][1]<o?r=l+1:i=l;}return r<(n?.length??0)&&n[r][0]<=o};return {isRowHidden:n=>t(e?.hiddenRowSpans,n),isColHidden:n=>t(e?.hiddenColSpans,n)}}function Ll(e,t){if(!e)return false;let n=(o,r,i,l)=>r?r.includes(o):o>=i&&o<i+l.length-1;return n(t.row,e.rowIndices,e.startRow,e.rowOffsets)&&n(t.col,e.colIndices,e.startCol,e.colOffsets)}function An(e){return {mergeAt:(t,n)=>{let o=e?.find(r=>t>=Math.min(r.start.row,r.end.row)&&t<=Math.max(r.start.row,r.end.row)&&n>=Math.min(r.start.col,r.end.col)&&n<=Math.max(r.start.col,r.end.col));return o?{top:Math.min(o.start.row,o.end.row),left:Math.min(o.start.col,o.end.col),bottom:Math.max(o.start.row,o.end.row),right:Math.max(o.start.col,o.end.col)}:null}}}function kt(e,t){let n=t.mergeAt(e.row,e.col);return n&&(n.top!==e.row||n.left!==e.col)?{row:n.top,col:n.left}:e}var Ln=new WeakMap;function Ol(e,t,n){if(e)try{let o=e.version(),r=Ln.get(e);(!r||r.version!==o)&&(r={version:o,sheets:new Map},Ln.set(e,r));let i=r.sheets.get(t);return i||(i=An(e.mergedRanges(t,"A1:XFD1048576")),r.sheets.set(t,i)),i}catch{}return n??An(void 0)}function Rt(e,t){let n=e.anchor.row===e.focus.row&&e.anchor.col===e.focus.col,o=kt(e.anchor,t),r=n?kt(e.focus,t):e.focus;if(o===e.anchor&&r===e.focus)return e;let i=normalizeRange(e);return {anchor:o,focus:r,...!n||e.range&&(i.top!==i.bottom||i.left!==i.right)?{range:i}:{}}}function On(e){if(!e.ctrlKey&&!e.metaKey)return e.key==="End"?"rowEnd":null;switch(e.key){case "ArrowUp":return "up";case "ArrowDown":return "down";case "ArrowLeft":return "left";case "ArrowRight":return "right";case "End":return "usedRange";case "a":case "A":return "region";default:return null}}function ir(e,t){if(!e||e.focus.row!==t.focus.row||e.focus.col!==t.focus.col||e.anchor.row!==t.anchor.row||e.anchor.col!==t.anchor.col||!!e.range!=!!t.range)return false;let n=normalizeRange(e),o=normalizeRange(t);return n.top===o.top&&n.left===o.left&&n.bottom===o.bottom&&n.right===o.right}var it=e=>"run"in e;function lt(e,t){return t!==null&&e.owner===t.owner&&e.sheet===t.sheet&&e.selection===t.selection&&e.navigation===t.navigation}function Ie(e,t){return lt(e.context,t)||!!e.target&&e.context.owner===t.owner&&e.context.sheet===t.sheet&&e.context.navigation===t.navigation&&ir(e.target,t.selection)}function Hl(){let e=null,t=false,n=0,o=null,r=s=>((!o||o.owner!==s.owner||o.sheet!==s.sheet||o.version!==s.version)&&(o={owner:s.owner,sheet:s.sheet,version:s.version,ranges:[],cells:new Set}),o.ranges),i=(s,h)=>({mergeAt:(m,w)=>r(s).find(c=>m>=c.top&&m<=c.bottom&&w>=c.left&&w<=c.right)??h?.mergeAt(m,w)??null}),l=(s,h)=>(r(s),!!(o?.cells.has(`${h.row}:${h.col}`)||i(s).mergeAt(h.row,h.col))),u=(s,h,m)=>{if(r(s),h){let w=h.edge??m;o.cells.add(`${w.row}:${w.col}`);}h?.merge&&!r(s).some(w=>w.top===h.merge.top&&w.left===h.merge.left)&&r(s).push(h.merge);},a=s=>s.anchor.row===0&&s.anchor.col===0&&s.focus.row===0&&s.focus.col===0,f=(s,h,m)=>m.known?.(s,h.anchor)&&m.known(s,h.focus),p=async(s,h,m)=>{let w=h,c=h.anchor.row===h.focus.row&&h.anchor.col===h.focus.col;for(let v of ["anchor","focus"]){let R=w[v],k;if(s.sheet!==m.context()?.sheet||!m.known?.(s,R))try{k=await m.query({...s,selection:{anchor:R,focus:R}},"merge");}catch{}u(s,k,R);let P=k&&"merge"in k?k.merge?{row:k.merge.top,col:k.merge.left}:R:kt(R,i(s,s.sheet===m.context()?.sheet?m.merges?.():void 0));if((c||v==="anchor")&&(P.row!==R.row||P.col!==R.col)&&(w={...w,[v]:P}),c){let{range:X,...I}=w;return {...I,anchor:P,focus:P,...X&&(X.top!==X.bottom||X.left!==X.right)?{range:X}:{}}}}return w!==h&&!h.range?{...w,range:normalizeRange(h)}:w},y=async(s,h)=>{let m=false;try{for(;e===s&&s.keys.length>0;){let w=s.keys[0],c="selection"in w?w.options:h,v=c.context();if(!lt(s.context,v)||!v)return;if(it(w)){s.keys.shift(),t=!0,n=0;try{w.run();}finally{t=!1;}await Promise.resolve();let x=c.context();if(!x){m=!0;return}s.context=x;continue}let R="selection"in w?w:null,k=R?null:w,P=k?On(k):null,X=k&&c.activeCell&&(!k.shiftKey||k.key==="Tab"||k.key==="Enter"||P==="region")?{...v.selection,focus:c.activeCell(v.selection),range:normalizeRange(v.selection)}:v.selection,I=R?.sheet===void 0?v:{...v,sheet:R.sheet},O=!R&&!P&&f(v,X,c)?selectionKeyReducer(X,k,c.limits(),void 0,c.hidden?.(),i(v,c.merges?.())):void 0,L=O?.type==="move"?O:void 0,F;if(!R&&!L)try{F=await c.query(X===v.selection?v:{...v,selection:X},P==="region"?void 0:P??"merge");}catch{}let j=c.context();if(e!==s||!lt(v,j)||!j)return;if(v.version!==j.version)continue;u(v,F,X.focus);let V=R?{type:"move",selection:R.selection}:L?{...L,selection:Rt(L.selection,i(v,c.merges?.()))}:selectionKeyReducer(X,k,c.limits(),F,c.hidden?.(),i(v,c.merges?.()));if(V.type!=="move"){s.keys.shift();continue}let q=R||L&&!f(v,V.selection,c)||F&&"merge"in F?await p(I,V.selection,c):V.selection,B=c.context();if(e!==s||!lt(v,B)||!B)return;if(v.version!==B.version)continue;s.keys.shift(),V.selection=q,s.target=V.selection;let W=c.apply(V.selection,R?.sheet),Y=c.context();if(!Y){R?.done(!1);return}s.context=Y;let re=await W;if(R?.done(re),!re||e!==s)return;let H=c.context();if(!H||H.owner!==Y.owner||H.sheet!==Y.sheet||H.navigation!==Y.navigation)return;s.context=H,s.target=void 0;}}finally{e===s&&(e=null);let w=s.keys.splice(0);for(;w.length>0;){let c=w.shift();if(it(c)){if(m){let R=h.context();e&&R&&Ie(e,R)?e.keys.push(c):c.run();}else c.cancel?.();continue}let v=m&&!e?h.context():null;if(!v){"selection"in c&&c.done(false);continue}e={context:v,keys:[c,...w]},y(e,h);break}}};return {enqueue(s,h){let m=h.context();if(!m)return;let w={key:s.key,ctrlKey:s.ctrlKey,metaKey:s.metaKey,shiftKey:s.shiftKey,altKey:s.altKey};if(!e&&!On(w)&&f(m,m.selection,h)){let v=h.activeCell&&(!w.shiftKey||w.key==="Tab"||w.key==="Enter")?{...m.selection,focus:h.activeCell(m.selection)}:m.selection,R=i(m,h.merges?.()),k=selectionKeyReducer(v,w,h.limits(),void 0,h.hidden?.(),R);if(k.type==="move"&&f(m,k.selection,h)){h.apply(Rt(k.selection,R));return}}if(e&&Ie(e,m)){t?e.keys.splice(n++,0,w):e.keys.push(w);return}let c={context:m,keys:[w]};e=c,y(c,h);},merges:i,known:l,isPending:s=>!!(e&&s&&Ie(e,s)),beforeInput(s,h,m){if(t)return false;let w=s.context();return w?e&&Ie(e,w)?(e.keys.push({run:h,cancel:m}),true):a(w.selection)||f(w,w.selection,s)?false:(this.select(w.selection,s),e&&Ie(e,w)?(e.keys.push({run:h,cancel:m}),true):false):false},select(s,h,m,w=false){let c=h.context();if(!c)return Promise.resolve(false);w&&e&&!e.keys.some(it)&&(e=null);let v=m===void 0?c:{...c,sheet:m};return !e&&(a(s)||f(v,s,h))?Promise.resolve(h.apply(Rt(s,i(v,h.merges?.(v))),m)):new Promise(R=>{let k={selection:s,sheet:m,options:h,done:R};if(e&&Ie(e,c)){t?e.keys.splice(n++,0,k):e.keys.push(k);return}e={context:c,keys:[k]},y(e,h);})},defer(s,h,m=false,w){return t||!e||!s||!Ie(e,s)||m&&!e.keys.some(it)?false:(e.keys.push({run:h,cancel:w}),true)}}}var St=1e5,It=16*1024*1024,_n=class{constructor(){a(this,"pending",Promise.resolve());a(this,"revision",0);a(this,"cancellation",0);a(this,"escapes",0);a(this,"watching",null);a(this,"captured",null);}get escaped(){return this.escapes}get current(){return this.captured}begin(t=this.escapes,n=sr()){return this.captured=null,this.watching=null,{revision:++this.revision,cancellation:this.cancellation,escapes:t,marker:n}}capture(t,n,o=false){if(!o||t.revision!==this.revision||n.cut&&(t.cancellation!==this.cancellation||t.escapes!==this.escapes))return;let{owner:r,...i}=n;this.captured={...structuredClone(i),owner:r,text:toTsv(n.cells),marker:t.marker};}watch(t){t.revision===this.revision&&(this.watching=t);}changed(){(this.captured?.cut||this.watching)&&this.cancelCut();}escape(){this.escapes++,this.cancelCut();}cancelCut(){this.cancellation++,this.watching=null,this.captured?.cut&&(this.captured=null);}paste(t,n,o,r,i,l){let u=w=>!!(w&&w.owner===t&&w.text===n&&w.marker&&r?.includes(w.marker)),a=[l?.cut?null:l,this.captured].find(u);if(!a)return this.cancelCut(),null;if(a.cut&&i!==void 0&&a.sheet!==i)throw this.cancelCut(),new E("Moving cells between worksheets is unavailable");if(!a.cut&&a.cells.some(w=>w.some(c=>c.isArrayFormula)))throw new E("Copying array or spill formula cells is unavailable");let f=a.range.bottom-a.range.top+1,p=a.range.right-a.range.left+1,y=a.cut?f:Math.max(f,o.bottom-o.top+1),s=a.cut?p:Math.max(p,o.right-o.left+1);if(y*s>St)throw new E("Paste exceeds the 100000-cell limit");let h=ur(n),m=[];for(let w=0;w<y;w++)for(let c=0;c<s;c++){let v=w%f,R=c%p,k=h[v]?.[R]??"";m.push({row:o.top+w,col:o.left+c,input:k,...a.cells[v]?.[R]?.isFormula?{copyFrom:{row:a.range.top+v,col:a.range.left+R}}:{}});}return {...a,edits:m,bottom:o.top+y-1,right:o.left+s-1}}consume(t,n){n&&t.cut&&this.captured?.owner===t.owner&&this.captured.cells===t.cells&&this.cancelCut();}};function sr(){return `betteroffice-${crypto.randomUUID()}`}function ar(e,t=""){let n=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),o=fromTsv(t).map(r=>`<tr>${r.map(i=>`<td>${n(i)}</td>`).join("")}</tr>`).join("");return new Blob([`<table data-betteroffice-clipboard="${e.marker}">${o}</table>`],{type:"text/html"})}function Gl(e,t){let n=t.then(async o=>ar(e,await o.text()));return n.catch(()=>{}),n}function Gn(e){if(e.length>It||new TextEncoder().encode(e).byteLength>It)throw new E("Clipboard exceeds the 16 MiB limit");return e}function ur(e){Gn(e);let t=false,n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==='"')t&&e[r+1]==='"'?r++:t=!t;else if(!t&&(i===" "||i==="\r"||i===`
2
+ `)){if(++n>St)throw new E("Paste exceeds the 100000-cell limit");i==="\r"&&e[r+1]===`
3
+ `&&r++;}}let o=fromTsv(e);if(o.reduce((r,i)=>r+i.length,0)>St)throw new E("Paste exceeds the 100000-cell limit");return o}async function Fl(){let e=navigator.clipboard.readText().then(Gn);if(e.catch(()=>{}),typeof navigator.clipboard.read!="function")return {text:await e};let t=null;try{let r=(await navigator.clipboard.read()).find(i=>i.types.includes("text/plain"));r?.types.includes("text/html")&&(t=await r.getType("text/html"));}catch{}if(t&&t.size>It)throw new E("Clipboard exceeds the 16 MiB limit");let n=t?await t.text():null;return {text:await e,html:n}}var Wn=[{handle:"nw",x:0,y:0,cursor:"nwse-resize"},{handle:"n",x:.5,y:0,cursor:"ns-resize"},{handle:"ne",x:1,y:0,cursor:"nesw-resize"},{handle:"e",x:1,y:.5,cursor:"ew-resize"},{handle:"se",x:1,y:1,cursor:"nwse-resize"},{handle:"s",x:.5,y:1,cursor:"ns-resize"},{handle:"sw",x:0,y:1,cursor:"nesw-resize"},{handle:"w",x:0,y:.5,cursor:"ew-resize"}];function st(e,t,n){return {left:e==="nw"||e==="w"||e==="sw"?t:0,top:e==="nw"||e==="n"||e==="ne"?n:0,right:e==="ne"||e==="e"||e==="se"?t:0,bottom:e==="sw"||e==="s"||e==="se"?n:0}}function Kl(e,t){let n=(i,l)=>l!==void 0&&l>0?i<l-.5:i<=.5,o=t.frozenCols>0&&n(e.clip.x,t.frozenWidth),r=t.frozenRows>0&&n(e.clip.y,t.frozenHeight);return {originX:o?0:t.x,originY:r?0:t.y,width:t.sheetWidth??1/0,height:t.sheetHeight??1/0}}function Fn(e,t,n,o,r){let l=Math.min(Math.max(e+o,0),n),u=Math.min(Math.max(t+r,0),n);return u-l<1&&(o!==0&&r===0?l=u-1:u=l+1,u>n&&(u=n,l=Math.max(u-1,0)),l<0&&(l=0,u=Math.min(1,n))),[l,u]}function Bl(e,t,n,o,r){let i=st(t,n,o),l=r?.originX??0,u=r?.originY??0,a=e.x+l,f=e.y+u,[p,y]=Fn(a,a+e.w,r?.width??1/0,i.left,i.right),[s,h]=Fn(f,f+e.h,r?.height??1/0,i.top,i.bottom);return {x:p-l,y:s-u,w:y-p,h:h-s}}function ql(e){let t=useRef(null),n=useRef(e);n.current=e;let o=useCallback(a=>{let f=t.current;if(f){t.current=null;try{f.element.hasPointerCapture?.(f.pointerId)&&f.element.releasePointerCapture(f.pointerId);}catch{}n.current.preview(null),a&&(f.dx!==0||f.dy!==0)&&n.current.commit(f.handle,st(f.handle,f.dx,f.dy));}},[]);useEffect(()=>{let a=h=>{let m=t.current;if(!m||h.pointerId!==m.pointerId)return;let w=n.current.zoom()||1;m.dx=(h.clientX-m.startX)/w,m.dy=(h.clientY-m.startY)/w,n.current.preview({kind:"resize",handle:m.handle,dx:m.dx,dy:m.dy}),h.preventDefault();},f=h=>{let m=t.current;!m||h.pointerId!==m.pointerId||o(h.type==="pointerup"&&h.button===0);},p=h=>{!t.current||h.pointerId!==t.current.pointerId||o(false);},y=()=>{t.current&&o(false);},s=h=>{h.key!=="Escape"||!t.current||(h.preventDefault(),h.stopPropagation(),o(false));};return window.addEventListener("pointermove",a),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",p),window.addEventListener("blur",y),window.addEventListener("keydown",s,true),()=>{window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",p),window.removeEventListener("blur",y),window.removeEventListener("keydown",s,true);let h=t.current;if(t.current=null,h)try{h.element.hasPointerCapture?.(h.pointerId)&&h.element.releasePointerCapture(h.pointerId);}catch{}}},[o]);let r=useCallback((a,f)=>{if(f.button!==0||t.current)return;f.preventDefault(),f.stopPropagation();let p=f.currentTarget;try{p.setPointerCapture(f.pointerId);}catch{}t.current={pointerId:f.pointerId,handle:a,startX:f.clientX,startY:f.clientY,element:p,dx:0,dy:0},n.current.preview({kind:"resize",handle:a,dx:0,dy:0});},[]),i=useCallback(()=>o(false),[o]),l=useCallback((a,f,p)=>{f===0&&p===0||(n.current.preview(null),n.current.commit(a,st(a,f,p)));},[]),u=useCallback(()=>t.current!==null,[]);return {start:r,cancel:i,nudge:l,active:u}}var Kn={load:()=>import('./chunk-ZYRFP7C5.js')};function Zl(e,t,n,o,r,i){let l=JSON.stringify(i??"bunny"),u=useRef(o);u.current=o;let a=useRef(r);a.current=r;let f=useRef(void 0),p=useRef(void 0);useLayoutEffect(()=>{if(n===false||t===void 0)return;let s={owner:e};return e!=null&&(s.last=p.current,p.current=void 0),f.current=s,Kn.load().then(({createDefaultFontPainter:h})=>{f.current===s&&(s.painter=h(t,()=>u.current(),{onSettled:()=>a.current?.(),remoteFonts:JSON.parse(l)}),s.last&&s.painter.adopt(s.last));},()=>{f.current===s&&(f.current=void 0,u.current(),a.current?.());}),()=>{s.painter?.dispose(),f.current===s&&(f.current=void 0);}},[e,t,n,l]);let y=useCallback((s,h)=>{let m=f.current;return m&&m.owner==null&&(p.current=s),m?.painter?m.painter.paint(s,h):(h(),m?(m.last=s,false):true)},[]);return useMemo(()=>Object.assign(y,{preload:(s,h)=>{f.current?.painter?.preload(s,h);}}),[y])}async function Ql(e,t,n,o){if(n===false||e.length===0)return;let{exportFaces:r}=await Kn.load(),i=new Set,l=await r(e,t,i);if(l.length)return l;o&&i.size&&Object.defineProperty(o,Symbol.for("@betteroffice/xlsx/reportedFontCdnErrors"),{value:i});}var Xt=new WeakMap;function Bn(e,t){Xt.has(e)||Xt.set(e,t);}function jn(e){return Xt.get(e)??null}var ze={"data-xlsx-plugin-chrome":""};function ts(e){return e instanceof Element&&e.closest("[data-xlsx-plugin-chrome]")!==null}function hr({label:e,entries:t,point:n,modality:o$1="pointer",colors:r,className:i,testId:l,returnFocus:u,onClose:a}){let[f]=useState(()=>typeof document<"u"&&document.activeElement instanceof HTMLElement?document.activeElement:null),p=useRef(new Set),y=useRef(a);y.current=a;let s=useRef(u);s.current=u;let h=useRef(false),[,m]=useState(0),w=L(),c=useCallback((k,P)=>{h.current||(h.current=true,P&&s.current?s.current():P&&f?.isConnected&&f.focus({preventScroll:true}),y.current(k));},[f]);useEffect(()=>{if(w)return;let k=true;return M().then(()=>{k&&m(P=>P+1);},()=>{k&&c("escape",true);}),()=>{k=false;}},[c,w]);let v=useCallback(k=>(p.current.add(k),()=>{p.current.delete(k);}),[]);useLayoutEffect(()=>{let k=L=>L instanceof Node&&[...p.current].some(F=>F.contains(L)),P=L=>{k(L.target)||c("outside",false);},X=L=>{L.key==="Escape"&&!k(L.target)&&c("escape",false);},I=()=>c("resize",k(document.activeElement));document.addEventListener("pointerdown",P,true);let O$1=O(L=>c(L==="Tab"?"tab":"escape",false));return document.addEventListener("keydown",X),window.addEventListener("resize",I),()=>{document.removeEventListener("pointerdown",P,true),O$1(),document.removeEventListener("keydown",X),window.removeEventListener("resize",I);}},[c]);let R=useCallback(()=>({x:n.x,y:n.y,left:n.x,right:n.x,top:n.y,bottom:n.y,width:0,height:0}),[n.x,n.y]);return !w||h.current?null:jsx(w,{label:e,entries:t,anchor:R,mode:"point",colors:{...o,...r},initialFocus:o$1==="keyboard"?"first":"menu",onClose:k=>c(k==="tab"?"tab":"escape",k!=="tab"),onSelect:k=>{c("select",true),k.onSelect();},registerMenu:v,className:i,testId:l})}var xr=1e3,br=500;function yr(e){return e.key==="ContextMenu"?true:e.key==="F10"&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function ls(e){let t=useRef(e);t.current=e;let[n,o]=useState(null),[,r]=useReducer(m=>m+1,0),i=useRef(0),l=useRef(-1/0),u=useRef(-1/0);useEffect(()=>N(),[]);let a=useCallback(m=>{let w=t.current.resolve(m);return w?(o({spec:w,x:m.x,y:m.y,modality:m.modality,key:++i.current}),true):false},[]),f=useCallback(()=>o(null),[]),p=useCallback(m=>{let w=t.current.keyboardPoint?.(),c=t.current.surface.current?.getBoundingClientRect();return {x:w?.x??(c?c.left+8:8),y:w?.y??(c?c.top+8:8),modality:"keyboard",target:m}},[]);useEffect(()=>{let m=e.surface.current;if(!m)return;let w=R=>{(R.button===2||R.button===0&&R.ctrlKey)&&(l.current=performance.now());},c=R=>{if(R.defaultPrevented)return;let k=performance.now(),P=R.button===2||k-l.current<xr;if(l.current=-1/0,!P&&k-u.current<br){R.preventDefault();return}let X=P?{x:R.clientX,y:R.clientY,modality:"pointer",target:R.target}:p(R.target);a(X)&&R.preventDefault();},v=R=>{R.defaultPrevented||R.isComposing||!yr(R)||a(p(R.target))&&(R.preventDefault(),u.current=performance.now());};return m.addEventListener("pointerdown",w,true),m.addEventListener("contextmenu",c),m.addEventListener("keydown",v),()=>{m.removeEventListener("pointerdown",w,true),m.removeEventListener("contextmenu",c),m.removeEventListener("keydown",v);}});let y=e.subscribe,s=n!==null;return useEffect(()=>s&&y?y(r):void 0,[s,y]),{element:n?jsx(hr,{label:n.spec.label,entries:n.spec.entries(),point:{x:n.x,y:n.y},modality:n.modality,colors:e.colors,className:n.spec.className,testId:n.spec.testId,returnFocus:n.spec.returnFocus,onClose:f},n.key):null,isOpen:s,open:a,close:f}}function Un(e){let t=[];return e.forEach((n,o)=>{n.length!==0&&(t.length>0&&t.push({kind:"separator",id:`separator-${o}`}),t.push(...n));}),t}function Ne(e){let{id:t,label:n,state:o,shortcut:r,ariaShortcut:i,icon:l,run:u}=e;return {kind:"item",id:t,label:n,icon:l,shortcut:r??void 0,ariaShortcut:i??void 0,disabled:!o.enabled,description:o.enabled?void 0:o.disabledReason?.message,onSelect:u}}function Ge(e){let t="";for(let n=e;n>=0;n=Math.floor(n/26)-1)t=String.fromCharCode(65+n%26)+t;return t}function wr(e,t,n){let o=[];if(e){let r=n.index;r>0&&n.cols!==r&&o.push(Ne({id:`freezeColumns:${r}`,label:r===1?t("commands.freezeColumn",{column:Ge(0)}):t("commands.freezeColumns",{first:Ge(0),last:Ge(r-1)}),state:{enabled:true},run:()=>n.apply(n.rows,r)}));}else {let r=n.index;r>0&&n.rows!==r&&o.push(Ne({id:`freezeRows:${r}`,label:r===1?t("commands.freezeRow",{row:1}):t("commands.freezeRows",{first:1,last:r}),state:{enabled:true},run:()=>n.apply(r,n.cols)}));}return (n.rows>0||n.cols>0)&&o.push(Ne({id:"unfreezePanes",label:t("commands.unfreezePanes"),state:{enabled:true},run:()=>n.apply(0,0)})),o}function Q(e,t$1,n,o){let r=o===null?void 0:o;return Ne({id:r?`${n}:${JSON.stringify(r)}`:n,label:t$1(l(n,r)),state:e.getState(n,o),shortcut:s(e,n,t$1,r),ariaShortcut:t(e,n,r),run:()=>{e.execute(n,o);}})}function Tt(e,t,n){let o=n.every(r=>r.kind==="item"&&r.disabled);return {kind:"submenu",id:e,label:t,entries:n,disabled:o}}function vr(e,t,n,o){if(e==="sheetTab")return [{id:"sheet",entries:[Q(t,n,"insertSheet",null),Q(t,n,"deleteSheet",null),Q(t,n,"renameSheet",null)]},{id:"arrange",entries:[Q(t,n,"moveSheet",{direction:"left"}),Q(t,n,"moveSheet",{direction:"right"})]}];if(e==="columnHeader"||e==="rowHeader"){let i=e==="columnHeader",l=[{id:"cells",entries:i?[Q(t,n,"insertColumns",{position:"left"}),Q(t,n,"insertColumns",{position:"right"})]:[Q(t,n,"insertRows",{position:"above"}),Q(t,n,"insertRows",{position:"below"})]},{id:"delete",entries:[i?Q(t,n,"deleteColumns",null):Q(t,n,"deleteRows",null)]}],u=o?wr(i,n,o):[];return u.length>0&&l.push({id:"view",entries:u}),l}let r=t.getState("numberFormat");return [{id:"clipboard",entries:[Q(t,n,"cut",null),Q(t,n,"copy",null),Q(t,n,"paste",null),Q(t,n,"pastePlainText",null)]},{id:"cells",entries:[Tt("insert",n("commands.insert"),[Q(t,n,"insertRows",{position:"above"}),Q(t,n,"insertRows",{position:"below"}),Q(t,n,"insertColumns",{position:"left"}),Q(t,n,"insertColumns",{position:"right"})]),Tt("delete",n("commands.delete"),[Q(t,n,"deleteRows",null),Q(t,n,"deleteColumns",null)]),Q(t,n,"clearContents",null)]},{id:"format",entries:r.options?[Tt("numberFormat",n("commands.numberFormat"),r.options.filter(i=>i.args.value!=="custom").map(i=>Ne({id:`numberFormat:${i.args.value}`,label:i.label,state:i.state,run:()=>{t.execute("numberFormat",i.args);}})).map(i=>({...i,...i.kind==="item"?{radio:true,checked:r.value?.kind===i.id.slice(13)}:{}})))]:[]}]}function ms(e,t,n,o){return Un(vr(e,t,n,o).map(r=>r.entries))}var Rr=new Set(["save"]),kr=new Set(["undo","redo"]);function qn(e){let n=(e instanceof Element?e:null)?.closest("input, textarea, select, [contenteditable]");return n!=null&&n.getAttribute("contenteditable")!=="false"}function Er(e){e.code!=="displaced-default"&&(typeof process<"u"&&process.env?.NODE_ENV==="production"||console.warn(`Shortcut ${e.chord??""} of ${e.id} was not applied: ${e.code}`));}function ws(e,t,n={}){let{shortcuts:o,onShortcutIssue:r}=n,i$1=useRef(o);i$1.current=o;let l=useRef(r);l.current=r;let u=o===void 0?void 0:JSON.stringify(o),a=useRef(new Set);useLayoutEffect(()=>{for(let f of e.setShortcuts(i$1.current)){let p=JSON.stringify(f);a.current.has(p)||(a.current.add(p),(l.current??Er)(f));}},[e,u]),useEffect(()=>{let f=p=>{if(p.defaultPrevented||p.isComposing||p.keyCode===229)return;let y=p.target,s=jn(p);if(!(s?e.ownsStore(s):y instanceof Node&&(t.current?.contains(y)??false)||e.ownsChrome(y)))return;let m=e.shortcutAt(p);if(!m){let c=e.pluginShortcuts(),v=w(c.map(({chord:k})=>i(k)??k),p),R=c.find(({chord:k})=>(i(k)??k)===v);if(!R||qn(y))return;p.preventDefault(),p.repeat||e.store.execute(R.id,null);return}if(qn(y)&&!Rr.has(m.id))return;let w$1=e.store.getState(m.id,m.args);!w$1.enabled&&w$1.disabledReason.code==="unsupported-command"||(p.preventDefault(),!(p.repeat&&!kr.has(m.id))&&e.store.execute(m.id,m.args));};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[e,t]);}function Rs(e){let t=useRef(e);t.current=e;let n=useRef(null);return useCallback(o=>{let r=t.current;if(!r.onSaveRequest)return o();let i=r.document(),l=()=>({ok:false,failure:{code:"document-replaced",message:"The workbook was replaced"}});if(!i)return Promise.resolve(l());if(n.current?.document===i)return n.current.promise;let u$1=Promise.resolve().then(async()=>{if(t.current.document()!==i)return l();let a=r.onSaveRequest?await r.onSaveRequest():true;return t.current.document()!==i?l():a===true?o():{ok:true,status:"noop"}}).catch(a=>{if(t.current.document()!==i)return l();if(a instanceof u)throw a;return t.current.fail(a),{ok:false,failure:{code:"command-failed",message:a instanceof Error?a.message:String(a)}}}).finally(()=>{n.current?.promise===u$1&&(n.current=null);});return n.current={document:i,promise:u$1},u$1},[])}var Tr=24;function Ss(e,t,n,o,r){if(!n||!e.grid||!Number.isFinite(o)||!Number.isFinite(r))return null;let i=n.getBoundingClientRect();if(i.width<=0||i.height<=0||o<i.left||r<i.top||o>=i.right||r>=i.bottom)return null;let l=(o-i.left)*e.width/i.width,u=(r-i.top)*e.height/i.height;if(chartRegionAtPoint(e.charts,l,u))return null;let a=cellAtPoint(e.grid,l,u);return a?{...a,sheet:t}:null}function Dr(e,t){if(!e||e.length<2)return t;let n=[];for(let r=1;r<e.length;r++)n.push(e[r]-e[r-1]);n.sort((r,i)=>r-i);let o=n[n.length>>1];return o>0?o:t}function Is(e,t){let n=Dr(e?.grid?.rowOffsets,Tr);return {rows:1048576,cols:16384,rowsPerPage:Math.max(1,Math.floor(t/n))}}function Xs(e,t){return e.top<=0&&e.bottom>=t.rows-1||e.left<=0&&e.right>=t.cols-1}function Ms(e,t,n,o){let r={...t,contentWidth:Math.max(t.contentWidth,n.x+n.w),contentHeight:Math.max(t.contentHeight,n.y+n.h)},i=e.firstElementChild;return i&&(i.style.width=`${r.contentWidth*o}px`,i.style.height=`${r.contentHeight*o}px`),r}function Ts(e,t,n){let o=e.scrollLeft/n,r=e.scrollTop/n;return t.x+t.w>o&&t.y+t.h>r&&t.x<o+e.clientWidth/n&&t.y<r+e.clientHeight/n}function Ds(e,t,n,o){let r=cellRect(e.grid,o.row,o.col);return r?{...r,x:r.x+(o.col<n.frozenCols?0:t.x),y:r.y+(o.row<n.frozenRows?0:t.y)}:null}function As(e,t,n,o,r=0){let i=(l,u,a,f,p,y)=>{if(a)return p;let s=l-f,h=Math.max(0,y-f);return s>=p+r&&s+u<=p+h-r?p:s<p+r||u+r*2>=h?Math.max(0,s-r):Math.max(0,s+u-h+r)};return {x:i(e.x,e.w,t.col<n.frozenCols,n.frozenWidth,o.x,o.width),y:i(e.y,e.h,t.row<n.frozenRows,n.frozenHeight,o.y,o.height)}}function Ls(e,t){return {x:e.x*t,y:e.y*t,w:e.w*t,h:e.h*t}}function Ar(e,t){return e.left<=t.right&&e.right>=t.left&&e.top<=t.bottom&&e.bottom>=t.top}function Ot(e,t,n=false){if(n&&e.top===0&&e.bottom===1048575)return {...e};if(n&&e.left===0&&e.right===16383)return {...e};let o={...e},r=true;for(;r;){r=false;for(let i of t){let l={top:Math.min(i.start.row,i.end.row),left:Math.min(i.start.col,i.end.col),bottom:Math.max(i.start.row,i.end.row),right:Math.max(i.start.col,i.end.col)};if(!Ar(o,l))continue;let u=Math.min(o.top,l.top),a=Math.min(o.left,l.left),f=Math.max(o.bottom,l.bottom),p=Math.max(o.right,l.right);u===o.top&&a===o.left&&f===o.bottom&&p===o.right||(Object.assign(o,{top:u,left:a,bottom:f,right:p}),r=true);}}return o}var Jn=["#7c3aed","#0891b2","#c2410c","#4d7c0f","#be185d","#1d4ed8"];function Lr(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return (t>>>0)%Jn.length}function Zn(e){return Jn[Lr(e)]}function Or(e,t,n){e.execute(t,n).then(o=>{let r=document.activeElement;o.ok&&(!r||r===document.body)&&y(e)?.focusEditor();});}function Ht({id:e,args:t,label:n,testId:o,color:r}){let i=I(),l=J(e,t),u=l.enabled?void 0:l.disabledReason.message;return jsx("button",{"data-testid":o,"aria-disabled":u?true:void 0,title:u,onClick:()=>{l.enabled&&Or(i,e,t);},style:{padding:"3px 10px",cursor:l.enabled?"pointer":"default",color:r,opacity:l.enabled?1:.48},children:n})}function Fs({proposals:e,staleFor:t,style:n}){let{t:o}=c();return jsx("div",{"data-testid":"xlsx-proposals-panel",role:"region","aria-label":o("proposals.panelLabel"),style:{position:"absolute",top:"100%",right:0,marginTop:4,width:320,maxHeight:420,overflowY:"auto",background:"#ffffff",border:"1px solid #d0d0d0",borderRadius:10,boxShadow:"0 6px 24px rgba(0, 0, 0, 0.16)",padding:8,zIndex:10,font:"13px system-ui, sans-serif",textAlign:"left",...n},children:e.length===0?jsx("div",{style:{padding:12,color:"#707070",textAlign:"center"},children:o("proposals.empty")}):e.map(r=>{let i=Zn(r.agentId),l=r.cells.filter(a=>a.stale).map(a=>a.a1),u=l.length>0?l:t[r.id];return jsxs("div",{"data-testid":"xlsx-proposal","data-proposal-id":r.id,style:{borderLeft:`3px solid ${i}`,padding:"8px 10px",marginBottom:8,background:"#fafafa",borderRadius:4},children:[jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline"},children:[jsx("strong",{style:{color:i},children:r.agentId}),jsx("span",{style:{color:"#707070",fontSize:12},children:o("proposals.cellCount",{count:r.cells.length})})]}),r.note&&jsx("div",{style:{color:"#404040",margin:"4px 0"},children:r.note}),jsx("ul",{style:{listStyle:"none",margin:"6px 0",padding:0},children:r.cells.map(a=>jsxs("li",{"data-testid":"xlsx-proposal-cell",style:{fontVariantNumeric:"tabular-nums",lineHeight:1.5},children:[jsx("strong",{"data-testid":"xlsx-proposal-cell-a1",children:a.a1}),":"," ",jsx("span",{style:{color:"#909090"},children:a.oldText||"\u2205"})," ",o("proposals.changeArrow")," ",jsx("span",{"data-testid":"xlsx-proposal-cell-new",style:{color:i},children:a.newText})]},a.a1))}),u&&u.length>0&&jsxs("div",{"data-testid":"xlsx-proposal-stale",role:"alert",style:{color:"#b45309",background:"#fef3c7",borderRadius:4,padding:"4px 6px",margin:"4px 0",fontSize:12},children:[o("proposals.staleWarning",{cells:u.join(", ")}),r.forceBlocked&&jsx("div",{"data-testid":"xlsx-proposal-force-blocked",children:o("proposals.forceBlockedReason")})]}),jsxs("div",{style:{display:"flex",gap:6,marginTop:4},children:[jsx(Ht,{id:"proposalAccept",args:{proposalId:r.id},label:o("proposals.accept"),testId:"xlsx-proposal-accept"}),u&&u.length>0&&!r.forceBlocked&&jsx(Ht,{id:"proposalAccept",args:{proposalId:r.id,force:true},label:o("proposals.forceApply"),testId:"xlsx-proposal-force",color:"#b45309"}),jsx(Ht,{id:"proposalReject",args:{proposalId:r.id},label:o("proposals.reject"),testId:"xlsx-proposal-reject"})]})]},r.id)})})}function Vs(e,t){return t.ok?e.map(n=>{let o=t.sheets.find(r=>r.sheetId===n.sheetId);return o?{...n,hidden:o.visibility==="hidden"||o.visibility==="veryHidden",kind:o.kind}:n}):[...e]}var _r=420,qe={height:30,padding:"0 12px",borderRadius:4},Qn={...qe,width:30,padding:0},eo=1e4,xe="formulas",Nr=1048575,Gr=16383,to={kind:"rowCol",start:{row:0,col:0},end:{row:Nr,col:Gr}};function Nt(e,t){return t==="selection"?[{sheetId:e.sheetId,range:e.range}]:t==="sheet"?[{sheetId:e.sheetId,range:to}]:oo(e).map(n=>({sheetId:n.sheetId,range:to}))}function Fr(e){return e.sheets?.length?e.sheets:[{sheetId:e.sheetId,name:e.label}]}function oo(e){return Fr(e).filter(t=>!t.hidden&&(t.kind??"worksheet")==="worksheet")}function Wr(e,t=[]){let n={matched:0,replaced:0,skippedFormulas:0,skippedLocked:0},o=0,r=[],i=[],l=0,u=false;for(let a of e){if(!a.replace)continue;u=true,n.matched+=a.replace.matched,n.replaced+=a.replace.replaced,n.skippedFormulas+=a.replace.skippedFormulas,n.skippedLocked+=a.replace.skippedLocked,o+=a.replace.skippedValues??0;let f=e.length>1?t.find(p=>p.sheetId===a.target.sheetId)?.name:void 0;for(let p of a.replace.skippedCells??[])r.push(f?`${f}!${p}`:p);i.push(...a.replace.refusedCells??[]),l+=Ft(a.replace);}return u?{...n,skippedValues:o,skippedCells:r,refusedCells:i,refused:l}:null}function Ft(e){return e.refused??e.refusedCells?.length??0}var Gt=5;function $r(e){let t=(e.skippedCells??[]).slice(0,Gt).join(", ");return (e.skippedValues??0)>Gt?`${t}, \u2026`:t}function Kr(e){let t=(e.refusedCells??[]).slice(0,Gt),n=t.map(r=>r.reason).join("; "),o=Ft(e)-t.length;return o>0?`${n}; \u2026 +${o}`:n}function Ve(e){return e.failure.message}function zt(e,t,n,o,r,i,l){let u=Nt(e,t).map(a=>a.sheetId).join(",");return [e.sheetId,e.label,JSON.stringify(e.range),u,t,n,o,String(r),String(i),l].join("\0")}function no(e){let t=e.activeCell??(e.range.kind==="rowCol"?e.range.start:{row:0,col:0});return {sheetId:e.sheetId,row:t.row,col:t.col}}function ct(e,t,n){let o=r=>{let i=e.indexOf(r);return i<0?e.length:i};return o(t.sheetId)-o(n.sheetId)||t.row-n.row||t.col-n.col}function _t(e,t,n){let{matches:o,sheetOrder:r}=e;if(n>0){let i=o.findIndex(l=>ct(r,l.cell,t)>0);return i<0?0:i}for(let i=o.length-1;i>=0;i-=1)if(ct(r,o[i].cell,t)<0)return i;return o.length-1}function Br(e){if(!e)return "workbook";if(e.defaultScope)return e.defaultScope;let{range:t}=e;return t.kind==="rowCol"?t.start.row===t.end.row&&t.start.col===t.end.col?"workbook":"selection":t.a1.includes(":")?"selection":"workbook"}function qs({open:e,target:t,api:n,readOnly:o=false,onClose:r,onApplied:i}){let{t:l,lang:u}=c(),[a,f]=useState("values"),[p,y]=useState("selection"),[s,h]=useState(false),[m,w]=useState(false),[c$1,v]=useState({kind:"idle"}),[R,k]=useState(null),[P,X]=useState({x:0,y:0}),[I,O]=useState(false),L=useRef(null),F=useRef(null),j=useRef(0),V=useRef(null),q=useRef(null),B=useRef(null),W=useId(),Y=useId(),re=useId(),H=useId(),x=useId(),T=useId(),_=useId(),A=useRef({open:e,target:t,scope:p,entireCell:s,matchCase:m});if(A.current={open:e,target:t,scope:p,entireCell:s,matchCase:m},useLayoutEffect(()=>{e&&(j.current+=1,F.current=null,V.current=null,k(null),v({kind:"idle"}),y(Br(t)),X({x:0,y:0}),O(false),q.current?.focus(),q.current?.select());},[e]),useEffect(()=>{if(!I)return;let C=G=>{let $=L.current;$&&X({x:$.baseX+G.clientX-$.x,y:$.baseY+G.clientY-$.y});},M=()=>{L.current=null,O(false);};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",M),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",M);}},[I]),!e)return null;let N=c$1.kind==="busy",z=t!==null&&!N&&!o,K=c$1.kind==="preview"||c$1.kind==="applied"?c$1.stats:null,ee=t?.sheets?.find(C=>C.sheetId===t.sheetId)?.name??t?.label??"",ie=t?oo(t).length:1,ge=()=>{j.current+=1,F.current=null,k(null);},ce=(C,M,G,$)=>{let U=A.current;return j.current===C&&U.open&&U.target!==null&&zt(U.target,U.scope,q.current?.value??"",G,U.entireCell,U.matchCase,$)===M},de=async(C,M=a)=>{if(!t)return null;let G=j.current,$=await Promise.resolve(n.version()),U=zt(t,p,C,M,s,m,$);if(!ce(G,U,M,$))return v({kind:"idle"}),null;if(F.current?.key===U)return F.current;let te=Nt(t,p),J=await Promise.resolve(n.find(p==="workbook"?{text:C,lookIn:M,entireCell:s,matchCase:m,limit:eo}:{text:C,range:te[0],lookIn:M,entireCell:s,matchCase:m,limit:eo})),ne=await Promise.resolve(n.version());if(!ce(G,U,M,ne))return v({kind:"idle"}),null;if(!J.ok)return v({kind:"refused",message:Ve(J)}),null;let le=te.map(ae=>ae.sheetId),fe=[...J.matches].sort((ae,me)=>ct(le,ae.cell,me.cell));return F.current={key:U,matches:fe,sheetOrder:le,truncated:J.truncated},F.current},g=async(C,M)=>{V.current=C.matches[M].cell,k({index:M,total:C.matches.length,truncated:C.truncated}),await Promise.resolve(n.reveal?.(C.matches[M].cell));},S=async C=>{let M=q.current?.value??"";if(!(!t||M.length===0||N||o)){v({kind:"busy"});try{let G=await de(M);if(!G)return;if(G.matches.length===0){k({index:-1,total:0,truncated:!1}),v({kind:"idle"});return}v({kind:"idle"}),await g(G,_t(G,V.current??no(t),C));}catch(G){v({kind:"refused",message:G instanceof Error?G.message:String(G)});}}},d=async()=>{let C=q.current?.value??"",M=B.current?.value??"";if(!t||C.length===0||N||o)return;let G=j.current;v({kind:"busy"});try{let $=await de(C,xe);if(!$)return;if($.matches.length===0){k({index:-1,total:0,truncated:!1}),v({kind:"idle"});return}let U=V.current??no(t),te=$.matches.findIndex(Ke=>ct($.sheetOrder,Ke.cell,U)===0);if(te<0){v({kind:"idle"}),await g($,_t($,U,1));return}let J=$.matches[te].cell,ne={row:J.row,col:J.col},le=await Promise.resolve(n.version());if(!ce(G,$.key,xe,le)){v({kind:"idle"});return}let fe={expectVersion:le,steps:[{op:"replaceText",target:{sheetId:J.sheetId,range:{kind:"rowCol",start:ne,end:ne}},query:C,replacement:M,entireCell:s,lookIn:xe,matchCase:m}]},ae=await Promise.resolve(n.validate(fe));if(!ce(G,$.key,xe,le)){v({kind:"idle"});return}if(!ae.ok){v({kind:"refused",message:Ve(ae)});return}let me=ae.previews[0];if(!ae.wouldApply||!me?.wouldChange){v({kind:"preview",preview:me??{stepIndex:0,target:fe.steps[0].target,wouldChange:!1,changedCellCount:0,replace:void 0},stats:me?.replace??null}),await g($,te);return}let et=await Promise.resolve(n.apply(fe));if(!et.ok){v({kind:"refused",message:Ve(et)});return}v({kind:"applied",preview:me,stats:me.replace??null}),i?.(et),F.current=null,V.current=J;let we=await de(C,xe);if(!we)return;if(we.matches.length===0){k({index:-1,total:0,truncated:!1});return}await g(we,_t(we,J,1));}catch($){v({kind:"refused",message:$ instanceof Error?$.message:String($)});}},b=async C=>{let M=q.current?.value??"",G=B.current?.value??"";if(!t||M.length===0||N||o)return;let $=j.current;v({kind:"busy"});try{let U=await Promise.resolve(n.version()),te=zt(t,p,M,xe,s,m,U);if(!ce($,te,xe,U)){v({kind:"idle"});return}let J=Nt(t,p).map(Ke=>({op:"replaceText",target:Ke,query:M,replacement:G,entireCell:s,lookIn:xe,matchCase:m,...p==="workbook"?{within:"workbook"}:{}}));if(J.length===0){k({index:-1,total:0,truncated:!1}),v({kind:"idle"});return}let ne={expectVersion:U,steps:J},le=await Promise.resolve(n.validate(ne));if(!ce($,te,xe,U)){v({kind:"idle"});return}if(!le.ok){v({kind:"refused",message:Ve(le)});return}let fe=le.previews,ae=fe[0]??{stepIndex:0,target:J[0].target,wouldChange:!1,changedCellCount:0,replace:void 0},me=Wr(fe,t.sheets);if(!(le.wouldApply&&fe.some(Ke=>Ke.wouldChange))){v({kind:"preview",preview:ae,stats:me});return}if(!C){v({kind:"preview",preview:ae,stats:me});return}let we=await Promise.resolve(n.apply(ne));if(!we.ok){v({kind:"refused",message:Ve(we)});return}v({kind:"applied",preview:ae,stats:me}),k(null),F.current=null,i?.(we);}catch(U){v({kind:"refused",message:U instanceof Error?U.message:String(U)});}},E=C=>{C.key==="Escape"&&(C.preventDefault(),C.stopPropagation(),r());},D=C=>{C.button===0&&(C.target.closest("button, input, label")||(C.preventDefault(),L.current={x:C.clientX,y:C.clientY,baseX:P.x,baseY:P.y},O(true)));};return jsx("div",{style:{position:"fixed",inset:0,zIndex:10001,display:"flex",alignItems:"flex-start",justifyContent:"flex-end",padding:16,pointerEvents:"none"},children:jsxs("form",{role:"dialog","aria-modal":"false","aria-labelledby":W,onSubmit:C=>{C.preventDefault(),d();},onKeyDown:E,style:{width:`min(${_r}px, calc(100vw - 32px))`,padding:16,borderRadius:8,background:"#ffffff",color:a$1.ink,boxShadow:"0 12px 32px rgba(0,0,0,.24)",fontSize:13,display:"flex",flexDirection:"column",gap:10,pointerEvents:"auto",transform:`translate(${P.x}px, ${P.y}px)`},children:[jsxs("div",{onMouseDown:D,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,cursor:I?"grabbing":"move",userSelect:"none"},children:[jsx("strong",{id:W,children:l("replaceDialog.title")}),jsx("button",{type:"button",onClick:r,"aria-label":l("commands.cancel"),style:{...qe,height:26,padding:"0 8px",border:"1px solid #dadce0",background:"#fff",cursor:"pointer"},children:"\xD7"})]}),jsxs("div",{style:{display:"grid",gap:4},children:[jsx("label",{htmlFor:Y,children:l("replaceDialog.find")}),jsxs("div",{style:{display:"flex",gap:6},children:[jsx("input",{id:Y,ref:q,autoComplete:"off",onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),S(C.shiftKey?-1:1));},style:{flex:1,minWidth:0,height:30,padding:"0 8px",border:"1px solid #dadce0",borderRadius:4}}),jsx("button",{type:"button",disabled:!z,onClick:()=>{S(-1);},"aria-label":l("replaceDialog.findPrevious"),title:l("replaceDialog.findPrevious"),style:{...Qn,border:"1px solid #dadce0",background:"#fff",cursor:"pointer"},children:"\u2191"}),jsx("button",{type:"button",disabled:!z,onClick:()=>{S(1);},"aria-label":l("replaceDialog.findNext"),title:l("replaceDialog.findNext"),style:{...Qn,border:"1px solid #dadce0",background:"#fff",cursor:"pointer"},children:"\u2193"})]})]}),jsxs("div",{style:{display:"grid",gap:4},children:[jsx("label",{htmlFor:re,children:l("replaceDialog.replaceWith")}),jsxs("div",{style:{display:"flex",gap:6},children:[jsx("input",{id:re,ref:B,autoComplete:"off",onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),d());},style:{flex:1,minWidth:0,height:30,padding:"0 8px",border:"1px solid #dadce0",borderRadius:4}}),jsx("button",{type:"button",disabled:!z,onClick:()=>{d();},style:{...qe,border:"1px solid #dadce0",background:"#fff",cursor:"pointer"},children:l("replaceDialog.replace")})]})]}),jsxs("fieldset",{style:{border:"none",margin:0,padding:0,display:"grid",gap:6},children:[jsx("legend",{id:H,style:{padding:0,marginBottom:4},children:l("replaceDialog.lookIn")}),jsxs("div",{role:"radiogroup","aria-labelledby":H,style:{display:"flex",gap:16},children:[jsxs("label",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("input",{type:"radio",name:"replace-look-in",checked:a==="values",onChange:()=>{ge(),f("values");}})," ",l("replaceDialog.values")]}),jsxs("label",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("input",{type:"radio",name:"replace-look-in",checked:a==="formulas",onChange:()=>{ge(),f("formulas");}})," ",l("replaceDialog.formulas")]})]})]}),jsxs("label",{htmlFor:x,style:{display:"flex",alignItems:"center",gap:6},children:[jsx("input",{id:x,type:"checkbox",checked:s,onChange:C=>{ge(),h(C.target.checked);}}),l("replaceDialog.entireCell")]}),jsxs("label",{htmlFor:T,style:{display:"flex",alignItems:"center",gap:6},children:[jsx("input",{id:T,type:"checkbox",checked:m,onChange:C=>{ge(),w(C.target.checked);}}),l("replaceDialog.matchCase")]}),jsxs("label",{htmlFor:_,style:{display:"grid",gap:4},children:[l("replaceDialog.scope"),jsxs("select",{id:_,value:p,onChange:C=>{ge(),v({kind:"idle"}),y(C.target.value);},style:{height:30,padding:"0 8px",border:"1px solid #dadce0",borderRadius:4,background:"#fff"},children:[jsx("option",{value:"selection",children:l("replaceDialog.scopeSelection")}),jsx("option",{value:"sheet",children:l("replaceDialog.scopeSheet")}),jsx("option",{value:"workbook",children:l("replaceDialog.scopeWorkbook")})]})]}),jsx("div",{style:{fontSize:12,color:a$1.inkMuted},children:t?p==="selection"?l("replaceDialog.range",{range:t.label}):p==="sheet"?l("replaceDialog.sheetScope",{sheet:ee}):l("replaceDialog.workbookScope",{count:ie}):l("replaceDialog.noRange")}),jsx("div",{style:{fontSize:12,color:"#b06000"},children:l("replaceDialog.formulaWarning")}),jsxs("div",{role:"status","aria-live":"polite",style:{minHeight:18,fontSize:12,color:a$1.inkMuted},children:[c$1.kind==="refused"&&jsx("span",{style:{color:"#b3261e"},children:l("replaceDialog.refused",{message:c$1.message})}),c$1.kind==="busy"&&l("replaceDialog.working"),c$1.kind!=="busy"&&R?.total===0&&l("replaceDialog.noMatches"),R&&R.total>0&&l(R.truncated?"replaceDialog.matchPositionTruncated":"replaceDialog.matchPosition",{index:R.index+1,total:new Intl.NumberFormat(a$2(u)).format(R.total)}),c$1.kind==="preview"&&!c$1.preview.wouldChange&&!R&&!K?.matched&&l("replaceDialog.noMatches"),K?.matched?` ${l("replaceDialog.summary",{matched:K.matched,replaced:K.replaced,formulas:K.skippedFormulas,locked:K.skippedLocked})}`:null,K?.skippedValues?` ${l("replaceDialog.skippedValues",{count:K.skippedValues,cells:$r(K)})}`:null,K&&Ft(K)>0?jsx("span",{style:{color:"#b3261e"},children:` ${l("replaceDialog.refused",{message:Kr(K)})}`}):null]}),jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[jsx("button",{type:"button",disabled:!z,onClick:()=>{b(false);},style:{...qe,border:"1px solid #dadce0",background:"#fff",cursor:"pointer"},children:l("replaceDialog.preview")}),jsx("button",{type:"button",disabled:!z,onClick:()=>{b(true);},style:{...qe,border:"1px solid #217346",background:"#217346",color:"#fff",cursor:"pointer"},children:l("replaceDialog.replaceAll")})]})]})})}var Wt=class extends Component{constructor(){super(...arguments);a(this,"state",{failed:false});}static getDerivedStateFromError(){return {failed:true}}componentDidCatch(n){this.props.onError(n);}render(){return this.state.failed?null:this.props.children}};function Ur(e){return t=>Bn(t.nativeEvent,e)}function dt({host:e$1,activation:t,phase:n="render",children:o}){let r=e$1.commandStore(t),i=Ur(r);return jsx(Wt,{onError:l=>e$1.fail(t.pluginId,n,l),children:jsx(G.Provider,{value:r,children:jsx(U.Provider,{value:null,children:jsx(P.Provider,{value:null,children:jsx(Q$1.Provider,{value:null,children:jsx(X.Provider,{value:null,children:jsx("div",{"data-plugin-activation":e(t.activation),style:{display:"contents"},onKeyDownCapture:i,onMouseDownCapture:i,onClickCapture:i,onDoubleClickCapture:i,children:o})})})})})})})}function ca({host:e,activations:t,layerRef:n,width:o,height:r}){return jsx("div",{ref:n,...ze,className:"xlsx-plugin-overlays","data-plugin-overlays":"","data-testid":"plugin-overlays",style:{position:"absolute",top:0,left:0,width:o,height:r,overflow:"hidden",pointerEvents:"none"},children:t.map(i=>{let l=i.plugin.overlay,u=i.context.geometry;return l&&u?jsx(dt,{host:e,activation:i,children:jsx(l,{context:i.context,geometry:u})},i.key):null})})}var Vr=new Set(["badge","dot"]),qr=new Set(["neutral","info","success","warning","danger"]);function ro(e){return e===void 0||typeof e=="string"}function io(e){if(e===null)return null;let t=e;if(typeof t!="object"||typeof t.version!="string"||!Array.isArray(t.items))throw new TypeError("rowDecorations must return null or { version, items }");if(t.items.length>1e4)throw new TypeError("rowDecorations returned more than 10000 items");let n=new Set,o=[];for(let r of t.items){let i=r;if(!i||typeof i!="object"||typeof i.id!="string"||typeof i.sheetId!="string")throw new TypeError("A row decoration needs a string id and sheetId");if(n.has(i.id))throw new TypeError(`Duplicate row decoration id "${i.id}"`);n.add(i.id);let l=i.row;if(typeof l!="number"||!Number.isInteger(l)||l<0||l>=1048576)throw new TypeError(`Row decoration "${i.id}" has an invalid row`);if(!Vr.has(i.kind))throw new TypeError(`Row decoration "${i.id}" has an unknown kind`);if(i.tone!==void 0&&!qr.has(i.tone))throw new TypeError(`Row decoration "${i.id}" has an unknown tone`);if(!ro(i.text)||!ro(i.tooltip))throw new TypeError(`Row decoration "${i.id}" text and tooltip must be strings`);if(i.text!==void 0&&Array.from(i.text).length>4)throw new TypeError(`Row decoration "${i.id}" text is longer than 4 characters`);o.push(Object.freeze({id:i.id,sheetId:i.sheetId,row:l,kind:i.kind,...i.text!==void 0&&{text:i.text},...i.tone!==void 0&&{tone:i.tone},...i.tooltip!==void 0&&{tooltip:i.tooltip}}));}return Object.freeze({version:t.version,items:Object.freeze(o)})}var Yr=20;function lo(e,t,n){if(t===null)return null;let o=new Map,r=i=>i.tooltip??i.text??n(i.row);for(let i of e)for(let l of i.items){if(l.sheetId!==t)continue;let u=o.get(l.row);if(u||(u={shown:[],more:0,named:[],tooltip:""},o.set(l.row,u)),u.shown.length<2){u.shown.push({entry:{pluginId:i.pluginId,key:i.key,...i.activationId&&{activationId:i.activationId},item:l},label:r(l)});continue}u.more+=1,u.named.length<Yr&&u.named.push(r(l));}for(let i of o.values()){if(!i.more)continue;let l=i.more-i.named.length;i.tooltip=l>0?[...i.named,`+${l}`].join(`
4
+ `):i.named.join(`
5
+ `);}return o.size?{sheetId:t,rows:o}:null}var Bt={neutral:{ink:"#3c4043",fill:"#e8eaed"},info:{ink:"#174ea6",fill:"#d2e3fc"},success:{ink:"#0d652d",fill:"#ceead6"},warning:{ink:"#7a4f01",fill:"#feefc3"},danger:{ink:"#a50e0e",fill:"#fad2cf"}},Kt=1,Qr={position:"absolute",top:0,boxSizing:"border-box",margin:0,border:"none",background:"transparent",font:"inherit",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"};function ei(e,t){let n=Bt[e.tone??"neutral"];if(e.kind==="dot"){let o=6*t;return {flex:"none",width:o,height:o,maxWidth:"100%",maxHeight:"100%",borderRadius:"50%",background:n.ink}}return {display:"block",minWidth:0,maxWidth:"100%",maxHeight:"100%",boxSizing:"border-box",padding:`0 ${t}px`,borderRadius:3*t,background:n.fill,color:n.ink,fontSize:8*t,lineHeight:`${10*t}px`,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}}function ti(e,t,n){return {position:"absolute",top:0,right:0,maxWidth:t,maxHeight:n,boxSizing:"border-box",padding:`0 ${e}px`,borderRadius:2*e,background:Bt.neutral.fill,color:Bt.neutral.ink,fontSize:6*e,lineHeight:`${7*e}px`,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",pointerEvents:"none"}}var ba=memo(function({host:t,index:n,painted:o,zoom:r,top:i=0}){let{t:l}=c(),u=useSyncExternalStore(o.subscribe,o.get,()=>null),a=u?.zoom??r,f=m=>w=>{w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),w.stopPropagation(),t.activateRowDecoration(m));},p=24*r-Kt,y=[],s=u&&u.sheetId===n.sheetId?u.frame:null,h=s?.grid;for(let m=0;s&&h&&m<h.rowOffsets.length-1;m++){let w=h.rowIndices?.[m]??h.startRow+m,c=n.rows.get(w),v=(h.rowOffsets[m+1]-h.rowOffsets[m])*a;if(!c||!(v>0)||h.rowOffsets[m]>=s.height)continue;let R=p/c.shown.length;y.push(jsxs("div",{"data-row":w,title:c.more>0?c.tooltip:void 0,style:{position:"absolute",left:0,top:h.rowOffsets[m]*a,width:p,height:v,overflow:"hidden"},children:[c.shown.map(({entry:k,label:P},X)=>jsx("button",{type:"button","data-plugin-id":k.pluginId,"data-plugin-activation":k.activationId,"data-decoration-id":k.item.id,"aria-label":P,title:k.item.tooltip,onClick:()=>t.activateRowDecoration(k),onKeyDown:f(k),onKeyUp:I=>{I.key===" "&&I.preventDefault();},style:{...Qr,left:X*R,width:R,height:v,padding:`0 ${a}px`},children:jsx("span",{"aria-hidden":true,style:ei(k.item,a),children:k.item.kind==="badge"?k.item.text:null})},`${k.key}\0${k.item.id}`)),c.more>0&&jsx("span",{role:"img","data-testid":"xlsx-row-decoration-more","aria-label":c.tooltip,title:c.tooltip,style:ti(a,R,v),children:`+${c.more}`})]},w));}return jsx("div",{style:{position:"relative",flex:"none",width:0,height:0},children:jsx("div",{...ze,role:"region","aria-label":l("plugins.rowGutter"),"data-testid":"xlsx-row-gutter",style:{position:"absolute",top:i,left:0,width:p+Kt,height:u?u.frame.height*a:0,overflow:"hidden",boxSizing:"border-box",borderRight:`${Kt}px solid #e0e0e0`,background:"#f8f9fa"},children:y})})});var ri={left:280,right:280,bottom:200},Vt={left:160,right:160,bottom:120},ii=640,ye={surface:"#ffffff",border:"#e2e8f0",text:"#172033",muted:"#647087",selected:"#e6f4ea",primary:"#217346"};function li(e,t,n){let o=e==="bottom"?n.height:n.width,r=Math.max(Vt[e],Math.floor(o*.4));return Math.max(Vt[e],Math.min(t??ri[e],r))}function uo(e=true){let t=useRef(null),[n,o]=useState({width:0,height:0});return useEffect(()=>{let r=t.current;if(!e||!r)return;let i=()=>o(u=>u.width===r.clientWidth&&u.height===r.clientHeight?u:{width:r.clientWidth,height:r.clientHeight});if(i(),typeof ResizeObserver>"u")return;let l=new ResizeObserver(i);return l.observe(r),()=>l.disconnect()},[e]),[t,n]}var ka=uo;function si({host:e,activation:t,id:n,labelledBy:o}){let[r,i]=uo(),l=t.plugin.panel.render;return jsx("div",{ref:r,id:n,role:"tabpanel","aria-labelledby":o,className:"xlsx-plugin-dock__panel",style:{flex:1,minHeight:0,minWidth:0,overflow:"auto"},children:jsx(dt,{host:e,activation:t,children:jsx(l,{context:t.context,width:i.width,height:i.height})})})}var ai=e=>({maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"4px 8px",border:0,borderRadius:4,background:e?ye.selected:"transparent",color:e?ye.primary:ye.muted,font:"12px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"}),so={flex:"0 0 auto",padding:"0 6px",border:0,borderRadius:4,background:"transparent",color:ye.muted,font:"13px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"};function Ea({host:e,placement:t,activations:n,available:o}){let{t:r}=c(),i=useId(),[l,u]=useState(null),[a,f]=useState({}),[p,y]=useState(false),s=useRef(null),h=useRef(null),m=t!=="bottom"&&o.width>0&&o.width<ii,w=m&&p&&n.length>0;if(useEffect(()=>{w&&h.current?.focus();},[w]),n.length===0)return null;let c$1=n.find(W=>W.pluginId===l)??n[0],v=c$1.plugin.panel,R=m?!w:a[c$1.pluginId]??v.defaultCollapsed??false,k=li(t,v.preferredSize,o),P=W=>`${i}-tab-${W}`,X=`${i}-panel`,I=W=>s.current?.querySelector(`[data-plugin-tab="${W}"]`)?.focus(),O=W=>{m?y(!(w&&W===c$1.pluginId)):W===c$1.pluginId&&R&&f(Y=>({...Y,[W]:false})),u(W);},L=()=>{y(false),I(c$1.pluginId);},F=W=>{let Y=n.findIndex(T=>T.pluginId===c$1.pluginId),re=n.length-1,H=W.key==="ArrowRight"||W.key==="ArrowDown"?Y===re?0:Y+1:W.key==="ArrowLeft"||W.key==="ArrowUp"?Y===0?re:Y-1:W.key==="Home"?0:W.key==="End"?re:null;if(H===null)return;W.preventDefault();let x=n[H].pluginId;u(x),I(x);},j=r(R?"plugins.expandPanel":"plugins.collapsePanel",{title:v.title}),V=t==="bottom",q=m||!V&&R,B=jsx(si,{host:e,activation:c$1,id:X,labelledBy:P(c$1.pluginId)},c$1.key);return jsxs("section",{...ze,className:`xlsx-plugin-dock xlsx-plugin-dock--${t}`,"data-testid":`plugin-dock-${t}`,"aria-label":r("plugins.panelTabs"),style:{position:"relative",display:"flex",flexDirection:"column",flexShrink:0,minWidth:0,minHeight:0,background:ye.surface,color:ye.text,...V?{height:R?void 0:k,borderTop:`1px solid ${ye.border}`}:{width:R||m?void 0:k,maxWidth:R||m?96:void 0,[t==="left"?"borderRight":"borderLeft"]:`1px solid ${ye.border}`}},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:4,flexWrap:"wrap"},children:[jsx("div",{ref:s,role:"tablist","aria-label":r("plugins.panelTabs"),"aria-orientation":q?"vertical":"horizontal",onKeyDown:F,style:{display:"flex",flexDirection:q?"column":"row",gap:2,flex:1,minWidth:0,overflow:"hidden"},children:n.map(W=>{let Y=W.pluginId===c$1.pluginId;return jsx("button",{type:"button",role:"tab",id:P(W.pluginId),"data-plugin-tab":W.pluginId,"aria-selected":Y,"aria-controls":Y&&!R?X:void 0,"aria-expanded":m?Y&&w:void 0,tabIndex:Y?0:-1,title:W.plugin.panel.title,onClick:()=>O(W.pluginId),style:ai(Y),children:W.plugin.panel.title},W.pluginId)})}),!m&&jsx("button",{type:"button","aria-expanded":!R,"aria-label":j,title:j,onClick:()=>f(W=>({...W,[c$1.pluginId]:!R})),style:so,children:R?"+":"\u2212"})]}),!R&&!m&&B,w&&jsxs("div",{ref:h,tabIndex:-1,"data-testid":`plugin-drawer-${t}`,onKeyDown:W=>{W.key==="Escape"&&(W.stopPropagation(),L());},style:{position:"absolute",top:0,bottom:0,[t==="left"?"left":"right"]:"100%",width:Math.min(k,Math.max(Vt[t],o.width-64)),zIndex:60,display:"flex",flexDirection:"column",background:ye.surface,boxShadow:"0 4px 16px rgba(15, 23, 42, 0.18)",outline:"none"},children:[jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:4},children:jsx("button",{type:"button","aria-label":j,title:j,onClick:L,style:so,children:"\xD7"})}),B]})]})}var fo=5e4,ci=1e5;function po(e,t,n,o){if(o.length===0||!e.gatesEdits())return null;let r=t.readCells({ranges:[]}),i=r.ok?r.sheets[n]:void 0;return i?o.map(({row:l,col:u})=>({sheetId:i.sheetId,row:l,col:u})):null}function Ta(e,t,n,o){let[r]=po(e,t,n,[o])??[];return !r||e.openGate().cellEditable(r)}function mo(e,t,n,o,r,i,l){if(o.length>0&&e.editGateStarting())return new v(l);let u=po(e,t,n,o);if(!u)return [...o];let a=e.openGate();if(!u.every(p=>a.cellEditable(p)))return new v(i);let f=[];for(let[p,y]of u.entries()){let s=a.beforeCellCommit({...y,input:o[p].input,source:r});if(!s.ok)return new v(s.message??i);f.push({...o[p],input:s.input});}return f}function Da(e,t,n,o,r,i,l){if(!e.gatesEdits())return [...o];let u=o.filter(({row:y,col:s})=>t.cell(n,y,s).input!=="");if(l&&u.length>fo)return new v(l.tooMany);let f=mo(e,t,n,u,l?"cut":"clear-key",r,i);if(!Array.isArray(f))return f;let p=new Map(f.map(y=>[`${y.row}:${y.col}`,y.input]));return o.map(y=>({...y,input:p.get(`${y.row}:${y.col}`)??y.input}))}function co(e){let t=e+1,n="";for(;t>0;)t-=1,n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26);return n}function di(e){return `${co(e.left)}${e.top+1}:${co(e.right)}${e.bottom+1}`}function fi(e){let t={at:[],items:[]};return e.forEach((n,o)=>{!n.copyFrom||!n.input.startsWith("=")||(t.at.push(o),t.items.push({formula:n.input.slice(1),from:n.copyFrom,to:{row:n.row,col:n.col}}));}),t}function pi(e,t,n){let o=e.map(r=>r.input);return t.at.forEach((r,i)=>{let l=n[i];if(!l?.ok)throw new Error(l?.error??"formula could not be moved");o[r]=`=${l.formula}`;}),o}function mi(e){if(e.length===0)return [];let t=new Map;for(let{row:i,col:l}of e){let u=t.get(i);u?(u.left=Math.min(u.left,l),u.right=Math.max(u.right,l)):t.set(i,{top:i,bottom:i,left:l,right:l});}let n=[...t.values()],o=n.reduce((i,l)=>({top:Math.min(i.top,l.top),bottom:Math.max(i.bottom,l.bottom),left:Math.min(i.left,l.left),right:Math.max(i.right,l.right)}));return (o.bottom-o.top+1)*(o.right-o.left+1)<=ci?[o]:n}function gi(e,t,n,o){let r=(u,a)=>{let f=n.findIndex(p=>u>=p.top&&u<=p.bottom&&a>=p.left&&a<=p.right);return f<0?"":o[f][u-n[f].top]?.[a-n[f].left]?.input??""},i=n.length===1?r:(()=>{let u=new Map(n.map((a,f)=>[a.top,f]));return (a,f)=>{let p=u.get(a);return p===void 0?"":o[p][0]?.[f-n[p].left]?.input??""}})(),l=[];return e.forEach((u,a)=>{let f=t[a];f!==i(u.row,u.col)&&l.push({row:u.row,col:u.col,input:f});}),l}function hi(e,t,n){let o=new Map;return n.forEach((r,i)=>{r.input!==t[i].input&&o.set(`${r.row}:${r.col}`,r.input);}),o.size===0?[...e]:e.map(r=>{let i=o.get(`${r.row}:${r.col}`);return i===void 0?r:{row:r.row,col:r.col,input:i}})}function Aa(e,t,n,o,r,i,l){if(o.length===0||!e.gatesEdits())return [...o];let u=fi(o),a=pi(o,u,u.items.length?translateFormulasOn(t,u.items):[]),f=mi(o),p=gi(o,a,f,f.map(s=>t.rangeCells(n,di(s))));if(p.length>fo)return new v(l);let y=mo(e,t,n,p,"paste",r,i);return Array.isArray(y)?hi(o,p,y):y}function La(e){let t=[];for(let{row:o,col:r}of [...e].sort((i,l)=>i.row-l.row||i.col-l.col)){let i=t[t.length-1];i&&i.top===o&&r<=i.right+1?i.right=Math.max(i.right,r):t.push({top:o,bottom:o,left:r,right:r});}let n=[];for(let o of t){let r=n[n.length-1];r&&r.left===o.left&&r.right===o.right&&r.bottom+1===o.top?r.bottom=o.top:n.push(o);}return n}function xi(e){return e.altKey&&e.key==="F10"?false:e.ctrlKey||e.metaKey?["v","x"].includes(e.key.toLowerCase()):e.altKey?false:e.key.length===1||["Enter","Backspace","Delete"].includes(e.key)}function go({root:e,isEditorTarget:t,settleMs:n=350,restartOnTyping:o=true,canSettle:r=()=>true,onUnsettle:i,onSettle:l,onResettle:u}){let a=()=>typeof e=="function"?e():e,f=a()?.ownerDocument??globalThis.document,p=true,y=false,s=false,h="keyboard",m,w,c=null,v=F=>F instanceof Node&&!!a()?.contains(F)||!!t?.(F),R=()=>{c!==null&&clearTimeout(c),c=null;},k=()=>{!p||y||!r()||(s=false,m===w?u?.(h):(w=m,l(h)),h="keyboard");},P=()=>{R(),s=false,!(!p||y)&&(c=setTimeout(()=>{c=null,s=true,k();},n));},X=F=>{v(F.target)&&(y=true,s=false,h=F.pointerType==="touch"?"touch":"pointer",R(),i());},I=()=>{y&&(y=false,P());},O=F=>{v(F.target)&&(h="keyboard",o&&xi(F)&&(c!==null||s)&&P());},L=f.defaultView;return f.addEventListener("pointerdown",X,true),f.addEventListener("pointerup",I,true),f.addEventListener("pointercancel",I,true),L?.addEventListener("pointerup",I,true),L?.addEventListener("pointercancel",I,true),L?.addEventListener("blur",I),f.addEventListener("lostpointercapture",I,true),f.addEventListener("keydown",O,true),{notifySelectionChange(F){if(p){if(F===m){s&&k();return}s=false,m=F,i(),y||P();}},dispose(){p=false,R(),f.removeEventListener("pointerdown",X,true),f.removeEventListener("pointerup",I,true),f.removeEventListener("pointercancel",I,true),L?.removeEventListener("pointerup",I,true),L?.removeEventListener("pointercancel",I,true),L?.removeEventListener("blur",I),f.removeEventListener("lostpointercapture",I,true),f.removeEventListener("keydown",O,true);}}}function ho(e,t){let n=e()[0]?.ownerDocument??globalThis.document,o=n.defaultView,r=null,i=true,l=typeof n.hasFocus=="function"?n.hasFocus():true,u=false,a=[],f=new MutationObserver(()=>h()),p=()=>{let P=e().filter(X=>X.isConnected);if(!(P.length===a.length&&P.every((X,I)=>X===a[I]))){f.disconnect(),a=P;for(let X of a)f.observe(X,{childList:true,subtree:true});}},y=P=>P instanceof Node&&P.isConnected&&!(P instanceof Element?P:P.parentElement)?.closest("[data-plugin-overlays]")&&e().some(X=>X.isConnected&&X.contains(P)),s=P=>{i&&(P?p():(f.disconnect(),a=[]),r!==P&&(r=P,t(P)));},h=()=>s(l&&y(n.activeElement)),m=()=>{u||(u=true,queueMicrotask(()=>{u=false,i&&h();}));},w=P=>s(l&&y(P.target)),c=P=>{y(P.relatedTarget)?s(l):m();},v=()=>{l=false,s(false);},R=()=>{l=true,m();};return n.addEventListener("focusin",w,true),n.addEventListener("focusout",c,true),o.addEventListener("blur",v),o.addEventListener("focus",R),h(),Object.assign(()=>{i=false,f.disconnect(),n.removeEventListener("focusin",w,true),n.removeEventListener("focusout",c,true),o.removeEventListener("blur",v),o.removeEventListener("focus",R);},{recheck:()=>{i&&h();}})}var bi=Object.freeze({commands:Object.freeze([])});function xo(e){if(!e||typeof e!="object")return bi;let t=Array.isArray(e.commands)?[...new Set(e.commands.filter(n=>typeof n=="string"))].sort():[];return e.document!=="write"?Object.freeze({commands:Object.freeze(t)}):Object.freeze({commands:Object.freeze(t),document:"write",...e.editBatches===true?{editBatches:true}:{},...e.untrackedHistory===true?{untrackedHistory:true}:{}})}function bo(e,t){let n=e.commands??[],o=t.commands??[];return e.document===t.document&&e.editBatches===t.editBatches&&e.untrackedHistory===t.untrackedHistory&&n.length===o.length&&n.every((r,i)=>r===o[i])}function yo(e,t){return e.commands?.includes(t)??false}function wo(e){return e.document==="write"}function pt(e,t){return e.document==="write"&&e.editBatches===true&&(t!=="none"||e.untrackedHistory===true)}var yi=/^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,126}[A-Za-z0-9])?$/;function wi(e){return typeof e=="string"&&yi.test(e)}function vo(e){return e.revision===void 0?"":`${typeof e.revision}:${e.revision}`}var Co=10;function qt(e){return e.type==="load"?"document-change":e.type}function vi(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function Yt(e){let t=new AbortController;if(e.aborted)return t.abort(),{controller:t,release:()=>{}};let n=()=>t.abort();return e.addEventListener("abort",n,{once:true}),{controller:t,release:()=>e.removeEventListener("abort",n)}}function Po(e){let t=new Map,n=null,o=false,r={},i=new Map,l=new WeakSet,u=new Set,a=new Set,f=0,p=0,y=null,s=[],h=false,m=new Set,w=()=>!h&&[...t.values()].every(({activation:x})=>!x||x.status==="disposed"||x.status==="ready"&&!x.running&&!x.pumping&&!x.pending.length),c=()=>{if(!(!m.size||!w())){for(let x of m)x();m.clear();}},v=x=>{try{e.report(x);}catch(T){console.error("[plugins] onPluginError threw",T);}},R=x=>{let T=Object.hasOwn(r,x)?r[x]:void 0,_=i.get(x);if(_&&_.source===T)return _.grant;let A=xo(T);return i.set(x,{source:T,grant:A}),A},k=x=>{let T=`${f}:${x.stateRevision}`;if(x.rendered?.key===T)return x.rendered.entry;let _=j(x,x.lifetime.signal),A={pluginId:x.registration.id,plugin:x.registration.plugin,generation:x.generation,activation:x.token,key:x.key,context:e.context(_,x.registration.plugin)};return x.rendered={key:T,entry:A},A},P=()=>{h=false;let x=[];for(let _ of t.values()){let A=_.activation;A?.status==="ready"&&x.push(k(A));}x.length===s.length&&x.every((_,A)=>_===s[A])||(s=x);for(let _ of [...a])_();c();},X=()=>{f+=1,!h&&(h=true,queueMicrotask(P));},I=(x,T)=>x.status==="disposed"?x.ended==="document-replaced"?"document-replaced":"plugin-unavailable":T.aborted?"aborted":null,O=(x,T,_)=>{let A=N=>v({pluginId:x.registration.id,generation:x.generation,phase:"cleanup",error:N});try{let N=T(_);vi(N)&&N.then(void 0,A);}catch(N){A(N);}},L=(x,T)=>{if(x.status!=="disposed"){x.status="disposed",x.ended=T,x.pending=[],x.registration.activation===x&&(x.registration.activation=null),x.lifetime.abort();for(let _ of x.cleanups.splice(0).reverse())O(x,_,T);X();}},F=(x,T,_)=>{x.status!=="disposed"&&(x.registration.quarantined=true,v({pluginId:x.registration.id,generation:x.generation,phase:T,error:_}),L(x,"failed"));};function j(x,T){let _=e.snapshot(x.registration.id,x.generation);return {pluginId:x.registration.id,activation:x.token,snapshot:_,signal:T,lifetimeSignal:x.lifetime.signal,state:()=>x.state,setState(N,z){if(I(x,T)!==null)return false;let K=e.currentVersion();return K===null||(z??_.version)!==K?false:(x.state=typeof N=="function"?N(x.state):N,x.stateRevision+=1,X(),true)},onCleanup(N){if(typeof N!="function")throw new TypeError("A cleanup must be a function");x.status==="disposed"?O(x,N,x.ended??"unmounted"):x.cleanups.push(N);},run:N=>V(x,N),commit(N){let z=y;y=T;try{return N()}finally{y=z;}},refusal:()=>I(x,T)}}async function V(x,T){let{controller:_,release:A}=Yt(x.lifetime.signal);if(!_.signal.aborted)try{await T(j(x,_.signal));}catch(N){_.signal.aborted||F(x,"action",N);}finally{A();}}async function q(x,T,_,A){let{controller:N,release:z}=Yt(x.lifetime.signal);x.running={channel:_,controller:N};try{let K=j(x,N.signal);return await A(e.context(K,x.registration.plugin),K),x.status==="disposed"?"ended":N.signal.aborted?"aborted":"ok"}catch(K){return x.status==="disposed"?"ended":N.signal.aborted?"aborted":(F(x,T,K),"ended")}finally{z(),x.running?.controller===N&&(x.running=null);}}async function B(x){if(!x.pumping){x.pumping=true;try{for(;x.status==="ready";){let T=x.pending.shift();if(!T)break;if(!x.registration.plugin.onEvent)continue;if(await q(x,"event",qt(T),(A,N)=>{if(!e.eventCurrent||e.eventCurrent(T,N.snapshot))return x.registration.plugin.onEvent?.(A,T)})==="ended")break}}finally{x.pumping=false,c();}}}let W=(x,T)=>{if(x.status==="disposed"||T.generation!==x.generation)return;let _=qt(T),A=x.pending.findIndex(z=>qt(z)===_);if(A>=0){if(x.pending[A].type==="load")return;x.pending[A]=T;}else x.pending.push(T);let N=x.running;N?.channel===_&&N.controller.signal!==y&&N.controller.abort(),x.status==="ready"&&queueMicrotask(()=>{B(x);});};async function Y(x,T,_){p+=1;let A={token:Object.freeze({}),key:`${x.id}#${p}`,registration:x,generation:T,lifetime:new AbortController,status:"initializing",ended:null,state:void 0,stateRevision:0,cleanups:[],pending:[],running:null,pumping:false,rendered:null};x.activation=A;try{A.state=x.plugin.createState();}catch(z){F(A,"initialize",z);return}if(x.plugin.initialize&&await q(A,"initialize","initialize",K=>A.registration.plugin.initialize?.(K))==="ended")return;let N="aborted";for(let z=0;N==="aborted"&&A.status!=="disposed";z+=1){if(z===Co){F(A,"event",new Error(`Document changes superseded the load hook ${Co} times`));return}A.pending=[],N=await q(A,"event","document-change",(K,ee)=>A.registration.plugin.onEvent?.(K,e.loadEvent(ee.snapshot,_)));}N!=="ok"||A.status==="disposed"||(A.status="ready",X(),B(A));}let re=(x,T)=>v({pluginId:x,generation:n,phase:"definition",error:T}),H=x=>{n=null,x==="unmounted"&&(o=false);for(let T of t.values())T.activation&&L(T.activation,x);X();};return {setPlugins(x){let T=new Map;for(let z of x){let K=wi(z?.id)?e.validate?.(z):new TypeError(`Invalid plugin id ${JSON.stringify(z?.id)}`);if(K!=null){z&&typeof z=="object"&&!l.has(z)&&(l.add(z),re(typeof z.id=="string"?z.id:"",K));continue}let ee=T.get(z.id);ee?ee.push(z):T.set(z.id,[z]);}let _=new Set,A=new Map,N=[];for(let[z,K]of T){if(K.length>1){_.add(z),u.has(z)||re(z,new Error(`${K.length} plugins share the id "${z}"`));continue}let ee=K[0],ie=t.get(z);if(ie&&vo(ie.plugin)===vo(ee)){ie.plugin=ee,A.set(z,ie);continue}ie&&N.push([ie,"definition-replaced"]),A.set(z,{id:z,plugin:ee,quarantined:false,activation:null});}u=_;for(let[z,K]of t)A.has(z)||N.push([K,"removed"]);t=A;for(let[z,K]of N)z.activation&&L(z.activation,K);if(n!==null)for(let z of t.values())!z.activation&&!z.quarantined&&Y(z,n,"attached");X();},registered:()=>new Map([...t].map(([x,T])=>[x,T.plugin])),setGrants(x){let T=new Map([...t.keys()].map(A=>[A,R(A)]));r=x??{},i.clear();let _=false;for(let A of t.values()){let N=R(A.id),z=T.get(A.id);if(bo(z,N)){i.get(A.id).grant=z;continue}_=true;let K=A.activation;K&&W(K,e.grantsEvent(e.snapshot(A.id,K.generation),N));}_&&X();},grant:R,open(x){if(n===x)return;n!==null&&H("document-replaced"),n=x;let T=o?"replaced":"loaded";o=true;for(let _ of t.values())_.quarantined=false,Y(_,x,T);X();},close:H,generation:()=>n,notify(x){if(x.generation===n){for(let T of t.values())T.activation&&W(T.activation,x);X();}},notificationsIdle(){return w()?Promise.resolve():new Promise(x=>m.add(x))},touch:X,activations:()=>s,activationState(x){let T=t.get(x),_=T?.activation;return !_||T.quarantined||n===null||_.generation!==n||_.status==="disposed"?"none":_.status==="ready"?"ready":"loading"},subscribe(x){return a.add(x),()=>{a.delete(x);}},guard(x,T,_,A){let N=t.get(x)?.activation;if(N?.status!=="ready")return A;try{return _(k(N).context)}catch(z){return queueMicrotask(()=>F(N,T,z)),A}},async invoke(x,T,_){let A=t.get(x)?.activation;if(A?.status!=="ready")return {ok:false,reason:"plugin-unavailable"};let{controller:N,release:z}=Yt(A.lifetime.signal),K=j(A,N.signal);try{return {ok:!0,value:await _(e.context(K,A.registration.plugin))}}catch(ee){let ie=K.refusal();return ie?{ok:false,reason:ie}:(F(A,T,ee),{ok:false,reason:"failed"})}finally{z();}},fail(x,T,_){let A=t.get(x)?.activation;A&&F(A,T,_);}}}var Ci={"plugin-unavailable":"The plugin is no longer active","document-replaced":"The workbook was replaced",aborted:"This plugin context was superseded","permission-denied":"The host has not granted this operation","read-only":"The editor is read-only","input-failed":"Pending input could not be applied","unsupported-policy":"Plugins cannot run this operation yet","plugin-failed":"The plugin failed"},Pi={"stale-version":"The workbook changed after that version","missing-target":"The target is not in the workbook","ambiguous-target":"The target does not identify one place","layout-unavailable":"The sheet cannot be shown",unsupported:"The editor cannot show this target now"},Ri=new Set(["nearest","start","center"]);function Re(e,t=Ci[e]){return {ok:false,failure:{code:e,message:t}}}function Fe(e){let t=e.refusal();return t?Re(t):null}function Jt(e$1,t,n){return {gesture:()=>f(e(e$1.activation)),deny(o){let r=e$1.refusal();if(r)return r;if(k(o))return o.startsWith(`plugin:${e$1.pluginId}/`)?null:"permission-denied";let i=t();return !yo(i,o)||j[o].mutatesDocument&&!wo(i)?"permission-denied":null},subscribe:n}}function ki(e,t,n){return !n()&&e.some(o=>o.aborted)?Promise.resolve(null):new Promise((o,r)=>{let i=()=>{n()||(l(),o(null));},l=()=>{for(let u of e)u.removeEventListener("abort",i);};for(let u of e)u.addEventListener("abort",i,{once:true});t.then(u=>{l(),o(u);},u=>{l(),r(u);});})}function Ro(e,t,n,o){if("identity"in t)throw new Error("Document access requires async plugin clients");let r=async s=>{let h=Fe(e);if(h)return h;let m=t.handle();if(!m)return Re("plugin-unavailable");let w=false,c=await ki([e.signal,e.lifetimeSignal],t.admit(m,()=>{let v=Fe(e);return v?{refused:v}:(w=true,{value:s(m)})}),()=>w);return c?c.ok?"refused"in c.value?c.value.refused:c.value.value:Fe(e)??Re(c.code):Fe(e)??Re("aborted")},i={version:()=>r(s=>({ok:true,version:s.version()})),readCells:s=>r(h=>h.readCells(s)),findText:s=>r(h=>h.findText(s)),validateEdits:s=>r(h=>t.readOnlyRefusal(h)??h.validateEdits(s))},l=s=>Fe(e)??(pt(n(),s)?null:Re("permission-denied")),u=pt(n(),"separate")?{async applyEdits(s){let h=l(s?.history);if(h)return h;if(t.admitEdits){let m=t.handle();if(!m)return Re("plugin-unavailable");let w=structuredClone(s),c=await t.admitEdits(m,w,v=>v?pt(n(),w.history)?null:Re("permission-denied"):l(w.history),v=>e.commit(v));return c.ok?c.value:Re(c.code)}return r(m=>t.applyEdits(m,s,()=>l(s.history),w=>e.commit(w)))}}:null,a={getDescriptor:s=>o.getDescriptor(s),getState:(s,h)=>o.getState(s,h),subscribe:s=>o.subscribe(s),execute:async(s,h)=>Fe(e)??o.execute(s,h)},f=()=>e.refusal()===null,p=async(s,h)=>{let m=await r(w=>w.version()===s?.expectVersion?h(w):"stale-version");return m===null?{ok:true}:typeof m=="object"?m:{ok:false,failure:{code:m,message:Pi[m]}}};return {read:i,commands:a,edits:u,navigation:{selectCells:(s,h)=>p(h,m=>t.navigator.selectCells(m,s,h.focus===true,f)),scrollToCell:(s,h)=>p(h,m=>{let w=h.align??"nearest";return Ri.has(w)?t.navigator.scrollToCell(m,s,w,f):"unsupported"})}}}function Zt(e,t){return e?.scoped(t)??z}var Ei="edit gating is not supported in the legacy worker editor",Si=Object.freeze({enabled:true});function Ii(e){let t=e;if(!t||typeof t.enabled!="boolean")throw new TypeError("A command getState must return a CommandState");if(!t.enabled&&(typeof t.disabledReason?.code!="string"||typeof t.disabledReason.message!="string"))throw new TypeError("A disabled command state needs a disabledReason");return e}function Xi(e){let t=e;return t&&typeof t.ok=="boolean"?e:{ok:true,status:"executed"}}function Mi(e){if(e!==null&&typeof e=="object"){let t=e,n=t.action;if(n==="accept")return {action:n};if(n==="replace"){let o=t.input;if(typeof o=="string")return {action:n,input:o}}if(n==="refuse"){let o=t.message;if(o===void 0)return {action:n};if(typeof o=="string")return {action:n,message:o}}}throw new TypeError("beforeCellCommit must return an accept, replace or refuse decision")}function Ti(e){return e===""?"clear":e.startsWith("=")?"formula":"value"}function Di(e,t){return e===t||!!e&&!!t&&e.id===t.id&&e.version===t.version}function mt(e){try{return e.version()}catch{return null}}function ko(e$1,t=Ro,{editGate:n$1=true}={}){let o,r=null,i$1=null,l=null,u=false,a=0,f="null",p=new WeakMap,y=null,s=null,h=false,m$1=()=>{s&&!h&&(y=null),s=null;},w=null,c={version:"",readOnly:false,focused:false,locale:"en",selectionSettled:true,selection:null,layout:null,proposals:JSON.stringify({proposals:[],staleFor:{},version:null}),previewVersion:0},v=new WeakMap,R=new WeakMap,k$1=0,P=g=>{let S=R.get(g);return S===void 0&&(k$1+=1,S=k$1,R.set(g,S)),S},X=new WeakSet,I=new WeakMap,O=new Map,L=g=>O.get(g.pluginId)??g.plugin,F=Object.freeze([]),j=new Set,V=[],q=g=>{if(!o){console.error(`[XlsxEditor] plugin "${g.pluginId}" failed (${g.phase})`,g.error);return}try{o(g);}catch(S){console.error("[XlsxEditor] onPluginError threw",S);}},B=()=>e$1.commands(),W=g=>{let S=()=>H.grant(g.pluginId);if(g.signal!==g.lifetimeSignal)return Jt(g,S,H.subscribe);let d=v.get(g.activation);return d||(d=Jt(g,S,H.subscribe),v.set(g.activation,d)),d},Y=g=>{let S=g.pluginId,d=t(g,e$1,()=>H.grant(S),Zt(B(),W(g))),b=e$1.geometry(),E=b?.getPositionAtPoint??null,D=p.get(g.snapshot),C=()=>D===f;return {pluginId:S,snapshot:g.snapshot,get state(){return g.state()},signal:g.signal,lifetimeSignal:g.lifetimeSignal,read:d.read,commands:d.commands,edits:d.edits,geometry:b&&g.snapshot.layout?.id===b.layout.id?{layout:b.layout,getCellRect:M=>g.refusal()?null:b.getCellRect(M),getRangeRect:M=>g.refusal()?null:b.getRangeRect(M),getAnchorGeometry:M=>g.refusal()||M.kind==="selection"&&!C()?{ok:false,failure:{code:"layout-unavailable",message:"The plugin context is no longer current"}}:b.getAnchorGeometry(M),readAnchorGeometries:async M=>g.refusal()?M.map(()=>({ok:false,failure:{code:"layout-unavailable",message:"The plugin context is no longer current"}})):(await b.readAnchorGeometries(M)).map(($,U)=>g.refusal()||M[U].kind==="selection"&&!C()?{ok:false,failure:{code:"layout-unavailable",message:"The plugin context is no longer current"}}:$),getPositionAtPoint:E&&((M,G)=>g.refusal()?null:E(M,G))}:null,navigation:d.navigation,setState:(M,G)=>g.setState(M,G),onCleanup:M=>g.onCleanup(M),run:M=>g.run(G=>M(Y(G)))}},re=(g,S)=>{let d={generation:S,version:c.version,readOnly:c.readOnly,focused:c.focused,locale:c.locale,grant:H.grant(g),selection:c.selection,selectionSettled:c.selectionSettled,layout:c.layout};return p.set(d,f),d},H=Po({context:g=>Y(g),snapshot:(g,S)=>re(g,S),currentVersion:()=>i$1&&H.generation()!==null?"identity"in e$1?e$1.currentVersion(i$1):mt(i$1):null,loadEvent:(g,S)=>({type:"load",generation:g.generation,version:g.version,reason:S}),grantsEvent:(g,S)=>({type:"grants-change",generation:g.generation,grant:S}),eventCurrent:(g,S)=>{if(g.type!=="selection-settle")return true;let d=g===s&&g.version===S.version&&y===p.get(S)&&JSON.stringify(g.selection)===JSON.stringify(S.selection);return g===s&&(d?h=true:m$1()),d},validate:ma,report:q}),x=g=>{(g.type==="selection-change"||g.type==="document-change")&&m$1(),H.notify(g);},T=()=>{let g=H.generation();if(!("identity"in e$1)){let d=i$1?mt(i$1):null;if(!g||!d||d===c.version)return;c.version=d,x({type:"document-change",generation:g,version:d}),c.layout&&c.layout.version!==d&&(c.layout=null,x({type:"layout-change",generation:g,layout:null}));return}let S=i$1?e$1.version(i$1):null;if(i$1&&e$1.identity()!==i$1){A(),c.layout=null,H.close("document-replaced");return}!g||!S||(S!==c.version&&(c.version=S,x({type:"document-change",generation:g,version:S}),c.layout&&c.layout.version!==S&&(c.layout=null,x({type:"layout-change",generation:g,layout:null}))),i$1&&e$1.selection&&de.selectionChanged(e$1.selection(i$1)),i$1&&e$1.readOnly&&de.modeChanged(e$1.readOnly(i$1)));},_=()=>{if(!u||!i$1){l?.(),l=null;return}if(!l){c.version=("identity"in e$1?e$1.version(i$1):mt(i$1))??c.version,"identity"in e$1&&(c.selection=e$1.selection?e$1.selection(i$1):null,e$1.readOnly&&(c.readOnly=e$1.readOnly(i$1)));try{l="identity"in e$1?e$1.subscribe(i$1,T):i$1.onUpdate(T);}catch(g){console.error("[XlsxEditor] observing workbook changes for plugins failed",g);}}},A=()=>{l?.(),l=null,i$1=null;},N=(g,S)=>H.guard(g,"command-state",d=>Ii(S.getState?S.getState(d):Si),{enabled:false,disabledReason:n("plugin-unavailable",{translate:e$1.translate})}),z$1=async(g,S)=>{let d=await H.invoke(g,"command",E=>S.execute(E));if(d.ok)return Xi(d.value);let b=d.reason==="failed"?"command-failed":d.reason;return {ok:false,failure:n(b,{translate:e$1.translate})}},K=new WeakSet,ee=()=>{if(!(n$1||H.generation()===null))for(let g of V)H.fail(g,"edit-gate",new Error(Ei));},ie=()=>H.activations().filter(g=>!K.has(g.activation)&&(L(g).cellEditable!==void 0||L(g).beforeCellCommit!==void 0)),ge=g=>Object.freeze({pluginId:g.pluginId,get snapshot(){return re(g.pluginId,g.snapshot.generation)},get state(){return g.state},read:g.read}),ce=(g,S,d)=>{try{let b=S.get(g.activation);return b||(b=ge(g.context),S.set(g.activation,b)),d(b)}catch(b){return K.add(g.activation),queueMicrotask(()=>{H.activations().some(E=>E.activation===g.activation)&&H.fail(g.pluginId,"edit-gate",b);}),null}},de={setPlugins(g){let S=[];for(let d of g??[]){let b=la(d);if(b){S.push(b);continue}if(d!==null&&typeof d=="object"){if(X.has(d))continue;X.add(d);}q({pluginId:typeof d?.id=="string"?d.id:"",generation:H.generation(),phase:"definition",error:new TypeError("Plugins must be created with defineXlsxPlugin")});}u=S.length>0,_(),H.setPlugins(S),O=H.registered(),V=[...O.values()].filter(d=>d.cellEditable!==void 0||d.beforeCellCommit!==void 0).map(d=>d.id),ee();},setGrants:g=>H.setGrants(g),setReporter(g){o=g;},open(g){A(),i$1=g,c.version=("identity"in e$1?e$1.version(g):mt(g))??"",c.layout=null,c.selectionSettled=true,f="null",y=null,s=null,c.proposals=JSON.stringify({proposals:[],staleFor:{},version:null}),c.previewVersion=0,c.selection="identity"in e$1&&e$1.selection?e$1.selection(g):null,f=JSON.stringify(c.selection),"identity"in e$1&&e$1.readOnly&&(c.readOnly=e$1.readOnly(g)),_(),a+=1,H.open(`workbook-${a}`),ee(),r?.();},close(g){A(),c.layout=null,H.close(g),r?.();},generation:()=>H.generation(),version:()=>c.version,previewVersion:()=>c.previewVersion,proposalsChanged(g){if(c.proposals===g)return;c.proposals=g,c.previewVersion+=1;let S=H.generation();S&&x({type:"proposal-change",generation:S,version:c.version,previewVersion:c.previewVersion});},selectionChanged(g,S=JSON.stringify(g)){let d=S!==f;if(f=S,JSON.stringify(g)===JSON.stringify(c.selection))return d&&(m$1(),H.touch()),S;c.selection=g;let b=H.generation();return b&&x({type:"selection-change",generation:b,version:c.version,selection:g}),S},selectionUnsettled(g=H.generation()){!g||H.generation()!==g||!c.selectionSettled||(c.selectionSettled=false,m$1(),H.touch());},selectionSettled(g,S=H.generation()){if(!S||H.generation()!==S)return;let d=!c.selectionSettled;c.selectionSettled=true;let b=f;if(b===y){d&&H.touch();return}y=b,h=false,s={type:"selection-settle",generation:S,version:c.version,selection:structuredClone(c.selection),source:g},x(s);},focusChanged(g){if(g===c.focused)return;c.focused=g;let S=H.generation();S&&x({type:"focus-change",generation:S,focused:g});},setFocusCheck(g){r=g;},localeChanged(g){if(g===c.locale)return;c.locale=g;let S=H.generation();S&&x({type:"locale-change",generation:S,locale:g});},modeChanged(g){if(g===c.readOnly)return;c.readOnly=g;let S=H.generation();S&&x({type:"mode-change",generation:S,readOnly:g});},layoutChanged(g){let S=g&&g.version===c.version?g:null;if(Di(S,c.layout))return;c.layout=S;let d=H.generation();d&&x({type:"layout-change",generation:d,layout:S});},layoutId:()=>H.generation()===null?null:c.layout?.id??null,geometryChanged:()=>H.touch(),activations:()=>H.activations(),subscribe:g=>H.subscribe(g),commandStore(g){let S=v.get(g.activation);return S?Zt(B(),S):z},syncCommands(){let g=B();if(!g)return;let S=[],d=[],b=new Map,E=[];for(let C of H.activations()){let M=C.plugin;E.push(`${C.pluginId}:${P(M)}:${P(C.activation)}`);for(let G of M.commands??[]){let $=`plugin:${C.pluginId}/${G.id}`,U=[],te=g.hostPluginChords($);for(let J of te??[])b.set(J,$),U.push({chord:J,args:null});for(let J of te?[]:G.shortcuts??[]){let ne=i(J),le=g.shortcutOwner(ne),fe=le!==void 0?k(le)?le:m(ne)?"the grid":"a built-in command":m(ne)&&!g.releasedChord(ne)?"the grid":b.get(ne);if(!fe){b.set(ne,$),U.push({chord:J,args:null});continue}let ae=`${C.pluginId}\0${ne}`;j.has(ae)||(j.add(ae),q({pluginId:C.pluginId,generation:C.generation,phase:"definition",error:new Error(`Shortcut ${J} of ${$} is already used by ${fe}; it was not bound`)}));}S.push({descriptor:Object.freeze({id:$,label:G.label,mutatesDocument:G.mutatesDocument,shortcuts:Object.freeze(U)}),activationId:e(C.activation),state:()=>N(C.pluginId,G),execute:()=>z$1(C.pluginId,G)});}for(let G of M.toolbar??[])d.push(`plugin:${C.pluginId}/${G}`);}E.push(`shortcuts:${g.shortcutRevision()}`);let D=E.join("|");if(D===w){g.refresh();return}w=D,g.setPluginCommands(S,d);},guard:(g,S,d,b)=>H.guard(g,S,d,b),fail:(g,S,d)=>H.fail(g,S,d),gatesEdits:()=>H.generation()!==null&&(ie().length>0||de.editGateStarting()),editGateStarting(){if(!n$1||H.generation()===null)return false;for(let[g,S]of O){if(S.cellEditable===void 0&&S.beforeCellCommit===void 0)continue;let d=H.activationState(g);if(d==="loading"||d==="ready"&&!H.activations().some(b=>b.pluginId===g))return true}return false},openGate(){T();let g=new Map,S=ie();return {cellEditable(d){for(let b of S){let E=L(b).cellEditable;if(!E||K.has(b.activation))continue;if(ce(b,g,C=>{let M=E(C,{...d});if(typeof M!="boolean")throw new TypeError("cellEditable must return a boolean");return M})===false)return false}return true},beforeCellCommit(d){let b=d.input;for(let E of S){let D=L(E).beforeCellCommit;if(!D||K.has(E.activation))continue;let C={...d,input:b,kind:Ti(b)},M=ce(E,g,G=>Mi(D(G,C)));if(M?.action==="refuse")return {ok:false,message:M.message??null};M?.action==="replace"&&(b=M.input);}return {ok:true,input:b}}}},rowDecorations(){let g=[];for(let d of H.activations()){let b=L(d),E=b.rowDecorations;if(!E)continue;let D=d.context.state,C=I.get(d.activation);if(!C||C.definition!==b||C.hook!==E||C.state!==D||C.version!==c.version){let G=H.guard(d.pluginId,"row-decorations",$=>io(b.rowDecorations($)),null);C={definition:b,hook:E,state:D,version:c.version,value:G},I.set(d.activation,C);}let M=C.value;M&&M.version===c.version&&M.items.length&&g.push({pluginId:d.pluginId,key:d.key,activationId:e(d.activation),items:M.items});}return g.length===F.length&&g.every((d,b)=>d.key===F[b].key&&d.items===F[b].items)||(F=Object.freeze(g)),F},activateRowDecoration({pluginId:g,key:S,item:d}){let b=de.rowDecorations().find(C=>C.key===S&&C.pluginId===g)?.items.find(C=>C.id===d.id);if(!b||b.sheetId!==d.sheetId||b.row!==d.row)return;let E=H.activations().find(C=>C.key===S),D=E&&L(E);!E||!D?.onEvent||H.invoke(g,"event",C=>D.onEvent(C,{type:"row-decoration-activate",generation:E.generation,id:d.id,sheetId:d.sheetId,row:d.row}));}};return de}function nu(e,t,n,o={width:0,height:0}){let r=(i,l,u,a,f)=>{if(a===0)return 0;let p=l?l.filter(y=>y<a).length:Math.max(0,a-u);return i?.[p]??f};return {width:r(e?.colOffsets,e?.colIndices,e?.startCol??0,n,o.width),height:r(e?.rowOffsets,e?.rowIndices,e?.startRow??0,t,o.height)}}function ou(e){let t=e.rowOffsets.length-1,n=e.colOffsets.length-1;return t<=0||n<=0?null:{top:e.rowIndices?.[0]??e.startRow,left:e.colIndices?.[0]??e.startCol,bottom:e.rowIndices?.[t-1]??e.startRow+t-1,right:e.colIndices?.[n-1]??e.startCol+n-1}}var So=new WeakMap,Io=0;function Oi(e){let t=So.get(e);return t||(Io+=1,t=`grid-layout-${Io}`,So.set(e,t)),t}function Xo(e,t){if(!e||t===null||e.version!==t)return null;let{x:n,y:o,width:r,height:i}=e.viewport;return {id:Oi(e),version:t,sheetId:e.sheetId,zoom:e.zoom,viewport:{x:n,y:o,width:r,height:i}}}function Je(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function Hi(e,t,n){let o=Math.max(0,t.x),r=Math.max(0,t.y),i=Math.min(e.frame.width,t.x+t.w),l=Math.min(e.frame.height,t.y+t.h);return i>o&&l>r?{x:n.x+o*e.zoom,y:n.y+r*e.zoom,width:(i-o)*e.zoom,height:(l-r)*e.zoom}:null}function Qt(e,t){let n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return {x:n.left-o.left-t.clientLeft+t.scrollLeft,y:n.top-o.top-t.clientTop+t.scrollTop}}function Mo(e,t,n,o,r,i=()=>({proposals:[],sheetIndex:-1,previewVersion:0}),l,u=()=>null){let a=p=>p?Hi(t,p,Qt(n,o)):null,f={layout:e,readAnchorGeometries:async p=>p.map(y=>f.getAnchorGeometry(y)),getAnchorGeometry(p){let y=(O,L)=>({ok:false,failure:{code:O,message:L}});if(!r())return y("layout-unavailable","The layout is no longer painted");if(p.kind==="selection"){let O=u();if(!O?.cells||O.chartId)return y("missing-target","No cell selection is available");if(O.sheetId!==e.sheetId)return y("layout-unavailable","The selected sheet is not painted");let L=f.getRangeRect({sheetId:O.sheetId,range:normalizeRange(O.cells)});if(!L)return y("layout-unavailable","The selection is outside the painted grid");let F;try{F=i();}catch{return y("read-failed","The proposals could not be read")}return F?{ok:true,version:e.version,previewVersion:F.previewVersion,layoutId:e.id,rects:[L],anchor:L,pageRect:{...Qt(n,o),width:t.frame.width*t.zoom,height:t.frame.height*t.zoom}}:y("layout-unavailable","The selection layout is being refreshed")}let s;try{s=i();}catch{return y("read-failed","The proposals could not be read")}if(!s)return y("pending","The proposals are being refreshed");let{proposals:h,sheetIndex:m,previewVersion:w}=s,c=h.find(O=>O.id===p.id);if(!c)return y("unknown-proposal","The proposal is not registered in this document");let v=c.cells.flatMap(O=>{if(O.sheet!==m)return [];let L=a(cellRect(t.frame.grid,O.row,O.col));return L?[L]:[]});if(!v.length)return y("missing-target","The proposal has no visible cells on this sheet");let R=1/0,k=1/0,P=-1/0,X=-1/0;for(let O of v)R=Math.min(R,O.x),k=Math.min(k,O.y),P=Math.max(P,O.x+O.width),X=Math.max(X,O.y+O.height);let I=Qt(n,o);return {ok:true,version:e.version,previewVersion:w,layoutId:e.id,rects:v,anchor:{x:R,y:k,width:P-R,height:X-k},pageRect:{...I,width:t.frame.width*t.zoom,height:t.frame.height*t.zoom}}},getCellRect(p){return !r()||p?.sheetId!==e.sheetId||!Je(p.row)||!Je(p.col)?null:a(cellRect(t.frame.grid,p.row,p.col))},getRangeRect(p){if(!r()||p?.sheetId!==e.sheetId)return null;let y=p.range;return !y||![y.top,y.left,y.bottom,y.right].every(Je)||y.top>y.bottom||y.left>y.right?null:a(rangeRect(t.frame.grid,y))},getPositionAtPoint:l?(p,y)=>{if(!r())return null;let s=l(p,y);return !s||s.sheet!==t.sheet||!Je(s.row)||!Je(s.col)?null:{sheet:s.sheet,sheetId:e.sheetId,row:s.row,col:s.col,version:e.version,layoutId:e.id}}:null};return f}var Do=Object.freeze([]),Ni=Object.freeze([]),Gi=1500;function Ao(e,t){let n=e.proposals??[];return JSON.stringify({proposals:n,staleFor:e.staleFor??{},version:n.length?t:null})}function fu(e){let t=useRef(e);t.current=e;let n=useRef(null),o=useRef(null),r=useRef(null),[i]=useState(()=>{let I=new Set;return {get:()=>o.current,subscribe(O){return I.add(O),()=>{I.delete(O);}},emit(){for(let O of [...I])O();}}}),[l]=useState(()=>ko({...e.access,translate:I=>t.current.t(I),geometry:()=>n.current},e.createClients,{editGate:e.editGate})),u=useRef(null),a=useRef(null),f=useRef(null),p=(e.plugins?.length??0)>0;useEffect(()=>{if(!p||!e.handle)return;let I=l.generation(),O,L=null,F=false,j=()=>{L!==null&&clearTimeout(L),L=null;},V=B=>{j(),O=void 0,l.selectionSettled(B,I);},q=go({root:()=>t.current.focusRoot?.current??null,canSettle:()=>{let B=u.current?.sheetIndex;return B===void 0||F||(O??(O=t.current.selectionPaintReady?.(B)??(()=>true)),O())?true:(L===null&&(L=setTimeout(()=>{L=null,F=true,a.current!==null&&q.notifySelectionChange(a.current);},Gi)),false)},onUnsettle:()=>{j(),O=void 0,F=false,I=l.generation(),l.selectionUnsettled(I);},onSettle:V,onResettle:V});return f.current=q,()=>{j(),q.dispose(),f.current=null;}},[l,p,e.handle]);let y=a$2(e.locale);useLayoutEffect(()=>{l.localeChanged(y);},[l,y]),useLayoutEffect(()=>{if(!p)return;let I=ho(()=>t.current.focusRoot?.current?[t.current.focusRoot.current]:[],O=>l.focusChanged(O));return l.setFocusCheck(I.recheck),()=>{l.setFocusCheck(null),I();}},[l,p]);let s=useCallback(()=>{let I=o.current,O=t.current.canvasRef.current,L=r.current,j=(t.current.plugins?.length??0)>0&&l.generation()!==null?Xo(I,l.version()):null,V=t.current.positionAtPoint?(B,W)=>t.current.positionAtPoint?.(B,W)??null:void 0,q=()=>{let B=t.current;return B.proposalsPending?.()||!B.selection||B.selection.sheetId!==j?.sheetId?null:{proposals:B.proposals??[],sheetIndex:B.selection.sheetIndex,previewVersion:l.previewVersion()}};n.current=j&&I&&O&&L?"identity"in t.current.access?t.current.createGeometry?.(j,I,O,L,()=>{let B=t.current.access,W=l.layoutId()===j.id&&O.isConnected&&L.isConnected;if(!("identity"in B))return {version:null,painted:null};let Y=B.identity();return {version:Y?B.version(Y):null,painted:W?o.current:null}},q,V,()=>u.current)??null:Mo(j,I,O,L,()=>l.layoutId()===j.id&&o.current===I&&O.isConnected&&L.isConnected,q,V,()=>u.current):null,l.layoutChanged(j),l.geometryChanged();},[l]);useLayoutEffect(()=>{l.setReporter(e.onPluginError);}),useLayoutEffect(()=>{"identity"in e.access||l.modeChanged(e.readOnly);},[l,e.readOnly]),useLayoutEffect(()=>{l.setGrants(e.pluginGrants);}),useLayoutEffect(()=>{l.setPlugins(e.plugins);},[l,e.plugins]),useEffect(()=>()=>l.close("unmounted"),[l]),useEffect(()=>{if(!e.handle)return;let I=e.access;if(("identity"in I?I.identity():I.handle())===e.handle)return l.open(e.handle),l.proposalsChanged(Ao(t.current,l.version())),s(),()=>l.close("document-replaced")},[l,e.access,e.handle,s]),useEffect(()=>{l.syncCommands();let I=l.subscribe(()=>l.syncCommands()),O=e.commands.subscribeShortcuts(()=>l.syncCommands());return ()=>{I(),O();}},[l,e.commands]);let h=Ao(e,l.version());useLayoutEffect(()=>{e.handle&&l.generation()&&l.proposalsChanged(h);},[l,e.handle,h]);let m=useSyncExternalStore(l.subscribe,l.activations,()=>Do),w=p&&m.length?l.rowDecorations():Ni,c=e.selection?.sheetId??null,v=e.t,R=useMemo(()=>lo(w,c,I=>v("a11y.rowHeaderLabel",{row:I+1})),[w,c,v]);useEffect(()=>{if(p){u.current=e.selection;let I=l.selectionChanged(e.selection);a.current=I,f.current?.notifySelectionChange(I);}},[l,p,e.handle,e.selection]),useEffect(()=>{s();},[p,s]);let k=useCallback(I=>{o.current=I,(!I||(t.current.plugins?.length??0)>0)&&s(),i.emit(),I&&a.current!==null&&f.current?.notifySelectionChange(a.current);},[i,s]),P=useCallback(I=>{r.current=I,s();},[s]),X=useCallback(()=>{k(null),l.close("document-replaced");},[l,k]);return {host:l,managed:p,activations:p?m:Do,overlayLayerRef:P,beginLoad:X,presentGrid:k,rowGutter:R,painted:i}}function mu({children:e}){return e==null||typeof e=="boolean"||e===""?null:jsx("div",{"data-testid":"xlsx-loading",role:"status",style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",pointerEvents:"none"},children:e})}var ke=24,Ee=44,Lo=9,Oo=10,Ho="#8a8a8a",ht=2,Ki=4,Qe=4,Bi=6,Wo=7,$o=5,ji=255*Wo+$o,Ui=409.5*4/3;function wu(e){return Math.max(0,(e-$o)/Wo)}function vu(e){return Math.max(0,e*3/4)}function zo(e,t){for(let n of e)if(t>=n.offset&&t<n.offset+n.size)return n;return null}function Vi(e,t,n=1){let o=Qe/(n||1);for(let r=0;r<e.length-1;r+=1){let i=e[r].offset+e[r].size;if(Math.abs(t-i)<=o)return e[r]}return null}function qi(e,t){let n=e==="col"?ji:Ui;return Math.min(Math.max(t,0),n)}function Yi(e,t,n){let o=false;return e.map(r=>r.index===t?(o=true,{...r,size:Math.max(0,r.size+n)}):o?{...r,offset:r.offset+n}:r)}function _o(e,t){if(!e)return [];let n=t==="col"?e.colOffsets:e.rowOffsets,o=t==="col"?e.colIndices:e.rowIndices,r=t==="col"?e.colSizes:e.rowSizes,i=t==="col"?e.startCol:e.startRow,l=[];for(let u=0;u<n.length-1;u+=1){let a=r?.[u]??n[u+1]-n[u];a<=0||l.push({index:o?.[u]??i+u,offset:n[u],size:a});}return l}function xt(e){return e.map(t=>`${t.index}:${t.offset}:${t.size}`).join("|")}function Ji(e,t,n){let o=t==="col"?e?.hiddenColSpans:e?.hiddenRowSpans;if(!o||o.length===0)return [];let r=t==="col"?e?.frozenCols??0:e?.frozenRows??0,i=n.findIndex(u=>u.index>=r);if(i<0)return [];let l=[];for(let[u,a]of o){if(a<n[i].index||!n.some(y=>y.index<u))continue;let f=n.findIndex(y=>y.index>a);if(f<=0)continue;let p=l.find(y=>y.position===f);p?(p.start=Math.min(p.start,u),p.end=Math.max(p.end,a)):l.push({position:f,start:u,end:a});}return l}function No(e,t,n){return Ji(e,t,n).map(o=>o.position)}function Zi(e,t){let n=0;for(let o of e)o.offset+o.size/2<t&&(n+=1);return n}function Ko(e,t,n){return n?(e==="col"?n.top===0&&n.bottom===1048575:n.left===0&&n.right===16383)?e==="col"?{from:n.left,to:n.right}:{from:n.top,to:n.bottom}:{from:t,to:t}:{from:t,to:t}}function Qi(e,t,n){let o=Ko(e,t,n);if(!(!n||o.from===t&&o.to===t)&&!(t<o.from||t>o.to))return {at:o.from,count:o.to-o.from+1}}function el(e,t,n){if(!n)return false;let o=n.top===0&&n.bottom===1048575,r=n.left===0&&n.right===16383;return e==="col"?!r&&n.left<=t&&t<=n.right:!o&&n.top<=t&&t<=n.bottom}function tn(e,t,n){return n?e==="col"?n.top===0&&n.bottom===1048575&&n.left<=t&&t<=n.right:n.left===0&&n.right===16383&&n.top<=t&&t<=n.bottom:false}var nn={background:"#f8f9fa",color:"#5f6368",font:"11px/1 ui-sans-serif, system-ui, sans-serif",userSelect:"none"},Go={position:"absolute",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",whiteSpace:"nowrap"},Fo=(e,t,n)=>e==="col"?{position:"absolute",left:Math.round(t*n)-ht/2,top:0,width:ht,height:ke,background:Ho,pointerEvents:"none",zIndex:1}:{position:"absolute",left:0,top:Math.round(t*n)-ht/2,width:Ee,height:ht,background:Ho,pointerEvents:"none",zIndex:1};function Cu({frame:e,zoom:t,leadingInset:n=0,headerHandlers:o,selection:r,sheet:i,selectAllLabel:l,showSheetHeaders:u=false,children:a}){let f=e?.grid,p=_o(f,"col"),y=_o(f,"row"),s=f?.dividerX,h=f?.dividerY,m=useRef({frame:e??null,sheet:i??null});m.current={frame:e??null,sheet:i??null};let w=useRef({col:p,row:y});w.current={col:p,row:y};let c=useCallback(d=>{let b=m.current;return d.sheet===null?b.frame===d.frame:b.sheet===d.sheet&&xt(w.current[d.axis])===d.tracks},[]),v=useRef(null),R=useRef(null),k=useRef(null),[P,X]=useState(null),[I,O]=useState(null),[L,F]=useState(null),j=r?normalizeRange(r):null,V=(d,b)=>P?.axis===d?Yi(b,P.index,P.size-P.startSize):b,q=useCallback(d=>{let b=v.current;b&&(v.current=null,X(null),b.host.hasPointerCapture?.(b.pointerId)&&b.host.releasePointerCapture(b.pointerId),!(!d||!b.moved||!b.host.isConnected)&&c(b)&&o?.onHeaderResize?.(b.axis,b.index,qi(b.axis,b.size),b.run));},[o,c]),B=useCallback(d=>{let b=R.current;if(!b)return;if(R.current=null,O(null),b.host.hasPointerCapture?.(b.pointerId)&&b.host.releasePointerCapture(b.pointerId),b.gap===null){d&&b.press&&c(b)&&o?.onHeaderMouseDown?.(b.axis,b.press.index,b.press.event);return}if(!d||!c(b))return;let E=w.current[b.axis==="col"?"col":"row"];if(E.length===0)return;let D=b.gap<E.length?E[b.gap].index:E[E.length-1].index+1,C=b.run.from,M=b.run.to-b.run.from+1;C<=D&&D<=C+M||o?.onHeaderReorder?.(b.axis,C,D,M);},[o,c]),W=useCallback(()=>{let d=k.current;d&&(k.current=null,d.host.hasPointerCapture?.(d.pointerId)&&d.host.releasePointerCapture(d.pointerId));},[]);useEffect(()=>{let d=E=>{let D=v.current;D&&E.pointerId===D.pointerId&&q(true);let C=R.current;C&&E.pointerId===C.pointerId&&B(true);let M=k.current;M&&E.pointerId===M.pointerId&&W();},b=()=>{q(false),B(false),W();};return window.addEventListener("pointerup",d),window.addEventListener("pointercancel",b),()=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",b);}},[q,B,W]);let Y=useCallback((d,b,E)=>{if(o?.onHeaderPress?.(),E.button!==0)return;let D=E.currentTarget,C=D.getBoundingClientRect(),M=(d==="col"?E.clientX-C.left:E.clientY-C.top)/t,G=o?.onHeaderResize?Vi(b,M,t):null;if(G){E.preventDefault(),E.stopPropagation(),v.current={...m.current,tracks:xt(b),axis:d,index:G.index,size:G.size,run:Qi(d,G.index,j),host:D,pointerId:E.pointerId,start:d==="col"?E.clientX:E.clientY,startSize:G.size,moved:false},D.setPointerCapture&&D.setPointerCapture(E.pointerId);return}let $=zo(b,M);if(!$)return;if(!(E.shiftKey||E.metaKey||E.ctrlKey)&&o?.onHeaderReorder&&tn(d,$.index,j)){E.stopPropagation(),R.current={...m.current,tracks:xt(b),axis:d,fromIndex:$.index,run:Ko(d,$.index,j),host:D,pointerId:E.pointerId,start:d==="col"?E.clientX:E.clientY,gap:null,press:null},D.setPointerCapture&&D.setPointerCapture(E.pointerId);return}o?.onHeaderDragSelect&&(E.stopPropagation(),k.current={...m.current,tracks:xt(b),axis:d,host:D,pointerId:E.pointerId,index:$.index},D.setPointerCapture&&D.setPointerCapture(E.pointerId));},[o,j,t]),re=useCallback((d,b,E)=>{let D=v.current;if(D&&D.axis===d){let te=d==="col"?E.clientX:E.clientY;if(!D.moved&&Math.abs(te-D.start)<Ki)return;D.moved=true,D.size=D.startSize+(te-D.start)/t,X({axis:d,index:D.index,size:D.size,startSize:D.startSize});return}let C=R.current;if(C&&C.axis===d){if(!c(C)){B(false);return}if(b.findIndex(le=>le.index===C.fromIndex)<0){B(false);return}let te=d==="col"?E.clientX:E.clientY;if(C.gap===null&&Math.abs(te-C.start)<Bi)return;let J=C.host.getBoundingClientRect(),ne=d==="col"?E.clientX-J.left:E.clientY-J.top;C.gap=Zi(b,ne/t),O({axis:d,gap:C.gap,fromIndex:C.fromIndex,runFrom:C.run.from,runTo:C.run.to,pointer:ne});return}let M=k.current;if(!M||M.axis!==d)return;if(!c(M)){W();return}let G=M.host.getBoundingClientRect(),$=d==="col"?E.clientX-G.left:E.clientY-G.top,U=zo(b,$/t);!U||U.index===M.index||(M.index=U.index,o?.onHeaderDragSelect?.(d,U.index));},[B,W,o,c,t]),H=useCallback((d,b)=>{let E=v.current;E&&E.axis===d&&b.pointerId===E.pointerId&&q(true);let D=R.current;D&&D.axis===d&&b.pointerId===D.pointerId&&B(true);let C=k.current;C&&C.axis===d&&b.pointerId===C.pointerId&&W();},[q,B,W]),x=(d,b)=>{let E=o?.onHeaderMouseDown;return {onPointerEnter:()=>F({axis:d,index:b}),onPointerLeave:()=>F(D=>D?.axis===d&&D.index===b?null:D),onMouseDown:E?D=>{let C=R.current;if(C){C.press||(C.press={index:b,event:D});return}E(d,b,D);}:void 0}},T=(d,b)=>{let E=No(f,d,b);return b.map((D,C)=>{if(E.includes(C+1))return null;let M=Math.round((D.offset+D.size)*t)-1;return jsx("span",{"aria-hidden":true,"data-track-divider":true,style:d==="col"?{position:"absolute",left:M,top:0,width:1,height:ke,background:"#e0e0e0",pointerEvents:"none"}:{position:"absolute",left:0,top:M,width:Ee,height:1,background:"#e0e0e0",pointerEvents:"none"}},`${d}:divider:${D.index}`)})},_=(d,b)=>No(f,d,b).flatMap(E=>{let D=Math.round(b[E].offset*t);return [-1,1].map(C=>jsx("span",{"aria-hidden":true,"data-testid":"xlsx-hidden-divider","data-axis":d,style:d==="col"?{position:"absolute",left:D+C*2,top:0,width:1,height:ke,background:"#9aa0a6",pointerEvents:"none"}:{position:"absolute",left:0,top:D+C*2,width:Ee,height:1,background:"#9aa0a6",pointerEvents:"none"}},`${d}:hidden:${b[E].index}:${C}`))}),A=(d,b)=>b.filter(E=>tn(d,E.index,j)).map(E=>jsx("span",{"aria-hidden":true,"data-testid":"xlsx-header-underline","data-axis":d,style:d==="col"?{position:"absolute",left:E.offset*t,bottom:0,width:E.size*t,height:2,background:"#9aa0a6",pointerEvents:"none",zIndex:2}:{position:"absolute",top:E.offset*t,right:0,height:E.size*t,width:2,background:"#9aa0a6",pointerEvents:"none",zIndex:2}},`${d}:underline:${E.index}`)),N=(d,b)=>{if(!o?.onHeaderResize)return null;let E=d==="col";return b.slice(0,-1).map(D=>jsx("div",{"data-resize-axis":d,"data-resize-index":D.index,"aria-hidden":true,style:E?{position:"absolute",left:(D.offset+D.size)*t-Qe,top:Lo,width:Qe*2,height:ke-Lo,cursor:"col-resize"}:{position:"absolute",left:Oo,top:(D.offset+D.size)*t-Qe,width:Ee-Oo,height:Qe*2,cursor:"row-resize"}},`${d}:${D.index}`))},z=d=>{let b=d.currentTarget.parentElement?.querySelector('[data-testid="xlsx-scroll"]');b&&(b.scrollTop+=d.deltaY,b.scrollLeft+=d.deltaX);},K=d=>{if(!P||P.axis!==d)return null;let b=V(d,d==="col"?p:y).find(E=>E.index===P.index);return b?Math.round((b.offset+b.size)*t):null},ee=d=>{if(I?.axis!==d)return null;let b=V(d,d==="col"?p:y),E=I.gap>0?b[I.gap-1]:null;return E?Math.round((E.offset+E.size)*t):0},ie=(d,b,E)=>{let D=tn(d,b,j),C=!D&&el(d,b,j),M=L?.axis===d&&L.index===b,G=I?.axis===d?I:null,$=G!==null&&G.runFrom<=b&&b<=G.runTo,U=G&&$?(d==="col"?p:y).find(J=>J.index===G.fromIndex):void 0,te=G&&U?G.pointer-(U.offset+U.size/2)*t:0;return {...E,backgroundColor:$?"#ffffff":D?"#e3e7ea":M?"#f1f3f4":C?"#eceff1":void 0,fontWeight:D||$?600:void 0,color:D||$?"#3c4043":void 0,zIndex:$?3:void 0,transform:$?`translate${d==="col"?"X":"Y"}(${te}px)`:void 0,cursor:$?"grabbing":void 0}},ge=(d,b)=>o?.onHeaderResize||o?.onHeaderReorder||o?.onHeaderDragSelect||o?.onHeaderPress?{onPointerDown:E=>Y(d,b,E),onPointerMove:E=>re(d,b,E),onPointerUp:E=>H(d,E),onPointerCancel:()=>{v.current?.axis===d&&q(false),R.current?.axis===d&&B(false),k.current?.axis===d&&W();}}:{},ce=K("col"),de=K("row"),g=ee("col"),S=ee("row");return u?jsxs("div",{"data-testid":"xlsx-grid",style:{display:"grid",gridTemplateColumns:`${Ee}px minmax(0, 1fr)`,gridTemplateRows:`${ke}px minmax(0, 1fr)`,flex:1,minWidth:0,minHeight:0,marginLeft:n===0?void 0:n},children:[jsx("div",{"data-testid":"xlsx-grid-corner","aria-hidden":o?.onSelectAll?void 0:true,role:o?.onSelectAll?"button":void 0,title:o?.onSelectAll?l:void 0,"aria-label":o?.onSelectAll?l:void 0,onPointerDown:o?.onSelectAll?d=>{d.stopPropagation(),o.onHeaderPress?.();}:void 0,onMouseDown:o?.onSelectAll?d=>{d.stopPropagation();}:void 0,onClick:o?.onSelectAll?()=>o.onSelectAll?.():void 0,style:{...nn,gridColumn:1,gridRow:1,position:"relative",borderRight:"1px solid #e0e0e0",borderBottom:"1px solid #e0e0e0",cursor:o?.onSelectAll?"pointer":void 0},children:o?.onSelectAll&&jsx("span",{"aria-hidden":true,style:{position:"absolute",right:5,bottom:4,width:0,height:0,borderTop:"4px solid transparent",borderLeft:"4px solid transparent",borderRight:"4px solid #70757a",borderBottom:"4px solid #70757a"}})}),jsxs("div",{"data-testid":"xlsx-column-headers","aria-hidden":true,style:{...nn,gridColumn:2,gridRow:1,position:"relative",overflow:"hidden"},onWheel:z,...ge("col",p),children:[V("col",p).map(d=>jsx("div",{"data-col":d.index,...x("col",d.index),style:ie("col",d.index,{...Go,left:d.offset*t,top:0,width:d.size*t,height:ke}),children:d.size*t>=12?Ge(d.index):null},d.index)),T("col",V("col",p)),_("col",V("col",p)),s!==void 0&&jsx("div",{"data-testid":"xlsx-freeze-divider","data-axis":"col","aria-hidden":true,style:Fo("col",s,t)}),N("col",p),ce!==null&&jsx("div",{"data-testid":"xlsx-resize-guide","aria-hidden":true,style:{position:"absolute",left:ce,top:0,width:1,height:ke,background:"#5f6368",pointerEvents:"none"}}),g!==null&&jsx("div",{"data-testid":"xlsx-reorder-guide","aria-hidden":true,style:{position:"absolute",left:g,top:0,width:2,height:ke,background:"#5f6368",pointerEvents:"none",zIndex:4}}),jsx("span",{"aria-hidden":true,"data-testid":"xlsx-header-edge","data-axis":"col",style:{position:"absolute",left:0,right:0,bottom:0,height:1,background:"#e0e0e0",pointerEvents:"none"}}),A("col",V("col",p))]}),jsxs("div",{"data-testid":"xlsx-row-headers","aria-hidden":true,style:{...nn,gridColumn:1,gridRow:2,position:"relative",overflow:"hidden"},onWheel:z,...ge("row",y),children:[V("row",y).map(d=>jsx("div",{"data-row":d.index,...x("row",d.index),style:ie("row",d.index,{...Go,left:0,top:d.offset*t,width:Ee,height:d.size*t}),children:d.size*t>=10?d.index+1:null},d.index)),T("row",V("row",y)),_("row",V("row",y)),h!==void 0&&jsx("div",{"data-testid":"xlsx-freeze-divider","data-axis":"row","aria-hidden":true,style:Fo("row",h,t)}),N("row",y),de!==null&&jsx("div",{"data-testid":"xlsx-resize-guide","aria-hidden":true,style:{position:"absolute",left:0,top:de,width:Ee,height:1,background:"#5f6368",pointerEvents:"none"}}),S!==null&&jsx("div",{"data-testid":"xlsx-reorder-guide","aria-hidden":true,style:{position:"absolute",left:0,top:S,width:Ee,height:2,background:"#5f6368",pointerEvents:"none",zIndex:4}}),jsx("span",{"aria-hidden":true,"data-testid":"xlsx-header-edge","data-axis":"row",style:{position:"absolute",left:"auto",right:0,top:0,bottom:0,width:1,background:"#e0e0e0",pointerEvents:"none"}}),A("row",V("row",y))]}),jsx("div",{style:{gridColumn:2,gridRow:2,position:"relative",display:"flex",flexDirection:"column",minWidth:0,minHeight:0},children:a})]}):jsx(Fragment,{children:a})}var ku="rgba(33, 115, 70, 0.12)",Eu="#217346";function Bo(e,t=1){let n=Math.round(e.x),o=Math.round(e.y),r=Math.round(e.x+e.w),i=Math.round(e.y+e.h),l=Math.max(0,r-n),u=Math.max(0,i-o);if(t%2===1)return {left:n,top:o,width:l,height:u,inset:{x:n,y:o,w:l,h:u}};let a=t/2;return {left:n-a,top:o-a,width:l+2*a,height:u+2*a,inset:{x:n,y:o,w:l,h:u}}}function Su(e,t){let n=Bo(e).inset;if(!t||n.w===0||n.h===0)return n.w&&n.h?[n]:[];let o=Bo(t).inset,r=n.x+n.w,i=n.y+n.h,l=o.x+o.w,u=o.y+o.h,a={x:Math.max(n.x,o.x),y:Math.max(n.y,o.y),w:Math.max(0,Math.min(r,l)-Math.max(n.x,o.x)),h:Math.max(0,Math.min(i,u)-Math.max(n.y,o.y))};return a.w===0||a.h===0?[n]:[{x:n.x,y:n.y,w:n.w,h:a.y-n.y},{x:n.x,y:a.y+a.h,w:n.w,h:i-(a.y+a.h)},{x:n.x,y:a.y,w:a.x-n.x,h:a.h},{x:a.x+a.w,y:a.y,w:r-(a.x+a.w),h:a.h}].filter(p=>p.w>0&&p.h>0)}var bt=8,nl={nw:"a11y.chartResizeNw",n:"a11y.chartResizeN",ne:"a11y.chartResizeNe",e:"a11y.chartResizeE",se:"a11y.chartResizeSe",s:"a11y.chartResizeS",sw:"a11y.chartResizeSw",w:"a11y.chartResizeW"};function ol(e){return {horizontal:e==="nw"||e==="w"||e==="sw"||e==="ne"||e==="e"||e==="se",vertical:e==="nw"||e==="n"||e==="ne"||e==="sw"||e==="s"||e==="se"}}var rl={position:"absolute",width:bt,height:bt,marginLeft:-bt/2,marginTop:-bt/2,boxSizing:"border-box",border:"1px solid #217346",background:"#ffffff",pointerEvents:"auto",touchAction:"none"};function Tu({rect:e,onStart:t,onNudge:n}){let{t:o}=c();return jsx(Fragment,{children:Wn.map(r=>{let i=ol(r.handle),l=[i.horizontal?"ArrowLeft ArrowRight":null,i.vertical?"ArrowUp ArrowDown":null].filter(Boolean).join(" "),u=i.horizontal&&i.vertical?"a11y.chartResizeHintBoth":i.horizontal?"a11y.chartResizeHintHorizontal":"a11y.chartResizeHintVertical",a=o(nl[r.handle]);return jsx("button",{type:"button","data-testid":"xlsx-chart-resize-handle","data-handle":r.handle,"aria-label":a,"aria-keyshortcuts":l,title:o(u,{label:a}),onPointerDown:f=>t(r.handle,f),onMouseDown:f=>f.stopPropagation(),onKeyDown:f=>{if(f.key!=="ArrowLeft"&&f.key!=="ArrowRight"&&f.key!=="ArrowUp"&&f.key!=="ArrowDown")return;f.preventDefault(),f.stopPropagation();let p=f.shiftKey?10:1,y=(f.key==="ArrowRight"?p:f.key==="ArrowLeft"?-p:0)*(i.horizontal?1:0),s=(f.key==="ArrowDown"?p:f.key==="ArrowUp"?-p:0)*(i.vertical?1:0);y===0&&s===0||n(r.handle,y,s);},style:{...rl,left:e.x+e.w*r.x,top:e.y+e.h*r.y,cursor:r.cursor,padding:0}},r.handle)})})}var Yo=8,Uo=Yo/2;function cl(e){return {left:e.x+e.w-Uo,top:e.y+e.h-Uo,size:Yo}}function Ou(e,t){return t??e}function Vo(e,t){return {top:e.top,left:e.left,bottom:Math.max(e.bottom,t.row),right:Math.max(e.right,t.col)}}function Hu({rect:e,source:t,rectForRange:n,cellAt:o,onFill:r,ariaLabel:i}){let[l,u]=useState(null),a=useRef(null);a.current=l;let f=useCallback(()=>{a.current=null,u(null);},[]),p=l!==null;useEffect(()=>{if(!p)return;let P=X=>{X.key==="Escape"&&(X.preventDefault(),X.stopPropagation(),f());};return window.addEventListener("keydown",P,true),()=>window.removeEventListener("keydown",P,true)},[p,f]);let y=l?Vo(t,l.endpoint):null,s=y&&(y.bottom>t.bottom||y.right>t.right)?n(y):null,h=P=>{if(P.button!==0)return;P.preventDefault(),P.stopPropagation();try{P.currentTarget.setPointerCapture?.(P.pointerId);}catch{}let X={pointerId:P.pointerId,endpoint:{row:t.bottom,col:t.right},startX:P.clientX,startY:P.clientY,moved:false};a.current=X,u(X);},m=P=>{let X=a.current;if(!X||P.pointerId!==X.pointerId)return;P.preventDefault(),P.stopPropagation();let I=o(P.clientX,P.clientY);if(!I)return;let O=X.moved||P.clientX!==X.startX||P.clientY!==X.startY,L={...X,endpoint:I,moved:O};a.current=L,u(L);},w=P=>{let X=a.current;if(!X||P.pointerId!==X.pointerId)return;P.preventDefault(),P.stopPropagation();let I=o(P.clientX,P.clientY)??X.endpoint;a.current=null,u(null);try{P.currentTarget.releasePointerCapture?.(P.pointerId);}catch{}let O=X.moved||P.clientX!==X.startX||P.clientY!==X.startY,L=Vo(t,I);O&&(L.bottom>t.bottom||L.right>t.right)&&r(t,L);},c=P=>{!a.current||P.pointerId!==a.current.pointerId||(P.preventDefault(),P.stopPropagation(),f());},v=cl(e),R={position:"absolute",left:v.left,top:v.top,width:v.size,height:v.size,boxSizing:"border-box",background:"#217346",border:"1px solid #ffffff",cursor:"crosshair",pointerEvents:"auto",touchAction:"none"},k=s?{position:"absolute",left:s.x,top:s.y,width:s.w,height:s.h,boxSizing:"border-box",border:"1px dashed #217346",background:"rgba(33, 115, 70, 0.06)",pointerEvents:"none"}:null;return jsxs(Fragment,{children:[k&&jsx("div",{"data-testid":"xlsx-fill-preview","aria-hidden":true,style:k}),jsx("div",{"data-testid":"xlsx-fill-handle",role:"button",tabIndex:-1,"aria-label":i,onPointerDown:h,onPointerMove:m,onPointerUp:w,onPointerCancel:c,onLostPointerCapture:c,onMouseDown:P=>{P.preventDefault(),P.stopPropagation();},onMouseMove:P=>{a.current&&P.stopPropagation();},onClick:P=>P.stopPropagation(),onDoubleClick:P=>P.stopPropagation(),style:R})]})}var Jo=["#0B57D0","#B3261E","#146C2E","#6B4EFF","#8E24AA","#00639B","#8E4E00","#7D5260"];function rn(e,t){if(typeof e!="string"||!/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(e))return Jo[t%Jo.length];let n=e.slice(1).toUpperCase();return n.length===6?`#${n}`:`#${n[0]}${n[0]}${n[1]}${n[1]}${n[2]}${n[2]}`}function Zo(e,t,n=1048576,o=16384){let r=t.indexOf(e.sheet);return r<0||n<1||o<1||[e.anchor,e.head].some(({row:l,col:u})=>!Number.isSafeInteger(l)||!Number.isSafeInteger(u)||l<0||u<0||l>=n||u>=o)?null:{sheetIndex:r,range:{top:Math.min(e.anchor.row,e.head.row),left:Math.min(e.anchor.col,e.head.col),bottom:Math.max(e.anchor.row,e.head.row),right:Math.max(e.anchor.col,e.head.col)}}}var xl=8,bl=32;function yl(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(n=>n[0]).join("").toUpperCase()}function wl(e){let t=Number.parseInt(e.slice(1,3),16),n=Number.parseInt(e.slice(3,5),16),o=Number.parseInt(e.slice(5,7),16);return `rgba(${t}, ${n}, ${o}, 0.1)`}function vl(e){let[t,n]=useState(()=>Date.now());return useEffect(()=>{let o=Date.now();n(o);let r=e.map(u=>u.cursorMovedAt+3e3).filter(u=>u>o);if(r.length===0)return;let i=setTimeout(()=>n(Date.now()),Math.min(...r)-o+1);return i.unref?.(),()=>clearTimeout(i)},[e]),t}function Bu({peers:e,sheetIds:t,sheetNames:n,activeSheet:o}){let{t:r}=c();if(e.length===0)return null;let i=e.slice(0,xl),l=e.length-i.length;return jsxs("div",{"data-testid":"xlsx-presence-strip","aria-label":r("presence.label"),style:{display:"flex",alignItems:"center",gap:4,padding:"0 6px",flex:"0 0 auto"},children:[i.map(u=>{let a=u.cursor?t.indexOf(u.cursor.sheet):o,f=u.cursor!==null&&a!==o,p=rn(u.user.color,u.clientId),y=a>=0?n[a]:u.cursor?r("presence.unavailableSheet"):void 0,s=(f||a<0)&&y!==void 0?r("presence.peerOnSheet",{name:u.user.name,sheet:y}):u.user.name;return jsx("span",{"data-testid":`xlsx-presence-chip-${u.clientId}`,title:s,"aria-label":s,style:{display:"inline-grid",placeItems:"center",width:24,height:24,borderRadius:"50%",backgroundColor:p,color:"#ffffff",boxShadow:"0 0 0 2px #ffffff",fontSize:9,fontWeight:700,lineHeight:1,letterSpacing:"-0.02em",opacity:f||a<0?.42:1,transition:"opacity 120ms ease"},children:yl(u.user.name)},u.clientId)}),l>0&&jsxs("span",{"data-testid":"xlsx-presence-overflow",title:r("presence.moreCollaborators",{count:l}),"aria-label":r("presence.moreCollaborators",{count:l}),style:{display:"inline-grid",placeItems:"center",minWidth:24,height:24,padding:"0 4px",borderRadius:12,backgroundColor:"#5f6368",color:"#ffffff",fontSize:9,fontWeight:700,lineHeight:1},children:["+",l]})]})}function ju({peers:e,grid:t,sheetIds:n,activeSheet:o,zoom:r,mergedRanges:i}){let l=useMemo(()=>e.slice(0,bl),[e]),u=e.length-l.length,a=vl(l);return t?jsxs(Fragment,{children:[l.map(f=>{if(!f.cursor)return null;let p=Zo(f.cursor,n);if(!p||p.sheetIndex!==o)return null;let y=Ot(p.range,i),s=rangeRect(t,y);if(!s)return null;let h=rn(f.user.color,f.clientId),m={x:s.x*r,y:s.y*r,w:s.w*r,h:s.h*r},w=p.range.top!==p.range.bottom||p.range.left!==p.range.right,c=y.left<t.startCol,v=y.top<t.startRow||m.y<18,R=f.cursorMovedAt>0&&a-f.cursorMovedAt<3e3;return jsx("div",{"data-testid":`xlsx-remote-selection-${f.clientId}`,style:{position:"absolute",left:m.x,top:m.y,width:m.w,height:m.h,boxSizing:"border-box",borderWidth:2,borderStyle:"solid",borderColor:h,backgroundColor:w?wl(h):"transparent"},children:R&&jsx("span",{"data-testid":`xlsx-remote-label-${f.clientId}`,style:{position:"absolute",top:v?0:-18,...c?{right:-2}:{left:-2},maxWidth:180,height:18,padding:"2px 6px",borderRadius:v?"0 0 3px 3px":"3px 3px 0 0",boxSizing:"border-box",overflow:"hidden",backgroundColor:h,color:"#ffffff",fontSize:10,fontWeight:600,lineHeight:"14px",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.user.name})},f.clientId)}),u>0&&jsxs("span",{"data-testid":"xlsx-remote-selection-overflow","aria-hidden":"true",style:{position:"absolute",left:4,top:4,padding:"2px 5px",borderWidth:1,borderStyle:"solid",borderColor:"#c7cacf",borderRadius:8,backgroundColor:"#ffffff",color:"#3c4043",fontSize:9,lineHeight:1},children:["+",u]})]}):null}var sn="#ffffff";function tr(e){if(!e)return null;let t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e.trim());if(t){let r=t[1].length===3?[...t[1]].map(a=>a+a).join(""):t[1],[i,l,u]=[0,2,4].map(a=>parseInt(r.slice(a,a+2),16));return [i,l,u,r.length===8?parseInt(r.slice(6),16)/255:1]}let n=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)(?:[\s,/]+([\d.]+%?))?\s*\)$/i.exec(e.trim());if(!n)return null;let o=n[4]===void 0?1:n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4]);return [Number(n[1]),Number(n[2]),Number(n[3]),Math.min(1,Math.max(0,o))]}function er(e){let t=tr(e);return t&&t[3]>=.5?[t[0],t[1],t[2]]:null}function Pl(e){return "#"+e.map(t=>t.toString(16).padStart(2,"0")).join("")}function an([e,t,n]){let o=r=>{let i=r/255;return i<=.03928?i/12.92:((i+.055)/1.055)**2.4};return .2126*o(e)+.7152*o(t)+.0722*o(n)}function Rl(e,t){let[n,o]=[an(e),an(t)].sort((r,i)=>i-r);return (n+.05)/(o+.05)}function wt(e,t,n){return t>=e.x&&t<=e.x+e.w&&n>=e.y&&n<=e.y+e.h}function Yu(e,t){let n=sn,o=er(sn),r;if(e&&t){let l=t.x+t.w/2,u=t.y+t.h/2;for(let a of e.commands)if(a.op==="fillRect"){let f=tr(a.color);f&&f[3]>=.5&&wt(a,l,u)&&(!a.clip||wt(a.clip,l,u))&&(o=[0,1,2].map(p=>Math.round(f[p]*f[3]+o[p]*(1-f[3]))),n=f[3]<1?Pl(o):a.color);}else a.op==="text"&&!a.ghost&&!a.chart&&(a.clip?wt(a.clip,l,u):wt(t,a.x,a.y))&&(r=a.color);}let i=er(r);return r&&i&&Rl(i,o)>=2?{color:r,background:n}:{color:an(o)<.18?sn:"#000000",background:n}}function kl({cell:e,onFollowLink:t}){return jsx("span",{role:"gridcell","aria-colindex":e.col+2,"aria-selected":e.selected,children:e.href&&t?jsx("a",{href:e.href,tabIndex:-1,onClick:n=>{n.preventDefault(),t(e.row,e.col);},children:e.label}):e.label})}function Zu({grid:e,style:t,onFollowLink:n}){return jsxs("div",{style:t,role:"grid","aria-label":e.label,"aria-rowcount":-1,"aria-colcount":-1,children:[jsxs("div",{role:"row","aria-rowindex":1,children:[jsx("span",{role:"gridcell","aria-colindex":1}),e.columnHeaders.map(o=>jsx("span",{role:"columnheader","aria-colindex":o.col+2,children:o.label},o.col))]}),e.rows.map(o=>jsxs("div",{role:"row","aria-rowindex":o.row+2,children:[jsx("span",{role:"rowheader","aria-colindex":1,children:o.header}),o.cells.map(r=>jsx(kl,{cell:r,onFollowLink:n},r.col))]},o.row))]})}export{Vs as $,Bl as A,mu as Aa,Tu as B,Zu as Ba,ql as C,ke as Ca,Zl as D,wu as Da,Ql as E,vu as Ea,jn as F,Cu as Fa,ts as G,ls as H,Ge as I,vr as J,ms as K,ws as L,Rs as M,Ou as N,Hu as O,Ss as P,Is as Q,Xs as R,Ms as S,Ts as T,Ds as U,As as V,Ls as W,Ot as X,Bu as Y,ju as Z,Fs as _,Il as a,qs as aa,or as b,Yu as ba,Et as c,ca,rr as d,ba as da,Tl as e,nu as ea,Dl as f,ou as fa,Al as g,Mo as ga,Ll as h,ka as ha,An as i,Ea as ia,kt as j,fo as ja,Ol as k,Ta as ka,Rt as l,mo as la,On as m,Da as ma,ir as n,fi as na,Hl as o,pi as oa,ku as p,mi as pa,Eu as q,gi as qa,Bo as r,hi as ra,Su as s,Aa as sa,_n as t,La as ta,sr as u,pt as ua,ar as v,Pi as va,Gl as w,Ri as wa,ur as x,Re as xa,Fl as y,ki as ya,Kl as z,fu as za};