@mlightcad/mtext-renderer 0.4.6 → 0.4.7
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 +2 -2
- package/dist/index.umd.cjs +1 -1
- package/lib/worker/index.d.ts +5 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13259,8 +13259,8 @@ export {
|
|
|
13259
13259
|
El as MText,
|
|
13260
13260
|
yl as MTextAttachmentPoint,
|
|
13261
13261
|
je as MTextFlowDirection,
|
|
13262
|
-
bn as MTextWorkerManager,
|
|
13263
13262
|
Ul as MainThreadRenderer,
|
|
13264
13263
|
Ol as StyleManager,
|
|
13265
|
-
Pl as UnifiedRenderer
|
|
13264
|
+
Pl as UnifiedRenderer,
|
|
13265
|
+
bn as WebWorkerRenderer
|
|
13266
13266
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function(v,se){typeof exports=="object"&&typeof module<"u"?se(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],se):(v=typeof globalThis<"u"?globalThis:v||self,se(v.MTextRenderer={},v.THREE))})(this,function(v,se){"use strict";var St=typeof document<"u"?document.currentScript:null;function Ca(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const R=Ca(se);class kt{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(r=>r!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...r){for(const n of this.listeners)n.call(null,e,...r)}}class Ea{constructor(){this.cache=new Map}hasGeometry(e,r){const n=this.generateKey(e,r);return this.cache.has(n)}getGeometry(e,r){const n=this.generateKey(e,r);if(this.cache.has(n))return this.cache.get(n)}setGeometry(e,r,n){const a=this.generateKey(e,r);this.cache.set(a,n)}dispose(){for(const e of this.cache.values())e.dispose();this.cache.clear()}generateKey(e,r){return`${e}_${r}`}}class Ft{constructor(){this.unsupportedChars={},this.cache=new Ea}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}}class Tt extends R.Shape{constructor(e){super(),this.width=0,this.char=e}}const wt=(t,e)=>e.some(r=>t instanceof r);let Fr,Tr;function Oa(){return Fr||(Fr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ua(){return Tr||(Tr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Ct=new WeakMap,Et=new WeakMap,at=new WeakMap;function La(t){const e=new Promise((r,n)=>{const a=()=>{t.removeEventListener("success",s),t.removeEventListener("error",i)},s=()=>{r(Oe(t.result)),a()},i=()=>{n(t.error),a()};t.addEventListener("success",s),t.addEventListener("error",i)});return at.set(e,t),e}function Ra(t){if(Ct.has(t))return;const e=new Promise((r,n)=>{const a=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",i),t.removeEventListener("abort",i)},s=()=>{r(),a()},i=()=>{n(t.error||new DOMException("AbortError","AbortError")),a()};t.addEventListener("complete",s),t.addEventListener("error",i),t.addEventListener("abort",i)});Ct.set(t,e)}let Ot={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Ct.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Oe(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function wr(t){Ot=t(Ot)}function Ma(t){return Ua().includes(t)?function(...e){return t.apply(Ut(this),e),Oe(this.request)}:function(...e){return Oe(t.apply(Ut(this),e))}}function Aa(t){return typeof t=="function"?Ma(t):(t instanceof IDBTransaction&&Ra(t),wt(t,Oa())?new Proxy(t,Ot):t)}function Oe(t){if(t instanceof IDBRequest)return La(t);if(Et.has(t))return Et.get(t);const e=Aa(t);return e!==t&&(Et.set(t,e),at.set(e,t)),e}const Ut=t=>at.get(t);function Pa(t,e,{blocked:r,upgrade:n,blocking:a,terminated:s}={}){const i=indexedDB.open(t,e),o=Oe(i);return n&&i.addEventListener("upgradeneeded",u=>{n(Oe(i.result),u.oldVersion,u.newVersion,Oe(i.transaction),u)}),r&&i.addEventListener("blocked",u=>r(u.oldVersion,u.newVersion,u)),o.then(u=>{s&&u.addEventListener("close",()=>s()),a&&u.addEventListener("versionchange",l=>a(l.oldVersion,l.newVersion,l))}).catch(()=>{}),o}const Ba=["get","getKey","getAll","getAllKeys","count"],Ia=["put","add","delete","clear"],Lt=new Map;function Cr(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Lt.get(e))return Lt.get(e);const r=e.replace(/FromIndex$/,""),n=e!==r,a=Ia.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(a||Ba.includes(r)))return;const s=async function(i,...o){const u=this.transaction(i,a?"readwrite":"readonly");let l=u.store;return n&&(l=l.index(o.shift())),(await Promise.all([l[r](...o),a&&u.done]))[0]};return Lt.set(e,s),s}wr(t=>({...t,get:(e,r,n)=>Cr(e,r)||t.get(e,r,n),has:(e,r)=>!!Cr(e,r)||t.has(e,r)}));const Da=["continue","continuePrimaryKey","advance"],Er={},Rt=new WeakMap,Or=new WeakMap,Ga={get(t,e){if(!Da.includes(e))return t[e];let r=Er[e];return r||(r=Er[e]=function(...n){Rt.set(this,Or.get(this)[e](...n))}),r}};async function*Na(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;const r=new Proxy(e,Ga);for(Or.set(r,e),at.set(r,Ut(e));e;)yield r,e=await(Rt.get(r)||e.continue()),Rt.delete(r)}function Ur(t,e){return e===Symbol.asyncIterator&&wt(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&wt(t,[IDBIndex,IDBObjectStore])}wr(t=>({...t,get(e,r,n){return Ur(e,r)?Na:t.get(e,r,n)},has(e,r){return Ur(e,r)||t.has(e,r)}}));const Be={fonts:"fonts"},Mt=[{version:1,stores:[{name:Be.fonts,keyPath:"name"}]}],ae=class ae{constructor(){this.isClosing=!1,typeof window<"u"&&window.addEventListener("unload",()=>{this.close()})}static get instance(){return ae._instance||(ae._instance=new ae),ae._instance}async set(e,r){await(await this.getDatabase()).put(Be.fonts,{...r,name:e})}async get(e){return await(await this.getDatabase()).get(Be.fonts,e)}async delete(e){await(await this.getDatabase()).delete(Be.fonts,e)}async getAll(){return await(await this.getDatabase()).getAll(Be.fonts)}async clear(){await(await this.getDatabase()).clear(Be.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(ae.DATABASE_NAME),ae._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 Pa(ae.DATABASE_NAME,ae.DATABASE_VERSION,{upgrade:(e,r,n)=>this.handleUpgrade(e,r,n),blocked(){console.warn("Database upgrade blocked - please close other tabs using the application")},blocking(){console.warn("Database blocking newer version - closing connection"),ae.instance.close()}}),this.db)}handleUpgrade(e,r,n){const a=Mt.filter(s=>s.version>r&&(!n||s.version<=n));for(const s of a)this.applySchemaVersion(e,s)}applySchemaVersion(e,r){for(const n of r.stores)e.objectStoreNames.contains(n.name)||e.createObjectStore(n.name,{keyPath:n.keyPath})}};ae.DATABASE_NAME="mlightcad",ae.DATABASE_VERSION=Mt[Mt.length-1].version;let We=ae;const _a=t=>t.substring(t.lastIndexOf(".")+1),Lr=t=>t.split("/").pop(),Rr=t=>{const e=Lr(t);if(e){const r=e.lastIndexOf(".");return r===-1?e:e.substring(0,r)}return t},Ha=[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],za=t=>Ha[t];let Wa=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,r=100){const n=[],a=Va(e,r,this.data);for(let s=0,i=a.length;s<i;s++)n.push(...a[s].toShapes());return n}};function Va(t,e,r){const n=Array.from(t),a=e/r.resolution,s=(r.boundingBox.yMax-r.boundingBox.yMin+r.underlineThickness)*a,i=[];let o=0,u=0;for(let l=0;l<n.length;l++){const c=n[l];if(c===`
|
|
2
2
|
`)o=0,u-=s;else{const f=qa(c,a,o,u,r);o+=f.offsetX,i.push(f.path)}}return i}function qa(t,e,r,n,a){const s=a.glyphs[t]||a.glyphs["?"];if(!s){console.error('THREE.Font: character "'+t+'" does not exists in font family '+a.familyName+".");return}const i=new se.ShapePath;let o,u,l,c,f,h,p,d;if(s.o){const m=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let b=0,y=m.length;b<y;)switch(m[b++]){case"m":o=m[b++]*e+r,u=m[b++]*e+n,i.moveTo(o,u);break;case"l":o=m[b++]*e+r,u=m[b++]*e+n,i.lineTo(o,u);break;case"q":l=m[b++]*e+r,c=m[b++]*e+n,f=m[b++]*e+r,h=m[b++]*e+n,i.quadraticCurveTo(f,h,l,c);break;case"b":l=m[b++]*e+r,c=m[b++]*e+n,f=m[b++]*e+r,h=m[b++]*e+n,p=m[b++]*e+r,d=m[b++]*e+n,i.bezierCurveTo(f,h,p,d,l,c);break}}return{offsetX:s.ha*e,path:i}}function Mr(t,e=!1){const r=t[0].index!==null,n=new Set(Object.keys(t[0].attributes)),a=new Set(Object.keys(t[0].morphAttributes)),s={},i={},o=t[0].morphTargetsRelative,u=new se.BufferGeometry;let l=0;for(let c=0;c<t.length;++c){const f=t[c];let h=0;if(r!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". 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(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(f.attributes[p]),h++}if(h!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". 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 "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in f.morphAttributes){if(!a.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;i[p]===void 0&&(i[p]=[]),i[p].push(f.morphAttributes[p])}if(e){let p;if(r)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 "+c+". The geometry must have either an index or a position attribute"),null;u.addGroup(l,p,c),l+=p}}if(r){let c=0;const f=[];for(let h=0;h<t.length;++h){const p=t[h].index;for(let d=0;d<p.count;++d)f.push(p.getX(d)+c);c+=t[h].attributes.position.count}u.setIndex(f)}for(const c in s){const f=Ar(s[c]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;u.setAttribute(c,f)}for(const c in i){const f=i[c][0].length;if(f===0)break;u.morphAttributes=u.morphAttributes||{},u.morphAttributes[c]=[];for(let h=0;h<f;++h){const p=[];for(let m=0;m<i[c].length;++m)p.push(i[c][m][h]);const d=Ar(p);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;u.morphAttributes[c].push(d)}}return u}function Ar(t){let e,r,n,a=-1,s=0;for(let l=0;l<t.length;++l){const c=t[l];if(e===void 0&&(e=c.array.constructor),e!==c.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(r===void 0&&(r=c.itemSize),r!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=c.normalized),n!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(a===-1&&(a=c.gpuType),a!==c.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=c.count*r}const i=new e(s),o=new se.BufferAttribute(i,r,n);let u=0;for(let l=0;l<t.length;++l){const c=t[l];if(c.isInterleavedBufferAttribute){const f=u/r;for(let h=0,p=c.count;h<p;h++)for(let d=0;d<r;d++){const m=c.getComponent(h,d);o.setComponent(h+f,d,m)}}else i.set(c.array,u);u+=c.count*r}return a!==void 0&&(o.gpuType=a),o}function Xa(t,e=1e-4){e=Math.max(e,Number.EPSILON);const r={},n=t.getIndex(),a=t.getAttribute("position"),s=n?n.count:a.count;let i=0;const o=Object.keys(t.attributes),u={},l={},c=[],f=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let S=0,x=o.length;S<x;S++){const C=o[S],k=t.attributes[C];u[C]=new k.constructor(new k.array.constructor(k.count*k.itemSize),k.itemSize,k.normalized);const A=t.morphAttributes[C];A&&(l[C]||(l[C]=[]),A.forEach((U,E)=>{const B=new U.array.constructor(U.count*U.itemSize);l[C][E]=new U.constructor(B,U.itemSize,U.normalized)}))}const p=e*.5,d=Math.log10(1/e),m=Math.pow(10,d),b=p*m;for(let S=0;S<s;S++){const x=n?n.getX(S):S;let C="";for(let k=0,A=o.length;k<A;k++){const U=o[k],E=t.getAttribute(U),B=E.itemSize;for(let z=0;z<B;z++)C+=`${~~(E[f[z]](x)*m+b)},`}if(C in r)c.push(r[C]);else{for(let k=0,A=o.length;k<A;k++){const U=o[k],E=t.getAttribute(U),B=t.morphAttributes[U],z=E.itemSize,Q=u[U],J=l[U];for(let Z=0;Z<z;Z++){const D=f[Z],W=h[Z];if(Q[W](i,E[D](x)),B)for(let N=0,q=B.length;N<q;N++)J[N][W](i,B[N][D](x))}}r[C]=i,c.push(i),i++}}const y=t.clone();for(const S in t.attributes){const x=u[S];if(y.setAttribute(S,new x.constructor(x.array.slice(0,i*x.itemSize),x.itemSize,x.normalized)),S in l)for(let C=0;C<l[S].length;C++){const k=l[S][C];y.morphAttributes[S][C]=new k.constructor(k.array.slice(0,i*k.itemSize),k.itemSize,k.normalized)}}return y.setIndex(c),y}class Ya extends se.ExtrudeGeometry{constructor(e,r={}){const n=r.font;if(n===void 0)super();else{const a=n.generateShapes(e,r.size);r.depth===void 0&&r.height!==void 0&&console.warn("THREE.TextGeometry: .height is now depreciated. Please use .depth instead"),r.depth=r.depth!==void 0?r.depth:r.height!==void 0?r.height:50,r.bevelThickness===void 0&&(r.bevelThickness=10),r.bevelSize===void 0&&(r.bevelSize=8),r.bevelEnabled===void 0&&(r.bevelEnabled=!1),super(a,r)}this.type="TextGeometry"}}const xr=class xr{static dummyComputeVertexNormals(){}static disable(){se.BufferGeometry.prototype.computeVertexNormals=this.dummyComputeVertexNormals}static restore(){se.BufferGeometry.prototype.computeVertexNormals=this.originalComputeVertexNormals}static runWithoutNormals(e){this.disable();try{return e()}finally{this.restore()}}};xr.originalComputeVertexNormals=se.BufferGeometry.prototype.computeVertexNormals;let At=xr;const Ue=new R.Vector2;class Pr extends Tt{constructor(e,r,n){super(e),this.isFound=!1,this.fontSize=r,this.font=n,this.width=this.getCharWidth(e,r,n)}toGeometry(){let e=this.font.cache.getGeometry(this.char,this.fontSize);return e==null&&(e=At.runWithoutNormals(()=>{const r=new Ya(this.char,{font:this.font.font,depth:0,size:this.fontSize,curveSegments:3,bevelSegments:3,UVGenerator:{generateTopUV:()=>[Ue,Ue,Ue],generateSideWallUV:()=>[Ue,Ue,Ue,Ue]}});return r.hasAttribute("uv")&&r.deleteAttribute("uv"),r.hasAttribute("normal")&&r.deleteAttribute("normal"),Xa(r,1e-6)})),e}getCharWidth(e,r,n){const a=n.data.glyphs[e];return a?(this.isFound=!0,a.ha*r/n.data.resolution):(this.isFound=!1,0)}}/*! https://mths.be/codepointat v0.2.0 by @mathias */String.prototype.codePointAt||function(){var t=function(){try{var r={},n=Object.defineProperty,a=n(r,r,r)&&n}catch{}return a}(),e=function(r){if(this==null)throw TypeError();var n=String(this),a=n.length,s=r?Number(r):0;if(s!=s&&(s=0),!(s<0||s>=a)){var i=n.charCodeAt(s),o;return i>=55296&&i<=56319&&a>s+1&&(o=n.charCodeAt(s+1),o>=56320&&o<=57343)?(i-55296)*1024+o-56320+65536:i}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}();var Pt=0,Br=-3;function Ve(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Za(t,e){this.source=t,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new Ve,this.dtree=new Ve}var Ir=new Ve,Dr=new Ve,Bt=new Uint8Array(30),It=new Uint16Array(30),Gr=new Uint8Array(30),Nr=new Uint16Array(30),ja=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_r=new Ve,pe=new Uint8Array(320);function Hr(t,e,r,n){var a,s;for(a=0;a<r;++a)t[a]=0;for(a=0;a<30-r;++a)t[a+r]=a/r|0;for(s=n,a=0;a<30;++a)e[a]=s,s+=1<<t[a]}function Ka(t,e){var r;for(r=0;r<7;++r)t.table[r]=0;for(t.table[7]=24,t.table[8]=152,t.table[9]=112,r=0;r<24;++r)t.trans[r]=256+r;for(r=0;r<144;++r)t.trans[24+r]=r;for(r=0;r<8;++r)t.trans[168+r]=280+r;for(r=0;r<112;++r)t.trans[176+r]=144+r;for(r=0;r<5;++r)e.table[r]=0;for(e.table[5]=32,r=0;r<32;++r)e.trans[r]=r}var zr=new Uint16Array(16);function Dt(t,e,r,n){var a,s;for(a=0;a<16;++a)t.table[a]=0;for(a=0;a<n;++a)t.table[e[r+a]]++;for(t.table[0]=0,s=0,a=0;a<16;++a)zr[a]=s,s+=t.table[a];for(a=0;a<n;++a)e[r+a]&&(t.trans[zr[e[r+a]]++]=a)}function Qa(t){t.bitcount--||(t.tag=t.source[t.sourceIndex++],t.bitcount=7);var e=t.tag&1;return t.tag>>>=1,e}function de(t,e,r){if(!e)return r;for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var n=t.tag&65535>>>16-e;return t.tag>>>=e,t.bitcount-=e,n+r}function Gt(t,e){for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var r=0,n=0,a=0,s=t.tag;do n=2*n+(s&1),s>>>=1,++a,r+=e.table[a],n-=e.table[a];while(n>=0);return t.tag=s,t.bitcount-=a,e.trans[r+n]}function $a(t,e,r){var n,a,s,i,o,u;for(n=de(t,5,257),a=de(t,5,1),s=de(t,4,4),i=0;i<19;++i)pe[i]=0;for(i=0;i<s;++i){var l=de(t,3,0);pe[ja[i]]=l}for(Dt(_r,pe,0,19),o=0;o<n+a;){var c=Gt(t,_r);switch(c){case 16:var f=pe[o-1];for(u=de(t,2,3);u;--u)pe[o++]=f;break;case 17:for(u=de(t,3,3);u;--u)pe[o++]=0;break;case 18:for(u=de(t,7,11);u;--u)pe[o++]=0;break;default:pe[o++]=c;break}}Dt(e,pe,0,n),Dt(r,pe,n,a)}function Wr(t,e,r){for(;;){var n=Gt(t,e);if(n===256)return Pt;if(n<256)t.dest[t.destLen++]=n;else{var a,s,i,o;for(n-=257,a=de(t,Bt[n],It[n]),s=Gt(t,r),i=t.destLen-de(t,Gr[s],Nr[s]),o=i;o<i+a;++o)t.dest[t.destLen++]=t.dest[o]}}}function Ja(t){for(var e,r,n;t.bitcount>8;)t.sourceIndex--,t.bitcount-=8;if(e=t.source[t.sourceIndex+1],e=256*e+t.source[t.sourceIndex],r=t.source[t.sourceIndex+3],r=256*r+t.source[t.sourceIndex+2],e!==(~r&65535))return Br;for(t.sourceIndex+=4,n=e;n;--n)t.dest[t.destLen++]=t.source[t.sourceIndex++];return t.bitcount=0,Pt}function es(t,e){var r=new Za(t,e),n,a,s;do{switch(n=Qa(r),a=de(r,2,0),a){case 0:s=Ja(r);break;case 1:s=Wr(r,Ir,Dr);break;case 2:$a(r,r.ltree,r.dtree),s=Wr(r,r.ltree,r.dtree);break;default:s=Br}if(s!==Pt)throw new Error("Data error")}while(!n);return r.destLen<r.dest.length?typeof r.dest.slice=="function"?r.dest.slice(0,r.destLen):r.dest.subarray(0,r.destLen):r.dest}Ka(Ir,Dr),Hr(Bt,It,4,3),Hr(Gr,Nr,2,1),Bt[28]=0,It[28]=258;var ts=es;function Ie(t,e,r,n,a){return Math.pow(1-a,3)*t+3*Math.pow(1-a,2)*a*e+3*(1-a)*Math.pow(a,2)*r+Math.pow(a,3)*n}function Se(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}Se.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},Se.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))},Se.prototype.addX=function(t){this.addPoint(t,null)},Se.prototype.addY=function(t){this.addPoint(null,t)},Se.prototype.addBezier=function(t,e,r,n,a,s,i,o){var u=[t,e],l=[r,n],c=[a,s],f=[i,o];this.addPoint(t,e),this.addPoint(i,o);for(var h=0;h<=1;h++){var p=6*u[h]-12*l[h]+6*c[h],d=-3*u[h]+9*l[h]-9*c[h]+3*f[h],m=3*l[h]-3*u[h];if(d===0){if(p===0)continue;var b=-m/p;0<b&&b<1&&(h===0&&this.addX(Ie(u[h],l[h],c[h],f[h],b)),h===1&&this.addY(Ie(u[h],l[h],c[h],f[h],b)));continue}var y=Math.pow(p,2)-4*m*d;if(!(y<0)){var S=(-p+Math.sqrt(y))/(2*d);0<S&&S<1&&(h===0&&this.addX(Ie(u[h],l[h],c[h],f[h],S)),h===1&&this.addY(Ie(u[h],l[h],c[h],f[h],S)));var x=(-p-Math.sqrt(y))/(2*d);0<x&&x<1&&(h===0&&this.addX(Ie(u[h],l[h],c[h],f[h],x)),h===1&&this.addY(Ie(u[h],l[h],c[h],f[h],x)))}}},Se.prototype.addQuad=function(t,e,r,n,a,s){var i=t+.6666666666666666*(r-t),o=e+2/3*(n-e),u=i+1/3*(a-t),l=o+1/3*(s-e);this.addBezier(t,e,i,o,u,l,a,s)};function V(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}V.prototype.moveTo=function(t,e){this.commands.push({type:"M",x:t,y:e})},V.prototype.lineTo=function(t,e){this.commands.push({type:"L",x:t,y:e})},V.prototype.curveTo=V.prototype.bezierCurveTo=function(t,e,r,n,a,s){this.commands.push({type:"C",x1:t,y1:e,x2:r,y2:n,x:a,y:s})},V.prototype.quadTo=V.prototype.quadraticCurveTo=function(t,e,r,n){this.commands.push({type:"Q",x1:t,y1:e,x:r,y:n})},V.prototype.close=V.prototype.closePath=function(){this.commands.push({type:"Z"})},V.prototype.extend=function(t){if(t.commands)t=t.commands;else if(t instanceof Se){var 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)},V.prototype.getBoundingBox=function(){for(var t=new Se,e=0,r=0,n=0,a=0,s=0;s<this.commands.length;s++){var i=this.commands[s];switch(i.type){case"M":t.addPoint(i.x,i.y),e=n=i.x,r=a=i.y;break;case"L":t.addPoint(i.x,i.y),n=i.x,a=i.y;break;case"Q":t.addQuad(n,a,i.x1,i.y1,i.x,i.y),n=i.x,a=i.y;break;case"C":t.addBezier(n,a,i.x1,i.y1,i.x2,i.y2,i.x,i.y),n=i.x,a=i.y;break;case"Z":n=e,a=r;break;default:throw new Error("Unexpected path command "+i.type)}}return t.isEmpty()&&t.addPoint(0,0),t},V.prototype.draw=function(t){t.beginPath();for(var e=0;e<this.commands.length;e+=1){var r=this.commands[e];r.type==="M"?t.moveTo(r.x,r.y):r.type==="L"?t.lineTo(r.x,r.y):r.type==="C"?t.bezierCurveTo(r.x1,r.y1,r.x2,r.y2,r.x,r.y):r.type==="Q"?t.quadraticCurveTo(r.x1,r.y1,r.x,r.y):r.type==="Z"&&t.closePath()}this.fill&&(t.fillStyle=this.fill,t.fill()),this.stroke&&(t.strokeStyle=this.stroke,t.lineWidth=this.strokeWidth,t.stroke())},V.prototype.toPathData=function(t){t=t!==void 0?t:2;function e(i){return Math.round(i)===i?""+Math.round(i):i.toFixed(t)}function r(){for(var i=arguments,o="",u=0;u<arguments.length;u+=1){var l=i[u];l>=0&&u>0&&(o+=" "),o+=e(l)}return o}for(var n="",a=0;a<this.commands.length;a+=1){var s=this.commands[a];s.type==="M"?n+="M"+r(s.x,s.y):s.type==="L"?n+="L"+r(s.x,s.y):s.type==="C"?n+="C"+r(s.x1,s.y1,s.x2,s.y2,s.x,s.y):s.type==="Q"?n+="Q"+r(s.x1,s.y1,s.x,s.y):s.type==="Z"&&(n+="Z")}return n},V.prototype.toSVG=function(t){var e='<path d="';return e+=this.toPathData(t),e+='"',this.fill&&this.fill!=="black"&&(this.fill===null?e+=' fill="none"':e+=' fill="'+this.fill+'"'),this.stroke&&(e+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),e+="/>",e},V.prototype.toDOMElement=function(t){var e=this.toPathData(t),r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d",e),r};function Vr(t){throw new Error(t)}function qr(t,e){t||Vr(e)}var L={fail:Vr,argument:qr,assert:qr},Xr=32768,Yr=2147483648,De={},F={},M={};function oe(t){return function(){return t}}F.BYTE=function(t){return L.argument(t>=0&&t<=255,"Byte value should be between 0 and 255."),[t]},M.BYTE=oe(1),F.CHAR=function(t){return[t.charCodeAt(0)]},M.CHAR=oe(1),F.CHARARRAY=function(t){typeof t>"u"&&(t="",console.warn("Undefined CHARARRAY encountered and treated as an empty string. This is probably caused by a missing glyph name."));for(var e=[],r=0;r<t.length;r+=1)e[r]=t.charCodeAt(r);return e},M.CHARARRAY=function(t){return typeof t>"u"?0:t.length},F.USHORT=function(t){return[t>>8&255,t&255]},M.USHORT=oe(2),F.SHORT=function(t){return t>=Xr&&(t=-(2*Xr-t)),[t>>8&255,t&255]},M.SHORT=oe(2),F.UINT24=function(t){return[t>>16&255,t>>8&255,t&255]},M.UINT24=oe(3),F.ULONG=function(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]},M.ULONG=oe(4),F.LONG=function(t){return t>=Yr&&(t=-(2*Yr-t)),[t>>24&255,t>>16&255,t>>8&255,t&255]},M.LONG=oe(4),F.FIXED=F.ULONG,M.FIXED=M.ULONG,F.FWORD=F.SHORT,M.FWORD=M.SHORT,F.UFWORD=F.USHORT,M.UFWORD=M.USHORT,F.LONGDATETIME=function(t){return[0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255]},M.LONGDATETIME=oe(8),F.TAG=function(t){return L.argument(t.length===4,"Tag should be exactly 4 ASCII characters."),[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]},M.TAG=oe(4),F.Card8=F.BYTE,M.Card8=M.BYTE,F.Card16=F.USHORT,M.Card16=M.USHORT,F.OffSize=F.BYTE,M.OffSize=M.BYTE,F.SID=F.USHORT,M.SID=M.USHORT,F.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?F.NUMBER16(t):F.NUMBER32(t)},M.NUMBER=function(t){return F.NUMBER(t).length},F.NUMBER16=function(t){return[28,t>>8&255,t&255]},M.NUMBER16=oe(3),F.NUMBER32=function(t){return[29,t>>24&255,t>>16&255,t>>8&255,t&255]},M.NUMBER32=oe(5),F.REAL=function(t){var e=t.toString(),r=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(r){var n=parseFloat("1e"+((r[2]?+r[2]:0)+r[1].length));e=(Math.round(t*n)/n).toString()}for(var a="",s=0,i=e.length;s<i;s+=1){var o=e[s];o==="e"?a+=e[++s]==="-"?"c":"b":o==="."?a+="a":o==="-"?a+="e":a+=o}a+=a.length&1?"f":"ff";for(var u=[30],l=0,c=a.length;l<c;l+=2)u.push(parseInt(a.substr(l,2),16));return u},M.REAL=function(t){return F.REAL(t).length},F.NAME=F.CHARARRAY,M.NAME=M.CHARARRAY,F.STRING=F.CHARARRAY,M.STRING=M.CHARARRAY,De.UTF8=function(t,e,r){for(var n=[],a=r,s=0;s<a;s++,e+=1)n[s]=t.getUint8(e);return String.fromCharCode.apply(null,n)},De.UTF16=function(t,e,r){for(var n=[],a=r/2,s=0;s<a;s++,e+=2)n[s]=t.getUint16(e);return String.fromCharCode.apply(null,n)},F.UTF16=function(t){for(var e=[],r=0;r<t.length;r+=1){var n=t.charCodeAt(r);e[e.length]=n>>8&255,e[e.length]=n&255}return e},M.UTF16=function(t){return t.length*2};var Nt={"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":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};De.MACSTRING=function(t,e,r,n){var a=Nt[n];if(a!==void 0){for(var s="",i=0;i<r;i++){var o=t.getUint8(e+i);o<=127?s+=String.fromCharCode(o):s+=a[o&127]}return s}};var st=typeof WeakMap=="function"&&new WeakMap,it,rs=function(t){if(!it){it={};for(var e in Nt)it[e]=new String(e)}var r=it[t];if(r!==void 0){if(st){var n=st.get(r);if(n!==void 0)return n}var a=Nt[t];if(a!==void 0){for(var s={},i=0;i<a.length;i++)s[a.charCodeAt(i)]=i+128;return st&&st.set(r,s),s}}};F.MACSTRING=function(t,e){var r=rs(e);if(r!==void 0){for(var n=[],a=0;a<t.length;a++){var s=t.charCodeAt(a);if(s>=128&&(s=r[s],s===void 0))return;n[a]=s}return n}},M.MACSTRING=function(t,e){var r=F.MACSTRING(t,e);return r!==void 0?r.length:0};function _t(t){return t>=-128&&t<=127}function ns(t,e,r){for(var n=0,a=t.length;e<a&&n<64&&t[e]===0;)++e,++n;return r.push(128|n-1),e}function as(t,e,r){for(var n=0,a=t.length,s=e;s<a&&n<64;){var i=t[s];if(!_t(i)||i===0&&s+1<a&&t[s+1]===0)break;++s,++n}r.push(n-1);for(var o=e;o<s;++o)r.push(t[o]+256&255);return s}function ss(t,e,r){for(var n=0,a=t.length,s=e;s<a&&n<64;){var i=t[s];if(i===0||_t(i)&&s+1<a&&_t(t[s+1]))break;++s,++n}r.push(64|n-1);for(var o=e;o<s;++o){var u=t[o];r.push(u+65536>>8&255,u+256&255)}return s}F.VARDELTAS=function(t){for(var e=0,r=[];e<t.length;){var n=t[e];n===0?e=ns(t,e,r):n>=-128&&n<=127?e=as(t,e,r):e=ss(t,e,r)}return r},F.INDEX=function(t){for(var e=1,r=[e],n=[],a=0;a<t.length;a+=1){var s=F.OBJECT(t[a]);Array.prototype.push.apply(n,s),e+=s.length,r.push(e)}if(n.length===0)return[0,0];for(var i=[],o=1+Math.floor(Math.log(e)/Math.log(2))/8|0,u=[void 0,F.BYTE,F.USHORT,F.UINT24,F.ULONG][o],l=0;l<r.length;l+=1){var c=u(r[l]);Array.prototype.push.apply(i,c)}return Array.prototype.concat(F.Card16(t.length),F.OffSize(o),i,n)},M.INDEX=function(t){return F.INDEX(t).length},F.DICT=function(t){for(var e=[],r=Object.keys(t),n=r.length,a=0;a<n;a+=1){var s=parseInt(r[a],0),i=t[s];e=e.concat(F.OPERAND(i.value,i.type)),e=e.concat(F.OPERATOR(s))}return e},M.DICT=function(t){return F.DICT(t).length},F.OPERATOR=function(t){return t<1200?[t]:[12,t-1200]},F.OPERAND=function(t,e){var r=[];if(Array.isArray(e))for(var n=0;n<e.length;n+=1)L.argument(t.length===e.length,"Not enough arguments given for type"+e),r=r.concat(F.OPERAND(t[n],e[n]));else if(e==="SID")r=r.concat(F.NUMBER(t));else if(e==="offset")r=r.concat(F.NUMBER32(t));else if(e==="number")r=r.concat(F.NUMBER(t));else if(e==="real")r=r.concat(F.REAL(t));else throw new Error("Unknown operand type "+e);return r},F.OP=F.BYTE,M.OP=M.BYTE;var ot=typeof WeakMap=="function"&&new WeakMap;F.CHARSTRING=function(t){if(ot){var e=ot.get(t);if(e!==void 0)return e}for(var r=[],n=t.length,a=0;a<n;a+=1){var s=t[a];r=r.concat(F[s.type](s.value))}return ot&&ot.set(t,r),r},M.CHARSTRING=function(t){return F.CHARSTRING(t).length},F.OBJECT=function(t){var e=F[t.type];return L.argument(e!==void 0,"No encoding function for type "+t.type),e(t.value)},M.OBJECT=function(t){var e=M[t.type];return L.argument(e!==void 0,"No sizeOf function for type "+t.type),e(t.value)},F.TABLE=function(t){for(var e=[],r=t.fields.length,n=[],a=[],s=0;s<r;s+=1){var i=t.fields[s],o=F[i.type];L.argument(o!==void 0,"No encoding function for field type "+i.type+" ("+i.name+")");var u=t[i.name];u===void 0&&(u=i.value);var l=o(u);i.type==="TABLE"?(a.push(e.length),e=e.concat([0,0]),n.push(l)):e=e.concat(l)}for(var c=0;c<n.length;c+=1){var f=a[c],h=e.length;L.argument(h<65536,"Table "+t.tableName+" too big."),e[f]=h>>8,e[f+1]=h&255,e=e.concat(n[c])}return e},M.TABLE=function(t){for(var e=0,r=t.fields.length,n=0;n<r;n+=1){var a=t.fields[n],s=M[a.type];L.argument(s!==void 0,"No sizeOf function for field type "+a.type+" ("+a.name+")");var i=t[a.name];i===void 0&&(i=a.value),e+=s(i),a.type==="TABLE"&&(e+=2)}return e},F.RECORD=F.TABLE,M.RECORD=M.TABLE,F.LITERAL=function(t){return t},M.LITERAL=function(t){return t.length};function X(t,e,r){if(e.length&&(e[0].name!=="coverageFormat"||e[0].value===1))for(var n=0;n<e.length;n+=1){var a=e[n];this[a.name]=a.value}if(this.tableName=t,this.fields=e,r)for(var s=Object.keys(r),i=0;i<s.length;i+=1){var o=s[i],u=r[o];this[o]!==void 0&&(this[o]=u)}}X.prototype.encode=function(){return F.TABLE(this)},X.prototype.sizeOf=function(){return M.TABLE(this)};function qe(t,e,r){r===void 0&&(r=e.length);var n=new Array(e.length+1);n[0]={name:t+"Count",type:"USHORT",value:r};for(var a=0;a<e.length;a++)n[a+1]={name:t+a,type:"USHORT",value:e[a]};return n}function Ht(t,e,r){var n=e.length,a=new Array(n+1);a[0]={name:t+"Count",type:"USHORT",value:n};for(var s=0;s<n;s++)a[s+1]={name:t+s,type:"TABLE",value:r(e[s],s)};return a}function Xe(t,e,r){var n=e.length,a=[];a[0]={name:t+"Count",type:"USHORT",value:n};for(var s=0;s<n;s++)a=a.concat(r(e[s],s));return a}function ut(t){t.format===1?X.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(qe("glyph",t.glyphs))):t.format===2?X.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(Xe("rangeRecord",t.ranges,function(e){return[{name:"startGlyphID",type:"USHORT",value:e.start},{name:"endGlyphID",type:"USHORT",value:e.end},{name:"startCoverageIndex",type:"USHORT",value:e.index}]}))):L.assert(!1,"Coverage format must be 1 or 2.")}ut.prototype=Object.create(X.prototype),ut.prototype.constructor=ut;function lt(t){X.call(this,"scriptListTable",Xe("scriptRecord",t,function(e,r){var n=e.script,a=n.defaultLangSys;return L.assert(!!a,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+r,type:"TAG",value:e.tag},{name:"script"+r,type:"TABLE",value:new X("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new X("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat(qe("featureIndex",a.featureIndexes)))}].concat(Xe("langSys",n.langSysRecords,function(s,i){var o=s.langSys;return[{name:"langSysTag"+i,type:"TAG",value:s.tag},{name:"langSys"+i,type:"TABLE",value:new X("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:o.reqFeatureIndex}].concat(qe("featureIndex",o.featureIndexes)))}]})))}]}))}lt.prototype=Object.create(X.prototype),lt.prototype.constructor=lt;function ct(t){X.call(this,"featureListTable",Xe("featureRecord",t,function(e,r){var n=e.feature;return[{name:"featureTag"+r,type:"TAG",value:e.tag},{name:"feature"+r,type:"TABLE",value:new X("featureTable",[{name:"featureParams",type:"USHORT",value:n.featureParams}].concat(qe("lookupListIndex",n.lookupListIndexes)))}]}))}ct.prototype=Object.create(X.prototype),ct.prototype.constructor=ct;function ht(t,e){X.call(this,"lookupListTable",Ht("lookup",t,function(r){var n=e[r.lookupType];return L.assert(!!n,"Unable to write GSUB lookup type "+r.lookupType+" tables."),new X("lookupTable",[{name:"lookupType",type:"USHORT",value:r.lookupType},{name:"lookupFlag",type:"USHORT",value:r.lookupFlag}].concat(Ht("subtable",r.subtables,n)))}))}ht.prototype=Object.create(X.prototype),ht.prototype.constructor=ht;var T={Table:X,Record:X,Coverage:ut,ScriptList:lt,FeatureList:ct,LookupList:ht,ushortList:qe,tableList:Ht,recordList:Xe};function Zr(t,e){return t.getUint8(e)}function ft(t,e){return t.getUint16(e,!1)}function is(t,e){return t.getInt16(e,!1)}function zt(t,e){return t.getUint32(e,!1)}function jr(t,e){var r=t.getInt16(e,!1),n=t.getUint16(e+2,!1);return r+n/65535}function os(t,e){for(var r="",n=e;n<e+4;n+=1)r+=String.fromCharCode(t.getInt8(n));return r}function us(t,e,r){for(var n=0,a=0;a<r;a+=1)n<<=8,n+=t.getUint8(e+a);return n}function ls(t,e,r){for(var n=[],a=e;a<r;a+=1)n.push(t.getUint8(a));return n}function cs(t){for(var e="",r=0;r<t.length;r+=1)e+=String.fromCharCode(t[r]);return e}var hs={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function g(t,e){this.data=t,this.offset=e,this.relativeOffset=0}g.prototype.parseByte=function(){var t=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,t},g.prototype.parseChar=function(){var t=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,t},g.prototype.parseCard8=g.prototype.parseByte,g.prototype.parseUShort=function(){var t=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,t},g.prototype.parseCard16=g.prototype.parseUShort,g.prototype.parseSID=g.prototype.parseUShort,g.prototype.parseOffset16=g.prototype.parseUShort,g.prototype.parseShort=function(){var t=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,t},g.prototype.parseF2Dot14=function(){var t=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,t},g.prototype.parseULong=function(){var t=zt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t},g.prototype.parseOffset32=g.prototype.parseULong,g.prototype.parseFixed=function(){var t=jr(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t},g.prototype.parseString=function(t){var e=this.data,r=this.offset+this.relativeOffset,n="";this.relativeOffset+=t;for(var a=0;a<t;a++)n+=String.fromCharCode(e.getUint8(r+a));return n},g.prototype.parseTag=function(){return this.parseString(4)},g.prototype.parseLongDateTime=function(){var t=zt(this.data,this.offset+this.relativeOffset+4);return t-=2082844800,this.relativeOffset+=8,t},g.prototype.parseVersion=function(t){var e=ft(this.data,this.offset+this.relativeOffset),r=ft(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,t===void 0&&(t=4096),e+r/t/10},g.prototype.skip=function(t,e){e===void 0&&(e=1),this.relativeOffset+=hs[t]*e},g.prototype.parseULongList=function(t){t===void 0&&(t=this.parseULong());for(var e=new Array(t),r=this.data,n=this.offset+this.relativeOffset,a=0;a<t;a++)e[a]=r.getUint32(n),n+=4;return this.relativeOffset+=t*4,e},g.prototype.parseOffset16List=g.prototype.parseUShortList=function(t){t===void 0&&(t=this.parseUShort());for(var e=new Array(t),r=this.data,n=this.offset+this.relativeOffset,a=0;a<t;a++)e[a]=r.getUint16(n),n+=2;return this.relativeOffset+=t*2,e},g.prototype.parseShortList=function(t){for(var e=new Array(t),r=this.data,n=this.offset+this.relativeOffset,a=0;a<t;a++)e[a]=r.getInt16(n),n+=2;return this.relativeOffset+=t*2,e},g.prototype.parseByteList=function(t){for(var e=new Array(t),r=this.data,n=this.offset+this.relativeOffset,a=0;a<t;a++)e[a]=r.getUint8(n++);return this.relativeOffset+=t,e},g.prototype.parseList=function(t,e){e||(e=t,t=this.parseUShort());for(var r=new Array(t),n=0;n<t;n++)r[n]=e.call(this);return r},g.prototype.parseList32=function(t,e){e||(e=t,t=this.parseULong());for(var r=new Array(t),n=0;n<t;n++)r[n]=e.call(this);return r},g.prototype.parseRecordList=function(t,e){e||(e=t,t=this.parseUShort());for(var r=new Array(t),n=Object.keys(e),a=0;a<t;a++){for(var s={},i=0;i<n.length;i++){var o=n[i],u=e[o];s[o]=u.call(this)}r[a]=s}return r},g.prototype.parseRecordList32=function(t,e){e||(e=t,t=this.parseULong());for(var r=new Array(t),n=Object.keys(e),a=0;a<t;a++){for(var s={},i=0;i<n.length;i++){var o=n[i],u=e[o];s[o]=u.call(this)}r[a]=s}return r},g.prototype.parseStruct=function(t){if(typeof t=="function")return t.call(this);for(var e=Object.keys(t),r={},n=0;n<e.length;n++){var a=e[n],s=t[a];r[a]=s.call(this)}return r},g.prototype.parseValueRecord=function(t){if(t===void 0&&(t=this.parseUShort()),t!==0){var 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}},g.prototype.parseValueRecordList=function(){for(var t=this.parseUShort(),e=this.parseUShort(),r=new Array(e),n=0;n<e;n++)r[n]=this.parseValueRecord(t);return r},g.prototype.parsePointer=function(t){var e=this.parseOffset16();if(e>0)return new g(this.data,this.offset+e).parseStruct(t)},g.prototype.parsePointer32=function(t){var e=this.parseOffset32();if(e>0)return new g(this.data,this.offset+e).parseStruct(t)},g.prototype.parseListOfLists=function(t){for(var e=this.parseOffset16List(),r=e.length,n=this.relativeOffset,a=new Array(r),s=0;s<r;s++){var i=e[s];if(i===0){a[s]=void 0;continue}if(this.relativeOffset=i,t){for(var o=this.parseOffset16List(),u=new Array(o.length),l=0;l<o.length;l++)this.relativeOffset=i+o[l],u[l]=t.call(this);a[s]=u}else a[s]=this.parseUShortList()}return this.relativeOffset=n,a},g.prototype.parseCoverage=function(){var t=this.offset+this.relativeOffset,e=this.parseUShort(),r=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(r)};if(e===2){for(var n=new Array(r),a=0;a<r;a++)n[a]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:n}}throw new Error("0x"+t.toString(16)+": Coverage format must be 1 or 2.")},g.prototype.parseClassDef=function(){var t=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()};if(e===2)return{format:2,ranges:this.parseRecordList({start:g.uShort,end:g.uShort,classId:g.uShort})};throw new Error("0x"+t.toString(16)+": ClassDef format must be 1 or 2.")},g.list=function(t,e){return function(){return this.parseList(t,e)}},g.list32=function(t,e){return function(){return this.parseList32(t,e)}},g.recordList=function(t,e){return function(){return this.parseRecordList(t,e)}},g.recordList32=function(t,e){return function(){return this.parseRecordList32(t,e)}},g.pointer=function(t){return function(){return this.parsePointer(t)}},g.pointer32=function(t){return function(){return this.parsePointer32(t)}},g.tag=g.prototype.parseTag,g.byte=g.prototype.parseByte,g.uShort=g.offset16=g.prototype.parseUShort,g.uShortList=g.prototype.parseUShortList,g.uLong=g.offset32=g.prototype.parseULong,g.uLongList=g.prototype.parseULongList,g.struct=g.prototype.parseStruct,g.coverage=g.prototype.parseCoverage,g.classDef=g.prototype.parseClassDef;var Kr={reserved:g.uShort,reqFeatureIndex:g.uShort,featureIndexes:g.uShortList};g.prototype.parseScriptList=function(){return this.parsePointer(g.recordList({tag:g.tag,script:g.pointer({defaultLangSys:g.pointer(Kr),langSysRecords:g.recordList({tag:g.tag,langSys:g.pointer(Kr)})})}))||[]},g.prototype.parseFeatureList=function(){return this.parsePointer(g.recordList({tag:g.tag,feature:g.pointer({featureParams:g.offset16,lookupListIndexes:g.uShortList})}))||[]},g.prototype.parseLookupList=function(t){return this.parsePointer(g.list(g.pointer(function(){var e=this.parseUShort();L.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");var r=this.parseUShort(),n=r&16;return{lookupType:e,lookupFlag:r,subtables:this.parseList(g.pointer(t[e])),markFilteringSet:n?this.parseUShort():void 0}})))||[]},g.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){var t=this.parseUShort(),e=this.parseUShort();L.argument(t===1&&e<1,"GPOS/GSUB feature variations table unknown.");var r=this.parseRecordList32({conditionSetOffset:g.offset32,featureTableSubstitutionOffset:g.offset32});return r})||[]};var O={getByte:Zr,getCard8:Zr,getUShort:ft,getCard16:ft,getShort:is,getULong:zt,getFixed:jr,getTag:os,getOffset:us,getBytes:ls,bytesToString:cs,Parser:g};function fs(t,e){e.parseUShort(),t.length=e.parseULong(),t.language=e.parseULong();var r;t.groupCount=r=e.parseULong(),t.glyphIndexMap={};for(var n=0;n<r;n+=1)for(var a=e.parseULong(),s=e.parseULong(),i=e.parseULong(),o=a;o<=s;o+=1)t.glyphIndexMap[o]=i,i++}function ps(t,e,r,n,a){t.length=e.parseUShort(),t.language=e.parseUShort();var s;t.segCount=s=e.parseUShort()>>1,e.skip("uShort",3),t.glyphIndexMap={};for(var i=new O.Parser(r,n+a+14),o=new O.Parser(r,n+a+16+s*2),u=new O.Parser(r,n+a+16+s*4),l=new O.Parser(r,n+a+16+s*6),c=n+a+16+s*8,f=0;f<s-1;f+=1)for(var h=void 0,p=i.parseUShort(),d=o.parseUShort(),m=u.parseShort(),b=l.parseUShort(),y=d;y<=p;y+=1)b!==0?(c=l.offset+l.relativeOffset-2,c+=b,c+=(y-d)*2,h=O.getUShort(r,c),h!==0&&(h=h+m&65535)):h=y+m&65535,t.glyphIndexMap[y]=h}function ds(t,e){var r={};r.version=O.getUShort(t,e),L.argument(r.version===0,"cmap table version should be 0."),r.numTables=O.getUShort(t,e+2);for(var n=-1,a=r.numTables-1;a>=0;a-=1){var s=O.getUShort(t,e+4+a*8),i=O.getUShort(t,e+4+a*8+2);if(s===3&&(i===0||i===1||i===10)||s===0&&(i===0||i===1||i===2||i===3||i===4)){n=O.getULong(t,e+4+a*8+4);break}}if(n===-1)throw new Error("No valid cmap sub-tables found.");var o=new O.Parser(t,e+n);if(r.format=o.parseUShort(),r.format===12)fs(r,o);else if(r.format===4)ps(r,o,t,e,n);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+r.format+").");return r}function gs(t,e,r){t.segments.push({end:e,start:e,delta:-(e-r),offset:0,glyphIndex:r})}function vs(t){t.segments.push({end:65535,start:65535,delta:1,offset:0})}function ms(t){var e=!0,r;for(r=t.length-1;r>0;r-=1){var n=t.get(r);if(n.unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}}var a=[{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||(a=a.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),a=a.concat([{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}]);var s=new T.Table("cmap",a);for(s.segments=[],r=0;r<t.length;r+=1){for(var i=t.get(r),o=0;o<i.unicodes.length;o+=1)gs(s,i.unicodes[o],r);s.segments=s.segments.sort(function(S,x){return S.start-x.start})}vs(s);var u=s.segments.length,l=0,c=[],f=[],h=[],p=[],d=[],m=[];for(r=0;r<u;r+=1){var b=s.segments[r];b.end<=65535&&b.start<=65535?(c=c.concat({name:"end_"+r,type:"USHORT",value:b.end}),f=f.concat({name:"start_"+r,type:"USHORT",value:b.start}),h=h.concat({name:"idDelta_"+r,type:"SHORT",value:b.delta}),p=p.concat({name:"idRangeOffset_"+r,type:"USHORT",value:b.offset}),b.glyphId!==void 0&&(d=d.concat({name:"glyph_"+r,type:"USHORT",value:b.glyphId}))):l+=1,!e&&b.glyphIndex!==void 0&&(m=m.concat({name:"cmap12Start_"+r,type:"ULONG",value:b.start}),m=m.concat({name:"cmap12End_"+r,type:"ULONG",value:b.end}),m=m.concat({name:"cmap12Glyph_"+r,type:"ULONG",value:b.glyphIndex}))}if(s.segCountX2=(u-l)*2,s.searchRange=Math.pow(2,Math.floor(Math.log(u-l)/Math.log(2)))*2,s.entrySelector=Math.log(s.searchRange/2)/Math.log(2),s.rangeShift=s.segCountX2-s.searchRange,s.fields=s.fields.concat(c),s.fields.push({name:"reservedPad",type:"USHORT",value:0}),s.fields=s.fields.concat(f),s.fields=s.fields.concat(h),s.fields=s.fields.concat(p),s.fields=s.fields.concat(d),s.cmap4Length=14+c.length*2+2+f.length*2+h.length*2+p.length*2+d.length*2,!e){var y=16+m.length*4;s.cmap12Offset=12+2*2+4+s.cmap4Length,s.fields=s.fields.concat([{name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:y},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:m.length/3}]),s.fields=s.fields.concat(m)}return s}var Qr={parse:ds,make:ms},pt=[".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"],ys=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],bs=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Le=[".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 $r(t){this.font=t}$r.prototype.charToGlyphIndex=function(t){var e=t.codePointAt(0),r=this.font.glyphs;if(r){for(var n=0;n<r.length;n+=1)for(var a=r.get(n),s=0;s<a.unicodes.length;s+=1)if(a.unicodes[s]===e)return n}return null};function Jr(t){this.cmap=t}Jr.prototype.charToGlyphIndex=function(t){return this.cmap.glyphIndexMap[t.codePointAt(0)]||0};function dt(t,e){this.encoding=t,this.charset=e}dt.prototype.charToGlyphIndex=function(t){var e=t.codePointAt(0),r=this.encoding[e];return this.charset.indexOf(r)};function Wt(t){switch(t.version){case 1:this.names=Le.slice();break;case 2:this.names=new Array(t.numberOfGlyphs);for(var e=0;e<t.numberOfGlyphs;e++)t.glyphNameIndex[e]<Le.length?this.names[e]=Le[t.glyphNameIndex[e]]:this.names[e]=t.names[t.glyphNameIndex[e]-Le.length];break;case 2.5:this.names=new Array(t.numberOfGlyphs);for(var r=0;r<t.numberOfGlyphs;r++)this.names[r]=Le[r+t.glyphNameIndex[r]];break;case 3:this.names=[];break;default:this.names=[];break}}Wt.prototype.nameToGlyphIndex=function(t){return this.names.indexOf(t)},Wt.prototype.glyphIndexToName=function(t){return this.names[t]};function xs(t){for(var e,r=t.tables.cmap.glyphIndexMap,n=Object.keys(r),a=0;a<n.length;a+=1){var s=n[a],i=r[s];e=t.glyphs.get(i),e.addUnicode(parseInt(s))}for(var o=0;o<t.glyphs.length;o+=1)e=t.glyphs.get(o),t.cffEncoding?t.isCIDFont?e.name="gid"+o:e.name=t.cffEncoding.charset[o]:t.glyphNames.names&&(e.name=t.glyphNames.glyphIndexToName(o))}function Ss(t){t._IndexToUnicodeMap={};for(var e=t.tables.cmap.glyphIndexMap,r=Object.keys(e),n=0;n<r.length;n+=1){var a=r[n],s=e[a];t._IndexToUnicodeMap[s]===void 0?t._IndexToUnicodeMap[s]={unicodes:[parseInt(a)]}:t._IndexToUnicodeMap[s].unicodes.push(parseInt(a))}}function ks(t,e){e.lowMemory?Ss(t):xs(t)}function Fs(t,e,r,n,a){t.beginPath(),t.moveTo(e,r),t.lineTo(n,a),t.stroke()}var Re={line:Fs};function Ts(t,e){var r=e||new V;return{configurable:!0,get:function(){return typeof r=="function"&&(r=r()),r},set:function(n){r=n}}}function ie(t){this.bindConstructorValues(t)}ie.prototype.bindConstructorValues=function(t){this.index=t.index||0,this.name=t.name||null,this.unicode=t.unicode||void 0,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),Object.defineProperty(this,"path",Ts(this,t.path))},ie.prototype.addUnicode=function(t){this.unicodes.length===0&&(this.unicode=t),this.unicodes.push(t)},ie.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},ie.prototype.getPath=function(t,e,r,n,a){t=t!==void 0?t:0,e=e!==void 0?e:0,r=r!==void 0?r:72;var s,i;n||(n={});var o=n.xScale,u=n.yScale;if(n.hinting&&a&&a.hinting&&(i=this.path&&a.hinting.exec(this,r)),i)s=a.hinting.getCommands(i),t=Math.round(t),e=Math.round(e),o=u=1;else{s=this.path.commands;var l=1/(this.path.unitsPerEm||1e3)*r;o===void 0&&(o=l),u===void 0&&(u=l)}for(var c=new V,f=0;f<s.length;f+=1){var h=s[f];h.type==="M"?c.moveTo(t+h.x*o,e+-h.y*u):h.type==="L"?c.lineTo(t+h.x*o,e+-h.y*u):h.type==="Q"?c.quadraticCurveTo(t+h.x1*o,e+-h.y1*u,t+h.x*o,e+-h.y*u):h.type==="C"?c.curveTo(t+h.x1*o,e+-h.y1*u,t+h.x2*o,e+-h.y2*u,t+h.x*o,e+-h.y*u):h.type==="Z"&&c.closePath()}return c},ie.prototype.getContours=function(){if(this.points===void 0)return[];for(var t=[],e=[],r=0;r<this.points.length;r+=1){var n=this.points[r];e.push(n),n.lastPointOfContour&&(t.push(e),e=[])}return L.argument(e.length===0,"There are still points left in the current contour."),t},ie.prototype.getMetrics=function(){for(var t=this.path.commands,e=[],r=[],n=0;n<t.length;n+=1){var a=t[n];a.type!=="Z"&&(e.push(a.x),r.push(a.y)),(a.type==="Q"||a.type==="C")&&(e.push(a.x1),r.push(a.y1)),a.type==="C"&&(e.push(a.x2),r.push(a.y2))}var s={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,r),xMax:Math.max.apply(null,e),yMax:Math.max.apply(null,r),leftSideBearing:this.leftSideBearing};return isFinite(s.xMin)||(s.xMin=0),isFinite(s.xMax)||(s.xMax=this.advanceWidth),isFinite(s.yMin)||(s.yMin=0),isFinite(s.yMax)||(s.yMax=0),s.rightSideBearing=this.advanceWidth-s.leftSideBearing-(s.xMax-s.xMin),s},ie.prototype.draw=function(t,e,r,n,a){this.getPath(e,r,n,a).draw(t)},ie.prototype.drawPoints=function(t,e,r,n){function a(f,h,p,d){t.beginPath();for(var m=0;m<f.length;m+=1)t.moveTo(h+f[m].x*d,p+f[m].y*d),t.arc(h+f[m].x*d,p+f[m].y*d,2,0,Math.PI*2,!1);t.closePath(),t.fill()}e=e!==void 0?e:0,r=r!==void 0?r:0,n=n!==void 0?n:24;for(var s=1/this.path.unitsPerEm*n,i=[],o=[],u=this.path,l=0;l<u.commands.length;l+=1){var c=u.commands[l];c.x!==void 0&&i.push({x:c.x,y:-c.y}),c.x1!==void 0&&o.push({x:c.x1,y:-c.y1}),c.x2!==void 0&&o.push({x:c.x2,y:-c.y2})}t.fillStyle="blue",a(i,e,r,s),t.fillStyle="red",a(o,e,r,s)},ie.prototype.drawMetrics=function(t,e,r,n){var a;e=e!==void 0?e:0,r=r!==void 0?r:0,n=n!==void 0?n:24,a=1/this.path.unitsPerEm*n,t.lineWidth=1,t.strokeStyle="black",Re.line(t,e,-1e4,e,1e4),Re.line(t,-1e4,r,1e4,r);var s=this.xMin||0,i=this.yMin||0,o=this.xMax||0,u=this.yMax||0,l=this.advanceWidth||0;t.strokeStyle="blue",Re.line(t,e+s*a,-1e4,e+s*a,1e4),Re.line(t,e+o*a,-1e4,e+o*a,1e4),Re.line(t,-1e4,r+-i*a,1e4,r+-i*a),Re.line(t,-1e4,r+-u*a,1e4,r+-u*a),t.strokeStyle="green",Re.line(t,e+l*a,-1e4,e+l*a,1e4)};function gt(t,e,r){Object.defineProperty(t,e,{get:function(){return t.path,t[r]},set:function(n){t[r]=n},enumerable:!0,configurable:!0})}function Vt(t,e){if(this.font=t,this.glyphs={},Array.isArray(e))for(var r=0;r<e.length;r++){var n=e[r];n.path.unitsPerEm=t.unitsPerEm,this.glyphs[r]=n}this.length=e&&e.length||0}Vt.prototype.get=function(t){if(this.glyphs[t]===void 0){this.font._push(t),typeof this.glyphs[t]=="function"&&(this.glyphs[t]=this.glyphs[t]());var e=this.glyphs[t],r=this.font._IndexToUnicodeMap[t];if(r)for(var n=0;n<r.unicodes.length;n++)e.addUnicode(r.unicodes[n]);this.font.cffEncoding?this.font.isCIDFont?e.name="gid"+t: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]},Vt.prototype.push=function(t,e){this.glyphs[t]=e,this.length++};function ws(t,e){return new ie({index:e,font:t})}function Cs(t,e,r,n,a,s){return function(){var i=new ie({index:e,font:t});return i.path=function(){r(i,n,a);var o=s(t.glyphs,i);return o.unitsPerEm=t.unitsPerEm,o},gt(i,"xMin","_xMin"),gt(i,"xMax","_xMax"),gt(i,"yMin","_yMin"),gt(i,"yMax","_yMax"),i}}function Es(t,e,r,n){return function(){var a=new ie({index:e,font:t});return a.path=function(){var s=r(t,a,n);return s.unitsPerEm=t.unitsPerEm,s},a}}var ge={GlyphSet:Vt,glyphLoader:ws,ttfGlyphLoader:Cs,cffGlyphLoader:Es};function en(t,e){if(t===e)return!0;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var r=0;r<t.length;r+=1)if(!en(t[r],e[r]))return!1;return!0}else return!1}function qt(t){var e;return t.length<1240?e=107:t.length<33900?e=1131:e=32768,e}function ke(t,e,r){var n=[],a=[],s=O.getCard16(t,e),i,o;if(s!==0){var u=O.getByte(t,e+2);i=e+(s+1)*u+2;for(var l=e+3,c=0;c<s+1;c+=1)n.push(O.getOffset(t,l,u)),l+=u;o=i+n[s]}else o=e+2;for(var f=0;f<n.length-1;f+=1){var h=O.getBytes(t,i+n[f],i+n[f+1]);r&&(h=r(h)),a.push(h)}return{objects:a,startOffset:e,endOffset:o}}function Os(t,e){var r=[],n=O.getCard16(t,e),a,s;if(n!==0){var i=O.getByte(t,e+2);a=e+(n+1)*i+2;for(var o=e+3,u=0;u<n+1;u+=1)r.push(O.getOffset(t,o,i)),o+=i;s=a+r[n]}else s=e+2;return{offsets:r,startOffset:e,endOffset:s}}function Us(t,e,r,n,a){var s=O.getCard16(r,n),i=0;if(s!==0){var o=O.getByte(r,n+2);i=n+(s+1)*o+2}var u=O.getBytes(r,i+e[t],i+e[t+1]);return u}function Ls(t){for(var e="",r=15,n=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];;){var a=t.parseByte(),s=a>>4,i=a&15;if(s===r||(e+=n[s],i===r))break;e+=n[i]}return parseFloat(e)}function Rs(t,e){var r,n,a,s;if(e===28)return r=t.parseByte(),n=t.parseByte(),r<<8|n;if(e===29)return r=t.parseByte(),n=t.parseByte(),a=t.parseByte(),s=t.parseByte(),r<<24|n<<16|a<<8|s;if(e===30)return Ls(t);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return r=t.parseByte(),(e-247)*256+r+108;if(e>=251&&e<=254)return r=t.parseByte(),-(e-251)*256-r-108;throw new Error("Invalid b0 "+e)}function Ms(t){for(var e={},r=0;r<t.length;r+=1){var n=t[r][0],a=t[r][1],s=void 0;if(a.length===1?s=a[0]:s=a,e.hasOwnProperty(n)&&!isNaN(e[n]))throw new Error("Object "+e+" already has key "+n);e[n]=s}return e}function tn(t,e,r){e=e!==void 0?e:0;var n=new O.Parser(t,e),a=[],s=[];for(r=r!==void 0?r:t.length;n.relativeOffset<r;){var i=n.parseByte();i<=21?(i===12&&(i=1200+n.parseByte()),a.push([i,s]),s=[]):s.push(Rs(n,i))}return Ms(a)}function Ye(t,e){return e<=390?e=pt[e]:e=t[e-391],e}function rn(t,e,r){for(var n={},a,s=0;s<e.length;s+=1){var i=e[s];if(Array.isArray(i.type)){var o=[];o.length=i.type.length;for(var u=0;u<i.type.length;u++)a=t[i.op]!==void 0?t[i.op][u]:void 0,a===void 0&&(a=i.value!==void 0&&i.value[u]!==void 0?i.value[u]:null),i.type[u]==="SID"&&(a=Ye(r,a)),o[u]=a;n[i.name]=o}else a=t[i.op],a===void 0&&(a=i.value!==void 0?i.value:null),i.type==="SID"&&(a=Ye(r,a)),n[i.name]=a}return n}function As(t,e){var r={};return r.formatMajor=O.getCard8(t,e),r.formatMinor=O.getCard8(t,e+1),r.size=O.getCard8(t,e+2),r.offsetSize=O.getCard8(t,e+3),r.startOffset=e,r.endOffset=e+4,r}var nn=[{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"}],an=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}];function Ps(t,e){var r=tn(t,0,t.byteLength);return rn(r,nn,e)}function sn(t,e,r,n){var a=tn(t,e,r);return rn(a,an,n)}function on(t,e,r,n){for(var a=[],s=0;s<r.length;s+=1){var i=new DataView(new Uint8Array(r[s]).buffer),o=Ps(i,n);o._subrs=[],o._subrsBias=0,o._defaultWidthX=0,o._nominalWidthX=0;var u=o.private[0],l=o.private[1];if(u!==0&&l!==0){var c=sn(t,l+e,u,n);if(o._defaultWidthX=c.defaultWidthX,o._nominalWidthX=c.nominalWidthX,c.subrs!==0){var f=l+c.subrs,h=ke(t,f+e);o._subrs=h.objects,o._subrsBias=qt(o._subrs)}o._privateDict=c}a.push(o)}return a}function Bs(t,e,r,n){var a,s,i=new O.Parser(t,e);r-=1;var o=[".notdef"],u=i.parseCard8();if(u===0)for(var l=0;l<r;l+=1)a=i.parseSID(),o.push(Ye(n,a));else if(u===1)for(;o.length<=r;){a=i.parseSID(),s=i.parseCard8();for(var c=0;c<=s;c+=1)o.push(Ye(n,a)),a+=1}else if(u===2)for(;o.length<=r;){a=i.parseSID(),s=i.parseCard16();for(var f=0;f<=s;f+=1)o.push(Ye(n,a)),a+=1}else throw new Error("Unknown charset format "+u);return o}function Is(t,e,r){var n,a={},s=new O.Parser(t,e),i=s.parseCard8();if(i===0)for(var o=s.parseCard8(),u=0;u<o;u+=1)n=s.parseCard8(),a[n]=u;else if(i===1){var l=s.parseCard8();n=1;for(var c=0;c<l;c+=1)for(var f=s.parseCard8(),h=s.parseCard8(),p=f;p<=f+h;p+=1)a[p]=n,n+=1}else throw new Error("Unknown encoding format "+i);return new dt(a,r)}function un(t,e,r){var n,a,s,i,o=new V,u=[],l=0,c=!1,f=!1,h=0,p=0,d,m,b,y;if(t.isCIDFont){var S=t.tables.cff.topDict._fdSelect[e.index],x=t.tables.cff.topDict._fdArray[S];d=x._subrs,m=x._subrsBias,b=x._defaultWidthX,y=x._nominalWidthX}else d=t.tables.cff.topDict._subrs,m=t.tables.cff.topDict._subrsBias,b=t.tables.cff.topDict._defaultWidthX,y=t.tables.cff.topDict._nominalWidthX;var C=b;function k(E,B){f&&o.closePath(),o.moveTo(E,B),f=!0}function A(){var E;E=u.length%2!==0,E&&!c&&(C=u.shift()+y),l+=u.length>>1,u.length=0,c=!0}function U(E){for(var B,z,Q,J,Z,D,W,N,q,j,Y,$,I=0;I<E.length;){var K=E[I];switch(I+=1,K){case 1:A();break;case 3:A();break;case 4:u.length>1&&!c&&(C=u.shift()+y,c=!0),p+=u.pop(),k(h,p);break;case 5:for(;u.length>0;)h+=u.shift(),p+=u.shift(),o.lineTo(h,p);break;case 6:for(;u.length>0&&(h+=u.shift(),o.lineTo(h,p),u.length!==0);)p+=u.shift(),o.lineTo(h,p);break;case 7:for(;u.length>0&&(p+=u.shift(),o.lineTo(h,p),u.length!==0);)h+=u.shift(),o.lineTo(h,p);break;case 8:for(;u.length>0;)n=h+u.shift(),a=p+u.shift(),s=n+u.shift(),i=a+u.shift(),h=s+u.shift(),p=i+u.shift(),o.curveTo(n,a,s,i,h,p);break;case 10:Z=u.pop()+m,D=d[Z],D&&U(D);break;case 11:return;case 12:switch(K=E[I],I+=1,K){case 35:n=h+u.shift(),a=p+u.shift(),s=n+u.shift(),i=a+u.shift(),W=s+u.shift(),N=i+u.shift(),q=W+u.shift(),j=N+u.shift(),Y=q+u.shift(),$=j+u.shift(),h=Y+u.shift(),p=$+u.shift(),u.shift(),o.curveTo(n,a,s,i,W,N),o.curveTo(q,j,Y,$,h,p);break;case 34:n=h+u.shift(),a=p,s=n+u.shift(),i=a+u.shift(),W=s+u.shift(),N=i,q=W+u.shift(),j=i,Y=q+u.shift(),$=p,h=Y+u.shift(),o.curveTo(n,a,s,i,W,N),o.curveTo(q,j,Y,$,h,p);break;case 36:n=h+u.shift(),a=p+u.shift(),s=n+u.shift(),i=a+u.shift(),W=s+u.shift(),N=i,q=W+u.shift(),j=i,Y=q+u.shift(),$=j+u.shift(),h=Y+u.shift(),o.curveTo(n,a,s,i,W,N),o.curveTo(q,j,Y,$,h,p);break;case 37:n=h+u.shift(),a=p+u.shift(),s=n+u.shift(),i=a+u.shift(),W=s+u.shift(),N=i+u.shift(),q=W+u.shift(),j=N+u.shift(),Y=q+u.shift(),$=j+u.shift(),Math.abs(Y-h)>Math.abs($-p)?h=Y+u.shift():p=$+u.shift(),o.curveTo(n,a,s,i,W,N),o.curveTo(q,j,Y,$,h,p);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+K),u.length=0}break;case 14:u.length>0&&!c&&(C=u.shift()+y,c=!0),f&&(o.closePath(),f=!1);break;case 18:A();break;case 19:case 20:A(),I+=l+7>>3;break;case 21:u.length>2&&!c&&(C=u.shift()+y,c=!0),p+=u.pop(),h+=u.pop(),k(h,p);break;case 22:u.length>1&&!c&&(C=u.shift()+y,c=!0),h+=u.pop(),k(h,p);break;case 23:A();break;case 24:for(;u.length>2;)n=h+u.shift(),a=p+u.shift(),s=n+u.shift(),i=a+u.shift(),h=s+u.shift(),p=i+u.shift(),o.curveTo(n,a,s,i,h,p);h+=u.shift(),p+=u.shift(),o.lineTo(h,p);break;case 25:for(;u.length>6;)h+=u.shift(),p+=u.shift(),o.lineTo(h,p);n=h+u.shift(),a=p+u.shift(),s=n+u.shift(),i=a+u.shift(),h=s+u.shift(),p=i+u.shift(),o.curveTo(n,a,s,i,h,p);break;case 26:for(u.length%2&&(h+=u.shift());u.length>0;)n=h,a=p+u.shift(),s=n+u.shift(),i=a+u.shift(),h=s,p=i+u.shift(),o.curveTo(n,a,s,i,h,p);break;case 27:for(u.length%2&&(p+=u.shift());u.length>0;)n=h+u.shift(),a=p,s=n+u.shift(),i=a+u.shift(),h=s+u.shift(),p=i,o.curveTo(n,a,s,i,h,p);break;case 28:B=E[I],z=E[I+1],u.push((B<<24|z<<16)>>16),I+=2;break;case 29:Z=u.pop()+t.gsubrsBias,D=t.gsubrs[Z],D&&U(D);break;case 30:for(;u.length>0&&(n=h,a=p+u.shift(),s=n+u.shift(),i=a+u.shift(),h=s+u.shift(),p=i+(u.length===1?u.shift():0),o.curveTo(n,a,s,i,h,p),u.length!==0);)n=h+u.shift(),a=p,s=n+u.shift(),i=a+u.shift(),p=i+u.shift(),h=s+(u.length===1?u.shift():0),o.curveTo(n,a,s,i,h,p);break;case 31:for(;u.length>0&&(n=h+u.shift(),a=p,s=n+u.shift(),i=a+u.shift(),p=i+u.shift(),h=s+(u.length===1?u.shift():0),o.curveTo(n,a,s,i,h,p),u.length!==0);)n=h,a=p+u.shift(),s=n+u.shift(),i=a+u.shift(),h=s+u.shift(),p=i+(u.length===1?u.shift():0),o.curveTo(n,a,s,i,h,p);break;default:K<32?console.log("Glyph "+e.index+": unknown operator "+K):K<247?u.push(K-139):K<251?(B=E[I],I+=1,u.push((K-247)*256+B+108)):K<255?(B=E[I],I+=1,u.push(-(K-251)*256-B-108)):(B=E[I],z=E[I+1],Q=E[I+2],J=E[I+3],I+=4,u.push((B<<24|z<<16|Q<<8|J)/65536))}}}return U(r),e.advanceWidth=C,o}function Ds(t,e,r,n){var a=[],s,i=new O.Parser(t,e),o=i.parseCard8();if(o===0)for(var u=0;u<r;u++){if(s=i.parseCard8(),s>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+s+" (FD count "+n+")");a.push(s)}else if(o===3){var l=i.parseCard16(),c=i.parseCard16();if(c!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+c);for(var f,h=0;h<l;h++){if(s=i.parseCard8(),f=i.parseCard16(),s>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+s+" (FD count "+n+")");if(f>r)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+f);for(;c<f;c++)a.push(s);c=f}if(f!==r)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+f)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+o);return a}function Gs(t,e,r,n){r.tables.cff={};var a=As(t,e),s=ke(t,a.endOffset,O.bytesToString),i=ke(t,s.endOffset),o=ke(t,i.endOffset,O.bytesToString),u=ke(t,o.endOffset);r.gsubrs=u.objects,r.gsubrsBias=qt(r.gsubrs);var l=on(t,e,i.objects,o.objects);if(l.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+l.length);var c=l[0];if(r.tables.cff.topDict=c,c._privateDict&&(r.defaultWidthX=c._privateDict.defaultWidthX,r.nominalWidthX=c._privateDict.nominalWidthX),c.ros[0]!==void 0&&c.ros[1]!==void 0&&(r.isCIDFont=!0),r.isCIDFont){var f=c.fdArray,h=c.fdSelect;if(f===0||h===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");f+=e;var p=ke(t,f),d=on(t,e,p.objects,o.objects);c._fdArray=d,h+=e,c._fdSelect=Ds(t,h,r.numGlyphs,d.length)}var m=e+c.private[1],b=sn(t,m,c.private[0],o.objects);if(r.defaultWidthX=b.defaultWidthX,r.nominalWidthX=b.nominalWidthX,b.subrs!==0){var y=m+b.subrs,S=ke(t,y);r.subrs=S.objects,r.subrsBias=qt(r.subrs)}else r.subrs=[],r.subrsBias=0;var x;n.lowMemory?(x=Os(t,e+c.charStrings),r.nGlyphs=x.offsets.length):(x=ke(t,e+c.charStrings),r.nGlyphs=x.objects.length);var C=Bs(t,e+c.charset,r.nGlyphs,o.objects);if(c.encoding===0?r.cffEncoding=new dt(ys,C):c.encoding===1?r.cffEncoding=new dt(bs,C):r.cffEncoding=Is(t,e+c.encoding,C),r.encoding=r.encoding||r.cffEncoding,r.glyphs=new ge.GlyphSet(r),n.lowMemory)r._push=function(U){var E=Us(U,x.offsets,t,e+c.charStrings);r.glyphs.push(U,ge.cffGlyphLoader(r,U,un,E))};else for(var k=0;k<r.nGlyphs;k+=1){var A=x.objects[k];r.glyphs.push(k,ge.cffGlyphLoader(r,k,un,A))}}function ln(t,e){var r,n=pt.indexOf(t);return n>=0&&(r=n),n=e.indexOf(t),n>=0?r=n+pt.length:(r=pt.length+e.length,e.push(t)),r}function Ns(){return new T.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 _s(t){var e=new T.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(var r=0;r<t.length;r+=1)e.names.push({name:"name_"+r,type:"NAME",value:t[r]});return e}function cn(t,e,r){for(var n={},a=0;a<t.length;a+=1){var s=t[a],i=e[s.name];i!==void 0&&!en(i,s.value)&&(s.type==="SID"&&(i=ln(i,r)),n[s.op]={name:s.name,type:s.type,value:i})}return n}function hn(t,e){var r=new T.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return r.dict=cn(nn,t,e),r}function fn(t){var e=new T.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:t}],e}function Hs(t){var e=new T.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(var r=0;r<t.length;r+=1)e.strings.push({name:"string_"+r,type:"STRING",value:t[r]});return e}function zs(){return new T.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Ws(t,e){for(var r=new T.Record("Charsets",[{name:"format",type:"Card8",value:0}]),n=0;n<t.length;n+=1){var a=t[n],s=ln(a,e);r.fields.push({name:"glyph_"+n,type:"SID",value:s})}return r}function Vs(t){var e=[],r=t.path;e.push({name:"width",type:"NUMBER",value:t.advanceWidth});for(var n=0,a=0,s=0;s<r.commands.length;s+=1){var i=void 0,o=void 0,u=r.commands[s];if(u.type==="Q"){var l=.3333333333333333,c=2/3;u={type:"C",x:u.x,y:u.y,x1:Math.round(l*n+c*u.x1),y1:Math.round(l*a+c*u.y1),x2:Math.round(l*u.x+c*u.x1),y2:Math.round(l*u.y+c*u.y1)}}if(u.type==="M")i=Math.round(u.x-n),o=Math.round(u.y-a),e.push({name:"dx",type:"NUMBER",value:i}),e.push({name:"dy",type:"NUMBER",value:o}),e.push({name:"rmoveto",type:"OP",value:21}),n=Math.round(u.x),a=Math.round(u.y);else if(u.type==="L")i=Math.round(u.x-n),o=Math.round(u.y-a),e.push({name:"dx",type:"NUMBER",value:i}),e.push({name:"dy",type:"NUMBER",value:o}),e.push({name:"rlineto",type:"OP",value:5}),n=Math.round(u.x),a=Math.round(u.y);else if(u.type==="C"){var f=Math.round(u.x1-n),h=Math.round(u.y1-a),p=Math.round(u.x2-u.x1),d=Math.round(u.y2-u.y1);i=Math.round(u.x-u.x2),o=Math.round(u.y-u.y2),e.push({name:"dx1",type:"NUMBER",value:f}),e.push({name:"dy1",type:"NUMBER",value:h}),e.push({name:"dx2",type:"NUMBER",value:p}),e.push({name:"dy2",type:"NUMBER",value:d}),e.push({name:"dx",type:"NUMBER",value:i}),e.push({name:"dy",type:"NUMBER",value:o}),e.push({name:"rrcurveto",type:"OP",value:8}),n=Math.round(u.x),a=Math.round(u.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function qs(t){for(var e=new T.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),r=0;r<t.length;r+=1){var n=t.get(r),a=Vs(n);e.charStrings.push({name:n.name,type:"CHARSTRING",value:a})}return e}function Xs(t,e){var r=new T.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return r.dict=cn(an,t,e),r}function Ys(t,e){for(var r=new T.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"}]),n=1/e.unitsPerEm,a={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[n,0,0,n,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},s={},i=[],o,u=1;u<t.length;u+=1)o=t.get(u),i.push(o.name);var l=[];r.header=Ns(),r.nameIndex=_s([e.postScriptName]);var c=hn(a,l);r.topDictIndex=fn(c),r.globalSubrIndex=zs(),r.charsets=Ws(i,l),r.charStringsIndex=qs(t),r.privateDict=Xs(s,l),r.stringIndex=Hs(l);var f=r.header.sizeOf()+r.nameIndex.sizeOf()+r.topDictIndex.sizeOf()+r.stringIndex.sizeOf()+r.globalSubrIndex.sizeOf();return a.charset=f,a.encoding=0,a.charStrings=a.charset+r.charsets.sizeOf(),a.private[1]=a.charStrings+r.charStringsIndex.sizeOf(),c=hn(a,l),r.topDictIndex=fn(c),r}var pn={parse:Gs,make:Ys};function Zs(t,e){var r={},n=new O.Parser(t,e);return r.version=n.parseVersion(),r.fontRevision=Math.round(n.parseFixed()*1e3)/1e3,r.checkSumAdjustment=n.parseULong(),r.magicNumber=n.parseULong(),L.argument(r.magicNumber===1594834165,"Font header has wrong magic number."),r.flags=n.parseUShort(),r.unitsPerEm=n.parseUShort(),r.created=n.parseLongDateTime(),r.modified=n.parseLongDateTime(),r.xMin=n.parseShort(),r.yMin=n.parseShort(),r.xMax=n.parseShort(),r.yMax=n.parseShort(),r.macStyle=n.parseUShort(),r.lowestRecPPEM=n.parseUShort(),r.fontDirectionHint=n.parseShort(),r.indexToLocFormat=n.parseShort(),r.glyphDataFormat=n.parseShort(),r}function js(t){var e=Math.round(new Date().getTime()/1e3)+2082844800,r=e;return t.createdTimestamp&&(r=t.createdTimestamp+2082844800),new T.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:r},{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:0},{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 dn={parse:Zs,make:js};function Ks(t,e){var r={},n=new O.Parser(t,e);return r.version=n.parseVersion(),r.ascender=n.parseShort(),r.descender=n.parseShort(),r.lineGap=n.parseShort(),r.advanceWidthMax=n.parseUShort(),r.minLeftSideBearing=n.parseShort(),r.minRightSideBearing=n.parseShort(),r.xMaxExtent=n.parseShort(),r.caretSlopeRise=n.parseShort(),r.caretSlopeRun=n.parseShort(),r.caretOffset=n.parseShort(),n.relativeOffset+=8,r.metricDataFormat=n.parseShort(),r.numberOfHMetrics=n.parseUShort(),r}function Qs(t){return new T.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 gn={parse:Ks,make:Qs};function $s(t,e,r,n,a){for(var s,i,o=new O.Parser(t,e),u=0;u<n;u+=1){u<r&&(s=o.parseUShort(),i=o.parseShort());var l=a.get(u);l.advanceWidth=s,l.leftSideBearing=i}}function Js(t,e,r,n,a){t._hmtxTableData={};for(var s,i,o=new O.Parser(e,r),u=0;u<a;u+=1)u<n&&(s=o.parseUShort(),i=o.parseShort()),t._hmtxTableData[u]={advanceWidth:s,leftSideBearing:i}}function ei(t,e,r,n,a,s,i){i.lowMemory?Js(t,e,r,n,a):$s(e,r,n,a,s)}function ti(t){for(var e=new T.Table("hmtx",[]),r=0;r<t.length;r+=1){var n=t.get(r),a=n.advanceWidth||0,s=n.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+r,type:"USHORT",value:a}),e.fields.push({name:"leftSideBearing_"+r,type:"SHORT",value:s})}return e}var vn={parse:ei,make:ti};function ri(t){for(var e=new T.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:t.length}]),r="",n=12+t.length*4,a=0;a<t.length;++a){var s=r.indexOf(t[a]);s<0&&(s=r.length,r+=t[a]),e.fields.push({name:"offset "+a,type:"USHORT",value:n+s}),e.fields.push({name:"length "+a,type:"USHORT",value:t[a].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:r}),e}function ni(t,e){var r=new O.Parser(t,e),n=r.parseULong();L.argument(n===1,"Unsupported ltag table version."),r.skip("uLong",1);for(var a=r.parseULong(),s=[],i=0;i<a;i++){for(var o="",u=e+r.parseUShort(),l=r.parseUShort(),c=u;c<u+l;++c)o+=String.fromCharCode(t.getInt8(c));s.push(o)}return s}var mn={make:ri,parse:ni};function ai(t,e){var r={},n=new O.Parser(t,e);return r.version=n.parseVersion(),r.numGlyphs=n.parseUShort(),r.version===1&&(r.maxPoints=n.parseUShort(),r.maxContours=n.parseUShort(),r.maxCompositePoints=n.parseUShort(),r.maxCompositeContours=n.parseUShort(),r.maxZones=n.parseUShort(),r.maxTwilightPoints=n.parseUShort(),r.maxStorage=n.parseUShort(),r.maxFunctionDefs=n.parseUShort(),r.maxInstructionDefs=n.parseUShort(),r.maxStackElements=n.parseUShort(),r.maxSizeOfInstructions=n.parseUShort(),r.maxComponentElements=n.parseUShort(),r.maxComponentDepth=n.parseUShort()),r}function si(t){return new T.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:t}])}var yn={parse:ai,make:si},bn=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],xn={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"},ii={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},Sn={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 oi(t,e,r){switch(t){case 0:if(e===65535)return"und";if(r)return r[e];break;case 1:return xn[e];case 3:return Sn[e]}}var Xt="utf-16",ui={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"},li={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 kn(t,e,r){switch(t){case 0:return Xt;case 1:return li[r]||ui[e];case 3:if(e===1||e===10)return Xt;break}}function ci(t,e,r){for(var n={},a=new O.Parser(t,e),s=a.parseUShort(),i=a.parseUShort(),o=a.offset+a.parseUShort(),u=0;u<i;u++){var l=a.parseUShort(),c=a.parseUShort(),f=a.parseUShort(),h=a.parseUShort(),p=bn[h]||h,d=a.parseUShort(),m=a.parseUShort(),b=oi(l,f,r),y=kn(l,c,f);if(y!==void 0&&b!==void 0){var S=void 0;if(y===Xt?S=De.UTF16(t,o+m,d):S=De.MACSTRING(t,o+m,d,y),S){var x=n[p];x===void 0&&(x=n[p]={}),x[b]=S}}}return s===1&&a.parseUShort(),n}function Yt(t){var e={};for(var r in t)e[t[r]]=parseInt(r);return e}function Fn(t,e,r,n,a,s){return new T.Record("NameRecord",[{name:"platformID",type:"USHORT",value:t},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:r},{name:"nameID",type:"USHORT",value:n},{name:"length",type:"USHORT",value:a},{name:"offset",type:"USHORT",value:s}])}function hi(t,e){var r=t.length,n=e.length-r+1;e:for(var a=0;a<n;a++)for(;a<n;a++){for(var s=0;s<r;s++)if(e[a+s]!==t[s])continue e;return a}return-1}function Tn(t,e){var r=hi(t,e);if(r<0){r=e.length;for(var n=0,a=t.length;n<a;++n)e.push(t[n])}return r}function fi(t,e){var r,n=[],a={},s=Yt(bn);for(var i in t){var o=s[i];if(o===void 0&&(o=i),r=parseInt(o),isNaN(r))throw new Error('Name table entry "'+i+'" does not exist, see nameTableNames for complete list.');a[r]=t[i],n.push(r)}for(var u=Yt(xn),l=Yt(Sn),c=[],f=[],h=0;h<n.length;h++){r=n[h];var p=a[r];for(var d in p){var m=p[d],b=1,y=u[d],S=ii[y],x=kn(b,S,y),C=F.MACSTRING(m,x);C===void 0&&(b=0,y=e.indexOf(d),y<0&&(y=e.length,e.push(d)),S=4,C=F.UTF16(m));var k=Tn(C,f);c.push(Fn(b,S,y,r,C.length,k));var A=l[d];if(A!==void 0){var U=F.UTF16(m),E=Tn(U,f);c.push(Fn(3,1,A,r,U.length,E))}}}c.sort(function(Q,J){return Q.platformID-J.platformID||Q.encodingID-J.encodingID||Q.languageID-J.languageID||Q.nameID-J.nameID});for(var B=new T.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:c.length},{name:"stringOffset",type:"USHORT",value:6+c.length*12}]),z=0;z<c.length;z++)B.fields.push({name:"record_"+z,type:"RECORD",value:c[z]});return B.fields.push({name:"strings",type:"LITERAL",value:f}),B}var wn={parse:ci,make:fi},Zt=[{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 pi(t){for(var e=0;e<Zt.length;e+=1){var r=Zt[e];if(t>=r.begin&&t<r.end)return e}return-1}function di(t,e){var r={},n=new O.Parser(t,e);r.version=n.parseUShort(),r.xAvgCharWidth=n.parseShort(),r.usWeightClass=n.parseUShort(),r.usWidthClass=n.parseUShort(),r.fsType=n.parseUShort(),r.ySubscriptXSize=n.parseShort(),r.ySubscriptYSize=n.parseShort(),r.ySubscriptXOffset=n.parseShort(),r.ySubscriptYOffset=n.parseShort(),r.ySuperscriptXSize=n.parseShort(),r.ySuperscriptYSize=n.parseShort(),r.ySuperscriptXOffset=n.parseShort(),r.ySuperscriptYOffset=n.parseShort(),r.yStrikeoutSize=n.parseShort(),r.yStrikeoutPosition=n.parseShort(),r.sFamilyClass=n.parseShort(),r.panose=[];for(var a=0;a<10;a++)r.panose[a]=n.parseByte();return r.ulUnicodeRange1=n.parseULong(),r.ulUnicodeRange2=n.parseULong(),r.ulUnicodeRange3=n.parseULong(),r.ulUnicodeRange4=n.parseULong(),r.achVendID=String.fromCharCode(n.parseByte(),n.parseByte(),n.parseByte(),n.parseByte()),r.fsSelection=n.parseUShort(),r.usFirstCharIndex=n.parseUShort(),r.usLastCharIndex=n.parseUShort(),r.sTypoAscender=n.parseShort(),r.sTypoDescender=n.parseShort(),r.sTypoLineGap=n.parseShort(),r.usWinAscent=n.parseUShort(),r.usWinDescent=n.parseUShort(),r.version>=1&&(r.ulCodePageRange1=n.parseULong(),r.ulCodePageRange2=n.parseULong()),r.version>=2&&(r.sxHeight=n.parseShort(),r.sCapHeight=n.parseShort(),r.usDefaultChar=n.parseUShort(),r.usBreakChar=n.parseUShort(),r.usMaxContent=n.parseUShort()),r}function gi(t){return new T.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 jt={parse:di,make:gi,unicodeRanges:Zt,getUnicodeRange:pi};function vi(t,e){var r={},n=new O.Parser(t,e);switch(r.version=n.parseVersion(),r.italicAngle=n.parseFixed(),r.underlinePosition=n.parseShort(),r.underlineThickness=n.parseShort(),r.isFixedPitch=n.parseULong(),r.minMemType42=n.parseULong(),r.maxMemType42=n.parseULong(),r.minMemType1=n.parseULong(),r.maxMemType1=n.parseULong(),r.version){case 1:r.names=Le.slice();break;case 2:r.numberOfGlyphs=n.parseUShort(),r.glyphNameIndex=new Array(r.numberOfGlyphs);for(var a=0;a<r.numberOfGlyphs;a++)r.glyphNameIndex[a]=n.parseUShort();r.names=[];for(var s=0;s<r.numberOfGlyphs;s++)if(r.glyphNameIndex[s]>=Le.length){var i=n.parseChar();r.names.push(n.parseString(i))}break;case 2.5:r.numberOfGlyphs=n.parseUShort(),r.offset=new Array(r.numberOfGlyphs);for(var o=0;o<r.numberOfGlyphs;o++)r.offset[o]=n.parseChar();break}return r}function mi(){return new T.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:0},{name:"underlinePosition",type:"FWORD",value:0},{name:"underlineThickness",type:"FWORD",value:0},{name:"isFixedPitch",type:"ULONG",value:0},{name:"minMemType42",type:"ULONG",value:0},{name:"maxMemType42",type:"ULONG",value:0},{name:"minMemType1",type:"ULONG",value:0},{name:"maxMemType1",type:"ULONG",value:0}])}var Cn={parse:vi,make:mi},ue=new Array(9);ue[1]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();if(r===1)return{substFormat:1,coverage:this.parsePointer(g.coverage),deltaGlyphId:this.parseUShort()};if(r===2)return{substFormat:2,coverage:this.parsePointer(g.coverage),substitute:this.parseOffset16List()};L.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")},ue[2]=function(){var e=this.parseUShort();return L.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(g.coverage),sequences:this.parseListOfLists()}},ue[3]=function(){var e=this.parseUShort();return L.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(g.coverage),alternateSets:this.parseListOfLists()}},ue[4]=function(){var e=this.parseUShort();return L.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(g.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Ge={sequenceIndex:g.uShort,lookupListIndex:g.uShort};ue[5]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();if(r===1)return{substFormat:r,coverage:this.parsePointer(g.coverage),ruleSets:this.parseListOfLists(function(){var s=this.parseUShort(),i=this.parseUShort();return{input:this.parseUShortList(s-1),lookupRecords:this.parseRecordList(i,Ge)}})};if(r===2)return{substFormat:r,coverage:this.parsePointer(g.coverage),classDef:this.parsePointer(g.classDef),classSets:this.parseListOfLists(function(){var s=this.parseUShort(),i=this.parseUShort();return{classes:this.parseUShortList(s-1),lookupRecords:this.parseRecordList(i,Ge)}})};if(r===3){var n=this.parseUShort(),a=this.parseUShort();return{substFormat:r,coverages:this.parseList(n,g.pointer(g.coverage)),lookupRecords:this.parseRecordList(a,Ge)}}L.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},ue[6]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();if(r===1)return{substFormat:1,coverage:this.parsePointer(g.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ge)}})};if(r===2)return{substFormat:2,coverage:this.parsePointer(g.coverage),backtrackClassDef:this.parsePointer(g.classDef),inputClassDef:this.parsePointer(g.classDef),lookaheadClassDef:this.parsePointer(g.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ge)}})};if(r===3)return{substFormat:3,backtrackCoverage:this.parseList(g.pointer(g.coverage)),inputCoverage:this.parseList(g.pointer(g.coverage)),lookaheadCoverage:this.parseList(g.pointer(g.coverage)),lookupRecords:this.parseRecordList(Ge)};L.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},ue[7]=function(){var e=this.parseUShort();L.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");var r=this.parseUShort(),n=new g(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:r,extension:ue[r].call(n)}},ue[8]=function(){var e=this.parseUShort();return L.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(g.coverage),backtrackCoverage:this.parseList(g.pointer(g.coverage)),lookaheadCoverage:this.parseList(g.pointer(g.coverage)),substitutes:this.parseUShortList()}};function yi(t,e){e=e||0;var r=new g(t,e),n=r.parseVersion(1);return L.argument(n===1||n===1.1,"Unsupported GSUB table version."),n===1?{version:n,scripts:r.parseScriptList(),features:r.parseFeatureList(),lookups:r.parseLookupList(ue)}:{version:n,scripts:r.parseScriptList(),features:r.parseFeatureList(),lookups:r.parseLookupList(ue),variations:r.parseFeatureVariationsList()}}var Ne=new Array(9);Ne[1]=function(e){return e.substFormat===1?new T.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new T.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new T.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new T.Coverage(e.coverage)}].concat(T.ushortList("substitute",e.substitute)))},Ne[2]=function(e){return L.assert(e.substFormat===1,"Lookup type 2 substFormat must be 1."),new T.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new T.Coverage(e.coverage)}].concat(T.tableList("seqSet",e.sequences,function(r){return new T.Table("sequenceSetTable",T.ushortList("sequence",r))})))},Ne[3]=function(e){return L.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new T.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new T.Coverage(e.coverage)}].concat(T.tableList("altSet",e.alternateSets,function(r){return new T.Table("alternateSetTable",T.ushortList("alternate",r))})))},Ne[4]=function(e){return L.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new T.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new T.Coverage(e.coverage)}].concat(T.tableList("ligSet",e.ligatureSets,function(r){return new T.Table("ligatureSetTable",T.tableList("ligature",r,function(n){return new T.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:n.ligGlyph}].concat(T.ushortList("component",n.components,n.components.length+1)))}))})))},Ne[6]=function(e){if(e.substFormat===1){var r=new T.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new T.Coverage(e.coverage)}].concat(T.tableList("chainRuleSet",e.chainRuleSets,function(s){return new T.Table("chainRuleSetTable",T.tableList("chainRule",s,function(i){var o=T.ushortList("backtrackGlyph",i.backtrack,i.backtrack.length).concat(T.ushortList("inputGlyph",i.input,i.input.length+1)).concat(T.ushortList("lookaheadGlyph",i.lookahead,i.lookahead.length)).concat(T.ushortList("substitution",[],i.lookupRecords.length));return i.lookupRecords.forEach(function(u,l){o=o.concat({name:"sequenceIndex"+l,type:"USHORT",value:u.sequenceIndex}).concat({name:"lookupListIndex"+l,type:"USHORT",value:u.lookupListIndex})}),new T.Table("chainRuleTable",o)}))})));return r}else if(e.substFormat===2)L.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(e.substFormat===3){var n=[{name:"substFormat",type:"USHORT",value:e.substFormat}];n.push({name:"backtrackGlyphCount",type:"USHORT",value:e.backtrackCoverage.length}),e.backtrackCoverage.forEach(function(s,i){n.push({name:"backtrackCoverage"+i,type:"TABLE",value:new T.Coverage(s)})}),n.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length}),e.inputCoverage.forEach(function(s,i){n.push({name:"inputCoverage"+i,type:"TABLE",value:new T.Coverage(s)})}),n.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length}),e.lookaheadCoverage.forEach(function(s,i){n.push({name:"lookaheadCoverage"+i,type:"TABLE",value:new T.Coverage(s)})}),n.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length}),e.lookupRecords.forEach(function(s,i){n=n.concat({name:"sequenceIndex"+i,type:"USHORT",value:s.sequenceIndex}).concat({name:"lookupListIndex"+i,type:"USHORT",value:s.lookupListIndex})});var a=new T.Table("chainContextTable",n);return a}L.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function bi(t){return new T.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new T.ScriptList(t.scripts)},{name:"features",type:"TABLE",value:new T.FeatureList(t.features)},{name:"lookups",type:"TABLE",value:new T.LookupList(t.lookups,Ne)}])}var En={parse:yi,make:bi};function xi(t,e){var r=new O.Parser(t,e),n=r.parseULong();L.argument(n===1,"Unsupported META table version."),r.parseULong(),r.parseULong();for(var a=r.parseULong(),s={},i=0;i<a;i++){var o=r.parseTag(),u=r.parseULong(),l=r.parseULong(),c=De.UTF8(t,e+u,l);s[o]=c}return s}function Si(t){var e=Object.keys(t).length,r="",n=16+e*12,a=new T.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:n},{name:"numTags",type:"ULONG",value:e}]);for(var s in t){var i=r.length;r+=t[s],a.fields.push({name:"tag "+s,type:"TAG",value:s}),a.fields.push({name:"offset "+s,type:"ULONG",value:n+i}),a.fields.push({name:"length "+s,type:"ULONG",value:t[s].length})}return a.fields.push({name:"stringPool",type:"CHARARRAY",value:r}),a}var On={parse:xi,make:Si};function Un(t){return Math.log(t)/Math.log(2)|0}function Kt(t){for(;t.length%4!==0;)t.push(0);for(var e=0,r=0;r<t.length;r+=4)e+=(t[r]<<24)+(t[r+1]<<16)+(t[r+2]<<8)+t[r+3];return e%=Math.pow(2,32),e}function Ln(t,e,r,n){return new T.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:r!==void 0?r:0},{name:"length",type:"ULONG",value:n!==void 0?n:0}])}function Rn(t){var e=new T.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;var r=Math.pow(2,Un(e.numTables));e.searchRange=16*r,e.entrySelector=Un(r),e.rangeShift=e.numTables*16-e.searchRange;for(var n=[],a=[],s=e.sizeOf()+Ln().sizeOf()*e.numTables;s%4!==0;)s+=1,a.push({name:"padding",type:"BYTE",value:0});for(var i=0;i<t.length;i+=1){var o=t[i];L.argument(o.tableName.length===4,"Table name"+o.tableName+" is invalid.");var u=o.sizeOf(),l=Ln(o.tableName,Kt(o.encode()),s,u);for(n.push({name:l.tag+" Table Record",type:"RECORD",value:l}),a.push({name:o.tableName+" table",type:"RECORD",value:o}),s+=u,L.argument(!isNaN(s),"Something went wrong calculating the offset.");s%4!==0;)s+=1,a.push({name:"padding",type:"BYTE",value:0})}return n.sort(function(c,f){return c.value.tag>f.value.tag?1:-1}),e.fields=e.fields.concat(n),e.fields=e.fields.concat(a),e}function Mn(t,e,r){for(var n=0;n<e.length;n+=1){var a=t.charToGlyphIndex(e[n]);if(a>0){var s=t.glyphs.get(a);return s.getMetrics()}}return r}function ki(t){for(var e=0,r=0;r<t.length;r+=1)e+=t[r];return e/t.length}function Fi(t){for(var e=[],r=[],n=[],a=[],s=[],i=[],o=[],u,l=0,c=0,f=0,h=0,p=0,d=0;d<t.glyphs.length;d+=1){var m=t.glyphs.get(d),b=m.unicode|0;if(isNaN(m.advanceWidth))throw new Error("Glyph "+m.name+" ("+d+"): advanceWidth is not a number.");(u>b||u===void 0)&&b>0&&(u=b),l<b&&(l=b);var y=jt.getUnicodeRange(b);if(y<32)c|=1<<y;else if(y<64)f|=1<<y-32;else if(y<96)h|=1<<y-64;else if(y<123)p|=1<<y-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(m.name!==".notdef"){var S=m.getMetrics();e.push(S.xMin),r.push(S.yMin),n.push(S.xMax),a.push(S.yMax),i.push(S.leftSideBearing),o.push(S.rightSideBearing),s.push(m.advanceWidth)}}var x={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,r),xMax:Math.max.apply(null,n),yMax:Math.max.apply(null,a),advanceWidthMax:Math.max.apply(null,s),advanceWidthAvg:ki(s),minLeftSideBearing:Math.min.apply(null,i),maxLeftSideBearing:Math.max.apply(null,i),minRightSideBearing:Math.min.apply(null,o)};x.ascender=t.ascender,x.descender=t.descender;var C=dn.make({flags:3,unitsPerEm:t.unitsPerEm,xMin:x.xMin,yMin:x.yMin,xMax:x.xMax,yMax:x.yMax,lowestRecPPEM:3,createdTimestamp:t.createdTimestamp}),k=gn.make({ascender:x.ascender,descender:x.descender,advanceWidthMax:x.advanceWidthMax,minLeftSideBearing:x.minLeftSideBearing,minRightSideBearing:x.minRightSideBearing,xMaxExtent:x.maxLeftSideBearing+(x.xMax-x.xMin),numberOfHMetrics:t.glyphs.length}),A=yn.make(t.glyphs.length),U=jt.make(Object.assign({xAvgCharWidth:Math.round(x.advanceWidthAvg),usFirstCharIndex:u,usLastCharIndex:l,ulUnicodeRange1:c,ulUnicodeRange2:f,ulUnicodeRange3:h,ulUnicodeRange4:p,sTypoAscender:x.ascender,sTypoDescender:x.descender,sTypoLineGap:0,usWinAscent:x.yMax,usWinDescent:Math.abs(x.yMin),ulCodePageRange1:1,sxHeight:Mn(t,"xyvw",{yMax:Math.round(x.ascender/2)}).yMax,sCapHeight:Mn(t,"HIKLEFJMNTZBDPRAGOQSUVWXY",x).yMax,usDefaultChar:t.hasChar(" ")?32:0,usBreakChar:t.hasChar(" ")?32:0},t.tables.os2)),E=vn.make(t.glyphs),B=Qr.make(t.glyphs),z=t.getEnglishName("fontFamily"),Q=t.getEnglishName("fontSubfamily"),J=z+" "+Q,Z=t.getEnglishName("postScriptName");Z||(Z=z.replace(/\s/g,"")+"-"+Q);var D={};for(var W in t.names)D[W]=t.names[W];D.uniqueID||(D.uniqueID={en:t.getEnglishName("manufacturer")+":"+J}),D.postScriptName||(D.postScriptName={en:Z}),D.preferredFamily||(D.preferredFamily=t.names.fontFamily),D.preferredSubfamily||(D.preferredSubfamily=t.names.fontSubfamily);var N=[],q=wn.make(D,N),j=N.length>0?mn.make(N):void 0,Y=Cn.make(),$=pn.make(t.glyphs,{version:t.getEnglishName("version"),fullName:J,familyName:z,weightName:Q,postScriptName:Z,unitsPerEm:t.unitsPerEm,fontBBox:[0,x.yMin,x.ascender,x.advanceWidthMax]}),I=t.metas&&Object.keys(t.metas).length>0?On.make(t.metas):void 0,K=[C,k,A,U,q,B,Y,$,E];j&&K.push(j),t.tables.gsub&&K.push(En.make(t.tables.gsub)),I&&K.push(I);for(var Sr=Rn(K),Ul=Sr.encode(),Ll=Kt(Ul),kr=Sr.fields,Ta=!1,xt=0;xt<kr.length;xt+=1)if(kr[xt].name==="head table"){kr[xt].value.checkSumAdjustment=2981146554-Ll,Ta=!0;break}if(!Ta)throw new Error("Could not find head table with checkSum to adjust.");return Sr}var Ti={make:Rn,fontToTable:Fi,computeCheckSum:Kt};function Qt(t,e){for(var r=0,n=t.length-1;r<=n;){var a=r+n>>>1,s=t[a].tag;if(s===e)return a;s<e?r=a+1:n=a-1}return-r-1}function An(t,e){for(var r=0,n=t.length-1;r<=n;){var a=r+n>>>1,s=t[a];if(s===e)return a;s<e?r=a+1:n=a-1}return-r-1}function Pn(t,e){for(var r,n=0,a=t.length-1;n<=a;){var s=n+a>>>1;r=t[s];var i=r.start;if(i===e)return r;i<e?n=s+1:a=s-1}if(n>0)return r=t[n-1],e>r.end?0:r}function Ze(t,e){this.font=t,this.tableName=e}Ze.prototype={searchTag:Qt,binSearch:An,getTable:function(t){var e=this.font.tables[this.tableName];return!e&&t&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){var t=this.getTable();return t?t.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){var t=this.getTable();if(t){for(var e=!1,r=0;r<t.scripts.length;r++){var n=t.scripts[r].tag;if(n==="DFLT")return n;n==="latn"&&(e=!0)}if(e)return"latn"}},getScriptTable:function(t,e){var r=this.getTable(e);if(r){t=t||"DFLT";var n=r.scripts,a=Qt(r.scripts,t);if(a>=0)return n[a].script;if(e){var s={tag:t,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return n.splice(-1-a,0,s),s.script}}},getLangSysTable:function(t,e,r){var n=this.getScriptTable(t,r);if(n){if(!e||e==="dflt"||e==="DFLT")return n.defaultLangSys;var a=Qt(n.langSysRecords,e);if(a>=0)return n.langSysRecords[a].langSys;if(r){var s={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return n.langSysRecords.splice(-1-a,0,s),s.langSys}}},getFeatureTable:function(t,e,r,n){var a=this.getLangSysTable(t,e,n);if(a){for(var s,i=a.featureIndexes,o=this.font.tables[this.tableName].features,u=0;u<i.length;u++)if(s=o[i[u]],s.tag===r)return s.feature;if(n){var l=o.length;return L.assert(l===0||r>=o[l-1].tag,"Features must be added in alphabetical order."),s={tag:r,feature:{params:0,lookupListIndexes:[]}},o.push(s),i.push(l),s.feature}}},getLookupTables:function(t,e,r,n,a){var s=this.getFeatureTable(t,e,r,a),i=[];if(s){for(var o,u=s.lookupListIndexes,l=this.font.tables[this.tableName].lookups,c=0;c<u.length;c++)o=l[u[c]],o.lookupType===n&&i.push(o);if(i.length===0&&a){o={lookupType:n,lookupFlag:0,subtables:[],markFilteringSet:void 0};var f=l.length;return l.push(o),u.push(f),[o]}}return i},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:var r=Pn(t.ranges,e);return r?r.classId:0}},getCoverageIndex:function(t,e){switch(t.format){case 1:var r=An(t.glyphs,e);return r>=0?r:-1;case 2:var n=Pn(t.ranges,e);return n?n.index+e-n.start:-1}},expandCoverage:function(t){if(t.format===1)return t.glyphs;for(var e=[],r=t.ranges,n=0;n<r.length;n++)for(var a=r[n],s=a.start,i=a.end,o=s;o<=i;o++)e.push(o);return e}};function je(t){Ze.call(this,t,"gpos")}je.prototype=Ze.prototype,je.prototype.init=function(){var t=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(t)},je.prototype.getKerningValue=function(t,e,r){for(var n=0;n<t.length;n++)for(var a=t[n].subtables,s=0;s<a.length;s++){var i=a[s],o=this.getCoverageIndex(i.coverage,e);if(!(o<0))switch(i.posFormat){case 1:for(var u=i.pairSets[o],l=0;l<u.length;l++){var c=u[l];if(c.secondGlyph===r)return c.value1&&c.value1.xAdvance||0}break;case 2:var f=this.getGlyphClass(i.classDef1,e),h=this.getGlyphClass(i.classDef2,r),p=i.classRecords[f][h];return p.value1&&p.value1.xAdvance||0}}return 0},je.prototype.getKerningTables=function(t,e){if(this.font.tables.gpos)return this.getLookupTables(t,e,"kern",2)};function ee(t){Ze.call(this,t,"gsub")}function wi(t,e){var r=t.length;if(r!==e.length)return!1;for(var n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}function $t(t,e,r){for(var n=t.subtables,a=0;a<n.length;a++){var s=n[a];if(s.substFormat===e)return s}if(r)return n.push(r),r}ee.prototype=Ze.prototype,ee.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},ee.prototype.getSingle=function(t,e,r){for(var n=[],a=this.getLookupTables(e,r,t,1),s=0;s<a.length;s++)for(var i=a[s].subtables,o=0;o<i.length;o++){var u=i[o],l=this.expandCoverage(u.coverage),c=void 0;if(u.substFormat===1){var f=u.deltaGlyphId;for(c=0;c<l.length;c++){var h=l[c];n.push({sub:h,by:h+f})}}else{var p=u.substitute;for(c=0;c<l.length;c++)n.push({sub:l[c],by:p[c]})}}return n},ee.prototype.getMultiple=function(t,e,r){for(var n=[],a=this.getLookupTables(e,r,t,2),s=0;s<a.length;s++)for(var i=a[s].subtables,o=0;o<i.length;o++){var u=i[o],l=this.expandCoverage(u.coverage),c=void 0;for(c=0;c<l.length;c++){var f=l[c],h=u.sequences[c];n.push({sub:f,by:h})}}return n},ee.prototype.getAlternates=function(t,e,r){for(var n=[],a=this.getLookupTables(e,r,t,3),s=0;s<a.length;s++)for(var i=a[s].subtables,o=0;o<i.length;o++)for(var u=i[o],l=this.expandCoverage(u.coverage),c=u.alternateSets,f=0;f<l.length;f++)n.push({sub:l[f],by:c[f]});return n},ee.prototype.getLigatures=function(t,e,r){for(var n=[],a=this.getLookupTables(e,r,t,4),s=0;s<a.length;s++)for(var i=a[s].subtables,o=0;o<i.length;o++)for(var u=i[o],l=this.expandCoverage(u.coverage),c=u.ligatureSets,f=0;f<l.length;f++)for(var h=l[f],p=c[f],d=0;d<p.length;d++){var m=p[d];n.push({sub:[h].concat(m.components),by:m.ligGlyph})}return n},ee.prototype.addSingle=function(t,e,r,n){var a=this.getLookupTables(r,n,t,1,!0)[0],s=$t(a,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});L.assert(s.coverage.format===1,"Single: unable to modify coverage table format "+s.coverage.format);var i=e.sub,o=this.binSearch(s.coverage.glyphs,i);o<0&&(o=-1-o,s.coverage.glyphs.splice(o,0,i),s.substitute.splice(o,0,0)),s.substitute[o]=e.by},ee.prototype.addMultiple=function(t,e,r,n){L.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');var a=this.getLookupTables(r,n,t,2,!0)[0],s=$t(a,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});L.assert(s.coverage.format===1,"Multiple: unable to modify coverage table format "+s.coverage.format);var i=e.sub,o=this.binSearch(s.coverage.glyphs,i);o<0&&(o=-1-o,s.coverage.glyphs.splice(o,0,i),s.sequences.splice(o,0,0)),s.sequences[o]=e.by},ee.prototype.addAlternate=function(t,e,r,n){var a=this.getLookupTables(r,n,t,3,!0)[0],s=$t(a,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});L.assert(s.coverage.format===1,"Alternate: unable to modify coverage table format "+s.coverage.format);var i=e.sub,o=this.binSearch(s.coverage.glyphs,i);o<0&&(o=-1-o,s.coverage.glyphs.splice(o,0,i),s.alternateSets.splice(o,0,0)),s.alternateSets[o]=e.by},ee.prototype.addLigature=function(t,e,r,n){var a=this.getLookupTables(r,n,t,4,!0)[0],s=a.subtables[0];s||(s={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},a.subtables[0]=s),L.assert(s.coverage.format===1,"Ligature: unable to modify coverage table format "+s.coverage.format);var i=e.sub[0],o=e.sub.slice(1),u={ligGlyph:e.by,components:o},l=this.binSearch(s.coverage.glyphs,i);if(l>=0){for(var c=s.ligatureSets[l],f=0;f<c.length;f++)if(wi(c[f].components,o))return;c.push(u)}else l=-1-l,s.coverage.glyphs.splice(l,0,i),s.ligatureSets.splice(l,0,[u])},ee.prototype.getFeature=function(t,e,r){if(/ss\d\d/.test(t))return this.getSingle(t,e,r);switch(t){case"aalt":case"salt":return this.getSingle(t,e,r).concat(this.getAlternates(t,e,r));case"dlig":case"liga":case"rlig":return this.getLigatures(t,e,r);case"ccmp":return this.getMultiple(t,e,r).concat(this.getLigatures(t,e,r));case"stch":return this.getMultiple(t,e,r)}},ee.prototype.add=function(t,e,r,n){if(/ss\d\d/.test(t))return this.addSingle(t,e,r,n);switch(t){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(t,e,r,n):this.addAlternate(t,e,r,n);case"dlig":case"liga":case"rlig":return this.addLigature(t,e,r,n);case"ccmp":return e.by instanceof Array?this.addMultiple(t,e,r,n):this.addLigature(t,e,r,n)}};function Ci(){return typeof window<"u"}function Ei(t){for(var e=new Buffer(t.byteLength),r=new Uint8Array(t),n=0;n<e.length;++n)e[n]=r[n];return e}function Ke(t,e){if(!t)throw e}function Bn(t,e,r,n,a){var s;return(e&n)>0?(s=t.parseByte(),e&a||(s=-s),s=r+s):(e&a)>0?s=r:s=r+t.parseShort(),s}function In(t,e,r){var n=new O.Parser(e,r);t.numberOfContours=n.parseShort(),t._xMin=n.parseShort(),t._yMin=n.parseShort(),t._xMax=n.parseShort(),t._yMax=n.parseShort();var a,s;if(t.numberOfContours>0){for(var i=t.endPointIndices=[],o=0;o<t.numberOfContours;o+=1)i.push(n.parseUShort());t.instructionLength=n.parseUShort(),t.instructions=[];for(var u=0;u<t.instructionLength;u+=1)t.instructions.push(n.parseByte());var l=i[i.length-1]+1;a=[];for(var c=0;c<l;c+=1)if(s=n.parseByte(),a.push(s),(s&8)>0)for(var f=n.parseByte(),h=0;h<f;h+=1)a.push(s),c+=1;if(L.argument(a.length===l,"Bad flags."),i.length>0){var p=[],d;if(l>0){for(var m=0;m<l;m+=1)s=a[m],d={},d.onCurve=!!(s&1),d.lastPointOfContour=i.indexOf(m)>=0,p.push(d);for(var b=0,y=0;y<l;y+=1)s=a[y],d=p[y],d.x=Bn(n,s,b,2,16),b=d.x;for(var S=0,x=0;x<l;x+=1)s=a[x],d=p[x],d.y=Bn(n,s,S,4,32),S=d.y}t.points=p}else t.points=[]}else if(t.numberOfContours===0)t.points=[];else{t.isComposite=!0,t.points=[],t.components=[];for(var C=!0;C;){a=n.parseUShort();var k={glyphIndex:n.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(a&1)>0?(a&2)>0?(k.dx=n.parseShort(),k.dy=n.parseShort()):k.matchedPoints=[n.parseUShort(),n.parseUShort()]:(a&2)>0?(k.dx=n.parseChar(),k.dy=n.parseChar()):k.matchedPoints=[n.parseByte(),n.parseByte()],(a&8)>0?k.xScale=k.yScale=n.parseF2Dot14():(a&64)>0?(k.xScale=n.parseF2Dot14(),k.yScale=n.parseF2Dot14()):(a&128)>0&&(k.xScale=n.parseF2Dot14(),k.scale01=n.parseF2Dot14(),k.scale10=n.parseF2Dot14(),k.yScale=n.parseF2Dot14()),t.components.push(k),C=!!(a&32)}if(a&256){t.instructionLength=n.parseUShort(),t.instructions=[];for(var A=0;A<t.instructionLength;A+=1)t.instructions.push(n.parseByte())}}}function Jt(t,e){for(var r=[],n=0;n<t.length;n+=1){var a=t[n],s={x:e.xScale*a.x+e.scale01*a.y+e.dx,y:e.scale10*a.x+e.yScale*a.y+e.dy,onCurve:a.onCurve,lastPointOfContour:a.lastPointOfContour};r.push(s)}return r}function Oi(t){for(var e=[],r=[],n=0;n<t.length;n+=1){var a=t[n];r.push(a),a.lastPointOfContour&&(e.push(r),r=[])}return L.argument(r.length===0,"There are still points left in the current contour."),e}function Dn(t){var e=new V;if(!t)return e;for(var r=Oi(t),n=0;n<r.length;++n){var a=r[n],s=null,i=a[a.length-1],o=a[0];if(i.onCurve)e.moveTo(i.x,i.y);else if(o.onCurve)e.moveTo(o.x,o.y);else{var u={x:(i.x+o.x)*.5,y:(i.y+o.y)*.5};e.moveTo(u.x,u.y)}for(var l=0;l<a.length;++l)if(s=i,i=o,o=a[(l+1)%a.length],i.onCurve)e.lineTo(i.x,i.y);else{var c=o;s.onCurve||((i.x+s.x)*.5,(i.y+s.y)*.5),o.onCurve||(c={x:(i.x+o.x)*.5,y:(i.y+o.y)*.5}),e.quadraticCurveTo(i.x,i.y,c.x,c.y)}e.closePath()}return e}function Gn(t,e){if(e.isComposite)for(var r=0;r<e.components.length;r+=1){var n=e.components[r],a=t.get(n.glyphIndex);if(a.getPath(),a.points){var s=void 0;if(n.matchedPoints===void 0)s=Jt(a.points,n);else{if(n.matchedPoints[0]>e.points.length-1||n.matchedPoints[1]>a.points.length-1)throw Error("Matched points out of range in "+e.name);var i=e.points[n.matchedPoints[0]],o=a.points[n.matchedPoints[1]],u={xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:0,dy:0};o=Jt([o],u)[0],u.dx=i.x-o.x,u.dy=i.y-o.y,s=Jt(a.points,u)}e.points=e.points.concat(s)}}return Dn(e.points)}function Ui(t,e,r,n){for(var a=new ge.GlyphSet(n),s=0;s<r.length-1;s+=1){var i=r[s],o=r[s+1];i!==o?a.push(s,ge.ttfGlyphLoader(n,s,In,t,e+i,Gn)):a.push(s,ge.glyphLoader(n,s))}return a}function Li(t,e,r,n){var a=new ge.GlyphSet(n);return n._push=function(s){var i=r[s],o=r[s+1];i!==o?a.push(s,ge.ttfGlyphLoader(n,s,In,t,e+i,Gn)):a.push(s,ge.glyphLoader(n,s))},a}function Ri(t,e,r,n,a){return a.lowMemory?Li(t,e,r,n):Ui(t,e,r,n)}var Nn={getPath:Dn,parse:Ri},_n,Me,Hn,er;function zn(t){this.font=t,this.getCommands=function(e){return Nn.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Mi(t){return t}function Wn(t){return Math.sign(t)*Math.round(Math.abs(t))}function Ai(t){return Math.sign(t)*Math.round(Math.abs(t*2))/2}function Pi(t){return Math.sign(t)*(Math.round(Math.abs(t)+.5)-.5)}function Bi(t){return Math.sign(t)*Math.ceil(Math.abs(t))}function Ii(t){return Math.sign(t)*Math.floor(Math.abs(t))}var Vn=function(t){var e=this.srPeriod,r=this.srPhase,n=this.srThreshold,a=1;return t<0&&(t=-t,a=-1),t+=n-r,t=Math.trunc(t/e)*e,t+=r,t<0?r*a:t*a},ve={x:1,y:0,axis:"x",distance:function(t,e,r,n){return(r?t.xo:t.x)-(n?e.xo:e.x)},interpolate:function(t,e,r,n){var a,s,i,o,u,l,c;if(!n||n===this){if(a=t.xo-e.xo,s=t.xo-r.xo,u=e.x-e.xo,l=r.x-r.xo,i=Math.abs(a),o=Math.abs(s),c=i+o,c===0){t.x=t.xo+(u+l)/2;return}t.x=t.xo+(u*o+l*i)/c;return}if(a=n.distance(t,e,!0,!0),s=n.distance(t,r,!0,!0),u=n.distance(e,e,!1,!0),l=n.distance(r,r,!1,!0),i=Math.abs(a),o=Math.abs(s),c=i+o,c===0){ve.setRelative(t,t,(u+l)/2,n,!0);return}ve.setRelative(t,t,(u*o+l*i)/c,n,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(t,e,r,n,a){if(!n||n===this){t.x=(a?e.xo:e.x)+r;return}var s=a?e.xo:e.x,i=a?e.yo:e.y,o=s+r*n.x,u=i+r*n.y;t.x=o+(t.y-u)/n.normalSlope},slope:0,touch:function(t){t.xTouched=!0},touched:function(t){return t.xTouched},untouch:function(t){t.xTouched=!1}},me={x:0,y:1,axis:"y",distance:function(t,e,r,n){return(r?t.yo:t.y)-(n?e.yo:e.y)},interpolate:function(t,e,r,n){var a,s,i,o,u,l,c;if(!n||n===this){if(a=t.yo-e.yo,s=t.yo-r.yo,u=e.y-e.yo,l=r.y-r.yo,i=Math.abs(a),o=Math.abs(s),c=i+o,c===0){t.y=t.yo+(u+l)/2;return}t.y=t.yo+(u*o+l*i)/c;return}if(a=n.distance(t,e,!0,!0),s=n.distance(t,r,!0,!0),u=n.distance(e,e,!1,!0),l=n.distance(r,r,!1,!0),i=Math.abs(a),o=Math.abs(s),c=i+o,c===0){me.setRelative(t,t,(u+l)/2,n,!0);return}me.setRelative(t,t,(u*o+l*i)/c,n,!0)},normalSlope:0,setRelative:function(t,e,r,n,a){if(!n||n===this){t.y=(a?e.yo:e.y)+r;return}var s=a?e.xo:e.x,i=a?e.yo:e.y,o=s+r*n.x,u=i+r*n.y;t.y=u+n.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(ve),Object.freeze(me);function Qe(t,e){this.x=t,this.y=e,this.axis=void 0,this.slope=e/t,this.normalSlope=-t/e,Object.freeze(this)}Qe.prototype.distance=function(t,e,r,n){return this.x*ve.distance(t,e,r,n)+this.y*me.distance(t,e,r,n)},Qe.prototype.interpolate=function(t,e,r,n){var a,s,i,o,u,l,c;if(i=n.distance(t,e,!0,!0),o=n.distance(t,r,!0,!0),a=n.distance(e,e,!1,!0),s=n.distance(r,r,!1,!0),u=Math.abs(i),l=Math.abs(o),c=u+l,c===0){this.setRelative(t,t,(a+s)/2,n,!0);return}this.setRelative(t,t,(a*l+s*u)/c,n,!0)},Qe.prototype.setRelative=function(t,e,r,n,a){n=n||this;var s=a?e.xo:e.x,i=a?e.yo:e.y,o=s+r*n.x,u=i+r*n.y,l=n.normalSlope,c=this.slope,f=t.x,h=t.y;t.x=(c*f-l*o+u-h)/(c-l),t.y=c*(t.x-f)+h},Qe.prototype.touch=function(t){t.xTouched=!0,t.yTouched=!0};function $e(t,e){var r=Math.sqrt(t*t+e*e);return t/=r,e/=r,t===1&&e===0?ve:t===0&&e===1?me:new Qe(t,e)}function ye(t,e,r,n){this.x=this.xo=Math.round(t*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=r,this.onCurve=n,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}ye.prototype.nextTouched=function(t){for(var e=this.nextPointOnContour;!t.touched(e)&&e!==this;)e=e.nextPointOnContour;return e},ye.prototype.prevTouched=function(t){for(var e=this.prevPointOnContour;!t.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Je=Object.freeze(new ye(0,0)),Di={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Fe(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=ve,this.round=Wn}}zn.prototype.exec=function(t,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(!(this._errorState>2)){var r=this.font,n=this._prepState;if(!n||n.ppem!==e){var a=this._fpgmState;if(!a){Fe.prototype=Di,a=this._fpgmState=new Fe("fpgm",r.tables.fpgm),a.funcs=[],a.font=r,v.DEBUG&&(console.log("---EXEC FPGM---"),a.step=-1);try{Me(a)}catch(l){console.log("Hinting error in FPGM:"+l),this._errorState=3;return}}Fe.prototype=a,n=this._prepState=new Fe("prep",r.tables.prep),n.ppem=e;var s=r.tables.cvt;if(s)for(var i=n.cvt=new Array(s.length),o=e/r.unitsPerEm,u=0;u<s.length;u++)i[u]=s[u]*o;else n.cvt=[];v.DEBUG&&(console.log("---EXEC PREP---"),n.step=-1);try{Me(n)}catch(l){this._errorState<2&&console.log("Hinting error in PREP:"+l),this._errorState=2}}if(!(this._errorState>1))try{return Hn(t,n)}catch(l){this._errorState<1&&(console.log("Hinting error:"+l),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}}},Hn=function(t,e){var r=e.ppem/e.font.unitsPerEm,n=r,a=t.components,s,i,o;if(Fe.prototype=e,!a)o=new Fe("glyf",t.instructions),v.DEBUG&&(console.log("---EXEC GLYPH---"),o.step=-1),er(t,o,r,n),i=o.gZone;else{var u=e.font;i=[],s=[];for(var l=0;l<a.length;l++){var c=a[l],f=u.glyphs.get(c.glyphIndex);o=new Fe("glyf",f.instructions),v.DEBUG&&(console.log("---EXEC COMP "+l+"---"),o.step=-1),er(f,o,r,n);for(var h=Math.round(c.dx*r),p=Math.round(c.dy*n),d=o.gZone,m=o.contours,b=0;b<d.length;b++){var y=d[b];y.xTouched=y.yTouched=!1,y.xo=y.x=y.x+h,y.yo=y.y=y.y+p}var S=i.length;i.push.apply(i,d);for(var x=0;x<m.length;x++)s.push(m[x]+S)}t.instructions&&!o.inhibitGridFit&&(o=new Fe("glyf",t.instructions),o.gZone=o.z0=o.z1=o.z2=i,o.contours=s,i.push(new ye(0,0),new ye(Math.round(t.advanceWidth*r),0)),v.DEBUG&&(console.log("---EXEC COMPOSITE---"),o.step=-1),Me(o),i.length-=2)}return i},er=function(t,e,r,n){for(var a=t.points||[],s=a.length,i=e.gZone=e.z0=e.z1=e.z2=[],o=e.contours=[],u,l=0;l<s;l++)u=a[l],i[l]=new ye(u.x*r,u.y*n,u.lastPointOfContour,u.onCurve);for(var c,f,h=0;h<s;h++)u=i[h],c||(c=u,o.push(h)),u.lastPointOfContour?(u.nextPointOnContour=c,c.prevPointOnContour=u,c=void 0):(f=i[h+1],u.nextPointOnContour=f,f.prevPointOnContour=u);if(!e.inhibitGridFit){if(v.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(var p=0;p<s;p++)console.log(p,i[p].x,i[p].y)}if(i.push(new ye(0,0),new ye(Math.round(t.advanceWidth*r),0)),Me(e),i.length-=2,v.DEBUG){console.log("FINISHED GLYPH",e.stack);for(var d=0;d<s;d++)console.log(d,i[d].x,i[d].y)}}},Me=function(t){var e=t.prog;if(e){var r=e.length,n;for(t.ip=0;t.ip<r;t.ip++){if(v.DEBUG&&t.step++,n=_n[e[t.ip]],!n)throw new Error("unknown instruction: 0x"+Number(e[t.ip]).toString(16));n(t)}}};function vt(t){for(var e=t.tZone=new Array(t.gZone.length),r=0;r<e.length;r++)e[r]=new ye(0,0)}function qn(t,e){var r=t.prog,n=t.ip,a=1,s;do if(s=r[++n],s===88)a++;else if(s===89)a--;else if(s===64)n+=r[n+1]+1;else if(s===65)n+=2*r[n+1]+1;else if(s>=176&&s<=183)n+=s-176+1;else if(s>=184&&s<=191)n+=(s-184+1)*2;else if(e&&a===1&&s===27)break;while(a>0);t.ip=n}function Xn(t,e){v.DEBUG&&console.log(e.step,"SVTCA["+t.axis+"]"),e.fv=e.pv=e.dpv=t}function Yn(t,e){v.DEBUG&&console.log(e.step,"SPVTCA["+t.axis+"]"),e.pv=e.dpv=t}function Zn(t,e){v.DEBUG&&console.log(e.step,"SFVTCA["+t.axis+"]"),e.fv=t}function jn(t,e){var r=e.stack,n=r.pop(),a=r.pop(),s=e.z2[n],i=e.z1[a];v.DEBUG&&console.log("SPVTL["+t+"]",n,a);var o,u;t?(o=s.y-i.y,u=i.x-s.x):(o=i.x-s.x,u=i.y-s.y),e.pv=e.dpv=$e(o,u)}function Kn(t,e){var r=e.stack,n=r.pop(),a=r.pop(),s=e.z2[n],i=e.z1[a];v.DEBUG&&console.log("SFVTL["+t+"]",n,a);var o,u;t?(o=s.y-i.y,u=i.x-s.x):(o=i.x-s.x,u=i.y-s.y),e.fv=$e(o,u)}function Gi(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"SPVFS[]",r,n),t.pv=t.dpv=$e(n,r)}function Ni(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"SPVFS[]",r,n),t.fv=$e(n,r)}function _i(t){var e=t.stack,r=t.pv;v.DEBUG&&console.log(t.step,"GPV[]"),e.push(r.x*16384),e.push(r.y*16384)}function Hi(t){var e=t.stack,r=t.fv;v.DEBUG&&console.log(t.step,"GFV[]"),e.push(r.x*16384),e.push(r.y*16384)}function zi(t){t.fv=t.pv,v.DEBUG&&console.log(t.step,"SFVTPV[]")}function Wi(t){var e=t.stack,r=e.pop(),n=e.pop(),a=e.pop(),s=e.pop(),i=e.pop(),o=t.z0,u=t.z1,l=o[r],c=o[n],f=u[a],h=u[s],p=t.z2[i];v.DEBUG&&console.log("ISECT[], ",r,n,a,s,i);var d=l.x,m=l.y,b=c.x,y=c.y,S=f.x,x=f.y,C=h.x,k=h.y,A=(d-b)*(x-k)-(m-y)*(S-C),U=d*y-m*b,E=S*k-x*C;p.x=(U*(S-C)-E*(d-b))/A,p.y=(U*(x-k)-E*(m-y))/A}function Vi(t){t.rp0=t.stack.pop(),v.DEBUG&&console.log(t.step,"SRP0[]",t.rp0)}function qi(t){t.rp1=t.stack.pop(),v.DEBUG&&console.log(t.step,"SRP1[]",t.rp1)}function Xi(t){t.rp2=t.stack.pop(),v.DEBUG&&console.log(t.step,"SRP2[]",t.rp2)}function Yi(t){var e=t.stack.pop();switch(v.DEBUG&&console.log(t.step,"SZP0[]",e),t.zp0=e,e){case 0:t.tZone||vt(t),t.z0=t.tZone;break;case 1:t.z0=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Zi(t){var e=t.stack.pop();switch(v.DEBUG&&console.log(t.step,"SZP1[]",e),t.zp1=e,e){case 0:t.tZone||vt(t),t.z1=t.tZone;break;case 1:t.z1=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function ji(t){var e=t.stack.pop();switch(v.DEBUG&&console.log(t.step,"SZP2[]",e),t.zp2=e,e){case 0:t.tZone||vt(t),t.z2=t.tZone;break;case 1:t.z2=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Ki(t){var e=t.stack.pop();switch(v.DEBUG&&console.log(t.step,"SZPS[]",e),t.zp0=t.zp1=t.zp2=e,e){case 0:t.tZone||vt(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 Qi(t){t.loop=t.stack.pop(),v.DEBUG&&console.log(t.step,"SLOOP[]",t.loop)}function $i(t){v.DEBUG&&console.log(t.step,"RTG[]"),t.round=Wn}function Ji(t){v.DEBUG&&console.log(t.step,"RTHG[]"),t.round=Pi}function eo(t){var e=t.stack.pop();v.DEBUG&&console.log(t.step,"SMD[]",e),t.minDis=e/64}function to(t){v.DEBUG&&console.log(t.step,"ELSE[]"),qn(t,!1)}function ro(t){var e=t.stack.pop();v.DEBUG&&console.log(t.step,"JMPR[]",e),t.ip+=e-1}function no(t){var e=t.stack.pop();v.DEBUG&&console.log(t.step,"SCVTCI[]",e),t.cvCutIn=e/64}function ao(t){var e=t.stack;v.DEBUG&&console.log(t.step,"DUP[]"),e.push(e[e.length-1])}function tr(t){v.DEBUG&&console.log(t.step,"POP[]"),t.stack.pop()}function so(t){v.DEBUG&&console.log(t.step,"CLEAR[]"),t.stack.length=0}function io(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"SWAP[]"),e.push(r),e.push(n)}function oo(t){var e=t.stack;v.DEBUG&&console.log(t.step,"DEPTH[]"),e.push(e.length)}function uo(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"LOOPCALL[]",r,n);var a=t.ip,s=t.prog;t.prog=t.funcs[r];for(var i=0;i<n;i++)Me(t),v.DEBUG&&console.log(++t.step,i+1<n?"next loopcall":"done loopcall",i);t.ip=a,t.prog=s}function lo(t){var e=t.stack.pop();v.DEBUG&&console.log(t.step,"CALL[]",e);var r=t.ip,n=t.prog;t.prog=t.funcs[e],Me(t),t.ip=r,t.prog=n,v.DEBUG&&console.log(++t.step,"returning from",e)}function co(t){var e=t.stack,r=e.pop();v.DEBUG&&console.log(t.step,"CINDEX[]",r),e.push(e[e.length-r])}function ho(t){var e=t.stack,r=e.pop();v.DEBUG&&console.log(t.step,"MINDEX[]",r),e.push(e.splice(e.length-r,1)[0])}function fo(t){if(t.env!=="fpgm")throw new Error("FDEF not allowed here");var e=t.stack,r=t.prog,n=t.ip,a=e.pop(),s=n;for(v.DEBUG&&console.log(t.step,"FDEF[]",a);r[++n]!==45;);t.ip=n,t.funcs[a]=r.slice(s+1,n)}function Qn(t,e){var r=e.stack.pop(),n=e.z0[r],a=e.fv,s=e.pv;v.DEBUG&&console.log(e.step,"MDAP["+t+"]",r);var i=s.distance(n,Je);t&&(i=e.round(i)),a.setRelative(n,Je,i,s),a.touch(n),e.rp0=e.rp1=r}function $n(t,e){var r=e.z2,n=r.length-2,a,s,i;v.DEBUG&&console.log(e.step,"IUP["+t.axis+"]");for(var o=0;o<n;o++)a=r[o],!t.touched(a)&&(s=a.prevTouched(t),s!==a&&(i=a.nextTouched(t),s===i&&t.setRelative(a,a,t.distance(s,s,!1,!0),t,!0),t.interpolate(a,s,i,t)))}function Jn(t,e){for(var r=e.stack,n=t?e.rp1:e.rp2,a=(t?e.z0:e.z1)[n],s=e.fv,i=e.pv,o=e.loop,u=e.z2;o--;){var l=r.pop(),c=u[l],f=i.distance(a,a,!1,!0);s.setRelative(c,c,f,i),s.touch(c),v.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-o)+": ":"")+"SHP["+(t?"rp1":"rp2")+"]",l)}e.loop=1}function ea(t,e){var r=e.stack,n=t?e.rp1:e.rp2,a=(t?e.z0:e.z1)[n],s=e.fv,i=e.pv,o=r.pop(),u=e.z2[e.contours[o]],l=u;v.DEBUG&&console.log(e.step,"SHC["+t+"]",o);var c=i.distance(a,a,!1,!0);do l!==a&&s.setRelative(l,l,c,i),l=l.nextPointOnContour;while(l!==u)}function ta(t,e){var r=e.stack,n=t?e.rp1:e.rp2,a=(t?e.z0:e.z1)[n],s=e.fv,i=e.pv,o=r.pop();v.DEBUG&&console.log(e.step,"SHZ["+t+"]",o);var u;switch(o){case 0:u=e.tZone;break;case 1:u=e.gZone;break;default:throw new Error("Invalid zone")}for(var l,c=i.distance(a,a,!1,!0),f=u.length-2,h=0;h<f;h++)l=u[h],s.setRelative(l,l,c,i)}function po(t){for(var e=t.stack,r=t.loop,n=t.fv,a=e.pop()/64,s=t.z2;r--;){var i=e.pop(),o=s[i];v.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-r)+": ":"")+"SHPIX[]",i,a),n.setRelative(o,o,a),n.touch(o)}t.loop=1}function go(t){for(var e=t.stack,r=t.rp1,n=t.rp2,a=t.loop,s=t.z0[r],i=t.z1[n],o=t.fv,u=t.dpv,l=t.z2;a--;){var c=e.pop(),f=l[c];v.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-a)+": ":"")+"IP[]",c,r,"<->",n),o.interpolate(f,s,i,u),o.touch(f)}t.loop=1}function ra(t,e){var r=e.stack,n=r.pop()/64,a=r.pop(),s=e.z1[a],i=e.z0[e.rp0],o=e.fv,u=e.pv;o.setRelative(s,i,n,u),o.touch(s),v.DEBUG&&console.log(e.step,"MSIRP["+t+"]",n,a),e.rp1=e.rp0,e.rp2=a,t&&(e.rp0=a)}function vo(t){for(var e=t.stack,r=t.rp0,n=t.z0[r],a=t.loop,s=t.fv,i=t.pv,o=t.z1;a--;){var u=e.pop(),l=o[u];v.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-a)+": ":"")+"ALIGNRP[]",u),s.setRelative(l,n,0,i),s.touch(l)}t.loop=1}function mo(t){v.DEBUG&&console.log(t.step,"RTDG[]"),t.round=Ai}function na(t,e){var r=e.stack,n=r.pop(),a=r.pop(),s=e.z0[a],i=e.fv,o=e.pv,u=e.cvt[n];v.DEBUG&&console.log(e.step,"MIAP["+t+"]",n,"(",u,")",a);var l=o.distance(s,Je);t&&(Math.abs(l-u)<e.cvCutIn&&(l=u),l=e.round(l)),i.setRelative(s,Je,l,o),e.zp0===0&&(s.xo=s.x,s.yo=s.y),i.touch(s),e.rp0=e.rp1=a}function yo(t){var e=t.prog,r=t.ip,n=t.stack,a=e[++r];v.DEBUG&&console.log(t.step,"NPUSHB[]",a);for(var s=0;s<a;s++)n.push(e[++r]);t.ip=r}function bo(t){var e=t.ip,r=t.prog,n=t.stack,a=r[++e];v.DEBUG&&console.log(t.step,"NPUSHW[]",a);for(var s=0;s<a;s++){var i=r[++e]<<8|r[++e];i&32768&&(i=-((i^65535)+1)),n.push(i)}t.ip=e}function xo(t){var e=t.stack,r=t.store;r||(r=t.store=[]);var n=e.pop(),a=e.pop();v.DEBUG&&console.log(t.step,"WS",n,a),r[a]=n}function So(t){var e=t.stack,r=t.store,n=e.pop();v.DEBUG&&console.log(t.step,"RS",n);var a=r&&r[n]||0;e.push(a)}function ko(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"WCVTP",r,n),t.cvt[n]=r/64}function Fo(t){var e=t.stack,r=e.pop();v.DEBUG&&console.log(t.step,"RCVT",r),e.push(t.cvt[r]*64)}function aa(t,e){var r=e.stack,n=r.pop(),a=e.z2[n];v.DEBUG&&console.log(e.step,"GC["+t+"]",n),r.push(e.dpv.distance(a,Je,t,!1)*64)}function sa(t,e){var r=e.stack,n=r.pop(),a=r.pop(),s=e.z1[n],i=e.z0[a],o=e.dpv.distance(i,s,t,t);v.DEBUG&&console.log(e.step,"MD["+t+"]",n,a,"->",o),e.stack.push(Math.round(o*64))}function To(t){v.DEBUG&&console.log(t.step,"MPPEM[]"),t.stack.push(t.ppem)}function wo(t){v.DEBUG&&console.log(t.step,"FLIPON[]"),t.autoFlip=!0}function Co(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"LT[]",r,n),e.push(n<r?1:0)}function Eo(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"LTEQ[]",r,n),e.push(n<=r?1:0)}function Oo(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"GT[]",r,n),e.push(n>r?1:0)}function Uo(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"GTEQ[]",r,n),e.push(n>=r?1:0)}function Lo(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"EQ[]",r,n),e.push(r===n?1:0)}function Ro(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"NEQ[]",r,n),e.push(r!==n?1:0)}function Mo(t){var e=t.stack,r=e.pop();v.DEBUG&&console.log(t.step,"ODD[]",r),e.push(Math.trunc(r)%2?1:0)}function Ao(t){var e=t.stack,r=e.pop();v.DEBUG&&console.log(t.step,"EVEN[]",r),e.push(Math.trunc(r)%2?0:1)}function Po(t){var e=t.stack.pop();v.DEBUG&&console.log(t.step,"IF[]",e),e||(qn(t,!0),v.DEBUG&&console.log(t.step,"EIF[]"))}function Bo(t){v.DEBUG&&console.log(t.step,"EIF[]")}function Io(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"AND[]",r,n),e.push(r&&n?1:0)}function Do(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"OR[]",r,n),e.push(r||n?1:0)}function Go(t){var e=t.stack,r=e.pop();v.DEBUG&&console.log(t.step,"NOT[]",r),e.push(r?0:1)}function rr(t,e){var r=e.stack,n=r.pop(),a=e.fv,s=e.pv,i=e.ppem,o=e.deltaBase+(t-1)*16,u=e.deltaShift,l=e.z0;v.DEBUG&&console.log(e.step,"DELTAP["+t+"]",n,r);for(var c=0;c<n;c++){var f=r.pop(),h=r.pop(),p=o+((h&240)>>4);if(p===i){var d=(h&15)-8;d>=0&&d++,v.DEBUG&&console.log(e.step,"DELTAPFIX",f,"by",d*u);var m=l[f];a.setRelative(m,m,d*u,s)}}}function No(t){var e=t.stack,r=e.pop();v.DEBUG&&console.log(t.step,"SDB[]",r),t.deltaBase=r}function _o(t){var e=t.stack,r=e.pop();v.DEBUG&&console.log(t.step,"SDS[]",r),t.deltaShift=Math.pow(.5,r)}function Ho(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"ADD[]",r,n),e.push(n+r)}function zo(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"SUB[]",r,n),e.push(n-r)}function Wo(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"DIV[]",r,n),e.push(n*64/r)}function Vo(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"MUL[]",r,n),e.push(n*r/64)}function qo(t){var e=t.stack,r=e.pop();v.DEBUG&&console.log(t.step,"ABS[]",r),e.push(Math.abs(r))}function Xo(t){var e=t.stack,r=e.pop();v.DEBUG&&console.log(t.step,"NEG[]",r),e.push(-r)}function Yo(t){var e=t.stack,r=e.pop();v.DEBUG&&console.log(t.step,"FLOOR[]",r),e.push(Math.floor(r/64)*64)}function Zo(t){var e=t.stack,r=e.pop();v.DEBUG&&console.log(t.step,"CEILING[]",r),e.push(Math.ceil(r/64)*64)}function mt(t,e){var r=e.stack,n=r.pop();v.DEBUG&&console.log(e.step,"ROUND[]"),r.push(e.round(n/64)*64)}function jo(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"WCVTF[]",r,n),t.cvt[n]=r*t.ppem/t.font.unitsPerEm}function nr(t,e){var r=e.stack,n=r.pop(),a=e.ppem,s=e.deltaBase+(t-1)*16,i=e.deltaShift;v.DEBUG&&console.log(e.step,"DELTAC["+t+"]",n,r);for(var o=0;o<n;o++){var u=r.pop(),l=r.pop(),c=s+((l&240)>>4);if(c===a){var f=(l&15)-8;f>=0&&f++;var h=f*i;v.DEBUG&&console.log(e.step,"DELTACFIX",u,"by",h),e.cvt[u]+=h}}}function Ko(t){var e=t.stack.pop();v.DEBUG&&console.log(t.step,"SROUND[]",e),t.round=Vn;var r;switch(e&192){case 0:r=.5;break;case 64:r=1;break;case 128:r=2;break;default:throw new Error("invalid SROUND value")}switch(t.srPeriod=r,e&48){case 0:t.srPhase=0;break;case 16:t.srPhase=.25*r;break;case 32:t.srPhase=.5*r;break;case 48:t.srPhase=.75*r;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?t.srThreshold=0:t.srThreshold=(e/8-.5)*r}function Qo(t){var e=t.stack.pop();v.DEBUG&&console.log(t.step,"S45ROUND[]",e),t.round=Vn;var r;switch(e&192){case 0:r=Math.sqrt(2)/2;break;case 64:r=Math.sqrt(2);break;case 128:r=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(t.srPeriod=r,e&48){case 0:t.srPhase=0;break;case 16:t.srPhase=.25*r;break;case 32:t.srPhase=.5*r;break;case 48:t.srPhase=.75*r;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?t.srThreshold=0:t.srThreshold=(e/8-.5)*r}function $o(t){v.DEBUG&&console.log(t.step,"ROFF[]"),t.round=Mi}function Jo(t){v.DEBUG&&console.log(t.step,"RUTG[]"),t.round=Bi}function eu(t){v.DEBUG&&console.log(t.step,"RDTG[]"),t.round=Ii}function tu(t){var e=t.stack.pop();v.DEBUG&&console.log(t.step,"SCANCTRL[]",e)}function ia(t,e){var r=e.stack,n=r.pop(),a=r.pop(),s=e.z2[n],i=e.z1[a];v.DEBUG&&console.log(e.step,"SDPVTL["+t+"]",n,a);var o,u;t?(o=s.y-i.y,u=i.x-s.x):(o=i.x-s.x,u=i.y-s.y),e.dpv=$e(o,u)}function ru(t){var e=t.stack,r=e.pop(),n=0;v.DEBUG&&console.log(t.step,"GETINFO[]",r),r&1&&(n=35),r&32&&(n|=4096),e.push(n)}function nu(t){var e=t.stack,r=e.pop(),n=e.pop(),a=e.pop();v.DEBUG&&console.log(t.step,"ROLL[]"),e.push(n),e.push(r),e.push(a)}function au(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"MAX[]",r,n),e.push(Math.max(n,r))}function su(t){var e=t.stack,r=e.pop(),n=e.pop();v.DEBUG&&console.log(t.step,"MIN[]",r,n),e.push(Math.min(n,r))}function iu(t){var e=t.stack.pop();v.DEBUG&&console.log(t.step,"SCANTYPE[]",e)}function ou(t){var e=t.stack.pop(),r=t.stack.pop();switch(v.DEBUG&&console.log(t.step,"INSTCTRL[]",e,r),e){case 1:t.inhibitGridFit=!!r;return;case 2:t.ignoreCvt=!!r;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Te(t,e){var r=e.stack,n=e.prog,a=e.ip;v.DEBUG&&console.log(e.step,"PUSHB["+t+"]");for(var s=0;s<t;s++)r.push(n[++a]);e.ip=a}function we(t,e){var r=e.ip,n=e.prog,a=e.stack;v.DEBUG&&console.log(e.ip,"PUSHW["+t+"]");for(var s=0;s<t;s++){var i=n[++r]<<8|n[++r];i&32768&&(i=-((i^65535)+1)),a.push(i)}e.ip=r}function w(t,e,r,n,a,s){var i=s.stack,o=t&&i.pop(),u=i.pop(),l=s.rp0,c=s.z0[l],f=s.z1[u],h=s.minDis,p=s.fv,d=s.dpv,m,b,y,S;b=m=d.distance(f,c,!0,!0),y=b>=0?1:-1,b=Math.abs(b),t&&(S=s.cvt[o],n&&Math.abs(b-S)<s.cvCutIn&&(b=S)),r&&b<h&&(b=h),n&&(b=s.round(b)),p.setRelative(f,c,y*b,d),p.touch(f),v.DEBUG&&console.log(s.step,(t?"MIRP[":"MDRP[")+(e?"M":"m")+(r?">":"_")+(n?"R":"_")+(a===0?"Gr":a===1?"Bl":a===2?"Wh":"")+"]",t?o+"("+s.cvt[o]+","+S+")":"",u,"(d =",m,"->",y*b,")"),s.rp1=s.rp0,s.rp2=u,e&&(s.rp0=u)}_n=[Xn.bind(void 0,me),Xn.bind(void 0,ve),Yn.bind(void 0,me),Yn.bind(void 0,ve),Zn.bind(void 0,me),Zn.bind(void 0,ve),jn.bind(void 0,0),jn.bind(void 0,1),Kn.bind(void 0,0),Kn.bind(void 0,1),Gi,Ni,_i,Hi,zi,Wi,Vi,qi,Xi,Yi,Zi,ji,Ki,Qi,$i,Ji,eo,to,ro,no,void 0,void 0,ao,tr,so,io,oo,co,ho,void 0,void 0,void 0,uo,lo,fo,void 0,Qn.bind(void 0,0),Qn.bind(void 0,1),$n.bind(void 0,me),$n.bind(void 0,ve),Jn.bind(void 0,0),Jn.bind(void 0,1),ea.bind(void 0,0),ea.bind(void 0,1),ta.bind(void 0,0),ta.bind(void 0,1),po,go,ra.bind(void 0,0),ra.bind(void 0,1),vo,mo,na.bind(void 0,0),na.bind(void 0,1),yo,bo,xo,So,ko,Fo,aa.bind(void 0,0),aa.bind(void 0,1),void 0,sa.bind(void 0,0),sa.bind(void 0,1),To,void 0,wo,void 0,void 0,Co,Eo,Oo,Uo,Lo,Ro,Mo,Ao,Po,Bo,Io,Do,Go,rr.bind(void 0,1),No,_o,Ho,zo,Wo,Vo,qo,Xo,Yo,Zo,mt.bind(void 0,0),mt.bind(void 0,1),mt.bind(void 0,2),mt.bind(void 0,3),void 0,void 0,void 0,void 0,jo,rr.bind(void 0,2),rr.bind(void 0,3),nr.bind(void 0,1),nr.bind(void 0,2),nr.bind(void 0,3),Ko,Qo,void 0,void 0,$o,void 0,Jo,eu,tr,tr,void 0,void 0,void 0,void 0,void 0,tu,ia.bind(void 0,0),ia.bind(void 0,1),ru,void 0,nu,au,su,iu,ou,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,Te.bind(void 0,1),Te.bind(void 0,2),Te.bind(void 0,3),Te.bind(void 0,4),Te.bind(void 0,5),Te.bind(void 0,6),Te.bind(void 0,7),Te.bind(void 0,8),we.bind(void 0,1),we.bind(void 0,2),we.bind(void 0,3),we.bind(void 0,4),we.bind(void 0,5),we.bind(void 0,6),we.bind(void 0,7),we.bind(void 0,8),w.bind(void 0,0,0,0,0,0),w.bind(void 0,0,0,0,0,1),w.bind(void 0,0,0,0,0,2),w.bind(void 0,0,0,0,0,3),w.bind(void 0,0,0,0,1,0),w.bind(void 0,0,0,0,1,1),w.bind(void 0,0,0,0,1,2),w.bind(void 0,0,0,0,1,3),w.bind(void 0,0,0,1,0,0),w.bind(void 0,0,0,1,0,1),w.bind(void 0,0,0,1,0,2),w.bind(void 0,0,0,1,0,3),w.bind(void 0,0,0,1,1,0),w.bind(void 0,0,0,1,1,1),w.bind(void 0,0,0,1,1,2),w.bind(void 0,0,0,1,1,3),w.bind(void 0,0,1,0,0,0),w.bind(void 0,0,1,0,0,1),w.bind(void 0,0,1,0,0,2),w.bind(void 0,0,1,0,0,3),w.bind(void 0,0,1,0,1,0),w.bind(void 0,0,1,0,1,1),w.bind(void 0,0,1,0,1,2),w.bind(void 0,0,1,0,1,3),w.bind(void 0,0,1,1,0,0),w.bind(void 0,0,1,1,0,1),w.bind(void 0,0,1,1,0,2),w.bind(void 0,0,1,1,0,3),w.bind(void 0,0,1,1,1,0),w.bind(void 0,0,1,1,1,1),w.bind(void 0,0,1,1,1,2),w.bind(void 0,0,1,1,1,3),w.bind(void 0,1,0,0,0,0),w.bind(void 0,1,0,0,0,1),w.bind(void 0,1,0,0,0,2),w.bind(void 0,1,0,0,0,3),w.bind(void 0,1,0,0,1,0),w.bind(void 0,1,0,0,1,1),w.bind(void 0,1,0,0,1,2),w.bind(void 0,1,0,0,1,3),w.bind(void 0,1,0,1,0,0),w.bind(void 0,1,0,1,0,1),w.bind(void 0,1,0,1,0,2),w.bind(void 0,1,0,1,0,3),w.bind(void 0,1,0,1,1,0),w.bind(void 0,1,0,1,1,1),w.bind(void 0,1,0,1,1,2),w.bind(void 0,1,0,1,1,3),w.bind(void 0,1,1,0,0,0),w.bind(void 0,1,1,0,0,1),w.bind(void 0,1,1,0,0,2),w.bind(void 0,1,1,0,0,3),w.bind(void 0,1,1,0,1,0),w.bind(void 0,1,1,0,1,1),w.bind(void 0,1,1,0,1,2),w.bind(void 0,1,1,0,1,3),w.bind(void 0,1,1,1,0,0),w.bind(void 0,1,1,1,0,1),w.bind(void 0,1,1,1,0,2),w.bind(void 0,1,1,1,0,3),w.bind(void 0,1,1,1,1,0),w.bind(void 0,1,1,1,1,1),w.bind(void 0,1,1,1,1,2),w.bind(void 0,1,1,1,1,3)];function _e(t){this.char=t,this.state={},this.activeState=null}function ar(t,e,r){this.contextName=r,this.startIndex=t,this.endOffset=e}function uu(t,e,r){this.contextName=t,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=r}function le(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 yt(t){this.eventId=t,this.subscribers=[]}function lu(t){var e=this,r=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];r.forEach(function(a){Object.defineProperty(e.events,a,{value:new yt(a)})}),t&&r.forEach(function(a){var s=t[a];typeof s=="function"&&e.events[a].subscribe(s)});var n=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];n.forEach(function(a){e.events[a].subscribe(e.updateContextsRanges)})}function G(t){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],lu.call(this,t)}_e.prototype.setState=function(t,e){return this.state[t]=e,this.activeState={key:t,value:this.state[t]},this.activeState},_e.prototype.getState=function(t){return this.state[t]||null},G.prototype.inboundIndex=function(t){return t>=0&&t<this.tokens.length},G.prototype.composeRUD=function(t){var e=this,r=!0,n=t.map(function(s){return e[s[0]].apply(e,s.slice(1).concat(r))}),a=function(s){return typeof s=="object"&&s.hasOwnProperty("FAIL")};if(n.every(a))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:n.filter(a)};this.dispatch("composeRUD",[n.filter(function(s){return!a(s)})])},G.prototype.replaceRange=function(t,e,r,n){e=e!==null?e:this.tokens.length;var a=r.every(function(i){return i instanceof _e});if(!isNaN(t)&&this.inboundIndex(t)&&a){var s=this.tokens.splice.apply(this.tokens,[t,e].concat(r));return n||this.dispatch("replaceToken",[t,e,r]),[s,r]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},G.prototype.replaceToken=function(t,e,r){if(!isNaN(t)&&this.inboundIndex(t)&&e instanceof _e){var n=this.tokens.splice(t,1,e);return r||this.dispatch("replaceToken",[t,e]),[n[0],e]}else return{FAIL:"replaceToken: invalid token or index."}},G.prototype.removeRange=function(t,e,r){e=isNaN(e)?this.tokens.length:e;var n=this.tokens.splice(t,e);return r||this.dispatch("removeRange",[n,t,e]),n},G.prototype.removeToken=function(t,e){if(!isNaN(t)&&this.inboundIndex(t)){var r=this.tokens.splice(t,1);return e||this.dispatch("removeToken",[r,t]),r}else return{FAIL:"removeToken: invalid token index."}},G.prototype.insertToken=function(t,e,r){var n=t.every(function(a){return a instanceof _e});return n?(this.tokens.splice.apply(this.tokens,[e,0].concat(t)),r||this.dispatch("insertToken",[t,e]),t):{FAIL:"insertToken: invalid token(s)."}},G.prototype.registerModifier=function(t,e,r){this.events.newToken.subscribe(function(n,a){var s=[n,a],i=e===null||e.apply(this,s)===!0,o=[n,a];if(i){var u=r.apply(this,o);n.setState(t,u)}}),this.registeredModifiers.push(t)},yt.prototype.subscribe=function(t){return typeof t=="function"?this.subscribers.push(t)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}},yt.prototype.unsubscribe=function(t){this.subscribers.splice(t,1)},le.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)},le.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}},G.prototype.rangeToText=function(t){if(t instanceof ar)return this.getRangeTokens(t).map(function(e){return e.char}).join("")},G.prototype.getText=function(){return this.tokens.map(function(t){return t.char}).join("")},G.prototype.getContext=function(t){var e=this.registeredContexts[t];return e||null},G.prototype.on=function(t,e){var r=this.events[t];return r?r.subscribe(e):null},G.prototype.dispatch=function(t,e){var r=this,n=this.events[t];n instanceof yt&&n.subscribers.forEach(function(a){a.apply(r,e||[])})},G.prototype.registerContextChecker=function(t,e,r){if(this.getContext(t))return{FAIL:"context name '"+t+"' is already registered."};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof r!="function")return{FAIL:"missing context end check."};var n=new uu(t,e,r);return this.registeredContexts[t]=n,this.contextCheckers.push(n),n},G.prototype.getRangeTokens=function(t){var e=t.startIndex+t.endOffset;return[].concat(this.tokens.slice(t.startIndex,e))},G.prototype.getContextRanges=function(t){var e=this.getContext(t);return e?e.ranges:{FAIL:"context checker '"+t+"' is not registered."}},G.prototype.resetContextsRanges=function(){var t=this.registeredContexts;for(var e in t)if(t.hasOwnProperty(e)){var r=t[e];r.ranges=[]}},G.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var t=this.tokens.map(function(n){return n.char}),e=0;e<t.length;e++){var r=new le(t,e);this.runContextCheck(r)}this.dispatch("updateContextsRanges",[this.registeredContexts])},G.prototype.setEndOffset=function(t,e){var r=this.getContext(e).openRange.startIndex,n=new ar(r,t,e),a=this.getContext(e).ranges;return n.rangeId=e+"."+a.length,a.push(n),this.getContext(e).openRange=null,n},G.prototype.runContextCheck=function(t){var e=this,r=t.index;this.contextCheckers.forEach(function(n){var a=n.contextName,s=e.getContext(a).openRange;if(!s&&n.checkStart(t)&&(s=new ar(r,null,a),e.getContext(a).openRange=s,e.dispatch("contextStart",[a,r])),s&&n.checkEnd(t)){var i=r-s.startIndex+1,o=e.setEndOffset(i,a);e.dispatch("contextEnd",[a,o])}})},G.prototype.tokenize=function(t){this.tokens=[],this.resetContextsRanges();var e=Array.from(t);this.dispatch("start");for(var r=0;r<e.length;r++){var n=e[r],a=new le(e,r);this.dispatch("next",[a]),this.runContextCheck(a);var s=new _e(n);this.tokens.push(s),this.dispatch("newToken",[s,a])}return this.dispatch("end",[this.tokens]),this.tokens};function Ce(t){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(t)}function oa(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 Ee(t){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(t)}function bt(t){return/[A-z]/.test(t)}function cu(t){return/\s/.test(t)}function te(t){this.font=t,this.features={}}function Ae(t){this.id=t.id,this.tag=t.tag,this.substitution=t.substitution}function et(t,e){if(!t)return-1;switch(e.format){case 1:return e.glyphs.indexOf(t);case 2:for(var r=e.ranges,n=0;n<r.length;n++){var a=r[n];if(t>=a.start&&t<=a.end){var s=t-a.start;return a.index+s}}break;default:return-1}return-1}function hu(t,e){var r=et(t,e.coverage);return r===-1?null:t+e.deltaGlyphId}function fu(t,e){var r=et(t,e.coverage);return r===-1?null:e.substitute[r]}function sr(t,e){for(var r=[],n=0;n<t.length;n++){var a=t[n],s=e.current;s=Array.isArray(s)?s[0]:s;var i=et(s,a);i!==-1&&r.push(i)}return r.length!==t.length?-1:r}function pu(t,e){var r=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(t.context.length<r)return[];var n=sr(e.inputCoverage,t);if(n===-1)return[];var a=e.inputCoverage.length-1;if(t.lookahead.length<e.lookaheadCoverage.length)return[];for(var s=t.lookahead.slice(a);s.length&&Ee(s[0].char);)s.shift();var i=new le(s,0),o=sr(e.lookaheadCoverage,i),u=[].concat(t.backtrack);for(u.reverse();u.length&&Ee(u[0].char);)u.shift();if(u.length<e.backtrackCoverage.length)return[];var l=new le(u,0),c=sr(e.backtrackCoverage,l),f=n.length===e.inputCoverage.length&&o.length===e.lookaheadCoverage.length&&c.length===e.backtrackCoverage.length,h=[];if(f)for(var p=0;p<e.lookupRecords.length;p++)for(var d=e.lookupRecords[p],m=d.lookupListIndex,b=this.getLookupByIndex(m),y=0;y<b.subtables.length;y++){var S=b.subtables[y],x=this.getLookupMethod(b,S),C=this.getSubstitutionType(b,S);if(C==="12")for(var k=0;k<n.length;k++){var A=t.get(k),U=x(A);U&&h.push(U)}}return h}function du(t,e){var r=t.current,n=et(r,e.coverage);if(n===-1)return null;for(var a,s=e.ligatureSets[n],i=0;i<s.length;i++){a=s[i];for(var o=0;o<a.components.length;o++){var u=t.lookahead[o],l=a.components[o];if(u!==l)break;if(o===a.components.length-1)return a}}return null}function gu(t,e){var r=et(t,e.coverage);return r===-1?null:e.sequences[r]}te.prototype.getDefaultScriptFeaturesIndexes=function(){for(var t=this.font.tables.gsub.scripts,e=0;e<t.length;e++){var r=t[e];if(r.tag==="DFLT")return r.script.defaultLangSys.featureIndexes}return[]},te.prototype.getScriptFeaturesIndexes=function(t){var e=this.font.tables;if(!e.gsub)return[];if(!t)return this.getDefaultScriptFeaturesIndexes();for(var r=this.font.tables.gsub.scripts,n=0;n<r.length;n++){var a=r[n];if(a.tag===t&&a.script.defaultLangSys)return a.script.defaultLangSys.featureIndexes;var s=a.langSysRecords;if(s)for(var i=0;i<s.length;i++){var o=s[i];if(o.tag===t){var u=o.langSys;return u.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},te.prototype.mapTagsToFeatures=function(t,e){for(var r={},n=0;n<t.length;n++){var a=t[n].tag,s=t[n].feature;r[a]=s}this.features[e].tags=r},te.prototype.getScriptFeatures=function(t){var e=this.features[t];if(this.features.hasOwnProperty(t))return e;var r=this.getScriptFeaturesIndexes(t);if(!r)return null;var n=this.font.tables.gsub;return e=r.map(function(a){return n.features[a]}),this.features[t]=e,this.mapTagsToFeatures(e,t),e},te.prototype.getSubstitutionType=function(t,e){var r=t.lookupType.toString(),n=e.substFormat.toString();return r+n},te.prototype.getLookupMethod=function(t,e){var r=this,n=this.getSubstitutionType(t,e);switch(n){case"11":return function(a){return hu.apply(r,[a,e])};case"12":return function(a){return fu.apply(r,[a,e])};case"63":return function(a){return pu.apply(r,[a,e])};case"41":return function(a){return du.apply(r,[a,e])};case"21":return function(a){return gu.apply(r,[a,e])};default:throw new Error("lookupType: "+t.lookupType+" - substFormat: "+e.substFormat+" is not yet supported")}},te.prototype.lookupFeature=function(t){var e=t.contextParams,r=e.index,n=this.getFeature({tag:t.tag,script:t.script});if(!n)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+t.tag+"' for script '"+t.script+"'.");for(var a=this.getFeatureLookups(n),s=[].concat(e.context),i=0;i<a.length;i++)for(var o=a[i],u=this.getLookupSubtables(o),l=0;l<u.length;l++){var c=u[l],f=this.getSubstitutionType(o,c),h=this.getLookupMethod(o,c),p=void 0;switch(f){case"11":p=h(e.current),p&&s.splice(r,1,new Ae({id:11,tag:t.tag,substitution:p}));break;case"12":p=h(e.current),p&&s.splice(r,1,new Ae({id:12,tag:t.tag,substitution:p}));break;case"63":p=h(e),Array.isArray(p)&&p.length&&s.splice(r,1,new Ae({id:63,tag:t.tag,substitution:p}));break;case"41":p=h(e),p&&s.splice(r,1,new Ae({id:41,tag:t.tag,substitution:p}));break;case"21":p=h(e.current),p&&s.splice(r,1,new Ae({id:21,tag:t.tag,substitution:p}));break}e=new le(s,r),!(Array.isArray(p)&&!p.length)&&(p=null)}return s.length?s:null},te.prototype.supports=function(t){if(!t.script)return!1;this.getScriptFeatures(t.script);var e=this.features.hasOwnProperty(t.script);if(!t.tag)return e;var r=this.features[t.script].some(function(n){return n.tag===t.tag});return e&&r},te.prototype.getLookupSubtables=function(t){return t.subtables||null},te.prototype.getLookupByIndex=function(t){var e=this.font.tables.gsub.lookups;return e[t]||null},te.prototype.getFeatureLookups=function(t){return t.lookupListIndexes.map(this.getLookupByIndex.bind(this))},te.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};this.features.hasOwnProperty(e.script)||this.getScriptFeatures(e.script);var r=this.features[e.script];return r?r.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:"No feature for script "+e.script}};function vu(t){var e=t.current,r=t.get(-1);return r===null&&Ce(e)||!Ce(r)&&Ce(e)}function mu(t){var e=t.get(1);return e===null||!Ce(e)}var yu={startCheck:vu,endCheck:mu};function bu(t){var e=t.current,r=t.get(-1);return(Ce(e)||Ee(e))&&!Ce(r)}function xu(t){var e=t.get(1);switch(!0){case e===null:return!0;case(!Ce(e)&&!Ee(e)):var r=cu(e);if(!r)return!0;if(r){var n=!1;if(n=t.lookahead.some(function(a){return Ce(a)||Ee(a)}),!n)return!0}break;default:return!1}}var Su={startCheck:bu,endCheck:xu};function ku(t,e,r){e[r].setState(t.tag,t.substitution)}function Fu(t,e,r){e[r].setState(t.tag,t.substitution)}function Tu(t,e,r){t.substitution.forEach(function(n,a){var s=e[r+a];s.setState(t.tag,n)})}function wu(t,e,r){var n=e[r];n.setState(t.tag,t.substitution.ligGlyph);for(var a=t.substitution.components.length,s=0;s<a;s++)n=e[r+s+1],n.setState("deleted",!0)}var ua={11:ku,12:Fu,63:Tu,41:wu};function ir(t,e,r){t instanceof Ae&&ua[t.id]&&ua[t.id](t,e,r)}function Cu(t){for(var e=[].concat(t.backtrack),r=e.length-1;r>=0;r--){var n=e[r],a=oa(n),s=Ee(n);if(!a&&!s)return!0;if(a)return!1}return!1}function Eu(t){if(oa(t.current))return!1;for(var e=0;e<t.lookahead.length;e++){var r=t.lookahead[e],n=Ee(r);if(!n)return!0}return!1}function Ou(t){var e=this,r="arab",n=this.featuresTags[r],a=this.tokenizer.getRangeTokens(t);if(a.length!==1){var s=new le(a.map(function(o){return o.getState("glyphIndex")}),0),i=new le(a.map(function(o){return o.char}),0);a.forEach(function(o,u){if(!Ee(o.char)){s.setCurrentIndex(u),i.setCurrentIndex(u);var l=0;Cu(i)&&(l|=1),Eu(i)&&(l|=2);var c;switch(l){case 1:c="fina";break;case 2:c="init";break;case 3:c="medi";break}if(n.indexOf(c)!==-1){var f=e.query.lookupFeature({tag:c,script:r,contextParams:s});if(f instanceof Error)return console.info(f.message);f.forEach(function(h,p){h instanceof Ae&&(ir(h,a,p),s.context[p]=h.substitution)})}}})}}function la(t,e){var r=t.map(function(n){return n.activeState.value});return new le(r,0)}function Uu(t){var e=this,r="arab",n=this.tokenizer.getRangeTokens(t),a=la(n);a.context.forEach(function(s,i){a.setCurrentIndex(i);var o=e.query.lookupFeature({tag:"rlig",script:r,contextParams:a});o.length&&(o.forEach(function(u){return ir(u,n,i)}),a=la(n))})}function Lu(t){var e=t.current,r=t.get(-1);return r===null&&bt(e)||!bt(r)&&bt(e)}function Ru(t){var e=t.get(1);return e===null||!bt(e)}var Mu={startCheck:Lu,endCheck:Ru};function ca(t,e){var r=t.map(function(n){return n.activeState.value});return new le(r,0)}function Au(t){var e=this,r="latn",n=this.tokenizer.getRangeTokens(t),a=ca(n);a.context.forEach(function(s,i){a.setCurrentIndex(i);var o=e.query.lookupFeature({tag:"liga",script:r,contextParams:a});o.length&&(o.forEach(function(u){return ir(u,n,i)}),a=ca(n))})}function ce(t){this.baseDir=t||"ltr",this.tokenizer=new G,this.featuresTags={}}ce.prototype.setText=function(t){this.text=t},ce.prototype.contextChecks={latinWordCheck:Mu,arabicWordCheck:yu,arabicSentenceCheck:Su};function or(t){var e=this.contextChecks[t+"Check"];return this.tokenizer.registerContextChecker(t,e.startCheck,e.endCheck)}function Pu(){return or.call(this,"latinWord"),or.call(this,"arabicWord"),or.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function Bu(){var t=this,e=this.tokenizer.getContextRanges("arabicSentence");e.forEach(function(r){var n=t.tokenizer.getRangeTokens(r);t.tokenizer.replaceRange(r.startIndex,r.endOffset,n.reverse())})}ce.prototype.registerFeatures=function(t,e){var r=this,n=e.filter(function(a){return r.query.supports({script:t,tag:a})});this.featuresTags.hasOwnProperty(t)?this.featuresTags[t]=this.featuresTags[t].concat(n):this.featuresTags[t]=n},ce.prototype.applyFeatures=function(t,e){if(!t)throw new Error("No valid font was provided to apply features");this.query||(this.query=new te(t));for(var r=0;r<e.length;r++){var n=e[r];this.query.supports({script:n.script})&&this.registerFeatures(n.script,n.tags)}},ce.prototype.registerModifier=function(t,e,r){this.tokenizer.registerModifier(t,e,r)};function ur(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function Iu(){var t=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){ur.call(this);var r=this.tokenizer.getContextRanges("arabicWord");r.forEach(function(n){Ou.call(t,n)})}}function Du(){var t=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){var r=this.featuresTags[e];if(r.indexOf("rlig")!==-1){ur.call(this);var n=this.tokenizer.getContextRanges("arabicWord");n.forEach(function(a){Uu.call(t,a)})}}}function Gu(){var t=this,e="latn";if(this.featuresTags.hasOwnProperty(e)){var r=this.featuresTags[e];if(r.indexOf("liga")!==-1){ur.call(this);var n=this.tokenizer.getContextRanges("latinWord");n.forEach(function(a){Au.call(t,a)})}}}ce.prototype.checkContextReady=function(t){return!!this.tokenizer.getContext(t)},ce.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(Iu.call(this),Du.call(this)),this.checkContextReady("latinWord")&&Gu.call(this),this.checkContextReady("arabicSentence")&&Bu.call(this)},ce.prototype.processText=function(t){(!this.text||this.text!==t)&&(this.setText(t),Pu.call(this),this.applyFeaturesToContexts())},ce.prototype.getBidiText=function(t){return this.processText(t),this.tokenizer.getText()},ce.prototype.getTextGlyphs=function(t){this.processText(t);for(var e=[],r=0;r<this.tokenizer.tokens.length;r++){var n=this.tokenizer.tokens[r];if(!n.state.deleted){var a=n.activeState.value;e.push(Array.isArray(a)?a[0]:a)}}return e};function P(t){t=t||{},t.tables=t.tables||{},t.empty||(Ke(t.familyName,"When creating a new Font object, familyName is required."),Ke(t.styleName,"When creating a new Font object, styleName is required."),Ke(t.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),Ke(t.ascender,"When creating a new Font object, ascender is required."),Ke(t.descender<=0,"When creating a new Font object, negative descender value is required."),this.names={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||" "}},this.unitsPerEm=t.unitsPerEm||1e3,this.ascender=t.ascender,this.descender=t.descender,this.createdTimestamp=t.createdTimestamp,this.tables=Object.assign(t.tables,{os2:Object.assign({usWeightClass:t.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:t.widthClass||this.usWidthClasses.MEDIUM,fsSelection:t.fsSelection||this.fsSelectionValues.REGULAR},t.tables.os2)})),this.supported=!0,this.glyphs=new ge.GlyphSet(this,t.glyphs||[]),this.encoding=new $r(this),this.position=new je(this),this.substitution=new ee(this),this.tables=this.tables||{},this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){if(this._hinting)return this._hinting;if(this.outlinesFormat==="truetype")return this._hinting=new zn(this)}})}P.prototype.hasChar=function(t){return this.encoding.charToGlyphIndex(t)!==null},P.prototype.charToGlyphIndex=function(t){return this.encoding.charToGlyphIndex(t)},P.prototype.charToGlyph=function(t){var e=this.charToGlyphIndex(t),r=this.glyphs.get(e);return r||(r=this.glyphs.get(0)),r},P.prototype.updateFeatures=function(t){return this.defaultRenderOptions.features.map(function(e){return e.script==="latn"?{script:"latn",tags:e.tags.filter(function(r){return t[r]})}:e})},P.prototype.stringToGlyphs=function(t,e){var r=this,n=new ce,a=function(f){return r.charToGlyphIndex(f.char)};n.registerModifier("glyphIndex",null,a);var s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;n.applyFeatures(this,s);for(var i=n.getTextGlyphs(t),o=i.length,u=new Array(o),l=this.glyphs.get(0),c=0;c<o;c+=1)u[c]=this.glyphs.get(i[c])||l;return u},P.prototype.nameToGlyphIndex=function(t){return this.glyphNames.nameToGlyphIndex(t)},P.prototype.nameToGlyph=function(t){var e=this.nameToGlyphIndex(t),r=this.glyphs.get(e);return r||(r=this.glyphs.get(0)),r},P.prototype.glyphIndexToName=function(t){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(t):""},P.prototype.getKerningValue=function(t,e){t=t.index||t,e=e.index||e;var r=this.position.defaultKerningTables;return r?this.position.getKerningValue(r,t,e):this.kerningPairs[t+","+e]||0},P.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]},P.prototype.forEachGlyph=function(t,e,r,n,a,s){e=e!==void 0?e:0,r=r!==void 0?r:0,n=n!==void 0?n:72,a=Object.assign({},this.defaultRenderOptions,a);var i=1/this.unitsPerEm*n,o=this.stringToGlyphs(t,a),u;if(a.kerning){var l=a.script||this.position.getDefaultScriptName();u=this.position.getKerningTables(l,a.language)}for(var c=0;c<o.length;c+=1){var f=o[c];if(s.call(this,f,e,r,n,a),f.advanceWidth&&(e+=f.advanceWidth*i),a.kerning&&c<o.length-1){var h=u?this.position.getKerningValue(u,f.index,o[c+1].index):this.getKerningValue(f,o[c+1]);e+=h*i}a.letterSpacing?e+=a.letterSpacing*n:a.tracking&&(e+=a.tracking/1e3*n)}return e},P.prototype.getPath=function(t,e,r,n,a){var s=new V;return this.forEachGlyph(t,e,r,n,a,function(i,o,u,l){var c=i.getPath(o,u,l,a,this);s.extend(c)}),s},P.prototype.getPaths=function(t,e,r,n,a){var s=[];return this.forEachGlyph(t,e,r,n,a,function(i,o,u,l){var c=i.getPath(o,u,l,a,this);s.push(c)}),s},P.prototype.getAdvanceWidth=function(t,e,r){return this.forEachGlyph(t,0,0,e,r,function(){})},P.prototype.draw=function(t,e,r,n,a,s){this.getPath(e,r,n,a,s).draw(t)},P.prototype.drawPoints=function(t,e,r,n,a,s){this.forEachGlyph(e,r,n,a,s,function(i,o,u,l){i.drawPoints(t,o,u,l)})},P.prototype.drawMetrics=function(t,e,r,n,a,s){this.forEachGlyph(e,r,n,a,s,function(i,o,u,l){i.drawMetrics(t,o,u,l)})},P.prototype.getEnglishName=function(t){var e=this.names[t];if(e)return e.en},P.prototype.validate=function(){var t=this;function e(n,a){}function r(n){var a=t.getEnglishName(n);a&&a.trim().length>0}r("fontFamily"),r("weightName"),r("manufacturer"),r("copyright"),r("version"),this.unitsPerEm>0},P.prototype.toTables=function(){return Ti.fontToTable(this)},P.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},P.prototype.toArrayBuffer=function(){for(var t=this.toTables(),e=t.encode(),r=new ArrayBuffer(e.length),n=new Uint8Array(r),a=0;a<e.length;a++)n[a]=e[a];return r},P.prototype.download=function(t){var e=this.getEnglishName("fontFamily"),r=this.getEnglishName("fontSubfamily");t=t||e.replace(/\s/g,"")+"-"+r+".otf";var n=this.toArrayBuffer();if(Ci())if(window.URL=window.URL||window.webkitURL,window.URL){var a=new DataView(n),s=new Blob([a],{type:"font/opentype"}),i=document.createElement("a");i.href=window.URL.createObjectURL(s),i.download=t;var o=document.createEvent("MouseEvents");o.initEvent("click",!0,!1),i.dispatchEvent(o)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{var u=require("fs"),l=Ei(n);u.writeFileSync(t,l)}},P.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},P.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},P.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function ha(t,e){var r=JSON.stringify(t),n=256;for(var a in e){var s=parseInt(a);if(!(!s||s<256)){if(JSON.stringify(e[a])===r)return s;n<=s&&(n=s+1)}}return e[n]=t,n}function Nu(t,e,r){var n=ha(e.name,r);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:n}]}function _u(t,e,r){var n={},a=new O.Parser(t,e);return n.tag=a.parseTag(),n.minValue=a.parseFixed(),n.defaultValue=a.parseFixed(),n.maxValue=a.parseFixed(),a.skip("uShort",1),n.name=r[a.parseUShort()]||{},n}function Hu(t,e,r,n){for(var a=ha(e.name,n),s=[{name:"nameID_"+t,type:"USHORT",value:a},{name:"flags_"+t,type:"USHORT",value:0}],i=0;i<r.length;++i){var o=r[i].tag;s.push({name:"axis_"+t+" "+o,type:"FIXED",value:e.coordinates[o]<<16})}return s}function zu(t,e,r,n){var a={},s=new O.Parser(t,e);a.name=n[s.parseUShort()]||{},s.skip("uShort",1),a.coordinates={};for(var i=0;i<r.length;++i)a.coordinates[r[i].tag]=s.parseFixed();return a}function Wu(t,e){var r=new T.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}]);r.offsetToData=r.sizeOf();for(var n=0;n<t.axes.length;n++)r.fields=r.fields.concat(Nu(n,t.axes[n],e));for(var a=0;a<t.instances.length;a++)r.fields=r.fields.concat(Hu(a,t.instances[a],t.axes,e));return r}function Vu(t,e,r){var n=new O.Parser(t,e),a=n.parseULong();L.argument(a===65536,"Unsupported fvar table version.");var s=n.parseOffset16();n.skip("uShort",1);for(var i=n.parseUShort(),o=n.parseUShort(),u=n.parseUShort(),l=n.parseUShort(),c=[],f=0;f<i;f++)c.push(_u(t,e+s+f*o,r));for(var h=[],p=e+s+i*o,d=0;d<u;d++)h.push(zu(t,p+d*l,c,r));return{axes:c,instances:h}}var qu={make:Wu,parse:Vu},Xu=function(){return{coverage:this.parsePointer(g.coverage),attachPoints:this.parseList(g.pointer(g.uShortList))}},Yu=function(){var t=this.parseUShort();if(L.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()}},Zu=function(){return this.parseList(g.pointer(Yu))},ju=function(){return{coverage:this.parsePointer(g.coverage),ligGlyphs:this.parseList(g.pointer(Zu))}},Ku=function(){return this.parseUShort(),this.parseList(g.pointer(g.coverage))};function Qu(t,e){e=e||0;var r=new g(t,e),n=r.parseVersion(1);L.argument(n===1||n===1.2||n===1.3,"Unsupported GDEF table version.");var a={version:n,classDef:r.parsePointer(g.classDef),attachList:r.parsePointer(Xu),ligCaretList:r.parsePointer(ju),markAttachClassDef:r.parsePointer(g.classDef)};return n>=1.2&&(a.markGlyphSets=r.parsePointer(Ku)),a}var $u={parse:Qu},he=new Array(10);he[1]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();if(r===1)return{posFormat:1,coverage:this.parsePointer(g.coverage),value:this.parseValueRecord()};if(r===2)return{posFormat:2,coverage:this.parsePointer(g.coverage),values:this.parseValueRecordList()};L.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},he[2]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();L.assert(r===1||r===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var n=this.parsePointer(g.coverage),a=this.parseUShort(),s=this.parseUShort();if(r===1)return{posFormat:r,coverage:n,valueFormat1:a,valueFormat2:s,pairSets:this.parseList(g.pointer(g.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(a),value2:this.parseValueRecord(s)}})))};if(r===2){var i=this.parsePointer(g.classDef),o=this.parsePointer(g.classDef),u=this.parseUShort(),l=this.parseUShort();return{posFormat:r,coverage:n,valueFormat1:a,valueFormat2:s,classDef1:i,classDef2:o,class1Count:u,class2Count:l,classRecords:this.parseList(u,g.list(l,function(){return{value1:this.parseValueRecord(a),value2:this.parseValueRecord(s)}}))}}},he[3]=function(){return{error:"GPOS Lookup 3 not supported"}},he[4]=function(){return{error:"GPOS Lookup 4 not supported"}},he[5]=function(){return{error:"GPOS Lookup 5 not supported"}},he[6]=function(){return{error:"GPOS Lookup 6 not supported"}},he[7]=function(){return{error:"GPOS Lookup 7 not supported"}},he[8]=function(){return{error:"GPOS Lookup 8 not supported"}},he[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Ju(t,e){e=e||0;var r=new g(t,e),n=r.parseVersion(1);return L.argument(n===1||n===1.1,"Unsupported GPOS table version "+n),n===1?{version:n,scripts:r.parseScriptList(),features:r.parseFeatureList(),lookups:r.parseLookupList(he)}:{version:n,scripts:r.parseScriptList(),features:r.parseFeatureList(),lookups:r.parseLookupList(he),variations:r.parseFeatureVariationsList()}}var el=new Array(10);function tl(t){return new T.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new T.ScriptList(t.scripts)},{name:"features",type:"TABLE",value:new T.FeatureList(t.features)},{name:"lookups",type:"TABLE",value:new T.LookupList(t.lookups,el)}])}var rl={parse:Ju,make:tl};function nl(t){var e={};t.skip("uShort");var r=t.parseUShort();L.argument(r===0,"Unsupported kern sub-table version."),t.skip("uShort",2);var n=t.parseUShort();t.skip("uShort",3);for(var a=0;a<n;a+=1){var s=t.parseUShort(),i=t.parseUShort(),o=t.parseShort();e[s+","+i]=o}return e}function al(t){var e={};t.skip("uShort");var r=t.parseULong();r>1&&console.warn("Only the first kern subtable is supported."),t.skip("uLong");var n=t.parseUShort(),a=n&255;if(t.skip("uShort"),a===0){var s=t.parseUShort();t.skip("uShort",3);for(var i=0;i<s;i+=1){var o=t.parseUShort(),u=t.parseUShort(),l=t.parseShort();e[o+","+u]=l}}return e}function sl(t,e){var r=new O.Parser(t,e),n=r.parseUShort();if(n===0)return nl(r);if(n===1)return al(r);throw new Error("Unsupported kern table version ("+n+").")}var il={parse:sl};function ol(t,e,r,n){for(var a=new O.Parser(t,e),s=n?a.parseUShort:a.parseULong,i=[],o=0;o<r+1;o+=1){var u=s.call(a);n&&(u*=2),i.push(u)}return i}var ul={parse:ol};function fa(t,e){for(var r=[],n=12,a=0;a<e;a+=1){var s=O.getTag(t,n),i=O.getULong(t,n+4),o=O.getULong(t,n+8),u=O.getULong(t,n+12);r.push({tag:s,checksum:i,offset:o,length:u,compression:!1}),n+=16}return r}function ll(t,e){for(var r=[],n=44,a=0;a<e;a+=1){var s=O.getTag(t,n),i=O.getULong(t,n+4),o=O.getULong(t,n+8),u=O.getULong(t,n+12),l=void 0;o<u?l="WOFF":l=!1,r.push({tag:s,offset:i,compression:l,compressedLength:o,length:u}),n+=20}return r}function _(t,e){if(e.compression==="WOFF"){var r=new Uint8Array(t.buffer,e.offset+2,e.compressedLength-2),n=new Uint8Array(e.length);if(ts(r,n),n.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");var a=new DataView(n.buffer,0);return{data:a,offset:0}}else return{data:t,offset:e.offset}}function cl(t,e){e=e??{};var r,n,a=new P({empty:!0}),s=new DataView(t,0),i,o=[],u=O.getTag(s,0);if(u==="\0\0\0"||u==="true"||u==="typ1")a.outlinesFormat="truetype",i=O.getUShort(s,4),o=fa(s,i);else if(u==="OTTO")a.outlinesFormat="cff",i=O.getUShort(s,4),o=fa(s,i);else if(u==="wOFF"){var l=O.getTag(s,4);if(l==="\0\0\0")a.outlinesFormat="truetype";else if(l==="OTTO")a.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+u);i=O.getUShort(s,12),o=ll(s,i)}else throw new Error("Unsupported OpenType signature "+u);for(var c,f,h,p,d,m,b,y,S,x,C,k,A=0;A<i;A+=1){var U=o[A],E=void 0;switch(U.tag){case"cmap":E=_(s,U),a.tables.cmap=Qr.parse(E.data,E.offset),a.encoding=new Jr(a.tables.cmap);break;case"cvt ":E=_(s,U),k=new O.Parser(E.data,E.offset),a.tables.cvt=k.parseShortList(U.length/2);break;case"fvar":f=U;break;case"fpgm":E=_(s,U),k=new O.Parser(E.data,E.offset),a.tables.fpgm=k.parseByteList(U.length);break;case"head":E=_(s,U),a.tables.head=dn.parse(E.data,E.offset),a.unitsPerEm=a.tables.head.unitsPerEm,r=a.tables.head.indexToLocFormat;break;case"hhea":E=_(s,U),a.tables.hhea=gn.parse(E.data,E.offset),a.ascender=a.tables.hhea.ascender,a.descender=a.tables.hhea.descender,a.numberOfHMetrics=a.tables.hhea.numberOfHMetrics;break;case"hmtx":b=U;break;case"ltag":E=_(s,U),n=mn.parse(E.data,E.offset);break;case"maxp":E=_(s,U),a.tables.maxp=yn.parse(E.data,E.offset),a.numGlyphs=a.tables.maxp.numGlyphs;break;case"name":x=U;break;case"OS/2":E=_(s,U),a.tables.os2=jt.parse(E.data,E.offset);break;case"post":E=_(s,U),a.tables.post=Cn.parse(E.data,E.offset),a.glyphNames=new Wt(a.tables.post);break;case"prep":E=_(s,U),k=new O.Parser(E.data,E.offset),a.tables.prep=k.parseByteList(U.length);break;case"glyf":h=U;break;case"loca":S=U;break;case"CFF ":c=U;break;case"kern":y=U;break;case"GDEF":p=U;break;case"GPOS":d=U;break;case"GSUB":m=U;break;case"meta":C=U;break}}var B=_(s,x);if(a.tables.name=wn.parse(B.data,B.offset,n),a.names=a.tables.name,h&&S){var z=r===0,Q=_(s,S),J=ul.parse(Q.data,Q.offset,a.numGlyphs,z),Z=_(s,h);a.glyphs=Nn.parse(Z.data,Z.offset,J,a,e)}else if(c){var D=_(s,c);pn.parse(D.data,D.offset,a,e)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");var W=_(s,b);if(vn.parse(a,W.data,W.offset,a.numberOfHMetrics,a.numGlyphs,a.glyphs,e),ks(a,e),y){var N=_(s,y);a.kerningPairs=il.parse(N.data,N.offset)}else a.kerningPairs={};if(p){var q=_(s,p);a.tables.gdef=$u.parse(q.data,q.offset)}if(d){var j=_(s,d);a.tables.gpos=rl.parse(j.data,j.offset),a.position.init()}if(m){var Y=_(s,m);a.tables.gsub=En.parse(Y.data,Y.offset)}if(f){var $=_(s,f);a.tables.fvar=qu.parse($.data,$.offset,a.names)}if(C){var I=_(s,C);a.tables.meta=On.parse(I.data,I.offset),a.metas=a.tables.meta}return a}function hl(t){return((r,n)=>{const a=Math.round,s={},i=r.encoding.cmap.glyphIndexMap,o=Object.keys(i),u=r.glyphs.glyphs[i[65]];let l=1;u&&(l=r.unitsPerEm/u.yMax);for(let c=0;c<o.length;c++){const f=o[c],h=r.glyphs.glyphs[i[f]];if(f!==void 0){const p={ha:a(h.advanceWidth),x_min:a(h.xMin),x_max:a(h.xMax),o:""};h.path.commands.forEach(function(d){d.type.toLowerCase()==="c"&&(d.type="b"),p.o+=d.type.toLowerCase()+" ",d.x!==void 0&&d.y!==void 0&&(p.o+=a(d.x)+" "+a(d.y)+" "),d.x1!==void 0&&d.y1!==void 0&&(p.o+=a(d.x1)+" "+a(d.y1)+" "),d.x2!==void 0&&d.y2!==void 0&&(p.o+=a(d.x2)+" "+a(d.y2)+" ")}),s[String.fromCodePoint(h.unicode)]=p}}return{glyphs:s,familyName:r.getEnglishName("fullName"),ascender:a(r.ascender),descender:a(r.descender),underlinePosition:r.tables.post.underlinePosition,underlineThickness:r.tables.post.underlineThickness,boundingBox:{xMin:r.tables.head.xMin,xMax:r.tables.head.xMax,yMin:r.tables.head.yMin,yMax:r.tables.head.yMax},resolution:r.unitsPerEm||1e3,scaleFactor:l,original_font_information:r.tables.name}})(cl(t))}class pa extends Ft{constructor(e){super(),this.type="mesh",e instanceof ArrayBuffer?this.data=hl(e):this.data=e,this.font=new Wa(this.data)}hasChar(e){return this.data.glyphs[e]!=null}generateShapes(e,r){return this.font.generateShapes(e,r)}getCharShape(e,r){if(!this.data.glyphs[e]){this.addUnsupportedChar(e);return}return new Pr(e,r,this)}getScaleFactor(){return this.scaleFactor==null?(this.scaleFactor=this.data.scaleFactor,this.scaleFactor):this.scaleFactor}getNotFoundTextShape(e){return new Pr("?",e,this)}}class re{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 r=new Uint8Array(this.data.buffer,this.position,e);return this.position+=e,r}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 r=this.data.getUint16(this.position,e);return this.position+=2,r}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 ne=(t=>(t.SHAPES="shapes",t.BIGFONT="bigfont",t.UNIFONT="unifont",t))(ne||{});let fl=class{parse(e){const r=this.parseHeader(e).split(" "),n=r[1].toLocaleLowerCase();if(!Object.values(ne).includes(n))throw new Error(`Invalid font type: ${n}`);return{fileHeader:r[0],fontType:n,fileVersion:r[2]}}parseHeader(e){let r="",n=0;for(;e.currentPosition<e.length-2&&n<1024;){const a=e.readUint8();if(a===13){const s=e.currentPosition,i=e.readUint8(),o=e.readUint8();if(i===10&&o===26)break;e.setPosition(s),r+=String.fromCharCode(a)}else r+=String.fromCharCode(a);n++}return r.trim()}};class pl{parse(e){try{e.readBytes(4);const r=e.readInt16();if(r<=0)throw new Error("Invalid shape count in font file");const n=[];for(let i=0;i<r;i++){const o=e.readUint16(),u=e.readUint16();u>0&&n.push({code:o,length:u})}const a={};for(const i of n)try{const o=e.readBytes(i.length);o.length===i.length&&(a[i.code]=o)}catch{console.warn(`Failed to read shape data for code ${i.code}`)}const s={data:a,info:"",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1};if(0 in a){const i=a[0];try{const o=new TextDecoder().decode(i);let u=o.indexOf("\0");u>=0&&(s.info=o.substring(0,u),u+3<i.length&&(s.baseUp=i[u+1],s.baseDown=i[u+2],s.orientation=i[u+3]===0?"horizontal":"vertical"))}catch{console.warn("Failed to parse font info block")}}return s}catch(r){return console.error("Error parsing shape font:",r),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1}}}}class dl{parse(e){try{e.readInt16();const r=e.readInt16(),n=e.readInt16();if(r<=0)throw new Error("Invalid character count in font file");e.skip(n*4);const a=[];for(let o=0;o<r;o++){const u=e.readUint16(!1),l=e.readUint16(),c=e.readUint32();(u!==0||l!==0||c!==0)&&a.push({code:u,length:l,offset:c})}const s={};for(const o of a)try{e.setPosition(o.offset);const u=e.readBytes(o.length);u.length===o.length&&(s[o.code]=u)}catch{console.warn(`Failed to read bigfont data for code ${o.code}`)}const i={data:s,info:"",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1};if(0 in s){const o=s[0];try{const u=this.utf8ArrayToStr(o);let l=u.indexOf("\0");l>=0&&(i.info=u.substring(0,l),l++,l+3<o.length&&(o.length-l===4?(i.baseUp=o[l++],i.baseDown=o[l++],i.orientation=o[l++]===0?"horizontal":"vertical"):(i.baseUp=o[l++],l++,i.orientation=o[l++]===0?"horizontal":"vertical",i.baseDown=o[l++],i.isExtended=!0)))}catch{console.warn("Failed to parse bigfont info block")}}return i}catch(r){return console.error("Error parsing big font:",r),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1}}}utf8ArrayToStr(e){let r="",n=0;for(;n<e.length;){const a=e[n++];switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:r+=String.fromCharCode(a);break;case 12:case 13:{const s=e[n++];r+=String.fromCharCode((a&31)<<6|s&63);break}case 14:{const s=e[n++],i=e[n++];r+=String.fromCharCode((a&15)<<12|(s&63)<<6|(i&63)<<0);break}}}return r}}class gl{parse(e){try{const r=e.readInt32();if(r<=0)throw new Error("Invalid character count in font file");const n=e.readInt16(),a=e.readBytes(n),s={data:{},info:"",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1};try{const o=new TextDecoder().decode(a);let u=o.indexOf("\0");u>=0&&(s.info=o.substring(0,u),u+3<a.length&&(s.baseUp=a[u+1],s.baseDown=a[u+2],s.orientation=a[u+3]===0?"horizontal":"vertical"))}catch{console.warn("Failed to parse unifont info block")}const i={};for(let o=0;o<r-1;o++)try{const u=e.readUint16(),l=e.readUint16();if(l>0){const c=e.readBytes(l);c.length===l&&(i[u]=c)}}catch{console.warn("Failed to read unifont character data");break}return s.data=i,s}catch(r){return console.error("Error parsing unifont:",r),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1}}}}class vl{static createParser(e){switch(e){case ne.SHAPES:return new pl;case ne.BIGFONT:return new dl;case ne.UNIFONT:return new gl;default:throw new Error(`Unsupported font type: ${e}`)}}}class H{constructor(e=0,r=0){this.x=e,this.y=r}set(e,r){return this.x=e,this.y=r,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 H(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,r){return this.x*=e,this.y*=r,this}divideScalars(e,r){return e!==0&&(this.x/=e),r!==0&&(this.y/=r),this}distanceTo(e){const r=this.x-e.x,n=this.y-e.y;return Math.sqrt(r*r+n*n)}}const da=Math.PI/4;class tt{static fromBulge(e,r,n){const a=Math.max(-1,Math.min(1,n));return new tt({start:e,end:r,bulge:a})}static fromOctant(e,r,n,a,s){return new tt({center:e,radius:r,startOctant:n,octantCount:a,isClockwise:s})}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 r=this.end.clone().subtract(this.start),n=r.length();if(Math.abs(this.bulge)*n/2===0){this.radius=0,this.center=this.start.clone(),this.startAngle=Math.atan2(r.y,r.x),this.endAngle=this.startAngle;return}const a=4*Math.atan(Math.abs(this.bulge));this.radius=n/(2*Math.sin(a/2));const s=this.start.clone().add(r.clone().divide(2)),i=new H(-r.y,r.x);i.normalize(),i.multiply(Math.abs(this.radius*Math.cos(a/2))),this.center=s.clone(),this.isClockwise?this.center.subtract(i):this.center.add(i),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*da;const r=(e.octantCount===0?8:e.octantCount)*da;this.endAngle=this.startAngle+(this.isClockwise?-r:r),this.start=this.center.clone().add(new H(this.radius*Math.cos(this.startAngle),this.radius*Math.sin(this.startAngle))),this.end=this.center.clone().add(new H(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 r=[this.start.clone()],n=Math.abs(this.endAngle-this.startAngle),a=Math.max(1,Math.floor(n/e));for(let s=1;s<a;s++){const i=s/a,o=this.isClockwise?this.startAngle-i*n:this.startAngle+i*n;r.push(this.center.clone().add(new H(this.radius*Math.cos(o),this.radius*Math.sin(o))))}return r.push(this.end?this.end.clone():this.center.clone().add(new H(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))),r}}let lr=class wa{constructor(e,r=[]){this.lastPoint=e,this.polylines=r}get bbox(){let e=1/0,r=-1/0,n=1/0,a=-1/0;return this.polylines.forEach(s=>{s.forEach(i=>{e=Math.min(e,i.x),r=Math.max(r,i.x),n=Math.min(n,i.y),a=Math.max(a,i.y)})}),{minX:e,minY:n,maxX:r,maxY:a}}offset(e,r=!0){var n,a;return r?new wa((n=this.lastPoint)==null?void 0:n.clone().add(e),this.polylines.map(s=>s.map(i=>i.clone().add(e)))):((a=this.lastPoint)==null||a.add(e),this.polylines.forEach(s=>s.forEach(i=>i.add(e))),this)}toSVG(e={}){const{strokeWidth:r="0.5%",strokeColor:n="black",isAutoFit:a=!1}=e;let s,i;if(a){const o=this.bbox,u=.2,l=o.maxX-o.minX,c=o.maxY-o.minY,f=o.minX-l*u,h=o.maxX+l*u,p=o.minY-c*u,d=o.maxY+c*u;i=this.polylines.map(m=>{let b="";return m.forEach((y,S)=>{const x=y.x,C=-y.y;b+=S===0?`M ${x} ${C} `:`L ${x} ${C} `}),`<path d="${b}" stroke="${n}" stroke-width="${r}" fill="none"/>`}).join(""),s=`${f} ${-d} ${h-f} ${d-p}`}else s="0 0 20 20",i=this.polylines.map(o=>{let u="";return o.forEach((l,c)=>{const f=l.x+5,h=-l.y+15;u+=c===0?`M ${f} ${h} `:`L ${f} ${h} `}),`<path d="${u}" stroke="${n}" stroke-width="${r}" fill="none"/>`}).join("");return`<svg width="100%" height="100%" viewBox="${s}" preserveAspectRatio="xMidYMid meet">${i}</svg>`}};const ml=Math.PI/18,ga=12;let yl=class{constructor(e){this.shapeCache=new Map,this.shapeData=new Map,this.fontData=e}release(){this.shapeCache.clear(),this.shapeData.clear()}parse(e,r){var n;const a=`${e}_${r}`;if(this.shapeCache.has(a))return this.shapeCache.get(a);if(e===0)return;const s=this.fontData.content.data;let i;if(!this.shapeData.has(e)&&s[e]){const o=s[e],u=ga/this.fontData.content.baseUp;i=this.parseShape(o,u),this.shapeData.set(e,i)}if(this.shapeData.has(e)){const o=r/ga,u=this.shapeData.get(e);i=new lr((n=u.lastPoint)==null?void 0:n.clone().multiply(o),u.polylines.map(l=>l.map(c=>c.clone().multiply(o))))}return i}parseShape(e,r){const n={currentPoint:new H,polylines:[],currentPolyline:[],sp:[],isPenDown:!1,scale:r};for(let a=0;a<e.length;a++){const s=e[a];s<=15?a=this.handleSpecialCommand(s,e,a,n):this.handleVectorCommand(s,n)}return new lr(n.currentPoint,n.polylines)}handleSpecialCommand(e,r,n,a){let s=n;switch(e){case 0:a.currentPolyline=[],a.isPenDown=!1;break;case 1:a.isPenDown=!0,a.currentPolyline.push(a.currentPoint.clone());break;case 2:a.isPenDown=!1,a.currentPolyline.length>1&&a.polylines.push(a.currentPolyline.slice()),a.currentPolyline=[];break;case 3:s++,a.scale/=r[s];break;case 4:s++,a.scale*=r[s];break;case 5:if(a.sp.length===4)throw new Error("The position stack is only four locations deep");a.sp.push(a.currentPoint.clone());break;case 6:a.currentPoint=a.sp.pop()??a.currentPoint;break;case 7:s=this.handleSubshapeCommand(r,s,a);break;case 8:s=this.handleXYDisplacement(r,s,a);break;case 9:s=this.handleMultipleXYDisplacements(r,s,a);break;case 10:s=this.handleOctantArc(r,s,a);break;case 11:s=this.handleFractionalArc(r,s,a);break;case 12:s=this.handleBulgeArc(r,s,a);break;case 13:s=this.handleMultipleBulgeArcs(r,s,a);break;case 14:s=this.skipCode(r,++s);break}return s}handleVectorCommand(e,r){const n=(e&240)>>4,a=e&15,s=this.getVectorForDirection(a);r.currentPoint.add(s.multiply(n*r.scale)),r.isPenDown&&r.currentPolyline.push(r.currentPoint.clone())}getVectorForDirection(e){const r=new H;switch(e){case 0:r.x=1;break;case 1:r.x=1,r.y=.5;break;case 2:r.x=1,r.y=1;break;case 3:r.x=.5,r.y=1;break;case 4:r.y=1;break;case 5:r.x=-.5,r.y=1;break;case 6:r.x=-1,r.y=1;break;case 7:r.x=-1,r.y=.5;break;case 8:r.x=-1;break;case 9:r.x=-1,r.y=-.5;break;case 10:r.x=-1,r.y=-1;break;case 11:r.x=-.5,r.y=-1;break;case 12:r.y=-1;break;case 13:r.x=.5,r.y=-1;break;case 14:r.x=1,r.y=-1;break;case 15:r.x=1,r.y=-.5;break}return r}handleSubshapeCommand(e,r,n){let a=r,s=0,i,o=n.scale*this.fontData.content.baseUp,u=o;const l=n.currentPoint.clone();switch(n.currentPolyline.length>1&&(n.polylines.push(n.currentPolyline.slice()),n.currentPolyline=[]),this.fontData.header.fontType){case ne.SHAPES:a++,s=e[a];break;case ne.BIGFONT:a++,s=e[a],s===0&&(a++,s=e[a++]|e[a++]<<8,l.x=e[a++]*n.scale,l.y=e[a++]*n.scale,this.fontData.content.isExtended&&(u=e[a++]*n.scale),o=e[a]*n.scale);break;case ne.UNIFONT:a++,s=e[a++]|e[a++]<<8;break}return s!==0&&(i=this.getShapeByCodeWithOffset(s,u,o,l),i&&(n.polylines.push(...i.polylines.slice()),n.currentPoint=i.lastPoint?i.lastPoint.clone():l.clone())),n.currentPolyline=[],a}handleXYDisplacement(e,r,n){let a=r;const s=new H;return s.x=re.byteToSByte(e[++a]),s.y=re.byteToSByte(e[++a]),n.currentPoint.add(s.multiply(n.scale)),n.isPenDown&&n.currentPolyline.push(n.currentPoint.clone()),a}handleMultipleXYDisplacements(e,r,n){let a=r;for(;;){const s=new H;if(s.x=re.byteToSByte(e[++a]),s.y=re.byteToSByte(e[++a]),s.x===0&&s.y===0)break;n.currentPoint.add(s.multiply(n.scale)),n.isPenDown&&n.currentPolyline.push(n.currentPoint.clone())}return a}handleOctantArc(e,r,n){var a;let s=r;const i=e[++s]*n.scale,o=re.byteToSByte(e[++s]),u=(o&112)>>4;let l=o&7;const c=o<0,f=Math.PI/4*u,h=n.currentPoint.clone().subtract(new H(Math.cos(f)*i,Math.sin(f)*i)),p=tt.fromOctant(h,i,u,l,c);if(n.isPenDown){const d=p.tessellate();n.currentPolyline.pop(),n.currentPolyline.push(...d.slice())}return n.currentPoint=(a=p.tessellate().pop())==null?void 0:a.clone(),s}handleFractionalArc(e,r,n){let a=r;const s=e[++a],i=e[++a],o=e[++a],u=e[++a],l=(o*255+u)*n.scale,c=re.byteToSByte(e[++a]),f=(c&112)>>4;let h=c&7;h===0&&(h=8),i!==0&&h--;const p=Math.PI/4;let d=p*h,m=ml,b=1;c<0&&(m=-m,d=-d,b=-1);let y=p*f,S=y+d;y+=p*s/256*b,S+=p*i/256*b;const x=n.currentPoint.clone().subtract(new H(l*Math.cos(y),l*Math.sin(y)));if(n.currentPoint=x.clone().add(new H(l*Math.cos(S),l*Math.sin(S))),n.isPenDown){let C=y;const k=[];if(k.push(x.clone().add(new H(l*Math.cos(C),l*Math.sin(C)))),m>0)for(;C+m<S;)C+=m,k.push(x.clone().add(new H(l*Math.cos(C),l*Math.sin(C))));else for(;C+m>S;)C+=m,k.push(x.clone().add(new H(l*Math.cos(C),l*Math.sin(C))));k.push(x.clone().add(new H(l*Math.cos(S),l*Math.sin(S)))),n.currentPolyline.push(...k)}return a}handleBulgeArc(e,r,n){let a=r;const s=new H;s.x=re.byteToSByte(e[++a]),s.y=re.byteToSByte(e[++a]);const i=re.byteToSByte(e[++a]);return n.currentPoint=this.handleArcSegment(n.currentPoint,s,i,n.scale,n.isPenDown,n.currentPolyline),a}handleMultipleBulgeArcs(e,r,n){let a=r;for(;;){const s=new H;if(s.x=re.byteToSByte(e[++a]),s.y=re.byteToSByte(e[++a]),s.x===0&&s.y===0)break;const i=re.byteToSByte(e[++a]);n.currentPoint=this.handleArcSegment(n.currentPoint,s,i,n.scale,n.isPenDown,n.currentPolyline)}return a}skipCode(e,r){switch(e[r]){case 0:break;case 1:break;case 2:break;case 3:case 4:r++;break;case 5:break;case 6:break;case 7:switch(this.fontData.header.fontType){case ne.SHAPES:r++;break;case ne.BIGFONT:r++,e[r]===0&&(r+=5);break;case ne.UNIFONT:r+=2;break}break;case 8:r+=2;break;case 9:for(;;){const n=e[++r],a=e[++r];if(n===0&&a===0)break}break;case 10:r+=2;break;case 11:r+=5;break;case 12:r+=3;break;case 13:for(;;){const n=e[++r],a=e[++r];if(n===0&&a===0)break;r++}break}return r}getShapeByCodeWithOffset(e,r,n,a){var s;const i=this.parse(e,n);if(i){if(r===n)return i.offset(a);{const o=(s=i.lastPoint)==null?void 0:s.clone();o&&(o.x*=r/n);const u=i.polylines.map(l=>l.map(c=>c.clone()));return u.forEach(l=>l.forEach(c=>c.x*=r/n)),new lr(o==null?void 0:o.add(a),u.map(l=>l.map(c=>c.add(a))))}}}handleArcSegment(e,r,n,a,s,i){r.x*=a,r.y*=a,n<-127&&(n=-127);const o=e.clone();if(s)if(n===0)i.push(o.clone().add(r));else{const u=o.clone().add(r),l=tt.fromBulge(o,u,n/127).tessellate();i.push(...l.slice(1))}return o.add(r),o}};class bl{constructor(e){if(e instanceof ArrayBuffer){const r=new re(e),n=new fl().parse(r),a=vl.createParser(n.fontType).parse(r);this.fontData={header:n,content:a}}else this.fontData=e;this.shapeParser=new yl(this.fontData)}hasChar(e){return this.fontData.content.data[e]!==void 0}getCharShape(e,r){return this.shapeParser.parse(e,r)}release(){this.shapeParser.release()}}class cr extends Tt{constructor(e,r,n,a){super(e),this.fontSize=r,this.shape=n,this.font=a,this.width=this.calcWidth()}calcWidth(){const e=this.shape.bbox;return e.maxX-e.minX}offset(e){return new cr(this.char,this.fontSize,this.shape.offset(e),this.font)}toGeometry(){let e=this.font.cache.getGeometry(this.char,this.fontSize);if(e==null){const r=this.shape.polylines,n=[],a=[];let s=0;e=new R.BufferGeometry;for(let i=0;i<r.length;i++){const o=r[i];for(let u=0;u<o.length;u++){const l=o[u];n.push(l.x,l.y,0),u===o.length-1||a.push(s,s+1),s++}}e.setAttribute("position",new R.Float32BufferAttribute(n,3)),e.setIndex(a)}return e}}class va extends Ft{constructor(e){super(),this.type="shx",this.font=new bl(e),this.data=this.font.fontData}hasChar(e){const r=e.charCodeAt(0);return this.font.hasChar(r)}generateShapes(e,r){const n=[];let a=0;for(let s=0;s<e.length;s++){const i=e[s];if(i===" "){a+=r;continue}const o=this.getCharShape(i,r);if(!o){a+=r,this.addUnsupportedChar(i);continue}n.push(o.offset(new H(a,0))),a+=o.width}return n}getScaleFactor(){return 1}getCharShape(e,r){let n=this.getCode(e);const a=this.font.getCharShape(n,r);return a?new cr(e,r,a,this):void 0}getNotFoundTextShape(e){let r=this.font.fontData.header.fontType===ne.BIGFONT?"?":"?";return this.getCharShape(r,e)}getCode(e){if(this.font.fontData.header.fontType===ne.BIGFONT)throw new Error(`Can't get font glyph for '${e}' because big font is not supported yet!`);return e.charCodeAt(0)}}class be{constructor(){}static get instance(){return be._instance||(be._instance=new be),be._instance}createFont(e){if(e.type==="shx")return new va(e.data);if(e.type==="mesh")return new pa(e.data);throw new Error("Unsupported font data type")}createFontFromBuffer(e,r){const n=_a(e).toLowerCase();if(n==="shx")return new va(r);if(["ttf","otf","woff"].includes(n))return new pa(r);throw new Error(`Unsupported font file type: ${n}`)}}class xe{constructor(){this.fontMapping={},this.fontMap=new Map,this.unsupportedChars={},this.missedFonts={},this.enableFontCache=!0,this.defaultFont="simsun",this.events={fontNotFound:new kt,fontLoaded:new kt},this.loader=new R.FileLoader,this.loader.setResponseType("arraybuffer"),this.fileNames=[]}static get instance(){return xe._instance||(xe._instance=new xe),xe._instance}setFontMapping(e){this.fontMapping=e}async loadFonts(e){e=Array.isArray(e)?e:[e];const r=[];for(let a=0;a<e.length;a++){const s=e[a];r.push(this.loadFont(s))}const n=[];return await Promise.allSettled(r).then(a=>{a.forEach((s,i)=>{const o=s.status==="fulfilled",u=e[i],l=Rr(u.toLowerCase());n.push({fontName:l,url:u,status:o}),o&&this.fileNames.push(l)})}),n}findAndReplaceFont(e){let r=this.fontMap.get(e.toLowerCase());if(r==null){const n=this.fontMapping[e];if(n)return r=this.fontMap.get(n.toLowerCase()),n}return r?e:this.defaultFont}getFontByName(e,r=!0){if(this.fontMap.size===0)return;e==null&&(e="");let n=this.fontMap.get(e.toLowerCase());if(!n){r&&this.recordMissedFonts(e);return}return n}getFontByChar(e){for(const[,r]of this.fontMap)if(r.hasChar(e))return r}getCharShape(e,r,n){let a=this.getFontByName(r);return a||(a=this.getFontByChar(e)),a==null?void 0:a.getCharShape(e,n)}getFontScaleFactor(e){const r=this.fontMap.get(e.toLowerCase());return r?r.getScaleFactor():1}getFontType(e){const r=this.fontMap.get(e.toLowerCase());return r==null?void 0:r.type}getNotFoundTextShape(e){for(const[,r]of this.fontMap){const n=r.getNotFoundTextShape(e);if(n)return n}}isFontLoaded(e){return this.fontMap.has(e.toLowerCase())}recordMissedFonts(e){e&&(this.missedFonts[e]||(this.missedFonts[e]=0),this.missedFonts[e]++,this.events.fontNotFound.dispatch({fontName:e,count:this.missedFonts[e]}))}async loadFont(e){const r=Lr(e);if(!r)throw new Error(`Invalid font url: ${e}`);const n=Rr(e).toLowerCase(),a=await We.instance.get(n);if(a){const s=be.instance.createFont(a);this.fontMap.set(n,s)}else{const s=await this.loader.loadAsync(e),i=be.instance.createFontFromBuffer(r,s);i&&(this.fontMap.set(n,i),this.enableFontCache&&await We.instance.set(n,{name:n,type:i.type,data:i.data}))}this.events.fontLoaded.dispatch({fontName:n})}async getAllFontsFromCache(){if(this.fontMap.size!==0)return;const e=await We.instance.getAll();for(const r of e){const{name:n}=r;if(this.fileNames&&!this.fileNames.includes(n))continue;const a=be.instance.createFont(r);this.fontMap.set(n,a)}}getUnsupportedChar(){for(const[,e]of this.fontMap)Object.assign(this.unsupportedChars,e.unsupportedChars);return this.unsupportedChars}release(e){return e==null?(this.fontMap.clear(),!0):this.fontMap.delete(e)}}class ma{constructor(){this._avaiableFonts=[]}get avaiableFonts(){return this._avaiableFonts}async getAvaiableFonts(){if(this._avaiableFonts.length==0){const e="https://cdn.jsdelivr.net/gh/mlight-lee/cad-data/fonts/",r=e+"fonts.json";try{const n=await fetch(r);this._avaiableFonts=await n.json()}catch{throw new Error(`Filed to get avaiable font from '${r}'`)}this._avaiableFonts.forEach(n=>{n.url=e+n.file})}return this._avaiableFonts}async load(e){if(e.length==0)return await this.getAvaiableFonts(),[];const r=[],n=[],a={};this._avaiableFonts.forEach(o=>{o.name.forEach(u=>{a[u.toLowerCase()]=o.url})}),e.forEach(o=>{const u=o.toLowerCase(),l=a[u];l&&(xe.instance.isFontLoaded(u)?n.push({fontName:u,url:l,status:!0}):r.push(l))});let s=[];r.length>0&&(s=await xe.instance.loadFonts(r));const i={};return[...n,...s].forEach(o=>{i[o.fontName]=o}),e.map(o=>{const u=o.toLowerCase();return i[u]||{fontName:u,url:a[u]||"",status:!1}})}}var He=(t=>(t[t.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",t[t.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",t[t.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",t[t.BY_STYLE=5]="BY_STYLE",t))(He||{}),ya=(t=>(t[t.TopLeft=1]="TopLeft",t[t.TopCenter=2]="TopCenter",t[t.TopRight=3]="TopRight",t[t.MiddleLeft=4]="MiddleLeft",t[t.MiddleCenter=5]="MiddleCenter",t[t.MiddleRight=6]="MiddleRight",t[t.BottomLeft=7]="BottomLeft",t[t.BottomCenter=8]="BottomCenter",t[t.BottomRight=9]="BottomRight",t))(ya||{}),ze=(t=>(t[t.NONE=0]="NONE",t[t.WORD=1]="WORD",t[t.STACK=2]="STACK",t[t.SPACE=3]="SPACE",t[t.NBSP=4]="NBSP",t[t.TABULATOR=5]="TABULATOR",t[t.NEW_PARAGRAPH=6]="NEW_PARAGRAPH",t[t.NEW_COLUMN=7]="NEW_COLUMN",t[t.WRAP_AT_DIMLINE=8]="WRAP_AT_DIMLINE",t[t.PROPERTIES_CHANGED=9]="PROPERTIES_CHANGED",t))(ze||{}),rt=(t=>(t[t.BOTTOM=0]="BOTTOM",t[t.MIDDLE=1]="MIDDLE",t[t.TOP=2]="TOP",t))(rt||{}),fe=(t=>(t[t.DEFAULT=0]="DEFAULT",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.CENTER=3]="CENTER",t[t.JUSTIFIED=4]="JUSTIFIED",t[t.DISTRIBUTED=5]="DISTRIBUTED",t))(fe||{});const xl={c:"Ø",d:"°",p:"±"},Sl={l:1,r:2,c:3,j:4,d:5};function kl(t,e=!1){const r=new Set,n=/\\[fF](.*?)[;|]/g;return[...t.matchAll(n)].forEach(a=>{let s=a[1].toLowerCase();e&&(s=s.replace(/\.(ttf|otf|woff|shx)$/,"")),r.add(s)}),r}class Fl{constructor(e){this.stack=[],this.stack.push(e)}push(e){this.stack.push(e)}pop(){if(this.stack.length<=1)return;const e=this.stack.pop(),r=this.stack[this.stack.length-1];return JSON.stringify(r.paragraph)!==JSON.stringify(e.paragraph)&&(r.paragraph={...e.paragraph}),e}get current(){return this.stack[this.stack.length-1]}get depth(){return this.stack.length-1}get root(){return this.stack[0]}setCurrent(e){this.stack[this.stack.length-1]=e}}class Tl{constructor(e,r,n={}){this.continueStroke=!1,this.inStackContext=!1,this.scanner=new hr(e);const a=r??new nt;this.ctxStack=new Fl(a),this.yieldPropertyCommands=n.yieldPropertyCommands??!1,this.resetParagraphParameters=n.resetParagraphParameters??!1}decodeMultiByteChar(e){try{const r=new Uint8Array([parseInt(e.substr(0,2),16),parseInt(e.substr(2,2),16)]),n=new TextDecoder("gbk").decode(r);if(n!=="▯")return n;const a=new TextDecoder("big5").decode(r);return a!=="▯"?a:"▯"}catch{return"▯"}}pushCtx(){this.ctxStack.push(this.ctxStack.current)}popCtx(){this.ctxStack.pop()}parseStacking(){const e=new hr(this.extractExpression(!0));let r="",n="",a="";const s=()=>{let u=e.peek(),l=!1;return u.charCodeAt(0)<32&&(u=" "),u==="\\"&&(l=!0,e.consume(1),u=e.peek()),e.consume(1),[u,l]},i=()=>{let u="";for(;e.hasData;){const[l,c]=s();if(!c&&(l==="/"||l==="#"||l==="^"))return[u,l];u+=l}return[u,""]},o=u=>{let l="",c=u;for(;e.hasData;){const[f,h]=s();if(!(c&&f===" ")){if(c=!1,!h&&f===";")break;l+=f}}return l};return[r,a]=i(),a&&(n=o(a==="^")),r===""&&n.includes("I/")?[2,[" "," ","/"]]:a==="^"?[2,[r,n,"^"]]:[2,[r,n,a]]}parseProperties(e){const r=this.ctxStack.current.copy(),n=this.ctxStack.current.copy();switch(e){case"L":n.underline=!0,this.continueStroke=!0;break;case"l":n.underline=!1,n.hasAnyStroke||(this.continueStroke=!1);break;case"O":n.overline=!0,this.continueStroke=!0;break;case"o":n.overline=!1,n.hasAnyStroke||(this.continueStroke=!1);break;case"K":n.strikeThrough=!0,this.continueStroke=!0;break;case"k":n.strikeThrough=!1,n.hasAnyStroke||(this.continueStroke=!1);break;case"A":this.parseAlign(n);break;case"C":this.parseAciColor(n);break;case"c":this.parseRgbColor(n);break;case"H":this.parseHeight(n);break;case"W":this.parseWidth(n);break;case"Q":this.parseOblique(n);break;case"T":this.parseCharTracking(n);break;case"p":this.parseParagraphProperties(n);break;case"f":case"F":this.parseFontProperties(n);break;default:throw new Error(`Unknown command: ${e}`)}if(this.continueStroke=n.hasAnyStroke,n.continueStroke=this.continueStroke,this.ctxStack.setCurrent(n),this.yieldPropertyCommands){const a=this.getPropertyChanges(r,n);if(Object.keys(a).length>0)return{command:e,changes:a,depth:this.ctxStack.depth}}}getPropertyChanges(e,r){const n={};if(e.underline!==r.underline&&(n.underline=r.underline),e.overline!==r.overline&&(n.overline=r.overline),e.strikeThrough!==r.strikeThrough&&(n.strikeThrough=r.strikeThrough),e.color.aci!==r.color.aci&&(n.aci=r.color.aci),e.color.rgbValue!==r.color.rgbValue&&(n.rgb=r.color.rgb),e.align!==r.align&&(n.align=r.align),JSON.stringify(e.fontFace)!==JSON.stringify(r.fontFace)&&(n.fontFace=r.fontFace),(e.capHeight.value!==r.capHeight.value||e.capHeight.isRelative!==r.capHeight.isRelative)&&(n.capHeight=r.capHeight),(e.widthFactor.value!==r.widthFactor.value||e.widthFactor.isRelative!==r.widthFactor.isRelative)&&(n.widthFactor=r.widthFactor),(e.charTrackingFactor.value!==r.charTrackingFactor.value||e.charTrackingFactor.isRelative!==r.charTrackingFactor.isRelative)&&(n.charTrackingFactor=r.charTrackingFactor),e.oblique!==r.oblique&&(n.oblique=r.oblique),JSON.stringify(e.paragraph)!==JSON.stringify(r.paragraph)){const a={};e.paragraph.indent!==r.paragraph.indent&&(a.indent=r.paragraph.indent),e.paragraph.align!==r.paragraph.align&&(a.align=r.paragraph.align),e.paragraph.left!==r.paragraph.left&&(a.left=r.paragraph.left),e.paragraph.right!==r.paragraph.right&&(a.right=r.paragraph.right),JSON.stringify(e.paragraph.tabs)!==JSON.stringify(r.paragraph.tabs)&&(a.tabs=r.paragraph.tabs),Object.keys(a).length>0&&(n.paragraph=a)}return n}parseAlign(e){const r=this.scanner.get();"012".includes(r)?e.align=parseInt(r):e.align=0,this.consumeOptionalTerminator()}parseHeight(e){const r=this.extractFloatExpression(!0);if(r)try{r.endsWith("x")?e.capHeight={value:parseFloat(r.slice(0,-1)),isRelative:!0}:e.capHeight={value:parseFloat(r),isRelative:!1}}catch{this.scanner.consume(-r.length);return}this.consumeOptionalTerminator()}parseWidth(e){const r=this.extractFloatExpression(!0);if(r)try{r.endsWith("x")?e.widthFactor={value:parseFloat(r.slice(0,-1)),isRelative:!0}:e.widthFactor={value:parseFloat(r),isRelative:!1}}catch{this.scanner.consume(-r.length);return}this.consumeOptionalTerminator()}parseCharTracking(e){const r=this.extractFloatExpression(!0);if(r)try{r.endsWith("x")?e.charTrackingFactor={value:Math.abs(parseFloat(r.slice(0,-1))),isRelative:!0}:e.charTrackingFactor={value:Math.abs(parseFloat(r)),isRelative:!1}}catch{this.scanner.consume(-r.length);return}this.consumeOptionalTerminator()}parseFloatValueOrFactor(e){const r=this.extractFloatExpression(!0);if(r)if(r.endsWith("x")){const n=parseFloat(r.slice(0,-1));e*=n}else e=parseFloat(r);return e}parseOblique(e){const r=this.extractFloatExpression(!1);r&&(e.oblique=parseFloat(r)),this.consumeOptionalTerminator()}parseAciColor(e){const r=this.extractIntExpression();if(r){const n=parseInt(r);n<257&&(e.color.aci=n)}this.consumeOptionalTerminator()}parseRgbColor(e){const r=this.extractIntExpression();if(r){const n=parseInt(r)&16777215;e.color.rgbValue=n}this.consumeOptionalTerminator()}extractFloatExpression(e=!1){const r=e?/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?x?/:/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/,n=this.scanner.tail.match(r);if(n){const a=n[0];return this.scanner.consume(a.length),a}return""}extractIntExpression(){const e=this.scanner.tail.match(/^\d+/);if(e){const r=e[0];return this.scanner.consume(r.length),r}return""}extractExpression(e=!1){const r=this.scanner.find(";",e);if(r<0){const s=this.scanner.tail;return this.scanner.consume(s.length),s}const n=this.scanner.peek(r-this.scanner.currentIndex-1)==="\\",a=this.scanner.tail.slice(0,r-this.scanner.currentIndex+(n?1:0));return this.scanner.consume(a.length+1),a}parseFontProperties(e){const r=this.extractExpression().split("|");if(r.length>0&&r[0]){const n=r[0];let a="Regular",s=400;for(const i of r.slice(1))i.startsWith("b1")?s=700:i==="i"||i.startsWith("i1")?a="Italic":(i==="i0"||i.startsWith("i0"))&&(a="Regular");e.fontFace={family:n,style:a,weight:s}}}parseParagraphProperties(e){const r=new hr(this.extractExpression());let n=e.paragraph.indent,a=e.paragraph.left,s=e.paragraph.right,i=e.paragraph.align,o=[];const u=()=>{const l=r.tail.match(/^[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/);if(l){const c=parseFloat(l[0]);for(r.consume(l[0].length);r.peek()===",";)r.consume(1);return c}return 0};for(;r.hasData;)switch(r.get()){case"i":n=u();break;case"l":a=u();break;case"r":s=u();break;case"x":break;case"q":{const l=r.get();for(i=Sl[l]||0;r.peek()===",";)r.consume(1);break}case"t":for(o=[];r.hasData;){const l=r.peek();if(l==="r"||l==="c"){r.consume(1);const c=u();o.push(l+c.toString())}else{const c=u();isNaN(c)?r.consume(1):o.push(c)}}break}e.paragraph={indent:n,left:a,right:s,align:i,tabs:o}}consumeOptionalTerminator(){this.scanner.peek()===";"&&this.scanner.consume(1)}*parse(){let e=null;function r(a){const s={...a.paragraph};a.paragraph={indent:0,left:0,right:0,align:0,tabs:[]};const i={};return s.indent!==0&&(i.indent=0),s.left!==0&&(i.left=0),s.right!==0&&(i.right=0),s.align!==0&&(i.align=0),JSON.stringify(s.tabs)!==JSON.stringify([])&&(i.tabs=[]),i}const n=()=>{var a;let s="";for(;this.scanner.hasData;){let i=!1,o=this.scanner.peek();const u=this.scanner.currentIndex;if(o.charCodeAt(0)<32){if(this.scanner.consume(1),o===" ")return[5,null];if(o===`
|
|
3
|
-
`)return[6,null];o=" "}if(o==="\\")if("\\{}".includes(this.scanner.peek(1)))i=!0,this.scanner.consume(1),o=this.scanner.peek();else{if(s)return[1,s];this.scanner.consume(1);const l=this.scanner.get();switch(l){case"~":return[4,null];case"P":return[6,null];case"N":return[7,null];case"X":return[8,null];case"S":{this.inStackContext=!0;const c=this.parseStacking();return this.inStackContext=!1,c}case"m":case"M":if(this.scanner.peek()==="+"){this.scanner.consume(1);const c=(a=this.scanner.tail.match(/^[0-9A-Fa-f]{4}/))==null?void 0:a[0];if(c){this.scanner.consume(4);const f=this.decodeMultiByteChar(c);return s?[1,s]:[1,f]}this.scanner.consume(-1)}s+="\\M";continue;case"U":if(this.scanner.peek()==="+"){this.scanner.consume(1);const c=this.scanner.tail.match(/^[0-9A-Fa-f]{4,8}/);if(c){const f=c[0];this.scanner.consume(f.length);const h=parseInt(f,16);let p="";try{p=String.fromCodePoint(h)}catch{p="▯"}return s?[1,s]:[1,p]}this.scanner.consume(-1)}s+="\\U";continue;default:if(l)try{const c=this.parseProperties(l);if(this.yieldPropertyCommands&&c)return[9,c];continue}catch{const c=this.scanner.tail.slice(u,this.scanner.currentIndex);s+=c}}continue}if(o==="%"&&this.scanner.peek(1)==="%"){const l=this.scanner.peek(2).toLowerCase(),c=xl[l];if(c){this.scanner.consume(3),s+=c;continue}else{this.scanner.consume(3);continue}}if(o===" ")return s?(this.scanner.consume(1),e=3,[1,s]):(this.scanner.consume(1),[3,null]);if(!i){if(o==="{"){if(s)return[1,s];this.scanner.consume(1),this.pushCtx();continue}else if(o==="}"){if(s)return[1,s];if(this.scanner.consume(1),this.yieldPropertyCommands){const l=this.ctxStack.current;this.popCtx();const c=this.getPropertyChanges(l,this.ctxStack.current);if(Object.keys(c).length>0)return[9,{command:void 0,changes:c,depth:this.ctxStack.depth}]}else this.popCtx();continue}}if(!this.inStackContext&&o==="^"){const l=this.scanner.peek(1);if(l){const c=l.charCodeAt(0);if(this.scanner.consume(2),c===32)s+="^";else{if(c===73)return s?[1,s]:[5,null];if(c===74)return s?[1,s]:[6,null];if(c===77)continue;s+="▯"}continue}}this.scanner.consume(1),o.charCodeAt(0)>=32&&(s+=o)}return s?[1,s]:[0,null]};for(;;){const[a,s]=n.call(this);if(a){if(yield new pr(a,this.ctxStack.current.copy(),s),a===6&&this.resetParagraphParameters){const i=this.ctxStack.current,o=r(i);this.yieldPropertyCommands&&Object.keys(o).length>0&&(yield new pr(9,i.copy(),{command:void 0,changes:{paragraph:o},depth:this.ctxStack.depth}))}e&&(yield new pr(e,this.ctxStack.current.copy(),null),e=null)}else break}}}class hr{constructor(e){this.text=e,this.textLen=e.length,this._index=0}get currentIndex(){return this._index}get isEmpty(){return this._index>=this.textLen}get hasData(){return this._index<this.textLen}get(){if(this.isEmpty)return"";const e=this.text[this._index];return this._index++,e}consume(e=1){this._index=Math.max(0,Math.min(this._index+e,this.textLen))}peek(e=0){const r=this._index+e;return r>=this.textLen||r<0?"":this.text[r]}find(e,r=!1){let n=this._index;for(;n<this.textLen;){if(r&&this.text[n]==="\\"){if(n+1<this.textLen){if(this.text[n+1]===e)return n+1;n+=2;continue}n++;continue}if(this.text[n]===e)return n;n++}return-1}get tail(){return this.text.slice(this._index)}isNextSpace(){return this.peek()===" "}consumeSpaces(){let e=0;for(;this.isNextSpace();)this.consume(),e++;return e}}class fr{constructor(e){this._aci=256,this._rgbValue=null,Array.isArray(e)?this.rgb=e:typeof e=="number"?this.aci=e:this.aci=256}get aci(){return this._aci}set aci(e){if(e===null)this._aci=null;else if(e>=0&&e<=256)this._aci=e,this._rgbValue=null;else throw new Error("ACI not in range [0, 256]")}get rgb(){if(this._rgbValue===null)return null;const e=this._rgbValue>>16&255,r=this._rgbValue>>8&255,n=this._rgbValue&255;return[e,r,n]}set rgb(e){if(e){const[r,n,a]=e;this._rgbValue=(r&255)<<16|(n&255)<<8|a&255,this._aci=null}else this._rgbValue=null}get isRgb(){return this._rgbValue!==null}get isAci(){return this._rgbValue===null&&this._aci!==null}get rgbValue(){return this._rgbValue}set rgbValue(e){e===null?this._rgbValue=null:(this._rgbValue=e&16777215,this._aci=null)}copy(){const e=new fr;return e._aci=this._aci,e._rgbValue=this._rgbValue,e}toObject(){return{aci:this._aci,rgb:this.rgb,rgbValue:this._rgbValue}}equals(e){return this._aci===e._aci&&this._rgbValue===e._rgbValue}}class nt{constructor(){this._stroke=0,this.continueStroke=!1,this.color=new fr,this.align=0,this.fontFace={family:"",style:"Regular",weight:400},this._capHeight={value:1,isRelative:!1},this._widthFactor={value:1,isRelative:!1},this._charTrackingFactor={value:1,isRelative:!1},this.oblique=0,this.paragraph={indent:0,left:0,right:0,align:0,tabs:[]}}get capHeight(){return this._capHeight}set capHeight(e){this._capHeight={value:Math.abs(e.value),isRelative:e.isRelative}}get widthFactor(){return this._widthFactor}set widthFactor(e){this._widthFactor={value:Math.abs(e.value),isRelative:e.isRelative}}get charTrackingFactor(){return this._charTrackingFactor}set charTrackingFactor(e){this._charTrackingFactor={value:Math.abs(e.value),isRelative:e.isRelative}}get aci(){return this.color.aci}set aci(e){this.color.aci=e}get rgb(){return this.color.rgb}set rgb(e){this.color.rgb=e}get italic(){return this.fontFace.style==="Italic"}set italic(e){this.fontFace.style=e?"Italic":"Regular"}get bold(){return(this.fontFace.weight||400)>=700}set bold(e){this.fontFace.weight=e?700:400}get underline(){return!!(this._stroke&1)}set underline(e){this._setStrokeState(1,e)}get strikeThrough(){return!!(this._stroke&4)}set strikeThrough(e){this._setStrokeState(4,e)}get overline(){return!!(this._stroke&2)}set overline(e){this._setStrokeState(2,e)}get hasAnyStroke(){return!!this._stroke}_setStrokeState(e,r=!0){r?this._stroke|=e:this._stroke&=~e}copy(){const e=new nt;return e._stroke=this._stroke,e.continueStroke=this.continueStroke,e.color=this.color.copy(),e.align=this.align,e.fontFace={...this.fontFace},e._capHeight={...this._capHeight},e._widthFactor={...this._widthFactor},e._charTrackingFactor={...this._charTrackingFactor},e.oblique=this.oblique,e.paragraph={...this.paragraph},e}}class pr{constructor(e,r,n){this.type=e,this.ctx=r,this.data=n}}const wl=new R.Vector3,Cl=1.666666;class dr extends nt{constructor(e){super(),this.fontScaleFactor=1,this.fontSize=1,this.fontSizeScaleFactor=1,this.blankWidth=0,e&&Object.assign(this,e)}clone(){const e=new dr;return e.continueStroke=this.continueStroke,e.color=this.color.copy(),e.align=this.align,e.fontFace={...this.fontFace},e.capHeight={...this.capHeight},e.widthFactor={...this.widthFactor},e.charTrackingFactor={...this.charTrackingFactor},e.oblique=this.oblique,e.paragraph={...this.paragraph},e.fontScaleFactor=this.fontScaleFactor,e.fontSize=this.fontSize,e.fontSizeScaleFactor=this.fontSizeScaleFactor,e.blankWidth=this.blankWidth,e}getColorAsHex(){return this.color.isRgb&&this.color.rgbValue!==null?this.color.rgbValue:this.color.isAci&&this.color.aci!==null?za(this.color.aci):16777215}setColorFromHex(e){const r=e>>16&255,n=e>>8&255,a=e&255;this.color.rgb=[r,n,a]}}class El{constructor(e,r,n,a){this._contextStack=[],this._maxFontSize=0,this._currentIndent=0,this._currentLeftMargin=0,this._currentRightMargin=0,this._style=e,this._styleManager=r,this._fontManager=n,this._options=a,this._totalHeight=0,this._hOffset=0,this._vOffset=0,this._lineCount=1,this._currentLineObjects=[],this._currentContext=new dr({fontScaleFactor:this.fontManager.getFontScaleFactor(this.textStyle.font.toLowerCase()),fontSize:a.fontSize,fontSizeScaleFactor:1,italic:!1,bold:!1,blankWidth:this.calculateBlankWidthForFont(this.textStyle.font.toLowerCase(),a.fontSize)}),this._currentContext.setColorFromHex(e.color),this._currentContext.fontFace.family=this.textStyle.font.toLowerCase(),this._currentContext.widthFactor={value:a.widthFactor,isRelative:!0},this._currentContext.oblique=e.obliqueAngle||0,this._maxFontSize=0,this._currentHorizontalAlignment=a.horizontalAlignment,this._currentIndent=0,this._currentLeftMargin=0,this._currentRightMargin=0,this.initLineParams()}get fontManager(){return this._fontManager}get styleManager(){return this._styleManager}get textStyle(){return this._style}get totalHeight(){return this._lineCount==1?this.currentMaxFontSize:this._totalHeight+this.currentLineHeight}get maxWidth(){return this._options.maxWidth}get flowDirection(){return this._options.flowDirection}get defaultHorizontalAlignment(){return this._options.horizontalAlignment}get defaultWidthFactor(){return this._options.widthFactor}get defaultFontSize(){return this._options.fontSize}get defaultLineSpaceFactor(){return this._options.lineSpaceFactor}get currentFont(){return this._currentContext.fontFace.family}get currentHorizontalAlignment(){return this._currentHorizontalAlignment}get currentFontSize(){return this._currentContext.fontSize}get currentLineHeight(){return this.defaultLineSpaceFactor*this.currentFontSize*Cl+this.currentMaxFontSize}get currentMaxFontSize(){return this._maxFontSize}get currentWordSpace(){return this._currentContext.charTrackingFactor.value}get currentWidthFactor(){return this._currentContext.widthFactor.value}get currentLineObjects(){return this._currentLineObjects}get hOffset(){return this._hOffset}set hOffset(e){this._hOffset=e}get vOffset(){return this._vOffset}set vOffset(e){this._vOffset=e}get currentIndent(){return this._currentIndent}get currentLeftMargin(){return this._currentLeftMargin}get currentRightMargin(){return this._currentRightMargin}get maxLineWidth(){return this.maxWidth-this._currentLeftMargin-this._currentRightMargin}processFormat(e){switch(e.command){case"f":case"F":if(e.changes.fontFace){this.changeFont(e.changes.fontFace.family),this.fontManager.getFontType(this._currentContext.fontFace.family)==="mesh"?(this._currentContext.italic=e.changes.fontFace.style==="Italic",this._currentContext.bold=(e.changes.fontFace.weight||400)>=700,this._currentContext.oblique=this.textStyle.obliqueAngle||0):(this._currentContext.italic=!1,this._currentContext.bold=!1,e.changes.fontFace.style==="Italic"?this._currentContext.oblique=15:this._currentContext.oblique=this.textStyle.obliqueAngle||0);break}case"c":case"C":e.changes.aci?e.changes.aci===0?this._currentContext.setColorFromHex(this._options.byBlockColor):e.changes.aci===256?this._currentContext.setColorFromHex(this._options.byLayerColor):this._currentContext.color.aci=e.changes.aci:e.changes.rgb&&(this._currentContext.color.rgb=e.changes.rgb);break;case"W":e.changes.widthFactor&&(e.changes.widthFactor.isRelative?this._currentContext.widthFactor={value:e.changes.widthFactor.value*this.maxWidth,isRelative:!1}:this._currentContext.widthFactor={value:e.changes.widthFactor.value*.93,isRelative:!1});break;case"H":e.changes.capHeight&&(e.changes.capHeight.isRelative?this.changeFontSizeScaleFactor(e.changes.capHeight.value):this.changeFontHeight(e.changes.capHeight.value));break;case"T":e.changes.charTrackingFactor&&(e.changes.charTrackingFactor.isRelative?this._currentContext.charTrackingFactor={value:e.changes.charTrackingFactor.value+1,isRelative:!1}:this._currentContext.charTrackingFactor={value:e.changes.charTrackingFactor.value,isRelative:!1});break;case"p":e.changes.paragraph&&(e.changes.paragraph.align&&(this._currentHorizontalAlignment=e.changes.paragraph.align),typeof e.changes.paragraph.indent=="number"&&(this._currentIndent=e.changes.paragraph.indent*this.defaultFontSize,this._hOffset+=this._currentIndent),typeof e.changes.paragraph.left=="number"&&(this._currentLeftMargin=e.changes.paragraph.left*this.defaultFontSize),typeof e.changes.paragraph.right=="number"&&(this._currentRightMargin=e.changes.paragraph.right*this.defaultFontSize));break;case"L":this._currentContext.underline=!0;break;case"l":this._currentContext.underline=!1;break;case"O":this._currentContext.overline=!0;break;case"o":this._currentContext.overline=!1;break;case"K":this._currentContext.strikeThrough=!0;break;case"k":this._currentContext.strikeThrough=!1;break;case"Q":e.changes.oblique!==void 0&&(this._currentContext.oblique=e.changes.oblique);break}}resetParagraphProperties(){this._currentIndent=0,this._currentLeftMargin=0,this._currentRightMargin=0,this._currentHorizontalAlignment=this._options.horizontalAlignment}startNewParagraph(e,r,n){this.processGeometries(e,r,n),this.startNewLine(),this.resetParagraphProperties()}processText(e){const r=[],n=[],a=new R.Group;for(const s of e)if(s.type===ze.NEW_PARAGRAPH)this.startNewParagraph(r,n,a);else if(s.type===ze.WORD){const i=s.data;Array.isArray(i)?i.forEach(o=>this.processWord(o,r,n)):typeof i=="string"&&i.length>0&&this.processWord(i,r,n)}else if(s.type===ze.SPACE)this.processBlank();else if(s.type===ze.PROPERTIES_CHANGED){this.processGeometries(r,n,a);const i=s.data;i.command===void 0?this._contextStack.length>0&&(this._currentContext=this._contextStack.pop()):(i.depth>0&&this._contextStack.push(this._currentContext.clone()),this.processFormat(i))}else s.type===ze.STACK&&(this.processStack(s.data,r,n),this.processGeometries(r,n,a));return(r.length>0||n.length>0)&&this.processGeometries(r,n,a),this.processLastLine(),a}processGeometries(e,r,n){if(e.length>0||r.length>0){const a=this.toThreeObject(e,r);n.add(a),this._currentLineObjects.push(a),e.length=0,r.length=0}}processWord(e,r,n){let a=0;for(let s=0;s<e.length;s++){const i=this.getCharShape(e[s]);i?this.currentHorizontalAlignment==fe.DISTRIBUTED?a+=i.width*this.currentWidthFactor:a+=i.width*this.currentWordSpace*this.currentWidthFactor:a+=this._currentContext.blankWidth}this.hOffset+a>(this.maxLineWidth||1/0)&&this.startNewLine();for(let s=0;s<e.length;s++)this.processChar(e[s],r,n)}processStack(e,r,n){const[a,s,i]=e,o=this._hOffset,u=this._vOffset,l=this._currentContext.charTrackingFactor.value,c=this._currentContext.fontSize,f=this._currentContext.fontSizeScaleFactor;this._hOffset=o,this._currentContext.charTrackingFactor={value:1,isRelative:!1};let h=0;for(let y=0;y<a.length;y++){const S=this.getCharShape(a[y]);S&&(h+=S.width*this.currentWidthFactor)}this._hOffset=o;let p=0;for(let y=0;y<s.length;y++){const S=this.getCharShape(s[y]);S&&(p+=S.width*this.currentWidthFactor)}const d=Math.max(h,p),m=(d-h)/2,b=(d-p)/2;if(i==="^"){if(this._currentContext.fontSizeScaleFactor=f*.7,this.calcuateLineParams(),a&&!s){const y=[],S=[];this._hOffset=o,this._vOffset=u+c*.1;for(let x=0;x<a.length;x++)this.processChar(a[x],y,S);r.push(...y),n.push(...S),this._hOffset=o+h}else if(!a&&s){const y=[],S=[];this._hOffset=o,this._vOffset=u-c*.6;for(let x=0;x<s.length;x++)this.processChar(s[x],y,S);r.push(...y),n.push(...S),this._hOffset=o+p}this._currentContext.fontSizeScaleFactor=f,this.calcuateLineParams()}else{const y=[],S=[];this._hOffset=o+m,this._vOffset=u+this.currentFontSize*.3;for(let k=0;k<a.length;k++)this.processChar(a[k],y,S);r.push(...y),n.push(...S);const x=[],C=[];this._hOffset=o+b,this._vOffset=u-this.currentFontSize*.6;for(let k=0;k<s.length;k++)this.processChar(s[k],x,C);if(r.push(...x),n.push(...C),i==="/"||i==="#"){const k=new R.BufferGeometry,A=new Float32Array([o,u-this.currentFontSize*.8,0,o+d,u-this.currentFontSize*.8,0]);k.setAttribute("position",new R.BufferAttribute(A,3)),k.setIndex(null),n.push(k)}this._hOffset=o+d}this._vOffset=u,this._currentContext.charTrackingFactor={value:l,isRelative:!1}}processBlank(){this._hOffset+=this._currentContext.blankWidth}processChar(e,r,n){const a=this.getCharShape(e);if(!a){this.processBlank();return}let s=a.toGeometry();s.scale(this.currentWidthFactor,1,1);let i=this._currentContext.oblique;if(this._currentContext.italic&&(i+=15),i){const d=i*Math.PI/180,m=new R.Matrix4;m.set(1,Math.tan(d),0,0,0,1,0,0,0,0,1,0,0,0,0,1),s.applyMatrix4(m)}const o=this.fontManager.getFontType(this.currentFont);this._currentContext.bold&&o==="mesh"&&s.scale(1.06,1.06,1),this.hOffset>(this.maxLineWidth||1/0)&&this.startNewLine();let u=this.hOffset,l=this.flowDirection==He.BOTTOM_TO_TOP?this.vOffset:this.vOffset-this.currentFontSize,c=a.width*this.currentWidthFactor,f=this.currentFontSize;s.translate(u,l,0),this.currentHorizontalAlignment==fe.DISTRIBUTED?this._hOffset+=a.width*this.currentWidthFactor:this._hOffset+=a.width*this.currentWordSpace*this.currentWidthFactor,r.push(s);const h=f*.05,p=.001;if(this._currentContext.underline){const d=new R.BufferGeometry,m=l-h;d.setAttribute("position",new R.BufferAttribute(new Float32Array([u,m,p,u+c,m,p]),3)),d.setIndex(null),n.push(d)}if(this._currentContext.overline){const d=new R.BufferGeometry,m=l+f+h;d.setAttribute("position",new R.BufferAttribute(new Float32Array([u,m,p,u+c,m,p]),3)),d.setIndex(null),n.push(d)}if(this._currentContext.strikeThrough){const d=new R.BufferGeometry,m=l+f/2-f*.2;d.setAttribute("position",new R.BufferAttribute(new Float32Array([u,m,p,u+c,m,p]),3)),d.setIndex(null),n.push(d)}}processLastLine(){this.processAlignment()}initLineParams(){this.calcuateLineParams()}changeFont(e){let r=e;this._options.removeFontExtension&&(r=e.replace(/\.(ttf|otf|woff|shx)$/,"")),this._currentContext.fontFace.family=this.fontManager.findAndReplaceFont(r),this._currentContext.blankWidth=this.calculateBlankWidthForFont(this._currentContext.fontFace.family,this._currentContext.fontSize),this.calcuateLineParams()}calcuateLineParams(e){this._currentContext.fontScaleFactor=this.fontManager.getFontScaleFactor(this.currentFont);const r=e||this.defaultFontSize||this.textStyle.fixedTextHeight;this._currentContext.fontSize=r*this._currentContext.fontScaleFactor*this._currentContext.fontSizeScaleFactor}getCharShape(e){let r=this.fontManager.getCharShape(e,this.currentFont,this.currentFontSize);return this.textStyle.bigFont&&!r&&(r=this.fontManager.getCharShape(e,this.textStyle.bigFont,this.currentFontSize)),r||(r=this.fontManager.getCharShape(e,"",this.currentFontSize)),r||(r=this.fontManager.getNotFoundTextShape(this.currentFontSize)),this.currentFontSize>this._maxFontSize&&(this._maxFontSize=this.currentFontSize),r}startNewLine(){this._hOffset=0,this.flowDirection==He.BOTTOM_TO_TOP?this._vOffset+=this.currentLineHeight:this._vOffset-=this.currentLineHeight,this._lineCount++,this.processAlignment(),this._currentLineObjects=[],this._lineCount==2?this._totalHeight=this.currentMaxFontSize:this._totalHeight=this._totalHeight+this.currentLineHeight,this._maxFontSize=0}processAlignment(){const e=[];if(this.currentLineObjects.forEach(n=>n.traverse(a=>{"geometry"in a&&e.push(a.geometry)})),e.length==0)return;let r;if(e.forEach((n,a)=>{n.boundingBox||n.computeBoundingBox(),a===0?r=n.boundingBox:r.union(n.boundingBox)}),r){const n=r.getSize(wl);switch(this.currentHorizontalAlignment){case fe.LEFT:e.forEach(a=>a.translate(this._currentLeftMargin-r.min.x,0,0));break;case fe.CENTER:e.forEach(a=>a.translate(this._currentLeftMargin+(this.maxLineWidth-n.x)/2-r.min.x,0,0));break;case fe.RIGHT:e.forEach(a=>a.translate(this._currentLeftMargin+this.maxLineWidth-n.x-r.min.x,0,0));break;case fe.DISTRIBUTED:if(e.length>1){const a=(this.maxLineWidth-n.x)/(e.length-1);for(let s=1;s<e.length;s++)e[s].translate(a*s,0,0)}e.forEach(a=>a.translate(this._currentLeftMargin-r.min.x,0,0));break}}}calculateBlankWidthForFont(e,r){return this.fontManager.getFontType(e)==="shx"?r*.5:r*.3}toThreeObject(e,r){const n=new R.Group,a=this._currentContext.getColorAsHex(),s=e.filter(o=>o instanceof R.ExtrudeGeometry);if(s.length>0){const o=new R.Mesh;o.geometry=Mr(s),o.material=this.styleManager.getMeshBasicMaterial(a),o.userData.bboxIntersectionCheck=!0,n.add(o)}const i=[...r,...e.filter(o=>!(o instanceof R.ExtrudeGeometry))];if(i.length>0){const o=new R.LineSegments;o.geometry=Mr(i),o.material=this.styleManager.getLineBasicMaterial(a),o.userData.bboxIntersectionCheck=!0,n.add(o)}return n.children.length===1?n.children[0]:n}changeFontSizeScaleFactor(e){this._currentContext.fontSizeScaleFactor*=e,this.calcuateLineParams()}changeFontHeight(e){this._currentContext.fontSize=e*this._currentContext.fontScaleFactor*this._currentContext.fontSizeScaleFactor,this.calcuateLineParams()}}const gr=new R.Vector3,Pe=new R.Vector3,vr=new R.Vector3,mr=new R.Quaternion,yr=new R.Matrix4,ba=new R.Matrix4,xa=new R.Vector3(1,0,0);class Sa extends R.Object3D{static getFonts(e,r=!1){return kl(e,r)}constructor(e,r,n,a,s={byLayerColor:16777215,byBlockColor:16777215}){super(),this._style=r,this._styleManager=n,this._fontManager=a,this._colorSettings={byLayerColor:s.byLayerColor,byBlockColor:s.byBlockColor},this._box=new R.Box3,this._boxes=[];const i=this.loadMText(e,r);i&&(this.getBoxes(i,this._boxes),this._boxes.forEach(o=>this.box.union(o)),this.add(i))}get fontManager(){return this._fontManager}get styleManager(){return this._styleManager}get textStyle(){return this._style}get box(){return this._box}set box(e){this._box.copy(e)}raycast(e,r){this._boxes.forEach(n=>{if(e.ray.intersectBox(n,gr)){const a=e.ray.origin.distanceTo(gr);r.push({distance:a,point:gr.clone(),object:this,face:null,faceIndex:void 0,uv:void 0})}})}loadMText(e,r){const{object:n,height:a}=this.createMTextGroup(e,r);if(!n)return;n.matrix.decompose(Pe,mr,vr),e.position&&(Pe.x+=e.position.x,Pe.y+=e.position.y,n.matrix.compose(Pe,mr,vr));const s=e.width,i=this.calculateAnchorPoint(s,a,e.attachmentPoint,e.drawingDirection);n.traverse(l=>{"geometry"in l&&l.geometry.translate(i.x,i.y,0),l.layers.enableAll()});let o=e.rotation||0;if(e.directionVector){const l=e.directionVector,c=new R.Vector3(l.x,l.y,l.z),f=c.clone().cross(xa),h=xa.angleTo(c);o=f.z>0?-h:h}n.matrix.compose(Pe,mr,vr);const u=e.position?Pe.clone().sub(e.position):Pe;return yr.makeTranslation(-u.x,-u.y,0),ba.makeRotationZ(o),n.matrix.multiply(yr),n.matrix.multiply(ba),n.matrix.multiply(yr.invert()),n.matrix.decompose(n.position,n.quaternion,n.scale),n}createMTextGroup(e,r){if(r&&r.font&&r.font.endsWith(".shx")){const m=`${r.font}_${r.name}`;this.styleManager.unsupportedTextStyles[m]||(this.styleManager.unsupportedTextStyles[m]=0),this.styleManager.unsupportedTextStyles[m]++}const n=e.width||0;let a=fe.LEFT;e.width&&e.attachmentPoint&&([1,4,7].includes(e.attachmentPoint)?a=fe.LEFT:[2,5,8].includes(e.attachmentPoint)?a=fe.CENTER:[3,6,9].includes(e.attachmentPoint)&&(a=fe.RIGHT));let s=rt.BOTTOM;e.attachmentPoint&&([1,2,3].includes(e.attachmentPoint)?s=rt.TOP:[4,5,6].includes(e.attachmentPoint)?s=rt.MIDDLE:[7,8,9].includes(e.attachmentPoint)&&(s=rt.BOTTOM));const i=e.height||0,o=e.lineSpaceFactor||.3,u=e.drawingDirection??He.LEFT_TO_RIGHT,l={fontSize:i,widthFactor:e.widthFactor??1,lineSpaceFactor:o,horizontalAlignment:a,maxWidth:n,flowDirection:u,byBlockColor:this._colorSettings.byBlockColor,byLayerColor:this._colorSettings.byLayerColor,removeFontExtension:!0},c=new nt;c.fontFace.family=r.font,c.capHeight={value:e.height||1,isRelative:!0},c.widthFactor={value:e.widthFactor??1,isRelative:!0},c.align=s,c.paragraph.align=a;const f=new El(r,this.styleManager,this.fontManager,l),p=new Tl(e.text,c,{resetParagraphParameters:!0,yieldPropertyCommands:!0}).parse();return{object:f.processText(p),height:f.totalHeight}}calculateAnchorPoint(e,r,n,a){let s=0,i=0;switch(n){case void 0:case 1:s=0,i=0;break;case 2:s-=e/2,i=0;break;case 3:s-=e,i=0;break;case 4:s=0,i+=r/2;break;case 5:s-=e/2,i+=r/2;break;case 6:s-=e,i+=r/2;break;case 7:s=0,i+=r;break;case 8:s-=e/2,i+=r;break;case 9:s-=e,i+=r;break}return a==He.BOTTOM_TO_TOP&&(i-=r),{x:s,y:i}}getBoxes(e,r){if(e.updateWorldMatrix(!1,!1),e instanceof R.Line||e instanceof R.Mesh){const a=e.geometry;a.boundingBox===null&&a.computeBoundingBox();const s=new R.Box3().copy(a.boundingBox);s.applyMatrix4(e.matrixWorld),r.push(s)}const n=e.children;for(let a=0,s=n.length;a<s;a++)this.getBoxes(n[a],r)}}class ka{constructor(){this.lineBasicMaterials={},this.meshBasicMaterials={},this.unsupportedTextStyles={}}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new R.MeshBasicMaterial({color:e})),this.meshBasicMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new R.LineBasicMaterial({color:e})),this.lineBasicMaterials[e]}}class br{constructor(e=Math.max(1,navigator.hardwareConcurrency?Math.min(4,navigator.hardwareConcurrency):2)){this.workers=[],this.inFlightPerWorker=[],this.pendingRequests=new Map,this.requestId=0,this.readyPromise=null,this.poolSize=e;for(let r=0;r<this.poolSize;r++){const n=new Worker(new URL("/assets/mtextWorker-BlkfNPdt.js",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:St&&St.tagName.toUpperCase()==="SCRIPT"&&St.src||new URL("index.umd.cjs",document.baseURI).href),{type:"module"});this.attachWorkerHandlers(n,r),this.workers.push(n),this.inFlightPerWorker.push(0)}this.ensureInitialized()}handleWorkerMessage(e){const{id:r,success:n,data:a,error:s}=e,i=this.pendingRequests.get(r);if(i){this.pendingRequests.delete(r);const{workerIndex:o}=i;this.inFlightPerWorker[o]=Math.max(0,this.inFlightPerWorker[o]-1),n?i.resolve(a):i.reject(new Error(s||"Unknown worker error"))}}attachWorkerHandlers(e,r){e.onmessage=n=>{this.handleWorkerMessage(n.data)},e.onerror=n=>{console.error("Worker error:",n);const a=[];this.pendingRequests.forEach((s,i)=>{s.workerIndex===r&&a.push(i)}),a.forEach(s=>{const i=this.pendingRequests.get(s);i&&(i.reject(new Error("Worker error occurred")),this.pendingRequests.delete(s))}),this.inFlightPerWorker[r]=0}}pickLeastLoadedWorker(){let e=0,r=this.inFlightPerWorker[0]??0;for(let n=1;n<this.inFlightPerWorker.length;n++){const a=this.inFlightPerWorker[n]??0;a<r&&(r=a,e=n)}return e}sendMessage(e,r){const n=this.pickLeastLoadedWorker(),a=this.workers[n];return new Promise((s,i)=>{const o=`req_${++this.requestId}`;this.pendingRequests.set(o,{resolve:u=>s(u),reject:i,workerIndex:n}),this.inFlightPerWorker[n]=(this.inFlightPerWorker[n]??0)+1,a.postMessage({type:e,id:o,data:r}),setTimeout(()=>{this.pendingRequests.get(o)&&(this.pendingRequests.delete(o),this.inFlightPerWorker[n]=Math.max(0,this.inFlightPerWorker[n]-1),i(new Error("Worker request timeout")))},3e4)})}ensureInitialized(){return this.readyPromise?this.readyPromise:this.workers.length===0?Promise.resolve():(this.readyPromise=Promise.all(this.workers.map((e,r)=>new Promise((n,a)=>{const s=`req_${++this.requestId}`;this.pendingRequests.set(s,{resolve:()=>n(),reject:a,workerIndex:r}),this.inFlightPerWorker[r]=(this.inFlightPerWorker[r]??0)+1,e.postMessage({type:"getAvailableFonts",id:s}),setTimeout(()=>{this.pendingRequests.get(s)&&(this.pendingRequests.delete(s),this.inFlightPerWorker[r]=Math.max(0,this.inFlightPerWorker[r]-1),a(new Error("Worker init timeout")))},3e4)}))).then(()=>{}),this.readyPromise)}async renderMText(e,r,n={byLayerColor:16777215,byBlockColor:16777215}){await this.ensureInitialized();const a=await this.sendMessage("render",{mtextContent:e,textStyle:r,colorSettings:n});return this.reconstructMText(a)}async loadFonts(e){await this.ensureInitialized();const r=await Promise.all(this.workers.map((a,s)=>new Promise((i,o)=>{const u=`req_${++this.requestId}`;this.pendingRequests.set(u,{resolve:l=>i(l),reject:o,workerIndex:s}),this.inFlightPerWorker[s]=(this.inFlightPerWorker[s]??0)+1,a.postMessage({type:"loadFonts",id:u,data:{fonts:e}}),setTimeout(()=>{this.pendingRequests.get(u)&&(this.pendingRequests.delete(u),this.inFlightPerWorker[s]=Math.max(0,this.inFlightPerWorker[s]-1),o(new Error("Worker request timeout")))},3e4)}))),n=new Set;return r.forEach(a=>{var s;return(s=a.loaded)==null?void 0:s.forEach(i=>n.add(i))}),{loaded:Array.from(n)}}async getAvailableFonts(){if(this.workers.length===0)return{fonts:[]};await this.ensureInitialized();const e=0,r=this.workers[e];return new Promise((n,a)=>{const s=`req_${++this.requestId}`;this.pendingRequests.set(s,{resolve:i=>n(i),reject:a,workerIndex:e}),this.inFlightPerWorker[e]=(this.inFlightPerWorker[e]??0)+1,r.postMessage({type:"getAvailableFonts",id:s}),setTimeout(()=>{this.pendingRequests.get(s)&&(this.pendingRequests.delete(s),this.inFlightPerWorker[e]=Math.max(0,this.inFlightPerWorker[e]-1),a(new Error("Worker request timeout")))},3e4)})}reconstructMText(e){const r=new R.Group;return e.children.forEach(n=>{const a=new R.BufferGeometry;if(Object.keys(n.geometry.attributes).forEach(o=>{const u=n.geometry.attributes[o],l=new Float32Array(u.arrayBuffer,u.byteOffset,u.length),c=new R.BufferAttribute(l,u.itemSize,u.normalized);a.setAttribute(o,c)}),n.geometry.index)if(n.geometry.index.componentType==="uint32"){const u=new Uint32Array(n.geometry.index.arrayBuffer,n.geometry.index.byteOffset,n.geometry.index.length);a.setIndex(new R.Uint32BufferAttribute(u,1))}else{const u=new Uint16Array(n.geometry.index.arrayBuffer,n.geometry.index.byteOffset,n.geometry.index.length);a.setIndex(new R.Uint16BufferAttribute(u,1))}let s;n.type==="mesh"?s=new R.MeshBasicMaterial({color:n.material.color,transparent:n.material.transparent,opacity:n.material.opacity,side:n.material.side}):s=new R.LineBasicMaterial({color:n.material.color,transparent:n.material.transparent,opacity:n.material.opacity,linewidth:n.material.linewidth});let i;n.type==="mesh"?i=new R.Mesh(a,s):i=new R.Line(a,s),a.boundingBox||a.computeBoundingBox(),a.boundingSphere||a.computeBoundingSphere(),i.position.set(n.position.x,n.position.y,n.position.z),i.quaternion.set(n.rotation.x,n.rotation.y,n.rotation.z,n.rotation.w),i.scale.set(n.scale.x,n.scale.y,n.scale.z),r.add(i)}),r.box=new R.Box3(new R.Vector3(e.box.min.x,e.box.min.y,e.box.min.z),new R.Vector3(e.box.max.x,e.box.max.y,e.box.max.z)),r}terminate(){this.workers.forEach(e=>e.terminate()),this.workers=[],this.inFlightPerWorker=[],this.readyPromise=null,this.pendingRequests.forEach(({reject:e})=>{e(new Error("Renderer terminated"))}),this.pendingRequests.clear()}destroy(){this.terminate()}}class Fa{constructor(){this.fontManager=xe.instance,this.styleManager=new ka,this.fontLoader=new ma,this.fontManager.defaultFont="simkai"}async renderMText(e,r,n={byLayerColor:16777215,byBlockColor:16777215}){const a=new Sa(e,r,this.styleManager,this.fontManager,n);return a.updateMatrixWorld(!0),a}async loadFonts(e){return await this.fontLoader.load(e),{loaded:e}}async getAvailableFonts(){return{fonts:await this.fontLoader.getAvaiableFonts()}}destroy(){}}class Ol{constructor(e="main"){this.workerManager=null,this.currentMode=e,this.mainThreadRenderer=new Fa,this.adapter=this.mainThreadRenderer,e==="worker"&&(this.workerManager=new br,this.adapter=this.workerManager)}switchMode(e){this.currentMode!==e&&(this.currentMode==="worker"&&this.workerManager&&(this.workerManager.terminate(),this.workerManager=null),this.currentMode=e,e==="worker"?(this.workerManager=new br,this.adapter=this.workerManager):this.adapter=this.mainThreadRenderer)}getMode(){return this.currentMode}async renderMText(e,r,n={byLayerColor:16777215,byBlockColor:16777215}){return this.adapter.renderMText(e,r,n)}async loadFonts(e){return this.adapter.loadFonts(e)}async getAvailableFonts(){return this.adapter.getAvailableFonts()}destroy(){this.workerManager&&(this.workerManager.terminate(),this.workerManager=null),this.mainThreadRenderer.destroy()}}v.BaseFont=Ft,v.BaseTextShape=Tt,v.DefaultFontLoader=ma,v.EventManager=kt,v.FontFactory=be,v.FontManager=xe,v.MText=Sa,v.MTextAttachmentPoint=ya,v.MTextFlowDirection=He,v.MTextWorkerManager=br,v.MainThreadRenderer=Fa,v.StyleManager=ka,v.UnifiedRenderer=Ol,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
|
3
|
+
`)return[6,null];o=" "}if(o==="\\")if("\\{}".includes(this.scanner.peek(1)))i=!0,this.scanner.consume(1),o=this.scanner.peek();else{if(s)return[1,s];this.scanner.consume(1);const l=this.scanner.get();switch(l){case"~":return[4,null];case"P":return[6,null];case"N":return[7,null];case"X":return[8,null];case"S":{this.inStackContext=!0;const c=this.parseStacking();return this.inStackContext=!1,c}case"m":case"M":if(this.scanner.peek()==="+"){this.scanner.consume(1);const c=(a=this.scanner.tail.match(/^[0-9A-Fa-f]{4}/))==null?void 0:a[0];if(c){this.scanner.consume(4);const f=this.decodeMultiByteChar(c);return s?[1,s]:[1,f]}this.scanner.consume(-1)}s+="\\M";continue;case"U":if(this.scanner.peek()==="+"){this.scanner.consume(1);const c=this.scanner.tail.match(/^[0-9A-Fa-f]{4,8}/);if(c){const f=c[0];this.scanner.consume(f.length);const h=parseInt(f,16);let p="";try{p=String.fromCodePoint(h)}catch{p="▯"}return s?[1,s]:[1,p]}this.scanner.consume(-1)}s+="\\U";continue;default:if(l)try{const c=this.parseProperties(l);if(this.yieldPropertyCommands&&c)return[9,c];continue}catch{const c=this.scanner.tail.slice(u,this.scanner.currentIndex);s+=c}}continue}if(o==="%"&&this.scanner.peek(1)==="%"){const l=this.scanner.peek(2).toLowerCase(),c=xl[l];if(c){this.scanner.consume(3),s+=c;continue}else{this.scanner.consume(3);continue}}if(o===" ")return s?(this.scanner.consume(1),e=3,[1,s]):(this.scanner.consume(1),[3,null]);if(!i){if(o==="{"){if(s)return[1,s];this.scanner.consume(1),this.pushCtx();continue}else if(o==="}"){if(s)return[1,s];if(this.scanner.consume(1),this.yieldPropertyCommands){const l=this.ctxStack.current;this.popCtx();const c=this.getPropertyChanges(l,this.ctxStack.current);if(Object.keys(c).length>0)return[9,{command:void 0,changes:c,depth:this.ctxStack.depth}]}else this.popCtx();continue}}if(!this.inStackContext&&o==="^"){const l=this.scanner.peek(1);if(l){const c=l.charCodeAt(0);if(this.scanner.consume(2),c===32)s+="^";else{if(c===73)return s?[1,s]:[5,null];if(c===74)return s?[1,s]:[6,null];if(c===77)continue;s+="▯"}continue}}this.scanner.consume(1),o.charCodeAt(0)>=32&&(s+=o)}return s?[1,s]:[0,null]};for(;;){const[a,s]=n.call(this);if(a){if(yield new pr(a,this.ctxStack.current.copy(),s),a===6&&this.resetParagraphParameters){const i=this.ctxStack.current,o=r(i);this.yieldPropertyCommands&&Object.keys(o).length>0&&(yield new pr(9,i.copy(),{command:void 0,changes:{paragraph:o},depth:this.ctxStack.depth}))}e&&(yield new pr(e,this.ctxStack.current.copy(),null),e=null)}else break}}}class hr{constructor(e){this.text=e,this.textLen=e.length,this._index=0}get currentIndex(){return this._index}get isEmpty(){return this._index>=this.textLen}get hasData(){return this._index<this.textLen}get(){if(this.isEmpty)return"";const e=this.text[this._index];return this._index++,e}consume(e=1){this._index=Math.max(0,Math.min(this._index+e,this.textLen))}peek(e=0){const r=this._index+e;return r>=this.textLen||r<0?"":this.text[r]}find(e,r=!1){let n=this._index;for(;n<this.textLen;){if(r&&this.text[n]==="\\"){if(n+1<this.textLen){if(this.text[n+1]===e)return n+1;n+=2;continue}n++;continue}if(this.text[n]===e)return n;n++}return-1}get tail(){return this.text.slice(this._index)}isNextSpace(){return this.peek()===" "}consumeSpaces(){let e=0;for(;this.isNextSpace();)this.consume(),e++;return e}}class fr{constructor(e){this._aci=256,this._rgbValue=null,Array.isArray(e)?this.rgb=e:typeof e=="number"?this.aci=e:this.aci=256}get aci(){return this._aci}set aci(e){if(e===null)this._aci=null;else if(e>=0&&e<=256)this._aci=e,this._rgbValue=null;else throw new Error("ACI not in range [0, 256]")}get rgb(){if(this._rgbValue===null)return null;const e=this._rgbValue>>16&255,r=this._rgbValue>>8&255,n=this._rgbValue&255;return[e,r,n]}set rgb(e){if(e){const[r,n,a]=e;this._rgbValue=(r&255)<<16|(n&255)<<8|a&255,this._aci=null}else this._rgbValue=null}get isRgb(){return this._rgbValue!==null}get isAci(){return this._rgbValue===null&&this._aci!==null}get rgbValue(){return this._rgbValue}set rgbValue(e){e===null?this._rgbValue=null:(this._rgbValue=e&16777215,this._aci=null)}copy(){const e=new fr;return e._aci=this._aci,e._rgbValue=this._rgbValue,e}toObject(){return{aci:this._aci,rgb:this.rgb,rgbValue:this._rgbValue}}equals(e){return this._aci===e._aci&&this._rgbValue===e._rgbValue}}class nt{constructor(){this._stroke=0,this.continueStroke=!1,this.color=new fr,this.align=0,this.fontFace={family:"",style:"Regular",weight:400},this._capHeight={value:1,isRelative:!1},this._widthFactor={value:1,isRelative:!1},this._charTrackingFactor={value:1,isRelative:!1},this.oblique=0,this.paragraph={indent:0,left:0,right:0,align:0,tabs:[]}}get capHeight(){return this._capHeight}set capHeight(e){this._capHeight={value:Math.abs(e.value),isRelative:e.isRelative}}get widthFactor(){return this._widthFactor}set widthFactor(e){this._widthFactor={value:Math.abs(e.value),isRelative:e.isRelative}}get charTrackingFactor(){return this._charTrackingFactor}set charTrackingFactor(e){this._charTrackingFactor={value:Math.abs(e.value),isRelative:e.isRelative}}get aci(){return this.color.aci}set aci(e){this.color.aci=e}get rgb(){return this.color.rgb}set rgb(e){this.color.rgb=e}get italic(){return this.fontFace.style==="Italic"}set italic(e){this.fontFace.style=e?"Italic":"Regular"}get bold(){return(this.fontFace.weight||400)>=700}set bold(e){this.fontFace.weight=e?700:400}get underline(){return!!(this._stroke&1)}set underline(e){this._setStrokeState(1,e)}get strikeThrough(){return!!(this._stroke&4)}set strikeThrough(e){this._setStrokeState(4,e)}get overline(){return!!(this._stroke&2)}set overline(e){this._setStrokeState(2,e)}get hasAnyStroke(){return!!this._stroke}_setStrokeState(e,r=!0){r?this._stroke|=e:this._stroke&=~e}copy(){const e=new nt;return e._stroke=this._stroke,e.continueStroke=this.continueStroke,e.color=this.color.copy(),e.align=this.align,e.fontFace={...this.fontFace},e._capHeight={...this._capHeight},e._widthFactor={...this._widthFactor},e._charTrackingFactor={...this._charTrackingFactor},e.oblique=this.oblique,e.paragraph={...this.paragraph},e}}class pr{constructor(e,r,n){this.type=e,this.ctx=r,this.data=n}}const wl=new R.Vector3,Cl=1.666666;class dr extends nt{constructor(e){super(),this.fontScaleFactor=1,this.fontSize=1,this.fontSizeScaleFactor=1,this.blankWidth=0,e&&Object.assign(this,e)}clone(){const e=new dr;return e.continueStroke=this.continueStroke,e.color=this.color.copy(),e.align=this.align,e.fontFace={...this.fontFace},e.capHeight={...this.capHeight},e.widthFactor={...this.widthFactor},e.charTrackingFactor={...this.charTrackingFactor},e.oblique=this.oblique,e.paragraph={...this.paragraph},e.fontScaleFactor=this.fontScaleFactor,e.fontSize=this.fontSize,e.fontSizeScaleFactor=this.fontSizeScaleFactor,e.blankWidth=this.blankWidth,e}getColorAsHex(){return this.color.isRgb&&this.color.rgbValue!==null?this.color.rgbValue:this.color.isAci&&this.color.aci!==null?za(this.color.aci):16777215}setColorFromHex(e){const r=e>>16&255,n=e>>8&255,a=e&255;this.color.rgb=[r,n,a]}}class El{constructor(e,r,n,a){this._contextStack=[],this._maxFontSize=0,this._currentIndent=0,this._currentLeftMargin=0,this._currentRightMargin=0,this._style=e,this._styleManager=r,this._fontManager=n,this._options=a,this._totalHeight=0,this._hOffset=0,this._vOffset=0,this._lineCount=1,this._currentLineObjects=[],this._currentContext=new dr({fontScaleFactor:this.fontManager.getFontScaleFactor(this.textStyle.font.toLowerCase()),fontSize:a.fontSize,fontSizeScaleFactor:1,italic:!1,bold:!1,blankWidth:this.calculateBlankWidthForFont(this.textStyle.font.toLowerCase(),a.fontSize)}),this._currentContext.setColorFromHex(e.color),this._currentContext.fontFace.family=this.textStyle.font.toLowerCase(),this._currentContext.widthFactor={value:a.widthFactor,isRelative:!0},this._currentContext.oblique=e.obliqueAngle||0,this._maxFontSize=0,this._currentHorizontalAlignment=a.horizontalAlignment,this._currentIndent=0,this._currentLeftMargin=0,this._currentRightMargin=0,this.initLineParams()}get fontManager(){return this._fontManager}get styleManager(){return this._styleManager}get textStyle(){return this._style}get totalHeight(){return this._lineCount==1?this.currentMaxFontSize:this._totalHeight+this.currentLineHeight}get maxWidth(){return this._options.maxWidth}get flowDirection(){return this._options.flowDirection}get defaultHorizontalAlignment(){return this._options.horizontalAlignment}get defaultWidthFactor(){return this._options.widthFactor}get defaultFontSize(){return this._options.fontSize}get defaultLineSpaceFactor(){return this._options.lineSpaceFactor}get currentFont(){return this._currentContext.fontFace.family}get currentHorizontalAlignment(){return this._currentHorizontalAlignment}get currentFontSize(){return this._currentContext.fontSize}get currentLineHeight(){return this.defaultLineSpaceFactor*this.currentFontSize*Cl+this.currentMaxFontSize}get currentMaxFontSize(){return this._maxFontSize}get currentWordSpace(){return this._currentContext.charTrackingFactor.value}get currentWidthFactor(){return this._currentContext.widthFactor.value}get currentLineObjects(){return this._currentLineObjects}get hOffset(){return this._hOffset}set hOffset(e){this._hOffset=e}get vOffset(){return this._vOffset}set vOffset(e){this._vOffset=e}get currentIndent(){return this._currentIndent}get currentLeftMargin(){return this._currentLeftMargin}get currentRightMargin(){return this._currentRightMargin}get maxLineWidth(){return this.maxWidth-this._currentLeftMargin-this._currentRightMargin}processFormat(e){switch(e.command){case"f":case"F":if(e.changes.fontFace){this.changeFont(e.changes.fontFace.family),this.fontManager.getFontType(this._currentContext.fontFace.family)==="mesh"?(this._currentContext.italic=e.changes.fontFace.style==="Italic",this._currentContext.bold=(e.changes.fontFace.weight||400)>=700,this._currentContext.oblique=this.textStyle.obliqueAngle||0):(this._currentContext.italic=!1,this._currentContext.bold=!1,e.changes.fontFace.style==="Italic"?this._currentContext.oblique=15:this._currentContext.oblique=this.textStyle.obliqueAngle||0);break}case"c":case"C":e.changes.aci?e.changes.aci===0?this._currentContext.setColorFromHex(this._options.byBlockColor):e.changes.aci===256?this._currentContext.setColorFromHex(this._options.byLayerColor):this._currentContext.color.aci=e.changes.aci:e.changes.rgb&&(this._currentContext.color.rgb=e.changes.rgb);break;case"W":e.changes.widthFactor&&(e.changes.widthFactor.isRelative?this._currentContext.widthFactor={value:e.changes.widthFactor.value*this.maxWidth,isRelative:!1}:this._currentContext.widthFactor={value:e.changes.widthFactor.value*.93,isRelative:!1});break;case"H":e.changes.capHeight&&(e.changes.capHeight.isRelative?this.changeFontSizeScaleFactor(e.changes.capHeight.value):this.changeFontHeight(e.changes.capHeight.value));break;case"T":e.changes.charTrackingFactor&&(e.changes.charTrackingFactor.isRelative?this._currentContext.charTrackingFactor={value:e.changes.charTrackingFactor.value+1,isRelative:!1}:this._currentContext.charTrackingFactor={value:e.changes.charTrackingFactor.value,isRelative:!1});break;case"p":e.changes.paragraph&&(e.changes.paragraph.align&&(this._currentHorizontalAlignment=e.changes.paragraph.align),typeof e.changes.paragraph.indent=="number"&&(this._currentIndent=e.changes.paragraph.indent*this.defaultFontSize,this._hOffset+=this._currentIndent),typeof e.changes.paragraph.left=="number"&&(this._currentLeftMargin=e.changes.paragraph.left*this.defaultFontSize),typeof e.changes.paragraph.right=="number"&&(this._currentRightMargin=e.changes.paragraph.right*this.defaultFontSize));break;case"L":this._currentContext.underline=!0;break;case"l":this._currentContext.underline=!1;break;case"O":this._currentContext.overline=!0;break;case"o":this._currentContext.overline=!1;break;case"K":this._currentContext.strikeThrough=!0;break;case"k":this._currentContext.strikeThrough=!1;break;case"Q":e.changes.oblique!==void 0&&(this._currentContext.oblique=e.changes.oblique);break}}resetParagraphProperties(){this._currentIndent=0,this._currentLeftMargin=0,this._currentRightMargin=0,this._currentHorizontalAlignment=this._options.horizontalAlignment}startNewParagraph(e,r,n){this.processGeometries(e,r,n),this.startNewLine(),this.resetParagraphProperties()}processText(e){const r=[],n=[],a=new R.Group;for(const s of e)if(s.type===ze.NEW_PARAGRAPH)this.startNewParagraph(r,n,a);else if(s.type===ze.WORD){const i=s.data;Array.isArray(i)?i.forEach(o=>this.processWord(o,r,n)):typeof i=="string"&&i.length>0&&this.processWord(i,r,n)}else if(s.type===ze.SPACE)this.processBlank();else if(s.type===ze.PROPERTIES_CHANGED){this.processGeometries(r,n,a);const i=s.data;i.command===void 0?this._contextStack.length>0&&(this._currentContext=this._contextStack.pop()):(i.depth>0&&this._contextStack.push(this._currentContext.clone()),this.processFormat(i))}else s.type===ze.STACK&&(this.processStack(s.data,r,n),this.processGeometries(r,n,a));return(r.length>0||n.length>0)&&this.processGeometries(r,n,a),this.processLastLine(),a}processGeometries(e,r,n){if(e.length>0||r.length>0){const a=this.toThreeObject(e,r);n.add(a),this._currentLineObjects.push(a),e.length=0,r.length=0}}processWord(e,r,n){let a=0;for(let s=0;s<e.length;s++){const i=this.getCharShape(e[s]);i?this.currentHorizontalAlignment==fe.DISTRIBUTED?a+=i.width*this.currentWidthFactor:a+=i.width*this.currentWordSpace*this.currentWidthFactor:a+=this._currentContext.blankWidth}this.hOffset+a>(this.maxLineWidth||1/0)&&this.startNewLine();for(let s=0;s<e.length;s++)this.processChar(e[s],r,n)}processStack(e,r,n){const[a,s,i]=e,o=this._hOffset,u=this._vOffset,l=this._currentContext.charTrackingFactor.value,c=this._currentContext.fontSize,f=this._currentContext.fontSizeScaleFactor;this._hOffset=o,this._currentContext.charTrackingFactor={value:1,isRelative:!1};let h=0;for(let y=0;y<a.length;y++){const S=this.getCharShape(a[y]);S&&(h+=S.width*this.currentWidthFactor)}this._hOffset=o;let p=0;for(let y=0;y<s.length;y++){const S=this.getCharShape(s[y]);S&&(p+=S.width*this.currentWidthFactor)}const d=Math.max(h,p),m=(d-h)/2,b=(d-p)/2;if(i==="^"){if(this._currentContext.fontSizeScaleFactor=f*.7,this.calcuateLineParams(),a&&!s){const y=[],S=[];this._hOffset=o,this._vOffset=u+c*.1;for(let x=0;x<a.length;x++)this.processChar(a[x],y,S);r.push(...y),n.push(...S),this._hOffset=o+h}else if(!a&&s){const y=[],S=[];this._hOffset=o,this._vOffset=u-c*.6;for(let x=0;x<s.length;x++)this.processChar(s[x],y,S);r.push(...y),n.push(...S),this._hOffset=o+p}this._currentContext.fontSizeScaleFactor=f,this.calcuateLineParams()}else{const y=[],S=[];this._hOffset=o+m,this._vOffset=u+this.currentFontSize*.3;for(let k=0;k<a.length;k++)this.processChar(a[k],y,S);r.push(...y),n.push(...S);const x=[],C=[];this._hOffset=o+b,this._vOffset=u-this.currentFontSize*.6;for(let k=0;k<s.length;k++)this.processChar(s[k],x,C);if(r.push(...x),n.push(...C),i==="/"||i==="#"){const k=new R.BufferGeometry,A=new Float32Array([o,u-this.currentFontSize*.8,0,o+d,u-this.currentFontSize*.8,0]);k.setAttribute("position",new R.BufferAttribute(A,3)),k.setIndex(null),n.push(k)}this._hOffset=o+d}this._vOffset=u,this._currentContext.charTrackingFactor={value:l,isRelative:!1}}processBlank(){this._hOffset+=this._currentContext.blankWidth}processChar(e,r,n){const a=this.getCharShape(e);if(!a){this.processBlank();return}let s=a.toGeometry();s.scale(this.currentWidthFactor,1,1);let i=this._currentContext.oblique;if(this._currentContext.italic&&(i+=15),i){const d=i*Math.PI/180,m=new R.Matrix4;m.set(1,Math.tan(d),0,0,0,1,0,0,0,0,1,0,0,0,0,1),s.applyMatrix4(m)}const o=this.fontManager.getFontType(this.currentFont);this._currentContext.bold&&o==="mesh"&&s.scale(1.06,1.06,1),this.hOffset>(this.maxLineWidth||1/0)&&this.startNewLine();let u=this.hOffset,l=this.flowDirection==He.BOTTOM_TO_TOP?this.vOffset:this.vOffset-this.currentFontSize,c=a.width*this.currentWidthFactor,f=this.currentFontSize;s.translate(u,l,0),this.currentHorizontalAlignment==fe.DISTRIBUTED?this._hOffset+=a.width*this.currentWidthFactor:this._hOffset+=a.width*this.currentWordSpace*this.currentWidthFactor,r.push(s);const h=f*.05,p=.001;if(this._currentContext.underline){const d=new R.BufferGeometry,m=l-h;d.setAttribute("position",new R.BufferAttribute(new Float32Array([u,m,p,u+c,m,p]),3)),d.setIndex(null),n.push(d)}if(this._currentContext.overline){const d=new R.BufferGeometry,m=l+f+h;d.setAttribute("position",new R.BufferAttribute(new Float32Array([u,m,p,u+c,m,p]),3)),d.setIndex(null),n.push(d)}if(this._currentContext.strikeThrough){const d=new R.BufferGeometry,m=l+f/2-f*.2;d.setAttribute("position",new R.BufferAttribute(new Float32Array([u,m,p,u+c,m,p]),3)),d.setIndex(null),n.push(d)}}processLastLine(){this.processAlignment()}initLineParams(){this.calcuateLineParams()}changeFont(e){let r=e;this._options.removeFontExtension&&(r=e.replace(/\.(ttf|otf|woff|shx)$/,"")),this._currentContext.fontFace.family=this.fontManager.findAndReplaceFont(r),this._currentContext.blankWidth=this.calculateBlankWidthForFont(this._currentContext.fontFace.family,this._currentContext.fontSize),this.calcuateLineParams()}calcuateLineParams(e){this._currentContext.fontScaleFactor=this.fontManager.getFontScaleFactor(this.currentFont);const r=e||this.defaultFontSize||this.textStyle.fixedTextHeight;this._currentContext.fontSize=r*this._currentContext.fontScaleFactor*this._currentContext.fontSizeScaleFactor}getCharShape(e){let r=this.fontManager.getCharShape(e,this.currentFont,this.currentFontSize);return this.textStyle.bigFont&&!r&&(r=this.fontManager.getCharShape(e,this.textStyle.bigFont,this.currentFontSize)),r||(r=this.fontManager.getCharShape(e,"",this.currentFontSize)),r||(r=this.fontManager.getNotFoundTextShape(this.currentFontSize)),this.currentFontSize>this._maxFontSize&&(this._maxFontSize=this.currentFontSize),r}startNewLine(){this._hOffset=0,this.flowDirection==He.BOTTOM_TO_TOP?this._vOffset+=this.currentLineHeight:this._vOffset-=this.currentLineHeight,this._lineCount++,this.processAlignment(),this._currentLineObjects=[],this._lineCount==2?this._totalHeight=this.currentMaxFontSize:this._totalHeight=this._totalHeight+this.currentLineHeight,this._maxFontSize=0}processAlignment(){const e=[];if(this.currentLineObjects.forEach(n=>n.traverse(a=>{"geometry"in a&&e.push(a.geometry)})),e.length==0)return;let r;if(e.forEach((n,a)=>{n.boundingBox||n.computeBoundingBox(),a===0?r=n.boundingBox:r.union(n.boundingBox)}),r){const n=r.getSize(wl);switch(this.currentHorizontalAlignment){case fe.LEFT:e.forEach(a=>a.translate(this._currentLeftMargin-r.min.x,0,0));break;case fe.CENTER:e.forEach(a=>a.translate(this._currentLeftMargin+(this.maxLineWidth-n.x)/2-r.min.x,0,0));break;case fe.RIGHT:e.forEach(a=>a.translate(this._currentLeftMargin+this.maxLineWidth-n.x-r.min.x,0,0));break;case fe.DISTRIBUTED:if(e.length>1){const a=(this.maxLineWidth-n.x)/(e.length-1);for(let s=1;s<e.length;s++)e[s].translate(a*s,0,0)}e.forEach(a=>a.translate(this._currentLeftMargin-r.min.x,0,0));break}}}calculateBlankWidthForFont(e,r){return this.fontManager.getFontType(e)==="shx"?r*.5:r*.3}toThreeObject(e,r){const n=new R.Group,a=this._currentContext.getColorAsHex(),s=e.filter(o=>o instanceof R.ExtrudeGeometry);if(s.length>0){const o=new R.Mesh;o.geometry=Mr(s),o.material=this.styleManager.getMeshBasicMaterial(a),o.userData.bboxIntersectionCheck=!0,n.add(o)}const i=[...r,...e.filter(o=>!(o instanceof R.ExtrudeGeometry))];if(i.length>0){const o=new R.LineSegments;o.geometry=Mr(i),o.material=this.styleManager.getLineBasicMaterial(a),o.userData.bboxIntersectionCheck=!0,n.add(o)}return n.children.length===1?n.children[0]:n}changeFontSizeScaleFactor(e){this._currentContext.fontSizeScaleFactor*=e,this.calcuateLineParams()}changeFontHeight(e){this._currentContext.fontSize=e*this._currentContext.fontScaleFactor*this._currentContext.fontSizeScaleFactor,this.calcuateLineParams()}}const gr=new R.Vector3,Pe=new R.Vector3,vr=new R.Vector3,mr=new R.Quaternion,yr=new R.Matrix4,ba=new R.Matrix4,xa=new R.Vector3(1,0,0);class Sa extends R.Object3D{static getFonts(e,r=!1){return kl(e,r)}constructor(e,r,n,a,s={byLayerColor:16777215,byBlockColor:16777215}){super(),this._style=r,this._styleManager=n,this._fontManager=a,this._colorSettings={byLayerColor:s.byLayerColor,byBlockColor:s.byBlockColor},this._box=new R.Box3,this._boxes=[];const i=this.loadMText(e,r);i&&(this.getBoxes(i,this._boxes),this._boxes.forEach(o=>this.box.union(o)),this.add(i))}get fontManager(){return this._fontManager}get styleManager(){return this._styleManager}get textStyle(){return this._style}get box(){return this._box}set box(e){this._box.copy(e)}raycast(e,r){this._boxes.forEach(n=>{if(e.ray.intersectBox(n,gr)){const a=e.ray.origin.distanceTo(gr);r.push({distance:a,point:gr.clone(),object:this,face:null,faceIndex:void 0,uv:void 0})}})}loadMText(e,r){const{object:n,height:a}=this.createMTextGroup(e,r);if(!n)return;n.matrix.decompose(Pe,mr,vr),e.position&&(Pe.x+=e.position.x,Pe.y+=e.position.y,n.matrix.compose(Pe,mr,vr));const s=e.width,i=this.calculateAnchorPoint(s,a,e.attachmentPoint,e.drawingDirection);n.traverse(l=>{"geometry"in l&&l.geometry.translate(i.x,i.y,0),l.layers.enableAll()});let o=e.rotation||0;if(e.directionVector){const l=e.directionVector,c=new R.Vector3(l.x,l.y,l.z),f=c.clone().cross(xa),h=xa.angleTo(c);o=f.z>0?-h:h}n.matrix.compose(Pe,mr,vr);const u=e.position?Pe.clone().sub(e.position):Pe;return yr.makeTranslation(-u.x,-u.y,0),ba.makeRotationZ(o),n.matrix.multiply(yr),n.matrix.multiply(ba),n.matrix.multiply(yr.invert()),n.matrix.decompose(n.position,n.quaternion,n.scale),n}createMTextGroup(e,r){if(r&&r.font&&r.font.endsWith(".shx")){const m=`${r.font}_${r.name}`;this.styleManager.unsupportedTextStyles[m]||(this.styleManager.unsupportedTextStyles[m]=0),this.styleManager.unsupportedTextStyles[m]++}const n=e.width||0;let a=fe.LEFT;e.width&&e.attachmentPoint&&([1,4,7].includes(e.attachmentPoint)?a=fe.LEFT:[2,5,8].includes(e.attachmentPoint)?a=fe.CENTER:[3,6,9].includes(e.attachmentPoint)&&(a=fe.RIGHT));let s=rt.BOTTOM;e.attachmentPoint&&([1,2,3].includes(e.attachmentPoint)?s=rt.TOP:[4,5,6].includes(e.attachmentPoint)?s=rt.MIDDLE:[7,8,9].includes(e.attachmentPoint)&&(s=rt.BOTTOM));const i=e.height||0,o=e.lineSpaceFactor||.3,u=e.drawingDirection??He.LEFT_TO_RIGHT,l={fontSize:i,widthFactor:e.widthFactor??1,lineSpaceFactor:o,horizontalAlignment:a,maxWidth:n,flowDirection:u,byBlockColor:this._colorSettings.byBlockColor,byLayerColor:this._colorSettings.byLayerColor,removeFontExtension:!0},c=new nt;c.fontFace.family=r.font,c.capHeight={value:e.height||1,isRelative:!0},c.widthFactor={value:e.widthFactor??1,isRelative:!0},c.align=s,c.paragraph.align=a;const f=new El(r,this.styleManager,this.fontManager,l),p=new Tl(e.text,c,{resetParagraphParameters:!0,yieldPropertyCommands:!0}).parse();return{object:f.processText(p),height:f.totalHeight}}calculateAnchorPoint(e,r,n,a){let s=0,i=0;switch(n){case void 0:case 1:s=0,i=0;break;case 2:s-=e/2,i=0;break;case 3:s-=e,i=0;break;case 4:s=0,i+=r/2;break;case 5:s-=e/2,i+=r/2;break;case 6:s-=e,i+=r/2;break;case 7:s=0,i+=r;break;case 8:s-=e/2,i+=r;break;case 9:s-=e,i+=r;break}return a==He.BOTTOM_TO_TOP&&(i-=r),{x:s,y:i}}getBoxes(e,r){if(e.updateWorldMatrix(!1,!1),e instanceof R.Line||e instanceof R.Mesh){const a=e.geometry;a.boundingBox===null&&a.computeBoundingBox();const s=new R.Box3().copy(a.boundingBox);s.applyMatrix4(e.matrixWorld),r.push(s)}const n=e.children;for(let a=0,s=n.length;a<s;a++)this.getBoxes(n[a],r)}}class ka{constructor(){this.lineBasicMaterials={},this.meshBasicMaterials={},this.unsupportedTextStyles={}}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new R.MeshBasicMaterial({color:e})),this.meshBasicMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new R.LineBasicMaterial({color:e})),this.lineBasicMaterials[e]}}class br{constructor(e=Math.max(1,navigator.hardwareConcurrency?Math.min(4,navigator.hardwareConcurrency):2)){this.workers=[],this.inFlightPerWorker=[],this.pendingRequests=new Map,this.requestId=0,this.readyPromise=null,this.poolSize=e;for(let r=0;r<this.poolSize;r++){const n=new Worker(new URL("/assets/mtextWorker-BlkfNPdt.js",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:St&&St.tagName.toUpperCase()==="SCRIPT"&&St.src||new URL("index.umd.cjs",document.baseURI).href),{type:"module"});this.attachWorkerHandlers(n,r),this.workers.push(n),this.inFlightPerWorker.push(0)}this.ensureInitialized()}handleWorkerMessage(e){const{id:r,success:n,data:a,error:s}=e,i=this.pendingRequests.get(r);if(i){this.pendingRequests.delete(r);const{workerIndex:o}=i;this.inFlightPerWorker[o]=Math.max(0,this.inFlightPerWorker[o]-1),n?i.resolve(a):i.reject(new Error(s||"Unknown worker error"))}}attachWorkerHandlers(e,r){e.onmessage=n=>{this.handleWorkerMessage(n.data)},e.onerror=n=>{console.error("Worker error:",n);const a=[];this.pendingRequests.forEach((s,i)=>{s.workerIndex===r&&a.push(i)}),a.forEach(s=>{const i=this.pendingRequests.get(s);i&&(i.reject(new Error("Worker error occurred")),this.pendingRequests.delete(s))}),this.inFlightPerWorker[r]=0}}pickLeastLoadedWorker(){let e=0,r=this.inFlightPerWorker[0]??0;for(let n=1;n<this.inFlightPerWorker.length;n++){const a=this.inFlightPerWorker[n]??0;a<r&&(r=a,e=n)}return e}sendMessage(e,r){const n=this.pickLeastLoadedWorker(),a=this.workers[n];return new Promise((s,i)=>{const o=`req_${++this.requestId}`;this.pendingRequests.set(o,{resolve:u=>s(u),reject:i,workerIndex:n}),this.inFlightPerWorker[n]=(this.inFlightPerWorker[n]??0)+1,a.postMessage({type:e,id:o,data:r}),setTimeout(()=>{this.pendingRequests.get(o)&&(this.pendingRequests.delete(o),this.inFlightPerWorker[n]=Math.max(0,this.inFlightPerWorker[n]-1),i(new Error("Worker request timeout")))},3e4)})}ensureInitialized(){return this.readyPromise?this.readyPromise:this.workers.length===0?Promise.resolve():(this.readyPromise=Promise.all(this.workers.map((e,r)=>new Promise((n,a)=>{const s=`req_${++this.requestId}`;this.pendingRequests.set(s,{resolve:()=>n(),reject:a,workerIndex:r}),this.inFlightPerWorker[r]=(this.inFlightPerWorker[r]??0)+1,e.postMessage({type:"getAvailableFonts",id:s}),setTimeout(()=>{this.pendingRequests.get(s)&&(this.pendingRequests.delete(s),this.inFlightPerWorker[r]=Math.max(0,this.inFlightPerWorker[r]-1),a(new Error("Worker init timeout")))},3e4)}))).then(()=>{}),this.readyPromise)}async renderMText(e,r,n={byLayerColor:16777215,byBlockColor:16777215}){await this.ensureInitialized();const a=await this.sendMessage("render",{mtextContent:e,textStyle:r,colorSettings:n});return this.reconstructMText(a)}async loadFonts(e){await this.ensureInitialized();const r=await Promise.all(this.workers.map((a,s)=>new Promise((i,o)=>{const u=`req_${++this.requestId}`;this.pendingRequests.set(u,{resolve:l=>i(l),reject:o,workerIndex:s}),this.inFlightPerWorker[s]=(this.inFlightPerWorker[s]??0)+1,a.postMessage({type:"loadFonts",id:u,data:{fonts:e}}),setTimeout(()=>{this.pendingRequests.get(u)&&(this.pendingRequests.delete(u),this.inFlightPerWorker[s]=Math.max(0,this.inFlightPerWorker[s]-1),o(new Error("Worker request timeout")))},3e4)}))),n=new Set;return r.forEach(a=>{var s;return(s=a.loaded)==null?void 0:s.forEach(i=>n.add(i))}),{loaded:Array.from(n)}}async getAvailableFonts(){if(this.workers.length===0)return{fonts:[]};await this.ensureInitialized();const e=0,r=this.workers[e];return new Promise((n,a)=>{const s=`req_${++this.requestId}`;this.pendingRequests.set(s,{resolve:i=>n(i),reject:a,workerIndex:e}),this.inFlightPerWorker[e]=(this.inFlightPerWorker[e]??0)+1,r.postMessage({type:"getAvailableFonts",id:s}),setTimeout(()=>{this.pendingRequests.get(s)&&(this.pendingRequests.delete(s),this.inFlightPerWorker[e]=Math.max(0,this.inFlightPerWorker[e]-1),a(new Error("Worker request timeout")))},3e4)})}reconstructMText(e){const r=new R.Group;return e.children.forEach(n=>{const a=new R.BufferGeometry;if(Object.keys(n.geometry.attributes).forEach(o=>{const u=n.geometry.attributes[o],l=new Float32Array(u.arrayBuffer,u.byteOffset,u.length),c=new R.BufferAttribute(l,u.itemSize,u.normalized);a.setAttribute(o,c)}),n.geometry.index)if(n.geometry.index.componentType==="uint32"){const u=new Uint32Array(n.geometry.index.arrayBuffer,n.geometry.index.byteOffset,n.geometry.index.length);a.setIndex(new R.Uint32BufferAttribute(u,1))}else{const u=new Uint16Array(n.geometry.index.arrayBuffer,n.geometry.index.byteOffset,n.geometry.index.length);a.setIndex(new R.Uint16BufferAttribute(u,1))}let s;n.type==="mesh"?s=new R.MeshBasicMaterial({color:n.material.color,transparent:n.material.transparent,opacity:n.material.opacity,side:n.material.side}):s=new R.LineBasicMaterial({color:n.material.color,transparent:n.material.transparent,opacity:n.material.opacity,linewidth:n.material.linewidth});let i;n.type==="mesh"?i=new R.Mesh(a,s):i=new R.Line(a,s),a.boundingBox||a.computeBoundingBox(),a.boundingSphere||a.computeBoundingSphere(),i.position.set(n.position.x,n.position.y,n.position.z),i.quaternion.set(n.rotation.x,n.rotation.y,n.rotation.z,n.rotation.w),i.scale.set(n.scale.x,n.scale.y,n.scale.z),r.add(i)}),r.box=new R.Box3(new R.Vector3(e.box.min.x,e.box.min.y,e.box.min.z),new R.Vector3(e.box.max.x,e.box.max.y,e.box.max.z)),r}terminate(){this.workers.forEach(e=>e.terminate()),this.workers=[],this.inFlightPerWorker=[],this.readyPromise=null,this.pendingRequests.forEach(({reject:e})=>{e(new Error("Renderer terminated"))}),this.pendingRequests.clear()}destroy(){this.terminate()}}class Fa{constructor(){this.fontManager=xe.instance,this.styleManager=new ka,this.fontLoader=new ma,this.fontManager.defaultFont="simkai"}async renderMText(e,r,n={byLayerColor:16777215,byBlockColor:16777215}){const a=new Sa(e,r,this.styleManager,this.fontManager,n);return a.updateMatrixWorld(!0),a}async loadFonts(e){return await this.fontLoader.load(e),{loaded:e}}async getAvailableFonts(){return{fonts:await this.fontLoader.getAvaiableFonts()}}destroy(){}}class Ol{constructor(e="main"){this.workerManager=null,this.currentMode=e,this.mainThreadRenderer=new Fa,this.adapter=this.mainThreadRenderer,e==="worker"&&(this.workerManager=new br,this.adapter=this.workerManager)}switchMode(e){this.currentMode!==e&&(this.currentMode==="worker"&&this.workerManager&&(this.workerManager.terminate(),this.workerManager=null),this.currentMode=e,e==="worker"?(this.workerManager=new br,this.adapter=this.workerManager):this.adapter=this.mainThreadRenderer)}getMode(){return this.currentMode}async renderMText(e,r,n={byLayerColor:16777215,byBlockColor:16777215}){return this.adapter.renderMText(e,r,n)}async loadFonts(e){return this.adapter.loadFonts(e)}async getAvailableFonts(){return this.adapter.getAvailableFonts()}destroy(){this.workerManager&&(this.workerManager.terminate(),this.workerManager=null),this.mainThreadRenderer.destroy()}}v.BaseFont=Ft,v.BaseTextShape=Tt,v.DefaultFontLoader=ma,v.EventManager=kt,v.FontFactory=be,v.FontManager=xe,v.MText=Sa,v.MTextAttachmentPoint=ya,v.MTextFlowDirection=He,v.MainThreadRenderer=Fa,v.StyleManager=ka,v.UnifiedRenderer=Ol,v.WebWorkerRenderer=br,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
package/lib/worker/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export type { MTextData, TextStyle, ColorSettings } from '../renderer/types';
|
|
1
|
+
export * from './webWorkerRenderer';
|
|
2
|
+
export * from './mainThreadRenderer';
|
|
3
|
+
export * from './unifiedRenderer';
|
|
4
|
+
export * from './unifiedRenderer';
|
|
5
|
+
export * from './baseRenderer';
|