efficient-office 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Slides-JLWEMUXJ.js +1 -0
- package/dist/SlidesEditor-DGK4W6W4.js +1 -0
- package/dist/Spreadsheet-WQOZPWY5.js +1 -0
- package/dist/chunk-5K2D7PBJ.js +1 -0
- package/dist/chunk-AJTH75FI.js +1 -0
- package/dist/chunk-BDVKNU3U.js +1 -0
- package/dist/chunk-CEVQKZ66.js +1 -0
- package/dist/chunk-EDJRXJNE.js +1 -0
- package/dist/chunk-EP3ZNVDB.js +1 -0
- package/dist/{chunk-DG4VDXLL.js → chunk-HQM2HX4V.js} +1 -1
- package/dist/chunk-PX4QOBHF.js +1 -0
- package/dist/{chunk-MDG2ADZ7.js → chunk-R2CXMNZL.js} +1 -1
- package/dist/chunk-T2TZ7HF5.js +1 -0
- package/dist/chunk-VYLIT7NN.js +1 -0
- package/dist/{chunk-MR7ZWQHF.js → chunk-WAB44FLE.js} +1 -1
- package/dist/{chunk-NRGUS5QY.js → chunk-XENQLN5I.js} +1 -1
- package/dist/deckPdf-KZFS4CTF.js +1 -0
- package/dist/documents/index.js +1 -1
- package/dist/docxPdf-S4RXU4L2.js +1 -0
- package/dist/importSpreadsheet-L5FJGRUV.js +1 -0
- package/dist/{pptxImport-OACGHWQ6.js → pptxImport-UQQXZUQL.js} +1 -1
- package/dist/slides/index.d.ts +213 -17
- package/dist/slides/index.js +1 -1
- package/dist/slides/slides.css +53 -0
- package/dist/spreadsheet/index.d.ts +2 -1
- package/dist/spreadsheet/index.js +1 -1
- package/dist/workbookPdf-K65CQX4K.js +1 -0
- package/dist/xlsxFile-3GXD4KW5.js +1 -0
- package/package.json +1 -1
- package/dist/Slides-YZQXZJX4.js +0 -1
- package/dist/SlidesEditor-ETCUQVJ7.js +0 -1
- package/dist/Spreadsheet-VWRRB6FE.js +0 -1
- package/dist/chunk-3RFDQOTI.js +0 -1
- package/dist/chunk-ADXHTZ3Q.js +0 -1
- package/dist/chunk-B2X3NIQR.js +0 -1
- package/dist/chunk-BGAR3P46.js +0 -1
- package/dist/chunk-JKYJGXJE.js +0 -1
- package/dist/chunk-PXOQN7D6.js +0 -1
- package/dist/chunk-Q7NVDOCX.js +0 -1
- package/dist/chunk-UKGIT2RS.js +0 -1
- package/dist/chunk-ZS45QEF4.js +0 -1
- package/dist/deckPdf-4RC7QJ45.js +0 -1
- package/dist/docxPdf-QSMEFCUF.js +0 -1
- package/dist/importSpreadsheet-IRN32JON.js +0 -1
- package/dist/workbookPdf-CQTTURQ5.js +0 -1
- package/dist/xlsxFile-SX767BIH.js +0 -1
|
@@ -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{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};
|
package/dist/documents/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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-
|
|
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{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-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 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 D=t=>"1"===t||"true"===t,R=t=>Math.round(100*t)/100+0,L=(t,e)=>R(12700*t*e.scale),E=t=>t*Math.PI/180;function H(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=H(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:D(e?.attrs.flipH),flipV:D(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=E(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=>R((t%360+360)%360);function G(t,e,n){const r=e.reduce(W,t);return{id:l(),x:R(n.left+r.x*n.scale),y:R(n.top+r.y*n.scale),w:R(r.w*n.scale),h:R(r.h*n.scale),rotation:Y(r.rotation)}}function q(t,e,n,r){const o=t.x+t.w/2,s=t.y+t.h/2,i=E(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:R((p.x+f.x-u)/2),y:R((p.y+f.y-a)/2),w:R(u),h:a,rotation:Y(180*Math.atan2(f.y-p.y,f.x-p.x)/Math.PI)}}var J={scheme:new Map,map:{}},K=(t,e)=>[...t.rels.values()].find(t=>t.type.endsWith(e)),Q=t=>p(p(t,"p:cSld"),"p:spTree");function U(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=U(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=U(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=>(Q(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=H(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:L(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=L(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:R(e.x+c),y:R(e.y+f+y),w:R(u),h:R(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:R((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 R((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=H(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({...q(s,{flipH:D(a?.attrs.flipH),flipV:D(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=H(p(a,"a:xfrm"))??r.shapes.map(t=>H(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=H(p(p(t,"p:spPr"),"a:xfrm"))??a.shapes.map(t=>H(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)??_[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=K(e,"/notesSlide"),r=n&&U(t,w(e.part,n.target)),a=((r&&Q(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 Dt(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 Rt=t=>"0"===t.root.attrs.showMasterSp||"false"===t.root.attrs.showMasterSp;function Lt(t,e){const n=function(t){for(const e of[t.slide,t.layout,t.master]){const n=e&&Dt(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(!Rt(r))for(const r of[e&&Rt(e)?void 0:n,e]){const e=r?Q(r.root)?.children??[]:[];r&&$t(e.filter(t=>!et(t)),{...t,slide:r})}}(t),$t(Q(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 Et=t=>"0"===t.root.attrs.show||"false"===t.root.attrs.show;function Ht(t){const n=function(t){const n=y(t,"").find(t=>t.type.endsWith("/officeDocument")),r=U(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??J;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=U(t,e);s&&!Et(s)&&(p(s.root,"p:timing")&&(d+=1),u.push(Lt({...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 qt={"image/webp":"webp","image/png":"png","image/jpeg":"jpg","image/gif":"gif"};async function Jt(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 Jt(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}`:""}.${qt[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 Qt(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 Ht(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{Qt 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};
|
package/dist/slides/index.d.ts
CHANGED
|
@@ -32,6 +32,10 @@ interface TextRun {
|
|
|
32
32
|
font?: string;
|
|
33
33
|
/** `https://`, `http://`, `mailto:`, or `#slide=<id>` for another slide. */
|
|
34
34
|
link?: string;
|
|
35
|
+
/** Raised or lowered, smaller, as in H₂O or 10³ (0.11). */
|
|
36
|
+
script?: 'super' | 'sub';
|
|
37
|
+
/** Extra room between letters, in ems (0.11). */
|
|
38
|
+
spacing?: number;
|
|
35
39
|
}
|
|
36
40
|
interface Paragraph {
|
|
37
41
|
runs: TextRun[];
|
|
@@ -41,6 +45,11 @@ interface Paragraph {
|
|
|
41
45
|
level?: number;
|
|
42
46
|
/** A multiple of the font size. */
|
|
43
47
|
lineHeight?: number;
|
|
48
|
+
/** Room above and below the paragraph, in slide pixels (0.11). */
|
|
49
|
+
spaceBefore?: number;
|
|
50
|
+
spaceAfter?: number;
|
|
51
|
+
/** A bulleted paragraph's mark, one of `BULLET_GLYPHS` (0.11). */
|
|
52
|
+
bullet?: string;
|
|
44
53
|
}
|
|
45
54
|
/** What a layout's text box is for, so a theme can restyle it. */
|
|
46
55
|
type PlaceholderRole = 'title' | 'subtitle' | 'body';
|
|
@@ -61,10 +70,22 @@ interface TextElement extends ElementBase {
|
|
|
61
70
|
/** Shrink the type until the words fit the box. */
|
|
62
71
|
autofit?: boolean;
|
|
63
72
|
placeholder?: PlaceholderRole;
|
|
73
|
+
/** The words flow through this many columns (0.11). */
|
|
74
|
+
columns?: number;
|
|
75
|
+
}
|
|
76
|
+
/** The words a shape holds (0.11): a text box's own fields, all optional, so an
|
|
77
|
+
* older shape is a shape with none (./shapeText). */
|
|
78
|
+
type ShapeWords = Partial<Pick<TextElement, 'text' | 'paragraphs' | 'fontSize' | 'bold' | 'color' | 'align' | 'font' | 'anchor' | 'autofit'>>;
|
|
79
|
+
declare const SHAPE_KINDS: readonly ["rect", "roundRect", "ellipse", "triangle", "rightTriangle", "diamond", "pentagon", "hexagon", "octagon", "star", "heart", "cloud", "bolt", "parallelogram", "trapezoid", "cylinder", "plus", "arrowRight", "arrowLeft", "arrowUp", "arrowDown", "arrowLeftRight", "chevron", "callout", "calloutRound", "line", "freeform", "curve"];
|
|
80
|
+
type StrokeDash = 'solid' | 'dash' | 'dot';
|
|
81
|
+
/** Two colours across a fill, turned by `angle` degrees (0 runs left to right). */
|
|
82
|
+
interface Gradient {
|
|
83
|
+
from: string;
|
|
84
|
+
to: string;
|
|
85
|
+
angle: number;
|
|
64
86
|
}
|
|
65
|
-
declare const SHAPE_KINDS: readonly ["rect", "roundRect", "ellipse", "triangle", "rightTriangle", "diamond", "pentagon", "hexagon", "octagon", "star", "heart", "cloud", "bolt", "parallelogram", "trapezoid", "cylinder", "plus", "arrowRight", "arrowLeft", "arrowUp", "arrowDown", "arrowLeftRight", "chevron", "callout", "calloutRound", "line"];
|
|
66
87
|
type ShapeKind = (typeof SHAPE_KINDS)[number];
|
|
67
|
-
interface ShapeElement extends ElementBase {
|
|
88
|
+
interface ShapeElement extends ElementBase, ShapeWords {
|
|
68
89
|
type: 'shape';
|
|
69
90
|
/** A `line` runs left to right through the middle of its box; `rotation` turns it. */
|
|
70
91
|
shape: ShapeKind;
|
|
@@ -75,6 +96,14 @@ interface ShapeElement extends ElementBase {
|
|
|
75
96
|
radius?: number;
|
|
76
97
|
arrowEnd?: boolean;
|
|
77
98
|
arrowStart?: boolean;
|
|
99
|
+
dash?: StrokeDash;
|
|
100
|
+
/** Drawn over `fill`, which stays as the colour an older reader shows. */
|
|
101
|
+
gradient?: Gradient;
|
|
102
|
+
/** A soft shadow below and to the right. */
|
|
103
|
+
shadow?: boolean;
|
|
104
|
+
/** A drawn shape's outline, each point a share of its box's width and height
|
|
105
|
+
* (0 to 1), so it stretches as the box is resized (`DRAWN_SHAPES`). */
|
|
106
|
+
points?: [number, number][];
|
|
78
107
|
}
|
|
79
108
|
/** A share of each side cut away, each 0 to below 1. */
|
|
80
109
|
interface Crop {
|
|
@@ -90,12 +119,24 @@ interface ImageElement extends ElementBase {
|
|
|
90
119
|
crop?: Crop;
|
|
91
120
|
/** 0 to 1; absent is 1. */
|
|
92
121
|
opacity?: number;
|
|
122
|
+
/** Drawn inside this shape's outline instead of its box (0.11). */
|
|
123
|
+
mask?: Exclude<ShapeKind, 'line' | 'freeform' | 'curve'>;
|
|
124
|
+
/** 1 is as taken; 0.5 to 1.5. */
|
|
125
|
+
brightness?: number;
|
|
126
|
+
contrast?: number;
|
|
127
|
+
recolour?: 'greyscale' | 'sepia';
|
|
93
128
|
}
|
|
94
129
|
interface VideoElement extends ElementBase {
|
|
95
130
|
type: 'video';
|
|
96
131
|
/** A YouTube or Vimeo page, or a video file's address. */
|
|
97
132
|
src: string;
|
|
98
133
|
alt: string;
|
|
134
|
+
/** Seconds into the video it starts and stops (0.11). */
|
|
135
|
+
start?: number;
|
|
136
|
+
end?: number;
|
|
137
|
+
/** Plays as the slide is shown. */
|
|
138
|
+
autoplay?: boolean;
|
|
139
|
+
mute?: boolean;
|
|
99
140
|
}
|
|
100
141
|
type ConnectorSide = 'n' | 'e' | 's' | 'w';
|
|
101
142
|
interface ConnectorEnd {
|
|
@@ -165,6 +206,10 @@ interface TableElement extends ElementBase {
|
|
|
165
206
|
borderColor?: string;
|
|
166
207
|
/** In slide pixels; 0 draws none. */
|
|
167
208
|
borderWidth?: number;
|
|
209
|
+
/** Room inside each cell, in slide pixels (0.11); absent scales with the type. */
|
|
210
|
+
cellPadding?: number;
|
|
211
|
+
cellAlign?: TextAlign;
|
|
212
|
+
cellAnchor?: 'top' | 'middle' | 'bottom';
|
|
168
213
|
}
|
|
169
214
|
type SlideElement = TextElement | ShapeElement | ImageElement | VideoElement | ConnectorElement | ChartElement | TableElement;
|
|
170
215
|
type TransitionKind = 'fade' | 'slide' | 'push' | 'zoom' | 'flip';
|
|
@@ -173,12 +218,13 @@ interface Transition {
|
|
|
173
218
|
/** Seconds. */
|
|
174
219
|
duration: number;
|
|
175
220
|
}
|
|
176
|
-
|
|
221
|
+
declare const ANIMATION_EFFECTS: readonly ["appear", "fadeIn", "flyIn", "zoomIn", "wipeIn", "spin", "pulse", "fadeOut", "flyOut", "zoomOut", "wipeOut"];
|
|
222
|
+
type AnimationEffect = (typeof ANIMATION_EFFECTS)[number];
|
|
177
223
|
interface Animation {
|
|
178
224
|
id: string;
|
|
179
225
|
elementId: string;
|
|
180
226
|
effect: AnimationEffect;
|
|
181
|
-
/** Where a fly-in comes from. */
|
|
227
|
+
/** Where a fly-in comes from, a fly-out goes, or a wipe starts. */
|
|
182
228
|
from?: 'left' | 'right' | 'top' | 'bottom';
|
|
183
229
|
start: 'click' | 'withPrevious' | 'afterPrevious';
|
|
184
230
|
/** Seconds. */
|
|
@@ -187,17 +233,36 @@ interface Animation {
|
|
|
187
233
|
byParagraph?: boolean;
|
|
188
234
|
}
|
|
189
235
|
type LayoutId = 'title' | 'titleBody' | 'section' | 'twoColumns' | 'titleOnly' | 'blank';
|
|
236
|
+
/** A picture behind a slide's objects (0.11), named by address like an image. */
|
|
237
|
+
interface BackgroundImage {
|
|
238
|
+
src: string;
|
|
239
|
+
fit: 'fill' | 'fit' | 'tile';
|
|
240
|
+
/** 0 to 0.8: a black veil over the picture, so words on it read. */
|
|
241
|
+
dim?: number;
|
|
242
|
+
}
|
|
190
243
|
interface Slide {
|
|
191
244
|
id: string;
|
|
192
245
|
background: string;
|
|
193
246
|
notes: string;
|
|
194
247
|
elements: SlideElement[];
|
|
195
|
-
|
|
248
|
+
/** A built-in `LayoutId`, or the id of one of the deck's own `layouts`. */
|
|
249
|
+
layout?: LayoutId | (string & {});
|
|
196
250
|
/** Left out of the show, kept in the deck. */
|
|
197
251
|
skip?: boolean;
|
|
198
252
|
transition?: Transition;
|
|
199
253
|
/** In the order they play. */
|
|
200
254
|
animations?: Animation[];
|
|
255
|
+
/** Drawn over `background`, which stays as an older reader's colour (0.11). */
|
|
256
|
+
backgroundImage?: BackgroundImage;
|
|
257
|
+
backgroundGradient?: Gradient;
|
|
258
|
+
}
|
|
259
|
+
/** A layout the deck keeps of its own (0.11): a built-in one restyled (same `id`),
|
|
260
|
+
* or a new one. Its elements are a new slide's, given new ids each time. */
|
|
261
|
+
interface DeckLayout {
|
|
262
|
+
id: string;
|
|
263
|
+
name: string;
|
|
264
|
+
background?: string;
|
|
265
|
+
elements: SlideElement[];
|
|
201
266
|
}
|
|
202
267
|
interface DeckTheme {
|
|
203
268
|
id: string;
|
|
@@ -214,6 +279,7 @@ interface DeckDocument {
|
|
|
214
279
|
slides: Slide[];
|
|
215
280
|
theme?: DeckTheme;
|
|
216
281
|
slideNumbers?: boolean;
|
|
282
|
+
layouts?: DeckLayout[];
|
|
217
283
|
}
|
|
218
284
|
/** A document that came back from the server with nothing in it yet. */
|
|
219
285
|
declare function asDocument(stored: unknown): DeckDocument;
|
|
@@ -559,6 +625,125 @@ interface SlidesWords {
|
|
|
559
625
|
commentCount: (n: number) => string;
|
|
560
626
|
restoreConfirm: (when: string) => string;
|
|
561
627
|
shapeName: (kind: ShapeKind) => string;
|
|
628
|
+
effectFlyOut: string;
|
|
629
|
+
effectZoomOut: string;
|
|
630
|
+
effectSpin: string;
|
|
631
|
+
effectWipeIn: string;
|
|
632
|
+
effectWipeOut: string;
|
|
633
|
+
effectPulse: string;
|
|
634
|
+
assignTo: (name: string) => string;
|
|
635
|
+
assignedTo: (name: string) => string;
|
|
636
|
+
assignedDone: (name: string) => string;
|
|
637
|
+
unassign: string;
|
|
638
|
+
findReplace: string;
|
|
639
|
+
find: string;
|
|
640
|
+
replaceWith: string;
|
|
641
|
+
matchCase: string;
|
|
642
|
+
wholeWords: string;
|
|
643
|
+
matchesOf: (n: number, total: number, slides: number) => string;
|
|
644
|
+
noMatches: string;
|
|
645
|
+
findHint: string;
|
|
646
|
+
previousMatch: string;
|
|
647
|
+
nextMatch: string;
|
|
648
|
+
replace: string;
|
|
649
|
+
replaceAll: string;
|
|
650
|
+
gridView: string;
|
|
651
|
+
slidesPicked: (n: number) => string;
|
|
652
|
+
duplicateSlides: (n: number) => string;
|
|
653
|
+
deleteSlides: (n: number) => string;
|
|
654
|
+
outlineStyle: string;
|
|
655
|
+
dashSolid: string;
|
|
656
|
+
dashDashed: string;
|
|
657
|
+
dashDotted: string;
|
|
658
|
+
fillSolid: string;
|
|
659
|
+
fillGradient: string;
|
|
660
|
+
gradientFrom: string;
|
|
661
|
+
gradientTo: string;
|
|
662
|
+
shadow: string;
|
|
663
|
+
videoStart: string;
|
|
664
|
+
videoEnd: string;
|
|
665
|
+
autoplay: string;
|
|
666
|
+
mute: string;
|
|
667
|
+
mask: string;
|
|
668
|
+
maskNone: string;
|
|
669
|
+
brightness: string;
|
|
670
|
+
contrast: string;
|
|
671
|
+
recolour: string;
|
|
672
|
+
recolourNone: string;
|
|
673
|
+
greyscale: string;
|
|
674
|
+
sepia: string;
|
|
675
|
+
backgroundKind: string;
|
|
676
|
+
backgroundFit: string;
|
|
677
|
+
fitFill: string;
|
|
678
|
+
fitFit: string;
|
|
679
|
+
fitTile: string;
|
|
680
|
+
dim: string;
|
|
681
|
+
reset: string;
|
|
682
|
+
cellPadding: string;
|
|
683
|
+
cellAlign: string;
|
|
684
|
+
evenRows: string;
|
|
685
|
+
evenColumns: string;
|
|
686
|
+
superscript: string;
|
|
687
|
+
subscript: string;
|
|
688
|
+
letterSpacing: string;
|
|
689
|
+
normal: string;
|
|
690
|
+
bulletStyle: string;
|
|
691
|
+
bulletAuto: string;
|
|
692
|
+
spaceBefore: string;
|
|
693
|
+
spaceAfter: string;
|
|
694
|
+
columns: string;
|
|
695
|
+
importSlides: string;
|
|
696
|
+
importCount: (n: number) => string;
|
|
697
|
+
importFrom: string;
|
|
698
|
+
importPptxFile: string;
|
|
699
|
+
selectAll: string;
|
|
700
|
+
keepTheirTheme: string;
|
|
701
|
+
useThisTheme: string;
|
|
702
|
+
sameTheme: string;
|
|
703
|
+
print: string;
|
|
704
|
+
printLayout: string;
|
|
705
|
+
printSlides: string;
|
|
706
|
+
printNotes: string;
|
|
707
|
+
printHandouts: (n: number) => string;
|
|
708
|
+
includeSkipped: string;
|
|
709
|
+
printHint: string;
|
|
710
|
+
presentOptions: string;
|
|
711
|
+
fromStart: string;
|
|
712
|
+
autoAdvance: string;
|
|
713
|
+
everySeconds: (seconds: number) => string;
|
|
714
|
+
off: string;
|
|
715
|
+
loopAtEnd: string;
|
|
716
|
+
loop: string;
|
|
717
|
+
laserPointer: string;
|
|
718
|
+
advancingEvery: (seconds: number) => string;
|
|
719
|
+
thisSlide: string;
|
|
720
|
+
plainText: string;
|
|
721
|
+
makeCopy: string;
|
|
722
|
+
copyOf: (title: string) => string;
|
|
723
|
+
copyMade: (title: string) => string;
|
|
724
|
+
copyFailed: string;
|
|
725
|
+
drawFreeform: string;
|
|
726
|
+
drawCurve: string;
|
|
727
|
+
drawFreeformHint: string;
|
|
728
|
+
drawCurveHint: string;
|
|
729
|
+
zoom: string;
|
|
730
|
+
zoomIn: string;
|
|
731
|
+
zoomOut: string;
|
|
732
|
+
fit: string;
|
|
733
|
+
rulers: string;
|
|
734
|
+
onEverySlide: string;
|
|
735
|
+
editLayouts: string;
|
|
736
|
+
saveAsLayout: string;
|
|
737
|
+
layoutNamePrompt: string;
|
|
738
|
+
myLayout: string;
|
|
739
|
+
layoutSaved: string;
|
|
740
|
+
newLayout: string;
|
|
741
|
+
replaceLayout: (name: string) => string;
|
|
742
|
+
resetLayout: string;
|
|
743
|
+
deleteLayout: string;
|
|
744
|
+
layoutHint: string;
|
|
745
|
+
importTheme: string;
|
|
746
|
+
themeImported: string;
|
|
562
747
|
starterName: (id: StarterId) => string;
|
|
563
748
|
themeName: (id: string) => string;
|
|
564
749
|
presenterStep: (n: number, total: number) => string;
|
|
@@ -609,20 +794,29 @@ interface DeckComment {
|
|
|
609
794
|
createdAt: string;
|
|
610
795
|
resolvedAt: string | null;
|
|
611
796
|
resolvedByName: string;
|
|
797
|
+
/** Whose action item the thread is (a thread's first comment only, 0.11). */
|
|
798
|
+
assigneeId?: string | null;
|
|
799
|
+
assigneeName?: string;
|
|
800
|
+
}
|
|
801
|
+
interface NewDeckComment {
|
|
802
|
+
slideId: string;
|
|
803
|
+
elementId: string;
|
|
804
|
+
body: string;
|
|
805
|
+
parent: string | null;
|
|
806
|
+
mentions: string[];
|
|
807
|
+
/** A person to hand the thread to, by id (0.11). A host that can't assign ignores it. */
|
|
808
|
+
assignee?: string;
|
|
809
|
+
}
|
|
810
|
+
interface DeckCommentChange {
|
|
811
|
+
body?: string;
|
|
812
|
+
resolved?: boolean;
|
|
813
|
+
/** Hand the thread to somebody, or null to take it back (0.11). */
|
|
814
|
+
assignee?: string | null;
|
|
612
815
|
}
|
|
613
816
|
interface CommentsStore {
|
|
614
817
|
list: (deckId: string) => Promise<DeckComment[]>;
|
|
615
|
-
add: (deckId: string, comment:
|
|
616
|
-
|
|
617
|
-
elementId: string;
|
|
618
|
-
body: string;
|
|
619
|
-
parent: string | null;
|
|
620
|
-
mentions: string[];
|
|
621
|
-
}) => Promise<DeckComment>;
|
|
622
|
-
update: (deckId: string, id: string, change: {
|
|
623
|
-
body?: string;
|
|
624
|
-
resolved?: boolean;
|
|
625
|
-
}) => Promise<DeckComment>;
|
|
818
|
+
add: (deckId: string, comment: NewDeckComment) => Promise<DeckComment>;
|
|
819
|
+
update: (deckId: string, id: string, change: DeckCommentChange) => Promise<DeckComment>;
|
|
626
820
|
remove: (deckId: string, id: string) => Promise<void>;
|
|
627
821
|
}
|
|
628
822
|
interface DeckVersionSummary {
|
|
@@ -773,6 +967,8 @@ interface ElementBodyOptions {
|
|
|
773
967
|
onLink?: (href: string) => void;
|
|
774
968
|
/** A table cell's editor, in place of its words. */
|
|
775
969
|
cellEditor?: (row: number, col: number) => ReactNode;
|
|
970
|
+
/** The words editor of the shape being typed in, drawn over the shape. */
|
|
971
|
+
shapeEditor?: ReactNode;
|
|
776
972
|
}
|
|
777
973
|
interface SlideMotion {
|
|
778
974
|
hidden: ReadonlySet<string>;
|
|
@@ -814,4 +1010,4 @@ declare function importPptx(file: Blob, options: PptxImportOptions): Promise<{
|
|
|
814
1010
|
/** A PDF with one page for each slide, drawn as `SlideView` draws it. */
|
|
815
1011
|
declare function deckToPdf(document: DeckDocument, options?: PdfOptions): Promise<Blob>;
|
|
816
1012
|
|
|
817
|
-
export { ChooseOfficeFile, type CommentsStore, type DeckComment, DeckEditor, type DeckSummary, type DeckVersionSummary, ENGLISH_WORDS, FileWords, type ImportDeckOptions, type ImportedDeck, type LiveChannel, type LiveEvent, PdfOptions, type Person, type PptxImportNotes, type PptxImportOptions, PptxPasswordError, PptxUnreadableError, SlideView, Slides, SlidesConflict, type SlidesHost, SlidesProvider, type SlidesStore, type SlidesWords, type StoredDeck, type VersionsStore, ZH_HANS_WORDS, asDocument, browserSlidesStore, deckToPdf, importDeckFile, importPptx, mergeDecks, slidesApps };
|
|
1013
|
+
export { ChooseOfficeFile, type CommentsStore, type DeckComment, type DeckCommentChange, DeckEditor, type DeckSummary, type DeckVersionSummary, ENGLISH_WORDS, FileWords, type ImportDeckOptions, type ImportedDeck, type LiveChannel, type LiveEvent, type NewDeckComment, PdfOptions, type Person, type PptxImportNotes, type PptxImportOptions, PptxPasswordError, PptxUnreadableError, SlideView, Slides, SlidesConflict, type SlidesHost, SlidesProvider, type SlidesStore, type SlidesWords, type StoredDeck, type VersionsStore, ZH_HANS_WORDS, asDocument, browserSlidesStore, deckToPdf, importDeckFile, importPptx, mergeDecks, slidesApps };
|
package/dist/slides/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mergeDecks as o}from"../chunk-
|
|
1
|
+
import{mergeDecks as o}from"../chunk-EDJRXJNE.js";import{PptxPasswordError as t,PptxUnreadableError as r}from"../chunk-R2CXMNZL.js";import{SlidesConflict as i,SlidesProvider as m,browserSlidesStore as p,importDeckFile as s}from"../chunk-T2TZ7HF5.js";import{SlideView as n}from"../chunk-EP3ZNVDB.js";import{ENGLISH_WORDS as e,ZH_HANS_WORDS as c,asDocument as f}from"../chunk-AJTH75FI.js";import{ENGLISH_FILE_WORDS as u,ZH_HANS_FILE_WORDS as a}from"../chunk-B32ASXHM.js";import{hasExtension as j}from"../chunk-XYVQTQ6N.js";import{lazy as d}from"react";var h=d(()=>import("../Slides-JLWEMUXJ.js")),k=d(()=>import("../Slides-JLWEMUXJ.js").then(o=>({default:o.OpenDeck}))),l={"/slides":{component:h,label:"Slides",size:"3xl",appStyle:!0,flushBody:!0,autoHeight:!1}};async function J(o,t){const{importPptx:r}=await(import("../pptxImport-UQQXZUQL.js"));return r(o,t)}async function X(o,t){const{deckToPdf:r}=await(import("../deckPdf-KZFS4CTF.js"));return r(o,t)}export{k as DeckEditor,u as ENGLISH_FILE_WORDS,e as ENGLISH_WORDS,t as PptxPasswordError,r as PptxUnreadableError,n as SlideView,h as Slides,i as SlidesConflict,m as SlidesProvider,a as ZH_HANS_FILE_WORDS,c as ZH_HANS_WORDS,f as asDocument,p as browserSlidesStore,X as deckToPdf,j as hasExtension,s as importDeckFile,J as importPptx,o as mergeDecks,l as slidesApps};
|