@betteroffice/xlsx-react 0.0.7 → 0.1.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 +75 -25
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
React chrome for the BetterOffice XLSX editor — wraps
|
|
4
4
|
[`@betteroffice/xlsx`](https://www.npmjs.com/package/@betteroffice/xlsx) in a
|
|
5
|
-
drop-in `<XlsxEditor>` component with selection, keyboard, and
|
|
5
|
+
drop-in `<XlsxEditor>` component with the toolbar, selection, keyboard, and
|
|
6
|
+
clipboard wired up. Formula calculation and rendering run in the core's
|
|
7
|
+
Rust/WebAssembly engine; the grid is painted onto canvas.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
<!-- TODO(author): add a screenshot/GIF here once hosted; an <img> with an unresolvable src renders broken on npm -->
|
|
10
|
+
|
|
11
|
+
> **Early (`0.0.x`).** The core surfaces — opening/saving documents, the editor
|
|
12
|
+
> components, collaboration — are settling and unlikely to change shape. Smaller
|
|
13
|
+
> APIs may still move between releases; breaking changes are always listed in
|
|
14
|
+
> the changelog.
|
|
8
15
|
|
|
9
16
|
```bash
|
|
10
17
|
bun add @betteroffice/xlsx-react @betteroffice/xlsx react react-dom
|
|
@@ -12,7 +19,17 @@ bun add @betteroffice/xlsx-react @betteroffice/xlsx react react-dom
|
|
|
12
19
|
|
|
13
20
|
`react` and `react-dom` (18 or 19) are peer dependencies.
|
|
14
21
|
|
|
15
|
-
##
|
|
22
|
+
## Render a workbook
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { XlsxEditor } from "@betteroffice/xlsx-react";
|
|
26
|
+
|
|
27
|
+
<XlsxEditor file={bytes} fileName="report.xlsx" />;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`file` is a `Uint8Array` of `.xlsx` bytes; omit it to render an empty frame.
|
|
31
|
+
|
|
32
|
+
## Open and save
|
|
16
33
|
|
|
17
34
|
```tsx
|
|
18
35
|
import { useState } from "react";
|
|
@@ -34,39 +51,72 @@ export function App() {
|
|
|
34
51
|
<XlsxEditor
|
|
35
52
|
file={file}
|
|
36
53
|
fileName="workbook.xlsx"
|
|
37
|
-
onSave={(bytes) => {
|
|
38
|
-
// edited .xlsx bytes; without onSave the save button downloads them
|
|
39
|
-
console.log(`saved ${bytes.length} bytes`);
|
|
40
|
-
}}
|
|
54
|
+
onSave={(bytes) => console.log(`saved ${bytes.length} bytes`)}
|
|
41
55
|
/>
|
|
42
56
|
</>
|
|
43
57
|
);
|
|
44
58
|
}
|
|
45
59
|
```
|
|
46
60
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
`
|
|
50
|
-
`className`.
|
|
61
|
+
Without `onSave`, the save button downloads the edited bytes.
|
|
62
|
+
|
|
63
|
+
Props: `file`, `fileName`, `onSave`, `onReady` (a handle for host/agent-driven
|
|
64
|
+
edits), `collaboration`, `i18n`, and `className`.
|
|
65
|
+
|
|
66
|
+
## What works today
|
|
67
|
+
|
|
68
|
+
- Cell editing with formula recalculation of dependents on every edit
|
|
69
|
+
- Editing toolbar: number formats, fonts, colors, borders, alignment, merges
|
|
70
|
+
- Agent proposals: in-cell tracked-change ghosts plus an accept/reject panel
|
|
71
|
+
- TSV clipboard copy/paste
|
|
72
|
+
- Accessible grid mirroring the painted canvas for screen readers
|
|
73
|
+
- Localized UI via the `i18n` prop
|
|
74
|
+
([`@betteroffice/xlsx-i18n`](https://www.npmjs.com/package/@betteroffice/xlsx-i18n))
|
|
75
|
+
- Real-time collaboration with people or agents; the workbook is a CRDT
|
|
76
|
+
- Live collaborator selections and presence chips, shown in each peer's color
|
|
77
|
+
|
|
78
|
+
## AI agents
|
|
79
|
+
|
|
80
|
+
`onReady` hands you the open `WorkbookHandle`. An agent stages edits with
|
|
81
|
+
`propose()` instead of applying them; the editor paints per-cell ghosts and a
|
|
82
|
+
review panel where the human accepts or rejects. The full proposal API lives in
|
|
83
|
+
[`@betteroffice/xlsx`](https://www.npmjs.com/package/@betteroffice/xlsx).
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { isProposalsAvailable } from "@betteroffice/xlsx";
|
|
87
|
+
import type { XlsxEditorApi } from "@betteroffice/xlsx-react";
|
|
88
|
+
|
|
89
|
+
<XlsxEditor
|
|
90
|
+
file={file}
|
|
91
|
+
onReady={({ handle, refreshProposals }: XlsxEditorApi) => {
|
|
92
|
+
if (!isProposalsAvailable()) return;
|
|
93
|
+
handle.propose("copilot", "add totals", [
|
|
94
|
+
{ sheet: 0, row: 9, col: 2, input: "=SUM(C1:C9)" },
|
|
95
|
+
]);
|
|
96
|
+
refreshProposals();
|
|
97
|
+
}}
|
|
98
|
+
/>;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Collaboration
|
|
51
102
|
|
|
52
|
-
|
|
103
|
+
Pass `collaboration` to open a network-ready replica, then attach a transport
|
|
104
|
+
provider from `onReady`:
|
|
53
105
|
|
|
54
106
|
```tsx
|
|
55
107
|
import { CollaborationProvider } from "@betteroffice/xlsx/collaboration";
|
|
56
108
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
);
|
|
69
|
-
}
|
|
109
|
+
<XlsxEditor
|
|
110
|
+
file={file}
|
|
111
|
+
collaboration={{ clientId }}
|
|
112
|
+
onReady={({ handle }) => {
|
|
113
|
+
const provider = new CollaborationProvider(handle, transport, {
|
|
114
|
+
user: { name: "Ada" }, // shown on this peer's selection flag
|
|
115
|
+
});
|
|
116
|
+
provider.connect();
|
|
117
|
+
return () => provider.destroy();
|
|
118
|
+
}}
|
|
119
|
+
/>;
|
|
70
120
|
```
|
|
71
121
|
|
|
72
122
|
Docs: https://betteroffice.dev · Apache-2.0.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { CSSProperties, ReactNode } from 'react';
|
|
3
3
|
import { WorkbookHandle } from '@betteroffice/xlsx';
|
|
4
|
-
import { CollaborationReplica } from '@betteroffice/xlsx/collaboration';
|
|
4
|
+
import { CollaborationReplica, CollaborationAwareness } from '@betteroffice/xlsx/collaboration';
|
|
5
5
|
import { Translations, TFunction } from '@betteroffice/xlsx-i18n';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -20,6 +20,8 @@ interface XlsxEditorCollaborationOptions {
|
|
|
20
20
|
initialUpdate?: Uint8Array;
|
|
21
21
|
/** Receive the editor-owned collaboration replica. */
|
|
22
22
|
onReplica?: (replica: CollaborationReplica | null) => void;
|
|
23
|
+
/** Presence-capable provider connected to the editor-owned replica. */
|
|
24
|
+
provider?: CollaborationAwareness | null;
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* Props for {@link XlsxEditor}.
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {createContext,useMemo,useContext,useState,useRef,useCallback,useEffect}from'react';import {isPngExportAvailable,isProposalsAvailable,initWasm,openWorkbook,selectionAt,paintDisplayList,normalizeRange,buildA11yGrid,cellAtPoint,moveFocus,toTsv,fromTsv,StaleProposalError,selectionKeyReducer,extendTo,rangeRect,cellRect}from'@betteroffice/xlsx';import {en,deepMerge,createT}from'@betteroffice/xlsx-i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Ut=createContext(en),Gt=createContext("en");function rt({i18n:t,children:r}){let i=typeof t?._lang=="string"?t._lang:"en",c=useMemo(()=>deepMerge(en,t),[t]);return jsx(Gt.Provider,{value:i,children:jsx(Ut.Provider,{value:c,children:r})})}function ye(){let t=useContext(Ut),r=useContext(Gt);return {t:useMemo(()=>createT(t,r),[t,r])}}var De=createContext(null);function Io(){let t=useContext(De);if(!t)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return t}function k({name:t,size:r=20,style:i}){return jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"inline-flex",flexShrink:0,...i},children:[t==="search"&&jsxs(Fragment,{children:[jsx("circle",{cx:"10.5",cy:"10.5",r:"6"}),jsx("path",{d:"m15 15 4.5 4.5"})]}),t==="undo"&&jsx("path",{d:"m9 7-5 5 5 5M5 12h9a6 6 0 0 1 6 6"}),t==="redo"&&jsx("path",{d:"m15 7 5 5-5 5m4-5h-9a6 6 0 0 0-6 6"}),t==="print"&&jsxs(Fragment,{children:[jsx("path",{d:"M7 9V4h10v5M7 18H5a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),jsx("path",{d:"M7 14h10v6H7z"}),jsx("path",{d:"M17.5 12h.01"})]}),t==="formatPaint"&&jsxs(Fragment,{children:[jsx("path",{d:"M5 4h11v5H5zM8 9v3h5V9"}),jsx("path",{d:"M10.5 12v8"})]}),t==="decimalDecrease"&&jsxs(Fragment,{children:[jsx("path",{d:"M5 7h1M9 7h1M14 7h1M18 7h1"}),jsx("path",{d:"M5 16h1M9 16h1"}),jsx("path",{d:"m15 12-4 4 4 4M11 16h8"})]}),t==="decimalIncrease"&&jsxs(Fragment,{children:[jsx("path",{d:"M5 7h1M9 7h1"}),jsx("path",{d:"M5 16h1M9 16h1M14 16h1M18 16h1"}),jsx("path",{d:"m15 3 4 4-4 4M19 7h-8"})]}),t==="bold"&&jsx("path",{d:"M7 4h6a4 4 0 0 1 0 8H7zm0 8h7a4 4 0 0 1 0 8H7z"}),t==="italic"&&jsx("path",{d:"M10 4h8M6 20h8M14 4 10 20"}),t==="strikethrough"&&jsx(Fragment,{children:jsx("path",{d:"M5 12h14M8 7.5A4.5 4.5 0 0 1 12.5 4c2.2 0 3.7 1 4.5 2.5M8 16.5c.8 2.1 2.4 3.5 5 3.5 2.8 0 4.5-1.4 4.5-3.5 0-2.3-2-3.3-5.5-4.5"})}),t==="textColor"&&jsxs(Fragment,{children:[jsx("path",{d:"m7 16 5-12 5 12M9 11h6"}),jsx("path",{d:"M5 20h14",strokeWidth:"3"})]}),t==="fillColor"&&jsxs(Fragment,{children:[jsx("path",{d:"m7 4 10 10-6 6-7-7zM5 12h12"}),jsx("path",{d:"M18 17c0-1 1-2 1-2s1 1 1 2a1 1 0 0 1-2 0Z"})]}),t==="borders"&&jsx(Fragment,{children:jsx("path",{d:"M4 4h16v16H4zM12 4v16M4 12h16"})}),t==="merge"&&jsxs(Fragment,{children:[jsx("path",{d:"M4 5h16v14H4z"}),jsx("path",{d:"m8 9 3 3-3 3M16 9l-3 3 3 3"})]}),t==="alignLeft"&&jsx("path",{d:"M4 6h16M4 10h11M4 14h16M4 18h11"}),t==="verticalAlignCenter"&&jsxs(Fragment,{children:[jsx("path",{d:"M4 4h16M4 20h16M8 12h8"}),jsx("path",{d:"m10 9 2 3 2-3M10 15l2-3 2 3"})]}),t==="wrap"&&jsxs(Fragment,{children:[jsx("path",{d:"M4 6h16M4 11h12a3 3 0 0 1 0 6h-3"}),jsx("path",{d:"m15 14-3 3 3 3M4 17h5"})]}),t==="more"&&jsxs(Fragment,{children:[jsx("circle",{cx:"5",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),jsx("circle",{cx:"19",cy:"12",r:"1",fill:"currentColor",stroke:"none"})]}),t==="chevronDown"&&jsx("path",{d:"m7 10 5 5 5-5"}),t==="remove"&&jsx("path",{d:"M5 12h14"}),t==="add"&&jsx("path",{d:"M12 5v14M5 12h14"}),t==="check"&&jsx("path",{d:"m5 12 4 4L19 6"}),t==="save"&&jsx("path",{d:"M12 3v11m0 0 4-4m-4 4-4-4M5 19h14"}),t==="image"&&jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),jsx("circle",{cx:"8.5",cy:"9.5",r:"1.25"}),jsx("path",{d:"m6 17 4.5-4.5 3.25 3.25L16 13.5l2 2"})]}),t==="proposals"&&jsxs(Fragment,{children:[jsx("path",{d:"m12 3 1.25 3.75L17 8l-3.75 1.25L12 13l-1.25-3.75L7 8l3.75-1.25L12 3Z"}),jsx("path",{d:"m18 14 .75 2.25L21 17l-2.25.75L18 20l-.75-2.25L15 17l2.25-.75L18 14Z"})]})]})}var T={text:"#3c4043",muted:"#5f6368",disabled:"#9aa0a6",hover:"#e2e7ef",active:"#d3e3fd",border:"#c7cacf",surface:"#ffffff",rail:"#edf2fa"},Ho={appearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:2,minWidth:28,height:28,padding:"0 5px",border:0,borderRadius:4,color:T.text,font:"500 13px ui-sans-serif, system-ui, sans-serif",lineHeight:1,whiteSpace:"nowrap",boxSizing:"border-box"};function _t(t,r,i,c){return {...Ho,background:r?T.active:i&&!t?T.hover:"transparent",color:t?T.disabled:T.text,cursor:t?"default":"pointer",opacity:t?.48:1,...c}}function H({active:t=false,disabled:r=false,title:i,onClick:c,children:h,style:g,testId:s,ariaExpanded:F}){let[R,z]=useState(false);return jsx("button",{type:"button","data-testid":s,disabled:r,"aria-label":i,"aria-pressed":t||void 0,"aria-expanded":F,title:i,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>z(true),onMouseLeave:()=>z(false),onClick:r?void 0:c,style:_t(r,t,R,g),children:h})}function K({label:t,children:r,style:i}){return jsx("div",{role:"group","aria-label":t,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto",...i},children:r})}function $e(){return jsx("div",{role:"separator",style:{width:1,height:24,margin:"0 5px",background:T.border,flex:"0 0 auto"}})}function ce({title:t,trigger:r,children:i,disabled:c=false,active:h=false,menuWidth:g=220,style:s,testId:F}){let[R,z]=useState(false),[O,q]=useState(false),[U,ae]=useState({top:0,left:0}),x=useRef(null),_=useRef(null),I=useCallback(()=>z(false),[]);return useEffect(()=>{if(!R||!x.current)return;let B=x.current.getBoundingClientRect(),J=Math.min(B.left,Math.max(8,window.innerWidth-g-8));ae({top:B.bottom+4,left:J});},[R,g]),useEffect(()=>{if(!R)return;let B=Y=>{let S=Y.target;!x.current?.contains(S)&&!_.current?.contains(S)&&I();},J=Y=>{Y.key==="Escape"&&I();},v=()=>I();return document.addEventListener("mousedown",B),document.addEventListener("keydown",J),window.addEventListener("scroll",v,true),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("keydown",J),window.removeEventListener("scroll",v,true);}},[R,I]),jsxs("div",{style:{position:"relative",display:"inline-flex",flex:"0 0 auto"},children:[jsx("button",{ref:x,type:"button","data-testid":F,disabled:c,"aria-label":t,"aria-haspopup":"menu","aria-expanded":R,title:t,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>q(true),onMouseLeave:()=>q(false),onClick:()=>!c&&z(B=>!B),style:_t(c,h||R,O,s),children:r}),R&&jsx("div",{ref:_,role:"menu","aria-label":t,onMouseDown:B=>B.preventDefault(),style:{position:"fixed",top:U.top,left:U.left,zIndex:1e4,width:g,maxHeight:"min(440px, calc(100vh - 16px))",overflowY:"auto",padding:6,border:`1px solid ${T.border}`,borderRadius:8,background:T.surface,boxShadow:"0 4px 16px rgba(60, 64, 67, 0.24)",boxSizing:"border-box"},children:i(I)})]})}function te({label:t,icon:r,selected:i=false,disabled:c=false,onClick:h,close:g}){let[s,F]=useState(false);return jsxs("button",{type:"button",role:"menuitem",disabled:c,"aria-label":t,onMouseEnter:()=>F(true),onMouseLeave:()=>F(false),onClick:()=>{c||(h?.(),g?.());},style:{appearance:"none",display:"flex",alignItems:"center",gap:10,width:"100%",minHeight:32,padding:"5px 9px",border:0,borderRadius:4,background:s&&!c?T.hover:"transparent",color:c?T.disabled:T.text,cursor:c?"default":"pointer",opacity:c?.48:1,font:"400 13px ui-sans-serif, system-ui, sans-serif",textAlign:"left",boxSizing:"border-box"},children:[jsx("span",{style:{display:"inline-grid",placeItems:"center",width:20,flex:"0 0 auto"},children:r}),jsx("span",{style:{flex:1},children:t}),i&&jsx("span",{"aria-hidden":"true",children:"\u2713"})]})}function Oe(){return jsx("div",{role:"separator",style:{height:1,margin:"5px 2px",background:T.border}})}function xt({mode:t,value:r,label:i,onChange:c,disabled:h=false}){let[g,s]=useState(false);return jsxs("label",{title:i,"aria-label":i,style:{position:"relative",display:"inline-grid",placeItems:"center",width:28,height:28,borderRadius:4,background:g&&!h?T.hover:"transparent",color:h?T.disabled:T.text,cursor:h?"default":"pointer",opacity:h?.48:1,boxSizing:"border-box"},onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),children:[jsx(k,{name:t==="text"?"textColor":"fillColor",size:20}),jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:5,right:5,bottom:2,height:3,borderRadius:2,background:r}}),jsx("input",{type:"color",value:r,disabled:h,"aria-label":i,onChange:F=>c?.(F.target.value),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0}})]})}function Ct({value:t,options:r,label:i,onCommit:c,disabled:h=false,width:g=72,inputStyle:s,testId:F}){let[R,z]=useState(t),[O,q]=useState(false),[U,ae]=useState({top:0,left:0,width:g}),x=useRef(null),_=useRef(null),I=useRef(null);useEffect(()=>z(t),[t]);let B=useCallback(()=>q(false),[]);useEffect(()=>{if(!O||!x.current)return;let v=x.current.getBoundingClientRect();ae({top:v.bottom+4,left:v.left,width:Math.max(v.width,g)});},[O,g]),useEffect(()=>{if(!O)return;let v=S=>{let Q=S.target;!x.current?.contains(Q)&&!_.current?.contains(Q)&&B();},Y=S=>{S.key==="Escape"&&(z(t),B());};return document.addEventListener("mousedown",v),document.addEventListener("keydown",Y),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",Y);}},[O,B,t]);let J=useCallback(()=>{!h&&c&&R.trim()?c(R.trim()):z(t);},[h,c,R,t]);return jsxs("div",{ref:x,style:{display:"inline-flex",alignItems:"center",width:g,height:28,border:`1px solid ${T.border}`,borderRadius:4,background:h?"rgba(255,255,255,0.5)":T.surface,opacity:h?.48:1,boxSizing:"border-box",flex:"0 0 auto"},children:[jsx("input",{ref:I,"data-testid":F,role:"combobox","aria-label":i,"aria-autocomplete":"list","aria-expanded":O,disabled:h,value:R,onFocus:v=>{h||(q(true),v.currentTarget.select());},onChange:v=>z(v.target.value),onKeyDown:v=>{v.key==="Enter"?(J(),B(),v.currentTarget.blur()):v.key==="ArrowDown"&&(q(true),v.preventDefault());},onBlur:()=>{requestAnimationFrame(()=>{_.current?.contains(document.activeElement)||J();});},style:{appearance:"none",width:"calc(100% - 22px)",height:26,padding:"0 2px 0 7px",border:0,outline:0,background:"transparent",color:T.text,font:"500 13px ui-sans-serif, system-ui, sans-serif",boxSizing:"border-box",...s}}),jsx("button",{type:"button",disabled:h,tabIndex:-1,"aria-label":i,title:i,onMouseDown:v=>v.preventDefault(),onClick:()=>{h||(q(v=>!v),I.current?.focus());},style:{appearance:"none",display:"grid",placeItems:"center",width:21,height:26,padding:0,border:0,background:"transparent",color:T.muted,cursor:h?"default":"pointer"},children:jsx(k,{name:"chevronDown",size:14})}),O&&!h&&jsx("div",{ref:_,role:"listbox","aria-label":i,style:{position:"fixed",top:U.top,left:U.left,zIndex:1e4,width:U.width,maxHeight:260,overflowY:"auto",padding:4,border:`1px solid ${T.border}`,borderRadius:6,background:T.surface,boxShadow:"0 4px 16px rgba(60, 64, 67, 0.24)",boxSizing:"border-box"},children:r.map(v=>jsx("button",{type:"button",role:"option","aria-selected":v.value===t,onMouseDown:Y=>Y.preventDefault(),onClick:()=>{z(v.label),c?.(v.value),B();},style:{appearance:"none",display:"block",width:"100%",minHeight:28,padding:"4px 7px",border:0,borderRadius:3,background:v.value===t?T.active:"transparent",color:T.text,cursor:"pointer",font:"400 13px ui-sans-serif, system-ui, sans-serif",textAlign:"left"},children:v.label},v.value))})]})}var Xo=[.5,.75,.9,1,1.25,1.5,2],_o=["Arial","Calibri","Cambria","Georgia","Roboto","Times New Roman","Verdana"],Vo=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],Zo=["automatic","plainText","number","percent","scientific","currency","date","time","custom"],Yo=["all","inner","horizontal","vertical","outer","left","top","right","bottom","none"],jo=["solid","dashed","dotted","double"],qo=["left","center","right"],Jo=["top","middle","bottom"],Qo=["overflow","wrap","clip"];function er(t){let r={};for(let i of Object.keys(t))t[i]!==void 0&&(r[i]=t[i]);return r}function tr(t){let r=useContext(De);return r?{...r,...er(t)}:t}function jt({preset:t}){let r=i=>t===i||t==="all"||t==="outer"?2:.6;return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","aria-hidden":"true",children:[t!=="none"&&jsxs(Fragment,{children:[jsx("path",{d:"M3 3h14",strokeWidth:r("top")}),jsx("path",{d:"M17 3v14",strokeWidth:r("right")}),jsx("path",{d:"M3 17h14",strokeWidth:r("bottom")}),jsx("path",{d:"M3 3v14",strokeWidth:r("left")}),(t==="all"||t==="inner"||t==="horizontal")&&jsx("path",{d:"M3 10h14",strokeWidth:"1.5"}),(t==="all"||t==="inner"||t==="vertical")&&jsx("path",{d:"M10 3v14",strokeWidth:"1.5"})]}),t==="none"&&jsx("path",{d:"M4 4h12v12H4zM3 17 17 3",strokeWidth:"1.5"})]})}function qt({value:t}){let r=t==="left"?3:t==="center"?5:7,i=t==="left"?15:t==="center"?17:19;return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:[jsx("path",{d:"M3 4h14M3 10h14M3 16h14"}),jsx("path",{d:`M${r} 7h${i-r}M${r} 13h${i-r}`})]})}function Jt({value:t}){return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:[jsx("path",{d:"M3 3h14M3 17h14"}),jsx("path",{d:`M6 ${t==="top"?5:t==="middle"?10:15}h8`}),jsx("path",{d:t==="top"?"m8 8 2-3 2 3":t==="bottom"?"m8 12 2 3 2-3":"m8 7 2 3 2-3m-4 6 2-3 2 3"})]})}function or({value:t}){return jsx("svg",{width:"44",height:"12",viewBox:"0 0 44 12",fill:"none",stroke:"currentColor","aria-hidden":"true",children:t==="double"?jsx(Fragment,{children:jsx("path",{d:"M2 4h40M2 8h40"})}):jsx("path",{d:"M2 6h40",strokeWidth:"2",strokeDasharray:t==="dashed"?"7 4":t==="dotted"?"1 4":void 0})})}function Qt(t,r,i){return i>0?r.find(c=>c>t)??t+1:[...r].reverse().find(c=>c<t)??Math.max(1,t-1)}function nt(t){let{t:r}=ye(),{currentFormatting:i={},selectionShape:c,onFormat:h,onMerge:g,onSearchMenus:s,onUndo:F,onRedo:R,canUndo:z=false,canRedo:O=false,onPrint:q,zoom:U=1,onZoomChange:ae,fontFamilies:x=_o,fontSizes:_=Vo,disabled:I=false,className:B,style:J,children:v}=tr(t),Y=useRef(null),[S,Q]=useState(Number.POSITIVE_INFINITY),w=!I&&!!h,E=!I&&!!g,me=i.fontSize??10,Ke=(c?.rows??1)>1,f=(c?.columns??1)>1,G=Ke||f;useEffect(()=>{let b=Y.current;if(!b)return;let d=()=>Q(b.clientWidth);d();let we=new ResizeObserver(d);return we.observe(b),()=>we.disconnect()},[]);let V=useMemo(()=>Xo.map(b=>({value:`${b*100}%`,label:`${b*100}%`})),[]),he=useMemo(()=>_.map(b=>({value:String(b),label:String(b)})),[_]),D=b=>{w&&h?.(b);},Ae=b=>jsx(Fragment,{children:Zo.map(d=>jsx(te,{label:r(`toolbar.numberFormats.${d}`),selected:i.numberFormat===d,disabled:!w,onClick:()=>D({type:"numberFormat",value:d}),close:b},d))}),Ce=b=>jsxs(Fragment,{children:[Yo.map(d=>jsx(te,{icon:jsx(jt,{preset:d}),label:r(`toolbar.borderPresets.${d}`),selected:i.borderPreset===d,disabled:!w,onClick:()=>D({type:"borderPreset",value:d}),close:b},d)),jsx(Oe,{}),jo.map(d=>jsx(te,{icon:jsx(or,{value:d}),label:r(`toolbar.borderStyles.${d}`),selected:i.borderStyle===d,disabled:!w,onClick:()=>D({type:"borderStyle",value:d}),close:b},d)),jsx(Oe,{}),jsxs("label",{style:{position:"relative",display:"flex",alignItems:"center",gap:10,minHeight:32,padding:"5px 9px",color:T.text,font:"400 13px ui-sans-serif, system-ui, sans-serif",cursor:w?"pointer":"default"},children:[jsx("span",{style:{width:20,height:5,borderRadius:2,background:i.borderColor??"#000000"}}),jsx("span",{children:r("toolbar.borderColor")}),jsx("input",{type:"color",value:i.borderColor??"#000000",disabled:!w,"aria-label":r("toolbar.borderColor"),onChange:d=>D({type:"borderColor",value:d.target.value}),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0}})]})]}),Se=b=>jsxs(Fragment,{children:[jsx(te,{label:r("toolbar.merge.all"),disabled:!E||!G,onClick:()=>g?.("all"),close:b}),jsx(te,{label:r("toolbar.merge.horizontal"),disabled:!E||!f,onClick:()=>g?.("horizontal"),close:b}),jsx(te,{label:r("toolbar.merge.vertical"),disabled:!E||!Ke,onClick:()=>g?.("vertical"),close:b}),jsx(Oe,{}),jsx(te,{label:r("toolbar.merge.unmerge"),disabled:!E||!c?.canUnmerge,onClick:()=>g?.("unmerge"),close:b})]}),Xe=b=>jsx(Fragment,{children:qo.map(d=>jsx(te,{icon:jsx(qt,{value:d}),label:r(`toolbar.horizontalAlign.${d}`),selected:i.horizontalAlignment===d,disabled:!w,onClick:()=>D({type:"horizontalAlignment",value:d}),close:b},d))}),st=b=>jsx(Fragment,{children:Jo.map(d=>jsx(te,{icon:jsx(Jt,{value:d}),label:r(`toolbar.verticalAlign.${d}`),selected:i.verticalAlignment===d,disabled:!w,onClick:()=>D({type:"verticalAlignment",value:d}),close:b},d))}),L=b=>jsx(Fragment,{children:Qo.map(d=>jsx(te,{label:r(`toolbar.wrapping.${d}`),selected:i.textWrapping===d,disabled:!w,onClick:()=>D({type:"textWrapping",value:d}),close:b},d))}),ge=[{key:"search",width:29,node:jsx(K,{label:r("toolbar.groups.search"),children:jsx(H,{title:r("toolbar.searchMenus"),onClick:s,testId:"xlsx-search-menus",children:jsx(k,{name:"search"})})})},{key:"history",width:58,node:jsxs(K,{label:r("toolbar.groups.history"),children:[jsx(H,{title:r("toolbar.undo"),disabled:I||!z||!F,onClick:F,testId:"xlsx-undo",children:jsx(k,{name:"undo"})}),jsx(H,{title:r("toolbar.redo"),disabled:I||!O||!R,onClick:R,testId:"xlsx-redo",children:jsx(k,{name:"redo"})})]})},{key:"print",width:29,node:jsx(K,{label:r("toolbar.groups.print"),children:jsx(H,{title:r("toolbar.print"),disabled:I||!q,onClick:q,children:jsx(k,{name:"print"})})})},{key:"paint",width:29,node:jsx(K,{label:r("toolbar.groups.paintFormat"),children:jsx(H,{title:r("toolbar.paintFormat"),active:i.paintFormat,disabled:!w,onClick:()=>D("paintFormat"),children:jsx(k,{name:"formatPaint"})})})},{key:"zoom",width:82,node:jsx(K,{label:r("toolbar.groups.zoom"),children:jsx(Ct,{value:`${Math.round(U*100)}%`,options:V,label:r("toolbar.zoomValue",{value:`${Math.round(U*100)}%`}),disabled:I||!ae,onCommit:b=>{let d=Number.parseFloat(b.replace("%",""));Number.isFinite(d)&&d>=25&&d<=400&&ae?.(d/100);},width:76,testId:"xlsx-zoom"})})},{key:"number",width:202,node:jsxs(Fragment,{children:[jsx($e,{}),jsxs(K,{label:r("toolbar.groups.number"),children:[jsx(H,{title:r("toolbar.currency"),disabled:!w,onClick:()=>D("currency"),children:jsx("span",{style:{fontSize:16},children:r("toolbar.currencySymbol")})}),jsx(H,{title:r("toolbar.percent"),disabled:!w,onClick:()=>D("percent"),children:jsx("span",{style:{fontSize:15},children:"%"})}),jsx(H,{title:r("toolbar.decreaseDecimal"),disabled:!w,onClick:()=>D("decreaseDecimal"),children:jsx(k,{name:"decimalDecrease"})}),jsx(H,{title:r("toolbar.increaseDecimal"),disabled:!w,onClick:()=>D("increaseDecimal"),children:jsx(k,{name:"decimalIncrease"})}),jsx(ce,{title:r("toolbar.moreNumberFormats"),disabled:!w,trigger:jsxs(Fragment,{children:[jsx("span",{children:"123"}),jsx(k,{name:"chevronDown",size:13})]}),children:Ae})]})]})},{key:"font-family",width:137,node:jsxs(Fragment,{children:[jsx($e,{}),jsx(K,{label:r("toolbar.groups.font"),children:jsx(ce,{title:r("toolbar.fontFamily"),disabled:!w,menuWidth:210,style:{width:120,justifyContent:"space-between"},trigger:jsxs(Fragment,{children:[jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:i.fontFamily??"Calibri"}),jsx(k,{name:"chevronDown",size:13})]}),children:b=>jsx(Fragment,{children:x.map(d=>jsx(te,{label:d,selected:i.fontFamily===d,disabled:!w,onClick:()=>D({type:"fontFamily",value:d}),close:b},d))})})})]})},{key:"font-size",width:116,node:jsxs(K,{label:r("toolbar.groups.font"),children:[jsx(H,{title:r("toolbar.decreaseFontSize"),disabled:!w,onClick:()=>D({type:"fontSize",value:Qt(me,_,-1)}),children:jsx(k,{name:"remove"})}),jsx(Ct,{value:String(me),options:he,label:r("toolbar.fontSize"),disabled:!w,onCommit:b=>{let d=Number.parseFloat(b);Number.isFinite(d)&&d>=1&&d<=400&&D({type:"fontSize",value:d});},width:50,inputStyle:{textAlign:"center"}}),jsx(H,{title:r("toolbar.increaseFontSize"),disabled:!w,onClick:()=>D({type:"fontSize",value:Qt(me,_,1)}),children:jsx(k,{name:"add"})})]})},{key:"text",width:98,node:jsxs(Fragment,{children:[jsx($e,{}),jsxs(K,{label:r("toolbar.groups.text"),children:[jsx(H,{title:r("toolbar.bold"),active:i.bold,disabled:!w,onClick:()=>D("bold"),children:jsx(k,{name:"bold"})}),jsx(H,{title:r("toolbar.italic"),active:i.italic,disabled:!w,onClick:()=>D("italic"),children:jsx(k,{name:"italic"})}),jsx(H,{title:r("toolbar.strikethrough"),active:i.strikethrough,disabled:!w,onClick:()=>D("strikethrough"),children:jsx(k,{name:"strikethrough"})})]})]})},{key:"colors",width:58,node:jsxs(K,{label:r("toolbar.groups.colors"),children:[jsx(xt,{mode:"text",value:i.textColor??"#000000",label:r("toolbar.textColor"),disabled:!w,onChange:b=>D({type:"textColor",value:b})}),jsx(xt,{mode:"fill",value:i.fillColor??"#ffffff",label:r("toolbar.fillColor"),disabled:!w,onChange:b=>D({type:"fillColor",value:b})})]})},{key:"borders",width:36,node:jsx(K,{label:r("toolbar.groups.borders"),children:jsx(ce,{title:r("toolbar.borders"),disabled:!w,menuWidth:240,trigger:jsxs(Fragment,{children:[jsx(jt,{preset:i.borderPreset??"all"}),jsx(k,{name:"chevronDown",size:12})]}),children:Ce})})},{key:"merge",width:58,node:jsxs(K,{label:r("toolbar.groups.merge"),children:[jsx(H,{title:r("toolbar.merge.all"),disabled:!E||!G,onClick:()=>g?.("all"),style:{borderRadius:"4px 0 0 4px"},testId:"xlsx-merge-all",children:jsx(k,{name:"merge"})}),jsx(ce,{title:r("toolbar.mergeCells"),disabled:!E||!G&&!c?.canUnmerge,menuWidth:220,style:{minWidth:20,width:20,padding:0,borderRadius:"0 4px 4px 0"},trigger:jsx(k,{name:"chevronDown",size:13}),children:Se})]})},{key:"alignment",width:118,node:jsxs(K,{label:r("toolbar.groups.alignment"),children:[jsx(ce,{title:r("toolbar.horizontalAlignment"),disabled:!w,menuWidth:180,trigger:jsxs(Fragment,{children:[jsx(qt,{value:i.horizontalAlignment??"left"}),jsx(k,{name:"chevronDown",size:12})]}),children:Xe}),jsx(ce,{title:r("toolbar.verticalAlignment"),disabled:!w,menuWidth:180,trigger:jsxs(Fragment,{children:[jsx(Jt,{value:i.verticalAlignment??"middle"}),jsx(k,{name:"chevronDown",size:12})]}),children:st}),jsx(ce,{title:r("toolbar.textWrapping"),disabled:!w,menuWidth:180,trigger:jsxs(Fragment,{children:[jsx(k,{name:"wrap"}),jsx(k,{name:"chevronDown",size:12})]}),children:L})]})}];v&&ge.push({key:"custom",width:40,node:v});let Fe=Math.max(0,S-48),ke=0,Te=ge.length;for(let b=0;b<ge.length;b++)if(ke+=ge[b].width,ke>Fe){Te=b;break}let _e=ge.slice(0,Te),ee=ge.slice(Te);return jsxs("div",{ref:Y,className:B,role:"toolbar","aria-label":r("toolbar.actionsLabel"),"data-testid":"xlsx-formatting-toolbar",style:{display:"flex",alignItems:"center",minWidth:0,minHeight:36,margin:"0 8px 5px",padding:"4px 7px",borderRadius:18,background:T.rail,color:T.text,overflow:"hidden",boxSizing:"border-box",...J},children:[_e.map(b=>jsx("span",{style:{display:"contents"},children:b.node},b.key)),jsx("span",{style:{marginLeft:"auto",flex:"0 0 auto"},children:jsx(ce,{title:r("toolbar.more"),disabled:ee.length===0,menuWidth:390,testId:"xlsx-toolbar-more",trigger:jsx(k,{name:"more"}),children:()=>jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:2},children:ee.map(b=>jsx("span",{style:{display:"contents"},children:b.node},b.key))})})})]})}function rr({children:t,className:r,style:i,...c}){return jsx(De.Provider,{value:c,children:jsx("div",{className:r,"data-testid":"xlsx-editor-toolbar",style:{display:"flex",flexDirection:"column",flex:"0 0 auto",...i},children:t})})}var Ge=rr;Ge.Toolbar=nt;var to=["#7c3aed","#0891b2","#c2410c","#4d7c0f","#be185d","#1d4ed8"];function nr(t){let r=2166136261;for(let i=0;i<t.length;i++)r^=t.charCodeAt(i),r=Math.imul(r,16777619);return (r>>>0)%to.length}function oo(t){return to[nr(t)]}function ro({proposals:t,staleFor:r,onAccept:i,onReject:c,style:h}){let{t:g}=ye();return jsx("div",{"data-testid":"xlsx-proposals-panel",role:"region","aria-label":g("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",...h},children:t.length===0?jsx("div",{style:{padding:12,color:"#707070",textAlign:"center"},children:g("proposals.empty")}):t.map(s=>{let F=oo(s.agentId),R=r[s.id];return jsxs("div",{"data-testid":"xlsx-proposal","data-proposal-id":s.id,style:{borderLeft:`3px solid ${F}`,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:F},children:s.agentId}),jsx("span",{style:{color:"#707070",fontSize:12},children:g("proposals.cellCount",{count:s.cells.length})})]}),s.note&&jsx("div",{style:{color:"#404040",margin:"4px 0"},children:s.note}),jsx("ul",{style:{listStyle:"none",margin:"6px 0",padding:0},children:s.cells.map(z=>jsxs("li",{"data-testid":"xlsx-proposal-cell",style:{fontVariantNumeric:"tabular-nums",lineHeight:1.5},children:[jsx("strong",{"data-testid":"xlsx-proposal-cell-a1",children:z.a1}),":"," ",jsx("span",{style:{color:"#909090"},children:z.oldText||"\u2205"})," ",g("proposals.changeArrow")," ",jsx("span",{"data-testid":"xlsx-proposal-cell-new",style:{color:F},children:z.newText})]},z.a1))}),R&&R.length>0&&jsx("div",{"data-testid":"xlsx-proposal-stale",role:"alert",style:{color:"#b45309",background:"#fef3c7",borderRadius:4,padding:"4px 6px",margin:"4px 0",fontSize:12},children:g("proposals.staleWarning",{cells:R.join(", ")})}),jsxs("div",{style:{display:"flex",gap:6,marginTop:4},children:[jsx("button",{"data-testid":"xlsx-proposal-accept",onClick:()=>i(s.id),style:{padding:"3px 10px",cursor:"pointer"},children:g("proposals.accept")}),R&&R.length>0&&jsx("button",{"data-testid":"xlsx-proposal-force",onClick:()=>i(s.id,true),style:{padding:"3px 10px",cursor:"pointer",color:"#b45309"},children:g("proposals.forceApply")}),jsx("button",{"data-testid":"xlsx-proposal-reject",onClick:()=>c(s.id),style:{padding:"3px 10px",cursor:"pointer"},children:g("proposals.reject")})]})]},s.id)})})}var xe=96,ve=24,it="#217346",co=87,gr="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";function yr(t,r,i){let c=[{op:"fillRect",x:0,y:0,w:t,h:r,color:"#ffffff"}],h=Math.ceil(t/xe),g=Math.ceil(r/ve);for(let s=0;s<=h;s++)c.push({op:"line",x1:s*xe,y1:0,x2:s*xe,y2:r,width:1,color:"#e0e0e0"});for(let s=0;s<=g;s++)c.push({op:"line",x1:0,y1:s*ve,x2:t,y2:s*ve,width:1,color:"#e0e0e0"});return c.push({op:"fillRect",x:0,y:0,w:t,h:ve,color:"#f3f3f3"}),c.push({op:"fillRect",x:0,y:0,w:xe,h:r,color:"#f3f3f3"}),c.push({op:"text",x:xe+8,y:ve+18,text:i,fontSize:14,color:"#202020",clip:{x:xe,y:ve,w:xe*3,h:ve},align:"left"}),{width:t,height:r,commands:c}}function io(t,r){if(!t||t.length<2)return r;let i=[];for(let h=1;h<t.length;h++)i.push(t[h]-t[h-1]);i.sort((h,g)=>h-g);let c=i[i.length>>1];return c>0?c:r}function xr(t,r,i){let c=io(t?.grid?.rowOffsets,ve),h=io(t?.grid?.colOffsets,xe),g=Math.max(1,Math.round(r.contentHeight/c))+1,s=Math.max(1,Math.round(r.contentWidth/h))+1,F=Math.max(1,Math.floor(i/c));return {rows:g,cols:s,rowsPerPage:F}}function so(t,r,i){let c=new Blob([new Uint8Array(t)],{type:i}),h=URL.createObjectURL(c),g=document.createElement("a");g.href=h,g.download=r,document.body.appendChild(g),g.click(),g.remove(),URL.revokeObjectURL(h);}function vr(t){return `${(t??"workbook.xlsx").replace(/\.xlsx$/i,"")}.png`}function Tt(t,r){return {x:t.x*r,y:t.y*r,w:t.w*r,h:t.h*r}}var Sr={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},fe={shell:{flex:"0 0 auto",minHeight:co,padding:"4px 0 5px",borderBottom:"1px solid #e2e8f0",background:"#ffffff",color:"#0f172a",boxSizing:"border-box"},rail:{display:"flex",alignItems:"center",minHeight:32,margin:"0 8px",padding:"2px 8px",borderRadius:4,background:"#ffffff",boxSizing:"border-box",overflowX:"auto",overflowY:"hidden"},group:{display:"inline-flex",alignItems:"center",gap:1,padding:"0 6px",borderRight:"1px solid rgba(226, 232, 240, 0.9)",flex:"0 0 auto"},formulaGroup:{display:"flex",alignItems:"center",gap:4,flex:"1 1 320px",minWidth:240,padding:"0 6px",borderRight:"1px solid rgba(226, 232, 240, 0.9)"},nameBox:{appearance:"none",width:64,height:28,flex:"0 0 auto",boxSizing:"border-box",border:"1px solid #e2e8f0",borderRadius:6,background:"#f8fafc",color:"#0f172a",font:"600 12px ui-monospace, SFMono-Regular, Menlo, monospace",textAlign:"center",outlineColor:"#2563eb"},formulaMark:{display:"grid",placeItems:"center",width:20,height:28,flex:"0 0 auto",color:"#64748b",font:"italic 700 12px Georgia, serif",userSelect:"none"},formulaInput:{appearance:"none",flex:"1 1 260px",minWidth:140,height:28,boxSizing:"border-box",border:"1px solid #e2e8f0",borderRadius:6,padding:"0 8px",background:"#ffffff",color:"#0f172a",font:"13px ui-sans-serif, system-ui, sans-serif",outlineColor:"#2563eb"},proposals:{marginLeft:"auto",paddingLeft:6,flex:"0 0 auto"},count:{display:"inline-grid",placeItems:"center",minWidth:15,height:15,marginLeft:-3,padding:"0 4px",borderRadius:8,background:"#0f172a",color:"#ffffff",fontSize:10,fontWeight:700,lineHeight:1,boxSizing:"border-box"}};function wr({i18n:t,...r}){return jsx(rt,{i18n:t,children:jsx(Cr,{...r})})}function Cr({file:t,fileName:r,onSave:i,collaboration:c,onReady:h,className:g}){let{t:s}=ye(),F=c!==void 0,R=c?.clientId,z=c?.initialUpdate,O=c?.onReplica,q=useRef(null),U=useRef(null),ae=useRef(null),x=useRef(null),_=useRef(null),I=useRef(null),B=useRef(null),J=useRef(false),v=useRef(false),Y=useRef(h);Y.current=h;let[S,Q]=useState(null),[w,E]=useState(null),[me,Ke]=useState(null),[f,G]=useState(null),[V,he]=useState(null),[D,Ae]=useState(null),[Ce,Se]=useState(null),[Xe,st]=useState(co),[L,ge]=useState(1),[Fe,ke]=useState(0),[Te,_e]=useState(false),[ee,b]=useState({}),[d,we]=useState({canUndo:false,canRedo:false}),[ct,Ve]=useState([]),[dt,Mt]=useState(),[pt,Et]=useState(),[Me,ze]=useState(null),Ee=useRef(null),[Ze,Ye]=useState([]),[ut,Rt]=useState(false),[bt,Pt]=useState(null),[po,Ie]=useState({}),p=S?.activeSheet??0,uo=useMemo(()=>isPngExportAvailable(),[]),Lt=useMemo(()=>isProposalsAvailable(),[]);useEffect(()=>{let e=q.current;if(!e)return;let o=()=>st(e.offsetHeight);o();let n=new ResizeObserver(o);return n.observe(e),()=>n.disconnect()},[]);let ie=useCallback(()=>{let e=x.current;if(!e){Ye([]);return}try{Ye(e.listProposals());}catch{Ye([]);}ke(o=>o+1);},[]);useEffect(()=>{if(he(null),Se(null),Ye([]),Ie({}),Rt(false),Pt(null),b({}),we({canUndo:false,canRedo:false}),Ve([]),Mt(void 0),Et(void 0),ze(null),Ee.current=null,!t){x.current=null,Q(null),G(null),E(null);return}x.current=null,Q(null),G(null);let e=null,o=()=>{},n=()=>{},a=false,u=()=>{let C=n;n=()=>{};try{C();}catch{}};return initWasm().then(()=>{if(!a)try{e=openWorkbook(t,{collaborative:F,clientId:R}),z&&e.applyUpdate(z.slice()),x.current=e,o=e.onUpdate(()=>{if(!(a||!e))try{Q(e.sheetInfo()),ke(y=>y+1),Ie({}),ie(),E(null);}catch(y){E(y instanceof Error?y.message:String(y));}}),Q(e.sheetInfo()),G(selectionAt({row:0,col:0})),Pt(e),E(null),ie();let C=Y.current?.({handle:e,refreshProposals:ie});typeof C=="function"&&(n=C);}catch(C){u(),o(),o=()=>{},e?.dispose(),e=null,x.current=null,Q(null),G(null),E(C instanceof Error?C.message:String(C));}},C=>{a||(x.current=null,Q(null),G(null),E(C instanceof Error?C.message:String(C)));}),()=>{a=true,u(),o(),e?.dispose(),x.current=null;}},[t,F,R,z,ie]),useEffect(()=>{if(!(!O||!bt))return O(bt),()=>O(null)},[O,bt]);let ft=useCallback(()=>{let e=U.current,o=ae.current;if(!e||!o)return;let n=o.getContext("2d");if(!n)return;let a=window.devicePixelRatio||1,u=e.clientWidth,C=e.clientHeight;if(u===0||C===0)return;o.width=Math.round(u*a),o.height=Math.round(C*a),o.style.width=`${u}px`,o.style.height=`${C}px`;let y=u/L,ne=C/L,Le=x.current,pe;if(Le)try{pe=Le.displayList({x:e.scrollLeft/L,y:e.scrollTop/L,width:y,height:ne});}catch{return}else pe=yr(y,ne,s("editor.demoCellText"));paintDisplayList(n,pe,a*L),_.current=pe,Ke(pe);},[s,L]);useEffect(()=>{let e=U.current;if(!e)return;let o=()=>{I.current==null&&(I.current=requestAnimationFrame(()=>{I.current=null,ft();}));};ft(),e.addEventListener("scroll",o,{passive:true});let n=new ResizeObserver(o);return n.observe(e),()=>{e.removeEventListener("scroll",o),n.disconnect(),I.current!=null&&(cancelAnimationFrame(I.current),I.current=null);}},[ft,S,w,Fe]),useEffect(()=>{let e=x.current;if(!e||!f||!S){Ae(null);return}try{Ae(e.cell(p,f.focus.row,f.focus.col));}catch{Ae(null);}},[f,S,p,Fe]),useEffect(()=>{let e=()=>{J.current=false,_e(false);};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),useEffect(()=>{let e=x.current;if(!e||!f||!S){b({}),we({canUndo:false,canRedo:false}),Ve([]);return}let o=normalizeRange(f);try{let n=e.cell(p,o.top,o.left).a1,a=e.cell(p,o.bottom,o.right).a1,u=`${n}:${a}`;b(e.selectionFormatting(p,u)),we(e.historyState()),Ve(e.mergedRanges(p,u));}catch{b({}),we({canUndo:false,canRedo:false}),Ve([]);}},[f,S,p,Fe]);let je=useMemo(()=>!me||!S?null:buildA11yGrid(me,f,S.sheetNames[p]??"",{gridLabel:s("a11y.gridLabel"),rowHeaderLabel:s("a11y.rowHeaderLabel"),columnHeaderLabel:s("a11y.columnHeaderLabel"),cellLabel:s("a11y.cellLabel"),cellLabelSelected:s("a11y.cellLabelSelected"),emptyCellLabel:s("a11y.emptyCellLabel"),emptyCellLabelSelected:s("a11y.emptyCellLabelSelected")}),[me,f,S,p,s]),X=useCallback(()=>{U.current?.focus({preventScroll:true});},[]);useEffect(()=>{V&&B.current?.focus({preventScroll:true});},[V]);let N=useCallback(e=>{Q(e.sheetInfo),ke(o=>o+1),ie();},[ie]),qe=useCallback(e=>{let o=x.current;if(!o)return null;let n=normalizeRange(e),a=o.cell(p,n.top,n.left).a1,u=o.cell(p,n.bottom,n.right).a1;return `${a}:${u}`},[p]),se=useCallback(()=>xr(_.current,S,(U.current?.clientHeight??0)/L),[S,L]),Je=useCallback((e,o)=>{let n=ae.current,a=_.current?.grid;if(!n||!a)return null;let u=n.getBoundingClientRect();return cellAtPoint(a,(e-u.left)/L,(o-u.top)/L)},[L]),Qe=useCallback(e=>{let o=x.current;if(!o||!f)return;let{row:n,col:a}=f.focus,u=e??"";if(e===void 0)try{u=o.cell(p,n,a).input;}catch{u="";}he({row:n,col:a,value:u});},[f,p]),mt=useCallback(e=>{let o=x.current;if(!o||!V)return;v.current=true;let{row:n,col:a,value:u}=V;try{N(o.editCell(p,n,a,u));}catch(y){E(y instanceof Error?y.message:String(y));}he(null);let C=selectionAt({row:n,col:a});G(e?moveFocus(C,e,{limits:se()}):C),X();},[V,p,N,se,X]),bo=useCallback(()=>{v.current=true,he(null),X();},[X]),et=useCallback(()=>{let e=x.current;if(!e||!f)return;let o=normalizeRange(f),n=[];for(let a=o.top;a<=o.bottom;a++)for(let u=o.left;u<=o.right;u++)n.push({row:a,col:u,input:""});try{N(e.editCells(p,n));}catch(a){E(a instanceof Error?a.message:String(a));}},[f,p,N]),tt=useCallback(async()=>{let e=x.current;if(!e||!f)return;let o=normalizeRange(f);try{let n=e.cell(p,o.top,o.left).a1,a=e.cell(p,o.bottom,o.right).a1,u=e.rangeCells(p,`${n}:${a}`),C=toTsv(u.map(y=>y.map(ne=>({input:ne.input,isFormula:ne.isFormula}))));await navigator.clipboard.writeText(C);}catch{}},[f,p]),Dt=useCallback(async()=>{await tt(),et();},[tt,et]),At=useCallback(async()=>{let e=x.current;if(!e||!f)return;let o;try{o=await navigator.clipboard.readText();}catch{return}let n=fromTsv(o);if(n.length===0)return;let a=normalizeRange(f),u=[],C=1;n.forEach((y,ne)=>{C=Math.max(C,y.length),y.forEach((Le,pe)=>u.push({row:a.top+ne,col:a.left+pe,input:Le}));});try{N(e.editCells(p,u));}catch(y){E(y instanceof Error?y.message:String(y));return}G({anchor:{row:a.top,col:a.left},focus:{row:a.top+n.length-1,col:a.left+C-1}});},[f,p,N]),fo=useCallback(e=>{let o=x.current;if(!o||!f)return;let n=qe(f);if(n){if(e==="paintFormat"){if(Me){ze(null),Ee.current=null;return}try{ze(o.captureFormat(p,n));let a=normalizeRange(f);Ee.current=`${p}:${a.top}:${a.left}:${a.bottom}:${a.right}`;}catch(a){E(a instanceof Error?a.message:String(a));}return}try{let a;e==="currency"?a=o.setNumberFormat(p,n,"currency"):e==="percent"?a=o.setNumberFormat(p,n,"percent"):e==="increaseDecimal"?a=o.setNumberFormat(p,n,"increaseDecimal"):e==="decreaseDecimal"?a=o.setNumberFormat(p,n,"decreaseDecimal"):e==="bold"?a=o.patchRangeStyle(p,n,{bold:!ee.bold}):e==="italic"?a=o.patchRangeStyle(p,n,{italic:!ee.italic}):e==="strikethrough"?a=o.patchRangeStyle(p,n,{strikethrough:!ee.strikethrough}):e.type==="numberFormat"?a=e.value==="custom"?o.setNumberFormat(p,n,{type:"custom",pattern:ee.numberFormatPattern??"0.00"}):o.setNumberFormat(p,n,e.value):e.type==="fontFamily"?a=o.patchRangeStyle(p,n,{fontFamily:e.value}):e.type==="fontSize"?a=o.patchRangeStyle(p,n,{fontSize:e.value}):e.type==="textColor"?a=o.patchRangeStyle(p,n,{textColor:e.value}):e.type==="fillColor"?a=o.patchRangeStyle(p,n,{fillColor:e.value}):e.type==="borderPreset"?a=o.patchRangeStyle(p,n,{border:{preset:e.value,style:dt??ee.borderStyle??"solid",color:pt??ee.borderColor??"#000000"}}):e.type==="borderStyle"?(Mt(e.value),a=o.patchRangeStyle(p,n,{border:{style:e.value}})):e.type==="borderColor"?(Et(e.value),a=o.patchRangeStyle(p,n,{border:{color:e.value}})):e.type==="horizontalAlignment"?a=o.patchRangeStyle(p,n,{horizontalAlignment:e.value}):e.type==="verticalAlignment"?a=o.patchRangeStyle(p,n,{verticalAlignment:e.value}):a=o.patchRangeStyle(p,n,{textWrapping:e.value}),N(a),X();}catch(a){E(a instanceof Error?a.message:String(a));}}},[f,qe,Me,p,ee,dt,pt,N,X]);useEffect(()=>{let e=x.current;if(!e||!f||!Me||Te)return;let o=normalizeRange(f);if(`${p}:${o.top}:${o.left}:${o.bottom}:${o.right}`===Ee.current)return;let a=qe(f);if(a)try{N(e.applyFormat(p,a,Me)),ze(null),Ee.current=null,X();}catch(u){E(u instanceof Error?u.message:String(u));}},[f,Me,Te,p,qe,N,X]);let ht=useCallback(()=>{let e=x.current;if(e)try{N(e.undo());}catch(o){E(o instanceof Error?o.message:String(o));}},[N]),ot=useCallback(()=>{let e=x.current;if(e)try{N(e.redo());}catch(o){E(o instanceof Error?o.message:String(o));}},[N]),mo=useCallback(()=>window.print(),[]),ho=useCallback(()=>{},[]),go=useCallback(e=>{let o=x.current;if(!o||!f)return;let n=normalizeRange(f),a=(y,ne)=>({row:y,col:ne}),u=(y,ne,Le,pe)=>({start:a(y,ne),end:a(Le,pe)}),C=[];if(e==="all")C.push({type:"mergeCells",sheet:p,range:u(n.top,n.left,n.bottom,n.right)});else if(e==="horizontal")for(let y=n.top;y<=n.bottom;y++)C.push({type:"mergeCells",sheet:p,range:u(y,n.left,y,n.right)});else if(e==="vertical")for(let y=n.left;y<=n.right;y++)C.push({type:"mergeCells",sheet:p,range:u(n.top,y,n.bottom,y)});else for(let y of ct)C.push({type:"unmergeCells",sheet:p,range:u(y.start.row,y.start.col,y.end.row,y.end.col)});if(C.length!==0)try{N(o.applyOps(C)),X();}catch(y){E(y instanceof Error?y.message:String(y));}},[f,p,ct,N,X]),yo=useCallback((e,o)=>{let n=x.current;if(n)try{N(n.acceptProposal(e,{force:o})),Ie(({[e]:a,...u})=>u),ie(),X();}catch(a){a instanceof StaleProposalError?Ie(u=>({...u,[e]:a.cells})):E(a instanceof Error?a.message:String(a));}},[N,ie,X]),xo=useCallback(e=>{let o=x.current;if(o)try{o.rejectProposal(e),Ie(({[e]:n,...a})=>a),ie();}catch(n){E(n instanceof Error?n.message:String(n));}},[ie]),gt=useCallback(()=>{let e=x.current;if(e)try{let o=e.save();i?i(o):so(o,r??"workbook.xlsx",gr);}catch(o){E(o instanceof Error?o.message:String(o));}},[i,r]),vo=useCallback(()=>{let e=x.current,o=U.current;if(!(!e||!o))try{let n=e.renderPng({x:o.scrollLeft/L,y:o.scrollTop/L,width:o.clientWidth/L,height:o.clientHeight/L});so(n,vr(r),"image/png");}catch(n){E(n instanceof Error?n.message:String(n));}},[r,L]),Ft=useCallback(e=>{let o=x.current;if(!o||!f||Ce==null)return;let{row:n,col:a}=f.focus;try{N(o.editCell(p,n,a,Ce));}catch(u){E(u instanceof Error?u.message:String(u));}Se(null),e&&G(u=>u&&moveFocus(u,e,{limits:se()}));},[f,Ce,p,N,se]),So=useCallback(e=>{if(!x.current||!f||!S||V)return;let n=e.metaKey||e.ctrlKey,a=e.key.toLowerCase();if(n){if(a==="c"){tt(),e.preventDefault();return}if(a==="v"){At(),e.preventDefault();return}if(a==="x"){Dt(),e.preventDefault();return}if(a==="z"){e.shiftKey?ot():ht(),e.preventDefault();return}if(a==="y"){ot(),e.preventDefault();return}if(a==="s"){gt(),e.preventDefault();return}}let u=selectionKeyReducer(f,{key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey},se());switch(u.type){case "move":G(u.selection),e.preventDefault();break;case "startEdit":Qe(u.initialInput),e.preventDefault();break;case "clear":et(),e.preventDefault();break;}},[f,S,V,se,tt,At,Dt,ht,ot,gt,Qe,et]),wo=useCallback(e=>{if(!f)return;let o=Je(e.clientX,e.clientY);o&&(e.shiftKey?G(n=>n&&extendTo(n,o,se())):G(selectionAt(o)),J.current=true,_e(true),X());},[f,Je,se,X]),Co=useCallback(e=>{if(!J.current)return;let o=Je(e.clientX,e.clientY);o&&G(n=>n&&extendTo(n,o,se()));},[Je,se]),ko=useCallback(()=>{f&&Qe();},[f,Qe]),Re=me?.grid,zt=Re&&f?rangeRect(Re,normalizeRange(f)):null,It=Re&&f?cellRect(Re,f.focus.row,f.focus.col):null,Bt=Re&&V?cellRect(Re,V.row,V.col):null,Be=zt?Tt(zt,L):null,He=It?Tt(It,L):null,We=Bt?Tt(Bt,L):null,To=S?S.contentWidth*L:void 0,Mo=S?S.contentHeight*L:void 0,Eo=Ce??D?.input??"",Pe=f?normalizeRange(f):null,Ro=Pe?Pe.bottom-Pe.top+1:1,Po=Pe?Pe.right-Pe.left+1:1,Lo=e=>{let o=x.current;if(o)try{o.setActiveSheet(e);let n=U.current;n&&(n.scrollLeft=0,n.scrollTop=0),G(selectionAt({row:0,col:0})),he(null),Se(null),ze(null),Ee.current=null,Q(o.sheetInfo());}catch(n){E(n instanceof Error?n.message:String(n));}};return jsxs("div",{className:g,role:"application","aria-label":s("editor.appLabel"),style:{position:"relative",display:"flex",flexDirection:"column",width:"100%",height:"100%",minWidth:0,color:"#202124",background:"#ffffff",fontFamily:"ui-sans-serif, system-ui, sans-serif"},children:[jsx("div",{ref:q,"data-testid":"xlsx-toolbar",style:fe.shell,children:jsxs(Ge,{currentFormatting:{...ee,borderStyle:dt??ee.borderStyle,borderColor:pt??ee.borderColor,paintFormat:Me!==null},selectionShape:{rows:Ro,columns:Po,canUnmerge:ct.length>0},onSearchMenus:ho,onUndo:ht,onRedo:ot,canUndo:d.canUndo,canRedo:d.canRedo,onPrint:mo,zoom:L,onZoomChange:ge,onFormat:fo,onMerge:go,children:[jsx(Ge.Toolbar,{}),jsxs("div",{style:fe.rail,role:"group","aria-label":s("toolbar.formulaBarLabel"),children:[jsxs(K,{style:{...fe.group,paddingLeft:0},label:s("toolbar.fileActionsLabel"),children:[jsx(H,{testId:"xlsx-save",onClick:gt,disabled:!S,title:s("toolbar.save"),children:jsx(k,{name:"save",size:18})}),jsx(H,{testId:"xlsx-export-png",onClick:vo,disabled:!S||!uo,title:s("toolbar.exportPng"),children:jsx(k,{name:"image",size:18})})]}),jsxs("div",{style:fe.formulaGroup,role:"group","aria-label":s("toolbar.formulaBarLabel"),children:[jsx("input",{"data-testid":"xlsx-name-box",readOnly:true,value:D?.a1??"",placeholder:s("toolbar.nameBoxPlaceholder"),"aria-label":s("toolbar.nameBoxPlaceholder"),style:fe.nameBox}),jsx("span",{style:fe.formulaMark,"aria-hidden":"true",children:"fx"}),jsx("input",{"data-testid":"xlsx-formula-input",value:Eo,placeholder:s("toolbar.formulaPlaceholder"),"aria-label":s("toolbar.formulaPlaceholder"),disabled:!S,onChange:e=>Se(e.target.value),onKeyDown:e=>{e.key==="Enter"?(Ft(e.shiftKey?"up":"down"),X(),e.preventDefault()):e.key==="Escape"&&(Se(null),X(),e.preventDefault());},onBlur:()=>Ft(),style:fe.formulaInput})]}),Lt&&jsx("div",{style:fe.proposals,children:jsxs(H,{testId:"xlsx-proposals-button",onClick:()=>Rt(e=>!e),disabled:!S,active:ut,ariaExpanded:ut,title:s("proposals.panelLabel"),style:{width:Ze.length>0?42:28},children:[jsx(k,{name:"proposals",size:18}),Ze.length>0&&jsx("span",{"data-testid":"xlsx-proposals-count",style:fe.count,children:Ze.length})]})})]})]})}),Lt&&ut&&jsx(ro,{proposals:Ze,staleFor:po,onAccept:yo,onReject:xo,style:{top:Xe+4,right:8,width:"min(320px, calc(100% - 16px))",maxHeight:`min(420px, calc(100% - ${Xe+12}px))`}}),jsxs("div",{ref:U,"data-testid":"xlsx-scroll",tabIndex:0,onKeyDown:So,onMouseDown:wo,onMouseMove:Co,onDoubleClick:ko,style:{position:"relative",flex:1,overflow:"auto",minHeight:0,outline:"none"},children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:To??"100%",height:Mo??"100%"}}),jsxs("div",{style:{position:"sticky",top:0,left:0,width:0,height:0},children:[jsx("canvas",{ref:ae,style:{display:"block",position:"absolute",top:0,left:0}}),jsxs("div",{"data-testid":"xlsx-overlay-host",style:{position:"absolute",top:0,left:0,width:0,height:0,pointerEvents:"none"},children:[Be&&jsx("div",{"data-testid":"xlsx-selection",style:{position:"absolute",left:Be.x,top:Be.y,width:Be.w,height:Be.h,boxSizing:"border-box",border:`1px solid ${it}`,background:"rgba(33, 115, 70, 0.12)"}}),He&&!V&&jsx("div",{style:{position:"absolute",left:He.x,top:He.y,width:He.w,height:He.h,boxSizing:"border-box",border:`2px solid ${it}`}}),V&&We&&jsx("input",{ref:B,"data-testid":"xlsx-cell-editor",value:V.value,onChange:e=>he(o=>o&&{...o,value:e.target.value}),onKeyDown:e=>{e.stopPropagation(),e.key==="Enter"?(mt(e.shiftKey?"up":"down"),e.preventDefault()):e.key==="Tab"?(mt(e.shiftKey?"left":"right"),e.preventDefault()):e.key==="Escape"&&(bo(),e.preventDefault());},onBlur:()=>{if(v.current){v.current=false;return}mt();},style:{position:"absolute",left:We.x,top:We.y,width:We.w,height:We.h,boxSizing:"border-box",border:`2px solid ${it}`,padding:"0 3px",font:`${13*L}px system-ui, sans-serif`,background:"#ffffff",pointerEvents:"auto",outline:"none"}})]})]})]}),je&&jsxs("div",{style:Sr,role:"grid","aria-label":je.label,children:[jsxs("div",{role:"row",children:[jsx("span",{role:"columnheader"}),je.columnHeaders.map(e=>jsx("span",{role:"columnheader",children:e.label},e.col))]}),je.rows.map(e=>jsxs("div",{role:"row",children:[jsx("span",{role:"rowheader",children:e.header}),e.cells.map(o=>jsx("span",{role:"gridcell","aria-selected":o.selected,children:o.label},o.col))]},e.row))]}),w&&jsxs("div",{"data-testid":"xlsx-error",role:"alert",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",padding:16,textAlign:"center",color:"#b00020"},children:[s("editor.openError"),": ",w]}),S&&S.sheetNames.length>0&&jsx("div",{"data-testid":"xlsx-sheet-tabs",role:"tablist","aria-label":s("editor.sheetTabsLabel"),style:{display:"flex",gap:2,padding:"4px 6px",borderTop:"1px solid #e0e0e0",background:"#fafafa",overflowX:"auto"},children:S.sheetNames.map((e,o)=>{let n=o===S.activeSheet;return jsx("button",{role:"tab","aria-selected":n,onClick:()=>Lo(o),style:{border:"none",padding:"4px 12px",cursor:"pointer",borderBottom:n?`2px solid ${it}`:"2px solid transparent",fontWeight:n?600:400,background:n?"#ffffff":"transparent"},children:e},o)})})]})}export{Ge as EditorToolbar,De as EditorToolbarContext,rt as LocaleProvider,nt as Toolbar,H as ToolbarButton,ce as ToolbarDropdown,K as ToolbarGroup,te as ToolbarMenuItem,Oe as ToolbarMenuSeparator,$e as ToolbarSeparator,wr as XlsxEditor,nt as XlsxToolbar,Io as useEditorToolbar,ye as useTranslation};
|
|
1
|
+
import {createContext,useMemo,useContext,useState,useRef,useCallback,useEffect}from'react';import {isPngExportAvailable,isProposalsAvailable,initWasm,openWorkbook,selectionAt,paintDisplayList,normalizeRange,buildA11yGrid,cellAtPoint,chartRegionAtPoint,moveFocus,toTsv,fromTsv,StaleProposalError,selectionKeyReducer,extendTo,hyperlinkAtCell,safeExternalHyperlink,parseHyperlinkLocation,rangeRect,cellRect}from'@betteroffice/xlsx';import {en,deepMerge,createT}from'@betteroffice/xlsx-i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {normalizeAwarenessColor,resolveAwarenessCursor,AWARENESS_LABEL_DURATION_MS}from'@betteroffice/xlsx/collaboration';var Eo=createContext(en),Po=createContext("en");function St({i18n:t,children:r}){let i=typeof t?._lang=="string"?t._lang:"en",d=useMemo(()=>deepMerge(en,t),[t]);return jsx(Po.Provider,{value:i,children:jsx(Eo.Provider,{value:d,children:r})})}function Me(){let t=useContext(Eo),r=useContext(Po);return {t:useMemo(()=>createT(t,r),[t,r])}}var _e=createContext(null);function Pr(){let t=useContext(_e);if(!t)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return t}function L({name:t,size:r=20,style:i}){return jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"inline-flex",flexShrink:0,...i},children:[t==="search"&&jsxs(Fragment,{children:[jsx("circle",{cx:"10.5",cy:"10.5",r:"6"}),jsx("path",{d:"m15 15 4.5 4.5"})]}),t==="undo"&&jsx("path",{d:"m9 7-5 5 5 5M5 12h9a6 6 0 0 1 6 6"}),t==="redo"&&jsx("path",{d:"m15 7 5 5-5 5m4-5h-9a6 6 0 0 0-6 6"}),t==="print"&&jsxs(Fragment,{children:[jsx("path",{d:"M7 9V4h10v5M7 18H5a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),jsx("path",{d:"M7 14h10v6H7z"}),jsx("path",{d:"M17.5 12h.01"})]}),t==="formatPaint"&&jsxs(Fragment,{children:[jsx("path",{d:"M5 4h11v5H5zM8 9v3h5V9"}),jsx("path",{d:"M10.5 12v8"})]}),t==="decimalDecrease"&&jsxs(Fragment,{children:[jsx("path",{d:"M5 7h1M9 7h1M14 7h1M18 7h1"}),jsx("path",{d:"M5 16h1M9 16h1"}),jsx("path",{d:"m15 12-4 4 4 4M11 16h8"})]}),t==="decimalIncrease"&&jsxs(Fragment,{children:[jsx("path",{d:"M5 7h1M9 7h1"}),jsx("path",{d:"M5 16h1M9 16h1M14 16h1M18 16h1"}),jsx("path",{d:"m15 3 4 4-4 4M19 7h-8"})]}),t==="bold"&&jsx("path",{d:"M7 4h6a4 4 0 0 1 0 8H7zm0 8h7a4 4 0 0 1 0 8H7z"}),t==="italic"&&jsx("path",{d:"M10 4h8M6 20h8M14 4 10 20"}),t==="strikethrough"&&jsx(Fragment,{children:jsx("path",{d:"M5 12h14M8 7.5A4.5 4.5 0 0 1 12.5 4c2.2 0 3.7 1 4.5 2.5M8 16.5c.8 2.1 2.4 3.5 5 3.5 2.8 0 4.5-1.4 4.5-3.5 0-2.3-2-3.3-5.5-4.5"})}),t==="textColor"&&jsxs(Fragment,{children:[jsx("path",{d:"m7 16 5-12 5 12M9 11h6"}),jsx("path",{d:"M5 20h14",strokeWidth:"3"})]}),t==="fillColor"&&jsxs(Fragment,{children:[jsx("path",{d:"m7 4 10 10-6 6-7-7zM5 12h12"}),jsx("path",{d:"M18 17c0-1 1-2 1-2s1 1 1 2a1 1 0 0 1-2 0Z"})]}),t==="borders"&&jsx(Fragment,{children:jsx("path",{d:"M4 4h16v16H4zM12 4v16M4 12h16"})}),t==="merge"&&jsxs(Fragment,{children:[jsx("path",{d:"M4 5h16v14H4z"}),jsx("path",{d:"m8 9 3 3-3 3M16 9l-3 3 3 3"})]}),t==="alignLeft"&&jsx("path",{d:"M4 6h16M4 10h11M4 14h16M4 18h11"}),t==="verticalAlignCenter"&&jsxs(Fragment,{children:[jsx("path",{d:"M4 4h16M4 20h16M8 12h8"}),jsx("path",{d:"m10 9 2 3 2-3M10 15l2-3 2 3"})]}),t==="wrap"&&jsxs(Fragment,{children:[jsx("path",{d:"M4 6h16M4 11h12a3 3 0 0 1 0 6h-3"}),jsx("path",{d:"m15 14-3 3 3 3M4 17h5"})]}),t==="more"&&jsxs(Fragment,{children:[jsx("circle",{cx:"5",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),jsx("circle",{cx:"19",cy:"12",r:"1",fill:"currentColor",stroke:"none"})]}),t==="chevronDown"&&jsx("path",{d:"m7 10 5 5 5-5"}),t==="remove"&&jsx("path",{d:"M5 12h14"}),t==="add"&&jsx("path",{d:"M12 5v14M5 12h14"}),t==="check"&&jsx("path",{d:"m5 12 4 4L19 6"}),t==="save"&&jsx("path",{d:"M12 3v11m0 0 4-4m-4 4-4-4M5 19h14"}),t==="image"&&jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),jsx("circle",{cx:"8.5",cy:"9.5",r:"1.25"}),jsx("path",{d:"m6 17 4.5-4.5 3.25 3.25L16 13.5l2 2"})]}),t==="proposals"&&jsxs(Fragment,{children:[jsx("path",{d:"m12 3 1.25 3.75L17 8l-3.75 1.25L12 13l-1.25-3.75L7 8l3.75-1.25L12 3Z"}),jsx("path",{d:"m18 14 .75 2.25L21 17l-2.25.75L18 20l-.75-2.25L15 17l2.25-.75L18 14Z"})]})]})}var D={text:"#3c4043",muted:"#5f6368",disabled:"#9aa0a6",hover:"#e2e7ef",active:"#d3e3fd",border:"#c7cacf",surface:"#ffffff",rail:"#edf2fa"},Ar={appearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:2,minWidth:28,height:28,padding:"0 5px",border:0,borderRadius:4,color:D.text,font:"500 13px ui-sans-serif, system-ui, sans-serif",lineHeight:1,whiteSpace:"nowrap",boxSizing:"border-box"};function Do(t,r,i,d){return {...Ar,background:r?D.active:i&&!t?D.hover:"transparent",color:t?D.disabled:D.text,cursor:t?"default":"pointer",opacity:t?.48:1,...d}}function _({active:t=false,disabled:r=false,title:i,onClick:d,children:p,style:b,testId:s,ariaExpanded:R}){let[P,k]=useState(false);return jsx("button",{type:"button","data-testid":s,disabled:r,"aria-label":i,"aria-pressed":t||void 0,"aria-expanded":R,title:i,onMouseDown:I=>I.preventDefault(),onMouseEnter:()=>k(true),onMouseLeave:()=>k(false),onClick:r?void 0:d,style:Do(r,t,P,b),children:p})}function j({label:t,children:r,style:i}){return jsx("div",{role:"group","aria-label":t,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto",...i},children:r})}function rt(){return jsx("div",{role:"separator",style:{width:1,height:24,margin:"0 5px",background:D.border,flex:"0 0 auto"}})}function he({title:t,trigger:r,children:i,disabled:d=false,active:p=false,menuWidth:b=220,style:s,testId:R}){let[P,k]=useState(false),[I,z]=useState(false),[K,X]=useState({top:0,left:0}),O=useRef(null),v=useRef(null),F=useCallback(()=>k(false),[]);return useEffect(()=>{if(!P||!O.current)return;let N=O.current.getBoundingClientRect(),Y=Math.min(N.left,Math.max(8,window.innerWidth-b-8));X({top:N.bottom+4,left:Y});},[P,b]),useEffect(()=>{if(!P)return;let N=q=>{let oe=q.target;!O.current?.contains(oe)&&!v.current?.contains(oe)&&F();},Y=q=>{q.key==="Escape"&&F();},M=()=>F();return document.addEventListener("mousedown",N),document.addEventListener("keydown",Y),window.addEventListener("scroll",M,true),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",Y),window.removeEventListener("scroll",M,true);}},[P,F]),jsxs("div",{style:{position:"relative",display:"inline-flex",flex:"0 0 auto"},children:[jsx("button",{ref:O,type:"button","data-testid":R,disabled:d,"aria-label":t,"aria-haspopup":"menu","aria-expanded":P,title:t,onMouseDown:N=>N.preventDefault(),onMouseEnter:()=>z(true),onMouseLeave:()=>z(false),onClick:()=>!d&&k(N=>!N),style:Do(d,p||P,I,s),children:r}),P&&jsx("div",{ref:v,role:"menu","aria-label":t,onMouseDown:N=>N.preventDefault(),style:{position:"fixed",top:K.top,left:K.left,zIndex:1e4,width:b,maxHeight:"min(440px, calc(100vh - 16px))",overflowY:"auto",padding:6,border:`1px solid ${D.border}`,borderRadius:8,background:D.surface,boxShadow:"0 4px 16px rgba(60, 64, 67, 0.24)",boxSizing:"border-box"},children:i(F)})]})}function ce({label:t,icon:r,selected:i=false,disabled:d=false,onClick:p,close:b}){let[s,R]=useState(false);return jsxs("button",{type:"button",role:"menuitem",disabled:d,"aria-label":t,onMouseEnter:()=>R(true),onMouseLeave:()=>R(false),onClick:()=>{d||(p?.(),b?.());},style:{appearance:"none",display:"flex",alignItems:"center",gap:10,width:"100%",minHeight:32,padding:"5px 9px",border:0,borderRadius:4,background:s&&!d?D.hover:"transparent",color:d?D.disabled:D.text,cursor:d?"default":"pointer",opacity:d?.48:1,font:"400 13px ui-sans-serif, system-ui, sans-serif",textAlign:"left",boxSizing:"border-box"},children:[jsx("span",{style:{display:"inline-grid",placeItems:"center",width:20,flex:"0 0 auto"},children:r}),jsx("span",{style:{flex:1},children:t}),i&&jsx("span",{"aria-hidden":"true",children:"\u2713"})]})}function nt(){return jsx("div",{role:"separator",style:{height:1,margin:"5px 2px",background:D.border}})}function Ot({mode:t,value:r,label:i,onChange:d,disabled:p=false}){let[b,s]=useState(false);return jsxs("label",{title:i,"aria-label":i,style:{position:"relative",display:"inline-grid",placeItems:"center",width:28,height:28,borderRadius:4,background:b&&!p?D.hover:"transparent",color:p?D.disabled:D.text,cursor:p?"default":"pointer",opacity:p?.48:1,boxSizing:"border-box"},onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),children:[jsx(L,{name:t==="text"?"textColor":"fillColor",size:20}),jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:5,right:5,bottom:2,height:3,borderRadius:2,background:r}}),jsx("input",{type:"color",value:r,disabled:p,"aria-label":i,onChange:R=>d?.(R.target.value),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0}})]})}function Gt({value:t,options:r,label:i,onCommit:d,disabled:p=false,width:b=72,inputStyle:s,testId:R}){let[P,k]=useState(t),[I,z]=useState(false),[K,X]=useState({top:0,left:0,width:b}),O=useRef(null),v=useRef(null),F=useRef(null);useEffect(()=>k(t),[t]);let N=useCallback(()=>z(false),[]);useEffect(()=>{if(!I||!O.current)return;let M=O.current.getBoundingClientRect();X({top:M.bottom+4,left:M.left,width:Math.max(M.width,b)});},[I,b]),useEffect(()=>{if(!I)return;let M=oe=>{let re=oe.target;!O.current?.contains(re)&&!v.current?.contains(re)&&N();},q=oe=>{oe.key==="Escape"&&(k(t),N());};return document.addEventListener("mousedown",M),document.addEventListener("keydown",q),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",q);}},[I,N,t]);let Y=useCallback(()=>{!p&&d&&P.trim()&&d(P.trim()),k(t);},[p,d,P,t]);return jsxs("div",{ref:O,style:{display:"inline-flex",alignItems:"center",width:b,height:28,border:`1px solid ${D.border}`,borderRadius:4,background:p?"rgba(255,255,255,0.5)":D.surface,opacity:p?.48:1,boxSizing:"border-box",flex:"0 0 auto"},children:[jsx("input",{ref:F,"data-testid":R,role:"combobox","aria-label":i,"aria-autocomplete":"list","aria-expanded":I,disabled:p,value:P,onFocus:M=>{p||(z(true),M.currentTarget.select());},onChange:M=>k(M.target.value),onKeyDown:M=>{M.key==="Enter"?(Y(),N(),M.currentTarget.blur()):M.key==="ArrowDown"&&(z(true),M.preventDefault());},onBlur:()=>{requestAnimationFrame(()=>{v.current?.contains(document.activeElement)||Y();});},style:{appearance:"none",width:"calc(100% - 22px)",height:26,padding:"0 2px 0 7px",border:0,outline:0,background:"transparent",color:D.text,font:"500 13px ui-sans-serif, system-ui, sans-serif",boxSizing:"border-box",...s}}),jsx("button",{type:"button",disabled:p,tabIndex:-1,"aria-label":i,title:i,onMouseDown:M=>M.preventDefault(),onClick:()=>{p||(z(M=>!M),F.current?.focus());},style:{appearance:"none",display:"grid",placeItems:"center",width:21,height:26,padding:0,border:0,background:"transparent",color:D.muted,cursor:p?"default":"pointer"},children:jsx(L,{name:"chevronDown",size:14})}),I&&!p&&jsx("div",{ref:v,role:"listbox","aria-label":i,style:{position:"fixed",top:K.top,left:K.left,zIndex:1e4,width:K.width,maxHeight:260,overflowY:"auto",padding:4,border:`1px solid ${D.border}`,borderRadius:6,background:D.surface,boxShadow:"0 4px 16px rgba(60, 64, 67, 0.24)",boxSizing:"border-box"},children:r.map(M=>jsx("button",{type:"button",role:"option","aria-selected":M.value===t,onMouseDown:q=>q.preventDefault(),onClick:()=>{k(M.label),d?.(M.value),N();},style:{appearance:"none",display:"block",width:"100%",minHeight:28,padding:"4px 7px",border:0,borderRadius:3,background:M.value===t?D.active:"transparent",color:D.text,cursor:"pointer",font:"400 13px ui-sans-serif, system-ui, sans-serif",textAlign:"left"},children:M.label},M.value))})]})}var Wr=[.5,.75,.9,1,1.25,1.5,2],$r=["Arial","Calibri","Cambria","Georgia","Roboto","Times New Roman","Verdana"],Or=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],Ur=["automatic","plainText","number","percent","scientific","currency","date","time","custom"],_r=["all","inner","horizontal","vertical","outer","left","top","right","bottom","none"],Xr=["solid","dashed","dotted","double"],Gr=["left","center","right"],Kr=["top","middle","bottom"],Yr=["overflow","wrap","clip"];function Vr(t){let r={};for(let i of Object.keys(t))t[i]!==void 0&&(r[i]=t[i]);return r}function Zr(t){let r=useContext(_e);return r?{...r,...Vr(t)}:t}function Ho({preset:t}){let r=i=>t===i||t==="all"||t==="outer"?2:.6;return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","aria-hidden":"true",children:[t!=="none"&&jsxs(Fragment,{children:[jsx("path",{d:"M3 3h14",strokeWidth:r("top")}),jsx("path",{d:"M17 3v14",strokeWidth:r("right")}),jsx("path",{d:"M3 17h14",strokeWidth:r("bottom")}),jsx("path",{d:"M3 3v14",strokeWidth:r("left")}),(t==="all"||t==="inner"||t==="horizontal")&&jsx("path",{d:"M3 10h14",strokeWidth:"1.5"}),(t==="all"||t==="inner"||t==="vertical")&&jsx("path",{d:"M10 3v14",strokeWidth:"1.5"})]}),t==="none"&&jsx("path",{d:"M4 4h12v12H4zM3 17 17 3",strokeWidth:"1.5"})]})}function No({value:t}){let r=t==="left"?3:t==="center"?5:7,i=t==="left"?15:t==="center"?17:19;return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:[jsx("path",{d:"M3 4h14M3 10h14M3 16h14"}),jsx("path",{d:`M${r} 7h${i-r}M${r} 13h${i-r}`})]})}function Bo({value:t}){return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:[jsx("path",{d:"M3 3h14M3 17h14"}),jsx("path",{d:`M6 ${t==="top"?5:t==="middle"?10:15}h8`}),jsx("path",{d:t==="top"?"m8 8 2-3 2 3":t==="bottom"?"m8 12 2 3 2-3":"m8 7 2 3 2-3m-4 6 2-3 2 3"})]})}function jr({value:t}){return jsx("svg",{width:"44",height:"12",viewBox:"0 0 44 12",fill:"none",stroke:"currentColor","aria-hidden":"true",children:t==="double"?jsx(Fragment,{children:jsx("path",{d:"M2 4h40M2 8h40"})}):jsx("path",{d:"M2 6h40",strokeWidth:"2",strokeDasharray:t==="dashed"?"7 4":t==="dotted"?"1 4":void 0})})}function Wo(t,r,i){return i>0?r.find(d=>d>t)??t+1:[...r].reverse().find(d=>d<t)??Math.max(1,t-1)}function Ct(t){let{t:r}=Me(),{currentFormatting:i={},selectionShape:d,onFormat:p,onMerge:b,onSearchMenus:s,onUndo:R,onRedo:P,canUndo:k=false,canRedo:I=false,onPrint:z,zoom:K=1,onZoomChange:X,fontFamilies:O=$r,fontSizes:v=Or,disabled:F=false,className:N,style:Y,children:M}=Zr(t),q=useRef(null),[oe,re]=useState(Number.POSITIVE_INFINITY),C=!F&&!!p,$=!F&&!!b,Ce=i.fontSize??10,Te=(d?.rows??1)>1,Xe=(d?.columns??1)>1,S=Te||Xe;useEffect(()=>{let g=q.current;if(!g)return;let h=()=>re(g.clientWidth);h();let T=new ResizeObserver(h);return T.observe(g),()=>T.disconnect()},[]);let ue=useMemo(()=>Wr.map(g=>({value:`${g*100}%`,label:`${g*100}%`})),[]),Ge=useMemo(()=>v.map(g=>({value:String(g),label:String(g)})),[v]),y=g=>{C&&p?.(g);},ct=g=>jsx(Fragment,{children:Ur.map(h=>jsx(ce,{label:r(`toolbar.numberFormats.${h}`),selected:i.numberFormat===h,disabled:!C,onClick:()=>y({type:"numberFormat",value:h}),close:g},h))}),Ke=g=>jsxs(Fragment,{children:[_r.map(h=>jsx(ce,{icon:jsx(Ho,{preset:h}),label:r(`toolbar.borderPresets.${h}`),selected:i.borderPreset===h,disabled:!C,onClick:()=>y({type:"borderPreset",value:h}),close:g},h)),jsx(nt,{}),Xr.map(h=>jsx(ce,{icon:jsx(jr,{value:h}),label:r(`toolbar.borderStyles.${h}`),selected:i.borderStyle===h,disabled:!C,onClick:()=>y({type:"borderStyle",value:h}),close:g},h)),jsx(nt,{}),jsxs("label",{style:{position:"relative",display:"flex",alignItems:"center",gap:10,minHeight:32,padding:"5px 9px",color:D.text,font:"400 13px ui-sans-serif, system-ui, sans-serif",cursor:C?"pointer":"default"},children:[jsx("span",{style:{width:20,height:5,borderRadius:2,background:i.borderColor??"#000000"}}),jsx("span",{children:r("toolbar.borderColor")}),jsx("input",{type:"color",value:i.borderColor??"#000000",disabled:!C,"aria-label":r("toolbar.borderColor"),onChange:h=>y({type:"borderColor",value:h.target.value}),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0}})]})]}),pe=g=>jsxs(Fragment,{children:[jsx(ce,{label:r("toolbar.merge.all"),disabled:!$||!S,onClick:()=>b?.("all"),close:g}),jsx(ce,{label:r("toolbar.merge.horizontal"),disabled:!$||!Xe,onClick:()=>b?.("horizontal"),close:g}),jsx(ce,{label:r("toolbar.merge.vertical"),disabled:!$||!Te,onClick:()=>b?.("vertical"),close:g}),jsx(nt,{}),jsx(ce,{label:r("toolbar.merge.unmerge"),disabled:!$||!d?.canUnmerge,onClick:()=>b?.("unmerge"),close:g})]}),dt=g=>jsx(Fragment,{children:Gr.map(h=>jsx(ce,{icon:jsx(No,{value:h}),label:r(`toolbar.horizontalAlign.${h}`),selected:i.horizontalAlignment===h,disabled:!C,onClick:()=>y({type:"horizontalAlignment",value:h}),close:g},h))}),m=g=>jsx(Fragment,{children:Kr.map(h=>jsx(ce,{icon:jsx(Bo,{value:h}),label:r(`toolbar.verticalAlign.${h}`),selected:i.verticalAlignment===h,disabled:!C,onClick:()=>y({type:"verticalAlignment",value:h}),close:g},h))}),J=g=>jsx(Fragment,{children:Yr.map(h=>jsx(ce,{label:r(`toolbar.wrapping.${h}`),selected:i.textWrapping===h,disabled:!C,onClick:()=>y({type:"textWrapping",value:h}),close:g},h))}),B=[{key:"search",width:29,node:jsx(j,{label:r("toolbar.groups.search"),children:jsx(_,{title:r("toolbar.searchMenus"),onClick:s,testId:"xlsx-search-menus",children:jsx(L,{name:"search"})})})},{key:"history",width:58,node:jsxs(j,{label:r("toolbar.groups.history"),children:[jsx(_,{title:r("toolbar.undo"),disabled:F||!k||!R,onClick:R,testId:"xlsx-undo",children:jsx(L,{name:"undo"})}),jsx(_,{title:r("toolbar.redo"),disabled:F||!I||!P,onClick:P,testId:"xlsx-redo",children:jsx(L,{name:"redo"})})]})},{key:"print",width:29,node:jsx(j,{label:r("toolbar.groups.print"),children:jsx(_,{title:r("toolbar.print"),disabled:F||!z,onClick:z,children:jsx(L,{name:"print"})})})},{key:"paint",width:29,node:jsx(j,{label:r("toolbar.groups.paintFormat"),children:jsx(_,{title:r("toolbar.paintFormat"),active:i.paintFormat,disabled:!C,onClick:()=>y("paintFormat"),children:jsx(L,{name:"formatPaint"})})})},{key:"zoom",width:82,node:jsx(j,{label:r("toolbar.groups.zoom"),children:jsx(Gt,{value:`${Math.round(K*100)}%`,options:ue,label:r("toolbar.zoomValue",{value:`${Math.round(K*100)}%`}),disabled:F||!X,onCommit:g=>{let h=Number.parseFloat(g.replace("%",""));Number.isFinite(h)&&h>=25&&h<=400&&X?.(h/100);},width:76,testId:"xlsx-zoom"})})},{key:"number",width:202,node:jsxs(Fragment,{children:[jsx(rt,{}),jsxs(j,{label:r("toolbar.groups.number"),children:[jsx(_,{title:r("toolbar.currency"),disabled:!C,onClick:()=>y("currency"),children:jsx("span",{style:{fontSize:16},children:r("toolbar.currencySymbol")})}),jsx(_,{title:r("toolbar.percent"),disabled:!C,onClick:()=>y("percent"),children:jsx("span",{style:{fontSize:15},children:"%"})}),jsx(_,{title:r("toolbar.decreaseDecimal"),disabled:!C,onClick:()=>y("decreaseDecimal"),children:jsx(L,{name:"decimalDecrease"})}),jsx(_,{title:r("toolbar.increaseDecimal"),disabled:!C,onClick:()=>y("increaseDecimal"),children:jsx(L,{name:"decimalIncrease"})}),jsx(he,{title:r("toolbar.moreNumberFormats"),disabled:!C,trigger:jsxs(Fragment,{children:[jsx("span",{children:"123"}),jsx(L,{name:"chevronDown",size:13})]}),children:ct})]})]})},{key:"font-family",width:137,node:jsxs(Fragment,{children:[jsx(rt,{}),jsx(j,{label:r("toolbar.groups.font"),children:jsx(he,{title:r("toolbar.fontFamily"),disabled:!C,menuWidth:210,style:{width:120,justifyContent:"space-between"},trigger:jsxs(Fragment,{children:[jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:i.fontFamily??"Calibri"}),jsx(L,{name:"chevronDown",size:13})]}),children:g=>jsx(Fragment,{children:O.map(h=>jsx(ce,{label:h,selected:i.fontFamily===h,disabled:!C,onClick:()=>y({type:"fontFamily",value:h}),close:g},h))})})})]})},{key:"font-size",width:116,node:jsxs(j,{label:r("toolbar.groups.font"),children:[jsx(_,{title:r("toolbar.decreaseFontSize"),disabled:!C,onClick:()=>y({type:"fontSize",value:Wo(Ce,v,-1)}),children:jsx(L,{name:"remove"})}),jsx(Gt,{value:String(Ce),options:Ge,label:r("toolbar.fontSize"),disabled:!C,onCommit:g=>{let h=Number.parseFloat(g);Number.isFinite(h)&&h>=1&&h<=400&&y({type:"fontSize",value:h});},width:50,inputStyle:{textAlign:"center"}}),jsx(_,{title:r("toolbar.increaseFontSize"),disabled:!C,onClick:()=>y({type:"fontSize",value:Wo(Ce,v,1)}),children:jsx(L,{name:"add"})})]})},{key:"text",width:98,node:jsxs(Fragment,{children:[jsx(rt,{}),jsxs(j,{label:r("toolbar.groups.text"),children:[jsx(_,{title:r("toolbar.bold"),active:i.bold,disabled:!C,onClick:()=>y("bold"),children:jsx(L,{name:"bold"})}),jsx(_,{title:r("toolbar.italic"),active:i.italic,disabled:!C,onClick:()=>y("italic"),children:jsx(L,{name:"italic"})}),jsx(_,{title:r("toolbar.strikethrough"),active:i.strikethrough,disabled:!C,onClick:()=>y("strikethrough"),children:jsx(L,{name:"strikethrough"})})]})]})},{key:"colors",width:58,node:jsxs(j,{label:r("toolbar.groups.colors"),children:[jsx(Ot,{mode:"text",value:i.textColor??"#000000",label:r("toolbar.textColor"),disabled:!C,onChange:g=>y({type:"textColor",value:g})}),jsx(Ot,{mode:"fill",value:i.fillColor??"#ffffff",label:r("toolbar.fillColor"),disabled:!C,onChange:g=>y({type:"fillColor",value:g})})]})},{key:"borders",width:36,node:jsx(j,{label:r("toolbar.groups.borders"),children:jsx(he,{title:r("toolbar.borders"),disabled:!C,menuWidth:240,trigger:jsxs(Fragment,{children:[jsx(Ho,{preset:i.borderPreset??"all"}),jsx(L,{name:"chevronDown",size:12})]}),children:Ke})})},{key:"merge",width:58,node:jsxs(j,{label:r("toolbar.groups.merge"),children:[jsx(_,{title:r("toolbar.merge.all"),disabled:!$||!S,onClick:()=>b?.("all"),style:{borderRadius:"4px 0 0 4px"},testId:"xlsx-merge-all",children:jsx(L,{name:"merge"})}),jsx(he,{title:r("toolbar.mergeCells"),disabled:!$||!S&&!d?.canUnmerge,menuWidth:220,style:{minWidth:20,width:20,padding:0,borderRadius:"0 4px 4px 0"},trigger:jsx(L,{name:"chevronDown",size:13}),children:pe})]})},{key:"alignment",width:118,node:jsxs(j,{label:r("toolbar.groups.alignment"),children:[jsx(he,{title:r("toolbar.horizontalAlignment"),disabled:!C,menuWidth:180,trigger:jsxs(Fragment,{children:[jsx(No,{value:i.horizontalAlignment??"left"}),jsx(L,{name:"chevronDown",size:12})]}),children:dt}),jsx(he,{title:r("toolbar.verticalAlignment"),disabled:!C,menuWidth:180,trigger:jsxs(Fragment,{children:[jsx(Bo,{value:i.verticalAlignment??"middle"}),jsx(L,{name:"chevronDown",size:12})]}),children:m}),jsx(he,{title:r("toolbar.textWrapping"),disabled:!C,menuWidth:180,trigger:jsxs(Fragment,{children:[jsx(L,{name:"wrap"}),jsx(L,{name:"chevronDown",size:12})]}),children:J})]})}];M&&B.push({key:"custom",width:40,node:M});let ye=Math.max(0,oe-48),Ye=0,Le=B.length;for(let g=0;g<B.length;g++)if(Ye+=B[g].width,Ye>ye){Le=g;break}let Fe=B.slice(0,Le),xe=B.slice(Le);return jsxs("div",{ref:q,className:N,role:"toolbar","aria-label":r("toolbar.actionsLabel"),"data-testid":"xlsx-formatting-toolbar",style:{display:"flex",alignItems:"center",minWidth:0,minHeight:36,margin:"0 8px 5px",padding:"4px 7px",borderRadius:18,background:D.rail,color:D.text,overflow:"hidden",boxSizing:"border-box",...Y},children:[Fe.map(g=>jsx("span",{style:{display:"contents"},children:g.node},g.key)),jsx("span",{style:{marginLeft:"auto",flex:"0 0 auto"},children:jsx(he,{title:r("toolbar.more"),disabled:xe.length===0,menuWidth:390,testId:"xlsx-toolbar-more",trigger:jsx(L,{name:"more"}),children:()=>jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:2},children:xe.map(g=>jsx("span",{style:{display:"contents"},children:g.node},g.key))})})})]})}function qr({children:t,className:r,style:i,...d}){return jsx(_e.Provider,{value:d,children:jsx("div",{className:r,"data-testid":"xlsx-editor-toolbar",style:{display:"flex",flexDirection:"column",flex:"0 0 auto",...i},children:t})})}var at=qr;at.Toolbar=Ct;var rn=8,nn=32;function ln(t){let r=t.trim().split(/\s+/).filter(Boolean);return r.length===0?"?":r.slice(0,2).map(i=>i[0]).join("").toUpperCase()}function an(t){let r=Number.parseInt(t.slice(1,3),16),i=Number.parseInt(t.slice(3,5),16),d=Number.parseInt(t.slice(5,7),16);return `rgba(${r}, ${i}, ${d}, 0.1)`}function sn(t,r){return t.left<=r.right&&t.right>=r.left&&t.top<=r.bottom&&t.bottom>=r.top}function Rt(t,r){let i={...t},d=true;for(;d;){d=false;for(let p of r){let b={top:Math.min(p.start.row,p.end.row),left:Math.min(p.start.col,p.end.col),bottom:Math.max(p.start.row,p.end.row),right:Math.max(p.start.col,p.end.col)};if(!sn(i,b))continue;let s=Math.min(i.top,b.top),R=Math.min(i.left,b.left),P=Math.max(i.bottom,b.bottom),k=Math.max(i.right,b.right);s===i.top&&R===i.left&&P===i.bottom&&k===i.right||(Object.assign(i,{top:s,left:R,bottom:P,right:k}),d=true);}}return i}function cn(t){let[r,i]=useState(()=>Date.now());return useEffect(()=>{let d=Date.now();i(d);let p=t.map(R=>R.cursorMovedAt+AWARENESS_LABEL_DURATION_MS).filter(R=>R>d);if(p.length===0)return;let b=setTimeout(()=>i(Date.now()),Math.min(...p)-d+1);return b.unref?.(),()=>clearTimeout(b)},[t]),r}function _o({peers:t,sheetIds:r,sheetNames:i,activeSheet:d}){if(t.length===0)return null;let p=t.slice(0,rn),b=t.length-p.length;return jsxs("div",{"data-testid":"xlsx-presence-strip","aria-label":"Collaborators",style:{display:"flex",alignItems:"center",gap:4,padding:"0 6px",flex:"0 0 auto"},children:[p.map(s=>{let R=s.cursor?r.indexOf(s.cursor.sheet):d,P=s.cursor!==null&&R!==d,k=normalizeAwarenessColor(s.user.color,s.clientId),I=R>=0?i[R]:s.cursor?"Unavailable sheet":void 0,z=P||R<0?`${s.user.name} \u2014 ${I}`:s.user.name;return jsx("span",{"data-testid":`xlsx-presence-chip-${s.clientId}`,title:z,"aria-label":z,style:{display:"inline-grid",placeItems:"center",width:24,height:24,borderRadius:"50%",backgroundColor:k,color:"#ffffff",boxShadow:"0 0 0 2px #ffffff",fontSize:9,fontWeight:700,lineHeight:1,letterSpacing:"-0.02em",opacity:P||R<0?.42:1,transition:"opacity 120ms ease"},children:ln(s.user.name)},s.clientId)}),b>0&&jsxs("span",{"data-testid":"xlsx-presence-overflow",title:`${b} more collaborators`,"aria-label":`${b} more collaborators`,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:["+",b]})]})}function Xo({peers:t,grid:r,sheetIds:i,activeSheet:d,zoom:p,mergedRanges:b}){let s=useMemo(()=>t.slice(0,nn),[t]),R=t.length-s.length,P=cn(s);return r?jsxs(Fragment,{children:[s.map(k=>{if(!k.cursor)return null;let I=resolveAwarenessCursor(k.cursor,i);if(!I||I.sheetIndex!==d)return null;let z=Rt(I.range,b),K=rangeRect(r,z);if(!K)return null;let X=normalizeAwarenessColor(k.user.color,k.clientId),O={x:K.x*p,y:K.y*p,w:K.w*p,h:K.h*p},v=I.range.top!==I.range.bottom||I.range.left!==I.range.right,F=z.left<r.startCol,N=z.top<r.startRow||O.y<18,Y=k.cursorMovedAt>0&&P-k.cursorMovedAt<AWARENESS_LABEL_DURATION_MS;return jsx("div",{"data-testid":`xlsx-remote-selection-${k.clientId}`,style:{position:"absolute",left:O.x,top:O.y,width:O.w,height:O.h,boxSizing:"border-box",borderWidth:2,borderStyle:"solid",borderColor:X,backgroundColor:v?an(X):"transparent"},children:Y&&jsx("span",{"data-testid":`xlsx-remote-label-${k.clientId}`,style:{position:"absolute",top:N?0:-18,...F?{right:-2}:{left:-2},maxWidth:180,height:18,padding:"2px 6px",borderRadius:N?"0 0 3px 3px":"3px 3px 0 0",boxSizing:"border-box",overflow:"hidden",backgroundColor:X,color:"#ffffff",fontSize:10,fontWeight:600,lineHeight:"14px",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.user.name})},k.clientId)}),R>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:["+",R]})]}):null}var Go=["#7c3aed","#0891b2","#c2410c","#4d7c0f","#be185d","#1d4ed8"];function un(t){let r=2166136261;for(let i=0;i<t.length;i++)r^=t.charCodeAt(i),r=Math.imul(r,16777619);return (r>>>0)%Go.length}function Ko(t){return Go[un(t)]}function Yo({proposals:t,staleFor:r,onAccept:i,onReject:d,style:p}){let{t:b}=Me();return jsx("div",{"data-testid":"xlsx-proposals-panel",role:"region","aria-label":b("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",...p},children:t.length===0?jsx("div",{style:{padding:12,color:"#707070",textAlign:"center"},children:b("proposals.empty")}):t.map(s=>{let R=Ko(s.agentId),P=r[s.id];return jsxs("div",{"data-testid":"xlsx-proposal","data-proposal-id":s.id,style:{borderLeft:`3px solid ${R}`,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:R},children:s.agentId}),jsx("span",{style:{color:"#707070",fontSize:12},children:b("proposals.cellCount",{count:s.cells.length})})]}),s.note&&jsx("div",{style:{color:"#404040",margin:"4px 0"},children:s.note}),jsx("ul",{style:{listStyle:"none",margin:"6px 0",padding:0},children:s.cells.map(k=>jsxs("li",{"data-testid":"xlsx-proposal-cell",style:{fontVariantNumeric:"tabular-nums",lineHeight:1.5},children:[jsx("strong",{"data-testid":"xlsx-proposal-cell-a1",children:k.a1}),":"," ",jsx("span",{style:{color:"#909090"},children:k.oldText||"\u2205"})," ",b("proposals.changeArrow")," ",jsx("span",{"data-testid":"xlsx-proposal-cell-new",style:{color:R},children:k.newText})]},k.a1))}),P&&P.length>0&&jsx("div",{"data-testid":"xlsx-proposal-stale",role:"alert",style:{color:"#b45309",background:"#fef3c7",borderRadius:4,padding:"4px 6px",margin:"4px 0",fontSize:12},children:b("proposals.staleWarning",{cells:P.join(", ")})}),jsxs("div",{style:{display:"flex",gap:6,marginTop:4},children:[jsx("button",{"data-testid":"xlsx-proposal-accept",onClick:()=>i(s.id),style:{padding:"3px 10px",cursor:"pointer"},children:b("proposals.accept")}),P&&P.length>0&&jsx("button",{"data-testid":"xlsx-proposal-force",onClick:()=>i(s.id,true),style:{padding:"3px 10px",cursor:"pointer",color:"#b45309"},children:b("proposals.forceApply")}),jsx("button",{"data-testid":"xlsx-proposal-reject",onClick:()=>d(s.id),style:{padding:"3px 10px",cursor:"pointer"},children:b("proposals.reject")})]})]},s.id)})})}var Ee=96,Pe=24,st="#217346",er=87,Mn=1024,En="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",Pn=1,Ln=10,An=250,Dn={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},In=new Set(["z","y","s"]);function zn(t,r,i){let d=[{op:"fillRect",x:0,y:0,w:t,h:r,color:"#ffffff"}],p=Math.ceil(t/Ee),b=Math.ceil(r/Pe);for(let s=0;s<=p;s++)d.push({op:"line",x1:s*Ee,y1:0,x2:s*Ee,y2:r,width:1,color:"#e0e0e0"});for(let s=0;s<=b;s++)d.push({op:"line",x1:0,y1:s*Pe,x2:t,y2:s*Pe,width:1,color:"#e0e0e0"});return d.push({op:"fillRect",x:0,y:0,w:t,h:Pe,color:"#f3f3f3"}),d.push({op:"fillRect",x:0,y:0,w:Ee,h:r,color:"#f3f3f3"}),d.push({op:"text",x:Ee+8,y:Pe+18,text:i,fontSize:14,color:"#202020",clip:{x:Ee,y:Pe,w:Ee*3,h:Pe},align:"left"}),{width:t,height:r,commands:d}}function qo(t,r){if(!t||t.length<2)return r;let i=[];for(let p=1;p<t.length;p++)i.push(t[p]-t[p-1]);i.sort((p,b)=>p-b);let d=i[i.length>>1];return d>0?d:r}function Fn(t,r,i){let d=qo(t?.grid?.rowOffsets,Pe),p=qo(t?.grid?.colOffsets,Ee),b=Math.max(1,Math.round(r.contentHeight/d))+1,s=Math.max(1,Math.round(r.contentWidth/p))+1,R=Math.max(1,Math.floor(i/d));return {rows:b,cols:s,rowsPerPage:R}}function Jo(t,r,i){let d=new Blob([new Uint8Array(t)],{type:i}),p=URL.createObjectURL(d),b=document.createElement("a");b.href=p,b.download=r,document.body.appendChild(b),b.click(),b.remove(),URL.revokeObjectURL(p);}function Hn(t){return `${(t??"workbook.xlsx").replace(/\.xlsx$/i,"")}.png`}function Et(t,r){return {x:t.x*r,y:t.y*r,w:t.w*r,h:t.h*r}}var Qo={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},Se={shell:{flex:"0 0 auto",minHeight:er,padding:"4px 0 5px",borderBottom:"1px solid #e2e8f0",background:"#ffffff",color:"#0f172a",boxSizing:"border-box"},rail:{display:"flex",alignItems:"center",minHeight:32,margin:"0 8px",padding:"2px 8px",borderRadius:4,background:"#ffffff",boxSizing:"border-box",overflowX:"auto",overflowY:"hidden"},group:{display:"inline-flex",alignItems:"center",gap:1,padding:"0 6px",borderRight:"1px solid rgba(226, 232, 240, 0.9)",flex:"0 0 auto"},formulaGroup:{display:"flex",alignItems:"center",gap:4,flex:"1 1 320px",minWidth:240,padding:"0 6px",borderRight:"1px solid rgba(226, 232, 240, 0.9)"},nameBox:{appearance:"none",width:64,height:28,flex:"0 0 auto",boxSizing:"border-box",border:"1px solid #e2e8f0",borderRadius:6,background:"#f8fafc",color:"#0f172a",font:"600 12px ui-monospace, SFMono-Regular, Menlo, monospace",textAlign:"center",outlineColor:"#2563eb"},formulaMark:{display:"grid",placeItems:"center",width:20,height:28,flex:"0 0 auto",color:"#64748b",font:"italic 700 12px Georgia, serif",userSelect:"none"},formulaInput:{appearance:"none",flex:"1 1 260px",minWidth:140,height:28,boxSizing:"border-box",border:"1px solid #e2e8f0",borderRadius:6,padding:"0 8px",background:"#ffffff",color:"#0f172a",font:"13px ui-sans-serif, system-ui, sans-serif",outlineColor:"#2563eb"},proposals:{marginLeft:"auto",paddingLeft:6,flex:"0 0 auto"},count:{display:"inline-grid",placeItems:"center",minWidth:15,height:15,marginLeft:-3,padding:"0 4px",borderRadius:8,background:"#0f172a",color:"#ffffff",fontSize:10,fontWeight:700,lineHeight:1,boxSizing:"border-box"}};function Nn({i18n:t,...r}){return jsx(St,{i18n:t,children:jsx(Bn,{...r})})}function Bn({file:t,fileName:r,onSave:i,collaboration:d,onReady:p,className:b}){let{t:s}=Me(),R=d!==void 0,P=d?.clientId,k=d?.initialUpdate,I=d?.onReplica,z=d?.provider,K=useRef(null),X=useRef(null),O=useRef(null),v=useRef(null),F=useRef(null),N=useRef(null),Y=useRef(null),M=useRef(null),q=useRef(false),oe=useRef(null),re=useRef(null),C=useRef(null),$=useRef(null),Ce=useRef(false),Te=useRef(false),Xe=useRef(p);Xe.current=p;let[S,ue]=useState(null),[Ge,y]=useState(null),[ct,Ke]=useState(null),[pe,dt]=useState(null),[m,J]=useState(null),[B,ye]=useState(null),[Ye,Le]=useState(null),[Fe,xe]=useState(null),[g,h]=useState(er),[T,tr]=useState(1),[ut,Pt]=useState(0),[Vt,Zt]=useState(false),[se,He]=useState(null),[Lt,Re]=useState(null),[jt,Ve]=useState(null),[fe,pt]=useState({}),[qt,ft]=useState({canUndo:false,canRedo:false}),[At,bt]=useState([]),[Dt,Jt]=useState([]),[It,Qt]=useState(),[zt,eo]=useState(),[Ne,Be]=useState(null),Ae=useRef(null),[mt,ht]=useState([]),[Ft,to]=useState(false),[Ht,oo]=useState(null),[ro,no]=useState([]),[or,Ze]=useState({}),u=S?.activeSheet??0,rr=useMemo(()=>isPngExportAvailable(),[]),lo=useMemo(()=>isProposalsAvailable(),[]);useEffect(()=>{let e=K.current;if(!e)return;let o=()=>h(e.offsetHeight);o();let n=new ResizeObserver(o);return n.observe(e),()=>n.disconnect()},[]);let be=useCallback(()=>{let e=v.current;if(!e){ht([]);return}try{ht(e.listProposals());}catch{ht([]);}Pt(o=>o+1);},[]);useEffect(()=>{if(ye(null),xe(null),He(null),C.current=null,Ve(null),$.current!=null&&(clearTimeout($.current),$.current=null),ht([]),Ze({}),to(false),oo(null),pt({}),ft({canUndo:false,canRedo:false}),bt([]),Jt([]),Qt(void 0),eo(void 0),Be(null),Ke(null),Ae.current=null,Te.current=false,!t){v.current=null,ue(null),J(null),y(null);return}v.current=null,ue(null),J(null);let e=null,o=()=>{},n=()=>{},l=false,c=()=>{let w=n;n=()=>{};try{w();}catch{}};return initWasm().then(()=>{if(!l)try{e=openWorkbook(t,{collaborative:R,clientId:P}),k&&e.applyUpdate(k.slice()),v.current=e,o=e.onUpdate(()=>{if(!(l||!e))try{ue(e.sheetInfo()),Pt(f=>f+1),Ze({}),be(),y(null);}catch(f){y(f instanceof Error?f.message:String(f));}}),Te.current=!0,ue(e.sheetInfo()),J(selectionAt({row:0,col:0})),oo(e),y(null),be();let w=Xe.current?.({handle:e,refreshProposals:be});typeof w=="function"&&(n=w);}catch(w){c(),o(),o=()=>{},e?.dispose(),e=null,v.current=null,ue(null),J(null),y(w instanceof Error?w.message:String(w));}},w=>{l||(v.current=null,ue(null),J(null),y(w instanceof Error?w.message:String(w)));}),()=>{l=true,c(),o(),e?.dispose(),v.current=null;}},[t,R,P,k,be]),useEffect(()=>{if(!S||!Te.current)return;let e=X.current;e&&(Te.current=false,e.scrollLeft=S.initialScrollX*T,e.scrollTop=S.initialScrollY*T);},[S,T]),useEffect(()=>{if(!(!I||!Ht))return I(Ht),()=>I(null)},[I,Ht]),useEffect(()=>{if(no([]),!!z)return z.onAwareness(e=>no([...e]))},[z]),useEffect(()=>()=>z?.setCursor(null),[z]),useEffect(()=>{if(!z)return;let e=S?.sheetIds[u];if(!m||!e){z.setCursor(null);return}z.setCursor({sheet:e,anchor:{...m.anchor},head:{...m.focus}});},[z,m,S,u,ut]);let Nt=useCallback(()=>{let e=X.current,o=O.current;if(!e||!o)return;let n=o.getContext("2d");if(!n)return;let l=window.devicePixelRatio||1,c=e.clientWidth,w=e.clientHeight;if(c===0||w===0)return;o.width=Math.round(c*l),o.height=Math.round(w*l),o.style.width=`${c}px`,o.style.height=`${w}px`;let f=c/T,ee=w/T,ne={x:e.scrollLeft/T,y:e.scrollTop/T,width:f,height:ee},le=v.current,Ie;if(le)try{Ie=le.displayList(ne);}catch(tt){F.current=null,N.current=null,dt(null),Ke(tt instanceof Error?tt.message:String(tt));return}else Ie=zn(f,ee,s("editor.demoCellText"));let vo=[],ze=Ie.grid,wo=(ze?.rowOffsets.length??0)-1,So=(ze?.colOffsets.length??0)-1;if(le&&ze&&wo>0&&So>0)try{let tt=le.cell(u,ze.startRow,ze.startCol).a1,Tr=le.cell(u,ze.startRow+wo-1,ze.startCol+So-1).a1;vo=le.mergedRanges(u,`${tt}:${Tr}`).slice(0,Mn);}catch{}paintDisplayList(n,Ie,l*T),F.current=Ie,N.current={frame:Ie,zoom:T},Ke(null),Jt(vo),dt(Ie);},[u,s,T]);useEffect(()=>{let e=X.current;if(!e)return;let o=()=>{Y.current==null&&(Y.current=requestAnimationFrame(()=>{Y.current=null,Nt();}));};Nt(),e.addEventListener("scroll",o,{passive:true});let n=new ResizeObserver(o);return n.observe(e),()=>{e.removeEventListener("scroll",o),n.disconnect(),Y.current!=null&&(cancelAnimationFrame(Y.current),Y.current=null);}},[Nt,S,Ge,ut]),useEffect(()=>{let e=v.current;if(!e||!m||!S){Le(null);return}try{Le(e.cell(u,m.focus.row,m.focus.col));}catch{Le(null);}},[m,S,u,ut]),useEffect(()=>{let e=()=>{q.current=false,Zt(false);};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),useEffect(()=>{let e=v.current;if(!e||!m||!S){pt({}),ft({canUndo:false,canRedo:false}),bt([]);return}let o=normalizeRange(m);try{let n=e.cell(u,o.top,o.left).a1,l=e.cell(u,o.bottom,o.right).a1,c=`${n}:${l}`;pt(e.selectionFormatting(u,c)),ft(e.historyState()),bt(e.mergedRanges(u,c));}catch{pt({}),ft({canUndo:false,canRedo:false}),bt([]);}},[m,S,u,ut]);let je=useMemo(()=>!pe||!S?null:buildA11yGrid(pe,m,S.sheetNames[u]??"",{gridLabel:s("a11y.gridLabel"),rowHeaderLabel:s("a11y.rowHeaderLabel"),columnHeaderLabel:s("a11y.columnHeaderLabel"),cellLabel:s("a11y.cellLabel"),cellLabelSelected:s("a11y.cellLabelSelected"),emptyCellLabel:s("a11y.emptyCellLabel"),emptyCellLabelSelected:s("a11y.emptyCellLabelSelected")}),[pe,m,S,u,s]),Z=useCallback(()=>{X.current?.focus({preventScroll:true});},[]);useEffect(()=>{B&&M.current?.focus({preventScroll:true});},[B]);let U=useCallback(e=>{ue(e.sheetInfo),Pt(o=>o+1),be();},[be]),gt=useCallback(e=>{let o=v.current;if(!o)return null;let n=normalizeRange(e),l=o.cell(u,n.top,n.left).a1,c=o.cell(u,n.bottom,n.right).a1;return `${l}:${c}`},[u]),me=useCallback(()=>Fn(F.current,S,(X.current?.clientHeight??0)/T),[S,T]),ke=useCallback((e,o)=>{let n=O.current,l=F.current?.grid;if(!n||!l)return null;let c=n.getBoundingClientRect();return cellAtPoint(l,(e-c.left)/T,(o-c.top)/T)},[T]),We=useCallback((e,o)=>{let n=O.current,l=N.current;if(!n||!l)return null;let c=n.getBoundingClientRect();return chartRegionAtPoint(l.frame.charts,(e-c.left)/l.zoom,(o-c.top)/l.zoom)},[]),ao=useMemo(()=>se?pe?.charts?.find(e=>e.id===se.id)??null:null,[pe,se]);useEffect(()=>{!se||!pe||pe.charts?.some(e=>e.id===se.id)||(ve.current(),re.current=null,Re(null),He(null));},[pe,se]);let $e=useCallback((e,o,n)=>{let l=v.current;if(!(!l||o===0&&n===0))try{U(l.moveChart(u,e,o,n));}catch(c){y(c instanceof Error?c.message:String(c));}},[u,U]),io=useCallback(()=>{$.current!=null&&(clearTimeout($.current),$.current=null);let e=C.current;C.current=null,Ve(null),e&&$e(e.id,e.dx,e.dy);},[$e]),ve=useRef(io);ve.current=io;let so=useCallback((e,o,n)=>{let l=C.current;l&&l.id!==e&&ve.current();let c=C.current??{dx:0,dy:0},w={id:e,dx:c.dx+o,dy:c.dy+n};C.current=w,Ve({x:w.dx,y:w.dy}),$.current!=null&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null;let f=C.current;C.current=null,Ve(null),f&&(f.dx!==0||f.dy!==0)&&co.current(f.id,f.dx,f.dy);},An);},[]),co=useRef($e);co.current=$e,useEffect(()=>{let e=n=>{let l=re.current;re.current=null,Re(null),!(!l||n.button!==0)&&$e(l.id,(n.clientX-l.clientX)/T,(n.clientY-l.clientY)/T);},o=()=>{re.current=null,Re(null),ve.current();};return window.addEventListener("mouseup",e),window.addEventListener("blur",o),()=>{window.removeEventListener("mouseup",e),window.removeEventListener("blur",o);}},[$e,T]),useEffect(()=>()=>{$.current!=null&&clearTimeout($.current),$.current=null,C.current=null;},[]);let yt=useCallback(e=>{let o=v.current;if(!o||!m)return;let{row:n,col:l}=m.focus,c=e??"";if(e===void 0)try{c=o.cell(u,n,l).input;}catch{c="";}ye({row:n,col:l,value:c});},[m,u]),Oe=useCallback(e=>{let o=v.current;if(!o||!B)return;Ce.current=true;let{row:n,col:l,value:c}=B;try{U(o.editCell(u,n,l,c));}catch(f){y(f instanceof Error?f.message:String(f));}ye(null);let w=selectionAt({row:n,col:l});J(e?moveFocus(w,e,{limits:me()}):w),Z();},[B,u,U,me,Z]),nr=useCallback(()=>{Ce.current=true,ye(null),Z();},[Z]),xt=useCallback(()=>{let e=v.current;if(!e||!m)return;let o=normalizeRange(m),n=[];for(let l=o.top;l<=o.bottom;l++)for(let c=o.left;c<=o.right;c++)n.push({row:l,col:c,input:""});try{U(e.editCells(u,n));}catch(l){y(l instanceof Error?l.message:String(l));}},[m,u,U]),vt=useCallback(async()=>{let e=v.current;if(!e||!m)return;let o=normalizeRange(m);try{let n=e.cell(u,o.top,o.left).a1,l=e.cell(u,o.bottom,o.right).a1,c=e.rangeCells(u,`${n}:${l}`),w=toTsv(c.map(f=>f.map(ee=>({input:ee.input,isFormula:ee.isFormula}))));await navigator.clipboard.writeText(w);}catch{}},[m,u]),uo=useCallback(async()=>{await vt(),xt();},[vt,xt]),po=useCallback(async()=>{let e=v.current;if(!e||!m)return;let o;try{o=await navigator.clipboard.readText();}catch{return}let n=fromTsv(o);if(n.length===0)return;let l=normalizeRange(m),c=[],w=1;n.forEach((f,ee)=>{w=Math.max(w,f.length),f.forEach((ne,le)=>c.push({row:l.top+ee,col:l.left+le,input:ne}));});try{U(e.editCells(u,c));}catch(f){y(f instanceof Error?f.message:String(f));return}J({anchor:{row:l.top,col:l.left},focus:{row:l.top+n.length-1,col:l.left+w-1}});},[m,u,U]),lr=useCallback(e=>{let o=v.current;if(!o||!m)return;let n=gt(m);if(n){if(e==="paintFormat"){if(Ne){Be(null),Ae.current=null;return}try{Be(o.captureFormat(u,n));let l=normalizeRange(m);Ae.current=`${u}:${l.top}:${l.left}:${l.bottom}:${l.right}`;}catch(l){y(l instanceof Error?l.message:String(l));}return}try{let l;e==="currency"?l=o.setNumberFormat(u,n,"currency"):e==="percent"?l=o.setNumberFormat(u,n,"percent"):e==="increaseDecimal"?l=o.setNumberFormat(u,n,"increaseDecimal"):e==="decreaseDecimal"?l=o.setNumberFormat(u,n,"decreaseDecimal"):e==="bold"?l=o.patchRangeStyle(u,n,{bold:!fe.bold}):e==="italic"?l=o.patchRangeStyle(u,n,{italic:!fe.italic}):e==="strikethrough"?l=o.patchRangeStyle(u,n,{strikethrough:!fe.strikethrough}):e.type==="numberFormat"?l=e.value==="custom"?o.setNumberFormat(u,n,{type:"custom",pattern:fe.numberFormatPattern??"0.00"}):o.setNumberFormat(u,n,e.value):e.type==="fontFamily"?l=o.patchRangeStyle(u,n,{fontFamily:e.value}):e.type==="fontSize"?l=o.patchRangeStyle(u,n,{fontSize:e.value}):e.type==="textColor"?l=o.patchRangeStyle(u,n,{textColor:e.value}):e.type==="fillColor"?l=o.patchRangeStyle(u,n,{fillColor:e.value}):e.type==="borderPreset"?l=o.patchRangeStyle(u,n,{border:{preset:e.value,style:It??fe.borderStyle??"solid",color:zt??fe.borderColor??"#000000"}}):e.type==="borderStyle"?(Qt(e.value),l=o.patchRangeStyle(u,n,{border:{style:e.value}})):e.type==="borderColor"?(eo(e.value),l=o.patchRangeStyle(u,n,{border:{color:e.value}})):e.type==="horizontalAlignment"?l=o.patchRangeStyle(u,n,{horizontalAlignment:e.value}):e.type==="verticalAlignment"?l=o.patchRangeStyle(u,n,{verticalAlignment:e.value}):l=o.patchRangeStyle(u,n,{textWrapping:e.value}),U(l),Z();}catch(l){y(l instanceof Error?l.message:String(l));}}},[m,gt,Ne,u,fe,It,zt,U,Z]);useEffect(()=>{let e=v.current;if(!e||!m||!Ne||Vt)return;let o=normalizeRange(m);if(`${u}:${o.top}:${o.left}:${o.bottom}:${o.right}`===Ae.current)return;let l=gt(m);if(l)try{U(e.applyFormat(u,l,Ne)),Be(null),Ae.current=null,Z();}catch(c){y(c instanceof Error?c.message:String(c));}},[m,Ne,Vt,u,gt,U,Z]);let Bt=useCallback(()=>{let e=v.current;if(e){ve.current();try{U(e.undo());}catch(o){y(o instanceof Error?o.message:String(o));}}},[U]),wt=useCallback(()=>{let e=v.current;if(e){ve.current();try{U(e.redo());}catch(o){y(o instanceof Error?o.message:String(o));}}},[U]),ar=useCallback(()=>window.print(),[]),ir=useCallback(()=>{},[]),sr=useCallback(e=>{let o=v.current;if(!o||!m)return;let n=normalizeRange(m),l=(f,ee)=>({row:f,col:ee}),c=(f,ee,ne,le)=>({start:l(f,ee),end:l(ne,le)}),w=[];if(e==="all")w.push({type:"mergeCells",sheet:u,range:c(n.top,n.left,n.bottom,n.right)});else if(e==="horizontal")for(let f=n.top;f<=n.bottom;f++)w.push({type:"mergeCells",sheet:u,range:c(f,n.left,f,n.right)});else if(e==="vertical")for(let f=n.left;f<=n.right;f++)w.push({type:"mergeCells",sheet:u,range:c(n.top,f,n.bottom,f)});else for(let f of At)w.push({type:"unmergeCells",sheet:u,range:c(f.start.row,f.start.col,f.end.row,f.end.col)});if(w.length!==0)try{U(o.applyOps(w)),Z();}catch(f){y(f instanceof Error?f.message:String(f));}},[m,u,At,U,Z]),cr=useCallback((e,o)=>{let n=v.current;if(n)try{U(n.acceptProposal(e,{force:o})),Ze(({[e]:l,...c})=>c),be(),Z();}catch(l){l instanceof StaleProposalError?Ze(c=>({...c,[e]:l.cells})):y(l instanceof Error?l.message:String(l));}},[U,be,Z]),dr=useCallback(e=>{let o=v.current;if(o)try{o.rejectProposal(e),Ze(({[e]:n,...l})=>l),be();}catch(n){y(n instanceof Error?n.message:String(n));}},[be]),Wt=useCallback(()=>{let e=v.current;if(e){ve.current();try{let o=e.save();i?i(o):Jo(o,r??"workbook.xlsx",En);}catch(o){y(o instanceof Error?o.message:String(o));}}},[i,r]),ur=useCallback(()=>{let e=v.current,o=X.current;if(!(!e||!o))try{let n=e.renderPng({x:o.scrollLeft/T,y:o.scrollTop/T,width:o.clientWidth/T,height:o.clientHeight/T});Jo(n,Hn(r),"image/png");}catch(n){y(n instanceof Error?n.message:String(n));}},[r,T]),fo=useCallback(e=>{let o=v.current;if(!o||!m||Fe==null)return;let{row:n,col:l}=m.focus;try{U(o.editCell(u,n,l,Fe));}catch(c){y(c instanceof Error?c.message:String(c));}xe(null),e&&J(c=>c&&moveFocus(c,e,{limits:me()}));},[m,Fe,u,U,me]),pr=useCallback(e=>{if(!v.current||!m||!S||B)return;let n=e.metaKey||e.ctrlKey,l=e.key.toLowerCase();if(se&&!(n&&In.has(l))){if(e.key==="Escape"){re.current=null,Re(null),C.current=null,Ve(null),$.current!=null&&(clearTimeout($.current),$.current=null),He(null),e.preventDefault();return}let w=n?void 0:Dn[e.key];if(w){let f=Pn*(e.shiftKey?Ln:1);se.movable&&so(se.id,w[0]*f,w[1]*f),e.preventDefault();}return}if(n){if(l==="c"){vt(),e.preventDefault();return}if(l==="v"){po(),e.preventDefault();return}if(l==="x"){uo(),e.preventDefault();return}if(l==="z"){e.shiftKey?wt():Bt(),e.preventDefault();return}if(l==="y"){wt(),e.preventDefault();return}if(l==="s"){Wt(),e.preventDefault();return}}let c=selectionKeyReducer(m,{key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey},me());switch(c.type){case "move":J(c.selection),e.preventDefault();break;case "startEdit":yt(c.initialInput),e.preventDefault();break;case "clear":xt(),e.preventDefault();break;}},[m,S,B,me,vt,po,uo,Bt,wt,Wt,yt,xt,se,so]),fr=useCallback(e=>{let o=B!=null;if(o&&M.current?.contains(e.target))return;re.current=null,ve.current();let n=We(e.clientX,e.clientY);if(n){o&&Oe(),He({id:n.id,movable:n.movable}),n.movable&&e.button===0&&(re.current={id:n.id,clientX:e.clientX,clientY:e.clientY}),Re(null),oe.current=null,Z(),e.preventDefault();return}if(He(null),Re(null),!m)return;let l=ke(e.clientX,e.clientY);l&&(o&&Oe(),e.shiftKey?J(c=>c&&extendTo(c,l,me())):J(selectionAt(l)),oe.current=o?null:l,q.current=true,Zt(true),Z());},[B,m,ke,We,me,Z,Oe]),br=useCallback(e=>{let o=re.current;if(o){if(e.buttons===0){re.current=null,Re(null);return}e.currentTarget.style.cursor="move",e.currentTarget.title="",Re({x:e.clientX-o.clientX,y:e.clientY-o.clientY});return}let n=ke(e.clientX,e.clientY);if(!n){q.current||(e.currentTarget.style.cursor="default",e.currentTarget.title="");return}if(!q.current){let l=We(e.clientX,e.clientY);if(l){e.currentTarget.style.cursor=l.movable?"move":"pointer",e.currentTarget.title="";return}let c=F.current?hyperlinkAtCell(F.current,n.row,n.col):null;e.currentTarget.style.cursor=c?"pointer":"default",e.currentTarget.title=c?.tooltip??"";return}J(l=>l&&extendTo(l,n,me()));},[ke,We,me]),bo=useCallback(e=>{let o=v.current,n=F.current;if(!o||!n||!S)return false;let l=hyperlinkAtCell(n,e.row,e.col);if(!l)return false;let c=safeExternalHyperlink(l);if(c)return window.open(c,"_blank","noopener,noreferrer"),true;if(!l.location)return true;let w=S.sheetNames[u]??"",f=parseHyperlinkLocation(l.location,w);if(!f)return true;let ee=S.sheetNames.findIndex(ne=>ne.toLowerCase()===f.sheetName.toLowerCase());if(ee<0)return true;try{o.setActiveSheet(ee);let ne=o.cellPosition(ee,f.row,f.col);ue(o.sheetInfo()),requestAnimationFrame(()=>{let le=X.current;le&&(le.scrollLeft=ne.x*T,le.scrollTop=ne.y*T);}),J(selectionAt({row:f.row,col:f.col})),ye(null),xe(null),Be(null),Ae.current=null,y(null);}catch(ne){y(ne instanceof Error?ne.message:String(ne));}return true},[u,S,T]),mr=useCallback(e=>{if(B){oe.current=null;return}let o=ke(e.clientX,e.clientY),n=oe.current;oe.current=null,!(!o||!n||o.row!==n.row||o.col!==n.col)&&bo(o);},[bo,B,ke]),hr=useCallback(e=>{if(B||We(e.clientX,e.clientY))return;let o=ke(e.clientX,e.clientY);o&&F.current&&hyperlinkAtCell(F.current,o.row,o.col)||m&&yt();},[B,yt,ke,We,m]),gr=useCallback(e=>{e.currentTarget.style.cursor="default",e.currentTarget.title="";},[]),De=pe?.grid,mo=m?Rt(normalizeRange(m),Dt):null,ho=m?Rt({top:m.focus.row,left:m.focus.col,bottom:m.focus.row,right:m.focus.col},Dt):null,go=De&&mo?rangeRect(De,mo):null,yo=De&&ho?rangeRect(De,ho):null,xo=De&&B?cellRect(De,B.row,B.col):null,qe=go?Et(go,T):null,Je=yo?Et(yo,T):null,Qe=xo?Et(xo,T):null,et=ao?Et(ao.rect,T):null,yr=S?S.contentWidth*T:void 0,xr=S?S.contentHeight*T:void 0,vr=Fe??Ye?.input??"",Ue=m?normalizeRange(m):null,wr=Ue?Ue.bottom-Ue.top+1:1,Sr=Ue?Ue.right-Ue.left+1:1,Cr=e=>{let o=v.current;if(o){ve.current();try{o.setActiveSheet(e),Te.current=!0,J(selectionAt({row:0,col:0})),He(null),ye(null),xe(null),Be(null),Ae.current=null,ue(o.sheetInfo());}catch(n){y(n instanceof Error?n.message:String(n));}}};return jsxs("div",{className:b,role:"application","aria-label":s("editor.appLabel"),style:{position:"relative",display:"flex",flexDirection:"column",width:"100%",height:"100%",minWidth:0,color:"#202124",background:"#ffffff",fontFamily:"ui-sans-serif, system-ui, sans-serif"},children:[jsx("div",{ref:K,"data-testid":"xlsx-toolbar",style:Se.shell,children:jsxs(at,{currentFormatting:{...fe,borderStyle:It??fe.borderStyle,borderColor:zt??fe.borderColor,paintFormat:Ne!==null},selectionShape:{rows:wr,columns:Sr,canUnmerge:At.length>0},onSearchMenus:ir,onUndo:Bt,onRedo:wt,canUndo:qt.canUndo,canRedo:qt.canRedo,onPrint:ar,zoom:T,onZoomChange:tr,onFormat:lr,onMerge:sr,children:[jsx(at.Toolbar,{}),jsxs("div",{style:Se.rail,role:"group","aria-label":s("toolbar.formulaBarLabel"),children:[jsxs(j,{style:{...Se.group,paddingLeft:0},label:s("toolbar.fileActionsLabel"),children:[jsx(_,{testId:"xlsx-save",onClick:Wt,disabled:!S,title:s("toolbar.save"),children:jsx(L,{name:"save",size:18})}),jsx(_,{testId:"xlsx-export-png",onClick:ur,disabled:!S||!rr,title:s("toolbar.exportPng"),children:jsx(L,{name:"image",size:18})})]}),jsxs("div",{style:Se.formulaGroup,role:"group","aria-label":s("toolbar.formulaBarLabel"),children:[jsx("input",{"data-testid":"xlsx-name-box",readOnly:true,value:Ye?.a1??"",placeholder:s("toolbar.nameBoxPlaceholder"),"aria-label":s("toolbar.nameBoxPlaceholder"),style:Se.nameBox}),jsx("span",{style:Se.formulaMark,"aria-hidden":"true",children:"fx"}),jsx("input",{"data-testid":"xlsx-formula-input",value:vr,placeholder:s("toolbar.formulaPlaceholder"),"aria-label":s("toolbar.formulaPlaceholder"),disabled:!S,onChange:e=>xe(e.target.value),onKeyDown:e=>{e.key==="Enter"?(fo(e.shiftKey?"up":"down"),Z(),e.preventDefault()):e.key==="Escape"&&(xe(null),Z(),e.preventDefault());},onBlur:()=>fo(),style:Se.formulaInput})]}),jsx(_o,{peers:ro,sheetIds:S?.sheetIds??[],sheetNames:S?.sheetNames??[],activeSheet:u}),lo&&jsx("div",{style:Se.proposals,children:jsxs(_,{testId:"xlsx-proposals-button",onClick:()=>to(e=>!e),disabled:!S,active:Ft,ariaExpanded:Ft,title:s("proposals.panelLabel"),style:{width:mt.length>0?42:28},children:[jsx(L,{name:"proposals",size:18}),mt.length>0&&jsx("span",{"data-testid":"xlsx-proposals-count",style:Se.count,children:mt.length})]})})]})]})}),lo&&Ft&&jsx(Yo,{proposals:mt,staleFor:or,onAccept:cr,onReject:dr,style:{top:g+4,right:8,width:"min(320px, calc(100% - 16px))",maxHeight:`min(420px, calc(100% - ${g+12}px))`}}),jsxs("div",{ref:X,"data-testid":"xlsx-scroll",tabIndex:0,onKeyDown:pr,onMouseDown:fr,onMouseMove:br,onMouseLeave:gr,onClick:mr,onDoubleClick:hr,style:{position:"relative",flex:1,overflow:"auto",minHeight:0,outline:"none"},children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:yr??"100%",height:xr??"100%"}}),jsxs("div",{style:{position:"sticky",top:0,left:0,width:0,height:0},children:[jsx("canvas",{ref:O,style:{display:"block",position:"absolute",top:0,left:0}}),jsxs("div",{"data-testid":"xlsx-overlay-host",style:{position:"absolute",top:0,left:0,width:0,height:0,pointerEvents:"none"},children:[qe&&!se&&jsx("div",{"data-testid":"xlsx-selection",style:{position:"absolute",left:qe.x,top:qe.y,width:qe.w,height:qe.h,boxSizing:"border-box",border:`1px solid ${st}`,background:"rgba(33, 115, 70, 0.12)"}}),et&&jsx("div",{"data-testid":"xlsx-chart-selection","data-chart-id":se?.id,"aria-hidden":true,style:{position:"absolute",left:et.x+(Lt?.x??0)+(jt?.x??0)*T,top:et.y+(Lt?.y??0)+(jt?.y??0)*T,width:et.w,height:et.h,boxSizing:"border-box",border:`2px solid ${st}`,boxShadow:"0 1px 6px rgba(0, 0, 0, 0.25)",background:Lt?"rgba(33, 115, 70, 0.08)":"transparent"}}),Je&&!se&&!B&&jsx("div",{style:{position:"absolute",left:Je.x,top:Je.y,width:Je.w,height:Je.h,boxSizing:"border-box",border:`2px solid ${st}`}}),jsx(Xo,{peers:ro,grid:De,sheetIds:S?.sheetIds??[],activeSheet:u,zoom:T,mergedRanges:Dt}),B&&Qe&&jsx("input",{ref:M,"data-testid":"xlsx-cell-editor",value:B.value,onChange:e=>ye(o=>o&&{...o,value:e.target.value}),onKeyDown:e=>{e.stopPropagation(),e.key==="Enter"?(Oe(e.shiftKey?"up":"down"),e.preventDefault()):e.key==="Tab"?(Oe(e.shiftKey?"left":"right"),e.preventDefault()):e.key==="Escape"&&(nr(),e.preventDefault());},onBlur:()=>{if(Ce.current){Ce.current=false;return}Oe();},style:{position:"absolute",left:Qe.x,top:Qe.y,width:Qe.w,height:Qe.h,boxSizing:"border-box",border:`2px solid ${st}`,padding:"0 3px",font:`${13*T}px system-ui, sans-serif`,background:"#ffffff",pointerEvents:"auto",outline:"none"}})]})]})]}),je&&jsxs(Fragment,{children:[jsxs("div",{style:Qo,role:"grid","aria-label":je.label,children:[jsxs("div",{role:"row",children:[jsx("span",{role:"columnheader"}),je.columnHeaders.map(e=>jsx("span",{role:"columnheader",children:e.label},e.col))]}),je.rows.map(e=>jsxs("div",{role:"row",children:[jsx("span",{role:"rowheader",children:e.header}),e.cells.map(o=>jsx("span",{role:"gridcell","aria-selected":o.selected,children:o.label},o.col))]},e.row))]}),je.charts.map((e,o)=>jsx("div",{style:Qo,role:"img","aria-label":e.label},`${o}:${e.label}`))]}),ct&&jsx("div",{"data-testid":"xlsx-render-error",role:"alert",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",padding:16,textAlign:"center",color:"#b00020",background:"#ffffff"},children:ct}),Ge&&jsxs("div",{"data-testid":"xlsx-error",role:"alert",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",padding:16,textAlign:"center",color:"#b00020"},children:[s("editor.openError"),": ",Ge]}),S&&S.sheetNames.length>0&&jsx("div",{"data-testid":"xlsx-sheet-tabs",role:"tablist","aria-label":s("editor.sheetTabsLabel"),style:{display:"flex",gap:2,padding:"4px 6px",borderTop:"1px solid #e0e0e0",background:"#fafafa",overflowX:"auto"},children:S.sheetNames.map((e,o)=>{let n=o===S.activeSheet;return jsx("button",{role:"tab","aria-selected":n,onClick:()=>Cr(o),style:{border:"none",padding:"4px 12px",cursor:"pointer",borderBottom:n?`2px solid ${st}`:"2px solid transparent",fontWeight:n?600:400,background:n?"#ffffff":"transparent"},children:e},o)})})]})}export{at as EditorToolbar,_e as EditorToolbarContext,St as LocaleProvider,Ct as Toolbar,_ as ToolbarButton,he as ToolbarDropdown,j as ToolbarGroup,ce as ToolbarMenuItem,nt as ToolbarMenuSeparator,rt as ToolbarSeparator,Nn as XlsxEditor,Ct as XlsxToolbar,Pr as useEditorToolbar,Me as useTranslation};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betteroffice/xlsx-react",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Excel-faithful React XLSX spreadsheet editor and viewer — full OOXML fidelity, real-time human + AI agent collaboration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xlsx",
|
|
@@ -10,8 +10,15 @@
|
|
|
10
10
|
"editor",
|
|
11
11
|
"viewer",
|
|
12
12
|
"react",
|
|
13
|
+
"react-spreadsheet",
|
|
14
|
+
"spreadsheet-component",
|
|
15
|
+
"xlsx-editor",
|
|
16
|
+
"xlsx-viewer",
|
|
17
|
+
"data-grid",
|
|
13
18
|
"collaborative",
|
|
14
19
|
"real-time",
|
|
20
|
+
"crdt",
|
|
21
|
+
"yjs",
|
|
15
22
|
"ai-agent"
|
|
16
23
|
],
|
|
17
24
|
"type": "module",
|
|
@@ -33,14 +40,17 @@
|
|
|
33
40
|
"typecheck": "tsc --noEmit -p ."
|
|
34
41
|
},
|
|
35
42
|
"dependencies": {
|
|
36
|
-
"@betteroffice/xlsx": "0.0
|
|
37
|
-
"@betteroffice/xlsx-i18n": "0.0
|
|
43
|
+
"@betteroffice/xlsx": "0.1.0",
|
|
44
|
+
"@betteroffice/xlsx-i18n": "0.1.0"
|
|
38
45
|
},
|
|
39
46
|
"peerDependencies": {
|
|
40
47
|
"react": "^18.0.0 || ^19.0.0",
|
|
41
48
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
42
49
|
},
|
|
43
50
|
"devDependencies": {
|
|
51
|
+
"@happy-dom/global-registrator": "^20.8.3",
|
|
52
|
+
"@testing-library/react": "^16.0.0",
|
|
53
|
+
"@types/bun": "^1.3.14",
|
|
44
54
|
"@types/react": "^19.2.17",
|
|
45
55
|
"@types/react-dom": "^19.2.3",
|
|
46
56
|
"react": "^19.2.7",
|