efficient-office 0.11.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/Documents-2ZU5D3ZI.js +1 -0
- 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-D3JKD7KW.js +1 -0
- package/dist/chunk-EC6D54MM.js +1 -0
- package/dist/chunk-EDJRXJNE.js +1 -0
- package/dist/chunk-EP3ZNVDB.js +1 -0
- package/dist/{chunk-HU4RI2OM.js → chunk-HNNYUGDU.js} +1 -1
- package/dist/{chunk-DG4VDXLL.js → chunk-HQM2HX4V.js} +1 -1
- package/dist/{chunk-JCSB2PHB.js → chunk-O35VT6BD.js} +1 -1
- package/dist/chunk-POH6OTTR.js +1 -0
- 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/chunk-YKQ5UKYZ.js +1 -0
- package/dist/deckPdf-KZFS4CTF.js +1 -0
- package/dist/documents/documents.css +39 -0
- package/dist/documents/index.d.ts +63 -2
- package/dist/documents/index.js +1 -1
- package/dist/docxPdf-S4RXU4L2.js +1 -0
- package/dist/importDocument-34WALCTG.js +1 -0
- package/dist/importSpreadsheet-L5FJGRUV.js +1 -0
- package/dist/{pptxImport-Y7TB6PYP.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/Documents-ISV66NLW.js +0 -1
- package/dist/Slides-LJW5C24V.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-4NKXNXKY.js +0 -1
- package/dist/chunk-6ZFEBY6H.js +0 -1
- package/dist/chunk-B2X3NIQR.js +0 -1
- package/dist/chunk-BGAR3P46.js +0 -1
- package/dist/chunk-COXKOQPZ.js +0 -1
- package/dist/chunk-I3AC6PYR.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-RHW2M2UY.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-EW5I5JR3.js +0 -1
- package/dist/importDocument-274VK7OM.js +0 -1
- package/dist/importSpreadsheet-IRN32JON.js +0 -1
- package/dist/workbookPdf-CQTTURQ5.js +0 -1
- package/dist/xlsxFile-SX767BIH.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ENGLISH_FILE_WORDS as e,ZH_HANS_FILE_WORDS as t}from"./chunk-B32ASXHM.js";var o={styleHeading4:"Heading 4",styleHeading5:"Heading 5",styleHeading6:"Heading 6",applyStyle:e=>`Apply "${e}"`,updateStyle:e=>`Update "${e}" to match`,styleUpdated:e=>`"${e}" now looks like the selected paragraph.`,paintFormat:"Paint format",paintFormatHint:"Select the text to give this formatting.",checklist:"Checklist",paragraphSpacing:"Line and paragraph spacing",addSpaceBefore:"Add space before paragraph",removeSpaceBefore:"Remove space before paragraph",addSpaceAfter:"Add space after paragraph",removeSpaceAfter:"Remove space after paragraph",customSpacing:"Custom spacing and indents",lineSpacingCustom:"Line spacing (lines)",spacingBefore:"Space before (pt)",spacingAfter:"Space after (pt)",indentLeft:"Left indent (pt)",indentRight:"Right indent (pt)",indentSpecial:"Special indent",indentNone:"None",indentFirstLine:"First line",indentHanging:"Hanging",indentBy:"By (pt)",spacingInvalid:"Enter numbers of 0 or more, and a line spacing between 0 and 10.",ruler:"Ruler",tabStop:"Tab stop",tabStopHint:"Click to add a tab stop. Drag one off the ruler to remove it. Double-click one to change its alignment.",columns:"Columns",columnsCount:e=>1===e?"One column":2===e?"Two columns":`${e} columns`,tableOfContents:"Table of contents",tocRefresh:"Refresh table of contents",tocDelete:"Delete table of contents",footnote:"Footnote",footnotes:"Footnotes",footnotePlaceholder:"Footnote text",footnoteLocked:"This footnote holds more than text, so it is kept as it is. Edit it in Word.",bookmark:"Bookmark",bookmarkPrompt:"Name the bookmark. Letters, numbers and underscores, starting with a letter.",bookmarkInvalid:"A bookmark name starts with a letter and has only letters, numbers and underscores.",bookmarkTaken:"There is already a bookmark with that name.",linkToHeading:"Link to a heading",linkToBookmark:"Link to a bookmark",noHeadings:"No headings yet",noBookmarks:"No bookmarks yet",breakMenu:"Break",sectionBreakNext:"Section break (next page)",sectionBreakContinuous:"Section break (continuous)",removeSectionBreak:"Remove section break",headersFooters:"Headers and footers",headersFootersHint:"Click to edit headers and footers",differentFirst:"Different first page",differentOddEven:"Different odd and even pages",headerDefault:"All pages",headerOdd:"Odd pages",headerFirst:"First page",headerEven:"Even pages",pageCount:"Page count",webFonts:"Web fonts",wordFonts:"Word fonts",pdfPageFailed:e=>`Page ${e} couldn't be drawn for the PDF.`,files:e,fileKind:"Word",backToFiles:"Back to files",filesHeading:"Documents",newFile:"New document",openFile:"Open a file",filesEmptyTitle:"Write your first document",filesEmptyBody:"Every change saves by itself.",deleteFile:"Delete",createFailed:"The document could not be made.",deleteFailed:"The document could not be deleted.",deleteConfirm:e=>`Delete "${e}"? Nobody can open it again.`,documentName:"Document name",documentPanel:"Document",pagePanel:"Page",outline:"Outline",outlineEmpty:"Headings in the document show here.",morePageSetup:"More page setup",export:"Export",renameFailed:"The document could not be renamed.",openFailed:"This document could not be opened.",conflict:"Somebody else saved this document, so your latest changes are not saved. Reload to see theirs.",reload:"Reload",noStoreEdited:"Not saved. Export to keep your changes",noStoreClean:"No autosave here. Export to keep a copy",openFromFiles:"Go back to your files to open another document.",untitled:"Untitled",loading:"Loading",newDocument:"New",open:"Open",rename:"Rename",menuFile:"File",menuInsert:"Insert",menuLayout:"Layout",save:"Save",saveDocx:"Save (.docx)",saveKeepType:"Save",saveAs:"Save as",saveAsWord:"Word document (.docx)",saveAsPdf:"PDF (from the print dialog)",saveAsWeb:"Web page (.html)",saveAsText:"Plain text (.txt)",print:"Print",undo:"Undo",redo:"Redo",find:"Find",replaceWith:"Replace with",replace:"Replace",replaceAll:"Replace all",matchCase:"Match case",previousMatch:"Previous match",nextMatch:"Next match",closeFind:"Close find",noMatches:"No matches",paragraphStyle:"Paragraph style",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",superscript:"Superscript",subscript:"Subscript",textColor:"Text color",highlight:"Highlight color",clearFormatting:"Clear formatting",bulletedList:"Bulleted list",numberedList:"Numbered list",decreaseIndent:"Decrease indent",increaseIndent:"Increase indent",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",justify:"Justify",lineSpacing:"Line spacing",styleNormal:"Normal",styleTitle:"Title",styleHeading1:"Heading 1",styleHeading2:"Heading 2",styleHeading3:"Heading 3",styleQuote:"Quote",table:"Table",image:"Image",link:"Link",linkPrompt:"Web address, or leave empty to remove the link.",linkInvalid:"That address can't be used as a link.",pageBreak:"Page break",pageNumber:"Page number",horizontalLine:"Horizontal line",rowAbove:"Insert row above",rowBelow:"Insert row below",columnLeft:"Insert column left",columnRight:"Insert column right",mergeCells:"Merge cells",mergeFailed:"These cells can't be merged: the selection would cut a merged cell.",cellShading:"Cell shading",noColor:"No color",deleteRow:"Delete row",deleteColumn:"Delete column",deleteTable:"Delete table",imageWidth:"Image width",imageOriginalSize:"Original size",imageRemove:"Remove image",pageSetup:"Page setup",paperSize:"Size",paperLetter:"US Letter",paperLegal:"US Legal",custom:"Custom",orientation:"Orientation",portrait:"Portrait",landscape:"Landscape",margins:"Margins",marginsNormal:"Normal, 2.54 cm",marginsNarrow:"Narrow, 1.27 cm",marginsModerate:"Moderate, 1.91 cm sides",marginsWide:"Wide, 5.08 cm sides",header:"Header",footer:"Footer",headerFooterLocked:"This one holds a picture or a table, so it is kept as it is. Edit it in Word.",ok:"OK",cancel:"Cancel",dismiss:"Dismiss",zoomIn:"Zoom in",zoomOut:"Zoom out",wrapLines:"Wrap lines",objectTextBox:"Text box",objectChart:"Chart from Word. Kept as is.",objectDiagram:"Diagram from Word. Kept as is.",objectEquation:"Equation from Word. Kept as is.",objectPicture:"Picture from Word. Kept as is.",objectOther:"Object from Word. Kept as is.",objectField:"Field",discardMessage:"They haven't been saved.",discard:"Discard",keepEditing:"Keep editing",legacyDoc:".doc is the old Word format. Save it as .docx in Word first.",openedOldSave:"Opened as a document. Save it to get a Word file.",saveFailed:"The document could not be saved.",savedAsUtf8:"Saved as UTF-8: the original encoding can't be written from a browser.",dropHint:"Drop a document to open. Images insert into the page.",matchCount:(e,t)=>`${e} of ${t}`,replacedCount:e=>1===e?"1 replacement":`${e} replacements`,tableSize:(e,t)=>`${e} × ${t}`,pageLabel:e=>`Page ${e}`,pageOf:(e,t)=>`Page ${e} of ${t}`,wordCount:e=>1===e?"1 word":`${e.toLocaleString()} words`,lineColumn:(e,t)=>`Ln ${e}, Col ${t}`,lineCount:e=>1===e?"1 line":`${e.toLocaleString()} lines`,noticeComments:e=>1===e?"1 comment":`${e} comments`,noticeTracked:e=>1===e?"1 tracked change":`${e} tracked changes`,noticeObjects:e=>1===e?"1 object such as a text box":`${e} objects such as text boxes`,noticeFootnotes:e=>1===e?"1 footnote":`${e} footnotes`,noticeLead:e=>`Has ${e.length>1?`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`:e[0]}. They stay in the file, but need Word to edit.`,discardTitle:e=>`Discard your changes to ${e}?`,cannotRead:e=>`${e} can't be opened. It may be damaged or password protected.`,unsupported:e=>`Unsupported file type: .${e||"unknown"}`},a={styleHeading4:"标题 4",styleHeading5:"标题 5",styleHeading6:"标题 6",applyStyle:e=>`应用“${e}”`,updateStyle:e=>`更新“${e}”以匹配所选内容`,styleUpdated:e=>`“${e}”现在与所选段落一致。`,paintFormat:"格式刷",paintFormatHint:"选择要应用此格式的文字。",checklist:"核对清单",paragraphSpacing:"行距和段落间距",addSpaceBefore:"在段前添加间距",removeSpaceBefore:"删除段前间距",addSpaceAfter:"在段后添加间距",removeSpaceAfter:"删除段后间距",customSpacing:"自定义间距和缩进",lineSpacingCustom:"行距(行)",spacingBefore:"段前(磅)",spacingAfter:"段后(磅)",indentLeft:"左缩进(磅)",indentRight:"右缩进(磅)",indentSpecial:"特殊缩进",indentNone:"无",indentFirstLine:"首行缩进",indentHanging:"悬挂缩进",indentBy:"缩进值(磅)",spacingInvalid:"请输入不小于 0 的数字,行距须在 0 到 10 之间。",ruler:"标尺",tabStop:"制表位",tabStopHint:"单击添加制表位。将制表位拖离标尺即可删除。双击可更改其对齐方式。",columns:"分栏",columnsCount:e=>1===e?"一栏":2===e?"两栏":`${e} 栏`,tableOfContents:"目录",tocRefresh:"更新目录",tocDelete:"删除目录",footnote:"脚注",footnotes:"脚注",footnotePlaceholder:"脚注文字",footnoteLocked:"此脚注包含文字以外的内容,因此保持原样。请在 Word 中编辑。",bookmark:"书签",bookmarkPrompt:"为书签命名。可使用字母、数字和下划线,须以字母开头。",bookmarkInvalid:"书签名称须以字母开头,且只能包含字母、数字和下划线。",bookmarkTaken:"已有同名书签。",linkToHeading:"链接到标题",linkToBookmark:"链接到书签",noHeadings:"尚无标题",noBookmarks:"尚无书签",breakMenu:"分隔符",sectionBreakNext:"分节符(下一页)",sectionBreakContinuous:"分节符(连续)",removeSectionBreak:"删除分节符",headersFooters:"页眉和页脚",headersFootersHint:"单击以编辑页眉和页脚",differentFirst:"首页不同",differentOddEven:"奇偶页不同",headerDefault:"所有页",headerOdd:"奇数页",headerFirst:"首页",headerEven:"偶数页",pageCount:"总页数",webFonts:"网络字体",wordFonts:"Word 字体",pdfPageFailed:e=>`第 ${e} 页无法绘制到 PDF。`,files:t,fileKind:"Word",backToFiles:"返回文件",filesHeading:"文档",newFile:"新建文档",openFile:"打开文件",filesEmptyTitle:"写下您的第一份文档",filesEmptyBody:"每次更改都会自动保存。",deleteFile:"删除",createFailed:"无法创建文档。",deleteFailed:"无法删除文档。",deleteConfirm:e=>`删除“${e}”?之后任何人都无法再打开它。`,documentName:"文档名称",documentPanel:"文档",pagePanel:"页面",outline:"大纲",outlineEmpty:"文档中的标题会显示在这里。",morePageSetup:"更多页面设置",export:"导出",renameFailed:"无法重命名文档。",openFailed:"无法打开此文档。",conflict:"其他人已保存此文档,您最近的更改尚未保存。请重新加载以查看他们的版本。",reload:"重新加载",noStoreEdited:"未保存。请导出以保留更改",noStoreClean:"此处不会自动保存。请导出以保留副本",openFromFiles:"请返回文件列表以打开其他文档。",untitled:"未命名",loading:"正在加载",newDocument:"新建",open:"打开",rename:"重命名",menuFile:"文件",menuInsert:"插入",menuLayout:"布局",save:"保存",saveDocx:"保存 (.docx)",saveKeepType:"保存",saveAs:"另存为",saveAsWord:"Word 文档 (.docx)",saveAsPdf:"PDF(通过打印对话框)",saveAsWeb:"网页 (.html)",saveAsText:"纯文本 (.txt)",print:"打印",undo:"撤销",redo:"重做",find:"查找",replaceWith:"替换为",replace:"替换",replaceAll:"全部替换",matchCase:"区分大小写",previousMatch:"上一个匹配项",nextMatch:"下一个匹配项",closeFind:"关闭查找",noMatches:"无匹配项",paragraphStyle:"段落样式",font:"字体",fontSize:"字号",bold:"加粗",italic:"倾斜",underline:"下划线",strikethrough:"删除线",superscript:"上标",subscript:"下标",textColor:"文字颜色",highlight:"突出显示颜色",clearFormatting:"清除格式",bulletedList:"项目符号列表",numberedList:"编号列表",decreaseIndent:"减少缩进",increaseIndent:"增加缩进",alignLeft:"左对齐",alignCenter:"居中",alignRight:"右对齐",justify:"两端对齐",lineSpacing:"行距",styleNormal:"正文",styleTitle:"标题",styleHeading1:"标题 1",styleHeading2:"标题 2",styleHeading3:"标题 3",styleQuote:"引用",table:"表格",image:"图片",link:"链接",linkPrompt:"输入网址;留空则移除链接。",linkInvalid:"该地址不能用作链接。",pageBreak:"分页符",pageNumber:"页码",horizontalLine:"水平线",rowAbove:"在上方插入行",rowBelow:"在下方插入行",columnLeft:"在左侧插入列",columnRight:"在右侧插入列",mergeCells:"合并单元格",mergeFailed:"无法合并这些单元格:所选范围会切开已合并的单元格。",cellShading:"单元格底纹",noColor:"无颜色",deleteRow:"删除行",deleteColumn:"删除列",deleteTable:"删除表格",imageWidth:"图片宽度",imageOriginalSize:"原始大小",imageRemove:"移除图片",pageSetup:"页面设置",paperSize:"纸张大小",paperLetter:"美国信纸",paperLegal:"美国法律用纸",custom:"自定义",orientation:"方向",portrait:"纵向",landscape:"横向",margins:"页边距",marginsNormal:"常规,2.54 厘米",marginsNarrow:"窄,1.27 厘米",marginsModerate:"中等,左右 1.91 厘米",marginsWide:"宽,左右 5.08 厘米",header:"页眉",footer:"页脚",headerFooterLocked:"此处包含图片或表格,因此保持原样。请在 Word 中编辑。",ok:"确定",cancel:"取消",dismiss:"关闭",zoomIn:"放大",zoomOut:"缩小",wrapLines:"自动换行",objectTextBox:"文本框",objectChart:"来自 Word 的图表,保持原样。",objectDiagram:"来自 Word 的示意图,保持原样。",objectEquation:"来自 Word 的公式,保持原样。",objectPicture:"来自 Word 的图片,保持原样。",objectOther:"来自 Word 的对象,保持原样。",objectField:"域",discardMessage:"这些更改尚未保存。",discard:"放弃",keepEditing:"继续编辑",legacyDoc:".doc 是旧版 Word 格式,请先在 Word 中另存为 .docx。",openedOldSave:"已作为文档打开。保存后即可得到 Word 文件。",saveFailed:"无法保存文档。",savedAsUtf8:"已保存为 UTF-8:浏览器无法写入原始编码。",dropHint:"拖放文档以打开;图片会插入页面。",matchCount:(e,t)=>`第 ${e} 个,共 ${t} 个`,replacedCount:e=>`已替换 ${e} 处`,tableSize:(e,t)=>`${e} × ${t}`,pageLabel:e=>`第 ${e} 页`,pageOf:(e,t)=>`第 ${e} 页,共 ${t} 页`,wordCount:e=>`${e.toLocaleString()} 字`,lineColumn:(e,t)=>`第 ${e} 行,第 ${t} 列`,lineCount:e=>`${e.toLocaleString()} 行`,noticeComments:e=>`${e} 条批注`,noticeTracked:e=>`${e} 处修订`,noticeObjects:e=>`${e} 个文本框等对象`,noticeFootnotes:e=>`${e} 条脚注`,noticeLead:e=>`包含 ${e.join("、")}。它们会保留在文件中,但需要在 Word 中编辑。`,discardTitle:e=>`放弃对 ${e} 的更改?`,cannotRead:e=>`无法打开 ${e}。文件可能已损坏或受密码保护。`,unsupported:e=>`不支持的文件类型:.${e||"未知"}`};export{o as ENGLISH_WORDS,a as ZH_HANS_WORDS};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(){const t=document.createElement("div");return t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:-100000px;top:0;pointer-events:none;",document.body.append(t),{root:t,close:()=>t.remove()}}async function e(t){const{getFontEmbedCSS:e}=await(import("html-to-image"));return e(t,{includeQueryParams:!0})}async function n(t){t.getBoundingClientRect(),await document.fonts.ready,await Promise.all(Array.from(t.querySelectorAll("img"),t=>t.decode()))}function o(t){const e=atob(t.slice(t.indexOf(",")+1)),n=new Uint8Array(e.length);for(let t=0;t<e.length;t+=1)n[t]=e.charCodeAt(t);return n}async function i(t,{width:e,height:n,pixelRatio:i,quality:r,fontCss:a,background:c}){const{toJpeg:u}=await(import("html-to-image"));return o(await u(t,{width:e,height:n,pixelRatio:i,quality:r??.8,backgroundColor:c??"#ffffff",fontEmbedCSS:a,includeQueryParams:!0}))}export{t as openStage,e as embeddedFonts,n as settled,o as dataUrlBytes,i as drawJpeg};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ENGLISH_WORDS as r}from"./chunk-
|
|
1
|
+
import{ENGLISH_WORDS as r}from"./chunk-AJTH75FI.js";var s=class extends Error{constructor(s=r.pptxPasswordProtected){super(s),this.name="PptxPasswordError"}},t=class extends Error{constructor(s=r.pptxUnreadable){super(s),this.name="PptxUnreadableError"}};export{s as PptxPasswordError,t as PptxUnreadableError};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ENGLISH_WORDS as t}from"./chunk-AJTH75FI.js";import{titleOf as e}from"./chunk-XYVQTQ6N.js";var r=t=>new Promise((e,r)=>{const o=new FileReader;o.onload=()=>e(String(o.result)),o.onerror=()=>r(o.error??new Error("Unreadable picture")),o.readAsDataURL(t)});async function o(t,o,a={}){const{importPptx:n}=await(import("./pptxImport-UQQXZUQL.js")),{document:i,notes:s}=await n(o,{storeImage:a.storeImage??r,onProgress:a.onProgress,signal:a.signal}),c=e(o.name),d=await t.create(c);try{await t.save(d.id,i,d.version)}catch(e){throw await t.remove(d.id).catch(()=>{}),e}return{id:d.id,title:c,notes:s}}import{createContext as a,useContext as n}from"react";import{jsx as i}from"react/jsx-runtime";var s=class extends Error{},c="efficient-office:slides",d=()=>{try{return JSON.parse(localStorage.getItem(c)??"{}")}catch{return{}}},m=t=>localStorage.setItem(c,JSON.stringify(t)),u={list:async()=>Object.values(d()).map(({id:t,title:e,updatedAt:r})=>({id:t,title:e,updatedAt:r})).sort((t,e)=>e.updatedAt.localeCompare(t.updatedAt)),get:async t=>{const e=d()[t];if(!e)throw new Error("No such deck");return e},create:async t=>{const e=(new Date).toISOString(),r={id:crypto.randomUUID(),title:t,document:{},version:crypto.randomUUID(),updatedAt:e};return m({...d(),[r.id]:r}),r},rename:async(t,e)=>{const r=d();r[t]&&m({...r,[t]:{...r[t],title:e,updatedAt:(new Date).toISOString()}})},save:async(t,e,r)=>{const o=d();if(!o[t]||o[t].version!==r)throw new s;const a=crypto.randomUUID();return m({...o,[t]:{...o[t],document:e,version:a,updatedAt:(new Date).toISOString()}}),a},remove:async t=>{const{[t]:e,...r}=d();m(r)}},l=a({store:u});function p({value:t,children:e}){return i(l.Provider,{value:t,children:e})}var w=()=>n(l),g=()=>n(l).words??t;export{r as asDataUrl,o as importDeckFile,s as SlidesConflict,u as browserSlidesStore,p as SlidesProvider,w as useSlidesHost,g as useSlidesWords};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{paragraphsOf as t,withParagraphs as e}from"./chunk-EP3ZNVDB.js";import{DECK_FONT as n,DECK_FONTS as o,SLIDE_H as r,SLIDE_W as i,newId as a,newSlide as l}from"./chunk-AJTH75FI.js";var s=[{id:"simple",name:"Simple",background:"#ffffff",text:"#2c2c2a",heading:"#26215c",accents:["#534ab7","#1d9e75","#d85a30","#ef9f27","#378add","#d4537e"],headingFont:n,bodyFont:n},{id:"midnight",name:"Midnight",background:"#26215c",text:"#eeedfe",heading:"#ffffff",accents:["#afa9ec","#5dcaa5","#f0997b","#fac775","#85b7eb","#ed93b1"],headingFont:"Montserrat",bodyFont:n},{id:"editorial",name:"Editorial",background:"#f1efe8",text:"#444441",heading:"#2c2c2a",accents:["#993c1d","#5f5e5a","#0f6e56","#854f0b","#185fa5","#993556"],headingFont:"Playfair Display",bodyFont:"Lora"}],d=s[0],c=t=>t.theme??d,u={title:96,subtitle:48,body:44};function f(t,e,n,o){return{id:a(),type:"text",...e,rotation:0,text:n,fontSize:u[t],bold:"title"===t,color:"title"===t?o.heading:o.text,font:"title"===t?o.headingFont:o.bodyFont,align:"left",anchor:"body"===t?"top":"bottom",placeholder:t,..."body"===t?{paragraphs:[{list:"bullet",runs:[{text:n}]}]}:{}}}var m=120,h={x:m,y:80,w:i-240,h:180},p={x:m,y:300,w:i-240,h:r-300-100},y=["title","titleBody","section","twoColumns","titleOnly","blank"];function g(t,e,n){const o={...l(),background:e.background,layout:t},r=(p.w-80)/2;return{...o,elements:(()=>{switch(t){case"title":return[{...f("title",{x:m,y:340,w:i-240,h:220},n.title,e),align:"center"},{...f("subtitle",{x:m,y:580,w:i-240,h:120},n.subtitle,e),align:"center",anchor:"top"}];case"titleBody":return[f("title",h,n.title,e),f("body",p,n.body,e)];case"section":return[f("title",{x:m,y:520,w:i-240,h:200},n.title,e)];case"twoColumns":return[f("title",h,n.title,e),f("body",{...p,w:r},n.body,e),f("body",{...p,x:p.x+r+80,w:r},n.body,e)];case"titleOnly":return[f("title",h,n.title,e)];case"blank":return[]}})()}}function b(o,r){const i=c(o),a=(t,e)=>!!t&&t.toLowerCase()===e.toLowerCase(),l=t=>{const e=i.accents.findIndex(e=>a(t,e));return-1===e?t:r.accents[e]??t},s=o=>{switch(o.type){case"text":{const l="title"===o.placeholder||!o.placeholder&&a(o.color,i.heading),s=t=>a(t,i.heading)?r.heading:a(t,i.text)?r.text:t,d=l?i.headingFont:i.bodyFont,c=l?r.headingFont:r.bodyFont,u=o.placeholder||(o.font??n)===d?c===n?void 0:c:o.font,f=t(o).map(t=>({...t,runs:t.runs.map(t=>({...t,color:s(t.color),font:t.font===d?void 0:t.font}))}));return e({...o,color:s(o.color)??o.color,font:u},f)}case"shape":return{...o,fill:l(o.fill),stroke:o.stroke&&(a(o.stroke,i.text)?r.text:l(o.stroke))};case"connector":return{...o,stroke:a(o.stroke,i.text)?r.text:l(o.stroke)};case"chart":return{...o,color:l(o.color),series:o.series?.map(t=>({...t,color:l(t.color)}))};default:return o}};return{...o,theme:r,slides:o.slides.map(t=>({...t,background:a(t.background,i.background)?r.background:t.background,elements:t.elements.map(s)}))}}var k=t=>y.includes(t);function x(t){const e=t.layouts??[];return[...y.map(t=>({id:t,name:e.find(e=>e.id===t)?.name??"",builtIn:!0})),...e.filter(t=>!k(t.id)).map(t=>({id:t.id,name:t.name,builtIn:!1}))]}function w(t){const e=new Map;return t.map(t=>{const n=t.groupId?e.get(t.groupId)??e.set(t.groupId,a()).get(t.groupId):void 0;return{...t,id:a(),...n?{groupId:n}:{}}})}function F(t,e,n){const o=c(t),r=t.layouts?.find(t=>t.id===e);return r?{...l(),background:r.background??o.background,layout:e,elements:w(r.elements)}:g(k(e)?e:"titleBody",o,n)}function I(n,o,r,i){return{id:o,name:r,background:n.background,elements:n.elements.map(n=>"text"===n.type?(n=>{if(!n.placeholder)return n;const o=i[n.placeholder],r=t(n)[0];return e(n,[{...r,runs:[{...r?.runs[0]??{},text:o}]}])})(n):n)}}function v(t,e){const n=t.layouts??[],o=n.findIndex(t=>t.id===e.id);return{...t,layouts:-1===o?[...n,e]:n.map((t,n)=>n===o?e:t)}}function P(t,e){const n=(t.layouts??[]).filter(t=>t.id!==e),{layouts:o,...r}=t;return n.length>0?{...r,layouts:n}:r}function B(t,e,n){return 0===n.length?t:{...t,slides:t.slides.map(t=>t.id===e?t:{...t,elements:[...t.elements,...w(n).map(t=>({...t,locked:!0}))]})}}function C(t,e){const{layouts:n,...o}=b(t,c(e));return e.layouts?{...o,layouts:e.layouts.map(t=>({...t,elements:[...t.elements]}))}:o}var S=["blank","simple","midnight","editorial","dealerPitch","monthlyReport"];function j(n,o){if("blank"===n)return{slides:[l()]};const r=s.find(t=>t.id===n)??("dealerPitch"===n?s[1]:d);if("simple"===n||"midnight"===n||"editorial"===n)return{theme:r,slides:[g("title",r,o)]};const i="dealerPitch"===n?o.dealerPitch:o.monthlyReport,a=i.map(([n,a],l)=>((n,o,r)=>({...n,elements:n.elements.map(n=>{if("text"!==n.type)return n;const i="title"===n.placeholder?o:r;return e(n,t(n).slice(0,1).map(t=>({...t,runs:[{...t.runs[0],text:i}]})))})}))(g(0===l?"title":l===i.length-1?"section":"titleBody",r,o),n,a));return{theme:r,slideNumbers:!0,slides:a}}function E(t){const e=c(t),n=new Set([e.headingFont,e.bodyFont]);for(const e of t.slides)for(const t of e.elements)if("text"===t.type||"shape"===t.type){t.font&&n.add(t.font);for(const e of t.paragraphs??[])for(const t of e.runs)t.font&&n.add(t.font)}return[...n].filter(t=>o.includes(t))}var L="data-slides-fonts";function M(t,e){const o=function(t){return`https://fonts.googleapis.com/css2?${[...t].sort().map(t=>`family=${t.replace(/ /g,"+")}:ital,wght@0,400;0,700;1,400;1,700`).join("&")}&display=swap`}([...new Set([n,...e])]),r=t.head.querySelector(`link[${L}]`);if(r?.href===o)return;const i=t.createElement("link");i.rel="stylesheet",i.crossOrigin="anonymous",i.href=o,i.setAttribute(L,""),t.head.appendChild(i),r?.remove()}export{s as THEMES,c as themeOf,g as slideFromLayout,b as applyTheme,x as layoutChoices,F as slideFromDeckLayout,I as layoutFromSlide,v as withLayout,P as withoutLayout,B as onEverySlide,C as importLook,S as STARTERS,j as starterDeck,E as fontsOf,M as ensureFonts};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEFAULT_COL_WIDTH as t,DEFAULT_FONT_SIZE as e,DEFAULT_ROW_HEIGHT as n,FormulaError as r,colIndex as o,colLabel as s,formatKey as l,isFormula as i,newSheet as a,rangeLabel as m,shiftFormula as c,tokenize as f,usedBounds as u}from"./chunk-ZS45QEF4.js";var h=(()=>{const t=new Uint32Array(256);for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)n=1&n?3988292384^n>>>1:n>>>1;t[e]=n>>>0}return t})();function d(t){let e=4294967295;for(let n=0;n<t.length;n++)e=h[255&(e^t[n])]^e>>>8;return(4294967295^e)>>>0}async function g(t,e){const n=e.writable.getWriter();return n.write(t).then(()=>n.close()).catch(()=>{}),new Uint8Array(await new Response(e.readable).arrayBuffer())}async function p(t){return"undefined"==typeof CompressionStream?null:g(t,new CompressionStream("deflate-raw"))}async function $(t){return g(t,new DecompressionStream("deflate-raw"))}async function b(t){const e=new TextEncoder,n=[],r=[];let o=0;for(const s of t){const t=e.encode(s.name),l=e.encode(s.text),i=await p(l),a=null===i||i.length>=l.length,m=a?l:i,c=d(l),f=new Uint8Array(30+t.length),u=new DataView(f.buffer);u.setUint32(0,67324752,!0),u.setUint16(4,20,!0),u.setUint16(6,2048,!0),u.setUint16(8,a?0:8,!0),u.setUint32(14,c,!0),u.setUint32(18,m.length,!0),u.setUint32(22,l.length,!0),u.setUint16(26,t.length,!0),f.set(t,30);const h=new Uint8Array(46+t.length),g=new DataView(h.buffer);g.setUint32(0,33639248,!0),g.setUint16(4,20,!0),g.setUint16(6,20,!0),g.setUint16(8,2048,!0),g.setUint16(10,a?0:8,!0),g.setUint32(16,c,!0),g.setUint32(20,m.length,!0),g.setUint32(24,l.length,!0),g.setUint16(28,t.length,!0),g.setUint32(42,o,!0),h.set(t,46),n.push(f,m),r.push(h),o+=f.length+m.length}const s=r.reduce((t,e)=>t+e.length,0),l=new Uint8Array(22),i=new DataView(l.buffer);i.setUint32(0,101010256,!0),i.setUint16(8,t.length,!0),i.setUint16(10,t.length,!0),i.setUint32(12,s,!0),i.setUint32(16,o,!0);const a=new Uint8Array(o+s+22);let m=0;for(const t of[...n,...r,l])a.set(t,m),m+=t.length;return a}async function x(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);let n=-1;for(let r=t.length-22;r>=Math.max(0,t.length-66e3);r--)if(101010256===e.getUint32(r,!0)){n=r;break}if(n<0)throw new Error("Not a zip file");const r=e.getUint16(n+10,!0);let o=e.getUint32(n+16,!0);const s=new TextDecoder,l=new Map;for(let n=0;n<r;n++){const n=e.getUint16(o+10,!0),r=e.getUint32(o+20,!0),i=e.getUint16(o+28,!0),a=e.getUint16(o+30,!0),m=e.getUint16(o+32,!0),c=e.getUint32(o+42,!0),f=s.decode(t.subarray(o+46,o+46+i));if(o+=46+i+a+m,!/\.(xml|rels)$/i.test(f))continue;const u=c+30+e.getUint16(c+26,!0)+e.getUint16(c+28,!0),h=t.subarray(u,u+r);l.set(f,s.decode(8===n?await $(h):h))}return l}var w=new Set(["CONCAT","IFS","SWITCH","TEXTJOIN","XLOOKUP","XOR","IFNA","DAYS","STDEV.S","STDEV.P","VAR.S","VAR.P","MODE.SNGL","RANK.EQ","CEILING.MATH","FLOOR.MATH"]);function F(t){const{tokens:e}=f(t);let n="",r=0;for(const o of e){if("ident"!==o.type)continue;const e=o.value.replace(/^_xlfn\.(?:_xlws\.)?/i,"").replace(/^_xlws\./i,"");e!==o.value&&(n+=t.slice(r,o.start)+e,r=o.end)}return`=${n}${t.slice(r)}`}function y(t){return t.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var A='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n',C="http://schemas.openxmlformats.org/spreadsheetml/2006/main",v="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function N(t){return`FF${t.replace("#","").toUpperCase().padStart(6,"0").slice(0,6)}`}var S=class{fonts=[`<font><sz val="${e}"/><name val="Arial"/></font>`];fills=['<fill><patternFill patternType="none"/></fill>','<fill><patternFill patternType="gray125"/></fill>'];borders=["<border><left/><right/><top/><bottom/><diagonal/></border>"];numFmts=[];xfs=['<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>'];seen=new Map;index(t,e){const n=t.indexOf(e);return n>=0?n:(t.push(e),t.length-1)}add(t){if(!t||!Object.keys(t).length)return 0;const n=JSON.stringify(t),r=this.seen.get(n);if(void 0!==r)return r;const o=this.index(this.fonts,`<font>${t.bold?"<b/>":""}${t.italic?"<i/>":""}${t.strike?"<strike/>":""}${t.underline?"<u/>":""}<sz val="${t.fontSize??e}"/>${t.color?`<color rgb="${N(t.color)}"/>`:""}<name val="Arial"/></font>`),s=t.fill?this.index(this.fills,`<fill><patternFill patternType="solid"><fgColor rgb="${N(t.fill)}"/><bgColor indexed="64"/></patternFill></fill>`):0,l=(t,e)=>e?`<${t} style="thin"><color auto="1"/></${t}>`:`<${t}/>`,i=t.border??{},a=this.index(this.borders,`<border>${l("left",i.left)}${l("right",i.right)}${l("top",i.top)}${l("bottom",i.bottom)}<diagonal/></border>`);let m=0;t.numFmt&&"General"!==t.numFmt&&(m="@"===t.numFmt?49:164+this.index(this.numFmts,t.numFmt));const c=t.align||t.vAlign||t.wrap?`<alignment${t.align?` horizontal="${t.align}"`:""}${t.vAlign?` vertical="${"middle"===t.vAlign?"center":t.vAlign}"`:""}${t.wrap?' wrapText="1"':""}/>`:"",f=`<xf numFmtId="${m}" fontId="${o}" fillId="${s}" borderId="${a}" xfId="0" applyFont="1"${s?' applyFill="1"':""}${a?' applyBorder="1"':""}${m?' applyNumberFormat="1"':""}${c?' applyAlignment="1"':""}${c?`>${c}</xf>`:"/>"}`;return this.xfs.push(f),this.seen.set(n,this.xfs.length-1),this.xfs.length-1}toXml(){const t=this.numFmts.length?`<numFmts count="${this.numFmts.length}">${this.numFmts.map((t,e)=>`<numFmt numFmtId="${164+e}" formatCode="${y(t)}"/>`).join("")}</numFmts>`:"";return`${A}<styleSheet xmlns="${C}">${t}<fonts count="${this.fonts.length}">${this.fonts.join("")}</fonts><fills count="${this.fills.length}">${this.fills.join("")}</fills><borders count="${this.borders.length}">${this.borders.join("")}</borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="${this.xfs.length}">${this.xfs.join("")}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`}};function U(t,e,n,o,a,m){const c=`${s(a)}${o+1}`,u=t.cells[o]?.[a]??"",h=t.formats[l(o,a)],d=m.add(h),g=d?` s="${d}"`:"";if(""===u)return d?`<c r="${c}"${g}/>`:"";const p=n.value(e,o,a);if(i(u)){const t=`<f>${y(function(t){const e=t.slice(1),{tokens:n}=f(e);let r="",o=0;for(let t=0;t<n.length;t++){const s=n[t],l=n[t+1];"ident"===s.type&&"op"===l?.type&&"("===l.value&&w.has(s.value.toUpperCase())&&(r+=`${e.slice(o,s.start)}_xlfn.${s.value.toUpperCase()}`,o=s.end)}return r+e.slice(o)}(u))}</f>`;if("number"==typeof p)return`<c r="${c}"${g}>${t}<v>${p}</v></c>`;if("boolean"==typeof p)return`<c r="${c}"${g} t="b">${t}<v>${p?1:0}</v></c>`;if(p instanceof r){return`<c r="${c}"${g} t="e">${t}<v>${/^#(?:REF!|N\/A|NAME\?|DIV\/0!|VALUE!|NUM!|NULL!)$/.test(p.code)?p.code:"#VALUE!"}</v></c>`}return`<c r="${c}"${g} t="str">${t}<v>${y(null===p?"":p)}</v></c>`}if("number"==typeof p)return`<c r="${c}"${g}><v>${p}</v></c>`;if("boolean"==typeof p)return`<c r="${c}"${g} t="b"><v>${p?1:0}</v></c>`;const $=String(p??"");return`<c r="${c}"${g} t="inlineStr"><is><t${$!==$.trim()||/\n/.test($)?' xml:space="preserve"':""}>${y($)}</t></is></c>`}function k(e,r,o,l){const i=u(e);let a=i?.row??0,c=i?.col??0;const f=new Map;for(const t of Object.keys(e.formats)){const[e,n]=t.split(":").map(Number);a=Math.max(a,e),c=Math.max(c,n),f.has(e)||f.set(e,[]),f.get(e).push(n)}const h=new Set(e.hiddenRows);for(const t of[...e.hiddenRows,...Object.keys(e.rowHeights).map(Number)])a=Math.max(a,t);const d=[];for(let t=0;t<=a;t++){const n=e.cells[t]??[],s=new Set(f.get(t)??[]);n.forEach((t,e)=>{""!==t&&s.add(e)});const i=e.rowHeights[t];if(!s.size&&void 0===i&&!h.has(t))continue;const a=[...s].sort((t,e)=>t-e).map(n=>U(e,r,o,t,n,l)).join(""),m=`${void 0!==i?` ht="${(.75*i).toFixed(2)}" customHeight="1"`:""}${h.has(t)?' hidden="1"':""}`;d.push(`<row r="${t+1}"${m}>${a}</row>`)}const g=new Set(e.hiddenCols),p=[...new Set([...Object.keys(e.colWidths).map(Number),...g])].sort((t,e)=>t-e),$=p.length?`<cols>${p.map(n=>`<col min="${n+1}" max="${n+1}" width="${(((e.colWidths[n]??t)-5)/7).toFixed(4)}" customWidth="1"${g.has(n)?' hidden="1"':""}/>`).join("")}</cols>`:"",{frozenRows:b,frozenCols:x}=e,w=b||x?`<pane${x?` xSplit="${x}"`:""}${b?` ySplit="${b}"`:""} topLeftCell="${s(x)}${b+1}" activePane="${b&&x?"bottomRight":b?"bottomLeft":"topRight"}" state="frozen"/>`:"",F=e.merges.length?`<mergeCells count="${e.merges.length}">${e.merges.map(t=>`<mergeCell ref="${m(t)}"/>`).join("")}</mergeCells>`:"",y=e.filter?`<autoFilter ref="${m(e.filter.range)}"/>`:"",v=e.tabColor?`<sheetPr><tabColor rgb="${N(e.tabColor)}"/></sheetPr>`:"";return`${A}<worksheet xmlns="${C}">${v}<dimension ref="A1:${s(c)}${a+1}"/><sheetViews><sheetView${0===r?' tabSelected="1"':""} workbookViewId="0">${w}</sheetView></sheetViews><sheetFormatPr defaultColWidth="${((t-5)/7).toFixed(4)}" defaultRowHeight="${(.75*n).toFixed(2)}" customHeight="1"/>${$}<sheetData>${d.join("")}</sheetData>${y}${F}</worksheet>`}async function I(t,e){const n=new S,r=function(t){const e=new Set;return t.map((t,n)=>{const r=t.name.replace(/[[\]:*?/\\]/g," ").trim().slice(0,31)||`Sheet ${n+1}`;let o=r;for(let t=2;e.has(o.toLowerCase());t++)o=`${r.slice(0,28)} ${t}`;return e.add(o.toLowerCase()),o})}(t),o=t.map((t,r)=>({name:`xl/worksheets/sheet${r+1}.xml`,text:k(t,r,e,n)})),l=t.map((t,e)=>{return t.filter?`<definedName name="_xlnm._FilterDatabase" localSheetId="${e}" hidden="1">${y(`'${r[e].replace(/'/g,"''")}'!${n=t.filter.range,`$${s(n.c1)}$${n.r1+1}:$${s(n.c2)}$${n.r2+1}`}`)}</definedName>`:"";var n}).join("");return b([{name:"[Content_Types].xml",text:`${A}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>${t.map((t,e)=>`<Override PartName="/xl/worksheets/sheet${e+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join("")}</Types>`},{name:"_rels/.rels",text:`${A}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${v}/officeDocument" Target="xl/workbook.xml"/></Relationships>`},{name:"xl/workbook.xml",text:`${A}<workbook xmlns="${C}" xmlns:r="${v}"><sheets>${r.map((t,e)=>`<sheet name="${y(t)}" sheetId="${e+1}" r:id="rId${e+1}"/>`).join("")}</sheets>${l?`<definedNames>${l}</definedNames>`:""}<calcPr calcId="0" fullCalcOnLoad="1"/></workbook>`},{name:"xl/_rels/workbook.xml.rels",text:`${A}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${t.map((t,e)=>`<Relationship Id="rId${e+1}" Type="${v}/worksheet" Target="worksheets/sheet${e+1}.xml"/>`).join("")}<Relationship Id="rId${t.length+1}" Type="${v}/styles" Target="styles.xml"/></Relationships>`},{name:"xl/styles.xml",text:n.toXml()},...o])}var T={1:"0",2:"0.00",3:"#,##0",4:"#,##0.00",9:"0%",10:"0.00%",11:"0.00E+00",14:"dd/mm/yyyy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"dd/mm/yyyy h:mm",37:"#,##0;(#,##0)",38:"#,##0;[Red](#,##0)",39:"#,##0.00;(#,##0.00)",40:"#,##0.00;[Red](#,##0.00)",45:"mm:ss",46:"[h]:mm:ss",47:"mm:ss.0",48:"##0.0E+0",49:"@"},E=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47","0563C1","954F72"],M={0:"000000",1:"FFFFFF",2:"FF0000",3:"00FF00",4:"0000FF",5:"FFFF00",6:"FF00FF",7:"00FFFF",8:"000000",9:"FFFFFF",10:"FF0000",11:"00FF00",12:"0000FF",13:"FFFF00",14:"FF00FF",15:"00FFFF"};function R(t){if(!t)return;const e=t.getAttribute("rgb");if(e)return`#${e.slice(-6).toLowerCase()}`;const n=Number(t.getAttribute("tint")??0),r=t.getAttribute("theme");if(null!==r){const t=E[Number(r)];return t?`#${function(t,e){const n=n=>{const r=parseInt(t.slice(n,n+2),16),o=e<0?r*(1+e):r+(255-r)*e;return Math.round(o).toString(16).padStart(2,"0")};return`${n(0)}${n(2)}${n(4)}`}(t,n)}`.toLowerCase():void 0}const o=t.getAttribute("indexed");if(null!==o){const t=M[Number(o)];return t?`#${t}`.toLowerCase():void 0}}var D=t=>(new DOMParser).parseFromString(t,"application/xml"),j=(t,e)=>Array.from(t.getElementsByTagNameNS("*",e)),O=(t,e)=>j(t,e)[0],L=(t,e)=>Array.from(t.children).filter(t=>t.localName===e);function z(t){const e=/^([A-Z]+)(\d+)$/.exec(t);return{row:Number(e[2])-1,col:o(e[1])}}function V(t){const[e,n=e]=t.replace(/\$/g,"").split(":"),r=z(e),o=z(n);return{r1:r.row,c1:r.col,r2:o.row,c2:o.col}}function P(t,e,n,r){const o=D(e),s=a(t),i=[],m={},f=new Map;for(const t of j(o,"c")){const e=t.getAttribute("r");if(!e)continue;const{row:o,col:s}=z(e),a=r[Number(t.getAttribute("s")??0)];a&&Object.keys(a).length&&(m[l(o,s)]=a);const u=L(t,"f")[0],h=L(t,"v")[0]?.textContent??"",d=t.getAttribute("t");let g="";if(u){const t=u.getAttribute("si");if("shared"===u.getAttribute("t")&&null!==t)if(u.textContent)f.set(t,{text:u.textContent,row:o,col:s}),g=F(u.textContent);else{const e=f.get(t);e&&(g=c(F(e.text),o-e.row,s-e.col))}else u.textContent&&(g=F(u.textContent))}if(g||(g="s"===d?n[Number(h)]??"":"inlineStr"===d?j(t,"t").map(t=>t.textContent??"").join(""):"b"===d?"1"===h?"TRUE":"FALSE":h,"s"!==d&&"inlineStr"!==d&&"str"!==d||!/^(?:=|-?\d|'|true$|false$)/i.test(g)||(g=`'${g}`)),""!==g){for(;i.length<=o;)i.push([]);for(;i[o].length<=s;)i[o].push("");i[o][s]=g}}const u={},h=[];for(const t of j(o,"col")){const e=Number(t.getAttribute("min"))-1,n=Math.min(Number(t.getAttribute("max"))-1,e+500),r=Number(t.getAttribute("width")??0);for(let o=e;o<=n;o++)r&&"1"===t.getAttribute("customWidth")&&(u[o]=Math.round(7*r+5)),"1"===t.getAttribute("hidden")&&h.push(o)}const d={},g=[];for(const t of j(o,"row")){const e=Number(t.getAttribute("r"))-1,n=t.getAttribute("ht");n&&"1"===t.getAttribute("customHeight")&&(d[e]=Math.round(Number(n)/.75)),"1"===t.getAttribute("hidden")&&g.push(e)}const p=O(o,"pane"),$="frozen"===p?.getAttribute("state"),b=O(o,"autoFilter")?.getAttribute("ref"),x=R(O(o,"tabColor"));return{...s,tabColor:x,cells:i,formats:m,colWidths:u,rowHeights:d,hiddenCols:h,hiddenRows:g,merges:j(o,"mergeCell").map(t=>V(t.getAttribute("ref")??"A1")),frozenRows:$?Number(p?.getAttribute("ySplit")??0):0,frozenCols:$?Number(p?.getAttribute("xSplit")??0):0,filter:b?{range:V(b),excluded:{}}:null,rowCount:Math.max(s.rowCount,i.length+100),colCount:Math.max(s.colCount,i.reduce((t,e)=>Math.max(t,e.length),0))}}async function H(t){const e=await x(t),n=e.get("xl/workbook.xml");if(!n)throw new Error("Not a workbook");const r=D(e.get("xl/_rels/workbook.xml.rels")??"<Relationships/>"),o=new Map(j(r,"Relationship").map(t=>[t.getAttribute("Id"),t.getAttribute("Target")??""])),s=e.get("xl/sharedStrings.xml")?j(D(e.get("xl/sharedStrings.xml")),"si").map(t=>j(t,"t").filter(t=>"rPh"!==t.parentElement?.localName).map(t=>t.textContent??"").join("")):[],l=function(t){if(!t)return[];const e=D(t),n=new Map(j(e,"numFmt").map(t=>[Number(t.getAttribute("numFmtId")),t.getAttribute("formatCode")??""])),r=O(e,"fonts"),o=O(e,"fills"),s=O(e,"borders"),l=O(e,"cellXfs");if(!l)return[];const i=r?L(r,"font"):[],a=o?L(o,"fill"):[],m=s?L(s,"border"):[],c=Number(i[0]?L(i[0],"sz")[0]?.getAttribute("val")??0:0);return L(l,"xf").map(t=>{const e={},r=Number(t.getAttribute("numFmtId")??0),o=n.get(r)??T[r];o&&"General"!==o&&(e.numFmt=o);const s=i[Number(t.getAttribute("fontId")??0)];if(s){L(s,"b").length&&(e.bold=!0),L(s,"i").length&&(e.italic=!0),L(s,"u").length&&(e.underline=!0),L(s,"strike").length&&(e.strike=!0);const t=Number(L(s,"sz")[0]?.getAttribute("val")??0);t&&t!==c&&(e.fontSize=t);const n=R(L(s,"color")[0]);n&&"#000000"!==n&&(e.color=n)}const l=a[Number(t.getAttribute("fillId")??0)]?.getElementsByTagNameNS("*","patternFill")[0];if(l&&"solid"===l.getAttribute("patternType")){const t=R(L(l,"fgColor")[0]);t&&(e.fill=t)}const f=m[Number(t.getAttribute("borderId")??0)];if(f){const t=t=>!!L(f,t)[0]?.getAttribute("style"),n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")};(n.top||n.right||n.bottom||n.left)&&(e.border={...n.top?{top:!0}:{},...n.right?{right:!0}:{},...n.bottom?{bottom:!0}:{},...n.left?{left:!0}:{}})}const u=L(t,"alignment")[0];if(u){const t=u.getAttribute("horizontal");"left"!==t&&"center"!==t&&"right"!==t||(e.align=t);const n=u.getAttribute("vertical");"top"!==n&&"bottom"!==n||(e.vAlign=n),"center"===n&&(e.vAlign="middle");const r=u.getAttribute("wrapText");"1"!==r&&"true"!==r||(e.wrap=!0)}return e})}(e.get("xl/styles.xml")),i=[];for(const t of j(D(n),"sheet")){const n=t.getAttribute("name")??`Sheet ${i.length+1}`,r=t.getAttributeNS(v,"id")??t.getAttribute("r:id"),a=o.get(r)??"",m=a.startsWith("/")?a.slice(1):`xl/${a}`,c=e.get(m);c&&i.push(P(n,c,s,l))}if(!i.length)throw new Error("No sheets");return i}export{b as zip,x as unzip,I as writeXlsx,H as readXlsx};
|
|
1
|
+
import{DEFAULT_COL_WIDTH as t,DEFAULT_FONT_SIZE as e,DEFAULT_ROW_HEIGHT as n,FormulaError as r,colIndex as o,colLabel as s,formatKey as l,isFormula as i,newSheet as a,rangeLabel as m,shiftFormula as c,tokenize as f,usedBounds as u}from"./chunk-5K2D7PBJ.js";var h=(()=>{const t=new Uint32Array(256);for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)n=1&n?3988292384^n>>>1:n>>>1;t[e]=n>>>0}return t})();function d(t){let e=4294967295;for(let n=0;n<t.length;n++)e=h[255&(e^t[n])]^e>>>8;return(4294967295^e)>>>0}async function g(t,e){const n=e.writable.getWriter();return n.write(t).then(()=>n.close()).catch(()=>{}),new Uint8Array(await new Response(e.readable).arrayBuffer())}async function p(t){return"undefined"==typeof CompressionStream?null:g(t,new CompressionStream("deflate-raw"))}async function $(t){return g(t,new DecompressionStream("deflate-raw"))}async function b(t){const e=new TextEncoder,n=[],r=[];let o=0;for(const s of t){const t=e.encode(s.name),l=e.encode(s.text),i=await p(l),a=null===i||i.length>=l.length,m=a?l:i,c=d(l),f=new Uint8Array(30+t.length),u=new DataView(f.buffer);u.setUint32(0,67324752,!0),u.setUint16(4,20,!0),u.setUint16(6,2048,!0),u.setUint16(8,a?0:8,!0),u.setUint32(14,c,!0),u.setUint32(18,m.length,!0),u.setUint32(22,l.length,!0),u.setUint16(26,t.length,!0),f.set(t,30);const h=new Uint8Array(46+t.length),g=new DataView(h.buffer);g.setUint32(0,33639248,!0),g.setUint16(4,20,!0),g.setUint16(6,20,!0),g.setUint16(8,2048,!0),g.setUint16(10,a?0:8,!0),g.setUint32(16,c,!0),g.setUint32(20,m.length,!0),g.setUint32(24,l.length,!0),g.setUint16(28,t.length,!0),g.setUint32(42,o,!0),h.set(t,46),n.push(f,m),r.push(h),o+=f.length+m.length}const s=r.reduce((t,e)=>t+e.length,0),l=new Uint8Array(22),i=new DataView(l.buffer);i.setUint32(0,101010256,!0),i.setUint16(8,t.length,!0),i.setUint16(10,t.length,!0),i.setUint32(12,s,!0),i.setUint32(16,o,!0);const a=new Uint8Array(o+s+22);let m=0;for(const t of[...n,...r,l])a.set(t,m),m+=t.length;return a}async function x(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);let n=-1;for(let r=t.length-22;r>=Math.max(0,t.length-66e3);r--)if(101010256===e.getUint32(r,!0)){n=r;break}if(n<0)throw new Error("Not a zip file");const r=e.getUint16(n+10,!0);let o=e.getUint32(n+16,!0);const s=new TextDecoder,l=new Map;for(let n=0;n<r;n++){const n=e.getUint16(o+10,!0),r=e.getUint32(o+20,!0),i=e.getUint16(o+28,!0),a=e.getUint16(o+30,!0),m=e.getUint16(o+32,!0),c=e.getUint32(o+42,!0),f=s.decode(t.subarray(o+46,o+46+i));if(o+=46+i+a+m,!/\.(xml|rels)$/i.test(f))continue;const u=c+30+e.getUint16(c+26,!0)+e.getUint16(c+28,!0),h=t.subarray(u,u+r);l.set(f,s.decode(8===n?await $(h):h))}return l}var w=new Set(["CONCAT","IFS","SWITCH","TEXTJOIN","XLOOKUP","XOR","IFNA","DAYS","STDEV.S","STDEV.P","VAR.S","VAR.P","MODE.SNGL","RANK.EQ","CEILING.MATH","FLOOR.MATH"]);function F(t){const{tokens:e}=f(t);let n="",r=0;for(const o of e){if("ident"!==o.type)continue;const e=o.value.replace(/^_xlfn\.(?:_xlws\.)?/i,"").replace(/^_xlws\./i,"");e!==o.value&&(n+=t.slice(r,o.start)+e,r=o.end)}return`=${n}${t.slice(r)}`}function y(t){return t.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var A='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n',C="http://schemas.openxmlformats.org/spreadsheetml/2006/main",v="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function N(t){return`FF${t.replace("#","").toUpperCase().padStart(6,"0").slice(0,6)}`}var U=class{fonts=[`<font><sz val="${e}"/><name val="Arial"/></font>`];fills=['<fill><patternFill patternType="none"/></fill>','<fill><patternFill patternType="gray125"/></fill>'];borders=["<border><left/><right/><top/><bottom/><diagonal/></border>"];numFmts=[];xfs=['<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>'];seen=new Map;index(t,e){const n=t.indexOf(e);return n>=0?n:(t.push(e),t.length-1)}add(t){if(!t||!Object.keys(t).length)return 0;const n=JSON.stringify(t),r=this.seen.get(n);if(void 0!==r)return r;const o=this.index(this.fonts,`<font>${t.bold?"<b/>":""}${t.italic?"<i/>":""}${t.strike?"<strike/>":""}${t.underline?"<u/>":""}<sz val="${t.fontSize??e}"/>${t.color?`<color rgb="${N(t.color)}"/>`:""}<name val="Arial"/></font>`),s=t.fill?this.index(this.fills,`<fill><patternFill patternType="solid"><fgColor rgb="${N(t.fill)}"/><bgColor indexed="64"/></patternFill></fill>`):0,l=(t,e)=>e?`<${t} style="thin"><color auto="1"/></${t}>`:`<${t}/>`,i=t.border??{},a=this.index(this.borders,`<border>${l("left",i.left)}${l("right",i.right)}${l("top",i.top)}${l("bottom",i.bottom)}<diagonal/></border>`);let m=0;t.numFmt&&"General"!==t.numFmt&&(m="@"===t.numFmt?49:164+this.index(this.numFmts,t.numFmt));const c=t.align||t.vAlign||t.wrap?`<alignment${t.align?` horizontal="${t.align}"`:""}${t.vAlign?` vertical="${"middle"===t.vAlign?"center":t.vAlign}"`:""}${t.wrap?' wrapText="1"':""}/>`:"",f=`<xf numFmtId="${m}" fontId="${o}" fillId="${s}" borderId="${a}" xfId="0" applyFont="1"${s?' applyFill="1"':""}${a?' applyBorder="1"':""}${m?' applyNumberFormat="1"':""}${c?' applyAlignment="1"':""}${c?`>${c}</xf>`:"/>"}`;return this.xfs.push(f),this.seen.set(n,this.xfs.length-1),this.xfs.length-1}toXml(){const t=this.numFmts.length?`<numFmts count="${this.numFmts.length}">${this.numFmts.map((t,e)=>`<numFmt numFmtId="${164+e}" formatCode="${y(t)}"/>`).join("")}</numFmts>`:"";return`${A}<styleSheet xmlns="${C}">${t}<fonts count="${this.fonts.length}">${this.fonts.join("")}</fonts><fills count="${this.fills.length}">${this.fills.join("")}</fills><borders count="${this.borders.length}">${this.borders.join("")}</borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="${this.xfs.length}">${this.xfs.join("")}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`}};function S(t,e,n,o,a,m){const c=`${s(a)}${o+1}`,u=t.cells[o]?.[a]??"",h=t.formats[l(o,a)],d=m.add(h),g=d?` s="${d}"`:"";if(""===u)return d?`<c r="${c}"${g}/>`:"";const p=n.value(e,o,a);if(i(u)){const t=`<f>${y(function(t){const e=t.slice(1),{tokens:n}=f(e);let r="",o=0;for(let t=0;t<n.length;t++){const s=n[t],l=n[t+1];"ident"===s.type&&"op"===l?.type&&"("===l.value&&w.has(s.value.toUpperCase())&&(r+=`${e.slice(o,s.start)}_xlfn.${s.value.toUpperCase()}`,o=s.end)}return r+e.slice(o)}(u))}</f>`;if("number"==typeof p)return`<c r="${c}"${g}>${t}<v>${p}</v></c>`;if("boolean"==typeof p)return`<c r="${c}"${g} t="b">${t}<v>${p?1:0}</v></c>`;if(p instanceof r){return`<c r="${c}"${g} t="e">${t}<v>${/^#(?:REF!|N\/A|NAME\?|DIV\/0!|VALUE!|NUM!|NULL!)$/.test(p.code)?p.code:"#VALUE!"}</v></c>`}return`<c r="${c}"${g} t="str">${t}<v>${y(null===p?"":p)}</v></c>`}if("number"==typeof p)return`<c r="${c}"${g}><v>${p}</v></c>`;if("boolean"==typeof p)return`<c r="${c}"${g} t="b"><v>${p?1:0}</v></c>`;const $=String(p??"");return`<c r="${c}"${g} t="inlineStr"><is><t${$!==$.trim()||/\n/.test($)?' xml:space="preserve"':""}>${y($)}</t></is></c>`}function k(e,r,o,l){const i=u(e);let a=i?.row??0,c=i?.col??0;const f=new Map;for(const t of Object.keys(e.formats)){const[e,n]=t.split(":").map(Number);a=Math.max(a,e),c=Math.max(c,n),f.has(e)||f.set(e,[]),f.get(e).push(n)}const h=new Set(e.hiddenRows);for(const t of[...e.hiddenRows,...Object.keys(e.rowHeights).map(Number)])a=Math.max(a,t);const d=[];for(let t=0;t<=a;t++){const n=e.cells[t]??[],s=new Set(f.get(t)??[]);n.forEach((t,e)=>{""!==t&&s.add(e)});const i=e.rowHeights[t];if(!s.size&&void 0===i&&!h.has(t))continue;const a=[...s].sort((t,e)=>t-e).map(n=>S(e,r,o,t,n,l)).join(""),m=`${void 0!==i?` ht="${(.75*i).toFixed(2)}" customHeight="1"`:""}${h.has(t)?' hidden="1"':""}`;d.push(`<row r="${t+1}"${m}>${a}</row>`)}const g=new Set(e.hiddenCols),p=[...new Set([...Object.keys(e.colWidths).map(Number),...g])].sort((t,e)=>t-e),$=p.length?`<cols>${p.map(n=>`<col min="${n+1}" max="${n+1}" width="${(((e.colWidths[n]??t)-5)/7).toFixed(4)}" customWidth="1"${g.has(n)?' hidden="1"':""}/>`).join("")}</cols>`:"",{frozenRows:b,frozenCols:x}=e,w=b||x?`<pane${x?` xSplit="${x}"`:""}${b?` ySplit="${b}"`:""} topLeftCell="${s(x)}${b+1}" activePane="${b&&x?"bottomRight":b?"bottomLeft":"topRight"}" state="frozen"/>`:"",F=e.merges.length?`<mergeCells count="${e.merges.length}">${e.merges.map(t=>`<mergeCell ref="${m(t)}"/>`).join("")}</mergeCells>`:"",y=e.filter?`<autoFilter ref="${m(e.filter.range)}"/>`:"",v=e.tabColor?`<sheetPr><tabColor rgb="${N(e.tabColor)}"/></sheetPr>`:"";return`${A}<worksheet xmlns="${C}">${v}<dimension ref="A1:${s(c)}${a+1}"/><sheetViews><sheetView${0===r?' tabSelected="1"':""} workbookViewId="0">${w}</sheetView></sheetViews><sheetFormatPr defaultColWidth="${((t-5)/7).toFixed(4)}" defaultRowHeight="${(.75*n).toFixed(2)}" customHeight="1"/>${$}<sheetData>${d.join("")}</sheetData>${y}${F}</worksheet>`}async function I(t,e){const n=new U,r=function(t){const e=new Set;return t.map((t,n)=>{const r=t.name.replace(/[[\]:*?/\\]/g," ").trim().slice(0,31)||`Sheet ${n+1}`;let o=r;for(let t=2;e.has(o.toLowerCase());t++)o=`${r.slice(0,28)} ${t}`;return e.add(o.toLowerCase()),o})}(t),o=t.map((t,r)=>({name:`xl/worksheets/sheet${r+1}.xml`,text:k(t,r,e,n)})),l=t.map((t,e)=>{return t.filter?`<definedName name="_xlnm._FilterDatabase" localSheetId="${e}" hidden="1">${y(`'${r[e].replace(/'/g,"''")}'!${n=t.filter.range,`$${s(n.c1)}$${n.r1+1}:$${s(n.c2)}$${n.r2+1}`}`)}</definedName>`:"";var n}).join("");return b([{name:"[Content_Types].xml",text:`${A}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>${t.map((t,e)=>`<Override PartName="/xl/worksheets/sheet${e+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join("")}</Types>`},{name:"_rels/.rels",text:`${A}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${v}/officeDocument" Target="xl/workbook.xml"/></Relationships>`},{name:"xl/workbook.xml",text:`${A}<workbook xmlns="${C}" xmlns:r="${v}"><sheets>${r.map((t,e)=>`<sheet name="${y(t)}" sheetId="${e+1}" r:id="rId${e+1}"/>`).join("")}</sheets>${l?`<definedNames>${l}</definedNames>`:""}<calcPr calcId="0" fullCalcOnLoad="1"/></workbook>`},{name:"xl/_rels/workbook.xml.rels",text:`${A}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${t.map((t,e)=>`<Relationship Id="rId${e+1}" Type="${v}/worksheet" Target="worksheets/sheet${e+1}.xml"/>`).join("")}<Relationship Id="rId${t.length+1}" Type="${v}/styles" Target="styles.xml"/></Relationships>`},{name:"xl/styles.xml",text:n.toXml()},...o])}var T={1:"0",2:"0.00",3:"#,##0",4:"#,##0.00",9:"0%",10:"0.00%",11:"0.00E+00",14:"dd/mm/yyyy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"dd/mm/yyyy h:mm",37:"#,##0;(#,##0)",38:"#,##0;[Red](#,##0)",39:"#,##0.00;(#,##0.00)",40:"#,##0.00;[Red](#,##0.00)",45:"mm:ss",46:"[h]:mm:ss",47:"mm:ss.0",48:"##0.0E+0",49:"@"},E=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47","0563C1","954F72"],M={0:"000000",1:"FFFFFF",2:"FF0000",3:"00FF00",4:"0000FF",5:"FFFF00",6:"FF00FF",7:"00FFFF",8:"000000",9:"FFFFFF",10:"FF0000",11:"00FF00",12:"0000FF",13:"FFFF00",14:"FF00FF",15:"00FFFF"};function R(t){if(!t)return;const e=t.getAttribute("rgb");if(e)return`#${e.slice(-6).toLowerCase()}`;const n=Number(t.getAttribute("tint")??0),r=t.getAttribute("theme");if(null!==r){const t=E[Number(r)];return t?`#${function(t,e){const n=n=>{const r=parseInt(t.slice(n,n+2),16),o=e<0?r*(1+e):r+(255-r)*e;return Math.round(o).toString(16).padStart(2,"0")};return`${n(0)}${n(2)}${n(4)}`}(t,n)}`.toLowerCase():void 0}const o=t.getAttribute("indexed");if(null!==o){const t=M[Number(o)];return t?`#${t}`.toLowerCase():void 0}}var D=t=>(new DOMParser).parseFromString(t,"application/xml"),j=(t,e)=>Array.from(t.getElementsByTagNameNS("*",e)),O=(t,e)=>j(t,e)[0],L=(t,e)=>Array.from(t.children).filter(t=>t.localName===e);function z(t){const e=/^([A-Z]+)(\d+)$/.exec(t);return{row:Number(e[2])-1,col:o(e[1])}}function P(t){const[e,n=e]=t.replace(/\$/g,"").split(":"),r=z(e),o=z(n);return{r1:r.row,c1:r.col,r2:o.row,c2:o.col}}function V(t,e,n,r){const o=D(e),s=a(t),i=[],m={},f=new Map;for(const t of j(o,"c")){const e=t.getAttribute("r");if(!e)continue;const{row:o,col:s}=z(e),a=r[Number(t.getAttribute("s")??0)];a&&Object.keys(a).length&&(m[l(o,s)]=a);const u=L(t,"f")[0],h=L(t,"v")[0]?.textContent??"",d=t.getAttribute("t");let g="";if(u){const t=u.getAttribute("si");if("shared"===u.getAttribute("t")&&null!==t)if(u.textContent)f.set(t,{text:u.textContent,row:o,col:s}),g=F(u.textContent);else{const e=f.get(t);e&&(g=c(F(e.text),o-e.row,s-e.col))}else u.textContent&&(g=F(u.textContent))}if(g||(g="s"===d?n[Number(h)]??"":"inlineStr"===d?j(t,"t").map(t=>t.textContent??"").join(""):"b"===d?"1"===h?"TRUE":"FALSE":h,"s"!==d&&"inlineStr"!==d&&"str"!==d||!/^(?:=|-?\d|'|true$|false$)/i.test(g)||(g=`'${g}`)),""!==g){for(;i.length<=o;)i.push([]);for(;i[o].length<=s;)i[o].push("");i[o][s]=g}}const u={},h=[];for(const t of j(o,"col")){const e=Number(t.getAttribute("min"))-1,n=Math.min(Number(t.getAttribute("max"))-1,e+500),r=Number(t.getAttribute("width")??0);for(let o=e;o<=n;o++)r&&"1"===t.getAttribute("customWidth")&&(u[o]=Math.round(7*r+5)),"1"===t.getAttribute("hidden")&&h.push(o)}const d={},g=[];for(const t of j(o,"row")){const e=Number(t.getAttribute("r"))-1,n=t.getAttribute("ht");n&&"1"===t.getAttribute("customHeight")&&(d[e]=Math.round(Number(n)/.75)),"1"===t.getAttribute("hidden")&&g.push(e)}const p=O(o,"pane"),$="frozen"===p?.getAttribute("state"),b=O(o,"autoFilter")?.getAttribute("ref"),x=R(O(o,"tabColor"));return{...s,tabColor:x,cells:i,formats:m,colWidths:u,rowHeights:d,hiddenCols:h,hiddenRows:g,merges:j(o,"mergeCell").map(t=>P(t.getAttribute("ref")??"A1")),frozenRows:$?Number(p?.getAttribute("ySplit")??0):0,frozenCols:$?Number(p?.getAttribute("xSplit")??0):0,filter:b?{range:P(b),excluded:{}}:null,rowCount:Math.max(s.rowCount,i.length+100),colCount:Math.max(s.colCount,i.reduce((t,e)=>Math.max(t,e.length),0))}}async function H(t){const e=await x(t),n=e.get("xl/workbook.xml");if(!n)throw new Error("Not a workbook");const r=D(e.get("xl/_rels/workbook.xml.rels")??"<Relationships/>"),o=new Map(j(r,"Relationship").map(t=>[t.getAttribute("Id"),t.getAttribute("Target")??""])),s=e.get("xl/sharedStrings.xml")?j(D(e.get("xl/sharedStrings.xml")),"si").map(t=>j(t,"t").filter(t=>"rPh"!==t.parentElement?.localName).map(t=>t.textContent??"").join("")):[],l=function(t){if(!t)return[];const e=D(t),n=new Map(j(e,"numFmt").map(t=>[Number(t.getAttribute("numFmtId")),t.getAttribute("formatCode")??""])),r=O(e,"fonts"),o=O(e,"fills"),s=O(e,"borders"),l=O(e,"cellXfs");if(!l)return[];const i=r?L(r,"font"):[],a=o?L(o,"fill"):[],m=s?L(s,"border"):[],c=Number(i[0]?L(i[0],"sz")[0]?.getAttribute("val")??0:0);return L(l,"xf").map(t=>{const e={},r=Number(t.getAttribute("numFmtId")??0),o=n.get(r)??T[r];o&&"General"!==o&&(e.numFmt=o);const s=i[Number(t.getAttribute("fontId")??0)];if(s){L(s,"b").length&&(e.bold=!0),L(s,"i").length&&(e.italic=!0),L(s,"u").length&&(e.underline=!0),L(s,"strike").length&&(e.strike=!0);const t=Number(L(s,"sz")[0]?.getAttribute("val")??0);t&&t!==c&&(e.fontSize=t);const n=R(L(s,"color")[0]);n&&"#000000"!==n&&(e.color=n)}const l=a[Number(t.getAttribute("fillId")??0)]?.getElementsByTagNameNS("*","patternFill")[0];if(l&&"solid"===l.getAttribute("patternType")){const t=R(L(l,"fgColor")[0]);t&&(e.fill=t)}const f=m[Number(t.getAttribute("borderId")??0)];if(f){const t=t=>!!L(f,t)[0]?.getAttribute("style"),n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")};(n.top||n.right||n.bottom||n.left)&&(e.border={...n.top?{top:!0}:{},...n.right?{right:!0}:{},...n.bottom?{bottom:!0}:{},...n.left?{left:!0}:{}})}const u=L(t,"alignment")[0];if(u){const t=u.getAttribute("horizontal");"left"!==t&&"center"!==t&&"right"!==t||(e.align=t);const n=u.getAttribute("vertical");"top"!==n&&"bottom"!==n||(e.vAlign=n),"center"===n&&(e.vAlign="middle");const r=u.getAttribute("wrapText");"1"!==r&&"true"!==r||(e.wrap=!0)}return e})}(e.get("xl/styles.xml")),i=[];for(const t of j(D(n),"sheet")){const n=t.getAttribute("name")??`Sheet ${i.length+1}`,r=t.getAttributeNS(v,"id")??t.getAttribute("r:id"),a=o.get(r)??"",m=a.startsWith("/")?a.slice(1):`xl/${a}`,c=e.get(m);c&&i.push(V(n,c,s,l))}if(!i.length)throw new Error("No sheets");return i}export{b as zip,x as unzip,I as writeXlsx,H as readXlsx};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ENGLISH_WORDS as r}from"./chunk-
|
|
1
|
+
import{ENGLISH_WORDS as r}from"./chunk-BDVKNU3U.js";import{newSheet as e}from"./chunk-5K2D7PBJ.js";var t=["xlsx","xls","ods","csv","tsv","txt"],s=t.map(r=>`.${r}`).join(",");import{createContext as o,useContext as a}from"react";import{jsx as n}from"react/jsx-runtime";var c=o(r);function i({words:r,children:e}){return n(c.Provider,{value:r,children:e})}var m=()=>a(c);import{createContext as l,useContext as u}from"react";import{jsx as v}from"react/jsx-runtime";var p=class extends Error{},x=l({});function d({value:r,children:e}){return v(x.Provider,{value:r,children:e})}var f=()=>u(x);function h(r,t){const s=Array.isArray(r?.sheets)?r.sheets:[];return s.length?s.map(r=>({...e(r.name),...r,cells:(r.cells??[]).map(r=>(r??[]).map(r=>r??""))})):[e(t)]}export{t as SPREADSHEET_EXTENSIONS,s as SPREADSHEET_ACCEPT,i as SpreadsheetWordsProvider,m as useSpreadsheetWords,p as SpreadsheetsConflict,d as SpreadsheetsProvider,f as useSpreadsheetsHost,h as sheetsOf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{BUILTIN_STYLES as t,CHECK_BULLETS as e,DEFAULT_PAGE as a,REL as n,child as r,childrenOf as o,descendants as s,paraCss as c,parseParaProps as l,parseRunProps as d,parseXml as i,partText as w,readRels as m,readThemeFonts as p,readZip as f,resolveTarget as u,runCss as h,tabCss as b,tabsAttr as g}from"./chunk-D3JKD7KW.js";import{escapeHtml as $}from"efficient-shell/ui";var v={textBox:"Text box",chart:"Chart",diagram:"Diagram",equation:"Equation",picture:"Picture",object:"Object",contents:"Field"},x={text:"",html:"",editable:!0},k=()=>({default:{...x},first:{...x},even:{...x}}),y=new Set(["w:ins","w:del","w:moveFrom","w:moveTo","w:rPrChange","w:pPrChange","w:tcPrChange","w:trPrChange","w:tblPrChange","w:sectPrChange","w:cellIns","w:cellDel"]),P=new Set(["w:ins","w:del","w:moveFrom","w:moveTo"]),j={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",bmp:"image/bmp",webp:"image/webp",svg:"image/svg+xml"},C=/^(https?:|mailto:|tel:)/i,S=t=>$(t);function M(t,e){let a="";for(let e=0;e<t.length;e+=32768)a+=String.fromCharCode(...t.subarray(e,e+32768));return`data:${e};base64,${btoa(a)}`}var I=(t,e)=>`${e}${++t.nextId}`,T=(t,e)=>t.src.slice(e.start,e.end),N=(t,e)=>e?T(t,e):void 0;function A(t,e){const a=[],n=new Set;let o=e;for(;o&&!n.has(o);){n.add(o);const e=t.styles.get(o);if(!e)break;a.unshift(e),o=r(e,"w:basedOn")?.attrs["w:val"]}return a}var E=t=>`"${t.replace(/["\\\n\r]/g,"")}"`;function O(t){return"w:t"===t.name||"w:delText"===t.name?t.text:"w:tab"===t.name?"\t":"w:instrText"===t.name||"w:instrDelText"===t.name?"":t.children.map(O).join("")}function B(t,e,a,n,r=""){const o=I(t,"x");return t.doc.raw.set(o,e),`<span data-raw="${o}" data-kind="${a}" contenteditable="false"${r}>${$(n)}</span>`}function L(t,e){const a=I(t,"x");return t.doc.raw.set(a,e),`<span data-raw="${a}" data-kind="mark"></span>`}function R(t,e,a){const n=a(T(t,e)),o=t=>s(e,new Set([t])).length>0,c=r(e,"wp:inline"),l=s(e,new Set(["a:blip"]))[0],d=l&&t.rels.get(l.attrs["r:embed"]),i=d&&!d.external?u(t.doc.docPath,d.target):void 0,w=i?.split(".").pop()?.toLowerCase()??"",m=i?t.doc.parts.get(i):void 0;if(m&&j[w]&&!o("wps:txbx")){const a=I(t,"x");t.doc.raw.set(a,n);const o=r(c??r(e,"wp:anchor"),"wp:extent"),s=Number(o?.attrs.cx)/12700,l=Number(o?.attrs.cy)/12700,d=s&&l?` style="width:${Math.round(100*s)/100}pt;height:${Math.round(100*l)/100}pt"`:"",i=c?"":' contenteditable="false"';return c||t.doc.notices.objects++,`<img data-raw="${a}" src="${S(t.imageUrl(m,j[w]))}"${d}${i} alt="">`}return t.doc.notices.objects++,o("wps:txbx")||o("w:txbxContent")?B(t,n,"object",`${t.labels.textBox}: ${O(e).slice(0,80)}`):o("c:chart")?B(t,n,"object",t.labels.chart):o("dgm:relIds")?B(t,n,"object",t.labels.diagram):B(t,n,"object",l?t.labels.picture:t.labels.object)}function F(t,e){const a=r(e,"w:rPr"),n=d(a,t.theme),o=N(t,a)??"",c=t=>`<w:r>${o}${t}</w:r>`;let l="";for(const a of e.children)switch(a.name){case"w:rPr":case"w:lastRenderedPageBreak":case"w:commentReference":case"w:fldChar":case"w:instrText":case"w:delInstrText":break;case"w:t":case"w:delText":l+=$(a.text);break;case"w:tab":l+="\t";break;case"w:noBreakHyphen":l+="‑";break;case"w:softHyphen":l+="";break;case"w:br":case"w:cr":"page"===a.attrs["w:type"]?l+='<span data-page-break contenteditable="false"></span>':"column"===a.attrs["w:type"]?l+=B(t,c(T(t,a)),"mark",""):l+="<br>";break;case"w:drawing":l+=R(t,a,c);break;case"mc:AlternateContent":case"w:pict":case"w:object":t.doc.notices.objects++,l+=B(t,c(T(t,a)),"object",s(a,new Set(["wps:txbx","w:txbxContent","v:textbox"])).length?`${t.labels.textBox}: ${O(s(a,new Set(["wps:txbx","w:txbxContent","v:textbox"]))[0]).slice(0,80)}`:t.labels.object);break;case"w:footnoteReference":{const e=a.attrs["w:id"],n=I(t,"x");t.doc.raw.set(n,c(T(t,a))),l+=`<span data-raw="${n}" data-kind="note" data-note="${S(e)}" contenteditable="false"></span>`;break}case"w:endnoteReference":{const e=++t.footnoteCount;t.doc.notices.footnotes++;const n=t.footnotes.get(a.attrs["w:id"]);l+=B(t,c(T(t,a)),"endnote",String(e),n?` title="${S(n)}"`:"");break}default:l+=B(t,c(T(t,a)),"mark","")}if(!l)return"";if(n.vert&&(l=`<${"sub"===n.vert?"sub":"sup"}>${l}</${"sub"===n.vert?"sub":"sup"}>`),a){const e=I(t,"r");t.doc.runs.set(e,o);const s=h(n),c=r(a,"w:rStyle")?.attrs["w:val"];l=`<span data-r="${e}"${c?` data-rstyle="${S(c)}"`:""}${s?` style="${S(s)}"`:""}>${l}</span>`}for(const e of t.openComments)l=`<span data-comment="${S(e)}" title="${S(t.comments.get(e)??"")}">${l}</span>`;return l}function D(t,e){let a="",n=0,r=-1,s=-1,c="",l="",d=!1;const i=()=>{if(r>=0){const e=J(l);a+=B(t,t.src.slice(r,s),"field",c||t.labels.contents,e?` data-field="${e}"`:"")}l="",r=-1,c="",d=!1};for(const w of e){if("w:r"===w.name){const e=o(w,"w:fldChar");if(e.length||n>0){if(0===n&&(r=w.start,d=!1),d)c+=O(w);else for(const t of o(w,"w:instrText"))l+=t.text;for(const t of e){const e=t.attrs["w:fldCharType"];"begin"===e?n++:"separate"===e&&1===n?d=!0:"end"===e&&n--}s=w.end,0===n&&i();continue}a+=F(t,w);continue}if(n>0)s=w.end;else switch(w.name){case"w:pPr":case"w:proofErr":break;case"w:commentRangeStart":t.openComments.add(w.attrs["w:id"]);break;case"w:commentRangeEnd":t.openComments.delete(w.attrs["w:id"]);break;case"w:hyperlink":{const e=w.attrs["r:id"]?t.rels.get(w.attrs["r:id"]):void 0,n=w.attrs["w:anchor"],r=e?.target??(n?`#${n}`:""),o=C.test(r)||r.startsWith("#"),s=`${e?` data-rel="${S(w.attrs["r:id"])}"`:""}${n?` data-anchor="${S(n)}"`:""}`;a+=`<a${o?` href="${S(r)}"`:""}${s}>${D(t,w.children)}</a>`;break}case"w:ins":case"w:moveTo":a+=`<ins>${D(t,w.children)}</ins>`;break;case"w:del":case"w:moveFrom":a+=`<del>${D(t,w.children)}</del>`;break;case"w:bookmarkStart":{const e=w.attrs["w:name"]??"",n=I(t,"x");t.doc.raw.set(n,T(t,w)),a+=e&&!e.startsWith("_")?`<span data-raw="${n}" data-kind="mark" data-bookmark="${S(e)}" contenteditable="false"></span>`:`<span data-raw="${n}" data-kind="mark"${e.startsWith("_Toc")?` data-toc-anchor="${S(e)}"`:""}></span>`;break}case"w:bookmarkEnd":case"w:permStart":case"w:permEnd":default:a+=L(t,T(t,w));break;case"m:oMath":case"m:oMathPara":t.doc.notices.objects++,a+=B(t,T(t,w),"object",t.labels.equation);break;case"w:fldSimple":case"w:sdt":case"w:smartTag":case"w:customXml":{const e="w:fldSimple"===w.name?J(w.attrs["w:instr"]??""):"";a+=B(t,T(t,w),"field",O(w)||t.labels.contents,e?` data-field="${e}"`:"");break}}}return n>0&&(a+=$(c)),a}function q(t){return s(t,y).length>0}function W(t,e){const a=r(e,"w:pPr"),n=r(a,"w:pStyle")?.attrs["w:val"],o=r(a,"w:numPr")??function(t,e){let a;for(const n of A(t,e))a=r(r(n,"w:pPr"),"w:numPr")??a;return a}(t,n),s=r(o,"w:numId")?.attrs["w:val"];if(!s||"0"===s)return null;const c=Number(r(o,"w:ilvl")?.attrs["w:val"]??0),l=t.numbering.get(s)?.get(c);return{numId:s,ilvl:c,ordered:l?.ordered??!1,marker:l?.marker??"",check:l?.check}}function H(t){const e=[],a=r(t,"w:pBdr");for(const t of["top","bottom","left","right"]){const n=r(a,`w:${t}`);if(!n||"nil"===n.attrs["w:val"]||"none"===n.attrs["w:val"])continue;const o=/^[0-9a-fA-F]{6}$/.test(n.attrs["w:color"]??"")?`#${n.attrs["w:color"]}`:"currentcolor";e.push(`border-${t}:${(Number(n.attrs["w:sz"])||4)/8}pt solid ${o}`)}const n=r(t,"w:shd")?.attrs["w:fill"];return n&&/^[0-9a-fA-F]{6}$/.test(n)&&e.push(`background-color:#${n}`),e.join(";")}function z(t,e,a){const n=r(e,"w:pPr"),o=r(n,"w:pStyle")?.attrs["w:val"],d=t.fieldOpen,i=function(t){let e=0;for(const a of s(t,new Set(["w:fldChar"]))){const t=a.attrs["w:fldCharType"];"begin"===t?e++:"end"===t&&e--}return e}(e),w=q(e)||d||0!==i;i>0&&(t.fieldOpen=!0),d&&i<0&&(t.fieldOpen=!1);const m=I(t,"p");t.doc.blocks.set(m,{xml:T(t,e),fingerprint:"",props:N(t,n),numId:a?.numId,ilvl:a?.ilvl});const p=a?0:function(t,e){if(!e)return 0;const a=r(t.styles.get(e),"w:name")?.attrs["w:val"]??"",n=/^heading ([1-6])$/i.exec(a);return n?Number(n[1]):0}(t,o),f=a?"li":p?`h${p}`:"p",u=l(n);a&&delete u.indentLeft,a&&delete u.firstLine;const h=[c(u),b(u),H(n)].filter(Boolean).join(";");let $=w?G(t,e):D(t,e.children);$&&!/<br>(<\/[^>]+>)*$/.test($)||($+="<br>");const v=r(n,"w:pageBreakBefore")?" data-break-before":"",x=u.tabs?` data-tabs="${g(u.tabs)}"`:"",k=e.attrs["w14:paraId"]?` data-pid="${S(e.attrs["w14:paraId"])}"`:"",y=r(n,"w:sectPr");let P="";if(y){const e=t.sectionTypes[++t.sectionIndex]??"nextPage",a=Number(r(y,"w:cols")?.attrs["w:num"]??1);P=` data-section="${S(e)}"${a>1?` data-cols="${a}"`:""}`}const j=/<span data-raw="[^"]+" data-kind="mark" data-toc-anchor="([^"]+)"/.exec($)?.[1];return`<${f} data-docx="${m}"${k}${v}${P}${p&&j?` data-bm="${j}"`:""}${o?` data-pstyle="${S(o)}"`:""}${x}${h?` style="${S(h)}"`:""}${w?' data-locked contenteditable="false"':""}>${$}</${f}>`}function G(t,e){let a="";for(const n of e.children)"w:pPr"!==n.name&&"w:rPr"!==n.name&&"w:instrText"!==n.name&&"w:delInstrText"!==n.name&&("w:ins"===n.name||"w:moveTo"===n.name?a+=`<ins>${G(t,n)}</ins>`:"w:del"===n.name||"w:moveFrom"===n.name?a+=`<del>${G(t,n)}</del>`:"w:commentRangeStart"===n.name?t.openComments.add(n.attrs["w:id"]):"w:commentRangeEnd"===n.name?t.openComments.delete(n.attrs["w:id"]):"w:t"===n.name||"w:delText"===n.name?a+=$(n.text):"w:tab"===n.name?a+="\t":"w:br"===n.name?a+="<br>":"w:drawing"===n.name||"mc:AlternateContent"===n.name||"w:pict"===n.name?a+=`<span data-kind="object">${$(t.labels.object)}</span>`:a+=G(t,n));return a}function U(t,e){const a=I(t,"t"),n=r(e,"w:tblPr"),s=r(e,"w:tblGrid"),c=o(e,"w:tr"),l=c.some(t=>r(r(t,"w:trPr"),"w:gridBefore")||r(r(t,"w:trPr"),"w:gridAfter")),d=q(e)||l;l&&t.doc.notices.objects++,t.doc.blocks.set(a,{xml:T(t,e),fingerprint:"",props:N(t,n),tblGrid:N(t,s)});const i=r(n,"w:tblStyle")?.attrs["w:val"],w=o(s,"w:gridCol").map(t=>Number(t.attrs["w:w"])/20),m=new Map,p=c.map(t=>{const e=[];let a=0;for(const n of o(t,"w:tc")){const t=r(n,"w:tcPr"),o=Number(r(t,"w:gridSpan")?.attrs["w:val"]??1),s=r(t,"w:vMerge");if(s&&"restart"!==s.attrs["w:val"]&&m.has(a))m.get(a).rowSpan++;else{const t={node:n,rowSpan:1,col:a,span:o};e.push(t),s?m.set(a,t):m.delete(a)}a+=o}return e}),f=function(t,e,a){let n=r(e,"w:tblBorders");if(!n)for(const e of A(t,a))n=r(r(e,"w:tblPr"),"w:tblBorders")??n;return!!n&&n.children.some(t=>!["nil","none"].includes(t.attrs["w:val"]))}(t,n,i),u=c.map((e,a)=>{const n=I(t,"t");t.doc.blocks.set(n,{xml:"",fingerprint:"",props:N(t,r(e,"w:trPr"))});return`<tr data-docx="${n}">${p[a].map(e=>{const a=I(t,"t"),n=r(e.node,"w:tcPr");t.doc.blocks.set(a,{xml:"",fingerprint:"",props:N(t,n)});const o=r(n,"w:shd")?.attrs["w:fill"],s=[];o&&/^[0-9a-fA-F]{6}$/.test(o)&&s.push(`background-color:#${o.toLowerCase()}`);const c=r(n,"w:vAlign")?.attrs["w:val"];return"center"===c&&s.push("vertical-align:middle"),"bottom"===c&&s.push("vertical-align:bottom"),`<td data-docx="${a}"${e.span>1?` colspan="${e.span}"`:""}${e.rowSpan>1?` rowspan="${e.rowSpan}"`:""}${s.length?` style="${s.join(";")}"`:""}>${_(t,e.node.children)}</td>`}).join("")}</tr>`}).join(""),h=w.length?`<colgroup>${w.map(t=>`<col style="width:${Math.round(100*t)/100}pt">`).join("")}</colgroup>`:"";return`<table data-docx="${a}"${i?` data-tstyle="${S(i)}"`:""}${f?"":" data-no-borders"}${d?' data-locked contenteditable="false"':""}>${h}<tbody>${u}</tbody></table>`}function _(t,e){const a=[],n=[],c=t=>{for(;n.length>t;){const t=n.pop();a.push(`</li></${t.tag}>`)}};for(const l of e){const e="w:p"===l.name?W(t,l):null;if(e){for(;n.length&&n[n.length-1].ilvl>e.ilvl;)c(n.length-1);const r=n[n.length-1],o=r&&(!(!r.check||!e.check)||r.numId===e.numId&&r.tag===(e.ordered?"ol":"ul"));r&&r.ilvl===e.ilvl&&!o&&c(n.length-1);const s=`${e.numId}:${e.ilvl}`,d=t.listCounters.get(s)??0;t.listCounters.set(s,d+1);let i=z(t,l,e);"done"===e.check&&(i=i.replace(/^<li /,"<li data-checked "));const w=n[n.length-1];if(w&&w.ilvl===e.ilvl)a.push(`</li>${i.slice(0,i.lastIndexOf("</li>"))}`);else{const t=e.ordered?"ol":"ul",r=e.marker?` style="list-style-type:${e.marker}"`:"",o=e.ordered&&d?` start="${d+1}"`:"",s=e.check?" data-checklist":` data-num-id="${S(e.numId)}"`;a.push(`<${t}${s} data-ilvl="${e.ilvl}"${o}${r}>${i.slice(0,i.lastIndexOf("</li>"))}`),n.push({tag:t,numId:e.numId,ilvl:e.ilvl,check:!!e.check})}continue}if("w:tcPr"!==l.name&&"w:sectPr"!==l.name)if(c(0),"w:p"===l.name)a.push(z(t,l,null));else if("w:tbl"===l.name)a.push(U(t,l));else if("w:sdt"===l.name&&K(l)){const e=I(t,"p");t.doc.blocks.set(e,{xml:T(t,l),fingerprint:""});const n=o(r(l,"w:sdtContent"),"w:p").map(t=>{const e=Number(/(\d)$/.exec(r(r(t,"w:pPr"),"w:pStyle")?.attrs["w:val"]??"")?.[1]??1),a=s(t,new Set(["w:hyperlink"]))[0]?.attrs["w:anchor"]??"",n=O(t).replace(/\s+/g," ").trim();return Z(e,a,n.replace(/\t?\s*\d+$/,""),/(\d+)$/.exec(n)?.[1]??"")}).join("");a.push(`<div data-docx="${e}" data-toc contenteditable="false">${n}</div>`)}else if("w:sdt"===l.name){const e=I(t,"p");t.doc.blocks.set(e,{xml:T(t,l),fingerprint:""}),t.doc.notices.objects++;const n=_(t,o(r(l,"w:sdtContent"),"w:p"));a.push(`<div data-docx="${e}" data-locked contenteditable="false">${n}</div>`)}else{const e=I(t,"p");t.doc.blocks.set(e,{xml:T(t,l),fingerprint:""}),a.push(`<div data-docx="${e}" data-locked data-hidden contenteditable="false"></div>`)}}return c(0),a.join("")}function K(t){const e=r(r(r(t,"w:sdtPr"),"w:docPartObj"),"w:docPartGallery")?.attrs["w:val"]??"";return/table of contents/i.test(e)}function Z(t,e,a,n){const r=/^[A-Za-z0-9_]+$/.test(e)?e:"";return`<p data-toc-level="${Math.min(Math.max(t,1),9)}">${r?`<a href="#${r}" data-anchor="${r}">${$(a)}</a>`:$(a)}<span data-toc-page>${$(n)}</span></p>`}function J(t){const e=t.trim().split(/\s+/)[0]?.toUpperCase();return"PAGE"===e?"page":"NUMPAGES"===e||"SECTIONPAGES"===e?"pages":""}function X(t){if("LI"!==t.tagName)return t.outerHTML;const e=t.cloneNode(!0);return Array.from(e.children).forEach(t=>{"UL"!==t.tagName&&"OL"!==t.tagName||t.remove()}),e.outerHTML}function Q(t,e=t.html){const a=document.createElement("div");a.innerHTML=e,a.querySelectorAll("[data-docx]").forEach(e=>{const a=t.blocks.get(e.getAttribute("data-docx"));a&&(a.fingerprint=X(e))})}function V(t,e){const a=e?w(t.doc.parts,e):void 0;if(!e||!a)return{text:"",html:"",editable:!0};const n=i(a),r=0===s(n,new Set(["w:sdt","mc:AlternateContent","w:pict","w:txbxContent"])).length,o={src:t.src,rels:t.rels,notices:{...t.doc.notices}};t.src=a,t.rels=new Map(m(t.doc.parts,e).map(t=>[t.id,t]));let c="";try{c=_(t,n.children)}finally{t.src=o.src,t.rels=o.rels,t.doc.notices=o.notices}return{text:Y(n),html:r?c:`<div data-locked contenteditable="false">${c}</div>`,editable:r,part:e}}function Y(t){return t.children.filter(t=>"w:p"===t.name).map(t=>{let e="",a="",n=!1;const r=t=>{for(const o of t.children)if("w:t"===o.name)n||(e+=o.text);else if("w:tab"===o.name)n||(e+=" | ");else if("w:instrText"===o.name)a+=o.text;else if("w:fldChar"===o.name){const t=o.attrs["w:fldCharType"];"separate"!==t&&"end"!==t||(a&&(e+=tt(a),a=""),n="separate"===t)}else"w:fldSimple"===o.name?e+=tt(o.attrs["w:instr"]??"")||o.children.map(O).join(""):"w:pPr"!==o.name&&"w:rPr"!==o.name&&r(o)};return r(t),e}).filter(Boolean).join(" ")}function tt(t){const e=J(t);return e?`{${e}}`:""}function et(t,e,a){return 1===t&&e?"first":t%2==0&&a?"even":"default"}function at(t){const e=document.createElement("div");e.innerHTML=t,e.querySelectorAll('[data-field="page"]').forEach(t=>t.replaceWith("{page}")),e.querySelectorAll('[data-field="pages"]').forEach(t=>t.replaceWith("{pages}")),e.querySelectorAll('img,[data-kind="object"],[data-hidden]').forEach(t=>t.remove());const a=Array.from(e.querySelectorAll("p,h1,h2,h3,h4,h5,h6,li")).map(t=>(t.textContent??"").replace(/\t/g," | ").trim()).filter(Boolean);return a.length?a.join(" "):(e.textContent??"").trim()}async function nt(t,e={}){return rt(await f(t),t,e)}function rt(f,b,g={}){const $=m(f,"").find(t=>t.type.endsWith("/officeDocument")),x=$?u("",$.target):"word/document.xml",y=w(f,x);if(!y)throw new Error("Not a Word document");const j=i(y),C=r(j,"w:body");if(!C)throw new Error("Not a Word document");const S=m(f,x),I=t=>{const e=(t=>S.find(e=>e.type===t))(t);return e?u(x,e.target):void 0},T=p(I(n.theme)?w(f,I(n.theme)):void 0),N={parts:f,docPath:x,source:b,html:"",css:"",page:{...a},headers:k(),footers:k(),titlePage:!1,evenOdd:!1,columns:1,footnotes:new Map,blocks:new Map,runs:new Map,raw:new Map,notices:{comments:0,tracked:0,objects:0,footnotes:0},styles:[],theme:T},B={src:y,doc:N,labels:g.labels??v,rels:new Map(S.map(t=>[t.id,t])),theme:T,imageUrl:g.imageUrl??M,styles:new Map,numbering:new Map,listCounters:new Map,comments:new Map,footnotes:new Map,nextId:0,footnoteCount:0,openComments:new Set,fieldOpen:!1,sectionTypes:[],sectionIndex:0},L=I(n.styles),R=L?w(f,L):void 0,F=R?i(R):void 0;for(const t of o(F,"w:style"))B.styles.set(t.attrs["w:styleId"],t);const D=new Set(B.styles.keys());for(const[e,a]of Object.entries(t))D.has(e)||B.styles.set(e,i(a.xml));const q=r(F,"w:docDefaults");N.lang=r(r(r(q,"w:rPrDefault"),"w:rPr"),"w:lang")?.attrs["w:val"],N.css=function(t,e){const a=[],n=d(r(r(e,"w:rPrDefault"),"w:rPr"),t.theme),o=l(r(r(e,"w:pPrDefault"),"w:pPr"));t.doc.defaultFont=n.font,t.doc.defaultSize=n.size;let s=n,i=o;for(const[e,w]of t.styles){const m=w.attrs["w:type"];if("paragraph"!==m&&"character"!==m&&"table"!==m)continue;let p={},f={};for(const a of A(t,e))p={...p,...d(r(a,"w:rPr"),t.theme)},f={...f,...l(r(a,"w:pPr"))};if("paragraph"===m)a.push(`.docs-page [data-pstyle=${E(e)}]{${[h(p),c(f)].filter(Boolean).join(";")}}`),"1"===w.attrs["w:default"]&&(s={...n,...p},i={...o,...f});else if("character"===m)a.push(`.docs-page [data-rstyle=${E(e)}]{${h(p)}}`);else{const t=c(f);t&&a.push(`.docs-page table[data-tstyle=${E(e)}] p{${t}}`)}}return a.unshift(`.docs-page{${h(s)}}`,`.docs-page p,.docs-page h1,.docs-page h2,.docs-page h3,.docs-page h4,.docs-page h5,.docs-page h6,.docs-page li{${c(i)}}`),a.join("\n")}(B,q);const W=new Set(Object.keys(t));N.styles=[...B.styles.values()].filter(t=>"paragraph"===t.attrs["w:type"]&&"1"!==t.attrs["w:default"]&&(W.has(t.attrs["w:styleId"])||r(t,"w:qFormat"))&&!r(t,"w:hidden")&&!r(t,"w:semiHidden")).map(t=>({id:t.attrs["w:styleId"],name:r(t,"w:name")?.attrs["w:val"]??t.attrs["w:styleId"]}));const H=I(n.numbering),z=H?w(f,H):void 0;z&&function(t,a){const n=new Map;for(const t of o(a,"w:abstractNum")){const a=new Map;for(const n of o(t,"w:lvl")){const t=r(n,"w:numFmt")?.attrs["w:val"]??"decimal",o=r(n,"w:lvlText")?.attrs["w:val"],s="bullet"===t&&o===e.open?"open":"bullet"===t&&o===e.done?"done":void 0;a.set(Number(n.attrs["w:ilvl"]),{ordered:"bullet"!==t&&"none"!==t,marker:ot[t]??"",check:s})}n.set(t.attrs["w:abstractNumId"],a)}for(const e of o(a,"w:num")){const a=n.get(r(e,"w:abstractNumId")?.attrs["w:val"]??"");a&&t.numbering.set(e.attrs["w:numId"],a)}}(B,i(z));const G=I(n.comments),U=G?w(f,G):void 0;if(U){for(const t of o(i(U),"w:comment"))B.comments.set(t.attrs["w:id"],`${t.attrs["w:author"]??""}: ${O(t)}`);N.notices.comments=B.comments.size}const K=I(n.footnotes),Z=K?w(f,K):void 0;if(Z)for(const t of o(i(Z),"w:footnote")){const e=t.attrs["w:id"];if(B.footnotes.set(e,O(t)),t.attrs["w:type"]&&"normal"!==t.attrs["w:type"])continue;const a=0===s(t,new Set(["w:tbl","w:drawing","w:pict","mc:AlternateContent","w:sdt","m:oMath"])).length;N.footnotes.set(e,{text:O(t).trim(),xml:Z.slice(t.start,t.end),editable:a})}N.notices.tracked=s(C,P).length;const J=r(C,"w:sectPr"),X=[...s(C,new Set(["w:sectPr"])).filter(t=>t!==J),...J?[J]:[]];B.sectionTypes=X.map(t=>r(t,"w:type")?.attrs["w:val"]??"nextPage"),B.sectionIndex=0,N.columns=Math.max(1,Number(r(J,"w:cols")?.attrs["w:num"]??1)||1),N.titlePage=!!r(J,"w:titlePg")&&"0"!==r(J,"w:titlePg")?.attrs["w:val"];const Y=I(n.settings),tt=Y?w(f,Y):void 0;N.evenOdd=!!tt&&/<w:evenAndOddHeaders(?![^>]*w:val="(?:0|false)")[^>]*\/?>/.test(tt);const et=r(J,"w:pgSz"),at=r(J,"w:pgMar"),nt=(t,e,a)=>{const n=Number(t?.attrs[e]);return Number.isFinite(n)&&void 0!==t?.attrs[e]?n:a};N.page={width:nt(et,"w:w",a.width),height:nt(et,"w:h",a.height),top:Math.abs(nt(at,"w:top",a.top)),right:nt(at,"w:right",a.right),bottom:Math.abs(nt(at,"w:bottom",a.bottom)),left:nt(at,"w:left",a.left),header:nt(at,"w:header",a.header),footer:nt(at,"w:footer",a.footer)};const rt=(t,e)=>{const a=o(J,t).find(t=>(t.attrs["w:type"]??"default")===e),n=a&&B.rels.get(a.attrs["r:id"]);return n?u(x,n.target):void 0};N.html=_(B,C.children);for(const t of["default","first","even"])N.headers[t]=V(B,rt("w:headerReference",t)),N.footers[t]=V(B,rt("w:footerReference",t));N.html||(N.html="<p><br></p>"),Q(N),N.footnotesRead=new Map([...N.footnotes].map(([t,e])=>[t,e.text]));for(const t of[N.headers,N.footers])for(const e of Object.values(t))e.html&&Q(N,e.html);return N}var ot={lowerLetter:"lower-alpha",upperLetter:"upper-alpha",lowerRoman:"lower-roman",upperRoman:"upper-roman",decimalZero:"decimal-leading-zero"};export{Z as tocEntryHtml,X as fingerprintOf,Q as stampFingerprints,et as headerKindFor,at as marginTextOfHtml,nt as readDocx,rt as readParts};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jpegPdf as t}from"./chunk-CEVQKZ66.js";import{drawJpeg as o,embeddedFonts as r,openStage as n,settled as e}from"./chunk-PX4QOBHF.js";import{SLIDE_FONT as i,SlideView as c}from"./chunk-EP3ZNVDB.js";import{ENGLISH_WORDS as s}from"./chunk-AJTH75FI.js";import"./chunk-B32ASXHM.js";import{flushSync as a}from"react-dom";import{createRoot as m}from"react-dom/client";import{jsx as l}from"react/jsx-runtime";async function d(t,r,n,i){const s=document.createElement("div");r.root.append(s);const d=m(s);try{a(()=>d.render(l(c,{slide:t,width:1600})));const r=s.firstElementChild;await e(r);return{jpeg:await o(r,{width:1600,height:900,pixelRatio:1,quality:i,fontCss:n,background:t.background}),width:720,height:405}}finally{d.unmount(),s.remove()}}async function u(o,e={}){const{signal:c,onProgress:a,quality:m}=e;c?.throwIfAborted();const l=n();try{const n=await async function(t){const o=document.createElement("div");o.style.fontFamily=i,t.root.append(o);try{return await r(o)}finally{o.remove()}}(l),e=[];for(const[t,r]of o.slides.entries()){c?.throwIfAborted();const i=await d(r,l,n,m).catch(o=>{throw new Error(s.pdfSlideFailed(t+1),{cause:o})});e.push(i),a?.(t+1,o.slides.length)}return t(e)}finally{l.close()}}export{u as deckToPdf};
|
|
@@ -31,6 +31,45 @@
|
|
|
31
31
|
.docs-outline { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
|
|
32
32
|
.docs-outline button { display: block; width: 100%; padding: 4px; border-radius: 4px; text-align: left; font-size: 12px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
33
33
|
.docs-outline button:hover { background: var(--line-subtle); }
|
|
34
|
+
|
|
35
|
+
/* Documents parity (2026-11-16): ruler, header/footer, footnotes, dialogs. The ruler
|
|
36
|
+
and the header and footer previews sit on the white sheet, so they keep its colours. */
|
|
37
|
+
.docs-ruler-row { position: sticky; top: 0; z-index: 2; display: flex; justify-content: center; padding: 6px 0 4px; background: var(--surface-sunken); }
|
|
38
|
+
.docs-ruler { position: relative; height: 18px; background: #fff; border-bottom: 1px solid #ccc; cursor: copy; user-select: none; touch-action: none; }
|
|
39
|
+
.docs-ruler-margin { position: absolute; top: 0; bottom: 0; background: #e8e8e8; pointer-events: none; }
|
|
40
|
+
.docs-ruler-tick { position: absolute; top: 2px; transform: translateX(-50%); font-size: 9px; line-height: 1; color: #777; pointer-events: none; }
|
|
41
|
+
.docs-ruler-tick::after { content: ""; position: absolute; left: 50%; top: 11px; width: 1px; height: 4px; background: #aaa; }
|
|
42
|
+
.docs-ruler button { position: absolute; padding: 0; border: 0; background: none; cursor: ew-resize; transform: translateX(-50%); }
|
|
43
|
+
.docs-ruler-first { top: 0; width: 0; height: 0; border-left: 5px solid transparent !important; border-right: 5px solid transparent !important; border-top: 7px solid #1a73e8 !important; }
|
|
44
|
+
.docs-ruler-left, .docs-ruler-right { bottom: 0; width: 0; height: 0; border-left: 5px solid transparent !important; border-right: 5px solid transparent !important; border-bottom: 7px solid #1a73e8 !important; }
|
|
45
|
+
.docs-ruler-tab { top: 9px; width: 9px; height: 9px; }
|
|
46
|
+
.docs-ruler-tab::before { content: ""; position: absolute; inset: 0; border-left: 2px solid #333; border-bottom: 2px solid #333; }
|
|
47
|
+
.docs-ruler-tab-center::before { left: 3px; right: auto; width: 0; border-left: 2px solid #333; border-bottom: 0; }
|
|
48
|
+
.docs-ruler-tab-center::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; border-bottom: 2px solid #333; }
|
|
49
|
+
.docs-ruler-tab-right::before { border-left: 0; border-right: 2px solid #333; }
|
|
50
|
+
|
|
51
|
+
.docs-hf-preview { position: absolute; display: block; overflow: hidden; padding: 0; border: 1px dashed transparent; background: transparent; text-align: left; cursor: pointer; min-height: 12px; }
|
|
52
|
+
.docs-hf-preview:hover, .docs-hf-preview:focus-visible { border-color: #9ab; outline: none; }
|
|
53
|
+
.docs-hf-preview:empty:hover::before, .docs-hf-preview:empty:focus-visible::before { content: attr(data-hint); color: #999; font: 9pt Calibri, Carlito, Arial, sans-serif; }
|
|
54
|
+
.docs-hf { display: flex; flex-direction: column; gap: 16px; }
|
|
55
|
+
.docs-hf-options { display: flex; flex-wrap: wrap; gap: 16px; }
|
|
56
|
+
.docs-hf-kind { display: flex; flex-direction: column; gap: 8px; }
|
|
57
|
+
.docs-hf-kind h4 { margin: 0; font-size: 13px; font-weight: 600; }
|
|
58
|
+
.docs-hf-region { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
|
|
59
|
+
.docs-hf-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 2px 6px; border-bottom: 1px solid var(--line); background: var(--surface-sunken); }
|
|
60
|
+
.docs-hf-label { margin-right: auto; font-size: 12px; color: var(--ink-muted); }
|
|
61
|
+
.docs-hf-edit { min-height: 48px; padding: 8px 12px; }
|
|
62
|
+
.docs-hf-note { margin: 0; padding: 4px 12px 8px; font-size: 12px; color: var(--ink-muted); }
|
|
63
|
+
|
|
64
|
+
.docs-footnotes { position: relative; margin-top: 12pt; padding-top: 6pt; border-top: 0.75pt solid #999; color: #000; font: 9pt Calibri, Carlito, Arial, sans-serif; }
|
|
65
|
+
.docs-footnote { display: flex; align-items: baseline; gap: 4pt; margin-bottom: 3pt; }
|
|
66
|
+
.docs-footnote sup { min-width: 10pt; color: #0563c1; }
|
|
67
|
+
.docs-footnote input { flex: 1; min-width: 0; padding: 1pt 2pt; border: 1px solid transparent; border-radius: 2px; background: transparent; color: #000; font: inherit; }
|
|
68
|
+
.docs-footnote input:hover, .docs-footnote input:focus { border-color: #bbb; outline: none; }
|
|
69
|
+
.docs-footnote input::placeholder { color: #999; }
|
|
70
|
+
|
|
71
|
+
.docs-para-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
|
|
72
|
+
.docs-para-error { margin: 8px 0 0; font-size: 12px; color: var(--status-danger-ink, #b42318); }
|
|
34
73
|
/* The file list Documents and Spreadsheet share (./FileList.tsx), laid out as
|
|
35
74
|
Slides' deck list is. The build appends this to documents.css and
|
|
36
75
|
spreadsheet.css, so a host loads it with the app's own stylesheet. */
|
|
@@ -9,7 +9,8 @@ export { E as ENGLISH_FILE_WORDS, O as OfficeFileChoice, a as OfficeFileRequest,
|
|
|
9
9
|
*
|
|
10
10
|
* The zh-Hans words for the Easel frame (`backToFiles` to `openFromFiles`) are
|
|
11
11
|
* machine-written, and no person has read them yet. Nor have the file list's
|
|
12
|
-
* (`filesHeading` to `deleteConfirm`)
|
|
12
|
+
* (`filesHeading` to `deleteConfirm`), nor the parity words of 2026-11-16 (`styleHeading4`
|
|
13
|
+
* to `wordFonts`).
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
interface DocumentsWords {
|
|
@@ -129,7 +130,6 @@ interface DocumentsWords {
|
|
|
129
130
|
marginsWide: string;
|
|
130
131
|
header: string;
|
|
131
132
|
footer: string;
|
|
132
|
-
headerFooterHint: string;
|
|
133
133
|
headerFooterLocked: string;
|
|
134
134
|
ok: string;
|
|
135
135
|
cancel: string;
|
|
@@ -169,6 +169,67 @@ interface DocumentsWords {
|
|
|
169
169
|
cannotRead: (name: string) => string;
|
|
170
170
|
unsupported: (ext: string) => string;
|
|
171
171
|
pdfPageFailed: (page: number) => string;
|
|
172
|
+
styleHeading4: string;
|
|
173
|
+
styleHeading5: string;
|
|
174
|
+
styleHeading6: string;
|
|
175
|
+
applyStyle: (name: string) => string;
|
|
176
|
+
updateStyle: (name: string) => string;
|
|
177
|
+
styleUpdated: (name: string) => string;
|
|
178
|
+
paintFormat: string;
|
|
179
|
+
paintFormatHint: string;
|
|
180
|
+
checklist: string;
|
|
181
|
+
paragraphSpacing: string;
|
|
182
|
+
addSpaceBefore: string;
|
|
183
|
+
removeSpaceBefore: string;
|
|
184
|
+
addSpaceAfter: string;
|
|
185
|
+
removeSpaceAfter: string;
|
|
186
|
+
customSpacing: string;
|
|
187
|
+
lineSpacingCustom: string;
|
|
188
|
+
spacingBefore: string;
|
|
189
|
+
spacingAfter: string;
|
|
190
|
+
indentLeft: string;
|
|
191
|
+
indentRight: string;
|
|
192
|
+
indentSpecial: string;
|
|
193
|
+
indentNone: string;
|
|
194
|
+
indentFirstLine: string;
|
|
195
|
+
indentHanging: string;
|
|
196
|
+
indentBy: string;
|
|
197
|
+
spacingInvalid: string;
|
|
198
|
+
ruler: string;
|
|
199
|
+
tabStop: string;
|
|
200
|
+
tabStopHint: string;
|
|
201
|
+
columns: string;
|
|
202
|
+
columnsCount: (n: number) => string;
|
|
203
|
+
tableOfContents: string;
|
|
204
|
+
tocRefresh: string;
|
|
205
|
+
tocDelete: string;
|
|
206
|
+
footnote: string;
|
|
207
|
+
footnotes: string;
|
|
208
|
+
footnotePlaceholder: string;
|
|
209
|
+
footnoteLocked: string;
|
|
210
|
+
bookmark: string;
|
|
211
|
+
bookmarkPrompt: string;
|
|
212
|
+
bookmarkInvalid: string;
|
|
213
|
+
bookmarkTaken: string;
|
|
214
|
+
linkToHeading: string;
|
|
215
|
+
linkToBookmark: string;
|
|
216
|
+
noHeadings: string;
|
|
217
|
+
noBookmarks: string;
|
|
218
|
+
breakMenu: string;
|
|
219
|
+
sectionBreakNext: string;
|
|
220
|
+
sectionBreakContinuous: string;
|
|
221
|
+
removeSectionBreak: string;
|
|
222
|
+
headersFooters: string;
|
|
223
|
+
headersFootersHint: string;
|
|
224
|
+
differentFirst: string;
|
|
225
|
+
differentOddEven: string;
|
|
226
|
+
headerDefault: string;
|
|
227
|
+
headerOdd: string;
|
|
228
|
+
headerFirst: string;
|
|
229
|
+
headerEven: string;
|
|
230
|
+
pageCount: string;
|
|
231
|
+
webFonts: string;
|
|
232
|
+
wordFonts: string;
|
|
172
233
|
/** The file list's shared words: Open, Rename and the rest. */
|
|
173
234
|
files: FileWords;
|
|
174
235
|
/** The kind of file Open takes from the drive, as the drive names it. */
|
package/dist/documents/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DocumentsConflict as t,DocumentsProvider as o,DocumentsWordsProvider as n}from"../chunk-
|
|
1
|
+
import{DocumentsConflict as t,DocumentsProvider as o,DocumentsWordsProvider as n}from"../chunk-HNNYUGDU.js";import{ENGLISH_WORDS as m,ZH_HANS_WORDS as r}from"../chunk-POH6OTTR.js";import{ENGLISH_FILE_WORDS as c,ZH_HANS_FILE_WORDS as e}from"../chunk-B32ASXHM.js";import{hasExtension as i}from"../chunk-XYVQTQ6N.js";import{lazy as s}from"react";var u=s(()=>import("../Documents-2ZU5D3ZI.js")),p=s(()=>import("../Documents-2ZU5D3ZI.js").then(t=>({default:t.OpenDocument}))),a={"/documents":{component:u,label:"Documents",size:"xl",appStyle:!0,multiInstance:!0}};async function f(t,o){const{docxToPdf:n}=await(import("../docxPdf-S4RXU4L2.js"));return n(t,o)}async function D(t,o){const{importDocumentFile:n}=await(import("../importDocument-34WALCTG.js"));return n(t,o)}export{p as DocumentEditor,u as Documents,t as DocumentsConflict,o as DocumentsProvider,n as DocumentsWordsProvider,c as ENGLISH_FILE_WORDS,m as ENGLISH_WORDS,e as ZH_HANS_FILE_WORDS,r as ZH_HANS_WORDS,a as documentsApp,f as docxToPdf,i as hasExtension,D as importDocumentFile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{marginText as t,pageBlocks as e,pageStarts as o,pageStyles as n,printStyles as i}from"./chunk-EC6D54MM.js";import{boxesInWindow as r,pageWindows as s}from"./chunk-PWF37Y2N.js";import{ENGLISH_WORDS as a}from"./chunk-POH6OTTR.js";import{jpegPdf as p}from"./chunk-CEVQKZ66.js";import{drawJpeg as c,embeddedFonts as l,openStage as h,settled as d}from"./chunk-PX4QOBHF.js";import"./chunk-B32ASXHM.js";import{headerKindFor as f,readDocx as u}from"./chunk-YKQ5UKYZ.js";import"./chunk-D3JKD7KW.js";var g="pdf",m=t=>t/20*(4/3);function x(t){const e=t.getBoundingClientRect().top;return Array.from(t.children,t=>{const o=t.getBoundingClientRect();return{top:o.top-e,height:o.height}})}function w(e,o,n,i,r){const s=document.createElement("div");s.style.cssText=`position:absolute;display:flex;justify-content:space-between;font:9pt Calibri,Carlito,Arial,sans-serif;color:#555;white-space:pre;left:${m(o.left)}px;right:${m(o.right)}px;${r}`;for(const o of t(e,n,i))s.append(Object.assign(document.createElement("span"),{textContent:o}));return s}function y(t,e,o,n){const{page:i,headers:s,footers:a,titlePage:p,evenOdd:c}=t.doc,l=f(o,p,c),h=s[l],d=a[l],u=document.createElement("div");u.style.cssText=`position:relative;overflow:hidden;background:#fff;width:${m(i.width)}px;height:${m(i.height)}px`;const g=document.createElement("div");return g.style.cssText=`position:absolute;overflow:hidden;left:${m(i.left)}px;top:${m(i.top)}px;right:${m(i.right)}px;height:${e.height}px`,g.append(function({body:t,boxes:e},o){const n=t.cloneNode(!1),i=r(e,o);if(!i)return n;for(let e=i.first;e<=i.last;e+=1)n.append(t.children[e].cloneNode(!0));const s=parseFloat(getComputedStyle(t.children[i.first]).marginTop)||0;return n.style.position="absolute",n.style.left="0",n.style.top=e[i.first].top-s-o.top+"px",n}(t,e)),u.append(g),h.text&&u.append(w(h.text,i,o,n,`top:${m(i.header)}px`)),d.text&&u.append(w(d.text,i,o,n,`bottom:${m(i.footer)}px`)),u}async function b(t,e,o,n,i){e.append(t);try{await d(t);return{jpeg:await c(t,{width:m(o.width),height:m(o.height),pixelRatio:2,quality:i,fontCss:n}),width:o.width/20,height:o.height/20}}finally{t.remove()}}async function $(t,r={}){const{signal:c,onProgress:f,quality:w}=r;c?.throwIfAborted();const $=await u(new Uint8Array(await t.arrayBuffer())),C=h();try{const t=function(t,e){const o=document.createElement("style");o.textContent=`${n(t,g)}\n${i(g)}`;const r=document.createElement("div");return r.className="docs-page",r.dataset.doc=g,r.style.cssText=`display:flow-root;width:${m(t.page.width-t.page.left-t.page.right)}px`,r.innerHTML=t.html,e.append(o,r),r}($,C.root);await d(t);const r={doc:$,body:t,boxes:x(t)},h=function(t,n){const i=m(t.page.height-t.page.top-t.page.bottom),r=o(e(n,n.getBoundingClientRect().top),i);return s(r,i,n.getBoundingClientRect().height)}($,t),u=await l(t),j=[];for(const[t,e]of h.entries()){c?.throwIfAborted();const o=y(r,e,t+1,h.length);j.push(await b(o,C.root,$.page,u,w).catch(e=>{throw new Error(a.pdfPageFailed(t+1),{cause:e})})),f?.(t+1,h.length)}return p(j)}finally{C.close()}}export{$ as docxToPdf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{importDocumentFile as o}from"./chunk-O35VT6BD.js";import"./chunk-YKQ5UKYZ.js";import"./chunk-D3JKD7KW.js";import"./chunk-XYVQTQ6N.js";export{o as importDocumentFile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{importSpreadsheetFile as o}from"./chunk-HQM2HX4V.js";import"./chunk-WAB44FLE.js";import"./chunk-5K2D7PBJ.js";import"./chunk-XYVQTQ6N.js";export{o as importSpreadsheetFile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PptxPasswordError as t,PptxUnreadableError as e}from"./chunk-MDG2ADZ7.js";import{DECK_FONT as n,ENGLISH_WORDS as r,MIN_SIZE as a,NO_FILL as o,SLIDE_H as s,SLIDE_W as i,newId as l,newSlide as c}from"./chunk-PXOQN7D6.js";import"./chunk-B32ASXHM.js";import{child as p,childrenOf as f,descendants as u,openZip as d,parseXml as m,partText as h,readRels as y,readThemeFonts as g,resolveTarget as w}from"./chunk-RHW2M2UY.js";var x=2097152;function b(t){if(Array.isArray(t))return t.reduce((t,e)=>t+b(e)+2,t.length?0:2);if(t&&"object"==typeof t){const e=Object.entries(t).filter(([,t])=>void 0!==t);return e.reduce((t,[e,n])=>t+b(e)+2+b(n)+2,e.length?0:2)}const e=JSON.stringify(t)??"null";return e.length+5*(e.match(/[^\x20-\x7e]/g)?.length??0)}var v=[208,207,17,224],M=Array.from("EncryptedPackage").flatMap(t=>[t.charCodeAt(0),0]),k=4194304;function P(t){for(let e=t.indexOf(M[0]);e>=0;e=t.indexOf(M[0],e+1))if(M.every((n,r)=>t[e+r]===n))return!0;return!1}var S={black:"000000",white:"ffffff",red:"ff0000",green:"008000",blue:"0000ff",yellow:"ffff00",gray:"808080",grey:"808080"},N={bg1:"lt1",tx1:"dk1",bg2:"lt2",tx2:"dk2"};function C(t){const e=t.children[0];return e?.attrs.lastClr??e?.attrs.val}function A(t,e){const n=new Map,r=p(p(t,"a:themeElements"),"a:clrScheme")?.children??[];for(const t of r){const e=C(t);e&&n.set(t.name.replace(/^a:/,""),e)}return{scheme:n,map:{...N,...e?.attrs}}}function B(t,e){const n=p(p(e,"p:clrMapOvr"),"a:overrideClrMapping");return n?{...t,map:{...t.map,...n.attrs}}:t}var I=t=>[0,2,4].map(e=>parseInt(t.slice(e,e+2),16)),F=t=>t.map(t=>{return(e=t,Math.max(0,Math.min(255,Math.round(e)))).toString(16).padStart(2,"0");var e}).join("");function T(t,e,n){const[r,a,o]=function([t,e,n]){const[r,a,o]=[t/255,e/255,n/255],s=Math.max(r,a,o),i=Math.min(r,a,o),l=(s+i)/2;if(s===i)return[0,0,l];const c=s-i;return[(s===r?(a-o)/c+(a<o?6:0):s===a?(o-r)/c+2:(r-a)/c+4)/6,l>.5?c/(2-s-i):c/(s+i),l]}(I(t));return F(function([t,e,n]){if(0===e)return[255*n,255*n,255*n];const r=n<.5?n*(1+e):n+e-n*e,a=2*n-r,o=t=>{const e=(t+1)%1;return e<1/6?a+6*(r-a)*e:e<.5?r:e<2/3?a+(r-a)*(2/3-e)*6:a};return[o(t+1/3),o(t),o(t-1/3)].map(t=>255*t)}([r,a,Math.max(0,Math.min(1,o*e+n))]))}function $(t,e){const n=Number(e.attrs.val)/1e5;if(!Number.isFinite(n))return t;switch(e.name){case"a:lumMod":return T(t,n,0);case"a:lumOff":return T(t,1,n);case"a:tint":return F(I(t).map(t=>t+(255-t)*(1-n)));case"a:shade":return F(I(t).map(t=>t*n));default:return t}}function j(t,e){const n=e.scheme.get(e.map[t]??t);return n?`#${n.toLowerCase()}`:void 0}function z(t,e){const n=t&&function(t,e){switch(t.name){case"a:srgbClr":return t.attrs.val;case"a:sysClr":return t.attrs.lastClr;case"a:prstClr":return S[t.attrs.val];case"a:schemeClr":return e.scheme.get(e.map[t.attrs.val]??t.attrs.val);default:return}}(t,e);if(t&&n&&/^[0-9a-f]{6}$/i.test(n)&&"0"!==p(t,"a:alpha")?.attrs.val)return`#${t.children.reduce($,n).toLowerCase()}`}function O(t,e){return z(p(t,"a:solidFill")?.children[0],e)}var R=t=>"1"===t||"true"===t,D=t=>Math.round(100*t)/100+0,H=(t,e)=>D(12700*t*e.scale),L=t=>t*Math.PI/180;function E(t){const e=p(t,"a:off")?.attrs,n=p(t,"a:ext")?.attrs;if(t&&e&&n)return{x:Number(e.x)||0,y:Number(e.y)||0,w:Number(n.cx)||0,h:Number(n.cy)||0,rotation:(Number(t.attrs.rot)||0)/6e4}}function V(t){const e=p(p(t,"p:grpSpPr"),"a:xfrm"),n=E(e),r=p(e,"a:chOff")?.attrs,a=p(e,"a:chExt")?.attrs;if(n&&r&&a)return{box:n,childX:Number(r.x)||0,childY:Number(r.y)||0,scaleX:Number(a.cx)?n.w/Number(a.cx):1,scaleY:Number(a.cy)?n.h/Number(a.cy):1,flipH:R(e?.attrs.flipH),flipV:R(e?.attrs.flipV)}}function X(t,e){const{box:n}=e,r=n.x+n.w/2,a=n.y+n.h/2;let o=n.x+(t.x-e.childX)*e.scaleX,s=n.y+(t.y-e.childY)*e.scaleY;e.flipH&&(o=2*r-o),e.flipV&&(s=2*a-s);const i=L(n.rotation),l=o-r,c=s-a;return{x:r+l*Math.cos(i)-c*Math.sin(i),y:a+l*Math.sin(i)+c*Math.cos(i)}}function W(t,e){const n=X({x:t.x+t.w/2,y:t.y+t.h/2},e),r=t.w*e.scaleX,a=t.h*e.scaleY,o=e.flipH!==e.flipV;return{x:n.x-r/2,y:n.y-a/2,w:r,h:a,rotation:(o?-t.rotation:t.rotation)+e.box.rotation}}var Y=t=>D((t%360+360)%360);function G(t,e,n){const r=e.reduce(W,t);return{id:l(),x:D(n.left+r.x*n.scale),y:D(n.top+r.y*n.scale),w:D(r.w*n.scale),h:D(r.h*n.scale),rotation:Y(r.rotation)}}function U(t,e,n,r){const o=t.x+t.w/2,s=t.y+t.h/2,i=L(t.rotation),c=a=>{const l=a*(e.flipH?-1:1)*t.w/2,c=a*(e.flipV?-1:1)*t.h/2,p={x:o+l*Math.cos(i)-c*Math.sin(i),y:s+l*Math.sin(i)+c*Math.cos(i)},f=n.reduce(X,p);return{x:r.left+f.x*r.scale,y:r.top+f.y*r.scale}},p=c(-1),f=c(1),u=Math.hypot(f.x-p.x,f.y-p.y);return{id:l(),x:D((p.x+f.x-u)/2),y:D((p.y+f.y-a)/2),w:D(u),h:a,rotation:Y(180*Math.atan2(f.y-p.y,f.x-p.x)/Math.PI)}}var q={scheme:new Map,map:{}},Q=(t,e)=>[...t.rels.values()].find(t=>t.type.endsWith(e)),J=t=>p(p(t,"p:cSld"),"p:spTree");function Z(t,e){const n=h(t,e);if(n)return{part:e,root:m(n),rels:new Map(y(t,e).map(t=>[t.id,t]))}}function _(t,e,n){const r=Z(t,e);if(!r)return;const a=Q(r,"/slideMaster"),o=a&&w(e,a.target);return o&&!n.has(o)&&n.set(o,function(t,e){const n=Z(t,e);if(!n)return;const r=Q(n,"/theme"),a=r?h(t,w(e,r.target)):void 0;return{...n,palette:A(a?m(a):void 0,p(n.root,"p:clrMap")),fonts:g(a)}}(t,o)),{...r,master:o?n.get(o):void 0}}var K={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp"};var tt=t=>p(p(p(t,"p:nvSpPr"),"p:nvPr"),"p:ph")??p(p(p(t,"p:nvPicPr"),"p:nvPr"),"p:ph"),et=t=>!!tt(t),nt=t=>(J(t.root)?.children??[]).filter(t=>"p:sp"===t.name&&tt(t)),rt=new Set(["title","ctrTitle"]),at=new Set(["dt","ftr","sldNum"]);function ot(t){return t&&rt.has(t)?"title":t&&at.has(t)?t:"body"}function st(t,e){const n=tt(t);if(!n)return{shapes:[],style:"p:otherStyle",isPlaceholder:!1};const r=e.layout&&function(t,e){const n=nt(t),{idx:r,type:a}=e.attrs;return(void 0!==r?n.find(t=>tt(t)?.attrs.idx===r):void 0)??(void 0!==a?n.find(t=>tt(t)?.attrs.type===a):void 0)}(e.layout,n),a=r?tt(r)??n:n,o=e.master&&function(t,e){const n=ot(e.attrs.type);return nt(t).find(t=>ot(tt(t)?.attrs.type)===n)}(e.master,a),s=ot(a.attrs.type);return{shapes:[r,o].filter(t=>!!t),style:"title"===s?"p:titleStyle":"body"===s?"p:bodyStyle":"p:otherStyle",isPlaceholder:!0}}function it(t,e,n,r){const a=t=>p(p(t,"p:txBody"),"a:lstStyle"),o=p(p(n.master?.root,"p:txStyles"),e.style),s=e.isPlaceholder?[o,r]:[r,o];return[a(t),...e.shapes.map(a),...s]}function lt(t,e,n){for(const r of[t,...e.shapes]){const t=p(p(r,"p:txBody"),"a:bodyPr")?.attrs[n];if(void 0!==t)return t}}var ct={l:"left",ctr:"center",r:"right"},pt=(t,e)=>t.lists.flatMap(t=>{const n=p(t,`a:lvl${e+1}pPr`);return n?[n]:[]});function ft(t,e){return"+mj-lt"===t?e.fonts.major:"+mn-lt"===t?e.fonts.minor:t}function ut(t,e,n,r){const a=[t,p(e,"a:defRPr"),...n.map(t=>p(t,"a:defRPr"))].filter(t=>!!t),o=t=>a.find(e=>void 0!==e.attrs[t])?.attrs[t],s=Number(o("sz")),i=o("b"),l=a.map(t=>O(t,r.palette)),c=a.map(t=>p(t,"a:latin")?.attrs.typeface).find(Boolean);return{sizePt:Number.isFinite(s)&&s>0?s/100:18,bold:"1"===i||"true"===i,colour:l.find(Boolean)??r.styleColour??j("tx1",r.palette)??"#000000",typeface:ft(c,r)??(r.isTitle?r.fonts.major:r.fonts.minor)}}function dt(t,e){for(const n of[t,...e]){if(p(n,"a:buNone"))return{kind:"none"};if(p(n,"a:buChar")||p(n,"a:buBlip"))return{kind:"bullet"};const t=p(n,"a:buAutoNum");if(t)return{kind:"number",startAt:Number(t.attrs.startAt)||1}}return{kind:"none"}}function mt(t,e){const n=[t,...e].map(t=>t?.attrs.algn).find(Boolean);return n&&ct[n]||"left"}function ht(t,e,n){const r=p(t,"a:pPr"),a=[];let o="";for(const s of t.children){if("a:br"===s.name&&(o+="\n"),"a:r"!==s.name&&"a:fld"!==s.name)continue;const t=p(s,"a:t")?.text??"";o+=t,t.trim()&&a.push({text:t,style:ut(p(s,"a:rPr"),r,e,n)})}return{text:o,runs:a}}var yt=(t,e)=>t.sizePt===e.sizePt&&t.bold===e.bold&&t.colour===e.colour;function gt(t,e){const n=[],r=[],a=function(){const t=[];return(e,n)=>"bullet"===e.kind?"• ":"none"===e.kind?(t.length=Math.min(t.length,n),""):(t.length=Math.min(t.length,n+1),t[n]=(t[n]??e.startAt-1)+1,`${t[n]}. `)}();let o;for(const s of f(t,"a:p")){const t=p(s,"a:pPr"),i=Number(t?.attrs.lvl)||0,l=pt(e,i),c=ht(s,l,e),f=dt(t,l),u=c.text.trim()?a(f,i):"";n.push(u?`${" ".repeat(i)}${u}${c.text}`:c.text),c.runs.length&&!o&&(o=mt(t,l)),r.push(...c.runs)}if(!r[0])return null;const s=function(t){const e=[];for(const n of t){const t=e.find(t=>yt(t.style,n.style));t?t.length+=n.text.length:e.push({style:n.style,length:n.text.length})}return e.reduce((t,e)=>e.length>t.length?e:t).style}(r),i=Number(p(p(t,"a:bodyPr"),"a:normAutofit")?.attrs.fontScale);return{text:n.join("\n").trimEnd(),sizePt:s.sizePt*(i>0?i/1e5:1),bold:s.bold,colour:s.colour,align:o??"left",mixed:r.some(t=>!yt(t.style,s)),typefaces:new Set(r.flatMap(t=>t.style.typeface?[t.style.typeface]:[]))}}function wt(t,e){const n=t.map(t=>t.map(e));return n.some(t=>t.some(Boolean))?n:void 0}var xt=t=>t.reduce((t,e)=>t+e,0);function bt(t,e,n,r){const a=E(p(t,"p:xfrm")),s=f(e,"a:tr");if(!a||!s.length)return void(n.tally.skipped+=1);const i=f(p(e,"a:tblGrid"),"a:gridCol").map(t=>Number(t.attrs.w)||0),l=s.map(t=>Number(t.attrs.h)||0),c=s.map(t=>f(t,"a:tc").map(t=>function(t,e){const n=p(t,"a:txBody"),r=gt(n,{palette:e.palette,fonts:e.master?.fonts??{},lists:[p(n,"a:lstStyle"),e.presentation.defaultTextStyle],isTitle:!1});for(const t of r?.typefaces??[])e.tally.typefaces.add(t);return{text:r?.text.replace(/\s*\n\s*/g," ")??"",block:r,fill:O(p(t,"a:tcPr"),e.palette)??null}}(t,n))),u=G({...a,w:xt(i)||a.w,h:xt(l)||a.h},r,n.frame),d=function(t){const e=new Map;for(const{block:n}of t)n&&e.set(n.sizePt,(e.get(n.sizePt)??0)+1);return[...e].sort((t,e)=>e[1]-t[1])[0]?.[0]}(c.flat()),m={...u,type:"table",rows:c.map(t=>t.map(t=>t.text)),headerFill:c[0].map(t=>t.fill).find(Boolean)??o,headerColor:c[0].map(t=>t.block?.colour).find(Boolean),fontSize:void 0===d?void 0:H(d,n.frame),columnWidths:xt(i)?i.map(t=>{return e=t,n=xt(i),Math.round(e/n*1e4)/1e4;var e,n}):void 0,rowHeights:xt(l)?l.map(t=>Math.round(t/xt(l)*u.h*100)/100):void 0,cellFills:wt(c,t=>t.fill),cellColors:wt(c,t=>t.block?.colour??null)};n.elements.push(m)}var vt={rect:"rect",ellipse:"ellipse",roundRect:"roundRect",diamond:"diamond",line:"line",straightConnector1:"line",flowChartProcess:"rect",flowChartAlternateProcess:"roundRect",flowChartDecision:"diamond",flowChartConnector:"ellipse"},Mt=new Set(["a:videoFile","a:audioFile","a:quickTimeFile","p14:media"]);function kt(t,e,n,r){const a=gt(p(t,"p:txBody"),function(t,e,n){const r=p(p(t,"p:style"),"a:fontRef")?.children[0];return{palette:n.palette,fonts:n.master?.fonts??{},lists:it(t,e,n,n.presentation.defaultTextStyle),isTitle:"p:titleStyle"===e.style,styleColour:z(r,n.palette)}}(t,n,r));if(!a)return;const{scale:o}=r.frame,s=(e,r)=>(Number(lt(t,n,e)??r)||0)*o,i=H(a.sizePt,r.frame),c=s("lIns",91440),f=s("tIns",45720),u=Math.max(e.w-c-s("rIns",91440),1),d=Math.max(e.h-f-s("bIns",45720),1),m=lt(t,n,"anchor"),h=Math.max(d-function(t,e,n){const r=Math.max(1,Math.floor(n/(.52*e)));return t.split("\n").reduce((t,e)=>t+Math.max(1,Math.ceil(e.length/r)),0)*e*1.25}(a.text,i,u),0),y="ctr"===m?h/2:"b"===m?h:0;r.elements.push({id:l(),type:"text",rotation:e.rotation,x:D(e.x+c),y:D(e.y+f+y),w:D(u),h:D(d-y),text:a.text,fontSize:i,bold:a.bold,color:a.colour,align:a.align});for(const t of a.typefaces)r.tally.typefaces.add(t);a.mixed&&(r.tally.mixedTextSimplified+=1)}function Pt(t,e){const n=p(t,"p:spPr");if(p(n,"a:noFill"))return{kind:"none"};if(p(n,"a:solidFill")){const t=O(n,e.palette);return t?{kind:"colour",colour:t}:{kind:"none"}}if(["a:gradFill","a:blipFill","a:pattFill","a:grpFill"].some(t=>p(n,t))){const t=function(t,e){const n=p(p(p(t,"a:gradFill"),"a:gsLst"),"a:gs")?.children[0],r=p(p(t,"a:pattFill"),"a:fgClr")?.children[0];return z(n??r,e.palette)}(n,e);return t?{kind:"colour",colour:t}:{kind:"undrawable"}}const r=p(p(t,"p:style"),"a:fillRef"),a=r&&"0"!==r.attrs.idx?z(r.children[0],e.palette):void 0;return a?{kind:"colour",colour:a}:{kind:"none"}}function St(t,e){const n=p(p(t,"p:spPr"),"a:ln");if(p(n,"a:noFill"))return;const r=p(p(t,"p:style"),"a:lnRef"),a=O(n,e.palette)??(r&&"0"!==r.attrs.idx?z(r.children[0],e.palette):void 0);return a?{stroke:a,strokeWidth:D((Number(n?.attrs.w)||9525)*e.frame.scale)}:void 0}function Nt(t,e){const n=p(p(p(t,"a:prstGeom"),"a:avLst"),"a:gd")?.attrs.fmla,r=Number(n?.replace("val ",""));return D((Number.isFinite(r)?r:16667)/1e5*Math.min(e.w,e.h))}var Ct=t=>!!t?.attrs.type&&"none"!==t.attrs.type;function At(t,e,n){const r=p(t,"p:spPr"),a=p(r,"a:xfrm"),s=E(a);if(!s)return void(e.tally.skipped+=1);const i=St(t,e);if(!i)return;const l=p(r,"a:ln");e.elements.push({...U(s,{flipH:R(a?.attrs.flipH),flipV:R(a?.attrs.flipV)},n,e.frame),type:"shape",shape:"line",fill:o,...i,...Ct(p(l,"a:tailEnd"))?{arrowEnd:!0}:{},...Ct(p(l,"a:headEnd"))?{arrowStart:!0}:{}})}function Bt(t,e,n){const r=st(t,e),a=p(t,"p:spPr"),s=function(t){return vt[p(t,"a:prstGeom")?.attrs.prst??"rect"]??"rect"}(a);if("line"===s)return void At(t,e,n);const i=E(p(a,"a:xfrm"))??r.shapes.map(t=>E(p(p(t,"p:spPr"),"a:xfrm"))).find(Boolean);if(!i)return void(p(t,"p:txBody")&&u(t,new Set(["a:t"])).length&&(e.tally.skipped+=1));const l=G(i,n,e.frame),c=Pt(t,e),f=St(t,e),d="colour"===c.kind||!!f;d&&function(t,e,n,r,a,s){s.elements.push({...t,type:"shape",shape:e,fill:"colour"===n.kind?n.colour:o,...r,..."roundRect"===e?{radius:Nt(a,t)}:{}})}(l,s,c,f,a,e),kt(t,l,r,e),"undrawable"!==c.kind||d||(e.tally.skipped+=1)}function It(t,e){const n=e.rels.get(t?.attrs["r:embed"]??"");return n&&!n.external?w(e.part,n.target):void 0}function Ft(t,e,n){const r=p(t,"p:nvPicPr"),a=st(t,e),o=E(p(p(t,"p:spPr"),"a:xfrm"))??a.shapes.map(t=>E(p(p(t,"p:spPr"),"a:xfrm"))).find(Boolean),s=p(t,"p:blipFill"),i=It(p(s,"a:blip"),e.slide),l=i&&!u(t,Mt).length?e.useImage(i,function(t){const e=e=>(Number(t?.attrs[e])||0)/1e5,n={left:e("l"),top:e("t"),right:e("r"),bottom:e("b")},r=Object.values(n);if(!r.every(t=>0===t)&&!r.some(t=>t<0))return n.left+n.right<1&&n.top+n.bottom<1?n:void 0}(p(s,"a:srcRect"))):void 0;o&&l?e.elements.push({...G(o,n,e.frame),type:"image",src:l,alt:p(r,"p:cNvPr")?.attrs.descr??""}):e.tally.skipped+=1}function Tt(t,e,n){const r=p(p(p(t,"a:graphic"),"a:graphicData"),"a:tbl");r?bt(t,r,e,n):e.tally.skipped+=1}function $t(t,e,n=[]){for(const r of t)switch(r.name){case"p:sp":Bt(r,e,n);break;case"p:pic":Ft(r,e,n);break;case"p:graphicFrame":Tt(r,e,n);break;case"p:cxnSp":At(r,e,n);break;case"p:contentPart":e.tally.skipped+=1;break;case"p:grpSp":{const t=V(r);$t(r.children,e,t?[t,...n]:n);break}case"mc:AlternateContent":$t(p(r,"mc:Fallback")?.children??[],e,n)}}function jt(t){const e=function(t){const e=h(t,"[Content_Types].xml"),n=e?m(e):void 0,r=new Map(f(n,"Override").map(t=>[t.attrs.PartName,t.attrs.ContentType])),a=new Map(f(n,"Default").map(t=>[t.attrs.Extension?.toLowerCase(),t.attrs.ContentType]));return t=>{const e=t.slice(t.lastIndexOf(".")+1).toLowerCase();return r.get(`/${t}`)??a.get(e)??K[e]??"application/octet-stream"}}(t),n=new Map;return{use:(t,r)=>{const a=e(t);if(!a.startsWith("image/"))return;const o=`${t}${function(t){return t?`#${t.left},${t.top},${t.right},${t.bottom}`:""}(r)}`;return n.has(o)||n.set(o,{key:o,part:t,contentType:a,crop:r}),o},uses:n}}function zt(t){return t.children.map(t=>"a:br"===t.name?"\n":"a:r"===t.name||"a:fld"===t.name?p(t,"a:t")?.text??"":"").join("")}function Ot(t,e){const n=Q(e,"/notesSlide"),r=n&&Z(t,w(e.part,n.target)),a=((r&&J(r.root)?.children)??[]).find(t=>"body"===p(p(p(t,"p:nvSpPr"),"p:nvPr"),"p:ph")?.attrs.type);return f(p(a,"p:txBody"),"a:p").map(zt).join("\n").trim()}function Rt(t,e){const n=p(p(t.root,"p:cSld"),"p:bg");if(!n)return;const r=p(n,"p:bgPr"),a=O(r,e.palette)??z(p(n,"p:bgRef")?.children[0],e.palette);if(a)return{colour:a};const o=It(p(p(r,"a:blipFill"),"a:blip"),t);return o?{picture:o}:void 0}var Dt=t=>"0"===t.root.attrs.showMasterSp||"false"===t.root.attrs.showMasterSp;function Ht(t,e){const n=function(t){for(const e of[t.slide,t.layout,t.master]){const n=e&&Rt(e,t);if(n)return n}return{}}(t);return n.picture&&function(t,e){const n=e.useImage(t,void 0);if(!n)return void(e.tally.skipped+=1);const{left:r,top:a,width:o,height:s}=e.frame;e.elements.push({id:l(),type:"image",x:r,y:a,w:o,h:s,rotation:0,src:n,alt:""})}(n.picture,t),function(t){const{layout:e,master:n,slide:r}=t;if(!Dt(r))for(const r of[e&&Dt(e)?void 0:n,e]){const e=r?J(r.root)?.children??[]:[];r&&$t(e.filter(t=>!et(t)),{...t,slide:r})}}(t),$t(J(t.slide.root)?.children??[],t),{id:l(),background:n.colour??"#ffffff",notes:Ot(e,t.slide),elements:(r=t.elements,a=t.tally,a.skipped+=Math.max(r.length-200,0),r.slice(0,200))};var r,a}var Lt=t=>"0"===t.root.attrs.show||"false"===t.root.attrs.show;function Et(t){const n=function(t){const n=y(t,"").find(t=>t.type.endsWith("/officeDocument")),r=Z(t,n?w("",n.target):"ppt/presentation.xml");if(!r||"p:presentation"!==r.root.name)throw new e;const a=f(p(r.root,"p:sldIdLst"),"p:sldId").flatMap(t=>{const e=r.rels.get(t.attrs["r:id"]);return e?[w(r.part,e.target)]:[]}),o=p(r.root,"p:sldSz")?.attrs;return{width:Number(o?.cx)||9144e3,height:Number(o?.cy)||5143500,slides:a,defaultTextStyle:p(r.root,"p:defaultTextStyle")}}(t),r=function(t){const e=new Map,n=new Map;return r=>{const a=Q(r,"/slideLayout"),o=a&&w(r.part,a.target);o&&!n.has(o)&&n.set(o,_(t,o,e));const s=o?n.get(o):void 0,i=s?.master,l=i?.palette??q;return{slide:r,layout:s,master:i,palette:B(s?B(l,s.root):l,r.root)}}}(t),a=jt(t),o=function(t,e){const n=Math.min(i/t,s/e);return{scale:n,left:(i-t*n)/2,top:(s-e*n)/2,width:t*n,height:e*n}}(n.width,n.height),l={skipped:0,mixedTextSimplified:0,typefaces:new Set},u=[];let d=0;for(const e of n.slides){const s=Z(t,e);s&&!Lt(s)&&(p(s.root,"p:timing")&&(d+=1),u.push(Ht({...r(s),presentation:n,frame:o,tally:l,elements:[],useImage:a.use},t)))}const m=new Set(u.flatMap(t=>t.elements.flatMap(t=>"image"===t.type?[t.src]:[])));return{document:{slides:u.length?u:[c()]},slideCount:u.length,images:[...a.uses.values()].filter(t=>m.has(t.key)),animationsDropped:d,tally:l}}var Vt=.15,Xt=1048576,Wt=/\.(xml|rels)$/i;async function Yt(n,a){if(await async function(t){const e=new Uint8Array(await t.slice(0,v.length).arrayBuffer());return v.every((t,n)=>e[n]===t)}(n))throw await async function(t,e){for(let n=0;n<t.size;n+=k-M.length)if(e?.throwIfAborted(),P(new Uint8Array(await t.slice(n,n+k).arrayBuffer())))return!0;return!1}(n,a)?new t:new e(r.pptxLegacyFormat)}function Gt(t){if(t.slides.length>300)throw new e(r.pptxTooManySlides(t.slides.length,300));const n=b(t);if(n>x)throw new e(r.pptxTooLarge((n/Xt).toFixed(1),2))}var Ut={"image/webp":"webp","image/png":"png","image/jpeg":"jpg","image/gif":"gif"};async function qt(t,e,n){try{return await(n.prepareImage?n.prepareImage(e,t.contentType):async function(t,e,n){const r=await createImageBitmap(new Blob([t],{type:e}));try{const t=r.width*(n?.left??0),e=r.height*(n?.top??0),a=r.width-t-r.width*(n?.right??0),o=r.height-e-r.height*(n?.bottom??0),s=Math.min(1,1920/Math.max(a,o)),i=new OffscreenCanvas(Math.max(1,Math.round(a*s)),Math.max(1,Math.round(o*s))),l=i.getContext("2d");if(!l)throw new Error("No drawing context");return l.imageSmoothingQuality="high",l.drawImage(r,t,e,a,o,0,0,i.width,i.height),await i.convertToBlob({type:"image/webp",quality:.85})}finally{r.close()}}(e,t.contentType,t.crop))}catch(e){return n.signal?.throwIfAborted(),console.warn("A picture in the deck could not be read",t.part,e),null}}async function Qt(t,e,n){const r={addresses:new Map,count:0,bytesBefore:0,bytesAfter:0},a=function(t,e){const n=new Map;for(const r of t){const t=e.prepareImage?r.part:r.key;n.set(t,[...n.get(t)??[],r])}return[...n.values()]}(t,n),o=new Map;let s=0;return await async function(t,e,n){let r=0,a=!1;await Promise.all(Array.from({length:Math.min(e,t.length)},async()=>{for(;!a&&r<t.length;){const e=t[r];r+=1;try{await n(e)}catch(t){throw a=!0,t}}}))}(a,4,async t=>{n.signal?.throwIfAborted();const[i]=t,l=o.get(i.part)??0;o.set(i.part,l+1);const c=await e.read(i.part).catch(()=>null),p=c&&await qt(i,c,n);if(c&&p){n.signal?.throwIfAborted();const e=await n.storeImage(p,function(t,e,n){return`${t.slice(t.lastIndexOf("/")+1).replace(/\.[^.]*$/,"")}${n?`-${n}`:""}.${Ut[e.type]??"img"}`}(i.part,p,l));for(const{key:n}of t)r.addresses.set(n,e);r.count+=1,r.bytesBefore+=c.length,r.bytesAfter+=p.size}s+=1,n.onProgress?.(Vt+.85*s/a.length)}),r}async function Jt(t,r){r.signal?.throwIfAborted(),await Yt(t,r.signal);const a=await async function(t){try{return await d(t)}catch{throw new e}}(t),o=await async function(t,e){const n=new Map,r=t.names.filter(t=>Wt.test(t));for(const[a,o]of r.entries())e.signal?.throwIfAborted(),n.set(o,await t.read(o)),e.onProgress?.(Vt*(a+1)/r.length);return n}(a,r).catch(t=>{throw r.signal?.throwIfAborted(),t instanceof e?t:new e}),s=function(t){try{return Et(t)}catch(t){if(t instanceof e)throw t;throw new e}}(o);Gt(s.document);const i=await Qt(s.images,a,r),l=function(t,e,n){const r=t=>{if("image"!==t.type)return[t];const r=e.get(t.src);return void 0===r&&(n.skipped+=1),void 0===r?[]:[{...t,src:r}]};return{slides:t.slides.map(t=>({...t,elements:t.elements.flatMap(r)}))}}(s.document,i.addresses,s.tally);return Gt(l),r.onProgress?.(1),{document:l,notes:{slides:s.slideCount,images:i.count,imageBytesBefore:i.bytesBefore,imageBytesAfter:i.bytesAfter,fontsReplaced:[...s.tally.typefaces].filter(t=>t!==n).sort(),animationsDropped:s.animationsDropped,mixedTextSimplified:s.tally.mixedTextSimplified,skipped:s.tally.skipped}}}export{Jt as importPptx};
|
|
1
|
+
import{PptxPasswordError as t,PptxUnreadableError as e}from"./chunk-R2CXMNZL.js";import{DECK_FONT as n,ENGLISH_WORDS as r,MIN_SIZE as a,NO_FILL as o,SLIDE_H as s,SLIDE_W as i,newId as l,newSlide as c}from"./chunk-AJTH75FI.js";import"./chunk-B32ASXHM.js";import{child as p,childrenOf as f,descendants as u,openZip as d,parseXml as m,partText as h,readRels as y,readThemeFonts as g,resolveTarget as w}from"./chunk-D3JKD7KW.js";var x=2097152;function b(t){if(Array.isArray(t))return t.reduce((t,e)=>t+b(e)+2,t.length?0:2);if(t&&"object"==typeof t){const e=Object.entries(t).filter(([,t])=>void 0!==t);return e.reduce((t,[e,n])=>t+b(e)+2+b(n)+2,e.length?0:2)}const e=JSON.stringify(t)??"null";return e.length+5*(e.match(/[^\x20-\x7e]/g)?.length??0)}var v=[208,207,17,224],M=Array.from("EncryptedPackage").flatMap(t=>[t.charCodeAt(0),0]),k=4194304;function P(t){for(let e=t.indexOf(M[0]);e>=0;e=t.indexOf(M[0],e+1))if(M.every((n,r)=>t[e+r]===n))return!0;return!1}var S={black:"000000",white:"ffffff",red:"ff0000",green:"008000",blue:"0000ff",yellow:"ffff00",gray:"808080",grey:"808080"},N={bg1:"lt1",tx1:"dk1",bg2:"lt2",tx2:"dk2"};function C(t){const e=t.children[0];return e?.attrs.lastClr??e?.attrs.val}function A(t,e){const n=new Map,r=p(p(t,"a:themeElements"),"a:clrScheme")?.children??[];for(const t of r){const e=C(t);e&&n.set(t.name.replace(/^a:/,""),e)}return{scheme:n,map:{...N,...e?.attrs}}}function I(t,e){const n=p(p(e,"p:clrMapOvr"),"a:overrideClrMapping");return n?{...t,map:{...t.map,...n.attrs}}:t}var B=t=>[0,2,4].map(e=>parseInt(t.slice(e,e+2),16)),F=t=>t.map(t=>{return(e=t,Math.max(0,Math.min(255,Math.round(e)))).toString(16).padStart(2,"0");var e}).join("");function T(t,e,n){const[r,a,o]=function([t,e,n]){const[r,a,o]=[t/255,e/255,n/255],s=Math.max(r,a,o),i=Math.min(r,a,o),l=(s+i)/2;if(s===i)return[0,0,l];const c=s-i;return[(s===r?(a-o)/c+(a<o?6:0):s===a?(o-r)/c+2:(r-a)/c+4)/6,l>.5?c/(2-s-i):c/(s+i),l]}(B(t));return F(function([t,e,n]){if(0===e)return[255*n,255*n,255*n];const r=n<.5?n*(1+e):n+e-n*e,a=2*n-r,o=t=>{const e=(t+1)%1;return e<1/6?a+6*(r-a)*e:e<.5?r:e<2/3?a+(r-a)*(2/3-e)*6:a};return[o(t+1/3),o(t),o(t-1/3)].map(t=>255*t)}([r,a,Math.max(0,Math.min(1,o*e+n))]))}function $(t,e){const n=Number(e.attrs.val)/1e5;if(!Number.isFinite(n))return t;switch(e.name){case"a:lumMod":return T(t,n,0);case"a:lumOff":return T(t,1,n);case"a:tint":return F(B(t).map(t=>t+(255-t)*(1-n)));case"a:shade":return F(B(t).map(t=>t*n));default:return t}}function j(t,e){const n=e.scheme.get(e.map[t]??t);return n?`#${n.toLowerCase()}`:void 0}function z(t,e){const n=t&&function(t,e){switch(t.name){case"a:srgbClr":return t.attrs.val;case"a:sysClr":return t.attrs.lastClr;case"a:prstClr":return S[t.attrs.val];case"a:schemeClr":return e.scheme.get(e.map[t.attrs.val]??t.attrs.val);default:return}}(t,e);if(t&&n&&/^[0-9a-f]{6}$/i.test(n)&&"0"!==p(t,"a:alpha")?.attrs.val)return`#${t.children.reduce($,n).toLowerCase()}`}function R(t,e){return z(p(t,"a:solidFill")?.children[0],e)}var O=t=>"1"===t||"true"===t,L=t=>Math.round(100*t)/100+0,H=(t,e)=>L(12700*t*e.scale),D=t=>t*Math.PI/180;function E(t){const e=p(t,"a:off")?.attrs,n=p(t,"a:ext")?.attrs;if(t&&e&&n)return{x:Number(e.x)||0,y:Number(e.y)||0,w:Number(n.cx)||0,h:Number(n.cy)||0,rotation:(Number(t.attrs.rot)||0)/6e4}}function V(t){const e=p(p(t,"p:grpSpPr"),"a:xfrm"),n=E(e),r=p(e,"a:chOff")?.attrs,a=p(e,"a:chExt")?.attrs;if(n&&r&&a)return{box:n,childX:Number(r.x)||0,childY:Number(r.y)||0,scaleX:Number(a.cx)?n.w/Number(a.cx):1,scaleY:Number(a.cy)?n.h/Number(a.cy):1,flipH:O(e?.attrs.flipH),flipV:O(e?.attrs.flipV)}}function X(t,e){const{box:n}=e,r=n.x+n.w/2,a=n.y+n.h/2;let o=n.x+(t.x-e.childX)*e.scaleX,s=n.y+(t.y-e.childY)*e.scaleY;e.flipH&&(o=2*r-o),e.flipV&&(s=2*a-s);const i=D(n.rotation),l=o-r,c=s-a;return{x:r+l*Math.cos(i)-c*Math.sin(i),y:a+l*Math.sin(i)+c*Math.cos(i)}}function W(t,e){const n=X({x:t.x+t.w/2,y:t.y+t.h/2},e),r=t.w*e.scaleX,a=t.h*e.scaleY,o=e.flipH!==e.flipV;return{x:n.x-r/2,y:n.y-a/2,w:r,h:a,rotation:(o?-t.rotation:t.rotation)+e.box.rotation}}var Y=t=>L((t%360+360)%360);function G(t,e,n){const r=e.reduce(W,t);return{id:l(),x:L(n.left+r.x*n.scale),y:L(n.top+r.y*n.scale),w:L(r.w*n.scale),h:L(r.h*n.scale),rotation:Y(r.rotation)}}function J(t,e,n,r){const o=t.x+t.w/2,s=t.y+t.h/2,i=D(t.rotation),c=a=>{const l=a*(e.flipH?-1:1)*t.w/2,c=a*(e.flipV?-1:1)*t.h/2,p={x:o+l*Math.cos(i)-c*Math.sin(i),y:s+l*Math.sin(i)+c*Math.cos(i)},f=n.reduce(X,p);return{x:r.left+f.x*r.scale,y:r.top+f.y*r.scale}},p=c(-1),f=c(1),u=Math.hypot(f.x-p.x,f.y-p.y);return{id:l(),x:L((p.x+f.x-u)/2),y:L((p.y+f.y-a)/2),w:L(u),h:a,rotation:Y(180*Math.atan2(f.y-p.y,f.x-p.x)/Math.PI)}}var q={scheme:new Map,map:{}},K=(t,e)=>[...t.rels.values()].find(t=>t.type.endsWith(e)),U=t=>p(p(t,"p:cSld"),"p:spTree");function Q(t,e){const n=h(t,e);if(n)return{part:e,root:m(n),rels:new Map(y(t,e).map(t=>[t.id,t]))}}function Z(t,e,n){const r=Q(t,e);if(!r)return;const a=K(r,"/slideMaster"),o=a&&w(e,a.target);return o&&!n.has(o)&&n.set(o,function(t,e){const n=Q(t,e);if(!n)return;const r=K(n,"/theme"),a=r?h(t,w(e,r.target)):void 0;return{...n,palette:A(a?m(a):void 0,p(n.root,"p:clrMap")),fonts:g(a)}}(t,o)),{...r,master:o?n.get(o):void 0}}var _={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp"};var tt=t=>p(p(p(t,"p:nvSpPr"),"p:nvPr"),"p:ph")??p(p(p(t,"p:nvPicPr"),"p:nvPr"),"p:ph"),et=t=>!!tt(t),nt=t=>(U(t.root)?.children??[]).filter(t=>"p:sp"===t.name&&tt(t)),rt=new Set(["title","ctrTitle"]),at=new Set(["dt","ftr","sldNum"]);function ot(t){return t&&rt.has(t)?"title":t&&at.has(t)?t:"body"}function st(t,e){const n=tt(t);if(!n)return{shapes:[],style:"p:otherStyle",isPlaceholder:!1};const r=e.layout&&function(t,e){const n=nt(t),{idx:r,type:a}=e.attrs;return(void 0!==r?n.find(t=>tt(t)?.attrs.idx===r):void 0)??(void 0!==a?n.find(t=>tt(t)?.attrs.type===a):void 0)}(e.layout,n),a=r?tt(r)??n:n,o=e.master&&function(t,e){const n=ot(e.attrs.type);return nt(t).find(t=>ot(tt(t)?.attrs.type)===n)}(e.master,a),s=ot(a.attrs.type);return{shapes:[r,o].filter(t=>!!t),style:"title"===s?"p:titleStyle":"body"===s?"p:bodyStyle":"p:otherStyle",isPlaceholder:!0}}function it(t,e,n,r){const a=t=>p(p(t,"p:txBody"),"a:lstStyle"),o=p(p(n.master?.root,"p:txStyles"),e.style),s=e.isPlaceholder?[o,r]:[r,o];return[a(t),...e.shapes.map(a),...s]}function lt(t,e,n){for(const r of[t,...e.shapes]){const t=p(p(r,"p:txBody"),"a:bodyPr")?.attrs[n];if(void 0!==t)return t}}var ct={l:"left",ctr:"center",r:"right"},pt=(t,e)=>t.lists.flatMap(t=>{const n=p(t,`a:lvl${e+1}pPr`);return n?[n]:[]});function ft(t,e){return"+mj-lt"===t?e.fonts.major:"+mn-lt"===t?e.fonts.minor:t}function ut(t,e,n,r){const a=[t,p(e,"a:defRPr"),...n.map(t=>p(t,"a:defRPr"))].filter(t=>!!t),o=t=>a.find(e=>void 0!==e.attrs[t])?.attrs[t],s=Number(o("sz")),i=o("b"),l=a.map(t=>R(t,r.palette)),c=a.map(t=>p(t,"a:latin")?.attrs.typeface).find(Boolean);return{sizePt:Number.isFinite(s)&&s>0?s/100:18,bold:"1"===i||"true"===i,colour:l.find(Boolean)??r.styleColour??j("tx1",r.palette)??"#000000",typeface:ft(c,r)??(r.isTitle?r.fonts.major:r.fonts.minor)}}function dt(t,e){for(const n of[t,...e]){if(p(n,"a:buNone"))return{kind:"none"};if(p(n,"a:buChar")||p(n,"a:buBlip"))return{kind:"bullet"};const t=p(n,"a:buAutoNum");if(t)return{kind:"number",startAt:Number(t.attrs.startAt)||1}}return{kind:"none"}}function mt(t,e){const n=[t,...e].map(t=>t?.attrs.algn).find(Boolean);return n&&ct[n]||"left"}function ht(t,e,n){const r=p(t,"a:pPr"),a=[];let o="";for(const s of t.children){if("a:br"===s.name&&(o+="\n"),"a:r"!==s.name&&"a:fld"!==s.name)continue;const t=p(s,"a:t")?.text??"";o+=t,t.trim()&&a.push({text:t,style:ut(p(s,"a:rPr"),r,e,n)})}return{text:o,runs:a}}var yt=(t,e)=>t.sizePt===e.sizePt&&t.bold===e.bold&&t.colour===e.colour;function gt(t,e){const n=[],r=[],a=function(){const t=[];return(e,n)=>"bullet"===e.kind?"• ":"none"===e.kind?(t.length=Math.min(t.length,n),""):(t.length=Math.min(t.length,n+1),t[n]=(t[n]??e.startAt-1)+1,`${t[n]}. `)}();let o;for(const s of f(t,"a:p")){const t=p(s,"a:pPr"),i=Number(t?.attrs.lvl)||0,l=pt(e,i),c=ht(s,l,e),f=dt(t,l),u=c.text.trim()?a(f,i):"";n.push(u?`${" ".repeat(i)}${u}${c.text}`:c.text),c.runs.length&&!o&&(o=mt(t,l)),r.push(...c.runs)}if(!r[0])return null;const s=function(t){const e=[];for(const n of t){const t=e.find(t=>yt(t.style,n.style));t?t.length+=n.text.length:e.push({style:n.style,length:n.text.length})}return e.reduce((t,e)=>e.length>t.length?e:t).style}(r),i=Number(p(p(t,"a:bodyPr"),"a:normAutofit")?.attrs.fontScale);return{text:n.join("\n").trimEnd(),sizePt:s.sizePt*(i>0?i/1e5:1),bold:s.bold,colour:s.colour,align:o??"left",mixed:r.some(t=>!yt(t.style,s)),typefaces:new Set(r.flatMap(t=>t.style.typeface?[t.style.typeface]:[]))}}function wt(t,e){const n=t.map(t=>t.map(e));return n.some(t=>t.some(Boolean))?n:void 0}var xt=t=>t.reduce((t,e)=>t+e,0);function bt(t,e,n,r){const a=E(p(t,"p:xfrm")),s=f(e,"a:tr");if(!a||!s.length)return void(n.tally.skipped+=1);const i=f(p(e,"a:tblGrid"),"a:gridCol").map(t=>Number(t.attrs.w)||0),l=s.map(t=>Number(t.attrs.h)||0),c=s.map(t=>f(t,"a:tc").map(t=>function(t,e){const n=p(t,"a:txBody"),r=gt(n,{palette:e.palette,fonts:e.master?.fonts??{},lists:[p(n,"a:lstStyle"),e.presentation.defaultTextStyle],isTitle:!1});for(const t of r?.typefaces??[])e.tally.typefaces.add(t);return{text:r?.text.replace(/\s*\n\s*/g," ")??"",block:r,fill:R(p(t,"a:tcPr"),e.palette)??null}}(t,n))),u=G({...a,w:xt(i)||a.w,h:xt(l)||a.h},r,n.frame),d=function(t){const e=new Map;for(const{block:n}of t)n&&e.set(n.sizePt,(e.get(n.sizePt)??0)+1);return[...e].sort((t,e)=>e[1]-t[1])[0]?.[0]}(c.flat()),m={...u,type:"table",rows:c.map(t=>t.map(t=>t.text)),headerFill:c[0].map(t=>t.fill).find(Boolean)??o,headerColor:c[0].map(t=>t.block?.colour).find(Boolean),fontSize:void 0===d?void 0:H(d,n.frame),columnWidths:xt(i)?i.map(t=>{return e=t,n=xt(i),Math.round(e/n*1e4)/1e4;var e,n}):void 0,rowHeights:xt(l)?l.map(t=>Math.round(t/xt(l)*u.h*100)/100):void 0,cellFills:wt(c,t=>t.fill),cellColors:wt(c,t=>t.block?.colour??null)};n.elements.push(m)}var vt={rect:"rect",ellipse:"ellipse",roundRect:"roundRect",diamond:"diamond",line:"line",straightConnector1:"line",flowChartProcess:"rect",flowChartAlternateProcess:"roundRect",flowChartDecision:"diamond",flowChartConnector:"ellipse"},Mt=new Set(["a:videoFile","a:audioFile","a:quickTimeFile","p14:media"]);function kt(t,e,n,r){const a=gt(p(t,"p:txBody"),function(t,e,n){const r=p(p(t,"p:style"),"a:fontRef")?.children[0];return{palette:n.palette,fonts:n.master?.fonts??{},lists:it(t,e,n,n.presentation.defaultTextStyle),isTitle:"p:titleStyle"===e.style,styleColour:z(r,n.palette)}}(t,n,r));if(!a)return;const{scale:o}=r.frame,s=(e,r)=>(Number(lt(t,n,e)??r)||0)*o,i=H(a.sizePt,r.frame),c=s("lIns",91440),f=s("tIns",45720),u=Math.max(e.w-c-s("rIns",91440),1),d=Math.max(e.h-f-s("bIns",45720),1),m=lt(t,n,"anchor"),h=Math.max(d-function(t,e,n){const r=Math.max(1,Math.floor(n/(.52*e)));return t.split("\n").reduce((t,e)=>t+Math.max(1,Math.ceil(e.length/r)),0)*e*1.25}(a.text,i,u),0),y="ctr"===m?h/2:"b"===m?h:0;r.elements.push({id:l(),type:"text",rotation:e.rotation,x:L(e.x+c),y:L(e.y+f+y),w:L(u),h:L(d-y),text:a.text,fontSize:i,bold:a.bold,color:a.colour,align:a.align});for(const t of a.typefaces)r.tally.typefaces.add(t);a.mixed&&(r.tally.mixedTextSimplified+=1)}function Pt(t,e){const n=p(t,"p:spPr");if(p(n,"a:noFill"))return{kind:"none"};if(p(n,"a:solidFill")){const t=R(n,e.palette);return t?{kind:"colour",colour:t}:{kind:"none"}}if(["a:gradFill","a:blipFill","a:pattFill","a:grpFill"].some(t=>p(n,t))){const t=function(t,e){const n=p(p(p(t,"a:gradFill"),"a:gsLst"),"a:gs")?.children[0],r=p(p(t,"a:pattFill"),"a:fgClr")?.children[0];return z(n??r,e.palette)}(n,e);return t?{kind:"colour",colour:t}:{kind:"undrawable"}}const r=p(p(t,"p:style"),"a:fillRef"),a=r&&"0"!==r.attrs.idx?z(r.children[0],e.palette):void 0;return a?{kind:"colour",colour:a}:{kind:"none"}}function St(t,e){const n=p(p(t,"p:spPr"),"a:ln");if(p(n,"a:noFill"))return;const r=p(p(t,"p:style"),"a:lnRef"),a=R(n,e.palette)??(r&&"0"!==r.attrs.idx?z(r.children[0],e.palette):void 0);return a?{stroke:a,strokeWidth:L((Number(n?.attrs.w)||9525)*e.frame.scale)}:void 0}function Nt(t,e){const n=p(p(p(t,"a:prstGeom"),"a:avLst"),"a:gd")?.attrs.fmla,r=Number(n?.replace("val ",""));return L((Number.isFinite(r)?r:16667)/1e5*Math.min(e.w,e.h))}var Ct=t=>!!t?.attrs.type&&"none"!==t.attrs.type;function At(t,e,n){const r=p(t,"p:spPr"),a=p(r,"a:xfrm"),s=E(a);if(!s)return void(e.tally.skipped+=1);const i=St(t,e);if(!i)return;const l=p(r,"a:ln");e.elements.push({...J(s,{flipH:O(a?.attrs.flipH),flipV:O(a?.attrs.flipV)},n,e.frame),type:"shape",shape:"line",fill:o,...i,...Ct(p(l,"a:tailEnd"))?{arrowEnd:!0}:{},...Ct(p(l,"a:headEnd"))?{arrowStart:!0}:{}})}function It(t,e,n){const r=st(t,e),a=p(t,"p:spPr"),s=function(t){return vt[p(t,"a:prstGeom")?.attrs.prst??"rect"]??"rect"}(a);if("line"===s)return void At(t,e,n);const i=E(p(a,"a:xfrm"))??r.shapes.map(t=>E(p(p(t,"p:spPr"),"a:xfrm"))).find(Boolean);if(!i)return void(p(t,"p:txBody")&&u(t,new Set(["a:t"])).length&&(e.tally.skipped+=1));const l=G(i,n,e.frame),c=Pt(t,e),f=St(t,e),d="colour"===c.kind||!!f;d&&function(t,e,n,r,a,s){s.elements.push({...t,type:"shape",shape:e,fill:"colour"===n.kind?n.colour:o,...r,..."roundRect"===e?{radius:Nt(a,t)}:{}})}(l,s,c,f,a,e),kt(t,l,r,e),"undrawable"!==c.kind||d||(e.tally.skipped+=1)}function Bt(t,e){const n=e.rels.get(t?.attrs["r:embed"]??"");return n&&!n.external?w(e.part,n.target):void 0}function Ft(t,e,n){const r=p(t,"p:nvPicPr"),a=st(t,e),o=E(p(p(t,"p:spPr"),"a:xfrm"))??a.shapes.map(t=>E(p(p(t,"p:spPr"),"a:xfrm"))).find(Boolean),s=p(t,"p:blipFill"),i=Bt(p(s,"a:blip"),e.slide),l=i&&!u(t,Mt).length?e.useImage(i,function(t){const e=e=>(Number(t?.attrs[e])||0)/1e5,n={left:e("l"),top:e("t"),right:e("r"),bottom:e("b")},r=Object.values(n);if(!r.every(t=>0===t)&&!r.some(t=>t<0))return n.left+n.right<1&&n.top+n.bottom<1?n:void 0}(p(s,"a:srcRect"))):void 0;o&&l?e.elements.push({...G(o,n,e.frame),type:"image",src:l,alt:p(r,"p:cNvPr")?.attrs.descr??""}):e.tally.skipped+=1}function Tt(t,e,n){const r=p(p(p(t,"a:graphic"),"a:graphicData"),"a:tbl");r?bt(t,r,e,n):e.tally.skipped+=1}function $t(t,e,n=[]){for(const r of t)switch(r.name){case"p:sp":It(r,e,n);break;case"p:pic":Ft(r,e,n);break;case"p:graphicFrame":Tt(r,e,n);break;case"p:cxnSp":At(r,e,n);break;case"p:contentPart":e.tally.skipped+=1;break;case"p:grpSp":{const t=V(r);$t(r.children,e,t?[t,...n]:n);break}case"mc:AlternateContent":$t(p(r,"mc:Fallback")?.children??[],e,n)}}function jt(t){const e=function(t){const e=h(t,"[Content_Types].xml"),n=e?m(e):void 0,r=new Map(f(n,"Override").map(t=>[t.attrs.PartName,t.attrs.ContentType])),a=new Map(f(n,"Default").map(t=>[t.attrs.Extension?.toLowerCase(),t.attrs.ContentType]));return t=>{const e=t.slice(t.lastIndexOf(".")+1).toLowerCase();return r.get(`/${t}`)??a.get(e)??_[e]??"application/octet-stream"}}(t),n=new Map;return{use:(t,r)=>{const a=e(t);if(!a.startsWith("image/"))return;const o=`${t}${function(t){return t?`#${t.left},${t.top},${t.right},${t.bottom}`:""}(r)}`;return n.has(o)||n.set(o,{key:o,part:t,contentType:a,crop:r}),o},uses:n}}function zt(t){return t.children.map(t=>"a:br"===t.name?"\n":"a:r"===t.name||"a:fld"===t.name?p(t,"a:t")?.text??"":"").join("")}function Rt(t,e){const n=K(e,"/notesSlide"),r=n&&Q(t,w(e.part,n.target)),a=((r&&U(r.root)?.children)??[]).find(t=>"body"===p(p(p(t,"p:nvSpPr"),"p:nvPr"),"p:ph")?.attrs.type);return f(p(a,"p:txBody"),"a:p").map(zt).join("\n").trim()}function Ot(t,e){const n=p(p(t.root,"p:cSld"),"p:bg");if(!n)return;const r=p(n,"p:bgPr"),a=R(r,e.palette)??z(p(n,"p:bgRef")?.children[0],e.palette);if(a)return{colour:a};const o=Bt(p(p(r,"a:blipFill"),"a:blip"),t);return o?{picture:o}:void 0}var Lt=t=>"0"===t.root.attrs.showMasterSp||"false"===t.root.attrs.showMasterSp;function Ht(t,e){const n=function(t){for(const e of[t.slide,t.layout,t.master]){const n=e&&Ot(e,t);if(n)return n}return{}}(t);return n.picture&&function(t,e){const n=e.useImage(t,void 0);if(!n)return void(e.tally.skipped+=1);const{left:r,top:a,width:o,height:s}=e.frame;e.elements.push({id:l(),type:"image",x:r,y:a,w:o,h:s,rotation:0,src:n,alt:""})}(n.picture,t),function(t){const{layout:e,master:n,slide:r}=t;if(!Lt(r))for(const r of[e&&Lt(e)?void 0:n,e]){const e=r?U(r.root)?.children??[]:[];r&&$t(e.filter(t=>!et(t)),{...t,slide:r})}}(t),$t(U(t.slide.root)?.children??[],t),{id:l(),background:n.colour??"#ffffff",notes:Rt(e,t.slide),elements:(r=t.elements,a=t.tally,a.skipped+=Math.max(r.length-200,0),r.slice(0,200))};var r,a}var Dt=t=>"0"===t.root.attrs.show||"false"===t.root.attrs.show;function Et(t){const n=function(t){const n=y(t,"").find(t=>t.type.endsWith("/officeDocument")),r=Q(t,n?w("",n.target):"ppt/presentation.xml");if(!r||"p:presentation"!==r.root.name)throw new e;const a=f(p(r.root,"p:sldIdLst"),"p:sldId").flatMap(t=>{const e=r.rels.get(t.attrs["r:id"]);return e?[w(r.part,e.target)]:[]}),o=p(r.root,"p:sldSz")?.attrs;return{width:Number(o?.cx)||9144e3,height:Number(o?.cy)||5143500,slides:a,defaultTextStyle:p(r.root,"p:defaultTextStyle")}}(t),r=function(t){const e=new Map,n=new Map;return r=>{const a=K(r,"/slideLayout"),o=a&&w(r.part,a.target);o&&!n.has(o)&&n.set(o,Z(t,o,e));const s=o?n.get(o):void 0,i=s?.master,l=i?.palette??q;return{slide:r,layout:s,master:i,palette:I(s?I(l,s.root):l,r.root)}}}(t),a=jt(t),o=function(t,e){const n=Math.min(i/t,s/e);return{scale:n,left:(i-t*n)/2,top:(s-e*n)/2,width:t*n,height:e*n}}(n.width,n.height),l={skipped:0,mixedTextSimplified:0,typefaces:new Set},u=[];let d=0;for(const e of n.slides){const s=Q(t,e);s&&!Dt(s)&&(p(s.root,"p:timing")&&(d+=1),u.push(Ht({...r(s),presentation:n,frame:o,tally:l,elements:[],useImage:a.use},t)))}const m=new Set(u.flatMap(t=>t.elements.flatMap(t=>"image"===t.type?[t.src]:[])));return{document:{slides:u.length?u:[c()]},slideCount:u.length,images:[...a.uses.values()].filter(t=>m.has(t.key)),animationsDropped:d,tally:l}}var Vt=.15,Xt=1048576,Wt=/\.(xml|rels)$/i;async function Yt(n,a){if(await async function(t){const e=new Uint8Array(await t.slice(0,v.length).arrayBuffer());return v.every((t,n)=>e[n]===t)}(n))throw await async function(t,e){for(let n=0;n<t.size;n+=k-M.length)if(e?.throwIfAborted(),P(new Uint8Array(await t.slice(n,n+k).arrayBuffer())))return!0;return!1}(n,a)?new t:new e(r.pptxLegacyFormat)}function Gt(t){if(t.slides.length>300)throw new e(r.pptxTooManySlides(t.slides.length,300));const n=b(t);if(n>x)throw new e(r.pptxTooLarge((n/Xt).toFixed(1),2))}var Jt={"image/webp":"webp","image/png":"png","image/jpeg":"jpg","image/gif":"gif"};async function qt(t,e,n){try{return await(n.prepareImage?n.prepareImage(e,t.contentType):async function(t,e,n){const r=await createImageBitmap(new Blob([t],{type:e}));try{const t=r.width*(n?.left??0),e=r.height*(n?.top??0),a=r.width-t-r.width*(n?.right??0),o=r.height-e-r.height*(n?.bottom??0),s=Math.min(1,1920/Math.max(a,o)),i=new OffscreenCanvas(Math.max(1,Math.round(a*s)),Math.max(1,Math.round(o*s))),l=i.getContext("2d");if(!l)throw new Error("No drawing context");return l.imageSmoothingQuality="high",l.drawImage(r,t,e,a,o,0,0,i.width,i.height),await i.convertToBlob({type:"image/webp",quality:.85})}finally{r.close()}}(e,t.contentType,t.crop))}catch(e){return n.signal?.throwIfAborted(),console.warn("A picture in the deck could not be read",t.part,e),null}}async function Kt(t,e,n){const r={addresses:new Map,count:0,bytesBefore:0,bytesAfter:0},a=function(t,e){const n=new Map;for(const r of t){const t=e.prepareImage?r.part:r.key;n.set(t,[...n.get(t)??[],r])}return[...n.values()]}(t,n),o=new Map;let s=0;return await async function(t,e,n){let r=0,a=!1;await Promise.all(Array.from({length:Math.min(e,t.length)},async()=>{for(;!a&&r<t.length;){const e=t[r];r+=1;try{await n(e)}catch(t){throw a=!0,t}}}))}(a,4,async t=>{n.signal?.throwIfAborted();const[i]=t,l=o.get(i.part)??0;o.set(i.part,l+1);const c=await e.read(i.part).catch(()=>null),p=c&&await qt(i,c,n);if(c&&p){n.signal?.throwIfAborted();const e=await n.storeImage(p,function(t,e,n){return`${t.slice(t.lastIndexOf("/")+1).replace(/\.[^.]*$/,"")}${n?`-${n}`:""}.${Jt[e.type]??"img"}`}(i.part,p,l));for(const{key:n}of t)r.addresses.set(n,e);r.count+=1,r.bytesBefore+=c.length,r.bytesAfter+=p.size}s+=1,n.onProgress?.(Vt+.85*s/a.length)}),r}async function Ut(t,r){r.signal?.throwIfAborted(),await Yt(t,r.signal);const a=await async function(t){try{return await d(t)}catch{throw new e}}(t),o=await async function(t,e){const n=new Map,r=t.names.filter(t=>Wt.test(t));for(const[a,o]of r.entries())e.signal?.throwIfAborted(),n.set(o,await t.read(o)),e.onProgress?.(Vt*(a+1)/r.length);return n}(a,r).catch(t=>{throw r.signal?.throwIfAborted(),t instanceof e?t:new e}),s=function(t){try{return Et(t)}catch(t){if(t instanceof e)throw t;throw new e}}(o);Gt(s.document);const i=await Kt(s.images,a,r),l=function(t,e,n){const r=t=>{if("image"!==t.type)return[t];const r=e.get(t.src);return void 0===r&&(n.skipped+=1),void 0===r?[]:[{...t,src:r}]};return{slides:t.slides.map(t=>({...t,elements:t.elements.flatMap(r)}))}}(s.document,i.addresses,s.tally);return Gt(l),r.onProgress?.(1),{document:l,notes:{slides:s.slideCount,images:i.count,imageBytesBefore:i.bytesBefore,imageBytesAfter:i.bytesAfter,fontsReplaced:[...s.tally.typefaces].filter(t=>t!==n).sort(),animationsDropped:s.animationsDropped,mixedTextSimplified:s.tally.mixedTextSimplified,skipped:s.tally.skipped}}}export{Ut as importPptx};
|