@betteroffice/xlsx-react 0.3.0 → 0.5.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/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {createContext,forwardRef,useRef,useId,useState,useCallback,useImperativeHandle,useEffect,useLayoutEffect,useMemo,useContext,useSyncExternalStore,useReducer,Component}from'react';import {selectionAt,isPngExportAvailable,isProposalsAvailable,initWasm,openWorkbook,paintDisplayList,buildA11yGrid,normalizeRange,cellAtPoint,chartRegionAtPoint,moveFocus,toTsv,fromTsv,selectionKeyReducer,extendTo,hyperlinkAtCell,safeExternalHyperlink,parseHyperlinkLocation,rangeRect,cellRect,StaleProposalError}from'@betteroffice/xlsx';import {en,deepMerge,createT}from'@betteroffice/xlsx-i18n';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {normalizeAwarenessColor,resolveAwarenessCursor,AWARENESS_LABEL_DURATION_MS}from'@betteroffice/xlsx/collaboration';var Bi=Object.defineProperty;var Wi=(e,t,n)=>t in e?Bi(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var Wt=(e,t,n)=>Wi(e,typeof t!="symbol"?t+"":t,n);var Ol=createContext(en),Dl=createContext("en");function _t({i18n:e,children:t}){let n=typeof e?._lang=="string"?e._lang:"en",o=useMemo(()=>deepMerge(en,e),[e]);return jsx(Dl.Provider,{value:n,children:jsx(Ol.Provider,{value:o,children:t})})}function re(){let e=useContext(Ol),t=useContext(Dl);return {t:useMemo(()=>createT(e,t),[e,t])}}function se(e,t,n,o=[]){return Object.freeze({id:e,labelKey:t,mutatesDocument:n,shortcuts:Object.freeze(o)})}var $t=e=>({chord:e,args:null}),Ae=Object.freeze({bold:se("bold","toolbar.bold",true,[$t("Mod+B")]),italic:se("italic","toolbar.italic",true,[$t("Mod+I")]),strikethrough:se("strikethrough","toolbar.strikethrough",true),paintFormat:se("paintFormat","toolbar.paintFormat",true),fontFamily:se("fontFamily","toolbar.fontFamily",true),fontSize:se("fontSize","toolbar.fontSize",true),fontSizeStep:se("fontSizeStep","commands.fontSizeStep",true),textColor:se("textColor","toolbar.textColor",true),fillColor:se("fillColor","toolbar.fillColor",true),numberFormat:se("numberFormat","commands.numberFormat",true),decimalPlaces:se("decimalPlaces","commands.decimalPlaces",true),borderPreset:se("borderPreset","toolbar.borders",true),borderStyle:se("borderStyle","commands.borderStyle",true),borderColor:se("borderColor","toolbar.borderColor",true),merge:se("merge","toolbar.mergeCells",true),horizontalAlignment:se("horizontalAlignment","toolbar.horizontalAlignment",true),verticalAlignment:se("verticalAlignment","toolbar.verticalAlignment",true),textWrapping:se("textWrapping","toolbar.textWrapping",true),searchMenus:se("searchMenus","toolbar.searchMenus",false),save:se("save","toolbar.save",false,[$t("Mod+S")]),exportPng:se("exportPng","toolbar.exportPng",false),print:se("print","toolbar.print",false),undo:se("undo","toolbar.undo",true,[$t("Mod+Z")]),redo:se("redo","toolbar.redo",true,[$t("Mod+Y"),$t("Mod+Shift+Z")]),zoom:se("zoom","toolbar.zoom",false),proposalsPanel:se("proposalsPanel","proposals.panelLabel",false),proposalAccept:se("proposalAccept","proposals.accept",true),proposalReject:se("proposalReject","proposals.reject",false)}),Fl=Object.freeze(Object.keys(Ae));function zl(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(Ae,e)}var Gi=/^plugin:[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?\/[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;function Ce(e){return typeof e=="string"&&Gi.test(e)}function Ne(e,t){let n=t;if(n&&typeof n=="object"){let o=n.value,r=n.direction;switch(e){case "numberFormat":return o==="currency"?"toolbar.currency":o==="percent"?"toolbar.percent":`toolbar.numberFormats.${o}`;case "decimalPlaces":return r==="increase"?"toolbar.increaseDecimal":"toolbar.decreaseDecimal";case "fontSizeStep":return r==="increase"?"toolbar.increaseFontSize":"toolbar.decreaseFontSize";case "merge":return `toolbar.merge.${o}`;case "borderPreset":return `toolbar.borderPresets.${o}`;case "borderStyle":return `toolbar.borderStyles.${o}`;case "horizontalAlignment":return `toolbar.horizontalAlign.${o}`;case "verticalAlignment":return `toolbar.verticalAlign.${o}`;case "textWrapping":return `toolbar.wrapping.${o}`;}}return Ae[e].labelKey}function sn(e){let t=e.split("+"),n=t.length>1&&t[t.length-1]===""?"+":t[t.length-1],o=new Set(t.slice(0,-1));return {mod:o.has("Mod"),shift:o.has("Shift"),alt:o.has("Alt"),key:n.toLowerCase()}}var ji=new Set(["Mod","Shift","Alt"]);function un(e){if(typeof e!="string"||e.length===0)return null;let t=e.split("+");if(!(t.length>1&&t[t.length-1]===""?t.slice(0,-2):t.slice(0,-1)).every(r=>ji.has(r)))return null;let o=sn(e);return o.key.length===0?null:[o.mod&&"Mod",o.alt&&"Alt",o.shift&&"Shift",o.key].filter(Boolean).join("+")}function Hl(){return typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform)}function Bo(e,t,n=Hl()){let o=sn(e),r=n?t.metaKey:t.ctrlKey,l=n?t.ctrlKey:t.metaKey;return o.mod===r&&!l&&o.shift===t.shiftKey&&o.alt===t.altKey&&t.key.toLowerCase()===o.key}function Wo(e,t=Hl()){let n=sn(e),o=n.key.length===1?n.key.toUpperCase():n.key;return t?`${n.mod?"\u2318":""}${n.alt?"\u2325":""}${n.shift?"\u21E7":""}${o}`:[n.mod&&"Ctrl",n.alt&&"Alt",n.shift&&"Shift",o].filter(Boolean).join("+")}function Kn(e,t){let n=Ae[e].shortcuts,o=JSON.stringify(t??null),r=n.find(l=>JSON.stringify(l.args)===o);return r?Wo(r.chord):null}var Nl=Object.freeze(Object.values(Ae).flatMap(e=>e.shortcuts.map(t=>({id:e.id,shortcut:t})))),Kl=new Set(Nl.map(({shortcut:e})=>un(e.chord))),Ui=/^f(?:[1-9]|1[0-2])$/;function Bl(e){let t=sn(e);return t.mod||t.alt||Ui.test(t.key)}var Vi=new Set(["arrowup","arrowdown","arrowleft","arrowright","tab","enter","escape","home","end","pageup","pagedown","f2","delete","backspace"]),qi=new Set(["a","c","v","x"]);function Wl(e){let t=sn(e);return Vi.has(t.key)?true:t.mod?qi.has(t.key):!t.alt&&t.key.length===1}function dn(e){return Nl.find(({shortcut:t})=>Bo(t.chord,e))??null}var Zi={"editor-unavailable":"commands.reasons.editorUnavailable","document-loading":"commands.reasons.documentLoading","no-document":"commands.reasons.noDocument","read-only":"commands.reasons.readOnly","cell-selection-required":"commands.reasons.cellSelectionRequired","unsupported-selection":"commands.reasons.unsupportedSelection","multiple-cells-required":"commands.reasons.multipleCellsRequired","multiple-columns-required":"commands.reasons.multipleColumnsRequired","multiple-rows-required":"commands.reasons.multipleRowsRequired","no-merged-cells":"commands.reasons.noMergedCells","collaboration-unsupported":"commands.reasons.collaborationUnsupported","nothing-to-undo":"commands.reasons.nothingToUndo","nothing-to-redo":"commands.reasons.nothingToRedo","png-unavailable":"commands.reasons.pngUnavailable","no-proposals":"commands.reasons.noProposals","proposal-not-found":"commands.reasons.proposalNotFound","host-disabled":"commands.reasons.hostDisabled","unsupported-command":"commands.reasons.unsupportedCommand","invalid-arguments":"commands.reasons.invalidArguments","permission-denied":"commands.reasons.permissionDenied","unsupported-policy":"commands.reasons.unsupportedPolicy","plugin-unavailable":"commands.reasons.pluginUnavailable",aborted:"commands.reasons.aborted","input-failed":"commands.reasons.inputFailed","document-replaced":"commands.reasons.documentReplaced","target-changed":"commands.reasons.targetChanged","gesture-active":"commands.reasons.gestureActive","proposal-stale":"commands.reasons.proposalStale","render-failed":"commands.reasons.renderFailed","command-failed":"commands.reasons.commandFailed"},Yi={"editor-unavailable":"The editor is not ready."};function Xe(e,t){return {code:e,message:t?t.translate(Zi[e]):Yi[e]??e}}var Gl=["automatic","plainText","number","percent","scientific","currency","date","time","custom"],jl=["all","inner","horizontal","vertical","outer","left","top","right","bottom","none"],Ul=["solid","dashed","dotted","double"],Vl=["left","center","right"],ql=["top","middle","bottom"],Zl=["overflow","wrap","clip"],Go=["all","horizontal","vertical","unmerge"],Ji=[.5,.75,.9,1,1.25,1.5,2],Bn=["Arial","Calibri","Cambria","Georgia","Roboto","Times New Roman","Verdana"],Wn=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],_n=1,$n=400,Gn=.25,jn=4,Yl=new Set(["bold","italic","strikethrough","paintFormat","fontFamily","fontSize","fontSizeStep","textColor","fillColor","numberFormat","decimalPlaces","borderPreset","borderStyle","borderColor","merge","horizontalAlignment","verticalAlignment","textWrapping"]),Qi=new Set(["proposalReject"]),eu=new Set(["increase","decrease"]);function Re(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Tt(e,t){return typeof t=="string"&&e.includes(t)}function cn(e){return typeof e=="string"&&/^#[0-9a-f]{6}$/i.test(e)}function _l(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function tu(e,t){if(t===void 0)return true;switch(e){case "fontFamily":return Re(t)&&typeof t.family=="string"&&t.family.trim()!=="";case "fontSize":return Re(t)&&_l(t.points,_n,$n);case "fontSizeStep":case "decimalPlaces":return Re(t)&&typeof t.direction=="string"&&eu.has(t.direction);case "textColor":case "fillColor":case "borderColor":return Re(t)&&cn(t.color);case "numberFormat":return Re(t)&&Tt(Gl,t.value);case "borderPreset":return Re(t)&&Tt(jl,t.value);case "borderStyle":return Re(t)&&Tt(Ul,t.value);case "merge":return Re(t)&&Tt(Go,t.value);case "horizontalAlignment":return Re(t)&&Tt(Vl,t.value);case "verticalAlignment":return Re(t)&&Tt(ql,t.value);case "textWrapping":return Re(t)&&Tt(Zl,t.value);case "zoom":return Re(t)&&_l(t.scale,Gn,jn);case "proposalsPanel":return t===null||Re(t)&&typeof t.open=="boolean";case "proposalAccept":return Re(t)&&typeof t.proposalId=="string"&&(t.force===void 0||typeof t.force=="boolean");case "proposalReject":return Re(t)&&typeof t.proposalId=="string";default:return t===null}}function _o(e,t){if(t)return e===void 0?"mixed":e}function Jl(e){return e.status==="loading"?"document-loading":e.status==="empty"?"no-document":null}function $l(e,t,n){return n.map(o=>({args:o,label:e.translate(Ne(t,o))}))}function $o(e,t,n){if(e.collaborative)return "collaboration-unsupported";let o=t.bottom-t.top+1,r=t.right-t.left+1;switch(n){case "all":return o>1||r>1?null:"multiple-cells-required";case "horizontal":return r>1?null:"multiple-columns-required";case "vertical":return o>1?null:"multiple-rows-required";case "unmerge":return t.merged.length>0?null:"no-merged-cells"}}function nu(e,t,n,o){let r=o.formatting,l=t,i=(s,b)=>({gate:null,value:s,active:l?s===l.value:void 0,options:$l(n,e,b.map(p=>({value:p})))});switch(e){case "bold":return {gate:null,active:_o(r?.bold,r)};case "italic":return {gate:null,active:_o(r?.italic,r)};case "strikethrough":return {gate:null,active:_o(r?.strikethrough,r)};case "paintFormat":return {gate:null,active:n.paintFormat};case "fontFamily":{let s=r?.fontFamily??null;return {gate:null,value:s,active:l?s?.toLowerCase()===String(l.family).toLowerCase():void 0,options:n.fontFamilies.map(b=>({args:{family:b},label:b}))}}case "fontSize":{let s=r?.fontSize??null;return {gate:null,value:s,active:l?s===l.points:void 0,options:n.fontSizes.map(b=>({args:{points:b},label:String(b)}))}}case "textColor":return {gate:null,value:r?.textColor??null};case "fillColor":return {gate:null,value:r?.fillColor??null};case "borderColor":return {gate:null,value:n.borderColor};case "numberFormat":{let s=r?{kind:r.numberFormat??null,pattern:r.numberFormatPattern??null}:null;return {gate:null,value:s,active:l?s?.kind===l.value:void 0,options:Gl.map(b=>({args:{value:b},label:n.translate(`toolbar.numberFormats.${b}`)}))}}case "borderPreset":return i(r?.borderPreset??null,jl);case "borderStyle":return i(n.borderStyle,Ul);case "horizontalAlignment":return i(r?.horizontalAlignment??null,Vl);case "verticalAlignment":return i(r?.verticalAlignment??null,ql);case "textWrapping":return i(r?.textWrapping??null,Zl);case "merge":{let s={rows:o.bottom-o.top+1,columns:o.right-o.left+1},b=$l(n,e,Go.map(g=>({value:g})));return l?{gate:$o(n,o,l.value),value:s}:{gate:Go.some(g=>!$o(n,o,g))?null:$o(n,o,"all"),value:s,options:b}}default:return {gate:null}}}function ou(e,t,n){if(e==="searchMenus")return {gate:"unsupported-command"};if(e==="zoom")return {gate:null,value:n.zoom,active:t?n.zoom===t.scale:void 0,options:Ji.map(i=>({args:{scale:i},label:`${Math.round(i*100)}%`}))};let o=Jl(n);if(o)return {gate:o};let r=n.readOnly&&(Ae[e].mutatesDocument||Qi.has(e))?"read-only":null,l;return Yl.has(e)?n.selection===null?l={gate:"cell-selection-required"}:n.selection==="chart"?l={gate:"unsupported-selection"}:l=nu(e,t,n,n.selection):l=ru(e,t,n),r?{...l,gate:r}:l}function ru(e,t,n){switch(e){case "undo":return {gate:n.canUndo||n.pendingInput?null:"nothing-to-undo"};case "redo":return {gate:n.canRedo?null:"nothing-to-redo"};case "exportPng":return {gate:n.pngExport?null:"png-unavailable"};case "proposalsPanel":return n.proposals?{gate:null,active:n.proposalsPanelOpen,value:n.proposals.length}:{gate:"unsupported-command"};case "proposalAccept":case "proposalReject":{if(!n.proposals)return {gate:"unsupported-command"};let o=n.proposals.map(l=>({args:{proposalId:l.id},label:l.label}));if(!t)return {gate:o.length>0?null:"no-proposals",options:o};let r=t.proposalId;return {gate:n.proposals.some(l=>l.id===r)?null:"proposal-not-found"}}default:return {gate:null}}}function Ql(e,t){if(!t)return Xe("editor-unavailable",null);let n=Jl(t)??(e&&t.readOnly?"read-only":null);return n?Xe(n,t):null}function ea(e){return Yl.has(e)}function mn(e,t,n){if(!n)return {enabled:false,disabledReason:Xe("editor-unavailable",null)};let o=tu(e,t)?n.hostDisabled?.has(e)?{gate:"host-disabled"}:ou(e,t,n):{gate:"invalid-arguments"},r={...o.active!==void 0?{active:o.active}:{},...o.value!==void 0?{value:o.value}:{},...o.options!==void 0&&t===void 0?{options:o.options.map(l=>({...l,state:mn(e,l.args,n)}))}:{}};return o.gate?{...r,enabled:false,disabledReason:Xe(o.gate,n)}:{...r,enabled:true}}var lu={"input-failed":"Input accepted earlier could not be written","document-replaced":"The workbook was replaced","target-changed":"The selection changed","gesture-active":"Finish the chart drag first","editor-unavailable":"The editor is not ready"},ve=class extends Error{constructor(n){super(lu[n]);Wt(this,"code",n);this.name="XlsxCommandAdmissionError";}},jo=512,Vo=new WeakMap;function it(e,t){return {ok:false,failure:Xe(e,t)}}function ta(e,t){return t===void 0?e:`${e}\0${JSON.stringify(t)}`}function au(e){switch(e){case "input-failed":case "target-changed":case "gesture-active":case "proposal-stale":case "render-failed":case "command-failed":return "editor-unavailable";case "document-replaced":case "aborted":return "plugin-unavailable";default:return e}}function na(e){return !Ce(e)&&Ae[e].mutatesDocument}function Uo(e){return zl(e)||Ce(e)}function qo(){let e=null,t=new Map,n=Object.freeze([]),o=Object.freeze([]),r=new WeakMap,l=new WeakSet,i=new Set,s=new Map,b=new Set,p=new Set,g=null,w=0,d=y=>{if(!e)return null;try{return e.environment(y)}catch(X){return console.error("[xlsx commands] reading editor state failed",X),null}},C=(y,X)=>{let u=t.get(y);if(!u)return {enabled:false,disabledReason:Xe("unsupported-command",X)};let E=Ql(u.descriptor.mutatesDocument,X);return E?{enabled:false,disabledReason:E}:u.state()},h=(y,X,u)=>Ce(y)?C(y,u):mn(y,X,u),D=()=>{w+=1;for(let y of [...i])y();},F=()=>{if(!(s.size<=jo))for(let[y,X]of s){if(s.size<=jo)break;X.holds===0&&X.read<w&&s.delete(y);}},H=(y,X)=>{let u=ta(y,X),E=s.get(u);if(!E){let M=Uo(y)?h(y,X,d(false)):{enabled:false,disabledReason:Xe("unsupported-command",d(false))};E={id:y,args:X,json:JSON.stringify(M),state:M,holds:0,read:w},s.set(u,E),F();}return E.read=w,E},S=()=>{let y=null;try{y=e?.chrome()??null;}catch(X){console.error("[xlsx commands] reading editor chrome failed",X);}if(!(y?.i18n===g?.i18n&&y===null==(g===null))){g=y;for(let X of [...p])X();}},k=()=>{if(S(),F(),s.size===0)return;let y=d(false),X=false;for(let u of s.values()){if(!Uo(u.id))continue;let E=h(u.id,u.args,y),M=JSON.stringify(E);M!==u.json&&(u.state=E,u.json=M,X=true);}X&&D();},W=(y,X)=>{try{return y.capture(X)}catch(u){return console.error("[xlsx commands] capturing a command target failed",u),null}},K=(y,X,u)=>Ce(y)?t.get(y).execute():e.perform(y,X,u);async function f(y,X,u,E){let M=e;if(!M)return it("editor-unavailable",null);let R=Ce(y)?null:y,z=R!==null&&M.ordered(R),N=u!==void 0?u:z&&R?W(M,R):null,$=()=>{if(e!==M)return it("editor-unavailable",null);if(N&&R){let tt=M.resume(N,R);if(tt)return it(tt,d(true))}else if(u!==void 0)return it("editor-unavailable",d(true));let le=E?.deny(y)??null;if(le)return it(le,d(true));let ue=d(true),Pe=h(y,X,ue);return Pe.enabled?E&&na(y)?it("unsupported-policy",ue):K(y,X,ue):{ok:false,failure:Pe.disabledReason}};try{return await(z||u!==void 0?M.admit($):$())}catch(le){return le instanceof ve?it(le.code,d(false)):(console.error(`[xlsx commands] ${y} failed`,le),it("command-failed",d(false)))}finally{k();}}let c=(y,X,u)=>Uo(y)?f(y,X,void 0,u):Promise.resolve(it("unsupported-command",d(false))),T=y=>Ce(y)?t.get(y)?.descriptor??null:Ae[y],x=Object.freeze({getDescriptor:T,getState:(y,X)=>H(y,X).state,subscribe(y){return i.add(y),()=>{i.delete(y);}},execute:(y,X)=>c(y,X)}),I=(y,X)=>{let u=e?W(e,y):null;return {execute:E=>f(y,E,u,X)}},P=y=>{let X=new Map,E=Object.freeze({getDescriptor:T,getState:(M,R)=>{let z=H(M,R).state,N=y.deny(M),$=!N&&z.enabled&&na(M),le=ta(M,R),ue=X.get(le);if(ue&&ue.base===z&&ue.denial===N&&ue.policy===$)return ue.state;let Pe=N?au(N):$?"unsupported-policy":null,{enabled:tt,disabledReason:wt,...U}=z,nt=Pe?{...U,enabled:false,disabledReason:Xe(Pe,d(false))}:z;return X.size>=jo&&X.delete(X.keys().next().value),X.set(le,{base:z,denial:N,policy:$,state:nt}),nt},subscribe(M){let R=[x.subscribe(M),y.subscribe(M)];return ()=>{for(let z of R)z();}},execute:(M,R)=>c(M,R,y)});return Vo.set(E,{...B,store:E,prepare:M=>I(M,y)}),E},B={store:x,attach(y){e=y,k();},detach(y){e===y&&(e=null,k());},refresh:k,hold(y,X){let u=H(y,X);u.holds+=1;let E=true;return ()=>{E&&(E=false,u.holds-=1);}},prepare:y=>I(y),registerChrome(y){return b.add(y),()=>{b.delete(y);}},ownsChrome(y){if(!(y instanceof Node))return false;for(let X of b)if(X.contains(y))return true;return false},chrome:()=>g,subscribeChrome(y){return p.add(y),()=>{p.delete(y);}},focusEditor(){e?.focusEditor();},setPluginCommands(y,X){t=new Map(y.map(u=>[u.descriptor.id,u])),n=Object.freeze(X.filter(u=>t.has(u))),o=Object.freeze(y.flatMap(u=>u.descriptor.shortcuts.map(({chord:E})=>({id:u.descriptor.id,chord:E})))),k(),D();},pluginToolbar:()=>n,pluginShortcuts:()=>o,scoped(y){let X=r.get(y);return X||(X=P(y),r.set(y,X),l.add(X)),X},ownsStore:y=>l.has(y)};return l.add(x),Vo.set(x,B),B}function Le(e){return Vo.get(e)??null}var Gt=qo().store;var ut=createContext(null);function iu({commands:e,children:t}){return jsx(ut.Provider,{value:e??Gt,children:t})}function fe(){let e=useContext(ut);if(!e)throw new Error("useXlsxCommands must be used inside XlsxEditor chrome or an XlsxCommandProvider");return e}function fn(e){return e===void 0?void 0:JSON.parse(e)}function oe(e,t){let n=fe(),o=t===void 0?void 0:JSON.stringify(t),r=useCallback(i=>{let s=Le(n)?.hold(e,fn(o)),b=n.subscribe(i);return ()=>{b(),s?.();}},[n,e,o]),l=useCallback(()=>n.getState(e,fn(o)),[n,e,o]);return useSyncExternalStore(r,l,l)}function xt(e,t){let n=fe(),o=oe(e,t),{t:r}=re(),l=n.getDescriptor(e),i=t===void 0?void 0:JSON.stringify(t),s=useCallback(b=>n.execute(e,b!==void 0?b:fn(i)??null),[n,e,i]);return useMemo(()=>{if(Ce(e)){let b=l,p=b?.shortcuts[0]?.chord;return {id:e,descriptor:b,state:o,label:b?.label??e,shortcut:p?Wo(p):null,execute:()=>s()}}return {id:e,descriptor:l,state:o,label:r(Ne(e,fn(i))),shortcut:Kn(e,fn(i)),execute:s}},[e,l,o,r,i,s])}function ra(){let e=Le(fe()),t=useCallback(o=>e?.subscribeChrome(o)??(()=>{}),[e]),n=useCallback(()=>e?.chrome()??null,[e]);return useSyncExternalStore(t,n,n)}function la(){let e;return {closed:new Promise(n=>{e=n;}),close:e}}function aa(e){return typeof e?.then=="function"}function Zo(e,t){return e.generation===t.generation&&e.source===t.source&&e.sheet===t.sheet&&e.row===t.row&&e.col===t.col}function sa(e){let t=null,n=null,o=la(),r=false,l=false,i=false,s=new WeakSet,b=[],p=[],g=f=>b=b.filter(c=>!Zo(c,f)),w=f=>b=[...b.filter(c=>!Zo(c,f)),f],d=()=>{let f=e.generation();b=b.filter(c=>c.generation===f);},C=f=>{let c=f.then(()=>{},()=>{});n=c,c.then(()=>{n===c&&(n=null,r=false);});},h=(f,c)=>{if(n){let x=n.then(()=>false),I=Promise.race([x,o.closed.then(()=>true)]).then(P=>P?c():f());return C(I),I}let T;try{T=f();}catch(x){return r=false,Promise.reject(x)}return aa(T)?(C(T),T):(r=false,Promise.resolve(T))},D=()=>{},F=()=>{throw new ve("document-replaced")},H=()=>{r=true,l&&(i=true);},S=f=>s.has(f)?true:e.write(f)?(s.add(f),g(f),true):false,k=()=>(d(),b.length>0),W=f=>{g(f),p.push(f),h(()=>{p.splice(p.indexOf(f),1),!(f.generation!==e.generation()||S(f))&&(r=!0,!p.some(c=>Zo(c,f))&&(w(f),t===null&&e.restore(f)&&(t=f)));},D);},K=(f,c)=>{if(e.generation()!==c)throw new ve("document-replaced");if(r||k())throw new ve("input-failed");if(!(!f||f.generation!==c)){if(!S(f))throw r=true,w(f),new ve("input-failed");t===f&&(t=null,e.close(f));}};return {get draft(){return t},get rejected(){return b},get pending(){return n!==null},setDraft(f){t=f;},input(f){return h(()=>{let c=x=>{x===!1&&H();},T;try{T=f();}catch{T=!1;}return aa(T)?T.then(c,()=>c(!1)):c(T)},D)},submit(f){return t===f&&(t=null),n?(W(f),true):f.generation!==e.generation()||S(f)?true:(w(f),t=f,false)},discard(f){g(f);},settle(){let f=t;return f?f.generation!==e.generation()?(t=null,true):n?(t=null,e.close(f),W(f),true):S(f)?(t===f&&(t=null,e.close(f)),true):false:true},runAfterPendingInput(f){if(k())return Promise.reject(new ve("input-failed"));l=true,i=false;let c;try{c=e.seal();}finally{l=false;}if(c.refused)return Promise.reject(new ve(c.refused));if(i)return Promise.reject(new ve("input-failed"));let T=e.generation(),x=c.composition;if(x){let P=x.then(B=>{if(B)return e.sync(),t});return h(async()=>{let B=await P;if(B===void 0)throw new ve("input-failed");return K(B,T),f()},F)}e.sync();let I=t;return h(()=>(K(I,T),f()),F)},reset(){o.close(),o=la(),n=null,r=false;}}}var Yo=new WeakMap;function ia(e,t){Yo.has(e)||Yo.set(e,t);}function Un(e){return Yo.get(e)??null}var Vn={"data-xlsx-plugin-chrome":""};function ua(e){return e instanceof Element&&e.closest("[data-xlsx-plugin-chrome]")!==null}var fu=new Set(["save"]),pu=new Set(["undo","redo"]);function da(e){let n=(e instanceof Element?e:null)?.closest("input, textarea, select, [contenteditable]");return n!=null&&n.getAttribute("contenteditable")!=="false"}function ca(e,t){useEffect(()=>{let n=o=>{if(o.defaultPrevented||o.isComposing||o.keyCode===229)return;let r=o.target,l=Un(o);if(!(l?e.ownsStore(l):r instanceof Node&&(t.current?.contains(r)??false)||e.ownsChrome(r)))return;let s=dn(o);if(!s){let b=e.pluginShortcuts().find(({chord:p})=>Bo(p,o));if(!b||da(r))return;o.preventDefault(),o.repeat||e.store.execute(b.id,null);return}da(r)&&!fu.has(s.id)||(o.preventDefault(),!(o.repeat&&!pu.has(s.id))&&e.store.execute(s.id,s.shortcut.args));};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,t]);}var bu=new Set(["zoom","searchMenus","proposalsPanel"]);function pa(e,t){let n=e.cell(t.sheet,t.top,t.left).a1,o=e.cell(t.sheet,t.bottom,t.right).a1;return `${n}:${o}`}function xu(e,t,n,o){let r={key:o,formatting:null,merged:[],canUndo:false,canRedo:false};try{let l=pa(e,{sheet:t,...n,merged:[],formatting:null});r.formatting=e.selectionFormatting(t,l),r.merged=e.mergedRanges(t,l);}catch{}try{let l=e.historyState();r.canUndo=l.canUndo,r.canRedo=l.canRedo;}catch{}return r}function hu(e,t,n){let o=(l,i,s,b)=>({start:{row:l,col:i},end:{row:s,col:b}}),r=[];if(n==="all")r.push({type:"mergeCells",sheet:e,range:o(t.top,t.left,t.bottom,t.right)});else if(n==="horizontal")for(let l=t.top;l<=t.bottom;l++)r.push({type:"mergeCells",sheet:e,range:o(l,t.left,l,t.right)});else if(n==="vertical")for(let l=t.left;l<=t.right;l++)r.push({type:"mergeCells",sheet:e,range:o(t.top,l,t.bottom,l)});else for(let l of t.merged)r.push({type:"unmergeCells",sheet:e,range:o(l.start.row,l.start.col,l.end.row,l.end.col)});return r}function ga(e,t){let n=useRef(t);n.current=t;let o=useRef(null);useLayoutEffect(()=>{let r=p=>{let g=n.current,w=g.handle(),d=g.view();if(!w||g.status()!=="ready")return null;let C=d.selection?normalizeRange(d.selection):{top:0,left:0,bottom:0,right:0},h=[g.generation(),g.mutation(),d.sheet,C.top,C.left,C.bottom,C.right].join(":");return !p&&o.current?.key===h||(o.current=xu(w,d.sheet,C,h)),o.current},l=p=>{let g=n.current,w=g.view(),d=r(p),C=null;return w.chartSelected?C="chart":w.selection&&d&&(C={sheet:w.sheet,...normalizeRange(w.selection),merged:d.merged,formatting:d.formatting}),{status:g.status(),readOnly:g.readOnly(),collaborative:g.collaborative(),selection:C,canUndo:d?.canUndo??false,canRedo:d?.canRedo??false,pendingInput:g.coordinator.draft!==null,zoom:w.zoom,paintFormat:w.capturedFormat!==null,borderStyle:w.borderStyle??d?.formatting?.borderStyle??null,borderColor:w.borderColor??d?.formatting?.borderColor??null,pngExport:w.pngExport,proposals:w.proposalsAvailable?w.proposals.map(h=>({id:h.id,label:h.agentId})):null,proposalsPanelOpen:w.proposalsPanelOpen,fontFamilies:Bn,fontSizes:Wn,translate:g.translate}},i=(p,g,w)=>{let d=n.current,C=d.handle(),h=c=>({ok:false,failure:Xe(c,w)});if(!C)return h("editor-unavailable");let D=(c=true)=>({ok:true,status:c?"executed":"noop"}),F=c=>{try{return c()}catch(T){return d.fail(T),h("command-failed")}},H=c=>F(()=>{let T=c();return d.apply(T),D(T.applied)}),S=g,k=typeof w.selection=="object"?w.selection:null,W=()=>{if(!k)throw new Error("no cell selection");return {sheet:k.sheet,range:pa(C,k)}},K=c=>H(()=>{let{sheet:T,range:x}=W();return C.patchRangeStyle(T,x,c)}),f=k?.formatting??null;switch(p){case "bold":return K({bold:f?.bold!==true});case "italic":return K({italic:f?.italic!==true});case "strikethrough":return K({strikethrough:f?.strikethrough!==true});case "paintFormat":return w.paintFormat?(d.setCapturedFormat(null,null),D()):F(()=>{let{sheet:c,range:T}=W(),x=`${c}:${k.top}:${k.left}:${k.bottom}:${k.right}`;return d.setCapturedFormat(C.captureFormat(c,T),x),D()});case "fontFamily":return K({fontFamily:S.family});case "fontSize":return K({fontSize:S.points});case "fontSizeStep":{let c=f?.fontSize??10,T=w.fontSizes,x=S.direction==="increase"?T.find(I=>I>c)??c+1:[...T].reverse().find(I=>I<c)??Math.max(1,c-1);return K({fontSize:x})}case "textColor":return K({textColor:S.color});case "fillColor":return K({fillColor:S.color});case "numberFormat":return H(()=>{let{sheet:c,range:T}=W();return S.value==="custom"?C.setNumberFormat(c,T,{type:"custom",pattern:f?.numberFormatPattern??"0.00"}):C.setNumberFormat(c,T,S.value)});case "decimalPlaces":return H(()=>{let{sheet:c,range:T}=W();return C.setNumberFormat(c,T,S.direction==="increase"?"increaseDecimal":"decreaseDecimal")});case "borderPreset":return K({border:{preset:S.value,style:w.borderStyle??"solid",color:w.borderColor??"#000000"}});case "borderStyle":return d.setBorderStyle(S.value),K({border:{style:S.value}});case "borderColor":return d.setBorderColor(S.color),K({border:{color:S.color}});case "horizontalAlignment":return K({horizontalAlignment:S.value});case "verticalAlignment":return K({verticalAlignment:S.value});case "textWrapping":return K({textWrapping:S.value});case "merge":{if(!k)return h("cell-selection-required");let c=hu(k.sheet,k,S.value);return c.length===0?D(false):H(()=>C.applyOps(c))}case "undo":return H(()=>C.undo());case "redo":return H(()=>C.redo());case "save":return F(()=>(d.deliver(C.save()),D()));case "exportPng":return F(()=>(d.exportPng(),D()));case "print":{let c=d.generation();return d.afterPaint().then(T=>n.current.generation()!==c?h("document-replaced"):T?(window.print(),D()):h("render-failed"))}case "zoom":return w.zoom===S.scale?D(false):(d.setZoom(S.scale),D());case "proposalsPanel":{let c=g===null?!w.proposalsPanelOpen:S.open;return c===w.proposalsPanelOpen?D(false):(d.setProposalsPanelOpen(c),D())}case "proposalAccept":try{return d.apply(C.acceptProposal(S.proposalId,{force:S.force})),d.markStale(S.proposalId,null),d.refreshProposals(),D()}catch(c){return c instanceof StaleProposalError?(d.markStale(S.proposalId,c.cells),d.refreshProposals(),h("proposal-stale")):(d.fail(c),h("command-failed"))}case "proposalReject":return F(()=>{let c=C.rejectProposal(S.proposalId);return d.markStale(S.proposalId,null),d.refreshProposals(),c?D():h("proposal-not-found")});default:return h("unsupported-command")}},s=p=>{if(!ea(p))return "document";let g=n.current.view();return g.chartSelected?"chart":g.selection?`${g.sheet}:${JSON.stringify(normalizeRange(g.selection))}`:"none"},b={environment:l,ordered:p=>{let g=n.current;return !bu.has(p)||g.coordinator.rejected.some(w=>w.generation===g.generation())},admit:p=>n.current.coordinator.runAfterPendingInput(p),perform:i,capture(p){let g=n.current;return g.handle()?{generation:g.generation(),target:s(p)}:null},resume(p,g){let w=n.current;return !w.handle()||w.generation()!==p.generation?"document-replaced":s(g)===p.target?null:"target-changed"},chrome:()=>({i18n:n.current.i18n()}),focusEditor:()=>n.current.focusGrid()};return e.attach(b),()=>e.detach(b)},[e]),useLayoutEffect(()=>{e.refresh();});}var dt=createContext(null),kt=createContext(null),qn=createContext(false);function Cu(){let e=useContext(dt);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}var gn=createContext(null),Zn={group:{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"},mark:{display:"grid",placeItems:"center",width:20,height:28,flex:"0 0 auto",color:"#64748b",font:"italic 700 12px Georgia, serif",userSelect:"none"},input:{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"}};function ba({className:e,style:t}){let n=useContext(gn),{t:o}=re();return n?jsxs("div",{className:e,style:{...Zn.group,...t},role:"group","aria-label":o("toolbar.formulaBarLabel"),children:[jsx("input",{"data-testid":"xlsx-name-box",readOnly:true,value:n.a1,placeholder:o("toolbar.nameBoxPlaceholder"),"aria-label":o("toolbar.nameBoxPlaceholder"),style:Zn.nameBox}),jsx("span",{style:Zn.mark,"aria-hidden":"true",children:"fx"}),jsx("input",{ref:n.inputRef,"data-testid":"xlsx-formula-input",value:n.value,placeholder:o("toolbar.formulaPlaceholder"),"aria-label":o("toolbar.formulaPlaceholder"),disabled:n.disabled,readOnly:n.readOnly,onChange:r=>n.onChange(r.target.value),onCompositionStart:n.onCompositionStart,onCompositionEnd:n.onCompositionEnd,onKeyDown:r=>{n.readOnly||r.nativeEvent.isComposing||r.keyCode===229||(r.key==="Enter"?(n.onCommit(r.shiftKey?"up":"down"),r.preventDefault()):r.key==="Escape"&&(n.onCancel(),r.preventDefault()));},onBlur:n.onBlur,style:Zn.input})]}):null}var wu={bold:"onFormat",italic:"onFormat",strikethrough:"onFormat",paintFormat:"onFormat",fontFamily:"onFormat",fontSize:"onFormat",fontSizeStep:"onFormat",textColor:"onFormat",fillColor:"onFormat",numberFormat:"onFormat",decimalPlaces:"onFormat",borderPreset:"onFormat",borderStyle:"onFormat",borderColor:"onFormat",merge:"onMerge",horizontalAlignment:"onFormat",verticalAlignment:"onFormat",textWrapping:"onFormat",searchMenus:"onSearchMenus",save:null,exportPng:null,print:"onPrint",undo:"onUndo",redo:"onRedo",zoom:"onZoomChange",proposalsPanel:null,proposalAccept:null,proposalReject:null},xa=10;function Xu(e,t,n){return n>0?t.find(o=>o>e)??e+1:[...t].reverse().find(o=>o<e)??Math.max(1,e-1)}function Eu(e,t,n){let o=t;switch(e){case "bold":case "italic":case "strikethrough":case "paintFormat":return e;case "numberFormat":return {type:"numberFormat",value:o.value};case "decimalPlaces":return o.direction==="increase"?"increaseDecimal":"decreaseDecimal";case "fontSizeStep":{let r=n.selection,l=typeof r=="object"&&r?.formatting?.fontSize||xa;return {type:"fontSize",value:Xu(l,n.fontSizes,o.direction==="increase"?1:-1)}}case "fontFamily":return {type:"fontFamily",value:o.family};case "fontSize":return {type:"fontSize",value:o.points};case "textColor":case "fillColor":case "borderColor":return {type:e,value:o.color};case "borderPreset":case "borderStyle":case "horizontalAlignment":case "verticalAlignment":case "textWrapping":return {type:e,value:o.value};default:return null}}function Ru(e,t){let n=e.currentFormatting??{},o=Math.max(1,e.selectionShape?.rows??1),r=Math.max(1,e.selectionShape?.columns??1),l={row:0,col:0};return {status:"ready",readOnly:false,collaborative:false,selection:{sheet:0,top:0,left:0,bottom:o-1,right:r-1,merged:e.selectionShape?.canUnmerge?[{start:l,end:l}]:[],formatting:{...n,fontFamily:n.fontFamily??"Calibri",fontSize:n.fontSize??xa,bold:n.bold??false,italic:n.italic??false,strikethrough:n.strikethrough??false}},canUndo:e.canUndo??false,canRedo:e.canRedo??false,pendingInput:false,zoom:e.zoom??1,paintFormat:n.paintFormat??false,borderStyle:n.borderStyle??null,borderColor:n.borderColor??null,pngExport:false,proposals:null,proposalsPanelOpen:false,fontFamilies:e.fontFamilies??Bn,fontSizes:e.fontSizes??Wn,hostDisabled:new Set(Fl.filter(i=>{let s=wu[i];return e.disabled||!s||!e[s]})),translate:t}}function ha(e,t,n){let o=Ru(e,n),r=new Map,l=(i,s)=>Ce(i)?{enabled:false,disabledReason:Xe("unsupported-command",o)}:i==="searchMenus"&&!o.hostDisabled?.has(i)?{enabled:true}:mn(i,s,o);return Object.freeze({getDescriptor(i){return Ce(i)?null:Ae[i]},getState(i,s){let b=s===void 0?i:`${i}\0${JSON.stringify(s)}`,p=r.get(b);return p||(p=l(i,s),r.set(b,p)),p},subscribe:()=>()=>{},async execute(i,s){let b=l(i,s);if(!b.enabled)return {ok:false,failure:b.disabledReason};let p=t();if(i==="merge")p.onMerge?.(s.value);else if(i==="searchMenus")p.onSearchMenus?.();else if(i==="undo")p.onUndo?.();else if(i==="redo")p.onRedo?.();else if(i==="print")p.onPrint?.();else if(i==="zoom")p.onZoomChange?.(s.scale);else {let g=Eu(i,s,o);g&&p.onFormat?.(g);}return {ok:true,status:"requested"}}})}function ya(e){switch(e){case "bold":case "italic":case "strikethrough":case "paintFormat":return {id:e,args:null};case "currency":case "percent":return {id:"numberFormat",args:{value:e}};case "increaseDecimal":return {id:"decimalPlaces",args:{direction:"increase"}};case "decreaseDecimal":return {id:"decimalPlaces",args:{direction:"decrease"}}}switch(e.type){case "fontFamily":return {id:"fontFamily",args:{family:e.value}};case "fontSize":return {id:"fontSize",args:{points:e.value}};case "textColor":case "fillColor":case "borderColor":return {id:e.type,args:{color:e.value}};default:return {id:e.type,args:{value:e.value}}}}function be({name:e,size:t=20,style:n}){return jsxs("svg",{width:t,height:t,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,...n},children:[e==="search"&&jsxs(Fragment,{children:[jsx("circle",{cx:"10.5",cy:"10.5",r:"6"}),jsx("path",{d:"m15 15 4.5 4.5"})]}),e==="undo"&&jsx("path",{d:"m9 7-5 5 5 5M5 12h9a6 6 0 0 1 6 6"}),e==="redo"&&jsx("path",{d:"m15 7 5 5-5 5m4-5h-9a6 6 0 0 0-6 6"}),e==="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"})]}),e==="formatPaint"&&jsxs(Fragment,{children:[jsx("path",{d:"M5 4h11v5H5zM8 9v3h5V9"}),jsx("path",{d:"M10.5 12v8"})]}),e==="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"})]}),e==="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"})]}),e==="bold"&&jsx("path",{d:"M7 4h6a4 4 0 0 1 0 8H7zm0 8h7a4 4 0 0 1 0 8H7z"}),e==="italic"&&jsx("path",{d:"M10 4h8M6 20h8M14 4 10 20"}),e==="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"})}),e==="textColor"&&jsxs(Fragment,{children:[jsx("path",{d:"m7 16 5-12 5 12M9 11h6"}),jsx("path",{d:"M5 20h14",strokeWidth:"3"})]}),e==="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"})]}),e==="borders"&&jsx(Fragment,{children:jsx("path",{d:"M4 4h16v16H4zM12 4v16M4 12h16"})}),e==="merge"&&jsxs(Fragment,{children:[jsx("path",{d:"M4 5h16v14H4z"}),jsx("path",{d:"m8 9 3 3-3 3M16 9l-3 3 3 3"})]}),e==="alignLeft"&&jsx("path",{d:"M4 6h16M4 10h11M4 14h16M4 18h11"}),e==="verticalAlignCenter"&&jsxs(Fragment,{children:[jsx("path",{d:"M4 4h16M4 20h16M8 12h8"}),jsx("path",{d:"m10 9 2 3 2-3M10 15l2-3 2 3"})]}),e==="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"})]}),e==="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"})]}),e==="chevronDown"&&jsx("path",{d:"m7 10 5 5 5-5"}),e==="remove"&&jsx("path",{d:"M5 12h14"}),e==="add"&&jsx("path",{d:"M12 5v14M5 12h14"}),e==="check"&&jsx("path",{d:"m5 12 4 4L19 6"}),e==="save"&&jsx("path",{d:"M12 3v11m0 0 4-4m-4 4-4-4M5 19h14"}),e==="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"})]}),e==="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 Tu=500;function Yn(e){let t=useRef(e);t.current=e;let n=useRef({buffer:"",at:0}),o=useCallback(()=>{let{container:i,itemSelector:s,scope:b}=t.current,p=i.current;return p?Array.from(p.querySelectorAll(s)).filter(g=>!b||g.closest(b)===p):[]},[]),r=useCallback(i=>{let s=o();s.length!==0&&s[(i+s.length)%s.length].focus();},[o]),l=useCallback(i=>{let s=o();if(s.length===0)return false;let b=s.findIndex(C=>C===document.activeElement),p=(t.current.orientation??"vertical")==="vertical",g=p?"ArrowDown":"ArrowRight",w=p?"ArrowUp":"ArrowLeft",d=null;if(i.key===g)d=b+1;else if(i.key===w)d=b<0?s.length-1:b-1;else if(i.key==="Home")d=0;else if(i.key==="End")d=s.length-1;else if(i.key.length===1&&i.key!==" "&&!i.ctrlKey&&!i.metaKey&&!i.altKey){let C=Date.now(),h=n.current;h.buffer=C-h.at>Tu?i.key.toLowerCase():h.buffer+i.key.toLowerCase(),h.at=C;let D=t.current.labelOf??(k=>k.textContent??""),F=[...s.slice(b+1),...s.slice(0,b+1)],H=[...h.buffer].every(k=>k===h.buffer[0]),S=F.find(k=>D(k).trim().toLowerCase().startsWith(h.buffer))??(H?F.find(k=>D(k).trim().toLowerCase().startsWith(h.buffer[0])):void 0);return S?(i.preventDefault(),S.focus(),true):false}return d===null?false:(i.preventDefault(),r(d),true)},[r,o]);return {items:o,focusFirst:useCallback(()=>r(0),[r]),focusLast:useCallback(()=>r(-1),[r]),onKeyDown:l}}var Qe=createContext(null);function Sa(e,t){for(let n of e){if(n.kind==="item"&&n.id===t)return n;if(n.kind==="group"||n.kind==="submenu"){let o=Sa(n.entries,t);if(o)return o}}return null}function wa(e,t){return e.map(n=>n.kind==="item"?{...n,onSelect:()=>{let o=Sa(t(),n.id);o&&!o.disabled&&o.onSelect();}}:n.kind==="group"||n.kind==="submenu"?{...n,entries:wa(n.entries,t)}:n)}function Mu(e){return JSON.stringify(e,(t,n)=>t==="icon"||typeof n=="function"?void 0:n)}function It(e,t){let n=useContext(Qe),o=useRef(t);o.current=t;let r=useRef(null),l=t!==null;useLayoutEffect(()=>{if(!n||!l)return;let i=()=>o.current?.()??[];return r.current=null,n.register({element:()=>e.current,entries:()=>wa(i(),i)})},[n,e,l]),useLayoutEffect(()=>{if(!n||!l)return;if(!n.overflowing()){r.current=null;return}let i=Mu(o.current?.()??[]);r.current!==i&&n.changed(),r.current=i;});}var q={text:"#3c4043",muted:"#5f6368",disabled:"#9aa0a6",hover:"#e2e7ef",active:"#d3e3fd",border:"#c7cacf",surface:"#ffffff",rail:"#edf2fa"},Ou={appearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:2,minWidth:28,height:28,padding:"0 5px",border:0,borderRadius:4,color:q.text,font:"500 13px ui-sans-serif, system-ui, sans-serif",lineHeight:1,whiteSpace:"nowrap",boxSizing:"border-box"};function Ea(e,t,n,o){return {...Ou,background:t?q.active:n&&!e?q.hover:"transparent",color:e?q.disabled:q.text,cursor:e?"default":"pointer",opacity:e?.48:1,...o}}function Ra(e,t,n){let o=t?`${e} (${t})`:e;return n?`${o}: ${n}`:o}function ct({active:e,toggle:t=false,disabled:n=false,description:o,title:r,shortcut:l,onClick:i,children:s,style:b,testId:p,ariaExpanded:g,className:w,overflow:d}){let[C,h]=useState(false),D=useRef(null),F=useId(),H=n&&o?o:void 0,S=t?e??false:e||void 0;return It(D,d!==void 0?d:()=>[{kind:"item",id:F,label:r,shortcut:l??void 0,checked:t?e??false:e,disabled:n,description:H,onSelect:()=>i?.()}]),jsxs(Fragment,{children:[jsx("button",{ref:D,type:"button",className:w,"data-testid":p,disabled:n&&!H,"aria-disabled":H?true:void 0,"aria-describedby":H?F:void 0,"aria-label":r,"aria-pressed":S,"aria-expanded":g,title:Ra(r,l,H),onMouseDown:k=>k.preventDefault(),onMouseEnter:()=>h(true),onMouseLeave:()=>h(false),onClick:n?void 0:i,style:Ea(n,e===true,C,b),children:s}),H&&jsx("span",{id:F,hidden:true,children:H})]})}function Du(e){return jsx(ct,{...e})}function xe({label:e,children:t,style:n}){return jsx("div",{role:"group","aria-label":e,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto",...n},children:t})}function xn(){return jsx("div",{role:"separator","aria-orientation":"vertical",style:{width:1,height:24,margin:"0 5px",background:q.border,flex:"0 0 auto"}})}var Fu='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]',zu=new Set(["menuitem","menuitemradio","menuitemcheckbox","separator"]),Hu='button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])',ht=8,tr=440;function Nu(e,t,n){let o=window.innerHeight,r=Math.max(0,o-ht-(e.bottom+4)),l=Math.max(0,e.top-4-ht),i=Math.max(ht,Math.min(e.left,window.innerWidth-n-ht));if(Math.min(t,tr)<=r||r>=l){let p=Math.min(tr,r),g=Math.min(e.bottom+4,o-ht-p);return {top:Math.max(ht,g),left:i,maxHeight:p}}let s=Math.min(tr,l),b=e.top-4-Math.min(t,s);return {top:Math.max(ht,b),left:i,maxHeight:s}}function hn({title:e,trigger:t,children:n,disabled:o=false,description:r,active:l=false,menuWidth:i=220,style:s,testId:b}){let[p,g]=useState(null),[w,d]=useState("menu"),[C,h]=useState(false),[D,F]=useState({top:0,left:0,maxHeight:440}),H=useRef(null),S=useRef(null),k=useId(),W=useId(),K=o&&r?r:void 0,f=Yn({container:S,itemSelector:Fu,labelOf:P=>P.getAttribute("aria-label")??P.textContent??""}),c=useRef(f);c.current=f;let T=useCallback((P=false)=>{g(null),P&&H.current?.focus({preventScroll:true});},[]),x=useCallback(()=>T(S.current?.contains(document.activeElement)??false),[T]);useLayoutEffect(()=>{let P=H.current,B=S.current;if(!p||!P||!B)return;F(Nu(P.getBoundingClientRect(),B.scrollHeight,i));let y=Array.from(B.children).every(X=>X.hasAttribute("hidden")||zu.has(X.getAttribute("role")??""));d(y?"menu":"dialog"),p!=="pointer"&&(y?p==="first"?c.current.focusFirst():c.current.focusLast():B.querySelector(Hu)?.focus({preventScroll:true}));},[p,i]),useEffect(()=>{if(!p)return;let P=X=>{let u=X.target;!H.current?.contains(u)&&!S.current?.contains(u)&&T();},B=X=>{X.key==="Escape"&&T();},y=X=>{X.target instanceof Node&&S.current?.contains(X.target)||T();};return document.addEventListener("mousedown",P),document.addEventListener("keydown",B),window.addEventListener("scroll",y,true),()=>{document.removeEventListener("mousedown",P),document.removeEventListener("keydown",B),window.removeEventListener("scroll",y,true);}},[p,T]);let I=P=>{if(P.key==="Escape"){P.preventDefault(),P.stopPropagation(),T(true);return}if(w==="menu"){if(P.key==="Tab"){T();return}f.onKeyDown(P)&&P.stopPropagation();}};return jsxs("div",{style:{position:"relative",display:"inline-flex",flex:"0 0 auto"},children:[jsx("button",{ref:H,type:"button","data-testid":b,disabled:o&&!K,"aria-disabled":K?true:void 0,"aria-describedby":K?W:void 0,"aria-label":e,"aria-haspopup":w,"aria-expanded":p!==null,"aria-controls":p?k:void 0,title:Ra(e,null,K),onMouseDown:P=>P.preventDefault(),onMouseEnter:()=>h(true),onMouseLeave:()=>h(false),onClick:()=>!o&&g(P=>P?null:"pointer"),onKeyDown:P=>{o||(P.key==="Enter"||P.key===" "||P.key==="ArrowDown"?(P.preventDefault(),g("first")):P.key==="ArrowUp"?(P.preventDefault(),g("last")):P.key==="Escape"&&p&&(P.preventDefault(),T()));},style:Ea(o,l||p!==null,C,s),children:t}),K&&jsx("span",{id:W,hidden:true,children:K}),p&&jsx("div",{ref:S,id:k,role:w,"aria-label":e,"aria-orientation":w==="menu"?"vertical":void 0,tabIndex:-1,onKeyDown:I,onBlur:P=>{if(w!=="dialog")return;let B=P.relatedTarget;B&&!S.current?.contains(B)&&!H.current?.contains(B)&&T();},onMouseDown:P=>P.preventDefault(),style:{position:"fixed",top:D.top,left:D.left,zIndex:1e4,width:i,maxWidth:`calc(100vw - ${2*ht}px)`,maxHeight:D.maxHeight,overflowY:"auto",padding:6,border:`1px solid ${q.border}`,borderRadius:8,background:q.surface,boxShadow:"0 4px 16px rgba(60, 64, 67, 0.24)",boxSizing:"border-box",outline:"none"},children:n(x)})]})}function to({label:e,icon:t,selected:n,disabled:o=false,description:r,onClick:l,close:i}){let[s,b]=useState(false),p=useId(),g=o&&r?r:void 0;return jsxs(Fragment,{children:[jsxs("button",{type:"button",role:n===void 0?"menuitem":"menuitemradio",tabIndex:-1,"aria-checked":n,"aria-disabled":o||void 0,"aria-describedby":g?p:void 0,"aria-label":e,title:g,onMouseEnter:()=>b(true),onMouseLeave:()=>b(false),onClick:()=>{o||(l?.(),i?.());},style:{appearance:"none",display:"flex",alignItems:"center",gap:10,width:"100%",minHeight:32,padding:"5px 9px",border:0,borderRadius:4,background:s&&!o?q.hover:"transparent",color:o?q.disabled:q.text,cursor:o?"default":"pointer",opacity:o?.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:t}),jsx("span",{style:{flex:1},children:e}),n&&jsx("span",{"aria-hidden":"true",children:"\u2713"})]}),g&&jsx("span",{id:p,hidden:true,children:g})]})}function yn(){return jsx("div",{role:"separator",style:{height:1,margin:"5px 2px",background:q.border}})}function ka({mode:e,value:t,label:n,onChange:o,onOpen:r,disabled:l=false,description:i}){let[s,b]=useState(false),p=useId(),g=l&&i?i:void 0,w=g?`${n}: ${g}`:n;return jsxs("label",{title:w,"aria-label":n,style:{position:"relative",display:"inline-grid",placeItems:"center",width:28,height:28,borderRadius:4,background:s&&!l?q.hover:"transparent",color:l?q.disabled:q.text,cursor:l?"default":"pointer",opacity:l?.48:1,boxSizing:"border-box"},onMouseEnter:()=>b(true),onMouseLeave:()=>b(false),children:[jsx(be,{name:e==="text"?"textColor":e==="fill"?"fillColor":"borders",size:20}),jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:5,right:5,bottom:2,height:3,borderRadius:2,background:t}}),jsx("input",{type:"color",value:t,disabled:l&&!g,"aria-disabled":g?true:void 0,"aria-describedby":g?p:void 0,"aria-label":n,onClick:d=>{l?d.preventDefault():r?.();},onKeyDown:d=>{l&&(d.key==="Enter"||d.key===" ")&&d.preventDefault();},onChange:d=>{l||o?.(d.target.value);},style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0}}),g&&jsx("span",{id:p,hidden:true,children:g})]})}function lr({value:e,options:t,label:n,onCommit:o,disabled:r=false,description:l,width:i=72,inputStyle:s,testId:b}){let p=useId(),g=r&&l?l:void 0,[w,d]=useState(e),[C,h]=useState(false),[D,F]=useState({top:0,left:0,width:i}),H=useRef(null),S=useRef(null),k=useRef(null);useEffect(()=>d(e),[e]);let W=useCallback(()=>h(false),[]);useEffect(()=>{if(!C||!H.current)return;let f=H.current.getBoundingClientRect();F({top:f.bottom+4,left:f.left,width:Math.max(f.width,i)});},[C,i]),useEffect(()=>{if(!C)return;let f=T=>{let x=T.target;!H.current?.contains(x)&&!S.current?.contains(x)&&W();},c=T=>{T.key==="Escape"&&(d(e),W());};return document.addEventListener("mousedown",f),document.addEventListener("keydown",c),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",c);}},[C,W,e]);let K=useCallback(()=>{let f=w.trim();!r&&o&&f&&f!==e&&o(f,false),d(e);},[r,o,w,e]);return jsxs("div",{ref:H,style:{display:"inline-flex",alignItems:"center",width:i,height:28,border:`1px solid ${q.border}`,borderRadius:4,background:r?"rgba(255,255,255,0.5)":q.surface,opacity:r?.48:1,boxSizing:"border-box",flex:"0 0 auto"},children:[jsx("input",{ref:k,"data-testid":b,role:"combobox","aria-label":n,"aria-autocomplete":"list","aria-expanded":C,disabled:r&&!g,readOnly:!!g,"aria-disabled":g?true:void 0,"aria-describedby":g?p:void 0,title:g?`${n}: ${g}`:void 0,value:w,onFocus:f=>{r||(h(true),f.currentTarget.select());},onChange:f=>d(f.target.value),onKeyDown:f=>{f.key==="Enter"?(K(),W()):f.key==="ArrowDown"&&(h(true),f.preventDefault());},onBlur:()=>{requestAnimationFrame(()=>{S.current?.contains(document.activeElement)||K();});},style:{appearance:"none",width:"calc(100% - 22px)",height:26,padding:"0 2px 0 7px",border:0,outline:0,background:"transparent",color:q.text,font:"500 13px ui-sans-serif, system-ui, sans-serif",boxSizing:"border-box",...s}}),jsx("button",{type:"button",disabled:r,tabIndex:-1,"aria-label":n,title:n,onMouseDown:f=>f.preventDefault(),onClick:()=>{r||(h(f=>!f),k.current?.focus());},style:{appearance:"none",display:"grid",placeItems:"center",width:21,height:26,padding:0,border:0,background:"transparent",color:q.muted,cursor:r?"default":"pointer"},children:jsx(be,{name:"chevronDown",size:14})}),g&&jsx("span",{id:p,hidden:true,children:g}),C&&!r&&jsx("div",{ref:S,role:"listbox","aria-label":n,style:{position:"fixed",top:D.top,left:D.left,zIndex:1e4,width:D.width,maxHeight:260,overflowY:"auto",padding:4,border:`1px solid ${q.border}`,borderRadius:6,background:q.surface,boxShadow:"0 4px 16px rgba(60, 64, 67, 0.24)",boxSizing:"border-box"},children:t.map(f=>jsx("button",{type:"button",role:"option","aria-selected":f.value===e,onMouseDown:c=>c.preventDefault(),onClick:()=>{d(f.label),o?.(f.value,true),W();},style:{appearance:"none",display:"block",width:"100%",minHeight:28,padding:"4px 7px",border:0,borderRadius:3,background:f.value===e?q.active:"transparent",color:q.text,cursor:"pointer",font:"400 13px ui-sans-serif, system-ui, sans-serif",textAlign:"left"},children:f.label},f.value))})]})}function ar({preset:e}){let t=n=>e===n||e==="all"||e==="outer"?2:.6;return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","aria-hidden":"true",children:[e!=="none"&&jsxs(Fragment,{children:[jsx("path",{d:"M3 3h14",strokeWidth:t("top")}),jsx("path",{d:"M17 3v14",strokeWidth:t("right")}),jsx("path",{d:"M3 17h14",strokeWidth:t("bottom")}),jsx("path",{d:"M3 3v14",strokeWidth:t("left")}),(e==="all"||e==="inner"||e==="horizontal")&&jsx("path",{d:"M3 10h14",strokeWidth:"1.5"}),(e==="all"||e==="inner"||e==="vertical")&&jsx("path",{d:"M10 3v14",strokeWidth:"1.5"})]}),e==="none"&&jsx("path",{d:"M4 4h12v12H4zM3 17 17 3",strokeWidth:"1.5"})]})}function sr({value:e}){let t=e==="left"?3:e==="center"?5:7,n=e==="left"?15:e==="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${t} 7h${n-t}M${t} 13h${n-t}`})]})}function ir({value:e}){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 ${e==="top"?5:e==="middle"?10:15}h8`}),jsx("path",{d:e==="top"?"m8 8 2-3 2 3":e==="bottom"?"m8 12 2 3 2-3":"m8 7 2 3 2-3m-4 6 2-3 2 3"})]})}function ur({value:e}){return jsx("svg",{width:"44",height:"12",viewBox:"0 0 44 12",fill:"none",stroke:"currentColor","aria-hidden":"true",children:e==="double"?jsx("path",{d:"M2 4h40M2 8h40"}):jsx("path",{d:"M2 6h40",strokeWidth:"2",strokeDasharray:e==="dashed"?"7 4":e==="dotted"?"1 4":void 0})})}function dr({color:e}){return jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:20,height:5,borderRadius:2,background:e}})}var ju={searchMenus:"search",undo:"undo",redo:"redo",print:"print",paintFormat:"formatPaint",bold:"bold",italic:"italic",strikethrough:"strikethrough",merge:"merge",save:"save",exportPng:"image",proposalsPanel:"proposals"},Uu={searchMenus:"xlsx-search-menus",undo:"xlsx-undo",redo:"xlsx-redo",save:"xlsx-save",exportPng:"xlsx-export-png",proposalsPanel:"xlsx-proposals-button"},Aa=new Set(["bold","italic","strikethrough","paintFormat","proposalsPanel","borderStyle","horizontalAlignment","verticalAlignment","textWrapping"]),La=new Set(["fontFamily","fontSize","numberFormat","borderPreset","borderStyle","merge","horizontalAlignment","verticalAlignment","textWrapping","zoom"]),Oa=new Set(["textColor","fillColor","borderColor"]),cr={textColor:"#000000",fillColor:"#ffffff",borderColor:"#000000"};function Ke(e){return e.enabled?void 0:e.disabledReason.message}function vn(e,t,n,o){e.execute(t,n).then(r=>o?.(r));}function Vu(e){requestAnimationFrame(()=>Le(e)?.focusEditor());}function Pn(e,t){return Le(e)?.prepare(t)??{execute:n=>e.execute(t,n)}}function Da(e,t,n){let o=t;if(e==="numberFormat"&&o?.value==="currency")return jsx("span",{style:{fontSize:16},children:n("toolbar.currencySymbol")});if(e==="numberFormat"&&o?.value==="percent")return jsx("span",{style:{fontSize:15},children:"%"});if(e==="decimalPlaces")return jsx(be,{name:o?.direction==="increase"?"decimalIncrease":"decimalDecrease"});if(e==="fontSizeStep")return jsx(be,{name:o?.direction==="increase"?"add":"remove"});if(e==="borderPreset"&&o)return jsx(ar,{preset:o.value});if(e==="borderStyle"&&o)return jsx(ur,{value:o.value});if(e==="horizontalAlignment"&&o)return jsx(sr,{value:o.value});if(e==="verticalAlignment"&&o)return jsx(ir,{value:o.value});let r=ju[e];return r?jsx(be,{name:r}):null}function Fa(e,t,n){if(!(e==="numberFormat"||e==="merge"))return Da(e,t,n)??void 0}function qu(e,t){return e==="merge"&&t?.value==="all"?"xlsx-merge-all":t==null?Uu[e]:void 0}function Zu(e,t,n,o,r){let l=e.getState(n,o),i=Aa.has(n)&&l.active!==void 0;return {kind:"item",id:o===void 0?n:`${n}:${JSON.stringify(o)}`,label:r??t(Ne(n,o)),icon:Fa(n,o,t),shortcut:Kn(n,o)??void 0,checked:i?l.active:void 0,disabled:!l.enabled,description:Ke(l),onSelect:()=>vn(e,n,o??null)}}function ro(e,t,n,o=e.getState(n)){let r=n!=="merge";return (o.options??[]).flatMap((l,i)=>{let s=l.state,b={kind:"item",id:`${n}-${i}`,label:l.label,icon:Fa(n,l.args,t),...r?{radio:true,checked:s.active===true}:{},disabled:!s.enabled,description:Ke(s),onSelect:()=>vn(e,n,l.args)};return n==="merge"&&l.args.value==="unmerge"?[{kind:"separator",id:`${n}-separator`},b]:[b]})}function za(e,t,n,o){let r=e.getState(n),l=cn(r.value)?r.value:cr[n];return {kind:"item",id:n,label:t(Ne(n)),icon:jsx(dr,{color:l}),disabled:!r.enabled||!o,description:Ke(r),onSelect:()=>{let i=Pn(e,n);o?.pickColor({value:l,submit:s=>{i.execute({color:s});}});}}}function Yu(e,t,n,o){if(!o)return null;let r=e.getState(n),l=n==="zoom";return {kind:"item",id:`${n}-custom`,label:t(l?"commands.customZoom":"commands.customFontSize"),disabled:!r.enabled,description:Ke(r),onSelect:()=>{let i=Pn(e,n),s=typeof r.value=="number"?r.value:null;o.prompt({title:t(Ne(n)),label:t(l?"commands.zoomPercent":"commands.fontSizePoints"),initialValue:s===null?"":String(l?Math.round(s*100):s),valid:b=>{let p=Number(b);return /^\d+(\.\d+)?$/.test(b)?l?p/100>=Gn&&p/100<=jn:p>=_n&&p<=$n:false},submit:b=>{l?i.execute({scale:Number(b)/100}):i.execute({points:Number(b)});}});}}}function Ju(e,t,n){return [...ro(e,t,"borderPreset"),{kind:"separator",id:"borders-styles"},...ro(e,t,"borderStyle"),{kind:"separator",id:"borders-color"},za(e,t,"borderColor",n)]}function Ha(e,t,n,o,r=null,l){if(o===void 0){if(Oa.has(n))return za(e,t,n,r);if(La.has(n)){let i=e.getState(n),s=n==="borderPreset"?Ju(e,t,r):ro(e,t,n),b=n==="fontSize"||n==="zoom"?Yu(e,t,n,r):null;return {kind:"submenu",id:n,label:l??t(Ne(n)),disabled:!i.enabled,description:Ke(i),entries:b?[...s,b]:s}}}return Zu(e,t,n,o,l)}function Na(e,t,n){let o=fe(),{t:r}=re(),l=useContext(Qe);It(e,()=>[Ha(o,r,t,n,l)]);}function yt(e){return Ce(e.id)?jsx(Qu,{id:e.id,label:e.label,className:e.className,children:e.children}):jsx(ed,{...e})}function Qu({id:e,label:t,className:n,children:o}){let r=xt(e);if(r.descriptor===null)return null;let l=r.state,i=t??r.label,s=l.active!==void 0;return jsx(ct,{active:s?l.active:void 0,toggle:s,disabled:!l.enabled,description:l.enabled?void 0:l.disabledReason.message,title:i,shortcut:r.shortcut,className:n,style:o?void 0:{padding:"0 8px"},onClick:()=>{r.execute();},children:o??i})}function ed(e){let{id:t,children:n,label:o,className:r}=e,l=e.args,i=fe(),s=xt(t,l),{t:b}=re(),p=useContext(Qe),g=s.state,w=o??s.label,d=Aa.has(t)&&g.active!==void 0;return jsx(ct,{active:d?g.active:void 0,toggle:d,disabled:!g.enabled,description:Ke(g),title:w,shortcut:s.shortcut,testId:qu(t,l),className:r,onClick:()=>{s.execute();},overflow:()=>[Ha(i,b,t,l,p,w)],children:n??Da(t,l,b)??w})}function lo({id:e,close:t}){let n=fe(),{t:o}=re(),r=oe(e);return jsx(Fragment,{children:ro(n,o,e,r).map(l=>l.kind==="item"?jsx(to,{label:l.label,icon:l.icon,selected:l.radio?l.checked===true:void 0,disabled:l.disabled,description:l.description,onClick:l.onSelect,close:t},l.id):jsx(yn,{},l.id))})}function td({inputRef:e,onPick:t}){return jsx("input",{ref:e,type:"color",tabIndex:-1,"aria-hidden":"true",onChange:n=>t(n.target.value),style:{position:"absolute",width:1,height:1,padding:0,border:0,opacity:0,pointerEvents:"none"}})}function mr(e,t){if(!e)return;e.value=t;let n=e;try{n.showPicker?n.showPicker():e.click();}catch{e.click();}}function nd(){let e=fe(),{t}=re(),n=oe("borderPreset"),o=oe("borderColor"),r=useRef(null),l=useRef(null),i=cn(o.value)?o.value:cr.borderColor;return jsxs(Fragment,{children:[jsx(hn,{title:t("toolbar.borders"),disabled:!n.enabled,description:Ke(n),menuWidth:240,trigger:jsxs(Fragment,{children:[jsx(ar,{preset:n.value??"all"}),jsx(be,{name:"chevronDown",size:12})]}),children:s=>jsxs(Fragment,{children:[jsx(lo,{id:"borderPreset",close:s}),jsx(yn,{}),jsx(lo,{id:"borderStyle",close:s}),jsx(yn,{}),jsx(to,{label:t("toolbar.borderColor"),icon:jsx(dr,{color:i}),disabled:!o.enabled,description:Ke(o),onClick:()=>{l.current=Pn(e,"borderColor"),mr(r.current,i);},close:s})]})}),jsx(td,{inputRef:r,onPick:s=>{l.current?.execute({color:s});}})]})}function od(){let e=fe(),{t}=re(),n=oe("merge"),o=oe("merge",{value:"all"});return jsxs(Fragment,{children:[jsx(ct,{title:t("toolbar.merge.all"),disabled:!o.enabled,description:Ke(o),onClick:()=>vn(e,"merge",{value:"all"}),style:{borderRadius:"4px 0 0 4px"},testId:"xlsx-merge-all",overflow:null,children:jsx(be,{name:"merge"})}),jsx(hn,{title:t("toolbar.mergeCells"),disabled:!n.enabled,description:Ke(n),menuWidth:220,style:{minWidth:20,width:20,padding:0,borderRadius:"0 4px 4px 0"},trigger:jsx(be,{name:"chevronDown",size:13}),children:r=>jsx(lo,{id:"merge",close:r})})]})}var rd={fontFamily:210,numberFormat:220,borderStyle:220};function ld(e,t,n){let o=jsx(be,{name:"chevronDown",size:e==="numberFormat"||e==="fontFamily"?13:12});switch(e){case "fontFamily":return jsxs(Fragment,{children:[jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:typeof t.value=="string"?t.value:""}),o]});case "numberFormat":return jsxs(Fragment,{children:[jsx("span",{children:"123"}),o]});case "horizontalAlignment":return jsxs(Fragment,{children:[jsx(sr,{value:t.value??"left"}),o]});case "verticalAlignment":return jsxs(Fragment,{children:[jsx(ir,{value:t.value??"middle"}),o]});case "textWrapping":return jsxs(Fragment,{children:[jsx(be,{name:"wrap"}),o]});case "borderStyle":return jsxs(Fragment,{children:[jsx(ur,{value:t.value??"solid"}),o]});default:return jsx("span",{children:n(Ne(e))})}}function Ka({id:e,className:t}){let n=fe(),{t:o}=re(),r=oe(e),l=useRef(null);Na(l,e);let i=!r.enabled,s=Ke(r),b;if(e==="fontSize"){let p=typeof r.value=="number"?String(r.value):"";b=jsx(lr,{value:p,options:(r.options??[]).map(g=>({value:String(g.args.points),label:g.label})),label:o("toolbar.fontSize"),disabled:i,description:s,onCommit:(g,w)=>{let d=Number.parseFloat(g);!Number.isFinite(d)||d<_n||d>$n||vn(n,"fontSize",{points:d},w?()=>Vu(n):void 0);},width:50,inputStyle:{textAlign:"center"}});}else if(e==="zoom"){let p=`${Math.round((typeof r.value=="number"?r.value:1)*100)}%`;b=jsx(lr,{value:p,options:(r.options??[]).map(g=>({value:g.label,label:g.label})),label:o("toolbar.zoomValue",{value:p}),disabled:i,description:s,onCommit:g=>{let w=Number.parseFloat(g.replace("%",""))/100;Number.isFinite(w)&&w>=Gn&&w<=jn&&vn(n,"zoom",{scale:w});},width:76,testId:"xlsx-zoom"});}else e==="borderPreset"?b=jsx(nd,{}):e==="merge"?b=jsx(od,{}):b=jsx(hn,{title:o(e==="numberFormat"?"toolbar.moreNumberFormats":Ne(e)),disabled:i,description:s,menuWidth:rd[e]??180,style:e==="fontFamily"?{width:120,justifyContent:"space-between"}:void 0,trigger:ld(e,r,o),children:p=>jsx(lo,{id:e,close:p})});return jsx("span",{ref:l,className:t,style:{display:"inline-flex",alignItems:"center",flex:"0 0 auto"},children:b})}function ad({id:e,className:t}){let n=fe(),{t:o}=re(),r=oe(e),l=useRef(null),i=useRef(null);return Na(l,e),jsx("span",{ref:l,className:t,style:{display:"inline-flex",flex:"0 0 auto"},children:jsx(ka,{mode:e==="textColor"?"text":e==="fillColor"?"fill":"border",value:cn(r.value)?r.value:cr[e],label:o(Ne(e)),disabled:!r.enabled,description:Ke(r),onOpen:()=>{i.current=Pn(n,e);},onChange:s=>{(i.current??Pn(n,e)).execute({color:s});}})})}function ie(e){let{id:t,args:n,className:o}=e;if(Ce(t))return jsx(yt,{id:t,className:o});if(n===void 0){if(Oa.has(t))return jsx(ad,{id:t,className:o});if(La.has(t))return jsx(Ka,{id:t,className:o})}return jsx(yt,{id:t,args:n,className:o})}var ud=Object.freeze([]);function fr(){let e=fe(),t=Le(e),n=useCallback(()=>t?.pluginToolbar()??ud,[t]),o=useSyncExternalStore(e.subscribe,n,n),{t:r}=re();return o.length===0?null:jsx(xe,{label:r("plugins.toolbarGroup"),children:o.map(l=>jsx(yt,{id:l},l))})}var fd={surface:"#ffffff",text:"#202124",mutedText:"#5f6368",border:"#dadce0",hover:"#f1f3f4",shadow:"rgba(60, 64, 67, 0.24)"},Wa='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]',Ct=8,pd=320;function gd(e,t,n){let o=t.offsetWidth,r=t.scrollHeight,l=window.innerWidth,i=window.innerHeight,s=n?e.right:e.right-o;n&&s+o>l-Ct&&(s=e.left-o),s=Math.max(Ct,Math.min(s,l-o-Ct));let b=i-Ct-(n?e.top:e.bottom+4),p=(n?e.bottom:e.top-4)-Ct;if(r<=b||b>=p)return {top:n?e.top:e.bottom+4,left:s,maxHeight:Math.max(b,80)};let g=Math.max(p,80),w=n?e.bottom:e.top-4;return {top:Math.max(Ct,w-Math.min(r,g)),left:s,maxHeight:g}}function bd(){return jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:jsx("path",{d:"M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z",fill:"currentColor"})})}function xd(){return jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:jsx("path",{d:"M10 6 8.6 7.4 13.2 12l-4.6 4.6L10 18l6-6z",fill:"currentColor"})})}function $a({id:e,label:t,entries:n,anchor:o,beside:r,colors:l,initialFocus:i,onClose:s,onSelect:b,registerMenu:p}){let g=useRef(null),w=useId(),[d,C]=useState(null),h=useRef(false),[D,F]=useState(null),H=useRef(new Map),S=Yn({container:g,itemSelector:Wa,scope:'[role="menu"]',labelOf:f=>f.dataset.label??f.textContent??""});useLayoutEffect(()=>g.current?p(g.current):void 0,[p]),useLayoutEffect(()=>{let f=o(),c=g.current;if(!f||!c)return;let T=gd(f,c,r);C(x=>x&&x.top===T.top&&x.left===T.left&&x.maxHeight===T.maxHeight?x:T);},[o,r,n]),useLayoutEffect(()=>{!d||h.current||(h.current=true,i==="first"?S.focusFirst():i==="last"?S.focusLast():i==="menu"&&g.current?.focus({preventScroll:true}));},[i,d,S]);let k=(f,c)=>F({id:f,focus:c}),W=f=>{if(f.target instanceof Node&&!g.current?.contains(f.target))return;let c=f.target instanceof HTMLElement?f.target.closest(Wa):null,T=c&&c.closest('[role="menu"]')===g.current?c:null;if(f.key==="Escape"){f.preventDefault(),f.stopPropagation(),s(r?"parent":"escape");return}if(f.key==="Tab"){setTimeout(()=>s("tab"),0);return}if(r&&f.key==="ArrowLeft"){f.preventDefault(),f.stopPropagation(),s("parent");return}if(T?.dataset.submenu&&(f.key==="ArrowRight"||f.key==="Enter"||f.key===" ")){f.preventDefault(),f.stopPropagation(),T.getAttribute("aria-disabled")!=="true"&&k(T.dataset.submenu,"first");return}if(T&&(f.key==="Enter"||f.key===" ")){f.preventDefault(),f.stopPropagation();let x=Ga(n,T.dataset.entry??"");x&&!x.disabled&&b(x,"keyboard");return}S.onKeyDown(f)&&f.stopPropagation();},K=f=>f.map(c=>{if(c.kind==="separator")return jsx("div",{role:"separator",style:{height:1,margin:"4px 0",background:l.border}},c.id);if(c.kind==="group"){let y=`${w}-${c.id}-label`;return jsxs("div",{role:"group","aria-labelledby":c.label?y:void 0,children:[c.label&&jsx("div",{id:y,style:{padding:"6px 12px 2px",fontSize:11,fontWeight:500,color:l.mutedText,overflowWrap:"anywhere"},children:c.label}),K(c.entries)]},c.id)}let T=c.description?`${w}-${c.id}-description`:void 0,x=c.kind==="submenu",I=x?"menuitem":c.radio?"menuitemradio":c.checked!==void 0?"menuitemcheckbox":"menuitem",P=x?void 0:c.checked,B=x&&D?.id===c.id;return jsxs("div",{style:{position:"relative"},children:[jsxs("div",{role:I,tabIndex:-1,"data-entry":c.id,"data-label":c.label,"data-submenu":x?c.id:void 0,"aria-haspopup":x?"menu":void 0,"aria-expanded":x?B:void 0,"aria-checked":I==="menuitemcheckbox"||I==="menuitemradio"?P==="mixed"?"mixed":P===true:void 0,"aria-disabled":c.disabled?true:void 0,"aria-describedby":T,title:c.description,ref:y=>{x&&y&&H.current.set(c.id,y);},onMouseDown:y=>y.preventDefault(),onMouseEnter:y=>{x&&!c.disabled?k(c.id,"none"):D&&F(null),y.currentTarget.style.background=c.disabled?"transparent":l.hover;},onMouseLeave:y=>{y.currentTarget.style.background="transparent";},onClick:()=>{c.disabled||(x?k(c.id,"none"):b(c,"pointer"));},style:{display:"flex",alignItems:"center",gap:8,minHeight:30,padding:"4px 12px 4px 8px",fontSize:13,cursor:c.disabled?"default":"pointer",color:c.disabled?l.mutedText:l.text,opacity:c.disabled?.6:1,outlineOffset:-2},children:[jsx("span",{style:{width:16,flexShrink:0,display:"inline-flex",justifyContent:"center"},children:P===true?jsx(bd,{}):P==="mixed"?"\u2013":null}),c.icon&&jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",flexShrink:0},children:c.icon}),jsx("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:c.label}),!x&&c.shortcut&&jsx("span",{"aria-hidden":"true",style:{marginLeft:16,flexShrink:0,whiteSpace:"nowrap",fontSize:12,color:l.mutedText},children:c.shortcut}),x&&jsx("span",{style:{display:"inline-flex",flexShrink:0},children:jsx(xd,{})})]}),T&&jsx("span",{id:T,hidden:true,children:c.description}),x&&B&&jsx($a,{label:c.label,entries:c.entries,anchor:()=>H.current.get(c.id)?.getBoundingClientRect()??null,beside:true,colors:l,initialFocus:D?.focus??"none",onClose:y=>{F(null),y==="parent"?H.current.get(c.id)?.focus():s(y);},onSelect:b,registerMenu:p})]},c.id)});return jsx("div",{ref:g,id:e,role:"menu","aria-label":t,"aria-orientation":"vertical",tabIndex:-1,onKeyDown:W,style:{position:"fixed",top:d?.top??0,left:d?.left??0,maxHeight:d?.maxHeight,visibility:d?"visible":"hidden",overflowY:"auto",overflowX:"hidden",minWidth:Math.min(200,window.innerWidth-2*Ct),maxWidth:Math.min(pd,window.innerWidth-2*Ct),padding:"4px 0",background:l.surface,color:l.text,border:`1px solid ${l.border}`,borderRadius:8,boxShadow:`0 4px 16px ${l.shadow}`,zIndex:1e4,boxSizing:"border-box",outline:"none"},children:K(n)})}function Ga(e,t){for(let n of e){if(n.kind==="item"&&n.id===t)return n;if(n.kind==="group"){let o=Ga(n.entries,t);if(o)return o}}return null}var ja=forwardRef(function({label:t,trigger:n,entries:o,colors:r,triggerClassName:l,triggerStyle:i,testId:s,onItemSelected:b},p){let g=useRef(null),w=useRef(new Set),d=useId(),[C,h]=useState(null),D={...fd,...r},F=useCallback(()=>h(null),[]);useImperativeHandle(p,()=>({focus:()=>g.current?.focus({preventScroll:true}),close:F}),[F]);let H=useCallback(k=>(w.current.add(k),()=>{w.current.delete(k);}),[]);useEffect(()=>{if(!C)return;let k=K=>{let f=K.target;if(!g.current?.contains(f)){for(let c of w.current)if(c.contains(f))return;F();}},W=()=>{let K=document.activeElement,f=[...w.current].some(c=>c.contains(K));F(),f&&g.current?.focus({preventScroll:true});};return document.addEventListener("mousedown",k,true),window.addEventListener("resize",W),()=>{document.removeEventListener("mousedown",k,true),window.removeEventListener("resize",W);}},[C,F]);let S=useCallback(()=>g.current?.getBoundingClientRect()??null,[]);return jsxs("span",{style:{display:"inline-flex",flex:"0 0 auto"},children:[jsx("button",{ref:g,type:"button",className:l,style:i,"data-testid":s,"aria-label":t,title:t,"aria-haspopup":"menu","aria-expanded":C!==null,"aria-controls":C?d:void 0,onMouseDown:k=>k.preventDefault(),onClick:()=>h(k=>k?null:"menu"),onKeyDown:k=>{k.key==="Enter"||k.key===" "||k.key==="ArrowDown"?(k.preventDefault(),h("first")):k.key==="ArrowUp"&&(k.preventDefault(),h("last"));},children:n}),C&&jsx($a,{id:d,label:t,entries:o,anchor:S,beside:false,colors:D,initialFocus:C,onClose:k=>{F(),k!=="tab"&&g.current?.focus({preventScroll:true});},onSelect:(k,W)=>{F(),W==="keyboard"&&g.current?.focus({preventScroll:true}),k.onSelect(),b?.(W);},registerMenu:H})]})});var Cd={position:"absolute",visibility:"hidden",pointerEvents:"none",insetInlineStart:"0"},Va={overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin"},vd=new WeakMap,qa=new WeakMap,Za=["a[href]","button",'input:not([type="hidden"])',"select","textarea","summary","[tabindex]",'[contenteditable]:not([contenteditable="false"])'].join(", ");function Qa(e,t){if(t.length===0)return false;let n=Array.from(e.querySelectorAll(Za));return e.matches(Za)&&n.push(e),n.every(o=>t.some(r=>r.contains(o)))}function Ya(e){let t=getComputedStyle(e),n=(parseFloat(t.marginLeft)||0)+(parseFloat(t.marginRight)||0);return e.getBoundingClientRect().width+n}function Pd(e){let t=getComputedStyle(e),n=(parseFloat(t.paddingLeft)||0)+(parseFloat(t.paddingRight)||0);return e.getBoundingClientRect().width-n}function yr(e,t,n,o){let r=n.get(e);if(o===!!r)return false;let l=Object.keys(t);if(o){let i={};for(let s of l)i[s]=e.style[s],e.style[s]=t[s]??"";n.set(e,i);}else {for(let i of l)e.style[i]=r?.[i]??"";n.delete(e);}return true}function hr(e,t){yr(e,Cd,vd,t)&&(t?e.setAttribute("aria-hidden","true"):e.removeAttribute("aria-hidden"),e.inert=t);}function Ja(e,t){let n=e.getBoundingClientRect(),o=t.getBoundingClientRect();o.left<n.left?e.scrollLeft-=n.left-o.left:o.right>n.right&&(e.scrollLeft+=Math.min(o.right-n.right,o.left-n.left));}function Sd(e,t){return e.length===t.length&&e.every((n,o)=>n===t[o])}function es(e){let t=useRef(e);t.current=e;let[n,o]=useState([]),r=useRef(n);r.current=n;let l=useRef(e.moreWidth??32),i=useCallback(()=>{let{items:s,more:b,canHide:p,onFocusHidden:g}=t.current,w=s.current,d=w?.parentElement;if(!w||!d)return;let C=b.current;C&&(l.current=Ya(C));let h=Array.from(w.children).filter(f=>f instanceof HTMLElement),D=parseFloat(getComputedStyle(w).columnGap)||0,F=Pd(d),H=h.map(Ya),S=H.reduce((f,c)=>f+c,0)+D*Math.max(0,h.length-1),k=[],W=false;if(S>F+.5){let f=F-l.current,c=h.map(I=>p(I)),T=h.reduce((I,P,B)=>c[B]?I:I+H[B]+D,0),x=false;h.forEach((I,P)=>{if(c[P]){if(!x&&T+H[P]<=f){T+=H[P]+D;return}x=true,k.push(I);}}),W=T-D>(k.length>0?f:F)+.5;}yr(w,Va,qa,W);for(let f of h)hr(f,k.includes(f));for(let f of r.current)h.includes(f)||hr(f,false);let K=document.activeElement;K&&k.some(f=>f.contains(K))?g?.():W&&K&&w.contains(K)&&Ja(w,K),Sd(k,r.current)||(r.current=k,o(k));},[]);return useLayoutEffect(()=>{i();}),useLayoutEffect(()=>{let s=t.current.items.current;if(!s)return;let b=new Set,p=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>i()),g=()=>{if(p)for(let C of [s,s.parentElement,...Array.from(s.children)])C&&!b.has(C)&&(b.add(C),p.observe(C));};g();let w=typeof MutationObserver>"u"?null:new MutationObserver(()=>{g(),i();});w?.observe(s,{childList:true});let d=C=>{C.target instanceof Element&&Ja(s,C.target);};return s.addEventListener("focusin",d),window.addEventListener("resize",i),document.fonts?.ready.then(i,()=>{}),()=>{p?.disconnect(),w?.disconnect(),s.removeEventListener("focusin",d),window.removeEventListener("resize",i),yr(s,Va,qa,false);for(let C of Array.from(s.children))C instanceof HTMLElement&&hr(C,false);}},[i]),{hidden:n,remeasure:i}}var Ed="input, button:not([disabled])",os={appearance:"none",minHeight:30,padding:"0 12px",border:`1px solid ${q.border}`,borderRadius:4,background:q.surface,color:q.text,font:"500 13px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"};function ls({prompt:e,onClose:t}){let{t:n}=re(),[o,r]=useState(e.initialValue??""),l=useRef(null),i=useRef(null),s=useId(),b=useId(),p=o.trim(),g=e.valid(p);return useLayoutEffect(()=>{i.current?.focus(),i.current?.select();},[]),jsx("div",{style:{position:"fixed",inset:0,zIndex:10001,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(32, 33, 36, 0.32)"},onMouseDown:d=>{d.target===d.currentTarget&&t();},children:jsxs("form",{ref:l,role:"dialog","aria-modal":"true","aria-labelledby":s,onKeyDown:d=>{if(d.key==="Escape"){d.preventDefault(),d.stopPropagation(),t();return}if(d.key!=="Tab")return;let C=Array.from(l.current?.querySelectorAll(Ed)??[]);if(C.length===0)return;let h=C.indexOf(document.activeElement),D=d.shiftKey?h<=0?C.length-1:h-1:h===C.length-1?0:h+1;d.preventDefault(),C[D].focus();},onSubmit:d=>{d.preventDefault(),g&&(t(),e.submit(p));},style:{width:"min(320px, 100%)",boxSizing:"border-box",padding:16,borderRadius:8,background:q.surface,color:q.text,font:"13px ui-sans-serif, system-ui, sans-serif",boxShadow:"0 8px 24px rgba(60, 64, 67, 0.3)"},children:[jsx("h2",{id:s,style:{margin:"0 0 12px",fontSize:15,fontWeight:600},children:e.title}),jsx("label",{htmlFor:b,style:{display:"block",marginBottom:4,fontSize:12},children:e.label}),jsx("input",{id:b,ref:i,value:o,inputMode:"decimal","aria-invalid":p!==""&&!g,onChange:d=>r(d.target.value),style:{width:"100%",boxSizing:"border-box",padding:"6px 8px",border:`1px solid ${q.border}`,borderRadius:4,background:q.surface,color:q.text}}),jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[jsx("button",{type:"button",onClick:t,style:os,children:n("commands.cancel")}),jsx("button",{type:"submit",disabled:!g,style:{...os,opacity:g?1:.48,cursor:g?"pointer":"default"},children:n("commands.apply")})]})]})})}var Id={surface:q.surface,text:q.text,mutedText:q.muted,border:q.border,hover:q.hover,shadow:"rgba(60, 64, 67, 0.24)"},Md={appearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,padding:0,border:0,borderRadius:4,background:"transparent",color:q.text,cursor:"pointer"};function Ad(e){return e instanceof HTMLElement&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT"||e.tagName==="OPTION")}function Ld(e,t){return e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function vr({children:e,className:t,style:n}){let{t:o}=re(),r=fe(),l=useRef(null),i=useRef(null),s=useRef(null),b=useRef(null),p=useRef(null),g=useRef(null),w=useRef(null),d=useRef(new Set),[C,h]=useReducer(P=>P+1,0),[,D]=useReducer(P=>P+1,0),[F,H]=useState(false),[S,k]=useState(null),W=useRef(false),K=useMemo(()=>({register(P){return d.current.add(P),h(),()=>{d.current.delete(P),h();}},overflowing:()=>W.current,changed(){W.current&&D();},prompt:k,pickColor(P){w.current=P,mr(g.current,P.value);},popupHost:()=>p.current,focusMore(){s.current&&i.current?.isConnected?s.current.focus():b.current?.focus({preventScroll:true});}}),[]),f=useCallback(P=>{let B=[];for(let y of d.current){let X=y.element();X&&P.contains(X)&&B.push({element:X,source:y});}return B.sort((y,X)=>Ld(y.element,X.element))},[]),{hidden:c,remeasure:T}=es({items:l,more:i,canHide:P=>P.getAttribute("role")==="separator"||Qa(P,f(P).map(({element:B})=>B)),onFocusHidden:()=>H(true)});useLayoutEffect(()=>{T();},[C,T]),useLayoutEffect(()=>{!F||c.length===0||(H(false),s.current?.focus());},[F,c]),W.current=c.length>0,useEffect(()=>{if(c.length!==0)return r.subscribe(D)},[c.length,r]);let x=[];c.forEach((P,B)=>{let y=f(P).flatMap(({source:u})=>u.entries());if(y.length===0)return;let X=P.getAttribute("role")==="group"?P.getAttribute("aria-label"):null;x.push({kind:"group",id:`unit-${B}`,label:X??void 0,entries:y});});let I=x.flatMap((P,B)=>B===0?[P]:[{kind:"separator",id:`separator-${B}`},P]);return jsxs("div",{ref:b,className:t,role:"toolbar","aria-label":o("toolbar.actionsLabel"),"data-testid":"xlsx-formatting-toolbar",tabIndex:-1,onMouseDown:P=>{Ad(P.target)||P.preventDefault();},style:{display:"flex",alignItems:"center",minWidth:0,minHeight:36,margin:"0 8px 5px",padding:"4px 7px",borderRadius:18,background:q.rail,color:q.text,overflow:"hidden",boxSizing:"border-box",outline:"none",...n},children:[jsx(Qe.Provider,{value:K,children:jsx("div",{ref:l,"data-toolbar-items":"",style:{position:"relative",display:"flex",alignItems:"center",flex:1,minWidth:0,overflow:"hidden"},children:e})}),c.length>0&&jsx("span",{ref:i,style:{display:"inline-flex",flex:"0 0 auto"},children:jsx(ja,{ref:s,label:o("toolbar.more"),trigger:jsx(be,{name:"more"}),entries:I,colors:Id,triggerStyle:Md,testId:"xlsx-toolbar-more",onItemSelected:P=>{P==="pointer"&&Le(r)?.focusEditor();}})}),jsx("div",{ref:p}),jsx("input",{ref:g,type:"color",tabIndex:-1,"aria-hidden":"true",onChange:P=>w.current?.submit(P.target.value),style:{position:"absolute",width:1,height:1,padding:0,border:0,opacity:0,pointerEvents:"none"}}),S&&jsx(ls,{prompt:S,onClose:()=>{k(null),K.focusMore();}})]})}function Od({label:e,onSelect:t,disabled:n,description:o,checked:r,children:l}){let i=useRef(null),s=useId();return It(i,()=>[{kind:"item",id:s,label:e,checked:r,disabled:n,description:n?o:void 0,onSelect:t}]),jsx("span",{ref:i,style:{display:"inline-flex",alignItems:"center",flex:"0 0 auto"},children:l})}var Dd='button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])';function ds({children:e}){let{t}=re(),n=useContext(Qe),o=useRef(null),r=useRef(null),l=useId(),[i]=useState(()=>typeof document>"u"?null:document.createElement("span")),[s,b]=useState(false),p=t("commands.moreTools");It(o,()=>[{kind:"item",id:l,label:p,onSelect:()=>b(true)}]),useLayoutEffect(()=>{let d=o.current,C=s?r.current:d;!i||!d||!C||(s&&!d.style.minWidth&&(d.style.minWidth=`${d.getBoundingClientRect().width}px`),s||(d.style.minWidth=""),i.parentNode!==C&&C.appendChild(i),s&&r.current?.querySelector(Dd)?.focus({preventScroll:true}));},[s,i]),useEffect(()=>{if(!s)return;let d=h=>{h.target instanceof Node&&r.current?.contains(h.target)||b(false);},C=()=>b(false);return document.addEventListener("mousedown",d),window.addEventListener("resize",C),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("resize",C);}},[s]);let g=n?.popupHost()??null,w=s?g?.parentElement?.getBoundingClientRect():void 0;return jsxs(Fragment,{children:[jsx("span",{ref:o,style:{display:"inline-flex",alignItems:"center",flex:"0 0 auto"}}),i&&createPortal(jsx(Qe.Provider,{value:null,children:e}),i),s&&g&&createPortal(jsx("div",{ref:r,role:"dialog","aria-label":p,onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),b(false),n?.focusMore());},onBlur:d=>{let C=d.relatedTarget;C&&!r.current?.contains(C)&&b(false);},style:{position:"fixed",top:(w?.bottom??0)+4,right:8,zIndex:1e4,display:"flex",flexWrap:"wrap",alignItems:"center",gap:2,maxWidth:"calc(100vw - 16px)",padding:6,border:`1px solid ${q.border}`,borderRadius:8,background:q.surface,boxShadow:"0 4px 16px rgba(60, 64, 67, 0.24)",boxSizing:"border-box"}}),g)]})}var fs=["currentFormatting","selectionShape","onFormat","onMerge","onSearchMenus","onUndo","onRedo","canUndo","canRedo","onPrint","zoom","onZoomChange","fontFamilies","fontSizes","disabled"];function Kd(e){let t={};for(let n of Object.keys(e))e[n]!==void 0&&(t[n]=e[n]);return t}var ps=createContext(null);function ms({value:e}){let t=useContext(ps),n=xt("numberFormat",{value:e}),{t:o}=re();if(!t)return jsx(ie,{id:"numberFormat",args:{value:e}});let r=n.state;return jsx(ct,{title:n.label,disabled:!r.enabled,description:r.enabled?void 0:r.disabledReason.message,onClick:()=>t(e),children:jsx("span",{style:{fontSize:e==="currency"?16:15},children:e==="currency"?o("toolbar.currencySymbol"):"%"})})}function gs(){let{t:e}=re();return jsxs(Fragment,{children:[jsx(xe,{label:e("toolbar.groups.search"),children:jsx(ie,{id:"searchMenus"})}),jsxs(xe,{label:e("toolbar.groups.history"),children:[jsx(ie,{id:"undo"}),jsx(ie,{id:"redo"})]}),jsx(xe,{label:e("toolbar.groups.print"),children:jsx(ie,{id:"print"})}),jsx(xe,{label:e("toolbar.groups.paintFormat"),children:jsx(ie,{id:"paintFormat"})}),jsx(xe,{label:e("toolbar.groups.zoom"),children:jsx(ie,{id:"zoom"})}),jsx(xn,{}),jsxs(xe,{label:e("toolbar.groups.number"),children:[jsx(ms,{value:"currency"}),jsx(ms,{value:"percent"}),jsx(ie,{id:"decimalPlaces",args:{direction:"decrease"}}),jsx(ie,{id:"decimalPlaces",args:{direction:"increase"}}),jsx(ie,{id:"numberFormat"})]}),jsx(xn,{}),jsx(xe,{label:e("toolbar.groups.font"),children:jsx(ie,{id:"fontFamily"})}),jsxs(xe,{label:e("toolbar.groups.font"),children:[jsx(ie,{id:"fontSizeStep",args:{direction:"decrease"}}),jsx(ie,{id:"fontSize"}),jsx(ie,{id:"fontSizeStep",args:{direction:"increase"}})]}),jsx(xn,{}),jsxs(xe,{label:e("toolbar.groups.text"),children:[jsx(ie,{id:"bold"}),jsx(ie,{id:"italic"}),jsx(ie,{id:"strikethrough"})]}),jsxs(xe,{label:e("toolbar.groups.colors"),children:[jsx(ie,{id:"textColor"}),jsx(ie,{id:"fillColor"})]}),jsx(xe,{label:e("toolbar.groups.borders"),children:jsx(ie,{id:"borderPreset"})}),jsx(xe,{label:e("toolbar.groups.merge"),children:jsx(ie,{id:"merge"})}),jsxs(xe,{label:e("toolbar.groups.alignment"),children:[jsx(ie,{id:"horizontalAlignment"}),jsx(ie,{id:"verticalAlignment"}),jsx(ie,{id:"textWrapping"})]}),jsx(fr,{})]})}function Sr(e,t){let n=fs.filter(o=>e[o]!==void 0);if(n.length!==0)throw new Error(`A commands-mode ${t} reads state and actions from the editor's commands; remove ${n.join(", ")} or use mode="legacy".`)}function Bd(e){return Sr(e,"Toolbar"),jsx(vr,{className:e.className,style:e.style,children:e.children??jsx(gs,{})})}function Wd(e){let{t}=re(),n=useContext(dt),o=n?{...n,...Kd(e)}:e,r=useRef(o);r.current=o;let l=JSON.stringify([o.currentFormatting,o.selectionShape,o.canUndo,o.canRedo,o.zoom,o.fontFamilies,o.fontSizes,o.disabled,fs.filter(b=>b.startsWith("on")&&o[b]!==void 0)]),i=useMemo(()=>ha(o,()=>r.current,t),[l,t]),s=o.onFormat?b=>r.current.onFormat?.(b):null;return jsx(ut.Provider,{value:i,children:jsx(ps.Provider,{value:s,children:jsxs(vr,{className:o.className,style:o.style,children:[jsx(gs,{}),o.children!=null&&jsx(ds,{children:o.children})]})})})}function wn(e){let t=useContext(kt);return (e.mode??t??"legacy")==="commands"?jsx(Bd,{...e}):jsx(Wd,{...e})}function bs({className:e,style:t,children:n}){return jsx("div",{className:e,"data-testid":"xlsx-editor-toolbar",style:{display:"flex",flexDirection:"column",flex:"0 0 auto",...t},children:n})}function Vd({children:e}){let t=fe(),n=oe("paintFormat"),o=oe("numberFormat"),r=oe("fontFamily"),l=oe("fontSize"),i=oe("bold"),s=oe("italic"),b=oe("strikethrough"),p=oe("textColor"),g=oe("fillColor"),w=oe("borderPreset"),d=oe("borderStyle"),C=oe("borderColor"),h=oe("horizontalAlignment"),D=oe("verticalAlignment"),F=oe("textWrapping"),H=oe("merge"),S=oe("merge",{value:"unmerge"}),k=oe("undo"),W=oe("redo"),K=oe("zoom"),f=useMemo(()=>{let c=x=>x==="mixed"?void 0:x,T=x=>x??void 0;return {currentFormatting:{paintFormat:n.active===true,numberFormat:T(o.value?.kind),numberFormatPattern:T(o.value?.pattern),fontFamily:T(r.value),fontSize:T(l.value),bold:c(i.active),italic:c(s.active),strikethrough:c(b.active),textColor:T(p.value),fillColor:T(g.value),borderPreset:T(w.value),borderStyle:T(d.value),borderColor:T(C.value),horizontalAlignment:T(h.value),verticalAlignment:T(D.value),textWrapping:T(F.value)},selectionShape:H.value?{rows:H.value.rows,columns:H.value.columns,canUnmerge:S.enabled}:void 0,onFormat:x=>{let I=ya(x);t.execute(I.id,I.args);},onMerge:x=>{t.execute("merge",{value:x});},onSearchMenus:()=>{t.execute("searchMenus",null);},onUndo:()=>{t.execute("undo",null);},onRedo:()=>{t.execute("redo",null);},canUndo:k.enabled,canRedo:W.enabled,onPrint:()=>{t.execute("print",null);},zoom:K.value,onZoomChange:x=>{t.execute("zoom",{scale:x});}}},[t,n,o,r,l,i,s,b,p,g,w,d,C,h,D,F,H,S,k,W,K]);return jsx(dt.Provider,{value:f,children:e})}function qd({i18n:e,children:t}){let n=Le(fe()),o=ra(),r=useRef(null);return useLayoutEffect(()=>{let l=r.current;if(!(!l||!n))return n.registerChrome(l)},[n]),jsx("div",{ref:r,style:{display:"contents"},children:jsx(_t,{i18n:e??o?.i18n,children:t})})}function Zd({children:e,className:t,style:n,i18n:o,mode:r,...l}){let i=useContext(qn);if(r!=="commands")return jsx(kt.Provider,{value:"legacy",children:jsx(dt.Provider,{value:l,children:jsx(bs,{className:t,style:n,children:e})})});Sr(l,"EditorToolbar");let s=jsx(kt.Provider,{value:"commands",children:jsx(Vd,{children:jsx(bs,{className:t,style:n,children:e??jsx(wn,{})})})});return i?s:jsx(qd,{i18n:o,children:s})}var Mt=Zd;Mt.Toolbar=wn;Mt.FormulaBar=ba;var nc=8,oc=32;function rc(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(n=>n[0]).join("").toUpperCase()}function lc(e){let t=Number.parseInt(e.slice(1,3),16),n=Number.parseInt(e.slice(3,5),16),o=Number.parseInt(e.slice(5,7),16);return `rgba(${t}, ${n}, ${o}, 0.1)`}function ac(e,t){return e.left<=t.right&&e.right>=t.left&&e.top<=t.bottom&&e.bottom>=t.top}function uo(e,t){let n={...e},o=true;for(;o;){o=false;for(let r of t){let l={top:Math.min(r.start.row,r.end.row),left:Math.min(r.start.col,r.end.col),bottom:Math.max(r.start.row,r.end.row),right:Math.max(r.start.col,r.end.col)};if(!ac(n,l))continue;let i=Math.min(n.top,l.top),s=Math.min(n.left,l.left),b=Math.max(n.bottom,l.bottom),p=Math.max(n.right,l.right);i===n.top&&s===n.left&&b===n.bottom&&p===n.right||(Object.assign(n,{top:i,left:s,bottom:b,right:p}),o=true);}}return n}function sc(e){let[t,n]=useState(()=>Date.now());return useEffect(()=>{let o=Date.now();n(o);let r=e.map(s=>s.cursorMovedAt+AWARENESS_LABEL_DURATION_MS).filter(s=>s>o);if(r.length===0)return;let l=setTimeout(()=>n(Date.now()),Math.min(...r)-o+1);return l.unref?.(),()=>clearTimeout(l)},[e]),t}function ys({peers:e,sheetIds:t,sheetNames:n,activeSheet:o}){if(e.length===0)return null;let r=e.slice(0,nc),l=e.length-r.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:[r.map(i=>{let s=i.cursor?t.indexOf(i.cursor.sheet):o,b=i.cursor!==null&&s!==o,p=normalizeAwarenessColor(i.user.color,i.clientId),g=s>=0?n[s]:i.cursor?"Unavailable sheet":void 0,w=b||s<0?`${i.user.name} \u2014 ${g}`:i.user.name;return jsx("span",{"data-testid":`xlsx-presence-chip-${i.clientId}`,title:w,"aria-label":w,style:{display:"inline-grid",placeItems:"center",width:24,height:24,borderRadius:"50%",backgroundColor:p,color:"#ffffff",boxShadow:"0 0 0 2px #ffffff",fontSize:9,fontWeight:700,lineHeight:1,letterSpacing:"-0.02em",opacity:b||s<0?.42:1,transition:"opacity 120ms ease"},children:rc(i.user.name)},i.clientId)}),l>0&&jsxs("span",{"data-testid":"xlsx-presence-overflow",title:`${l} more collaborators`,"aria-label":`${l} 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:["+",l]})]})}function Cs({peers:e,grid:t,sheetIds:n,activeSheet:o,zoom:r,mergedRanges:l}){let i=useMemo(()=>e.slice(0,oc),[e]),s=e.length-i.length,b=sc(i);return t?jsxs(Fragment,{children:[i.map(p=>{if(!p.cursor)return null;let g=resolveAwarenessCursor(p.cursor,n);if(!g||g.sheetIndex!==o)return null;let w=uo(g.range,l),d=rangeRect(t,w);if(!d)return null;let C=normalizeAwarenessColor(p.user.color,p.clientId),h={x:d.x*r,y:d.y*r,w:d.w*r,h:d.h*r},D=g.range.top!==g.range.bottom||g.range.left!==g.range.right,F=w.left<t.startCol,H=w.top<t.startRow||h.y<18,S=p.cursorMovedAt>0&&b-p.cursorMovedAt<AWARENESS_LABEL_DURATION_MS;return jsx("div",{"data-testid":`xlsx-remote-selection-${p.clientId}`,style:{position:"absolute",left:h.x,top:h.y,width:h.w,height:h.h,boxSizing:"border-box",borderWidth:2,borderStyle:"solid",borderColor:C,backgroundColor:D?lc(C):"transparent"},children:S&&jsx("span",{"data-testid":`xlsx-remote-label-${p.clientId}`,style:{position:"absolute",top:H?0:-18,...F?{right:-2}:{left:-2},maxWidth:180,height:18,padding:"2px 6px",borderRadius:H?"0 0 3px 3px":"3px 3px 0 0",boxSizing:"border-box",overflow:"hidden",backgroundColor:C,color:"#ffffff",fontSize:10,fontWeight:600,lineHeight:"14px",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.user.name})},p.clientId)}),s>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:["+",s]})]}):null}var vs=["#7c3aed","#0891b2","#c2410c","#4d7c0f","#be185d","#1d4ed8"];function uc(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return (t>>>0)%vs.length}function Ps(e){return vs[uc(e)]}function dc(e,t,n){e.execute(t,n).then(o=>{let r=document.activeElement;o.ok&&(!r||r===document.body)&&Le(e)?.focusEditor();});}function Xr({id:e,args:t,label:n,testId:o,color:r}){let l=fe(),i=oe(e,t),s=i.enabled?void 0:i.disabledReason.message;return jsx("button",{"data-testid":o,"aria-disabled":s?true:void 0,title:s,onClick:()=>{i.enabled&&dc(l,e,t);},style:{padding:"3px 10px",cursor:i.enabled?"pointer":"default",color:r,opacity:i.enabled?1:.48},children:n})}function Ss({proposals:e,staleFor:t,style:n}){let{t:o}=re();return jsx("div",{"data-testid":"xlsx-proposals-panel",role:"region","aria-label":o("proposals.panelLabel"),style:{position:"absolute",top:"100%",right:0,marginTop:4,width:320,maxHeight:420,overflowY:"auto",background:"#ffffff",border:"1px solid #d0d0d0",borderRadius:10,boxShadow:"0 6px 24px rgba(0, 0, 0, 0.16)",padding:8,zIndex:10,font:"13px system-ui, sans-serif",textAlign:"left",...n},children:e.length===0?jsx("div",{style:{padding:12,color:"#707070",textAlign:"center"},children:o("proposals.empty")}):e.map(r=>{let l=Ps(r.agentId),i=t[r.id];return jsxs("div",{"data-testid":"xlsx-proposal","data-proposal-id":r.id,style:{borderLeft:`3px solid ${l}`,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:l},children:r.agentId}),jsx("span",{style:{color:"#707070",fontSize:12},children:o("proposals.cellCount",{count:r.cells.length})})]}),r.note&&jsx("div",{style:{color:"#404040",margin:"4px 0"},children:r.note}),jsx("ul",{style:{listStyle:"none",margin:"6px 0",padding:0},children:r.cells.map(s=>jsxs("li",{"data-testid":"xlsx-proposal-cell",style:{fontVariantNumeric:"tabular-nums",lineHeight:1.5},children:[jsx("strong",{"data-testid":"xlsx-proposal-cell-a1",children:s.a1}),":"," ",jsx("span",{style:{color:"#909090"},children:s.oldText||"\u2205"})," ",o("proposals.changeArrow")," ",jsx("span",{"data-testid":"xlsx-proposal-cell-new",style:{color:l},children:s.newText})]},s.a1))}),i&&i.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:o("proposals.staleWarning",{cells:i.join(", ")})}),jsxs("div",{style:{display:"flex",gap:6,marginTop:4},children:[jsx(Xr,{id:"proposalAccept",args:{proposalId:r.id},label:o("proposals.accept"),testId:"xlsx-proposal-accept"}),i&&i.length>0&&jsx(Xr,{id:"proposalAccept",args:{proposalId:r.id,force:true},label:o("proposals.forceApply"),testId:"xlsx-proposal-force",color:"#b45309"}),jsx(Xr,{id:"proposalReject",args:{proposalId:r.id},label:o("proposals.reject"),testId:"xlsx-proposal-reject"})]})]},r.id)})})}var Er=class extends Component{constructor(){super(...arguments);Wt(this,"state",{failed:false});}static getDerivedStateFromError(){return {failed:true}}componentDidCatch(n){this.props.onError(n);}render(){return this.state.failed?null:this.props.children}};function mc(e){return t=>ia(t.nativeEvent,e)}function mo({host:e,activation:t,phase:n="render",children:o}){let r=e.commandStore(t),l=mc(r);return jsx(Er,{onError:i=>e.fail(t.pluginId,n,i),children:jsx(ut.Provider,{value:r,children:jsx(gn.Provider,{value:null,children:jsx(dt.Provider,{value:null,children:jsx(kt.Provider,{value:null,children:jsx(Qe.Provider,{value:null,children:jsx("div",{style:{display:"contents"},onKeyDownCapture:l,onMouseDownCapture:l,onClickCapture:l,onDoubleClickCapture:l,children:o})})})})})})})}function ws({host:e,activations:t,layerRef:n,width:o,height:r}){return jsx("div",{ref:n,...Vn,className:"xlsx-plugin-overlays","data-testid":"plugin-overlays",style:{position:"absolute",top:0,left:0,width:o,height:r,overflow:"hidden",pointerEvents:"none"},children:t.map(l=>{let i=l.plugin.overlay,s=l.context.geometry;return i&&s?jsx(mo,{host:e,activation:l,children:jsx(i,{context:l.context,geometry:s})},l.key):null})})}var pc={left:280,right:280,bottom:200},Ir={left:160,right:160,bottom:120},gc=640,ft={surface:"#ffffff",border:"#e2e8f0",text:"#172033",muted:"#647087",selected:"#e6f4ea",primary:"#217346"};function bc(e,t,n){let o=e==="bottom"?n.height:n.width,r=Math.max(Ir[e],Math.floor(o*.4));return Math.max(Ir[e],Math.min(t??pc[e],r))}function Rs(e=true){let t=useRef(null),[n,o]=useState({width:0,height:0});return useEffect(()=>{let r=t.current;if(!e||!r)return;let l=()=>o(s=>s.width===r.clientWidth&&s.height===r.clientHeight?s:{width:r.clientWidth,height:r.clientHeight});if(l(),typeof ResizeObserver>"u")return;let i=new ResizeObserver(l);return i.observe(r),()=>i.disconnect()},[e]),[t,n]}var Ts=Rs;function xc({host:e,activation:t,id:n,labelledBy:o}){let[r,l]=Rs(),i=t.plugin.panel.render;return jsx("div",{ref:r,id:n,role:"tabpanel","aria-labelledby":o,className:"xlsx-plugin-dock__panel",style:{flex:1,minHeight:0,minWidth:0,overflow:"auto"},children:jsx(mo,{host:e,activation:t,children:jsx(i,{context:t.context,width:l.width,height:l.height})})})}var hc=e=>({maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"4px 8px",border:0,borderRadius:4,background:e?ft.selected:"transparent",color:e?ft.primary:ft.muted,font:"12px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"}),Xs={flex:"0 0 auto",padding:"0 6px",border:0,borderRadius:4,background:"transparent",color:ft.muted,font:"13px ui-sans-serif, system-ui, sans-serif",cursor:"pointer"};function ks({host:e,placement:t,activations:n,available:o}){let{t:r}=re(),l=useId(),[i,s]=useState(null),[b,p]=useState({}),[g,w]=useState(false),d=useRef(null),C=useRef(null),h=t!=="bottom"&&o.width>0&&o.width<gc,D=h&&g&&n.length>0;if(useEffect(()=>{D&&C.current?.focus();},[D]),n.length===0)return null;let F=n.find(X=>X.pluginId===i)??n[0],H=F.plugin.panel,S=h?!D:b[F.pluginId]??H.defaultCollapsed??false,k=bc(t,H.preferredSize,o),W=X=>`${l}-tab-${X}`,K=`${l}-panel`,f=X=>d.current?.querySelector(`[data-plugin-tab="${X}"]`)?.focus(),c=X=>{h?w(!(D&&X===F.pluginId)):X===F.pluginId&&S&&p(u=>({...u,[X]:false})),s(X);},T=()=>{w(false),f(F.pluginId);},x=X=>{let u=n.findIndex(z=>z.pluginId===F.pluginId),E=n.length-1,M=X.key==="ArrowRight"||X.key==="ArrowDown"?u===E?0:u+1:X.key==="ArrowLeft"||X.key==="ArrowUp"?u===0?E:u-1:X.key==="Home"?0:X.key==="End"?E:null;if(M===null)return;X.preventDefault();let R=n[M].pluginId;s(R),f(R);},I=r(S?"plugins.expandPanel":"plugins.collapsePanel",{title:H.title}),P=t==="bottom",B=h||!P&&S,y=jsx(xc,{host:e,activation:F,id:K,labelledBy:W(F.pluginId)},F.key);return jsxs("section",{...Vn,className:`xlsx-plugin-dock xlsx-plugin-dock--${t}`,"data-testid":`plugin-dock-${t}`,"aria-label":r("plugins.panelTabs"),style:{position:"relative",display:"flex",flexDirection:"column",flexShrink:0,minWidth:0,minHeight:0,background:ft.surface,color:ft.text,...P?{height:S?void 0:k,borderTop:`1px solid ${ft.border}`}:{width:S||h?void 0:k,maxWidth:S||h?96:void 0,[t==="left"?"borderRight":"borderLeft"]:`1px solid ${ft.border}`}},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:4,flexWrap:"wrap"},children:[jsx("div",{ref:d,role:"tablist","aria-label":r("plugins.panelTabs"),"aria-orientation":B?"vertical":"horizontal",onKeyDown:x,style:{display:"flex",flexDirection:B?"column":"row",gap:2,flex:1,minWidth:0,overflow:"hidden"},children:n.map(X=>{let u=X.pluginId===F.pluginId;return jsx("button",{type:"button",role:"tab",id:W(X.pluginId),"data-plugin-tab":X.pluginId,"aria-selected":u,"aria-controls":u&&!S?K:void 0,"aria-expanded":h?u&&D:void 0,tabIndex:u?0:-1,title:X.plugin.panel.title,onClick:()=>c(X.pluginId),style:hc(u),children:X.plugin.panel.title},X.pluginId)})}),!h&&jsx("button",{type:"button","aria-expanded":!S,"aria-label":I,title:I,onClick:()=>p(X=>({...X,[F.pluginId]:!S})),style:Xs,children:S?"+":"\u2212"})]}),!S&&!h&&y,D&&jsxs("div",{ref:C,tabIndex:-1,"data-testid":`plugin-drawer-${t}`,onKeyDown:X=>{X.key==="Escape"&&(X.stopPropagation(),T());},style:{position:"absolute",top:0,bottom:0,[t==="left"?"left":"right"]:"100%",width:Math.min(k,Math.max(Ir[t],o.width-64)),zIndex:60,display:"flex",flexDirection:"column",background:ft.surface,boxShadow:"0 4px 16px rgba(15, 23, 42, 0.18)",outline:"none"},children:[jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:4},children:jsx("button",{type:"button","aria-label":I,title:I,onClick:T,style:Xs,children:"\xD7"})}),y]})]})}var yc=Object.freeze({commands:Object.freeze([])});function Is(e){if(!e||typeof e!="object")return yc;let t=Array.isArray(e.commands)?[...new Set(e.commands.filter(n=>typeof n=="string"))].sort():[];return e.document!=="write"?Object.freeze({commands:Object.freeze(t)}):Object.freeze({commands:Object.freeze(t),document:"write",...e.editBatches===true?{editBatches:true}:{},...e.untrackedHistory===true?{untrackedHistory:true}:{}})}function Ms(e,t){let n=e.commands??[],o=t.commands??[];return e.document===t.document&&e.editBatches===t.editBatches&&e.untrackedHistory===t.untrackedHistory&&n.length===o.length&&n.every((r,l)=>r===o[l])}function As(e,t){return e.commands?.includes(t)??false}function Ls(e){return e.document==="write"}function Mr(e,t){return e.document==="write"&&e.editBatches===true&&(t!=="none"||e.untrackedHistory===true)}var Cc=/^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,126}[A-Za-z0-9])?$/;function vc(e){return typeof e=="string"&&Cc.test(e)}function Os(e){return e.revision===void 0?"":`${typeof e.revision}:${e.revision}`}var Ds=10;function Ar(e){return e.type==="load"?"document-change":e.type}function Pc(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function Lr(e){let t=new AbortController;if(e.aborted)return t.abort(),{controller:t,release:()=>{}};let n=()=>t.abort();return e.addEventListener("abort",n,{once:true}),{controller:t,release:()=>e.removeEventListener("abort",n)}}function Fs(e){let t=new Map,n=null,o=false,r={},l=new Map,i=new WeakSet,s=new Set,b=new Set,p=0,g=0,w=null,d=[],C=false,h=u=>{try{e.report(u);}catch(E){console.error("[plugins] onPluginError threw",E);}},D=u=>{let E=Object.hasOwn(r,u)?r[u]:void 0,M=l.get(u);if(M&&M.source===E)return M.grant;let R=Is(E);return l.set(u,{source:E,grant:R}),R},F=u=>{let E=`${p}:${u.stateRevision}`;if(u.rendered?.key===E)return u.rendered.entry;let M=c(u,u.lifetime.signal),R={pluginId:u.registration.id,plugin:u.registration.plugin,generation:u.generation,activation:u.token,key:u.key,context:e.context(M,u.registration.plugin)};return u.rendered={key:E,entry:R},R},H=()=>{C=false;let u=[];for(let M of t.values()){let R=M.activation;R?.status==="ready"&&u.push(F(R));}u.length===d.length&&u.every((M,R)=>M===d[R])||(d=u);for(let M of [...b])M();},S=()=>{p+=1,!C&&(C=true,queueMicrotask(H));},k=(u,E)=>u.status==="disposed"?u.ended==="document-replaced"?"document-replaced":"plugin-unavailable":E.aborted?"aborted":null,W=(u,E,M)=>{let R=z=>h({pluginId:u.registration.id,generation:u.generation,phase:"cleanup",error:z});try{let z=E(M);Pc(z)&&z.then(void 0,R);}catch(z){R(z);}},K=(u,E)=>{if(u.status!=="disposed"){u.status="disposed",u.ended=E,u.pending=[],u.registration.activation===u&&(u.registration.activation=null),u.lifetime.abort();for(let M of u.cleanups.splice(0).reverse())W(u,M,E);S();}},f=(u,E,M)=>{u.status!=="disposed"&&(u.registration.quarantined=true,h({pluginId:u.registration.id,generation:u.generation,phase:E,error:M}),K(u,"failed"));};function c(u,E){let M=e.snapshot(u.registration.id,u.generation);return {pluginId:u.registration.id,activation:u.token,snapshot:M,signal:E,lifetimeSignal:u.lifetime.signal,state:()=>u.state,setState(z,N){if(k(u,E)!==null)return false;let $=e.currentVersion();return $===null||(N??M.version)!==$?false:(u.state=typeof z=="function"?z(u.state):z,u.stateRevision+=1,S(),true)},onCleanup(z){if(typeof z!="function")throw new TypeError("A cleanup must be a function");u.status==="disposed"?W(u,z,u.ended??"unmounted"):u.cleanups.push(z);},run:z=>T(u,z),commit(z){let N=w;w=E;try{return z()}finally{w=N;}},refusal:()=>k(u,E)}}async function T(u,E){let{controller:M,release:R}=Lr(u.lifetime.signal);if(!M.signal.aborted)try{await E(c(u,M.signal));}catch(z){M.signal.aborted||f(u,"action",z);}finally{R();}}async function x(u,E,M,R){let{controller:z,release:N}=Lr(u.lifetime.signal);u.running={channel:M,controller:z};try{let $=c(u,z.signal);return await R(e.context($,u.registration.plugin),$),u.status==="disposed"?"ended":z.signal.aborted?"aborted":"ok"}catch($){return u.status==="disposed"?"ended":z.signal.aborted?"aborted":(f(u,E,$),"ended")}finally{N(),u.running?.controller===z&&(u.running=null);}}async function I(u){if(!u.pumping){u.pumping=true;try{for(;u.status==="ready";){let E=u.pending.shift();if(!E)break;if(!u.registration.plugin.onEvent)continue;if(await x(u,"event",Ar(E),R=>u.registration.plugin.onEvent?.(R,E))==="ended")break}}finally{u.pumping=false;}}}let P=(u,E)=>{if(u.status==="disposed"||E.generation!==u.generation)return;let M=Ar(E),R=u.pending.findIndex(N=>Ar(N)===M);if(R>=0){if(u.pending[R].type==="load")return;u.pending[R]=E;}else u.pending.push(E);let z=u.running;z?.channel===M&&z.controller.signal!==w&&z.controller.abort(),u.status==="ready"&&queueMicrotask(()=>{I(u);});};async function B(u,E,M){g+=1;let R={token:Object.freeze({}),key:`${u.id}#${g}`,registration:u,generation:E,lifetime:new AbortController,status:"initializing",ended:null,state:void 0,stateRevision:0,cleanups:[],pending:[],running:null,pumping:false,rendered:null};u.activation=R;try{R.state=u.plugin.createState();}catch(N){f(R,"initialize",N);return}if(u.plugin.initialize&&await x(R,"initialize","initialize",$=>R.registration.plugin.initialize?.($))==="ended")return;let z="aborted";for(let N=0;z==="aborted"&&R.status!=="disposed";N+=1){if(N===Ds){f(R,"event",new Error(`Document changes superseded the load hook ${Ds} times`));return}R.pending=[],z=await x(R,"event","document-change",($,le)=>R.registration.plugin.onEvent?.($,e.loadEvent(le.snapshot,M)));}z!=="ok"||R.status==="disposed"||(R.status="ready",S(),I(R));}let y=(u,E)=>h({pluginId:u,generation:n,phase:"definition",error:E}),X=u=>{n=null,u==="unmounted"&&(o=false);for(let E of t.values())E.activation&&K(E.activation,u);S();};return {setPlugins(u){let E=new Map;for(let N of u){let $=vc(N?.id)?e.validate?.(N):new TypeError(`Invalid plugin id ${JSON.stringify(N?.id)}`);if($!=null){N&&typeof N=="object"&&!i.has(N)&&(i.add(N),y(typeof N.id=="string"?N.id:"",$));continue}let le=E.get(N.id);le?le.push(N):E.set(N.id,[N]);}let M=new Set,R=new Map,z=[];for(let[N,$]of E){if($.length>1){M.add(N),s.has(N)||y(N,new Error(`${$.length} plugins share the id "${N}"`));continue}let le=$[0],ue=t.get(N);if(ue&&Os(ue.plugin)===Os(le)){ue.plugin=le,R.set(N,ue);continue}ue&&z.push([ue,"definition-replaced"]),R.set(N,{id:N,plugin:le,quarantined:false,activation:null});}s=M;for(let[N,$]of t)R.has(N)||z.push([$,"removed"]);t=R;for(let[N,$]of z)N.activation&&K(N.activation,$);if(n!==null)for(let N of t.values())!N.activation&&!N.quarantined&&B(N,n,"attached");S();},setGrants(u){let E=new Map([...t.keys()].map(R=>[R,D(R)]));r=u??{},l.clear();let M=false;for(let R of t.values()){let z=D(R.id),N=E.get(R.id);if(Ms(N,z)){l.get(R.id).grant=N;continue}M=true;let $=R.activation;$&&P($,e.grantsEvent(e.snapshot(R.id,$.generation),z));}M&&S();},grant:D,open(u){if(n===u)return;n!==null&&X("document-replaced"),n=u;let E=o?"replaced":"loaded";o=true;for(let M of t.values())M.quarantined=false,B(M,u,E);S();},close:X,generation:()=>n,notify(u){if(u.generation===n){for(let E of t.values())E.activation&&P(E.activation,u);S();}},touch:S,activations:()=>d,subscribe(u){return b.add(u),()=>{b.delete(u);}},guard(u,E,M,R){let z=t.get(u)?.activation;if(z?.status!=="ready")return R;try{return M(F(z).context)}catch(N){return queueMicrotask(()=>f(z,E,N)),R}},async invoke(u,E,M){let R=t.get(u)?.activation;if(R?.status!=="ready")return {ok:false,reason:"plugin-unavailable"};let{controller:z,release:N}=Lr(R.lifetime.signal),$=c(R,z.signal);try{return {ok:!0,value:await M(e.context($,R.registration.plugin))}}catch(le){let ue=$.refusal();return ue?{ok:false,reason:ue}:(f(R,E,le),{ok:false,reason:"failed"})}finally{N();}},fail(u,E,M){let R=t.get(u)?.activation;R&&f(R,E,M);}}}var Sc={"plugin-unavailable":"The plugin is no longer active","document-replaced":"The workbook was replaced",aborted:"This plugin context was superseded","permission-denied":"The host has not granted this operation","read-only":"The editor is read-only","input-failed":"Pending input could not be applied","unsupported-policy":"Plugins cannot run this operation yet","plugin-failed":"The plugin failed"},wc={"stale-version":"The workbook changed after that version","missing-target":"The target is not in the workbook","ambiguous-target":"The target does not identify one place","layout-unavailable":"The sheet cannot be shown",unsupported:"The editor cannot show this target now"},Xc=new Set(["nearest","start","center"]);function Xn(e,t=Sc[e]){return {ok:false,failure:{code:e,message:t}}}function qt(e){let t=e.refusal();return t?Xn(t):null}function Or(e,t,n){return {deny(o){let r=e.refusal();if(r)return r;if(Ce(o))return o.startsWith(`plugin:${e.pluginId}/`)?null:"permission-denied";let l=t();return !As(l,o)||Ae[o].mutatesDocument&&!Ls(l)?"permission-denied":null},subscribe:n}}function Ec(e,t,n){return !n()&&e.some(o=>o.aborted)?Promise.resolve(null):new Promise((o,r)=>{let l=()=>{n()||(i(),o(null));},i=()=>{for(let s of e)s.removeEventListener("abort",l);};for(let s of e)s.addEventListener("abort",l,{once:true});t.then(s=>{i(),o(s);},s=>{i(),r(s);});})}function zs(e,t,n,o){let r=async d=>{let C=qt(e);if(C)return C;let h=t.handle();if(!h)return Xn("plugin-unavailable");let D=false,F=await Ec([e.signal,e.lifetimeSignal],t.admit(h,()=>{let H=qt(e);return H?{refused:H}:(D=true,{value:d(h)})}),()=>D);return F?F.ok?"refused"in F.value?F.value.refused:F.value.value:qt(e)??Xn(F.code):qt(e)??Xn("aborted")},l={version:()=>r(d=>({ok:true,version:d.version()})),readCells:d=>r(C=>C.readCells(d)),findText:d=>r(C=>C.findText(d)),validateEdits:d=>r(C=>t.readOnlyRefusal(C)??C.validateEdits(d))},i=d=>qt(e)??(Mr(n(),d)?null:Xn("permission-denied")),s=Mr(n(),"separate")?{async applyEdits(d){let C=i(d?.history);return C||r(h=>t.applyEdits(h,d,()=>i(d.history),D=>e.commit(D)))}}:null,b={getDescriptor:d=>o.getDescriptor(d),getState:(d,C)=>o.getState(d,C),subscribe:d=>o.subscribe(d),execute:async(d,C)=>qt(e)??o.execute(d,C)},p=()=>e.refusal()===null,g=async(d,C)=>{let h=await r(D=>D.version()===d?.expectVersion?C(D):"stale-version");return h===null?{ok:true}:typeof h=="object"?h:{ok:false,failure:{code:h,message:wc[h]}}};return {read:l,commands:b,edits:s,navigation:{selectCells:(d,C)=>g(C,h=>t.navigator.selectCells(h,d,C.focus===true,p)),scrollToCell:(d,C)=>g(C,h=>{let D=C.align??"nearest";return Xc.has(D)?t.navigator.scrollToCell(h,d,D,p):"unsupported"})}}}function Dr(e,t){return e?.scoped(t)??Gt}var Ns=new WeakMap,Rc=/^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,126}[A-Za-z0-9])?$/,Tc=new Set(["left","right","bottom"]),Ks=e=>e!==null&&typeof e=="object"?Object.freeze({...e}):e;function kc(e){return Array.isArray(e?.shortcuts)?Object.freeze({...e,shortcuts:Object.freeze([...e.shortcuts])}):Ks(e)}function Ic(e){let t={...e};t.panel!==void 0&&(t.panel=Ks(t.panel)),Array.isArray(t.commands)&&(t.commands=Object.freeze(t.commands.map(kc))),Array.isArray(t.toolbar)&&(t.toolbar=Object.freeze([...t.toolbar]));let n=Object.freeze(t),o=Object.freeze(n.revision===void 0?{id:n.id}:{id:n.id,revision:n.revision});return Ns.set(o,n),o}function Bs(e){return e!==null&&typeof e=="object"?Ns.get(e)??null:null}function Hs(e){return typeof e=="function"||e!==null&&typeof e=="object"}function Fr(e){return e===void 0||typeof e=="function"}function Ws(e){if(typeof e.createState!="function")return new TypeError("createState must be a function");if(!Fr(e.initialize)||!Fr(e.onEvent))return new TypeError("initialize and onEvent must be functions");if(e.overlay!==void 0&&!Hs(e.overlay))return new TypeError("overlay must be a component");let t=e.panel;if(t!==void 0&&(typeof t?.title!="string"||!Tc.has(t.placement)||!Hs(t.render)||t.preferredSize!==void 0&&!(Number.isFinite(t.preferredSize)&&t.preferredSize>0)))return new TypeError("panel needs a title, a left, right or bottom placement and a renderer");let n=e.commands??[];if(!Array.isArray(n))return new TypeError("commands must be an array");let o=new Set;for(let l of n){if(!Rc.test(l?.id??""))return new TypeError(`Invalid command id ${JSON.stringify(l?.id)}`);if(o.has(l.id))return new TypeError(`Duplicate command id "${l.id}"`);if(o.add(l.id),typeof l.label!="string"||typeof l.mutatesDocument!="boolean"||typeof l.execute!="function"||!Fr(l.getState))return new TypeError(`Command "${l.id}" needs a label, mutatesDocument and execute`);let i=l.shortcuts??[],s=b=>{let p=un(b);return p===null||!Bl(p)};if(!Array.isArray(i)||i.some(s))return new TypeError(`Command "${l.id}" has an invalid shortcut`)}let r=e.toolbar??[];return !Array.isArray(r)||r.some(l=>!o.has(l))?new TypeError("toolbar may only list the plugin\u2019s own command ids"):null}var Mc=Object.freeze({enabled:true});function Ac(e){let t=e;if(!t||typeof t.enabled!="boolean")throw new TypeError("A command getState must return a CommandState");if(!t.enabled&&(typeof t.disabledReason?.code!="string"||typeof t.disabledReason.message!="string"))throw new TypeError("A disabled command state needs a disabledReason");return e}function Lc(e){let t=e;return t&&typeof t.ok=="boolean"?e:{ok:true,status:"executed"}}function Oc(e,t){return e===t||!!e&&!!t&&e.id===t.id&&e.version===t.version}function po(e){try{return e.version()}catch{return null}}function _s(e){let t,n=null,o=null,r=false,l=0,i=null,s={version:"",readOnly:false,selection:null,layout:null},b=new WeakMap,p=new WeakMap,g=0,w=x=>{let I=p.get(x);return I===void 0&&(g+=1,I=g,p.set(x,I)),I},d=new WeakSet,C=new Set,h=x=>{if(!t){console.error(`[XlsxEditor] plugin "${x.pluginId}" failed (${x.phase})`,x.error);return}try{t(x);}catch(I){console.error("[XlsxEditor] onPluginError threw",I);}},D=()=>e.commands(),F=x=>{let I=()=>S.grant(x.pluginId);if(x.signal!==x.lifetimeSignal)return Or(x,I,S.subscribe);let P=b.get(x.activation);return P||(P=Or(x,I,S.subscribe),b.set(x.activation,P)),P},H=x=>{let I=x.pluginId,P=zs(x,e,()=>S.grant(I),Dr(D(),F(x))),B=e.geometry();return {pluginId:I,snapshot:x.snapshot,get state(){return x.state()},signal:x.signal,lifetimeSignal:x.lifetimeSignal,read:P.read,commands:P.commands,edits:P.edits,geometry:B&&x.snapshot.layout?.id===B.layout.id?B:null,navigation:P.navigation,setState:(y,X)=>x.setState(y,X),onCleanup:y=>x.onCleanup(y),run:y=>x.run(X=>y(H(X)))}},S=Fs({context:x=>H(x),snapshot:(x,I)=>({generation:I,version:s.version,readOnly:s.readOnly,grant:S.grant(x),selection:s.selection,layout:s.layout}),currentVersion:()=>n&&S.generation()!==null?po(n):null,loadEvent:(x,I)=>({type:"load",generation:x.generation,version:x.version,reason:I}),grantsEvent:(x,I)=>({type:"grants-change",generation:x.generation,grant:I}),validate:Ws,report:h}),k=x=>S.notify(x),W=()=>{let x=S.generation(),I=n?po(n):null;!x||!I||I===s.version||(s.version=I,k({type:"document-change",generation:x,version:I}),s.layout&&s.layout.version!==I&&(s.layout=null,k({type:"layout-change",generation:x,layout:null})));},K=()=>{if(!r||!n){o?.(),o=null;return}if(!o){s.version=po(n)??s.version;try{o=n.onUpdate(W);}catch(x){console.error("[XlsxEditor] observing workbook changes for plugins failed",x);}}},f=()=>{o?.(),o=null,n=null;},c=(x,I)=>S.guard(x,"command-state",P=>Ac(I.getState?I.getState(P):Mc),{enabled:false,disabledReason:Xe("plugin-unavailable",{translate:e.translate})}),T=async(x,I)=>{let P=await S.invoke(x,"command",y=>I.execute(y));if(P.ok)return Lc(P.value);let B=P.reason==="failed"?"command-failed":P.reason;return {ok:false,failure:Xe(B,{translate:e.translate})}};return {setPlugins(x){let I=[];for(let P of x??[]){let B=Bs(P);if(B){I.push(B);continue}if(P!==null&&typeof P=="object"){if(d.has(P))continue;d.add(P);}h({pluginId:typeof P?.id=="string"?P.id:"",generation:S.generation(),phase:"definition",error:new TypeError("Plugins must be created with defineXlsxPlugin")});}r=I.length>0,K(),S.setPlugins(I);},setGrants:x=>S.setGrants(x),setReporter(x){t=x;},open(x){f(),n=x,s.version=po(x)??"",s.layout=null,s.selection=null,K(),l+=1,S.open(`workbook-${l}`);},close(x){f(),s.layout=null,S.close(x);},generation:()=>S.generation(),version:()=>s.version,selectionChanged(x){if(JSON.stringify(x)===JSON.stringify(s.selection))return;s.selection=x;let I=S.generation();I&&k({type:"selection-change",generation:I,version:s.version,selection:x});},modeChanged(x){if(x===s.readOnly)return;s.readOnly=x;let I=S.generation();I&&k({type:"mode-change",generation:I,readOnly:x});},layoutChanged(x){let I=x&&x.version===s.version?x:null;if(Oc(I,s.layout))return;s.layout=I;let P=S.generation();P&&k({type:"layout-change",generation:P,layout:I});},layoutId:()=>S.generation()===null?null:s.layout?.id??null,geometryChanged:()=>S.touch(),activations:()=>S.activations(),subscribe:x=>S.subscribe(x),commandStore(x){let I=b.get(x.activation);return I?Dr(D(),I):Gt},syncCommands(){let x=D();if(!x)return;let I=[],P=[],B=new Map,y=[];for(let u of S.activations()){let E=u.plugin;y.push(`${u.pluginId}:${w(E)}:${w(u.activation)}`);for(let M of E.commands??[]){let R=`plugin:${u.pluginId}/${M.id}`,z=[];for(let N of M.shortcuts??[]){let $=un(N),le=Kl.has($)?"a built-in command":Wl($)?"the grid":B.get($);if(!le){B.set($,R),z.push({chord:N,args:null});continue}let ue=`${u.pluginId}\0${$}`;C.has(ue)||(C.add(ue),h({pluginId:u.pluginId,generation:u.generation,phase:"definition",error:new Error(`Shortcut ${N} of ${R} is already used by ${le}; it was not bound`)}));}I.push({descriptor:Object.freeze({id:R,label:M.label,mutatesDocument:M.mutatesDocument,shortcuts:Object.freeze(z)}),state:()=>c(u.pluginId,M),execute:()=>T(u.pluginId,M)});}for(let M of E.toolbar??[])P.push(`plugin:${u.pluginId}/${M}`);}let X=y.join("|");if(X===i){x.refresh();return}i=X,x.setPluginCommands(I,P);},guard:(x,I,P,B)=>S.guard(x,I,P,B),fail:(x,I,P)=>S.fail(x,I,P)}}var $s=new WeakMap,Gs=0;function zc(e){let t=$s.get(e);return t||(Gs+=1,t=`grid-layout-${Gs}`,$s.set(e,t)),t}function js(e,t){if(!e||t===null||e.version!==t)return null;let{x:n,y:o,width:r,height:l}=e.viewport;return {id:zc(e),version:t,sheetId:e.sheetId,zoom:e.zoom,viewport:{x:n,y:o,width:r,height:l}}}function zr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function Hc(e,t,n){let o=Math.max(0,t.x),r=Math.max(0,t.y),l=Math.min(e.frame.width,t.x+t.w),i=Math.min(e.frame.height,t.y+t.h);return l>o&&i>r?{x:n.x+o*e.zoom,y:n.y+r*e.zoom,width:(l-o)*e.zoom,height:(i-r)*e.zoom}:null}function Nc(e,t){let n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return {x:n.left-o.left-t.clientLeft+t.scrollLeft,y:n.top-o.top-t.clientTop+t.scrollTop}}function Us(e,t,n,o,r){let l=i=>i?Hc(t,i,Nc(n,o)):null;return {layout:e,getCellRect(i){return !r()||i?.sheetId!==e.sheetId||!zr(i.row)||!zr(i.col)?null:l(cellRect(t.frame.grid,i.row,i.col))},getRangeRect(i){if(!r()||i?.sheetId!==e.sheetId)return null;let s=i.range;return !s||![s.top,s.left,s.bottom,s.right].every(zr)||s.top>s.bottom||s.left>s.right?null:l(rangeRect(t.frame.grid,s))},getPositionAtPoint:null}}var Vs=Object.freeze([]);function qs(e){let t=useRef(e);t.current=e;let n=useRef(null),o=useRef(null),r=useRef(null),[l]=useState(()=>_s({...e.access,translate:d=>t.current.t(d),geometry:()=>n.current})),i=(e.plugins?.length??0)>0,s=useCallback(()=>{let d=o.current,C=t.current.canvasRef.current,h=r.current,F=(t.current.plugins?.length??0)>0&&l.generation()!==null?js(d,l.version()):null;n.current=F&&d&&C&&h?Us(F,d,C,h,()=>l.layoutId()===F.id&&o.current===d&&C.isConnected&&h.isConnected):null,l.layoutChanged(F),l.geometryChanged();},[l]);useLayoutEffect(()=>{l.setReporter(e.onPluginError);}),useLayoutEffect(()=>{l.modeChanged(e.readOnly);},[l,e.readOnly]),useLayoutEffect(()=>{l.setGrants(e.pluginGrants);}),useLayoutEffect(()=>{l.setPlugins(e.plugins);},[l,e.plugins]),useEffect(()=>()=>l.close("unmounted"),[l]),useEffect(()=>{if(!(!e.handle||e.access.handle()!==e.handle))return l.open(e.handle),s(),()=>l.close("document-replaced")},[l,e.access,e.handle,s]),useEffect(()=>(l.syncCommands(),l.subscribe(()=>l.syncCommands())),[l]);let b=useSyncExternalStore(l.subscribe,l.activations,()=>Vs);useEffect(()=>{i&&l.selectionChanged(e.selection);},[l,i,e.selection]),useEffect(()=>{s();},[i,s]);let p=useCallback(d=>{o.current=d,(!d||(t.current.plugins?.length??0)>0)&&s();},[s]),g=useCallback(d=>{r.current=d,s();},[s]),w=useCallback(()=>{p(null),l.close("document-replaced");},[l,p]);return {host:l,managed:i,activations:i?b:Vs,overlayLayerRef:g,beginLoad:w,presentGrid:p}}function Tn(e){return {ok:false,version:e.version(),failure:{code:"read-only",message:"The editor is read-only"}}}var Qt=class extends Error{constructor(n){super(n==="input-pending"?'Accepted input is still being written; await commands.execute("save", null)':"A cell entry could not be written; correct or discard it first");Wt(this,"code",n);this.name="XlsxSaveRefusedError";}},Pt=96,St=24,kn="#217346",nm=87,om=1024,rm="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",lm=1,am=10,sm=250,im=1e3,um={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};function dm(e,t,n){let o=[{op:"fillRect",x:0,y:0,w:e,h:t,color:"#ffffff"}],r=Math.ceil(e/Pt),l=Math.ceil(t/St);for(let i=0;i<=r;i++)o.push({op:"line",x1:i*Pt,y1:0,x2:i*Pt,y2:t,width:1,color:"#e0e0e0"});for(let i=0;i<=l;i++)o.push({op:"line",x1:0,y1:i*St,x2:e,y2:i*St,width:1,color:"#e0e0e0"});return o.push({op:"fillRect",x:0,y:0,w:e,h:St,color:"#f3f3f3"}),o.push({op:"fillRect",x:0,y:0,w:Pt,h:t,color:"#f3f3f3"}),o.push({op:"text",x:Pt+8,y:St+18,text:n,fontSize:14,color:"#202020",clip:{x:Pt,y:St,w:Pt*3,h:St},align:"left"}),{width:e,height:t,commands:o}}function Qs(e,t){if(!e||e.length<2)return t;let n=[];for(let r=1;r<e.length;r++)n.push(e[r]-e[r-1]);n.sort((r,l)=>r-l);let o=n[n.length>>1];return o>0?o:t}function cm(e,t,n){let o=Qs(e?.grid?.rowOffsets,St),r=Qs(e?.grid?.colOffsets,Pt),l=Math.max(1,Math.round(t.contentHeight/o))+1,i=Math.max(1,Math.round(t.contentWidth/r))+1,s=Math.max(1,Math.floor(n/o));return {rows:l,cols:i,rowsPerPage:s}}function ei(e,t,n){let o=new Blob([new Uint8Array(e)],{type:n}),r=URL.createObjectURL(o),l=document.createElement("a");l.href=r,l.download=t,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(r);}function mm(e){return `${(e??"workbook.xlsx").replace(/\.xlsx$/i,"")}.png`}function Nr(e,t){return e.generation===t.generation&&e.view===t.view&&e.mutation>=t.mutation}function ho(e,t){return {x:e.x*t,y:e.y*t,w:e.w*t,h:e.h*t}}var fm=1048575,pm=16383;function ti(e,t,n,o,r,l){return n?null:l==="start"?e:l==="center"?Math.max(0,e-Math.max(0,r-t)/2):e>=o&&e+t<=o+r?null:e<o||t>=r?e:Math.max(0,e+t-r)}function gm(e,t,n){let o=e.displayList({...n,x:0,y:0}).grid,r=(l,i,s)=>i===0?0:l?.[i]??s;return {width:r(o?.colOffsets,t.frozenCols,n.width),height:r(o?.rowOffsets,t.frozenRows,n.height)}}function bm(e,t,n,o,r,l){let i=e.sheetInfo(),s=e.cellPosition(t,n,o),b=e.cellPosition(t,Math.min(n+1,fm),Math.min(o+1,pm)),p=i.frozenRows>0||i.frozenCols>0?gm(e,i,l):{width:0,height:0};return {x:ti(s.x,b.x-s.x,o<i.frozenCols,l.x,Math.max(0,l.width-p.width),r),y:ti(s.y,b.y-s.y,n<i.frozenRows,l.y,Math.max(0,l.height-p.height),r)}}function In(e){return Un(e.nativeEvent)!==null||ua(e.target)}function ni(e,t){return typeof t=="string"?e.sheetInfo().sheetIds.indexOf(t):-1}function oi(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function Kr(e,t,n,o){if(!oi(n)||!oi(o))return false;try{return e.cellPosition(t,n,o),!0}catch{return false}}var ri={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},li={workspace:{position:"relative",display:"flex",flex:1,minWidth:0,minHeight:0},center:{position:"relative",display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0}},Jt={shell:{flex:"0 0 auto",minHeight:nm,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"},host:{flex:"0 0 auto"},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 Lt(e){let[t,n]=useState(e),o=useRef(t),r=useCallback(l=>{o.current=typeof l=="function"?l(o.current):l,n(o.current);},[]);return [t,r,o]}function xm(e){return jsx(_t,{i18n:e.i18n,children:jsx(hm,{...e})})}function hm({file:e,fileName:t,onSave:n,onChange:o,collaboration:r,onReady:l,className:i,readOnly:s=false,toolbar:b,showToolbar:p=true,i18n:g,plugins:w,pluginGrants:d,onPluginError:C}){let{t:h}=re(),D=r!==void 0,F=r?.clientId,H=r?.initialUpdate,S=r?.onReplica,k=r?.provider,[W]=useState(qo),K=useRef(null),f=useRef(null),c=useRef(null),T=useRef(null),x=useRef(null),I=useRef(null),P=useRef(null),B=useRef(null),y=useRef(null),X=useRef(false),u=useRef(null),E=useRef(null),M=useRef(null),R=useRef(null),z=useRef(false),N=useRef(false),$=useRef(()=>{}),le=useRef(()=>true),ue=useRef(()=>false),Pe=useRef(0),tt=useRef(0),wt=useRef(null),[U]=useState(()=>sa({generation:()=>Pe.current,seal:()=>wt.current?.seal()??{},sync:()=>wt.current?.sync(),write:a=>wt.current?.write(a)??false,close:a=>wt.current?.close(a),restore:a=>wt.current?.restore(a)??false})),nt=useRef(null),yo=useRef(false),Br=useRef(null),en=useRef([]),Wr=useRef(l);Wr.current=l;let Co=useRef(o);Co.current=o;let Fe=useRef(s);Fe.current=s;let[J,je,vo]=Lt(null),[Mn,Se]=useState(null),[_r,Po]=useState(null),[$e,$r]=useState(null),[te,pe,ot]=Lt(null),[me,Xt]=useState(null),[Gr,So]=useState(null),[ai,Ot]=useState(null),[Z,si,tn]=Lt(1),[wo,Xo]=useState(0),[jr,Eo]=useState(false),[we,rt,Ur]=Lt(null),[Ro,Ue]=useState(null),[Vr,Dt]=useState(null),[To,qr]=useState([]),ko=useRef(void 0),Io=useRef(void 0),[Mo,lt,ii]=Lt(null),at=useRef(null),[ui,An,di]=Lt([]),[ci,Zr,mi]=Lt(false),[Ao,Yr]=useState(null),[Jr,Qr]=useState([]),[fi,Lo]=useState({}),ae=J?.activeSheet??0,ge=useMemo(()=>({get current(){return vo.current?.activeSheet??0}}),[vo]),Ft=useCallback((a,m,v,A)=>({generation:Pe.current,sheet:ge.current,row:m,col:v,value:A,source:a}),[]),Oo=useCallback(a=>{pe(selectionAt({row:a.row,col:a.col})),a.source==="cell"?Xt({row:a.row,col:a.col,value:a.value}):Ot(a.value);},[]),He=useCallback(a=>{if(U.draft)return;let m=U.rejected.find(v=>v.sheet===a&&v.generation===Pe.current);m&&(U.setDraft(m),Oo(m));},[U,Oo]),pt=useCallback(()=>{U.setDraft(null),Xt(null),Ot(null);},[U]),el=useCallback(()=>{le.current()&&(pe(null),rt(null),pt(),lt(null),at.current=null,He(ge.current),W.refresh());},[pt,He,ge,W,pe,rt,lt]),Ln=useCallback((a,m,v)=>{a.setActiveSheet(m),je(a.sheetInfo()),pe(v?{anchor:{...v.anchor},focus:{...v.focus}}:null),rt(null),pt(),lt(null),at.current=null,He(m),Se(null),W.refresh();},[pt,He,W]),tl=useCallback((a,m)=>{let v=c.current;if(!v||!Number.isInteger(a))return false;try{let A=v.sheetInfo();if(a<0||a>=A.sheetNames.length)return !1;v.cellPosition(a,m.anchor.row,m.anchor.col);let L=v.cellPosition(a,m.focus.row,m.focus.col);return le.current()?(Ln(v,a,m),requestAnimationFrame(()=>{let O=K.current;O&&(O.scrollLeft=L.x*tn.current,O.scrollTop=L.y*tn.current);}),!0):!1}catch{return false}},[Ln]),nl=useCallback((a,m,v,A,L)=>{let O=c.current,Y=Pe.current;requestAnimationFrame(()=>{let ne=K.current;if(!(!ne||!O||!L()||c.current!==O||Pe.current!==Y||ge.current!==a))try{let de=tn.current,ce=bm(O,a,m,v,A,{x:ne.scrollLeft/de,y:ne.scrollTop/de,width:ne.clientWidth/de,height:ne.clientHeight/de});ce.x!==null&&(ne.scrollLeft=ce.x*de),ce.y!==null&&(ne.scrollTop=ce.y*de);}catch{}});},[ge]);useEffect(()=>{s&&(pt(),lt(null),at.current=null,E.current=null,Ue(null),M.current=null,Dt(null),R.current!=null&&clearTimeout(R.current),R.current=null);},[s]);let pi=useMemo(()=>isPngExportAvailable(),[]),Do=useMemo(()=>isProposalsAvailable(),[]),gt=useCallback((a,m)=>c.current!==a?Promise.reject(new ve("document-replaced")):U.runAfterPendingInput(()=>{if(c.current!==a)throw new ve("document-replaced");return m()}),[U]),ol=useCallback(async(a,m)=>{try{return {ok:!0,value:await gt(a,m)}}catch(v){if(!(v instanceof ve))throw v;return {ok:false,code:v.code==="document-replaced"||v.code==="editor-unavailable"?"document-replaced":"input-failed",error:v}}},[gt]),On=useCallback((a,m,v,A=L=>L())=>{let L=v?.()??null;if(L)return L;if(Fe.current)return Tn(a);let O=A(()=>a.applyEdits(m));return O.ok&&O.applied&&(Co.current?.(),W.refresh()),O},[W]),Et=useCallback(()=>{let a=c.current;if(!a){An([]);return}try{An(a.listProposals());}catch{An([]);}Xo(m=>m+1);},[]),zt=useRef({admit:ol,applyBatch:On,navigator:null});zt.current.admit=ol,zt.current.applyBatch=On;let[gi]=useState(()=>{let a=()=>{let m=zt.current.navigator;if(!m)throw new Error("The editor is not ready");return m};return {handle:()=>c.current,admit:(m,v)=>zt.current.admit(m,v),readOnlyRefusal:m=>Fe.current?Tn(m):null,applyEdits:(m,v,A,L)=>zt.current.applyBatch(m,v,A,L),commands:()=>W,navigator:{selectCells:(...m)=>a().selectCells(...m),scrollToCell:(...m)=>a().scrollToCell(...m)}}}),[bi,rl]=useState(null),xi=useMemo(()=>{let a=J?.sheetIds[ae];return a===void 0?null:{sheetId:a,sheetIndex:ae,cells:te?{anchor:{...te.anchor},focus:{...te.focus}}:null,chartId:we?.id??null}},[J,ae,te,we]),Ve=qs({plugins:w,pluginGrants:d,onPluginError:C,access:gi,commands:W,readOnly:s,handle:bi,selection:xi,canvasRef:f,t:h}),ll=Ve.beginLoad,Fo=Ve.presentGrid,[hi,yi]=Ts(Ve.managed);useEffect(()=>{if(Pe.current+=1,ll(),rl(null),pt(),rt(null),M.current=null,Dt(null),R.current!=null&&(clearTimeout(R.current),R.current=null),An([]),Lo({}),Zr(false),Yr(null),qr([]),ko.current=void 0,Io.current=void 0,lt(null),Po(null),at.current=null,N.current=false,!e){c.current=null,je(null),pe(null),Se(null);return}c.current=null,je(null),pe(null);let a=null,m=()=>{},v=()=>{},A=false,L=()=>{let O=v;v=()=>{};try{O();}catch{}};return initWasm().then(()=>{if(!A)try{a=openWorkbook(e,{collaborative:D,clientId:F}),H&&a.applyUpdate(H.slice()),c.current=a,m=a.onUpdate(()=>{if(!(A||!a)){tt.current+=1;try{je(a.sheetInfo()),Xo(ne=>ne+1),Lo({}),Et(),Se(null);}catch(ne){Se(ne instanceof Error?ne.message:String(ne));}}}),N.current=!0,je(a.sheetInfo()),pe(selectionAt({row:0,col:0})),Yr(a),Se(null),Et();let O=a,Y=Wr.current?.({clearSelection:el,commands:W.store,handle:a,refreshProposals:Et,focus:()=>K.current?.focus(),save:()=>{if(ue.current())throw new Qt("input-failed");if(U.pending)throw new Qt("input-pending");if(!le.current())throw new Qt("input-failed");return O.save()},selectCells:tl,version:()=>gt(O,()=>O.version()),readCells:ne=>gt(O,()=>O.readCells(ne)),findText:ne=>gt(O,()=>O.findText(ne)),validateEdits:async ne=>Fe.current&&c.current===O?Tn(O):gt(O,()=>Fe.current?Tn(O):O.validateEdits(ne)),applyEdits:async ne=>Fe.current&&c.current===O?Tn(O):gt(O,()=>On(O,ne))});typeof Y=="function"&&(v=Y),rl(O);}catch(O){L(),m(),m=()=>{},a?.dispose(),a=null,c.current=null,je(null),pe(null),Se(O instanceof Error?O.message:String(O));}},O=>{A||(c.current=null,je(null),pe(null),Se(O instanceof Error?O.message:String(O)));}),()=>{A=true,L(),m(),a?.dispose(),c.current=null,U.reset();}},[e,D,F,H,el,gt,On,ll,W,U,Et,tl]),useEffect(()=>{if(!J||!N.current)return;let a=K.current;a&&(N.current=false,a.scrollLeft=J.initialScrollX*Z,a.scrollTop=J.initialScrollY*Z);},[J,Z]),useEffect(()=>{if(!(!S||!Ao))return S(Ao),()=>S(null)},[S,Ao]),useEffect(()=>{if(Qr([]),!!k)return k.onAwareness(a=>Qr([...a]))},[k]),useEffect(()=>()=>k?.setCursor(null),[k]),useEffect(()=>{if(!k)return;let a=J?.sheetIds[ae];if(!te||!a){k.setCursor(null);return}k.setCursor({sheet:a,anchor:{...te.anchor},head:{...te.focus}});},[k,te,J,ae,wo]);let zo=useCallback(()=>{let a=K.current,m=f.current;if(!a||!m)return;let v=m.getContext("2d");if(!v)return;let A=window.devicePixelRatio||1,L=a.clientWidth,O=a.clientHeight;if(L===0||O===0)return;m.width=Math.round(L*A),m.height=Math.round(O*A),m.style.width=`${L}px`,m.style.height=`${O}px`;let Y=L/Z,ne=O/Z,de={x:a.scrollLeft/Z,y:a.scrollTop/Z,width:Y,height:ne},ce=c.current,Ye;if(ce)try{Ye=ce.displayList(de);}catch(Je){T.current=null,x.current=null,Fo(null),$r(null),Po(Je instanceof Error?Je.message:String(Je));return}else Ye=dm(Y,ne,h("editor.demoCellText"));let Nn=[],st=Ye.grid,Xl=(st?.rowOffsets.length??0)-1,El=(st?.colOffsets.length??0)-1;if(ce&&st&&Xl>0&&El>0)try{let Je=ce.cell(ae,st.startRow,st.startCol).a1,Ki=ce.cell(ae,st.startRow+Xl-1,st.startCol+El-1).a1;Nn=ce.mergedRanges(ae,`${Je}:${Ki}`).slice(0,om);}catch{}paintDisplayList(v,Ye,A*Z),T.current=Ye,x.current={frame:Ye,zoom:Z};let No=null;try{No=ce?ce.version():null;}catch{}let Rl=vo.current?.sheetIds[ae];if(Fo(No!==null&&Rl!==void 0?{frame:Ye,zoom:Z,version:No,sheetId:Rl,viewport:de}:null),Po(null),qr(Nn),$r(Ye),!ce)return;let Ko={generation:Pe.current,mutation:tt.current,view:`${ae}:${Z}`};Br.current=Ko;let Tl=en.current;en.current=Tl.filter(Je=>!Nr(Ko,Je.mark));for(let Je of Tl)Nr(Ko,Je.mark)&&Je.resolve(true);},[ae,Fo,h,Z]);useEffect(()=>{let a=K.current;if(!a)return;let m=()=>{I.current==null&&(I.current=requestAnimationFrame(()=>{I.current=null,zo();}));};zo(),a.addEventListener("scroll",m,{passive:true});let v=new ResizeObserver(m);return v.observe(a),()=>{a.removeEventListener("scroll",m),v.disconnect(),I.current!=null&&(cancelAnimationFrame(I.current),I.current=null);}},[zo,J,Mn,wo]);let Ci=useCallback(()=>{let a={generation:Pe.current,mutation:tt.current,view:`${ge.current}:${tn.current}`},m=Br.current;return m&&Nr(m,a)?Promise.resolve(true):new Promise(v=>{let A={mark:a,resolve:O=>{clearTimeout(L),v(O);}},L=setTimeout(()=>{en.current=en.current.filter(O=>O!==A),v(false);},im);en.current.push(A);})},[]);useEffect(()=>{let a=c.current;if(!a||!te||!J){So(null);return}try{So(a.cell(ae,te.focus.row,te.focus.col));}catch{So(null);}},[te,J,ae,wo]),useEffect(()=>{let a=()=>{X.current=false,Eo(false);};return window.addEventListener("mouseup",a),()=>window.removeEventListener("mouseup",a)},[]);let nn=useMemo(()=>!$e||!J?null:buildA11yGrid($e,te,J.sheetNames[ae]??"",{gridLabel:h("a11y.gridLabel"),rowHeaderLabel:h("a11y.rowHeaderLabel"),columnHeaderLabel:h("a11y.columnHeaderLabel"),cellLabel:h("a11y.cellLabel"),cellLabelSelected:h("a11y.cellLabelSelected"),emptyCellLabel:h("a11y.emptyCellLabel"),emptyCellLabelSelected:h("a11y.emptyCellLabelSelected")}),[$e,te,J,ae,h]),Me=useCallback(()=>{K.current?.focus({preventScroll:true});},[]);useEffect(()=>{me&&B.current?.focus({preventScroll:true});},[me]);let qe=useCallback(a=>{tt.current+=1,je(a.sheetInfo),Xo(m=>m+1),Et(),a.applied&&Co.current?.();},[Et]);wt.current={seal(){if(E.current)return {refused:"gesture-active"};$.current();let a=nt.current;return a?(a.source==="cell"?(z.current=true,B.current?.blur(),z.current=false):(yo.current=true,y.current?.blur(),yo.current=false),{composition:a.done}):{}},sync(){let a=U.draft,m=a?.source==="cell"?B.current:y.current;a&&m&&m.value!==a.value&&U.setDraft({...a,value:m.value});},write(a){let m=c.current;if(!m)return false;if(Fe.current)return true;try{return m.cell(a.sheet,a.row,a.col).input!==a.value&&qe(m.editCell(a.sheet,a.row,a.col,a.value)),!0}catch(v){return Se(v instanceof Error?v.message:String(v)),false}},close(a){if(a.source==="formula"){Ot(null);return}let m=document.activeElement===B.current;z.current=true,B.current?.blur(),z.current=false,Xt(null),m&&Me();},restore(a){return a.sheet!==ge.current?false:(Oo(a),true)}},ue.current=()=>U.rejected.some(a=>a.generation===Pe.current),le.current=()=>c.current?($.current(),E.current=null,Ue(null),Eo(false),U.settle()):false;let al=useCallback(a=>{let m=c.current;if(!m)return null;let v=normalizeRange(a),A=m.cell(ae,v.top,v.left).a1,L=m.cell(ae,v.bottom,v.right).a1;return `${A}:${L}`},[ae]),Ze=useCallback(()=>cm(T.current,J,(K.current?.clientHeight??0)/Z),[J,Z]),bt=useCallback((a,m)=>{let v=f.current,A=T.current?.grid;if(!v||!A)return null;let L=v.getBoundingClientRect();return cellAtPoint(A,(a-L.left)/Z,(m-L.top)/Z)},[Z]),Ht=useCallback((a,m)=>{let v=f.current,A=x.current;if(!v||!A)return null;let L=v.getBoundingClientRect();return chartRegionAtPoint(A.frame.charts,(a-L.left)/A.zoom,(m-L.top)/A.zoom)},[]),sl=useMemo(()=>we?$e?.charts?.find(a=>a.id===we.id)??null:null,[$e,we]);useEffect(()=>{!we||!$e||$e.charts?.some(a=>a.id===we.id)||($.current(),E.current=null,Ue(null),rt(null));},[$e,we]);let Nt=useCallback((a,m,v)=>{let A=c.current;if(!A||s||m===0&&v===0)return;let L=ae;U.input(()=>{if(!(c.current!==A||Fe.current))try{return qe(A.moveChart(L,a,m,v)),!0}catch(O){return Se(O instanceof Error?O.message:String(O)),false}});},[ae,qe,s,U]),vi=useCallback(()=>{R.current!=null&&(clearTimeout(R.current),R.current=null);let a=M.current;M.current=null,Dt(null),a&&Nt(a.id,a.dx,a.dy);},[Nt]);$.current=vi;let il=useCallback((a,m,v)=>{let A=M.current;A&&A.id!==a&&$.current();let L=M.current??{dx:0,dy:0},O={id:a,dx:L.dx+m,dy:L.dy+v};M.current=O,Dt({x:O.dx,y:O.dy}),R.current!=null&&clearTimeout(R.current),R.current=setTimeout(()=>{R.current=null;let Y=M.current;M.current=null,Dt(null),Y&&(Y.dx!==0||Y.dy!==0)&&ul.current(Y.id,Y.dx,Y.dy);},sm);},[]),ul=useRef(Nt);ul.current=Nt,useEffect(()=>{let a=v=>{let A=E.current;E.current=null,Ue(null),!(!A||v.button!==0)&&Nt(A.id,(v.clientX-A.clientX)/Z,(v.clientY-A.clientY)/Z);},m=()=>{E.current=null,Ue(null),$.current();};return window.addEventListener("mouseup",a),window.addEventListener("blur",m),()=>{window.removeEventListener("mouseup",a),window.removeEventListener("blur",m);}},[Nt,Z]),useEffect(()=>()=>{R.current!=null&&clearTimeout(R.current),R.current=null,M.current=null;},[]);let Dn=useCallback(a=>{let m=c.current,v=ot.current;if(!m||!v||s)return;let{row:A,col:L}=v.focus,O=a??"";if(a===void 0)try{O=m.cell(ge.current,A,L).input;}catch{O="";}Xt({row:A,col:L,value:O}),U.setDraft(Ft("cell",A,L,O));},[ot,ge,s,U,Ft]),Kt=useCallback(a=>{if(!c.current||!me||s)return;let{row:m,col:v,value:A}=me,L=U.draft,O=L?.source==="cell"&&L.row===m&&L.col===v?L:Ft("cell",m,v,A);if(!U.submit(O))return;z.current=true,Xt(null);let Y=selectionAt({row:m,col:v});pe(a?moveFocus(Y,a,{limits:Ze()}):Y),Me(),He(ge.current);},[me,Ze,Me,s,U,Ft,He]),Pi=useCallback(()=>{z.current=true;let a=U.draft;a?.source==="cell"&&U.discard(a),U.setDraft(null),Xt(null),Me(),He(ge.current);},[Me,U,He]),Bt=useCallback(()=>{let a=c.current,m=ot.current;return !a||!m?null:{handle:a,sheet:ge.current,range:normalizeRange(m)}},[ot,ge]),Fn=useCallback(({handle:a,sheet:m,range:v})=>{if(c.current!==a||Fe.current)return;let A=[];for(let L=v.top;L<=v.bottom;L++)for(let O=v.left;O<=v.right;O++)A.push({row:L,col:O,input:""});try{return qe(a.editCells(m,A)),!0}catch(L){return Se(L instanceof Error?L.message:String(L)),false}},[qe]),dl=useCallback(()=>{let a=Bt();a&&!s&&U.input(()=>Fn(a));},[Bt,Fn,s,U]),zn=useCallback(async({handle:a,sheet:m,range:v})=>{try{let A=a.cell(m,v.top,v.left).a1,L=a.cell(m,v.bottom,v.right).a1,O=a.rangeCells(m,`${A}:${L}`),Y=toTsv(O.map(ne=>ne.map(de=>({input:de.input,isFormula:de.isFormula}))));return await navigator.clipboard.writeText(Y),!0}catch{return false}},[]),cl=useCallback(async()=>{let a=Bt();a&&await zn(a);},[Bt,zn]),ml=useCallback(()=>{let a=Bt();if(!a)return;let m=zn(a);s||U.input(async()=>await m?Fn(a):void 0);},[Bt,zn,Fn,s,U]),fl=useCallback(()=>{let a=c.current,m=ot.current;if(!a||!m||s)return Promise.resolve();let v=(async()=>{try{return await navigator.clipboard.readText()}catch{return null}})(),A=ge.current,L=normalizeRange(m);return U.input(async()=>{let O=await v;if(O===null||Fe.current||c.current!==a)return;let Y=fromTsv(O);if(Y.length===0)return;let ne=[],de=1;Y.forEach((ce,Ye)=>{de=Math.max(de,ce.length),ce.forEach((Nn,st)=>ne.push({row:L.top+Ye,col:L.left+st,input:Nn}));});try{qe(a.editCells(A,ne));}catch(ce){return Se(ce instanceof Error?ce.message:String(ce)),false}return ot.current===m&&ge.current===A&&pe({anchor:{row:L.top,col:L.left},focus:{row:L.top+Y.length-1,col:L.left+de-1}}),true})},[ot,ge,qe,s,U,pe]);useEffect(()=>{let a=c.current;if(!a||!te||!Mo||jr||s)return;let m=normalizeRange(te);if(`${ae}:${m.top}:${m.left}:${m.bottom}:${m.right}`===at.current)return;let A=al(te);if(!A)return;let L=ae,O=Mo;lt(null),at.current=null,U.input(()=>{if(!(c.current!==a||Fe.current))try{return qe(a.applyFormat(L,A,O)),Me(),!0}catch(Y){return Se(Y instanceof Error?Y.message:String(Y)),false}});},[te,Mo,jr,ae,al,qe,Me,s,U]);let Si=useCallback(a=>{n?n(a):ei(a,t??"workbook.xlsx",rm);},[n,t]),wi=useCallback(()=>{let a=c.current,m=K.current;if(!a||!m)throw new Error("the workbook is not open");let v=a.renderPng({x:m.scrollLeft/Z,y:m.scrollTop/Z,width:m.clientWidth/Z,height:m.clientHeight/Z});ei(v,mm(t),"image/png");},[t,Z]),pl=useCallback(a=>{let m=U.draft;!c.current||m?.source!=="formula"||s||U.submit(m)&&(Ot(null),a&&pe(v=>v&&moveFocus(v,a,{limits:Ze()})),He(ge.current));},[U,Ze,s,He]),Xi=useCallback(a=>{if(!c.current||!te||!J||me||In(a)||dn(a))return;let v=a.metaKey||a.ctrlKey,A=a.key.toLowerCase();if(we){if(a.key==="Escape"){E.current=null,Ue(null),M.current=null,Dt(null),R.current!=null&&(clearTimeout(R.current),R.current=null),rt(null),a.preventDefault();return}let O=v?void 0:um[a.key];if(O){let Y=lm*(a.shiftKey?am:1);!s&&we.movable&&il(we.id,O[0]*Y,O[1]*Y),a.preventDefault();}return}if(v){if(A==="c"){cl(),a.preventDefault();return}if(A==="v"){fl(),a.preventDefault();return}if(A==="x"){ml(),a.preventDefault();return}}let L=selectionKeyReducer(te,{key:a.key,shiftKey:a.shiftKey,metaKey:a.metaKey,ctrlKey:a.ctrlKey,altKey:a.altKey},Ze());switch(L.type){case "move":pe(L.selection),a.preventDefault();break;case "startEdit":Dn(L.initialInput),a.preventDefault();break;case "clear":dl(),a.preventDefault();break;}},[te,J,me,Ze,cl,fl,ml,Dn,dl,we,il,s]),Ei=useCallback(a=>{if(In(a))return;let m=me!=null;if(m&&B.current?.contains(a.target))return;E.current=null,$.current();let v=Ht(a.clientX,a.clientY);if(v){m&&Kt(),rt({id:v.id,movable:!s&&v.movable}),!s&&v.movable&&a.button===0&&(E.current={id:v.id,clientX:a.clientX,clientY:a.clientY}),Ue(null),u.current=null,Me(),a.preventDefault();return}if(rt(null),Ue(null),!te)return;let A=bt(a.clientX,a.clientY);A&&(m&&Kt(),a.shiftKey?pe(L=>L&&extendTo(L,A,Ze())):pe(selectionAt(A)),u.current=m?null:A,X.current=true,Eo(true),Me());},[me,te,bt,Ht,Ze,Me,Kt,s]),Ri=useCallback(a=>{let m=E.current;if(In(a)){m||(a.currentTarget.style.cursor="default",a.currentTarget.title="");return}if(m){if(a.buttons===0){E.current=null,Ue(null);return}a.currentTarget.style.cursor="move",a.currentTarget.title="",Ue({x:a.clientX-m.clientX,y:a.clientY-m.clientY});return}let v=bt(a.clientX,a.clientY);if(!v){X.current||(a.currentTarget.style.cursor="default",a.currentTarget.title="");return}if(!X.current){let A=Ht(a.clientX,a.clientY);if(A){a.currentTarget.style.cursor=!s&&A.movable?"move":"pointer",a.currentTarget.title="";return}let L=T.current?hyperlinkAtCell(T.current,v.row,v.col):null;a.currentTarget.style.cursor=L?"pointer":"default",a.currentTarget.title=L?.tooltip??"";return}pe(A=>A&&extendTo(A,v,Ze()));},[bt,Ht,Ze,s]),gl=useCallback(a=>{let m=c.current,v=T.current;if(!m||!v||!J)return false;let A=hyperlinkAtCell(v,a.row,a.col);if(!A)return false;let L=safeExternalHyperlink(A);if(L)return window.open(L,"_blank","noopener,noreferrer"),true;if(!A.location)return true;let O=J.sheetNames[ae]??"",Y=parseHyperlinkLocation(A.location,O);if(!Y)return true;let ne=J.sheetNames.findIndex(de=>de.toLowerCase()===Y.sheetName.toLowerCase());if(ne<0)return true;try{m.setActiveSheet(ne);let de=m.cellPosition(ne,Y.row,Y.col);je(m.sheetInfo()),requestAnimationFrame(()=>{let ce=K.current;ce&&(ce.scrollLeft=de.x*Z,ce.scrollTop=de.y*Z);}),pe(selectionAt({row:Y.row,col:Y.col})),pt(),lt(null),at.current=null,Se(null);}catch(de){Se(de instanceof Error?de.message:String(de));}return true},[ae,J,Z]),Ti=useCallback(a=>{if(In(a))return;if(me){u.current=null;return}let m=bt(a.clientX,a.clientY),v=u.current;u.current=null,!(!m||!v||m.row!==v.row||m.col!==v.col)&&gl(m);},[gl,me,bt]),ki=useCallback(a=>{if(me||In(a)||Ht(a.clientX,a.clientY))return;let m=bt(a.clientX,a.clientY);m&&T.current&&hyperlinkAtCell(T.current,m.row,m.col)||te&&Dn();},[me,Dn,bt,Ht,te]),Ii=useCallback(a=>{a.currentTarget.style.cursor="default",a.currentTarget.title="";},[]),Rt=$e?.grid,bl=te?uo(normalizeRange(te),To):null,xl=te?uo({top:te.focus.row,left:te.focus.col,bottom:te.focus.row,right:te.focus.col},To):null,hl=Rt&&bl?rangeRect(Rt,bl):null,yl=Rt&&xl?rangeRect(Rt,xl):null,Cl=Rt&&me?cellRect(Rt,me.row,me.col):null,on=hl?ho(hl,Z):null,rn=yl?ho(yl,Z):null,ln=Cl?ho(Cl,Z):null,an=sl?ho(sl.rect,Z):null,Mi=J?J.contentWidth*Z:void 0,Ai=J?J.contentHeight*Z:void 0,Li=ai??Gr?.input??"",Oi=a=>{let m=c.current;if(m&&le.current())try{m.setActiveSheet(a),N.current=!0,pe(selectionAt({row:0,col:0})),rt(null),pt(),lt(null),at.current=null,je(m.sheetInfo()),He(a),W.refresh();}catch(v){Se(v instanceof Error?v.message:String(v));}};zt.current.navigator={selectCells(a,m,v,A){let L=ni(a,m?.sheetId),O=m?.selection;return L<0||!Kr(a,L,O?.anchor?.row,O?.anchor?.col)||!Kr(a,L,O?.focus?.row,O?.focus?.col)?"missing-target":(Ln(a,L,O),nl(L,O.focus.row,O.focus.col,"nearest",A),v&&Me(),null)},scrollToCell(a,m,v,A){let L=ni(a,m?.sheetId);return L<0||!Kr(a,L,m.row,m.col)?"missing-target":(L!==ge.current&&Ln(a,L,null),nl(L,m.row,m.col,v,A),null)}},ga(W,{handle:()=>c.current,status:()=>c.current?"ready":e&&!Mn?"loading":"empty",readOnly:()=>Fe.current,collaborative:()=>D,mutation:()=>tt.current,generation:()=>Pe.current,view:()=>({sheet:ge.current,selection:ot.current,chartSelected:Ur.current!==null,zoom:tn.current,capturedFormat:ii.current,borderStyle:ko.current,borderColor:Io.current,proposals:di.current,proposalsAvailable:Do,proposalsPanelOpen:mi.current,pngExport:pi}),coordinator:U,i18n:()=>g,translate:h,apply:qe,fail:a=>Se(a instanceof Error?a.message:String(a)),setZoom:si,setProposalsPanelOpen:Zr,setCapturedFormat:(a,m)=>{lt(a),at.current=m;},setBorderStyle:a=>{ko.current=a;},setBorderColor:a=>{Io.current=a;},markStale:(a,m)=>Lo(({[a]:v,...A})=>m?{...A,[a]:m}:A),refreshProposals:Et,deliver:Si,exportPng:wi,afterPaint:Ci,focusGrid:Me}),ca(W,P);let vl=a=>{let m=()=>{},v=new Promise(A=>{m=L=>setTimeout(()=>A(L),0);});nt.current={source:a,done:v,settle:m};},Pl=()=>{nt.current?.settle(true),nt.current=null;},Hn=useCallback(a=>{let m=nt.current;m?.source===a&&(m.settle(false),nt.current=null);},[]),Di=useCallback(a=>{B.current=a,a||Hn("cell");},[Hn]),Fi=useCallback(a=>{y.current=a,a||Hn("formula");},[Hn]),Sl=!s&&te!==null&&we===null,zi={a1:Gr?.a1??"",value:Li,disabled:!J||!te,readOnly:!Sl,inputRef:Fi,onChange:a=>{let m=ot.current;!Sl||Fe.current||!m||Ur.current||(Ot(a),U.setDraft(Ft("formula",m.focus.row,m.focus.col,a)));},onCommit:a=>{pl(a),Me();},onCancel:()=>{let a=U.draft;a?.source==="formula"&&(U.discard(a),U.setDraft(null)),Ot(null),Me(),He(ae);},onBlur:()=>{yo.current||pl();},onCompositionStart:()=>vl("formula"),onCompositionEnd:Pl},Hi=jsxs(Mt,{mode:"commands",children:[jsx(Mt.Toolbar,{}),jsxs("div",{style:Jt.rail,role:"group","aria-label":h("toolbar.formulaBarLabel"),children:[jsxs(xe,{style:{...Jt.group,paddingLeft:0},label:h("toolbar.fileActionsLabel"),children:[jsx(yt,{id:"save",children:jsx(be,{name:"save",size:18})}),jsx(yt,{id:"exportPng",children:jsx(be,{name:"image",size:18})})]}),jsx(Mt.FormulaBar,{}),jsx(ys,{peers:Jr,sheetIds:J?.sheetIds??[],sheetNames:J?.sheetNames??[],activeSheet:ae}),Do&&jsx("div",{style:Jt.proposals,children:jsx(ym,{})})]})]}),wl=p?b===void 0?s?null:Hi:b:null,Ho=a=>Ve.managed?jsx(ks,{host:Ve.host,placement:a,activations:Ve.activations.filter(m=>m.plugin.panel?.placement===a),available:yi}):null,Ni=jsxs("div",{ref:P,className:i,role:"application","aria-label":h("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:[wl!=null&&jsx("div",{"data-testid":"xlsx-toolbar",style:b===void 0?Jt.shell:Jt.host,children:wl}),jsxs("div",{ref:hi,"data-testid":"xlsx-workspace",style:li.workspace,children:[Ho("left"),jsxs("div",{style:li.center,children:[Do&&ci&&jsx(Ss,{proposals:ui,staleFor:fi,style:{top:4,right:8,width:"min(320px, calc(100% - 16px))",maxHeight:"min(420px, calc(100% - 12px))"}}),jsxs("div",{ref:K,"data-testid":"xlsx-scroll",tabIndex:0,onKeyDown:Xi,onMouseDown:Ei,onMouseMove:Ri,onMouseLeave:Ii,onClick:Ti,onDoubleClick:ki,style:{position:"relative",flex:1,overflow:"auto",minHeight:0,outline:"none"},children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:Mi??"100%",height:Ai??"100%"}}),jsxs("div",{style:{position:"sticky",top:0,left:0,width:0,height:0},children:[jsx("canvas",{ref:f,style:{display:"block",position:"absolute",top:0,left:0}}),Ve.managed&&jsx(ws,{host:Ve.host,activations:Ve.activations,layerRef:Ve.overlayLayerRef,width:($e?.width??0)*Z,height:($e?.height??0)*Z}),jsxs("div",{"data-testid":"xlsx-overlay-host",style:{position:"absolute",top:0,left:0,width:0,height:0,pointerEvents:"none"},children:[on&&!we&&jsx("div",{"data-testid":"xlsx-selection",style:{position:"absolute",left:on.x,top:on.y,width:on.w,height:on.h,boxSizing:"border-box",border:`1px solid ${kn}`,background:"rgba(33, 115, 70, 0.12)"}}),an&&jsx("div",{"data-testid":"xlsx-chart-selection","data-chart-id":we?.id,"aria-hidden":true,style:{position:"absolute",left:an.x+(Ro?.x??0)+(Vr?.x??0)*Z,top:an.y+(Ro?.y??0)+(Vr?.y??0)*Z,width:an.w,height:an.h,boxSizing:"border-box",border:`2px solid ${kn}`,boxShadow:"0 1px 6px rgba(0, 0, 0, 0.25)",background:Ro?"rgba(33, 115, 70, 0.08)":"transparent"}}),rn&&!we&&!me&&jsx("div",{style:{position:"absolute",left:rn.x,top:rn.y,width:rn.w,height:rn.h,boxSizing:"border-box",border:`2px solid ${kn}`}}),jsx(Cs,{peers:Jr,grid:Rt,sheetIds:J?.sheetIds??[],activeSheet:ae,zoom:Z,mergedRanges:To}),!s&&me&&ln&&jsx("input",{ref:Di,"data-testid":"xlsx-cell-editor",value:me.value,onChange:a=>{let m=a.target.value;Xt(v=>v&&{...v,value:m}),me&&U.setDraft(Ft("cell",me.row,me.col,m));},onCompositionStart:()=>vl("cell"),onCompositionEnd:Pl,onKeyDown:a=>{dn(a)||a.stopPropagation(),!(a.nativeEvent.isComposing||a.keyCode===229)&&(a.key==="Enter"?(Kt(a.shiftKey?"up":"down"),a.preventDefault()):a.key==="Tab"?(Kt(a.shiftKey?"left":"right"),a.preventDefault()):a.key==="Escape"&&(Pi(),a.preventDefault()));},onBlur:()=>{if(z.current){z.current=false;return}Kt();},style:{position:"absolute",left:ln.x,top:ln.y,width:ln.w,height:ln.h,boxSizing:"border-box",border:`2px solid ${kn}`,padding:"0 3px",font:`${13*Z}px system-ui, sans-serif`,background:"#ffffff",pointerEvents:"auto",outline:"none"}})]})]})]}),Ho("bottom")]}),Ho("right")]}),nn&&jsxs(Fragment,{children:[jsxs("div",{style:ri,role:"grid","aria-label":nn.label,children:[jsxs("div",{role:"row",children:[jsx("span",{role:"columnheader"}),nn.columnHeaders.map(a=>jsx("span",{role:"columnheader",children:a.label},a.col))]}),nn.rows.map(a=>jsxs("div",{role:"row",children:[jsx("span",{role:"rowheader",children:a.header}),a.cells.map(m=>jsx("span",{role:"gridcell","aria-selected":m.selected,children:m.label},m.col))]},a.row))]}),nn.charts.map((a,m)=>jsx("div",{style:ri,role:"img","aria-label":a.label},`${m}:${a.label}`))]}),_r&&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:_r}),Mn&&jsxs("div",{"data-testid":"xlsx-error",role:"alert",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",padding:16,textAlign:"center",color:"#b00020"},children:[h("editor.openError"),": ",Mn]}),J&&J.sheetNames.length>0&&jsx("div",{"data-testid":"xlsx-sheet-tabs",role:"tablist","aria-label":h("editor.sheetTabsLabel"),style:{display:"flex",gap:2,padding:"4px 6px",borderTop:"1px solid #e0e0e0",background:"#fafafa",overflowX:"auto"},children:J.sheetNames.map((a,m)=>{let v=m===J.activeSheet;return jsx("button",{role:"tab","aria-selected":v,onClick:()=>Oi(m),style:{border:"none",padding:"4px 12px",cursor:"pointer",borderBottom:v?`2px solid ${kn}`:"2px solid transparent",fontWeight:v?600:400,background:v?"#ffffff":"transparent"},children:a},m)})})]});return jsx(ut.Provider,{value:W.store,children:jsx(qn.Provider,{value:true,children:jsx(gn.Provider,{value:zi,children:Ni})})})}function ym(){let e=xt("proposalsPanel"),t=e.state.value??0;return jsxs(ct,{testId:"xlsx-proposals-button",onClick:()=>{e.execute();},disabled:!e.state.enabled,description:e.state.enabled?void 0:e.state.disabledReason.message,active:e.state.active===true,toggle:true,ariaExpanded:e.state.active===true,title:e.label,style:{width:t>0?42:28},children:[jsx(be,{name:"proposals",size:18}),t>0&&jsx("span",{"data-testid":"xlsx-proposals-count",style:Jt.count,children:t})]})}export{Mt as EditorToolbar,dt as EditorToolbarContext,_t as LocaleProvider,wn as Toolbar,Du as ToolbarButton,ie as ToolbarCommand,yt as ToolbarCommandButton,Ka as ToolbarCommandSelect,hn as ToolbarDropdown,xe as ToolbarGroup,to as ToolbarMenuItem,yn as ToolbarMenuSeparator,Od as ToolbarOverflow,xn as ToolbarSeparator,ve as XlsxCommandAdmissionError,iu as XlsxCommandProvider,xm as XlsxEditor,fr as XlsxPluginToolbar,Qt as XlsxSaveRefusedError,wn as XlsxToolbar,Ic as defineXlsxPlugin,Cu as useEditorToolbar,re as useTranslation,xt as useXlsxCommand,oe as useXlsxCommandState,fe as useXlsxCommands};
1
+ import {V,W,a,G,Ua,H,x,A,u,k,j,pa as pa$1,qa,w,Na,Fa,Da,oa,i,f,e,c,C,F,E,na,q,l,ua as ua$1,ta,Q,P,ma as ma$1,X,va as va$1,xa as xa$1,Ba,wa as wa$1,ya as ya$1,I,S,Y,M,$,_,h,Ga,ra,sa,t,s,N,O,Ra as Ra$1,n,za,Ta,Aa,z,ga as ga$1,Ca as Ca$1,Wa,y,g,d,v,r,o,b}from'./chunk-OADYDRKQ.js';export{ma as EditorToolbar,R as EditorToolbarContext,G as LocaleProvider,la as Toolbar,aa as ToolbarButton,ia as ToolbarCommand,ga as ToolbarCommandButton,ha as ToolbarCommandSelect,da as ToolbarDropdown,ba as ToolbarGroup,ea as ToolbarMenuItem,fa as ToolbarMenuSeparator,ka as ToolbarOverflow,ca as ToolbarSeparator,Va as XlsxAsyncApiSyncAccessError,w as XlsxCommandAdmissionError,J as XlsxCommandProvider,Oa as XlsxPeerNotReadyError,ja as XlsxPluginToolbar,la as XlsxToolbar,Pa as XlsxWorkerEditorCollaborationError,Sa as XlsxWorkerSessionFailedError,Ma as defineXlsxPlugin,U as useEditorToolbar,H as useTranslation,M as useXlsxCommand,L as useXlsxCommandState,K as useXlsxCommands}from'./chunk-OADYDRKQ.js';import {useMemo,useEffect,useState,useRef,useCallback,useLayoutEffect,Component}from'react';import {selectionAt,isPngExportAvailable,isProposalsAvailable,initWasm,openWorkbook,normalizeRange,paintDisplayList,buildA11yGrid,cellAtPoint,chartRegionAtPoint,moveFocus,toTsv,selectionKeyReducer,extendTo,hyperlinkAtCell,safeExternalHyperlink,parseHyperlinkLocation,rangeRect,cellRect,WorkbookEditPeerFailedError,openWorkbookSession,StaleProposalError,fromTsv}from'@betteroffice/xlsx';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {workbookEditPeerOperations,localNowSerial,workbookSessionInternals,createWorkbookRecoveryMutators,WorkbookRecoveryRefusal}from'@betteroffice/xlsx/worker';import {flushSync}from'react-dom';function Fi(){let n;return {closed:new Promise(l=>{n=l;}),close:n}}function qi(n){return typeof n?.then=="function"}function Vo(n,r){return n.generation===r.generation&&n.source===r.source&&n.sheet===r.sheet&&n.row===r.row&&n.col===r.col}function Mi(n){let r=null,l=null,c=Fi(),y=false,f=false,A=false,I=new WeakSet,d=[],b=[],X=C=>d=d.filter(v=>!Vo(v,C)),x=C=>d=[...d.filter(v=>!Vo(v,C)),C],q=()=>{let C=n.generation();d=d.filter(v=>v.generation===C);},E=C=>{let v=C.then(()=>{},()=>{});l=v,v.then(()=>{l===v&&(l=null,y=false);});},W=(C,v)=>{if(l){let le=l.then(()=>false),oe=Promise.race([le,c.closed.then(()=>true)]).then(U=>U?v():C());return E(oe),oe}let L;try{L=C();}catch(le){return y=false,Promise.reject(le)}return qi(L)?(E(L),L):(y=false,Promise.resolve(L))},V=()=>{},g=()=>{throw new w("document-replaced")},K=()=>{y=true,f&&(A=true);},F=C=>I.has(C)?true:n.write(C)?(I.add(C),X(C),true):false,M=()=>(q(),d.length>0),j=C=>{X(C),b.push(C),W(()=>{b.splice(b.indexOf(C),1),!(C.generation!==n.generation()||F(C))&&(y=!0,!b.some(v=>Vo(v,C))&&(x(C),r===null&&n.restore(C)&&(r=C)));},V);},O=(C,v)=>{if(n.generation()!==v)throw new w("document-replaced");if(y||M())throw new w("input-failed");if(!(!C||C.generation!==v)){if(!F(C))throw y=true,x(C),new w("input-failed");r===C&&(r=null,n.close(C));}};return {get draft(){return r},get rejected(){return d},get pending(){return l!==null},setDraft(C){r=C;},input(C){return W(()=>{let v=le=>{le===!1&&K();},L;try{L=C();}catch{L=!1;}return qi(L)?L.then(v,()=>v(!1)):v(L)},V)},submit(C){return r===C&&(r=null),l?(j(C),true):C.generation!==n.generation()||F(C)?true:(x(C),r=C,false)},discard(C){X(C);},settle(){let C=r;return C?C.generation!==n.generation()?(r=null,true):l?(r=null,n.close(C),j(C),true):F(C)?(r===C&&(r=null,n.close(C)),true):false:true},runAfterPendingInput(C){if(M())return Promise.reject(new w("input-failed"));f=true,A=false;let v;try{v=n.seal();}finally{f=false;}if(v.refused)return Promise.reject(new w(v.refused));if(A)return Promise.reject(new w("input-failed"));let L=n.generation(),le=v.composition;if(le){let U=le.then(J=>{if(J)return n.sync(),r});return W(async()=>{let J=await U;if(J===void 0)throw new w("input-failed");return O(J,L),C()},g)}n.sync();let oe=r;return W(()=>(O(oe,L),C()),g)},reset(){c.close(),c=Fi(),l=null,y=false;}}}var el=new Set(["zoom","searchMenus","proposalsPanel"]);function Bi(n,r){let l=n.cell(r.sheet,r.top,r.left).a1,c=n.cell(r.sheet,r.bottom,r.right).a1;return `${l}:${c}`}function tl(n,r,l,c){let y={key:c,formatting:null,merged:[],canUndo:false,canRedo:false};try{let f=Bi(n,{sheet:r,...l,merged:[],formatting:null});y.formatting=n.selectionFormatting(r,f),y.merged=n.mergedRanges(r,f);}catch{}try{let f=n.historyState();y.canUndo=f.canUndo,y.canRedo=f.canRedo;}catch{}return y}function rl(n,r,l){let c=(f,A,I,d)=>({start:{row:f,col:A},end:{row:I,col:d}}),y=[];if(l==="all")y.push({type:"mergeCells",sheet:n,range:c(r.top,r.left,r.bottom,r.right)});else if(l==="horizontal")for(let f=r.top;f<=r.bottom;f++)y.push({type:"mergeCells",sheet:n,range:c(f,r.left,f,r.right)});else if(l==="vertical")for(let f=r.left;f<=r.right;f++)y.push({type:"mergeCells",sheet:n,range:c(r.top,f,r.bottom,f)});else for(let f of r.merged)y.push({type:"unmergeCells",sheet:n,range:c(f.start.row,f.start.col,f.end.row,f.end.col)});return y}function zi(n,r$1){let l=useRef(r$1);l.current=r$1;let c=useRef(null);useLayoutEffect(()=>{let y=b=>{let X=l.current,x=X.handle(),q=X.view();if(!x||X.status()!=="ready")return null;let E=q.selection?normalizeRange(q.selection):{top:0,left:0,bottom:0,right:0},W=[X.generation(),X.mutation(),q.sheet,E.top,E.left,E.bottom,E.right].join(":");return !b&&c.current?.key===W||(c.current=tl(x,q.sheet,E,W)),c.current},f=b=>{let X=l.current,x=X.view(),q=y(b),E=null;return x.chartSelected?E="chart":x.selection&&q&&(E={sheet:x.sheet,...normalizeRange(x.selection),merged:q.merged,formatting:q.formatting}),{status:X.status(),readOnly:X.readOnly(),collaborative:X.collaborative(),selection:E,canUndo:q?.canUndo??false,canRedo:q?.canRedo??false,pendingInput:X.coordinator.draft!==null,zoom:x.zoom,paintFormat:x.capturedFormat!==null,borderStyle:x.borderStyle??q?.formatting?.borderStyle??null,borderColor:x.borderColor??q?.formatting?.borderColor??null,pngExport:x.pngExport,proposals:x.proposalsAvailable?x.proposals.map(W=>({id:W.id,label:W.agentId})):null,proposalsPanelOpen:x.proposalsPanelOpen,fontFamilies:s,fontSizes:t,translate:X.translate}},A=(b,X,x)=>{let q=l.current,E=q.handle(),W=v=>({ok:false,failure:r(v,x)});if(!E)return W("editor-unavailable");let V=(v=true)=>({ok:true,status:v?"executed":"noop"}),g=v=>{try{return v()}catch(L){return q.fail(L),W("command-failed")}},K=v=>g(()=>{let L=v();return q.apply(L),V(L.applied)}),F=X,M=typeof x.selection=="object"?x.selection:null,j=()=>{if(!M)throw new Error("no cell selection");return {sheet:M.sheet,range:Bi(E,M)}},O=v=>K(()=>{let{sheet:L,range:le}=j();return E.patchRangeStyle(L,le,v)}),C=M?.formatting??null;switch(b){case "bold":return O({bold:C?.bold!==true});case "italic":return O({italic:C?.italic!==true});case "strikethrough":return O({strikethrough:C?.strikethrough!==true});case "paintFormat":return x.paintFormat?(q.setCapturedFormat(null,null),V()):g(()=>{let{sheet:v,range:L}=j(),le=`${v}:${M.top}:${M.left}:${M.bottom}:${M.right}`;return q.setCapturedFormat(E.captureFormat(v,L),le),V()});case "fontFamily":return O({fontFamily:F.family});case "fontSize":return O({fontSize:F.points});case "fontSizeStep":{let v=C?.fontSize??10,L=x.fontSizes,le=F.direction==="increase"?L.find(oe=>oe>v)??v+1:[...L].reverse().find(oe=>oe<v)??Math.max(1,v-1);return O({fontSize:le})}case "textColor":return O({textColor:F.color});case "fillColor":return O({fillColor:F.color});case "numberFormat":return K(()=>{let{sheet:v,range:L}=j();return F.value==="custom"?E.setNumberFormat(v,L,{type:"custom",pattern:C?.numberFormatPattern??"0.00"}):E.setNumberFormat(v,L,F.value)});case "decimalPlaces":return K(()=>{let{sheet:v,range:L}=j();return E.setNumberFormat(v,L,F.direction==="increase"?"increaseDecimal":"decreaseDecimal")});case "borderPreset":return O({border:{preset:F.value,style:x.borderStyle??"solid",color:x.borderColor??"#000000"}});case "borderStyle":return q.setBorderStyle(F.value),O({border:{style:F.value}});case "borderColor":return q.setBorderColor(F.color),O({border:{color:F.color}});case "horizontalAlignment":return O({horizontalAlignment:F.value});case "verticalAlignment":return O({verticalAlignment:F.value});case "textWrapping":return O({textWrapping:F.value});case "merge":{if(!M)return W("cell-selection-required");let v=rl(M.sheet,M,F.value);return v.length===0?V(false):K(()=>E.applyOps(v))}case "undo":return K(()=>E.undo());case "redo":return K(()=>E.redo());case "save":return g(()=>(q.deliver(E.save()),V()));case "exportPng":return g(()=>(q.exportPng(),V()));case "print":{let v=q.generation();return q.afterPaint().then(L=>l.current.generation()!==v?W("document-replaced"):L?(window.print(),V()):W("render-failed"))}case "zoom":return x.zoom===F.scale?V(false):(q.setZoom(F.scale),V());case "proposalsPanel":{let v=X===null?!x.proposalsPanelOpen:F.open;return v===x.proposalsPanelOpen?V(false):(q.setProposalsPanelOpen(v),V())}case "proposalAccept":try{return q.apply(E.acceptProposal(F.proposalId,{force:F.force})),q.markStale(F.proposalId,null),q.refreshProposals(),V()}catch(v){return v instanceof StaleProposalError?(q.markStale(F.proposalId,v.cells),q.refreshProposals(),W("proposal-stale")):(q.fail(v),W("command-failed"))}case "proposalReject":return g(()=>{let v=E.rejectProposal(F.proposalId);return q.markStale(F.proposalId,null),q.refreshProposals(),v?V():W("proposal-not-found")});default:return W("unsupported-command")}},I=b=>{if(!v(b))return "document";let X=l.current.view();return X.chartSelected?"chart":X.selection?`${X.sheet}:${JSON.stringify(normalizeRange(X.selection))}`:"none"},d={requestSave:b=>l.current.requestSave?.(b)??b(),environment:f,ordered:b=>{let X=l.current;return !el.has(b)||X.coordinator.rejected.some(x=>x.generation===X.generation())},admit:b=>l.current.coordinator.runAfterPendingInput(b),perform:A,capture(b){let X=l.current;return X.handle()?{generation:X.generation(),target:I(b)}:null},resume(b,X){let x=l.current;return !x.handle()||x.generation()!==b.generation?"document-replaced":I(X)===b.target?null:"target-changed"},chrome:()=>({i18n:l.current.i18n()}),focusEditor:()=>l.current.focusGrid()};return n.attach(d),()=>n.detach(d)},[n]),useLayoutEffect(()=>{n.refresh();});}var ll={open:openWorkbookSession};function So(n,r){return n!==null&&n.sheet===r.sheet&&n.navigation===r.navigation&&n.zoom===r.zoom&&n.dpr===r.dpr&&n.width===r.width&&n.height===r.height&&Vi(n.viewport,r.viewport)}function Vi(n,r){return n.x===r.x&&n.y===r.y&&n.width===r.width&&n.height===r.height}function $i(n){return [n?.anchor,n?.focus].every(r=>r&&Number.isInteger(r.row)&&r.row>=0&&r.row<=1048575&&Number.isInteger(r.col)&&r.col>=0&&r.col<=16383)}var Ko=class{constructor(r,l,c,y,f$1=()=>true,A=0){a(this,"session",r);a(this,"changed",l);a(this,"report",c);a(this,"onReady",y);a(this,"isCurrent",f$1);a(this,"generation",A);a(this,"selectionNavigation",n());a(this,"emptySelection",selectionAt({row:0,col:0}));a(this,"alive",true);a(this,"failed",false);a(this,"active");a(this,"navigation",0);a(this,"selection",selectionAt({row:0,col:0}));a(this,"view",null);a(this,"painted",null);a(this,"scrollRevision",0);a(this,"scrollTarget",null);a(this,"surface",null);a(this,"raf",null);a(this,"revision",0);a(this,"pending",null);a(this,"running",false);a(this,"ready",false);a(this,"viewRequest",0);a(this,"waiters",new Set);a(this,"selectionContext",()=>{if(!this.current)return null;let r=this.session.confirmedBasis;return {owner:this,sheet:this.active,selection:this.selection??this.emptySelection,navigation:this.navigation,version:`${r.epoch}:${r.version}:${this.session.state.version}`}});a(this,"selectionMerges",(r=this.selectionContext())=>{let l=this.painted?.frame,c=l&&r&&l.sheet===r.sheet&&l.version===this.session.confirmedBasis.version?h(l.mergedRanges):void 0;return r?this.selectionNavigation.merges(r,c):{mergeAt:()=>null}});a(this,"selectionOptions",()=>({context:this.selectionContext,limits:()=>oa(this.painted?.frame.displayList??null,this.surface?.capture()?.viewport.height??0),hidden:()=>f(this.painted?.frame.displayList.grid),merges:this.selectionMerges,known:(r,l)=>{let c=this.painted?.frame;return this.selectionNavigation.known(r,l)||c?.sheet===r.sheet&&c.version===this.session.confirmedBasis.version&&g(c.displayList.grid,l)},query:(r,l)=>this.session.call.selectionData(r.sheet,r.selection.focus.row,r.selection.focus.col,l),apply:(r,l=this.active)=>this.placeCellsAsync(l,r,"nearest",false)}));this.active=r.state.activeSheet;}get current(){return this.alive&&!this.failed&&this.isCurrent()}getPositionAtPoint(r,l){return this.current?this.surface?.getPositionAtPoint?.(r,l)??null:null}connect(r){return this.surface=r,this.schedule(),()=>{this.surface===r&&(this.surface=null,this.cancelFrame());}}start(){this.show(this.active);}async show(r){if(!this.current||!this.validSheet(r))return false;this.beginNavigation();let l=++this.viewRequest;this.active=r,this.view=null,this.selection=selectionAt({row:0,col:0}),this.changed();try{let c=await this.session.call.sheetView(r);return !this.current||l!==this.viewRequest?!1:(this.presentView(c,{x:c.initialScrollX,y:c.initialScrollY}),!0)}catch(c){return this.current&&l===this.viewRequest&&this.fail(c),false}}selectCellsAsync(r,l,c="start"){return !this.current||!this.validSheet(r)||!$i(l)?Promise.resolve(false):this.selectionNavigation.select(l,{...this.selectionOptions(),apply:y=>this.placeCellsAsync(r,y,c)},r)}async placeCellsAsync(r,l,c="start",y=true){if(!this.current||!this.validSheet(r)||!$i(l))return false;let f=structuredClone(l),A=this.beginNavigation();this.viewRequest+=1,c==="nearest"&&r===this.active&&(this.selection=f,this.changed());try{let[I,d,b]=await Promise.all([this.view?.sheet===r?Promise.resolve(this.view):this.session.call.sheetView(r),f.anchor.row===f.focus.row&&f.anchor.col===f.focus.col?Promise.resolve(null):this.session.call.cellGeometry(r,f.anchor.row,f.anchor.col),this.session.call.cellGeometry(r,f.focus.row,f.focus.col)]);if(!this.current||A!==this.navigation)return !1;this.active=r,this.selection=f;let X=y?new Promise(v=>this.waiters.add({request:null,resolve:v})):null,x=this.surface?.capture()?.viewport;if(this.presentView({...I,contentWidth:Math.max(I.contentWidth,d?d.rect.x+d.rect.w:0,b.rect.x+b.rect.w),contentHeight:Math.max(I.contentHeight,d?d.rect.y+d.rect.h:0,b.rect.y+b.rect.h)},c==="nearest"&&x?sa(b.rect,f.focus,I,x):b.scrollPosition),!y)return !0;if(!await X||!this.current||A!==this.navigation)return !1;let q=this.painted;if(!q||!So(this.surface?.capture()??null,q.request))return !1;let{frame:E,request:W}=q,{viewport:V}=W,g=ua$1({top:f.focus.row,left:f.focus.col,bottom:f.focus.row,right:f.focus.col},E.mergedRanges??[]),K=rangeRect(E.displayList.grid,g);if(!K||K.w<=0||K.h<=0)return !1;let F=g.left<I.frozenCols?0:I.frozenWidth,M=g.top<I.frozenRows?0:I.frozenHeight,j=Math.min(V.width,E.displayList.width,g.right<I.frozenCols?I.frozenWidth:1/0),O=Math.min(V.height,E.displayList.height,g.bottom<I.frozenRows?I.frozenHeight:1/0),C=1/W.zoom;return j>F&&O>M&&Math.min(K.x+K.w,j+C)>Math.max(K.x,F-C)&&Math.min(K.y+K.h,O+C)>Math.max(K.y,M-C)}catch{return this.current&&A===this.navigation&&(this.view?this.schedule():this.show(this.active)),false}}setSelection(r){if(this.current){if(!r){this.placeSelection(null);return}this.selectionNavigation.select(r,{...this.selectionOptions(),apply:l=>(this.placeSelection(l),true)},void 0,true);}}placeSelection(r){this.beginNavigation(),this.selection=r,this.changed(),this.schedule();}afterPaint(){return this.current?this.painted&&So(this.surface?.capture()??null,this.painted.request)?Promise.resolve(true):(this.schedule(),new Promise(r=>this.waiters.add({request:void 0,resolve:r}))):Promise.resolve(false)}placedView(){this.scrollTarget=null;let r=this.surface?.capture()??null;for(let l of this.waiters)l.request===null&&(l.request=r);this.schedule();}schedule(){!this.current||!this.surface||(this.revision+=1,this.raf===null&&(this.raf=requestAnimationFrame(()=>{if(this.raf=null,!this.current||!this.view||this.scrollTarget)return;let r=this.surface?.capture();if(r){for(let l of this.waiters)l.request===null&&(l.request=r);this.pending={request:r,revision:this.revision},this.drain();}})));}fail(r){this.current&&(this.failed=true,this.cancelFrame(),this.finish(false),this.report(r),this.changed());}dispose(){this.alive&&(this.alive=false,this.cancelFrame(),this.finish(false),this.surface=null,this.painted=null,this.session.dispose().catch(()=>{}));}validSheet(r){return Number.isInteger(r)&&r>=0&&r<this.session.state.sheets.length}beginNavigation(){return this.finish(false),this.navigation+=1,this.revision+=1,this.pending=null,this.navigation}presentView(r,l){if(r.sheet!==this.active){this.fail(new Error("Unexpected sheet view"));return}this.view=r,this.scrollTarget=l,this.scrollRevision+=1,this.changed(),this.schedule();}cancelFrame(){this.raf!==null&&cancelAnimationFrame(this.raf),this.raf=null,this.pending=null;}finish(r){for(let l of this.waiters)l.resolve(r);this.waiters.clear();}matches(r,l){return l===this.revision&&r.navigation===this.navigation&&r.sheet===this.active&&this.scrollTarget===null&&So(this.surface?.capture()??null,r)}async drain(){if(!(this.running||!this.current)){this.running=true;try{for(;this.current&&this.pending;){let r=this.pending;this.pending=null;let{request:l,revision:c}=r;if(!this.matches(l,c)){this.raf===null&&this.schedule();continue}try{let y=await this.session.call.frame(l.viewport,{sheet:l.sheet});if(!this.current)break;if(!this.matches(l,c)){!this.pending&&this.raf===null&&this.schedule();continue}if(y.sheet!==l.sheet||!Vi(y.viewport,l.viewport))throw new Error("Unexpected workbook frame");if(this.surface.paint(y,l),!this.current)break;this.painted={frame:y,request:l},this.changed();for(let f of this.waiters)f.resolve(f.request===void 0||So(f.request,l));this.waiters.clear(),this.ready||(this.ready=!0,this.onReady());}catch(y){if(!this.current)break;y instanceof Error&&y.name==="SessionSuperseded"?this.pending||this.schedule():this.matches(l,c)&&this.fail(y);}}}finally{this.running=false;}}}};function Ui(n,r,l){let c=useRef({props:n,focus:l});c.current={props:n,focus:l};let y=useRef(0),[f,A]=useState(null),[,I]=useState(0),[d,b]=useState(null),[X,x]=useState(false),q=n.collaboration,E=useCallback(W=>{let V=W instanceof Error?W:new Error(W&&typeof W=="object"&&"message"in W?String(W.message):String(W));b(V.message),c.current.props.onError?.(V);},[]);return useEffect(()=>{let W=++y.current,V=new AbortController,g=false,K,F=()=>{},M,j=()=>!g&&W===y.current&&c.current.props.file===n.file,O=()=>{j()&&I(C=>C+1);};return A(null),b(null),x(!!n.file),q?(E(new Error("Collaboration is unavailable in the worker viewer")),x(false)):n.file&&(async()=>{try{let C=await ll.open(n.file,{signal:V.signal});if(!j()){C.dispose().catch(()=>{});return}K=new Ko(C,O,U=>{j()&&E(U);},()=>{j()&&(M=c.current.props.onReady?.(oe));},j,W);let v=K,L=async U=>{if(!v.current)return null;try{let J=await U(C);return v.current?J:null}catch(J){if(!v.current)return null;throw J}},le=()=>L(async U=>({ok:!1,version:await U.call.version(),failure:{code:"read-only",message:"The editor is read-only"}})),oe={handle:null,commands:r,save:()=>null,selectCells:()=>!1,flushPendingInput:async()=>{if(!v.current)throw new w("document-replaced")},getPositionAtPoint:(U,J)=>v.getPositionAtPoint(U,J),refreshProposals:()=>{},clearSelection:()=>v.setSelection(null),focus:()=>{v.current&&c.current.focus();},selectCellsAsync:(U,J)=>v.selectCellsAsync(U,J),saveAsync:()=>L(U=>U.save()),version:()=>L(U=>U.call.version()),readCells:U=>L(J=>J.call.readCells(U)),findText:U=>L(J=>J.call.findText(U)),validateEdits:le,applyEdits:le};F=C.onFailure(U=>v.fail(U)),C.failure&&v.fail(C.failure),A(v),x(!1),v.start();}catch(C){if(!j())return;K?.fail(C),K||E(C),x(false);}})(),()=>{g=true,y.current+=1,V.abort(),F();try{typeof M=="function"&&M();}finally{K?.dispose();}}},[n.file,q,r,E]),{run:f?.current?f:null,error:d,loading:X,reportError:E}}var Wo="#217346",gl="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",Zi={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"};function Yo(n){let r="";for(let l=n.col+1;l>0;l=Math.floor((l-1)/26))r=String.fromCharCode(65+(l-1)%26)+r;return `${r}${n.row+1}`}function vl(n){return `${Yo({row:n.top,col:n.left})}:${Yo({row:n.bottom,col:n.right})}`}function yl(n,r){let l=URL.createObjectURL(new Blob([new Uint8Array(n)],{type:gl})),c=document.createElement("a");c.href=l,c.download=r,document.body.appendChild(c),c.click(),c.remove(),URL.revokeObjectURL(l);}function Qi(n){let{t:r}=H(),l$1=useRef(null),c=useRef(null),y=useRef(null),[f$1]=useState(x),[A,I$1]=useState(1),d$1=useRef(A);d$1.current=A;let[b,X]=useState(null),[x$1,q$1]=useState(null),E=useRef(false),W=useRef(null),V=useCallback(()=>c.current?.focus({preventScroll:true}),[]),{run:g,loading:K,error:F,reportError:M}=Ui(n,f$1.store,V),j=useRef({run:g,props:n,zoom:A,selectedChart:b,loading:K,t:r,reportError:M});j.current={run:g,props:n,zoom:A,selectedChart:b,loading:K,t:r,reportError:M};let O=useRef(null),C=Q({document:()=>j.current.run?.current?j.current.run:null,onSaveRequest:n.onSaveRequest,fail:M}),v=useMemo(()=>({getPositionAtPoint(u,S){let $=j.current.run?.painted;return $?na($.frame.displayList,$.frame.sheet,y.current,u,S):null},capture(){let u=j.current.run,S=c.current,$=d$1.current;if(!u?.current||!u.view||!S||!y.current)return null;let Z=S.clientWidth,xe=S.clientHeight;return Z===0||xe===0?null:{sheet:u.active,navigation:u.navigation,zoom:$,dpr:window.devicePixelRatio||1,width:Z,height:xe,viewport:{x:S.scrollLeft/$,y:S.scrollTop/$,width:Z/$,height:xe/$}}},paint(u,S){let $=y.current,Z=$.getContext("2d");if(!Z)throw new Error("Canvas context is unavailable");$.width=Math.round(S.width*S.dpr),$.height=Math.round(S.height*S.dpr),$.style.width=`${S.width}px`,$.style.height=`${S.height}px`,paintDisplayList(Z,u.displayList,S.dpr*S.zoom);}}),[]);useLayoutEffect(()=>g?.connect(v),[g,v]),useLayoutEffect(()=>{!g?.current||!g.scrollTarget||!c.current||(c.current.scrollLeft=g.scrollTarget.x*d$1.current,c.current.scrollTop=g.scrollTarget.y*d$1.current,E.current=false,W.current=null,X(null),g.placedView());},[g,g?.scrollRevision]),useEffect(()=>{let u=c.current;if(!u||!g)return;let S=()=>g.schedule();S(),u.addEventListener("scroll",S,{passive:true});let $=new ResizeObserver(S);return $.observe(u),()=>{u.removeEventListener("scroll",S),$.disconnect();}},[g,A]);let L=(u,S,$,Z=false)=>{let xe=c.current,me=u.view,Xe=u.painted;if(!u.current||!me||!xe)return Promise.resolve(false);let We=S.focus,He=Xe?.frame.sheet===u.active&&Xe.frame.version===u.session.confirmedBasis.version?ra(Xe.frame.displayList,Xe.request.viewport,me,We):null;if(!He)return Z?Promise.resolve(u.selectionOptions().apply(S)):u.selectCellsAsync(u.active,S,"nearest");if($!==void 0&&!qa(xe,He,$))return Promise.resolve(false);$===void 0&&(Z?u.placeSelection(S):u.setSelection(S));let Q=d$1.current,_e=sa(He,We,me,{x:xe.scrollLeft/Q,y:xe.scrollTop/Q,width:xe.clientWidth/Q,height:xe.clientHeight/Q});return xe.scrollLeft=_e.x*Q,xe.scrollTop=_e.y*Q,u.schedule(),Promise.resolve(true)},le=useRef(A);useLayoutEffect(()=>{if(le.current===A)return;let u=le.current;if(le.current=A,!g?.current||!g.selection||b)return;let S=g.selection,$=g.navigation,Z=g.painted;if(Z&&g.view&&Z.frame.version===g.session.confirmedBasis.version?ra(Z.frame.displayList,Z.request.viewport,g.view,S.focus):null){L(g,S,u);return}let me=g.active;g.session.call.cellGeometry(me,S.focus.row,S.focus.col).then(Xe=>{let We=c.current;if(g.current&&j.current.run===g&&g.navigation===$&&d$1.current===A&&We&&qa(We,Xe.rect,u)){let He=d$1.current,Q={x:We.scrollLeft/He,y:We.scrollTop/He,width:We.clientWidth/He,height:We.clientHeight/He},_e=g.view&&sa(Xe.rect,S.focus,g.view,Q);_e&&(_e.x!==Q.x||_e.y!==Q.y)&&g.selectCellsAsync(me,S,"nearest");}}).catch(M);},[g,A]),useEffect(()=>{if(typeof window.matchMedia!="function")return;let u,S=()=>{j.current.run?.schedule(),u?.removeEventListener("change",S),u=window.matchMedia(`(resolution: ${window.devicePixelRatio||1}dppx)`),u.addEventListener("change",S);};return S(),()=>u?.removeEventListener("change",S)},[]),useEffect(()=>{let u=()=>{E.current=false;};return window.addEventListener("mouseup",u),()=>window.removeEventListener("mouseup",u)},[]);let oe=useMemo(()=>({requestSave:C,environment(){let{run:u,selectedChart:S,loading:$,t:Z}=j.current,xe=u?.selection;return {status:u?.current?"ready":$?"loading":"empty",readOnly:true,collaborative:false,canUndo:false,canRedo:false,pendingInput:false,selection:S?"chart":u&&xe?{sheet:u.active,...normalizeRange(xe),merged:u.painted?.frame.sheet===u.active?u.painted.frame.mergedRanges??[]:[],formatting:null}:null,zoom:d$1.current,paintFormat:false,borderStyle:null,borderColor:null,pngExport:false,proposals:null,proposalsPanelOpen:false,fontFamilies:s,fontSizes:t,translate:Z}},ordered:()=>false,admit:async u=>u(),perform(u,S){let{run:$,props:Z}=j.current;if(!$?.current)return {ok:false,failure:{code:"document-replaced",message:"Workbook is no longer open"}};if(u==="zoom"){let me=S.scale,Xe=d$1.current;return d$1.current=me,I$1(me),$.schedule(),{ok:true,status:me===Xe?"noop":"executed"}}if(u==="print")return $.afterPaint().then(me=>$.current?me?(window.print(),{ok:true,status:"executed"}):{ok:false,failure:{code:"render-failed",message:"Workbook was not painted"}}:{ok:false,failure:{code:"document-replaced",message:"Workbook is no longer open"}});if(u!=="save")return {ok:false,failure:{code:"read-only",message:"The editor is read-only"}};if(O.current?.run===$)return O.current.promise;let xe=$.session.save().then(me=>$.current?(Z.onSave?Z.onSave(me):yl(me,Z.fileName??"workbook.xlsx"),{ok:true,status:"executed"}):{ok:false,failure:{code:"document-replaced",message:"Workbook is no longer open"}}).catch(me=>($.current&&j.current.reportError(me),{ok:false,failure:{code:$.current?"command-failed":"document-replaced",message:String(me)}})).finally(()=>{O.current?.promise===xe&&(O.current=null);});return O.current={run:$,promise:xe},xe},capture:()=>j.current.run?{generation:j.current.run.generation,target:JSON.stringify([j.current.run.active,j.current.run.selection])}:null,resume:u=>!j.current.run?.current||u.generation!==j.current.run.generation?"document-replaced":u.target!==JSON.stringify([j.current.run.active,j.current.run.selection])?"target-changed":null,chrome:()=>({i18n:j.current.props.i18n}),focusEditor:V}),[V]);useLayoutEffect(()=>(f$1.attach(oe),()=>f$1.detach(oe)),[f$1,oe]),useLayoutEffect(()=>f$1.refresh()),P(f$1,l$1);let U=g?.painted,J=U?.frame.displayList,Oe=U?.request.zoom??A,N=g?.active??0,Ae=g?.selection??null,dt=U?.frame.sheet===N?Ae:null,Ct=g?.session.state.sheets??[],ot=n.showToolbar===false?null:n.toolbar??null;useEffect(()=>{b&&J&&!J.charts?.some(u=>u.id===b)&&X(null);},[J,b]),useEffect(()=>{if(q$1(null),!g?.current||!Ae||!ot)return;let u=false,S=g.navigation,$=Yo(Ae.focus);return g.session.call.cellInputs(N,$).then(Z=>{!u&&g.current&&g.navigation===S&&q$1(Z.cells[0]?.[0]??null);}).catch(Z=>{!u&&g.current&&g.navigation===S&&M(Z);}),()=>{u=true;}},[g,Ae,N,ot,M]);let Se={onNavigate:u=>{g&&g.selectCellsAsync(g.active,selectionAt(u)),V();},a1:x$1?.a1??"",value:x$1?.input??"",disabled:!g?.view||!Ae,readOnly:true,inputRef:null,onChange:()=>{},onCommit:()=>{},onCancel:()=>{},onBlur:()=>{},onCompositionStart:()=>{},onCompositionEnd:()=>{}},it=()=>oa(J??null,(c.current?.clientHeight??0)/Oe),Ue=u=>{if(!J||!y.current)return {cell:null,chart:null};let S=y.current.getBoundingClientRect(),$=(u.clientX-S.left)/Oe,Z=(u.clientY-S.top)/Oe;return {cell:J.grid?cellAtPoint(J.grid,$,Z):null,chart:chartRegionAtPoint(J.charts,$,Z)?.id??null}},xr=u=>{if(!g?.view||U?.frame.sheet!==N)return;let{cell:S,chart:$}=Ue(u);if(W.current=null,X($),$){V(),u.preventDefault();return}!S||!Ae||(g.setSelection(u.shiftKey?extendTo(Ae,S,it()):selectionAt(S)),W.current=S,E.current=true,V());},Be=u=>{let{cell:S,chart:$}=Ue(u);if(!S){E.current||(u.currentTarget.style.cursor="default",u.currentTarget.title="");return}if(!E.current){let Z=J?hyperlinkAtCell(J,S.row,S.col):null;u.currentTarget.style.cursor=$||Z?"pointer":"default",u.currentTarget.title=$?"":Z?.tooltip??"";return}g?.selection&&g.view&&U?.frame.sheet===N&&g.setSelection(extendTo(g.selection,S,it()));},vt=u=>{let{cell:S}=Ue(u),$=W.current;if(W.current=null,!g||!J||!S||!$||S.row!==$.row||S.col!==$.col)return;let Z=hyperlinkAtCell(J,S.row,S.col);if(!Z)return;let xe=safeExternalHyperlink(Z);if(xe){window.open(xe,"_blank","noopener,noreferrer");return}if(!Z.location)return;let me=parseHyperlinkLocation(Z.location,Ct[U.frame.sheet]?.name??"");if(!me)return;let Xe=Ct.findIndex(We=>We.name.toLowerCase()===me.sheetName.toLowerCase());Xe>=0&&g.selectCellsAsync(Xe,selectionAt(me));},ze=async()=>{if(!(!g?.current||!Ae))try{let u=await g.session.call.cellInputs(N,vl(await d(g.session,N,Ae)));g.current&&await navigator.clipboard.writeText(toTsv(u.cells));}catch{}},ft=u=>{let S=g?.selection;if(!g?.view||!S||q(u))return;if(b){u.key==="Escape"&&X(null),(u.key==="Escape"||u.key.startsWith("Arrow"))&&u.preventDefault();return}if(u.ctrlKey||u.metaKey){let me=u.key.toLowerCase();if(me==="c"||me==="x"){g.selectionNavigation.defer(g.selectionContext(),()=>{ze();})||ze(),u.preventDefault();return}if(me==="v"){u.preventDefault();return}}let $=l(u),Z=selectionKeyReducer(S,u,it()).type==="move";if($||Z){u.preventDefault();let me=g.active;g.selectionNavigation.enqueue(u,{context:()=>{if(!g.current||j.current.run!==g||g.active!==me||!g.selection||j.current.selectedChart)return null;let Xe=g.session.confirmedBasis;return {owner:g,sheet:me,selection:g.selection,navigation:g.navigation,version:`${Xe.epoch}:${Xe.version}:${g.session.state.version}`}},limits:()=>oa(g.painted?.frame.displayList??null,(c.current?.clientHeight??0)/d$1.current),hidden:()=>f(g.painted?.frame.displayList.grid),merges:g.selectionOptions().merges,known:g.selectionOptions().known,query:(Xe,We)=>g.session.call.selectionData(me,Xe.selection.focus.row,Xe.selection.focus.col,We),apply:async Xe=>{let We=g.navigation+1;return await L(g,Xe,void 0,true),g.current&&g.navigation===We&&g.active===me}});return}let xe=selectionKeyReducer(S,u,it(),void 0,f(J?.grid),h(g.painted?.frame.sheet===g.active?g.painted.frame.mergedRanges:void 0));xe.type==="move"&&L(g,xe.selection),xe.type!=="none"&&u.preventDefault();},Ce=U?.frame.mergedRanges?.slice(0,1024)??[],lt=J?.grid,yt=dt?ua$1(normalizeRange(dt),Ce):null,Mt=dt?ua$1({top:dt.focus.row,left:dt.focus.col,bottom:dt.focus.row,right:dt.focus.col},Ce):null,Pt=lt&&yt?rangeRect(lt,yt):null,kr=lt&&Mt?rangeRect(lt,Mt):null,pt=b?J?.charts?.find(u=>u.id===b)?.rect:null,Tt=J&&U?buildA11yGrid(J,dt,Ct[U.frame.sheet]?.name??"",{gridLabel:r("a11y.gridLabel"),rowHeaderLabel:r("a11y.rowHeaderLabel"),columnHeaderLabel:r("a11y.columnHeaderLabel"),cellLabel:r("a11y.cellLabel"),cellLabelSelected:r("a11y.cellLabelSelected"),emptyCellLabel:r("a11y.emptyCellLabel"),emptyCellLabelSelected:r("a11y.emptyCellLabelSelected")}):null,Rt=(u,S,$)=>{let Z=ta(u,Oe);return {position:"absolute",left:Z.x,top:Z.y,width:Z.w,height:Z.h,boxSizing:"border-box",border:S,background:$}};return jsx(I.Provider,{value:f$1.store,children:jsx(S.Provider,{value:true,children:jsx(Y.Provider,{value:Se,children:jsxs("div",{ref:l$1,className:n.className,role:"application","aria-label":r("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:[ot!=null&&jsx("div",{"data-testid":"xlsx-toolbar",style:{flex:"0 0 auto"},children:ot}),jsx("div",{"data-testid":"xlsx-workspace",style:{position:"relative",display:"flex",flex:1,minWidth:0,minHeight:0},children:jsx("div",{style:{position:"relative",display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:jsxs("div",{ref:c,"data-testid":"xlsx-scroll",tabIndex:0,onKeyDown:ft,onMouseDown:xr,onMouseMove:Be,onClick:vt,onMouseLeave:u=>{u.currentTarget.style.cursor="default",u.currentTarget.title="";},style:{position:"relative",flex:1,overflow:"auto",minHeight:0,outline:"none"},children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:g?.view?g.view.contentWidth*A:"100%",height:g?.view?g.view.contentHeight*A:"100%"}}),jsxs("div",{style:{position:"sticky",top:0,left:0,width:0,height:0},children:[jsx("canvas",{ref:y,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:[Pt&&!b&&jsx("div",{"data-testid":"xlsx-selection",style:Rt(Pt,`1px solid ${Wo}`,"rgba(33, 115, 70, 0.12)")}),kr&&!b&&jsx("div",{style:Rt(kr,`2px solid ${Wo}`)}),pt&&jsx("div",{"data-testid":"xlsx-chart-selection","data-chart-id":b,"aria-hidden":true,style:{...Rt(pt,`2px solid ${Wo}`,"transparent"),boxShadow:"0 1px 6px rgba(0, 0, 0, 0.25)"}})]})]})]})})}),Tt&&jsxs(Fragment,{children:[jsxs("div",{style:Zi,role:"grid","aria-label":Tt.label,children:[jsxs("div",{role:"row",children:[jsx("span",{role:"columnheader"}),Tt.columnHeaders.map(u=>jsx("span",{role:"columnheader",children:u.label},u.col))]}),Tt.rows.map(u=>jsxs("div",{role:"row",children:[jsx("span",{role:"rowheader",children:u.header}),u.cells.map(S=>jsx("span",{role:"gridcell","aria-selected":S.selected,children:S.label},S.col))]},u.row))]}),Tt.charts.map((u,S)=>jsx("div",{style:Zi,role:"img","aria-label":u.label},`${S}:${u.label}`))]}),F&&jsx(ya$1,{kind:"open",details:F}),Ct.length>0&&jsx("div",{"data-testid":"xlsx-sheet-tabs",role:"tablist","aria-label":r("editor.sheetTabsLabel"),style:{display:"flex",gap:2,padding:"4px 6px",borderTop:"1px solid #e0e0e0",background:"#fafafa",overflowX:"auto"},children:Ct.map((u,S)=>jsx("button",{role:"tab","aria-selected":S===N,onClick:()=>{X(null),g?.show(S);},style:{border:"none",padding:"4px 12px",cursor:"pointer",borderBottom:S===N?`2px solid ${Wo}`:"2px solid transparent",fontWeight:S===N?600:400,background:S===N?"#ffffff":"transparent"},children:u.name},u.id))})]})})})})}var kl=new Set(["zoom","searchMenus","proposalsPanel"]);function ts(n,r){let l=n.cell(r.sheet,r.top,r.left).a1,c=n.cell(r.sheet,r.bottom,r.right).a1;return `${l}:${c}`}function Cl(n,r,l,c){let y={key:c,formatting:null,merged:[],canUndo:false,canRedo:false};try{let f=ts(n,{sheet:r,...l,merged:[],formatting:null});y.formatting=n.selectionFormatting(r,f),y.merged=n.mergedRanges(r,f);}catch{}try{let f=n.historyState();y.canUndo=f.canUndo,y.canRedo=f.canRedo;}catch{}return y}function Pl(n,r,l){let c=(f,A,I,d)=>({start:{row:f,col:A},end:{row:I,col:d}}),y=[];if(l==="all")y.push({type:"mergeCells",sheet:n,range:c(r.top,r.left,r.bottom,r.right)});else if(l==="horizontal")for(let f=r.top;f<=r.bottom;f++)y.push({type:"mergeCells",sheet:n,range:c(f,r.left,f,r.right)});else if(l==="vertical")for(let f=r.left;f<=r.right;f++)y.push({type:"mergeCells",sheet:n,range:c(r.top,f,r.bottom,f)});else for(let f of r.merged)y.push({type:"unmergeCells",sheet:n,range:c(f.start.row,f.start.col,f.end.row,f.end.col)});return y}function Rl(n){let r$1=null,l=null,c=d=>{let b=n(),X=b.peer(),x=b.view();if(!X||b.status()!=="ready")return null;let q=x.selection?normalizeRange(x.selection):{top:0,left:0,bottom:0,right:0},E=[b.generation(),b.mutation(),x.sheet,q.top,q.left,q.bottom,q.right].join(":");return !d&&r$1?.key===E||(r$1=Cl(X,x.sheet,q,E)),r$1},y=d=>{let b=n(),X=b.view(),x=c(d),q=null;return X.chartSelected?q="chart":X.selection&&(q={sheet:X.sheet,...normalizeRange(X.selection),merged:x?.merged??[],formatting:x?.formatting??null}),{status:b.status(),readOnly:b.readOnly(),collaborative:b.collaborative(),selection:q,canUndo:x?.canUndo??false,canRedo:x?.canRedo??false,pendingInput:b.coordinator.draft!==null||b.coordinator.committed.length>0,zoom:X.zoom,paintFormat:X.capturedFormat!==null,borderStyle:X.borderStyle??x?.formatting?.borderStyle??null,borderColor:X.borderColor??x?.formatting?.borderColor??null,pngExport:false,proposals:X.proposalsAvailable?X.proposals.map(E=>({id:E.id,label:E.agentId})):null,proposalsPanelOpen:X.proposalsPanelOpen,fontFamilies:s,fontSizes:t,translate:b.translate}},f=(d,b,X)=>{let x=n(),q=x.peer(),E=v=>({ok:false,failure:r(v,X)});if(d==="zoom"){let v=b.scale;return X.zoom===v?{ok:true,status:"noop"}:(x.setZoom(v),{ok:true,status:"executed"})}let W=x.editPeer();if(!q||!W)return E("editor-unavailable");let V=(v=true)=>({ok:true,status:v?"executed":"noop"}),g=v=>{try{return v()}catch(L){return za(L)?x.refuse?.({message:L.message}):x.fail(L),E("command-failed")}},K=v=>g(()=>{let L=v();return l?.(),x.apply(L),V(L.applied)}),F=b,M=typeof X.selection=="object"?X.selection:null,j=()=>{if(!M)throw new Error("no cell selection");return {sheet:M.sheet,range:ts(q,M)}},O=v=>K(()=>{let{sheet:L,range:le}=j();return W.patchRangeStyle(L,le,v)}),C=M?.formatting??null;switch(d){case "bold":return O({bold:C?.bold!==true});case "italic":return O({italic:C?.italic!==true});case "strikethrough":return O({strikethrough:C?.strikethrough!==true});case "paintFormat":return X.paintFormat?(x.setCapturedFormat(null,null),V()):g(()=>{let{sheet:v,range:L}=j(),le=`${v}:${M.top}:${M.left}:${M.bottom}:${M.right}`;return x.setCapturedFormat(q.captureFormat(v,L),le),V()});case "fontFamily":return O({fontFamily:F.family});case "fontSize":return O({fontSize:F.points});case "fontSizeStep":{let v=C?.fontSize??10,L=X.fontSizes,le=F.direction==="increase"?L.find(oe=>oe>v)??v+1:[...L].reverse().find(oe=>oe<v)??Math.max(1,v-1);return O({fontSize:le})}case "textColor":return O({textColor:F.color});case "fillColor":return O({fillColor:F.color});case "numberFormat":return K(()=>{let{sheet:v,range:L}=j();return F.value==="custom"?W.setNumberFormat(v,L,{type:"custom",pattern:C?.numberFormatPattern??"0.00"}):W.setNumberFormat(v,L,F.value)});case "decimalPlaces":return K(()=>{let{sheet:v,range:L}=j();return W.setNumberFormat(v,L,F.direction==="increase"?"increaseDecimal":"decreaseDecimal")});case "borderPreset":return O({border:{preset:F.value,style:X.borderStyle??"solid",color:X.borderColor??"#000000"}});case "borderStyle":return x.setBorderStyle(F.value),O({border:{style:F.value}});case "borderColor":return x.setBorderColor(F.color),O({border:{color:F.color}});case "horizontalAlignment":return O({horizontalAlignment:F.value});case "verticalAlignment":return O({verticalAlignment:F.value});case "textWrapping":return O({textWrapping:F.value});case "merge":{if(!M)return E("cell-selection-required");let v=Pl(M.sheet,M,F.value);return v.length===0?V(false):K(()=>W.applyOps(v))}case "undo":return K(()=>W.undo());case "redo":return K(()=>W.redo());case "save":{let v=x.generation();return l?.(),W.save().then(L=>n().generation()!==v?E("document-replaced"):(x.deliver(new Uint8Array(L)),V())).catch(L=>n().generation()!==v?E("document-replaced"):(x.fail(L),E("command-failed")))}case "exportPng":return E("png-unavailable");case "print":{let v=x.generation();return x.afterPaint().then(L=>n().generation()!==v?E("document-replaced"):L?(window.print(),V()):E("render-failed"))}case "proposalsPanel":{let v=b===null?!X.proposalsPanelOpen:F.open;return v===X.proposalsPanelOpen?V(false):(x.setProposalsPanelOpen(v),V())}case "proposalAccept":try{let v=W.acceptProposal(F.proposalId,{force:F.force});return l?.(),x.apply(v),x.markStale(F.proposalId,null),x.refreshProposals(),V()}catch(v){return v instanceof StaleProposalError?(l?.(),x.markStale(F.proposalId,v.cells),x.refreshProposals(),E("proposal-stale")):(x.fail(v),E("command-failed"))}case "proposalReject":return g(()=>{let v=W.rejectProposal(F.proposalId);return l?.(),x.markStale(F.proposalId,null),x.refreshProposals(),v?V():E("proposal-not-found")});default:return E("unsupported-command")}},A=d=>{if(!v(d))return "document";let b=n().view();return b.chartSelected?"chart":b.selection?`${b.sheet}:${JSON.stringify(normalizeRange(b.selection))}`:"none"};return {requestSave:d=>n().requestSave?.(d)??d(),environment:y,ordered:d=>{let b=n();return d==="save"&&b.coordinator.requestHydration("save").catch(()=>{}),!kl.has(d)||b.coordinator.rejected.some(X=>X.generation===b.generation())},refuse:d=>n().refuse?.(d),admit:(d,b)=>{let X=n().readOnly();return n().coordinator.runAfterPendingInput(async(x,q)=>{let E=n(),W=E.generation();if(await E.preview(),q.check(),n().generation()!==W)throw new w("document-replaced");if(E.coordinator.error)throw E.coordinator.error;l=q;try{let V=await d(X);if(V!==null&&typeof V=="object"&&"ok"in V&&V.ok===!1){let g="failure"in V?V.failure:{message:"Command was refused"};q.refuse(new z(g.message),b!==void 0&&o[b].mutatesDocument);}return V}finally{l=null;}},{recover:b===void 0||o[b].mutatesDocument,barrier:b==="save"})},perform:f,capture(d){let b=n();return b.status()==="empty"?null:{generation:b.generation(),target:A(d)}},resume(d,b){return n().generation()!==d.generation?"document-replaced":A(b)===d.target?null:"target-changed"},chrome:()=>({i18n:n().i18n()}),focusEditor:()=>n().focusGrid()}}function rs(n,r){let l=useRef(r);l.current=r,useLayoutEffect(()=>{let c=Rl(()=>l.current);return n.attach(c),()=>n.detach(c)},[n]),useLayoutEffect(()=>n.refresh());}var Jo=new WeakMap;function Wl(n,r){let l=Jo.get(n),c=l?{Component:l}:{loading:true},[y,f]=useState(()=>({load:n,chunk:c})),A=useRef(null);return useEffect(()=>{if(l)return;let I=true;if(!A.current||A.current.load!==n){let b;try{b=n();}catch(X){b=Promise.reject(X);}A.current={load:n,promise:b};}let d=A.current;return d.promise.then(b=>{!I||A.current!==d||(Jo.set(n,b.XlsxPeerlessWorkerEditor),f({load:n,chunk:{Component:b.XlsxPeerlessWorkerEditor}}));}).catch(b=>{!I||A.current!==d||(Jo.delete(n),f({load:n,chunk:{error:new r(b)}}));}),()=>{I=false;}},[n,r]),l?{Component:l}:y.load===n?y.chunk:{loading:true}}function ns({load:n,ErrorType:r,editorProps:l}){let c=Wl(n,r);if("error"in c)throw c.error;return "Component"in c?jsx(c.Component,{...l}):l.file?l.loadingIndicator??null:null}var Al={request:n=>requestAnimationFrame(n),cancel:n=>cancelAnimationFrame(n)};function os(n){return {...n,viewport:{...n.viewport}}}function is(n,r){return n.x===r.x&&n.y===r.y&&n.width===r.width&&n.height===r.height}function Zo(n,r){return n!==null&&n.generation===r.generation&&n.sheet===r.sheet&&n.navigation===r.navigation&&n.width===r.width&&n.height===r.height&&n.zoom===r.zoom&&n.dpr===r.dpr&&is(n.viewport,r.viewport)}var To=class{constructor(r){a(this,"options",r);a(this,"scheduler");a(this,"disposed",false);a(this,"failed",false);a(this,"raf",null);a(this,"revision",0);a(this,"pending",null);a(this,"running",false);a(this,"lastPaint",null);this.scheduler=r.scheduler??Al;}get painted(){return this.lastPaint}schedule(){!this.current||this.failed||(this.revision+=1,this.raf===null&&(this.raf=this.scheduler.request(()=>{if(this.raf=null,!this.current||this.failed)return;let r=this.capture();r&&(this.pending={request:r,revision:this.revision,sequence:this.options.sentSequence()},this.drain().catch(l=>this.fail(l)));})));}fail(r){if(!(!this.current||this.failed)){this.failed=true,this.cancelFrame();try{this.options.onError(r);}catch{}}}dispose(){this.disposed||(this.disposed=true,this.cancelFrame());}get current(){return !this.disposed&&(this.options.isCurrent?.()??true)}capture(){if(!this.current)return null;let r=this.options.capture();return r?.generation===this.options.generation?os(r):null}matches(r){return r.revision===this.revision&&Zo(this.capture(),r.request)}cancelFrame(){this.raf!==null&&this.scheduler.cancel(this.raf),this.raf=null,this.pending=null;}retry(r){let l=this.capture();!l||Zo(l,r.request)&&this.options.sentSequence()===r.sequence||!this.pending&&this.raf===null&&this.schedule();}publish(r,l,c,y){let f={...c,source:r,request:l,sequence:y,geometry:c.displayList.grid},A=this.lastPaint;this.lastPaint=f;try{this.options.publish(f);}catch(I){throw this.lastPaint===f&&(this.lastPaint=A),I}return f}async drain(){if(!(this.running||!this.current||this.failed)){this.running=true;try{for(;this.current&&!this.failed&&this.pending;){let r=this.pending;if(this.pending=null,!this.matches(r)){this.retry(r);continue}let{request:l}=r,c;try{c=await this.options.requestFrame(os(l));}catch(y){if(!this.current||this.failed)break;!Zo(this.capture(),l)||y instanceof Error&&y.name==="SessionSuperseded"?this.retry(r):this.fail(y);continue}if(!this.current||this.failed)break;if(!this.matches(r)||c.sheet!==l.sheet||!is(c.viewport,l.viewport)||!(c.sequence>=this.options.sentSequence())){this.retry(r);continue}try{this.publish("worker",l,{displayList:c.displayList,mergedRanges:c.mergedRanges??[],version:c.version},c.sequence);}catch(y){this.fail(y);}}}finally{this.running=false;}}}};var Yn="#217346",$l="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ds={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},Vl={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};function yn(n){let r="";for(let l=n.col+1;l>0;l=Math.floor((l-1)/26))r=String.fromCharCode(65+(l-1)%26)+r;return `${r}${n.row+1}`}function ps(n){return `${yn({row:n.top,col:n.left})}:${yn({row:n.bottom,col:n.right})}`}function Ul(n){return ps(normalizeRange(n))}function jn(n){return N(n.nativeEvent)!==null||O(n.target)}function yr(n){let[r,l]=useState(n),c=useRef(r),y=useCallback(f=>{c.current=typeof f=="function"?f(c.current):f,l(c.current);},[]);return [r,y,c]}function ni(n,r,l){if(!n||!r||n.sequence<l)return false;let c=n.request;return c.generation===r.generation&&c.sheet===r.sheet&&c.navigation===r.navigation&&c.zoom===r.zoom&&c.dpr===r.dpr&&c.width===r.width&&c.height===r.height&&JSON.stringify(c.viewport)===JSON.stringify(r.viewport)}function fs(n,r,l,c,y,f){return l?null:f==="start"?n:f==="center"?Math.max(0,n-Math.max(0,y-r)/2):n>=c&&n+r<=c+y?null:n<c||r>=y?n:Math.max(0,n+r-y)}var _l={load:()=>import('./chunk-2S2QUCJE.js')},Kl=()=>globalThis.location?.reload(),Zn=class extends Error{constructor(l){super("Failed to load the editor code. Reload the page to retry.");a(this,"cause",l);a(this,"code","chunk-load-failed");this.name="XlsxWorkerEditorChunkLoadError";}};function Gl({error:n,className:r,style:l}){let c=n instanceof Zn;return jsx(ya$1,{kind:c?"load":"open",details:n.message,onReload:c?Kl:void 0,className:r,style:{position:"relative",width:"100%",height:"100%",...l}})}var oi=class extends Component{constructor(){super(...arguments);a(this,"state",{error:null});a(this,"reported",null);}static getDerivedStateFromError(l){return {error:Ra$1(l)}}componentDidCatch(){let l=this.state.error;if(!(!l||this.reported===l)){this.reported=l;try{this.props.onError?.(l);}catch{}}}render(){return this.state.error?jsx(Gl,{error:this.state.error,className:this.props.className,style:this.props.style}):this.props.children}};function ii(n){return useRef(n.backend??"legacy").current==="peerless"?jsx(G,{i18n:n.i18n,children:jsx(oi,{onError:n.onError,className:n.className,style:n.style,children:jsx(ns,{load:_l.load,ErrorType:Zn,editorProps:n})})}):jsx(Yl,{...n})}function Yl(n$1){let{t:r}=H(),l$1=useRef(null),c$1=useRef(null),y=useRef(null),f$1=useRef(null),A=useRef(null),I$1=useRef(null),d=useRef(null),b$1=useRef(n$1);b$1.current=n$1;let[X]=useState(x),[x$1,q$1,E]=yr(0),[W,V,g$1]=yr(null),[K,F,M]=yr(null),j$1=useRef(()=>{}),O=useCallback(e=>{let o=typeof e=="function"?e(M.current):e;o&&!d.current?.peer&&(o.anchor.row||o.anchor.col||o.focus.row||o.focus.col)?j$1.current(o):F(o?k(o,j(d.current?.peer,E.current)):null);},[]),[C,v,L]=yr(1),[le,oe,U]=yr(null),[J,Oe]=useState(null),[N,Ae]=useState(null),dt=useRef(null),[Ct,ot]=useState(null),[Se,it]=useState(null),[Ue,xr]=useState(null),[Be,vt,ze]=yr(null),[ft,Ce]=useState(null),[lt,yt,Mt]=yr(null),Pt=useRef(null),kr=useRef(void 0),pt=useRef(void 0),[Tt,Rt,u]=yr([]),[S$1,$,Z]=yr(false),[xe,me]=useState({}),Xe=useRef(0),We=useRef(0),[He]=useState(n),Q$1=useRef(null),_e=useRef(false),Ze=useRef(null),ee=useRef(null),Ke=useRef(null),Ne=useRef(null),Et=useRef(()=>{}),Re=useRef(false),Cr=useRef(false),Te=useRef(null),Qe=useRef([]),xn=useRef(null),te=useRef(0),ro=useRef(0),Ie=useCallback(()=>c$1.current?.focus({preventScroll:true}),[]),pe=useCallback(e=>{let o=za(e);if(o||e instanceof w){ot((o??e).message);return}ot(e instanceof Error?e.message:String(e));},[]),$e=()=>!!(d.current?.current&&!d.current.retiring&&!d.current.failure&&!b$1.current.readOnly),At=useRef(null),[kn]=useState(()=>({getPositionAtPoint:(e,o)=>At.current?.getPositionAtPoint?.(e,o)??null,coordinator:()=>xn.current,readOnly:()=>b$1.current.readOnly??false,clearSelection:()=>At.current?.clearSelection(),focus:Ie,refreshProposals:()=>At.current?.refreshProposals(),recoverInput:()=>At.current.recoverInput(),selectCells:(...e)=>At.current?.selectCells(...e)??false,selectCellsAsync:(...e)=>At.current?.selectCellsAsync(...e)??Promise.resolve(false),apply:(e,o)=>At.current?.apply(e,o),previewEdits:(e,o,i)=>At.current?.previewEdits?.(e,o,i)??Promise.resolve(),canNavigateSync:()=>At.current?.canNavigateSync?.()??false})),{run:p,error:Ot,loading:re}=Ta(n$1,X.store,kn);d.current=p;let bt=useMemo(()=>({current:null}),[p]),Ge=useMemo(()=>new Map,[p]),St=useMemo(()=>new WeakMap,[p]),at=useMemo(()=>new Map,[p]),Fr=useMemo(()=>new WeakMap,[p]),lr=useMemo(()=>({current:p?.editPeer??null}),[p]);p?.editPeer&&!p.recovering&&(lr.current=p.editPeer);let ke=useMemo(()=>new Map,[p]),wt=useMemo(()=>new WeakSet,[p]),ye=useMemo(()=>[],[p]),st=useMemo(()=>new WeakMap,[p]),qe=useMemo(()=>new Set,[p]),ue=useMemo(()=>({revision:0,sequence:1/0,request:null,committed:null}),[p]),Zt=useMemo(()=>{let e=new Set;return {resolve(){for(let o of e)o();e.clear();},wait(o){return new Promise((i,a)=>{let h=()=>{e.delete(h),i();};e.add(h),o.then(h,w=>{e.delete(h),a(w);});})}}},[p]),_=useMemo(()=>{let e=p,o=Aa({generation:()=>e?.generation??0,capture:()=>({sheet:E.current,target:JSON.stringify(M.current)}),isReady:()=>e?.ready??false,isAcknowledged:()=>!e?.editPeer||e.editPeer.acknowledgedSequence>=e.editPeer.sentSequence,whenReady:()=>e?.whenHydrated()??Promise.reject(new w("editor-unavailable")),requestHydration:i=>e?.requestHydration(i),flushEdits:()=>e?.editPeer?.flush()??Promise.reject(new w("editor-unavailable")),async acknowledgeEdits(){!e?.editPeer||e.recovering||e.retiring||(await Zt.wait(workbookEditPeerOperations(e.editPeer).whenAcknowledged()),e.retiring||await bt.current?.acknowledgeEdits?.());},preview:i=>bt.current.preview(i),resolveDraft:i=>bt.current.resolveDraft(i),sameDraft:(i,a)=>i.draftId===a.draftId,seal:()=>bt.current?.seal()??{},sync:()=>bt.current?.sync(),write:(i,a)=>bt.current?.write(i,a)??false,onError:i=>e?.fail(i),onRefusal(i,a){if(e?.retiring){e.reportRefusal(i);return}let h=i instanceof Error?i.message:String(i);e?.recovering?flushSync(()=>ot(h)):ot(h),bt.current?.sync?.();let w=a?.revision??0;a&&!b$1.current.readOnly&&w>ro.current&&w===te.current&&(o.setDraft(a),a.source==="cell"?oe(a):Oe(a.value));}});return o},[p,bt,pe,Zt]);xn.current=_;let ar=useCallback(()=>{let e=d.current,o=c$1.current,i=L.current;return !e?.current||!g$1.current||!o||!y.current||!o.clientWidth||!o.clientHeight?null:{generation:e.generation,sheet:E.current,navigation:We.current,zoom:i,dpr:window.devicePixelRatio||1,width:o.clientWidth,height:o.clientHeight,viewport:{x:o.scrollLeft/i,y:o.scrollTop/i,width:o.clientWidth/i,height:o.clientHeight/i}}},[]),It=useCallback(()=>p?.current?p.failure&&!p.recovering?Promise.reject(p.failure):Promise.resolve():Promise.reject(new w("document-replaced")),[p]),Ht=useCallback((e,o,i)=>{for(let h of at.values()){let w=h.get(e);w?.operation===o&&(w.operation=i?.operation,w.input=i?.input,w.index=i?.index??-1);}let a=at.get(o);a?.delete(e),a?.size||at.delete(o);},[at]),Le=useCallback(async(e,o=true)=>{if(!(!p||p.failure||p.recovering||p.retiring)){if(e){let i=`${e.sheet}:${e.row}:${e.col}`,a=ke.get(i),h=ue.committed,w=Ge.get(i)??(h&&`${h.sheet}:${h.row}:${h.col}`===i?h.value:void 0);Ge.set(i,e.value);let P=St.get(e)??{method:"editCell",args:[e.sheet,e.row,e.col,e.value],calculation:{nowSerial:localNowSerial(Date.now()),randSeed:globalThis.crypto.getRandomValues(new Uint32Array(1))[0]>>>0}};if(St.set(e,P),a!==P){let H=at.get(P);H||at.set(P,H=new Map),H.set(i,{operation:a,input:w,index:a?ye.indexOf(a):-1});}if(e.unchanged&&wt.add(P),a&&a!==P&&wt.has(a)){let H=ye.indexOf(a);H>=0&&ye.splice(H,1);}ke.set(i,P),ye.includes(P)||ye.push(P),ue.sequence=1/0;let B=++ue.revision,z=()=>{let H=at.get(P)?.get(i),G=ye.indexOf(P);G>=0&&ye.splice(G,1),Ht(i,P,H);let se=ke.get(i)===P;if(se&&(H?.operation?(ke.set(i,H.operation),ye.includes(H.operation)||ye.splice(Math.max(0,H.index),0,H.operation)):ke.delete(i),H?.operation&&H.input!==void 0?Ge.set(i,H.input):Ge.delete(i)),!ke.size&&(se&&!qe.size||B===ue.revision)&&!p.retiring)it(ue.committed),ue.request=null;else if(se&&!p.retiring){let ge=[...ke.keys()].reverse()[0];if(ge){let[Je,De,et]=ge.split(":").map(Number);it({...e,sheet:Je,row:De,col:et,value:Ge.get(ge)??""});}}let be=!qe.size&&ye.every(ge=>st.has(ge));ue.sequence=be?Math.max(0,...ye.map(ge=>st.get(ge))):1/0,be&&Q$1.current?.schedule();};if(o&&Fr.set(e,z),p.ready){qe.size||flushSync(()=>it(e));return}let T=ar();if(qe.size){await It();return}if(T){let H=workbookSessionInternals.get(p.session);if(!H?.preview)throw new Error("Worker cell preview is unavailable");let G;try{G=await H.preview(T.viewport,T.sheet,ye.filter(ge=>!st.has(ge)));}catch(ge){throw o&&z(),ge}if(p.retiring||p.recovering||p.failure||!p.current||B!==ue.revision||(ue.request=T,ue.sequence=ye.every(ge=>st.has(ge))?p.editPeer?.sentSequence??1/0:1/0,qe.size)||(flushSync(()=>it(e)),p.ready))return;let se=dt.current,be=se?.getContext("2d");if(!se||!be)throw new Error("Preview canvas context is unavailable");se.width=Math.round(T.width*T.dpr),se.height=Math.round(T.height*T.dpr),se.style.width=`${T.width}px`,se.style.height=`${T.height}px`,paintDisplayList(be,G.displayList,T.dpr*T.zoom),se.dataset.previewReady="true";}}await It();}},[p,ar,It,Ge,ke,ue,St,Fr,at,Ht,st,qe,ye,wt]),qr=useCallback(async(e,o,i)=>{if(i?.method==="applyEdits"&&i.args[0].steps.some(P=>P.op!=="setCellInputs"))return qe.add(i),ue.revision+=1,ue.request=null,it(null),async()=>{qe.delete(i);};i&&(i.calculation??(i.calculation={nowSerial:localNowSerial(Date.now()),randSeed:globalThis.crypto.getRandomValues(new Uint32Array(1))[0]>>>0}));let a=new Map,h=new Map;for(let P of o)if(!Number.isInteger(e)||e<0||e>=(p?.session.state.sheets.length??0)||!Number.isInteger(P.row)||P.row<0||P.row>1048575||!Number.isInteger(P.col)||P.col<0||P.col>16383||!P.input.startsWith("=")&&[...P.input.replace(/^'/,"")].length>32767)throw new z("Invalid cell input or target");for(let P of o){let B=`${e}:${P.row}:${P.col}`,z=i??{method:"editCell",args:[e,P.row,P.col,P.input]},T=ke.get(B),H=at.get(z);H||at.set(z,H=new Map);let G=a.get(B)??(T===z?H.get(B):void 0)??{operation:T,input:Ge.get(B)??(ue.committed&&`${ue.committed.sheet}:${ue.committed.row}:${ue.committed.col}`===B?ue.committed.value:void 0),index:T?ye.indexOf(T):-1};if(a.set(B,G),H.set(B,G),Ge.set(B,P.input),T&&T!==z&&wt.has(T)){let se=ye.indexOf(T);se>=0&&ye.splice(se,1);}ke.set(B,z),h.set(B,z),ye.includes(z)||ye.push(z);}let w=async()=>{let P=false;for(let z of o){let T=`${e}:${z.row}:${z.col}`,H=h.get(T),G=a.get(T),se=G?.operation,be=G?.input;H&&Ht(T,H,G),ke.get(T)===H&&(se?(ke.set(T,se),ye.includes(se)||ye.splice(Math.max(0,G.index),0,se)):ke.delete(T),se&&be!==void 0?Ge.set(T,be):Ge.delete(T),P=true);}for(let z of new Set(h.values())){let T=ye.indexOf(z);T>=0&&ye.splice(T,1);}if(!P||!p||p.retiring||p.failure)return;let B=[...ke.entries()].reverse()[0];if(B){let[z,T,H]=B[0].split(":").map(Number),G={generation:p.generation,sheet:z,row:T,col:H,value:Ge.get(B[0])??"",source:"cell"};St.set(G,B[1]),await Le(G),ye.every(se=>st.has(se))&&(ue.sequence=p.editPeer?.sentSequence??1/0,Q$1.current?.schedule());}else ue.revision+=1,ue.request=null,ue.sequence=p.editPeer?.sentSequence??1/0,it(ue.committed);};try{let P=o[0]?{generation:p.generation,sheet:e,row:o[0].row,col:o[0].col,value:o[0].input,source:"cell"}:void 0;P&&St.set(P,h.get(`${e}:${P.row}:${P.col}`)),await(P?Le(P,!1):Promise.resolve());}catch(P){throw await w(),P}return w},[p,Le,Ht,Ge,ke,at,ue,St,st,qe,ye,wt]),Pr=useCallback(()=>{let e=d.current;if(!e?.peer){Rt([]);return}Rt(e.peer.listProposals()),e.recovering||Q$1.current?.schedule(),X.refresh();},[X]),Rr=useCallback(()=>{p?.retiring||p?.recovering||Q$1.current?.schedule();},[p]),Lt=useCallback(e=>{e&&(st.set(e,p?.editPeer?.sentSequence??0),qe.delete(e));let o=!qe.size&&ye.every(i=>st.has(i));ue.sequence=o?Math.max(0,...ye.map(i=>st.get(i))):1/0,!p?.recovering&&!p?.retiring&&Q$1.current?.schedule();},[p,ue,st,qe,ye]),Do=e=>{let o=_.draft;if(!(o&&(o.source!==e.source||o.sheet!==e.sheet||o.row!==e.row||o.col!==e.col||o.revision!==e.revision||o.value!==e.value&&o.modified!==false)))if(o&&_.setDraft(null),e.source==="cell"){let i=U.current;i&&i.sheet===e.sheet&&i.row===e.row&&i.col===e.col&&i.revision===e.revision&&(i.value===e.value||i.modified===false)&&(Re.current=true,oe(null));}else Oe(null);},Ye=useCallback((e,o)=>{let i=p;if(!(!i?.peer||i.retiring))try{!o&&ue.request&&(!("ok"in e)||e.ok)&&e.applied&&(ue.revision+=1,ue.request=null,it(null)),Lt(o),Xe.current+=1;let a=i.peer.sheetInfo();g$1.current&&a.activeSheet===E.current&&V({...g$1.current,...a,sheet:a.activeSheet,version:i.peer.version()}),Rr(),Pr(),(!("ok"in e)||e.ok)&&e.applied&&b$1.current.onChange?.(),X.refresh();}catch(a){i.fail(a);}},[p,X,Rr,Pr,Lt,ue]),Fo=useCallback(()=>{let e=d.current,o=ar(),i=Q$1.current;if(!e?.current||e.failure||!o||!i)return Promise.resolve(false);let a=e.editPeer?.sentSequence??0;return ni(i.painted,o,a)?Promise.resolve(true):(i.schedule(),new Promise(h=>{let w={request:o,sequence:a,resolve(B){clearTimeout(P),h(B);}},P=setTimeout(()=>{Qe.current=Qe.current.filter(B=>B!==w),h(false);},1e3);Qe.current.push(w);}))},[ar]),_t=useCallback((e,o)=>{let i=p;if(!i?.peer||!i.current||i.retiring)return false;let a=i.peer.sheetInfo();if(a.activeSheet!==e)return false;We.current+=1,q$1(e),V({...g$1.current,...a,sheet:e,version:i.peer.version(),frozenWidth:0,frozenHeight:0}),O(o?structuredClone(o):null),vt(null),yt(null),Pt.current=null,_.draft||(oe(null),Oe(null));let h=c$1.current;if(h&&o){let w=i.peer.cellPosition(e,o.focus.row,o.focus.col);h.scrollLeft=w.x*L.current,h.scrollTop=w.y*L.current;}return i.recovering||(Rr(),Q$1.current?.schedule()),X.refresh(),true},[X,_,Rr]),qo=useCallback(async()=>{let e=d.current;if(!e?.current||!e.peer||!e.editPeer)throw new w("editor-unavailable");let o=e.editPeer;lr.current=o;let i;try{i=createWorkbookRecoveryMutators(o);}catch(a){throw a instanceof WorkbookEditPeerFailedError?a:new WorkbookEditPeerFailedError(a instanceof Error?a:new Error(String(a)))}e.recovering=true,e.editPeer=new Proxy(o,{get(a,h){return h in i?Reflect.get(i,h):h==="flush"||h==="save"?()=>Promise.reject(e.failure??new Error("Worker is unavailable")):Reflect.get(a,h)}});try{Et.current(!0),_.draft&&_.submit(_.draft),await _.recover();}catch(a){throw a instanceof w||a instanceof WorkbookEditPeerFailedError?a:new WorkbookEditPeerFailedError(a instanceof Error?a:new Error(String(a)))}finally{e.editPeer=o,e.recovering=false,_.fail(e.failure??o.error??new Error("Worker is unavailable"));}},[_]);At.current={getPositionAtPoint:(e,o)=>{let i=Q$1.current?.painted;return !i||i.request.generation!==d.current?.generation?null:na(i.displayList,i.request.sheet,y.current,e,o)},coordinator:()=>_,readOnly:()=>b$1.current.readOnly??false,focus:Ie,clearSelection:()=>{_.settle(),oe(null),Oe(null),O(null),vt(null),yt(null),X.refresh();},refreshProposals:Pr,recoverInput:qo,selectCells:_t,previewEdits:qr,canNavigateSync:()=>ue.request===null,selectCellsAsync:async(e,o)=>_t(e,o),apply:Ye};let Kt=useRef(null),[Cn]=useState(()=>({handle:()=>d.current?.ready&&!d.current.failure?d.current.peer:null,admit:(e,o)=>Kt.current.admit(e,o),readOnlyRefusal:e=>Kt.current.readOnlyRefusal(e),applyEdits:(...e)=>Kt.current.applyEdits(...e),admitEdits:(...e)=>Kt.current.admitEdits(...e),commands:()=>X,navigator:{selectCells:(...e)=>Kt.current.navigator.selectCells(...e),scrollToCell:(...e)=>Kt.current.navigator.scrollToCell(...e)}})),Mo=useMemo(()=>{let e=p?.session.state.sheets[x$1]?.id;return e===void 0?null:{sheetId:e,sheetIndex:x$1,cells:K,chartId:Be?.id??null}},[p,x$1,K,Be]),xt=Na({...n$1,access:Cn,commands:X,readOnly:n$1.readOnly??false,handle:p?.ready&&!p.failure?p.peer:null,selection:Mo,canvasRef:y,t:r}),Jr=useRef(xt.presentGrid);Jr.current=xt.presentGrid;let[no,oo]=Fa(xt.managed),Er=useCallback(()=>{for(let e of Qe.current.splice(0))e.resolve(false);},[]);useLayoutEffect(()=>{if(ot(null),xr(null),it(null),O(null),V(null),oe(null),Oe(null),vt(null),Ce(null),Ae(null),I$1.current=null,yt(null),Rt([]),me({}),$(false),Xe.current=0,We.current+=1,_e.current=false,ee.current=null,Ke.current=null,Ne.current!==null&&clearTimeout(Ne.current),Ne.current=null,Te.current?.settle(false),Te.current=null,xt.beginLoad(),!p)return;let e=new To({generation:p.generation,capture:ar,isCurrent:()=>p.current&&!p.failure,requestFrame:i=>p.session.call.frame(i.viewport,{sheet:i.sheet}),sentSequence:()=>p.editPeer?.sentSequence??0,publish(i){let a=y.current,h=a?.getContext("2d");if(!a||!h)throw new Error("Canvas context is unavailable");let w=i.request;a.width=Math.round(w.width*w.dpr),a.height=Math.round(w.height*w.dpr),a.style.width=`${w.width}px`,a.style.height=`${w.height}px`,paintDisplayList(h,i.displayList,w.dpr*w.zoom),a.dataset.workerSequence=String(i.sequence),a.dataset.paintSource=i.source,a.dataset.workerZoom=String(w.zoom),xr(i),i.sequence>=ue.sequence&&(ke.clear(),ye.length=0,at.clear(),Ge.clear(),ue.request=null,ue.committed=null,flushSync(()=>it(null)));let P=p.session.state.sheets[w.sheet]?.id;Jr.current(P===void 0?null:{frame:i.displayList,zoom:w.zoom,viewport:w.viewport,version:i.version,sheetId:P});for(let B of Qe.current.slice()){let z=ni(i,B.request,B.sequence);(z||!ni(i,B.request,0))&&(Qe.current=Qe.current.filter(T=>T!==B),B.resolve(z));}p.firstPaint();},onError:i=>p.fail(i)});Q$1.current=e;let o=p.session.state.activeSheet;return q$1(o),p.session.call.sheetView(o).then(i=>{!p.current||p.failure||Q$1.current!==e||(V(i),O(selectionAt({row:0,col:0})),c$1.current&&(c$1.current.scrollLeft=i.initialScrollX*L.current,c$1.current.scrollTop=i.initialScrollY*L.current),e.schedule());}).catch(i=>p.fail(i)),()=>{e.dispose(),Q$1.current===e&&(Q$1.current=null),Er(),Jr.current(null);}},[p,ar,Er]),useEffect(()=>{let e=c$1.current;if(!e||!p)return;let o=()=>Q$1.current?.schedule();e.addEventListener("scroll",o,{passive:true});let i=new ResizeObserver(o);return i.observe(e),o(),()=>{e.removeEventListener("scroll",o),i.disconnect();}},[p,C]),useEffect(()=>{if(typeof window.matchMedia!="function")return;let e,o=()=>{Q$1.current?.schedule(),e?.removeEventListener("change",o),e=window.matchMedia(`(resolution: ${window.devicePixelRatio||1}dppx)`),e.addEventListener("change",o);};return o(),()=>e?.removeEventListener("change",o)},[]),useEffect(()=>{p?.failure&&(Q$1.current?.dispose(),Er(),ee.current=null,Et.current(true),Xt(),Te.current?.settle(true),Te.current=null);},[p,p?.failure,Er]),useEffect(()=>()=>{Er(),Ne.current!==null&&clearTimeout(Ne.current),Te.current?.settle(false),Te.current=null;},[Er]),useEffect(()=>{if(Ae(null),!p?.current||p.failure||!K||Be)return;if(p.ready&&p.peer){Ae(p.peer.cell(x$1,K.focus.row,K.focus.col));return}let e=false,o=We.current;return p.session.call.cellInputs(x$1,yn(K.focus)).then(i=>{!e&&p.current&&We.current===o&&Ae(i.cells[0]?.[0]??null);}).catch(i=>{!e&&p.current&&p.fail(i);}),()=>{e=true;}},[p,p?.peer,K,x$1,Be,Ue]);let Sr=()=>{let e=d.current;if(!e?.current||e.retiring||e.failure||!M.current)return null;let o=e.session.confirmedBasis;return {owner:e,sheet:E.current,selection:M.current,navigation:We.current,version:`${o.epoch}:${o.version}:${e.peer?.version()??o.version}:${e.session.state.version}`}},he=e=>He.defer(Sr(),e),Pe=()=>f(Q$1.current?.painted?.displayList.grid),mt=()=>{let e=Q$1.current?.painted,o=d.current,i=Sr(),a=h(e?.request.sheet===E.current&&e.version===o?.session.confirmedBasis.version?e.mergedRanges:void 0);return j(o?.peer,E.current,i?He.merges(i,a):a)},Bt=()=>({context:Sr,limits:ht,hidden:Pe,merges:mt,known:(e,o)=>{let i=d.current,a=Q$1.current?.painted;return !!(i?.peer||He.known(e,o)||a?.request.sheet===e.sheet&&a.version===i?.session.confirmedBasis.version&&g(a.displayList.grid,o))},query:(e,o)=>(d.current.peer??d.current.session.call).selectionData(e.sheet,e.selection.focus.row,e.selection.focus.col,o),apply:e=>(F(e),Hr(E.current,e),true)});j$1.current=e=>{He.select(e,{...Bt(),apply:o=>(F(o),true)});};let ct=e=>d.current?.peer?he(e):He.beforeInput({...Bt(),apply:o=>(F(o),true)},e,()=>pe(new w("editor-unavailable"))),ht=()=>oa(Q$1.current?.painted?.displayList??null,(c$1.current?.clientHeight??0)/L.current),Zr=(e,o,i)=>({generation:d.current.generation,sheet:E.current,...o,source:e,value:i,revision:++te.current,draftId:te.current}),Xt=()=>{let e=_.draft,o=e?.source==="cell"?f$1.current:A.current;if(e&&o&&e.value!==o.value){let i={...e,value:o.value,prefill:false,modified:true,revision:++te.current};_.setDraft(i),i.source==="cell"?oe(i):Oe(i.value);}},Pn=()=>{if(ee.current)return {refused:"gesture-active"};Et.current();let e=Te.current;return e?(e.source==="cell"?(Re.current=true,f$1.current?.blur(),Re.current=false):(Cr.current=true,A.current?.blur(),Cr.current=false),{composition:e.done}):{}};bt.current={generation:()=>p?.generation??0,capture:()=>({sheet:x$1,target:JSON.stringify(K)}),isReady:()=>p?.ready??false,whenReady:()=>p.whenHydrated(),requestHydration:e=>p.requestHydration(e),flushEdits:()=>p.editPeer.flush(),preview:Le,seal:Pn,sync:Xt,async acknowledgeEdits(){if(!(!p?.peer||!p.editPeer)){for(let e of ye.slice()){let o=st.get(e);if(o===void 0||o>p.editPeer.acknowledgedSequence)continue;let i=[...at.get(e)?.keys()??[]];if(i[0]){let[a,h,w]=i[0].split(":").map(Number);ue.committed={generation:p.generation,sheet:a,row:h,col:w,value:p.peer.cell(a,h,w).input,source:"cell"};}for(let a of i){let[h,w,P]=a.split(":").map(Number);Ht(a,e,{input:p.peer.cell(h,w,P).input,index:-1}),ke.get(a)===e&&(ke.delete(a),Ge.delete(a));}ye.splice(ye.indexOf(e),1),st.delete(e),Se&&St.get(Se)===e&&(St.delete(Se),Fr.delete(Se));}!qe.size&&ye.every(e=>st.has(e))&&(ue.sequence=p.editPeer.sentSequence);}},async resolveDraft(e){if(!e.value.startsWith("=")&&[...e.value.replace(/^'/,"")].length>32767)throw new z("Cell text exceeds 32,767 characters");if(e.modified!==false)return e;let o=`${e.sheet}:${e.row}:${e.col}`,i=Ge.get(o);if(i!==void 0)return {...e,value:i,modified:true};let a=p&&workbookSessionInternals.get(p.session),h=p?.peer?p.peer.cell(e.sheet,e.row,e.col).input:a?.cellInput?await a.cellInput(e.sheet,e.row,e.col):(await p.session.call.cellInputs(e.sheet,yn(e))).cells[0]?.[0]?.input??"";return {...e,value:h,modified:true,unchanged:true}},write(e,o){let i=p;if(!i?.ready||!i.peer||!i.editPeer)return false;if(i.peer.cell(e.sheet,e.row,e.col).input!==e.value){o.check();let a=St.get(e),h=workbookEditPeerOperations(i.recovering?lr.current:i.editPeer),w;try{w=a?p.recovering?h.applyRecoveryOp(a):h.applyQueuedOp(a):i.editPeer.editCell(e.sheet,e.row,e.col,e.value);}catch(P){throw za(P)&&Fr.get(e)?.(),P}o(),Ye(w,a);}else Lt(St.get(e));return i.retiring||Do(e),true}};let Qt=e=>{if(ct(()=>Qt(e)))return;let o=d.current,i$1=M.current;if(!$e()||!o||!i$1)return;_.draft&&(Xt(),_.settle(),Oe(null));let a=i(i$1.focus,mt()),h=Q$1.current?.painted?.displayList.grid;I$1.current=h?cellRect(h,a.row,a.col):null;let w={...Zr("cell",a,e??o.peer?.cell(E.current,a.row,a.col).input??""),prefill:e===void 0&&!o.peer,modified:e!==void 0};_.setDraft(w),oe(w),!(e!==void 0||o.peer)&&o.session.call.cellInputs(w.sheet,yn(a)).then(P=>{if(!o.current||o.failure||_.draft!==w||U.current!==w)return;let B={...w,value:P.cells[0]?.[0]?.input??"",prefill:false},z=f$1.current,T=z?.selectionStart,H=z?.selectionEnd;flushSync(()=>{oe(B),_.setDraft(B);}),z&&T!=null&&H!=null&&z.setSelectionRange(T,H);}).catch(P=>o.fail(P));},Dt=(e,o,i=false)=>{if(!i&&he(()=>Dt(e,o,true))||!$e()||Te.current)return;i||Xt();let a=_.draft;if(a?.source!==e||!_.submit(a))return;a.modified!==false&&!qe.size&&(ue.sequence=1/0,dt.current&&(dt.current.dataset.previewReady="false"),it(a)),e==="cell"?(Re.current=true,oe(null)):Oe(null);let h=selectionAt({row:a.row,col:a.col});o&&!d.current?.peer?(He.select(h,Bt()),He.enqueue({key:o==="down"||o==="up"?"Enter":"Tab",shiftKey:o==="up"||o==="left"},Bt())):O(o?moveFocus(h,o,{limits:ht(),hidden:Pe(),merges:mt()}):h),Ie();},Qr=()=>{he(Qr)||(_.setDraft(null),Re.current=true,oe(null),Oe(null),Ie());},Mr=e$1=>{if(ct(()=>Mr(e$1)))return;let o=d.current,i=M.current,a=i&&k(i,mt());if(!o?.current||o.failure||!a||e$1!=="copy"&&!$e())return;a!==i&&O(a);let h=E.current,w$1=normalizeRange(a),P=()=>p.peer?.selectionData(h,0,0,"usedRange").usedRange,B;if(e$1!=="paste")if(typeof ClipboardItem!="function"||typeof navigator.clipboard.write!="function"){if(e$1==="cut"){pe(new z("Cut requires clipboard write access"));return}}else {let be,ge,Je=new Promise((De,et)=>{be=De,ge=et;});Je.catch(()=>{});try{let De=navigator.clipboard.write([new ClipboardItem({"text/plain":Je})]).then(()=>!0,et=>{throw ge(et),new z(et instanceof Error?et.message:"Clipboard write failed",e$1==="cut")});De.catch(()=>{}),B={resolve:be,reject:ge,done:De};}catch(De){ge(De),pe(new z(De instanceof Error?De.message:"Clipboard write failed"));return}}let z$1=()=>e$1==="paste"?navigator.clipboard.readText():"",T,H,G;B?.done.catch(be=>{G=be,e$1==="cut"&&H&&H().catch(pe),pe(be);});let se=async(be,ge=false)=>{if(!(e$1==="cut"&&b(w$1)&&!ge)){if(e$1!=="copy"&&!T){let Je=e$1==="cut"&&b(w$1)?await(p.peer??p.session.call).selectionData?.(h,0,0,"usedRange"):void 0,De=e$1==="paste"?[]:e(w$1,()=>Je?.usedRange);if(!De)throw new z("Clear exceeds the cell limit");if(e$1==="cut"&&De.length===0)return;e$1==="paste"&&fromTsv(be).forEach((et,or)=>et.forEach((Fn,ir)=>De.push({row:w$1.top+or,col:w$1.left+ir,input:Fn}))),T={method:"editCells",args:[h,De]};}if(T&&!ge&&(H=await qr(h,T.args[1],T)),G)throw await H?.(),G}};_.clipboard(z$1,async(be,ge,Je)=>{if(e$1!=="copy"&&!T&&await se(be,true),e$1!=="paste"){let ir=toTsv(o.peer.rangeCells(h,ps(c(w$1,P)))),qn;if(B)B.resolve(new Blob([ir],{type:"text/plain"})),qn=await B.done;else try{await navigator.clipboard.writeText(ir),qn=!0;}catch(ao){throw new z(ao instanceof Error?ao.message:"Clipboard write failed")}if(!o.current)throw new w("document-replaced");if(Je.check(),!qn)throw new z("Clipboard write was refused",e$1==="cut");if(e$1==="copy")return}if(!T)return;let De=T,et=De.args[1];if(et.length===0)return;Je.check();let or=workbookEditPeerOperations(p.recovering?lr.current:p.editPeer),Fn=p.recovering?or.applyRecoveryOp(De):or.applyQueuedOp(De);Je(),Ye(Fn,De),e$1==="paste"&&M.current===a&&E.current===h&&O({anchor:{row:w$1.top,col:w$1.left},focus:{row:Math.max(...et.map(ir=>ir.row)),col:Math.max(...et.map(ir=>ir.col))}});},{sheet:h,target:JSON.stringify(w$1)},e$1!=="copy"?se:void 0,e$1!=="copy").catch(async be=>{B?.reject(be),za(be)&&await H?.(),pe(be);});},Gt=()=>{if(!$e()||!M.current)return;let e$1=E.current,o=normalizeRange(M.current),i,a,h=async()=>{let w=b(o)?await(p.peer??p.session.call).selectionData?.(e$1,0,0,"usedRange"):void 0,P=e(o,()=>w?.usedRange);if(!P)throw new z("Clear exceeds the cell limit");P.length!==0&&(i={method:"editCells",args:[e$1,P]},b(o)||(a=await qr(e$1,P,i)));};_.runAfterPendingInput(async(w,P)=>{if(i||await h(),!i)return;P.check();let B=workbookEditPeerOperations(p.recovering?lr.current:p.editPeer),z=p.recovering?B.applyRecoveryOp(i):B.applyQueuedOp(i);P(),Ye(z,i);},{kind:"input",target:{sheet:e$1,target:JSON.stringify(o)},prepare:async()=>{b(o)||await h();}}).catch(async w=>{za(w)&&await a?.(),pe(w);});},Rn=(e,o)=>{let i=p;if(!i?.current||i.failure)return;let a=w=>{let P=!i.peer;P&&(We.current+=1,q$1(e),F(w)),_.runAfterPendingInput(async(B,z)=>{z.check(),i.editPeer.setActiveSheet(e),z(),P?E.current===e&&_t(e,M.current):_t(e,w);},{kind:"input",target:{sheet:e,target:JSON.stringify(w)}}).catch(pe);},h=structuredClone(o);i.peer?a(h):He.select(h,{...Bt(),apply:w=>(a(w),true)},e,true);},Xr=(e,o,i,a,h=false)=>{let w=p;if(!w?.current||!h&&!$e()||i===0&&a===0)return;let P=async(z,T)=>{await It(),T.check();let H=w.editPeer.moveChart(e,o,i,a);T(),Ye(H),Ce(null);},B={kind:"chart",target:{sheet:e,target:o},input:{dx:i,dy:a}};(h?_.input(P,B):_.runAfterPendingInput(P,B)).catch(pe);},er=(e=false)=>{let o=Ke.current;Ke.current=null,o&&Xr(o.sheet,o.id,o.dx,o.dy,e),Ne.current!==null&&clearTimeout(Ne.current),Ne.current=null;};Et.current=er,p&&(p.beforeRetire=()=>{_.retire(),Zt.resolve(),Q$1.current?.dispose(),Xt(),Te.current?.settle(true),Te.current=null,er(true);});let cr=useRef(Xr);cr.current=Xr,useEffect(()=>{let e=i=>{_e.current=false;let a=ee.current;ee.current=null,a&&i.button===0?cr.current(a.sheet,a.id,(i.clientX-a.clientX)/a.zoom,(i.clientY-a.clientY)/a.zoom):Ce(null);},o=()=>{_e.current=false,ee.current=null,Ce(null),Et.current();};return window.addEventListener("mouseup",e),window.addEventListener("blur",o),()=>{window.removeEventListener("mouseup",e),window.removeEventListener("blur",o);}},[]);let Or=e=>{let o=Q$1.current?.painted,i=y.current;if(!o||o.request.sheet!==E.current||!i)return {cell:null,chart:null};let a=i.getBoundingClientRect(),h=(e.clientX-a.left)/o.request.zoom,w=(e.clientY-a.top)/o.request.zoom;return {cell:o.geometry?cellAtPoint(o.geometry,h,w):null,chart:chartRegionAtPoint(o.displayList.charts,h,w)}},Oo=e=>{if(jn(e)||d.current?.failure||f$1.current?.contains(e.target))return;let{cell:o,chart:i$1}=Or(e),a=U.current!==null;if(a?Dt("cell"):_.draft?.source==="formula"&&Dt("formula"),Et.current(),ee.current=null,Ze.current=null,i$1){vt({id:i$1.id,movable:i$1.movable}),$e()&&i$1.movable&&e.button===0&&(ee.current={id:i$1.id,sheet:E.current,zoom:Q$1.current?.painted?.request.zoom??L.current,clientX:e.clientX,clientY:e.clientY}),Ie(),e.preventDefault();return}vt(null),!(!o||!M.current)&&(O(e.shiftKey?extendTo(M.current,o,ht()):selectionAt(i(o,mt()))),Ze.current=a?null:o,_e.current=true,Ie());},io=e=>{if(jn(e)||d.current?.failure)return;let o=ee.current;if(o){if(!e.buttons){ee.current=null,Ce(null);return}Ce({x:e.clientX-o.clientX,y:e.clientY-o.clientY}),e.currentTarget.style.cursor="move",e.currentTarget.title="";return}let{cell:i,chart:a}=Or(e);if(_e.current&&i&&M.current){O(extendTo(M.current,i,ht()));return}let h=i&&Q$1.current?.painted?hyperlinkAtCell(Q$1.current.painted.displayList,i.row,i.col):null;e.currentTarget.style.cursor=a?.movable&&$e()?"move":a||h?"pointer":"default",e.currentTarget.title=a?"":h?.tooltip??"";},Ho=e=>{if(jn(e)||d.current?.failure)return;let{cell:o}=Or(e),i=Ze.current;Ze.current=null;let a=Q$1.current?.painted?.displayList;if(!o||!i||!a||o.row!==i.row||o.col!==i.col)return;let h=hyperlinkAtCell(a,o.row,o.col);if(!h)return;let w=safeExternalHyperlink(h);if(w){window.open(w,"_blank","noopener,noreferrer");return}if(!h.location)return;let P=d.current.session.state.sheets,B=parseHyperlinkLocation(h.location,P[E.current]?.name??"");if(!B)return;let z=P.findIndex(T=>T.name.toLowerCase()===B.sheetName.toLowerCase());z>=0&&Rn(z,selectionAt(B));},zt=e=>{if(jn(e)||d.current?.failure||!g$1.current||!M.current||U.current||q(e))return;let o=e.metaKey||e.ctrlKey,i=ze.current;if(i){if(e.key==="Escape"){ee.current=null,Ke.current=null,Ce(null),vt(null),Ne.current!==null&&clearTimeout(Ne.current),Ne.current=null,e.preventDefault();return}let z=!o&&Vl[e.key];if(z){if($e()&&i.movable){let T=e.shiftKey?10:1,H=Q$1.current?.painted?.request.zoom??L.current,G=Ke.current??{id:i.id,sheet:E.current,dx:0,dy:0};Ke.current={...G,dx:G.dx+z[0]*T,dy:G.dy+z[1]*T},Ce({x:Ke.current.dx*H,y:Ke.current.dy*H}),Ne.current!==null&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>Et.current(),250);}e.preventDefault();}return}if(o){let z=e.key.toLowerCase();if(z==="c"||z==="x"||z==="v"){let T=z==="c"?"copy":z==="x"?"cut":"paste";he(()=>Mr(T))||Mr(T),e.preventDefault();return}}let a=l(e),h={key:e.key,ctrlKey:e.ctrlKey,metaKey:e.metaKey,altKey:e.altKey,shiftKey:e.shiftKey},w=a||selectionKeyReducer(M.current,h,ht()).type==="move",P=()=>{if(!M.current)return;if(U.current){if(h.key==="Enter"||h.key==="Tab")Dt("cell",h.key==="Enter"?h.shiftKey?"up":"down":h.shiftKey?"left":"right",true);else if(h.key==="Escape")Qr();else if(h.key.length===1&&!h.ctrlKey&&!h.metaKey&&!h.altKey){let G={...U.current,value:U.current.value+h.key};f$1.current&&(f$1.current.value=G.value),_.setDraft(G),oe(G);}return}if(!d.current?.peer&&w){He.enqueue(h,Bt());return}let z=M.current,T=a?d.current?.peer?.selectionData(E.current,z.focus.row,z.focus.col,a==="region"?void 0:a):void 0,H=selectionKeyReducer(z,h,ht(),T,Pe(),mt());H.type==="move"?(O(H.selection),Hr(E.current,M.current)):H.type==="startEdit"?Qt(H.initialInput):H.type==="clear"&&Gt();};if(!d.current?.peer&&w){e.preventDefault(),He.defer(Sr(),P,true)||He.enqueue(h,Bt());return}(selectionKeyReducer(M.current,h,ht(),void 0,Pe(),mt()).type!=="none"||a)&&(e.preventDefault(),he(P)||P());},en=(e,o,i,a,h,w)=>{let P=d.current,B=c$1.current;if(!P?.current||!w()||!B||E.current!==o)return;let z=e.sheetInfo(),T=e.cellPosition(o,i,a),H=e.cellRect(o,i,a),G=L.current;g$1.current&&V(pa$1(B,g$1.current,H,G));let se=Ca$1(Q$1.current?.painted?.displayList.grid,z.frozenRows,z.frozenCols),be=fs(T.x,H.w,a<z.frozenCols,B.scrollLeft/G,B.clientWidth/G-se.width,h),ge=fs(T.y,H.h,i<z.frozenRows,B.scrollTop/G,B.clientHeight/G-se.height,h);be!==null&&(B.scrollLeft=be*G),ge!==null&&(B.scrollTop=ge*G),P.recovering||Q$1.current?.schedule();},Hr=(e,o,i)=>{let a=d.current;if(!a?.current)return;let h=()=>a.current&&d.current===a&&E.current===e&&M.current===o;if(a.peer){let T=c$1.current;if(i!==void 0&&(!T||!qa(T,a.peer.cellRect(e,o.focus.row,o.focus.col),i)))return;en(a.peer,e,o.focus.row,o.focus.col,"nearest",h);return}let w=T=>{let H=c$1.current,G=g$1.current;if(!h()||!H||!G||G.sheet!==e||i!==void 0&&!qa(H,T,i))return;let se=L.current;(T.x+T.w>G.contentWidth||T.y+T.h>G.contentHeight)&&V(pa$1(H,G,T,se));let be=sa(T,o.focus,G,{x:H.scrollLeft/se,y:H.scrollTop/se,width:H.clientWidth/se,height:H.clientHeight/se});(H.scrollLeft!==be.x*se||H.scrollTop!==be.y*se)&&(H.scrollLeft=be.x*se,H.scrollTop=be.y*se,Q$1.current?.schedule());},P=Q$1.current?.painted,B=g$1.current,z=P?.request.sheet===e&&B?ra(P.displayList,P.request.viewport,B,o.focus):null;z?w(z):a.session.call.cellGeometry(e,o.focus.row,o.focus.col).then(T=>w(T.rect)).catch(pe);},En=useRef(C);useLayoutEffect(()=>{if(En.current===C)return;let e=En.current;En.current=C;let o=M.current;o&&!ze.current&&Hr(E.current,o,e);},[C]);let Sn=(e,o,i)=>{if(!i||!Number.isInteger(i.row)||!Number.isInteger(i.col)||i.row<0||i.col<0||i.row>1048575||i.col>16383)return false;try{return e.cellPosition(o,i.row,i.col),!0}catch{return false}};Kt.current={handle:Cn.handle,commands:()=>X,async admit(e,o){try{return {ok:!0,value:await _.runAfterPendingInput(async(a,h)=>{if(d.current?.peer!==e)throw new w("document-replaced");await It(),h.check();let w$1=o();if(d.current?.recovering&&w$1!==null&&typeof w$1=="object"&&("refused"in w$1||"ok"in w$1&&w$1.ok===!1))throw new w("input-failed");return w$1!==null&&typeof w$1=="object"&&("refused"in w$1||"ok"in w$1&&w$1.ok===!1)?h.refuse(new z("Plugin request was refused")):h(),w$1},{kind:"plugin",recover:!1})}}catch(i){return {ok:false,code:i instanceof w&&i.code==="document-replaced"?"document-replaced":"input-failed",error:i}}},async admitEdits(e,o,i,a){let h=p,w$1=h?.editPeer;if(!h||!w$1||h.peer!==e)return {ok:false,code:"document-replaced",error:new w("document-replaced")};let P={method:"applyEdits",args:[structuredClone(o)]},B=workbookEditPeerOperations(w$1),z$1=Kt.current.readOnlyRefusal(e);try{return {ok:!0,value:await _.runAfterPendingInput(async(H,G)=>{await It(),G.check();let se=i(h.recovering);if(se)return G.refuse(new z("Plugin write permission was refused")),se;if(z$1)return G.refuse(new z(z$1.failure.message)),z$1;let be=()=>h.recovering?B.applyRecoveryOp(P):B.applyQueuedOp(P),ge;try{ge=h.recovering?be():a(be);}catch(Je){if(!(Je instanceof WorkbookRecoveryRefusal))throw Je;ge=Je.result;}return ge.ok?(G(),Ye(ge),ge):(G.refuse(new z(ge.failure.message),!0),ge)},{kind:"plugin",input:P})}}catch(T){return {ok:false,code:T instanceof w&&T.code==="document-replaced"?"document-replaced":"input-failed",error:T}}},readOnlyRefusal:e=>b$1.current.readOnly?{ok:false,version:e.version(),failure:{code:"read-only",message:"The editor is read-only"}}:null,applyEdits(e,o,i,a){let h=i();if(h)return h;let w=Kt.current.readOnlyRefusal(e);if(w)return w;let P=a(()=>d.current.editPeer.applyEdits(o));return Ye(P),P},navigator:{selectCells(e,o,i,a){let h=e.sheetInfo().sheetIds.indexOf(o?.sheetId);return h<0||!Sn(e,h,o?.selection?.anchor)||!Sn(e,h,o?.selection?.focus)?"missing-target":(d.current.editPeer.setActiveSheet(h),_t(h,o.selection),en(e,h,o.selection.focus.row,o.selection.focus.col,"nearest",a),i&&Ie(),null)},scrollToCell(e,o,i,a){let h=e.sheetInfo().sheetIds.indexOf(o?.sheetId);return h<0||!Sn(e,h,o)?"missing-target":(h!==E.current&&(d.current.editPeer.setActiveSheet(h),_t(h,null)),en(e,h,o.row,o.col,i,a),null)}}};let Xn=Q({document:()=>d.current?.current&&!d.current.retiring&&!d.current.failure?d.current:null,onSaveRequest:n$1.onSaveRequest,fail:pe});rs(X,{requestSave:Xn,peer:()=>p?.peer??null,editPeer:()=>p?.editPeer??null,status:()=>p?.ready?"ready":p&&!p.failure||re?"loading":"empty",readOnly:()=>b$1.current.readOnly??false,collaborative:()=>false,mutation:()=>Xe.current,generation:()=>p?.generation??0,view:()=>({sheet:E.current,selection:M.current,chartSelected:ze.current!==null,zoom:L.current,capturedFormat:Mt.current,borderStyle:kr.current,borderColor:pt.current,proposals:u.current,proposalsAvailable:isProposalsAvailable(),proposalsPanelOpen:Z.current,pngExport:false}),coordinator:_,preview:()=>Le(),recovering:()=>d.current?.recovering??false,i18n:()=>b$1.current.i18n,translate:r,apply:Ye,fail:e=>p?.fail(e),setZoom:e=>{v(e),Q$1.current?.schedule();},setProposalsPanelOpen:$,setCapturedFormat:(e,o)=>{yt(e),Pt.current=o;},setBorderStyle:e=>{kr.current=e;},setBorderColor:e=>{pt.current=e;},markStale:(e,o)=>me(({[e]:i,...a})=>o?{...a,[e]:o}:a),refreshProposals:Pr,deliver(e){if(b$1.current.onSave)b$1.current.onSave(e);else {let o=URL.createObjectURL(new Blob([new Uint8Array(e)],{type:$l})),i=document.createElement("a");i.href=o,i.download=b$1.current.fileName??"workbook.xlsx",document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(o);}},afterPaint:Fo,focusGrid:Ie,refuse:e=>ot(e.message)}),P(X,l$1),useEffect(()=>{if(!lt||!K||!$e()||_e.current)return;let e=normalizeRange(K);if(`${x$1}:${e.top}:${e.left}:${e.bottom}:${e.right}`===Pt.current)return;let i=lt,a=Ul(K);yt(null),Pt.current=null,_.runAfterPendingInput(async(h,w)=>{await It(),w.check();let P=p.editPeer.applyFormat(x$1,a,i);w(),Ye(P),Ie();},{kind:"input",target:{sheet:x$1,target:a}}).catch(pe);},[lt,K,x$1,_,It,Ye,pe,Ie]),useLayoutEffect(()=>{if(!n$1.readOnly)return;Xt(),ro.current=te.current;let e=_.draft?.source;Re.current=true,Cr.current=true,Te.current?.settle(true),Te.current=null,oe(null),Oe(null),yt(null),Pt.current=null,_e.current=false,Ze.current=null,ee.current=null,Ke.current=null,Ce(null),Ne.current!==null&&clearTimeout(Ne.current),Ne.current=null,(_.draft||_.pending)&&_.drain().catch(pe),e==="cell"&&Ie(),Cr.current=false;},[n$1.readOnly,_]);let Wn=e=>{if(ct(()=>Wn(e))||!$e())return;e==="formula"&&_.draft?.source!=="formula"&&M.current&&(Xt(),_.settle(),Re.current=true,oe(null),_.setDraft(Zr(e,i(M.current.focus,mt()),A.current?.value??"")));let o,i$1=new Promise(a=>{o=a;});Te.current={source:e,done:i$1,settle:o};},ur=e=>{if(he(()=>ur(e))||!Te.current)return;let o=_.draft;if(e!==void 0&&o){let i={...o,value:e};_.setDraft(i),o.source==="cell"?oe(i):Oe(e);}else Xt();Te.current?.settle(true),Te.current=null;},ut=useCallback(e=>{e||bt.current?.sync?.(),f$1.current=e,e&&(Re.current=false),!e&&Te.current?.source==="cell"&&(Te.current.settle(true),Te.current=null);},[bt]),Nt=useCallback(e=>{e||bt.current?.sync?.(),A.current=e,!e&&Te.current?.source==="formula"&&(Te.current.settle(true),Te.current=null);},[bt]);useLayoutEffect(()=>{if(!le||p?.failure)return;let e=f$1.current;e&&document.activeElement!==e&&(e.focus({preventScroll:true}),e.setSelectionRange(e.value.length,e.value.length));},[le!==null]);let Tn=e=>{let o=M.current;if(!$e()||!o||ze.current)return;let i$1=_.draft;i$1&&i$1.source!=="formula"&&(Xt(),_.settle(),Re.current=true,oe(null),i$1=null),_.setDraft({...i$1??Zr("formula",i(o.focus,mt()),e),value:e,modified:true,revision:++te.current});},$t={onNavigate:e=>{He.select(selectionAt(e),Bt()),Ie();},a1:K?yn(K.focus):"",value:(Te.current?.source==="formula"?A.current?.value:void 0)??J??N?.input??"",disabled:!W||!K||!!Ot,readOnly:!$e()||Be!==null,inputRef:Nt,onChange(e){!$e()||!M.current||ze.current||(Oe(e),ct(()=>Tn(e))||Tn(e));},onCommit:e=>Dt("formula",e),onCancel:Qr,onBlur:()=>{Cr.current||Dt("formula");},onCompositionStart:()=>Wn("formula"),onCompositionEnd:()=>ur(A.current?.value)},je=Ue?.displayList;useEffect(()=>{!Be||!je||je.charts?.some(e=>e.id===Be.id)||(Et.current(),ee.current=null,Ce(null),vt(null));},[Be,je]);let Wt=Ue?.request.zoom??C,Yt=Ue?.request.sheet===x$1?K:null,tr=Ue?.mergedRanges??[],jt=je?.grid,An=Yt?ua$1(normalizeRange(Yt),tr):null,In=Yt?ua$1({top:Yt.focus.row,left:Yt.focus.col,bottom:Yt.focus.row,right:Yt.focus.col},tr):null,Br=jt&&An?rangeRect(jt,An):null,dr=jt&&In?rangeRect(jt,In):null,so=le?(jt&&le.sheet===Ue?.request.sheet?cellRect(jt,le.row,le.col):null)??I$1.current??{x:0,y:0,w:96,h:24}:null,rr=Se&&jt&&Se.sheet===Ue?.request.sheet?rangeRect(jt,ua$1({top:Se.row,left:Se.col,bottom:Se.row,right:Se.col},tr)):null,zr=Be?je?.charts?.find(e=>e.id===Be.id)?.rect:null,tn=p?.session.state.sheets??[],nr=je&&Ue?buildA11yGrid(je,Yt,tn[Ue.request.sheet]?.name??"",{gridLabel:r("a11y.gridLabel"),rowHeaderLabel:r("a11y.rowHeaderLabel"),columnHeaderLabel:r("a11y.columnHeaderLabel"),cellLabel:r("a11y.cellLabel"),cellLabelSelected:r("a11y.cellLabelSelected"),emptyCellLabel:r("a11y.emptyCellLabel"),emptyCellLabelSelected:r("a11y.emptyCellLabelSelected")}):null,Wr=(e,o,i)=>{let a=ta(e,Wt);return {position:"absolute",left:a.x,top:a.y,width:a.w,height:a.h,boxSizing:"border-box",border:o,background:i}},lo=jsxs(ma$1,{mode:"commands",children:[jsx(ma$1.Toolbar,{}),jsxs("div",{style:{display:"flex",padding:"4px 8px"},children:[jsx(ma$1.FormulaBar,{}),isProposalsAvailable()&&jsx(ga$1,{id:"proposalsPanel"})]})]}),Ln=n$1.showToolbar===false?null:n$1.toolbar===void 0?n$1.readOnly?null:lo:n$1.toolbar,Dn=e=>xt.managed?jsx(Ga,{host:xt.host,placement:e,activations:xt.activations.filter(o=>o.plugin.panel?.placement===e),available:oo}):null;return jsx(I.Provider,{value:X.store,children:jsx(S.Provider,{value:true,children:jsx(Y.Provider,{value:$t,children:jsxs("div",{ref:l$1,className:n$1.className,role:"application","aria-label":r("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:[Ln!=null&&jsx("div",{"data-testid":"xlsx-toolbar",style:{flex:"0 0 auto"},children:Ln}),jsxs("div",{ref:no,"data-testid":"xlsx-workspace",style:{position:"relative",display:"flex",flex:1,minWidth:0,minHeight:0},children:[Dn("left"),jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:[isProposalsAvailable()&&S$1&&jsx(xa$1,{proposals:Tt,staleFor:xe,style:{top:4,right:8,width:"min(320px, calc(100% - 16px))",maxHeight:"min(420px, calc(100% - 12px))"}}),jsxs("div",{ref:c$1,"data-testid":"xlsx-scroll",tabIndex:0,onKeyDown:zt,onMouseDown:Oo,onMouseMove:io,onClick:Ho,onDoubleClick:e=>{if(jn(e)||U.current||Or(e).chart)return;let o=Or(e).cell;o&&je&&hyperlinkAtCell(je,o.row,o.col)||Qt();},onMouseLeave:e=>{e.currentTarget.style.cursor="default",e.currentTarget.title="";},style:{position:"relative",flex:1,overflow:"auto",minHeight:0,outline:"none"},children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:W?W.contentWidth*C:"100%",height:W?W.contentHeight*C:"100%"}}),jsxs("div",{style:{position:"sticky",top:0,left:0,width:0,height:0},children:[jsx("canvas",{ref:y,style:{display:"block",position:"absolute",top:0,left:0}}),Se&&(p?.ready?jsx("div",{"data-testid":"xlsx-commit-preview","aria-hidden":true,style:{...Wr(rr??{x:0,y:0,w:96,h:24},"none","#fff"),color:"#000",padding:`0 ${8*Wt}px`,overflow:"hidden",whiteSpace:"pre",display:Se.sheet===x$1&&(!jt||rr)?"block":"none",font:`${13*Wt}px system-ui, sans-serif`,lineHeight:`${(rr?.h??24)*Wt}px`,pointerEvents:"none"},children:Se.value}):jsx("canvas",{ref:dt,"data-testid":"xlsx-commit-preview","aria-hidden":true,style:{position:"absolute",left:0,top:0,pointerEvents:"none"},children:Se.value})),xt.managed&&jsx(Ba,{host:xt.host,activations:xt.activations,layerRef:xt.overlayLayerRef,width:(je?.width??0)*Wt,height:(je?.height??0)*Wt}),jsxs("div",{"data-testid":"xlsx-overlay-host",style:{position:"absolute",top:0,left:0,width:0,height:0,pointerEvents:"none"},children:[Br&&!Be&&jsx("div",{"data-testid":"xlsx-selection",style:Wr(Br,`1px solid ${Yn}`,"rgba(33, 115, 70, 0.12)")}),dr&&!Be&&!le&&jsx("div",{style:Wr(dr,`2px solid ${Yn}`)}),zr&&jsx("div",{"data-testid":"xlsx-chart-selection","data-chart-id":Be?.id,"aria-hidden":true,style:{...Wr(zr,`2px solid ${Yn}`),transform:`translate(${ft?.x??0}px, ${ft?.y??0}px)`,boxShadow:"0 1px 6px rgba(0, 0, 0, 0.25)"}}),le&&so&&jsx("input",{ref:ut,"data-testid":"xlsx-cell-editor",value:(Te.current?.source==="cell"?f$1.current?.value:void 0)??le.value,disabled:!!Ot||n$1.readOnly,onChange:e=>{if(!$e())return;let o={...le,value:e.target.value,prefill:false,modified:true,revision:++te.current};oe(o),_.setDraft(o);},onCompositionStart:()=>Wn("cell"),onCompositionEnd:e=>ur(e.currentTarget.value),onKeyDown:e=>{q(e)||e.stopPropagation(),!(e.nativeEvent.isComposing||e.keyCode===229)&&(e.key==="Enter"?(Dt("cell",e.shiftKey?"up":"down"),e.preventDefault()):e.key==="Tab"?(Dt("cell",e.shiftKey?"left":"right"),e.preventDefault()):e.key==="Escape"&&(Qr(),e.preventDefault()));},onBlur:()=>{if(Re.current){Re.current=false;return}Dt("cell");},style:{...Wr(so,`2px solid ${Yn}`,"#ffffff"),padding:"0 3px",font:`${13*Wt}px system-ui, sans-serif`,pointerEvents:"auto",outline:"none"}})]})]})]}),Dn("bottom")]}),Dn("right")]}),nr&&jsxs(Fragment,{children:[jsxs("div",{style:ds,role:"grid","aria-label":nr.label,children:[jsxs("div",{role:"row",children:[jsx("span",{role:"columnheader"}),nr.columnHeaders.map(e=>jsx("span",{role:"columnheader",children:e.label},e.col))]}),nr.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))]}),nr.charts.map((e,o)=>jsx("div",{style:ds,role:"img","aria-label":e.label},`${o}:${e.label}`))]}),Ct&&jsx("div",{"data-testid":"xlsx-input-refusal",role:"alert",style:{position:"relative",zIndex:1},children:Ct}),Ot&&jsxs("div",{"data-testid":"xlsx-error",role:"alert",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",padding:16,textAlign:"center",color:"#b00020"},children:[r("editor.openError"),": ",Ot.message]}),tn.length>0&&jsx("div",{"data-testid":"xlsx-sheet-tabs",role:"tablist","aria-label":r("editor.sheetTabsLabel"),style:{display:"flex",gap:2,padding:"4px 6px",borderTop:"1px solid #e0e0e0",background:"#fafafa",overflowX:"auto"},children:tn.map((e,o)=>jsx("button",{role:"tab","aria-selected":o===x$1,disabled:!!Ot,onClick:()=>Rn(o,selectionAt({row:0,col:0})),style:{border:"none",padding:"4px 12px",cursor:"pointer",background:o===x$1?"#ffffff":"transparent",borderBottom:o===x$1?`2px solid ${Yn}`:"2px solid transparent",fontWeight:o===x$1?600:400},children:e.name},e.id))})]})})})})}var Jl={deprecated:`[XlsxEditor] \`experimentalWorkerOpen={false}\` selects the deprecated in-thread engine. Omit it and \`${Ua}\` to use the worker-owned async editor.`,"no-worker":"[XlsxEditor] `Worker` is not available in this environment; using the deprecated in-thread engine.","no-offscreen-canvas":"[XlsxEditor] `OffscreenCanvas` is not available in this environment; using the deprecated in-thread engine.","legacy-sync-api":`[XlsxEditor] \`${Ua}\` keeps the deprecated synchronous API on the in-thread engine, removed in 0.6.0. Omit it to use the async editor.`},si=Symbol.for("@betteroffice/xlsx-react/engine-warnings"),li=globalThis,ms=li[si]??(li[si]=new Set);function Lo(n){let r=Jl[n];ms.has(r)||(ms.add(r),console.warn(r));}function hs(n,r,l,c=()=>{}){async function y$1(I){return await n.flushPendingInput(),I()}let f=async I=>{l();try{let d=await I();return l(),d}catch(d){throw l(),d}},A=n.handle;return Wa({hydrated:true,failure:null,version:()=>f(()=>n.version()),readCells(I){let d=structuredClone(I);return f(()=>n.readCells(d))},findText(I){let d=structuredClone(I);return f(()=>n.findText(d))},validateEdits(I){let d=structuredClone(I);return f(()=>n.validateEdits(d))},applyEdits(I){let d=structuredClone(I);return f(()=>n.applyEdits(d))},save:()=>f(async()=>{let I;try{await n.flushPendingInput(),l();try{I=n.save();}catch(d){if(!(d instanceof br)||d.code!=="input-pending")throw d;await n.flushPendingInput(),l(),I=n.save();}}catch(d){throw d instanceof br?new w("input-failed"):d}return l(),c()?.(I),I}),whenHydrated:n.flushPendingInput,recoverySave:()=>y$1(()=>({bytes:n.save(),recovery:true})),commands:y(n.commands).guarded(l),collaboration:r?{clientId:A.clientId,encodeStateVector:()=>y$1(()=>A.encodeStateVector()),encodeStateAsUpdate(I){let d=I?.slice();return y$1(()=>A.encodeStateAsUpdate(d))},applyUpdate(I){let d=I.slice();return y$1(()=>A.applyUpdate(d))},onUpdate:I=>A.onUpdate(I)}:null,focus:n.focus,renderPng(I){let d=structuredClone(I);return y$1(()=>A.renderPng(d))},renderRangePng(I){let d=structuredClone(I);return y$1(()=>A.renderRangePng(d))},exportStructured(I){let d=structuredClone(I);return y$1(()=>A.exportStructured(d))},exportMarkdown(I,d){let b=structuredClone([I,d]);return y$1(()=>A.exportMarkdown(...b))},printDisplayList(...I){let d=structuredClone(I);return y$1(()=>A.printDisplayList(...d))}})}function Qn(n){return {ok:false,version:n.version(),failure:{code:"read-only",message:"The editor is read-only"}}}var br=class extends Error{constructor(l){super(l==="input-pending"?'Accepted input is still being written; await commands.execute("save", null)':"A cell entry could not be written; correct or discard it first");a(this,"code",l);this.name="XlsxSaveRefusedError";}},Gr=96,Yr=24,eo="#217346",ua=87,da=1024,fa="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",pa=1,ma=10,ha=250,ga=1e3,va={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};function ya(n,r,l){let c=[{op:"fillRect",x:0,y:0,w:n,h:r,color:"#ffffff"}],y=Math.ceil(n/Gr),f=Math.ceil(r/Yr);for(let A=0;A<=y;A++)c.push({op:"line",x1:A*Gr,y1:0,x2:A*Gr,y2:r,width:1,color:"#e0e0e0"});for(let A=0;A<=f;A++)c.push({op:"line",x1:0,y1:A*Yr,x2:n,y2:A*Yr,width:1,color:"#e0e0e0"});return c.push({op:"fillRect",x:0,y:0,w:n,h:Yr,color:"#f3f3f3"}),c.push({op:"fillRect",x:0,y:0,w:Gr,h:r,color:"#f3f3f3"}),c.push({op:"text",x:Gr+8,y:Yr+18,text:l,fontSize:14,color:"#202020",clip:{x:Gr,y:Yr,w:Gr*3,h:Yr},align:"left"}),{width:n,height:r,commands:c}}function bs(n,r,l){let c=new Blob([new Uint8Array(n)],{type:l}),y=URL.createObjectURL(c),f=document.createElement("a");f.href=y,f.download=r,document.body.appendChild(f),f.click(),f.remove(),URL.revokeObjectURL(y);}function ba(n){return `${(n??"workbook.xlsx").replace(/\.xlsx$/i,"")}.png`}function ui(n,r){return n.generation===r.generation&&n.view===r.view&&n.mutation>=r.mutation}function ws(n,r,l,c,y,f){return l?null:f==="start"?n:f==="center"?Math.max(0,n-Math.max(0,y-r)/2):n>=c&&n+r<=c+y?null:n<c||r>=y?n:Math.max(0,n+r-y)}function wa(n,r,l){let c=n.displayList({...l,x:0,y:0}).grid;return Ca$1(c,r.frozenRows,r.frozenCols,l)}function xa(n,r,l,c,y,f){let A=n.sheetInfo(),I=n.cellPosition(r,l,c),d=n.cellRect(r,l,c),b=A.frozenRows>0||A.frozenCols>0?wa(n,A,f):{width:0,height:0};return {x:ws(I.x,d.w,c<A.frozenCols,f.x,Math.max(0,f.width-b.width),y),y:ws(I.y,d.h,l<A.frozenRows,f.y,Math.max(0,f.height-b.height),y)}}function wn(n){return N(n.nativeEvent)!==null||O(n.target)}function xs(n,r){return typeof r=="string"?n.sheetInfo().sheetIds.indexOf(r):-1}function ks(n){return typeof n=="number"&&Number.isInteger(n)&&n>=0}function di(n,r,l,c){if(!ks(l)||!ks(c))return false;try{return n.cellPosition(r,l,c),!0}catch{return false}}var Cs={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},Ps={workspace:{position:"relative",display:"flex",flex:1,minWidth:0,minHeight:0},center:{position:"relative",display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0}},to={shell:{flex:"0 0 auto",minHeight:ua,padding:"4px 0 5px",borderBottom:`1px solid ${V.line}`,background:"#ffffff",color:V.ink,boxSizing:"border-box"},rail:{...W,margin:"0 8px",overflowX:"auto",overflowY:"hidden"},host:{flex:"0 0 auto"},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:V.accent,color:V.accentInk,fontSize:10,fontWeight:700,lineHeight:1,boxSizing:"border-box"}};function jr(n){let[r,l]=useState(n),c=useRef(r),y=useCallback(f=>{c.current=typeof f=="function"?f(c.current):f,l(c.current);},[]);return [r,y,c]}function ka(n){let r=n.experimentalWorkerOpen===false,l=useMemo(()=>({}),[n.file,n.collaboration,r]),c=()=>({identity:l,reason:r?"deprecated":typeof Worker!="function"?"no-worker":typeof OffscreenCanvas!="function"?"no-offscreen-canvas":void 0}),[y,f]=useState(c),A=y.identity===l?y:c();return y!==A&&f(A),useEffect(()=>{A.reason&&Lo(A.reason);},[A.reason]),A.reason?jsx(Ca,{...n}):jsx(ii,{...n,backend:"peerless"})}function Ca(n){let r=useRef(n);r.current=n;let l=useRef(null),c=useCallback(y=>{l.current=y;let f=n.onReady?.(hs(y,n.collaboration!==void 0,()=>{if(l.current!==y)throw new w("document-replaced")},()=>r.current.onSave));return ()=>{l.current===y&&(l.current=null),f?.();}},[n.onReady,n.collaboration]);return jsx(Rs,{...n,experimentalWorkerOpen:false,onReady:c})}function Pa(n){let r=useMemo(()=>n.file instanceof ArrayBuffer?new Uint8Array(n.file):n.file,[n.file]),l={...n,file:r};return jsx(G,{i18n:n.i18n,children:l[Ua]===true?jsx(Ra,{...l}):jsx(ka,{...l})})}function Ra(n){useEffect(()=>{Lo("legacy-sync-api");},[]);let r=n.experimentalWorkerOpen,l=n.collaboration,c=useMemo(()=>({}),[n.file,l,r]),y=()=>({identity:c,reason:r===false?"deprecated":r!==true?"in-thread":typeof Worker!="function"?"no-worker":void 0,editor:!n.readOnly}),[f,A]=useState(y),I=f.identity===c?f:y(),d=I.editor||!n.readOnly;return (f!==I||f.editor!==d)&&A({...I,editor:d}),useEffect(()=>{I.reason&&I.reason!=="in-thread"&&Lo(I.reason);},[I.reason]),I.reason?jsx(Rs,{...n}):d?jsx(ii,{...n}):jsx(Qi,{...n})}function Rs({file:n,fileName:r,onSave:l$1,downloadOnSave:c$1,onSaveRequest:y,onChange:f$1,onDocumentChange:A$1,initialZoom:I$1,loadingIndicator:d,style:b,onError:X$1,collaboration:x$1,onReady:q$1,className:E$1,readOnly:W=false,toolbar:V,showToolbar:g=true,i18n:K,plugins:F$1,pluginGrants:M,onPluginError:j$1}){let{t:O}=H(),C$1=x$1!==void 0,v=x$1?.clientId,L=x$1?.initialUpdate,le=x$1?.onReplica,oe=x$1?.provider,[U]=useState(x),J=useRef(null),Oe=useRef(null),N=useRef(null),Ae=useRef(null),dt=useRef(()=>null),Ct=useRef(null),ot=useRef(null),[Se]=useState(()=>new A),it=useRef(null),Ue=useRef(null),xr=useRef(null),Be=useRef(false),vt=useRef(null),ze=useRef(null),ft=useRef(null),Ce=useRef(null),lt=useRef(false),yt=useRef(false),Mt=useRef(()=>{}),Pt=useRef(()=>true),kr=useRef(()=>false),pt=useRef(0),Tt=useRef(0),Rt=useRef(null),[u$1]=useState(()=>Mi({generation:()=>pt.current,seal:()=>Rt.current?.seal()??{},sync:()=>Rt.current?.sync(),write:t=>Rt.current?.write(t)??false,close:t=>Rt.current?.close(t),restore:t=>Rt.current?.restore(t)??false})),S$1=useRef(null),$=useRef(false),Z=useRef(null),xe=useRef([]),me=useRef(q$1);me.current=q$1;let Xe=useRef(X$1);Xe.current=X$1;let We=useRef(f$1);We.current=f$1;let He=useRef(A$1);He.current=A$1;let Q$1=useRef(null),_e=useCallback(t=>{let s=t.version();return s===Q$1.current?false:(Q$1.current=s,He.current?.({version:s}),true)},[]),Ze=useRef(W);Ze.current=W;let[ee,Ke,Ne]=jr(null),[Et,Re]=useState(null),[Cr,Te]=useState(null),[Qe,xn]=useState(null),[te,ro,Ie]=jr(null),[pe,$e]=useState(null),[At,kn]=useState(null),[p,Ot]=useState(null),[re,bt,Ge]=jr(u(I$1)),[St,at]=useState(0),[Fr,lr]=useState(false),[ke,wt,ye]=jr(null),[st,qe]=useState(null),[ue,Zt]=useState(null),[_,ar]=useState([]),It=useRef(null),Ht=()=>j(N.current,Pe.current,h(It.current?.sheet===Pe.current?It.current.ranges:void 0)),Le=useCallback(t=>{let s=typeof t=="function"?t(Ie.current):t;ro(s?k(s,j(N.current,Pe.current)):null);},[]),qr=useRef(void 0),Pr=useRef(void 0),[Rr,Lt,Do]=jr(null),Ye=useRef(null),[Fo,_t,qo]=jr([]),[Kt,Cn,Mo]=jr(false),[xt,Jr]=useState(null),[no,oo]=useState([]),[Er,Sr]=useState({}),he=ee?.activeSheet??0,Pe=useMemo(()=>({get current(){return Ne.current?.activeSheet??0}}),[Ne]),mt=useCallback((t,s,m,R)=>({generation:pt.current,sheet:Pe.current,row:s,col:m,value:R,source:t}),[]),Bt=useCallback(t=>{Le(selectionAt({row:t.row,col:t.col})),t.source==="cell"?$e({row:t.row,col:t.col,value:t.value}):Ot(t.value);},[]),ct=useCallback(t=>{if(u$1.draft)return;let s=u$1.rejected.find(m=>m.sheet===t&&m.generation===pt.current);s&&(u$1.setDraft(s),Bt(s));},[u$1,Bt]),ht=useCallback(()=>{u$1.setDraft(null),$e(null),Ot(null);},[u$1]),Zr=useCallback(()=>{Pt.current()&&(Le(null),wt(null),ht(),Lt(null),Ye.current=null,ct(Pe.current),U.refresh());},[ht,ct,Pe,U,Le,wt,Lt]),Xt=useCallback((t,s,m)=>{t.setActiveSheet(s),Ke(t.sheetInfo()),Le(m?structuredClone(m):null),wt(null),ht(),Lt(null),Ye.current=null,ct(s),Re(null),U.refresh();},[ht,ct,U]),Pn=useCallback((t,s)=>{let m=N.current;if(!m||!Number.isInteger(t))return false;try{let R=m.sheetInfo();if(t<0||t>=R.sheetNames.length)return !1;m.cellPosition(t,s.anchor.row,s.anchor.col);let D=m.cellPosition(t,s.focus.row,s.focus.col);return Pt.current()?(Xt(m,t,s),requestAnimationFrame(()=>{let k=J.current;k&&(k.scrollLeft=D.x*Ge.current,k.scrollTop=D.y*Ge.current);}),!0):!1}catch{return false}},[Xt]),Qt=useCallback((t,s,m,R,D)=>{let k=N.current,ie=pt.current;requestAnimationFrame(()=>{let ce=J.current;if(!(!ce||!k||!D()||N.current!==k||pt.current!==ie||Pe.current!==t))try{let ve=Ge.current,Me=Ne.current;Me&&Ke(pa$1(ce,Me,k.cellRect(t,s,m),ve));let Fe=xa(k,t,s,m,R,{x:ce.scrollLeft/ve,y:ce.scrollTop/ve,width:ce.clientWidth/ve,height:ce.clientHeight/ve});Fe.x!==null&&(ce.scrollLeft=Fe.x*ve),Fe.y!==null&&(ce.scrollTop=Fe.y*ve);}catch{}});},[Pe]),Dt=useRef(re);useEffect(()=>{if(Dt.current===re)return;let t=Dt.current;Dt.current=re;let s=Ie.current,m=J.current,R=N.current;if(!s||!m||!R)return;let{row:D,col:k}=s.focus;qa(m,R.cellRect(Pe.current,D,k),t)&&Qt(Pe.current,D,k,"nearest",()=>Ie.current===s);},[re,Qt]),useEffect(()=>{W&&(ht(),Lt(null),Ye.current=null,ze.current=null,qe(null),ft.current=null,Zt(null),Ce.current!=null&&clearTimeout(Ce.current),Ce.current=null);},[W]);let Qr=useMemo(()=>isPngExportAvailable(),[]),Mr=useMemo(()=>isProposalsAvailable(),[]),Gt=useCallback((t,s)=>N.current!==t?Promise.reject(new w("document-replaced")):u$1.runAfterPendingInput(()=>{if(N.current!==t)throw new w("document-replaced");return s()}),[u$1]),Rn=useCallback(async(t,s)=>{try{return {ok:!0,value:await Gt(t,s)}}catch(m){if(!(m instanceof w))throw m;return {ok:false,code:m.code==="document-replaced"||m.code==="editor-unavailable"?"document-replaced":"input-failed",error:m}}},[Gt]),Xr=useCallback((t,s,m,R=D=>D())=>{let D=m?.()??null;if(D)return D;if(Ze.current)return Qn(t);let k=R(()=>t.applyEdits(s));return k.ok&&k.applied&&(_e(t),We.current?.(),U.refresh()),k},[U,_e]),er=useCallback(()=>{let t=N.current;if(!t){_t([]);return}try{_t(t.listProposals());}catch{_t([]);}at(s=>s+1);},[]),cr=useRef({admit:Rn,applyBatch:Xr,navigator:null});cr.current.admit=Rn,cr.current.applyBatch=Xr;let[Or]=useState(()=>{let t=()=>{let s=cr.current.navigator;if(!s)throw new Error("The editor is not ready");return s};return {handle:()=>N.current,admit:(s,m)=>cr.current.admit(s,m),readOnlyRefusal:s=>Ze.current?Qn(s):null,applyEdits:(s,m,R,D)=>cr.current.applyBatch(s,m,R,D),commands:()=>U,navigator:{selectCells:(...s)=>t().selectCells(...s),scrollToCell:(...s)=>t().scrollToCell(...s)}}}),[Oo,io]=useState(null),Ho=useMemo(()=>{let t=ee?.sheetIds[he];return t===void 0?null:{sheetId:t,sheetIndex:he,cells:te?structuredClone(te):null,chartId:ke?.id??null}},[ee,he,te,ke]),zt=Na({plugins:F$1,pluginGrants:M,onPluginError:j$1,access:Or,commands:U,readOnly:W,handle:Oo,selection:Ho,canvasRef:Oe,t:O}),en=zt.beginLoad,Hr=zt.presentGrid,[En,Sn]=Fa(zt.managed);useEffect(()=>{if(pt.current+=1,en(),io(null),ht(),wt(null),ft.current=null,Zt(null),Ce.current!=null&&(clearTimeout(Ce.current),Ce.current=null),_t([]),Sr({}),Cn(false),Jr(null),ar([]),It.current=null,qr.current=void 0,Pr.current=void 0,Lt(null),Te(null),Ye.current=null,yt.current=false,Ct.current=null,!n){N.current=null,Ke(null),Le(null),Re(null);return}N.current=null,Ke(null),Le(null);let t=null,s=()=>{},m=()=>{},R=false,D=()=>{let k=m;m=()=>{};try{k();}catch{}};return initWasm().then(()=>{if(!R)try{t=openWorkbook(n,{collaborative:C$1,clientId:v}),L&&t.applyUpdate(L.slice()),N.current=t,Q$1.current=t.version(),s=t.onUpdate((ce,ve,{fromPeer:Me})=>{if(!(R||!t)){Se.changed(),Tt.current+=1;try{Ke(t.sheetInfo()),at(Fe=>Fe+1),Sr({}),er(),Re(null),_e(t)&&Me&&We.current?.();}catch(Fe){Re(Fe instanceof Error?Fe.message:String(Fe));}}}),yt.current=!0,Ke(t.sheetInfo()),Le(selectionAt({row:0,col:0})),Jr(t),Re(null),er();let k=t,ie=me.current?.({clearSelection:Zr,commands:U.store,handle:t,refreshProposals:er,focus:()=>J.current?.focus(),flushPendingInput:async()=>{if(N.current!==k)throw new w("document-replaced");if(Be.current)throw new w("gesture-active");if(await Gt(k,()=>{}),N.current!==k)throw new w("document-replaced")},getPositionAtPoint:(ce,ve)=>N.current===k?dt.current(ce,ve):null,save:()=>{if(N.current!==k)throw new w("document-replaced");if(kr.current())throw new br("input-failed");if(u$1.pending||S$1.current||ze.current||Be.current)throw new br("input-pending");if(!Pt.current())throw new br("input-failed");return k.save()},selectCells:Pn,version:()=>Gt(k,()=>k.version()),readCells:ce=>Gt(k,()=>k.readCells(ce)),findText:ce=>Gt(k,()=>k.findText(ce)),validateEdits:async ce=>Ze.current&&N.current===k?Qn(k):Gt(k,()=>Ze.current?Qn(k):k.validateEdits(ce)),applyEdits:async ce=>Ze.current&&N.current===k?Qn(k):Gt(k,()=>Xr(k,ce))});typeof ie=="function"&&(m=ie),io(k);}catch(k){D(),s(),s=()=>{},t?.dispose(),t=null,N.current=null,Ke(null),Le(null),Re(k instanceof Error?k.message:String(k));try{Xe.current?.(k instanceof Error?k:new Error(String(k)));}catch{}}},k=>{if(!R){N.current=null,Ke(null),Le(null),Re(k instanceof Error?k.message:String(k));try{Xe.current?.(k instanceof Error?k:new Error(String(k)));}catch{}}}),()=>{R=true,S$1.current?.settle(false),S$1.current=null,D(),s(),t?.dispose(),N.current=null,u$1.reset();}},[n,C$1,v,L,Zr,Gt,Xr,en,U,u$1,_e,er,Pn]),useEffect(()=>{if(!ee||!yt.current)return;let t=J.current;t&&(yt.current=false,t.scrollLeft=ee.initialScrollX*re,t.scrollTop=ee.initialScrollY*re);},[ee,re]),useEffect(()=>{if(!(!le||!xt))return le(xt),()=>le(null)},[le,xt]),useEffect(()=>{if(oo([]),!!oe)return oe.onAwareness(t=>oo([...t]))},[oe]),useEffect(()=>()=>oe?.setCursor(null),[oe]),useEffect(()=>{if(!oe)return;let t=ee?.sheetIds[he];if(!te||!t){oe.setCursor(null);return}let s=normalizeRange(te);oe.setCursor({sheet:t,anchor:te.range?{row:s.top,col:s.left}:{...te.anchor},head:te.range?{row:s.bottom,col:s.right}:{...te.focus}});},[oe,te,ee,he,St]);let Xn=useCallback(()=>{let t=J.current,s=Oe.current;if(!t||!s)return;let m=s.getContext("2d");if(!m)return;let R=window.devicePixelRatio||1,D=t.clientWidth,k=t.clientHeight;if(D===0||k===0)return;s.width=Math.round(D*R),s.height=Math.round(k*R),s.style.width=`${D}px`,s.style.height=`${k}px`;let ie=D/re,ce=k/re,ve={x:t.scrollLeft/re,y:t.scrollTop/re,width:ie,height:ce},Me=N.current,Fe;if(Me)try{Fe=Me.displayList(ve);}catch(sr){Ae.current=null,Ct.current=null,Hr(null),xn(null),Te(sr instanceof Error?sr.message:String(sr));return}else Fe=ya(ie,ce,O("editor.demoCellText"));let Nr=[],Mn=Fe.grid,fr=Mn?Da(Mn):null;if(Me&&fr)try{let sr=Me.cell(he,fr.top,fr.left).a1,Is=Me.cell(he,fr.bottom,fr.right).a1;Nr=Me.mergedRanges(he,`${sr}:${Is}`).slice(0,da);}catch{}paintDisplayList(m,Fe,R*re),Ae.current=Fe,Ct.current={frame:Fe,zoom:re,sheet:he,handle:Me};let rn=null;try{rn=Me?Me.version():null;}catch{}let uo=Ne.current?.sheetIds[he];if(Hr(rn!==null&&uo!==void 0?{frame:Fe,zoom:re,version:rn,sheetId:uo,viewport:ve}:null),Te(null),ar(Nr),It.current={sheet:he,ranges:Nr},xn(Fe),!Me)return;let On={generation:pt.current,mutation:Tt.current,view:`${he}:${re}`};Z.current=On;let fo=xe.current;xe.current=fo.filter(sr=>!ui(On,sr.mark));for(let sr of fo)ui(On,sr.mark)&&sr.resolve(true);},[he,Hr,O,re]);useEffect(()=>{let t=J.current;if(!t)return;let s=()=>{ot.current==null&&(ot.current=requestAnimationFrame(()=>{ot.current=null,Xn();}));};Xn(),t.addEventListener("scroll",s,{passive:true});let m=new ResizeObserver(s);return m.observe(t),()=>{t.removeEventListener("scroll",s),m.disconnect(),ot.current!=null&&(cancelAnimationFrame(ot.current),ot.current=null);}},[Xn,ee,Et,St]);let Wn=useCallback(()=>{let t={generation:pt.current,mutation:Tt.current,view:`${Pe.current}:${Ge.current}`},s=Z.current;return s&&ui(s,t)?Promise.resolve(true):new Promise(m=>{let R={mark:t,resolve:k=>{clearTimeout(D),m(k);}},D=setTimeout(()=>{xe.current=xe.current.filter(k=>k!==R),m(false);},ga);xe.current.push(R);})},[]);useEffect(()=>{let t=N.current;if(!t||!te||!ee){kn(null);return}try{kn(t.cell(he,te.focus.row,te.focus.col));}catch{kn(null);}},[te,ee,he,St]),useEffect(()=>{let t=()=>{Be.current=false,lr(false);};return window.addEventListener("mouseup",t),()=>window.removeEventListener("mouseup",t)},[]);let ur=useMemo(()=>!Qe||!ee?null:buildA11yGrid(Qe,te,ee.sheetNames[he]??"",{gridLabel:O("a11y.gridLabel"),rowHeaderLabel:O("a11y.rowHeaderLabel"),columnHeaderLabel:O("a11y.columnHeaderLabel"),cellLabel:O("a11y.cellLabel"),cellLabelSelected:O("a11y.cellLabelSelected"),emptyCellLabel:O("a11y.emptyCellLabel"),emptyCellLabelSelected:O("a11y.emptyCellLabelSelected")}),[Qe,te,ee,he,O]),ut=useCallback(()=>{J.current?.focus({preventScroll:true});},[]);useEffect(()=>{pe&&Ue.current?.focus({preventScroll:true});},[pe]);let Nt=useCallback(t=>{t.applied&&Se.changed(),Tt.current+=1,Ke(t.sheetInfo),at(s=>s+1),er(),t.applied&&(_e(N.current),We.current?.());},[er,Se,_e]);Rt.current={seal(){if(ze.current)return {refused:"gesture-active"};Mt.current();let t=S$1.current;return t?(t.source==="cell"?(lt.current=true,Ue.current?.blur(),lt.current=false):($.current=true,xr.current?.blur(),$.current=false),{composition:t.done}):{}},sync(){let t=u$1.draft,s=t?.source==="cell"?Ue.current:xr.current;t&&s&&s.value!==t.value&&u$1.setDraft({...t,value:s.value});},write(t){let s=N.current;if(!s)return false;if(Ze.current)return true;try{return s.cell(t.sheet,t.row,t.col).input!==t.value&&Nt(s.editCell(t.sheet,t.row,t.col,t.value)),!0}catch(m){return Re(m instanceof Error?m.message:String(m)),false}},close(t){if(t.source==="formula"){Ot(null);return}let s=document.activeElement===Ue.current;lt.current=true,Ue.current?.blur(),lt.current=false,$e(null),s&&ut();},restore(t){return t.sheet!==Pe.current?false:(Bt(t),true)}},kr.current=()=>u$1.rejected.some(t=>t.generation===pt.current),Pt.current=()=>N.current?(Mt.current(),ze.current=null,qe(null),lr(false),u$1.settle()):false;let Tn=useCallback(t=>{let s=N.current;if(!s)return null;let m=normalizeRange(t),R=s.cell(he,m.top,m.left).a1,D=s.cell(he,m.bottom,m.right).a1;return `${R}:${D}`},[he]),$t=useCallback(()=>oa(Ae.current,(J.current?.clientHeight??0)/re),[re]),je=useCallback((t,s)=>{let m=Oe.current,R=Ae.current?.grid;if(!m||!R)return null;let D=m.getBoundingClientRect();return cellAtPoint(R,(t-D.left)/re,(s-D.top)/re)},[re]),Wt=useCallback((t,s)=>{let m=Oe.current,R=Ct.current;if(!m||!R)return null;let D=m.getBoundingClientRect();return chartRegionAtPoint(R.frame.charts,(t-D.left)/R.zoom,(s-D.top)/R.zoom)},[]),Yt=useMemo(()=>ke?Qe?.charts?.find(t=>t.id===ke.id)??null:null,[Qe,ke]);useEffect(()=>{!ke||!Qe||Qe.charts?.some(t=>t.id===ke.id)||(Mt.current(),ze.current=null,qe(null),wt(null));},[Qe,ke]);let tr=useCallback((t,s,m)=>{let R=N.current;if(!R||W||s===0&&m===0)return;let D=he;u$1.input(()=>{if(!(N.current!==R||Ze.current))try{return Nt(R.moveChart(D,t,s,m)),!0}catch(k){return Re(k instanceof Error?k.message:String(k)),false}});},[he,Nt,W,u$1]),jt=useCallback(()=>{Ce.current!=null&&(clearTimeout(Ce.current),Ce.current=null);let t=ft.current;ft.current=null,Zt(null),t&&tr(t.id,t.dx,t.dy);},[tr]);Mt.current=jt;let An=useCallback((t,s,m)=>{let R=ft.current;R&&R.id!==t&&Mt.current();let D=ft.current??{dx:0,dy:0},k={id:t,dx:D.dx+s,dy:D.dy+m};ft.current=k,Zt({x:k.dx,y:k.dy}),Ce.current!=null&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{Ce.current=null;let ie=ft.current;ft.current=null,Zt(null),ie&&(ie.dx!==0||ie.dy!==0)&&In.current(ie.id,ie.dx,ie.dy);},ha);},[]),In=useRef(tr);In.current=tr,useEffect(()=>{let t=m=>{let R=ze.current;ze.current=null,qe(null),!(!R||m.button!==0)&&tr(R.id,(m.clientX-R.clientX)/re,(m.clientY-R.clientY)/re);},s=()=>{ze.current=null,qe(null),Mt.current();};return window.addEventListener("mouseup",t),window.addEventListener("blur",s),()=>{window.removeEventListener("mouseup",t),window.removeEventListener("blur",s);}},[tr,re]),useEffect(()=>()=>{Ce.current!=null&&clearTimeout(Ce.current),Ce.current=null,ft.current=null;},[]);let Br=useCallback(t=>{let s=N.current,m=Ie.current;if(!s||!m||W)return;let{row:R,col:D}=i(m.focus,Ht()),k=t??"";if(t===void 0)try{k=s.cell(Pe.current,R,D).input;}catch{k="";}$e({row:R,col:D,value:k}),u$1.setDraft(mt("cell",R,D,k));},[Ie,Pe,W,u$1,mt]),dr=useCallback(t=>{if(!N.current||!pe||W)return;let{row:s,col:m,value:R}=pe,D=u$1.draft,k=D?.source==="cell"&&D.row===s&&D.col===m?D:mt("cell",s,m,R);if(!u$1.submit(k))return;lt.current=true,$e(null);let ie=selectionAt({row:s,col:m});Le(t?moveFocus(ie,t,{limits:$t(),hidden:f(Ae.current?.grid),merges:Ht()}):ie),ut(),ct(Pe.current);},[pe,$t,ut,W,u$1,mt,ct]),so=useCallback(()=>{lt.current=true;let t=u$1.draft;t?.source==="cell"&&u$1.discard(t),u$1.setDraft(null),$e(null),ut(),ct(Pe.current);},[ut,u$1,ct]),rr=useCallback(()=>{let t=N.current,s=Ie.current;return !t||!s?null:{handle:t,sheet:Pe.current,range:normalizeRange(s)}},[Ie,Pe]),zr=useCallback(({handle:t,sheet:s,range:m})=>{if(!(N.current!==t||Ze.current))try{let R=e(m,()=>t.selectionData(s,0,0,"usedRange").usedRange);if(!R){Re("Clear exceeds the cell limit");return}return Nt(t.editCells(s,R)),!0}catch(R){return Re(R instanceof Error?R.message:String(R)),false}},[Nt]),tn=useCallback(()=>{let t=rr();t&&!W&&u$1.input(()=>zr(t));},[rr,zr,W,u$1]),nr=useCallback(async({handle:t,sheet:s,range:m},R=false)=>{let D=Se.begin();try{let k=c(m,()=>t.selectionData(s,0,0,"usedRange").usedRange),ie=t.cell(s,k.top,k.left).a1,ce=t.cell(s,k.bottom,k.right).a1,ve=t.rangeCells(s,`${ie}:${ce}`),Me=!R&&typeof ClipboardItem=="function"&&typeof navigator.clipboard.write=="function";return Me?await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([toTsv(ve)],{type:"text/plain"}),"text/html":C(D,toTsv(ve))})]):await navigator.clipboard.writeText(toTsv(ve)),Me&&N.current===t&&Se.capture(D,{owner:t,sheet:s,range:k,cells:ve,cut:!1},Me),!0}catch(k){return Re(k instanceof Error?k.message:String(k)),false}},[Se]),Wr=useCallback(async()=>{let t=rr();t&&await nr(t);},[rr,nr]),lo=useCallback(()=>{let t=rr();if(!t)return;let s=Se.escaped,m=nr(t,true);W||u$1.input(async()=>Se.escaped===s&&await m?zr(t):void 0);},[rr,Se,nr,zr,W,u$1]),Ln=useCallback(()=>{let t=N.current,s=Ie.current,m=s&&k(s,j(t,Pe.current));if(!t||!m||W)return Promise.resolve();m!==s&&Le(m);let R=Se.current,D=(async()=>{try{return await F()}catch(ce){return Re(ce instanceof Error?ce.message:String(ce)),null}})(),k$1=Pe.current,ie=normalizeRange(m);return u$1.input(async()=>{let ce=await D;if(!(ce===null||Ze.current||N.current!==t))try{let{text:ve,html:Me}=ce,Fe=Se.paste(t,ve,ie,Me,k$1,R),Nr=Fe?[]:E(ve);if(!Fe&&Nr.length===0)return;let Mn=Fe?.edits??[],fr=1;return Fe||Nr.forEach((rn,uo)=>{fr=Math.max(fr,rn.length),rn.forEach((On,fo)=>Mn.push({row:ie.top+uo,col:ie.left+fo,input:On}));}),Nt(t.editCells(k$1,Mn)),Ie.current===m&&Pe.current===k$1&&Le({anchor:{row:ie.top,col:ie.left},focus:{row:Fe?.bottom??ie.top+Nr.length-1,col:Fe?.right??ie.left+fr-1}}),!0}catch(ve){return Re(ve instanceof Error?ve.message:String(ve)),false}})},[Ie,Pe,Nt,W,u$1,Le,Se]);useEffect(()=>{let t=N.current;if(!t||!te||!Rr||Fr||W)return;let s=normalizeRange(te);if(`${he}:${s.top}:${s.left}:${s.bottom}:${s.right}`===Ye.current)return;let R=Tn(te);if(!R)return;let D=he,k=Rr;Lt(null),Ye.current=null,u$1.input(()=>{if(!(N.current!==t||Ze.current))try{return Nt(t.applyFormat(D,R,k)),ut(),!0}catch(ie){return Re(ie instanceof Error?ie.message:String(ie)),false}});},[te,Rr,Fr,he,Tn,Nt,ut,W,u$1]);let Dn=useCallback(t=>{l$1&&l$1(t),(c$1??!l$1)&&bs(t,r??"workbook.xlsx",fa);},[l$1,r,c$1]);dt.current=(t,s)=>{let m=Ct.current;return !m?.handle||m.handle!==N.current?null:na(m.frame,m.sheet,Oe.current,t,s)};let e$1=useCallback(()=>{let t=N.current,s=J.current;if(!t||!s)throw new Error("the workbook is not open");let m=t.renderPng({x:s.scrollLeft/re,y:s.scrollTop/re,width:s.clientWidth/re,height:s.clientHeight/re});bs(m,ba(r),"image/png");},[r,re]),o=useCallback(t=>{let s=u$1.draft;!N.current||s?.source!=="formula"||W||u$1.submit(s)&&(Ot(null),t&&Le(m=>m&&moveFocus(m,t,{limits:$t(),hidden:f(Ae.current?.grid),merges:Ht()})),ct(Pe.current));},[u$1,$t,W,ct]),i$1=useCallback(t=>{let s=N.current;if(!s||!te||!ee||pe||wn(t)||q(t))return;let m=t.metaKey||t.ctrlKey,R=t.key.toLowerCase();if(ke){if(t.key==="Escape"){ze.current=null,qe(null),ft.current=null,Zt(null),Ce.current!=null&&(clearTimeout(Ce.current),Ce.current=null),wt(null),t.preventDefault();return}let ce=m?void 0:va[t.key];if(ce){let ve=pa*(t.shiftKey?ma:1);!W&&ke.movable&&An(ke.id,ce[0]*ve,ce[1]*ve),t.preventDefault();}return}if(m){if(R==="c"){Wr(),t.preventDefault();return}if(R==="v"){Ln(),t.preventDefault();return}if(R==="x"){lo(),t.preventDefault();return}}let D=l(t),k;try{k=D?s.selectionData(Pe.current,te.focus.row,te.focus.col,D==="region"?void 0:D):void 0;}catch(ce){if(D!=="usedRange"&&D!=="rowEnd")throw ce;t.preventDefault();return}let ie=selectionKeyReducer(te,{key:t.key,shiftKey:t.shiftKey,metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey},$t(),k,f(Ae.current?.grid),Ht());switch(ie.type){case "move":Le(ie.selection),Qt(Pe.current,ie.selection.focus.row,ie.selection.focus.col,"nearest",()=>Ie.current===ie.selection),t.preventDefault();break;case "startEdit":Br(ie.initialInput),t.preventDefault();break;case "clear":tn(),t.preventDefault();break;}},[te,ee,pe,$t,Wr,Ln,lo,Br,tn,ke,An,Qt,W]),a=useCallback(t=>{if(wn(t))return;let s=pe!=null;if(s&&Ue.current?.contains(t.target))return;ze.current=null,Mt.current();let m=Wt(t.clientX,t.clientY);if(m){s&&dr(),wt({id:m.id,movable:!W&&m.movable}),!W&&m.movable&&t.button===0&&(ze.current={id:m.id,clientX:t.clientX,clientY:t.clientY}),qe(null),vt.current=null,ut(),t.preventDefault();return}if(wt(null),qe(null),!te)return;let R=je(t.clientX,t.clientY);R&&(s&&dr(),t.shiftKey?Le(D=>D&&extendTo(D,R,$t())):Le(selectionAt(i(R,Ht()))),vt.current=s?null:R,Be.current=true,lr(true),ut());},[pe,te,je,Wt,$t,ut,dr,W]),h$1=useCallback(t=>{let s=ze.current;if(wn(t)){s||(t.currentTarget.style.cursor="default",t.currentTarget.title="");return}if(s){if(t.buttons===0){ze.current=null,qe(null);return}t.currentTarget.style.cursor="move",t.currentTarget.title="",qe({x:t.clientX-s.clientX,y:t.clientY-s.clientY});return}let m=je(t.clientX,t.clientY);if(!m){Be.current||(t.currentTarget.style.cursor="default",t.currentTarget.title="");return}if(!Be.current){let R=Wt(t.clientX,t.clientY);if(R){t.currentTarget.style.cursor=!W&&R.movable?"move":"pointer",t.currentTarget.title="";return}let D=Ae.current?hyperlinkAtCell(Ae.current,m.row,m.col):null;t.currentTarget.style.cursor=D?"pointer":"default",t.currentTarget.title=D?.tooltip??"";return}Le(R=>R&&extendTo(R,m,$t()));},[je,Wt,$t,W]),w$1=useCallback(t=>{let s=N.current,m=Ae.current;if(!s||!m||!ee)return false;let R=hyperlinkAtCell(m,t.row,t.col);if(!R)return false;let D=safeExternalHyperlink(R);if(D)return window.open(D,"_blank","noopener,noreferrer"),true;if(!R.location)return true;let k=ee.sheetNames[he]??"",ie=parseHyperlinkLocation(R.location,k);if(!ie)return true;let ce=ee.sheetNames.findIndex(ve=>ve.toLowerCase()===ie.sheetName.toLowerCase());if(ce<0)return true;try{s.setActiveSheet(ce);let ve=s.cellPosition(ce,ie.row,ie.col);Ke(s.sheetInfo()),requestAnimationFrame(()=>{let Me=J.current;Me&&(Me.scrollLeft=ve.x*re,Me.scrollTop=ve.y*re);}),Le(selectionAt({row:ie.row,col:ie.col})),ht(),Lt(null),Ye.current=null,Re(null);}catch(ve){Re(ve instanceof Error?ve.message:String(ve));}return true},[he,ee,re]),P$1=useCallback(t=>{if(wn(t))return;if(pe){vt.current=null;return}let s=je(t.clientX,t.clientY),m=vt.current;vt.current=null,!(!s||!m||s.row!==m.row||s.col!==m.col)&&w$1(s);},[w$1,pe,je]),B=useCallback(t=>{if(pe||wn(t)||Wt(t.clientX,t.clientY))return;let s=je(t.clientX,t.clientY);s&&Ae.current&&hyperlinkAtCell(Ae.current,s.row,s.col)||te&&Br();},[pe,Br,je,Wt,te]),z=useCallback(t=>{t.currentTarget.style.cursor="default",t.currentTarget.title="";},[]),T=Qe?.grid,H$1=te?ua$1(normalizeRange(te),_):null,G=te?ua$1({top:te.focus.row,left:te.focus.col,bottom:te.focus.row,right:te.focus.col},_):null,se=T&&H$1?rangeRect(T,H$1):null,be=T&&G?rangeRect(T,G):null,ge=T&&pe?cellRect(T,pe.row,pe.col):null,Je=se?ta(se,re):null,De=be?ta(be,re):null,et=ge?ta(ge,re):null,or=Yt?ta(Yt.rect,re):null,Fn=ee?ee.contentWidth*re:void 0,ir=ee?ee.contentHeight*re:void 0,qn=p??At?.input??"",ao=t=>{let s=N.current;if(s&&Pt.current())try{s.setActiveSheet(t),yt.current=!0,Le(selectionAt({row:0,col:0})),wt(null),ht(),Lt(null),Ye.current=null,Ke(s.sheetInfo()),ct(t),U.refresh();}catch(m){Re(m instanceof Error?m.message:String(m));}};cr.current.navigator={selectCells(t,s,m,R){let D=xs(t,s?.sheetId),k=s?.selection;return D<0||!di(t,D,k?.anchor?.row,k?.anchor?.col)||!di(t,D,k?.focus?.row,k?.focus?.col)?"missing-target":(Xt(t,D,k),Qt(D,k.focus.row,k.focus.col,"nearest",R),m&&ut(),null)},scrollToCell(t,s,m,R){let D=xs(t,s?.sheetId);return D<0||!di(t,D,s.row,s.col)?"missing-target":(D!==Pe.current&&Xt(t,D,null),Qt(D,s.row,s.col,m,R),null)}};let Es={requestSave:Q({document:()=>N.current,onSaveRequest:y,fail:t=>Re(t instanceof Error?t.message:String(t))}),handle:()=>N.current,status:()=>N.current?"ready":n&&!Et?"loading":"empty",readOnly:()=>Ze.current,collaborative:()=>C$1,mutation:()=>Tt.current,generation:()=>pt.current,view:()=>({sheet:Pe.current,selection:Ie.current,chartSelected:ye.current!==null,zoom:Ge.current,capturedFormat:Do.current,borderStyle:qr.current,borderColor:Pr.current,proposals:qo.current,proposalsAvailable:Mr,proposalsPanelOpen:Mo.current,pngExport:Qr}),coordinator:u$1,i18n:()=>K,translate:O,apply:Nt,fail:t=>Re(t instanceof Error?t.message:String(t)),setZoom:bt,setProposalsPanelOpen:Cn,setCapturedFormat:(t,s)=>{Lt(t),Ye.current=s;},setBorderStyle:t=>{qr.current=t;},setBorderColor:t=>{Pr.current=t;},markStale:(t,s)=>Sr(({[t]:m,...R})=>s?{...R,[t]:s}:R),refreshProposals:er,deliver:Dn,exportPng:e$1,afterPaint:Wn,focusGrid:ut};zi(U,Es),P(U,it);let fi=t=>{let s=()=>{},m=new Promise(R=>{s=D=>setTimeout(()=>R(D),0);});S$1.current={source:t,done:m,settle:s};},pi=()=>{S$1.current?.settle(true),S$1.current=null;},co=useCallback(t=>{let s=S$1.current;s?.source===t&&(s.settle(false),S$1.current=null);},[]),Ss=useCallback(t=>{Ue.current=t,t||co("cell");},[co]),Xs=useCallback(t=>{xr.current=t,t||co("formula");},[co]),mi=!W&&te!==null&&ke===null,Ws={onNavigate:t=>{Pn(Pe.current,selectionAt(t)),ut();},a1:At?.a1??"",value:qn,disabled:!ee||!te,readOnly:!mi,inputRef:Xs,onChange:t=>{let s=Ie.current;if(!mi||Ze.current||!s||ye.current)return;Ot(t);let m=i(s.focus,Ht());u$1.setDraft(mt("formula",m.row,m.col,t));},onCommit:t=>{o(t),ut();},onCancel:()=>{let t=u$1.draft;t?.source==="formula"&&(u$1.discard(t),u$1.setDraft(null)),Ot(null),ut(),ct(he);},onBlur:()=>{$.current||o();},onCompositionStart:()=>fi("formula"),onCompositionEnd:pi},Ts=jsxs(ma$1,{mode:"commands",children:[jsx(ma$1.Toolbar,{}),jsxs("div",{style:to.rail,role:"group","aria-label":O("toolbar.formulaBarLabel"),children:[jsx(ma$1.FormulaBar,{}),jsx("div",{style:X,"aria-hidden":"true"}),jsx(va$1,{peers:no,sheetIds:ee?.sheetIds??[],sheetNames:ee?.sheetNames??[],activeSheet:he}),Mr&&jsx("div",{style:to.proposals,children:jsx(Ea,{})})]})]}),hi=g?V===void 0?W?null:Ts:V:null,Bo=t=>zt.managed?jsx(Ga,{host:zt.host,placement:t,activations:zt.activations.filter(s=>s.plugin.panel?.placement===t),available:Sn}):null,As=jsxs("div",{ref:it,className:E$1,role:"application","aria-label":O("editor.appLabel"),onKeyDownCapture:t=>{!wn(t)&&t.key==="Escape"&&Se.escape();},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",...b},children:[n&&!N.current&&!Et&&d,hi!=null&&jsx("div",{"data-testid":"xlsx-toolbar",style:V===void 0?to.shell:to.host,children:hi}),jsxs("div",{ref:En,"data-testid":"xlsx-workspace",style:Ps.workspace,children:[Bo("left"),jsxs("div",{style:Ps.center,children:[Mr&&Kt&&jsx(xa$1,{proposals:Fo,staleFor:Er,style:{top:4,right:8,width:"min(320px, calc(100% - 16px))",maxHeight:"min(420px, calc(100% - 12px))"}}),jsxs("div",{ref:J,"data-testid":"xlsx-scroll",tabIndex:0,onKeyDown:i$1,onMouseDown:a,onMouseMove:h$1,onMouseLeave:z,onClick:P$1,onDoubleClick:B,style:{position:"relative",flex:1,overflow:"auto",minHeight:0,outline:"none"},children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:Fn??"100%",height:ir??"100%"}}),jsxs("div",{style:{position:"sticky",top:0,left:0,width:0,height:0},children:[jsx("canvas",{ref:Oe,style:{display:"block",position:"absolute",top:0,left:0}}),zt.managed&&jsx(Ba,{host:zt.host,activations:zt.activations,layerRef:zt.overlayLayerRef,width:(Qe?.width??0)*re,height:(Qe?.height??0)*re}),jsxs("div",{"data-testid":"xlsx-overlay-host",style:{position:"absolute",top:0,left:0,width:0,height:0,pointerEvents:"none"},children:[Je&&!ke&&jsx("div",{"data-testid":"xlsx-selection",style:{position:"absolute",left:Je.x,top:Je.y,width:Je.w,height:Je.h,boxSizing:"border-box",border:`1px solid ${eo}`,background:"rgba(33, 115, 70, 0.12)"}}),or&&jsx("div",{"data-testid":"xlsx-chart-selection","data-chart-id":ke?.id,"aria-hidden":true,style:{position:"absolute",left:or.x+(st?.x??0)+(ue?.x??0)*re,top:or.y+(st?.y??0)+(ue?.y??0)*re,width:or.w,height:or.h,boxSizing:"border-box",border:`2px solid ${eo}`,boxShadow:"0 1px 6px rgba(0, 0, 0, 0.25)",background:st?"rgba(33, 115, 70, 0.08)":"transparent"}}),De&&!ke&&!pe&&jsx("div",{style:{position:"absolute",left:De.x,top:De.y,width:De.w,height:De.h,boxSizing:"border-box",border:`2px solid ${eo}`}}),jsx(wa$1,{peers:no,grid:T,sheetIds:ee?.sheetIds??[],activeSheet:he,zoom:re,mergedRanges:_}),!W&&pe&&et&&jsx("input",{ref:Ss,"data-testid":"xlsx-cell-editor",value:pe.value,onChange:t=>{let s=t.target.value;$e(m=>m&&{...m,value:s}),pe&&u$1.setDraft(mt("cell",pe.row,pe.col,s));},onCompositionStart:()=>fi("cell"),onCompositionEnd:pi,onKeyDown:t=>{q(t)||t.stopPropagation(),!(t.nativeEvent.isComposing||t.keyCode===229)&&(t.key==="Enter"?(dr(t.shiftKey?"up":"down"),t.preventDefault()):t.key==="Tab"?(dr(t.shiftKey?"left":"right"),t.preventDefault()):t.key==="Escape"&&(so(),t.preventDefault()));},onBlur:()=>{if(lt.current){lt.current=false;return}dr();},style:{position:"absolute",left:et.x,top:et.y,width:et.w,height:et.h,boxSizing:"border-box",border:`2px solid ${eo}`,padding:"0 3px",font:`${13*re}px system-ui, sans-serif`,background:"#ffffff",pointerEvents:"auto",outline:"none"}})]})]})]}),Bo("bottom")]}),Bo("right")]}),ur&&jsxs(Fragment,{children:[jsxs("div",{style:Cs,role:"grid","aria-label":ur.label,children:[jsxs("div",{role:"row",children:[jsx("span",{role:"columnheader"}),ur.columnHeaders.map(t=>jsx("span",{role:"columnheader",children:t.label},t.col))]}),ur.rows.map(t=>jsxs("div",{role:"row",children:[jsx("span",{role:"rowheader",children:t.header}),t.cells.map(s=>jsx("span",{role:"gridcell","aria-selected":s.selected,children:s.label},s.col))]},t.row))]}),ur.charts.map((t,s)=>jsx("div",{style:Cs,role:"img","aria-label":t.label},`${s}:${t.label}`))]}),Cr&&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:Cr}),Et&&jsx(ya$1,{kind:"open",details:Et}),ee&&ee.sheetNames.length>0&&jsx("div",{"data-testid":"xlsx-sheet-tabs",role:"tablist","aria-label":O("editor.sheetTabsLabel"),style:{display:"flex",gap:2,padding:"4px 6px",borderTop:"1px solid #e0e0e0",background:"#fafafa",overflowX:"auto"},children:ee.sheetNames.map((t,s)=>{let m=s===ee.activeSheet;return jsx("button",{role:"tab","aria-selected":m,onClick:()=>ao(s),style:{border:"none",padding:"4px 12px",cursor:"pointer",borderBottom:m?`2px solid ${eo}`:"2px solid transparent",fontWeight:m?600:400,background:m?"#ffffff":"transparent"},children:t},s)})})]});return jsx(I.Provider,{value:U.store,children:jsx(S.Provider,{value:true,children:jsx(Y.Provider,{value:Ws,children:As})})})}function Ea(){let n=M("proposalsPanel"),r=n.state.value??0;return jsxs($,{testId:"xlsx-proposals-button",onClick:()=>{n.execute();},disabled:!n.state.enabled,description:n.state.enabled?void 0:n.state.disabledReason.message,active:n.state.active===true,toggle:true,ariaExpanded:n.state.active===true,title:n.label,style:{width:r>0?42:28},children:[jsx(_,{name:"proposals",size:18}),r>0&&jsx("span",{"data-testid":"xlsx-proposals-count",style:to.count,children:r})]})}export{Pa as XlsxEditor,br as XlsxSaveRefusedError,Zn as XlsxWorkerEditorChunkLoadError};