@8sheets/data-grid 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/a11y/cell-alt-text.js +1 -1
- package/api/serialize.js +1 -1
- package/api/style-refs.js +1 -1
- package/calc/adjust.js +1 -1
- package/calc/compile.js +1 -1
- package/calc/engine.js +1 -1
- package/calc/functions/array.js +1 -1
- package/calc/functions/database.js +1 -1
- package/calc/functions/date.js +1 -1
- package/calc/functions/engineering.js +1 -1
- package/calc/functions/financial.js +1 -1
- package/calc/functions/helpers.js +1 -1
- package/calc/functions/index.js +3 -2
- package/calc/functions/info.js +1 -1
- package/calc/functions/logical.js +1 -1
- package/calc/functions/lookup.js +1 -1
- package/calc/functions/math.js +1 -1
- package/calc/functions/stat.js +1 -1
- package/calc/functions/text.js +1 -1
- package/calc/parser.js +2 -2
- package/calc/shown-refs.js +1 -0
- package/calc/values.js +1 -1
- package/calcx/calc-control.js +1 -0
- package/calcx/external-read.js +1 -1
- package/calcx/external.js +1 -1
- package/calcx/lang/convert.js +1 -1
- package/cells/axis-ops.js +1 -1
- package/cells/book-css.js +7 -2
- package/cells/cell-styles-xml.js +1 -1
- package/cells/cf-engine.js +1 -1
- package/cells/cf-file.js +1 -1
- package/cells/docprops-xml.js +2 -2
- package/cells/filter-eval.js +1 -0
- package/cells/filter-file.js +1 -1
- package/cells/find-engine.js +2 -2
- package/cells/find.js +1 -1
- package/cells/goto.js +1 -1
- package/cells/link-model.js +1 -0
- package/cells/name-box.js +1 -1
- package/cells/note-box.js +3 -0
- package/cells/options.js +1 -1
- package/cells/outline-column.js +1 -1
- package/cells/protected-menu.js +1 -0
- package/cells/rich-data-xml.js +1 -1
- package/cells/selection-modes.js +1 -1
- package/cells/sheet-views-file.js +2 -0
- package/cells/shift-check.js +1 -1
- package/cells/sort-compare.js +1 -0
- package/cells/ui-kit.js +1 -1
- package/cells/undo-group.js +1 -1
- package/celltypes/dropdowns.js +2 -2
- package/core/address.js +1 -1
- package/core/autofill.js +1 -1
- package/core/axis.js +1 -1
- package/core/cond-format.js +1 -1
- package/core/culture.js +5 -1
- package/core/custom-views.js +1 -1
- package/core/data-tools.js +1 -0
- package/core/date-codes.js +1 -0
- package/core/default-names.js +1 -1
- package/core/edit-ranges.js +1 -0
- package/core/formula-refs.js +1 -1
- package/core/host-rules.js +1 -0
- package/core/input.js +1 -1
- package/core/numfmt.js +1 -1
- package/core/precision.js +1 -0
- package/core/protection.js +1 -1
- package/core/region-input.js +1 -1
- package/core/rule-refs.js +1 -0
- package/core/shared-view.js +1 -0
- package/core/sheet.js +1 -1
- package/core/sparklines.js +1 -1
- package/core/sparse.js +1 -1
- package/core/spills.js +1 -0
- package/core/strings.js +1 -1
- package/core/structure.js +1 -1
- package/core/table-columns.js +1 -0
- package/core/tables.js +2 -2
- package/core/validation-ranges.js +1 -1
- package/core/whatif.js +1 -1
- package/core/workbook.js +1 -1
- package/datasheets/formula.js +1 -1
- package/datasheets/manager.js +1 -1
- package/datasheets/path-binding.js +1 -1
- package/datasheets/persist-writer.js +1 -1
- package/datasheets/persist.js +1 -1
- package/datasheets/report.js +1 -1
- package/extras/getdata/persist.js +2 -2
- package/extras/getdata/rows.js +1 -1
- package/extras/getdata/shared-steps.js +1 -0
- package/extras/getdata/steps-formula.js +1 -0
- package/extras/getdata/steps-more.js +1 -0
- package/extras/getdata/steps-tables.js +1 -0
- package/extras/getdata/steps.js +1 -1
- package/i18n/de/a11y.js +1 -0
- package/i18n/de/cells.js +2 -0
- package/i18n/de/charts.js +1 -0
- package/i18n/de/common.js +1 -0
- package/i18n/de/datasheets.js +1 -0
- package/i18n/de/format.js +1 -0
- package/i18n/de/misc.js +1 -0
- package/i18n/de/pivot.js +1 -0
- package/i18n/de/proofing.js +1 -0
- package/i18n/de/ribbon.js +1 -0
- package/i18n/de/shapes.js +1 -0
- package/i18n/de/shell.js +3 -0
- package/i18n/de/touch.js +1 -0
- package/i18n/de.js +1 -0
- package/i18n/en/cells.js +2 -1
- package/i18n/en/charts.js +1 -1
- package/i18n/en/format.js +1 -1
- package/i18n/en/misc.js +1 -1
- package/i18n/en/pivot.js +1 -1
- package/i18n/en/proofing.js +1 -1
- package/i18n/en/ribbon.js +1 -1
- package/i18n/en/shapes.js +1 -1
- package/i18n/en/shell.js +3 -2
- package/i18n/en/touch.js +1 -1
- package/i18n/es/a11y.js +1 -0
- package/i18n/es/cells.js +2 -0
- package/i18n/es/charts.js +1 -0
- package/i18n/es/common.js +1 -0
- package/i18n/es/datasheets.js +1 -0
- package/i18n/es/format.js +1 -0
- package/i18n/es/misc.js +1 -0
- package/i18n/es/pivot.js +1 -0
- package/i18n/es/proofing.js +1 -0
- package/i18n/es/ribbon.js +1 -0
- package/i18n/es/shapes.js +1 -0
- package/i18n/es/shell.js +3 -0
- package/i18n/es/touch.js +1 -0
- package/i18n/es.js +1 -0
- package/i18n/fr/a11y.js +1 -0
- package/i18n/fr/cells.js +2 -0
- package/i18n/fr/charts.js +1 -0
- package/i18n/fr/common.js +1 -0
- package/i18n/fr/datasheets.js +1 -0
- package/i18n/fr/format.js +1 -0
- package/i18n/fr/misc.js +1 -0
- package/i18n/fr/pivot.js +1 -0
- package/i18n/fr/proofing.js +1 -0
- package/i18n/fr/ribbon.js +1 -0
- package/i18n/fr/shapes.js +1 -0
- package/i18n/fr/shell.js +3 -0
- package/i18n/fr/touch.js +1 -0
- package/i18n/fr.js +1 -0
- package/i18n/index.js +1 -1
- package/i18n/languages.js +1 -1
- package/i18n/pl/cells.js +2 -1
- package/i18n/pl/charts.js +1 -1
- package/i18n/pl/format.js +1 -1
- package/i18n/pl/misc.js +1 -1
- package/i18n/pl/pivot.js +1 -1
- package/i18n/pl/proofing.js +1 -1
- package/i18n/pl/ribbon.js +1 -1
- package/i18n/pl/shapes.js +1 -1
- package/i18n/pl/shell.js +3 -2
- package/i18n/pl/touch.js +1 -1
- package/io/blob-sink.js +1 -0
- package/io/canonical-xml.js +1 -0
- package/io/client.js +1 -1
- package/io/crypto/cfb-build.js +1 -0
- package/io/crypto/cfb-read.js +1 -1
- package/io/crypto/cfb-write.js +1 -1
- package/io/crypto/errors.js +1 -1
- package/io/csv.js +8 -8
- package/io/encoding.js +1 -0
- package/io/foreign-sheets.js +2 -2
- package/io/io.worker.js +1 -1
- package/io/open-package.js +1 -0
- package/io/package-paths.js +1 -1
- package/io/plan.js +1 -1
- package/io/text-split.js +3 -3
- package/io/xls/chart-sheet.js +1 -0
- package/io/xls/chart.js +1 -0
- package/io/xls/crypt.js +1 -0
- package/io/xls/dml-color.js +1 -0
- package/io/xls/drawing.js +1 -0
- package/io/xls/formula.js +1 -0
- package/io/xls/geometry.js +1 -0
- package/io/xls/index.js +1 -0
- package/io/xls/pictures.js +1 -0
- package/io/xls/pivot.js +1 -0
- package/io/xls/props.js +1 -0
- package/io/xls/records.js +1 -0
- package/io/xls/shapes.js +1 -0
- package/io/xls/sheet-ext.js +1 -0
- package/io/xls/sheet.js +1 -0
- package/io/xls/styles.js +1 -0
- package/io/xls/vba.js +1 -0
- package/io/xls/workbook.js +1 -0
- package/io/xlsb/filter.js +1 -0
- package/io/xlsb/formula.js +2 -0
- package/io/xlsb/functions.js +1 -0
- package/io/xlsb/index.js +1 -0
- package/io/xlsb/parts.js +1 -0
- package/io/xlsb/pivot.js +1 -0
- package/io/xlsb/records.js +1 -0
- package/io/xlsb/sheet-ext.js +1 -0
- package/io/xlsb/sheet.js +1 -0
- package/io/xlsb/slicer.js +1 -0
- package/io/xlsb/styles.js +1 -0
- package/io/xlsb/workbook.js +1 -0
- package/io/xlsb/xml.js +2 -0
- package/io/xlsx-read.js +1 -1
- package/io/xlsx-styles.js +2 -2
- package/io/xlsx-tail.js +1 -1
- package/io/xlsx-write.js +2 -2
- package/io/xml-escape.js +1 -1
- package/io/xml-scan.js +2 -2
- package/io/zip-reader.js +1 -1
- package/objects/chart-model.js +1 -1
- package/objects/drawing-xml.js +1 -1
- package/package.json +1 -1
- package/pivot/calc-items.js +1 -0
- package/pivot/engine.js +1 -1
- package/pivot/xml.js +2 -2
- package/print/note-pages.js +2 -0
- package/print/page-setup.js +1 -1
- package/print/paginate.js +1 -1
- package/print/pdf-crypt.js +1 -0
- package/print/pdf-links.js +1 -0
- package/print/pdf-tags.js +1 -0
- package/print/pdf.js +24 -13
- package/print/render-page.js +3 -3
- package/print/shown-notes.js +1 -0
- package/shapes/form-xml.js +1 -1
- package/slicers/custom-styles.js +1 -1
- package/slicers/format.js +1 -1
- package/slicers/structured.js +1 -1
- package/slicers/write.js +1 -1
- package/table-view/files.js +1 -1
- package/table-view/mount.js +1 -1
- package/table-view/version.js +1 -1
- package/ui/dialogs.js +3 -3
- package/ui/icons.js +1 -1
- package/ui/menu-base.js +1 -1
- package/ui/protection-ui.js +1 -1
package/print/pdf.js
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
const W=new TextEncoder,M=65536,J=9999999999,K=128,H=()=>{},j=[];for(let o=0;o<256;o++)j.push(o.toString(16).padStart(2,"0"));const F=o=>j[o>>8&255]+j[o&255],b=o=>String(Math.round(o*1e3)/1e3+0),A=o=>Array(10).fill(o),D={Helvetica:[278,278,355,556,556,889,667,191,333,333,389,584,278,333,278,278,...A(556),278,278,584,584,584,556,1015,667,667,722,722,667,611,778,722,278,500,667,556,833,722,778,667,778,722,667,611,722,667,944,667,667,611,278,278,278,469,556,333,556,556,500,556,556,278,556,556,222,222,500,222,833,556,556,556,556,333,500,278,556,500,722,500,500,500,334,260,334,584],"Helvetica-Bold":[278,333,474,556,556,889,722,238,333,333,389,584,278,333,278,278,...A(556),333,333,584,584,584,611,975,722,722,722,722,667,611,778,722,278,556,722,611,833,722,778,667,778,722,667,611,722,667,944,667,667,611,333,278,333,584,556,333,556,611,556,611,556,333,611,611,278,278,556,278,889,611,611,611,611,389,556,333,611,556,778,556,556,500,389,280,389,584],"Times-Roman":[250,333,408,500,500,833,778,180,333,333,500,564,250,333,250,278,...A(500),278,278,564,564,564,444,921,722,667,667,722,611,556,722,722,333,389,722,611,889,722,722,556,722,667,556,611,722,722,944,722,722,611,333,278,333,469,500,333,444,500,444,500,444,333,500,500,278,278,500,278,778,500,500,500,500,333,389,278,500,500,722,500,500,444,480,200,480,541],"Times-Bold":[250,333,555,500,500,1e3,833,278,333,333,500,570,250,333,250,278,...A(500),333,333,570,570,570,500,930,722,667,722,722,667,611,778,778,389,500,778,667,944,722,778,611,778,722,556,667,722,722,1e3,722,722,667,333,278,333,581,500,333,500,556,444,556,444,333,500,556,278,333,556,278,833,556,500,556,556,444,389,333,556,500,722,500,500,444,394,220,394,520],"Times-Italic":[250,333,420,500,500,833,778,214,333,333,500,675,250,333,250,278,...A(500),333,333,675,675,675,500,920,611,611,667,722,611,611,722,722,333,444,667,556,833,667,722,611,722,611,500,556,722,611,833,611,556,556,389,278,389,422,500,333,500,500,444,500,444,278,500,500,278,278,444,278,722,500,500,500,500,389,389,278,500,444,667,444,444,389,400,275,400,541],"Times-BoldItalic":[250,389,555,500,500,833,778,278,333,333,500,570,250,333,250,278,...A(500),333,333,570,570,570,500,832,667,667,667,722,667,667,722,778,389,500,667,611,889,722,722,611,722,667,556,611,722,667,889,667,611,611,333,278,333,570,500,333,500,500,444,500,444,333,500,556,278,278,500,278,778,556,500,500,500,389,389,278,556,444,667,500,444,389,348,220,348,570]};D["Helvetica-Oblique"]=D.Helvetica,D["Helvetica-BoldOblique"]=D["Helvetica-Bold"];const Y=new Map(Object.entries({"€":[556,500],"–":[556,500],"—":[1e3,1e3],"…":[1e3,1e3],"•":[350,350],"‘":[222,333],"’":[222,333],"‚":[222,333],"“":[333,444],"”":[333,444],"„":[333,444],"†":[556,500],"‡":[556,500],"‰":[1e3,1e3],"‹":[333,333],"›":[333,333],ƒ:[556,500],"™":[1e3,980],"ˆ":[333,333],"˜":[333,333],"¡":[333,333],"¢":[556,500],"£":[556,500],"¤":[556,500],"¥":[556,500],"¦":[260,200],"§":[556,500],"¨":[333,333],"©":[737,760],ª:[370,276],"«":[556,500],"¬":[584,564],"®":[737,760],"¯":[333,333],"°":[400,400],"±":[584,564],"²":[333,300],"³":[333,300],"´":[333,333],µ:[556,500],"¶":[537,453],"·":[278,250],"¸":[333,333],"¹":[333,300],º:[365,310],"»":[556,500],"¼":[834,750],"½":[834,750],"¾":[834,750],"¿":[611,444],"×":[584,564],"÷":[584,564],Æ:[1e3,889],æ:[889,667],Œ:[1e3,889],œ:[944,722],Ø:[778,722],ø:[611,500],ß:[611,500],Ð:[722,722],ð:[556,500],Þ:[667,556],þ:[556,500]})),L="€\0‚ƒ„…†‡ˆ‰Š‹Œ\0Ž\0\0‘’“”•–—˜™š›œ\0žŸ",z=[["ą","aogonek"],["Ą","Aogonek"],["ć","cacute"],["Ć","Cacute"],["ę","eogonek"],["Ę","Eogonek"],["ł","lslash"],["Ł","Lslash"],["ń","nacute"],["Ń","Nacute"],["ś","sacute"],["Ś","Sacute"],["ź","zacute"],["Ź","Zacute"],["ż","zdotaccent"],["Ż","Zdotaccent"],["č","ccaron"],["Č","Ccaron"],["ě","ecaron"],["Ě","Ecaron"],["ř","rcaron"],["Ř","Rcaron"],["ů","uring"],["Ů","Uring"],["ő","ohungarumlaut"],["Ő","Ohungarumlaut"],["ű","uhungarumlaut"],["Ű","Uhungarumlaut"],["ň","ncaron"],["ď","dcaron"],["ť","tcaron"]],U=new Map;for(let o=32;o<127;o++)U.set(o,o);for(let o=161;o<=255;o++)U.set(o,o);for(let o=0;o<L.length;o++)L[o]!=="\0"&&U.set(L.codePointAt(o),128+o);z.forEach(([o],t)=>U.set(o.codePointAt(0),t+1));for(const o of[160,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288])U.set(o,32);for(const o of[8208,8209,173])U.set(o,45);U.set(8722,150),U.set(8213,151);const Z=/times|georgia|cambria|garamond|palatino|book antiqua|constantia|baskerville|bookman|century|minion|serif$/,Q=/sans|gothic/,tt=/courier|consolas|menlo|monaco|lucida console|lucida sans typewriter|mono/,et=/aptos narrow|calibri|carlito|arial narrow|corbel|candara/;function st(o,t,e){return tt.test(o)?`Courier${t||e?"-":""}${t?"Bold":""}${e?"Oblique":""}`:Z.test(o)&&!Q.test(o)?t?e?"Times-BoldItalic":"Times-Bold":e?"Times-Italic":"Times-Roman":`Helvetica${t||e?"-":""}${t?"Bold":""}${e?"Oblique":""}`}class it{constructor(t,e,s){this.name=t,this.resId=e,this.objectId=s,this.mono=t.startsWith("Courier"),this.serif=t.startsWith("Times"),this.table=D[t]??null,this.ascent=this.mono?.629:this.serif?.683:.718,this.descent=this.mono?.157:this.serif?.217:.207,this.widths=new Map}width(t){if(this.mono)return 600;if(t>=32&&t<127)return this.table[t-32];let e=this.widths.get(t);return e===void 0&&(e=this._extraWidth(t),this.widths.set(t,e)),e}_extraWidth(t){const e=String.fromCodePoint(t),s=Y.get(e);if(s)return s[this.serif?1:0];if(e==="ł")return this.table[76];if(e==="Ł")return this.table[44];const i=U.get(t);if(i===32)return this.table[0];if(i===45)return this.table[13];const n=e.normalize("NFD").codePointAt(0);return n>=32&&n<127?this.table[n-32]:this.serif?500:556}}function N(o){const t=String.fromCodePoint(o).normalize("NFD").codePointAt(0);return U.has(t)?t:63}class nt{constructor(t,e={}){this.bytes=ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.tables=this._openFace(e.postscriptName);for(const h of["head","hhea","hmtx","maxp","cmap","loca","glyf"])if(!this.tables.has(h))throw new Error(`Font has no ${h} table, so it isn't TrueType`);const s=this.view,i=this.tables.get("head").offset,n=this.tables.get("hhea").offset;this.unitsPerEm=s.getUint16(i+18)||1e3,this.bbox=[s.getInt16(i+36),s.getInt16(i+38),s.getInt16(i+40),s.getInt16(i+42)];const a=s.getUint16(i+44);this.longLoca=s.getInt16(i+50)!==0,this.ascentUnits=s.getInt16(n+4),this.descentUnits=s.getInt16(n+6),this.numHMetrics=s.getUint16(n+34),this.numGlyphs=s.getUint16(this.tables.get("maxp").offset+4),this.italicAngle=this.tables.has("post")?s.getInt32(this.tables.get("post").offset+4)/65536:0,this.capHeightUnits=this.ascentUnits;const r=this.tables.get("OS/2");if(r){if((s.getUint16(r.offset+8)&15)===2)throw new Error("Font license forbids embedding");s.getUint16(r.offset)>=2&&r.length>=90&&(this.capHeightUnits=s.getInt16(r.offset+88)||this.ascentUnits)}const l=this._names();this.family=e.family??l.family??"Embedded",this.postscriptName=(l.postscript??this.family).replace(/[^A-Za-z0-9-]/g,""),this.bold=e.bold??(a&1)!==0,this.italic=e.italic??(a&2)!==0,this.scale=1e3/this.unitsPerEm,this.ascent=this.ascentUnits/this.unitsPerEm,this.descent=-this.descentUnits/this.unitsPerEm,this.lookup=this._cmap(),this.gids=new Map,this.order=[0],this.newIds=new Map([[0,0]]),this.unicode=[],this.resId=0,this.objectId=0}_openFace(t){const e=this.view,s=e.getUint32(0);if(s===1330926671)throw new Error("OpenType/CFF fonts are not supported");if(s===1953784678){const i=e.getUint32(8);let n=null;for(let a=0;a<i;a++){const r=this._directory(e.getUint32(12+a*4));if(n===null&&(n=r),t&&this._names(r).postscript===t)return r}if(n===null)throw new Error("Empty font collection");return n}if(s!==65536&&s!==1953658213)throw new Error("Not a TrueType font");return this._directory(0)}_directory(t){const e=this.view,s=e.getUint16(t+4),i=new Map;for(let n=0;n<s;n++){const a=t+12+n*16,r=String.fromCharCode(e.getUint8(a),e.getUint8(a+1),e.getUint8(a+2),e.getUint8(a+3));i.set(r,{offset:e.getUint32(a+8),length:e.getUint32(a+12)})}return i}_names(t=this.tables){const e={},s=t.get("name");if(!s)return e;const i=this.view,n=i.getUint16(s.offset+2),a=s.offset+i.getUint16(s.offset+4);for(let r=0;r<n;r++){const l=s.offset+6+r*12,h=i.getUint16(l),c=i.getUint16(l+6);if(c!==1&&c!==6)continue;const d=i.getUint16(l+8),g=a+i.getUint16(l+10);let f="";if(h===3||h===0)for(let m=0;m+1<d;m+=2)f+=String.fromCharCode(i.getUint16(g+m));else for(let m=0;m<d;m++)f+=String.fromCharCode(i.getUint8(g+m));const u=c===1?"family":"postscript";(e[u]===void 0||h===3)&&(e[u]=f)}return e}_cmap(){const t=this.view,e=this.tables.get("cmap").offset,s=t.getUint16(e+2);let i=null,n=-1;for(let u=0;u<s;u++){const m=e+4+u*8,w=t.getUint16(m),x=t.getUint16(m+2),y=e+t.getUint32(m+4),$=t.getUint16(y);if($!==4&&$!==12&&$!==6)continue;let I=-1;w===3&&x===10?I=4:w===0&&$===12?I=3:w===3&&x===1?I=2:w===0&&(I=1),I>n&&(n=I,i={at:y,format:$})}if(i===null)throw new Error("Font has no Unicode cmap");const{at:a,format:r}=i;if(r===12){const u=t.getUint32(a+12);return m=>{let w=0,x=u-1;for(;w<=x;){const y=w+x>>>1,$=a+16+y*12;if(m<t.getUint32($))x=y-1;else if(m>t.getUint32($+4))w=y+1;else return t.getUint32($+8)+m-t.getUint32($)}return 0}}if(r===6){const u=t.getUint16(a+6),m=t.getUint16(a+8);return w=>w>=u&&w<u+m?t.getUint16(a+10+(w-u)*2):0}const l=t.getUint16(a+6),h=a+14,c=h+l+2,d=c+l,g=d+l,f=l/2;return u=>{if(u>65535)return 0;let m=0,w=f-1;for(;m<w;){const p=m+w>>>1;t.getUint16(h+p*2)<u?m=p+1:w=p}const x=t.getUint16(c+m*2);if(u<x||u>t.getUint16(h+m*2))return 0;const y=t.getInt16(d+m*2),$=t.getUint16(g+m*2);if($===0)return u+y&65535;const I=t.getUint16(g+m*2+$+(u-x)*2);return I===0?0:I+y&65535}}gidOf(t){let e=this.gids.get(t);return e===void 0&&(e=this.lookup(t),e>=this.numGlyphs&&(e=0),this.gids.set(t,e)),e}_rawAdvance(t){const e=this.tables.get("hmtx").offset;return this.view.getUint16(e+Math.min(t,this.numHMetrics-1)*4)}_rawLsb(t){const e=this.tables.get("hmtx").offset;return t<this.numHMetrics?this.view.getInt16(e+t*4+2):this.view.getInt16(e+this.numHMetrics*4+(t-this.numHMetrics)*2)}width(t){return this._rawAdvance(this.gidOf(t))*this.scale}_newId(t){let e=this.newIds.get(t);return e===void 0&&(e=this.order.length,this.order.push(t),this.newIds.set(t,e)),e}use(t){const e=this._newId(this.gidOf(t));return this.unicode[e]===void 0&&(this.unicode[e]=t),e}_glyphRange(t){const e=this.tables.get("loca").offset,s=this.tables.get("glyf").offset,i=this.view,n=this.longLoca?i.getUint32(e+t*4):i.getUint16(e+t*2)*2,a=this.longLoca?i.getUint32(e+(t+1)*4):i.getUint16(e+(t+1)*2)*2;return[s+n,a-n]}_copyTable(t){const e=this.tables.get(t);return e?this.bytes.slice(e.offset,e.offset+e.length):null}subset(){const t=[];for(let p=0;p<this.order.length;p++){const[_,T]=this._glyphRange(this.order[p]);if(T<=0){t.push(null);continue}const k=this.bytes.slice(_,_+T),C=new DataView(k.buffer);if(C.getInt16(0)<0){let S=10;for(;;){const v=C.getUint16(S);if(C.setUint16(S+2,this._newId(C.getUint16(S+2))),S+=4+(v&1?4:2),v&8?S+=2:v&64?S+=4:v&128&&(S+=8),!(v&32))break}}t.push(k)}const e=this.order.length,s=new Uint8Array((e+1)*4),i=new DataView(s.buffer);let n=0;for(let p=0;p<e;p++)i.setUint32(p*4,n),t[p]&&(n+=t[p].length+3&-4);i.setUint32(e*4,n);const a=new Uint8Array(n);for(let p=0;p<e;p++)t[p]&&a.set(t[p],i.getUint32(p*4));const r=new Uint8Array(e*4),l=new DataView(r.buffer);for(let p=0;p<e;p++)l.setUint16(p*4,this._rawAdvance(this.order[p])),l.setInt16(p*4+2,this._rawLsb(this.order[p]));const h=this._copyTable("head"),c=new DataView(h.buffer);c.setUint32(8,0),c.setInt16(50,1);const d=this._copyTable("hhea");new DataView(d.buffer).setUint16(34,e);const g=this._copyTable("maxp");new DataView(g.buffer).setUint16(4,e);const f=[["glyf",a],["head",h],["hhea",d],["hmtx",r],["loca",s],["maxp",g]];for(const p of["cvt ","fpgm","prep"]){const _=this._copyTable(p);_&&f.push([p,_])}f.sort((p,_)=>p[0]<_[0]?-1:1);let u=12+f.length*16;for(const[,p]of f)u+=p.length+3&-4;const m=new Uint8Array(u),w=new DataView(m.buffer),x=f.length,y=31-Math.clz32(x);w.setUint32(0,65536),w.setUint16(4,x),w.setUint16(6,16<<y),w.setUint16(8,y),w.setUint16(10,x*16-(16<<y));let $=12+x*16,I=0;return f.forEach(([p,_],T)=>{const k=12+T*16;for(let C=0;C<4;C++)w.setUint8(k+C,p.charCodeAt(C));w.setUint32(k+4,q(_)),w.setUint32(k+8,$),w.setUint32(k+12,_.length),m.set(_,$),p==="head"&&(I=$),$+=_.length+3&-4}),w.setUint32(I+8,2981146554-q(m)>>>0),m}}function q(o){let t=0;const e=o.length;for(let s=0;s<e;s+=4){const i=(o[s]<<24|(o[s+1]??0)<<16|(o[s+2]??0)<<8|(o[s+3]??0))>>>0;t=t+i>>>0}return t}const ot={black:"000000",white:"ffffff",red:"ff0000",green:"008000",blue:"0000ff",yellow:"ffff00",orange:"ffa500",purple:"800080",gray:"808080",grey:"808080",silver:"c0c0c0",maroon:"800000",navy:"000080",teal:"008080",olive:"808000",lime:"00ff00",aqua:"00ffff",cyan:"00ffff",fuchsia:"ff00ff",magenta:"ff00ff",pink:"ffc0cb",brown:"a52a2a",lightgray:"d3d3d3",lightgrey:"d3d3d3",darkgray:"a9a9a9",darkgrey:"a9a9a9"},B=new Map;function E(o){const t=String(o);let e=B.get(t);return e!==void 0||(e=at(t.trim().toLowerCase()),B.size>4096&&B.clear(),B.set(t,e)),e}function at(o){if(o==="transparent")return{r:0,g:0,b:0,a:0,ops:"0 0 0"};let t=ot[o]??null;t===null&&o[0]==="#"&&(t=o.slice(1),(t.length===3||t.length===4)&&(t=[...t].map(r=>r+r).join("")));let e,s,i,n=1;if(t!==null){if(!/^[0-9a-f]{6}([0-9a-f]{2})?$/.test(t))return null;e=parseInt(t.slice(0,2),16),s=parseInt(t.slice(2,4),16),i=parseInt(t.slice(4,6),16),t.length===8&&(n=parseInt(t.slice(6,8),16)/255)}else{const r=/^rgba?\(\s*([\d.]+%?)[\s,]+([\d.]+%?)[\s,]+([\d.]+%?)(?:[\s,/]+([\d.]+%?))?\s*\)$/.exec(o);if(!r)return null;const l=h=>h.endsWith("%")?parseFloat(h)*2.55:parseFloat(h);e=l(r[1]),s=l(r[2]),i=l(r[3]),r[4]!==void 0&&(n=r[4].endsWith("%")?parseFloat(r[4])/100:parseFloat(r[4]))}const a=r=>b(Math.min(255,Math.max(0,r))/255);return{r:e,g:s,b:i,a:n,ops:`${a(e)} ${a(s)} ${a(i)}`}}class R{constructor(){this.color=null}addColorStop(t,e){this.color===null&&(this.color=e)}}const ht=()=>({a:1,b:0,c:0,d:1,e:0,f:0,fill:E("#000000"),fillText:"#000000",stroke:E("#000000"),strokeText:"#000000",lineWidth:1,lineCap:"butt",lineJoin:"miter",miterLimit:10,dash:[],dashOffset:0,alpha:1,font:"10px sans-serif",spec:null,textAlign:"start",textBaseline:"alphabetic"}),rt=()=>({fill:null,stroke:null,width:1,dash:"[] 0",cap:0,join:0,miter:10,alpha:1});class ct{constructor(t,e,s){this.writer=t,this.canvas={width:e,height:s},this.pageWidth=e,this.pageHeight=s,this.ops=[],this.fonts=new Set,this.images=new Set,this.alphas=new Set,this.s=ht(),this.stack=[],this.emitted=rt(),this.emittedStack=[],this.path=[],this.cx=0,this.cy=0,this.imageSmoothingEnabled=!0,this.globalCompositeOperation="source-over",this.shadowBlur=0,this.shadowColor="transparent",this.shadowOffsetX=0,this.shadowOffsetY=0,this.fontKerning="auto",this.direction="ltr"}save(){this.stack.push({...this.s}),this.emittedStack.push({...this.emitted}),this.ops.push("q")}restore(){this.stack.length!==0&&(this.s=this.stack.pop(),this.emitted=this.emittedStack.pop(),this.ops.push("Q"))}get fillStyle(){return this.s.fillText}set fillStyle(t){const e=t instanceof R?t.color??"#000000":t,s=E(e);s!==null&&(this.s.fill=s,this.s.fillText=e)}get strokeStyle(){return this.s.strokeText}set strokeStyle(t){const e=t instanceof R?t.color??"#000000":t,s=E(e);s!==null&&(this.s.stroke=s,this.s.strokeText=e)}get lineWidth(){return this.s.lineWidth}set lineWidth(t){t>0&&(this.s.lineWidth=t)}get lineCap(){return this.s.lineCap}set lineCap(t){this.s.lineCap=t}get lineJoin(){return this.s.lineJoin}set lineJoin(t){this.s.lineJoin=t}get miterLimit(){return this.s.miterLimit}set miterLimit(t){this.s.miterLimit=t}get lineDashOffset(){return this.s.dashOffset}set lineDashOffset(t){this.s.dashOffset=t}get globalAlpha(){return this.s.alpha}set globalAlpha(t){t>=0&&t<=1&&(this.s.alpha=t)}get textAlign(){return this.s.textAlign}set textAlign(t){this.s.textAlign=t}get textBaseline(){return this.s.textBaseline}set textBaseline(t){this.s.textBaseline=t}get font(){return this.s.font}set font(t){this.s.font=t,this.s.spec=null}setLineDash(t){this.s.dash=t.slice()}getLineDash(){return this.s.dash.slice()}translate(t,e){const s=this.s;s.e+=s.a*t+s.c*e,s.f+=s.b*t+s.d*e}scale(t,e){const s=this.s;s.a*=t,s.b*=t,s.c*=e,s.d*=e}rotate(t){const e=Math.cos(t),s=Math.sin(t);this.transform(e,s,-s,e,0,0)}transform(t,e,s,i,n,a){const r=this.s,{a:l,b:h,c,d,e:g,f}=r;r.a=l*t+c*e,r.b=h*t+d*e,r.c=l*s+c*i,r.d=h*s+d*i,r.e=l*n+c*a+g,r.f=h*n+d*a+f}setTransform(t,e,s,i,n,a){const r=this.s;typeof t=="object"&&t!==null&&({a:t,b:e,c:s,d:i,e:n,f:a}=t),r.a=t,r.b=e,r.c=s,r.d=i,r.e=n,r.f=a}resetTransform(){this.setTransform(1,0,0,1,0,0)}getTransform(){const{a:t,b:e,c:s,d:i,e:n,f:a}=this.s;return{a:t,b:e,c:s,d:i,e:n,f:a}}_X(t,e){const s=this.s;return s.a*t+s.c*e+s.e}_Y(t,e){const s=this.s;return this.pageHeight-(s.b*t+s.d*e+s.f)}_pt(t,e){return`${b(this._X(t,e))} ${b(this._Y(t,e))}`}beginPath(){this.path=[]}moveTo(t,e){this.path.push(`${this._pt(t,e)} m`),this.cx=t,this.cy=e}lineTo(t,e){this.path.push(`${this._pt(t,e)} ${this.path.length===0?"m":"l"}`),this.cx=t,this.cy=e}closePath(){this.path.length>0&&this.path.push("h")}bezierCurveTo(t,e,s,i,n,a){this.path.length===0&&this.moveTo(t,e),this.path.push(`${this._pt(t,e)} ${this._pt(s,i)} ${this._pt(n,a)} c`),this.cx=n,this.cy=a}quadraticCurveTo(t,e,s,i){this.path.length===0&&this.moveTo(t,e);const{cx:n,cy:a}=this;this.bezierCurveTo(n+2/3*(t-n),a+2/3*(e-a),s+2/3*(t-s),i+2/3*(e-i),s,i)}rect(t,e,s,i){const n=this.s;n.b===0&&n.c===0?this.path.push(`${this._pt(t,e)} ${b(n.a*s)} ${b(-n.d*i)} re`):this.path.push(`${this._pt(t,e)} m ${this._pt(t+s,e)} l ${this._pt(t+s,e+i)} l ${this._pt(t,e+i)} l h`),this.cx=t,this.cy=e}roundRect(t,e,s,i,n=0){const a=Math.min(Math.abs(Array.isArray(n)?Number(n[0])||0:Number(n)||0),Math.abs(s)/2,Math.abs(i)/2);if(a===0){this.rect(t,e,s,i);return}this.moveTo(t+a,e),this.lineTo(t+s-a,e),this.quadraticCurveTo(t+s,e,t+s,e+a),this.lineTo(t+s,e+i-a),this.quadraticCurveTo(t+s,e+i,t+s-a,e+i),this.lineTo(t+a,e+i),this.quadraticCurveTo(t,e+i,t,e+i-a),this.lineTo(t,e+a),this.quadraticCurveTo(t,e,t+a,e),this.closePath()}arc(t,e,s,i,n,a=!1){this.ellipse(t,e,s,s,0,i,n,a)}ellipse(t,e,s,i,n,a,r,l=!1){let h=r-a;const c=Math.PI*2;!l&&h<0&&(h=h%c+c),l&&h>0&&(h=h%c-c),Math.abs(r-a)>=c&&(h=l?-c:c);const d=Math.cos(n),g=Math.sin(n),f=p=>{const _=s*Math.cos(p),T=i*Math.sin(p);return[t+_*d-T*g,e+_*g+T*d]},u=p=>{const _=-s*Math.sin(p),T=i*Math.cos(p);return[_*d-T*g,_*g+T*d]},m=Math.max(1,Math.ceil(Math.abs(h)/(Math.PI/2))),w=h/m,x=4/3*Math.tan(w/4),[y,$]=f(a);this.path.length===0?this.moveTo(y,$):this.lineTo(y,$);let I=a;for(let p=0;p<m;p++){const _=I+w,[T,k]=f(I),[C,S]=f(_),[v,V]=u(I),[G,X]=u(_);this.bezierCurveTo(T+x*v,k+x*V,C-x*G,S-x*X,C,S),I=_}}_applyAlpha(t){const e=Math.round(this.s.alpha*t*100);e!==Math.round(this.emitted.alpha*100)&&(this.emitted.alpha=e/100,this.alphas.add(e),this.ops.push(`/A${e} gs`))}_applyFill(){const t=this.s.fill;this._applyAlpha(t.a),this.emitted.fill!==t.ops&&(this.emitted.fill=t.ops,this.ops.push(`${t.ops} rg`))}_applyStroke(){const{s:t,emitted:e,ops:s}=this;this._applyAlpha(t.stroke.a),e.stroke!==t.stroke.ops&&(e.stroke=t.stroke.ops,s.push(`${t.stroke.ops} RG`));const i=Math.sqrt(Math.abs(t.a*t.d-t.b*t.c))||1,n=t.lineWidth*i;e.width!==n&&(e.width=n,s.push(`${b(n)} w`));const a=`[${t.dash.map(h=>b(h*i)).join(" ")}] ${b(t.dashOffset*i)}`;e.dash!==a&&(e.dash=a,s.push(`${a} d`));const r=t.lineCap==="round"?1:t.lineCap==="square"?2:0;e.cap!==r&&(e.cap=r,s.push(`${r} J`));const l=t.lineJoin==="round"?1:t.lineJoin==="bevel"?2:0;e.join!==l&&(e.join=l,s.push(`${l} j`)),e.miter!==t.miterLimit&&(e.miter=t.miterLimit,s.push(`${b(t.miterLimit)} M`))}fill(t){this.path.length!==0&&(this._applyFill(),this.ops.push(`${this.path.join(" ")} ${t==="evenodd"?"f*":"f"}`))}stroke(){this.path.length!==0&&(this._applyStroke(),this.ops.push(`${this.path.join(" ")} S`))}clip(t){this.ops.push(`${this.path.length?`${this.path.join(" ")} `:"0 0 0 0 re "}${t==="evenodd"?"W*":"W"} n`)}fillRect(t,e,s,i){this._applyFill();const n=this.s;n.b===0&&n.c===0?this.ops.push(`${this._pt(t,e)} ${b(n.a*s)} ${b(-n.d*i)} re f`):this.ops.push(`${this._pt(t,e)} m ${this._pt(t+s,e)} l ${this._pt(t+s,e+i)} l ${this._pt(t,e+i)} l h f`)}strokeRect(t,e,s,i){const n=this.path;this.path=[],this.rect(t,e,s,i),this.stroke(),this.path=n}clearRect(t,e,s,i){this.ops.push("q 1 1 1 rg");const n=this.s;n.b===0&&n.c===0?this.ops.push(`${this._pt(t,e)} ${b(n.a*s)} ${b(-n.d*i)} re f`):this.ops.push(`${this._pt(t,e)} m ${this._pt(t+s,e)} l ${this._pt(t+s,e+i)} l ${this._pt(t,e+i)} l h f`),this.ops.push("Q")}createLinearGradient(){return new R}createRadialGradient(){return new R}createConicGradient(){return new R}createPattern(){return null}_spec(){const t=this.s;return t.spec===null&&(t.spec=this.writer._fontSpec(t.font)),t.spec}measureText(t){const e=this._spec(),s=this.writer._measure(String(t),e),i=e.size*e.ascent,n=e.size*e.descent;return{width:s,actualBoundingBoxLeft:0,actualBoundingBoxRight:s,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,fontBoundingBoxAscent:i,fontBoundingBoxDescent:n}}fillText(t,e,s){this._text(String(t),e,s,!1)}strokeText(t,e,s){this._text(String(t),e,s,!0)}_text(t,e,s,i){if(t==="")return;const n=this._spec(),{writer:a,s:r}=this,l=a._runs(t,n);let h=0;for(const f of l)h+=f.width;const c=r.textAlign;switch(c==="center"?e-=h/2:(c==="right"||c==="end")&&(e-=h),r.textBaseline){case"top":s+=n.size*n.ascent;break;case"hanging":s+=n.size*n.ascent*.8;break;case"middle":s+=n.size*(n.ascent-n.descent)/2;break;case"bottom":case"ideographic":s-=n.size*n.descent;break;default:}i?this._applyStroke():this._applyFill();const d=b(n.size);let g=e;for(const f of l){this.fonts.add(f.font);const u=f.hScale,m=`${b(r.a*u)} ${b(-r.b*u)} ${b(-r.c)} ${b(r.d)} ${b(this._X(g,s))} ${b(this._Y(g,s))}`;this.ops.push(`BT${i?" 1 Tr":""} /F${f.font.resId} ${d} Tf ${m} Tm <${f.hex}> Tj${i?" 0 Tr":""} ET`),g+=f.width}}drawImage(t,...e){const s=this.writer._image(t);if(s===null)return;this.images.add(s);let i=0,n=0,a=s.width,r=s.height,l,h,c,d;if(e.length>=8?[i,n,a,r,l,h,c,d]=e:e.length>=4?[l,h,c,d]=e:([l,h]=e,c=s.width,d=s.height),this._applyAlpha(1),this.ops.push("q"),e.length>=8){const $=this.path;this.path=[],this.rect(l,h,c,d),this.ops.push(`${this.path.join(" ")} W n`),this.path=$;const I=c/a,p=d/r;l-=i*I,h-=n*p,c=s.width*I,d=s.height*p}const g=this.s,f=g.a*c,u=-g.b*c,m=-g.c*d,w=g.d*d,x=this._X(l,h+d),y=this._Y(l,h+d);this.ops.push(`${b(f)} ${b(u)} ${b(m)} ${b(w)} ${b(x)} ${b(y)} cm /Im${s.resId} Do Q`)}}function lt(o){const t=(e,s=2)=>String(e).padStart(s,"0");return`D:${t(o.getUTCFullYear(),4)}${t(o.getUTCMonth()+1)}${t(o.getUTCDate())}${t(o.getUTCHours())}${t(o.getUTCMinutes())}${t(o.getUTCSeconds())}Z`}function O(o){let t="FEFF";for(let e=0;e<o.length;e++)t+=F(o.charCodeAt(e));return`<${t}>`}function ft(o){let t=2;for(;t+9<o.length;){if(o[t]!==255){t++;continue}const e=o[t+1];if(e>=192&&e<=207&&e!==196&&e!==200&&e!==204)return{height:o[t+5]<<8|o[t+6],width:o[t+7]<<8|o[t+8],components:o[t+9]};t+=2+(o[t+2]<<8|o[t+3])}return null}class wt{constructor(t,e={}){this.sink=t,this.options=e,this.compress=e.compress!==!1&&typeof CompressionStream<"u",this.offset=0,this.buffer=new Uint8Array(M),this.pos=0,this.xref=new Float64Array(1024),this.nextId=1,this.started=!1,this.finished=!1,this.page=null,this.pageCount=0,this.levels=[],this.faces=[],this.stdFonts=new Map,this.encodingId=0,this.nextFontRes=1,this.nextImageRes=1,this.imageIds=new WeakMap,this.pendingImages=[],this.specs=new Map,this.missing=new Set,this.fontWarnings=[];for(const s of e.fonts??[])this.registerFont(s)}registerFont(t){try{const e=new nt(t.bytes,t);return e.familyKey=e.family.toLowerCase(),this.faces.push(e),this.specs.clear(),!0}catch(e){return this.fontWarnings.push(`${t.family??"font"}: ${e.message}`),!1}}async _raw(t){const e=t.length;if(this.offset+=e,e>=M/2){await this._flush(),await this.sink.write(t);return}this.pos+e>M&&await this._flush(),this.buffer.set(t,this.pos),this.pos+=e}async _flush(){if(this.pos===0)return;const t=this.buffer.slice(0,this.pos);this.pos=0,await this.sink.write(t)}_w(t){return this._raw(W.encode(t))}_alloc(){const t=this.nextId++;if(t>=this.xref.length){const e=new Float64Array(this.xref.length*2);e.set(this.xref),this.xref=e}return t}async _obj(t,e){this.xref[t]=this.offset,await this._w(`${t} 0 obj
|
|
1
|
+
import{encryptedString as J,newPdfEncryption as Z,StreamCipher as Q}from"./pdf-crypt.js";import{PageMarks as tt,Structure as et}from"./pdf-tags.js";const M=new TextEncoder,j=65536,st=9999999999,it=128,B=200,L=9,N=16384,H=()=>{},v=[];for(let o=0;o<256;o++)v.push(o.toString(16).padStart(2,"0"));const R=o=>v[o>>8&255]+v[o&255],b=o=>String(Math.round(o*1e3)/1e3+0),A=o=>Array(10).fill(o),D={Helvetica:[278,278,355,556,556,889,667,191,333,333,389,584,278,333,278,278,...A(556),278,278,584,584,584,556,1015,667,667,722,722,667,611,778,722,278,500,667,556,833,722,778,667,778,722,667,611,722,667,944,667,667,611,278,278,278,469,556,333,556,556,500,556,556,278,556,556,222,222,500,222,833,556,556,556,556,333,500,278,556,500,722,500,500,500,334,260,334,584],"Helvetica-Bold":[278,333,474,556,556,889,722,238,333,333,389,584,278,333,278,278,...A(556),333,333,584,584,584,611,975,722,722,722,722,667,611,778,722,278,556,722,611,833,722,778,667,778,722,667,611,722,667,944,667,667,611,333,278,333,584,556,333,556,611,556,611,556,333,611,611,278,278,556,278,889,611,611,611,611,389,556,333,611,556,778,556,556,500,389,280,389,584],"Times-Roman":[250,333,408,500,500,833,778,180,333,333,500,564,250,333,250,278,...A(500),278,278,564,564,564,444,921,722,667,667,722,611,556,722,722,333,389,722,611,889,722,722,556,722,667,556,611,722,722,944,722,722,611,333,278,333,469,500,333,444,500,444,500,444,333,500,500,278,278,500,278,778,500,500,500,500,333,389,278,500,500,722,500,500,444,480,200,480,541],"Times-Bold":[250,333,555,500,500,1e3,833,278,333,333,500,570,250,333,250,278,...A(500),333,333,570,570,570,500,930,722,667,722,722,667,611,778,778,389,500,778,667,944,722,778,611,778,722,556,667,722,722,1e3,722,722,667,333,278,333,581,500,333,500,556,444,556,444,333,500,556,278,333,556,278,833,556,500,556,556,444,389,333,556,500,722,500,500,444,394,220,394,520],"Times-Italic":[250,333,420,500,500,833,778,214,333,333,500,675,250,333,250,278,...A(500),333,333,675,675,675,500,920,611,611,667,722,611,611,722,722,333,444,667,556,833,667,722,611,722,611,500,556,722,611,833,611,556,556,389,278,389,422,500,333,500,500,444,500,444,278,500,500,278,278,444,278,722,500,500,500,500,389,389,278,500,444,667,444,444,389,400,275,400,541],"Times-BoldItalic":[250,389,555,500,500,833,778,278,333,333,500,570,250,333,250,278,...A(500),333,333,570,570,570,500,832,667,667,667,722,667,667,722,778,389,500,667,611,889,722,722,611,722,667,556,611,722,667,889,667,611,611,333,278,333,570,500,333,500,500,444,500,444,333,500,556,278,278,500,278,778,556,500,500,500,389,389,278,556,444,667,500,444,389,348,220,348,570]};D["Helvetica-Oblique"]=D.Helvetica,D["Helvetica-BoldOblique"]=D["Helvetica-Bold"];const nt=new Map(Object.entries({"€":[556,500],"–":[556,500],"—":[1e3,1e3],"…":[1e3,1e3],"•":[350,350],"‘":[222,333],"’":[222,333],"‚":[222,333],"“":[333,444],"”":[333,444],"„":[333,444],"†":[556,500],"‡":[556,500],"‰":[1e3,1e3],"‹":[333,333],"›":[333,333],ƒ:[556,500],"™":[1e3,980],"ˆ":[333,333],"˜":[333,333],"¡":[333,333],"¢":[556,500],"£":[556,500],"¤":[556,500],"¥":[556,500],"¦":[260,200],"§":[556,500],"¨":[333,333],"©":[737,760],ª:[370,276],"«":[556,500],"¬":[584,564],"®":[737,760],"¯":[333,333],"°":[400,400],"±":[584,564],"²":[333,300],"³":[333,300],"´":[333,333],µ:[556,500],"¶":[537,453],"·":[278,250],"¸":[333,333],"¹":[333,300],º:[365,310],"»":[556,500],"¼":[834,750],"½":[834,750],"¾":[834,750],"¿":[611,444],"×":[584,564],"÷":[584,564],Æ:[1e3,889],æ:[889,667],Œ:[1e3,889],œ:[944,722],Ø:[778,722],ø:[611,500],ß:[611,500],Ð:[722,722],ð:[556,500],Þ:[667,556],þ:[556,500]})),z="€\0‚ƒ„…†‡ˆ‰Š‹Œ\0Ž\0\0‘’“”•–—˜™š›œ\0žŸ",q=[["ą","aogonek"],["Ą","Aogonek"],["ć","cacute"],["Ć","Cacute"],["ę","eogonek"],["Ę","Eogonek"],["ł","lslash"],["Ł","Lslash"],["ń","nacute"],["Ń","Nacute"],["ś","sacute"],["Ś","Sacute"],["ź","zacute"],["Ź","Zacute"],["ż","zdotaccent"],["Ż","Zdotaccent"],["č","ccaron"],["Č","Ccaron"],["ě","ecaron"],["Ě","Ecaron"],["ř","rcaron"],["Ř","Rcaron"],["ů","uring"],["Ů","Uring"],["ő","ohungarumlaut"],["Ő","Ohungarumlaut"],["ű","uhungarumlaut"],["Ű","Uhungarumlaut"],["ň","ncaron"],["ď","dcaron"],["ť","tcaron"]],U=new Map;for(let o=32;o<127;o++)U.set(o,o);for(let o=161;o<=255;o++)U.set(o,o);for(let o=0;o<z.length;o++)z[o]!=="\0"&&U.set(z.codePointAt(o),128+o);q.forEach(([o],t)=>U.set(o.codePointAt(0),t+1));for(const o of[160,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288])U.set(o,32);for(const o of[8208,8209,173])U.set(o,45);U.set(8722,150),U.set(8213,151);const at=/times|georgia|cambria|garamond|palatino|book antiqua|constantia|baskerville|bookman|century|minion|serif$/,ot=/sans|gothic/,rt=/courier|consolas|menlo|monaco|lucida console|lucida sans typewriter|mono/,ht=/aptos narrow|calibri|carlito|arial narrow|corbel|candara/;function ct(o,t,e){return rt.test(o)?`Courier${t||e?"-":""}${t?"Bold":""}${e?"Oblique":""}`:at.test(o)&&!ot.test(o)?t?e?"Times-BoldItalic":"Times-Bold":e?"Times-Italic":"Times-Roman":`Helvetica${t||e?"-":""}${t?"Bold":""}${e?"Oblique":""}`}class lt{constructor(t,e,s){this.name=t,this.resId=e,this.objectId=s,this.mono=t.startsWith("Courier"),this.serif=t.startsWith("Times"),this.table=D[t]??null,this.ascent=this.mono?.629:this.serif?.683:.718,this.descent=this.mono?.157:this.serif?.217:.207,this.widths=new Map}width(t){if(this.mono)return 600;if(t>=32&&t<127)return this.table[t-32];let e=this.widths.get(t);return e===void 0&&(e=this._extraWidth(t),this.widths.set(t,e)),e}_extraWidth(t){const e=String.fromCodePoint(t),s=nt.get(e);if(s)return s[this.serif?1:0];if(e==="ł")return this.table[76];if(e==="Ł")return this.table[44];const i=U.get(t);if(i===32)return this.table[0];if(i===45)return this.table[13];const n=e.normalize("NFD").codePointAt(0);return n>=32&&n<127?this.table[n-32]:this.serif?500:556}}function V(o){const t=String.fromCodePoint(o).normalize("NFD").codePointAt(0);return U.has(t)?t:63}class ft{constructor(t,e={}){this.bytes=ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.tables=this._openFace(e.postscriptName);for(const h of["head","hhea","hmtx","maxp","cmap","loca","glyf"])if(!this.tables.has(h))throw new Error(`Font has no ${h} table, so it isn't TrueType`);const s=this.view,i=this.tables.get("head").offset,n=this.tables.get("hhea").offset;this.unitsPerEm=s.getUint16(i+18)||1e3,this.bbox=[s.getInt16(i+36),s.getInt16(i+38),s.getInt16(i+40),s.getInt16(i+42)];const a=s.getUint16(i+44);this.longLoca=s.getInt16(i+50)!==0,this.ascentUnits=s.getInt16(n+4),this.descentUnits=s.getInt16(n+6),this.numHMetrics=s.getUint16(n+34),this.numGlyphs=s.getUint16(this.tables.get("maxp").offset+4),this.italicAngle=this.tables.has("post")?s.getInt32(this.tables.get("post").offset+4)/65536:0,this.capHeightUnits=this.ascentUnits;const r=this.tables.get("OS/2");if(r){if((s.getUint16(r.offset+8)&15)===2)throw new Error("Font license forbids embedding");s.getUint16(r.offset)>=2&&r.length>=90&&(this.capHeightUnits=s.getInt16(r.offset+88)||this.ascentUnits)}const l=this._names();this.family=e.family??l.family??"Embedded",this.postscriptName=(l.postscript??this.family).replace(/[^A-Za-z0-9-]/g,""),this.bold=e.bold??(a&1)!==0,this.italic=e.italic??(a&2)!==0,this.scale=1e3/this.unitsPerEm,this.ascent=this.ascentUnits/this.unitsPerEm,this.descent=-this.descentUnits/this.unitsPerEm,this.lookup=this._cmap(),this.gids=new Map,this.order=[0],this.newIds=new Map([[0,0]]),this.unicode=[],this.resId=0,this.objectId=0}_openFace(t){const e=this.view,s=e.getUint32(0);if(s===1330926671)throw new Error("OpenType/CFF fonts are not supported");if(s===1953784678){const i=e.getUint32(8);let n=null;for(let a=0;a<i;a++){const r=this._directory(e.getUint32(12+a*4));if(n===null&&(n=r),t&&this._names(r).postscript===t)return r}if(n===null)throw new Error("Empty font collection");return n}if(s!==65536&&s!==1953658213)throw new Error("Not a TrueType font");return this._directory(0)}_directory(t){const e=this.view,s=e.getUint16(t+4),i=new Map;for(let n=0;n<s;n++){const a=t+12+n*16,r=String.fromCharCode(e.getUint8(a),e.getUint8(a+1),e.getUint8(a+2),e.getUint8(a+3));i.set(r,{offset:e.getUint32(a+8),length:e.getUint32(a+12)})}return i}_names(t=this.tables){const e={},s=t.get("name");if(!s)return e;const i=this.view,n=i.getUint16(s.offset+2),a=s.offset+i.getUint16(s.offset+4);for(let r=0;r<n;r++){const l=s.offset+6+r*12,h=i.getUint16(l),c=i.getUint16(l+6);if(c!==1&&c!==6)continue;const d=i.getUint16(l+8),f=a+i.getUint16(l+10);let u="";if(h===3||h===0)for(let m=0;m+1<d;m+=2)u+=String.fromCharCode(i.getUint16(f+m));else for(let m=0;m<d;m++)u+=String.fromCharCode(i.getUint8(f+m));const p=c===1?"family":"postscript";(e[p]===void 0||h===3)&&(e[p]=u)}return e}_cmap(){const t=this.view,e=this.tables.get("cmap").offset,s=t.getUint16(e+2);let i=null,n=-1;for(let p=0;p<s;p++){const m=e+4+p*8,g=t.getUint16(m),_=t.getUint16(m+2),I=e+t.getUint32(m+4),$=t.getUint16(I);if($!==4&&$!==12&&$!==6)continue;let y=-1;g===3&&_===10?y=4:g===0&&$===12?y=3:g===3&&_===1?y=2:g===0&&(y=1),y>n&&(n=y,i={at:I,format:$})}if(i===null)throw new Error("Font has no Unicode cmap");const{at:a,format:r}=i;if(r===12){const p=t.getUint32(a+12);return m=>{let g=0,_=p-1;for(;g<=_;){const I=g+_>>>1,$=a+16+I*12;if(m<t.getUint32($))_=I-1;else if(m>t.getUint32($+4))g=I+1;else return t.getUint32($+8)+m-t.getUint32($)}return 0}}if(r===6){const p=t.getUint16(a+6),m=t.getUint16(a+8);return g=>g>=p&&g<p+m?t.getUint16(a+10+(g-p)*2):0}const l=t.getUint16(a+6),h=a+14,c=h+l+2,d=c+l,f=d+l,u=l/2;return p=>{if(p>65535)return 0;let m=0,g=u-1;for(;m<g;){const w=m+g>>>1;t.getUint16(h+w*2)<p?m=w+1:g=w}const _=t.getUint16(c+m*2);if(p<_||p>t.getUint16(h+m*2))return 0;const I=t.getInt16(d+m*2),$=t.getUint16(f+m*2);if($===0)return p+I&65535;const y=t.getUint16(f+m*2+$+(p-_)*2);return y===0?0:y+I&65535}}gidOf(t){let e=this.gids.get(t);return e===void 0&&(e=this.lookup(t),e>=this.numGlyphs&&(e=0),this.gids.set(t,e)),e}_rawAdvance(t){const e=this.tables.get("hmtx").offset;return this.view.getUint16(e+Math.min(t,this.numHMetrics-1)*4)}_rawLsb(t){const e=this.tables.get("hmtx").offset;return t<this.numHMetrics?this.view.getInt16(e+t*4+2):this.view.getInt16(e+this.numHMetrics*4+(t-this.numHMetrics)*2)}width(t){return this._rawAdvance(this.gidOf(t))*this.scale}_newId(t){let e=this.newIds.get(t);return e===void 0&&(e=this.order.length,this.order.push(t),this.newIds.set(t,e)),e}use(t){const e=this._newId(this.gidOf(t));return this.unicode[e]===void 0&&(this.unicode[e]=t),e}_glyphRange(t){const e=this.tables.get("loca").offset,s=this.tables.get("glyf").offset,i=this.view,n=this.longLoca?i.getUint32(e+t*4):i.getUint16(e+t*2)*2,a=this.longLoca?i.getUint32(e+(t+1)*4):i.getUint16(e+(t+1)*2)*2;return[s+n,a-n]}_copyTable(t){const e=this.tables.get(t);return e?this.bytes.slice(e.offset,e.offset+e.length):null}subset(){const t=[];for(let w=0;w<this.order.length;w++){const[x,k]=this._glyphRange(this.order[w]);if(k<=0){t.push(null);continue}const S=this.bytes.slice(x,x+k),T=new DataView(S.buffer);if(T.getInt16(0)<0){let C=10;for(;;){const F=T.getUint16(C);if(T.setUint16(C+2,this._newId(T.getUint16(C+2))),C+=4+(F&1?4:2),F&8?C+=2:F&64?C+=4:F&128&&(C+=8),!(F&32))break}}t.push(S)}const e=this.order.length,s=new Uint8Array((e+1)*4),i=new DataView(s.buffer);let n=0;for(let w=0;w<e;w++)i.setUint32(w*4,n),t[w]&&(n+=t[w].length+3&-4);i.setUint32(e*4,n);const a=new Uint8Array(n);for(let w=0;w<e;w++)t[w]&&a.set(t[w],i.getUint32(w*4));const r=new Uint8Array(e*4),l=new DataView(r.buffer);for(let w=0;w<e;w++)l.setUint16(w*4,this._rawAdvance(this.order[w])),l.setInt16(w*4+2,this._rawLsb(this.order[w]));const h=this._copyTable("head"),c=new DataView(h.buffer);c.setUint32(8,0),c.setInt16(50,1);const d=this._copyTable("hhea");new DataView(d.buffer).setUint16(34,e);const f=this._copyTable("maxp");new DataView(f.buffer).setUint16(4,e);const u=[["glyf",a],["head",h],["hhea",d],["hmtx",r],["loca",s],["maxp",f]];for(const w of["cvt ","fpgm","prep"]){const x=this._copyTable(w);x&&u.push([w,x])}u.sort((w,x)=>w[0]<x[0]?-1:1);let p=12+u.length*16;for(const[,w]of u)p+=w.length+3&-4;const m=new Uint8Array(p),g=new DataView(m.buffer),_=u.length,I=31-Math.clz32(_);g.setUint32(0,65536),g.setUint16(4,_),g.setUint16(6,16<<I),g.setUint16(8,I),g.setUint16(10,_*16-(16<<I));let $=12+_*16,y=0;return u.forEach(([w,x],k)=>{const S=12+k*16;for(let T=0;T<4;T++)g.setUint8(S+T,w.charCodeAt(T));g.setUint32(S+4,X(x)),g.setUint32(S+8,$),g.setUint32(S+12,x.length),m.set(x,$),w==="head"&&(y=$),$+=x.length+3&-4}),g.setUint32(y+8,2981146554-X(m)>>>0),m}}function X(o){let t=0;const e=o.length;for(let s=0;s<e;s+=4){const i=(o[s]<<24|(o[s+1]??0)<<16|(o[s+2]??0)<<8|(o[s+3]??0))>>>0;t=t+i>>>0}return t}const dt={black:"000000",white:"ffffff",red:"ff0000",green:"008000",blue:"0000ff",yellow:"ffff00",orange:"ffa500",purple:"800080",gray:"808080",grey:"808080",silver:"c0c0c0",maroon:"800000",navy:"000080",teal:"008080",olive:"808000",lime:"00ff00",aqua:"00ffff",cyan:"00ffff",fuchsia:"ff00ff",magenta:"ff00ff",pink:"ffc0cb",brown:"a52a2a",lightgray:"d3d3d3",lightgrey:"d3d3d3",darkgray:"a9a9a9",darkgrey:"a9a9a9"},O=new Map;function W(o){const t=String(o);let e=O.get(t);return e!==void 0||(e=ut(t.trim().toLowerCase()),O.size>4096&&O.clear(),O.set(t,e)),e}function ut(o){if(o==="transparent")return{r:0,g:0,b:0,a:0,ops:"0 0 0"};let t=dt[o]??null;t===null&&o[0]==="#"&&(t=o.slice(1),(t.length===3||t.length===4)&&(t=[...t].map(r=>r+r).join("")));let e,s,i,n=1;if(t!==null){if(!/^[0-9a-f]{6}([0-9a-f]{2})?$/.test(t))return null;e=parseInt(t.slice(0,2),16),s=parseInt(t.slice(2,4),16),i=parseInt(t.slice(4,6),16),t.length===8&&(n=parseInt(t.slice(6,8),16)/255)}else{const r=/^rgba?\(\s*([\d.]+%?)[\s,]+([\d.]+%?)[\s,]+([\d.]+%?)(?:[\s,/]+([\d.]+%?))?\s*\)$/.exec(o);if(!r)return null;const l=h=>h.endsWith("%")?parseFloat(h)*2.55:parseFloat(h);e=l(r[1]),s=l(r[2]),i=l(r[3]),r[4]!==void 0&&(n=r[4].endsWith("%")?parseFloat(r[4])/100:parseFloat(r[4]))}const a=r=>b(Math.min(255,Math.max(0,r))/255);return{r:e,g:s,b:i,a:n,ops:`${a(e)} ${a(s)} ${a(i)}`}}class E{constructor(){this.color=null}addColorStop(t,e){this.color===null&&(this.color=e)}}const pt=()=>({a:1,b:0,c:0,d:1,e:0,f:0,fill:W("#000000"),fillText:"#000000",stroke:W("#000000"),strokeText:"#000000",lineWidth:1,lineCap:"butt",lineJoin:"miter",miterLimit:10,dash:[],dashOffset:0,alpha:1,font:"10px sans-serif",spec:null,textAlign:"start",textBaseline:"alphabetic"}),gt=()=>({fill:null,stroke:null,width:1,dash:"[] 0",cap:0,join:0,miter:10,alpha:1});class mt{constructor(t,e,s){this.writer=t,this.canvas={width:e,height:s},this.pageWidth=e,this.pageHeight=s,this.ops=[],this.fonts=new Set,this.images=new Set,this.alphas=new Set,this.links=[],this.marks=null,this.s=pt(),this.stack=[],this.emitted=gt(),this.emittedStack=[],this.path=[],this.cx=0,this.cy=0,this.imageSmoothingEnabled=!0,this.globalCompositeOperation="source-over",this.shadowBlur=0,this.shadowColor="transparent",this.shadowOffsetX=0,this.shadowOffsetY=0,this.fontKerning="auto",this.direction="ltr"}save(){this.stack.push({...this.s}),this.emittedStack.push({...this.emitted}),this.ops.push("q")}restore(){this.stack.length!==0&&(this.s=this.stack.pop(),this.emitted=this.emittedStack.pop(),this.ops.push("Q"))}get fillStyle(){return this.s.fillText}set fillStyle(t){const e=t instanceof E?t.color??"#000000":t,s=W(e);s!==null&&(this.s.fill=s,this.s.fillText=e)}get strokeStyle(){return this.s.strokeText}set strokeStyle(t){const e=t instanceof E?t.color??"#000000":t,s=W(e);s!==null&&(this.s.stroke=s,this.s.strokeText=e)}get lineWidth(){return this.s.lineWidth}set lineWidth(t){t>0&&(this.s.lineWidth=t)}get lineCap(){return this.s.lineCap}set lineCap(t){this.s.lineCap=t}get lineJoin(){return this.s.lineJoin}set lineJoin(t){this.s.lineJoin=t}get miterLimit(){return this.s.miterLimit}set miterLimit(t){this.s.miterLimit=t}get lineDashOffset(){return this.s.dashOffset}set lineDashOffset(t){this.s.dashOffset=t}get globalAlpha(){return this.s.alpha}set globalAlpha(t){t>=0&&t<=1&&(this.s.alpha=t)}get textAlign(){return this.s.textAlign}set textAlign(t){this.s.textAlign=t}get textBaseline(){return this.s.textBaseline}set textBaseline(t){this.s.textBaseline=t}get font(){return this.s.font}set font(t){this.s.font=t,this.s.spec=null}setLineDash(t){this.s.dash=t.slice()}getLineDash(){return this.s.dash.slice()}translate(t,e){const s=this.s;s.e+=s.a*t+s.c*e,s.f+=s.b*t+s.d*e}scale(t,e){const s=this.s;s.a*=t,s.b*=t,s.c*=e,s.d*=e}rotate(t){const e=Math.cos(t),s=Math.sin(t);this.transform(e,s,-s,e,0,0)}transform(t,e,s,i,n,a){const r=this.s,{a:l,b:h,c,d,e:f,f:u}=r;r.a=l*t+c*e,r.b=h*t+d*e,r.c=l*s+c*i,r.d=h*s+d*i,r.e=l*n+c*a+f,r.f=h*n+d*a+u}setTransform(t,e,s,i,n,a){const r=this.s;typeof t=="object"&&t!==null&&({a:t,b:e,c:s,d:i,e:n,f:a}=t),r.a=t,r.b=e,r.c=s,r.d=i,r.e=n,r.f=a}resetTransform(){this.setTransform(1,0,0,1,0,0)}getTransform(){const{a:t,b:e,c:s,d:i,e:n,f:a}=this.s;return{a:t,b:e,c:s,d:i,e:n,f:a}}_X(t,e){const s=this.s;return s.a*t+s.c*e+s.e}_Y(t,e){const s=this.s;return this.pageHeight-(s.b*t+s.d*e+s.f)}_pt(t,e){return`${b(this._X(t,e))} ${b(this._Y(t,e))}`}link(t,e,s,i,n){const a=[this._X(t,e),this._X(t+s,e+i)],r=[this._Y(t,e),this._Y(t+s,e+i)];this.links.push({...n,rect:[Math.min(...a),Math.min(...r),Math.max(...a),Math.max(...r)].map(b).join(" ")})}beginCell(t,e,{scope:s=null,rows:i=1,cols:n=1}={}){this.marks?.begin({tag:s?"TH":"TD",row:t,col:e,scope:s,rows:i,cols:n})}beginFigure(t){return this.marks?.begin({tag:"Figure",alt:t})??!1}beginParagraph(){this.marks?.begin({tag:"P"})}endMark(){this.marks?.end()}beginPath(){this.path=[]}moveTo(t,e){this.path.push(`${this._pt(t,e)} m`),this.cx=t,this.cy=e}lineTo(t,e){this.path.push(`${this._pt(t,e)} ${this.path.length===0?"m":"l"}`),this.cx=t,this.cy=e}closePath(){this.path.length>0&&this.path.push("h")}bezierCurveTo(t,e,s,i,n,a){this.path.length===0&&this.moveTo(t,e),this.path.push(`${this._pt(t,e)} ${this._pt(s,i)} ${this._pt(n,a)} c`),this.cx=n,this.cy=a}quadraticCurveTo(t,e,s,i){this.path.length===0&&this.moveTo(t,e);const{cx:n,cy:a}=this;this.bezierCurveTo(n+2/3*(t-n),a+2/3*(e-a),s+2/3*(t-s),i+2/3*(e-i),s,i)}rect(t,e,s,i){const n=this.s;n.b===0&&n.c===0?this.path.push(`${this._pt(t,e)} ${b(n.a*s)} ${b(-n.d*i)} re`):this.path.push(`${this._pt(t,e)} m ${this._pt(t+s,e)} l ${this._pt(t+s,e+i)} l ${this._pt(t,e+i)} l h`),this.cx=t,this.cy=e}roundRect(t,e,s,i,n=0){const a=Math.min(Math.abs(Array.isArray(n)?Number(n[0])||0:Number(n)||0),Math.abs(s)/2,Math.abs(i)/2);if(a===0){this.rect(t,e,s,i);return}this.moveTo(t+a,e),this.lineTo(t+s-a,e),this.quadraticCurveTo(t+s,e,t+s,e+a),this.lineTo(t+s,e+i-a),this.quadraticCurveTo(t+s,e+i,t+s-a,e+i),this.lineTo(t+a,e+i),this.quadraticCurveTo(t,e+i,t,e+i-a),this.lineTo(t,e+a),this.quadraticCurveTo(t,e,t+a,e),this.closePath()}arc(t,e,s,i,n,a=!1){this.ellipse(t,e,s,s,0,i,n,a)}ellipse(t,e,s,i,n,a,r,l=!1){let h=r-a;const c=Math.PI*2;!l&&h<0&&(h=h%c+c),l&&h>0&&(h=h%c-c),Math.abs(r-a)>=c&&(h=l?-c:c);const d=Math.cos(n),f=Math.sin(n),u=w=>{const x=s*Math.cos(w),k=i*Math.sin(w);return[t+x*d-k*f,e+x*f+k*d]},p=w=>{const x=-s*Math.sin(w),k=i*Math.cos(w);return[x*d-k*f,x*f+k*d]},m=Math.max(1,Math.ceil(Math.abs(h)/(Math.PI/2))),g=h/m,_=4/3*Math.tan(g/4),[I,$]=u(a);this.path.length===0?this.moveTo(I,$):this.lineTo(I,$);let y=a;for(let w=0;w<m;w++){const x=y+g,[k,S]=u(y),[T,C]=u(x),[F,G]=p(y),[Y,K]=p(x);this.bezierCurveTo(k+_*F,S+_*G,T-_*Y,C-_*K,T,C),y=x}}_applyAlpha(t){const e=Math.round(this.s.alpha*t*100);e!==Math.round(this.emitted.alpha*100)&&(this.emitted.alpha=e/100,this.alphas.add(e),this.ops.push(`/A${e} gs`))}_applyFill(){const t=this.s.fill;this._applyAlpha(t.a),this.emitted.fill!==t.ops&&(this.emitted.fill=t.ops,this.ops.push(`${t.ops} rg`))}_applyStroke(){const{s:t,emitted:e,ops:s}=this;this._applyAlpha(t.stroke.a),e.stroke!==t.stroke.ops&&(e.stroke=t.stroke.ops,s.push(`${t.stroke.ops} RG`));const i=Math.sqrt(Math.abs(t.a*t.d-t.b*t.c))||1,n=t.lineWidth*i;e.width!==n&&(e.width=n,s.push(`${b(n)} w`));const a=`[${t.dash.map(h=>b(h*i)).join(" ")}] ${b(t.dashOffset*i)}`;e.dash!==a&&(e.dash=a,s.push(`${a} d`));const r=t.lineCap==="round"?1:t.lineCap==="square"?2:0;e.cap!==r&&(e.cap=r,s.push(`${r} J`));const l=t.lineJoin==="round"?1:t.lineJoin==="bevel"?2:0;e.join!==l&&(e.join=l,s.push(`${l} j`)),e.miter!==t.miterLimit&&(e.miter=t.miterLimit,s.push(`${b(t.miterLimit)} M`))}fill(t){this.path.length!==0&&(this._applyFill(),this.ops.push(`${this.path.join(" ")} ${t==="evenodd"?"f*":"f"}`))}stroke(){this.path.length!==0&&(this._applyStroke(),this.ops.push(`${this.path.join(" ")} S`))}clip(t){this.ops.push(`${this.path.length?`${this.path.join(" ")} `:"0 0 0 0 re "}${t==="evenodd"?"W*":"W"} n`)}fillRect(t,e,s,i){this._applyFill();const n=this.s;n.b===0&&n.c===0?this.ops.push(`${this._pt(t,e)} ${b(n.a*s)} ${b(-n.d*i)} re f`):this.ops.push(`${this._pt(t,e)} m ${this._pt(t+s,e)} l ${this._pt(t+s,e+i)} l ${this._pt(t,e+i)} l h f`)}strokeRect(t,e,s,i){const n=this.path;this.path=[],this.rect(t,e,s,i),this.stroke(),this.path=n}clearRect(t,e,s,i){this.ops.push("q 1 1 1 rg");const n=this.s;n.b===0&&n.c===0?this.ops.push(`${this._pt(t,e)} ${b(n.a*s)} ${b(-n.d*i)} re f`):this.ops.push(`${this._pt(t,e)} m ${this._pt(t+s,e)} l ${this._pt(t+s,e+i)} l ${this._pt(t,e+i)} l h f`),this.ops.push("Q")}createLinearGradient(){return new E}createRadialGradient(){return new E}createConicGradient(){return new E}createPattern(){return null}_spec(){const t=this.s;return t.spec===null&&(t.spec=this.writer._fontSpec(t.font)),t.spec}measureText(t){const e=this._spec(),s=this.writer._measure(String(t),e),i=e.size*e.ascent,n=e.size*e.descent;return{width:s,actualBoundingBoxLeft:0,actualBoundingBoxRight:s,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,fontBoundingBoxAscent:i,fontBoundingBoxDescent:n}}fillText(t,e,s){this._text(String(t),e,s,!1)}strokeText(t,e,s){this._text(String(t),e,s,!0)}_text(t,e,s,i){if(t==="")return;const n=this._spec(),{writer:a,s:r}=this,l=a._runs(t,n);let h=0;for(const u of l)h+=u.width;const c=r.textAlign;switch(c==="center"?e-=h/2:(c==="right"||c==="end")&&(e-=h),r.textBaseline){case"top":s+=n.size*n.ascent;break;case"hanging":s+=n.size*n.ascent*.8;break;case"middle":s+=n.size*(n.ascent-n.descent)/2;break;case"bottom":case"ideographic":s-=n.size*n.descent;break;default:}i?this._applyStroke():this._applyFill();const d=b(n.size);let f=e;for(const u of l){this.fonts.add(u.font);const p=u.hScale,m=`${b(r.a*p)} ${b(-r.b*p)} ${b(-r.c)} ${b(r.d)} ${b(this._X(f,s))} ${b(this._Y(f,s))}`;this.ops.push(`BT${i?" 1 Tr":""} /F${u.font.resId} ${d} Tf ${m} Tm <${u.hex}> Tj${i?" 0 Tr":""} ET`),f+=u.width}}drawImage(t,...e){const s=this.writer._image(t);if(s===null)return;this.images.add(s);let i=0,n=0,a=s.width,r=s.height,l,h,c,d;if(e.length>=8?[i,n,a,r,l,h,c,d]=e:e.length>=4?[l,h,c,d]=e:([l,h]=e,c=s.width,d=s.height),this._applyAlpha(1),this.ops.push("q"),e.length>=8){const $=this.path;this.path=[],this.rect(l,h,c,d),this.ops.push(`${this.path.join(" ")} W n`),this.path=$;const y=c/a,w=d/r;l-=i*y,h-=n*w,c=s.width*y,d=s.height*w}const f=this.s,u=f.a*c,p=-f.b*c,m=-f.c*d,g=f.d*d,_=this._X(l,h+d),I=this._Y(l,h+d);this.ops.push(`${b(u)} ${b(p)} ${b(m)} ${b(g)} ${b(_)} ${b(I)} cm /Im${s.resId} Do Q`)}}function wt(o){const t=(e,s=2)=>String(e).padStart(s,"0");return`D:${t(o.getUTCFullYear(),4)}${t(o.getUTCMonth()+1)}${t(o.getUTCDate())}${t(o.getUTCHours())}${t(o.getUTCMinutes())}${t(o.getUTCSeconds())}Z`}function bt(o){const t=new Uint8Array(2+o.length*2);t.set([254,255]);for(let e=0;e<o.length;e++)t[2+e*2]=o.charCodeAt(e)>>8,t[3+e*2]=o.charCodeAt(e)&255;return t}const _t=o=>[...o].map(t=>/[!-~]/.test(t)?t:encodeURIComponent(t.isWellFormed?.()===!1?"�":t)).join("");function $t(o){let t=2;for(;t+9<o.length;){if(o[t]!==255){t++;continue}const e=o[t+1];if(e>=192&&e<=207&&e!==196&&e!==200&&e!==204)return{height:o[t+5]<<8|o[t+6],width:o[t+7]<<8|o[t+8],components:o[t+9]};t+=2+(o[t+2]<<8|o[t+3])}return null}class St{constructor(t,e={}){this.sink=t,this.options=e,this.compress=e.compress!==!1&&typeof CompressionStream<"u",this.offset=0,this.buffer=new Uint8Array(j),this.pos=0,this.xref=new Float64Array(1024),this.nextId=1,this.started=!1,this.finished=!1,this.page=null,this.pageCount=0,this.pageIds=[],this.dests=new Map,this.bookmarks=[],this.levels=[],this.faces=[],this.stdFonts=new Map,this.encodingId=0,this.nextFontRes=1,this.nextImageRes=1,this.imageIds=new WeakMap,this.pendingImages=[],this.specs=new Map,this.packed=null,this.structure=e.tagged?new et(this,{lang:e.lang}):null,this.crypt=null,this.missing=new Set,this.fontWarnings=[];for(const s of e.fonts??[])this.registerFont(s)}registerFont(t){try{const e=new ft(t.bytes,t);return e.familyKey=e.family.toLowerCase(),this.faces.push(e),this.specs.clear(),!0}catch(e){return this.fontWarnings.push(`${t.family??"font"}: ${e.message}`),!1}}async _raw(t){const e=t.length;if(this.offset+=e,e>=j/2){await this._flush(),await this.sink.write(t);return}this.pos+e>j&&await this._flush(),this.buffer.set(t,this.pos),this.pos+=e}async _flush(){if(this.pos===0)return;const t=this.buffer.slice(0,this.pos);this.pos=0,await this.sink.write(t)}_w(t){return this._raw(M.encode(t))}_alloc(){const t=this.nextId++;if(t>=this.xref.length){const e=new Float64Array(this.xref.length*2);e.set(this.xref),this.xref=e}return t}async _obj(t,e){this.xref[t]=this.offset,await this._w(`${t} 0 obj
|
|
2
2
|
${e}
|
|
3
3
|
endobj
|
|
4
|
-
`)}
|
|
5
|
-
|
|
4
|
+
`)}_text(t){return this._string(bt(t))}_ascii(t){return this.crypt?this._string(M.encode(t)):`(${t.replace(/[\\()]/g,"\\$&")})`}_string(t){if(this.crypt)return J(this.crypt,t);let e="";for(const s of t)e+=v[s];return`<${e}>`}async _packed(t,e){this.packed??={id:this._alloc(),ids:[],offsets:[],text:""};const{packed:s}=this;this.xref[t]=-(s.id*B+s.ids.length)-1,s.ids.push(t),s.offsets.push(s.text.length),s.text+=`${e}
|
|
5
|
+
`,s.ids.length===B&&await this._flushPacked()}async _flushPacked(){const{packed:t}=this;if(t===null)return;this.packed=null;const e=t.ids.map((s,i)=>`${s} ${t.offsets[i]}`).join(" ")+`
|
|
6
|
+
`;await this._stream(t.id,` /Type /ObjStm /N ${t.ids.length} /First ${e.length}`,s=>P(M.encode(e+t.text),s))}async _stream(t,e,s,{deflate:i=this.compress,encrypt:n=!0}={}){const a=this.crypt&&n?new Q(this.crypt):null,r=a?async d=>this._raw(await a.push(d)):d=>this._raw(d),l=this._alloc();this.xref[t]=this.offset,await this._w(`${t} 0 obj
|
|
7
|
+
<<${e} /Length ${l} 0 R${i?" /Filter /FlateDecode":""}>>
|
|
6
8
|
stream
|
|
7
|
-
`);const
|
|
9
|
+
`);const h=this.offset;if(i){const d=new CompressionStream("deflate"),f=d.writable.getWriter(),u=d.readable.getReader(),m=(async()=>{for(;;){const{done:g,value:_}=await u.read();if(g)return;await r(_)}})().catch(g=>{throw f.abort(g).catch(H),g});try{await s(async g=>{await f.ready,await f.write(g)}),await f.close()}catch(g){throw f.abort(g).catch(H),await m.catch(H),g}await m}else await s(r);a&&await this._raw(await a.end());const c=this.offset-h;await this._w(`
|
|
8
10
|
endstream
|
|
9
11
|
endobj
|
|
10
|
-
`),await this._obj(
|
|
11
|
-
`)),
|
|
12
|
-
0 ${
|
|
12
|
+
`),await this._obj(l,String(c))}async _begin(){if(this.started)return;this.started=!0;const{openPassword:t,permissionsPassword:e,permissions:s}=this.options;(t||e)&&(this.crypt=await Z({openPassword:t,permissionsPassword:e,permissions:s})),await this._raw(new Uint8Array([37,80,68,70,45,49,46,55,10,37,226,227,207,211,10]))}_stdFont(t){let e=this.stdFonts.get(t);return e===void 0&&(e=new lt(t,this.nextFontRes++,this._alloc()),this.stdFonts.set(t,e)),e}_fontSpec(t){let e=this.specs.get(t);if(e!==void 0)return e;const s=/([\d.]+)(px|pt)\s+(.*)$/.exec(t),i=s?t.slice(0,s.index):"",n=s?Number(s[1])*(s[2]==="pt"?4/3:1):10,a=(s?s[3]:"sans-serif").split(",").map(u=>u.trim().replace(/^["']|["']$/g,"").toLowerCase()).filter(Boolean),r=/\bbold\b|\b[6-9]00\b/.test(i),l=/\b(italic|oblique)\b/.test(i),h=[];for(const u of a)for(const p of this.faces)p.familyKey===u&&p.bold===r&&p.italic===l&&!h.includes(p)&&h.push(p);const c=a[0]??"sans-serif",d=this._stdFont(ct(c,r,l)),f=h[0]??d;return e={size:n,faces:h,std:d,hScale:!d.mono&&ht.test(c)?.9:1,ascent:f.ascent,descent:f.descent},this.specs.set(t,e),e}_measure(t,e){const{size:s,faces:i,std:n,hScale:a}=e;let r=0;for(const l of t){let h=l.codePointAt(0);h<32&&(h=32);let c=null;for(let d=0;d<i.length;d++)if(i[d].gidOf(h)!==0){c=i[d];break}if(c!==null){r+=c.width(h);continue}U.has(h)||(h=V(h)),r+=n.width(h)*a}return r*s/1e3}_runs(t,e){const{size:s,faces:i,std:n,hScale:a}=e,r=[];let l=null;for(const h of t){let c=h.codePointAt(0);c<32&&(c=32);let d=null;for(let g=0;g<i.length;g++)if(i[g].gidOf(c)!==0){d=i[g];break}let f,u,p,m=1;if(d!==null)d.resId===0&&(d.resId=this.nextFontRes++,d.objectId=this._alloc()),f=d,u=R(d.use(c)),p=d.width(c);else{let g=U.get(c);g===void 0&&(this.missing.add(c),c=V(c),g=U.get(c)),f=n,u=v[g],p=n.width(c)*a,m=a}(l===null||l.font!==f)&&(l={font:f,hex:"",width:0,hScale:m},r.push(l)),l.hex+=u,l.width+=p*s/1e3}return r}async _writeFonts(){if(this.stdFonts.size>0){this.encodingId=this._alloc();const e=q.map(([,s])=>`/${s}`).join(" ");await this._obj(this.encodingId,`<< /Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [1 ${e}] >>`);for(const s of this.stdFonts.values())await this._obj(s.objectId,`<< /Type /Font /Subtype /Type1 /BaseFont /${s.name} /Encoding ${this.encodingId} 0 R >>`)}let t=0;for(const e of this.faces)e.objectId!==0&&await this._writeFace(e,xt(t++))}async _writeFace(t,e){const s=t.subset(),i=this._alloc(),n=this._alloc(),a=this._alloc(),r=this._alloc();await this._stream(i,` /Length1 ${s.length}`,u=>P(s,u));const l=It(t.unicode);await this._stream(n,"",u=>P(M.encode(l),u));const h=`${e}+${t.postscriptName}`,c=t.scale,d=4|(t.italic?64:0)|(t.bold?1<<18:0);await this._obj(a,`<< /Type /FontDescriptor /FontName /${h} /Flags ${d} /FontBBox [${t.bbox.map(u=>Math.round(u*c)).join(" ")}] /ItalicAngle ${b(t.italicAngle)} /Ascent ${Math.round(t.ascentUnits*c)} /Descent ${Math.round(t.descentUnits*c)} /CapHeight ${Math.round(t.capHeightUnits*c)} /StemV ${t.bold?140:80} /FontFile2 ${i} 0 R >>`);const f=[];for(let u=0;u<t.order.length;u++)f.push(Math.round(t._rawAdvance(t.order[u])*c));await this._obj(r,`<< /Type /Font /Subtype /CIDFontType2 /BaseFont /${h} /CIDSystemInfo << /Registry ${await this._ascii("Adobe")} /Ordering ${await this._ascii("Identity")} /Supplement 0 >> /FontDescriptor ${a} 0 R /CIDToGIDMap /Identity /DW 1000 /W [0 [${f.join(" ")}]] >>`),await this._obj(t.objectId,`<< /Type /Font /Subtype /Type0 /BaseFont /${h} /Encoding /Identity-H /DescendantFonts [${r} 0 R] /ToUnicode ${n} 0 R >>`)}_image(t){const e=this.imageIds.get(t);if(e!==void 0)return e;let s;if(t.jpeg){const i=$t(t.jpeg);if(i===null)return null;s={kind:"jpeg",bytes:t.jpeg,...i}}else if(t.rgba||t.data)s={kind:"rgba",rgba:t.rgba??t.data,width:t.width,height:t.height};else{const i=kt(t);if(i===null)return null;s={kind:"rgba",rgba:i.data,width:i.width,height:i.height}}return s.resId=this.nextImageRes++,s.objectId=this._alloc(),this.imageIds.set(t,s),this.pendingImages.push(s),s}async _writeImage(t){const e=`/Type /XObject /Subtype /Image /Width ${t.width} /Height ${t.height} /BitsPerComponent 8`;if(t.kind==="jpeg"){const s=t.components===1?"/DeviceGray":t.components===4?"/DeviceCMYK":"/DeviceRGB",i=t.components===4?" /Decode [1 0 1 0 1 0 1 0]":"";await this._stream(t.objectId,` ${e} /ColorSpace ${s}${i} /Filter /DCTDecode`,n=>P(t.bytes,n),{deflate:!1})}else{const{rgba:s,width:i,height:n}=t,a=i*n;let r=!0;for(let h=3;h<a*4;h+=4)if(s[h]!==255){r=!1;break}let l="";if(!r){const h=this._alloc();await this._stream(h,` /Type /XObject /Subtype /Image /Width ${i} /Height ${n} /BitsPerComponent 8 /ColorSpace /DeviceGray`,async c=>{for(let d=0;d<a;d+=65536){const f=Math.min(65536,a-d),u=new Uint8Array(f);for(let p=0;p<f;p++)u[p]=s[(d+p)*4+3];await c(u)}}),l=` /SMask ${h} 0 R`}await this._stream(t.objectId,` ${e} /ColorSpace /DeviceRGB${l}`,async h=>{for(let c=0;c<a;c+=65536){const d=Math.min(65536,a-c),f=new Uint8Array(d*3);for(let u=0;u<d;u++){const p=(c+u)*4;f[u*3]=s[p],f[u*3+1]=s[p+1],f[u*3+2]=s[p+2]}await h(f)}})}t.rgba=null,t.bytes=null}beginPage(t,e){if(this.page!==null)throw new Error("Call endPage before the next beginPage");if(this.finished)throw new Error("The document is finished");return this.page=new mt(this,t,e),this.structure&&(this.page.marks=new tt(this.page.ops)),this.page}async endPage(){const t=this.page;if(t===null)return;for(this.page=null,await this._begin();t.stack.length>0;)t.restore();t.marks?.close();const e=this.pendingImages;this.pendingImages=[];for(const f of e)await this._writeImage(f);const s=this._alloc();await this._stream(s,"",f=>P(M.encode(t.ops.join(`
|
|
13
|
+
`)),f));const i=[...t.fonts].map(f=>`/F${f.resId} ${f.objectId} 0 R`).join(" "),n=[...t.images].map(f=>`/Im${f.resId} ${f.objectId} 0 R`).join(" "),a=[...t.alphas].map(f=>`/A${f} << /ca ${b(f/100)} /CA ${b(f/100)} >>`).join(" "),r=`${i?`/Font << ${i} >>`:""}${n?` /XObject << ${n} >>`:""}${a?` /ExtGState << ${a} >>`:""}`,l=[];for(const f of t.links){const u=this._alloc(),p=f.uri===void 0?`/Dest /${f.dest}`:`/A << /S /URI /URI ${await this._ascii(_t(f.uri))} >>`;await this._obj(u,`<< /Type /Annot /Subtype /Link /Rect [${f.rect}] /Border [0 0 0] /F 4 ${p} >>`),l.push(`${u} 0 R`)}const h=this._level(0),c=this._alloc();this.pageIds.push(c);const d=t.marks?await this.structure.page(c,t.marks):"";if(await this._obj(c,`<< /Type /Page /Parent ${h.id} 0 R /MediaBox [0 0 ${b(t.pageWidth)} ${b(t.pageHeight)}] /Contents ${s} 0 R${l.length?` /Annots [${l.join(" ")}]`:""}${d} /Resources << ${r} >> >>`),await this._addKid(0,c,1),this.pageCount++,this.offset>st)throw new Error("PDF exceeds the classic xref limit of 10 GB")}_level(t){let e=this.levels[t];return e===void 0&&(e={id:this._alloc(),kids:[],count:0},this.levels[t]=e),e}async _addKid(t,e,s){const i=this._level(t);if(i.kids.push(e),i.count+=s,i.kids.length<it)return;const n=this._level(t+1);await this._writeNode(i,n.id),this.levels[t]=void 0,await this._addKid(t+1,i.id,i.count)}_writeNode(t,e){const s=e===null?"":` /Parent ${e} 0 R`;return this._obj(t.id,`<< /Type /Pages${s} /Kids [${t.kids.map(i=>`${i} 0 R`).join(" ")}] /Count ${t.count} >>`)}async _closeTree(){let t=Math.max(0,this.levels.length-1);for(;t>0&&this.levels[t]===void 0;)t--;for(let s=0;s<t;s++){const i=this.levels[s];if(i===void 0||i.kids.length===0)continue;const n=this._level(s+1);await this._writeNode(i,n.id),n.kids.push(i.id),n.count+=i.count}const e=this._level(t);return await this._writeNode(e,null),e.id}destination(t,e,s){this.dests.set(t,{page:e,top:s})}bookmark(t,e){this.bookmarks.push({title:t,page:e})}section(t){this.structure?.section(t)}async _writeNavigation(){let t="";const e=[...this.dests].filter(([,i])=>this.pageIds[i.page]!==void 0);if(e.length>0){const i=this._alloc();await this._obj(i,`<< ${e.map(([n,a])=>`/${n} [${this.pageIds[a.page]} 0 R /XYZ null ${b(a.top)} null]`).join(" ")} >>`),t+=` /Dests ${i} 0 R`}const s=this.bookmarks.filter(i=>this.pageIds[i.page]!==void 0);if(s.length>0){const i=this._alloc(),n=s.map(()=>this._alloc());for(let a=0;a<s.length;a++){const r=`${a>0?` /Prev ${n[a-1]} 0 R`:""}${a+1<n.length?` /Next ${n[a+1]} 0 R`:""}`;await this._obj(n[a],`<< /Title ${await this._text(s[a].title)} /Parent ${i} 0 R${r} /Dest [${this.pageIds[s[a].page]} 0 R /Fit] >>`)}await this._obj(i,`<< /Type /Outlines /First ${n[0]} 0 R /Last ${n.at(-1)} 0 R /Count ${n.length} >>`),t+=` /Outlines ${i} 0 R`}return t}async finish(){if(this.finished)return;await this.endPage(),await this._begin(),this.finished=!0,await this._writeFonts();const t=await this._closeTree();let e=await this._writeNavigation();this.structure&&(e+=await this.structure.finish(p=>this._ascii(p))),this.crypt&&(e+=" /Extensions << /ADBE << /BaseVersion /1.7 /ExtensionLevel 8 >> >>");const s=this._alloc();await this._obj(s,`<< /Type /Catalog /Pages ${t} 0 R${e} /ViewerPreferences << /DisplayDocTitle true >> >>`);const i=this.options,n=wt(i.creationDate??new Date),a=[i.title?`/Title ${await this._text(i.title)}`:"",i.author?`/Author ${await this._text(i.author)}`:"",i.subject?`/Subject ${await this._text(i.subject)}`:"",`/Producer ${await this._text(i.producer??"8sheets")}`,`/CreationDate ${await this._ascii(n)}`].filter(Boolean).join(" "),r=this._alloc();await this._obj(r,`<< ${a} >>`),await this._flushPacked();let l="";if(this.crypt){const p=this._alloc();await this._obj(p,this.crypt.dict),l=` /Encrypt ${p} 0 R`}const h=Ut(),c=` /Root ${s} 0 R /Info ${r} 0 R /ID [<${h}> <${h}>]${l}`;if(this.structure){await this._xrefStream(c);return}const d=this.offset,f=this.nextId;await this._w(`xref
|
|
14
|
+
0 ${f}
|
|
13
15
|
0000000000 65535 f
|
|
14
|
-
`);let
|
|
15
|
-
`,
|
|
16
|
-
<< /Size ${
|
|
16
|
+
`);let u="";for(let p=1;p<f;p++)u+=`${String(this.xref[p]).padStart(10,"0")} 00000 n
|
|
17
|
+
`,u.length>=32768&&(await this._w(u),u="");await this._w(u),await this._w(`trailer
|
|
18
|
+
<< /Size ${f}${c} >>
|
|
17
19
|
startxref
|
|
18
|
-
${
|
|
20
|
+
${d}
|
|
19
21
|
%%EOF
|
|
20
|
-
`),await this._flush()}
|
|
22
|
+
`),await this._flush()}async _xrefStream(t){const e=this._alloc(),s=this.offset;this.xref[e]=s;const{nextId:i}=this,n=[],a=async l=>{for(let h=0;h<i;h+=N){const c=Math.min(N,i-h),d=new Uint8Array(c*L),f=new DataView(d.buffer);for(let u=0;u<c;u++){const p=this.xref[h+u],m=u*L;if(p<0){const g=-p-1;d[m]=2,f.setUint32(m+3,Math.floor(g/B)),f.setUint16(m+7,g%B)}else p>0?(d[m]=1,f.setUint16(m+1,Math.floor(p/4294967296)),f.setUint32(m+3,p>>>0)):h+u===0&&f.setUint16(m+7,65535)}await l(d)}};if(this.compress){const l=new CompressionStream("deflate"),h=l.writable.getWriter(),c=(async()=>{const d=l.readable.getReader();for(;;){const{done:f,value:u}=await d.read();if(f)return;n.push(u)}})();await a(async d=>{await h.ready,await h.write(d)}),await h.close(),await c}const r=this.compress?n.reduce((l,h)=>l+h.length,0):i*L;if(await this._w(`${e} 0 obj
|
|
23
|
+
<< /Type /XRef /Size ${i} /W [1 6 2]${t} /Length ${r}${this.compress?" /Filter /FlateDecode":""} >>
|
|
24
|
+
stream
|
|
25
|
+
`),this.compress)for(const l of n)await this._raw(l);else await a(l=>this._raw(l));await this._w(`
|
|
26
|
+
endstream
|
|
27
|
+
endobj
|
|
28
|
+
startxref
|
|
29
|
+
${s}
|
|
30
|
+
%%EOF
|
|
31
|
+
`),await this._flush()}}async function P(o,t){for(let e=0;e<o.length;e+=j)await t(o.subarray(e,Math.min(o.length,e+j)))}function xt(o){let t="",e=o;for(let s=0;s<6;s++)t=String.fromCharCode(65+e%26)+t,e=Math.floor(e/26);return t}function yt(o){if(o<=65535)return R(o);const t=o-65536;return R(55296+(t>>10))+R(56320+(t&1023))}function It(o){const t=[],e=[];for(let s=1;s<o.length;s++)o[s]!==void 0&&e.push(`<${R(s)}> <${yt(o[s])}>`);for(let s=0;s<e.length;s+=100){const i=e.slice(s,s+100);t.push(`${i.length} beginbfchar`,...i,"endbfchar")}return`/CIDInit /ProcSet findresource begin
|
|
21
32
|
12 dict begin
|
|
22
33
|
begincmap
|
|
23
34
|
/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def
|
|
@@ -32,4 +43,4 @@ endcmap
|
|
|
32
43
|
CMapName currentdict /CMap defineresource pop
|
|
33
44
|
end
|
|
34
45
|
end
|
|
35
|
-
`}function
|
|
46
|
+
`}function Ut(){const o=new Uint8Array(16);return globalThis.crypto.getRandomValues(o),[...o].map(t=>v[t]).join("")}function kt(o){const t=o.naturalWidth??o.videoWidth??o.width,e=o.naturalHeight??o.videoHeight??o.height;if(!t||!e)return null;try{const i=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,e):Object.assign(document.createElement("canvas"),{width:t,height:e})).getContext("2d");return i.drawImage(o,0,0),i.getImageData(0,0,t,e)}catch{return null}}export{mt as PdfPageContext,St as PdfWriter};
|
package/print/render-page.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{hasCellTypes as
|
|
2
|
-
`)){let r="";for(const
|
|
3
|
-
`).forEach((
|
|
1
|
+
import{hasCellTypes as j}from"../core/cell-type-rules.js";import{hasConditionalFormats as ct}from"../core/host-rules.js";import{readingDirection as at,visualOrder as ht,wrapsByAlign as dt}from"../cells/text-layout.js";import{gradientPatches as q}from"../cells/paint.js";import{paintWatermarks as ut}from"../shapes/watermark.js";import{BOOL as mt,CHUNK_BITS as Q,CHUNK_MASK as W,EMPTY as X,ERR as tt,ERRORS as gt,KIND_MASK as $,NUM as L,STR as v,FORMULA as et,SPILL as nt}from"../core/sheet.js";import{isBarcodeText as pt,paintBarcodeValue as wt}from"../celltypes/barcode.js";import{printCellType as ot,printEmptyTypedCells as bt}from"../celltypes/cell-types.js";import{FILL_MARK as it,fitGeneral as kt,formatGeneral as yt,getFormatter as K}from"../core/numfmt.js";import{colName as Tt}from"../core/address.js";import{cssFont as E}from"../core/styles.js";import{CondFormats as Ot}from"../core/cond-format.js";import{drawCfIcon as St,iconSide as Pt,monoContext as Dt,paintCfBar as Rt}from"../cells/cf-paint.js";import{sparklineIndex as xt}from"../core/sparklines.js";import{paintSparkline as At}from"../sparklines/excel-paint.js";import{isSparklineText as Ct,paintSparklineValue as Ft}from"../sparklines/paint.js";import{paintSparkRulesOnPage as Mt,sparkRuleHidesValue as zt}from"../sparklines/rule.js";import{preparePicturesForPrint as It}from"../sparklines/print.js";import{tableColors as Nt,tablesOf as vt}from"../core/tables.js";import{paintCustomTable as Ht}from"../slicers/custom-styles.js";import{resolveColor as Lt}from"../io/xlsx-styles.js";import{parseHeaderFooter as Wt}from"./page-setup.js";import{linkRegion as Et}from"./pdf-links.js";import{paintNotePage as _t}from"./note-pages.js";import{paintShownNotes as Bt}from"./shown-notes.js";const Gt=2,Xt=6,$t=32,U="#000000",Y=.25,V=10,Kt={hair:.25,thin:.5,dotted:.5,dashed:.5,dashDot:.5,dashDotDot:.5,medium:1,mediumDashed:1,mediumDashDot:1,mediumDashDotDot:1,slantDashDot:1,thick:1.5,double:.5},Ut={hair:[.5,.75],dotted:[.5,1.5],dashed:[3,1.5],dashDot:[3,1.5,.75,1.5],dashDotDot:[3,1.5,.75,1.5,.75,1.5],mediumDashed:[4,2],mediumDashDot:[4,2,1,2],mediumDashDotDot:[4,2,1,2,1,2],slantDashDot:[4,1,1,1]},st=new WeakMap;function J(t){let i=st.get(t);return i===void 0&&(i=E(t,t.fontSize),st.set(t,i)),i}function Yt(t,i,l,s){switch(i){case L:return s.numFmt==="General"?yt(l):K(s.numFmt).number(l,t.dateOffset);case v:{const p=t.strings.get(l);return s.numFmt==="General"||s.numFmt==="@"?p:K(s.numFmt).text(p)}case mt:return l?"TRUE":"FALSE";case tt:return gt[l]??"#N/A";default:return""}}class Vt{constructor(i,l,s,p){this.ctx=i,this.book=l,this.sheet=s,this.styles=l.styles.list,this.mono=p.blackAndWhite,this.errors=p.errors,this.cfFrame=null,this.tables=null,this.font="",this.ink="",this.wrapCache=new Map,this.reachX=null}style(i,l){return this.styles[this.sheet.style(i,l)]??this.styles[0]}textStyle(i,l,s,p,n){let e=this.style(i,l);const r=this.cfFrame===null?void 0:this.cfFrame.get(i*16384+l);if(r!==void 0){if(r.icon&&this.icon(r.icon,s,p,n,e),r.hideValue)return null;(r.color||r.numFmt!==void 0||r.bold!==void 0||r.italic!==void 0||r.underline!==void 0||r.strike!==void 0)&&(e={...e,color:r.color??e.color,numFmt:r.numFmt??e.numFmt,bold:r.bold??e.bold,italic:r.italic??e.italic,underline:r.underline??e.underline,strike:r.strike??e.strike})}if(this.tables!==null)for(const d of this.tables){if(i<d.r0||i>d.r1||l<d.c0||l>d.c1||!d._colors)continue;const m=d._colors.format(d,i,l);e={...e,color:e.color??m.color,bold:e.bold||m.bold===!0,italic:e.italic||m.italic===!0},m.underline&&!e.underline&&(e.underline=m.underline),m.strike&&(e.strike=!0);break}return e}icon(i,l,s,p,n){const e=Pt(p,1,n.fontSize),r=n.vAlign==="top"?s+1:n.vAlign==="center"?s+(p-e)/2:s+p-e-1;St(this.mono?Dt(this.ctx):this.ctx,i.name,i.level,l+1,r,e),this.ink=""}setFont(i){this.font!==i&&(this.ctx.font=i,this.font=i)}setInk(i){this.ink!==i&&(this.ctx.fillStyle=i,this.ink=i)}reset(){this.font="",this.ink=""}width(i){return this.ctx.measureText(i).width}richLine(i,l,s,p,n,e,r,d,m){const{ctx:y}=this,h=[];let k=0,g=0;l.forEach((b,C)=>{const O=l[C+1]?.at??i.length;if(O<=b.at)return;const D={...s,fontName:b.name??s.fontName,fontSize:b.sz??s.fontSize,bold:b.b??s.bold,italic:b.i??s.italic},z=J(D);this.setFont(z);const N=i.slice(b.at,O).replace(/\n/g," "),R=y.measureText(N).width;h.push({piece:N,font:z,ink:b.color??s.color??"#000000",pw:R}),k+=R,g=Math.max(g,D.fontSize)});const w=s.vAlign??"bottom",F=w==="top"?e+g*1.05:w==="center"?e+(d+g*.72)/2:e+d-3;let M=p==="right"?n+r-m-k:p==="center"||p==="centerContinuous"?n+(r-k)/2:n+m;y.textAlign="left";for(const b of h)this.setFont(b.font),this.setInk(b.ink),y.fillText(b.piece,M,F),M+=b.pw}text(i,l,s,p,n,e,r,d,m,y=!1){const{ctx:h}=this;if(!h.marks){this._text(i,l,s,p,n,e,r,d,m,y);return}const k=y?this.sheet.mergeAt(i,l):null;h.beginCell(i,l,{scope:this.scopeOf(i,l),rows:k?k.r1-k.r0+1:1,cols:k?k.c1-k.c0+1:1}),this._text(i,l,s,p,n,e,r,d,m,y),h.endMark()}scopeOf(i,l){const{titleRows:s,titleCols:p}=this;if(s&&i>=s.r0&&i<=s.r1)return"Column";for(const n of this.tables??[])if(n.headerRows>0&&i===n.r0&&l>=n.c0&&l<=n.c1)return"Column";return p&&l>=p.c0&&l<=p.c1?"Row":null}_text(i,l,s,p,n,e,r,d,m,y){const{ctx:h,sheet:k}=this,g=this.reachX===null?this.textStyle(i,l,n,e,d):this.style(i,l);if(g===null)return;if(j(k)&&this.reachX===null&&ot(h,this.book,k,i,l,n,e,r,d)){this.reset();return}if(s===L&&p===0&&k.hideZeros)return;if(g.ext?.pad){const[c,T,A,I]=g.ext.pad;n+=I,e+=c,r=Math.max(0,r-I-T),d=Math.max(0,d-c-A)}let w=Yt(this.book,s,p,g);if(s===tt&&this.errors!=="displayed"&&(w=this.errors==="blank"?"":this.errors==="dash"?"--":"#N/A"),w===""||s===v&&pt(w)&&(k.kind(i,l)&(et|nt))!==0&&wt(h,w,n,e,r,d,1)||s===v&&Ct(w)&&(k.kind(i,l)&(et|nt))!==0&&Ft(h,w,n,e,r,d,1,{ink:g.color??"#000000",snap:!1,mono:this.mono})||k.sparkRules!==null&&zt(k,i,l))return;const F=J(g);this.setFont(F);let M=g.color??"#000000";s===L&&g.numFmt!=="General"&&(M=K(g.numFmt).color(p)??M),this.setInk(this.mono?"#000000":M);const b=Gt,C=s===v?at(g.readingOrder,w):null;s===v&&!("direction"in h)&&(w=ht(w,C==="rtl")),C==="rtl"&&"direction"in h?(h.direction="rtl",this.pendingDirection=!0):this.pendingDirection&&(h.direction="ltr",this.pendingDirection=!1);const O=g.hAlign??(s===L||C==="rtl"?"right":s===v?"left":"center");if(O==="centerContinuous")for(let c=l+1;(k.kind(i,c)&15)===0&&k.mergeAt(i,c)===null&&this.book.styles.get(k.style(i,c)).hAlign==="centerContinuous";c++)r+=k.cols.sizeOf(c);const D=r-b*2,z=g.fontSize;if(this.reachX!==null&&(g.rotation!==0||g.wrap))return;if(g.rotation!==0){this.rotated(w,g,n,e,r,d);return}if(g.wrap||dt(g)){this.wrapped(w,g,O,n,e,r,d,b,z);return}const N=s===v?this.book.strings.rich?.get(p):void 0;if(N!==void 0&&!this.mono){this.richLine(w,N,g,O,n,e,r,d,b);return}const R=g.vAlign??"bottom";let x;if(R==="top"?x=e+z*1.05:R==="center"?x=e+(d+z*.72)/2:x=e+d-3,w.indexOf(it)>=0){if(this.reachX!==null)return;const c=w.split(it),T=c[0],A=c[1]??" ",I=c.slice(2).join("");h.textAlign="left",T&&h.fillText(T,n+b,x);const H=this.width(T),B=this.width(I);if(A!==" "){const G=this.width(A)||1,Z=Math.floor((D-H-B)/G);Z>0&&h.fillText(A.repeat(Z),n+b+H,x)}h.textAlign="right",I&&h.fillText(I,n+r-b,x),h.textAlign="left";return}let S=this.width(w);if(S>D&&s===L&&(g.numFmt==="General"&&(w=kt(p,c=>this.width(c)<=D),S=this.width(w)),S>D)){const c=this.width("#")||1;w="#".repeat(Math.max(1,Math.floor(D/c))),S=c*w.length}let P=!1;if(g.shrink&&S>D&&D>0&&(this.setFont(E(g,z*(D/S))),S=D,P=!0),g.indent>0){const c=g.indent*Xt;O==="left"?(n+=c,r-=c):O==="right"&&(r-=c)}let o,a=!1,f=n,u=n+r;if(O==="center"||O==="centerContinuous")o=n+(r-S)/2;else if(O==="right")o=n+r-b-S;else if(O==="fill"){const c=Math.max(1,Math.floor(D/(S||1)));w=w.repeat(c),S*=c,o=n+b}else o=n+b;if(this.reachX!==null&&o+S<=this.reachX){P&&this.setFont(F);return}if(S>D||o<n+b)if(y)a=!0;else if(s===v){if(o+S>u){let c=l+1,T=u;for(;T<o+S&&c<=m.c1&&(k.kind(i,c)&15)===0&&k.mergeAt(i,c)===null;)T+=k.cols.sizeOf(c),c++;u=T}if(o<f){let c=l-1,T=f;for(;T>o&&c>=m.c0&&(k.kind(i,c)&15)===0&&k.mergeAt(i,c)===null;)T-=k.cols.sizeOf(c),c--;f=T}a=o+S>u||o<f}else a=!0;h.textAlign="left",a?(h.save(),h.beginPath(),h.rect(f,e,u-f,d),h.clip(),h.fillText(w,o,x),this.decorate(g,o,x,S,z),h.restore()):(h.fillText(w,o,x),(g.underline!==0||g.strike)&&this.decorate(g,o,x,S,z)),P&&this.setFont(F)}decorate(i,l,s,p,n){const{ctx:e}=this,r=Math.max(.5,n/14);if(i.underline!==0){const d=s+n*.14;e.fillRect(l,d,p,r),i.underline===2&&e.fillRect(l,d+r*2,p,r)}i.strike&&e.fillRect(l,s-n*.3,p,r)}wrapLines(i,l,s){const p=`${i}|${Math.round(s)}|${l}`;let n=this.wrapCache.get(p);if(n!==void 0)return n;n=[];for(const e of l.split(`
|
|
2
|
+
`)){let r="";for(const d of e.split(/(?<=\s)/)){const m=r+d;for(r!==""&&this.width(m.trimEnd())>s?(n.push(r.trimEnd()),r=d):r=m;this.width(r.trimEnd())>s&&r.length>1;){let y=r.length-1;for(;y>1&&this.width(r.slice(0,y))>s;)y--;n.push(r.slice(0,y)),r=r.slice(y)}}n.push(r.trimEnd())}return this.wrapCache.size>4096&&this.wrapCache.clear(),this.wrapCache.set(p,n),n}wrapped(i,l,s,p,n,e,r,d,m){const{ctx:y}=this,h=this.wrapLines(J(l),i,e-d*2),k=Math.round(m*1.26),g=h.length*k,w=l.vAlign??"bottom";let F;w==="top"?F=n:w==="center"?F=n+(r-g)/2:F=n+r-g,y.save(),y.beginPath(),y.rect(p,n,e,r),y.clip(),y.textAlign=s==="center"?"center":s==="right"?"right":"left";const M=s==="center"?p+e/2:s==="right"?p+e-d:p+d;for(let b=0;b<h.length;b++){const C=F+b*k+Math.round(k*.8);C+k<n||C-k>n+r||y.fillText(h[b],M,C)}y.restore(),y.textAlign="left"}rotated(i,l,s,p,n,e){const{ctx:r}=this;r.save(),r.beginPath(),r.rect(s,p,n,e),r.clip(),r.translate(s+n/2,p+e/2);const d=l.rotation;if(r.textAlign="center",d===255){const m=l.fontSize*1.1,y=-((i.length-1)*m)/2;for(let h=0;h<i.length;h++)r.fillText(i[h],0,y+h*m)}else{const m=d>90?90-d:d;r.rotate(-m*Math.PI/180),r.fillText(i,0,l.fontSize*.35)}r.restore(),r.textAlign="left"}side(i,l,s,p,n){if(!i)return;const{ctx:e}=this,r=Kt[i.style]??.5;if(e.strokeStyle=this.mono?"#000000":i.color??"#000000",e.lineWidth=r,e.setLineDash(Ut[i.style]??[]),e.beginPath(),i.style==="double"){const d=s===n?0:.75,m=s===n?.75:0;e.moveTo(l-d,s-m),e.lineTo(p-d,n-m),e.moveTo(l+d,s+m),e.lineTo(p+d,n+m)}else e.moveTo(l,s),e.lineTo(p,n);e.stroke()}}function rt(t,i,l){const s=new Float64Array(l-i+2);let p=0;for(let n=i;n<=l;n++)s[n-i]=p,p+=t.sizeOf(n);return s[l-i+1]=p,s}function Jt(t,i,l,s,p){const{ctx:n,sheet:e}=t,{x:r,y:d,r0:m,r1:y,c0:h,c1:k}=i,g=rt(e.cols,h,k),w=rt(e.rows,m,y),F=k-h+1,M=y-m+1,b=g[F],C=w[M];if(b<=0||C<=0)return;if(n.save(),n.beginPath(),n.rect(r,d,b,C),n.clip(),t.reset(),l){n.strokeStyle=U,n.lineWidth=Y,n.setLineDash([]),n.beginPath();for(let o=0;o<=F;o++)o>0&&g[o]===g[o-1]||(n.moveTo(r+g[o],d),n.lineTo(r+g[o],d+C));for(let o=0;o<=M;o++)o>0&&w[o]===w[o-1]||(n.moveTo(r,d+w[o]),n.lineTo(r+b,d+w[o]));n.stroke()}const O=e.mergesInRows(m,y).filter(o=>o.c1>=h&&o.c0<=k),D=O.length>0,z=e.rowStyles!==null||e.colStyles!==null,N=t.styles[0].fill===null&&t.styles[0].borders===null;t.tables=null;const{book:R}=t;if(R.engine&&R.engine.tables.size>0){const o=vt(R,e);o.length>0&&(t.tables=o);for(const a of o){if(a.r1<m||a.r0>y||a.c1<h||a.c0>k)continue;const f=Nt(a.styleName,R.theme);f&&(a._colors=f,Ht(n,a,f,{ra:m,rb:y,ca:h,cb:k,xs:g,ys:w,ox:r,oy:d,line:.5,noFill:t.mono,setInk:u=>t.setInk(t.mono?"#000000":u)}))}}let x=null;for(let o=h;o<=k;o++){const a=g[o-h+1]-g[o-h];if(a===0)continue;const f=e.columns[o];if(!(f===void 0&&!z&&N))for(let u=m;u<=y;u++){if(!z&&N){const A=f[u>>>Q];if(A===void 0||A.styles===null){u|=W;continue}if(A.styles[u&W]===0)continue}const c=w[u-m+1]-w[u-m];if(c===0)continue;const T=t.style(u,o);T.fill===null&&T.borders===null||D&&e.mergeAt(u,o)!==null||(T.fill!==null&&!t.mono&&(T.gradient?q(T.gradient,r+g[o-h],d+w[u-m],a,c,(A,I,H,B,G)=>{t.setInk(A),n.fillRect(I,H,B,G)}):(t.setInk(ft(T)),n.fillRect(r+g[o-h],d+w[u-m],a,c))),T.borders!==null&&(x??=[]).push(u,o,T.borders))}}const S=o=>{const a=r+e.cols.offsetOf(o.c0)-e.cols.offsetOf(h),f=d+e.rows.offsetOf(o.r0)-e.rows.offsetOf(m);return{x:a,y:f,w:e.cols.offsetOf(o.c1+1)-e.cols.offsetOf(o.c0),h:e.rows.offsetOf(o.r1+1)-e.rows.offsetOf(o.r0)}};for(const o of O){const a=S(o),f=t.style(o.r0,o.c0);(l||f.fill!==null&&!t.mono)&&(f.gradient&&!t.mono?q(f.gradient,a.x,a.y,a.w,a.h,(u,c,T,A,I)=>{t.setInk(u),n.fillRect(c,T,A,I)}):(t.setInk(f.fill!==null&&!t.mono?ft(f):"#ffffff"),n.fillRect(a.x,a.y,a.w,a.h))),l&&(n.strokeStyle=U,n.lineWidth=Y,n.setLineDash([]),n.strokeRect(a.x,a.y,a.w,a.h))}if(t.cfFrame=null,ct(e)){e.cfEval||(e.cfEval=new Ot(R,e,a=>Lt(a,R.theme??[])));const o=new Map;t.cfFrame=o;for(let a=h;a<=k;a++){const f=g[a-h+1]-g[a-h];for(let u=m;u<=y;u++){const c=e.cfEval.at(u,a);if(c===null)continue;o.set(u*16384+a,c);const T=r+g[a-h],A=d+w[u-m],I=w[u-m+1]-w[u-m];c.noFill&&!t.mono&&(t.setInk("#FFFFFF"),n.fillRect(T,A,f,I)),c.fill&&!t.mono&&(t.setInk(c.fill),n.fillRect(T,A,f,I)),c.bar&&!t.mono&&(Rt(n,c.bar,T,A,f,I,1,!1,!0),t.ink=""),c.borders&&(x??=[]).push(u,a,c.borders)}}}if(x!==null)for(let o=0;o<x.length;o+=3){const a=x[o],f=x[o+1],u=x[o+2],c=r+g[f-h],T=r+g[f-h+1],A=d+w[a-m],I=d+w[a-m+1];t.side(u.t,c,A,T,A),t.side(u.b,c,I,T,I),t.side(u.l,c,A,c,I),t.side(u.r,T,A,T,I),u.d&&u.down&&t.side(u.d,c,A,T,I),u.d&&u.up&&t.side(u.d,c,I,T,A)}for(const o of O){const a=S(o);for(let f=o.c0;f<=o.c1;f++){const u=e.cols.sizeOf(f),c=a.x+e.cols.offsetOf(f)-e.cols.offsetOf(o.c0),T=t.style(o.r0,f).borders;T?.t&&t.side(T.t,c,a.y,c+u,a.y);const A=t.style(o.r1,f).borders;A?.b&&t.side(A.b,c,a.y+a.h,c+u,a.y+a.h)}for(let f=o.r0;f<=o.r1;f++){const u=e.rows.sizeOf(f),c=a.y+e.rows.offsetOf(f)-e.rows.offsetOf(o.r0),T=t.style(f,o.c0).borders;T?.l&&t.side(T.l,a.x,c,a.x,c+u);const A=t.style(f,o.c1).borders;A?.r&&t.side(A.r,a.x+a.w,c,a.x+a.w,c+u)}}if(e.sparklines&&e.sparklines.length>0&&R.engine)for(const[o,a]of xt(e)){const f=Math.floor(o/16384),u=o-f*16384;f<m||f>y||u<h||u>k||At(n,R.engine,e,a,f,u,r+g[u-h],d+w[f-m],g[u-h+1]-g[u-h],w[f-m+1]-w[f-m],1,{snap:!1,mono:t.mono})}e.sparkRules!==null&&Mt(n,R,e,{r0:m,r1:y,c0:h,c1:k,xs:g,ys:w,ox:r,oy:d,mono:t.mono}),t.reset(),n.textBaseline="alphabetic",n.textAlign="left";const P={c0:h,c1:k};for(let o=h;o<=k;o++){const a=r+g[o-h],f=g[o-h+1]-g[o-h];if(f===0)continue;const u=e.columns[o];if(u!==void 0)for(let c=m;c<=y;c++){const T=u[c>>>Q];if(T===void 0){c|=W;continue}const A=c&W,I=T.kinds[A]&$;if(I===X||D&&e.mergeAt(c,o)!==null)continue;const H=w[c-m+1]-w[c-m];H!==0&&t.text(c,o,I,T.values[A],a,d+w[c-m],f,H,P)}}if(s<h)for(let o=m;o<=y;o++){const a=w[o-m+1]-w[o-m];if(a===0||e.kind(o,h)!==0)continue;let f=0;for(let u=h-1;u>=Math.max(s,h-$t);u--){f+=e.cols.sizeOf(u);const c=e.kind(o,u)&$;if(c!==X){c===v&&e.mergeAt(o,u)===null&&(t.reachX=r,t.text(o,u,c,e.value(o,u),r-f,d+w[o-m],e.cols.sizeOf(u),a,P),t.reachX=null);break}}}for(const o of O){const a=e.kind(o.r0,o.c0)&$;if(a===X)continue;const f=S(o);t.text(o.r0,o.c0,a,e.value(o.r0,o.c0),f.x,f.y,f.w,f.h,P,!0)}j(e)&&bt(t.book,e,m,y,h,k,(o,a)=>{ot(t.ctx,t.book,e,o,a,r+g[a-h],d+w[o-m],g[a-h+1]-g[a-h],w[o-m+1]-w[o-m]),t.reset()}),p&&(t.reset(),p(i),t.reset()),n.restore(),t.reset()}function Zt(t,i,l){const{ctx:s,sheet:p}=t,{headingW:n,headingH:e,titleW:r,titleH:d}=i,m=r+i.bodyW,y=d+i.bodyH;s.strokeStyle=U,s.lineWidth=Y,s.setLineDash([]),t.reset(),s.font=l,s.textBaseline="alphabetic",s.textAlign="center",t.setInk("#000000");const h=3;s.strokeRect(0,0,n+m,e),s.strokeRect(0,0,n,e+y);const k=(w,F,M)=>{let b=M;for(let C=w;C<=F;C++){const O=p.cols.sizeOf(C);O>0&&(s.beginPath(),s.moveTo(b+O,0),s.lineTo(b+O,e),s.stroke(),s.fillText(Tt(C),b+O/2,e-h)),b+=O}},g=(w,F,M)=>{let b=M;for(let C=w;C<=F;C++){const O=p.rows.sizeOf(C);O>0&&(s.beginPath(),s.moveTo(0,b+O),s.lineTo(n,b+O),s.stroke(),s.fillText(String(C+1),n/2,b+O-h)),b+=O}};i.titleCols&&k(i.titleCols.c0,i.titleCols.c1,n),k(i.c0,i.c1,n+r),i.titleRows&&g(i.titleRows.r0,i.titleRows.r1,e),g(i.r0,i.r1,e+d),s.textAlign="left"}const _=new Map;function jt(t){let i=_.get(t);return i===void 0&&(i=Wt(t),_.size>256&&_.clear(),_.set(t,i)),i}function qt(t,i){switch(t.field){case"page":return String(i.pageNumber+(t.offset??0));case"pages":return String(i.totalPages);case"date":return i.now.toLocaleDateString(i.locale);case"time":return i.now.toLocaleTimeString(i.locale,{hour:"2-digit",minute:"2-digit"});case"file":return i.fileName;case"sheet":return i.sheetName;case"path":return i.filePath;default:return""}}function Qt(t,i){const l=[[]];for(const s of t)(s.field?qt(s,i):s.text).split(`
|
|
3
|
+
`).forEach((e,r)=>{r>0&&l.push([]),e&&l[l.length-1].push({...s,text:e})});return l}function te(t,i,l,s,p,n=null){const{setup:e,paper:r}=i,d=e.margins,m=s.pageNumber%2===0,y=O=>e.differentFirst&&s.sheetPage===0?O.first:e.differentOddEven&&m?O.even:O.odd,h=y(e.header),k=y(e.footer);if(!h&&!k)return;const g=s.defaultStyle,w=(e.alignWithMargins?d.left:.7)*72,F=r.width-(e.alignWithMargins?d.right:.7)*72;t.save(),t.textBaseline="alphabetic",t.textAlign="left";const M=(O,D,z,N)=>{const R=O.map(P=>{const o=(P.size??V)*p*(P.script!==0?.66:1),a=E({...g,fontName:P.font??g.fontName,bold:P.bold,italic:P.italic},o);return t.font=a,{run:P,size:o,font:a,width:t.measureText(P.text).width}});let x=0;for(const P of R)x+=P.width;let S=z==="center"?D-x/2:z==="right"?D-x:D;for(const{run:P,size:o,font:a,width:f}of R){t.font=a;const u=e.blackAndWhite?"#000000":P.color??"#000000";t.fillStyle=u;const c=N-(P.script===1?o*.5:P.script===-1?-o*.2:0);t.fillText(P.text,S,c);const T=Math.max(.4,o/14);P.underline&&(t.fillRect(S,c+o*.14,f,T),P.underline===2&&t.fillRect(S,c+o*.14+T*2,f,T)),P.strike&&t.fillRect(S,c-o*.3,f,T),S+=f}},b=O=>{let D=V;return O.length>0&&(D=Math.max(...O.map(z=>z.size??V))),D*p*1.2},C=(O,D,z,N)=>{if(O.length===0)return;const R=Qt(O,s);if(N){let x=d.header*72;for(const S of R){const P=b(S);M(S,D,z,x+P*.8),x+=P}}else{let x=r.height-d.footer*72;for(let S=R.length-1;S>=0;S--){const P=b(R[S]);M(R[S],D,z,x-P*.2),x-=P}}};for(const[O,D]of[[h,!0],[k,!1]]){if(!O)continue;const z=jt(O),N=n?.[D?"header":"footer"];N!=="L"&&C(z.left,w,"left",D),N!=="C"&&C(z.center,r.width/2,"center",D),N!=="R"&&C(z.right,F,"right",D)}t.restore()}function ee(t,i){t.translate((i.paperW-2*i.originX)/i.scale,0),t.scale(-1,1);const l=Object.prototype.hasOwnProperty.call(t,"fillText"),s=t.fillText;return t.fillText=function(n,e,r){const d=t.measureText(n).width,m=t.textAlign,y=m==="right"||m==="end"?e-d:m==="center"?e-d/2:e;t.save(),t.scale(-1,1),t.textAlign="left",s.call(t,n,-y-d,r),t.restore()},()=>{l?t.fillText=s:delete t.fillText}}function lt(t,i,l,s={}){const{book:p,sheet:n,setup:e}=i,r=p.styles.list[0];t.save(),s.background!==!1&&(t.fillStyle="#ffffff",t.fillRect(0,0,l.paperW,l.paperH)),ut(t,n,l,s.sheetPage??l.index,e);const d={pageNumber:s.pageNumber??l.index+1,totalPages:s.totalPages??i.pageCount,sheetPage:s.sheetPage??l.index,fileName:s.fileName??p.fileName??"",filePath:s.filePath??"",sheetName:n.name,now:s.now??new Date,locale:s.locale,defaultStyle:r};if(te(t,i,l,d,e.scaleWithDoc?l.scale:1),l.noteLines){_t(t,l),t.restore();return}t.save(),t.translate(l.originX,l.originY),t.scale(l.scale,l.scale);const m=n.rtl===!0?ee(t,l):null,y=new Vt(t,p,n,e),{headingW:h,headingH:k,titleW:g,titleH:w,titleRows:F,titleCols:M,r0:b,r1:C,c0:O,c1:D,area:z}=l;y.titleRows=F,y.titleCols=M;const N=e.gridLines&&!e.draft;e.headings&&Zt(y,l,E(r,r.fontSize));const R=s.objectPainters??null,x=e.cellComments==="asDisplayed"&&n.comments?.size>0,S=R&&R.length>0||x?f=>{const u=f.x-n.cols.offsetOf(f.c0),c=f.y-n.rows.offsetOf(f.r0),T={printing:!0,dpr:1,zoom:1,hx:f.x,hy:f.y,cssW:f.x+n.cols.offsetOf(f.c1+1)-n.cols.offsetOf(f.c0),cssH:f.y+n.rows.offsetOf(f.r1+1)-n.rows.offsetOf(f.r0),toScreen:(A,I)=>({x:u+A,y:c+I}),sheet:n};for(const A of R??[])A(t,T);x&&Bt(t,n,T.toScreen,f)}:null;if(l.chartBox){if(R){const f={printing:!0,dpr:1,zoom:1,hx:0,hy:0,cssW:l.bodyW,cssH:l.bodyH,toScreen:(u,c)=>({x:u,y:c}),sheet:n,chartBox:l.chartBox};for(const u of R)u(t,f)}t.restore(),t.restore();return}const P=h+g,o=k+w,a=(f,u)=>{s.objectsOnly?(t.save(),t.beginPath(),t.rect(f.x,f.y,n.cols.offsetOf(f.c1+1)-n.cols.offsetOf(f.c0),n.rows.offsetOf(f.r1+1)-n.rows.offsetOf(f.r0)),t.clip(),S?.(f),t.restore()):Jt(y,f,N,u,S),t.link&&s.onPlace&&Et(t,p,n,f,s.onPlace)};a({x:P,y:o,r0:b,r1:C,c0:O,c1:D},z.c0),F&&a({x:P,y:k,r0:F.r0,r1:F.r1,c0:O,c1:D},z.c0),M&&a({x:h,y:o,r0:b,r1:C,c0:M.c0,c1:M.c1},M.c0),F&&M&&a({x:h,y:k,r0:F.r0,r1:F.r1,c0:M.c0,c1:M.c1},M.c0),m?.(),t.restore(),t.restore()}function Ce(t,i,l,{pxPerPt:s=2,...p}={}){const n=i.at(l);if(n===null)return null;const{page:e,pagination:r}=n;t.width=Math.max(1,Math.round(e.paperW*s)),t.height=Math.max(1,Math.round(e.paperH*s));const d=t.getContext("2d",{alpha:!1});return d.setTransform(s,0,0,s,0,0),lt(d,r,e,{pageNumber:n.pageNumber,totalPages:n.totalPages,sheetPage:n.sheetPage,...p}),n}const ne=()=>new Promise(t=>setTimeout(t,0)),oe={gray0625:.0625,gray125:.125,lightGray:.25,mediumGray:.5,darkGray:.75,lightHorizontal:.25,lightVertical:.25,lightDown:.25,lightUp:.25,lightGrid:.44,lightTrellis:.5,darkHorizontal:.5,darkVertical:.5,darkDown:.5,darkUp:.5,darkGrid:.5,darkTrellis:.75};function ft(t){if(!t.pattern)return t.fill;const i=oe[t.pattern.type]??.5,l=s=>{const p=parseInt(t.pattern.fg.slice(s,s+2),16),n=parseInt(t.fill.slice(s,s+2),16);return Math.round(p*i+n*(1-i)).toString(16).padStart(2,"0")};return`#${l(1)}${l(3)}${l(5)}`}async function Fe(t,i,l={}){const{title:s,author:p,subject:n,fonts:e,compress:r,tagged:d=!0,lang:m,openPassword:y,permissionsPassword:h,permissions:k,signal:g,onProgress:w,...F}=l,[{PdfWriter:M}]=await Promise.all([import("./pdf.js"),It(t)]),b=new M(i,{title:s,author:p,subject:n,fonts:e,compress:r,tagged:d,lang:m,openPassword:y,permissionsPassword:h,permissions:k}),C=F.now??new Date;let O=performance.now();const D=new Map,z=(R,x,S)=>{const P=`${t.book.sheets.indexOf(R)}:${x}:${S}`;if(!D.has(P)){const o=t.entries.find(f=>f.sheet===R),a=o?o.pagination.pageAt(x,S):-1;if(D.set(P,a<0?null:`L${D.size}`),a>=0){const f=o.pagination.page(a),u=f.headingH+f.titleH+R.rows.offsetOf(x)-R.rows.offsetOf(f.r0);b.destination(D.get(P),o.first+a,f.paperH-f.originY-u*f.scale)}}return D.get(P)};let N=null;for(let R=0;R<t.pageCount;R++){g?.throwIfAborted();const x=t.at(R),{page:S,pagination:P}=x;P.sheet!==N&&(N=P.sheet,b.bookmark(N.name,R),b.section(N.name));const o=b.beginPage(S.paperW,S.paperH);lt(o,P,S,{...F,now:C,onPlace:z,background:!1,pageNumber:x.pageNumber,totalPages:x.totalPages,sheetPage:x.sheetPage}),await b.endPage(),w?.(R+1,t.pageCount),performance.now()-O>12&&(await ne(),O=performance.now())}return b.bookmarks.length<2&&(b.bookmarks.length=0),await b.finish(),{pages:b.pageCount,bytes:b.offset,missing:[...b.missing],fontWarnings:b.fontWarnings}}export{Yt as displayText,te as paintHeaderFooter,Ce as renderJobPageToCanvas,lt as renderPage,Fe as writeJobPdf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{noteBox as O,noteCorner as E,noteDisplayText as N,isThread as $}from"../cells/note-box.js";import{MAX_COLS as M}from"../core/address.js";function g(o){const t=[];for(const[i,e]of o.comments??[]){if(!e.visible||$(e))continue;const a=Math.floor(i/M),s=i-a*M;o.rows.sizeOf(a)===0||o.cols.sizeOf(s)===0||t.push({row:a,col:s,note:e,box:O(o,a,s,e)})}return t}function v(o){let t=-1,i=-1;for(const{box:e}of g(o))t=Math.max(t,o.rows.indexAt(Math.max(0,e.y+e.h-.01))),i=Math.max(i,o.cols.indexAt(Math.max(0,e.x+e.w-.01)));return t<0?null:{r1:t,c1:i}}function z(o,t,i){const e=[];for(const a of String(t).split(/\r?\n/)){let s="";for(const w of a.split(/(?<=\s)/)){let f=w;for(s&&o.measureText((s+f).trimEnd()).width>i&&(e.push(s.trimEnd()),s="");f.length>1&&o.measureText(f.trimEnd()).width>i;){let h=1;for(;h<f.length&&o.measureText(f.slice(0,h+1)).width<=i;)h++;e.push(f.slice(0,h)),f=f.slice(h)}s+=f}e.push(s.trimEnd())}return e}function P(o,t,i,e){const a=t.cols.offsetOf(e.c0),s=t.cols.offsetOf(e.c1+1),w=t.rows.offsetOf(e.r0),f=t.rows.offsetOf(e.r1+1);for(const{row:h,col:k,note:b,box:n}of g(t)){const c=E(t,h,k);if(Math.min(n.x,c.x)>s||n.x+n.w<a||Math.min(n.y,c.y)>f||n.y+n.h<w)continue;const r=b.style??{},l=i(n.x,n.y),p=i(c.x,c.y);o.save(),o.marks&&o.beginParagraph(),o.strokeStyle=r.borderColor??"#808080",o.lineWidth=.75,o.beginPath(),o.moveTo(p.x,p.y),o.lineTo(l.x,Math.min(l.y+n.h,Math.max(l.y,p.y))),o.stroke(),o.fillStyle=r.backColor??"#ffffe1",o.fillRect(l.x,l.y,n.w,n.h),r.borderStyle!=="none"&&(o.lineWidth=r.borderWidth??1,o.strokeRect(l.x,l.y,n.w,n.h)),o.beginPath(),o.rect(l.x,l.y,n.w,n.h),o.clip();const y=r.fontSize??10,S=r.fontName?`"${r.fontName}", Tahoma, sans-serif`:"Tahoma, Verdana, sans-serif";o.font=`${r.italic?"italic ":""}${r.bold?"bold ":""}${y}px ${S}`,o.fillStyle=r.color??"#000000",o.textBaseline="alphabetic",o.textAlign="left";const d=3;let u=l.y+d+y;for(const m of z(o,N(b),n.w-2*d)){if(u-y>l.y+n.h)break;const T=n.w-2*d-o.measureText(m).width,x=l.x+d+(r.align==="center"?T/2:r.align==="right"?T:0);m&&o.fillText(m,x,u),r.underline&&m&&o.fillRect(x,u+1.5,o.measureText(m).width,.75),u+=y*1.2}o.marks&&o.endMark(),o.restore()}}export{P as paintShownNotes,g as shownNotes,v as shownNotesExtent};
|
package/shapes/form-xml.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{child as O,children as M,parseTree as E,unescapeXml as I}from"../io/xml-scan.js";import{relsPathOf as B,resolveTarget as N}from"../io/package-paths.js";import{XML_HEAD as w,parseXml as z}from"../objects/dml.js";import{escapeMarkup as x,xmlLiteralText as y}from"../io/xml-escape.js";import{parseRels as V}from"../objects/drawing-xml.js";const k="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",q="http://schemas.openxmlformats.org/markup-compatibility/2006",W="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",X="http://schemas.microsoft.com/office/drawing/2010/main",ce="http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp",xe="http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",me="application/vnd.ms-excel.controlproperties+xml",fe="application/vnd.openxmlformats-officedocument.vmlDrawing",$={button:{objectType:"Button",label:"Button",vml:"Button"},spin:{objectType:"Spin",label:"Spinner",vml:"Spin"},scroll:{objectType:"Scroll",label:"Scroll Bar",vml:"Scroll"},list:{objectType:"List",label:"List Box",vml:"List"},check:{objectType:"CheckBox",label:"Check Box",vml:"Checkbox"},radio:{objectType:"Radio",label:"Option Button",vml:"Radio"},label:{objectType:"Label",label:"Label",vml:"Label"},group:{objectType:"GBox",label:"Group Box",vml:"GBox"},drop:{objectType:"Drop",label:"Drop Down",ui:"Combo Box",vml:"Drop"}},H=Object.fromEntries(Object.entries($).map(([e,o])=>[o.objectType,e])),b=Object.fromEntries(Object.entries($).map(([e,o])=>[o.vml,e]));function de(e){const o=$[e].objectType;switch(e){case"button":case"label":return{objectType:o,lockText:"1"};case"check":case"radio":return{objectType:o,lockText:"1",noThreeD:"1",...e==="radio"?{firstButton:"1"}:{}};case"group":return{objectType:o,noThreeD:"1"};case"spin":return{objectType:o,dx:"15",inc:"1",max:"100",min:"0",page:"10",val:"0"};case"scroll":return{objectType:o,dx:"15",horiz:"1",inc:"1",max:"100",min:"0",page:"10",val:"0"};case"list":return{objectType:o,dx:"15",noThreeD:"1",sel:"0",val:"0"};default:return{objectType:o,dropStyle:"combo",dx:"15",noThreeD:"1",sel:"0",val:"0",dropLines:"8"}}}function Y(e){return H[e?.objectType]??null}function G(e){const o=z(e),t={...o.root.a};delete t.xmlns;for(const s of Object.keys(t))s.startsWith("xmlns")&&delete t[s];const n=M(O(o.root,"itemLst"),"item").map(s=>s.a.val??"");return{attrs:t,items:n.length?n:void 0}}function he(e){const o=Object.entries(e.attrs).filter(([,n])=>n!=null).map(([n,s])=>` ${n}="${x(s)}"`).join(""),t=e.items?.length?`<itemLst>${e.items.map(n=>`<item val="${x(n)}"/>`).join("")}</itemLst>`:"";return`${w}<formControlPr xmlns="${k}"${o}${t?`>${t}</formControlPr>`:"/>"}`}const U=/<v:(?:shape|rect|roundrect|oval|line)\b[^>]*\bid="_x0000_s(\d+)"[\s\S]*?<\/v:(?:shape|rect|roundrect|oval|line)>/g;function g(e,o){const t=new RegExp(`<x:${o}>([\\s\\S]*?)</x:${o}>`).exec(e);return t?t[1].trim():void 0}function J(e,o){const t=b[o],n={objectType:$[t].objectType},s={FmlaLink:"fmlaLink",FmlaRange:"fmlaRange",Val:"val",Min:"min",Max:"max",Inc:"inc",Page:"page",Dx:"dx",Sel:"sel",DropLines:"dropLines",Checked:"checked",FmlaTxbx:"fmlaTxbx",FmlaMacro:"macro"};for(const[p,m]of Object.entries(s)){const l=g(e,p);l!==void 0&&(n[m]=I(l))}/<x:Horiz\s*\/>/.test(e)&&(n.horiz="1"),/<x:NoThreeD2?\s*\/>/.test(e)&&(n.noThreeD="1"),/<x:FirstButton\s*\/>/.test(e)&&(n.firstButton="1");const r=g(e,"SelType");r&&r!=="Single"&&(n.selType=r.toLowerCase());const a=g(e,"DropStyle");return a&&(n.dropStyle=a.toLowerCase()),n}function K(e){const o=new Map;for(const t of e.matchAll(U)){const n=t[0],s=/ObjectType="(\w+)"/.exec(n)?.[1];!s||!b[s]||o.set(Number(t[1]),{type:b[s],attrs:J(n,s),printObject:g(n,"PrintObject")!=="False",disabled:/<x:Disabled>True/.test(n)||/<x:Disabled\s*\/>/.test(n)})}return o}async function Q(e){const o=e.pipeThrough(new TextDecoderStream).getReader();let t="";const n=1<<20;for(;;){const{value:a,done:p}=await o.read();if(p)break;t+=a,t.length>n*2&&(t=t.slice(-n))}const s=new Map,r=t.lastIndexOf("<controls");if(r<0)return s;for(const a of t.slice(r).matchAll(/<control\b([^>]*)>/g)){const p=/shapeId="(\d+)"/.exec(a[1])?.[1],m=/r:id="([^"]+)"/.exec(a[1])?.[1];p&&m&&s.set(Number(p),{rid:m,name:/name="([^"]*)"/.exec(a[1])?.[1]})}return s}async function ue(e,o){const t=B(o);if(!e.has(t))return null;const n=V(await e.bytes(t)),s=l=>N(o,l),r=n.filter(l=>/\/ctrlProp$/.test(l.type)),a=n.find(l=>/\/vmlDrawing$/.test(l.type));if(r.length===0&&!a)return null;const p=new Map,m=a?s(a.target):null;if(m&&e.has(m))for(const[l,i]of K(await e.text(m)))p.set(l,{...i,vmlPath:m});if(r.length>0){const l=await Q(await e.stream(o)),i=new Map(r.map(d=>[d.id,s(d.target)]));for(const[d,h]of l){const c=i.get(h.rid);if(!c||!e.has(c))continue;const f=G(await e.bytes(c)),u=Y(f.attrs);if(!u)continue;const T=p.get(d);p.set(d,{...T??{},type:u,attrs:f.attrs,items:f.items,path:c,rid:h.rid,vmlPath:m,name:h.name})}}return p.size>0?p:null}const _='<v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><v:stroke joinstyle="miter"/><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"/><v:f eqn="sum @0 1 0"/><v:f eqn="sum 0 0 @1"/><v:f eqn="prod @2 1 2"/><v:f eqn="prod @3 21600 pixelWidth"/><v:f eqn="prod @3 21600 pixelHeight"/><v:f eqn="sum @0 0 1"/><v:f eqn="prod @6 1 2"/><v:f eqn="prod @7 21600 pixelWidth"/><v:f eqn="sum @8 21600 0"/><v:f eqn="prod @7 21600 pixelHeight"/><v:f eqn="sum @10 21600 0"/></v:formulas><v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/><o:lock v:ext="edit" aspectratio="t"/></v:shapetype>';function L(e,o){const t=e.rect,n=`position:absolute;margin-left:${t.x}pt;margin-top:${t.y}pt;width:${t.w}pt;height:${t.h}pt;z-index:${o};visibility:visible`;return`<v:shape id="Picture_x0020_${e.shapeId}" o:spid="_x0000_s${e.shapeId}" type="#_x0000_t75" style="${n}"><v:imagedata o:relid="${x(e.relId)}" o:title=""/><x:ClientData ObjectType="Pict"><x:SizeWithCells/><x:Anchor>${S(e.anchor)}</x:Anchor><x:FmlaPict>${x(e.range)}</x:FmlaPict><x:CF>Pict</x:CF><x:Camera/></x:ClientData></v:shape>`}const P='<v:shapetype id="_x0000_t201" coordsize="21600,21600" o:spt="201" path="m,l,21600r21600,l21600,xe"><v:stroke joinstyle="miter"/><v:path shadowok="f" o:extrusionok="f" strokeok="f" fillok="f" o:connecttype="rect"/><o:lock v:ext="edit" shapetype="t"/></v:shapetype>';function v(e){return Math.round(e/12700)}function S(e){return`${e.from.col}, ${v(e.from.colOff)}, ${e.from.row}, ${v(e.from.rowOff)}, ${e.to.col}, ${v(e.to.colOff)}, ${e.to.row}, ${v(e.to.rowOff)}`}const $e=e=>e?"True":"False";function D(e,o){const t=e.attrs,n=e.rect,s=`position:absolute;margin-left:${n.x}pt;margin-top:${n.y}pt;width:${n.w}pt;height:${n.h}pt;z-index:${o}`,r=[];if(e.moveWithCells===!1&&r.push("<x:MoveWithCells/>"),e.sizeWithCells===!1&&r.push("<x:SizeWithCells/>"),r.push(`<x:Anchor>${S(e.anchor)}</x:Anchor>`),e.print===!1&&r.push("<x:PrintObject>False</x:PrintObject>"),(e.type==="check"||e.type==="radio")&&r.push("<x:AutoFill>False</x:AutoFill>","<x:AutoLine>False</x:AutoLine>","<x:TextVAlign>Center</x:TextVAlign>"),e.type==="button"&&r.push("<x:AutoFill>False</x:AutoFill>","<x:TextHAlign>Center</x:TextHAlign>","<x:TextVAlign>Center</x:TextVAlign>"),(e.type==="label"||e.type==="drop")&&r.push("<x:AutoFill>False</x:AutoFill>"),t.fmlaLink&&r.push(`<x:FmlaLink>${x(t.fmlaLink)}</x:FmlaLink>`),t.fmlaTxbx&&r.push(`<x:FmlaTxbx>${x(t.fmlaTxbx)}</x:FmlaTxbx>`),e.macro&&r.push(`<x:FmlaMacro>${x(e.macro)}</x:FmlaMacro>`),(e.type==="check"||e.type==="radio")&&(t.checked&&t.checked!=="Unchecked"&&t.checked!=="0"&&r.push(`<x:Checked>${t.checked==="Mixed"||t.checked==="2"?2:1}</x:Checked>`),t.noThreeD&&r.push("<x:NoThreeD/>"),t.firstButton&&r.push("<x:FirstButton/>")),e.type==="group"&&t.noThreeD&&r.push("<x:NoThreeD/>"),(e.type==="spin"||e.type==="scroll"||e.type==="list"||e.type==="drop")&&(r.push(`<x:Val>${x(t.val??0)}</x:Val>`,`<x:Min>${x(t.min??0)}</x:Min>`,`<x:Max>${x(t.max??100)}</x:Max>`,`<x:Inc>${x(t.inc??1)}</x:Inc>`,`<x:Page>${x(t.page??10)}</x:Page>`),t.horiz&&r.push("<x:Horiz/>"),r.push(`<x:Dx>${x(t.dx??15)}</x:Dx>`)),e.type==="list"||e.type==="drop"){t.fmlaRange&&r.push(`<x:FmlaRange>${x(t.fmlaRange)}</x:FmlaRange>`),r.push(`<x:Sel>${x(t.sel??0)}</x:Sel>`),t.noThreeD&&r.push("<x:NoThreeD2/>");const i=t.selType??"single";r.push(`<x:SelType>${i[0].toUpperCase()}${i.slice(1)}</x:SelType>`,"<x:LCT>Normal</x:LCT>"),e.type==="drop"&&r.push(`<x:DropStyle>${(t.dropStyle??"combo")[0].toUpperCase()}${(t.dropStyle??"combo").slice(1)}</x:DropStyle>`,`<x:DropLines>${x(t.dropLines??8)}</x:DropLines>`)}let a="";const p=e.type==="button"||e.type==="check"||e.type==="radio"||e.type==="label"||e.type==="group";p&&(a=`<v:textbox style="mso-direction-alt:auto" o:singleclick="f"><div style="text-align:${e.type==="button"?"center":"left"};direction:ltr"><font face="Calibri" size="220" color="auto">${y(e.text??"")}</font></div></v:textbox>`);const m=e.type==="button"?' fillcolor="#f0f0f0 [67]"':e.type==="check"||e.type==="radio"?' filled="f" stroked="f"':e.type==="label"?' filled="f"':"",l=p?'<o:lock v:ext="edit" rotation="t"/>':'<o:lock v:ext="edit" rotation="t" text="t"/>';return`<v:shape id="_x0000_s${e.shapeId}" type="#_x0000_t201" style="${s}"${m} o:insetmode="auto">${l}${a}<x:ClientData ObjectType="${$[e.type].vml}">${r.join("")}</x:ClientData></v:shape>`}function j(e,o,t=[]){const n=e.map((r,a)=>D(r,a+1)).join(""),s=t.map((r,a)=>L(r,e.length+a+1)).join("");return`<xml xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel"><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="${o}"/></o:shapelayout>${P}${t.length?_:""}${n}${s}</xml>`}function Z(e,o,t,n=[]){let s=e.replace(/<v:(shape|rect|roundrect|oval|line)\b(?:(?!<\/v:\1>)[\s\S])*?<\/v:\1>/g,l=>{const i=/ObjectType="(\w+)"/.exec(l)?.[1];return i==="Pict"&&/<x:Camera\s*\/>/.test(l)||i&&b[i]?"":l});const r=new Set([...o,...n].map(l=>l.shapeId));let a=Math.max(1024,...r);for(const l of s.matchAll(/_x0000_s(\d+)/g))a=Math.max(a,Number(l[1]));s=s.replace(/id="_x0000_s(\d+)"/g,(l,i)=>r.has(Number(i))?`id="_x0000_s${++a}"`:l),o.length&&!/id="_x0000_t201"/.test(s)&&(s=s.replace("</xml>",`${P}</xml>`)),n.length&&!/id="_x0000_t75"/.test(s)&&(s=s.replace("</xml>",`${_}</xml>`)),t!==void 0&&(s=s.replace(/(<o:idmap\b[^>]*data=")([^"]*)(")/,(l,i,d,h)=>{const c=new Set(String(d).split(",").filter(Boolean));for(const f of String(t).split(","))c.add(f);return`${i}${[...c].join(",")}${h}`}));let p=1;for(const l of s.matchAll(/z-index:(\d+)/g))p=Math.max(p,Number(l[1])+1);const m=n.map((l,i)=>L(l,p+o.length+i)).join("");return s.replace("</xml>",`${o.map((l,i)=>D(l,p+i)).join("")}${m}</xml>`)}const F=(e,o)=>`<${e}><xdr:col>${o.col}</xdr:col><xdr:colOff>${Math.round(o.colOff)}</xdr:colOff><xdr:row>${o.row}</xdr:row><xdr:rowOff>${Math.round(o.rowOff)}</xdr:rowOff></${e}>`;function ee(e){const o=e.moveWithCells===!1?"":' moveWithCells="1"',t=e.sizeWithCells===!1?"":' sizeWithCells="1"',n=[' defaultSize="0"',e.print===!1?' print="0"':"",e.locked===!1?' locked="0"':"",e.type==="check"||e.type==="radio"||e.type==="button"||e.type==="label"||e.type==="drop"?' autoFill="0"':"",e.type==="check"||e.type==="radio"?' autoLine="0"':"",' autoPict="0"',e.macro?` macro="${x(e.macro)}"`:"",e.altText?` altText="${y(e.altText)}"`:""].join("");return`<mc:AlternateContent><mc:Choice Requires="x14"><control shapeId="${e.shapeId}" r:id="${x(e.rid)}" name="${x(e.name)}"><controlPr${n}><anchor${o}${t}>${F("from",e.anchor.from)}${F("to",e.anchor.to)}</anchor></controlPr></control></mc:Choice></mc:AlternateContent>`}function te(e){return e.length===0?"":`<mc:AlternateContent xmlns:mc="${q}" xmlns:x14="${k}" xmlns:xdr="${W}"><mc:Choice Requires="x14"><controls>${e.map(ee).join("")}</controls></mc:Choice></mc:AlternateContent>`}function oe(e){return e.replace(/<mc:AlternateContent\b[^>]*>\s*<mc:Choice\b[^>]*>\s*<controls\b[\s\S]*?<\/controls>\s*<\/mc:Choice>\s*(?:<mc:Fallback\b[\s\S]*?<\/mc:Fallback>\s*)?<\/mc:AlternateContent>/,"").replace(/<controls\b[\s\S]*?<\/controls>/,"")}const ne=/<(?:legacyDrawingHF|picture|oleObjects|mc:AlternateContent|controls|webPublishItems|tableParts|extLst)\b|<\/worksheet>/,re=/<(?:webPublishItems|tableParts|extLst)\b|<\/worksheet>/;function R(e,o,t){const n=o.exec(e);return n?e.slice(0,n.index)+t+e.slice(n.index):e+t}async function ye(e,o,t){const{source:n,relsName:s,addRel:r,extraParts:a}=t;let p=oe(e);const m=n?.zip.has(s)?await n.zip.text(s):"";for(const c of o.parts)a.push({path:c.path,xml:c.xml});for(const c of o.newRels)m.includes(`Id="${c.id}"`)||r(c.id,"ctrlProp",c.target,!1);const l=/<legacyDrawing\b[^>]*r:id="([^"]+)"/.exec(p)?.[1];let i=null;if(l){const c=`${m}${(t.pendingRels??[]).join("")}`,f=new RegExp(`<Relationship\\b[^>]*Id="${l}"[^>]*/>`).exec(c),u=f&&/Target="([^"]+)"/.exec(f[0])?.[1];u&&(i=t.resolveTarget(t.part,u))}const d=i?a.find(c=>c.path===i):null,h=o.cameras??[];if(i){const c=d?d.xml:n?.zip.has(i)?await n.zip.text(i):null,f=c?Z(c,o.items,o.idmap,h):j(o.items,o.idmap,h);d?d.xml=f:a.push({path:i,xml:f})}else(o.items.length>0||h.length>0)&&(i=o.vmlPath,a.push({path:i,xml:j(o.items,o.idmap,h)}),m.includes(`Id="${o.vmlRelId}"`)||r(o.vmlRelId,"vmlDrawing",t.relativeTo(t.part,i),!1),p=R(p,ne,`<legacyDrawing r:id="${o.vmlRelId}"/>`));if(h.length>0){const c=i.lastIndexOf("/"),f=`${i.slice(0,c)}/_rels/${i.slice(c+1)}.rels`,T=(n?.zip.has(f)?await n.zip.text(f):`${w}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>`).replace(/<Relationship\b[^>]*Id="rIdCam\d+"[^>]*\/>/g,""),A=h.map(C=>`<Relationship Id="${x(C.relId)}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="${x(t.relativeTo(i,C.imagePath))}"/>`).join("");a.push({path:f,xml:T.replace("</Relationships>",`${A}</Relationships>`)})}return o.items.length>0&&(p=R(p,re,te(o.items))),p}function be(e,o){return new RegExp(`id="_x0000_s${o}"`).test(e)}function ge(e,o){return`<xdr:sp macro="" textlink=""><xdr:nvSpPr><xdr:cNvPr id="${e.id}" name="${y(e.name??"")}" hidden="1"${e.descr?` descr="${y(e.descr)}"`:""}><a:extLst><a:ext uri="{63B3BB69-23CF-44E3-9099-C40C66FF867C}"><a14:compatExt xmlns:a14="${X}" spid="_x0000_s${e.id}"/></a:ext></a:extLst></xdr:cNvPr><xdr:cNvSpPr/></xdr:nvSpPr><xdr:spPr bwMode="auto"><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:noFill/><a:ln><a:noFill/></a:ln></xdr:spPr>${o}</xdr:sp>`}export{$ as CONTROL_TYPES,me as CTRL_CONTENT_TYPE,ce as CTRL_REL,X as NS_A14,q as NS_MC,k as NS_X14,W as NS_XDR,fe as VML_CONTENT_TYPE,xe as VML_REL,ye as applyControls,Y as controlTypeOf,te as controlsListXml,he as ctrlPropXml,de as newControlAttrs,j as newVmlXml,G as parseCtrlProp,E as parseTree,K as parseVmlControls,Z as patchVmlControls,ge as placeholderSpXml,ue as readSheetControls,oe as removeControlsList,Q as scanControlsList,L as vmlCameraXml,be as vmlHasShape,D as vmlShapeXml};
|
|
1
|
+
import{child as O,children as M,parseTree as E,unescapeXml as I}from"../io/xml-scan.js";import{relsPathOf as B,resolveTarget as N}from"../io/package-paths.js";import{XML_HEAD as w,parseXml as z}from"../objects/dml.js";import{escapeMarkup as x,xmlLiteralText as y}from"../io/xml-escape.js";import{parseRels as V}from"../objects/drawing-xml.js";const k="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",q="http://schemas.openxmlformats.org/markup-compatibility/2006",W="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",X="http://schemas.microsoft.com/office/drawing/2010/main",ce="http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp",xe="http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",me="application/vnd.ms-excel.controlproperties+xml",fe="application/vnd.openxmlformats-officedocument.vmlDrawing",$={button:{objectType:"Button",label:"Button",vml:"Button"},spin:{objectType:"Spin",label:"Spinner",vml:"Spin"},scroll:{objectType:"Scroll",label:"Scroll Bar",vml:"Scroll"},list:{objectType:"List",label:"List Box",vml:"List"},check:{objectType:"CheckBox",label:"Check Box",vml:"Checkbox"},radio:{objectType:"Radio",label:"Option Button",vml:"Radio"},label:{objectType:"Label",label:"Label",vml:"Label"},group:{objectType:"GBox",label:"Group Box",vml:"GBox"},drop:{objectType:"Drop",label:"Drop Down",ui:"Combo Box",vml:"Drop"}},H=Object.fromEntries(Object.entries($).map(([e,o])=>[o.objectType,e])),b=Object.fromEntries(Object.entries($).map(([e,o])=>[o.vml,e]));function de(e){const o=$[e].objectType;switch(e){case"button":case"label":return{objectType:o,lockText:"1"};case"check":case"radio":return{objectType:o,lockText:"1",noThreeD:"1",...e==="radio"?{firstButton:"1"}:{}};case"group":return{objectType:o,noThreeD:"1"};case"spin":return{objectType:o,dx:"15",inc:"1",max:"100",min:"0",page:"10",val:"0"};case"scroll":return{objectType:o,dx:"15",horiz:"1",inc:"1",max:"100",min:"0",page:"10",val:"0"};case"list":return{objectType:o,dx:"15",noThreeD:"1",sel:"0",val:"0"};default:return{objectType:o,dropStyle:"combo",dx:"15",noThreeD:"1",sel:"0",val:"0",dropLines:"8"}}}function Y(e){return H[e?.objectType]??null}function G(e){const o=z(e),t={...o.root.a};delete t.xmlns;for(const s of Object.keys(t))s.startsWith("xmlns")&&delete t[s];const n=M(O(o.root,"itemLst"),"item").map(s=>s.a.val??"");return{attrs:t,items:n.length?n:void 0}}function he(e){const o=Object.entries(e.attrs).filter(([,n])=>n!=null).map(([n,s])=>` ${n}="${x(s)}"`).join(""),t=e.items?.length?`<itemLst>${e.items.map(n=>`<item val="${x(n)}"/>`).join("")}</itemLst>`:"";return`${w}<formControlPr xmlns="${k}"${o}${t?`>${t}</formControlPr>`:"/>"}`}const U=/<v:(?:shape|rect|roundrect|oval|line)\b[^>]*\bid="_x0000_s(\d+)"[\s\S]*?<\/v:(?:shape|rect|roundrect|oval|line)>/g;function g(e,o){const t=new RegExp(`<x:${o}>([\\s\\S]*?)</x:${o}>`).exec(e);return t?t[1].trim():void 0}function J(e,o){const t=b[o],n={objectType:$[t].objectType},s={FmlaLink:"fmlaLink",FmlaRange:"fmlaRange",Val:"val",Min:"min",Max:"max",Inc:"inc",Page:"page",Dx:"dx",Sel:"sel",DropLines:"dropLines",Checked:"checked",FmlaTxbx:"fmlaTxbx",FmlaMacro:"macro"};for(const[p,m]of Object.entries(s)){const l=g(e,p);l!==void 0&&(n[m]=I(l))}/<x:Horiz\s*\/>/.test(e)&&(n.horiz="1"),/<x:NoThreeD2?\s*\/>/.test(e)&&(n.noThreeD="1"),/<x:FirstButton\s*\/>/.test(e)&&(n.firstButton="1");const r=g(e,"SelType");r&&r!=="Single"&&(n.selType=r.toLowerCase());const a=g(e,"DropStyle");return a&&(n.dropStyle=a.toLowerCase()),n}function K(e){const o=new Map;for(const t of e.matchAll(U)){const n=t[0],s=/ObjectType="(\w+)"/.exec(n)?.[1];!s||!b[s]||o.set(Number(t[1]),{type:b[s],attrs:J(n,s),printObject:g(n,"PrintObject")!=="False",disabled:/<x:Disabled>True/.test(n)||/<x:Disabled\s*\/>/.test(n)})}return o}async function Q(e){const o=e.pipeThrough(new TextDecoderStream).getReader();let t="";const n=1<<20;for(;;){const{value:a,done:p}=await o.read();if(p)break;t+=a,t.length>n*2&&(t=t.slice(-n))}const s=new Map,r=t.lastIndexOf("<controls");if(r<0)return s;for(const a of t.slice(r).matchAll(/<control\b([^>]*)>/g)){const p=/shapeId="(\d+)"/.exec(a[1])?.[1],m=/r:id="([^"]+)"/.exec(a[1])?.[1];p&&m&&s.set(Number(p),{rid:m,name:/name="([^"]*)"/.exec(a[1])?.[1]})}return s}async function ue(e,o){const t=B(o);if(!e.has(t))return null;const n=V(await e.bytes(t)),s=l=>N(o,l),r=n.filter(l=>/\/ctrlProp$/.test(l.type)),a=n.find(l=>/\/vmlDrawing$/.test(l.type));if(r.length===0&&!a)return null;const p=new Map,m=a?s(a.target):null;if(m&&e.has(m))for(const[l,i]of K(await e.text(m)))p.set(l,{...i,vmlPath:m});if(r.length>0){const l=await Q(await e.stream(o)),i=new Map(r.map(d=>[d.id,s(d.target)]));for(const[d,h]of l){const c=i.get(h.rid);if(!c||!e.has(c))continue;const f=G(await e.bytes(c)),u=Y(f.attrs);if(!u)continue;const T=p.get(d);p.set(d,{...T??{},type:u,attrs:f.attrs,items:f.items,path:c,rid:h.rid,vmlPath:m,name:h.name})}}return p.size>0?p:null}const _='<v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><v:stroke joinstyle="miter"/><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"/><v:f eqn="sum @0 1 0"/><v:f eqn="sum 0 0 @1"/><v:f eqn="prod @2 1 2"/><v:f eqn="prod @3 21600 pixelWidth"/><v:f eqn="prod @3 21600 pixelHeight"/><v:f eqn="sum @0 0 1"/><v:f eqn="prod @6 1 2"/><v:f eqn="prod @7 21600 pixelWidth"/><v:f eqn="sum @8 21600 0"/><v:f eqn="prod @7 21600 pixelHeight"/><v:f eqn="sum @10 21600 0"/></v:formulas><v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/><o:lock v:ext="edit" aspectratio="t"/></v:shapetype>';function L(e,o){const t=e.rect,n=`position:absolute;margin-left:${t.x}pt;margin-top:${t.y}pt;width:${t.w}pt;height:${t.h}pt;z-index:${o};visibility:visible`;return`<v:shape id="Picture_x0020_${e.shapeId}" o:spid="_x0000_s${e.shapeId}" type="#_x0000_t75" style="${n}"><v:imagedata o:relid="${x(e.relId)}" o:title=""/><x:ClientData ObjectType="Pict"><x:SizeWithCells/><x:Anchor>${S(e.anchor)}</x:Anchor><x:FmlaPict>${x(e.range)}</x:FmlaPict><x:CF>Pict</x:CF><x:Camera/></x:ClientData></v:shape>`}const P='<v:shapetype id="_x0000_t201" coordsize="21600,21600" o:spt="201" path="m,l,21600r21600,l21600,xe"><v:stroke joinstyle="miter"/><v:path shadowok="f" o:extrusionok="f" strokeok="f" fillok="f" o:connecttype="rect"/><o:lock v:ext="edit" shapetype="t"/></v:shapetype>';function v(e){return Math.round(e/12700)}function S(e){return`${e.from.col}, ${v(e.from.colOff)}, ${e.from.row}, ${v(e.from.rowOff)}, ${e.to.col}, ${v(e.to.colOff)}, ${e.to.row}, ${v(e.to.rowOff)}`}const $e=e=>e?"True":"False";function D(e,o){const t=e.attrs,n=e.rect,s=`position:absolute;margin-left:${n.x}pt;margin-top:${n.y}pt;width:${n.w}pt;height:${n.h}pt;z-index:${o}`,r=[];if(e.moveWithCells===!1&&r.push("<x:MoveWithCells/>"),e.sizeWithCells===!1&&r.push("<x:SizeWithCells/>"),r.push(`<x:Anchor>${S(e.anchor)}</x:Anchor>`),e.print===!1&&r.push("<x:PrintObject>False</x:PrintObject>"),(e.type==="check"||e.type==="radio")&&r.push("<x:AutoFill>False</x:AutoFill>","<x:AutoLine>False</x:AutoLine>","<x:TextVAlign>Center</x:TextVAlign>"),e.type==="button"&&r.push("<x:AutoFill>False</x:AutoFill>","<x:TextHAlign>Center</x:TextHAlign>","<x:TextVAlign>Center</x:TextVAlign>"),(e.type==="label"||e.type==="drop")&&r.push("<x:AutoFill>False</x:AutoFill>"),t.fmlaLink&&r.push(`<x:FmlaLink>${x(t.fmlaLink)}</x:FmlaLink>`),t.fmlaTxbx&&r.push(`<x:FmlaTxbx>${x(t.fmlaTxbx)}</x:FmlaTxbx>`),e.macro&&r.push(`<x:FmlaMacro>${x(e.macro)}</x:FmlaMacro>`),(e.type==="check"||e.type==="radio")&&(t.checked&&t.checked!=="Unchecked"&&t.checked!=="0"&&r.push(`<x:Checked>${t.checked==="Mixed"||t.checked==="2"?2:1}</x:Checked>`),t.noThreeD&&r.push("<x:NoThreeD/>"),t.firstButton&&r.push("<x:FirstButton/>")),e.type==="group"&&t.noThreeD&&r.push("<x:NoThreeD/>"),(e.type==="spin"||e.type==="scroll"||e.type==="list"||e.type==="drop")&&(r.push(`<x:Val>${x(t.val??0)}</x:Val>`,`<x:Min>${x(t.min??0)}</x:Min>`,`<x:Max>${x(t.max??100)}</x:Max>`,`<x:Inc>${x(t.inc??1)}</x:Inc>`,`<x:Page>${x(t.page??10)}</x:Page>`),t.horiz&&r.push("<x:Horiz/>"),r.push(`<x:Dx>${x(t.dx??15)}</x:Dx>`)),e.type==="list"||e.type==="drop"){t.fmlaRange&&r.push(`<x:FmlaRange>${x(t.fmlaRange)}</x:FmlaRange>`),r.push(`<x:Sel>${x(t.sel??0)}</x:Sel>`),t.noThreeD&&r.push("<x:NoThreeD2/>");const i=t.selType??"single";r.push(`<x:SelType>${i[0].toUpperCase()}${i.slice(1)}</x:SelType>`,"<x:LCT>Normal</x:LCT>"),e.type==="drop"&&r.push(`<x:DropStyle>${(t.dropStyle??"combo")[0].toUpperCase()}${(t.dropStyle??"combo").slice(1)}</x:DropStyle>`,`<x:DropLines>${x(t.dropLines??8)}</x:DropLines>`)}let a="";const p=e.type==="button"||e.type==="check"||e.type==="radio"||e.type==="label"||e.type==="group";p&&(a=`<v:textbox style="mso-direction-alt:auto" o:singleclick="f"><div style="text-align:${e.type==="button"?"center":"left"};direction:ltr"><font face="Calibri" size="220" color="auto">${y(e.text??"")}</font></div></v:textbox>`);const m=e.type==="button"?' fillcolor="#f0f0f0 [67]"':e.type==="check"||e.type==="radio"?' filled="f" stroked="f"':e.type==="label"?' filled="f"':"",l=p?'<o:lock v:ext="edit" rotation="t"/>':'<o:lock v:ext="edit" rotation="t" text="t"/>';return`<v:shape id="_x0000_s${e.shapeId}" type="#_x0000_t201" style="${s}"${m} o:insetmode="auto">${l}${a}<x:ClientData ObjectType="${$[e.type].vml}">${r.join("")}</x:ClientData></v:shape>`}function j(e,o,t=[]){const n=e.map((r,a)=>D(r,a+1)).join(""),s=t.map((r,a)=>L(r,e.length+a+1)).join("");return`<xml xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel"><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="${o}"/></o:shapelayout>${P}${t.length?_:""}${n}${s}</xml>`}function Z(e,o,t,n=[]){let s=e.replace(/<v:(shape|rect|roundrect|oval|line)\b(?:(?!<\/v:\1>)[\s\S])*?<\/v:\1>/g,l=>{const i=/ObjectType="(\w+)"/.exec(l)?.[1];return i==="Pict"&&/<x:Camera\s*\/>/.test(l)||i&&b[i]?"":l});const r=new Set([...o,...n].map(l=>l.shapeId));let a=Math.max(1024,...r);for(const l of s.matchAll(/_x0000_s(\d+)/g))a=Math.max(a,Number(l[1]));s=s.replace(/id="_x0000_s(\d+)"/g,(l,i)=>r.has(Number(i))?`id="_x0000_s${++a}"`:l),o.length&&!/id="_x0000_t201"/.test(s)&&(s=s.replace("</xml>",()=>`${P}</xml>`)),n.length&&!/id="_x0000_t75"/.test(s)&&(s=s.replace("</xml>",()=>`${_}</xml>`)),t!==void 0&&(s=s.replace(/(<o:idmap\b[^>]*data=")([^"]*)(")/,(l,i,d,h)=>{const c=new Set(String(d).split(",").filter(Boolean));for(const f of String(t).split(","))c.add(f);return`${i}${[...c].join(",")}${h}`}));let p=1;for(const l of s.matchAll(/z-index:(\d+)/g))p=Math.max(p,Number(l[1])+1);const m=n.map((l,i)=>L(l,p+o.length+i)).join("");return s.replace("</xml>",`${o.map((l,i)=>D(l,p+i)).join("")}${m}</xml>`)}const F=(e,o)=>`<${e}><xdr:col>${o.col}</xdr:col><xdr:colOff>${Math.round(o.colOff)}</xdr:colOff><xdr:row>${o.row}</xdr:row><xdr:rowOff>${Math.round(o.rowOff)}</xdr:rowOff></${e}>`;function ee(e){const o=e.moveWithCells===!1?"":' moveWithCells="1"',t=e.sizeWithCells===!1?"":' sizeWithCells="1"',n=[' defaultSize="0"',e.print===!1?' print="0"':"",e.locked===!1?' locked="0"':"",e.type==="check"||e.type==="radio"||e.type==="button"||e.type==="label"||e.type==="drop"?' autoFill="0"':"",e.type==="check"||e.type==="radio"?' autoLine="0"':"",' autoPict="0"',e.macro?` macro="${x(e.macro)}"`:"",e.altText?` altText="${y(e.altText)}"`:""].join("");return`<mc:AlternateContent><mc:Choice Requires="x14"><control shapeId="${e.shapeId}" r:id="${x(e.rid)}" name="${x(e.name)}"><controlPr${n}><anchor${o}${t}>${F("from",e.anchor.from)}${F("to",e.anchor.to)}</anchor></controlPr></control></mc:Choice></mc:AlternateContent>`}function te(e){return e.length===0?"":`<mc:AlternateContent xmlns:mc="${q}" xmlns:x14="${k}" xmlns:xdr="${W}"><mc:Choice Requires="x14"><controls>${e.map(ee).join("")}</controls></mc:Choice></mc:AlternateContent>`}function oe(e){return e.replace(/<mc:AlternateContent\b[^>]*>\s*<mc:Choice\b[^>]*>\s*<controls\b[\s\S]*?<\/controls>\s*<\/mc:Choice>\s*(?:<mc:Fallback\b[\s\S]*?<\/mc:Fallback>\s*)?<\/mc:AlternateContent>/,"").replace(/<controls\b[\s\S]*?<\/controls>/,"")}const ne=/<(?:legacyDrawingHF|picture|oleObjects|mc:AlternateContent|controls|webPublishItems|tableParts|extLst)\b|<\/worksheet>/,re=/<(?:webPublishItems|tableParts|extLst)\b|<\/worksheet>/;function R(e,o,t){const n=o.exec(e);return n?e.slice(0,n.index)+t+e.slice(n.index):e+t}async function ye(e,o,t){const{source:n,relsName:s,addRel:r,extraParts:a}=t;let p=oe(e);const m=n?.zip.has(s)?await n.zip.text(s):"";for(const c of o.parts)a.push({path:c.path,xml:c.xml});for(const c of o.newRels)m.includes(`Id="${c.id}"`)||r(c.id,"ctrlProp",c.target,!1);const l=/<legacyDrawing\b[^>]*r:id="([^"]+)"/.exec(p)?.[1];let i=null;if(l){const c=`${m}${(t.pendingRels??[]).join("")}`,f=new RegExp(`<Relationship\\b[^>]*Id="${l}"[^>]*/>`).exec(c),u=f&&/Target="([^"]+)"/.exec(f[0])?.[1];u&&(i=t.resolveTarget(t.part,u))}const d=i?a.find(c=>c.path===i):null,h=o.cameras??[];if(i){const c=d?d.xml:n?.zip.has(i)?await n.zip.text(i):null,f=c?Z(c,o.items,o.idmap,h):j(o.items,o.idmap,h);d?d.xml=f:a.push({path:i,xml:f})}else(o.items.length>0||h.length>0)&&(i=o.vmlPath,a.push({path:i,xml:j(o.items,o.idmap,h)}),m.includes(`Id="${o.vmlRelId}"`)||r(o.vmlRelId,"vmlDrawing",t.relativeTo(t.part,i),!1),p=R(p,ne,`<legacyDrawing r:id="${o.vmlRelId}"/>`));if(h.length>0){const c=i.lastIndexOf("/"),f=`${i.slice(0,c)}/_rels/${i.slice(c+1)}.rels`,T=(n?.zip.has(f)?await n.zip.text(f):`${w}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>`).replace(/<Relationship\b[^>]*Id="rIdCam\d+"[^>]*\/>/g,""),A=h.map(C=>`<Relationship Id="${x(C.relId)}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="${x(t.relativeTo(i,C.imagePath))}"/>`).join("");a.push({path:f,xml:T.replace("</Relationships>",()=>`${A}</Relationships>`)})}return o.items.length>0&&(p=R(p,re,te(o.items))),p}function be(e,o){return new RegExp(`id="_x0000_s${o}"`).test(e)}function ge(e,o){return`<xdr:sp macro="" textlink=""><xdr:nvSpPr><xdr:cNvPr id="${e.id}" name="${y(e.name??"")}" hidden="1"${e.descr?` descr="${y(e.descr)}"`:""}><a:extLst><a:ext uri="{63B3BB69-23CF-44E3-9099-C40C66FF867C}"><a14:compatExt xmlns:a14="${X}" spid="_x0000_s${e.id}"/></a:ext></a:extLst></xdr:cNvPr><xdr:cNvSpPr/></xdr:nvSpPr><xdr:spPr bwMode="auto"><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:noFill/><a:ln><a:noFill/></a:ln></xdr:spPr>${o}</xdr:sp>`}export{$ as CONTROL_TYPES,me as CTRL_CONTENT_TYPE,ce as CTRL_REL,X as NS_A14,q as NS_MC,k as NS_X14,W as NS_XDR,fe as VML_CONTENT_TYPE,xe as VML_REL,ye as applyControls,Y as controlTypeOf,te as controlsListXml,he as ctrlPropXml,de as newControlAttrs,j as newVmlXml,G as parseCtrlProp,E as parseTree,K as parseVmlControls,Z as patchVmlControls,ge as placeholderSpXml,ue as readSheetControls,oe as removeControlsList,Q as scanControlsList,L as vmlCameraXml,be as vmlHasShape,D as vmlShapeXml};
|