@mylasertools/kerfscript 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,15 +1,15 @@
1
1
  /*! @mylasertools/kerfscript | (c) MyLaserTools | AGPL-3.0-only or commercial licence, see COMMERCIAL-LICENSE.md. Includes Clipper2 (BSL-1.0), opentype.js, tiny-inflate and string.prototype.codepointat (MIT), see THIRD-PARTY-NOTICES.md. */
2
- "use strict";var Jt=Object.defineProperty;var no=Object.getOwnPropertyDescriptor;var so=Object.getOwnPropertyNames;var io=Object.prototype.hasOwnProperty;var oo=(r,e,t)=>e in r?Jt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ao=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),uo=(r,e)=>{for(var t in e)Jt(r,t,{get:e[t],enumerable:!0})},lo=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of so(e))!io.call(r,s)&&s!==t&&Jt(r,s,{get:()=>e[s],enumerable:!(n=no(e,s))||n.enumerable});return r};var fo=r=>lo(Jt({},"__esModule",{value:!0}),r);var b=(r,e,t)=>oo(r,typeof e!="symbol"?e+"":e,t);var gs=ao((ip,ds)=>{ds.exports={}});var vh={};uo(vh,{DEFAULT_LAYERS:()=>An,DEFAULT_LIMITS:()=>Dn,KerfError:()=>R,LANGUAGE_VERSION:()=>gh,VERSION:()=>dh,parameters:()=>ro,parse:()=>Je,render:()=>Qi,tokenize:()=>yr});module.exports=fo(vh);var Be=r=>typeof r=="object"&&r!==null&&!Array.isArray(r)&&r.type==="range",_e=r=>typeof r=="object"&&r!==null&&!Array.isArray(r)&&r.type==="function",Hn=r=>typeof r=="number";function er(r,e){let t=[];if(r.step===0||(r.step>0?r.start>r.end:r.start<r.end))return t;let n=Math.floor((r.end-r.start)/r.step+1e-9)+1;if(n>e)throw new Error(`Range has ${n} steps, more than the limit of ${e}`);for(let s=0;s<n;s++)t.push(r.start+s*r.step);return t}function Se(r){return r===void 0||r===!1||r===0||r===""?!1:Array.isArray(r)?r.length>0:typeof r=="number"?!Number.isNaN(r):!0}function at(r,e){return Array.isArray(r)&&Array.isArray(e)?r.length===e.length&&r.every((t,n)=>at(t,e[n])):Be(r)&&Be(e)?r.start===e.start&&r.step===e.step&&r.end===e.end:r===e}function Pe(r){return r===void 0?"undef":Array.isArray(r)?"list":Be(r)?"range":_e(r)?"function":typeof r}function Le(r){return r===void 0?"undef":typeof r=="string"?JSON.stringify(r):typeof r=="number"?Qt(r):Array.isArray(r)?`[${r.map(Le).join(", ")}]`:Be(r)?`[${Qt(r.start)}:${Qt(r.step)}:${Qt(r.end)}]`:_e(r)?`function(${r.params.map(e=>e.name).join(", ")})`:String(r)}function tr(r){return typeof r=="string"?r:Le(r)}function Qt(r){return Number.isInteger(r)?String(r):String(Number(r.toPrecision(10)))}var ut=Math.PI/180;function $(r,e){if(typeof r!="number")throw new Error(`${e}() needs a number, got ${Pe(r)}`);return r}function Ge(r,e){if(Array.isArray(r))return r;if(Be(r))return er(r,1e6);if(typeof r=="string")return[...r];throw new Error(`${e}() needs a list, got ${Pe(r)}`)}var we=(r,e)=>t=>typeof t[0]=="number"?Gr(e(t[0])):void 0;function Gr(r){let e=Math.round(r);return Math.abs(r-e)<1e-12?e:r}function ho(r){let e=Math.floor(r)>>>0||2654435769;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function zn(r,e,t){let n=r.length===1&&Array.isArray(r[0])?r[0]:r;if(n.length)return e(n.map(s=>$(s,t)))}var Vn={abs:we("abs",Math.abs),sign:we("sign",Math.sign),floor:we("floor",Math.floor),ceil:we("ceil",Math.ceil),round:we("round",r=>r<0?-Math.round(-r):Math.round(r)),sqrt:we("sqrt",Math.sqrt),exp:we("exp",Math.exp),ln:we("ln",Math.log),log:r=>r.length===2?Math.log($(r[1],"log"))/Math.log($(r[0],"log")):Gr(Math.log10($(r[0],"log"))),sin:we("sin",r=>Math.sin(r*ut)),cos:we("cos",r=>Math.cos(r*ut)),tan:we("tan",r=>Math.tan(r*ut)),asin:we("asin",r=>Math.asin(r)/ut),acos:we("acos",r=>Math.acos(r)/ut),atan:we("atan",r=>Math.atan(r)/ut),atan2:r=>Gr(Math.atan2($(r[0],"atan2"),$(r[1],"atan2"))/ut),pow:r=>Math.pow($(r[0],"pow"),$(r[1],"pow")),min:r=>zn(r,e=>e.reduce((t,n)=>n<t?n:t,1/0),"min"),max:r=>zn(r,e=>e.reduce((t,n)=>n>t?n:t,-1/0),"max"),clamp:r=>Math.min(Math.max($(r[0],"clamp"),$(r[1],"clamp")),$(r[2],"clamp")),lerp:r=>{let e=$(r[2],"lerp");if(Array.isArray(r[0])&&Array.isArray(r[1])){let t=r[1];return r[0].map((n,s)=>$(n,"lerp")+($(t[s],"lerp")-$(n,"lerp"))*e)}return $(r[0],"lerp")+($(r[1],"lerp")-$(r[0],"lerp"))*e},norm:r=>Math.sqrt(Ge(r[0],"norm").reduce((e,t)=>e+$(t,"norm")**2,0)),cross:r=>{let e=Ge(r[0],"cross").map(n=>$(n,"cross")),t=Ge(r[1],"cross").map(n=>$(n,"cross"));return e.length===2?e[0]*t[1]-e[1]*t[0]:[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]},len:r=>typeof r[0]=="string"?[...r[0]].length:Array.isArray(r[0])?r[0].length:void 0,concat:r=>r.flatMap(e=>Array.isArray(e)?e:[e]),reverse:r=>typeof r[0]=="string"?[...r[0]].reverse().join(""):[...Ge(r[0],"reverse")].reverse(),sum:r=>Ge(r[0],"sum").reduce((e,t)=>e+$(t,"sum"),0),slice:r=>{let t=(typeof r[0]=="string"?[...r[0]]:Ge(r[0],"slice")).slice($(r[1]??0,"slice"),r[2]===void 0?void 0:$(r[2],"slice"));return typeof r[0]=="string"?t.join(""):t},str:r=>r.map(tr).join(""),chr:r=>r.flatMap(e=>Array.isArray(e)?e:[e]).map(e=>String.fromCodePoint($(e,"chr"))).join(""),ord:r=>typeof r[0]=="string"&&r[0].length?r[0].codePointAt(0):void 0,upper:r=>typeof r[0]=="string"?r[0].toUpperCase():void 0,lower:r=>typeof r[0]=="string"?r[0].toLowerCase():void 0,split:r=>typeof r[0]=="string"?r[0].split(typeof r[1]=="string"?r[1]:" "):void 0,join:r=>Ge(r[0],"join").map(tr).join(typeof r[1]=="string"?r[1]:""),search:r=>{let t=(typeof r[1]=="string"?[...r[1]]:Ge(r[1],"search")).findIndex(n=>at(n,r[0]));return t<0?void 0:t},contains:r=>typeof r[0]=="string"?r[0].includes(tr(r[1])):Ge(r[0],"contains").some(e=>at(e,r[1])),lookup:r=>{let e=$(r[0],"lookup"),t=Ge(r[1],"lookup");if(!t.length)return;let n=t.map(s=>[$(s[0],"lookup"),$(s[1],"lookup")]).sort((s,i)=>s[0]-i[0]);if(e<=n[0][0])return n[0][1];for(let s=1;s<n.length;s++)if(e<=n[s][0]){let[i,o]=n[s-1],[a,u]=n[s];return o+(e-i)/(a-i)*(u-o)}return n[n.length-1][1]},rands:r=>{let e=$(r[0],"rands"),t=$(r[1],"rands"),n=$(r[2],"rands"),s=ho(r[3]===void 0?1:$(r[3],"rands"));return Array.from({length:Math.min(Math.max(0,Math.floor(n)),1e6)},()=>e+(t-e)*s())},is_num:r=>Hn(r[0])&&!Number.isNaN(r[0]),is_string:r=>typeof r[0]=="string",is_bool:r=>typeof r[0]=="boolean",is_list:r=>Array.isArray(r[0]),is_undef:r=>r[0]===void 0,is_function:r=>_e(r[0]),type_of:r=>Pe(r[0])};var j;(function(r){r[r.NoClip=0]="NoClip",r[r.Intersection=1]="Intersection",r[r.Union=2]="Union",r[r.Difference=3]="Difference",r[r.Xor=4]="Xor"})(j||(j={}));var me;(function(r){r[r.Subject=0]="Subject",r[r.Clip=1]="Clip"})(me||(me={}));var V;(function(r){r[r.EvenOdd=0]="EvenOdd",r[r.NonZero=1]="NonZero",r[r.Positive=2]="Positive",r[r.Negative=3]="Negative"})(V||(V={}));var q;(function(r){r[r.IsOn=0]="IsOn",r[r.IsInside=1]="IsInside",r[r.IsOutside=2]="IsOutside"})(q||(q={}));var xt=Number.MAX_SAFE_INTEGER,oe=Math.floor(Math.sqrt(xt));function rr(r,e){return!Number.isSafeInteger(r)||!Number.isSafeInteger(e)?!1:r===0||e===0?!0:Math.abs(r)<=xt/Math.abs(e)}function Xn(r,e){return Math.abs(r)+Math.abs(e)<=xt}function Hr(r,e,t,n){if(rr(r,e)&&rr(t,n)){let s=r*e,i=t*n;if(Xn(s,i))return s-i}return Number.isSafeInteger(r)&&Number.isSafeInteger(e)&&Number.isSafeInteger(t)&&Number.isSafeInteger(n)?Number(BigInt(r)*BigInt(e)-BigInt(t)*BigInt(n)):r*e-t*n}function zr(r,e,t,n){if(rr(r,e)&&rr(t,n)){let s=r*e,i=t*n;if(Xn(s,i))return s+i}return Number.isSafeInteger(r)&&Number.isSafeInteger(e)&&Number.isSafeInteger(t)&&Number.isSafeInteger(n)?Number(BigInt(r)*BigInt(e)+BigInt(t)*BigInt(n)):r*e+t*n}var Vr=BigInt(0),nr=BigInt(2),co=BigInt(4),po=BigInt(64),go=BigInt("0xFFFFFFFFFFFFFFFF"),Wr=BigInt("9223372036854775807"),Ct=Number(Wr/co),qn=Number(Wr),Wn=1e-12,vo=.1,Xr=Math.floor(oe/2),mo=Math.floor(Math.sqrt(Math.sqrt(xt/4)));function xo(r){if(!Number.isFinite(r))throw new RangeError("Scale must be a finite number");let e=Math.abs(r);return e===0?Number.POSITIVE_INFINITY:xt/e}function yo(r,e,t){if(!Number.isFinite(r)||Math.abs(r)>e)throw new RangeError(`Scaled coordinate exceeds Number.MAX_SAFE_INTEGER in ${t}`)}function bo(r,e){if(!Number.isFinite(r)||Math.abs(r)>xt)throw new RangeError(`Coordinate exceeds Number.MAX_SAFE_INTEGER in ${e}`)}function So(r,e,t){let n=e.x-r.x,s=t.y-e.y,i=e.y-r.y,o=t.x-e.x;return Math.abs(n)<oe&&Math.abs(s)<oe&&Math.abs(i)<oe&&Math.abs(o)<oe?n*s-i*o:Hr(n,s,i,o)}function Ie(r,e,t){let n=e.x-r.x,s=t.y-e.y,i=e.y-r.y,o=t.x-e.x;if(Math.abs(n)<oe&&Math.abs(s)<oe&&Math.abs(i)<oe&&Math.abs(o)<oe){let l=n*s,f=i*o;return l>f?1:l<f?-1:0}if(!Number.isSafeInteger(n)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)){let l=n*s,f=i*o;return l>f?1:l<f?-1:0}let a=BigInt(n)*BigInt(s),u=BigInt(i)*BigInt(o);return a===u?0:a>u?1:-1}function wo(r){if(r<-8||r>8)throw new Error("Error: Precision is out of range.")}function ko(r){return Math.abs(r)<=Wn}function Eo(r){return r<0?-1:r>0?1:0}function Po(r,e){let t=BigInt(r),n=BigInt(e),s=t*n;return{lo64:s&go,hi64:s>>po}}function $n(r,e,t,n){let s=Math.abs(r),i=Math.abs(e),o=Math.abs(t),a=Math.abs(n);if(s<oe&&i<oe&&o<oe&&a<oe)return r*e===t*n;let u=(r<0?-1:r>0?1:0)*(e<0?-1:e>0?1:0),l=(t<0?-1:t>0?1:0)*(n<0?-1:n>0?1:0);if(u!==l)return!1;if(u===0)return!0;if(!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)||!Number.isSafeInteger(a))return r*e===t*n;let f=BigInt(s),c=BigInt(i),h=BigInt(o),p=BigInt(a);return f*c===h*p}function Lo(r,e,t){let n=e.x-r.x,s=t.y-e.y,i=e.y-r.y,o=t.x-e.x;return $n(n,s,i,o)}function Io(r,e,t){let n=e.x-r.x,s=t.x-e.x,i=e.y-r.y,o=t.y-e.y;return Math.abs(n)<oe&&Math.abs(s)<oe&&Math.abs(i)<oe&&Math.abs(o)<oe?n*s+i*o:zr(n,s,i,o)}function To(r,e,t){let n=e.x-r.x,s=t.x-e.x,i=e.y-r.y,o=t.y-e.y;if(Math.abs(n)<oe&&Math.abs(s)<oe&&Math.abs(i)<oe&&Math.abs(o)<oe){let u=n*s+i*o;return u>0?1:u<0?-1:0}if(!Number.isSafeInteger(n)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)){let u=n*s+i*o;return u>0?1:u<0?-1:0}let a=BigInt(n)*BigInt(s)+BigInt(i)*BigInt(o);return a===Vr?0:a>Vr?1:-1}function Co(r){let e=r.length;if(e<3)return 0;let t=!0;for(let i=0;i<e&&t;i++){let o=r[i];(Math.abs(o.x)>=Xr||Math.abs(o.y)>=Xr)&&(t=!1)}let n=r[e-1];if(t){let i=0;for(let o of r)i+=(n.y+o.y)*(n.x-o.x),n=o;return i*.5}let s=Vr;for(let i of r){let o=n.y+i.y,a=n.x-i.x;if(Number.isSafeInteger(o)&&Number.isSafeInteger(a))s+=BigInt(o)*BigInt(a);else if(Number.isSafeInteger(n.y)&&Number.isSafeInteger(i.y)&&Number.isSafeInteger(n.x)&&Number.isSafeInteger(i.x)){let u=BigInt(n.y)+BigInt(i.y),l=BigInt(n.x)-BigInt(i.x);s+=u*l}else s+=BigInt(Math.round(o*a));n=i}return Number(s)*.5}function Mo(r,e){return r.y*e.x-e.y*r.x}function Oo(r,e){return r.x*e.x+r.y*e.y}function Fo(r){let e=Math.round(r);return r===e-.5&&(e&1)!==0?e-1:e}function Ao(r){return r>=Ct||r<=-Ct?qn:Math.round(r)}function Do(r,e,t,n){let s=e.y-r.y,i=e.x-r.x,o=n.y-t.y,a=n.x-t.x,u=Hr(s,a,o,i);if(u===0)return null;let l=Hr(r.x-t.x,o,r.y-t.y,a)/u;return l<=0?{x:r.x,y:r.y,z:r.z||0}:l>=1?{x:e.x,y:e.y,z:e.z||0}:{x:Math.trunc(r.x+l*i),y:Math.trunc(r.y+l*s),z:0}}function Uo(r,e,t,n){let s=e.y-r.y,i=e.x-r.x,o=n.y-t.y,a=n.x-t.x,u=s*a-o*i;if(u===0)return{success:!1,ip:{x:0,y:0,z:0}};let l=((r.x-t.x)*o-(r.y-t.y)*a)/u,f;return l<=0?f={...r,z:0}:l>=1?f={...e,z:0}:f={x:r.x+l*i,y:r.y+l*s,z:0},{success:!0,ip:f}}function Ro(r,e,t,n,s=!1){if(!s){let l=Ie(r,t,n),f=Ie(e,t,n),c=Ie(t,r,e),h=Ie(n,r,e);return l!==0&&f!==0&&l!==f&&c!==0&&h!==0&&c!==h}let i=Ie(r,t,n),o=Ie(e,t,n);if(i!==0&&i===o)return!1;let a=Ie(t,r,e),u=Ie(n,r,e);return a!==0&&a===u?!1:i!==0||o!==0||a!==0||u!==0}function Zn(r){if(r.length===0)return{left:0,top:0,right:0,bottom:0};let e={left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER};for(let t of r)t.x<e.left&&(e.left=t.x),t.x>e.right&&(e.right=t.x),t.y<e.top&&(e.top=t.y),t.y>e.bottom&&(e.bottom=t.y);return e.left===Number.MAX_SAFE_INTEGER?{left:0,top:0,right:0,bottom:0}:e}function No(r,e,t){if(e.x===t.x&&e.y===t.y)return{x:e.x,y:e.y,z:0};let n=t.x-e.x,s=t.y-e.y,i=zr(r.x-e.x,n,r.y-e.y,s)/zr(n,n,s,s),o=i<0?0:i>1?1:i;return{x:Math.round(e.x+o*n),y:Math.round(e.y+o*s),z:0}}function qr(r,e){let t=e.length,n=0;if(t<3)return q.IsOutside;for(;n<t&&e[n].y===r.y;)n++;if(n===t)return q.IsOutside;let s=e[n].y<r.y,i=s,o=0,a=n+1,u=t;for(;;){if(a===u){if(u===0||n===0)break;u=n,a=0}if(s)for(;a<u&&e[a].y<r.y;)a++;else for(;a<u&&e[a].y>r.y;)a++;if(a===u)continue;let f=e[a],c=a>0?e[a-1]:e[t-1];if(f.y===r.y){if(f.x===r.x||f.y===c.y&&r.x<c.x!=r.x<f.x)return q.IsOn;if(a++,a===n)break;continue}if(!(r.x<f.x&&r.x<c.x))if(r.x>c.x&&r.x>f.x)o=1-o;else{let h=Ie(c,f,r);if(h===0)return q.IsOn;h<0===s&&(o=1-o)}s=!s,a++}if(s===i)return o===0?q.IsOutside:q.IsInside;a===t&&(a=0);let l=a===0?Ie(e[t-1],e[0],r):Ie(e[a-1],e[a],r);return l===0?q.IsOn:(l<0===s&&(o=1-o),o===0?q.IsOutside:q.IsInside)}function Bo(r,e){let t=q.IsOn;for(let a of r)switch(qr(a,e)){case q.IsOutside:if(t===q.IsOutside)return!1;t=q.IsOutside;break;case q.IsInside:if(t===q.IsInside)return!0;t=q.IsInside;break;default:break}let n=Zn(r),s,i;return Number.isSafeInteger(n.left)&&Number.isSafeInteger(n.right)&&Math.abs(n.left)+Math.abs(n.right)>Number.MAX_SAFE_INTEGER?(s=Number((BigInt(n.left)+BigInt(n.right))/nr),i=Number((BigInt(n.top)+BigInt(n.bottom))/nr)):(s=Math.round((n.left+n.right)/2),i=Math.round((n.top+n.bottom)/2)),qr({x:s,y:i},e)!==q.IsOutside}var z={MaxInt64:Wr,MaxCoord:Ct,max_coord:Ct,min_coord:-Ct,Invalid64:qn,floatingPointTolerance:Wn,defaultMinimumEdgeLength:vo,maxCoordForSafeAreaProduct:Xr,maxCoordForSafeCrossSq:mo,maxSafeCoordinateForScale:xo,checkSafeScaleValue:yo,ensureSafeInteger:bo,crossProduct:So,crossProductSign:Ie,checkPrecision:wo,isAlmostZero:ko,triSign:Eo,multiplyUInt64:Po,productsAreEqual:$n,isCollinear:Lo,dotProduct:Io,dotProductSign:To,area:Co,crossProductD:Mo,dotProductD:Oo,roundToEven:Fo,checkCastInt64:Ao,getLineIntersectPt:Do,getLineIntersectPtD:Uo,segsIntersect:Ro,getBounds:Zn,getClosestPtOnSegment:No,pointInPolygon:qr,path2ContainsPath1:Bo},He={create(r=0,e=0,t=0){return{x:Math.round(r),y:Math.round(e),z:t}},fromPointD(r){return z.ensureSafeInteger(r.x,"Point64Utils.fromPointD"),z.ensureSafeInteger(r.y,"Point64Utils.fromPointD"),{x:Math.round(r.x),y:Math.round(r.y),z:r.z||0}},scale(r,e){return{x:Math.round(r.x*e),y:Math.round(r.y*e),z:r.z||0}},equals(r,e){return r.x===e.x&&r.y===e.y},add(r,e){if(Number.isSafeInteger(r.x)&&Number.isSafeInteger(e.x)&&Number.isSafeInteger(r.y)&&Number.isSafeInteger(e.y)){let t=r.x+e.x,n=r.y+e.y;return Number.isSafeInteger(t)&&Number.isSafeInteger(n)?{x:t,y:n,z:0}:{x:Number(BigInt(r.x)+BigInt(e.x)),y:Number(BigInt(r.y)+BigInt(e.y)),z:0}}return{x:r.x+e.x,y:r.y+e.y,z:0}},subtract(r,e){return{x:r.x-e.x,y:r.y-e.y,z:0}},toString(r){return r.z!==void 0&&r.z!==0?`${r.x},${r.y},${r.z} `:`${r.x},${r.y} `}},sr={create(r=0,e=0,t=0){return{x:r,y:e,z:t}},fromPoint64(r){return{x:r.x,y:r.y,z:r.z||0}},scale(r,e){return{x:r.x*e,y:r.y*e,z:r.z||0}},equals(r,e){return z.isAlmostZero(r.x-e.x)&&z.isAlmostZero(r.y-e.y)},negate(r){r.x=-r.x,r.y=-r.y},toString(r,e=2){return r.z!==void 0&&r.z!==0?`${r.x.toFixed(e)},${r.y.toFixed(e)},${r.z}`:`${r.x.toFixed(e)},${r.y.toFixed(e)}`}},lt={create(r=0,e=0,t=0,n=0){return{left:r,top:e,right:t,bottom:n}},createInvalid(){return{left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER}},width(r){return r.right-r.left},height(r){return r.bottom-r.top},isEmpty(r){return r.bottom<=r.top||r.right<=r.left},isValid(r){return r.left<Number.MAX_SAFE_INTEGER},midPoint(r){if(Number.isSafeInteger(r.left)&&Number.isSafeInteger(r.right)&&Math.abs(r.left)+Math.abs(r.right)>Number.MAX_SAFE_INTEGER){let e=Number((BigInt(r.left)+BigInt(r.right))/nr),t=Number((BigInt(r.top)+BigInt(r.bottom))/nr);return{x:e,y:t}}return{x:Math.round((r.left+r.right)/2),y:Math.round((r.top+r.bottom)/2)}},contains(r,e){return e.x>r.left&&e.x<r.right&&e.y>r.top&&e.y<r.bottom},containsRect(r,e){return e.left>=r.left&&e.right<=r.right&&e.top>=r.top&&e.bottom<=r.bottom},intersects(r,e){return Math.max(r.left,e.left)<=Math.min(r.right,e.right)&&Math.max(r.top,e.top)<=Math.min(r.bottom,e.bottom)},asPath(r){return[{x:r.left,y:r.top,z:0},{x:r.right,y:r.top,z:0},{x:r.right,y:r.bottom,z:0},{x:r.left,y:r.bottom,z:0}]}},$r={create(r=0,e=0,t=0,n=0){return{left:r,top:e,right:t,bottom:n}},createInvalid(){return{left:Number.MAX_VALUE,top:Number.MAX_VALUE,right:-Number.MAX_VALUE,bottom:-Number.MAX_VALUE}},width(r){return r.right-r.left},height(r){return r.bottom-r.top},isEmpty(r){return r.bottom<=r.top||r.right<=r.left},midPoint(r){return{x:(r.left+r.right)/2,y:(r.top+r.bottom)/2}},contains(r,e){return e.x>r.left&&e.x<r.right&&e.y>r.top&&e.y<r.bottom},containsRect(r,e){return e.left>=r.left&&e.right<=r.right&&e.top>=r.top&&e.bottom<=r.bottom},intersects(r,e){return Math.max(r.left,e.left)<Math.min(r.right,e.right)&&Math.max(r.top,e.top)<Math.min(r.bottom,e.bottom)},asPath(r){return[{x:r.left,y:r.top,z:0},{x:r.right,y:r.top,z:0},{x:r.right,y:r.bottom,z:0},{x:r.left,y:r.bottom,z:0}]}};var _n=Object.freeze(lt.createInvalid()),Yn=Object.freeze($r.createInvalid());var Mt=BigInt(0),Go=BigInt(2),jn=BigInt(4),Z;(function(r){r[r.None=0]="None",r[r.OpenStart=1]="OpenStart",r[r.OpenEnd=2]="OpenEnd",r[r.LocalMax=4]="LocalMax",r[r.LocalMin=8]="LocalMin"})(Z||(Z={}));var Zr=class{constructor(){b(this,"data",[])}push(e){this.data.push(e),this.siftUp(this.data.length-1)}pop(){if(this.data.length===0)return null;let e=this.data[0],t=this.data.pop();return this.data.length>0&&(this.data[0]=t,this.siftDown(0)),e}clear(){this.data.length=0}siftUp(e){let t=this.data[e];for(;e>0;){let n=e-1>>1;if(this.data[n]>=t)break;this.data[e]=this.data[n],e=n}this.data[e]=t}siftDown(e){let t=this.data.length,n=this.data[e];for(;;){let s=(e<<1)+1;if(s>=t)break;let i=s+1,o=s;if(i<t&&this.data[i]>this.data[s]&&(o=i),this.data[o]<=n)break;this.data[e]=this.data[o],e=o}this.data[e]=n}},Ot=class{constructor(e,t,n){b(this,"pt");b(this,"next",null);b(this,"prev",null);b(this,"flags");this.pt=e,this.flags=t,this.prev=n}},Ft=class{constructor(e,t,n=!1){b(this,"vertex");b(this,"polytype");b(this,"isOpen");this.vertex=e,this.polytype=t,this.isOpen=n}equals(e){return e!==null&&this.vertex===e.vertex}};function Kn(r,e,t){return{pt:r,edge1:e,edge2:t}}var We=class{constructor(e,t){b(this,"pt");b(this,"next");b(this,"prev");b(this,"outrec");b(this,"horz");this.pt=e,this.outrec=t,this.next=this,this.prev=this,this.horz=null}},xe;(function(r){r[r.None=0]="None",r[r.Left=1]="Left",r[r.Right=2]="Right"})(xe||(xe={}));var _r;(function(r){r[r.Bottom=0]="Bottom",r[r.Middle=1]="Middle",r[r.Top=2]="Top"})(_r||(_r={}));var ir=class{constructor(){b(this,"idx",0);b(this,"owner",null);b(this,"frontEdge",null);b(this,"backEdge",null);b(this,"pts",null);b(this,"polypath",null);b(this,"bounds",{left:0,top:0,right:0,bottom:0});b(this,"path",[]);b(this,"isOpen",!1);b(this,"splits",null);b(this,"recursiveSplit",null)}},or=class{constructor(e){b(this,"leftOp");b(this,"rightOp");b(this,"leftToRight");this.leftOp=e,this.rightOp=null,this.leftToRight=!0}},At=class{constructor(e,t){b(this,"op1");b(this,"op2");this.op1=e,this.op2=t}};function Ho(r,e){return r.rightOp===null?e.rightOp===null?0:1:e.rightOp===null?-1:r.leftOp.pt.x-e.leftOp.pt.x}function zo(r,e){return r.pt.y!==e.pt.y?r.pt.y>e.pt.y?-1:1:r.pt.x!==e.pt.x?r.pt.x<e.pt.x?-1:1:r.edge1.curX!==e.edge1.curX?r.edge1.curX<e.edge1.curX?-1:1:r.edge2.curX<e.edge2.curX?-1:r.edge2.curX>e.edge2.curX?1:0}var Dt=class{constructor(){b(this,"bot",{x:0,y:0});b(this,"top",{x:0,y:0});b(this,"curX",0);b(this,"dx",0);b(this,"windDx",0);b(this,"windCount",0);b(this,"windCount2",0);b(this,"outrec",null);b(this,"prevInAEL",null);b(this,"nextInAEL",null);b(this,"prevInSEL",null);b(this,"nextInSEL",null);b(this,"jump",null);b(this,"vertexTop",null);b(this,"localMin",null);b(this,"isLeftBound",!1);b(this,"joinWith",xe.None)}},yt={addLocMin(r,e,t,n){if((r.flags&Z.LocalMin)!==Z.None)return;r.flags|=Z.LocalMin;let s=new Ft(r,e,t);n.push(s)},addPathsToVertexList(r,e,t,n,s){for(let i=0,o=r.length;i<o;i++){let a=r[i],u=null,l=null,f=null;for(let g=0,m=a.length;g<m;g++){let x=a[g];if(u===null)u=new Ot(x,Z.None,null),s.push(u),l=u,f=x;else if(!(f.x===x.x&&f.y===x.y)){let y=new Ot(x,Z.None,l);l.next=y,l=y,f=x}}if(l?.prev==null||(!t&&l.pt.x===u.pt.x&&l.pt.y===u.pt.y&&(l=l.prev),l.next=u,u.prev=l,!t&&l.next===l))continue;let c;if(t){let g=u.next;for(;g!==u&&g.pt.y===u.pt.y;)g=g.next;c=g.pt.y<=u.pt.y,c?(u.flags=Z.OpenStart,yt.addLocMin(u,e,!0,n)):u.flags=Z.OpenStart|Z.LocalMax}else{for(l=u.prev;l!==u&&l.pt.y===u.pt.y;)l=l.prev;if(l===u)continue;c=l.pt.y>u.pt.y}let h=c;l=u;let p=u.next;for(;p!==u;)p.pt.y>l.pt.y&&c?(l.flags|=Z.LocalMax,c=!1):p.pt.y<l.pt.y&&!c&&(c=!0,yt.addLocMin(l,e,t,n)),l=p,p=p.next;t?(l.flags|=Z.OpenEnd,c?l.flags|=Z.LocalMax:yt.addLocMin(l,e,t,n)):c!==h&&(h?yt.addLocMin(l,e,!1,n):l.flags|=Z.LocalMax)}}};var ar=class{constructor(e=null){b(this,"parent");b(this,"children",[]);this.parent=e}get isHole(){return this.getIsHole()}getLevel(){let e=0,t=this.parent;for(;t!==null;)++e,t=t.parent;return e}get level(){return this.getLevel()}getIsHole(){let e=this.getLevel();return e!==0&&(e&1)===0}get count(){return this.children.length}clear(){this.children.length=0}toStringInternal(e,t){let n="",s=" ".repeat(t),i=this.children.length===1?"":"s";(t&1)===0?n+=`${s}+- hole (${e}) contains ${this.children.length} nested polygon${i}.
2
+ "use strict";var fr=Object.defineProperty;var Ho=Object.getOwnPropertyDescriptor;var Vo=Object.getOwnPropertyNames;var zo=Object.prototype.hasOwnProperty;var $o=(t,e,r)=>e in t?fr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Xo=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),qo=(t,e)=>{for(var r in e)fr(t,r,{get:e[r],enumerable:!0})},Wo=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Vo(e))!zo.call(t,s)&&s!==r&&fr(t,s,{get:()=>e[s],enumerable:!(n=Ho(e,s))||n.enumerable});return t};var Zo=t=>Wo(fr({},"__esModule",{value:!0}),t);var b=(t,e,r)=>$o(t,typeof e!="symbol"?e+"":e,r);var js=Xo((Kp,Ys)=>{Ys.exports={}});var ac={};qo(ac,{DEFAULT_LAYERS:()=>lr,DEFAULT_LIMITS:()=>es,KerfError:()=>O,LANGUAGE_VERSION:()=>oc,VERSION:()=>ic,parameters:()=>Go,parse:()=>it,render:()=>Ro,tokenize:()=>Ur});module.exports=Zo(ac);var os=Math.PI/180;function as(t,e){let r=new Array(16).fill(0);for(let n=0;n<4;n++)for(let s=0;s<4;s++)for(let i=0;i<4;i++)r[n*4+s]+=t[n*4+i]*e[i*4+s];return r}function tn(t,e){let r=Math.cos(e*os),n=Math.sin(e*os);return t===0?[1,0,0,0,0,r,-n,0,0,n,r,0,0,0,0,1]:t===1?[r,0,n,0,0,1,0,0,-n,0,r,0,0,0,0,1]:[r,-n,0,0,n,r,0,0,0,0,1,0,0,0,0,1]}var hs=t=>Math.abs(t)<1e-12?0:t;function sn(t){let[e,r,n]=t.rotate,s=as(tn(2,n),as(tn(1,r),tn(0,e)));return s[3]=t.at[0],s[7]=t.at[1],s[11]=t.at[2],s.map(hs)}function cs(t,e,r,n){return[t[0]*e+t[1]*r+t[2]*n+t[3],t[4]*e+t[5]*r+t[6]*n+t[7],t[8]*e+t[9]*r+t[10]*n+t[11]]}function _o(t){let[e,r,n]=[t[3],t[7],t[11]],s=[t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]];return[s[0],s[1],s[2],-(s[0]*e+s[1]*r+s[2]*n),s[3],s[4],s[5],-(s[3]*e+s[4]*r+s[5]*n),s[6],s[7],s[8],-(s[6]*e+s[7]*r+s[8]*n),0,0,0,1]}function cr(t){let[e,r,n,s]=[1/0,1/0,-1/0,-1/0];for(let i of t)for(let[o,a]of i)e=Math.min(e,o),r=Math.min(r,a),n=Math.max(n,o),s=Math.max(s,a);return[e,r,n,s]}function ps(t){let[e,r,n,s]=cr(t.outline),i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let a of[e,n])for(let u of[r,s])for(let l of[0,t.thickness]){let f=cs(t.matrix,a,u,l);for(let c=0;c<3;c++)i[c]=Math.min(i[c],f[c]),o[c]=Math.max(o[c],f[c])}return[i,o]}function ds(t,e,r=10){let n=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let[f,c]of t.map(ps))for(let h=0;h<3;h++)n[h]=Math.min(n[h],f[h]),s[h]=Math.max(s[h],c[h]);let i=e.map(f=>cr(f.outline)),o=i.reduce((f,[c,,h])=>Math.max(f,h-c),s[0]-n[0]),a=0,u=0,l=0;return e.map((f,c)=>{let[h,p,d,m]=i[c];a>0&&a+d-h>o&&(a=0,u+=l+r,l=0);let x=[1,0,0,s[0]+r+a-h,0,1,0,n[1]+u-p,0,0,1,n[2],0,0,0,1];return a+=d-h+r,l=Math.max(l,m-p),{...f,matrix:x.map(hs)}})}var Yo=(t,e,r)=>[0,1,2].every(n=>t[0][n]<e[1][n]-r&&e[0][n]<t[1][n]-r),hr=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],rn=(t,e)=>[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]],us=(t,e,r=1)=>[t[0]+e[0]*r,t[1]+e[1]*r,t[2]+e[2]*r],pr=t=>[t[2],t[6],t[10]],ls=t=>[t[3],t[7],t[11]],jo=(t,e)=>[t[0]*e[0]+t[1]*e[1]+t[2]*e[2],t[4]*e[0]+t[5]*e[1]+t[6]*e[2],t[8]*e[0]+t[9]*e[1]+t[10]*e[2]];function Pt(t,e,r){let n=r[0]*r[0]+r[1]*r[1],s=[];for(let i of t)for(let o=0,a=i.length-1;o<i.length;a=o++){let u=i[a],l=i[o],f=r[0]*(u[1]-e[1])-r[1]*(u[0]-e[0]),c=r[0]*(l[1]-e[1])-r[1]*(l[0]-e[0]);if(f>0==c>0)continue;let h=f/(f-c),p=u[0]+(l[0]-u[0])*h-e[0],d=u[1]+(l[1]-u[1])*h-e[1];s.push((p*r[0]+d*r[1])/n)}return s.sort((i,o)=>i-o)}function nn(t,e,r){let n=0,s=0,i=0;for(;s+1<t.length&&i+1<e.length;){let o=Math.min(t[s+1],e[i+1])-Math.max(t[s],e[i]);o>r&&(n+=o),t[s+1]<e[i+1]?s+=2:i+=2}return n}function dr(t,e,r,n){let s=t+r,i=e-r;if(i<=s)return{at:[],size:0};let o=Math.max(4,Math.ceil((i-s)/n));return{at:Array.from({length:o},(a,u)=>s+(i-s)*(u+.5)/o),size:(i-s)/o}}function fs(t,e,r){let n=cs(t,e[0],e[1],e[2]),s=jo(t,r);return[[n[0],n[1]],[s[0],s[1]]]}function Ko(t,e,r,n,s,i,o){let a=pr(t.matrix),u=pr(e.matrix),l=rn(a,u),f=Math.hypot(...l),c=[l[0]/f,l[1]/f,l[2]/f],h=rn(c,a),p=hr(u,h),d=ls(t.matrix),m=hr(u,ls(e.matrix)),x=dr(0,t.thickness,s,i),y=0;for(let L of x.at){let S=us(d,a,L),A=(m-hr(u,S))/p,E=(m+e.thickness-hr(u,S))/p,F=dr(Math.min(A,E),Math.max(A,E),s,i);for(let k of F.at){let I=us(S,h,k),[z,B]=fs(r,I,c),[$,ge]=fs(n,I,c);if(y+=nn(Pt(t.outline,z,B),Pt(e.outline,$,ge),s)*x.size*F.size,y>o)return!0}}return!1}function Jo(t,e,r,n,s,i){let o=[0,1,2,3].flatMap(k=>[0,1,2,3].map(I=>{let z=0;for(let B=0;B<4;B++)z+=r[k*4+B]*e.matrix[B*4+I];return z})),a=o[11],u=o[11]+o[10]*e.thickness,l=Math.min(t.thickness,Math.max(a,u))-Math.max(0,Math.min(a,u));if(l<=n)return!1;let f=e.outline.map(k=>k.map(([I,z])=>[o[0]*I+o[1]*z+o[3],o[4]*I+o[5]*z+o[7]])),[c,h,p,d]=cr(t.outline),[m,x,y,L]=cr(f),S=dr(Math.max(h,x),Math.min(d,L),n,s),A=0;for(let k of S.at)if(A+=nn(Pt(t.outline,[0,k],[1,0]),Pt(f,[0,k],[1,0]),n)*S.size*l,A>i)return!0;let E=dr(Math.max(c,m),Math.min(p,y),n,s),F=0;for(let k of E.at)if(F+=nn(Pt(t.outline,[k,0],[0,1]),Pt(f,[k,0],[0,1]),n)*E.size*l,F>i)return!0;return!1}function gs(t,e=1/0,r=.05,n=.25,s=1){let i=t.map(ps),o=t.map(f=>_o(f.matrix)),a=t.map((f,c)=>c).sort((f,c)=>i[f][0][0]-i[c][0][0]),u=[],l=0;for(let f=0;f<a.length;f++)for(let c=f+1;c<a.length;c++){let h=a[f],p=a[c];if(i[p][0][0]>=i[h][1][0]-r)break;if(!Yo(i[h],i[p],r))continue;if(++l>e)return{found:u,complete:!1};let[d,m]=h<p?[t[h],t[p]]:[t[p],t[h]],[x,y]=h<p?[o[h],o[p]]:[o[p],o[h]];(Math.hypot(...rn(pr(d.matrix),pr(m.matrix)))<1e-9?Jo(d,m,x,r,n,s):Ko(d,m,x,y,r,n,s))&&u.push([d,m])}return{found:u,complete:!0}}var Be=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.type==="range",tt=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.type==="function",vs=t=>typeof t=="number",Lt=(t,e)=>t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;function on(t,e,r=0){if(!(e==null||["number","string","boolean"].includes(typeof e))){if(Array.isArray(e)&&r<32){for(let n of e)on(t,n,r+1);return}throw new Error(`Setting "${t}" must be a number, string, boolean or list`)}}function mr(t,e){let r=[];if(t.step===0||(t.step>0?t.start>t.end:t.start<t.end))return r;let n=Math.floor((t.end-t.start)/t.step+1e-9)+1;if(n>e)throw new Error(`a range of ${n} items is more than the limit of ${e}`);for(let s=0;s<n;s++)r.push(t.start+s*t.step);return r}function Me(t){return t===void 0||t===!1||t===0||t===""?!1:Array.isArray(t)?t.length>0:typeof t=="number"?!Number.isNaN(t):!0}var ms=(t,e)=>Be(t)&&Be(e)?t.start===e.start&&t.step===e.step&&t.end===e.end:t===e;function Ht(t,e,r){if(r?.(),!Array.isArray(t)||!Array.isArray(e))return ms(t,e);let n=new Map,s=[],i=(o,a)=>{let u=n.get(o);return u?.has(a)?!0:o.length!==a.length?!1:(u||n.set(o,u=new Set),u.add(a),s.push([o,a,0]),!0)};if(!i(t,e))return!1;for(;s.length;){let o=s[s.length-1];if(o[2]===o[0].length){s.pop();continue}let a=o[0][o[2]],u=o[1][o[2]++];if(r?.(),Array.isArray(a)&&Array.isArray(u)?!i(a,u):!ms(a,u))return!1}return!0}function De(t){return t===void 0?"undef":Array.isArray(t)?"list":Be(t)?"range":tt(t)?"function":typeof t}function Qo(t){return t===void 0?"undef":typeof t=="string"?JSON.stringify(t):typeof t=="number"?gr(t):Be(t)?`[${gr(t.start)}:${gr(t.step)}:${gr(t.end)}]`:tt(t)?`function(${t.params.map(e=>e.name).join(", ")})`:String(t)}function It(t,e,r=!1){if(typeof t=="string"&&!r)return{text:t.length>e?t.slice(0,Math.max(e,0)):t,whole:t.length<=e};let n=[],s=0,i=l=>{n.push(l),s+=l.length},o=[],a=t;for(;;){Array.isArray(a)?(i("["),o.push([a,0])):i(Qo(a));let l=!1;for(;o.length&&!l;){let f=o[o.length-1];f[1]<f[0].length?(f[1]&&i(", "),a=f[0][f[1]++],l=!0):(o.pop(),i("]"))}if(!l||s>e)break}let u=n.join("");return s>e?{text:u.slice(0,Math.max(e,0)),whole:!1}:{text:u,whole:!0}}function xs(t,e,r){let n=[],s=0;for(let i of t){n.length&&(s+=e.length);let o=It(i,r-s);if(!o.whole)return;s+=o.text.length,n.push(o.text)}return n.join(e)}function dt(t){let e=It(t,200,!0);return e.whole?e.text:e.text+"..."}var Ge=t=>typeof t=="string"?t:dt(t);function ke(t){let e=!1;for(;Array.isArray(t)&&t.length===1;)t=t[0],e=!0;return Array.isArray(t)?t.length?NaN:0:e&&(t===void 0||typeof t=="boolean")?t===void 0?0:NaN:typeof t=="object"?NaN:Number(t)}function gr(t){return Number.isInteger(t)?String(t):String(Number(t.toPrecision(10)))}var gt=Math.PI/180,X=(t,e,r)=>({params:t.replace("...","").split(",").map(n=>n.trim()).filter(Boolean),rest:t.endsWith("..."),order:r,run:e});function bs(t,e,r){return t.order?[]:t.params.filter((n,s)=>s<e.length&&r.has(n))}function Ss(t,e,r){if(t.rest){let i=[...e];return t.params.forEach((o,a)=>{r.has(o)&&(i[a]=r.get(o))}),i}if(!t.order)return t.params.map((i,o)=>r.has(i)?r.get(i):e[o]);let n=e.length+t.params.filter(i=>r.has(i)).length,s=t.order(n).filter(i=>!r.has(i));return t.params.map(i=>r.has(i)?r.get(i):e[s.indexOf(i)])}function an(t,e,r,n){let s=xs(t,e,r.maxLength);if(s===void 0)throw new Error(`${n}(): the text would be longer than the limit of ${r.maxLength} characters`);return r.step(Math.ceil(s.length/8)),s}function Z(t,e){if(typeof t!="number")throw new Error(`${e}() needs a number, got ${De(t)}`);return t}function We(t,e,r){if(Array.isArray(t))return t;if(Be(t))return mr(t,r.maxLength);if(typeof t=="string")return[...t];throw new Error(`${e}() needs a list, got ${De(t)}`)}var ea=new Set(["is_num","is_string","is_bool","is_list","is_undef","is_function","type_of","ord"]);function ws(t,e,r){if(ea.has(t))return 0;let n=0;for(let s of e)if(typeof s=="string")n+=s.length;else if(Array.isArray(s))n+=t==="len"?0:s.length;else if(Be(s)&&s.step!==0){let i=Math.floor((s.end-s.start)/s.step)+1;i>0&&(n+=Math.min(i,r+1))}return n}var Ie=t=>X("x",e=>typeof e[0]=="number"?un(t(e[0])):void 0);function un(t){let e=Math.round(t);return Math.abs(t-e)<1e-12?e:t}function ta(t){let e=Math.floor(t)>>>0||2654435769;return()=>{e=e+1831565813>>>0;let r=e;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}}function ys(t,e,r){let n=t.length===1&&Array.isArray(t[0])?t[0]:t;if(n.length)return e(n.map(s=>Z(s,r)))}var ks={abs:Ie(Math.abs),sign:Ie(Math.sign),floor:Ie(Math.floor),ceil:Ie(Math.ceil),round:Ie(t=>t<0?-Math.round(-t):Math.round(t)),sqrt:Ie(Math.sqrt),exp:Ie(Math.exp),ln:Ie(Math.log),log:X("x, base",(t,e)=>e.given<2?un(Math.log10(Z(t[0],"log"))):Math.log(Z(t[0],"log"))/Math.log(Z(t[1],"log")),t=>t>=2?["base","x"]:["x","base"]),sin:Ie(t=>Math.sin(t*gt)),cos:Ie(t=>Math.cos(t*gt)),tan:Ie(t=>Math.tan(t*gt)),asin:Ie(t=>Math.asin(t)/gt),acos:Ie(t=>Math.acos(t)/gt),atan:Ie(t=>Math.atan(t)/gt),atan2:X("y, x",t=>un(Math.atan2(Z(t[0],"atan2"),Z(t[1],"atan2"))/gt)),pow:X("x, y",t=>Math.pow(Z(t[0],"pow"),Z(t[1],"pow"))),min:X("values...",t=>ys(t,e=>e.reduce((r,n)=>n<r?n:r,1/0),"min")),max:X("values...",t=>ys(t,e=>e.reduce((r,n)=>n>r?n:r,-1/0),"max")),clamp:X("x, low, high",t=>Math.min(Math.max(Z(t[0],"clamp"),Z(t[1],"clamp")),Z(t[2],"clamp"))),lerp:X("a, b, t",t=>{let e=Z(t[2],"lerp");if(Array.isArray(t[0])&&Array.isArray(t[1])){let r=t[1];return t[0].map((n,s)=>Z(n,"lerp")+(Z(r[s],"lerp")-Z(n,"lerp"))*e)}return Z(t[0],"lerp")+(Z(t[1],"lerp")-Z(t[0],"lerp"))*e}),norm:X("v",(t,e)=>Math.sqrt(We(t[0],"norm",e).reduce((r,n)=>r+Z(n,"norm")**2,0))),cross:X("a, b",(t,e)=>{let r=We(t[0],"cross",e).map(s=>Z(s,"cross")),n=We(t[1],"cross",e).map(s=>Z(s,"cross"));return r.length===2?r[0]*n[1]-r[1]*n[0]:[r[1]*n[2]-r[2]*n[1],r[2]*n[0]-r[0]*n[2],r[0]*n[1]-r[1]*n[0]]}),len:X("value",t=>typeof t[0]=="string"?[...t[0]].length:Array.isArray(t[0])?t[0].length:void 0),concat:X("...",(t,e)=>{let r=t.reduce((n,s)=>n+(Array.isArray(s)?s.length:1),0);if(r>e.maxLength)throw new Error(`concat(): a list of ${r} items is more than the limit of ${e.maxLength}`);return t.flatMap(n=>Array.isArray(n)?n:[n])}),reverse:X("value",(t,e)=>typeof t[0]=="string"?[...t[0]].reverse().join(""):[...We(t[0],"reverse",e)].reverse()),sum:X("values",(t,e)=>We(t[0],"sum",e).reduce((r,n)=>r+Z(n,"sum"),0)),slice:X("value, start, end",(t,e)=>{let n=(typeof t[0]=="string"?[...t[0]]:We(t[0],"slice",e)).slice(Z(t[1]??0,"slice"),t[2]===void 0?void 0:Z(t[2],"slice"));return typeof t[0]=="string"?n.join(""):n}),str:X("...",(t,e)=>an(t,"",e,"str")),chr:X("...",t=>t.flatMap(e=>Array.isArray(e)?e:[e]).map(e=>String.fromCodePoint(Z(e,"chr"))).join("")),ord:X("text",t=>typeof t[0]=="string"&&t[0].length?t[0].codePointAt(0):void 0),upper:X("text",t=>typeof t[0]=="string"?t[0].toUpperCase():void 0),lower:X("text",t=>typeof t[0]=="string"?t[0].toLowerCase():void 0),split:X("text, separator",t=>typeof t[0]=="string"?t[0].split(typeof t[1]=="string"?t[1]:" "):void 0),join:X("values, separator",(t,e)=>an(We(t[0],"join",e),typeof t[1]=="string"?t[1]:"",e,"join")),search:X("value, list",(t,e)=>{let n=(typeof t[1]=="string"?[...t[1]]:We(t[1],"search",e)).findIndex(s=>Ht(s,t[0],e.step));return n<0?void 0:n}),contains:X("value, item",(t,e)=>typeof t[0]=="string"?t[0].includes(an([t[1]],"",e,"contains")):We(t[0],"contains",e).some(r=>Ht(r,t[1],e.step))),lookup:X("x, table",(t,e)=>{let r=Z(t[0],"lookup"),n=We(t[1],"lookup",e);if(!n.length)return;let s=n.map(i=>[Z(i[0],"lookup"),Z(i[1],"lookup")]).sort((i,o)=>i[0]-o[0]);if(r<=s[0][0])return s[0][1];for(let i=1;i<s.length;i++)if(r<=s[i][0]){let[o,a]=s[i-1],[u,l]=s[i];return a+(r-o)/(u-o)*(l-a)}return s[s.length-1][1]}),rands:X("min, max, count, seed",t=>{let e=Z(t[0],"rands"),r=Z(t[1],"rands"),n=Z(t[2],"rands"),s=ta(t[3]===void 0?1:Z(t[3],"rands"));return Array.from({length:Math.min(Math.max(0,Math.floor(n)),1e6)},()=>e+(r-e)*s())}),is_num:X("value",t=>vs(t[0])&&!Number.isNaN(t[0])),is_string:X("value",t=>typeof t[0]=="string"),is_bool:X("value",t=>typeof t[0]=="boolean"),is_list:X("value",t=>Array.isArray(t[0])),is_undef:X("value",t=>t[0]===void 0),is_function:X("value",t=>tt(t[0])),type_of:X("value",t=>De(t[0]))};var J;(function(t){t[t.NoClip=0]="NoClip",t[t.Intersection=1]="Intersection",t[t.Union=2]="Union",t[t.Difference=3]="Difference",t[t.Xor=4]="Xor"})(J||(J={}));var we;(function(t){t[t.Subject=0]="Subject",t[t.Clip=1]="Clip"})(we||(we={}));var H;(function(t){t[t.EvenOdd=0]="EvenOdd",t[t.NonZero=1]="NonZero",t[t.Positive=2]="Positive",t[t.Negative=3]="Negative"})(H||(H={}));var V;(function(t){t[t.IsOn=0]="IsOn",t[t.IsInside=1]="IsInside",t[t.IsOutside=2]="IsOutside"})(V||(V={}));var Tt=Number.MAX_SAFE_INTEGER,pe=Math.floor(Math.sqrt(Tt));function vr(t,e){return!Number.isSafeInteger(t)||!Number.isSafeInteger(e)?!1:t===0||e===0?!0:Math.abs(t)<=Tt/Math.abs(e)}function Es(t,e){return Math.abs(t)+Math.abs(e)<=Tt}function ln(t,e,r,n){if(vr(t,e)&&vr(r,n)){let s=t*e,i=r*n;if(Es(s,i))return s-i}return Number.isSafeInteger(t)&&Number.isSafeInteger(e)&&Number.isSafeInteger(r)&&Number.isSafeInteger(n)?Number(BigInt(t)*BigInt(e)-BigInt(r)*BigInt(n)):t*e-r*n}function fn(t,e,r,n){if(vr(t,e)&&vr(r,n)){let s=t*e,i=r*n;if(Es(s,i))return s+i}return Number.isSafeInteger(t)&&Number.isSafeInteger(e)&&Number.isSafeInteger(r)&&Number.isSafeInteger(n)?Number(BigInt(t)*BigInt(e)+BigInt(r)*BigInt(n)):t*e+r*n}var hn=BigInt(0),xr=BigInt(2),ra=BigInt(4),na=BigInt(64),sa=BigInt("0xFFFFFFFFFFFFFFFF"),dn=BigInt("9223372036854775807"),Vt=Number(dn/ra),Ps=Number(dn),Ls=1e-12,ia=.1,cn=Math.floor(pe/2),oa=Math.floor(Math.sqrt(Math.sqrt(Tt/4)));function aa(t){if(!Number.isFinite(t))throw new RangeError("Scale must be a finite number");let e=Math.abs(t);return e===0?Number.POSITIVE_INFINITY:Tt/e}function ua(t,e,r){if(!Number.isFinite(t)||Math.abs(t)>e)throw new RangeError(`Scaled coordinate exceeds Number.MAX_SAFE_INTEGER in ${r}`)}function la(t,e){if(!Number.isFinite(t)||Math.abs(t)>Tt)throw new RangeError(`Coordinate exceeds Number.MAX_SAFE_INTEGER in ${e}`)}function fa(t,e,r){let n=e.x-t.x,s=r.y-e.y,i=e.y-t.y,o=r.x-e.x;return Math.abs(n)<pe&&Math.abs(s)<pe&&Math.abs(i)<pe&&Math.abs(o)<pe?n*s-i*o:ln(n,s,i,o)}function Ue(t,e,r){let n=e.x-t.x,s=r.y-e.y,i=e.y-t.y,o=r.x-e.x;if(Math.abs(n)<pe&&Math.abs(s)<pe&&Math.abs(i)<pe&&Math.abs(o)<pe){let l=n*s,f=i*o;return l>f?1:l<f?-1:0}if(!Number.isSafeInteger(n)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)){let l=n*s,f=i*o;return l>f?1:l<f?-1:0}let a=BigInt(n)*BigInt(s),u=BigInt(i)*BigInt(o);return a===u?0:a>u?1:-1}function ha(t){if(t<-8||t>8)throw new Error("Error: Precision is out of range.")}function ca(t){return Math.abs(t)<=Ls}function pa(t){return t<0?-1:t>0?1:0}function da(t,e){let r=BigInt(t),n=BigInt(e),s=r*n;return{lo64:s&sa,hi64:s>>na}}function Is(t,e,r,n){let s=Math.abs(t),i=Math.abs(e),o=Math.abs(r),a=Math.abs(n);if(s<pe&&i<pe&&o<pe&&a<pe)return t*e===r*n;let u=(t<0?-1:t>0?1:0)*(e<0?-1:e>0?1:0),l=(r<0?-1:r>0?1:0)*(n<0?-1:n>0?1:0);if(u!==l)return!1;if(u===0)return!0;if(!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)||!Number.isSafeInteger(a))return t*e===r*n;let f=BigInt(s),c=BigInt(i),h=BigInt(o),p=BigInt(a);return f*c===h*p}function ga(t,e,r){let n=e.x-t.x,s=r.y-e.y,i=e.y-t.y,o=r.x-e.x;return Is(n,s,i,o)}function ma(t,e,r){let n=e.x-t.x,s=r.x-e.x,i=e.y-t.y,o=r.y-e.y;return Math.abs(n)<pe&&Math.abs(s)<pe&&Math.abs(i)<pe&&Math.abs(o)<pe?n*s+i*o:fn(n,s,i,o)}function va(t,e,r){let n=e.x-t.x,s=r.x-e.x,i=e.y-t.y,o=r.y-e.y;if(Math.abs(n)<pe&&Math.abs(s)<pe&&Math.abs(i)<pe&&Math.abs(o)<pe){let u=n*s+i*o;return u>0?1:u<0?-1:0}if(!Number.isSafeInteger(n)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)){let u=n*s+i*o;return u>0?1:u<0?-1:0}let a=BigInt(n)*BigInt(s)+BigInt(i)*BigInt(o);return a===hn?0:a>hn?1:-1}function xa(t){let e=t.length;if(e<3)return 0;let r=!0;for(let i=0;i<e&&r;i++){let o=t[i];(Math.abs(o.x)>=cn||Math.abs(o.y)>=cn)&&(r=!1)}let n=t[e-1];if(r){let i=0;for(let o of t)i+=(n.y+o.y)*(n.x-o.x),n=o;return i*.5}let s=hn;for(let i of t){let o=n.y+i.y,a=n.x-i.x;if(Number.isSafeInteger(o)&&Number.isSafeInteger(a))s+=BigInt(o)*BigInt(a);else if(Number.isSafeInteger(n.y)&&Number.isSafeInteger(i.y)&&Number.isSafeInteger(n.x)&&Number.isSafeInteger(i.x)){let u=BigInt(n.y)+BigInt(i.y),l=BigInt(n.x)-BigInt(i.x);s+=u*l}else s+=BigInt(Math.round(o*a));n=i}return Number(s)*.5}function ya(t,e){return t.y*e.x-e.y*t.x}function ba(t,e){return t.x*e.x+t.y*e.y}function Sa(t){let e=Math.round(t);return t===e-.5&&(e&1)!==0?e-1:e}function wa(t){return t>=Vt||t<=-Vt?Ps:Math.round(t)}function ka(t,e,r,n){let s=e.y-t.y,i=e.x-t.x,o=n.y-r.y,a=n.x-r.x,u=ln(s,a,o,i);if(u===0)return null;let l=ln(t.x-r.x,o,t.y-r.y,a)/u;return l<=0?{x:t.x,y:t.y,z:t.z||0}:l>=1?{x:e.x,y:e.y,z:e.z||0}:{x:Math.trunc(t.x+l*i),y:Math.trunc(t.y+l*s),z:0}}function Ea(t,e,r,n){let s=e.y-t.y,i=e.x-t.x,o=n.y-r.y,a=n.x-r.x,u=s*a-o*i;if(u===0)return{success:!1,ip:{x:0,y:0,z:0}};let l=((t.x-r.x)*o-(t.y-r.y)*a)/u,f;return l<=0?f={...t,z:0}:l>=1?f={...e,z:0}:f={x:t.x+l*i,y:t.y+l*s,z:0},{success:!0,ip:f}}function Pa(t,e,r,n,s=!1){if(!s){let l=Ue(t,r,n),f=Ue(e,r,n),c=Ue(r,t,e),h=Ue(n,t,e);return l!==0&&f!==0&&l!==f&&c!==0&&h!==0&&c!==h}let i=Ue(t,r,n),o=Ue(e,r,n);if(i!==0&&i===o)return!1;let a=Ue(r,t,e),u=Ue(n,t,e);return a!==0&&a===u?!1:i!==0||o!==0||a!==0||u!==0}function Ts(t){if(t.length===0)return{left:0,top:0,right:0,bottom:0};let e={left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER};for(let r of t)r.x<e.left&&(e.left=r.x),r.x>e.right&&(e.right=r.x),r.y<e.top&&(e.top=r.y),r.y>e.bottom&&(e.bottom=r.y);return e.left===Number.MAX_SAFE_INTEGER?{left:0,top:0,right:0,bottom:0}:e}function La(t,e,r){if(e.x===r.x&&e.y===r.y)return{x:e.x,y:e.y,z:0};let n=r.x-e.x,s=r.y-e.y,i=fn(t.x-e.x,n,t.y-e.y,s)/fn(n,n,s,s),o=i<0?0:i>1?1:i;return{x:Math.round(e.x+o*n),y:Math.round(e.y+o*s),z:0}}function pn(t,e){let r=e.length,n=0;if(r<3)return V.IsOutside;for(;n<r&&e[n].y===t.y;)n++;if(n===r)return V.IsOutside;let s=e[n].y<t.y,i=s,o=0,a=n+1,u=r;for(;;){if(a===u){if(u===0||n===0)break;u=n,a=0}if(s)for(;a<u&&e[a].y<t.y;)a++;else for(;a<u&&e[a].y>t.y;)a++;if(a===u)continue;let f=e[a],c=a>0?e[a-1]:e[r-1];if(f.y===t.y){if(f.x===t.x||f.y===c.y&&t.x<c.x!=t.x<f.x)return V.IsOn;if(a++,a===n)break;continue}if(!(t.x<f.x&&t.x<c.x))if(t.x>c.x&&t.x>f.x)o=1-o;else{let h=Ue(c,f,t);if(h===0)return V.IsOn;h<0===s&&(o=1-o)}s=!s,a++}if(s===i)return o===0?V.IsOutside:V.IsInside;a===r&&(a=0);let l=a===0?Ue(e[r-1],e[0],t):Ue(e[a-1],e[a],t);return l===0?V.IsOn:(l<0===s&&(o=1-o),o===0?V.IsOutside:V.IsInside)}function Ia(t,e){let r=V.IsOn;for(let a of t)switch(pn(a,e)){case V.IsOutside:if(r===V.IsOutside)return!1;r=V.IsOutside;break;case V.IsInside:if(r===V.IsInside)return!0;r=V.IsInside;break;default:break}let n=Ts(t),s,i;return Number.isSafeInteger(n.left)&&Number.isSafeInteger(n.right)&&Math.abs(n.left)+Math.abs(n.right)>Number.MAX_SAFE_INTEGER?(s=Number((BigInt(n.left)+BigInt(n.right))/xr),i=Number((BigInt(n.top)+BigInt(n.bottom))/xr)):(s=Math.round((n.left+n.right)/2),i=Math.round((n.top+n.bottom)/2)),pn({x:s,y:i},e)!==V.IsOutside}var N={MaxInt64:dn,MaxCoord:Vt,max_coord:Vt,min_coord:-Vt,Invalid64:Ps,floatingPointTolerance:Ls,defaultMinimumEdgeLength:ia,maxCoordForSafeAreaProduct:cn,maxCoordForSafeCrossSq:oa,maxSafeCoordinateForScale:aa,checkSafeScaleValue:ua,ensureSafeInteger:la,crossProduct:fa,crossProductSign:Ue,checkPrecision:ha,isAlmostZero:ca,triSign:pa,multiplyUInt64:da,productsAreEqual:Is,isCollinear:ga,dotProduct:ma,dotProductSign:va,area:xa,crossProductD:ya,dotProductD:ba,roundToEven:Sa,checkCastInt64:wa,getLineIntersectPt:ka,getLineIntersectPtD:Ea,segsIntersect:Pa,getBounds:Ts,getClosestPtOnSegment:La,pointInPolygon:pn,path2ContainsPath1:Ia},Ze={create(t=0,e=0,r=0){return{x:Math.round(t),y:Math.round(e),z:r}},fromPointD(t){return N.ensureSafeInteger(t.x,"Point64Utils.fromPointD"),N.ensureSafeInteger(t.y,"Point64Utils.fromPointD"),{x:Math.round(t.x),y:Math.round(t.y),z:t.z||0}},scale(t,e){return{x:Math.round(t.x*e),y:Math.round(t.y*e),z:t.z||0}},equals(t,e){return t.x===e.x&&t.y===e.y},add(t,e){if(Number.isSafeInteger(t.x)&&Number.isSafeInteger(e.x)&&Number.isSafeInteger(t.y)&&Number.isSafeInteger(e.y)){let r=t.x+e.x,n=t.y+e.y;return Number.isSafeInteger(r)&&Number.isSafeInteger(n)?{x:r,y:n,z:0}:{x:Number(BigInt(t.x)+BigInt(e.x)),y:Number(BigInt(t.y)+BigInt(e.y)),z:0}}return{x:t.x+e.x,y:t.y+e.y,z:0}},subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:0}},toString(t){return t.z!==void 0&&t.z!==0?`${t.x},${t.y},${t.z} `:`${t.x},${t.y} `}},yr={create(t=0,e=0,r=0){return{x:t,y:e,z:r}},fromPoint64(t){return{x:t.x,y:t.y,z:t.z||0}},scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z||0}},equals(t,e){return N.isAlmostZero(t.x-e.x)&&N.isAlmostZero(t.y-e.y)},negate(t){t.x=-t.x,t.y=-t.y},toString(t,e=2){return t.z!==void 0&&t.z!==0?`${t.x.toFixed(e)},${t.y.toFixed(e)},${t.z}`:`${t.x.toFixed(e)},${t.y.toFixed(e)}`}},mt={create(t=0,e=0,r=0,n=0){return{left:t,top:e,right:r,bottom:n}},createInvalid(){return{left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER}},width(t){return t.right-t.left},height(t){return t.bottom-t.top},isEmpty(t){return t.bottom<=t.top||t.right<=t.left},isValid(t){return t.left<Number.MAX_SAFE_INTEGER},midPoint(t){if(Number.isSafeInteger(t.left)&&Number.isSafeInteger(t.right)&&Math.abs(t.left)+Math.abs(t.right)>Number.MAX_SAFE_INTEGER){let e=Number((BigInt(t.left)+BigInt(t.right))/xr),r=Number((BigInt(t.top)+BigInt(t.bottom))/xr);return{x:e,y:r}}return{x:Math.round((t.left+t.right)/2),y:Math.round((t.top+t.bottom)/2)}},contains(t,e){return e.x>t.left&&e.x<t.right&&e.y>t.top&&e.y<t.bottom},containsRect(t,e){return e.left>=t.left&&e.right<=t.right&&e.top>=t.top&&e.bottom<=t.bottom},intersects(t,e){return Math.max(t.left,e.left)<=Math.min(t.right,e.right)&&Math.max(t.top,e.top)<=Math.min(t.bottom,e.bottom)},asPath(t){return[{x:t.left,y:t.top,z:0},{x:t.right,y:t.top,z:0},{x:t.right,y:t.bottom,z:0},{x:t.left,y:t.bottom,z:0}]}},gn={create(t=0,e=0,r=0,n=0){return{left:t,top:e,right:r,bottom:n}},createInvalid(){return{left:Number.MAX_VALUE,top:Number.MAX_VALUE,right:-Number.MAX_VALUE,bottom:-Number.MAX_VALUE}},width(t){return t.right-t.left},height(t){return t.bottom-t.top},isEmpty(t){return t.bottom<=t.top||t.right<=t.left},midPoint(t){return{x:(t.left+t.right)/2,y:(t.top+t.bottom)/2}},contains(t,e){return e.x>t.left&&e.x<t.right&&e.y>t.top&&e.y<t.bottom},containsRect(t,e){return e.left>=t.left&&e.right<=t.right&&e.top>=t.top&&e.bottom<=t.bottom},intersects(t,e){return Math.max(t.left,e.left)<Math.min(t.right,e.right)&&Math.max(t.top,e.top)<Math.min(t.bottom,e.bottom)},asPath(t){return[{x:t.left,y:t.top,z:0},{x:t.right,y:t.top,z:0},{x:t.right,y:t.bottom,z:0},{x:t.left,y:t.bottom,z:0}]}};var Cs=Object.freeze(mt.createInvalid()),Ms=Object.freeze(gn.createInvalid());var zt=BigInt(0),Ta=BigInt(2),As=BigInt(4),_;(function(t){t[t.None=0]="None",t[t.OpenStart=1]="OpenStart",t[t.OpenEnd=2]="OpenEnd",t[t.LocalMax=4]="LocalMax",t[t.LocalMin=8]="LocalMin"})(_||(_={}));var mn=class{constructor(){b(this,"data",[])}push(e){this.data.push(e),this.siftUp(this.data.length-1)}pop(){if(this.data.length===0)return null;let e=this.data[0],r=this.data.pop();return this.data.length>0&&(this.data[0]=r,this.siftDown(0)),e}clear(){this.data.length=0}siftUp(e){let r=this.data[e];for(;e>0;){let n=e-1>>1;if(this.data[n]>=r)break;this.data[e]=this.data[n],e=n}this.data[e]=r}siftDown(e){let r=this.data.length,n=this.data[e];for(;;){let s=(e<<1)+1;if(s>=r)break;let i=s+1,o=s;if(i<r&&this.data[i]>this.data[s]&&(o=i),this.data[o]<=n)break;this.data[e]=this.data[o],e=o}this.data[e]=n}},$t=class{constructor(e,r,n){b(this,"pt");b(this,"next",null);b(this,"prev",null);b(this,"flags");this.pt=e,this.flags=r,this.prev=n}},Xt=class{constructor(e,r,n=!1){b(this,"vertex");b(this,"polytype");b(this,"isOpen");this.vertex=e,this.polytype=r,this.isOpen=n}equals(e){return e!==null&&this.vertex===e.vertex}};function Os(t,e,r){return{pt:t,edge1:e,edge2:r}}var Je=class{constructor(e,r){b(this,"pt");b(this,"next");b(this,"prev");b(this,"outrec");b(this,"horz");this.pt=e,this.outrec=r,this.next=this,this.prev=this,this.horz=null}},Pe;(function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Right=2]="Right"})(Pe||(Pe={}));var vn;(function(t){t[t.Bottom=0]="Bottom",t[t.Middle=1]="Middle",t[t.Top=2]="Top"})(vn||(vn={}));var br=class{constructor(){b(this,"idx",0);b(this,"owner",null);b(this,"frontEdge",null);b(this,"backEdge",null);b(this,"pts",null);b(this,"polypath",null);b(this,"bounds",{left:0,top:0,right:0,bottom:0});b(this,"path",[]);b(this,"isOpen",!1);b(this,"splits",null);b(this,"recursiveSplit",null)}},Sr=class{constructor(e){b(this,"leftOp");b(this,"rightOp");b(this,"leftToRight");this.leftOp=e,this.rightOp=null,this.leftToRight=!0}},qt=class{constructor(e,r){b(this,"op1");b(this,"op2");this.op1=e,this.op2=r}};function Ca(t,e){return t.rightOp===null?e.rightOp===null?0:1:e.rightOp===null?-1:t.leftOp.pt.x-e.leftOp.pt.x}function Ma(t,e){return t.pt.y!==e.pt.y?t.pt.y>e.pt.y?-1:1:t.pt.x!==e.pt.x?t.pt.x<e.pt.x?-1:1:t.edge1.curX!==e.edge1.curX?t.edge1.curX<e.edge1.curX?-1:1:t.edge2.curX<e.edge2.curX?-1:t.edge2.curX>e.edge2.curX?1:0}var Wt=class{constructor(){b(this,"bot",{x:0,y:0});b(this,"top",{x:0,y:0});b(this,"curX",0);b(this,"dx",0);b(this,"windDx",0);b(this,"windCount",0);b(this,"windCount2",0);b(this,"outrec",null);b(this,"prevInAEL",null);b(this,"nextInAEL",null);b(this,"prevInSEL",null);b(this,"nextInSEL",null);b(this,"jump",null);b(this,"vertexTop",null);b(this,"localMin",null);b(this,"isLeftBound",!1);b(this,"joinWith",Pe.None)}},Ct={addLocMin(t,e,r,n){if((t.flags&_.LocalMin)!==_.None)return;t.flags|=_.LocalMin;let s=new Xt(t,e,r);n.push(s)},addPathsToVertexList(t,e,r,n,s){for(let i=0,o=t.length;i<o;i++){let a=t[i],u=null,l=null,f=null;for(let d=0,m=a.length;d<m;d++){let x=a[d];if(u===null)u=new $t(x,_.None,null),s.push(u),l=u,f=x;else if(!(f.x===x.x&&f.y===x.y)){let y=new $t(x,_.None,l);l.next=y,l=y,f=x}}if(l?.prev==null||(!r&&l.pt.x===u.pt.x&&l.pt.y===u.pt.y&&(l=l.prev),l.next=u,u.prev=l,!r&&l.next===l))continue;let c;if(r){let d=u.next;for(;d!==u&&d.pt.y===u.pt.y;)d=d.next;c=d.pt.y<=u.pt.y,c?(u.flags=_.OpenStart,Ct.addLocMin(u,e,!0,n)):u.flags=_.OpenStart|_.LocalMax}else{for(l=u.prev;l!==u&&l.pt.y===u.pt.y;)l=l.prev;if(l===u)continue;c=l.pt.y>u.pt.y}let h=c;l=u;let p=u.next;for(;p!==u;)p.pt.y>l.pt.y&&c?(l.flags|=_.LocalMax,c=!1):p.pt.y<l.pt.y&&!c&&(c=!0,Ct.addLocMin(l,e,r,n)),l=p,p=p.next;r?(l.flags|=_.OpenEnd,c?l.flags|=_.LocalMax:Ct.addLocMin(l,e,r,n)):c!==h&&(h?Ct.addLocMin(l,e,!1,n):l.flags|=_.LocalMax)}}};var wr=class{constructor(e=null){b(this,"parent");b(this,"children",[]);this.parent=e}get isHole(){return this.getIsHole()}getLevel(){let e=0,r=this.parent;for(;r!==null;)++e,r=r.parent;return e}get level(){return this.getLevel()}getIsHole(){let e=this.getLevel();return e!==0&&(e&1)===0}get count(){return this.children.length}clear(){this.children.length=0}toStringInternal(e,r){let n="",s=" ".repeat(r),i=this.children.length===1?"":"s";(r&1)===0?n+=`${s}+- hole (${e}) contains ${this.children.length} nested polygon${i}.
3
3
  `:n+=`${s}+- polygon (${e}) contains ${this.children.length} hole${i}.
4
- `;for(let o=0;o<this.count;o++)this.children[o].count>0&&(n+=this.children[o].toStringInternal(o,t+1));return n}toString(){if(this.level>0)return"";let e=this.children.length===1?"":"s",t=`Polytree with ${this.children.length} polygon${e}.
5
- `;for(let n=0;n<this.count;n++)this.children[n].count>0&&(t+=this.children[n].toStringInternal(n,1));return t+`
6
- `}},ur=class r extends ar{constructor(t=null){super(t);b(this,"polygon",null)}get poly(){return this.polygon}addChild(t){let n=new r(this);return n.polygon=t,this.children.push(n),n}child(t){if(t<0||t>=this.children.length)throw new Error("Index out of range");return this.children[t]}area(){let t=this.polygon===null?0:Yr.area(this.polygon);for(let n of this.children)t+=n.area();return t}};var Ut=class extends ur{};var d=class d{constructor(){b(this,"cliptype",j.NoClip);b(this,"fillrule",V.EvenOdd);b(this,"actives",null);b(this,"sel",null);b(this,"minimaList",[]);b(this,"intersectList",[]);b(this,"vertexList",[]);b(this,"outrecList",[]);b(this,"scanlineHeap",new Zr);b(this,"scanlineSet",new Set);b(this,"scanlineArr",[]);b(this,"useScanlineArray",!1);b(this,"horzSegList",[]);b(this,"horzJoinList",[]);b(this,"currentLocMin",0);b(this,"currentBotY",0);b(this,"curXValidAtTop",!1);b(this,"isSortedMinimaList",!1);b(this,"hasOpenPaths",!1);b(this,"usingPolytree",!1);b(this,"succeeded",!1);b(this,"zCallbackInternal");b(this,"preserveCollinear",!0);b(this,"reverseSolution",!1)}getZCallback(){}xyEqual(e,t){return e.x===t.x&&e.y===t.y}setZ(e,t,n){let s=this.zCallbackInternal;s&&(d.getPolyType(e)===me.Subject?(this.xyEqual(n,e.bot)?n.z=e.bot.z??0:this.xyEqual(n,e.top)?n.z=e.top.z??0:this.xyEqual(n,t.bot)?n.z=t.bot.z??0:this.xyEqual(n,t.top)?n.z=t.top.z??0:n.z=0,s(e.bot,e.top,t.bot,t.top,n)):(this.xyEqual(n,t.bot)?n.z=t.bot.z??0:this.xyEqual(n,t.top)?n.z=t.top.z??0:this.xyEqual(n,e.bot)?n.z=e.bot.z??0:this.xyEqual(n,e.top)?n.z=e.top.z??0:n.z=0,s(t.bot,t.top,e.bot,e.top,n)))}static isOdd(e){return(e&1)!==0}static isHotEdge(e){return e.outrec!=null}static isOpen(e){return d.openPathsEnabled&&e.localMin.isOpen}static isOpenEnd(e){return d.openPathsEnabled&&e.localMin.isOpen&&d.isOpenEndVertex(e.vertexTop)}static isOpenEndVertex(e){return(e.flags&(Z.OpenStart|Z.OpenEnd))!==Z.None}static getPrevHotEdge(e){let t=e.prevInAEL;if(!d.openPathsEnabled){for(;t!==null&&!d.isHotEdge(t);)t=t.prevInAEL;return t}for(;t!==null&&(t.localMin.isOpen||!d.isHotEdge(t));)t=t.prevInAEL;return t}static isFront(e){return e===e.outrec.frontEdge}static getDx(e,t){let n=t.y-e.y;return n!==0?(t.x-e.x)/n:t.x>e.x?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY}static topX(e,t){return t===e.top.y||e.top.x===e.bot.x?e.top.x:t===e.bot.y?e.bot.x:z.roundToEven(e.bot.x+e.dx*(t-e.bot.y))}static isHorizontal(e){return e.dx===Number.NEGATIVE_INFINITY||e.dx===Number.POSITIVE_INFINITY}static isHeadingRightHorz(e){return e.dx===Number.NEGATIVE_INFINITY}static isHeadingLeftHorz(e){return e.dx===Number.POSITIVE_INFINITY}static getPolyType(e){return e.localMin.polytype}static isSamePolyType(e,t){return e.localMin.polytype===t.localMin.polytype}static setDx(e){e.dx=d.getDx(e.bot,e.top)}static nextVertex(e){return e.windDx>0?e.vertexTop.next:e.vertexTop.prev}static prevPrevVertex(e){return e.windDx>0?e.vertexTop.prev.prev:e.vertexTop.next.next}static isMaximaVertex(e){return(e.flags&Z.LocalMax)!==Z.None}static isMaximaEdge(e){return(e.vertexTop.flags&Z.LocalMax)!==Z.None}static getMaximaPair(e){let t=e.nextInAEL;for(;t!==null;){if(t.vertexTop===e.vertexTop)return t;t=t.nextInAEL}return null}boundingBoxesOverlap(e,t,n,s){let i=e.x<t.x?e.x:t.x;if((n.x>s.x?n.x:s.x)<i)return!1;let a=e.x>t.x?e.x:t.x,u=n.x<s.x?n.x:s.x;if(a<u)return!1;let l=e.y<t.y?e.y:t.y;if((n.y>s.y?n.y:s.y)<l)return!1;let c=e.y>t.y?e.y:t.y,h=n.y<s.y?n.y:s.y;return c>=h}clearSolutionOnly(){for(;this.actives!==null;)this.deleteFromAEL(this.actives);this.scanlineHeap.clear(),this.scanlineSet.clear(),this.scanlineArr.length=0,this.disposeIntersectNodes(),this.outrecList.length=0,this.horzSegList.length=0,this.horzJoinList.length=0}clear(){this.clearSolutionOnly(),this.minimaList.length=0,this.vertexList.length=0,this.currentLocMin=0,this.isSortedMinimaList=!1,this.hasOpenPaths=!1}reset(){this.isSortedMinimaList||(this.minimaList.sort((e,t)=>t.vertex.pt.y-e.vertex.pt.y),this.isSortedMinimaList=!0),this.scanlineHeap.clear(),this.scanlineSet.clear(),this.scanlineArr.length=0,this.useScanlineArray=this.minimaList.length<=16;for(let e=this.minimaList.length-1;e>=0;e--)this.insertScanline(this.minimaList[e].vertex.pt.y);this.currentBotY=0,this.currentLocMin=0,this.actives=null,this.sel=null,this.curXValidAtTop=!1,this.succeeded=!0}upgradeScanlineStructureFromArray(){let e=this.scanlineArr;for(let t=0,n=e.length;t<n;t++){let s=e[t];this.scanlineSet.add(s),this.scanlineHeap.push(s)}e.length=0,this.useScanlineArray=!1}insertScanline(e){if(this.useScanlineArray){let t=this.scanlineArr;for(let n=0,s=t.length;n<s;n++)if(t[n]===e)return;t.push(e),t.length>64&&this.upgradeScanlineStructureFromArray();return}this.scanlineSet.has(e)||(this.scanlineSet.add(e),this.scanlineHeap.push(e))}popScanline(){if(this.useScanlineArray){let t=this.scanlineArr,n=t.length;if(n===0)return null;let s=0,i=t[0];for(let o=1;o<n;o++){let a=t[o];a>i&&(i=a,s=o)}return t[s]=t[n-1],t.pop(),i}let e=this.scanlineHeap.pop();return e===null?null:(this.scanlineSet.delete(e),e)}hasLocMinAtY(e){return this.currentLocMin<this.minimaList.length&&this.minimaList[this.currentLocMin].vertex.pt.y===e}popLocalMinima(){return this.minimaList[this.currentLocMin++]}addPath(e,t,n=!1){let s=[e];this.addPaths(s,t,n)}addPaths(e,t,n=!1){n&&(this.hasOpenPaths=!0),this.isSortedMinimaList=!1,yt.addPathsToVertexList(e,t,n,this.minimaList,this.vertexList)}addReuseableData(e){if(e.minimaList.length!==0){this.isSortedMinimaList=!1;for(let t of e.minimaList)this.minimaList.push(new Ft(t.vertex,t.polytype,t.isOpen)),t.isOpen&&(this.hasOpenPaths=!0)}}deleteFromAEL(e){let t=e.prevInAEL,n=e.nextInAEL;t===null&&n===null&&e!==this.actives||(t!==null?t.nextInAEL=n:this.actives=n,n!==null&&(n.prevInAEL=t))}getBounds(){let e={left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER};for(let t of this.vertexList){let n=t;do n.pt.x<e.left&&(e.left=n.pt.x),n.pt.x>e.right&&(e.right=n.pt.x),n.pt.y<e.top&&(e.top=n.pt.y),n.pt.y>e.bottom&&(e.bottom=n.pt.y),n=n.next;while(n!==t)}return lt.isEmpty(e)?{left:0,top:0,right:0,bottom:0}:e}executeInternal(e,t){if(e===j.NoClip)return;d.openPathsEnabled=this.hasOpenPaths,this.zCallbackInternal=this.getZCallback(),this.fillrule=t,this.cliptype=e,this.reset();let n=this.popScanline();if(n!==null){for(;this.succeeded;){this.insertLocalMinimaIntoAEL(n);let s;for(;(s=this.popHorz())!==null;)this.doHorizontal(s);this.horzSegList.length>0&&(this.convertHorzSegsToJoins(),this.horzSegList.length=0),this.currentBotY=n;let i=this.popScanline();if(i===null)break;for(n=i,this.doIntersections(n),this.doTopOfScanbeam(n);(s=this.popHorz())!==null;)this.doHorizontal(s)}this.succeeded&&this.processHorzJoins()}}insertLocalMinimaIntoAEL(e){for(;this.hasLocMinAtY(e);){let t=this.popLocalMinima(),n;(t.vertex.flags&Z.OpenStart)!==Z.None?n=null:(n=new Dt,n.bot=t.vertex.pt,n.curX=t.vertex.pt.x,n.windDx=-1,n.vertexTop=t.vertex.prev,n.top=t.vertex.prev.pt,n.outrec=null,n.localMin=t,d.setDx(n));let s;if((t.vertex.flags&Z.OpenEnd)!==Z.None?s=null:(s=new Dt,s.bot=t.vertex.pt,s.curX=t.vertex.pt.x,s.windDx=1,s.vertexTop=t.vertex.next,s.top=t.vertex.next.pt,s.outrec=null,s.localMin=t,d.setDx(s)),n!==null&&s!==null){if(d.isHorizontal(n)){if(d.isHeadingRightHorz(n)){let o=n;n=s,s=o}}else if(d.isHorizontal(s)){if(d.isHeadingLeftHorz(s)){let o=n;n=s,s=o}}else if(n.dx<s.dx){let o=n;n=s,s=o}}else n===null&&(n=s,s=null);let i;if(n.isLeftBound=!0,this.insertLeftEdge(n),d.openPathsEnabled?d.isOpen(n)?(this.setWindCountForOpenPathEdge(n),i=this.isContributingOpen(n)):(this.setWindCountForClosedPathEdge(n),i=this.isContributingClosed(n)):(this.setWindCountForClosedPathEdge(n),i=this.isContributingClosed(n)),s!==null){for(s.windCount=n.windCount,s.windCount2=n.windCount2,this.insertRightEdge(n,s),i&&(this.addLocalMinPoly(n,s,n.bot,!0),d.isHorizontal(n)||this.checkJoinLeft(n,n.bot));s.nextInAEL!==null&&this.isValidAelOrder(s.nextInAEL,s);)this.intersectEdges(s,s.nextInAEL,s.bot),this.swapPositionsInAEL(s,s.nextInAEL);d.isHorizontal(s)?this.pushHorz(s):(this.checkJoinRight(s,s.bot),this.insertScanline(s.top.y))}else i&&d.openPathsEnabled&&this.startOpenPath(n,n.bot);d.isHorizontal(n)?this.pushHorz(n):this.insertScanline(n.top.y)}}pushHorz(e){e.nextInSEL=this.sel,this.sel=e}popHorz(){let e=this.sel;return e===null?null:(this.sel=this.sel.nextInSEL,e)}doHorizontal(e){if(!d.openPathsEnabled){this.doHorizontalClosed(e);return}let t=d.isOpen(e),n=e.bot.y,s=t?this.getCurrYMaximaVertexOpen(e):this.getCurrYMaximaVertex(e),{isLeftToRight:i,leftX:o,rightX:a}=this.resetHorzDirection(e,s),u=o,l=a;if(d.isHotEdge(e)){let f=this.addOutPt(e,{x:e.curX,y:n});this.addToHorzSegList(f)}for(;;){let f=i?e.nextInAEL:e.prevInAEL;for(;f!==null;){if(f.vertexTop===s){if(d.isHotEdge(e)&&this.isJoined(f)&&this.split(f,f.top),d.isHotEdge(e)){for(;e.vertexTop!==s;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);i?this.addLocalMaxPoly(e,f,e.top):this.addLocalMaxPoly(f,e,e.top)}this.deleteFromAEL(f),this.deleteFromAEL(e);return}if(s!==e.vertexTop||d.isOpenEnd(e)){if(i&&f.curX>l||!i&&f.curX<u)break;if(f.curX===e.top.x&&!d.isHorizontal(f)){let p=d.nextVertex(e).pt;if(d.isOpen(f)&&!d.isSamePolyType(f,e)&&!d.isHotEdge(f)){if(i&&d.topX(f,p.y)>p.x||!i&&d.topX(f,p.y)<p.x)break}else if(i&&d.topX(f,p.y)>=p.x||!i&&d.topX(f,p.y)<=p.x)break}}let h={x:f.curX,y:n};i?(this.intersectEdges(e,f,h),this.swapPositionsInAEL(e,f),this.checkJoinLeft(f,h),e.curX=f.curX,f=e.nextInAEL):(this.intersectEdges(f,e,h),this.swapPositionsInAEL(f,e),this.checkJoinRight(f,h),e.curX=f.curX,f=e.prevInAEL),d.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(t&&d.isOpenEnd(e)){d.isHotEdge(e)&&(this.addOutPt(e,e.top),d.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e);return}if(d.nextVertex(e).pt.y!==e.top.y)break;d.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let c=this.resetHorzDirection(e,s);u=c.leftX,l=c.rightX}if(d.isHotEdge(e)){let f=this.addOutPt(e,e.top);this.addToHorzSegList(f)}this.updateEdgeIntoAEL(e)}doHorizontalClosed(e){let t=e.bot.y,n=this.getCurrYMaximaVertex(e),{isLeftToRight:s,leftX:i,rightX:o}=this.resetHorzDirection(e,n),a=i,u=o;if(d.isHotEdge(e)){let l=this.addOutPt(e,{x:e.curX,y:t});this.addToHorzSegList(l)}for(;;){let l=s?e.nextInAEL:e.prevInAEL;for(;l!==null;){if(l.vertexTop===n){if(d.isHotEdge(e)&&this.isJoined(l)&&this.split(l,l.top),d.isHotEdge(e)){for(;e.vertexTop!==n;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);s?this.addLocalMaxPoly(e,l,e.top):this.addLocalMaxPoly(l,e,e.top)}this.deleteFromAEL(l),this.deleteFromAEL(e);return}if(n!==e.vertexTop){if(s&&l.curX>u||!s&&l.curX<a)break;if(l.curX===e.top.x&&!d.isHorizontal(l)){let h=d.nextVertex(e).pt,p=d.topX(l,h.y);if(s&&p>=h.x||!s&&p<=h.x)break}}let c={x:l.curX,y:t};s?(this.intersectEdges(e,l,c),this.swapPositionsInAEL(e,l),this.checkJoinLeft(l,c),e.curX=l.curX,l=e.nextInAEL):(this.intersectEdges(l,e,c),this.swapPositionsInAEL(l,e),this.checkJoinRight(l,c),e.curX=l.curX,l=e.prevInAEL),d.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(d.nextVertex(e).pt.y!==e.top.y)break;d.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let f=this.resetHorzDirection(e,n);a=f.leftX,u=f.rightX}if(d.isHotEdge(e)){let l=this.addOutPt(e,e.top);this.addToHorzSegList(l)}this.updateEdgeIntoAEL(e)}convertHorzSegsToJoins(){let e=this.horzSegList,t=0;for(let n=0,s=e.length;n<s;n++){let i=e[n];this.updateHorzSegment(i)&&(e[t++]=i)}if(!(t<2)){e.length=t,this.horzSegList.sort(Ho);for(let n=0;n<t-1;n++){let s=this.horzSegList[n];for(let i=n+1;i<t;i++){let o=this.horzSegList[i];if(o.leftOp.pt.x>=s.rightOp.pt.x||o.leftToRight===s.leftToRight||o.rightOp.pt.x<=s.leftOp.pt.x)continue;let a=s.leftOp.pt.y;if(s.leftToRight){for(;s.leftOp.next.pt.y===a&&s.leftOp.next.pt.x<=o.leftOp.pt.x;)s.leftOp=s.leftOp.next;for(;o.leftOp.prev.pt.y===a&&o.leftOp.prev.pt.x<=s.leftOp.pt.x;)o.leftOp=o.leftOp.prev;let u=new At(this.duplicateOp(s.leftOp,!0),this.duplicateOp(o.leftOp,!1));this.horzJoinList.push(u)}else{for(;s.leftOp.prev.pt.y===a&&s.leftOp.prev.pt.x<=o.leftOp.pt.x;)s.leftOp=s.leftOp.prev;for(;o.leftOp.next.pt.y===a&&o.leftOp.next.pt.x<=s.leftOp.pt.x;)o.leftOp=o.leftOp.next;let u=new At(this.duplicateOp(o.leftOp,!0),this.duplicateOp(s.leftOp,!1));this.horzJoinList.push(u)}}}}}updateHorzSegment(e){let t=e.leftOp,n=this.getRealOutRec(t.outrec),s=n.frontEdge!==null,i=t.pt.y,o=t,a=t;if(s){let l=n.pts,f=l.next;for(;o!==f&&o.prev.pt.y===i;)o=o.prev;for(;a!==l&&a.next.pt.y===i;)a=a.next}else{for(;o.prev!==a&&o.prev.pt.y===i;)o=o.prev;for(;a.next!==o&&a.next.pt.y===i;)a=a.next}let u=this.setHorzSegHeadingForward(e,o,a)&&e.leftOp.horz===null;return u?e.leftOp.horz=e:e.rightOp=null,u}setHorzSegHeadingForward(e,t,n){return t.pt.x===n.pt.x?!1:(t.pt.x<n.pt.x?(e.leftOp=t,e.rightOp=n,e.leftToRight=!0):(e.leftOp=n,e.rightOp=t,e.leftToRight=!1),!0)}duplicateOp(e,t){let n=new We(e.pt,e.outrec);return t?(n.next=e.next,n.next.prev=n,n.prev=e,e.next=n):(n.prev=e.prev,n.prev.next=n,n.next=e,e.prev=n),n}getRealOutRec(e){for(;e!==null&&e.pts===null;)e=e.owner;return e}doIntersections(e){this.buildIntersectList(e)&&(this.processIntersectList(),this.disposeIntersectNodes())}doTopOfScanbeam(e){let t=this.curXValidAtTop;this.curXValidAtTop=!1,this.sel=null;let n=this.actives;for(;n!==null;){if(n.top.y===e)if(n.curX=n.top.x,d.isMaximaEdge(n)){n=this.doMaxima(n);continue}else d.isHotEdge(n)&&this.addOutPt(n,n.top),this.updateEdgeIntoAEL(n),d.isHorizontal(n)&&this.pushHorz(n);else t||(n.curX=d.topX(n,e));n=n.nextInAEL}}processHorzJoins(){for(let e of this.horzJoinList){let t=this.getRealOutRec(e.op1.outrec),n=this.getRealOutRec(e.op2.outrec),s=e.op1.next,i=e.op2.prev;if(e.op1.next=e.op2,e.op2.prev=e.op1,s.prev=i,i.next=s,t===n){let o=this.newOutRec();o.pts=s,this.fixOutRecPts(o),t.pts.outrec===o&&(t.pts=e.op1,t.pts.outrec=t),this.usingPolytree?(this.path1InsidePath2(t.pts,o.pts)?([o.pts,t.pts]=[t.pts,o.pts],this.fixOutRecPts(t),this.fixOutRecPts(o),o.owner=t):this.path1InsidePath2(o.pts,t.pts)?o.owner=t:o.owner=t.owner,t.splits===null&&(t.splits=[]),t.splits.push(o.idx)):o.owner=t}else n.pts=null,this.usingPolytree?(this.setOwner(n,t),this.moveSplits(n,t)):n.owner=t}}fixOutRecPts(e){let t=e.pts;do t.outrec=e,t=t.next;while(t!==e.pts)}path1InsidePath2(e,t){let n=q.IsOn,s=e;do{switch(this.pointInOpPolygon(s.pt,t)){case q.IsOutside:if(n===q.IsOutside)return!1;n=q.IsOutside;break;case q.IsInside:if(n===q.IsInside)return!0;n=q.IsInside;break;default:break}s=s.next}while(s!==e);return z.path2ContainsPath1(this.getCleanPath(e),this.getCleanPath(t))}pointInOpPolygon(e,t){if(t===t.next||t.prev===t.next)return q.IsOutside;let n=t;do{if(t.pt.y!==e.y)break;t=t.next}while(t!==n);if(t.pt.y===e.y)return q.IsOutside;let s=t.pt.y<e.y,i=s,o=0;for(n=t.next;n!==t;){if(s)for(;n!==t&&n.pt.y<e.y;)n=n.next;else for(;n!==t&&n.pt.y>e.y;)n=n.next;if(n===t)break;if(n.pt.y===e.y){if(n.pt.x===e.x||n.pt.y===n.prev.pt.y&&e.x<n.prev.pt.x!=e.x<n.pt.x)return q.IsOn;if(n=n.next,n===t)break;continue}if(n.pt.x<=e.x||n.prev.pt.x<=e.x)if(n.prev.pt.x<e.x&&n.pt.x<e.x)o=1-o;else{let a=z.crossProductSign(n.prev.pt,n.pt,e);if(a===0)return q.IsOn;a<0===s&&(o=1-o)}s=!s,n=n.next}if(s===i)return o===0?q.IsOutside:q.IsInside;{let a=z.crossProductSign(n.prev.pt,n.pt,e);if(a===0)return q.IsOn;a<0===s&&(o=1-o)}return o===0?q.IsOutside:q.IsInside}getCleanPath(e){let t=[],n=e;for(;n.next!==e&&(n.pt.x===n.next.pt.x&&n.pt.x===n.prev.pt.x||n.pt.y===n.next.pt.y&&n.pt.y===n.prev.pt.y);)n=n.next;t.push(n.pt);let s=n;for(n=n.next;n!==e;)(n.pt.x!==n.next.pt.x||n.pt.x!==s.pt.x)&&(n.pt.y!==n.next.pt.y||n.pt.y!==s.pt.y)&&(t.push(n.pt),s=n),n=n.next;return t}moveSplits(e,t){if(e.splits!==null){t.splits===null&&(t.splits=[]);for(let n of e.splits)n!==t.idx&&t.splits.push(n);e.splits=null}}buildIntersectList(e){if(this.actives?.nextInAEL===null)return!1;if(!this.adjustCurrXAndCopyToSEL(e))return this.curXValidAtTop=!0,!1;let t=this.sel;for(;t!==null&&t.jump!==null;){let n=null;for(;t!==null&&t.jump!==null;){let s=t,i=t.jump,o=i,a=i?.jump||null;for(t.jump=a;t!==o&&i!==a;)if(i.curX<t.curX){let u=i.prevInSEL;for(;this.addNewIntersectNode(u,i,e),u!==t;)u=u.prevInSEL;if(u=i,i=this.extractFromSEL(u),o=i,t!==null&&this.insert1Before2InSEL(u,t),t!==s)continue;s=u,s.jump=a,n===null?this.sel=s:n.jump=s}else t=t.nextInSEL;n=s,t=a}t=this.sel}return this.intersectList.length>0}processIntersectList(){this.intersectList.sort(zo);for(let e=0;e<this.intersectList.length;++e){if(!this.edgesAdjacentInAEL(this.intersectList[e])){let n=e+1;for(;!this.edgesAdjacentInAEL(this.intersectList[n]);)n++;[this.intersectList[n],this.intersectList[e]]=[this.intersectList[e],this.intersectList[n]]}let t=this.intersectList[e];this.intersectEdges(t.edge1,t.edge2,t.pt),this.swapPositionsInAEL(t.edge1,t.edge2),t.edge1.curX=t.pt.x,t.edge2.curX=t.pt.x,this.checkJoinLeft(t.edge2,t.pt,!0),this.checkJoinRight(t.edge1,t.pt,!0)}}edgesAdjacentInAEL(e){return e.edge1.nextInAEL===e.edge2||e.edge1.prevInAEL===e.edge2}adjustCurrXAndCopyToSEL(e){let t=this.actives;this.sel=t;let n=Number.NEGATIVE_INFINITY,s=!1;for(;t!==null;){t.prevInSEL=t.prevInAEL,t.nextInSEL=t.nextInAEL,t.jump=t.nextInSEL;let i=d.topX(t,e);t.curX=i,i<n&&(s=!0),n=i,t=t.nextInAEL}return s}doMaxima(e){let t=e.prevInAEL,n=e.nextInAEL;if(d.isOpenEnd(e))return d.isHotEdge(e)&&this.addOutPt(e,e.top),d.isHorizontal(e)||(d.isHotEdge(e)&&(d.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e)),n;let s=d.getMaximaPair(e);if(s===null)return n;for(this.isJoined(e)&&this.split(e,e.top),this.isJoined(s)&&this.split(s,s.top);n!==s;)this.intersectEdges(e,n,e.top),this.swapPositionsInAEL(e,n),n=e.nextInAEL;return d.isOpen(e)?(d.isHotEdge(e)&&this.addLocalMaxPoly(e,s,e.top),this.deleteFromAEL(s),this.deleteFromAEL(e),t!==null?t.nextInAEL:this.actives):(d.isHotEdge(e)&&this.addLocalMaxPoly(e,s,e.top),this.deleteFromAEL(e),this.deleteFromAEL(s),t!==null?t.nextInAEL:this.actives)}updateEdgeIntoAEL(e){if(e.bot=e.top,e.vertexTop=d.nextVertex(e),e.top=e.vertexTop.pt,e.curX=e.bot.x,d.setDx(e),this.isJoined(e)&&this.split(e,e.bot),d.isHorizontal(e)){d.openPathsEnabled?d.isOpen(e)||this.trimHorz(e,this.preserveCollinear):this.trimHorz(e,this.preserveCollinear);return}this.insertScanline(e.top.y),this.checkJoinLeft(e,e.bot),this.checkJoinRight(e,e.bot,!0)}trimHorz(e,t){let n=!1,s=d.nextVertex(e).pt;for(;s.y===e.top.y&&!(t&&s.x<e.top.x!=e.bot.x<e.top.x||(e.vertexTop=d.nextVertex(e),e.top=s,n=!0,d.isMaximaVertex(e.vertexTop)));)s=d.nextVertex(e).pt;n&&d.setDx(e)}addToHorzSegList(e){e.outrec.isOpen||this.horzSegList.push(new or(e))}addNewIntersectNode(e,t,n){let s=z.getLineIntersectPt(e.bot,e.top,t.bot,t.top);if(s===null&&(s={x:e.curX,y:n}),s.y>this.currentBotY||s.y<n){let o=Math.abs(e.dx),a=Math.abs(t.dx);o>100&&a>100?o>a?s=z.getClosestPtOnSegment(s,e.bot,e.top):s=z.getClosestPtOnSegment(s,t.bot,t.top):o>100?s=z.getClosestPtOnSegment(s,e.bot,e.top):a>100?s=z.getClosestPtOnSegment(s,t.bot,t.top):(s.y<n?s.y=n:s.y=this.currentBotY,o<a?s.x=d.topX(e,s.y):s.x=d.topX(t,s.y))}let i=Kn(s,e,t);this.intersectList.push(i)}extractFromSEL(e){let t=e.nextInSEL;return t!==null&&(t.prevInSEL=e.prevInSEL),e.prevInSEL.nextInSEL=t,t}insert1Before2InSEL(e,t){e.prevInSEL=t.prevInSEL,e.prevInSEL!==null&&(e.prevInSEL.nextInSEL=e),e.nextInSEL=t,t.prevInSEL=e}getCurrYMaximaVertexOpen(e){let t=e.vertexTop;if(e.windDx>0)for(;t.next.pt.y===t.pt.y&&(t.flags&(Z.OpenEnd|Z.LocalMax))===Z.None;)t=t.next;else for(;t.prev.pt.y===t.pt.y&&(t.flags&(Z.OpenEnd|Z.LocalMax))===Z.None;)t=t.prev;return d.isMaximaVertex(t)||(t=null),t}getCurrYMaximaVertex(e){let t=e.vertexTop;if(e.windDx>0)for(;t.next.pt.y===t.pt.y;)t=t.next;else for(;t.prev.pt.y===t.pt.y;)t=t.prev;return d.isMaximaVertex(t)||(t=null),t}resetHorzDirection(e,t){if(e.bot.x===e.top.x){let n=e.curX,s=e.curX,i=e.nextInAEL;for(;i!==null&&i.vertexTop!==t;)i=i.nextInAEL;return{isLeftToRight:i!==null,leftX:n,rightX:s}}return e.curX<e.top.x?{isLeftToRight:!0,leftX:e.curX,rightX:e.top.x}:{isLeftToRight:!1,leftX:e.top.x,rightX:e.curX}}getLastOp(e){let t=e.outrec;return e===t.frontEdge?t.pts:t.pts.next}insertLeftEdge(e){if(this.actives===null)e.prevInAEL=null,e.nextInAEL=null,this.actives=e;else if(!this.isValidAelOrder(this.actives,e))e.prevInAEL=null,e.nextInAEL=this.actives,this.actives.prevInAEL=e,this.actives=e;else{let t=this.actives;for(;t.nextInAEL!==null&&this.isValidAelOrder(t.nextInAEL,e);)t=t.nextInAEL;t.joinWith===xe.Right&&(t=t.nextInAEL),e.nextInAEL=t.nextInAEL,t.nextInAEL!==null&&(t.nextInAEL.prevInAEL=e),e.prevInAEL=t,t.nextInAEL=e}}insertRightEdge(e,t){t.nextInAEL=e.nextInAEL,e.nextInAEL!==null&&(e.nextInAEL.prevInAEL=t),t.prevInAEL=e,e.nextInAEL=t}setWindCountForOpenPathEdge(e){let t=this.actives;if(this.fillrule===V.EvenOdd){let n=0,s=0;for(;t!==e;)d.getPolyType(t)===me.Clip?s++:d.isOpen(t)||n++,t=t.nextInAEL;e.windCount=d.isOdd(n)?1:0,e.windCount2=d.isOdd(s)?1:0}else for(;t!==e;)d.getPolyType(t)===me.Clip?e.windCount2+=t.windDx:d.isOpen(t)||(e.windCount+=t.windDx),t=t.nextInAEL}setWindCountForClosedPathEdge(e){let t=e.prevInAEL,n=d.getPolyType(e);if(!d.openPathsEnabled){for(;t!==null&&d.getPolyType(t)!==n;)t=t.prevInAEL;if(t===null?(e.windCount=e.windDx,t=this.actives):this.fillrule===V.EvenOdd?(e.windCount=e.windDx,e.windCount2=t.windCount2,t=t.nextInAEL):(t.windCount*t.windDx<0?Math.abs(t.windCount)>1?t.windDx*e.windDx<0?e.windCount=t.windCount:e.windCount=t.windCount+e.windDx:e.windCount=e.windDx:t.windDx*e.windDx<0?e.windCount=t.windCount:e.windCount=t.windCount+e.windDx,e.windCount2=t.windCount2,t=t.nextInAEL),this.fillrule===V.EvenOdd)for(;t!==e;)d.getPolyType(t)!==n&&(e.windCount2=e.windCount2===0?1:0),t=t.nextInAEL;else for(;t!==e;)d.getPolyType(t)!==n&&(e.windCount2+=t.windDx),t=t.nextInAEL;return}for(;t!==null&&(d.getPolyType(t)!==n||d.isOpen(t));)t=t.prevInAEL;if(t===null?(e.windCount=e.windDx,t=this.actives):this.fillrule===V.EvenOdd?(e.windCount=e.windDx,e.windCount2=t.windCount2,t=t.nextInAEL):(t.windCount*t.windDx<0?Math.abs(t.windCount)>1?t.windDx*e.windDx<0?e.windCount=t.windCount:e.windCount=t.windCount+e.windDx:e.windCount=d.isOpen(e)?1:e.windDx:t.windDx*e.windDx<0?e.windCount=t.windCount:e.windCount=t.windCount+e.windDx,e.windCount2=t.windCount2,t=t.nextInAEL),this.fillrule===V.EvenOdd)for(;t!==e;)d.getPolyType(t)!==n&&!d.isOpen(t)&&(e.windCount2=e.windCount2===0?1:0),t=t.nextInAEL;else for(;t!==e;)d.getPolyType(t)!==n&&!d.isOpen(t)&&(e.windCount2+=t.windDx),t=t.nextInAEL}isContributingOpen(e){let t,n;switch(this.fillrule){case V.Positive:n=e.windCount>0,t=e.windCount2>0;break;case V.Negative:n=e.windCount<0,t=e.windCount2<0;break;default:n=e.windCount!==0,t=e.windCount2!==0;break}switch(this.cliptype){case j.Intersection:return t;case j.Union:return!n&&!t;default:return!t}}isContributingClosed(e){switch(this.fillrule){case V.Positive:if(e.windCount!==1)return!1;break;case V.Negative:if(e.windCount!==-1)return!1;break;case V.NonZero:if(Math.abs(e.windCount)!==1)return!1;break}switch(this.cliptype){case j.Intersection:return this.fillrule===V.Positive?e.windCount2>0:this.fillrule===V.Negative?e.windCount2<0:e.windCount2!==0;case j.Union:return this.fillrule===V.Positive?e.windCount2<=0:this.fillrule===V.Negative?e.windCount2>=0:e.windCount2===0;case j.Difference:{let t=this.fillrule===V.Positive?e.windCount2<=0:this.fillrule===V.Negative?e.windCount2>=0:e.windCount2===0;return d.getPolyType(e)===me.Subject?t:!t}case j.Xor:return!0;default:return!1}}addLocalMinPoly(e,t,n,s=!1){let i=this.newOutRec();if(e.outrec=i,t.outrec=i,d.isOpen(e))i.owner=null,i.isOpen=!0,e.windDx>0?this.setSides(i,e,t):this.setSides(i,t,e);else{i.isOpen=!1;let a=d.getPrevHotEdge(e);a!==null?(this.usingPolytree&&this.setOwner(i,a.outrec),i.owner=a.outrec,this.outrecIsAscending(a)===s?this.setSides(i,t,e):this.setSides(i,e,t)):(i.owner=null,s?this.setSides(i,e,t):this.setSides(i,t,e))}let o=new We(n,i);return i.pts=o,o}outrecIsAscending(e){return e===e.outrec.frontEdge}newOutRec(){let e=new ir;return e.idx=this.outrecList.length,this.outrecList.push(e),e}startOpenPath(e,t){let n=this.newOutRec();n.isOpen=!0,e.windDx>0?(n.frontEdge=e,n.backEdge=null):(n.frontEdge=null,n.backEdge=e),e.outrec=n;let s=new We(t,n);return n.pts=s,s}checkJoinLeft(e,t,n=!1){let s=e.prevInAEL;s!==null&&(!n&&e.curX!==s.curX||!d.isHotEdge(e)||!d.isHotEdge(s)||d.isHorizontal(e)||d.isHorizontal(s)||d.isOpen(e)||d.isOpen(s)||(t.y<e.top.y+2||t.y<s.top.y+2)&&(e.bot.y>t.y||s.bot.y>t.y)||n&&this.perpendicDistFromLineSqrdGreaterThanQuarter(t,s.bot,s.top)||z.isCollinear(e.top,t,s.top)&&(e.outrec.idx===s.outrec.idx?this.addLocalMaxPoly(s,e,t):e.outrec.idx<s.outrec.idx?this.joinOutrecPaths(e,s):this.joinOutrecPaths(s,e),s.joinWith=xe.Right,e.joinWith=xe.Left))}checkJoinRight(e,t,n=!1){let s=e.nextInAEL;s!==null&&(!n&&e.curX!==s.curX||!d.isHotEdge(e)||!d.isHotEdge(s)||d.isHorizontal(e)||d.isHorizontal(s)||d.isOpen(e)||d.isOpen(s)||(t.y<e.top.y+2||t.y<s.top.y+2)&&(e.bot.y>t.y||s.bot.y>t.y)||n&&this.perpendicDistFromLineSqrdGreaterThanQuarter(t,s.bot,s.top)||z.isCollinear(e.top,t,s.top)&&(e.outrec.idx===s.outrec.idx?this.addLocalMaxPoly(e,s,t):e.outrec.idx<s.outrec.idx?this.joinOutrecPaths(e,s):this.joinOutrecPaths(s,e),e.joinWith=xe.Right,s.joinWith=xe.Left))}perpendicDistFromLineSqrdGreaterThanQuarter(e,t,n){let s=e.x-t.x,i=e.y-t.y,o=n.x-t.x,a=n.y-t.y;if(o===0&&a===0)return!1;let u=z.maxCoordForSafeCrossSq;if(Math.abs(s)<u&&Math.abs(i)<u&&Math.abs(o)<u&&Math.abs(a)<u){let f=s*a-o*i;return f*f/(o*o+a*a)>.25}if(Number.isSafeInteger(s)&&Number.isSafeInteger(i)&&Number.isSafeInteger(o)&&Number.isSafeInteger(a)){let f=BigInt(s)*BigInt(a)-BigInt(o)*BigInt(i),c=f*f,h=BigInt(o)*BigInt(o)+BigInt(a)*BigInt(a);return jn*c>h}let l=s*a-o*i;return l*l/(o*o+a*a)>.25}intersectEdges(e,t,n){let s;if(this.hasOpenPaths&&(d.isOpen(e)||d.isOpen(t))){if(d.isOpen(e)&&d.isOpen(t))return;if(d.isOpen(t)){let l=e;e=t,t=l}if(this.isJoined(t)&&this.split(t,n),this.cliptype===j.Union){if(!d.isHotEdge(t))return}else if(t.localMin.polytype===me.Subject)return;switch(this.fillrule){case V.Positive:if(t.windCount!==1)return;break;case V.Negative:if(t.windCount!==-1)return;break;default:if(Math.abs(t.windCount)!==1)return;break}if(d.isHotEdge(e))s=this.addOutPt(e,n),this.setZ(e,t,s.pt),d.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null;else if(n.x===e.localMin.vertex.pt.x&&n.y===e.localMin.vertex.pt.y&&!d.isOpenEndVertex(e.localMin.vertex)){let l=this.findEdgeWithMatchingLocMin(e);if(l!==null&&d.isHotEdge(l)){e.outrec=l.outrec,e.windDx>0?this.setSides(l.outrec,e,l):this.setSides(l.outrec,l,e);return}s=this.startOpenPath(e,n)}else s=this.startOpenPath(e,n);this.setZ(e,t,s.pt);return}this.isJoined(e)&&this.split(e,n),this.isJoined(t)&&this.split(t,n);let i,o;switch(e.localMin.polytype===t.localMin.polytype?this.fillrule===V.EvenOdd?(i=e.windCount,e.windCount=t.windCount,t.windCount=i):(e.windCount+t.windDx===0?e.windCount=-e.windCount:e.windCount+=t.windDx,t.windCount-e.windDx===0?t.windCount=-t.windCount:t.windCount-=e.windDx):(this.fillrule!==V.EvenOdd?e.windCount2+=t.windDx:e.windCount2=e.windCount2===0?1:0,this.fillrule!==V.EvenOdd?t.windCount2-=e.windDx:t.windCount2=t.windCount2===0?1:0),this.fillrule){case V.Positive:i=e.windCount,o=t.windCount;break;case V.Negative:i=-e.windCount,o=-t.windCount;break;default:i=Math.abs(e.windCount),o=Math.abs(t.windCount);break}let a=i===0||i===1,u=o===0||o===1;if(!(!d.isHotEdge(e)&&!a||!d.isHotEdge(t)&&!u))if(d.isHotEdge(e)&&d.isHotEdge(t))if(i!==0&&i!==1||o!==0&&o!==1||e.localMin.polytype!==t.localMin.polytype&&this.cliptype!==j.Xor)s=this.addLocalMaxPoly(e,t,n),s&&this.setZ(e,t,s.pt);else if(d.isFront(e)||e.outrec===t.outrec){s=this.addLocalMaxPoly(e,t,n),s&&this.setZ(e,t,s.pt);let l=this.addLocalMinPoly(e,t,n);this.setZ(e,t,l.pt)}else{s=this.addOutPt(e,n),this.setZ(e,t,s.pt);let l=this.addOutPt(t,n);this.setZ(e,t,l.pt),this.swapOutrecs(e,t)}else if(d.isHotEdge(e))s=this.addOutPt(e,n),this.setZ(e,t,s.pt),this.swapOutrecs(e,t);else if(d.isHotEdge(t))s=this.addOutPt(t,n),this.setZ(e,t,s.pt),this.swapOutrecs(e,t);else{let l,f;switch(this.fillrule){case V.Positive:l=e.windCount2,f=t.windCount2;break;case V.Negative:l=-e.windCount2,f=-t.windCount2;break;default:l=Math.abs(e.windCount2),f=Math.abs(t.windCount2);break}if(!d.isSamePolyType(e,t))s=this.addLocalMinPoly(e,t,n),this.setZ(e,t,s.pt);else if(i===1&&o===1){switch(s=null,this.cliptype){case j.Union:if(l>0&&f>0)return;s=this.addLocalMinPoly(e,t,n);break;case j.Difference:(d.getPolyType(e)===me.Clip&&l>0&&f>0||d.getPolyType(e)===me.Subject&&l<=0&&f<=0)&&(s=this.addLocalMinPoly(e,t,n));break;case j.Xor:s=this.addLocalMinPoly(e,t,n);break;default:if(l<=0||f<=0)return;s=this.addLocalMinPoly(e,t,n);break}s&&this.setZ(e,t,s.pt)}}}swapPositionsInAEL(e,t){let n=t.nextInAEL;n!==null&&(n.prevInAEL=e);let s=e.prevInAEL;s!==null&&(s.nextInAEL=t),t.prevInAEL=s,t.nextInAEL=e,e.prevInAEL=t,e.nextInAEL=n,t.prevInAEL===null&&(this.actives=t)}isValidAelOrder(e,t){if(t.curX!==e.curX)return t.curX>e.curX;let n=z.crossProductSign(e.top,t.bot,t.top);if(n!==0)return n<0;if(!d.isMaximaEdge(e)&&e.top.y>t.top.y)return z.crossProductSign(t.bot,e.top,d.nextVertex(e).pt)<=0;if(!d.isMaximaEdge(t)&&t.top.y>e.top.y)return z.crossProductSign(t.bot,t.top,d.nextVertex(t).pt)>=0;let s=t.bot.y,i=t.isLeftBound;return e.bot.y!==s||e.localMin.vertex.pt.y!==s?t.isLeftBound:e.isLeftBound!==i?i:z.isCollinear(d.prevPrevVertex(e).pt,e.bot,e.top)?!0:z.crossProductSign(d.prevPrevVertex(e).pt,t.bot,d.prevPrevVertex(t).pt)>0===i}isJoined(e){return e.joinWith!==xe.None}split(e,t){e.joinWith===xe.Right?(e.joinWith=xe.None,e.nextInAEL.joinWith=xe.None,this.addLocalMinPoly(e,e.nextInAEL,t,!0)):(e.joinWith=xe.None,e.prevInAEL.joinWith=xe.None,this.addLocalMinPoly(e.prevInAEL,e,t,!0))}setSides(e,t,n){e.frontEdge=t,e.backEdge=n}findEdgeWithMatchingLocMin(e){let t=e.nextInAEL;for(;t!==null;){if(t.localMin?.equals(e.localMin))return t;!d.isHorizontal(t)&&!(e.bot.x===t.bot.x&&e.bot.y===t.bot.y)?t=null:t=t.nextInAEL}for(t=e.prevInAEL;t!==null;){if(t.localMin?.equals(e.localMin))return t;if(!d.isHorizontal(t)&&!(e.bot.x===t.bot.x&&e.bot.y===t.bot.y))return null;t=t.prevInAEL}return t}addOutPt(e,t){let n=e.outrec,s=d.isFront(e),i=n.pts,o=i.next;if(s&&t.x===i.pt.x&&t.y===i.pt.y)return i;if(!s&&t.x===o.pt.x&&t.y===o.pt.y)return o;let a=new We(t,n);return o.prev=a,a.prev=i,a.next=o,i.next=a,s&&(n.pts=a),a}addLocalMaxPoly(e,t,n){if(this.isJoined(e)&&this.split(e,n),this.isJoined(t)&&this.split(t,n),d.isFront(e)===d.isFront(t))if(d.isOpenEnd(e))this.swapFrontBackSides(e.outrec);else if(d.isOpenEnd(t))this.swapFrontBackSides(t.outrec);else return this.succeeded=!1,null;let s=this.addOutPt(e,n);if(e.outrec===t.outrec){let i=e.outrec;if(i.pts=s,this.usingPolytree){let o=d.getPrevHotEdge(e);o===null?i.owner=null:this.setOwner(i,o.outrec)}this.uncoupleOutRec(e)}else d.isOpen(e)?e.windDx<0?this.joinOutrecPaths(e,t):this.joinOutrecPaths(t,e):e.outrec.idx<t.outrec.idx?this.joinOutrecPaths(e,t):this.joinOutrecPaths(t,e);return s}swapFrontBackSides(e){let t=e.frontEdge;e.frontEdge=e.backEdge,e.backEdge=t,e.pts=e.pts.next}setOwner(e,t){for(;t.owner!==null&&t.owner.pts===null;)t.owner=t.owner.owner;let n=t;for(;n!==null&&n!==e;)n=n.owner;n!==null&&(t.owner=e.owner),e.owner=t}uncoupleOutRec(e){let t=e.outrec;t!==null&&(t.frontEdge.outrec=null,t.backEdge.outrec=null,t.frontEdge=null,t.backEdge=null)}joinOutrecPaths(e,t){let n=e.outrec.pts,s=t.outrec.pts,i=n.next,o=s.next;d.isFront(e)?(o.prev=n,n.next=o,s.next=i,i.prev=s,e.outrec.pts=s,e.outrec.frontEdge=t.outrec.frontEdge,e.outrec.frontEdge!==null&&(e.outrec.frontEdge.outrec=e.outrec)):(i.prev=s,s.next=i,n.next=o,o.prev=n,e.outrec.backEdge=t.outrec.backEdge,e.outrec.backEdge!==null&&(e.outrec.backEdge.outrec=e.outrec)),t.outrec.frontEdge=null,t.outrec.backEdge=null,t.outrec.pts=null,this.setOwner(t.outrec,e.outrec),d.isOpenEnd(e)&&(t.outrec.pts=e.outrec.pts,e.outrec.pts=null),e.outrec=null,t.outrec=null}swapOutrecs(e,t){let n=e.outrec,s=t.outrec;if(n===s){let i=n.frontEdge;n.frontEdge=n.backEdge,n.backEdge=i;return}n!==null&&(e===n.frontEdge?n.frontEdge=t:n.backEdge=t),s!==null&&(t===s.frontEdge?s.frontEdge=e:s.backEdge=e),e.outrec=s,t.outrec=n}disposeIntersectNodes(){this.intersectList.length=0}static ptsReallyClose(e,t){return Math.abs(e.x-t.x)<2&&Math.abs(e.y-t.y)<2}static isVerySmallTriangle(e){return e.next.next===e.prev&&(d.ptsReallyClose(e.prev.pt,e.next.pt)||d.ptsReallyClose(e.pt,e.next.pt)||d.ptsReallyClose(e.pt,e.prev.pt))}static buildPath(e,t,n,s){if(e===null||e.next===e||!n&&e.next===e.prev)return!1;s.length=0;let i,o;for(t?(i=e.pt,o=e.prev):(e=e.next,i=e.pt,o=e.next),s.push(i);o!==e;)o.pt.x===i.x&&o.pt.y===i.y||(i=o.pt,s.push(i)),t?o=o.prev:o=o.next;return s.length!==3||n||!d.isVerySmallTriangle(o)}buildPaths(e,t){e.length=0,t.length=0;let n=0;for(;n<this.outrecList.length;){let s=this.outrecList[n++];if(s.pts===null)continue;let i=[];s.isOpen?d.buildPath(s.pts,this.reverseSolution,!0,i)&&t.push(i):(this.cleanCollinear(s),d.buildPath(s.pts,this.reverseSolution,!1,i)&&e.push(i))}return!0}buildTree(e,t){e.clear(),t.length=0;let n=0;for(;n<this.outrecList.length;){let s=this.outrecList[n++];if(s.pts!==null){if(s.isOpen){let i=[];d.buildPath(s.pts,this.reverseSolution,!0,i)&&t.push(i);continue}this.checkBounds(s)&&this.recursiveCheckOwners(s,e)}}}checkBounds(e){return e.pts===null?!1:lt.isEmpty(e.bounds)?(this.cleanCollinear(e),e.pts===null||!d.buildPath(e.pts,this.reverseSolution,!1,e.path)?!1:(e.bounds=z.getBounds(e.path),!0)):!0}recursiveCheckOwners(e,t){if(!(e.polypath!==null||lt.isEmpty(e.bounds))){for(;e.owner!==null&&!(e.owner.splits!==null&&this.checkSplitOwner(e,e.owner.splits)||e.owner.pts!==null&&this.checkBounds(e.owner)&&this.containsRect(e.owner.bounds,e.bounds)&&this.path1InsidePath2(e.pts,e.owner.pts));)e.owner=e.owner.owner;e.owner!==null?(e.owner.polypath===null&&this.recursiveCheckOwners(e.owner,t),e.polypath=e.owner.polypath.addChild(e.path)):e.polypath=t.addChild(e.path)}}cleanCollinear(e){if(e=this.getRealOutRec(e),e===null||e.isOpen)return;if(!this.isValidClosedPath(e.pts)){e.pts=null;return}let t=e.pts,n=t;for(;;){if(n!==null&&z.isCollinear(n.prev.pt,n.pt,n.next.pt)&&(n.pt.x===n.prev.pt.x&&n.pt.y===n.prev.pt.y||n.pt.x===n.next.pt.x&&n.pt.y===n.next.pt.y||!this.preserveCollinear||z.dotProductSign(n.prev.pt,n.pt,n.next.pt)<0)){if(n===e.pts&&(e.pts=n.prev),n=this.disposeOutPt(n),!this.isValidClosedPath(n)){e.pts=null;return}t=n;continue}if(n===null||(n=n.next,n===t))break}this.fixSelfIntersects(e)}isValidClosedPath(e){return e!==null&&e.next!==e&&(e.next!==e.prev||!d.isVerySmallTriangle(e))}disposeOutPt(e){let t=e.next===e?null:e.next;return e.prev.next=e.next,e.next.prev=e.prev,t}fixSelfIntersects(e){let t=e.pts;if(t.prev!==t.next.next)for(;;){if(t.next&&t.next.next&&this.boundingBoxesOverlap(t.prev.pt,t.pt,t.next.pt,t.next.next.pt)&&z.segsIntersect(t.prev.pt,t.pt,t.next.pt,t.next.next.pt)){if((t===e.pts||t.next===e.pts)&&(e.pts=e.pts.prev),this.doSplitOp(e,t),e.pts===null)return;if(t=e.pts,t.prev===t.next.next)break;continue}if(t=t.next,t===e.pts)break}}doSplitOp(e,t){let n=t.prev,s=t.next.next;e.pts=n;let i=z.getLineIntersectPt(n.pt,t.pt,t.next.pt,s.pt);this.zCallbackInternal&&this.zCallbackInternal(n.pt,t.pt,t.next.pt,s.pt,i);let o=d.areaOutPt(n),a=o<Mt?-o:o;if(a<jn){e.pts=null;return}let u=this.areaTriangle(i,t.pt,t.next.pt),l=u<Mt?-u:u;if(i.x===n.pt.x&&i.y===n.pt.y||i.x===s.pt.x&&i.y===s.pt.y)s.prev=n,n.next=s;else{let h=new We(i,e);h.prev=n,h.next=s,s.prev=h,n.next=h}if(!(l>Go)||!(l>a)&&u>Mt!=o>Mt)return;let f=this.newOutRec();f.owner=e.owner,t.outrec=f,t.next.outrec=f;let c=new We(i,f);c.prev=t.next,c.next=t,f.pts=c,t.prev=c,t.next.next=c,this.usingPolytree&&(this.path1InsidePath2(n,c)?(f.splits===null&&(f.splits=[]),f.splits.push(e.idx)):(e.splits===null&&(e.splits=[]),e.splits.push(f.idx)))}static areaOutPt(e){let t=z.maxCoordForSafeAreaProduct,n=0,s=!0,i=e;do{let a=i.prev,u=i.pt;if(Math.abs(a.pt.x)>=t||Math.abs(a.pt.y)>=t||Math.abs(u.x)>=t||Math.abs(u.y)>=t){s=!1;break}n+=(a.pt.y+u.y)*(a.pt.x-u.x),i=i.next}while(i!==e);if(s)return BigInt(Math.round(n));let o=Mt;i=e;do{let a=i.prev;if(Number.isSafeInteger(a.pt.y)&&Number.isSafeInteger(i.pt.y)&&Number.isSafeInteger(a.pt.x)&&Number.isSafeInteger(i.pt.x)){let u=BigInt(a.pt.y)+BigInt(i.pt.y),l=BigInt(a.pt.x)-BigInt(i.pt.x);o+=u*l}else{let u=a.pt.y+i.pt.y,l=a.pt.x-i.pt.x;o+=BigInt(Math.round(u*l))}i=i.next}while(i!==e);return o}areaTriangle(e,t,n){let s=z.maxCoordForSafeAreaProduct;if(Math.abs(e.x)<s&&Math.abs(e.y)<s&&Math.abs(t.x)<s&&Math.abs(t.y)<s&&Math.abs(n.x)<s&&Math.abs(n.y)<s){let o=(n.y+e.y)*(n.x-e.x)+(e.y+t.y)*(e.x-t.x)+(t.y+n.y)*(t.x-n.x);return BigInt(Math.round(o))}if(Number.isSafeInteger(e.x)&&Number.isSafeInteger(e.y)&&Number.isSafeInteger(t.x)&&Number.isSafeInteger(t.y)&&Number.isSafeInteger(n.x)&&Number.isSafeInteger(n.y)){let o=(BigInt(n.y)+BigInt(e.y))*(BigInt(n.x)-BigInt(e.x)),a=(BigInt(e.y)+BigInt(t.y))*(BigInt(e.x)-BigInt(t.x)),u=(BigInt(t.y)+BigInt(n.y))*(BigInt(t.x)-BigInt(n.x));return o+a+u}let i=(n.y+e.y)*(n.x-e.x)+(e.y+t.y)*(e.x-t.x)+(t.y+n.y)*(t.x-n.x);return BigInt(Math.round(i))}isValidOwner(e,t){for(;t!==null&&t!==e;)t=t.owner;return t===null}containsRect(e,t){return t.left>=e.left&&t.right<=e.right&&t.top>=e.top&&t.bottom<=e.bottom}checkSplitOwner(e,t){for(let n=0;n<t.length;n++){let s=this.outrecList[t[n]];if(s.pts===null&&s.splits!==null&&this.checkSplitOwner(e,s.splits))return!0;if(s=this.getRealOutRec(s),!(s===null||s===e||s.recursiveSplit===e)){if(s.recursiveSplit=e,s.splits!==null&&this.checkSplitOwner(e,s.splits))return!0;if(!(!this.checkBounds(s)||!this.containsRect(s.bounds,e.bounds)||!this.path1InsidePath2(e.pts,s.pts)))return this.isValidOwner(e,s)||(s.owner=e.owner),e.owner=s,!0}}return!1}};b(d,"openPathsEnabled",!0);var lr=d,Oe=class extends lr{constructor(){super(...arguments);b(this,"zCallback")}getZCallback(){return this.zCallback}addPath(t,n,s=!1){super.addPath(t,n,s)}addReuseableData(t){super.addReuseableData(t)}addPaths(t,n,s=!1){super.addPaths(t,n,s)}addSubject(t){this.addPaths(t,me.Subject)}addOpenSubject(t){this.addPaths(t,me.Subject,!0)}addClip(t){this.addPaths(t,me.Clip)}execute(t,n,s,i){if(Array.isArray(s)){let o=s,a=i;o.length=0,a&&(a.length=0);try{this.executeInternal(t,n),this.buildPaths(o,a||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}else{let o=s,a=i;o.clear(),a&&(a.length=0),this.usingPolytree=!0;try{this.executeInternal(t,n),this.buildTree(o,a||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}}};var Yr={area(r){return z.area(r)},areaD(r){let e=0,t=r.length;if(t<3)return 0;let n=r[t-1];for(let s of r)e+=(n.y+s.y)*(n.x-s.x),n=s;return e*.5},scalePath64(r,e){let t=z.maxSafeCoordinateForScale(e),n=[];for(let s of r)z.checkSafeScaleValue(s.x,t,"scalePath64"),z.checkSafeScaleValue(s.y,t,"scalePath64"),n.push({x:Math.round(s.x*e),y:Math.round(s.y*e)});return n},scalePaths64(r,e){let t=[];for(let n of r)t.push(Yr.scalePath64(n,e));return t},scalePathD(r,e){let t=[];for(let n of r)t.push({x:n.x*e,y:n.y*e});return t},scalePathsD(r,e){let t=[];for(let n of r)t.push(Yr.scalePathD(n,e));return t}};var ye;(function(r){r[r.Miter=0]="Miter",r[r.Square=1]="Square",r[r.Bevel=2]="Bevel",r[r.Round=3]="Round"})(ye||(ye={}));var ne;(function(r){r[r.Polygon=0]="Polygon",r[r.Joined=1]="Joined",r[r.Butt=2]="Butt",r[r.Square=3]="Square",r[r.Round=4]="Round"})(ne||(ne={}));var jr=class{constructor(e,t,n=ne.Polygon){b(this,"inPaths");b(this,"joinType");b(this,"endType");b(this,"pathsReversed");b(this,"lowestPathIdx");this.joinType=t,this.endType=n;let s=n===ne.Polygon||n===ne.Joined;this.inPaths=[];for(let i of e)this.inPaths.push(ft.stripDuplicates(i,s));if(n===ne.Polygon){let i=ft.getLowestPathInfo(this.inPaths);this.lowestPathIdx=i.idx,this.pathsReversed=this.lowestPathIdx>=0&&i.isNegArea}else this.lowestPathIdx=-1,this.pathsReversed=!1}},re=class re{constructor(e=2,t=0,n=!1,s=!1){b(this,"groupList",[]);b(this,"pathOut",[]);b(this,"normals",[]);b(this,"solution",[]);b(this,"solutionTree",null);b(this,"groupDelta",0);b(this,"delta",0);b(this,"mitLimSqr",0);b(this,"stepsPerRad",0);b(this,"stepSin",0);b(this,"stepCos",0);b(this,"joinType",ye.Bevel);b(this,"endType",ne.Polygon);b(this,"arcTolerance",0);b(this,"mergeGroups",!0);b(this,"miterLimit",2);b(this,"preserveCollinear",!1);b(this,"reverseSolution",!1);b(this,"zCallback");b(this,"deltaCallback",null);b(this,"ZCB",(e,t,n,s,i)=>{(e.z||0)!==0&&(e.z===n.z||e.z===s.z)?i.z=e.z:(n.z||0)!==0&&n.z===t.z?i.z=n.z:(t.z||0)!==0&&t.z===s.z?i.z=t.z:this.zCallback&&this.zCallback(e,t,n,s,i)});this.miterLimit=e,this.arcTolerance=t,this.mergeGroups=!0,this.preserveCollinear=n,this.reverseSolution=s}clear(){this.groupList.length=0}addPath(e,t,n){if(e.length===0)return;let s=[e];this.addPaths(s,t,n)}addPaths(e,t,n){e.length!==0&&this.groupList.push(new jr(e,t,n))}calcSolutionCapacity(){let e=0;for(let t of this.groupList)e+=t.endType===ne.Joined?t.inPaths.length*2:t.inPaths.length;return e}checkPathsReversed(){let e=!1;for(let t of this.groupList)if(t.endType===ne.Polygon){e=t.pathsReversed;break}return e}executeInternal(e){if(this.groupList.length===0)return;if(Math.abs(e)<.5){for(let i of this.groupList)for(let o of i.inPaths)this.solution.push(o);return}this.delta=e,this.mitLimSqr=this.miterLimit<=1?2:2/re.sqr(this.miterLimit);for(let i of this.groupList)this.doGroupOffset(i);if(this.groupList.length===0)return;let t=this.checkPathsReversed(),n=t?V.Negative:V.Positive,s=new Oe;s.preserveCollinear=this.preserveCollinear,s.reverseSolution=this.reverseSolution!==t,s.zCallback=this.ZCB,s.addSubject(this.solution),this.solutionTree!==null?s.execute(j.Union,n,this.solutionTree):s.execute(j.Union,n,this.solution)}execute(e,t){if(Array.isArray(t)){let n=t;n.length=0,this.solution=n,this.executeInternal(e)}else{let n=t;n.clear(),this.solutionTree=n,this.solution=[],this.executeInternal(e)}}executeWithCallback(e,t){this.deltaCallback=e,this.execute(1,t)}static getUnitNormal(e,t){let n=t.x-e.x,s=t.y-e.y;if(n===0&&s===0)return{x:0,y:0};let i=1/Math.sqrt(n*n+s*s);return{x:s*i,y:-n*i}}static getLowestPathInfo(e){let t=-1,n=!1,s={x:Number.MAX_SAFE_INTEGER,y:Number.MIN_SAFE_INTEGER};for(let i=0;i<e.length;++i){let o=Number.MAX_VALUE;for(let a of e[i])if(!(a.y<s.y||a.y===s.y&&a.x>=s.x)){if(o===Number.MAX_VALUE){if(o=re.area(e[i]),o===0)break;n=o<0}t=i,s.x=a.x,s.y=a.y}}return{idx:t,isNegArea:n}}static translatePoint(e,t,n){return{x:e.x+t,y:e.y+n,z:e.z}}static reflectPoint(e,t){return{x:t.x+(t.x-e.x),y:t.y+(t.y-e.y),z:e.z}}static almostZero(e,t=.001){return Math.abs(e)<t}static hypotenuse(e,t){return Math.sqrt(e*e+t*t)}static normalizeVector(e){let t=re.hypotenuse(e.x,e.y);if(re.almostZero(t))return{x:0,y:0};let n=1/t;return{x:e.x*n,y:e.y*n}}static getAvgUnitVector(e,t){return re.normalizeVector({x:e.x+t.x,y:e.y+t.y})}static intersectPoint(e,t,n,s){if(z.isAlmostZero(e.x-t.x)){if(z.isAlmostZero(n.x-s.x))return{x:0,y:0};let i=(s.y-n.y)/(s.x-n.x),o=n.y-i*n.x;return{x:e.x,y:i*e.x+o}}if(z.isAlmostZero(n.x-s.x)){let i=(t.y-e.y)/(t.x-e.x),o=e.y-i*e.x;return{x:n.x,y:i*n.x+o}}else{let i=(t.y-e.y)/(t.x-e.x),o=e.y-i*e.x,a=(s.y-n.y)/(s.x-n.x),u=n.y-a*n.x;if(z.isAlmostZero(i-a))return{x:0,y:0};let l=(u-o)/(i-a);return{x:l,y:i*l+o}}}getPerpendic(e,t){return{x:Math.round(e.x+t.x*this.groupDelta),y:Math.round(e.y+t.y*this.groupDelta),z:e.z||0}}getPerpendicD(e,t){return{x:e.x+t.x*this.groupDelta,y:e.y+t.y*this.groupDelta,z:e.z||0}}doBevel(e,t,n){let s,i,o=e[t].z||0;if(t===n){let a=Math.abs(this.groupDelta);s={x:Math.round(e[t].x-a*this.normals[t].x),y:Math.round(e[t].y-a*this.normals[t].y),z:o},i={x:Math.round(e[t].x+a*this.normals[t].x),y:Math.round(e[t].y+a*this.normals[t].y),z:o}}else s={x:Math.round(e[t].x+this.groupDelta*this.normals[n].x),y:Math.round(e[t].y+this.groupDelta*this.normals[n].y),z:o},i={x:Math.round(e[t].x+this.groupDelta*this.normals[t].x),y:Math.round(e[t].y+this.groupDelta*this.normals[t].y),z:o};this.pathOut.push(s),this.pathOut.push(i)}doSquare(e,t,n){let s;t===n?s={x:this.normals[t].y,y:-this.normals[t].x}:s=re.getAvgUnitVector({x:-this.normals[n].y,y:this.normals[n].x},{x:this.normals[t].y,y:-this.normals[t].x});let i=Math.abs(this.groupDelta),o={x:e[t].x,y:e[t].y,z:e[t].z||0};o=re.translatePoint(o,i*s.x,i*s.y);let a=re.translatePoint(o,this.groupDelta*s.y,this.groupDelta*-s.x),u=re.translatePoint(o,this.groupDelta*-s.y,this.groupDelta*s.x),l=this.getPerpendicD(e[n],this.normals[n]);if(t===n){let f={x:l.x+s.x*this.groupDelta,y:l.y+s.y*this.groupDelta},c=re.intersectPoint(a,u,l,f);c.z=o.z,this.pathOut.push(He.fromPointD(re.reflectPoint(c,o))),this.pathOut.push(He.fromPointD(c))}else{let f=this.getPerpendicD(e[t],this.normals[n]),c=re.intersectPoint(a,u,l,f);c.z=o.z,this.pathOut.push(He.fromPointD(c)),this.pathOut.push(He.fromPointD(re.reflectPoint(c,o)))}}doMiter(e,t,n,s){let i=this.groupDelta/(s+1);this.pathOut.push({x:Math.round(e[t].x+(this.normals[n].x+this.normals[t].x)*i),y:Math.round(e[t].y+(this.normals[n].y+this.normals[t].y)*i),z:e[t].z||0})}doRound(e,t,n,s){if(this.deltaCallback!==null){let l=Math.abs(this.groupDelta),f=this.arcTolerance>.01?this.arcTolerance:l*re.arc_const,c=Math.PI/Math.acos(1-f/l);this.stepSin=Math.sin(2*Math.PI/c),this.stepCos=Math.cos(2*Math.PI/c),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=c/(2*Math.PI)}let i=e[t],o=i.z||0,a={x:this.normals[n].x*this.groupDelta,y:this.normals[n].y*this.groupDelta};t===n&&sr.negate(a),this.pathOut.push({x:Math.round(i.x+a.x),y:Math.round(i.y+a.y),z:o});let u=Math.ceil(this.stepsPerRad*Math.abs(s));for(let l=1;l<u;l++)a={x:a.x*this.stepCos-this.stepSin*a.y,y:a.x*this.stepSin+a.y*this.stepCos},this.pathOut.push({x:Math.round(i.x+a.x),y:Math.round(i.y+a.y),z:o});this.pathOut.push(this.getPerpendic(e[t],this.normals[t]))}buildNormals(e){let t=e.length;if(this.normals.length=0,t!==0){for(let n=0;n<t-1;n++)this.normals.push(re.getUnitNormal(e[n],e[n+1]));this.normals.push(re.getUnitNormal(e[t-1],e[0]))}}offsetPoint(e,t,n,s){if(He.equals(t[n],t[s]))return;let i=z.crossProductD(this.normals[n],this.normals[s]),o=z.dotProductD(this.normals[n],this.normals[s]);if(i>1?i=1:i<-1&&(i=-1),this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,n,s),e.pathsReversed&&(this.groupDelta=-this.groupDelta)),Math.abs(this.groupDelta)<re.Tolerance){this.pathOut.push(t[n]);return}if(o>-.999&&i*this.groupDelta<0)this.pathOut.push(this.getPerpendic(t[n],this.normals[s])),this.pathOut.push(t[n]),this.pathOut.push(this.getPerpendic(t[n],this.normals[n]));else if(o>.999&&this.joinType!==ye.Round)this.doMiter(t,n,s,o);else switch(this.joinType){case ye.Miter:o>this.mitLimSqr-1?this.doMiter(t,n,s,o):this.doSquare(t,n,s);break;case ye.Round:this.doRound(t,n,s,Math.atan2(i,o));break;case ye.Bevel:this.doBevel(t,n,s);break;default:this.doSquare(t,n,s);break}}offsetPolygon(e,t){this.pathOut=[];let n=t.length,s=n-1;for(let i=0;i<n;i++)this.offsetPoint(e,t,i,s),s=i;this.solution.push(this.pathOut)}offsetOpenJoined(e,t){this.offsetPolygon(e,t);let n=[...t].reverse();this.buildNormals(n),this.offsetPolygon(e,n)}offsetOpenPath(e,t){this.pathOut=[];let n=t.length-1;if(this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,0,0)),Math.abs(this.groupDelta)<re.Tolerance)this.pathOut.push(t[0]);else switch(this.endType){case ne.Butt:this.doBevel(t,0,0);break;case ne.Round:this.doRound(t,0,0,Math.PI);break;default:this.doSquare(t,0,0);break}for(let s=1,i=0;s<n;s++)this.offsetPoint(e,t,s,i),i=s;for(let s=n;s>0;s--)this.normals[s]={x:-this.normals[s-1].x,y:-this.normals[s-1].y};if(this.normals[0]=this.normals[n],this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,n,n)),Math.abs(this.groupDelta)<re.Tolerance)this.pathOut.push(t[n]);else switch(this.endType){case ne.Butt:this.doBevel(t,n,n);break;case ne.Round:this.doRound(t,n,n,Math.PI);break;default:this.doSquare(t,n,n);break}for(let s=n-1,i=n;s>0;s--)this.offsetPoint(e,t,s,i),i=s;this.solution.push(this.pathOut)}doGroupOffset(e){e.endType===ne.Polygon?(e.lowestPathIdx<0&&(this.delta=Math.abs(this.delta)),this.groupDelta=e.pathsReversed?-this.delta:this.delta):this.groupDelta=Math.abs(this.delta);let t=Math.abs(this.groupDelta);if(this.joinType=e.joinType,this.endType=e.endType,e.joinType===ye.Round||e.endType===ne.Round){let n=this.arcTolerance>.01?this.arcTolerance:t*re.arc_const,s=Math.PI/Math.acos(1-n/t);this.stepSin=Math.sin(2*Math.PI/s),this.stepCos=Math.cos(2*Math.PI/s),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=s/(2*Math.PI)}for(let n of e.inPaths){this.pathOut=[];let s=n.length;if(s===1){let i=n[0];this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(n,this.normals,0,0),e.pathsReversed&&(this.groupDelta=-this.groupDelta));let o=i.z||0;if(e.endType===ne.Round){let a=Math.ceil(this.stepsPerRad*2*Math.PI);if(this.pathOut=re.ellipse(i,Math.abs(this.groupDelta),Math.abs(this.groupDelta),a),o!==0)for(let u=0;u<this.pathOut.length;u++)this.pathOut[u].z=o}else{let a=Math.ceil(Math.abs(this.groupDelta)),u={left:i.x-a,top:i.y-a,right:i.x+a,bottom:i.y+a};this.pathOut=[{x:u.left,y:u.top,z:o},{x:u.right,y:u.top,z:o},{x:u.right,y:u.bottom,z:o},{x:u.left,y:u.bottom,z:o}]}this.solution.push(this.pathOut);continue}switch(s===2&&e.endType===ne.Joined&&(this.endType=e.joinType===ye.Round?ne.Round:ne.Square),this.buildNormals(n),this.endType){case ne.Polygon:this.offsetPolygon(e,n);break;case ne.Joined:this.offsetOpenJoined(e,n);break;default:this.offsetOpenPath(e,n);break}}}static stripDuplicates(e,t){let n=e.length,s=[];if(n===0)return s;let i=e[0];s.push(i);for(let o=1;o<n;o++)He.equals(i,e[o])||(i=e[o],s.push(i));return t&&He.equals(i,s[0])&&s.pop(),s}static area(e){return z.area(e)}static sqr(e){return e*e}static ellipse(e,t,n=0,s=0){if(t<=0)return[];n<=0&&(n=t),s<=2&&(s=Math.ceil(Math.PI*Math.sqrt((t+n)/2)));let i=Math.sin(2*Math.PI/s),o=Math.cos(2*Math.PI/s),a=o,u=i,l=[{x:Math.round(e.x+t),y:e.y}];for(let f=1;f<s;++f){l.push({x:Math.round(e.x+t*a),y:Math.round(e.y+n*u)});let c=a*o-u*i;u=u*o+a*i,a=c}return l}};b(re,"Tolerance",1e-12),b(re,"arc_const",.002);var ft=re;var Fh=BigInt(2);function Jr(r,e,t){return typeof e=="number"?Kr(j.Union,r,null,e):Kr(j.Union,r,e,t)}function Kr(r,e,t,n){let s=[];if(e===null)return s;let i=new Oe;return i.addPaths(e,me.Subject),t!==null&&i.addPaths(t,me.Clip),i.execute(r,n,s),s}function fr(r,e,t,n,s=2,i=0){let o=new ft(s,i);o.addPaths(r,t,n);let a=[];return o.execute(e,a),a}var Ye=1e4;function ht(){return{layers:new Map,parts:[]}}function Te(r,e="cut"){return{layers:new Map([[e,{regions:r,lines:[]}]]),parts:[]}}function bt(r,e="cut"){return{layers:new Map([[e,{regions:[],lines:r}]]),parts:[]}}function ts(r){if(r.parts.length)return!1;for(let e of r.layers.values())if(e.regions.length||e.lines.length)return!1;return!0}var je=r=>r.map(e=>e.map(([t,n])=>({x:Math.round(t*Ye),y:Math.round(n*Ye)}))),St=r=>r.filter(e=>e.length>=2).map(e=>e.map(t=>[t.x/Ye,t.y/Ye]));function de(r,e="nonzero"){if(!r.length)return[];let t=e==="evenodd"?V.EvenOdd:V.NonZero;return St(Jr(je(r),t)).filter(n=>n.length>=3)}function rs(r,e,t){if(!e.length)return[];let n=new Oe;n.addSubject(je(e)),t.length&&n.addClip(je(t));let s=[];return n.execute(r,V.NonZero,s),St(s).filter(i=>i.length>=3)}var hr=(r,e)=>e.length?rs(j.Difference,r,e):de(r),cr=(r,e)=>rs(j.Intersection,r,e);function Rt(r,e,t){if(!r.length)return[];if(!e.length)return t==="outside"?r:[];let n=new Oe;n.addOpenSubject(je(r)),n.addClip(je(e));let s=[],i=[];return n.execute(t==="inside"?j.Intersection:j.Difference,V.NonZero,s,i),St(i)}function pr(r,e,t="round",n=.01){if(!r.length)return[];if(e===0)return de(r);let s=t==="round"?ye.Round:t==="square"?ye.Square:ye.Miter,i=fr(je(de(r)),e*Ye,s,ne.Polygon,2,n*Ye);return St(i).filter(o=>o.length>=3)}function ns(r,e){if(!r.length||e<=0)return[];let t=fr(je(r),e/2*Ye,ye.Round,ne.Round,2,.01*Ye);return St(t)}function ss(r){if(!r.length)return[];let e=new Ut,t=new Oe;t.addSubject(je(r)),t.execute(j.Union,V.NonZero,e);let n=[],s=i=>{for(let o=0;o<i.count;o++){let a=i.child(o),u=[a.poly];for(let l=0;l<a.count;l++){let f=a.child(l);u.push(f.poly),s(f)}n.push(St(u))}};return s(e),n}function Ke(r){let e=0;for(let t=0,n=r.length-1;t<r.length;n=t++)e+=(r[n][0]+r[t][0])*(r[n][1]-r[t][1]);return-e/2}function Jn(r,[e,t]){return[r[0]*e+r[2]*t+r[4],r[1]*e+r[3]*t+r[5]]}function Qn(r,e){let t=e[0]*e[3]-e[1]*e[2]<0,n=new Map;for(let[s,i]of r)n.set(s,{regions:i.regions.map(o=>{let a=o.map(u=>Jn(e,u));return t?a.reverse():a}),lines:i.lines.map(o=>o.map(a=>Jn(e,a)))});return n}function dr(r,e){return{layers:Qn(r.layers,e),parts:r.parts.map(t=>({...t,layers:Qn(t.layers,e)}))}}function Nt(r){let e=ht();for(let t of r){for(let[n,s]of t.layers){let i=e.layers.get(n)??{regions:[],lines:[]};for(let o of s.regions)i.regions.push(o);for(let o of s.lines)i.lines.push(o);e.layers.set(n,i)}for(let n of t.parts)e.parts.push(n)}return e}function es(r,e){let t={regions:[],lines:[]};for(let n of r.values()){for(let s of n.regions)t.regions.push(s);for(let s of n.lines)t.lines.push(s)}return new Map([[e,t]])}function gr(r,e){if(r.parts.length&&e!=="guide")throw new Error(`a part cannot go on the ${e} layer as a whole. Put ${e}() inside part() instead.`);return{layers:es(r.layers,e),parts:r.parts.map(t=>({...t,layers:es(t.layers,e)}))}}function vr(r){let e=1/0,t=1/0,n=-1/0,s=-1/0;for(let i of r)for(let[o,a]of i)o<e&&(e=o),a<t&&(t=a),o>n&&(n=o),a>s&&(s=a);return e===1/0?null:[e,t,n,s]}function Qr(r,e){let t=[];for(let[n,s]of r)if(!e?.(n))for(let i of[...s.regions,...s.lines])t.push(i);return vr(t)}function is(r){let e=[...r].sort((i,o)=>i[0]-o[0]||i[1]-o[1]);if(e.length<3)return e;let t=(i,o,a)=>(o[0]-i[0])*(a[1]-i[1])-(o[1]-i[1])*(a[0]-i[0]),n=[];for(let i of e){for(;n.length>=2&&t(n[n.length-2],n[n.length-1],i)<=0;)n.pop();n.push(i)}let s=[];for(let i=e.length-1;i>=0;i--){let o=e[i];for(;s.length>=2&&t(s[s.length-2],s[s.length-1],o)<=0;)s.pop();s.push(o)}return s.pop(),n.pop(),n.concat(s)}function os(r,e,t,n){return r<1e-9?3:e>0?Math.max(Math.floor(e),3):Math.max(Math.ceil(Math.min(360/t,r*2*Math.PI/n)),5)}function mr(r,e,t){let n=[];for(let s=0;s<t;s++){let i=2*Math.PI*s/t;n.push([r*Math.cos(i),e*Math.sin(i)])}return n}function as(r,e,t,n){if(t=Math.min(t,r/2,e/2),t<=0)return[[0,0],[r,0],[r,e],[0,e]];let s=Math.max(1,Math.ceil(n(t)/4)),i=[],o=[[r-t,t,-90],[r-t,e-t,0],[t,e-t,90],[t,t,180]];for(let[a,u,l]of o)for(let f=0;f<=s;f++){let c=(l+90*f/s)*Math.PI/180;i.push([a+t*Math.cos(c),u+t*Math.sin(c)])}return i}function xr(r,e){let t=Math.round(r/e);return t%2===0&&(t+=r/e>t?1:-1),Math.max(3,t)}var Bt=(r,e,t,n)=>[[r,e],[t,e],[t,n],[r,n]];function qo(r,e,t,n){if(e==="flat")return[];let s=xr(r,n),i=r/s,o=[];for(let a=0;a<s;a++)(e==="out"?a%2===1:a%2===0)&&o.push(Bt(a*i,-1,(a+1)*i,t));return o}function us(r,e,t,n,s){let i=[([u,l])=>[u,l],([u,l])=>[r-l,u],([u,l])=>[r-u,e-l],([u,l])=>[l,e-u]],o=[r,e,r,e],a=[];return t.forEach((u,l)=>{for(let f of qo(o[l],u,n,s))a.push(f.map(i[l]))}),hr([Bt(0,0,r,e)],a)}function ls(r,e,t,n){let s=xr(r,n),i=r/s,o=[];for(let a=0;a<s;a++)(e==="out"?a%2===0:a%2===1)&&o.push(Bt(a*i,-t/2,(a+1)*i,t/2));return o}function fs(r,e,t,n,s){let i=Bt(-r/2,-1,r/2,e),o=Bt(-t/2,s,t/2,s+n);return[i,o]}function hs(r,e,t,n,s){let i=[],o=s+n,a=Math.floor(r/t),u=(r-a*t)/2;for(let l=0;l<=a;l++){let f=u+l*t,c=l%2===0?n:n-o/2;for(let h=c;h<e;h+=o){let p=Math.max(h,l%2===0?n:0),g=Math.min(h+s,e-(l%2===0?n:0));g-p>=n/2&&i.push([[f,p],[f,g]])}}return i}var R=class extends Error{constructor(t,n){super(n?`${t} (line ${n.line}, column ${n.col})`:t);this.echoes=[];this.name="KerfError",n&&(this.line=n.line,this.col=n.col)}},Wo=["<=",">=","==","!=","&&","||","+","-","*","/","%","^","<",">","!","?",":","=",".",",",";","(",")","[","]","{","}","#"];function yr(r){let e=[],t=[],n=0,s=1,i=0,o=()=>({line:s,col:n-i+1,offset:n}),a=u=>{for(let l=0;l<u;l++)r[n]===`
7
- `&&(s++,i=n+1),n++};for(;n<r.length;){let u=r[n];if(u===" "||u===" "||u==="\r"||u===`
8
- `){a(1);continue}if(u==="/"&&r[n+1]==="/"){let c=r.indexOf(`
9
- `,n),h=c<0?r.length:c,p=/^[ \t]*$/.test(r.slice(r.lastIndexOf(`
10
- `,n-1)+1,n));t.push({text:r.slice(n+2,h).trim(),line:s,block:!1,own:p}),n=h;continue}if(u==="/"&&r[n+1]==="*"){let c=o(),h=r.indexOf("*/",n+2);if(h<0)throw new R("Unclosed block comment",c);t.push({text:r.slice(n+2,h).trim(),line:c.line,block:!0,own:!0}),a(h+2-n);continue}let l=o();if(/[0-9]/.test(u)||u==="."&&/[0-9]/.test(r[n+1]??"")){let c=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(r.slice(n));e.push({type:"num",value:c[0],pos:l}),a(c[0].length);continue}if(/[A-Za-z_$]/.test(u)){let c=/^[A-Za-z_$][A-Za-z0-9_]*/.exec(r.slice(n));e.push({type:"id",value:c[0],pos:l}),a(c[0].length);continue}if(u==='"'){let c="";for(a(1);n<r.length&&r[n]!=='"';){if(r[n]==="\\"){let h=r[n+1];if(h==="n")c+=`
11
- `;else if(h==="t")c+=" ";else if(h==="u"){let p=r.slice(n+2,n+6);if(!/^[0-9a-fA-F]{4}$/.test(p))throw new R("Bad \\u escape",o());c+=String.fromCharCode(parseInt(p,16)),a(4)}else c+=h;a(2);continue}if(r[n]===`
12
- `)throw new R("Unclosed string",l);c+=r[n],a(1)}if(n>=r.length)throw new R("Unclosed string",l);a(1),e.push({type:"str",value:c,pos:l});continue}if(u==="<"&&/^<[A-Za-z0-9_./-]+>/.test(r.slice(n))){let c=e[e.length-1];if(c&&c.type==="id"&&(c.value==="use"||c.value==="include")){let h=/^<([A-Za-z0-9_./-]+)>/.exec(r.slice(n));e.push({type:"str",value:h[1],pos:l}),a(h[0].length);continue}}let f=Wo.find(c=>r.startsWith(c,n));if(!f)throw new R(`Unexpected character "${u}"`,l);e.push({type:"punct",value:f,pos:l}),a(f.length)}return e.push({type:"eof",value:"",pos:o()}),{tokens:e,comments:t}}var en=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]);function Je(r){let{tokens:e,comments:t}=yr(r),n=new tn(e),s=[];for(;!n.at("eof");)s.push(...n.statement());return{program:{body:s},comments:t}}var Gt=class Gt{constructor(e){this.tokens=e;this.i=0}peek(e=0){return this.tokens[Math.min(this.i+e,this.tokens.length-1)]}at(e,t,n=0){let s=this.peek(n);return s.type===e&&(t===void 0||s.value===t)}isP(e,t=0){return this.at("punct",e,t)}isK(e,t=0){return this.at("id",e,t)}next(){return this.tokens[this.i++]}fail(e,t=this.peek()){let n=t.type==="eof"?"end of file":`"${t.value}"`;throw new R(`${e}, found ${n}`,t.pos)}expectP(e){return this.isP(e)||this.fail(`Expected "${e}"`),this.next()}ident(){let e=this.peek();return(e.type!=="id"||en.has(e.value))&&this.fail("Expected a name"),this.next()}statement(){let e=this.peek();if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let o=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),o.push(...this.statement());return this.next(),[{kind:"block",body:o,pos:e.pos}]}if(this.isK("module")){this.next();let o=this.ident().value,a=this.params();return[{kind:"module",name:o,params:a,body:this.body(),pos:e.pos}]}if(this.isK("function")&&this.at("id",void 0,1)){this.next();let o=this.ident().value,a=this.params();this.expectP("=");let u=this.expr();return this.expectP(";"),[{kind:"function",name:o,params:a,body:u,pos:e.pos}]}if(this.isK("use")||this.isK("include")){this.next();let o=this.peek();return o.type!=="str"&&this.fail("Expected a library path like <kerf/box>"),this.next(),this.isP(";")&&this.next(),[{kind:"use",path:o.value,include:e.value==="include",pos:e.pos}]}if(this.isK("for"))return this.next(),[{kind:"for",assigns:this.assigns(),body:this.body(),pos:e.pos}];if(this.isK("if")){this.next(),this.expectP("(");let o=this.expr();this.expectP(")");let a=this.body(),u=[];return this.isK("else")&&(this.next(),u=this.body()),[{kind:"if",cond:o,then:a,else:u,pos:e.pos}]}if(this.isK("let")&&this.isP("(",1))return this.next(),[{kind:"let",assigns:this.assigns(),body:this.body(),pos:e.pos}];if(e.type==="id"&&this.isP("=",1)){let o=this.ident().value;this.next();let a=this.peek().pos.offset,u=this.expr(),l=this.expectP(";").pos.offset;return[{kind:"assign",name:o,value:u,span:[a,l],pos:e.pos}]}let t=null;(this.isP("*")||this.isP("!")||this.isP("#")||this.isP("%"))&&(t=this.next().value);let n=this.peek();(n.type!=="id"||en.has(n.value))&&this.fail("Expected a statement"),this.next();let s=this.args(),i=this.body();return[{kind:"call",name:n.value,args:s,children:i,modifier:t,pos:n.pos}]}body(){if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let e=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),e.push(...this.statement());return this.next(),e}return this.statement()}params(){this.expectP("(");let e=[];for(;!this.isP(")");){let t=this.ident().value,n=null;this.isP("=")&&(this.next(),n=this.expr()),e.push({name:t,default:n}),this.isP(")")||this.expectP(",")}return this.next(),e}args(){this.expectP("(");let e=[];for(;!this.isP(")");){let t=null;this.at("id")&&this.isP("=",1)&&(t=this.next().value,this.next()),e.push({name:t,value:this.expr()}),this.isP(")")||this.expectP(",")}return this.next(),e}assigns(){this.expectP("(");let e=[];for(;!this.isP(")");){let t=this.ident();this.expectP("="),e.push({name:t.value,value:this.expr(),pos:t.pos}),this.isP(")")||this.expectP(",")}return this.next(),e}expr(){let e=this.peek();if(this.isK("function")&&this.isP("(",1))return this.next(),{kind:"lambda",params:this.params(),body:this.expr(),pos:e.pos};if(this.isK("let")&&this.isP("(",1))return this.next(),{kind:"let",assigns:this.assigns(),body:this.expr(),pos:e.pos};let t=this.binary(0);if(this.isP("?")){this.next();let n=this.expr();this.expectP(":");let s=this.expr();return{kind:"ternary",cond:t,then:n,else:s,pos:e.pos}}return t}binary(e){if(e>=Gt.LEVELS.length)return this.unary();let t=this.binary(e+1);for(;this.at("punct")&&Gt.LEVELS[e].includes(this.peek().value);){let n=this.next(),s=this.binary(e+1);t={kind:"binary",op:n.value,left:t,right:s,pos:n.pos}}return t}unary(){if(this.isP("-")||this.isP("!")||this.isP("+")){let e=this.next();return{kind:"unary",op:e.value,arg:this.unary(),pos:e.pos}}return this.power()}power(){let e=this.postfix();if(this.isP("^")){let t=this.next();return{kind:"binary",op:"^",left:e,right:this.unary(),pos:t.pos}}return e}postfix(){let e=this.primary();for(;;){let t=this.peek();if(this.isP("("))e={kind:"call",callee:e,args:this.args(),pos:t.pos};else if(this.isP("[")){this.next();let n=this.expr();this.expectP("]"),e={kind:"index",target:e,index:n,pos:t.pos}}else if(this.isP("."))this.next(),e={kind:"member",target:e,name:this.ident().value,pos:t.pos};else return e}}primary(){let e=this.peek();if(e.type==="num")return this.next(),{kind:"num",value:Number(e.value),pos:e.pos};if(e.type==="str")return this.next(),{kind:"str",value:e.value,pos:e.pos};if(e.type==="id")return e.value==="true"||e.value==="false"?(this.next(),{kind:"bool",value:e.value==="true",pos:e.pos}):e.value==="undef"?(this.next(),{kind:"undef",pos:e.pos}):(en.has(e.value)&&this.fail("Expected a value"),this.next(),{kind:"var",name:e.value,pos:e.pos});if(this.isP("(")){this.next();let t=this.expr();return this.expectP(")"),t}if(this.isP("["))return this.list();this.fail("Expected a value")}list(){let e=this.expectP("[");if(this.isP("]"))return this.next(),{kind:"list",items:[],pos:e.pos};if(!this.isK("for")&&!this.isK("if")&&!this.isK("each")&&!(this.isK("let")&&this.isP("(",1))){let t=this.expr();if(this.isP(":")){this.next();let s=null,i=this.expr();return this.isP(":")&&(this.next(),s=i,i=this.expr()),this.expectP("]"),{kind:"range",start:t,step:s,end:i,pos:e.pos}}let n=[{kind:"item",expr:t}];return this.listRest(n,e.pos)}return this.listRest([],e.pos)}listRest(e,t){if(e.length){if(this.isP("]"))return this.next(),{kind:"list",items:e,pos:t};this.expectP(",")}for(;!this.isP("]");)e.push(this.listItem()),this.isP("]")||this.expectP(",");return this.next(),{kind:"list",items:e,pos:t}}listItem(){if(this.isK("for")&&this.isP("(",1))return this.next(),{kind:"for",assigns:this.assigns(),body:this.listItem()};if(this.isK("if")&&this.isP("(",1)){this.next(),this.expectP("(");let e=this.expr();this.expectP(")");let t=this.listItem(),n=null;return this.isK("else")&&(this.next(),n=this.listItem()),{kind:"if",cond:e,then:t,else:n}}if(this.isK("let")&&this.isP("(",1))return this.next(),{kind:"let",assigns:this.assigns(),body:this.listItem()};if(this.isK("each"))return this.next(),{kind:"each",expr:this.expr()};if(this.isP("(")&&(this.isK("for",1)||this.isK("if",1))){this.next();let e=this.listItem();return this.expectP(")"),e}return{kind:"item",expr:this.expr()}}};Gt.LEVELS=[["||"],["&&"],["==","!="],["<","<=",">",">="],["+","-"],["*","/","%"]];var tn=Gt;var cs={"kerf/box":`// kerf/box: finger-jointed boxes.
4
+ `;for(let o=0;o<this.count;o++)this.children[o].count>0&&(n+=this.children[o].toStringInternal(o,r+1));return n}toString(){if(this.level>0)return"";let e=this.children.length===1?"":"s",r=`Polytree with ${this.children.length} polygon${e}.
5
+ `;for(let n=0;n<this.count;n++)this.children[n].count>0&&(r+=this.children[n].toStringInternal(n,1));return r+`
6
+ `}},kr=class t extends wr{constructor(r=null){super(r);b(this,"polygon",null)}get poly(){return this.polygon}addChild(r){let n=new t(this);return n.polygon=r,this.children.push(n),n}child(r){if(r<0||r>=this.children.length)throw new Error("Index out of range");return this.children[r]}area(){let r=this.polygon===null?0:xn.area(this.polygon);for(let n of this.children)r+=n.area();return r}};var Zt=class extends kr{};var g=class g{constructor(){b(this,"cliptype",J.NoClip);b(this,"fillrule",H.EvenOdd);b(this,"actives",null);b(this,"sel",null);b(this,"minimaList",[]);b(this,"intersectList",[]);b(this,"vertexList",[]);b(this,"outrecList",[]);b(this,"scanlineHeap",new mn);b(this,"scanlineSet",new Set);b(this,"scanlineArr",[]);b(this,"useScanlineArray",!1);b(this,"horzSegList",[]);b(this,"horzJoinList",[]);b(this,"currentLocMin",0);b(this,"currentBotY",0);b(this,"curXValidAtTop",!1);b(this,"isSortedMinimaList",!1);b(this,"hasOpenPaths",!1);b(this,"usingPolytree",!1);b(this,"succeeded",!1);b(this,"zCallbackInternal");b(this,"preserveCollinear",!0);b(this,"reverseSolution",!1)}getZCallback(){}xyEqual(e,r){return e.x===r.x&&e.y===r.y}setZ(e,r,n){let s=this.zCallbackInternal;s&&(g.getPolyType(e)===we.Subject?(this.xyEqual(n,e.bot)?n.z=e.bot.z??0:this.xyEqual(n,e.top)?n.z=e.top.z??0:this.xyEqual(n,r.bot)?n.z=r.bot.z??0:this.xyEqual(n,r.top)?n.z=r.top.z??0:n.z=0,s(e.bot,e.top,r.bot,r.top,n)):(this.xyEqual(n,r.bot)?n.z=r.bot.z??0:this.xyEqual(n,r.top)?n.z=r.top.z??0:this.xyEqual(n,e.bot)?n.z=e.bot.z??0:this.xyEqual(n,e.top)?n.z=e.top.z??0:n.z=0,s(r.bot,r.top,e.bot,e.top,n)))}static isOdd(e){return(e&1)!==0}static isHotEdge(e){return e.outrec!=null}static isOpen(e){return g.openPathsEnabled&&e.localMin.isOpen}static isOpenEnd(e){return g.openPathsEnabled&&e.localMin.isOpen&&g.isOpenEndVertex(e.vertexTop)}static isOpenEndVertex(e){return(e.flags&(_.OpenStart|_.OpenEnd))!==_.None}static getPrevHotEdge(e){let r=e.prevInAEL;if(!g.openPathsEnabled){for(;r!==null&&!g.isHotEdge(r);)r=r.prevInAEL;return r}for(;r!==null&&(r.localMin.isOpen||!g.isHotEdge(r));)r=r.prevInAEL;return r}static isFront(e){return e===e.outrec.frontEdge}static getDx(e,r){let n=r.y-e.y;return n!==0?(r.x-e.x)/n:r.x>e.x?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY}static topX(e,r){return r===e.top.y||e.top.x===e.bot.x?e.top.x:r===e.bot.y?e.bot.x:N.roundToEven(e.bot.x+e.dx*(r-e.bot.y))}static isHorizontal(e){return e.dx===Number.NEGATIVE_INFINITY||e.dx===Number.POSITIVE_INFINITY}static isHeadingRightHorz(e){return e.dx===Number.NEGATIVE_INFINITY}static isHeadingLeftHorz(e){return e.dx===Number.POSITIVE_INFINITY}static getPolyType(e){return e.localMin.polytype}static isSamePolyType(e,r){return e.localMin.polytype===r.localMin.polytype}static setDx(e){e.dx=g.getDx(e.bot,e.top)}static nextVertex(e){return e.windDx>0?e.vertexTop.next:e.vertexTop.prev}static prevPrevVertex(e){return e.windDx>0?e.vertexTop.prev.prev:e.vertexTop.next.next}static isMaximaVertex(e){return(e.flags&_.LocalMax)!==_.None}static isMaximaEdge(e){return(e.vertexTop.flags&_.LocalMax)!==_.None}static getMaximaPair(e){let r=e.nextInAEL;for(;r!==null;){if(r.vertexTop===e.vertexTop)return r;r=r.nextInAEL}return null}boundingBoxesOverlap(e,r,n,s){let i=e.x<r.x?e.x:r.x;if((n.x>s.x?n.x:s.x)<i)return!1;let a=e.x>r.x?e.x:r.x,u=n.x<s.x?n.x:s.x;if(a<u)return!1;let l=e.y<r.y?e.y:r.y;if((n.y>s.y?n.y:s.y)<l)return!1;let c=e.y>r.y?e.y:r.y,h=n.y<s.y?n.y:s.y;return c>=h}clearSolutionOnly(){for(;this.actives!==null;)this.deleteFromAEL(this.actives);this.scanlineHeap.clear(),this.scanlineSet.clear(),this.scanlineArr.length=0,this.disposeIntersectNodes(),this.outrecList.length=0,this.horzSegList.length=0,this.horzJoinList.length=0}clear(){this.clearSolutionOnly(),this.minimaList.length=0,this.vertexList.length=0,this.currentLocMin=0,this.isSortedMinimaList=!1,this.hasOpenPaths=!1}reset(){this.isSortedMinimaList||(this.minimaList.sort((e,r)=>r.vertex.pt.y-e.vertex.pt.y),this.isSortedMinimaList=!0),this.scanlineHeap.clear(),this.scanlineSet.clear(),this.scanlineArr.length=0,this.useScanlineArray=this.minimaList.length<=16;for(let e=this.minimaList.length-1;e>=0;e--)this.insertScanline(this.minimaList[e].vertex.pt.y);this.currentBotY=0,this.currentLocMin=0,this.actives=null,this.sel=null,this.curXValidAtTop=!1,this.succeeded=!0}upgradeScanlineStructureFromArray(){let e=this.scanlineArr;for(let r=0,n=e.length;r<n;r++){let s=e[r];this.scanlineSet.add(s),this.scanlineHeap.push(s)}e.length=0,this.useScanlineArray=!1}insertScanline(e){if(this.useScanlineArray){let r=this.scanlineArr;for(let n=0,s=r.length;n<s;n++)if(r[n]===e)return;r.push(e),r.length>64&&this.upgradeScanlineStructureFromArray();return}this.scanlineSet.has(e)||(this.scanlineSet.add(e),this.scanlineHeap.push(e))}popScanline(){if(this.useScanlineArray){let r=this.scanlineArr,n=r.length;if(n===0)return null;let s=0,i=r[0];for(let o=1;o<n;o++){let a=r[o];a>i&&(i=a,s=o)}return r[s]=r[n-1],r.pop(),i}let e=this.scanlineHeap.pop();return e===null?null:(this.scanlineSet.delete(e),e)}hasLocMinAtY(e){return this.currentLocMin<this.minimaList.length&&this.minimaList[this.currentLocMin].vertex.pt.y===e}popLocalMinima(){return this.minimaList[this.currentLocMin++]}addPath(e,r,n=!1){let s=[e];this.addPaths(s,r,n)}addPaths(e,r,n=!1){n&&(this.hasOpenPaths=!0),this.isSortedMinimaList=!1,Ct.addPathsToVertexList(e,r,n,this.minimaList,this.vertexList)}addReuseableData(e){if(e.minimaList.length!==0){this.isSortedMinimaList=!1;for(let r of e.minimaList)this.minimaList.push(new Xt(r.vertex,r.polytype,r.isOpen)),r.isOpen&&(this.hasOpenPaths=!0)}}deleteFromAEL(e){let r=e.prevInAEL,n=e.nextInAEL;r===null&&n===null&&e!==this.actives||(r!==null?r.nextInAEL=n:this.actives=n,n!==null&&(n.prevInAEL=r))}getBounds(){let e={left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER};for(let r of this.vertexList){let n=r;do n.pt.x<e.left&&(e.left=n.pt.x),n.pt.x>e.right&&(e.right=n.pt.x),n.pt.y<e.top&&(e.top=n.pt.y),n.pt.y>e.bottom&&(e.bottom=n.pt.y),n=n.next;while(n!==r)}return mt.isEmpty(e)?{left:0,top:0,right:0,bottom:0}:e}executeInternal(e,r){if(e===J.NoClip)return;g.openPathsEnabled=this.hasOpenPaths,this.zCallbackInternal=this.getZCallback(),this.fillrule=r,this.cliptype=e,this.reset();let n=this.popScanline();if(n!==null){for(;this.succeeded;){this.insertLocalMinimaIntoAEL(n);let s;for(;(s=this.popHorz())!==null;)this.doHorizontal(s);this.horzSegList.length>0&&(this.convertHorzSegsToJoins(),this.horzSegList.length=0),this.currentBotY=n;let i=this.popScanline();if(i===null)break;for(n=i,this.doIntersections(n),this.doTopOfScanbeam(n);(s=this.popHorz())!==null;)this.doHorizontal(s)}this.succeeded&&this.processHorzJoins()}}insertLocalMinimaIntoAEL(e){for(;this.hasLocMinAtY(e);){let r=this.popLocalMinima(),n;(r.vertex.flags&_.OpenStart)!==_.None?n=null:(n=new Wt,n.bot=r.vertex.pt,n.curX=r.vertex.pt.x,n.windDx=-1,n.vertexTop=r.vertex.prev,n.top=r.vertex.prev.pt,n.outrec=null,n.localMin=r,g.setDx(n));let s;if((r.vertex.flags&_.OpenEnd)!==_.None?s=null:(s=new Wt,s.bot=r.vertex.pt,s.curX=r.vertex.pt.x,s.windDx=1,s.vertexTop=r.vertex.next,s.top=r.vertex.next.pt,s.outrec=null,s.localMin=r,g.setDx(s)),n!==null&&s!==null){if(g.isHorizontal(n)){if(g.isHeadingRightHorz(n)){let o=n;n=s,s=o}}else if(g.isHorizontal(s)){if(g.isHeadingLeftHorz(s)){let o=n;n=s,s=o}}else if(n.dx<s.dx){let o=n;n=s,s=o}}else n===null&&(n=s,s=null);let i;if(n.isLeftBound=!0,this.insertLeftEdge(n),g.openPathsEnabled?g.isOpen(n)?(this.setWindCountForOpenPathEdge(n),i=this.isContributingOpen(n)):(this.setWindCountForClosedPathEdge(n),i=this.isContributingClosed(n)):(this.setWindCountForClosedPathEdge(n),i=this.isContributingClosed(n)),s!==null){for(s.windCount=n.windCount,s.windCount2=n.windCount2,this.insertRightEdge(n,s),i&&(this.addLocalMinPoly(n,s,n.bot,!0),g.isHorizontal(n)||this.checkJoinLeft(n,n.bot));s.nextInAEL!==null&&this.isValidAelOrder(s.nextInAEL,s);)this.intersectEdges(s,s.nextInAEL,s.bot),this.swapPositionsInAEL(s,s.nextInAEL);g.isHorizontal(s)?this.pushHorz(s):(this.checkJoinRight(s,s.bot),this.insertScanline(s.top.y))}else i&&g.openPathsEnabled&&this.startOpenPath(n,n.bot);g.isHorizontal(n)?this.pushHorz(n):this.insertScanline(n.top.y)}}pushHorz(e){e.nextInSEL=this.sel,this.sel=e}popHorz(){let e=this.sel;return e===null?null:(this.sel=this.sel.nextInSEL,e)}doHorizontal(e){if(!g.openPathsEnabled){this.doHorizontalClosed(e);return}let r=g.isOpen(e),n=e.bot.y,s=r?this.getCurrYMaximaVertexOpen(e):this.getCurrYMaximaVertex(e),{isLeftToRight:i,leftX:o,rightX:a}=this.resetHorzDirection(e,s),u=o,l=a;if(g.isHotEdge(e)){let f=this.addOutPt(e,{x:e.curX,y:n});this.addToHorzSegList(f)}for(;;){let f=i?e.nextInAEL:e.prevInAEL;for(;f!==null;){if(f.vertexTop===s){if(g.isHotEdge(e)&&this.isJoined(f)&&this.split(f,f.top),g.isHotEdge(e)){for(;e.vertexTop!==s;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);i?this.addLocalMaxPoly(e,f,e.top):this.addLocalMaxPoly(f,e,e.top)}this.deleteFromAEL(f),this.deleteFromAEL(e);return}if(s!==e.vertexTop||g.isOpenEnd(e)){if(i&&f.curX>l||!i&&f.curX<u)break;if(f.curX===e.top.x&&!g.isHorizontal(f)){let p=g.nextVertex(e).pt;if(g.isOpen(f)&&!g.isSamePolyType(f,e)&&!g.isHotEdge(f)){if(i&&g.topX(f,p.y)>p.x||!i&&g.topX(f,p.y)<p.x)break}else if(i&&g.topX(f,p.y)>=p.x||!i&&g.topX(f,p.y)<=p.x)break}}let h={x:f.curX,y:n};i?(this.intersectEdges(e,f,h),this.swapPositionsInAEL(e,f),this.checkJoinLeft(f,h),e.curX=f.curX,f=e.nextInAEL):(this.intersectEdges(f,e,h),this.swapPositionsInAEL(f,e),this.checkJoinRight(f,h),e.curX=f.curX,f=e.prevInAEL),g.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(r&&g.isOpenEnd(e)){g.isHotEdge(e)&&(this.addOutPt(e,e.top),g.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e);return}if(g.nextVertex(e).pt.y!==e.top.y)break;g.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let c=this.resetHorzDirection(e,s);u=c.leftX,l=c.rightX}if(g.isHotEdge(e)){let f=this.addOutPt(e,e.top);this.addToHorzSegList(f)}this.updateEdgeIntoAEL(e)}doHorizontalClosed(e){let r=e.bot.y,n=this.getCurrYMaximaVertex(e),{isLeftToRight:s,leftX:i,rightX:o}=this.resetHorzDirection(e,n),a=i,u=o;if(g.isHotEdge(e)){let l=this.addOutPt(e,{x:e.curX,y:r});this.addToHorzSegList(l)}for(;;){let l=s?e.nextInAEL:e.prevInAEL;for(;l!==null;){if(l.vertexTop===n){if(g.isHotEdge(e)&&this.isJoined(l)&&this.split(l,l.top),g.isHotEdge(e)){for(;e.vertexTop!==n;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);s?this.addLocalMaxPoly(e,l,e.top):this.addLocalMaxPoly(l,e,e.top)}this.deleteFromAEL(l),this.deleteFromAEL(e);return}if(n!==e.vertexTop){if(s&&l.curX>u||!s&&l.curX<a)break;if(l.curX===e.top.x&&!g.isHorizontal(l)){let h=g.nextVertex(e).pt,p=g.topX(l,h.y);if(s&&p>=h.x||!s&&p<=h.x)break}}let c={x:l.curX,y:r};s?(this.intersectEdges(e,l,c),this.swapPositionsInAEL(e,l),this.checkJoinLeft(l,c),e.curX=l.curX,l=e.nextInAEL):(this.intersectEdges(l,e,c),this.swapPositionsInAEL(l,e),this.checkJoinRight(l,c),e.curX=l.curX,l=e.prevInAEL),g.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(g.nextVertex(e).pt.y!==e.top.y)break;g.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let f=this.resetHorzDirection(e,n);a=f.leftX,u=f.rightX}if(g.isHotEdge(e)){let l=this.addOutPt(e,e.top);this.addToHorzSegList(l)}this.updateEdgeIntoAEL(e)}convertHorzSegsToJoins(){let e=this.horzSegList,r=0;for(let n=0,s=e.length;n<s;n++){let i=e[n];this.updateHorzSegment(i)&&(e[r++]=i)}if(!(r<2)){e.length=r,this.horzSegList.sort(Ca);for(let n=0;n<r-1;n++){let s=this.horzSegList[n];for(let i=n+1;i<r;i++){let o=this.horzSegList[i];if(o.leftOp.pt.x>=s.rightOp.pt.x||o.leftToRight===s.leftToRight||o.rightOp.pt.x<=s.leftOp.pt.x)continue;let a=s.leftOp.pt.y;if(s.leftToRight){for(;s.leftOp.next.pt.y===a&&s.leftOp.next.pt.x<=o.leftOp.pt.x;)s.leftOp=s.leftOp.next;for(;o.leftOp.prev.pt.y===a&&o.leftOp.prev.pt.x<=s.leftOp.pt.x;)o.leftOp=o.leftOp.prev;let u=new qt(this.duplicateOp(s.leftOp,!0),this.duplicateOp(o.leftOp,!1));this.horzJoinList.push(u)}else{for(;s.leftOp.prev.pt.y===a&&s.leftOp.prev.pt.x<=o.leftOp.pt.x;)s.leftOp=s.leftOp.prev;for(;o.leftOp.next.pt.y===a&&o.leftOp.next.pt.x<=s.leftOp.pt.x;)o.leftOp=o.leftOp.next;let u=new qt(this.duplicateOp(o.leftOp,!0),this.duplicateOp(s.leftOp,!1));this.horzJoinList.push(u)}}}}}updateHorzSegment(e){let r=e.leftOp,n=this.getRealOutRec(r.outrec),s=n.frontEdge!==null,i=r.pt.y,o=r,a=r;if(s){let l=n.pts,f=l.next;for(;o!==f&&o.prev.pt.y===i;)o=o.prev;for(;a!==l&&a.next.pt.y===i;)a=a.next}else{for(;o.prev!==a&&o.prev.pt.y===i;)o=o.prev;for(;a.next!==o&&a.next.pt.y===i;)a=a.next}let u=this.setHorzSegHeadingForward(e,o,a)&&e.leftOp.horz===null;return u?e.leftOp.horz=e:e.rightOp=null,u}setHorzSegHeadingForward(e,r,n){return r.pt.x===n.pt.x?!1:(r.pt.x<n.pt.x?(e.leftOp=r,e.rightOp=n,e.leftToRight=!0):(e.leftOp=n,e.rightOp=r,e.leftToRight=!1),!0)}duplicateOp(e,r){let n=new Je(e.pt,e.outrec);return r?(n.next=e.next,n.next.prev=n,n.prev=e,e.next=n):(n.prev=e.prev,n.prev.next=n,n.next=e,e.prev=n),n}getRealOutRec(e){for(;e!==null&&e.pts===null;)e=e.owner;return e}doIntersections(e){this.buildIntersectList(e)&&(this.processIntersectList(),this.disposeIntersectNodes())}doTopOfScanbeam(e){let r=this.curXValidAtTop;this.curXValidAtTop=!1,this.sel=null;let n=this.actives;for(;n!==null;){if(n.top.y===e)if(n.curX=n.top.x,g.isMaximaEdge(n)){n=this.doMaxima(n);continue}else g.isHotEdge(n)&&this.addOutPt(n,n.top),this.updateEdgeIntoAEL(n),g.isHorizontal(n)&&this.pushHorz(n);else r||(n.curX=g.topX(n,e));n=n.nextInAEL}}processHorzJoins(){for(let e of this.horzJoinList){let r=this.getRealOutRec(e.op1.outrec),n=this.getRealOutRec(e.op2.outrec),s=e.op1.next,i=e.op2.prev;if(e.op1.next=e.op2,e.op2.prev=e.op1,s.prev=i,i.next=s,r===n){let o=this.newOutRec();o.pts=s,this.fixOutRecPts(o),r.pts.outrec===o&&(r.pts=e.op1,r.pts.outrec=r),this.usingPolytree?(this.path1InsidePath2(r.pts,o.pts)?([o.pts,r.pts]=[r.pts,o.pts],this.fixOutRecPts(r),this.fixOutRecPts(o),o.owner=r):this.path1InsidePath2(o.pts,r.pts)?o.owner=r:o.owner=r.owner,r.splits===null&&(r.splits=[]),r.splits.push(o.idx)):o.owner=r}else n.pts=null,this.usingPolytree?(this.setOwner(n,r),this.moveSplits(n,r)):n.owner=r}}fixOutRecPts(e){let r=e.pts;do r.outrec=e,r=r.next;while(r!==e.pts)}path1InsidePath2(e,r){let n=V.IsOn,s=e;do{switch(this.pointInOpPolygon(s.pt,r)){case V.IsOutside:if(n===V.IsOutside)return!1;n=V.IsOutside;break;case V.IsInside:if(n===V.IsInside)return!0;n=V.IsInside;break;default:break}s=s.next}while(s!==e);return N.path2ContainsPath1(this.getCleanPath(e),this.getCleanPath(r))}pointInOpPolygon(e,r){if(r===r.next||r.prev===r.next)return V.IsOutside;let n=r;do{if(r.pt.y!==e.y)break;r=r.next}while(r!==n);if(r.pt.y===e.y)return V.IsOutside;let s=r.pt.y<e.y,i=s,o=0;for(n=r.next;n!==r;){if(s)for(;n!==r&&n.pt.y<e.y;)n=n.next;else for(;n!==r&&n.pt.y>e.y;)n=n.next;if(n===r)break;if(n.pt.y===e.y){if(n.pt.x===e.x||n.pt.y===n.prev.pt.y&&e.x<n.prev.pt.x!=e.x<n.pt.x)return V.IsOn;if(n=n.next,n===r)break;continue}if(n.pt.x<=e.x||n.prev.pt.x<=e.x)if(n.prev.pt.x<e.x&&n.pt.x<e.x)o=1-o;else{let a=N.crossProductSign(n.prev.pt,n.pt,e);if(a===0)return V.IsOn;a<0===s&&(o=1-o)}s=!s,n=n.next}if(s===i)return o===0?V.IsOutside:V.IsInside;{let a=N.crossProductSign(n.prev.pt,n.pt,e);if(a===0)return V.IsOn;a<0===s&&(o=1-o)}return o===0?V.IsOutside:V.IsInside}getCleanPath(e){let r=[],n=e;for(;n.next!==e&&(n.pt.x===n.next.pt.x&&n.pt.x===n.prev.pt.x||n.pt.y===n.next.pt.y&&n.pt.y===n.prev.pt.y);)n=n.next;r.push(n.pt);let s=n;for(n=n.next;n!==e;)(n.pt.x!==n.next.pt.x||n.pt.x!==s.pt.x)&&(n.pt.y!==n.next.pt.y||n.pt.y!==s.pt.y)&&(r.push(n.pt),s=n),n=n.next;return r}moveSplits(e,r){if(e.splits!==null){r.splits===null&&(r.splits=[]);for(let n of e.splits)n!==r.idx&&r.splits.push(n);e.splits=null}}buildIntersectList(e){if(this.actives?.nextInAEL===null)return!1;if(!this.adjustCurrXAndCopyToSEL(e))return this.curXValidAtTop=!0,!1;let r=this.sel;for(;r!==null&&r.jump!==null;){let n=null;for(;r!==null&&r.jump!==null;){let s=r,i=r.jump,o=i,a=i?.jump||null;for(r.jump=a;r!==o&&i!==a;)if(i.curX<r.curX){let u=i.prevInSEL;for(;this.addNewIntersectNode(u,i,e),u!==r;)u=u.prevInSEL;if(u=i,i=this.extractFromSEL(u),o=i,r!==null&&this.insert1Before2InSEL(u,r),r!==s)continue;s=u,s.jump=a,n===null?this.sel=s:n.jump=s}else r=r.nextInSEL;n=s,r=a}r=this.sel}return this.intersectList.length>0}processIntersectList(){this.intersectList.sort(Ma);for(let e=0;e<this.intersectList.length;++e){if(!this.edgesAdjacentInAEL(this.intersectList[e])){let n=e+1;for(;!this.edgesAdjacentInAEL(this.intersectList[n]);)n++;[this.intersectList[n],this.intersectList[e]]=[this.intersectList[e],this.intersectList[n]]}let r=this.intersectList[e];this.intersectEdges(r.edge1,r.edge2,r.pt),this.swapPositionsInAEL(r.edge1,r.edge2),r.edge1.curX=r.pt.x,r.edge2.curX=r.pt.x,this.checkJoinLeft(r.edge2,r.pt,!0),this.checkJoinRight(r.edge1,r.pt,!0)}}edgesAdjacentInAEL(e){return e.edge1.nextInAEL===e.edge2||e.edge1.prevInAEL===e.edge2}adjustCurrXAndCopyToSEL(e){let r=this.actives;this.sel=r;let n=Number.NEGATIVE_INFINITY,s=!1;for(;r!==null;){r.prevInSEL=r.prevInAEL,r.nextInSEL=r.nextInAEL,r.jump=r.nextInSEL;let i=g.topX(r,e);r.curX=i,i<n&&(s=!0),n=i,r=r.nextInAEL}return s}doMaxima(e){let r=e.prevInAEL,n=e.nextInAEL;if(g.isOpenEnd(e))return g.isHotEdge(e)&&this.addOutPt(e,e.top),g.isHorizontal(e)||(g.isHotEdge(e)&&(g.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e)),n;let s=g.getMaximaPair(e);if(s===null)return n;for(this.isJoined(e)&&this.split(e,e.top),this.isJoined(s)&&this.split(s,s.top);n!==s;)this.intersectEdges(e,n,e.top),this.swapPositionsInAEL(e,n),n=e.nextInAEL;return g.isOpen(e)?(g.isHotEdge(e)&&this.addLocalMaxPoly(e,s,e.top),this.deleteFromAEL(s),this.deleteFromAEL(e),r!==null?r.nextInAEL:this.actives):(g.isHotEdge(e)&&this.addLocalMaxPoly(e,s,e.top),this.deleteFromAEL(e),this.deleteFromAEL(s),r!==null?r.nextInAEL:this.actives)}updateEdgeIntoAEL(e){if(e.bot=e.top,e.vertexTop=g.nextVertex(e),e.top=e.vertexTop.pt,e.curX=e.bot.x,g.setDx(e),this.isJoined(e)&&this.split(e,e.bot),g.isHorizontal(e)){g.openPathsEnabled?g.isOpen(e)||this.trimHorz(e,this.preserveCollinear):this.trimHorz(e,this.preserveCollinear);return}this.insertScanline(e.top.y),this.checkJoinLeft(e,e.bot),this.checkJoinRight(e,e.bot,!0)}trimHorz(e,r){let n=!1,s=g.nextVertex(e).pt;for(;s.y===e.top.y&&!(r&&s.x<e.top.x!=e.bot.x<e.top.x||(e.vertexTop=g.nextVertex(e),e.top=s,n=!0,g.isMaximaVertex(e.vertexTop)));)s=g.nextVertex(e).pt;n&&g.setDx(e)}addToHorzSegList(e){e.outrec.isOpen||this.horzSegList.push(new Sr(e))}addNewIntersectNode(e,r,n){let s=N.getLineIntersectPt(e.bot,e.top,r.bot,r.top);if(s===null&&(s={x:e.curX,y:n}),s.y>this.currentBotY||s.y<n){let o=Math.abs(e.dx),a=Math.abs(r.dx);o>100&&a>100?o>a?s=N.getClosestPtOnSegment(s,e.bot,e.top):s=N.getClosestPtOnSegment(s,r.bot,r.top):o>100?s=N.getClosestPtOnSegment(s,e.bot,e.top):a>100?s=N.getClosestPtOnSegment(s,r.bot,r.top):(s.y<n?s.y=n:s.y=this.currentBotY,o<a?s.x=g.topX(e,s.y):s.x=g.topX(r,s.y))}let i=Os(s,e,r);this.intersectList.push(i)}extractFromSEL(e){let r=e.nextInSEL;return r!==null&&(r.prevInSEL=e.prevInSEL),e.prevInSEL.nextInSEL=r,r}insert1Before2InSEL(e,r){e.prevInSEL=r.prevInSEL,e.prevInSEL!==null&&(e.prevInSEL.nextInSEL=e),e.nextInSEL=r,r.prevInSEL=e}getCurrYMaximaVertexOpen(e){let r=e.vertexTop;if(e.windDx>0)for(;r.next.pt.y===r.pt.y&&(r.flags&(_.OpenEnd|_.LocalMax))===_.None;)r=r.next;else for(;r.prev.pt.y===r.pt.y&&(r.flags&(_.OpenEnd|_.LocalMax))===_.None;)r=r.prev;return g.isMaximaVertex(r)||(r=null),r}getCurrYMaximaVertex(e){let r=e.vertexTop;if(e.windDx>0)for(;r.next.pt.y===r.pt.y;)r=r.next;else for(;r.prev.pt.y===r.pt.y;)r=r.prev;return g.isMaximaVertex(r)||(r=null),r}resetHorzDirection(e,r){if(e.bot.x===e.top.x){let n=e.curX,s=e.curX,i=e.nextInAEL;for(;i!==null&&i.vertexTop!==r;)i=i.nextInAEL;return{isLeftToRight:i!==null,leftX:n,rightX:s}}return e.curX<e.top.x?{isLeftToRight:!0,leftX:e.curX,rightX:e.top.x}:{isLeftToRight:!1,leftX:e.top.x,rightX:e.curX}}getLastOp(e){let r=e.outrec;return e===r.frontEdge?r.pts:r.pts.next}insertLeftEdge(e){if(this.actives===null)e.prevInAEL=null,e.nextInAEL=null,this.actives=e;else if(!this.isValidAelOrder(this.actives,e))e.prevInAEL=null,e.nextInAEL=this.actives,this.actives.prevInAEL=e,this.actives=e;else{let r=this.actives;for(;r.nextInAEL!==null&&this.isValidAelOrder(r.nextInAEL,e);)r=r.nextInAEL;r.joinWith===Pe.Right&&(r=r.nextInAEL),e.nextInAEL=r.nextInAEL,r.nextInAEL!==null&&(r.nextInAEL.prevInAEL=e),e.prevInAEL=r,r.nextInAEL=e}}insertRightEdge(e,r){r.nextInAEL=e.nextInAEL,e.nextInAEL!==null&&(e.nextInAEL.prevInAEL=r),r.prevInAEL=e,e.nextInAEL=r}setWindCountForOpenPathEdge(e){let r=this.actives;if(this.fillrule===H.EvenOdd){let n=0,s=0;for(;r!==e;)g.getPolyType(r)===we.Clip?s++:g.isOpen(r)||n++,r=r.nextInAEL;e.windCount=g.isOdd(n)?1:0,e.windCount2=g.isOdd(s)?1:0}else for(;r!==e;)g.getPolyType(r)===we.Clip?e.windCount2+=r.windDx:g.isOpen(r)||(e.windCount+=r.windDx),r=r.nextInAEL}setWindCountForClosedPathEdge(e){let r=e.prevInAEL,n=g.getPolyType(e);if(!g.openPathsEnabled){for(;r!==null&&g.getPolyType(r)!==n;)r=r.prevInAEL;if(r===null?(e.windCount=e.windDx,r=this.actives):this.fillrule===H.EvenOdd?(e.windCount=e.windDx,e.windCount2=r.windCount2,r=r.nextInAEL):(r.windCount*r.windDx<0?Math.abs(r.windCount)>1?r.windDx*e.windDx<0?e.windCount=r.windCount:e.windCount=r.windCount+e.windDx:e.windCount=e.windDx:r.windDx*e.windDx<0?e.windCount=r.windCount:e.windCount=r.windCount+e.windDx,e.windCount2=r.windCount2,r=r.nextInAEL),this.fillrule===H.EvenOdd)for(;r!==e;)g.getPolyType(r)!==n&&(e.windCount2=e.windCount2===0?1:0),r=r.nextInAEL;else for(;r!==e;)g.getPolyType(r)!==n&&(e.windCount2+=r.windDx),r=r.nextInAEL;return}for(;r!==null&&(g.getPolyType(r)!==n||g.isOpen(r));)r=r.prevInAEL;if(r===null?(e.windCount=e.windDx,r=this.actives):this.fillrule===H.EvenOdd?(e.windCount=e.windDx,e.windCount2=r.windCount2,r=r.nextInAEL):(r.windCount*r.windDx<0?Math.abs(r.windCount)>1?r.windDx*e.windDx<0?e.windCount=r.windCount:e.windCount=r.windCount+e.windDx:e.windCount=g.isOpen(e)?1:e.windDx:r.windDx*e.windDx<0?e.windCount=r.windCount:e.windCount=r.windCount+e.windDx,e.windCount2=r.windCount2,r=r.nextInAEL),this.fillrule===H.EvenOdd)for(;r!==e;)g.getPolyType(r)!==n&&!g.isOpen(r)&&(e.windCount2=e.windCount2===0?1:0),r=r.nextInAEL;else for(;r!==e;)g.getPolyType(r)!==n&&!g.isOpen(r)&&(e.windCount2+=r.windDx),r=r.nextInAEL}isContributingOpen(e){let r,n;switch(this.fillrule){case H.Positive:n=e.windCount>0,r=e.windCount2>0;break;case H.Negative:n=e.windCount<0,r=e.windCount2<0;break;default:n=e.windCount!==0,r=e.windCount2!==0;break}switch(this.cliptype){case J.Intersection:return r;case J.Union:return!n&&!r;default:return!r}}isContributingClosed(e){switch(this.fillrule){case H.Positive:if(e.windCount!==1)return!1;break;case H.Negative:if(e.windCount!==-1)return!1;break;case H.NonZero:if(Math.abs(e.windCount)!==1)return!1;break}switch(this.cliptype){case J.Intersection:return this.fillrule===H.Positive?e.windCount2>0:this.fillrule===H.Negative?e.windCount2<0:e.windCount2!==0;case J.Union:return this.fillrule===H.Positive?e.windCount2<=0:this.fillrule===H.Negative?e.windCount2>=0:e.windCount2===0;case J.Difference:{let r=this.fillrule===H.Positive?e.windCount2<=0:this.fillrule===H.Negative?e.windCount2>=0:e.windCount2===0;return g.getPolyType(e)===we.Subject?r:!r}case J.Xor:return!0;default:return!1}}addLocalMinPoly(e,r,n,s=!1){let i=this.newOutRec();if(e.outrec=i,r.outrec=i,g.isOpen(e))i.owner=null,i.isOpen=!0,e.windDx>0?this.setSides(i,e,r):this.setSides(i,r,e);else{i.isOpen=!1;let a=g.getPrevHotEdge(e);a!==null?(this.usingPolytree&&this.setOwner(i,a.outrec),i.owner=a.outrec,this.outrecIsAscending(a)===s?this.setSides(i,r,e):this.setSides(i,e,r)):(i.owner=null,s?this.setSides(i,e,r):this.setSides(i,r,e))}let o=new Je(n,i);return i.pts=o,o}outrecIsAscending(e){return e===e.outrec.frontEdge}newOutRec(){let e=new br;return e.idx=this.outrecList.length,this.outrecList.push(e),e}startOpenPath(e,r){let n=this.newOutRec();n.isOpen=!0,e.windDx>0?(n.frontEdge=e,n.backEdge=null):(n.frontEdge=null,n.backEdge=e),e.outrec=n;let s=new Je(r,n);return n.pts=s,s}checkJoinLeft(e,r,n=!1){let s=e.prevInAEL;s!==null&&(!n&&e.curX!==s.curX||!g.isHotEdge(e)||!g.isHotEdge(s)||g.isHorizontal(e)||g.isHorizontal(s)||g.isOpen(e)||g.isOpen(s)||(r.y<e.top.y+2||r.y<s.top.y+2)&&(e.bot.y>r.y||s.bot.y>r.y)||n&&this.perpendicDistFromLineSqrdGreaterThanQuarter(r,s.bot,s.top)||N.isCollinear(e.top,r,s.top)&&(e.outrec.idx===s.outrec.idx?this.addLocalMaxPoly(s,e,r):e.outrec.idx<s.outrec.idx?this.joinOutrecPaths(e,s):this.joinOutrecPaths(s,e),s.joinWith=Pe.Right,e.joinWith=Pe.Left))}checkJoinRight(e,r,n=!1){let s=e.nextInAEL;s!==null&&(!n&&e.curX!==s.curX||!g.isHotEdge(e)||!g.isHotEdge(s)||g.isHorizontal(e)||g.isHorizontal(s)||g.isOpen(e)||g.isOpen(s)||(r.y<e.top.y+2||r.y<s.top.y+2)&&(e.bot.y>r.y||s.bot.y>r.y)||n&&this.perpendicDistFromLineSqrdGreaterThanQuarter(r,s.bot,s.top)||N.isCollinear(e.top,r,s.top)&&(e.outrec.idx===s.outrec.idx?this.addLocalMaxPoly(e,s,r):e.outrec.idx<s.outrec.idx?this.joinOutrecPaths(e,s):this.joinOutrecPaths(s,e),e.joinWith=Pe.Right,s.joinWith=Pe.Left))}perpendicDistFromLineSqrdGreaterThanQuarter(e,r,n){let s=e.x-r.x,i=e.y-r.y,o=n.x-r.x,a=n.y-r.y;if(o===0&&a===0)return!1;let u=N.maxCoordForSafeCrossSq;if(Math.abs(s)<u&&Math.abs(i)<u&&Math.abs(o)<u&&Math.abs(a)<u){let f=s*a-o*i;return f*f/(o*o+a*a)>.25}if(Number.isSafeInteger(s)&&Number.isSafeInteger(i)&&Number.isSafeInteger(o)&&Number.isSafeInteger(a)){let f=BigInt(s)*BigInt(a)-BigInt(o)*BigInt(i),c=f*f,h=BigInt(o)*BigInt(o)+BigInt(a)*BigInt(a);return As*c>h}let l=s*a-o*i;return l*l/(o*o+a*a)>.25}intersectEdges(e,r,n){let s;if(this.hasOpenPaths&&(g.isOpen(e)||g.isOpen(r))){if(g.isOpen(e)&&g.isOpen(r))return;if(g.isOpen(r)){let l=e;e=r,r=l}if(this.isJoined(r)&&this.split(r,n),this.cliptype===J.Union){if(!g.isHotEdge(r))return}else if(r.localMin.polytype===we.Subject)return;switch(this.fillrule){case H.Positive:if(r.windCount!==1)return;break;case H.Negative:if(r.windCount!==-1)return;break;default:if(Math.abs(r.windCount)!==1)return;break}if(g.isHotEdge(e))s=this.addOutPt(e,n),this.setZ(e,r,s.pt),g.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null;else if(n.x===e.localMin.vertex.pt.x&&n.y===e.localMin.vertex.pt.y&&!g.isOpenEndVertex(e.localMin.vertex)){let l=this.findEdgeWithMatchingLocMin(e);if(l!==null&&g.isHotEdge(l)){e.outrec=l.outrec,e.windDx>0?this.setSides(l.outrec,e,l):this.setSides(l.outrec,l,e);return}s=this.startOpenPath(e,n)}else s=this.startOpenPath(e,n);this.setZ(e,r,s.pt);return}this.isJoined(e)&&this.split(e,n),this.isJoined(r)&&this.split(r,n);let i,o;switch(e.localMin.polytype===r.localMin.polytype?this.fillrule===H.EvenOdd?(i=e.windCount,e.windCount=r.windCount,r.windCount=i):(e.windCount+r.windDx===0?e.windCount=-e.windCount:e.windCount+=r.windDx,r.windCount-e.windDx===0?r.windCount=-r.windCount:r.windCount-=e.windDx):(this.fillrule!==H.EvenOdd?e.windCount2+=r.windDx:e.windCount2=e.windCount2===0?1:0,this.fillrule!==H.EvenOdd?r.windCount2-=e.windDx:r.windCount2=r.windCount2===0?1:0),this.fillrule){case H.Positive:i=e.windCount,o=r.windCount;break;case H.Negative:i=-e.windCount,o=-r.windCount;break;default:i=Math.abs(e.windCount),o=Math.abs(r.windCount);break}let a=i===0||i===1,u=o===0||o===1;if(!(!g.isHotEdge(e)&&!a||!g.isHotEdge(r)&&!u))if(g.isHotEdge(e)&&g.isHotEdge(r))if(i!==0&&i!==1||o!==0&&o!==1||e.localMin.polytype!==r.localMin.polytype&&this.cliptype!==J.Xor)s=this.addLocalMaxPoly(e,r,n),s&&this.setZ(e,r,s.pt);else if(g.isFront(e)||e.outrec===r.outrec){s=this.addLocalMaxPoly(e,r,n),s&&this.setZ(e,r,s.pt);let l=this.addLocalMinPoly(e,r,n);this.setZ(e,r,l.pt)}else{s=this.addOutPt(e,n),this.setZ(e,r,s.pt);let l=this.addOutPt(r,n);this.setZ(e,r,l.pt),this.swapOutrecs(e,r)}else if(g.isHotEdge(e))s=this.addOutPt(e,n),this.setZ(e,r,s.pt),this.swapOutrecs(e,r);else if(g.isHotEdge(r))s=this.addOutPt(r,n),this.setZ(e,r,s.pt),this.swapOutrecs(e,r);else{let l,f;switch(this.fillrule){case H.Positive:l=e.windCount2,f=r.windCount2;break;case H.Negative:l=-e.windCount2,f=-r.windCount2;break;default:l=Math.abs(e.windCount2),f=Math.abs(r.windCount2);break}if(!g.isSamePolyType(e,r))s=this.addLocalMinPoly(e,r,n),this.setZ(e,r,s.pt);else if(i===1&&o===1){switch(s=null,this.cliptype){case J.Union:if(l>0&&f>0)return;s=this.addLocalMinPoly(e,r,n);break;case J.Difference:(g.getPolyType(e)===we.Clip&&l>0&&f>0||g.getPolyType(e)===we.Subject&&l<=0&&f<=0)&&(s=this.addLocalMinPoly(e,r,n));break;case J.Xor:s=this.addLocalMinPoly(e,r,n);break;default:if(l<=0||f<=0)return;s=this.addLocalMinPoly(e,r,n);break}s&&this.setZ(e,r,s.pt)}}}swapPositionsInAEL(e,r){let n=r.nextInAEL;n!==null&&(n.prevInAEL=e);let s=e.prevInAEL;s!==null&&(s.nextInAEL=r),r.prevInAEL=s,r.nextInAEL=e,e.prevInAEL=r,e.nextInAEL=n,r.prevInAEL===null&&(this.actives=r)}isValidAelOrder(e,r){if(r.curX!==e.curX)return r.curX>e.curX;let n=N.crossProductSign(e.top,r.bot,r.top);if(n!==0)return n<0;if(!g.isMaximaEdge(e)&&e.top.y>r.top.y)return N.crossProductSign(r.bot,e.top,g.nextVertex(e).pt)<=0;if(!g.isMaximaEdge(r)&&r.top.y>e.top.y)return N.crossProductSign(r.bot,r.top,g.nextVertex(r).pt)>=0;let s=r.bot.y,i=r.isLeftBound;return e.bot.y!==s||e.localMin.vertex.pt.y!==s?r.isLeftBound:e.isLeftBound!==i?i:N.isCollinear(g.prevPrevVertex(e).pt,e.bot,e.top)?!0:N.crossProductSign(g.prevPrevVertex(e).pt,r.bot,g.prevPrevVertex(r).pt)>0===i}isJoined(e){return e.joinWith!==Pe.None}split(e,r){e.joinWith===Pe.Right?(e.joinWith=Pe.None,e.nextInAEL.joinWith=Pe.None,this.addLocalMinPoly(e,e.nextInAEL,r,!0)):(e.joinWith=Pe.None,e.prevInAEL.joinWith=Pe.None,this.addLocalMinPoly(e.prevInAEL,e,r,!0))}setSides(e,r,n){e.frontEdge=r,e.backEdge=n}findEdgeWithMatchingLocMin(e){let r=e.nextInAEL;for(;r!==null;){if(r.localMin?.equals(e.localMin))return r;!g.isHorizontal(r)&&!(e.bot.x===r.bot.x&&e.bot.y===r.bot.y)?r=null:r=r.nextInAEL}for(r=e.prevInAEL;r!==null;){if(r.localMin?.equals(e.localMin))return r;if(!g.isHorizontal(r)&&!(e.bot.x===r.bot.x&&e.bot.y===r.bot.y))return null;r=r.prevInAEL}return r}addOutPt(e,r){let n=e.outrec,s=g.isFront(e),i=n.pts,o=i.next;if(s&&r.x===i.pt.x&&r.y===i.pt.y)return i;if(!s&&r.x===o.pt.x&&r.y===o.pt.y)return o;let a=new Je(r,n);return o.prev=a,a.prev=i,a.next=o,i.next=a,s&&(n.pts=a),a}addLocalMaxPoly(e,r,n){if(this.isJoined(e)&&this.split(e,n),this.isJoined(r)&&this.split(r,n),g.isFront(e)===g.isFront(r))if(g.isOpenEnd(e))this.swapFrontBackSides(e.outrec);else if(g.isOpenEnd(r))this.swapFrontBackSides(r.outrec);else return this.succeeded=!1,null;let s=this.addOutPt(e,n);if(e.outrec===r.outrec){let i=e.outrec;if(i.pts=s,this.usingPolytree){let o=g.getPrevHotEdge(e);o===null?i.owner=null:this.setOwner(i,o.outrec)}this.uncoupleOutRec(e)}else g.isOpen(e)?e.windDx<0?this.joinOutrecPaths(e,r):this.joinOutrecPaths(r,e):e.outrec.idx<r.outrec.idx?this.joinOutrecPaths(e,r):this.joinOutrecPaths(r,e);return s}swapFrontBackSides(e){let r=e.frontEdge;e.frontEdge=e.backEdge,e.backEdge=r,e.pts=e.pts.next}setOwner(e,r){for(;r.owner!==null&&r.owner.pts===null;)r.owner=r.owner.owner;let n=r;for(;n!==null&&n!==e;)n=n.owner;n!==null&&(r.owner=e.owner),e.owner=r}uncoupleOutRec(e){let r=e.outrec;r!==null&&(r.frontEdge.outrec=null,r.backEdge.outrec=null,r.frontEdge=null,r.backEdge=null)}joinOutrecPaths(e,r){let n=e.outrec.pts,s=r.outrec.pts,i=n.next,o=s.next;g.isFront(e)?(o.prev=n,n.next=o,s.next=i,i.prev=s,e.outrec.pts=s,e.outrec.frontEdge=r.outrec.frontEdge,e.outrec.frontEdge!==null&&(e.outrec.frontEdge.outrec=e.outrec)):(i.prev=s,s.next=i,n.next=o,o.prev=n,e.outrec.backEdge=r.outrec.backEdge,e.outrec.backEdge!==null&&(e.outrec.backEdge.outrec=e.outrec)),r.outrec.frontEdge=null,r.outrec.backEdge=null,r.outrec.pts=null,this.setOwner(r.outrec,e.outrec),g.isOpenEnd(e)&&(r.outrec.pts=e.outrec.pts,e.outrec.pts=null),e.outrec=null,r.outrec=null}swapOutrecs(e,r){let n=e.outrec,s=r.outrec;if(n===s){let i=n.frontEdge;n.frontEdge=n.backEdge,n.backEdge=i;return}n!==null&&(e===n.frontEdge?n.frontEdge=r:n.backEdge=r),s!==null&&(r===s.frontEdge?s.frontEdge=e:s.backEdge=e),e.outrec=s,r.outrec=n}disposeIntersectNodes(){this.intersectList.length=0}static ptsReallyClose(e,r){return Math.abs(e.x-r.x)<2&&Math.abs(e.y-r.y)<2}static isVerySmallTriangle(e){return e.next.next===e.prev&&(g.ptsReallyClose(e.prev.pt,e.next.pt)||g.ptsReallyClose(e.pt,e.next.pt)||g.ptsReallyClose(e.pt,e.prev.pt))}static buildPath(e,r,n,s){if(e===null||e.next===e||!n&&e.next===e.prev)return!1;s.length=0;let i,o;for(r?(i=e.pt,o=e.prev):(e=e.next,i=e.pt,o=e.next),s.push(i);o!==e;)o.pt.x===i.x&&o.pt.y===i.y||(i=o.pt,s.push(i)),r?o=o.prev:o=o.next;return s.length!==3||n||!g.isVerySmallTriangle(o)}buildPaths(e,r){e.length=0,r.length=0;let n=0;for(;n<this.outrecList.length;){let s=this.outrecList[n++];if(s.pts===null)continue;let i=[];s.isOpen?g.buildPath(s.pts,this.reverseSolution,!0,i)&&r.push(i):(this.cleanCollinear(s),g.buildPath(s.pts,this.reverseSolution,!1,i)&&e.push(i))}return!0}buildTree(e,r){e.clear(),r.length=0;let n=0;for(;n<this.outrecList.length;){let s=this.outrecList[n++];if(s.pts!==null){if(s.isOpen){let i=[];g.buildPath(s.pts,this.reverseSolution,!0,i)&&r.push(i);continue}this.checkBounds(s)&&this.recursiveCheckOwners(s,e)}}}checkBounds(e){return e.pts===null?!1:mt.isEmpty(e.bounds)?(this.cleanCollinear(e),e.pts===null||!g.buildPath(e.pts,this.reverseSolution,!1,e.path)?!1:(e.bounds=N.getBounds(e.path),!0)):!0}recursiveCheckOwners(e,r){if(!(e.polypath!==null||mt.isEmpty(e.bounds))){for(;e.owner!==null&&!(e.owner.splits!==null&&this.checkSplitOwner(e,e.owner.splits)||e.owner.pts!==null&&this.checkBounds(e.owner)&&this.containsRect(e.owner.bounds,e.bounds)&&this.path1InsidePath2(e.pts,e.owner.pts));)e.owner=e.owner.owner;e.owner!==null?(e.owner.polypath===null&&this.recursiveCheckOwners(e.owner,r),e.polypath=e.owner.polypath.addChild(e.path)):e.polypath=r.addChild(e.path)}}cleanCollinear(e){if(e=this.getRealOutRec(e),e===null||e.isOpen)return;if(!this.isValidClosedPath(e.pts)){e.pts=null;return}let r=e.pts,n=r;for(;;){if(n!==null&&N.isCollinear(n.prev.pt,n.pt,n.next.pt)&&(n.pt.x===n.prev.pt.x&&n.pt.y===n.prev.pt.y||n.pt.x===n.next.pt.x&&n.pt.y===n.next.pt.y||!this.preserveCollinear||N.dotProductSign(n.prev.pt,n.pt,n.next.pt)<0)){if(n===e.pts&&(e.pts=n.prev),n=this.disposeOutPt(n),!this.isValidClosedPath(n)){e.pts=null;return}r=n;continue}if(n===null||(n=n.next,n===r))break}this.fixSelfIntersects(e)}isValidClosedPath(e){return e!==null&&e.next!==e&&(e.next!==e.prev||!g.isVerySmallTriangle(e))}disposeOutPt(e){let r=e.next===e?null:e.next;return e.prev.next=e.next,e.next.prev=e.prev,r}fixSelfIntersects(e){let r=e.pts;if(r.prev!==r.next.next)for(;;){if(r.next&&r.next.next&&this.boundingBoxesOverlap(r.prev.pt,r.pt,r.next.pt,r.next.next.pt)&&N.segsIntersect(r.prev.pt,r.pt,r.next.pt,r.next.next.pt)){if((r===e.pts||r.next===e.pts)&&(e.pts=e.pts.prev),this.doSplitOp(e,r),e.pts===null)return;if(r=e.pts,r.prev===r.next.next)break;continue}if(r=r.next,r===e.pts)break}}doSplitOp(e,r){let n=r.prev,s=r.next.next;e.pts=n;let i=N.getLineIntersectPt(n.pt,r.pt,r.next.pt,s.pt);this.zCallbackInternal&&this.zCallbackInternal(n.pt,r.pt,r.next.pt,s.pt,i);let o=g.areaOutPt(n),a=o<zt?-o:o;if(a<As){e.pts=null;return}let u=this.areaTriangle(i,r.pt,r.next.pt),l=u<zt?-u:u;if(i.x===n.pt.x&&i.y===n.pt.y||i.x===s.pt.x&&i.y===s.pt.y)s.prev=n,n.next=s;else{let h=new Je(i,e);h.prev=n,h.next=s,s.prev=h,n.next=h}if(!(l>Ta)||!(l>a)&&u>zt!=o>zt)return;let f=this.newOutRec();f.owner=e.owner,r.outrec=f,r.next.outrec=f;let c=new Je(i,f);c.prev=r.next,c.next=r,f.pts=c,r.prev=c,r.next.next=c,this.usingPolytree&&(this.path1InsidePath2(n,c)?(f.splits===null&&(f.splits=[]),f.splits.push(e.idx)):(e.splits===null&&(e.splits=[]),e.splits.push(f.idx)))}static areaOutPt(e){let r=N.maxCoordForSafeAreaProduct,n=0,s=!0,i=e;do{let a=i.prev,u=i.pt;if(Math.abs(a.pt.x)>=r||Math.abs(a.pt.y)>=r||Math.abs(u.x)>=r||Math.abs(u.y)>=r){s=!1;break}n+=(a.pt.y+u.y)*(a.pt.x-u.x),i=i.next}while(i!==e);if(s)return BigInt(Math.round(n));let o=zt;i=e;do{let a=i.prev;if(Number.isSafeInteger(a.pt.y)&&Number.isSafeInteger(i.pt.y)&&Number.isSafeInteger(a.pt.x)&&Number.isSafeInteger(i.pt.x)){let u=BigInt(a.pt.y)+BigInt(i.pt.y),l=BigInt(a.pt.x)-BigInt(i.pt.x);o+=u*l}else{let u=a.pt.y+i.pt.y,l=a.pt.x-i.pt.x;o+=BigInt(Math.round(u*l))}i=i.next}while(i!==e);return o}areaTriangle(e,r,n){let s=N.maxCoordForSafeAreaProduct;if(Math.abs(e.x)<s&&Math.abs(e.y)<s&&Math.abs(r.x)<s&&Math.abs(r.y)<s&&Math.abs(n.x)<s&&Math.abs(n.y)<s){let o=(n.y+e.y)*(n.x-e.x)+(e.y+r.y)*(e.x-r.x)+(r.y+n.y)*(r.x-n.x);return BigInt(Math.round(o))}if(Number.isSafeInteger(e.x)&&Number.isSafeInteger(e.y)&&Number.isSafeInteger(r.x)&&Number.isSafeInteger(r.y)&&Number.isSafeInteger(n.x)&&Number.isSafeInteger(n.y)){let o=(BigInt(n.y)+BigInt(e.y))*(BigInt(n.x)-BigInt(e.x)),a=(BigInt(e.y)+BigInt(r.y))*(BigInt(e.x)-BigInt(r.x)),u=(BigInt(r.y)+BigInt(n.y))*(BigInt(r.x)-BigInt(n.x));return o+a+u}let i=(n.y+e.y)*(n.x-e.x)+(e.y+r.y)*(e.x-r.x)+(r.y+n.y)*(r.x-n.x);return BigInt(Math.round(i))}isValidOwner(e,r){for(;r!==null&&r!==e;)r=r.owner;return r===null}containsRect(e,r){return r.left>=e.left&&r.right<=e.right&&r.top>=e.top&&r.bottom<=e.bottom}checkSplitOwner(e,r){for(let n=0;n<r.length;n++){let s=this.outrecList[r[n]];if(s.pts===null&&s.splits!==null&&this.checkSplitOwner(e,s.splits))return!0;if(s=this.getRealOutRec(s),!(s===null||s===e||s.recursiveSplit===e)){if(s.recursiveSplit=e,s.splits!==null&&this.checkSplitOwner(e,s.splits))return!0;if(!(!this.checkBounds(s)||!this.containsRect(s.bounds,e.bounds)||!this.path1InsidePath2(e.pts,s.pts)))return this.isValidOwner(e,s)||(s.owner=e.owner),e.owner=s,!0}}return!1}};b(g,"openPathsEnabled",!0);var Er=g,He=class extends Er{constructor(){super(...arguments);b(this,"zCallback")}getZCallback(){return this.zCallback}addPath(r,n,s=!1){super.addPath(r,n,s)}addReuseableData(r){super.addReuseableData(r)}addPaths(r,n,s=!1){super.addPaths(r,n,s)}addSubject(r){this.addPaths(r,we.Subject)}addOpenSubject(r){this.addPaths(r,we.Subject,!0)}addClip(r){this.addPaths(r,we.Clip)}execute(r,n,s,i){if(Array.isArray(s)){let o=s,a=i;o.length=0,a&&(a.length=0);try{this.executeInternal(r,n),this.buildPaths(o,a||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}else{let o=s,a=i;o.clear(),a&&(a.length=0),this.usingPolytree=!0;try{this.executeInternal(r,n),this.buildTree(o,a||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}}};var xn={area(t){return N.area(t)},areaD(t){let e=0,r=t.length;if(r<3)return 0;let n=t[r-1];for(let s of t)e+=(n.y+s.y)*(n.x-s.x),n=s;return e*.5},scalePath64(t,e){let r=N.maxSafeCoordinateForScale(e),n=[];for(let s of t)N.checkSafeScaleValue(s.x,r,"scalePath64"),N.checkSafeScaleValue(s.y,r,"scalePath64"),n.push({x:Math.round(s.x*e),y:Math.round(s.y*e)});return n},scalePaths64(t,e){let r=[];for(let n of t)r.push(xn.scalePath64(n,e));return r},scalePathD(t,e){let r=[];for(let n of t)r.push({x:n.x*e,y:n.y*e});return r},scalePathsD(t,e){let r=[];for(let n of t)r.push(xn.scalePathD(n,e));return r}};var Le;(function(t){t[t.Miter=0]="Miter",t[t.Square=1]="Square",t[t.Bevel=2]="Bevel",t[t.Round=3]="Round"})(Le||(Le={}));var ue;(function(t){t[t.Polygon=0]="Polygon",t[t.Joined=1]="Joined",t[t.Butt=2]="Butt",t[t.Square=3]="Square",t[t.Round=4]="Round"})(ue||(ue={}));var yn=class{constructor(e,r,n=ue.Polygon){b(this,"inPaths");b(this,"joinType");b(this,"endType");b(this,"pathsReversed");b(this,"lowestPathIdx");this.joinType=r,this.endType=n;let s=n===ue.Polygon||n===ue.Joined;this.inPaths=[];for(let i of e)this.inPaths.push(vt.stripDuplicates(i,s));if(n===ue.Polygon){let i=vt.getLowestPathInfo(this.inPaths);this.lowestPathIdx=i.idx,this.pathsReversed=this.lowestPathIdx>=0&&i.isNegArea}else this.lowestPathIdx=-1,this.pathsReversed=!1}},ae=class ae{constructor(e=2,r=0,n=!1,s=!1){b(this,"groupList",[]);b(this,"pathOut",[]);b(this,"normals",[]);b(this,"solution",[]);b(this,"solutionTree",null);b(this,"groupDelta",0);b(this,"delta",0);b(this,"mitLimSqr",0);b(this,"stepsPerRad",0);b(this,"stepSin",0);b(this,"stepCos",0);b(this,"joinType",Le.Bevel);b(this,"endType",ue.Polygon);b(this,"arcTolerance",0);b(this,"mergeGroups",!0);b(this,"miterLimit",2);b(this,"preserveCollinear",!1);b(this,"reverseSolution",!1);b(this,"zCallback");b(this,"deltaCallback",null);b(this,"ZCB",(e,r,n,s,i)=>{(e.z||0)!==0&&(e.z===n.z||e.z===s.z)?i.z=e.z:(n.z||0)!==0&&n.z===r.z?i.z=n.z:(r.z||0)!==0&&r.z===s.z?i.z=r.z:this.zCallback&&this.zCallback(e,r,n,s,i)});this.miterLimit=e,this.arcTolerance=r,this.mergeGroups=!0,this.preserveCollinear=n,this.reverseSolution=s}clear(){this.groupList.length=0}addPath(e,r,n){if(e.length===0)return;let s=[e];this.addPaths(s,r,n)}addPaths(e,r,n){e.length!==0&&this.groupList.push(new yn(e,r,n))}calcSolutionCapacity(){let e=0;for(let r of this.groupList)e+=r.endType===ue.Joined?r.inPaths.length*2:r.inPaths.length;return e}checkPathsReversed(){let e=!1;for(let r of this.groupList)if(r.endType===ue.Polygon){e=r.pathsReversed;break}return e}executeInternal(e){if(this.groupList.length===0)return;if(Math.abs(e)<.5){for(let i of this.groupList)for(let o of i.inPaths)this.solution.push(o);return}this.delta=e,this.mitLimSqr=this.miterLimit<=1?2:2/ae.sqr(this.miterLimit);for(let i of this.groupList)this.doGroupOffset(i);if(this.groupList.length===0)return;let r=this.checkPathsReversed(),n=r?H.Negative:H.Positive,s=new He;s.preserveCollinear=this.preserveCollinear,s.reverseSolution=this.reverseSolution!==r,s.zCallback=this.ZCB,s.addSubject(this.solution),this.solutionTree!==null?s.execute(J.Union,n,this.solutionTree):s.execute(J.Union,n,this.solution)}execute(e,r){if(Array.isArray(r)){let n=r;n.length=0,this.solution=n,this.executeInternal(e)}else{let n=r;n.clear(),this.solutionTree=n,this.solution=[],this.executeInternal(e)}}executeWithCallback(e,r){this.deltaCallback=e,this.execute(1,r)}static getUnitNormal(e,r){let n=r.x-e.x,s=r.y-e.y;if(n===0&&s===0)return{x:0,y:0};let i=1/Math.sqrt(n*n+s*s);return{x:s*i,y:-n*i}}static getLowestPathInfo(e){let r=-1,n=!1,s={x:Number.MAX_SAFE_INTEGER,y:Number.MIN_SAFE_INTEGER};for(let i=0;i<e.length;++i){let o=Number.MAX_VALUE;for(let a of e[i])if(!(a.y<s.y||a.y===s.y&&a.x>=s.x)){if(o===Number.MAX_VALUE){if(o=ae.area(e[i]),o===0)break;n=o<0}r=i,s.x=a.x,s.y=a.y}}return{idx:r,isNegArea:n}}static translatePoint(e,r,n){return{x:e.x+r,y:e.y+n,z:e.z}}static reflectPoint(e,r){return{x:r.x+(r.x-e.x),y:r.y+(r.y-e.y),z:e.z}}static almostZero(e,r=.001){return Math.abs(e)<r}static hypotenuse(e,r){return Math.sqrt(e*e+r*r)}static normalizeVector(e){let r=ae.hypotenuse(e.x,e.y);if(ae.almostZero(r))return{x:0,y:0};let n=1/r;return{x:e.x*n,y:e.y*n}}static getAvgUnitVector(e,r){return ae.normalizeVector({x:e.x+r.x,y:e.y+r.y})}static intersectPoint(e,r,n,s){if(N.isAlmostZero(e.x-r.x)){if(N.isAlmostZero(n.x-s.x))return{x:0,y:0};let i=(s.y-n.y)/(s.x-n.x),o=n.y-i*n.x;return{x:e.x,y:i*e.x+o}}if(N.isAlmostZero(n.x-s.x)){let i=(r.y-e.y)/(r.x-e.x),o=e.y-i*e.x;return{x:n.x,y:i*n.x+o}}else{let i=(r.y-e.y)/(r.x-e.x),o=e.y-i*e.x,a=(s.y-n.y)/(s.x-n.x),u=n.y-a*n.x;if(N.isAlmostZero(i-a))return{x:0,y:0};let l=(u-o)/(i-a);return{x:l,y:i*l+o}}}getPerpendic(e,r){return{x:Math.round(e.x+r.x*this.groupDelta),y:Math.round(e.y+r.y*this.groupDelta),z:e.z||0}}getPerpendicD(e,r){return{x:e.x+r.x*this.groupDelta,y:e.y+r.y*this.groupDelta,z:e.z||0}}doBevel(e,r,n){let s,i,o=e[r].z||0;if(r===n){let a=Math.abs(this.groupDelta);s={x:Math.round(e[r].x-a*this.normals[r].x),y:Math.round(e[r].y-a*this.normals[r].y),z:o},i={x:Math.round(e[r].x+a*this.normals[r].x),y:Math.round(e[r].y+a*this.normals[r].y),z:o}}else s={x:Math.round(e[r].x+this.groupDelta*this.normals[n].x),y:Math.round(e[r].y+this.groupDelta*this.normals[n].y),z:o},i={x:Math.round(e[r].x+this.groupDelta*this.normals[r].x),y:Math.round(e[r].y+this.groupDelta*this.normals[r].y),z:o};this.pathOut.push(s),this.pathOut.push(i)}doSquare(e,r,n){let s;r===n?s={x:this.normals[r].y,y:-this.normals[r].x}:s=ae.getAvgUnitVector({x:-this.normals[n].y,y:this.normals[n].x},{x:this.normals[r].y,y:-this.normals[r].x});let i=Math.abs(this.groupDelta),o={x:e[r].x,y:e[r].y,z:e[r].z||0};o=ae.translatePoint(o,i*s.x,i*s.y);let a=ae.translatePoint(o,this.groupDelta*s.y,this.groupDelta*-s.x),u=ae.translatePoint(o,this.groupDelta*-s.y,this.groupDelta*s.x),l=this.getPerpendicD(e[n],this.normals[n]);if(r===n){let f={x:l.x+s.x*this.groupDelta,y:l.y+s.y*this.groupDelta},c=ae.intersectPoint(a,u,l,f);c.z=o.z,this.pathOut.push(Ze.fromPointD(ae.reflectPoint(c,o))),this.pathOut.push(Ze.fromPointD(c))}else{let f=this.getPerpendicD(e[r],this.normals[n]),c=ae.intersectPoint(a,u,l,f);c.z=o.z,this.pathOut.push(Ze.fromPointD(c)),this.pathOut.push(Ze.fromPointD(ae.reflectPoint(c,o)))}}doMiter(e,r,n,s){let i=this.groupDelta/(s+1);this.pathOut.push({x:Math.round(e[r].x+(this.normals[n].x+this.normals[r].x)*i),y:Math.round(e[r].y+(this.normals[n].y+this.normals[r].y)*i),z:e[r].z||0})}doRound(e,r,n,s){if(this.deltaCallback!==null){let l=Math.abs(this.groupDelta),f=this.arcTolerance>.01?this.arcTolerance:l*ae.arc_const,c=Math.PI/Math.acos(1-f/l);this.stepSin=Math.sin(2*Math.PI/c),this.stepCos=Math.cos(2*Math.PI/c),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=c/(2*Math.PI)}let i=e[r],o=i.z||0,a={x:this.normals[n].x*this.groupDelta,y:this.normals[n].y*this.groupDelta};r===n&&yr.negate(a),this.pathOut.push({x:Math.round(i.x+a.x),y:Math.round(i.y+a.y),z:o});let u=Math.ceil(this.stepsPerRad*Math.abs(s));for(let l=1;l<u;l++)a={x:a.x*this.stepCos-this.stepSin*a.y,y:a.x*this.stepSin+a.y*this.stepCos},this.pathOut.push({x:Math.round(i.x+a.x),y:Math.round(i.y+a.y),z:o});this.pathOut.push(this.getPerpendic(e[r],this.normals[r]))}buildNormals(e){let r=e.length;if(this.normals.length=0,r!==0){for(let n=0;n<r-1;n++)this.normals.push(ae.getUnitNormal(e[n],e[n+1]));this.normals.push(ae.getUnitNormal(e[r-1],e[0]))}}offsetPoint(e,r,n,s){if(Ze.equals(r[n],r[s]))return;let i=N.crossProductD(this.normals[n],this.normals[s]),o=N.dotProductD(this.normals[n],this.normals[s]);if(i>1?i=1:i<-1&&(i=-1),this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(r,this.normals,n,s),e.pathsReversed&&(this.groupDelta=-this.groupDelta)),Math.abs(this.groupDelta)<ae.Tolerance){this.pathOut.push(r[n]);return}if(o>-.999&&i*this.groupDelta<0)this.pathOut.push(this.getPerpendic(r[n],this.normals[s])),this.pathOut.push(r[n]),this.pathOut.push(this.getPerpendic(r[n],this.normals[n]));else if(o>.999&&this.joinType!==Le.Round)this.doMiter(r,n,s,o);else switch(this.joinType){case Le.Miter:o>this.mitLimSqr-1?this.doMiter(r,n,s,o):this.doSquare(r,n,s);break;case Le.Round:this.doRound(r,n,s,Math.atan2(i,o));break;case Le.Bevel:this.doBevel(r,n,s);break;default:this.doSquare(r,n,s);break}}offsetPolygon(e,r){this.pathOut=[];let n=r.length,s=n-1;for(let i=0;i<n;i++)this.offsetPoint(e,r,i,s),s=i;this.solution.push(this.pathOut)}offsetOpenJoined(e,r){this.offsetPolygon(e,r);let n=[...r].reverse();this.buildNormals(n),this.offsetPolygon(e,n)}offsetOpenPath(e,r){this.pathOut=[];let n=r.length-1;if(this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(r,this.normals,0,0)),Math.abs(this.groupDelta)<ae.Tolerance)this.pathOut.push(r[0]);else switch(this.endType){case ue.Butt:this.doBevel(r,0,0);break;case ue.Round:this.doRound(r,0,0,Math.PI);break;default:this.doSquare(r,0,0);break}for(let s=1,i=0;s<n;s++)this.offsetPoint(e,r,s,i),i=s;for(let s=n;s>0;s--)this.normals[s]={x:-this.normals[s-1].x,y:-this.normals[s-1].y};if(this.normals[0]=this.normals[n],this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(r,this.normals,n,n)),Math.abs(this.groupDelta)<ae.Tolerance)this.pathOut.push(r[n]);else switch(this.endType){case ue.Butt:this.doBevel(r,n,n);break;case ue.Round:this.doRound(r,n,n,Math.PI);break;default:this.doSquare(r,n,n);break}for(let s=n-1,i=n;s>0;s--)this.offsetPoint(e,r,s,i),i=s;this.solution.push(this.pathOut)}doGroupOffset(e){e.endType===ue.Polygon?(e.lowestPathIdx<0&&(this.delta=Math.abs(this.delta)),this.groupDelta=e.pathsReversed?-this.delta:this.delta):this.groupDelta=Math.abs(this.delta);let r=Math.abs(this.groupDelta);if(this.joinType=e.joinType,this.endType=e.endType,e.joinType===Le.Round||e.endType===ue.Round){let n=this.arcTolerance>.01?this.arcTolerance:r*ae.arc_const,s=Math.PI/Math.acos(1-n/r);this.stepSin=Math.sin(2*Math.PI/s),this.stepCos=Math.cos(2*Math.PI/s),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=s/(2*Math.PI)}for(let n of e.inPaths){this.pathOut=[];let s=n.length;if(s===1){let i=n[0];this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(n,this.normals,0,0),e.pathsReversed&&(this.groupDelta=-this.groupDelta));let o=i.z||0;if(e.endType===ue.Round){let a=Math.ceil(this.stepsPerRad*2*Math.PI);if(this.pathOut=ae.ellipse(i,Math.abs(this.groupDelta),Math.abs(this.groupDelta),a),o!==0)for(let u=0;u<this.pathOut.length;u++)this.pathOut[u].z=o}else{let a=Math.ceil(Math.abs(this.groupDelta)),u={left:i.x-a,top:i.y-a,right:i.x+a,bottom:i.y+a};this.pathOut=[{x:u.left,y:u.top,z:o},{x:u.right,y:u.top,z:o},{x:u.right,y:u.bottom,z:o},{x:u.left,y:u.bottom,z:o}]}this.solution.push(this.pathOut);continue}switch(s===2&&e.endType===ue.Joined&&(this.endType=e.joinType===Le.Round?ue.Round:ue.Square),this.buildNormals(n),this.endType){case ue.Polygon:this.offsetPolygon(e,n);break;case ue.Joined:this.offsetOpenJoined(e,n);break;default:this.offsetOpenPath(e,n);break}}}static stripDuplicates(e,r){let n=e.length,s=[];if(n===0)return s;let i=e[0];s.push(i);for(let o=1;o<n;o++)Ze.equals(i,e[o])||(i=e[o],s.push(i));return r&&Ze.equals(i,s[0])&&s.pop(),s}static area(e){return N.area(e)}static sqr(e){return e*e}static ellipse(e,r,n=0,s=0){if(r<=0)return[];n<=0&&(n=r),s<=2&&(s=Math.ceil(Math.PI*Math.sqrt((r+n)/2)));let i=Math.sin(2*Math.PI/s),o=Math.cos(2*Math.PI/s),a=o,u=i,l=[{x:Math.round(e.x+r),y:e.y}];for(let f=1;f<s;++f){l.push({x:Math.round(e.x+r*a),y:Math.round(e.y+n*u)});let c=a*o-u*i;u=u*o+a*i,a=c}return l}};b(ae,"Tolerance",1e-12),b(ae,"arc_const",.002);var vt=ae;var Ec=BigInt(2);function Sn(t,e,r){return typeof e=="number"?bn(J.Union,t,null,e):bn(J.Union,t,e,r)}function bn(t,e,r,n){let s=[];if(e===null)return s;let i=new He;return i.addPaths(e,we.Subject),r!==null&&i.addPaths(r,we.Clip),i.execute(t,n,s),s}function Pr(t,e,r,n,s=2,i=0){let o=new vt(s,i);o.addPaths(t,r,n);let a=[];return o.execute(e,a),a}var rt=1e4;function xt(){return{layers:new Map,parts:[]}}function Re(t,e="cut"){return{layers:new Map([[e,{regions:t,lines:[]}]]),parts:[]}}function Mt(t,e="cut"){return{layers:new Map([[e,{regions:[],lines:t}]]),parts:[]}}function Rs(t){if(t.parts.length)return!1;for(let e of t.layers.values())if(e.regions.length||e.lines.length)return!1;return!0}var nt=t=>t.map(e=>e.map(([r,n])=>({x:Math.round(r*rt),y:Math.round(n*rt)}))),At=t=>t.filter(e=>e.length>=2).map(e=>e.map(r=>[r.x/rt,r.y/rt]));function ye(t,e="nonzero"){if(!t.length)return[];let r=e==="evenodd"?H.EvenOdd:H.NonZero;return At(Sn(nt(t),r)).filter(n=>n.length>=3)}function Ns(t,e,r){if(!e.length)return[];let n=new He;n.addSubject(nt(e)),r.length&&n.addClip(nt(r));let s=[];return n.execute(t,H.NonZero,s),At(s).filter(i=>i.length>=3)}var Lr=(t,e)=>e.length?Ns(J.Difference,t,e):ye(t),Ir=(t,e)=>Ns(J.Intersection,t,e);function _t(t,e,r){if(!t.length)return[];if(!e.length)return r==="outside"?t:[];let n=new He;n.addOpenSubject(nt(t)),n.addClip(nt(e));let s=[],i=[];return n.execute(r==="inside"?J.Intersection:J.Difference,H.NonZero,s,i),At(i)}function Tr(t,e,r="round",n=.01){if(!t.length)return[];if(e===0)return ye(t);let s=r==="round"?Le.Round:r==="square"?Le.Square:Le.Miter,i=Pr(nt(ye(t)),e*rt,s,ue.Polygon,2,n*rt);return At(i).filter(o=>o.length>=3)}function Bs(t,e){if(!t.length||e<=0)return[];let r=Pr(nt(t),e/2*rt,Le.Round,ue.Round,2,.01*rt);return At(r)}function Gs(t){if(!t.length)return[];let e=new Zt,r=new He;r.addSubject(nt(t)),r.execute(J.Union,H.NonZero,e);let n=[],s=i=>{for(let o=0;o<i.count;o++){let a=i.child(o),u=[a.poly];for(let l=0;l<a.count;l++){let f=a.child(l);u.push(f.poly),s(f)}n.push(At(u))}};return s(e),n}function st(t){let e=0;for(let r=0,n=t.length-1;r<t.length;n=r++)e+=(t[n][0]+t[r][0])*(t[n][1]-t[r][1]);return-e/2}function Fs(t,[e,r]){return[t[0]*e+t[2]*r+t[4],t[1]*e+t[3]*r+t[5]]}function Ds(t,e){let r=e[0]*e[3]-e[1]*e[2]<0,n=new Map;for(let[s,i]of t)n.set(s,{regions:i.regions.map(o=>{let a=o.map(u=>Fs(e,u));return r?a.reverse():a}),lines:i.lines.map(o=>o.map(a=>Fs(e,a)))});return n}function Cr(t,e){return{layers:Ds(t.layers,e),parts:t.parts.map(r=>({...r,layers:Ds(r.layers,e)}))}}function Yt(t){let e=xt();for(let r of t){for(let[n,s]of r.layers){let i=e.layers.get(n)??{regions:[],lines:[]};for(let o of s.regions)i.regions.push(o);for(let o of s.lines)i.lines.push(o);e.layers.set(n,i)}for(let n of r.parts)e.parts.push(n)}return e}function Us(t,e){let r={regions:[],lines:[]};for(let n of t.values()){for(let s of n.regions)r.regions.push(s);for(let s of n.lines)r.lines.push(s)}return new Map([[e,r]])}function Mr(t,e){if(t.parts.length&&e!=="guide")throw new Error(`a part cannot go on the ${e} layer as a whole. Put ${e}() inside part() instead.`);return{layers:Us(t.layers,e),parts:t.parts.map(r=>({...r,layers:Us(r.layers,e)}))}}function Ar(t){let e=1/0,r=1/0,n=-1/0,s=-1/0;for(let i of t)for(let[o,a]of i)o<e&&(e=o),a<r&&(r=a),o>n&&(n=o),a>s&&(s=a);return e===1/0?null:[e,r,n,s]}function wn(t,e){let r=[];for(let[n,s]of t)if(!e?.(n))for(let i of[...s.regions,...s.lines])r.push(i);return Ar(r)}function Hs(t){let e=[...t].sort((i,o)=>i[0]-o[0]||i[1]-o[1]);if(e.length<3)return e;let r=(i,o,a)=>(o[0]-i[0])*(a[1]-i[1])-(o[1]-i[1])*(a[0]-i[0]),n=[];for(let i of e){for(;n.length>=2&&r(n[n.length-2],n[n.length-1],i)<=0;)n.pop();n.push(i)}let s=[];for(let i=e.length-1;i>=0;i--){let o=e[i];for(;s.length>=2&&r(s[s.length-2],s[s.length-1],o)<=0;)s.pop();s.push(o)}return s.pop(),n.pop(),n.concat(s)}function Vs(t,e,r,n){return t<1e-9?3:e>0?Math.max(Math.floor(e),3):Math.max(Math.ceil(Math.min(360/r,t*2*Math.PI/n)),5)}function Or(t,e,r){let n=[];for(let s=0;s<r;s++){let i=2*Math.PI*s/r;n.push([t*Math.cos(i),e*Math.sin(i)])}return n}function zs(t,e,r,n){if(r=Math.min(r,t/2,e/2),r<=0)return[[0,0],[t,0],[t,e],[0,e]];let s=Math.max(1,Math.ceil(n(r)/4)),i=[],o=[[t-r,r,-90],[t-r,e-r,0],[r,e-r,90],[r,r,180]];for(let[a,u,l]of o)for(let f=0;f<=s;f++){let c=(l+90*f/s)*Math.PI/180;i.push([a+r*Math.cos(c),u+r*Math.sin(c)])}return i}function Fr(t,e){let r=Math.round(t/e);return r%2===0&&(r+=t/e>r?1:-1),Math.max(3,r)}var jt=(t,e,r,n)=>[[t,e],[r,e],[r,n],[t,n]];function Fa(t,e,r,n){if(e==="flat")return[];let s=Fr(t,n),i=t/s,o=[];for(let a=0;a<s;a++)(e==="out"?a%2===1:a%2===0)&&o.push(jt(a*i,-1,(a+1)*i,r));return o}function $s(t,e,r,n,s){let i=[([u,l])=>[u,l],([u,l])=>[t-l,u],([u,l])=>[t-u,e-l],([u,l])=>[l,e-u]],o=[t,e,t,e],a=[];return r.forEach((u,l)=>{for(let f of Fa(o[l],u,n,s))a.push(f.map(i[l]))}),Lr([jt(0,0,t,e)],a)}function Xs(t,e,r,n){let s=Fr(t,n),i=t/s,o=[];for(let a=0;a<s;a++)(e==="out"?a%2===0:a%2===1)&&o.push(jt(a*i,-r/2,(a+1)*i,r/2));return o}function qs(t,e,r,n,s){let i=jt(-t/2,-1,t/2,e),o=jt(-r/2,s,r/2,s+n);return[i,o]}function Ws(t,e,r,n,s){let i=[],o=s+n,a=Math.floor(t/r),u=(t-a*r)/2;for(let l=0;l<=a;l++){let f=u+l*r,c=l%2===0?n:n-o/2;for(let h=c;h<e;h+=o){let p=Math.max(h,l%2===0?n:0),d=Math.min(h+s,e-(l%2===0?n:0));d-p>=n/2&&i.push([[f,p],[f,d]])}}return i}var Dr=(t,e=!0)=>`line ${t.line}${e?`, column ${t.col}`:""}${t.file?` in <${t.file}>`:""}`,O=class extends Error{constructor(r,n){super(n?`${r} (${Dr(n)})`:r);this.echoes=[];this.name="KerfError",n&&(this.line=n.line,this.col=n.col,this.file=n.file)}},Da=["<=",">=","==","!=","&&","||","+","-","*","/","%","^","<",">","!","?",":","=",".",",",";","(",")","[","]","{","}","#"];function Ur(t,e){let r=[],n=[],s=0,i=1,o=0,a=()=>({line:i,col:s-o+1,offset:s,...e&&{file:e}}),u=l=>{for(let f=0;f<l;f++)t[s]===`
7
+ `&&(i++,o=s+1),s++};for(;s<t.length;){let l=t[s];if(l===" "||l===" "||l==="\r"||l===`
8
+ `){u(1);continue}if(l==="/"&&t[s+1]==="/"){let h=t.indexOf(`
9
+ `,s),p=h<0?t.length:h,d=/^[ \t]*$/.test(t.slice(t.lastIndexOf(`
10
+ `,s-1)+1,s));n.push({text:t.slice(s+2,p).trim(),line:i,block:!1,own:d}),s=p;continue}if(l==="/"&&t[s+1]==="*"){let h=a(),p=t.indexOf("*/",s+2);if(p<0)throw new O("Unclosed block comment",h);n.push({text:t.slice(s+2,p).trim(),line:h.line,block:!0,own:!0}),u(p+2-s);continue}let f=a();if(/[0-9]/.test(l)||l==="."&&/[0-9]/.test(t[s+1]??"")){let h=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(t.slice(s));r.push({type:"num",value:h[0],pos:f}),u(h[0].length);continue}if(/[A-Za-z_$]/.test(l)){let h=/^[A-Za-z_$][A-Za-z0-9_]*/.exec(t.slice(s));r.push({type:"id",value:h[0],pos:f}),u(h[0].length);continue}if(l==='"'){let h="";for(u(1);s<t.length&&t[s]!=='"';){if(t[s]==="\\"){let p=t[s+1];if(p==="n")h+=`
11
+ `;else if(p==="t")h+=" ";else if(p==="u"){let d=t.slice(s+2,s+6);if(!/^[0-9a-fA-F]{4}$/.test(d))throw new O("Bad \\u escape",a());h+=String.fromCharCode(parseInt(d,16)),u(4)}else h+=p;u(2);continue}if(t[s]===`
12
+ `)throw new O("Unclosed string",f);h+=t[s],u(1)}if(s>=t.length)throw new O("Unclosed string",f);u(1),r.push({type:"str",value:h,pos:f});continue}if(l==="<"&&/^<[A-Za-z0-9_./-]+>/.test(t.slice(s))){let h=r[r.length-1];if(h&&h.type==="id"&&(h.value==="use"||h.value==="include")){let p=/^<([A-Za-z0-9_./-]+)>/.exec(t.slice(s));r.push({type:"str",value:p[1],pos:f}),u(p[0].length);continue}}let c=Da.find(h=>t.startsWith(h,s));if(!c)throw new O(`Unexpected character "${l}"`,f);r.push({type:"punct",value:c,pos:f}),u(c.length)}return r.push({type:"eof",value:"",pos:a()}),{tokens:r,comments:n}}var kn=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]);function it(t,e){let{tokens:r,comments:n}=Ur(t,e),s=new En(r),i=[];for(;!s.at("eof");)i.push(...s.statement());return{program:{body:i},comments:n}}var Kt=class Kt{constructor(e){this.tokens=e;this.i=0}peek(e=0){return this.tokens[Math.min(this.i+e,this.tokens.length-1)]}at(e,r,n=0){let s=this.peek(n);return s.type===e&&(r===void 0||s.value===r)}isP(e,r=0){return this.at("punct",e,r)}isK(e,r=0){return this.at("id",e,r)}next(){return this.tokens[this.i++]}fail(e,r=this.peek()){let n=r.type==="eof"?"end of file":`"${r.value}"`;throw new O(`${e}, found ${n}`,r.pos)}expectP(e){return this.isP(e)||this.fail(`Expected "${e}"`),this.next()}ident(){let e=this.peek();return(e.type!=="id"||kn.has(e.value))&&this.fail("Expected a name"),this.next()}statement(){let e=this.peek();if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let o=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),o.push(...this.statement());return this.next(),[{kind:"block",body:o,pos:e.pos}]}if(this.isK("module")){this.next();let o=this.ident().value,a=this.params();return[{kind:"module",name:o,params:a,body:this.body(),pos:e.pos}]}if(this.isK("function")&&this.at("id",void 0,1)){this.next();let o=this.ident().value,a=this.params();this.expectP("=");let u=this.expr();return this.expectP(";"),[{kind:"function",name:o,params:a,body:u,pos:e.pos}]}if(this.isK("use")||this.isK("include")){this.next();let o=this.peek();return o.type!=="str"&&this.fail("Expected a library path like <kerf/box>"),this.next(),this.isP(";")&&this.next(),[{kind:"use",path:o.value,include:e.value==="include",pos:e.pos}]}if(this.isK("for"))return this.next(),[{kind:"for",assigns:this.assigns(),body:this.body(),pos:e.pos}];if(this.isK("if")){this.next(),this.expectP("(");let o=this.expr();this.expectP(")");let a=this.body(),u=[];return this.isK("else")&&(this.next(),u=this.body()),[{kind:"if",cond:o,then:a,else:u,pos:e.pos}]}if(this.isK("let")&&this.isP("(",1))return this.next(),[{kind:"let",assigns:this.assigns(),body:this.body(),pos:e.pos}];if(e.type==="id"&&this.isP("=",1)){let o=this.ident().value;this.next();let a=this.peek().pos.offset,u=this.expr(),l=this.expectP(";").pos.offset;return[{kind:"assign",name:o,value:u,span:[a,l],pos:e.pos}]}let r=null;(this.isP("*")||this.isP("!")||this.isP("#")||this.isP("%"))&&(r=this.next().value);let n=this.peek();(n.type!=="id"||kn.has(n.value))&&this.fail("Expected a statement"),this.next();let s=this.args(),i=this.body();return[{kind:"call",name:n.value,args:s,children:i,modifier:r,pos:n.pos}]}body(){if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let e=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),e.push(...this.statement());return this.next(),e}return this.statement()}params(){this.expectP("(");let e=[];for(;!this.isP(")");){let r=this.ident().value,n=null;this.isP("=")&&(this.next(),n=this.expr()),e.push({name:r,default:n}),this.isP(")")||this.expectP(",")}return this.next(),e}args(){this.expectP("(");let e=[];for(;!this.isP(")");){let r=null;this.at("id")&&this.isP("=",1)&&(r=this.next().value,this.next()),e.push({name:r,value:this.expr()}),this.isP(")")||this.expectP(",")}return this.next(),e}assigns(){this.expectP("(");let e=[];for(;!this.isP(")");){let r=this.ident();this.expectP("="),e.push({name:r.value,value:this.expr(),pos:r.pos}),this.isP(")")||this.expectP(",")}return this.next(),e}expr(){let e=this.peek();if(this.isK("function")&&this.isP("(",1))return this.next(),{kind:"lambda",params:this.params(),body:this.expr(),pos:e.pos};if(this.isK("let")&&this.isP("(",1))return this.next(),{kind:"let",assigns:this.assigns(),body:this.expr(),pos:e.pos};let r=this.binary(0);if(this.isP("?")){this.next();let n=this.expr();this.expectP(":");let s=this.expr();return{kind:"ternary",cond:r,then:n,else:s,pos:e.pos}}return r}binary(e){if(e>=Kt.LEVELS.length)return this.unary();let r=this.binary(e+1);for(;this.at("punct")&&Kt.LEVELS[e].includes(this.peek().value);){let n=this.next(),s=this.binary(e+1);r={kind:"binary",op:n.value,left:r,right:s,pos:n.pos}}return r}unary(){if(this.isP("-")||this.isP("!")||this.isP("+")){let e=this.next();return{kind:"unary",op:e.value,arg:this.unary(),pos:e.pos}}return this.power()}power(){let e=this.postfix();if(this.isP("^")){let r=this.next();return{kind:"binary",op:"^",left:e,right:this.unary(),pos:r.pos}}return e}postfix(){let e=this.primary();for(;;){let r=this.peek();if(this.isP("("))e={kind:"call",callee:e,args:this.args(),pos:r.pos};else if(this.isP("[")){this.next();let n=this.expr();this.expectP("]"),e={kind:"index",target:e,index:n,pos:r.pos}}else if(this.isP("."))this.next(),e={kind:"member",target:e,name:this.ident().value,pos:r.pos};else return e}}primary(){let e=this.peek();if(e.type==="num")return this.next(),{kind:"num",value:Number(e.value),pos:e.pos};if(e.type==="str")return this.next(),{kind:"str",value:e.value,pos:e.pos};if(e.type==="id")return e.value==="true"||e.value==="false"?(this.next(),{kind:"bool",value:e.value==="true",pos:e.pos}):e.value==="undef"?(this.next(),{kind:"undef",pos:e.pos}):(kn.has(e.value)&&this.fail("Expected a value"),this.next(),{kind:"var",name:e.value,pos:e.pos});if(this.isP("(")){this.next();let r=this.expr();return this.expectP(")"),r}if(this.isP("["))return this.list();this.fail("Expected a value")}list(){let e=this.expectP("[");if(this.isP("]"))return this.next(),{kind:"list",items:[],pos:e.pos};if(!this.isK("for")&&!this.isK("if")&&!this.isK("each")&&!(this.isK("let")&&this.isP("(",1))){let r=this.expr();if(this.isP(":")){this.next();let s=null,i=this.expr();return this.isP(":")&&(this.next(),s=i,i=this.expr()),this.expectP("]"),{kind:"range",start:r,step:s,end:i,pos:e.pos}}let n=[{kind:"item",expr:r}];return this.listRest(n,e.pos)}return this.listRest([],e.pos)}listRest(e,r){if(e.length){if(this.isP("]"))return this.next(),{kind:"list",items:e,pos:r};this.expectP(",")}for(;!this.isP("]");)e.push(this.listItem()),this.isP("]")||this.expectP(",");return this.next(),{kind:"list",items:e,pos:r}}listItem(){if(this.isK("for")&&this.isP("(",1))return this.next(),{kind:"for",assigns:this.assigns(),body:this.listItem()};if(this.isK("if")&&this.isP("(",1)){this.next(),this.expectP("(");let e=this.expr();this.expectP(")");let r=this.listItem(),n=null;return this.isK("else")&&(this.next(),n=this.listItem()),{kind:"if",cond:e,then:r,else:n}}if(this.isK("let")&&this.isP("(",1))return this.next(),{kind:"let",assigns:this.assigns(),body:this.listItem()};if(this.isK("each"))return this.next(),{kind:"each",expr:this.expr()};if(this.isP("(")&&(this.isK("for",1)||this.isK("if",1))){this.next();let e=this.listItem();return this.expectP(")"),e}return{kind:"item",expr:this.expr()}}};Kt.LEVELS=[["||"],["&&"],["==","!="],["<","<=",">",">="],["+","-"],["*","/","%"]];var En=Kt;var Zs={"kerf/box":`// kerf/box: finger-jointed boxes.
13
13
  // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
14
14
 
15
15
  // Box from its outer size [width, depth, height] in the current material.
@@ -19,13 +19,18 @@ module box(size, lid = false, finger = undef) {
19
19
  w = size[0];
20
20
  d = size[1];
21
21
  h = size[2];
22
+ t = $thickness;
22
23
  top = lid ? "in" : "flat";
23
- part("bottom") finger_rect([w, d], "out", finger = finger);
24
- if (lid) part("lid") finger_rect([w, d], "out", finger = finger);
25
- part("front") finger_rect([w, h], ["in", "out", top, "out"], finger = finger);
26
- part("back") finger_rect([w, h], ["in", "out", top, "out"], finger = finger);
27
- part("left") finger_rect([d, h], ["in", "in", top, "in"], finger = finger);
28
- part("right") finger_rect([d, h], ["in", "in", top, "in"], finger = finger);
24
+ part("bottom", at = [0, 0, 0]) finger_rect([w, d], "out", finger = finger);
25
+ if (lid) part("lid", at = [0, 0, h - t]) finger_rect([w, d], "out", finger = finger);
26
+ part("front", at = [0, t, 0], rotate = [90, 0, 0])
27
+ finger_rect([w, h], ["in", "out", top, "out"], finger = finger);
28
+ part("back", at = [0, d, 0], rotate = [90, 0, 0])
29
+ finger_rect([w, h], ["in", "out", top, "out"], finger = finger);
30
+ part("left", rotate = [90, 0, 90])
31
+ finger_rect([d, h], ["in", "in", top, "in"], finger = finger);
32
+ part("right", at = [w - t, 0, 0], rotate = [90, 0, 90])
33
+ finger_rect([d, h], ["in", "in", top, "in"], finger = finger);
29
34
  }
30
35
 
31
36
  // Divider that slides between two walls: tabs on both sides drop into
@@ -33,10 +38,10 @@ module box(size, lid = false, finger = undef) {
33
38
  module divider(size, finger = undef) {
34
39
  finger_rect(size, ["flat", "out", "flat", "out"], finger = finger);
35
40
  }
36
- `};function br(r,e=.02){let t=[],n=[],s=[],i=[0,0],o=[0,0],a=l=>{s.length>=2&&(l?t:n).push(s),s=[]},u=l=>Math.max(2,Math.min(256,Math.ceil(Math.sqrt(l/e))));for(let l of r)if(l.type==="M")a(!1),i=o=[l.x,l.y],s=[o];else if(l.type==="L")o=[l.x,l.y],s.push(o);else if(l.type==="Q"){let[f,c]=o,h=u(Math.hypot(l.x1-f,l.y1-c)+Math.hypot(l.x-l.x1,l.y-l.y1));for(let p=1;p<=h;p++){let g=p/h,m=1-g;s.push([m*m*f+2*m*g*l.x1+g*g*l.x,m*m*c+2*m*g*l.y1+g*g*l.y])}o=[l.x,l.y]}else if(l.type==="C"){let[f,c]=o,h=u(Math.hypot(l.x1-f,l.y1-c)+Math.hypot(l.x2-l.x1,l.y2-l.y1)+Math.hypot(l.x-l.x2,l.y-l.y2));for(let p=1;p<=h;p++){let g=p/h,m=1-g;s.push([m*m*m*f+3*m*m*g*l.x1+3*m*g*g*l.x2+g*g*g*l.x,m*m*m*c+3*m*m*g*l.y1+3*m*g*g*l.y2+g*g*g*l.y])}o=[l.x,l.y]}else a(!0),o=i,s=[i];return a(!1),{closed:t,open:n}}function ps(r){let e=y=>/^[a-zA-Z]$/.test(y),t=r.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g)??[],n=[],s=0,i="",o=0,a=0,u=0,l=0,f=0,c=0,h=0,p=0,g="",m=()=>{let y=t[s++];if(y===void 0||e(y))throw new Error(`Bad path data near "${y??"end"}"`);return Number(y)},x=()=>{let y=t[s];if(y===void 0)throw new Error("Bad path data: missing arc flag");return y.length>1&&(y[0]==="0"||y[0]==="1")&&!y.includes(".")?(t[s]=y.slice(1),Number(y[0])):(s++,Number(y))};for(;s<t.length;){if(e(t[s]))i=t[s++];else if(i){if(i==="Z"||i==="z")throw new Error(`Bad path data near "${t[s]}": Z takes no numbers`)}else throw new Error("Path data must start with a command");let y=i===i.toLowerCase(),S=i.toUpperCase(),w=y?o:0,F=y?a:0;if(S==="M")o=w+m(),a=F+m(),u=o,l=a,n.push({type:"M",x:o,y:a}),i=y?"l":"L";else if(S==="L")o=w+m(),a=F+m(),n.push({type:"L",x:o,y:a});else if(S==="H")o=w+m(),n.push({type:"L",x:o,y:a});else if(S==="V")a=F+m(),n.push({type:"L",x:o,y:a});else if(S==="C"||S==="S"){let P,U;if(S==="C")P=w+m(),U=F+m();else{let W=g==="C"||g==="S";P=W?2*o-f:o,U=W?2*a-c:a}let O=w+m(),L=F+m();o=w+m(),a=F+m(),f=O,c=L,n.push({type:"C",x1:P,y1:U,x2:O,y2:L,x:o,y:a})}else if(S==="Q"||S==="T"){let P,U;if(S==="Q")P=w+m(),U=F+m();else{let O=g==="Q"||g==="T";P=O?2*o-h:o,U=O?2*a-p:a}o=w+m(),a=F+m(),h=P,p=U,n.push({type:"Q",x1:P,y1:U,x:o,y:a})}else if(S==="A"){let P=m(),U=m(),O=m(),L=x(),W=x(),_=w+m(),Y=F+m();n.push(...$o(o,a,P,U,O,L,W,_,Y)),o=_,a=Y}else if(S==="Z")n.push({type:"Z"}),o=u,a=l;else throw new Error(`Unknown path command "${i}"`);g=S}return n}function $o(r,e,t,n,s,i,o,a,u){if(t===0||n===0||r===a&&e===u)return[{type:"L",x:a,y:u}];t=Math.abs(t),n=Math.abs(n);let l=s*Math.PI/180,f=Math.cos(l),c=Math.sin(l),h=(r-a)/2,p=(e-u)/2,g=f*h+c*p,m=-c*h+f*p,x=g*g/(t*t)+m*m/(n*n);x>1&&(t*=Math.sqrt(x),n*=Math.sqrt(x));let y=t*t*n*n-t*t*m*m-n*n*g*g,S=t*t*m*m+n*n*g*g,w=Math.sqrt(Math.max(0,y/S));i===o&&(w=-w);let F=w*t*m/n,P=-w*n*g/t,U=f*F-c*P+(r+a)/2,O=c*F+f*P+(e+u)/2,L=(X,ee,k,M)=>Math.atan2(X*M-ee*k,X*k+ee*M),W=L(1,0,(g-F)/t,(m-P)/n),_=L((g-F)/t,(m-P)/n,(-g-F)/t,(-m-P)/n);!o&&_>0&&(_-=2*Math.PI),o&&_<0&&(_+=2*Math.PI);let Y=Math.ceil(Math.abs(_)/(Math.PI/2)),he=[],ce=X=>[U+t*Math.cos(X)*f-n*Math.sin(X)*c,O+t*Math.cos(X)*c+n*Math.sin(X)*f],Q=X=>[-t*Math.sin(X)*f-n*Math.cos(X)*c,-t*Math.sin(X)*c+n*Math.cos(X)*f];for(let X=0;X<Y;X++){let ee=W+_*X/Y,k=W+_*(X+1)/Y,M=4/3*Math.tan((k-ee)/4),A=ce(ee),G=ce(k),D=Q(ee),H=Q(k);he.push({type:"C",x1:A[0]+M*D[0],y1:A[1]+M*D[1],x2:G[0]-M*H[0],y2:G[1]-M*H[1],x:G[0],y:G[1]})}return he}String.prototype.codePointAt||(function(){var r=(function(){try{var t={},n=Object.defineProperty,s=n(t,t,t)&&n}catch{}return s})(),e=function(t){if(this==null)throw TypeError();var n=String(this),s=n.length,i=t?Number(t):0;if(i!=i&&(i=0),!(i<0||i>=s)){var o=n.charCodeAt(i),a;return o>=55296&&o<=56319&&s>i+1&&(a=n.charCodeAt(i+1),a>=56320&&a<=57343)?(o-55296)*1024+a-56320+65536:o}};r?r(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e})();var Sn=0,ti=-3;function Vt(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Zo(r,e){this.source=r,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new Vt,this.dtree=new Vt}var ri=new Vt,ni=new Vt,wn=new Uint8Array(30),kn=new Uint16Array(30),si=new Uint8Array(30),ii=new Uint16Array(30),_o=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),vs=new Vt,ze=new Uint8Array(320);function oi(r,e,t,n){var s,i;for(s=0;s<t;++s)r[s]=0;for(s=0;s<30-t;++s)r[s+t]=s/t|0;for(i=n,s=0;s<30;++s)e[s]=i,i+=1<<r[s]}function Yo(r,e){var t;for(t=0;t<7;++t)r.table[t]=0;for(r.table[7]=24,r.table[8]=152,r.table[9]=112,t=0;t<24;++t)r.trans[t]=256+t;for(t=0;t<144;++t)r.trans[24+t]=t;for(t=0;t<8;++t)r.trans[168+t]=280+t;for(t=0;t<112;++t)r.trans[176+t]=144+t;for(t=0;t<5;++t)e.table[t]=0;for(e.table[5]=32,t=0;t<32;++t)e.trans[t]=t}var ms=new Uint16Array(16);function rn(r,e,t,n){var s,i;for(s=0;s<16;++s)r.table[s]=0;for(s=0;s<n;++s)r.table[e[t+s]]++;for(r.table[0]=0,i=0,s=0;s<16;++s)ms[s]=i,i+=r.table[s];for(s=0;s<n;++s)e[t+s]&&(r.trans[ms[e[t+s]]++]=s)}function jo(r){r.bitcount--||(r.tag=r.source[r.sourceIndex++],r.bitcount=7);var e=r.tag&1;return r.tag>>>=1,e}function Ve(r,e,t){if(!e)return t;for(;r.bitcount<24;)r.tag|=r.source[r.sourceIndex++]<<r.bitcount,r.bitcount+=8;var n=r.tag&65535>>>16-e;return r.tag>>>=e,r.bitcount-=e,n+t}function cn(r,e){for(;r.bitcount<24;)r.tag|=r.source[r.sourceIndex++]<<r.bitcount,r.bitcount+=8;var t=0,n=0,s=0,i=r.tag;do n=2*n+(i&1),i>>>=1,++s,t+=e.table[s],n-=e.table[s];while(n>=0);return r.tag=i,r.bitcount-=s,e.trans[t+n]}function Ko(r,e,t){var n,s,i,o,a,u;for(n=Ve(r,5,257),s=Ve(r,5,1),i=Ve(r,4,4),o=0;o<19;++o)ze[o]=0;for(o=0;o<i;++o){var l=Ve(r,3,0);ze[_o[o]]=l}for(rn(vs,ze,0,19),a=0;a<n+s;){var f=cn(r,vs);switch(f){case 16:var c=ze[a-1];for(u=Ve(r,2,3);u;--u)ze[a++]=c;break;case 17:for(u=Ve(r,3,3);u;--u)ze[a++]=0;break;case 18:for(u=Ve(r,7,11);u;--u)ze[a++]=0;break;default:ze[a++]=f;break}}rn(e,ze,0,n),rn(t,ze,n,s)}function xs(r,e,t){for(;;){var n=cn(r,e);if(n===256)return Sn;if(n<256)r.dest[r.destLen++]=n;else{var s,i,o,a;for(n-=257,s=Ve(r,wn[n],kn[n]),i=cn(r,t),o=r.destLen-Ve(r,si[i],ii[i]),a=o;a<o+s;++a)r.dest[r.destLen++]=r.dest[a]}}}function Jo(r){for(var e,t,n;r.bitcount>8;)r.sourceIndex--,r.bitcount-=8;if(e=r.source[r.sourceIndex+1],e=256*e+r.source[r.sourceIndex],t=r.source[r.sourceIndex+3],t=256*t+r.source[r.sourceIndex+2],e!==(~t&65535))return ti;for(r.sourceIndex+=4,n=e;n;--n)r.dest[r.destLen++]=r.source[r.sourceIndex++];return r.bitcount=0,Sn}function Qo(r,e){var t=new Zo(r,e),n,s,i;do{switch(n=jo(t),s=Ve(t,2,0),s){case 0:i=Jo(t);break;case 1:i=xs(t,ri,ni);break;case 2:Ko(t,t.ltree,t.dtree),i=xs(t,t.ltree,t.dtree);break;default:i=ti}if(i!==Sn)throw new Error("Data error")}while(!n);return t.destLen<t.dest.length?typeof t.dest.slice=="function"?t.dest.slice(0,t.destLen):t.dest.subarray(0,t.destLen):t.dest}Yo(ri,ni);oi(wn,kn,4,3);oi(si,ii,2,1);wn[28]=0;kn[28]=258;var ea=Qo;function wt(r,e,t,n,s){return Math.pow(1-s,3)*r+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*t+Math.pow(s,3)*n}function it(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}it.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)};it.prototype.addPoint=function(r,e){typeof r=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=r,this.x2=r),r<this.x1&&(this.x1=r),r>this.x2&&(this.x2=r)),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))};it.prototype.addX=function(r){this.addPoint(r,null)};it.prototype.addY=function(r){this.addPoint(null,r)};it.prototype.addBezier=function(r,e,t,n,s,i,o,a){var u=[r,e],l=[t,n],f=[s,i],c=[o,a];this.addPoint(r,e),this.addPoint(o,a);for(var h=0;h<=1;h++){var p=6*u[h]-12*l[h]+6*f[h],g=-3*u[h]+9*l[h]-9*f[h]+3*c[h],m=3*l[h]-3*u[h];if(g===0){if(p===0)continue;var x=-m/p;0<x&&x<1&&(h===0&&this.addX(wt(u[h],l[h],f[h],c[h],x)),h===1&&this.addY(wt(u[h],l[h],f[h],c[h],x)));continue}var y=Math.pow(p,2)-4*m*g;if(!(y<0)){var S=(-p+Math.sqrt(y))/(2*g);0<S&&S<1&&(h===0&&this.addX(wt(u[h],l[h],f[h],c[h],S)),h===1&&this.addY(wt(u[h],l[h],f[h],c[h],S)));var w=(-p-Math.sqrt(y))/(2*g);0<w&&w<1&&(h===0&&this.addX(wt(u[h],l[h],f[h],c[h],w)),h===1&&this.addY(wt(u[h],l[h],f[h],c[h],w)))}}};it.prototype.addQuad=function(r,e,t,n,s,i){var o=r+.6666666666666666*(t-r),a=e+2/3*(n-e),u=o+1/3*(s-r),l=a+1/3*(i-e);this.addBezier(r,e,o,a,u,l,s,i)};function fe(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}fe.prototype.moveTo=function(r,e){this.commands.push({type:"M",x:r,y:e})};fe.prototype.lineTo=function(r,e){this.commands.push({type:"L",x:r,y:e})};fe.prototype.curveTo=fe.prototype.bezierCurveTo=function(r,e,t,n,s,i){this.commands.push({type:"C",x1:r,y1:e,x2:t,y2:n,x:s,y:i})};fe.prototype.quadTo=fe.prototype.quadraticCurveTo=function(r,e,t,n){this.commands.push({type:"Q",x1:r,y1:e,x:t,y:n})};fe.prototype.close=fe.prototype.closePath=function(){this.commands.push({type:"Z"})};fe.prototype.extend=function(r){if(r.commands)r=r.commands;else if(r instanceof it){var e=r;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,r)};fe.prototype.getBoundingBox=function(){for(var r=new it,e=0,t=0,n=0,s=0,i=0;i<this.commands.length;i++){var o=this.commands[i];switch(o.type){case"M":r.addPoint(o.x,o.y),e=n=o.x,t=s=o.y;break;case"L":r.addPoint(o.x,o.y),n=o.x,s=o.y;break;case"Q":r.addQuad(n,s,o.x1,o.y1,o.x,o.y),n=o.x,s=o.y;break;case"C":r.addBezier(n,s,o.x1,o.y1,o.x2,o.y2,o.x,o.y),n=o.x,s=o.y;break;case"Z":n=e,s=t;break;default:throw new Error("Unexpected path command "+o.type)}}return r.isEmpty()&&r.addPoint(0,0),r};fe.prototype.draw=function(r){r.beginPath();for(var e=0;e<this.commands.length;e+=1){var t=this.commands[e];t.type==="M"?r.moveTo(t.x,t.y):t.type==="L"?r.lineTo(t.x,t.y):t.type==="C"?r.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y):t.type==="Q"?r.quadraticCurveTo(t.x1,t.y1,t.x,t.y):t.type==="Z"&&r.closePath()}this.fill&&(r.fillStyle=this.fill,r.fill()),this.stroke&&(r.strokeStyle=this.stroke,r.lineWidth=this.strokeWidth,r.stroke())};fe.prototype.toPathData=function(r){r=r!==void 0?r:2;function e(o){return Math.round(o)===o?""+Math.round(o):o.toFixed(r)}function t(){for(var o=arguments,a="",u=0;u<arguments.length;u+=1){var l=o[u];l>=0&&u>0&&(a+=" "),a+=e(l)}return a}for(var n="",s=0;s<this.commands.length;s+=1){var i=this.commands[s];i.type==="M"?n+="M"+t(i.x,i.y):i.type==="L"?n+="L"+t(i.x,i.y):i.type==="C"?n+="C"+t(i.x1,i.y1,i.x2,i.y2,i.x,i.y):i.type==="Q"?n+="Q"+t(i.x1,i.y1,i.x,i.y):i.type==="Z"&&(n+="Z")}return n};fe.prototype.toSVG=function(r){var e='<path d="';return e+=this.toPathData(r),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};fe.prototype.toDOMElement=function(r){var e=this.toPathData(r),t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",e),t};function ai(r){throw new Error(r)}function ys(r,e){r||ai(e)}var N={fail:ai,argument:ys,assert:ys},bs=32768,Ss=2147483648,Et={},E={},B={};function Ue(r){return function(){return r}}E.BYTE=function(r){return N.argument(r>=0&&r<=255,"Byte value should be between 0 and 255."),[r]};B.BYTE=Ue(1);E.CHAR=function(r){return[r.charCodeAt(0)]};B.CHAR=Ue(1);E.CHARARRAY=function(r){typeof r>"u"&&(r="",console.warn("Undefined CHARARRAY encountered and treated as an empty string. This is probably caused by a missing glyph name."));for(var e=[],t=0;t<r.length;t+=1)e[t]=r.charCodeAt(t);return e};B.CHARARRAY=function(r){return typeof r>"u"?0:r.length};E.USHORT=function(r){return[r>>8&255,r&255]};B.USHORT=Ue(2);E.SHORT=function(r){return r>=bs&&(r=-(2*bs-r)),[r>>8&255,r&255]};B.SHORT=Ue(2);E.UINT24=function(r){return[r>>16&255,r>>8&255,r&255]};B.UINT24=Ue(3);E.ULONG=function(r){return[r>>24&255,r>>16&255,r>>8&255,r&255]};B.ULONG=Ue(4);E.LONG=function(r){return r>=Ss&&(r=-(2*Ss-r)),[r>>24&255,r>>16&255,r>>8&255,r&255]};B.LONG=Ue(4);E.FIXED=E.ULONG;B.FIXED=B.ULONG;E.FWORD=E.SHORT;B.FWORD=B.SHORT;E.UFWORD=E.USHORT;B.UFWORD=B.USHORT;E.LONGDATETIME=function(r){return[0,0,0,0,r>>24&255,r>>16&255,r>>8&255,r&255]};B.LONGDATETIME=Ue(8);E.TAG=function(r){return N.argument(r.length===4,"Tag should be exactly 4 ASCII characters."),[r.charCodeAt(0),r.charCodeAt(1),r.charCodeAt(2),r.charCodeAt(3)]};B.TAG=Ue(4);E.Card8=E.BYTE;B.Card8=B.BYTE;E.Card16=E.USHORT;B.Card16=B.USHORT;E.OffSize=E.BYTE;B.OffSize=B.BYTE;E.SID=E.USHORT;B.SID=B.USHORT;E.NUMBER=function(r){return r>=-107&&r<=107?[r+139]:r>=108&&r<=1131?(r=r-108,[(r>>8)+247,r&255]):r>=-1131&&r<=-108?(r=-r-108,[(r>>8)+251,r&255]):r>=-32768&&r<=32767?E.NUMBER16(r):E.NUMBER32(r)};B.NUMBER=function(r){return E.NUMBER(r).length};E.NUMBER16=function(r){return[28,r>>8&255,r&255]};B.NUMBER16=Ue(3);E.NUMBER32=function(r){return[29,r>>24&255,r>>16&255,r>>8&255,r&255]};B.NUMBER32=Ue(5);E.REAL=function(r){var e=r.toString(),t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){var n=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(r*n)/n).toString()}for(var s="",i=0,o=e.length;i<o;i+=1){var a=e[i];a==="e"?s+=e[++i]==="-"?"c":"b":a==="."?s+="a":a==="-"?s+="e":s+=a}s+=s.length&1?"f":"ff";for(var u=[30],l=0,f=s.length;l<f;l+=2)u.push(parseInt(s.substr(l,2),16));return u};B.REAL=function(r){return E.REAL(r).length};E.NAME=E.CHARARRAY;B.NAME=B.CHARARRAY;E.STRING=E.CHARARRAY;B.STRING=B.CHARARRAY;Et.UTF8=function(r,e,t){for(var n=[],s=t,i=0;i<s;i++,e+=1)n[i]=r.getUint8(e);return String.fromCharCode.apply(null,n)};Et.UTF16=function(r,e,t){for(var n=[],s=t/2,i=0;i<s;i++,e+=2)n[i]=r.getUint16(e);return String.fromCharCode.apply(null,n)};E.UTF16=function(r){for(var e=[],t=0;t<r.length;t+=1){var n=r.charCodeAt(t);e[e.length]=n>>8&255,e[e.length]=n&255}return e};B.UTF16=function(r){return r.length*2};var pn={"x-mac-croatian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\u0160\u2122\xB4\xA8\u2260\u017D\xD8\u221E\xB1\u2264\u2265\u2206\xB5\u2202\u2211\u220F\u0161\u222B\xAA\xBA\u03A9\u017E\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u0106\xAB\u010C\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u0110\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\uF8FF\xA9\u2044\u20AC\u2039\u203A\xC6\xBB\u2013\xB7\u201A\u201E\u2030\xC2\u0107\xC1\u010D\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u0111\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u03C0\xCB\u02DA\xB8\xCA\xE6\u02C7","x-mac-cyrillic":"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u2020\xB0\u0490\xA3\xA7\u2022\xB6\u0406\xAE\xA9\u2122\u0402\u0452\u2260\u0403\u0453\u221E\xB1\u2264\u2265\u0456\xB5\u0491\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040A\u045A\u0458\u0405\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\u040B\u045B\u040C\u045C\u0455\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u201E\u040E\u045E\u040F\u045F\u2116\u0401\u0451\u044F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E","x-mac-gaelic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u1E02\xB1\u2264\u2265\u1E03\u010A\u010B\u1E0A\u1E0B\u1E1E\u1E1F\u0120\u0121\u1E40\xE6\xF8\u1E41\u1E56\u1E57\u027C\u0192\u017F\u1E60\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u1E61\u1E9B\xFF\u0178\u1E6A\u20AC\u2039\u203A\u0176\u0177\u1E6B\xB7\u1EF2\u1EF3\u204A\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u2663\xD2\xDA\xDB\xD9\u0131\xDD\xFD\u0174\u0175\u1E84\u1E85\u1E80\u1E81\u1E82\u1E83","x-mac-greek":"\xC4\xB9\xB2\xC9\xB3\xD6\xDC\u0385\xE0\xE2\xE4\u0384\xA8\xE7\xE9\xE8\xEA\xEB\xA3\u2122\xEE\xEF\u2022\xBD\u2030\xF4\xF6\xA6\u20AC\xF9\xFB\xFC\u2020\u0393\u0394\u0398\u039B\u039E\u03A0\xDF\xAE\xA9\u03A3\u03AA\xA7\u2260\xB0\xB7\u0391\xB1\u2264\u2265\xA5\u0392\u0395\u0396\u0397\u0399\u039A\u039C\u03A6\u03AB\u03A8\u03A9\u03AC\u039D\xAC\u039F\u03A1\u2248\u03A4\xAB\xBB\u2026\xA0\u03A5\u03A7\u0386\u0388\u0153\u2013\u2015\u201C\u201D\u2018\u2019\xF7\u0389\u038A\u038C\u038E\u03AD\u03AE\u03AF\u03CC\u038F\u03CD\u03B1\u03B2\u03C8\u03B4\u03B5\u03C6\u03B3\u03B7\u03B9\u03BE\u03BA\u03BB\u03BC\u03BD\u03BF\u03C0\u03CE\u03C1\u03C3\u03C4\u03B8\u03C9\u03C2\u03C7\u03C5\u03B6\u03CA\u03CB\u0390\u03B0\xAD","x-mac-icelandic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\xDD\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\xD0\xF0\xDE\xFE\xFD\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-inuit":"\u1403\u1404\u1405\u1406\u140A\u140B\u1431\u1432\u1433\u1434\u1438\u1439\u1449\u144E\u144F\u1450\u1451\u1455\u1456\u1466\u146D\u146E\u146F\u1470\u1472\u1473\u1483\u148B\u148C\u148D\u148E\u1490\u1491\xB0\u14A1\u14A5\u14A6\u2022\xB6\u14A7\xAE\xA9\u2122\u14A8\u14AA\u14AB\u14BB\u14C2\u14C3\u14C4\u14C5\u14C7\u14C8\u14D0\u14EF\u14F0\u14F1\u14F2\u14F4\u14F5\u1505\u14D5\u14D6\u14D7\u14D8\u14DA\u14DB\u14EA\u1528\u1529\u152A\u152B\u152D\u2026\xA0\u152E\u153E\u1555\u1556\u1557\u2013\u2014\u201C\u201D\u2018\u2019\u1558\u1559\u155A\u155D\u1546\u1547\u1548\u1549\u154B\u154C\u1550\u157F\u1580\u1581\u1582\u1583\u1584\u1585\u158F\u1590\u1591\u1592\u1593\u1594\u1595\u1671\u1672\u1673\u1674\u1675\u1676\u1596\u15A0\u15A1\u15A2\u15A3\u15A4\u15A5\u15A6\u157C\u0141\u0142","x-mac-ce":"\xC4\u0100\u0101\xC9\u0104\xD6\xDC\xE1\u0105\u010C\xE4\u010D\u0106\u0107\xE9\u0179\u017A\u010E\xED\u010F\u0112\u0113\u0116\xF3\u0117\xF4\xF6\xF5\xFA\u011A\u011B\xFC\u2020\xB0\u0118\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\u0119\xA8\u2260\u0123\u012E\u012F\u012A\u2264\u2265\u012B\u0136\u2202\u2211\u0142\u013B\u013C\u013D\u013E\u0139\u013A\u0145\u0146\u0143\xAC\u221A\u0144\u0147\u2206\xAB\xBB\u2026\xA0\u0148\u0150\xD5\u0151\u014C\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\u014D\u0154\u0155\u0158\u2039\u203A\u0159\u0156\u0157\u0160\u201A\u201E\u0161\u015A\u015B\xC1\u0164\u0165\xCD\u017D\u017E\u016A\xD3\xD4\u016B\u016E\xDA\u016F\u0170\u0171\u0172\u0173\xDD\xFD\u0137\u017B\u0141\u017C\u0122\u02C7",macintosh:"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\uFB01\uFB02\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-romanian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\u0102\u0218\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\u0103\u0219\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\u021A\u021B\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-turkish":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u011E\u011F\u0130\u0131\u015E\u015F\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\uF8A0\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7"};Et.MACSTRING=function(r,e,t,n){var s=pn[n];if(s!==void 0){for(var i="",o=0;o<t;o++){var a=r.getUint8(e+o);a<=127?i+=String.fromCharCode(a):i+=s[a&127]}return i}};var Sr=typeof WeakMap=="function"&&new WeakMap,wr,ta=function(r){if(!wr){wr={};for(var e in pn)wr[e]=new String(e)}var t=wr[r];if(t!==void 0){if(Sr){var n=Sr.get(t);if(n!==void 0)return n}var s=pn[r];if(s!==void 0){for(var i={},o=0;o<s.length;o++)i[s.charCodeAt(o)]=o+128;return Sr&&Sr.set(t,i),i}}};E.MACSTRING=function(r,e){var t=ta(e);if(t!==void 0){for(var n=[],s=0;s<r.length;s++){var i=r.charCodeAt(s);if(i>=128&&(i=t[i],i===void 0))return;n[s]=i}return n}};B.MACSTRING=function(r,e){var t=E.MACSTRING(r,e);return t!==void 0?t.length:0};function dn(r){return r>=-128&&r<=127}function ra(r,e,t){for(var n=0,s=r.length;e<s&&n<64&&r[e]===0;)++e,++n;return t.push(128|n-1),e}function na(r,e,t){for(var n=0,s=r.length,i=e;i<s&&n<64;){var o=r[i];if(!dn(o)||o===0&&i+1<s&&r[i+1]===0)break;++i,++n}t.push(n-1);for(var a=e;a<i;++a)t.push(r[a]+256&255);return i}function sa(r,e,t){for(var n=0,s=r.length,i=e;i<s&&n<64;){var o=r[i];if(o===0||dn(o)&&i+1<s&&dn(r[i+1]))break;++i,++n}t.push(64|n-1);for(var a=e;a<i;++a){var u=r[a];t.push(u+65536>>8&255,u+256&255)}return i}E.VARDELTAS=function(r){for(var e=0,t=[];e<r.length;){var n=r[e];n===0?e=ra(r,e,t):n>=-128&&n<=127?e=na(r,e,t):e=sa(r,e,t)}return t};E.INDEX=function(r){for(var e=1,t=[e],n=[],s=0;s<r.length;s+=1){var i=E.OBJECT(r[s]);Array.prototype.push.apply(n,i),e+=i.length,t.push(e)}if(n.length===0)return[0,0];for(var o=[],a=1+Math.floor(Math.log(e)/Math.log(2))/8|0,u=[void 0,E.BYTE,E.USHORT,E.UINT24,E.ULONG][a],l=0;l<t.length;l+=1){var f=u(t[l]);Array.prototype.push.apply(o,f)}return Array.prototype.concat(E.Card16(r.length),E.OffSize(a),o,n)};B.INDEX=function(r){return E.INDEX(r).length};E.DICT=function(r){for(var e=[],t=Object.keys(r),n=t.length,s=0;s<n;s+=1){var i=parseInt(t[s],0),o=r[i];e=e.concat(E.OPERAND(o.value,o.type)),e=e.concat(E.OPERATOR(i))}return e};B.DICT=function(r){return E.DICT(r).length};E.OPERATOR=function(r){return r<1200?[r]:[12,r-1200]};E.OPERAND=function(r,e){var t=[];if(Array.isArray(e))for(var n=0;n<e.length;n+=1)N.argument(r.length===e.length,"Not enough arguments given for type"+e),t=t.concat(E.OPERAND(r[n],e[n]));else if(e==="SID")t=t.concat(E.NUMBER(r));else if(e==="offset")t=t.concat(E.NUMBER32(r));else if(e==="number")t=t.concat(E.NUMBER(r));else if(e==="real")t=t.concat(E.REAL(r));else throw new Error("Unknown operand type "+e);return t};E.OP=E.BYTE;B.OP=B.BYTE;var kr=typeof WeakMap=="function"&&new WeakMap;E.CHARSTRING=function(r){if(kr){var e=kr.get(r);if(e!==void 0)return e}for(var t=[],n=r.length,s=0;s<n;s+=1){var i=r[s];t=t.concat(E[i.type](i.value))}return kr&&kr.set(r,t),t};B.CHARSTRING=function(r){return E.CHARSTRING(r).length};E.OBJECT=function(r){var e=E[r.type];return N.argument(e!==void 0,"No encoding function for type "+r.type),e(r.value)};B.OBJECT=function(r){var e=B[r.type];return N.argument(e!==void 0,"No sizeOf function for type "+r.type),e(r.value)};E.TABLE=function(r){for(var e=[],t=r.fields.length,n=[],s=[],i=0;i<t;i+=1){var o=r.fields[i],a=E[o.type];N.argument(a!==void 0,"No encoding function for field type "+o.type+" ("+o.name+")");var u=r[o.name];u===void 0&&(u=o.value);var l=a(u);o.type==="TABLE"?(s.push(e.length),e=e.concat([0,0]),n.push(l)):e=e.concat(l)}for(var f=0;f<n.length;f+=1){var c=s[f],h=e.length;N.argument(h<65536,"Table "+r.tableName+" too big."),e[c]=h>>8,e[c+1]=h&255,e=e.concat(n[f])}return e};B.TABLE=function(r){for(var e=0,t=r.fields.length,n=0;n<t;n+=1){var s=r.fields[n],i=B[s.type];N.argument(i!==void 0,"No sizeOf function for field type "+s.type+" ("+s.name+")");var o=r[s.name];o===void 0&&(o=s.value),e+=i(o),s.type==="TABLE"&&(e+=2)}return e};E.RECORD=E.TABLE;B.RECORD=B.TABLE;E.LITERAL=function(r){return r};B.LITERAL=function(r){return r.length};function ge(r,e,t){if(e.length&&(e[0].name!=="coverageFormat"||e[0].value===1))for(var n=0;n<e.length;n+=1){var s=e[n];this[s.name]=s.value}if(this.tableName=r,this.fields=e,t)for(var i=Object.keys(t),o=0;o<i.length;o+=1){var a=i[o],u=t[a];this[a]!==void 0&&(this[a]=u)}}ge.prototype.encode=function(){return E.TABLE(this)};ge.prototype.sizeOf=function(){return B.TABLE(this)};function Xt(r,e,t){t===void 0&&(t=e.length);var n=new Array(e.length+1);n[0]={name:r+"Count",type:"USHORT",value:t};for(var s=0;s<e.length;s++)n[s+1]={name:r+s,type:"USHORT",value:e[s]};return n}function gn(r,e,t){var n=e.length,s=new Array(n+1);s[0]={name:r+"Count",type:"USHORT",value:n};for(var i=0;i<n;i++)s[i+1]={name:r+i,type:"TABLE",value:t(e[i],i)};return s}function qt(r,e,t){var n=e.length,s=[];s[0]={name:r+"Count",type:"USHORT",value:n};for(var i=0;i<n;i++)s=s.concat(t(e[i],i));return s}function Tr(r){r.format===1?ge.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(Xt("glyph",r.glyphs))):r.format===2?ge.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(qt("rangeRecord",r.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}]}))):N.assert(!1,"Coverage format must be 1 or 2.")}Tr.prototype=Object.create(ge.prototype);Tr.prototype.constructor=Tr;function Cr(r){ge.call(this,"scriptListTable",qt("scriptRecord",r,function(e,t){var n=e.script,s=n.defaultLangSys;return N.assert(!!s,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+t,type:"TAG",value:e.tag},{name:"script"+t,type:"TABLE",value:new ge("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new ge("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(Xt("featureIndex",s.featureIndexes)))}].concat(qt("langSys",n.langSysRecords,function(i,o){var a=i.langSys;return[{name:"langSysTag"+o,type:"TAG",value:i.tag},{name:"langSys"+o,type:"TABLE",value:new ge("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat(Xt("featureIndex",a.featureIndexes)))}]})))}]}))}Cr.prototype=Object.create(ge.prototype);Cr.prototype.constructor=Cr;function Mr(r){ge.call(this,"featureListTable",qt("featureRecord",r,function(e,t){var n=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new ge("featureTable",[{name:"featureParams",type:"USHORT",value:n.featureParams}].concat(Xt("lookupListIndex",n.lookupListIndexes)))}]}))}Mr.prototype=Object.create(ge.prototype);Mr.prototype.constructor=Mr;function Or(r,e){ge.call(this,"lookupListTable",gn("lookup",r,function(t){var n=e[t.lookupType];return N.assert(!!n,"Unable to write GSUB lookup type "+t.lookupType+" tables."),new ge("lookupTable",[{name:"lookupType",type:"USHORT",value:t.lookupType},{name:"lookupFlag",type:"USHORT",value:t.lookupFlag}].concat(gn("subtable",t.subtables,n)))}))}Or.prototype=Object.create(ge.prototype);Or.prototype.constructor=Or;var I={Table:ge,Record:ge,Coverage:Tr,ScriptList:Cr,FeatureList:Mr,LookupList:Or,ushortList:Xt,tableList:gn,recordList:qt};function ws(r,e){return r.getUint8(e)}function Fr(r,e){return r.getUint16(e,!1)}function ia(r,e){return r.getInt16(e,!1)}function En(r,e){return r.getUint32(e,!1)}function ui(r,e){var t=r.getInt16(e,!1),n=r.getUint16(e+2,!1);return t+n/65535}function oa(r,e){for(var t="",n=e;n<e+4;n+=1)t+=String.fromCharCode(r.getInt8(n));return t}function aa(r,e,t){for(var n=0,s=0;s<t;s+=1)n<<=8,n+=r.getUint8(e+s);return n}function ua(r,e,t){for(var n=[],s=e;s<t;s+=1)n.push(r.getUint8(s));return n}function la(r){for(var e="",t=0;t<r.length;t+=1)e+=String.fromCharCode(r[t]);return e}var fa={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function v(r,e){this.data=r,this.offset=e,this.relativeOffset=0}v.prototype.parseByte=function(){var r=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,r};v.prototype.parseChar=function(){var r=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,r};v.prototype.parseCard8=v.prototype.parseByte;v.prototype.parseUShort=function(){var r=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,r};v.prototype.parseCard16=v.prototype.parseUShort;v.prototype.parseSID=v.prototype.parseUShort;v.prototype.parseOffset16=v.prototype.parseUShort;v.prototype.parseShort=function(){var r=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,r};v.prototype.parseF2Dot14=function(){var r=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,r};v.prototype.parseULong=function(){var r=En(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,r};v.prototype.parseOffset32=v.prototype.parseULong;v.prototype.parseFixed=function(){var r=ui(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,r};v.prototype.parseString=function(r){var e=this.data,t=this.offset+this.relativeOffset,n="";this.relativeOffset+=r;for(var s=0;s<r;s++)n+=String.fromCharCode(e.getUint8(t+s));return n};v.prototype.parseTag=function(){return this.parseString(4)};v.prototype.parseLongDateTime=function(){var r=En(this.data,this.offset+this.relativeOffset+4);return r-=2082844800,this.relativeOffset+=8,r};v.prototype.parseVersion=function(r){var e=Fr(this.data,this.offset+this.relativeOffset),t=Fr(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,r===void 0&&(r=4096),e+t/r/10};v.prototype.skip=function(r,e){e===void 0&&(e=1),this.relativeOffset+=fa[r]*e};v.prototype.parseULongList=function(r){r===void 0&&(r=this.parseULong());for(var e=new Array(r),t=this.data,n=this.offset+this.relativeOffset,s=0;s<r;s++)e[s]=t.getUint32(n),n+=4;return this.relativeOffset+=r*4,e};v.prototype.parseOffset16List=v.prototype.parseUShortList=function(r){r===void 0&&(r=this.parseUShort());for(var e=new Array(r),t=this.data,n=this.offset+this.relativeOffset,s=0;s<r;s++)e[s]=t.getUint16(n),n+=2;return this.relativeOffset+=r*2,e};v.prototype.parseShortList=function(r){for(var e=new Array(r),t=this.data,n=this.offset+this.relativeOffset,s=0;s<r;s++)e[s]=t.getInt16(n),n+=2;return this.relativeOffset+=r*2,e};v.prototype.parseByteList=function(r){for(var e=new Array(r),t=this.data,n=this.offset+this.relativeOffset,s=0;s<r;s++)e[s]=t.getUint8(n++);return this.relativeOffset+=r,e};v.prototype.parseList=function(r,e){e||(e=r,r=this.parseUShort());for(var t=new Array(r),n=0;n<r;n++)t[n]=e.call(this);return t};v.prototype.parseList32=function(r,e){e||(e=r,r=this.parseULong());for(var t=new Array(r),n=0;n<r;n++)t[n]=e.call(this);return t};v.prototype.parseRecordList=function(r,e){e||(e=r,r=this.parseUShort());for(var t=new Array(r),n=Object.keys(e),s=0;s<r;s++){for(var i={},o=0;o<n.length;o++){var a=n[o],u=e[a];i[a]=u.call(this)}t[s]=i}return t};v.prototype.parseRecordList32=function(r,e){e||(e=r,r=this.parseULong());for(var t=new Array(r),n=Object.keys(e),s=0;s<r;s++){for(var i={},o=0;o<n.length;o++){var a=n[o],u=e[a];i[a]=u.call(this)}t[s]=i}return t};v.prototype.parseStruct=function(r){if(typeof r=="function")return r.call(this);for(var e=Object.keys(r),t={},n=0;n<e.length;n++){var s=e[n],i=r[s];t[s]=i.call(this)}return t};v.prototype.parseValueRecord=function(r){if(r===void 0&&(r=this.parseUShort()),r!==0){var e={};return r&1&&(e.xPlacement=this.parseShort()),r&2&&(e.yPlacement=this.parseShort()),r&4&&(e.xAdvance=this.parseShort()),r&8&&(e.yAdvance=this.parseShort()),r&16&&(e.xPlaDevice=void 0,this.parseShort()),r&32&&(e.yPlaDevice=void 0,this.parseShort()),r&64&&(e.xAdvDevice=void 0,this.parseShort()),r&128&&(e.yAdvDevice=void 0,this.parseShort()),e}};v.prototype.parseValueRecordList=function(){for(var r=this.parseUShort(),e=this.parseUShort(),t=new Array(e),n=0;n<e;n++)t[n]=this.parseValueRecord(r);return t};v.prototype.parsePointer=function(r){var e=this.parseOffset16();if(e>0)return new v(this.data,this.offset+e).parseStruct(r)};v.prototype.parsePointer32=function(r){var e=this.parseOffset32();if(e>0)return new v(this.data,this.offset+e).parseStruct(r)};v.prototype.parseListOfLists=function(r){for(var e=this.parseOffset16List(),t=e.length,n=this.relativeOffset,s=new Array(t),i=0;i<t;i++){var o=e[i];if(o===0){s[i]=void 0;continue}if(this.relativeOffset=o,r){for(var a=this.parseOffset16List(),u=new Array(a.length),l=0;l<a.length;l++)this.relativeOffset=o+a[l],u[l]=r.call(this);s[i]=u}else s[i]=this.parseUShortList()}return this.relativeOffset=n,s};v.prototype.parseCoverage=function(){var r=this.offset+this.relativeOffset,e=this.parseUShort(),t=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(t)};if(e===2){for(var n=new Array(t),s=0;s<t;s++)n[s]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:n}}throw new Error("0x"+r.toString(16)+": Coverage format must be 1 or 2.")};v.prototype.parseClassDef=function(){var r=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:v.uShort,end:v.uShort,classId:v.uShort})};throw new Error("0x"+r.toString(16)+": ClassDef format must be 1 or 2.")};v.list=function(r,e){return function(){return this.parseList(r,e)}};v.list32=function(r,e){return function(){return this.parseList32(r,e)}};v.recordList=function(r,e){return function(){return this.parseRecordList(r,e)}};v.recordList32=function(r,e){return function(){return this.parseRecordList32(r,e)}};v.pointer=function(r){return function(){return this.parsePointer(r)}};v.pointer32=function(r){return function(){return this.parsePointer32(r)}};v.tag=v.prototype.parseTag;v.byte=v.prototype.parseByte;v.uShort=v.offset16=v.prototype.parseUShort;v.uShortList=v.prototype.parseUShortList;v.uLong=v.offset32=v.prototype.parseULong;v.uLongList=v.prototype.parseULongList;v.struct=v.prototype.parseStruct;v.coverage=v.prototype.parseCoverage;v.classDef=v.prototype.parseClassDef;var ks={reserved:v.uShort,reqFeatureIndex:v.uShort,featureIndexes:v.uShortList};v.prototype.parseScriptList=function(){return this.parsePointer(v.recordList({tag:v.tag,script:v.pointer({defaultLangSys:v.pointer(ks),langSysRecords:v.recordList({tag:v.tag,langSys:v.pointer(ks)})})}))||[]};v.prototype.parseFeatureList=function(){return this.parsePointer(v.recordList({tag:v.tag,feature:v.pointer({featureParams:v.offset16,lookupListIndexes:v.uShortList})}))||[]};v.prototype.parseLookupList=function(r){return this.parsePointer(v.list(v.pointer(function(){var e=this.parseUShort();N.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");var t=this.parseUShort(),n=t&16;return{lookupType:e,lookupFlag:t,subtables:this.parseList(v.pointer(r[e])),markFilteringSet:n?this.parseUShort():void 0}})))||[]};v.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){var r=this.parseUShort(),e=this.parseUShort();N.argument(r===1&&e<1,"GPOS/GSUB feature variations table unknown.");var t=this.parseRecordList32({conditionSetOffset:v.offset32,featureTableSubstitutionOffset:v.offset32});return t})||[]};var C={getByte:ws,getCard8:ws,getUShort:Fr,getCard16:Fr,getShort:ia,getULong:En,getFixed:ui,getTag:oa,getOffset:aa,getBytes:ua,bytesToString:la,Parser:v};function ha(r,e){e.parseUShort(),r.length=e.parseULong(),r.language=e.parseULong();var t;r.groupCount=t=e.parseULong(),r.glyphIndexMap={};for(var n=0;n<t;n+=1)for(var s=e.parseULong(),i=e.parseULong(),o=e.parseULong(),a=s;a<=i;a+=1)r.glyphIndexMap[a]=o,o++}function ca(r,e,t,n,s){r.length=e.parseUShort(),r.language=e.parseUShort();var i;r.segCount=i=e.parseUShort()>>1,e.skip("uShort",3),r.glyphIndexMap={};for(var o=new C.Parser(t,n+s+14),a=new C.Parser(t,n+s+16+i*2),u=new C.Parser(t,n+s+16+i*4),l=new C.Parser(t,n+s+16+i*6),f=n+s+16+i*8,c=0;c<i-1;c+=1)for(var h=void 0,p=o.parseUShort(),g=a.parseUShort(),m=u.parseShort(),x=l.parseUShort(),y=g;y<=p;y+=1)x!==0?(f=l.offset+l.relativeOffset-2,f+=x,f+=(y-g)*2,h=C.getUShort(t,f),h!==0&&(h=h+m&65535)):h=y+m&65535,r.glyphIndexMap[y]=h}function pa(r,e){var t={};t.version=C.getUShort(r,e),N.argument(t.version===0,"cmap table version should be 0."),t.numTables=C.getUShort(r,e+2);for(var n=-1,s=t.numTables-1;s>=0;s-=1){var i=C.getUShort(r,e+4+s*8),o=C.getUShort(r,e+4+s*8+2);if(i===3&&(o===0||o===1||o===10)||i===0&&(o===0||o===1||o===2||o===3||o===4)){n=C.getULong(r,e+4+s*8+4);break}}if(n===-1)throw new Error("No valid cmap sub-tables found.");var a=new C.Parser(r,e+n);if(t.format=a.parseUShort(),t.format===12)ha(t,a);else if(t.format===4)ca(t,a,r,e,n);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+t.format+").");return t}function da(r,e,t){r.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function ga(r){r.segments.push({end:65535,start:65535,delta:1,offset:0})}function va(r){var e=!0,t;for(t=r.length-1;t>0;t-=1){var n=r.get(t);if(n.unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}}var s=[{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||(s=s.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),s=s.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 i=new I.Table("cmap",s);for(i.segments=[],t=0;t<r.length;t+=1){for(var o=r.get(t),a=0;a<o.unicodes.length;a+=1)da(i,o.unicodes[a],t);i.segments=i.segments.sort(function(S,w){return S.start-w.start})}ga(i);var u=i.segments.length,l=0,f=[],c=[],h=[],p=[],g=[],m=[];for(t=0;t<u;t+=1){var x=i.segments[t];x.end<=65535&&x.start<=65535?(f=f.concat({name:"end_"+t,type:"USHORT",value:x.end}),c=c.concat({name:"start_"+t,type:"USHORT",value:x.start}),h=h.concat({name:"idDelta_"+t,type:"SHORT",value:x.delta}),p=p.concat({name:"idRangeOffset_"+t,type:"USHORT",value:x.offset}),x.glyphId!==void 0&&(g=g.concat({name:"glyph_"+t,type:"USHORT",value:x.glyphId}))):l+=1,!e&&x.glyphIndex!==void 0&&(m=m.concat({name:"cmap12Start_"+t,type:"ULONG",value:x.start}),m=m.concat({name:"cmap12End_"+t,type:"ULONG",value:x.end}),m=m.concat({name:"cmap12Glyph_"+t,type:"ULONG",value:x.glyphIndex}))}if(i.segCountX2=(u-l)*2,i.searchRange=Math.pow(2,Math.floor(Math.log(u-l)/Math.log(2)))*2,i.entrySelector=Math.log(i.searchRange/2)/Math.log(2),i.rangeShift=i.segCountX2-i.searchRange,i.fields=i.fields.concat(f),i.fields.push({name:"reservedPad",type:"USHORT",value:0}),i.fields=i.fields.concat(c),i.fields=i.fields.concat(h),i.fields=i.fields.concat(p),i.fields=i.fields.concat(g),i.cmap4Length=14+f.length*2+2+c.length*2+h.length*2+p.length*2+g.length*2,!e){var y=16+m.length*4;i.cmap12Offset=20+i.cmap4Length,i.fields=i.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}]),i.fields=i.fields.concat(m)}return i}var li={parse:pa,make:va},Lr=[".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"],ma=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],xa=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],pt=[".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 fi(r){this.font=r}fi.prototype.charToGlyphIndex=function(r){var e=r.codePointAt(0),t=this.font.glyphs;if(t){for(var n=0;n<t.length;n+=1)for(var s=t.get(n),i=0;i<s.unicodes.length;i+=1)if(s.unicodes[i]===e)return n}return null};function hi(r){this.cmap=r}hi.prototype.charToGlyphIndex=function(r){return this.cmap.glyphIndexMap[r.codePointAt(0)]||0};function Ar(r,e){this.encoding=r,this.charset=e}Ar.prototype.charToGlyphIndex=function(r){var e=r.codePointAt(0),t=this.encoding[e];return this.charset.indexOf(t)};function Pn(r){switch(r.version){case 1:this.names=pt.slice();break;case 2:this.names=new Array(r.numberOfGlyphs);for(var e=0;e<r.numberOfGlyphs;e++)r.glyphNameIndex[e]<pt.length?this.names[e]=pt[r.glyphNameIndex[e]]:this.names[e]=r.names[r.glyphNameIndex[e]-pt.length];break;case 2.5:this.names=new Array(r.numberOfGlyphs);for(var t=0;t<r.numberOfGlyphs;t++)this.names[t]=pt[t+r.glyphNameIndex[t]];break;case 3:this.names=[];break;default:this.names=[];break}}Pn.prototype.nameToGlyphIndex=function(r){return this.names.indexOf(r)};Pn.prototype.glyphIndexToName=function(r){return this.names[r]};function ya(r){for(var e,t=r.tables.cmap.glyphIndexMap,n=Object.keys(t),s=0;s<n.length;s+=1){var i=n[s],o=t[i];e=r.glyphs.get(o),e.addUnicode(parseInt(i))}for(var a=0;a<r.glyphs.length;a+=1)e=r.glyphs.get(a),r.cffEncoding?r.isCIDFont?e.name="gid"+a:e.name=r.cffEncoding.charset[a]:r.glyphNames.names&&(e.name=r.glyphNames.glyphIndexToName(a))}function ba(r){r._IndexToUnicodeMap={};for(var e=r.tables.cmap.glyphIndexMap,t=Object.keys(e),n=0;n<t.length;n+=1){var s=t[n],i=e[s];r._IndexToUnicodeMap[i]===void 0?r._IndexToUnicodeMap[i]={unicodes:[parseInt(s)]}:r._IndexToUnicodeMap[i].unicodes.push(parseInt(s))}}function Sa(r,e){e.lowMemory?ba(r):ya(r)}function wa(r,e,t,n,s){r.beginPath(),r.moveTo(e,t),r.lineTo(n,s),r.stroke()}var ct={line:wa};function ka(r,e){var t=e||new fe;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(n){t=n}}}function Ce(r){this.bindConstructorValues(r)}Ce.prototype.bindConstructorValues=function(r){this.index=r.index||0,this.name=r.name||null,this.unicode=r.unicode||void 0,this.unicodes=r.unicodes||r.unicode!==void 0?[r.unicode]:[],"xMin"in r&&(this.xMin=r.xMin),"yMin"in r&&(this.yMin=r.yMin),"xMax"in r&&(this.xMax=r.xMax),"yMax"in r&&(this.yMax=r.yMax),"advanceWidth"in r&&(this.advanceWidth=r.advanceWidth),Object.defineProperty(this,"path",ka(this,r.path))};Ce.prototype.addUnicode=function(r){this.unicodes.length===0&&(this.unicode=r),this.unicodes.push(r)};Ce.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};Ce.prototype.getPath=function(r,e,t,n,s){r=r!==void 0?r:0,e=e!==void 0?e:0,t=t!==void 0?t:72;var i,o;n||(n={});var a=n.xScale,u=n.yScale;if(n.hinting&&s&&s.hinting&&(o=this.path&&s.hinting.exec(this,t)),o)i=s.hinting.getCommands(o),r=Math.round(r),e=Math.round(e),a=u=1;else{i=this.path.commands;var l=1/(this.path.unitsPerEm||1e3)*t;a===void 0&&(a=l),u===void 0&&(u=l)}for(var f=new fe,c=0;c<i.length;c+=1){var h=i[c];h.type==="M"?f.moveTo(r+h.x*a,e+-h.y*u):h.type==="L"?f.lineTo(r+h.x*a,e+-h.y*u):h.type==="Q"?f.quadraticCurveTo(r+h.x1*a,e+-h.y1*u,r+h.x*a,e+-h.y*u):h.type==="C"?f.curveTo(r+h.x1*a,e+-h.y1*u,r+h.x2*a,e+-h.y2*u,r+h.x*a,e+-h.y*u):h.type==="Z"&&f.closePath()}return f};Ce.prototype.getContours=function(){if(this.points===void 0)return[];for(var r=[],e=[],t=0;t<this.points.length;t+=1){var n=this.points[t];e.push(n),n.lastPointOfContour&&(r.push(e),e=[])}return N.argument(e.length===0,"There are still points left in the current contour."),r};Ce.prototype.getMetrics=function(){for(var r=this.path.commands,e=[],t=[],n=0;n<r.length;n+=1){var s=r[n];s.type!=="Z"&&(e.push(s.x),t.push(s.y)),(s.type==="Q"||s.type==="C")&&(e.push(s.x1),t.push(s.y1)),s.type==="C"&&(e.push(s.x2),t.push(s.y2))}var i={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,e),yMax:Math.max.apply(null,t),leftSideBearing:this.leftSideBearing};return isFinite(i.xMin)||(i.xMin=0),isFinite(i.xMax)||(i.xMax=this.advanceWidth),isFinite(i.yMin)||(i.yMin=0),isFinite(i.yMax)||(i.yMax=0),i.rightSideBearing=this.advanceWidth-i.leftSideBearing-(i.xMax-i.xMin),i};Ce.prototype.draw=function(r,e,t,n,s){this.getPath(e,t,n,s).draw(r)};Ce.prototype.drawPoints=function(r,e,t,n){function s(c,h,p,g){r.beginPath();for(var m=0;m<c.length;m+=1)r.moveTo(h+c[m].x*g,p+c[m].y*g),r.arc(h+c[m].x*g,p+c[m].y*g,2,0,Math.PI*2,!1);r.closePath(),r.fill()}e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:24;for(var i=1/this.path.unitsPerEm*n,o=[],a=[],u=this.path,l=0;l<u.commands.length;l+=1){var f=u.commands[l];f.x!==void 0&&o.push({x:f.x,y:-f.y}),f.x1!==void 0&&a.push({x:f.x1,y:-f.y1}),f.x2!==void 0&&a.push({x:f.x2,y:-f.y2})}r.fillStyle="blue",s(o,e,t,i),r.fillStyle="red",s(a,e,t,i)};Ce.prototype.drawMetrics=function(r,e,t,n){var s;e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:24,s=1/this.path.unitsPerEm*n,r.lineWidth=1,r.strokeStyle="black",ct.line(r,e,-1e4,e,1e4),ct.line(r,-1e4,t,1e4,t);var i=this.xMin||0,o=this.yMin||0,a=this.xMax||0,u=this.yMax||0,l=this.advanceWidth||0;r.strokeStyle="blue",ct.line(r,e+i*s,-1e4,e+i*s,1e4),ct.line(r,e+a*s,-1e4,e+a*s,1e4),ct.line(r,-1e4,t+-o*s,1e4,t+-o*s),ct.line(r,-1e4,t+-u*s,1e4,t+-u*s),r.strokeStyle="green",ct.line(r,e+l*s,-1e4,e+l*s,1e4)};function Er(r,e,t){Object.defineProperty(r,e,{get:function(){return r.path,r[t]},set:function(n){r[t]=n},enumerable:!0,configurable:!0})}function Ln(r,e){if(this.font=r,this.glyphs={},Array.isArray(e))for(var t=0;t<e.length;t++){var n=e[t];n.path.unitsPerEm=r.unitsPerEm,this.glyphs[t]=n}this.length=e&&e.length||0}Ln.prototype.get=function(r){if(this.glyphs[r]===void 0){this.font._push(r),typeof this.glyphs[r]=="function"&&(this.glyphs[r]=this.glyphs[r]());var e=this.glyphs[r],t=this.font._IndexToUnicodeMap[r];if(t)for(var n=0;n<t.unicodes.length;n++)e.addUnicode(t.unicodes[n]);this.font.cffEncoding?this.font.isCIDFont?e.name="gid"+r:e.name=this.font.cffEncoding.charset[r]:this.font.glyphNames.names&&(e.name=this.font.glyphNames.glyphIndexToName(r)),this.glyphs[r].advanceWidth=this.font._hmtxTableData[r].advanceWidth,this.glyphs[r].leftSideBearing=this.font._hmtxTableData[r].leftSideBearing}else typeof this.glyphs[r]=="function"&&(this.glyphs[r]=this.glyphs[r]());return this.glyphs[r]};Ln.prototype.push=function(r,e){this.glyphs[r]=e,this.length++};function Ea(r,e){return new Ce({index:e,font:r})}function Pa(r,e,t,n,s,i){return function(){var o=new Ce({index:e,font:r});return o.path=function(){t(o,n,s);var a=i(r.glyphs,o);return a.unitsPerEm=r.unitsPerEm,a},Er(o,"xMin","_xMin"),Er(o,"xMax","_xMax"),Er(o,"yMin","_yMin"),Er(o,"yMax","_yMax"),o}}function La(r,e,t,n){return function(){var s=new Ce({index:e,font:r});return s.path=function(){var i=t(r,s,n);return i.unitsPerEm=r.unitsPerEm,i},s}}var qe={GlyphSet:Ln,glyphLoader:Ea,ttfGlyphLoader:Pa,cffGlyphLoader:La};function ci(r,e){if(r===e)return!0;if(Array.isArray(r)&&Array.isArray(e)){if(r.length!==e.length)return!1;for(var t=0;t<r.length;t+=1)if(!ci(r[t],e[t]))return!1;return!0}else return!1}function vn(r){var e;return r.length<1240?e=107:r.length<33900?e=1131:e=32768,e}function tt(r,e,t){var n=[],s=[],i=C.getCard16(r,e),o,a;if(i!==0){var u=C.getByte(r,e+2);o=e+(i+1)*u+2;for(var l=e+3,f=0;f<i+1;f+=1)n.push(C.getOffset(r,l,u)),l+=u;a=o+n[i]}else a=e+2;for(var c=0;c<n.length-1;c+=1){var h=C.getBytes(r,o+n[c],o+n[c+1]);t&&(h=t(h)),s.push(h)}return{objects:s,startOffset:e,endOffset:a}}function Ia(r,e){var t=[],n=C.getCard16(r,e),s,i;if(n!==0){var o=C.getByte(r,e+2);s=e+(n+1)*o+2;for(var a=e+3,u=0;u<n+1;u+=1)t.push(C.getOffset(r,a,o)),a+=o;i=s+t[n]}else i=e+2;return{offsets:t,startOffset:e,endOffset:i}}function Ta(r,e,t,n,s){var i=C.getCard16(t,n),o=0;if(i!==0){var a=C.getByte(t,n+2);o=n+(i+1)*a+2}var u=C.getBytes(t,o+e[r],o+e[r+1]);return s&&(u=s(u)),u}function Ca(r){for(var e="",t=15,n=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];;){var s=r.parseByte(),i=s>>4,o=s&15;if(i===t||(e+=n[i],o===t))break;e+=n[o]}return parseFloat(e)}function Ma(r,e){var t,n,s,i;if(e===28)return t=r.parseByte(),n=r.parseByte(),t<<8|n;if(e===29)return t=r.parseByte(),n=r.parseByte(),s=r.parseByte(),i=r.parseByte(),t<<24|n<<16|s<<8|i;if(e===30)return Ca(r);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=r.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=r.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function Oa(r){for(var e={},t=0;t<r.length;t+=1){var n=r[t][0],s=r[t][1],i=void 0;if(s.length===1?i=s[0]:i=s,e.hasOwnProperty(n)&&!isNaN(e[n]))throw new Error("Object "+e+" already has key "+n);e[n]=i}return e}function pi(r,e,t){e=e!==void 0?e:0;var n=new C.Parser(r,e),s=[],i=[];for(t=t!==void 0?t:r.length;n.relativeOffset<t;){var o=n.parseByte();o<=21?(o===12&&(o=1200+n.parseByte()),s.push([o,i]),i=[]):i.push(Ma(n,o))}return Oa(s)}function zt(r,e){return e<=390?e=Lr[e]:e=r[e-391],e}function di(r,e,t){for(var n={},s,i=0;i<e.length;i+=1){var o=e[i];if(Array.isArray(o.type)){var a=[];a.length=o.type.length;for(var u=0;u<o.type.length;u++)s=r[o.op]!==void 0?r[o.op][u]:void 0,s===void 0&&(s=o.value!==void 0&&o.value[u]!==void 0?o.value[u]:null),o.type[u]==="SID"&&(s=zt(t,s)),a[u]=s;n[o.name]=a}else s=r[o.op],s===void 0&&(s=o.value!==void 0?o.value:null),o.type==="SID"&&(s=zt(t,s)),n[o.name]=s}return n}function Fa(r,e){var t={};return t.formatMajor=C.getCard8(r,e),t.formatMinor=C.getCard8(r,e+1),t.size=C.getCard8(r,e+2),t.offsetSize=C.getCard8(r,e+3),t.startOffset=e,t.endOffset=e+4,t}var gi=[{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"}],vi=[{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 Aa(r,e){var t=pi(r,0,r.byteLength);return di(t,gi,e)}function mi(r,e,t,n){var s=pi(r,e,t);return di(s,vi,n)}function Es(r,e,t,n){for(var s=[],i=0;i<t.length;i+=1){var o=new DataView(new Uint8Array(t[i]).buffer),a=Aa(o,n);a._subrs=[],a._subrsBias=0,a._defaultWidthX=0,a._nominalWidthX=0;var u=a.private[0],l=a.private[1];if(u!==0&&l!==0){var f=mi(r,l+e,u,n);if(a._defaultWidthX=f.defaultWidthX,a._nominalWidthX=f.nominalWidthX,f.subrs!==0){var c=l+f.subrs,h=tt(r,c+e);a._subrs=h.objects,a._subrsBias=vn(a._subrs)}a._privateDict=f}s.push(a)}return s}function Da(r,e,t,n){var s,i,o=new C.Parser(r,e);t-=1;var a=[".notdef"],u=o.parseCard8();if(u===0)for(var l=0;l<t;l+=1)s=o.parseSID(),a.push(zt(n,s));else if(u===1)for(;a.length<=t;){s=o.parseSID(),i=o.parseCard8();for(var f=0;f<=i;f+=1)a.push(zt(n,s)),s+=1}else if(u===2)for(;a.length<=t;){s=o.parseSID(),i=o.parseCard16();for(var c=0;c<=i;c+=1)a.push(zt(n,s)),s+=1}else throw new Error("Unknown charset format "+u);return a}function Ua(r,e,t){var n,s={},i=new C.Parser(r,e),o=i.parseCard8();if(o===0)for(var a=i.parseCard8(),u=0;u<a;u+=1)n=i.parseCard8(),s[n]=u;else if(o===1){var l=i.parseCard8();n=1;for(var f=0;f<l;f+=1)for(var c=i.parseCard8(),h=i.parseCard8(),p=c;p<=c+h;p+=1)s[p]=n,n+=1}else throw new Error("Unknown encoding format "+o);return new Ar(s,t)}function Ps(r,e,t){var n,s,i,o,a=new fe,u=[],l=0,f=!1,c=!1,h=0,p=0,g,m,x,y;if(r.isCIDFont){var S=r.tables.cff.topDict._fdSelect[e.index],w=r.tables.cff.topDict._fdArray[S];g=w._subrs,m=w._subrsBias,x=w._defaultWidthX,y=w._nominalWidthX}else g=r.tables.cff.topDict._subrs,m=r.tables.cff.topDict._subrsBias,x=r.tables.cff.topDict._defaultWidthX,y=r.tables.cff.topDict._nominalWidthX;var F=x;function P(L,W){c&&a.closePath(),a.moveTo(L,W),c=!0}function U(){var L;L=u.length%2!==0,L&&!f&&(F=u.shift()+y),l+=u.length>>1,u.length=0,f=!0}function O(L){for(var W,_,Y,he,ce,Q,X,ee,k,M,A,G,D=0;D<L.length;){var H=L[D];switch(D+=1,H){case 1:U();break;case 3:U();break;case 4:u.length>1&&!f&&(F=u.shift()+y,f=!0),p+=u.pop(),P(h,p);break;case 5:for(;u.length>0;)h+=u.shift(),p+=u.shift(),a.lineTo(h,p);break;case 6:for(;u.length>0&&(h+=u.shift(),a.lineTo(h,p),u.length!==0);)p+=u.shift(),a.lineTo(h,p);break;case 7:for(;u.length>0&&(p+=u.shift(),a.lineTo(h,p),u.length!==0);)h+=u.shift(),a.lineTo(h,p);break;case 8:for(;u.length>0;)n=h+u.shift(),s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),h=i+u.shift(),p=o+u.shift(),a.curveTo(n,s,i,o,h,p);break;case 10:ce=u.pop()+m,Q=g[ce],Q&&O(Q);break;case 11:return;case 12:switch(H=L[D],D+=1,H){case 35:n=h+u.shift(),s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),X=i+u.shift(),ee=o+u.shift(),k=X+u.shift(),M=ee+u.shift(),A=k+u.shift(),G=M+u.shift(),h=A+u.shift(),p=G+u.shift(),u.shift(),a.curveTo(n,s,i,o,X,ee),a.curveTo(k,M,A,G,h,p);break;case 34:n=h+u.shift(),s=p,i=n+u.shift(),o=s+u.shift(),X=i+u.shift(),ee=o,k=X+u.shift(),M=o,A=k+u.shift(),G=p,h=A+u.shift(),a.curveTo(n,s,i,o,X,ee),a.curveTo(k,M,A,G,h,p);break;case 36:n=h+u.shift(),s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),X=i+u.shift(),ee=o,k=X+u.shift(),M=o,A=k+u.shift(),G=M+u.shift(),h=A+u.shift(),a.curveTo(n,s,i,o,X,ee),a.curveTo(k,M,A,G,h,p);break;case 37:n=h+u.shift(),s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),X=i+u.shift(),ee=o+u.shift(),k=X+u.shift(),M=ee+u.shift(),A=k+u.shift(),G=M+u.shift(),Math.abs(A-h)>Math.abs(G-p)?h=A+u.shift():p=G+u.shift(),a.curveTo(n,s,i,o,X,ee),a.curveTo(k,M,A,G,h,p);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+H),u.length=0}break;case 14:u.length>0&&!f&&(F=u.shift()+y,f=!0),c&&(a.closePath(),c=!1);break;case 18:U();break;case 19:case 20:U(),D+=l+7>>3;break;case 21:u.length>2&&!f&&(F=u.shift()+y,f=!0),p+=u.pop(),h+=u.pop(),P(h,p);break;case 22:u.length>1&&!f&&(F=u.shift()+y,f=!0),h+=u.pop(),P(h,p);break;case 23:U();break;case 24:for(;u.length>2;)n=h+u.shift(),s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),h=i+u.shift(),p=o+u.shift(),a.curveTo(n,s,i,o,h,p);h+=u.shift(),p+=u.shift(),a.lineTo(h,p);break;case 25:for(;u.length>6;)h+=u.shift(),p+=u.shift(),a.lineTo(h,p);n=h+u.shift(),s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),h=i+u.shift(),p=o+u.shift(),a.curveTo(n,s,i,o,h,p);break;case 26:for(u.length%2&&(h+=u.shift());u.length>0;)n=h,s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),h=i,p=o+u.shift(),a.curveTo(n,s,i,o,h,p);break;case 27:for(u.length%2&&(p+=u.shift());u.length>0;)n=h+u.shift(),s=p,i=n+u.shift(),o=s+u.shift(),h=i+u.shift(),p=o,a.curveTo(n,s,i,o,h,p);break;case 28:W=L[D],_=L[D+1],u.push((W<<24|_<<16)>>16),D+=2;break;case 29:ce=u.pop()+r.gsubrsBias,Q=r.gsubrs[ce],Q&&O(Q);break;case 30:for(;u.length>0&&(n=h,s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),h=i+u.shift(),p=o+(u.length===1?u.shift():0),a.curveTo(n,s,i,o,h,p),u.length!==0);)n=h+u.shift(),s=p,i=n+u.shift(),o=s+u.shift(),p=o+u.shift(),h=i+(u.length===1?u.shift():0),a.curveTo(n,s,i,o,h,p);break;case 31:for(;u.length>0&&(n=h+u.shift(),s=p,i=n+u.shift(),o=s+u.shift(),p=o+u.shift(),h=i+(u.length===1?u.shift():0),a.curveTo(n,s,i,o,h,p),u.length!==0);)n=h,s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),h=i+u.shift(),p=o+(u.length===1?u.shift():0),a.curveTo(n,s,i,o,h,p);break;default:H<32?console.log("Glyph "+e.index+": unknown operator "+H):H<247?u.push(H-139):H<251?(W=L[D],D+=1,u.push((H-247)*256+W+108)):H<255?(W=L[D],D+=1,u.push(-(H-251)*256-W-108)):(W=L[D],_=L[D+1],Y=L[D+2],he=L[D+3],D+=4,u.push((W<<24|_<<16|Y<<8|he)/65536))}}}return O(t),e.advanceWidth=F,a}function Ra(r,e,t,n){var s=[],i,o=new C.Parser(r,e),a=o.parseCard8();if(a===0)for(var u=0;u<t;u++){if(i=o.parseCard8(),i>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+n+")");s.push(i)}else if(a===3){var l=o.parseCard16(),f=o.parseCard16();if(f!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+f);for(var c,h=0;h<l;h++){if(i=o.parseCard8(),c=o.parseCard16(),i>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+n+")");if(c>t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+c);for(;f<c;f++)s.push(i);f=c}if(c!==t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+c)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+a);return s}function Na(r,e,t,n){t.tables.cff={};var s=Fa(r,e),i=tt(r,s.endOffset,C.bytesToString),o=tt(r,i.endOffset),a=tt(r,o.endOffset,C.bytesToString),u=tt(r,a.endOffset);t.gsubrs=u.objects,t.gsubrsBias=vn(t.gsubrs);var l=Es(r,e,o.objects,a.objects);if(l.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+l.length);var f=l[0];if(t.tables.cff.topDict=f,f._privateDict&&(t.defaultWidthX=f._privateDict.defaultWidthX,t.nominalWidthX=f._privateDict.nominalWidthX),f.ros[0]!==void 0&&f.ros[1]!==void 0&&(t.isCIDFont=!0),t.isCIDFont){var c=f.fdArray,h=f.fdSelect;if(c===0||h===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");c+=e;var p=tt(r,c),g=Es(r,e,p.objects,a.objects);f._fdArray=g,h+=e,f._fdSelect=Ra(r,h,t.numGlyphs,g.length)}var m=e+f.private[1],x=mi(r,m,f.private[0],a.objects);if(t.defaultWidthX=x.defaultWidthX,t.nominalWidthX=x.nominalWidthX,x.subrs!==0){var y=m+x.subrs,S=tt(r,y);t.subrs=S.objects,t.subrsBias=vn(t.subrs)}else t.subrs=[],t.subrsBias=0;var w;n.lowMemory?(w=Ia(r,e+f.charStrings),t.nGlyphs=w.offsets.length):(w=tt(r,e+f.charStrings),t.nGlyphs=w.objects.length);var F=Da(r,e+f.charset,t.nGlyphs,a.objects);if(f.encoding===0?t.cffEncoding=new Ar(ma,F):f.encoding===1?t.cffEncoding=new Ar(xa,F):t.cffEncoding=Ua(r,e+f.encoding,F),t.encoding=t.encoding||t.cffEncoding,t.glyphs=new qe.GlyphSet(t),n.lowMemory)t._push=function(O){var L=Ta(O,w.offsets,r,e+f.charStrings);t.glyphs.push(O,qe.cffGlyphLoader(t,O,Ps,L))};else for(var P=0;P<t.nGlyphs;P+=1){var U=w.objects[P];t.glyphs.push(P,qe.cffGlyphLoader(t,P,Ps,U))}}function xi(r,e){var t,n=Lr.indexOf(r);return n>=0&&(t=n),n=e.indexOf(r),n>=0?t=n+Lr.length:(t=Lr.length+e.length,e.push(r)),t}function Ba(){return new I.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 Ga(r){var e=new I.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(var t=0;t<r.length;t+=1)e.names.push({name:"name_"+t,type:"NAME",value:r[t]});return e}function yi(r,e,t){for(var n={},s=0;s<r.length;s+=1){var i=r[s],o=e[i.name];o!==void 0&&!ci(o,i.value)&&(i.type==="SID"&&(o=xi(o,t)),n[i.op]={name:i.name,type:i.type,value:o})}return n}function Ls(r,e){var t=new I.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=yi(gi,r,e),t}function Is(r){var e=new I.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:r}],e}function Ha(r){var e=new I.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(var t=0;t<r.length;t+=1)e.strings.push({name:"string_"+t,type:"STRING",value:r[t]});return e}function za(){return new I.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Va(r,e){for(var t=new I.Record("Charsets",[{name:"format",type:"Card8",value:0}]),n=0;n<r.length;n+=1){var s=r[n],i=xi(s,e);t.fields.push({name:"glyph_"+n,type:"SID",value:i})}return t}function Xa(r){var e=[],t=r.path;e.push({name:"width",type:"NUMBER",value:r.advanceWidth});for(var n=0,s=0,i=0;i<t.commands.length;i+=1){var o=void 0,a=void 0,u=t.commands[i];if(u.type==="Q"){var l=.3333333333333333,f=2/3;u={type:"C",x:u.x,y:u.y,x1:Math.round(l*n+f*u.x1),y1:Math.round(l*s+f*u.y1),x2:Math.round(l*u.x+f*u.x1),y2:Math.round(l*u.y+f*u.y1)}}if(u.type==="M")o=Math.round(u.x-n),a=Math.round(u.y-s),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rmoveto",type:"OP",value:21}),n=Math.round(u.x),s=Math.round(u.y);else if(u.type==="L")o=Math.round(u.x-n),a=Math.round(u.y-s),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rlineto",type:"OP",value:5}),n=Math.round(u.x),s=Math.round(u.y);else if(u.type==="C"){var c=Math.round(u.x1-n),h=Math.round(u.y1-s),p=Math.round(u.x2-u.x1),g=Math.round(u.y2-u.y1);o=Math.round(u.x-u.x2),a=Math.round(u.y-u.y2),e.push({name:"dx1",type:"NUMBER",value:c}),e.push({name:"dy1",type:"NUMBER",value:h}),e.push({name:"dx2",type:"NUMBER",value:p}),e.push({name:"dy2",type:"NUMBER",value:g}),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rrcurveto",type:"OP",value:8}),n=Math.round(u.x),s=Math.round(u.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function qa(r){for(var e=new I.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),t=0;t<r.length;t+=1){var n=r.get(t),s=Xa(n);e.charStrings.push({name:n.name,type:"CHARSTRING",value:s})}return e}function Wa(r,e){var t=new I.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=yi(vi,r,e),t}function $a(r,e){for(var t=new I.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,s={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]},i={},o=[],a,u=1;u<r.length;u+=1)a=r.get(u),o.push(a.name);var l=[];t.header=Ba(),t.nameIndex=Ga([e.postScriptName]);var f=Ls(s,l);t.topDictIndex=Is(f),t.globalSubrIndex=za(),t.charsets=Va(o,l),t.charStringsIndex=qa(r),t.privateDict=Wa(i,l),t.stringIndex=Ha(l);var c=t.header.sizeOf()+t.nameIndex.sizeOf()+t.topDictIndex.sizeOf()+t.stringIndex.sizeOf()+t.globalSubrIndex.sizeOf();return s.charset=c,s.encoding=0,s.charStrings=s.charset+t.charsets.sizeOf(),s.private[1]=s.charStrings+t.charStringsIndex.sizeOf(),f=Ls(s,l),t.topDictIndex=Is(f),t}var bi={parse:Na,make:$a};function Za(r,e){var t={},n=new C.Parser(r,e);return t.version=n.parseVersion(),t.fontRevision=Math.round(n.parseFixed()*1e3)/1e3,t.checkSumAdjustment=n.parseULong(),t.magicNumber=n.parseULong(),N.argument(t.magicNumber===1594834165,"Font header has wrong magic number."),t.flags=n.parseUShort(),t.unitsPerEm=n.parseUShort(),t.created=n.parseLongDateTime(),t.modified=n.parseLongDateTime(),t.xMin=n.parseShort(),t.yMin=n.parseShort(),t.xMax=n.parseShort(),t.yMax=n.parseShort(),t.macStyle=n.parseUShort(),t.lowestRecPPEM=n.parseUShort(),t.fontDirectionHint=n.parseShort(),t.indexToLocFormat=n.parseShort(),t.glyphDataFormat=n.parseShort(),t}function _a(r){var e=Math.round(new Date().getTime()/1e3)+2082844800,t=e;return r.createdTimestamp&&(t=r.createdTimestamp+2082844800),new I.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:t},{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}],r)}var Si={parse:Za,make:_a};function Ya(r,e){var t={},n=new C.Parser(r,e);return t.version=n.parseVersion(),t.ascender=n.parseShort(),t.descender=n.parseShort(),t.lineGap=n.parseShort(),t.advanceWidthMax=n.parseUShort(),t.minLeftSideBearing=n.parseShort(),t.minRightSideBearing=n.parseShort(),t.xMaxExtent=n.parseShort(),t.caretSlopeRise=n.parseShort(),t.caretSlopeRun=n.parseShort(),t.caretOffset=n.parseShort(),n.relativeOffset+=8,t.metricDataFormat=n.parseShort(),t.numberOfHMetrics=n.parseUShort(),t}function ja(r){return new I.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}],r)}var wi={parse:Ya,make:ja};function Ka(r,e,t,n,s){for(var i,o,a=new C.Parser(r,e),u=0;u<n;u+=1){u<t&&(i=a.parseUShort(),o=a.parseShort());var l=s.get(u);l.advanceWidth=i,l.leftSideBearing=o}}function Ja(r,e,t,n,s){r._hmtxTableData={};for(var i,o,a=new C.Parser(e,t),u=0;u<s;u+=1)u<n&&(i=a.parseUShort(),o=a.parseShort()),r._hmtxTableData[u]={advanceWidth:i,leftSideBearing:o}}function Qa(r,e,t,n,s,i,o){o.lowMemory?Ja(r,e,t,n,s):Ka(e,t,n,s,i)}function eu(r){for(var e=new I.Table("hmtx",[]),t=0;t<r.length;t+=1){var n=r.get(t),s=n.advanceWidth||0,i=n.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+t,type:"USHORT",value:s}),e.fields.push({name:"leftSideBearing_"+t,type:"SHORT",value:i})}return e}var ki={parse:Qa,make:eu};function tu(r){for(var e=new I.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:r.length}]),t="",n=12+r.length*4,s=0;s<r.length;++s){var i=t.indexOf(r[s]);i<0&&(i=t.length,t+=r[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:n+i}),e.fields.push({name:"length "+s,type:"USHORT",value:r[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),e}function ru(r,e){var t=new C.Parser(r,e),n=t.parseULong();N.argument(n===1,"Unsupported ltag table version."),t.skip("uLong",1);for(var s=t.parseULong(),i=[],o=0;o<s;o++){for(var a="",u=e+t.parseUShort(),l=t.parseUShort(),f=u;f<u+l;++f)a+=String.fromCharCode(r.getInt8(f));i.push(a)}return i}var Ei={make:tu,parse:ru};function nu(r,e){var t={},n=new C.Parser(r,e);return t.version=n.parseVersion(),t.numGlyphs=n.parseUShort(),t.version===1&&(t.maxPoints=n.parseUShort(),t.maxContours=n.parseUShort(),t.maxCompositePoints=n.parseUShort(),t.maxCompositeContours=n.parseUShort(),t.maxZones=n.parseUShort(),t.maxTwilightPoints=n.parseUShort(),t.maxStorage=n.parseUShort(),t.maxFunctionDefs=n.parseUShort(),t.maxInstructionDefs=n.parseUShort(),t.maxStackElements=n.parseUShort(),t.maxSizeOfInstructions=n.parseUShort(),t.maxComponentElements=n.parseUShort(),t.maxComponentDepth=n.parseUShort()),t}function su(r){return new I.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:r}])}var Pi={parse:nu,make:su},Li=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Ii={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"},iu={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},Ti={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 ou(r,e,t){switch(r){case 0:if(e===65535)return"und";if(t)return t[e];break;case 1:return Ii[e];case 3:return Ti[e]}}var mn="utf-16",au={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"},uu={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 Ci(r,e,t){switch(r){case 0:return mn;case 1:return uu[t]||au[e];case 3:if(e===1||e===10)return mn;break}}function lu(r,e,t){for(var n={},s=new C.Parser(r,e),i=s.parseUShort(),o=s.parseUShort(),a=s.offset+s.parseUShort(),u=0;u<o;u++){var l=s.parseUShort(),f=s.parseUShort(),c=s.parseUShort(),h=s.parseUShort(),p=Li[h]||h,g=s.parseUShort(),m=s.parseUShort(),x=ou(l,c,t),y=Ci(l,f,c);if(y!==void 0&&x!==void 0){var S=void 0;if(y===mn?S=Et.UTF16(r,a+m,g):S=Et.MACSTRING(r,a+m,g,y),S){var w=n[p];w===void 0&&(w=n[p]={}),w[x]=S}}}var F=0;return i===1&&(F=s.parseUShort()),n}function nn(r){var e={};for(var t in r)e[r[t]]=parseInt(t);return e}function Ts(r,e,t,n,s,i){return new I.Record("NameRecord",[{name:"platformID",type:"USHORT",value:r},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:t},{name:"nameID",type:"USHORT",value:n},{name:"length",type:"USHORT",value:s},{name:"offset",type:"USHORT",value:i}])}function fu(r,e){var t=r.length,n=e.length-t+1;e:for(var s=0;s<n;s++)for(;s<n;s++){for(var i=0;i<t;i++)if(e[s+i]!==r[i])continue e;return s}return-1}function Cs(r,e){var t=fu(r,e);if(t<0){t=e.length;for(var n=0,s=r.length;n<s;++n)e.push(r[n])}return t}function hu(r,e){var t,n=[],s={},i=nn(Li);for(var o in r){var a=i[o];if(a===void 0&&(a=o),t=parseInt(a),isNaN(t))throw new Error('Name table entry "'+o+'" does not exist, see nameTableNames for complete list.');s[t]=r[o],n.push(t)}for(var u=nn(Ii),l=nn(Ti),f=[],c=[],h=0;h<n.length;h++){t=n[h];var p=s[t];for(var g in p){var m=p[g],x=1,y=u[g],S=iu[y],w=Ci(x,S,y),F=E.MACSTRING(m,w);F===void 0&&(x=0,y=e.indexOf(g),y<0&&(y=e.length,e.push(g)),S=4,F=E.UTF16(m));var P=Cs(F,c);f.push(Ts(x,S,y,t,F.length,P));var U=l[g];if(U!==void 0){var O=E.UTF16(m),L=Cs(O,c);f.push(Ts(3,1,U,t,O.length,L))}}}f.sort(function(Y,he){return Y.platformID-he.platformID||Y.encodingID-he.encodingID||Y.languageID-he.languageID||Y.nameID-he.nameID});for(var W=new I.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:f.length},{name:"stringOffset",type:"USHORT",value:6+f.length*12}]),_=0;_<f.length;_++)W.fields.push({name:"record_"+_,type:"RECORD",value:f[_]});return W.fields.push({name:"strings",type:"LITERAL",value:c}),W}var Mi={parse:lu,make:hu},xn=[{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 cu(r){for(var e=0;e<xn.length;e+=1){var t=xn[e];if(r>=t.begin&&r<t.end)return e}return-1}function pu(r,e){var t={},n=new C.Parser(r,e);t.version=n.parseUShort(),t.xAvgCharWidth=n.parseShort(),t.usWeightClass=n.parseUShort(),t.usWidthClass=n.parseUShort(),t.fsType=n.parseUShort(),t.ySubscriptXSize=n.parseShort(),t.ySubscriptYSize=n.parseShort(),t.ySubscriptXOffset=n.parseShort(),t.ySubscriptYOffset=n.parseShort(),t.ySuperscriptXSize=n.parseShort(),t.ySuperscriptYSize=n.parseShort(),t.ySuperscriptXOffset=n.parseShort(),t.ySuperscriptYOffset=n.parseShort(),t.yStrikeoutSize=n.parseShort(),t.yStrikeoutPosition=n.parseShort(),t.sFamilyClass=n.parseShort(),t.panose=[];for(var s=0;s<10;s++)t.panose[s]=n.parseByte();return t.ulUnicodeRange1=n.parseULong(),t.ulUnicodeRange2=n.parseULong(),t.ulUnicodeRange3=n.parseULong(),t.ulUnicodeRange4=n.parseULong(),t.achVendID=String.fromCharCode(n.parseByte(),n.parseByte(),n.parseByte(),n.parseByte()),t.fsSelection=n.parseUShort(),t.usFirstCharIndex=n.parseUShort(),t.usLastCharIndex=n.parseUShort(),t.sTypoAscender=n.parseShort(),t.sTypoDescender=n.parseShort(),t.sTypoLineGap=n.parseShort(),t.usWinAscent=n.parseUShort(),t.usWinDescent=n.parseUShort(),t.version>=1&&(t.ulCodePageRange1=n.parseULong(),t.ulCodePageRange2=n.parseULong()),t.version>=2&&(t.sxHeight=n.parseShort(),t.sCapHeight=n.parseShort(),t.usDefaultChar=n.parseUShort(),t.usBreakChar=n.parseUShort(),t.usMaxContent=n.parseUShort()),t}function du(r){return new I.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}],r)}var yn={parse:pu,make:du,unicodeRanges:xn,getUnicodeRange:cu};function gu(r,e){var t={},n=new C.Parser(r,e);switch(t.version=n.parseVersion(),t.italicAngle=n.parseFixed(),t.underlinePosition=n.parseShort(),t.underlineThickness=n.parseShort(),t.isFixedPitch=n.parseULong(),t.minMemType42=n.parseULong(),t.maxMemType42=n.parseULong(),t.minMemType1=n.parseULong(),t.maxMemType1=n.parseULong(),t.version){case 1:t.names=pt.slice();break;case 2:t.numberOfGlyphs=n.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(var s=0;s<t.numberOfGlyphs;s++)t.glyphNameIndex[s]=n.parseUShort();t.names=[];for(var i=0;i<t.numberOfGlyphs;i++)if(t.glyphNameIndex[i]>=pt.length){var o=n.parseChar();t.names.push(n.parseString(o))}break;case 2.5:t.numberOfGlyphs=n.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(var a=0;a<t.numberOfGlyphs;a++)t.offset[a]=n.parseChar();break}return t}function vu(){return new I.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 Oi={parse:gu,make:vu},Fe=new Array(9);Fe[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(v.coverage),deltaGlyphId:this.parseUShort()};if(t===2)return{substFormat:2,coverage:this.parsePointer(v.coverage),substitute:this.parseOffset16List()};N.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")};Fe[2]=function(){var e=this.parseUShort();return N.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(v.coverage),sequences:this.parseListOfLists()}};Fe[3]=function(){var e=this.parseUShort();return N.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(v.coverage),alternateSets:this.parseListOfLists()}};Fe[4]=function(){var e=this.parseUShort();return N.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(v.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var kt={sequenceIndex:v.uShort,lookupListIndex:v.uShort};Fe[5]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:t,coverage:this.parsePointer(v.coverage),ruleSets:this.parseListOfLists(function(){var i=this.parseUShort(),o=this.parseUShort();return{input:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(o,kt)}})};if(t===2)return{substFormat:t,coverage:this.parsePointer(v.coverage),classDef:this.parsePointer(v.classDef),classSets:this.parseListOfLists(function(){var i=this.parseUShort(),o=this.parseUShort();return{classes:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(o,kt)}})};if(t===3){var n=this.parseUShort(),s=this.parseUShort();return{substFormat:t,coverages:this.parseList(n,v.pointer(v.coverage)),lookupRecords:this.parseRecordList(s,kt)}}N.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")};Fe[6]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(v.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(kt)}})};if(t===2)return{substFormat:2,coverage:this.parsePointer(v.coverage),backtrackClassDef:this.parsePointer(v.classDef),inputClassDef:this.parsePointer(v.classDef),lookaheadClassDef:this.parsePointer(v.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(kt)}})};if(t===3)return{substFormat:3,backtrackCoverage:this.parseList(v.pointer(v.coverage)),inputCoverage:this.parseList(v.pointer(v.coverage)),lookaheadCoverage:this.parseList(v.pointer(v.coverage)),lookupRecords:this.parseRecordList(kt)};N.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")};Fe[7]=function(){var e=this.parseUShort();N.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");var t=this.parseUShort(),n=new v(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:Fe[t].call(n)}};Fe[8]=function(){var e=this.parseUShort();return N.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(v.coverage),backtrackCoverage:this.parseList(v.pointer(v.coverage)),lookaheadCoverage:this.parseList(v.pointer(v.coverage)),substitutes:this.parseUShortList()}};function mu(r,e){e=e||0;var t=new v(r,e),n=t.parseVersion(1);return N.argument(n===1||n===1.1,"Unsupported GSUB table version."),n===1?{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Fe)}:{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Fe),variations:t.parseFeatureVariationsList()}}var Pt=new Array(9);Pt[1]=function(e){return e.substFormat===1?new I.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new I.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new I.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new I.Coverage(e.coverage)}].concat(I.ushortList("substitute",e.substitute)))};Pt[2]=function(e){return N.assert(e.substFormat===1,"Lookup type 2 substFormat must be 1."),new I.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new I.Coverage(e.coverage)}].concat(I.tableList("seqSet",e.sequences,function(t){return new I.Table("sequenceSetTable",I.ushortList("sequence",t))})))};Pt[3]=function(e){return N.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new I.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new I.Coverage(e.coverage)}].concat(I.tableList("altSet",e.alternateSets,function(t){return new I.Table("alternateSetTable",I.ushortList("alternate",t))})))};Pt[4]=function(e){return N.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new I.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new I.Coverage(e.coverage)}].concat(I.tableList("ligSet",e.ligatureSets,function(t){return new I.Table("ligatureSetTable",I.tableList("ligature",t,function(n){return new I.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:n.ligGlyph}].concat(I.ushortList("component",n.components,n.components.length+1)))}))})))};Pt[6]=function(e){if(e.substFormat===1){var t=new I.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new I.Coverage(e.coverage)}].concat(I.tableList("chainRuleSet",e.chainRuleSets,function(i){return new I.Table("chainRuleSetTable",I.tableList("chainRule",i,function(o){var a=I.ushortList("backtrackGlyph",o.backtrack,o.backtrack.length).concat(I.ushortList("inputGlyph",o.input,o.input.length+1)).concat(I.ushortList("lookaheadGlyph",o.lookahead,o.lookahead.length)).concat(I.ushortList("substitution",[],o.lookupRecords.length));return o.lookupRecords.forEach(function(u,l){a=a.concat({name:"sequenceIndex"+l,type:"USHORT",value:u.sequenceIndex}).concat({name:"lookupListIndex"+l,type:"USHORT",value:u.lookupListIndex})}),new I.Table("chainRuleTable",a)}))})));return t}else if(e.substFormat===2)N.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(i,o){n.push({name:"backtrackCoverage"+o,type:"TABLE",value:new I.Coverage(i)})}),n.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length}),e.inputCoverage.forEach(function(i,o){n.push({name:"inputCoverage"+o,type:"TABLE",value:new I.Coverage(i)})}),n.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length}),e.lookaheadCoverage.forEach(function(i,o){n.push({name:"lookaheadCoverage"+o,type:"TABLE",value:new I.Coverage(i)})}),n.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length}),e.lookupRecords.forEach(function(i,o){n=n.concat({name:"sequenceIndex"+o,type:"USHORT",value:i.sequenceIndex}).concat({name:"lookupListIndex"+o,type:"USHORT",value:i.lookupListIndex})});var s=new I.Table("chainContextTable",n);return s}N.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function xu(r){return new I.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new I.ScriptList(r.scripts)},{name:"features",type:"TABLE",value:new I.FeatureList(r.features)},{name:"lookups",type:"TABLE",value:new I.LookupList(r.lookups,Pt)}])}var Fi={parse:mu,make:xu};function yu(r,e){var t=new C.Parser(r,e),n=t.parseULong();N.argument(n===1,"Unsupported META table version."),t.parseULong(),t.parseULong();for(var s=t.parseULong(),i={},o=0;o<s;o++){var a=t.parseTag(),u=t.parseULong(),l=t.parseULong(),f=Et.UTF8(r,e+u,l);i[a]=f}return i}function bu(r){var e=Object.keys(r).length,t="",n=16+e*12,s=new I.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 i in r){var o=t.length;t+=r[i],s.fields.push({name:"tag "+i,type:"TAG",value:i}),s.fields.push({name:"offset "+i,type:"ULONG",value:n+o}),s.fields.push({name:"length "+i,type:"ULONG",value:r[i].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),s}var Ai={parse:yu,make:bu};function Ms(r){return Math.log(r)/Math.log(2)|0}function In(r){for(;r.length%4!==0;)r.push(0);for(var e=0,t=0;t<r.length;t+=4)e+=(r[t]<<24)+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];return e%=Math.pow(2,32),e}function Os(r,e,t,n){return new I.Record("Table Record",[{name:"tag",type:"TAG",value:r!==void 0?r:""},{name:"checkSum",type:"ULONG",value:e!==void 0?e:0},{name:"offset",type:"ULONG",value:t!==void 0?t:0},{name:"length",type:"ULONG",value:n!==void 0?n:0}])}function Di(r){var e=new I.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=r,e.numTables=r.length;var t=Math.pow(2,Ms(e.numTables));e.searchRange=16*t,e.entrySelector=Ms(t),e.rangeShift=e.numTables*16-e.searchRange;for(var n=[],s=[],i=e.sizeOf()+Os().sizeOf()*e.numTables;i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0});for(var o=0;o<r.length;o+=1){var a=r[o];N.argument(a.tableName.length===4,"Table name"+a.tableName+" is invalid.");var u=a.sizeOf(),l=Os(a.tableName,In(a.encode()),i,u);for(n.push({name:l.tag+" Table Record",type:"RECORD",value:l}),s.push({name:a.tableName+" table",type:"RECORD",value:a}),i+=u,N.argument(!isNaN(i),"Something went wrong calculating the offset.");i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0})}return n.sort(function(f,c){return f.value.tag>c.value.tag?1:-1}),e.fields=e.fields.concat(n),e.fields=e.fields.concat(s),e}function Fs(r,e,t){for(var n=0;n<e.length;n+=1){var s=r.charToGlyphIndex(e[n]);if(s>0){var i=r.glyphs.get(s);return i.getMetrics()}}return t}function Su(r){for(var e=0,t=0;t<r.length;t+=1)e+=r[t];return e/r.length}function wu(r){for(var e=[],t=[],n=[],s=[],i=[],o=[],a=[],u,l=0,f=0,c=0,h=0,p=0,g=0;g<r.glyphs.length;g+=1){var m=r.glyphs.get(g),x=m.unicode|0;if(isNaN(m.advanceWidth))throw new Error("Glyph "+m.name+" ("+g+"): advanceWidth is not a number.");(u>x||u===void 0)&&x>0&&(u=x),l<x&&(l=x);var y=yn.getUnicodeRange(x);if(y<32)f|=1<<y;else if(y<64)c|=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),t.push(S.yMin),n.push(S.xMax),s.push(S.yMax),o.push(S.leftSideBearing),a.push(S.rightSideBearing),i.push(m.advanceWidth)}}var w={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,n),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,i),advanceWidthAvg:Su(i),minLeftSideBearing:Math.min.apply(null,o),maxLeftSideBearing:Math.max.apply(null,o),minRightSideBearing:Math.min.apply(null,a)};w.ascender=r.ascender,w.descender=r.descender;var F=Si.make({flags:3,unitsPerEm:r.unitsPerEm,xMin:w.xMin,yMin:w.yMin,xMax:w.xMax,yMax:w.yMax,lowestRecPPEM:3,createdTimestamp:r.createdTimestamp}),P=wi.make({ascender:w.ascender,descender:w.descender,advanceWidthMax:w.advanceWidthMax,minLeftSideBearing:w.minLeftSideBearing,minRightSideBearing:w.minRightSideBearing,xMaxExtent:w.maxLeftSideBearing+(w.xMax-w.xMin),numberOfHMetrics:r.glyphs.length}),U=Pi.make(r.glyphs.length),O=yn.make(Object.assign({xAvgCharWidth:Math.round(w.advanceWidthAvg),usFirstCharIndex:u,usLastCharIndex:l,ulUnicodeRange1:f,ulUnicodeRange2:c,ulUnicodeRange3:h,ulUnicodeRange4:p,sTypoAscender:w.ascender,sTypoDescender:w.descender,sTypoLineGap:0,usWinAscent:w.yMax,usWinDescent:Math.abs(w.yMin),ulCodePageRange1:1,sxHeight:Fs(r,"xyvw",{yMax:Math.round(w.ascender/2)}).yMax,sCapHeight:Fs(r,"HIKLEFJMNTZBDPRAGOQSUVWXY",w).yMax,usDefaultChar:r.hasChar(" ")?32:0,usBreakChar:r.hasChar(" ")?32:0},r.tables.os2)),L=ki.make(r.glyphs),W=li.make(r.glyphs),_=r.getEnglishName("fontFamily"),Y=r.getEnglishName("fontSubfamily"),he=_+" "+Y,ce=r.getEnglishName("postScriptName");ce||(ce=_.replace(/\s/g,"")+"-"+Y);var Q={};for(var X in r.names)Q[X]=r.names[X];Q.uniqueID||(Q.uniqueID={en:r.getEnglishName("manufacturer")+":"+he}),Q.postScriptName||(Q.postScriptName={en:ce}),Q.preferredFamily||(Q.preferredFamily=r.names.fontFamily),Q.preferredSubfamily||(Q.preferredSubfamily=r.names.fontSubfamily);var ee=[],k=Mi.make(Q,ee),M=ee.length>0?Ei.make(ee):void 0,A=Oi.make(),G=bi.make(r.glyphs,{version:r.getEnglishName("version"),fullName:he,familyName:_,weightName:Y,postScriptName:ce,unitsPerEm:r.unitsPerEm,fontBBox:[0,w.yMin,w.ascender,w.advanceWidthMax]}),D=r.metas&&Object.keys(r.metas).length>0?Ai.make(r.metas):void 0,H=[F,P,U,O,k,W,A,G,L];M&&H.push(M),r.tables.gsub&&H.push(Fi.make(r.tables.gsub)),D&&H.push(D);for(var se=Di(H),be=se.encode(),te=In(be),le=se.fields,ue=!1,pe=0;pe<le.length;pe+=1)if(le[pe].name==="head table"){le[pe].value.checkSumAdjustment=2981146554-te,ue=!0;break}if(!ue)throw new Error("Could not find head table with checkSum to adjust.");return se}var ku={make:Di,fontToTable:wu,computeCheckSum:In};function sn(r,e){for(var t=0,n=r.length-1;t<=n;){var s=t+n>>>1,i=r[s].tag;if(i===e)return s;i<e?t=s+1:n=s-1}return-t-1}function As(r,e){for(var t=0,n=r.length-1;t<=n;){var s=t+n>>>1,i=r[s];if(i===e)return s;i<e?t=s+1:n=s-1}return-t-1}function Ds(r,e){for(var t,n=0,s=r.length-1;n<=s;){var i=n+s>>>1;t=r[i];var o=t.start;if(o===e)return t;o<e?n=i+1:s=i-1}if(n>0)return t=r[n-1],e>t.end?0:t}function $t(r,e){this.font=r,this.tableName=e}$t.prototype={searchTag:sn,binSearch:As,getTable:function(r){var e=this.font.tables[this.tableName];return!e&&r&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){var r=this.getTable();return r?r.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){var r=this.getTable();if(r){for(var e=!1,t=0;t<r.scripts.length;t++){var n=r.scripts[t].tag;if(n==="DFLT")return n;n==="latn"&&(e=!0)}if(e)return"latn"}},getScriptTable:function(r,e){var t=this.getTable(e);if(t){r=r||"DFLT";var n=t.scripts,s=sn(t.scripts,r);if(s>=0)return n[s].script;if(e){var i={tag:r,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return n.splice(-1-s,0,i),i.script}}},getLangSysTable:function(r,e,t){var n=this.getScriptTable(r,t);if(n){if(!e||e==="dflt"||e==="DFLT")return n.defaultLangSys;var s=sn(n.langSysRecords,e);if(s>=0)return n.langSysRecords[s].langSys;if(t){var i={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return n.langSysRecords.splice(-1-s,0,i),i.langSys}}},getFeatureTable:function(r,e,t,n){var s=this.getLangSysTable(r,e,n);if(s){for(var i,o=s.featureIndexes,a=this.font.tables[this.tableName].features,u=0;u<o.length;u++)if(i=a[o[u]],i.tag===t)return i.feature;if(n){var l=a.length;return N.assert(l===0||t>=a[l-1].tag,"Features must be added in alphabetical order."),i={tag:t,feature:{params:0,lookupListIndexes:[]}},a.push(i),o.push(l),i.feature}}},getLookupTables:function(r,e,t,n,s){var i=this.getFeatureTable(r,e,t,s),o=[];if(i){for(var a,u=i.lookupListIndexes,l=this.font.tables[this.tableName].lookups,f=0;f<u.length;f++)a=l[u[f]],a.lookupType===n&&o.push(a);if(o.length===0&&s){a={lookupType:n,lookupFlag:0,subtables:[],markFilteringSet:void 0};var c=l.length;return l.push(a),u.push(c),[a]}}return o},getGlyphClass:function(r,e){switch(r.format){case 1:return r.startGlyph<=e&&e<r.startGlyph+r.classes.length?r.classes[e-r.startGlyph]:0;case 2:var t=Ds(r.ranges,e);return t?t.classId:0}},getCoverageIndex:function(r,e){switch(r.format){case 1:var t=As(r.glyphs,e);return t>=0?t:-1;case 2:var n=Ds(r.ranges,e);return n?n.index+e-n.start:-1}},expandCoverage:function(r){if(r.format===1)return r.glyphs;for(var e=[],t=r.ranges,n=0;n<t.length;n++)for(var s=t[n],i=s.start,o=s.end,a=i;a<=o;a++)e.push(a);return e}};function Zt(r){$t.call(this,r,"gpos")}Zt.prototype=$t.prototype;Zt.prototype.init=function(){var r=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(r)};Zt.prototype.getKerningValue=function(r,e,t){for(var n=0;n<r.length;n++)for(var s=r[n].subtables,i=0;i<s.length;i++){var o=s[i],a=this.getCoverageIndex(o.coverage,e);if(!(a<0))switch(o.posFormat){case 1:for(var u=o.pairSets[a],l=0;l<u.length;l++){var f=u[l];if(f.secondGlyph===t)return f.value1&&f.value1.xAdvance||0}break;case 2:var c=this.getGlyphClass(o.classDef1,e),h=this.getGlyphClass(o.classDef2,t),p=o.classRecords[c][h];return p.value1&&p.value1.xAdvance||0}}return 0};Zt.prototype.getKerningTables=function(r,e){if(this.font.tables.gpos)return this.getLookupTables(r,e,"kern",2)};function ke(r){$t.call(this,r,"gsub")}function Eu(r,e){var t=r.length;if(t!==e.length)return!1;for(var n=0;n<t;n++)if(r[n]!==e[n])return!1;return!0}function Tn(r,e,t){for(var n=r.subtables,s=0;s<n.length;s++){var i=n[s];if(i.substFormat===e)return i}if(t)return n.push(t),t}ke.prototype=$t.prototype;ke.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}};ke.prototype.getSingle=function(r,e,t){for(var n=[],s=this.getLookupTables(e,t,r,1),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++){var u=o[a],l=this.expandCoverage(u.coverage),f=void 0;if(u.substFormat===1){var c=u.deltaGlyphId;for(f=0;f<l.length;f++){var h=l[f];n.push({sub:h,by:h+c})}}else{var p=u.substitute;for(f=0;f<l.length;f++)n.push({sub:l[f],by:p[f]})}}return n};ke.prototype.getMultiple=function(r,e,t){for(var n=[],s=this.getLookupTables(e,t,r,2),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++){var u=o[a],l=this.expandCoverage(u.coverage),f=void 0;for(f=0;f<l.length;f++){var c=l[f],h=u.sequences[f];n.push({sub:c,by:h})}}return n};ke.prototype.getAlternates=function(r,e,t){for(var n=[],s=this.getLookupTables(e,t,r,3),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++)for(var u=o[a],l=this.expandCoverage(u.coverage),f=u.alternateSets,c=0;c<l.length;c++)n.push({sub:l[c],by:f[c]});return n};ke.prototype.getLigatures=function(r,e,t){for(var n=[],s=this.getLookupTables(e,t,r,4),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++)for(var u=o[a],l=this.expandCoverage(u.coverage),f=u.ligatureSets,c=0;c<l.length;c++)for(var h=l[c],p=f[c],g=0;g<p.length;g++){var m=p[g];n.push({sub:[h].concat(m.components),by:m.ligGlyph})}return n};ke.prototype.addSingle=function(r,e,t,n){var s=this.getLookupTables(t,n,r,1,!0)[0],i=Tn(s,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});N.assert(i.coverage.format===1,"Single: unable to modify coverage table format "+i.coverage.format);var o=e.sub,a=this.binSearch(i.coverage.glyphs,o);a<0&&(a=-1-a,i.coverage.glyphs.splice(a,0,o),i.substitute.splice(a,0,0)),i.substitute[a]=e.by};ke.prototype.addMultiple=function(r,e,t,n){N.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');var s=this.getLookupTables(t,n,r,2,!0)[0],i=Tn(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});N.assert(i.coverage.format===1,"Multiple: unable to modify coverage table format "+i.coverage.format);var o=e.sub,a=this.binSearch(i.coverage.glyphs,o);a<0&&(a=-1-a,i.coverage.glyphs.splice(a,0,o),i.sequences.splice(a,0,0)),i.sequences[a]=e.by};ke.prototype.addAlternate=function(r,e,t,n){var s=this.getLookupTables(t,n,r,3,!0)[0],i=Tn(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});N.assert(i.coverage.format===1,"Alternate: unable to modify coverage table format "+i.coverage.format);var o=e.sub,a=this.binSearch(i.coverage.glyphs,o);a<0&&(a=-1-a,i.coverage.glyphs.splice(a,0,o),i.alternateSets.splice(a,0,0)),i.alternateSets[a]=e.by};ke.prototype.addLigature=function(r,e,t,n){var s=this.getLookupTables(t,n,r,4,!0)[0],i=s.subtables[0];i||(i={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=i),N.assert(i.coverage.format===1,"Ligature: unable to modify coverage table format "+i.coverage.format);var o=e.sub[0],a=e.sub.slice(1),u={ligGlyph:e.by,components:a},l=this.binSearch(i.coverage.glyphs,o);if(l>=0){for(var f=i.ligatureSets[l],c=0;c<f.length;c++)if(Eu(f[c].components,a))return;f.push(u)}else l=-1-l,i.coverage.glyphs.splice(l,0,o),i.ligatureSets.splice(l,0,[u])};ke.prototype.getFeature=function(r,e,t){if(/ss\d\d/.test(r))return this.getSingle(r,e,t);switch(r){case"aalt":case"salt":return this.getSingle(r,e,t).concat(this.getAlternates(r,e,t));case"dlig":case"liga":case"rlig":return this.getLigatures(r,e,t);case"ccmp":return this.getMultiple(r,e,t).concat(this.getLigatures(r,e,t));case"stch":return this.getMultiple(r,e,t)}};ke.prototype.add=function(r,e,t,n){if(/ss\d\d/.test(r))return this.addSingle(r,e,t,n);switch(r){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(r,e,t,n):this.addAlternate(r,e,t,n);case"dlig":case"liga":case"rlig":return this.addLigature(r,e,t,n);case"ccmp":return e.by instanceof Array?this.addMultiple(r,e,t,n):this.addLigature(r,e,t,n)}};function Pu(){return typeof window<"u"}function Lu(r){for(var e=new Buffer(r.byteLength),t=new Uint8Array(r),n=0;n<e.length;++n)e[n]=t[n];return e}function Ht(r,e){if(!r)throw e}function Us(r,e,t,n,s){var i;return(e&n)>0?(i=r.parseByte(),(e&s)===0&&(i=-i),i=t+i):(e&s)>0?i=t:i=t+r.parseShort(),i}function Ui(r,e,t){var n=new C.Parser(e,t);r.numberOfContours=n.parseShort(),r._xMin=n.parseShort(),r._yMin=n.parseShort(),r._xMax=n.parseShort(),r._yMax=n.parseShort();var s,i;if(r.numberOfContours>0){for(var o=r.endPointIndices=[],a=0;a<r.numberOfContours;a+=1)o.push(n.parseUShort());r.instructionLength=n.parseUShort(),r.instructions=[];for(var u=0;u<r.instructionLength;u+=1)r.instructions.push(n.parseByte());var l=o[o.length-1]+1;s=[];for(var f=0;f<l;f+=1)if(i=n.parseByte(),s.push(i),(i&8)>0)for(var c=n.parseByte(),h=0;h<c;h+=1)s.push(i),f+=1;if(N.argument(s.length===l,"Bad flags."),o.length>0){var p=[],g;if(l>0){for(var m=0;m<l;m+=1)i=s[m],g={},g.onCurve=!!(i&1),g.lastPointOfContour=o.indexOf(m)>=0,p.push(g);for(var x=0,y=0;y<l;y+=1)i=s[y],g=p[y],g.x=Us(n,i,x,2,16),x=g.x;for(var S=0,w=0;w<l;w+=1)i=s[w],g=p[w],g.y=Us(n,i,S,4,32),S=g.y}r.points=p}else r.points=[]}else if(r.numberOfContours===0)r.points=[];else{r.isComposite=!0,r.points=[],r.components=[];for(var F=!0;F;){s=n.parseUShort();var P={glyphIndex:n.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(P.dx=n.parseShort(),P.dy=n.parseShort()):P.matchedPoints=[n.parseUShort(),n.parseUShort()]:(s&2)>0?(P.dx=n.parseChar(),P.dy=n.parseChar()):P.matchedPoints=[n.parseByte(),n.parseByte()],(s&8)>0?P.xScale=P.yScale=n.parseF2Dot14():(s&64)>0?(P.xScale=n.parseF2Dot14(),P.yScale=n.parseF2Dot14()):(s&128)>0&&(P.xScale=n.parseF2Dot14(),P.scale01=n.parseF2Dot14(),P.scale10=n.parseF2Dot14(),P.yScale=n.parseF2Dot14()),r.components.push(P),F=!!(s&32)}if(s&256){r.instructionLength=n.parseUShort(),r.instructions=[];for(var U=0;U<r.instructionLength;U+=1)r.instructions.push(n.parseByte())}}}function on(r,e){for(var t=[],n=0;n<r.length;n+=1){var s=r[n],i={x:e.xScale*s.x+e.scale01*s.y+e.dx,y:e.scale10*s.x+e.yScale*s.y+e.dy,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour};t.push(i)}return t}function Iu(r){for(var e=[],t=[],n=0;n<r.length;n+=1){var s=r[n];t.push(s),s.lastPointOfContour&&(e.push(t),t=[])}return N.argument(t.length===0,"There are still points left in the current contour."),e}function Ri(r){var e=new fe;if(!r)return e;for(var t=Iu(r),n=0;n<t.length;++n){var s=t[n],i=null,o=s[s.length-1],a=s[0];if(o.onCurve)e.moveTo(o.x,o.y);else if(a.onCurve)e.moveTo(a.x,a.y);else{var u={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5};e.moveTo(u.x,u.y)}for(var l=0;l<s.length;++l)if(i=o,o=a,a=s[(l+1)%s.length],o.onCurve)e.lineTo(o.x,o.y);else{var f=i,c=a;i.onCurve||(f={x:(o.x+i.x)*.5,y:(o.y+i.y)*.5}),a.onCurve||(c={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5}),e.quadraticCurveTo(o.x,o.y,c.x,c.y)}e.closePath()}return e}function Ni(r,e){if(e.isComposite)for(var t=0;t<e.components.length;t+=1){var n=e.components[t],s=r.get(n.glyphIndex);if(s.getPath(),s.points){var i=void 0;if(n.matchedPoints===void 0)i=on(s.points,n);else{if(n.matchedPoints[0]>e.points.length-1||n.matchedPoints[1]>s.points.length-1)throw Error("Matched points out of range in "+e.name);var o=e.points[n.matchedPoints[0]],a=s.points[n.matchedPoints[1]],u={xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:0,dy:0};a=on([a],u)[0],u.dx=o.x-a.x,u.dy=o.y-a.y,i=on(s.points,u)}e.points=e.points.concat(i)}}return Ri(e.points)}function Tu(r,e,t,n){for(var s=new qe.GlyphSet(n),i=0;i<t.length-1;i+=1){var o=t[i],a=t[i+1];o!==a?s.push(i,qe.ttfGlyphLoader(n,i,Ui,r,e+o,Ni)):s.push(i,qe.glyphLoader(n,i))}return s}function Cu(r,e,t,n){var s=new qe.GlyphSet(n);return n._push=function(i){var o=t[i],a=t[i+1];o!==a?s.push(i,qe.ttfGlyphLoader(n,i,Ui,r,e+o,Ni)):s.push(i,qe.glyphLoader(n,i))},s}function Mu(r,e,t,n,s){return s.lowMemory?Cu(r,e,t,n):Tu(r,e,t,n)}var Bi={getPath:Ri,parse:Mu},Gi,gt,Hi,bn;function zi(r){this.font=r,this.getCommands=function(e){return Bi.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Ou(r){return r}function Vi(r){return Math.sign(r)*Math.round(Math.abs(r))}function Fu(r){return Math.sign(r)*Math.round(Math.abs(r*2))/2}function Au(r){return Math.sign(r)*(Math.round(Math.abs(r)+.5)-.5)}function Du(r){return Math.sign(r)*Math.ceil(Math.abs(r))}function Uu(r){return Math.sign(r)*Math.floor(Math.abs(r))}var Xi=function(r){var e=this.srPeriod,t=this.srPhase,n=this.srThreshold,s=1;return r<0&&(r=-r,s=-1),r+=n-t,r=Math.trunc(r/e)*e,r+=t,r<0?t*s:r*s},Xe={x:1,y:0,axis:"x",distance:function(r,e,t,n){return(t?r.xo:r.x)-(n?e.xo:e.x)},interpolate:function(r,e,t,n){var s,i,o,a,u,l,f;if(!n||n===this){if(s=r.xo-e.xo,i=r.xo-t.xo,u=e.x-e.xo,l=t.x-t.xo,o=Math.abs(s),a=Math.abs(i),f=o+a,f===0){r.x=r.xo+(u+l)/2;return}r.x=r.xo+(u*a+l*o)/f;return}if(s=n.distance(r,e,!0,!0),i=n.distance(r,t,!0,!0),u=n.distance(e,e,!1,!0),l=n.distance(t,t,!1,!0),o=Math.abs(s),a=Math.abs(i),f=o+a,f===0){Xe.setRelative(r,r,(u+l)/2,n,!0);return}Xe.setRelative(r,r,(u*a+l*o)/f,n,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(r,e,t,n,s){if(!n||n===this){r.x=(s?e.xo:e.x)+t;return}var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+t*n.x,u=o+t*n.y;r.x=a+(r.y-u)/n.normalSlope},slope:0,touch:function(r){r.xTouched=!0},touched:function(r){return r.xTouched},untouch:function(r){r.xTouched=!1}},$e={x:0,y:1,axis:"y",distance:function(r,e,t,n){return(t?r.yo:r.y)-(n?e.yo:e.y)},interpolate:function(r,e,t,n){var s,i,o,a,u,l,f;if(!n||n===this){if(s=r.yo-e.yo,i=r.yo-t.yo,u=e.y-e.yo,l=t.y-t.yo,o=Math.abs(s),a=Math.abs(i),f=o+a,f===0){r.y=r.yo+(u+l)/2;return}r.y=r.yo+(u*a+l*o)/f;return}if(s=n.distance(r,e,!0,!0),i=n.distance(r,t,!0,!0),u=n.distance(e,e,!1,!0),l=n.distance(t,t,!1,!0),o=Math.abs(s),a=Math.abs(i),f=o+a,f===0){$e.setRelative(r,r,(u+l)/2,n,!0);return}$e.setRelative(r,r,(u*a+l*o)/f,n,!0)},normalSlope:0,setRelative:function(r,e,t,n,s){if(!n||n===this){r.y=(s?e.yo:e.y)+t;return}var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+t*n.x,u=o+t*n.y;r.y=u+n.normalSlope*(r.x-a)},slope:Number.POSITIVE_INFINITY,touch:function(r){r.yTouched=!0},touched:function(r){return r.yTouched},untouch:function(r){r.yTouched=!1}};Object.freeze(Xe);Object.freeze($e);function _t(r,e){this.x=r,this.y=e,this.axis=void 0,this.slope=e/r,this.normalSlope=-r/e,Object.freeze(this)}_t.prototype.distance=function(r,e,t,n){return this.x*Xe.distance(r,e,t,n)+this.y*$e.distance(r,e,t,n)};_t.prototype.interpolate=function(r,e,t,n){var s,i,o,a,u,l,f;if(o=n.distance(r,e,!0,!0),a=n.distance(r,t,!0,!0),s=n.distance(e,e,!1,!0),i=n.distance(t,t,!1,!0),u=Math.abs(o),l=Math.abs(a),f=u+l,f===0){this.setRelative(r,r,(s+i)/2,n,!0);return}this.setRelative(r,r,(s*l+i*u)/f,n,!0)};_t.prototype.setRelative=function(r,e,t,n,s){n=n||this;var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+t*n.x,u=o+t*n.y,l=n.normalSlope,f=this.slope,c=r.x,h=r.y;r.x=(f*c-l*a+u-h)/(f-l),r.y=f*(r.x-c)+h};_t.prototype.touch=function(r){r.xTouched=!0,r.yTouched=!0};function Yt(r,e){var t=Math.sqrt(r*r+e*e);return r/=t,e/=t,r===1&&e===0?Xe:r===0&&e===1?$e:new _t(r,e)}function Ze(r,e,t,n){this.x=this.xo=Math.round(r*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=n,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Ze.prototype.nextTouched=function(r){for(var e=this.nextPointOnContour;!r.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};Ze.prototype.prevTouched=function(r){for(var e=this.prevPointOnContour;!r.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Wt=Object.freeze(new Ze(0,0)),Ru={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function rt(r,e){switch(this.env=r,this.stack=[],this.prog=e,r){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=Xe,this.round=Vi}}zi.prototype.exec=function(r,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(!(this._errorState>2)){var t=this.font,n=this._prepState;if(!n||n.ppem!==e){var s=this._fpgmState;if(!s){rt.prototype=Ru,s=this._fpgmState=new rt("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,exports.DEBUG&&(console.log("---EXEC FPGM---"),s.step=-1);try{gt(s)}catch(l){console.log("Hinting error in FPGM:"+l),this._errorState=3;return}}rt.prototype=s,n=this._prepState=new rt("prep",t.tables.prep),n.ppem=e;var i=t.tables.cvt;if(i)for(var o=n.cvt=new Array(i.length),a=e/t.unitsPerEm,u=0;u<i.length;u++)o[u]=i[u]*a;else n.cvt=[];exports.DEBUG&&(console.log("---EXEC PREP---"),n.step=-1);try{gt(n)}catch(l){this._errorState<2&&console.log("Hinting error in PREP:"+l),this._errorState=2}}if(!(this._errorState>1))try{return Hi(r,n)}catch(l){this._errorState<1&&(console.log("Hinting error:"+l),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}}};Hi=function(r,e){var t=e.ppem/e.font.unitsPerEm,n=t,s=r.components,i,o,a;if(rt.prototype=e,!s)a=new rt("glyf",r.instructions),exports.DEBUG&&(console.log("---EXEC GLYPH---"),a.step=-1),bn(r,a,t,n),o=a.gZone;else{var u=e.font;o=[],i=[];for(var l=0;l<s.length;l++){var f=s[l],c=u.glyphs.get(f.glyphIndex);a=new rt("glyf",c.instructions),exports.DEBUG&&(console.log("---EXEC COMP "+l+"---"),a.step=-1),bn(c,a,t,n);for(var h=Math.round(f.dx*t),p=Math.round(f.dy*n),g=a.gZone,m=a.contours,x=0;x<g.length;x++){var y=g[x];y.xTouched=y.yTouched=!1,y.xo=y.x=y.x+h,y.yo=y.y=y.y+p}var S=o.length;o.push.apply(o,g);for(var w=0;w<m.length;w++)i.push(m[w]+S)}r.instructions&&!a.inhibitGridFit&&(a=new rt("glyf",r.instructions),a.gZone=a.z0=a.z1=a.z2=o,a.contours=i,o.push(new Ze(0,0),new Ze(Math.round(r.advanceWidth*t),0)),exports.DEBUG&&(console.log("---EXEC COMPOSITE---"),a.step=-1),gt(a),o.length-=2)}return o};bn=function(r,e,t,n){for(var s=r.points||[],i=s.length,o=e.gZone=e.z0=e.z1=e.z2=[],a=e.contours=[],u,l=0;l<i;l++)u=s[l],o[l]=new Ze(u.x*t,u.y*n,u.lastPointOfContour,u.onCurve);for(var f,c,h=0;h<i;h++)u=o[h],f||(f=u,a.push(h)),u.lastPointOfContour?(u.nextPointOnContour=f,f.prevPointOnContour=u,f=void 0):(c=o[h+1],u.nextPointOnContour=c,c.prevPointOnContour=u);if(!e.inhibitGridFit){if(exports.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(var p=0;p<i;p++)console.log(p,o[p].x,o[p].y)}if(o.push(new Ze(0,0),new Ze(Math.round(r.advanceWidth*t),0)),gt(e),o.length-=2,exports.DEBUG){console.log("FINISHED GLYPH",e.stack);for(var g=0;g<i;g++)console.log(g,o[g].x,o[g].y)}}};gt=function(r){var e=r.prog;if(e){var t=e.length,n;for(r.ip=0;r.ip<t;r.ip++){if(exports.DEBUG&&r.step++,n=Gi[e[r.ip]],!n)throw new Error("unknown instruction: 0x"+Number(e[r.ip]).toString(16));n(r)}}};function Dr(r){for(var e=r.tZone=new Array(r.gZone.length),t=0;t<e.length;t++)e[t]=new Ze(0,0)}function qi(r,e){var t=r.prog,n=r.ip,s=1,i;do if(i=t[++n],i===88)s++;else if(i===89)s--;else if(i===64)n+=t[n+1]+1;else if(i===65)n+=2*t[n+1]+1;else if(i>=176&&i<=183)n+=i-176+1;else if(i>=184&&i<=191)n+=(i-184+1)*2;else if(e&&s===1&&i===27)break;while(s>0);r.ip=n}function Rs(r,e){exports.DEBUG&&console.log(e.step,"SVTCA["+r.axis+"]"),e.fv=e.pv=e.dpv=r}function Ns(r,e){exports.DEBUG&&console.log(e.step,"SPVTCA["+r.axis+"]"),e.pv=e.dpv=r}function Bs(r,e){exports.DEBUG&&console.log(e.step,"SFVTCA["+r.axis+"]"),e.fv=r}function Gs(r,e){var t=e.stack,n=t.pop(),s=t.pop(),i=e.z2[n],o=e.z1[s];exports.DEBUG&&console.log("SPVTL["+r+"]",n,s);var a,u;r?(a=i.y-o.y,u=o.x-i.x):(a=o.x-i.x,u=o.y-i.y),e.pv=e.dpv=Yt(a,u)}function Hs(r,e){var t=e.stack,n=t.pop(),s=t.pop(),i=e.z2[n],o=e.z1[s];exports.DEBUG&&console.log("SFVTL["+r+"]",n,s);var a,u;r?(a=i.y-o.y,u=o.x-i.x):(a=o.x-i.x,u=o.y-i.y),e.fv=Yt(a,u)}function Nu(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"SPVFS[]",t,n),r.pv=r.dpv=Yt(n,t)}function Bu(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"SPVFS[]",t,n),r.fv=Yt(n,t)}function Gu(r){var e=r.stack,t=r.pv;exports.DEBUG&&console.log(r.step,"GPV[]"),e.push(t.x*16384),e.push(t.y*16384)}function Hu(r){var e=r.stack,t=r.fv;exports.DEBUG&&console.log(r.step,"GFV[]"),e.push(t.x*16384),e.push(t.y*16384)}function zu(r){r.fv=r.pv,exports.DEBUG&&console.log(r.step,"SFVTPV[]")}function Vu(r){var e=r.stack,t=e.pop(),n=e.pop(),s=e.pop(),i=e.pop(),o=e.pop(),a=r.z0,u=r.z1,l=a[t],f=a[n],c=u[s],h=u[i],p=r.z2[o];exports.DEBUG&&console.log("ISECT[], ",t,n,s,i,o);var g=l.x,m=l.y,x=f.x,y=f.y,S=c.x,w=c.y,F=h.x,P=h.y,U=(g-x)*(w-P)-(m-y)*(S-F),O=g*y-m*x,L=S*P-w*F;p.x=(O*(S-F)-L*(g-x))/U,p.y=(O*(w-P)-L*(m-y))/U}function Xu(r){r.rp0=r.stack.pop(),exports.DEBUG&&console.log(r.step,"SRP0[]",r.rp0)}function qu(r){r.rp1=r.stack.pop(),exports.DEBUG&&console.log(r.step,"SRP1[]",r.rp1)}function Wu(r){r.rp2=r.stack.pop(),exports.DEBUG&&console.log(r.step,"SRP2[]",r.rp2)}function $u(r){var e=r.stack.pop();switch(exports.DEBUG&&console.log(r.step,"SZP0[]",e),r.zp0=e,e){case 0:r.tZone||Dr(r),r.z0=r.tZone;break;case 1:r.z0=r.gZone;break;default:throw new Error("Invalid zone pointer")}}function Zu(r){var e=r.stack.pop();switch(exports.DEBUG&&console.log(r.step,"SZP1[]",e),r.zp1=e,e){case 0:r.tZone||Dr(r),r.z1=r.tZone;break;case 1:r.z1=r.gZone;break;default:throw new Error("Invalid zone pointer")}}function _u(r){var e=r.stack.pop();switch(exports.DEBUG&&console.log(r.step,"SZP2[]",e),r.zp2=e,e){case 0:r.tZone||Dr(r),r.z2=r.tZone;break;case 1:r.z2=r.gZone;break;default:throw new Error("Invalid zone pointer")}}function Yu(r){var e=r.stack.pop();switch(exports.DEBUG&&console.log(r.step,"SZPS[]",e),r.zp0=r.zp1=r.zp2=e,e){case 0:r.tZone||Dr(r),r.z0=r.z1=r.z2=r.tZone;break;case 1:r.z0=r.z1=r.z2=r.gZone;break;default:throw new Error("Invalid zone pointer")}}function ju(r){r.loop=r.stack.pop(),exports.DEBUG&&console.log(r.step,"SLOOP[]",r.loop)}function Ku(r){exports.DEBUG&&console.log(r.step,"RTG[]"),r.round=Vi}function Ju(r){exports.DEBUG&&console.log(r.step,"RTHG[]"),r.round=Au}function Qu(r){var e=r.stack.pop();exports.DEBUG&&console.log(r.step,"SMD[]",e),r.minDis=e/64}function el(r){exports.DEBUG&&console.log(r.step,"ELSE[]"),qi(r,!1)}function tl(r){var e=r.stack.pop();exports.DEBUG&&console.log(r.step,"JMPR[]",e),r.ip+=e-1}function rl(r){var e=r.stack.pop();exports.DEBUG&&console.log(r.step,"SCVTCI[]",e),r.cvCutIn=e/64}function nl(r){var e=r.stack;exports.DEBUG&&console.log(r.step,"DUP[]"),e.push(e[e.length-1])}function an(r){exports.DEBUG&&console.log(r.step,"POP[]"),r.stack.pop()}function sl(r){exports.DEBUG&&console.log(r.step,"CLEAR[]"),r.stack.length=0}function il(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"SWAP[]"),e.push(t),e.push(n)}function ol(r){var e=r.stack;exports.DEBUG&&console.log(r.step,"DEPTH[]"),e.push(e.length)}function al(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"LOOPCALL[]",t,n);var s=r.ip,i=r.prog;r.prog=r.funcs[t];for(var o=0;o<n;o++)gt(r),exports.DEBUG&&console.log(++r.step,o+1<n?"next loopcall":"done loopcall",o);r.ip=s,r.prog=i}function ul(r){var e=r.stack.pop();exports.DEBUG&&console.log(r.step,"CALL[]",e);var t=r.ip,n=r.prog;r.prog=r.funcs[e],gt(r),r.ip=t,r.prog=n,exports.DEBUG&&console.log(++r.step,"returning from",e)}function ll(r){var e=r.stack,t=e.pop();exports.DEBUG&&console.log(r.step,"CINDEX[]",t),e.push(e[e.length-t])}function fl(r){var e=r.stack,t=e.pop();exports.DEBUG&&console.log(r.step,"MINDEX[]",t),e.push(e.splice(e.length-t,1)[0])}function hl(r){if(r.env!=="fpgm")throw new Error("FDEF not allowed here");var e=r.stack,t=r.prog,n=r.ip,s=e.pop(),i=n;for(exports.DEBUG&&console.log(r.step,"FDEF[]",s);t[++n]!==45;);r.ip=n,r.funcs[s]=t.slice(i+1,n)}function zs(r,e){var t=e.stack.pop(),n=e.z0[t],s=e.fv,i=e.pv;exports.DEBUG&&console.log(e.step,"MDAP["+r+"]",t);var o=i.distance(n,Wt);r&&(o=e.round(o)),s.setRelative(n,Wt,o,i),s.touch(n),e.rp0=e.rp1=t}function Vs(r,e){var t=e.z2,n=t.length-2,s,i,o;exports.DEBUG&&console.log(e.step,"IUP["+r.axis+"]");for(var a=0;a<n;a++)s=t[a],!r.touched(s)&&(i=s.prevTouched(r),i!==s&&(o=s.nextTouched(r),i===o&&r.setRelative(s,s,r.distance(i,i,!1,!0),r,!0),r.interpolate(s,i,o,r)))}function Xs(r,e){for(var t=e.stack,n=r?e.rp1:e.rp2,s=(r?e.z0:e.z1)[n],i=e.fv,o=e.pv,a=e.loop,u=e.z2;a--;){var l=t.pop(),f=u[l],c=o.distance(s,s,!1,!0);i.setRelative(f,f,c,o),i.touch(f),exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-a)+": ":"")+"SHP["+(r?"rp1":"rp2")+"]",l)}e.loop=1}function qs(r,e){var t=e.stack,n=r?e.rp1:e.rp2,s=(r?e.z0:e.z1)[n],i=e.fv,o=e.pv,a=t.pop(),u=e.z2[e.contours[a]],l=u;exports.DEBUG&&console.log(e.step,"SHC["+r+"]",a);var f=o.distance(s,s,!1,!0);do l!==s&&i.setRelative(l,l,f,o),l=l.nextPointOnContour;while(l!==u)}function Ws(r,e){var t=e.stack,n=r?e.rp1:e.rp2,s=(r?e.z0:e.z1)[n],i=e.fv,o=e.pv,a=t.pop();exports.DEBUG&&console.log(e.step,"SHZ["+r+"]",a);var u;switch(a){case 0:u=e.tZone;break;case 1:u=e.gZone;break;default:throw new Error("Invalid zone")}for(var l,f=o.distance(s,s,!1,!0),c=u.length-2,h=0;h<c;h++)l=u[h],i.setRelative(l,l,f,o)}function cl(r){for(var e=r.stack,t=r.loop,n=r.fv,s=e.pop()/64,i=r.z2;t--;){var o=e.pop(),a=i[o];exports.DEBUG&&console.log(r.step,(r.loop>1?"loop "+(r.loop-t)+": ":"")+"SHPIX[]",o,s),n.setRelative(a,a,s),n.touch(a)}r.loop=1}function pl(r){for(var e=r.stack,t=r.rp1,n=r.rp2,s=r.loop,i=r.z0[t],o=r.z1[n],a=r.fv,u=r.dpv,l=r.z2;s--;){var f=e.pop(),c=l[f];exports.DEBUG&&console.log(r.step,(r.loop>1?"loop "+(r.loop-s)+": ":"")+"IP[]",f,t,"<->",n),a.interpolate(c,i,o,u),a.touch(c)}r.loop=1}function $s(r,e){var t=e.stack,n=t.pop()/64,s=t.pop(),i=e.z1[s],o=e.z0[e.rp0],a=e.fv,u=e.pv;a.setRelative(i,o,n,u),a.touch(i),exports.DEBUG&&console.log(e.step,"MSIRP["+r+"]",n,s),e.rp1=e.rp0,e.rp2=s,r&&(e.rp0=s)}function dl(r){for(var e=r.stack,t=r.rp0,n=r.z0[t],s=r.loop,i=r.fv,o=r.pv,a=r.z1;s--;){var u=e.pop(),l=a[u];exports.DEBUG&&console.log(r.step,(r.loop>1?"loop "+(r.loop-s)+": ":"")+"ALIGNRP[]",u),i.setRelative(l,n,0,o),i.touch(l)}r.loop=1}function gl(r){exports.DEBUG&&console.log(r.step,"RTDG[]"),r.round=Fu}function Zs(r,e){var t=e.stack,n=t.pop(),s=t.pop(),i=e.z0[s],o=e.fv,a=e.pv,u=e.cvt[n];exports.DEBUG&&console.log(e.step,"MIAP["+r+"]",n,"(",u,")",s);var l=a.distance(i,Wt);r&&(Math.abs(l-u)<e.cvCutIn&&(l=u),l=e.round(l)),o.setRelative(i,Wt,l,a),e.zp0===0&&(i.xo=i.x,i.yo=i.y),o.touch(i),e.rp0=e.rp1=s}function vl(r){var e=r.prog,t=r.ip,n=r.stack,s=e[++t];exports.DEBUG&&console.log(r.step,"NPUSHB[]",s);for(var i=0;i<s;i++)n.push(e[++t]);r.ip=t}function ml(r){var e=r.ip,t=r.prog,n=r.stack,s=t[++e];exports.DEBUG&&console.log(r.step,"NPUSHW[]",s);for(var i=0;i<s;i++){var o=t[++e]<<8|t[++e];o&32768&&(o=-((o^65535)+1)),n.push(o)}r.ip=e}function xl(r){var e=r.stack,t=r.store;t||(t=r.store=[]);var n=e.pop(),s=e.pop();exports.DEBUG&&console.log(r.step,"WS",n,s),t[s]=n}function yl(r){var e=r.stack,t=r.store,n=e.pop();exports.DEBUG&&console.log(r.step,"RS",n);var s=t&&t[n]||0;e.push(s)}function bl(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"WCVTP",t,n),r.cvt[n]=t/64}function Sl(r){var e=r.stack,t=e.pop();exports.DEBUG&&console.log(r.step,"RCVT",t),e.push(r.cvt[t]*64)}function _s(r,e){var t=e.stack,n=t.pop(),s=e.z2[n];exports.DEBUG&&console.log(e.step,"GC["+r+"]",n),t.push(e.dpv.distance(s,Wt,r,!1)*64)}function Ys(r,e){var t=e.stack,n=t.pop(),s=t.pop(),i=e.z1[n],o=e.z0[s],a=e.dpv.distance(o,i,r,r);exports.DEBUG&&console.log(e.step,"MD["+r+"]",n,s,"->",a),e.stack.push(Math.round(a*64))}function wl(r){exports.DEBUG&&console.log(r.step,"MPPEM[]"),r.stack.push(r.ppem)}function kl(r){exports.DEBUG&&console.log(r.step,"FLIPON[]"),r.autoFlip=!0}function El(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"LT[]",t,n),e.push(n<t?1:0)}function Pl(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"LTEQ[]",t,n),e.push(n<=t?1:0)}function Ll(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"GT[]",t,n),e.push(n>t?1:0)}function Il(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"GTEQ[]",t,n),e.push(n>=t?1:0)}function Tl(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"EQ[]",t,n),e.push(t===n?1:0)}function Cl(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"NEQ[]",t,n),e.push(t!==n?1:0)}function Ml(r){var e=r.stack,t=e.pop();exports.DEBUG&&console.log(r.step,"ODD[]",t),e.push(Math.trunc(t)%2?1:0)}function Ol(r){var e=r.stack,t=e.pop();exports.DEBUG&&console.log(r.step,"EVEN[]",t),e.push(Math.trunc(t)%2?0:1)}function Fl(r){var e=r.stack.pop();exports.DEBUG&&console.log(r.step,"IF[]",e),e||(qi(r,!0),exports.DEBUG&&console.log(r.step,"EIF[]"))}function Al(r){exports.DEBUG&&console.log(r.step,"EIF[]")}function Dl(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"AND[]",t,n),e.push(t&&n?1:0)}function Ul(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"OR[]",t,n),e.push(t||n?1:0)}function Rl(r){var e=r.stack,t=e.pop();exports.DEBUG&&console.log(r.step,"NOT[]",t),e.push(t?0:1)}function un(r,e){var t=e.stack,n=t.pop(),s=e.fv,i=e.pv,o=e.ppem,a=e.deltaBase+(r-1)*16,u=e.deltaShift,l=e.z0;exports.DEBUG&&console.log(e.step,"DELTAP["+r+"]",n,t);for(var f=0;f<n;f++){var c=t.pop(),h=t.pop(),p=a+((h&240)>>4);if(p===o){var g=(h&15)-8;g>=0&&g++,exports.DEBUG&&console.log(e.step,"DELTAPFIX",c,"by",g*u);var m=l[c];s.setRelative(m,m,g*u,i)}}}function Nl(r){var e=r.stack,t=e.pop();exports.DEBUG&&console.log(r.step,"SDB[]",t),r.deltaBase=t}function Bl(r){var e=r.stack,t=e.pop();exports.DEBUG&&console.log(r.step,"SDS[]",t),r.deltaShift=Math.pow(.5,t)}function Gl(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"ADD[]",t,n),e.push(n+t)}function Hl(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"SUB[]",t,n),e.push(n-t)}function zl(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"DIV[]",t,n),e.push(n*64/t)}function Vl(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"MUL[]",t,n),e.push(n*t/64)}function Xl(r){var e=r.stack,t=e.pop();exports.DEBUG&&console.log(r.step,"ABS[]",t),e.push(Math.abs(t))}function ql(r){var e=r.stack,t=e.pop();exports.DEBUG&&console.log(r.step,"NEG[]",t),e.push(-t)}function Wl(r){var e=r.stack,t=e.pop();exports.DEBUG&&console.log(r.step,"FLOOR[]",t),e.push(Math.floor(t/64)*64)}function $l(r){var e=r.stack,t=e.pop();exports.DEBUG&&console.log(r.step,"CEILING[]",t),e.push(Math.ceil(t/64)*64)}function Pr(r,e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ROUND[]"),t.push(e.round(n/64)*64)}function Zl(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"WCVTF[]",t,n),r.cvt[n]=t*r.ppem/r.font.unitsPerEm}function ln(r,e){var t=e.stack,n=t.pop(),s=e.ppem,i=e.deltaBase+(r-1)*16,o=e.deltaShift;exports.DEBUG&&console.log(e.step,"DELTAC["+r+"]",n,t);for(var a=0;a<n;a++){var u=t.pop(),l=t.pop(),f=i+((l&240)>>4);if(f===s){var c=(l&15)-8;c>=0&&c++;var h=c*o;exports.DEBUG&&console.log(e.step,"DELTACFIX",u,"by",h),e.cvt[u]+=h}}}function _l(r){var e=r.stack.pop();exports.DEBUG&&console.log(r.step,"SROUND[]",e),r.round=Xi;var t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(r.srPeriod=t,e&48){case 0:r.srPhase=0;break;case 16:r.srPhase=.25*t;break;case 32:r.srPhase=.5*t;break;case 48:r.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?r.srThreshold=0:r.srThreshold=(e/8-.5)*t}function Yl(r){var e=r.stack.pop();exports.DEBUG&&console.log(r.step,"S45ROUND[]",e),r.round=Xi;var t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(r.srPeriod=t,e&48){case 0:r.srPhase=0;break;case 16:r.srPhase=.25*t;break;case 32:r.srPhase=.5*t;break;case 48:r.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?r.srThreshold=0:r.srThreshold=(e/8-.5)*t}function jl(r){exports.DEBUG&&console.log(r.step,"ROFF[]"),r.round=Ou}function Kl(r){exports.DEBUG&&console.log(r.step,"RUTG[]"),r.round=Du}function Jl(r){exports.DEBUG&&console.log(r.step,"RDTG[]"),r.round=Uu}function Ql(r){var e=r.stack.pop();exports.DEBUG&&console.log(r.step,"SCANCTRL[]",e)}function js(r,e){var t=e.stack,n=t.pop(),s=t.pop(),i=e.z2[n],o=e.z1[s];exports.DEBUG&&console.log(e.step,"SDPVTL["+r+"]",n,s);var a,u;r?(a=i.y-o.y,u=o.x-i.x):(a=o.x-i.x,u=o.y-i.y),e.dpv=Yt(a,u)}function ef(r){var e=r.stack,t=e.pop(),n=0;exports.DEBUG&&console.log(r.step,"GETINFO[]",t),t&1&&(n=35),t&32&&(n|=4096),e.push(n)}function tf(r){var e=r.stack,t=e.pop(),n=e.pop(),s=e.pop();exports.DEBUG&&console.log(r.step,"ROLL[]"),e.push(n),e.push(t),e.push(s)}function rf(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"MAX[]",t,n),e.push(Math.max(n,t))}function nf(r){var e=r.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(r.step,"MIN[]",t,n),e.push(Math.min(n,t))}function sf(r){var e=r.stack.pop();exports.DEBUG&&console.log(r.step,"SCANTYPE[]",e)}function of(r){var e=r.stack.pop(),t=r.stack.pop();switch(exports.DEBUG&&console.log(r.step,"INSTCTRL[]",e,t),e){case 1:r.inhibitGridFit=!!t;return;case 2:r.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Qe(r,e){var t=e.stack,n=e.prog,s=e.ip;exports.DEBUG&&console.log(e.step,"PUSHB["+r+"]");for(var i=0;i<r;i++)t.push(n[++s]);e.ip=s}function et(r,e){var t=e.ip,n=e.prog,s=e.stack;exports.DEBUG&&console.log(e.ip,"PUSHW["+r+"]");for(var i=0;i<r;i++){var o=n[++t]<<8|n[++t];o&32768&&(o=-((o^65535)+1)),s.push(o)}e.ip=t}function T(r,e,t,n,s,i){var o=i.stack,a=r&&o.pop(),u=o.pop(),l=i.rp0,f=i.z0[l],c=i.z1[u],h=i.minDis,p=i.fv,g=i.dpv,m,x,y,S;x=m=g.distance(c,f,!0,!0),y=x>=0?1:-1,x=Math.abs(x),r&&(S=i.cvt[a],n&&Math.abs(x-S)<i.cvCutIn&&(x=S)),t&&x<h&&(x=h),n&&(x=i.round(x)),p.setRelative(c,f,y*x,g),p.touch(c),exports.DEBUG&&console.log(i.step,(r?"MIRP[":"MDRP[")+(e?"M":"m")+(t?">":"_")+(n?"R":"_")+(s===0?"Gr":s===1?"Bl":s===2?"Wh":"")+"]",r?a+"("+i.cvt[a]+","+S+")":"",u,"(d =",m,"->",y*x,")"),i.rp1=i.rp0,i.rp2=u,e&&(i.rp0=u)}Gi=[Rs.bind(void 0,$e),Rs.bind(void 0,Xe),Ns.bind(void 0,$e),Ns.bind(void 0,Xe),Bs.bind(void 0,$e),Bs.bind(void 0,Xe),Gs.bind(void 0,0),Gs.bind(void 0,1),Hs.bind(void 0,0),Hs.bind(void 0,1),Nu,Bu,Gu,Hu,zu,Vu,Xu,qu,Wu,$u,Zu,_u,Yu,ju,Ku,Ju,Qu,el,tl,rl,void 0,void 0,nl,an,sl,il,ol,ll,fl,void 0,void 0,void 0,al,ul,hl,void 0,zs.bind(void 0,0),zs.bind(void 0,1),Vs.bind(void 0,$e),Vs.bind(void 0,Xe),Xs.bind(void 0,0),Xs.bind(void 0,1),qs.bind(void 0,0),qs.bind(void 0,1),Ws.bind(void 0,0),Ws.bind(void 0,1),cl,pl,$s.bind(void 0,0),$s.bind(void 0,1),dl,gl,Zs.bind(void 0,0),Zs.bind(void 0,1),vl,ml,xl,yl,bl,Sl,_s.bind(void 0,0),_s.bind(void 0,1),void 0,Ys.bind(void 0,0),Ys.bind(void 0,1),wl,void 0,kl,void 0,void 0,El,Pl,Ll,Il,Tl,Cl,Ml,Ol,Fl,Al,Dl,Ul,Rl,un.bind(void 0,1),Nl,Bl,Gl,Hl,zl,Vl,Xl,ql,Wl,$l,Pr.bind(void 0,0),Pr.bind(void 0,1),Pr.bind(void 0,2),Pr.bind(void 0,3),void 0,void 0,void 0,void 0,Zl,un.bind(void 0,2),un.bind(void 0,3),ln.bind(void 0,1),ln.bind(void 0,2),ln.bind(void 0,3),_l,Yl,void 0,void 0,jl,void 0,Kl,Jl,an,an,void 0,void 0,void 0,void 0,void 0,Ql,js.bind(void 0,0),js.bind(void 0,1),ef,void 0,tf,rf,nf,sf,of,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,Qe.bind(void 0,1),Qe.bind(void 0,2),Qe.bind(void 0,3),Qe.bind(void 0,4),Qe.bind(void 0,5),Qe.bind(void 0,6),Qe.bind(void 0,7),Qe.bind(void 0,8),et.bind(void 0,1),et.bind(void 0,2),et.bind(void 0,3),et.bind(void 0,4),et.bind(void 0,5),et.bind(void 0,6),et.bind(void 0,7),et.bind(void 0,8),T.bind(void 0,0,0,0,0,0),T.bind(void 0,0,0,0,0,1),T.bind(void 0,0,0,0,0,2),T.bind(void 0,0,0,0,0,3),T.bind(void 0,0,0,0,1,0),T.bind(void 0,0,0,0,1,1),T.bind(void 0,0,0,0,1,2),T.bind(void 0,0,0,0,1,3),T.bind(void 0,0,0,1,0,0),T.bind(void 0,0,0,1,0,1),T.bind(void 0,0,0,1,0,2),T.bind(void 0,0,0,1,0,3),T.bind(void 0,0,0,1,1,0),T.bind(void 0,0,0,1,1,1),T.bind(void 0,0,0,1,1,2),T.bind(void 0,0,0,1,1,3),T.bind(void 0,0,1,0,0,0),T.bind(void 0,0,1,0,0,1),T.bind(void 0,0,1,0,0,2),T.bind(void 0,0,1,0,0,3),T.bind(void 0,0,1,0,1,0),T.bind(void 0,0,1,0,1,1),T.bind(void 0,0,1,0,1,2),T.bind(void 0,0,1,0,1,3),T.bind(void 0,0,1,1,0,0),T.bind(void 0,0,1,1,0,1),T.bind(void 0,0,1,1,0,2),T.bind(void 0,0,1,1,0,3),T.bind(void 0,0,1,1,1,0),T.bind(void 0,0,1,1,1,1),T.bind(void 0,0,1,1,1,2),T.bind(void 0,0,1,1,1,3),T.bind(void 0,1,0,0,0,0),T.bind(void 0,1,0,0,0,1),T.bind(void 0,1,0,0,0,2),T.bind(void 0,1,0,0,0,3),T.bind(void 0,1,0,0,1,0),T.bind(void 0,1,0,0,1,1),T.bind(void 0,1,0,0,1,2),T.bind(void 0,1,0,0,1,3),T.bind(void 0,1,0,1,0,0),T.bind(void 0,1,0,1,0,1),T.bind(void 0,1,0,1,0,2),T.bind(void 0,1,0,1,0,3),T.bind(void 0,1,0,1,1,0),T.bind(void 0,1,0,1,1,1),T.bind(void 0,1,0,1,1,2),T.bind(void 0,1,0,1,1,3),T.bind(void 0,1,1,0,0,0),T.bind(void 0,1,1,0,0,1),T.bind(void 0,1,1,0,0,2),T.bind(void 0,1,1,0,0,3),T.bind(void 0,1,1,0,1,0),T.bind(void 0,1,1,0,1,1),T.bind(void 0,1,1,0,1,2),T.bind(void 0,1,1,0,1,3),T.bind(void 0,1,1,1,0,0),T.bind(void 0,1,1,1,0,1),T.bind(void 0,1,1,1,0,2),T.bind(void 0,1,1,1,0,3),T.bind(void 0,1,1,1,1,0),T.bind(void 0,1,1,1,1,1),T.bind(void 0,1,1,1,1,2),T.bind(void 0,1,1,1,1,3)];function Lt(r){this.char=r,this.state={},this.activeState=null}function Cn(r,e,t){this.contextName=t,this.startIndex=r,this.endOffset=e}function af(r,e,t){this.contextName=r,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=t}function Ae(r,e){this.context=r,this.index=e,this.length=r.length,this.current=r[e],this.backtrack=r.slice(0,e),this.lookahead=r.slice(e+1)}function Ur(r){this.eventId=r,this.subscribers=[]}function uf(r){var e=this,t=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];t.forEach(function(s){Object.defineProperty(e.events,s,{value:new Ur(s)})}),r&&t.forEach(function(s){var i=r[s];typeof i=="function"&&e.events[s].subscribe(i)});var n=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];n.forEach(function(s){e.events[s].subscribe(e.updateContextsRanges)})}function ie(r){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],uf.call(this,r)}Lt.prototype.setState=function(r,e){return this.state[r]=e,this.activeState={key:r,value:this.state[r]},this.activeState};Lt.prototype.getState=function(r){return this.state[r]||null};ie.prototype.inboundIndex=function(r){return r>=0&&r<this.tokens.length};ie.prototype.composeRUD=function(r){var e=this,t=!0,n=r.map(function(i){return e[i[0]].apply(e,i.slice(1).concat(t))}),s=function(i){return typeof i=="object"&&i.hasOwnProperty("FAIL")};if(n.every(s))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:n.filter(s)};this.dispatch("composeRUD",[n.filter(function(i){return!s(i)})])};ie.prototype.replaceRange=function(r,e,t,n){e=e!==null?e:this.tokens.length;var s=t.every(function(o){return o instanceof Lt});if(!isNaN(r)&&this.inboundIndex(r)&&s){var i=this.tokens.splice.apply(this.tokens,[r,e].concat(t));return n||this.dispatch("replaceToken",[r,e,t]),[i,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};ie.prototype.replaceToken=function(r,e,t){if(!isNaN(r)&&this.inboundIndex(r)&&e instanceof Lt){var n=this.tokens.splice(r,1,e);return t||this.dispatch("replaceToken",[r,e]),[n[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};ie.prototype.removeRange=function(r,e,t){e=isNaN(e)?this.tokens.length:e;var n=this.tokens.splice(r,e);return t||this.dispatch("removeRange",[n,r,e]),n};ie.prototype.removeToken=function(r,e){if(!isNaN(r)&&this.inboundIndex(r)){var t=this.tokens.splice(r,1);return e||this.dispatch("removeToken",[t,r]),t}else return{FAIL:"removeToken: invalid token index."}};ie.prototype.insertToken=function(r,e,t){var n=r.every(function(s){return s instanceof Lt});return n?(this.tokens.splice.apply(this.tokens,[e,0].concat(r)),t||this.dispatch("insertToken",[r,e]),r):{FAIL:"insertToken: invalid token(s)."}};ie.prototype.registerModifier=function(r,e,t){this.events.newToken.subscribe(function(n,s){var i=[n,s],o=e===null||e.apply(this,i)===!0,a=[n,s];if(o){var u=t.apply(this,a);n.setState(r,u)}}),this.registeredModifiers.push(r)};Ur.prototype.subscribe=function(r){return typeof r=="function"?this.subscribers.push(r)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}};Ur.prototype.unsubscribe=function(r){this.subscribers.splice(r,1)};Ae.prototype.setCurrentIndex=function(r){this.index=r,this.current=this.context[r],this.backtrack=this.context.slice(0,r),this.lookahead=this.context.slice(r+1)};Ae.prototype.get=function(r){switch(!0){case r===0:return this.current;case(r<0&&Math.abs(r)<=this.backtrack.length):return this.backtrack.slice(r)[0];case(r>0&&r<=this.lookahead.length):return this.lookahead[r-1];default:return null}};ie.prototype.rangeToText=function(r){if(r instanceof Cn)return this.getRangeTokens(r).map(function(e){return e.char}).join("")};ie.prototype.getText=function(){return this.tokens.map(function(r){return r.char}).join("")};ie.prototype.getContext=function(r){var e=this.registeredContexts[r];return e||null};ie.prototype.on=function(r,e){var t=this.events[r];return t?t.subscribe(e):null};ie.prototype.dispatch=function(r,e){var t=this,n=this.events[r];n instanceof Ur&&n.subscribers.forEach(function(s){s.apply(t,e||[])})};ie.prototype.registerContextChecker=function(r,e,t){if(this.getContext(r))return{FAIL:"context name '"+r+"' is already registered."};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof t!="function")return{FAIL:"missing context end check."};var n=new af(r,e,t);return this.registeredContexts[r]=n,this.contextCheckers.push(n),n};ie.prototype.getRangeTokens=function(r){var e=r.startIndex+r.endOffset;return[].concat(this.tokens.slice(r.startIndex,e))};ie.prototype.getContextRanges=function(r){var e=this.getContext(r);return e?e.ranges:{FAIL:"context checker '"+r+"' is not registered."}};ie.prototype.resetContextsRanges=function(){var r=this.registeredContexts;for(var e in r)if(r.hasOwnProperty(e)){var t=r[e];t.ranges=[]}};ie.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var r=this.tokens.map(function(n){return n.char}),e=0;e<r.length;e++){var t=new Ae(r,e);this.runContextCheck(t)}this.dispatch("updateContextsRanges",[this.registeredContexts])};ie.prototype.setEndOffset=function(r,e){var t=this.getContext(e).openRange.startIndex,n=new Cn(t,r,e),s=this.getContext(e).ranges;return n.rangeId=e+"."+s.length,s.push(n),this.getContext(e).openRange=null,n};ie.prototype.runContextCheck=function(r){var e=this,t=r.index;this.contextCheckers.forEach(function(n){var s=n.contextName,i=e.getContext(s).openRange;if(!i&&n.checkStart(r)&&(i=new Cn(t,null,s),e.getContext(s).openRange=i,e.dispatch("contextStart",[s,t])),i&&n.checkEnd(r)){var o=t-i.startIndex+1,a=e.setEndOffset(o,s);e.dispatch("contextEnd",[s,a])}})};ie.prototype.tokenize=function(r){this.tokens=[],this.resetContextsRanges();var e=Array.from(r);this.dispatch("start");for(var t=0;t<e.length;t++){var n=e[t],s=new Ae(e,t);this.dispatch("next",[s]),this.runContextCheck(s);var i=new Lt(n);this.tokens.push(i),this.dispatch("newToken",[i,s])}return this.dispatch("end",[this.tokens]),this.tokens};function nt(r){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(r)}function Wi(r){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(r)}function st(r){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(r)}function Ir(r){return/[A-z]/.test(r)}function lf(r){return/\s/.test(r)}function Ee(r){this.font=r,this.features={}}function dt(r){this.id=r.id,this.tag=r.tag,this.substitution=r.substitution}function jt(r,e){if(!r)return-1;switch(e.format){case 1:return e.glyphs.indexOf(r);case 2:for(var t=e.ranges,n=0;n<t.length;n++){var s=t[n];if(r>=s.start&&r<=s.end){var i=r-s.start;return s.index+i}}break;default:return-1}return-1}function ff(r,e){var t=jt(r,e.coverage);return t===-1?null:r+e.deltaGlyphId}function hf(r,e){var t=jt(r,e.coverage);return t===-1?null:e.substitute[t]}function fn(r,e){for(var t=[],n=0;n<r.length;n++){var s=r[n],i=e.current;i=Array.isArray(i)?i[0]:i;var o=jt(i,s);o!==-1&&t.push(o)}return t.length!==r.length?-1:t}function cf(r,e){var t=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(r.context.length<t)return[];var n=fn(e.inputCoverage,r);if(n===-1)return[];var s=e.inputCoverage.length-1;if(r.lookahead.length<e.lookaheadCoverage.length)return[];for(var i=r.lookahead.slice(s);i.length&&st(i[0].char);)i.shift();var o=new Ae(i,0),a=fn(e.lookaheadCoverage,o),u=[].concat(r.backtrack);for(u.reverse();u.length&&st(u[0].char);)u.shift();if(u.length<e.backtrackCoverage.length)return[];var l=new Ae(u,0),f=fn(e.backtrackCoverage,l),c=n.length===e.inputCoverage.length&&a.length===e.lookaheadCoverage.length&&f.length===e.backtrackCoverage.length,h=[];if(c)for(var p=0;p<e.lookupRecords.length;p++)for(var g=e.lookupRecords[p],m=g.lookupListIndex,x=this.getLookupByIndex(m),y=0;y<x.subtables.length;y++){var S=x.subtables[y],w=this.getLookupMethod(x,S),F=this.getSubstitutionType(x,S);if(F==="12")for(var P=0;P<n.length;P++){var U=r.get(P),O=w(U);O&&h.push(O)}}return h}function pf(r,e){var t=r.current,n=jt(t,e.coverage);if(n===-1)return null;for(var s,i=e.ligatureSets[n],o=0;o<i.length;o++){s=i[o];for(var a=0;a<s.components.length;a++){var u=r.lookahead[a],l=s.components[a];if(u!==l)break;if(a===s.components.length-1)return s}}return null}function df(r,e){var t=jt(r,e.coverage);return t===-1?null:e.sequences[t]}Ee.prototype.getDefaultScriptFeaturesIndexes=function(){for(var r=this.font.tables.gsub.scripts,e=0;e<r.length;e++){var t=r[e];if(t.tag==="DFLT")return t.script.defaultLangSys.featureIndexes}return[]};Ee.prototype.getScriptFeaturesIndexes=function(r){var e=this.font.tables;if(!e.gsub)return[];if(!r)return this.getDefaultScriptFeaturesIndexes();for(var t=this.font.tables.gsub.scripts,n=0;n<t.length;n++){var s=t[n];if(s.tag===r&&s.script.defaultLangSys)return s.script.defaultLangSys.featureIndexes;var i=s.langSysRecords;if(i)for(var o=0;o<i.length;o++){var a=i[o];if(a.tag===r){var u=a.langSys;return u.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()};Ee.prototype.mapTagsToFeatures=function(r,e){for(var t={},n=0;n<r.length;n++){var s=r[n].tag,i=r[n].feature;t[s]=i}this.features[e].tags=t};Ee.prototype.getScriptFeatures=function(r){var e=this.features[r];if(this.features.hasOwnProperty(r))return e;var t=this.getScriptFeaturesIndexes(r);if(!t)return null;var n=this.font.tables.gsub;return e=t.map(function(s){return n.features[s]}),this.features[r]=e,this.mapTagsToFeatures(e,r),e};Ee.prototype.getSubstitutionType=function(r,e){var t=r.lookupType.toString(),n=e.substFormat.toString();return t+n};Ee.prototype.getLookupMethod=function(r,e){var t=this,n=this.getSubstitutionType(r,e);switch(n){case"11":return function(s){return ff.apply(t,[s,e])};case"12":return function(s){return hf.apply(t,[s,e])};case"63":return function(s){return cf.apply(t,[s,e])};case"41":return function(s){return pf.apply(t,[s,e])};case"21":return function(s){return df.apply(t,[s,e])};default:throw new Error("lookupType: "+r.lookupType+" - substFormat: "+e.substFormat+" is not yet supported")}};Ee.prototype.lookupFeature=function(r){var e=r.contextParams,t=e.index,n=this.getFeature({tag:r.tag,script:r.script});if(!n)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+r.tag+"' for script '"+r.script+"'.");for(var s=this.getFeatureLookups(n),i=[].concat(e.context),o=0;o<s.length;o++)for(var a=s[o],u=this.getLookupSubtables(a),l=0;l<u.length;l++){var f=u[l],c=this.getSubstitutionType(a,f),h=this.getLookupMethod(a,f),p=void 0;switch(c){case"11":p=h(e.current),p&&i.splice(t,1,new dt({id:11,tag:r.tag,substitution:p}));break;case"12":p=h(e.current),p&&i.splice(t,1,new dt({id:12,tag:r.tag,substitution:p}));break;case"63":p=h(e),Array.isArray(p)&&p.length&&i.splice(t,1,new dt({id:63,tag:r.tag,substitution:p}));break;case"41":p=h(e),p&&i.splice(t,1,new dt({id:41,tag:r.tag,substitution:p}));break;case"21":p=h(e.current),p&&i.splice(t,1,new dt({id:21,tag:r.tag,substitution:p}));break}e=new Ae(i,t),!(Array.isArray(p)&&!p.length)&&(p=null)}return i.length?i:null};Ee.prototype.supports=function(r){if(!r.script)return!1;this.getScriptFeatures(r.script);var e=this.features.hasOwnProperty(r.script);if(!r.tag)return e;var t=this.features[r.script].some(function(n){return n.tag===r.tag});return e&&t};Ee.prototype.getLookupSubtables=function(r){return r.subtables||null};Ee.prototype.getLookupByIndex=function(r){var e=this.font.tables.gsub.lookups;return e[r]||null};Ee.prototype.getFeatureLookups=function(r){return r.lookupListIndexes.map(this.getLookupByIndex.bind(this))};Ee.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};this.features.hasOwnProperty(e.script)||this.getScriptFeatures(e.script);var t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:"No feature for script "+e.script}};function gf(r){var e=r.current,t=r.get(-1);return t===null&&nt(e)||!nt(t)&&nt(e)}function vf(r){var e=r.get(1);return e===null||!nt(e)}var mf={startCheck:gf,endCheck:vf};function xf(r){var e=r.current,t=r.get(-1);return(nt(e)||st(e))&&!nt(t)}function yf(r){var e=r.get(1);switch(!0){case e===null:return!0;case(!nt(e)&&!st(e)):var t=lf(e);if(!t)return!0;if(t){var n=!1;if(n=r.lookahead.some(function(s){return nt(s)||st(s)}),!n)return!0}break;default:return!1}}var bf={startCheck:xf,endCheck:yf};function Sf(r,e,t){e[t].setState(r.tag,r.substitution)}function wf(r,e,t){e[t].setState(r.tag,r.substitution)}function kf(r,e,t){r.substitution.forEach(function(n,s){var i=e[t+s];i.setState(r.tag,n)})}function Ef(r,e,t){var n=e[t];n.setState(r.tag,r.substitution.ligGlyph);for(var s=r.substitution.components.length,i=0;i<s;i++)n=e[t+i+1],n.setState("deleted",!0)}var Ks={11:Sf,12:wf,63:kf,41:Ef};function Mn(r,e,t){r instanceof dt&&Ks[r.id]&&Ks[r.id](r,e,t)}function Pf(r){for(var e=[].concat(r.backtrack),t=e.length-1;t>=0;t--){var n=e[t],s=Wi(n),i=st(n);if(!s&&!i)return!0;if(s)return!1}return!1}function Lf(r){if(Wi(r.current))return!1;for(var e=0;e<r.lookahead.length;e++){var t=r.lookahead[e],n=st(t);if(!n)return!0}return!1}function If(r){var e=this,t="arab",n=this.featuresTags[t],s=this.tokenizer.getRangeTokens(r);if(s.length!==1){var i=new Ae(s.map(function(a){return a.getState("glyphIndex")}),0),o=new Ae(s.map(function(a){return a.char}),0);s.forEach(function(a,u){if(!st(a.char)){i.setCurrentIndex(u),o.setCurrentIndex(u);var l=0;Pf(o)&&(l|=1),Lf(o)&&(l|=2);var f;switch(l){case 1:f="fina";break;case 2:f="init";break;case 3:f="medi";break}if(n.indexOf(f)!==-1){var c=e.query.lookupFeature({tag:f,script:t,contextParams:i});if(c instanceof Error)return console.info(c.message);c.forEach(function(h,p){h instanceof dt&&(Mn(h,s,p),i.context[p]=h.substitution)})}}})}}function Js(r,e){var t=r.map(function(n){return n.activeState.value});return new Ae(t,e||0)}function Tf(r){var e=this,t="arab",n=this.tokenizer.getRangeTokens(r),s=Js(n);s.context.forEach(function(i,o){s.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"rlig",script:t,contextParams:s});a.length&&(a.forEach(function(u){return Mn(u,n,o)}),s=Js(n))})}function Cf(r){var e=r.current,t=r.get(-1);return t===null&&Ir(e)||!Ir(t)&&Ir(e)}function Mf(r){var e=r.get(1);return e===null||!Ir(e)}var Of={startCheck:Cf,endCheck:Mf};function Qs(r,e){var t=r.map(function(n){return n.activeState.value});return new Ae(t,e||0)}function Ff(r){var e=this,t="latn",n=this.tokenizer.getRangeTokens(r),s=Qs(n);s.context.forEach(function(i,o){s.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"liga",script:t,contextParams:s});a.length&&(a.forEach(function(u){return Mn(u,n,o)}),s=Qs(n))})}function Re(r){this.baseDir=r||"ltr",this.tokenizer=new ie,this.featuresTags={}}Re.prototype.setText=function(r){this.text=r};Re.prototype.contextChecks={latinWordCheck:Of,arabicWordCheck:mf,arabicSentenceCheck:bf};function hn(r){var e=this.contextChecks[r+"Check"];return this.tokenizer.registerContextChecker(r,e.startCheck,e.endCheck)}function Af(){return hn.call(this,"latinWord"),hn.call(this,"arabicWord"),hn.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function Df(){var r=this,e=this.tokenizer.getContextRanges("arabicSentence");e.forEach(function(t){var n=r.tokenizer.getRangeTokens(t);r.tokenizer.replaceRange(t.startIndex,t.endOffset,n.reverse())})}Re.prototype.registerFeatures=function(r,e){var t=this,n=e.filter(function(s){return t.query.supports({script:r,tag:s})});this.featuresTags.hasOwnProperty(r)?this.featuresTags[r]=this.featuresTags[r].concat(n):this.featuresTags[r]=n};Re.prototype.applyFeatures=function(r,e){if(!r)throw new Error("No valid font was provided to apply features");this.query||(this.query=new Ee(r));for(var t=0;t<e.length;t++){var n=e[t];this.query.supports({script:n.script})&&this.registerFeatures(n.script,n.tags)}};Re.prototype.registerModifier=function(r,e,t){this.tokenizer.registerModifier(r,e,t)};function On(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function Uf(){var r=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){On.call(this);var t=this.tokenizer.getContextRanges("arabicWord");t.forEach(function(n){If.call(r,n)})}}function Rf(){var r=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("rlig")!==-1){On.call(this);var n=this.tokenizer.getContextRanges("arabicWord");n.forEach(function(s){Tf.call(r,s)})}}}function Nf(){var r=this,e="latn";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("liga")!==-1){On.call(this);var n=this.tokenizer.getContextRanges("latinWord");n.forEach(function(s){Ff.call(r,s)})}}}Re.prototype.checkContextReady=function(r){return!!this.tokenizer.getContext(r)};Re.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(Uf.call(this),Rf.call(this)),this.checkContextReady("latinWord")&&Nf.call(this),this.checkContextReady("arabicSentence")&&Df.call(this)};Re.prototype.processText=function(r){(!this.text||this.text!==r)&&(this.setText(r),Af.call(this),this.applyFeaturesToContexts())};Re.prototype.getBidiText=function(r){return this.processText(r),this.tokenizer.getText()};Re.prototype.getTextGlyphs=function(r){this.processText(r);for(var e=[],t=0;t<this.tokenizer.tokens.length;t++){var n=this.tokenizer.tokens[t];if(!n.state.deleted){var s=n.activeState.value;e.push(Array.isArray(s)?s[0]:s)}}return e};function J(r){r=r||{},r.tables=r.tables||{},r.empty||(Ht(r.familyName,"When creating a new Font object, familyName is required."),Ht(r.styleName,"When creating a new Font object, styleName is required."),Ht(r.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),Ht(r.ascender,"When creating a new Font object, ascender is required."),Ht(r.descender<=0,"When creating a new Font object, negative descender value is required."),this.names={fontFamily:{en:r.familyName||" "},fontSubfamily:{en:r.styleName||" "},fullName:{en:r.fullName||r.familyName+" "+r.styleName},postScriptName:{en:r.postScriptName||(r.familyName+r.styleName).replace(/\s/g,"")},designer:{en:r.designer||" "},designerURL:{en:r.designerURL||" "},manufacturer:{en:r.manufacturer||" "},manufacturerURL:{en:r.manufacturerURL||" "},license:{en:r.license||" "},licenseURL:{en:r.licenseURL||" "},version:{en:r.version||"Version 0.1"},description:{en:r.description||" "},copyright:{en:r.copyright||" "},trademark:{en:r.trademark||" "}},this.unitsPerEm=r.unitsPerEm||1e3,this.ascender=r.ascender,this.descender=r.descender,this.createdTimestamp=r.createdTimestamp,this.tables=Object.assign(r.tables,{os2:Object.assign({usWeightClass:r.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:r.widthClass||this.usWidthClasses.MEDIUM,fsSelection:r.fsSelection||this.fsSelectionValues.REGULAR},r.tables.os2)})),this.supported=!0,this.glyphs=new qe.GlyphSet(this,r.glyphs||[]),this.encoding=new fi(this),this.position=new Zt(this),this.substitution=new ke(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 zi(this)}})}J.prototype.hasChar=function(r){return this.encoding.charToGlyphIndex(r)!==null};J.prototype.charToGlyphIndex=function(r){return this.encoding.charToGlyphIndex(r)};J.prototype.charToGlyph=function(r){var e=this.charToGlyphIndex(r),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};J.prototype.updateFeatures=function(r){return this.defaultRenderOptions.features.map(function(e){return e.script==="latn"?{script:"latn",tags:e.tags.filter(function(t){return r[t]})}:e})};J.prototype.stringToGlyphs=function(r,e){var t=this,n=new Re,s=function(c){return t.charToGlyphIndex(c.char)};n.registerModifier("glyphIndex",null,s);var i=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;n.applyFeatures(this,i);for(var o=n.getTextGlyphs(r),a=o.length,u=new Array(a),l=this.glyphs.get(0),f=0;f<a;f+=1)u[f]=this.glyphs.get(o[f])||l;return u};J.prototype.nameToGlyphIndex=function(r){return this.glyphNames.nameToGlyphIndex(r)};J.prototype.nameToGlyph=function(r){var e=this.nameToGlyphIndex(r),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};J.prototype.glyphIndexToName=function(r){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(r):""};J.prototype.getKerningValue=function(r,e){r=r.index||r,e=e.index||e;var t=this.position.defaultKerningTables;return t?this.position.getKerningValue(t,r,e):this.kerningPairs[r+","+e]||0};J.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]};J.prototype.forEachGlyph=function(r,e,t,n,s,i){e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:72,s=Object.assign({},this.defaultRenderOptions,s);var o=1/this.unitsPerEm*n,a=this.stringToGlyphs(r,s),u;if(s.kerning){var l=s.script||this.position.getDefaultScriptName();u=this.position.getKerningTables(l,s.language)}for(var f=0;f<a.length;f+=1){var c=a[f];if(i.call(this,c,e,t,n,s),c.advanceWidth&&(e+=c.advanceWidth*o),s.kerning&&f<a.length-1){var h=u?this.position.getKerningValue(u,c.index,a[f+1].index):this.getKerningValue(c,a[f+1]);e+=h*o}s.letterSpacing?e+=s.letterSpacing*n:s.tracking&&(e+=s.tracking/1e3*n)}return e};J.prototype.getPath=function(r,e,t,n,s){var i=new fe;return this.forEachGlyph(r,e,t,n,s,function(o,a,u,l){var f=o.getPath(a,u,l,s,this);i.extend(f)}),i};J.prototype.getPaths=function(r,e,t,n,s){var i=[];return this.forEachGlyph(r,e,t,n,s,function(o,a,u,l){var f=o.getPath(a,u,l,s,this);i.push(f)}),i};J.prototype.getAdvanceWidth=function(r,e,t){return this.forEachGlyph(r,0,0,e,t,function(){})};J.prototype.draw=function(r,e,t,n,s,i){this.getPath(e,t,n,s,i).draw(r)};J.prototype.drawPoints=function(r,e,t,n,s,i){this.forEachGlyph(e,t,n,s,i,function(o,a,u,l){o.drawPoints(r,a,u,l)})};J.prototype.drawMetrics=function(r,e,t,n,s,i){this.forEachGlyph(e,t,n,s,i,function(o,a,u,l){o.drawMetrics(r,a,u,l)})};J.prototype.getEnglishName=function(r){var e=this.names[r];if(e)return e.en};J.prototype.validate=function(){var r=this;function e(n,s){}function t(n){var s=r.getEnglishName(n);s&&s.trim().length>0}t("fontFamily"),t("weightName"),t("manufacturer"),t("copyright"),t("version"),this.unitsPerEm>0};J.prototype.toTables=function(){return ku.fontToTable(this)};J.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};J.prototype.toArrayBuffer=function(){for(var r=this.toTables(),e=r.encode(),t=new ArrayBuffer(e.length),n=new Uint8Array(t),s=0;s<e.length;s++)n[s]=e[s];return t};J.prototype.download=function(r){var e=this.getEnglishName("fontFamily"),t=this.getEnglishName("fontSubfamily");r=r||e.replace(/\s/g,"")+"-"+t+".otf";var n=this.toArrayBuffer();if(Pu())if(window.URL=window.URL||window.webkitURL,window.URL){var s=new DataView(n),i=new Blob([s],{type:"font/opentype"}),o=document.createElement("a");o.href=window.URL.createObjectURL(i),o.download=r;var a=document.createEvent("MouseEvents");a.initEvent("click",!0,!1),o.dispatchEvent(a)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{var u=gs(),l=Lu(n);u.writeFileSync(r,l)}};J.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512};J.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};J.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function $i(r,e){var t=JSON.stringify(r),n=256;for(var s in e){var i=parseInt(s);if(!(!i||i<256)){if(JSON.stringify(e[s])===t)return i;n<=i&&(n=i+1)}}return e[n]=r,n}function Bf(r,e,t){var n=$i(e.name,t);return[{name:"tag_"+r,type:"TAG",value:e.tag},{name:"minValue_"+r,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+r,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+r,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+r,type:"USHORT",value:0},{name:"nameID_"+r,type:"USHORT",value:n}]}function Gf(r,e,t){var n={},s=new C.Parser(r,e);return n.tag=s.parseTag(),n.minValue=s.parseFixed(),n.defaultValue=s.parseFixed(),n.maxValue=s.parseFixed(),s.skip("uShort",1),n.name=t[s.parseUShort()]||{},n}function Hf(r,e,t,n){for(var s=$i(e.name,n),i=[{name:"nameID_"+r,type:"USHORT",value:s},{name:"flags_"+r,type:"USHORT",value:0}],o=0;o<t.length;++o){var a=t[o].tag;i.push({name:"axis_"+r+" "+a,type:"FIXED",value:e.coordinates[a]<<16})}return i}function zf(r,e,t,n){var s={},i=new C.Parser(r,e);s.name=n[i.parseUShort()]||{},i.skip("uShort",1),s.coordinates={};for(var o=0;o<t.length;++o)s.coordinates[t[o].tag]=i.parseFixed();return s}function Vf(r,e){var t=new I.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:r.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:r.instances.length},{name:"instanceSize",type:"USHORT",value:4+r.axes.length*4}]);t.offsetToData=t.sizeOf();for(var n=0;n<r.axes.length;n++)t.fields=t.fields.concat(Bf(n,r.axes[n],e));for(var s=0;s<r.instances.length;s++)t.fields=t.fields.concat(Hf(s,r.instances[s],r.axes,e));return t}function Xf(r,e,t){var n=new C.Parser(r,e),s=n.parseULong();N.argument(s===65536,"Unsupported fvar table version.");var i=n.parseOffset16();n.skip("uShort",1);for(var o=n.parseUShort(),a=n.parseUShort(),u=n.parseUShort(),l=n.parseUShort(),f=[],c=0;c<o;c++)f.push(Gf(r,e+i+c*a,t));for(var h=[],p=e+i+o*a,g=0;g<u;g++)h.push(zf(r,p+g*l,f,t));return{axes:f,instances:h}}var qf={make:Vf,parse:Xf},Wf=function(){return{coverage:this.parsePointer(v.coverage),attachPoints:this.parseList(v.pointer(v.uShortList))}},$f=function(){var r=this.parseUShort();if(N.argument(r===1||r===2||r===3,"Unsupported CaretValue table version."),r===1)return{coordinate:this.parseShort()};if(r===2)return{pointindex:this.parseShort()};if(r===3)return{coordinate:this.parseShort()}},Zf=function(){return this.parseList(v.pointer($f))},_f=function(){return{coverage:this.parsePointer(v.coverage),ligGlyphs:this.parseList(v.pointer(Zf))}},Yf=function(){return this.parseUShort(),this.parseList(v.pointer(v.coverage))};function jf(r,e){e=e||0;var t=new v(r,e),n=t.parseVersion(1);N.argument(n===1||n===1.2||n===1.3,"Unsupported GDEF table version.");var s={version:n,classDef:t.parsePointer(v.classDef),attachList:t.parsePointer(Wf),ligCaretList:t.parsePointer(_f),markAttachClassDef:t.parsePointer(v.classDef)};return n>=1.2&&(s.markGlyphSets=t.parsePointer(Yf)),s}var Kf={parse:jf},De=new Array(10);De[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(v.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(v.coverage),values:this.parseValueRecordList()};N.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};De[2]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();N.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var n=this.parsePointer(v.coverage),s=this.parseUShort(),i=this.parseUShort();if(t===1)return{posFormat:t,coverage:n,valueFormat1:s,valueFormat2:i,pairSets:this.parseList(v.pointer(v.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}})))};if(t===2){var o=this.parsePointer(v.classDef),a=this.parsePointer(v.classDef),u=this.parseUShort(),l=this.parseUShort();return{posFormat:t,coverage:n,valueFormat1:s,valueFormat2:i,classDef1:o,classDef2:a,class1Count:u,class2Count:l,classRecords:this.parseList(u,v.list(l,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}}))}}};De[3]=function(){return{error:"GPOS Lookup 3 not supported"}};De[4]=function(){return{error:"GPOS Lookup 4 not supported"}};De[5]=function(){return{error:"GPOS Lookup 5 not supported"}};De[6]=function(){return{error:"GPOS Lookup 6 not supported"}};De[7]=function(){return{error:"GPOS Lookup 7 not supported"}};De[8]=function(){return{error:"GPOS Lookup 8 not supported"}};De[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Jf(r,e){e=e||0;var t=new v(r,e),n=t.parseVersion(1);return N.argument(n===1||n===1.1,"Unsupported GPOS table version "+n),n===1?{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(De)}:{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(De),variations:t.parseFeatureVariationsList()}}var Qf=new Array(10);function eh(r){return new I.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new I.ScriptList(r.scripts)},{name:"features",type:"TABLE",value:new I.FeatureList(r.features)},{name:"lookups",type:"TABLE",value:new I.LookupList(r.lookups,Qf)}])}var th={parse:Jf,make:eh};function rh(r){var e={};r.skip("uShort");var t=r.parseUShort();N.argument(t===0,"Unsupported kern sub-table version."),r.skip("uShort",2);var n=r.parseUShort();r.skip("uShort",3);for(var s=0;s<n;s+=1){var i=r.parseUShort(),o=r.parseUShort(),a=r.parseShort();e[i+","+o]=a}return e}function nh(r){var e={};r.skip("uShort");var t=r.parseULong();t>1&&console.warn("Only the first kern subtable is supported."),r.skip("uLong");var n=r.parseUShort(),s=n&255;if(r.skip("uShort"),s===0){var i=r.parseUShort();r.skip("uShort",3);for(var o=0;o<i;o+=1){var a=r.parseUShort(),u=r.parseUShort(),l=r.parseShort();e[a+","+u]=l}}return e}function sh(r,e){var t=new C.Parser(r,e),n=t.parseUShort();if(n===0)return rh(t);if(n===1)return nh(t);throw new Error("Unsupported kern table version ("+n+").")}var ih={parse:sh};function oh(r,e,t,n){for(var s=new C.Parser(r,e),i=n?s.parseUShort:s.parseULong,o=[],a=0;a<t+1;a+=1){var u=i.call(s);n&&(u*=2),o.push(u)}return o}var ah={parse:oh};function ei(r,e){for(var t=[],n=12,s=0;s<e;s+=1){var i=C.getTag(r,n),o=C.getULong(r,n+4),a=C.getULong(r,n+8),u=C.getULong(r,n+12);t.push({tag:i,checksum:o,offset:a,length:u,compression:!1}),n+=16}return t}function uh(r,e){for(var t=[],n=44,s=0;s<e;s+=1){var i=C.getTag(r,n),o=C.getULong(r,n+4),a=C.getULong(r,n+8),u=C.getULong(r,n+12),l=void 0;a<u?l="WOFF":l=!1,t.push({tag:i,offset:o,compression:l,compressedLength:a,length:u}),n+=20}return t}function ae(r,e){if(e.compression==="WOFF"){var t=new Uint8Array(r.buffer,e.offset+2,e.compressedLength-2),n=new Uint8Array(e.length);if(ea(t,n),n.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");var s=new DataView(n.buffer,0);return{data:s,offset:0}}else return{data:r,offset:e.offset}}function Zi(r,e){e=e??{};var t,n,s=new J({empty:!0}),i=new DataView(r,0),o,a=[],u=C.getTag(i,0);if(u==="\0\0\0"||u==="true"||u==="typ1")s.outlinesFormat="truetype",o=C.getUShort(i,4),a=ei(i,o);else if(u==="OTTO")s.outlinesFormat="cff",o=C.getUShort(i,4),a=ei(i,o);else if(u==="wOFF"){var l=C.getTag(i,4);if(l==="\0\0\0")s.outlinesFormat="truetype";else if(l==="OTTO")s.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+u);o=C.getUShort(i,12),a=uh(i,o)}else throw new Error("Unsupported OpenType signature "+u);for(var f,c,h,p,g,m,x,y,S,w,F,P,U=0;U<o;U+=1){var O=a[U],L=void 0;switch(O.tag){case"cmap":L=ae(i,O),s.tables.cmap=li.parse(L.data,L.offset),s.encoding=new hi(s.tables.cmap);break;case"cvt ":L=ae(i,O),P=new C.Parser(L.data,L.offset),s.tables.cvt=P.parseShortList(O.length/2);break;case"fvar":c=O;break;case"fpgm":L=ae(i,O),P=new C.Parser(L.data,L.offset),s.tables.fpgm=P.parseByteList(O.length);break;case"head":L=ae(i,O),s.tables.head=Si.parse(L.data,L.offset),s.unitsPerEm=s.tables.head.unitsPerEm,t=s.tables.head.indexToLocFormat;break;case"hhea":L=ae(i,O),s.tables.hhea=wi.parse(L.data,L.offset),s.ascender=s.tables.hhea.ascender,s.descender=s.tables.hhea.descender,s.numberOfHMetrics=s.tables.hhea.numberOfHMetrics;break;case"hmtx":x=O;break;case"ltag":L=ae(i,O),n=Ei.parse(L.data,L.offset);break;case"maxp":L=ae(i,O),s.tables.maxp=Pi.parse(L.data,L.offset),s.numGlyphs=s.tables.maxp.numGlyphs;break;case"name":w=O;break;case"OS/2":L=ae(i,O),s.tables.os2=yn.parse(L.data,L.offset);break;case"post":L=ae(i,O),s.tables.post=Oi.parse(L.data,L.offset),s.glyphNames=new Pn(s.tables.post);break;case"prep":L=ae(i,O),P=new C.Parser(L.data,L.offset),s.tables.prep=P.parseByteList(O.length);break;case"glyf":h=O;break;case"loca":S=O;break;case"CFF ":f=O;break;case"kern":y=O;break;case"GDEF":p=O;break;case"GPOS":g=O;break;case"GSUB":m=O;break;case"meta":F=O;break}}var W=ae(i,w);if(s.tables.name=Mi.parse(W.data,W.offset,n),s.names=s.tables.name,h&&S){var _=t===0,Y=ae(i,S),he=ah.parse(Y.data,Y.offset,s.numGlyphs,_),ce=ae(i,h);s.glyphs=Bi.parse(ce.data,ce.offset,he,s,e)}else if(f){var Q=ae(i,f);bi.parse(Q.data,Q.offset,s,e)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");var X=ae(i,x);if(ki.parse(s,X.data,X.offset,s.numberOfHMetrics,s.numGlyphs,s.glyphs,e),Sa(s,e),y){var ee=ae(i,y);s.kerningPairs=ih.parse(ee.data,ee.offset)}else s.kerningPairs={};if(p){var k=ae(i,p);s.tables.gdef=Kf.parse(k.data,k.offset)}if(g){var M=ae(i,g);s.tables.gpos=th.parse(M.data,M.offset),s.position.init()}if(m){var A=ae(i,m);s.tables.gsub=Fi.parse(A.data,A.offset)}if(c){var G=ae(i,c);s.tables.fvar=qf.parse(G.data,G.offset,s.names)}if(F){var D=ae(i,F);s.tables.meta=Ai.parse(D.data,D.offset),s.metas=s.tables.meta}return s}var Rr=class{constructor(e,t){this.sources=e;this.fallback=t;this.parsed=new Map;this.missing=new Set}names(){return Object.keys(this.sources)}get(e){let t=e||this.fallback||Object.keys(this.sources)[0];if(!t)throw this.missing.add(""),new Error("text() needs a font. Pass fonts to render(), or --font on the command line.");let n=this.parsed.get(t);if(n)return n;let s=this.sources[t];if(!s)throw this.missing.add(t),new Error(`Font "${t}" is not available.${this.names().length?` Available fonts: ${this.names().join(", ")}`:""}`);let i=s instanceof Uint8Array?s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength):s,o=Zi(i);return this.parsed.set(t,o),o}};function _i(r,e,t){let n={kerning:!0};if(t.spacing===1)return{cmds:r.getPath(e,0,0,t.size,n).commands,advance:r.getAdvanceWidth(e,t.size,n)};let s=[],i=0,o=[...e];return o.forEach((a,u)=>{s.push(...r.getPath(a,i,0,t.size,n).commands),i+=r.getAdvanceWidth(a,t.size,n)*(u<o.length-1?t.spacing:1)}),{cmds:s,advance:i}}function Fn(r,e,t){if(!e)return[];let n=r.get(t.font),{cmds:s,advance:i}=_i(n,e,t),o=s.map(h=>h.type==="Z"?h:h.type==="C"?{...h,y1:-h.y1,y2:-h.y2,y:-h.y}:h.type==="Q"?{...h,y1:-h.y1,y:-h.y}:{...h,y:-h.y}),a=br(o,Math.max(.005,t.size/2e3)),u=de([...a.closed,...a.open.filter(h=>h.length>=3)]),l=vr(u);if(!l)return[];let f=t.halign==="center"?-i/2:t.halign==="right"?-i:0,c=t.valign==="top"?-l[3]:t.valign==="center"?-(l[1]+l[3])/2:t.valign==="bottom"?-l[1]:0;return u.map(h=>h.map(([p,g])=>[p+f,g+c]))}function Yi(r,e,t){let n=r.get(t.font),{advance:s}=_i(n,e,t),i=Fn(r,e,{...t,halign:"left",valign:"baseline"}),o=vr(i)??[0,0,0,0];return{advance:s,bounds:[[o[0],o[1]],[o[2],o[3]]],ascent:n.ascender/n.unitsPerEm*t.size,descent:n.descender/n.unitsPerEm*t.size}}var An=[{name:"engrave",mode:"fill",color:"#000000"},{name:"score",mode:"line",color:"#0000ff"},{name:"cut",mode:"cut",color:"#ff0000"},{name:"guide",mode:"guide",color:"#00a0ff"}],Dn={maxParts:1e4,maxSegments:1e4,maxListLength:1e6,maxListItems:3e6,maxTextLength:2e3,maxPoints:2e6,maxOutputPoints:1e6,maxSheets:200},lh=100,Kt=4,ji=8,fh=r=>{let e=lh,t=n=>{for(let s of n.values()){for(let i of s.regions)e+=i.length;for(let i of s.lines)e+=i.length}};t(r.layers);for(let n of r.parts)t(n.layers);return e},ve=class{constructor(e,t){this.parent=e;this.caller=t;this.vars=new Map;this.fns=new Map;this.mods=new Map}get(e){let t=this,n=e.startsWith("$");for(;t;){if(t.vars.has(e))return{found:!0,value:t.vars.get(e)};t=n?t.caller??t.parent:t.parent}return{found:!1}}fn(e){for(let t=this;t;t=t.parent){let n=t.fns.get(e);if(n)return n}}mod(e){for(let t=this;t;t=t.parent){let n=t.mods.get(e);if(n)return n}}childCtx(){for(let e=this;e;e=e.parent)if(e.children)return e.children}},hh=cs,Nr=class{constructor(e={}){this.opts=e;this.steps=0;this.depth=0;this.pointCount=0;this.itemCount=0;this.copies=0;this.echoes=[];this.warnings=[];this.layers=new Map(An.map(e=>[e.name,e]));this.loaded=new Map;this.maxSteps=e.maxSteps??5e6,this.limits={...Dn,...e.limits},this.builtins=this.makeBuiltins()}run(e){let t=new ve,n={$fn:0,$fa:2,$fs:.2,$thickness:3,$kerf:0,$material:"material",$sheet:[600,400],$gap:3,$layout:"pack",PI:Math.PI};for(let[o,a]of Object.entries(n))t.vars.set(o,a);let s=new ve(t);return{shape:this.block(e.body,s,!0),globals:s,layers:this.layers,echoes:this.echoes,warnings:this.warnings}}tick(e){if(++this.steps>this.maxSteps)throw new R(`Stopped after ${this.maxSteps} steps. Is there an endless loop?`,e)}load(e,t){let n=this.loaded.get(e);if(n)return n;let s=hh[e]??this.opts.resolve?.(e);if(s===void 0)throw new R(`Library <${e}> not found`,t);this.loaded.set(e,{body:[]});let{program:i}=Je(s);return this.loaded.set(e,i),i}hoist(e,t){for(let n of e)if(n.kind==="module")t.mods.set(n.name,{params:n.params,body:n.body,env:t});else if(n.kind==="function")t.fns.set(n.name,{params:n.params,body:n.body,env:t});else if(n.kind==="use"&&!n.include){let s=this.included(this.load(n.path,n.pos).body,new Set([n.path])),i=new ve(t);this.hoist(s,i);for(let o of s)o.kind==="assign"&&this.assign(o.name,this.expr(o.value,i),i);for(let[o,a]of i.mods)t.mods.set(o,a);for(let[o,a]of i.fns)t.fns.set(o,a)}}included(e,t){let n=[];for(let s of e)if(s.kind!=="use"||!s.include)n.push(s);else if(!t.has(s.path)){t.add(s.path);for(let i of this.included(this.load(s.path,s.pos).body,t))n.push(i)}return n}assign(e,t,n){n.vars.set(e,t)}block(e,t,n=!1){this.hoist(e,t);let s=[];for(let i of e){let o=this.stmt(i,t,n);o&&!ts(o)&&s.push(o)}return s.length===1?s[0]:Nt(s)}stmt(e,t,n=!1){switch(this.tick(e.pos),e.kind){case"assign":{let s=this.opts.overrides,i=n&&s&&Object.prototype.hasOwnProperty.call(s,e.name)?s[e.name]:this.expr(e.value,t);return this.assign(e.name,i,t),null}case"module":case"function":return null;case"use":{if(!e.include)return null;let s=this.load(e.path,e.pos);return this.block(s.body,t)}case"block":return this.block(e.body,new ve(t));case"if":return Se(this.expr(e.cond,t))?this.block(e.then,new ve(t)):this.block(e.else,new ve(t));case"let":{let s=new ve(t);return this.bindSeq(e.assigns,s),this.block(e.body,s)}case"for":{let s=[];return this.loop(e.assigns,t,i=>s.push(this.block(e.body,i))),Nt(s)}case"call":if(e.modifier==="*")return null;{let s=this.callModule(e,t);return e.modifier==="#"||e.modifier==="%"?gr(s,"guide"):s}}}bindSeq(e,t){for(let n of e)this.assign(n.name,this.expr(n.value,t),t)}iterable(e,t){if(Be(e))try{return er(e,1e6)}catch(n){throw new R(n.message,t)}return Array.isArray(e)?e:typeof e=="string"?[...e]:e===void 0?[]:[e]}loop(e,t,n,s=0,i=new ve(t)){if(s===e.length)return n(i);let o=e[s];for(let a of this.iterable(this.expr(o.value,i),o.pos)){this.tick(o.pos);let u=new ve(i);u.vars.set(o.name,a),this.loop(e,t,n,s+1,u)}}evalArgs(e,t,n){let s=[],i=new Map;for(let o of e){let a=this.expr(o.value,t);o.name===null?s.push(a):i.set(o.name,a)}return{pos:s,named:i,at:n}}bindParams(e,t,n,s,i){let o=new Set(e.map(a=>a.name));e.forEach((a,u)=>{let l;t.named.has(a.name)?l=t.named.get(a.name):u<t.pos.length?l=t.pos[u]:l=a.default?this.expr(a.default,n):void 0,n.vars.set(a.name,l)});for(let a of t.named.keys())if(a.startsWith("$"))n.vars.set(a,t.named.get(a));else if(!o.has(a)){let u=`${i}: unknown argument "${a}" (line ${t.at.line})`;this.warnings.includes(u)||this.warnings.push(u)}}callModule(e,t){let n=this.evalArgs(e.args,t,e.pos),s=t.mod(e.name);if(s){if(++this.depth>1e3)throw new R(`Recursion too deep in module ${e.name}()`,e.pos);try{let c=new ve(s.env,t);return this.bindParams(s.params,n,c,s.env,`${e.name}()`),c.children={stmts:e.children,env:t},c.vars.set("$children",this.childStmts(e.children).length),this.block(s.body,c)}finally{this.depth--}}let i=this.builtins[e.name];if(!i){let c=e.name==="color"?" Use layer(), cut(), score() or engrave() instead.":e.name==="square"?" Use rect().":"";throw new R(`Unknown module ${e.name}().${c}`,e.pos)}let o=new ve(t,t);for(let[c,h]of n.named)c.startsWith("$")&&o.vars.set(c,h);let a=this.childStmts(e.children),u=()=>new ve(t,o),l={args:n,env:o,children:()=>e.children.length?this.block(e.children,u()):ht(),childList:()=>{let c=u();this.hoist(e.children,c);let h=[];for(let p of e.children){let g=this.stmt(p,c);a.includes(p)&&h.push(g??ht())}return h}},f;try{f=i(l)}catch(c){throw c instanceof R?c:new R(`${e.name}(): ${c.message}`,e.pos)}if(this.pointCount+=fh(f),this.pointCount>this.limits.maxPoints)throw new R(`The shapes have more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes, or a lower $fn.`,e.pos);return f}childStmts(e){return e.filter(t=>t.kind!=="assign"&&t.kind!=="module"&&t.kind!=="function"&&t.kind!=="use")}callFunction(e,t,n,s){if(++this.depth>2e3)throw new R(`Recursion too deep in ${s}()`,t.at);try{this.tick(t.at);let i=_e(e)?e.scope:e.env,o=new ve(i,n);return this.bindParams(e.params,t,o,i,`${s}()`),this.expr(e.body,o)}finally{this.depth--}}expr(e,t){switch(e.kind){case"num":case"str":case"bool":return e.value;case"undef":return;case"var":{let n=t.get(e.name);if(n.found)return n.value;let s=t.fn(e.name);if(s)return{type:"function",params:s.params,body:s.body,scope:s.env,name:e.name};if(e.name.startsWith("$"))return;throw new R(`Unknown variable "${e.name}"`,e.pos)}case"list":{let n=[];for(let s of e.items)this.listItem(s,t,n,e.pos);return this.charge(Kt,e.pos),n}case"range":{let n=this.expr(e.start,t),s=this.expr(e.end,t),i=e.step?this.expr(e.step,t):1;if(typeof n!="number"||typeof s!="number"||typeof i!="number")throw new R("Range values must be numbers",e.pos);return{type:"range",start:n,step:i,end:s}}case"unary":{let n=this.expr(e.arg,t);return e.op==="!"?!Se(n):e.op==="+"?n:this.arith("*",-1,n,e.pos)}case"binary":{if(e.op==="&&")return Se(this.expr(e.left,t))&&Se(this.expr(e.right,t));if(e.op==="||")return Se(this.expr(e.left,t))||Se(this.expr(e.right,t));let n=this.expr(e.left,t),s=this.expr(e.right,t);if(e.op==="==")return at(n,s);if(e.op==="!=")return!at(n,s);if(e.op==="<"||e.op==="<="||e.op===">"||e.op===">="){if(!(typeof n=="number"&&typeof s=="number"||typeof n=="string"&&typeof s=="string"))throw new R(`Can't compare ${Pe(n)} ${e.op} ${Pe(s)}`,e.pos);return e.op==="<"?n<s:e.op==="<="?n<=s:e.op===">"?n>s:n>=s}return this.arith(e.op,n,s,e.pos)}case"ternary":return Se(this.expr(e.cond,t))?this.expr(e.then,t):this.expr(e.else,t);case"index":{let n=this.expr(e.target,t),s=this.expr(e.index,t);if(typeof s!="number")throw new R(`List index must be a number, got ${Pe(s)}`,e.pos);return Array.isArray(n)?n[Math.floor(s)]:typeof n=="string"?[...n][Math.floor(s)]:Be(n)?[n.start,n.step,n.end][Math.floor(s)]:void 0}case"member":{let n=this.expr(e.target,t),s={x:0,y:1,z:2}[e.name];return Array.isArray(n)&&s!==void 0?n[s]:Be(n)&&(e.name==="begin"||e.name==="step"||e.name==="end")?e.name==="begin"?n.start:e.name==="step"?n.step:n.end:void 0}case"call":return this.call(e,t);case"lambda":return{type:"function",params:e.params,body:e.body,scope:t};case"let":{let n=new ve(t);return this.bindSeq(e.assigns,n),this.expr(e.body,n)}}}listItem(e,t,n,s){switch(e.kind){case"item":{let i=this.expr(e.expr,t);this.grow(n,1,s),n.push(i);return}case"each":{let i=this.iterable(this.expr(e.expr,t),s);this.grow(n,i.length,s);for(let o of i)n.push(o);return}case"for":this.loop(e.assigns,t,i=>this.listItem(e.body,i,n,s));return;case"if":Se(this.expr(e.cond,t))?this.listItem(e.then,t,n,s):e.else&&this.listItem(e.else,t,n,s);return;case"let":{let i=new ve(t);this.bindSeq(e.assigns,i),this.listItem(e.body,i,n,s)}}}grow(e,t,n){if(e.length+t>this.limits.maxListLength)throw new R(`a list of ${e.length+t} items is more than the limit of ${this.limits.maxListLength}`,n);this.charge(t,n)}charge(e,t){if(this.itemCount+=e,!(this.itemCount<=this.limits.maxListItems))throw new R(`The lists and strings hold more than ${this.limits.maxListItems} items in all, the limit. Is a loop building more than it needs?`,t)}call(e,t){if(e.callee.kind==="var"){let s=e.callee.name,i=t.get(s);if(!i.found){let o=t.fn(s);if(o)return this.callFunction(o,this.evalArgs(e.args,t,e.pos),t,s);let a=this.specialFunction(s,e,t);if(a.handled)return a.value;let u=Vn[s];if(u){let l=this.evalArgs(e.args,t,e.pos),f;try{f=u(l.pos,l.named)}catch(c){throw new R(c instanceof RangeError?`${s}(): the result is too large`:c.message,e.pos)}return this.checkValue(f,e.pos,s),f}throw new R(`Unknown function ${s}()`,e.pos)}if(!_e(i.value))throw new R(`"${s}" is a ${Pe(i.value)}, not a function`,e.pos);return this.callFunction(i.value,this.evalArgs(e.args,t,e.pos),t,s)}let n=this.expr(e.callee,t);if(!_e(n))throw new R(`Can't call a ${Pe(n)}`,e.pos);return this.callFunction(n,this.evalArgs(e.args,t,e.pos),t,"function")}specialFunction(e,t,n){if(e==="echo"){let s=this.evalArgs(t.args,n,t.pos);return this.echo(this.echoText(s),t.pos),{handled:!0,value:void 0}}if(e==="assert"){let s=this.evalArgs(t.args,n,t.pos);if(!Se(s.pos[0]))throw new R(`Assertion failed${s.pos[1]!==void 0?": "+(typeof s.pos[1]=="string"?s.pos[1]:Le(s.pos[1])):""}`,t.pos);return{handled:!0,value:!0}}if(e==="text_width"||e==="text_metrics"){let s=this.evalArgs(t.args,n,t.pos),i=this.measure(s,n);return e==="text_width"?{handled:!0,value:i.advance}:{handled:!0,value:[i.advance,i.bounds,i.ascent,i.descent]}}if(e==="finger_count"){let s=this.evalArgs(t.args,n,t.pos),i=this.num(this.arg(s,"length",0),"finger_count","length");return{handled:!0,value:xr(i,this.fingerWidth(s,n,1))}}return{handled:!1}}echo(e,t){this.charge(Math.ceil(e.length/ji),t),this.echoes.push(e)}echoText(e){let t=e.pos.map(n=>typeof n=="string"?n:Le(n));for(let[n,s]of e.named)t.push(`${n} = ${Le(s)}`);return t.join(", ")}arith(e,t,n,s){if(typeof t=="number"&&typeof n=="number")switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n;case"%":return t%n;case"^":return Math.pow(t,n)}if(e==="+"&&typeof t=="string"&&typeof n=="string")return this.checkSize(t.length+n.length,!0,s),t+n;if(Array.isArray(t)&&Array.isArray(n)){if(e==="+"||e==="-"){if(t.length!==n.length)throw new R(`Can't ${e==="+"?"add":"subtract"} lists of length ${t.length} and ${n.length}`,s);return this.charge(t.length+Kt,s),t.map((o,a)=>this.arith(e,o,n[a],s))}if(e==="*"){if(Array.isArray(t[0]))return t.map(o=>this.arith("*",o,n,s));if(Array.isArray(n[0])){let o=n[0].length;return this.checkSize(o,!1,s),Array.from({length:o},(a,u)=>t.reduce((l,f,c)=>l+this.arith("*",f,n[c][u],s),0))}if(t.length!==n.length)throw new R(`Can't multiply lists of length ${t.length} and ${n.length}`,s);return t.reduce((o,a,u)=>o+this.arith("*",a,n[u],s),0)}}if(Array.isArray(t)&&typeof n=="number"&&(e==="*"||e==="/"))return this.charge(t.length+Kt,s),t.map(o=>this.arith(e,o,n,s));if(typeof t=="number"&&Array.isArray(n)&&e==="*")return this.charge(n.length+Kt,s),n.map(o=>this.arith(e,t,o,s));let i={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"take remainder of","^":"raise"};throw new R(`Can't ${i[e]??e} ${Pe(t)} and ${Pe(n)}`,s)}arg(e,t,n,s){return e.named.has(t)?e.named.get(t):n>=0&&n<e.pos.length?e.pos[n]:s}num(e,t,n){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${n} must be a finite number, got ${Le(e)}`);return e}vec2(e,t,n=!0){let s=i=>typeof i=="number"&&Number.isFinite(i);if(s(e)&&n)return[e,e];if(Array.isArray(e)&&s(e[0])&&(e[1]===void 0||s(e[1])))return[e[0],e[1]??0];throw new Error(`${t} must be a number or [x, y], got ${Le(e)}`)}points(e,t){if(!Array.isArray(e))throw new Error(`${t} must be a list of [x, y] points`);return e.map((n,s)=>{if(!Array.isArray(n)||!Number.isFinite(n[0])||!Number.isFinite(n[1]))throw new Error(`${t}[${s}] must be an [x, y] point, got ${Le(n)}`);return[n[0],n[1]]})}dyn(e,t){return e.get(t).value}spend(e){if(this.pointCount+=e,!(this.pointCount<=this.limits.maxPoints))throw new Error(`the shapes need more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes.`)}checkValue(e,t,n){(Array.isArray(e)||typeof e=="string")&&this.checkSize(e.length,typeof e=="string",t,n)}checkSize(e,t,n,s){if(e>this.limits.maxListLength)throw new R(`${s?`${s}(): `:""}${t?`a string of ${e} characters`:`a list of ${e} items`} is more than the limit of ${this.limits.maxListLength}`,n);this.charge(t?Math.ceil(e/ji):e+Kt,n)}segs(e){let t=Number(this.dyn(e,"$fn"))||0,n=Number(this.dyn(e,"$fa"))||2,s=Number(this.dyn(e,"$fs"))||.2,i=this.limits.maxSegments;return o=>{let a=os(o,t,n,s);if(!(a<=i))throw new Error(`a circle with ${a} segments is more than the limit of ${i}. Lower $fn, or raise $fa or $fs.`);return a}}thickness(e){let t=this.dyn(e,"$thickness");if(typeof t!="number"||t<=0)throw new Error("$thickness must be a positive number");return t}fingerWidth(e,t,n){let s=this.arg(e,"finger",n);return typeof s=="number"&&s>0?s:Math.max(3*this.thickness(t),6)}measure(e,t){if(!this.opts.fonts)throw new R("text needs a font. Pass fonts to render(), or --font on the command line.",e.at);let n=String(this.arg(e,"text",0,""));try{return Yi(this.opts.fonts,n,this.textOpts(e,t))}catch(s){throw s instanceof R?s:new R(s.message,e.at)}}textOpts(e,t){return{size:this.num(this.arg(e,"size",1,10),"text","size"),font:String(this.arg(e,"font",2,this.dyn(t,"$font")??"")),halign:String(this.arg(e,"halign",-1,"left")),valign:String(this.arg(e,"valign",-1,"baseline")),spacing:Number(this.arg(e,"spacing",-1,1))}}edges(e){let t=n=>{if(n==="out"||n==="in"||n==="flat")return n;throw new Error(`edges must be "out", "in" or "flat", got ${Le(n)}`)};if(typeof e=="string")return[t(e),t(e),t(e),t(e)];if(Array.isArray(e)&&e.length===4)return e.map(t);throw new Error("edges must be one value or a list of 4: [bottom, right, top, left]")}makeBuiltins(){let e=(i,o)=>dr(i.children(),o),t=i=>o=>gr(o.children(),i);return{rect:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0,1),"size"),u=Number(this.arg(i.args,"r",-1,0))||0,l=Se(this.arg(i.args,"center",1,!1)),f=as(o,a,u,this.segs(i.env));return Te(de([l?f.map(([c,h])=>[c-o/2,h-a/2]):f]))},square:i=>this.builtins.rect(i),circle:i=>{let o=this.arg(i.args,"d",-1),a=o!==void 0?this.num(o,"circle","d")/2:this.num(this.arg(i.args,"r",0,1),"circle","r");return Te([mr(a,a,this.segs(i.env)(a))])},ellipse:i=>{let[o,a]=this.vec2(this.arg(i.args,"r",0,1),"r");return Te([mr(o,a,this.segs(i.env)(Math.max(o,a)))])},regular_polygon:i=>{let o=Math.max(3,Math.floor(this.num(this.arg(i.args,"n",0,6),"regular_polygon","n"))),a=this.num(this.arg(i.args,"r",1,10),"regular_polygon","r");if(!(o<=this.limits.maxSegments))throw new Error(`${o} corners is more than the limit of ${this.limits.maxSegments}`);return Te([mr(a,a,o)])},star:i=>{let o=Math.max(2,Math.floor(this.num(this.arg(i.args,"n",0,5),"star","n"))),a=this.num(this.arg(i.args,"r",1,10),"star","r"),u=this.num(this.arg(i.args,"inner",2,a*.45),"star","inner");if(!(o*2<=this.limits.maxSegments))throw new Error(`${o} points is more than the limit of ${this.limits.maxSegments/2}`);let l=[];for(let f=0;f<o*2;f++){let c=Math.PI/2+Math.PI*f/o,h=f%2?u:a;l.push([h*Math.cos(c),h*Math.sin(c)])}return Te(de([l]))},polygon:i=>{let o=this.points(this.arg(i.args,"points",0),"points"),a=this.arg(i.args,"paths",1),u=Array.isArray(a)?a.map(l=>(Array.isArray(l)?l:[]).map(f=>o[Number(f)]).filter(Boolean)):[o];return Te(de(u,"evenodd"))},path:i=>{let o=this.arg(i.args,"d",0);if(typeof o!="string")throw new Error('path() needs SVG path data, like path("M0 0 L10 0 L5 8 Z")');let a=br(ps(o),.01),u=String(this.arg(i.args,"fill",-1,"evenodd"))==="nonzero"?"nonzero":"evenodd";return Nt([Te(de(a.closed,u)),bt(a.open)])},line:i=>{let o=this.vec2(this.arg(i.args,"from",0,[0,0]),"from",!1),a=this.vec2(this.arg(i.args,"to",1,[10,0]),"to",!1);return bt([[o,a]])},polyline:i=>{let o=this.points(this.arg(i.args,"points",0),"points"),a=Se(this.arg(i.args,"closed",1,!1));return bt([a&&o.length?[...o,o[0]]:o])},arc:i=>{let o=this.num(this.arg(i.args,"r",0,10),"arc","r"),a=this.num(this.arg(i.args,"start",1,0),"arc","start"),u=this.num(this.arg(i.args,"end",2,90),"arc","end"),l=Math.max(2,Math.ceil(this.segs(i.env)(o)*Math.abs(u-a)/360));if(!(l<=this.limits.maxSegments))throw new Error(`an arc with ${l} segments is more than the limit of ${this.limits.maxSegments}`);let f=[];for(let c=0;c<=l;c++){let h=(a+(u-a)*c/l)*Math.PI/180;f.push([o*Math.cos(h),o*Math.sin(h)])}return bt([f])},text:i=>{if(!this.opts.fonts)throw new Error("text() needs a font. Pass fonts to render(), or --font on the command line.");let o=this.arg(i.args,"text",0,""),a=typeof o=="string"?o:Le(o);if(a.length>this.limits.maxTextLength)throw new Error(`${a.length} characters is more than the limit of ${this.limits.maxTextLength} for one text()`);return Te(Fn(this.opts.fonts,a,this.textOpts(i.args,i.env)))},translate:i=>{let[o,a]=this.vec2(this.arg(i.args,"v",0,[0,0]),"v",!1);return e(i,[1,0,0,1,o,a])},rotate:i=>{let o=this.arg(i.args,"a",0,0),u=(Array.isArray(o)?Number(o[2]??0):this.num(o,"rotate","a"))*Math.PI/180,l=Math.cos(u),f=Math.sin(u),c=this.arg(i.args,"center",-1),h=[l,f,-f,l,0,0];if(c!==void 0){let[p,g]=this.vec2(c,"center",!1);h=[l,f,-f,l,p-l*p+f*g,g-f*p-l*g]}return e(i,h)},scale:i=>{let[o,a]=this.vec2(this.arg(i.args,"v",0,1),"v");return e(i,[o,0,0,a,0,0])},mirror:i=>{let[o,a]=this.vec2(this.arg(i.args,"v",0,[1,0]),"v",!1),u=Math.hypot(o,a)||1,l=o/u,f=a/u;return e(i,[1-2*l*l,-2*l*f,-2*l*f,1-2*f*f,0,0])},multmatrix:i=>{let o=this.arg(i.args,"m",0);if(!Array.isArray(o)||o.length<2)throw new Error("m must be a 2x3 or 3x3 matrix");let a=o[0],u=o[1];return e(i,[a[0],u[0],a[1],u[1],a[2]??0,u[2]??0])},union:i=>i.children(),group:i=>i.children(),difference:i=>{let[o,...a]=i.childList();if(!o)return ht();let u=n(a,"difference");return s(o,l=>({regions:hr(l.regions,u.regions),lines:Rt(l.lines,de(u.regions),"outside")}))},intersection:i=>{let[o,...a]=i.childList();if(!o)return ht();let u=o;for(let l of a){let f=de(n([l],"intersection").regions);u=s(u,c=>({regions:cr(c.regions,f),lines:Rt(c.lines,f,"inside")}))}return u},hull:i=>{let o=i.children(),a=[],u="cut",l=!0;for(let[c,h]of o.layers){l&&(h.regions.length||h.lines.length)&&(u=c,l=!1);for(let p of[...h.regions,...h.lines])for(let g of p)a.push(g)}let f=is(a);return{layers:new Map([[u,{regions:f.length>=3?[f]:[],lines:[]}]]),parts:o.parts}},offset:i=>{let o=this.arg(i.args,"r",0),a=this.arg(i.args,"delta",-1),u=Se(this.arg(i.args,"chamfer",-1,!1)),l=o!==void 0?this.num(o,"offset","r"):this.num(a??0,"offset","delta"),f=o!==void 0?"round":u?"square":"miter";return s(i.children(),c=>({regions:pr(c.regions,l,f),lines:c.lines}))},stroke:i=>{let o=this.num(this.arg(i.args,"width",0,1),"stroke","width");return s(i.children(),a=>({regions:de([...a.regions,...ns(a.lines,o)]),lines:[]}))},outline:i=>s(i.children(),o=>({regions:[],lines:[...o.lines,...de(o.regions).map(a=>[...a,a[0]])]})),cut:t("cut"),score:t("score"),engrave:t("engrave"),guide:t("guide"),layer:i=>{let o=this.arg(i.args,"name",0);if(typeof o!="string"||!o)throw new Error("layer() needs a name");let a=this.arg(i.args,"mode",1),u=this.arg(i.args,"color",2),l=this.layers.get(o);if(a!==void 0||u!==void 0||!l){let f=a??l?.mode??"line";if(!["cut","line","fill","guide"].includes(f))throw new Error('mode must be "cut", "line", "fill" or "guide"');let c=String(u??l?.color??"#00aa00");if(!/^#[0-9a-fA-F]{6}$/.test(c))throw new Error('color must look like "#00aa00"');this.layers.set(o,{name:o,mode:f,color:c})}return gr(i.children(),o)},part:i=>{let o=String(this.arg(i.args,"name",0,"part")),a=Math.max(1,Math.floor(Number(this.arg(i.args,"qty",1,1))||1));if(this.copies+=a,!(this.copies<=this.limits.maxParts))throw new Error(`more than ${this.limits.maxParts} part copies in total, the limit`);let u=i.children();return{layers:new Map,parts:[...u.parts,{name:o,qty:a,layers:u.layers,thickness:this.thickness(i.env),kerf:Number(this.dyn(i.env,"$kerf"))||0,material:String(this.dyn(i.env,"$material")??"material")}]}},material:i=>{let o=this.arg(i.args,"thickness",0),a=this.arg(i.args,"kerf",1),u=this.arg(i.args,"name",2);return o!==void 0&&i.env.vars.set("$thickness",this.num(o,"material","thickness")),a!==void 0&&i.env.vars.set("$kerf",this.num(a,"material","kerf")),u!==void 0&&i.env.vars.set("$material",String(u)),i.children()},children:i=>{let o=i.env.childCtx();if(!o)return ht();let a=this.childStmts(o.stmts),u=this.arg(i.args,"index",0),l=new ve(o.env,i.env);this.hoist(o.stmts,l);let f=new Set;if(u===void 0)a.forEach(h=>f.add(h));else for(let h of this.iterable(u,i.args.at))a[Number(h)]&&f.add(a[Number(h)]);let c=[];for(let h of o.stmts)if(h.kind==="assign")this.stmt(h,l);else if(f.has(h)){let p=this.stmt(h,l);p&&c.push(p)}return Nt(c)},echo:i=>(this.echo(this.echoText(i.args),i.args.at),i.children()),assert:i=>{let o=i.args;if(!Se(o.pos[0]??o.named.get("condition")))throw new R(`Assertion failed${o.pos[1]!==void 0?": "+(typeof o.pos[1]=="string"?o.pos[1]:Le(o.pos[1])):""}`,o.at);return i.children()},finger_rect:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0),"size"),u=this.edges(this.arg(i.args,"edges",1,"out")),l=this.thickness(i.env),f=this.fingerWidth(i.args,i.env,2);return this.spend(2*(Math.abs(o)+Math.abs(a))/f*4),Te(us(o,a,u,l,f))},finger_holes:i=>{let o=this.num(this.arg(i.args,"length",0),"finger_holes","length"),a=this.edges(this.arg(i.args,"edge",1,"out"))[0];if(a==="flat")throw new Error('edge must be "out" or "in"');let u=this.fingerWidth(i.args,i.env,2);return this.spend(Math.abs(o)/u*4),Te(ls(o,a,this.thickness(i.env),u))},tslot:i=>{let o=this.num(this.arg(i.args,"d",0,3),"tslot","d"),a=this.num(this.arg(i.args,"length",1,12),"tslot","length"),[u,l]=this.vec2(this.arg(i.args,"nut",2,[o*1.85,o*.8]),"nut",!1),f=this.num(this.arg(i.args,"nut_at",3,a/2),"tslot","nut_at");return Te(de(fs(o,a,u,l,f)))},living_hinge:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0),"size"),u=this.num(this.arg(i.args,"spacing",1,1.5),"living_hinge","spacing"),l=this.num(this.arg(i.args,"bridge",2,3),"living_hinge","bridge"),f=this.num(this.arg(i.args,"cut",3,Math.max(l*2,(a-3*l)/2)),"living_hinge","cut");if(u<=0||l<=0||f<=0)throw new Error("spacing, bridge and cut must be positive");return this.spend((Math.abs(o)/u+1)*(Math.abs(a)/(f+l)+2)*2),bt(hs(o,a,u,l,f))}};function n(i,o){let a={regions:[],lines:[]};for(let u of i){if(u.parts.length)throw new Error(`part() can only be the first child of ${o}()`);for(let l of u.layers.values())for(let f of l.regions)a.regions.push(f)}return a}function s(i,o){let a=u=>{let l=new Map;for(let[f,c]of u)l.set(f,o(c));return l};return{layers:a(i.layers),parts:i.parts.map(u=>({...u,layers:a(u.layers)}))}}}};var It=r=>{let e=Math.round(r*1e3)/1e3;return Object.is(e,-0)?"0":String(e)},Un=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;");function Rn(r,e){let t=[];for(let[n,s]of r){let i=[It(n),It(s)],o=t[t.length-1];(!o||o[0]!==i[0]||o[1]!==i[1])&&t.push(i)}for(;e&&t.length>1&&t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1];)t.pop();return t}var Tt=(r,e)=>`M${Rn(r,e).map(([t,n])=>`${t} ${n}`).join("L")}${e?"Z":""}`;function Nn(r,e){let t=[];for(let n of e){let s=[],i=[],o=[];for(let a of r){let u=a.layers.get(n.name);if(u){for(let l of u.lines)s.push(Tt(l,!1));for(let l of u.regions)(Ke(l)<0?i:o).push(Tt(l,!0))}}(s.length||i.length||o.length)&&t.push({name:n.name,mode:n.mode,color:n.color,d:[...s,...i,...o].join(""),regions:[...i,...o].join(""),lines:s.join("")})}return t}function Bn(r,e,t,n){let s=['<?xml version="1.0" encoding="UTF-8"?>',`<svg xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="${It(e)}mm" height="${It(t)}mm" viewBox="0 0 ${It(e)} ${It(t)}">`];for(let i of n){let o=[],a=[];for(let l of r){let f=l.layers.get(i.name);if(!f)continue;let c=` data-part="${Un(l.part)}"`;if(i.mode==="fill"){f.regions.length&&a.push(`<path${c} d="${f.regions.map(h=>Tt(h,!0)).join("")}"/>`);for(let h of f.lines)a.push(`<path${c} fill="none" stroke="${i.color}" stroke-width="0.1" d="${Tt(h,!1)}"/>`);continue}for(let h of f.lines)o.push(`<path${c} d="${Tt(h,!1)}"/>`);for(let h of f.regions)(Ke(h)<0?o:a).push(`<path${c} d="${Tt(h,!0)}"/>`)}if(!o.length&&!a.length)continue;let u=i.mode==="fill"?`fill="${i.color}" fill-rule="evenodd" stroke="none"`:`fill="none" stroke="${i.color}" stroke-width="0.1"${i.mode==="guide"?' stroke-dasharray="1 1"':""}`;s.push(`<g id="${Un(i.name)}" inkscape:groupmode="layer" inkscape:label="${Un(i.name)}" data-mode="${i.mode}" ${u}>`,...o,...a,"</g>")}return s.push("</svg>",""),s.join(`
37
- `)}var ch={"#ff0000":1,"#ffff00":2,"#00ff00":3,"#00ffff":4,"#0000ff":5,"#ff00ff":6,"#000000":7},ph=r=>{let e=ch[r.toLowerCase()];if(e)return e;let[t,n,s]=[1,3,5].map(i=>parseInt(r.slice(i,i+2),16));return t>n&&t>s?1:n>t&&n>s?3:s>t&&s>n?5:7};function Ki(r,e,t,n){let s=[],i=(u,l)=>s.push(String(u),String(l)),o=u=>u.toUpperCase().replace(/[^A-Z0-9_-]/g,"_");i(0,"SECTION"),i(2,"HEADER"),i(9,"$ACADVER"),i(1,"AC1009"),i(9,"$INSUNITS"),i(70,4),i(0,"ENDSEC"),i(0,"SECTION"),i(2,"TABLES"),i(0,"TABLE"),i(2,"LAYER"),i(70,n.length);for(let u of n)i(0,"LAYER"),i(2,o(u.name)),i(70,0),i(62,ph(u.color)),i(6,"CONTINUOUS");i(0,"ENDTAB"),i(0,"ENDSEC"),i(0,"SECTION"),i(2,"ENTITIES");let a=(u,l,f)=>{i(0,"POLYLINE"),i(8,u),i(66,1),i(10,0),i(20,0),i(30,0),i(70,f?1:0);for(let[c,h]of Rn(l.map(([p,g])=>[p,t-g]),f))i(0,"VERTEX"),i(8,u),i(10,c),i(20,h),i(30,0);i(0,"SEQEND"),i(8,u)};for(let u of n){let l=o(u.name),f=[];for(let c of r){let h=c.layers.get(u.name);if(h){for(let p of h.lines)a(l,p,!1);for(let p of h.regions)Ke(p)<0?a(l,p,!0):f.push(p)}}for(let c of f)a(l,c,!0)}return i(0,"ENDSEC"),i(0,"EOF"),s.join(`
41
+ `};function Rr(t,e=.02){let r=[],n=[],s=[],i=[0,0],o=[0,0],a=l=>{s.length>=2&&(l?r:n).push(s),s=[]},u=l=>Math.max(2,Math.min(256,Math.ceil(Math.sqrt(l/e))));for(let l of t)if(l.type==="M")a(!1),i=o=[l.x,l.y],s=[o];else if(l.type==="L")o=[l.x,l.y],s.push(o);else if(l.type==="Q"){let[f,c]=o,h=u(Math.hypot(l.x1-f,l.y1-c)+Math.hypot(l.x-l.x1,l.y-l.y1));for(let p=1;p<=h;p++){let d=p/h,m=1-d;s.push([m*m*f+2*m*d*l.x1+d*d*l.x,m*m*c+2*m*d*l.y1+d*d*l.y])}o=[l.x,l.y]}else if(l.type==="C"){let[f,c]=o,h=u(Math.hypot(l.x1-f,l.y1-c)+Math.hypot(l.x2-l.x1,l.y2-l.y1)+Math.hypot(l.x-l.x2,l.y-l.y2));for(let p=1;p<=h;p++){let d=p/h,m=1-d;s.push([m*m*m*f+3*m*m*d*l.x1+3*m*d*d*l.x2+d*d*d*l.x,m*m*m*c+3*m*m*d*l.y1+3*m*d*d*l.y2+d*d*d*l.y])}o=[l.x,l.y]}else a(!0),o=i,s=[i];return a(!1),{closed:r,open:n}}function _s(t){let e=y=>/^[a-zA-Z]$/.test(y),r=t.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g)??[],n=[],s=0,i="",o=0,a=0,u=0,l=0,f=0,c=0,h=0,p=0,d="",m=()=>{let y=r[s++];if(y===void 0||e(y))throw new Error(`Bad path data near "${y??"end"}"`);return Number(y)},x=()=>{let y=r[s];if(y===void 0)throw new Error("Bad path data: missing arc flag");return y.length>1&&(y[0]==="0"||y[0]==="1")&&!y.includes(".")?(r[s]=y.slice(1),Number(y[0])):(s++,Number(y))};for(;s<r.length;){if(e(r[s]))i=r[s++];else if(i){if(i==="Z"||i==="z")throw new Error(`Bad path data near "${r[s]}": Z takes no numbers`)}else throw new Error("Path data must start with a command");let y=i===i.toLowerCase(),L=i.toUpperCase(),S=y?o:0,A=y?a:0;if(L==="M")o=S+m(),a=A+m(),u=o,l=a,n.push({type:"M",x:o,y:a}),i=y?"l":"L";else if(L==="L")o=S+m(),a=A+m(),n.push({type:"L",x:o,y:a});else if(L==="H")o=S+m(),n.push({type:"L",x:o,y:a});else if(L==="V")a=A+m(),n.push({type:"L",x:o,y:a});else if(L==="C"||L==="S"){let E,F;if(L==="C")E=S+m(),F=A+m();else{let z=d==="C"||d==="S";E=z?2*o-f:o,F=z?2*a-c:a}let k=S+m(),I=A+m();o=S+m(),a=A+m(),f=k,c=I,n.push({type:"C",x1:E,y1:F,x2:k,y2:I,x:o,y:a})}else if(L==="Q"||L==="T"){let E,F;if(L==="Q")E=S+m(),F=A+m();else{let k=d==="Q"||d==="T";E=k?2*o-h:o,F=k?2*a-p:a}o=S+m(),a=A+m(),h=E,p=F,n.push({type:"Q",x1:E,y1:F,x:o,y:a})}else if(L==="A"){let E=m(),F=m(),k=m(),I=x(),z=x(),B=S+m(),$=A+m();n.push(...Ua(o,a,E,F,k,I,z,B,$)),o=B,a=$}else if(L==="Z")n.push({type:"Z"}),o=u,a=l;else throw new Error(`Unknown path command "${i}"`);d=L}return n}function Ua(t,e,r,n,s,i,o,a,u){if(r===0||n===0||t===a&&e===u)return[{type:"L",x:a,y:u}];r=Math.abs(r),n=Math.abs(n);let l=s*Math.PI/180,f=Math.cos(l),c=Math.sin(l),h=(t-a)/2,p=(e-u)/2,d=f*h+c*p,m=-c*h+f*p,x=d*d/(r*r)+m*m/(n*n);x>1&&(r*=Math.sqrt(x),n*=Math.sqrt(x));let y=r*r*n*n-r*r*m*m-n*n*d*d,L=r*r*m*m+n*n*d*d,S=Math.sqrt(Math.max(0,y/L));i===o&&(S=-S);let A=S*r*m/n,E=-S*n*d/r,F=f*A-c*E+(t+a)/2,k=c*A+f*E+(e+u)/2,I=(G,q,ee,Q)=>Math.atan2(G*Q-q*ee,G*ee+q*Q),z=I(1,0,(d-A)/r,(m-E)/n),B=I((d-A)/r,(m-E)/n,(-d-A)/r,(-m-E)/n);!o&&B>0&&(B-=2*Math.PI),o&&B<0&&(B+=2*Math.PI);let $=Math.ceil(Math.abs(B)/(Math.PI/2)),ge=[],me=G=>[F+r*Math.cos(G)*f-n*Math.sin(G)*c,k+r*Math.cos(G)*c+n*Math.sin(G)*f],Y=G=>[-r*Math.sin(G)*f-n*Math.cos(G)*c,-r*Math.sin(G)*c+n*Math.cos(G)*f];for(let G=0;G<$;G++){let q=z+B*G/$,ee=z+B*(G+1)/$,Q=4/3*Math.tan((ee-q)/4),se=me(q),le=me(ee),K=Y(q),w=Y(ee);ge.push({type:"C",x1:se[0]+Q*K[0],y1:se[1]+Q*K[1],x2:le[0]-Q*w[0],y2:le[1]-Q*w[1],x:le[0],y:le[1]})}return ge}String.prototype.codePointAt||(function(){var t=(function(){try{var r={},n=Object.defineProperty,s=n(r,r,r)&&n}catch{}return s})(),e=function(r){if(this==null)throw TypeError();var n=String(this),s=n.length,i=r?Number(r):0;if(i!=i&&(i=0),!(i<0||i>=s)){var o=n.charCodeAt(i),a;return o>=55296&&o<=56319&&s>i+1&&(a=n.charCodeAt(i+1),a>=56320&&a<=57343)?(o-55296)*1024+a-56320+65536:o}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e})();var $n=0,Ri=-3;function er(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Ra(t,e){this.source=t,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new er,this.dtree=new er}var Ni=new er,Bi=new er,Xn=new Uint8Array(30),qn=new Uint16Array(30),Gi=new Uint8Array(30),Hi=new Uint16Array(30),Na=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ks=new er,_e=new Uint8Array(320);function Vi(t,e,r,n){var s,i;for(s=0;s<r;++s)t[s]=0;for(s=0;s<30-r;++s)t[s+r]=s/r|0;for(i=n,s=0;s<30;++s)e[s]=i,i+=1<<t[s]}function Ba(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 Js=new Uint16Array(16);function Pn(t,e,r,n){var s,i;for(s=0;s<16;++s)t.table[s]=0;for(s=0;s<n;++s)t.table[e[r+s]]++;for(t.table[0]=0,i=0,s=0;s<16;++s)Js[s]=i,i+=t.table[s];for(s=0;s<n;++s)e[r+s]&&(t.trans[Js[e[r+s]]++]=s)}function Ga(t){t.bitcount--||(t.tag=t.source[t.sourceIndex++],t.bitcount=7);var e=t.tag&1;return t.tag>>>=1,e}function Ye(t,e,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 Dn(t,e){for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var r=0,n=0,s=0,i=t.tag;do n=2*n+(i&1),i>>>=1,++s,r+=e.table[s],n-=e.table[s];while(n>=0);return t.tag=i,t.bitcount-=s,e.trans[r+n]}function Ha(t,e,r){var n,s,i,o,a,u;for(n=Ye(t,5,257),s=Ye(t,5,1),i=Ye(t,4,4),o=0;o<19;++o)_e[o]=0;for(o=0;o<i;++o){var l=Ye(t,3,0);_e[Na[o]]=l}for(Pn(Ks,_e,0,19),a=0;a<n+s;){var f=Dn(t,Ks);switch(f){case 16:var c=_e[a-1];for(u=Ye(t,2,3);u;--u)_e[a++]=c;break;case 17:for(u=Ye(t,3,3);u;--u)_e[a++]=0;break;case 18:for(u=Ye(t,7,11);u;--u)_e[a++]=0;break;default:_e[a++]=f;break}}Pn(e,_e,0,n),Pn(r,_e,n,s)}function Qs(t,e,r){for(;;){var n=Dn(t,e);if(n===256)return $n;if(n<256)t.dest[t.destLen++]=n;else{var s,i,o,a;for(n-=257,s=Ye(t,Xn[n],qn[n]),i=Dn(t,r),o=t.destLen-Ye(t,Gi[i],Hi[i]),a=o;a<o+s;++a)t.dest[t.destLen++]=t.dest[a]}}}function Va(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 Ri;for(t.sourceIndex+=4,n=e;n;--n)t.dest[t.destLen++]=t.source[t.sourceIndex++];return t.bitcount=0,$n}function za(t,e){var r=new Ra(t,e),n,s,i;do{switch(n=Ga(r),s=Ye(r,2,0),s){case 0:i=Va(r);break;case 1:i=Qs(r,Ni,Bi);break;case 2:Ha(r,r.ltree,r.dtree),i=Qs(r,r.ltree,r.dtree);break;default:i=Ri}if(i!==$n)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}Ba(Ni,Bi);Vi(Xn,qn,4,3);Vi(Gi,Hi,2,1);Xn[28]=0;qn[28]=258;var $a=za;function Ot(t,e,r,n,s){return Math.pow(1-s,3)*t+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*r+Math.pow(s,3)*n}function ct(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}ct.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)};ct.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))};ct.prototype.addX=function(t){this.addPoint(t,null)};ct.prototype.addY=function(t){this.addPoint(null,t)};ct.prototype.addBezier=function(t,e,r,n,s,i,o,a){var u=[t,e],l=[r,n],f=[s,i],c=[o,a];this.addPoint(t,e),this.addPoint(o,a);for(var h=0;h<=1;h++){var p=6*u[h]-12*l[h]+6*f[h],d=-3*u[h]+9*l[h]-9*f[h]+3*c[h],m=3*l[h]-3*u[h];if(d===0){if(p===0)continue;var x=-m/p;0<x&&x<1&&(h===0&&this.addX(Ot(u[h],l[h],f[h],c[h],x)),h===1&&this.addY(Ot(u[h],l[h],f[h],c[h],x)));continue}var y=Math.pow(p,2)-4*m*d;if(!(y<0)){var L=(-p+Math.sqrt(y))/(2*d);0<L&&L<1&&(h===0&&this.addX(Ot(u[h],l[h],f[h],c[h],L)),h===1&&this.addY(Ot(u[h],l[h],f[h],c[h],L)));var S=(-p-Math.sqrt(y))/(2*d);0<S&&S<1&&(h===0&&this.addX(Ot(u[h],l[h],f[h],c[h],S)),h===1&&this.addY(Ot(u[h],l[h],f[h],c[h],S)))}}};ct.prototype.addQuad=function(t,e,r,n,s,i){var o=t+.6666666666666666*(r-t),a=e+2/3*(n-e),u=o+1/3*(s-t),l=a+1/3*(i-e);this.addBezier(t,e,o,a,u,l,s,i)};function xe(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}xe.prototype.moveTo=function(t,e){this.commands.push({type:"M",x:t,y:e})};xe.prototype.lineTo=function(t,e){this.commands.push({type:"L",x:t,y:e})};xe.prototype.curveTo=xe.prototype.bezierCurveTo=function(t,e,r,n,s,i){this.commands.push({type:"C",x1:t,y1:e,x2:r,y2:n,x:s,y:i})};xe.prototype.quadTo=xe.prototype.quadraticCurveTo=function(t,e,r,n){this.commands.push({type:"Q",x1:t,y1:e,x:r,y:n})};xe.prototype.close=xe.prototype.closePath=function(){this.commands.push({type:"Z"})};xe.prototype.extend=function(t){if(t.commands)t=t.commands;else if(t instanceof ct){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)};xe.prototype.getBoundingBox=function(){for(var t=new ct,e=0,r=0,n=0,s=0,i=0;i<this.commands.length;i++){var o=this.commands[i];switch(o.type){case"M":t.addPoint(o.x,o.y),e=n=o.x,r=s=o.y;break;case"L":t.addPoint(o.x,o.y),n=o.x,s=o.y;break;case"Q":t.addQuad(n,s,o.x1,o.y1,o.x,o.y),n=o.x,s=o.y;break;case"C":t.addBezier(n,s,o.x1,o.y1,o.x2,o.y2,o.x,o.y),n=o.x,s=o.y;break;case"Z":n=e,s=r;break;default:throw new Error("Unexpected path command "+o.type)}}return t.isEmpty()&&t.addPoint(0,0),t};xe.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())};xe.prototype.toPathData=function(t){t=t!==void 0?t:2;function e(o){return Math.round(o)===o?""+Math.round(o):o.toFixed(t)}function r(){for(var o=arguments,a="",u=0;u<arguments.length;u+=1){var l=o[u];l>=0&&u>0&&(a+=" "),a+=e(l)}return a}for(var n="",s=0;s<this.commands.length;s+=1){var i=this.commands[s];i.type==="M"?n+="M"+r(i.x,i.y):i.type==="L"?n+="L"+r(i.x,i.y):i.type==="C"?n+="C"+r(i.x1,i.y1,i.x2,i.y2,i.x,i.y):i.type==="Q"?n+="Q"+r(i.x1,i.y1,i.x,i.y):i.type==="Z"&&(n+="Z")}return n};xe.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};xe.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 zi(t){throw new Error(t)}function ei(t,e){t||zi(e)}var D={fail:zi,argument:ei,assert:ei},ti=32768,ri=2147483648,Dt={},P={},U={};function Xe(t){return function(){return t}}P.BYTE=function(t){return D.argument(t>=0&&t<=255,"Byte value should be between 0 and 255."),[t]};U.BYTE=Xe(1);P.CHAR=function(t){return[t.charCodeAt(0)]};U.CHAR=Xe(1);P.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};U.CHARARRAY=function(t){return typeof t>"u"?0:t.length};P.USHORT=function(t){return[t>>8&255,t&255]};U.USHORT=Xe(2);P.SHORT=function(t){return t>=ti&&(t=-(2*ti-t)),[t>>8&255,t&255]};U.SHORT=Xe(2);P.UINT24=function(t){return[t>>16&255,t>>8&255,t&255]};U.UINT24=Xe(3);P.ULONG=function(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]};U.ULONG=Xe(4);P.LONG=function(t){return t>=ri&&(t=-(2*ri-t)),[t>>24&255,t>>16&255,t>>8&255,t&255]};U.LONG=Xe(4);P.FIXED=P.ULONG;U.FIXED=U.ULONG;P.FWORD=P.SHORT;U.FWORD=U.SHORT;P.UFWORD=P.USHORT;U.UFWORD=U.USHORT;P.LONGDATETIME=function(t){return[0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255]};U.LONGDATETIME=Xe(8);P.TAG=function(t){return D.argument(t.length===4,"Tag should be exactly 4 ASCII characters."),[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]};U.TAG=Xe(4);P.Card8=P.BYTE;U.Card8=U.BYTE;P.Card16=P.USHORT;U.Card16=U.USHORT;P.OffSize=P.BYTE;U.OffSize=U.BYTE;P.SID=P.USHORT;U.SID=U.USHORT;P.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?P.NUMBER16(t):P.NUMBER32(t)};U.NUMBER=function(t){return P.NUMBER(t).length};P.NUMBER16=function(t){return[28,t>>8&255,t&255]};U.NUMBER16=Xe(3);P.NUMBER32=function(t){return[29,t>>24&255,t>>16&255,t>>8&255,t&255]};U.NUMBER32=Xe(5);P.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 s="",i=0,o=e.length;i<o;i+=1){var a=e[i];a==="e"?s+=e[++i]==="-"?"c":"b":a==="."?s+="a":a==="-"?s+="e":s+=a}s+=s.length&1?"f":"ff";for(var u=[30],l=0,f=s.length;l<f;l+=2)u.push(parseInt(s.substr(l,2),16));return u};U.REAL=function(t){return P.REAL(t).length};P.NAME=P.CHARARRAY;U.NAME=U.CHARARRAY;P.STRING=P.CHARARRAY;U.STRING=U.CHARARRAY;Dt.UTF8=function(t,e,r){for(var n=[],s=r,i=0;i<s;i++,e+=1)n[i]=t.getUint8(e);return String.fromCharCode.apply(null,n)};Dt.UTF16=function(t,e,r){for(var n=[],s=r/2,i=0;i<s;i++,e+=2)n[i]=t.getUint16(e);return String.fromCharCode.apply(null,n)};P.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};U.UTF16=function(t){return t.length*2};var Un={"x-mac-croatian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\u0160\u2122\xB4\xA8\u2260\u017D\xD8\u221E\xB1\u2264\u2265\u2206\xB5\u2202\u2211\u220F\u0161\u222B\xAA\xBA\u03A9\u017E\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u0106\xAB\u010C\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u0110\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\uF8FF\xA9\u2044\u20AC\u2039\u203A\xC6\xBB\u2013\xB7\u201A\u201E\u2030\xC2\u0107\xC1\u010D\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u0111\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u03C0\xCB\u02DA\xB8\xCA\xE6\u02C7","x-mac-cyrillic":"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u2020\xB0\u0490\xA3\xA7\u2022\xB6\u0406\xAE\xA9\u2122\u0402\u0452\u2260\u0403\u0453\u221E\xB1\u2264\u2265\u0456\xB5\u0491\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040A\u045A\u0458\u0405\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\u040B\u045B\u040C\u045C\u0455\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u201E\u040E\u045E\u040F\u045F\u2116\u0401\u0451\u044F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E","x-mac-gaelic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u1E02\xB1\u2264\u2265\u1E03\u010A\u010B\u1E0A\u1E0B\u1E1E\u1E1F\u0120\u0121\u1E40\xE6\xF8\u1E41\u1E56\u1E57\u027C\u0192\u017F\u1E60\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u1E61\u1E9B\xFF\u0178\u1E6A\u20AC\u2039\u203A\u0176\u0177\u1E6B\xB7\u1EF2\u1EF3\u204A\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u2663\xD2\xDA\xDB\xD9\u0131\xDD\xFD\u0174\u0175\u1E84\u1E85\u1E80\u1E81\u1E82\u1E83","x-mac-greek":"\xC4\xB9\xB2\xC9\xB3\xD6\xDC\u0385\xE0\xE2\xE4\u0384\xA8\xE7\xE9\xE8\xEA\xEB\xA3\u2122\xEE\xEF\u2022\xBD\u2030\xF4\xF6\xA6\u20AC\xF9\xFB\xFC\u2020\u0393\u0394\u0398\u039B\u039E\u03A0\xDF\xAE\xA9\u03A3\u03AA\xA7\u2260\xB0\xB7\u0391\xB1\u2264\u2265\xA5\u0392\u0395\u0396\u0397\u0399\u039A\u039C\u03A6\u03AB\u03A8\u03A9\u03AC\u039D\xAC\u039F\u03A1\u2248\u03A4\xAB\xBB\u2026\xA0\u03A5\u03A7\u0386\u0388\u0153\u2013\u2015\u201C\u201D\u2018\u2019\xF7\u0389\u038A\u038C\u038E\u03AD\u03AE\u03AF\u03CC\u038F\u03CD\u03B1\u03B2\u03C8\u03B4\u03B5\u03C6\u03B3\u03B7\u03B9\u03BE\u03BA\u03BB\u03BC\u03BD\u03BF\u03C0\u03CE\u03C1\u03C3\u03C4\u03B8\u03C9\u03C2\u03C7\u03C5\u03B6\u03CA\u03CB\u0390\u03B0\xAD","x-mac-icelandic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\xDD\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\xD0\xF0\xDE\xFE\xFD\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-inuit":"\u1403\u1404\u1405\u1406\u140A\u140B\u1431\u1432\u1433\u1434\u1438\u1439\u1449\u144E\u144F\u1450\u1451\u1455\u1456\u1466\u146D\u146E\u146F\u1470\u1472\u1473\u1483\u148B\u148C\u148D\u148E\u1490\u1491\xB0\u14A1\u14A5\u14A6\u2022\xB6\u14A7\xAE\xA9\u2122\u14A8\u14AA\u14AB\u14BB\u14C2\u14C3\u14C4\u14C5\u14C7\u14C8\u14D0\u14EF\u14F0\u14F1\u14F2\u14F4\u14F5\u1505\u14D5\u14D6\u14D7\u14D8\u14DA\u14DB\u14EA\u1528\u1529\u152A\u152B\u152D\u2026\xA0\u152E\u153E\u1555\u1556\u1557\u2013\u2014\u201C\u201D\u2018\u2019\u1558\u1559\u155A\u155D\u1546\u1547\u1548\u1549\u154B\u154C\u1550\u157F\u1580\u1581\u1582\u1583\u1584\u1585\u158F\u1590\u1591\u1592\u1593\u1594\u1595\u1671\u1672\u1673\u1674\u1675\u1676\u1596\u15A0\u15A1\u15A2\u15A3\u15A4\u15A5\u15A6\u157C\u0141\u0142","x-mac-ce":"\xC4\u0100\u0101\xC9\u0104\xD6\xDC\xE1\u0105\u010C\xE4\u010D\u0106\u0107\xE9\u0179\u017A\u010E\xED\u010F\u0112\u0113\u0116\xF3\u0117\xF4\xF6\xF5\xFA\u011A\u011B\xFC\u2020\xB0\u0118\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\u0119\xA8\u2260\u0123\u012E\u012F\u012A\u2264\u2265\u012B\u0136\u2202\u2211\u0142\u013B\u013C\u013D\u013E\u0139\u013A\u0145\u0146\u0143\xAC\u221A\u0144\u0147\u2206\xAB\xBB\u2026\xA0\u0148\u0150\xD5\u0151\u014C\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\u014D\u0154\u0155\u0158\u2039\u203A\u0159\u0156\u0157\u0160\u201A\u201E\u0161\u015A\u015B\xC1\u0164\u0165\xCD\u017D\u017E\u016A\xD3\xD4\u016B\u016E\xDA\u016F\u0170\u0171\u0172\u0173\xDD\xFD\u0137\u017B\u0141\u017C\u0122\u02C7",macintosh:"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\uFB01\uFB02\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-romanian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\u0102\u0218\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\u0103\u0219\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\u021A\u021B\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-turkish":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u011E\u011F\u0130\u0131\u015E\u015F\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\uF8A0\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7"};Dt.MACSTRING=function(t,e,r,n){var s=Un[n];if(s!==void 0){for(var i="",o=0;o<r;o++){var a=t.getUint8(e+o);a<=127?i+=String.fromCharCode(a):i+=s[a&127]}return i}};var Nr=typeof WeakMap=="function"&&new WeakMap,Br,Xa=function(t){if(!Br){Br={};for(var e in Un)Br[e]=new String(e)}var r=Br[t];if(r!==void 0){if(Nr){var n=Nr.get(r);if(n!==void 0)return n}var s=Un[t];if(s!==void 0){for(var i={},o=0;o<s.length;o++)i[s.charCodeAt(o)]=o+128;return Nr&&Nr.set(r,i),i}}};P.MACSTRING=function(t,e){var r=Xa(e);if(r!==void 0){for(var n=[],s=0;s<t.length;s++){var i=t.charCodeAt(s);if(i>=128&&(i=r[i],i===void 0))return;n[s]=i}return n}};U.MACSTRING=function(t,e){var r=P.MACSTRING(t,e);return r!==void 0?r.length:0};function Rn(t){return t>=-128&&t<=127}function qa(t,e,r){for(var n=0,s=t.length;e<s&&n<64&&t[e]===0;)++e,++n;return r.push(128|n-1),e}function Wa(t,e,r){for(var n=0,s=t.length,i=e;i<s&&n<64;){var o=t[i];if(!Rn(o)||o===0&&i+1<s&&t[i+1]===0)break;++i,++n}r.push(n-1);for(var a=e;a<i;++a)r.push(t[a]+256&255);return i}function Za(t,e,r){for(var n=0,s=t.length,i=e;i<s&&n<64;){var o=t[i];if(o===0||Rn(o)&&i+1<s&&Rn(t[i+1]))break;++i,++n}r.push(64|n-1);for(var a=e;a<i;++a){var u=t[a];r.push(u+65536>>8&255,u+256&255)}return i}P.VARDELTAS=function(t){for(var e=0,r=[];e<t.length;){var n=t[e];n===0?e=qa(t,e,r):n>=-128&&n<=127?e=Wa(t,e,r):e=Za(t,e,r)}return r};P.INDEX=function(t){for(var e=1,r=[e],n=[],s=0;s<t.length;s+=1){var i=P.OBJECT(t[s]);Array.prototype.push.apply(n,i),e+=i.length,r.push(e)}if(n.length===0)return[0,0];for(var o=[],a=1+Math.floor(Math.log(e)/Math.log(2))/8|0,u=[void 0,P.BYTE,P.USHORT,P.UINT24,P.ULONG][a],l=0;l<r.length;l+=1){var f=u(r[l]);Array.prototype.push.apply(o,f)}return Array.prototype.concat(P.Card16(t.length),P.OffSize(a),o,n)};U.INDEX=function(t){return P.INDEX(t).length};P.DICT=function(t){for(var e=[],r=Object.keys(t),n=r.length,s=0;s<n;s+=1){var i=parseInt(r[s],0),o=t[i];e=e.concat(P.OPERAND(o.value,o.type)),e=e.concat(P.OPERATOR(i))}return e};U.DICT=function(t){return P.DICT(t).length};P.OPERATOR=function(t){return t<1200?[t]:[12,t-1200]};P.OPERAND=function(t,e){var r=[];if(Array.isArray(e))for(var n=0;n<e.length;n+=1)D.argument(t.length===e.length,"Not enough arguments given for type"+e),r=r.concat(P.OPERAND(t[n],e[n]));else if(e==="SID")r=r.concat(P.NUMBER(t));else if(e==="offset")r=r.concat(P.NUMBER32(t));else if(e==="number")r=r.concat(P.NUMBER(t));else if(e==="real")r=r.concat(P.REAL(t));else throw new Error("Unknown operand type "+e);return r};P.OP=P.BYTE;U.OP=U.BYTE;var Gr=typeof WeakMap=="function"&&new WeakMap;P.CHARSTRING=function(t){if(Gr){var e=Gr.get(t);if(e!==void 0)return e}for(var r=[],n=t.length,s=0;s<n;s+=1){var i=t[s];r=r.concat(P[i.type](i.value))}return Gr&&Gr.set(t,r),r};U.CHARSTRING=function(t){return P.CHARSTRING(t).length};P.OBJECT=function(t){var e=P[t.type];return D.argument(e!==void 0,"No encoding function for type "+t.type),e(t.value)};U.OBJECT=function(t){var e=U[t.type];return D.argument(e!==void 0,"No sizeOf function for type "+t.type),e(t.value)};P.TABLE=function(t){for(var e=[],r=t.fields.length,n=[],s=[],i=0;i<r;i+=1){var o=t.fields[i],a=P[o.type];D.argument(a!==void 0,"No encoding function for field type "+o.type+" ("+o.name+")");var u=t[o.name];u===void 0&&(u=o.value);var l=a(u);o.type==="TABLE"?(s.push(e.length),e=e.concat([0,0]),n.push(l)):e=e.concat(l)}for(var f=0;f<n.length;f+=1){var c=s[f],h=e.length;D.argument(h<65536,"Table "+t.tableName+" too big."),e[c]=h>>8,e[c+1]=h&255,e=e.concat(n[f])}return e};U.TABLE=function(t){for(var e=0,r=t.fields.length,n=0;n<r;n+=1){var s=t.fields[n],i=U[s.type];D.argument(i!==void 0,"No sizeOf function for field type "+s.type+" ("+s.name+")");var o=t[s.name];o===void 0&&(o=s.value),e+=i(o),s.type==="TABLE"&&(e+=2)}return e};P.RECORD=P.TABLE;U.RECORD=U.TABLE;P.LITERAL=function(t){return t};U.LITERAL=function(t){return t.length};function be(t,e,r){if(e.length&&(e[0].name!=="coverageFormat"||e[0].value===1))for(var n=0;n<e.length;n+=1){var s=e[n];this[s.name]=s.value}if(this.tableName=t,this.fields=e,r)for(var i=Object.keys(r),o=0;o<i.length;o+=1){var a=i[o],u=r[a];this[a]!==void 0&&(this[a]=u)}}be.prototype.encode=function(){return P.TABLE(this)};be.prototype.sizeOf=function(){return U.TABLE(this)};function tr(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 s=0;s<e.length;s++)n[s+1]={name:t+s,type:"USHORT",value:e[s]};return n}function Nn(t,e,r){var n=e.length,s=new Array(n+1);s[0]={name:t+"Count",type:"USHORT",value:n};for(var i=0;i<n;i++)s[i+1]={name:t+i,type:"TABLE",value:r(e[i],i)};return s}function rr(t,e,r){var n=e.length,s=[];s[0]={name:t+"Count",type:"USHORT",value:n};for(var i=0;i<n;i++)s=s.concat(r(e[i],i));return s}function Xr(t){t.format===1?be.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(tr("glyph",t.glyphs))):t.format===2?be.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(rr("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}]}))):D.assert(!1,"Coverage format must be 1 or 2.")}Xr.prototype=Object.create(be.prototype);Xr.prototype.constructor=Xr;function qr(t){be.call(this,"scriptListTable",rr("scriptRecord",t,function(e,r){var n=e.script,s=n.defaultLangSys;return D.assert(!!s,"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 be("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new be("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(tr("featureIndex",s.featureIndexes)))}].concat(rr("langSys",n.langSysRecords,function(i,o){var a=i.langSys;return[{name:"langSysTag"+o,type:"TAG",value:i.tag},{name:"langSys"+o,type:"TABLE",value:new be("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat(tr("featureIndex",a.featureIndexes)))}]})))}]}))}qr.prototype=Object.create(be.prototype);qr.prototype.constructor=qr;function Wr(t){be.call(this,"featureListTable",rr("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 be("featureTable",[{name:"featureParams",type:"USHORT",value:n.featureParams}].concat(tr("lookupListIndex",n.lookupListIndexes)))}]}))}Wr.prototype=Object.create(be.prototype);Wr.prototype.constructor=Wr;function Zr(t,e){be.call(this,"lookupListTable",Nn("lookup",t,function(r){var n=e[r.lookupType];return D.assert(!!n,"Unable to write GSUB lookup type "+r.lookupType+" tables."),new be("lookupTable",[{name:"lookupType",type:"USHORT",value:r.lookupType},{name:"lookupFlag",type:"USHORT",value:r.lookupFlag}].concat(Nn("subtable",r.subtables,n)))}))}Zr.prototype=Object.create(be.prototype);Zr.prototype.constructor=Zr;var T={Table:be,Record:be,Coverage:Xr,ScriptList:qr,FeatureList:Wr,LookupList:Zr,ushortList:tr,tableList:Nn,recordList:rr};function ni(t,e){return t.getUint8(e)}function _r(t,e){return t.getUint16(e,!1)}function _a(t,e){return t.getInt16(e,!1)}function Wn(t,e){return t.getUint32(e,!1)}function $i(t,e){var r=t.getInt16(e,!1),n=t.getUint16(e+2,!1);return r+n/65535}function Ya(t,e){for(var r="",n=e;n<e+4;n+=1)r+=String.fromCharCode(t.getInt8(n));return r}function ja(t,e,r){for(var n=0,s=0;s<r;s+=1)n<<=8,n+=t.getUint8(e+s);return n}function Ka(t,e,r){for(var n=[],s=e;s<r;s+=1)n.push(t.getUint8(s));return n}function Ja(t){for(var e="",r=0;r<t.length;r+=1)e+=String.fromCharCode(t[r]);return e}var Qa={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function v(t,e){this.data=t,this.offset=e,this.relativeOffset=0}v.prototype.parseByte=function(){var t=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,t};v.prototype.parseChar=function(){var t=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,t};v.prototype.parseCard8=v.prototype.parseByte;v.prototype.parseUShort=function(){var t=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,t};v.prototype.parseCard16=v.prototype.parseUShort;v.prototype.parseSID=v.prototype.parseUShort;v.prototype.parseOffset16=v.prototype.parseUShort;v.prototype.parseShort=function(){var t=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,t};v.prototype.parseF2Dot14=function(){var t=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,t};v.prototype.parseULong=function(){var t=Wn(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t};v.prototype.parseOffset32=v.prototype.parseULong;v.prototype.parseFixed=function(){var t=$i(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t};v.prototype.parseString=function(t){var e=this.data,r=this.offset+this.relativeOffset,n="";this.relativeOffset+=t;for(var s=0;s<t;s++)n+=String.fromCharCode(e.getUint8(r+s));return n};v.prototype.parseTag=function(){return this.parseString(4)};v.prototype.parseLongDateTime=function(){var t=Wn(this.data,this.offset+this.relativeOffset+4);return t-=2082844800,this.relativeOffset+=8,t};v.prototype.parseVersion=function(t){var e=_r(this.data,this.offset+this.relativeOffset),r=_r(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,t===void 0&&(t=4096),e+r/t/10};v.prototype.skip=function(t,e){e===void 0&&(e=1),this.relativeOffset+=Qa[t]*e};v.prototype.parseULongList=function(t){t===void 0&&(t=this.parseULong());for(var e=new Array(t),r=this.data,n=this.offset+this.relativeOffset,s=0;s<t;s++)e[s]=r.getUint32(n),n+=4;return this.relativeOffset+=t*4,e};v.prototype.parseOffset16List=v.prototype.parseUShortList=function(t){t===void 0&&(t=this.parseUShort());for(var e=new Array(t),r=this.data,n=this.offset+this.relativeOffset,s=0;s<t;s++)e[s]=r.getUint16(n),n+=2;return this.relativeOffset+=t*2,e};v.prototype.parseShortList=function(t){for(var e=new Array(t),r=this.data,n=this.offset+this.relativeOffset,s=0;s<t;s++)e[s]=r.getInt16(n),n+=2;return this.relativeOffset+=t*2,e};v.prototype.parseByteList=function(t){for(var e=new Array(t),r=this.data,n=this.offset+this.relativeOffset,s=0;s<t;s++)e[s]=r.getUint8(n++);return this.relativeOffset+=t,e};v.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};v.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};v.prototype.parseRecordList=function(t,e){e||(e=t,t=this.parseUShort());for(var r=new Array(t),n=Object.keys(e),s=0;s<t;s++){for(var i={},o=0;o<n.length;o++){var a=n[o],u=e[a];i[a]=u.call(this)}r[s]=i}return r};v.prototype.parseRecordList32=function(t,e){e||(e=t,t=this.parseULong());for(var r=new Array(t),n=Object.keys(e),s=0;s<t;s++){for(var i={},o=0;o<n.length;o++){var a=n[o],u=e[a];i[a]=u.call(this)}r[s]=i}return r};v.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 s=e[n],i=t[s];r[s]=i.call(this)}return r};v.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}};v.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};v.prototype.parsePointer=function(t){var e=this.parseOffset16();if(e>0)return new v(this.data,this.offset+e).parseStruct(t)};v.prototype.parsePointer32=function(t){var e=this.parseOffset32();if(e>0)return new v(this.data,this.offset+e).parseStruct(t)};v.prototype.parseListOfLists=function(t){for(var e=this.parseOffset16List(),r=e.length,n=this.relativeOffset,s=new Array(r),i=0;i<r;i++){var o=e[i];if(o===0){s[i]=void 0;continue}if(this.relativeOffset=o,t){for(var a=this.parseOffset16List(),u=new Array(a.length),l=0;l<a.length;l++)this.relativeOffset=o+a[l],u[l]=t.call(this);s[i]=u}else s[i]=this.parseUShortList()}return this.relativeOffset=n,s};v.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),s=0;s<r;s++)n[s]={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.")};v.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:v.uShort,end:v.uShort,classId:v.uShort})};throw new Error("0x"+t.toString(16)+": ClassDef format must be 1 or 2.")};v.list=function(t,e){return function(){return this.parseList(t,e)}};v.list32=function(t,e){return function(){return this.parseList32(t,e)}};v.recordList=function(t,e){return function(){return this.parseRecordList(t,e)}};v.recordList32=function(t,e){return function(){return this.parseRecordList32(t,e)}};v.pointer=function(t){return function(){return this.parsePointer(t)}};v.pointer32=function(t){return function(){return this.parsePointer32(t)}};v.tag=v.prototype.parseTag;v.byte=v.prototype.parseByte;v.uShort=v.offset16=v.prototype.parseUShort;v.uShortList=v.prototype.parseUShortList;v.uLong=v.offset32=v.prototype.parseULong;v.uLongList=v.prototype.parseULongList;v.struct=v.prototype.parseStruct;v.coverage=v.prototype.parseCoverage;v.classDef=v.prototype.parseClassDef;var si={reserved:v.uShort,reqFeatureIndex:v.uShort,featureIndexes:v.uShortList};v.prototype.parseScriptList=function(){return this.parsePointer(v.recordList({tag:v.tag,script:v.pointer({defaultLangSys:v.pointer(si),langSysRecords:v.recordList({tag:v.tag,langSys:v.pointer(si)})})}))||[]};v.prototype.parseFeatureList=function(){return this.parsePointer(v.recordList({tag:v.tag,feature:v.pointer({featureParams:v.offset16,lookupListIndexes:v.uShortList})}))||[]};v.prototype.parseLookupList=function(t){return this.parsePointer(v.list(v.pointer(function(){var e=this.parseUShort();D.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(v.pointer(t[e])),markFilteringSet:n?this.parseUShort():void 0}})))||[]};v.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){var t=this.parseUShort(),e=this.parseUShort();D.argument(t===1&&e<1,"GPOS/GSUB feature variations table unknown.");var r=this.parseRecordList32({conditionSetOffset:v.offset32,featureTableSubstitutionOffset:v.offset32});return r})||[]};var M={getByte:ni,getCard8:ni,getUShort:_r,getCard16:_r,getShort:_a,getULong:Wn,getFixed:$i,getTag:Ya,getOffset:ja,getBytes:Ka,bytesToString:Ja,Parser:v};function eu(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 s=e.parseULong(),i=e.parseULong(),o=e.parseULong(),a=s;a<=i;a+=1)t.glyphIndexMap[a]=o,o++}function tu(t,e,r,n,s){t.length=e.parseUShort(),t.language=e.parseUShort();var i;t.segCount=i=e.parseUShort()>>1,e.skip("uShort",3),t.glyphIndexMap={};for(var o=new M.Parser(r,n+s+14),a=new M.Parser(r,n+s+16+i*2),u=new M.Parser(r,n+s+16+i*4),l=new M.Parser(r,n+s+16+i*6),f=n+s+16+i*8,c=0;c<i-1;c+=1)for(var h=void 0,p=o.parseUShort(),d=a.parseUShort(),m=u.parseShort(),x=l.parseUShort(),y=d;y<=p;y+=1)x!==0?(f=l.offset+l.relativeOffset-2,f+=x,f+=(y-d)*2,h=M.getUShort(r,f),h!==0&&(h=h+m&65535)):h=y+m&65535,t.glyphIndexMap[y]=h}function ru(t,e){var r={};r.version=M.getUShort(t,e),D.argument(r.version===0,"cmap table version should be 0."),r.numTables=M.getUShort(t,e+2);for(var n=-1,s=r.numTables-1;s>=0;s-=1){var i=M.getUShort(t,e+4+s*8),o=M.getUShort(t,e+4+s*8+2);if(i===3&&(o===0||o===1||o===10)||i===0&&(o===0||o===1||o===2||o===3||o===4)){n=M.getULong(t,e+4+s*8+4);break}}if(n===-1)throw new Error("No valid cmap sub-tables found.");var a=new M.Parser(t,e+n);if(r.format=a.parseUShort(),r.format===12)eu(r,a);else if(r.format===4)tu(r,a,t,e,n);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+r.format+").");return r}function nu(t,e,r){t.segments.push({end:e,start:e,delta:-(e-r),offset:0,glyphIndex:r})}function su(t){t.segments.push({end:65535,start:65535,delta:1,offset:0})}function iu(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 s=[{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||(s=s.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),s=s.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 i=new T.Table("cmap",s);for(i.segments=[],r=0;r<t.length;r+=1){for(var o=t.get(r),a=0;a<o.unicodes.length;a+=1)nu(i,o.unicodes[a],r);i.segments=i.segments.sort(function(L,S){return L.start-S.start})}su(i);var u=i.segments.length,l=0,f=[],c=[],h=[],p=[],d=[],m=[];for(r=0;r<u;r+=1){var x=i.segments[r];x.end<=65535&&x.start<=65535?(f=f.concat({name:"end_"+r,type:"USHORT",value:x.end}),c=c.concat({name:"start_"+r,type:"USHORT",value:x.start}),h=h.concat({name:"idDelta_"+r,type:"SHORT",value:x.delta}),p=p.concat({name:"idRangeOffset_"+r,type:"USHORT",value:x.offset}),x.glyphId!==void 0&&(d=d.concat({name:"glyph_"+r,type:"USHORT",value:x.glyphId}))):l+=1,!e&&x.glyphIndex!==void 0&&(m=m.concat({name:"cmap12Start_"+r,type:"ULONG",value:x.start}),m=m.concat({name:"cmap12End_"+r,type:"ULONG",value:x.end}),m=m.concat({name:"cmap12Glyph_"+r,type:"ULONG",value:x.glyphIndex}))}if(i.segCountX2=(u-l)*2,i.searchRange=Math.pow(2,Math.floor(Math.log(u-l)/Math.log(2)))*2,i.entrySelector=Math.log(i.searchRange/2)/Math.log(2),i.rangeShift=i.segCountX2-i.searchRange,i.fields=i.fields.concat(f),i.fields.push({name:"reservedPad",type:"USHORT",value:0}),i.fields=i.fields.concat(c),i.fields=i.fields.concat(h),i.fields=i.fields.concat(p),i.fields=i.fields.concat(d),i.cmap4Length=14+f.length*2+2+c.length*2+h.length*2+p.length*2+d.length*2,!e){var y=16+m.length*4;i.cmap12Offset=20+i.cmap4Length,i.fields=i.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}]),i.fields=i.fields.concat(m)}return i}var Xi={parse:ru,make:iu},zr=[".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"],ou=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],au=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],bt=[".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 qi(t){this.font=t}qi.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 s=r.get(n),i=0;i<s.unicodes.length;i+=1)if(s.unicodes[i]===e)return n}return null};function Wi(t){this.cmap=t}Wi.prototype.charToGlyphIndex=function(t){return this.cmap.glyphIndexMap[t.codePointAt(0)]||0};function Yr(t,e){this.encoding=t,this.charset=e}Yr.prototype.charToGlyphIndex=function(t){var e=t.codePointAt(0),r=this.encoding[e];return this.charset.indexOf(r)};function Zn(t){switch(t.version){case 1:this.names=bt.slice();break;case 2:this.names=new Array(t.numberOfGlyphs);for(var e=0;e<t.numberOfGlyphs;e++)t.glyphNameIndex[e]<bt.length?this.names[e]=bt[t.glyphNameIndex[e]]:this.names[e]=t.names[t.glyphNameIndex[e]-bt.length];break;case 2.5:this.names=new Array(t.numberOfGlyphs);for(var r=0;r<t.numberOfGlyphs;r++)this.names[r]=bt[r+t.glyphNameIndex[r]];break;case 3:this.names=[];break;default:this.names=[];break}}Zn.prototype.nameToGlyphIndex=function(t){return this.names.indexOf(t)};Zn.prototype.glyphIndexToName=function(t){return this.names[t]};function uu(t){for(var e,r=t.tables.cmap.glyphIndexMap,n=Object.keys(r),s=0;s<n.length;s+=1){var i=n[s],o=r[i];e=t.glyphs.get(o),e.addUnicode(parseInt(i))}for(var a=0;a<t.glyphs.length;a+=1)e=t.glyphs.get(a),t.cffEncoding?t.isCIDFont?e.name="gid"+a:e.name=t.cffEncoding.charset[a]:t.glyphNames.names&&(e.name=t.glyphNames.glyphIndexToName(a))}function lu(t){t._IndexToUnicodeMap={};for(var e=t.tables.cmap.glyphIndexMap,r=Object.keys(e),n=0;n<r.length;n+=1){var s=r[n],i=e[s];t._IndexToUnicodeMap[i]===void 0?t._IndexToUnicodeMap[i]={unicodes:[parseInt(s)]}:t._IndexToUnicodeMap[i].unicodes.push(parseInt(s))}}function fu(t,e){e.lowMemory?lu(t):uu(t)}function hu(t,e,r,n,s){t.beginPath(),t.moveTo(e,r),t.lineTo(n,s),t.stroke()}var yt={line:hu};function cu(t,e){var r=e||new xe;return{configurable:!0,get:function(){return typeof r=="function"&&(r=r()),r},set:function(n){r=n}}}function Ne(t){this.bindConstructorValues(t)}Ne.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",cu(this,t.path))};Ne.prototype.addUnicode=function(t){this.unicodes.length===0&&(this.unicode=t),this.unicodes.push(t)};Ne.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};Ne.prototype.getPath=function(t,e,r,n,s){t=t!==void 0?t:0,e=e!==void 0?e:0,r=r!==void 0?r:72;var i,o;n||(n={});var a=n.xScale,u=n.yScale;if(n.hinting&&s&&s.hinting&&(o=this.path&&s.hinting.exec(this,r)),o)i=s.hinting.getCommands(o),t=Math.round(t),e=Math.round(e),a=u=1;else{i=this.path.commands;var l=1/(this.path.unitsPerEm||1e3)*r;a===void 0&&(a=l),u===void 0&&(u=l)}for(var f=new xe,c=0;c<i.length;c+=1){var h=i[c];h.type==="M"?f.moveTo(t+h.x*a,e+-h.y*u):h.type==="L"?f.lineTo(t+h.x*a,e+-h.y*u):h.type==="Q"?f.quadraticCurveTo(t+h.x1*a,e+-h.y1*u,t+h.x*a,e+-h.y*u):h.type==="C"?f.curveTo(t+h.x1*a,e+-h.y1*u,t+h.x2*a,e+-h.y2*u,t+h.x*a,e+-h.y*u):h.type==="Z"&&f.closePath()}return f};Ne.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 D.argument(e.length===0,"There are still points left in the current contour."),t};Ne.prototype.getMetrics=function(){for(var t=this.path.commands,e=[],r=[],n=0;n<t.length;n+=1){var s=t[n];s.type!=="Z"&&(e.push(s.x),r.push(s.y)),(s.type==="Q"||s.type==="C")&&(e.push(s.x1),r.push(s.y1)),s.type==="C"&&(e.push(s.x2),r.push(s.y2))}var i={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(i.xMin)||(i.xMin=0),isFinite(i.xMax)||(i.xMax=this.advanceWidth),isFinite(i.yMin)||(i.yMin=0),isFinite(i.yMax)||(i.yMax=0),i.rightSideBearing=this.advanceWidth-i.leftSideBearing-(i.xMax-i.xMin),i};Ne.prototype.draw=function(t,e,r,n,s){this.getPath(e,r,n,s).draw(t)};Ne.prototype.drawPoints=function(t,e,r,n){function s(c,h,p,d){t.beginPath();for(var m=0;m<c.length;m+=1)t.moveTo(h+c[m].x*d,p+c[m].y*d),t.arc(h+c[m].x*d,p+c[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 i=1/this.path.unitsPerEm*n,o=[],a=[],u=this.path,l=0;l<u.commands.length;l+=1){var f=u.commands[l];f.x!==void 0&&o.push({x:f.x,y:-f.y}),f.x1!==void 0&&a.push({x:f.x1,y:-f.y1}),f.x2!==void 0&&a.push({x:f.x2,y:-f.y2})}t.fillStyle="blue",s(o,e,r,i),t.fillStyle="red",s(a,e,r,i)};Ne.prototype.drawMetrics=function(t,e,r,n){var s;e=e!==void 0?e:0,r=r!==void 0?r:0,n=n!==void 0?n:24,s=1/this.path.unitsPerEm*n,t.lineWidth=1,t.strokeStyle="black",yt.line(t,e,-1e4,e,1e4),yt.line(t,-1e4,r,1e4,r);var i=this.xMin||0,o=this.yMin||0,a=this.xMax||0,u=this.yMax||0,l=this.advanceWidth||0;t.strokeStyle="blue",yt.line(t,e+i*s,-1e4,e+i*s,1e4),yt.line(t,e+a*s,-1e4,e+a*s,1e4),yt.line(t,-1e4,r+-o*s,1e4,r+-o*s),yt.line(t,-1e4,r+-u*s,1e4,r+-u*s),t.strokeStyle="green",yt.line(t,e+l*s,-1e4,e+l*s,1e4)};function Hr(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 _n(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}_n.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]};_n.prototype.push=function(t,e){this.glyphs[t]=e,this.length++};function pu(t,e){return new Ne({index:e,font:t})}function du(t,e,r,n,s,i){return function(){var o=new Ne({index:e,font:t});return o.path=function(){r(o,n,s);var a=i(t.glyphs,o);return a.unitsPerEm=t.unitsPerEm,a},Hr(o,"xMin","_xMin"),Hr(o,"xMax","_xMax"),Hr(o,"yMin","_yMin"),Hr(o,"yMax","_yMax"),o}}function gu(t,e,r,n){return function(){var s=new Ne({index:e,font:t});return s.path=function(){var i=r(t,s,n);return i.unitsPerEm=t.unitsPerEm,i},s}}var Ke={GlyphSet:_n,glyphLoader:pu,ttfGlyphLoader:du,cffGlyphLoader:gu};function Zi(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(!Zi(t[r],e[r]))return!1;return!0}else return!1}function Bn(t){var e;return t.length<1240?e=107:t.length<33900?e=1131:e=32768,e}function ut(t,e,r){var n=[],s=[],i=M.getCard16(t,e),o,a;if(i!==0){var u=M.getByte(t,e+2);o=e+(i+1)*u+2;for(var l=e+3,f=0;f<i+1;f+=1)n.push(M.getOffset(t,l,u)),l+=u;a=o+n[i]}else a=e+2;for(var c=0;c<n.length-1;c+=1){var h=M.getBytes(t,o+n[c],o+n[c+1]);r&&(h=r(h)),s.push(h)}return{objects:s,startOffset:e,endOffset:a}}function mu(t,e){var r=[],n=M.getCard16(t,e),s,i;if(n!==0){var o=M.getByte(t,e+2);s=e+(n+1)*o+2;for(var a=e+3,u=0;u<n+1;u+=1)r.push(M.getOffset(t,a,o)),a+=o;i=s+r[n]}else i=e+2;return{offsets:r,startOffset:e,endOffset:i}}function vu(t,e,r,n,s){var i=M.getCard16(r,n),o=0;if(i!==0){var a=M.getByte(r,n+2);o=n+(i+1)*a+2}var u=M.getBytes(r,o+e[t],o+e[t+1]);return s&&(u=s(u)),u}function xu(t){for(var e="",r=15,n=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];;){var s=t.parseByte(),i=s>>4,o=s&15;if(i===r||(e+=n[i],o===r))break;e+=n[o]}return parseFloat(e)}function yu(t,e){var r,n,s,i;if(e===28)return r=t.parseByte(),n=t.parseByte(),r<<8|n;if(e===29)return r=t.parseByte(),n=t.parseByte(),s=t.parseByte(),i=t.parseByte(),r<<24|n<<16|s<<8|i;if(e===30)return xu(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 bu(t){for(var e={},r=0;r<t.length;r+=1){var n=t[r][0],s=t[r][1],i=void 0;if(s.length===1?i=s[0]:i=s,e.hasOwnProperty(n)&&!isNaN(e[n]))throw new Error("Object "+e+" already has key "+n);e[n]=i}return e}function _i(t,e,r){e=e!==void 0?e:0;var n=new M.Parser(t,e),s=[],i=[];for(r=r!==void 0?r:t.length;n.relativeOffset<r;){var o=n.parseByte();o<=21?(o===12&&(o=1200+n.parseByte()),s.push([o,i]),i=[]):i.push(yu(n,o))}return bu(s)}function Qt(t,e){return e<=390?e=zr[e]:e=t[e-391],e}function Yi(t,e,r){for(var n={},s,i=0;i<e.length;i+=1){var o=e[i];if(Array.isArray(o.type)){var a=[];a.length=o.type.length;for(var u=0;u<o.type.length;u++)s=t[o.op]!==void 0?t[o.op][u]:void 0,s===void 0&&(s=o.value!==void 0&&o.value[u]!==void 0?o.value[u]:null),o.type[u]==="SID"&&(s=Qt(r,s)),a[u]=s;n[o.name]=a}else s=t[o.op],s===void 0&&(s=o.value!==void 0?o.value:null),o.type==="SID"&&(s=Qt(r,s)),n[o.name]=s}return n}function Su(t,e){var r={};return r.formatMajor=M.getCard8(t,e),r.formatMinor=M.getCard8(t,e+1),r.size=M.getCard8(t,e+2),r.offsetSize=M.getCard8(t,e+3),r.startOffset=e,r.endOffset=e+4,r}var ji=[{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"}],Ki=[{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 wu(t,e){var r=_i(t,0,t.byteLength);return Yi(r,ji,e)}function Ji(t,e,r,n){var s=_i(t,e,r);return Yi(s,Ki,n)}function ii(t,e,r,n){for(var s=[],i=0;i<r.length;i+=1){var o=new DataView(new Uint8Array(r[i]).buffer),a=wu(o,n);a._subrs=[],a._subrsBias=0,a._defaultWidthX=0,a._nominalWidthX=0;var u=a.private[0],l=a.private[1];if(u!==0&&l!==0){var f=Ji(t,l+e,u,n);if(a._defaultWidthX=f.defaultWidthX,a._nominalWidthX=f.nominalWidthX,f.subrs!==0){var c=l+f.subrs,h=ut(t,c+e);a._subrs=h.objects,a._subrsBias=Bn(a._subrs)}a._privateDict=f}s.push(a)}return s}function ku(t,e,r,n){var s,i,o=new M.Parser(t,e);r-=1;var a=[".notdef"],u=o.parseCard8();if(u===0)for(var l=0;l<r;l+=1)s=o.parseSID(),a.push(Qt(n,s));else if(u===1)for(;a.length<=r;){s=o.parseSID(),i=o.parseCard8();for(var f=0;f<=i;f+=1)a.push(Qt(n,s)),s+=1}else if(u===2)for(;a.length<=r;){s=o.parseSID(),i=o.parseCard16();for(var c=0;c<=i;c+=1)a.push(Qt(n,s)),s+=1}else throw new Error("Unknown charset format "+u);return a}function Eu(t,e,r){var n,s={},i=new M.Parser(t,e),o=i.parseCard8();if(o===0)for(var a=i.parseCard8(),u=0;u<a;u+=1)n=i.parseCard8(),s[n]=u;else if(o===1){var l=i.parseCard8();n=1;for(var f=0;f<l;f+=1)for(var c=i.parseCard8(),h=i.parseCard8(),p=c;p<=c+h;p+=1)s[p]=n,n+=1}else throw new Error("Unknown encoding format "+o);return new Yr(s,r)}function oi(t,e,r){var n,s,i,o,a=new xe,u=[],l=0,f=!1,c=!1,h=0,p=0,d,m,x,y;if(t.isCIDFont){var L=t.tables.cff.topDict._fdSelect[e.index],S=t.tables.cff.topDict._fdArray[L];d=S._subrs,m=S._subrsBias,x=S._defaultWidthX,y=S._nominalWidthX}else d=t.tables.cff.topDict._subrs,m=t.tables.cff.topDict._subrsBias,x=t.tables.cff.topDict._defaultWidthX,y=t.tables.cff.topDict._nominalWidthX;var A=x;function E(I,z){c&&a.closePath(),a.moveTo(I,z),c=!0}function F(){var I;I=u.length%2!==0,I&&!f&&(A=u.shift()+y),l+=u.length>>1,u.length=0,f=!0}function k(I){for(var z,B,$,ge,me,Y,G,q,ee,Q,se,le,K=0;K<I.length;){var w=I[K];switch(K+=1,w){case 1:F();break;case 3:F();break;case 4:u.length>1&&!f&&(A=u.shift()+y,f=!0),p+=u.pop(),E(h,p);break;case 5:for(;u.length>0;)h+=u.shift(),p+=u.shift(),a.lineTo(h,p);break;case 6:for(;u.length>0&&(h+=u.shift(),a.lineTo(h,p),u.length!==0);)p+=u.shift(),a.lineTo(h,p);break;case 7:for(;u.length>0&&(p+=u.shift(),a.lineTo(h,p),u.length!==0);)h+=u.shift(),a.lineTo(h,p);break;case 8:for(;u.length>0;)n=h+u.shift(),s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),h=i+u.shift(),p=o+u.shift(),a.curveTo(n,s,i,o,h,p);break;case 10:me=u.pop()+m,Y=d[me],Y&&k(Y);break;case 11:return;case 12:switch(w=I[K],K+=1,w){case 35:n=h+u.shift(),s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),G=i+u.shift(),q=o+u.shift(),ee=G+u.shift(),Q=q+u.shift(),se=ee+u.shift(),le=Q+u.shift(),h=se+u.shift(),p=le+u.shift(),u.shift(),a.curveTo(n,s,i,o,G,q),a.curveTo(ee,Q,se,le,h,p);break;case 34:n=h+u.shift(),s=p,i=n+u.shift(),o=s+u.shift(),G=i+u.shift(),q=o,ee=G+u.shift(),Q=o,se=ee+u.shift(),le=p,h=se+u.shift(),a.curveTo(n,s,i,o,G,q),a.curveTo(ee,Q,se,le,h,p);break;case 36:n=h+u.shift(),s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),G=i+u.shift(),q=o,ee=G+u.shift(),Q=o,se=ee+u.shift(),le=Q+u.shift(),h=se+u.shift(),a.curveTo(n,s,i,o,G,q),a.curveTo(ee,Q,se,le,h,p);break;case 37:n=h+u.shift(),s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),G=i+u.shift(),q=o+u.shift(),ee=G+u.shift(),Q=q+u.shift(),se=ee+u.shift(),le=Q+u.shift(),Math.abs(se-h)>Math.abs(le-p)?h=se+u.shift():p=le+u.shift(),a.curveTo(n,s,i,o,G,q),a.curveTo(ee,Q,se,le,h,p);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+w),u.length=0}break;case 14:u.length>0&&!f&&(A=u.shift()+y,f=!0),c&&(a.closePath(),c=!1);break;case 18:F();break;case 19:case 20:F(),K+=l+7>>3;break;case 21:u.length>2&&!f&&(A=u.shift()+y,f=!0),p+=u.pop(),h+=u.pop(),E(h,p);break;case 22:u.length>1&&!f&&(A=u.shift()+y,f=!0),h+=u.pop(),E(h,p);break;case 23:F();break;case 24:for(;u.length>2;)n=h+u.shift(),s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),h=i+u.shift(),p=o+u.shift(),a.curveTo(n,s,i,o,h,p);h+=u.shift(),p+=u.shift(),a.lineTo(h,p);break;case 25:for(;u.length>6;)h+=u.shift(),p+=u.shift(),a.lineTo(h,p);n=h+u.shift(),s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),h=i+u.shift(),p=o+u.shift(),a.curveTo(n,s,i,o,h,p);break;case 26:for(u.length%2&&(h+=u.shift());u.length>0;)n=h,s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),h=i,p=o+u.shift(),a.curveTo(n,s,i,o,h,p);break;case 27:for(u.length%2&&(p+=u.shift());u.length>0;)n=h+u.shift(),s=p,i=n+u.shift(),o=s+u.shift(),h=i+u.shift(),p=o,a.curveTo(n,s,i,o,h,p);break;case 28:z=I[K],B=I[K+1],u.push((z<<24|B<<16)>>16),K+=2;break;case 29:me=u.pop()+t.gsubrsBias,Y=t.gsubrs[me],Y&&k(Y);break;case 30:for(;u.length>0&&(n=h,s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),h=i+u.shift(),p=o+(u.length===1?u.shift():0),a.curveTo(n,s,i,o,h,p),u.length!==0);)n=h+u.shift(),s=p,i=n+u.shift(),o=s+u.shift(),p=o+u.shift(),h=i+(u.length===1?u.shift():0),a.curveTo(n,s,i,o,h,p);break;case 31:for(;u.length>0&&(n=h+u.shift(),s=p,i=n+u.shift(),o=s+u.shift(),p=o+u.shift(),h=i+(u.length===1?u.shift():0),a.curveTo(n,s,i,o,h,p),u.length!==0);)n=h,s=p+u.shift(),i=n+u.shift(),o=s+u.shift(),h=i+u.shift(),p=o+(u.length===1?u.shift():0),a.curveTo(n,s,i,o,h,p);break;default:w<32?console.log("Glyph "+e.index+": unknown operator "+w):w<247?u.push(w-139):w<251?(z=I[K],K+=1,u.push((w-247)*256+z+108)):w<255?(z=I[K],K+=1,u.push(-(w-251)*256-z-108)):(z=I[K],B=I[K+1],$=I[K+2],ge=I[K+3],K+=4,u.push((z<<24|B<<16|$<<8|ge)/65536))}}}return k(r),e.advanceWidth=A,a}function Pu(t,e,r,n){var s=[],i,o=new M.Parser(t,e),a=o.parseCard8();if(a===0)for(var u=0;u<r;u++){if(i=o.parseCard8(),i>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+n+")");s.push(i)}else if(a===3){var l=o.parseCard16(),f=o.parseCard16();if(f!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+f);for(var c,h=0;h<l;h++){if(i=o.parseCard8(),c=o.parseCard16(),i>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+n+")");if(c>r)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+c);for(;f<c;f++)s.push(i);f=c}if(c!==r)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+c)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+a);return s}function Lu(t,e,r,n){r.tables.cff={};var s=Su(t,e),i=ut(t,s.endOffset,M.bytesToString),o=ut(t,i.endOffset),a=ut(t,o.endOffset,M.bytesToString),u=ut(t,a.endOffset);r.gsubrs=u.objects,r.gsubrsBias=Bn(r.gsubrs);var l=ii(t,e,o.objects,a.objects);if(l.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+l.length);var f=l[0];if(r.tables.cff.topDict=f,f._privateDict&&(r.defaultWidthX=f._privateDict.defaultWidthX,r.nominalWidthX=f._privateDict.nominalWidthX),f.ros[0]!==void 0&&f.ros[1]!==void 0&&(r.isCIDFont=!0),r.isCIDFont){var c=f.fdArray,h=f.fdSelect;if(c===0||h===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");c+=e;var p=ut(t,c),d=ii(t,e,p.objects,a.objects);f._fdArray=d,h+=e,f._fdSelect=Pu(t,h,r.numGlyphs,d.length)}var m=e+f.private[1],x=Ji(t,m,f.private[0],a.objects);if(r.defaultWidthX=x.defaultWidthX,r.nominalWidthX=x.nominalWidthX,x.subrs!==0){var y=m+x.subrs,L=ut(t,y);r.subrs=L.objects,r.subrsBias=Bn(r.subrs)}else r.subrs=[],r.subrsBias=0;var S;n.lowMemory?(S=mu(t,e+f.charStrings),r.nGlyphs=S.offsets.length):(S=ut(t,e+f.charStrings),r.nGlyphs=S.objects.length);var A=ku(t,e+f.charset,r.nGlyphs,a.objects);if(f.encoding===0?r.cffEncoding=new Yr(ou,A):f.encoding===1?r.cffEncoding=new Yr(au,A):r.cffEncoding=Eu(t,e+f.encoding,A),r.encoding=r.encoding||r.cffEncoding,r.glyphs=new Ke.GlyphSet(r),n.lowMemory)r._push=function(k){var I=vu(k,S.offsets,t,e+f.charStrings);r.glyphs.push(k,Ke.cffGlyphLoader(r,k,oi,I))};else for(var E=0;E<r.nGlyphs;E+=1){var F=S.objects[E];r.glyphs.push(E,Ke.cffGlyphLoader(r,E,oi,F))}}function Qi(t,e){var r,n=zr.indexOf(t);return n>=0&&(r=n),n=e.indexOf(t),n>=0?r=n+zr.length:(r=zr.length+e.length,e.push(t)),r}function Iu(){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 Tu(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 eo(t,e,r){for(var n={},s=0;s<t.length;s+=1){var i=t[s],o=e[i.name];o!==void 0&&!Zi(o,i.value)&&(i.type==="SID"&&(o=Qi(o,r)),n[i.op]={name:i.name,type:i.type,value:o})}return n}function ai(t,e){var r=new T.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return r.dict=eo(ji,t,e),r}function ui(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 Cu(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 Mu(){return new T.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Au(t,e){for(var r=new T.Record("Charsets",[{name:"format",type:"Card8",value:0}]),n=0;n<t.length;n+=1){var s=t[n],i=Qi(s,e);r.fields.push({name:"glyph_"+n,type:"SID",value:i})}return r}function Ou(t){var e=[],r=t.path;e.push({name:"width",type:"NUMBER",value:t.advanceWidth});for(var n=0,s=0,i=0;i<r.commands.length;i+=1){var o=void 0,a=void 0,u=r.commands[i];if(u.type==="Q"){var l=.3333333333333333,f=2/3;u={type:"C",x:u.x,y:u.y,x1:Math.round(l*n+f*u.x1),y1:Math.round(l*s+f*u.y1),x2:Math.round(l*u.x+f*u.x1),y2:Math.round(l*u.y+f*u.y1)}}if(u.type==="M")o=Math.round(u.x-n),a=Math.round(u.y-s),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rmoveto",type:"OP",value:21}),n=Math.round(u.x),s=Math.round(u.y);else if(u.type==="L")o=Math.round(u.x-n),a=Math.round(u.y-s),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rlineto",type:"OP",value:5}),n=Math.round(u.x),s=Math.round(u.y);else if(u.type==="C"){var c=Math.round(u.x1-n),h=Math.round(u.y1-s),p=Math.round(u.x2-u.x1),d=Math.round(u.y2-u.y1);o=Math.round(u.x-u.x2),a=Math.round(u.y-u.y2),e.push({name:"dx1",type:"NUMBER",value:c}),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:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rrcurveto",type:"OP",value:8}),n=Math.round(u.x),s=Math.round(u.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function Fu(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),s=Ou(n);e.charStrings.push({name:n.name,type:"CHARSTRING",value:s})}return e}function Du(t,e){var r=new T.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return r.dict=eo(Ki,t,e),r}function Uu(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,s={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]},i={},o=[],a,u=1;u<t.length;u+=1)a=t.get(u),o.push(a.name);var l=[];r.header=Iu(),r.nameIndex=Tu([e.postScriptName]);var f=ai(s,l);r.topDictIndex=ui(f),r.globalSubrIndex=Mu(),r.charsets=Au(o,l),r.charStringsIndex=Fu(t),r.privateDict=Du(i,l),r.stringIndex=Cu(l);var c=r.header.sizeOf()+r.nameIndex.sizeOf()+r.topDictIndex.sizeOf()+r.stringIndex.sizeOf()+r.globalSubrIndex.sizeOf();return s.charset=c,s.encoding=0,s.charStrings=s.charset+r.charsets.sizeOf(),s.private[1]=s.charStrings+r.charStringsIndex.sizeOf(),f=ai(s,l),r.topDictIndex=ui(f),r}var to={parse:Lu,make:Uu};function Ru(t,e){var r={},n=new M.Parser(t,e);return r.version=n.parseVersion(),r.fontRevision=Math.round(n.parseFixed()*1e3)/1e3,r.checkSumAdjustment=n.parseULong(),r.magicNumber=n.parseULong(),D.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 Nu(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 ro={parse:Ru,make:Nu};function Bu(t,e){var r={},n=new M.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 Gu(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 no={parse:Bu,make:Gu};function Hu(t,e,r,n,s){for(var i,o,a=new M.Parser(t,e),u=0;u<n;u+=1){u<r&&(i=a.parseUShort(),o=a.parseShort());var l=s.get(u);l.advanceWidth=i,l.leftSideBearing=o}}function Vu(t,e,r,n,s){t._hmtxTableData={};for(var i,o,a=new M.Parser(e,r),u=0;u<s;u+=1)u<n&&(i=a.parseUShort(),o=a.parseShort()),t._hmtxTableData[u]={advanceWidth:i,leftSideBearing:o}}function zu(t,e,r,n,s,i,o){o.lowMemory?Vu(t,e,r,n,s):Hu(e,r,n,s,i)}function $u(t){for(var e=new T.Table("hmtx",[]),r=0;r<t.length;r+=1){var n=t.get(r),s=n.advanceWidth||0,i=n.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+r,type:"USHORT",value:s}),e.fields.push({name:"leftSideBearing_"+r,type:"SHORT",value:i})}return e}var so={parse:zu,make:$u};function Xu(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,s=0;s<t.length;++s){var i=r.indexOf(t[s]);i<0&&(i=r.length,r+=t[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:n+i}),e.fields.push({name:"length "+s,type:"USHORT",value:t[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:r}),e}function qu(t,e){var r=new M.Parser(t,e),n=r.parseULong();D.argument(n===1,"Unsupported ltag table version."),r.skip("uLong",1);for(var s=r.parseULong(),i=[],o=0;o<s;o++){for(var a="",u=e+r.parseUShort(),l=r.parseUShort(),f=u;f<u+l;++f)a+=String.fromCharCode(t.getInt8(f));i.push(a)}return i}var io={make:Xu,parse:qu};function Wu(t,e){var r={},n=new M.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 Zu(t){return new T.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:t}])}var oo={parse:Wu,make:Zu},ao=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],uo={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"},_u={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},lo={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 Yu(t,e,r){switch(t){case 0:if(e===65535)return"und";if(r)return r[e];break;case 1:return uo[e];case 3:return lo[e]}}var Gn="utf-16",ju={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"},Ku={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 fo(t,e,r){switch(t){case 0:return Gn;case 1:return Ku[r]||ju[e];case 3:if(e===1||e===10)return Gn;break}}function Ju(t,e,r){for(var n={},s=new M.Parser(t,e),i=s.parseUShort(),o=s.parseUShort(),a=s.offset+s.parseUShort(),u=0;u<o;u++){var l=s.parseUShort(),f=s.parseUShort(),c=s.parseUShort(),h=s.parseUShort(),p=ao[h]||h,d=s.parseUShort(),m=s.parseUShort(),x=Yu(l,c,r),y=fo(l,f,c);if(y!==void 0&&x!==void 0){var L=void 0;if(y===Gn?L=Dt.UTF16(t,a+m,d):L=Dt.MACSTRING(t,a+m,d,y),L){var S=n[p];S===void 0&&(S=n[p]={}),S[x]=L}}}var A=0;return i===1&&(A=s.parseUShort()),n}function Ln(t){var e={};for(var r in t)e[t[r]]=parseInt(r);return e}function li(t,e,r,n,s,i){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:s},{name:"offset",type:"USHORT",value:i}])}function Qu(t,e){var r=t.length,n=e.length-r+1;e:for(var s=0;s<n;s++)for(;s<n;s++){for(var i=0;i<r;i++)if(e[s+i]!==t[i])continue e;return s}return-1}function fi(t,e){var r=Qu(t,e);if(r<0){r=e.length;for(var n=0,s=t.length;n<s;++n)e.push(t[n])}return r}function el(t,e){var r,n=[],s={},i=Ln(ao);for(var o in t){var a=i[o];if(a===void 0&&(a=o),r=parseInt(a),isNaN(r))throw new Error('Name table entry "'+o+'" does not exist, see nameTableNames for complete list.');s[r]=t[o],n.push(r)}for(var u=Ln(uo),l=Ln(lo),f=[],c=[],h=0;h<n.length;h++){r=n[h];var p=s[r];for(var d in p){var m=p[d],x=1,y=u[d],L=_u[y],S=fo(x,L,y),A=P.MACSTRING(m,S);A===void 0&&(x=0,y=e.indexOf(d),y<0&&(y=e.length,e.push(d)),L=4,A=P.UTF16(m));var E=fi(A,c);f.push(li(x,L,y,r,A.length,E));var F=l[d];if(F!==void 0){var k=P.UTF16(m),I=fi(k,c);f.push(li(3,1,F,r,k.length,I))}}}f.sort(function($,ge){return $.platformID-ge.platformID||$.encodingID-ge.encodingID||$.languageID-ge.languageID||$.nameID-ge.nameID});for(var z=new T.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:f.length},{name:"stringOffset",type:"USHORT",value:6+f.length*12}]),B=0;B<f.length;B++)z.fields.push({name:"record_"+B,type:"RECORD",value:f[B]});return z.fields.push({name:"strings",type:"LITERAL",value:c}),z}var ho={parse:Ju,make:el},Hn=[{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 tl(t){for(var e=0;e<Hn.length;e+=1){var r=Hn[e];if(t>=r.begin&&t<r.end)return e}return-1}function rl(t,e){var r={},n=new M.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 s=0;s<10;s++)r.panose[s]=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 nl(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 Vn={parse:rl,make:nl,unicodeRanges:Hn,getUnicodeRange:tl};function sl(t,e){var r={},n=new M.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=bt.slice();break;case 2:r.numberOfGlyphs=n.parseUShort(),r.glyphNameIndex=new Array(r.numberOfGlyphs);for(var s=0;s<r.numberOfGlyphs;s++)r.glyphNameIndex[s]=n.parseUShort();r.names=[];for(var i=0;i<r.numberOfGlyphs;i++)if(r.glyphNameIndex[i]>=bt.length){var o=n.parseChar();r.names.push(n.parseString(o))}break;case 2.5:r.numberOfGlyphs=n.parseUShort(),r.offset=new Array(r.numberOfGlyphs);for(var a=0;a<r.numberOfGlyphs;a++)r.offset[a]=n.parseChar();break}return r}function il(){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 co={parse:sl,make:il},Ve=new Array(9);Ve[1]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();if(r===1)return{substFormat:1,coverage:this.parsePointer(v.coverage),deltaGlyphId:this.parseUShort()};if(r===2)return{substFormat:2,coverage:this.parsePointer(v.coverage),substitute:this.parseOffset16List()};D.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")};Ve[2]=function(){var e=this.parseUShort();return D.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(v.coverage),sequences:this.parseListOfLists()}};Ve[3]=function(){var e=this.parseUShort();return D.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(v.coverage),alternateSets:this.parseListOfLists()}};Ve[4]=function(){var e=this.parseUShort();return D.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(v.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Ft={sequenceIndex:v.uShort,lookupListIndex:v.uShort};Ve[5]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();if(r===1)return{substFormat:r,coverage:this.parsePointer(v.coverage),ruleSets:this.parseListOfLists(function(){var i=this.parseUShort(),o=this.parseUShort();return{input:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(o,Ft)}})};if(r===2)return{substFormat:r,coverage:this.parsePointer(v.coverage),classDef:this.parsePointer(v.classDef),classSets:this.parseListOfLists(function(){var i=this.parseUShort(),o=this.parseUShort();return{classes:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(o,Ft)}})};if(r===3){var n=this.parseUShort(),s=this.parseUShort();return{substFormat:r,coverages:this.parseList(n,v.pointer(v.coverage)),lookupRecords:this.parseRecordList(s,Ft)}}D.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")};Ve[6]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();if(r===1)return{substFormat:1,coverage:this.parsePointer(v.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ft)}})};if(r===2)return{substFormat:2,coverage:this.parsePointer(v.coverage),backtrackClassDef:this.parsePointer(v.classDef),inputClassDef:this.parsePointer(v.classDef),lookaheadClassDef:this.parsePointer(v.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ft)}})};if(r===3)return{substFormat:3,backtrackCoverage:this.parseList(v.pointer(v.coverage)),inputCoverage:this.parseList(v.pointer(v.coverage)),lookaheadCoverage:this.parseList(v.pointer(v.coverage)),lookupRecords:this.parseRecordList(Ft)};D.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")};Ve[7]=function(){var e=this.parseUShort();D.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");var r=this.parseUShort(),n=new v(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:r,extension:Ve[r].call(n)}};Ve[8]=function(){var e=this.parseUShort();return D.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(v.coverage),backtrackCoverage:this.parseList(v.pointer(v.coverage)),lookaheadCoverage:this.parseList(v.pointer(v.coverage)),substitutes:this.parseUShortList()}};function ol(t,e){e=e||0;var r=new v(t,e),n=r.parseVersion(1);return D.argument(n===1||n===1.1,"Unsupported GSUB table version."),n===1?{version:n,scripts:r.parseScriptList(),features:r.parseFeatureList(),lookups:r.parseLookupList(Ve)}:{version:n,scripts:r.parseScriptList(),features:r.parseFeatureList(),lookups:r.parseLookupList(Ve),variations:r.parseFeatureVariationsList()}}var Ut=new Array(9);Ut[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)))};Ut[2]=function(e){return D.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))})))};Ut[3]=function(e){return D.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))})))};Ut[4]=function(e){return D.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)))}))})))};Ut[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(i){return new T.Table("chainRuleSetTable",T.tableList("chainRule",i,function(o){var a=T.ushortList("backtrackGlyph",o.backtrack,o.backtrack.length).concat(T.ushortList("inputGlyph",o.input,o.input.length+1)).concat(T.ushortList("lookaheadGlyph",o.lookahead,o.lookahead.length)).concat(T.ushortList("substitution",[],o.lookupRecords.length));return o.lookupRecords.forEach(function(u,l){a=a.concat({name:"sequenceIndex"+l,type:"USHORT",value:u.sequenceIndex}).concat({name:"lookupListIndex"+l,type:"USHORT",value:u.lookupListIndex})}),new T.Table("chainRuleTable",a)}))})));return r}else if(e.substFormat===2)D.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(i,o){n.push({name:"backtrackCoverage"+o,type:"TABLE",value:new T.Coverage(i)})}),n.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length}),e.inputCoverage.forEach(function(i,o){n.push({name:"inputCoverage"+o,type:"TABLE",value:new T.Coverage(i)})}),n.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length}),e.lookaheadCoverage.forEach(function(i,o){n.push({name:"lookaheadCoverage"+o,type:"TABLE",value:new T.Coverage(i)})}),n.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length}),e.lookupRecords.forEach(function(i,o){n=n.concat({name:"sequenceIndex"+o,type:"USHORT",value:i.sequenceIndex}).concat({name:"lookupListIndex"+o,type:"USHORT",value:i.lookupListIndex})});var s=new T.Table("chainContextTable",n);return s}D.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function al(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,Ut)}])}var po={parse:ol,make:al};function ul(t,e){var r=new M.Parser(t,e),n=r.parseULong();D.argument(n===1,"Unsupported META table version."),r.parseULong(),r.parseULong();for(var s=r.parseULong(),i={},o=0;o<s;o++){var a=r.parseTag(),u=r.parseULong(),l=r.parseULong(),f=Dt.UTF8(t,e+u,l);i[a]=f}return i}function ll(t){var e=Object.keys(t).length,r="",n=16+e*12,s=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 i in t){var o=r.length;r+=t[i],s.fields.push({name:"tag "+i,type:"TAG",value:i}),s.fields.push({name:"offset "+i,type:"ULONG",value:n+o}),s.fields.push({name:"length "+i,type:"ULONG",value:t[i].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:r}),s}var go={parse:ul,make:ll};function hi(t){return Math.log(t)/Math.log(2)|0}function Yn(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 ci(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 mo(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,hi(e.numTables));e.searchRange=16*r,e.entrySelector=hi(r),e.rangeShift=e.numTables*16-e.searchRange;for(var n=[],s=[],i=e.sizeOf()+ci().sizeOf()*e.numTables;i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0});for(var o=0;o<t.length;o+=1){var a=t[o];D.argument(a.tableName.length===4,"Table name"+a.tableName+" is invalid.");var u=a.sizeOf(),l=ci(a.tableName,Yn(a.encode()),i,u);for(n.push({name:l.tag+" Table Record",type:"RECORD",value:l}),s.push({name:a.tableName+" table",type:"RECORD",value:a}),i+=u,D.argument(!isNaN(i),"Something went wrong calculating the offset.");i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0})}return n.sort(function(f,c){return f.value.tag>c.value.tag?1:-1}),e.fields=e.fields.concat(n),e.fields=e.fields.concat(s),e}function pi(t,e,r){for(var n=0;n<e.length;n+=1){var s=t.charToGlyphIndex(e[n]);if(s>0){var i=t.glyphs.get(s);return i.getMetrics()}}return r}function fl(t){for(var e=0,r=0;r<t.length;r+=1)e+=t[r];return e/t.length}function hl(t){for(var e=[],r=[],n=[],s=[],i=[],o=[],a=[],u,l=0,f=0,c=0,h=0,p=0,d=0;d<t.glyphs.length;d+=1){var m=t.glyphs.get(d),x=m.unicode|0;if(isNaN(m.advanceWidth))throw new Error("Glyph "+m.name+" ("+d+"): advanceWidth is not a number.");(u>x||u===void 0)&&x>0&&(u=x),l<x&&(l=x);var y=Vn.getUnicodeRange(x);if(y<32)f|=1<<y;else if(y<64)c|=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 L=m.getMetrics();e.push(L.xMin),r.push(L.yMin),n.push(L.xMax),s.push(L.yMax),o.push(L.leftSideBearing),a.push(L.rightSideBearing),i.push(m.advanceWidth)}}var S={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,r),xMax:Math.max.apply(null,n),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,i),advanceWidthAvg:fl(i),minLeftSideBearing:Math.min.apply(null,o),maxLeftSideBearing:Math.max.apply(null,o),minRightSideBearing:Math.min.apply(null,a)};S.ascender=t.ascender,S.descender=t.descender;var A=ro.make({flags:3,unitsPerEm:t.unitsPerEm,xMin:S.xMin,yMin:S.yMin,xMax:S.xMax,yMax:S.yMax,lowestRecPPEM:3,createdTimestamp:t.createdTimestamp}),E=no.make({ascender:S.ascender,descender:S.descender,advanceWidthMax:S.advanceWidthMax,minLeftSideBearing:S.minLeftSideBearing,minRightSideBearing:S.minRightSideBearing,xMaxExtent:S.maxLeftSideBearing+(S.xMax-S.xMin),numberOfHMetrics:t.glyphs.length}),F=oo.make(t.glyphs.length),k=Vn.make(Object.assign({xAvgCharWidth:Math.round(S.advanceWidthAvg),usFirstCharIndex:u,usLastCharIndex:l,ulUnicodeRange1:f,ulUnicodeRange2:c,ulUnicodeRange3:h,ulUnicodeRange4:p,sTypoAscender:S.ascender,sTypoDescender:S.descender,sTypoLineGap:0,usWinAscent:S.yMax,usWinDescent:Math.abs(S.yMin),ulCodePageRange1:1,sxHeight:pi(t,"xyvw",{yMax:Math.round(S.ascender/2)}).yMax,sCapHeight:pi(t,"HIKLEFJMNTZBDPRAGOQSUVWXY",S).yMax,usDefaultChar:t.hasChar(" ")?32:0,usBreakChar:t.hasChar(" ")?32:0},t.tables.os2)),I=so.make(t.glyphs),z=Xi.make(t.glyphs),B=t.getEnglishName("fontFamily"),$=t.getEnglishName("fontSubfamily"),ge=B+" "+$,me=t.getEnglishName("postScriptName");me||(me=B.replace(/\s/g,"")+"-"+$);var Y={};for(var G in t.names)Y[G]=t.names[G];Y.uniqueID||(Y.uniqueID={en:t.getEnglishName("manufacturer")+":"+ge}),Y.postScriptName||(Y.postScriptName={en:me}),Y.preferredFamily||(Y.preferredFamily=t.names.fontFamily),Y.preferredSubfamily||(Y.preferredSubfamily=t.names.fontSubfamily);var q=[],ee=ho.make(Y,q),Q=q.length>0?io.make(q):void 0,se=co.make(),le=to.make(t.glyphs,{version:t.getEnglishName("version"),fullName:ge,familyName:B,weightName:$,postScriptName:me,unitsPerEm:t.unitsPerEm,fontBBox:[0,S.yMin,S.ascender,S.advanceWidthMax]}),K=t.metas&&Object.keys(t.metas).length>0?go.make(t.metas):void 0,w=[A,E,F,k,ee,z,se,le,I];Q&&w.push(Q),t.tables.gsub&&w.push(po.make(t.tables.gsub)),K&&w.push(K);for(var R=mo(w),W=R.encode(),ie=Yn(W),ne=R.fields,oe=!1,fe=0;fe<ne.length;fe+=1)if(ne[fe].name==="head table"){ne[fe].value.checkSumAdjustment=2981146554-ie,oe=!0;break}if(!oe)throw new Error("Could not find head table with checkSum to adjust.");return R}var cl={make:mo,fontToTable:hl,computeCheckSum:Yn};function In(t,e){for(var r=0,n=t.length-1;r<=n;){var s=r+n>>>1,i=t[s].tag;if(i===e)return s;i<e?r=s+1:n=s-1}return-r-1}function di(t,e){for(var r=0,n=t.length-1;r<=n;){var s=r+n>>>1,i=t[s];if(i===e)return s;i<e?r=s+1:n=s-1}return-r-1}function gi(t,e){for(var r,n=0,s=t.length-1;n<=s;){var i=n+s>>>1;r=t[i];var o=r.start;if(o===e)return r;o<e?n=i+1:s=i-1}if(n>0)return r=t[n-1],e>r.end?0:r}function sr(t,e){this.font=t,this.tableName=e}sr.prototype={searchTag:In,binSearch:di,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,s=In(r.scripts,t);if(s>=0)return n[s].script;if(e){var i={tag:t,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return n.splice(-1-s,0,i),i.script}}},getLangSysTable:function(t,e,r){var n=this.getScriptTable(t,r);if(n){if(!e||e==="dflt"||e==="DFLT")return n.defaultLangSys;var s=In(n.langSysRecords,e);if(s>=0)return n.langSysRecords[s].langSys;if(r){var i={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return n.langSysRecords.splice(-1-s,0,i),i.langSys}}},getFeatureTable:function(t,e,r,n){var s=this.getLangSysTable(t,e,n);if(s){for(var i,o=s.featureIndexes,a=this.font.tables[this.tableName].features,u=0;u<o.length;u++)if(i=a[o[u]],i.tag===r)return i.feature;if(n){var l=a.length;return D.assert(l===0||r>=a[l-1].tag,"Features must be added in alphabetical order."),i={tag:r,feature:{params:0,lookupListIndexes:[]}},a.push(i),o.push(l),i.feature}}},getLookupTables:function(t,e,r,n,s){var i=this.getFeatureTable(t,e,r,s),o=[];if(i){for(var a,u=i.lookupListIndexes,l=this.font.tables[this.tableName].lookups,f=0;f<u.length;f++)a=l[u[f]],a.lookupType===n&&o.push(a);if(o.length===0&&s){a={lookupType:n,lookupFlag:0,subtables:[],markFilteringSet:void 0};var c=l.length;return l.push(a),u.push(c),[a]}}return o},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=gi(t.ranges,e);return r?r.classId:0}},getCoverageIndex:function(t,e){switch(t.format){case 1:var r=di(t.glyphs,e);return r>=0?r:-1;case 2:var n=gi(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 s=r[n],i=s.start,o=s.end,a=i;a<=o;a++)e.push(a);return e}};function ir(t){sr.call(this,t,"gpos")}ir.prototype=sr.prototype;ir.prototype.init=function(){var t=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(t)};ir.prototype.getKerningValue=function(t,e,r){for(var n=0;n<t.length;n++)for(var s=t[n].subtables,i=0;i<s.length;i++){var o=s[i],a=this.getCoverageIndex(o.coverage,e);if(!(a<0))switch(o.posFormat){case 1:for(var u=o.pairSets[a],l=0;l<u.length;l++){var f=u[l];if(f.secondGlyph===r)return f.value1&&f.value1.xAdvance||0}break;case 2:var c=this.getGlyphClass(o.classDef1,e),h=this.getGlyphClass(o.classDef2,r),p=o.classRecords[c][h];return p.value1&&p.value1.xAdvance||0}}return 0};ir.prototype.getKerningTables=function(t,e){if(this.font.tables.gpos)return this.getLookupTables(t,e,"kern",2)};function Ae(t){sr.call(this,t,"gsub")}function pl(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 jn(t,e,r){for(var n=t.subtables,s=0;s<n.length;s++){var i=n[s];if(i.substFormat===e)return i}if(r)return n.push(r),r}Ae.prototype=sr.prototype;Ae.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}};Ae.prototype.getSingle=function(t,e,r){for(var n=[],s=this.getLookupTables(e,r,t,1),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++){var u=o[a],l=this.expandCoverage(u.coverage),f=void 0;if(u.substFormat===1){var c=u.deltaGlyphId;for(f=0;f<l.length;f++){var h=l[f];n.push({sub:h,by:h+c})}}else{var p=u.substitute;for(f=0;f<l.length;f++)n.push({sub:l[f],by:p[f]})}}return n};Ae.prototype.getMultiple=function(t,e,r){for(var n=[],s=this.getLookupTables(e,r,t,2),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++){var u=o[a],l=this.expandCoverage(u.coverage),f=void 0;for(f=0;f<l.length;f++){var c=l[f],h=u.sequences[f];n.push({sub:c,by:h})}}return n};Ae.prototype.getAlternates=function(t,e,r){for(var n=[],s=this.getLookupTables(e,r,t,3),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++)for(var u=o[a],l=this.expandCoverage(u.coverage),f=u.alternateSets,c=0;c<l.length;c++)n.push({sub:l[c],by:f[c]});return n};Ae.prototype.getLigatures=function(t,e,r){for(var n=[],s=this.getLookupTables(e,r,t,4),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++)for(var u=o[a],l=this.expandCoverage(u.coverage),f=u.ligatureSets,c=0;c<l.length;c++)for(var h=l[c],p=f[c],d=0;d<p.length;d++){var m=p[d];n.push({sub:[h].concat(m.components),by:m.ligGlyph})}return n};Ae.prototype.addSingle=function(t,e,r,n){var s=this.getLookupTables(r,n,t,1,!0)[0],i=jn(s,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});D.assert(i.coverage.format===1,"Single: unable to modify coverage table format "+i.coverage.format);var o=e.sub,a=this.binSearch(i.coverage.glyphs,o);a<0&&(a=-1-a,i.coverage.glyphs.splice(a,0,o),i.substitute.splice(a,0,0)),i.substitute[a]=e.by};Ae.prototype.addMultiple=function(t,e,r,n){D.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');var s=this.getLookupTables(r,n,t,2,!0)[0],i=jn(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});D.assert(i.coverage.format===1,"Multiple: unable to modify coverage table format "+i.coverage.format);var o=e.sub,a=this.binSearch(i.coverage.glyphs,o);a<0&&(a=-1-a,i.coverage.glyphs.splice(a,0,o),i.sequences.splice(a,0,0)),i.sequences[a]=e.by};Ae.prototype.addAlternate=function(t,e,r,n){var s=this.getLookupTables(r,n,t,3,!0)[0],i=jn(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});D.assert(i.coverage.format===1,"Alternate: unable to modify coverage table format "+i.coverage.format);var o=e.sub,a=this.binSearch(i.coverage.glyphs,o);a<0&&(a=-1-a,i.coverage.glyphs.splice(a,0,o),i.alternateSets.splice(a,0,0)),i.alternateSets[a]=e.by};Ae.prototype.addLigature=function(t,e,r,n){var s=this.getLookupTables(r,n,t,4,!0)[0],i=s.subtables[0];i||(i={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=i),D.assert(i.coverage.format===1,"Ligature: unable to modify coverage table format "+i.coverage.format);var o=e.sub[0],a=e.sub.slice(1),u={ligGlyph:e.by,components:a},l=this.binSearch(i.coverage.glyphs,o);if(l>=0){for(var f=i.ligatureSets[l],c=0;c<f.length;c++)if(pl(f[c].components,a))return;f.push(u)}else l=-1-l,i.coverage.glyphs.splice(l,0,o),i.ligatureSets.splice(l,0,[u])};Ae.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)}};Ae.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 dl(){return typeof window<"u"}function gl(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 Jt(t,e){if(!t)throw e}function mi(t,e,r,n,s){var i;return(e&n)>0?(i=t.parseByte(),(e&s)===0&&(i=-i),i=r+i):(e&s)>0?i=r:i=r+t.parseShort(),i}function vo(t,e,r){var n=new M.Parser(e,r);t.numberOfContours=n.parseShort(),t._xMin=n.parseShort(),t._yMin=n.parseShort(),t._xMax=n.parseShort(),t._yMax=n.parseShort();var s,i;if(t.numberOfContours>0){for(var o=t.endPointIndices=[],a=0;a<t.numberOfContours;a+=1)o.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=o[o.length-1]+1;s=[];for(var f=0;f<l;f+=1)if(i=n.parseByte(),s.push(i),(i&8)>0)for(var c=n.parseByte(),h=0;h<c;h+=1)s.push(i),f+=1;if(D.argument(s.length===l,"Bad flags."),o.length>0){var p=[],d;if(l>0){for(var m=0;m<l;m+=1)i=s[m],d={},d.onCurve=!!(i&1),d.lastPointOfContour=o.indexOf(m)>=0,p.push(d);for(var x=0,y=0;y<l;y+=1)i=s[y],d=p[y],d.x=mi(n,i,x,2,16),x=d.x;for(var L=0,S=0;S<l;S+=1)i=s[S],d=p[S],d.y=mi(n,i,L,4,32),L=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 A=!0;A;){s=n.parseUShort();var E={glyphIndex:n.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(E.dx=n.parseShort(),E.dy=n.parseShort()):E.matchedPoints=[n.parseUShort(),n.parseUShort()]:(s&2)>0?(E.dx=n.parseChar(),E.dy=n.parseChar()):E.matchedPoints=[n.parseByte(),n.parseByte()],(s&8)>0?E.xScale=E.yScale=n.parseF2Dot14():(s&64)>0?(E.xScale=n.parseF2Dot14(),E.yScale=n.parseF2Dot14()):(s&128)>0&&(E.xScale=n.parseF2Dot14(),E.scale01=n.parseF2Dot14(),E.scale10=n.parseF2Dot14(),E.yScale=n.parseF2Dot14()),t.components.push(E),A=!!(s&32)}if(s&256){t.instructionLength=n.parseUShort(),t.instructions=[];for(var F=0;F<t.instructionLength;F+=1)t.instructions.push(n.parseByte())}}}function Tn(t,e){for(var r=[],n=0;n<t.length;n+=1){var s=t[n],i={x:e.xScale*s.x+e.scale01*s.y+e.dx,y:e.scale10*s.x+e.yScale*s.y+e.dy,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour};r.push(i)}return r}function ml(t){for(var e=[],r=[],n=0;n<t.length;n+=1){var s=t[n];r.push(s),s.lastPointOfContour&&(e.push(r),r=[])}return D.argument(r.length===0,"There are still points left in the current contour."),e}function xo(t){var e=new xe;if(!t)return e;for(var r=ml(t),n=0;n<r.length;++n){var s=r[n],i=null,o=s[s.length-1],a=s[0];if(o.onCurve)e.moveTo(o.x,o.y);else if(a.onCurve)e.moveTo(a.x,a.y);else{var u={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5};e.moveTo(u.x,u.y)}for(var l=0;l<s.length;++l)if(i=o,o=a,a=s[(l+1)%s.length],o.onCurve)e.lineTo(o.x,o.y);else{var f=i,c=a;i.onCurve||(f={x:(o.x+i.x)*.5,y:(o.y+i.y)*.5}),a.onCurve||(c={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5}),e.quadraticCurveTo(o.x,o.y,c.x,c.y)}e.closePath()}return e}function yo(t,e){if(e.isComposite)for(var r=0;r<e.components.length;r+=1){var n=e.components[r],s=t.get(n.glyphIndex);if(s.getPath(),s.points){var i=void 0;if(n.matchedPoints===void 0)i=Tn(s.points,n);else{if(n.matchedPoints[0]>e.points.length-1||n.matchedPoints[1]>s.points.length-1)throw Error("Matched points out of range in "+e.name);var o=e.points[n.matchedPoints[0]],a=s.points[n.matchedPoints[1]],u={xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:0,dy:0};a=Tn([a],u)[0],u.dx=o.x-a.x,u.dy=o.y-a.y,i=Tn(s.points,u)}e.points=e.points.concat(i)}}return xo(e.points)}function vl(t,e,r,n){for(var s=new Ke.GlyphSet(n),i=0;i<r.length-1;i+=1){var o=r[i],a=r[i+1];o!==a?s.push(i,Ke.ttfGlyphLoader(n,i,vo,t,e+o,yo)):s.push(i,Ke.glyphLoader(n,i))}return s}function xl(t,e,r,n){var s=new Ke.GlyphSet(n);return n._push=function(i){var o=r[i],a=r[i+1];o!==a?s.push(i,Ke.ttfGlyphLoader(n,i,vo,t,e+o,yo)):s.push(i,Ke.glyphLoader(n,i))},s}function yl(t,e,r,n,s){return s.lowMemory?xl(t,e,r,n):vl(t,e,r,n)}var bo={getPath:xo,parse:yl},So,wt,wo,zn;function ko(t){this.font=t,this.getCommands=function(e){return bo.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function bl(t){return t}function Eo(t){return Math.sign(t)*Math.round(Math.abs(t))}function Sl(t){return Math.sign(t)*Math.round(Math.abs(t*2))/2}function wl(t){return Math.sign(t)*(Math.round(Math.abs(t)+.5)-.5)}function kl(t){return Math.sign(t)*Math.ceil(Math.abs(t))}function El(t){return Math.sign(t)*Math.floor(Math.abs(t))}var Po=function(t){var e=this.srPeriod,r=this.srPhase,n=this.srThreshold,s=1;return t<0&&(t=-t,s=-1),t+=n-r,t=Math.trunc(t/e)*e,t+=r,t<0?r*s:t*s},je={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 s,i,o,a,u,l,f;if(!n||n===this){if(s=t.xo-e.xo,i=t.xo-r.xo,u=e.x-e.xo,l=r.x-r.xo,o=Math.abs(s),a=Math.abs(i),f=o+a,f===0){t.x=t.xo+(u+l)/2;return}t.x=t.xo+(u*a+l*o)/f;return}if(s=n.distance(t,e,!0,!0),i=n.distance(t,r,!0,!0),u=n.distance(e,e,!1,!0),l=n.distance(r,r,!1,!0),o=Math.abs(s),a=Math.abs(i),f=o+a,f===0){je.setRelative(t,t,(u+l)/2,n,!0);return}je.setRelative(t,t,(u*a+l*o)/f,n,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(t,e,r,n,s){if(!n||n===this){t.x=(s?e.xo:e.x)+r;return}var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+r*n.x,u=o+r*n.y;t.x=a+(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}},Qe={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 s,i,o,a,u,l,f;if(!n||n===this){if(s=t.yo-e.yo,i=t.yo-r.yo,u=e.y-e.yo,l=r.y-r.yo,o=Math.abs(s),a=Math.abs(i),f=o+a,f===0){t.y=t.yo+(u+l)/2;return}t.y=t.yo+(u*a+l*o)/f;return}if(s=n.distance(t,e,!0,!0),i=n.distance(t,r,!0,!0),u=n.distance(e,e,!1,!0),l=n.distance(r,r,!1,!0),o=Math.abs(s),a=Math.abs(i),f=o+a,f===0){Qe.setRelative(t,t,(u+l)/2,n,!0);return}Qe.setRelative(t,t,(u*a+l*o)/f,n,!0)},normalSlope:0,setRelative:function(t,e,r,n,s){if(!n||n===this){t.y=(s?e.yo:e.y)+r;return}var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+r*n.x,u=o+r*n.y;t.y=u+n.normalSlope*(t.x-a)},slope:Number.POSITIVE_INFINITY,touch:function(t){t.yTouched=!0},touched:function(t){return t.yTouched},untouch:function(t){t.yTouched=!1}};Object.freeze(je);Object.freeze(Qe);function or(t,e){this.x=t,this.y=e,this.axis=void 0,this.slope=e/t,this.normalSlope=-t/e,Object.freeze(this)}or.prototype.distance=function(t,e,r,n){return this.x*je.distance(t,e,r,n)+this.y*Qe.distance(t,e,r,n)};or.prototype.interpolate=function(t,e,r,n){var s,i,o,a,u,l,f;if(o=n.distance(t,e,!0,!0),a=n.distance(t,r,!0,!0),s=n.distance(e,e,!1,!0),i=n.distance(r,r,!1,!0),u=Math.abs(o),l=Math.abs(a),f=u+l,f===0){this.setRelative(t,t,(s+i)/2,n,!0);return}this.setRelative(t,t,(s*l+i*u)/f,n,!0)};or.prototype.setRelative=function(t,e,r,n,s){n=n||this;var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+r*n.x,u=o+r*n.y,l=n.normalSlope,f=this.slope,c=t.x,h=t.y;t.x=(f*c-l*a+u-h)/(f-l),t.y=f*(t.x-c)+h};or.prototype.touch=function(t){t.xTouched=!0,t.yTouched=!0};function ar(t,e){var r=Math.sqrt(t*t+e*e);return t/=r,e/=r,t===1&&e===0?je:t===0&&e===1?Qe:new or(t,e)}function et(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)}et.prototype.nextTouched=function(t){for(var e=this.nextPointOnContour;!t.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};et.prototype.prevTouched=function(t){for(var e=this.prevPointOnContour;!t.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var nr=Object.freeze(new et(0,0)),Pl={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function lt(t,e){switch(this.env=t,this.stack=[],this.prog=e,t){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=je,this.round=Eo}}ko.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 s=this._fpgmState;if(!s){lt.prototype=Pl,s=this._fpgmState=new lt("fpgm",r.tables.fpgm),s.funcs=[],s.font=r,exports.DEBUG&&(console.log("---EXEC FPGM---"),s.step=-1);try{wt(s)}catch(l){console.log("Hinting error in FPGM:"+l),this._errorState=3;return}}lt.prototype=s,n=this._prepState=new lt("prep",r.tables.prep),n.ppem=e;var i=r.tables.cvt;if(i)for(var o=n.cvt=new Array(i.length),a=e/r.unitsPerEm,u=0;u<i.length;u++)o[u]=i[u]*a;else n.cvt=[];exports.DEBUG&&(console.log("---EXEC PREP---"),n.step=-1);try{wt(n)}catch(l){this._errorState<2&&console.log("Hinting error in PREP:"+l),this._errorState=2}}if(!(this._errorState>1))try{return wo(t,n)}catch(l){this._errorState<1&&(console.log("Hinting error:"+l),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}}};wo=function(t,e){var r=e.ppem/e.font.unitsPerEm,n=r,s=t.components,i,o,a;if(lt.prototype=e,!s)a=new lt("glyf",t.instructions),exports.DEBUG&&(console.log("---EXEC GLYPH---"),a.step=-1),zn(t,a,r,n),o=a.gZone;else{var u=e.font;o=[],i=[];for(var l=0;l<s.length;l++){var f=s[l],c=u.glyphs.get(f.glyphIndex);a=new lt("glyf",c.instructions),exports.DEBUG&&(console.log("---EXEC COMP "+l+"---"),a.step=-1),zn(c,a,r,n);for(var h=Math.round(f.dx*r),p=Math.round(f.dy*n),d=a.gZone,m=a.contours,x=0;x<d.length;x++){var y=d[x];y.xTouched=y.yTouched=!1,y.xo=y.x=y.x+h,y.yo=y.y=y.y+p}var L=o.length;o.push.apply(o,d);for(var S=0;S<m.length;S++)i.push(m[S]+L)}t.instructions&&!a.inhibitGridFit&&(a=new lt("glyf",t.instructions),a.gZone=a.z0=a.z1=a.z2=o,a.contours=i,o.push(new et(0,0),new et(Math.round(t.advanceWidth*r),0)),exports.DEBUG&&(console.log("---EXEC COMPOSITE---"),a.step=-1),wt(a),o.length-=2)}return o};zn=function(t,e,r,n){for(var s=t.points||[],i=s.length,o=e.gZone=e.z0=e.z1=e.z2=[],a=e.contours=[],u,l=0;l<i;l++)u=s[l],o[l]=new et(u.x*r,u.y*n,u.lastPointOfContour,u.onCurve);for(var f,c,h=0;h<i;h++)u=o[h],f||(f=u,a.push(h)),u.lastPointOfContour?(u.nextPointOnContour=f,f.prevPointOnContour=u,f=void 0):(c=o[h+1],u.nextPointOnContour=c,c.prevPointOnContour=u);if(!e.inhibitGridFit){if(exports.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(var p=0;p<i;p++)console.log(p,o[p].x,o[p].y)}if(o.push(new et(0,0),new et(Math.round(t.advanceWidth*r),0)),wt(e),o.length-=2,exports.DEBUG){console.log("FINISHED GLYPH",e.stack);for(var d=0;d<i;d++)console.log(d,o[d].x,o[d].y)}}};wt=function(t){var e=t.prog;if(e){var r=e.length,n;for(t.ip=0;t.ip<r;t.ip++){if(exports.DEBUG&&t.step++,n=So[e[t.ip]],!n)throw new Error("unknown instruction: 0x"+Number(e[t.ip]).toString(16));n(t)}}};function jr(t){for(var e=t.tZone=new Array(t.gZone.length),r=0;r<e.length;r++)e[r]=new et(0,0)}function Lo(t,e){var r=t.prog,n=t.ip,s=1,i;do if(i=r[++n],i===88)s++;else if(i===89)s--;else if(i===64)n+=r[n+1]+1;else if(i===65)n+=2*r[n+1]+1;else if(i>=176&&i<=183)n+=i-176+1;else if(i>=184&&i<=191)n+=(i-184+1)*2;else if(e&&s===1&&i===27)break;while(s>0);t.ip=n}function vi(t,e){exports.DEBUG&&console.log(e.step,"SVTCA["+t.axis+"]"),e.fv=e.pv=e.dpv=t}function xi(t,e){exports.DEBUG&&console.log(e.step,"SPVTCA["+t.axis+"]"),e.pv=e.dpv=t}function yi(t,e){exports.DEBUG&&console.log(e.step,"SFVTCA["+t.axis+"]"),e.fv=t}function bi(t,e){var r=e.stack,n=r.pop(),s=r.pop(),i=e.z2[n],o=e.z1[s];exports.DEBUG&&console.log("SPVTL["+t+"]",n,s);var a,u;t?(a=i.y-o.y,u=o.x-i.x):(a=o.x-i.x,u=o.y-i.y),e.pv=e.dpv=ar(a,u)}function Si(t,e){var r=e.stack,n=r.pop(),s=r.pop(),i=e.z2[n],o=e.z1[s];exports.DEBUG&&console.log("SFVTL["+t+"]",n,s);var a,u;t?(a=i.y-o.y,u=o.x-i.x):(a=o.x-i.x,u=o.y-i.y),e.fv=ar(a,u)}function Ll(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"SPVFS[]",r,n),t.pv=t.dpv=ar(n,r)}function Il(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"SPVFS[]",r,n),t.fv=ar(n,r)}function Tl(t){var e=t.stack,r=t.pv;exports.DEBUG&&console.log(t.step,"GPV[]"),e.push(r.x*16384),e.push(r.y*16384)}function Cl(t){var e=t.stack,r=t.fv;exports.DEBUG&&console.log(t.step,"GFV[]"),e.push(r.x*16384),e.push(r.y*16384)}function Ml(t){t.fv=t.pv,exports.DEBUG&&console.log(t.step,"SFVTPV[]")}function Al(t){var e=t.stack,r=e.pop(),n=e.pop(),s=e.pop(),i=e.pop(),o=e.pop(),a=t.z0,u=t.z1,l=a[r],f=a[n],c=u[s],h=u[i],p=t.z2[o];exports.DEBUG&&console.log("ISECT[], ",r,n,s,i,o);var d=l.x,m=l.y,x=f.x,y=f.y,L=c.x,S=c.y,A=h.x,E=h.y,F=(d-x)*(S-E)-(m-y)*(L-A),k=d*y-m*x,I=L*E-S*A;p.x=(k*(L-A)-I*(d-x))/F,p.y=(k*(S-E)-I*(m-y))/F}function Ol(t){t.rp0=t.stack.pop(),exports.DEBUG&&console.log(t.step,"SRP0[]",t.rp0)}function Fl(t){t.rp1=t.stack.pop(),exports.DEBUG&&console.log(t.step,"SRP1[]",t.rp1)}function Dl(t){t.rp2=t.stack.pop(),exports.DEBUG&&console.log(t.step,"SRP2[]",t.rp2)}function Ul(t){var e=t.stack.pop();switch(exports.DEBUG&&console.log(t.step,"SZP0[]",e),t.zp0=e,e){case 0:t.tZone||jr(t),t.z0=t.tZone;break;case 1:t.z0=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Rl(t){var e=t.stack.pop();switch(exports.DEBUG&&console.log(t.step,"SZP1[]",e),t.zp1=e,e){case 0:t.tZone||jr(t),t.z1=t.tZone;break;case 1:t.z1=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Nl(t){var e=t.stack.pop();switch(exports.DEBUG&&console.log(t.step,"SZP2[]",e),t.zp2=e,e){case 0:t.tZone||jr(t),t.z2=t.tZone;break;case 1:t.z2=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Bl(t){var e=t.stack.pop();switch(exports.DEBUG&&console.log(t.step,"SZPS[]",e),t.zp0=t.zp1=t.zp2=e,e){case 0:t.tZone||jr(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 Gl(t){t.loop=t.stack.pop(),exports.DEBUG&&console.log(t.step,"SLOOP[]",t.loop)}function Hl(t){exports.DEBUG&&console.log(t.step,"RTG[]"),t.round=Eo}function Vl(t){exports.DEBUG&&console.log(t.step,"RTHG[]"),t.round=wl}function zl(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SMD[]",e),t.minDis=e/64}function $l(t){exports.DEBUG&&console.log(t.step,"ELSE[]"),Lo(t,!1)}function Xl(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"JMPR[]",e),t.ip+=e-1}function ql(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SCVTCI[]",e),t.cvCutIn=e/64}function Wl(t){var e=t.stack;exports.DEBUG&&console.log(t.step,"DUP[]"),e.push(e[e.length-1])}function Cn(t){exports.DEBUG&&console.log(t.step,"POP[]"),t.stack.pop()}function Zl(t){exports.DEBUG&&console.log(t.step,"CLEAR[]"),t.stack.length=0}function _l(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"SWAP[]"),e.push(r),e.push(n)}function Yl(t){var e=t.stack;exports.DEBUG&&console.log(t.step,"DEPTH[]"),e.push(e.length)}function jl(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"LOOPCALL[]",r,n);var s=t.ip,i=t.prog;t.prog=t.funcs[r];for(var o=0;o<n;o++)wt(t),exports.DEBUG&&console.log(++t.step,o+1<n?"next loopcall":"done loopcall",o);t.ip=s,t.prog=i}function Kl(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"CALL[]",e);var r=t.ip,n=t.prog;t.prog=t.funcs[e],wt(t),t.ip=r,t.prog=n,exports.DEBUG&&console.log(++t.step,"returning from",e)}function Jl(t){var e=t.stack,r=e.pop();exports.DEBUG&&console.log(t.step,"CINDEX[]",r),e.push(e[e.length-r])}function Ql(t){var e=t.stack,r=e.pop();exports.DEBUG&&console.log(t.step,"MINDEX[]",r),e.push(e.splice(e.length-r,1)[0])}function ef(t){if(t.env!=="fpgm")throw new Error("FDEF not allowed here");var e=t.stack,r=t.prog,n=t.ip,s=e.pop(),i=n;for(exports.DEBUG&&console.log(t.step,"FDEF[]",s);r[++n]!==45;);t.ip=n,t.funcs[s]=r.slice(i+1,n)}function wi(t,e){var r=e.stack.pop(),n=e.z0[r],s=e.fv,i=e.pv;exports.DEBUG&&console.log(e.step,"MDAP["+t+"]",r);var o=i.distance(n,nr);t&&(o=e.round(o)),s.setRelative(n,nr,o,i),s.touch(n),e.rp0=e.rp1=r}function ki(t,e){var r=e.z2,n=r.length-2,s,i,o;exports.DEBUG&&console.log(e.step,"IUP["+t.axis+"]");for(var a=0;a<n;a++)s=r[a],!t.touched(s)&&(i=s.prevTouched(t),i!==s&&(o=s.nextTouched(t),i===o&&t.setRelative(s,s,t.distance(i,i,!1,!0),t,!0),t.interpolate(s,i,o,t)))}function Ei(t,e){for(var r=e.stack,n=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[n],i=e.fv,o=e.pv,a=e.loop,u=e.z2;a--;){var l=r.pop(),f=u[l],c=o.distance(s,s,!1,!0);i.setRelative(f,f,c,o),i.touch(f),exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-a)+": ":"")+"SHP["+(t?"rp1":"rp2")+"]",l)}e.loop=1}function Pi(t,e){var r=e.stack,n=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[n],i=e.fv,o=e.pv,a=r.pop(),u=e.z2[e.contours[a]],l=u;exports.DEBUG&&console.log(e.step,"SHC["+t+"]",a);var f=o.distance(s,s,!1,!0);do l!==s&&i.setRelative(l,l,f,o),l=l.nextPointOnContour;while(l!==u)}function Li(t,e){var r=e.stack,n=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[n],i=e.fv,o=e.pv,a=r.pop();exports.DEBUG&&console.log(e.step,"SHZ["+t+"]",a);var u;switch(a){case 0:u=e.tZone;break;case 1:u=e.gZone;break;default:throw new Error("Invalid zone")}for(var l,f=o.distance(s,s,!1,!0),c=u.length-2,h=0;h<c;h++)l=u[h],i.setRelative(l,l,f,o)}function tf(t){for(var e=t.stack,r=t.loop,n=t.fv,s=e.pop()/64,i=t.z2;r--;){var o=e.pop(),a=i[o];exports.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-r)+": ":"")+"SHPIX[]",o,s),n.setRelative(a,a,s),n.touch(a)}t.loop=1}function rf(t){for(var e=t.stack,r=t.rp1,n=t.rp2,s=t.loop,i=t.z0[r],o=t.z1[n],a=t.fv,u=t.dpv,l=t.z2;s--;){var f=e.pop(),c=l[f];exports.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-s)+": ":"")+"IP[]",f,r,"<->",n),a.interpolate(c,i,o,u),a.touch(c)}t.loop=1}function Ii(t,e){var r=e.stack,n=r.pop()/64,s=r.pop(),i=e.z1[s],o=e.z0[e.rp0],a=e.fv,u=e.pv;a.setRelative(i,o,n,u),a.touch(i),exports.DEBUG&&console.log(e.step,"MSIRP["+t+"]",n,s),e.rp1=e.rp0,e.rp2=s,t&&(e.rp0=s)}function nf(t){for(var e=t.stack,r=t.rp0,n=t.z0[r],s=t.loop,i=t.fv,o=t.pv,a=t.z1;s--;){var u=e.pop(),l=a[u];exports.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-s)+": ":"")+"ALIGNRP[]",u),i.setRelative(l,n,0,o),i.touch(l)}t.loop=1}function sf(t){exports.DEBUG&&console.log(t.step,"RTDG[]"),t.round=Sl}function Ti(t,e){var r=e.stack,n=r.pop(),s=r.pop(),i=e.z0[s],o=e.fv,a=e.pv,u=e.cvt[n];exports.DEBUG&&console.log(e.step,"MIAP["+t+"]",n,"(",u,")",s);var l=a.distance(i,nr);t&&(Math.abs(l-u)<e.cvCutIn&&(l=u),l=e.round(l)),o.setRelative(i,nr,l,a),e.zp0===0&&(i.xo=i.x,i.yo=i.y),o.touch(i),e.rp0=e.rp1=s}function of(t){var e=t.prog,r=t.ip,n=t.stack,s=e[++r];exports.DEBUG&&console.log(t.step,"NPUSHB[]",s);for(var i=0;i<s;i++)n.push(e[++r]);t.ip=r}function af(t){var e=t.ip,r=t.prog,n=t.stack,s=r[++e];exports.DEBUG&&console.log(t.step,"NPUSHW[]",s);for(var i=0;i<s;i++){var o=r[++e]<<8|r[++e];o&32768&&(o=-((o^65535)+1)),n.push(o)}t.ip=e}function uf(t){var e=t.stack,r=t.store;r||(r=t.store=[]);var n=e.pop(),s=e.pop();exports.DEBUG&&console.log(t.step,"WS",n,s),r[s]=n}function lf(t){var e=t.stack,r=t.store,n=e.pop();exports.DEBUG&&console.log(t.step,"RS",n);var s=r&&r[n]||0;e.push(s)}function ff(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"WCVTP",r,n),t.cvt[n]=r/64}function hf(t){var e=t.stack,r=e.pop();exports.DEBUG&&console.log(t.step,"RCVT",r),e.push(t.cvt[r]*64)}function Ci(t,e){var r=e.stack,n=r.pop(),s=e.z2[n];exports.DEBUG&&console.log(e.step,"GC["+t+"]",n),r.push(e.dpv.distance(s,nr,t,!1)*64)}function Mi(t,e){var r=e.stack,n=r.pop(),s=r.pop(),i=e.z1[n],o=e.z0[s],a=e.dpv.distance(o,i,t,t);exports.DEBUG&&console.log(e.step,"MD["+t+"]",n,s,"->",a),e.stack.push(Math.round(a*64))}function cf(t){exports.DEBUG&&console.log(t.step,"MPPEM[]"),t.stack.push(t.ppem)}function pf(t){exports.DEBUG&&console.log(t.step,"FLIPON[]"),t.autoFlip=!0}function df(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"LT[]",r,n),e.push(n<r?1:0)}function gf(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"LTEQ[]",r,n),e.push(n<=r?1:0)}function mf(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"GT[]",r,n),e.push(n>r?1:0)}function vf(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"GTEQ[]",r,n),e.push(n>=r?1:0)}function xf(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"EQ[]",r,n),e.push(r===n?1:0)}function yf(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"NEQ[]",r,n),e.push(r!==n?1:0)}function bf(t){var e=t.stack,r=e.pop();exports.DEBUG&&console.log(t.step,"ODD[]",r),e.push(Math.trunc(r)%2?1:0)}function Sf(t){var e=t.stack,r=e.pop();exports.DEBUG&&console.log(t.step,"EVEN[]",r),e.push(Math.trunc(r)%2?0:1)}function wf(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"IF[]",e),e||(Lo(t,!0),exports.DEBUG&&console.log(t.step,"EIF[]"))}function kf(t){exports.DEBUG&&console.log(t.step,"EIF[]")}function Ef(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"AND[]",r,n),e.push(r&&n?1:0)}function Pf(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"OR[]",r,n),e.push(r||n?1:0)}function Lf(t){var e=t.stack,r=e.pop();exports.DEBUG&&console.log(t.step,"NOT[]",r),e.push(r?0:1)}function Mn(t,e){var r=e.stack,n=r.pop(),s=e.fv,i=e.pv,o=e.ppem,a=e.deltaBase+(t-1)*16,u=e.deltaShift,l=e.z0;exports.DEBUG&&console.log(e.step,"DELTAP["+t+"]",n,r);for(var f=0;f<n;f++){var c=r.pop(),h=r.pop(),p=a+((h&240)>>4);if(p===o){var d=(h&15)-8;d>=0&&d++,exports.DEBUG&&console.log(e.step,"DELTAPFIX",c,"by",d*u);var m=l[c];s.setRelative(m,m,d*u,i)}}}function If(t){var e=t.stack,r=e.pop();exports.DEBUG&&console.log(t.step,"SDB[]",r),t.deltaBase=r}function Tf(t){var e=t.stack,r=e.pop();exports.DEBUG&&console.log(t.step,"SDS[]",r),t.deltaShift=Math.pow(.5,r)}function Cf(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"ADD[]",r,n),e.push(n+r)}function Mf(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"SUB[]",r,n),e.push(n-r)}function Af(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"DIV[]",r,n),e.push(n*64/r)}function Of(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"MUL[]",r,n),e.push(n*r/64)}function Ff(t){var e=t.stack,r=e.pop();exports.DEBUG&&console.log(t.step,"ABS[]",r),e.push(Math.abs(r))}function Df(t){var e=t.stack,r=e.pop();exports.DEBUG&&console.log(t.step,"NEG[]",r),e.push(-r)}function Uf(t){var e=t.stack,r=e.pop();exports.DEBUG&&console.log(t.step,"FLOOR[]",r),e.push(Math.floor(r/64)*64)}function Rf(t){var e=t.stack,r=e.pop();exports.DEBUG&&console.log(t.step,"CEILING[]",r),e.push(Math.ceil(r/64)*64)}function Vr(t,e){var r=e.stack,n=r.pop();exports.DEBUG&&console.log(e.step,"ROUND[]"),r.push(e.round(n/64)*64)}function Nf(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"WCVTF[]",r,n),t.cvt[n]=r*t.ppem/t.font.unitsPerEm}function An(t,e){var r=e.stack,n=r.pop(),s=e.ppem,i=e.deltaBase+(t-1)*16,o=e.deltaShift;exports.DEBUG&&console.log(e.step,"DELTAC["+t+"]",n,r);for(var a=0;a<n;a++){var u=r.pop(),l=r.pop(),f=i+((l&240)>>4);if(f===s){var c=(l&15)-8;c>=0&&c++;var h=c*o;exports.DEBUG&&console.log(e.step,"DELTACFIX",u,"by",h),e.cvt[u]+=h}}}function Bf(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SROUND[]",e),t.round=Po;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 Gf(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"S45ROUND[]",e),t.round=Po;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 Hf(t){exports.DEBUG&&console.log(t.step,"ROFF[]"),t.round=bl}function Vf(t){exports.DEBUG&&console.log(t.step,"RUTG[]"),t.round=kl}function zf(t){exports.DEBUG&&console.log(t.step,"RDTG[]"),t.round=El}function $f(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SCANCTRL[]",e)}function Ai(t,e){var r=e.stack,n=r.pop(),s=r.pop(),i=e.z2[n],o=e.z1[s];exports.DEBUG&&console.log(e.step,"SDPVTL["+t+"]",n,s);var a,u;t?(a=i.y-o.y,u=o.x-i.x):(a=o.x-i.x,u=o.y-i.y),e.dpv=ar(a,u)}function Xf(t){var e=t.stack,r=e.pop(),n=0;exports.DEBUG&&console.log(t.step,"GETINFO[]",r),r&1&&(n=35),r&32&&(n|=4096),e.push(n)}function qf(t){var e=t.stack,r=e.pop(),n=e.pop(),s=e.pop();exports.DEBUG&&console.log(t.step,"ROLL[]"),e.push(n),e.push(r),e.push(s)}function Wf(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"MAX[]",r,n),e.push(Math.max(n,r))}function Zf(t){var e=t.stack,r=e.pop(),n=e.pop();exports.DEBUG&&console.log(t.step,"MIN[]",r,n),e.push(Math.min(n,r))}function _f(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SCANTYPE[]",e)}function Yf(t){var e=t.stack.pop(),r=t.stack.pop();switch(exports.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 ot(t,e){var r=e.stack,n=e.prog,s=e.ip;exports.DEBUG&&console.log(e.step,"PUSHB["+t+"]");for(var i=0;i<t;i++)r.push(n[++s]);e.ip=s}function at(t,e){var r=e.ip,n=e.prog,s=e.stack;exports.DEBUG&&console.log(e.ip,"PUSHW["+t+"]");for(var i=0;i<t;i++){var o=n[++r]<<8|n[++r];o&32768&&(o=-((o^65535)+1)),s.push(o)}e.ip=r}function C(t,e,r,n,s,i){var o=i.stack,a=t&&o.pop(),u=o.pop(),l=i.rp0,f=i.z0[l],c=i.z1[u],h=i.minDis,p=i.fv,d=i.dpv,m,x,y,L;x=m=d.distance(c,f,!0,!0),y=x>=0?1:-1,x=Math.abs(x),t&&(L=i.cvt[a],n&&Math.abs(x-L)<i.cvCutIn&&(x=L)),r&&x<h&&(x=h),n&&(x=i.round(x)),p.setRelative(c,f,y*x,d),p.touch(c),exports.DEBUG&&console.log(i.step,(t?"MIRP[":"MDRP[")+(e?"M":"m")+(r?">":"_")+(n?"R":"_")+(s===0?"Gr":s===1?"Bl":s===2?"Wh":"")+"]",t?a+"("+i.cvt[a]+","+L+")":"",u,"(d =",m,"->",y*x,")"),i.rp1=i.rp0,i.rp2=u,e&&(i.rp0=u)}So=[vi.bind(void 0,Qe),vi.bind(void 0,je),xi.bind(void 0,Qe),xi.bind(void 0,je),yi.bind(void 0,Qe),yi.bind(void 0,je),bi.bind(void 0,0),bi.bind(void 0,1),Si.bind(void 0,0),Si.bind(void 0,1),Ll,Il,Tl,Cl,Ml,Al,Ol,Fl,Dl,Ul,Rl,Nl,Bl,Gl,Hl,Vl,zl,$l,Xl,ql,void 0,void 0,Wl,Cn,Zl,_l,Yl,Jl,Ql,void 0,void 0,void 0,jl,Kl,ef,void 0,wi.bind(void 0,0),wi.bind(void 0,1),ki.bind(void 0,Qe),ki.bind(void 0,je),Ei.bind(void 0,0),Ei.bind(void 0,1),Pi.bind(void 0,0),Pi.bind(void 0,1),Li.bind(void 0,0),Li.bind(void 0,1),tf,rf,Ii.bind(void 0,0),Ii.bind(void 0,1),nf,sf,Ti.bind(void 0,0),Ti.bind(void 0,1),of,af,uf,lf,ff,hf,Ci.bind(void 0,0),Ci.bind(void 0,1),void 0,Mi.bind(void 0,0),Mi.bind(void 0,1),cf,void 0,pf,void 0,void 0,df,gf,mf,vf,xf,yf,bf,Sf,wf,kf,Ef,Pf,Lf,Mn.bind(void 0,1),If,Tf,Cf,Mf,Af,Of,Ff,Df,Uf,Rf,Vr.bind(void 0,0),Vr.bind(void 0,1),Vr.bind(void 0,2),Vr.bind(void 0,3),void 0,void 0,void 0,void 0,Nf,Mn.bind(void 0,2),Mn.bind(void 0,3),An.bind(void 0,1),An.bind(void 0,2),An.bind(void 0,3),Bf,Gf,void 0,void 0,Hf,void 0,Vf,zf,Cn,Cn,void 0,void 0,void 0,void 0,void 0,$f,Ai.bind(void 0,0),Ai.bind(void 0,1),Xf,void 0,qf,Wf,Zf,_f,Yf,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,ot.bind(void 0,1),ot.bind(void 0,2),ot.bind(void 0,3),ot.bind(void 0,4),ot.bind(void 0,5),ot.bind(void 0,6),ot.bind(void 0,7),ot.bind(void 0,8),at.bind(void 0,1),at.bind(void 0,2),at.bind(void 0,3),at.bind(void 0,4),at.bind(void 0,5),at.bind(void 0,6),at.bind(void 0,7),at.bind(void 0,8),C.bind(void 0,0,0,0,0,0),C.bind(void 0,0,0,0,0,1),C.bind(void 0,0,0,0,0,2),C.bind(void 0,0,0,0,0,3),C.bind(void 0,0,0,0,1,0),C.bind(void 0,0,0,0,1,1),C.bind(void 0,0,0,0,1,2),C.bind(void 0,0,0,0,1,3),C.bind(void 0,0,0,1,0,0),C.bind(void 0,0,0,1,0,1),C.bind(void 0,0,0,1,0,2),C.bind(void 0,0,0,1,0,3),C.bind(void 0,0,0,1,1,0),C.bind(void 0,0,0,1,1,1),C.bind(void 0,0,0,1,1,2),C.bind(void 0,0,0,1,1,3),C.bind(void 0,0,1,0,0,0),C.bind(void 0,0,1,0,0,1),C.bind(void 0,0,1,0,0,2),C.bind(void 0,0,1,0,0,3),C.bind(void 0,0,1,0,1,0),C.bind(void 0,0,1,0,1,1),C.bind(void 0,0,1,0,1,2),C.bind(void 0,0,1,0,1,3),C.bind(void 0,0,1,1,0,0),C.bind(void 0,0,1,1,0,1),C.bind(void 0,0,1,1,0,2),C.bind(void 0,0,1,1,0,3),C.bind(void 0,0,1,1,1,0),C.bind(void 0,0,1,1,1,1),C.bind(void 0,0,1,1,1,2),C.bind(void 0,0,1,1,1,3),C.bind(void 0,1,0,0,0,0),C.bind(void 0,1,0,0,0,1),C.bind(void 0,1,0,0,0,2),C.bind(void 0,1,0,0,0,3),C.bind(void 0,1,0,0,1,0),C.bind(void 0,1,0,0,1,1),C.bind(void 0,1,0,0,1,2),C.bind(void 0,1,0,0,1,3),C.bind(void 0,1,0,1,0,0),C.bind(void 0,1,0,1,0,1),C.bind(void 0,1,0,1,0,2),C.bind(void 0,1,0,1,0,3),C.bind(void 0,1,0,1,1,0),C.bind(void 0,1,0,1,1,1),C.bind(void 0,1,0,1,1,2),C.bind(void 0,1,0,1,1,3),C.bind(void 0,1,1,0,0,0),C.bind(void 0,1,1,0,0,1),C.bind(void 0,1,1,0,0,2),C.bind(void 0,1,1,0,0,3),C.bind(void 0,1,1,0,1,0),C.bind(void 0,1,1,0,1,1),C.bind(void 0,1,1,0,1,2),C.bind(void 0,1,1,0,1,3),C.bind(void 0,1,1,1,0,0),C.bind(void 0,1,1,1,0,1),C.bind(void 0,1,1,1,0,2),C.bind(void 0,1,1,1,0,3),C.bind(void 0,1,1,1,1,0),C.bind(void 0,1,1,1,1,1),C.bind(void 0,1,1,1,1,2),C.bind(void 0,1,1,1,1,3)];function Rt(t){this.char=t,this.state={},this.activeState=null}function Kn(t,e,r){this.contextName=r,this.startIndex=t,this.endOffset=e}function jf(t,e,r){this.contextName=t,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=r}function ze(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 Kr(t){this.eventId=t,this.subscribers=[]}function Kf(t){var e=this,r=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];r.forEach(function(s){Object.defineProperty(e.events,s,{value:new Kr(s)})}),t&&r.forEach(function(s){var i=t[s];typeof i=="function"&&e.events[s].subscribe(i)});var n=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];n.forEach(function(s){e.events[s].subscribe(e.updateContextsRanges)})}function ce(t){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Kf.call(this,t)}Rt.prototype.setState=function(t,e){return this.state[t]=e,this.activeState={key:t,value:this.state[t]},this.activeState};Rt.prototype.getState=function(t){return this.state[t]||null};ce.prototype.inboundIndex=function(t){return t>=0&&t<this.tokens.length};ce.prototype.composeRUD=function(t){var e=this,r=!0,n=t.map(function(i){return e[i[0]].apply(e,i.slice(1).concat(r))}),s=function(i){return typeof i=="object"&&i.hasOwnProperty("FAIL")};if(n.every(s))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:n.filter(s)};this.dispatch("composeRUD",[n.filter(function(i){return!s(i)})])};ce.prototype.replaceRange=function(t,e,r,n){e=e!==null?e:this.tokens.length;var s=r.every(function(o){return o instanceof Rt});if(!isNaN(t)&&this.inboundIndex(t)&&s){var i=this.tokens.splice.apply(this.tokens,[t,e].concat(r));return n||this.dispatch("replaceToken",[t,e,r]),[i,r]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};ce.prototype.replaceToken=function(t,e,r){if(!isNaN(t)&&this.inboundIndex(t)&&e instanceof Rt){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."}};ce.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};ce.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."}};ce.prototype.insertToken=function(t,e,r){var n=t.every(function(s){return s instanceof Rt});return n?(this.tokens.splice.apply(this.tokens,[e,0].concat(t)),r||this.dispatch("insertToken",[t,e]),t):{FAIL:"insertToken: invalid token(s)."}};ce.prototype.registerModifier=function(t,e,r){this.events.newToken.subscribe(function(n,s){var i=[n,s],o=e===null||e.apply(this,i)===!0,a=[n,s];if(o){var u=r.apply(this,a);n.setState(t,u)}}),this.registeredModifiers.push(t)};Kr.prototype.subscribe=function(t){return typeof t=="function"?this.subscribers.push(t)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}};Kr.prototype.unsubscribe=function(t){this.subscribers.splice(t,1)};ze.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)};ze.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}};ce.prototype.rangeToText=function(t){if(t instanceof Kn)return this.getRangeTokens(t).map(function(e){return e.char}).join("")};ce.prototype.getText=function(){return this.tokens.map(function(t){return t.char}).join("")};ce.prototype.getContext=function(t){var e=this.registeredContexts[t];return e||null};ce.prototype.on=function(t,e){var r=this.events[t];return r?r.subscribe(e):null};ce.prototype.dispatch=function(t,e){var r=this,n=this.events[t];n instanceof Kr&&n.subscribers.forEach(function(s){s.apply(r,e||[])})};ce.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 jf(t,e,r);return this.registeredContexts[t]=n,this.contextCheckers.push(n),n};ce.prototype.getRangeTokens=function(t){var e=t.startIndex+t.endOffset;return[].concat(this.tokens.slice(t.startIndex,e))};ce.prototype.getContextRanges=function(t){var e=this.getContext(t);return e?e.ranges:{FAIL:"context checker '"+t+"' is not registered."}};ce.prototype.resetContextsRanges=function(){var t=this.registeredContexts;for(var e in t)if(t.hasOwnProperty(e)){var r=t[e];r.ranges=[]}};ce.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 ze(t,e);this.runContextCheck(r)}this.dispatch("updateContextsRanges",[this.registeredContexts])};ce.prototype.setEndOffset=function(t,e){var r=this.getContext(e).openRange.startIndex,n=new Kn(r,t,e),s=this.getContext(e).ranges;return n.rangeId=e+"."+s.length,s.push(n),this.getContext(e).openRange=null,n};ce.prototype.runContextCheck=function(t){var e=this,r=t.index;this.contextCheckers.forEach(function(n){var s=n.contextName,i=e.getContext(s).openRange;if(!i&&n.checkStart(t)&&(i=new Kn(r,null,s),e.getContext(s).openRange=i,e.dispatch("contextStart",[s,r])),i&&n.checkEnd(t)){var o=r-i.startIndex+1,a=e.setEndOffset(o,s);e.dispatch("contextEnd",[s,a])}})};ce.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],s=new ze(e,r);this.dispatch("next",[s]),this.runContextCheck(s);var i=new Rt(n);this.tokens.push(i),this.dispatch("newToken",[i,s])}return this.dispatch("end",[this.tokens]),this.tokens};function ft(t){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(t)}function Io(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 ht(t){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(t)}function $r(t){return/[A-z]/.test(t)}function Jf(t){return/\s/.test(t)}function Oe(t){this.font=t,this.features={}}function St(t){this.id=t.id,this.tag=t.tag,this.substitution=t.substitution}function ur(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 s=r[n];if(t>=s.start&&t<=s.end){var i=t-s.start;return s.index+i}}break;default:return-1}return-1}function Qf(t,e){var r=ur(t,e.coverage);return r===-1?null:t+e.deltaGlyphId}function eh(t,e){var r=ur(t,e.coverage);return r===-1?null:e.substitute[r]}function On(t,e){for(var r=[],n=0;n<t.length;n++){var s=t[n],i=e.current;i=Array.isArray(i)?i[0]:i;var o=ur(i,s);o!==-1&&r.push(o)}return r.length!==t.length?-1:r}function th(t,e){var r=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(t.context.length<r)return[];var n=On(e.inputCoverage,t);if(n===-1)return[];var s=e.inputCoverage.length-1;if(t.lookahead.length<e.lookaheadCoverage.length)return[];for(var i=t.lookahead.slice(s);i.length&&ht(i[0].char);)i.shift();var o=new ze(i,0),a=On(e.lookaheadCoverage,o),u=[].concat(t.backtrack);for(u.reverse();u.length&&ht(u[0].char);)u.shift();if(u.length<e.backtrackCoverage.length)return[];var l=new ze(u,0),f=On(e.backtrackCoverage,l),c=n.length===e.inputCoverage.length&&a.length===e.lookaheadCoverage.length&&f.length===e.backtrackCoverage.length,h=[];if(c)for(var p=0;p<e.lookupRecords.length;p++)for(var d=e.lookupRecords[p],m=d.lookupListIndex,x=this.getLookupByIndex(m),y=0;y<x.subtables.length;y++){var L=x.subtables[y],S=this.getLookupMethod(x,L),A=this.getSubstitutionType(x,L);if(A==="12")for(var E=0;E<n.length;E++){var F=t.get(E),k=S(F);k&&h.push(k)}}return h}function rh(t,e){var r=t.current,n=ur(r,e.coverage);if(n===-1)return null;for(var s,i=e.ligatureSets[n],o=0;o<i.length;o++){s=i[o];for(var a=0;a<s.components.length;a++){var u=t.lookahead[a],l=s.components[a];if(u!==l)break;if(a===s.components.length-1)return s}}return null}function nh(t,e){var r=ur(t,e.coverage);return r===-1?null:e.sequences[r]}Oe.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[]};Oe.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 s=r[n];if(s.tag===t&&s.script.defaultLangSys)return s.script.defaultLangSys.featureIndexes;var i=s.langSysRecords;if(i)for(var o=0;o<i.length;o++){var a=i[o];if(a.tag===t){var u=a.langSys;return u.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()};Oe.prototype.mapTagsToFeatures=function(t,e){for(var r={},n=0;n<t.length;n++){var s=t[n].tag,i=t[n].feature;r[s]=i}this.features[e].tags=r};Oe.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(s){return n.features[s]}),this.features[t]=e,this.mapTagsToFeatures(e,t),e};Oe.prototype.getSubstitutionType=function(t,e){var r=t.lookupType.toString(),n=e.substFormat.toString();return r+n};Oe.prototype.getLookupMethod=function(t,e){var r=this,n=this.getSubstitutionType(t,e);switch(n){case"11":return function(s){return Qf.apply(r,[s,e])};case"12":return function(s){return eh.apply(r,[s,e])};case"63":return function(s){return th.apply(r,[s,e])};case"41":return function(s){return rh.apply(r,[s,e])};case"21":return function(s){return nh.apply(r,[s,e])};default:throw new Error("lookupType: "+t.lookupType+" - substFormat: "+e.substFormat+" is not yet supported")}};Oe.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 s=this.getFeatureLookups(n),i=[].concat(e.context),o=0;o<s.length;o++)for(var a=s[o],u=this.getLookupSubtables(a),l=0;l<u.length;l++){var f=u[l],c=this.getSubstitutionType(a,f),h=this.getLookupMethod(a,f),p=void 0;switch(c){case"11":p=h(e.current),p&&i.splice(r,1,new St({id:11,tag:t.tag,substitution:p}));break;case"12":p=h(e.current),p&&i.splice(r,1,new St({id:12,tag:t.tag,substitution:p}));break;case"63":p=h(e),Array.isArray(p)&&p.length&&i.splice(r,1,new St({id:63,tag:t.tag,substitution:p}));break;case"41":p=h(e),p&&i.splice(r,1,new St({id:41,tag:t.tag,substitution:p}));break;case"21":p=h(e.current),p&&i.splice(r,1,new St({id:21,tag:t.tag,substitution:p}));break}e=new ze(i,r),!(Array.isArray(p)&&!p.length)&&(p=null)}return i.length?i:null};Oe.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};Oe.prototype.getLookupSubtables=function(t){return t.subtables||null};Oe.prototype.getLookupByIndex=function(t){var e=this.font.tables.gsub.lookups;return e[t]||null};Oe.prototype.getFeatureLookups=function(t){return t.lookupListIndexes.map(this.getLookupByIndex.bind(this))};Oe.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 sh(t){var e=t.current,r=t.get(-1);return r===null&&ft(e)||!ft(r)&&ft(e)}function ih(t){var e=t.get(1);return e===null||!ft(e)}var oh={startCheck:sh,endCheck:ih};function ah(t){var e=t.current,r=t.get(-1);return(ft(e)||ht(e))&&!ft(r)}function uh(t){var e=t.get(1);switch(!0){case e===null:return!0;case(!ft(e)&&!ht(e)):var r=Jf(e);if(!r)return!0;if(r){var n=!1;if(n=t.lookahead.some(function(s){return ft(s)||ht(s)}),!n)return!0}break;default:return!1}}var lh={startCheck:ah,endCheck:uh};function fh(t,e,r){e[r].setState(t.tag,t.substitution)}function hh(t,e,r){e[r].setState(t.tag,t.substitution)}function ch(t,e,r){t.substitution.forEach(function(n,s){var i=e[r+s];i.setState(t.tag,n)})}function ph(t,e,r){var n=e[r];n.setState(t.tag,t.substitution.ligGlyph);for(var s=t.substitution.components.length,i=0;i<s;i++)n=e[r+i+1],n.setState("deleted",!0)}var Oi={11:fh,12:hh,63:ch,41:ph};function Jn(t,e,r){t instanceof St&&Oi[t.id]&&Oi[t.id](t,e,r)}function dh(t){for(var e=[].concat(t.backtrack),r=e.length-1;r>=0;r--){var n=e[r],s=Io(n),i=ht(n);if(!s&&!i)return!0;if(s)return!1}return!1}function gh(t){if(Io(t.current))return!1;for(var e=0;e<t.lookahead.length;e++){var r=t.lookahead[e],n=ht(r);if(!n)return!0}return!1}function mh(t){var e=this,r="arab",n=this.featuresTags[r],s=this.tokenizer.getRangeTokens(t);if(s.length!==1){var i=new ze(s.map(function(a){return a.getState("glyphIndex")}),0),o=new ze(s.map(function(a){return a.char}),0);s.forEach(function(a,u){if(!ht(a.char)){i.setCurrentIndex(u),o.setCurrentIndex(u);var l=0;dh(o)&&(l|=1),gh(o)&&(l|=2);var f;switch(l){case 1:f="fina";break;case 2:f="init";break;case 3:f="medi";break}if(n.indexOf(f)!==-1){var c=e.query.lookupFeature({tag:f,script:r,contextParams:i});if(c instanceof Error)return console.info(c.message);c.forEach(function(h,p){h instanceof St&&(Jn(h,s,p),i.context[p]=h.substitution)})}}})}}function Fi(t,e){var r=t.map(function(n){return n.activeState.value});return new ze(r,e||0)}function vh(t){var e=this,r="arab",n=this.tokenizer.getRangeTokens(t),s=Fi(n);s.context.forEach(function(i,o){s.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"rlig",script:r,contextParams:s});a.length&&(a.forEach(function(u){return Jn(u,n,o)}),s=Fi(n))})}function xh(t){var e=t.current,r=t.get(-1);return r===null&&$r(e)||!$r(r)&&$r(e)}function yh(t){var e=t.get(1);return e===null||!$r(e)}var bh={startCheck:xh,endCheck:yh};function Di(t,e){var r=t.map(function(n){return n.activeState.value});return new ze(r,e||0)}function Sh(t){var e=this,r="latn",n=this.tokenizer.getRangeTokens(t),s=Di(n);s.context.forEach(function(i,o){s.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"liga",script:r,contextParams:s});a.length&&(a.forEach(function(u){return Jn(u,n,o)}),s=Di(n))})}function qe(t){this.baseDir=t||"ltr",this.tokenizer=new ce,this.featuresTags={}}qe.prototype.setText=function(t){this.text=t};qe.prototype.contextChecks={latinWordCheck:bh,arabicWordCheck:oh,arabicSentenceCheck:lh};function Fn(t){var e=this.contextChecks[t+"Check"];return this.tokenizer.registerContextChecker(t,e.startCheck,e.endCheck)}function wh(){return Fn.call(this,"latinWord"),Fn.call(this,"arabicWord"),Fn.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function kh(){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())})}qe.prototype.registerFeatures=function(t,e){var r=this,n=e.filter(function(s){return r.query.supports({script:t,tag:s})});this.featuresTags.hasOwnProperty(t)?this.featuresTags[t]=this.featuresTags[t].concat(n):this.featuresTags[t]=n};qe.prototype.applyFeatures=function(t,e){if(!t)throw new Error("No valid font was provided to apply features");this.query||(this.query=new Oe(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)}};qe.prototype.registerModifier=function(t,e,r){this.tokenizer.registerModifier(t,e,r)};function Qn(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function Eh(){var t=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){Qn.call(this);var r=this.tokenizer.getContextRanges("arabicWord");r.forEach(function(n){mh.call(t,n)})}}function Ph(){var t=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){var r=this.featuresTags[e];if(r.indexOf("rlig")!==-1){Qn.call(this);var n=this.tokenizer.getContextRanges("arabicWord");n.forEach(function(s){vh.call(t,s)})}}}function Lh(){var t=this,e="latn";if(this.featuresTags.hasOwnProperty(e)){var r=this.featuresTags[e];if(r.indexOf("liga")!==-1){Qn.call(this);var n=this.tokenizer.getContextRanges("latinWord");n.forEach(function(s){Sh.call(t,s)})}}}qe.prototype.checkContextReady=function(t){return!!this.tokenizer.getContext(t)};qe.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(Eh.call(this),Ph.call(this)),this.checkContextReady("latinWord")&&Lh.call(this),this.checkContextReady("arabicSentence")&&kh.call(this)};qe.prototype.processText=function(t){(!this.text||this.text!==t)&&(this.setText(t),wh.call(this),this.applyFeaturesToContexts())};qe.prototype.getBidiText=function(t){return this.processText(t),this.tokenizer.getText()};qe.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 s=n.activeState.value;e.push(Array.isArray(s)?s[0]:s)}}return e};function re(t){t=t||{},t.tables=t.tables||{},t.empty||(Jt(t.familyName,"When creating a new Font object, familyName is required."),Jt(t.styleName,"When creating a new Font object, styleName is required."),Jt(t.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),Jt(t.ascender,"When creating a new Font object, ascender is required."),Jt(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 Ke.GlyphSet(this,t.glyphs||[]),this.encoding=new qi(this),this.position=new ir(this),this.substitution=new Ae(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 ko(this)}})}re.prototype.hasChar=function(t){return this.encoding.charToGlyphIndex(t)!==null};re.prototype.charToGlyphIndex=function(t){return this.encoding.charToGlyphIndex(t)};re.prototype.charToGlyph=function(t){var e=this.charToGlyphIndex(t),r=this.glyphs.get(e);return r||(r=this.glyphs.get(0)),r};re.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})};re.prototype.stringToGlyphs=function(t,e){var r=this,n=new qe,s=function(c){return r.charToGlyphIndex(c.char)};n.registerModifier("glyphIndex",null,s);var i=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;n.applyFeatures(this,i);for(var o=n.getTextGlyphs(t),a=o.length,u=new Array(a),l=this.glyphs.get(0),f=0;f<a;f+=1)u[f]=this.glyphs.get(o[f])||l;return u};re.prototype.nameToGlyphIndex=function(t){return this.glyphNames.nameToGlyphIndex(t)};re.prototype.nameToGlyph=function(t){var e=this.nameToGlyphIndex(t),r=this.glyphs.get(e);return r||(r=this.glyphs.get(0)),r};re.prototype.glyphIndexToName=function(t){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(t):""};re.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};re.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]};re.prototype.forEachGlyph=function(t,e,r,n,s,i){e=e!==void 0?e:0,r=r!==void 0?r:0,n=n!==void 0?n:72,s=Object.assign({},this.defaultRenderOptions,s);var o=1/this.unitsPerEm*n,a=this.stringToGlyphs(t,s),u;if(s.kerning){var l=s.script||this.position.getDefaultScriptName();u=this.position.getKerningTables(l,s.language)}for(var f=0;f<a.length;f+=1){var c=a[f];if(i.call(this,c,e,r,n,s),c.advanceWidth&&(e+=c.advanceWidth*o),s.kerning&&f<a.length-1){var h=u?this.position.getKerningValue(u,c.index,a[f+1].index):this.getKerningValue(c,a[f+1]);e+=h*o}s.letterSpacing?e+=s.letterSpacing*n:s.tracking&&(e+=s.tracking/1e3*n)}return e};re.prototype.getPath=function(t,e,r,n,s){var i=new xe;return this.forEachGlyph(t,e,r,n,s,function(o,a,u,l){var f=o.getPath(a,u,l,s,this);i.extend(f)}),i};re.prototype.getPaths=function(t,e,r,n,s){var i=[];return this.forEachGlyph(t,e,r,n,s,function(o,a,u,l){var f=o.getPath(a,u,l,s,this);i.push(f)}),i};re.prototype.getAdvanceWidth=function(t,e,r){return this.forEachGlyph(t,0,0,e,r,function(){})};re.prototype.draw=function(t,e,r,n,s,i){this.getPath(e,r,n,s,i).draw(t)};re.prototype.drawPoints=function(t,e,r,n,s,i){this.forEachGlyph(e,r,n,s,i,function(o,a,u,l){o.drawPoints(t,a,u,l)})};re.prototype.drawMetrics=function(t,e,r,n,s,i){this.forEachGlyph(e,r,n,s,i,function(o,a,u,l){o.drawMetrics(t,a,u,l)})};re.prototype.getEnglishName=function(t){var e=this.names[t];if(e)return e.en};re.prototype.validate=function(){var t=this;function e(n,s){}function r(n){var s=t.getEnglishName(n);s&&s.trim().length>0}r("fontFamily"),r("weightName"),r("manufacturer"),r("copyright"),r("version"),this.unitsPerEm>0};re.prototype.toTables=function(){return cl.fontToTable(this)};re.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};re.prototype.toArrayBuffer=function(){for(var t=this.toTables(),e=t.encode(),r=new ArrayBuffer(e.length),n=new Uint8Array(r),s=0;s<e.length;s++)n[s]=e[s];return r};re.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(dl())if(window.URL=window.URL||window.webkitURL,window.URL){var s=new DataView(n),i=new Blob([s],{type:"font/opentype"}),o=document.createElement("a");o.href=window.URL.createObjectURL(i),o.download=t;var a=document.createEvent("MouseEvents");a.initEvent("click",!0,!1),o.dispatchEvent(a)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{var u=js(),l=gl(n);u.writeFileSync(t,l)}};re.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512};re.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};re.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function To(t,e){var r=JSON.stringify(t),n=256;for(var s in e){var i=parseInt(s);if(!(!i||i<256)){if(JSON.stringify(e[s])===r)return i;n<=i&&(n=i+1)}}return e[n]=t,n}function Ih(t,e,r){var n=To(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 Th(t,e,r){var n={},s=new M.Parser(t,e);return n.tag=s.parseTag(),n.minValue=s.parseFixed(),n.defaultValue=s.parseFixed(),n.maxValue=s.parseFixed(),s.skip("uShort",1),n.name=r[s.parseUShort()]||{},n}function Ch(t,e,r,n){for(var s=To(e.name,n),i=[{name:"nameID_"+t,type:"USHORT",value:s},{name:"flags_"+t,type:"USHORT",value:0}],o=0;o<r.length;++o){var a=r[o].tag;i.push({name:"axis_"+t+" "+a,type:"FIXED",value:e.coordinates[a]<<16})}return i}function Mh(t,e,r,n){var s={},i=new M.Parser(t,e);s.name=n[i.parseUShort()]||{},i.skip("uShort",1),s.coordinates={};for(var o=0;o<r.length;++o)s.coordinates[r[o].tag]=i.parseFixed();return s}function Ah(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(Ih(n,t.axes[n],e));for(var s=0;s<t.instances.length;s++)r.fields=r.fields.concat(Ch(s,t.instances[s],t.axes,e));return r}function Oh(t,e,r){var n=new M.Parser(t,e),s=n.parseULong();D.argument(s===65536,"Unsupported fvar table version.");var i=n.parseOffset16();n.skip("uShort",1);for(var o=n.parseUShort(),a=n.parseUShort(),u=n.parseUShort(),l=n.parseUShort(),f=[],c=0;c<o;c++)f.push(Th(t,e+i+c*a,r));for(var h=[],p=e+i+o*a,d=0;d<u;d++)h.push(Mh(t,p+d*l,f,r));return{axes:f,instances:h}}var Fh={make:Ah,parse:Oh},Dh=function(){return{coverage:this.parsePointer(v.coverage),attachPoints:this.parseList(v.pointer(v.uShortList))}},Uh=function(){var t=this.parseUShort();if(D.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()}},Rh=function(){return this.parseList(v.pointer(Uh))},Nh=function(){return{coverage:this.parsePointer(v.coverage),ligGlyphs:this.parseList(v.pointer(Rh))}},Bh=function(){return this.parseUShort(),this.parseList(v.pointer(v.coverage))};function Gh(t,e){e=e||0;var r=new v(t,e),n=r.parseVersion(1);D.argument(n===1||n===1.2||n===1.3,"Unsupported GDEF table version.");var s={version:n,classDef:r.parsePointer(v.classDef),attachList:r.parsePointer(Dh),ligCaretList:r.parsePointer(Nh),markAttachClassDef:r.parsePointer(v.classDef)};return n>=1.2&&(s.markGlyphSets=r.parsePointer(Bh)),s}var Hh={parse:Gh},$e=new Array(10);$e[1]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();if(r===1)return{posFormat:1,coverage:this.parsePointer(v.coverage),value:this.parseValueRecord()};if(r===2)return{posFormat:2,coverage:this.parsePointer(v.coverage),values:this.parseValueRecordList()};D.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};$e[2]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();D.assert(r===1||r===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var n=this.parsePointer(v.coverage),s=this.parseUShort(),i=this.parseUShort();if(r===1)return{posFormat:r,coverage:n,valueFormat1:s,valueFormat2:i,pairSets:this.parseList(v.pointer(v.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}})))};if(r===2){var o=this.parsePointer(v.classDef),a=this.parsePointer(v.classDef),u=this.parseUShort(),l=this.parseUShort();return{posFormat:r,coverage:n,valueFormat1:s,valueFormat2:i,classDef1:o,classDef2:a,class1Count:u,class2Count:l,classRecords:this.parseList(u,v.list(l,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}}))}}};$e[3]=function(){return{error:"GPOS Lookup 3 not supported"}};$e[4]=function(){return{error:"GPOS Lookup 4 not supported"}};$e[5]=function(){return{error:"GPOS Lookup 5 not supported"}};$e[6]=function(){return{error:"GPOS Lookup 6 not supported"}};$e[7]=function(){return{error:"GPOS Lookup 7 not supported"}};$e[8]=function(){return{error:"GPOS Lookup 8 not supported"}};$e[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Vh(t,e){e=e||0;var r=new v(t,e),n=r.parseVersion(1);return D.argument(n===1||n===1.1,"Unsupported GPOS table version "+n),n===1?{version:n,scripts:r.parseScriptList(),features:r.parseFeatureList(),lookups:r.parseLookupList($e)}:{version:n,scripts:r.parseScriptList(),features:r.parseFeatureList(),lookups:r.parseLookupList($e),variations:r.parseFeatureVariationsList()}}var zh=new Array(10);function $h(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,zh)}])}var Xh={parse:Vh,make:$h};function qh(t){var e={};t.skip("uShort");var r=t.parseUShort();D.argument(r===0,"Unsupported kern sub-table version."),t.skip("uShort",2);var n=t.parseUShort();t.skip("uShort",3);for(var s=0;s<n;s+=1){var i=t.parseUShort(),o=t.parseUShort(),a=t.parseShort();e[i+","+o]=a}return e}function Wh(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(),s=n&255;if(t.skip("uShort"),s===0){var i=t.parseUShort();t.skip("uShort",3);for(var o=0;o<i;o+=1){var a=t.parseUShort(),u=t.parseUShort(),l=t.parseShort();e[a+","+u]=l}}return e}function Zh(t,e){var r=new M.Parser(t,e),n=r.parseUShort();if(n===0)return qh(r);if(n===1)return Wh(r);throw new Error("Unsupported kern table version ("+n+").")}var _h={parse:Zh};function Yh(t,e,r,n){for(var s=new M.Parser(t,e),i=n?s.parseUShort:s.parseULong,o=[],a=0;a<r+1;a+=1){var u=i.call(s);n&&(u*=2),o.push(u)}return o}var jh={parse:Yh};function Ui(t,e){for(var r=[],n=12,s=0;s<e;s+=1){var i=M.getTag(t,n),o=M.getULong(t,n+4),a=M.getULong(t,n+8),u=M.getULong(t,n+12);r.push({tag:i,checksum:o,offset:a,length:u,compression:!1}),n+=16}return r}function Kh(t,e){for(var r=[],n=44,s=0;s<e;s+=1){var i=M.getTag(t,n),o=M.getULong(t,n+4),a=M.getULong(t,n+8),u=M.getULong(t,n+12),l=void 0;a<u?l="WOFF":l=!1,r.push({tag:i,offset:o,compression:l,compressedLength:a,length:u}),n+=20}return r}function de(t,e){if(e.compression==="WOFF"){var r=new Uint8Array(t.buffer,e.offset+2,e.compressedLength-2),n=new Uint8Array(e.length);if($a(r,n),n.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");var s=new DataView(n.buffer,0);return{data:s,offset:0}}else return{data:t,offset:e.offset}}function Co(t,e){e=e??{};var r,n,s=new re({empty:!0}),i=new DataView(t,0),o,a=[],u=M.getTag(i,0);if(u==="\0\0\0"||u==="true"||u==="typ1")s.outlinesFormat="truetype",o=M.getUShort(i,4),a=Ui(i,o);else if(u==="OTTO")s.outlinesFormat="cff",o=M.getUShort(i,4),a=Ui(i,o);else if(u==="wOFF"){var l=M.getTag(i,4);if(l==="\0\0\0")s.outlinesFormat="truetype";else if(l==="OTTO")s.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+u);o=M.getUShort(i,12),a=Kh(i,o)}else throw new Error("Unsupported OpenType signature "+u);for(var f,c,h,p,d,m,x,y,L,S,A,E,F=0;F<o;F+=1){var k=a[F],I=void 0;switch(k.tag){case"cmap":I=de(i,k),s.tables.cmap=Xi.parse(I.data,I.offset),s.encoding=new Wi(s.tables.cmap);break;case"cvt ":I=de(i,k),E=new M.Parser(I.data,I.offset),s.tables.cvt=E.parseShortList(k.length/2);break;case"fvar":c=k;break;case"fpgm":I=de(i,k),E=new M.Parser(I.data,I.offset),s.tables.fpgm=E.parseByteList(k.length);break;case"head":I=de(i,k),s.tables.head=ro.parse(I.data,I.offset),s.unitsPerEm=s.tables.head.unitsPerEm,r=s.tables.head.indexToLocFormat;break;case"hhea":I=de(i,k),s.tables.hhea=no.parse(I.data,I.offset),s.ascender=s.tables.hhea.ascender,s.descender=s.tables.hhea.descender,s.numberOfHMetrics=s.tables.hhea.numberOfHMetrics;break;case"hmtx":x=k;break;case"ltag":I=de(i,k),n=io.parse(I.data,I.offset);break;case"maxp":I=de(i,k),s.tables.maxp=oo.parse(I.data,I.offset),s.numGlyphs=s.tables.maxp.numGlyphs;break;case"name":S=k;break;case"OS/2":I=de(i,k),s.tables.os2=Vn.parse(I.data,I.offset);break;case"post":I=de(i,k),s.tables.post=co.parse(I.data,I.offset),s.glyphNames=new Zn(s.tables.post);break;case"prep":I=de(i,k),E=new M.Parser(I.data,I.offset),s.tables.prep=E.parseByteList(k.length);break;case"glyf":h=k;break;case"loca":L=k;break;case"CFF ":f=k;break;case"kern":y=k;break;case"GDEF":p=k;break;case"GPOS":d=k;break;case"GSUB":m=k;break;case"meta":A=k;break}}var z=de(i,S);if(s.tables.name=ho.parse(z.data,z.offset,n),s.names=s.tables.name,h&&L){var B=r===0,$=de(i,L),ge=jh.parse($.data,$.offset,s.numGlyphs,B),me=de(i,h);s.glyphs=bo.parse(me.data,me.offset,ge,s,e)}else if(f){var Y=de(i,f);to.parse(Y.data,Y.offset,s,e)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");var G=de(i,x);if(so.parse(s,G.data,G.offset,s.numberOfHMetrics,s.numGlyphs,s.glyphs,e),fu(s,e),y){var q=de(i,y);s.kerningPairs=_h.parse(q.data,q.offset)}else s.kerningPairs={};if(p){var ee=de(i,p);s.tables.gdef=Hh.parse(ee.data,ee.offset)}if(d){var Q=de(i,d);s.tables.gpos=Xh.parse(Q.data,Q.offset),s.position.init()}if(m){var se=de(i,m);s.tables.gsub=po.parse(se.data,se.offset)}if(c){var le=de(i,c);s.tables.fvar=Fh.parse(le.data,le.offset,s.names)}if(A){var K=de(i,A);s.tables.meta=go.parse(K.data,K.offset),s.metas=s.tables.meta}return s}var Jr=class{constructor(e,r){this.sources=e;this.fallback=r;this.parsed=new Map;this.missing=new Set}names(){return Object.keys(this.sources)}get(e){let r=e||this.fallback||Object.keys(this.sources)[0];if(!r)throw this.missing.add(""),new Error("text() needs a font. Pass fonts to render(), or --font on the command line.");let n=this.parsed.get(r);if(n)return n;let s=Lt(this.sources,r);if(!s)throw this.missing.add(r),new Error(`Font "${r}" is not available.${this.names().length?` Available fonts: ${this.names().join(", ")}`:""}`);let i=s instanceof Uint8Array?s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength):s,o=Co(i);return this.parsed.set(r,o),o}};function Jh(t,e,r){let n={kerning:!0};if(r.spacing===1)return{cmds:t.getPath(e,0,0,r.size,n).commands,advance:t.getAdvanceWidth(e,r.size,n)};let s=[],i=0,o=[...e];return o.forEach((a,u)=>{s.push(...t.getPath(a,i,0,r.size,n).commands),i+=t.getAdvanceWidth(a,r.size,n)*(u<o.length-1?r.spacing:1)}),{cmds:s,advance:i}}function Mo(t,e,r){let{cmds:n,advance:s}=Jh(t,e,r),i=n.map(a=>a.type==="Z"?a:a.type==="C"?{...a,y1:-a.y1,y2:-a.y2,y:-a.y}:a.type==="Q"?{...a,y1:-a.y1,y:-a.y}:{...a,y:-a.y}),o=Rr(i,Math.max(.005,r.size/2e3));return{polys:[...o.closed,...o.open.filter(a=>a.length>=3)],advance:s}}function Ao(t,e,r){if(!e)return[];let n=t.get(r.font),{polys:s,advance:i}=Mo(n,e,r),o=ye(s),a=Ar(o);if(!a)return[];let u=r.halign==="center"?-i/2:r.halign==="right"?-i:0,l=r.valign==="top"?-a[3]:r.valign==="center"?-(a[1]+a[3])/2:r.valign==="bottom"?-a[1]:0;return o.map(f=>f.map(([c,h])=>[c+u,h+l]))}function Oo(t,e,r){let n=t.get(r.font),{polys:s,advance:i}=Mo(n,e,r),o=Ar(s)??[0,0,0,0];return{advance:i,bounds:[[o[0],o[1]],[o[2],o[3]]],ascent:n.ascender/n.unitsPerEm*r.size,descent:n.descender/n.unitsPerEm*r.size}}var lr=[{name:"engrave",mode:"fill",color:"#000000"},{name:"score",mode:"line",color:"#0000ff"},{name:"cut",mode:"cut",color:"#ff0000"},{name:"guide",mode:"guide",color:"#00a0ff"}],es={maxParts:1e4,maxSegments:1e4,maxListLength:1e6,maxListItems:3e6,maxTextLength:2e3,maxPoints:2e6,maxOutputPoints:1e6,maxSheets:200,maxCollisionPairs:2e4},Qh=100,Nt=4,Fo=8,ec=t=>{let e=Qh,r=n=>{for(let s of n.values()){for(let i of s.regions)e+=i.length;for(let i of s.lines)e+=i.length}};r(t.layers);for(let n of t.parts)r(n.layers);return e},Se=class{constructor(e,r){this.parent=e;this.caller=r;this.vars=new Map;this.fns=new Map;this.mods=new Map}get(e){let r=this,n=e.startsWith("$");for(;r;){if(r.vars.has(e))return{found:!0,value:r.vars.get(e)};r=n?r.caller??r.parent:r.parent}return{found:!1}}fn(e){for(let r=this;r;r=r.parent){let n=r.fns.get(e);if(n)return n}}mod(e){for(let r=this;r;r=r.parent){let n=r.mods.get(e);if(n)return n}}childCtx(){for(let e=this;e;e=e.parent)if(e.children)return e.children}},tc=Zs,Qr=class{constructor(e={}){this.opts=e;this.steps=0;this.depth=0;this.pointCount=0;this.itemCount=0;this.copies=0;this.echoes=[];this.warnings=[];this.layers=new Map(lr.map(e=>[e.name,e]));this.loaded=new Map;this.maxSteps=e.maxSteps??5e6,this.limits={...es,...e.limits},this.builtins=this.makeBuiltins()}run(e){let r=new Se,n={$fn:0,$fa:2,$fs:.2,$thickness:3,$kerf:0,$material:"material",$sheet:[600,400],$gap:3,$layout:"pack",PI:Math.PI};for(let[o,a]of Object.entries(n))r.vars.set(o,a);let s=new Se(r);return{shape:this.block(e.body,s,!0),globals:s,layers:this.layers,echoes:this.echoes,warnings:this.warnings}}tick(e,r=1){if(!((this.steps+=r)<=this.maxSteps))throw new O(`Stopped after ${this.maxSteps} steps. Is there an endless loop?`,e)}load(e,r){let n=this.loaded.get(e);if(n)return n;let s=Lt(tc,e)??this.opts.resolve?.(e);if(typeof s!="string")throw new O(`Library <${e}> not found`,r);this.loaded.set(e,{body:[]});let{program:i}=it(s,e);return this.loaded.set(e,i),i}hoist(e,r){for(let n of e)if(n.kind==="module")r.mods.set(n.name,{params:n.params,body:n.body,env:r});else if(n.kind==="function")r.fns.set(n.name,{params:n.params,body:n.body,env:r});else if(n.kind==="use"&&!n.include){let s=this.included(this.load(n.path,n.pos).body,new Set([n.path])),i=new Se(r);this.hoist(s,i);for(let o of s)o.kind==="assign"&&this.assign(o.name,this.expr(o.value,i),i);for(let[o,a]of i.mods)r.mods.set(o,a);for(let[o,a]of i.fns)r.fns.set(o,a)}}included(e,r){let n=[];for(let s of e)if(s.kind!=="use"||!s.include)n.push(s);else if(!r.has(s.path)){r.add(s.path);for(let i of this.included(this.load(s.path,s.pos).body,r))n.push(i)}return n}assign(e,r,n){n.vars.set(e,r)}block(e,r,n=!1){this.hoist(e,r);let s=[];for(let i of e){let o=this.stmt(i,r,n);o&&!Rs(o)&&s.push(o)}return s.length===1?s[0]:Yt(s)}stmt(e,r,n=!1){switch(this.tick(e.pos),e.kind){case"assign":{let s=this.opts.overrides,i=n&&s&&Object.prototype.hasOwnProperty.call(s,e.name)?s[e.name]:this.expr(e.value,r);return this.assign(e.name,i,r),null}case"module":case"function":return null;case"use":{if(!e.include)return null;let s=this.load(e.path,e.pos);return this.block(s.body,r)}case"block":return this.block(e.body,new Se(r));case"if":return Me(this.expr(e.cond,r))?this.block(e.then,new Se(r)):this.block(e.else,new Se(r));case"let":{let s=new Se(r);return this.bindSeq(e.assigns,s),this.block(e.body,s)}case"for":{let s=[];return this.loop(e.assigns,r,i=>s.push(this.block(e.body,i))),Yt(s)}case"call":if(e.modifier==="*")return null;{let s=this.callModule(e,r);return e.modifier==="#"||e.modifier==="%"?Mr(s,"guide"):s}}}bindSeq(e,r){for(let n of e)this.assign(n.name,this.expr(n.value,r),r)}iterable(e,r){if(Be(e))try{return mr(e,this.limits.maxListLength)}catch(n){throw new O(n.message,r)}return Array.isArray(e)?e:typeof e=="string"?[...e]:e===void 0?[]:[e]}loop(e,r,n,s=0,i=new Se(r)){if(s===e.length)return n(i);let o=e[s];for(let a of this.iterable(this.expr(o.value,i),o.pos)){this.tick(o.pos);let u=new Se(i);u.vars.set(o.name,a),this.loop(e,r,n,s+1,u)}}evalArgs(e,r,n){let s=[],i=new Map;for(let o of e){let a=this.expr(o.value,r);o.name===null?s.push(a):i.set(o.name,a)}return{pos:s,named:i,at:n}}bindParams(e,r,n,s,i){let o=new Set(e.map(a=>a.name));e.forEach((a,u)=>{let l;r.named.has(a.name)?l=r.named.get(a.name):u<r.pos.length?l=r.pos[u]:l=a.default?this.expr(a.default,n):void 0,n.vars.set(a.name,l)});for(let a of r.named.keys())a.startsWith("$")?n.vars.set(a,r.named.get(a)):o.has(a)||this.unknownArg(i,a,r.at)}unknownArg(e,r,n){this.warn(`${e}: unknown argument "${r}" (${Dr(n,!1)})`)}warn(e){this.warnings.includes(e)||this.warnings.push(e)}callModule(e,r){let n=this.evalArgs(e.args,r,e.pos),s=r.mod(e.name);if(s){if(++this.depth>1e3)throw new O(`Recursion too deep in module ${e.name}()`,e.pos);try{let c=new Se(s.env,r);return this.bindParams(s.params,n,c,s.env,`${e.name}()`),c.children={stmts:e.children,env:r},c.vars.set("$children",this.childStmts(e.children).length),this.block(s.body,c)}finally{this.depth--}}let i=Lt(this.builtins,e.name);if(!i){let c=e.name==="color"?" Use layer(), cut(), score() or engrave() instead.":e.name==="square"?" Use rect().":"";throw new O(`Unknown module ${e.name}().${c}`,e.pos)}let o=new Se(r,r);for(let[c,h]of n.named)c.startsWith("$")&&o.vars.set(c,h);let a=this.childStmts(e.children),u=()=>new Se(r,o),l={args:n,env:o,children:()=>e.children.length?this.block(e.children,u()):xt(),childList:()=>{let c=u();this.hoist(e.children,c);let h=[];for(let p of e.children){let d=this.stmt(p,c);a.includes(p)&&h.push(d??xt())}return h}},f;try{f=i(l)}catch(c){throw c instanceof O?c:new O(`${e.name}(): ${c.message}`,e.pos)}if(this.pointCount+=ec(f),this.pointCount>this.limits.maxPoints)throw new O(`The shapes have more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes, or a lower $fn.`,e.pos);return f}childStmts(e){return e.filter(r=>r.kind!=="assign"&&r.kind!=="module"&&r.kind!=="function"&&r.kind!=="use")}callFunction(e,r,n,s){if(++this.depth>2e3)throw new O(`Recursion too deep in ${s}()`,r.at);try{this.tick(r.at);let i=tt(e)?e.scope:e.env,o=new Se(i,n);return this.bindParams(e.params,r,o,i,`${s}()`),this.expr(e.body,o)}finally{this.depth--}}expr(e,r){switch(e.kind){case"num":case"str":case"bool":return e.value;case"undef":return;case"var":{let n=r.get(e.name);if(n.found)return n.value;let s=r.fn(e.name);if(s)return{type:"function",params:s.params,body:s.body,scope:s.env,name:e.name};if(e.name.startsWith("$"))return;throw new O(`Unknown variable "${e.name}"`,e.pos)}case"list":{let n=[];for(let s of e.items)this.listItem(s,r,n,e.pos);return this.charge(Nt,e.pos),n}case"range":{let n=this.expr(e.start,r),s=this.expr(e.end,r),i=e.step?this.expr(e.step,r):1;if(typeof n!="number"||typeof s!="number"||typeof i!="number")throw new O("Range values must be numbers",e.pos);return{type:"range",start:n,step:i,end:s}}case"unary":{let n=this.expr(e.arg,r);return e.op==="!"?!Me(n):e.op==="+"?n:this.arith("*",-1,n,e.pos)}case"binary":{if(e.op==="&&")return Me(this.expr(e.left,r))&&Me(this.expr(e.right,r));if(e.op==="||")return Me(this.expr(e.left,r))||Me(this.expr(e.right,r));let n=this.expr(e.left,r),s=this.expr(e.right,r);if(e.op==="=="||e.op==="!=")return Ht(n,s,()=>this.tick(e.pos))===(e.op==="==");if(e.op==="<"||e.op==="<="||e.op===">"||e.op===">="){if(!(typeof n=="number"&&typeof s=="number"||typeof n=="string"&&typeof s=="string"))throw new O(`Can't compare ${De(n)} ${e.op} ${De(s)}`,e.pos);return e.op==="<"?n<s:e.op==="<="?n<=s:e.op===">"?n>s:n>=s}return this.arith(e.op,n,s,e.pos)}case"ternary":return Me(this.expr(e.cond,r))?this.expr(e.then,r):this.expr(e.else,r);case"index":{let n=this.expr(e.target,r),s=this.expr(e.index,r);if(typeof s!="number")throw new O(`List index must be a number, got ${De(s)}`,e.pos);return Array.isArray(n)?n[Math.floor(s)]:typeof n=="string"?[...n][Math.floor(s)]:Be(n)?[n.start,n.step,n.end][Math.floor(s)]:void 0}case"member":{let n=this.expr(e.target,r),s={x:0,y:1,z:2}[e.name];return Array.isArray(n)&&s!==void 0?n[s]:Be(n)&&(e.name==="begin"||e.name==="step"||e.name==="end")?e.name==="begin"?n.start:e.name==="step"?n.step:n.end:void 0}case"call":return this.call(e,r);case"lambda":return{type:"function",params:e.params,body:e.body,scope:r};case"let":{let n=new Se(r);return this.bindSeq(e.assigns,n),this.expr(e.body,n)}}}listItem(e,r,n,s){switch(e.kind){case"item":{let i=this.expr(e.expr,r);this.grow(n,1,s),n.push(i);return}case"each":{let i=this.iterable(this.expr(e.expr,r),s);this.grow(n,i.length,s);for(let o of i)n.push(o);return}case"for":this.loop(e.assigns,r,i=>this.listItem(e.body,i,n,s));return;case"if":Me(this.expr(e.cond,r))?this.listItem(e.then,r,n,s):e.else&&this.listItem(e.else,r,n,s);return;case"let":{let i=new Se(r);this.bindSeq(e.assigns,i),this.listItem(e.body,i,n,s)}}}grow(e,r,n){if(e.length+r>this.limits.maxListLength)throw new O(`a list of ${e.length+r} items is more than the limit of ${this.limits.maxListLength}`,n);this.charge(r,n)}charge(e,r){if(this.itemCount+=e,!(this.itemCount<=this.limits.maxListItems))throw new O(`The lists and strings hold more than ${this.limits.maxListItems} items in all, the limit. Is a loop building more than it needs?`,r)}call(e,r){if(e.callee.kind==="var"){let s=e.callee.name,i=r.get(s);if(!i.found){let o=r.fn(s);if(o)return this.callFunction(o,this.evalArgs(e.args,r,e.pos),r,s);let a=this.specialFunction(s,e,r);if(a.handled)return a.value;let u=Lt(ks,s);if(u){let l=this.evalArgs(e.args,r,e.pos);for(let p of l.named.keys())!p.startsWith("$")&&!u.params.includes(p)&&this.unknownArg(`${s}()`,p,e.pos);for(let p of bs(u,l.pos,l.named))this.warn(`${s}(): "${p}" is given by position and by name; the named value is used (${Dr(e.pos,!1)})`);let f={maxLength:this.limits.maxListLength,step:p=>this.tick(e.pos,p),given:l.pos.length+u.params.filter(p=>l.named.has(p)).length},c=Ss(u,l.pos,l.named);this.tick(e.pos,ws(s,c,this.limits.maxListLength));let h;try{h=u.run(c,f)}catch(p){throw p instanceof O?p:new O(p instanceof RangeError?`${s}(): the result is too large`:p.message,e.pos)}return this.checkValue(h,e.pos,s),h}throw new O(`Unknown function ${s}()`,e.pos)}if(!tt(i.value))throw new O(`"${s}" is a ${De(i.value)}, not a function`,e.pos);return this.callFunction(i.value,this.evalArgs(e.args,r,e.pos),r,s)}let n=this.expr(e.callee,r);if(!tt(n))throw new O(`Can't call a ${De(n)}`,e.pos);return this.callFunction(n,this.evalArgs(e.args,r,e.pos),r,"function")}specialFunction(e,r,n){if(e==="echo"){let s=this.evalArgs(r.args,n,r.pos);return this.echo(this.echoText(s),r.pos),{handled:!0,value:void 0}}if(e==="assert")return this.assert(this.evalArgs(r.args,n,r.pos)),{handled:!0,value:!0};if(e==="text_width"||e==="text_metrics"){let s=this.evalArgs(r.args,n,r.pos),i=this.measure(s,n);return e==="text_width"?{handled:!0,value:i.advance}:{handled:!0,value:[i.advance,i.bounds,i.ascent,i.descent]}}if(e==="finger_count"){let s=this.evalArgs(r.args,n,r.pos),i=this.num(this.arg(s,"length",0),"finger_count","length");return{handled:!0,value:Fr(i,this.fingerWidth(s,n,1))}}return{handled:!1}}assert(e){if(Me(this.arg(e,"condition",0)))return;let r=this.arg(e,"message",1);throw new O(`Assertion failed${r===void 0?"":": "+Ge(r)}`,e.at)}echo(e,r){this.charge(Math.ceil(e.length/Fo),r),this.echoes.push(e)}echoText(e){let r=this.limits.maxListLength,n=[],s=0,i=(o,a,u)=>{n.length&&(s+=2);let l=It(a,r-s-o.length,u);if(s+=o.length+l.text.length,!l.whole)throw new O(`echo(): the text would be longer than the limit of ${r} characters`,e.at);n.push(o+l.text)};for(let o of e.pos)i("",o,!1);for(let[o,a]of e.named)i(`${o} = `,a,!0);return n.join(", ")}arith(e,r,n,s){if(typeof r=="number"&&typeof n=="number")switch(e){case"+":return r+n;case"-":return r-n;case"*":return r*n;case"/":return r/n;case"%":return r%n;case"^":return Math.pow(r,n)}if(e==="+"&&typeof r=="string"&&typeof n=="string")return this.checkSize(r.length+n.length,!0,s),r+n;if(Array.isArray(r)&&Array.isArray(n)){if(e==="+"||e==="-"){if(r.length!==n.length)throw new O(`Can't ${e==="+"?"add":"subtract"} lists of length ${r.length} and ${n.length}`,s);return this.charge(r.length+Nt,s),r.map((o,a)=>this.arith(e,o,n[a],s))}if(e==="*"){if(Array.isArray(r[0]))return this.charge(r.length+Nt,s),r.map(a=>this.arith("*",a,n,s));let o=(a,u)=>{let l=this.arith("*",a,u,s);if(typeof l!="number")throw new O("Can't multiply these lists: an item times an item is not a number",s);return l};if(Array.isArray(n[0])){let a=n[0].length;if(r.length!==n.length||n.some(u=>!Array.isArray(u)||u.length!==a))throw new O(`Can't multiply a list of length ${r.length} by a matrix: it needs ${r.length} rows of the same length`,s);return this.checkSize(a,!1,s),this.tick(s,a*r.length),Array.from({length:a},(u,l)=>r.reduce((f,c,h)=>f+o(c,n[h][l]),0))}if(r.length!==n.length)throw new O(`Can't multiply lists of length ${r.length} and ${n.length}`,s);return this.tick(s,r.length),r.reduce((a,u,l)=>a+o(u,n[l]),0)}}if(Array.isArray(r)&&typeof n=="number"&&(e==="*"||e==="/"))return this.charge(r.length+Nt,s),r.map(o=>this.arith(e,o,n,s));if(typeof r=="number"&&Array.isArray(n)&&e==="*")return this.charge(n.length+Nt,s),n.map(o=>this.arith(e,r,o,s));let i={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"take remainder of","^":"raise"};throw new O(`Can't ${i[e]??e} ${De(r)} and ${De(n)}`,s)}arg(e,r,n,s){return e.named.has(r)?e.named.get(r):n>=0&&n<e.pos.length?e.pos[n]:s}num(e,r,n){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${n} must be a finite number, got ${dt(e)}`);return e}vec2(e,r,n=!0){let s=i=>typeof i=="number"&&Number.isFinite(i);if(s(e)&&n)return[e,e];if(Array.isArray(e)&&s(e[0])&&(e[1]===void 0||s(e[1])))return[e[0],e[1]??0];throw new Error(`${r} must be a number or [x, y], got ${dt(e)}`)}vec3(e,r){let n=s=>typeof s=="number"&&Number.isFinite(s);if(Array.isArray(e)&&(e.length===2||e.length===3)&&e.every(n))return[e[0],e[1],e[2]??0];throw new Error(`${r} must be [x, y, z], got ${dt(e)}`)}placements(e,r,n){let s=(a,u)=>a===void 0?[[0,0,0]]:Array.isArray(a)&&a.length>0&&Array.isArray(a[0])?a.map((l,f)=>this.vec3(l,`${u}[${f}]`)):[this.vec3(a,u)],i=s(e,"at"),o=s(r,"rotate");for(let[a,u]of[[i,"at"],[o,"rotate"]])if(a.length!==1&&a.length!==n)throw new Error(`${u} needs one placement per copy: qty is ${n} but ${u} has ${a.length}`);return Array.from({length:n},(a,u)=>({at:i[i.length===1?0:u],rotate:o[o.length===1?0:u]}))}points(e,r){if(!Array.isArray(e))throw new Error(`${r} must be a list of [x, y] points`);return e.map((n,s)=>{if(!Array.isArray(n)||!Number.isFinite(n[0])||!Number.isFinite(n[1]))throw new Error(`${r}[${s}] must be an [x, y] point, got ${dt(n)}`);return[n[0],n[1]]})}dyn(e,r){return e.get(r).value}spend(e){if(this.pointCount+=e,!(this.pointCount<=this.limits.maxPoints))throw new Error(`the shapes need more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes.`)}checkValue(e,r,n){(Array.isArray(e)||typeof e=="string")&&this.checkSize(e.length,typeof e=="string",r,n)}checkSize(e,r,n,s){if(e>this.limits.maxListLength)throw new O(`${s?`${s}(): `:""}${r?`a string of ${e} characters`:`a list of ${e} items`} is more than the limit of ${this.limits.maxListLength}`,n);this.charge(r?Math.ceil(e/Fo):e+Nt,n)}segs(e){let r=ke(this.dyn(e,"$fn"))||0,n=ke(this.dyn(e,"$fa"))||2,s=ke(this.dyn(e,"$fs"))||.2,i=this.limits.maxSegments;return o=>{let a=Vs(o,r,n,s);if(!(a<=i))throw new Error(`a circle with ${a} segments is more than the limit of ${i}. Lower $fn, or raise $fa or $fs.`);return a}}thickness(e){let r=this.dyn(e,"$thickness");if(typeof r!="number"||r<=0)throw new Error("$thickness must be a positive number");return r}fingerWidth(e,r,n){let s=this.arg(e,"finger",n);return typeof s=="number"&&s>0?s:Math.max(3*this.thickness(r),6)}measure(e,r){if(!this.opts.fonts)throw new O("text needs a font. Pass fonts to render(), or --font on the command line.",e.at);let n=It(this.arg(e,"text",0,""),this.limits.maxTextLength);if(!n.whole)throw new O(`the text is more than ${this.limits.maxTextLength} characters, the limit for one text()`,e.at);this.tick(e.at,n.text.length);try{return Oo(this.opts.fonts,n.text,this.textOpts(e,r))}catch(s){throw s instanceof O?s:new O(s.message,e.at)}}textOpts(e,r){return{size:this.num(this.arg(e,"size",1,10),"text","size"),font:Ge(this.arg(e,"font",2,this.dyn(r,"$font")??"")),halign:Ge(this.arg(e,"halign",-1,"left")),valign:Ge(this.arg(e,"valign",-1,"baseline")),spacing:ke(this.arg(e,"spacing",-1,1))}}edges(e){let r=n=>{if(n==="out"||n==="in"||n==="flat")return n;throw new Error(`edges must be "out", "in" or "flat", got ${dt(n)}`)};if(typeof e=="string")return[r(e),r(e),r(e),r(e)];if(Array.isArray(e)&&e.length===4)return e.map(r);throw new Error("edges must be one value or a list of 4: [bottom, right, top, left]")}makeBuiltins(){let e=(i,o)=>Cr(i.children(),o),r=i=>o=>Mr(o.children(),i);return{rect:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0,1),"size"),u=ke(this.arg(i.args,"r",-1,0))||0,l=Me(this.arg(i.args,"center",1,!1)),f=zs(o,a,u,this.segs(i.env));return Re(ye([l?f.map(([c,h])=>[c-o/2,h-a/2]):f]))},square:i=>this.builtins.rect(i),circle:i=>{let o=this.arg(i.args,"d",-1),a=o!==void 0?this.num(o,"circle","d")/2:this.num(this.arg(i.args,"r",0,1),"circle","r");return Re([Or(a,a,this.segs(i.env)(a))])},ellipse:i=>{let[o,a]=this.vec2(this.arg(i.args,"r",0,1),"r");return Re([Or(o,a,this.segs(i.env)(Math.max(o,a)))])},regular_polygon:i=>{let o=Math.max(3,Math.floor(this.num(this.arg(i.args,"n",0,6),"regular_polygon","n"))),a=this.num(this.arg(i.args,"r",1,10),"regular_polygon","r");if(!(o<=this.limits.maxSegments))throw new Error(`${o} corners is more than the limit of ${this.limits.maxSegments}`);return Re([Or(a,a,o)])},star:i=>{let o=Math.max(2,Math.floor(this.num(this.arg(i.args,"n",0,5),"star","n"))),a=this.num(this.arg(i.args,"r",1,10),"star","r"),u=this.num(this.arg(i.args,"inner",2,a*.45),"star","inner");if(!(o*2<=this.limits.maxSegments))throw new Error(`${o} points is more than the limit of ${this.limits.maxSegments/2}`);let l=[];for(let f=0;f<o*2;f++){let c=Math.PI/2+Math.PI*f/o,h=f%2?u:a;l.push([h*Math.cos(c),h*Math.sin(c)])}return Re(ye([l]))},polygon:i=>{let o=this.points(this.arg(i.args,"points",0),"points"),a=this.arg(i.args,"paths",1),u=Array.isArray(a)?a.map(l=>(Array.isArray(l)?l:[]).map(f=>o[ke(f)]).filter(Boolean)):[o];return Re(ye(u,"evenodd"))},path:i=>{let o=this.arg(i.args,"d",0);if(typeof o!="string")throw new Error('path() needs SVG path data, like path("M0 0 L10 0 L5 8 Z")');let a=Rr(_s(o),.01),u=this.arg(i.args,"fill",-1,"evenodd")==="nonzero"?"nonzero":"evenodd";return Yt([Re(ye(a.closed,u)),Mt(a.open)])},line:i=>{let o=this.vec2(this.arg(i.args,"from",0,[0,0]),"from",!1),a=this.vec2(this.arg(i.args,"to",1,[10,0]),"to",!1);return Mt([[o,a]])},polyline:i=>{let o=this.points(this.arg(i.args,"points",0),"points"),a=Me(this.arg(i.args,"closed",1,!1));return Mt([a&&o.length?[...o,o[0]]:o])},arc:i=>{let o=this.num(this.arg(i.args,"r",0,10),"arc","r"),a=this.num(this.arg(i.args,"start",1,0),"arc","start"),u=this.num(this.arg(i.args,"end",2,90),"arc","end"),l=Math.max(2,Math.ceil(this.segs(i.env)(o)*Math.abs(u-a)/360));if(!(l<=this.limits.maxSegments))throw new Error(`an arc with ${l} segments is more than the limit of ${this.limits.maxSegments}`);let f=[];for(let c=0;c<=l;c++){let h=(a+(u-a)*c/l)*Math.PI/180;f.push([o*Math.cos(h),o*Math.sin(h)])}return Mt([f])},text:i=>{if(!this.opts.fonts)throw new Error("text() needs a font. Pass fonts to render(), or --font on the command line.");let o=this.arg(i.args,"text",0,""),a=It(o,this.limits.maxTextLength);if(!a.whole)throw new Error(`the text is more than ${this.limits.maxTextLength} characters, the limit for one text()`);return this.tick(i.args.at,a.text.length),Re(Ao(this.opts.fonts,a.text,this.textOpts(i.args,i.env)))},translate:i=>{let[o,a]=this.vec2(this.arg(i.args,"v",0,[0,0]),"v",!1);return e(i,[1,0,0,1,o,a])},rotate:i=>{let o=this.arg(i.args,"a",0,0),u=(Array.isArray(o)?ke(o[2]??0):this.num(o,"rotate","a"))*Math.PI/180,l=Math.cos(u),f=Math.sin(u),c=this.arg(i.args,"center",-1),h=[l,f,-f,l,0,0];if(c!==void 0){let[p,d]=this.vec2(c,"center",!1);h=[l,f,-f,l,p-l*p+f*d,d-f*p-l*d]}return e(i,h)},scale:i=>{let[o,a]=this.vec2(this.arg(i.args,"v",0,1),"v");return e(i,[o,0,0,a,0,0])},mirror:i=>{let[o,a]=this.vec2(this.arg(i.args,"v",0,[1,0]),"v",!1),u=Math.hypot(o,a)||1,l=o/u,f=a/u;return e(i,[1-2*l*l,-2*l*f,-2*l*f,1-2*f*f,0,0])},multmatrix:i=>{let o=this.arg(i.args,"m",0);if(!Array.isArray(o)||o.length<2)throw new Error("m must be a 2x3 or 3x3 matrix");let a=o[0],u=o[1];return e(i,[a[0],u[0],a[1],u[1],a[2]??0,u[2]??0])},union:i=>i.children(),group:i=>i.children(),difference:i=>{let[o,...a]=i.childList();if(!o)return xt();let u=n(a,"difference");return s(o,l=>({regions:Lr(l.regions,u.regions),lines:_t(l.lines,ye(u.regions),"outside")}))},intersection:i=>{let[o,...a]=i.childList();if(!o)return xt();let u=o;for(let l of a){let f=ye(n([l],"intersection").regions);u=s(u,c=>({regions:Ir(c.regions,f),lines:_t(c.lines,f,"inside")}))}return u},hull:i=>{let o=i.children(),a=u=>{let l=[],f="cut",c=!0;for(let[p,d]of u){c&&(d.regions.length||d.lines.length)&&(f=p,c=!1);for(let m of[...d.regions,...d.lines])for(let x of m)l.push(x)}let h=Hs(l);return new Map([[f,{regions:h.length>=3?[h]:[],lines:[]}]])};return{layers:a(o.layers),parts:o.parts.map(u=>({...u,layers:a(u.layers)}))}},offset:i=>{let o=this.arg(i.args,"r",0),a=this.arg(i.args,"delta",-1),u=Me(this.arg(i.args,"chamfer",-1,!1)),l=o!==void 0?this.num(o,"offset","r"):this.num(a??0,"offset","delta"),f=o!==void 0?"round":u?"square":"miter";return s(i.children(),c=>({regions:Tr(c.regions,l,f),lines:c.lines}))},stroke:i=>{let o=this.num(this.arg(i.args,"width",0,1),"stroke","width");return s(i.children(),a=>({regions:ye([...a.regions,...Bs(a.lines,o)]),lines:[]}))},outline:i=>s(i.children(),o=>({regions:[],lines:[...o.lines,...ye(o.regions).map(a=>[...a,a[0]])]})),cut:r("cut"),score:r("score"),engrave:r("engrave"),guide:r("guide"),layer:i=>{let o=this.arg(i.args,"name",0);if(typeof o!="string"||!o)throw new Error("layer() needs a name");let a=this.arg(i.args,"mode",1),u=this.arg(i.args,"color",2),l=this.layers.get(o);if(a!==void 0||u!==void 0||!l){let f=a??l?.mode??"line";if(!["cut","line","fill","guide"].includes(f))throw new Error('mode must be "cut", "line", "fill" or "guide"');let c=Ge(u??l?.color??"#00aa00");if(!/^#[0-9a-fA-F]{6}$/.test(c))throw new Error('color must look like "#00aa00"');this.layers.set(o,{name:o,mode:f,color:c})}return Mr(i.children(),o)},part:i=>{let o=Ge(this.arg(i.args,"name",0,"part")),a=Math.max(1,Math.floor(ke(this.arg(i.args,"qty",1,1))||1));if(this.copies+=a,!(this.copies<=this.limits.maxParts))throw new Error(`more than ${this.limits.maxParts} part copies in total, the limit`);let u=this.arg(i.args,"at",-1),l=this.arg(i.args,"rotate",-1),f=u===void 0&&l===void 0?void 0:this.placements(u,l,a),c=i.children();return{layers:new Map,parts:[...c.parts,{name:o,qty:a,layers:c.layers,thickness:this.thickness(i.env),kerf:ke(this.dyn(i.env,"$kerf"))||0,material:Ge(this.dyn(i.env,"$material")??"material"),...f?{placements:f}:{}}]}},material:i=>{let o=this.arg(i.args,"thickness",0),a=this.arg(i.args,"kerf",1),u=this.arg(i.args,"name",2);return o!==void 0&&i.env.vars.set("$thickness",this.num(o,"material","thickness")),a!==void 0&&i.env.vars.set("$kerf",this.num(a,"material","kerf")),u!==void 0&&i.env.vars.set("$material",Ge(u)),i.children()},children:i=>{let o=i.env.childCtx();if(!o)return xt();let a=this.childStmts(o.stmts),u=this.arg(i.args,"index",0),l=new Se(o.env,i.env);this.hoist(o.stmts,l);let f=new Set;if(u===void 0)a.forEach(h=>f.add(h));else for(let h of this.iterable(u,i.args.at))a[ke(h)]&&f.add(a[ke(h)]);let c=[];for(let h of o.stmts)if(h.kind==="assign")this.stmt(h,l);else if(f.has(h)){let p=this.stmt(h,l);p&&c.push(p)}return Yt(c)},echo:i=>(this.echo(this.echoText(i.args),i.args.at),i.children()),assert:i=>(this.assert(i.args),i.children()),finger_rect:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0),"size"),u=this.edges(this.arg(i.args,"edges",1,"out")),l=this.thickness(i.env),f=this.fingerWidth(i.args,i.env,2);return this.spend(2*(Math.abs(o)+Math.abs(a))/f*4),Re($s(o,a,u,l,f))},finger_holes:i=>{let o=this.num(this.arg(i.args,"length",0),"finger_holes","length"),a=this.edges(this.arg(i.args,"edge",1,"out"))[0];if(a==="flat")throw new Error('edge must be "out" or "in"');let u=this.fingerWidth(i.args,i.env,2);return this.spend(Math.abs(o)/u*4),Re(Xs(o,a,this.thickness(i.env),u))},tslot:i=>{let o=this.num(this.arg(i.args,"d",0,3),"tslot","d"),a=this.num(this.arg(i.args,"length",1,12),"tslot","length"),[u,l]=this.vec2(this.arg(i.args,"nut",2,[o*1.85,o*.8]),"nut",!1),f=this.num(this.arg(i.args,"nut_at",3,a/2),"tslot","nut_at");return Re(ye(qs(o,a,u,l,f)))},living_hinge:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0),"size"),u=this.num(this.arg(i.args,"spacing",1,1.5),"living_hinge","spacing"),l=this.num(this.arg(i.args,"bridge",2,3),"living_hinge","bridge"),f=this.num(this.arg(i.args,"cut",3,Math.max(l*2,(a-3*l)/2)),"living_hinge","cut");if(u<=0||l<=0||f<=0)throw new Error("spacing, bridge and cut must be positive");return this.spend((Math.abs(o)/u+1)*(Math.abs(a)/(f+l)+2)*2),Mt(Ws(o,a,u,l,f))}};function n(i,o){let a={regions:[],lines:[]};for(let u of i){if(u.parts.length)throw new Error(`part() can only be the first child of ${o}()`);for(let l of u.layers.values())for(let f of l.regions)a.regions.push(f)}return a}function s(i,o){let a=u=>{let l=new Map;for(let[f,c]of u)l.set(f,o(c));return l};return{layers:a(i.layers),parts:i.parts.map(u=>({...u,layers:a(u.layers)}))}}}};var Bt=t=>{let e=Math.round(t*1e3)/1e3;return Object.is(e,-0)?"0":String(e)},ts=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;");function rs(t,e){let r=[];for(let[n,s]of t){let i=[Bt(n),Bt(s)],o=r[r.length-1];(!o||o[0]!==i[0]||o[1]!==i[1])&&r.push(i)}for(;e&&r.length>1&&r[0][0]===r[r.length-1][0]&&r[0][1]===r[r.length-1][1];)r.pop();return r}var Gt=(t,e)=>`M${rs(t,e).map(([r,n])=>`${r} ${n}`).join("L")}${e?"Z":""}`;function ns(t,e){let r=[];for(let n of e){let s=[],i=[],o=[];for(let a of t){let u=a.layers.get(n.name);if(u){for(let l of u.lines)s.push(Gt(l,!1));for(let l of u.regions)(st(l)<0?i:o).push(Gt(l,!0))}}(s.length||i.length||o.length)&&r.push({name:n.name,mode:n.mode,color:n.color,d:[...s,...i,...o].join(""),regions:[...i,...o].join(""),lines:s.join("")})}return r}function ss(t,e,r,n){let s=['<?xml version="1.0" encoding="UTF-8"?>',`<svg xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="${Bt(e)}mm" height="${Bt(r)}mm" viewBox="0 0 ${Bt(e)} ${Bt(r)}">`];for(let i of n){let o=[],a=[];for(let l of t){let f=l.layers.get(i.name);if(!f)continue;let c=` data-part="${ts(l.part)}"`;if(i.mode==="fill"){f.regions.length&&a.push(`<path${c} d="${f.regions.map(h=>Gt(h,!0)).join("")}"/>`);for(let h of f.lines)a.push(`<path${c} fill="none" stroke="${i.color}" stroke-width="0.1" d="${Gt(h,!1)}"/>`);continue}for(let h of f.lines)o.push(`<path${c} d="${Gt(h,!1)}"/>`);for(let h of f.regions)(st(h)<0?o:a).push(`<path${c} d="${Gt(h,!0)}"/>`)}if(!o.length&&!a.length)continue;let u=i.mode==="fill"?`fill="${i.color}" fill-rule="evenodd" stroke="none"`:`fill="none" stroke="${i.color}" stroke-width="0.1"${i.mode==="guide"?' stroke-dasharray="1 1"':""}`;s.push(`<g id="${ts(i.name)}" inkscape:groupmode="layer" inkscape:label="${ts(i.name)}" data-mode="${i.mode}" ${u}>`,...o,...a,"</g>")}return s.push("</svg>",""),s.join(`
42
+ `)}var rc={"#ff0000":1,"#ffff00":2,"#00ff00":3,"#00ffff":4,"#0000ff":5,"#ff00ff":6,"#000000":7},nc=t=>{let e=rc[t.toLowerCase()];if(e)return e;let[r,n,s]=[1,3,5].map(i=>parseInt(t.slice(i,i+2),16));return r>n&&r>s?1:n>r&&n>s?3:s>r&&s>n?5:7};function sc(t){let e=a=>a.toUpperCase().replace(/[^A-Z0-9_-]/g,"_"),r=new Set(lr.map(a=>a.name)),n=new Set(t.map(a=>e(a.name))),s=new Set,i=new Map,o=[...t.filter(a=>r.has(a.name)),...t.filter(a=>!r.has(a.name))];for(let a of o){let u=e(a.name);if(s.has(u)){let l=2;for(;n.has(`${u}_${l}`)||s.has(`${u}_${l}`);)l++;u=`${u}_${l}`}s.add(u),i.set(a.name,u)}return i}function Do(t,e,r,n){let s=[],i=(u,l)=>s.push(String(u),String(l)),o=sc(n);i(0,"SECTION"),i(2,"HEADER"),i(9,"$ACADVER"),i(1,"AC1009"),i(9,"$INSUNITS"),i(70,4),i(0,"ENDSEC"),i(0,"SECTION"),i(2,"TABLES"),i(0,"TABLE"),i(2,"LAYER"),i(70,n.length);for(let u of n)i(0,"LAYER"),i(2,o.get(u.name)),i(70,0),i(62,nc(u.color)),i(6,"CONTINUOUS");i(0,"ENDTAB"),i(0,"ENDSEC"),i(0,"SECTION"),i(2,"ENTITIES");let a=(u,l,f)=>{i(0,"POLYLINE"),i(8,u),i(66,1),i(10,0),i(20,0),i(30,0),i(70,f?1:0);for(let[c,h]of rs(l.map(([p,d])=>[p,r-d]),f))i(0,"VERTEX"),i(8,u),i(10,c),i(20,h),i(30,0);i(0,"SEQEND"),i(8,u)};for(let u of n){let l=o.get(u.name),f=[];for(let c of t){let h=c.layers.get(u.name);if(h){for(let p of h.lines)a(l,p,!1);for(let p of h.regions)st(p)<0?a(l,p,!0):f.push(p)}}for(let c of f)a(l,c,!0)}return i(0,"ENDSEC"),i(0,"EOF"),s.join(`
38
43
  `)+`
39
- `}var Ji=(r,e)=>{let t=0;for(let n=1;n<r.length;n++)t+=Math.hypot(r[n][0]-r[n-1][0],r[n][1]-r[n-1][1]);return e&&r.length>2&&(t+=Math.hypot(r[0][0]-r[r.length-1][0],r[0][1]-r[r.length-1][1])),t},ot=r=>Math.round(r*100)/100;function Qi(r,e={}){let{program:t}=Je(r),n=e.fonts?new Rr(e.fonts,e.defaultFont):void 0,s=new Nr({overrides:e.params,resolve:e.resolve,fonts:n,maxSteps:e.maxSteps,limits:e.limits}),i=s.limits,o;try{o=s.run(t)}catch(k){let M=k instanceof RangeError?new R(/call stack/i.test(k.message)?"Recursion too deep: the program calls itself without stopping":"A value grew too large. Is a list or string doubling without end?"):k;throw M instanceof R&&(M.echoes=s.echoes,n?.missing.size&&(M.missingFonts=[...n.missing])),M}let a=k=>o.globals.get(k).value,u=o.warnings,l=o.layers,f=k=>l.get(k)?.mode??"line",c=[...o.shape.parts];[...o.shape.layers.values()].some(k=>k.regions.length||k.lines.length)&&c.unshift({name:"part",qty:1,layers:o.shape.layers,thickness:Number(a("$thickness"))||3,kerf:Number(a("$kerf"))||0,material:String(a("$material")??"material")}),c.length||u.push("Nothing to cut: the program made no shapes.");let p=[],g=[];for(let k of c){let M=de([...k.layers].filter(([te])=>f(te)==="cut").flatMap(([,te])=>te.regions)),A=new Map;for(let[te,le]of k.layers){if(f(te)==="guide"&&!e.guides)continue;let ue=de(le.regions),pe=le.lines.filter(K=>K.length>=2);(f(te)==="line"||f(te)==="guide")&&(pe=[...pe,...ue.map(K=>[...K,K[0]])],ue=[]),M.length&&f(te)!=="guide"&&(f(te)!=="cut"&&(ue=cr(ue,M)),pe=Rt(pe,M,"inside")),(ue.length||pe.length)&&A.set(te,{regions:ue,lines:pe})}let G=ss(M).length;G>1&&u.push(`Part "${k.name}" cuts into ${G} separate pieces. Join them, or make them separate parts.`);let D=0;for(let[te,le]of A)if(f(te)==="cut"){for(let ue of le.regions)D+=Ji(ue,!0);for(let ue of le.lines)D+=Ji(ue,!1)}let H=Qr(A)??[0,0,0,0],se=e.kerf??k.kerf;if(!(Number.isFinite(se)&&se>=0))throw new R("$kerf must be a number, 0 or more");let be={name:k.name,qty:k.qty,width:ot(H[2]-H[0]),height:ot(H[3]-H[1]),pieces:G,cutLength:Math.round(D),thickness:k.thickness,kerf:se,material:k.material};if(se>0){for(let[te,le]of A)if(f(te)==="cut"){let ue=le.regions.filter(K=>Ke(K)<0).length;le.regions=pr(le.regions,se/2,"round",Math.min(.01,se/20));let pe=ue-le.regions.filter(K=>Ke(K)<0).length;pe>0&&u.push(`Part "${k.name}": ${pe} hole${pe===1?" is":"s are"} narrower than the ${se} mm kerf and will not be cut.`)}}p.push(be),g.push({info:be,layers:A})}let m=0;for(let k of g){let M=0;for(let A of k.layers.values()){for(let G of A.regions)M+=G.length;for(let G of A.lines)M+=G.length}m+=M*k.info.qty}if(m>i.maxOutputPoints)throw new R(`The files would have ${m} points, more than the limit of ${i.maxOutputPoints}. Use fewer copies or simpler shapes.`);let x=e.sheet??a("$sheet");if(!Array.isArray(x)||!(Number.isFinite(x[0])&&x[0]>0)||!(Number.isFinite(x[1])&&x[1]>0))throw new R("$sheet must be [width, height], both more than 0");let y=e.gap??Number(a("$gap")??3),S=e.margin??y;if(!(Number.isFinite(y)&&y>=0))throw new R("$gap must be a number, 0 or more");if(!(Number.isFinite(S)&&S>=0))throw new R("margin must be a number, 0 or more");let w=e.layout??(a("$layout")==="none"?"none":"pack"),P=["engrave",...[...l.keys()].filter(k=>!["engrave","score","cut","guide"].includes(k)),"score","cut","guide"].map(k=>l.get(k)).filter(Boolean),U=[],O=[1,0,0,-1,0,0],L=k=>Qr(k)??[0,0,0,0],W=(k,M)=>dr({layers:k,parts:[]},M).layers;if(w==="none"){let k=[];for(let D of g)for(let H=0;H<D.info.qty;H++)k.push({part:D.info.name,copy:H+1,layers:W(D.layers,O),rotated:!1});let M=new Map;for(let D of k)for(let[H,se]of D.layers){let be=M.get(H)??{regions:[],lines:[]};for(let te of se.regions)be.regions.push(te);for(let te of se.lines)be.lines.push(te);M.set(H,be)}let A=L(M),G=[1,0,0,1,S-A[0],S-A[1]];for(let D of k)D.layers=W(D.layers,G);U.push(_(k,A[2]-A[0]+2*S,A[3]-A[1]+2*S,g[0]?.info))}else{let k=new Map;for(let M of g){let A=`${M.info.material}|${M.info.thickness}`;k.set(A,[...k.get(A)??[],M])}for(let M of k.values()){let[A,G]=x,D=[];for(let K of M){let Ne=W(K.layers,O),Me=L(Ne),vt=Me[2]-Me[0],mt=Me[3]-Me[1],Gn=!1;(vt>A-2*S||mt>G-2*S)&&mt<=A-2*S&&vt<=G-2*S&&(Ne=W(Ne,[0,1,-1,0,0,0]),Me=L(Ne),vt=Me[2]-Me[0],mt=Me[3]-Me[1],Gn=!0),(vt>A-2*S||mt>G-2*S)&&u.push(`Part "${K.info.name}" (${ot(vt)} x ${ot(mt)} mm) is bigger than the ${A} x ${G} mm sheet.`),Ne=W(Ne,[1,0,0,1,-Me[0],-Me[1]]);for(let Br=0;Br<K.info.qty;Br++)D.push({info:K.info,layers:Ne,w:vt,h:mt,copy:Br+1,rotated:Gn})}D.sort((K,Ne)=>Ne.h-K.h||Ne.w-K.w);let H=[],se=S,be=S,te=0,le=0,ue=0,pe=()=>{if(H.length&&U.length>=i.maxSheets)throw new R(`The parts need more than ${i.maxSheets} sheets, the limit. Use fewer copies or a bigger $sheet.`);H.length&&U.push(_(H,Math.max(le+S,1),Math.max(ue+S,1),M[0].info)),H=[],se=S,be=S,te=0,le=0,ue=0};for(let K of D)se>S&&se+K.w>A-S&&(se=S,be+=te+y,te=0),H.length&&be+K.h>G-S&&pe(),H.push({part:K.info.name,copy:K.copy,layers:W(K.layers,[1,0,0,1,se,be]),rotated:K.rotated}),le=Math.max(le,se+K.w),ue=Math.max(ue,be+K.h),se+=K.w+y,te=Math.max(te,K.h);pe()}}function _(k,M,A,G){let D=ot(M),H=ot(A);return{width:D,height:H,material:G?.material??"material",thickness:G?.thickness??0,items:k,paths:Nn(k,P),svg:Bn(k,D,H,P),dxf:Ki(k,D,H,P)}}let Y=U.length===1?U[0]:void 0,he=Y?[]:U.flatMap((k,M)=>{let A=U.slice(0,M).reduce((G,D)=>G+D.height+10,0);return k.items.map(G=>({...G,layers:W(G.layers,[1,0,0,1,0,A])}))}),ce=ot(Math.max(1,...U.map(k=>k.width))),Q=ot(Math.max(1,U.reduce((k,M)=>k+M.height,0)+10*Math.max(0,U.length-1))),X=Y?Y.svg:Bn(he,ce,Q,P),ee=Y?Y.paths:Nn(he,P);return{sheets:U,width:Y?.width??ce,height:Y?.height??Q,paths:ee,svg:X,parts:p,layers:P,warnings:u,echoes:o.echoes}}function to(r){switch(r.kind){case"num":case"str":case"bool":return{ok:!0,value:r.value};case"unary":return r.op==="-"&&r.arg.kind==="num"?{ok:!0,value:-r.arg.value}:{ok:!1};case"list":{let e=[];for(let t of r.items){if(t.kind!=="item")return{ok:!1};let n=to(t.expr);if(!n.ok||typeof n.value!="number")return{ok:!1};e.push(n.value)}return{ok:!0,value:e}}default:return{ok:!1}}}function eo(r){let e=Number(r.trim());return r.trim()!==""&&Number.isFinite(e)?e:void 0}function ro(r){let{program:e,comments:t}=Je(r),n=t.filter(a=>a.block&&/^\[[^\]]+\]$/.test(a.text)),s=new Map(t.filter(a=>!a.block&&!a.own).map(a=>[a.line,a.text])),i=new Map(t.filter(a=>!a.block&&a.own).map(a=>[a.line,a.text])),o=[];for(let a of e.body){if(a.kind!=="assign"||/^\$f[nas]$/.test(a.name))continue;let u=to(a.value);if(!u.ok)continue;let l=n.filter(m=>m.line<=a.pos.line).pop()?.text.slice(1,-1).trim()??"Parameters";if(l.toLowerCase()==="hidden")continue;let f=s.get(a.pos.line),c=i.get(a.pos.line-1)??"",h=u.value,p={name:a.name,caption:c,group:l,type:typeof h=="number"||Array.isArray(h)?"number":typeof h=="boolean"?"boolean":"string",initial:h,span:a.span},g=f?/^\[(.*)\]$/.exec(f.trim()):null;if(g){let m=g[1];if(m.includes(",")||/[a-zA-Z"]/.test(m)&&!/^-?[\d.]+(:-?[\d.]+){0,2}$/.test(m))p.options=m.split(",").map(x=>{let[y,S]=x.split(":").map(P=>P.trim().replace(/^"|"$/g,"")),w=eo(y),F=p.type==="number"&&w!==void 0?w:y;return{name:S??y,value:F}});else{let x=m.split(":").map(eo);x.every(y=>y!==void 0)&&(x.length===1?p.max=x[0]:x.length===2?(p.min=x[0],p.max=x[1]):(p.min=x[0],p.step=x[1],p.max=x[2]))}}o.push(p)}return{parameters:o}}var dh="0.2.1",gh="0.1";
44
+ `}var Uo=(t,e)=>{let r=0;for(let n=1;n<t.length;n++)r+=Math.hypot(t[n][0]-t[n-1][0],t[n][1]-t[n-1][1]);return e&&t.length>2&&(r+=Math.hypot(t[0][0]-t[t.length-1][0],t[0][1]-t[t.length-1][1])),r},pt=t=>Math.round(t*100)/100;function Ro(t,e={}){for(let[w,R]of Object.entries(e.params??{}))try{on(w,R)}catch(W){throw new O(W.message)}let{program:r}=it(t),n=e.fonts?new Jr(e.fonts,e.defaultFont):void 0,s=new Qr({overrides:e.params,resolve:e.resolve,fonts:n,maxSteps:e.maxSteps,limits:e.limits}),i=s.limits,o;try{o=s.run(r)}catch(w){let R=w instanceof RangeError?new O(/call stack/i.test(w.message)?"Recursion too deep: the program calls itself without stopping":"A value grew too large. Is a list or string doubling without end?"):w;throw R instanceof O&&(R.echoes=s.echoes,n?.missing.size&&(R.missingFonts=[...n.missing])),R}let a=w=>o.globals.get(w).value,u=o.warnings,l=o.layers,f=w=>l.get(w)?.mode??"line",c=[...o.shape.parts];[...o.shape.layers.values()].some(w=>w.regions.length||w.lines.length)&&c.unshift({name:"part",qty:1,layers:o.shape.layers,thickness:ke(a("$thickness"))||3,kerf:ke(a("$kerf"))||0,material:Ge(a("$material")??"material")}),c.length||u.push("Nothing to cut: the program made no shapes.");let p=[],d=[],m=[],x=new Set,y=[];for(let w of c){let R=ye([...w.layers].filter(([te])=>f(te)==="cut").flatMap(([,te])=>te.regions)),W=new Map;for(let[te,he]of w.layers){if(f(te)==="guide"&&!e.guides)continue;let ve=ye(he.regions),Ee=he.lines.filter(j=>j.length>=2);(f(te)==="line"||f(te)==="guide")&&(Ee=[...Ee,...ve.map(j=>[...j,j[0]])],ve=[]),R.length&&f(te)!=="guide"&&(f(te)!=="cut"&&(ve=Ir(ve,R)),Ee=_t(Ee,R,"inside")),(ve.length||Ee.length)&&W.set(te,{regions:ve,lines:Ee})}if(R.length){let te={name:w.name,thickness:w.thickness,outline:R};if(w.placements){let he=new Set;w.placements.forEach((ve,Ee)=>{let j={...te,copy:Ee+1,matrix:sn(ve),placed:!0};d.push(j);let Te=j.matrix.map(Ce=>Ce.toFixed(6)).join(",");he.has(Te)&&x.add(j),he.add(Te)}),he.size<w.placements.length&&u.push(`Copies of part "${w.name}" are in the same place in the assembly. Give at a list with one placement per copy to spread them out.`)}else for(let he=0;he<w.qty;he++)m.push({...te,copy:he+1,matrix:sn({at:[0,0,0],rotate:[0,0,0]}),placed:!1})}let ie=Gs(R).length;ie>1&&u.push(`Part "${w.name}" cuts into ${ie} separate pieces. Join them, or make them separate parts.`);let ne=0;for(let[te,he]of W)if(f(te)==="cut"){for(let ve of he.regions)ne+=Uo(ve,!0);for(let ve of he.lines)ne+=Uo(ve,!1)}let oe=wn(W)??[0,0,0,0],fe=e.kerf??w.kerf;if(!(Number.isFinite(fe)&&fe>=0))throw new O("$kerf must be a number, 0 or more");let Fe={name:w.name,qty:w.qty,width:pt(oe[2]-oe[0]),height:pt(oe[3]-oe[1]),pieces:ie,cutLength:Math.round(ne),thickness:w.thickness,kerf:fe,material:w.material};if(fe>0){for(let[te,he]of W)if(f(te)==="cut"){let ve=he.regions.filter(j=>st(j)<0).length;he.regions=Tr(he.regions,fe/2,"round",Math.min(.01,fe/20));let Ee=ve-he.regions.filter(j=>st(j)<0).length;Ee>0&&u.push(`Part "${w.name}": ${Ee} hole${Ee===1?" is":"s are"} narrower than the ${fe} mm kerf and will not be cut.`)}}p.push(Fe),y.push({info:Fe,layers:W})}let{found:L,complete:S}=gs(d.filter(w=>!x.has(w)),i.maxCollisionPairs);S||u.push(`The assembly has more than ${i.maxCollisionPairs} pairs of touching parts, the limit, so only those were checked for collisions.`);for(let[w,R]of L.slice(0,5))u.push(`Parts "${w.name}"${w.copy>1?` (copy ${w.copy})`:""} and "${R.name}"${R.copy>1?` (copy ${R.copy})`:""} collide in the assembly. Check their edges and where they are placed.`);if(L.length>5&&u.push(`${L.length-5} more pairs of parts collide in the assembly.`),d.length&&m.length){let w=[...new Set(m.map(R=>`"${R.name}"`))];u.push(`${w.length===1?"Part":"Parts"} ${w.slice(0,5).join(", ")}${w.length>5?` and ${w.length-5} more`:""} ${w.length===1?"has":"have"} no at or rotate, so ${w.length===1?"it lies":"they lie"} flat beside the assembly.`),d.push(...ds(d,m))}let A=0;for(let w of y){let R=0;for(let W of w.layers.values()){for(let ie of W.regions)R+=ie.length;for(let ie of W.lines)R+=ie.length}A+=R*w.info.qty}if(A>i.maxOutputPoints)throw new O(`The files would have ${A} points, more than the limit of ${i.maxOutputPoints}. Use fewer copies or simpler shapes.`);let E=e.sheet??a("$sheet");if(!Array.isArray(E)||!(Number.isFinite(E[0])&&E[0]>0)||!(Number.isFinite(E[1])&&E[1]>0))throw new O("$sheet must be [width, height], both more than 0");let F=e.gap??ke(a("$gap")??3),k=e.margin??F;if(!(Number.isFinite(F)&&F>=0))throw new O("$gap must be a number, 0 or more");if(!(Number.isFinite(k)&&k>=0))throw new O("margin must be a number, 0 or more");let I=e.layout??(a("$layout")==="none"?"none":"pack"),B=["engrave",...[...l.keys()].filter(w=>!["engrave","score","cut","guide"].includes(w)),"score","cut","guide"].map(w=>l.get(w)).filter(Boolean),$=[],ge=[1,0,0,-1,0,0],me=w=>wn(w)??[0,0,0,0],Y=(w,R)=>Cr({layers:w,parts:[]},R).layers;if(I==="none"){let w=[];for(let ne of y)for(let oe=0;oe<ne.info.qty;oe++)w.push({part:ne.info.name,copy:oe+1,layers:Y(ne.layers,ge),rotated:!1});let R=new Map;for(let ne of w)for(let[oe,fe]of ne.layers){let Fe=R.get(oe)??{regions:[],lines:[]};for(let te of fe.regions)Fe.regions.push(te);for(let te of fe.lines)Fe.lines.push(te);R.set(oe,Fe)}let W=me(R),ie=[1,0,0,1,k-W[0],k-W[1]];for(let ne of w)ne.layers=Y(ne.layers,ie);$.push(G(w,W[2]-W[0]+2*k,W[3]-W[1]+2*k,y[0]?.info))}else{let w=new Map;for(let R of y){let W=`${R.info.material}|${R.info.thickness}`;w.set(W,[...w.get(W)??[],R])}for(let R of w.values()){let[W,ie]=E,ne=[];for(let j of R){let Te=Y(j.layers,ge),Ce=me(Te),kt=Ce[2]-Ce[0],Et=Ce[3]-Ce[1],is=!1;(kt>W-2*k||Et>ie-2*k)&&Et<=W-2*k&&kt<=ie-2*k&&(Te=Y(Te,[0,1,-1,0,0,0]),Ce=me(Te),kt=Ce[2]-Ce[0],Et=Ce[3]-Ce[1],is=!0),(kt>W-2*k||Et>ie-2*k)&&u.push(`Part "${j.info.name}" (${pt(kt)} x ${pt(Et)} mm) is bigger than the ${W} x ${ie} mm sheet.`),Te=Y(Te,[1,0,0,1,-Ce[0],-Ce[1]]);for(let en=0;en<j.info.qty;en++)ne.push({info:j.info,layers:Te,w:kt,h:Et,copy:en+1,rotated:is})}ne.sort((j,Te)=>Te.h-j.h||Te.w-j.w);let oe=[],fe=k,Fe=k,te=0,he=0,ve=0,Ee=()=>{if(oe.length&&$.length>=i.maxSheets)throw new O(`The parts need more than ${i.maxSheets} sheets, the limit. Use fewer copies or a bigger $sheet.`);oe.length&&$.push(G(oe,Math.max(he+k,1),Math.max(ve+k,1),R[0].info)),oe=[],fe=k,Fe=k,te=0,he=0,ve=0};for(let j of ne)fe>k&&fe+j.w>W-k&&(fe=k,Fe+=te+F,te=0),oe.length&&Fe+j.h>ie-k&&Ee(),oe.push({part:j.info.name,copy:j.copy,layers:Y(j.layers,[1,0,0,1,fe,Fe]),rotated:j.rotated}),he=Math.max(he,fe+j.w),ve=Math.max(ve,Fe+j.h),fe+=j.w+F,te=Math.max(te,j.h);Ee()}}function G(w,R,W,ie){let ne=pt(R),oe=pt(W);return{width:ne,height:oe,material:ie?.material??"material",thickness:ie?.thickness??0,items:w,paths:ns(w,B),svg:ss(w,ne,oe,B),dxf:Do(w,ne,oe,B)}}let q=$.length===1?$[0]:void 0,ee=q?[]:$.flatMap((w,R)=>{let W=$.slice(0,R).reduce((ie,ne)=>ie+ne.height+10,0);return w.items.map(ie=>({...ie,layers:Y(ie.layers,[1,0,0,1,0,W])}))}),Q=pt(Math.max(1,...$.map(w=>w.width))),se=pt(Math.max(1,$.reduce((w,R)=>w+R.height,0)+10*Math.max(0,$.length-1))),le=q?q.svg:ss(ee,Q,se,B),K=q?q.paths:ns(ee,B);return{sheets:$,width:q?.width??Q,height:q?.height??se,paths:K,svg:le,parts:p,assembly:d,layers:B,warnings:u,echoes:o.echoes}}function Bo(t){switch(t.kind){case"num":case"str":case"bool":return{ok:!0,value:t.value};case"unary":return t.op==="-"&&t.arg.kind==="num"?{ok:!0,value:-t.arg.value}:{ok:!1};case"list":{let e=[];for(let r of t.items){if(r.kind!=="item")return{ok:!1};let n=Bo(r.expr);if(!n.ok||typeof n.value!="number")return{ok:!1};e.push(n.value)}return{ok:!0,value:e}}default:return{ok:!1}}}function No(t){let e=Number(t.trim());return t.trim()!==""&&Number.isFinite(e)?e:void 0}function Go(t){let{program:e,comments:r}=it(t),n=r.filter(a=>a.block&&/^\[[^\]]+\]$/.test(a.text)),s=new Map(r.filter(a=>!a.block&&!a.own).map(a=>[a.line,a.text])),i=new Map(r.filter(a=>!a.block&&a.own).map(a=>[a.line,a.text])),o=[];for(let a of e.body){if(a.kind!=="assign"||/^\$f[nas]$/.test(a.name))continue;let u=Bo(a.value);if(!u.ok)continue;let l=n.filter(m=>m.line<=a.pos.line).pop()?.text.slice(1,-1).trim()??"Parameters";if(l.toLowerCase()==="hidden")continue;let f=s.get(a.pos.line),c=i.get(a.pos.line-1)??"",h=u.value,p={name:a.name,caption:c,group:l,type:typeof h=="number"||Array.isArray(h)?"number":typeof h=="boolean"?"boolean":"string",initial:h,span:a.span},d=f?/^\[(.*)\]$/.exec(f.trim()):null;if(d){let m=d[1];if(m.includes(",")||/[a-zA-Z"]/.test(m)&&!/^-?[\d.]+(:-?[\d.]+){0,2}$/.test(m))p.options=m.split(",").map(x=>{let[y,L]=x.split(":").map(E=>E.trim().replace(/^"|"$/g,"")),S=No(y),A=p.type==="number"&&S!==void 0?S:y;return{name:L??y,value:A}});else{let x=m.split(":").map(No);x.every(y=>y!==void 0)&&(x.length===1?p.max=x[0]:x.length===2?(p.min=x[0],p.max=x[1]):(p.min=x[0],p.step=x[1],p.max=x[2]))}}o.push(p)}return{parameters:o}}var ic="0.4.0",oc="0.1";
40
45
  /*! Bundled license information:
41
46
 
42
47
  opentype.js/dist/opentype.module.js: