efficient-office 0.12.0 → 0.13.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/Slides-JLWEMUXJ.js +1 -0
- package/dist/SlidesEditor-DGK4W6W4.js +1 -0
- package/dist/Spreadsheet-WQOZPWY5.js +1 -0
- package/dist/chunk-5K2D7PBJ.js +1 -0
- package/dist/chunk-AJTH75FI.js +1 -0
- package/dist/chunk-BDVKNU3U.js +1 -0
- package/dist/chunk-CEVQKZ66.js +1 -0
- package/dist/chunk-EDJRXJNE.js +1 -0
- package/dist/chunk-EP3ZNVDB.js +1 -0
- package/dist/{chunk-DG4VDXLL.js → chunk-HQM2HX4V.js} +1 -1
- package/dist/chunk-PX4QOBHF.js +1 -0
- package/dist/{chunk-MDG2ADZ7.js → chunk-R2CXMNZL.js} +1 -1
- package/dist/chunk-T2TZ7HF5.js +1 -0
- package/dist/chunk-VYLIT7NN.js +1 -0
- package/dist/{chunk-MR7ZWQHF.js → chunk-WAB44FLE.js} +1 -1
- package/dist/{chunk-NRGUS5QY.js → chunk-XENQLN5I.js} +1 -1
- package/dist/deckPdf-KZFS4CTF.js +1 -0
- package/dist/documents/index.js +1 -1
- package/dist/docxPdf-S4RXU4L2.js +1 -0
- package/dist/importSpreadsheet-L5FJGRUV.js +1 -0
- package/dist/{pptxImport-OACGHWQ6.js → pptxImport-UQQXZUQL.js} +1 -1
- package/dist/slides/index.d.ts +213 -17
- package/dist/slides/index.js +1 -1
- package/dist/slides/slides.css +53 -0
- package/dist/spreadsheet/index.d.ts +2 -1
- package/dist/spreadsheet/index.js +1 -1
- package/dist/workbookPdf-K65CQX4K.js +1 -0
- package/dist/xlsxFile-3GXD4KW5.js +1 -0
- package/package.json +1 -1
- package/dist/Slides-YZQXZJX4.js +0 -1
- package/dist/SlidesEditor-ETCUQVJ7.js +0 -1
- package/dist/Spreadsheet-VWRRB6FE.js +0 -1
- package/dist/chunk-3RFDQOTI.js +0 -1
- package/dist/chunk-ADXHTZ3Q.js +0 -1
- package/dist/chunk-B2X3NIQR.js +0 -1
- package/dist/chunk-BGAR3P46.js +0 -1
- package/dist/chunk-JKYJGXJE.js +0 -1
- package/dist/chunk-PXOQN7D6.js +0 -1
- package/dist/chunk-Q7NVDOCX.js +0 -1
- package/dist/chunk-UKGIT2RS.js +0 -1
- package/dist/chunk-ZS45QEF4.js +0 -1
- package/dist/deckPdf-4RC7QJ45.js +0 -1
- package/dist/docxPdf-QSMEFCUF.js +0 -1
- package/dist/importSpreadsheet-IRN32JON.js +0 -1
- package/dist/workbookPdf-CQTTURQ5.js +0 -1
- package/dist/xlsxFile-SX767BIH.js +0 -1
package/dist/slides/slides.css
CHANGED
|
@@ -153,6 +153,59 @@
|
|
|
153
153
|
.slides-starter:hover { border-color: var(--slides-accent); }
|
|
154
154
|
.slides-starter-thumb { display: block; width: 128px; height: 72px; overflow: hidden; border-radius: 3px; }
|
|
155
155
|
.slides-starter-blank { display: block; width: 100%; height: 100%; background: #ffffff; border: 1px solid var(--line); box-sizing: border-box; }
|
|
156
|
+
|
|
157
|
+
/* 0.11: the Tier 1 and 2 additions (mockup approved 2026-11-16). */
|
|
158
|
+
.slides-pane[data-zoomed] { overflow: auto; align-items: flex-start; justify-content: flex-start; }
|
|
159
|
+
.slides-pane[data-zoomed] .slides-stage-frame { margin: 24px; }
|
|
160
|
+
.slides-stage-frame { position: relative; flex: none; }
|
|
161
|
+
.slides-stage-frame[data-rulers] { padding: 20px 0 0 20px; }
|
|
162
|
+
.slides-ruler { position: absolute; background: var(--surface); color: var(--ink); opacity: 0.85; font-size: 9px; overflow: hidden; pointer-events: none; }
|
|
163
|
+
.slides-ruler-top { top: 0; left: 20px; border-bottom: 1px solid var(--line); }
|
|
164
|
+
.slides-ruler-left { top: 20px; left: 0; border-right: 1px solid var(--line); }
|
|
165
|
+
.slides-ruler span { position: absolute; }
|
|
166
|
+
.slides-ruler-top span { bottom: 0; height: 5px; border-left: 1px solid var(--line); padding-left: 2px; line-height: 1; }
|
|
167
|
+
.slides-ruler-top span[data-major] { height: 14px; }
|
|
168
|
+
.slides-ruler-left span { right: 0; width: 5px; border-top: 1px solid var(--line); writing-mode: vertical-rl; transform: rotate(180deg); line-height: 1; }
|
|
169
|
+
.slides-ruler-left span[data-major] { width: 14px; }
|
|
170
|
+
.slides-stage[data-drawing] { cursor: crosshair; }
|
|
171
|
+
.slides-drawn { position: absolute; left: 0; top: 0; color: var(--slides-accent); pointer-events: none; }
|
|
172
|
+
.slides-zoom { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 4px 12px; font-size: 12px; background: var(--surface-raised); border-top: 1px solid var(--line); }
|
|
173
|
+
.slides-zoom-value { min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
|
|
174
|
+
.slides-present { display: inline-flex; align-items: center; gap: 2px; }
|
|
175
|
+
|
|
176
|
+
.slides-segmented { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
|
|
177
|
+
.slides-segmented button { flex: 1; padding: 4px 8px; font-size: 12px; background: transparent; color: inherit; border: 0; border-left: 1px solid var(--line); cursor: pointer; }
|
|
178
|
+
.slides-segmented button:first-child { border-left: 0; }
|
|
179
|
+
.slides-segmented button[aria-checked='true'] { background: var(--slides-accent); color: var(--submit-fg, #fff); }
|
|
180
|
+
.slides-segmented-wrap { flex-wrap: wrap; }
|
|
181
|
+
.slides-segmented-wrap button { flex: 1 1 45%; border-top: 1px solid var(--line); }
|
|
182
|
+
|
|
183
|
+
.slides-sorter-pane { flex-direction: column; align-items: stretch; justify-content: flex-start; }
|
|
184
|
+
.slides-sorter-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 12px; background: var(--surface); }
|
|
185
|
+
.slides-sorter { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; padding: 16px; align-content: start; }
|
|
186
|
+
.slides-sorter-tile { display: flex; flex-direction: column; gap: 4px; width: fit-content; cursor: pointer; border-radius: 4px; outline: none; }
|
|
187
|
+
.slides-sorter-tile > div:first-child { border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
|
|
188
|
+
.slides-sorter-tile[data-picked] > div:first-child { outline: 2px solid var(--slides-accent); outline-offset: 1px; }
|
|
189
|
+
.slides-sorter-tile[data-skipped] > div:first-child { opacity: 0.5; }
|
|
190
|
+
.slides-sorter-tile[data-drop] { box-shadow: -4px 0 0 var(--slides-accent); }
|
|
191
|
+
.slides-sorter-tile:focus-visible > div:first-child { outline: 2px solid var(--slides-accent); }
|
|
192
|
+
.slides-sorter-number { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; opacity: 0.7; }
|
|
193
|
+
.slides-thumb[data-picked] .slides-thumb-image { outline: 2px solid var(--slides-accent); outline-offset: 1px; opacity: 0.85; }
|
|
194
|
+
|
|
195
|
+
.slides-import { display: flex; flex-direction: column; gap: 12px; }
|
|
196
|
+
.slides-import-source { flex: 1; min-width: 0; }
|
|
197
|
+
.slides-import-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 10px; max-height: 360px; overflow: auto; }
|
|
198
|
+
.slides-import-tile { padding: 0; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; background: transparent; cursor: pointer; width: fit-content; }
|
|
199
|
+
.slides-import-tile[aria-selected='true'] { outline: 2px solid var(--slides-accent); outline-offset: 1px; }
|
|
200
|
+
.slides-print { display: flex; flex-direction: column; gap: 12px; }
|
|
201
|
+
|
|
202
|
+
.slides-layouts { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
|
|
203
|
+
.slides-layout-row { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 8px; font-size: 12px; }
|
|
204
|
+
.slides-layout-row > div:first-child { border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
|
|
205
|
+
|
|
206
|
+
.slides-assigned { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 0 4px; color: var(--slides-accent); }
|
|
207
|
+
.slides-link-button { margin-left: auto; padding: 0; border: 0; background: none; color: inherit; font-size: 12px; text-decoration: underline; cursor: pointer; }
|
|
208
|
+
.slides-presenter-current[data-laser] { cursor: none; }
|
|
156
209
|
/* The file list Documents and Spreadsheet share (./FileList.tsx), laid out as
|
|
157
210
|
Slides' deck list is. The build appends this to documents.css and
|
|
158
211
|
spreadsheet.css, so a host loads it with the app's own stylesheet. */
|
|
@@ -240,7 +240,8 @@ declare const SPREADSHEET_EXTENSIONS: readonly string[];
|
|
|
240
240
|
* SUBTOTAL: CHAR, CLEAN, CODE, ISERR, ISEVEN, ISODD, MAXIFS, MINIFS, MROUND,
|
|
241
241
|
* PERCENTILE, QUARTILE, QUOTIENT, the three REGEX functions and SUBTOTAL), and of
|
|
242
242
|
* its date functions (DATEVALUE, ISOWEEKNUM, NETWORKDAYS.INTL, TIMEVALUE, WEEKNUM,
|
|
243
|
-
* WORKDAY, WORKDAY.INTL and YEARFRAC)
|
|
243
|
+
* WORKDAY, WORKDAY.INTL and YEARFRAC), and of its finance functions and HYPERLINK
|
|
244
|
+
* (HYPERLINK, IPMT, IRR, NPER, PPMT, RATE, XIRR and XNPV).
|
|
244
245
|
*/
|
|
245
246
|
|
|
246
247
|
interface SpreadsheetWords {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SPREADSHEET_EXTENSIONS as e,SpreadsheetWordsProvider as t,SpreadsheetsConflict as n,SpreadsheetsProvider as s}from"../chunk-
|
|
1
|
+
import{SPREADSHEET_EXTENSIONS as e,SpreadsheetWordsProvider as t,SpreadsheetsConflict as n,SpreadsheetsProvider as s}from"../chunk-XENQLN5I.js";import{ENGLISH_WORDS as r,ZH_HANS_WORDS as o}from"../chunk-BDVKNU3U.js";import{cellDisplay as a,cellLabel as i,changeStructure as l,clearValues as c,colIndex as h,commitEntry as u,isFormula as p,makeEvaluator as m,newSheet as d,parseRangeLabel as f,rangeLabel as w,renameSheet as g,sortRange as b,updateFormats as k,usedBounds as S}from"../chunk-5K2D7PBJ.js";import{ENGLISH_FILE_WORDS as j,ZH_HANS_FILE_WORDS as y}from"../chunk-B32ASXHM.js";import{hasExtension as _}from"../chunk-XYVQTQ6N.js";import{lazy as x}from"react";var v=class extends Error{};function L(e,t,n){if(!t)return Math.min(n,e.length-1);const s=e.findIndex(e=>e.name.toLowerCase()===t.trim().toLowerCase());if(s<0)throw new v(`there is no sheet "${t}" any more`);return s}function P(e){const t=f(e);if(!t)throw new v(`"${e}" is not a range`);return t}function Q(e,t,n){return e.map((e,s)=>s===t?n(e):e)}function W(e,t){const n={...e},s=(e,t)=>{void 0!==t&&(null===t||!1===t?delete n[e]:n[e]=t)};return s("bold",t.bold),s("italic",t.italic),s("underline",t.underline),s("align",t.align),s("fill",t.fill),s("color",t.color),s("numFmt",t.numFmt),n}function M(e,t,n){let s=e;for(const e of n)switch(e.op){case"add_sheet":if(s.some(t=>t.name.toLowerCase()===e.name.toLowerCase()))throw new v(`there is already a sheet "${e.name}"`);s=[...s,d(e.name)];break;case"rename_sheet":s=g(s,L(s,e.sheet,t),e.name);break;case"set_cells":{const n=L(s,e.sheet,t),r=P(e.start);s=Q(s,n,t=>{let n=t;return e.values.forEach((e,t)=>e.forEach((e,s)=>{n=u(n,r.r1+t,r.c1+s,e)})),n});break}case"clear":s=Q(s,L(s,e.sheet,t),t=>c(t,P(e.range)));break;case"insert_rows":case"delete_rows":{const n=L(s,e.sheet,t);s=l(s,n,"row",e.at-1,"insert_rows"===e.op?e.count:-e.count);break}case"insert_columns":case"delete_columns":{const n=L(s,e.sheet,t);s=l(s,n,"col",h(e.at),"insert_columns"===e.op?e.count:-e.count);break}case"sort":{const n=L(s,e.sheet,t),r=m(s);s=Q(s,n,t=>b(t,n,r,P(e.range),h(e.by),!e.descending));break}case"format":s=Q(s,L(s,e.sheet,t),t=>k(t,P(e.range),t=>W(t,e.format)));break;default:throw new v("this spreadsheet does not make that change")}return s}function X(){let e=null,t={open:!1,title:"",selection:null};const n=new Set,s=new Map,r=e=>{if(e.open!==t.open||e.title!==t.title||e.selection?.sheet!==t.selection?.sheet||e.selection?.range!==t.selection?.range){t=e;for(const e of n)e()}};return{getState:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),attach:t=>(e=t,s.clear(),()=>{e===t&&(e=null,s.clear(),r({open:!1,title:"",selection:null}))}),changed(){if(!e)return;const t=e.sheets(),n=e.selection();r({open:!0,title:e.title(),selection:n&&t[n.sheet]?{sheet:t[n.sheet].name,range:w(n.range)}:null})},snapshot:()=>e?function(e,t,n,s){const r=m(t);return{title:e,sheets:t.map((e,t)=>{const n=S(e),s=[],o={};if(n)for(let l=0;l<=Math.min(n.row,4999);l++){const n=[],c=Math.min(e.cells[l]?.length??0,200);for(let s=0;s<c;s++){const c=e.cells[l][s]??"";""!==c?(n.push(a(e,t,r,l,s).text),p(c)&&(o[i(l,s)]=c)):n.push("")}s.push(n)}return{name:e.name,rows:s,formulas:o}}),activeSheet:Math.min(n,t.length-1),selection:s?{sheet:s.sheet,range:w(s.range)}:null}}(e.title(),e.sheets(),e.activeSheet(),e.selection()):null,apply(t,n){if(!e)return{applied:!1,reason:"the spreadsheet is closed"};if(s.has(t))return{applied:!0};const r=e.sheets();let o;try{o=M(r,e.activeSheet(),n)}catch(e){return{applied:!1,reason:e instanceof v?e.message:"it no longer fits the sheet"}}return e.commit(o),s.set(t,{before:r,after:o}),{applied:!0}},undo(t){const n=s.get(t);return e&&n?e.sheets()!==n.after?{applied:!1,reason:"the sheet has changed since"}:(e.undoLast(),s.delete(t),{applied:!0}):{applied:!1,reason:"the spreadsheet has been closed since"}}}}var C=x(()=>import("../Spreadsheet-WQOZPWY5.js")),F=x(()=>import("../Spreadsheet-WQOZPWY5.js").then(e=>({default:e.SpreadsheetById}))),K=x(()=>import("../Spreadsheet-WQOZPWY5.js").then(e=>({default:e.SpreadsheetPane}))),B={"/spreadsheet":{component:C,label:"Spreadsheets",size:"2xl",appStyle:!0,multiInstance:!0}};async function E(e){const{readXlsx:t}=await(import("../xlsxFile-3GXD4KW5.js"));return t(e)}async function I(e,t){const{workbookToPdf:n}=await(import("../workbookPdf-K65CQX4K.js"));return n(e,t)}async function N(e,t){const{importSpreadsheetFile:n}=await(import("../importSpreadsheet-L5FJGRUV.js"));return n(e,t)}export{j as ENGLISH_FILE_WORDS,r as ENGLISH_WORDS,e as SPREADSHEET_EXTENSIONS,v as SheetEditRefused,C as Spreadsheet,F as SpreadsheetEditor,K as SpreadsheetPane,t as SpreadsheetWordsProvider,n as SpreadsheetsConflict,s as SpreadsheetsProvider,y as ZH_HANS_FILE_WORDS,o as ZH_HANS_WORDS,M as applySheetOps,X as createSheetBridge,_ as hasExtension,N as importSpreadsheetFile,E as readXlsx,B as spreadsheetApp,I as workbookToPdf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{rowPageStarts as t}from"./chunk-PWF37Y2N.js";import{ENGLISH_WORDS as e}from"./chunk-BDVKNU3U.js";import{DEFAULT_COL_WIDTH as o,cellDisplay as n,filteredRows as r,formatKey as s,makeEvaluator as a,usedBounds as i}from"./chunk-5K2D7PBJ.js";import{jpegPdf as c}from"./chunk-CEVQKZ66.js";import{drawJpeg as l,embeddedFonts as d,openStage as p,settled as h}from"./chunk-PX4QOBHF.js";import"./chunk-B32ASXHM.js";var m=t=>t*(4/3),f=m(842),u=m(595),w=f-2*m(36),g=u-2*m(36),y="Calibri,Carlito,Arial,sans-serif",b=t=>Array.from({length:t},(t,e)=>e);function x(t,e,a){const c=i(t);if(!c)return{name:t.name,widths:[],rows:[],headerRows:0};const l=new Set([...t.hiddenRows,...r(t,e,a)]),d=new Set(t.hiddenCols),p=b(c.col+1).filter(t=>!d.has(t)),h=b(c.row+1).filter(t=>!l.has(t)).map(o=>p.map(r=>{const{text:i,align:c,color:l}=n(t,e,a,o,r),d=t.formats[s(o,r)];return{text:i,align:d?.align??c,color:d?.color??l,format:d}}));return{name:t.name,widths:p.map(e=>t.colWidths[e]??o),rows:h,headerRows:Math.min(Math.max(t.frozenRows,1),h.length)}}function R(t){const e=document.createElement("td");e.textContent=t.text;const{format:o}=t;return e.style.cssText=`border:.5pt solid #bbb;padding:1pt 3pt;vertical-align:top;overflow-wrap:anywhere;white-space:pre-wrap;text-align:${t.align}`,t.color&&(e.style.color=t.color),o?.fill&&(e.style.background=o.fill),o?.bold&&(e.style.fontWeight="700"),o?.italic&&(e.style.fontStyle="italic"),o?.fontSize&&(e.style.fontSize=`${o.fontSize}pt`),e}function v(t){const e=document.createElement("tr");return e.append(...t.map(R)),e}function E(t,e){const o=document.createElement("table"),n=t.widths.reduce((t,e)=>t+e,0);o.style.cssText=`border-collapse:collapse;table-layout:fixed;width:${n}px;font:10pt ${y};color:#000`;const r=document.createElement("colgroup");r.append(...t.widths.map(t=>Object.assign(document.createElement("col"),{style:`width:${t}px`})));const s=document.createElement("tbody");return s.append(...e.map(v)),o.append(r,s),o}function $(t){const e=document.createElement("div");return e.textContent=t,e.style.cssText=`font:600 13pt ${y};color:#000;margin-bottom:6pt`,e}function k({table:t,scale:e,starts:o},n){const r=document.createElement("div");if(r.style.cssText=`position:relative;overflow:hidden;background:#fff;width:${f}px;height:${u}px;padding:${m(36)}px;box-sizing:border-box`,r.append($(t.name)),t.rows.length){const s=o[n+1]??t.rows.length,a=E(t,[...t.rows.slice(0,t.headerRows),...t.rows.slice(o[n],s)]);a.style.transform=`scale(${e})`,a.style.transformOrigin="0 0",r.append(a)}return r}async function C(t,e,o,n){e.append(t);try{await h(t);return{jpeg:await l(t,{width:f,height:u,pixelRatio:2,quality:n,fontCss:o}),width:842,height:595}}finally{t.remove()}}async function j(o,n={}){const{signal:r,onProgress:s,quality:i}=n;r?.throwIfAborted();const l=p();try{const n=a(o),p=o.map((e,o)=>function(e,o){const n=e.widths.reduce((t,e)=>t+e,0),r=n>w?w/n:1,s=$(e.name),a=E(e,e.rows);o.append(s,a);const i=s.getBoundingClientRect().height+m(6),c=Array.from(a.querySelectorAll("tr"),t=>t.getBoundingClientRect().height);s.remove(),a.remove();const l=c.slice(0,e.headerRows).reduce((t,e)=>t+e,0),d=(g-i)/r,p=t(c.slice(e.headerRows),d,l).map(t=>t+e.headerRows);return{table:e,scale:r,starts:p}}(x(e,o,n),l.root)),h=p.reduce((t,e)=>t+e.starts.length,0),f=await d(l.root),u=[];for(const t of p)for(const o of t.starts.keys())r?.throwIfAborted(),u.push(await C(k(t,o),l.root,f,i).catch(t=>{throw new Error(e.pdfPageFailed(u.length+1),{cause:t})})),s?.(u.length,h);return c(u)}finally{l.close()}}export{x as sheetTable,j as workbookToPdf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readXlsx as o,unzip as r,writeXlsx as m,zip as p}from"./chunk-WAB44FLE.js";import"./chunk-5K2D7PBJ.js";export{o as readXlsx,r as unzip,m as writeXlsx,p as zip};
|
package/package.json
CHANGED
package/dist/Slides-YZQXZJX4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{FileList as e}from"./chunk-PMGQ5GUH.js";import{importDeckFile as t}from"./chunk-ADXHTZ3Q.js";import{PptxPasswordError as n,PptxUnreadableError as i}from"./chunk-MDG2ADZ7.js";import{STARTERS as s,starterDeck as l}from"./chunk-Q7NVDOCX.js";import{useSlidesHost as o,useSlidesWords as r}from"./chunk-BGAR3P46.js";import{SlideView as a}from"./chunk-B2X3NIQR.js";import"./chunk-PXOQN7D6.js";import"./chunk-B32ASXHM.js";import{placeCopy as c}from"./chunk-XYVQTQ6N.js";import{lazy as d,Suspense as m,useCallback as p,useEffect as u,useState as h}from"react";import{Button as f,EmptyState as k,IconButton as y,toast as b}from"efficient-shell/ui";import{Icon as N}from"efficient-shell/icons";import{jsx as v,jsxs as C}from"react/jsx-runtime";var w=e=>({title:e.placeholderTitle,subtitle:e.placeholderSubtitle,body:e.placeholderBody,dealerPitch:e.dealerPitch,monthlyReport:e.monthlyReport}),D=d(()=>import("./SlidesEditor-ETCUQVJ7.js")),j=["pptx"];function F({id:e,onClose:t,note:n}){const i=r(),{store:s}=o(),[l,a]=h(null),[c,d]=h(!1),[b,w]=h(n??null),j=p(()=>{s.get(e).then(e=>a(t=>({deck:e,nonce:(t?.nonce??0)+1})),()=>d(!0))},[e,s]);if(u(j,[j]),c)return v("div",{className:"slides-list-empty",children:v(k,{title:i.openFailed,children:v(f,{onClick:t,children:i.backToDecks})})});if(!l)return null;const F=v(m,{fallback:null,children:v(D,{deck:l.deck,onClose:t,onReload:j},l.nonce)});return b?C("div",{className:"slides-with-note",children:[C("div",{className:"slides-import-note",role:"status",children:[v(N,{name:"info",size:16}),v("span",{children:b}),v(y,{"aria-label":i.dismiss,onClick:()=>w(null),children:v(N,{name:"close",size:14})})]}),v("div",{className:"slides-with-note-body",children:F})]}):F}function P(){const d=r(),{store:m,canCreate:u=!0,canDelete:f=!0,chooseFile:k,storeImage:y}=o(),[N,D]=h(null),[P,g]=h(null),x=p(()=>m.list(),[m]);if(N)return v(F,{id:N.id,note:N.note,onClose:()=>D(null)});const Q=u&&v("div",{className:"slides-starters","aria-label":d.startFrom,role:"group",children:s.map(e=>{const t="blank"===e?null:l(e,w(d));return C("button",{type:"button",className:"slides-starter",disabled:!!P,onClick:()=>{(async e=>{if(!P)try{const t=await m.create("blank"===e?d.untitledDeck:d.starterName(e));"blank"!==e&&await m.save(t.id,l(e,w(d)),t.version),D({id:t.id})}catch{b.error(d.createFailed)}})(e)},children:[v("span",{className:"slides-starter-thumb",children:t?v(a,{slide:t.slides[0],width:128}):v("span",{className:"slides-starter-blank"})}),v("span",{children:d.starterName(e)})]},e)})});return v(e,{extra:Q,words:{windowTitle:d.slidesPanel,heading:d.decks,newFile:d.newDeck,emptyTitle:d.emptyTitle,emptyBody:d.emptyBody,deleteConfirm:d.deleteConfirm,createFailed:d.createFailed,deleteFailed:d.deleteFailed},files:d.files,list:x,create:()=>m.create(d.untitledDeck),rename:m.rename,remove:m.remove,canCreate:u,canDelete:f,accept:".pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation",choose:k&&{run:k,request:{title:d.files.choosing(d.fileKind,d.slidesPanel),extensions:j}},onOpen:e=>D({id:e}),onOpenFile:(e,s)=>{if(P)return;const l=d.files.opening(e.name);g(l),t(m,e,{storeImage:y,onProgress:e=>g(`${l} ${Math.round(100*e)}%`)}).then(async t=>{const n=await c(s,t.id);b.success(d.files.savedCopy(t.title,e.name,n?s?.location:void 0)),D({id:t.id,note:d.importNotes({skipped:t.notes.skipped,animations:t.notes.animationsDropped,fonts:t.notes.fontsReplaced})})}).catch(t=>{b.error(t instanceof n?d.pptxPasswordProtected:t instanceof i?t.message:d.files.openFailed(e.name))}).finally(()=>g(null))},busy:P})}export{F as OpenDeck,P as default,w as starterWords};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{mergeDecks as e}from"./chunk-3RFDQOTI.js";import{LAYOUTS as t,THEMES as n,applyTheme as i,ensureFonts as l,fontsOf as r,slideFromLayout as o,themeOf as s}from"./chunk-Q7NVDOCX.js";import{SlidesConflict as a,useSlidesHost as d,useSlidesWords as c}from"./chunk-BGAR3P46.js";import{DEFAULT_TRANSITION_SECONDS as m,PPTX_SHAPES as u,SlideView as h,applyStyle as p,boxStyle as f,chartToGrid as b,clicksOf as g,connectorPath as v,editorHtml as y,gridToChart as k,indent as w,insertColumn as x,insertRow as C,listMarkers as S,mergeAt as N,mergeCells as z,moveAnimation as I,nearestSide as D,newAnimation as M,paragraphsIn as E,paragraphsOf as A,plainText as P,readParagraphs as F,relayConnectors as T,removeColumn as L,removeRow as j,restoreSelection as $,selectionOffsets as R,seriesOf as B,setCell as W,setParagraphs as O,shapePath as K,shownSlides as U,stateAt as H,styleAt as V,toggleList as _,transitionKeyframes as J,unmergeCell as q,videoSource as X,withEnds as G,withParagraphs as Q}from"./chunk-B2X3NIQR.js";import{DECK_FONT as Y,DECK_FONTS as Z,HANDLES as ee,NO_FILL as te,SHAPE_KINDS as ne,SLIDE_H as ie,SLIDE_W as le,angleTo as re,asDocument as oe,boundsOf as se,boxesTouch as ae,bringForward as de,copySlide as ce,historyReducer as me,insertSlideAfter as ue,moveSlide as he,newElement as pe,newId as fe,removeElements as be,removeSlide as ge,resizeBox as ve,shiftElement as ye,snapBox as ke,updateElements as we,updateSlide as xe}from"./chunk-PXOQN7D6.js";import"./chunk-B32ASXHM.js";import{useCallback as Ce,useEffect as Se,useMemo as Ne,useReducer as ze,useRef as Ie,useState as De}from"react";import{saveIndicator as Me,useAutosave as Ee}from"efficient-easel/autosave";import{EaselIconButton as Ae,EaselTopBar as Pe,SaveState as Fe,TopBarCluster as Te,TopBarDivider as Le}from"efficient-easel/chrome";import{useEaselStrings as je}from"efficient-easel/strings";import"efficient-easel/shell.css";import"efficient-easel/chrome.css";import"efficient-easel/panel.css";import"efficient-easel/fields.css";import{AvatarGroup as $e,Avatar as Re,Button as Be,ContextMenu as We,DropdownMenu as Oe,IconButton as Ke,Input as Ue,Popover as He,registerModalEscapeInterceptor as Ve,Textarea as _e,useContextMenu as Je}from"efficient-shell/ui";import{Icon as qe}from"efficient-shell/icons";import{toast as Xe}from"efficient-shell";import{useRef as Ge,useState as Qe}from"react";import{Button as Ye,IconButton as Ze,Textarea as et}from"efficient-shell/ui";import{Icon as tt}from"efficient-shell/icons";import{toast as nt}from"efficient-shell";import{Button as it,IconButton as lt,Select as rt,Slider as ot,Switch as st}from"efficient-shell/ui";import{Icon as at}from"efficient-shell/icons";import{jsx as dt,jsxs as ct}from"react/jsx-runtime";var mt=["none","fade","slide","push","zoom","flip"],ut=["appear","fadeIn","flyIn","zoomIn","fadeOut"],ht=(e,t)=>({none:e.transitionNone,fade:e.transitionFade,slide:e.transitionSlide,push:e.transitionPush,zoom:e.transitionZoom,flip:e.transitionFlip}[t]),pt=(e,t)=>({appear:e.effectAppear,fadeIn:e.effectFadeIn,flyIn:e.effectFlyIn,zoomIn:e.effectZoomIn,fadeOut:e.effectFadeOut}[t]);function ft(e,t){return t?"text"===t.type?P(A(t)).split("\n")[0].slice(0,32)||e.elementText:{shape:e.elementShape,image:e.elementImage,video:e.elementVideo,connector:e.elementConnector,chart:e.elementChart,table:e.elementTable}[t.type]:""}function bt({slide:e,slideNumber:t,selected:n,onSlide:i,onAllSlides:l,onPlay:r}){const o=c(),s=e.animations??[],a=e=>i({animations:e.length>0?e:void 0}),d=(e,t)=>a(s.map(n=>n.id===e?{...n,...t}:n)),u=1===n.length?n[0]:null;return ct("aside",{className:"slides-inspector",children:[dt("h3",{children:o.motion}),ct("div",{className:"slides-section",children:[dt("p",{className:"slides-label",children:`${o.transition} · ${o.slideNumber(t)}`}),dt("div",{className:"slides-pills",role:"radiogroup","aria-label":o.transition,children:mt.map(t=>{const n=(e.transition?.kind??"none")===t;return dt("button",{type:"button",role:"radio","aria-checked":n,className:"slides-pill",onClick:()=>i({transition:"none"===t?void 0:{kind:t,duration:e.transition?.duration??m}}),children:ht(o,t)},t)})}),e.transition&&dt(ot,{label:o.duration,min:.1,max:5,step:.1,precision:1,suffix:"s",value:e.transition.duration,onChange:t=>i({transition:{...e.transition,duration:t??m}})}),ct("div",{className:"slides-actions",children:[dt(it,{variant:"secondary",size:"sm",onClick:()=>l({transition:e.transition}),children:o.applyToAll}),dt(it,{variant:"secondary",size:"sm",leftIcon:dt(at,{name:"play",size:14}),onClick:r,children:o.play})]})]}),ct("div",{className:"slides-section",children:[dt("p",{className:"slides-label",children:o.animations}),0===s.length&&dt("small",{className:"slides-hint",children:o.noAnimations}),s.map((t,n)=>{const i=e.elements.find(e=>e.id===t.elementId);return ct("div",{className:"slides-animation",children:[ct("div",{className:"slides-animation-head",children:[dt("span",{className:"slides-animation-number",children:n+1}),dt("span",{className:"slides-animation-name",children:ft(o,i)}),dt(lt,{"aria-label":o.moveEarlier,size:"sm",disabled:0===n,onClick:()=>a(I(s,n,n-1)),children:dt(at,{name:"chevron-up",size:14})}),dt(lt,{"aria-label":o.moveLater,size:"sm",disabled:n===s.length-1,onClick:()=>a(I(s,n,n+1)),children:dt(at,{name:"chevron-down",size:14})}),dt(lt,{"aria-label":o.removeAnimation,size:"sm",onClick:()=>a(s.filter(e=>e.id!==t.id)),children:dt(at,{name:"trash",size:14})})]}),dt(rt,{"aria-label":o.animations,size:"sm",value:t.effect,onChange:e=>d(t.id,{effect:e,from:"flyIn"===e?t.from??"bottom":void 0}),options:ut.map(e=>({value:e,label:pt(o,e)}))}),"flyIn"===t.effect&&dt(rt,{"aria-label":o.effectFlyIn,size:"sm",value:t.from??"bottom",onChange:e=>d(t.id,{from:e}),options:[{value:"left",label:o.fromLeft},{value:"right",label:o.fromRight},{value:"top",label:o.fromTop},{value:"bottom",label:o.fromBottom}]}),dt(rt,{"aria-label":o.startClick,size:"sm",value:t.start,onChange:e=>d(t.id,{start:e}),options:[{value:"click",label:o.startClick},{value:"withPrevious",label:o.startWithPrevious},{value:"afterPrevious",label:o.startAfterPrevious}]}),dt(ot,{label:o.duration,min:.1,max:5,step:.1,precision:1,suffix:"s",value:t.duration,onChange:e=>d(t.id,{duration:e??.5})}),"text"===i?.type&&dt(st,{label:o.byParagraph,checked:!!t.byParagraph,onChange:e=>d(t.id,{byParagraph:e||void 0})})]},t.id)}),u?ct("div",{className:"slides-actions",children:[dt(it,{variant:"secondary",size:"sm",leftIcon:dt(at,{name:"add",size:14}),onClick:()=>a([...s,M(u.id)]),children:o.addAnimation}),dt(it,{variant:"secondary",size:"sm",onClick:()=>a([...s,M(u.id,"fadeOut")]),children:o.effectFadeOut})]}):dt("small",{className:"slides-hint",children:o.selectToAnimate})]})]})}import{Fragment as gt,jsx as vt,jsxs as yt}from"react/jsx-runtime";function kt(e){return e.filter(e=>!e.parent).map(t=>({first:t,replies:e.filter(e=>e.parent===t.id)}))}function wt({placeholder:e,label:t,onPost:n,autoFocus:i}){const{people:l}=d(),r=c(),[o,s]=Qe(""),[a,m]=Qe([]),u=Ge(new Map),h=Ge(null),p=()=>{const e=o.trim();if(!e)return;const t=[...u.current].filter(([,t])=>e.includes(`@${t}`)).map(([e])=>e);n(e,t).then(()=>{s(""),u.current.clear()},()=>nt.error(r.commentFailed))};return yt("div",{className:"slides-composer",children:[vt(et,{ref:h,rows:2,"aria-label":t,placeholder:e,autoFocus:i,value:o,onChange:e=>{s(e.target.value),(e=>{const t=(e=>e.match(/@([\p{L}\p{N} .'-]{0,30})$/u)?.[1])(e);if(void 0===t||!l)return m([]);l(t.trim()).then(e=>m(e.slice(0,6)),()=>m([]))})(e.target.value)},onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&p()}}),a.length>0&&vt("ul",{className:"slides-mentions",role:"listbox","aria-label":t,children:a.map(e=>vt("li",{role:"option","aria-selected":!1,onMouseDown:t=>{t.preventDefault(),(e=>{const t=o.replace(/@([\p{L}\p{N} .'-]{0,30})$/u,`@${e.name} `);u.current.set(e.id,e.name),s(t),m([]),h.current?.focus()})(e)},children:e.name},e.id))}),vt("div",{className:"slides-actions slides-actions-end",children:vt(Ye,{size:"sm",disabled:!o.trim(),onClick:p,children:t})})]})}function xt({comment:e,mine:t,onSave:n,onDelete:i}){const l=c(),[r,o]=Qe(!1),[s,a]=Qe(e.body);return yt("div",{className:"slides-comment",children:[yt("div",{className:"slides-comment-head",children:[vt("span",{className:"slides-avatar","aria-hidden":"true",children:Ct(e.authorName)}),vt("span",{className:"slides-comment-author",children:e.authorName}),vt("time",{className:"slides-comment-time",dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}),t&&!r&&yt(gt,{children:[vt(Ze,{"aria-label":l.editComment,size:"sm",onClick:()=>o(!0),children:vt(tt,{name:"edit",size:14})}),vt(Ze,{"aria-label":l.deleteComment,size:"sm",onClick:i,children:vt(tt,{name:"trash",size:14})})]})]}),r?yt("div",{className:"slides-composer",children:[vt(et,{rows:2,"aria-label":l.editComment,value:s,onChange:e=>a(e.target.value)}),yt("div",{className:"slides-actions slides-actions-end",children:[vt(Ye,{variant:"secondary",size:"sm",onClick:()=>o(!1),children:l.cancel}),vt(Ye,{size:"sm",onClick:()=>{n(s.trim()),o(!1)},disabled:!s.trim(),children:l.save})]})]}):vt("p",{className:"slides-comment-body",children:e.body})]})}var Ct=e=>e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join("")||"?";function St({comments:e,slides:t,slide:n,selectedId:i,focusId:l,onAdd:r,onUpdate:o,onRemove:s,onShowSlide:a}){const m=c(),{currentUser:u}=d(),[h,p]=Qe(!1),f=kt(e).filter(e=>h||!e.first.resolvedAt).sort((e,i)=>{const l=e=>e.first.slideId===n.id?0:1,r=e=>t.findIndex(t=>t.id===e.first.slideId);return l(e)-l(i)||r(e)-r(i)||e.first.createdAt.localeCompare(i.first.createdAt)}),b=n.elements.find(e=>e.id===i);return yt("aside",{className:"slides-inspector slides-comments",children:[vt("h3",{children:m.comments}),yt("div",{className:"slides-section",children:[vt("p",{className:"slides-label",children:b?ft(m,b):m.onSlide}),vt(wt,{label:m.post,placeholder:m.commentPlaceholder,onPost:(e,t)=>r({slideId:n.id,elementId:i??"",body:e,parent:null,mentions:t})},`${n.id}-${i??""}`),yt("label",{className:"slides-check",children:[vt("input",{type:"checkbox",checked:h,onChange:e=>p(e.target.checked)}),m.showResolved]})]}),0===f.length&&vt("p",{className:"slides-empty",children:m.noComments}),f.map(({first:e,replies:n})=>{const i=t.findIndex(t=>t.id===e.slideId),d=t[i]?.elements.find(t=>t.id===e.elementId);return yt("article",{className:"slides-thread","data-focus":l===e.id||void 0,"data-resolved":e.resolvedAt?"":void 0,children:[yt("button",{type:"button",className:"slides-thread-where",onClick:()=>a(e.slideId),children:[m.slideNumber(i+1),e.elementId?` · ${d?ft(m,d):m.objectGone}`:""]}),[e,...n].map(e=>vt(xt,{comment:e,mine:e.authorId===u?.id,onSave:t=>o(e.id,{body:t}),onDelete:()=>s(e.id)},e.id)),e.resolvedAt?yt("div",{className:"slides-actions slides-actions-between",children:[vt("small",{className:"slides-hint",children:`${m.resolvedBy} · ${e.resolvedByName}`}),vt(Ye,{variant:"secondary",size:"sm",onClick:()=>o(e.id,{resolved:!1}),children:m.reopen})]}):yt(gt,{children:[vt(wt,{label:m.reply,placeholder:m.replyPlaceholder,onPost:(t,n)=>r({slideId:e.slideId,elementId:e.elementId,body:t,parent:e.id,mentions:n})}),vt("div",{className:"slides-actions slides-actions-end",children:vt(Ye,{variant:"secondary",size:"sm",leftIcon:vt(tt,{name:"check",size:14}),onClick:()=>o(e.id,{resolved:!0}),children:m.resolve})})]})]},e.id)})]})}import{useCallback as Nt,useEffect as zt,useState as It}from"react";import{Button as Dt,confirm as Mt,prompt as Et}from"efficient-shell/ui";import{Icon as At}from"efficient-shell/icons";import{toast as Pt}from"efficient-shell";import{jsx as Ft,jsxs as Tt}from"react/jsx-runtime";var Lt=e=>new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"});function jt({deckId:e,previewing:t,onPreview:n,onRestore:i,refreshKey:l}){const r=c(),{versions:o}=d(),[s,a]=It(null),m=Nt(()=>{o&&o.list(e).then(a,()=>Pt.error(r.versionsFailed))},[e,o,r.versionsFailed]);if(zt(m,[m,l]),!o)return null;const u=async(t,n="")=>{const i=await Et({title:r.nameVersion,message:r.versionName,defaultValue:n});if(null!==i)try{t?await o.rename(e,t,i.trim()):await o.name(e,i.trim()),m()}catch{Pt.error(r.versionsFailed)}};return Tt("aside",{className:"slides-inspector",children:[Ft("h3",{children:r.versionHistory}),Ft("div",{className:"slides-section",children:Ft(Dt,{variant:"secondary",size:"sm",leftIcon:Ft(At,{name:"bookmark",size:14}),onClick:()=>{u(null)},children:r.nameVersion})}),0===s?.length&&Ft("p",{className:"slides-empty",children:r.noVersions}),Ft("ul",{className:"slides-versions",children:s?.map(l=>Tt("li",{"data-current":t===l.id||void 0,children:[Ft("button",{type:"button",className:"slides-version-name",onClick:()=>{u(l.id,l.name)},children:l.name||Lt(l.createdAt)}),l.name&&Ft("small",{children:Lt(l.createdAt)}),Ft("small",{children:l.editorNames.join(", ")}),Tt("div",{className:"slides-actions",children:[Ft(Dt,{variant:"secondary",size:"sm",onClick:()=>{t===l.id?n(null,null):o.get(e,l.id).then(e=>n(l.id,e),()=>Pt.error(r.versionsFailed))},children:t===l.id?r.closePreview:r.previewVersion}),Ft(Dt,{variant:"secondary",size:"sm",onClick:()=>{(async t=>{if(await Mt({title:r.restore,message:r.restoreConfirm(Lt(t.createdAt)),confirmLabel:r.restore}))try{i(await o.get(e,t.id))}catch{Pt.error(r.restoreFailed)}})(l)},children:r.restore})]})]},l.id))})]})}import{useEffect as $t,useMemo as Rt,useRef as Bt,useState as Wt}from"react";import{Button as Ot,registerModalEscapeInterceptor as Kt}from"efficient-shell/ui";import{Icon as Ut}from"efficient-shell/icons";import{useLayoutEffect as Ht,useRef as Vt,useState as _t}from"react";import{createPortal as Jt}from"react-dom";import{jsx as qt,jsxs as Xt}from"react/jsx-runtime";function Gt(e){const[t,n]=_t(0);return Ht(()=>{const t=e.current;if(!t)return;const i=t.ownerDocument.defaultView,l=()=>n(Math.min(t.clientWidth,t.clientHeight*le/ie));l();const r=new(i?.ResizeObserver??ResizeObserver)(l);return r.observe(t),()=>r.disconnect()},[e]),t}function Qt({slide:e,popup:t,number:n,motion:i,fonts:r,transition:o,onLink:s,onAdvance:a}){const[d]=_t(()=>{const e=t.document.createElement("div");return e.style.cssText="position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#000;cursor:pointer;overflow:hidden",t.document.body.appendChild(e),{current:e}}),c=Gt(d),[m,u]=_t(null),p=Vt(e),f=Vt(null),b=Vt(null);Ht(()=>{r&&l(t.document,r)},[r,t]),Ht(()=>{const t=p.current;p.current=e,t.id!==e.id&&o?u(t):u(null)},[e,o]),Ht(()=>{if(!m||!o)return;const{incoming:e,outgoing:n}=J(o),i={duration:1e3*o.duration,easing:"ease-in-out",fill:"both"},l=f.current?.animate(e,i),r=b.current?.animate(n,i),s=t.setTimeout(()=>u(null),1e3*o.duration+30);return()=>{t.clearTimeout(s),l?.cancel(),r?.cancel()}},[m,o,t]);const g=Vt(!1);return Jt(Xt("div",{style:{position:"relative",width:c,height:c*ie/le},onClick:()=>{if(!g.current&&t.document.documentElement.requestFullscreen)return g.current=!0,void t.document.documentElement.requestFullscreen().catch(()=>{});a?.()},children:[m&&qt("div",{ref:b,style:{position:"absolute",inset:0},children:qt(h,{slide:m,width:c})}),qt("div",{ref:f,style:{position:"absolute",inset:0},children:qt(h,{slide:e,width:c,number:n,motion:i,options:{live:!0,onLink:s}})})]}),d.current)}import{jsx as Yt,jsxs as Zt}from"react/jsx-runtime";var en=e=>String(e).padStart(2,"0");function tn({slides:e,startIndex:t,numbers:n,fonts:i,popup:l,onEnd:r}){const o=Rt(()=>U(e),[e]),s=Math.max(0,o.findIndex(e=>e>=t)),[a,d]=Wt({at:s,step:0}),[m,u]=Wt(!0),p=function(){const[e,t]=Wt(0);return $t(()=>{const e=Date.now(),n=setInterval(()=>t(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(n)},[]),`${en(Math.floor(e/60))}:${en(e%60)}`}(),f=c(),b=Bt(null),v=Gt(b),y=t=>{const n=function(e,t,n,i){const l=e[t[n.at]];if(1===i)return l&&n.step<g(l)?{at:n.at,step:n.step+1}:n.at<t.length-1?{at:n.at+1,step:0}:n;if(n.step>0)return{at:n.at,step:n.step-1};if(0===n.at)return n;const r=e[t[n.at-1]];return{at:n.at-1,step:g(r)}}(e,o,a,t);u(n.at!==a.at&&1===t),d(n)},k=Bt({go:y,onEnd:r});k.current={go:y,onEnd:r},$t(()=>{const e=e=>{["ArrowRight","ArrowDown","PageDown"," ","Enter"].includes(e.key)?(e.preventDefault(),k.current.go(1)):["ArrowLeft","ArrowUp","PageUp","Backspace"].includes(e.key)&&(e.preventDefault(),k.current.go(-1))};return window.addEventListener("keydown",e),l?.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e),l?.removeEventListener("keydown",e)}},[l]),$t(()=>Kt(()=>(k.current.onEnd(),!0)),[]),$t(()=>{if(!l)return;const e=e=>{"Escape"===e.key&&k.current.onEnd()};return l.addEventListener("keydown",e),()=>{l.removeEventListener("keydown",e),l.close()}},[l]);const w=o[Math.min(a.at,o.length-1)],x=e[w],C=o[a.at+1],S=void 0!==C?e[C]:void 0,N=g(x),z=Rt(()=>H(x,a.step),[x,a.step]),I=t=>{if(t.startsWith("#slide=")){const n=e.findIndex(e=>e.id===t.slice(7));-1!==n&&(e=>{const t=o.indexOf(e);-1!==t&&(u(!0),d({at:t,step:0}))})(n)}else window.open(t,"_blank","noopener")},D=n?w+1:void 0;return Zt("div",{className:"slides-presenter",children:[Zt("div",{className:"slides-presenter-head",children:[Yt("span",{className:"slides-presenter-clock",children:p}),Zt("span",{children:[f.slideOf(w+1,e.length),N>0&&` · ${f.presenterStep(a.step,N)}`]}),Yt(Ot,{variant:"secondary",onClick:r,leftIcon:Yt(Ut,{name:"close",size:16}),children:f.endShow})]}),!l&&Yt("p",{className:"slides-presenter-blocked",children:f.popupBlocked}),Zt("div",{className:"slides-presenter-body",children:[Zt("div",{className:"slides-presenter-main",children:[Yt("div",{ref:b,className:"slides-presenter-current",children:Yt(h,{slide:x,width:v,number:D,motion:z,options:{onLink:I}})}),Zt("div",{className:"slides-presenter-steps",children:[Yt(Ot,{variant:"secondary",onClick:()=>y(-1),leftIcon:Yt(Ut,{name:"arrow-left",size:16}),children:f.back}),Yt(Ot,{variant:"secondary",onClick:()=>y(1),rightIcon:Yt(Ut,{name:"arrow-right",size:16}),children:f.next})]})]}),Zt("div",{className:"slides-presenter-side",children:[Yt("p",{className:"slides-presenter-label",children:f.nextSlide}),S?Yt(h,{slide:S,width:280,number:n?C+1:void 0}):Yt("p",{children:f.endOfDeck}),Yt("p",{className:"slides-presenter-label",children:f.notes}),Yt("p",{className:"slides-presenter-notes",children:x.notes||f.noNotes})]})]}),l&&Yt(Qt,{slide:x,popup:l,number:D,motion:z,fonts:i,transition:m&&0===a.step?x.transition:void 0,onLink:I,onAdvance:()=>y(1)})]})}import{useState as nn}from"react";import{SettingsColour as ln}from"efficient-easel/panel";import{Button as rn}from"efficient-shell/ui";import{IconButton as on}from"efficient-shell/ui";import{Input as sn}from"efficient-shell/ui";import{Select as an}from"efficient-shell/ui";import{Slider as dn}from"efficient-shell/ui";import{Switch as cn}from"efficient-shell/ui";import{Icon as mn}from"efficient-shell/icons";import{Fragment as un,jsx as hn,jsxs as pn}from"react/jsx-runtime";var fn=e=>e===te?"#ffffff":e;function bn({label:e,value:t,onChange:n}){return pn("label",{className:"slides-number",children:[hn("span",{children:e}),hn(sn,{type:"number",value:Math.round(t),onChange:e=>{const t=Number(e.target.value);""!==e.target.value&&Number.isFinite(t)&&n(t)}})]})}function gn(e){return[{label:e.alignLeft,icon:"box-x-start",action:{kind:"align",to:"left"}},{label:e.alignCentre,icon:"box-x-center",action:{kind:"align",to:"center"}},{label:e.alignRight,icon:"box-x-end",action:{kind:"align",to:"right"}},{label:e.alignTop,icon:"box-y-start",action:{kind:"align",to:"top"}},{label:e.alignMiddle,icon:"box-y-center",action:{kind:"align",to:"middle"}},{label:e.alignBottom,icon:"box-y-end",action:{kind:"align",to:"bottom"}},{label:e.distributeAcross,icon:"box-x-between",action:{kind:"distribute",axis:"horizontal"}},{label:e.distributeDown,icon:"box-y-between",action:{kind:"distribute",axis:"vertical"}}]}function vn({chart:e,accents:t,onChange:n}){const i=c(),l=b(e),r="pie"===e.kind||"donut"===e.kind;return pn("div",{className:"slides-field",children:[hn("span",{children:i.values}),hn("div",{className:"slides-grid-edit",style:{gridTemplateColumns:`repeat(${l[0].length}, minmax(0, 1fr))`},children:l.map((r,o)=>r.map((r,s)=>hn("input",{"aria-label":0===o?i.seriesName:0===s?i.rows:`${l[0][s]} ${l[o][0]}`,className:"slides-grid-cell","data-head":0===o||0===s||void 0,value:r,disabled:0===o&&0===s,inputMode:o>0&&s>0?"decimal":void 0,onChange:i=>((i,r,o)=>n(k(e,l.map((e,t)=>e.map((e,n)=>t===i&&n===r?o:e)),t)))(o,s,i.target.value)},`${o}-${s}`)))}),pn("div",{className:"slides-actions",children:[!r&&hn(rn,{variant:"secondary",size:"sm",leftIcon:hn(mn,{name:"add",size:14}),onClick:()=>n(k(e,l.map((e,t)=>[...e,0===t?`${i.addSeries} ${e.length}`:"0"]),t)),children:i.addSeries}),hn(rn,{variant:"secondary",size:"sm",leftIcon:hn(mn,{name:"add",size:14}),onClick:()=>n(k(e,[...l,l[0].map((e,t)=>0===t?"":"0")],t)),children:i.addCategory})]})]})}function yn({slide:e,selected:t,onChangeSlide:n,onChangeSelected:i,onAlign:l,onForward:r,onDelete:o,onArrange:s,cells:a,accents:m=[]}){const u=c(),{pickImage:h}=d();if(0===t.length)return pn("aside",{className:"slides-inspector",children:[hn("h3",{children:u.slide}),pn("div",{className:"slides-section",children:[hn(ln,{label:u.background,value:e.background,onChange:e=>n({background:e})}),hn(cn,{label:u.skipSlide,checked:!!e.skip,onChange:e=>n({skip:e||void 0})})]})]});const p=1===t.length?t[0]:null,f={text:u.elementText,shape:u.elementShape,image:u.elementImage,video:u.elementVideo,connector:u.elementConnector,chart:u.elementChart,table:u.elementTable},g=e=>i(t=>({...t,...e})),v=e=>{s?s(e):"align"!==e.kind||"left"!==e.to&&"center"!==e.to&&"right"!==e.to?"order"===e.kind&&"forward"===e.to&&r():l(e.to)},y=t.some(e=>e.groupId),w=t.every(e=>e.locked);return pn("aside",{className:"slides-inspector",children:[hn("h3",{children:p?f[p.type]:u.objects(t.length)}),p&&"connector"!==p.type&&pn("div",{className:"slides-section",children:[hn("p",{className:"slides-label",children:u.positionAndSize}),pn("div",{className:"slides-numbers",children:[hn(bn,{label:"X",value:p.x,onChange:e=>g({x:e})}),hn(bn,{label:"Y",value:p.y,onChange:e=>g({y:e})}),hn(bn,{label:u.width,value:p.w,onChange:e=>g({w:Math.max(20,e)})}),hn(bn,{label:u.height,value:p.h,onChange:e=>g({h:Math.max(20,e)})}),hn(bn,{label:u.angle,value:p.rotation,onChange:e=>g({rotation:e})})]})]}),pn("div",{className:"slides-section",children:[hn("p",{className:"slides-label",children:u.align}),hn("div",{className:"slides-actions",children:gn(u).map(({label:e,icon:t,action:n})=>hn(on,{"aria-label":e,size:"sm",onClick:()=>v(n),children:hn(mn,{name:t,size:16})},e))}),pn("div",{className:"slides-actions",children:[hn(on,{"aria-label":u.bringToFront,size:"sm",onClick:()=>v({kind:"order",to:"front"}),children:hn(mn,{name:"move-up",size:16})}),hn(on,{"aria-label":u.bringForward,size:"sm",onClick:()=>v({kind:"order",to:"forward"}),children:hn(mn,{name:"layers",size:16})}),hn(on,{"aria-label":u.sendBackward,size:"sm",onClick:()=>v({kind:"order",to:"backward"}),children:hn(mn,{name:"arrow-down",size:16})}),hn(on,{"aria-label":u.sendToBack,size:"sm",onClick:()=>v({kind:"order",to:"back"}),children:hn(mn,{name:"move-down",size:16})}),t.length>1&&!y&&hn(on,{"aria-label":u.group,size:"sm",onClick:()=>v({kind:"group"}),children:hn(mn,{name:"rectangle-group",size:16})}),y&&hn(on,{"aria-label":u.ungroup,size:"sm",onClick:()=>v({kind:"ungroup"}),children:hn(mn,{name:"detach",size:16})}),hn(on,{"aria-label":w?u.unlock:u.lock,size:"sm",pressed:w,onClick:()=>v({kind:"lock",locked:!w}),children:hn(mn,{name:"lock",size:16})}),hn(on,{"aria-label":u.delete,size:"sm",onClick:o,children:hn(mn,{name:"trash",size:16})})]})]}),"shape"===p?.type&&pn("div",{className:"slides-section",children:[hn(an,{"aria-label":u.elementShape,value:p.shape,onChange:e=>g({shape:e}),options:ne.map(e=>({value:e,label:u.shapeName(e)}))}),"line"!==p.shape&&hn(ln,{label:u.colour,value:fn(p.fill),onChange:e=>g({fill:e})}),(p.stroke||"line"===p.shape)&&hn(ln,{label:u.outlineColour,value:fn(p.stroke??p.fill),onChange:e=>g({stroke:e})}),"line"!==p.shape&&!p.stroke&&hn(rn,{variant:"secondary",size:"sm",onClick:()=>g({stroke:"#2c2c2a",strokeWidth:4}),children:u.outline}),(p.stroke||"line"===p.shape)&&hn(dn,{label:u.lineWidth,min:1,max:40,value:p.strokeWidth??4,onChange:e=>g({strokeWidth:e??4})}),"line"===p.shape&&pn(un,{children:[hn(cn,{label:u.arrowStart,checked:!!p.arrowStart,onChange:e=>g({arrowStart:e})}),hn(cn,{label:u.arrowEnd,checked:!!p.arrowEnd,onChange:e=>g({arrowEnd:e})})]})]}),"connector"===p?.type&&pn("div",{className:"slides-section",children:[hn(an,{"aria-label":u.route,value:p.route,onChange:e=>g({route:e}),options:[{value:"straight",label:u.routeStraight},{value:"elbow",label:u.routeElbow},{value:"curved",label:u.routeCurved}]}),hn(ln,{label:u.outlineColour,value:p.stroke,onChange:e=>g({stroke:e})}),hn(dn,{label:u.lineWidth,min:1,max:40,value:p.strokeWidth,onChange:e=>g({strokeWidth:e??4})}),hn(cn,{label:u.arrowStart,checked:!!p.arrowStart,onChange:e=>g({arrowStart:e})}),hn(cn,{label:u.arrowEnd,checked:!!p.arrowEnd,onChange:e=>g({arrowEnd:e})})]}),"image"===p?.type&&hn(kn,{element:p,pickImage:h,onChange:g,onChangeSelected:i}),"video"===p?.type&&pn("div",{className:"slides-section",children:[pn("label",{className:"slides-field",children:[hn("span",{children:u.videoAddress}),hn(sn,{value:p.src,placeholder:"https://youtu.be/…",onChange:e=>g({src:e.target.value.trim()})}),hn("small",{children:u.videoHint})]}),pn("label",{className:"slides-field",children:[hn("span",{children:u.description}),hn(sn,{value:p.alt,onChange:e=>g({alt:e.target.value})})]})]}),"chart"===p?.type&&pn("div",{className:"slides-section",children:[hn("p",{className:"slides-label",children:u.data}),hn(an,{"aria-label":u.chartType,value:p.kind,onChange:e=>g({kind:e}),options:[{value:"bar",label:u.chartBar},{value:"hbar",label:u.chartHbar},{value:"line",label:u.line},{value:"area",label:u.chartArea},{value:"pie",label:u.chartPie},{value:"donut",label:u.chartDonut}]}),hn(vn,{chart:p,accents:m,onChange:e=>i(()=>e)}),hn(an,{"aria-label":u.legend,value:p.legend??"auto",onChange:e=>g({legend:"auto"===e?void 0:e}),options:[{value:"auto",label:u.legend},{value:"bottom",label:u.legendBottom},{value:"right",label:u.legendRight},{value:"none",label:u.legendNone}]}),hn(ln,{label:u.colour,value:p.series?.[0]?.color??p.color,onChange:e=>i(t=>{const n=t,i=b(n);return k({...n,color:e,series:n.series?.map((t,n)=>0===n?{...t,color:e}:t)},i,m)})})]}),"table"===p?.type&&hn(wn,{table:p,cells:a??null,onChange:e=>i(()=>e)})]})}function kn({element:e,pickImage:t,onChange:n,onChangeSelected:i}){const l=c(),r=e.crop??{left:0,top:0,right:0,bottom:0};return pn("div",{className:"slides-section",children:[t?hn(rn,{variant:"secondary",block:!0,onClick:()=>{const{id:n}=e;t().then(e=>{e&&i(t=>t.id===n?{...t,src:e}:t)})},children:e.src?l.replaceImage:l.chooseImage}):pn("label",{className:"slides-field",children:[hn("span",{children:l.imageAddress}),hn(sn,{value:e.src,onChange:e=>n({src:e.target.value})})]}),pn("label",{className:"slides-field",children:[hn("span",{children:l.description}),hn(sn,{value:e.alt,onChange:e=>n({alt:e.target.value})})]}),hn("p",{className:"slides-label",children:l.crop}),["left","top","right","bottom"].map(e=>hn(dn,{label:l[{left:"cropLeft",top:"cropTop",right:"cropRight",bottom:"cropBottom"}[e]],min:0,max:45,suffix:"%",value:Math.round(100*r[e]),onChange:t=>((e,t)=>{const i={...r,[e]:Math.max(0,Math.min(.45,(t??0)/100))};n({crop:i.left||i.top||i.right||i.bottom?i:void 0})})(e,t)},e)),hn(dn,{label:l.opacity,min:0,max:100,suffix:"%",value:Math.round(100*(e.opacity??1)),onChange:e=>n({opacity:null===e||e>=100?void 0:e/100})})]})}function wn({table:e,cells:t,onChange:n}){const i=c(),[l]=nn(i.cellEditHint),r=t??{row:e.rows.length-1,col:(e.rows[0]?.length??1)-1,rows:1,cols:1},o=N(e,r.row,r.col);return pn("div",{className:"slides-section",children:[hn("small",{className:"slides-hint",children:l}),pn("div",{className:"slides-actions slides-actions-words",children:[hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(C(e,r.row)),children:i.insertRowAbove}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(C(e,r.row+r.rows)),children:i.insertRowBelow}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(x(e,r.col)),children:i.insertColumnLeft}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(x(e,r.col+r.cols)),children:i.insertColumnRight}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(j(e,r.row)),children:i.deleteRow}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(L(e,r.col)),children:i.deleteColumn}),t&&t.rows*t.cols>1&&hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(z(e,t)),children:i.mergeCells}),o&&hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(q(e,r.row,r.col)),children:i.unmergeCells})]}),hn(ln,{label:i.headingColour,value:fn(e.headerFill),onChange:t=>n({...e,headerFill:t})}),hn(ln,{label:i.borderColour,value:e.borderColor??"#b4b2a9",onChange:t=>n({...e,borderColor:t})}),hn(dn,{label:i.borderWidth,min:0,max:12,value:e.borderWidth??2,onChange:t=>n({...e,borderWidth:t??2})})]})}import{useState as xn}from"react";import{Button as Cn,ContextMenu as Sn,useContextMenu as Nn}from"efficient-shell/ui";import{Icon as zn}from"efficient-shell/icons";import{jsx as In,jsxs as Dn}from"react/jsx-runtime";function Mn({slides:e,currentId:t,onShow:n,onAdd:i,onMove:l,onDuplicate:r,onDelete:o,onSkip:s,numbers:a,visitors:d=[]}){const[m,u]=xn(null),p=c(),f=Nn(),b=f.state?e.findIndex(e=>e.id===f.state?.data):-1;return Dn("nav",{className:"slides-rail","aria-label":p.slidesPanel,children:[e.map((e,i)=>Dn("div",{className:"slides-thumb","data-current":e.id===t||void 0,"data-skipped":e.skip||void 0,draggable:!0,onDragStart:()=>u(e.id),onDragEnd:()=>u(null),onDragOver:e=>e.preventDefault(),onContextMenu:t=>f.open(t,e.id),onDrop:()=>{m&&m!==e.id&&l(m,i),u(null)},children:[In("span",{className:"slides-thumb-number",children:i+1}),Dn("div",{role:"button",tabIndex:0,"aria-label":p.slideNumber(i+1),"aria-current":e.id===t,className:"slides-thumb-image",onClick:()=>n(e.id),onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),n(e.id))},children:[In(h,{slide:e,width:132,number:a?i+1:void 0}),e.skip&&In("span",{className:"slides-thumb-skip",title:p.skipped,children:In(zn,{name:"eye-off",size:14})}),In("span",{className:"slides-thumb-visitors",children:d.filter(t=>t.slide===e.id).map(e=>In("span",{title:e.user.name,style:{background:e.color}},e.key))})]})]},e.id)),In(Cn,{variant:"secondary",block:!0,onClick:i,children:p.addSlide}),b>=0&&In(Sn,{...f.props,items:(g=e[b],[{key:"duplicate",label:p.duplicateSlide,icon:In(zn,{name:"copy",size:14}),onSelect:()=>r(g.id)},...s?[{key:"skip",label:g.skip?p.unskipSlide:p.skipSlide,icon:In(zn,{name:"eye-off",size:14}),onSelect:()=>s(g.id)}]:[],{type:"divider",key:"d-delete"},{key:"delete",label:p.deleteSlide,danger:!0,icon:In(zn,{name:"trash",size:14}),onSelect:()=>o(g.id)}]),"aria-label":p.slideNumber(b+1)})]});var g}import{useLayoutEffect as En,useRef as An,useState as Pn}from"react";function Fn(e,t){const n=[...e.elements];for(let e=1;e<n.length;e+=1)t.has(n[e].id)&&!t.has(n[e-1].id)&&([n[e],n[e-1]]=[n[e-1],n[e]]);return{...e,elements:n}}function Tn(e,t){const n=e.elements.filter(e=>!t.has(e.id));return{...e,elements:[...n,...e.elements.filter(e=>t.has(e.id))]}}function Ln(e,t){const n=e.elements.filter(e=>!t.has(e.id));return{...e,elements:[...e.elements.filter(e=>t.has(e.id)),...n]}}var jn={x:0,y:0,w:le,h:ie};function $n(e,t){const n=new Set(e.elements.filter(e=>t.has(e.id)&&e.groupId).map(e=>e.groupId));return new Set(e.elements.filter(e=>t.has(e.id)||e.groupId&&n.has(e.groupId)).map(e=>e.id))}var Rn="efficient-office/slide-elements";function Bn(e){try{const t=JSON.parse(e);return t?.type===Rn&&Array.isArray(t.elements)?t.elements:null}catch{return null}}function Wn(e,t){const n=new Map(t.map(e=>[e.id,fe()])),i=new Map,l=t.some(t=>e.elements.some(e=>e.id===t.id))?40:0,r=t.map(e=>{const t={...ye(e,l,l),id:n.get(e.id),locked:void 0};var r;if(e.groupId&&(t.groupId=(r=e.groupId,i.has(r)||i.set(r,fe()),i.get(r))),"connector"===t.type){const e=({attach:e,...t})=>{const i=e&&n.get(e.id);return i?{...t,attach:{...e,id:i}}:t};return{...t,start:e(t.start),end:e(t.end)}}return t});return{slide:{...e,elements:[...e.elements,...r]},ids:r.map(e=>e.id)}}import{useEffect as On,useLayoutEffect as Kn,useRef as Un}from"react";import{registerModalEscapeInterceptor as Hn}from"efficient-shell/ui";import{jsx as Vn}from"react/jsx-runtime";var _n=e=>e.reduce((e,t)=>e+t.runs.reduce((e,t)=>e+t.text.length,0),0)+e.length-1;function Jn({element:e,onCommit:t,onEnd:n,onEditing:i,onLinkShortcut:l}){const r=c(),o=Un(null),s=Un(A(e)),a=Un({start:0,end:_n(s.current)}),d=Un(t);d.current=t;const m=Un(n);m.current=n;const u=Un(i);u.current=i;const h=()=>{const t=o.current;t&&(t.innerHTML=y(e,s.current))},b=()=>{const{start:e,end:t}=a.current,n=s.current,i=e!==t,{runs:l,...r}=n[E(n,e,t)[0]??0]??{runs:[]};u.current({style:i?V(n,e,t):V(n,0,_n(n)),paragraph:r,hasRange:i,applyRun:e=>g((t,n,i)=>n===i?p(t,0,_n(t),e):p(t,n,i,e)),applyParagraph:e=>g((t,n,i)=>O(t,n,i,e)),toggleList:e=>g((t,n,i)=>_(t,n,i,e)),indent:e=>g((t,n,i)=>w(t,n,i,e))})},g=e=>{const t=o.current;if(!t)return;const{start:n,end:i}=a.current;s.current=e(s.current,n,i),h(),t.focus(),$(t,n,i),b()};return Kn(()=>{const e=o.current;if(!e)return;h(),e.focus();const t=_n(s.current);$(e,0,t),a.current={start:0,end:t},b()},[]),On(()=>Hn(()=>!!o.current?.contains(o.current.ownerDocument.activeElement)&&(m.current(),!0)),[]),On(()=>{const e=o.current;if(!e)return;const t=e.ownerDocument,n=()=>{const t=R(e);t&&(a.current=t,b())};return t.addEventListener("selectionchange",n),()=>{t.removeEventListener("selectionchange",n),u.current(null),d.current(s.current)}},[]),Vn("div",{ref:o,contentEditable:!0,role:"textbox","aria-multiline":"true","aria-label":r.slideText,suppressContentEditableWarning:!0,className:"slides-text-edit",style:{...f(e),display:"flex",flexDirection:"column",justifyContent:{top:"flex-start",middle:"center",bottom:"flex-end"}[e.anchor??"top"]},onPointerDown:e=>e.stopPropagation(),onInput:()=>{const e=o.current,t=s.current,n=F(e);s.current=n;if((n.some(e=>e.list)||t.some(e=>e.list))&&n.length!==t.length){const t=R(e)??a.current;h(),$(e,t.start,t.end)}},onPaste:e=>{e.preventDefault();const t=e.clipboardData.getData("text/plain");o.current?.ownerDocument.execCommand("insertText",!1,t)},onKeyDown:e=>{e.stopPropagation();const t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase(),i=V(s.current,a.current.start,a.current.end);t&&"b"===n?(e.preventDefault(),g((e,t,n)=>p(e,t,n,{bold:!i.bold}))):t&&"i"===n?(e.preventDefault(),g((e,t,n)=>p(e,t,n,{italic:!i.italic||void 0}))):t&&"u"===n?(e.preventDefault(),g((e,t,n)=>p(e,t,n,{underline:!i.underline||void 0}))):t&&"k"===n?(e.preventDefault(),l?.()):"Tab"===e.key?(e.preventDefault(),g((t,n,i)=>w(t,n,i,e.shiftKey?-1:1))):"Escape"===e.key&&m.current()}})}import{Fragment as qn,jsx as Xn,jsxs as Gn}from"react/jsx-runtime";var Qn={x:[],y:[]};function Yn({text:e,onDone:t}){const n=An(null);return En(()=>{const t=n.current;t&&(t.innerText=e,t.focus(),t.ownerDocument.getSelection()?.selectAllChildren(t))},[]),Xn("div",{ref:n,contentEditable:"plaintext-only",role:"textbox",suppressContentEditableWarning:!0,className:"slides-cell-edit",onPointerDown:e=>e.stopPropagation(),onBlur:e=>t(e.currentTarget.innerText.replace(/\n+$/,"")),onKeyDown:e=>{e.stopPropagation(),"Escape"===e.key&&t(null),"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.blur())}})}function Zn({slide:e,selected:t,onSelect:n,onLive:i,onSettle:l,onCommit:r,onEditing:o,onLink:s,cells:a,onCells:d,onContextMenu:c,visitors:m=[],pins:u=[],onPin:p,grid:f,slideNumber:b}){const g=An(null),[v,y]=Pn(0),[k,w]=Pn(Qn),[x,C]=Pn(null),[S,N]=Pn(null),[z,I]=Pn(null),M=An(null);En(()=>{const e=g.current;if(!e)return;const t=()=>{y(Math.max(0,Math.min(e.clientWidth-48,(e.clientHeight-48)*le/ie)))};t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const E=v/le,P=An(null),F=e=>{const t=P.current?.getBoundingClientRect();return{x:(e.clientX-(t?.left??0))/E,y:(e.clientY-(t?.top??0))/E}},L=(t,n,i=!1)=>{for(let l=e.elements.length-1;l>=0;l-=1){const r=e.elements[l];if(r.locked&&!i)continue;const o=-r.rotation*Math.PI/180,s=t-(r.x+r.w/2),a=n-(r.y+r.h/2),d=s*Math.cos(o)-a*Math.sin(o),c=s*Math.sin(o)+a*Math.cos(o);if(Math.abs(d)<=r.w/2&&Math.abs(c)<=r.h/2)return r}return null},j=(e,t)=>{e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),M.current=t},$=l=>{const r=M.current;if(!r)return;const{x:o,y:s}=F(l);if("marquee"===r.kind){const t={x:Math.min(r.px,o),y:Math.min(r.py,s),w:Math.abs(o-r.px),h:Math.abs(s-r.py)};C(t);const i=new Set(e.elements.filter(e=>!e.locked&&ae(t,e)).map(e=>e.id));n($n(e,i))}else if("move"===r.kind){const e=r.start.elements.filter(e=>t.has(e.id)),n=r.start.elements.filter(e=>!t.has(e.id)),a=se(e),d={...a,x:a.x+o-r.px,y:a.y+s-r.py},c=l.altKey?{box:d,guides:Qn}:ke(d,n);w(c.guides);const m=c.box.x-a.x,u=c.box.y-a.y;i(T(we(r.start,t,e=>ye(e,m,u)),t))}else if("resize"===r.kind){const e=we(r.start,new Set([r.id]),e=>{const t=-e.rotation*Math.PI/180,n=o-r.px,i=s-r.py,a=n*Math.cos(t)-i*Math.sin(t),d=n*Math.sin(t)+i*Math.cos(t);return{...e,...ve(e,r.handle,a,d,l.shiftKey)}});i(T(e))}else if("rotate"===r.kind){const e=we(r.start,new Set([r.id]),e=>({...e,rotation:re(e,o,s,l.shiftKey)}));i(T(e))}else{const e=r.start.elements.find(e=>e.id===r.id&&"connector"===e.type);if(!e)return;const t=l.altKey?null:D(r.start.elements,o,s,e.id),n=t?{x:t.x,y:t.y,attach:{id:t.id,side:t.side}}:{x:o,y:s},a="start"===r.end?n:e.start,d="end"===r.end?n:e.end;i(we(r.start,new Set([e.id]),()=>G(e,a,d)))}},R=()=>{const e=M.current;M.current=null,w(Qn),C(null),e&&"marquee"!==e.kind&&l()},B=e.elements.filter(e=>t.has(e.id)),O=1===B.length?B[0]:void 0,K=e.elements.find(e=>e.id===S&&"text"===e.type),U=An({slide:e,onCommit:r});U.current={slide:e,onCommit:r};const H=(e,t=null,n="slides-selection",i)=>Gn("div",{className:n,style:{left:e.x*E,top:e.y*E,width:e.w*E,height:e.h*E,transform:e.rotation?`rotate(${e.rotation}deg)`:void 0,...i?{borderColor:i.color}:{}},children:[i&&Xn("span",{className:"slides-visitor-name",style:{background:i.color},children:i.name}),t]},`${n}-${e.id}-${i?.name??""}`),V="table"===O?.type?O:null;return Xn("div",{ref:g,className:"slides-pane",children:Gn("div",{ref:P,className:"slides-stage",style:{width:v,height:v*ie/le},onPointerDown:i=>{if(0!==i.button)return;S&&N(null);const{x:l,y:r}=F(i),o=L(l,r);if(!o)return i.shiftKey||n(new Set),d(null),void j(i,{kind:"marquee",px:l,py:r});if("table"===o.type&&t.has(o.id)&&1===t.size){const e=i.target.closest("[data-cell]")?.dataset.cell;if(e){const[t,n]=e.split(":").map(Number);if(i.shiftKey&&a){const e=Math.min(a.row,t),i=Math.min(a.col,n);return void d({row:e,col:i,rows:Math.max(a.row+a.rows-1,t)-e+1,cols:Math.max(a.col+a.cols-1,n)-i+1})}d({row:t,col:n,rows:1,cols:1})}}else d(null);let s=t;const c=$n(e,new Set([o.id]));if(i.shiftKey){const e=new Set(t),i=!e.has(o.id);for(const t of c)i?e.add(t):e.delete(t);s=e,n(e)}else t.has(o.id)||(s=c,n(s));s.has(o.id)&&j(i,{kind:"move",start:e,px:l,py:r})},onPointerMove:$,onPointerUp:R,onPointerCancel:R,onContextMenu:i=>{const{x:l,y:r}=F(i),o=L(l,r,!0);o&&!t.has(o.id)&&n($n(e,new Set([o.id]))),c(i,o?.id??null)},onDoubleClick:e=>{const{x:t,y:i}=F(e),l=L(t,i);if("text"===l?.type)n(new Set([l.id])),N(l.id);else if("table"===l?.type){const t=e.target.closest("[data-cell]")?.dataset.cell;if(t){const[e,n]=t.split(":").map(Number);I({id:l.id,row:e,col:n})}}},children:[Xn(h,{slide:e,width:v,number:b,editingId:K?.id,options:V?{cellEditor:(J=V,(t,n)=>z&&z.id===J.id&&z.row===t&&z.col===n?Xn(Yn,{text:J.rows[t][n],onDone:i=>{I(null),null!==i&&i!==J.rows[t][n]&&r(we(e,new Set([J.id]),()=>W(J,t,n,i)))}}):void 0)}:void 0,editor:K&&Xn(Jn,{element:K,onCommit:(_=K.id,e=>{const{slide:t,onCommit:n}=U.current,i=t.elements.find(e=>e.id===_&&"text"===e.type);if(!i)return;const l=Q(i,e);JSON.stringify(l.paragraphs)===JSON.stringify(A(i))&&l.text===i.text||n(we(t,new Set([_]),()=>l))}),onEnd:()=>N(null),onEditing:o,onLinkShortcut:s},K.id)}),f&&Xn("div",{className:"slides-grid",style:{backgroundSize:`${60*E}px ${60*E}px`}}),m.flatMap(t=>e.elements.filter(e=>t.selected.includes(e.id)).map(e=>H(e,null,"slides-visitor",t))),!K&&B.map(t=>H(t,O?.id!==t.id||t.locked?t.locked?Xn("span",{className:"slides-lock","aria-hidden":"true"}):null:(t=>"connector"===t.type?["start","end"].map(n=>{const i=t[n];return Xn("div",{className:"slides-handle slides-end","data-held":i.attach?"":void 0,style:{left:(i.x-t.x)*E,top:(i.y-t.y)*E},onPointerDown:i=>j(i,{kind:"end",start:e,id:t.id,end:n}),onPointerMove:$,onPointerUp:R,onPointerCancel:R},n)}):Gn(qn,{children:[ee.map(n=>Xn("div",{className:`slides-handle slides-handle-${n}`,onPointerDown:i=>j(i,{kind:"resize",start:e,id:t.id,handle:n,...ti(F(i))}),onPointerMove:$,onPointerUp:R,onPointerCancel:R},n)),Xn("div",{className:"slides-rotate-stem"}),Xn("div",{className:"slides-rotate",onPointerDown:n=>j(n,{kind:"rotate",start:e,id:t.id}),onPointerMove:$,onPointerUp:R,onPointerCancel:R})]}))(t))),V&&a&&Xn("div",{className:"slides-cells","aria-hidden":"true",style:ei(P.current,V,a,E)}),u.map(e=>Xn("button",{type:"button",className:"slides-pin",style:{left:e.x*E,top:e.y*E},onPointerDown:e=>e.stopPropagation(),onClick:()=>p?.(e.id),children:e.count},e.id)),k.x.map(e=>Xn("div",{className:"slides-guide slides-guide-x",style:{left:e*E}},`x${e}`)),k.y.map(e=>Xn("div",{className:"slides-guide slides-guide-y",style:{top:e*E}},`y${e}`)),x&&Xn("div",{className:"slides-marquee",style:{left:x.x*E,top:x.y*E,width:x.w*E,height:x.h*E}})]})});var _,J}function ei(e,t,n,i){const l=e?.querySelector(`[data-element="${CSS.escape(t.id)}"] [data-cell="${n.row}:${n.col}"]`),r=e?.querySelector(`[data-element="${CSS.escape(t.id)}"] [data-cell="${n.row+n.rows-1}:${n.col+n.cols-1}"]`)??l;if(!e||!l||!r)return{display:"none"};const o=e.getBoundingClientRect(),s=l.getBoundingClientRect(),a=r.getBoundingClientRect();return{left:s.left-o.left,top:s.top-o.top,width:a.right-s.left,height:a.bottom-s.top}}var ti=({x:e,y:t})=>({px:e,py:t});import{ColorPicker as ni,DropdownMenu as ii,IconButton as li,prompt as ri,Select as oi}from"efficient-shell/ui";import{Icon as si}from"efficient-shell/icons";import{toast as ai}from"efficient-shell";import{jsx as di,jsxs as ci}from"react/jsx-runtime";var mi=[12,16,20,24,28,32,40,48,56,64,72,96,120,160],ui=[1,1.15,1.25,1.5,2];function hi({element:e,editing:t,slides:n,accents:i,onBox:l}){const r=c(),o=A(e),s=P(o).length,a=t?t.style:V(o,0,s),d=t?t.paragraph:o[0]??{runs:[]},m=a.size??(t?.hasRange?void 0:e.fontSize)??e.fontSize,u=a.font??e.font??Z[0],h=a.bold??e.bold,f=e=>{t?t.applyRun(e):l(t=>{const n={},i={...e};"size"in e&&e.size&&(n.fontSize=e.size,i.size=void 0),"bold"in e&&(n.bold=!!e.bold,i.bold=void 0),"color"in e&&e.color&&(n.color=e.color,i.color=void 0),"font"in e&&e.font&&(n.font=e.font,i.font=void 0);const l=A(t);return Q({...t,...n},p(l,0,P(l).length,i))})},b=e=>{t?t.applyParagraph(e):l(t=>Q(t,O(A(t),0,Number.MAX_SAFE_INTEGER,e)))},g=e=>{t?t.toggleList(e):l(t=>Q(t,_(A(t),0,Number.MAX_SAFE_INTEGER,e)))},v=e=>{t?t.indent(e):l(t=>Q(t,w(A(t),0,Number.MAX_SAFE_INTEGER,e)))},y=async()=>{const e=await ri({title:r.link,message:r.linkPrompt,allowEmpty:!0,defaultValue:a.link?.startsWith("#slide=")?"":a.link??""});if(null==e)return;if(!e.trim())return void f({link:void 0});const t=function(e,t){const n=e.trim();if(!n)return null;if(/^\d+$/.test(n)){const e=t[Number(n)-1];return e?`#slide=${e.id}`:null}return/^(https?:\/\/|mailto:)/i.test(n)?n:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?`mailto:${n}`:/^[\w-]+(\.[\w-]+)+(\/\S*)?$/.test(n)?`https://${n}`:null}(e,n);t?f({link:t}):ai.error(r.badLink)},k=e=>{const t=mi.findIndex(e=>e>=m),n=-1===t?mi.length-1:1===e?mi[t]>m?t:t+1:t-1;return mi[Math.max(0,Math.min(mi.length-1,n))]},x=d.align??e.align,C=(e,t,n,i)=>di(li,{"aria-label":e,size:"sm",pressed:i,onClick:n,children:di(si,{name:t,size:16})},e);return ci("div",{className:"slides-toolbar slides-texttools","data-text-toolbar":"",onMouseDown:e=>{e.target.closest('input, select, [role="combobox"], [role="listbox"]')||e.preventDefault()},children:[di("div",{className:"slides-tool-font",children:di(oi,{"aria-label":r.font,size:"sm",value:u,onChange:e=>f({font:String(e)}),options:Z.map(e=>({value:e,label:e}))})}),C(r.smaller,"remove",()=>f({size:k(-1)})),di("div",{className:"slides-tool-size",children:di(oi,{"aria-label":r.fontSize,size:"sm",value:String(Math.round(m)),onChange:e=>f({size:Number(e)}),options:[...new Set([...mi,Math.round(m)])].sort((e,t)=>e-t).map(e=>({value:String(e),label:String(e)}))})}),C(r.larger,"add",()=>f({size:k(1)})),di("span",{className:"slides-tool-gap"}),C(r.bold,"bold",()=>f({bold:!h}),h),C(r.italic,"italic",()=>f({italic:!a.italic||void 0}),!!a.italic),C(r.underline,"underline",()=>f({underline:!a.underline||void 0}),!!a.underline),C(r.strikethrough,"strike",()=>f({strike:!a.strike||void 0}),!!a.strike),di(ni,{label:r.textColour,size:"sm",value:a.color??e.color,presets:i,onChange:e=>f({color:e})}),di(ni,{label:r.highlight,size:"sm",value:a.highlight??"#ffffff",presets:["#fac775","#c0dd97","#b5d4f4","#f4c0d1"],clearable:!0,onChange:e=>f({highlight:e||void 0})}),C(r.link,"link",()=>{y()},!!a.link),di("span",{className:"slides-tool-gap"}),C(r.alignLeft,"align-left",()=>b(e=>({...e,align:"left"})),"left"===x),C(r.alignCentre,"align-center",()=>b(e=>({...e,align:"center"})),"center"===x),C(r.alignRight,"align-right",()=>b(e=>({...e,align:"right"})),"right"===x),C(r.alignJustify,"align-justify",()=>b(e=>({...e,align:"justify"})),"justify"===x),di("span",{className:"slides-tool-gap"}),C(r.bulletList,"list",()=>g("bullet"),"bullet"===d.list),C(r.numberedList,"numbered-list",()=>g("number"),"number"===d.list),C(r.indentLess,"chevron-left",()=>v(-1)),C(r.indentMore,"chevron-right",()=>v(1)),di(ii,{"aria-label":r.lineSpacing,trigger:di(si,{name:"line-spacing",size:16}),items:ui.map(e=>({type:"radio",key:String(e),label:String(e),checked:(d.lineHeight??1.25)===e,onSelect:()=>b(t=>({...t,lineHeight:1.25===e?void 0:e}))}))}),di(ii,{"aria-label":r.verticalAlign,trigger:di(si,{name:"v-align",size:16}),items:[...["top","middle","bottom"].map(t=>({type:"radio",key:t,label:r[t],checked:(e.anchor??"top")===t,onSelect:()=>l(e=>({...e,anchor:t}))})),{type:"divider",key:"d"},{type:"checkbox",key:"fit",label:r.shrinkToFit,checked:!!e.autofit,onSelect:()=>l(e=>({...e,autofit:!e.autofit||void 0}))}]})]})}import{SettingsColour as pi}from"efficient-easel/panel";import{Select as fi,Switch as bi}from"efficient-shell/ui";import{jsx as gi,jsxs as vi}from"react/jsx-runtime";function yi({doc:e,slide:t,onTheme:i,onDeck:l,onSlide:r}){const a=c(),d=s(e),m=e=>i({...d,...e,id:n.some(t=>t.id===d.id&&JSON.stringify({...t,...e})===JSON.stringify(t))?d.id:"custom"}),u={title:"Aa",subtitle:"",body:""};return vi("aside",{className:"slides-inspector",children:[gi("h3",{children:a.theme}),gi("div",{className:"slides-section",children:gi("div",{className:"slides-themes",children:n.map(e=>vi("button",{type:"button",className:"slides-theme-tile","aria-pressed":e.id===d.id,onClick:()=>i(e),children:[gi(h,{slide:{...o("title",e,u),elements:o("title",e,u).elements.slice(0,1)},width:96}),gi("span",{children:a.themeName(e.id)})]},e.id))})}),vi("div",{className:"slides-section",children:[gi("p",{className:"slides-label",children:a.colours}),gi(pi,{label:a.background,value:d.background,onChange:e=>m({background:e})}),gi(pi,{label:a.headingFont,value:d.heading,onChange:e=>m({heading:e})}),gi(pi,{label:a.bodyFont,value:d.text,onChange:e=>m({text:e})}),gi("div",{className:"slides-swatches","aria-hidden":"true",children:d.accents.map(e=>gi("span",{style:{background:e}},e))})]}),vi("div",{className:"slides-section",children:[gi(fi,{"aria-label":a.headingFont,value:d.headingFont,onChange:e=>m({headingFont:String(e)}),options:Z.map(e=>({value:e,label:`${a.headingFont}: ${e}`}))}),gi(fi,{"aria-label":a.bodyFont,value:d.bodyFont,onChange:e=>m({bodyFont:String(e)}),options:Z.map(e=>({value:e,label:`${a.bodyFont}: ${e}`}))})]}),vi("div",{className:"slides-section",children:[gi(bi,{label:a.slideNumbers,checked:!!e.slideNumbers,onChange:e=>l({slideNumbers:e||void 0})}),gi(bi,{label:a.skipSlide,checked:!!t.skip,onChange:e=>r({skip:e||void 0})})]})]})}import{useEffect as ki,useRef as wi,useState as xi}from"react";var Ci=["#1d9e75","#d85a30","#378add","#d4537e","#ba7517","#639922","#7f77dd","#993c1d"];function Si(e){let t=0;for(const n of e)t=31*t+n.charCodeAt(0)>>>0;return Ci[t%Ci.length]}var Ni=13.333,zi=e=>e/le*Ni,Ii=e=>e.replace("#","").toUpperCase(),Di=e=>Math.round(72*zi(e));function Mi(e){return`${e.replace(/[^\p{L}\p{N} _-]+/gu," ").replace(/ +/g," ").trim()||"Deck"}.pptx`}var Ei=e=>e===te?{type:"none"}:{color:Ii(e)},Ai=e=>e.stroke?{color:Ii(e.stroke),width:Di(e.strokeWidth??1)}:void 0;function Pi(e,t,n,i){const l=e.cellFills?.[n]?.[i]??(0===n?e.headerFill:null),r=e.cellColors?.[n]?.[i]??(0===n?e.headerColor:void 0),o=e.merges?.find(e=>e.row===n&&e.col===i);return{text:t,options:{...0===n?{bold:!0}:{},...l?{fill:Ei(l)}:{},...r?{color:Ii(r)}:{},...o?{rowspan:o.rows,colspan:o.cols}:{}}}}var Fi={bar:"bar",hbar:"bar",line:"line",area:"area",pie:"pie",donut:"doughnut"};function Ti(e,t,n){const i={x:zi(n.x),y:zi(n.y),w:zi(n.w),h:zi(n.h),rotate:n.rotation};switch(n.type){case"text":!function(e,t,n){const i=A(t),l=S(i),r=[];i.forEach((e,n)=>{const o=e.runs.length>0?e.runs:[{text:""}];o.forEach((s,a)=>{const d=a===o.length-1;r.push({text:s.text,options:{bold:s.bold??t.bold,italic:s.italic,underline:s.underline||s.link?{style:"sng"}:void 0,strike:s.strike?"sngStrike":void 0,color:Ii(s.color??t.color),highlight:s.highlight?Ii(s.highlight):void 0,fontSize:Di(s.size??t.fontSize),fontFace:s.font??t.font??Y,hyperlink:s.link&&!s.link.startsWith("#")?{url:s.link}:void 0,align:e.align??t.align,bullet:l[n]?"number"!==e.list||{type:"number"}:void 0,indentLevel:e.level||void 0,lineSpacingMultiple:e.lineHeight,breakLine:d&&n<i.length-1}})})}),e.addText(r,{...n,valign:t.anchor??"top",margin:0,fit:t.autofit?"shrink":void 0})}(t,n,i);break;case"shape":!function(e,t,n,i){"line"!==n.shape?t.addShape(u[n.shape],{...i,fill:Ei(n.fill),line:Ai(n),rectRadius:"roundRect"===n.shape&&void 0!==n.radius?zi(n.radius):void 0}):t.addShape(e.ShapeType.line,{...i,y:i.y+i.h/2,h:0,line:{color:Ii(n.stroke??n.fill),width:Di(n.strokeWidth??1),beginArrowType:n.arrowStart?"triangle":"none",endArrowType:n.arrowEnd?"triangle":"none"}})}(e,t,n,i);break;case"image":{if(!n.src)break;const e=n.crop;t.addImage({...i,path:n.src,altText:n.alt,transparency:void 0!==n.opacity?Math.round(100*(1-n.opacity)):void 0,...e&&(e.left||e.top||e.right||e.bottom)?{sizing:{type:"crop",x:zi(n.w*e.left/Math.max(.05,1-e.left-e.right)),y:zi(n.h*e.top/Math.max(.05,1-e.top-e.bottom)),w:i.w,h:i.h}}:{}});break}case"video":{const e=X(n.src);"youtube"===e?.kind?t.addMedia({...i,type:"online",link:`https://www.youtube.com/embed/${e.id}`}):n.src&&t.addText([{text:n.alt||n.src,options:{hyperlink:{url:n.src}}}],{...i,align:"center",valign:"middle",fill:{color:"2C2C2A"},color:"FFFFFF"});break}case"connector":!function(e,t,n){const i={color:Ii(n.stroke),width:Di(n.strokeWidth),beginArrowType:n.arrowStart?"triangle":"none",endArrowType:n.arrowEnd?"triangle":"none"};if("straight"===n.route){const l=Math.min(n.start.x,n.end.x),r=Math.min(n.start.y,n.end.y);return void t.addShape(e.ShapeType.line,{x:zi(l),y:zi(r),w:zi(Math.abs(n.end.x-n.start.x)),h:zi(Math.abs(n.end.y-n.start.y)),flipH:n.end.x<n.start.x!=n.end.y<n.start.y&&n.end.x<n.start.x,flipV:n.end.x<n.start.x!=n.end.y<n.start.y&&n.end.y<n.start.y,line:i})}const l=v(n),r=l.match(/-?\d+(\.\d+)?/g)?.map(Number)??[],o=[];if("elbow"===n.route){let e=r[0],t=r[1];o.push({x:e,y:t});for(const n of l.slice(l.indexOf(" ")+1).split(" ")){const i=Number(n.slice(1));"H"===n[0]?e=i:t=i,o.push({x:e,y:t})}}else{const[e,t,n,i,l,s,a,d]=r;for(let r=0;r<=16;r+=1){const c=r/16,m=1-c;o.push({x:m*m*m*e+3*m*m*c*n+3*m*c*c*l+c*c*c*a,y:m*m*m*t+3*m*m*c*i+3*m*c*c*s+c*c*c*d})}}t.addShape("custGeom",{x:zi(n.x),y:zi(n.y),w:zi(n.w),h:zi(n.h),points:o.map((e,t)=>0===t?{x:zi(e.x),y:zi(e.y),moveTo:!0}:{x:zi(e.x),y:zi(e.y)}),line:i})}(e,t,n);break;case"chart":!function(e,t,n,i){const{categories:l,series:r}=B(n),o="pie"===n.kind||"donut"===n.kind,s=(o?r.slice(0,1):r).map(e=>({name:e.name||" ",labels:l,values:e.values})),a=n.legend??(o||r.length>1?"bottom":"none");t.addChart(Fi[n.kind],s,{...i,barDir:"hbar"===n.kind?"bar":"col",chartColors:o?void 0:r.map(e=>Ii(e.color)),showValue:1===r.length&&!o,showPercent:o,showLegend:"none"!==a,legendPos:"right"===a?"r":"b"})}(0,t,n,i);break;case"table":!function(e,t,n){const{columnWidths:i,rowHeights:l,fontSize:r}=t,o=t.rows.map((e,n)=>e.flatMap((e,i)=>((e,t,n)=>e.merges?.some(e=>t>=e.row&&t<e.row+e.rows&&n>=e.col&&n<e.col+e.cols&&(t!==e.row||n!==e.col)))(t,n,i)?[]:[Pi(t,e,n,i)])),s=t.borderWidth??2;e.addTable(o,{...n,border:s?{type:"solid",color:Ii(t.borderColor??"#B4B2A9"),pt:Math.max(.25,Di(s))}:{type:"none"},...r?{fontSize:Di(r)}:{},...i?{colW:i.map(e=>e*n.w)}:{},...l?{rowH:l.map(zi)}:{}})}(t,n,i)}}async function Li(e,t){const n=await async function(e,t){const{default:n}=await(import("pptxgenjs")),i=new n;return i.defineLayout({name:"SLIDE_16_9",width:Ni,height:7.5}),i.layout="SLIDE_16_9",i.title=e,t.slides.forEach(e=>{const n=i.addSlide();n.background={color:Ii(e.background)},e.skip&&(n.hidden=!0),e.notes&&n.addNotes(e.notes);for(const t of e.elements)Ti(i,n,t);t.slideNumbers&&(n.slideNumber={x:zi(1780),y:zi(1010),fontSize:11,color:"888780"})}),i}(e,t);await n.writeFile({fileName:Mi(e)})}import{jsx as ji,jsxs as $i}from"react/jsx-runtime";var Ri=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t),Bi=(e,t)=>({title:e.layoutTitle,titleBody:e.layoutTitleBody,section:e.layoutSection,twoColumns:e.layoutTwoColumns,titleOnly:e.layoutTitleOnly,blank:e.layoutBlank}[t]);function Wi({onPick:e}){const t=c();return ji(He,{"aria-label":t.addShape,triggerLabel:t.addShape,trigger:ji(qe,{name:"shape-rect",size:16}),children:({close:n})=>ji("div",{className:"slides-shape-grid",role:"listbox","aria-label":t.addShape,children:ne.filter(e=>"line"!==e).map(i=>ji("button",{type:"button",title:t.shapeName(i),"aria-label":t.shapeName(i),onClick:()=>{e(i),n()},children:ji("svg",{viewBox:"-2 -2 28 28",width:22,height:22,"aria-hidden":"true",children:ji("path",{d:K(i,24,24),fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinejoin:"round"})})},i))})})}function Oi(e,t){return kt(t).filter(t=>t.first.slideId===e.id&&!t.first.resolvedAt).map((t,n)=>{const i=e.elements.find(e=>e.id===t.first.elementId);return{id:t.first.id,x:i?i.x+i.w-8:1880-40*n,y:i?i.y-28:16,count:1+t.replies.length}})}function Ki({deck:n,onClose:m,onReload:u}){const f=c(),b=d(),{store:g}=b,[v,y]=De(n.title),[k,w]=ze(me,void 0,()=>({past:[],present:oe(n.document),future:[]})),x=k.present,C=s(x),[S,N]=De(x.slides[0].id),[z,I]=De(new Set),[D,M]=De(!0),[E,F]=De(null),[L,j]=De("inspector"),[$,R]=De(null),[B,W]=De(null),[O,K]=De(!1),[U,H]=De(null),[V,_]=De([]),[J,q]=De(null),[X,G]=De(0),Y=Ie(null),Z=Ie(""),ee=x.slides.find(e=>e.id===S)??x.slides[0],te=x.slides.indexOf(ee);Se(()=>l(document,r(x)),[x]);const ne=Ie(n.version),ie=Ie(oe(n.document)),le=Ie(x);le.current=x;const[re,ae]=De(!1),ve=Ie(!1),ke=Ce(async()=>{const t=await g.get(n.id),i=oe(t.document),l=ie.current,r=le.current,o=e(l,r,i);return w({type:"rebase",rebase:t=>e(l,t,i)}),ie.current=i,ne.current=t.version,Ri(r,l)||ve.current||(ve.current=!0,Xe.info(f.merged)),o},[n.id,g,f.merged]),He=Ie(Promise.resolve()),Ge=je(),Qe=Ee({save:async t=>{await He.current.catch(()=>{});let i=t;for(let t=0;;t+=1)try{return ne.current=await g.save(n.id,i,ne.current),ie.current=i,void G(e=>e+1)}catch(n){if(!(n instanceof a)||t>=3)throw n;const l=ie.current;await ke(),i=e(l,i,ie.current)}},onFailure:(e,t)=>{e instanceof a?(Qe.stop(),ae(!0)):0===t&&Xe.error(f.saveFailed)}}),Ye=Ie(x),{push:Ze,flush:et}=Qe;Se(()=>{x!==Ye.current&&(Ye.current=x,Ri(x,ie.current)||Ze(x))},[x,Ze]),Se(()=>()=>{et()},[et]);const tt=Ce(()=>{b.comments?.list(n.id).then(_,()=>{})},[b.comments,n.id]);Se(tt,[tt]);const nt=Ne(()=>[...z],[z]),it=function(e,t,n,i){const[l,r]=xi([]),o=wi(null),s=wi(n);s.current=n;const a=wi(i);a.current=i,ki(()=>{if(!e.live)return;const n=e.live(t,e=>{if("saved"===e.event)return a.current.saved(e.payload.version);if("comments"===e.event)return a.current.comments();if("bye"===e.event)return r(t=>t.filter(t=>t.key!==e.payload.key));const{user:t,key:n,slide:i,selected:l}=e.payload;r(e=>[...e.filter(e=>e.key!==n),{key:n,user:t,slide:i,selected:l,color:Si(t.id)}]),"hello"===e.event&&o.current?.send({type:"presence",...s.current})});return o.current=n,n.send({type:"hello",...s.current}),()=>{n.close(),o.current=null,r([])}},[e,t]);const d=JSON.stringify(n);return ki(()=>{o.current?.send({type:"presence",...s.current})},[d]),l}(b,n.id,{slide:ee.id,selected:nt},{saved:e=>{e===ne.current||Date.parse(e)&&Date.parse(e)===Date.parse(ne.current)||(He.current=He.current.then(()=>Qe.hasPending()?void 0:ke()).catch(()=>{}))},comments:tt}),lt=it.filter(e=>e.slide===ee.id).map(e=>({key:e.key,name:e.user.name,color:e.color,selected:e.selected})),rt=Ce(e=>w({type:"commit",doc:e}),[]),ot=e=>rt(xe(x,ee.id,()=>e)),st=e=>ot(T(we(ee,z,e))),at=Ie(null),dt=e=>{N(e),I(new Set),W(null)},ct={text:C.text,accents:C.accents,shapeFill:x.theme?C.accents[0]:"#afa9ec",bodyFont:C.bodyFont},mt=e=>{ot({...ee,elements:[...ee.elements,e]}),I(new Set([e.id])),j("inspector")},ut=e=>mt(pe(e,ct)),ht=e=>{const t=pe("connector",ct);mt({...t,route:"elbow"===e?"elbow":"curved"===e?"curved":"straight",arrowEnd:"line"!==e,arrowStart:"double"===e||void 0})},pt={title:f.placeholderTitle,subtitle:f.placeholderSubtitle,body:f.placeholderBody},ft=(e=("title"===ee.layout?"titleBody":ee.layout??"titleBody"))=>{const t=o(e,C,pt);rt(ue(x,ee.id,t)),dt(t.id)},gt=()=>{ot(T(be(ee,z))),I(new Set)},vt=e=>{const t=$n(ee,z);switch(e.kind){case"align":return ot(T(function(e,t,n){const i=e.elements.filter(e=>t.has(e.id));if(0===i.length)return e;const l=1===new Set(i.map(e=>e.groupId??e.id)).size?jn:se(i),r=e=>e.groupId??e.id,o=new Map;for(const e of i){const t=r(e);o.set(t,o.has(t)?se([o.get(t),e]):e)}const s=e=>{switch(n){case"left":return{dx:l.x-e.x,dy:0};case"right":return{dx:l.x+l.w-e.x-e.w,dy:0};case"center":return{dx:l.x+(l.w-e.w)/2-e.x,dy:0};case"top":return{dx:0,dy:l.y-e.y};case"bottom":return{dx:0,dy:l.y+l.h-e.y-e.h};case"middle":return{dx:0,dy:l.y+(l.h-e.h)/2-e.y}}},a=new Map([...o].map(([e,t])=>[e,s(t)]));return we(e,t,e=>{const{dx:t,dy:n}=a.get(r(e));return ye(e,t,n)})}(ee,t,e.to),t));case"distribute":return ot(T(function(e,t,n){const i=e.elements.filter(e=>t.has(e.id));if(i.length<3)return e;const l=e=>"horizontal"===n?e.x:e.y,r=e=>"horizontal"===n?e.w:e.h,o=[...i].sort((e,t)=>l(e)-l(t)),s=o[0],a=o[o.length-1],d=o.reduce((e,t)=>e+r(t),0),c=(l(a)+r(a)-l(s)-d)/(o.length-1),m=new Map;let u=l(s);for(const e of o)m.set(e.id,u),u+=r(e)+c;return we(e,t,e=>"horizontal"===n?ye(e,m.get(e.id)-e.x,0):ye(e,0,m.get(e.id)-e.y))}(ee,t,e.axis),t));case"order":return ot({front:Tn,forward:de,backward:Fn,back:Ln}[e.to](ee,t));case"group":return ot(function(e,t){if(t.size<2)return e;const n=fe();return we(e,t,e=>({...e,groupId:n}))}(ee,t));case"ungroup":return ot(function(e,t){return we(e,t,({groupId:e,...t})=>t)}(ee,t));case"lock":return ot(function(e,t,n){return we(e,t,({locked:e,...t})=>n?{...t,locked:n}:t)}(ee,t,e.locked))}},yt=e=>{const t=ee.elements.filter(e=>z.has(e.id));if(0===t.length)return;const n=(i=t,JSON.stringify({type:Rn,elements:i}));var i;Z.current=n,navigator.clipboard?.writeText(n).catch(()=>{}),e&>()},wt=async()=>{const e=Bn(await(navigator.clipboard?.readText().catch(()=>""))||Z.current)??Bn(Z.current);if(!e)return;const t=Wn(ee,e);ot(t.slide),I(new Set(t.ids))},xt=()=>{const e=Wn(ee,ee.elements.filter(e=>z.has(e.id)));ot(e.slide),I(new Set(e.ids))},Ct=()=>{b.comments&&j("comments")},Nt=(e=te)=>{const t=window.open("about:blank","_blank","popup,width=1280,height=720");t&&(t.document.title=v),F({popup:t,at:e})},zt=Ie(()=>!1);zt.current=()=>!(E||0===z.size&&!B&&!U)&&(I(new Set),W(null),H(null),!0),Se(()=>Ve(()=>zt.current()),[]);const It=Je(),Dt=z.size>0,Mt=ee.elements.filter(e=>z.has(e.id)),Et=Dt&&Mt.every(e=>e.locked),At=[{type:"submenu",key:"order",label:f.order,disabled:!Dt,items:[{key:"front",label:f.bringToFront,onSelect:()=>vt({kind:"order",to:"front"})},{key:"forward",label:f.bringForward,onSelect:()=>vt({kind:"order",to:"forward"})},{key:"backward",label:f.sendBackward,onSelect:()=>vt({kind:"order",to:"backward"})},{key:"back",label:f.sendToBack,onSelect:()=>vt({kind:"order",to:"back"})}]},{type:"submenu",key:"align",label:f.align,disabled:!Dt,items:gn(f).map(({label:e,action:t})=>({key:e,label:e,onSelect:()=>vt(t)}))},{key:"group",label:f.group,disabled:z.size<2,onSelect:()=>vt({kind:"group"})},{key:"ungroup",label:f.ungroup,disabled:!Mt.some(e=>e.groupId),onSelect:()=>vt({kind:"ungroup"})},{key:"lock",label:Et?f.unlock:f.lock,disabled:!Dt,onSelect:()=>vt({kind:"lock",locked:!Et})},{type:"divider",key:"d-grid"},{type:"checkbox",key:"grid",label:f.grid,checked:O,onSelect:()=>K(e=>!e)}],Pt=It.state?.data?[{key:"cut",label:f.cut,onSelect:()=>yt(!0)},{key:"copy",label:f.copy,onSelect:()=>yt(!1)},{key:"paste",label:f.paste,onSelect:()=>{wt()}},{key:"duplicate",label:f.duplicate,onSelect:xt},{key:"copy-style",label:f.copyStyle,onSelect:()=>{return Y.current=Mt[0]?"text"===(e=Mt[0]).type?{fontSize:e.fontSize,bold:e.bold,color:e.color,font:e.font}:"shape"===e.type?{fill:e.fill,stroke:e.stroke,strokeWidth:e.strokeWidth}:"connector"===e.type?{stroke:e.stroke,strokeWidth:e.strokeWidth}:{}:null;var e}},{key:"paste-style",label:f.pasteStyle,disabled:!Y.current,onSelect:()=>Y.current&&st(e=>function(e,t){if("text"===e.type){const n=A(e);return Q({...e,fontSize:t.fontSize??e.fontSize,bold:t.bold??e.bold,color:t.color??e.color,font:t.font},p(n,0,P(n).length,{size:void 0,bold:void 0,color:void 0,font:void 0}))}return"shape"===e.type?{...e,fill:t.fill??e.fill,stroke:t.stroke,strokeWidth:t.strokeWidth}:"connector"===e.type&&t.stroke?{...e,stroke:t.stroke,strokeWidth:t.strokeWidth??e.strokeWidth}:e}(e,Y.current))},{type:"divider",key:"d1"},...At.slice(0,5),...b.comments?[{type:"divider",key:"d2"},{key:"comment",label:f.comment,onSelect:Ct}]:[],{type:"divider",key:"d3"},{key:"delete",label:f.delete,danger:!0,onSelect:gt}]:[{key:"paste",label:f.paste,onSelect:()=>{wt()}},{key:"new-slide",label:f.newSlide,onSelect:()=>ft()},{key:"skip",label:ee.skip?f.unskipSlide:f.skipSlide,onSelect:()=>ot({...ee,skip:!ee.skip||void 0})},...b.comments?[{key:"comment",label:f.comment,onSelect:Ct}]:[]],Ft=1===Mt.length&&"text"===Mt[0].type?Mt[0]:null,Tt=(e,t,n)=>ji(Ke,{"aria-label":e,onClick:n,children:ji(qe,{name:t,size:16})},e),Lt=e=>j(t=>t===e?"inspector":e),$t=U?U.doc.slides.find(e=>e.id===ee.id)??U.doc.slides[Math.min(te,U.doc.slides.length-1)]:ee;return $i("div",{className:"es-editor slides-editor",onKeyDown:e=>{if(E||U)return;if(e.target.closest('input, textarea, select, [contenteditable], [role="listbox"], [role="menu"], [role="dialog"]'))return;const t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase(),i=z.size>0;if(t&&"z"===n)e.preventDefault(),w({type:e.shiftKey?"redo":"undo"});else if(t&&"y"===n)e.preventDefault(),w({type:"redo"});else if(t&&"a"===n)e.preventDefault(),I(new Set(ee.elements.filter(e=>!e.locked).map(e=>e.id)));else if(t&&"d"===n&&i)e.preventDefault(),xt();else if(t&&("c"===n||"x"===n)&&i)e.preventDefault(),yt("x"===n);else if(t&&"v"===n)e.preventDefault(),wt();else if(t&&"g"===n&&i)e.preventDefault(),vt({kind:e.shiftKey?"ungroup":"group"});else if(t&&e.altKey&&"m"===n)e.preventDefault(),Ct();else if(t&&("ArrowUp"===e.key||"ArrowDown"===e.key)&&i){e.preventDefault();const t="ArrowUp"===e.key;vt({kind:"order",to:e.shiftKey?t?"front":"back":t?"forward":"backward"})}else if("Delete"!==e.key&&"Backspace"!==e.key||!i){if("Escape"===e.key)I(new Set),W(null);else if(e.key.startsWith("Arrow")&&i){e.preventDefault();const t=e.shiftKey?1:10,n="ArrowLeft"===e.key?-t:"ArrowRight"===e.key?t:0,i="ArrowUp"===e.key?-t:"ArrowDown"===e.key?t:0,l=new Set(ee.elements.filter(e=>z.has(e.id)&&!e.locked).map(e=>e.id));ot(T(we(ee,l,e=>ye(e,n,i)),l))}}else e.preventDefault(),gt()},tabIndex:-1,children:[$i(Pe,{children:[$i(Te,{children:[ji(Ae,{label:f.backToDecks,onClick:m,children:ji(qe,{name:"chevron-left",size:16})}),ji(Ae,{label:f.slidesPanel,state:D?"active":"inactive",onClick:()=>M(e=>!e),children:ji(qe,{name:"bars-3-bottom-left",size:16})}),ji("div",{className:"slides-title",children:ji(Ue,{"aria-label":f.deckName,value:v,onChange:e=>y(e.target.value),onBlur:()=>{const e=v.trim();e&&e!==n.title?g.rename(n.id,e).catch(()=>Xe.error(f.renameFailed)):y(e||n.title)}})}),ji(Fe,{...Me(Qe.state,Ge.save)}),ji(Le,{}),ji(Ae,{label:f.undo,disabled:0===k.past.length,onClick:()=>w({type:"undo"}),children:ji(qe,{name:"undo",size:16})}),ji(Ae,{label:f.redo,disabled:0===k.future.length,onClick:()=>w({type:"redo"}),children:ji(qe,{name:"redo",size:16})})]}),$i(Te,{kind:"right",children:[it.length>0&&ji("span",{className:"slides-visitors",title:f.editingNow(it.map(e=>e.user.name).join(", ")),children:ji($e,{size:"sm",max:4,children:[...new Map(it.map(e=>[e.user.id,e])).values()].map(e=>ji(Re,{name:e.user.name,size:"sm"},e.user.id))})}),b.versions&&ji(Ae,{label:f.versionHistory,state:"history"===L?"active":"inactive",onClick:()=>Lt("history"),children:ji(qe,{name:"clock",size:16})}),b.comments&&ji(Ae,{label:f.commentCount(kt(V).filter(e=>!e.first.resolvedAt).length),state:"comments"===L?"active":"inactive",onClick:()=>Lt("comments"),children:ji(qe,{name:"chat",size:16})}),ji(Oe,{"aria-label":f.export,trigger:$i("span",{className:"slides-export-trigger",children:[ji(qe,{name:"download",size:16}),f.export]}),items:[{key:"pptx",label:f.exportPptx,onSelect:()=>{Li(v,x).catch(()=>Xe.error(f.exportFailed))}},{key:"pdf",label:f.exportPdf,onSelect:()=>{(async()=>{const{deckToPdf:e}=await(import("./deckPdf-4RC7QJ45.js")),t=await e(x),n=URL.createObjectURL(t),i=document.createElement("a");i.href=n,i.download=`${v.trim()||"Deck"}.pdf`,i.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)})().catch(()=>Xe.error(f.exportFailed))}}]}),ji(Be,{leftIcon:ji(qe,{name:"play",size:16}),onClick:()=>Nt(),children:f.present})]})]}),re&&$i("div",{className:"slides-conflict",role:"alert",children:[ji("span",{children:f.conflict}),ji(Be,{variant:"secondary",onClick:u,children:f.reload})]}),U&&$i("div",{className:"slides-conflict",role:"status",children:[ji("span",{children:f.previewVersion}),ji(Be,{variant:"secondary",onClick:()=>H(null),children:f.closePreview})]}),$i("div",{className:"slides-body",children:[D&&ji(Mn,{slides:x.slides,currentId:ee.id,numbers:!!x.slideNumbers,visitors:it,onShow:dt,onAdd:()=>ft(),onMove:(e,t)=>rt(he(x,e,t)),onDuplicate:e=>{const t=x.slides.find(t=>t.id===e);if(!t)return;const n=ce(t);rt(ue(x,e,n)),dt(n.id)},onDelete:e=>{const t=ge(x,e);rt(t),e===ee.id&&dt(t.slides[Math.min(te,t.slides.length-1)].id)},onSkip:e=>rt(xe(x,e,e=>({...e,skip:!e.skip||void 0})))}),$i("div",{className:"slides-centre",children:[$i("div",{className:"slides-toolbar",children:[ji(Oe,{"aria-label":f.newSlide,trigger:$i("span",{className:"slides-export-trigger",children:[f.newSlide,ji(qe,{name:"chevron-down",size:14})]}),items:[{type:"label",key:"l",label:f.layouts},...t.map(e=>({key:e,label:Bi(f,e),onSelect:()=>ft(e)}))]}),Tt(f.addText,"type",()=>ut("text")),Tt(f.addImage,"image",()=>ut("image")),ji(Wi,{onPick:e=>mt({...pe("shape",ct),shape:e})}),ji(Oe,{"aria-label":f.addLine,trigger:ji(qe,{name:"line-solid",size:16}),items:[{key:"line",label:f.lineStraight,onSelect:()=>ht("line")},{key:"arrow",label:f.lineArrow,onSelect:()=>ht("arrow")},{key:"double",label:f.lineDoubleArrow,onSelect:()=>ht("double")},{key:"elbow",label:f.connectorElbow,onSelect:()=>ht("elbow")},{key:"curved",label:f.connectorCurved,onSelect:()=>ht("curved")}]}),Tt(f.addTable,"table",()=>ut("table")),Tt(f.addChart,"chart-bar",()=>ut("chart")),Tt(f.addVideo,"block-video",()=>ut("video")),ji("span",{className:"slides-tool-gap"}),ji(Oe,{"aria-label":f.arrange,trigger:$i("span",{className:"slides-export-trigger",children:[f.arrange,ji(qe,{name:"chevron-down",size:14})]}),items:At}),ji(Be,{variant:"theme"===L?"primary":"secondary",size:"sm",onClick:()=>Lt("theme"),children:f.theme}),ji(Be,{variant:"motion"===L?"primary":"secondary",size:"sm",onClick:()=>Lt("motion"),children:f.motion})]}),Ft&&!U&&ji(hi,{element:Ft,editing:$,slides:x.slides,accents:C.accents,onBox:e=>ot(we(ee,new Set([Ft.id]),t=>e(t)))}),U?ji("div",{className:"slides-pane slides-preview",children:ji(h,{slide:$t,width:720,number:U.doc.slideNumbers?te+1:void 0})}):ji(Zn,{slide:ee,selected:z,onSelect:e=>I(e),onLive:e=>{at.current??=x,w({type:"live",doc:xe(at.current,ee.id,()=>e)})},onSettle:()=>{at.current&&w({type:"settle",from:at.current}),at.current=null},onCommit:ot,onEditing:R,onLink:()=>{document.querySelector(`[data-text-toolbar] button[aria-label="${CSS.escape(f.link)}"]`)?.click()},cells:B,onCells:W,onContextMenu:(e,t)=>It.open(e,t),visitors:lt,pins:b.comments?Oi(ee,V):[],onPin:e=>{q(e),j("comments")},grid:O,slideNumber:x.slideNumbers?te+1:void 0},ee.id),$i("label",{className:"slides-notes",children:[ji("span",{children:f.speakerNotes}),ji(_e,{rows:2,value:ee.notes,onChange:e=>ot({...ee,notes:e.target.value})})]})]}),"inspector"===L&&ji(yn,{slide:ee,selected:Mt,onChangeSlide:e=>ot({...ee,...e}),onChangeSelected:st,onAlign:e=>vt({kind:"align",to:e}),onForward:()=>vt({kind:"order",to:"forward"}),onDelete:gt,onArrange:vt,cells:B,accents:C.accents}),"theme"===L&&ji(yi,{doc:x,slide:ee,onTheme:e=>rt(i(x,e)),onDeck:e=>rt({...x,...e}),onSlide:e=>ot({...ee,...e})}),"motion"===L&&ji(bt,{slide:ee,slideNumber:te+1,selected:Mt,onSlide:e=>ot({...ee,...e}),onAllSlides:e=>rt({...x,slides:x.slides.map(t=>({...t,...e}))}),onPlay:()=>Nt(te)}),"comments"===L&&b.comments&&ji(St,{comments:V,slides:x.slides,slide:ee,selectedId:1===Mt.length?Mt[0].id:null,focusId:J,onAdd:async e=>{const t=await b.comments.add(n.id,e);_(e=>[...e,t])},onUpdate:(e,t)=>b.comments.update(n.id,e,t).then(t=>_(n=>n.map(n=>n.id===e?t:n)),()=>Xe.error(f.commentFailed)),onRemove:e=>b.comments.remove(n.id,e).then(()=>_(t=>t.filter(t=>t.id!==e&&t.parent!==e)),()=>Xe.error(f.commentFailed)),onShowSlide:dt}),"history"===L&&ji(jt,{deckId:n.id,previewing:U?.id??null,refreshKey:X,onPreview:(e,t)=>H(e?{id:e,doc:oe(t)}:null),onRestore:e=>{H(null);const t=oe(e);rt(t),t.slides.some(e=>e.id===ee.id)||dt(t.slides[0].id)}})]}),It.state&&ji(We,{...It.props,items:Pt,"aria-label":f.arrange}),E&&ji(tn,{slides:x.slides,startIndex:E.at,numbers:!!x.slideNumbers,fonts:r(x),popup:E.popup,onEnd:()=>F(null)})]})}export{Ki as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{importSpreadsheetFile as e,readWithSheetJs as t}from"./chunk-DG4VDXLL.js";import{readXlsx as r,writeXlsx as n}from"./chunk-MR7ZWQHF.js";import{SPREADSHEET_ACCEPT as o,SPREADSHEET_EXTENSIONS as l,SpreadsheetsConflict as a,sheetsOf as i,useSpreadsheetWords as c,useSpreadsheetsHost as s}from"./chunk-NRGUS5QY.js";import"./chunk-UKGIT2RS.js";import{DEFAULT_COL_WIDTH as u,DEFAULT_FONT_SIZE as d,DEFAULT_ROW_HEIGHT as f,FUNCTION_NAMES as h,MAX_COLS as m,MAX_ROWS as g,NUMBER_FORMATS as p,adjustDecimals as v,applyBorders as w,cellDisplay as x,cellLabel as b,changeStructure as y,clearValues as C,colLabel as k,columnValues as N,commitEntry as E,copyClip as S,cycleRefAbsolute as D,dataRegion as R,deleteSheet as T,duplicateSheet as M,editText as A,expandForMerges as z,fillRange as F,filteredRows as I,findCells as L,formatKey as O,formatNumber as P,isFormula as U,makeEvaluator as $,mergeRange as B,mergedAt as K,moveCells as H,newSheet as W,nextSheetName as X,normalizeRange as V,parseCsv as Y,parseRangeLabel as G,pasteClip as j,printRef as _,rangeContains as Q,rangeLabel as Z,rawAt as q,readEntry as J,renameSheet as ee,replaceInCell as te,selectionStats as re,serializeCsv as ne,sheetFromRows as oe,shiftFormula as le,sortRange as ae,tokenize as ie,unmergeRange as ce,updateFormats as se,usedBounds as ue,withFormat as de,writeCells as fe}from"./chunk-ZS45QEF4.js";import{FileList as he}from"./chunk-PMGQ5GUH.js";import"./chunk-B32ASXHM.js";import{placeCopy as me}from"./chunk-XYVQTQ6N.js";import{useCallback as ge,useEffect as pe,useMemo as ve,useRef as we,useState as xe}from"react";import{saveIndicator as be,useAutosave as ye}from"efficient-easel/autosave";import{SaveState as Ce}from"efficient-easel/chrome";import"efficient-easel/chrome.css";import{useEaselStrings as ke}from"efficient-easel/strings";import{WindowTitle as Ne,useBrowserLayoutEffect as Ee,useWindowDirty as Se}from"efficient-shell";import{Icon as De}from"efficient-shell/icons";import{Button as Re,Checkbox as Te,ColorPickerPanel as Me,ContextMenu as Ae,DropdownMenu as ze,EmptyState as Fe,IconButton as Ie,Input as Le,LoadingSpinner as Oe,Popover as Pe,PopupMenu as Ue,PopupMenuDivider as $e,PopupMenuItem as Be,confirmDestructive as Ke,registerModalEscapeInterceptor as He,toDateKey as We,toast as Xe,useContextMenu as Ve}from"efficient-shell/ui";import{SPREADSHEET_PREVIEW_UPDATE_EVENT as Ye,peekSpreadsheetPreviewStage as Ge,claimSpreadsheetPreviewStage as je}from"efficient-shell/apps";import{forwardRef as _e,useCallback as Qe,useEffect as Ze,useImperativeHandle as qe,useMemo as Je,useRef as et,useState as tt}from"react";import{Icon as rt}from"efficient-shell/icons";import{jsx as nt,jsxs as ot}from"react/jsx-runtime";var lt,at=46,it=24,ct=4/3;function st(e,t){const r=new Float64Array(e+1);for(let n=0;n<e;n++)r[n+1]=r[n]+t(n);return r}function ut(e,t){let r=0,n=e.length-2;for(;r<n;){const o=r+n+1>>1;e[o]<=t?r=o:n=o-1}return r}function dt(e,t){if(void 0===lt)try{lt=document.createElement("canvas").getContext("2d")}catch{lt=null}const r=(t?.fontSize??d)*ct;return lt?(lt.font=`${t?.italic?"italic ":""}${t?.bold?"bold ":""}${r}px system-ui, sans-serif`,lt.measureText(e).width):e.length*r*.55}var ft=_e(function({sheet:e,sheetIndex:t,evaluator:r,filterHidden:n,selection:o,showGridlines:l,showFormulas:a,clipRange:i,highlights:s,pointing:h,onSelect:m,onPoint:g,onEdit:p,onFill:v,onResizeCol:w,onResizeRow:b,onAutoFitCol:y,onAutoFitRow:C,onHeaderMenu:N,onFilterButton:E,renderEditor:S,onKeyDown:D,onCopy:R,onCut:T,onPaste:M},A){const F=c(),I=et(null),[L,P]=tt({x:0,y:0}),[U,$]=tt({width:1e3,height:600}),[B,H]=tt(null),[W,X]=tt(null),[Y,G]=tt(null);Ze(()=>{const e=I.current;if(!e)return;const t=()=>{e.clientWidth&&e.clientHeight&&$({width:e.clientWidth,height:e.clientHeight})};if(t(),"undefined"==typeof ResizeObserver)return;const r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]);const j=Je(()=>{const n=new Map;for(const[o,l]of Object.entries(e.formats)){if(!l.fontSize&&!l.wrap)continue;const[a,i]=o.split(":").map(Number);if(void 0!==e.rowHeights[a])continue;const c=(l.fontSize??d)*ct*1.4;let s=1;if(l.wrap&&""!==q(e,a,i)){const n=(e.colWidths[i]??u)-8;s=x(e,t,r,a,i).text.split("\n").reduce((e,t)=>e+Math.max(1,Math.ceil(dt(t,l)/Math.max(n,1))),0)}const h=Math.ceil(c*s+6);h>(n.get(a)??f)&&n.set(a,h)}return n},[e,t,r]),_=Je(()=>new Set(e.hiddenRows),[e.hiddenRows]),Q=Je(()=>new Set(e.hiddenCols),[e.hiddenCols]),Z=Je(()=>st(e.rowCount,t=>_.has(t)||n.has(t)?0:W?.row===t?W.height:e.rowHeights[t]??j.get(t)??f),[e.rowCount,e.rowHeights,_,n,j,W]),J=Je(()=>st(e.colCount,t=>Q.has(t)?0:B?.col===t?B.width:e.colWidths[t]??u),[e.colCount,e.colWidths,Q,B]),ee=Math.min(e.frozenRows,e.rowCount),te=Math.min(e.frozenCols,e.colCount),re=Z[ee],ne=J[te],oe=J[e.colCount],le=Z[e.rowCount],ae=Qe(e=>at+J[e]-(e>=te?L.x:0),[J,te,L.x]),ie=Qe(e=>it+Z[e]-(e>=ee?L.y:0),[Z,ee,L.y]),ce=Qe(e=>{const t=I.current;if(!t)return;const r=t.clientWidth-at-ne,n=t.clientHeight-it-re;let{scrollLeft:o,scrollTop:l}=t;if(e.col>=te){const t=J[e.col]-ne,n=J[e.col+1]-ne;t<o?o=t:n>o+r&&(o=n-r)}if(e.row>=ee){const t=Z[e.row]-re,r=Z[e.row+1]-re;t<l?l=t:r>l+n&&(l=r-n)}t.scrollTo(o,l)},[J,Z,ne,re,te,ee]);qe(A,()=>({focus:()=>I.current?.focus({preventScroll:!0}),scrollTo:ce,measureColumn:n=>{let o=0;for(let l=0;l<e.cells.length;l++){if(""===q(e,l,n))continue;const a=e.formats[O(l,n)];o=Math.max(o,dt(x(e,t,r,l,n).text,a))}return Math.ceil(o+8+4)}}),[ce,e,t,r]);const se=Qe((e,t)=>{const r=I.current.getBoundingClientRect(),n=e-r.left-at,o=t-r.top-it,l=n<ne?n:n+I.current.scrollLeft,a=o<re?o:o+I.current.scrollTop;return{row:ut(Z,Math.max(0,Math.min(a,le-1))),col:ut(J,Math.max(0,Math.min(l,oe-1)))}},[J,Z,ne,re,oe,le]),ue=Qe((e,t)=>{const r=I.current,n=t=>{const n=r.getBoundingClientRect();t.clientY>n.bottom-4?r.scrollBy(0,24):t.clientY<n.top+it&&r.scrollBy(0,-24),t.clientX>n.right-4?r.scrollBy(24,0):t.clientX<n.left+at&&r.scrollBy(-24,0),e(t)},o=e=>{window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",o),window.removeEventListener("pointercancel",o),t(e)};window.addEventListener("pointermove",n),window.addEventListener("pointerup",o),window.addEventListener("pointercancel",o)},[]),de=Qe((t,r)=>{const n=z(e,V(t,r));m({active:t,range:n})},[e,m]),fe=Math.max(0,U.width-at-ne),he=Math.max(0,U.height-it-re),me=ut(Z,re+L.y),ge=ut(J,ne+L.x),pe=Math.min(e.rowCount-1,ut(Z,re+L.y+he)),ve=Math.min(e.colCount-1,ut(J,ne+L.x+fe)),we=(n,o,i,c)=>{const s=[],u=[],f=new Set,h=(n,o,i)=>{const c=O(n,o);if(f.has(c))return;f.add(c);const h=i?i.r2:n,m=i?i.c2:o,g=J[o],p=Z[n],v=J[m+1]-g,w=Z[h+1]-p;if(v<=0||w<=0)return;const b=e.formats[c],y=q(e,n,o),C=a&&"="===y[0]?{text:y,color:null,align:"left",error:!1}:x(e,t,r,n,o),k=b?.border,N="1px solid var(--ink)",E=!!b?.fill||!!k||!!i,S=l?"1px solid var(--line-subtle)":"1px solid transparent",D={position:"absolute",left:g,top:p,width:v,height:w,boxSizing:"border-box",borderRight:k?.right?N:S,borderBottom:k?.bottom?N:S,borderTop:k?.top?N:void 0,borderLeft:k?.left?N:void 0,background:b?.fill??(i?"var(--surface)":void 0)};if((E||l)&&s.push(nt("div",{style:D},`b${c}`)),!C.text)return;const R=b?.align??C.align;let T=C.text;"string"==typeof T&&!C.error&&"right"===C.align&&!b?.wrap&&dt(T,b)>v-4&&(T="#".repeat(Math.max(1,Math.floor(v/8))));let M=v,A=0;if(!i&&!b?.wrap&&"left"===C.align&&dt(T,b)>v-8){if("left"===R||"center"===R)for(let t=o+1;t<=Math.min(o+40,e.colCount-1)&&(""===q(e,n,t)&&!K(e,n,t));t++)M+=J[t+1]-J[t];if("right"===R||"center"===R)for(let t=o-1;t>=Math.max(o-40,0)&&(""===q(e,n,t)&&!K(e,n,t));t--)A+=J[t+1]-J[t]}const z=b?.vAlign??"bottom",F=C.error?"var(--danger-text)":C.color??b?.color;u.push(nt("div",{"data-cell":c,className:"pointer-events-none",style:{position:"absolute",left:g-A,top:p,width:M+A,height:w,boxSizing:"border-box",padding:"0 4px",overflow:"hidden",display:"flex",alignItems:"top"===z?"flex-start":"middle"===z?"center":"flex-end",justifyContent:b?.wrap?void 0:"right"===R?"flex-end":"center"===R?"center":"flex-start",textAlign:R,whiteSpace:b?.wrap?"pre-wrap":"pre",wordBreak:b?.wrap?"break-word":void 0,fontSize:(b?.fontSize??d)*ct,lineHeight:1.3,paddingBottom:"bottom"===z?2:void 0,fontWeight:b?.bold?700:void 0,fontStyle:b?.italic?"italic":void 0,textDecoration:[b?.underline?"underline":"",b?.strike?"line-through":""].join(" ").trim()||void 0,color:F},children:nt("span",{style:b?.wrap?{width:"100%"}:void 0,children:T})},`t${c}`))};for(let t=n;t<=o;t++)for(let r=i;r<=c;r++){const n=K(e,t,r);(!n||n.r1===t&&n.c1===r)&&h(t,r,n)}for(const t of e.merges)(t.r1<n||t.c1<i)&&t.r2>=n&&t.r1<=o&&t.c2>=i&&t.c1<=c&&h(t.r1,t.c1,t);return[...s,...u]},xe=(t,r,n,l)=>{const a=[],c=(e,o,i,c)=>{e.r2<t||e.r1>r||e.c2<n||e.c1>l||a.push(nt("div",{style:{position:"absolute",boxSizing:"border-box",pointerEvents:"none",left:J[e.c1],top:Z[e.r1],width:J[e.c2+1]-J[e.c1],height:Z[e.r2+1]-Z[e.r1],...i},children:c},o))},u=o.range,d=u.r1!==u.r2||u.c1!==u.c2,f=K(e,o.active.row,o.active.col),h=!!f&&f.r1===u.r1&&f.r2===u.r2&&f.c1===u.c1&&f.c2===u.c2;return c(u,"sel",{background:d&&!h?"color-mix(in srgb, var(--accent-fill) 12%, transparent)":void 0,border:"2px solid var(--accent-fill)"}),Y&&c(Y,"fill",{border:"1px dashed var(--ink-muted)"}),i&&c(i,"clip",{border:"2px dashed var(--accent-fill)"}),s.forEach((e,t)=>c(e.range,`ref${t}`,{border:`2px solid ${e.color}`,background:`color-mix(in srgb, ${e.color} 10%, transparent)`})),a},be=[];ee&&te&&be.push({key:"corner",left:at,top:it,width:ne,height:re,offsetX:0,offsetY:0,r1:0,r2:ee-1,c1:0,c2:te-1}),ee&&be.push({key:"top",left:at+ne,top:it,width:fe,height:re,offsetX:L.x,offsetY:0,r1:0,r2:ee-1,c1:ge,c2:ve}),te&&be.push({key:"left",left:at,top:it+re,width:ne,height:he,offsetX:0,offsetY:L.y,r1:me,r2:pe,c1:0,c2:te-1}),be.push({key:"main",left:at+ne,top:it+re,width:fe,height:he,offsetX:L.x,offsetY:L.y,r1:me,r2:pe,c1:ge,c2:ve});const ye=o.range,Ce=[];for(let e=0;e<te;e++)Ce.push(e);for(let e=ge;e<=ve;e++)Ce.push(e);const ke=[];for(let e=0;e<ee;e++)ke.push(e);for(let e=me;e<=pe;e++)ke.push(e);const Ne=0===ye.r1&&ye.r2===e.rowCount-1,Ee=0===ye.c1&&ye.c2===e.colCount-1,Se="absolute flex items-center justify-center select-none text-xs border-r border-b border-line",De="bg-accent-tint text-accent-text",Re="bg-surface-sunken text-ink-muted",Te=ye.r2<ee||ye.r2>=me,Me=ae(ye.c2+1),Ae=ie(ye.r2+1),ze=Te&&!h&&Me>=at&&Ae>=it&&Me<=U.width&&Ae<=U.height,Fe=K(e,o.active.row,o.active.col)??{r1:o.active.row,c1:o.active.col,r2:o.active.row,c2:o.active.col},Ie={x:ae(Fe.c1),y:ie(Fe.r1),width:J[Fe.c2+1]-J[Fe.c1],height:Z[Fe.r2+1]-Z[Fe.r1],viewportWidth:U.width,viewportHeight:U.height},{filter:Le}=e,Oe=Le?.range.r1??-1,Pe=[];if(Le&&(Oe<ee||Oe>=me&&Oe<=pe))for(let e=Le.range.c1;e<=Le.range.c2;e++)J[e+1]>J[e]&&(e<te||e>=ge&&e<=ve)&&Pe.push(e);return nt("div",{ref:I,tabIndex:0,role:"grid","aria-label":e.name,"aria-rowcount":e.rowCount,"aria-colcount":e.colCount,className:"relative h-full w-full overflow-auto outline-none bg-surface text-ink",onScroll:e=>P({x:e.currentTarget.scrollLeft,y:e.currentTarget.scrollTop}),onKeyDown:D,onCopy:R,onCut:T,onPaste:M,children:nt("div",{style:{width:at+oe,height:it+le},children:ot("div",{className:"sticky top-0 left-0 overflow-hidden",style:{width:U.width,height:U.height},children:[ot("div",{className:"absolute inset-0",onPointerDown:t=>{if(0!==t.button)return;const r=se(t.clientX,t.clientY);if(h)return t.preventDefault(),g(V(r,r),!1),void ue(e=>g(V(r,se(e.clientX,e.clientY)),!1),e=>g(V(r,se(e.clientX,e.clientY)),!0));if(I.current?.focus({preventScroll:!0}),t.detail>=2)return t.preventDefault(),void p(r);const n=t.shiftKey?o.active:K(e,r.row,r.col)?{row:K(e,r.row,r.col).r1,col:K(e,r.row,r.col).c1}:r;de(n,r),ue(e=>de(n,se(e.clientX,e.clientY)),()=>{})},onContextMenu:e=>N(e,"cell",se(e.clientX,e.clientY)),children:[be.map(e=>nt("div",{className:"absolute overflow-hidden",style:{left:e.left,top:e.top,width:e.width,height:e.height},children:ot("div",{className:"absolute",style:{left:-e.offsetX,top:-e.offsetY,width:oe,height:le},children:[we(e.r1,e.r2,e.c1,e.c2),xe(e.r1,e.r2,e.c1,e.c2)]})},e.key)),re>0&&nt("div",{className:"absolute bg-line-strong pointer-events-none",style:{left:0,right:0,top:it+re-1,height:2}}),ne>0&&nt("div",{className:"absolute bg-line-strong pointer-events-none",style:{top:0,bottom:0,left:at+ne-1,width:2}})]}),Pe.map(e=>{const t=ae(e+1),r=ie(Oe),n=Z[Oe+1]-Z[Oe],o=(Le?.excluded[e]?.length??0)>0;return nt("button",{type:"button","aria-label":F.filterColumn(k(e)),onClick:t=>{t.stopPropagation(),E(e,t.currentTarget.getBoundingClientRect())},onPointerDown:e=>e.stopPropagation(),className:`absolute flex items-center justify-center rounded border ${o?"":"border-line"} ${o?"border-accent-fill bg-accent-tint":"bg-surface hover:bg-surface-sunken"}`,style:{left:t-19,top:r+Math.max(0,(n-17)/2),width:17,height:17},children:nt(rt,{name:"filter",size:11})},e)}),ze&&nt("div",{"aria-label":F.fillHandle,className:"absolute bg-accent-fill border border-surface cursor-crosshair",style:{left:Me-5,top:Ae-5,width:8,height:8},onPointerDown:e=>{e.preventDefault(),e.stopPropagation();const t=o.range;let r=null;ue(e=>{r=(e=>{const r=se(e.clientX,e.clientY);return(r.row>t.r2?r.row-t.r2:r.row<t.r1?t.r1-r.row:0)>=(r.col>t.c2?r.col-t.c2:r.col<t.c1?t.c1-r.col:0)?{...t,r1:Math.min(t.r1,r.row),r2:Math.max(t.r2,r.row)}:{...t,c1:Math.min(t.c1,r.col),c2:Math.max(t.c2,r.col)}})(e),G(r)},()=>{G(null),!r||r.r1===t.r1&&r.r2===t.r2&&r.c1===t.c1&&r.c2===t.c2||v(r)})}}),nt("div",{className:"absolute top-0 overflow-hidden bg-surface-sunken",style:{left:at,right:0,height:it},children:Ce.map(t=>{const r=J[t+1]-J[t];if(r<=0)return null;const n=J[t]-(t>=te?L.x:0),l=t>=ye.c1&&t<=ye.c2;return ot("div",{className:`${Se} ${l?De:Re} ${l&&Ne?"font-semibold":""}`,style:{left:n,top:0,width:r,height:it},onPointerDown:r=>((t,r)=>{if(0!==t.button)return;I.current?.focus({preventScroll:!0});const n=t.shiftKey?o.active.col:r,l=t=>{const r={r1:0,c1:Math.min(n,t),r2:e.rowCount-1,c2:Math.max(n,t)};m({active:{row:0,col:n},range:r})};l(r),ue(e=>l(se(e.clientX,e.clientY).col),()=>{})})(r,t),onContextMenu:e=>N(e,"col",{row:0,col:t}),children:[k(t),nt("div",{className:"absolute top-0 bottom-0 cursor-col-resize",style:{right:-3,width:7},onPointerDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation();const r=e.clientX,n=J[t+1]-J[t],o=e=>Math.max(16,Math.round(n+e.clientX-r));ue(e=>H({col:t,width:o(e)}),e=>{H(null),o(e)!==n&&w(t,o(e))})})(e,t),onDoubleClick:e=>{e.stopPropagation(),y(t)}})]},t)})}),nt("div",{className:"absolute left-0 overflow-hidden bg-surface-sunken",style:{top:it,bottom:0,width:at},children:ke.map(t=>{const r=Z[t+1]-Z[t];if(r<=0)return null;const n=Z[t]-(t>=ee?L.y:0),l=t>=ye.r1&&t<=ye.r2;return ot("div",{className:`${Se} ${l?De:Re} ${l&&Ee?"font-semibold":""}`,style:{left:0,top:n,width:at,height:r},onPointerDown:r=>((t,r)=>{if(0!==t.button)return;I.current?.focus({preventScroll:!0});const n=t.shiftKey?o.active.row:r,l=t=>{const r={r1:Math.min(n,t),c1:0,r2:Math.max(n,t),c2:e.colCount-1};m({active:{row:n,col:0},range:r})};l(r),ue(e=>l(se(e.clientX,e.clientY).row),()=>{})})(r,t),onContextMenu:e=>N(e,"row",{row:t,col:0}),children:[t+1,nt("div",{className:"absolute left-0 right-0 cursor-row-resize",style:{bottom:-3,height:7},onPointerDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation();const r=e.clientY,n=Z[t+1]-Z[t],o=e=>Math.max(12,Math.round(n+e.clientY-r));ue(e=>X({row:t,height:o(e)}),e=>{X(null),o(e)!==n&&b(t,o(e))})})(e,t),onDoubleClick:e=>{e.stopPropagation(),C(t)}})]},t)})}),nt("div",{role:"button","aria-label":F.selectAll,className:`${Se} top-0 left-0 cursor-pointer bg-surface-sunken hover:bg-line`,style:{width:at,height:it},onPointerDown:t=>{t.preventDefault(),I.current?.focus({preventScroll:!0}),m({active:{row:0,col:0},range:{r1:0,c1:0,r2:e.rowCount-1,c2:e.colCount-1}})},onContextMenu:e=>N(e,"corner",{row:0,col:0})}),S?.(Ie)]})})})}),ht=["#000000","#434343","#666666","#999999","#cccccc","#efefef","#ffffff","#c00000","#ff0000","#ffc000","#ffff00","#92d050","#00b050","#00b0f0","#0070c0","#002060","#7030a0","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#d9d2e9","#ead1dc"],mt=["#1a73e8","#d93025","#7b1fa2","#188038","#e37400","#c5221f"];function gt(e,t){let r=!1;for(let n=0;n<t;n++)'"'===e[n]&&(r=!r);return r}function pt(e,t){if("="!==e[0]||gt(e,t))return null;const r=/[A-Za-z][A-Za-z0-9.]*$/.exec(e.slice(0,t));if(!r)return null;if("!"===e[r.index-1]||"("===e[t])return null;const n=r[0].toUpperCase(),o=h.filter(e=>e.startsWith(n));return o.length?{start:r.index,prefix:n,matches:o.slice(0,8)}:null}var vt={ABS:"value",AND:"condition1, [condition2, ...]",AVERAGE:"value1, [value2, ...]",AVERAGEIF:"range, criterion, [average_range]",AVERAGEIFS:"average_range, range1, criterion1, ...",CEILING:"value, [factor]","CEILING.MATH":"value, [factor]",CHOOSE:"index, choice1, [choice2, ...]",COLUMN:"[cell]",COLUMNS:"range",CONCAT:"value1, [value2, ...]",CONCATENATE:"value1, [value2, ...]",COS:"angle",COUNT:"value1, [value2, ...]",COUNTA:"value1, [value2, ...]",COUNTBLANK:"range",COUNTIF:"range, criterion",COUNTIFS:"range1, criterion1, ...",DATE:"year, month, day",DATEDIF:"start, end, unit",DAY:"date",DAYS:"end, start",EDATE:"start, months",EOMONTH:"start, months",EXACT:"text1, text2",EXP:"value",FIND:"find, within, [start]",FLOOR:"value, [factor]","FLOOR.MATH":"value, [factor]",FV:"rate, periods, payment, [present], [type]",HLOOKUP:"key, range, row, [approximate]",HOUR:"time",IF:"condition, if_true, [if_false]",IFERROR:"value, [if_error]",IFNA:"value, [if_na]",IFS:"condition1, value1, ...",INDEX:"range, row, [column]",INT:"value",ISBLANK:"value",ISERROR:"value",ISLOGICAL:"value",ISNA:"value",ISNUMBER:"value",ISTEXT:"value",LARGE:"range, k",LEFT:"text, [count]",LEN:"text",LN:"value",LOG:"value, [base]",LOG10:"value",LOWER:"text",MATCH:"key, range, [type]",MAX:"value1, [value2, ...]",MEDIAN:"value1, [value2, ...]",MID:"text, start, count",MIN:"value1, [value2, ...]",MINUTE:"time",MOD:"value, divisor",MODE:"value1, [value2, ...]","MODE.SNGL":"value1, [value2, ...]",MONTH:"date",N:"value",NA:"",NETWORKDAYS:"start, end, [holidays]",NOT:"condition",NOW:"",NPV:"rate, value1, [value2, ...]",OR:"condition1, [condition2, ...]",PI:"",PMT:"rate, periods, present, [future], [type]",POWER:"value, exponent",PRODUCT:"value1, [value2, ...]",PROPER:"text",PV:"rate, periods, payment, [future], [type]",RAND:"",RANDBETWEEN:"low, high",RANK:"value, range, [ascending]","RANK.EQ":"value, range, [ascending]",REPLACE:"text, start, count, new",REPT:"text, count",RIGHT:"text, [count]",ROUND:"value, [places]",ROUNDDOWN:"value, [places]",ROUNDUP:"value, [places]",ROW:"[cell]",ROWS:"range",SEARCH:"find, within, [start]",SECOND:"time",SIGN:"value",SIN:"angle",SMALL:"range, k",SQRT:"value",STDEV:"value1, [value2, ...]","STDEV.P":"value1, [value2, ...]","STDEV.S":"value1, [value2, ...]",STDEVP:"value1, [value2, ...]",SUBSTITUTE:"text, find, new, [occurrence]",SUM:"value1, [value2, ...]",SUMIF:"range, criterion, [sum_range]",SUMIFS:"sum_range, range1, criterion1, ...",SUMPRODUCT:"range1, [range2, ...]",SWITCH:"value, case1, result1, ..., [default]",TAN:"angle",TEXT:"value, format",TEXTJOIN:"delimiter, skip_blank, value1, ...",TIME:"hour, minute, second",TODAY:"",TRIM:"text",TRUNC:"value, [places]",UPPER:"text",VALUE:"text",VAR:"value1, [value2, ...]","VAR.P":"value1, [value2, ...]","VAR.S":"value1, [value2, ...]",VARP:"value1, [value2, ...]",VLOOKUP:"key, range, column, [approximate]",WEEKDAY:"date, [type]",XLOOKUP:"key, lookup_range, result_range, [if_not_found], [match_mode]",XOR:"condition1, [condition2, ...]",YEAR:"date",CHAR:"number",CLEAN:"text",CODE:"text",ISERR:"value",ISEVEN:"value",ISODD:"value",MAXIFS:"max_range, range1, criterion1, ...",MINIFS:"min_range, range1, criterion1, ...",MROUND:"value, factor",PERCENTILE:"range, percentile","PERCENTILE.INC":"range, percentile",QUARTILE:"range, quartile","QUARTILE.INC":"range, quartile",QUOTIENT:"dividend, divisor",REGEXEXTRACT:"text, regular_expression",REGEXMATCH:"text, regular_expression",REGEXREPLACE:"text, regular_expression, replacement",SUBTOTAL:"function_code, range1, [range2, ...]",DATEVALUE:"text",ISOWEEKNUM:"date","NETWORKDAYS.INTL":"start, end, [weekend], [holidays]",TIMEVALUE:"text",WEEKNUM:"date, [type]",WORKDAY:"start, days, [holidays]","WORKDAY.INTL":"start, days, [weekend], [holidays]",YEARFRAC:"start, end, [basis]"};import{Fragment as wt,jsx as xt,jsxs as bt}from"react/jsx-runtime";var yt=[8,9,10,11,12,14,16,18,20,24,28,36],Ct="undefined"!=typeof navigator&&/Mac|iPhone|iPad/.test(navigator.platform),kt=Ct?"⌘":"Ctrl+";function Nt(e,t,r){const n=URL.createObjectURL(new Blob([e],{type:t})),o=document.createElement("a");o.href=n,o.download=r,o.click(),URL.revokeObjectURL(n)}var Et=o;function St({spreadsheetId:t,onClose:r}){const n=c(),{store:o,canCreate:a=!0,canDelete:i=!0,chooseFile:u}=s(),[d]=xe(()=>null!=Ge()),[f,h]=xe(null),[m,g]=xe(null);if(!o||d)return xt(Mt,{onClose:r});if(t)return xt(Rt,{store:o,id:t,onClose:r});if(f?.id)return xt(Rt,{store:o,id:f.id,onClose:()=>h(null)},f.key);if(f?.file)return xt(Mt,{initialFile:f.file,hasStore:!0,onClose:()=>h(null)},f.key);return xt(he,{words:{windowTitle:n.filesHeading,heading:n.filesHeading,newFile:n.newFile,emptyTitle:n.filesEmptyTitle,emptyBody:n.filesEmptyBody,deleteConfirm:n.deleteConfirm,createFailed:n.createFailed,deleteFailed:n.deleteFailed},files:n.files,list:o.list,create:()=>o.create(n.untitled),rename:o.rename,remove:o.remove,canCreate:a,canDelete:i,accept:Et,choose:u&&{run:u,request:{title:n.files.choosing(n.fileKind,n.filesHeading),extensions:l}},onOpen:e=>h({key:Date.now(),id:e}),onOpenFile:(t,r)=>{m||(g(n.files.opening(t.name)),e(o,t).then(async e=>{const o=await me(r,e.id);Xe.success(n.files.savedCopy(e.title,t.name,o?r?.location:void 0)),h({key:Date.now(),id:e.id})}).catch(()=>Xe.error(n.files.openFailed(t.name))).finally(()=>g(null)))},busy:m})}function Dt({id:e,onClose:t}){return xt(St,{spreadsheetId:e,onClose:t})}function Rt({store:e,id:t,onClose:r,pane:n}){const o=c(),[l,a]=xe(null),[i,s]=xe(!1),u=ge(()=>{s(!1),e.get(t).then(e=>a(t=>({kept:e,nonce:(t?.nonce??0)+1})),()=>s(!0))},[t,e]);return pe(u,[u]),i?xt("div",{className:"office-open-failed",children:xt(Fe,{title:o.storedOpenFailed,children:r&&xt(Re,{onClick:r,children:o.backToFiles})})}):l?xt(Mt,{stored:{store:e,...l.kept},onClose:r,onReload:u,pane:n},l.nonce):xt(Oe,{size:"sm",padding:"",className:"h-full",label:o.loading})}function Tt({initial:e,spreadsheetId:t,bridge:r,onSaveToFiles:n}){const{store:o}=s(),l=ve(()=>({bridge:r,onSaveToFiles:n}),[r,n]);return o&&t?xt(Rt,{store:o,id:t,pane:l}):xt(Mt,{initial:e??{rows:[],filename:""},pane:l})}function Mt({stored:e,initialFile:o,hasStore:l,onClose:s,onReload:u,initial:f,pane:h}){const x=c(),k=we(void 0);void 0===k.current&&(k.current=e?null:f?{token:-1,data:f}:Ge());const he=we(k.current?.data??null),[me]=xe(()=>{const e=k.current;if(!e)return null;const t=At(e.data,x.sheetName(1));return t?{sheet:t,title:e.data.filename.replace(/\.(csv|tsv|txt)$/i,"")}:-1===e.token&&e.data.filename?{sheet:W(x.sheetName(1)),title:e.data.filename}:null}),[Fe,Oe]=xe(()=>e?i(e.workbook,x.sheetName(1)):me?[me.sheet]:[W(x.sheetName(1))]),[_e,Qe]=xe(0),[Ze,qe]=xe(e?.title??me?.title??x.untitled),[Je,et]=xe(()=>k.current?.data.onEmail),tt=we(Fe),rt=we([]),nt=we([]),[,ot]=xe(0),lt=ge(e=>{const t=tt.current,r=e(t);r!==t&&(rt.current.push(t),rt.current.length>100&&rt.current.shift(),nt.current=[],tt.current=r,Oe(r),ot(e=>e+1))},[]),at=ge(e=>{rt.current=[],nt.current=[],tt.current=e,Oe(e),Qe(0),ot(e=>e+1)},[]),it=ge(()=>{const e=rt.current.pop();e&&(nt.current.push(tt.current),tt.current=e,Oe(e),Qe(t=>Math.min(t,e.length-1)),ot(e=>e+1))},[]),ct=ge(()=>{const e=nt.current.pop();e&&(rt.current.push(tt.current),tt.current=e,Oe(e),Qe(t=>Math.min(t,e.length-1)),ot(e=>e+1))},[]),st=we(Fe),ut=we(e?.version??""),dt=we(e?.title??""),[St,Dt]=xe(!1),Rt=ke(),Tt=ye({save:async t=>{e&&(ut.current=await e.store.save(e.id,{sheets:t},ut.current))},onFailure:(e,t)=>{e instanceof a?(Tt.stop(),Dt(!0)):0===t&&Xe.error(x.saveFailed)}}),{push:Mt,flush:zt}=Tt,Ft=we(Fe);pe(()=>{e&&Fe!==Ft.current&&(Ft.current=Fe,Mt(Fe))},[Mt,Fe,e]),pe(()=>()=>{zt()},[zt]),Se(e?Tt.state.pending||St:Fe!==st.current);const It=ge(e=>{const t=At(e,x.sheetName(1));t&&(at([t]),st.current=tt.current,qe(e.filename.replace(/\.(csv|tsv|txt)$/i,"")),et(()=>e.onEmail))},[at,x]);pe(()=>{const e=k.current;null!=e&&(je(e),e.data!==he.current&&It(e.data))},[]),pe(()=>{const e=k.current?.token;if(null==e)return;const t=t=>{const r=t.detail;r&&r.token===e&&It(r.data)};return window.addEventListener(Ye,t),()=>window.removeEventListener(Ye,t)},[]);const Lt=Math.min(_e,Fe.length-1),Ot=Fe[Lt],Pt=ve(()=>$(Fe),[Fe]),Ut=ve(()=>I(Ot,Lt,Pt),[Ot,Lt,Pt]),$t=we(null),Bt=we(null),[Kt,Ht]=xe({}),Wt=Kt[Ot.id]??{active:{row:0,col:0},range:{r1:0,c1:0,r2:0,c2:0}},Xt=we(_e);Xt.current=_e;const Vt=ge(e=>{Ht(t=>({...t,[tt.current[Math.min(Xt.current,tt.current.length-1)].id]:e}))},[]),Yt=Wt.active,Gt=Ot.formats[O(Yt.row,Yt.col)]??{},jt=q(Ot,Yt.row,Yt.col),[_t,Qt]=xe(null),Zt=we(_t);Zt.current=_t;const[qt,Jt]=xe(null),[er,tr]=xe(!0),[rr,nr]=xe(!1),[or,lr]=xe(null),[ar,ir]=xe(null),[cr,sr]=xe(!1),[ur,dr]=xe(null),[fr,hr]=xe(null),[mr,gr]=xe(!1),[pr,vr]=xe(""),[wr,xr]=xe(""),[br,yr]=xe({matchCase:!1,wholeCell:!1,inFormulas:!1}),Cr=we(null),kr=we(null),Nr=we(null),Er=Ve(),Sr=Ve(),Dr=ge(()=>{$t.current?.focus(),setTimeout(()=>{const e=document.activeElement;e&&e!==document.body&&!e.closest("[aria-haspopup]")||$t.current?.focus()},0)},[]),Rr=ge(e=>{lt(t=>{const r=Math.min(Xt.current,t.length-1),n=e(t[r]);return n===t[r]?t:t.map((e,t)=>t===r?n:e)})},[lt]),Tr=we(null),Mr=we(()=>!1);pe(()=>He(()=>!!Tr.current?.contains(document.activeElement)&&Mr.current()),[]);const Ar=ge(e=>Ot.hiddenRows.includes(e)||Ut.has(e),[Ot.hiddenRows,Ut]),zr=ge(e=>Ot.hiddenCols.includes(e),[Ot.hiddenCols]),Fr=ge(e=>{const t=K(Ot,e.row,e.col),r=t??{r1:e.row,c1:e.col,r2:e.row,c2:e.col};Vt({active:t?{row:t.r1,col:t.c1}:e,range:r}),$t.current?.scrollTo(e)},[Ot,Vt]),Ir=ge((e,t,r)=>{let{row:n,col:o}=e;const l=K(Ot,n,o);l&&(t>0&&(n=l.r2),t<0&&(n=l.r1),r>0&&(o=l.c2),r<0&&(o=l.c1));do{n+=t,o+=r}while(n>=0&&n<Ot.rowCount&&o>=0&&o<Ot.colCount&&(Ar(n)||zr(o)));return n<0||n>=Ot.rowCount||o<0||o>=Ot.colCount?e:{row:n,col:o}},[Ot,Ar,zr]),Lr=ge((e,t,r)=>{const n=e=>""!==q(Ot,e.row,e.col);let o=e,l=Ir(o,t,r);if(l===o)return o;if(n(o)&&n(l)){for(;n(l);)if(o=l,l=Ir(o,t,r),l===o)return o;return o}for(;!n(l);)if(o=l,l=Ir(o,t,r),l===o)return o;return l},[Ot,Ir]),Or=ge(e=>{const t=z(Ot,V(Wt.active,e));Vt({active:Wt.active,range:t}),$t.current?.scrollTo(e)},[Ot,Wt.active,Vt]),Pr=ge(()=>{const{range:e,active:t}=Wt;return{row:t.row===e.r1?e.r2:e.r1,col:t.col===e.c1?e.c2:e.c1}},[Wt]),Ur=we(null),$r=ge((e,t={})=>{const r=q(Ot,e.row,e.col),n=t.text??A(r,Ot.formats[O(e.row,e.col)]);Jt(e=>e?.cut?null:e),t.inBar||null!==Ur.current||(Ur.current=n.length),Qt({sheetId:Ot.id,row:e.row,col:e.col,text:n,mode:t.mode??(void 0!==t.text?"enter":"edit"),inBar:!!t.inBar,caret:n.length,pick:null,suggestion:0})},[Ot]),Br=ge(e=>{const t=Zt.current;if(!t)return!1;Zt.current=null,Qt(null),lt(r=>{const n=r.findIndex(e=>e.id===t.sheetId);if(n<0)return r;const o=r[n];if(t.text===A(q(o,t.row,t.col),o.formats[O(t.row,t.col)])&&!e)return r;let l=o;if(e)for(let r=e.r1;r<=e.r2;r++)for(let n=e.c1;n<=e.c2;n++){const e=U(t.text)?le(J(t.text).raw,r-t.row,n-t.col):t.text;l=E(l,r,n,e)}else l=E(l,t.row,t.col,t.text);return r.map((e,t)=>t===n?l:e)});const r=tt.current.findIndex(e=>e.id===t.sheetId);return r>=0&&r!==Xt.current&&Qe(r),!0},[lt]),Kr=ge(()=>{const e=Zt.current;if(Zt.current=null,Qt(null),e){const t=tt.current.findIndex(t=>t.id===e.sheetId);t>=0&&t!==Xt.current&&Qe(t)}Dr()},[Dr]),Hr=ge((e,t)=>{Fr(Ir(Wt.active,e,t)),Dr()},[Dr,Fr,Wt.active,Ir]);Ee(()=>{if(!_t)return;const e=_t.inBar?Cr.current:kr.current;e&&(document.activeElement!==e&&e.focus({preventScroll:!0}),null!==Ur.current&&(e.setSelectionRange(Ur.current,Ur.current),Ur.current=null))},[_t]);const Wr=ge((e,t)=>{Qt(r=>r?{...r,text:e,caret:t,pick:null,suggestion:0}:r)},[]),Xr=_t?.sheetId===Ot.id,Vr=_t?pt(_t.text,_t.caret):null,Yr=_t?function(e,t){if("="!==e[0])return null;const r=[];let n=!1;for(let o=1;o<t;o++){const t=e[o];if('"'===t&&(n=!n),!n)if("("===t){const t=/([A-Za-z][A-Za-z0-9.]*)$/.exec(e.slice(1,o));r.push({name:t?t[1].toUpperCase():"",argIndex:0})}else")"===t?r.pop():","!==t&&";"!==t||!r.length||r[r.length-1].argIndex++}for(let e=r.length-1;e>=0;e--)if(r[e].name)return r[e];return null}(_t.text,_t.caret):null,Gr=!!_t&&(null!==_t.pick||function(e,t){if("="!==e[0]||gt(e,t))return!1;const r=e.slice(0,t).trimEnd(),n=e.slice(t).trimStart()[0];return!(void 0!==n&&!/[,;)+\-*/^&=<>%]/.test(n))&&/[=(,;+\-*/^&<>]$/.test(r)}(_t.text,_t.caret)),jr=ve(()=>_t?function(e,t,r,n,o){if("="!==e[0])return[];const l=[];let a=0;for(const i of ie(e.slice(1)).tokens){if("ref"!==i.type)continue;const e=mt[a++%mt.length];if(!(null===i.ref.sheet?r:i.ref.sheet.toLowerCase()===t.toLowerCase()))continue;const c=i.ref.b??i.ref.a,s=V({row:i.ref.a.row??0,col:i.ref.a.col??0},{row:c.row??n-1,col:c.col??o-1});l.push({range:s,color:e})}return l}(_t.text,Ot.name,Xr,Ot.rowCount,Ot.colCount):[],[_t,Ot.name,Ot.rowCount,Ot.colCount,Xr]),_r=ge((e,t)=>{const r=Zt.current;if(!r)return;const n=_({sheet:r.sheetId===tt.current[Xt.current].id?null:tt.current[Xt.current].name,a:{row:e.r1,col:e.c1,rowAbs:!1,colAbs:!1},b:e.r1===e.r2&&e.c1===e.c2?null:{row:e.r2,col:e.c2,rowAbs:!1,colAbs:!1}}),o=r.pick?.start??r.caret,l=r.pick?.end??r.caret,a=r.text.slice(0,o)+n+r.text.slice(l),i=o+n.length;Ur.current=i,Qt({...r,text:a,caret:i,pick:t?null:{start:o,end:i}})},[]),Qr=ge(e=>{const t=Zt.current,r=t?pt(t.text,t.caret):null;if(!t||!r)return;const n=function(e,t,r,n){const o=`${n}(`;return{text:e.slice(0,r)+o+e.slice(t),caret:r+o.length}}(t.text,t.caret,r.start,e);Ur.current=n.caret,Qt({...t,text:n.text,caret:n.caret,suggestion:0,pick:null})},[]),Zr=e=>{if(_t){if(e.stopPropagation(),Vr){if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=Vr.matches.length;return void Qt({..._t,suggestion:(_t.suggestion+("ArrowDown"===e.key?1:t-1))%t})}if("Tab"===e.key||"Enter"===e.key&&_t.suggestion>0)return e.preventDefault(),void Qr(Vr.matches[_t.suggestion])}if("Enter"===e.key){if(e.altKey){e.preventDefault();const{selectionStart:t,selectionEnd:r,value:n}=e.currentTarget,o=`${n.slice(0,t)}\n${n.slice(r)}`;return Ur.current=t+1,void Wr(o,t+1)}return e.preventDefault(),e.ctrlKey||e.metaKey?(Br(Wt.range),void Dr()):(Br(),void Hr(e.shiftKey?-1:1,0))}if("Tab"===e.key)return e.preventDefault(),Br(),void Hr(0,e.shiftKey?-1:1);if("F4"===e.key){e.preventDefault();const t=function(e,t){if("="!==e[0])return null;const r=t-1;for(const t of ie(e.slice(1)).tokens){if("ref"!==t.type||r<t.start||r>t.end)continue;const n={...t.ref,a:D(t.ref.a),b:t.ref.b?D(t.ref.b):null},o=_(n);return{text:`=${e.slice(1,t.start+1)}${o}${e.slice(t.end+1)}`,caret:t.start+1+o.length}}return null}(_t.text,e.currentTarget.selectionStart);return void(t&&(Ur.current=t.caret,Wr(t.text,t.caret)))}"enter"!==_t.mode||_t.inBar||U(_t.text)||!e.key.startsWith("Arrow")||(e.preventDefault(),Br(),Hr("ArrowDown"===e.key?1:"ArrowUp"===e.key?-1:0,"ArrowRight"===e.key?1:"ArrowLeft"===e.key?-1:0))}},qr=e=>{const t=e.currentTarget.selectionStart;Qt(e=>e&&e.caret!==t?{...e,caret:t,pick:null}:e)},Jr=ge(e=>{Br(),e(),Dr()},[Br,Dr]),en=we(Wt);en.current=Wt;const tn=h?.bridge,rn=we(Ze);rn.current=Ze;const nn=Kt[Ot.id]?Wt:null,on=we(nn);on.current=nn,pe(()=>{if(tn)return tn.attach({sheets:()=>tt.current,activeSheet:()=>Math.min(Xt.current,tt.current.length-1),title:()=>rn.current||x.untitled,selection:()=>on.current?{sheet:Math.min(Xt.current,tt.current.length-1),range:on.current.range}:null,commit:e=>lt(()=>e),undoLast:it})},[tn,lt,x,it]),pe(()=>{tn?.changed()},[tn,nn,Lt,Fe,Ze]);const ln=ge(e=>{Jr(()=>Rr(t=>se(t,en.current.range,e)))},[Jr,Rr]),an=ge(e=>{const t=!Gt[e];ln(r=>de(r,e,t||void 0))},[Gt,ln]),cn=ge(e=>{ln(t=>de(t,"numFmt","General"===e?void 0:e))},[ln]),sn=ge(e=>{const t=Pt.value(Lt,Yt.row,Yt.col),r=v(Gt.numFmt??"General",e,"number"==typeof t?t:null);cn(r)},[Yt,Gt.numFmt,Pt,Lt,cn]),un=ge((e,t)=>{const{range:r}=Wt,[n,o]="row"===e?[r.r1,r.r2]:[r.c1,r.c2],l="row"===e?Ot.rowCount:Ot.colCount,a=o-n+1>=l?1:o-n+1;l+a>("row"===e?g:m)||Jr(()=>lt(r=>y(r,Lt,e,t?o+1:n,a)))},[Ot.colCount,Ot.rowCount,lt,Lt,Jr,Wt]),dn=ge(e=>{const{range:t}=Wt,[r,n]="row"===e?[t.r1,t.r2]:[t.c1,t.c2],o="row"===e?Ot.rowCount:Ot.colCount,l=Math.min(n-r+1,o-1);l<1||Jr(()=>{lt(t=>y(t,Lt,e,r,-l)),Fr({row:"row"===e?Math.min(r,o-l-1):Wt.active.row,col:"col"===e?Math.min(r,o-l-1):Wt.active.col})})},[Ot.colCount,Ot.rowCount,lt,Lt,Jr,Fr,Wt]),fn=ge(e=>{const{range:t}=Wt;Jr(()=>Rr(r=>{if("row"===e){const e=new Set(r.hiddenRows);for(let r=t.r1;r<=t.r2;r++)e.add(r);return{...r,hiddenRows:[...e]}}const n=new Set(r.hiddenCols);for(let e=t.c1;e<=t.c2;e++)n.add(e);return{...r,hiddenCols:[...n]}}))},[Jr,Wt,Rr]),hn=ge(e=>{Jr(()=>Rr(t=>"row"===e?{...t,hiddenRows:[]}:{...t,hiddenCols:[]}))},[Jr,Rr]),mn=ge(e=>{Jr(()=>Rr(t=>{const r=Wt.range.r1===Wt.range.r2&&Wt.range.c1===Wt.range.c2,n=0===Wt.range.r1&&Wt.range.r2===t.rowCount-1;let o=r?R(t,Wt.range):Wt.range;return n&&(o={...o,r2:Math.max(o.r1,ue(t)?.row??0)}),t.filter&&Q(t.filter.range,Wt.active.row,Wt.active.col)&&(o={...t.filter.range,r1:t.filter.range.r1+1}),ae(t,Lt,Pt,o,Wt.active.col,e)}))},[Pt,Lt,Jr,Wt,Rr]),gn=ge(()=>{ir(null),Jr(()=>Rr(e=>{if(e.filter)return{...e,filter:null};const t=R(e,Wt.range);return t.r1===t.r2?e:{...e,filter:{range:t,excluded:{}}}}))},[Jr,Wt.range,Rr]),pn=ge(()=>{Jr(()=>Rr(e=>e.merges.some(e=>Q(Wt.range,e.r1,e.c1))?ce(e,Wt.range):B(e,Wt.range)))},[Jr,Wt.range,Rr]),vn=ge((e,t)=>{Jr(()=>Rr(r=>({...r,frozenRows:e??r.frozenRows,frozenCols:t??r.frozenCols})))},[Jr,Rr]),wn=ge(e=>{const{range:t,active:r}=Wt,n=t.r1===t.r2&&t.c1===t.c2;let o="";if(n){const e=(e,t)=>"number"==typeof Pt.value(Lt,e,t);let t=r.row;for(;t>0&&e(t-1,r.col);)t--;let n=r.col;for(;n>0&&e(r.row,n-1);)n--;t<r.row?o=Z({r1:t,c1:r.col,r2:r.row-1,c2:r.col}):n<r.col&&(o=Z({r1:r.row,c1:n,r2:r.row,c2:r.col-1}))}else o=Z(t);const l=n?r:{row:t.r2+1,col:t.c1};Br(),n||Fr(l);const a=`=${e}(${o})`;Ur.current=a.length-1,$r(l,{text:a})},[Br,Pt,Lt,Fr,Wt,$r]),xn=ge((e,t)=>{const r=Wt.range,n={...r,r2:Math.min(r.r2,Math.max(r.r1,Ot.cells.length-1))},o=S(Ot,Lt,Pt,n,e);Jt(o),t?(t.preventDefault(),t.clipboardData.setData("text/plain",o.text)):navigator.clipboard?.writeText(o.text).catch(()=>{})},[Ot,Pt,Lt,Wt.range]),bn=ge((e,t)=>{const{range:r}=Wt;if(qt&&qt.text===e){if(qt.cut){const e=tt.current.findIndex(e=>e.id===qt.sheetId);if(e<0)return;let t=null;return lt(n=>{const o=H(n,e,qt,Lt,r);return t=o.range,o.sheets}),t&&Vt({active:{row:t.r1,col:t.c1},range:t}),void Jt(null)}return void Rr(e=>{const n=j(e,qt,r,t);return Vt({active:Wt.active,range:n.range}),n.sheet})}if(!e)return;const n=function(e){const t=e.replace(/\r\n?/g,"\n").replace(/\n$/,"");if(!t.includes("\t")&&!t.includes("\n"))return[[t]];if(!t.includes('"'))return t.split("\n").map(e=>e.split("\t"));const r=Y(t.includes("\t")?t:`${t}\t`);return r.length?r:[[t]]}(e);Rr(e=>{let t=e;n.forEach((e,n)=>e.forEach((e,o)=>{t=E(t,r.r1+n,r.c1+o,e)}));const o=n.reduce((e,t)=>Math.max(e,t.length),1);return Vt({active:Wt.active,range:{r1:r.r1,c1:r.c1,r2:r.r1+n.length-1,c2:r.c1+o-1}}),t})},[qt,lt,Lt,Wt,Vt,Rr]),yn=ge(e=>{Jr(()=>{const t=navigator.clipboard?.readText?.();t?t.then(t=>bn(t,e)).catch(()=>{qt&&bn(qt.text,e)}):qt&&bn(qt.text,e)})},[qt,bn,Jr]);Mr.current=()=>Zt.current?(Kr(),!0):ar?(ir(null),Dr(),!0):ur?(dr(null),Dr(),!0):cr?(sr(!1),Dr(),!0):null!==fr?(hr(null),Dr(),!0):mr?(gr(!1),Dr(),!0):!(!qt&&!or)&&(Jt(null),lr(null),!0);const Cn=Ze||x.spreadsheetFile,kn=ge(async()=>{Br();try{const e=tt.current;Nt(await n(e,$(e)),"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",`${Cn}.xlsx`),st.current=e,ot(e=>e+1)}catch{Xe.error(x.saveFailed)}},[Br,Cn,x]),Nn=()=>{const e=tt.current,t=Math.min(Xt.current,e.length-1);return ne(e[t],t,$(e))},En=async n=>{const o=n.name.replace(/\.(csv|tsv|txt|xlsx|xls|ods)$/i,"");try{if(Br(),/\.(xlsx|xls|ods)$/i.test(n.name)){const e=new Uint8Array(await n.arrayBuffer()),o=/\.xlsx$/i.test(n.name)&&"undefined"!=typeof DecompressionStream?await r(e):await t(e);lt(()=>o),Qe(0)}else{const e=Y(await n.text());if(!e.length)return;Rr(t=>({...oe(t.name,e),id:t.id}))}e||qe(o)}catch{Xe.error(x.openFailed)}};pe(()=>{o&&En(o)},[]);const Sn=ve(()=>mr?L(Ot,Lt,Pt,pr,br):[],[Ot,Pt,mr,br,pr,Lt]),Dn=Sn.findIndex(e=>e.row===Wt.active.row&&e.col===Wt.active.col),Rn=e=>{if(!Sn.length)return;const t=Dn<0?e>0?0:Sn.length-1:(Dn+e+Sn.length)%Sn.length;Fr(Sn[t])},Tn=()=>{Br();const e=Lt+1;lt(t=>{const r=X(t,x.sheetBase);return[...t.slice(0,e),W(r),...t.slice(e)]}),Qe(e),Dr()},Mn=()=>{if(!ur)return;const{index:e,name:t}=ur;dr(null);const r=t.trim();r&&r!==Fe[e]?.name&&(Fe.some((t,n)=>n!==e&&t.name.toLowerCase()===r.toLowerCase())?Xe.error(x.sheetNameTaken):lt(t=>ee(t,e,r)))},An=(e,t)=>{const r=e+t;r<0||r>=Fe.length||(lt(t=>{const n=[...t],[o]=n.splice(e,1);return n.splice(r,0,o),n}),e===Lt?Qe(r):r===Lt&&Qe(e))},zn=ge(e=>{Zt.current&&Br(),Vt(e),or&&(Rr(t=>se(t,e.range,()=>or)),lr(null))},[Br,or,Vt,Rr]),Fn=ge((e,t,r)=>{"cell"!==t||Q(Wt.range,r.row,r.col)?"col"!==t||0===Wt.range.r1&&Wt.range.r2===Ot.rowCount-1&&r.col>=Wt.range.c1&&r.col<=Wt.range.c2?"row"!==t||0===Wt.range.c1&&Wt.range.c2===Ot.colCount-1&&r.row>=Wt.range.r1&&r.row<=Wt.range.r2||Vt({active:{row:r.row,col:0},range:{r1:r.row,c1:0,r2:r.row,c2:Ot.colCount-1}}):Vt({active:{row:0,col:r.col},range:{r1:0,c1:r.col,r2:Ot.rowCount-1,c2:r.col}}):Fr(r),Er.open(e,{kind:t,pos:r})},[Ot.colCount,Ot.rowCount,Er,Fr,Wt.range,Vt]),In=ge((e,t)=>{if(!Ot.filter)return;const r=N(Ot,Lt,Pt,Ot.filter.range,e);ir({col:e,x:t.left,y:t.bottom+2,values:r,unticked:new Set(Ot.filter.excluded[e]??[]),search:""})},[Ot,Pt,Lt]),Ln=(e,t)=>{ir(null),Jr(()=>Rr(r=>{if(!r.filter)return r;const{range:n}=r.filter;return ae(r,Lt,Pt,{...n,r1:n.r1+1},e,t)}))},On=ve(()=>{const{range:e}=Wt;return e.r1===e.r2&&e.c1===e.c2?null:re(Ot,Lt,Pt,e,Ut)},[Ot,Pt,Ut,Lt,Wt]),Pn=e=>P(Number(e.toPrecision(12)),On?.firstFormat??"#,##0.##").text,Un=(e,t)=>bt("span",{className:"flex w-full items-center justify-between gap-6",children:[xt("span",{children:e}),xt("span",{className:"text-xs text-ink-faint",children:t})]}),$n=(e,t,r,n={})=>({key:e,label:t,onSelect:r,...n}),Bn=e=>({type:"divider",key:e}),Kn=[{key:"general",label:x.formatGeneral,code:p.general},{key:"number",label:x.formatNumber,code:p.number},{key:"percent",label:x.formatPercent,code:p.percent},{key:"scientific",label:x.formatScientific,code:p.scientific},{key:"currency",label:x.formatCurrency,code:p.currency},{key:"date",label:x.formatDate,code:p.date},{key:"time",label:x.formatTime,code:p.time},{key:"dateTime",label:x.formatDateTime,code:p.dateTime},{key:"text",label:x.formatText,code:p.text}].map(e=>({type:"radio",key:e.key,label:e.label,checked:(Gt.numFmt??"General")===e.code,onSelect:()=>cn(e.code)})),Hn=[["all",x.bordersAll],["outer",x.bordersOuter],["top",x.bordersTop],["bottom",x.bordersBottom],["left",x.bordersLeft],["right",x.bordersRight],["none",x.bordersNone]].map(([e,t])=>$n(e,t,()=>Jr(()=>Rr(t=>w(t,Wt.range,e))))),Wn=[...["left","center","right"].map(e=>({type:"radio",key:e,label:"left"===e?x.alignLeft:"center"===e?x.alignCenter:x.alignRight,checked:Gt.align===e,onSelect:()=>ln(t=>de(t,"align",e))})),Bn("v"),...["top","middle","bottom"].map(e=>({type:"radio",key:e,label:"top"===e?x.alignTop:"middle"===e?x.alignMiddle:x.alignBottom,checked:(Gt.vAlign??"bottom")===e,onSelect:()=>ln(t=>de(t,"vAlign",e))}))],Xn=yt.map(e=>({type:"radio",key:String(e),label:String(e),checked:(Gt.fontSize??d)===e,onSelect:()=>ln(t=>de(t,"fontSize",e===d?void 0:e))})),Vn=["SUM","AVERAGE","COUNT","MAX","MIN"].map(e=>$n(e,e,()=>wn(e))),Yn=[...[0,1,2].map(e=>({type:"radio",key:`r${e}`,label:x.freezeRows(e),checked:Ot.frozenRows===e,onSelect:()=>vn(e,null)})),{type:"radio",key:"rUp",label:x.freezeUpToRow(Yt.row+1),checked:Ot.frozenRows===Yt.row+1&&Yt.row>1,onSelect:()=>vn(Yt.row+1,null)},Bn("c"),...[0,1,2].map(e=>({type:"radio",key:`c${e}`,label:x.freezeColumns(e),checked:Ot.frozenCols===e,onSelect:()=>vn(null,e)})),{type:"radio",key:"cUp",label:x.freezeUpToColumn(b(0,Yt.col).replace(/\d+$/,"")),checked:Ot.frozenCols===Yt.col+1&&Yt.col>1,onSelect:()=>vn(null,Yt.col+1)}],Gn=[...e?[]:[$n("new",x.menuNew,()=>Jr(()=>{lt(()=>[W(x.sheetName(1))]),Qe(0),qe(x.untitled)}))],$n("open",x.menuOpen,()=>Bt.current?.click()),Bn("a"),$n("xlsx",Un(x.saveExcel,`${kt}S`),()=>{kn()}),$n("csv",x.saveCsv,()=>Jr(()=>Nt(Nn(),"text/csv",`${Cn}.csv`))),...Je?[Bn("b"),$n("email",x.email,()=>Jr(()=>Je(Nn(),`${Cn}.csv`)))]:[],...!e&&h?.onSaveToFiles?[Bn("c"),$n("keep",x.saveToFiles,()=>Jr(()=>h.onSaveToFiles?.(Ze.trim()||x.untitled,tt.current)))]:[]],jn=[$n("undo",Un(x.undo,`${kt}Z`),()=>Jr(it),{disabled:0===rt.current.length}),$n("redo",Un(x.redo,Ct?"⇧⌘Z":"Ctrl+Y"),()=>Jr(ct),{disabled:0===nt.current.length}),Bn("a"),$n("cut",Un(x.cut,`${kt}X`),()=>Jr(()=>xn(!0))),$n("copy",Un(x.copy,`${kt}C`),()=>Jr(()=>xn(!1))),$n("paste",Un(x.paste,`${kt}V`),()=>yn("all")),$n("pasteValues",x.pasteValues,()=>yn("values")),$n("pasteFormats",x.pasteFormats,()=>yn("formats")),Bn("b"),$n("find",Un(x.findReplace,`${kt}F`),()=>{gr(!0),setTimeout(()=>Nr.current?.focus(),0)}),$n("clear",Un(x.clearValues,"Delete"),()=>Jr(()=>Rr(e=>C(e,Wt.range))))],_n=[{type:"submenu",key:"freeze",label:x.freeze,items:Yn},{type:"checkbox",key:"gridlines",label:x.gridlines,checked:er,onSelect:()=>tr(e=>!e)},{type:"checkbox",key:"formulas",label:Un(x.showFormulas,`${kt}\``),checked:rr,onSelect:()=>nr(e=>!e)}],Qn=[$n("rowAbove",x.rowsAbove,()=>un("row",!1)),$n("rowBelow",x.rowsBelow,()=>un("row",!0)),$n("colLeft",x.columnsLeft,()=>un("col",!1)),$n("colRight",x.columnsRight,()=>un("col",!0)),Bn("a"),$n("sheet",x.sheet,Tn),{type:"submenu",key:"fn",label:x.function,items:Vn}],Zn=[{type:"submenu",key:"number",label:x.number,items:Kn},Bn("a"),$n("bold",Un(x.bold,`${kt}B`),()=>an("bold")),$n("italic",Un(x.italic,`${kt}I`),()=>an("italic")),$n("underline",Un(x.underline,`${kt}U`),()=>an("underline")),$n("strike",x.strikethrough,()=>an("strike")),{type:"submenu",key:"size",label:x.fontSize,items:Xn},Bn("b"),{type:"submenu",key:"align",label:x.alignment,items:Wn},{type:"submenu",key:"borders",label:x.borders,items:Hn},$n("wrap",x.wrapText,()=>an("wrap")),$n("merge",x.mergeCells,pn),Bn("c"),$n("clearFormat",x.clearFormatting,()=>Jr(()=>Rr(e=>se(e,Wt.range,()=>({})))))],qn=[$n("asc",x.sortAscending,()=>mn(!0)),$n("desc",x.sortDescending,()=>mn(!1)),Bn("a"),{type:"checkbox",key:"filter",label:x.filter,checked:!!Ot.filter,onSelect:gn},Bn("b"),$n("hideRows",x.hideRows,()=>fn("row")),$n("hideCols",x.hideColumns,()=>fn("col")),$n("unhideRows",x.unhideRows,()=>hn("row"),{disabled:!Ot.hiddenRows.length}),$n("unhideCols",x.unhideColumns,()=>hn("col"),{disabled:!Ot.hiddenCols.length})],Jn="rounded px-2 py-0.5 text-xs text-ink-muted hover:bg-line-subtle hover:text-ink",eo="inline-flex h-7 items-center gap-1 rounded px-2 text-xs text-ink-muted hover:bg-line-subtle hover:text-ink",to=xt("div",{className:"mx-1 h-4 w-px bg-line"}),ro=e=>e.preventDefault(),no=(e,t,r,n={})=>xt(Ie,{"aria-label":e,title:e,size:"sm",variant:"ghost",onMouseDown:ro,onClick:r,disabled:n.disabled,...void 0!==n.pressed?{"aria-pressed":n.pressed}:{},children:t}),oo=(e,t,r)=>xt(Pe,{triggerLabel:e,align:"start",triggerClassName:"inline-flex h-7 w-7 flex-col items-center justify-center rounded text-ink-muted hover:bg-line-subtle hover:text-ink",trigger:bt(wt,{children:[t,xt("span",{className:"h-0.5 w-4 rounded-sm",style:{background:Gt[r]??("color"===r?"var(--ink)":"var(--line)")}})]}),children:({close:t})=>xt(Me,{label:e,value:Gt[r]??"",presets:ht,clearable:!0,dragWrites:"end",onChange:e=>{ln(t=>de(t,r,e||void 0)),t()}})}),lo=e=>{if(!_t||!Xr||_t.inBar)return null;const t=Ot.formats[O(_t.row,_t.col)],r=(t?.fontSize??d)*(4/3),n=Math.min(Math.max(e.width,_t.text.length*r*.62+16),e.viewportWidth-e.x-4);return xt("textarea",{ref:kr,"aria-label":x.cellEditor,value:_t.text,spellCheck:!1,rows:1,onChange:e=>Wr(e.target.value,e.target.selectionStart),onSelect:qr,onKeyDown:Zr,onPointerDown:e=>e.stopPropagation(),className:"absolute resize-none overflow-hidden border-2 border-accent-fill bg-surface text-ink outline-none",style:{left:e.x,top:e.y,width:n,minHeight:e.height,height:Math.max(e.height,_t.text.split("\n").length*r*1.35+6),padding:"0 2px",fontSize:r,lineHeight:1.3,fontWeight:t?.bold?700:void 0,fontStyle:t?.italic?"italic":void 0,background:t?.fill??void 0,color:t?.color??void 0}})},ao=e=>{if(!_t||!Xr)return null;const t=e.y+e.height+2,r=Math.max(0,Math.min(e.x,e.viewportWidth-320));if(Vr)return bt("div",{role:"listbox","aria-label":x.functions,className:"absolute w-80 overflow-hidden rounded-lg border border-line bg-surface shadow-lg",style:{left:r,top:t},onPointerDown:e=>e.preventDefault(),children:[Vr.matches.map((e,t)=>bt("div",{role:"option","aria-selected":t===_t.suggestion,onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),Qr(e)},className:"flex cursor-pointer items-center justify-between gap-3 px-2 py-1 text-xs "+(t===_t.suggestion?"bg-accent-tint text-accent-text":"text-ink hover:bg-surface-sunken"),children:[xt("span",{className:"font-medium",children:e}),xt("span",{className:"truncate "+(t===_t.suggestion?"text-accent-text":"text-ink-muted"),children:x.functionHelp(e)})]},e)),bt("div",{className:"border-t border-line px-2 py-1 font-mono text-xs text-ink-muted",children:[Vr.matches[_t.suggestion],"(",vt[Vr.matches[_t.suggestion]]??"",")"]})]});if(Yr&&void 0!==vt[Yr.name]){const e=vt[Yr.name].split(", ");return bt("div",{className:"absolute max-w-md rounded-lg border border-line bg-surface px-2 py-1 text-xs text-ink-muted shadow-lg",style:{left:r,top:t},children:[bt("div",{className:"font-mono",children:[Yr.name,"(",e.map((t,r)=>bt("span",{children:[r>0?", ":"",xt("span",{className:r===Math.min(Yr.argIndex,e.length-1)?"font-semibold text-ink":"",children:t})]},t+r)),")"]}),xt("div",{className:"mt-0.5",children:x.functionHelp(Yr.name)})]})}return null},io=ar?ar.values.filter(e=>e.toLowerCase().includes(ar.search.toLowerCase())):[];return bt("div",{ref:Tr,className:"flex h-full flex-col bg-surface text-ink",children:[!h&&xt(Ne,{title:`${uo=Ze||x.untitled,uo.length>24?`${uo.slice(0,23)}…`:uo} - Spreadsheets`}),xt("input",{ref:Bt,type:"file",accept:Et,onChange:e=>{const t=e.target.files?.[0];Bt.current&&(Bt.current.value=""),t&&En(t)},className:"hidden"}),bt("div",{className:"flex shrink-0 items-center gap-1 border-b border-line bg-surface-sunken px-2 py-1",children:[s&&xt(Ie,{"aria-label":x.backToFiles,title:x.backToFiles,size:"sm",variant:"ghost",onClick:()=>{zt(),s()},children:xt(De,{name:"arrow-left",size:16})}),cr?xt("input",{type:"text",value:Ze,autoFocus:!0,"aria-label":x.rename,onChange:e=>qe(e.target.value),onBlur:()=>{sr(!1);const t=Ze.trim()||x.untitled;if(t!==Ze&&qe(t),e&&t!==dt.current){const r=dt.current;dt.current=t,e.store.rename(e.id,t).catch(()=>{Xe.error(x.renameFailed),dt.current=r,qe(r)})}},onKeyDown:e=>{"Enter"===e.key&&(e.currentTarget.blur(),Dr())},className:"w-40 rounded border border-line bg-surface px-2 py-0.5 text-sm font-medium text-ink"}):xt("button",{type:"button",onClick:()=>sr(!0),title:x.rename,className:"max-w-[200px] truncate rounded px-2 py-0.5 text-sm font-medium text-ink hover:bg-line-subtle",children:Ze||x.untitled}),xt(ze,{trigger:x.menuFile,items:Gn,align:"start",triggerClassName:Jn}),xt(ze,{trigger:x.menuEdit,items:jn,align:"start",triggerClassName:Jn}),xt(ze,{trigger:x.menuView,items:_n,align:"start",triggerClassName:Jn}),xt(ze,{trigger:x.menuInsert,items:Qn,align:"start",triggerClassName:Jn}),xt(ze,{trigger:x.menuFormat,items:Zn,align:"start",triggerClassName:Jn}),xt(ze,{trigger:x.menuData,items:qn,align:"start",triggerClassName:Jn}),(e||l)&&xt("span",{className:"office-save-state",children:xt(Ce,{...e?be(Tt.state,Rt.save):{tone:Fe!==st.current?"off-unsaved":"off",label:Fe!==st.current?x.noStoreEdited:x.noStoreClean}})})]}),St&&bt("div",{className:"office-conflict",role:"alert",children:[xt("span",{children:x.conflict}),xt(Re,{variant:"secondary",onClick:u,children:x.reload})]}),bt("div",{className:"flex shrink-0 flex-wrap items-center gap-0.5 border-b border-line bg-surface-sunken px-2 py-1",children:[no(x.undo,xt(De,{name:"undo",size:16}),()=>Jr(it),{disabled:0===rt.current.length}),no(x.redo,xt(De,{name:"redo",size:16}),()=>Jr(ct),{disabled:0===nt.current.length}),no(x.formatPainter,xt(De,{name:"copy-style",size:16}),()=>lr(e=>e?null:Gt),{pressed:!!or}),to,no(x.formatCurrency,xt(De,{name:"dollar",size:16}),()=>cn(Gt.numFmt===p.currency?"General":p.currency),{pressed:Gt.numFmt===p.currency}),no(x.formatPercent,xt(De,{name:"percent",size:16}),()=>cn(/%/.test(Gt.numFmt??"")?"General":"0%"),{pressed:/%/.test(Gt.numFmt??"")}),no(x.fewerDecimals,xt("span",{className:"text-xs",children:".0"}),()=>sn(-1)),no(x.moreDecimals,xt("span",{className:"text-xs",children:".00"}),()=>sn(1)),xt(ze,{trigger:bt("span",{title:x.number,className:"flex items-center gap-0.5",children:["123",xt(De,{name:"chevron-down",size:12})]}),"aria-label":x.number,items:Kn,align:"start",triggerClassName:eo}),to,xt(ze,{trigger:bt("span",{title:x.fontSize,className:"flex items-center gap-0.5",children:[Gt.fontSize??d,xt(De,{name:"chevron-down",size:12})]}),"aria-label":x.fontSize,items:Xn,align:"start",triggerClassName:eo}),no(x.bold,xt(De,{name:"bold",size:16}),()=>an("bold"),{pressed:!!Gt.bold}),no(x.italic,xt(De,{name:"italic",size:16}),()=>an("italic"),{pressed:!!Gt.italic}),no(x.underline,xt(De,{name:"underline",size:16}),()=>an("underline"),{pressed:!!Gt.underline}),no(x.strikethrough,xt(De,{name:"strike",size:16}),()=>an("strike"),{pressed:!!Gt.strike}),oo(x.textColor,xt(De,{name:"text-color",size:14}),"color"),oo(x.fillColor,xt(De,{name:"palette",size:14}),"fill"),to,xt(ze,{trigger:bt("span",{title:x.borders,className:"flex items-center gap-0.5",children:[xt(De,{name:"border-all",size:16}),xt(De,{name:"chevron-down",size:12})]}),"aria-label":x.borders,items:Hn,align:"start",triggerClassName:eo}),no(x.mergeCells,xt(De,{name:"grid",size:16}),pn,{pressed:Ot.merges.some(e=>Q(e,Yt.row,Yt.col))}),xt(ze,{trigger:bt("span",{title:x.alignment,className:"flex items-center gap-0.5",children:["center"===Gt.align?xt(De,{name:"align-center",size:16}):"right"===Gt.align?xt(De,{name:"align-right",size:16}):xt(De,{name:"align-left",size:16}),xt(De,{name:"chevron-down",size:12})]}),"aria-label":x.alignment,items:Wn,align:"start",triggerClassName:eo}),no(x.wrapText,xt(De,{name:"wrap",size:16}),()=>an("wrap"),{pressed:!!Gt.wrap}),to,no(x.filter,xt(De,{name:"filter",size:16}),gn,{pressed:!!Ot.filter}),no(x.sortAscending,xt(De,{name:"sort",size:16}),()=>mn(!0)),xt(ze,{trigger:bt("span",{title:x.functions,className:"flex items-center gap-0.5 text-sm",children:["Σ",xt(De,{name:"chevron-down",size:12})]}),"aria-label":x.functions,items:Vn,align:"end",triggerClassName:eo})]}),bt("div",{className:"flex shrink-0 items-start gap-1 border-b border-line bg-surface px-2 py-1",children:[xt("input",{type:"text","aria-label":x.nameBox,spellCheck:!1,value:fr??(_t&&Xr?b(_t.row,_t.col):Z(Wt.range)),onFocus:e=>{hr(e.target.value),e.target.select()},onChange:e=>hr(e.target.value),onBlur:()=>hr(null),onKeyDown:e=>{if("Enter"===e.key){const e=G(fr??"");e&&e.r2<Ot.rowCount&&e.c2<Ot.colCount&&(Vt({active:{row:e.r1,col:e.c1},range:z(Ot,e)}),$t.current?.scrollTo({row:e.r1,col:e.c1})),hr(null),Dr()}},className:"w-20 shrink-0 rounded border border-line bg-surface px-2 py-0.5 text-center text-xs text-ink"}),xt("span",{className:"select-none pt-0.5 font-serif text-sm italic text-ink-faint","aria-hidden":"true",children:"fx"}),xt("textarea",{ref:Cr,"aria-label":x.formulaBar,spellCheck:!1,rows:1,value:_t?_t.text:A(jt,Gt),onFocus:()=>{_t?_t.inBar||Qt({..._t,inBar:!0}):$r(Yt,{inBar:!0,mode:"edit"})},onChange:e=>{_t&&Wr(e.target.value,e.target.selectionStart)},onSelect:qr,onKeyDown:Zr,className:"max-h-24 min-h-[22px] flex-1 resize-y rounded border border-line bg-surface px-2 py-0.5 font-mono text-xs text-ink outline-none focus:border-accent-fill"})]}),mr&&bt("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-line bg-surface-sunken px-2 py-1 text-xs",children:[xt("div",{className:"w-44",children:xt(Le,{ref:Nr,size:"sm","aria-label":x.find,placeholder:x.find,value:pr,onChange:e=>vr(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),Rn(e.shiftKey?-1:1))}})}),xt("span",{className:"w-16 text-center text-ink-muted",children:pr?x.hitCount(Dn<0?0:Dn+1,Sn.length):""}),no(x.previous,xt(De,{name:"arrow-up",size:14}),()=>Rn(-1)),no(x.next,xt(De,{name:"arrow-down",size:14}),()=>Rn(1)),xt("div",{className:"w-44",children:xt(Le,{size:"sm","aria-label":x.replaceWith,placeholder:x.replaceWith,value:wr,onChange:e=>xr(e.target.value)})}),xt(Re,{size:"sm",variant:"secondary",disabled:!Sn.length,onClick:()=>{if(Dn<0)return void Rn(1);const{row:e,col:t}=Sn[Dn];Rr(r=>{const n=te(q(r,e,t),pr,wr,br);return n===q(r,e,t)?r:fe(r,[{row:e,col:t,raw:n}])}),Rn(1)},children:x.replace}),xt(Re,{size:"sm",variant:"secondary",disabled:!Sn.length,onClick:()=>{let e=0;Rr(t=>{const r=[];for(const{row:e,col:n}of Sn){const o=te(q(t,e,n),pr,wr,br);o!==q(t,e,n)&&r.push({row:e,col:n,raw:o})}return e=r.length,fe(t,r)}),Xe.success(x.replacedCount(e))},children:x.replaceAll}),xt(Te,{label:x.matchCase,checked:br.matchCase,onChange:e=>yr(t=>({...t,matchCase:e}))}),xt(Te,{label:x.wholeCell,checked:br.wholeCell,onChange:e=>yr(t=>({...t,wholeCell:e}))}),xt(Te,{label:x.inFormulas,checked:br.inFormulas,onChange:e=>yr(t=>({...t,inFormulas:e}))}),xt("div",{className:"ml-auto",children:no(x.close,xt(De,{name:"close",size:14}),()=>{gr(!1),Dr()})})]}),xt("div",{className:"min-h-0 flex-1",children:xt(ft,{ref:$t,sheet:Ot,sheetIndex:Lt,evaluator:Pt,filterHidden:Ut,selection:Wt,showGridlines:er,showFormulas:rr,clipRange:qt&&qt.sheetId===Ot.id?qt.range:null,highlights:jr,pointing:Gr,onSelect:zn,onPoint:_r,onEdit:e=>{Br(),Fr(e),$r(K(Ot,e.row,e.col)?{row:K(Ot,e.row,e.col).r1,col:K(Ot,e.row,e.col).c1}:e)},onFill:e=>{const t=Wt.range;Rr(r=>F(r,t,e)),Vt({active:Wt.active,range:e})},onResizeCol:(e,t)=>Rr(r=>{const{range:n}=Wt,o=0===n.r1&&n.r2===r.rowCount-1&&e>=n.c1&&e<=n.c2,l={...r.colWidths};if(o)for(let e=n.c1;e<=n.c2;e++)l[e]=t;else l[e]=t;return{...r,colWidths:l}}),onResizeRow:(e,t)=>Rr(r=>({...r,rowHeights:{...r.rowHeights,[e]:t}})),onAutoFitCol:e=>{const t=Math.max(40,$t.current?.measureColumn(e)??0);Rr(r=>({...r,colWidths:{...r.colWidths,[e]:t}}))},onAutoFitRow:e=>Rr(t=>{const r={...t.rowHeights};return delete r[e],{...t,rowHeights:r}}),onHeaderMenu:Fn,onFilterButton:In,renderEditor:e=>bt(wt,{children:[lo(e),ao(e)]}),onKeyDown:t=>{if(_t)return;const r=t.ctrlKey||t.metaKey,n=t.key,o=n.toLowerCase(),l="ArrowUp"===n?[-1,0]:"ArrowDown"===n?[1,0]:"ArrowLeft"===n?[0,-1]:"ArrowRight"===n?[0,1]:null;if(l){t.preventDefault();const e=t.shiftKey?Pr():Wt.active,n=r?Lr(e,l[0],l[1]):Ir(e,l[0],l[1]);return void(t.shiftKey?Or(n):Fr(n))}if("Tab"===n||"Enter"===n){if(t.preventDefault(),"Enter"===n&&r)return;const e=Wt.range.r1!==Wt.range.r2||Wt.range.c1!==Wt.range.c2,o="Enter"===n?t.shiftKey?-1:1:0,l="Tab"===n?t.shiftKey?-1:1:0;if(e){const{range:e}=Wt;let{row:t,col:r}=Wt.active;return t+=o,r+=l,r>e.c2&&(r=e.c1,t=t+1>e.r2?e.r1:t+1),r<e.c1&&(r=e.c2,t=t-1<e.r1?e.r2:t-1),t>e.r2&&(t=e.r1,r=r+1>e.c2?e.c1:r+1),t<e.r1&&(t=e.r2,r=r-1<e.c1?e.c2:r-1),Vt({active:{row:t,col:r},range:e}),void $t.current?.scrollTo({row:t,col:r})}return void Fr(Ir(Wt.active,o,l))}if("Home"===n)return t.preventDefault(),void Fr(r?{row:Ot.frozenRows,col:Ot.frozenCols}:{row:Wt.active.row,col:0});if("End"===n){t.preventDefault();const e=ue(Ot);return void Fr(r?{row:e?.row??0,col:e?.col??0}:{row:Wt.active.row,col:Math.max(0,(Ot.cells[Wt.active.row]?.length??1)-1)})}if("PageDown"===n||"PageUp"===n){t.preventDefault();const e="PageDown"===n?25:-25;return void Fr({row:Math.max(0,Math.min(Ot.rowCount-1,Wt.active.row+e)),col:Wt.active.col})}if("Delete"===n||"Backspace"===n)return t.preventDefault(),void Rr(e=>C(e,Wt.range));if("F2"===n)return t.preventDefault(),void $r(Wt.active);if(" "===n&&(r||t.shiftKey))return t.preventDefault(),void Vt(r?{active:Wt.active,range:{r1:0,c1:Wt.range.c1,r2:Ot.rowCount-1,c2:Wt.range.c2}}:{active:Wt.active,range:{r1:Wt.range.r1,c1:0,r2:Wt.range.r2,c2:Ot.colCount-1}});if(!r)return!t.altKey||"="!==n&&"≠"!==n?1!==n.length||t.altKey?void("Process"!==n&&229!==t.keyCode||$r(Wt.active,{text:""})):(t.preventDefault(),void $r(Wt.active,{text:n})):(t.preventDefault(),void wn("SUM"));switch(o){case"z":return t.preventDefault(),void(t.shiftKey?ct():it());case"y":return t.preventDefault(),void ct();case"a":return t.preventDefault(),void Vt({active:Wt.active,range:{r1:0,c1:0,r2:Ot.rowCount-1,c2:Ot.colCount-1}});case"b":return t.preventDefault(),void an("bold");case"i":return t.preventDefault(),void an("italic");case"u":return t.preventDefault(),void an("underline");case"f":case"h":return t.preventDefault(),gr(!0),void setTimeout(()=>Nr.current?.focus(),0);case"s":return t.preventDefault(),void(e?zt():kn());case"d":{t.preventDefault();const{range:e}=Wt;return void(e.r2>e.r1?Rr(t=>F(t,{...e,r2:e.r1},e)):e.r1>0&&Rr(t=>F(t,{...e,r1:e.r1-1,r2:e.r1-1},{...e,r1:e.r1-1})))}case"r":{t.preventDefault();const{range:e}=Wt;return void(e.c2>e.c1?Rr(t=>F(t,{...e,c2:e.c1},e)):e.c1>0&&Rr(t=>F(t,{...e,c1:e.c1-1,c2:e.c1-1},{...e,c1:e.c1-1})))}case";":return t.preventDefault(),void Rr(e=>E(e,Wt.active.row,Wt.active.col,We(new Date)));case"`":return t.preventDefault(),void nr(e=>!e)}if(t.shiftKey){if("$"===n||"4"===n)return t.preventDefault(),void cn(p.currency);if("%"===n||"5"===n)return t.preventDefault(),void cn("0%")}},onCopy:e=>{_t||xn(!1,e)},onCut:e=>{_t||xn(!0,e)},onPaste:e=>{_t||(e.preventDefault(),bn(e.clipboardData.getData("text/plain"),"all"))}})}),bt("div",{className:"flex shrink-0 items-center border-t border-line bg-surface-sunken",children:[bt("div",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto px-1 py-1",children:[xt(Ie,{"aria-label":x.addSheet,title:x.addSheet,size:"sm",variant:"ghost",onClick:Tn,children:xt(De,{name:"add",size:14})}),Fe.map((e,t)=>xt("button",{type:"button",onClick:()=>(e=>{_t&&!Gr&&Br(),Qe(e),ir(null)})(t),onDoubleClick:()=>dr({index:t,name:e.name}),onContextMenu:e=>Sr.open(e,t),style:e.tabColor?{boxShadow:`inset 0 -3px 0 ${e.tabColor}`}:void 0,className:"whitespace-nowrap rounded px-3 py-1 text-xs font-medium "+(t===Lt?"bg-accent-tint text-accent-text":"text-ink-muted hover:bg-line-subtle hover:text-ink"),children:ur?.index===t?xt("input",{type:"text",value:ur.name,autoFocus:!0,"aria-label":x.rename,onChange:e=>dr({index:t,name:e.target.value}),onBlur:Mn,onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&Mn()},onClick:e=>e.stopPropagation(),className:"w-24 rounded border border-accent-fill bg-surface px-1 text-xs text-ink outline-none"}):e.name},e.id))]}),On&&On.count>0&&bt("div",{className:"flex shrink-0 items-center gap-3 border-l border-line px-3 py-1 text-xs text-ink-muted",children:[On.numbers>0&&bt("span",{children:[x.statSum,": ",Pn(On.sum)]}),null!==On.average&&bt("span",{children:[x.statAverage,": ",Pn(On.average)]}),bt("span",{children:[x.statCount,": ",On.count]}),On.numbers>0&&bt("span",{children:[x.statMin,": ",Pn(On.min)]}),On.numbers>0&&bt("span",{children:[x.statMax,": ",Pn(On.max)]})]})]}),Er.state&&xt(Ae,{...Er.props,items:(so=Er.state.data.kind,[$n("cut",x.cut,()=>Jr(()=>xn(!0))),$n("copy",x.copy,()=>Jr(()=>xn(!1))),$n("paste",x.paste,()=>yn("all")),$n("pasteValues",x.pasteValues,()=>yn("values")),Bn("a"),..."col"!==so?[$n("rowAbove",x.rowsAbove,()=>un("row",!1)),$n("rowBelow",x.rowsBelow,()=>un("row",!0))]:[],..."row"!==so?[$n("colLeft",x.columnsLeft,()=>un("col",!1)),$n("colRight",x.columnsRight,()=>un("col",!0))]:[],Bn("b"),..."col"!==so?[$n("delRows",x.deleteRows,()=>dn("row"),{danger:!0})]:[],..."row"!==so?[$n("delCols",x.deleteColumns,()=>dn("col"),{danger:!0})]:[],$n("clear",x.clearValues,()=>Jr(()=>Rr(e=>C(e,Wt.range)))),Bn("c"),..."col"!==so?[$n("hideRows",x.hideRows,()=>fn("row"))]:[],..."row"!==so?[$n("hideCols",x.hideColumns,()=>fn("col"))]:[],..."col"!==so&&Ot.hiddenRows.length?[$n("unhideRows",x.unhideRows,()=>hn("row"))]:[],..."row"!==so&&Ot.hiddenCols.length?[$n("unhideCols",x.unhideColumns,()=>hn("col"))]:[]])}),Sr.state&&xt(Ae,{...Sr.props,items:(co=Sr.state.data,[$n("rename",x.rename,()=>dr({index:co,name:Fe[co].name})),$n("duplicate",x.duplicate,()=>{lt(e=>M(e,co,X(e,Fe[co].name))),Qe(co+1)}),$n("left",x.moveLeft,()=>An(co,-1),{disabled:0===co}),$n("right",x.moveRight,()=>An(co,1),{disabled:co===Fe.length-1}),{type:"submenu",key:"colour",label:x.tabColor,items:[$n("none",x.noColor,()=>lt(e=>e.map((e,t)=>t===co?{...e,tabColor:void 0}:e))),...ht.slice(7,17).map(e=>$n(e,bt("span",{className:"flex items-center gap-2",children:[xt("span",{className:"inline-block h-3 w-3 rounded-sm",style:{background:e}}),e]}),()=>lt(t=>t.map((t,r)=>r===co?{...t,tabColor:e}:t))))]},Bn("a"),$n("delete",x.deleteSheet,()=>{(async e=>{Fe.length<=1||(null===ue(Fe[e])||await Ke({title:x.deleteSheetTitle,message:x.deleteSheetMessage(Fe[e].name),confirmLabel:x.deleteSheet}))&&(lt(t=>T(t,e)),Qe(t=>t>e||t>=Fe.length-1?Math.max(0,t-1):t))})(co)},{danger:!0,disabled:Fe.length<=1})])}),ar&&bt(Ue,{portal:!0,minWidth:230,onClose:()=>ir(null),style:{position:"fixed",left:ar.x,top:ar.y},children:[xt(Be,{onClick:()=>Ln(ar.col,!0),children:x.sortAscending}),xt(Be,{onClick:()=>Ln(ar.col,!1),children:x.sortDescending}),xt($e,{}),xt("div",{className:"px-2 py-1",children:xt(Le,{size:"sm","aria-label":x.find,placeholder:x.find,value:ar.search,onChange:e=>ir({...ar,search:e.target.value})})}),xt("div",{className:"max-h-52 overflow-y-auto px-2 py-1",children:io.map(e=>xt("div",{className:"py-0.5",children:xt(Te,{label:e||x.blank,checked:!ar.unticked.has(e),onChange:t=>{const r=new Set(ar.unticked);t?r.delete(e):r.add(e),ir({...ar,unticked:r})}})},e))}),bt("div",{className:"flex items-center justify-between gap-2 border-t border-line px-2 py-1",children:[xt(Re,{size:"sm",variant:"ghost",onClick:()=>ir({...ar,unticked:new Set}),children:x.clear}),xt(Re,{size:"sm",variant:"primary",onClick:()=>{if(!ar)return;const{col:e,unticked:t}=ar;ir(null),Jr(()=>Rr(r=>{if(!r.filter)return r;const n={...r.filter.excluded};return t.size?n[e]=[...t]:delete n[e],{...r,filter:{...r.filter,excluded:n}}}))},children:x.apply})]})]})]});var co,so,uo}function At(e,t){const r=e.rows?e.rows.map(e=>e.map(e=>String(e??""))):Y(e.csv??"");return 0===r.length?null:oe(t,r)}export{Rt as OpenSpreadsheet,Dt as SpreadsheetById,Tt as SpreadsheetPane,St as default};
|
package/dist/chunk-3RFDQOTI.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=(e,n)=>e===n||JSON.stringify(e)===JSON.stringify(n);function n(n,s,t){return e(s,n)?t:s}function s(n,s,t,i){const r=new Map(n.map(e=>[e.id,e])),o=new Map(s.map(e=>[e.id,e])),a=new Map(t.map(e=>[e.id,e])),u=new Set,l=new Map;for(const e of new Set([...o.keys(),...a.keys()])){const n=r.get(e),s=o.get(e),t=a.get(e);if(n){if(!s||!t)continue;l.set(e,i(n,s,t))}else l.set(e,s??t);u.add(e)}return function(n,s,t,i){const r=e=>e.filter(e=>n.includes(e)&&i.has(e)),o=!e(r(n),r(s)),[a,u]=o?[s,t]:[t,s],l=a.filter(e=>i.has(e));return u.forEach((e,n)=>{if(l.includes(e)||!i.has(e))return;const s=u.slice(0,n).reverse().find(e=>l.includes(e));l.splice(s?l.indexOf(s)+1:0,0,e)}),l}([...r.keys()],[...o.keys()],[...a.keys()],u).map(e=>l.get(e))}var t=(e,s,t)=>n(e,s,t);function i(e,i,r){return{...r,background:n(e.background,i.background,r.background),notes:n(e.notes,i.notes,r.notes),layout:n(e.layout,i.layout,r.layout),skip:n(e.skip,i.skip,r.skip),transition:n(e.transition,i.transition,r.transition),animations:n(e.animations,i.animations,r.animations),elements:s(e.elements,i.elements,r.elements,t)}}function r(t,r,o){if(e(r,t))return o;if(e(o,t))return r;const a=s(t.slides,r.slides,o.slides,i);return{...o,theme:n(t.theme,r.theme,o.theme),slideNumbers:n(t.slideNumbers,r.slideNumbers,o.slideNumbers),slides:a.length>0?a:o.slides}}export{r as mergeDecks};
|
package/dist/chunk-ADXHTZ3Q.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{titleOf as r}from"./chunk-XYVQTQ6N.js";var e=r=>new Promise((e,t)=>{const a=new FileReader;a.onload=()=>e(String(a.result)),a.onerror=()=>t(a.error??new Error("Unreadable picture")),a.readAsDataURL(r)});async function t(t,a,o={}){const{importPptx:n}=await(import("./pptxImport-OACGHWQ6.js")),{document:i,notes:s}=await n(a,{storeImage:o.storeImage??e,onProgress:o.onProgress,signal:o.signal}),c=r(a.name),m=await t.create(c);try{await t.save(m.id,i,m.version)}catch(r){throw await t.remove(m.id).catch(()=>{}),r}return{id:m.id,title:c,notes:s}}export{t as importDeckFile};
|