@8sheets/data-grid 1.1.0 → 1.1.2
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/api/serialize.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/financial.js +1 -1
- package/calc/functions/helpers.js +1 -1
- 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 +3 -3
- package/calc/values.js +1 -1
- package/calcx/async.js +1 -1
- package/calcx/functions/dynamic.js +1 -1
- package/calcx/functions/ets.js +1 -1
- package/calcx/functions/misc.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/cf-engine.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/outline-column.js +1 -1
- package/cells/panes.js +1 -1
- package/cells/rich-runs.js +2 -2
- package/cells/rich-values.js +1 -1
- package/cells/selection-modes.js +1 -1
- package/celltypes/cell-types.js +2 -2
- package/celltypes/dropdowns.js +3 -2
- package/celltypes/file-cell.js +2 -2
- package/celltypes/range-template.js +2 -2
- package/core/cell-type-rules.js +1 -0
- package/core/changes.js +1 -1
- package/core/cond-format.js +1 -1
- package/core/culture.js +1 -1
- package/core/edit-ranges.js +1 -0
- package/core/host-rules.js +1 -0
- package/core/input.js +1 -1
- package/core/numfmt.js +1 -1
- package/core/protection.js +1 -1
- package/core/region-input.js +1 -1
- package/core/sheet.js +1 -1
- package/core/sparse.js +1 -1
- package/core/structure.js +1 -1
- package/core/validation-ranges.js +1 -0
- package/core/workbook.js +1 -1
- package/datasheets/manager.js +1 -1
- package/datasheets/persist.js +1 -1
- package/extras/getdata/persist.js +2 -2
- package/i18n/en/cells.js +1 -1
- package/i18n/en/format.js +1 -1
- package/i18n/en/misc.js +1 -1
- package/i18n/en/ribbon.js +1 -1
- package/i18n/pl/cells.js +1 -1
- package/i18n/pl/format.js +1 -1
- package/i18n/pl/misc.js +1 -1
- package/i18n/pl/ribbon.js +1 -1
- package/io/client.js +1 -1
- package/io/csv.js +7 -7
- package/io/encoding.js +1 -0
- package/io/foreign-sheets.js +2 -2
- package/io/plan.js +1 -1
- package/io/xlsx-read.js +1 -1
- package/io/xlsx-tail.js +1 -1
- package/io/xlsx-write.js +2 -2
- package/io/xml-scan.js +2 -1
- package/io/zip-reader.js +1 -1
- package/package.json +1 -1
- package/pivot/engine.js +1 -1
- package/pivot/xml.js +2 -2
- package/print/note-pages.js +2 -0
- package/print/paginate.js +1 -1
- package/print/pdf-links.js +1 -0
- package/print/pdf.js +11 -11
- package/print/render-page.js +3 -3
- package/slicers/format.js +2 -2
- package/slicers/structured.js +1 -1
- package/table-view/files.js +1 -1
- package/table-view/labels-de.js +1 -1
- package/table-view/labels-es.js +1 -1
- package/table-view/labels-fr.js +1 -1
- package/table-view/labels-ja.js +1 -1
- package/table-view/labels.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/protection-ui.js +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parseRangeRef as R,unquoteSheetName as B}from"../core/address.js";import{FORMULA as C}from"../core/sheet.js";import{formulaLink as E}from"../cells/link-model.js";const F=/^(https?:|mailto:|ftp:|tel:)/i;function $(f,r,n,l=0){const a=String(n??"").replace(/^[#=]/,"").trim(),c=a.lastIndexOf("!"),i=R(a.slice(c+1).replace(/\$/g,""));if(i){if(c<0)return{sheet:r,row:i.r0,col:i.c0};const w=B(a.slice(0,c)).toLowerCase(),m=f.sheets.find(p=>p.name.toLowerCase()===w);return m?{sheet:m,row:i.r0,col:i.c0}:null}const s=l===0&&c<0?f.engine?._nameEntry(a,r)?.entry:null;return s?$(f,r,s.text,1):null}const A=new WeakMap;function S(f){const r=f.hyperlinks;if(!r?.length)return[];let n=A.get(r);return n||(n=r.flatMap(l=>(l.ref??"").split(/\s+/).map(R).filter(Boolean).map(a=>({h:l,box:a}))),A.set(r,n)),n}function v(f,r,n,l,a){const{r0:c,r1:i,c0:s,c1:w}=l,m=t=>l.x+n.cols.offsetOf(t)-n.cols.offsetOf(s),p=t=>l.y+n.rows.offsetOf(t)-n.rows.offsetOf(c),k=(t,o)=>{let{r0:e,r1:g,c0:u,c1:x}=o;const O=n.mergeAt(e,u);if(O&&(g=Math.max(g,O.r1),x=Math.max(x,O.c1)),e=Math.max(e,c),u=Math.max(u,s),g=Math.min(g,i),x=Math.min(x,w),e>g||u>x)return;const d=m(x+1)-m(u),L=p(g+1)-p(e);if(d>0&&L>0){if(t.target&&F.test(t.target))f.link(m(u),p(e),d,L,{uri:t.location?`${t.target}#${t.location}`:t.target});else if(!t.target&&t.location){const M=$(r,n,t.location),y=M?a(M.sheet,M.row,M.col):null;y&&f.link(m(u),p(e),d,L,{dest:y})}}};for(const{h:t,box:o}of S(n))o.r0<=i&&o.r1>=c&&o.c0<=w&&o.c1>=s&&k(t,o);if(n.formulas?.size>0)for(let t=c;t<=i;t++)for(let o=s;o<=w;o++){if(!(n.kind(t,o)&C))continue;const e=E(r,n,t,o);e&&k(e,{r0:t,r1:t,c0:o,c1:o})}}export{v as linkRegion,$ as resolveLocation};
|
package/print/pdf.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
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
|
+
const W=new TextEncoder,M=65536,Y=9999999999,J=128,L=()=>{},j=[];for(let a=0;a<256;a++)j.push(a.toString(16).padStart(2,"0"));const F=a=>j[a>>8&255]+j[a&255],b=a=>String(Math.round(a*1e3)/1e3+0),A=a=>Array(10).fill(a),R={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]};R["Helvetica-Oblique"]=R.Helvetica,R["Helvetica-BoldOblique"]=R["Helvetica-Bold"];const K=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]})),H="€\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"]],y=new Map;for(let a=32;a<127;a++)y.set(a,a);for(let a=161;a<=255;a++)y.set(a,a);for(let a=0;a<H.length;a++)H[a]!=="\0"&&y.set(H.codePointAt(a),128+a);z.forEach(([a],t)=>y.set(a.codePointAt(0),t+1));for(const a of[160,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288])y.set(a,32);for(const a of[8208,8209,173])y.set(a,45);y.set(8722,150),y.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(a,t,e){return tt.test(a)?`Courier${t||e?"-":""}${t?"Bold":""}${e?"Oblique":""}`:Z.test(a)&&!Q.test(a)?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=R[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=K.get(e);if(s)return s[this.serif?1:0];if(e==="ł")return this.table[76];if(e==="Ł")return this.table[44];const i=y.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(a){const t=String.fromCodePoint(a).normalize("NFD").codePointAt(0);return y.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 r of["head","hhea","hmtx","maxp","cmap","loca","glyf"])if(!this.tables.has(r))throw new Error(`Font has no ${r} 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 o=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 h=this.tables.get("OS/2");if(h){if((s.getUint16(h.offset+8)&15)===2)throw new Error("Font license forbids embedding");s.getUint16(h.offset)>=2&&h.length>=90&&(this.capHeightUnits=s.getInt16(h.offset+88)||this.ascentUnits)}const f=this._names();this.family=e.family??f.family??"Embedded",this.postscriptName=(f.postscript??this.family).replace(/[^A-Za-z0-9-]/g,""),this.bold=e.bold??(o&1)!==0,this.italic=e.italic??(o&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 o=0;o<i;o++){const h=this._directory(e.getUint32(12+o*4));if(n===null&&(n=h),t&&this._names(h).postscript===t)return h}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 o=t+12+n*16,h=String.fromCharCode(e.getUint8(o),e.getUint8(o+1),e.getUint8(o+2),e.getUint8(o+3));i.set(h,{offset:e.getUint32(o+8),length:e.getUint32(o+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),o=s.offset+i.getUint16(s.offset+4);for(let h=0;h<n;h++){const f=s.offset+6+h*12,r=i.getUint16(f),l=i.getUint16(f+6);if(l!==1&&l!==6)continue;const c=i.getUint16(f+8),u=o+i.getUint16(f+10);let d="";if(r===3||r===0)for(let m=0;m+1<c;m+=2)d+=String.fromCharCode(i.getUint16(u+m));else for(let m=0;m<c;m++)d+=String.fromCharCode(i.getUint8(u+m));const p=l===1?"family":"postscript";(e[p]===void 0||r===3)&&(e[p]=d)}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,w=t.getUint16(m),x=t.getUint16(m+2),U=e+t.getUint32(m+4),$=t.getUint16(U);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:U,format:$})}if(i===null)throw new Error("Font has no Unicode cmap");const{at:o,format:h}=i;if(h===12){const p=t.getUint32(o+12);return m=>{let w=0,x=p-1;for(;w<=x;){const U=w+x>>>1,$=o+16+U*12;if(m<t.getUint32($))x=U-1;else if(m>t.getUint32($+4))w=U+1;else return t.getUint32($+8)+m-t.getUint32($)}return 0}}if(h===6){const p=t.getUint16(o+6),m=t.getUint16(o+8);return w=>w>=p&&w<p+m?t.getUint16(o+10+(w-p)*2):0}const f=t.getUint16(o+6),r=o+14,l=r+f+2,c=l+f,u=c+f,d=f/2;return p=>{if(p>65535)return 0;let m=0,w=d-1;for(;m<w;){const g=m+w>>>1;t.getUint16(r+g*2)<p?m=g+1:w=g}const x=t.getUint16(l+m*2);if(p<x||p>t.getUint16(r+m*2))return 0;const U=t.getInt16(c+m*2),$=t.getUint16(u+m*2);if($===0)return p+U&65535;const I=t.getUint16(u+m*2+$+(p-x)*2);return I===0?0:I+U&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,o=this.longLoca?i.getUint32(e+(t+1)*4):i.getUint16(e+(t+1)*2)*2;return[s+n,o-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 g=0;g<this.order.length;g++){const[_,T]=this._glyphRange(this.order[g]);if(T<=0){t.push(null);continue}const S=this.bytes.slice(_,_+T),k=new DataView(S.buffer);if(k.getInt16(0)<0){let C=10;for(;;){const v=k.getUint16(C);if(k.setUint16(C+2,this._newId(k.getUint16(C+2))),C+=4+(v&1?4:2),v&8?C+=2:v&64?C+=4:v&128&&(C+=8),!(v&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 g=0;g<e;g++)i.setUint32(g*4,n),t[g]&&(n+=t[g].length+3&-4);i.setUint32(e*4,n);const o=new Uint8Array(n);for(let g=0;g<e;g++)t[g]&&o.set(t[g],i.getUint32(g*4));const h=new Uint8Array(e*4),f=new DataView(h.buffer);for(let g=0;g<e;g++)f.setUint16(g*4,this._rawAdvance(this.order[g])),f.setInt16(g*4+2,this._rawLsb(this.order[g]));const r=this._copyTable("head"),l=new DataView(r.buffer);l.setUint32(8,0),l.setInt16(50,1);const c=this._copyTable("hhea");new DataView(c.buffer).setUint16(34,e);const u=this._copyTable("maxp");new DataView(u.buffer).setUint16(4,e);const d=[["glyf",o],["head",r],["hhea",c],["hmtx",h],["loca",s],["maxp",u]];for(const g of["cvt ","fpgm","prep"]){const _=this._copyTable(g);_&&d.push([g,_])}d.sort((g,_)=>g[0]<_[0]?-1:1);let p=12+d.length*16;for(const[,g]of d)p+=g.length+3&-4;const m=new Uint8Array(p),w=new DataView(m.buffer),x=d.length,U=31-Math.clz32(x);w.setUint32(0,65536),w.setUint16(4,x),w.setUint16(6,16<<U),w.setUint16(8,U),w.setUint16(10,x*16-(16<<U));let $=12+x*16,I=0;return d.forEach(([g,_],T)=>{const S=12+T*16;for(let k=0;k<4;k++)w.setUint8(S+k,g.charCodeAt(k));w.setUint32(S+4,q(_)),w.setUint32(S+8,$),w.setUint32(S+12,_.length),m.set(_,$),g==="head"&&(I=$),$+=_.length+3&-4}),w.setUint32(I+8,2981146554-q(m)>>>0),m}}function q(a){let t=0;const e=a.length;for(let s=0;s<e;s+=4){const i=(a[s]<<24|(a[s+1]??0)<<16|(a[s+2]??0)<<8|(a[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"},E=new Map;function O(a){const t=String(a);let e=E.get(t);return e!==void 0||(e=at(t.trim().toLowerCase()),E.size>4096&&E.clear(),E.set(t,e)),e}function at(a){if(a==="transparent")return{r:0,g:0,b:0,a:0,ops:"0 0 0"};let t=ot[a]??null;t===null&&a[0]==="#"&&(t=a.slice(1),(t.length===3||t.length===4)&&(t=[...t].map(h=>h+h).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 h=/^rgba?\(\s*([\d.]+%?)[\s,]+([\d.]+%?)[\s,]+([\d.]+%?)(?:[\s,/]+([\d.]+%?))?\s*\)$/.exec(a);if(!h)return null;const f=r=>r.endsWith("%")?parseFloat(r)*2.55:parseFloat(r);e=f(h[1]),s=f(h[2]),i=f(h[3]),h[4]!==void 0&&(n=h[4].endsWith("%")?parseFloat(h[4])/100:parseFloat(h[4]))}const o=h=>b(Math.min(255,Math.max(0,h))/255);return{r:e,g:s,b:i,a:n,ops:`${o(e)} ${o(s)} ${o(i)}`}}class D{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:O("#000000"),fillText:"#000000",stroke:O("#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.links=[],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 D?t.color??"#000000":t,s=O(e);s!==null&&(this.s.fill=s,this.s.fillText=e)}get strokeStyle(){return this.s.strokeText}set strokeStyle(t){const e=t instanceof D?t.color??"#000000":t,s=O(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,o){const h=this.s,{a:f,b:r,c:l,d:c,e:u,f:d}=h;h.a=f*t+l*e,h.b=r*t+c*e,h.c=f*s+l*i,h.d=r*s+c*i,h.e=f*n+l*o+u,h.f=r*n+c*o+d}setTransform(t,e,s,i,n,o){const h=this.s;typeof t=="object"&&t!==null&&({a:t,b:e,c:s,d:i,e:n,f:o}=t),h.a=t,h.b=e,h.c=s,h.d=i,h.e=n,h.f=o}resetTransform(){this.setTransform(1,0,0,1,0,0)}getTransform(){const{a:t,b:e,c:s,d:i,e:n,f:o}=this.s;return{a:t,b:e,c:s,d:i,e:n,f:o}}_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 o=[this._X(t,e),this._X(t+s,e+i)],h=[this._Y(t,e),this._Y(t+s,e+i)];this.links.push({...n,rect:[Math.min(...o),Math.min(...h),Math.max(...o),Math.max(...h)].map(b).join(" ")})}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,o){this.path.length===0&&this.moveTo(t,e),this.path.push(`${this._pt(t,e)} ${this._pt(s,i)} ${this._pt(n,o)} c`),this.cx=n,this.cy=o}quadraticCurveTo(t,e,s,i){this.path.length===0&&this.moveTo(t,e);const{cx:n,cy:o}=this;this.bezierCurveTo(n+2/3*(t-n),o+2/3*(e-o),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 o=Math.min(Math.abs(Array.isArray(n)?Number(n[0])||0:Number(n)||0),Math.abs(s)/2,Math.abs(i)/2);if(o===0){this.rect(t,e,s,i);return}this.moveTo(t+o,e),this.lineTo(t+s-o,e),this.quadraticCurveTo(t+s,e,t+s,e+o),this.lineTo(t+s,e+i-o),this.quadraticCurveTo(t+s,e+i,t+s-o,e+i),this.lineTo(t+o,e+i),this.quadraticCurveTo(t,e+i,t,e+i-o),this.lineTo(t,e+o),this.quadraticCurveTo(t,e,t+o,e),this.closePath()}arc(t,e,s,i,n,o=!1){this.ellipse(t,e,s,s,0,i,n,o)}ellipse(t,e,s,i,n,o,h,f=!1){let r=h-o;const l=Math.PI*2;!f&&r<0&&(r=r%l+l),f&&r>0&&(r=r%l-l),Math.abs(h-o)>=l&&(r=f?-l:l);const c=Math.cos(n),u=Math.sin(n),d=g=>{const _=s*Math.cos(g),T=i*Math.sin(g);return[t+_*c-T*u,e+_*u+T*c]},p=g=>{const _=-s*Math.sin(g),T=i*Math.cos(g);return[_*c-T*u,_*u+T*c]},m=Math.max(1,Math.ceil(Math.abs(r)/(Math.PI/2))),w=r/m,x=4/3*Math.tan(w/4),[U,$]=d(o);this.path.length===0?this.moveTo(U,$):this.lineTo(U,$);let I=o;for(let g=0;g<m;g++){const _=I+w,[T,S]=d(I),[k,C]=d(_),[v,V]=p(I),[G,X]=p(_);this.bezierCurveTo(T+x*v,S+x*V,k-x*G,C-x*X,k,C),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 o=`[${t.dash.map(r=>b(r*i)).join(" ")}] ${b(t.dashOffset*i)}`;e.dash!==o&&(e.dash=o,s.push(`${o} d`));const h=t.lineCap==="round"?1:t.lineCap==="square"?2:0;e.cap!==h&&(e.cap=h,s.push(`${h} J`));const f=t.lineJoin==="round"?1:t.lineJoin==="bevel"?2:0;e.join!==f&&(e.join=f,s.push(`${f} 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 D}createRadialGradient(){return new D}createConicGradient(){return new D}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:o,s:h}=this,f=o._runs(t,n);let r=0;for(const d of f)r+=d.width;const l=h.textAlign;switch(l==="center"?e-=r/2:(l==="right"||l==="end")&&(e-=r),h.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 c=b(n.size);let u=e;for(const d of f){this.fonts.add(d.font);const p=d.hScale,m=`${b(h.a*p)} ${b(-h.b*p)} ${b(-h.c)} ${b(h.d)} ${b(this._X(u,s))} ${b(this._Y(u,s))}`;this.ops.push(`BT${i?" 1 Tr":""} /F${d.font.resId} ${c} Tf ${m} Tm <${d.hex}> Tj${i?" 0 Tr":""} ET`),u+=d.width}}drawImage(t,...e){const s=this.writer._image(t);if(s===null)return;this.images.add(s);let i=0,n=0,o=s.width,h=s.height,f,r,l,c;if(e.length>=8?[i,n,o,h,f,r,l,c]=e:e.length>=4?[f,r,l,c]=e:([f,r]=e,l=s.width,c=s.height),this._applyAlpha(1),this.ops.push("q"),e.length>=8){const $=this.path;this.path=[],this.rect(f,r,l,c),this.ops.push(`${this.path.join(" ")} W n`),this.path=$;const I=l/o,g=c/h;f-=i*I,r-=n*g,l=s.width*I,c=s.height*g}const u=this.s,d=u.a*l,p=-u.b*l,m=-u.c*c,w=u.d*c,x=this._X(f,r+c),U=this._Y(f,r+c);this.ops.push(`${b(d)} ${b(p)} ${b(m)} ${b(w)} ${b(x)} ${b(U)} cm /Im${s.resId} Do Q`)}}function lt(a){const t=(e,s=2)=>String(e).padStart(s,"0");return`D:${t(a.getUTCFullYear(),4)}${t(a.getUTCMonth()+1)}${t(a.getUTCDate())}${t(a.getUTCHours())}${t(a.getUTCMinutes())}${t(a.getUTCSeconds())}Z`}function B(a){let t="FEFF";for(let e=0;e<a.length;e++)t+=F(a.charCodeAt(e));return`<${t}>`}function ft(a){return`(${[...a].map(e=>/[!-~]/.test(e)?e:encodeURIComponent(e.isWellFormed?.()===!1?"�":e)).join("").replace(/[\\()]/g,"\\$&")})`}function dt(a){let t=2;for(;t+9<a.length;){if(a[t]!==255){t++;continue}const e=a[t+1];if(e>=192&&e<=207&&e!==196&&e!==200&&e!==204)return{height:a[t+5]<<8|a[t+6],width:a[t+7]<<8|a[t+8],components:a[t+9]};t+=2+(a[t+2]<<8|a[t+3])}return null}class bt{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.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.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
|
|
2
2
|
${e}
|
|
3
3
|
endobj
|
|
4
4
|
`)}async _stream(t,e,s,{deflate:i=this.compress}={}){const n=this._alloc();this.xref[t]=this.offset,await this._w(`${t} 0 obj
|
|
5
5
|
<<${e} /Length ${n} 0 R${i?" /Filter /FlateDecode":""}>>
|
|
6
6
|
stream
|
|
7
|
-
`);const
|
|
7
|
+
`);const o=this.offset;if(i){const f=new CompressionStream("deflate"),r=f.writable.getWriter(),l=f.readable.getReader(),u=(async()=>{for(;;){const{done:d,value:p}=await l.read();if(d)return;await this._raw(p)}})().catch(d=>{throw r.abort(d).catch(L),d});try{await s(async d=>{await r.ready,await r.write(d)}),await r.close()}catch(d){throw r.abort(d).catch(L),await u.catch(L),d}await u}else await s(f=>this._raw(f));const h=this.offset-o;await this._w(`
|
|
8
8
|
endstream
|
|
9
9
|
endobj
|
|
10
|
-
`),await this._obj(n,String(
|
|
11
|
-
`)),c));const i=[...t.fonts].map(c=>`/F${c.resId} ${c.objectId} 0 R`).join(" "),n=[...t.images].map(c=>`/Im${c.resId} ${c.objectId} 0 R`).join(" "),
|
|
12
|
-
0 ${
|
|
10
|
+
`),await this._obj(n,String(h))}async _begin(){this.started||(this.started=!0,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 it(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,o=(s?s[3]:"sans-serif").split(",").map(d=>d.trim().replace(/^["']|["']$/g,"").toLowerCase()).filter(Boolean),h=/\bbold\b|\b[6-9]00\b/.test(i),f=/\b(italic|oblique)\b/.test(i),r=[];for(const d of o)for(const p of this.faces)p.familyKey===d&&p.bold===h&&p.italic===f&&!r.includes(p)&&r.push(p);const l=o[0]??"sans-serif",c=this._stdFont(st(l,h,f)),u=r[0]??c;return e={size:n,faces:r,std:c,hScale:!c.mono&&et.test(l)?.9:1,ascent:u.ascent,descent:u.descent},this.specs.set(t,e),e}_measure(t,e){const{size:s,faces:i,std:n,hScale:o}=e;let h=0;for(const f of t){let r=f.codePointAt(0);r<32&&(r=32);let l=null;for(let c=0;c<i.length;c++)if(i[c].gidOf(r)!==0){l=i[c];break}if(l!==null){h+=l.width(r);continue}y.has(r)||(r=N(r)),h+=n.width(r)*o}return h*s/1e3}_runs(t,e){const{size:s,faces:i,std:n,hScale:o}=e,h=[];let f=null;for(const r of t){let l=r.codePointAt(0);l<32&&(l=32);let c=null;for(let w=0;w<i.length;w++)if(i[w].gidOf(l)!==0){c=i[w];break}let u,d,p,m=1;if(c!==null)c.resId===0&&(c.resId=this.nextFontRes++,c.objectId=this._alloc()),u=c,d=F(c.use(l)),p=c.width(l);else{let w=y.get(l);w===void 0&&(this.missing.add(l),l=N(l),w=y.get(l)),u=n,d=j[w],p=n.width(l)*o,m=o}(f===null||f.font!==u)&&(f={font:u,hex:"",width:0,hScale:m},h.push(f)),f.hex+=d,f.width+=p*s/1e3}return h}async _writeFonts(){if(this.stdFonts.size>0){this.encodingId=this._alloc();const e=z.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,ut(t++))}async _writeFace(t,e){const s=t.subset(),i=this._alloc(),n=this._alloc(),o=this._alloc(),h=this._alloc();await this._stream(i,` /Length1 ${s.length}`,d=>P(s,d));const f=gt(t.unicode);await this._stream(n,"",d=>P(W.encode(f),d));const r=`${e}+${t.postscriptName}`,l=t.scale,c=4|(t.italic?64:0)|(t.bold?1<<18:0);await this._obj(o,`<< /Type /FontDescriptor /FontName /${r} /Flags ${c} /FontBBox [${t.bbox.map(d=>Math.round(d*l)).join(" ")}] /ItalicAngle ${b(t.italicAngle)} /Ascent ${Math.round(t.ascentUnits*l)} /Descent ${Math.round(t.descentUnits*l)} /CapHeight ${Math.round(t.capHeightUnits*l)} /StemV ${t.bold?140:80} /FontFile2 ${i} 0 R >>`);const u=[];for(let d=0;d<t.order.length;d++)u.push(Math.round(t._rawAdvance(t.order[d])*l));await this._obj(h,`<< /Type /Font /Subtype /CIDFontType2 /BaseFont /${r} /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /FontDescriptor ${o} 0 R /CIDToGIDMap /Identity /DW 1000 /W [0 [${u.join(" ")}]] >>`),await this._obj(t.objectId,`<< /Type /Font /Subtype /Type0 /BaseFont /${r} /Encoding /Identity-H /DescendantFonts [${h} 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=dt(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=wt(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,o=i*n;let h=!0;for(let r=3;r<o*4;r+=4)if(s[r]!==255){h=!1;break}let f="";if(!h){const r=this._alloc();await this._stream(r,` /Type /XObject /Subtype /Image /Width ${i} /Height ${n} /BitsPerComponent 8 /ColorSpace /DeviceGray`,async l=>{for(let c=0;c<o;c+=65536){const u=Math.min(65536,o-c),d=new Uint8Array(u);for(let p=0;p<u;p++)d[p]=s[(c+p)*4+3];await l(d)}}),f=` /SMask ${r} 0 R`}await this._stream(t.objectId,` ${e} /ColorSpace /DeviceRGB${f}`,async r=>{for(let l=0;l<o;l+=65536){const c=Math.min(65536,o-l),u=new Uint8Array(c*3);for(let d=0;d<c;d++){const p=(l+d)*4;u[d*3]=s[p],u[d*3+1]=s[p+1],u[d*3+2]=s[p+2]}await r(u)}})}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 ct(this,t,e),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();const e=this.pendingImages;this.pendingImages=[];for(const c of e)await this._writeImage(c);const s=this._alloc();await this._stream(s,"",c=>P(W.encode(t.ops.join(`
|
|
11
|
+
`)),c));const i=[...t.fonts].map(c=>`/F${c.resId} ${c.objectId} 0 R`).join(" "),n=[...t.images].map(c=>`/Im${c.resId} ${c.objectId} 0 R`).join(" "),o=[...t.alphas].map(c=>`/A${c} << /ca ${b(c/100)} /CA ${b(c/100)} >>`).join(" "),h=`${i?`/Font << ${i} >>`:""}${n?` /XObject << ${n} >>`:""}${o?` /ExtGState << ${o} >>`:""}`,f=[];for(const c of t.links){const u=this._alloc(),d=c.uri===void 0?`/Dest /${c.dest}`:`/A << /S /URI /URI ${ft(c.uri)} >>`;await this._obj(u,`<< /Type /Annot /Subtype /Link /Rect [${c.rect}] /Border [0 0 0] /F 4 ${d} >>`),f.push(`${u} 0 R`)}const r=this._level(0),l=this._alloc();if(this.pageIds.push(l),await this._obj(l,`<< /Type /Page /Parent ${r.id} 0 R /MediaBox [0 0 ${b(t.pageWidth)} ${b(t.pageHeight)}] /Contents ${s} 0 R${f.length?` /Annots [${f.join(" ")}]`:""} /Resources << ${h} >> >>`),await this._addKid(0,l,1),this.pageCount++,this.offset>Y)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<J)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})}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,o])=>`/${n} [${this.pageIds[o.page]} 0 R /XYZ null ${b(o.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 o=0;o<s.length;o++){const h=`${o>0?` /Prev ${n[o-1]} 0 R`:""}${o+1<n.length?` /Next ${n[o+1]} 0 R`:""}`;await this._obj(n[o],`<< /Title ${B(s[o].title)} /Parent ${i} 0 R${h} /Dest [${this.pageIds[s[o].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(),e=await this._writeNavigation(),s=this._alloc();await this._obj(s,`<< /Type /Catalog /Pages ${t} 0 R${e} /ViewerPreferences << /DisplayDocTitle true >> >>`);const i=this.options,n=lt(i.creationDate??new Date),o=[i.title?`/Title ${B(i.title)}`:"",i.author?`/Author ${B(i.author)}`:"",i.subject?`/Subject ${B(i.subject)}`:"",`/Producer ${B(i.producer??"8sheets")}`,`/CreationDate (${n})`].filter(Boolean).join(" "),h=this._alloc();await this._obj(h,`<< ${o} >>`);const f=this.offset,r=this.nextId;await this._w(`xref
|
|
12
|
+
0 ${r}
|
|
13
13
|
0000000000 65535 f
|
|
14
|
-
`);let
|
|
15
|
-
`,
|
|
16
|
-
<< /Size ${
|
|
14
|
+
`);let l="";for(let u=1;u<r;u++)l+=`${String(this.xref[u]).padStart(10,"0")} 00000 n
|
|
15
|
+
`,l.length>=32768&&(await this._w(l),l="");await this._w(l);const c=mt();await this._w(`trailer
|
|
16
|
+
<< /Size ${r} /Root ${s} 0 R /Info ${h} 0 R /ID [<${c}> <${c}>] >>
|
|
17
17
|
startxref
|
|
18
|
-
${
|
|
18
|
+
${f}
|
|
19
19
|
%%EOF
|
|
20
|
-
`),await this._flush()}}async function P(
|
|
20
|
+
`),await this._flush()}}async function P(a,t){for(let e=0;e<a.length;e+=M)await t(a.subarray(e,Math.min(a.length,e+M)))}function ut(a){let t="",e=a;for(let s=0;s<6;s++)t=String.fromCharCode(65+e%26)+t,e=Math.floor(e/26);return t}function pt(a){if(a<=65535)return F(a);const t=a-65536;return F(55296+(t>>10))+F(56320+(t&1023))}function gt(a){const t=[],e=[];for(let s=1;s<a.length;s++)a[s]!==void 0&&e.push(`<${F(s)}> <${pt(a[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
21
|
12 dict begin
|
|
22
22
|
begincmap
|
|
23
23
|
/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def
|
|
@@ -32,4 +32,4 @@ endcmap
|
|
|
32
32
|
CMapName currentdict /CMap defineresource pop
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
|
-
`}function
|
|
35
|
+
`}function mt(){const a=new Uint8Array(16);return globalThis.crypto.getRandomValues(a),[...a].map(t=>j[t]).join("")}function wt(a){const t=a.naturalWidth??a.videoWidth??a.width,e=a.naturalHeight??a.videoHeight??a.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(a,0,0),i.getImageData(0,0,t,e)}catch{return null}}export{ct as PdfPageContext,bt as PdfWriter};
|
package/print/render-page.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{readingDirection as
|
|
2
|
-
`)){let r="";for(const h of
|
|
3
|
-
`).forEach((
|
|
1
|
+
import{hasCellTypes as q}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 j}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 bt}from"../celltypes/barcode.js";import{printCellType as ot,printEmptyTypedCells as kt}from"../celltypes/cell-types.js";import{FILL_MARK as it,fitGeneral as wt,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 xt}from"../core/cond-format.js";import{drawCfIcon as St,iconSide as Dt,monoContext as Ot,paintCfBar as At}from"../cells/cf-paint.js";import{sparklineIndex as Pt}from"../core/sparklines.js";import{paintSparkline as Rt}from"../sparklines/excel-paint.js";import{isSparklineText as Ft,paintSparklineValue as Ct}from"../sparklines/paint.js";import{paintSparkRulesOnPage as Mt,sparkRuleHidesValue as It}from"../sparklines/rule.js";import{preparePicturesForPrint as zt}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 Bt}from"./note-pages.js";const _t=2,Gt=6,Xt=32,U="#000000",Y=.25,V=10,$t={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},Kt={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 s=st.get(t);return s===void 0&&(s=E(t,t.fontSize),st.set(t,s)),s}function Ut(t,s,f,i){switch(s){case L:return i.numFmt==="General"?yt(f):K(i.numFmt).number(f,t.dateOffset);case v:{const b=t.strings.get(f);return i.numFmt==="General"||i.numFmt==="@"?b:K(i.numFmt).text(b)}case mt:return f?"TRUE":"FALSE";case tt:return gt[f]??"#N/A";default:return""}}class Yt{constructor(s,f,i,b){this.ctx=s,this.book=f,this.sheet=i,this.styles=f.styles.list,this.mono=b.blackAndWhite,this.errors=b.errors,this.cfFrame=null,this.tables=null,this.font="",this.ink="",this.wrapCache=new Map,this.reachX=null}style(s,f){return this.styles[this.sheet.style(s,f)]??this.styles[0]}textStyle(s,f,i,b,o){let e=this.style(s,f);const r=this.cfFrame===null?void 0:this.cfFrame.get(s*16384+f);if(r!==void 0){if(r.icon&&this.icon(r.icon,i,b,o,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 h of this.tables){if(s<h.r0||s>h.r1||f<h.c0||f>h.c1||!h._colors)continue;const d=h._colors.format(h,s,f);e={...e,color:e.color??d.color,bold:e.bold||d.bold===!0,italic:e.italic||d.italic===!0},d.underline&&!e.underline&&(e.underline=d.underline),d.strike&&(e.strike=!0);break}return e}icon(s,f,i,b,o){const e=Dt(b,1,o.fontSize),r=o.vAlign==="top"?i+1:o.vAlign==="center"?i+(b-e)/2:i+b-e-1;St(this.mono?Ot(this.ctx):this.ctx,s.name,s.level,f+1,r,e),this.ink=""}setFont(s){this.font!==s&&(this.ctx.font=s,this.font=s)}setInk(s){this.ink!==s&&(this.ctx.fillStyle=s,this.ink=s)}reset(){this.font="",this.ink=""}width(s){return this.ctx.measureText(s).width}richLine(s,f,i,b,o,e,r,h,d){const{ctx:x}=this,a=[];let k=0,u=0;f.forEach((T,D)=>{const w=f[D+1]?.at??s.length;if(w<=T.at)return;const S={...i,fontName:T.name??i.fontName,fontSize:T.sz??i.fontSize,bold:T.b??i.bold,italic:T.i??i.italic},P=J(S);this.setFont(P);const z=s.slice(T.at,w).replace(/\n/g," "),F=x.measureText(z).width;a.push({piece:z,font:P,ink:T.color??i.color??"#000000",pw:F}),k+=F,u=Math.max(u,S.fontSize)});const p=i.vAlign??"bottom",M=p==="top"?e+u*1.05:p==="center"?e+(h+u*.72)/2:e+h-3;let I=b==="right"?o+r-d-k:b==="center"||b==="centerContinuous"?o+(r-k)/2:o+d;x.textAlign="left";for(const T of a)this.setFont(T.font),this.setInk(T.ink),x.fillText(T.piece,I,M),I+=T.pw}text(s,f,i,b,o,e,r,h,d,x=!1){const{ctx:a,sheet:k}=this,u=this.reachX===null?this.textStyle(s,f,o,e,h):this.style(s,f);if(u===null)return;if(q(k)&&this.reachX===null&&ot(a,this.book,k,s,f,o,e,r,h)){this.reset();return}if(i===L&&b===0&&k.hideZeros)return;if(u.ext?.pad){const[c,y,R,N]=u.ext.pad;o+=N,e+=c,r=Math.max(0,r-N-y),h=Math.max(0,h-c-R)}let p=Ut(this.book,i,b,u);if(i===tt&&this.errors!=="displayed"&&(p=this.errors==="blank"?"":this.errors==="dash"?"--":"#N/A"),p===""||i===v&&pt(p)&&(k.kind(s,f)&(et|nt))!==0&&bt(a,p,o,e,r,h,1)||i===v&&Ft(p)&&(k.kind(s,f)&(et|nt))!==0&&Ct(a,p,o,e,r,h,1,{ink:u.color??"#000000",snap:!1,mono:this.mono})||k.sparkRules!==null&&It(k,s,f))return;const M=J(u);this.setFont(M);let I=u.color??"#000000";i===L&&u.numFmt!=="General"&&(I=K(u.numFmt).color(b)??I),this.setInk(this.mono?"#000000":I);const T=_t,D=i===v?at(u.readingOrder,p):null;i===v&&!("direction"in a)&&(p=ht(p,D==="rtl")),D==="rtl"&&"direction"in a?(a.direction="rtl",this.pendingDirection=!0):this.pendingDirection&&(a.direction="ltr",this.pendingDirection=!1);const w=u.hAlign??(i===L||D==="rtl"?"right":i===v?"left":"center");if(w==="centerContinuous")for(let c=f+1;(k.kind(s,c)&15)===0&&k.mergeAt(s,c)===null&&this.book.styles.get(k.style(s,c)).hAlign==="centerContinuous";c++)r+=k.cols.sizeOf(c);const S=r-T*2,P=u.fontSize;if(this.reachX!==null&&(u.rotation!==0||u.wrap))return;if(u.rotation!==0){this.rotated(p,u,o,e,r,h);return}if(u.wrap||dt(u)){this.wrapped(p,u,w,o,e,r,h,T,P);return}const z=i===v?this.book.strings.rich?.get(b):void 0;if(z!==void 0&&!this.mono){this.richLine(p,z,u,w,o,e,r,h,T);return}const F=u.vAlign??"bottom";let A;if(F==="top"?A=e+P*1.05:F==="center"?A=e+(h+P*.72)/2:A=e+h-3,p.indexOf(it)>=0){if(this.reachX!==null)return;const c=p.split(it),y=c[0],R=c[1]??" ",N=c.slice(2).join("");a.textAlign="left",y&&a.fillText(y,o+T,A);const H=this.width(y),_=this.width(N);if(R!==" "){const G=this.width(R)||1,Z=Math.floor((S-H-_)/G);Z>0&&a.fillText(R.repeat(Z),o+T+H,A)}a.textAlign="right",N&&a.fillText(N,o+r-T,A),a.textAlign="left";return}let O=this.width(p);if(O>S&&i===L&&(u.numFmt==="General"&&(p=wt(b,c=>this.width(c)<=S),O=this.width(p)),O>S)){const c=this.width("#")||1;p="#".repeat(Math.max(1,Math.floor(S/c))),O=c*p.length}let C=!1;if(u.shrink&&O>S&&S>0&&(this.setFont(E(u,P*(S/O))),O=S,C=!0),u.indent>0){const c=u.indent*Gt;w==="left"?(o+=c,r-=c):w==="right"&&(r-=c)}let n,l=!1,m=o,g=o+r;if(w==="center"||w==="centerContinuous")n=o+(r-O)/2;else if(w==="right")n=o+r-T-O;else if(w==="fill"){const c=Math.max(1,Math.floor(S/(O||1)));p=p.repeat(c),O*=c,n=o+T}else n=o+T;if(this.reachX!==null&&n+O<=this.reachX){C&&this.setFont(M);return}if(O>S||n<o+T)if(x)l=!0;else if(i===v){if(n+O>g){let c=f+1,y=g;for(;y<n+O&&c<=d.c1&&(k.kind(s,c)&15)===0&&k.mergeAt(s,c)===null;)y+=k.cols.sizeOf(c),c++;g=y}if(n<m){let c=f-1,y=m;for(;y>n&&c>=d.c0&&(k.kind(s,c)&15)===0&&k.mergeAt(s,c)===null;)y-=k.cols.sizeOf(c),c--;m=y}l=n+O>g||n<m}else l=!0;a.textAlign="left",l?(a.save(),a.beginPath(),a.rect(m,e,g-m,h),a.clip(),a.fillText(p,n,A),this.decorate(u,n,A,O,P),a.restore()):(a.fillText(p,n,A),(u.underline!==0||u.strike)&&this.decorate(u,n,A,O,P)),C&&this.setFont(M)}decorate(s,f,i,b,o){const{ctx:e}=this,r=Math.max(.5,o/14);if(s.underline!==0){const h=i+o*.14;e.fillRect(f,h,b,r),s.underline===2&&e.fillRect(f,h+r*2,b,r)}s.strike&&e.fillRect(f,i-o*.3,b,r)}wrapLines(s,f,i){const b=`${s}|${Math.round(i)}|${f}`;let o=this.wrapCache.get(b);if(o!==void 0)return o;o=[];for(const e of f.split(`
|
|
2
|
+
`)){let r="";for(const h of e.split(/(?<=\s)/)){const d=r+h;for(r!==""&&this.width(d.trimEnd())>i?(o.push(r.trimEnd()),r=h):r=d;this.width(r.trimEnd())>i&&r.length>1;){let x=r.length-1;for(;x>1&&this.width(r.slice(0,x))>i;)x--;o.push(r.slice(0,x)),r=r.slice(x)}}o.push(r.trimEnd())}return this.wrapCache.size>4096&&this.wrapCache.clear(),this.wrapCache.set(b,o),o}wrapped(s,f,i,b,o,e,r,h,d){const{ctx:x}=this,a=this.wrapLines(J(f),s,e-h*2),k=Math.round(d*1.26),u=a.length*k,p=f.vAlign??"bottom";let M;p==="top"?M=o:p==="center"?M=o+(r-u)/2:M=o+r-u,x.save(),x.beginPath(),x.rect(b,o,e,r),x.clip(),x.textAlign=i==="center"?"center":i==="right"?"right":"left";const I=i==="center"?b+e/2:i==="right"?b+e-h:b+h;for(let T=0;T<a.length;T++){const D=M+T*k+Math.round(k*.8);D+k<o||D-k>o+r||x.fillText(a[T],I,D)}x.restore(),x.textAlign="left"}rotated(s,f,i,b,o,e){const{ctx:r}=this;r.save(),r.beginPath(),r.rect(i,b,o,e),r.clip(),r.translate(i+o/2,b+e/2);const h=f.rotation;if(r.textAlign="center",h===255){const d=f.fontSize*1.1,x=-((s.length-1)*d)/2;for(let a=0;a<s.length;a++)r.fillText(s[a],0,x+a*d)}else{const d=h>90?90-h:h;r.rotate(-d*Math.PI/180),r.fillText(s,0,f.fontSize*.35)}r.restore(),r.textAlign="left"}side(s,f,i,b,o){if(!s)return;const{ctx:e}=this,r=$t[s.style]??.5;if(e.strokeStyle=this.mono?"#000000":s.color??"#000000",e.lineWidth=r,e.setLineDash(Kt[s.style]??[]),e.beginPath(),s.style==="double"){const h=i===o?0:.75,d=i===o?.75:0;e.moveTo(f-h,i-d),e.lineTo(b-h,o-d),e.moveTo(f+h,i+d),e.lineTo(b+h,o+d)}else e.moveTo(f,i),e.lineTo(b,o);e.stroke()}}function rt(t,s,f){const i=new Float64Array(f-s+2);let b=0;for(let o=s;o<=f;o++)i[o-s]=b,b+=t.sizeOf(o);return i[f-s+1]=b,i}function Vt(t,s,f,i,b){const{ctx:o,sheet:e}=t,{x:r,y:h,r0:d,r1:x,c0:a,c1:k}=s,u=rt(e.cols,a,k),p=rt(e.rows,d,x),M=k-a+1,I=x-d+1,T=u[M],D=p[I];if(T<=0||D<=0)return;if(o.save(),o.beginPath(),o.rect(r,h,T,D),o.clip(),t.reset(),f){o.strokeStyle=U,o.lineWidth=Y,o.setLineDash([]),o.beginPath();for(let n=0;n<=M;n++)n>0&&u[n]===u[n-1]||(o.moveTo(r+u[n],h),o.lineTo(r+u[n],h+D));for(let n=0;n<=I;n++)n>0&&p[n]===p[n-1]||(o.moveTo(r,h+p[n]),o.lineTo(r+T,h+p[n]));o.stroke()}const w=e.mergesInRows(d,x).filter(n=>n.c1>=a&&n.c0<=k),S=w.length>0,P=e.rowStyles!==null||e.colStyles!==null,z=t.styles[0].fill===null&&t.styles[0].borders===null;t.tables=null;const{book:F}=t;if(F.engine&&F.engine.tables.size>0){const n=vt(F,e);n.length>0&&(t.tables=n);for(const l of n){if(l.r1<d||l.r0>x||l.c1<a||l.c0>k)continue;const m=Nt(l.styleName,F.theme);m&&(l._colors=m,Ht(o,l,m,{ra:d,rb:x,ca:a,cb:k,xs:u,ys:p,ox:r,oy:h,line:.5,noFill:t.mono,setInk:g=>t.setInk(t.mono?"#000000":g)}))}}let A=null;for(let n=a;n<=k;n++){const l=u[n-a+1]-u[n-a];if(l===0)continue;const m=e.columns[n];if(!(m===void 0&&!P&&z))for(let g=d;g<=x;g++){if(!P&&z){const R=m[g>>>Q];if(R===void 0||R.styles===null){g|=W;continue}if(R.styles[g&W]===0)continue}const c=p[g-d+1]-p[g-d];if(c===0)continue;const y=t.style(g,n);y.fill===null&&y.borders===null||S&&e.mergeAt(g,n)!==null||(y.fill!==null&&!t.mono&&(y.gradient?j(y.gradient,r+u[n-a],h+p[g-d],l,c,(R,N,H,_,G)=>{t.setInk(R),o.fillRect(N,H,_,G)}):(t.setInk(ft(y)),o.fillRect(r+u[n-a],h+p[g-d],l,c))),y.borders!==null&&(A??=[]).push(g,n,y.borders))}}const O=n=>{const l=r+e.cols.offsetOf(n.c0)-e.cols.offsetOf(a),m=h+e.rows.offsetOf(n.r0)-e.rows.offsetOf(d);return{x:l,y:m,w:e.cols.offsetOf(n.c1+1)-e.cols.offsetOf(n.c0),h:e.rows.offsetOf(n.r1+1)-e.rows.offsetOf(n.r0)}};for(const n of w){const l=O(n),m=t.style(n.r0,n.c0);(f||m.fill!==null&&!t.mono)&&(m.gradient&&!t.mono?j(m.gradient,l.x,l.y,l.w,l.h,(g,c,y,R,N)=>{t.setInk(g),o.fillRect(c,y,R,N)}):(t.setInk(m.fill!==null&&!t.mono?ft(m):"#ffffff"),o.fillRect(l.x,l.y,l.w,l.h))),f&&(o.strokeStyle=U,o.lineWidth=Y,o.setLineDash([]),o.strokeRect(l.x,l.y,l.w,l.h))}if(t.cfFrame=null,ct(e)){e.cfEval||(e.cfEval=new xt(F,e,l=>Lt(l,F.theme??[])));const n=new Map;t.cfFrame=n;for(let l=a;l<=k;l++){const m=u[l-a+1]-u[l-a];for(let g=d;g<=x;g++){const c=e.cfEval.at(g,l);if(c===null)continue;n.set(g*16384+l,c);const y=r+u[l-a],R=h+p[g-d],N=p[g-d+1]-p[g-d];c.noFill&&!t.mono&&(t.setInk("#FFFFFF"),o.fillRect(y,R,m,N)),c.fill&&!t.mono&&(t.setInk(c.fill),o.fillRect(y,R,m,N)),c.bar&&!t.mono&&(At(o,c.bar,y,R,m,N,1,!1,!0),t.ink=""),c.borders&&(A??=[]).push(g,l,c.borders)}}}if(A!==null)for(let n=0;n<A.length;n+=3){const l=A[n],m=A[n+1],g=A[n+2],c=r+u[m-a],y=r+u[m-a+1],R=h+p[l-d],N=h+p[l-d+1];t.side(g.t,c,R,y,R),t.side(g.b,c,N,y,N),t.side(g.l,c,R,c,N),t.side(g.r,y,R,y,N),g.d&&g.down&&t.side(g.d,c,R,y,N),g.d&&g.up&&t.side(g.d,c,N,y,R)}for(const n of w){const l=O(n);for(let m=n.c0;m<=n.c1;m++){const g=e.cols.sizeOf(m),c=l.x+e.cols.offsetOf(m)-e.cols.offsetOf(n.c0),y=t.style(n.r0,m).borders;y?.t&&t.side(y.t,c,l.y,c+g,l.y);const R=t.style(n.r1,m).borders;R?.b&&t.side(R.b,c,l.y+l.h,c+g,l.y+l.h)}for(let m=n.r0;m<=n.r1;m++){const g=e.rows.sizeOf(m),c=l.y+e.rows.offsetOf(m)-e.rows.offsetOf(n.r0),y=t.style(m,n.c0).borders;y?.l&&t.side(y.l,l.x,c,l.x,c+g);const R=t.style(m,n.c1).borders;R?.r&&t.side(R.r,l.x+l.w,c,l.x+l.w,c+g)}}if(e.sparklines&&e.sparklines.length>0&&F.engine)for(const[n,l]of Pt(e)){const m=Math.floor(n/16384),g=n-m*16384;m<d||m>x||g<a||g>k||Rt(o,F.engine,e,l,m,g,r+u[g-a],h+p[m-d],u[g-a+1]-u[g-a],p[m-d+1]-p[m-d],1,{snap:!1,mono:t.mono})}e.sparkRules!==null&&Mt(o,F,e,{r0:d,r1:x,c0:a,c1:k,xs:u,ys:p,ox:r,oy:h,mono:t.mono}),t.reset(),o.textBaseline="alphabetic",o.textAlign="left";const C={c0:a,c1:k};for(let n=a;n<=k;n++){const l=r+u[n-a],m=u[n-a+1]-u[n-a];if(m===0)continue;const g=e.columns[n];if(g!==void 0)for(let c=d;c<=x;c++){const y=g[c>>>Q];if(y===void 0){c|=W;continue}const R=c&W,N=y.kinds[R]&$;if(N===X||S&&e.mergeAt(c,n)!==null)continue;const H=p[c-d+1]-p[c-d];H!==0&&t.text(c,n,N,y.values[R],l,h+p[c-d],m,H,C)}}if(i<a)for(let n=d;n<=x;n++){const l=p[n-d+1]-p[n-d];if(l===0||e.kind(n,a)!==0)continue;let m=0;for(let g=a-1;g>=Math.max(i,a-Xt);g--){m+=e.cols.sizeOf(g);const c=e.kind(n,g)&$;if(c!==X){c===v&&e.mergeAt(n,g)===null&&(t.reachX=r,t.text(n,g,c,e.value(n,g),r-m,h+p[n-d],e.cols.sizeOf(g),l,C),t.reachX=null);break}}}for(const n of w){const l=e.kind(n.r0,n.c0)&$;if(l===X)continue;const m=O(n);t.text(n.r0,n.c0,l,e.value(n.r0,n.c0),m.x,m.y,m.w,m.h,C,!0)}q(e)&&kt(t.book,e,d,x,a,k,(n,l)=>{ot(t.ctx,t.book,e,n,l,r+u[l-a],h+p[n-d],u[l-a+1]-u[l-a],p[n-d+1]-p[n-d]),t.reset()}),b&&(t.reset(),b(s),t.reset()),o.restore(),t.reset()}function Jt(t,s,f){const{ctx:i,sheet:b}=t,{headingW:o,headingH:e,titleW:r,titleH:h}=s,d=r+s.bodyW,x=h+s.bodyH;i.strokeStyle=U,i.lineWidth=Y,i.setLineDash([]),t.reset(),i.font=f,i.textBaseline="alphabetic",i.textAlign="center",t.setInk("#000000");const a=3;i.strokeRect(0,0,o+d,e),i.strokeRect(0,0,o,e+x);const k=(p,M,I)=>{let T=I;for(let D=p;D<=M;D++){const w=b.cols.sizeOf(D);w>0&&(i.beginPath(),i.moveTo(T+w,0),i.lineTo(T+w,e),i.stroke(),i.fillText(Tt(D),T+w/2,e-a)),T+=w}},u=(p,M,I)=>{let T=I;for(let D=p;D<=M;D++){const w=b.rows.sizeOf(D);w>0&&(i.beginPath(),i.moveTo(0,T+w),i.lineTo(o,T+w),i.stroke(),i.fillText(String(D+1),o/2,T+w-a)),T+=w}};s.titleCols&&k(s.titleCols.c0,s.titleCols.c1,o),k(s.c0,s.c1,o+r),s.titleRows&&u(s.titleRows.r0,s.titleRows.r1,e),u(s.r0,s.r1,e+h),i.textAlign="left"}const B=new Map;function Zt(t){let s=B.get(t);return s===void 0&&(s=Wt(t),B.size>256&&B.clear(),B.set(t,s)),s}function qt(t,s){switch(t.field){case"page":return String(s.pageNumber+(t.offset??0));case"pages":return String(s.totalPages);case"date":return s.now.toLocaleDateString(s.locale);case"time":return s.now.toLocaleTimeString(s.locale,{hour:"2-digit",minute:"2-digit"});case"file":return s.fileName;case"sheet":return s.sheetName;case"path":return s.filePath;default:return""}}function jt(t,s){const f=[[]];for(const i of t)(i.field?qt(i,s):i.text).split(`
|
|
3
|
+
`).forEach((e,r)=>{r>0&&f.push([]),e&&f[f.length-1].push({...i,text:e})});return f}function Qt(t,s,f,i,b,o=null){const{setup:e,paper:r}=s,h=e.margins,d=i.pageNumber%2===0,x=w=>e.differentFirst&&i.sheetPage===0?w.first:e.differentOddEven&&d?w.even:w.odd,a=x(e.header),k=x(e.footer);if(!a&&!k)return;const u=i.defaultStyle,p=(e.alignWithMargins?h.left:.7)*72,M=r.width-(e.alignWithMargins?h.right:.7)*72;t.save(),t.textBaseline="alphabetic",t.textAlign="left";const I=(w,S,P,z)=>{const F=w.map(C=>{const n=(C.size??V)*b*(C.script!==0?.66:1),l=E({...u,fontName:C.font??u.fontName,bold:C.bold,italic:C.italic},n);return t.font=l,{run:C,size:n,font:l,width:t.measureText(C.text).width}});let A=0;for(const C of F)A+=C.width;let O=P==="center"?S-A/2:P==="right"?S-A:S;for(const{run:C,size:n,font:l,width:m}of F){t.font=l;const g=e.blackAndWhite?"#000000":C.color??"#000000";t.fillStyle=g;const c=z-(C.script===1?n*.5:C.script===-1?-n*.2:0);t.fillText(C.text,O,c);const y=Math.max(.4,n/14);C.underline&&(t.fillRect(O,c+n*.14,m,y),C.underline===2&&t.fillRect(O,c+n*.14+y*2,m,y)),C.strike&&t.fillRect(O,c-n*.3,m,y),O+=m}},T=w=>{let S=V;return w.length>0&&(S=Math.max(...w.map(P=>P.size??V))),S*b*1.2},D=(w,S,P,z)=>{if(w.length===0)return;const F=jt(w,i);if(z){let A=h.header*72;for(const O of F){const C=T(O);I(O,S,P,A+C*.8),A+=C}}else{let A=r.height-h.footer*72;for(let O=F.length-1;O>=0;O--){const C=T(F[O]);I(F[O],S,P,A-C*.2),A-=C}}};for(const[w,S]of[[a,!0],[k,!1]]){if(!w)continue;const P=Zt(w),z=o?.[S?"header":"footer"];z!=="L"&&D(P.left,p,"left",S),z!=="C"&&D(P.center,r.width/2,"center",S),z!=="R"&&D(P.right,M,"right",S)}t.restore()}function te(t,s){t.translate((s.paperW-2*s.originX)/s.scale,0),t.scale(-1,1);const f=Object.prototype.hasOwnProperty.call(t,"fillText"),i=t.fillText;return t.fillText=function(o,e,r){const h=t.measureText(o).width,d=t.textAlign,x=d==="right"||d==="end"?e-h:d==="center"?e-h/2:e;t.save(),t.scale(-1,1),t.textAlign="left",i.call(t,o,-x-h,r),t.restore()},()=>{f?t.fillText=i:delete t.fillText}}function lt(t,s,f,i={}){const{book:b,sheet:o,setup:e}=s,r=b.styles.list[0];t.save(),i.background!==!1&&(t.fillStyle="#ffffff",t.fillRect(0,0,f.paperW,f.paperH)),ut(t,o,f,i.sheetPage??f.index,e);const h={pageNumber:i.pageNumber??f.index+1,totalPages:i.totalPages??s.pageCount,sheetPage:i.sheetPage??f.index,fileName:i.fileName??b.fileName??"",filePath:i.filePath??"",sheetName:o.name,now:i.now??new Date,locale:i.locale,defaultStyle:r};if(Qt(t,s,f,h,e.scaleWithDoc?f.scale:1),f.noteLines){Bt(t,f),t.restore();return}t.save(),t.translate(f.originX,f.originY),t.scale(f.scale,f.scale);const d=o.rtl===!0?te(t,f):null,x=new Yt(t,b,o,e),{headingW:a,headingH:k,titleW:u,titleH:p,titleRows:M,titleCols:I,r0:T,r1:D,c0:w,c1:S,area:P}=f,z=e.gridLines&&!e.draft;e.headings&&Jt(x,f,E(r,r.fontSize));const F=i.objectPainters??null,A=F&&F.length>0?l=>{const m=l.x-o.cols.offsetOf(l.c0),g=l.y-o.rows.offsetOf(l.r0),c={printing:!0,dpr:1,zoom:1,hx:l.x,hy:l.y,cssW:l.x+o.cols.offsetOf(l.c1+1)-o.cols.offsetOf(l.c0),cssH:l.y+o.rows.offsetOf(l.r1+1)-o.rows.offsetOf(l.r0),toScreen:(y,R)=>({x:m+y,y:g+R}),sheet:o};for(const y of F)y(t,c)}:null;if(f.chartBox){if(F){const l={printing:!0,dpr:1,zoom:1,hx:0,hy:0,cssW:f.bodyW,cssH:f.bodyH,toScreen:(m,g)=>({x:m,y:g}),sheet:o,chartBox:f.chartBox};for(const m of F)m(t,l)}t.restore(),t.restore();return}const O=a+u,C=k+p,n=(l,m)=>{Vt(x,l,z,m,A),t.link&&i.onPlace&&Et(t,b,o,l,i.onPlace)};n({x:O,y:C,r0:T,r1:D,c0:w,c1:S},P.c0),M&&n({x:O,y:k,r0:M.r0,r1:M.r1,c0:w,c1:S},P.c0),I&&n({x:a,y:C,r0:T,r1:D,c0:I.c0,c1:I.c1},I.c0),M&&I&&n({x:a,y:k,r0:M.r0,r1:M.r1,c0:I.c0,c1:I.c1},I.c0),d?.(),t.restore(),t.restore()}function Pe(t,s,f,{pxPerPt:i=2,...b}={}){const o=s.at(f);if(o===null)return null;const{page:e,pagination:r}=o;t.width=Math.max(1,Math.round(e.paperW*i)),t.height=Math.max(1,Math.round(e.paperH*i));const h=t.getContext("2d",{alpha:!1});return h.setTransform(i,0,0,i,0,0),lt(h,r,e,{pageNumber:o.pageNumber,totalPages:o.totalPages,sheetPage:o.sheetPage,...b}),o}const ee=()=>new Promise(t=>setTimeout(t,0)),ne={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 s=ne[t.pattern.type]??.5,f=i=>{const b=parseInt(t.pattern.fg.slice(i,i+2),16),o=parseInt(t.fill.slice(i,i+2),16);return Math.round(b*s+o*(1-s)).toString(16).padStart(2,"0")};return`#${f(1)}${f(3)}${f(5)}`}async function Re(t,s,f={}){const{title:i,author:b,subject:o,fonts:e,compress:r,signal:h,onProgress:d,...x}=f,[{PdfWriter:a}]=await Promise.all([import("./pdf.js"),zt(t)]),k=new a(s,{title:i,author:b,subject:o,fonts:e,compress:r}),u=x.now??new Date;let p=performance.now();const M=new Map,I=(D,w,S)=>{const P=`${t.book.sheets.indexOf(D)}:${w}:${S}`;if(!M.has(P)){const z=t.entries.find(A=>A.sheet===D),F=z?z.pagination.pageAt(w,S):-1;if(M.set(P,F<0?null:`L${M.size}`),F>=0){const A=z.pagination.page(F),O=A.headingH+A.titleH+D.rows.offsetOf(w)-D.rows.offsetOf(A.r0);k.destination(M.get(P),z.first+F,A.paperH-A.originY-O*A.scale)}}return M.get(P)};let T=null;for(let D=0;D<t.pageCount;D++){h?.throwIfAborted();const w=t.at(D),{page:S,pagination:P}=w;P.sheet!==T&&(T=P.sheet,k.bookmark(T.name,D));const z=k.beginPage(S.paperW,S.paperH);lt(z,P,S,{...x,now:u,onPlace:I,background:!1,pageNumber:w.pageNumber,totalPages:w.totalPages,sheetPage:w.sheetPage}),await k.endPage(),d?.(D+1,t.pageCount),performance.now()-p>12&&(await ee(),p=performance.now())}return k.bookmarks.length<2&&(k.bookmarks.length=0),await k.finish(),{pages:k.pageCount,bytes:k.offset,missing:[...k.missing],fontWarnings:k.fontWarnings}}export{Ut as displayText,Qt as paintHeaderFooter,Pe as renderJobPageToCanvas,lt as renderPage,Re as writeJobPdf};
|
package/slicers/format.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{parseNode as p}from"../pivot/xml.js";import{xmlAttr as
|
|
2
|
-
`,C=D,d=t=>Object.entries(t).filter(([,i])=>i!=null).map(([i,e])=>` ${i}="${C(e)}"`).join(""),x=(t,i)=>t?.c?.find(e=>e.n===i)??null,v=(t,i)=>t?t.c.filter(e=>e.n===i):[],$=t=>t.slice(t.indexOf(":")+1),f=(t,i)=>t===void 0?i:t==="1"||t==="true";function R(t){const i=d({name:t.name,"xr10:uid":t.uid??void 0,sourceName:t.sourceName,...t.extra??{}}),e=`${b}<slicerCacheDefinition xmlns="${a.x14}" xmlns:mc="${a.mc}" mc:Ignorable="x xr10" xmlns:x="${a.main}" xmlns:xr10="${a.xr10}"${i}>`,n={sortOrder:t.sortOrder&&t.sortOrder!=="ascending"?t.sortOrder:void 0,customListSort:t.customListSort===!1?"0":void 0,crossFilter:t.crossFilter&&t.crossFilter!=="showItemsWithDataAtTop"?t.crossFilter:void 0},r=[];let o="";if(t.kind==="table")r.push(`<x:ext uri="${h.tableSlicerCache}" xmlns:x15="${a.x15}"><x15:tableSlicerCache${d({tableId:t.tableId,column:t.column,...n})}/></x:ext>`);else{const l=(t.pivotTables??[]).map(m=>`<pivotTable${d({tabId:m.tabId,name:m.name})}/>`).join("");o+=`<pivotTables>${l}</pivotTables>`;const c=(t.items??[]).map(m=>`<i${d({x:m.x,s:m.s?"1":void 0,nd:m.nd?"1":void 0})}/>`).join(""),s={pivotCacheId:t.pivotCacheId,...n,showMissing:t.showMissing===!1?"0":void 0};o+=`<data><tabular${d(s)}><items count="${(t.items??[]).length}">${c}</items></tabular></data>`}t.hideNoData&&r.push(`<x:ext uri="${h.hideNoData}" xmlns:x15="${a.x15}"><x15:slicerCacheHideItemsWithNoData/></x:ext>`);for(const l of t.rawExt??[])r.push(l);return`${e}${o}${r.length?`<extLst>${r.join("")}</extLst>`:""}</slicerCacheDefinition>`}function k(t){const i=e=>{const n={name:e.name,"xr10:uid":e.uid??void 0,cache:e.cache,caption:e.caption,startItem:e.startItem?e.startItem:void 0,columnCount:e.columnCount&&e.columnCount!==1?e.columnCount:void 0,showCaption:e.showCaption===!1?"0":void 0,level:e.level?e.level:void 0,style:e.style&&e.style!=="SlicerStyleLight1"?e.style:void 0,lockedPosition:e.lockedPosition?"1":void 0,rowHeight:e.rowHeight??241300,...e.extra??{}};return`<slicer${d(n)}/>`};return`${b}<slicers xmlns="${a.x14}" xmlns:mc="${a.mc}" mc:Ignorable="x xr10" xmlns:x="${a.main}" xmlns:xr10="${a.xr10}">${t.map(i).join("")}</slicers>`}function H(t){const i=(t.pivotTables??[]).map(r=>`<pivotTable${d({tabId:r.tabId,name:r.name})}/>`).join(""),e=(r,o)=>o?`<${r}${d({startDate:o.start,endDate:o.end})}/>`:"",n=d({singleRangeFilterState:t.singleRange===!1?"0":void 0,minimalRefreshVersion:t.minimalRefreshVersion??6,lastRefreshVersion:t.lastRefreshVersion??6,pivotCacheId:t.pivotCacheId,filterType:t.selection?"dateBetween":"unknown",filterId:t.selection?t.filterId:void 0,filterTabId:t.selection?t.filterTabId:void 0,filterPivotName:t.selection?t.filterPivotName:void 0});return`${b}<timelineCacheDefinition xmlns="${a.x15}" xmlns:x15="${a.x15}" xmlns:mc="${a.mc}" mc:Ignorable="xr10" xmlns:xr10="${a.xr10}"${d({name:t.name,"xr10:uid":t.uid??void 0,sourceName:t.sourceName,...t.extra??{}})}><pivotTables>${i}</pivotTables><state${n}>${e("selection",t.selection)}${e("bounds",t.bounds)}</state></timelineCacheDefinition>`}function X(t){const i=e=>`<timeline${d({name:e.name,"xr10:uid":e.uid??void 0,cache:e.cache,caption:e.caption,showHeader:e.showHeader===!1?"0":void 0,showSelectionLabel:e.showSelectionLabel===!1?"0":void 0,showTimeLevel:e.showTimeLevel===!1?"0":void 0,showHorizontalScrollbar:e.showHorizontalScrollbar===!1?"0":void 0,level:e.level??2,selectionLevel:e.selectionLevel??e.level??2,scrollPosition:e.scrollPosition??void 0,style:e.style&&e.style!=="TimeSlicerStyleLight1"?e.style:void 0,...e.extra??{}})}/>`;return`${b}<timelines xmlns="${a.x15}" xmlns:mc="${a.mc}" mc:Ignorable="x xr10" xmlns:x="${a.main}" xmlns:xr10="${a.xr10}">${t.map(i).join("")}</timelines>`}const S={pivot:{choice:`xmlns:a14="${a.a14}" Requires="a14"`,uri:a.sle,inner:t=>`<sle:slicer xmlns:sle="${a.sle}" name="${C(t)}"/>`},table:{choice:`xmlns:sle15="${a.sle15}" Requires="sle15"`,uri:a.sle,inner:t=>`<sle:slicer xmlns:sle="${a.sle}" name="${C(t)}"/>`},timeline:{choice:`xmlns:tsle="${a.tsle}" Requires="tsle"`,uri:a.tsle,inner:t=>`<tsle:timeslicer xmlns:tsle="${a.tsle}" name="${C(t)}"/>`}},T={pivot:"This shape represents a slicer. Slicers are supported in Excel 2010 or later.",table:"This shape represents a table slicer. Table slicers are supported in Excel 2013 or later.",timeline:"Timeline: Works in Excel 2013 or higher. Do not move or resize."};function M({kind:t,name:i,id:e,from:n,to:r,cx:o=1828800,cy:l=2524125}){const c=S[t],s=(m,u)=>`<xdr:${m}><xdr:col>${u.col}</xdr:col><xdr:colOff>${u.colOff}</xdr:colOff><xdr:row>${u.row}</xdr:row><xdr:rowOff>${u.rowOff}</xdr:rowOff></xdr:${m}>`;return`<xdr:twoCellAnchor editAs="absolute">${s("from",n)}${s("to",r)}<mc:AlternateContent xmlns:mc="${a.mc}"><mc:Choice ${c.choice}><xdr:graphicFrame macro=""><xdr:nvGraphicFramePr><xdr:cNvPr id="${e}" name="${C(i)}"/><xdr:cNvGraphicFramePr/></xdr:nvGraphicFramePr><xdr:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/></xdr:xfrm><a:graphic><a:graphicData uri="${c.uri}">${c.inner(i)}</a:graphicData></a:graphic></xdr:graphicFrame></mc:Choice><mc:Fallback xmlns=""><xdr:sp macro="" textlink=""><xdr:nvSpPr><xdr:cNvPr id="0" name=""/><xdr:cNvSpPr><a:spLocks noTextEdit="1"/></xdr:cNvSpPr></xdr:nvSpPr><xdr:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="${o}" cy="${l}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:solidFill><a:prstClr val="white"/></a:solidFill><a:ln w="1"><a:solidFill><a:prstClr val="green"/></a:solidFill></a:ln></xdr:spPr><xdr:txBody><a:bodyPr vertOverflow="clip" horzOverflow="clip"/><a:lstStyle/><a:p><a:r><a:rPr lang="en-US" sz="1100"/><a:t>${T[t]}</a:t></a:r></a:p></xdr:txBody></xdr:sp></mc:Fallback></mc:AlternateContent><xdr:clientData/></xdr:twoCellAnchor>`}const j=t=>`${b}<xdr:wsDr xmlns:xdr="${a.xdr}" xmlns:a="${a.a}">${t}</xdr:wsDr>`,g=/<xdr:(twoCellAnchor|oneCellAnchor|absoluteAnchor)\b[\s\S]*?<\/xdr:\1>/g,I=/<(?:\w+:)?(slicer|timeslicer)\b[^>]*\bname="([^"]*)"/;function z(t){const i=[];for(const e of t.matchAll(g)){const n=e[0];if(!/drawing\/20(?:10|12)\/(?:time)?slicer/.test(n))continue;const r=I.exec(n);if(!r)continue;const o=l=>{const c=new RegExp(`<xdr:${l}>\\s*<xdr:col>(\\d+)</xdr:col>\\s*<xdr:colOff>(-?\\d+)</xdr:colOff>\\s*<xdr:row>(\\d+)</xdr:row>\\s*<xdr:rowOff>(-?\\d+)</xdr:rowOff>`).exec(n);return c?{col:Number(c[1]),colOff:Number(c[2]),row:Number(c[3]),rowOff:Number(c[4])}:null};i.push({kind:r[1]==="timeslicer"?"timeline":/Requires="sle15"/.test(n)?"table":"pivot",name:w(r[2]),id:Number(/<xdr:cNvPr\b[^>]*\bid="(\d+)"/.exec(n)?.[1]??0),from:o("from"),to:o("to"),raw:n})}return i}function V(t,{upsert:i=[],remove:e=[]}){const n=new Map(i.map(s=>[s.name,s.xml])),r=new Set(e),o=new Set;let l=t.replace(g,s=>{if(!/drawing\/20(?:10|12)\/(?:time)?slicer/.test(s))return s;const m=I.exec(s);if(!m)return s;const u=w(m[2]);return r.has(u)?"":n.has(u)?(o.add(u),n.get(u)):s});const c=i.filter(s=>!o.has(s.name)).map(s=>s.xml).join("");return c&&(l=l.replace(/<\/(\w+:)?wsDr>\s*$/,s=>`${c}${s}`)),l}const F=new Set(["name","xr10:uid","cache","caption","startItem","columnCount","showCaption","level","style","lockedPosition","rowHeight"]),A=new Set(["name","xr10:uid","cache","caption","showHeader","showSelectionLabel","showTimeLevel","showHorizontalScrollbar","level","selectionLevel","scrollPosition","style"]),N=(t,i)=>{const e={};for(const[n,r]of Object.entries(t))!i.has(n)&&!n.startsWith("xmlns")&&n!=="mc:Ignorable"&&(e[n]=r);return e};function W(t){const i=p(t),e={name:i.a.name,sourceName:i.a.sourceName,uid:i.a["xr10:uid"]??null,kind:"pivot",sortOrder:"ascending",customListSort:!0,crossFilter:"showItemsWithDataAtTop",showMissing:!0,hideNoData:!1,pivotTables:[],items:[],pivotCacheId:null,tableId:null,column:null},n=o=>{o.sortOrder&&(e.sortOrder=o.sortOrder),e.customListSort=f(o.customListSort,!0),o.crossFilter&&(e.crossFilter=o.crossFilter)};for(const o of v(x(i,"pivotTables"),"pivotTable"))e.pivotTables.push({tabId:Number(o.a.tabId),name:o.a.name});const r=x(x(i,"data"),"tabular");if(r){e.pivotCacheId=Number(r.a.pivotCacheId),n(r.a),e.showMissing=f(r.a.showMissing,!0);for(const o of v(x(r,"items"),"i"))e.items.push({x:Number(o.a.x),s:f(o.a.s,!1),nd:f(o.a.nd,!1)})}for(const o of x(i,"extLst")?.c??[])if($(o.n)==="ext")if(o.a.uri===h.tableSlicerCache){const l=o.c.find(c=>$(c.n)==="tableSlicerCache");l&&(e.kind="table",e.tableId=Number(l.a.tableId),e.column=Number(l.a.column),n(l.a))}else o.a.uri===h.hideNoData&&(e.hideNoData=!0);return e}function _(t){const i=p(t);return v(i,"slicer").map(e=>({name:e.a.name,uid:e.a["xr10:uid"]??null,cache:e.a.cache,caption:e.a.caption??e.a.name,startItem:Number(e.a.startItem??0),columnCount:Number(e.a.columnCount??1),showCaption:f(e.a.showCaption,!0),level:Number(e.a.level??0),style:e.a.style??"SlicerStyleLight1",lockedPosition:f(e.a.lockedPosition,!1),rowHeight:Number(e.a.rowHeight??241300),extra:N(e.a,F)}))}function G(t){const i=p(t),e=x(i,"state"),n=r=>{const o=x(e,r);return o?{start:o.a.startDate,end:o.a.endDate}:null};return{name:i.a.name,sourceName:i.a.sourceName,uid:i.a["xr10:uid"]??null,pivotTables:v(x(i,"pivotTables"),"pivotTable").map(r=>({tabId:Number(r.a.tabId),name:r.a.name})),singleRange:f(e?.a.singleRangeFilterState,!0),minimalRefreshVersion:Number(e?.a.minimalRefreshVersion??6),lastRefreshVersion:Number(e?.a.lastRefreshVersion??6),pivotCacheId:Number(e?.a.pivotCacheId??0),filterType:e?.a.filterType??"unknown",filterId:e?.a.filterId!==void 0?Number(e.a.filterId):null,filterTabId:e?.a.filterTabId!==void 0?Number(e.a.filterTabId):null,filterPivotName:e?.a.filterPivotName??null,selection:n("selection"),bounds:n("bounds")}}function q(t){const i=p(t);return v(i,"timeline").map(e=>({name:e.a.name,uid:e.a["xr10:uid"]??null,cache:e.a.cache,caption:e.a.caption??e.a.name,showHeader:f(e.a.showHeader,!0),showSelectionLabel:f(e.a.showSelectionLabel,!0),showTimeLevel:f(e.a.showTimeLevel,!0),showHorizontalScrollbar:f(e.a.showHorizontalScrollbar,!0),level:Number(e.a.level??2),selectionLevel:Number(e.a.selectionLevel??e.a.level??2),scrollPosition:e.a.scrollPosition??null,style:e.a.style??"TimeSlicerStyleLight1",extra:N(e.a,A)}))}function K(t){const i=p(t);for(const e of x(i,"extLst")?.c??[]){if(e.a.uri!==h.pivotCacheId)continue;const n=e.c.find(r=>$(r.n)==="pivotCacheDefinition");if(n?.a.pivotCacheId!==void 0)return Number(n.a.pivotCacheId)}return null}function U(t,i){const e=`<ext uri="${h.pivotCacheId}" xmlns:x14="${a.x14}"><x14:pivotCacheDefinition pivotCacheId="${i}"/></ext>`;return t.includes(h.pivotCacheId)?t.replace(/(<x14:pivotCacheDefinition\b[^>]*\bpivotCacheId=")\d+/,`$1${i}`):/<extLst>/.test(t)?t.replace(/<extLst>/,`<extLst>${e}`):t.replace("</pivotCacheDefinition>",`<extLst>${e}</extLst></pivotCacheDefinition>`)}import{isoToSerial as Y,serialToIso as Z}from"../pivot/xml.js";export{O as CT,h as EXT,a as NS,P as REL,b as XML_HEAD,M as frameXml,Y as isoToSerial,j as newDrawingXml,z as parseFrames,W as parseSlicerCacheXml,_ as parseSlicersXml,G as parseTimelineCacheXml,q as parseTimelinesXml,V as patchDrawingFrames,K as pivotCacheExtId,Z as serialToIso,U as setPivotCacheExtId,R as slicerCacheXml,k as slicersXml,B as tabPlaceholder,H as timelineCacheXml,X as timelinesXml};
|
|
1
|
+
import{parseNode as p}from"../pivot/xml.js";import{xmlAttr as A}from"../io/xml-escape.js";import{unescapeXstring as I}from"../io/xml-scan.js";const a={main:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",x14:"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",x15:"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main",xr10:"http://schemas.microsoft.com/office/spreadsheetml/2016/revision10",xdr:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",a:"http://schemas.openxmlformats.org/drawingml/2006/main",a14:"http://schemas.microsoft.com/office/drawing/2010/main",sle:"http://schemas.microsoft.com/office/drawing/2010/slicer",sle15:"http://schemas.microsoft.com/office/drawing/2012/slicer",tsle:"http://schemas.microsoft.com/office/drawing/2012/timeslicer"},k={slicerCache:"http://schemas.microsoft.com/office/2007/relationships/slicerCache",slicer:"http://schemas.microsoft.com/office/2007/relationships/slicer",timelineCache:"http://schemas.microsoft.com/office/2011/relationships/timelineCache",timeline:"http://schemas.microsoft.com/office/2011/relationships/timeline",drawing:`${a.r}/drawing`},H={slicerCache:"application/vnd.ms-excel.slicerCache+xml",slicer:"application/vnd.ms-excel.slicer+xml",timelineCache:"application/vnd.ms-excel.timelineCache+xml",timeline:"application/vnd.ms-excel.timeline+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml"},h={wbPivotSlicerCaches:"{BBE1A952-AA13-448e-AADC-164F8A28A991}",wbTableSlicerCaches:"{46BE6895-7355-4a93-B00E-2C351335B9C9}",wbTimelineCaches:"{D0CA8CA8-9F24-4464-BF8E-62219DCF47F9}",wsPivotSlicers:"{A8765BA9-456A-4dab-B4F3-ACF838C121DE}",wsTableSlicers:"{3A4CF648-6AED-40f4-86FF-DC5316D8AED3}",wsTimelines:"{7E03D99C-DC04-49d9-9315-930204A7B6E9}",tableSlicerCache:"{2F2917AC-EB37-4324-AD4E-5DD8C200BD13}",hideNoData:"{470722E0-AACD-4C17-9CDC-17EF765DBC7E}",pivotCacheId:"{725AE2AE-9491-48be-B2B4-4EB974FC3084}",slicerStyles:"{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}",timelineStyles:"{9260A510-F301-46a8-8635-F512D64BE5F5}"},X=t=>`@@TAB${t}@@`,b=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2
|
+
`,C=A,u=t=>Object.entries(t).filter(([,i])=>i!=null).map(([i,e])=>` ${i}="${C(e)}"`).join(""),f=(t,i)=>t?.c?.find(e=>e.n===i)??null,v=(t,i)=>t?t.c.filter(e=>e.n===i):[],$=t=>t.slice(t.indexOf(":")+1),x=(t,i)=>t===void 0?i:t==="1"||t==="true";function M(t){const i=u({name:t.name,"xr10:uid":t.uid??void 0,sourceName:t.sourceName,...t.extra??{}}),e=`${b}<slicerCacheDefinition xmlns="${a.x14}" xmlns:mc="${a.mc}" mc:Ignorable="x xr10" xmlns:x="${a.main}" xmlns:xr10="${a.xr10}"${i}>`,n={sortOrder:t.sortOrder&&t.sortOrder!=="ascending"?t.sortOrder:void 0,customListSort:t.customListSort===!1?"0":void 0,crossFilter:t.crossFilter&&t.crossFilter!=="showItemsWithDataAtTop"?t.crossFilter:void 0},r=[];let o="";if(t.kind==="table")r.push(`<x:ext uri="${h.tableSlicerCache}" xmlns:x15="${a.x15}"><x15:tableSlicerCache${u({tableId:t.tableId,column:t.column,...n})}/></x:ext>`);else{const l=(t.pivotTables??[]).map(c=>`<pivotTable${u({tabId:c.tabId,name:c.name})}/>`).join("");o+=`<pivotTables>${l}</pivotTables>`;const m=(t.items??[]).map(c=>`<i${u({x:c.x,s:c.s?"1":void 0,nd:c.nd?"1":void 0})}/>`).join(""),s={pivotCacheId:t.pivotCacheId,...n,showMissing:t.showMissing===!1?"0":void 0};o+=`<data><tabular${u(s)}><items count="${(t.items??[]).length}">${m}</items></tabular></data>`}t.hideNoData&&r.push(`<x:ext uri="${h.hideNoData}" xmlns:x15="${a.x15}"><x15:slicerCacheHideItemsWithNoData/></x:ext>`);for(const l of t.rawExt??[])r.push(l);return`${e}${o}${r.length?`<extLst>${r.join("")}</extLst>`:""}</slicerCacheDefinition>`}function j(t){const i=e=>{const n={name:e.name,"xr10:uid":e.uid??void 0,cache:e.cache,caption:e.caption,startItem:e.startItem?e.startItem:void 0,columnCount:e.columnCount&&e.columnCount!==1?e.columnCount:void 0,showCaption:e.showCaption===!1?"0":void 0,level:e.level?e.level:void 0,style:e.style&&e.style!=="SlicerStyleLight1"?e.style:void 0,lockedPosition:e.lockedPosition?"1":void 0,rowHeight:e.rowHeight??241300,...e.extra??{}};return`<slicer${u(n)}/>`};return`${b}<slicers xmlns="${a.x14}" xmlns:mc="${a.mc}" mc:Ignorable="x xr10" xmlns:x="${a.main}" xmlns:xr10="${a.xr10}">${t.map(i).join("")}</slicers>`}function z(t){const i=(t.pivotTables??[]).map(r=>`<pivotTable${u({tabId:r.tabId,name:r.name})}/>`).join(""),e=(r,o)=>o?`<${r}${u({startDate:o.start,endDate:o.end})}/>`:"",n=u({singleRangeFilterState:t.singleRange===!1?"0":void 0,minimalRefreshVersion:t.minimalRefreshVersion??6,lastRefreshVersion:t.lastRefreshVersion??6,pivotCacheId:t.pivotCacheId,filterType:t.selection?"dateBetween":"unknown",filterId:t.selection?t.filterId:void 0,filterTabId:t.selection?t.filterTabId:void 0,filterPivotName:t.selection?t.filterPivotName:void 0});return`${b}<timelineCacheDefinition xmlns="${a.x15}" xmlns:x15="${a.x15}" xmlns:mc="${a.mc}" mc:Ignorable="xr10" xmlns:xr10="${a.xr10}"${u({name:t.name,"xr10:uid":t.uid??void 0,sourceName:t.sourceName,...t.extra??{}})}><pivotTables>${i}</pivotTables><state${n}>${e("selection",t.selection)}${e("bounds",t.bounds)}</state></timelineCacheDefinition>`}function V(t){const i=e=>`<timeline${u({name:e.name,"xr10:uid":e.uid??void 0,cache:e.cache,caption:e.caption,showHeader:e.showHeader===!1?"0":void 0,showSelectionLabel:e.showSelectionLabel===!1?"0":void 0,showTimeLevel:e.showTimeLevel===!1?"0":void 0,showHorizontalScrollbar:e.showHorizontalScrollbar===!1?"0":void 0,level:e.level??2,selectionLevel:e.selectionLevel??e.level??2,scrollPosition:e.scrollPosition??void 0,style:e.style&&e.style!=="TimeSlicerStyleLight1"?e.style:void 0,...e.extra??{}})}/>`;return`${b}<timelines xmlns="${a.x15}" xmlns:mc="${a.mc}" mc:Ignorable="x xr10" xmlns:x="${a.main}" xmlns:xr10="${a.xr10}">${t.map(i).join("")}</timelines>`}const E={pivot:{choice:`xmlns:a14="${a.a14}" Requires="a14"`,uri:a.sle,inner:t=>`<sle:slicer xmlns:sle="${a.sle}" name="${C(t)}"/>`},table:{choice:`xmlns:sle15="${a.sle15}" Requires="sle15"`,uri:a.sle,inner:t=>`<sle:slicer xmlns:sle="${a.sle}" name="${C(t)}"/>`},timeline:{choice:`xmlns:tsle="${a.tsle}" Requires="tsle"`,uri:a.tsle,inner:t=>`<tsle:timeslicer xmlns:tsle="${a.tsle}" name="${C(t)}"/>`}},L={pivot:"This shape represents a slicer. Slicers are supported in Excel 2010 or later.",table:"This shape represents a table slicer. Table slicers are supported in Excel 2013 or later.",timeline:"Timeline: Works in Excel 2013 or higher. Do not move or resize."};function W({kind:t,name:i,id:e,from:n,to:r,cx:o=1828800,cy:l=2524125}){const m=E[t],s=(c,d)=>`<xdr:${c}><xdr:col>${d.col}</xdr:col><xdr:colOff>${d.colOff}</xdr:colOff><xdr:row>${d.row}</xdr:row><xdr:rowOff>${d.rowOff}</xdr:rowOff></xdr:${c}>`;return`<xdr:twoCellAnchor editAs="absolute">${s("from",n)}${s("to",r)}<mc:AlternateContent xmlns:mc="${a.mc}"><mc:Choice ${m.choice}><xdr:graphicFrame macro=""><xdr:nvGraphicFramePr><xdr:cNvPr id="${e}" name="${C(i)}"/><xdr:cNvGraphicFramePr/></xdr:nvGraphicFramePr><xdr:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/></xdr:xfrm><a:graphic><a:graphicData uri="${m.uri}">${m.inner(i)}</a:graphicData></a:graphic></xdr:graphicFrame></mc:Choice><mc:Fallback xmlns=""><xdr:sp macro="" textlink=""><xdr:nvSpPr><xdr:cNvPr id="0" name=""/><xdr:cNvSpPr><a:spLocks noTextEdit="1"/></xdr:cNvSpPr></xdr:nvSpPr><xdr:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="${o}" cy="${l}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:solidFill><a:prstClr val="white"/></a:solidFill><a:ln w="1"><a:solidFill><a:prstClr val="green"/></a:solidFill></a:ln></xdr:spPr><xdr:txBody><a:bodyPr vertOverflow="clip" horzOverflow="clip"/><a:lstStyle/><a:p><a:r><a:rPr lang="en-US" sz="1100"/><a:t>${L[t]}</a:t></a:r></a:p></xdr:txBody></xdr:sp></mc:Fallback></mc:AlternateContent><xdr:clientData/></xdr:twoCellAnchor>`}const _=t=>`${b}<xdr:wsDr xmlns:xdr="${a.xdr}" xmlns:a="${a.a}">${t}</xdr:wsDr>`,D=/<xdr:(twoCellAnchor|oneCellAnchor|absoluteAnchor)\b[\s\S]*?<\/xdr:\1>/g,S=/<(?:\w+:)?(slicer|timeslicer)\b[^>]*\bname="([^"]*)"/;function G(t){const i=[];for(const e of t.matchAll(D)){const n=e[0];if(!/drawing\/20(?:10|12)\/(?:time)?slicer/.test(n))continue;const r=S.exec(n);if(!r)continue;const o=m=>{const s=new RegExp(`<xdr:${m}>\\s*<xdr:col>(\\d+)</xdr:col>\\s*<xdr:colOff>(-?\\d+)</xdr:colOff>\\s*<xdr:row>(\\d+)</xdr:row>\\s*<xdr:rowOff>(-?\\d+)</xdr:rowOff>`).exec(n);return s?{col:Number(s[1]),colOff:Number(s[2]),row:Number(s[3]),rowOff:Number(s[4])}:null},l=(m,s,c)=>{const d=new RegExp(`<xdr:${m}\\b[^>]*>`).exec(n)?.[0];if(d===void 0)return null;const w=F=>Number(new RegExp(`\\b${F}="(-?\\d+)"`).exec(d)?.[1]),g=w(s),N=w(c);return Number.isFinite(g)&&Number.isFinite(N)?{[s]:g,[c]:N}:null};i.push({kind:r[1]==="timeslicer"?"timeline":/Requires="sle15"/.test(n)?"table":"pivot",name:I(r[2]),id:Number(/<xdr:cNvPr\b[^>]*\bid="(\d+)"/.exec(n)?.[1]??0),from:o("from"),to:o("to"),pos:e[1]==="absoluteAnchor"?l("pos","x","y"):null,ext:e[1]==="twoCellAnchor"?null:l("ext","cx","cy"),raw:n})}return i}function q(t,{upsert:i=[],remove:e=[]}){const n=new Map(i.map(s=>[s.name,s.xml])),r=new Set(e),o=new Set;let l=t.replace(D,s=>{if(!/drawing\/20(?:10|12)\/(?:time)?slicer/.test(s))return s;const c=S.exec(s);if(!c)return s;const d=I(c[2]);return r.has(d)?"":n.has(d)?(o.add(d),n.get(d)):s});const m=i.filter(s=>!o.has(s.name)).map(s=>s.xml).join("");return m&&(l=l.replace(/<\/(\w+:)?wsDr>\s*$/,s=>`${m}${s}`)),l}const y=new Set(["name","xr10:uid","cache","caption","startItem","columnCount","showCaption","level","style","lockedPosition","rowHeight"]),P=new Set(["name","xr10:uid","cache","caption","showHeader","showSelectionLabel","showTimeLevel","showHorizontalScrollbar","level","selectionLevel","scrollPosition","style"]),T=(t,i)=>{const e={};for(const[n,r]of Object.entries(t))!i.has(n)&&!n.startsWith("xmlns")&&n!=="mc:Ignorable"&&(e[n]=r);return e};function K(t){const i=p(t),e={name:i.a.name,sourceName:i.a.sourceName,uid:i.a["xr10:uid"]??null,kind:"pivot",sortOrder:"ascending",customListSort:!0,crossFilter:"showItemsWithDataAtTop",showMissing:!0,hideNoData:!1,pivotTables:[],items:[],pivotCacheId:null,tableId:null,column:null},n=o=>{o.sortOrder&&(e.sortOrder=o.sortOrder),e.customListSort=x(o.customListSort,!0),o.crossFilter&&(e.crossFilter=o.crossFilter)};for(const o of v(f(i,"pivotTables"),"pivotTable"))e.pivotTables.push({tabId:Number(o.a.tabId),name:o.a.name});const r=f(f(i,"data"),"tabular");if(r){e.pivotCacheId=Number(r.a.pivotCacheId),n(r.a),e.showMissing=x(r.a.showMissing,!0);for(const o of v(f(r,"items"),"i"))e.items.push({x:Number(o.a.x),s:x(o.a.s,!1),nd:x(o.a.nd,!1)})}for(const o of f(i,"extLst")?.c??[])if($(o.n)==="ext")if(o.a.uri===h.tableSlicerCache){const l=o.c.find(m=>$(m.n)==="tableSlicerCache");l&&(e.kind="table",e.tableId=Number(l.a.tableId),e.column=Number(l.a.column),n(l.a))}else o.a.uri===h.hideNoData&&(e.hideNoData=!0);return e}function U(t){const i=p(t);return v(i,"slicer").map(e=>({name:e.a.name,uid:e.a["xr10:uid"]??null,cache:e.a.cache,caption:e.a.caption??e.a.name,startItem:Number(e.a.startItem??0),columnCount:Number(e.a.columnCount??1),showCaption:x(e.a.showCaption,!0),level:Number(e.a.level??0),style:e.a.style??"SlicerStyleLight1",lockedPosition:x(e.a.lockedPosition,!1),rowHeight:Number(e.a.rowHeight??241300),extra:T(e.a,y)}))}function J(t){const i=p(t),e=f(i,"state"),n=r=>{const o=f(e,r);return o?{start:o.a.startDate,end:o.a.endDate}:null};return{name:i.a.name,sourceName:i.a.sourceName,uid:i.a["xr10:uid"]??null,pivotTables:v(f(i,"pivotTables"),"pivotTable").map(r=>({tabId:Number(r.a.tabId),name:r.a.name})),singleRange:x(e?.a.singleRangeFilterState,!0),minimalRefreshVersion:Number(e?.a.minimalRefreshVersion??6),lastRefreshVersion:Number(e?.a.lastRefreshVersion??6),pivotCacheId:Number(e?.a.pivotCacheId??0),filterType:e?.a.filterType??"unknown",filterId:e?.a.filterId!==void 0?Number(e.a.filterId):null,filterTabId:e?.a.filterTabId!==void 0?Number(e.a.filterTabId):null,filterPivotName:e?.a.filterPivotName??null,selection:n("selection"),bounds:n("bounds")}}function Q(t){const i=p(t);return v(i,"timeline").map(e=>({name:e.a.name,uid:e.a["xr10:uid"]??null,cache:e.a.cache,caption:e.a.caption??e.a.name,showHeader:x(e.a.showHeader,!0),showSelectionLabel:x(e.a.showSelectionLabel,!0),showTimeLevel:x(e.a.showTimeLevel,!0),showHorizontalScrollbar:x(e.a.showHorizontalScrollbar,!0),level:Number(e.a.level??2),selectionLevel:Number(e.a.selectionLevel??e.a.level??2),scrollPosition:e.a.scrollPosition??null,style:e.a.style??"TimeSlicerStyleLight1",extra:T(e.a,P)}))}function Y(t){const i=p(t);for(const e of f(i,"extLst")?.c??[]){if(e.a.uri!==h.pivotCacheId)continue;const n=e.c.find(r=>$(r.n)==="pivotCacheDefinition");if(n?.a.pivotCacheId!==void 0)return Number(n.a.pivotCacheId)}return null}function Z(t,i){const e=`<ext uri="${h.pivotCacheId}" xmlns:x14="${a.x14}"><x14:pivotCacheDefinition pivotCacheId="${i}"/></ext>`;return t.includes(h.pivotCacheId)?t.replace(/(<x14:pivotCacheDefinition\b[^>]*\bpivotCacheId=")\d+/,`$1${i}`):/<extLst>/.test(t)?t.replace(/<extLst>/,`<extLst>${e}`):t.replace("</pivotCacheDefinition>",`<extLst>${e}</extLst></pivotCacheDefinition>`)}import{isoToSerial as ie,serialToIso as oe}from"../pivot/xml.js";export{H as CT,h as EXT,a as NS,k as REL,b as XML_HEAD,W as frameXml,ie as isoToSerial,_ as newDrawingXml,G as parseFrames,K as parseSlicerCacheXml,U as parseSlicersXml,J as parseTimelineCacheXml,Q as parseTimelinesXml,q as patchDrawingFrames,Y as pivotCacheExtId,oe as serialToIso,Z as setPivotCacheExtId,M as slicerCacheXml,j as slicersXml,X as tabPlaceholder,z as timelineCacheXml,V as timelinesXml};
|
package/slicers/structured.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function C(t,h,r){const{r0:s,c0:a,r1:o,c1:e,headerRows:n,totalsRows:d,columns:A}=t,T=s+n,E=o-d;let f=h.slice(1,-1),g=!1;f.trimStart()[0]==="@"&&(g=!0,f=f.trimStart().slice(1));const L=[];if(f.trim()!=="")if(f.trimStart()[0]==="["){const c=/\[((?:[^\]']|'.)*)\]/g;let l;for(;(l=c.exec(f))!==null;)L.push(l[1].replace(/'(.)/g,"$1"))}else L.push(f.replace(/'(.)/g,"$1"));const u=new Set,p=[];for(const c of L){const l=c.toUpperCase(),i=l.trim();if(i==="#ALL"||i==="#DATA"||i==="#HEADERS"||i==="#TOTALS"||i==="#THIS ROW"){u.add(i),i==="#THIS ROW"&&(g=!0);continue}let R=A.findIndex(w=>w.toUpperCase()===l);if(R<0&&(R=A.findIndex(w=>w.toUpperCase()===i)),R<0)return"REF";p.push(a+R)}let m=T,S=E;if(u.has("#ALL"))m=s,S=o;else{const c=u.has("#HEADERS"),l=u.has("#TOTALS"),i=u.has("#DATA");if(c&&n===0||l&&d===0||c&&l&&!i)return"REF";(c||l||i)&&(m=c?s:i?T:o,S=l?o:i?E:s)}const U=p.length?Math.min(...p):a,b=p.length?Math.max(...p):e;if(g){if(r<T||r>E)return"VALUE";m=r,S=r}return{top:m,left:U,bottom:S,right:b}}function D(t,h){if(!h||h.size===0)return t;let r="",s=0;const a=t.length;for(;s<a;){const o=t[s];if(o==='"'||o==="'"){let e=s+1;for(;e<a;){if(t[e]===o){if(t[e+1]!==o)break;e++}e++}r+=t.slice(s,e+1),s=e+1}else if(o==="["){let e=0,n=s;for(;n<a;n++)if(t[n]==="'")n++;else if(t[n]==="[")e++;else if(t[n]==="]"&&--e===0)break;r+=t.slice(s,n+1),s=n+1}else if(/[A-Za-z_\\]/.test(o)){let e=s+1;for(;e<a&&/[A-Za-z0-9_.\\]/.test(t[e]);)e++;const n=t.slice(s,e),d=r[r.length-1],A=h.has(n.toUpperCase())&&t[e]!=="["&&t[e]!=="("&&t[e]!=="!"&&d!=="!";r+=A?`${n}[]`:n,s=e}else r+=o,s++}return r}export{D as expandBareTables,C as resolveStructuredSpec};
|