@mlightcad/mtext-renderer 0.12.8 → 0.12.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -2
- package/dist/index.umd.cjs +1 -1
- package/dist/mtext-renderer-worker.js +20 -2
- package/lib/font/defaultFontsPresets.d.ts +11 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2580,13 +2580,31 @@ const Ar = {
|
|
|
2580
2580
|
// BIGFONT SHX stays available via glyph fallback for CJK coverage.
|
|
2581
2581
|
modern: ["simsun", "hztxt"],
|
|
2582
2582
|
international: ["txt", "simplex", "romans", "simsun"],
|
|
2583
|
-
|
|
2583
|
+
// Full CJK: mesh faces for CN/KR/JP, then matching SHX big fonts.
|
|
2584
|
+
// `malgun` → Noto Sans KR; `msgothic` → MS Gothic in the font repository.
|
|
2585
|
+
cjk: [
|
|
2586
|
+
"simsun",
|
|
2587
|
+
"malgun",
|
|
2588
|
+
"msgothic",
|
|
2589
|
+
"gbcbig",
|
|
2590
|
+
"hztxt",
|
|
2591
|
+
"extfont2",
|
|
2592
|
+
"extfont",
|
|
2593
|
+
"whgtxt",
|
|
2594
|
+
"whgdtxt"
|
|
2595
|
+
],
|
|
2596
|
+
chinese: ["simsun", "gbcbig", "hztxt"],
|
|
2597
|
+
korean: ["malgun", "whgtxt", "whgdtxt"],
|
|
2598
|
+
japanese: ["msgothic", "extfont2", "extfont"]
|
|
2584
2599
|
}, Zn = {
|
|
2585
2600
|
minimal: ["simplex", "amgdt"],
|
|
2586
2601
|
r12r14: ["simplex", "amgdt"],
|
|
2587
2602
|
modern: ["simplex", "amgdt"],
|
|
2588
2603
|
international: ["simplex", "amgdt"],
|
|
2589
|
-
cjk: ["simplex", "amgdt"]
|
|
2604
|
+
cjk: ["simplex", "amgdt"],
|
|
2605
|
+
chinese: ["simplex", "amgdt"],
|
|
2606
|
+
korean: ["simplex", "amgdt"],
|
|
2607
|
+
japanese: ["simplex", "amgdt"]
|
|
2590
2608
|
};
|
|
2591
2609
|
function ks(t) {
|
|
2592
2610
|
return Object.prototype.hasOwnProperty.call(Ar, t);
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(A,he){typeof exports=="object"&&typeof module<"u"?he(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],he):(A=typeof globalThis<"u"?globalThis:A||self,he(A.MTextRenderer={},A.THREE))})(this,function(A,he){"use strict";function zo(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const M=zo(he);class Xn{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(n=>n!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...n){for(const r of this.listeners)r.call(null,e,...n)}}const Wo=t=>t.substring(t.lastIndexOf(".")+1),vs=t=>t.split("/").pop(),ct=t=>{const e=vs(t);if(e){const n=e.lastIndexOf(".");return n===-1?e:e.substring(0,n)}return t},Vo=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0],Kn=t=>Vo[t];function Zn(t){var r,s,i;if(!t||jo(t))return 0;let e=0;const{attributes:n}=t;for(const a of Object.keys(n)){const o=n[a];((r=o==null?void 0:o.array)==null?void 0:r.byteLength)!=null&&(e+=o.array.byteLength)}return((i=(s=t.index)==null?void 0:s.array)==null?void 0:i.byteLength)!=null&&(e+=t.index.array.byteLength),e}function jo(t){return t.disposed===!0?!0:Object.keys(t.attributes).length===0&&t.index==null}function Ss(t){return t?t.length*2:0}function Jn(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:0}function Ce(t){if(!Number.isFinite(t)||t<0)return"0 B";if(t<1024)return`${Math.round(t)} B`;const e=["KB","MB","GB"];let n=t/1024,r=0;for(;n>=1024&&r<e.length-1;)n/=1024,r++;const s=Number.isInteger(n)||n>=10?0:1;return`${n.toFixed(s)} ${e[r]}`}class Qn{constructor(e=4096,n){this.map=new Map,this.maxSize=e,this.onEvict=n}get(e){const n=this.map.get(e);return n!==void 0&&(this.map.delete(e),this.map.set(e,n)),n}set(e,n){var r,s;if(this.map.has(e)){const i=this.map.get(e);this.map.delete(e),i!==n&&((r=this.onEvict)==null||r.call(this,e,i))}else if(this.map.size>=this.maxSize){const i=this.map.keys().next().value;if(i!==void 0){const a=this.map.get(i);this.map.delete(i),(s=this.onEvict)==null||s.call(this,i,a)}}this.map.set(e,n)}has(e){return this.map.has(e)}get size(){return this.map.size}get capacity(){return this.maxSize}values(){return this.map.values()}clear(){if(this.onEvict)for(const[e,n]of this.map)this.onEvict(e,n);this.map.clear()}}const qo=4096;class $o{constructor(e=qo){this.maxSize=e,this.cache=new Qn(e,(n,r)=>{r.dispose()})}hasGeometry(e,n){const r=this.generateKey(e,n);return this.cache.has(r)}getGeometry(e,n){const r=this.generateKey(e,n);return this.cache.get(r)}setGeometry(e,n,r){const s=this.generateKey(e,n);this.cache.set(s,r)}getStats(){let e=0;for(const n of this.cache.values())e+=Zn(n);return{entries:this.cache.size,maxEntries:this.maxSize,estimatedBytes:e}}dispose(){this.cache.clear()}generateKey(e,n){return`${e}_${n}`}}class er{constructor(e){this.names=new Set,this.unsupportedChars={},this.encoding=e.encoding,e.alias.forEach(n=>this.names.add(n)),this.sourceByteLength=Jn(e.data),this.cache=new $o}dispose(){this.cache.dispose()}getShapeByName(e,n){}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}}class tr extends M.Shape{constructor(){super(...arguments),this.width=0}hasStrokeGeometry(){return this.width>0}}class ke{static byteToSByte(e){return(e&127)-(e&128?128:0)}constructor(e){this.position=0,this.data=new DataView(e)}readBytes(e=1){this.data.byteLength<this.position+e&&this.throwOutOfRangeError(this.position+e);const n=new Uint8Array(this.data.buffer,this.position,e);return this.position+=e,n}skip(e){this.data.byteLength<this.position+e&&this.throwOutOfRangeError(this.position+e),this.position+=e}readUint8(){this.data.byteLength<this.position+1&&this.throwOutOfRangeError(this.position+1);const e=this.data.getUint8(this.position);return this.position+=1,e}readInt8(){this.data.byteLength<this.position+1&&this.throwOutOfRangeError(this.position+1);const e=this.data.getInt8(this.position);return this.position+=1,e}readUint16(e=!0){this.data.byteLength<this.position+2&&this.throwOutOfRangeError(this.position+2);const n=this.data.getUint16(this.position,e);return this.position+=2,n}readInt16(){this.data.byteLength<this.position+2&&this.throwOutOfRangeError(this.position+2);const e=this.data.getInt16(this.position,!0);return this.position+=2,e}readUint32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getUint32(this.position,!0);return this.position+=4,e}readInt32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getInt32(this.position,!0);return this.position+=4,e}readFloat32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getFloat32(this.position,!0);return this.position+=4,e}readFloat64(){this.data.byteLength<this.position+8&&this.throwOutOfRangeError(this.position+8);const e=this.data.getFloat64(this.position,!0);return this.position+=8,e}setPosition(e){this.data.byteLength<e&&this.throwOutOfRangeError(e),this.position=e}isEnd(){return this.position===this.data.byteLength-1}get currentPosition(){return this.position}get length(){return this.data.byteLength}throwOutOfRangeError(e){throw new Error(`Position ${e} is out of range for the data length ${this.data.byteLength}!`)}}var K=(t=>(t.SHAPES="shapes",t.BIGFONT="bigfont",t.UNIFONT="unifont",t))(K||{});class Yo{parse(e){const n=this.parseHeader(e).split(" "),r=n[1].toLocaleLowerCase();if(!Object.values(K).includes(r))throw new Error(`Invalid font type: ${r}`);return{fileHeader:n[0],fontType:r,fileVersion:n[2]}}parseHeader(e){let n="",r=0;for(;e.currentPosition<e.length-2&&r<1024;){const s=e.readUint8();if(s===13){const i=e.currentPosition,a=e.readUint8(),o=e.readUint8();if(a===10&&o===26)break;e.setPosition(i),n+=String.fromCharCode(s)}else n+=String.fromCharCode(s);r++}return n.trim()}}const Et=10,Xo=[13,10,0];function ws(t,e){if(e===0){t.orientation="horizontal";return}if(e===2){t.orientation="horizontal",t.dualOrientation=!0;return}t.orientation="vertical"}function Ts(t){const e={};for(const[n,r]of Object.entries(t))e[r]=n;return e}function Cs(t){const e=t.indexOf(0);return e<0?{name:null,bytecode:t}:{name:e>0?new TextDecoder("ascii").decode(t.subarray(0,e)):null,bytecode:t.subarray(e+1)}}class Ko{parse(e){try{e.readBytes(4);const n=e.readInt16();if(n<=0)throw new Error("Invalid shape count in font file");const r=[];for(let c=0;c<n;c++){const l=e.readUint16(),u=e.readUint16();u>0&&r.push({code:l,length:u})}const s={};for(const c of r)try{const l=e.readBytes(c.length);l.length===c.length&&(s[c.code]=l)}catch{console.warn(`Failed to read shape data for code ${c.code}`)}const i={},a={};for(const[c,l]of Object.entries(s)){const u=Number(c);if(u===0){i[u]=l;continue}const{name:f,bytecode:h}=Cs(l);i[u]=h,f&&(a[f]=u)}const o={data:i,names:Object.keys(a).length>0?a:void 0,codeToName:Object.keys(a).length>0?Ts(a):void 0,info:"",baseUp:8,baseDown:2,height:Et,width:Et,orientation:"horizontal",isExtended:!1};if(0 in i){const c=i[0];try{const l=new TextDecoder().decode(c);let u=c.findIndex(f=>Xo.includes(f));u>=0&&(o.info=l.substring(0,u),u+3<c.length&&(o.baseUp=c[u+1],o.baseDown=c[u+2],o.height=o.baseDown+o.baseUp,o.width=o.height,ws(o,c[u+3])))}catch{console.warn("Failed to parse font info block")}}return o}catch(n){const r=n instanceof Error?n.message:String(n);throw new Error(`Failed to parse shape font: ${r}`)}}}class Zo{parse(e){try{e.readInt16();const n=e.readInt16(),r=e.readInt16();if(n<=0)throw new Error("Invalid character count in font file");e.skip(r*4);const s=[];for(let o=0;o<n;o++){const c=e.readUint16(),l=e.readUint16(),u=e.readUint32();(c!==0||l!==0||u!==0)&&s.push({code:c,length:l,offset:u})}const i={};for(const o of s)try{e.setPosition(o.offset);const c=e.readBytes(o.length);c.length===o.length&&(i[o.code]=c)}catch{console.warn(`Failed to read bigfont data for code ${o.code}`)}const a={data:i,info:"",baseUp:8,baseDown:2,height:Et,width:Et,orientation:"horizontal",isExtended:!1};if(0 in i){const o=i[0];try{const c=this.utf8ArrayToStr(o);if(c.pos>=0){let l=c.text;for(;l.length>0&&l.charCodeAt(l.length-1)===0;)l=l.slice(0,-1);a.info=l;const u=this.parseBigfontMetrics(o,c.pos+1);u&&Object.assign(a,u)}}catch{console.warn("Failed to parse bigfont info block")}}return a}catch(n){const r=n instanceof Error?n.message:String(n);throw new Error(`Failed to parse big font: ${r}`)}}parseBigfontMetrics(e,n){let r=n;for(;r<e.length&&e[r]===0;)r++;const s=e.length-r;if(s<=0)return null;const i=a=>a===0?"horizontal":"vertical";if(s>=5){const a=e[r++];r++;const o=i(e[r++]),c=e[r++];return{baseUp:a,baseDown:0,height:a,width:c,orientation:o,isExtended:!0}}if(s===4&&e[r+1]===0&&e[r+3]>0&&e[r+3]!==e[r]){const a=e[r++];r++;const o=i(e[r++]),c=e[r];return{baseUp:a,baseDown:0,height:a,width:c,orientation:o,isExtended:!0}}if(s===4){const a=e[r++],o=e[r++],c=i(e[r++]);return{baseUp:a,baseDown:o,height:a+o,width:a+o,orientation:c,isExtended:!1}}if(s===3){const a=e[r++],o=e[r++],c=i(o),l=o===2;return{baseUp:a,baseDown:0,height:a,width:a,orientation:c,isExtended:l,verticalDualMode:l}}return null}utf8ArrayToStr(e){let n="",r=0;for(;r<e.length;){const s=e[r];switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n+=String.fromCharCode(s);break;case 12:case 13:{const i=e[r++];n+=String.fromCharCode((s&31)<<6|i&63);break}case 14:{const i=e[r++],a=e[r++];n+=String.fromCharCode((s&15)<<12|(i&63)<<6|(a&63)<<0);break}}if(n.charCodeAt(n.length-1)===0)break;r++}return{text:n,pos:r}}}class Jo{parse(e){try{const n=e.readInt32();if(n<=0)throw new Error("Invalid character count in font file");const r=e.readInt16(),s=e.readBytes(r),i={data:{},info:"",baseUp:8,baseDown:2,height:Et,width:Et,orientation:"horizontal",isExtended:!1};try{const c=new TextDecoder().decode(s);let l=c.indexOf("\0");l>=0&&(i.info=c.substring(0,l),l+3<s.length&&(i.baseUp=s[l+1],i.baseDown=s[l+2],i.height=i.baseUp+i.baseDown,i.width=i.height,ws(i,s[l+3])))}catch{console.warn("Failed to parse unifont info block")}const a={},o={};for(let c=0;c<n-1;c++)try{const l=e.readUint16(),u=e.readUint16();if(u>0){const f=e.readBytes(u);if(f.length===u){const{name:h,bytecode:p}=Cs(f);p.length>0&&(a[l]=p,h&&(o[h]=l))}}}catch{console.warn("Failed to read unifont character data");break}return i.data=a,i.names=Object.keys(o).length>0?o:void 0,i.codeToName=Object.keys(o).length>0?Ts(o):void 0,i}catch(n){const r=n instanceof Error?n.message:String(n);throw new Error(`Failed to parse unifont: ${r}`)}}}class Qo{static createParser(e){switch(e){case K.SHAPES:return new Ko;case K.BIGFONT:return new Zo;case K.UNIFONT:return new Jo;default:throw new Error(`Unsupported font type: ${e}`)}}}const ks=.2;class ec{markAlignedAdvanceExplicit(e){return!1}}class un extends ec{constructor(e=ks){super(),this.cellWidthFactor=e}static isCenterOriginGlyph(e){return e.bbox.minX<-1e-6}static computeAdvance(e,n,r=ks){if(!e.polylines.some(a=>a.length>=2))return n*r;const s=n*r,{maxX:i}=e.bbox;return un.isCenterOriginGlyph(e)?Math.max(i,n/2)+s:i+s}resolve(e,n){var r;return e.hasExplicitAdvance?((r=e.lastPoint)==null?void 0:r.x)??0:un.computeAdvance(e,n,this.cellWidthFactor)}markAlignedAdvanceExplicit(e){return!0}}const hn=new un;class se{constructor(e=0,n=0){this.x=e,this.y=n}set(e,n){return this.x=e,this.y=n,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const e=this.length();return e!==0&&(this.x/=e,this.y/=e),this}clone(){return new se(this.x,this.y)}add(e){return this.x+=e.x,this.y+=e.y,this}subtract(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e,this.y*=e,this}divide(e){return e!==0&&(this.x/=e,this.y/=e),this}multiplyScalars(e,n){return this.x*=e,this.y*=n,this}divideScalars(e,n){return e!==0&&(this.x/=e),n!==0&&(this.y/=n),this}distanceTo(e){const n=this.x-e.x,r=this.y-e.y;return Math.sqrt(n*n+r*r)}}function Fs(t){const{width:e,capHeight:n,descenderHeight:r,origin:s="baseline"}=t,i=n+r;return s==="top"?{minX:-e/2,maxX:e/2,minY:-i,maxY:0}:{minX:0,maxX:e,minY:-r,maxY:n}}function tc(t){return[t.minX,t.minY,t.maxX,t.maxY].every(Number.isFinite)}function nc(t,e,n=1e-6){return e.minX>=t.minX-n&&e.maxX<=t.maxX+n&&e.minY>=t.minY-n&&e.maxY<=t.maxY+n}function rc(t,e){return{minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}}function sc(t,e,n){const r=t.maxX-t.minX,s=t.maxY-t.minY;return`<rect x="${t.minX}" y="${-t.maxY}" width="${r}" height="${s}" fill="none" stroke="${e}" stroke-width="${n}"/>`}function Es(t,e){const n=t.maxX-t.minX,r=t.maxY-t.minY;return`<rect x="${t.minX}" y="${-t.maxY}" width="${n}" height="${r}" fill="${e}"/>`}function ic(t,e,n,r,s,i,a){const o=` stroke-dasharray="${a}"`;return`<line x1="${t}" y1="${-e}" x2="${n}" y2="${-r}" stroke="${s}" stroke-width="${i}"${o}/>`}function ac(t,e,n){const{capHeight:r,descenderHeight:s,origin:i="baseline"}=t,a=r+s,o=Fs(t);let c,l,u;i==="top"?(r>0&&(c={minX:o.minX,maxX:o.maxX,minY:-r,maxY:0}),s>0&&(l={minX:o.minX,maxX:o.maxX,minY:-a,maxY:-r}),u=-r):(r>0&&(c={minX:o.minX,maxX:o.maxX,minY:0,maxY:r}),s>0&&(l={minX:o.minX,maxX:o.maxX,minY:-s,maxY:0}),u=0);const f=[c?Es(c,"rgba(255, 0, 0, 0.06)"):"",l?Es(l,"rgba(255, 0, 0, 0.14)"):"",sc(o,e,n)];return u!==void 0&&s>0&&r>0&&f.push(ic(o.minX,u,o.maxX,u,e,n,"4 2")),`<g>${f.join("")}</g>`}class At{constructor(e,n=[],r=!1){this.lastPoint=e,this.polylines=n,this.hasExplicitAdvance=r}get bbox(){if(this._bbox)return this._bbox;let e=1/0,n=-1/0,r=1/0,s=-1/0;return this.polylines.forEach(i=>{i.forEach(a=>{e=Math.min(e,a.x),n=Math.max(n,a.x),r=Math.min(r,a.y),s=Math.max(s,a.y)})}),this._bbox={minX:e,minY:r,maxX:n,maxY:s},this._bbox}offset(e,n=!0){var r,s;return n?new At((r=this.lastPoint)==null?void 0:r.clone().add(e),this.polylines.map(i=>i.map(a=>a.clone().add(e))),this.hasExplicitAdvance):((s=this.lastPoint)==null||s.add(e),this.polylines.forEach(i=>i.forEach(a=>a.add(e))),this._bbox&&(this._bbox.maxX+=e.x,this._bbox.minX+=e.x,this._bbox.maxY+=e.y,this._bbox.minY+=e.y),this)}normalizeToOrigin(e=!1){const n=this.bbox;return this.offset(new se(-n.minX,-n.minY),e)}toSVG(e={}){const{strokeWidth:n="0.5%",strokeColor:r="black",isAutoFit:s=!1,fontCell:i}=e;let a,o;const c=l=>this.polylines.map(u=>{let f="";return u.forEach((h,p)=>{const{x:y,y:m}=l(h);f+=p===0?`M ${y} ${m} `:`L ${y} ${m} `}),`<path d="${f}" stroke="${r}" stroke-width="${n}" fill="none"/>`}).join("");if(i){const{padding:l=.1,expandToFit:u=!1,showFrame:f=!1,frameColor:h="red",frameStrokeWidth:p="0.5%"}=i,y=Fs(i),m=this.bbox;let b=y;u&&tc(m)&&!nc(y,m)&&(b=rc(y,m));const v=b.maxX-b.minX,w=b.maxY-b.minY,T=v*l,C=w*l,E=b.minX-T,R=b.maxX+T,N=b.minY-C,V=b.maxY+C;o=c(G=>({x:G.x,y:-G.y}));const Y=f?ac(i,h,p):"";return a=`${E} ${-V} ${R-E} ${V-N}`,`<svg width="100%" height="100%" viewBox="${a}" preserveAspectRatio="xMidYMid meet">${Y}${o}</svg>`}else if(s){const l=this.bbox,u=.2,f=l.maxX-l.minX,h=l.maxY-l.minY,p=f===0?h:f,y=h===0?f:h,m=l.minX-p*u,b=l.maxX+p*u,v=l.minY-y*u,w=l.maxY+y*u;o=c(T=>({x:T.x,y:-T.y})),a=`${m} ${-w} ${b-m} ${w-v}`}else a="0 0 20 20",o=c(l=>({x:l.x+5,y:-l.y+15}));return`<svg width="100%" height="100%" viewBox="${a}" preserveAspectRatio="xMidYMid meet">${o}</svg>`}}const As=8,Os=48,oc=.4,cc=[52164,45795,49829,50150,54992,47610,54754,46532,51906,53947,49332,51706,46532,54224,52946,52714,52219,45755,51403,46532,53947,50410,49332,52219,52141,46532,50150,51120,50150,54992,51663,50119,53186,46532,46525,51365,52149,47016,46532,51889,51706,46025,47037,55031,48122,50935,47531,48122,51965,55e3];function fn(t,e){const{height:n,width:r,baseUp:s,baseDown:i}=t,a=n>0?e/n:1,o=a*s,c=a*i;return{size:e,capHeight:o,descenderHeight:c,cellWidth:a*r,totalHeight:o+c}}function lc(t,e,n){if(t.header.fontType!==K.SHAPES||!(0 in t.content.data))return!1;const r=-(n.descenderHeight+n.capHeight*.2);return e.bbox.minY<r}function Ls(t,e){const n=-(e.descenderHeight+e.capHeight*.05);return!(t.bbox.minY<n||t.bbox.maxY-t.bbox.minY<e.capHeight*.05)}function uc(t,e,n){if(t.header.fontType!==K.BIGFONT||t.content.baseDown>0)return 0;const{height:r}=t.content;if(r<=0)return 0;const s=r*oc,i=[],a=new Set,o=l=>{if(a.has(l)||l<=255||!(l in t.content.data))return;a.add(l);const u=e(l);if(!u)return;const f=u.bbox.minY;f>0&&f<=s&&i.push(f)};for(const l of cc)if(o(l),i.length>=Os)break;if(i.length<As){for(const l of Object.keys(t.content.data))if(o(Number(l)),i.length>=Os)break}if(i.length<As)return 0;i.sort((l,u)=>l-u);const c=Math.floor(i.length/2);return i.length%2===0?(i[c-1]+i[c])/2:i[c]}function hc(t,e,n){if(t.header.fontType!==K.UNIFONT)return!1;if(t.content.dualOrientation)return!0;const r=fn(t.content,n);for(const s of[48,65,78,49]){if(!(s in t.content.data))continue;const i=e(s);if(i&&Ls(i,r))return!0}return!1}function fc(t,e,n,r=hn,s=!1,i=0){var a;let o=t;if(e.header.fontType===K.BIGFONT&&i>0){const u=e.content.height>0?n.size/e.content.height:1;o=o.offset(new se(0,-i*u),!0)}if(e.header.fontType===K.UNIFONT||lc(e,t,n)){const u=e.header.fontType===K.UNIFONT&&(s||e.content.dualOrientation||Ls(t,n));(e.header.fontType!==K.UNIFONT||!u)&&(o=o.offset(new se(0,n.capHeight),!0))}const c=r.resolve(o,n.cellWidth),l=r.markAlignedAdvanceExplicit(o)?!0:o.hasExplicitAdvance;return new At(new se(c,((a=o.lastPoint)==null?void 0:a.y)??0),o.polylines,l)}function pc(t,e,n,r=hn,s=!1,i=0){const a=fn(e.content,n);return fc(t,e,a,r,s,i)}const Is=Math.PI/4;class jt{static fromBulge(e,n,r){const s=Math.max(-1,Math.min(1,r));return new jt({start:e,end:n,bulge:s})}static fromOctant(e,n,r,s,i){return new jt({center:e,radius:n,startOctant:r,octantCount:s,isClockwise:i})}constructor(e){if(e.start&&e.end&&e.bulge!==void 0){this.start=e.start.clone(),this.end=e.end.clone(),this.bulge=e.bulge,this.isClockwise=e.bulge<0;const n=this.end.clone().subtract(this.start),r=n.length();if(Math.abs(this.bulge)*r/2===0){this.radius=0,this.center=this.start.clone(),this.startAngle=Math.atan2(n.y,n.x),this.endAngle=this.startAngle;return}const s=4*Math.atan(Math.abs(this.bulge));this.radius=r/(2*Math.sin(s/2));const i=this.start.clone().add(n.clone().divide(2)),a=new se(-n.y,n.x);a.normalize(),a.multiply(Math.abs(this.radius*Math.cos(s/2))),this.center=i.clone(),this.isClockwise?this.center.subtract(a):this.center.add(a),this.startAngle=Math.atan2(this.start.y-this.center.y,this.start.x-this.center.x),this.endAngle=Math.atan2(this.end.y-this.center.y,this.end.x-this.center.x),this.isClockwise?this.endAngle>=this.startAngle&&(this.endAngle-=2*Math.PI):this.endAngle<=this.startAngle&&(this.endAngle+=2*Math.PI)}else if(e.center&&e.radius!==void 0&&e.startOctant!==void 0&&e.octantCount!==void 0&&e.isClockwise!==void 0){this.center=e.center.clone(),this.radius=e.radius,this.isClockwise=e.isClockwise,this.startAngle=e.startOctant*Is;const n=(e.octantCount===0?8:e.octantCount)*Is;this.endAngle=this.startAngle+(this.isClockwise?-n:n),this.start=this.center.clone().add(new se(this.radius*Math.cos(this.startAngle),this.radius*Math.sin(this.startAngle))),this.end=this.center.clone().add(new se(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))}else throw new Error("Invalid arc parameters")}tessellate(e=Math.PI/18){if(this.radius===0)return[this.start.clone(),this.end.clone()];const n=[this.start.clone()],r=Math.abs(this.endAngle-this.startAngle),s=Math.max(1,Math.floor(r/e));for(let i=1;i<s;i++){const a=i/s,o=this.isClockwise?this.startAngle-a*r:this.startAngle+a*r;n.push(this.center.clone().add(new se(this.radius*Math.cos(o),this.radius*Math.sin(o))))}return n.push(this.end?this.end.clone():this.center.clone().add(new se(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))),n}}const dc=Math.PI/18,gc=1e-6;class mc{constructor(e){this.shapeCache=new Map,this.subshapeCache=new Map,this.shapeData=new Map,this.fontData=e}release(){this.shapeCache.clear(),this.subshapeCache.clear(),this.shapeData.clear()}getCharShape(e,n){const r=this.fontData.header.fontType===K.SHAPES&&!(0 in this.fontData.content.data)?n:n/this.fontData.content.height;return this.parseAndScale(e,{factor:r})}parseAndScale(e,n){if(e===0)return;let r;if(this.shapeCache.has(e))r=this.shapeCache.get(e);else{const s=this.fontData.content.data;if(s[e]){const i=this.prepareBigfontGlyphBytecode(e,s[e]),a=this.fontData.header.fontType!==K.BIGFONT;r=this.parseShape(i,{flushOnEnd:!0,initialPenDown:a}),this.shapeData.set(e,r),this.shapeCache.set(e,r)}}if(r){if(n.factor!==void 0)return this.scaleShapeByFactor(r,n.factor);if(n.height!==void 0){const s=n.width??n.height;return this.scaleShapeByHeightAndWidth(r,n.height,s)}else return r}}prepareBigfontGlyphBytecode(e,n){if(this.fontData.header.fontType!==K.BIGFONT||e<=255)return n;const r=e>>8&255,s=e&255;if(n.length>=2&&n[0]===r&&n[1]===s){let i=2;return n[i]===0&&i++,n.slice(i)}return n}isVerticalDualBigfontMarker(e,n,r){return this.fontData.content.verticalDualMode?r==="open"?e[n]===142:e[n]===143:!1}scaleShapeByFactor(e,n){var r;return new At((r=e.lastPoint)==null?void 0:r.clone().multiply(n),e.polylines.map(s=>s.map(i=>i.clone().multiply(n))),e.hasExplicitAdvance)}scaleShapeByHeightAndWidth(e,n,r){var s;const i=e.bbox,a=i.maxY-i.minY,o=i.maxX-i.minX,c=a>0?n/a:1,l=o>0?r/o:1,u=(s=e.lastPoint)==null?void 0:s.clone();u&&(u.x*=l,u.y*=c);const f=e.polylines.map(h=>h.map(p=>{const y=p.clone();return y.x*=l,y.y*=c,y}));return new At(u,f,e.hasExplicitAdvance)}shouldSkipVerticalFlagCommand(e=!1){const{content:n,header:r}=this.fontData;return r.fontType===K.BIGFONT?!n.verticalDualMode:n.dualOrientation?!e:n.orientation==="horizontal"}markAdvanceDefined(e){e.hasExplicitAdvance=!0}notePenUpPositioning(e){e.pendingTerminalAdvance=!0}clearPendingAdvance(e){e.pendingTerminalAdvance=!1}stateHasInk(e){return e.currentPolyline.length>1?!0:e.polylines.some(n=>n.length>=2)}finalizeAdvanceFlag(e){if(!e.pendingTerminalAdvance)return;const n=e.currentPoint.x;if(Math.abs(n)>gc){e.hasExplicitAdvance=!0;return}this.stateHasInk(e)||(e.hasExplicitAdvance=!0)}parseShape(e,n={}){let r=new se;const s=[];let i=[];const a=[];let o=n.initialPenDown??!1;o&&i.push(r.clone());const c={currentPoint:r,polylines:s,currentPolyline:i,sp:a,isPenDown:o,scale:1,flushEndPolyline:n.flushOnEnd??!1,hasExplicitAdvance:!1,pendingTerminalAdvance:!1};for(let l=0;l<e.length;l++){const u=e[l];u<=15?l=this.handleSpecialCommand(u,e,l,c):(this.clearPendingAdvance(c),this.handleVectorCommand(u,c))}return this.finalizeAdvanceFlag(c),this.buildShapeFromState(c)}buildShapeFromState(e){const n=e.polylines.map(r=>r.map(s=>s.clone()));return e.currentPolyline.length>1&&n.push(e.currentPolyline.map(r=>r.clone())),new At(e.currentPoint.clone(),n,e.hasExplicitAdvance)}handleSpecialCommand(e,n,r,s){let i=r;switch(e){case 0:this.finalizeAdvanceFlag(s),s.flushEndPolyline&&s.currentPolyline.length>1?(s.polylines.push(s.currentPolyline.slice()),s.currentPolyline=[]):s.flushEndPolyline&&(s.currentPolyline=[]),s.isPenDown=!1;break;case 1:this.clearPendingAdvance(s),s.isPenDown||s.currentPolyline.push(s.currentPoint.clone()),s.isPenDown=!0;break;case 2:s.isPenDown=!1,s.currentPolyline.length>1&&s.polylines.push(s.currentPolyline.slice()),s.currentPolyline=[];break;case 3:this.clearPendingAdvance(s),i++,s.scale/=n[i];break;case 4:this.clearPendingAdvance(s),i++,s.scale*=n[i];break;case 5:if(this.clearPendingAdvance(s),s.sp.length===4)throw new Error("The position stack is only four locations deep");s.sp.push(s.currentPoint.clone());break;case 6:this.clearPendingAdvance(s),s.currentPoint=s.sp.pop()??s.currentPoint,s.currentPolyline.length>1&&(s.polylines.push(s.currentPolyline.slice()),s.currentPolyline=[]),s.isPenDown&&s.currentPolyline.push(s.currentPoint.clone());break;case 7:this.clearPendingAdvance(s),i=this.handleSubshapeCommand(n,i,s);break;case 8:i=this.handleXYDisplacement(n,i,s);break;case 9:i=this.handleMultipleXYDisplacements(n,i,s);break;case 10:this.clearPendingAdvance(s),i=this.handleOctantArc(n,i,s);break;case 11:this.clearPendingAdvance(s),i=this.handleFractionalArc(n,i,s);break;case 12:this.clearPendingAdvance(s),i=this.handleBulgeArc(n,i,s);break;case 13:this.clearPendingAdvance(s),i=this.handleMultipleBulgeArcs(n,i,s);break;case 14:this.clearPendingAdvance(s),this.shouldSkipVerticalFlagCommand()&&(i=this.skipCode(n,++i));break}return i}handleVectorCommand(e,n){const r=(e&240)>>4,s=e&15,i=this.getVectorForDirection(s);n.currentPoint.add(i.multiply(r*n.scale)),n.isPenDown&&n.currentPolyline.push(n.currentPoint.clone())}getVectorForDirection(e){const n=new se;switch(e){case 0:n.x=1;break;case 1:n.x=1,n.y=.5;break;case 2:n.x=1,n.y=1;break;case 3:n.x=.5,n.y=1;break;case 4:n.y=1;break;case 5:n.x=-.5,n.y=1;break;case 6:n.x=-1,n.y=1;break;case 7:n.x=-1,n.y=.5;break;case 8:n.x=-1;break;case 9:n.x=-1,n.y=-.5;break;case 10:n.x=-1,n.y=-1;break;case 11:n.x=-.5,n.y=-1;break;case 12:n.y=-1;break;case 13:n.x=.5,n.y=-1;break;case 14:n.x=1,n.y=-1;break;case 15:n.x=1,n.y=-.5;break}return n}handleSubshapeCommand(e,n,r){let s=n,i=0,a,o=r.scale*this.fontData.content.baseUp,c=o;const l=r.currentPoint.clone();switch(r.currentPolyline.length>1&&(r.polylines.push(r.currentPolyline.slice()),r.currentPolyline=[]),this.fontData.header.fontType){case K.SHAPES:s++,i=e[s];break;case K.BIGFONT:if(s++,this.isVerticalDualBigfontMarker(e,s,"open"))return s;if(this.isVerticalDualBigfontMarker(e,s,"close"))return s+1;i=e[s],i===0&&(s++,i=e[s++]<<8|e[s++],l.x=ke.byteToSByte(e[s++])*r.scale,l.y=ke.byteToSByte(e[s++])*r.scale,this.fontData.content.isExtended?(c=e[s++]*r.scale,o=e[s]*r.scale):(o=e[s]*r.scale,c=o));break;case K.UNIFONT:s++,i=e[s++]<<8|e[s++],s--;break}if(i!==0)if(this.fontData.header.fontType===K.UNIFONT){const u=r.isPenDown;a=this.getScaledSubshapeAtInsertPoint(i,c,o,l,u),a!=null&&a.polylines.some(f=>f.length>=2)&&(r.polylines.push(...a.polylines.slice()),a.lastPoint&&(r.currentPoint=a.lastPoint.clone()),r.currentPolyline=[],r.isPenDown&&r.currentPolyline.push(r.currentPoint.clone()))}else if(this.fontData.header.fontType===K.SHAPES)a=this.getScaledSubshapeAtInsertPoint(i,c,o,l),a&&(r.polylines.push(...a.polylines.slice()),a.lastPoint&&(r.currentPoint=a.lastPoint.clone(),a.hasExplicitAdvance&&this.markAdvanceDefined(r))),r.currentPolyline=[],r.isPenDown&&r.currentPolyline.push(r.currentPoint.clone());else{if(a=this.getScaledSubshapeAtInsertPoint(i,c,o,l),a&&(r.polylines.push(...a.polylines.slice()),i===2&&a.lastPoint)){const u=a.lastPoint.x-l.x;u>r.currentPoint.x&&(r.currentPoint.x=u),this.markAdvanceDefined(r)}r.currentPolyline=[]}return s}handleXYDisplacement(e,n,r){let s=n;const i=new se;return i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]),r.currentPoint.add(i.multiply(r.scale)),r.isPenDown?r.currentPolyline.push(r.currentPoint.clone()):this.notePenUpPositioning(r),s}handleMultipleXYDisplacements(e,n,r){let s=n;for(;!(s+1>=e.length);){const i=new se;if(i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]),i.x===0&&i.y===0)break;r.currentPoint.add(i.multiply(r.scale)),r.isPenDown?r.currentPolyline.push(r.currentPoint.clone()):this.notePenUpPositioning(r)}return s}handleOctantArc(e,n,r){let s=n;const i=e[++s]*r.scale,a=ke.byteToSByte(e[++s]),o=(a&112)>>4;let c=a&7;const l=a<0,u=Math.PI/4*o,f=r.currentPoint.clone().subtract(new se(Math.cos(u)*i,Math.sin(u)*i)),h=jt.fromOctant(f,i,o,c,l).tessellate();return r.isPenDown&&(r.currentPolyline.pop(),r.currentPolyline.push(...h.slice())),r.currentPoint=h[h.length-1].clone(),s}handleFractionalArc(e,n,r){let s=n;const i=e[++s],a=e[++s],o=e[++s],c=e[++s],l=(o*255+c)*r.scale,u=ke.byteToSByte(e[++s]),f=(u&112)>>4;let h=u&7;h===0&&(h=8),a!==0&&h--;const p=Math.PI/4;let y=p*h,m=dc,b=1;u<0&&(m=-m,y=-y,b=-1);let v=p*f,w=v+y;v+=p*i/256*b,w+=p*a/256*b;const T=r.currentPoint.clone().subtract(new se(l*Math.cos(v),l*Math.sin(v)));if(r.currentPoint=T.clone().add(new se(l*Math.cos(w),l*Math.sin(w))),r.isPenDown){let C=v;const E=[];if(E.push(T.clone().add(new se(l*Math.cos(C),l*Math.sin(C)))),m>0)for(;C+m<w;)C+=m,E.push(T.clone().add(new se(l*Math.cos(C),l*Math.sin(C))));else for(;C+m>w;)C+=m,E.push(T.clone().add(new se(l*Math.cos(C),l*Math.sin(C))));E.push(T.clone().add(new se(l*Math.cos(w),l*Math.sin(w)))),r.currentPolyline.push(...E)}return s}handleBulgeArc(e,n,r){let s=n;const i=new se;i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]);const a=ke.byteToSByte(e[++s]);return r.currentPoint=this.handleArcSegment(r.currentPoint,i,a,r.scale,r.isPenDown,r.currentPolyline),s}handleMultipleBulgeArcs(e,n,r){let s=n;for(;!(s+1>=e.length);){const i=new se;if(i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]),i.x===0&&i.y===0||s+1>=e.length)break;const a=ke.byteToSByte(e[++s]);r.currentPoint=this.handleArcSegment(r.currentPoint,i,a,r.scale,r.isPenDown,r.currentPolyline)}return s}skipCode(e,n){switch(e[n]){case 0:break;case 1:break;case 2:break;case 3:case 4:n++;break;case 5:break;case 6:break;case 7:switch(this.fontData.header.fontType){case K.SHAPES:n++;break;case K.BIGFONT:n++,this.isVerticalDualBigfontMarker(e,n,"open")?n++:this.isVerticalDualBigfontMarker(e,n,"close")?n+=2:e[n]===0&&(n+=this.fontData.content.isExtended?6:5);break;case K.UNIFONT:n+=2;break}break;case 8:n+=2;break;case 9:for(;n++,!(n>=e.length);){const r=e[n];if(n++,n>=e.length)break;const s=e[n];if(r===0&&s===0)break}break;case 10:n+=2;break;case 11:n+=5;break;case 12:n+=3;break;case 13:for(;n++,!(n>=e.length);){const r=e[n];if(n++,n>=e.length)break;const s=e[n];if(r===0&&s===0)break;n++}break}return n}getScaledSubshapeAtInsertPoint(e,n,r,s,i=!1){let a;if(i){const l=this.fontData.content.data[e];if(!l)return;a=this.parseShape(l,{initialPenDown:!0,flushOnEnd:!0})}else if(a=this.subshapeCache.get(e),!a){const l=this.fontData.content.data[e];if(!l)return;const u=this.fontData.header.fontType!==K.BIGFONT;a=this.parseShape(l,{flushOnEnd:!1,initialPenDown:u}),this.shapeData.set(e,a),this.subshapeCache.set(e,a)}const o=this.fontData.header.fontType===K.BIGFONT?void 0:r/this.fontData.content.baseUp,c=a.polylines.some(l=>l.length>0);return(o!==void 0?this.scaleShapeByFactor(a,o):this.scaleShapeByHeightAndWidth(c?a.normalizeToOrigin(!0):a,r,n)).offset(s,!1)}handleArcSegment(e,n,r,s,i,a){n.x*=s,n.y*=s,r<-127&&(r=-127);const o=e.clone();if(i)if(r===0)a.push(o.clone().add(n));else{const c=o.clone().add(n),l=jt.fromBulge(o,c,r/127).tessellate();a.push(...l.slice(1))}return o.add(n),o}}class Ms{constructor(e){if(e instanceof ArrayBuffer){const n=new ke(e),r=new Yo().parse(n),s=Qo.createParser(r.fontType).parse(n);this.fontData={header:r,content:s}}else this.fontData=e;this.shapeParser=new mc(this.fontData)}hasChar(e){return this.fontData.content.data[e]!==void 0}hasShape(e){return this.getShapeCode(e)!==void 0}getShapeCode(e){const n=this.fontData.content.names;if(n)return n[e.toUpperCase()]}getShapeName(e){var n;const r=(n=this.fontData.content.codeToName)==null?void 0:n[e];if(r!==void 0)return r;const s=this.fontData.content.names;if(s){for(const[i,a]of Object.entries(s))if(a===e)return i}}getFontMetrics(e){return fn(this.fontData.content,e)}getLayoutCharShape(e,n,r=hn){const s=this.getCharShape(e,n);if(s)return pc(s,this.fontData,n,r,this.usesUnifontBaselineOriginFont(n),this.getBigfontBaselineInkPaddingNative())}getBigfontBaselineInkPaddingNative(){if(this.bigfontBaselineInkPaddingNative===void 0){const e=this.fontData.content.height;this.bigfontBaselineInkPaddingNative=uc(this.fontData,n=>this.getCharShape(n,e))}return this.bigfontBaselineInkPaddingNative}usesUnifontBaselineOriginFont(e){return this.unifontBaselineOriginFont===void 0&&(this.unifontBaselineOriginFont=hc(this.fontData,n=>this.getCharShape(n,e),e)),this.unifontBaselineOriginFont}getShapeByName(e,n){const r=this.getShapeCode(e);if(r!==void 0)return this.getCharShape(r,n)}getCharShape(e,n){return this.shapeParser.getCharShape(e,n)}release(){this.shapeParser.release()}}function yc(t,e,n,r=hn){const s=fn(e.content,n);return r.resolve(t,s.cellWidth)}const nr=(t,e)=>e.some(n=>t instanceof n);let Rs,Bs;function bc(){return Rs||(Rs=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function xc(){return Bs||(Bs=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const rr=new WeakMap,sr=new WeakMap,pn=new WeakMap;function vc(t){const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("success",i),t.removeEventListener("error",a)},i=()=>{n(bt(t.result)),s()},a=()=>{r(t.error),s()};t.addEventListener("success",i),t.addEventListener("error",a)});return pn.set(e,t),e}function Sc(t){if(rr.has(t))return;const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",a),t.removeEventListener("abort",a)},i=()=>{n(),s()},a=()=>{r(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",i),t.addEventListener("error",a),t.addEventListener("abort",a)});rr.set(t,e)}let ir={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return rr.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return bt(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function Ds(t){ir=t(ir)}function wc(t){return xc().includes(t)?function(...e){return t.apply(ar(this),e),bt(this.request)}:function(...e){return bt(t.apply(ar(this),e))}}function Tc(t){return typeof t=="function"?wc(t):(t instanceof IDBTransaction&&Sc(t),nr(t,bc())?new Proxy(t,ir):t)}function bt(t){if(t instanceof IDBRequest)return vc(t);if(sr.has(t))return sr.get(t);const e=Tc(t);return e!==t&&(sr.set(t,e),pn.set(e,t)),e}const ar=t=>pn.get(t);function Cc(t,e,{blocked:n,upgrade:r,blocking:s,terminated:i}={}){const a=indexedDB.open(t,e),o=bt(a);return r&&a.addEventListener("upgradeneeded",c=>{r(bt(a.result),c.oldVersion,c.newVersion,bt(a.transaction),c)}),n&&a.addEventListener("blocked",c=>n(c.oldVersion,c.newVersion,c)),o.then(c=>{i&&c.addEventListener("close",()=>i()),s&&c.addEventListener("versionchange",l=>s(l.oldVersion,l.newVersion,l))}).catch(()=>{}),o}const kc=["get","getKey","getAll","getAllKeys","count"],Fc=["put","add","delete","clear"],or=new Map;function _s(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(or.get(e))return or.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,s=Fc.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(s||kc.includes(n)))return;const i=async function(a,...o){const c=this.transaction(a,s?"readwrite":"readonly");let l=c.store;return r&&(l=l.index(o.shift())),(await Promise.all([l[n](...o),s&&c.done]))[0]};return or.set(e,i),i}Ds(t=>({...t,get:(e,n,r)=>_s(e,n)||t.get(e,n,r),has:(e,n)=>!!_s(e,n)||t.has(e,n)}));const Ec=["continue","continuePrimaryKey","advance"],Us={},cr=new WeakMap,Ps=new WeakMap,Ac={get(t,e){if(!Ec.includes(e))return t[e];let n=Us[e];return n||(n=Us[e]=function(...r){cr.set(this,Ps.get(this)[e](...r))}),n}};async function*Oc(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;const n=new Proxy(e,Ac);for(Ps.set(n,e),pn.set(n,ar(e));e;)yield n,e=await(cr.get(n)||e.continue()),cr.delete(n)}function Ns(t,e){return e===Symbol.asyncIterator&&nr(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&nr(t,[IDBIndex,IDBObjectStore])}Ds(t=>({...t,get(e,n,r){return Ns(e,n)?Oc:t.get(e,n,r)},has(e,n){return Ns(e,n)||t.has(e,n)}}));const xt={fonts:"fonts"},lr=[{version:1,stores:[{name:xt.fonts,keyPath:"name"}]},{version:2,stores:[{name:xt.fonts,keyPath:"name"}]}],De=class De{constructor(){this.isClosing=!1,typeof window<"u"&&window.addEventListener("pagehide",e=>{e.persisted||this.close()})}static get instance(){return De._instance||(De._instance=new De),De._instance}async set(e,n){await(await this.getDatabase()).put(xt.fonts,{...n,name:e})}async get(e){return await(await this.getDatabase()).get(xt.fonts,e)}async find(e){const n=ct(e).toLowerCase(),r=await this.get(n);return r||(await this.getAll()).find(i=>{var a;return i.name===n||((a=i.alias)==null?void 0:a.some(o=>o.toLowerCase()===n))})}async delete(e){await(await this.getDatabase()).delete(xt.fonts,e)}async getAll(){return await(await this.getDatabase()).getAll(xt.fonts)}async getStorageStats(){const n=(await this.getAll()).map(s=>({name:s.name,type:s.type,bytes:Jn(s.data)})),r=n.reduce((s,i)=>s+i.bytes,0);return{fontCount:n.length,totalBytes:r,fonts:n}}async clear(){await(await this.getDatabase()).clear(xt.fonts)}async has(e){return await this.get(e)!==void 0}close(){if(!this.isClosing){this.isClosing=!0;try{this.db&&(this.db.close(),this.db=void 0)}finally{this.isClosing=!1}}}async destroy(){this.close(),await indexedDB.deleteDatabase(De.DATABASE_NAME),De._instance=void 0}async getDatabase(){if(this.isClosing)throw new Error("Cannot perform operation while database is closing");return this.db?this.db:(this.db=await Cc(De.DATABASE_NAME,De.DATABASE_VERSION,{upgrade:(e,n,r)=>this.handleUpgrade(e,n,r),blocked(){console.warn("Database upgrade blocked - please close other tabs using the application")},blocking(){console.warn("Database blocking newer version - closing connection"),De.instance.close()}}),this.db)}handleUpgrade(e,n,r){const s=lr.filter(i=>i.version>n&&(!r||i.version<=r));for(const i of s)this.applySchemaVersion(e,i)}applySchemaVersion(e,n){for(const r of n.stores)e.objectStoreNames.contains(r.name)||e.createObjectStore(r.name,{keyPath:r.keyPath})}};De.DATABASE_NAME="mlightcad",De.DATABASE_VERSION=lr[lr.length-1].version;let Qe=De;const Gs=512;function Hs(t,e){return(t+e)*Gs}const zs=2.5,Ws=1.5;function ur(){return{meshCount:0,lineCount:0,estimatedBytes:0}}const dn={minimal:["txt","simsun"],r12r14:["txt","simplex","romans","gbcbig","simsun"],modern:["simsun","hztxt"],international:["txt","simplex","romans","simsun"],cjk:["simsun","gbcbig","hztxt"]},gn={minimal:["simplex","amgdt"],r12r14:["simplex","amgdt"],modern:["simplex","amgdt"],international:["simplex","amgdt"],cjk:["simplex","amgdt"]};function hr(t){return Object.prototype.hasOwnProperty.call(dn,t)}var fr=0,Vs=-3;function qt(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Lc(t,e){this.source=t,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new qt,this.dtree=new qt}var js=new qt,qs=new qt,pr=new Uint8Array(30),dr=new Uint16Array(30),$s=new Uint8Array(30),Ys=new Uint16Array(30),Ic=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xs=new qt,$e=new Uint8Array(320);function Ks(t,e,n,r){var s,i;for(s=0;s<n;++s)t[s]=0;for(s=0;s<30-n;++s)t[s+n]=s/n|0;for(i=r,s=0;s<30;++s)e[s]=i,i+=1<<t[s]}function Mc(t,e){var n;for(n=0;n<7;++n)t.table[n]=0;for(t.table[7]=24,t.table[8]=152,t.table[9]=112,n=0;n<24;++n)t.trans[n]=256+n;for(n=0;n<144;++n)t.trans[24+n]=n;for(n=0;n<8;++n)t.trans[168+n]=280+n;for(n=0;n<112;++n)t.trans[176+n]=144+n;for(n=0;n<5;++n)e.table[n]=0;for(e.table[5]=32,n=0;n<32;++n)e.trans[n]=n}var Zs=new Uint16Array(16);function gr(t,e,n,r){var s,i;for(s=0;s<16;++s)t.table[s]=0;for(s=0;s<r;++s)t.table[e[n+s]]++;for(t.table[0]=0,i=0,s=0;s<16;++s)Zs[s]=i,i+=t.table[s];for(s=0;s<r;++s)e[n+s]&&(t.trans[Zs[e[n+s]]++]=s)}function Rc(t){t.bitcount--||(t.tag=t.source[t.sourceIndex++],t.bitcount=7);var e=t.tag&1;return t.tag>>>=1,e}function Ye(t,e,n){if(!e)return n;for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var r=t.tag&65535>>>16-e;return t.tag>>>=e,t.bitcount-=e,r+n}function mr(t,e){for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var n=0,r=0,s=0,i=t.tag;do r=2*r+(i&1),i>>>=1,++s,n+=e.table[s],r-=e.table[s];while(r>=0);return t.tag=i,t.bitcount-=s,e.trans[n+r]}function Bc(t,e,n){var r,s,i,a,o,c;for(r=Ye(t,5,257),s=Ye(t,5,1),i=Ye(t,4,4),a=0;a<19;++a)$e[a]=0;for(a=0;a<i;++a){var l=Ye(t,3,0);$e[Ic[a]]=l}for(gr(Xs,$e,0,19),o=0;o<r+s;){var u=mr(t,Xs);switch(u){case 16:var f=$e[o-1];for(c=Ye(t,2,3);c;--c)$e[o++]=f;break;case 17:for(c=Ye(t,3,3);c;--c)$e[o++]=0;break;case 18:for(c=Ye(t,7,11);c;--c)$e[o++]=0;break;default:$e[o++]=u;break}}gr(e,$e,0,r),gr(n,$e,r,s)}function Js(t,e,n){for(;;){var r=mr(t,e);if(r===256)return fr;if(r<256)t.dest[t.destLen++]=r;else{var s,i,a,o;for(r-=257,s=Ye(t,pr[r],dr[r]),i=mr(t,n),a=t.destLen-Ye(t,$s[i],Ys[i]),o=a;o<a+s;++o)t.dest[t.destLen++]=t.dest[o]}}}function Dc(t){for(var e,n,r;t.bitcount>8;)t.sourceIndex--,t.bitcount-=8;if(e=t.source[t.sourceIndex+1],e=256*e+t.source[t.sourceIndex],n=t.source[t.sourceIndex+3],n=256*n+t.source[t.sourceIndex+2],e!==(~n&65535))return Vs;for(t.sourceIndex+=4,r=e;r;--r)t.dest[t.destLen++]=t.source[t.sourceIndex++];return t.bitcount=0,fr}function Qs(t,e){var n=new Lc(t,e),r,s,i;do{switch(r=Rc(n),s=Ye(n,2,0),s){case 0:i=Dc(n);break;case 1:i=Js(n,js,qs);break;case 2:Bc(n,n.ltree,n.dtree),i=Js(n,n.ltree,n.dtree);break;default:i=Vs}if(i!==fr)throw new Error("Data error")}while(!r);return n.destLen<n.dest.length?typeof n.dest.slice=="function"?n.dest.slice(0,n.destLen):n.dest.subarray(0,n.destLen):n.dest}Mc(js,qs),Ks(pr,dr,4,3),Ks($s,Ys,2,1),pr[28]=0,dr[28]=258;function Ot(t,e,n,r,s){return Math.pow(1-s,3)*t+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*n+Math.pow(s,3)*r}function vt(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}vt.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},vt.prototype.addPoint=function(t,e){typeof t=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))},vt.prototype.addX=function(t){this.addPoint(t,null)},vt.prototype.addY=function(t){this.addPoint(null,t)},vt.prototype.addBezier=function(t,e,n,r,s,i,a,o){const c=[t,e],l=[n,r],u=[s,i],f=[a,o];this.addPoint(t,e),this.addPoint(a,o);for(let h=0;h<=1;h++){const p=6*c[h]-12*l[h]+6*u[h],y=-3*c[h]+9*l[h]-9*u[h]+3*f[h],m=3*l[h]-3*c[h];if(y===0){if(p===0)continue;const T=-m/p;0<T&&T<1&&(h===0&&this.addX(Ot(c[h],l[h],u[h],f[h],T)),h===1&&this.addY(Ot(c[h],l[h],u[h],f[h],T)));continue}const b=Math.pow(p,2)-4*m*y;if(b<0)continue;const v=(-p+Math.sqrt(b))/(2*y);0<v&&v<1&&(h===0&&this.addX(Ot(c[h],l[h],u[h],f[h],v)),h===1&&this.addY(Ot(c[h],l[h],u[h],f[h],v)));const w=(-p-Math.sqrt(b))/(2*y);0<w&&w<1&&(h===0&&this.addX(Ot(c[h],l[h],u[h],f[h],w)),h===1&&this.addY(Ot(c[h],l[h],u[h],f[h],w)))}},vt.prototype.addQuad=function(t,e,n,r,s,i){const a=t+.6666666666666666*(n-t),o=e+2/3*(r-e),c=a+1/3*(s-t),l=o+1/3*(i-e);this.addBezier(t,e,a,o,c,l,s,i)};var ei=vt;function pe(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var $t={};function ti(t,e){const n=Math.floor(t),r=t-n;if($t[e]||($t[e]={}),$t[e][r]!==void 0){const i=$t[e][r];return n+i}const s=+(Math.round(r+"e+"+e)+"e-"+e);return $t[e][r]=s,n+s}function ni(t){let e=[[]],n=0,r=0;for(let s=0;s<t.length;s+=1){const i=e[e.length-1],a=t[s],o=i[0],c=i[1],l=i[i.length-1],u=t[s+1];i.push(a),a.type==="M"?(n=a.x,r=a.y):a.type==="L"&&(!u||u.type==="Z")?Math.abs(a.x-n)>1||Math.abs(a.y-r)>1||i.pop():a.type==="L"&&l&&l.x===a.x&&l.y===a.y?i.pop():a.type==="Z"&&(o&&c&&l&&o.type==="M"&&c.type==="L"&&l.type==="L"&&l.x===o.x&&l.y===o.y&&(i.shift(),i[0].type="M"),s+1<t.length&&e.push([]))}return t=[].concat.apply([],e),t}function _c(t){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},t)}function Uc(t){return parseInt(t)===t&&(t={decimalPlaces:t,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},t)}pe.prototype.fromSVG=function(t,e={}){typeof SVGPathElement<"u"&&t instanceof SVGPathElement&&(t=t.getAttribute("d")),e=_c(e),this.commands=[];const n="0123456789",r="MmLlQqCcZzHhVv",s="SsTtAa",i="-+";let a={},o=[""],c=!1;function l(y){return y.filter(m=>m.length).map(m=>{let b=parseFloat(m);return(e.decimalPlaces||e.decimalPlaces===0)&&(b=ti(b,e.decimalPlaces)),b})}function u(y){if(!this.commands.length)return y;const m=this.commands[this.commands.length-1];for(let b=0;b<y.length;b++)y[b]+=m[b&1?"y":"x"];return y}function f(){if(a.type===void 0)return;const y=a.type.toUpperCase(),m=y!=="Z"&&a.type.toUpperCase()!==a.type;let b=l(o);if(o=[""],!b.length&&y!=="Z")return;m&&y!=="H"&&y!=="V"&&(b=u.apply(this,[b]));const v=this.commands.length&&this.commands[this.commands.length-1].x||0,w=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(y){case"M":this.moveTo(...b);break;case"L":this.lineTo(...b);break;case"V":for(let T=0;T<b.length;T++){let C=0;m&&(C=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(v,b[T]+C)}break;case"H":for(let T=0;T<b.length;T++){let C=0;m&&(C=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(b[T]+C,w)}break;case"C":this.bezierCurveTo(...b);break;case"Q":this.quadraticCurveTo(...b);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(const T in this.commands[this.commands.length-1])this.commands[this.commands.length-1][T]===void 0&&(this.commands[this.commands.length-1][T]=0)}for(let y=0;y<t.length;y++){const m=t.charAt(y),b=o[o.length-1];if(n.indexOf(m)>-1)o[o.length-1]+=m;else if(i.indexOf(m)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),m==="-")!a.type||b.indexOf("-")>0?c=!0:b.length?o.push("-"):o[o.length-1]=m;else if(!a.type||b.length>0)c=!0;else continue;else if(r.indexOf(m)>-1)a.type?(f.apply(this),a={type:m}):a.type=m;else{if(s.indexOf(m)>-1)throw new Error("Unsupported path command: "+m+". Currently supported commands are "+r.split("").join(", ")+".");` ,
|
|
1
|
+
(function(A,he){typeof exports=="object"&&typeof module<"u"?he(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],he):(A=typeof globalThis<"u"?globalThis:A||self,he(A.MTextRenderer={},A.THREE))})(this,function(A,he){"use strict";function zo(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const M=zo(he);class Xn{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(n=>n!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...n){for(const r of this.listeners)r.call(null,e,...n)}}const Wo=t=>t.substring(t.lastIndexOf(".")+1),vs=t=>t.split("/").pop(),ct=t=>{const e=vs(t);if(e){const n=e.lastIndexOf(".");return n===-1?e:e.substring(0,n)}return t},Vo=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0],Kn=t=>Vo[t];function Zn(t){var r,s,i;if(!t||jo(t))return 0;let e=0;const{attributes:n}=t;for(const a of Object.keys(n)){const o=n[a];((r=o==null?void 0:o.array)==null?void 0:r.byteLength)!=null&&(e+=o.array.byteLength)}return((i=(s=t.index)==null?void 0:s.array)==null?void 0:i.byteLength)!=null&&(e+=t.index.array.byteLength),e}function jo(t){return t.disposed===!0?!0:Object.keys(t.attributes).length===0&&t.index==null}function Ss(t){return t?t.length*2:0}function Jn(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:0}function Ce(t){if(!Number.isFinite(t)||t<0)return"0 B";if(t<1024)return`${Math.round(t)} B`;const e=["KB","MB","GB"];let n=t/1024,r=0;for(;n>=1024&&r<e.length-1;)n/=1024,r++;const s=Number.isInteger(n)||n>=10?0:1;return`${n.toFixed(s)} ${e[r]}`}class Qn{constructor(e=4096,n){this.map=new Map,this.maxSize=e,this.onEvict=n}get(e){const n=this.map.get(e);return n!==void 0&&(this.map.delete(e),this.map.set(e,n)),n}set(e,n){var r,s;if(this.map.has(e)){const i=this.map.get(e);this.map.delete(e),i!==n&&((r=this.onEvict)==null||r.call(this,e,i))}else if(this.map.size>=this.maxSize){const i=this.map.keys().next().value;if(i!==void 0){const a=this.map.get(i);this.map.delete(i),(s=this.onEvict)==null||s.call(this,i,a)}}this.map.set(e,n)}has(e){return this.map.has(e)}get size(){return this.map.size}get capacity(){return this.maxSize}values(){return this.map.values()}clear(){if(this.onEvict)for(const[e,n]of this.map)this.onEvict(e,n);this.map.clear()}}const qo=4096;class $o{constructor(e=qo){this.maxSize=e,this.cache=new Qn(e,(n,r)=>{r.dispose()})}hasGeometry(e,n){const r=this.generateKey(e,n);return this.cache.has(r)}getGeometry(e,n){const r=this.generateKey(e,n);return this.cache.get(r)}setGeometry(e,n,r){const s=this.generateKey(e,n);this.cache.set(s,r)}getStats(){let e=0;for(const n of this.cache.values())e+=Zn(n);return{entries:this.cache.size,maxEntries:this.maxSize,estimatedBytes:e}}dispose(){this.cache.clear()}generateKey(e,n){return`${e}_${n}`}}class er{constructor(e){this.names=new Set,this.unsupportedChars={},this.encoding=e.encoding,e.alias.forEach(n=>this.names.add(n)),this.sourceByteLength=Jn(e.data),this.cache=new $o}dispose(){this.cache.dispose()}getShapeByName(e,n){}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}}class tr extends M.Shape{constructor(){super(...arguments),this.width=0}hasStrokeGeometry(){return this.width>0}}class ke{static byteToSByte(e){return(e&127)-(e&128?128:0)}constructor(e){this.position=0,this.data=new DataView(e)}readBytes(e=1){this.data.byteLength<this.position+e&&this.throwOutOfRangeError(this.position+e);const n=new Uint8Array(this.data.buffer,this.position,e);return this.position+=e,n}skip(e){this.data.byteLength<this.position+e&&this.throwOutOfRangeError(this.position+e),this.position+=e}readUint8(){this.data.byteLength<this.position+1&&this.throwOutOfRangeError(this.position+1);const e=this.data.getUint8(this.position);return this.position+=1,e}readInt8(){this.data.byteLength<this.position+1&&this.throwOutOfRangeError(this.position+1);const e=this.data.getInt8(this.position);return this.position+=1,e}readUint16(e=!0){this.data.byteLength<this.position+2&&this.throwOutOfRangeError(this.position+2);const n=this.data.getUint16(this.position,e);return this.position+=2,n}readInt16(){this.data.byteLength<this.position+2&&this.throwOutOfRangeError(this.position+2);const e=this.data.getInt16(this.position,!0);return this.position+=2,e}readUint32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getUint32(this.position,!0);return this.position+=4,e}readInt32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getInt32(this.position,!0);return this.position+=4,e}readFloat32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getFloat32(this.position,!0);return this.position+=4,e}readFloat64(){this.data.byteLength<this.position+8&&this.throwOutOfRangeError(this.position+8);const e=this.data.getFloat64(this.position,!0);return this.position+=8,e}setPosition(e){this.data.byteLength<e&&this.throwOutOfRangeError(e),this.position=e}isEnd(){return this.position===this.data.byteLength-1}get currentPosition(){return this.position}get length(){return this.data.byteLength}throwOutOfRangeError(e){throw new Error(`Position ${e} is out of range for the data length ${this.data.byteLength}!`)}}var K=(t=>(t.SHAPES="shapes",t.BIGFONT="bigfont",t.UNIFONT="unifont",t))(K||{});class Yo{parse(e){const n=this.parseHeader(e).split(" "),r=n[1].toLocaleLowerCase();if(!Object.values(K).includes(r))throw new Error(`Invalid font type: ${r}`);return{fileHeader:n[0],fontType:r,fileVersion:n[2]}}parseHeader(e){let n="",r=0;for(;e.currentPosition<e.length-2&&r<1024;){const s=e.readUint8();if(s===13){const i=e.currentPosition,a=e.readUint8(),o=e.readUint8();if(a===10&&o===26)break;e.setPosition(i),n+=String.fromCharCode(s)}else n+=String.fromCharCode(s);r++}return n.trim()}}const Et=10,Xo=[13,10,0];function ws(t,e){if(e===0){t.orientation="horizontal";return}if(e===2){t.orientation="horizontal",t.dualOrientation=!0;return}t.orientation="vertical"}function Ts(t){const e={};for(const[n,r]of Object.entries(t))e[r]=n;return e}function Cs(t){const e=t.indexOf(0);return e<0?{name:null,bytecode:t}:{name:e>0?new TextDecoder("ascii").decode(t.subarray(0,e)):null,bytecode:t.subarray(e+1)}}class Ko{parse(e){try{e.readBytes(4);const n=e.readInt16();if(n<=0)throw new Error("Invalid shape count in font file");const r=[];for(let c=0;c<n;c++){const l=e.readUint16(),u=e.readUint16();u>0&&r.push({code:l,length:u})}const s={};for(const c of r)try{const l=e.readBytes(c.length);l.length===c.length&&(s[c.code]=l)}catch{console.warn(`Failed to read shape data for code ${c.code}`)}const i={},a={};for(const[c,l]of Object.entries(s)){const u=Number(c);if(u===0){i[u]=l;continue}const{name:f,bytecode:h}=Cs(l);i[u]=h,f&&(a[f]=u)}const o={data:i,names:Object.keys(a).length>0?a:void 0,codeToName:Object.keys(a).length>0?Ts(a):void 0,info:"",baseUp:8,baseDown:2,height:Et,width:Et,orientation:"horizontal",isExtended:!1};if(0 in i){const c=i[0];try{const l=new TextDecoder().decode(c);let u=c.findIndex(f=>Xo.includes(f));u>=0&&(o.info=l.substring(0,u),u+3<c.length&&(o.baseUp=c[u+1],o.baseDown=c[u+2],o.height=o.baseDown+o.baseUp,o.width=o.height,ws(o,c[u+3])))}catch{console.warn("Failed to parse font info block")}}return o}catch(n){const r=n instanceof Error?n.message:String(n);throw new Error(`Failed to parse shape font: ${r}`)}}}class Zo{parse(e){try{e.readInt16();const n=e.readInt16(),r=e.readInt16();if(n<=0)throw new Error("Invalid character count in font file");e.skip(r*4);const s=[];for(let o=0;o<n;o++){const c=e.readUint16(),l=e.readUint16(),u=e.readUint32();(c!==0||l!==0||u!==0)&&s.push({code:c,length:l,offset:u})}const i={};for(const o of s)try{e.setPosition(o.offset);const c=e.readBytes(o.length);c.length===o.length&&(i[o.code]=c)}catch{console.warn(`Failed to read bigfont data for code ${o.code}`)}const a={data:i,info:"",baseUp:8,baseDown:2,height:Et,width:Et,orientation:"horizontal",isExtended:!1};if(0 in i){const o=i[0];try{const c=this.utf8ArrayToStr(o);if(c.pos>=0){let l=c.text;for(;l.length>0&&l.charCodeAt(l.length-1)===0;)l=l.slice(0,-1);a.info=l;const u=this.parseBigfontMetrics(o,c.pos+1);u&&Object.assign(a,u)}}catch{console.warn("Failed to parse bigfont info block")}}return a}catch(n){const r=n instanceof Error?n.message:String(n);throw new Error(`Failed to parse big font: ${r}`)}}parseBigfontMetrics(e,n){let r=n;for(;r<e.length&&e[r]===0;)r++;const s=e.length-r;if(s<=0)return null;const i=a=>a===0?"horizontal":"vertical";if(s>=5){const a=e[r++];r++;const o=i(e[r++]),c=e[r++];return{baseUp:a,baseDown:0,height:a,width:c,orientation:o,isExtended:!0}}if(s===4&&e[r+1]===0&&e[r+3]>0&&e[r+3]!==e[r]){const a=e[r++];r++;const o=i(e[r++]),c=e[r];return{baseUp:a,baseDown:0,height:a,width:c,orientation:o,isExtended:!0}}if(s===4){const a=e[r++],o=e[r++],c=i(e[r++]);return{baseUp:a,baseDown:o,height:a+o,width:a+o,orientation:c,isExtended:!1}}if(s===3){const a=e[r++],o=e[r++],c=i(o),l=o===2;return{baseUp:a,baseDown:0,height:a,width:a,orientation:c,isExtended:l,verticalDualMode:l}}return null}utf8ArrayToStr(e){let n="",r=0;for(;r<e.length;){const s=e[r];switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n+=String.fromCharCode(s);break;case 12:case 13:{const i=e[r++];n+=String.fromCharCode((s&31)<<6|i&63);break}case 14:{const i=e[r++],a=e[r++];n+=String.fromCharCode((s&15)<<12|(i&63)<<6|(a&63)<<0);break}}if(n.charCodeAt(n.length-1)===0)break;r++}return{text:n,pos:r}}}class Jo{parse(e){try{const n=e.readInt32();if(n<=0)throw new Error("Invalid character count in font file");const r=e.readInt16(),s=e.readBytes(r),i={data:{},info:"",baseUp:8,baseDown:2,height:Et,width:Et,orientation:"horizontal",isExtended:!1};try{const c=new TextDecoder().decode(s);let l=c.indexOf("\0");l>=0&&(i.info=c.substring(0,l),l+3<s.length&&(i.baseUp=s[l+1],i.baseDown=s[l+2],i.height=i.baseUp+i.baseDown,i.width=i.height,ws(i,s[l+3])))}catch{console.warn("Failed to parse unifont info block")}const a={},o={};for(let c=0;c<n-1;c++)try{const l=e.readUint16(),u=e.readUint16();if(u>0){const f=e.readBytes(u);if(f.length===u){const{name:h,bytecode:p}=Cs(f);p.length>0&&(a[l]=p,h&&(o[h]=l))}}}catch{console.warn("Failed to read unifont character data");break}return i.data=a,i.names=Object.keys(o).length>0?o:void 0,i.codeToName=Object.keys(o).length>0?Ts(o):void 0,i}catch(n){const r=n instanceof Error?n.message:String(n);throw new Error(`Failed to parse unifont: ${r}`)}}}class Qo{static createParser(e){switch(e){case K.SHAPES:return new Ko;case K.BIGFONT:return new Zo;case K.UNIFONT:return new Jo;default:throw new Error(`Unsupported font type: ${e}`)}}}const ks=.2;class ec{markAlignedAdvanceExplicit(e){return!1}}class un extends ec{constructor(e=ks){super(),this.cellWidthFactor=e}static isCenterOriginGlyph(e){return e.bbox.minX<-1e-6}static computeAdvance(e,n,r=ks){if(!e.polylines.some(a=>a.length>=2))return n*r;const s=n*r,{maxX:i}=e.bbox;return un.isCenterOriginGlyph(e)?Math.max(i,n/2)+s:i+s}resolve(e,n){var r;return e.hasExplicitAdvance?((r=e.lastPoint)==null?void 0:r.x)??0:un.computeAdvance(e,n,this.cellWidthFactor)}markAlignedAdvanceExplicit(e){return!0}}const hn=new un;class se{constructor(e=0,n=0){this.x=e,this.y=n}set(e,n){return this.x=e,this.y=n,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const e=this.length();return e!==0&&(this.x/=e,this.y/=e),this}clone(){return new se(this.x,this.y)}add(e){return this.x+=e.x,this.y+=e.y,this}subtract(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e,this.y*=e,this}divide(e){return e!==0&&(this.x/=e,this.y/=e),this}multiplyScalars(e,n){return this.x*=e,this.y*=n,this}divideScalars(e,n){return e!==0&&(this.x/=e),n!==0&&(this.y/=n),this}distanceTo(e){const n=this.x-e.x,r=this.y-e.y;return Math.sqrt(n*n+r*r)}}function Fs(t){const{width:e,capHeight:n,descenderHeight:r,origin:s="baseline"}=t,i=n+r;return s==="top"?{minX:-e/2,maxX:e/2,minY:-i,maxY:0}:{minX:0,maxX:e,minY:-r,maxY:n}}function tc(t){return[t.minX,t.minY,t.maxX,t.maxY].every(Number.isFinite)}function nc(t,e,n=1e-6){return e.minX>=t.minX-n&&e.maxX<=t.maxX+n&&e.minY>=t.minY-n&&e.maxY<=t.maxY+n}function rc(t,e){return{minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}}function sc(t,e,n){const r=t.maxX-t.minX,s=t.maxY-t.minY;return`<rect x="${t.minX}" y="${-t.maxY}" width="${r}" height="${s}" fill="none" stroke="${e}" stroke-width="${n}"/>`}function Es(t,e){const n=t.maxX-t.minX,r=t.maxY-t.minY;return`<rect x="${t.minX}" y="${-t.maxY}" width="${n}" height="${r}" fill="${e}"/>`}function ic(t,e,n,r,s,i,a){const o=` stroke-dasharray="${a}"`;return`<line x1="${t}" y1="${-e}" x2="${n}" y2="${-r}" stroke="${s}" stroke-width="${i}"${o}/>`}function ac(t,e,n){const{capHeight:r,descenderHeight:s,origin:i="baseline"}=t,a=r+s,o=Fs(t);let c,l,u;i==="top"?(r>0&&(c={minX:o.minX,maxX:o.maxX,minY:-r,maxY:0}),s>0&&(l={minX:o.minX,maxX:o.maxX,minY:-a,maxY:-r}),u=-r):(r>0&&(c={minX:o.minX,maxX:o.maxX,minY:0,maxY:r}),s>0&&(l={minX:o.minX,maxX:o.maxX,minY:-s,maxY:0}),u=0);const f=[c?Es(c,"rgba(255, 0, 0, 0.06)"):"",l?Es(l,"rgba(255, 0, 0, 0.14)"):"",sc(o,e,n)];return u!==void 0&&s>0&&r>0&&f.push(ic(o.minX,u,o.maxX,u,e,n,"4 2")),`<g>${f.join("")}</g>`}class At{constructor(e,n=[],r=!1){this.lastPoint=e,this.polylines=n,this.hasExplicitAdvance=r}get bbox(){if(this._bbox)return this._bbox;let e=1/0,n=-1/0,r=1/0,s=-1/0;return this.polylines.forEach(i=>{i.forEach(a=>{e=Math.min(e,a.x),n=Math.max(n,a.x),r=Math.min(r,a.y),s=Math.max(s,a.y)})}),this._bbox={minX:e,minY:r,maxX:n,maxY:s},this._bbox}offset(e,n=!0){var r,s;return n?new At((r=this.lastPoint)==null?void 0:r.clone().add(e),this.polylines.map(i=>i.map(a=>a.clone().add(e))),this.hasExplicitAdvance):((s=this.lastPoint)==null||s.add(e),this.polylines.forEach(i=>i.forEach(a=>a.add(e))),this._bbox&&(this._bbox.maxX+=e.x,this._bbox.minX+=e.x,this._bbox.maxY+=e.y,this._bbox.minY+=e.y),this)}normalizeToOrigin(e=!1){const n=this.bbox;return this.offset(new se(-n.minX,-n.minY),e)}toSVG(e={}){const{strokeWidth:n="0.5%",strokeColor:r="black",isAutoFit:s=!1,fontCell:i}=e;let a,o;const c=l=>this.polylines.map(u=>{let f="";return u.forEach((h,p)=>{const{x:y,y:m}=l(h);f+=p===0?`M ${y} ${m} `:`L ${y} ${m} `}),`<path d="${f}" stroke="${r}" stroke-width="${n}" fill="none"/>`}).join("");if(i){const{padding:l=.1,expandToFit:u=!1,showFrame:f=!1,frameColor:h="red",frameStrokeWidth:p="0.5%"}=i,y=Fs(i),m=this.bbox;let b=y;u&&tc(m)&&!nc(y,m)&&(b=rc(y,m));const v=b.maxX-b.minX,w=b.maxY-b.minY,T=v*l,C=w*l,E=b.minX-T,R=b.maxX+T,N=b.minY-C,V=b.maxY+C;o=c(G=>({x:G.x,y:-G.y}));const Y=f?ac(i,h,p):"";return a=`${E} ${-V} ${R-E} ${V-N}`,`<svg width="100%" height="100%" viewBox="${a}" preserveAspectRatio="xMidYMid meet">${Y}${o}</svg>`}else if(s){const l=this.bbox,u=.2,f=l.maxX-l.minX,h=l.maxY-l.minY,p=f===0?h:f,y=h===0?f:h,m=l.minX-p*u,b=l.maxX+p*u,v=l.minY-y*u,w=l.maxY+y*u;o=c(T=>({x:T.x,y:-T.y})),a=`${m} ${-w} ${b-m} ${w-v}`}else a="0 0 20 20",o=c(l=>({x:l.x+5,y:-l.y+15}));return`<svg width="100%" height="100%" viewBox="${a}" preserveAspectRatio="xMidYMid meet">${o}</svg>`}}const As=8,Os=48,oc=.4,cc=[52164,45795,49829,50150,54992,47610,54754,46532,51906,53947,49332,51706,46532,54224,52946,52714,52219,45755,51403,46532,53947,50410,49332,52219,52141,46532,50150,51120,50150,54992,51663,50119,53186,46532,46525,51365,52149,47016,46532,51889,51706,46025,47037,55031,48122,50935,47531,48122,51965,55e3];function fn(t,e){const{height:n,width:r,baseUp:s,baseDown:i}=t,a=n>0?e/n:1,o=a*s,c=a*i;return{size:e,capHeight:o,descenderHeight:c,cellWidth:a*r,totalHeight:o+c}}function lc(t,e,n){if(t.header.fontType!==K.SHAPES||!(0 in t.content.data))return!1;const r=-(n.descenderHeight+n.capHeight*.2);return e.bbox.minY<r}function Ls(t,e){const n=-(e.descenderHeight+e.capHeight*.05);return!(t.bbox.minY<n||t.bbox.maxY-t.bbox.minY<e.capHeight*.05)}function uc(t,e,n){if(t.header.fontType!==K.BIGFONT||t.content.baseDown>0)return 0;const{height:r}=t.content;if(r<=0)return 0;const s=r*oc,i=[],a=new Set,o=l=>{if(a.has(l)||l<=255||!(l in t.content.data))return;a.add(l);const u=e(l);if(!u)return;const f=u.bbox.minY;f>0&&f<=s&&i.push(f)};for(const l of cc)if(o(l),i.length>=Os)break;if(i.length<As){for(const l of Object.keys(t.content.data))if(o(Number(l)),i.length>=Os)break}if(i.length<As)return 0;i.sort((l,u)=>l-u);const c=Math.floor(i.length/2);return i.length%2===0?(i[c-1]+i[c])/2:i[c]}function hc(t,e,n){if(t.header.fontType!==K.UNIFONT)return!1;if(t.content.dualOrientation)return!0;const r=fn(t.content,n);for(const s of[48,65,78,49]){if(!(s in t.content.data))continue;const i=e(s);if(i&&Ls(i,r))return!0}return!1}function fc(t,e,n,r=hn,s=!1,i=0){var a;let o=t;if(e.header.fontType===K.BIGFONT&&i>0){const u=e.content.height>0?n.size/e.content.height:1;o=o.offset(new se(0,-i*u),!0)}if(e.header.fontType===K.UNIFONT||lc(e,t,n)){const u=e.header.fontType===K.UNIFONT&&(s||e.content.dualOrientation||Ls(t,n));(e.header.fontType!==K.UNIFONT||!u)&&(o=o.offset(new se(0,n.capHeight),!0))}const c=r.resolve(o,n.cellWidth),l=r.markAlignedAdvanceExplicit(o)?!0:o.hasExplicitAdvance;return new At(new se(c,((a=o.lastPoint)==null?void 0:a.y)??0),o.polylines,l)}function pc(t,e,n,r=hn,s=!1,i=0){const a=fn(e.content,n);return fc(t,e,a,r,s,i)}const Is=Math.PI/4;class jt{static fromBulge(e,n,r){const s=Math.max(-1,Math.min(1,r));return new jt({start:e,end:n,bulge:s})}static fromOctant(e,n,r,s,i){return new jt({center:e,radius:n,startOctant:r,octantCount:s,isClockwise:i})}constructor(e){if(e.start&&e.end&&e.bulge!==void 0){this.start=e.start.clone(),this.end=e.end.clone(),this.bulge=e.bulge,this.isClockwise=e.bulge<0;const n=this.end.clone().subtract(this.start),r=n.length();if(Math.abs(this.bulge)*r/2===0){this.radius=0,this.center=this.start.clone(),this.startAngle=Math.atan2(n.y,n.x),this.endAngle=this.startAngle;return}const s=4*Math.atan(Math.abs(this.bulge));this.radius=r/(2*Math.sin(s/2));const i=this.start.clone().add(n.clone().divide(2)),a=new se(-n.y,n.x);a.normalize(),a.multiply(Math.abs(this.radius*Math.cos(s/2))),this.center=i.clone(),this.isClockwise?this.center.subtract(a):this.center.add(a),this.startAngle=Math.atan2(this.start.y-this.center.y,this.start.x-this.center.x),this.endAngle=Math.atan2(this.end.y-this.center.y,this.end.x-this.center.x),this.isClockwise?this.endAngle>=this.startAngle&&(this.endAngle-=2*Math.PI):this.endAngle<=this.startAngle&&(this.endAngle+=2*Math.PI)}else if(e.center&&e.radius!==void 0&&e.startOctant!==void 0&&e.octantCount!==void 0&&e.isClockwise!==void 0){this.center=e.center.clone(),this.radius=e.radius,this.isClockwise=e.isClockwise,this.startAngle=e.startOctant*Is;const n=(e.octantCount===0?8:e.octantCount)*Is;this.endAngle=this.startAngle+(this.isClockwise?-n:n),this.start=this.center.clone().add(new se(this.radius*Math.cos(this.startAngle),this.radius*Math.sin(this.startAngle))),this.end=this.center.clone().add(new se(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))}else throw new Error("Invalid arc parameters")}tessellate(e=Math.PI/18){if(this.radius===0)return[this.start.clone(),this.end.clone()];const n=[this.start.clone()],r=Math.abs(this.endAngle-this.startAngle),s=Math.max(1,Math.floor(r/e));for(let i=1;i<s;i++){const a=i/s,o=this.isClockwise?this.startAngle-a*r:this.startAngle+a*r;n.push(this.center.clone().add(new se(this.radius*Math.cos(o),this.radius*Math.sin(o))))}return n.push(this.end?this.end.clone():this.center.clone().add(new se(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))),n}}const dc=Math.PI/18,gc=1e-6;class mc{constructor(e){this.shapeCache=new Map,this.subshapeCache=new Map,this.shapeData=new Map,this.fontData=e}release(){this.shapeCache.clear(),this.subshapeCache.clear(),this.shapeData.clear()}getCharShape(e,n){const r=this.fontData.header.fontType===K.SHAPES&&!(0 in this.fontData.content.data)?n:n/this.fontData.content.height;return this.parseAndScale(e,{factor:r})}parseAndScale(e,n){if(e===0)return;let r;if(this.shapeCache.has(e))r=this.shapeCache.get(e);else{const s=this.fontData.content.data;if(s[e]){const i=this.prepareBigfontGlyphBytecode(e,s[e]),a=this.fontData.header.fontType!==K.BIGFONT;r=this.parseShape(i,{flushOnEnd:!0,initialPenDown:a}),this.shapeData.set(e,r),this.shapeCache.set(e,r)}}if(r){if(n.factor!==void 0)return this.scaleShapeByFactor(r,n.factor);if(n.height!==void 0){const s=n.width??n.height;return this.scaleShapeByHeightAndWidth(r,n.height,s)}else return r}}prepareBigfontGlyphBytecode(e,n){if(this.fontData.header.fontType!==K.BIGFONT||e<=255)return n;const r=e>>8&255,s=e&255;if(n.length>=2&&n[0]===r&&n[1]===s){let i=2;return n[i]===0&&i++,n.slice(i)}return n}isVerticalDualBigfontMarker(e,n,r){return this.fontData.content.verticalDualMode?r==="open"?e[n]===142:e[n]===143:!1}scaleShapeByFactor(e,n){var r;return new At((r=e.lastPoint)==null?void 0:r.clone().multiply(n),e.polylines.map(s=>s.map(i=>i.clone().multiply(n))),e.hasExplicitAdvance)}scaleShapeByHeightAndWidth(e,n,r){var s;const i=e.bbox,a=i.maxY-i.minY,o=i.maxX-i.minX,c=a>0?n/a:1,l=o>0?r/o:1,u=(s=e.lastPoint)==null?void 0:s.clone();u&&(u.x*=l,u.y*=c);const f=e.polylines.map(h=>h.map(p=>{const y=p.clone();return y.x*=l,y.y*=c,y}));return new At(u,f,e.hasExplicitAdvance)}shouldSkipVerticalFlagCommand(e=!1){const{content:n,header:r}=this.fontData;return r.fontType===K.BIGFONT?!n.verticalDualMode:n.dualOrientation?!e:n.orientation==="horizontal"}markAdvanceDefined(e){e.hasExplicitAdvance=!0}notePenUpPositioning(e){e.pendingTerminalAdvance=!0}clearPendingAdvance(e){e.pendingTerminalAdvance=!1}stateHasInk(e){return e.currentPolyline.length>1?!0:e.polylines.some(n=>n.length>=2)}finalizeAdvanceFlag(e){if(!e.pendingTerminalAdvance)return;const n=e.currentPoint.x;if(Math.abs(n)>gc){e.hasExplicitAdvance=!0;return}this.stateHasInk(e)||(e.hasExplicitAdvance=!0)}parseShape(e,n={}){let r=new se;const s=[];let i=[];const a=[];let o=n.initialPenDown??!1;o&&i.push(r.clone());const c={currentPoint:r,polylines:s,currentPolyline:i,sp:a,isPenDown:o,scale:1,flushEndPolyline:n.flushOnEnd??!1,hasExplicitAdvance:!1,pendingTerminalAdvance:!1};for(let l=0;l<e.length;l++){const u=e[l];u<=15?l=this.handleSpecialCommand(u,e,l,c):(this.clearPendingAdvance(c),this.handleVectorCommand(u,c))}return this.finalizeAdvanceFlag(c),this.buildShapeFromState(c)}buildShapeFromState(e){const n=e.polylines.map(r=>r.map(s=>s.clone()));return e.currentPolyline.length>1&&n.push(e.currentPolyline.map(r=>r.clone())),new At(e.currentPoint.clone(),n,e.hasExplicitAdvance)}handleSpecialCommand(e,n,r,s){let i=r;switch(e){case 0:this.finalizeAdvanceFlag(s),s.flushEndPolyline&&s.currentPolyline.length>1?(s.polylines.push(s.currentPolyline.slice()),s.currentPolyline=[]):s.flushEndPolyline&&(s.currentPolyline=[]),s.isPenDown=!1;break;case 1:this.clearPendingAdvance(s),s.isPenDown||s.currentPolyline.push(s.currentPoint.clone()),s.isPenDown=!0;break;case 2:s.isPenDown=!1,s.currentPolyline.length>1&&s.polylines.push(s.currentPolyline.slice()),s.currentPolyline=[];break;case 3:this.clearPendingAdvance(s),i++,s.scale/=n[i];break;case 4:this.clearPendingAdvance(s),i++,s.scale*=n[i];break;case 5:if(this.clearPendingAdvance(s),s.sp.length===4)throw new Error("The position stack is only four locations deep");s.sp.push(s.currentPoint.clone());break;case 6:this.clearPendingAdvance(s),s.currentPoint=s.sp.pop()??s.currentPoint,s.currentPolyline.length>1&&(s.polylines.push(s.currentPolyline.slice()),s.currentPolyline=[]),s.isPenDown&&s.currentPolyline.push(s.currentPoint.clone());break;case 7:this.clearPendingAdvance(s),i=this.handleSubshapeCommand(n,i,s);break;case 8:i=this.handleXYDisplacement(n,i,s);break;case 9:i=this.handleMultipleXYDisplacements(n,i,s);break;case 10:this.clearPendingAdvance(s),i=this.handleOctantArc(n,i,s);break;case 11:this.clearPendingAdvance(s),i=this.handleFractionalArc(n,i,s);break;case 12:this.clearPendingAdvance(s),i=this.handleBulgeArc(n,i,s);break;case 13:this.clearPendingAdvance(s),i=this.handleMultipleBulgeArcs(n,i,s);break;case 14:this.clearPendingAdvance(s),this.shouldSkipVerticalFlagCommand()&&(i=this.skipCode(n,++i));break}return i}handleVectorCommand(e,n){const r=(e&240)>>4,s=e&15,i=this.getVectorForDirection(s);n.currentPoint.add(i.multiply(r*n.scale)),n.isPenDown&&n.currentPolyline.push(n.currentPoint.clone())}getVectorForDirection(e){const n=new se;switch(e){case 0:n.x=1;break;case 1:n.x=1,n.y=.5;break;case 2:n.x=1,n.y=1;break;case 3:n.x=.5,n.y=1;break;case 4:n.y=1;break;case 5:n.x=-.5,n.y=1;break;case 6:n.x=-1,n.y=1;break;case 7:n.x=-1,n.y=.5;break;case 8:n.x=-1;break;case 9:n.x=-1,n.y=-.5;break;case 10:n.x=-1,n.y=-1;break;case 11:n.x=-.5,n.y=-1;break;case 12:n.y=-1;break;case 13:n.x=.5,n.y=-1;break;case 14:n.x=1,n.y=-1;break;case 15:n.x=1,n.y=-.5;break}return n}handleSubshapeCommand(e,n,r){let s=n,i=0,a,o=r.scale*this.fontData.content.baseUp,c=o;const l=r.currentPoint.clone();switch(r.currentPolyline.length>1&&(r.polylines.push(r.currentPolyline.slice()),r.currentPolyline=[]),this.fontData.header.fontType){case K.SHAPES:s++,i=e[s];break;case K.BIGFONT:if(s++,this.isVerticalDualBigfontMarker(e,s,"open"))return s;if(this.isVerticalDualBigfontMarker(e,s,"close"))return s+1;i=e[s],i===0&&(s++,i=e[s++]<<8|e[s++],l.x=ke.byteToSByte(e[s++])*r.scale,l.y=ke.byteToSByte(e[s++])*r.scale,this.fontData.content.isExtended?(c=e[s++]*r.scale,o=e[s]*r.scale):(o=e[s]*r.scale,c=o));break;case K.UNIFONT:s++,i=e[s++]<<8|e[s++],s--;break}if(i!==0)if(this.fontData.header.fontType===K.UNIFONT){const u=r.isPenDown;a=this.getScaledSubshapeAtInsertPoint(i,c,o,l,u),a!=null&&a.polylines.some(f=>f.length>=2)&&(r.polylines.push(...a.polylines.slice()),a.lastPoint&&(r.currentPoint=a.lastPoint.clone()),r.currentPolyline=[],r.isPenDown&&r.currentPolyline.push(r.currentPoint.clone()))}else if(this.fontData.header.fontType===K.SHAPES)a=this.getScaledSubshapeAtInsertPoint(i,c,o,l),a&&(r.polylines.push(...a.polylines.slice()),a.lastPoint&&(r.currentPoint=a.lastPoint.clone(),a.hasExplicitAdvance&&this.markAdvanceDefined(r))),r.currentPolyline=[],r.isPenDown&&r.currentPolyline.push(r.currentPoint.clone());else{if(a=this.getScaledSubshapeAtInsertPoint(i,c,o,l),a&&(r.polylines.push(...a.polylines.slice()),i===2&&a.lastPoint)){const u=a.lastPoint.x-l.x;u>r.currentPoint.x&&(r.currentPoint.x=u),this.markAdvanceDefined(r)}r.currentPolyline=[]}return s}handleXYDisplacement(e,n,r){let s=n;const i=new se;return i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]),r.currentPoint.add(i.multiply(r.scale)),r.isPenDown?r.currentPolyline.push(r.currentPoint.clone()):this.notePenUpPositioning(r),s}handleMultipleXYDisplacements(e,n,r){let s=n;for(;!(s+1>=e.length);){const i=new se;if(i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]),i.x===0&&i.y===0)break;r.currentPoint.add(i.multiply(r.scale)),r.isPenDown?r.currentPolyline.push(r.currentPoint.clone()):this.notePenUpPositioning(r)}return s}handleOctantArc(e,n,r){let s=n;const i=e[++s]*r.scale,a=ke.byteToSByte(e[++s]),o=(a&112)>>4;let c=a&7;const l=a<0,u=Math.PI/4*o,f=r.currentPoint.clone().subtract(new se(Math.cos(u)*i,Math.sin(u)*i)),h=jt.fromOctant(f,i,o,c,l).tessellate();return r.isPenDown&&(r.currentPolyline.pop(),r.currentPolyline.push(...h.slice())),r.currentPoint=h[h.length-1].clone(),s}handleFractionalArc(e,n,r){let s=n;const i=e[++s],a=e[++s],o=e[++s],c=e[++s],l=(o*255+c)*r.scale,u=ke.byteToSByte(e[++s]),f=(u&112)>>4;let h=u&7;h===0&&(h=8),a!==0&&h--;const p=Math.PI/4;let y=p*h,m=dc,b=1;u<0&&(m=-m,y=-y,b=-1);let v=p*f,w=v+y;v+=p*i/256*b,w+=p*a/256*b;const T=r.currentPoint.clone().subtract(new se(l*Math.cos(v),l*Math.sin(v)));if(r.currentPoint=T.clone().add(new se(l*Math.cos(w),l*Math.sin(w))),r.isPenDown){let C=v;const E=[];if(E.push(T.clone().add(new se(l*Math.cos(C),l*Math.sin(C)))),m>0)for(;C+m<w;)C+=m,E.push(T.clone().add(new se(l*Math.cos(C),l*Math.sin(C))));else for(;C+m>w;)C+=m,E.push(T.clone().add(new se(l*Math.cos(C),l*Math.sin(C))));E.push(T.clone().add(new se(l*Math.cos(w),l*Math.sin(w)))),r.currentPolyline.push(...E)}return s}handleBulgeArc(e,n,r){let s=n;const i=new se;i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]);const a=ke.byteToSByte(e[++s]);return r.currentPoint=this.handleArcSegment(r.currentPoint,i,a,r.scale,r.isPenDown,r.currentPolyline),s}handleMultipleBulgeArcs(e,n,r){let s=n;for(;!(s+1>=e.length);){const i=new se;if(i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]),i.x===0&&i.y===0||s+1>=e.length)break;const a=ke.byteToSByte(e[++s]);r.currentPoint=this.handleArcSegment(r.currentPoint,i,a,r.scale,r.isPenDown,r.currentPolyline)}return s}skipCode(e,n){switch(e[n]){case 0:break;case 1:break;case 2:break;case 3:case 4:n++;break;case 5:break;case 6:break;case 7:switch(this.fontData.header.fontType){case K.SHAPES:n++;break;case K.BIGFONT:n++,this.isVerticalDualBigfontMarker(e,n,"open")?n++:this.isVerticalDualBigfontMarker(e,n,"close")?n+=2:e[n]===0&&(n+=this.fontData.content.isExtended?6:5);break;case K.UNIFONT:n+=2;break}break;case 8:n+=2;break;case 9:for(;n++,!(n>=e.length);){const r=e[n];if(n++,n>=e.length)break;const s=e[n];if(r===0&&s===0)break}break;case 10:n+=2;break;case 11:n+=5;break;case 12:n+=3;break;case 13:for(;n++,!(n>=e.length);){const r=e[n];if(n++,n>=e.length)break;const s=e[n];if(r===0&&s===0)break;n++}break}return n}getScaledSubshapeAtInsertPoint(e,n,r,s,i=!1){let a;if(i){const l=this.fontData.content.data[e];if(!l)return;a=this.parseShape(l,{initialPenDown:!0,flushOnEnd:!0})}else if(a=this.subshapeCache.get(e),!a){const l=this.fontData.content.data[e];if(!l)return;const u=this.fontData.header.fontType!==K.BIGFONT;a=this.parseShape(l,{flushOnEnd:!1,initialPenDown:u}),this.shapeData.set(e,a),this.subshapeCache.set(e,a)}const o=this.fontData.header.fontType===K.BIGFONT?void 0:r/this.fontData.content.baseUp,c=a.polylines.some(l=>l.length>0);return(o!==void 0?this.scaleShapeByFactor(a,o):this.scaleShapeByHeightAndWidth(c?a.normalizeToOrigin(!0):a,r,n)).offset(s,!1)}handleArcSegment(e,n,r,s,i,a){n.x*=s,n.y*=s,r<-127&&(r=-127);const o=e.clone();if(i)if(r===0)a.push(o.clone().add(n));else{const c=o.clone().add(n),l=jt.fromBulge(o,c,r/127).tessellate();a.push(...l.slice(1))}return o.add(n),o}}class Ms{constructor(e){if(e instanceof ArrayBuffer){const n=new ke(e),r=new Yo().parse(n),s=Qo.createParser(r.fontType).parse(n);this.fontData={header:r,content:s}}else this.fontData=e;this.shapeParser=new mc(this.fontData)}hasChar(e){return this.fontData.content.data[e]!==void 0}hasShape(e){return this.getShapeCode(e)!==void 0}getShapeCode(e){const n=this.fontData.content.names;if(n)return n[e.toUpperCase()]}getShapeName(e){var n;const r=(n=this.fontData.content.codeToName)==null?void 0:n[e];if(r!==void 0)return r;const s=this.fontData.content.names;if(s){for(const[i,a]of Object.entries(s))if(a===e)return i}}getFontMetrics(e){return fn(this.fontData.content,e)}getLayoutCharShape(e,n,r=hn){const s=this.getCharShape(e,n);if(s)return pc(s,this.fontData,n,r,this.usesUnifontBaselineOriginFont(n),this.getBigfontBaselineInkPaddingNative())}getBigfontBaselineInkPaddingNative(){if(this.bigfontBaselineInkPaddingNative===void 0){const e=this.fontData.content.height;this.bigfontBaselineInkPaddingNative=uc(this.fontData,n=>this.getCharShape(n,e))}return this.bigfontBaselineInkPaddingNative}usesUnifontBaselineOriginFont(e){return this.unifontBaselineOriginFont===void 0&&(this.unifontBaselineOriginFont=hc(this.fontData,n=>this.getCharShape(n,e),e)),this.unifontBaselineOriginFont}getShapeByName(e,n){const r=this.getShapeCode(e);if(r!==void 0)return this.getCharShape(r,n)}getCharShape(e,n){return this.shapeParser.getCharShape(e,n)}release(){this.shapeParser.release()}}function yc(t,e,n,r=hn){const s=fn(e.content,n);return r.resolve(t,s.cellWidth)}const nr=(t,e)=>e.some(n=>t instanceof n);let Rs,Bs;function bc(){return Rs||(Rs=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function xc(){return Bs||(Bs=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const rr=new WeakMap,sr=new WeakMap,pn=new WeakMap;function vc(t){const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("success",i),t.removeEventListener("error",a)},i=()=>{n(bt(t.result)),s()},a=()=>{r(t.error),s()};t.addEventListener("success",i),t.addEventListener("error",a)});return pn.set(e,t),e}function Sc(t){if(rr.has(t))return;const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",a),t.removeEventListener("abort",a)},i=()=>{n(),s()},a=()=>{r(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",i),t.addEventListener("error",a),t.addEventListener("abort",a)});rr.set(t,e)}let ir={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return rr.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return bt(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function Ds(t){ir=t(ir)}function wc(t){return xc().includes(t)?function(...e){return t.apply(ar(this),e),bt(this.request)}:function(...e){return bt(t.apply(ar(this),e))}}function Tc(t){return typeof t=="function"?wc(t):(t instanceof IDBTransaction&&Sc(t),nr(t,bc())?new Proxy(t,ir):t)}function bt(t){if(t instanceof IDBRequest)return vc(t);if(sr.has(t))return sr.get(t);const e=Tc(t);return e!==t&&(sr.set(t,e),pn.set(e,t)),e}const ar=t=>pn.get(t);function Cc(t,e,{blocked:n,upgrade:r,blocking:s,terminated:i}={}){const a=indexedDB.open(t,e),o=bt(a);return r&&a.addEventListener("upgradeneeded",c=>{r(bt(a.result),c.oldVersion,c.newVersion,bt(a.transaction),c)}),n&&a.addEventListener("blocked",c=>n(c.oldVersion,c.newVersion,c)),o.then(c=>{i&&c.addEventListener("close",()=>i()),s&&c.addEventListener("versionchange",l=>s(l.oldVersion,l.newVersion,l))}).catch(()=>{}),o}const kc=["get","getKey","getAll","getAllKeys","count"],Fc=["put","add","delete","clear"],or=new Map;function _s(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(or.get(e))return or.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,s=Fc.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(s||kc.includes(n)))return;const i=async function(a,...o){const c=this.transaction(a,s?"readwrite":"readonly");let l=c.store;return r&&(l=l.index(o.shift())),(await Promise.all([l[n](...o),s&&c.done]))[0]};return or.set(e,i),i}Ds(t=>({...t,get:(e,n,r)=>_s(e,n)||t.get(e,n,r),has:(e,n)=>!!_s(e,n)||t.has(e,n)}));const Ec=["continue","continuePrimaryKey","advance"],Us={},cr=new WeakMap,Ps=new WeakMap,Ac={get(t,e){if(!Ec.includes(e))return t[e];let n=Us[e];return n||(n=Us[e]=function(...r){cr.set(this,Ps.get(this)[e](...r))}),n}};async function*Oc(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;const n=new Proxy(e,Ac);for(Ps.set(n,e),pn.set(n,ar(e));e;)yield n,e=await(cr.get(n)||e.continue()),cr.delete(n)}function Ns(t,e){return e===Symbol.asyncIterator&&nr(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&nr(t,[IDBIndex,IDBObjectStore])}Ds(t=>({...t,get(e,n,r){return Ns(e,n)?Oc:t.get(e,n,r)},has(e,n){return Ns(e,n)||t.has(e,n)}}));const xt={fonts:"fonts"},lr=[{version:1,stores:[{name:xt.fonts,keyPath:"name"}]},{version:2,stores:[{name:xt.fonts,keyPath:"name"}]}],De=class De{constructor(){this.isClosing=!1,typeof window<"u"&&window.addEventListener("pagehide",e=>{e.persisted||this.close()})}static get instance(){return De._instance||(De._instance=new De),De._instance}async set(e,n){await(await this.getDatabase()).put(xt.fonts,{...n,name:e})}async get(e){return await(await this.getDatabase()).get(xt.fonts,e)}async find(e){const n=ct(e).toLowerCase(),r=await this.get(n);return r||(await this.getAll()).find(i=>{var a;return i.name===n||((a=i.alias)==null?void 0:a.some(o=>o.toLowerCase()===n))})}async delete(e){await(await this.getDatabase()).delete(xt.fonts,e)}async getAll(){return await(await this.getDatabase()).getAll(xt.fonts)}async getStorageStats(){const n=(await this.getAll()).map(s=>({name:s.name,type:s.type,bytes:Jn(s.data)})),r=n.reduce((s,i)=>s+i.bytes,0);return{fontCount:n.length,totalBytes:r,fonts:n}}async clear(){await(await this.getDatabase()).clear(xt.fonts)}async has(e){return await this.get(e)!==void 0}close(){if(!this.isClosing){this.isClosing=!0;try{this.db&&(this.db.close(),this.db=void 0)}finally{this.isClosing=!1}}}async destroy(){this.close(),await indexedDB.deleteDatabase(De.DATABASE_NAME),De._instance=void 0}async getDatabase(){if(this.isClosing)throw new Error("Cannot perform operation while database is closing");return this.db?this.db:(this.db=await Cc(De.DATABASE_NAME,De.DATABASE_VERSION,{upgrade:(e,n,r)=>this.handleUpgrade(e,n,r),blocked(){console.warn("Database upgrade blocked - please close other tabs using the application")},blocking(){console.warn("Database blocking newer version - closing connection"),De.instance.close()}}),this.db)}handleUpgrade(e,n,r){const s=lr.filter(i=>i.version>n&&(!r||i.version<=r));for(const i of s)this.applySchemaVersion(e,i)}applySchemaVersion(e,n){for(const r of n.stores)e.objectStoreNames.contains(r.name)||e.createObjectStore(r.name,{keyPath:r.keyPath})}};De.DATABASE_NAME="mlightcad",De.DATABASE_VERSION=lr[lr.length-1].version;let Qe=De;const Gs=512;function Hs(t,e){return(t+e)*Gs}const zs=2.5,Ws=1.5;function ur(){return{meshCount:0,lineCount:0,estimatedBytes:0}}const dn={minimal:["txt","simsun"],r12r14:["txt","simplex","romans","gbcbig","simsun"],modern:["simsun","hztxt"],international:["txt","simplex","romans","simsun"],cjk:["simsun","malgun","msgothic","gbcbig","hztxt","extfont2","extfont","whgtxt","whgdtxt"],chinese:["simsun","gbcbig","hztxt"],korean:["malgun","whgtxt","whgdtxt"],japanese:["msgothic","extfont2","extfont"]},gn={minimal:["simplex","amgdt"],r12r14:["simplex","amgdt"],modern:["simplex","amgdt"],international:["simplex","amgdt"],cjk:["simplex","amgdt"],chinese:["simplex","amgdt"],korean:["simplex","amgdt"],japanese:["simplex","amgdt"]};function hr(t){return Object.prototype.hasOwnProperty.call(dn,t)}var fr=0,Vs=-3;function qt(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Lc(t,e){this.source=t,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new qt,this.dtree=new qt}var js=new qt,qs=new qt,pr=new Uint8Array(30),dr=new Uint16Array(30),$s=new Uint8Array(30),Ys=new Uint16Array(30),Ic=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xs=new qt,$e=new Uint8Array(320);function Ks(t,e,n,r){var s,i;for(s=0;s<n;++s)t[s]=0;for(s=0;s<30-n;++s)t[s+n]=s/n|0;for(i=r,s=0;s<30;++s)e[s]=i,i+=1<<t[s]}function Mc(t,e){var n;for(n=0;n<7;++n)t.table[n]=0;for(t.table[7]=24,t.table[8]=152,t.table[9]=112,n=0;n<24;++n)t.trans[n]=256+n;for(n=0;n<144;++n)t.trans[24+n]=n;for(n=0;n<8;++n)t.trans[168+n]=280+n;for(n=0;n<112;++n)t.trans[176+n]=144+n;for(n=0;n<5;++n)e.table[n]=0;for(e.table[5]=32,n=0;n<32;++n)e.trans[n]=n}var Zs=new Uint16Array(16);function gr(t,e,n,r){var s,i;for(s=0;s<16;++s)t.table[s]=0;for(s=0;s<r;++s)t.table[e[n+s]]++;for(t.table[0]=0,i=0,s=0;s<16;++s)Zs[s]=i,i+=t.table[s];for(s=0;s<r;++s)e[n+s]&&(t.trans[Zs[e[n+s]]++]=s)}function Rc(t){t.bitcount--||(t.tag=t.source[t.sourceIndex++],t.bitcount=7);var e=t.tag&1;return t.tag>>>=1,e}function Ye(t,e,n){if(!e)return n;for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var r=t.tag&65535>>>16-e;return t.tag>>>=e,t.bitcount-=e,r+n}function mr(t,e){for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var n=0,r=0,s=0,i=t.tag;do r=2*r+(i&1),i>>>=1,++s,n+=e.table[s],r-=e.table[s];while(r>=0);return t.tag=i,t.bitcount-=s,e.trans[n+r]}function Bc(t,e,n){var r,s,i,a,o,c;for(r=Ye(t,5,257),s=Ye(t,5,1),i=Ye(t,4,4),a=0;a<19;++a)$e[a]=0;for(a=0;a<i;++a){var l=Ye(t,3,0);$e[Ic[a]]=l}for(gr(Xs,$e,0,19),o=0;o<r+s;){var u=mr(t,Xs);switch(u){case 16:var f=$e[o-1];for(c=Ye(t,2,3);c;--c)$e[o++]=f;break;case 17:for(c=Ye(t,3,3);c;--c)$e[o++]=0;break;case 18:for(c=Ye(t,7,11);c;--c)$e[o++]=0;break;default:$e[o++]=u;break}}gr(e,$e,0,r),gr(n,$e,r,s)}function Js(t,e,n){for(;;){var r=mr(t,e);if(r===256)return fr;if(r<256)t.dest[t.destLen++]=r;else{var s,i,a,o;for(r-=257,s=Ye(t,pr[r],dr[r]),i=mr(t,n),a=t.destLen-Ye(t,$s[i],Ys[i]),o=a;o<a+s;++o)t.dest[t.destLen++]=t.dest[o]}}}function Dc(t){for(var e,n,r;t.bitcount>8;)t.sourceIndex--,t.bitcount-=8;if(e=t.source[t.sourceIndex+1],e=256*e+t.source[t.sourceIndex],n=t.source[t.sourceIndex+3],n=256*n+t.source[t.sourceIndex+2],e!==(~n&65535))return Vs;for(t.sourceIndex+=4,r=e;r;--r)t.dest[t.destLen++]=t.source[t.sourceIndex++];return t.bitcount=0,fr}function Qs(t,e){var n=new Lc(t,e),r,s,i;do{switch(r=Rc(n),s=Ye(n,2,0),s){case 0:i=Dc(n);break;case 1:i=Js(n,js,qs);break;case 2:Bc(n,n.ltree,n.dtree),i=Js(n,n.ltree,n.dtree);break;default:i=Vs}if(i!==fr)throw new Error("Data error")}while(!r);return n.destLen<n.dest.length?typeof n.dest.slice=="function"?n.dest.slice(0,n.destLen):n.dest.subarray(0,n.destLen):n.dest}Mc(js,qs),Ks(pr,dr,4,3),Ks($s,Ys,2,1),pr[28]=0,dr[28]=258;function Ot(t,e,n,r,s){return Math.pow(1-s,3)*t+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*n+Math.pow(s,3)*r}function vt(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}vt.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},vt.prototype.addPoint=function(t,e){typeof t=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))},vt.prototype.addX=function(t){this.addPoint(t,null)},vt.prototype.addY=function(t){this.addPoint(null,t)},vt.prototype.addBezier=function(t,e,n,r,s,i,a,o){const c=[t,e],l=[n,r],u=[s,i],f=[a,o];this.addPoint(t,e),this.addPoint(a,o);for(let h=0;h<=1;h++){const p=6*c[h]-12*l[h]+6*u[h],y=-3*c[h]+9*l[h]-9*u[h]+3*f[h],m=3*l[h]-3*c[h];if(y===0){if(p===0)continue;const T=-m/p;0<T&&T<1&&(h===0&&this.addX(Ot(c[h],l[h],u[h],f[h],T)),h===1&&this.addY(Ot(c[h],l[h],u[h],f[h],T)));continue}const b=Math.pow(p,2)-4*m*y;if(b<0)continue;const v=(-p+Math.sqrt(b))/(2*y);0<v&&v<1&&(h===0&&this.addX(Ot(c[h],l[h],u[h],f[h],v)),h===1&&this.addY(Ot(c[h],l[h],u[h],f[h],v)));const w=(-p-Math.sqrt(b))/(2*y);0<w&&w<1&&(h===0&&this.addX(Ot(c[h],l[h],u[h],f[h],w)),h===1&&this.addY(Ot(c[h],l[h],u[h],f[h],w)))}},vt.prototype.addQuad=function(t,e,n,r,s,i){const a=t+.6666666666666666*(n-t),o=e+2/3*(r-e),c=a+1/3*(s-t),l=o+1/3*(i-e);this.addBezier(t,e,a,o,c,l,s,i)};var ei=vt;function pe(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var $t={};function ti(t,e){const n=Math.floor(t),r=t-n;if($t[e]||($t[e]={}),$t[e][r]!==void 0){const i=$t[e][r];return n+i}const s=+(Math.round(r+"e+"+e)+"e-"+e);return $t[e][r]=s,n+s}function ni(t){let e=[[]],n=0,r=0;for(let s=0;s<t.length;s+=1){const i=e[e.length-1],a=t[s],o=i[0],c=i[1],l=i[i.length-1],u=t[s+1];i.push(a),a.type==="M"?(n=a.x,r=a.y):a.type==="L"&&(!u||u.type==="Z")?Math.abs(a.x-n)>1||Math.abs(a.y-r)>1||i.pop():a.type==="L"&&l&&l.x===a.x&&l.y===a.y?i.pop():a.type==="Z"&&(o&&c&&l&&o.type==="M"&&c.type==="L"&&l.type==="L"&&l.x===o.x&&l.y===o.y&&(i.shift(),i[0].type="M"),s+1<t.length&&e.push([]))}return t=[].concat.apply([],e),t}function _c(t){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},t)}function Uc(t){return parseInt(t)===t&&(t={decimalPlaces:t,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},t)}pe.prototype.fromSVG=function(t,e={}){typeof SVGPathElement<"u"&&t instanceof SVGPathElement&&(t=t.getAttribute("d")),e=_c(e),this.commands=[];const n="0123456789",r="MmLlQqCcZzHhVv",s="SsTtAa",i="-+";let a={},o=[""],c=!1;function l(y){return y.filter(m=>m.length).map(m=>{let b=parseFloat(m);return(e.decimalPlaces||e.decimalPlaces===0)&&(b=ti(b,e.decimalPlaces)),b})}function u(y){if(!this.commands.length)return y;const m=this.commands[this.commands.length-1];for(let b=0;b<y.length;b++)y[b]+=m[b&1?"y":"x"];return y}function f(){if(a.type===void 0)return;const y=a.type.toUpperCase(),m=y!=="Z"&&a.type.toUpperCase()!==a.type;let b=l(o);if(o=[""],!b.length&&y!=="Z")return;m&&y!=="H"&&y!=="V"&&(b=u.apply(this,[b]));const v=this.commands.length&&this.commands[this.commands.length-1].x||0,w=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(y){case"M":this.moveTo(...b);break;case"L":this.lineTo(...b);break;case"V":for(let T=0;T<b.length;T++){let C=0;m&&(C=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(v,b[T]+C)}break;case"H":for(let T=0;T<b.length;T++){let C=0;m&&(C=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(b[T]+C,w)}break;case"C":this.bezierCurveTo(...b);break;case"Q":this.quadraticCurveTo(...b);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(const T in this.commands[this.commands.length-1])this.commands[this.commands.length-1][T]===void 0&&(this.commands[this.commands.length-1][T]=0)}for(let y=0;y<t.length;y++){const m=t.charAt(y),b=o[o.length-1];if(n.indexOf(m)>-1)o[o.length-1]+=m;else if(i.indexOf(m)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),m==="-")!a.type||b.indexOf("-")>0?c=!0:b.length?o.push("-"):o[o.length-1]=m;else if(!a.type||b.length>0)c=!0;else continue;else if(r.indexOf(m)>-1)a.type?(f.apply(this),a={type:m}):a.type=m;else{if(s.indexOf(m)>-1)throw new Error("Unsupported path command: "+m+". Currently supported commands are "+r.split("").join(", ")+".");` ,
|
|
2
2
|
\r\f\v`.indexOf(m)>-1?o.push(""):m==="."?!a.type||b.indexOf(m)>-1?c=!0:o[o.length-1]+=m:c=!0}if(c)throw new Error("Unexpected character: "+m+" at offset "+y)}f.apply(this),e.optimize&&(this.commands=ni(this.commands));const h=e.flipY;let p=e.flipYBase;if(h===!0&&e.flipYBase===void 0){const y=this.getBoundingBox();p=y.y1+y.y2}for(const y in this.commands){const m=this.commands[y];for(const b in m)["x","x1","x2"].includes(b)?this.commands[y][b]=e.x+m[b]*e.scale:["y","y1","y2"].includes(b)&&(this.commands[y][b]=e.y+(h?p-m[b]:m[b])*e.scale)}return this},pe.fromSVG=function(t,e){return new pe().fromSVG(t,e)},pe.prototype.moveTo=function(t,e){this.commands.push({type:"M",x:t,y:e})},pe.prototype.lineTo=function(t,e){this.commands.push({type:"L",x:t,y:e})},pe.prototype.curveTo=pe.prototype.bezierCurveTo=function(t,e,n,r,s,i){this.commands.push({type:"C",x1:t,y1:e,x2:n,y2:r,x:s,y:i})},pe.prototype.quadTo=pe.prototype.quadraticCurveTo=function(t,e,n,r){this.commands.push({type:"Q",x1:t,y1:e,x:n,y:r})},pe.prototype.close=pe.prototype.closePath=function(){this.commands.push({type:"Z"})},pe.prototype.extend=function(t){if(t.commands)t=t.commands;else if(t instanceof ei){const e=t;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,t)},pe.prototype.getBoundingBox=function(){const t=new ei;let e=0,n=0,r=0,s=0;for(let i=0;i<this.commands.length;i++){const a=this.commands[i];switch(a.type){case"M":t.addPoint(a.x,a.y),e=r=a.x,n=s=a.y;break;case"L":t.addPoint(a.x,a.y),r=a.x,s=a.y;break;case"Q":t.addQuad(r,s,a.x1,a.y1,a.x,a.y),r=a.x,s=a.y;break;case"C":t.addBezier(r,s,a.x1,a.y1,a.x2,a.y2,a.x,a.y),r=a.x,s=a.y;break;case"Z":r=e,s=n;break;default:throw new Error("Unexpected path command "+a.type)}}return t.isEmpty()&&t.addPoint(0,0),t},pe.prototype.draw=function(t){const e=this._layers;if(e&&e.length){for(let r=0;r<e.length;r++)this.draw.call(e[r],t);return}const n=this._image;if(n){t.drawImage(n.image,n.x,n.y,n.width,n.height);return}t.beginPath();for(let r=0;r<this.commands.length;r+=1){const s=this.commands[r];s.type==="M"?t.moveTo(s.x,s.y):s.type==="L"?t.lineTo(s.x,s.y):s.type==="C"?t.bezierCurveTo(s.x1,s.y1,s.x2,s.y2,s.x,s.y):s.type==="Q"?t.quadraticCurveTo(s.x1,s.y1,s.x,s.y):s.type==="Z"&&this.stroke&&this.strokeWidth&&t.closePath()}this.fill&&(t.fillStyle=this.fill,t.fill()),this.stroke&&(t.strokeStyle=this.stroke,t.lineWidth=this.strokeWidth,t.stroke())},pe.prototype.toPathData=function(t){t=Uc(t);function e(o){const c=ti(o,t.decimalPlaces);return Math.round(o)===c?""+c:c.toFixed(t.decimalPlaces)}function n(){let o="";for(let c=0;c<arguments.length;c+=1){const l=arguments[c];l>=0&&c>0&&(o+=" "),o+=e(l)}return o}let r=this.commands;t.optimize&&(r=JSON.parse(JSON.stringify(this.commands)),r=ni(r));const s=t.flipY;let i=t.flipYBase;if(s===!0&&i===void 0){const o=new pe;o.extend(r);const c=o.getBoundingBox();i=c.y1+c.y2}let a="";for(let o=0;o<r.length;o+=1){const c=r[o];c.type==="M"?a+="M"+n(c.x,s?i-c.y:c.y):c.type==="L"?a+="L"+n(c.x,s?i-c.y:c.y):c.type==="C"?a+="C"+n(c.x1,s?i-c.y1:c.y1,c.x2,s?i-c.y2:c.y2,c.x,s?i-c.y:c.y):c.type==="Q"?a+="Q"+n(c.x1,s?i-c.y1:c.y1,c.x,s?i-c.y:c.y):c.type==="Z"&&(a+="Z")}return a},pe.prototype.toSVG=function(t,e){this._layers&&this._layers.length&&console.warn("toSVG() does not support colr font layers yet"),this._image&&console.warn("toSVG() does not support SVG glyphs yet"),e||(e=this.toPathData(t));let n='<path d="';return n+=e,n+='"',this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?n+=' fill="none"':n+=' fill="'+this.fill+'"'),this.stroke&&(n+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),n+="/>",n},pe.prototype.toDOMElement=function(t,e){this._layers&&this._layers.length&&console.warn("toDOMElement() does not support colr font layers yet"),e||(e=this.toPathData(t));const n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",e),this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?n.setAttribute("fill","none"):n.setAttribute("fill",this.fill)),this.stroke&&(n.setAttribute("stroke",this.stroke),n.setAttribute("stroke-width",this.strokeWidth)),n};var Lt=pe;function ri(t){throw new Error(t)}function si(t,e){t||ri(e)}var z={fail:ri,argument:si,assert:si},ii=32768,ai=2147483648,Pc=-32768,Nc=32767+1/65536,It={},B={},W={};function ze(t){return function(){return t}}B.BYTE=function(t){return z.argument(t>=0&&t<=255,"Byte value should be between 0 and 255."),[t]},W.BYTE=ze(1),B.CHAR=function(t){return[t.charCodeAt(0)]},W.CHAR=ze(1),B.CHARARRAY=function(t){(t===null||typeof t>"u")&&(t="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let n=0;n<t.length;n+=1)e[n]=t.charCodeAt(n);return e},W.CHARARRAY=function(t){return typeof t>"u"?0:t.length},B.USHORT=function(t){return[t>>8&255,t&255]},W.USHORT=ze(2),B.SHORT=function(t){return t>=ii&&(t=-(2*ii-t)),[t>>8&255,t&255]},W.SHORT=ze(2),B.UINT24=function(t){return[t>>16&255,t>>8&255,t&255]},W.UINT24=ze(3),B.ULONG=function(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]},W.ULONG=ze(4),B.LONG=function(t){return t>=ai&&(t=-(2*ai-t)),[t>>24&255,t>>16&255,t>>8&255,t&255]},W.LONG=ze(4),B.FLOAT=function(t){if(t>Nc||t<Pc)throw new Error(`Value ${t} is outside the range of representable values in 16.16 format`);const e=Math.round(t*65536)<<0;return B.ULONG(e)},W.FLOAT=W.ULONG,B.FIXED=B.ULONG,W.FIXED=W.ULONG,B.FWORD=B.SHORT,W.FWORD=W.SHORT,B.UFWORD=B.USHORT,W.UFWORD=W.USHORT,B.F2DOT14=function(t){return B.USHORT(t*16384)},W.F2DOT14=W.USHORT,B.LONGDATETIME=function(t){return[0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255]},W.LONGDATETIME=ze(8),B.TAG=function(t){return z.argument(t.length===4,"Tag should be exactly 4 ASCII characters."),[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]},W.TAG=ze(4),B.Card8=B.BYTE,W.Card8=W.BYTE,B.Card16=B.USHORT,W.Card16=W.USHORT,B.OffSize=B.BYTE,W.OffSize=W.BYTE,B.SID=B.USHORT,W.SID=W.USHORT,B.NUMBER=function(t){return t>=-107&&t<=107?[t+139]:t>=108&&t<=1131?(t=t-108,[(t>>8)+247,t&255]):t>=-1131&&t<=-108?(t=-t-108,[(t>>8)+251,t&255]):t>=-32768&&t<=32767?B.NUMBER16(t):B.NUMBER32(t)},W.NUMBER=function(t){return B.NUMBER(t).length},B.NUMBER16=function(t){return[28,t>>8&255,t&255]},W.NUMBER16=ze(3),B.NUMBER32=function(t){return[29,t>>24&255,t>>16&255,t>>8&255,t&255]},W.NUMBER32=ze(5),B.REAL=function(t){let e=t.toString();const n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(n){const i=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));e=(Math.round(t*i)/i).toString()}let r="";for(let i=0,a=e.length;i<a;i+=1){const o=e[i];o==="e"?r+=e[++i]==="-"?"c":"b":o==="."?r+="a":o==="-"?r+="e":r+=o}r+=r.length&1?"f":"ff";const s=[30];for(let i=0,a=r.length;i<a;i+=2)s.push(parseInt(r.substr(i,2),16));return s},W.REAL=function(t){return B.REAL(t).length},B.NAME=B.CHARARRAY,W.NAME=W.CHARARRAY,B.STRING=B.CHARARRAY,W.STRING=W.CHARARRAY,It.UTF8=function(t,e,n){const r=[],s=n;for(let i=0;i<s;i++,e+=1)r[i]=t.getUint8(e);return String.fromCharCode.apply(null,r)},It.UTF16=function(t,e,n){const r=[],s=n/2;for(let i=0;i<s;i++,e+=2)r[i]=t.getUint16(e);return String.fromCharCode.apply(null,r)},B.UTF16=function(t){const e=[];for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);e[e.length]=r>>8&255,e[e.length]=r&255}return e},W.UTF16=function(t){return t.length*2};var mn={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};It.MACSTRING=function(t,e,n,r){const s=mn[r];if(s===void 0)return;let i="";for(let a=0;a<n;a++){const o=t.getUint8(e+a);o<=127?i+=String.fromCharCode(o):i+=s[o&127]}return i};var yn=typeof WeakMap=="function"&&new WeakMap,bn,Gc=function(t){if(!bn){bn={};for(let s in mn)bn[s]=new String(s)}const e=bn[t];if(e===void 0)return;if(yn){const s=yn.get(e);if(s!==void 0)return s}const n=mn[t];if(n===void 0)return;const r={};for(let s=0;s<n.length;s++)r[n.charCodeAt(s)]=s+128;return yn&&yn.set(e,r),r};B.MACSTRING=function(t,e){const n=Gc(e);if(n===void 0)return;const r=[];for(let s=0;s<t.length;s++){let i=t.charCodeAt(s);if(i>=128&&(i=n[i],i===void 0))return;r[s]=i}return r},W.MACSTRING=function(t,e){const n=B.MACSTRING(t,e);return n!==void 0?n.length:0};function yr(t){return t>=-128&&t<=127}function Hc(t,e,n){let r=0;const s=t.length;for(;e<s&&r<64&&t[e]===0;)++e,++r;return n.push(128|r-1),e}function zc(t,e,n){let r=0;const s=t.length;let i=e;for(;i<s&&r<64;){const a=t[i];if(!yr(a)||a===0&&i+1<s&&t[i+1]===0)break;++i,++r}n.push(r-1);for(let a=e;a<i;++a)n.push(t[a]+256&255);return i}function Wc(t,e,n){let r=0;const s=t.length;let i=e;for(;i<s&&r<64;){const a=t[i];if(a===0||yr(a)&&i+1<s&&yr(t[i+1]))break;++i,++r}n.push(64|r-1);for(let a=e;a<i;++a){const o=t[a];n.push(o+65536>>8&255,o+256&255)}return i}B.VARDELTAS=function(t){let e=0;const n=[];for(;e<t.length;){const r=t[e];r===0?e=Hc(t,e,n):r>=-128&&r<=127?e=zc(t,e,n):e=Wc(t,e,n)}return n},B.INDEX=function(t){let e=1;const n=[e],r=[];for(let o=0;o<t.length;o+=1){const c=B.OBJECT(t[o]);Array.prototype.push.apply(r,c),e+=c.length,n.push(e)}if(r.length===0)return[0,0];const s=[],i=1+Math.floor(Math.log(e)/Math.log(2))/8|0,a=[void 0,B.BYTE,B.USHORT,B.UINT24,B.ULONG][i];for(let o=0;o<n.length;o+=1){const c=a(n[o]);Array.prototype.push.apply(s,c)}return Array.prototype.concat(B.Card16(t.length),B.OffSize(i),s,r)},W.INDEX=function(t){return B.INDEX(t).length},B.DICT=function(t){let e=[];const n=Object.keys(t),r=n.length;for(let s=0;s<r;s+=1){const i=parseInt(n[s],0),a=t[i],o=B.OPERAND(a.value,a.type),c=B.OPERATOR(i);for(let l=0;l<o.length;l++)e.push(o[l]);for(let l=0;l<c.length;l++)e.push(c[l])}return e},W.DICT=function(t){return B.DICT(t).length},B.OPERATOR=function(t){return t<1200?[t]:[12,t-1200]},B.OPERAND=function(t,e){let n=[];if(Array.isArray(e))for(let r=0;r<e.length;r+=1){z.argument(t.length===e.length,"Not enough arguments given for type"+e);const s=B.OPERAND(t[r],e[r]);for(let i=0;i<s.length;i++)n.push(s[i])}else if(e==="SID"){const r=B.NUMBER(t);for(let s=0;s<r.length;s++)n.push(r[s])}else if(e==="offset"){const r=B.NUMBER32(t);for(let s=0;s<r.length;s++)n.push(r[s])}else if(e==="number"){const r=B.NUMBER(t);for(let s=0;s<r.length;s++)n.push(r[s])}else if(e==="real"){const r=B.REAL(t);for(let s=0;s<r.length;s++)n.push(r[s])}else throw new Error("Unknown operand type "+e);return n},B.OP=B.BYTE,W.OP=W.BYTE;var xn=typeof WeakMap=="function"&&new WeakMap;B.CHARSTRING=function(t){if(xn){const r=xn.get(t);if(r!==void 0)return r}let e=[];const n=t.length;for(let r=0;r<n;r+=1){const s=t[r],i=B[s.type](s.value);for(let a=0;a<i.length;a++)e.push(i[a])}return xn&&xn.set(t,e),e},W.CHARSTRING=function(t){return B.CHARSTRING(t).length},B.OBJECT=function(t){const e=B[t.type];return z.argument(e!==void 0,"No encoding function for type "+t.type),e(t.value)},W.OBJECT=function(t){const e=W[t.type];return z.argument(e!==void 0,"No sizeOf function for type "+t.type),e(t.value)},B.TABLE=function(t){let e=[];const n=(t.fields||[]).length,r=[],s=[];for(let i=0;i<n;i+=1){const a=t.fields[i],o=B[a.type];z.argument(o!==void 0,"No encoding function for field type "+a.type+" ("+a.name+")");let c=t[a.name];c===void 0&&(c=a.value);const l=o(c);if(a.type==="TABLE")c.fields!==null&&(s.push(e.length),r.push(l)),e.push(0,0);else for(let u=0;u<l.length;u++)e.push(l[u])}for(let i=0;i<r.length;i+=1){const a=s[i],o=e.length;z.argument(o<65536,"Table "+t.tableName+" too big."),e[a]=o>>8,e[a+1]=o&255;for(let c=0;c<r[i].length;c++)e.push(r[i][c])}return e},W.TABLE=function(t){let e=0;const n=(t.fields||[]).length;for(let r=0;r<n;r+=1){const s=t.fields[r],i=W[s.type];z.argument(i!==void 0,"No sizeOf function for field type "+s.type+" ("+s.name+")");let a=t[s.name];a===void 0&&(a=s.value),e+=i(a),s.type==="TABLE"&&(e+=2)}return e},B.RECORD=B.TABLE,W.RECORD=W.TABLE,B.LITERAL=function(t){return t},W.LITERAL=function(t){return t.length};function fe(t,e,n){if(e&&e.length)for(let r=0;r<e.length;r+=1){const s=e[r];this[s.name]=s.value}if(this.tableName=t,this.fields=e,n){const r=Object.keys(n);for(let s=0;s<r.length;s+=1){const i=r[s],a=n[i];this[i]!==void 0&&(this[i]=a)}}}fe.prototype.encode=function(){return B.TABLE(this)},fe.prototype.sizeOf=function(){return W.TABLE(this)};function Mt(t,e,n){n===void 0&&(n=e.length);const r=new Array(e.length+1);r[0]={name:t+"Count",type:"USHORT",value:n};for(let s=0;s<e.length;s++)r[s+1]={name:t+s,type:"USHORT",value:e[s]};return r}function br(t,e,n){const r=e.length,s=new Array(r+1);s[0]={name:t+"Count",type:"USHORT",value:r};for(let i=0;i<r;i++)s[i+1]={name:t+i,type:"TABLE",value:n(e[i],i)};return s}function Rt(t,e,n){const r=e.length;let s=[];s[0]={name:t+"Count",type:"USHORT",value:r};for(let i=0;i<r;i++)s=s.concat(n(e[i],i));return s}function vn(t){t.format===1?fe.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(Mt("glyph",t.glyphs))):t.format===2?fe.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(Rt("rangeRecord",t.ranges,function(e,n){return[{name:"startGlyphID"+n,type:"USHORT",value:e.start},{name:"endGlyphID"+n,type:"USHORT",value:e.end},{name:"startCoverageIndex"+n,type:"USHORT",value:e.index}]}))):z.assert(!1,"Coverage format must be 1 or 2.")}vn.prototype=Object.create(fe.prototype),vn.prototype.constructor=vn;function Sn(t){fe.call(this,"scriptListTable",Rt("scriptRecord",t,function(e,n){const r=e.script;let s=r.defaultLangSys;return z.assert(!!s,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+n,type:"TAG",value:e.tag},{name:"script"+n,type:"TABLE",value:new fe("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new fe("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(Mt("featureIndex",s.featureIndexes)))}].concat(Rt("langSys",r.langSysRecords,function(i,a){const o=i.langSys;return[{name:"langSysTag"+a,type:"TAG",value:i.tag},{name:"langSys"+a,type:"TABLE",value:new fe("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:o.reqFeatureIndex}].concat(Mt("featureIndex",o.featureIndexes)))}]})))}]}))}Sn.prototype=Object.create(fe.prototype),Sn.prototype.constructor=Sn;function wn(t){fe.call(this,"featureListTable",Rt("featureRecord",t,function(e,n){const r=e.feature;return[{name:"featureTag"+n,type:"TAG",value:e.tag},{name:"feature"+n,type:"TABLE",value:new fe("featureTable",[{name:"featureParams",type:"USHORT",value:r.featureParams}].concat(Mt("lookupListIndex",r.lookupListIndexes)))}]}))}wn.prototype=Object.create(fe.prototype),wn.prototype.constructor=wn;function Tn(t,e){fe.call(this,"lookupListTable",br("lookup",t,function(n){let r=e[n.lookupType];return z.assert(!!r,"Unable to write GSUB lookup type "+n.lookupType+" tables."),new fe("lookupTable",[{name:"lookupType",type:"USHORT",value:n.lookupType},{name:"lookupFlag",type:"USHORT",value:n.lookupFlag}].concat(br("subtable",n.subtables,r)))}))}Tn.prototype=Object.create(fe.prototype),Tn.prototype.constructor=Tn;function Cn(t){t.format===1?fe.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:t.startGlyph}].concat(Mt("glyph",t.classes))):t.format===2?fe.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(Rt("rangeRecord",t.ranges,function(e,n){return[{name:"startGlyphID"+n,type:"USHORT",value:e.start},{name:"endGlyphID"+n,type:"USHORT",value:e.end},{name:"class"+n,type:"USHORT",value:e.classId}]}))):z.assert(!1,"Class format must be 1 or 2.")}Cn.prototype=Object.create(fe.prototype),Cn.prototype.constructor=Cn;var L={Table:fe,Record:fe,Coverage:vn,ClassDef:Cn,ScriptList:Sn,FeatureList:wn,LookupList:Tn,ushortList:Mt,tableList:br,recordList:Rt};function oi(t,e){return t.getUint8(e)}function kn(t,e){return t.getUint16(e,!1)}function Vc(t,e){return t.getInt16(e,!1)}function ci(t,e){return(t.getUint16(e)<<8)+t.getUint8(e+2)}function xr(t,e){return t.getUint32(e,!1)}function jc(t,e){return t.getInt32(e,!1)}function li(t,e){const n=t.getInt16(e,!1),r=t.getUint16(e+2,!1);return n+r/65535}function qc(t,e){let n="";for(let r=e;r<e+4;r+=1)n+=String.fromCharCode(t.getInt8(r));return n}function $c(t,e,n){let r=0;for(let s=0;s<n;s+=1)r<<=8,r+=t.getUint8(e+s);return r}function Yc(t,e,n){const r=[];for(let s=e;s<n;s+=1)r.push(t.getUint8(s));return r}function Xc(t){let e="";for(let n=0;n<t.length;n+=1)e+=String.fromCharCode(t[n]);return e}var Kc={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},be={LONG_WORDS:32768,WORD_DELTA_COUNT_MASK:32767,SHARED_POINT_NUMBERS:32768,COUNT_MASK:4095,EMBEDDED_PEAK_TUPLE:32768,INTERMEDIATE_REGION:16384,PRIVATE_POINT_NUMBERS:8192,TUPLE_INDEX_MASK:4095,POINTS_ARE_WORDS:128,POINT_RUN_COUNT_MASK:127,DELTAS_ARE_ZERO:128,DELTAS_ARE_WORDS:64,DELTA_RUN_COUNT_MASK:63,INNER_INDEX_BIT_COUNT_MASK:15,MAP_ENTRY_SIZE_MASK:48};function k(t,e){this.data=t,this.offset=e,this.relativeOffset=0}k.prototype.parseByte=function(){const t=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,t},k.prototype.parseChar=function(){const t=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,t},k.prototype.parseCard8=k.prototype.parseByte,k.prototype.parseUShort=function(){const t=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,t},k.prototype.parseCard16=k.prototype.parseUShort,k.prototype.parseSID=k.prototype.parseUShort,k.prototype.parseOffset16=k.prototype.parseUShort,k.prototype.parseShort=function(){const t=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,t},k.prototype.parseF2Dot14=function(){const t=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,t},k.prototype.parseUInt24=function(){const t=ci(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,t},k.prototype.parseULong=function(){const t=xr(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t},k.prototype.parseLong=function(){const t=jc(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t},k.prototype.parseOffset32=k.prototype.parseULong,k.prototype.parseFixed=function(){const t=li(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t},k.prototype.parseString=function(t){const e=this.data,n=this.offset+this.relativeOffset;let r="";this.relativeOffset+=t;for(let s=0;s<t;s++)r+=String.fromCharCode(e.getUint8(n+s));return r},k.prototype.parseTag=function(){return this.parseString(4)},k.prototype.parseLongDateTime=function(){let t=xr(this.data,this.offset+this.relativeOffset+4);return t-=2082844800,this.relativeOffset+=8,t},k.prototype.parseVersion=function(t){const e=kn(this.data,this.offset+this.relativeOffset),n=kn(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,t===void 0&&(t=4096),e+n/t/10},k.prototype.skip=function(t,e){e===void 0&&(e=1),this.relativeOffset+=Kc[t]*e},k.prototype.parseULongList=function(t){t===void 0&&(t=this.parseULong());const e=new Array(t),n=this.data;let r=this.offset+this.relativeOffset;for(let s=0;s<t;s++)e[s]=n.getUint32(r),r+=4;return this.relativeOffset+=t*4,e},k.prototype.parseOffset16List=k.prototype.parseUShortList=function(t){t===void 0&&(t=this.parseUShort());const e=new Array(t),n=this.data;let r=this.offset+this.relativeOffset;for(let s=0;s<t;s++)e[s]=n.getUint16(r),r+=2;return this.relativeOffset+=t*2,e},k.prototype.parseShortList=function(t){const e=new Array(t),n=this.data;let r=this.offset+this.relativeOffset;for(let s=0;s<t;s++)e[s]=n.getInt16(r),r+=2;return this.relativeOffset+=t*2,e},k.prototype.parseByteList=function(t){const e=new Array(t),n=this.data;let r=this.offset+this.relativeOffset;for(let s=0;s<t;s++)e[s]=n.getUint8(r++);return this.relativeOffset+=t,e},k.prototype.parseList=function(t,e){e||(e=t,t=this.parseUShort());const n=new Array(t);for(let r=0;r<t;r++)n[r]=e.call(this);return n},k.prototype.parseList32=function(t,e){e||(e=t,t=this.parseULong());const n=new Array(t);for(let r=0;r<t;r++)n[r]=e.call(this);return n},k.prototype.parseRecordList=function(t,e){e||(e=t,t=this.parseUShort());const n=new Array(t),r=Object.keys(e);for(let s=0;s<t;s++){const i={};for(let a=0;a<r.length;a++){const o=r[a],c=e[o];i[o]=c.call(this)}n[s]=i}return n},k.prototype.parseRecordList32=function(t,e){e||(e=t,t=this.parseULong());const n=new Array(t),r=Object.keys(e);for(let s=0;s<t;s++){const i={};for(let a=0;a<r.length;a++){const o=r[a],c=e[o];i[o]=c.call(this)}n[s]=i}return n},k.prototype.parseTupleRecords=function(t,e){let n=[];for(let r=0;r<t;r++){let s=[];for(let i=0;i<e;i++)s.push(this.parseF2Dot14());n.push(s)}return n},k.prototype.parseStruct=function(t){if(typeof t=="function")return t.call(this);{const e=Object.keys(t),n={};for(let r=0;r<e.length;r++){const s=e[r],i=t[s];n[s]=i.call(this)}return n}},k.prototype.parseValueRecord=function(t){if(t===void 0&&(t=this.parseUShort()),t===0)return;const e={};return t&1&&(e.xPlacement=this.parseShort()),t&2&&(e.yPlacement=this.parseShort()),t&4&&(e.xAdvance=this.parseShort()),t&8&&(e.yAdvance=this.parseShort()),t&16&&(e.xPlaDevice=void 0,this.parseShort()),t&32&&(e.yPlaDevice=void 0,this.parseShort()),t&64&&(e.xAdvDevice=void 0,this.parseShort()),t&128&&(e.yAdvDevice=void 0,this.parseShort()),e},k.prototype.parseValueRecordList=function(){const t=this.parseUShort(),e=this.parseUShort(),n=new Array(e);for(let r=0;r<e;r++)n[r]=this.parseValueRecord(t);return n},k.prototype.parsePointer=function(t){const e=this.parseOffset16();if(e>0)return new k(this.data,this.offset+e).parseStruct(t)},k.prototype.parsePointer32=function(t){const e=this.parseOffset32();if(e>0)return new k(this.data,this.offset+e).parseStruct(t)},k.prototype.parseListOfLists=function(t){const e=this.parseOffset16List(),n=e.length,r=this.relativeOffset,s=new Array(n);for(let i=0;i<n;i++){const a=e[i];if(a===0){s[i]=void 0;continue}if(this.relativeOffset=a,t){const o=this.parseOffset16List(),c=new Array(o.length);for(let l=0;l<o.length;l++)this.relativeOffset=a+o[l],c[l]=t.call(this);s[i]=c}else s[i]=this.parseUShortList()}return this.relativeOffset=r,s},k.prototype.parseCoverage=function(){const t=this.offset+this.relativeOffset,e=this.parseUShort(),n=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(n)};if(e===2){const r=new Array(n);for(let s=0;s<n;s++)r[s]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:r}}throw new Error("0x"+t.toString(16)+": Coverage format must be 1 or 2.")},k.prototype.parseClassDef=function(){const t=this.offset+this.relativeOffset,e=this.parseUShort();return e===1?{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()}:e===2?{format:2,ranges:this.parseRecordList({start:k.uShort,end:k.uShort,classId:k.uShort})}:(console.warn(`0x${t.toString(16)}: This font file uses an invalid ClassDef format of ${e}. It might be corrupted and should be reacquired if it doesn't display as intended.`),{format:e})},k.list=function(t,e){return function(){return this.parseList(t,e)}},k.list32=function(t,e){return function(){return this.parseList32(t,e)}},k.recordList=function(t,e){return function(){return this.parseRecordList(t,e)}},k.recordList32=function(t,e){return function(){return this.parseRecordList32(t,e)}},k.pointer=function(t){return function(){return this.parsePointer(t)}},k.pointer32=function(t){return function(){return this.parsePointer32(t)}},k.tag=k.prototype.parseTag,k.byte=k.prototype.parseByte,k.uShort=k.offset16=k.prototype.parseUShort,k.uShortList=k.prototype.parseUShortList,k.uInt24=k.prototype.parseUInt24,k.uLong=k.offset32=k.prototype.parseULong,k.uLongList=k.prototype.parseULongList,k.fixed=k.prototype.parseFixed,k.f2Dot14=k.prototype.parseF2Dot14,k.struct=k.prototype.parseStruct,k.coverage=k.prototype.parseCoverage,k.classDef=k.prototype.parseClassDef;var ui={reserved:k.uShort,reqFeatureIndex:k.uShort,featureIndexes:k.uShortList};k.prototype.parseScriptList=function(){return this.parsePointer(k.recordList({tag:k.tag,script:k.pointer({defaultLangSys:k.pointer(ui),langSysRecords:k.recordList({tag:k.tag,langSys:k.pointer(ui)})})}))||[]},k.prototype.parseFeatureList=function(){return this.parsePointer(k.recordList({tag:k.tag,feature:k.pointer({featureParams:k.offset16,lookupListIndexes:k.uShortList})}))||[]},k.prototype.parseLookupList=function(t){return this.parsePointer(k.list(k.pointer(function(){const e=this.parseUShort();z.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");const n=this.parseUShort(),r=n&16;return{lookupType:e,lookupFlag:n,subtables:this.parseList(k.pointer(t[e])),markFilteringSet:r?this.parseUShort():void 0}})))||[]},k.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){const t=this.parseUShort(),e=this.parseUShort();return z.argument(t===1&&e<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:k.offset32,featureTableSubstitutionOffset:k.offset32})})||[]},k.prototype.parseVariationStore=function(){const t=this.relativeOffset,e=this.parseUShort(),n={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=t+e+2,n},k.prototype.parseItemVariationStore=function(){const t=this.relativeOffset,e={format:this.parseUShort(),variationRegions:[],itemVariationSubtables:[]},n=this.parseOffset32(),r=this.parseUShort(),s=this.parseULongList(r);this.relativeOffset=t+n,e.variationRegions=this.parseVariationRegionList();for(let i=0;i<r;i++){const a=s[i];this.relativeOffset=t+a,e.itemVariationSubtables.push(this.parseItemVariationSubtable())}return e},k.prototype.parseVariationRegionList=function(){const t=this.parseUShort(),e=this.parseUShort();return this.parseRecordList(e,{regionAxes:k.recordList(t,{startCoord:k.f2Dot14,peakCoord:k.f2Dot14,endCoord:k.f2Dot14})})},k.prototype.parseItemVariationSubtable=function(){const t=this.parseUShort(),e=this.parseUShort(),n=this.parseUShortList(),r=n.length;return{regionIndexes:n,deltaSets:t&&r?this.parseDeltaSets(t,e,r):[]}},k.prototype.parseDeltaSetIndexMap=function(){const t=this.parseByte(),e=this.parseByte(),n=[];let r=0;switch(t){case 0:r=this.parseUShort();break;case 1:r=this.parseULong();break;default:console.error(`unsupported DeltaSetIndexMap format ${t}`)}if(!r)return{format:t,entryFormat:e};const s=(e&be.INNER_INDEX_BIT_COUNT_MASK)+1,i=((e&be.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let a=0;a<r;a++){let o;if(i===1)o=this.parseByte();else if(i===2)o=this.parseUShort();else if(i===3)o=this.parseUInt24();else if(i===4)o=this.parseULong();else throw new Error(`Invalid entry size of ${i}`);const c=o>>s,l=o&(1<<s)-1;n.push({outerIndex:c,innerIndex:l})}return{format:t,entryFormat:e,map:n}},k.prototype.parseDeltaSets=function(t,e,n){const r=Array.from({length:t},()=>[]),s=e&be.LONG_WORDS,i=e&be.WORD_DELTA_COUNT_MASK;if(i>n)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let c=0;c<t;c++)for(let l=0;l<n;l++)l<i?r[c].push(a()):r[c].push(o());return r},k.prototype.parseTupleVariationStoreList=function(t,e,n){const r=this.parseUShort(),i=this.parseUShort()&1,a=this.parseOffset32(),o=(i?this.parseULong:this.parseUShort).bind(this),c={};let l=o();i||(l*=2);let u;for(let f=0;f<r;f++){u=o(),i||(u*=2);const h=u-l;c[f]=h?this.parseTupleVariationStore(a+l,t,e,n,f):void 0,l=u}return c},k.prototype.parseTupleVariationStore=function(t,e,n,r,s){const i=this.relativeOffset;this.relativeOffset=t,n==="cvar"&&(this.relativeOffset+=4);const a=this.parseUShort(),o=!!(a&be.SHARED_POINT_NUMBERS),c=a&be.COUNT_MASK;let l=this.parseOffset16();const u=[];let f=[];for(let y=0;y<c;y++){const m=this.parseTupleVariationHeader(e,n);u.push(m)}this.relativeOffset!==t+l&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${t+l}, actually ${this.relativeOffset}`),this.relativeOffset=t+l),o&&(f=this.parsePackedPointNumbers());let h=this.relativeOffset;for(let y=0;y<c;y++){const m=u[y];m.privatePoints=[],this.relativeOffset=h,n==="cvar"&&!m.peakTuple&&console.warn("An embedded peak tuple is required in TupleVariationHeaders for the cvar table."),m.flags.privatePointNumbers&&(m.privatePoints=this.parsePackedPointNumbers()),delete m.flags;const b=this.offset,v=this.relativeOffset,w=T=>{let C,E;const R=()=>{let N=0;if(n==="gvar"){if(N=m.privatePoints.length||f.length,!N){const V=r.get(s);V.path,N=V.points.length,N+=4}}else n==="cvar"&&(N=r.length);this.offset=b,this.relativeOffset=v,C=this.parsePackedDeltas(N),n==="gvar"&&(E=this.parsePackedDeltas(N))};return{configurable:!0,get:function(){return C===void 0&&R(),T==="deltasY"?E:C},set:function(N){C===void 0&&R(),T==="deltasY"?E=N:C=N}}};Object.defineProperty(m,"deltas",w.call(this,"deltas")),n==="gvar"&&Object.defineProperty(m,"deltasY",w.call(this,"deltasY")),h+=m.variationDataSize,delete m.variationDataSize}this.relativeOffset=i;const p={headers:u};return p.sharedPoints=f,p},k.prototype.parseTupleVariationHeader=function(t,e){const n=this.parseUShort(),r=this.parseUShort(),s=!!(r&be.EMBEDDED_PEAK_TUPLE),i=!!(r&be.INTERMEDIATE_REGION),a=!!(r&be.PRIVATE_POINT_NUMBERS),o=s?void 0:r&be.TUPLE_INDEX_MASK,c=s?this.parseTupleRecords(1,t)[0]:void 0,l=i?this.parseTupleRecords(1,t)[0]:void 0,u=i?this.parseTupleRecords(1,t)[0]:void 0,f={variationDataSize:n,peakTuple:c,intermediateStartTuple:l,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:i,privatePointNumbers:a}};return e==="gvar"&&(f.sharedTupleRecordsIndex=o),f},k.prototype.parsePackedPointNumbers=function(){const t=this.parseByte(),e=[];let n=t;if(t>=128){const s=this.parseByte();n=(t&be.POINT_RUN_COUNT_MASK)<<8|s}let r=0;for(;e.length<n;){const s=this.parseByte(),i=!!(s&be.POINTS_ARE_WORDS);let a=(s&be.POINT_RUN_COUNT_MASK)+1;for(let o=0;o<a&&e.length<n;o++){let c;i?c=this.parseUShort():c=this.parseByte(),r=r+c,e.push(r)}}return e},k.prototype.parsePackedDeltas=function(t){const e=[];for(;e.length<t;){const n=this.parseByte(),r=!!(n&be.DELTAS_ARE_ZERO),s=!!(n&be.DELTAS_ARE_WORDS),i=(n&be.DELTA_RUN_COUNT_MASK)+1;for(let a=0;a<i&&e.length<t;a++)r?e.push(0):s?e.push(this.parseShort()):e.push(this.parseChar())}return e};var _={getByte:oi,getCard8:oi,getUShort:kn,getCard16:kn,getShort:Vc,getUInt24:ci,getULong:xr,getFixed:li,getTag:qc,getOffset:$c,getBytes:Yc,bytesToString:Xc,Parser:k},Fn=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],hi={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},Zc={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},fi={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function Jc(t,e,n){switch(t){case 0:if(e===65535)return"und";if(n)return n[e];break;case 1:return hi[e];case 3:return fi[e]}}var vr="utf-16",Qc={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},el={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function Sr(t,e,n){switch(t){case 0:return vr;case 1:return el[n]||Qc[e];case 3:if(e===1||e===10)return vr;break}}var pi={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function tl(t){return pi[t]}function nl(t,e,n){const r={},s=new _.Parser(t,e),i=s.parseUShort(),a=s.parseUShort(),o=s.offset+s.parseUShort();for(let c=0;c<a;c++){const l=s.parseUShort(),u=s.parseUShort(),f=s.parseUShort(),h=s.parseUShort(),p=Fn[h]||h,y=s.parseUShort(),m=s.parseUShort(),b=Jc(l,f,n),v=Sr(l,u,f),w=tl(l);if(v!==void 0&&b!==void 0&&w!==void 0){let T;if(v===vr?T=It.UTF16(t,o+m,y):T=It.MACSTRING(t,o+m,y,v),T){let C=r[w];C===void 0&&(C=r[w]={});let E=C[p];E===void 0&&(E=C[p]={}),E[b]=T}}}return i===1&&s.parseUShort(),r}function En(t){const e={};for(let n in t)e[t[n]]=parseInt(n);return e}function di(t,e,n,r,s,i){return new L.Record("NameRecord",[{name:"platformID",type:"USHORT",value:t},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:n},{name:"nameID",type:"USHORT",value:r},{name:"length",type:"USHORT",value:s},{name:"offset",type:"USHORT",value:i}])}function rl(t,e){const n=t.length,r=e.length-n+1;e:for(let s=0;s<r;s++)for(;s<r;s++){for(let i=0;i<n;i++)if(e[s+i]!==t[i])continue e;return s}return-1}function gi(t,e){let n=rl(t,e);if(n<0){n=e.length;let r=0;const s=t.length;for(;r<s;++r)e.push(t[r])}return n}function sl(t,e){const n=En(pi),r=En(hi),s=En(fi),i=[],a=[];for(let c in t){let l;const u=[],f={},h=En(Fn),p=n[c];for(let y in t[c]){let m=h[y];if(m===void 0&&(m=y),l=parseInt(m),isNaN(l))throw new Error('Name table entry "'+y+'" does not exist, see nameTableNames for complete list.');f[l]=t[c][y],u.push(l)}for(let y=0;y<u.length;y++){l=u[y];const m=f[l];for(let b in m){const v=m[b];if(p===1||p===0){let w=r[b],T=Zc[w];const C=Sr(p,T,w);let E=B.MACSTRING(v,C);if(p===0&&(w=e.indexOf(b),w<0&&(w=e.length,e.push(b)),T=4,E=B.UTF16(v)),E!==void 0){const R=gi(E,a);i.push(di(p,T,w,l,E.length,R))}}if(p===3){const w=s[b];if(w!==void 0){const T=B.UTF16(v),C=gi(T,a);i.push(di(3,1,w,l,T.length,C))}}}}}i.sort(function(c,l){return c.platformID-l.platformID||c.encodingID-l.encodingID||c.languageID-l.languageID||c.nameID-l.nameID});const o=new L.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:i.length},{name:"stringOffset",type:"USHORT",value:6+i.length*12}]);for(let c=0;c<i.length;c++)o.fields.push({name:"record_"+c,type:"RECORD",value:i[c]});return o.fields.push({name:"strings",type:"LITERAL",value:a}),o}function An(t,e,n=[]){if(e<256&&e in Fn){if(n.length&&!n.includes(parseInt(e)))return;e=Fn[e]}for(let r in t)for(let s in t[r])if(s===e||parseInt(s)===e)return t[r][s]}var mi={parse:nl,make:sl,getNameByID:An};function il(t,e,n,r){t.length=e.parseUShort(),t.language=e.parseUShort()-1;const s=e.parseByteList(t.length),i=Object.assign({},s),a=Sr(n,r,t.language),o=mn[a];for(let c=0;c<o.length;c++)i[o.charCodeAt(c)]=s[128+c];t.glyphIndexMap=i}function al(t,e,n){e.parseUShort(),t.length=e.parseULong(),t.language=e.parseULong();let r;t.groupCount=r=e.parseULong(),t.glyphIndexMap={};for(let s=0;s<r;s+=1){const i=e.parseULong(),a=e.parseULong();let o=e.parseULong();for(let c=i;c<=a;c+=1)t.glyphIndexMap[c]=o,n===12&&o++}}function ol(t,e,n,r,s){t.length=e.parseUShort(),t.language=e.parseUShort();let i;t.segCount=i=e.parseUShort()>>1,e.skip("uShort",3),t.glyphIndexMap={};const a=new _.Parser(n,r+s+14),o=new _.Parser(n,r+s+16+i*2),c=new _.Parser(n,r+s+16+i*4),l=new _.Parser(n,r+s+16+i*6);let u=r+s+16+i*8;for(let f=0;f<i-1;f+=1){let h;const p=a.parseUShort(),y=o.parseUShort(),m=c.parseShort(),b=l.parseUShort();for(let v=y;v<=p;v+=1)b!==0?(u=l.offset+l.relativeOffset-2,u+=b,u+=(v-y)*2,h=_.getUShort(n,u),h!==0&&(h=h+m&65535)):h=v+m&65535,t.glyphIndexMap[v]=h}}function cl(t,e){const n={};e.skip("uLong");const r=e.parseULong();for(let s=0;s<r;s+=1){const i=e.parseUInt24(),a={varSelector:i},o=e.parseOffset32(),c=e.parseOffset32(),l=e.relativeOffset;o&&(e.relativeOffset=o,a.defaultUVS=e.parseStruct({ranges:function(){return e.parseRecordList32({startUnicodeValue:e.parseUInt24,additionalCount:e.parseByte})}})),c&&(e.relativeOffset=c,a.nonDefaultUVS=e.parseStruct({uvsMappings:function(){const u={},f=e.parseRecordList32({unicodeValue:e.parseUInt24,glyphID:e.parseUShort});for(let h=0;h<f.length;h+=1)u[f[h].unicodeValue]=f[h];return u}})),n[i]=a,e.relativeOffset=l}t.varSelectorList=n}function ll(t,e){const n={};n.version=_.getUShort(t,e),z.argument(n.version===0,"cmap table version should be 0."),n.numTables=_.getUShort(t,e+2);let r=null,s=-1,i=-1,a=null,o=null;const c=[0,1,2,3,4,6],l=[0,1,10];for(let f=n.numTables-1;f>=0;f-=1)if(a=_.getUShort(t,e+4+f*8),o=_.getUShort(t,e+4+f*8+2),a===3&&l.includes(o)||a===0&&c.includes(o)||a===1&&o===0){if(i>0)continue;if(i=_.getULong(t,e+4+f*8+4),r)break}else if(a===0&&o===5){if(s=_.getULong(t,e+4+f*8+4),r=new _.Parser(t,e+s),r.parseUShort()!==14)s=-1,r=null;else if(i>0)break}if(i===-1)throw new Error("No valid cmap sub-tables found.");const u=new _.Parser(t,e+i);if(n.format=u.parseUShort(),n.format===0)il(n,u,a,o);else if(n.format===12||n.format===13)al(n,u,n.format);else if(n.format===4)ol(n,u,t,e,i);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+n.format+", platformId "+a+", encodingId "+o+").");return r&&cl(n,r),n}function ul(t,e,n){t.segments.push({end:e,start:e,delta:-(e-n),offset:0,glyphIndex:n})}function hl(t){t.segments.push({end:65535,start:65535,delta:1,offset:0})}function fl(t){if(t.length===0)return t;const e=[t[0]];for(let n=1;n<t.length;n++){const r=e[e.length-1],s=t[n];r.end+1===s.start&&r.delta===s.delta&&s.end!==65535?r.end=s.end:e.push(s)}return e}function pl(t){let e=!0,n;for(n=t.length-1;n>0;n-=1)if(t.get(n).unicode>65535){e=!1;break}let r=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||r.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),r.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new L.Table("cmap",r);for(s.segments=[],n=0;n<t.length;n+=1){const p=t.get(n);for(let y=0;y<p.unicodes.length;y+=1)ul(s,p.unicodes[y],n)}s.segments.sort(function(p,y){return p.start-y.start}),s.segments=fl(s.segments),hl(s);const i=s.segments.length;let a=0,o=[],c=[],l=[],u=[],f=[],h=[];for(n=0;n<i;n+=1){const p=s.segments[n];p.end<=65535&&p.start<=65535?(o.push({name:"end_"+n,type:"USHORT",value:p.end}),c.push({name:"start_"+n,type:"USHORT",value:p.start}),l.push({name:"idDelta_"+n,type:"SHORT",value:p.delta}),u.push({name:"idRangeOffset_"+n,type:"USHORT",value:p.offset}),p.glyphId!==void 0&&f.push({name:"glyph_"+n,type:"USHORT",value:p.glyphId})):a+=1,!e&&p.glyphIndex!==void 0&&(h.push({name:"cmap12Start_"+n,type:"ULONG",value:p.start}),h.push({name:"cmap12End_"+n,type:"ULONG",value:p.end}),h.push({name:"cmap12Glyph_"+n,type:"ULONG",value:p.glyphIndex}))}s.segCountX2=(i-a)*2,s.searchRange=Math.pow(2,Math.floor(Math.log(i-a)/Math.log(2)))*2,s.entrySelector=Math.log(s.searchRange/2)/Math.log(2),s.rangeShift=s.segCountX2-s.searchRange;for(let p=0;p<o.length;p++)s.fields.push(o[p]);s.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let p=0;p<c.length;p++)s.fields.push(c[p]);for(let p=0;p<l.length;p++)s.fields.push(l[p]);for(let p=0;p<u.length;p++)s.fields.push(u[p]);for(let p=0;p<f.length;p++)s.fields.push(f[p]);if(s.cmap4Length=14+o.length*2+2+c.length*2+l.length*2+u.length*2+f.length*2,!e){const p=16+h.length*4;s.cmap12Offset=12+2*2+4+s.cmap4Length,s.fields.push({name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:p},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:h.length/3});for(let y=0;y<h.length;y++)s.fields.push(h[y])}return s}var yi={parse:ll,make:pl},On=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],dl=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],gl=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],ml=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"],wr=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],yl=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],St=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function bi(t){this.font=t}bi.prototype.charToGlyphIndex=function(t){const e=t.codePointAt(0),n=this.font.glyphs;if(n)for(let r=0;r<n.length;r+=1){const s=n.get(r);for(let i=0;i<s.unicodes.length;i+=1)if(s.unicodes[i]===e)return r}return null};function xi(t){this.cmap=t}xi.prototype.charToGlyphIndex=function(t){return this.cmap.glyphIndexMap[t.codePointAt(0)]||0};function vi(t,e){this.encoding=t,this.charset=e}vi.prototype.charToGlyphIndex=function(t){const e=t.codePointAt(0),n=this.encoding[e];return this.charset.indexOf(n)};function Tr(t){switch(t.version){case 1:this.names=St.slice();break;case 2:this.names=new Array(t.numberOfGlyphs);for(let e=0;e<t.numberOfGlyphs;e++)t.glyphNameIndex[e]<St.length?this.names[e]=St[t.glyphNameIndex[e]]:this.names[e]=t.names[t.glyphNameIndex[e]-St.length];break;case 2.5:this.names=new Array(t.numberOfGlyphs);for(let e=0;e<t.numberOfGlyphs;e++)this.names[e]=St[e+t.glyphNameIndex[e]];break;case 3:this.names=[];break;default:this.names=[];break}}Tr.prototype.nameToGlyphIndex=function(t){return this.names.indexOf(t)},Tr.prototype.glyphIndexToName=function(t){return this.names[t]};function bl(t){let e;const n=t.tables.cmap.glyphIndexMap,r=Object.keys(n);for(let s=0;s<r.length;s+=1){const i=r[s],a=n[i];e=t.glyphs.get(a),e.addUnicode(parseInt(i))}for(let s=0;s<t.glyphs.length;s+=1)e=t.glyphs.get(s),t.cffEncoding?e.name=t.cffEncoding.charset[s]:t.glyphNames.names&&(e.name=t.glyphNames.glyphIndexToName(s))}function xl(t){t._IndexToUnicodeMap={};const e=t.tables.cmap.glyphIndexMap,n=Object.keys(e);for(let r=0;r<n.length;r+=1){const s=n[r];let i=e[s];t._IndexToUnicodeMap[i]===void 0?t._IndexToUnicodeMap[i]={unicodes:[parseInt(s)]}:t._IndexToUnicodeMap[i].unicodes.push(parseInt(s))}}function vl(t,e){e.lowMemory?xl(t):bl(t)}function Sl(t,e,n,r,s){t.beginPath(),t.moveTo(e,n),t.lineTo(r,s),t.stroke()}var wt={line:Sl};function wl(t,e){const n=new k(t,e),r=n.parseShort();r!==0&&console.warn("Only CPALv0 is currently fully supported.");const s=n.parseShort(),i=n.parseShort(),a=n.parseShort(),o=n.parseOffset32(),c=n.parseUShortList(i);n.relativeOffset=o;const l=n.parseULongList(a);return n.relativeOffset=o,{version:r,numPaletteEntries:s,colorRecords:l,colorRecordIndices:c}}function Tl({version:t=0,numPaletteEntries:e=0,colorRecords:n=[],colorRecordIndices:r=[0]}){return z.argument(t===0,"Only CPALv0 are supported."),z.argument(n.length,"No colorRecords given."),z.argument(r.length,"No colorRecordIndices given."),r.length>1&&z.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new L.Table("CPAL",[{name:"version",type:"USHORT",value:t},{name:"numPaletteEntries",type:"USHORT",value:e||n.length},{name:"numPalettes",type:"USHORT",value:r.length},{name:"numColorRecords",type:"USHORT",value:n.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*r.length},...r.map((s,i)=>({name:"colorRecordIndices_"+i,type:"USHORT",value:s})),...n.map((s,i)=>({name:"colorRecords_"+i,type:"ULONG",value:s}))])}function Si(t){var e=(t&4278190080)>>24,n=(t&16711680)>>16,r=(t&65280)>>8,s=t&255;return e=e+256&255,n=n+256&255,r=r+256&255,s=(s+256&255)/255,{b:e,g:n,r,a:s}}function Cr(t,e,n=0,r="hexa"){if(e==65535)return"currentColor";const s=t&&t.tables&&t.tables.cpal;if(!s)return"currentColor";if(n>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const i=s.colorRecordIndices[n]+e;if(i>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${i})`);const a=Si(s.colorRecords[i]);return r==="bgra"?a:Bt(a,r)}function We(t){return("0"+parseInt(t).toString(16)).slice(-2)}function Cl(t){const e=t.r/255,n=t.g/255,r=t.b/255,s=Math.max(e,n,r),i=Math.min(e,n,r);let a,o,c=(s+i)/2;if(s===i)a=o=0;else{const l=s-i;switch(o=c>.5?l/(2-s-i):l/(s+i),s){case e:a=(n-r)/l+(n<r?6:0);break;case n:a=(r-e)/l+2;break;case r:a=(e-n)/l+4;break}a/=6}return{h:a*360,s:o*100,l:c*100}}function kl(t){let{h:e,s:n,l:r,a:s}=t;e=e%360,n/=100,r/=100;const i=(1-Math.abs(2*r-1))*n,a=i*(1-Math.abs(e/60%2-1)),o=r-i/2;let c=0,l=0,u=0;return 0<=e&&e<60?(c=i,l=a,u=0):60<=e&&e<120?(c=a,l=i,u=0):120<=e&&e<180?(c=0,l=i,u=a):180<=e&&e<240?(c=0,l=a,u=i):240<=e&&e<300?(c=a,l=0,u=i):300<=e&&e<=360&&(c=i,l=0,u=a),{r:Math.round((c+o)*255),g:Math.round((l+o)*255),b:Math.round((u+o)*255),a:s}}function wi(t){return parseInt(`0x${We(t.b)}${We(t.g)}${We(t.r)}${We(t.a*255)}`,16)}function Ln(t,e="hexa"){const n=e=="raw"||e=="cpal",r=Number.isInteger(t);let s=!0;if(r&&n||t==="currentColor")return t;if(typeof t=="object"){if(e=="bgra")return t;if(n)return wi(t)}else if(!r&&/^#([a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(t.trim())){switch(t=t.trim().substring(1),t.length){case 3:t={r:parseInt(t[0].repeat(2),16),g:parseInt(t[1].repeat(2),16),b:parseInt(t[2].repeat(2),16),a:1};break;case 4:t={r:parseInt(t[0].repeat(2),16),g:parseInt(t[1].repeat(2),16),b:parseInt(t[2].repeat(2),16),a:parseInt(t[3].repeat(2),16)/255};break;case 6:t={r:parseInt(t[0]+t[1],16),g:parseInt(t[2]+t[3],16),b:parseInt(t[4]+t[5],16),a:1};break;case 8:t={r:parseInt(t[0]+t[1],16),g:parseInt(t[2]+t[3],16),b:parseInt(t[4]+t[5],16),a:parseInt(t[6]+t[7],16)/255};break}if(e=="bgra")return t}else if(typeof document<"u"&&/^[a-z]+$/i.test(t)){const i=document.createElement("canvas").getContext("2d");i.fillStyle=t;const a=Bt(i.fillStyle,"hexa");a==="#000000ff"&&t.toLowerCase()!=="black"?s=!1:t=a}else{t=t.trim();const i=/rgba?\(\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(i.test(t)){const a=t.match(i).filter(o=>typeof o<"u");t={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(t)){const o=t.match(a).filter(c=>typeof c<"u");t=kl({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${t}`);return Bt(t,e)}function Bt(t,e="hexa"){if(t==="currentColor")return t;if(Number.isInteger(t)){if(e=="raw"||e=="cpal")return t;t=Si(t)}else typeof t!="object"&&(t=Ln(t,"bgra"));let n=["hsl","hsla"].includes(e)?Cl(t):null;switch(e){case"rgba":return`rgba(${t.r}, ${t.g}, ${t.b}, ${parseFloat(t.a.toFixed(3))})`;case"rgb":return`rgb(${t.r}, ${t.g}, ${t.b})`;case"hex":case"hex6":case"hex-6":return`#${We(t.r)}${We(t.g)}${We(t.b)}`;case"hexa":case"hex8":case"hex-8":return`#${We(t.r)}${We(t.g)}${We(t.b)}${We(t.a*255)}`;case"hsl":return`hsl(${n.h.toFixed(2)}, ${n.s.toFixed(2)}%, ${n.l.toFixed(2)}%)`;case"hsla":return`hsla(${n.h.toFixed(2)}, ${n.s.toFixed(2)}%, ${n.l.toFixed(2)}%, ${parseFloat(t.a.toFixed(3))})`;case"bgra":return t;case"raw":case"cpal":return wi(t);default:throw new Error("Unknown color format: "+e)}}var Ti={parse:wl,make:Tl,getPaletteColor:Cr,parseColor:Ln,formatColor:Bt};function Fl(t,e){let n=e||new Lt;return{configurable:!0,get:function(){return typeof n=="function"&&(n=n()),n},set:function(r){n=r}}}function xe(t){this.bindConstructorValues(t)}xe.prototype.bindConstructorValues=function(t){if(this.index=t.index||0,t.name===".notdef"?t.unicode=void 0:t.name===".null"&&(t.unicode=0),t.unicode===0&&t.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=t.name||null,this.unicode=t.unicode,this.unicodes=t.unicodes||(t.unicode!==void 0?[t.unicode]:[]),"xMin"in t&&(this.xMin=t.xMin),"yMin"in t&&(this.yMin=t.yMin),"xMax"in t&&(this.xMax=t.xMax),"yMax"in t&&(this.yMax=t.yMax),"advanceWidth"in t&&(this.advanceWidth=t.advanceWidth),"leftSideBearing"in t&&(this.leftSideBearing=t.leftSideBearing),"points"in t&&(this.points=t.points),Object.defineProperty(this,"path",Fl(this,t.path))},xe.prototype.addUnicode=function(t){this.unicodes.length===0&&(this.unicode=t),this.unicodes.push(t)},xe.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},xe.prototype.getPath=function(t,e,n,r,s){t=t!==void 0?t:0,e=e!==void 0?e:0,n=n!==void 0?n:72,r=Object.assign({},s&&s.defaultRenderOptions,r);let i,a,o=r.xScale,c=r.yScale;const l=1/(this.path.unitsPerEm||1e3)*n;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,r.variation),i=u.path.commands),r.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,n,r)),a?(i=s.hinting.getCommands(a),t=Math.round(t),e=Math.round(e),o=c=1):(i=u.path.commands,o===void 0&&(o=l),c===void 0&&(c=l));const f=new Lt;if(r.drawSVG){const h=this.getSvgImage(s);if(h){const p=new Lt;return p._image={image:h.image,x:t+h.leftSideBearing*l,y:e-h.baseline*l,width:h.image.width*l,height:h.image.height*l},f._layers=[p],f}}if(r.drawLayers){const h=this.getLayers(s);if(h&&h.length){f._layers=[];for(let p=0;p<h.length;p+=1){const y=h[p];let m=Cr(s,y.paletteIndex,r.usePalette);m==="currentColor"?m=r.fill||"black":m=Bt(m,r.colorFormat||"rgba"),r=Object.assign({},r,{fill:m}),f._layers.push(this.getPath.call(y.glyph,t,e,n,r,s))}return f}}f.fill=r.fill||this.path.fill,f.stroke=this.path.stroke,f.strokeWidth=this.path.strokeWidth*l;for(let h=0;h<i.length;h+=1){const p=i[h];p.type==="M"?f.moveTo(t+p.x*o,e+-p.y*c):p.type==="L"?f.lineTo(t+p.x*o,e+-p.y*c):p.type==="Q"?f.quadraticCurveTo(t+p.x1*o,e+-p.y1*c,t+p.x*o,e+-p.y*c):p.type==="C"?f.curveTo(t+p.x1*o,e+-p.y1*c,t+p.x2*o,e+-p.y2*c,t+p.x*o,e+-p.y*c):p.type==="Z"&&f.stroke&&f.strokeWidth&&f.closePath()}return f},xe.prototype.getLayers=function(t){if(!t)throw new Error("The font object is required to read the colr/cpal tables in order to get the layers.");return t.layers.get(this.index)},xe.prototype.getSvgImage=function(t){if(!t)throw new Error("The font object is required to read the svg table in order to get the image.");return t.svgImages.get(this.index)},xe.prototype.getContours=function(t=null){if(this.points===void 0&&!t)return[];const e=[];let n=[],r=t||this.points;for(let s=0;s<r.length;s+=1){const i=r[s];n.push(i),i.lastPointOfContour&&(e.push(n),n=[])}return z.argument(n.length===0,"There are still points left in the current contour."),e},xe.prototype.getMetrics=function(){const t=this.path.commands,e=[],n=[];for(let s=0;s<t.length;s+=1){const i=t[s];i.type!=="Z"&&(e.push(i.x),n.push(i.y)),(i.type==="Q"||i.type==="C")&&(e.push(i.x1),n.push(i.y1)),i.type==="C"&&(e.push(i.x2),n.push(i.y2))}const r={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,e),yMax:Math.max.apply(null,n),leftSideBearing:this.leftSideBearing};return isFinite(r.xMin)||(r.xMin=0),isFinite(r.xMax)||(r.xMax=this.advanceWidth),isFinite(r.yMin)||(r.yMin=0),isFinite(r.yMax)||(r.yMax=0),r.rightSideBearing=this.advanceWidth-r.leftSideBearing-(r.xMax-r.xMin),r},xe.prototype.draw=function(t,e,n,r,s,i){s=Object.assign({},i&&i.defaultRenderOptions,s),this.getPath(e,n,r,s,i).draw(t)},xe.prototype.drawPoints=function(t,e,n,r,s,i){if(s=Object.assign({},i&&i.defaultRenderOptions,s),s.drawLayers){const h=this.getLayers(i);if(h&&h.length){for(let p=0;p<h.length;p+=1)h[p].glyph.index!==this.index&&this.drawPoints.call(h[p].glyph,t,e,n,r);return}}function a(h,p,y,m){t.beginPath();for(let b=0;b<h.length;b+=1)t.moveTo(p+h[b].x*m,y+h[b].y*m),t.arc(p+h[b].x*m,y+h[b].y*m,2,0,Math.PI*2,!1);t.fill()}e=e!==void 0?e:0,n=n!==void 0?n:0,r=r!==void 0?r:24;const o=1/this.path.unitsPerEm*r,c=[],l=[];let f=this.path.commands;i&&i.variation&&(f=i.variation.getTransform(this,s.variation).path.commands);for(let h=0;h<f.length;h+=1){const p=f[h];p.x!==void 0&&c.push({x:p.x,y:-p.y}),p.x1!==void 0&&l.push({x:p.x1,y:-p.y1}),p.x2!==void 0&&l.push({x:p.x2,y:-p.y2})}t.fillStyle="blue",a(c,e,n,o),t.fillStyle="red",a(l,e,n,o)},xe.prototype.drawMetrics=function(t,e,n,r){let s;e=e!==void 0?e:0,n=n!==void 0?n:0,r=r!==void 0?r:24,s=1/this.path.unitsPerEm*r,t.lineWidth=1,t.strokeStyle="black",wt.line(t,e,-1e4,e,1e4),wt.line(t,-1e4,n,1e4,n);const i=this.xMin||0;let a=this.yMin||0;const o=this.xMax||0;let c=this.yMax||0;const l=this.advanceWidth||0;t.strokeStyle="blue",wt.line(t,e+i*s,-1e4,e+i*s,1e4),wt.line(t,e+o*s,-1e4,e+o*s,1e4),wt.line(t,-1e4,n+-a*s,1e4,n+-a*s),wt.line(t,-1e4,n+-c*s,1e4,n+-c*s),t.strokeStyle="green",wt.line(t,e+l*s,-1e4,e+l*s,1e4)},xe.prototype.toPathData=function(t,e){t=Object.assign({},{variation:e&&e.defaultRenderOptions.variation},t);let n=this;e&&e.variation&&(n=e.variation.getTransform(this,t.variation));let r=n.points&&t.pointsTransform?t.pointsTransform(n.points):n.path;return t.pathTransform&&(r=t.pathTransform(r)),r.toPathData(t)},xe.prototype.fromSVG=function(t,e={}){return this.path.fromSVG(t,e)},xe.prototype.toSVG=function(t,e){const n=this.toPathData.apply(this,[t,e]);return this.path.toSVG(t,n)},xe.prototype.toDOMElement=function(t,e){t=Object.assign({},{variation:e&&e.defaultRenderOptions.variation},t);let n=this.path;return e&&e.variation&&(n=e.variation.getTransform(this,t.variation).path),n.toDOMElement(t)};var Yt=xe;function Dt(t,e,n){Object.defineProperty(t,e,{get:function(){return typeof t[n]>"u"&&t.path,t[n]},set:function(r){t[n]=r},enumerable:!0,configurable:!0})}function In(t,e){if(this.font=t,this.glyphs={},Array.isArray(e))for(let n=0;n<e.length;n++){const r=e[n];r.path.unitsPerEm=t.unitsPerEm,this.glyphs[n]=r}this.length=e&&e.length||0}typeof Symbol<"u"&&Symbol.iterator&&(In.prototype[Symbol.iterator]=function(){let t=-1;return{next:(function(){t++;const e=t>=this.length-1;return{value:this.get(t),done:e}}).bind(this)}}),In.prototype.get=function(t){if(this.font._push&&this.glyphs[t]===void 0){this.font._push(t),typeof this.glyphs[t]=="function"&&(this.glyphs[t]=this.glyphs[t]());let e=this.glyphs[t],n=this.font._IndexToUnicodeMap[t];if(n)for(let r=0;r<n.unicodes.length;r++)e.addUnicode(n.unicodes[r]);this.font.cffEncoding?e.name=this.font.cffEncoding.charset[t]:this.font.glyphNames.names&&(e.name=this.font.glyphNames.glyphIndexToName(t)),this.glyphs[t].advanceWidth=this.font._hmtxTableData[t].advanceWidth,this.glyphs[t].leftSideBearing=this.font._hmtxTableData[t].leftSideBearing}else typeof this.glyphs[t]=="function"&&(this.glyphs[t]=this.glyphs[t]());return this.glyphs[t]},In.prototype.push=function(t,e){this.glyphs[t]=e,this.length++};function El(t,e){return new Yt({index:e,font:t})}function Al(t,e,n,r,s,i){return function(){const a=new Yt({index:e,font:t});return a.path=function(){n(a,r,s);const o=i(t.glyphs,a);return o.unitsPerEm=t.unitsPerEm,o},Dt(a,"numberOfContours","_numberOfContours"),Dt(a,"xMin","_xMin"),Dt(a,"xMax","_xMax"),Dt(a,"yMin","_yMin"),Dt(a,"yMax","_yMax"),Dt(a,"points","_points"),a}}function Ol(t,e,n,r,s){return function(){const i=new Yt({index:e,font:t});return i.path=function(){const a=n(t,i,r,s);return a.unitsPerEm=t.unitsPerEm,a},i}}var Xe={GlyphSet:In,glyphLoader:El,ttfGlyphLoader:Al,cffGlyphLoader:Ol};function Ci(t,e){if(t===e)return!0;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!Ci(t[n],e[n]))return!1;return!0}else return!1}var ki=10;function Mn(t){let e;return t.length<1240?e=107:t.length<33900?e=1131:e=32768,e}function Ke(t,e,n,r){const s=[],i=[],a=r>1?_.getULong(t,e):_.getCard16(t,e),o=r>1?4:2;let c,l;if(a!==0){const u=_.getByte(t,e+o);c=e+(a+1)*u+o;let f=e+o+1;for(let h=0;h<a+1;h+=1)s.push(_.getOffset(t,f,u)),f+=u;l=c+s[a]}else l=e+o;for(let u=0;u<s.length-1;u+=1){let f=_.getBytes(t,c+s[u],c+s[u+1]);n&&(f=n(f,t,e,r)),i.push(f)}return{objects:i,startOffset:e,endOffset:l}}function Ll(t,e,n){const r=[],s=n>1?_.getULong(t,e):_.getCard16(t,e),i=n>1?4:2;let a,o;if(s!==0){const c=_.getByte(t,e+i);a=e+(s+1)*c+i;let l=e+i+1;for(let u=0;u<s+1;u+=1)r.push(_.getOffset(t,l,c)),l+=c;o=a+r[s]}else o=e+i;return{offsets:r,startOffset:e,endOffset:o}}function Il(t,e,n,r,s,i){const a=i>1?_.getULong(n,r):_.getCard16(n,r),o=i>1?4:2;let c=0;if(a!==0){const u=_.getByte(n,r+o);c=r+(a+1)*u+o}return _.getBytes(n,c+e[t],c+e[t+1])}function Ml(t){let e="";const r=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=t.parseByte(),i=s>>4,a=s&15;if(i===15||(e+=r[i],a===15))break;e+=r[a]}return parseFloat(e)}function Rl(t,e){let n,r,s,i;if(e===28)return n=t.parseByte(),r=t.parseByte(),n<<8|r;if(e===29)return n=t.parseByte(),r=t.parseByte(),s=t.parseByte(),i=t.parseByte(),n<<24|r<<16|s<<8|i;if(e===30)return Ml(t);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return n=t.parseByte(),(e-247)*256+n+108;if(e>=251&&e<=254)return n=t.parseByte(),-(e-251)*256-n-108;throw new Error("Invalid b0 "+e)}function Bl(t){const e={};for(let n=0;n<t.length;n+=1){const r=t[n][0],s=t[n][1];let i;if(s.length===1?i=s[0]:i=s,Object.prototype.hasOwnProperty.call(e,r)&&!isNaN(e[r]))throw new Error("Object "+e+" already has key "+r);e[r]=i}return e}function kr(t,e,n,r){e=e!==void 0?e:0;const s=new _.Parser(t,e),i=[];let a=[];n=n!==void 0?n:t.byteLength;let o=r<2?22:28;for(;s.relativeOffset<n;){let c=s.parseByte();if(c<o){if(c===12&&(c=1200+s.parseByte()),r>1&&c===23){Vl(a);continue}i.push([c,a]),a=[]}else a.push(Rl(s,c))}return Bl(i)}function Xt(t,e){return e<=390?e=On[e]:t?e=t[e-391]:e=void 0,e}function Fr(t,e,n){const r={};let s;for(let i=0;i<e.length;i+=1){const a=e[i];if(Array.isArray(a.type)){const o=[];o.length=a.type.length;for(let c=0;c<a.type.length;c++)s=t[a.op]!==void 0?t[a.op][c]:void 0,s===void 0&&(s=a.value!==void 0&&a.value[c]!==void 0?a.value[c]:null),a.type[c]==="SID"&&(s=Xt(n,s)),o[c]=s;r[a.name]=o}else s=t[a.op],s===void 0&&(s=a.value!==void 0?a.value:null),a.type==="SID"&&(s=Xt(n,s)),r[a.name]=s}return r}function Dl(t,e){const n={};if(n.formatMajor=_.getCard8(t,e),n.formatMinor=_.getCard8(t,e+1),n.formatMajor>2)throw new Error(`Unsupported CFF table version ${n.formatMajor}.${n.formatMinor}`);return n.size=_.getCard8(t,e+2),n.formatMajor<2?(n.offsetSize=_.getCard8(t,e+3),n.startOffset=e,n.endOffset=e+4):(n.topDictLength=_.getCard16(t,e+3),n.endOffset=e+8),n}var Fi=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],_l=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],Ei=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],Ul=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],Pl=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function Nl(t,e,n,r){const s=kr(t,e,t.byteLength,r);return Fr(s,r>1?_l:Fi,n)}function Er(t,e,n,r,s){const i=kr(t,e,n,s);return Fr(i,s>1?Ul:Ei,r)}function Gl(t,e,n){const r=kr(t,e,void 0,n);return Fr(r,Pl)}function Hl(t,e,n){const r=[];for(let s=0;s<n.length;s++){const i=new DataView(new Uint8Array(n[s]).buffer),a=Gl(i,0,2),o=a.private[0],c=a.private[1];if(o!==0&&c!==0){const l=Er(t,c+e,o,[],2);if(l.subrs){const u=c+l.subrs,f=Ke(t,u+e,void 0,2);a._subrs=f.objects,a._subrsBias=Mn(a._subrs)}a._privateDict=l}r.push(a)}return r}function Ar(t,e,n,r,s){const i=[];for(let a=0;a<n.length;a+=1){const o=new DataView(new Uint8Array(n[a]).buffer),c=Nl(o,0,r,s);c._subrs=[],c._subrsBias=0,c._defaultWidthX=0,c._nominalWidthX=0;const l=s<2?c.private[0]:0,u=s<2?c.private[1]:0;if(l!==0&&u!==0){const f=Er(t,u+e,l,r,s);if(c._defaultWidthX=f.defaultWidthX,c._nominalWidthX=f.nominalWidthX,f.subrs!==0){const h=u+f.subrs,p=Ke(t,h+e,void 0,s);c._subrs=p.objects,c._subrsBias=Mn(c._subrs)}c._privateDict=f}i.push(c)}return i}function zl(t,e,n,r,s){let i,a;const o=new _.Parser(t,e);n-=1;const c=[".notdef"],l=o.parseCard8();if(l===0)for(let u=0;u<n;u+=1)i=o.parseSID(),s?c.push(i):c.push(Xt(r,i)||i);else if(l===1)for(;c.length<=n;){i=o.parseSID(),a=o.parseCard8();for(let u=0;u<=a;u+=1)s?c.push("cid"+("00000"+i).slice(-5)):c.push(Xt(r,i)||i),i+=1}else if(l===2)for(;c.length<=n;){i=o.parseSID(),a=o.parseCard16();for(let u=0;u<=a;u+=1)s?c.push("cid"+("00000"+i).slice(-5)):c.push(Xt(r,i)||i),i+=1}else throw new Error("Unknown charset format "+l);return c}function Wl(t,e){let n;const r={},s=new _.Parser(t,e),i=s.parseCard8();if(i===0){const a=s.parseCard8();for(let o=0;o<a;o+=1)n=s.parseCard8(),r[n]=o}else if(i===1){const a=s.parseCard8();n=1;for(let o=0;o<a;o+=1){const c=s.parseCard8(),l=s.parseCard8();for(let u=c;u<=c+l;u+=1)r[u]=n,n+=1}}else throw new Error("Unknown encoding format "+i);return r}function Vl(t){let e=t.pop();for(;t.length>e;)t.pop()}function Ai(t,e){const n=t.tables.cff&&t.tables.cff.topDict&&t.tables.cff.topDict.paintType||0;return n===2&&(e.fill=null,e.stroke="black",e.strokeWidth=t.tables.cff.topDict.strokeWidth||0),n}function Or(t,e,n,r,s){let i,a,o,c;const l=new Lt,u=[];let f=0,h=!1,p=!1,y=0,m=0,b,v,w,T,C=0,E=[],R,N=0;const V=t.tables.cff2||t.tables.cff;if(w=V.topDict._defaultWidthX,T=V.topDict._nominalWidthX,s=s||t.variation&&t.variation.get(),e.getBlendPath||(e.getBlendPath=function(D){return Or(t,e,n,r,D)}),t.isCIDFont||r>1){const D=V.topDict._fdSelect?V.topDict._fdSelect[e.index]:0,U=V.topDict._fdArray[D];b=U._subrs,v=U._subrsBias,r>1?(E=V.topDict._vstore.itemVariationStore,C=U._privateDict.vsindex):(w=U._defaultWidthX,T=U._nominalWidthX)}else b=V.topDict._subrs,v=V.topDict._subrsBias;const Y=Ai(t,l);let G=w;function J(D,U){p&&Y!==2&&l.closePath(),l.moveTo(D,U),p=!0}function ie(){let D;D=(u.length&1)!==0,D&&!h&&(G=u.shift()+T),f+=u.length>>1,u.length=0,h=!0}function P(D){let U,re,Ae,at,He,me,X,ne,de,ve,ge,ye,ce=0;for(;ce<D.length;){let we=D[ce];switch(ce+=1,we){case 1:ie();break;case 3:ie();break;case 4:u.length>1&&!h&&(G=u.shift()+T,h=!0),m+=u.pop(),J(y,m);break;case 5:for(;u.length>0;)y+=u.shift(),m+=u.shift(),l.lineTo(y,m);break;case 6:for(;u.length>0&&(y+=u.shift(),l.lineTo(y,m),u.length!==0);)m+=u.shift(),l.lineTo(y,m);break;case 7:for(;u.length>0&&(m+=u.shift(),l.lineTo(y,m),u.length!==0);)y+=u.shift(),l.lineTo(y,m);break;case 8:for(;u.length>0;)i=y+u.shift(),a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),y=o+u.shift(),m=c+u.shift(),l.curveTo(i,a,o,c,y,m);break;case 10:if(He=u.pop()+v,me=b[He],me){if(N>=ki){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}N++,P(me),N--}break;case 11:if(r>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(we=D[ce],ce+=1,we){case 35:i=y+u.shift(),a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),X=o+u.shift(),ne=c+u.shift(),de=X+u.shift(),ve=ne+u.shift(),ge=de+u.shift(),ye=ve+u.shift(),y=ge+u.shift(),m=ye+u.shift(),u.shift(),l.curveTo(i,a,o,c,X,ne),l.curveTo(de,ve,ge,ye,y,m);break;case 34:i=y+u.shift(),a=m,o=i+u.shift(),c=a+u.shift(),X=o+u.shift(),ne=c,de=X+u.shift(),ve=c,ge=de+u.shift(),ye=m,y=ge+u.shift(),l.curveTo(i,a,o,c,X,ne),l.curveTo(de,ve,ge,ye,y,m);break;case 36:i=y+u.shift(),a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),X=o+u.shift(),ne=c,de=X+u.shift(),ve=c,ge=de+u.shift(),ye=ve+u.shift(),y=ge+u.shift(),l.curveTo(i,a,o,c,X,ne),l.curveTo(de,ve,ge,ye,y,m);break;case 37:i=y+u.shift(),a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),X=o+u.shift(),ne=c+u.shift(),de=X+u.shift(),ve=ne+u.shift(),ge=de+u.shift(),ye=ve+u.shift(),Math.abs(ge-y)>Math.abs(ye-m)?y=ge+u.shift():m=ye+u.shift(),l.curveTo(i,a,o,c,X,ne),l.curveTo(de,ve,ge,ye,y,m);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+we),u.length=0}break;case 14:if(r>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const ot=wr[u.pop()],x=wr[u.pop()],d=u.pop(),g=u.pop();if(ot&&x){e.isComposite=!0,e.components=[];const S=t.cffEncoding.charset.indexOf(ot),F=t.cffEncoding.charset.indexOf(x);e.components.push({glyphIndex:F,dx:0,dy:0}),e.components.push({glyphIndex:S,dx:g,dy:d}),l.extend(t.glyphs.get(F).path);const O=t.glyphs.get(S),I=JSON.parse(JSON.stringify(O.path.commands));for(let q=0;q<I.length;q+=1){const j=I[q];j.type!=="Z"&&(j.x+=g,j.y+=d),(j.type==="Q"||j.type==="C")&&(j.x1+=g,j.y1+=d),j.type==="C"&&(j.x2+=g,j.y2+=d)}l.extend(I)}}else u.length>0&&!h&&(G=u.shift()+T,h=!0);p&&Y!==2&&(l.closePath(),p=!1);break;case 15:if(r<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}C=u.pop();break;case 16:if(r<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}R||(R=t.variation&&s&&t.variation.process.getBlendVector(E,C,s));var ee=u.pop(),Se=R?R.length:E.itemVariationSubtables[C].regionIndexes.length,Oe=ee*Se,Le=u.length-Oe,Ie=Le-ee;if(R)for(let ot=0;ot<ee;ot++){var _e=u[Ie+ot];for(let x=0;x<Se;x++)_e+=R[x]*u[Le++];u[Ie+ot]=_e}for(;Oe--;)u.pop();break;case 18:ie();break;case 19:case 20:ie(),ce+=f+7>>3;break;case 21:u.length>2&&!h&&(G=u.shift()+T,h=!0),m+=u.pop(),y+=u.pop(),J(y,m);break;case 22:u.length>1&&!h&&(G=u.shift()+T,h=!0),y+=u.pop(),J(y,m);break;case 23:ie();break;case 24:for(;u.length>2;)i=y+u.shift(),a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),y=o+u.shift(),m=c+u.shift(),l.curveTo(i,a,o,c,y,m);y+=u.shift(),m+=u.shift(),l.lineTo(y,m);break;case 25:for(;u.length>6;)y+=u.shift(),m+=u.shift(),l.lineTo(y,m);i=y+u.shift(),a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),y=o+u.shift(),m=c+u.shift(),l.curveTo(i,a,o,c,y,m);break;case 26:for(u.length&1&&(y+=u.shift());u.length>0;)i=y,a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),y=o,m=c+u.shift(),l.curveTo(i,a,o,c,y,m);break;case 27:for(u.length&1&&(m+=u.shift());u.length>0;)i=y+u.shift(),a=m,o=i+u.shift(),c=a+u.shift(),y=o+u.shift(),m=c,l.curveTo(i,a,o,c,y,m);break;case 28:U=D[ce],re=D[ce+1],u.push((U<<24|re<<16)>>16),ce+=2;break;case 29:if(He=u.pop()+t.gsubrsBias,me=t.gsubrs[He],me){if(N>=ki){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}N++,P(me),N--}break;case 30:for(;u.length>0&&(i=y,a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),y=o+u.shift(),m=c+(u.length===1?u.shift():0),l.curveTo(i,a,o,c,y,m),u.length!==0);)i=y+u.shift(),a=m,o=i+u.shift(),c=a+u.shift(),m=c+u.shift(),y=o+(u.length===1?u.shift():0),l.curveTo(i,a,o,c,y,m);break;case 31:for(;u.length>0&&(i=y+u.shift(),a=m,o=i+u.shift(),c=a+u.shift(),m=c+u.shift(),y=o+(u.length===1?u.shift():0),l.curveTo(i,a,o,c,y,m),u.length!==0);)i=y,a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),y=o+u.shift(),m=c+(u.length===1?u.shift():0),l.curveTo(i,a,o,c,y,m);break;default:we<32?console.log("Glyph "+e.index+": unknown operator "+we):we<247?u.push(we-139):we<251?(U=D[ce],ce+=1,u.push((we-247)*256+U+108)):we<255?(U=D[ce],ce+=1,u.push(-(we-251)*256-U-108)):(U=D[ce],re=D[ce+1],Ae=D[ce+2],at=D[ce+3],ce+=4,u.push((U<<24|re<<16|Ae<<8|at)/65536))}}}return P(n),t.variation&&s&&(l.commands=l.commands.map(D=>{const U=Object.keys(D);for(let re=0;re<U.length;re++){const Ae=U[re];Ae!=="type"&&(D[Ae]=Math.round(D[Ae]))}return D})),h&&(e.advanceWidth=G),l}function Oi(t,e,n,r,s){const i=[];let a;const o=new _.Parser(t,e),c=o.parseCard8();if(c===0)for(let l=0;l<n;l++){if(a=o.parseCard8(),a>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+r+")");i.push(a)}else if(c===3||s>1&&c===4){const l=c===4?o.parseULong():o.parseCard16();let u=c===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${c} range has bad initial GID ${u}`);let f;for(let h=0;h<l;h++){if(a=c===4?o.parseUShort():o.parseCard8(),f=c===4?o.parseULong():o.parseCard16(),a>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+r+")");if(f>n)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${f}`);for(;u<f;u++)i.push(a);u=f}if(f!==n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+f)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+c);return i}function jl(t,e,n,r){let s;const i=Dl(t,e);i.formatMajor===2?s=n.tables.cff2={}:s=n.tables.cff={};const a=i.formatMajor>1?null:Ke(t,i.endOffset,_.bytesToString),o=i.formatMajor>1?null:Ke(t,a.endOffset),c=i.formatMajor>1?null:Ke(t,o.endOffset,_.bytesToString),l=Ke(t,i.formatMajor>1?e+i.size+i.topDictLength:c.endOffset,void 0,i.formatMajor);n.gsubrs=l.objects,n.gsubrsBias=Mn(n.gsubrs);let u;if(i.formatMajor>1){const h=e+i.size,p=_.getBytes(t,h,h+i.topDictLength);u=Ar(t,0,[p],void 0,i.formatMajor)[0]}else{const h=Ar(t,e,o.objects,c.objects,i.formatMajor);if(h.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+h.length);u=h[0]}if(s.topDict=u,u._privateDict&&(n.defaultWidthX=u._privateDict.defaultWidthX,n.nominalWidthX=u._privateDict.nominalWidthX),i.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(n.isCIDFont=!0),i.formatMajor>1){let h=u.fdArray,p=u.fdSelect;if(!h)throw new Error("This is a CFF2 font, but FDArray information is missing");const y=Ke(t,e+h,null,i.formatMajor),m=Hl(t,e,y.objects);u._fdArray=m,p&&(u._fdSelect=Oi(t,e+p,n.numGlyphs,m.length,i.formatMajor))}else if(n.isCIDFont){let h=u.fdArray,p=u.fdSelect;if(h===0||p===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;const y=Ke(t,h),m=Ar(t,e,y.objects,c.objects,i.formatMajor);u._fdArray=m,p+=e,u._fdSelect=Oi(t,p,n.numGlyphs,m.length,i.formatMajor)}if(i.formatMajor<2){const h=e+u.private[1],p=Er(t,h,u.private[0],c.objects,i.formatMajor);if(n.defaultWidthX=p.defaultWidthX,n.nominalWidthX=p.nominalWidthX,p.subrs!==0){const y=h+p.subrs,m=Ke(t,y);n.subrs=m.objects,n.subrsBias=Mn(n.subrs)}else n.subrs=[],n.subrsBias=0}let f;if(r.lowMemory?(f=Ll(t,e+u.charStrings,i.formatMajor),n.nGlyphs=f.offsets.length-(i.formatMajor>1?1:0)):(f=Ke(t,e+u.charStrings,null,i.formatMajor),n.nGlyphs=f.objects.length),i.formatMajor>1&&n.tables.maxp&&n.nGlyphs!==n.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${n.nGlyphs}) must correspond to the glyph count in the maxp table (${n.tables.maxp.numGlyphs})`),i.formatMajor<2){let h=[],p=[];u.charset===0?h=dl:u.charset===1?h=gl:u.charset===2?h=ml:h=zl(t,e+u.charset,n.nGlyphs,c.objects,n.isCIDFont),u.encoding===0?p=wr:u.encoding===1?p=yl:p=Wl(t,e+u.encoding),n.cffEncoding=new vi(p,h),n.encoding=n.encoding||n.cffEncoding}if(n.glyphs=new Xe.GlyphSet(n),r.lowMemory)n._push=function(h){const p=Il(h,f.offsets,t,e+u.charStrings,void 0,i.formatMajor);n.glyphs.push(h,Xe.cffGlyphLoader(n,h,Or,p,i.formatMajor))};else for(let h=0;h<n.nGlyphs;h+=1){const p=f.objects[h];n.glyphs.push(h,Xe.cffGlyphLoader(n,h,Or,p,i.formatMajor))}if(u.vstore){const h=new _.Parser(t,e+u.vstore);u._vstore=h.parseVariationStore()}}function Li(t,e){let n,r=On.indexOf(t);return r>=0&&(n=r),r=e.indexOf(t),r>=0?n=r+On.length:(n=On.length+e.length,e.push(t)),n}function ql(){return new L.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function $l(t){const e=new L.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let n=0;n<t.length;n+=1)e.names.push({name:"name_"+n,type:"NAME",value:t[n]});return e}function Ii(t,e,n){const r={};for(let s=0;s<t.length;s+=1){const i=t[s];let a=e[i.name];a!==void 0&&!Ci(a,i.value)&&(i.type==="SID"&&(a=Li(a,n)),r[i.op]={name:i.name,type:i.type,value:a})}return r}function Mi(t,e,n){const r=new L.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return r.dict=Ii(Fi,t,e),r}function Ri(t){const e=new L.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:t}],e}function Yl(t){const e=new L.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(let n=0;n<t.length;n+=1)e.strings.push({name:"string_"+n,type:"STRING",value:t[n]});return e}function Xl(){return new L.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Kl(t,e){const n=new L.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let r=0;r<t.length;r+=1){const s=t[r],i=Li(s,e);n.fields.push({name:"glyph_"+r,type:"SID",value:i})}return n}function Zl(t,e){const n=[],r=t.path;n.push({name:"width",type:"NUMBER",value:t.advanceWidth});let s=0,i=0;for(let a=0;a<r.commands.length;a+=1){let o,c,l=r.commands[a];if(l.type==="Q"){const u=.3333333333333333,f=2/3;l={type:"C",x:l.x,y:l.y,x1:Math.round(u*s+f*l.x1),y1:Math.round(u*i+f*l.y1),x2:Math.round(u*l.x+f*l.x1),y2:Math.round(u*l.y+f*l.y1)}}if(l.type==="M")o=Math.round(l.x-s),c=Math.round(l.y-i),n.push({name:"dx",type:"NUMBER",value:o}),n.push({name:"dy",type:"NUMBER",value:c}),n.push({name:"rmoveto",type:"OP",value:21}),s=Math.round(l.x),i=Math.round(l.y);else if(l.type==="L")o=Math.round(l.x-s),c=Math.round(l.y-i),n.push({name:"dx",type:"NUMBER",value:o}),n.push({name:"dy",type:"NUMBER",value:c}),n.push({name:"rlineto",type:"OP",value:5}),s=Math.round(l.x),i=Math.round(l.y);else if(l.type==="C"){const u=Math.round(l.x1-s),f=Math.round(l.y1-i),h=Math.round(l.x2-l.x1),p=Math.round(l.y2-l.y1);o=Math.round(l.x-l.x2),c=Math.round(l.y-l.y2),n.push({name:"dx1",type:"NUMBER",value:u}),n.push({name:"dy1",type:"NUMBER",value:f}),n.push({name:"dx2",type:"NUMBER",value:h}),n.push({name:"dy2",type:"NUMBER",value:p}),n.push({name:"dx",type:"NUMBER",value:o}),n.push({name:"dy",type:"NUMBER",value:c}),n.push({name:"rrcurveto",type:"OP",value:8}),s=Math.round(l.x),i=Math.round(l.y)}}return n.push({name:"endchar",type:"OP",value:14}),n}function Jl(t,e){const n=new L.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let r=0;r<t.length;r+=1){const s=t.get(r),i=Zl(s);n.charStrings.push({name:s.name,type:"CHARSTRING",value:i})}return n}function Ql(t,e,n){const r=new L.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return r.dict=Ii(Ei,t,e),r}function eu(t,e){const n=new L.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),r=1/e.unitsPerEm,s={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[r,0,0,r,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},i=e&&e.topDict||{};i.paintType&&(s.paintType=i.paintType,s.strokeWidth=i.strokeWidth||0);const a={},o=[];let c;for(let h=1;h<t.length;h+=1)c=t.get(h),o.push(c.name);const l=[];n.header=ql(),n.nameIndex=$l([e.postScriptName]);let u=Mi(s,l);n.topDictIndex=Ri(u),n.globalSubrIndex=Xl(),n.charsets=Kl(o,l),n.charStringsIndex=Jl(t),n.privateDict=Ql(a,l),n.stringIndex=Yl(l);const f=n.header.sizeOf()+n.nameIndex.sizeOf()+n.topDictIndex.sizeOf()+n.stringIndex.sizeOf()+n.globalSubrIndex.sizeOf();return s.charset=f,s.encoding=0,s.charStrings=s.charset+n.charsets.sizeOf(),s.private[1]=s.charStrings+n.charStringsIndex.sizeOf(),u=Mi(s,l),n.topDictIndex=Ri(u),n}var Lr={parse:jl,make:eu};function tu(t,e){const n={},r=new _.Parser(t,e);return n.version=r.parseVersion(),n.fontRevision=Math.round(r.parseFixed()*1e3)/1e3,n.checkSumAdjustment=r.parseULong(),n.magicNumber=r.parseULong(),z.argument(n.magicNumber===1594834165,"Font header has wrong magic number."),n.flags=r.parseUShort(),n.unitsPerEm=r.parseUShort(),n.created=r.parseLongDateTime(),n.modified=r.parseLongDateTime(),n.xMin=r.parseShort(),n.yMin=r.parseShort(),n.xMax=r.parseShort(),n.yMax=r.parseShort(),n.macStyle=r.parseUShort(),n.lowestRecPPEM=r.parseUShort(),n.fontDirectionHint=r.parseShort(),n.indexToLocFormat=r.parseShort(),n.glyphDataFormat=r.parseShort(),n}function nu(t){const e=Math.round(new Date().getTime()/1e3)+2082844800;let n=e,r=t.macStyle||0;return t.createdTimestamp&&(n=t.createdTimestamp+2082844800),new L.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:n},{name:"modified",type:"LONGDATETIME",value:e},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:r},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],t)}var Bi={parse:tu,make:nu};function ru(t,e){const n={},r=new _.Parser(t,e);return n.version=r.parseVersion(),n.ascender=r.parseShort(),n.descender=r.parseShort(),n.lineGap=r.parseShort(),n.advanceWidthMax=r.parseUShort(),n.minLeftSideBearing=r.parseShort(),n.minRightSideBearing=r.parseShort(),n.xMaxExtent=r.parseShort(),n.caretSlopeRise=r.parseShort(),n.caretSlopeRun=r.parseShort(),n.caretOffset=r.parseShort(),r.relativeOffset+=8,n.metricDataFormat=r.parseShort(),n.numberOfHMetrics=r.parseUShort(),n}function su(t){return new L.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],t)}var Di={parse:ru,make:su};function iu(t,e,n,r,s){let i,a;const o=new _.Parser(t,e);for(let c=0;c<r;c+=1){c<n&&(i=o.parseUShort(),a=o.parseShort());const l=s.get(c);l.advanceWidth=i,l.leftSideBearing=a}}function au(t,e,n,r,s){t._hmtxTableData={};let i,a;const o=new _.Parser(e,n);for(let c=0;c<s;c+=1)c<r&&(i=o.parseUShort(),a=o.parseShort()),t._hmtxTableData[c]={advanceWidth:i,leftSideBearing:a}}function ou(t,e,n,r,s,i,a){a.lowMemory?au(t,e,n,r,s):iu(e,n,r,s,i)}function cu(t){const e=new L.Table("hmtx",[]);for(let n=0;n<t.length;n+=1){const r=t.get(n),s=r.advanceWidth||0,i=r.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+n,type:"USHORT",value:s}),e.fields.push({name:"leftSideBearing_"+n,type:"SHORT",value:i})}return e}var _i={parse:ou,make:cu};function lu(t){const e=new L.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:t.length}]);let n="";const r=12+t.length*4;for(let s=0;s<t.length;++s){let i=n.indexOf(t[s]);i<0&&(i=n.length,n+=t[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:r+i}),e.fields.push({name:"length "+s,type:"USHORT",value:t[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:n}),e}function uu(t,e){const n=new _.Parser(t,e),r=n.parseULong();z.argument(r===1,"Unsupported ltag table version."),n.skip("uLong",1);const s=n.parseULong(),i=[];for(let a=0;a<s;a++){let o="";const c=e+n.parseUShort(),l=n.parseUShort();for(let u=c;u<c+l;++u)o+=String.fromCharCode(t.getInt8(u));i.push(o)}return i}var Ui={make:lu,parse:uu};function hu(t,e){const n={},r=new _.Parser(t,e);return n.version=r.parseVersion(),n.numGlyphs=r.parseUShort(),n.version===1&&(n.maxPoints=r.parseUShort(),n.maxContours=r.parseUShort(),n.maxCompositePoints=r.parseUShort(),n.maxCompositeContours=r.parseUShort(),n.maxZones=r.parseUShort(),n.maxTwilightPoints=r.parseUShort(),n.maxStorage=r.parseUShort(),n.maxFunctionDefs=r.parseUShort(),n.maxInstructionDefs=r.parseUShort(),n.maxStackElements=r.parseUShort(),n.maxSizeOfInstructions=r.parseUShort(),n.maxComponentElements=r.parseUShort(),n.maxComponentDepth=r.parseUShort()),n}function fu(t){return new L.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:t}])}var Pi={parse:hu,make:fu},Ir=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function pu(t){for(let e=0;e<Ir.length;e+=1){const n=Ir[e];if(t>=n.begin&&t<n.end)return e}return-1}function du(t,e){const n={},r=new _.Parser(t,e);n.version=r.parseUShort(),n.xAvgCharWidth=r.parseShort(),n.usWeightClass=r.parseUShort(),n.usWidthClass=r.parseUShort(),n.fsType=r.parseUShort(),n.ySubscriptXSize=r.parseShort(),n.ySubscriptYSize=r.parseShort(),n.ySubscriptXOffset=r.parseShort(),n.ySubscriptYOffset=r.parseShort(),n.ySuperscriptXSize=r.parseShort(),n.ySuperscriptYSize=r.parseShort(),n.ySuperscriptXOffset=r.parseShort(),n.ySuperscriptYOffset=r.parseShort(),n.yStrikeoutSize=r.parseShort(),n.yStrikeoutPosition=r.parseShort(),n.sFamilyClass=r.parseShort(),n.panose=[];for(let s=0;s<10;s++)n.panose[s]=r.parseByte();return n.ulUnicodeRange1=r.parseULong(),n.ulUnicodeRange2=r.parseULong(),n.ulUnicodeRange3=r.parseULong(),n.ulUnicodeRange4=r.parseULong(),n.achVendID=String.fromCharCode(r.parseByte(),r.parseByte(),r.parseByte(),r.parseByte()),n.fsSelection=r.parseUShort(),n.usFirstCharIndex=r.parseUShort(),n.usLastCharIndex=r.parseUShort(),n.sTypoAscender=r.parseShort(),n.sTypoDescender=r.parseShort(),n.sTypoLineGap=r.parseShort(),n.usWinAscent=r.parseUShort(),n.usWinDescent=r.parseUShort(),n.version>=1&&(n.ulCodePageRange1=r.parseULong(),n.ulCodePageRange2=r.parseULong()),n.version>=2&&(n.sxHeight=r.parseShort(),n.sCapHeight=r.parseShort(),n.usDefaultChar=r.parseUShort(),n.usBreakChar=r.parseUShort(),n.usMaxContent=r.parseUShort()),n}function gu(t){return new L.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],t)}var Mr={parse:du,make:gu,unicodeRanges:Ir,getUnicodeRange:pu};function mu(t,e){const n={},r=new _.Parser(t,e);switch(n.version=r.parseVersion(),n.italicAngle=r.parseFixed(),n.underlinePosition=r.parseShort(),n.underlineThickness=r.parseShort(),n.isFixedPitch=r.parseULong(),n.minMemType42=r.parseULong(),n.maxMemType42=r.parseULong(),n.minMemType1=r.parseULong(),n.maxMemType1=r.parseULong(),n.version){case 1:n.names=St.slice();break;case 2:n.numberOfGlyphs=r.parseUShort(),n.glyphNameIndex=new Array(n.numberOfGlyphs);for(let s=0;s<n.numberOfGlyphs;s++)n.glyphNameIndex[s]=r.parseUShort();n.names=[];for(let s=0;s<n.numberOfGlyphs;s++)if(n.glyphNameIndex[s]>=St.length){const i=r.parseChar();n.names.push(r.parseString(i))}break;case 2.5:n.numberOfGlyphs=r.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(let s=0;s<n.numberOfGlyphs;s++)n.offset[s]=r.parseChar();break}return n}function yu(t){const{italicAngle:e=Math.round((t.italicAngle||0)*65536),underlinePosition:n=0,underlineThickness:r=0,isFixedPitch:s=0,minMemType42:i=0,maxMemType42:a=0,minMemType1:o=0,maxMemType1:c=0}=t.tables.post||{};return new L.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:e},{name:"underlinePosition",type:"FWORD",value:n},{name:"underlineThickness",type:"FWORD",value:r},{name:"isFixedPitch",type:"ULONG",value:s},{name:"minMemType42",type:"ULONG",value:i},{name:"maxMemType42",type:"ULONG",value:a},{name:"minMemType1",type:"ULONG",value:o},{name:"maxMemType1",type:"ULONG",value:c}])}var Ni={parse:mu,make:yu},Ve=new Array(9);Ve[1]=function(){const e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{substFormat:1,coverage:this.parsePointer(k.coverage),deltaGlyphId:this.parseShort()};if(n===2)return{substFormat:2,coverage:this.parsePointer(k.coverage),substitute:this.parseOffset16List()};z.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")},Ve[2]=function(){const e=this.parseUShort();return z.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(k.coverage),sequences:this.parseListOfLists()}},Ve[3]=function(){const e=this.parseUShort();return z.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(k.coverage),alternateSets:this.parseListOfLists()}},Ve[4]=function(){const e=this.parseUShort();return z.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(k.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var _t={sequenceIndex:k.uShort,lookupListIndex:k.uShort};Ve[5]=function(){const e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{substFormat:n,coverage:this.parsePointer(k.coverage),ruleSets:this.parseListOfLists(function(){const r=this.parseUShort(),s=this.parseUShort();return{input:this.parseUShortList(r-1),lookupRecords:this.parseRecordList(s,_t)}})};if(n===2)return{substFormat:n,coverage:this.parsePointer(k.coverage),classDef:this.parsePointer(k.classDef),classSets:this.parseListOfLists(function(){const r=this.parseUShort(),s=this.parseUShort();return{classes:this.parseUShortList(r-1),lookupRecords:this.parseRecordList(s,_t)}})};if(n===3){const r=this.parseUShort(),s=this.parseUShort();return{substFormat:n,coverages:this.parseList(r,k.pointer(k.coverage)),lookupRecords:this.parseRecordList(s,_t)}}z.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},Ve[6]=function(){const e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{substFormat:1,coverage:this.parsePointer(k.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(_t)}})};if(n===2)return{substFormat:2,coverage:this.parsePointer(k.coverage),backtrackClassDef:this.parsePointer(k.classDef),inputClassDef:this.parsePointer(k.classDef),lookaheadClassDef:this.parsePointer(k.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(_t)}})};if(n===3)return{substFormat:3,backtrackCoverage:this.parseList(k.pointer(k.coverage)),inputCoverage:this.parseList(k.pointer(k.coverage)),lookaheadCoverage:this.parseList(k.pointer(k.coverage)),lookupRecords:this.parseRecordList(_t)};z.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},Ve[7]=function(){const e=this.parseUShort();z.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");const n=this.parseUShort(),r=new k(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:n,extension:Ve[n].call(r)}},Ve[8]=function(){const e=this.parseUShort();return z.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(k.coverage),backtrackCoverage:this.parseList(k.pointer(k.coverage)),lookaheadCoverage:this.parseList(k.pointer(k.coverage)),substitutes:this.parseUShortList()}};function bu(t,e){e=e||0;const n=new k(t,e),r=n.parseVersion(1);return z.argument(r===1||r===1.1,"Unsupported GSUB table version."),r===1?{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(Ve)}:{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(Ve),variations:n.parseFeatureVariationsList()}}var Tt=new Array(9);Tt[1]=function(e){if(e.substFormat===1)return new L.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)},{name:"deltaGlyphID",type:"SHORT",value:e.deltaGlyphId}]);if(e.substFormat===2)return new L.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)}].concat(L.ushortList("substitute",e.substitute)));z.fail("Lookup type 1 substFormat must be 1 or 2.")},Tt[2]=function(e){return z.assert(e.substFormat===1,"Lookup type 2 substFormat must be 1."),new L.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)}].concat(L.tableList("seqSet",e.sequences,function(n){return new L.Table("sequenceSetTable",L.ushortList("sequence",n))})))},Tt[3]=function(e){return z.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new L.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)}].concat(L.tableList("altSet",e.alternateSets,function(n){return new L.Table("alternateSetTable",L.ushortList("alternate",n))})))},Tt[4]=function(e){return z.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new L.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)}].concat(L.tableList("ligSet",e.ligatureSets,function(n){return new L.Table("ligatureSetTable",L.tableList("ligature",n,function(r){return new L.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:r.ligGlyph}].concat(L.ushortList("component",r.components,r.components.length+1)))}))})))},Tt[5]=function(e){if(e.substFormat===1)return new L.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)}].concat(L.tableList("sequenceRuleSet",e.ruleSets,function(n){return n?new L.Table("sequenceRuleSetTable",L.tableList("sequenceRule",n,function(r){let s=L.ushortList("seqLookup",[],r.lookupRecords.length).concat(L.ushortList("inputSequence",r.input,r.input.length+1));[s[0],s[1]]=[s[1],s[0]];for(let i=0;i<r.lookupRecords.length;i++){const a=r.lookupRecords[i];s=s.concat({name:"sequenceIndex"+i,type:"USHORT",value:a.sequenceIndex}).concat({name:"lookupListIndex"+i,type:"USHORT",value:a.lookupListIndex})}return new L.Table("sequenceRuleTable",s)})):new L.Table("NULL",null)})));if(e.substFormat===2)return new L.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)},{name:"classDef",type:"TABLE",value:new L.ClassDef(e.classDef)}].concat(L.tableList("classSeqRuleSet",e.classSets,function(n){return n?new L.Table("classSeqRuleSetTable",L.tableList("classSeqRule",n,function(r){let s=L.ushortList("classes",r.classes,r.classes.length+1).concat(L.ushortList("seqLookupCount",[],r.lookupRecords.length));for(let i=0;i<r.lookupRecords.length;i++){const a=r.lookupRecords[i];s=s.concat({name:"sequenceIndex"+i,type:"USHORT",value:a.sequenceIndex}).concat({name:"lookupListIndex"+i,type:"USHORT",value:a.lookupListIndex})}return new L.Table("classSeqRuleTable",s)})):new L.Table("NULL",null)})));if(e.substFormat===3){let n=[{name:"substFormat",type:"USHORT",value:e.substFormat}];n.push({name:"inputGlyphCount",type:"USHORT",value:e.coverages.length}),n.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length});for(let s=0;s<e.coverages.length;s++){const i=e.coverages[s];n.push({name:"inputCoverage"+s,type:"TABLE",value:new L.Coverage(i)})}for(let s=0;s<e.lookupRecords.length;s++){const i=e.lookupRecords[s];n=n.concat({name:"sequenceIndex"+s,type:"USHORT",value:i.sequenceIndex}).concat({name:"lookupListIndex"+s,type:"USHORT",value:i.lookupListIndex})}return new L.Table("contextualSubstitutionTable",n)}z.assert(!1,"lookup type 5 format must be 1, 2 or 3.")},Tt[6]=function(e){if(e.substFormat===1)return new L.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)}].concat(L.tableList("chainRuleSet",e.chainRuleSets,function(r){return new L.Table("chainRuleSetTable",L.tableList("chainRule",r,function(s){let i=L.ushortList("backtrackGlyph",s.backtrack,s.backtrack.length).concat(L.ushortList("inputGlyph",s.input,s.input.length+1)).concat(L.ushortList("lookaheadGlyph",s.lookahead,s.lookahead.length)).concat(L.ushortList("substitution",[],s.lookupRecords.length));for(let a=0;a<s.lookupRecords.length;a++){const o=s.lookupRecords[a];i=i.concat({name:"sequenceIndex"+a,type:"USHORT",value:o.sequenceIndex}).concat({name:"lookupListIndex"+a,type:"USHORT",value:o.lookupListIndex})}return new L.Table("chainRuleTable",i)}))})));if(e.substFormat===2)z.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(e.substFormat===3){let n=[{name:"substFormat",type:"USHORT",value:e.substFormat}];n.push({name:"backtrackGlyphCount",type:"USHORT",value:e.backtrackCoverage.length});for(let s=0;s<e.backtrackCoverage.length;s++){const i=e.backtrackCoverage[s];n.push({name:"backtrackCoverage"+s,type:"TABLE",value:new L.Coverage(i)})}n.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length});for(let s=0;s<e.inputCoverage.length;s++){const i=e.inputCoverage[s];n.push({name:"inputCoverage"+s,type:"TABLE",value:new L.Coverage(i)})}n.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length});for(let s=0;s<e.lookaheadCoverage.length;s++){const i=e.lookaheadCoverage[s];n.push({name:"lookaheadCoverage"+s,type:"TABLE",value:new L.Coverage(i)})}n.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length});for(let s=0;s<e.lookupRecords.length;s++){const i=e.lookupRecords[s];n=n.concat({name:"sequenceIndex"+s,type:"USHORT",value:i.sequenceIndex}).concat({name:"lookupListIndex"+s,type:"USHORT",value:i.lookupListIndex})}return new L.Table("chainContextTable",n)}z.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function xu(t){return new L.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new L.ScriptList(t.scripts)},{name:"features",type:"TABLE",value:new L.FeatureList(t.features)},{name:"lookups",type:"TABLE",value:new L.LookupList(t.lookups,Tt)}])}var Gi={parse:bu,make:xu};function vu(t,e){const n=new _.Parser(t,e),r=n.parseULong();z.argument(r===1,"Unsupported META table version."),n.parseULong(),n.parseULong();const s=n.parseULong(),i={};for(let a=0;a<s;a++){const o=n.parseTag(),c=n.parseULong(),l=n.parseULong();if(o==="appl"||o==="bild")continue;const u=It.UTF8(t,e+c,l);i[o]=u}return i}function Su(t){const e=Object.keys(t).length;let n="";const r=16+e*12,s=new L.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:r},{name:"numTags",type:"ULONG",value:e}]);for(let i in t){const a=n.length;n+=t[i],s.fields.push({name:"tag "+i,type:"TAG",value:i}),s.fields.push({name:"offset "+i,type:"ULONG",value:r+a}),s.fields.push({name:"length "+i,type:"ULONG",value:t[i].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:n}),s}var Hi={parse:vu,make:Su};function wu(t,e){const n=new k(t,e),r=n.parseUShort();r!==0&&console.warn("Only COLRv0 is currently fully supported. A subset of color glyphs might be available in this font if provided in the v0 format.");const s=n.parseUShort(),i=n.parseOffset32(),a=n.parseOffset32(),o=n.parseUShort();n.relativeOffset=i;const c=n.parseRecordList(s,{glyphID:k.uShort,firstLayerIndex:k.uShort,numLayers:k.uShort});n.relativeOffset=a;const l=n.parseRecordList(o,{glyphID:k.uShort,paletteIndex:k.uShort});return{version:r,baseGlyphRecords:c,layerRecords:l}}function Tu({version:t=0,baseGlyphRecords:e=[],layerRecords:n=[]}){z.argument(t===0,"Only COLRv0 supported.");const r=14,s=r+e.length*6;return new L.Table("COLR",[{name:"version",type:"USHORT",value:t},{name:"numBaseGlyphRecords",type:"USHORT",value:e.length},{name:"baseGlyphRecordsOffset",type:"ULONG",value:r},{name:"layerRecordsOffset",type:"ULONG",value:s},{name:"numLayerRecords",type:"USHORT",value:n.length},...e.map((i,a)=>[{name:"glyphID_"+a,type:"USHORT",value:i.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:i.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:i.numLayers}]).flat(),...n.map((i,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:i.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:i.paletteIndex}]).flat()])}var zi={parse:wu,make:Tu};function Cu(t,e){return[{name:"tag_"+t,type:"TAG",value:e.tag},{name:"minValue_"+t,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+t,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+t,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+t,type:"USHORT",value:0},{name:"nameID_"+t,type:"USHORT",value:e.axisNameID}]}function ku(t,e,n){const r={},s=new _.Parser(t,e);r.tag=s.parseTag(),r.minValue=s.parseFixed(),r.defaultValue=s.parseFixed(),r.maxValue=s.parseFixed(),s.skip("uShort",1);const i=s.parseUShort();return r.axisNameID=i,r.name=An(n,i),r}function Fu(t,e,n,r={}){const s=[{name:"nameID_"+t,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+t,type:"USHORT",value:0}];for(let i=0;i<n.length;++i){const a=n[i].tag;s.push({name:"axis_"+t+" "+a,type:"FIXED",value:e.coordinates[a]<<16})}return r&&r.postScriptNameID&&s.push({name:"postScriptNameID_",type:"USHORT",value:e.postScriptNameID!==void 0?e.postScriptNameID:65535}),s}function Eu(t,e,n,r,s){const i={},a=new _.Parser(t,e),o=a.parseUShort();i.subfamilyNameID=o,i.name=An(r,o,[2,17]),a.skip("uShort",1),i.coordinates={};for(let l=0;l<n.length;++l)i.coordinates[n[l].tag]=a.parseFixed();if(a.relativeOffset===s)return i.postScriptNameID=void 0,i.postScriptName=void 0,i;const c=a.parseUShort();return i.postScriptNameID=c==65535?void 0:c,i.postScriptName=i.postScriptNameID!==void 0?An(r,c,[6]):"",i}function Au(t,e){const n=new L.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:t.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:t.instances.length},{name:"instanceSize",type:"USHORT",value:4+t.axes.length*4}]);n.offsetToData=n.sizeOf();for(let s=0;s<t.axes.length;s++)n.fields=n.fields.concat(Cu(s,t.axes[s]));const r={};for(let s=0;s<t.instances.length;s++)if(t.instances[s].postScriptNameID!==void 0){n.instanceSize+=2,r.postScriptNameID=!0;break}for(let s=0;s<t.instances.length;s++)n.fields=n.fields.concat(Fu(s,t.instances[s],t.axes,r));return n}function Ou(t,e,n){const r=new _.Parser(t,e),s=r.parseULong();z.argument(s===65536,"Unsupported fvar table version.");const i=r.parseOffset16();r.skip("uShort",1);const a=r.parseUShort(),o=r.parseUShort(),c=r.parseUShort(),l=r.parseUShort(),u=[];for(let p=0;p<a;p++)u.push(ku(t,e+i+p*o,n));const f=[],h=e+i+a*o;for(let p=0;p<c;p++)f.push(Eu(t,h+p*l,u,n,l));return{axes:u,instances:f}}var Wi={make:Au,parse:Ou},Lu={tag:k.tag,nameID:k.uShort,ordering:k.uShort},Kt=new Array(5);Kt[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}},Kt[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}},Kt[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}},Kt[4]=function(){const e=this.parseUShort();return{flags:this.parseUShort(),valueNameID:this.parseUShort(),axisValues:this.parseList(e,function(){return{axisIndex:this.parseUShort(),value:this.parseFixed()}})}};function Iu(){const t=this.parseUShort(),e=Kt[t],n={format:t};return e===void 0?(console.warn(`Unknown axis value table format ${t}`),n):Object.assign(n,this.parseStruct(e.bind(this)))}function Mu(t,e,n){e||(e=0);const r=new _.Parser(t,e),s=r.parseUShort(),i=r.parseUShort();s!==1&&console.warn(`Unsupported STAT table version ${s}.${i}`);const a=[s,i],o=r.parseUShort(),c=r.parseUShort(),l=r.parseOffset32(),u=r.parseUShort(),f=r.parseOffset32(),h=s>1||i>0?r.parseUShort():void 0;n!==void 0&&z.argument(c>=n.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&z.argument(c>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const p=[];for(let b=0;b<c;b++)r.offset=e+l,r.relativeOffset=b*o,p.push(r.parseStruct(Lu));r.offset=e,r.relativeOffset=f;const y=r.parseUShortList(u),m=[];for(let b=0;b<u;b++)r.offset=e+f,r.relativeOffset=y[b],m.push(Iu.apply(r));return{version:a,axes:p,values:m,elidedFallbackNameID:h}}var Zt=new Array(5);Zt[1]=function(e,n){return[{name:`format${e}`,type:"USHORT",value:1},{name:`axisIndex${e}`,type:"USHORT",value:n.axisIndex},{name:`flags${e}`,type:"USHORT",value:n.flags},{name:`valueNameID${e}`,type:"USHORT",value:n.valueNameID},{name:`value${e}`,type:"FLOAT",value:n.value}]},Zt[2]=function(e,n){return[{name:`format${e}`,type:"USHORT",value:2},{name:`axisIndex${e}`,type:"USHORT",value:n.axisIndex},{name:`flags${e}`,type:"USHORT",value:n.flags},{name:`valueNameID${e}`,type:"USHORT",value:n.valueNameID},{name:`nominalValue${e}`,type:"FLOAT",value:n.nominalValue},{name:`rangeMinValue${e}`,type:"FLOAT",value:n.rangeMinValue},{name:`rangeMaxValue${e}`,type:"FLOAT",value:n.rangeMaxValue}]},Zt[3]=function(e,n){return[{name:`format${e}`,type:"USHORT",value:3},{name:`axisIndex${e}`,type:"USHORT",value:n.axisIndex},{name:`flags${e}`,type:"USHORT",value:n.flags},{name:`valueNameID${e}`,type:"USHORT",value:n.valueNameID},{name:`value${e}`,type:"FLOAT",value:n.value},{name:`linkedValue${e}`,type:"FLOAT",value:n.linkedValue}]},Zt[4]=function(e,n){let r=[{name:`format${e}`,type:"USHORT",value:4},{name:`axisCount${e}`,type:"USHORT",value:n.axisValues.length},{name:`flags${e}`,type:"USHORT",value:n.flags},{name:`valueNameID${e}`,type:"USHORT",value:n.valueNameID}];for(let s=0;s<n.axisValues.length;s++)r=r.concat([{name:`format${e}axisIndex${s}`,type:"USHORT",value:n.axisValues[s].axisIndex},{name:`format${e}value${s}`,type:"FLOAT",value:n.axisValues[s].value}]);return r};function Ru(t,e){return new L.Record("axisRecord_"+t,[{name:"axisTag_"+t,type:"TAG",value:e.tag},{name:"axisNameID_"+t,type:"USHORT",value:e.nameID},{name:"axisOrdering_"+t,type:"USHORT",value:e.ordering}])}function Bu(t,e){const n=e.format,r=Zt[n];z.argument(r!==void 0,`Unknown axis value table format ${n}`);const s=r(t,e);return new L.Table("axisValueTable_"+t,s)}function Du(t){const e=new L.Table("STAT",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:2},{name:"designAxisSize",type:"USHORT",value:8},{name:"designAxisCount",type:"USHORT",value:t.axes.length},{name:"designAxesOffset",type:"ULONG",value:0},{name:"axisValueCount",type:"USHORT",value:t.values.length},{name:"offsetToAxisValueOffsets",type:"ULONG",value:0},{name:"elidedFallbackNameID",type:"USHORT",value:t.elidedFallbackNameID}]);e.designAxesOffset=e.offsetToAxisValueOffsets=e.sizeOf();for(let i=0;i<t.axes.length;i++){const a=Ru(i,t.axes[i]);e.offsetToAxisValueOffsets+=a.sizeOf(),e.fields=e.fields.concat(a.fields)}const n=[];let r=[],s=t.values.length*2;for(let i=0;i<t.values.length;i++){const a=Bu(i,t.values[i]);n.push({name:"offset_"+i,type:"USHORT",value:s}),s+=a.sizeOf(),r=r.concat(a.fields)}return e.fields=e.fields.concat(n),e.fields=e.fields.concat(r),e}var Vi={make:Du,parse:Mu};function _u(t,e){return new L.Record("axisValueMap_"+t,[{name:"fromCoordinate_"+t,type:"F2DOT14",value:e.fromCoordinate},{name:"toCoordinate_"+t,type:"F2DOT14",value:e.toCoordinate}])}function Uu(t,e){const n=new L.Record("segmentMap_"+t,[{name:"positionMapCount_"+t,type:"USHORT",value:e.axisValueMaps.length}]);let r=[];for(let s=0;s<e.axisValueMaps.length;s++){const i=_u(`${t}_${s}`,e.axisValueMaps[s]);r=r.concat(i.fields)}return n.fields=n.fields.concat(r),n}function Pu(t,e){z.argument(t.axisSegmentMaps.length===e.axes.length,"avar axis count must correspond to fvar axis count");const n=new L.Table("avar",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:0},{name:"reserved",type:"USHORT",value:0},{name:"axisCount",type:"USHORT",value:t.axisSegmentMaps.length}]);for(let r=0;r<t.axisSegmentMaps.length;r++){const s=Uu(r,t.axisSegmentMaps[r]);n.fields=n.fields.concat(s.fields)}return n}function Nu(t,e,n){e||(e=0);const r=new k(t,e),s=r.parseUShort(),i=r.parseUShort();s!==1&&console.warn(`Unsupported avar table version ${s}.${i}`),r.skip("uShort",1);const a=r.parseUShort();z.argument(a===n.axes.length,"avar axis count must correspond to fvar axis count");const o=[];for(let c=0;c<a;c++){const l=[],u=r.parseUShort();for(let f=0;f<u;f++){const h=r.parseF2Dot14(),p=r.parseF2Dot14();l.push({fromCoordinate:h,toCoordinate:p})}o.push({axisValueMaps:l})}return{version:[s,i],axisSegmentMaps:o}}var ji={make:Pu,parse:Nu};function Gu(t,e,n,r){const s=new _.Parser(t,e),i=s.parseTupleVariationStore(s.relativeOffset,n.axes.length,"cvar",r),a=s.parseUShort(),o=s.parseUShort();return a!==1&&console.warn(`Unsupported cvar table version ${a}.${o}`),{version:[a,o],...i}}function Hu(){console.warn("Writing of cvar tables is not yet supported.")}var qi={make:Hu,parse:Gu};function zu(t,e,n,r){const s=new _.Parser(t,e),i=s.parseUShort(),a=s.parseUShort();i!==1&&console.warn(`Unsupported gvar table version ${i}.${a}`);const o=s.parseUShort();o!==n.axes.length&&console.warn(`axisCount ${o} in gvar table does not match the number of axes ${n.axes.length} in the fvar table!`);const c=s.parseUShort(),l=s.parsePointer32(function(){return this.parseTupleRecords(c,o)}),u=s.parseTupleVariationStoreList(o,"gvar",r);return{version:[i,a],sharedTuples:l,glyphVariations:u}}function Wu(){console.warn("Writing of gvar tables is not yet supported.")}var $i={make:Wu,parse:zu};function Vu(t,e){const n={},r=new _.Parser(t,e);n.version=r.parseUShort(),z.argument(n.version<=1,"Unsupported gasp table version."),n.numRanges=r.parseUShort(),n.gaspRanges=[];for(let s=0;s<n.numRanges;s++)n.gaspRanges[s]={rangeMaxPPEM:r.parseUShort(),rangeGaspBehavior:r.parseUShort()};return n}function ju(t){const e=new L.Table("gasp",[{name:"version",type:"USHORT",value:1},{name:"numRanges",type:"USHORT",value:t.numRanges}]);for(let n in t.gaspRanges)e.fields.push({name:"rangeMaxPPEM",type:"USHORT",value:t.gaspRanges[n].rangeMaxPPEM}),e.fields.push({name:"rangeGaspBehavior",type:"USHORT",value:t.gaspRanges[n].rangeGaspBehavior});return e}var Yi={parse:Vu,make:ju};function qu(t,e){const n=new Map,r=t.buffer,s=new k(t,e);if(s.parseUShort()!==0)return n;s.relativeOffset=s.parseOffset32();const a=t.byteOffset+e+s.relativeOffset,o=s.parseUShort(),c=new Map;for(let l=0;l<o;l++){const u=s.parseUShort(),f=s.parseUShort(),h=a+s.parseOffset32(),p=s.parseULong();let y=c.get(h);y===void 0&&(y=new Uint8Array(r,h,p),c.set(h,y));for(let m=u;m<=f;m++)n.set(m,y)}return n}function $u(t){const e=Array.from(t.keys()).sort(),n=[],r=[],s=new Map;let i=0,a={endGlyphID:null};for(let h=0,p=e.length;h<p;h++){const y=e[h],m=t.get(y);let b=s.get(m);b===void 0&&(b=i,r.push(m),s.set(m,b),i+=m.byteLength),y-1===a.endGlyphID&&b===a.svgDocOffset?a.endGlyphID=y:(a={startGlyphID:y,endGlyphID:y,svgDocOffset:b,svgDocLength:m.byteLength},n.push(a))}const o=n.length,c=r.length,l=2+o*12,u=new Array(4+o*4+c);let f=0;u[f++]={name:"version",type:"USHORT",value:0},u[f++]={name:"svgDocumentListOffset",type:"ULONG",value:10},u[f++]={name:"reserved",type:"ULONG",value:0},u[f++]={name:"numEntries",type:"USHORT",value:o};for(let h=0;h<o;h++){const p="documentRecord_"+h,{startGlyphID:y,endGlyphID:m,svgDocOffset:b,svgDocLength:v}=n[h];u[f++]={name:p+"_startGlyphID",type:"USHORT",value:y},u[f++]={name:p+"_endGlyphID",type:"USHORT",value:m},u[f++]={name:p+"_svgDocOffset",type:"ULONG",value:l+b},u[f++]={name:p+"_svgDocLength",type:"ULONG",value:v}}for(let h=0;h<c;h++)u[f++]={name:"svgDoc_"+h,type:"LITERAL",value:r[h]};return new L.Table("SVG ",u)}var Xi={make:$u,parse:qu};function Ki(t){return Math.log(t)/Math.log(2)|0}function Rr(t){for(;t.length%4!==0;)t.push(0);let e=0;for(let n=0;n<t.length;n+=4)e+=(t[n]<<24)+(t[n+1]<<16)+(t[n+2]<<8)+t[n+3];return e%=Math.pow(2,32),e}function Zi(t,e,n,r){return new L.Record("Table Record",[{name:"tag",type:"TAG",value:t!==void 0?t:""},{name:"checkSum",type:"ULONG",value:e!==void 0?e:0},{name:"offset",type:"ULONG",value:n!==void 0?n:0},{name:"length",type:"ULONG",value:r!==void 0?r:0}])}function Ji(t){const e=new L.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);e.tables=t,e.numTables=t.length;const n=Math.pow(2,Ki(e.numTables));e.searchRange=16*n,e.entrySelector=Ki(n),e.rangeShift=e.numTables*16-e.searchRange;const r=[],s=[];let i=e.sizeOf()+Zi().sizeOf()*e.numTables;for(;i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0});for(let a=0;a<t.length;a+=1){const o=t[a];z.argument(o.tableName.length===4,"Table name"+o.tableName+" is invalid.");const c=o.sizeOf(),l=Zi(o.tableName,Rr(o.encode()),i,c);for(r.push({name:l.tag+" Table Record",type:"RECORD",value:l}),s.push({name:o.tableName+" table",type:"RECORD",value:o}),i+=c,z.argument(!isNaN(i),"Something went wrong calculating the offset.");i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0})}return r.sort(function(a,o){return a.value.tag>o.value.tag?1:-1}),e.fields=e.fields.concat(r),e.fields=e.fields.concat(s),e}function Qi(t,e,n){for(let r=0;r<e.length;r+=1){const s=t.charToGlyphIndex(e[r]);if(s>0)return t.glyphs.get(s).getMetrics()}return n}function Yu(t){let e=0;for(let n=0;n<t.length;n+=1)e+=t[n];return e/t.length}function Xu(t){const e=[],n=[],r=[],s=[],i=[],a=[],o=[];let c,l=0,u=0,f=0,h=0,p=0;for(let ee=0;ee<t.glyphs.length;ee+=1){const Se=t.glyphs.get(ee),Oe=Se.unicode|0;if(isNaN(Se.advanceWidth))throw new Error("Glyph "+Se.name+" ("+ee+"): advanceWidth is not a number.");(c>Oe||c===void 0)&&Oe>0&&(c=Oe),l<Oe&&(l=Oe);const Le=Mr.getUnicodeRange(Oe);if(Le<32)u|=1<<Le;else if(Le<64)f|=1<<Le-32;else if(Le<96)h|=1<<Le-64;else if(Le<123)p|=1<<Le-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(Se.name===".notdef")continue;const Ie=Se.getMetrics();e.push(Ie.xMin),n.push(Ie.yMin),r.push(Ie.xMax),s.push(Ie.yMax),a.push(Ie.leftSideBearing),o.push(Ie.rightSideBearing),i.push(Se.advanceWidth)}const y={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,r),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,i),advanceWidthAvg:Yu(i),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};y.ascender=t.ascender,y.descender=t.descender;let m=0;t.weightClass>=600&&(m|=t.macStyleValues.BOLD),t.italicAngle<0&&(m|=t.macStyleValues.ITALIC);const b=Bi.make({flags:3,unitsPerEm:t.unitsPerEm,xMin:y.xMin,yMin:y.yMin,xMax:y.xMax,yMax:y.yMax,lowestRecPPEM:3,macStyle:m,createdTimestamp:t.createdTimestamp}),v=Di.make({ascender:y.ascender,descender:y.descender,advanceWidthMax:y.advanceWidthMax,minLeftSideBearing:y.minLeftSideBearing,minRightSideBearing:y.minRightSideBearing,xMaxExtent:y.maxLeftSideBearing+(y.xMax-y.xMin),numberOfHMetrics:t.glyphs.length}),w=Pi.make(t.glyphs.length),T=Mr.make(Object.assign({xAvgCharWidth:Math.round(y.advanceWidthAvg),usFirstCharIndex:c,usLastCharIndex:l,ulUnicodeRange1:u,ulUnicodeRange2:f,ulUnicodeRange3:h,ulUnicodeRange4:p,sTypoAscender:y.ascender,sTypoDescender:y.descender,sTypoLineGap:0,usWinAscent:y.yMax,usWinDescent:Math.abs(y.yMin),ulCodePageRange1:1,sxHeight:Qi(t,"xyvw",{yMax:Math.round(y.ascender/2)}).yMax,sCapHeight:Qi(t,"HIKLEFJMNTZBDPRAGOQSUVWXY",y).yMax,usDefaultChar:t.hasChar(" ")?32:0,usBreakChar:t.hasChar(" ")?32:0},t.tables.os2)),C=_i.make(t.glyphs),E=yi.make(t.glyphs),R=t.getEnglishName("fontFamily"),N=t.getEnglishName("fontSubfamily"),V=R+" "+N;let Y=t.getEnglishName("postScriptName");Y||(Y=R.replace(/\s/g,"")+"-"+N);const G={};for(let ee in t.names)G[ee]=t.names[ee];G.unicode=G.unicode||{},G.macintosh=G.macintosh||{},G.windows=G.windows||{};const J=t.names.unicode||{},ie=t.names.macintosh||{},P=t.names.windows||{};for(const ee in G){if(G[ee]=G[ee]||{},!G[ee].uniqueID){const Se=t.getEnglishName("manufacturer")||"";G[ee].uniqueID={en:`${Se}: ${V}`}}G[ee].postScriptName||(G[ee].postScriptName={en:Y})}G.unicode.preferredFamily||(G.unicode.preferredFamily=J.fontFamily||ie.fontFamily||P.fontFamily),G.macintosh.preferredFamily||(G.macintosh.preferredFamily=ie.fontFamily||J.fontFamily||P.fontFamily),G.windows.preferredFamily||(G.windows.preferredFamily=P.fontFamily||J.fontFamily||ie.fontFamily),G.unicode.preferredSubfamily||(G.unicode.preferredSubfamily=J.fontSubfamily||ie.fontSubfamily||P.fontSubfamily),G.macintosh.preferredSubfamily||(G.macintosh.preferredSubfamily=ie.fontSubfamily||J.fontSubfamily||P.fontSubfamily),G.windows.preferredSubfamily||(G.windows.preferredSubfamily=P.fontSubfamily||J.fontSubfamily||ie.fontSubfamily);const D=[],U=mi.make(G,D),re=D.length>0?Ui.make(D):void 0,Ae=Ni.make(t),at=Lr.make(t.glyphs,{version:t.getEnglishName("version"),fullName:V,familyName:R,weightName:N,postScriptName:Y,unitsPerEm:t.unitsPerEm,fontBBox:[0,y.yMin,y.ascender,y.advanceWidthMax],topDict:t.tables.cff&&t.tables.cff.topDict||{}}),He=t.metas&&Object.keys(t.metas).length>0?Hi.make(t.metas):void 0,me=[b,v,w,T,U,E,Ae,at,C];re&&me.push(re);const X={gsub:Gi,cpal:Ti,colr:zi,stat:Vi,avar:ji,cvar:qi,fvar:Wi,gvar:$i,gasp:Yi,svg:Xi},ne={avar:[t.tables.fvar],fvar:[t.names]};for(let ee in X){const Se=t.tables[ee];if(Se){const Oe=X[ee].make.call(t,Se,...ne[ee]||[]);Oe&&me.push(Oe)}}He&&me.push(He);const de=Ji(me),ve=de.encode(),ge=Rr(ve),ye=de.fields;let ce=!1;for(let ee=0;ee<ye.length;ee+=1)if(ye[ee].name==="head table"){ye[ee].value.checkSumAdjustment=2981146554-ge,ce=!0;break}if(!ce)throw new Error("Could not find head table with checkSum to adjust.");return de}var Ku={make:Ji,fontToTable:Xu,computeCheckSum:Rr};function Br(t,e){let n=0,r=t.length-1;for(;n<=r;){const s=n+r>>>1,i=t[s].tag;if(i===e)return s;i<e?n=s+1:r=s-1}return-n-1}function ea(t,e){let n=0,r=t.length-1;for(;n<=r;){const s=n+r>>>1,i=t[s];if(i===e)return s;i<e?n=s+1:r=s-1}return-n-1}function ta(t,e){let n,r=0,s=t.length-1;for(;r<=s;){const i=r+s>>>1;n=t[i];const a=n.start;if(a===e)return n;a<e?r=i+1:s=i-1}if(r>0)return n=t[r-1],e>n.end?0:n}function na(t,e){this.font=t,this.tableName=e}na.prototype={searchTag:Br,binSearch:ea,getTable:function(t){let e=this.font.tables[this.tableName];return!e&&t&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let t=this.getTable();return t?t.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let t=this.getTable();if(!t)return;let e=!1;for(let n=0;n<t.scripts.length;n++){const r=t.scripts[n].tag;if(r==="DFLT")return r;r==="latn"&&(e=!0)}if(e)return"latn"},getScriptTable:function(t,e){const n=this.getTable(e);if(n){t=t||"DFLT";const r=n.scripts,s=Br(n.scripts,t);if(s>=0)return r[s].script;if(e){const i={tag:t,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return r.splice(-1-s,0,i),i.script}}},getLangSysTable:function(t,e,n){const r=this.getScriptTable(t,n);if(r){if(!e||e==="dflt"||e==="DFLT")return r.defaultLangSys;const s=Br(r.langSysRecords,e);if(s>=0)return r.langSysRecords[s].langSys;if(n){const i={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return r.langSysRecords.splice(-1-s,0,i),i.langSys}}},getFeatureTable:function(t,e,n,r){const s=this.getLangSysTable(t,e,r);if(s){let i;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let c=0;c<a.length;c++)if(i=o[a[c]],i.tag===n)return i.feature;if(r){const c=o.length;return z.assert(c===0||n>=o[c-1].tag,"Features must be added in alphabetical order."),i={tag:n,feature:{params:0,lookupListIndexes:[]}},o.push(i),a.push(c),i.feature}}},getLookupTables:function(t,e,n,r,s){const i=this.getFeatureTable(t,e,n,s),a=[];if(i){let o;const c=i.lookupListIndexes,l=this.font.tables[this.tableName].lookups;for(let u=0;u<c.length;u++)o=l[c[u]],o.lookupType===r&&a.push(o);if(a.length===0&&s){o={lookupType:r,lookupFlag:0,subtables:[],markFilteringSet:void 0};const u=l.length;return l.push(o),c.push(u),[o]}}return a},getGlyphClass:function(t,e){switch(t.format){case 1:return t.startGlyph<=e&&e<t.startGlyph+t.classes.length?t.classes[e-t.startGlyph]:0;case 2:{const n=ta(t.ranges,e);return n?n.classId:0}}},getCoverageIndex:function(t,e){switch(t.format){case 1:{const n=ea(t.glyphs,e);return n>=0?n:-1}case 2:{const n=ta(t.ranges,e);return n?n.index+e-n.start:-1}}},expandCoverage:function(t){if(t.format===1)return t.glyphs;{const e=[],n=t.ranges;for(let r=0;r<n.length;r++){const s=n[r],i=s.start,a=s.end;for(let o=i;o<=a;o++)e.push(o)}return e}}};var Rn=na;function Jt(t){Rn.call(this,t,"gpos")}Jt.prototype=Rn.prototype,Jt.prototype.init=function(){const t=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(t)},Jt.prototype.getKerningValue=function(t,e,n){for(let r=0;r<t.length;r++){const s=t[r].subtables;for(let i=0;i<s.length;i++){const a=s[i],o=this.getCoverageIndex(a.coverage,e);if(!(o<0))switch(a.posFormat){case 1:{let c=a.pairSets[o];for(let l=0;l<c.length;l++){let u=c[l];if(u.secondGlyph===n)return u.value1&&u.value1.xAdvance||0}break}case 2:{const c=this.getGlyphClass(a.classDef1,e),l=this.getGlyphClass(a.classDef2,n),u=a.classRecords[c][l];return u.value1&&u.value1.xAdvance||0}}}}return 0},Jt.prototype.getKerningTables=function(t,e){if(this.font.tables.gpos)return this.getLookupTables(t,e,"kern",2)};var Zu=Jt;function Ju(t,e){const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function Qu(t,e,n){let r=0,s=t.length-1,i=null;for(;r<=s;){const a=Math.floor((r+s)/2),o=t[a],c=o[e];if(c<n)r=a+1;else if(c>n)s=a-1;else{i=o;break}}return i}function eh(t,e,n){let r=0,s=t.length-1;for(;r<=s;){const i=Math.floor((r+s)/2),a=t[i];if(a[e]<n)r=i+1;else if(a[e]>n)s=i-1;else return i}return-1}function th(t,e,n){let r=0,s=t.length;const i=(a,o)=>a[e]-o[e];for(;r<s;){const a=r+s>>>1;i(t[a],n)<0?r=a+1:s=a}return t.splice(r,0,n),r}function ra(t){return t[0]===31&&t[1]===139&&t[2]===8}function nh(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);let n=10;const r=t.byteLength-8,s=e.getInt8(3);if(s&4&&(n+=2+e.getUint16(n,!0)),s&8)for(;n<r&&t[n++]!==0;);if(s&16)for(;n<r&&t[n++]!==0;);if(s&2&&(n+=2),n>=r)throw new Error("Can't find compressed blocks");const i=e.getUint32(e.byteLength-4,!0);return Qs(t.subarray(n,r),new Uint8Array(i))}function sa(t){return{x:t.x,y:t.y,onCurve:t.onCurve,lastPointOfContour:t.lastPointOfContour}}function rh(t){return{glyphIndex:t.glyphIndex,xScale:t.xScale,scale01:t.scale01,scale10:t.scale10,yScale:t.yScale,dx:t.dx,dy:t.dy}}function Me(t){Rn.call(this,t,"gsub")}function Dr(t,e,n){const r=t.subtables;for(let s=0;s<r.length;s++){const i=r[s];if(i.substFormat===e)return i}if(n)return r.push(n),n}Me.prototype=Rn.prototype,Me.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},Me.prototype.getSingle=function(t,e,n){const r=[],s=this.getLookupTables(e,n,t,1);for(let i=0;i<s.length;i++){const a=s[i].subtables;for(let o=0;o<a.length;o++){const c=a[o],l=this.expandCoverage(c.coverage);let u;if(c.substFormat===1){const f=c.deltaGlyphId;for(u=0;u<l.length;u++){const h=l[u];r.push({sub:h,by:h+f})}}else{const f=c.substitute;for(u=0;u<l.length;u++)r.push({sub:l[u],by:f[u]})}}}return r},Me.prototype.getMultiple=function(t,e,n){const r=[],s=this.getLookupTables(e,n,t,2);for(let i=0;i<s.length;i++){const a=s[i].subtables;for(let o=0;o<a.length;o++){const c=a[o],l=this.expandCoverage(c.coverage);let u;for(u=0;u<l.length;u++){const f=l[u],h=c.sequences[u];r.push({sub:f,by:h})}}}return r},Me.prototype.getAlternates=function(t,e,n){const r=[],s=this.getLookupTables(e,n,t,3);for(let i=0;i<s.length;i++){const a=s[i].subtables;for(let o=0;o<a.length;o++){const c=a[o],l=this.expandCoverage(c.coverage),u=c.alternateSets;for(let f=0;f<l.length;f++)r.push({sub:l[f],by:u[f]})}}return r},Me.prototype.getLigatures=function(t,e,n){const r=[],s=this.getLookupTables(e,n,t,4);for(let i=0;i<s.length;i++){const a=s[i].subtables;for(let o=0;o<a.length;o++){const c=a[o],l=this.expandCoverage(c.coverage),u=c.ligatureSets;for(let f=0;f<l.length;f++){const h=l[f],p=u[f];for(let y=0;y<p.length;y++){const m=p[y];r.push({sub:[h].concat(m.components),by:m.ligGlyph})}}}}return r},Me.prototype.addSingle=function(t,e,n,r){const s=this.getLookupTables(n,r,t,1,!0)[0],i=Dr(s,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});z.assert(i.coverage.format===1,"Single: unable to modify coverage table format "+i.coverage.format);const a=e.sub;let o=this.binSearch(i.coverage.glyphs,a);o<0&&(o=-1-o,i.coverage.glyphs.splice(o,0,a),i.substitute.splice(o,0,0)),i.substitute[o]=e.by},Me.prototype.addMultiple=function(t,e,n,r){z.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(n,r,t,2,!0)[0],i=Dr(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});z.assert(i.coverage.format===1,"Multiple: unable to modify coverage table format "+i.coverage.format);const a=e.sub;let o=this.binSearch(i.coverage.glyphs,a);o<0&&(o=-1-o,i.coverage.glyphs.splice(o,0,a),i.sequences.splice(o,0,0)),i.sequences[o]=e.by},Me.prototype.addAlternate=function(t,e,n,r){const s=this.getLookupTables(n,r,t,3,!0)[0],i=Dr(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});z.assert(i.coverage.format===1,"Alternate: unable to modify coverage table format "+i.coverage.format);const a=e.sub;let o=this.binSearch(i.coverage.glyphs,a);o<0&&(o=-1-o,i.coverage.glyphs.splice(o,0,a),i.alternateSets.splice(o,0,0)),i.alternateSets[o]=e.by},Me.prototype.addLigature=function(t,e,n,r){const s=this.getLookupTables(n,r,t,4,!0)[0];let i=s.subtables[0];i||(i={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=i),z.assert(i.coverage.format===1,"Ligature: unable to modify coverage table format "+i.coverage.format);const a=e.sub[0],o=e.sub.slice(1),c={ligGlyph:e.by,components:o};let l=this.binSearch(i.coverage.glyphs,a);if(l>=0){const u=i.ligatureSets[l];for(let f=0;f<u.length;f++)if(Ju(u[f].components,o))return;u.push(c)}else l=-1-l,i.coverage.glyphs.splice(l,0,a),i.ligatureSets.splice(l,0,[c])},Me.prototype.getFeature=function(t,e,n){if(/ss\d\d/.test(t))return this.getSingle(t,e,n);switch(t){case"aalt":case"salt":return this.getSingle(t,e,n).concat(this.getAlternates(t,e,n));case"dlig":case"liga":case"rlig":return this.getLigatures(t,e,n);case"ccmp":return this.getMultiple(t,e,n).concat(this.getLigatures(t,e,n));case"stch":return this.getMultiple(t,e,n)}},Me.prototype.add=function(t,e,n,r){if(/ss\d\d/.test(t))return this.addSingle(t,e,n,r);switch(t){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(t,e,n,r):this.addAlternate(t,e,n,r);case"dlig":case"liga":case"rlig":return this.addLigature(t,e,n,r);case"ccmp":return e.by instanceof Array?this.addMultiple(t,e,n,r):this.addLigature(t,e,n,r)}};var sh=Me,ia=class{constructor(t){this.defaultValue=255,this.font=t}cpal(){return this.font.tables&&this.font.tables.cpal?this.font.tables.cpal:!1}getAll(t){const e=[],n=this.cpal();if(!n)return e;for(let r=0;r<n.colorRecordIndices.length;r++){const s=n.colorRecordIndices[r],i=[];for(let a=s;a<s+n.numPaletteEntries;a++)i.push(Bt(n.colorRecords[a],t||"hexa"));e.push(i)}return e}toCPALcolor(t){return Array.isArray(t)?t.map(e=>Ln(e,"raw")):Ln(t,"raw")}fillPalette(t,e=[],n=this.cpal().numPaletteEntries){return t=Number.isInteger(t)?this.get(t,"raw"):t,Object.assign(Array(n).fill(this.defaultValue),this.toCPALcolor(t).concat(this.toCPALcolor(e)))}extend(t){if(this.ensureCPAL(Array(t).fill(this.defaultValue)))return;const e=this.cpal(),n=e.numPaletteEntries+t,r=this.getAll().map(s=>this.fillPalette(s,[],n));e.numPaletteEntries=n,e.colorRecords=this.toCPALcolor(r.flat()),this.updateIndices()}get(t,e="hexa"){return this.getAll(e)[t]||null}getColor(t,e=0,n="hexa"){return Cr(this.font,t,e,n)}setColor(t,e,n=0){t=parseInt(t),n=parseInt(n);let r=this.getAll("raw"),s=r[n];if(!s)throw Error(`paletteIndex ${n} out of range`);const i=this.cpal(),a=i.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+t>a&&(this.extend(e.length+t-a),r=this.getAll("raw"),s=r[n]);for(let o=0;o<e.length;o++)s[o+t]=this.toCPALcolor(e[o]);i.colorRecords=r.flat(),this.updateIndices()}add(t){if(this.ensureCPAL(t))return;const e=this.cpal(),n=e.numPaletteEntries;t&&t.length?(t=this.toCPALcolor(t),t.length>n?this.extend(t.length-n):t.length<n&&(t=this.fillPalette(t)),e.colorRecordIndices.push(e.colorRecords.length),e.colorRecords.push(...t)):(e.colorRecordIndices.push(e.colorRecords.length),e.colorRecords.push(...Array(n).fill(this.defaultValue)))}delete(t){const e=this.getAll("raw");delete e[t];const n=this.cpal();n.colorRecordIndices.pop(),n.colorRecords=e.flat()}deleteColor(t,e){if(t===e)throw Error("replacementIndex cannot be the same as colorIndex");const n=this.cpal(),r=this.getAll("raw"),s=[];if(e>n.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${n.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;o<r.length;o++){const l=r[o].filter((u,f)=>f!==t);s.push(l)}const i=this.font.tables.colr;if(i){const o=i.layerRecords;for(let c=0;c<o.length;c++){const l=o[c].paletteIndex;if(l>t)o[c].paletteIndex-=1;else if(l===t){let u=0;for(let f=0;f<r.length;f++)if(e>t&&e<=t+r[f].length){u++;break}o[c].paletteIndex=e-u}}this.font.tables.colr={...i,layerRecords:o}}const a=s.flat();for(let o=0;o<r.length;o++)n.colorRecordIndices[o]-=o;n.numPaletteEntries=Math.max(0,n.numPaletteEntries-1),n.colorRecords=this.toCPALcolor(a)}ensureCPAL(t){return this.cpal()?!1:(!t||!t.length?t=[this.defaultValue]:t=this.toCPALcolor(t),this.font.tables.cpal={version:0,numPaletteEntries:t.length,colorRecords:t,colorRecordIndices:[0]},!0)}updateIndices(){const t=this.cpal(),e=Math.ceil(t.colorRecords.length/t.numPaletteEntries);t.colorRecordIndices=[];for(let n=0;n<e;n++)t.colorRecordIndices.push(n*t.numPaletteEntries)}},ih=class{constructor(t){this.font=t}ensureCOLR(){return this.font.tables.colr||(this.font.tables.colr={version:0,baseGlyphRecords:[],layerRecords:[]}),this.font}get(t){const e=this.font,n=[],r=e.tables.colr,s=e.tables.cpal;if(!r||!s)return n;const i=Qu(r.baseGlyphRecords,"glyphID",t);if(!i)return n;const a=i.firstLayerIndex,o=i.numLayers;for(let c=0;c<o;c++){const l=r.layerRecords[a+c];n.push({glyph:e.glyphs.get(l.glyphID),paletteIndex:l.paletteIndex})}return n}add(t,e,n){const r=this.get(t);e=Array.isArray(e)?e:[e],n===void 0||n===1/0||n>r.length?n=r.length:n<0&&(n=r.length+1+n%(r.length+1),n>=r.length+1&&(n-=r.length+1));const s=[];for(let i=0;i<n;i++){const a=Number.isInteger(r[i].glyph)?r[i].glyph:r[i].glyph.index;s.push({glyphID:a,paletteIndex:r[i].paletteIndex})}for(const i of e){const a=Number.isInteger(i.glyph)?i.glyph:i.glyph.index;s.push({glyphID:a,paletteIndex:i.paletteIndex})}for(let i=n;i<r.length;i++){const a=Number.isInteger(r[i].glyph)?r[i].glyph:r[i].glyph.index;s.push({glyphID:a,paletteIndex:r[i].paletteIndex})}this.updateColrTable(t,s)}setPaletteIndex(t,e,n){let r=this.get(t);r[e]?(r=r.map((s,i)=>({glyphID:s.glyph.index,paletteIndex:i===e?n:s.paletteIndex})),this.updateColrTable(t,r)):console.error("Invalid layer index")}remove(t,e,n=e){let r=this.get(t);r=r.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),r.splice(e,n-e+1),this.updateColrTable(t,r)}updateColrTable(t,e){this.ensureCOLR();const r=this.font.tables.colr;let s=eh(r.baseGlyphRecords,"glyphID",t);if(s===-1){const u={glyphID:t,firstLayerIndex:r.layerRecords.length,numLayers:0};s=th(r.baseGlyphRecords,"glyphID",u)}const a=r.baseGlyphRecords[s],o=a.numLayers,c=e.length,l=c-o;if(l>0){const u=e.slice(o).map(f=>({glyphID:f.glyphID,paletteIndex:f.paletteIndex}));r.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else l<0&&r.layerRecords.splice(a.firstLayerIndex+c,-l);for(let u=0;u<Math.min(o,c);u++)r.layerRecords[a.firstLayerIndex+u]={glyphID:e[u].glyphID,paletteIndex:e[u].paletteIndex};if(a.numLayers=c,l!==0)for(let u=0;u<r.baseGlyphRecords.length;u++){const f=r.baseGlyphRecords[u];u===s||f.firstLayerIndex<a.firstLayerIndex||(r.baseGlyphRecords[u].firstLayerIndex+=l)}}},ah=class{constructor(t){this.font=t,this.cache=new WeakMap}get(t){const e=this.getOrCreateSvgImageCacheEntry(t);return e&&e.image}getAsync(t){const e=this.getOrCreateSvgImageCacheEntry(t);return e&&e.promise}getOrCreateSvgImageCacheEntry(t){const e=this.font.tables.svg;if(e===void 0)return;const n=e.get(t);if(n===void 0)return;let r=this.cache.get(n);r===void 0&&(r=oh(n),this.cache.set(n,r));let s=r.images.get(t);return s===void 0&&(s=ch(this.font,r.template,t),s.promise.then(i=>{if(s.image=i,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(t)}catch(a){console.error("font.onGlyphUpdated",t,a)}}),r.images.set(t,s)),s}};function oh(t){return{template:lh(t).then(fh),images:new Map}}function ch(t,e,n){return{promise:e.then(r=>{let s;typeof r=="string"?s=r:(r[4]=n,s=r.join(""));const i=ph(s,t.unitsPerEm);return i.image.decode().then(()=>i)}),image:void 0}}var lh=typeof DecompressionStream=="function"?hh:uh;function uh(t){try{return Promise.resolve(new TextDecoder().decode(ra(t)?nh(t):t))}catch(e){return Promise.reject(e)}}function hh(t){if(ra(t))return new Response(new Response(t).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(t))}catch(e){return Promise.reject(e)}}function fh(t){const e=t.indexOf("<svg"),n=t.indexOf(">",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(t.substring(e,n)))return t;const r=t.lastIndexOf("</svg>");return[t.substring(0,n),"<defs>",t.substring(n,r),'</defs><use href="#glyph',"",'"/>',t.substring(r)]}function ph(t,e){const r=new DOMParser().parseFromString(t,"image/svg+xml").documentElement,s=r.viewBox.baseVal,i=r.width.baseVal,a=r.height.baseVal;let o=1,c=1;s.width>0&&s.height>0&&(i.unitType===1?(o=i.valueInSpecifiedUnits/s.width,c=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(c=a.valueInSpecifiedUnits/s.height,o=c):e&&(o=e/s.width,c=e/s.height));const l=document.createElement("div");l.style.position="fixed",l.style.visibility="hidden",l.appendChild(r),document.body.appendChild(l);const u=r.getBBox();document.body.removeChild(l);const f=(u.x-s.x)*o,h=(s.y-u.y)*c,p=u.width*o,y=u.height*c;r.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&r.setAttribute("width",p),c!==1&&r.setAttribute("height",y);const m=new Image(p,y);return m.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(r.outerHTML),{leftSideBearing:f,baseline:h,image:m}}var _r=new WeakMap;function aa(t,e,n,r,s){let i;return(e&r)>0?(i=t.parseByte(),e&s||(i=-i),i=n+i):(e&s)>0?i=n:i=n+t.parseShort(),i}function oa(t,e,n){const r=new _.Parser(e,n);t._numberOfContours=r.parseShort(),t._xMin=r.parseShort(),t._yMin=r.parseShort(),t._xMax=r.parseShort(),t._yMax=r.parseShort();let s,i;if(t._numberOfContours>0){const a=t.endPointIndices=[];for(let c=0;c<t._numberOfContours;c+=1)a.push(r.parseUShort());t.instructionLength=r.parseUShort(),t.instructions=[];for(let c=0;c<t.instructionLength;c+=1)t.instructions.push(r.parseByte());const o=a[a.length-1]+1;s=[];for(let c=0;c<o;c+=1)if(i=r.parseByte(),s.push(i),(i&8)>0){const l=r.parseByte();for(let u=0;u<l;u+=1)s.push(i),c+=1}if(z.argument(s.length===o,"Bad flags."),a.length>0){const c=[];let l;if(o>0){for(let h=0;h<o;h+=1)i=s[h],l={},l.onCurve=!!(i&1),l.lastPointOfContour=a.indexOf(h)>=0,c.push(l);let u=0;for(let h=0;h<o;h+=1)i=s[h],l=c[h],l.x=aa(r,i,u,2,16),u=l.x;let f=0;for(let h=0;h<o;h+=1)i=s[h],l=c[h],l.y=aa(r,i,f,4,32),f=l.y}t.points=c}else t.points=[]}else if(t._numberOfContours===0)t.points=[];else{t.isComposite=!0,t.points=[],t.components=[];let a=!0;for(;a;){s=r.parseUShort();const o={glyphIndex:r.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(o.dx=r.parseShort(),o.dy=r.parseShort()):o.matchedPoints=[r.parseUShort(),r.parseUShort()]:(s&2)>0?(o.dx=r.parseChar(),o.dy=r.parseChar()):o.matchedPoints=[r.parseByte(),r.parseByte()],(s&8)>0?o.xScale=o.yScale=r.parseF2Dot14():(s&64)>0?(o.xScale=r.parseF2Dot14(),o.yScale=r.parseF2Dot14()):(s&128)>0&&(o.xScale=r.parseF2Dot14(),o.scale01=r.parseF2Dot14(),o.scale10=r.parseF2Dot14(),o.yScale=r.parseF2Dot14()),t.components.push(o),a=!!(s&32)}if(s&256){t.instructionLength=r.parseUShort(),t.instructions=[];for(let o=0;o<t.instructionLength;o+=1)t.instructions.push(r.parseByte())}}}function Bn(t,e){const n=[];for(let r=0;r<t.length;r+=1){const s=t[r],i={x:e.xScale*s.x+e.scale10*s.y+e.dx,y:e.scale01*s.x+e.yScale*s.y+e.dy,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour};n.push(i)}return n}function dh(t){const e=[];let n=[];for(let r=0;r<t.length;r+=1){const s=t[r];n.push(s),s.lastPointOfContour&&(e.push(n),n=[])}return z.argument(n.length===0,"There are still points left in the current contour."),e}function Ur(t){const e=new Lt;if(!t)return e;const n=dh(t);for(let r=0;r<n.length;++r){const s=n[r];let i=s[s.length-1],a=s[0];if(i.onCurve)e.moveTo(i.x,i.y);else if(a.onCurve)e.moveTo(a.x,a.y);else{const o={x:(i.x+a.x)*.5,y:(i.y+a.y)*.5};e.moveTo(o.x,o.y)}for(let o=0;o<s.length;++o)if(i=a,a=s[(o+1)%s.length],i.onCurve)e.lineTo(i.x,i.y);else{let c=a;a.onCurve||(c={x:(i.x+a.x)*.5,y:(i.y+a.y)*.5}),e.quadraticCurveTo(i.x,i.y,c.x,c.y)}e.closePath()}return e}function ca(t,e){if(e.isComposite){_r.has(t)||_r.set(t,new Set);const n=_r.get(t);n.add(e.index);try{for(let r=0;r<e.components.length;r+=1){const s=e.components[r];if(n.has(s.glyphIndex))continue;const i=t.get(s.glyphIndex);if(i.getPath(),i.points){let a;if(s.matchedPoints===void 0)a=Bn(i.points,s);else{if(s.matchedPoints[0]>e.points.length-1||s.matchedPoints[1]>i.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let c=i.points[s.matchedPoints[1]];const l={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};c=Bn([c],l)[0],l.dx=o.x-c.x,l.dy=o.y-c.y,a=Bn(i.points,l)}e.points=e.points.concat(a)}}}finally{n.delete(e.index)}}return Ur(e.points)}function gh(t,e,n,r){const s=new Xe.GlyphSet(r);for(let i=0;i<n.length-1;i+=1){const a=n[i],o=n[i+1];a!==o?s.push(i,Xe.ttfGlyphLoader(r,i,oa,t,e+a,ca)):s.push(i,Xe.glyphLoader(r,i))}return s}function mh(t,e,n,r){const s=new Xe.GlyphSet(r);return r._push=function(i){const a=n[i],o=n[i+1];a!==o?s.push(i,Xe.ttfGlyphLoader(r,i,oa,t,e+a,ca)):s.push(i,Xe.glyphLoader(r,i))},s}function yh(t,e,n,r,s){return s.lowMemory?mh(t,e,n,r):gh(t,e,n,r)}var la={getPath:Ur,parse:yh},bh=class{constructor(t){this.font=t}normalizeCoordTags(t){for(const e in t)if(e.length<4){const n=e.padEnd(4," ");t[n]===void 0&&(t[n]=t[e]),delete t[e]}}getNormalizedCoords(t){t||(t=this.font.variation.get());let e=[];this.normalizeCoordTags(t);for(let n=0;n<this.fvar().axes.length;n++){const r=this.fvar().axes[n];let s=t[r.tag];s===void 0&&(s=r.defaultValue),s<r.defaultValue?e.push((s-r.defaultValue+Number.EPSILON)/(r.defaultValue-r.minValue+Number.EPSILON)):e.push((s-r.defaultValue+Number.EPSILON)/(r.maxValue-r.defaultValue+Number.EPSILON))}if(this.avar())for(let n=0;n<this.avar().axisSegmentMaps.length;n++){let r=this.avar().axisSegmentMaps[n];for(let s=0;s<r.axisValueMaps.length;s++){let i=r.axisValueMaps[s];if(s>=1&&e[n]<i.fromCoordinate){let a=r.axisValueMaps[s-1];e[n]=((e[n]-a.fromCoordinate)*(i.toCoordinate-a.toCoordinate)+Number.EPSILON)/(i.fromCoordinate-a.fromCoordinate+Number.EPSILON)+a.toCoordinate;break}}}return e}interpolatePoints(t,e,n){if(t.length===0)return;let r=0;for(;r<t.length;){let s=r,i=r,a=t[i];for(;!a.lastPointOfContour;)a=t[++i];for(;r<=i&&!n[r];)r++;if(r>i)continue;let o=r,c=r;for(r++;r<=i;)n[r]&&(this.deltaInterpolate(c+1,r-1,c,r,e,t),c=r),r++;c===o?this.deltaShift(s,i,c,e,t):(this.deltaInterpolate(c+1,i,c,o,e,t),o>0&&this.deltaInterpolate(s,o-1,c,o,e,t)),r=i+1}}deltaInterpolate(t,e,n,r,s,i){if(t>e)return;let a=["x","y"];for(let c=0;c<a.length;c++){let l=a[c];if(s[n][l]>s[r][l]){var o=n;n=r,r=o}let u=s[n][l],f=s[r][l],h=i[n][l],p=i[r][l];if(u!==f||h===p){let y=u===f?0:(p-h)/(f-u);for(let m=t;m<=e;m++){let b=s[m][l];b<=u?b+=h-u:b>=f?b+=p-f:b=h+(b-u)*y,i[m][l]=b}}}}deltaShift(t,e,n,r,s){let i=s[n].x-r[n].x,a=s[n].y-r[n].y;if(!(i===0&&a===0))for(let o=t;o<=e;o++)o!==n&&(s[o].x+=i,s[o].y+=a)}transformComponents(t,e,n,r,s,i){let a=0;for(let o=0;o<t.components.length;o++){const c=t.components[o],l=this.font.glyphs.get(c.glyphIndex),u=rh(c),f=r.indexOf(o);f>-1&&(u.dx+=Math.round(s.deltas[f]*i),u.dy+=Math.round(s.deltasY[f]*i));const h=Bn(this.getTransform(l,n).points,u);e.splice(a,h.length,...h),a+=l.points.length}}applyTupleVariationStore(t,e,n,r="gvar",s={}){n||(n=this.font.variation.get());const i=this.getNormalizedCoords(n),{headers:a,sharedPoints:o}=t,c=this.fvar().axes.length;let l;r==="gvar"?l=e.map(sa):r==="cvar"&&(l=[...e]);for(let u=0;u<a.length;u++){const f=a[u];let h=1;for(let y=0;y<c;y++){let m=[0];switch(r){case"gvar":m=f.peakTuple?f.peakTuple:this.gvar().sharedTuples[f.sharedTupleRecordsIndex];break;case"cvar":m=f.peakTuple;break}if(m[y]!==0){if(i[y]===0){h=0;break}if(f.intermediateStartTuple)if(i[y]<f.intermediateStartTuple[y]||i[y]>f.intermediateEndTuple[y]){h=0;break}else i[y]<m[y]?h=h*(i[y]-f.intermediateStartTuple[y]+Number.EPSILON)/(m[y]-f.intermediateStartTuple[y]+Number.EPSILON):h=h*(f.intermediateEndTuple[y]-i[y]+Number.EPSILON)/(f.intermediateEndTuple[y]-m[y]+Number.EPSILON);else{if(i[y]<Math.min(0,m[y])||i[y]>Math.max(0,m[y])){h=0;break}h=(h*i[y]+Number.EPSILON)/(m[y]+Number.EPSILON)}}}if(h===0)continue;const p=f.privatePoints.length?f.privatePoints:o;if(r==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,l,n,p,f,h);else if(p.length===0)for(let y=0;y<l.length;y++){const m=l[y];r==="gvar"?l[y]={x:Math.round(m.x+f.deltas[y]*h),y:Math.round(m.y+f.deltasY[y]*h),onCurve:m.onCurve,lastPointOfContour:m.lastPointOfContour}:r==="cvar"&&(l[y]=Math.round(m+f.deltas[y]*h))}else{let y;r==="gvar"?y=l.map(sa):r==="cvar"&&(y=l);const m=Array(e.length).fill(!1);for(let b=0;b<p.length;b++){let v=p[b];if(v<e.length){let w=y[v];r==="gvar"?(m[v]=!0,w.x+=f.deltas[b]*h,w.y+=f.deltasY[b]*h):r==="cvar"&&(l[v]=Math.round(w+f.deltas[b]*h))}}if(r==="gvar"){this.interpolatePoints(y,l,m);for(let b=0;b<e.length;b++){let v=y[b].x-l[b].x,w=y[b].y-l[b].y;l[b].x=Math.round(l[b].x+v),l[b].y=Math.round(l[b].y+w)}}}}return l}getTransform(t,e){Number.isInteger(t)&&(t=this.font.glyphs.get(t));const n=t.getBlendPath,r=!!(t.points&&t.points.length);let s=t;if(n||r){if(e||(e=this.font.variation.get()),r){const i=this.gvar()&&this.gvar().glyphVariations[t.index];if(i){const a=t.points;let o=this.applyTupleVariationStore(i,a,e,"gvar",{glyph:t});s=new Yt(Object.assign({},t,{points:o,path:Ur(o)}))}}else if(n){const i=t.getBlendPath(e);s=new Yt(Object.assign({},t,{path:i}))}}return this.font.tables.hvar&&(t._advanceWidth=typeof t._advanceWidth<"u"?t._advanceWidth:t.advanceWidth,t.advanceWidth=s.advanceWidth=Math.round(t._advanceWidth+this.getVariableAdjustment(s.index,"hvar","advanceWidth",e)),t._leftSideBearing=typeof t._leftSideBearing<"u"?t._leftSideBearing:t.leftSideBearing,t.leftSideBearing=s.leftSideBearing=Math.round(t._leftSideBearing+this.getVariableAdjustment(s.index,"hvar","lsb",e))),s}getCvarTransform(t){const e=this.font.tables.cvt,n=this.cvar();return!e||!e.length||!n||!n.headers.length?e:this.applyTupleVariationStore(n,e,t,"cvar")}getVariableAdjustment(t,e,n,r){r=r||this.font.variation.get();let s,i;const a=this.font.tables[e];if(!a)throw Error(`trying to get variation adjustment from non-existent table "${a}"`);if(!a.itemVariationStore)throw Error(`trying to get variation adjustment from table "${a}" which does not have an itemVariationStore`);const o=a[n]&&a[n].map.length;if(o){let c=t;c>=o&&(c=o-1),{outerIndex:s,innerIndex:i}=a[n].map[c]}else s=0,i=t;return this.getDelta(a.itemVariationStore,s,i,r)}getDelta(t,e,n,r){if(e>=t.itemVariationSubtables.length)return 0;let s=t.itemVariationSubtables[e];if(n>=s.deltaSets.length)return 0;let i=s.deltaSets[n],a=this.getBlendVector(t,e,r),o=0;for(let c=0;c<s.regionIndexes.length;c++)o+=i[c]*a[c];return o}getBlendVector(t,e,n){n||(n=this.font.variation.get());let r=t.itemVariationSubtables[e];const s=this.getNormalizedCoords(n);let i=[];for(let a=0;a<r.regionIndexes.length;a++){let o=1,c=r.regionIndexes[a],l=t.variationRegions[c].regionAxes;for(let u=0;u<l.length;u++){let f=l[u],h;f.startCoord>f.peakCoord||f.peakCoord>f.endCoord||f.startCoord<0&&f.endCoord>0&&f.peakCoord!==0||f.peakCoord===0?h=1:s[u]<f.startCoord||s[u]>f.endCoord?h=0:s[u]===f.peakCoord?h=1:s[u]<f.peakCoord?h=(s[u]-f.startCoord+Number.EPSILON)/(f.peakCoord-f.startCoord+Number.EPSILON):h=(f.endCoord-s[u]+Number.EPSILON)/(f.endCoord-f.peakCoord+Number.EPSILON),o*=h}i[a]=o}return i}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},xh=class{constructor(t){this.font=t,this.process=new bh(this.font),this.activateDefaultVariation(),this.getTransform=this.process.getTransform.bind(this.process)}activateDefaultVariation(){const t=this.getDefaultInstanceIndex();t>-1?this.set(t):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((t,e)=>(t[e.tag]=e.defaultValue,t),{})}getDefaultInstanceIndex(){const t=this.getDefaultCoordinates();let e=this.getInstanceIndex(t);return e<0&&(e=this.fvar().instances.findIndex(n=>n.name&&n.name.en==="Regular")),e}getInstanceIndex(t){return this.fvar().instances.findIndex(e=>Object.keys(t).every(n=>e.coordinates[n]===t[n]))}getInstance(t){return this.fvar().instances&&this.fvar().instances[t]}set(t){let e;if(Number.isInteger(t)){const n=this.getInstance(t);if(!n)throw Error(`Invalid instance index ${t}`);e={...n.coordinates}}else e=t,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},ua=1e6,Dn=64,_n=1e4,ha,Ct,fa,Pr;function pa(t){this.font=t,this.getCommands=function(e){return la.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function vh(t){return t}function da(t){return Math.sign(t)*Math.round(Math.abs(t))}function Sh(t){return Math.sign(t)*Math.round(Math.abs(t*2))/2}function wh(t){return Math.sign(t)*(Math.round(Math.abs(t)+.5)-.5)}function Th(t){return Math.sign(t)*Math.ceil(Math.abs(t))}function Ch(t){return Math.sign(t)*Math.floor(Math.abs(t))}var ga=function(t){const e=this.srPeriod;let n=this.srPhase;const r=this.srThreshold;let s=1;return t<0&&(t=-t,s=-1),t+=r-n,t=Math.trunc(t/e)*e,t+=n,t<0?n*s:t*s},Ze={x:1,y:0,axis:"x",distance:function(t,e,n,r){return(n?t.xo:t.x)-(r?e.xo:e.x)},interpolate:function(t,e,n,r){let s,i,a,o,c,l,u;if(!r||r===this){if(s=t.xo-e.xo,i=t.xo-n.xo,c=e.x-e.xo,l=n.x-n.xo,a=Math.abs(s),o=Math.abs(i),u=a+o,u===0){t.x=t.xo+(c+l)/2;return}t.x=t.xo+(c*o+l*a)/u;return}if(s=r.distance(t,e,!0,!0),i=r.distance(t,n,!0,!0),c=r.distance(e,e,!1,!0),l=r.distance(n,n,!1,!0),a=Math.abs(s),o=Math.abs(i),u=a+o,u===0){Ze.setRelative(t,t,(c+l)/2,r,!0);return}Ze.setRelative(t,t,(c*o+l*a)/u,r,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(t,e,n,r,s){if(!r||r===this){t.x=(s?e.xo:e.x)+n;return}const i=s?e.xo:e.x,a=s?e.yo:e.y,o=i+n*r.x,c=a+n*r.y;t.x=o+(t.y-c)/r.normalSlope},slope:0,touch:function(t){t.xTouched=!0},touched:function(t){return t.xTouched},untouch:function(t){t.xTouched=!1}},et={x:0,y:1,axis:"y",distance:function(t,e,n,r){return(n?t.yo:t.y)-(r?e.yo:e.y)},interpolate:function(t,e,n,r){let s,i,a,o,c,l,u;if(!r||r===this){if(s=t.yo-e.yo,i=t.yo-n.yo,c=e.y-e.yo,l=n.y-n.yo,a=Math.abs(s),o=Math.abs(i),u=a+o,u===0){t.y=t.yo+(c+l)/2;return}t.y=t.yo+(c*o+l*a)/u;return}if(s=r.distance(t,e,!0,!0),i=r.distance(t,n,!0,!0),c=r.distance(e,e,!1,!0),l=r.distance(n,n,!1,!0),a=Math.abs(s),o=Math.abs(i),u=a+o,u===0){et.setRelative(t,t,(c+l)/2,r,!0);return}et.setRelative(t,t,(c*o+l*a)/u,r,!0)},normalSlope:0,setRelative:function(t,e,n,r,s){if(!r||r===this){t.y=(s?e.yo:e.y)+n;return}const i=s?e.xo:e.x,a=s?e.yo:e.y,o=i+n*r.x,c=a+n*r.y;t.y=c+r.normalSlope*(t.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(t){t.yTouched=!0},touched:function(t){return t.yTouched},untouch:function(t){t.yTouched=!1}};Object.freeze(Ze),Object.freeze(et);function Qt(t,e){this.x=t,this.y=e,this.axis=void 0,this.slope=e/t,this.normalSlope=-t/e,Object.freeze(this)}Qt.prototype.distance=function(t,e,n,r){return this.x*Ze.distance(t,e,n,r)+this.y*et.distance(t,e,n,r)},Qt.prototype.interpolate=function(t,e,n,r){let s,i,a,o,c,l,u;if(a=r.distance(t,e,!0,!0),o=r.distance(t,n,!0,!0),s=r.distance(e,e,!1,!0),i=r.distance(n,n,!1,!0),c=Math.abs(a),l=Math.abs(o),u=c+l,u===0){this.setRelative(t,t,(s+i)/2,r,!0);return}this.setRelative(t,t,(s*l+i*c)/u,r,!0)},Qt.prototype.setRelative=function(t,e,n,r,s){r=r||this;const i=s?e.xo:e.x,a=s?e.yo:e.y,o=i+n*r.x,c=a+n*r.y,l=r.normalSlope,u=this.slope,f=t.x,h=t.y;t.x=(u*f-l*o+c-h)/(u-l),t.y=u*(t.x-f)+h},Qt.prototype.touch=function(t){t.xTouched=!0,t.yTouched=!0};function en(t,e){const n=Math.sqrt(t*t+e*e);return t/=n,e/=n,t===1&&e===0?Ze:t===0&&e===1?et:new Qt(t,e)}function tt(t,e,n,r){this.x=this.xo=Math.round(t*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=n,this.onCurve=r,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}tt.prototype.nextTouched=function(t){let e=this.nextPointOnContour;for(;!t.touched(e)&&e!==this;)e=e.nextPointOnContour;return e},tt.prototype.prevTouched=function(t){let e=this.prevPointOnContour;for(;!t.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var tn=Object.freeze(new tt(0,0)),kh={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function lt(t,e){switch(this.env=t,this.stack=[],this.prog=e,t){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=Ze,this.round=da}}pa.prototype.exec=function(t,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const n=this.font;let r=this._prepState;if(!r||r.ppem!==e){let s=this._fpgmState;if(!s){lt.prototype=kh,s=this._fpgmState=new lt("fpgm",n.tables.fpgm),s.funcs=[],s.font=n,s.instructionCount=0,s.callDepth=0;try{Ct(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}lt.prototype=s,r=this._prepState=new lt("prep",n.tables.prep),r.ppem=e,r.instructionCount=0,r.callDepth=0;const i=n.variation&&n.variation.process.getCvarTransform()||n.tables.cvt;if(i){const a=r.cvt=new Array(i.length),o=e/n.unitsPerEm;for(let c=0;c<i.length;c++)a[c]=i[c]*o}else r.cvt=[];try{Ct(r)}catch(a){this._errorState<2&&console.log("Hinting error in PREP:"+a),this._errorState=2}}if(!(this._errorState>1))try{return fa(t,r)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},fa=function(t,e){const n=e.ppem/e.font.unitsPerEm,r=n;let s=t.components,i,a,o;if(lt.prototype=e,!s)o=new lt("glyf",t.instructions),o.instructionCount=0,o.callDepth=0,Pr(t,o,n,r),a=o.gZone;else{const c=e.font;a=[],i=[];for(let l=0;l<s.length;l++){const u=s[l],f=c.glyphs.get(u.glyphIndex);o=new lt("glyf",f.instructions),o.instructionCount=0,o.callDepth=0,Pr(f,o,n,r);const h=Math.round(u.dx*n),p=Math.round(u.dy*r),y=o.gZone,m=o.contours;for(let v=0;v<y.length;v++){const w=y[v];w.xTouched=w.yTouched=!1,w.xo=w.x=w.x+h,w.yo=w.y=w.y+p}const b=a.length;a.push.apply(a,y);for(let v=0;v<m.length;v++)i.push(m[v]+b)}t.instructions&&!o.inhibitGridFit&&(o=new lt("glyf",t.instructions),o.gZone=o.z0=o.z1=o.z2=a,o.contours=i,a.push(new tt(0,0),new tt(Math.round(t.advanceWidth*n),0)),Ct(o),a.length-=2)}return a},Pr=function(t,e,n,r){const s=t.points||[],i=s.length,a=e.gZone=e.z0=e.z1=e.z2=[],o=e.contours=[];let c;for(let f=0;f<i;f++)c=s[f],a[f]=new tt(c.x*n,c.y*r,c.lastPointOfContour,c.onCurve);let l,u;for(let f=0;f<i;f++)c=a[f],l||(l=c,o.push(f)),c.lastPointOfContour?(c.nextPointOnContour=l,l.prevPointOnContour=c,l=void 0):(u=a[f+1],c.nextPointOnContour=u,u.prevPointOnContour=c);e.inhibitGridFit||(a.push(new tt(0,0),new tt(Math.round(t.advanceWidth*n),0)),Ct(e),a.length-=2)},Ct=function(t){let e=t.prog;if(!e)return;const n=e.length;let r;for(t.ip=0;t.ip<n;t.ip++){if(++t.instructionCount>ua)throw new Error("Hinting instructions exceeded maximum of "+ua);if(r=ha[e[t.ip]],!r)throw new Error("unknown instruction: 0x"+Number(e[t.ip]).toString(16));r(t)}};function Un(t){const e=t.tZone=new Array(t.gZone.length);for(let n=0;n<e.length;n++)e[n]=new tt(0,0)}function ma(t,e){const n=t.prog;let r=t.ip,s=1,i;do if(i=n[++r],i===88)s++;else if(i===89)s--;else if(i===64)r+=n[r+1]+1;else if(i===65)r+=2*n[r+1]+1;else if(i>=176&&i<=183)r+=i-176+1;else if(i>=184&&i<=191)r+=(i-184+1)*2;else if(e&&s===1&&i===27)break;while(s>0);t.ip=r}function ya(t,e){e.fv=e.pv=e.dpv=t}function ba(t,e){e.pv=e.dpv=t}function xa(t,e){e.fv=t}function va(t,e){const n=e.stack,r=n.pop(),s=n.pop(),i=e.z2[r],a=e.z1[s];let o,c;t?(o=i.y-a.y,c=a.x-i.x):(o=a.x-i.x,c=a.y-i.y),e.pv=e.dpv=en(o,c)}function Sa(t,e){const n=e.stack,r=n.pop(),s=n.pop(),i=e.z2[r],a=e.z1[s];let o,c;t?(o=i.y-a.y,c=a.x-i.x):(o=a.x-i.x,c=a.y-i.y),e.fv=en(o,c)}function Fh(t){const e=t.stack,n=e.pop(),r=e.pop();t.pv=t.dpv=en(r,n)}function Eh(t){const e=t.stack,n=e.pop(),r=e.pop();t.fv=en(r,n)}function Ah(t){const e=t.stack,n=t.pv;e.push(n.x*16384),e.push(n.y*16384)}function Oh(t){const e=t.stack,n=t.fv;e.push(n.x*16384),e.push(n.y*16384)}function Lh(t){t.fv=t.pv}function Ih(t){const e=t.stack,n=e.pop(),r=e.pop(),s=e.pop(),i=e.pop(),a=e.pop(),o=t.z0,c=t.z1,l=o[n],u=o[r],f=c[s],h=c[i],p=t.z2[a],y=l.x,m=l.y,b=u.x,v=u.y,w=f.x,T=f.y,C=h.x,E=h.y,R=(y-b)*(T-E)-(m-v)*(w-C),N=y*v-m*b,V=w*E-T*C;p.x=(N*(w-C)-V*(y-b))/R,p.y=(N*(T-E)-V*(m-v))/R}function Mh(t){t.rp0=t.stack.pop()}function Rh(t){t.rp1=t.stack.pop()}function Bh(t){t.rp2=t.stack.pop()}function Dh(t){const e=t.stack.pop();switch(t.zp0=e,e){case 0:t.tZone||Un(t),t.z0=t.tZone;break;case 1:t.z0=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function _h(t){const e=t.stack.pop();switch(t.zp1=e,e){case 0:t.tZone||Un(t),t.z1=t.tZone;break;case 1:t.z1=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Uh(t){const e=t.stack.pop();switch(t.zp2=e,e){case 0:t.tZone||Un(t),t.z2=t.tZone;break;case 1:t.z2=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Ph(t){const e=t.stack.pop();switch(t.zp0=t.zp1=t.zp2=e,e){case 0:t.tZone||Un(t),t.z0=t.z1=t.z2=t.tZone;break;case 1:t.z0=t.z1=t.z2=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Nh(t){t.loop=t.stack.pop(),t.loop>_n&&(t.loop=_n)}function Gh(t){t.round=da}function Hh(t){t.round=wh}function zh(t){const e=t.stack.pop();t.minDis=e/64}function Wh(t){ma(t,!1)}function Vh(t){const e=t.stack.pop();t.ip+=e-1}function jh(t){const e=t.stack.pop();t.cvCutIn=e/64}function qh(t){const e=t.stack;e.push(e[e.length-1])}function Nr(t){t.stack.pop()}function $h(t){t.stack.length=0}function Yh(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(n),e.push(r)}function Xh(t){const e=t.stack;e.push(e.length)}function Kh(t){const e=t.stack,n=e.pop();let r=e.pop();if(r>_n&&(r=_n),++t.callDepth>Dn)throw new Error("Hinting call depth exceeded maximum of "+Dn);const s=t.ip,i=t.prog;t.prog=t.funcs[n];for(let a=0;a<r;a++)Ct(t);t.ip=s,t.prog=i,t.callDepth--}function Zh(t){const e=t.stack.pop();if(++t.callDepth>Dn)throw new Error("Hinting call depth exceeded maximum of "+Dn);const n=t.ip,r=t.prog;t.prog=t.funcs[e],Ct(t),t.ip=n,t.prog=r,t.callDepth--}function Jh(t){const e=t.stack,n=e.pop();e.push(e[e.length-n])}function Qh(t){const e=t.stack,n=e.pop();e.push(e.splice(e.length-n,1)[0])}function ef(t){if(t.env!=="fpgm")throw new Error("FDEF not allowed here");const e=t.stack,n=t.prog;let r=t.ip;const s=e.pop(),i=r;for(;n[++r]!==45;);t.ip=r,t.funcs[s]=n.slice(i+1,r)}function wa(t,e){const n=e.stack.pop(),r=e.z0[n],s=e.fv,i=e.pv;let a=i.distance(r,tn);t&&(a=e.round(a)),s.setRelative(r,tn,a,i),s.touch(r),e.rp0=e.rp1=n}function Ta(t,e){const n=e.z2,r=n.length-2;let s,i,a;for(let o=0;o<r;o++)s=n[o],!t.touched(s)&&(i=s.prevTouched(t),i!==s&&(a=s.nextTouched(t),i===a&&t.setRelative(s,s,t.distance(i,i,!1,!0),t,!0),t.interpolate(s,i,a,t)))}function Ca(t,e){const n=e.stack,r=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[r],i=e.fv,a=e.pv;let o=e.loop;const c=e.z2;for(;o--;){const l=n.pop(),u=c[l],f=a.distance(s,s,!1,!0);i.setRelative(u,u,f,a),i.touch(u)}e.loop=1}function ka(t,e){const n=e.stack,r=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[r],i=e.fv,a=e.pv,o=n.pop(),c=e.z2[e.contours[o]];let l=c;const u=a.distance(s,s,!1,!0);do l!==s&&i.setRelative(l,l,u,a),l=l.nextPointOnContour;while(l!==c)}function Fa(t,e){const n=e.stack,r=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[r],i=e.fv,a=e.pv,o=n.pop();let c;switch(o){case 0:c=e.tZone;break;case 1:c=e.gZone;break;default:throw new Error("Invalid zone")}let l;const u=a.distance(s,s,!1,!0),f=c.length-2;for(let h=0;h<f;h++)l=c[h],i.setRelative(l,l,u,a)}function tf(t){const e=t.stack;let n=t.loop;const r=t.fv,s=e.pop()/64,i=t.z2;for(;n--;){const a=e.pop(),o=i[a];r.setRelative(o,o,s),r.touch(o)}t.loop=1}function nf(t){const e=t.stack,n=t.rp1,r=t.rp2;let s=t.loop;const i=t.z0[n],a=t.z1[r],o=t.fv,c=t.dpv,l=t.z2;for(;s--;){const u=e.pop(),f=l[u];o.interpolate(f,i,a,c),o.touch(f)}t.loop=1}function Ea(t,e){const n=e.stack,r=n.pop()/64,s=n.pop(),i=e.z1[s],a=e.z0[e.rp0],o=e.fv,c=e.pv;o.setRelative(i,a,r,c),o.touch(i),e.rp1=e.rp0,e.rp2=s,t&&(e.rp0=s)}function rf(t){const e=t.stack,n=t.rp0,r=t.z0[n];let s=t.loop;const i=t.fv,a=t.pv,o=t.z1;for(;s--;){const c=e.pop(),l=o[c];i.setRelative(l,r,0,a),i.touch(l)}t.loop=1}function sf(t){t.round=Sh}function Aa(t,e){const n=e.stack,r=n.pop(),s=n.pop(),i=e.z0[s],a=e.fv,o=e.pv;let c=e.cvt[r],l=o.distance(i,tn);t&&(Math.abs(l-c)<e.cvCutIn&&(l=c),l=e.round(l)),a.setRelative(i,tn,l,o),e.zp0===0&&(i.xo=i.x,i.yo=i.y),a.touch(i),e.rp0=e.rp1=s}function af(t){const e=t.prog;let n=t.ip;const r=t.stack,s=e[++n];for(let i=0;i<s;i++)r.push(e[++n]);t.ip=n}function of(t){let e=t.ip;const n=t.prog,r=t.stack,s=n[++e];for(let i=0;i<s;i++){let a=n[++e]<<8|n[++e];a&32768&&(a=-((a^65535)+1)),r.push(a)}t.ip=e}function cf(t){const e=t.stack;let n=t.store;n||(n=t.store=[]);const r=e.pop(),s=e.pop();n[s]=r}function lf(t){const e=t.stack,n=t.store,r=e.pop(),s=n&&n[r]||0;e.push(s)}function uf(t){const e=t.stack,n=e.pop(),r=e.pop();t.cvt[r]=n/64}function hf(t){const e=t.stack,n=e.pop();e.push(t.cvt[n]*64)}function Oa(t,e){const n=e.stack,r=n.pop(),s=e.z2[r];n.push(e.dpv.distance(s,tn,t,!1)*64)}function La(t,e){const n=e.stack,r=n.pop(),s=n.pop(),i=e.z1[r],a=e.z0[s],o=e.dpv.distance(a,i,t,t);e.stack.push(Math.round(o*64))}function ff(t){t.stack.push(t.ppem)}function pf(t){t.autoFlip=!0}function df(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r<n?1:0)}function gf(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r<=n?1:0)}function mf(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r>n?1:0)}function yf(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r>=n?1:0)}function bf(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(n===r?1:0)}function xf(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(n!==r?1:0)}function vf(t){const e=t.stack,n=e.pop();e.push(Math.trunc(n)&1?1:0)}function Sf(t){const e=t.stack,n=e.pop();e.push(Math.trunc(n)&1?0:1)}function wf(t){t.stack.pop()||ma(t,!0)}function Tf(t){}function Cf(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(n&&r?1:0)}function kf(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(n||r?1:0)}function Ff(t){const e=t.stack,n=e.pop();e.push(n?0:1)}function Gr(t,e){const n=e.stack,r=n.pop(),s=e.fv,i=e.pv,a=e.ppem,o=e.deltaBase+(t-1)*16,c=e.deltaShift,l=e.z0;for(let u=0;u<r;u++){const f=n.pop(),h=n.pop();if(o+((h&240)>>4)!==a)continue;let y=(h&15)-8;y>=0&&y++;const m=l[f];s.setRelative(m,m,y*c,i)}}function Ef(t){const n=t.stack.pop();t.deltaBase=n}function Af(t){const n=t.stack.pop();t.deltaShift=Math.pow(.5,n)}function Of(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r+n)}function Lf(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r-n)}function If(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r*64/n)}function Mf(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r*n/64)}function Rf(t){const e=t.stack,n=e.pop();e.push(Math.abs(n))}function Bf(t){const e=t.stack;let n=e.pop();e.push(-n)}function Df(t){const e=t.stack,n=e.pop();e.push(Math.floor(n/64)*64)}function _f(t){const e=t.stack,n=e.pop();e.push(Math.ceil(n/64)*64)}function Pn(t,e){const n=e.stack,r=n.pop();n.push(e.round(r/64)*64)}function Uf(t){const e=t.stack,n=e.pop(),r=e.pop();t.cvt[r]=n*t.ppem/t.font.unitsPerEm}function Hr(t,e){const n=e.stack,r=n.pop(),s=e.ppem,i=e.deltaBase+(t-1)*16,a=e.deltaShift;for(let o=0;o<r;o++){const c=n.pop(),l=n.pop();if(i+((l&240)>>4)!==s)continue;let f=(l&15)-8;f>=0&&f++;const h=f*a;e.cvt[c]+=h}}function Pf(t){let e=t.stack.pop();t.round=ga;let n;switch(e&192){case 0:n=.5;break;case 64:n=1;break;case 128:n=2;break;default:throw new Error("invalid SROUND value")}switch(t.srPeriod=n,e&48){case 0:t.srPhase=0;break;case 16:t.srPhase=.25*n;break;case 32:t.srPhase=.5*n;break;case 48:t.srPhase=.75*n;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?t.srThreshold=0:t.srThreshold=(e/8-.5)*n}function Nf(t){let e=t.stack.pop();t.round=ga;let n;switch(e&192){case 0:n=Math.sqrt(2)/2;break;case 64:n=Math.sqrt(2);break;case 128:n=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(t.srPeriod=n,e&48){case 0:t.srPhase=0;break;case 16:t.srPhase=.25*n;break;case 32:t.srPhase=.5*n;break;case 48:t.srPhase=.75*n;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?t.srThreshold=0:t.srThreshold=(e/8-.5)*n}function Gf(t){t.round=vh}function Hf(t){t.round=Th}function zf(t){t.round=Ch}function Wf(t){t.stack.pop()}function Ia(t,e){const n=e.stack,r=n.pop(),s=n.pop(),i=e.z2[r],a=e.z1[s];let o,c;t?(o=i.y-a.y,c=a.x-i.x):(o=a.x-i.x,c=a.y-i.y),e.dpv=en(o,c)}function Vf(t){const e=t.stack,n=e.pop();let r=0;n&1&&(r=35),n&32&&(r|=4096),e.push(r)}function jf(t){const e=t.stack,n=e.pop(),r=e.pop(),s=e.pop();e.push(r),e.push(n),e.push(s)}function qf(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(Math.max(r,n))}function $f(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(Math.min(r,n))}function Yf(t){t.stack.pop()}function Xf(t){const e=t.stack.pop();let n=t.stack.pop();switch(e){case 1:t.inhibitGridFit=!!n;return;case 2:t.ignoreCvt=!!n;return;default:throw new Error("invalid INSTCTRL[] selector")}}function ut(t,e){const n=e.stack,r=e.prog;let s=e.ip;for(let i=0;i<t;i++)n.push(r[++s]);e.ip=s}function ht(t,e){let n=e.ip;const r=e.prog,s=e.stack;for(let i=0;i<t;i++){let a=r[++n]<<8|r[++n];a&32768&&(a=-((a^65535)+1)),s.push(a)}e.ip=n}function H(t,e,n,r,s,i){const a=i.stack,o=t&&a.pop(),c=a.pop(),l=i.rp0,u=i.z0[l],f=i.z1[c],h=i.minDis,p=i.fv,y=i.dpv;let m,b,v;m=y.distance(f,u,!0,!0),b=m>=0?1:-1,m=Math.abs(m),t&&(v=i.cvt[o],r&&Math.abs(m-v)<i.cvCutIn&&(m=v)),n&&m<h&&(m=h),r&&(m=i.round(m)),p.setRelative(f,u,b*m,y),p.touch(f),i.rp1=i.rp0,i.rp2=c,e&&(i.rp0=c)}ha=[ya.bind(void 0,et),ya.bind(void 0,Ze),ba.bind(void 0,et),ba.bind(void 0,Ze),xa.bind(void 0,et),xa.bind(void 0,Ze),va.bind(void 0,0),va.bind(void 0,1),Sa.bind(void 0,0),Sa.bind(void 0,1),Fh,Eh,Ah,Oh,Lh,Ih,Mh,Rh,Bh,Dh,_h,Uh,Ph,Nh,Gh,Hh,zh,Wh,Vh,jh,void 0,void 0,qh,Nr,$h,Yh,Xh,Jh,Qh,void 0,void 0,void 0,Kh,Zh,ef,void 0,wa.bind(void 0,0),wa.bind(void 0,1),Ta.bind(void 0,et),Ta.bind(void 0,Ze),Ca.bind(void 0,0),Ca.bind(void 0,1),ka.bind(void 0,0),ka.bind(void 0,1),Fa.bind(void 0,0),Fa.bind(void 0,1),tf,nf,Ea.bind(void 0,0),Ea.bind(void 0,1),rf,sf,Aa.bind(void 0,0),Aa.bind(void 0,1),af,of,cf,lf,uf,hf,Oa.bind(void 0,0),Oa.bind(void 0,1),void 0,La.bind(void 0,0),La.bind(void 0,1),ff,void 0,pf,void 0,void 0,df,gf,mf,yf,bf,xf,vf,Sf,wf,Tf,Cf,kf,Ff,Gr.bind(void 0,1),Ef,Af,Of,Lf,If,Mf,Rf,Bf,Df,_f,Pn.bind(void 0,0),Pn.bind(void 0,1),Pn.bind(void 0,2),Pn.bind(void 0,3),void 0,void 0,void 0,void 0,Uf,Gr.bind(void 0,2),Gr.bind(void 0,3),Hr.bind(void 0,1),Hr.bind(void 0,2),Hr.bind(void 0,3),Pf,Nf,void 0,void 0,Gf,void 0,Hf,zf,Nr,Nr,void 0,void 0,void 0,void 0,void 0,Wf,Ia.bind(void 0,0),Ia.bind(void 0,1),Vf,void 0,jf,qf,$f,Yf,Xf,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ut.bind(void 0,1),ut.bind(void 0,2),ut.bind(void 0,3),ut.bind(void 0,4),ut.bind(void 0,5),ut.bind(void 0,6),ut.bind(void 0,7),ut.bind(void 0,8),ht.bind(void 0,1),ht.bind(void 0,2),ht.bind(void 0,3),ht.bind(void 0,4),ht.bind(void 0,5),ht.bind(void 0,6),ht.bind(void 0,7),ht.bind(void 0,8),H.bind(void 0,0,0,0,0,0),H.bind(void 0,0,0,0,0,1),H.bind(void 0,0,0,0,0,2),H.bind(void 0,0,0,0,0,3),H.bind(void 0,0,0,0,1,0),H.bind(void 0,0,0,0,1,1),H.bind(void 0,0,0,0,1,2),H.bind(void 0,0,0,0,1,3),H.bind(void 0,0,0,1,0,0),H.bind(void 0,0,0,1,0,1),H.bind(void 0,0,0,1,0,2),H.bind(void 0,0,0,1,0,3),H.bind(void 0,0,0,1,1,0),H.bind(void 0,0,0,1,1,1),H.bind(void 0,0,0,1,1,2),H.bind(void 0,0,0,1,1,3),H.bind(void 0,0,1,0,0,0),H.bind(void 0,0,1,0,0,1),H.bind(void 0,0,1,0,0,2),H.bind(void 0,0,1,0,0,3),H.bind(void 0,0,1,0,1,0),H.bind(void 0,0,1,0,1,1),H.bind(void 0,0,1,0,1,2),H.bind(void 0,0,1,0,1,3),H.bind(void 0,0,1,1,0,0),H.bind(void 0,0,1,1,0,1),H.bind(void 0,0,1,1,0,2),H.bind(void 0,0,1,1,0,3),H.bind(void 0,0,1,1,1,0),H.bind(void 0,0,1,1,1,1),H.bind(void 0,0,1,1,1,2),H.bind(void 0,0,1,1,1,3),H.bind(void 0,1,0,0,0,0),H.bind(void 0,1,0,0,0,1),H.bind(void 0,1,0,0,0,2),H.bind(void 0,1,0,0,0,3),H.bind(void 0,1,0,0,1,0),H.bind(void 0,1,0,0,1,1),H.bind(void 0,1,0,0,1,2),H.bind(void 0,1,0,0,1,3),H.bind(void 0,1,0,1,0,0),H.bind(void 0,1,0,1,0,1),H.bind(void 0,1,0,1,0,2),H.bind(void 0,1,0,1,0,3),H.bind(void 0,1,0,1,1,0),H.bind(void 0,1,0,1,1,1),H.bind(void 0,1,0,1,1,2),H.bind(void 0,1,0,1,1,3),H.bind(void 0,1,1,0,0,0),H.bind(void 0,1,1,0,0,1),H.bind(void 0,1,1,0,0,2),H.bind(void 0,1,1,0,0,3),H.bind(void 0,1,1,0,1,0),H.bind(void 0,1,1,0,1,1),H.bind(void 0,1,1,0,1,2),H.bind(void 0,1,1,0,1,3),H.bind(void 0,1,1,1,0,0),H.bind(void 0,1,1,1,0,1),H.bind(void 0,1,1,1,0,2),H.bind(void 0,1,1,1,0,3),H.bind(void 0,1,1,1,1,0),H.bind(void 0,1,1,1,1,1),H.bind(void 0,1,1,1,1,2),H.bind(void 0,1,1,1,1,3)];var Kf=pa;function Ut(t){this.char=t,this.state={},this.activeState=null}function zr(t,e,n){this.contextName=n,this.startIndex=t,this.endOffset=e}function Zf(t,e,n){this.contextName=t,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=n}function Fe(t,e){this.context=t,this.index=e,this.length=t.length,this.current=t[e],this.backtrack=t.slice(0,e),this.lookahead=t.slice(e+1)}function Nn(t){this.eventId=t,this.subscribers=[]}function Jf(t){const e=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];for(let r=0;r<e.length;r++){const s=e[r];Object.defineProperty(this.events,s,{value:new Nn(s)})}if(t)for(let r=0;r<e.length;r++){const s=e[r],i=t[s];typeof i=="function"&&this.events[s].subscribe(i)}const n=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];for(let r=0;r<n.length;r++){const s=n[r];this.events[s].subscribe(this.updateContextsRanges)}}function le(t){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Jf.call(this,t)}Ut.prototype.setState=function(t,e){return this.state[t]=e,this.activeState={key:t,value:this.state[t]},this.activeState},Ut.prototype.getState=function(t){return this.state[t]||null},le.prototype.inboundIndex=function(t){return t>=0&&t<this.tokens.length},le.prototype.composeRUD=function(t){const n=t.map(s=>this[s[0]].apply(this,s.slice(1).concat(!0))),r=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(n.every(r))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:n.filter(r)};this.dispatch("composeRUD",[n.filter(s=>!r(s))])},le.prototype.replaceRange=function(t,e,n,r){e=e!==null?e:this.tokens.length;const s=n.every(i=>i instanceof Ut);if(!isNaN(t)&&this.inboundIndex(t)&&s){const i=this.tokens.splice.apply(this.tokens,[t,e].concat(n));return r||this.dispatch("replaceToken",[t,e,n]),[i,n]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},le.prototype.replaceToken=function(t,e,n){if(!isNaN(t)&&this.inboundIndex(t)&&e instanceof Ut){const r=this.tokens.splice(t,1,e);return n||this.dispatch("replaceToken",[t,e]),[r[0],e]}else return{FAIL:"replaceToken: invalid token or index."}},le.prototype.removeRange=function(t,e,n){e=isNaN(e)?this.tokens.length:e;const r=this.tokens.splice(t,e);return n||this.dispatch("removeRange",[r,t,e]),r},le.prototype.removeToken=function(t,e){if(!isNaN(t)&&this.inboundIndex(t)){const n=this.tokens.splice(t,1);return e||this.dispatch("removeToken",[n,t]),n}else return{FAIL:"removeToken: invalid token index."}},le.prototype.insertToken=function(t,e,n){return t.every(s=>s instanceof Ut)?(this.tokens.splice.apply(this.tokens,[e,0].concat(t)),n||this.dispatch("insertToken",[t,e]),t):{FAIL:"insertToken: invalid token(s)."}},le.prototype.registerModifier=function(t,e,n){this.events.newToken.subscribe(function(r,s){const i=[r,s],a=e===null||e.apply(this,i)===!0,o=[r,s];if(a){let c=n.apply(this,o);r.setState(t,c)}}),this.registeredModifiers.push(t)},Nn.prototype.subscribe=function(t){return typeof t=="function"?this.subscribers.push(t)-1:{FAIL:`invalid '${this.eventId}' event handler`}},Nn.prototype.unsubscribe=function(t){this.subscribers.splice(t,1)},Fe.prototype.setCurrentIndex=function(t){this.index=t,this.current=this.context[t],this.backtrack=this.context.slice(0,t),this.lookahead=this.context.slice(t+1)},Fe.prototype.get=function(t){switch(!0){case t===0:return this.current;case(t<0&&Math.abs(t)<=this.backtrack.length):return this.backtrack.slice(t)[0];case(t>0&&t<=this.lookahead.length):return this.lookahead[t-1];default:return null}},le.prototype.rangeToText=function(t){if(t instanceof zr)return this.getRangeTokens(t).map(e=>e.char).join("")},le.prototype.getText=function(){return this.tokens.map(t=>t.char).join("")},le.prototype.getContext=function(t){let e=this.registeredContexts[t];return e||null},le.prototype.on=function(t,e){const n=this.events[t];return n?n.subscribe(e):null},le.prototype.dispatch=function(t,e){const n=this.events[t];if(n instanceof Nn)for(let r=0;r<n.subscribers.length;r++)n.subscribers[r].apply(this,e||[])},le.prototype.registerContextChecker=function(t,e,n){if(this.getContext(t))return{FAIL:`context name '${t}' is already registered.`};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof n!="function")return{FAIL:"missing context end check."};const r=new Zf(t,e,n);return this.registeredContexts[t]=r,this.contextCheckers.push(r),r},le.prototype.getRangeTokens=function(t){const e=t.startIndex+t.endOffset;return[].concat(this.tokens.slice(t.startIndex,e))},le.prototype.getContextRanges=function(t){const e=this.getContext(t);return e?e.ranges:{FAIL:`context checker '${t}' is not registered.`}},le.prototype.resetContextsRanges=function(){const t=this.registeredContexts;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];n.ranges=[]}},le.prototype.updateContextsRanges=function(){this.resetContextsRanges();const t=this.tokens.map(e=>e.char);for(let e=0;e<t.length;e++){const n=new Fe(t,e);this.runContextCheck(n)}this.dispatch("updateContextsRanges",[this.registeredContexts])},le.prototype.setEndOffset=function(t,e){const n=this.getContext(e).openRange.startIndex;let r=new zr(n,t,e);const s=this.getContext(e).ranges;return r.rangeId=`${e}.${s.length}`,s.push(r),this.getContext(e).openRange=null,r},le.prototype.runContextCheck=function(t){const e=t.index;for(let n=0;n<this.contextCheckers.length;n++){const r=this.contextCheckers[n];let s=r.contextName,i=this.getContext(s).openRange;if(!i&&r.checkStart(t)&&(i=new zr(e,null,s),this.getContext(s).openRange=i,this.dispatch("contextStart",[s,e])),i&&r.checkEnd(t)){const a=e-i.startIndex+1,o=this.setEndOffset(a,s);this.dispatch("contextEnd",[s,o])}}},le.prototype.tokenize=function(t){this.tokens=[],this.resetContextsRanges();let e=Array.from(t);this.dispatch("start");for(let n=0;n<e.length;n++){const r=e[n],s=new Fe(e,n);this.dispatch("next",[s]),this.runContextCheck(s);let i=new Ut(r);this.tokens.push(i),this.dispatch("newToken",[i,s])}return this.dispatch("end",[this.tokens]),this.tokens};var Qf=le;function ft(t){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(t)}function Ma(t){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(t)}function pt(t){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(t)}function Gn(t){return/[\u0E00-\u0E7F]/.test(t)}function Hn(t){return/[A-z]/.test(t)}function ep(t){return/\s/.test(t)}function Re(t){this.font=t,this.features={}}function dt(t){this.id=t.id,this.tag=t.tag,this.substitution=t.substitution}function gt(t,e){if(!t)return-1;switch(e.format){case 1:return e.glyphs.indexOf(t);case 2:{let n=e.ranges;for(let r=0;r<n.length;r++){const s=n[r];if(t>=s.start&&t<=s.end){let i=t-s.start;return s.index+i}}break}default:return-1}return-1}function tp(t,e){return gt(t,e.coverage)===-1?null:t+e.deltaGlyphId}function np(t,e){let n=gt(t,e.coverage);return n===-1?null:e.substitute[n]}function Wr(t,e){let n=[];for(let r=0;r<t.length;r++){const s=t[r];let i=e.current;i=Array.isArray(i)?i[0]:i;const a=gt(i,s);a!==-1&&n.push(a)}return n.length!==t.length?-1:n}function rp(t,e){const n=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(t.context.length<n)return[];let r=Wr(e.inputCoverage,t);if(r===-1)return[];const s=e.inputCoverage.length-1;if(t.lookahead.length<e.lookaheadCoverage.length)return[];let i=t.lookahead.slice(s);for(;i.length&&pt(i[0].char);)i.shift();const a=new Fe(i,0);let o=Wr(e.lookaheadCoverage,a),c=[].concat(t.backtrack);for(c.reverse();c.length&&pt(c[0].char);)c.shift();if(c.length<e.backtrackCoverage.length)return[];const l=new Fe(c,0);let u=Wr(e.backtrackCoverage,l);const f=r.length===e.inputCoverage.length&&o.length===e.lookaheadCoverage.length&&u.length===e.backtrackCoverage.length;let h=[];if(f)for(let p=0;p<e.lookupRecords.length;p++){const y=e.lookupRecords[p],m=y.lookupListIndex,b=this.getLookupByIndex(m);for(let v=0;v<b.subtables.length;v++){let w=b.subtables[v],T,C=this.getSubstitutionType(b,w);if(C==="71"?(C=this.getSubstitutionType(w,w.extension),T=this.getLookupMethod(w,w.extension),w=w.extension):T=this.getLookupMethod(b,w),C==="12"){const E=t.get(y.sequenceIndex),R=T(E);R&&h.push(R)}else if(C==="21"){const E=t.get(y.sequenceIndex),R=T(E);R&&h.push(R)}else throw new Error(`Substitution type ${C} is not supported in chaining substitution`)}}return h}function sp(t,e){let n=t.current,r=gt(n,e.coverage);if(r===-1)return null;let s,i=e.ligatureSets[r];for(let a=0;a<i.length;a++){s=i[a];for(let o=0;o<s.components.length;o++){const c=t.lookahead[o],l=s.components[o];if(c!==l)break;if(o===s.components.length-1)return s}}return null}function ip(t,e){let n=t.current;if(gt(n,e.coverage)===-1)return null;for(const s of e.ruleSets)for(const i of s){let a=!0;for(let o=0;o<i.input.length;o++)if(t.lookahead[o]!==i.input[o]){a=!1;break}if(a){let o=[];o.push(n);for(let l=0;l<i.input.length;l++)o.push(i.input[l]);const c=(l,u)=>{const{lookupListIndex:f,sequenceIndex:h}=u,{subtables:p}=this.getLookupByIndex(f);for(const y of p)gt(l[h],y.coverage)!==-1&&(l[h]=y.deltaGlyphId)};for(let l=0;l<i.lookupRecords.length;l++){const u=i.lookupRecords[l];c(o,u)}return o}}return null}function ap(t,e){if(t.context.length<e.coverages.length)return[];for(let r=0;r<e.coverages.length;r++){let s=t.get(r);if(s=Array.isArray(s)?s[0]:s,gt(s,e.coverages[r])===-1)return[]}let n=[];for(let r=0;r<e.lookupRecords.length;r++){const s=e.lookupRecords[r],i=s.lookupListIndex,a=this.getLookupByIndex(i);for(let o=0;o<a.subtables.length;o++){let c=a.subtables[o],l,u=this.getSubstitutionType(a,c);if(u==="71"?(u=this.getSubstitutionType(c,c.extension),l=this.getLookupMethod(c,c.extension),c=c.extension):l=this.getLookupMethod(a,c),u==="12"){const f=t.get(s.sequenceIndex),h=l(f);h&&n.push(h)}else if(u==="21"){const f=t.get(s.sequenceIndex),h=l(f);h&&n.push(h)}}}return n}function op(t,e){let n=gt(t,e.coverage);return n===-1?null:e.sequences[n]}Re.prototype.getDefaultScriptFeaturesIndexes=function(){const t=this.font.tables.gsub.scripts;for(let e=0;e<t.length;e++){const n=t[e];if(n.tag==="DFLT")return n.script.defaultLangSys.featureIndexes}return[]},Re.prototype.getScriptFeaturesIndexes=function(t){if(!this.font.tables.gsub)return[];if(!t)return this.getDefaultScriptFeaturesIndexes();const n=this.font.tables.gsub.scripts;for(let r=0;r<n.length;r++){const s=n[r];if(s.tag===t&&s.script.defaultLangSys)return s.script.defaultLangSys.featureIndexes;{let i=s.langSysRecords;if(i)for(let a=0;a<i.length;a++){const o=i[a];if(o.tag===t)return o.langSys.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},Re.prototype.mapTagsToFeatures=function(t,e){let n={};for(let r=0;r<t.length;r++){const s=t[r].tag,i=t[r].feature;n[s]=i}this.features[e].tags=n},Re.prototype.getScriptFeatures=function(t){let e=this.features[t];if(Object.prototype.hasOwnProperty.call(this.features,t))return e;const n=this.getScriptFeaturesIndexes(t);if(!n)return null;const r=this.font.tables.gsub;return e=n.map(s=>r.features[s]),this.features[t]=e,this.mapTagsToFeatures(e,t),e},Re.prototype.getSubstitutionType=function(t,e){const n=t.lookupType.toString(),r=e.substFormat.toString();return n+r},Re.prototype.getLookupMethod=function(t,e){let n=this.getSubstitutionType(t,e);switch(n){case"11":return r=>tp.apply(this,[r,e]);case"12":return r=>np.apply(this,[r,e]);case"63":return r=>rp.apply(this,[r,e]);case"41":return r=>sp.apply(this,[r,e]);case"21":return r=>op.apply(this,[r,e]);case"51":return r=>ip.apply(this,[r,e]);case"53":return r=>ap.apply(this,[r,e]);default:throw new Error(`substitutionType : ${n} lookupType: ${t.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}},Re.prototype.lookupFeature=function(t){let e=t.contextParams,n=e.index;const r=this.getFeature({tag:t.tag,script:t.script});if(!r)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${t.tag}' for script '${t.script}'.`);const s=this.getFeatureLookups(r),i=[].concat(e.context);for(let a=0;a<s.length;a++){const o=s[a],c=this.getLookupSubtables(o);for(let l=0;l<c.length;l++){let u=c[l],f=this.getSubstitutionType(o,u),h;f==="71"?(f=this.getSubstitutionType(u,u.extension),h=this.getLookupMethod(u,u.extension),u=u.extension):h=this.getLookupMethod(o,u);let p;switch(f){case"11":p=h(e.current),p&&i.splice(n,1,new dt({id:11,tag:t.tag,substitution:p}));break;case"12":p=h(e.current),p&&i.splice(n,1,new dt({id:12,tag:t.tag,substitution:p}));break;case"63":p=h(e),Array.isArray(p)&&p.length&&i.splice(n,1,new dt({id:63,tag:t.tag,substitution:p}));break;case"41":p=h(e),p&&i.splice(n,1,new dt({id:41,tag:t.tag,substitution:p}));break;case"21":p=h(e.current),p&&i.splice(n,1,new dt({id:21,tag:t.tag,substitution:p}));break;case"51":case"53":p=h(e),Array.isArray(p)&&p.length&&i.splice(n,1,new dt({id:parseInt(f),tag:t.tag,substitution:p}));break}e=new Fe(i,n),!(Array.isArray(p)&&!p.length)&&(p=null)}}return i.length?i:null},Re.prototype.supports=function(t){if(!t.script)return!1;this.getScriptFeatures(t.script);const e=Object.prototype.hasOwnProperty.call(this.features,t.script);if(!t.tag)return e;const n=this.features[t.script].some(r=>r.tag===t.tag);return e&&n},Re.prototype.getLookupSubtables=function(t){return t.subtables||null},Re.prototype.getLookupByIndex=function(t){return this.font.tables.gsub.lookups[t]||null},Re.prototype.getFeatureLookups=function(t){return t.lookupListIndexes.map(this.getLookupByIndex.bind(this))},Re.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const n=this.features[e.script];return n?n.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var cp=Re;function lp(t){const e=t.current,n=t.get(-1);return n===null&&ft(e)||!ft(n)&&ft(e)}function up(t){const e=t.get(1);return e===null||!ft(e)}var hp={startCheck:lp,endCheck:up};function fp(t){const e=t.current,n=t.get(-1);return(ft(e)||pt(e))&&!ft(n)}function pp(t){const e=t.get(1);switch(!0){case e===null:return!0;case(!ft(e)&&!pt(e)):{const n=ep(e);if(!n)return!0;if(n){let r=!1;if(r=t.lookahead.some(s=>ft(s)||pt(s)),!r)return!0}break}default:return!1}}var dp={startCheck:fp,endCheck:pp};function gp(t,e,n){e[n].setState(t.tag,t.substitution)}function mp(t,e,n){e[n].setState(t.tag,t.substitution)}function Vr(t,e,n){for(let r=0;r<t.substitution.length;r++){const s=t.substitution[r],i=e[n+r];if(Array.isArray(s)){s.length?i.setState(t.tag,s[0]):i.setState("deleted",!0);continue}i.setState(t.tag,s)}}function yp(t,e,n){let r=e[n];r.setState(t.tag,t.substitution.ligGlyph);const s=t.substitution.components.length;for(let i=0;i<s;i++)r=e[n+i+1],r.setState("deleted",!0)}var Ra={11:gp,12:mp,63:Vr,41:yp,51:Vr,53:Vr};function bp(t,e,n){t instanceof dt&&Ra[t.id]&&Ra[t.id](t,e,n)}var kt=bp;function xp(t){let e=[].concat(t.backtrack);for(let n=e.length-1;n>=0;n--){const r=e[n],s=Ma(r),i=pt(r);if(!s&&!i)return!0;if(s)return!1}return!1}function vp(t){if(Ma(t.current))return!1;for(let e=0;e<t.lookahead.length;e++){const n=t.lookahead[e];if(!pt(n))return!0}return!1}function Sp(t){const e="arab",n=this.featuresTags[e],r=this.tokenizer.getRangeTokens(t);if(r.length===1)return;let s=new Fe(r.map(a=>a.getState("glyphIndex")),0);const i=new Fe(r.map(a=>a.char),0);for(let a=0;a<r.length;a++){const o=r[a];if(pt(o.char))continue;s.setCurrentIndex(a),i.setCurrentIndex(a);let c=0;xp(i)&&(c|=1),vp(i)&&(c|=2);let l;switch(c){case 1:l="fina";break;case 2:l="init";break;case 3:l="medi";break}if(n.indexOf(l)===-1)continue;let u=this.query.lookupFeature({tag:l,script:e,contextParams:s});if(u instanceof Error){console.info(u.message);continue}for(let f=0;f<u.length;f++){const h=u[f];h instanceof dt&&(kt(h,r,f),s.context[f]=h.substitution)}}}var wp=Sp;function Ba(t,e){const n=t.map(r=>r.activeState.value);return new Fe(n,0)}function Tp(t){const e="arab";let n=this.tokenizer.getRangeTokens(t),r=Ba(n);for(let s=0;s<r.context.length;s++){r.setCurrentIndex(s);let i=this.query.lookupFeature({tag:"rlig",script:e,contextParams:r});if(i.length){for(let a=0;a<i.length;a++){const o=i[a];kt(o,n,s)}r=Ba(n)}}}var Cp=Tp;function kp(t){return t.index===0&&t.context.length>1}function Fp(t){return t.index===t.context.length-1}var Ep={startCheck:kp,endCheck:Fp};function Da(t,e){const n=t.map(r=>r.activeState.value);return new Fe(n,0)}function Ap(t){const e="delf",n="ccmp";let r=this.tokenizer.getRangeTokens(t),s=Da(r);for(let i=0;i<s.context.length;i++){if(!this.query.getFeature({tag:n,script:e,contextParams:s}))continue;s.setCurrentIndex(i);let a=this.query.lookupFeature({tag:n,script:e,contextParams:s});if(a.length){for(let o=0;o<a.length;o++){const c=a[o];kt(c,r,i)}s=Da(r)}}}var Op=Ap;function Lp(t){const e=t.current,n=t.get(-1);return n===null&&Hn(e)||!Hn(n)&&Hn(e)}function Ip(t){const e=t.get(1);return e===null||!Hn(e)}var Mp={startCheck:Lp,endCheck:Ip};function _a(t,e){const n=t.map(r=>r.activeState.value);return new Fe(n,0)}function Rp(t){const e="latn";let n=this.tokenizer.getRangeTokens(t),r=_a(n);for(let s=0;s<r.context.length;s++){r.setCurrentIndex(s);let i=this.query.lookupFeature({tag:"liga",script:e,contextParams:r});if(i.length){for(let a=0;a<i.length;a++){const o=i[a];kt(o,n,s)}r=_a(n)}}}var Bp=Rp;function Dp(t){const e=t.current,n=t.get(-1);return n===null&&Gn(e)||!Gn(n)&&Gn(e)}function _p(t){const e=t.get(1);return e===null||!Gn(e)}var Up={startCheck:Dp,endCheck:_p};function Ua(t,e){const n=t.map(r=>r.activeState.value);return new Fe(n,e||0)}function Pp(t){const e="thai";let n=this.tokenizer.getRangeTokens(t),r=Ua(n,0);for(let s=0;s<r.context.length;s++){r.setCurrentIndex(s);let i=this.query.lookupFeature({tag:"ccmp",script:e,contextParams:r});if(i.length){for(let a=0;a<i.length;a++){const o=i[a];kt(o,n,s)}r=Ua(n,s)}}}var Np=Pp;function Pa(t,e){const n=t.map(r=>r.activeState.value);return new Fe(n,e||0)}function Gp(t){const e="thai";let n=this.tokenizer.getRangeTokens(t),r=Pa(n,0);for(let s=0;s<r.context.length;s++){r.setCurrentIndex(s);let i=this.query.lookupFeature({tag:"liga",script:e,contextParams:r});if(i.length){for(let a=0;a<i.length;a++){const o=i[a];kt(o,n,s)}r=Pa(n,s)}}}var Hp=Gp;function Na(t,e){const n=t.map(r=>r.activeState.value);return new Fe(n,e||0)}function zp(t){const e="thai";let n=this.tokenizer.getRangeTokens(t),r=Na(n,0);for(let s=0;s<r.context.length;s++){r.setCurrentIndex(s);let i=this.query.lookupFeature({tag:"rlig",script:e,contextParams:r});if(i.length){for(let a=0;a<i.length;a++){const o=i[a];kt(o,n,s)}r=Na(n,s)}}}var Wp=zp;function jr(t){if(t===null)return!1;const e=t.codePointAt(0);return e>=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function Vp(t){const e=t.current,n=t.get(1);return n===null&&jr(e)||jr(n)}function jp(t){const e=t.get(1);return e===null||!jr(e)}var qp={startCheck:Vp,endCheck:jp};function $p(t){const e=this.query.font,n=this.tokenizer.getRangeTokens(t);if(n[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const r=n[0].char.codePointAt(0),s=n[1].char.codePointAt(0),i=e.tables.cmap.varSelectorList[s];if(i!==void 0&&i.nonDefaultUVS){const a=i.nonDefaultUVS.uvsMappings;if(a[r]){const o=a[r].glyphID;e.glyphs.glyphs[o]!==void 0&&n[0].setState("glyphIndex",o)}}}}var Yp=$p;function Ue(t){this.baseDir=t||"ltr",this.tokenizer=new Qf,this.featuresTags={}}Ue.prototype.setText=function(t){this.text=t},Ue.prototype.contextChecks={ccmpReplacementCheck:Ep,latinWordCheck:Mp,arabicWordCheck:hp,arabicSentenceCheck:dp,thaiWordCheck:Up,unicodeVariationSequenceCheck:qp};function Pt(t){const e=this.contextChecks[`${t}Check`];return this.tokenizer.registerContextChecker(t,e.startCheck,e.endCheck)}function Xp(){return Pt.call(this,"ccmpReplacement"),Pt.call(this,"latinWord"),Pt.call(this,"arabicWord"),Pt.call(this,"arabicSentence"),Pt.call(this,"thaiWord"),Pt.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function Kp(){const t=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;e<t.length;e++){const n=t[e];let r=this.tokenizer.getRangeTokens(n);this.tokenizer.replaceRange(n.startIndex,n.endOffset,r.reverse())}}Ue.prototype.registerFeatures=function(t,e){const n=e.filter(r=>this.query.supports({script:t,tag:r}));Object.prototype.hasOwnProperty.call(this.featuresTags,t)?this.featuresTags[t]=this.featuresTags[t].concat(n):this.featuresTags[t]=n},Ue.prototype.applyFeatures=function(t,e){if(!t)throw new Error("No valid font was provided to apply features");this.query||(this.query=new cp(t));for(let n=0;n<e.length;n++){const r=e[n];this.query.supports({script:r.script})&&this.registerFeatures(r.script,r.tags)}},Ue.prototype.registerModifier=function(t,e,n){this.tokenizer.registerModifier(t,e,n)};function nn(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function Zp(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;nn.call(this);const e=this.tokenizer.getContextRanges("arabicWord");for(let n=0;n<e.length;n++){const r=e[n];wp.call(this,r)}}function Jp(){nn.call(this);const t=this.tokenizer.getContextRanges("ccmpReplacement");for(let e=0;e<t.length;e++){const n=t[e];Op.call(this,n)}}function Qp(){if(!this.hasFeatureEnabled("arab","rlig"))return;nn.call(this);const t=this.tokenizer.getContextRanges("arabicWord");for(let e=0;e<t.length;e++){const n=t[e];Cp.call(this,n)}}function ed(){if(!this.hasFeatureEnabled("latn","liga"))return;nn.call(this);const t=this.tokenizer.getContextRanges("latinWord");for(let e=0;e<t.length;e++){const n=t[e];Bp.call(this,n)}}function td(){const t=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let e=0;e<t.length;e++){const n=t[e];Yp.call(this,n)}}function nd(){nn.call(this);const t=this.tokenizer.getContextRanges("thaiWord");for(let e=0;e<t.length;e++){const n=t[e];this.hasFeatureEnabled("thai","liga")&&Hp.call(this,n),this.hasFeatureEnabled("thai","rlig")&&Wp.call(this,n),this.hasFeatureEnabled("thai","ccmp")&&Np.call(this,n)}}Ue.prototype.checkContextReady=function(t){return!!this.tokenizer.getContext(t)},Ue.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&Jp.call(this),this.checkContextReady("arabicWord")&&(Zp.call(this),Qp.call(this)),this.checkContextReady("latinWord")&&ed.call(this),this.checkContextReady("arabicSentence")&&Kp.call(this),this.checkContextReady("thaiWord")&&nd.call(this),this.checkContextReady("unicodeVariationSequence")&&td.call(this)},Ue.prototype.hasFeatureEnabled=function(t,e){return(this.featuresTags[t]||[]).indexOf(e)!==-1},Ue.prototype.processText=function(t){(!this.text||this.text!==t)&&(this.setText(t),Xp.call(this),this.applyFeaturesToContexts())},Ue.prototype.getBidiText=function(t){return this.processText(t),this.tokenizer.getText()},Ue.prototype.getTextGlyphs=function(t){this.processText(t);let e=[];for(let n=0;n<this.tokenizer.tokens.length;n++){const r=this.tokenizer.tokens[n];if(r.state.deleted)continue;const s=r.activeState.value;e.push(Array.isArray(s)?s[0]:s)}return e};var rd=Ue;function qr(t){return{fontFamily:{en:t.familyName||" "},fontSubfamily:{en:t.styleName||" "},fullName:{en:t.fullName||t.familyName+" "+t.styleName},postScriptName:{en:t.postScriptName||(t.familyName+t.styleName).replace(/\s/g,"")},designer:{en:t.designer||" "},designerURL:{en:t.designerURL||" "},manufacturer:{en:t.manufacturer||" "},manufacturerURL:{en:t.manufacturerURL||" "},license:{en:t.license||" "},licenseURL:{en:t.licenseURL||" "},version:{en:t.version||"Version 0.1"},description:{en:t.description||" "},copyright:{en:t.copyright||" "},trademark:{en:t.trademark||" "}}}function te(t){if(t=t||{},t.tables=t.tables||{},!t.empty){if(!t.familyName)throw new Error("When creating a new Font object, familyName is required.");if(!t.styleName)throw new Error("When creating a new Font object, styleName is required.");if(!t.unitsPerEm)throw new Error("When creating a new Font object, unitsPerEm is required.");if(!t.ascender)throw new Error("When creating a new Font object, ascender is required.");if(t.descender>0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=qr(t),this.names.macintosh=qr(t),this.names.windows=qr(t),this.unitsPerEm=t.unitsPerEm||1e3,this.ascender=t.ascender,this.descender=t.descender,this.createdTimestamp=t.createdTimestamp,this.italicAngle=t.italicAngle||0,this.weightClass=t.weightClass||0;let e=0;t.fsSelection?e=t.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!t.panose||!Array.isArray(t.panose))&&(t.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(t.tables,{os2:Object.assign({usWeightClass:t.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:t.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:t.panose[0]||0,bSerifStyle:t.panose[1]||0,bWeight:t.panose[2]||0,bProportion:t.panose[3]||0,bContrast:t.panose[4]||0,bStrokeVariation:t.panose[5]||0,bArmStyle:t.panose[6]||0,bLetterform:t.panose[7]||0,bMidline:t.panose[8]||0,bXHeight:t.panose[9]||0,fsSelection:e},t.tables.os2)})}this.supported=!0,this.glyphs=new Xe.GlyphSet(this,t.glyphs||[]),this.encoding=new bi(this),this.position=new Zu(this),this.substitution=new sh(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,n,r)=>(e[n]=r,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new xh(this)),!0)}),this.palettes=new ia(this),this.layers=new ih(this),this.svgImages=new ah(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new Kf(this):null}})}te.prototype.hasChar=function(t){return this.encoding.charToGlyphIndex(t)>0},te.prototype.charToGlyphIndex=function(t){return this.encoding.charToGlyphIndex(t)},te.prototype.charToGlyph=function(t){const e=this.charToGlyphIndex(t);let n=this.glyphs.get(e);return n||(n=this.glyphs.get(0)),n},te.prototype.updateFeatures=function(t){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(n=>t[n])}:e)},te.prototype.stringToGlyphIndexes=function(t,e){const n=new rd,r=i=>this.charToGlyphIndex(i.char);n.registerModifier("glyphIndex",null,r);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return n.applyFeatures(this,s),n.getTextGlyphs(t)},te.prototype.stringToGlyphs=function(t,e){const n=this.stringToGlyphIndexes(t,e);let r=n.length;const s=new Array(r),i=this.glyphs.get(0);for(let a=0;a<r;a+=1)s[a]=this.glyphs.get(n[a])||i;return s},te.prototype.nameToGlyphIndex=function(t){return this.glyphNames.nameToGlyphIndex(t)},te.prototype.nameToGlyph=function(t){const e=this.nameToGlyphIndex(t);let n=this.glyphs.get(e);return n||(n=this.glyphs.get(0)),n},te.prototype.glyphIndexToName=function(t){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(t):""},te.prototype.getKerningValue=function(t,e){t=t.index||t,e=e.index||e;const n=this.position.defaultKerningTables;return n?this.position.getKerningValue(n,t,e):this.kerningPairs[t+","+e]||0},te.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]},{script:"thai",tags:["liga","rlig","ccmp"]}],hinting:!1,usePalette:0,drawLayers:!0,drawSVG:!0},te.prototype.forEachGlyph=function(t,e,n,r,s,i){e=e!==void 0?e:0,n=n!==void 0?n:0,r=r!==void 0?r:72,s=Object.assign({},this.defaultRenderOptions,s);const a=1/this.unitsPerEm*r,o=this.stringToGlyphs(t,s);let c;if(s.kerning){const l=s.script||this.position.getDefaultScriptName();c=this.position.getKerningTables(l,s.language)}for(let l=0;l<o.length;l+=1){const u=o[l];if(i.call(this,u,e,n,r,s),u.advanceWidth&&(e+=u.advanceWidth*a),s.kerning&&l<o.length-1){const f=c?this.position.getKerningValue(c,u.index,o[l+1].index):this.getKerningValue(u,o[l+1]);e+=f*a}s.letterSpacing?e+=s.letterSpacing*r:s.tracking&&(e+=s.tracking/1e3*r)}return e},te.prototype.getPath=function(t,e,n,r,s){s=Object.assign({},this.defaultRenderOptions,s);const i=new Lt;if(i._layers=[],Ai(this,i),i.stroke){const a=1/(i.unitsPerEm||1e3)*r;i.strokeWidth*=a}return this.forEachGlyph(t,e,n,r,s,(a,o,c,l)=>{const u=a.getPath(o,c,l,s,this);if(s.drawSVG||s.drawLayers){const f=u._layers;if(f&&f.length){for(let h=0;h<f.length;h++){const p=f[h];i._layers.push(p)}return}}i.extend(u)}),i},te.prototype.getPaths=function(t,e,n,r,s){s=Object.assign({},this.defaultRenderOptions,s);const i=[];return this.forEachGlyph(t,e,n,r,s,function(a,o,c,l){const u=a.getPath(o,c,l,s,this);i.push(u)}),i},te.prototype.getAdvanceWidth=function(t,e,n){return n=Object.assign({},this.defaultRenderOptions,n),this.forEachGlyph(t,0,0,e,n,function(){})},te.prototype.draw=function(t,e,n,r,s,i){this.getPath(e,n,r,s,i).draw(t)},te.prototype.drawPoints=function(t,e,n,r,s,i){i=Object.assign({},this.defaultRenderOptions,i),this.forEachGlyph(e,n,r,s,i,function(a,o,c,l){a.drawPoints(t,o,c,l,i,this)})},te.prototype.drawMetrics=function(t,e,n,r,s,i){i=Object.assign({},this.defaultRenderOptions,i),this.forEachGlyph(e,n,r,s,i,function(a,o,c,l){a.drawMetrics(t,o,c,l)})},te.prototype.getEnglishName=function(t){const e=(this.names.unicode||this.names.macintosh||this.names.windows)[t];if(e)return e.en},te.prototype.validate=function(){const t=[],e=this;function n(s,i){s||(console.warn(`[opentype.js] ${i}`),t.push(i))}function r(s){const i=e.getEnglishName(s);n(i&&i.trim().length>0,"No English "+s+" specified.")}if(r("fontFamily"),r("weightName"),r("manufacturer"),r("copyright"),r("version"),n(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let i=-1;for(let a=0;a<s.length;a++){const o=s[a].glyphID;if(n(i<s[a].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${o} comes after ${i}`),i>s[a].glyphID)break;i=o}}return t},te.prototype.toTables=function(){return Ku.fontToTable(this)},te.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},te.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),n=new ArrayBuffer(e.length),r=new Uint8Array(n);for(let s=0;s<e.length;s++)r[s]=e[s];return n},te.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")},te.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},te.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},te.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},te.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var sd=te;function id(t,e){const n=new _.Parser(t,e),r=n.parseUShort(),s=n.parseUShort();r!==1&&console.warn(`Unsupported hvar table version ${r}.${s}`);const i=[r,s],a=n.parsePointer32(function(){return this.parseItemVariationStore()}),o=n.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),c=n.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),l=n.parsePointer32(function(){return this.parseDeltaSetIndexMap()});return{version:i,itemVariationStore:a,advanceWidth:o,lsb:c,rsb:l}}function ad(){console.warn("Writing of hvar tables is not yet supported.")}var od={make:ad,parse:id},cd=function(){return{coverage:this.parsePointer(k.coverage),attachPoints:this.parseList(k.pointer(k.uShortList))}},ld=function(){var t=this.parseUShort();if(z.argument(t===1||t===2||t===3,"Unsupported CaretValue table version."),t===1)return{coordinate:this.parseShort()};if(t===2)return{pointindex:this.parseShort()};if(t===3)return{coordinate:this.parseShort()}},ud=function(){return this.parseList(k.pointer(ld))},hd=function(){return{coverage:this.parsePointer(k.coverage),ligGlyphs:this.parseList(k.pointer(ud))}},fd=function(){return this.parseUShort(),this.parseList(k.pointer(k.coverage))};function pd(t,e){e=e||0;const n=new k(t,e),r=n.parseVersion(1);z.argument(r===1||r===1.2||r===1.3,"Unsupported GDEF table version.");var s={version:r,classDef:n.parsePointer(k.classDef),attachList:n.parsePointer(cd),ligCaretList:n.parsePointer(hd),markAttachClassDef:n.parsePointer(k.classDef)};return r>=1.2&&(s.markGlyphSets=n.parsePointer(fd)),s}var dd={parse:pd},je=new Array(10);je[1]=function(){const e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{posFormat:1,coverage:this.parsePointer(k.coverage),value:this.parseValueRecord()};if(n===2)return{posFormat:2,coverage:this.parsePointer(k.coverage),values:this.parseValueRecordList()};z.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},je[2]=function(){const e=this.offset+this.relativeOffset,n=this.parseUShort();z.assert(n===1||n===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const r=this.parsePointer(k.coverage),s=this.parseUShort(),i=this.parseUShort();if(n===1)return{posFormat:n,coverage:r,valueFormat1:s,valueFormat2:i,pairSets:this.parseList(k.pointer(k.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}})))};if(n===2){const a=this.parsePointer(k.classDef),o=this.parsePointer(k.classDef),c=this.parseUShort(),l=this.parseUShort();return{posFormat:n,coverage:r,valueFormat1:s,valueFormat2:i,classDef1:a,classDef2:o,class1Count:c,class2Count:l,classRecords:this.parseList(c,k.list(l,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}}))}}},je[3]=function(){return{error:"GPOS Lookup 3 not supported"}},je[4]=function(){return{error:"GPOS Lookup 4 not supported"}},je[5]=function(){return{error:"GPOS Lookup 5 not supported"}},je[6]=function(){return{error:"GPOS Lookup 6 not supported"}},je[7]=function(){return{error:"GPOS Lookup 7 not supported"}},je[8]=function(){return{error:"GPOS Lookup 8 not supported"}},je[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function gd(t,e){e=e||0;const n=new k(t,e),r=n.parseVersion(1);return z.argument(r===1||r===1.1,"Unsupported GPOS table version "+r),r===1?{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(je)}:{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(je),variations:n.parseFeatureVariationsList()}}var md=new Array(10);function yd(t){return new L.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new L.ScriptList(t.scripts)},{name:"features",type:"TABLE",value:new L.FeatureList(t.features)},{name:"lookups",type:"TABLE",value:new L.LookupList(t.lookups,md)}])}var bd={parse:gd,make:yd};function xd(t){const e={};t.skip("uShort");const n=t.parseUShort();z.argument(n===0,"Unsupported kern sub-table version."),t.skip("uShort",2);const r=t.parseUShort();t.skip("uShort",3);for(let s=0;s<r;s+=1){const i=t.parseUShort(),a=t.parseUShort(),o=t.parseShort();e[i+","+a]=o}return e}function vd(t){const e={};t.skip("uShort"),t.parseULong()>1&&console.warn("Only the first kern subtable is supported."),t.skip("uLong");const s=t.parseUShort()&255;if(t.skip("uShort"),s===0){const i=t.parseUShort();t.skip("uShort",3);for(let a=0;a<i;a+=1){const o=t.parseUShort(),c=t.parseUShort(),l=t.parseShort();e[o+","+c]=l}}return e}function Sd(t,e){const n=new _.Parser(t,e),r=n.parseUShort();if(r===0)return xd(n);if(r===1)return vd(n);throw new Error("Unsupported kern table version ("+r+").")}var wd={parse:Sd};function Td(t,e,n,r){const s=new _.Parser(t,e),i=r?s.parseUShort:s.parseULong,a=[];for(let o=0;o<n+1;o+=1){let c=i.call(s);r&&(c*=2),a.push(c)}return a}var Cd={parse:Td};function Ga(t,e){const n=[];let r=12;for(let s=0;s<e;s+=1){const i=_.getTag(t,r),a=_.getULong(t,r+4),o=_.getULong(t,r+8),c=_.getULong(t,r+12);n.push({tag:i,checksum:a,offset:o,length:c,compression:!1}),r+=16}return n}function kd(t,e){const n=[];let r=44;for(let s=0;s<e;s+=1){const i=_.getTag(t,r),a=_.getULong(t,r+4),o=_.getULong(t,r+8),c=_.getULong(t,r+12);let l;o<c?l="WOFF":l=!1,n.push({tag:i,offset:a,compression:l,compressedLength:o,length:c}),r+=20}return n}function Q(t,e){if(e.compression==="WOFF"){const n=new Uint8Array(t.buffer,e.offset+2,e.compressedLength-2),r=new Uint8Array(e.length);if(Qs(n,r),r.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");return{data:new DataView(r.buffer,0),offset:0}}else return{data:t,offset:e.offset}}function Fd(t,e={}){let n,r;const s=new sd({empty:!0});t.constructor!==ArrayBuffer&&(t=new Uint8Array(t).buffer);const i=new DataView(t,0);let a,o=[];const c=_.getTag(i,0);if(c==="\0\0\0"||c==="true"||c==="typ1")s.outlinesFormat="truetype",a=_.getUShort(i,4),o=Ga(i,a);else if(c==="OTTO")s.outlinesFormat="cff",a=_.getUShort(i,4),o=Ga(i,a);else if(c==="wOFF"){const P=_.getTag(i,4);if(P==="\0\0\0")s.outlinesFormat="truetype";else if(P==="OTTO")s.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+c);a=_.getUShort(i,12),o=kd(i,a)}else if(c==="wOF2"){const P="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+P)}else throw new Error("Unsupported OpenType signature "+c);let l,u,f,h,p,y,m,b,v,w,T,C,E,R,N,V,Y,G;for(let P=0;P<a;P+=1){const D=o[P];let U;switch(D.tag){case"avar":m=D;break;case"cmap":U=Q(i,D),s.tables.cmap=yi.parse(U.data,U.offset),s.encoding=new xi(s.tables.cmap);break;case"cvt ":U=Q(i,D),G=new _.Parser(U.data,U.offset),s.tables.cvt=G.parseShortList(D.length/2);break;case"fvar":f=D;break;case"STAT":h=D;break;case"gvar":p=D;break;case"cvar":y=D;break;case"fpgm":U=Q(i,D),G=new _.Parser(U.data,U.offset),s.tables.fpgm=G.parseByteList(D.length);break;case"head":U=Q(i,D),s.tables.head=Bi.parse(U.data,U.offset),s.unitsPerEm=s.tables.head.unitsPerEm,n=s.tables.head.indexToLocFormat;break;case"hhea":U=Q(i,D),s.tables.hhea=Di.parse(U.data,U.offset),s.ascender=s.tables.hhea.ascender,s.descender=s.tables.hhea.descender,s.numberOfHMetrics=s.tables.hhea.numberOfHMetrics;break;case"HVAR":E=D;break;case"hmtx":C=D;break;case"ltag":U=Q(i,D),r=Ui.parse(U.data,U.offset);break;case"COLR":U=Q(i,D),s.tables.colr=zi.parse(U.data,U.offset);break;case"CPAL":U=Q(i,D),s.tables.cpal=Ti.parse(U.data,U.offset);break;case"maxp":U=Q(i,D),s.tables.maxp=Pi.parse(U.data,U.offset),s.numGlyphs=s.tables.maxp.numGlyphs;break;case"name":V=D;break;case"OS/2":U=Q(i,D),s.tables.os2=Mr.parse(U.data,U.offset);break;case"post":U=Q(i,D),s.tables.post=Ni.parse(U.data,U.offset),s.glyphNames=new Tr(s.tables.post);break;case"prep":U=Q(i,D),G=new _.Parser(U.data,U.offset),s.tables.prep=G.parseByteList(D.length);break;case"glyf":b=D;break;case"loca":N=D;break;case"CFF ":l=D;break;case"CFF2":u=D;break;case"kern":R=D;break;case"GDEF":v=D;break;case"GPOS":w=D;break;case"GSUB":T=D;break;case"meta":Y=D;break;case"gasp":try{U=Q(i,D),s.tables.gasp=Yi.parse(U.data,U.offset)}catch(re){console.warn("Failed to parse gasp table, skipping."),console.warn(re)}break;case"SVG ":U=Q(i,D),s.tables.svg=Xi.parse(U.data,U.offset);break}}const J=Q(i,V);if(s.tables.name=mi.parse(J.data,J.offset,r),s.names=s.tables.name,b&&N){const P=n===0,D=Q(i,N),U=Cd.parse(D.data,D.offset,s.numGlyphs,P),re=Q(i,b);s.glyphs=la.parse(re.data,re.offset,U,s,e)}else if(l){const P=Q(i,l);Lr.parse(P.data,P.offset,s,e)}else if(u){const P=Q(i,u);Lr.parse(P.data,P.offset,s,e)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");const ie=Q(i,C);if(_i.parse(s,ie.data,ie.offset,s.numberOfHMetrics,s.numGlyphs,s.glyphs,e),vl(s,e),R){const P=Q(i,R);s.kerningPairs=wd.parse(P.data,P.offset)}else s.kerningPairs={};if(v){const P=Q(i,v);s.tables.gdef=dd.parse(P.data,P.offset)}if(w){const P=Q(i,w);s.tables.gpos=bd.parse(P.data,P.offset),s.position.init()}if(T){const P=Q(i,T);s.tables.gsub=Gi.parse(P.data,P.offset)}if(f){const P=Q(i,f);s.tables.fvar=Wi.parse(P.data,P.offset,s.names)}if(h){const P=Q(i,h);s.tables.stat=Vi.parse(P.data,P.offset,s.tables.fvar)}if(p){f||console.warn("This font provides a gvar table, but no fvar table, which is required for variable fonts."),b||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");const P=Q(i,p);s.tables.gvar=$i.parse(P.data,P.offset,s.tables.fvar,s.glyphs)}if(y){f||console.warn("This font provides a cvar table, but no fvar table, which is required for variable fonts."),s.tables.cvt||console.warn("This font provides a cvar table, but no cvt table which could be made variable."),b||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");const P=Q(i,y);s.tables.cvar=qi.parse(P.data,P.offset,s.tables.fvar,s.tables.cvt||[])}if(m){f||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");const P=Q(i,m);s.tables.avar=ji.parse(P.data,P.offset,s.tables.fvar)}if(E){f||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),C||console.warn("This font provides an HVAR table, but no hmtx table to vary.");const P=Q(i,E);s.tables.hvar=od.parse(P.data,P.offset,s.tables.fvar)}if(Y){const P=Q(i,Y);s.tables.meta=Hi.parse(P.data,P.offset),s.metas=s.tables.meta}return s.palettes=new ia(s),s}const Ed=1.15,Ad=.9,Od=["国","中","永"];function Ha(t,e){const n=t.charToGlyphIndex(e);return n!=null&&n>0}function Ld(t){var a;const e=t.unitsPerEm||1e3;if(!Ha(t,"A"))return 1;const n=t.charToGlyph("A"),r=n==null?void 0:n.yMax;if(!r||r<=0)return 1;const s=e/r;let i=0;for(const o of Od)if(Ha(t,o)){i=((a=t.charToGlyph(o))==null?void 0:a.advanceWidth)??0;break}return i>=e*Ad&&s>Ed?1:s}function Id(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),s=new Set(Object.keys(t[0].morphAttributes)),i={},a={},o=t[0].morphTargetsRelative,c=new he.BufferGeometry;let l=0;for(let u=0;u<t.length;++u){const f=t[u];let h=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in f.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;i[p]===void 0&&(i[p]=[]),i[p].push(f.attributes[p]),h++}if(h!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in f.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(f.morphAttributes[p])}if(e){let p;if(n)p=f.index.count;else if(f.attributes.position!==void 0)p=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,p,u),l+=p}}if(n){let u=0;const f=[];for(let h=0;h<t.length;++h){const p=t[h].index;for(let y=0;y<p.count;++y)f.push(p.getX(y)+u);u+=t[h].attributes.position.count}c.setIndex(f)}for(const u in i){const f=za(i[u]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;c.setAttribute(u,f)}for(const u in a){const f=a[u][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[u]=[];for(let h=0;h<f;++h){const p=[];for(let m=0;m<a[u].length;++m)p.push(a[u][m][h]);const y=za(p);if(!y)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;c.morphAttributes[u].push(y)}}return c}function za(t){let e,n,r,s=-1,i=0;for(let l=0;l<t.length;++l){const u=t[l];if(e===void 0&&(e=u.array.constructor),e!==u.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=u.itemSize),n!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=u.normalized),r!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=u.gpuType),s!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;i+=u.count*n}const a=new e(i),o=new he.BufferAttribute(a,n,r);let c=0;for(let l=0;l<t.length;++l){const u=t[l];if(u.isInterleavedBufferAttribute){const f=c/n;for(let h=0,p=u.count;h<p;h++)for(let y=0;y<n;y++){const m=u.getComponent(h,y);o.setComponent(h+f,y,m)}}else a.set(u.array,c);c+=u.count*n}return s!==void 0&&(o.gpuType=s),o}function Md(t,e=1e-4){e=Math.max(e,Number.EPSILON);const n={},r=t.getIndex(),s=t.getAttribute("position"),i=r?r.count:s.count;let a=0;const o=Object.keys(t.attributes),c={},l={},u=[],f=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let w=0,T=o.length;w<T;w++){const C=o[w],E=t.attributes[C];c[C]=new E.constructor(new E.array.constructor(E.count*E.itemSize),E.itemSize,E.normalized);const R=t.morphAttributes[C];R&&(l[C]||(l[C]=[]),R.forEach((N,V)=>{const Y=new N.array.constructor(N.count*N.itemSize);l[C][V]=new N.constructor(Y,N.itemSize,N.normalized)}))}const p=e*.5,y=Math.log10(1/e),m=Math.pow(10,y),b=p*m;for(let w=0;w<i;w++){const T=r?r.getX(w):w;let C="";for(let E=0,R=o.length;E<R;E++){const N=o[E],V=t.getAttribute(N),Y=V.itemSize;for(let G=0;G<Y;G++)C+=`${~~(V[f[G]](T)*m+b)},`}if(C in n)u.push(n[C]);else{for(let E=0,R=o.length;E<R;E++){const N=o[E],V=t.getAttribute(N),Y=t.morphAttributes[N],G=V.itemSize,J=c[N],ie=l[N];for(let P=0;P<G;P++){const D=f[P],U=h[P];if(J[U](a,V[D](T)),Y)for(let re=0,Ae=Y.length;re<Ae;re++)ie[re][U](a,Y[re][D](T))}}n[C]=a,u.push(a),a++}}const v=t.clone();for(const w in t.attributes){const T=c[w];if(v.setAttribute(w,new T.constructor(T.array.slice(0,a*T.itemSize),T.itemSize,T.normalized)),w in l)for(let C=0;C<l[w].length;C++){const E=l[w][C];v.morphAttributes[w][C]=new E.constructor(E.array.slice(0,a*E.itemSize),E.itemSize,E.normalized)}}return v.setIndex(u),v}new M.Vector2;function Wa(t){const e=t.getAttribute("position");if(!e||e.count===0)return!0;const n=e.array;for(let r=0;r<n.length;r++)if(!Number.isFinite(n[r]))return!1;return!0}class Rd extends tr{constructor(e,n,r){super(),this.isFound=!1,this.char=e,this.fontSize=n,this.font=r,this.width=this.getCharWidth(e,n,r)}toGeometry(){let e=this.font.cache.getGeometry(this.char.charCodeAt(0),this.fontSize);if(e==null){const n=this.font.generateShapes(this.char,this.fontSize);if(e=new M.ShapeGeometry(n,4),!Wa(e))return e.dispose(),new M.BufferGeometry;e.hasAttribute("uv")&&e.deleteAttribute("uv"),e.hasAttribute("normal")&&e.deleteAttribute("normal"),e=Md(e,1e-6),this.font.cache.setGeometry(this.char.charCodeAt(0),this.fontSize,e)}return Wa(e)?e:new M.BufferGeometry}hasStrokeGeometry(){return this.isFound&&this.width>0}getCharWidth(e,n,r){const s=r.data.glyphs[e];return s?(this.isFound=!0,s.ha*n/r.data.resolution):(this.isFound=!1,0)}}class Bd{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,n=100){const r=[],s=Dd(e,n,this.data);for(let i=0,a=s.length;i<a;i++)r.push(...s[i].toShapes());return r}}function Dd(t,e,n){const r=Array.from(t),s=e/n.resolution,i=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*s,a=[];let o=0,c=0;for(let l=0;l<r.length;l++){const u=r[l];if(u===`
|
|
3
3
|
`)o=0,c-=i;else{const f=_d(u,s,o,c,n);o+=f.offsetX,a.push(f.path)}}return a}function _d(t,e,n,r,s){const i=s.glyphs[t]||s.glyphs["?"];if(!i){console.error('THREE.Font: character "'+t+'" does not exists in font family '+s.familyName+".");return}const a=new he.ShapePath;let o,c,l,u,f,h,p,y;if(i.o){const m=i._cachedOutline||(i._cachedOutline=i.o.split(" "));for(let b=0,v=m.length;b<v;)switch(m[b++]){case"m":o=m[b++]*e+n,c=m[b++]*e+r,a.moveTo(o,c);break;case"l":o=m[b++]*e+n,c=m[b++]*e+r,a.lineTo(o,c);break;case"q":l=m[b++]*e+n,u=m[b++]*e+r,f=m[b++]*e+n,h=m[b++]*e+r,a.quadraticCurveTo(f,h,l,u);break;case"b":l=m[b++]*e+n,u=m[b++]*e+r,f=m[b++]*e+n,h=m[b++]*e+r,p=m[b++]*e+n,y=m[b++]*e+r,a.bezierCurveTo(f,h,p,y,l,u);break}}return{offsetX:i.ha*e,path:a}}class Ud extends Bd{generateShapes(e,n=100,r="ltr"){const s=[];return Pd(e,n,this.data,r).forEach(a=>{s.push(...jd(a))}),s}}function Pd(t,e,n,r="ltr"){const s=Array.from(t),i=e/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*i,o=[];let c=0,l=0;(r==="rtl"||r==="tb")&&s.reverse();for(const u of s)if(u===`
|
|
4
4
|
`)c=0,l-=a;else{const f=Nd(u,i,c,l,n);if(!f)continue;r==="tb"?(c=0,l+=n.ascender*i):c+=f.offsetX,o.push(f.path)}return o}function Nd(t,e,n,r,s){const i=s.glyphs[t]||s.glyphs["?"];if(!i){console.error(`THREE.Font: character "${t}" does not exist in font family ${s.familyName}.`);return}const a=new he.ShapePath;if(i.o){const o=i.o.split(" ");let c=0;for(;c<o.length;){const l=o[c++];let u,f,h,p,y,m,b,v;switch(l){case"m":u=parseFloat(o[c++])*e+n,f=parseFloat(o[c++])*e+r,a.moveTo(u,f);break;case"l":u=parseFloat(o[c++])*e+n,f=parseFloat(o[c++])*e+r,a.lineTo(u,f);break;case"q":h=parseFloat(o[c++])*e+n,p=parseFloat(o[c++])*e+r,y=parseFloat(o[c++])*e+n,m=parseFloat(o[c++])*e+r,a.quadraticCurveTo(y,m,h,p);break;case"b":h=parseFloat(o[c++])*e+n,p=parseFloat(o[c++])*e+r,y=parseFloat(o[c++])*e+n,m=parseFloat(o[c++])*e+r,b=parseFloat(o[c++])*e+n,v=parseFloat(o[c++])*e+r,a.bezierCurveTo(y,m,b,v,h,p);break}}}return{offsetX:i.ha*e,path:a}}function Gd(t,e){let n=!1;const{x:r,y:s}=t,i=e.length;for(let a=0,o=i-1;a<i;o=a++){const c=e[a].x,l=e[a].y,u=e[o].x,f=e[o].y;l>s!=f>s&&r<(u-c)*(s-l)/(f-l)+c&&(n=!n)}return n}function Hd(t){const e=t.length,n=Array(e).fill(null);for(let r=0;r<e;r++){let s=null,i=1/0;for(let a=0;a<e;a++)if(r!==a&&t[r].every(o=>Gd(o,t[a]))){const o=Math.abs(he.ShapeUtils.area(t[a]));o<i&&(i=o,s=a)}n[r]=s}return n}function zd(t){const e=t.length,n=Array.from({length:e},()=>[]);for(let r=0;r<e;r++){const s=t[r];s!==null&&n[s].push(r)}return n}function Wd(t){return t.map((e,n)=>e===null?n:-1).filter(e=>e>=0)}function Vd(t){const e=[];for(let n=t.length-1;n>=0;n--){const r=t[n];if(r instanceof he.LineCurve)e.push(new he.LineCurve(r.v2.clone(),r.v1.clone()));else if(r instanceof he.QuadraticBezierCurve)e.push(new he.QuadraticBezierCurve(r.v2.clone(),r.v1.clone(),r.v0.clone()));else if(r instanceof he.CubicBezierCurve)e.push(new he.CubicBezierCurve(r.v3.clone(),r.v2.clone(),r.v1.clone(),r.v0.clone()));else if(r instanceof he.EllipseCurve)e.push(new he.EllipseCurve(r.aX,r.aY,r.xRadius,r.yRadius,r.aEndAngle,r.aStartAngle,!r.aClockwise,r.aRotation));else if(typeof r.getPoints=="function"){const s=r.getPoints(8);for(let i=s.length-1;i>0;i--)e.push(new he.LineCurve(s[i].clone(),s[i-1].clone()))}}return e}function Va(t,e){const n=he.ShapeUtils.area(t.getPoints(32))>0,r=e===n?t.curves.slice():Vd(t.curves),s=new he.Shape;return s.curves.push(...r),s}function jd(t,e=32){const n=t.subPaths;if(!n||n.length===0)return[];const r=n.map(p=>p.getPoints(e)),s=Hd(r),i=zd(s),a=Wd(s),o=n.length,c=Array(o).fill(-1),l=Array(o).fill(-1);for(const p of a){const y=[{idx:p,d:0}];for(;y.length;){const m=y.pop();c[m.idx]=m.d,l[m.idx]=p;for(const b of i[m.idx])y.push({idx:b,d:m.d+1})}}const u=[],f=new Set;function h(p){const y=Va(n[p],!0);f.add(p);for(const m of i[p])if(!f.has(m)&&c[m]===c[p]+1){const b=Va(n[m],!1);y.holes.push(b),f.add(m)}u.push(y)}for(const p of a)h(p);for(let p=0;p<o;p++)f.has(p)||h(p);return u}const qd=61440;class $d extends er{constructor(e){super(e),this.type="mesh",this.glyphCache=new Qn(512);const n=e.data;if(n instanceof ArrayBuffer){const r=this.parseMeshFont(n);this.data=r.data,this.opentypeFont=r.font}else throw new Error("Invalid font cache data. Please remove font cache database named 'mlightcad' in IndexedDB and try again!");this.font=new Ud(this.data)}parseMeshFont(e){const n=Fd(e),r=Math.round,s=Ld(n),i={glyphs:{},familyName:n.getEnglishName("fullName"),ascender:r(n.ascender),descender:r(n.descender),underlinePosition:n.tables.post.underlinePosition,underlineThickness:n.tables.post.underlineThickness,boundingBox:{xMin:n.tables.head.xMin,xMax:n.tables.head.xMax,yMin:n.tables.head.yMin,yMax:n.tables.head.yMax},resolution:n.unitsPerEm||1e3,scaleFactor:s,original_font_information:n.tables.name};return{font:n,data:i}}opentypeLookupChar(e){if(!this.opentypeFont||e.length!==1)return e;const n=e.charCodeAt(0),r=this.opentypeFont.charToGlyphIndex(e);if(r!=null&&r>0)return e;if(n>=32&&n<=126){const s=String.fromCharCode(qd+n),i=this.opentypeFont.charToGlyphIndex(s);if(i!=null&&i>0)return s}return e}opentypeHasGlyph(e){if(!this.opentypeFont)return!1;const n=this.opentypeLookupChar(e),r=this.opentypeFont.charToGlyphIndex(n);return r!=null&&r>0}hasChar(e){return this.opentypeHasGlyph(e)}hasCode(e){return this.hasChar(String.fromCodePoint(e))}_loadGlyphIfNeeded(e){if(this.data.glyphs[e]||!this.opentypeFont)return;const n=this.glyphCache.get(e);if(n){this.data.glyphs[e]=n;return}if(this.opentypeHasGlyph(e)){const r=this.opentypeLookupChar(e),s=this.opentypeFont.charToGlyph(r);if(!s||!s.path)return;const i=Math.round,a={ha:i(s.advanceWidth??0),x_min:i(s.xMin??0),x_max:i(s.xMax??0),o:""};s.path.commands.forEach(o=>{let c=o.type.toLowerCase();c==="c"&&(c="b"),a.o+=c+" ",o.x!==void 0&&o.y!==void 0&&(a.o+=i(o.x)+" "+i(o.y)+" "),o.x1!==void 0&&o.y1!==void 0&&(a.o+=i(o.x1)+" "+i(o.y1)+" "),o.x2!==void 0&&o.y2!==void 0&&(a.o+=i(o.x2)+" "+i(o.y2)+" ")}),this.data.glyphs[e]=a,this.glyphCache.set(e,a)}}generateShapes(e,n){for(const r of e)this._loadGlyphIfNeeded(r);return this.font.generateShapes(e,n)}getCharShape(e,n){if(this._loadGlyphIfNeeded(e),!this.data.glyphs[e]){this.addUnsupportedChar(e);return}return new Rd(e,n,this)}getCodeShape(e,n){return this.getCharShape(String.fromCodePoint(e),n)}getScaleFactor(){return this.scaleFactor==null?(this.scaleFactor=this.data.scaleFactor,this.scaleFactor):this.scaleFactor}getNotFoundTextShape(e){return this.getCharShape("?",e)}estimateMemoryUsage(){var a;const e=this.cache.getStats();let n=0;const r=Object.keys(this.data.glyphs);for(const o of r)n+=Ss((a=this.data.glyphs[o])==null?void 0:a.o);const s=Math.round(this.sourceByteLength*zs),i=s+n+e.estimatedBytes;return{names:Array.from(this.names),type:"mesh",sourceByteLength:this.sourceByteLength,parsedFontEstimatedBytes:s,charGeometryCache:e,meshGlyphs:{glyphCount:r.length,outlineStringBytes:n},estimatedBytes:i}}dispose(){this.glyphCache.clear(),this.data.glyphs={},super.dispose()}}function Yd(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Xd(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var ja={exports:{}},$r={},zn={};zn.byteLength=Jd,zn.toByteArray=e0,zn.fromByteArray=r0;for(var Je=[],Pe=[],Kd=typeof Uint8Array<"u"?Uint8Array:Array,Yr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Nt=0,Zd=Yr.length;Nt<Zd;++Nt)Je[Nt]=Yr[Nt],Pe[Yr.charCodeAt(Nt)]=Nt;Pe[45]=62,Pe[95]=63;function qa(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function Jd(t){var e=qa(t),n=e[0],r=e[1];return(n+r)*3/4-r}function Qd(t,e,n){return(e+n)*3/4-n}function e0(t){var e,n=qa(t),r=n[0],s=n[1],i=new Kd(Qd(t,r,s)),a=0,o=s>0?r-4:r,c;for(c=0;c<o;c+=4)e=Pe[t.charCodeAt(c)]<<18|Pe[t.charCodeAt(c+1)]<<12|Pe[t.charCodeAt(c+2)]<<6|Pe[t.charCodeAt(c+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return s===2&&(e=Pe[t.charCodeAt(c)]<<2|Pe[t.charCodeAt(c+1)]>>4,i[a++]=e&255),s===1&&(e=Pe[t.charCodeAt(c)]<<10|Pe[t.charCodeAt(c+1)]<<4|Pe[t.charCodeAt(c+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function t0(t){return Je[t>>18&63]+Je[t>>12&63]+Je[t>>6&63]+Je[t&63]}function n0(t,e,n){for(var r,s=[],i=e;i<n;i+=3)r=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),s.push(t0(r));return s.join("")}function r0(t){for(var e,n=t.length,r=n%3,s=[],i=16383,a=0,o=n-r;a<o;a+=i)s.push(n0(t,a,a+i>o?o:a+i));return r===1?(e=t[n-1],s.push(Je[e>>2]+Je[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],s.push(Je[e>>10]+Je[e>>4&63]+Je[e<<2&63]+"=")),s.join("")}var Xr={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Xr.read=function(t,e,n,r,s){var i,a,o=s*8-r-1,c=(1<<o)-1,l=c>>1,u=-7,f=n?s-1:0,h=n?-1:1,p=t[e+f];for(f+=h,i=p&(1<<-u)-1,p>>=-u,u+=o;u>0;i=i*256+t[e+f],f+=h,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=r;u>0;a=a*256+t[e+f],f+=h,u-=8);if(i===0)i=1-l;else{if(i===c)return a?NaN:(p?-1:1)*(1/0);a=a+Math.pow(2,r),i=i-l}return(p?-1:1)*a*Math.pow(2,i-r)},Xr.write=function(t,e,n,r,s,i){var a,o,c,l=i*8-s-1,u=(1<<l)-1,f=u>>1,h=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,y=r?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),a+f>=1?e+=h/c:e+=h*Math.pow(2,1-f),e*c>=2&&(a++,c/=2),a+f>=u?(o=0,a=u):a+f>=1?(o=(e*c-1)*Math.pow(2,s),a=a+f):(o=e*Math.pow(2,f-1)*Math.pow(2,s),a=0));s>=8;t[n+p]=o&255,p+=y,o/=256,s-=8);for(a=a<<s|o,l+=s;l>0;t[n+p]=a&255,p+=y,a/=256,l-=8);t[n+p-y]|=m*128};/*!
|
|
@@ -8920,13 +8920,31 @@ const Qr = {
|
|
|
8920
8920
|
// BIGFONT SHX stays available via glyph fallback for CJK coverage.
|
|
8921
8921
|
modern: ["simsun", "hztxt"],
|
|
8922
8922
|
international: ["txt", "simplex", "romans", "simsun"],
|
|
8923
|
-
|
|
8923
|
+
// Full CJK: mesh faces for CN/KR/JP, then matching SHX big fonts.
|
|
8924
|
+
// `malgun` → Noto Sans KR; `msgothic` → MS Gothic in the font repository.
|
|
8925
|
+
cjk: [
|
|
8926
|
+
"simsun",
|
|
8927
|
+
"malgun",
|
|
8928
|
+
"msgothic",
|
|
8929
|
+
"gbcbig",
|
|
8930
|
+
"hztxt",
|
|
8931
|
+
"extfont2",
|
|
8932
|
+
"extfont",
|
|
8933
|
+
"whgtxt",
|
|
8934
|
+
"whgdtxt"
|
|
8935
|
+
],
|
|
8936
|
+
chinese: ["simsun", "gbcbig", "hztxt"],
|
|
8937
|
+
korean: ["malgun", "whgtxt", "whgdtxt"],
|
|
8938
|
+
japanese: ["msgothic", "extfont2", "extfont"]
|
|
8924
8939
|
}, br = {
|
|
8925
8940
|
minimal: ["simplex", "amgdt"],
|
|
8926
8941
|
r12r14: ["simplex", "amgdt"],
|
|
8927
8942
|
modern: ["simplex", "amgdt"],
|
|
8928
8943
|
international: ["simplex", "amgdt"],
|
|
8929
|
-
cjk: ["simplex", "amgdt"]
|
|
8944
|
+
cjk: ["simplex", "amgdt"],
|
|
8945
|
+
chinese: ["simplex", "amgdt"],
|
|
8946
|
+
korean: ["simplex", "amgdt"],
|
|
8947
|
+
japanese: ["simplex", "amgdt"]
|
|
8930
8948
|
};
|
|
8931
8949
|
function Do(n) {
|
|
8932
8950
|
return Object.prototype.hasOwnProperty.call(Qr, n);
|
|
@@ -13,8 +13,17 @@ export type DefaultFontsPreset =
|
|
|
13
13
|
| 'modern'
|
|
14
14
|
/** Western SHX fonts plus simsun and AMGDT; no CJK-specific SHX big fonts. */
|
|
15
15
|
| 'international'
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Broad CJK coverage: Chinese / Korean / Japanese mesh fonts plus matching
|
|
18
|
+
* SHX big fonts.
|
|
19
|
+
*/
|
|
20
|
+
| 'cjk'
|
|
21
|
+
/** Simplified Chinese: simsun (TTF) plus GB big-font SHX. */
|
|
22
|
+
| 'chinese'
|
|
23
|
+
/** Korean: malgun / Noto Sans KR (TTF) plus Korean big-font SHX. */
|
|
24
|
+
| 'korean'
|
|
25
|
+
/** Japanese: MS Gothic (TTF) plus extfont2 / extfont SHX. */
|
|
26
|
+
| 'japanese';
|
|
18
27
|
/**
|
|
19
28
|
* Predefined text-font fallback chains (primary / big-font substitutes and CJK
|
|
20
29
|
* mesh fallbacks). Symbol fonts such as `amgdt` are configured separately via
|