@mylasertools/kerfscript 0.5.0 → 0.6.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/CHANGELOG.md +29 -1
- package/README.md +14 -3
- package/dist/cli.js +2869 -318
- package/dist/import/dbg.d.cts +1 -0
- package/dist/import/dbg.d.ts +1 -0
- package/dist/import/index.d.cts +16 -0
- package/dist/import/index.d.ts +16 -0
- package/dist/import/shapes.d.cts +76 -0
- package/dist/import/shapes.d.ts +76 -0
- package/dist/import/svg.d.cts +48 -0
- package/dist/import/svg.d.ts +48 -0
- package/dist/import/xml.d.cts +12 -0
- package/dist/import/xml.d.ts +12 -0
- package/dist/index.cjs +46 -12
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +46 -12
- package/dist/language.cjs +26 -26
- package/dist/language.js +26 -26
- package/dist/paths.d.cts +1 -1
- package/dist/paths.d.ts +1 -1
- package/docs/cli.md +9 -0
- package/docs/import.md +149 -0
- package/docs/javascript.md +31 -0
- package/docs/library/calibration.svg +1 -1
- package/docs/library/hanging.svg +1 -1
- package/docs/library/hinge.svg +1 -1
- package/docs/mcp.md +88 -0
- package/docs/versions.md +2 -2
- package/package.json +2 -3
package/dist/index.js
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
|
-
var Jo=Object.defineProperty;var Qo=(t,e,n)=>e in t?Jo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ea=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var b=(t,e,n)=>Qo(t,typeof e!="symbol"?e+"":e,n);var li=ea((Sd,ai)=>{ai.exports={}});var xs=Math.PI/180;function ys(t,e){let n=new Array(16).fill(0);for(let r=0;r<4;r++)for(let s=0;s<4;s++)for(let i=0;i<4;i++)n[r*4+s]+=t[r*4+i]*e[i*4+s];return n}function ur(t,e){let n=Math.cos(e*xs),r=Math.sin(e*xs);return t===0?[1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1]:t===1?[n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1]:[n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1]}var ks=t=>Math.abs(t)<1e-12?0:t;function fr(t){let[e,n,r]=t.rotate,s=ys(ur(2,r),ys(ur(1,n),ur(0,e)));return s[3]=t.at[0],s[7]=t.at[1],s[11]=t.at[2],s.map(ks)}function Es(t,e,n,r){return[t[0]*e+t[1]*n+t[2]*r+t[3],t[4]*e+t[5]*n+t[6]*r+t[7],t[8]*e+t[9]*n+t[10]*r+t[11]]}function ta(t){let[e,n,r]=[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]*n+s[2]*r),s[3],s[4],s[5],-(s[3]*e+s[4]*n+s[5]*r),s[6],s[7],s[8],-(s[6]*e+s[7]*n+s[8]*r),0,0,0,1]}function yn(t){let[e,n,r,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),n=Math.min(n,a),r=Math.max(r,o),s=Math.max(s,a);return[e,n,r,s]}function Ps(t){let[e,n,r,s]=yn(t.outline),i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let a of[e,r])for(let l of[n,s])for(let u of[0,t.thickness]){let c=Es(t.matrix,a,l,u);for(let f=0;f<3;f++)i[f]=Math.min(i[f],c[f]),o[f]=Math.max(o[f],c[f])}return[i,o]}function Ls(t,e,n=10){let r=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let[c,f]of t.map(Ps))for(let h=0;h<3;h++)r[h]=Math.min(r[h],c[h]),s[h]=Math.max(s[h],f[h]);let i=e.map(c=>yn(c.outline)),o=i.reduce((c,[f,,h])=>Math.max(c,h-f),s[0]-r[0]),a=0,l=0,u=0;return e.map((c,f)=>{let[h,p,d,g]=i[f];a>0&&a+d-h>o&&(a=0,l+=u+n,u=0);let y=[1,0,0,s[0]+n+a-h,0,1,0,r[1]+l-p,0,0,1,r[2],0,0,0,1];return a+=d-h+n,u=Math.max(u,g-p),{...c,matrix:y.map(ks)}})}var na=(t,e,n)=>[0,1,2].every(r=>t[0][r]<e[1][r]-n&&e[0][r]<t[1][r]-n),xn=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],cr=(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]],bs=(t,e,n=1)=>[t[0]+e[0]*n,t[1]+e[1]*n,t[2]+e[2]*n],bn=t=>[t[2],t[6],t[10]],Ss=t=>[t[3],t[7],t[11]],ra=(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 It(t,e,n){let r=n[0]*n[0]+n[1]*n[1],s=[];for(let i of t)for(let o=0,a=i.length-1;o<i.length;a=o++){let l=i[a],u=i[o],c=n[0]*(l[1]-e[1])-n[1]*(l[0]-e[0]),f=n[0]*(u[1]-e[1])-n[1]*(u[0]-e[0]);if(c>0==f>0)continue;let h=c/(c-f),p=l[0]+(u[0]-l[0])*h-e[0],d=l[1]+(u[1]-l[1])*h-e[1];s.push((p*n[0]+d*n[1])/r)}return s.sort((i,o)=>i-o)}function hr(t,e,n){let r=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>n&&(r+=o),t[s+1]<e[i+1]?s+=2:i+=2}return r}function Sn(t,e,n,r){let s=t+n,i=e-n;if(i<=s)return{at:[],size:0};let o=Math.max(4,Math.ceil((i-s)/r));return{at:Array.from({length:o},(a,l)=>s+(i-s)*(l+.5)/o),size:(i-s)/o}}function ws(t,e,n){let r=Es(t,e[0],e[1],e[2]),s=ra(t,n);return[[r[0],r[1]],[s[0],s[1]]]}function sa(t,e,n,r,s,i,o){let a=bn(t.matrix),l=bn(e.matrix),u=cr(a,l),c=Math.hypot(...u),f=[u[0]/c,u[1]/c,u[2]/c],h=cr(f,a),p=xn(l,h),d=Ss(t.matrix),g=xn(l,Ss(e.matrix)),y=Sn(0,t.thickness,s,i),x=0;for(let L of y.at){let w=bs(d,a,L),A=(g-xn(l,w))/p,T=(g+e.thickness-xn(l,w))/p,U=Sn(Math.min(A,T),Math.max(A,T),s,i);for(let E of U.at){let P=bs(w,h,E),[F,z]=ws(n,P,f),[R,he]=ws(r,P,f);if(x+=hr(It(t.outline,F,z),It(e.outline,R,he),s)*y.size*U.size,x>o)return!0}}return!1}function ia(t,e,n,r,s,i){let o=[0,1,2,3].flatMap(E=>[0,1,2,3].map(P=>{let F=0;for(let z=0;z<4;z++)F+=n[E*4+z]*e.matrix[z*4+P];return F})),a=o[11],l=o[11]+o[10]*e.thickness,u=Math.min(t.thickness,Math.max(a,l))-Math.max(0,Math.min(a,l));if(u<=r)return!1;let c=e.outline.map(E=>E.map(([P,F])=>[o[0]*P+o[1]*F+o[3],o[4]*P+o[5]*F+o[7]])),[f,h,p,d]=yn(t.outline),[g,y,x,L]=yn(c),w=Sn(Math.max(h,y),Math.min(d,L),r,s),A=0;for(let E of w.at)if(A+=hr(It(t.outline,[0,E],[1,0]),It(c,[0,E],[1,0]),r)*w.size*u,A>i)return!0;let T=Sn(Math.max(f,g),Math.min(p,x),r,s),U=0;for(let E of T.at)if(U+=hr(It(t.outline,[E,0],[0,1]),It(c,[E,0],[0,1]),r)*T.size*u,U>i)return!0;return!1}function Ts(t,e=1/0,n=.05,r=.25,s=1){let i=t.map(Ps),o=t.map(c=>ta(c.matrix)),a=t.map((c,f)=>f).sort((c,f)=>i[c][0][0]-i[f][0][0]),l=[],u=0;for(let c=0;c<a.length;c++)for(let f=c+1;f<a.length;f++){let h=a[c],p=a[f];if(i[p][0][0]>=i[h][1][0]-n)break;if(!na(i[h],i[p],n))continue;if(++u>e)return{found:l,complete:!1};let[d,g]=h<p?[t[h],t[p]]:[t[p],t[h]],[y,x]=h<p?[o[h],o[p]]:[o[p],o[h]];(Math.hypot(...cr(bn(d.matrix),bn(g.matrix)))<1e-9?ia(d,g,y,n,r,s):sa(d,g,y,x,n,r,s))&&l.push([d,g])}return{found:l,complete:!0}}var He=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.type==="range",it=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.type==="function",Cs=t=>typeof t=="number",Ct=(t,e)=>t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;function pr(t,e,n=0){if(!(e==null||["number","string","boolean"].includes(typeof e))){if(Array.isArray(e)&&n<32){for(let r of e)pr(t,r,n+1);return}throw new Error(`Setting "${t}" must be a number, string, boolean or list`)}}function kn(t,e){let n=[];if(t.step===0||(t.step>0?t.start>t.end:t.start<t.end))return n;let r=Math.floor((t.end-t.start)/t.step+1e-9)+1;if(r>e)throw new Error(`a range of ${r} items is more than the limit of ${e}`);for(let s=0;s<r;s++)n.push(t.start+s*t.step);return n}function Fe(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 Is=(t,e)=>He(t)&&He(e)?t.start===e.start&&t.step===e.step&&t.end===e.end:t===e;function Xt(t,e,n){if(n?.(),!Array.isArray(t)||!Array.isArray(e))return Is(t,e);let r=new Map,s=[],i=(o,a)=>{let l=r.get(o);return l?.has(a)?!0:o.length!==a.length?!1:(l||r.set(o,l=new Set),l.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]],l=o[1][o[2]++];if(n?.(),Array.isArray(a)&&Array.isArray(l)?!i(a,l):!Is(a,l))return!1}return!0}function Ne(t){return t===void 0?"undef":Array.isArray(t)?"list":He(t)?"range":it(t)?"function":typeof t}function oa(t){return t===void 0?"undef":typeof t=="string"?JSON.stringify(t):typeof t=="number"?wn(t):He(t)?`[${wn(t.start)}:${wn(t.step)}:${wn(t.end)}]`:it(t)?`function(${t.params.map(e=>e.name).join(", ")})`:String(t)}function Mt(t,e,n=!1){if(typeof t=="string"&&!n)return{text:t.length>e?t.slice(0,Math.max(e,0)):t,whole:t.length<=e};let r=[],s=0,i=u=>{r.push(u),s+=u.length},o=[],a=t;for(;;){Array.isArray(a)?(i("["),o.push([a,0])):i(oa(a));let u=!1;for(;o.length&&!u;){let c=o[o.length-1];c[1]<c[0].length?(c[1]&&i(", "),a=c[0][c[1]++],u=!0):(o.pop(),i("]"))}if(!u||s>e)break}let l=r.join("");return s>e?{text:l.slice(0,Math.max(e,0)),whole:!1}:{text:l,whole:!0}}function Ms(t,e,n){let r=[],s=0;for(let i of t){r.length&&(s+=e.length);let o=Mt(i,n-s);if(!o.whole)return;s+=o.text.length,r.push(o.text)}return r.join(e)}function vt(t){let e=Mt(t,200,!0);return e.whole?e.text:e.text+"..."}var Ve=t=>typeof t=="string"?t:vt(t);function Ee(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 wn(t){return Number.isInteger(t)?String(t):String(Number(t.toPrecision(10)))}var xt=Math.PI/180,_=(t,e,n)=>({params:t.replace("...","").split(",").map(r=>r.trim()).filter(Boolean),rest:t.endsWith("..."),order:n,run:e});function Os(t,e,n){return t.order?[]:t.params.filter((r,s)=>s<e.length&&n.has(r))}function Fs(t,e,n){if(t.rest){let i=[...e];return t.params.forEach((o,a)=>{n.has(o)&&(i[a]=n.get(o))}),i}if(!t.order)return t.params.map((i,o)=>n.has(i)?n.get(i):e[o]);let r=e.length+t.params.filter(i=>n.has(i)).length,s=t.order(r).filter(i=>!n.has(i));return t.params.map(i=>n.has(i)?n.get(i):e[s.indexOf(i)])}function dr(t,e,n,r){let s=Ms(t,e,n.maxLength);if(s===void 0)throw new Error(`${r}(): the text would be longer than the limit of ${n.maxLength} characters`);return n.step(Math.ceil(s.length/8)),s}function Y(t,e){if(typeof t!="number")throw new Error(`${e}() needs a number, got ${Ne(t)}`);return t}function je(t,e,n){if(Array.isArray(t))return t;if(He(t))return kn(t,n.maxLength);if(typeof t=="string")return[...t];throw new Error(`${e}() needs a list, got ${Ne(t)}`)}var aa=new Set(["is_num","is_string","is_bool","is_list","is_undef","is_function","type_of","ord"]);function Ds(t,e,n){if(aa.has(t))return 0;let r=0;for(let s of e)if(typeof s=="string")r+=s.length;else if(Array.isArray(s))r+=t==="len"?0:s.length;else if(He(s)&&s.step!==0){let i=Math.floor((s.end-s.start)/s.step)+1;i>0&&(r+=Math.min(i,n+1))}return r}var Ce=t=>_("x",e=>typeof e[0]=="number"?gr(t(e[0])):void 0);function gr(t){let e=Math.round(t);return Math.abs(t-e)<1e-12?e:t}function la(t){let e=Math.floor(t)>>>0||2654435769;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function As(t,e,n){let r=t.length===1&&Array.isArray(t[0])?t[0]:t;if(r.length)return e(r.map(s=>Y(s,n)))}var mr={abs:Ce(Math.abs),sign:Ce(Math.sign),floor:Ce(Math.floor),ceil:Ce(Math.ceil),round:Ce(t=>t<0?-Math.round(-t):Math.round(t)),sqrt:Ce(Math.sqrt),exp:Ce(Math.exp),ln:Ce(Math.log),log:_("x, base",(t,e)=>e.given<2?gr(Math.log10(Y(t[0],"log"))):Math.log(Y(t[0],"log"))/Math.log(Y(t[1],"log")),t=>t>=2?["base","x"]:["x","base"]),sin:Ce(t=>Math.sin(t*xt)),cos:Ce(t=>Math.cos(t*xt)),tan:Ce(t=>Math.tan(t*xt)),asin:Ce(t=>Math.asin(t)/xt),acos:Ce(t=>Math.acos(t)/xt),atan:Ce(t=>Math.atan(t)/xt),atan2:_("y, x",t=>gr(Math.atan2(Y(t[0],"atan2"),Y(t[1],"atan2"))/xt)),pow:_("x, y",t=>Math.pow(Y(t[0],"pow"),Y(t[1],"pow"))),min:_("values...",t=>As(t,e=>e.reduce((n,r)=>r<n?r:n,1/0),"min")),max:_("values...",t=>As(t,e=>e.reduce((n,r)=>r>n?r:n,-1/0),"max")),clamp:_("x, low, high",t=>Math.min(Math.max(Y(t[0],"clamp"),Y(t[1],"clamp")),Y(t[2],"clamp"))),lerp:_("a, b, t",t=>{let e=Y(t[2],"lerp");if(Array.isArray(t[0])&&Array.isArray(t[1])){let n=t[1];return t[0].map((r,s)=>Y(r,"lerp")+(Y(n[s],"lerp")-Y(r,"lerp"))*e)}return Y(t[0],"lerp")+(Y(t[1],"lerp")-Y(t[0],"lerp"))*e}),norm:_("v",(t,e)=>Math.sqrt(je(t[0],"norm",e).reduce((n,r)=>n+Y(r,"norm")**2,0))),cross:_("a, b",(t,e)=>{let n=je(t[0],"cross",e).map(s=>Y(s,"cross")),r=je(t[1],"cross",e).map(s=>Y(s,"cross"));return n.length===2?n[0]*r[1]-n[1]*r[0]:[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]]}),len:_("value",t=>typeof t[0]=="string"?[...t[0]].length:Array.isArray(t[0])?t[0].length:void 0),concat:_("...",(t,e)=>{let n=t.reduce((r,s)=>r+(Array.isArray(s)?s.length:1),0);if(n>e.maxLength)throw new Error(`concat(): a list of ${n} items is more than the limit of ${e.maxLength}`);return t.flatMap(r=>Array.isArray(r)?r:[r])}),reverse:_("value",(t,e)=>typeof t[0]=="string"?[...t[0]].reverse().join(""):[...je(t[0],"reverse",e)].reverse()),sum:_("values",(t,e)=>je(t[0],"sum",e).reduce((n,r)=>n+Y(r,"sum"),0)),slice:_("value, start, end",(t,e)=>{let r=(typeof t[0]=="string"?[...t[0]]:je(t[0],"slice",e)).slice(Y(t[1]??0,"slice"),t[2]===void 0?void 0:Y(t[2],"slice"));return typeof t[0]=="string"?r.join(""):r}),str:_("...",(t,e)=>dr(t,"",e,"str")),chr:_("...",t=>t.flatMap(e=>Array.isArray(e)?e:[e]).map(e=>String.fromCodePoint(Y(e,"chr"))).join("")),ord:_("text",t=>typeof t[0]=="string"&&t[0].length?t[0].codePointAt(0):void 0),upper:_("text",t=>typeof t[0]=="string"?t[0].toUpperCase():void 0),lower:_("text",t=>typeof t[0]=="string"?t[0].toLowerCase():void 0),split:_("text, separator",t=>typeof t[0]=="string"?t[0].split(typeof t[1]=="string"?t[1]:" "):void 0),join:_("values, separator",(t,e)=>dr(je(t[0],"join",e),typeof t[1]=="string"?t[1]:"",e,"join")),search:_("value, list",(t,e)=>{let r=(typeof t[1]=="string"?[...t[1]]:je(t[1],"search",e)).findIndex(s=>Xt(s,t[0],e.step));return r<0?void 0:r}),contains:_("value, item",(t,e)=>typeof t[0]=="string"?t[0].includes(dr([t[1]],"",e,"contains")):je(t[0],"contains",e).some(n=>Xt(n,t[1],e.step))),lookup:_("x, table",(t,e)=>{let n=Y(t[0],"lookup"),r=je(t[1],"lookup",e);if(!r.length)return;let s=r.map(i=>[Y(i[0],"lookup"),Y(i[1],"lookup")]).sort((i,o)=>i[0]-o[0]);if(n<=s[0][0])return s[0][1];for(let i=1;i<s.length;i++)if(n<=s[i][0]){let[o,a]=s[i-1],[l,u]=s[i];return a+(n-o)/(l-o)*(u-a)}return s[s.length-1][1]}),rands:_("min, max, count, seed",t=>{let e=Y(t[0],"rands"),n=Y(t[1],"rands"),r=Y(t[2],"rands"),s=la(t[3]===void 0?1:Y(t[3],"rands"));return Array.from({length:Math.min(Math.max(0,Math.floor(r)),1e6)},()=>e+(n-e)*s())}),is_num:_("value",t=>Cs(t[0])&&!Number.isNaN(t[0])),is_string:_("value",t=>typeof t[0]=="string"),is_bool:_("value",t=>typeof t[0]=="boolean"),is_list:_("value",t=>Array.isArray(t[0])),is_undef:_("value",t=>t[0]===void 0),is_function:_("value",t=>it(t[0])),type_of:_("value",t=>Ne(t[0]))};var ee;(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"})(ee||(ee={}));var ke;(function(t){t[t.Subject=0]="Subject",t[t.Clip=1]="Clip"})(ke||(ke={}));var X;(function(t){t[t.EvenOdd=0]="EvenOdd",t[t.NonZero=1]="NonZero",t[t.Positive=2]="Positive",t[t.Negative=3]="Negative"})(X||(X={}));var q;(function(t){t[t.IsOn=0]="IsOn",t[t.IsInside=1]="IsInside",t[t.IsOutside=2]="IsOutside"})(q||(q={}));var At=Number.MAX_SAFE_INTEGER,me=Math.floor(Math.sqrt(At));function En(t,e){return!Number.isSafeInteger(t)||!Number.isSafeInteger(e)?!1:t===0||e===0?!0:Math.abs(t)<=At/Math.abs(e)}function Rs(t,e){return Math.abs(t)+Math.abs(e)<=At}function vr(t,e,n,r){if(En(t,e)&&En(n,r)){let s=t*e,i=n*r;if(Rs(s,i))return s-i}return Number.isSafeInteger(t)&&Number.isSafeInteger(e)&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)?Number(BigInt(t)*BigInt(e)-BigInt(n)*BigInt(r)):t*e-n*r}function xr(t,e,n,r){if(En(t,e)&&En(n,r)){let s=t*e,i=n*r;if(Rs(s,i))return s+i}return Number.isSafeInteger(t)&&Number.isSafeInteger(e)&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)?Number(BigInt(t)*BigInt(e)+BigInt(n)*BigInt(r)):t*e+n*r}var yr=BigInt(0),Pn=BigInt(2),ua=BigInt(4),ca=BigInt(64),ha=BigInt("0xFFFFFFFFFFFFFFFF"),wr=BigInt("9223372036854775807"),qt=Number(wr/ua),Us=Number(wr),Ns=1e-12,fa=.1,br=Math.floor(me/2),pa=Math.floor(Math.sqrt(Math.sqrt(At/4)));function da(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:At/e}function ga(t,e,n){if(!Number.isFinite(t)||Math.abs(t)>e)throw new RangeError(`Scaled coordinate exceeds Number.MAX_SAFE_INTEGER in ${n}`)}function ma(t,e){if(!Number.isFinite(t)||Math.abs(t)>At)throw new RangeError(`Coordinate exceeds Number.MAX_SAFE_INTEGER in ${e}`)}function va(t,e,n){let r=e.x-t.x,s=n.y-e.y,i=e.y-t.y,o=n.x-e.x;return Math.abs(r)<me&&Math.abs(s)<me&&Math.abs(i)<me&&Math.abs(o)<me?r*s-i*o:vr(r,s,i,o)}function Be(t,e,n){let r=e.x-t.x,s=n.y-e.y,i=e.y-t.y,o=n.x-e.x;if(Math.abs(r)<me&&Math.abs(s)<me&&Math.abs(i)<me&&Math.abs(o)<me){let u=r*s,c=i*o;return u>c?1:u<c?-1:0}if(!Number.isSafeInteger(r)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)){let u=r*s,c=i*o;return u>c?1:u<c?-1:0}let a=BigInt(r)*BigInt(s),l=BigInt(i)*BigInt(o);return a===l?0:a>l?1:-1}function xa(t){if(t<-8||t>8)throw new Error("Error: Precision is out of range.")}function ya(t){return Math.abs(t)<=Ns}function ba(t){return t<0?-1:t>0?1:0}function Sa(t,e){let n=BigInt(t),r=BigInt(e),s=n*r;return{lo64:s&ha,hi64:s>>ca}}function Bs(t,e,n,r){let s=Math.abs(t),i=Math.abs(e),o=Math.abs(n),a=Math.abs(r);if(s<me&&i<me&&o<me&&a<me)return t*e===n*r;let l=(t<0?-1:t>0?1:0)*(e<0?-1:e>0?1:0),u=(n<0?-1:n>0?1:0)*(r<0?-1:r>0?1:0);if(l!==u)return!1;if(l===0)return!0;if(!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)||!Number.isSafeInteger(a))return t*e===n*r;let c=BigInt(s),f=BigInt(i),h=BigInt(o),p=BigInt(a);return c*f===h*p}function wa(t,e,n){let r=e.x-t.x,s=n.y-e.y,i=e.y-t.y,o=n.x-e.x;return Bs(r,s,i,o)}function ka(t,e,n){let r=e.x-t.x,s=n.x-e.x,i=e.y-t.y,o=n.y-e.y;return Math.abs(r)<me&&Math.abs(s)<me&&Math.abs(i)<me&&Math.abs(o)<me?r*s+i*o:xr(r,s,i,o)}function Ea(t,e,n){let r=e.x-t.x,s=n.x-e.x,i=e.y-t.y,o=n.y-e.y;if(Math.abs(r)<me&&Math.abs(s)<me&&Math.abs(i)<me&&Math.abs(o)<me){let l=r*s+i*o;return l>0?1:l<0?-1:0}if(!Number.isSafeInteger(r)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)){let l=r*s+i*o;return l>0?1:l<0?-1:0}let a=BigInt(r)*BigInt(s)+BigInt(i)*BigInt(o);return a===yr?0:a>yr?1:-1}function Pa(t){let e=t.length;if(e<3)return 0;let n=!0;for(let i=0;i<e&&n;i++){let o=t[i];(Math.abs(o.x)>=br||Math.abs(o.y)>=br)&&(n=!1)}let r=t[e-1];if(n){let i=0;for(let o of t)i+=(r.y+o.y)*(r.x-o.x),r=o;return i*.5}let s=yr;for(let i of t){let o=r.y+i.y,a=r.x-i.x;if(Number.isSafeInteger(o)&&Number.isSafeInteger(a))s+=BigInt(o)*BigInt(a);else if(Number.isSafeInteger(r.y)&&Number.isSafeInteger(i.y)&&Number.isSafeInteger(r.x)&&Number.isSafeInteger(i.x)){let l=BigInt(r.y)+BigInt(i.y),u=BigInt(r.x)-BigInt(i.x);s+=l*u}else s+=BigInt(Math.round(o*a));r=i}return Number(s)*.5}function La(t,e){return t.y*e.x-e.y*t.x}function Ta(t,e){return t.x*e.x+t.y*e.y}function Ia(t){let e=Math.round(t);return t===e-.5&&(e&1)!==0?e-1:e}function Ca(t){return t>=qt||t<=-qt?Us:Math.round(t)}function Ma(t,e,n,r){let s=e.y-t.y,i=e.x-t.x,o=r.y-n.y,a=r.x-n.x,l=vr(s,a,o,i);if(l===0)return null;let u=vr(t.x-n.x,o,t.y-n.y,a)/l;return u<=0?{x:t.x,y:t.y,z:t.z||0}:u>=1?{x:e.x,y:e.y,z:e.z||0}:{x:Math.trunc(t.x+u*i),y:Math.trunc(t.y+u*s),z:0}}function Aa(t,e,n,r){let s=e.y-t.y,i=e.x-t.x,o=r.y-n.y,a=r.x-n.x,l=s*a-o*i;if(l===0)return{success:!1,ip:{x:0,y:0,z:0}};let u=((t.x-n.x)*o-(t.y-n.y)*a)/l,c;return u<=0?c={...t,z:0}:u>=1?c={...e,z:0}:c={x:t.x+u*i,y:t.y+u*s,z:0},{success:!0,ip:c}}function Oa(t,e,n,r,s=!1){if(!s){let u=Be(t,n,r),c=Be(e,n,r),f=Be(n,t,e),h=Be(r,t,e);return u!==0&&c!==0&&u!==c&&f!==0&&h!==0&&f!==h}let i=Be(t,n,r),o=Be(e,n,r);if(i!==0&&i===o)return!1;let a=Be(n,t,e),l=Be(r,t,e);return a!==0&&a===l?!1:i!==0||o!==0||a!==0||l!==0}function Gs(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 n of t)n.x<e.left&&(e.left=n.x),n.x>e.right&&(e.right=n.x),n.y<e.top&&(e.top=n.y),n.y>e.bottom&&(e.bottom=n.y);return e.left===Number.MAX_SAFE_INTEGER?{left:0,top:0,right:0,bottom:0}:e}function Fa(t,e,n){if(e.x===n.x&&e.y===n.y)return{x:e.x,y:e.y,z:0};let r=n.x-e.x,s=n.y-e.y,i=xr(t.x-e.x,r,t.y-e.y,s)/xr(r,r,s,s),o=i<0?0:i>1?1:i;return{x:Math.round(e.x+o*r),y:Math.round(e.y+o*s),z:0}}function Sr(t,e){let n=e.length,r=0;if(n<3)return q.IsOutside;for(;r<n&&e[r].y===t.y;)r++;if(r===n)return q.IsOutside;let s=e[r].y<t.y,i=s,o=0,a=r+1,l=n;for(;;){if(a===l){if(l===0||r===0)break;l=r,a=0}if(s)for(;a<l&&e[a].y<t.y;)a++;else for(;a<l&&e[a].y>t.y;)a++;if(a===l)continue;let c=e[a],f=a>0?e[a-1]:e[n-1];if(c.y===t.y){if(c.x===t.x||c.y===f.y&&t.x<f.x!=t.x<c.x)return q.IsOn;if(a++,a===r)break;continue}if(!(t.x<c.x&&t.x<f.x))if(t.x>f.x&&t.x>c.x)o=1-o;else{let h=Be(f,c,t);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===n&&(a=0);let u=a===0?Be(e[n-1],e[0],t):Be(e[a-1],e[a],t);return u===0?q.IsOn:(u<0===s&&(o=1-o),o===0?q.IsOutside:q.IsInside)}function Da(t,e){let n=q.IsOn;for(let a of t)switch(Sr(a,e)){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}let r=Gs(t),s,i;return Number.isSafeInteger(r.left)&&Number.isSafeInteger(r.right)&&Math.abs(r.left)+Math.abs(r.right)>Number.MAX_SAFE_INTEGER?(s=Number((BigInt(r.left)+BigInt(r.right))/Pn),i=Number((BigInt(r.top)+BigInt(r.bottom))/Pn)):(s=Math.round((r.left+r.right)/2),i=Math.round((r.top+r.bottom)/2)),Sr({x:s,y:i},e)!==q.IsOutside}var H={MaxInt64:wr,MaxCoord:qt,max_coord:qt,min_coord:-qt,Invalid64:Us,floatingPointTolerance:Ns,defaultMinimumEdgeLength:fa,maxCoordForSafeAreaProduct:br,maxCoordForSafeCrossSq:pa,maxSafeCoordinateForScale:da,checkSafeScaleValue:ga,ensureSafeInteger:ma,crossProduct:va,crossProductSign:Be,checkPrecision:xa,isAlmostZero:ya,triSign:ba,multiplyUInt64:Sa,productsAreEqual:Bs,isCollinear:wa,dotProduct:ka,dotProductSign:Ea,area:Pa,crossProductD:La,dotProductD:Ta,roundToEven:Ia,checkCastInt64:Ca,getLineIntersectPt:Ma,getLineIntersectPtD:Aa,segsIntersect:Oa,getBounds:Gs,getClosestPtOnSegment:Fa,pointInPolygon:Sr,path2ContainsPath1:Da},Ye={create(t=0,e=0,n=0){return{x:Math.round(t),y:Math.round(e),z:n}},fromPointD(t){return H.ensureSafeInteger(t.x,"Point64Utils.fromPointD"),H.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 n=t.x+e.x,r=t.y+e.y;return Number.isSafeInteger(n)&&Number.isSafeInteger(r)?{x:n,y:r,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} `}},Ln={create(t=0,e=0,n=0){return{x:t,y:e,z:n}},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 H.isAlmostZero(t.x-e.x)&&H.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)}`}},yt={create(t=0,e=0,n=0,r=0){return{left:t,top:e,right:n,bottom:r}},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))/Pn),n=Number((BigInt(t.top)+BigInt(t.bottom))/Pn);return{x:e,y:n}}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}]}},kr={create(t=0,e=0,n=0,r=0){return{left:t,top:e,right:n,bottom:r}},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 zs=Object.freeze(yt.createInvalid()),Hs=Object.freeze(kr.createInvalid());var Wt=BigInt(0),Ra=BigInt(2),Vs=BigInt(4),K;(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"})(K||(K={}));var Er=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],n=this.data.pop();return this.data.length>0&&(this.data[0]=n,this.siftDown(0)),e}clear(){this.data.length=0}siftUp(e){let n=this.data[e];for(;e>0;){let r=e-1>>1;if(this.data[r]>=n)break;this.data[e]=this.data[r],e=r}this.data[e]=n}siftDown(e){let n=this.data.length,r=this.data[e];for(;;){let s=(e<<1)+1;if(s>=n)break;let i=s+1,o=s;if(i<n&&this.data[i]>this.data[s]&&(o=i),this.data[o]<=r)break;this.data[e]=this.data[o],e=o}this.data[e]=r}},_t=class{constructor(e,n,r){b(this,"pt");b(this,"next",null);b(this,"prev",null);b(this,"flags");this.pt=e,this.flags=n,this.prev=r}},Zt=class{constructor(e,n,r=!1){b(this,"vertex");b(this,"polytype");b(this,"isOpen");this.vertex=e,this.polytype=n,this.isOpen=r}equals(e){return e!==null&&this.vertex===e.vertex}};function $s(t,e,n){return{pt:t,edge1:e,edge2:n}}var tt=class{constructor(e,n){b(this,"pt");b(this,"next");b(this,"prev");b(this,"outrec");b(this,"horz");this.pt=e,this.outrec=n,this.next=this,this.prev=this,this.horz=null}},Le;(function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Right=2]="Right"})(Le||(Le={}));var Pr;(function(t){t[t.Bottom=0]="Bottom",t[t.Middle=1]="Middle",t[t.Top=2]="Top"})(Pr||(Pr={}));var Tn=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)}},In=class{constructor(e){b(this,"leftOp");b(this,"rightOp");b(this,"leftToRight");this.leftOp=e,this.rightOp=null,this.leftToRight=!0}},jt=class{constructor(e,n){b(this,"op1");b(this,"op2");this.op1=e,this.op2=n}};function Ua(t,e){return t.rightOp===null?e.rightOp===null?0:1:e.rightOp===null?-1:t.leftOp.pt.x-e.leftOp.pt.x}function Na(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 Yt=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",Le.None)}},Ot={addLocMin(t,e,n,r){if((t.flags&K.LocalMin)!==K.None)return;t.flags|=K.LocalMin;let s=new Zt(t,e,n);r.push(s)},addPathsToVertexList(t,e,n,r,s){for(let i=0,o=t.length;i<o;i++){let a=t[i],l=null,u=null,c=null;for(let d=0,g=a.length;d<g;d++){let y=a[d];if(l===null)l=new _t(y,K.None,null),s.push(l),u=l,c=y;else if(!(c.x===y.x&&c.y===y.y)){let x=new _t(y,K.None,u);u.next=x,u=x,c=y}}if(u?.prev==null||(!n&&u.pt.x===l.pt.x&&u.pt.y===l.pt.y&&(u=u.prev),u.next=l,l.prev=u,!n&&u.next===u))continue;let f;if(n){let d=l.next;for(;d!==l&&d.pt.y===l.pt.y;)d=d.next;f=d.pt.y<=l.pt.y,f?(l.flags=K.OpenStart,Ot.addLocMin(l,e,!0,r)):l.flags=K.OpenStart|K.LocalMax}else{for(u=l.prev;u!==l&&u.pt.y===l.pt.y;)u=u.prev;if(u===l)continue;f=u.pt.y>l.pt.y}let h=f;u=l;let p=l.next;for(;p!==l;)p.pt.y>u.pt.y&&f?(u.flags|=K.LocalMax,f=!1):p.pt.y<u.pt.y&&!f&&(f=!0,Ot.addLocMin(u,e,n,r)),u=p,p=p.next;n?(u.flags|=K.OpenEnd,f?u.flags|=K.LocalMax:Ot.addLocMin(u,e,n,r)):f!==h&&(h?Ot.addLocMin(u,e,!1,r):u.flags|=K.LocalMax)}}};var Cn=class{constructor(e=null){b(this,"parent");b(this,"children",[]);this.parent=e}get isHole(){return this.getIsHole()}getLevel(){let e=0,n=this.parent;for(;n!==null;)++e,n=n.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,n){let r="",s=" ".repeat(n),i=this.children.length===1?"":"s";(n&1)===0?r+=`${s}+- hole (${e}) contains ${this.children.length} nested polygon${i}.
|
|
2
|
+
var El=Object.defineProperty;var Ll=(t,e,n)=>e in t?El(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Tl=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var R=(t,e,n)=>Ll(t,typeof e!="symbol"?e+"":e,n);var bo=Tl((wg,vo)=>{vo.exports={}});var Oi=Math.PI/180;function Fi(t,e){let n=new Array(16).fill(0);for(let r=0;r<4;r++)for(let s=0;s<4;s++)for(let i=0;i<4;i++)n[r*4+s]+=t[r*4+i]*e[i*4+s];return n}function ps(t,e){let n=Math.cos(e*Oi),r=Math.sin(e*Oi);return t===0?[1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1]:t===1?[n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1]:[n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1]}var Ni=t=>Math.abs(t)<1e-12?0:t;function ms(t){let[e,n,r]=t.rotate,s=Fi(ps(2,r),Fi(ps(1,n),ps(0,e)));return s[3]=t.at[0],s[7]=t.at[1],s[11]=t.at[2],s.map(Ni)}function Bi(t,e,n,r){return[t[0]*e+t[1]*n+t[2]*r+t[3],t[4]*e+t[5]*n+t[6]*r+t[7],t[8]*e+t[9]*n+t[10]*r+t[11]]}function Il(t){let[e,n,r]=[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]*n+s[2]*r),s[3],s[4],s[5],-(s[3]*e+s[4]*n+s[5]*r),s[6],s[7],s[8],-(s[6]*e+s[7]*n+s[8]*r),0,0,0,1]}function vr(t){let[e,n,r,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),n=Math.min(n,a),r=Math.max(r,o),s=Math.max(s,a);return[e,n,r,s]}function $i(t){let[e,n,r,s]=vr(t.outline),i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let a of[e,r])for(let l of[n,s])for(let u of[0,t.thickness]){let c=Bi(t.matrix,a,l,u);for(let f=0;f<3;f++)i[f]=Math.min(i[f],c[f]),o[f]=Math.max(o[f],c[f])}return[i,o]}function Gi(t,e,n=10){let r=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let[c,f]of t.map($i))for(let h=0;h<3;h++)r[h]=Math.min(r[h],c[h]),s[h]=Math.max(s[h],f[h]);let i=e.map(c=>vr(c.outline)),o=i.reduce((c,[f,,h])=>Math.max(c,h-f),s[0]-r[0]),a=0,l=0,u=0;return e.map((c,f)=>{let[h,p,d,g]=i[f];a>0&&a+d-h>o&&(a=0,l+=u+n,u=0);let m=[1,0,0,s[0]+n+a-h,0,1,0,r[1]+l-p,0,0,1,r[2],0,0,0,1];return a+=d-h+n,u=Math.max(u,g-p),{...c,matrix:m.map(Ni)}})}var Cl=(t,e,n)=>[0,1,2].every(r=>t[0][r]<e[1][r]-n&&e[0][r]<t[1][r]-n),yr=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],ds=(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]],Di=(t,e,n=1)=>[t[0]+e[0]*n,t[1]+e[1]*n,t[2]+e[2]*n],br=t=>[t[2],t[6],t[10]],Ri=t=>[t[3],t[7],t[11]],Al=(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 gn(t,e,n){let r=n[0]*n[0]+n[1]*n[1],s=[];for(let i of t)for(let o=0,a=i.length-1;o<i.length;a=o++){let l=i[a],u=i[o],c=n[0]*(l[1]-e[1])-n[1]*(l[0]-e[0]),f=n[0]*(u[1]-e[1])-n[1]*(u[0]-e[0]);if(c>0==f>0)continue;let h=c/(c-f),p=l[0]+(u[0]-l[0])*h-e[0],d=l[1]+(u[1]-l[1])*h-e[1];s.push((p*n[0]+d*n[1])/r)}return s.sort((i,o)=>i-o)}function gs(t,e,n){let r=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>n&&(r+=o),t[s+1]<e[i+1]?s+=2:i+=2}return r}function wr(t,e,n,r){let s=t+n,i=e-n;if(i<=s)return{at:[],size:0};let o=Math.max(4,Math.ceil((i-s)/r));return{at:Array.from({length:o},(a,l)=>s+(i-s)*(l+.5)/o),size:(i-s)/o}}function Ui(t,e,n){let r=Bi(t,e[0],e[1],e[2]),s=Al(t,n);return[[r[0],r[1]],[s[0],s[1]]]}function Ol(t,e,n,r,s,i,o){let a=br(t.matrix),l=br(e.matrix),u=ds(a,l),c=Math.hypot(...u),f=[u[0]/c,u[1]/c,u[2]/c],h=ds(f,a),p=yr(l,h),d=Ri(t.matrix),g=yr(l,Ri(e.matrix)),m=wr(0,t.thickness,s,i),x=0;for(let w of m.at){let v=Di(d,a,w),T=(g-yr(l,v))/p,P=(g+e.thickness-yr(l,v))/p,O=wr(Math.min(T,P),Math.max(T,P),s,i);for(let C of O.at){let L=Di(v,h,C),[B,A]=Ui(n,L,f),[F,te]=Ui(r,L,f);if(x+=gs(gn(t.outline,B,A),gn(e.outline,F,te),s)*m.size*O.size,x>o)return!0}}return!1}function Fl(t,e,n,r,s,i){let o=[0,1,2,3].flatMap(C=>[0,1,2,3].map(L=>{let B=0;for(let A=0;A<4;A++)B+=n[C*4+A]*e.matrix[A*4+L];return B})),a=o[11],l=o[11]+o[10]*e.thickness,u=Math.min(t.thickness,Math.max(a,l))-Math.max(0,Math.min(a,l));if(u<=r)return!1;let c=e.outline.map(C=>C.map(([L,B])=>[o[0]*L+o[1]*B+o[3],o[4]*L+o[5]*B+o[7]])),[f,h,p,d]=vr(t.outline),[g,m,x,w]=vr(c),v=wr(Math.max(h,m),Math.min(d,w),r,s),T=0;for(let C of v.at)if(T+=gs(gn(t.outline,[0,C],[1,0]),gn(c,[0,C],[1,0]),r)*v.size*u,T>i)return!0;let P=wr(Math.max(f,g),Math.min(p,x),r,s),O=0;for(let C of P.at)if(O+=gs(gn(t.outline,[C,0],[0,1]),gn(c,[C,0],[0,1]),r)*P.size*u,O>i)return!0;return!1}function zi(t,e=1/0,n=.05,r=.25,s=1){let i=t.map($i),o=t.map(c=>Il(c.matrix)),a=t.map((c,f)=>f).sort((c,f)=>i[c][0][0]-i[f][0][0]),l=[],u=0;for(let c=0;c<a.length;c++)for(let f=c+1;f<a.length;f++){let h=a[c],p=a[f];if(i[p][0][0]>=i[h][1][0]-n)break;if(!Cl(i[h],i[p],n))continue;if(++u>e)return{found:l,complete:!1};let[d,g]=h<p?[t[h],t[p]]:[t[p],t[h]],[m,x]=h<p?[o[h],o[p]]:[o[p],o[h]];(Math.hypot(...ds(br(d.matrix),br(g.matrix)))<1e-9?Fl(d,g,m,n,r,s):Ol(d,g,m,x,n,r,s))&&l.push([d,g])}return{found:l,complete:!0}}var pt=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.type==="range",zt=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.type==="function",Vi=t=>typeof t=="number",mn=(t,e)=>t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;function xs(t,e,n=0){if(!(e==null||["number","string","boolean"].includes(typeof e))){if(Array.isArray(e)&&n<32){for(let r of e)xs(t,r,n+1);return}throw new Error(`Setting "${t}" must be a number, string, boolean or list`)}}function kr(t,e){let n=[];if(t.step===0||(t.step>0?t.start>t.end:t.start<t.end))return n;let r=Math.floor((t.end-t.start)/t.step+1e-9)+1;if(r>e)throw new Error(`a range of ${r} items is more than the limit of ${e}`);for(let s=0;s<r;s++)n.push(t.start+s*t.step);return n}function rt(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 Hi=(t,e)=>pt(t)&&pt(e)?t.start===e.start&&t.step===e.step&&t.end===e.end:t===e;function Nn(t,e,n){if(n?.(),!Array.isArray(t)||!Array.isArray(e))return Hi(t,e);let r=new Map,s=[],i=(o,a)=>{let l=r.get(o);return l?.has(a)?!0:o.length!==a.length?!1:(l||r.set(o,l=new Set),l.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]],l=o[1][o[2]++];if(n?.(),Array.isArray(a)&&Array.isArray(l)?!i(a,l):!Hi(a,l))return!1}return!0}function at(t){return t===void 0?"undef":Array.isArray(t)?"list":pt(t)?"range":zt(t)?"function":typeof t}function Dl(t){return t===void 0?"undef":typeof t=="string"?JSON.stringify(t):typeof t=="number"?Sr(t):pt(t)?`[${Sr(t.start)}:${Sr(t.step)}:${Sr(t.end)}]`:zt(t)?`function(${t.params.map(e=>e.name).join(", ")})`:String(t)}function xn(t,e,n=!1){if(typeof t=="string"&&!n)return{text:t.length>e?t.slice(0,Math.max(e,0)):t,whole:t.length<=e};let r=[],s=0,i=u=>{r.push(u),s+=u.length},o=[],a=t;for(;;){Array.isArray(a)?(i("["),o.push([a,0])):i(Dl(a));let u=!1;for(;o.length&&!u;){let c=o[o.length-1];c[1]<c[0].length?(c[1]&&i(", "),a=c[0][c[1]++],u=!0):(o.pop(),i("]"))}if(!u||s>e)break}let l=r.join("");return s>e?{text:l.slice(0,Math.max(e,0)),whole:!1}:{text:l,whole:!0}}function Xi(t,e,n){let r=[],s=0;for(let i of t){r.length&&(s+=e.length);let o=xn(i,n-s);if(!o.whole)return;s+=o.text.length,r.push(o.text)}return r.join(e)}function Jt(t){let e=xn(t,200,!0);return e.whole?e.text:e.text+"..."}var dt=t=>typeof t=="string"?t:Jt(t);function je(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 Sr(t){return Number.isInteger(t)?String(t):String(Number(t.toPrecision(10)))}var Qt=Math.PI/180,Pe=(t,e,n)=>({params:t.replace("...","").split(",").map(r=>r.trim()).filter(Boolean),rest:t.endsWith("..."),order:n,run:e});function Wi(t,e,n){return t.order?[]:t.params.filter((r,s)=>s<e.length&&n.has(r))}function _i(t,e,n){if(t.rest){let i=[...e];return t.params.forEach((o,a)=>{n.has(o)&&(i[a]=n.get(o))}),i}if(!t.order)return t.params.map((i,o)=>n.has(i)?n.get(i):e[o]);let r=e.length+t.params.filter(i=>n.has(i)).length,s=t.order(r).filter(i=>!n.has(i));return t.params.map(i=>n.has(i)?n.get(i):e[s.indexOf(i)])}function ys(t,e,n,r){let s=Xi(t,e,n.maxLength);if(s===void 0)throw new Error(`${r}(): the text would be longer than the limit of ${n.maxLength} characters`);return n.step(Math.ceil(s.length/8)),s}function Ee(t,e){if(typeof t!="number")throw new Error(`${e}() needs a number, got ${at(t)}`);return t}function Mt(t,e,n){if(Array.isArray(t))return t;if(pt(t))return kr(t,n.maxLength);if(typeof t=="string")return[...t];throw new Error(`${e}() needs a list, got ${at(t)}`)}var Rl=new Set(["is_num","is_string","is_bool","is_list","is_undef","is_function","type_of","ord"]);function ji(t,e,n){if(Rl.has(t))return 0;let r=0;for(let s of e)if(typeof s=="string")r+=s.length;else if(Array.isArray(s))r+=t==="len"?0:s.length;else if(pt(s)&&s.step!==0){let i=Math.floor((s.end-s.start)/s.step)+1;i>0&&(r+=Math.min(i,n+1))}return r}var tt=t=>Pe("x",e=>typeof e[0]=="number"?vs(t(e[0])):void 0);function vs(t){let e=Math.round(t);return Math.abs(t-e)<1e-12?e:t}function Ul(t){let e=Math.floor(t)>>>0||2654435769;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function qi(t,e,n){let r=t.length===1&&Array.isArray(t[0])?t[0]:t;if(r.length)return e(r.map(s=>Ee(s,n)))}var bs={abs:tt(Math.abs),sign:tt(Math.sign),floor:tt(Math.floor),ceil:tt(Math.ceil),round:tt(t=>t<0?-Math.round(-t):Math.round(t)),sqrt:tt(Math.sqrt),exp:tt(Math.exp),ln:tt(Math.log),log:Pe("x, base",(t,e)=>e.given<2?vs(Math.log10(Ee(t[0],"log"))):Math.log(Ee(t[0],"log"))/Math.log(Ee(t[1],"log")),t=>t>=2?["base","x"]:["x","base"]),sin:tt(t=>Math.sin(t*Qt)),cos:tt(t=>Math.cos(t*Qt)),tan:tt(t=>Math.tan(t*Qt)),asin:tt(t=>Math.asin(t)/Qt),acos:tt(t=>Math.acos(t)/Qt),atan:tt(t=>Math.atan(t)/Qt),atan2:Pe("y, x",t=>vs(Math.atan2(Ee(t[0],"atan2"),Ee(t[1],"atan2"))/Qt)),pow:Pe("x, y",t=>Math.pow(Ee(t[0],"pow"),Ee(t[1],"pow"))),min:Pe("values...",t=>qi(t,e=>e.reduce((n,r)=>r<n?r:n,1/0),"min")),max:Pe("values...",t=>qi(t,e=>e.reduce((n,r)=>r>n?r:n,-1/0),"max")),clamp:Pe("x, low, high",t=>Math.min(Math.max(Ee(t[0],"clamp"),Ee(t[1],"clamp")),Ee(t[2],"clamp"))),lerp:Pe("a, b, t",t=>{let e=Ee(t[2],"lerp");if(Array.isArray(t[0])&&Array.isArray(t[1])){let n=t[1];return t[0].map((r,s)=>Ee(r,"lerp")+(Ee(n[s],"lerp")-Ee(r,"lerp"))*e)}return Ee(t[0],"lerp")+(Ee(t[1],"lerp")-Ee(t[0],"lerp"))*e}),norm:Pe("v",(t,e)=>Math.sqrt(Mt(t[0],"norm",e).reduce((n,r)=>n+Ee(r,"norm")**2,0))),cross:Pe("a, b",(t,e)=>{let n=Mt(t[0],"cross",e).map(s=>Ee(s,"cross")),r=Mt(t[1],"cross",e).map(s=>Ee(s,"cross"));return n.length===2?n[0]*r[1]-n[1]*r[0]:[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]]}),len:Pe("value",t=>typeof t[0]=="string"?[...t[0]].length:Array.isArray(t[0])?t[0].length:void 0),concat:Pe("...",(t,e)=>{let n=t.reduce((r,s)=>r+(Array.isArray(s)?s.length:1),0);if(n>e.maxLength)throw new Error(`concat(): a list of ${n} items is more than the limit of ${e.maxLength}`);return t.flatMap(r=>Array.isArray(r)?r:[r])}),reverse:Pe("value",(t,e)=>typeof t[0]=="string"?[...t[0]].reverse().join(""):[...Mt(t[0],"reverse",e)].reverse()),sum:Pe("values",(t,e)=>Mt(t[0],"sum",e).reduce((n,r)=>n+Ee(r,"sum"),0)),slice:Pe("value, start, end",(t,e)=>{let r=(typeof t[0]=="string"?[...t[0]]:Mt(t[0],"slice",e)).slice(Ee(t[1]??0,"slice"),t[2]===void 0?void 0:Ee(t[2],"slice"));return typeof t[0]=="string"?r.join(""):r}),str:Pe("...",(t,e)=>ys(t,"",e,"str")),chr:Pe("...",t=>t.flatMap(e=>Array.isArray(e)?e:[e]).map(e=>String.fromCodePoint(Ee(e,"chr"))).join("")),ord:Pe("text",t=>typeof t[0]=="string"&&t[0].length?t[0].codePointAt(0):void 0),upper:Pe("text",t=>typeof t[0]=="string"?t[0].toUpperCase():void 0),lower:Pe("text",t=>typeof t[0]=="string"?t[0].toLowerCase():void 0),split:Pe("text, separator",t=>typeof t[0]=="string"?t[0].split(typeof t[1]=="string"?t[1]:" "):void 0),join:Pe("values, separator",(t,e)=>ys(Mt(t[0],"join",e),typeof t[1]=="string"?t[1]:"",e,"join")),search:Pe("value, list",(t,e)=>{let r=(typeof t[1]=="string"?[...t[1]]:Mt(t[1],"search",e)).findIndex(s=>Nn(s,t[0],e.step));return r<0?void 0:r}),contains:Pe("value, item",(t,e)=>typeof t[0]=="string"?t[0].includes(ys([t[1]],"",e,"contains")):Mt(t[0],"contains",e).some(n=>Nn(n,t[1],e.step))),lookup:Pe("x, table",(t,e)=>{let n=Ee(t[0],"lookup"),r=Mt(t[1],"lookup",e);if(!r.length)return;let s=r.map(i=>[Ee(i[0],"lookup"),Ee(i[1],"lookup")]).sort((i,o)=>i[0]-o[0]);if(n<=s[0][0])return s[0][1];for(let i=1;i<s.length;i++)if(n<=s[i][0]){let[o,a]=s[i-1],[l,u]=s[i];return a+(n-o)/(l-o)*(u-a)}return s[s.length-1][1]}),rands:Pe("min, max, count, seed",t=>{let e=Ee(t[0],"rands"),n=Ee(t[1],"rands"),r=Ee(t[2],"rands"),s=Ul(t[3]===void 0?1:Ee(t[3],"rands"));return Array.from({length:Math.min(Math.max(0,Math.floor(r)),1e6)},()=>e+(n-e)*s())}),is_num:Pe("value",t=>Vi(t[0])&&!Number.isNaN(t[0])),is_string:Pe("value",t=>typeof t[0]=="string"),is_bool:Pe("value",t=>typeof t[0]=="boolean"),is_list:Pe("value",t=>Array.isArray(t[0])),is_undef:Pe("value",t=>t[0]===void 0),is_function:Pe("value",t=>zt(t[0])),type_of:Pe("value",t=>at(t[0]))};var Te;(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"})(Te||(Te={}));var qe;(function(t){t[t.Subject=0]="Subject",t[t.Clip=1]="Clip"})(qe||(qe={}));var be;(function(t){t[t.EvenOdd=0]="EvenOdd",t[t.NonZero=1]="NonZero",t[t.Positive=2]="Positive",t[t.Negative=3]="Negative"})(be||(be={}));var Se;(function(t){t[t.IsOn=0]="IsOn",t[t.IsInside=1]="IsInside",t[t.IsOutside=2]="IsOutside"})(Se||(Se={}));var yn=Number.MAX_SAFE_INTEGER,Be=Math.floor(Math.sqrt(yn));function Pr(t,e){return!Number.isSafeInteger(t)||!Number.isSafeInteger(e)?!1:t===0||e===0?!0:Math.abs(t)<=yn/Math.abs(e)}function Zi(t,e){return Math.abs(t)+Math.abs(e)<=yn}function ws(t,e,n,r){if(Pr(t,e)&&Pr(n,r)){let s=t*e,i=n*r;if(Zi(s,i))return s-i}return Number.isSafeInteger(t)&&Number.isSafeInteger(e)&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)?Number(BigInt(t)*BigInt(e)-BigInt(n)*BigInt(r)):t*e-n*r}function Ss(t,e,n,r){if(Pr(t,e)&&Pr(n,r)){let s=t*e,i=n*r;if(Zi(s,i))return s+i}return Number.isSafeInteger(t)&&Number.isSafeInteger(e)&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)?Number(BigInt(t)*BigInt(e)+BigInt(n)*BigInt(r)):t*e+n*r}var ks=BigInt(0),Mr=BigInt(2),Nl=BigInt(4),Bl=BigInt(64),$l=BigInt("0xFFFFFFFFFFFFFFFF"),Es=BigInt("9223372036854775807"),Bn=Number(Es/Nl),Yi=Number(Es),Ki=1e-12,Gl=.1,Ps=Math.floor(Be/2),zl=Math.floor(Math.sqrt(Math.sqrt(yn/4)));function Hl(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:yn/e}function Vl(t,e,n){if(!Number.isFinite(t)||Math.abs(t)>e)throw new RangeError(`Scaled coordinate exceeds Number.MAX_SAFE_INTEGER in ${n}`)}function Xl(t,e){if(!Number.isFinite(t)||Math.abs(t)>yn)throw new RangeError(`Coordinate exceeds Number.MAX_SAFE_INTEGER in ${e}`)}function ql(t,e,n){let r=e.x-t.x,s=n.y-e.y,i=e.y-t.y,o=n.x-e.x;return Math.abs(r)<Be&&Math.abs(s)<Be&&Math.abs(i)<Be&&Math.abs(o)<Be?r*s-i*o:ws(r,s,i,o)}function lt(t,e,n){let r=e.x-t.x,s=n.y-e.y,i=e.y-t.y,o=n.x-e.x;if(Math.abs(r)<Be&&Math.abs(s)<Be&&Math.abs(i)<Be&&Math.abs(o)<Be){let u=r*s,c=i*o;return u>c?1:u<c?-1:0}if(!Number.isSafeInteger(r)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)){let u=r*s,c=i*o;return u>c?1:u<c?-1:0}let a=BigInt(r)*BigInt(s),l=BigInt(i)*BigInt(o);return a===l?0:a>l?1:-1}function Wl(t){if(t<-8||t>8)throw new Error("Error: Precision is out of range.")}function _l(t){return Math.abs(t)<=Ki}function jl(t){return t<0?-1:t>0?1:0}function Zl(t,e){let n=BigInt(t),r=BigInt(e),s=n*r;return{lo64:s&$l,hi64:s>>Bl}}function Ji(t,e,n,r){let s=Math.abs(t),i=Math.abs(e),o=Math.abs(n),a=Math.abs(r);if(s<Be&&i<Be&&o<Be&&a<Be)return t*e===n*r;let l=(t<0?-1:t>0?1:0)*(e<0?-1:e>0?1:0),u=(n<0?-1:n>0?1:0)*(r<0?-1:r>0?1:0);if(l!==u)return!1;if(l===0)return!0;if(!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)||!Number.isSafeInteger(a))return t*e===n*r;let c=BigInt(s),f=BigInt(i),h=BigInt(o),p=BigInt(a);return c*f===h*p}function Yl(t,e,n){let r=e.x-t.x,s=n.y-e.y,i=e.y-t.y,o=n.x-e.x;return Ji(r,s,i,o)}function Kl(t,e,n){let r=e.x-t.x,s=n.x-e.x,i=e.y-t.y,o=n.y-e.y;return Math.abs(r)<Be&&Math.abs(s)<Be&&Math.abs(i)<Be&&Math.abs(o)<Be?r*s+i*o:Ss(r,s,i,o)}function Jl(t,e,n){let r=e.x-t.x,s=n.x-e.x,i=e.y-t.y,o=n.y-e.y;if(Math.abs(r)<Be&&Math.abs(s)<Be&&Math.abs(i)<Be&&Math.abs(o)<Be){let l=r*s+i*o;return l>0?1:l<0?-1:0}if(!Number.isSafeInteger(r)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)){let l=r*s+i*o;return l>0?1:l<0?-1:0}let a=BigInt(r)*BigInt(s)+BigInt(i)*BigInt(o);return a===ks?0:a>ks?1:-1}function Ql(t){let e=t.length;if(e<3)return 0;let n=!0;for(let i=0;i<e&&n;i++){let o=t[i];(Math.abs(o.x)>=Ps||Math.abs(o.y)>=Ps)&&(n=!1)}let r=t[e-1];if(n){let i=0;for(let o of t)i+=(r.y+o.y)*(r.x-o.x),r=o;return i*.5}let s=ks;for(let i of t){let o=r.y+i.y,a=r.x-i.x;if(Number.isSafeInteger(o)&&Number.isSafeInteger(a))s+=BigInt(o)*BigInt(a);else if(Number.isSafeInteger(r.y)&&Number.isSafeInteger(i.y)&&Number.isSafeInteger(r.x)&&Number.isSafeInteger(i.x)){let l=BigInt(r.y)+BigInt(i.y),u=BigInt(r.x)-BigInt(i.x);s+=l*u}else s+=BigInt(Math.round(o*a));r=i}return Number(s)*.5}function eu(t,e){return t.y*e.x-e.y*t.x}function tu(t,e){return t.x*e.x+t.y*e.y}function nu(t){let e=Math.round(t);return t===e-.5&&(e&1)!==0?e-1:e}function ru(t){return t>=Bn||t<=-Bn?Yi:Math.round(t)}function su(t,e,n,r){let s=e.y-t.y,i=e.x-t.x,o=r.y-n.y,a=r.x-n.x,l=ws(s,a,o,i);if(l===0)return null;let u=ws(t.x-n.x,o,t.y-n.y,a)/l;return u<=0?{x:t.x,y:t.y,z:t.z||0}:u>=1?{x:e.x,y:e.y,z:e.z||0}:{x:Math.trunc(t.x+u*i),y:Math.trunc(t.y+u*s),z:0}}function iu(t,e,n,r){let s=e.y-t.y,i=e.x-t.x,o=r.y-n.y,a=r.x-n.x,l=s*a-o*i;if(l===0)return{success:!1,ip:{x:0,y:0,z:0}};let u=((t.x-n.x)*o-(t.y-n.y)*a)/l,c;return u<=0?c={...t,z:0}:u>=1?c={...e,z:0}:c={x:t.x+u*i,y:t.y+u*s,z:0},{success:!0,ip:c}}function ou(t,e,n,r,s=!1){if(!s){let u=lt(t,n,r),c=lt(e,n,r),f=lt(n,t,e),h=lt(r,t,e);return u!==0&&c!==0&&u!==c&&f!==0&&h!==0&&f!==h}let i=lt(t,n,r),o=lt(e,n,r);if(i!==0&&i===o)return!1;let a=lt(n,t,e),l=lt(r,t,e);return a!==0&&a===l?!1:i!==0||o!==0||a!==0||l!==0}function Qi(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 n of t)n.x<e.left&&(e.left=n.x),n.x>e.right&&(e.right=n.x),n.y<e.top&&(e.top=n.y),n.y>e.bottom&&(e.bottom=n.y);return e.left===Number.MAX_SAFE_INTEGER?{left:0,top:0,right:0,bottom:0}:e}function au(t,e,n){if(e.x===n.x&&e.y===n.y)return{x:e.x,y:e.y,z:0};let r=n.x-e.x,s=n.y-e.y,i=Ss(t.x-e.x,r,t.y-e.y,s)/Ss(r,r,s,s),o=i<0?0:i>1?1:i;return{x:Math.round(e.x+o*r),y:Math.round(e.y+o*s),z:0}}function Ms(t,e){let n=e.length,r=0;if(n<3)return Se.IsOutside;for(;r<n&&e[r].y===t.y;)r++;if(r===n)return Se.IsOutside;let s=e[r].y<t.y,i=s,o=0,a=r+1,l=n;for(;;){if(a===l){if(l===0||r===0)break;l=r,a=0}if(s)for(;a<l&&e[a].y<t.y;)a++;else for(;a<l&&e[a].y>t.y;)a++;if(a===l)continue;let c=e[a],f=a>0?e[a-1]:e[n-1];if(c.y===t.y){if(c.x===t.x||c.y===f.y&&t.x<f.x!=t.x<c.x)return Se.IsOn;if(a++,a===r)break;continue}if(!(t.x<c.x&&t.x<f.x))if(t.x>f.x&&t.x>c.x)o=1-o;else{let h=lt(f,c,t);if(h===0)return Se.IsOn;h<0===s&&(o=1-o)}s=!s,a++}if(s===i)return o===0?Se.IsOutside:Se.IsInside;a===n&&(a=0);let u=a===0?lt(e[n-1],e[0],t):lt(e[a-1],e[a],t);return u===0?Se.IsOn:(u<0===s&&(o=1-o),o===0?Se.IsOutside:Se.IsInside)}function lu(t,e){let n=Se.IsOn;for(let a of t)switch(Ms(a,e)){case Se.IsOutside:if(n===Se.IsOutside)return!1;n=Se.IsOutside;break;case Se.IsInside:if(n===Se.IsInside)return!0;n=Se.IsInside;break;default:break}let r=Qi(t),s,i;return Number.isSafeInteger(r.left)&&Number.isSafeInteger(r.right)&&Math.abs(r.left)+Math.abs(r.right)>Number.MAX_SAFE_INTEGER?(s=Number((BigInt(r.left)+BigInt(r.right))/Mr),i=Number((BigInt(r.top)+BigInt(r.bottom))/Mr)):(s=Math.round((r.left+r.right)/2),i=Math.round((r.top+r.bottom)/2)),Ms({x:s,y:i},e)!==Se.IsOutside}var ge={MaxInt64:Es,MaxCoord:Bn,max_coord:Bn,min_coord:-Bn,Invalid64:Yi,floatingPointTolerance:Ki,defaultMinimumEdgeLength:Gl,maxCoordForSafeAreaProduct:Ps,maxCoordForSafeCrossSq:zl,maxSafeCoordinateForScale:Hl,checkSafeScaleValue:Vl,ensureSafeInteger:Xl,crossProduct:ql,crossProductSign:lt,checkPrecision:Wl,isAlmostZero:_l,triSign:jl,multiplyUInt64:Zl,productsAreEqual:Ji,isCollinear:Yl,dotProduct:Kl,dotProductSign:Jl,area:Ql,crossProductD:eu,dotProductD:tu,roundToEven:nu,checkCastInt64:ru,getLineIntersectPt:su,getLineIntersectPtD:iu,segsIntersect:ou,getBounds:Qi,getClosestPtOnSegment:au,pointInPolygon:Ms,path2ContainsPath1:lu},Et={create(t=0,e=0,n=0){return{x:Math.round(t),y:Math.round(e),z:n}},fromPointD(t){return ge.ensureSafeInteger(t.x,"Point64Utils.fromPointD"),ge.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 n=t.x+e.x,r=t.y+e.y;return Number.isSafeInteger(n)&&Number.isSafeInteger(r)?{x:n,y:r,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} `}},Er={create(t=0,e=0,n=0){return{x:t,y:e,z:n}},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 ge.isAlmostZero(t.x-e.x)&&ge.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)}`}},en={create(t=0,e=0,n=0,r=0){return{left:t,top:e,right:n,bottom:r}},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))/Mr),n=Number((BigInt(t.top)+BigInt(t.bottom))/Mr);return{x:e,y:n}}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}]}},Ls={create(t=0,e=0,n=0,r=0){return{left:t,top:e,right:n,bottom:r}},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 eo=Object.freeze(en.createInvalid()),to=Object.freeze(Ls.createInvalid());var $n=BigInt(0),uu=BigInt(2),no=BigInt(4),Le;(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"})(Le||(Le={}));var Ts=class{constructor(){R(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],n=this.data.pop();return this.data.length>0&&(this.data[0]=n,this.siftDown(0)),e}clear(){this.data.length=0}siftUp(e){let n=this.data[e];for(;e>0;){let r=e-1>>1;if(this.data[r]>=n)break;this.data[e]=this.data[r],e=r}this.data[e]=n}siftDown(e){let n=this.data.length,r=this.data[e];for(;;){let s=(e<<1)+1;if(s>=n)break;let i=s+1,o=s;if(i<n&&this.data[i]>this.data[s]&&(o=i),this.data[o]<=r)break;this.data[e]=this.data[o],e=o}this.data[e]=r}},Gn=class{constructor(e,n,r){R(this,"pt");R(this,"next",null);R(this,"prev",null);R(this,"flags");this.pt=e,this.flags=n,this.prev=r}},zn=class{constructor(e,n,r=!1){R(this,"vertex");R(this,"polytype");R(this,"isOpen");this.vertex=e,this.polytype=n,this.isOpen=r}equals(e){return e!==null&&this.vertex===e.vertex}};function ro(t,e,n){return{pt:t,edge1:e,edge2:n}}var Rt=class{constructor(e,n){R(this,"pt");R(this,"next");R(this,"prev");R(this,"outrec");R(this,"horz");this.pt=e,this.outrec=n,this.next=this,this.prev=this,this.horz=null}},Ye;(function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Right=2]="Right"})(Ye||(Ye={}));var Is;(function(t){t[t.Bottom=0]="Bottom",t[t.Middle=1]="Middle",t[t.Top=2]="Top"})(Is||(Is={}));var Lr=class{constructor(){R(this,"idx",0);R(this,"owner",null);R(this,"frontEdge",null);R(this,"backEdge",null);R(this,"pts",null);R(this,"polypath",null);R(this,"bounds",{left:0,top:0,right:0,bottom:0});R(this,"path",[]);R(this,"isOpen",!1);R(this,"splits",null);R(this,"recursiveSplit",null)}},Tr=class{constructor(e){R(this,"leftOp");R(this,"rightOp");R(this,"leftToRight");this.leftOp=e,this.rightOp=null,this.leftToRight=!0}},Hn=class{constructor(e,n){R(this,"op1");R(this,"op2");this.op1=e,this.op2=n}};function cu(t,e){return t.rightOp===null?e.rightOp===null?0:1:e.rightOp===null?-1:t.leftOp.pt.x-e.leftOp.pt.x}function fu(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 Vn=class{constructor(){R(this,"bot",{x:0,y:0});R(this,"top",{x:0,y:0});R(this,"curX",0);R(this,"dx",0);R(this,"windDx",0);R(this,"windCount",0);R(this,"windCount2",0);R(this,"outrec",null);R(this,"prevInAEL",null);R(this,"nextInAEL",null);R(this,"prevInSEL",null);R(this,"nextInSEL",null);R(this,"jump",null);R(this,"vertexTop",null);R(this,"localMin",null);R(this,"isLeftBound",!1);R(this,"joinWith",Ye.None)}},vn={addLocMin(t,e,n,r){if((t.flags&Le.LocalMin)!==Le.None)return;t.flags|=Le.LocalMin;let s=new zn(t,e,n);r.push(s)},addPathsToVertexList(t,e,n,r,s){for(let i=0,o=t.length;i<o;i++){let a=t[i],l=null,u=null,c=null;for(let d=0,g=a.length;d<g;d++){let m=a[d];if(l===null)l=new Gn(m,Le.None,null),s.push(l),u=l,c=m;else if(!(c.x===m.x&&c.y===m.y)){let x=new Gn(m,Le.None,u);u.next=x,u=x,c=m}}if(u?.prev==null||(!n&&u.pt.x===l.pt.x&&u.pt.y===l.pt.y&&(u=u.prev),u.next=l,l.prev=u,!n&&u.next===u))continue;let f;if(n){let d=l.next;for(;d!==l&&d.pt.y===l.pt.y;)d=d.next;f=d.pt.y<=l.pt.y,f?(l.flags=Le.OpenStart,vn.addLocMin(l,e,!0,r)):l.flags=Le.OpenStart|Le.LocalMax}else{for(u=l.prev;u!==l&&u.pt.y===l.pt.y;)u=u.prev;if(u===l)continue;f=u.pt.y>l.pt.y}let h=f;u=l;let p=l.next;for(;p!==l;)p.pt.y>u.pt.y&&f?(u.flags|=Le.LocalMax,f=!1):p.pt.y<u.pt.y&&!f&&(f=!0,vn.addLocMin(u,e,n,r)),u=p,p=p.next;n?(u.flags|=Le.OpenEnd,f?u.flags|=Le.LocalMax:vn.addLocMin(u,e,n,r)):f!==h&&(h?vn.addLocMin(u,e,!1,r):u.flags|=Le.LocalMax)}}};var Ir=class{constructor(e=null){R(this,"parent");R(this,"children",[]);this.parent=e}get isHole(){return this.getIsHole()}getLevel(){let e=0,n=this.parent;for(;n!==null;)++e,n=n.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,n){let r="",s=" ".repeat(n),i=this.children.length===1?"":"s";(n&1)===0?r+=`${s}+- hole (${e}) contains ${this.children.length} nested polygon${i}.
|
|
3
3
|
`:r+=`${s}+- polygon (${e}) contains ${this.children.length} hole${i}.
|
|
4
4
|
`;for(let o=0;o<this.count;o++)this.children[o].count>0&&(r+=this.children[o].toStringInternal(o,n+1));return r}toString(){if(this.level>0)return"";let e=this.children.length===1?"":"s",n=`Polytree with ${this.children.length} polygon${e}.
|
|
5
5
|
`;for(let r=0;r<this.count;r++)this.children[r].count>0&&(n+=this.children[r].toStringInternal(r,1));return n+`
|
|
6
|
-
`}},Mn=class t extends Cn{constructor(n=null){super(n);b(this,"polygon",null)}get poly(){return this.polygon}addChild(n){let r=new t(this);return r.polygon=n,this.children.push(r),r}child(n){if(n<0||n>=this.children.length)throw new Error("Index out of range");return this.children[n]}area(){let n=this.polygon===null?0:Lr.area(this.polygon);for(let r of this.children)n+=r.area();return n}};var Kt=class extends Mn{};var m=class m{constructor(){b(this,"cliptype",ee.NoClip);b(this,"fillrule",X.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 Er);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,n){return e.x===n.x&&e.y===n.y}setZ(e,n,r){let s=this.zCallbackInternal;s&&(m.getPolyType(e)===ke.Subject?(this.xyEqual(r,e.bot)?r.z=e.bot.z??0:this.xyEqual(r,e.top)?r.z=e.top.z??0:this.xyEqual(r,n.bot)?r.z=n.bot.z??0:this.xyEqual(r,n.top)?r.z=n.top.z??0:r.z=0,s(e.bot,e.top,n.bot,n.top,r)):(this.xyEqual(r,n.bot)?r.z=n.bot.z??0:this.xyEqual(r,n.top)?r.z=n.top.z??0:this.xyEqual(r,e.bot)?r.z=e.bot.z??0:this.xyEqual(r,e.top)?r.z=e.top.z??0:r.z=0,s(n.bot,n.top,e.bot,e.top,r)))}static isOdd(e){return(e&1)!==0}static isHotEdge(e){return e.outrec!=null}static isOpen(e){return m.openPathsEnabled&&e.localMin.isOpen}static isOpenEnd(e){return m.openPathsEnabled&&e.localMin.isOpen&&m.isOpenEndVertex(e.vertexTop)}static isOpenEndVertex(e){return(e.flags&(K.OpenStart|K.OpenEnd))!==K.None}static getPrevHotEdge(e){let n=e.prevInAEL;if(!m.openPathsEnabled){for(;n!==null&&!m.isHotEdge(n);)n=n.prevInAEL;return n}for(;n!==null&&(n.localMin.isOpen||!m.isHotEdge(n));)n=n.prevInAEL;return n}static isFront(e){return e===e.outrec.frontEdge}static getDx(e,n){let r=n.y-e.y;return r!==0?(n.x-e.x)/r:n.x>e.x?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY}static topX(e,n){return n===e.top.y||e.top.x===e.bot.x?e.top.x:n===e.bot.y?e.bot.x:H.roundToEven(e.bot.x+e.dx*(n-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,n){return e.localMin.polytype===n.localMin.polytype}static setDx(e){e.dx=m.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&K.LocalMax)!==K.None}static isMaximaEdge(e){return(e.vertexTop.flags&K.LocalMax)!==K.None}static getMaximaPair(e){let n=e.nextInAEL;for(;n!==null;){if(n.vertexTop===e.vertexTop)return n;n=n.nextInAEL}return null}boundingBoxesOverlap(e,n,r,s){let i=e.x<n.x?e.x:n.x;if((r.x>s.x?r.x:s.x)<i)return!1;let a=e.x>n.x?e.x:n.x,l=r.x<s.x?r.x:s.x;if(a<l)return!1;let u=e.y<n.y?e.y:n.y;if((r.y>s.y?r.y:s.y)<u)return!1;let f=e.y>n.y?e.y:n.y,h=r.y<s.y?r.y:s.y;return f>=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,n)=>n.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 n=0,r=e.length;n<r;n++){let s=e[n];this.scanlineSet.add(s),this.scanlineHeap.push(s)}e.length=0,this.useScanlineArray=!1}insertScanline(e){if(this.useScanlineArray){let n=this.scanlineArr;for(let r=0,s=n.length;r<s;r++)if(n[r]===e)return;n.push(e),n.length>64&&this.upgradeScanlineStructureFromArray();return}this.scanlineSet.has(e)||(this.scanlineSet.add(e),this.scanlineHeap.push(e))}popScanline(){if(this.useScanlineArray){let n=this.scanlineArr,r=n.length;if(r===0)return null;let s=0,i=n[0];for(let o=1;o<r;o++){let a=n[o];a>i&&(i=a,s=o)}return n[s]=n[r-1],n.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,n,r=!1){let s=[e];this.addPaths(s,n,r)}addPaths(e,n,r=!1){r&&(this.hasOpenPaths=!0),this.isSortedMinimaList=!1,Ot.addPathsToVertexList(e,n,r,this.minimaList,this.vertexList)}addReuseableData(e){if(e.minimaList.length!==0){this.isSortedMinimaList=!1;for(let n of e.minimaList)this.minimaList.push(new Zt(n.vertex,n.polytype,n.isOpen)),n.isOpen&&(this.hasOpenPaths=!0)}}deleteFromAEL(e){let n=e.prevInAEL,r=e.nextInAEL;n===null&&r===null&&e!==this.actives||(n!==null?n.nextInAEL=r:this.actives=r,r!==null&&(r.prevInAEL=n))}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 n of this.vertexList){let r=n;do r.pt.x<e.left&&(e.left=r.pt.x),r.pt.x>e.right&&(e.right=r.pt.x),r.pt.y<e.top&&(e.top=r.pt.y),r.pt.y>e.bottom&&(e.bottom=r.pt.y),r=r.next;while(r!==n)}return yt.isEmpty(e)?{left:0,top:0,right:0,bottom:0}:e}executeInternal(e,n){if(e===ee.NoClip)return;m.openPathsEnabled=this.hasOpenPaths,this.zCallbackInternal=this.getZCallback(),this.fillrule=n,this.cliptype=e,this.reset();let r=this.popScanline();if(r!==null){for(;this.succeeded;){this.insertLocalMinimaIntoAEL(r);let s;for(;(s=this.popHorz())!==null;)this.doHorizontal(s);this.horzSegList.length>0&&(this.convertHorzSegsToJoins(),this.horzSegList.length=0),this.currentBotY=r;let i=this.popScanline();if(i===null)break;for(r=i,this.doIntersections(r),this.doTopOfScanbeam(r);(s=this.popHorz())!==null;)this.doHorizontal(s)}this.succeeded&&this.processHorzJoins()}}insertLocalMinimaIntoAEL(e){for(;this.hasLocMinAtY(e);){let n=this.popLocalMinima(),r;(n.vertex.flags&K.OpenStart)!==K.None?r=null:(r=new Yt,r.bot=n.vertex.pt,r.curX=n.vertex.pt.x,r.windDx=-1,r.vertexTop=n.vertex.prev,r.top=n.vertex.prev.pt,r.outrec=null,r.localMin=n,m.setDx(r));let s;if((n.vertex.flags&K.OpenEnd)!==K.None?s=null:(s=new Yt,s.bot=n.vertex.pt,s.curX=n.vertex.pt.x,s.windDx=1,s.vertexTop=n.vertex.next,s.top=n.vertex.next.pt,s.outrec=null,s.localMin=n,m.setDx(s)),r!==null&&s!==null){if(m.isHorizontal(r)){if(m.isHeadingRightHorz(r)){let o=r;r=s,s=o}}else if(m.isHorizontal(s)){if(m.isHeadingLeftHorz(s)){let o=r;r=s,s=o}}else if(r.dx<s.dx){let o=r;r=s,s=o}}else r===null&&(r=s,s=null);let i;if(r.isLeftBound=!0,this.insertLeftEdge(r),m.openPathsEnabled?m.isOpen(r)?(this.setWindCountForOpenPathEdge(r),i=this.isContributingOpen(r)):(this.setWindCountForClosedPathEdge(r),i=this.isContributingClosed(r)):(this.setWindCountForClosedPathEdge(r),i=this.isContributingClosed(r)),s!==null){for(s.windCount=r.windCount,s.windCount2=r.windCount2,this.insertRightEdge(r,s),i&&(this.addLocalMinPoly(r,s,r.bot,!0),m.isHorizontal(r)||this.checkJoinLeft(r,r.bot));s.nextInAEL!==null&&this.isValidAelOrder(s.nextInAEL,s);)this.intersectEdges(s,s.nextInAEL,s.bot),this.swapPositionsInAEL(s,s.nextInAEL);m.isHorizontal(s)?this.pushHorz(s):(this.checkJoinRight(s,s.bot),this.insertScanline(s.top.y))}else i&&m.openPathsEnabled&&this.startOpenPath(r,r.bot);m.isHorizontal(r)?this.pushHorz(r):this.insertScanline(r.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(!m.openPathsEnabled){this.doHorizontalClosed(e);return}let n=m.isOpen(e),r=e.bot.y,s=n?this.getCurrYMaximaVertexOpen(e):this.getCurrYMaximaVertex(e),{isLeftToRight:i,leftX:o,rightX:a}=this.resetHorzDirection(e,s),l=o,u=a;if(m.isHotEdge(e)){let c=this.addOutPt(e,{x:e.curX,y:r});this.addToHorzSegList(c)}for(;;){let c=i?e.nextInAEL:e.prevInAEL;for(;c!==null;){if(c.vertexTop===s){if(m.isHotEdge(e)&&this.isJoined(c)&&this.split(c,c.top),m.isHotEdge(e)){for(;e.vertexTop!==s;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);i?this.addLocalMaxPoly(e,c,e.top):this.addLocalMaxPoly(c,e,e.top)}this.deleteFromAEL(c),this.deleteFromAEL(e);return}if(s!==e.vertexTop||m.isOpenEnd(e)){if(i&&c.curX>u||!i&&c.curX<l)break;if(c.curX===e.top.x&&!m.isHorizontal(c)){let p=m.nextVertex(e).pt;if(m.isOpen(c)&&!m.isSamePolyType(c,e)&&!m.isHotEdge(c)){if(i&&m.topX(c,p.y)>p.x||!i&&m.topX(c,p.y)<p.x)break}else if(i&&m.topX(c,p.y)>=p.x||!i&&m.topX(c,p.y)<=p.x)break}}let h={x:c.curX,y:r};i?(this.intersectEdges(e,c,h),this.swapPositionsInAEL(e,c),this.checkJoinLeft(c,h),e.curX=c.curX,c=e.nextInAEL):(this.intersectEdges(c,e,h),this.swapPositionsInAEL(c,e),this.checkJoinRight(c,h),e.curX=c.curX,c=e.prevInAEL),m.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(n&&m.isOpenEnd(e)){m.isHotEdge(e)&&(this.addOutPt(e,e.top),m.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e);return}if(m.nextVertex(e).pt.y!==e.top.y)break;m.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let f=this.resetHorzDirection(e,s);l=f.leftX,u=f.rightX}if(m.isHotEdge(e)){let c=this.addOutPt(e,e.top);this.addToHorzSegList(c)}this.updateEdgeIntoAEL(e)}doHorizontalClosed(e){let n=e.bot.y,r=this.getCurrYMaximaVertex(e),{isLeftToRight:s,leftX:i,rightX:o}=this.resetHorzDirection(e,r),a=i,l=o;if(m.isHotEdge(e)){let u=this.addOutPt(e,{x:e.curX,y:n});this.addToHorzSegList(u)}for(;;){let u=s?e.nextInAEL:e.prevInAEL;for(;u!==null;){if(u.vertexTop===r){if(m.isHotEdge(e)&&this.isJoined(u)&&this.split(u,u.top),m.isHotEdge(e)){for(;e.vertexTop!==r;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);s?this.addLocalMaxPoly(e,u,e.top):this.addLocalMaxPoly(u,e,e.top)}this.deleteFromAEL(u),this.deleteFromAEL(e);return}if(r!==e.vertexTop){if(s&&u.curX>l||!s&&u.curX<a)break;if(u.curX===e.top.x&&!m.isHorizontal(u)){let h=m.nextVertex(e).pt,p=m.topX(u,h.y);if(s&&p>=h.x||!s&&p<=h.x)break}}let f={x:u.curX,y:n};s?(this.intersectEdges(e,u,f),this.swapPositionsInAEL(e,u),this.checkJoinLeft(u,f),e.curX=u.curX,u=e.nextInAEL):(this.intersectEdges(u,e,f),this.swapPositionsInAEL(u,e),this.checkJoinRight(u,f),e.curX=u.curX,u=e.prevInAEL),m.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(m.nextVertex(e).pt.y!==e.top.y)break;m.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let c=this.resetHorzDirection(e,r);a=c.leftX,l=c.rightX}if(m.isHotEdge(e)){let u=this.addOutPt(e,e.top);this.addToHorzSegList(u)}this.updateEdgeIntoAEL(e)}convertHorzSegsToJoins(){let e=this.horzSegList,n=0;for(let r=0,s=e.length;r<s;r++){let i=e[r];this.updateHorzSegment(i)&&(e[n++]=i)}if(!(n<2)){e.length=n,this.horzSegList.sort(Ua);for(let r=0;r<n-1;r++){let s=this.horzSegList[r];for(let i=r+1;i<n;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 l=new jt(this.duplicateOp(s.leftOp,!0),this.duplicateOp(o.leftOp,!1));this.horzJoinList.push(l)}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 l=new jt(this.duplicateOp(o.leftOp,!0),this.duplicateOp(s.leftOp,!1));this.horzJoinList.push(l)}}}}}updateHorzSegment(e){let n=e.leftOp,r=this.getRealOutRec(n.outrec),s=r.frontEdge!==null,i=n.pt.y,o=n,a=n;if(s){let u=r.pts,c=u.next;for(;o!==c&&o.prev.pt.y===i;)o=o.prev;for(;a!==u&&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 l=this.setHorzSegHeadingForward(e,o,a)&&e.leftOp.horz===null;return l?e.leftOp.horz=e:e.rightOp=null,l}setHorzSegHeadingForward(e,n,r){return n.pt.x===r.pt.x?!1:(n.pt.x<r.pt.x?(e.leftOp=n,e.rightOp=r,e.leftToRight=!0):(e.leftOp=r,e.rightOp=n,e.leftToRight=!1),!0)}duplicateOp(e,n){let r=new tt(e.pt,e.outrec);return n?(r.next=e.next,r.next.prev=r,r.prev=e,e.next=r):(r.prev=e.prev,r.prev.next=r,r.next=e,e.prev=r),r}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 n=this.curXValidAtTop;this.curXValidAtTop=!1,this.sel=null;let r=this.actives;for(;r!==null;){if(r.top.y===e)if(r.curX=r.top.x,m.isMaximaEdge(r)){r=this.doMaxima(r);continue}else m.isHotEdge(r)&&this.addOutPt(r,r.top),this.updateEdgeIntoAEL(r),m.isHorizontal(r)&&this.pushHorz(r);else n||(r.curX=m.topX(r,e));r=r.nextInAEL}}processHorzJoins(){for(let e of this.horzJoinList){let n=this.getRealOutRec(e.op1.outrec),r=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,n===r){let o=this.newOutRec();o.pts=s,this.fixOutRecPts(o),n.pts.outrec===o&&(n.pts=e.op1,n.pts.outrec=n),this.usingPolytree?(this.path1InsidePath2(n.pts,o.pts)?([o.pts,n.pts]=[n.pts,o.pts],this.fixOutRecPts(n),this.fixOutRecPts(o),o.owner=n):this.path1InsidePath2(o.pts,n.pts)?o.owner=n:o.owner=n.owner,n.splits===null&&(n.splits=[]),n.splits.push(o.idx)):o.owner=n}else r.pts=null,this.usingPolytree?(this.setOwner(r,n),this.moveSplits(r,n)):r.owner=n}}fixOutRecPts(e){let n=e.pts;do n.outrec=e,n=n.next;while(n!==e.pts)}path1InsidePath2(e,n){let r=q.IsOn,s=e;do{switch(this.pointInOpPolygon(s.pt,n)){case q.IsOutside:if(r===q.IsOutside)return!1;r=q.IsOutside;break;case q.IsInside:if(r===q.IsInside)return!0;r=q.IsInside;break;default:break}s=s.next}while(s!==e);return H.path2ContainsPath1(this.getCleanPath(e),this.getCleanPath(n))}pointInOpPolygon(e,n){if(n===n.next||n.prev===n.next)return q.IsOutside;let r=n;do{if(n.pt.y!==e.y)break;n=n.next}while(n!==r);if(n.pt.y===e.y)return q.IsOutside;let s=n.pt.y<e.y,i=s,o=0;for(r=n.next;r!==n;){if(s)for(;r!==n&&r.pt.y<e.y;)r=r.next;else for(;r!==n&&r.pt.y>e.y;)r=r.next;if(r===n)break;if(r.pt.y===e.y){if(r.pt.x===e.x||r.pt.y===r.prev.pt.y&&e.x<r.prev.pt.x!=e.x<r.pt.x)return q.IsOn;if(r=r.next,r===n)break;continue}if(r.pt.x<=e.x||r.prev.pt.x<=e.x)if(r.prev.pt.x<e.x&&r.pt.x<e.x)o=1-o;else{let a=H.crossProductSign(r.prev.pt,r.pt,e);if(a===0)return q.IsOn;a<0===s&&(o=1-o)}s=!s,r=r.next}if(s===i)return o===0?q.IsOutside:q.IsInside;{let a=H.crossProductSign(r.prev.pt,r.pt,e);if(a===0)return q.IsOn;a<0===s&&(o=1-o)}return o===0?q.IsOutside:q.IsInside}getCleanPath(e){let n=[],r=e;for(;r.next!==e&&(r.pt.x===r.next.pt.x&&r.pt.x===r.prev.pt.x||r.pt.y===r.next.pt.y&&r.pt.y===r.prev.pt.y);)r=r.next;n.push(r.pt);let s=r;for(r=r.next;r!==e;)(r.pt.x!==r.next.pt.x||r.pt.x!==s.pt.x)&&(r.pt.y!==r.next.pt.y||r.pt.y!==s.pt.y)&&(n.push(r.pt),s=r),r=r.next;return n}moveSplits(e,n){if(e.splits!==null){n.splits===null&&(n.splits=[]);for(let r of e.splits)r!==n.idx&&n.splits.push(r);e.splits=null}}buildIntersectList(e){if(this.actives?.nextInAEL===null)return!1;if(!this.adjustCurrXAndCopyToSEL(e))return this.curXValidAtTop=!0,!1;let n=this.sel;for(;n!==null&&n.jump!==null;){let r=null;for(;n!==null&&n.jump!==null;){let s=n,i=n.jump,o=i,a=i?.jump||null;for(n.jump=a;n!==o&&i!==a;)if(i.curX<n.curX){let l=i.prevInSEL;for(;this.addNewIntersectNode(l,i,e),l!==n;)l=l.prevInSEL;if(l=i,i=this.extractFromSEL(l),o=i,n!==null&&this.insert1Before2InSEL(l,n),n!==s)continue;s=l,s.jump=a,r===null?this.sel=s:r.jump=s}else n=n.nextInSEL;r=s,n=a}n=this.sel}return this.intersectList.length>0}processIntersectList(){this.intersectList.sort(Na);for(let e=0;e<this.intersectList.length;++e){if(!this.edgesAdjacentInAEL(this.intersectList[e])){let r=e+1;for(;!this.edgesAdjacentInAEL(this.intersectList[r]);)r++;[this.intersectList[r],this.intersectList[e]]=[this.intersectList[e],this.intersectList[r]]}let n=this.intersectList[e];this.intersectEdges(n.edge1,n.edge2,n.pt),this.swapPositionsInAEL(n.edge1,n.edge2),n.edge1.curX=n.pt.x,n.edge2.curX=n.pt.x,this.checkJoinLeft(n.edge2,n.pt,!0),this.checkJoinRight(n.edge1,n.pt,!0)}}edgesAdjacentInAEL(e){return e.edge1.nextInAEL===e.edge2||e.edge1.prevInAEL===e.edge2}adjustCurrXAndCopyToSEL(e){let n=this.actives;this.sel=n;let r=Number.NEGATIVE_INFINITY,s=!1;for(;n!==null;){n.prevInSEL=n.prevInAEL,n.nextInSEL=n.nextInAEL,n.jump=n.nextInSEL;let i=m.topX(n,e);n.curX=i,i<r&&(s=!0),r=i,n=n.nextInAEL}return s}doMaxima(e){let n=e.prevInAEL,r=e.nextInAEL;if(m.isOpenEnd(e))return m.isHotEdge(e)&&this.addOutPt(e,e.top),m.isHorizontal(e)||(m.isHotEdge(e)&&(m.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e)),r;let s=m.getMaximaPair(e);if(s===null)return r;for(this.isJoined(e)&&this.split(e,e.top),this.isJoined(s)&&this.split(s,s.top);r!==s;)this.intersectEdges(e,r,e.top),this.swapPositionsInAEL(e,r),r=e.nextInAEL;return m.isOpen(e)?(m.isHotEdge(e)&&this.addLocalMaxPoly(e,s,e.top),this.deleteFromAEL(s),this.deleteFromAEL(e),n!==null?n.nextInAEL:this.actives):(m.isHotEdge(e)&&this.addLocalMaxPoly(e,s,e.top),this.deleteFromAEL(e),this.deleteFromAEL(s),n!==null?n.nextInAEL:this.actives)}updateEdgeIntoAEL(e){if(e.bot=e.top,e.vertexTop=m.nextVertex(e),e.top=e.vertexTop.pt,e.curX=e.bot.x,m.setDx(e),this.isJoined(e)&&this.split(e,e.bot),m.isHorizontal(e)){m.openPathsEnabled?m.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,n){let r=!1,s=m.nextVertex(e).pt;for(;s.y===e.top.y&&!(n&&s.x<e.top.x!=e.bot.x<e.top.x||(e.vertexTop=m.nextVertex(e),e.top=s,r=!0,m.isMaximaVertex(e.vertexTop)));)s=m.nextVertex(e).pt;r&&m.setDx(e)}addToHorzSegList(e){e.outrec.isOpen||this.horzSegList.push(new In(e))}addNewIntersectNode(e,n,r){let s=H.getLineIntersectPt(e.bot,e.top,n.bot,n.top);if(s===null&&(s={x:e.curX,y:r}),s.y>this.currentBotY||s.y<r){let o=Math.abs(e.dx),a=Math.abs(n.dx);o>100&&a>100?o>a?s=H.getClosestPtOnSegment(s,e.bot,e.top):s=H.getClosestPtOnSegment(s,n.bot,n.top):o>100?s=H.getClosestPtOnSegment(s,e.bot,e.top):a>100?s=H.getClosestPtOnSegment(s,n.bot,n.top):(s.y<r?s.y=r:s.y=this.currentBotY,o<a?s.x=m.topX(e,s.y):s.x=m.topX(n,s.y))}let i=$s(s,e,n);this.intersectList.push(i)}extractFromSEL(e){let n=e.nextInSEL;return n!==null&&(n.prevInSEL=e.prevInSEL),e.prevInSEL.nextInSEL=n,n}insert1Before2InSEL(e,n){e.prevInSEL=n.prevInSEL,e.prevInSEL!==null&&(e.prevInSEL.nextInSEL=e),e.nextInSEL=n,n.prevInSEL=e}getCurrYMaximaVertexOpen(e){let n=e.vertexTop;if(e.windDx>0)for(;n.next.pt.y===n.pt.y&&(n.flags&(K.OpenEnd|K.LocalMax))===K.None;)n=n.next;else for(;n.prev.pt.y===n.pt.y&&(n.flags&(K.OpenEnd|K.LocalMax))===K.None;)n=n.prev;return m.isMaximaVertex(n)||(n=null),n}getCurrYMaximaVertex(e){let n=e.vertexTop;if(e.windDx>0)for(;n.next.pt.y===n.pt.y;)n=n.next;else for(;n.prev.pt.y===n.pt.y;)n=n.prev;return m.isMaximaVertex(n)||(n=null),n}resetHorzDirection(e,n){if(e.bot.x===e.top.x){let r=e.curX,s=e.curX,i=e.nextInAEL;for(;i!==null&&i.vertexTop!==n;)i=i.nextInAEL;return{isLeftToRight:i!==null,leftX:r,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 n=e.outrec;return e===n.frontEdge?n.pts:n.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 n=this.actives;for(;n.nextInAEL!==null&&this.isValidAelOrder(n.nextInAEL,e);)n=n.nextInAEL;n.joinWith===Le.Right&&(n=n.nextInAEL),e.nextInAEL=n.nextInAEL,n.nextInAEL!==null&&(n.nextInAEL.prevInAEL=e),e.prevInAEL=n,n.nextInAEL=e}}insertRightEdge(e,n){n.nextInAEL=e.nextInAEL,e.nextInAEL!==null&&(e.nextInAEL.prevInAEL=n),n.prevInAEL=e,e.nextInAEL=n}setWindCountForOpenPathEdge(e){let n=this.actives;if(this.fillrule===X.EvenOdd){let r=0,s=0;for(;n!==e;)m.getPolyType(n)===ke.Clip?s++:m.isOpen(n)||r++,n=n.nextInAEL;e.windCount=m.isOdd(r)?1:0,e.windCount2=m.isOdd(s)?1:0}else for(;n!==e;)m.getPolyType(n)===ke.Clip?e.windCount2+=n.windDx:m.isOpen(n)||(e.windCount+=n.windDx),n=n.nextInAEL}setWindCountForClosedPathEdge(e){let n=e.prevInAEL,r=m.getPolyType(e);if(!m.openPathsEnabled){for(;n!==null&&m.getPolyType(n)!==r;)n=n.prevInAEL;if(n===null?(e.windCount=e.windDx,n=this.actives):this.fillrule===X.EvenOdd?(e.windCount=e.windDx,e.windCount2=n.windCount2,n=n.nextInAEL):(n.windCount*n.windDx<0?Math.abs(n.windCount)>1?n.windDx*e.windDx<0?e.windCount=n.windCount:e.windCount=n.windCount+e.windDx:e.windCount=e.windDx:n.windDx*e.windDx<0?e.windCount=n.windCount:e.windCount=n.windCount+e.windDx,e.windCount2=n.windCount2,n=n.nextInAEL),this.fillrule===X.EvenOdd)for(;n!==e;)m.getPolyType(n)!==r&&(e.windCount2=e.windCount2===0?1:0),n=n.nextInAEL;else for(;n!==e;)m.getPolyType(n)!==r&&(e.windCount2+=n.windDx),n=n.nextInAEL;return}for(;n!==null&&(m.getPolyType(n)!==r||m.isOpen(n));)n=n.prevInAEL;if(n===null?(e.windCount=e.windDx,n=this.actives):this.fillrule===X.EvenOdd?(e.windCount=e.windDx,e.windCount2=n.windCount2,n=n.nextInAEL):(n.windCount*n.windDx<0?Math.abs(n.windCount)>1?n.windDx*e.windDx<0?e.windCount=n.windCount:e.windCount=n.windCount+e.windDx:e.windCount=m.isOpen(e)?1:e.windDx:n.windDx*e.windDx<0?e.windCount=n.windCount:e.windCount=n.windCount+e.windDx,e.windCount2=n.windCount2,n=n.nextInAEL),this.fillrule===X.EvenOdd)for(;n!==e;)m.getPolyType(n)!==r&&!m.isOpen(n)&&(e.windCount2=e.windCount2===0?1:0),n=n.nextInAEL;else for(;n!==e;)m.getPolyType(n)!==r&&!m.isOpen(n)&&(e.windCount2+=n.windDx),n=n.nextInAEL}isContributingOpen(e){let n,r;switch(this.fillrule){case X.Positive:r=e.windCount>0,n=e.windCount2>0;break;case X.Negative:r=e.windCount<0,n=e.windCount2<0;break;default:r=e.windCount!==0,n=e.windCount2!==0;break}switch(this.cliptype){case ee.Intersection:return n;case ee.Union:return!r&&!n;default:return!n}}isContributingClosed(e){switch(this.fillrule){case X.Positive:if(e.windCount!==1)return!1;break;case X.Negative:if(e.windCount!==-1)return!1;break;case X.NonZero:if(Math.abs(e.windCount)!==1)return!1;break}switch(this.cliptype){case ee.Intersection:return this.fillrule===X.Positive?e.windCount2>0:this.fillrule===X.Negative?e.windCount2<0:e.windCount2!==0;case ee.Union:return this.fillrule===X.Positive?e.windCount2<=0:this.fillrule===X.Negative?e.windCount2>=0:e.windCount2===0;case ee.Difference:{let n=this.fillrule===X.Positive?e.windCount2<=0:this.fillrule===X.Negative?e.windCount2>=0:e.windCount2===0;return m.getPolyType(e)===ke.Subject?n:!n}case ee.Xor:return!0;default:return!1}}addLocalMinPoly(e,n,r,s=!1){let i=this.newOutRec();if(e.outrec=i,n.outrec=i,m.isOpen(e))i.owner=null,i.isOpen=!0,e.windDx>0?this.setSides(i,e,n):this.setSides(i,n,e);else{i.isOpen=!1;let a=m.getPrevHotEdge(e);a!==null?(this.usingPolytree&&this.setOwner(i,a.outrec),i.owner=a.outrec,this.outrecIsAscending(a)===s?this.setSides(i,n,e):this.setSides(i,e,n)):(i.owner=null,s?this.setSides(i,e,n):this.setSides(i,n,e))}let o=new tt(r,i);return i.pts=o,o}outrecIsAscending(e){return e===e.outrec.frontEdge}newOutRec(){let e=new Tn;return e.idx=this.outrecList.length,this.outrecList.push(e),e}startOpenPath(e,n){let r=this.newOutRec();r.isOpen=!0,e.windDx>0?(r.frontEdge=e,r.backEdge=null):(r.frontEdge=null,r.backEdge=e),e.outrec=r;let s=new tt(n,r);return r.pts=s,s}checkJoinLeft(e,n,r=!1){let s=e.prevInAEL;s!==null&&(!r&&e.curX!==s.curX||!m.isHotEdge(e)||!m.isHotEdge(s)||m.isHorizontal(e)||m.isHorizontal(s)||m.isOpen(e)||m.isOpen(s)||(n.y<e.top.y+2||n.y<s.top.y+2)&&(e.bot.y>n.y||s.bot.y>n.y)||r&&this.perpendicDistFromLineSqrdGreaterThanQuarter(n,s.bot,s.top)||H.isCollinear(e.top,n,s.top)&&(e.outrec.idx===s.outrec.idx?this.addLocalMaxPoly(s,e,n):e.outrec.idx<s.outrec.idx?this.joinOutrecPaths(e,s):this.joinOutrecPaths(s,e),s.joinWith=Le.Right,e.joinWith=Le.Left))}checkJoinRight(e,n,r=!1){let s=e.nextInAEL;s!==null&&(!r&&e.curX!==s.curX||!m.isHotEdge(e)||!m.isHotEdge(s)||m.isHorizontal(e)||m.isHorizontal(s)||m.isOpen(e)||m.isOpen(s)||(n.y<e.top.y+2||n.y<s.top.y+2)&&(e.bot.y>n.y||s.bot.y>n.y)||r&&this.perpendicDistFromLineSqrdGreaterThanQuarter(n,s.bot,s.top)||H.isCollinear(e.top,n,s.top)&&(e.outrec.idx===s.outrec.idx?this.addLocalMaxPoly(e,s,n):e.outrec.idx<s.outrec.idx?this.joinOutrecPaths(e,s):this.joinOutrecPaths(s,e),e.joinWith=Le.Right,s.joinWith=Le.Left))}perpendicDistFromLineSqrdGreaterThanQuarter(e,n,r){let s=e.x-n.x,i=e.y-n.y,o=r.x-n.x,a=r.y-n.y;if(o===0&&a===0)return!1;let l=H.maxCoordForSafeCrossSq;if(Math.abs(s)<l&&Math.abs(i)<l&&Math.abs(o)<l&&Math.abs(a)<l){let c=s*a-o*i;return c*c/(o*o+a*a)>.25}if(Number.isSafeInteger(s)&&Number.isSafeInteger(i)&&Number.isSafeInteger(o)&&Number.isSafeInteger(a)){let c=BigInt(s)*BigInt(a)-BigInt(o)*BigInt(i),f=c*c,h=BigInt(o)*BigInt(o)+BigInt(a)*BigInt(a);return Vs*f>h}let u=s*a-o*i;return u*u/(o*o+a*a)>.25}intersectEdges(e,n,r){let s;if(this.hasOpenPaths&&(m.isOpen(e)||m.isOpen(n))){if(m.isOpen(e)&&m.isOpen(n))return;if(m.isOpen(n)){let u=e;e=n,n=u}if(this.isJoined(n)&&this.split(n,r),this.cliptype===ee.Union){if(!m.isHotEdge(n))return}else if(n.localMin.polytype===ke.Subject)return;switch(this.fillrule){case X.Positive:if(n.windCount!==1)return;break;case X.Negative:if(n.windCount!==-1)return;break;default:if(Math.abs(n.windCount)!==1)return;break}if(m.isHotEdge(e))s=this.addOutPt(e,r),this.setZ(e,n,s.pt),m.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null;else if(r.x===e.localMin.vertex.pt.x&&r.y===e.localMin.vertex.pt.y&&!m.isOpenEndVertex(e.localMin.vertex)){let u=this.findEdgeWithMatchingLocMin(e);if(u!==null&&m.isHotEdge(u)){e.outrec=u.outrec,e.windDx>0?this.setSides(u.outrec,e,u):this.setSides(u.outrec,u,e);return}s=this.startOpenPath(e,r)}else s=this.startOpenPath(e,r);this.setZ(e,n,s.pt);return}this.isJoined(e)&&this.split(e,r),this.isJoined(n)&&this.split(n,r);let i,o;switch(e.localMin.polytype===n.localMin.polytype?this.fillrule===X.EvenOdd?(i=e.windCount,e.windCount=n.windCount,n.windCount=i):(e.windCount+n.windDx===0?e.windCount=-e.windCount:e.windCount+=n.windDx,n.windCount-e.windDx===0?n.windCount=-n.windCount:n.windCount-=e.windDx):(this.fillrule!==X.EvenOdd?e.windCount2+=n.windDx:e.windCount2=e.windCount2===0?1:0,this.fillrule!==X.EvenOdd?n.windCount2-=e.windDx:n.windCount2=n.windCount2===0?1:0),this.fillrule){case X.Positive:i=e.windCount,o=n.windCount;break;case X.Negative:i=-e.windCount,o=-n.windCount;break;default:i=Math.abs(e.windCount),o=Math.abs(n.windCount);break}let a=i===0||i===1,l=o===0||o===1;if(!(!m.isHotEdge(e)&&!a||!m.isHotEdge(n)&&!l))if(m.isHotEdge(e)&&m.isHotEdge(n))if(i!==0&&i!==1||o!==0&&o!==1||e.localMin.polytype!==n.localMin.polytype&&this.cliptype!==ee.Xor)s=this.addLocalMaxPoly(e,n,r),s&&this.setZ(e,n,s.pt);else if(m.isFront(e)||e.outrec===n.outrec){s=this.addLocalMaxPoly(e,n,r),s&&this.setZ(e,n,s.pt);let u=this.addLocalMinPoly(e,n,r);this.setZ(e,n,u.pt)}else{s=this.addOutPt(e,r),this.setZ(e,n,s.pt);let u=this.addOutPt(n,r);this.setZ(e,n,u.pt),this.swapOutrecs(e,n)}else if(m.isHotEdge(e))s=this.addOutPt(e,r),this.setZ(e,n,s.pt),this.swapOutrecs(e,n);else if(m.isHotEdge(n))s=this.addOutPt(n,r),this.setZ(e,n,s.pt),this.swapOutrecs(e,n);else{let u,c;switch(this.fillrule){case X.Positive:u=e.windCount2,c=n.windCount2;break;case X.Negative:u=-e.windCount2,c=-n.windCount2;break;default:u=Math.abs(e.windCount2),c=Math.abs(n.windCount2);break}if(!m.isSamePolyType(e,n))s=this.addLocalMinPoly(e,n,r),this.setZ(e,n,s.pt);else if(i===1&&o===1){switch(s=null,this.cliptype){case ee.Union:if(u>0&&c>0)return;s=this.addLocalMinPoly(e,n,r);break;case ee.Difference:(m.getPolyType(e)===ke.Clip&&u>0&&c>0||m.getPolyType(e)===ke.Subject&&u<=0&&c<=0)&&(s=this.addLocalMinPoly(e,n,r));break;case ee.Xor:s=this.addLocalMinPoly(e,n,r);break;default:if(u<=0||c<=0)return;s=this.addLocalMinPoly(e,n,r);break}s&&this.setZ(e,n,s.pt)}}}swapPositionsInAEL(e,n){let r=n.nextInAEL;r!==null&&(r.prevInAEL=e);let s=e.prevInAEL;s!==null&&(s.nextInAEL=n),n.prevInAEL=s,n.nextInAEL=e,e.prevInAEL=n,e.nextInAEL=r,n.prevInAEL===null&&(this.actives=n)}isValidAelOrder(e,n){if(n.curX!==e.curX)return n.curX>e.curX;let r=H.crossProductSign(e.top,n.bot,n.top);if(r!==0)return r<0;if(!m.isMaximaEdge(e)&&e.top.y>n.top.y)return H.crossProductSign(n.bot,e.top,m.nextVertex(e).pt)<=0;if(!m.isMaximaEdge(n)&&n.top.y>e.top.y)return H.crossProductSign(n.bot,n.top,m.nextVertex(n).pt)>=0;let s=n.bot.y,i=n.isLeftBound;return e.bot.y!==s||e.localMin.vertex.pt.y!==s?n.isLeftBound:e.isLeftBound!==i?i:H.isCollinear(m.prevPrevVertex(e).pt,e.bot,e.top)?!0:H.crossProductSign(m.prevPrevVertex(e).pt,n.bot,m.prevPrevVertex(n).pt)>0===i}isJoined(e){return e.joinWith!==Le.None}split(e,n){e.joinWith===Le.Right?(e.joinWith=Le.None,e.nextInAEL.joinWith=Le.None,this.addLocalMinPoly(e,e.nextInAEL,n,!0)):(e.joinWith=Le.None,e.prevInAEL.joinWith=Le.None,this.addLocalMinPoly(e.prevInAEL,e,n,!0))}setSides(e,n,r){e.frontEdge=n,e.backEdge=r}findEdgeWithMatchingLocMin(e){let n=e.nextInAEL;for(;n!==null;){if(n.localMin?.equals(e.localMin))return n;!m.isHorizontal(n)&&!(e.bot.x===n.bot.x&&e.bot.y===n.bot.y)?n=null:n=n.nextInAEL}for(n=e.prevInAEL;n!==null;){if(n.localMin?.equals(e.localMin))return n;if(!m.isHorizontal(n)&&!(e.bot.x===n.bot.x&&e.bot.y===n.bot.y))return null;n=n.prevInAEL}return n}addOutPt(e,n){let r=e.outrec,s=m.isFront(e),i=r.pts,o=i.next;if(s&&n.x===i.pt.x&&n.y===i.pt.y)return i;if(!s&&n.x===o.pt.x&&n.y===o.pt.y)return o;let a=new tt(n,r);return o.prev=a,a.prev=i,a.next=o,i.next=a,s&&(r.pts=a),a}addLocalMaxPoly(e,n,r){if(this.isJoined(e)&&this.split(e,r),this.isJoined(n)&&this.split(n,r),m.isFront(e)===m.isFront(n))if(m.isOpenEnd(e))this.swapFrontBackSides(e.outrec);else if(m.isOpenEnd(n))this.swapFrontBackSides(n.outrec);else return this.succeeded=!1,null;let s=this.addOutPt(e,r);if(e.outrec===n.outrec){let i=e.outrec;if(i.pts=s,this.usingPolytree){let o=m.getPrevHotEdge(e);o===null?i.owner=null:this.setOwner(i,o.outrec)}this.uncoupleOutRec(e)}else m.isOpen(e)?e.windDx<0?this.joinOutrecPaths(e,n):this.joinOutrecPaths(n,e):e.outrec.idx<n.outrec.idx?this.joinOutrecPaths(e,n):this.joinOutrecPaths(n,e);return s}swapFrontBackSides(e){let n=e.frontEdge;e.frontEdge=e.backEdge,e.backEdge=n,e.pts=e.pts.next}setOwner(e,n){for(;n.owner!==null&&n.owner.pts===null;)n.owner=n.owner.owner;let r=n;for(;r!==null&&r!==e;)r=r.owner;r!==null&&(n.owner=e.owner),e.owner=n}uncoupleOutRec(e){let n=e.outrec;n!==null&&(n.frontEdge.outrec=null,n.backEdge.outrec=null,n.frontEdge=null,n.backEdge=null)}joinOutrecPaths(e,n){let r=e.outrec.pts,s=n.outrec.pts,i=r.next,o=s.next;m.isFront(e)?(o.prev=r,r.next=o,s.next=i,i.prev=s,e.outrec.pts=s,e.outrec.frontEdge=n.outrec.frontEdge,e.outrec.frontEdge!==null&&(e.outrec.frontEdge.outrec=e.outrec)):(i.prev=s,s.next=i,r.next=o,o.prev=r,e.outrec.backEdge=n.outrec.backEdge,e.outrec.backEdge!==null&&(e.outrec.backEdge.outrec=e.outrec)),n.outrec.frontEdge=null,n.outrec.backEdge=null,n.outrec.pts=null,this.setOwner(n.outrec,e.outrec),m.isOpenEnd(e)&&(n.outrec.pts=e.outrec.pts,e.outrec.pts=null),e.outrec=null,n.outrec=null}swapOutrecs(e,n){let r=e.outrec,s=n.outrec;if(r===s){let i=r.frontEdge;r.frontEdge=r.backEdge,r.backEdge=i;return}r!==null&&(e===r.frontEdge?r.frontEdge=n:r.backEdge=n),s!==null&&(n===s.frontEdge?s.frontEdge=e:s.backEdge=e),e.outrec=s,n.outrec=r}disposeIntersectNodes(){this.intersectList.length=0}static ptsReallyClose(e,n){return Math.abs(e.x-n.x)<2&&Math.abs(e.y-n.y)<2}static isVerySmallTriangle(e){return e.next.next===e.prev&&(m.ptsReallyClose(e.prev.pt,e.next.pt)||m.ptsReallyClose(e.pt,e.next.pt)||m.ptsReallyClose(e.pt,e.prev.pt))}static buildPath(e,n,r,s){if(e===null||e.next===e||!r&&e.next===e.prev)return!1;s.length=0;let i,o;for(n?(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)),n?o=o.prev:o=o.next;return s.length!==3||r||!m.isVerySmallTriangle(o)}buildPaths(e,n){e.length=0,n.length=0;let r=0;for(;r<this.outrecList.length;){let s=this.outrecList[r++];if(s.pts===null)continue;let i=[];s.isOpen?m.buildPath(s.pts,this.reverseSolution,!0,i)&&n.push(i):(this.cleanCollinear(s),m.buildPath(s.pts,this.reverseSolution,!1,i)&&e.push(i))}return!0}buildTree(e,n){e.clear(),n.length=0;let r=0;for(;r<this.outrecList.length;){let s=this.outrecList[r++];if(s.pts!==null){if(s.isOpen){let i=[];m.buildPath(s.pts,this.reverseSolution,!0,i)&&n.push(i);continue}this.checkBounds(s)&&this.recursiveCheckOwners(s,e)}}}checkBounds(e){return e.pts===null?!1:yt.isEmpty(e.bounds)?(this.cleanCollinear(e),e.pts===null||!m.buildPath(e.pts,this.reverseSolution,!1,e.path)?!1:(e.bounds=H.getBounds(e.path),!0)):!0}recursiveCheckOwners(e,n){if(!(e.polypath!==null||yt.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,n),e.polypath=e.owner.polypath.addChild(e.path)):e.polypath=n.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 n=e.pts,r=n;for(;;){if(r!==null&&H.isCollinear(r.prev.pt,r.pt,r.next.pt)&&(r.pt.x===r.prev.pt.x&&r.pt.y===r.prev.pt.y||r.pt.x===r.next.pt.x&&r.pt.y===r.next.pt.y||!this.preserveCollinear||H.dotProductSign(r.prev.pt,r.pt,r.next.pt)<0)){if(r===e.pts&&(e.pts=r.prev),r=this.disposeOutPt(r),!this.isValidClosedPath(r)){e.pts=null;return}n=r;continue}if(r===null||(r=r.next,r===n))break}this.fixSelfIntersects(e)}isValidClosedPath(e){return e!==null&&e.next!==e&&(e.next!==e.prev||!m.isVerySmallTriangle(e))}disposeOutPt(e){let n=e.next===e?null:e.next;return e.prev.next=e.next,e.next.prev=e.prev,n}fixSelfIntersects(e){let n=e.pts;if(n.prev!==n.next.next)for(;;){if(n.next&&n.next.next&&this.boundingBoxesOverlap(n.prev.pt,n.pt,n.next.pt,n.next.next.pt)&&H.segsIntersect(n.prev.pt,n.pt,n.next.pt,n.next.next.pt)){if((n===e.pts||n.next===e.pts)&&(e.pts=e.pts.prev),this.doSplitOp(e,n),e.pts===null)return;if(n=e.pts,n.prev===n.next.next)break;continue}if(n=n.next,n===e.pts)break}}doSplitOp(e,n){let r=n.prev,s=n.next.next;e.pts=r;let i=H.getLineIntersectPt(r.pt,n.pt,n.next.pt,s.pt);this.zCallbackInternal&&this.zCallbackInternal(r.pt,n.pt,n.next.pt,s.pt,i);let o=m.areaOutPt(r),a=o<Wt?-o:o;if(a<Vs){e.pts=null;return}let l=this.areaTriangle(i,n.pt,n.next.pt),u=l<Wt?-l:l;if(i.x===r.pt.x&&i.y===r.pt.y||i.x===s.pt.x&&i.y===s.pt.y)s.prev=r,r.next=s;else{let h=new tt(i,e);h.prev=r,h.next=s,s.prev=h,r.next=h}if(!(u>Ra)||!(u>a)&&l>Wt!=o>Wt)return;let c=this.newOutRec();c.owner=e.owner,n.outrec=c,n.next.outrec=c;let f=new tt(i,c);f.prev=n.next,f.next=n,c.pts=f,n.prev=f,n.next.next=f,this.usingPolytree&&(this.path1InsidePath2(r,f)?(c.splits===null&&(c.splits=[]),c.splits.push(e.idx)):(e.splits===null&&(e.splits=[]),e.splits.push(c.idx)))}static areaOutPt(e){let n=H.maxCoordForSafeAreaProduct,r=0,s=!0,i=e;do{let a=i.prev,l=i.pt;if(Math.abs(a.pt.x)>=n||Math.abs(a.pt.y)>=n||Math.abs(l.x)>=n||Math.abs(l.y)>=n){s=!1;break}r+=(a.pt.y+l.y)*(a.pt.x-l.x),i=i.next}while(i!==e);if(s)return BigInt(Math.round(r));let o=Wt;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 l=BigInt(a.pt.y)+BigInt(i.pt.y),u=BigInt(a.pt.x)-BigInt(i.pt.x);o+=l*u}else{let l=a.pt.y+i.pt.y,u=a.pt.x-i.pt.x;o+=BigInt(Math.round(l*u))}i=i.next}while(i!==e);return o}areaTriangle(e,n,r){let s=H.maxCoordForSafeAreaProduct;if(Math.abs(e.x)<s&&Math.abs(e.y)<s&&Math.abs(n.x)<s&&Math.abs(n.y)<s&&Math.abs(r.x)<s&&Math.abs(r.y)<s){let o=(r.y+e.y)*(r.x-e.x)+(e.y+n.y)*(e.x-n.x)+(n.y+r.y)*(n.x-r.x);return BigInt(Math.round(o))}if(Number.isSafeInteger(e.x)&&Number.isSafeInteger(e.y)&&Number.isSafeInteger(n.x)&&Number.isSafeInteger(n.y)&&Number.isSafeInteger(r.x)&&Number.isSafeInteger(r.y)){let o=(BigInt(r.y)+BigInt(e.y))*(BigInt(r.x)-BigInt(e.x)),a=(BigInt(e.y)+BigInt(n.y))*(BigInt(e.x)-BigInt(n.x)),l=(BigInt(n.y)+BigInt(r.y))*(BigInt(n.x)-BigInt(r.x));return o+a+l}let i=(r.y+e.y)*(r.x-e.x)+(e.y+n.y)*(e.x-n.x)+(n.y+r.y)*(n.x-r.x);return BigInt(Math.round(i))}isValidOwner(e,n){for(;n!==null&&n!==e;)n=n.owner;return n===null}containsRect(e,n){return n.left>=e.left&&n.right<=e.right&&n.top>=e.top&&n.bottom<=e.bottom}checkSplitOwner(e,n){for(let r=0;r<n.length;r++){let s=this.outrecList[n[r]];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(m,"openPathsEnabled",!0);var An=m,$e=class extends An{constructor(){super(...arguments);b(this,"zCallback")}getZCallback(){return this.zCallback}addPath(n,r,s=!1){super.addPath(n,r,s)}addReuseableData(n){super.addReuseableData(n)}addPaths(n,r,s=!1){super.addPaths(n,r,s)}addSubject(n){this.addPaths(n,ke.Subject)}addOpenSubject(n){this.addPaths(n,ke.Subject,!0)}addClip(n){this.addPaths(n,ke.Clip)}execute(n,r,s,i){if(Array.isArray(s)){let o=s,a=i;o.length=0,a&&(a.length=0);try{this.executeInternal(n,r),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(n,r),this.buildTree(o,a||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}}};var Lr={area(t){return H.area(t)},areaD(t){let e=0,n=t.length;if(n<3)return 0;let r=t[n-1];for(let s of t)e+=(r.y+s.y)*(r.x-s.x),r=s;return e*.5},scalePath64(t,e){let n=H.maxSafeCoordinateForScale(e),r=[];for(let s of t)H.checkSafeScaleValue(s.x,n,"scalePath64"),H.checkSafeScaleValue(s.y,n,"scalePath64"),r.push({x:Math.round(s.x*e),y:Math.round(s.y*e)});return r},scalePaths64(t,e){let n=[];for(let r of t)n.push(Lr.scalePath64(r,e));return n},scalePathD(t,e){let n=[];for(let r of t)n.push({x:r.x*e,y:r.y*e});return n},scalePathsD(t,e){let n=[];for(let r of t)n.push(Lr.scalePathD(r,e));return n}};var Te;(function(t){t[t.Miter=0]="Miter",t[t.Square=1]="Square",t[t.Bevel=2]="Bevel",t[t.Round=3]="Round"})(Te||(Te={}));var ce;(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"})(ce||(ce={}));var Tr=class{constructor(e,n,r=ce.Polygon){b(this,"inPaths");b(this,"joinType");b(this,"endType");b(this,"pathsReversed");b(this,"lowestPathIdx");this.joinType=n,this.endType=r;let s=r===ce.Polygon||r===ce.Joined;this.inPaths=[];for(let i of e)this.inPaths.push(bt.stripDuplicates(i,s));if(r===ce.Polygon){let i=bt.getLowestPathInfo(this.inPaths);this.lowestPathIdx=i.idx,this.pathsReversed=this.lowestPathIdx>=0&&i.isNegArea}else this.lowestPathIdx=-1,this.pathsReversed=!1}},ue=class ue{constructor(e=2,n=0,r=!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",Te.Bevel);b(this,"endType",ce.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,n,r,s,i)=>{(e.z||0)!==0&&(e.z===r.z||e.z===s.z)?i.z=e.z:(r.z||0)!==0&&r.z===n.z?i.z=r.z:(n.z||0)!==0&&n.z===s.z?i.z=n.z:this.zCallback&&this.zCallback(e,n,r,s,i)});this.miterLimit=e,this.arcTolerance=n,this.mergeGroups=!0,this.preserveCollinear=r,this.reverseSolution=s}clear(){this.groupList.length=0}addPath(e,n,r){if(e.length===0)return;let s=[e];this.addPaths(s,n,r)}addPaths(e,n,r){e.length!==0&&this.groupList.push(new Tr(e,n,r))}calcSolutionCapacity(){let e=0;for(let n of this.groupList)e+=n.endType===ce.Joined?n.inPaths.length*2:n.inPaths.length;return e}checkPathsReversed(){let e=!1;for(let n of this.groupList)if(n.endType===ce.Polygon){e=n.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/ue.sqr(this.miterLimit);for(let i of this.groupList)this.doGroupOffset(i);if(this.groupList.length===0)return;let n=this.checkPathsReversed(),r=n?X.Negative:X.Positive,s=new $e;s.preserveCollinear=this.preserveCollinear,s.reverseSolution=this.reverseSolution!==n,s.zCallback=this.ZCB,s.addSubject(this.solution),this.solutionTree!==null?s.execute(ee.Union,r,this.solutionTree):s.execute(ee.Union,r,this.solution)}execute(e,n){if(Array.isArray(n)){let r=n;r.length=0,this.solution=r,this.executeInternal(e)}else{let r=n;r.clear(),this.solutionTree=r,this.solution=[],this.executeInternal(e)}}executeWithCallback(e,n){this.deltaCallback=e,this.execute(1,n)}static getUnitNormal(e,n){let r=n.x-e.x,s=n.y-e.y;if(r===0&&s===0)return{x:0,y:0};let i=1/Math.sqrt(r*r+s*s);return{x:s*i,y:-r*i}}static getLowestPathInfo(e){let n=-1,r=!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=ue.area(e[i]),o===0)break;r=o<0}n=i,s.x=a.x,s.y=a.y}}return{idx:n,isNegArea:r}}static translatePoint(e,n,r){return{x:e.x+n,y:e.y+r,z:e.z}}static reflectPoint(e,n){return{x:n.x+(n.x-e.x),y:n.y+(n.y-e.y),z:e.z}}static almostZero(e,n=.001){return Math.abs(e)<n}static hypotenuse(e,n){return Math.sqrt(e*e+n*n)}static normalizeVector(e){let n=ue.hypotenuse(e.x,e.y);if(ue.almostZero(n))return{x:0,y:0};let r=1/n;return{x:e.x*r,y:e.y*r}}static getAvgUnitVector(e,n){return ue.normalizeVector({x:e.x+n.x,y:e.y+n.y})}static intersectPoint(e,n,r,s){if(H.isAlmostZero(e.x-n.x)){if(H.isAlmostZero(r.x-s.x))return{x:0,y:0};let i=(s.y-r.y)/(s.x-r.x),o=r.y-i*r.x;return{x:e.x,y:i*e.x+o}}if(H.isAlmostZero(r.x-s.x)){let i=(n.y-e.y)/(n.x-e.x),o=e.y-i*e.x;return{x:r.x,y:i*r.x+o}}else{let i=(n.y-e.y)/(n.x-e.x),o=e.y-i*e.x,a=(s.y-r.y)/(s.x-r.x),l=r.y-a*r.x;if(H.isAlmostZero(i-a))return{x:0,y:0};let u=(l-o)/(i-a);return{x:u,y:i*u+o}}}getPerpendic(e,n){return{x:Math.round(e.x+n.x*this.groupDelta),y:Math.round(e.y+n.y*this.groupDelta),z:e.z||0}}getPerpendicD(e,n){return{x:e.x+n.x*this.groupDelta,y:e.y+n.y*this.groupDelta,z:e.z||0}}doBevel(e,n,r){let s,i,o=e[n].z||0;if(n===r){let a=Math.abs(this.groupDelta);s={x:Math.round(e[n].x-a*this.normals[n].x),y:Math.round(e[n].y-a*this.normals[n].y),z:o},i={x:Math.round(e[n].x+a*this.normals[n].x),y:Math.round(e[n].y+a*this.normals[n].y),z:o}}else s={x:Math.round(e[n].x+this.groupDelta*this.normals[r].x),y:Math.round(e[n].y+this.groupDelta*this.normals[r].y),z:o},i={x:Math.round(e[n].x+this.groupDelta*this.normals[n].x),y:Math.round(e[n].y+this.groupDelta*this.normals[n].y),z:o};this.pathOut.push(s),this.pathOut.push(i)}doSquare(e,n,r){let s;n===r?s={x:this.normals[n].y,y:-this.normals[n].x}:s=ue.getAvgUnitVector({x:-this.normals[r].y,y:this.normals[r].x},{x:this.normals[n].y,y:-this.normals[n].x});let i=Math.abs(this.groupDelta),o={x:e[n].x,y:e[n].y,z:e[n].z||0};o=ue.translatePoint(o,i*s.x,i*s.y);let a=ue.translatePoint(o,this.groupDelta*s.y,this.groupDelta*-s.x),l=ue.translatePoint(o,this.groupDelta*-s.y,this.groupDelta*s.x),u=this.getPerpendicD(e[r],this.normals[r]);if(n===r){let c={x:u.x+s.x*this.groupDelta,y:u.y+s.y*this.groupDelta},f=ue.intersectPoint(a,l,u,c);f.z=o.z,this.pathOut.push(Ye.fromPointD(ue.reflectPoint(f,o))),this.pathOut.push(Ye.fromPointD(f))}else{let c=this.getPerpendicD(e[n],this.normals[r]),f=ue.intersectPoint(a,l,u,c);f.z=o.z,this.pathOut.push(Ye.fromPointD(f)),this.pathOut.push(Ye.fromPointD(ue.reflectPoint(f,o)))}}doMiter(e,n,r,s){let i=this.groupDelta/(s+1);this.pathOut.push({x:Math.round(e[n].x+(this.normals[r].x+this.normals[n].x)*i),y:Math.round(e[n].y+(this.normals[r].y+this.normals[n].y)*i),z:e[n].z||0})}doRound(e,n,r,s){if(this.deltaCallback!==null){let u=Math.abs(this.groupDelta),c=this.arcTolerance>.01?this.arcTolerance:u*ue.arc_const,f=Math.PI/Math.acos(1-c/u);this.stepSin=Math.sin(2*Math.PI/f),this.stepCos=Math.cos(2*Math.PI/f),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=f/(2*Math.PI)}let i=e[n],o=i.z||0,a={x:this.normals[r].x*this.groupDelta,y:this.normals[r].y*this.groupDelta};n===r&&Ln.negate(a),this.pathOut.push({x:Math.round(i.x+a.x),y:Math.round(i.y+a.y),z:o});let l=Math.ceil(this.stepsPerRad*Math.abs(s));for(let u=1;u<l;u++)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[n],this.normals[n]))}buildNormals(e){let n=e.length;if(this.normals.length=0,n!==0){for(let r=0;r<n-1;r++)this.normals.push(ue.getUnitNormal(e[r],e[r+1]));this.normals.push(ue.getUnitNormal(e[n-1],e[0]))}}offsetPoint(e,n,r,s){if(Ye.equals(n[r],n[s]))return;let i=H.crossProductD(this.normals[r],this.normals[s]),o=H.dotProductD(this.normals[r],this.normals[s]);if(i>1?i=1:i<-1&&(i=-1),this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(n,this.normals,r,s),e.pathsReversed&&(this.groupDelta=-this.groupDelta)),Math.abs(this.groupDelta)<ue.Tolerance){this.pathOut.push(n[r]);return}if(o>-.999&&i*this.groupDelta<0)this.pathOut.push(this.getPerpendic(n[r],this.normals[s])),this.pathOut.push(n[r]),this.pathOut.push(this.getPerpendic(n[r],this.normals[r]));else if(o>.999&&this.joinType!==Te.Round)this.doMiter(n,r,s,o);else switch(this.joinType){case Te.Miter:o>this.mitLimSqr-1?this.doMiter(n,r,s,o):this.doSquare(n,r,s);break;case Te.Round:this.doRound(n,r,s,Math.atan2(i,o));break;case Te.Bevel:this.doBevel(n,r,s);break;default:this.doSquare(n,r,s);break}}offsetPolygon(e,n){this.pathOut=[];let r=n.length,s=r-1;for(let i=0;i<r;i++)this.offsetPoint(e,n,i,s),s=i;this.solution.push(this.pathOut)}offsetOpenJoined(e,n){this.offsetPolygon(e,n);let r=[...n].reverse();this.buildNormals(r),this.offsetPolygon(e,r)}offsetOpenPath(e,n){this.pathOut=[];let r=n.length-1;if(this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(n,this.normals,0,0)),Math.abs(this.groupDelta)<ue.Tolerance)this.pathOut.push(n[0]);else switch(this.endType){case ce.Butt:this.doBevel(n,0,0);break;case ce.Round:this.doRound(n,0,0,Math.PI);break;default:this.doSquare(n,0,0);break}for(let s=1,i=0;s<r;s++)this.offsetPoint(e,n,s,i),i=s;for(let s=r;s>0;s--)this.normals[s]={x:-this.normals[s-1].x,y:-this.normals[s-1].y};if(this.normals[0]=this.normals[r],this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(n,this.normals,r,r)),Math.abs(this.groupDelta)<ue.Tolerance)this.pathOut.push(n[r]);else switch(this.endType){case ce.Butt:this.doBevel(n,r,r);break;case ce.Round:this.doRound(n,r,r,Math.PI);break;default:this.doSquare(n,r,r);break}for(let s=r-1,i=r;s>0;s--)this.offsetPoint(e,n,s,i),i=s;this.solution.push(this.pathOut)}doGroupOffset(e){e.endType===ce.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 n=Math.abs(this.groupDelta);if(this.joinType=e.joinType,this.endType=e.endType,e.joinType===Te.Round||e.endType===ce.Round){let r=this.arcTolerance>.01?this.arcTolerance:n*ue.arc_const,s=Math.PI/Math.acos(1-r/n);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 r of e.inPaths){this.pathOut=[];let s=r.length;if(s===1){let i=r[0];this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(r,this.normals,0,0),e.pathsReversed&&(this.groupDelta=-this.groupDelta));let o=i.z||0;if(e.endType===ce.Round){let a=Math.ceil(this.stepsPerRad*2*Math.PI);if(this.pathOut=ue.ellipse(i,Math.abs(this.groupDelta),Math.abs(this.groupDelta),a),o!==0)for(let l=0;l<this.pathOut.length;l++)this.pathOut[l].z=o}else{let a=Math.ceil(Math.abs(this.groupDelta)),l={left:i.x-a,top:i.y-a,right:i.x+a,bottom:i.y+a};this.pathOut=[{x:l.left,y:l.top,z:o},{x:l.right,y:l.top,z:o},{x:l.right,y:l.bottom,z:o},{x:l.left,y:l.bottom,z:o}]}this.solution.push(this.pathOut);continue}switch(s===2&&e.endType===ce.Joined&&(this.endType=e.joinType===Te.Round?ce.Round:ce.Square),this.buildNormals(r),this.endType){case ce.Polygon:this.offsetPolygon(e,r);break;case ce.Joined:this.offsetOpenJoined(e,r);break;default:this.offsetOpenPath(e,r);break}}}static stripDuplicates(e,n){let r=e.length,s=[];if(r===0)return s;let i=e[0];s.push(i);for(let o=1;o<r;o++)Ye.equals(i,e[o])||(i=e[o],s.push(i));return n&&Ye.equals(i,s[0])&&s.pop(),s}static area(e){return H.area(e)}static sqr(e){return e*e}static ellipse(e,n,r=0,s=0){if(n<=0)return[];r<=0&&(r=n),s<=2&&(s=Math.ceil(Math.PI*Math.sqrt((n+r)/2)));let i=Math.sin(2*Math.PI/s),o=Math.cos(2*Math.PI/s),a=o,l=i,u=[{x:Math.round(e.x+n),y:e.y}];for(let c=1;c<s;++c){u.push({x:Math.round(e.x+n*a),y:Math.round(e.y+r*l)});let f=a*o-l*i;l=l*o+a*i,a=f}return u}};b(ue,"Tolerance",1e-12),b(ue,"arc_const",.002);var bt=ue;var _f=BigInt(2);function Cr(t,e,n){return typeof e=="number"?Ir(ee.Union,t,null,e):Ir(ee.Union,t,e,n)}function Ir(t,e,n,r){let s=[];if(e===null)return s;let i=new $e;return i.addPaths(e,ke.Subject),n!==null&&i.addPaths(n,ke.Clip),i.execute(t,r,s),s}function On(t,e,n,r,s=2,i=0){let o=new bt(s,i);o.addPaths(t,n,r);let a=[];return o.execute(e,a),a}var ot=1e4;function St(){return{layers:new Map,parts:[]}}function Ge(t,e="cut"){return{layers:new Map([[e,{regions:t,lines:[]}]]),parts:[]}}function Ft(t,e="cut"){return{layers:new Map([[e,{regions:[],lines:t}]]),parts:[]}}function _s(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 at=t=>t.map(e=>e.map(([n,r])=>({x:Math.round(n*ot),y:Math.round(r*ot)}))),Dt=t=>t.filter(e=>e.length>=2).map(e=>e.map(n=>[n.x/ot,n.y/ot]));function be(t,e="nonzero"){if(!t.length)return[];let n=e==="evenodd"?X.EvenOdd:X.NonZero;return Dt(Cr(at(t),n)).filter(r=>r.length>=3)}function Zs(t,e,n){if(!e.length)return[];let r=new $e;r.addSubject(at(e)),n.length&&r.addClip(at(n));let s=[];return r.execute(t,X.NonZero,s),Dt(s).filter(i=>i.length>=3)}var Fn=(t,e)=>e.length?Zs(ee.Difference,t,e):be(t),Dn=(t,e)=>Zs(ee.Intersection,t,e);function Jt(t,e,n){if(!t.length)return[];if(!e.length)return n==="outside"?t:[];let r=new $e;r.addOpenSubject(at(t)),r.addClip(at(e));let s=[],i=[];return r.execute(n==="inside"?ee.Intersection:ee.Difference,X.NonZero,s,i),Dt(i)}function Rn(t,e,n="round",r=.01){if(!t.length)return[];if(e===0)return be(t);let s=n==="round"?Te.Round:n==="square"?Te.Square:Te.Miter,i=On(at(be(t)),e*ot,s,ce.Polygon,2,r*ot);return Dt(i).filter(o=>o.length>=3)}function js(t,e){if(!t.length||e<=0)return[];let n=On(at(t),e/2*ot,Te.Round,ce.Round,2,.01*ot);return Dt(n)}function Ys(t){if(!t.length)return[];let e=new Kt,n=new $e;n.addSubject(at(t)),n.execute(ee.Union,X.NonZero,e);let r=[],s=i=>{for(let o=0;o<i.count;o++){let a=i.child(o),l=[a.poly];for(let u=0;u<a.count;u++){let c=a.child(u);l.push(c.poly),s(c)}r.push(Dt(l))}};return s(e),r}function lt(t){let e=0;for(let n=0,r=t.length-1;n<t.length;r=n++)e+=(t[r][0]+t[n][0])*(t[r][1]-t[n][1]);return-e/2}function Xs(t,[e,n]){return[t[0]*e+t[2]*n+t[4],t[1]*e+t[3]*n+t[5]]}function qs(t,e){let n=e[0]*e[3]-e[1]*e[2]<0,r=new Map;for(let[s,i]of t)r.set(s,{regions:i.regions.map(o=>{let a=o.map(l=>Xs(e,l));return n?a.reverse():a}),lines:i.lines.map(o=>o.map(a=>Xs(e,a)))});return r}function Un(t,e){return{layers:qs(t.layers,e),parts:t.parts.map(n=>({...n,layers:qs(n.layers,e)}))}}function Qt(t){let e=St();for(let n of t){for(let[r,s]of n.layers){let i=e.layers.get(r)??{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(r,i)}for(let r of n.parts)e.parts.push(r)}return e}function Ws(t,e){let n={regions:[],lines:[]};for(let r of t.values()){for(let s of r.regions)n.regions.push(s);for(let s of r.lines)n.lines.push(s)}return new Map([[e,n]])}function Nn(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:Ws(t.layers,e),parts:t.parts.map(n=>({...n,layers:Ws(n.layers,e)}))}}function Bn(t){let e=1/0,n=1/0,r=-1/0,s=-1/0;for(let i of t)for(let[o,a]of i)o<e&&(e=o),a<n&&(n=a),o>r&&(r=o),a>s&&(s=a);return e===1/0?null:[e,n,r,s]}function Mr(t,e){let n=[];for(let[r,s]of t)if(!e?.(r))for(let i of[...s.regions,...s.lines])n.push(i);return Bn(n)}function Ks(t){let e=[...t].sort((i,o)=>i[0]-o[0]||i[1]-o[1]);if(e.length<3)return e;let n=(i,o,a)=>(o[0]-i[0])*(a[1]-i[1])-(o[1]-i[1])*(a[0]-i[0]),r=[];for(let i of e){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],i)<=0;)r.pop();r.push(i)}let s=[];for(let i=e.length-1;i>=0;i--){let o=e[i];for(;s.length>=2&&n(s[s.length-2],s[s.length-1],o)<=0;)s.pop();s.push(o)}return s.pop(),r.pop(),r.concat(s)}function Js(t,e,n,r){return t<1e-9?3:e>0?Math.max(Math.floor(e),3):Math.max(Math.ceil(Math.min(360/n,t*2*Math.PI/r)),5)}function Gn(t,e,n){let r=[];for(let s=0;s<n;s++){let i=2*Math.PI*s/n;r.push([t*Math.cos(i),e*Math.sin(i)])}return r}function Qs(t,e,n,r){if(n=Math.min(n,t/2,e/2),n<=0)return[[0,0],[t,0],[t,e],[0,e]];let s=Math.max(1,Math.ceil(r(n)/4)),i=[],o=[[t-n,n,-90],[t-n,e-n,0],[n,e-n,90],[n,n,180]];for(let[a,l,u]of o)for(let c=0;c<=s;c++){let f=(u+90*c/s)*Math.PI/180;i.push([a+n*Math.cos(f),l+n*Math.sin(f)])}return i}function zn(t,e){let n=Math.round(t/e);return n%2===0&&(n+=t/e>n?1:-1),Math.max(3,n)}var en=(t,e,n,r)=>[[t,e],[n,e],[n,r],[t,r]];function za(t,e,n,r){if(e==="flat")return[];let s=zn(t,r),i=t/s,o=[];for(let a=0;a<s;a++)(e==="out"?a%2===1:a%2===0)&&o.push(en(a*i,-1,(a+1)*i,n));return o}function ei(t,e,n,r,s){let i=[([l,u])=>[l,u],([l,u])=>[t-u,l],([l,u])=>[t-l,e-u],([l,u])=>[u,e-l]],o=[t,e,t,e],a=[];return n.forEach((l,u)=>{for(let c of za(o[u],l,r,s))a.push(c.map(i[u]))}),Fn([en(0,0,t,e)],a)}function ti(t,e,n,r){let s=zn(t,r),i=t/s,o=[];for(let a=0;a<s;a++)(e==="out"?a%2===0:a%2===1)&&o.push(en(a*i,-n/2,(a+1)*i,n/2));return o}function ni(t,e,n,r,s){let i=en(-t/2,-1,t/2,e),o=en(-n/2,s,n/2,s+r);return[i,o]}function ri(t,e,n,r,s){let i=[],o=s+r,a=Math.floor(t/n),l=(t-a*n)/2;for(let u=0;u<=a;u++){let c=l+u*n,f=u%2===0?r:r-o/2;for(let h=f;h<e;h+=o){let p=Math.max(h,u%2===0?r:0),d=Math.min(h+s,e-(u%2===0?r:0));d-p>=r/2&&i.push([[c,p],[c,d]])}}return i}var tn=(t,e=!0)=>`line ${t.line}${e?`, column ${t.col}`:""}${t.file?` in <${t.file}>`:""}`;var D=class extends Error{constructor(n,r){super(r?`${n} (${tn(r)})`:n);this.echoes=[];this.warnings=[];this.trace=[];this.traceMore=0;this.name="KerfError",this.reason=n,r&&(this.line=r.line,this.col=r.col,this.file=r.file)}addFrame(n,r,s){let i=this.trace.find(o=>o.name===r&&o.line===s.line&&o.col===s.col&&o.file===s.file);i?i.count++:this.trace.length>=50?this.traceMore++:this.trace.push({kind:n,name:r,line:s.line,col:s.col,...s.file&&{file:s.file},count:1})}},Ha=["<=",">=","==","!=","&&","||","+","-","*","/","%","^","<",">","!","?",":","=",".",",",";","(",")","[","]","{","}","#"];function nn(t,e){let n=[],r=[],s=0,i=1,o=0,a=()=>({line:i,col:s-o+1,offset:s,...e&&{file:e}}),l=u=>{for(let c=0;c<u;c++)t[s]===`
|
|
6
|
+
`}},Cr=class t extends Ir{constructor(n=null){super(n);R(this,"polygon",null)}get poly(){return this.polygon}addChild(n){let r=new t(this);return r.polygon=n,this.children.push(r),r}child(n){if(n<0||n>=this.children.length)throw new Error("Index out of range");return this.children[n]}area(){let n=this.polygon===null?0:Cs.area(this.polygon);for(let r of this.children)n+=r.area();return n}};var Xn=class extends Cr{};var k=class k{constructor(){R(this,"cliptype",Te.NoClip);R(this,"fillrule",be.EvenOdd);R(this,"actives",null);R(this,"sel",null);R(this,"minimaList",[]);R(this,"intersectList",[]);R(this,"vertexList",[]);R(this,"outrecList",[]);R(this,"scanlineHeap",new Ts);R(this,"scanlineSet",new Set);R(this,"scanlineArr",[]);R(this,"useScanlineArray",!1);R(this,"horzSegList",[]);R(this,"horzJoinList",[]);R(this,"currentLocMin",0);R(this,"currentBotY",0);R(this,"curXValidAtTop",!1);R(this,"isSortedMinimaList",!1);R(this,"hasOpenPaths",!1);R(this,"usingPolytree",!1);R(this,"succeeded",!1);R(this,"zCallbackInternal");R(this,"preserveCollinear",!0);R(this,"reverseSolution",!1)}getZCallback(){}xyEqual(e,n){return e.x===n.x&&e.y===n.y}setZ(e,n,r){let s=this.zCallbackInternal;s&&(k.getPolyType(e)===qe.Subject?(this.xyEqual(r,e.bot)?r.z=e.bot.z??0:this.xyEqual(r,e.top)?r.z=e.top.z??0:this.xyEqual(r,n.bot)?r.z=n.bot.z??0:this.xyEqual(r,n.top)?r.z=n.top.z??0:r.z=0,s(e.bot,e.top,n.bot,n.top,r)):(this.xyEqual(r,n.bot)?r.z=n.bot.z??0:this.xyEqual(r,n.top)?r.z=n.top.z??0:this.xyEqual(r,e.bot)?r.z=e.bot.z??0:this.xyEqual(r,e.top)?r.z=e.top.z??0:r.z=0,s(n.bot,n.top,e.bot,e.top,r)))}static isOdd(e){return(e&1)!==0}static isHotEdge(e){return e.outrec!=null}static isOpen(e){return k.openPathsEnabled&&e.localMin.isOpen}static isOpenEnd(e){return k.openPathsEnabled&&e.localMin.isOpen&&k.isOpenEndVertex(e.vertexTop)}static isOpenEndVertex(e){return(e.flags&(Le.OpenStart|Le.OpenEnd))!==Le.None}static getPrevHotEdge(e){let n=e.prevInAEL;if(!k.openPathsEnabled){for(;n!==null&&!k.isHotEdge(n);)n=n.prevInAEL;return n}for(;n!==null&&(n.localMin.isOpen||!k.isHotEdge(n));)n=n.prevInAEL;return n}static isFront(e){return e===e.outrec.frontEdge}static getDx(e,n){let r=n.y-e.y;return r!==0?(n.x-e.x)/r:n.x>e.x?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY}static topX(e,n){return n===e.top.y||e.top.x===e.bot.x?e.top.x:n===e.bot.y?e.bot.x:ge.roundToEven(e.bot.x+e.dx*(n-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,n){return e.localMin.polytype===n.localMin.polytype}static setDx(e){e.dx=k.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&Le.LocalMax)!==Le.None}static isMaximaEdge(e){return(e.vertexTop.flags&Le.LocalMax)!==Le.None}static getMaximaPair(e){let n=e.nextInAEL;for(;n!==null;){if(n.vertexTop===e.vertexTop)return n;n=n.nextInAEL}return null}boundingBoxesOverlap(e,n,r,s){let i=e.x<n.x?e.x:n.x;if((r.x>s.x?r.x:s.x)<i)return!1;let a=e.x>n.x?e.x:n.x,l=r.x<s.x?r.x:s.x;if(a<l)return!1;let u=e.y<n.y?e.y:n.y;if((r.y>s.y?r.y:s.y)<u)return!1;let f=e.y>n.y?e.y:n.y,h=r.y<s.y?r.y:s.y;return f>=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,n)=>n.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 n=0,r=e.length;n<r;n++){let s=e[n];this.scanlineSet.add(s),this.scanlineHeap.push(s)}e.length=0,this.useScanlineArray=!1}insertScanline(e){if(this.useScanlineArray){let n=this.scanlineArr;for(let r=0,s=n.length;r<s;r++)if(n[r]===e)return;n.push(e),n.length>64&&this.upgradeScanlineStructureFromArray();return}this.scanlineSet.has(e)||(this.scanlineSet.add(e),this.scanlineHeap.push(e))}popScanline(){if(this.useScanlineArray){let n=this.scanlineArr,r=n.length;if(r===0)return null;let s=0,i=n[0];for(let o=1;o<r;o++){let a=n[o];a>i&&(i=a,s=o)}return n[s]=n[r-1],n.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,n,r=!1){let s=[e];this.addPaths(s,n,r)}addPaths(e,n,r=!1){r&&(this.hasOpenPaths=!0),this.isSortedMinimaList=!1,vn.addPathsToVertexList(e,n,r,this.minimaList,this.vertexList)}addReuseableData(e){if(e.minimaList.length!==0){this.isSortedMinimaList=!1;for(let n of e.minimaList)this.minimaList.push(new zn(n.vertex,n.polytype,n.isOpen)),n.isOpen&&(this.hasOpenPaths=!0)}}deleteFromAEL(e){let n=e.prevInAEL,r=e.nextInAEL;n===null&&r===null&&e!==this.actives||(n!==null?n.nextInAEL=r:this.actives=r,r!==null&&(r.prevInAEL=n))}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 n of this.vertexList){let r=n;do r.pt.x<e.left&&(e.left=r.pt.x),r.pt.x>e.right&&(e.right=r.pt.x),r.pt.y<e.top&&(e.top=r.pt.y),r.pt.y>e.bottom&&(e.bottom=r.pt.y),r=r.next;while(r!==n)}return en.isEmpty(e)?{left:0,top:0,right:0,bottom:0}:e}executeInternal(e,n){if(e===Te.NoClip)return;k.openPathsEnabled=this.hasOpenPaths,this.zCallbackInternal=this.getZCallback(),this.fillrule=n,this.cliptype=e,this.reset();let r=this.popScanline();if(r!==null){for(;this.succeeded;){this.insertLocalMinimaIntoAEL(r);let s;for(;(s=this.popHorz())!==null;)this.doHorizontal(s);this.horzSegList.length>0&&(this.convertHorzSegsToJoins(),this.horzSegList.length=0),this.currentBotY=r;let i=this.popScanline();if(i===null)break;for(r=i,this.doIntersections(r),this.doTopOfScanbeam(r);(s=this.popHorz())!==null;)this.doHorizontal(s)}this.succeeded&&this.processHorzJoins()}}insertLocalMinimaIntoAEL(e){for(;this.hasLocMinAtY(e);){let n=this.popLocalMinima(),r;(n.vertex.flags&Le.OpenStart)!==Le.None?r=null:(r=new Vn,r.bot=n.vertex.pt,r.curX=n.vertex.pt.x,r.windDx=-1,r.vertexTop=n.vertex.prev,r.top=n.vertex.prev.pt,r.outrec=null,r.localMin=n,k.setDx(r));let s;if((n.vertex.flags&Le.OpenEnd)!==Le.None?s=null:(s=new Vn,s.bot=n.vertex.pt,s.curX=n.vertex.pt.x,s.windDx=1,s.vertexTop=n.vertex.next,s.top=n.vertex.next.pt,s.outrec=null,s.localMin=n,k.setDx(s)),r!==null&&s!==null){if(k.isHorizontal(r)){if(k.isHeadingRightHorz(r)){let o=r;r=s,s=o}}else if(k.isHorizontal(s)){if(k.isHeadingLeftHorz(s)){let o=r;r=s,s=o}}else if(r.dx<s.dx){let o=r;r=s,s=o}}else r===null&&(r=s,s=null);let i;if(r.isLeftBound=!0,this.insertLeftEdge(r),k.openPathsEnabled?k.isOpen(r)?(this.setWindCountForOpenPathEdge(r),i=this.isContributingOpen(r)):(this.setWindCountForClosedPathEdge(r),i=this.isContributingClosed(r)):(this.setWindCountForClosedPathEdge(r),i=this.isContributingClosed(r)),s!==null){for(s.windCount=r.windCount,s.windCount2=r.windCount2,this.insertRightEdge(r,s),i&&(this.addLocalMinPoly(r,s,r.bot,!0),k.isHorizontal(r)||this.checkJoinLeft(r,r.bot));s.nextInAEL!==null&&this.isValidAelOrder(s.nextInAEL,s);)this.intersectEdges(s,s.nextInAEL,s.bot),this.swapPositionsInAEL(s,s.nextInAEL);k.isHorizontal(s)?this.pushHorz(s):(this.checkJoinRight(s,s.bot),this.insertScanline(s.top.y))}else i&&k.openPathsEnabled&&this.startOpenPath(r,r.bot);k.isHorizontal(r)?this.pushHorz(r):this.insertScanline(r.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(!k.openPathsEnabled){this.doHorizontalClosed(e);return}let n=k.isOpen(e),r=e.bot.y,s=n?this.getCurrYMaximaVertexOpen(e):this.getCurrYMaximaVertex(e),{isLeftToRight:i,leftX:o,rightX:a}=this.resetHorzDirection(e,s),l=o,u=a;if(k.isHotEdge(e)){let c=this.addOutPt(e,{x:e.curX,y:r});this.addToHorzSegList(c)}for(;;){let c=i?e.nextInAEL:e.prevInAEL;for(;c!==null;){if(c.vertexTop===s){if(k.isHotEdge(e)&&this.isJoined(c)&&this.split(c,c.top),k.isHotEdge(e)){for(;e.vertexTop!==s;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);i?this.addLocalMaxPoly(e,c,e.top):this.addLocalMaxPoly(c,e,e.top)}this.deleteFromAEL(c),this.deleteFromAEL(e);return}if(s!==e.vertexTop||k.isOpenEnd(e)){if(i&&c.curX>u||!i&&c.curX<l)break;if(c.curX===e.top.x&&!k.isHorizontal(c)){let p=k.nextVertex(e).pt;if(k.isOpen(c)&&!k.isSamePolyType(c,e)&&!k.isHotEdge(c)){if(i&&k.topX(c,p.y)>p.x||!i&&k.topX(c,p.y)<p.x)break}else if(i&&k.topX(c,p.y)>=p.x||!i&&k.topX(c,p.y)<=p.x)break}}let h={x:c.curX,y:r};i?(this.intersectEdges(e,c,h),this.swapPositionsInAEL(e,c),this.checkJoinLeft(c,h),e.curX=c.curX,c=e.nextInAEL):(this.intersectEdges(c,e,h),this.swapPositionsInAEL(c,e),this.checkJoinRight(c,h),e.curX=c.curX,c=e.prevInAEL),k.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(n&&k.isOpenEnd(e)){k.isHotEdge(e)&&(this.addOutPt(e,e.top),k.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e);return}if(k.nextVertex(e).pt.y!==e.top.y)break;k.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let f=this.resetHorzDirection(e,s);l=f.leftX,u=f.rightX}if(k.isHotEdge(e)){let c=this.addOutPt(e,e.top);this.addToHorzSegList(c)}this.updateEdgeIntoAEL(e)}doHorizontalClosed(e){let n=e.bot.y,r=this.getCurrYMaximaVertex(e),{isLeftToRight:s,leftX:i,rightX:o}=this.resetHorzDirection(e,r),a=i,l=o;if(k.isHotEdge(e)){let u=this.addOutPt(e,{x:e.curX,y:n});this.addToHorzSegList(u)}for(;;){let u=s?e.nextInAEL:e.prevInAEL;for(;u!==null;){if(u.vertexTop===r){if(k.isHotEdge(e)&&this.isJoined(u)&&this.split(u,u.top),k.isHotEdge(e)){for(;e.vertexTop!==r;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);s?this.addLocalMaxPoly(e,u,e.top):this.addLocalMaxPoly(u,e,e.top)}this.deleteFromAEL(u),this.deleteFromAEL(e);return}if(r!==e.vertexTop){if(s&&u.curX>l||!s&&u.curX<a)break;if(u.curX===e.top.x&&!k.isHorizontal(u)){let h=k.nextVertex(e).pt,p=k.topX(u,h.y);if(s&&p>=h.x||!s&&p<=h.x)break}}let f={x:u.curX,y:n};s?(this.intersectEdges(e,u,f),this.swapPositionsInAEL(e,u),this.checkJoinLeft(u,f),e.curX=u.curX,u=e.nextInAEL):(this.intersectEdges(u,e,f),this.swapPositionsInAEL(u,e),this.checkJoinRight(u,f),e.curX=u.curX,u=e.prevInAEL),k.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(k.nextVertex(e).pt.y!==e.top.y)break;k.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let c=this.resetHorzDirection(e,r);a=c.leftX,l=c.rightX}if(k.isHotEdge(e)){let u=this.addOutPt(e,e.top);this.addToHorzSegList(u)}this.updateEdgeIntoAEL(e)}convertHorzSegsToJoins(){let e=this.horzSegList,n=0;for(let r=0,s=e.length;r<s;r++){let i=e[r];this.updateHorzSegment(i)&&(e[n++]=i)}if(!(n<2)){e.length=n,this.horzSegList.sort(cu);for(let r=0;r<n-1;r++){let s=this.horzSegList[r];for(let i=r+1;i<n;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 l=new Hn(this.duplicateOp(s.leftOp,!0),this.duplicateOp(o.leftOp,!1));this.horzJoinList.push(l)}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 l=new Hn(this.duplicateOp(o.leftOp,!0),this.duplicateOp(s.leftOp,!1));this.horzJoinList.push(l)}}}}}updateHorzSegment(e){let n=e.leftOp,r=this.getRealOutRec(n.outrec),s=r.frontEdge!==null,i=n.pt.y,o=n,a=n;if(s){let u=r.pts,c=u.next;for(;o!==c&&o.prev.pt.y===i;)o=o.prev;for(;a!==u&&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 l=this.setHorzSegHeadingForward(e,o,a)&&e.leftOp.horz===null;return l?e.leftOp.horz=e:e.rightOp=null,l}setHorzSegHeadingForward(e,n,r){return n.pt.x===r.pt.x?!1:(n.pt.x<r.pt.x?(e.leftOp=n,e.rightOp=r,e.leftToRight=!0):(e.leftOp=r,e.rightOp=n,e.leftToRight=!1),!0)}duplicateOp(e,n){let r=new Rt(e.pt,e.outrec);return n?(r.next=e.next,r.next.prev=r,r.prev=e,e.next=r):(r.prev=e.prev,r.prev.next=r,r.next=e,e.prev=r),r}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 n=this.curXValidAtTop;this.curXValidAtTop=!1,this.sel=null;let r=this.actives;for(;r!==null;){if(r.top.y===e)if(r.curX=r.top.x,k.isMaximaEdge(r)){r=this.doMaxima(r);continue}else k.isHotEdge(r)&&this.addOutPt(r,r.top),this.updateEdgeIntoAEL(r),k.isHorizontal(r)&&this.pushHorz(r);else n||(r.curX=k.topX(r,e));r=r.nextInAEL}}processHorzJoins(){for(let e of this.horzJoinList){let n=this.getRealOutRec(e.op1.outrec),r=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,n===r){let o=this.newOutRec();o.pts=s,this.fixOutRecPts(o),n.pts.outrec===o&&(n.pts=e.op1,n.pts.outrec=n),this.usingPolytree?(this.path1InsidePath2(n.pts,o.pts)?([o.pts,n.pts]=[n.pts,o.pts],this.fixOutRecPts(n),this.fixOutRecPts(o),o.owner=n):this.path1InsidePath2(o.pts,n.pts)?o.owner=n:o.owner=n.owner,n.splits===null&&(n.splits=[]),n.splits.push(o.idx)):o.owner=n}else r.pts=null,this.usingPolytree?(this.setOwner(r,n),this.moveSplits(r,n)):r.owner=n}}fixOutRecPts(e){let n=e.pts;do n.outrec=e,n=n.next;while(n!==e.pts)}path1InsidePath2(e,n){let r=Se.IsOn,s=e;do{switch(this.pointInOpPolygon(s.pt,n)){case Se.IsOutside:if(r===Se.IsOutside)return!1;r=Se.IsOutside;break;case Se.IsInside:if(r===Se.IsInside)return!0;r=Se.IsInside;break;default:break}s=s.next}while(s!==e);return ge.path2ContainsPath1(this.getCleanPath(e),this.getCleanPath(n))}pointInOpPolygon(e,n){if(n===n.next||n.prev===n.next)return Se.IsOutside;let r=n;do{if(n.pt.y!==e.y)break;n=n.next}while(n!==r);if(n.pt.y===e.y)return Se.IsOutside;let s=n.pt.y<e.y,i=s,o=0;for(r=n.next;r!==n;){if(s)for(;r!==n&&r.pt.y<e.y;)r=r.next;else for(;r!==n&&r.pt.y>e.y;)r=r.next;if(r===n)break;if(r.pt.y===e.y){if(r.pt.x===e.x||r.pt.y===r.prev.pt.y&&e.x<r.prev.pt.x!=e.x<r.pt.x)return Se.IsOn;if(r=r.next,r===n)break;continue}if(r.pt.x<=e.x||r.prev.pt.x<=e.x)if(r.prev.pt.x<e.x&&r.pt.x<e.x)o=1-o;else{let a=ge.crossProductSign(r.prev.pt,r.pt,e);if(a===0)return Se.IsOn;a<0===s&&(o=1-o)}s=!s,r=r.next}if(s===i)return o===0?Se.IsOutside:Se.IsInside;{let a=ge.crossProductSign(r.prev.pt,r.pt,e);if(a===0)return Se.IsOn;a<0===s&&(o=1-o)}return o===0?Se.IsOutside:Se.IsInside}getCleanPath(e){let n=[],r=e;for(;r.next!==e&&(r.pt.x===r.next.pt.x&&r.pt.x===r.prev.pt.x||r.pt.y===r.next.pt.y&&r.pt.y===r.prev.pt.y);)r=r.next;n.push(r.pt);let s=r;for(r=r.next;r!==e;)(r.pt.x!==r.next.pt.x||r.pt.x!==s.pt.x)&&(r.pt.y!==r.next.pt.y||r.pt.y!==s.pt.y)&&(n.push(r.pt),s=r),r=r.next;return n}moveSplits(e,n){if(e.splits!==null){n.splits===null&&(n.splits=[]);for(let r of e.splits)r!==n.idx&&n.splits.push(r);e.splits=null}}buildIntersectList(e){if(this.actives?.nextInAEL===null)return!1;if(!this.adjustCurrXAndCopyToSEL(e))return this.curXValidAtTop=!0,!1;let n=this.sel;for(;n!==null&&n.jump!==null;){let r=null;for(;n!==null&&n.jump!==null;){let s=n,i=n.jump,o=i,a=i?.jump||null;for(n.jump=a;n!==o&&i!==a;)if(i.curX<n.curX){let l=i.prevInSEL;for(;this.addNewIntersectNode(l,i,e),l!==n;)l=l.prevInSEL;if(l=i,i=this.extractFromSEL(l),o=i,n!==null&&this.insert1Before2InSEL(l,n),n!==s)continue;s=l,s.jump=a,r===null?this.sel=s:r.jump=s}else n=n.nextInSEL;r=s,n=a}n=this.sel}return this.intersectList.length>0}processIntersectList(){this.intersectList.sort(fu);for(let e=0;e<this.intersectList.length;++e){if(!this.edgesAdjacentInAEL(this.intersectList[e])){let r=e+1;for(;!this.edgesAdjacentInAEL(this.intersectList[r]);)r++;[this.intersectList[r],this.intersectList[e]]=[this.intersectList[e],this.intersectList[r]]}let n=this.intersectList[e];this.intersectEdges(n.edge1,n.edge2,n.pt),this.swapPositionsInAEL(n.edge1,n.edge2),n.edge1.curX=n.pt.x,n.edge2.curX=n.pt.x,this.checkJoinLeft(n.edge2,n.pt,!0),this.checkJoinRight(n.edge1,n.pt,!0)}}edgesAdjacentInAEL(e){return e.edge1.nextInAEL===e.edge2||e.edge1.prevInAEL===e.edge2}adjustCurrXAndCopyToSEL(e){let n=this.actives;this.sel=n;let r=Number.NEGATIVE_INFINITY,s=!1;for(;n!==null;){n.prevInSEL=n.prevInAEL,n.nextInSEL=n.nextInAEL,n.jump=n.nextInSEL;let i=k.topX(n,e);n.curX=i,i<r&&(s=!0),r=i,n=n.nextInAEL}return s}doMaxima(e){let n=e.prevInAEL,r=e.nextInAEL;if(k.isOpenEnd(e))return k.isHotEdge(e)&&this.addOutPt(e,e.top),k.isHorizontal(e)||(k.isHotEdge(e)&&(k.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e)),r;let s=k.getMaximaPair(e);if(s===null)return r;for(this.isJoined(e)&&this.split(e,e.top),this.isJoined(s)&&this.split(s,s.top);r!==s;)this.intersectEdges(e,r,e.top),this.swapPositionsInAEL(e,r),r=e.nextInAEL;return k.isOpen(e)?(k.isHotEdge(e)&&this.addLocalMaxPoly(e,s,e.top),this.deleteFromAEL(s),this.deleteFromAEL(e),n!==null?n.nextInAEL:this.actives):(k.isHotEdge(e)&&this.addLocalMaxPoly(e,s,e.top),this.deleteFromAEL(e),this.deleteFromAEL(s),n!==null?n.nextInAEL:this.actives)}updateEdgeIntoAEL(e){if(e.bot=e.top,e.vertexTop=k.nextVertex(e),e.top=e.vertexTop.pt,e.curX=e.bot.x,k.setDx(e),this.isJoined(e)&&this.split(e,e.bot),k.isHorizontal(e)){k.openPathsEnabled?k.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,n){let r=!1,s=k.nextVertex(e).pt;for(;s.y===e.top.y&&!(n&&s.x<e.top.x!=e.bot.x<e.top.x||(e.vertexTop=k.nextVertex(e),e.top=s,r=!0,k.isMaximaVertex(e.vertexTop)));)s=k.nextVertex(e).pt;r&&k.setDx(e)}addToHorzSegList(e){e.outrec.isOpen||this.horzSegList.push(new Tr(e))}addNewIntersectNode(e,n,r){let s=ge.getLineIntersectPt(e.bot,e.top,n.bot,n.top);if(s===null&&(s={x:e.curX,y:r}),s.y>this.currentBotY||s.y<r){let o=Math.abs(e.dx),a=Math.abs(n.dx);o>100&&a>100?o>a?s=ge.getClosestPtOnSegment(s,e.bot,e.top):s=ge.getClosestPtOnSegment(s,n.bot,n.top):o>100?s=ge.getClosestPtOnSegment(s,e.bot,e.top):a>100?s=ge.getClosestPtOnSegment(s,n.bot,n.top):(s.y<r?s.y=r:s.y=this.currentBotY,o<a?s.x=k.topX(e,s.y):s.x=k.topX(n,s.y))}let i=ro(s,e,n);this.intersectList.push(i)}extractFromSEL(e){let n=e.nextInSEL;return n!==null&&(n.prevInSEL=e.prevInSEL),e.prevInSEL.nextInSEL=n,n}insert1Before2InSEL(e,n){e.prevInSEL=n.prevInSEL,e.prevInSEL!==null&&(e.prevInSEL.nextInSEL=e),e.nextInSEL=n,n.prevInSEL=e}getCurrYMaximaVertexOpen(e){let n=e.vertexTop;if(e.windDx>0)for(;n.next.pt.y===n.pt.y&&(n.flags&(Le.OpenEnd|Le.LocalMax))===Le.None;)n=n.next;else for(;n.prev.pt.y===n.pt.y&&(n.flags&(Le.OpenEnd|Le.LocalMax))===Le.None;)n=n.prev;return k.isMaximaVertex(n)||(n=null),n}getCurrYMaximaVertex(e){let n=e.vertexTop;if(e.windDx>0)for(;n.next.pt.y===n.pt.y;)n=n.next;else for(;n.prev.pt.y===n.pt.y;)n=n.prev;return k.isMaximaVertex(n)||(n=null),n}resetHorzDirection(e,n){if(e.bot.x===e.top.x){let r=e.curX,s=e.curX,i=e.nextInAEL;for(;i!==null&&i.vertexTop!==n;)i=i.nextInAEL;return{isLeftToRight:i!==null,leftX:r,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 n=e.outrec;return e===n.frontEdge?n.pts:n.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 n=this.actives;for(;n.nextInAEL!==null&&this.isValidAelOrder(n.nextInAEL,e);)n=n.nextInAEL;n.joinWith===Ye.Right&&(n=n.nextInAEL),e.nextInAEL=n.nextInAEL,n.nextInAEL!==null&&(n.nextInAEL.prevInAEL=e),e.prevInAEL=n,n.nextInAEL=e}}insertRightEdge(e,n){n.nextInAEL=e.nextInAEL,e.nextInAEL!==null&&(e.nextInAEL.prevInAEL=n),n.prevInAEL=e,e.nextInAEL=n}setWindCountForOpenPathEdge(e){let n=this.actives;if(this.fillrule===be.EvenOdd){let r=0,s=0;for(;n!==e;)k.getPolyType(n)===qe.Clip?s++:k.isOpen(n)||r++,n=n.nextInAEL;e.windCount=k.isOdd(r)?1:0,e.windCount2=k.isOdd(s)?1:0}else for(;n!==e;)k.getPolyType(n)===qe.Clip?e.windCount2+=n.windDx:k.isOpen(n)||(e.windCount+=n.windDx),n=n.nextInAEL}setWindCountForClosedPathEdge(e){let n=e.prevInAEL,r=k.getPolyType(e);if(!k.openPathsEnabled){for(;n!==null&&k.getPolyType(n)!==r;)n=n.prevInAEL;if(n===null?(e.windCount=e.windDx,n=this.actives):this.fillrule===be.EvenOdd?(e.windCount=e.windDx,e.windCount2=n.windCount2,n=n.nextInAEL):(n.windCount*n.windDx<0?Math.abs(n.windCount)>1?n.windDx*e.windDx<0?e.windCount=n.windCount:e.windCount=n.windCount+e.windDx:e.windCount=e.windDx:n.windDx*e.windDx<0?e.windCount=n.windCount:e.windCount=n.windCount+e.windDx,e.windCount2=n.windCount2,n=n.nextInAEL),this.fillrule===be.EvenOdd)for(;n!==e;)k.getPolyType(n)!==r&&(e.windCount2=e.windCount2===0?1:0),n=n.nextInAEL;else for(;n!==e;)k.getPolyType(n)!==r&&(e.windCount2+=n.windDx),n=n.nextInAEL;return}for(;n!==null&&(k.getPolyType(n)!==r||k.isOpen(n));)n=n.prevInAEL;if(n===null?(e.windCount=e.windDx,n=this.actives):this.fillrule===be.EvenOdd?(e.windCount=e.windDx,e.windCount2=n.windCount2,n=n.nextInAEL):(n.windCount*n.windDx<0?Math.abs(n.windCount)>1?n.windDx*e.windDx<0?e.windCount=n.windCount:e.windCount=n.windCount+e.windDx:e.windCount=k.isOpen(e)?1:e.windDx:n.windDx*e.windDx<0?e.windCount=n.windCount:e.windCount=n.windCount+e.windDx,e.windCount2=n.windCount2,n=n.nextInAEL),this.fillrule===be.EvenOdd)for(;n!==e;)k.getPolyType(n)!==r&&!k.isOpen(n)&&(e.windCount2=e.windCount2===0?1:0),n=n.nextInAEL;else for(;n!==e;)k.getPolyType(n)!==r&&!k.isOpen(n)&&(e.windCount2+=n.windDx),n=n.nextInAEL}isContributingOpen(e){let n,r;switch(this.fillrule){case be.Positive:r=e.windCount>0,n=e.windCount2>0;break;case be.Negative:r=e.windCount<0,n=e.windCount2<0;break;default:r=e.windCount!==0,n=e.windCount2!==0;break}switch(this.cliptype){case Te.Intersection:return n;case Te.Union:return!r&&!n;default:return!n}}isContributingClosed(e){switch(this.fillrule){case be.Positive:if(e.windCount!==1)return!1;break;case be.Negative:if(e.windCount!==-1)return!1;break;case be.NonZero:if(Math.abs(e.windCount)!==1)return!1;break}switch(this.cliptype){case Te.Intersection:return this.fillrule===be.Positive?e.windCount2>0:this.fillrule===be.Negative?e.windCount2<0:e.windCount2!==0;case Te.Union:return this.fillrule===be.Positive?e.windCount2<=0:this.fillrule===be.Negative?e.windCount2>=0:e.windCount2===0;case Te.Difference:{let n=this.fillrule===be.Positive?e.windCount2<=0:this.fillrule===be.Negative?e.windCount2>=0:e.windCount2===0;return k.getPolyType(e)===qe.Subject?n:!n}case Te.Xor:return!0;default:return!1}}addLocalMinPoly(e,n,r,s=!1){let i=this.newOutRec();if(e.outrec=i,n.outrec=i,k.isOpen(e))i.owner=null,i.isOpen=!0,e.windDx>0?this.setSides(i,e,n):this.setSides(i,n,e);else{i.isOpen=!1;let a=k.getPrevHotEdge(e);a!==null?(this.usingPolytree&&this.setOwner(i,a.outrec),i.owner=a.outrec,this.outrecIsAscending(a)===s?this.setSides(i,n,e):this.setSides(i,e,n)):(i.owner=null,s?this.setSides(i,e,n):this.setSides(i,n,e))}let o=new Rt(r,i);return i.pts=o,o}outrecIsAscending(e){return e===e.outrec.frontEdge}newOutRec(){let e=new Lr;return e.idx=this.outrecList.length,this.outrecList.push(e),e}startOpenPath(e,n){let r=this.newOutRec();r.isOpen=!0,e.windDx>0?(r.frontEdge=e,r.backEdge=null):(r.frontEdge=null,r.backEdge=e),e.outrec=r;let s=new Rt(n,r);return r.pts=s,s}checkJoinLeft(e,n,r=!1){let s=e.prevInAEL;s!==null&&(!r&&e.curX!==s.curX||!k.isHotEdge(e)||!k.isHotEdge(s)||k.isHorizontal(e)||k.isHorizontal(s)||k.isOpen(e)||k.isOpen(s)||(n.y<e.top.y+2||n.y<s.top.y+2)&&(e.bot.y>n.y||s.bot.y>n.y)||r&&this.perpendicDistFromLineSqrdGreaterThanQuarter(n,s.bot,s.top)||ge.isCollinear(e.top,n,s.top)&&(e.outrec.idx===s.outrec.idx?this.addLocalMaxPoly(s,e,n):e.outrec.idx<s.outrec.idx?this.joinOutrecPaths(e,s):this.joinOutrecPaths(s,e),s.joinWith=Ye.Right,e.joinWith=Ye.Left))}checkJoinRight(e,n,r=!1){let s=e.nextInAEL;s!==null&&(!r&&e.curX!==s.curX||!k.isHotEdge(e)||!k.isHotEdge(s)||k.isHorizontal(e)||k.isHorizontal(s)||k.isOpen(e)||k.isOpen(s)||(n.y<e.top.y+2||n.y<s.top.y+2)&&(e.bot.y>n.y||s.bot.y>n.y)||r&&this.perpendicDistFromLineSqrdGreaterThanQuarter(n,s.bot,s.top)||ge.isCollinear(e.top,n,s.top)&&(e.outrec.idx===s.outrec.idx?this.addLocalMaxPoly(e,s,n):e.outrec.idx<s.outrec.idx?this.joinOutrecPaths(e,s):this.joinOutrecPaths(s,e),e.joinWith=Ye.Right,s.joinWith=Ye.Left))}perpendicDistFromLineSqrdGreaterThanQuarter(e,n,r){let s=e.x-n.x,i=e.y-n.y,o=r.x-n.x,a=r.y-n.y;if(o===0&&a===0)return!1;let l=ge.maxCoordForSafeCrossSq;if(Math.abs(s)<l&&Math.abs(i)<l&&Math.abs(o)<l&&Math.abs(a)<l){let c=s*a-o*i;return c*c/(o*o+a*a)>.25}if(Number.isSafeInteger(s)&&Number.isSafeInteger(i)&&Number.isSafeInteger(o)&&Number.isSafeInteger(a)){let c=BigInt(s)*BigInt(a)-BigInt(o)*BigInt(i),f=c*c,h=BigInt(o)*BigInt(o)+BigInt(a)*BigInt(a);return no*f>h}let u=s*a-o*i;return u*u/(o*o+a*a)>.25}intersectEdges(e,n,r){let s;if(this.hasOpenPaths&&(k.isOpen(e)||k.isOpen(n))){if(k.isOpen(e)&&k.isOpen(n))return;if(k.isOpen(n)){let u=e;e=n,n=u}if(this.isJoined(n)&&this.split(n,r),this.cliptype===Te.Union){if(!k.isHotEdge(n))return}else if(n.localMin.polytype===qe.Subject)return;switch(this.fillrule){case be.Positive:if(n.windCount!==1)return;break;case be.Negative:if(n.windCount!==-1)return;break;default:if(Math.abs(n.windCount)!==1)return;break}if(k.isHotEdge(e))s=this.addOutPt(e,r),this.setZ(e,n,s.pt),k.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null;else if(r.x===e.localMin.vertex.pt.x&&r.y===e.localMin.vertex.pt.y&&!k.isOpenEndVertex(e.localMin.vertex)){let u=this.findEdgeWithMatchingLocMin(e);if(u!==null&&k.isHotEdge(u)){e.outrec=u.outrec,e.windDx>0?this.setSides(u.outrec,e,u):this.setSides(u.outrec,u,e);return}s=this.startOpenPath(e,r)}else s=this.startOpenPath(e,r);this.setZ(e,n,s.pt);return}this.isJoined(e)&&this.split(e,r),this.isJoined(n)&&this.split(n,r);let i,o;switch(e.localMin.polytype===n.localMin.polytype?this.fillrule===be.EvenOdd?(i=e.windCount,e.windCount=n.windCount,n.windCount=i):(e.windCount+n.windDx===0?e.windCount=-e.windCount:e.windCount+=n.windDx,n.windCount-e.windDx===0?n.windCount=-n.windCount:n.windCount-=e.windDx):(this.fillrule!==be.EvenOdd?e.windCount2+=n.windDx:e.windCount2=e.windCount2===0?1:0,this.fillrule!==be.EvenOdd?n.windCount2-=e.windDx:n.windCount2=n.windCount2===0?1:0),this.fillrule){case be.Positive:i=e.windCount,o=n.windCount;break;case be.Negative:i=-e.windCount,o=-n.windCount;break;default:i=Math.abs(e.windCount),o=Math.abs(n.windCount);break}let a=i===0||i===1,l=o===0||o===1;if(!(!k.isHotEdge(e)&&!a||!k.isHotEdge(n)&&!l))if(k.isHotEdge(e)&&k.isHotEdge(n))if(i!==0&&i!==1||o!==0&&o!==1||e.localMin.polytype!==n.localMin.polytype&&this.cliptype!==Te.Xor)s=this.addLocalMaxPoly(e,n,r),s&&this.setZ(e,n,s.pt);else if(k.isFront(e)||e.outrec===n.outrec){s=this.addLocalMaxPoly(e,n,r),s&&this.setZ(e,n,s.pt);let u=this.addLocalMinPoly(e,n,r);this.setZ(e,n,u.pt)}else{s=this.addOutPt(e,r),this.setZ(e,n,s.pt);let u=this.addOutPt(n,r);this.setZ(e,n,u.pt),this.swapOutrecs(e,n)}else if(k.isHotEdge(e))s=this.addOutPt(e,r),this.setZ(e,n,s.pt),this.swapOutrecs(e,n);else if(k.isHotEdge(n))s=this.addOutPt(n,r),this.setZ(e,n,s.pt),this.swapOutrecs(e,n);else{let u,c;switch(this.fillrule){case be.Positive:u=e.windCount2,c=n.windCount2;break;case be.Negative:u=-e.windCount2,c=-n.windCount2;break;default:u=Math.abs(e.windCount2),c=Math.abs(n.windCount2);break}if(!k.isSamePolyType(e,n))s=this.addLocalMinPoly(e,n,r),this.setZ(e,n,s.pt);else if(i===1&&o===1){switch(s=null,this.cliptype){case Te.Union:if(u>0&&c>0)return;s=this.addLocalMinPoly(e,n,r);break;case Te.Difference:(k.getPolyType(e)===qe.Clip&&u>0&&c>0||k.getPolyType(e)===qe.Subject&&u<=0&&c<=0)&&(s=this.addLocalMinPoly(e,n,r));break;case Te.Xor:s=this.addLocalMinPoly(e,n,r);break;default:if(u<=0||c<=0)return;s=this.addLocalMinPoly(e,n,r);break}s&&this.setZ(e,n,s.pt)}}}swapPositionsInAEL(e,n){let r=n.nextInAEL;r!==null&&(r.prevInAEL=e);let s=e.prevInAEL;s!==null&&(s.nextInAEL=n),n.prevInAEL=s,n.nextInAEL=e,e.prevInAEL=n,e.nextInAEL=r,n.prevInAEL===null&&(this.actives=n)}isValidAelOrder(e,n){if(n.curX!==e.curX)return n.curX>e.curX;let r=ge.crossProductSign(e.top,n.bot,n.top);if(r!==0)return r<0;if(!k.isMaximaEdge(e)&&e.top.y>n.top.y)return ge.crossProductSign(n.bot,e.top,k.nextVertex(e).pt)<=0;if(!k.isMaximaEdge(n)&&n.top.y>e.top.y)return ge.crossProductSign(n.bot,n.top,k.nextVertex(n).pt)>=0;let s=n.bot.y,i=n.isLeftBound;return e.bot.y!==s||e.localMin.vertex.pt.y!==s?n.isLeftBound:e.isLeftBound!==i?i:ge.isCollinear(k.prevPrevVertex(e).pt,e.bot,e.top)?!0:ge.crossProductSign(k.prevPrevVertex(e).pt,n.bot,k.prevPrevVertex(n).pt)>0===i}isJoined(e){return e.joinWith!==Ye.None}split(e,n){e.joinWith===Ye.Right?(e.joinWith=Ye.None,e.nextInAEL.joinWith=Ye.None,this.addLocalMinPoly(e,e.nextInAEL,n,!0)):(e.joinWith=Ye.None,e.prevInAEL.joinWith=Ye.None,this.addLocalMinPoly(e.prevInAEL,e,n,!0))}setSides(e,n,r){e.frontEdge=n,e.backEdge=r}findEdgeWithMatchingLocMin(e){let n=e.nextInAEL;for(;n!==null;){if(n.localMin?.equals(e.localMin))return n;!k.isHorizontal(n)&&!(e.bot.x===n.bot.x&&e.bot.y===n.bot.y)?n=null:n=n.nextInAEL}for(n=e.prevInAEL;n!==null;){if(n.localMin?.equals(e.localMin))return n;if(!k.isHorizontal(n)&&!(e.bot.x===n.bot.x&&e.bot.y===n.bot.y))return null;n=n.prevInAEL}return n}addOutPt(e,n){let r=e.outrec,s=k.isFront(e),i=r.pts,o=i.next;if(s&&n.x===i.pt.x&&n.y===i.pt.y)return i;if(!s&&n.x===o.pt.x&&n.y===o.pt.y)return o;let a=new Rt(n,r);return o.prev=a,a.prev=i,a.next=o,i.next=a,s&&(r.pts=a),a}addLocalMaxPoly(e,n,r){if(this.isJoined(e)&&this.split(e,r),this.isJoined(n)&&this.split(n,r),k.isFront(e)===k.isFront(n))if(k.isOpenEnd(e))this.swapFrontBackSides(e.outrec);else if(k.isOpenEnd(n))this.swapFrontBackSides(n.outrec);else return this.succeeded=!1,null;let s=this.addOutPt(e,r);if(e.outrec===n.outrec){let i=e.outrec;if(i.pts=s,this.usingPolytree){let o=k.getPrevHotEdge(e);o===null?i.owner=null:this.setOwner(i,o.outrec)}this.uncoupleOutRec(e)}else k.isOpen(e)?e.windDx<0?this.joinOutrecPaths(e,n):this.joinOutrecPaths(n,e):e.outrec.idx<n.outrec.idx?this.joinOutrecPaths(e,n):this.joinOutrecPaths(n,e);return s}swapFrontBackSides(e){let n=e.frontEdge;e.frontEdge=e.backEdge,e.backEdge=n,e.pts=e.pts.next}setOwner(e,n){for(;n.owner!==null&&n.owner.pts===null;)n.owner=n.owner.owner;let r=n;for(;r!==null&&r!==e;)r=r.owner;r!==null&&(n.owner=e.owner),e.owner=n}uncoupleOutRec(e){let n=e.outrec;n!==null&&(n.frontEdge.outrec=null,n.backEdge.outrec=null,n.frontEdge=null,n.backEdge=null)}joinOutrecPaths(e,n){let r=e.outrec.pts,s=n.outrec.pts,i=r.next,o=s.next;k.isFront(e)?(o.prev=r,r.next=o,s.next=i,i.prev=s,e.outrec.pts=s,e.outrec.frontEdge=n.outrec.frontEdge,e.outrec.frontEdge!==null&&(e.outrec.frontEdge.outrec=e.outrec)):(i.prev=s,s.next=i,r.next=o,o.prev=r,e.outrec.backEdge=n.outrec.backEdge,e.outrec.backEdge!==null&&(e.outrec.backEdge.outrec=e.outrec)),n.outrec.frontEdge=null,n.outrec.backEdge=null,n.outrec.pts=null,this.setOwner(n.outrec,e.outrec),k.isOpenEnd(e)&&(n.outrec.pts=e.outrec.pts,e.outrec.pts=null),e.outrec=null,n.outrec=null}swapOutrecs(e,n){let r=e.outrec,s=n.outrec;if(r===s){let i=r.frontEdge;r.frontEdge=r.backEdge,r.backEdge=i;return}r!==null&&(e===r.frontEdge?r.frontEdge=n:r.backEdge=n),s!==null&&(n===s.frontEdge?s.frontEdge=e:s.backEdge=e),e.outrec=s,n.outrec=r}disposeIntersectNodes(){this.intersectList.length=0}static ptsReallyClose(e,n){return Math.abs(e.x-n.x)<2&&Math.abs(e.y-n.y)<2}static isVerySmallTriangle(e){return e.next.next===e.prev&&(k.ptsReallyClose(e.prev.pt,e.next.pt)||k.ptsReallyClose(e.pt,e.next.pt)||k.ptsReallyClose(e.pt,e.prev.pt))}static buildPath(e,n,r,s){if(e===null||e.next===e||!r&&e.next===e.prev)return!1;s.length=0;let i,o;for(n?(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)),n?o=o.prev:o=o.next;return s.length!==3||r||!k.isVerySmallTriangle(o)}buildPaths(e,n){e.length=0,n.length=0;let r=0;for(;r<this.outrecList.length;){let s=this.outrecList[r++];if(s.pts===null)continue;let i=[];s.isOpen?k.buildPath(s.pts,this.reverseSolution,!0,i)&&n.push(i):(this.cleanCollinear(s),k.buildPath(s.pts,this.reverseSolution,!1,i)&&e.push(i))}return!0}buildTree(e,n){e.clear(),n.length=0;let r=0;for(;r<this.outrecList.length;){let s=this.outrecList[r++];if(s.pts!==null){if(s.isOpen){let i=[];k.buildPath(s.pts,this.reverseSolution,!0,i)&&n.push(i);continue}this.checkBounds(s)&&this.recursiveCheckOwners(s,e)}}}checkBounds(e){return e.pts===null?!1:en.isEmpty(e.bounds)?(this.cleanCollinear(e),e.pts===null||!k.buildPath(e.pts,this.reverseSolution,!1,e.path)?!1:(e.bounds=ge.getBounds(e.path),!0)):!0}recursiveCheckOwners(e,n){if(!(e.polypath!==null||en.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,n),e.polypath=e.owner.polypath.addChild(e.path)):e.polypath=n.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 n=e.pts,r=n;for(;;){if(r!==null&&ge.isCollinear(r.prev.pt,r.pt,r.next.pt)&&(r.pt.x===r.prev.pt.x&&r.pt.y===r.prev.pt.y||r.pt.x===r.next.pt.x&&r.pt.y===r.next.pt.y||!this.preserveCollinear||ge.dotProductSign(r.prev.pt,r.pt,r.next.pt)<0)){if(r===e.pts&&(e.pts=r.prev),r=this.disposeOutPt(r),!this.isValidClosedPath(r)){e.pts=null;return}n=r;continue}if(r===null||(r=r.next,r===n))break}this.fixSelfIntersects(e)}isValidClosedPath(e){return e!==null&&e.next!==e&&(e.next!==e.prev||!k.isVerySmallTriangle(e))}disposeOutPt(e){let n=e.next===e?null:e.next;return e.prev.next=e.next,e.next.prev=e.prev,n}fixSelfIntersects(e){let n=e.pts;if(n.prev!==n.next.next)for(;;){if(n.next&&n.next.next&&this.boundingBoxesOverlap(n.prev.pt,n.pt,n.next.pt,n.next.next.pt)&&ge.segsIntersect(n.prev.pt,n.pt,n.next.pt,n.next.next.pt)){if((n===e.pts||n.next===e.pts)&&(e.pts=e.pts.prev),this.doSplitOp(e,n),e.pts===null)return;if(n=e.pts,n.prev===n.next.next)break;continue}if(n=n.next,n===e.pts)break}}doSplitOp(e,n){let r=n.prev,s=n.next.next;e.pts=r;let i=ge.getLineIntersectPt(r.pt,n.pt,n.next.pt,s.pt);this.zCallbackInternal&&this.zCallbackInternal(r.pt,n.pt,n.next.pt,s.pt,i);let o=k.areaOutPt(r),a=o<$n?-o:o;if(a<no){e.pts=null;return}let l=this.areaTriangle(i,n.pt,n.next.pt),u=l<$n?-l:l;if(i.x===r.pt.x&&i.y===r.pt.y||i.x===s.pt.x&&i.y===s.pt.y)s.prev=r,r.next=s;else{let h=new Rt(i,e);h.prev=r,h.next=s,s.prev=h,r.next=h}if(!(u>uu)||!(u>a)&&l>$n!=o>$n)return;let c=this.newOutRec();c.owner=e.owner,n.outrec=c,n.next.outrec=c;let f=new Rt(i,c);f.prev=n.next,f.next=n,c.pts=f,n.prev=f,n.next.next=f,this.usingPolytree&&(this.path1InsidePath2(r,f)?(c.splits===null&&(c.splits=[]),c.splits.push(e.idx)):(e.splits===null&&(e.splits=[]),e.splits.push(c.idx)))}static areaOutPt(e){let n=ge.maxCoordForSafeAreaProduct,r=0,s=!0,i=e;do{let a=i.prev,l=i.pt;if(Math.abs(a.pt.x)>=n||Math.abs(a.pt.y)>=n||Math.abs(l.x)>=n||Math.abs(l.y)>=n){s=!1;break}r+=(a.pt.y+l.y)*(a.pt.x-l.x),i=i.next}while(i!==e);if(s)return BigInt(Math.round(r));let o=$n;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 l=BigInt(a.pt.y)+BigInt(i.pt.y),u=BigInt(a.pt.x)-BigInt(i.pt.x);o+=l*u}else{let l=a.pt.y+i.pt.y,u=a.pt.x-i.pt.x;o+=BigInt(Math.round(l*u))}i=i.next}while(i!==e);return o}areaTriangle(e,n,r){let s=ge.maxCoordForSafeAreaProduct;if(Math.abs(e.x)<s&&Math.abs(e.y)<s&&Math.abs(n.x)<s&&Math.abs(n.y)<s&&Math.abs(r.x)<s&&Math.abs(r.y)<s){let o=(r.y+e.y)*(r.x-e.x)+(e.y+n.y)*(e.x-n.x)+(n.y+r.y)*(n.x-r.x);return BigInt(Math.round(o))}if(Number.isSafeInteger(e.x)&&Number.isSafeInteger(e.y)&&Number.isSafeInteger(n.x)&&Number.isSafeInteger(n.y)&&Number.isSafeInteger(r.x)&&Number.isSafeInteger(r.y)){let o=(BigInt(r.y)+BigInt(e.y))*(BigInt(r.x)-BigInt(e.x)),a=(BigInt(e.y)+BigInt(n.y))*(BigInt(e.x)-BigInt(n.x)),l=(BigInt(n.y)+BigInt(r.y))*(BigInt(n.x)-BigInt(r.x));return o+a+l}let i=(r.y+e.y)*(r.x-e.x)+(e.y+n.y)*(e.x-n.x)+(n.y+r.y)*(n.x-r.x);return BigInt(Math.round(i))}isValidOwner(e,n){for(;n!==null&&n!==e;)n=n.owner;return n===null}containsRect(e,n){return n.left>=e.left&&n.right<=e.right&&n.top>=e.top&&n.bottom<=e.bottom}checkSplitOwner(e,n){for(let r=0;r<n.length;r++){let s=this.outrecList[n[r]];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}};R(k,"openPathsEnabled",!0);var Ar=k,Lt=class extends Ar{constructor(){super(...arguments);R(this,"zCallback")}getZCallback(){return this.zCallback}addPath(n,r,s=!1){super.addPath(n,r,s)}addReuseableData(n){super.addReuseableData(n)}addPaths(n,r,s=!1){super.addPaths(n,r,s)}addSubject(n){this.addPaths(n,qe.Subject)}addOpenSubject(n){this.addPaths(n,qe.Subject,!0)}addClip(n){this.addPaths(n,qe.Clip)}execute(n,r,s,i){if(Array.isArray(s)){let o=s,a=i;o.length=0,a&&(a.length=0);try{this.executeInternal(n,r),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(n,r),this.buildTree(o,a||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}}};var Cs={area(t){return ge.area(t)},areaD(t){let e=0,n=t.length;if(n<3)return 0;let r=t[n-1];for(let s of t)e+=(r.y+s.y)*(r.x-s.x),r=s;return e*.5},scalePath64(t,e){let n=ge.maxSafeCoordinateForScale(e),r=[];for(let s of t)ge.checkSafeScaleValue(s.x,n,"scalePath64"),ge.checkSafeScaleValue(s.y,n,"scalePath64"),r.push({x:Math.round(s.x*e),y:Math.round(s.y*e)});return r},scalePaths64(t,e){let n=[];for(let r of t)n.push(Cs.scalePath64(r,e));return n},scalePathD(t,e){let n=[];for(let r of t)n.push({x:r.x*e,y:r.y*e});return n},scalePathsD(t,e){let n=[];for(let r of t)n.push(Cs.scalePathD(r,e));return n}};var Ke;(function(t){t[t.Miter=0]="Miter",t[t.Square=1]="Square",t[t.Bevel=2]="Bevel",t[t.Round=3]="Round"})(Ke||(Ke={}));var Fe;(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"})(Fe||(Fe={}));var As=class{constructor(e,n,r=Fe.Polygon){R(this,"inPaths");R(this,"joinType");R(this,"endType");R(this,"pathsReversed");R(this,"lowestPathIdx");this.joinType=n,this.endType=r;let s=r===Fe.Polygon||r===Fe.Joined;this.inPaths=[];for(let i of e)this.inPaths.push(tn.stripDuplicates(i,s));if(r===Fe.Polygon){let i=tn.getLowestPathInfo(this.inPaths);this.lowestPathIdx=i.idx,this.pathsReversed=this.lowestPathIdx>=0&&i.isNegArea}else this.lowestPathIdx=-1,this.pathsReversed=!1}},Oe=class Oe{constructor(e=2,n=0,r=!1,s=!1){R(this,"groupList",[]);R(this,"pathOut",[]);R(this,"normals",[]);R(this,"solution",[]);R(this,"solutionTree",null);R(this,"groupDelta",0);R(this,"delta",0);R(this,"mitLimSqr",0);R(this,"stepsPerRad",0);R(this,"stepSin",0);R(this,"stepCos",0);R(this,"joinType",Ke.Bevel);R(this,"endType",Fe.Polygon);R(this,"arcTolerance",0);R(this,"mergeGroups",!0);R(this,"miterLimit",2);R(this,"preserveCollinear",!1);R(this,"reverseSolution",!1);R(this,"zCallback");R(this,"deltaCallback",null);R(this,"ZCB",(e,n,r,s,i)=>{(e.z||0)!==0&&(e.z===r.z||e.z===s.z)?i.z=e.z:(r.z||0)!==0&&r.z===n.z?i.z=r.z:(n.z||0)!==0&&n.z===s.z?i.z=n.z:this.zCallback&&this.zCallback(e,n,r,s,i)});this.miterLimit=e,this.arcTolerance=n,this.mergeGroups=!0,this.preserveCollinear=r,this.reverseSolution=s}clear(){this.groupList.length=0}addPath(e,n,r){if(e.length===0)return;let s=[e];this.addPaths(s,n,r)}addPaths(e,n,r){e.length!==0&&this.groupList.push(new As(e,n,r))}calcSolutionCapacity(){let e=0;for(let n of this.groupList)e+=n.endType===Fe.Joined?n.inPaths.length*2:n.inPaths.length;return e}checkPathsReversed(){let e=!1;for(let n of this.groupList)if(n.endType===Fe.Polygon){e=n.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/Oe.sqr(this.miterLimit);for(let i of this.groupList)this.doGroupOffset(i);if(this.groupList.length===0)return;let n=this.checkPathsReversed(),r=n?be.Negative:be.Positive,s=new Lt;s.preserveCollinear=this.preserveCollinear,s.reverseSolution=this.reverseSolution!==n,s.zCallback=this.ZCB,s.addSubject(this.solution),this.solutionTree!==null?s.execute(Te.Union,r,this.solutionTree):s.execute(Te.Union,r,this.solution)}execute(e,n){if(Array.isArray(n)){let r=n;r.length=0,this.solution=r,this.executeInternal(e)}else{let r=n;r.clear(),this.solutionTree=r,this.solution=[],this.executeInternal(e)}}executeWithCallback(e,n){this.deltaCallback=e,this.execute(1,n)}static getUnitNormal(e,n){let r=n.x-e.x,s=n.y-e.y;if(r===0&&s===0)return{x:0,y:0};let i=1/Math.sqrt(r*r+s*s);return{x:s*i,y:-r*i}}static getLowestPathInfo(e){let n=-1,r=!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=Oe.area(e[i]),o===0)break;r=o<0}n=i,s.x=a.x,s.y=a.y}}return{idx:n,isNegArea:r}}static translatePoint(e,n,r){return{x:e.x+n,y:e.y+r,z:e.z}}static reflectPoint(e,n){return{x:n.x+(n.x-e.x),y:n.y+(n.y-e.y),z:e.z}}static almostZero(e,n=.001){return Math.abs(e)<n}static hypotenuse(e,n){return Math.sqrt(e*e+n*n)}static normalizeVector(e){let n=Oe.hypotenuse(e.x,e.y);if(Oe.almostZero(n))return{x:0,y:0};let r=1/n;return{x:e.x*r,y:e.y*r}}static getAvgUnitVector(e,n){return Oe.normalizeVector({x:e.x+n.x,y:e.y+n.y})}static intersectPoint(e,n,r,s){if(ge.isAlmostZero(e.x-n.x)){if(ge.isAlmostZero(r.x-s.x))return{x:0,y:0};let i=(s.y-r.y)/(s.x-r.x),o=r.y-i*r.x;return{x:e.x,y:i*e.x+o}}if(ge.isAlmostZero(r.x-s.x)){let i=(n.y-e.y)/(n.x-e.x),o=e.y-i*e.x;return{x:r.x,y:i*r.x+o}}else{let i=(n.y-e.y)/(n.x-e.x),o=e.y-i*e.x,a=(s.y-r.y)/(s.x-r.x),l=r.y-a*r.x;if(ge.isAlmostZero(i-a))return{x:0,y:0};let u=(l-o)/(i-a);return{x:u,y:i*u+o}}}getPerpendic(e,n){return{x:Math.round(e.x+n.x*this.groupDelta),y:Math.round(e.y+n.y*this.groupDelta),z:e.z||0}}getPerpendicD(e,n){return{x:e.x+n.x*this.groupDelta,y:e.y+n.y*this.groupDelta,z:e.z||0}}doBevel(e,n,r){let s,i,o=e[n].z||0;if(n===r){let a=Math.abs(this.groupDelta);s={x:Math.round(e[n].x-a*this.normals[n].x),y:Math.round(e[n].y-a*this.normals[n].y),z:o},i={x:Math.round(e[n].x+a*this.normals[n].x),y:Math.round(e[n].y+a*this.normals[n].y),z:o}}else s={x:Math.round(e[n].x+this.groupDelta*this.normals[r].x),y:Math.round(e[n].y+this.groupDelta*this.normals[r].y),z:o},i={x:Math.round(e[n].x+this.groupDelta*this.normals[n].x),y:Math.round(e[n].y+this.groupDelta*this.normals[n].y),z:o};this.pathOut.push(s),this.pathOut.push(i)}doSquare(e,n,r){let s;n===r?s={x:this.normals[n].y,y:-this.normals[n].x}:s=Oe.getAvgUnitVector({x:-this.normals[r].y,y:this.normals[r].x},{x:this.normals[n].y,y:-this.normals[n].x});let i=Math.abs(this.groupDelta),o={x:e[n].x,y:e[n].y,z:e[n].z||0};o=Oe.translatePoint(o,i*s.x,i*s.y);let a=Oe.translatePoint(o,this.groupDelta*s.y,this.groupDelta*-s.x),l=Oe.translatePoint(o,this.groupDelta*-s.y,this.groupDelta*s.x),u=this.getPerpendicD(e[r],this.normals[r]);if(n===r){let c={x:u.x+s.x*this.groupDelta,y:u.y+s.y*this.groupDelta},f=Oe.intersectPoint(a,l,u,c);f.z=o.z,this.pathOut.push(Et.fromPointD(Oe.reflectPoint(f,o))),this.pathOut.push(Et.fromPointD(f))}else{let c=this.getPerpendicD(e[n],this.normals[r]),f=Oe.intersectPoint(a,l,u,c);f.z=o.z,this.pathOut.push(Et.fromPointD(f)),this.pathOut.push(Et.fromPointD(Oe.reflectPoint(f,o)))}}doMiter(e,n,r,s){let i=this.groupDelta/(s+1);this.pathOut.push({x:Math.round(e[n].x+(this.normals[r].x+this.normals[n].x)*i),y:Math.round(e[n].y+(this.normals[r].y+this.normals[n].y)*i),z:e[n].z||0})}doRound(e,n,r,s){if(this.deltaCallback!==null){let u=Math.abs(this.groupDelta),c=this.arcTolerance>.01?this.arcTolerance:u*Oe.arc_const,f=Math.PI/Math.acos(1-c/u);this.stepSin=Math.sin(2*Math.PI/f),this.stepCos=Math.cos(2*Math.PI/f),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=f/(2*Math.PI)}let i=e[n],o=i.z||0,a={x:this.normals[r].x*this.groupDelta,y:this.normals[r].y*this.groupDelta};n===r&&Er.negate(a),this.pathOut.push({x:Math.round(i.x+a.x),y:Math.round(i.y+a.y),z:o});let l=Math.ceil(this.stepsPerRad*Math.abs(s));for(let u=1;u<l;u++)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[n],this.normals[n]))}buildNormals(e){let n=e.length;if(this.normals.length=0,n!==0){for(let r=0;r<n-1;r++)this.normals.push(Oe.getUnitNormal(e[r],e[r+1]));this.normals.push(Oe.getUnitNormal(e[n-1],e[0]))}}offsetPoint(e,n,r,s){if(Et.equals(n[r],n[s]))return;let i=ge.crossProductD(this.normals[r],this.normals[s]),o=ge.dotProductD(this.normals[r],this.normals[s]);if(i>1?i=1:i<-1&&(i=-1),this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(n,this.normals,r,s),e.pathsReversed&&(this.groupDelta=-this.groupDelta)),Math.abs(this.groupDelta)<Oe.Tolerance){this.pathOut.push(n[r]);return}if(o>-.999&&i*this.groupDelta<0)this.pathOut.push(this.getPerpendic(n[r],this.normals[s])),this.pathOut.push(n[r]),this.pathOut.push(this.getPerpendic(n[r],this.normals[r]));else if(o>.999&&this.joinType!==Ke.Round)this.doMiter(n,r,s,o);else switch(this.joinType){case Ke.Miter:o>this.mitLimSqr-1?this.doMiter(n,r,s,o):this.doSquare(n,r,s);break;case Ke.Round:this.doRound(n,r,s,Math.atan2(i,o));break;case Ke.Bevel:this.doBevel(n,r,s);break;default:this.doSquare(n,r,s);break}}offsetPolygon(e,n){this.pathOut=[];let r=n.length,s=r-1;for(let i=0;i<r;i++)this.offsetPoint(e,n,i,s),s=i;this.solution.push(this.pathOut)}offsetOpenJoined(e,n){this.offsetPolygon(e,n);let r=[...n].reverse();this.buildNormals(r),this.offsetPolygon(e,r)}offsetOpenPath(e,n){this.pathOut=[];let r=n.length-1;if(this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(n,this.normals,0,0)),Math.abs(this.groupDelta)<Oe.Tolerance)this.pathOut.push(n[0]);else switch(this.endType){case Fe.Butt:this.doBevel(n,0,0);break;case Fe.Round:this.doRound(n,0,0,Math.PI);break;default:this.doSquare(n,0,0);break}for(let s=1,i=0;s<r;s++)this.offsetPoint(e,n,s,i),i=s;for(let s=r;s>0;s--)this.normals[s]={x:-this.normals[s-1].x,y:-this.normals[s-1].y};if(this.normals[0]=this.normals[r],this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(n,this.normals,r,r)),Math.abs(this.groupDelta)<Oe.Tolerance)this.pathOut.push(n[r]);else switch(this.endType){case Fe.Butt:this.doBevel(n,r,r);break;case Fe.Round:this.doRound(n,r,r,Math.PI);break;default:this.doSquare(n,r,r);break}for(let s=r-1,i=r;s>0;s--)this.offsetPoint(e,n,s,i),i=s;this.solution.push(this.pathOut)}doGroupOffset(e){e.endType===Fe.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 n=Math.abs(this.groupDelta);if(this.joinType=e.joinType,this.endType=e.endType,e.joinType===Ke.Round||e.endType===Fe.Round){let r=this.arcTolerance>.01?this.arcTolerance:n*Oe.arc_const,s=Math.PI/Math.acos(1-r/n);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 r of e.inPaths){this.pathOut=[];let s=r.length;if(s===1){let i=r[0];this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(r,this.normals,0,0),e.pathsReversed&&(this.groupDelta=-this.groupDelta));let o=i.z||0;if(e.endType===Fe.Round){let a=Math.ceil(this.stepsPerRad*2*Math.PI);if(this.pathOut=Oe.ellipse(i,Math.abs(this.groupDelta),Math.abs(this.groupDelta),a),o!==0)for(let l=0;l<this.pathOut.length;l++)this.pathOut[l].z=o}else{let a=Math.ceil(Math.abs(this.groupDelta)),l={left:i.x-a,top:i.y-a,right:i.x+a,bottom:i.y+a};this.pathOut=[{x:l.left,y:l.top,z:o},{x:l.right,y:l.top,z:o},{x:l.right,y:l.bottom,z:o},{x:l.left,y:l.bottom,z:o}]}this.solution.push(this.pathOut);continue}switch(s===2&&e.endType===Fe.Joined&&(this.endType=e.joinType===Ke.Round?Fe.Round:Fe.Square),this.buildNormals(r),this.endType){case Fe.Polygon:this.offsetPolygon(e,r);break;case Fe.Joined:this.offsetOpenJoined(e,r);break;default:this.offsetOpenPath(e,r);break}}}static stripDuplicates(e,n){let r=e.length,s=[];if(r===0)return s;let i=e[0];s.push(i);for(let o=1;o<r;o++)Et.equals(i,e[o])||(i=e[o],s.push(i));return n&&Et.equals(i,s[0])&&s.pop(),s}static area(e){return ge.area(e)}static sqr(e){return e*e}static ellipse(e,n,r=0,s=0){if(n<=0)return[];r<=0&&(r=n),s<=2&&(s=Math.ceil(Math.PI*Math.sqrt((n+r)/2)));let i=Math.sin(2*Math.PI/s),o=Math.cos(2*Math.PI/s),a=o,l=i,u=[{x:Math.round(e.x+n),y:e.y}];for(let c=1;c<s;++c){u.push({x:Math.round(e.x+n*a),y:Math.round(e.y+r*l)});let f=a*o-l*i;l=l*o+a*i,a=f}return u}};R(Oe,"Tolerance",1e-12),R(Oe,"arc_const",.002);var tn=Oe;var _d=BigInt(2);function Fs(t,e,n){return typeof e=="number"?Os(Te.Union,t,null,e):Os(Te.Union,t,e,n)}function Os(t,e,n,r){let s=[];if(e===null)return s;let i=new Lt;return i.addPaths(e,qe.Subject),n!==null&&i.addPaths(n,qe.Clip),i.execute(t,r,s),s}function Or(t,e,n,r,s=2,i=0){let o=new tn(s,i);o.addPaths(t,n,r);let a=[];return o.execute(e,a),a}var gt=1e4,Ds=[1,0,0,1,0,0];function nn(){return{layers:new Map,parts:[]}}function ut(t,e="cut"){return{layers:new Map([[e,{regions:t,lines:[]}]]),parts:[]}}function bn(t,e="cut"){return{layers:new Map([[e,{regions:[],lines:t}]]),parts:[]}}function oo(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 ao=t=>t.map(e=>e.map(([n,r])=>({x:Math.round(n*gt),y:Math.round(r*gt)})));function du(t){let e=(r,s,i)=>(s.x-r.x)*(i.y-s.y)-(s.y-r.y)*(i.x-s.x)===0,n=[];for(let r of t){for(;n.length>=2&&e(n[n.length-2],n[n.length-1],r);)n.pop();let s=n[n.length-1];(!s||s.x!==r.x||s.y!==r.y)&&n.push(r)}for(let r=!0;r&&n.length>=3;){let s=n.length;r=!0,n[s-1].x===n[0].x&&n[s-1].y===n[0].y||e(n[s-2],n[s-1],n[0])?n.pop():e(n[s-1],n[0],n[1])?n.shift():r=!1}return n}var qn=t=>ao(t).map(du),_n=t=>t.filter(e=>e.length>=2).map(e=>e.map(n=>[n.x/gt,n.y/gt]));function Ie(t,e="nonzero"){if(!t.length)return[];let n=e==="evenodd"?be.EvenOdd:be.NonZero;return _n(Fs(qn(t),n)).filter(r=>r.length>=3)}function lo(t,e,n){if(!e.length)return[];let r=new Lt;r.addSubject(qn(e)),n.length&&r.addClip(qn(n));let s=[];return r.execute(t,be.NonZero,s),_n(s).filter(i=>i.length>=3)}var Tt=(t,e)=>e.length?lo(Te.Difference,t,e):Ie(t),Fr=(t,e)=>lo(Te.Intersection,t,e);function jn(t,e,n){if(!t.length)return[];if(!e.length)return n==="outside"?t:[];let r=[];for(let g of e)for(let m=0;m<g.length;m++){let x=g[m],w=g[(m+1)%g.length];(x[0]!==w[0]||x[1]!==w[1])&&r.push([x,w])}if(!r.length)return n==="outside"?t:[];let s=st(e),i=Math.max(s[2]-s[0],s[3]-s[1],1e-6)/Math.max(1,Math.sqrt(r.length)),o=g=>Math.floor(g/i),a=new Map,l=new Map,u=(g,m,x)=>{let w=g.get(m);w?w[w.length-1]!==x&&w.push(x):g.set(m,[x])};r.forEach(([g,m],x)=>{let w=Math.max(1,Math.ceil(Math.hypot(m[0]-g[0],m[1]-g[1])/i*2));for(let v=0;v<=w;v++){let T=g[0]+(m[0]-g[0])*v/w,P=g[1]+(m[1]-g[1])*v/w;for(let O of[-1,0,1])for(let C of[-1,0,1])u(a,`${o(T)+O},${o(P)+C}`,x)}for(let v=o(Math.min(g[1],m[1]));v<=o(Math.max(g[1],m[1]));v++)u(l,v,x)});let c=(g,m)=>{let x=new Set,w=Math.max(1,Math.ceil(Math.hypot(m[0]-g[0],m[1]-g[1])/i*2));for(let v=0;v<=w;v++){let T=g[0]+(m[0]-g[0])*v/w,P=g[1]+(m[1]-g[1])*v/w;for(let O of a.get(`${o(T)},${o(P)}`)??[])x.add(O)}return x},f=.5/gt,h=g=>{for(let x of a.get(`${o(g[0])},${o(g[1])}`)??[]){let[w,v]=r[x],T=v[0]-w[0],P=v[1]-w[1],O=Math.max(0,Math.min(1,((g[0]-w[0])*T+(g[1]-w[1])*P)/(T*T+P*P)));if(Math.hypot(g[0]-w[0]-O*T,g[1]-w[1]-O*P)<=f)return}let m=0;for(let x of l.get(o(g[1]))??[]){let[w,v]=r[x],T=(v[0]-w[0])*(g[1]-w[1])-(g[0]-w[0])*(v[1]-w[1]);w[1]<=g[1]?v[1]>g[1]&&T>0&&m++:v[1]<=g[1]&&T<0&&m--}return m!==0},p=g=>Math.round(g*gt)/gt,d=[];for(let g of t){let m=null,x=()=>{m&&m.length>=2&&d.push(m),m=null};for(let w=1;w<g.length;w++){let v=g[w-1],T=g[w],P=T[0]-v[0],O=T[1]-v[1];if(!P&&!O)continue;let C=[0,1];for(let L of c(v,T)){let[B,A]=r[L],F=A[0]-B[0],te=A[1]-B[1],V=P*te-O*F;if(Math.abs(V)>1e-15){let q=((B[0]-v[0])*te-(B[1]-v[1])*F)/V,re=((B[0]-v[0])*O-(B[1]-v[1])*P)/V;q>0&&q<1&&re>=0&&re<=1&&C.push(q)}else{let q=P*P+O*O;for(let re of[B,A]){let U=((re[0]-v[0])*P+(re[1]-v[1])*O)/q,ae=Math.abs((re[0]-v[0])*O-(re[1]-v[1])*P)/Math.sqrt(q);U>0&&U<1&&ae<=f&&C.push(U)}}}C.sort((L,B)=>L-B);for(let L=1;L<C.length;L++){if(C[L]-C[L-1]<1e-12)continue;let B=[p(v[0]+P*C[L-1]),p(v[1]+O*C[L-1])],A=[p(v[0]+P*C[L]),p(v[1]+O*C[L])],F=(C[L-1]+C[L])/2,te=h([v[0]+P*F,v[1]+O*F]);if(te!==void 0&&te===(n==="inside")){let V=m?m[m.length-1]:void 0;m&&V&&V[0]===B[0]&&V[1]===B[1]?(A[0]!==V[0]||A[1]!==V[1])&&m.push(A):(x(),m=[B,A])}else x()}}x()}return d}function rn(t,e,n="round",r=.01){if(!t.length)return[];if(e===0)return Ie(t);let s=n==="round"?Ke.Round:n==="square"?Ke.Square:Ke.Miter,i=Or(qn(Ie(t)),e*gt,s,Fe.Polygon,2,r*gt);return _n(i).filter(o=>o.length>=3)}function uo(t,e){if(!t.length||e<=0)return[];let n=Or(ao(t),e/2*gt,Ke.Round,Fe.Round,2,.01*gt);return _n(n)}function Dr(t){if(!t.length)return[];let e=new Xn,n=new Lt;n.addSubject(qn(t)),n.execute(Te.Union,be.NonZero,e);let r=[],s=i=>{for(let o=0;o<i.count;o++){let a=i.child(o),l=[a.poly];for(let u=0;u<a.count;u++){let c=a.child(u);l.push(c.poly),s(c)}r.push(_n(l))}};return s(e),r}function Ze(t){let e=0;for(let n=0,r=t.length-1;n<t.length;r=n++)e+=(t[r][0]+t[n][0])*(t[r][1]-t[n][1]);return-e/2}function wn(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}function Wn(t,[e,n]){return[t[0]*e+t[2]*n+t[4],t[1]*e+t[3]*n+t[5]]}function so(t,e){let n=e[0]*e[3]-e[1]*e[2]<0,r=new Map;for(let[s,i]of t)r.set(s,{regions:i.regions.map(o=>{let a=o.map(l=>Wn(e,l));return n?a.reverse():a}),lines:i.lines.map(o=>o.map(a=>Wn(e,a)))});return r}function Rr(t,e){return{layers:so(t.layers,e),parts:t.parts.map(n=>({...n,layers:so(n.layers,e)}))}}function Zn(t){let e=nn();for(let n of t){for(let[r,s]of n.layers){let i=e.layers.get(r)??{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(r,i)}for(let r of n.parts)e.parts.push(r)}return e}function io(t,e){let n={regions:[],lines:[]};for(let r of t.values()){for(let s of r.regions)n.regions.push(s);for(let s of r.lines)n.lines.push(s)}return new Map([[e,n]])}function Ur(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:io(t.layers,e),parts:t.parts.map(n=>({...n,layers:io(n.layers,e)}))}}function st(t){let e=1/0,n=1/0,r=-1/0,s=-1/0;for(let i of t)for(let[o,a]of i)o<e&&(e=o),a<n&&(n=a),o>r&&(r=o),a>s&&(s=a);return e===1/0?null:[e,n,r,s]}function Rs(t,e){let n=[];for(let[r,s]of t)if(!e?.(r))for(let i of[...s.regions,...s.lines])n.push(i);return st(n)}function co(t){let e=[...t].sort((i,o)=>i[0]-o[0]||i[1]-o[1]);if(e.length<3)return e;let n=(i,o,a)=>(o[0]-i[0])*(a[1]-i[1])-(o[1]-i[1])*(a[0]-i[0]),r=[];for(let i of e){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],i)<=0;)r.pop();r.push(i)}let s=[];for(let i=e.length-1;i>=0;i--){let o=e[i];for(;s.length>=2&&n(s[s.length-2],s[s.length-1],o)<=0;)s.pop();s.push(o)}return s.pop(),r.pop(),r.concat(s)}function fo(t,e,n,r){return t<1e-9?3:e>0?Math.max(Math.floor(e),3):Math.max(Math.ceil(Math.min(360/n,t*2*Math.PI/r)),5)}function Sn(t,e,n){let r=[];for(let s=0;s<n;s++){let i=2*Math.PI*s/n;r.push([t*Math.cos(i),e*Math.sin(i)])}return r}function ho(t,e,n,r){if(n=Math.min(n,t/2,e/2),n<=0)return[[0,0],[t,0],[t,e],[0,e]];let s=Math.max(1,Math.ceil(r(n)/4)),i=[],o=[[t-n,n,-90],[t-n,e-n,0],[n,e-n,90],[n,n,180]];for(let[a,l,u]of o)for(let c=0;c<=s;c++){let f=(u+90*c/s)*Math.PI/180;i.push([a+n*Math.cos(f),l+n*Math.sin(f)])}return i}function sn(t,e){let n=Math.round(t/e);return n%2===0&&(n+=t/e>n?1:-1),Math.max(3,n)}var Yn=(t,e,n,r)=>[[t,e],[n,e],[n,r],[t,r]];function gu(t,e,n,r){if(e==="flat")return[];let s=sn(t,r),i=t/s,o=[];for(let a=0;a<s;a++)(e==="out"?a%2===1:a%2===0)&&o.push(Yn(a*i,-1,(a+1)*i,n));return o}function Nr(t,e,n,r,s){let i=[([l,u])=>[l,u],([l,u])=>[t-u,l],([l,u])=>[t-l,e-u],([l,u])=>[u,e-l]],o=[t,e,t,e],a=[];return n.forEach((l,u)=>{for(let c of gu(o[u],l,r,s))a.push(c.map(i[u]))}),Tt([Yn(0,0,t,e)],a)}function po(t,e,n,r){let s=sn(t,r),i=t/s,o=[];for(let a=0;a<s;a++)(e==="out"?a%2===0:a%2===1)&&o.push(Yn(a*i,-n/2,(a+1)*i,n/2));return o}function go(t,e,n,r,s){let i=Yn(-t/2,-1,t/2,e),o=Yn(-n/2,s,n/2,s+r);return[i,o]}function mo(t,e,n,r,s){let i=[],o=s+r,a=Math.floor(t/n),l=(t-a*n)/2;for(let u=0;u<=a;u++){let c=l+u*n,f=u%2===0?r:r-o/2;for(let h=f;h<e;h+=o){let p=Math.max(h,u%2===0?r:0),d=Math.min(h+s,e-(u%2===0?r:0));d-p>=r/2&&i.push([[c,p],[c,d]])}}return i}var Kn=(t,e=!0)=>`line ${t.line}${e?`, column ${t.col}`:""}${t.file?` in <${t.file}>`:""}`;var ne=class extends Error{constructor(n,r){super(r?`${n} (${Kn(r)})`:n);this.echoes=[];this.warnings=[];this.trace=[];this.traceMore=0;this.name="KerfError",this.reason=n,r&&(this.line=r.line,this.col=r.col,this.file=r.file)}addFrame(n,r,s){let i=this.trace.find(o=>o.name===r&&o.line===s.line&&o.col===s.col&&o.file===s.file);i?i.count++:this.trace.length>=50?this.traceMore++:this.trace.push({kind:n,name:r,line:s.line,col:s.col,...s.file&&{file:s.file},count:1})}},mu=["<=",">=","==","!=","&&","||","+","-","*","/","%","^","<",">","!","?",":","=",".",",",";","(",")","[","]","{","}","#"];function Jn(t,e){let n=[],r=[],s=0,i=1,o=0,a=()=>({line:i,col:s-o+1,offset:s,...e&&{file:e}}),l=u=>{for(let c=0;c<u;c++)t[s]===`
|
|
7
7
|
`&&(i++,o=s+1),s++};for(;s<t.length;){let u=t[s];if(u===" "||u===" "||u==="\r"||u===`
|
|
8
8
|
`){l(1);continue}if(u==="/"&&t[s+1]==="/"){let h=t.indexOf(`
|
|
9
9
|
`,s),p=h<0?t.length:h,d=/^[ \t]*$/.test(t.slice(t.lastIndexOf(`
|
|
10
|
-
`,s-1)+1,s));r.push({text:t.slice(s+2,p).trim(),line:i,block:!1,own:d,start:s,end:p}),s=p;continue}if(u==="/"&&t[s+1]==="*"){let h=a(),p=t.indexOf("*/",s+2);if(p<0)throw new
|
|
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
|
|
12
|
-
`)throw new D("Unclosed string",c);h+=t[s],l(1)}if(s>=t.length)throw new D("Unclosed string",c);l(1),n.push({type:"str",value:h,pos:c,end:s});continue}if(u==="<"&&/^<[A-Za-z0-9_./-]+>/.test(t.slice(s))){let h=n[n.length-1];if(h&&h.type==="id"&&(h.value==="use"||h.value==="include")){let p=/^<([A-Za-z0-9_./-]+)>/.exec(t.slice(s));n.push({type:"str",value:p[1],pos:c,end:s+p[0].length}),l(p[0].length);continue}}let f=Ha.find(h=>t.startsWith(h,s));if(!f)throw new D(`Unexpected character "${u}"`,c);n.push({type:"punct",value:f,pos:c,end:s+f.length}),l(f.length)}return n.push({type:"eof",value:"",pos:a(),end:s}),{tokens:n,comments:r}}var Ar=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]);function nt(t,e){let{tokens:n,comments:r}=nn(t,e),s=new Or(n),i=[];for(;!s.at("eof");)i.push(...s.statement());return{program:{body:i},comments:r}}var rn=class rn{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,n,r=0){let s=this.peek(r);return s.type===e&&(n===void 0||s.value===n)}isP(e,n=0){return this.at("punct",e,n)}isK(e,n=0){return this.at("id",e,n)}next(){return this.tokens[this.i++]}fail(e,n=this.peek()){let r=n.type==="eof"?"end of file":`"${n.value}"`;throw new D(`${e}, found ${r}`,n.pos)}expectP(e){return this.isP(e)||this.fail(`Expected "${e}"`),this.next()}separator(e){this.isP(e)||(this.isP(",")||this.fail(`Expected "," or "${e}"`),this.next())}ident(){let e=this.peek();return(e.type!=="id"||Ar.has(e.value))&&this.fail("Expected a name"),this.next()}last(){return this.tokens[this.i-1].end}statement(){let e=this.stmt();for(let n of e)n.end=this.last();return e}stmt(){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(),a=this.params();return[{kind:"module",name:o.value,params:a,body:this.body(),pos:e.pos,namePos:o.pos}]}if(this.isK("function")&&this.at("id",void 0,1)){this.next();let o=this.ident(),a=this.params();this.expectP("=");let l=this.expr();return this.expectP(";"),[{kind:"function",name:o.value,params:a,body:l,pos:e.pos,namePos:o.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(),l=[];return this.isK("else")&&(this.next(),l=this.body()),[{kind:"if",cond:o,then:a,else:l,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,l=this.expr(),u=this.expectP(";").pos.offset;return[{kind:"assign",name:o,value:l,span:[a,u],pos:e.pos}]}let n=null;(this.isP("*")||this.isP("!")||this.isP("#")||this.isP("%"))&&(n=this.next().value);let r=this.peek();(r.type!=="id"||Ar.has(r.value))&&this.fail("Expected a statement"),this.next();let s=this.args(),i=this.body();return[{kind:"call",name:r.value,args:s,children:i,modifier:n,pos:r.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 n=this.ident(),r=null;this.isP("=")&&(this.next(),r=this.expr()),e.push({name:n.value,default:r,pos:n.pos}),this.separator(")")}return this.next(),e}args(){this.expectP("(");let e=[];for(;!this.isP(")");){if(this.at("id")&&this.isP("=",1)){let n=this.next();this.next(),e.push({name:n.value,value:this.expr(),pos:n.pos})}else e.push({name:null,value:this.expr()});this.separator(")")}return this.next(),e}assigns(){this.expectP("(");let e=[];for(;!this.isP(")");){let n=this.ident();this.expectP("="),e.push({name:n.value,value:this.expr(),pos:n.pos}),this.separator(")")}return this.next(),e}expr(){let e=this.peek();if(this.isK("function")&&this.isP("(",1)){this.next();let r=this.params(),s=this.expr();return{kind:"lambda",params:r,body:s,pos:e.pos,end:this.last()}}if(this.isK("let")&&this.isP("(",1)){this.next();let r=this.assigns(),s=this.expr();return{kind:"let",assigns:r,body:s,pos:e.pos,end:this.last()}}let n=this.binary(0);if(this.isP("?")){this.next();let r=this.expr();this.expectP(":");let s=this.expr();return{kind:"ternary",cond:n,then:r,else:s,pos:e.pos}}return n}binary(e){if(e>=rn.LEVELS.length)return this.unary();let n=this.binary(e+1);for(;this.at("punct")&&rn.LEVELS[e].includes(this.peek().value);){let r=this.next(),s=this.binary(e+1);n={kind:"binary",op:r.value,left:n,right:s,pos:r.pos}}return n}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 n=this.next();return{kind:"binary",op:"^",left:e,right:this.unary(),pos:n.pos}}return e}postfix(){let e=this.primary();for(;;){let n=this.peek();if(this.isP("("))e={kind:"call",callee:e,args:this.args(),pos:e.pos};else if(this.isP("[")){this.next();let r=this.expr();this.expectP("]"),e={kind:"index",target:e,index:r,pos:n.pos}}else if(this.isP("."))this.next(),e={kind:"member",target:e,name:this.ident().value,pos:n.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}):(Ar.has(e.value)&&this.fail("Expected a value"),this.next(),{kind:"var",name:e.value,pos:e.pos});if(this.isP("(")){this.next();let n=this.expr();return this.expectP(")"),n}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))&&!(this.isP("(")&&(this.isK("for",1)||this.isK("if",1)))){let n=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:n,step:s,end:i,pos:e.pos}}let r=[{kind:"item",expr:n}];return this.listRest(r,e.pos)}return this.listRest([],e.pos)}listRest(e,n){if(e.length){if(this.isP("]"))return this.next(),{kind:"list",items:e,pos:n};this.separator("]")}for(;!this.isP("]");)e.push(this.listItem()),this.separator("]");return this.next(),{kind:"list",items:e,pos:n}}listItem(){let e=this.peek();if(this.isK("for")&&this.isP("(",1)){this.next();let n=this.assigns(),r=this.listItem();return{kind:"for",assigns:n,body:r,pos:e.pos,end:this.last()}}if(this.isK("if")&&this.isP("(",1)){this.next(),this.expectP("(");let n=this.expr();this.expectP(")");let r=this.listItem(),s=null;return this.isK("else")&&(this.next(),s=this.listItem()),{kind:"if",cond:n,then:r,else:s}}if(this.isK("let")&&this.isP("(",1)){this.next();let n=this.assigns(),r=this.listItem();return{kind:"let",assigns:n,body:r,pos:e.pos,end:this.last()}}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 n=this.listItem();return this.expectP(")"),n}return{kind:"item",expr:this.expr()}}};rn.LEVELS=[["||"],["&&"],["==","!="],["<","<=",">",">="],["+","-"],["*","/","%"]];var Or=rn;var S=(t,e,n)=>({name:t,...n!==void 0&&{default:n},...e&&{doc:e}}),Ie=(t,e,n)=>({...S(t,e,n),named:!0}),Fr="max(3 * $thickness, 6)",Hn=[S("value")],Va=[S("x")],Me=(t,e)=>({name:t,kind:"function",params:Va,section:"Numbers and vectors",doc:e}),Rt=(t,e)=>({name:t,kind:"function",params:Hn,section:"Types",doc:`Whether the value is ${e}`}),si=(t,e)=>({name:t,kind:"function",params:[S("text","The text to measure",'""'),S("size","Font size in millimetres","10"),S("font","Font name","$font"),Ie("halign","left, center or right",'"left"'),Ie("valign","baseline, top, center or bottom",'"baseline"'),Ie("spacing","Letter spacing factor","1")],section:"Text measurements",doc:e}),ii=[{name:"rect",kind:"module",params:[S("size","A number, or [width, height]","1"),S("center","Centre the rectangle on the origin instead of its corner","false"),Ie("r","Corner radius","0")],section:"Shapes",doc:"A rectangle with its corner at the origin"},{name:"square",kind:"module",params:[S("size","A number, or [width, height]","1"),S("center","Centre the square on the origin instead of its corner","false"),Ie("r","Corner radius","0")],section:"Shapes",doc:"Another name for rect()"},{name:"circle",kind:"module",params:[S("r","Radius","1"),Ie("d","Diameter, instead of r")],section:"Shapes",doc:"A circle centred on the origin"},{name:"ellipse",kind:"module",params:[S("r","[rx, ry], or one radius for both","1")],section:"Shapes",doc:"An ellipse centred on the origin"},{name:"regular_polygon",kind:"module",params:[S("n","Number of corners","6"),S("r","Distance to the corners","10")],section:"Shapes",doc:"A regular polygon centred on the origin"},{name:"star",kind:"module",params:[S("n","Number of points","5"),S("r","Radius of the points","10"),S("inner","Radius between the points","r * 0.45")],section:"Shapes",doc:"A star centred on the origin"},{name:"polygon",kind:"module",params:[S("points","A list of [x, y] points"),S("paths","Lists of point indexes, one per outline; holes come from even-odd fill")],section:"Shapes",doc:"A shape from a list of points"},{name:"path",kind:"module",params:[S("d",'SVG path data, as "M0 0 L10 0 L5 8 Z"'),Ie("fill",'"evenodd" or "nonzero"','"evenodd"')],section:"Shapes",doc:"Shapes from SVG path data: closed subpaths become areas, open ones lines"},{name:"text",kind:"module",params:[S("text","The text",'""'),S("size","Font size in millimetres","10"),S("font","Font name","$font"),Ie("halign","left, center or right",'"left"'),Ie("valign","baseline, top, center or bottom",'"baseline"'),Ie("spacing","Letter spacing factor","1")],section:"Shapes",doc:"Text as shapes; the font must be available to the renderer"},{name:"line",kind:"module",params:[S("from","Start point","[0, 0]"),S("to","End point","[10, 0]")],section:"Shapes",doc:"A straight line, not an area"},{name:"polyline",kind:"module",params:[S("points","A list of [x, y] points"),S("closed","Join the last point to the first","false")],section:"Shapes",doc:"Lines through a list of points"},{name:"arc",kind:"module",params:[S("r","Radius","10"),S("start","Start angle in degrees","0"),S("end","End angle in degrees","90")],section:"Shapes",doc:"An arc line around the origin"},{name:"translate",kind:"module",params:[S("v","[x, y]","[0, 0]")],children:!0,section:"Transforms",doc:"Move the children by x and y"},{name:"rotate",kind:"module",params:[S("a","Angle in degrees, anticlockwise","0"),Ie("center","The point to turn around, [x, y]")],children:!0,section:"Transforms",doc:"Rotate the children around the origin or a point"},{name:"scale",kind:"module",params:[S("v","One factor, or [sx, sy]","1")],children:!0,section:"Transforms",doc:"Scale the children"},{name:"mirror",kind:"module",params:[S("v","[nx, ny], perpendicular to the mirror line","[1, 0]")],children:!0,section:"Transforms",doc:"Reflect the children across a line through the origin"},{name:"multmatrix",kind:"module",params:[S("m","A 2 \xD7 3 or 3 \xD7 3 matrix")],children:!0,section:"Transforms",doc:"Apply a transformation matrix to the children"},{name:"union",kind:"module",params:[],children:!0,section:"Combining",doc:"Join the children"},{name:"group",kind:"module",params:[],children:!0,section:"Combining",doc:"Another name for union()"},{name:"difference",kind:"module",params:[],children:!0,section:"Combining",doc:"Remove every later child's area from every layer of the first child"},{name:"intersection",kind:"module",params:[],children:!0,section:"Combining",doc:"Keep only the area common to all children"},{name:"hull",kind:"module",params:[],children:!0,section:"Combining",doc:"The convex hull of the children; each part inside gets its own"},{name:"offset",kind:"module",params:[S("r","Grow (positive) or shrink areas with rounded corners"),Ie("delta","Grow or shrink areas with sharp corners","0"),Ie("chamfer","Cut the corners off when growing by delta","false")],children:!0,section:"Combining",doc:"Grow or shrink the areas of the children"},{name:"stroke",kind:"module",params:[S("width","Width of the area around each line","1")],children:!0,section:"Combining",doc:"Turn lines into areas, for cutting single-line art"},{name:"outline",kind:"module",params:[],children:!0,section:"Combining",doc:"Turn areas into their outline lines"},{name:"cut",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the cut layer"},{name:"score",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the score layer: lines marked without cutting through"},{name:"engrave",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the engrave layer: areas filled in"},{name:"guide",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the guide layer, which is not cut"},{name:"layer",kind:"module",params:[S("name","Layer name"),S("mode",'"cut", "line", "fill" or "guide"'),S("color",'Colour in the output, as "#00aa00"')],children:!0,section:"Layers",doc:"Put the children on a layer, defining it on first use"},{name:"part",kind:"module",params:[S("name","Part name",'"part"'),S("qty","Number of copies to cut","1"),Ie("at","Where the part goes in the assembled view, [x, y, z]"),Ie("rotate","How the part is turned in the assembled view, [x, y, z] in degrees")],children:!0,section:"Parts and sheets",doc:"A named part, with its thickness, kerf and material"},{name:"material",kind:"module",params:[S("thickness","Sets $thickness"),S("kerf","Sets $kerf"),S("name","Sets $material")],children:!0,section:"Parts and sheets",doc:"Set the thickness, kerf and material name for the children"},{name:"finger_rect",kind:"module",params:[S("size","[width, height]"),S("edges",'"out", "in" or "flat", or [bottom, right, top, left]','"out"'),S("finger","Finger width",Fr)],section:"Joinery",doc:"A rectangle with finger joints, notched $thickness deep"},{name:"finger_holes",kind:"module",params:[S("length","Length of the edge that plugs in"),S("edge",'"out" or "in", the kind of edge that plugs in','"out"'),S("finger","Finger width",Fr)],section:"Joinery",doc:"A row of slots along x for a finger edge to plug into"},{name:"tslot",kind:"module",params:[S("d","Screw diameter","3"),S("length","Screw length into the panel","12"),S("nut","Nut size, [width, height]","[d * 1.85, d * 0.8]"),S("nut_at","Distance of the nut from the edge","length / 2")],section:"Joinery",doc:"A T-slot for a screw and nut, opening at y = 0; subtract it from a panel edge"},{name:"living_hinge",kind:"module",params:[S("size","[width, height]"),S("spacing","Distance between the rows of cuts","1.5"),S("bridge","Uncut length between cuts","3"),S("cut","Length of each cut","max(bridge * 2, (height - 3 * bridge) / 2)")],section:"Joinery",doc:"A straight-line flex pattern of cut lines filling [width, height]"},{name:"children",kind:"module",params:[S("index","Which child, from 0, or a list of them")],section:"Other",doc:"Run the child statements passed to the current module"},{name:"echo",kind:"both",params:[],rest:!0,anyNamed:!0,section:"Other",doc:"Write values to the output without making shapes"},{name:"assert",kind:"both",params:[S("condition","Stops the program when false"),S("message","Says why")],section:"Other",doc:"Stop with an error when the condition is false"},Me("abs","Absolute value"),Me("sign","Sign as -1, 0 or 1"),Me("floor","Round down"),Me("ceil","Round up"),Me("round","Round to the nearest integer, halves away from zero"),Me("sqrt","Square root"),Me("exp","e raised to x"),Me("ln","Natural logarithm"),{name:"log",kind:"function",params:[S("x"),S("base",void 0,"10")],forms:["log(x)","log(base, x)"],section:"Numbers and vectors",doc:"Logarithm, base 10 or a chosen base; with two values the base comes first"},Me("sin","Sine of an angle in degrees"),Me("cos","Cosine of an angle in degrees"),Me("tan","Tangent of an angle in degrees"),Me("asin","Inverse sine, in degrees"),Me("acos","Inverse cosine, in degrees"),Me("atan","Inverse tangent, in degrees"),{name:"atan2",kind:"function",params:[S("y"),S("x")],section:"Numbers and vectors",doc:"The angle of the point [x, y] from the x axis, in degrees"},{name:"pow",kind:"function",params:[S("x"),S("y")],section:"Numbers and vectors",doc:"x raised to y"},{name:"min",kind:"function",params:[S("values","A list, or the first of several values")],rest:!0,section:"Numbers and vectors",doc:"The smallest of a list, or of several values"},{name:"max",kind:"function",params:[S("values","A list, or the first of several values")],rest:!0,section:"Numbers and vectors",doc:"The largest of a list, or of several values"},{name:"clamp",kind:"function",params:[S("x"),S("low"),S("high")],section:"Numbers and vectors",doc:"x limited to the interval from low to high"},{name:"lerp",kind:"function",params:[S("a"),S("b"),S("t","0 gives a, 1 gives b")],section:"Numbers and vectors",doc:"Interpolate between numbers or vectors"},{name:"norm",kind:"function",params:[S("v")],section:"Numbers and vectors",doc:"The length of a vector"},{name:"cross",kind:"function",params:[S("a"),S("b")],section:"Numbers and vectors",doc:"Cross product: a number for 2D vectors, a vector for 3D ones"},{name:"len",kind:"function",params:Hn,section:"Lists and strings",doc:"Number of items in a list or characters in a string"},{name:"concat",kind:"function",params:[],rest:!0,section:"Lists and strings",doc:"Join lists and single values into one list"},{name:"reverse",kind:"function",params:Hn,section:"Lists and strings",doc:"A list or string in reverse order"},{name:"sum",kind:"function",params:[S("values","A list of numbers")],section:"Lists and strings",doc:"The sum of a list of numbers"},{name:"slice",kind:"function",params:[S("value","A list or string"),S("start","First index","0"),S("end","Index after the last; the length when left out")],section:"Lists and strings",doc:"Part of a list or string"},{name:"str",kind:"function",params:[],rest:!0,section:"Lists and strings",doc:"Values as text, joined"},{name:"chr",kind:"function",params:[],rest:!0,section:"Lists and strings",doc:"Text from Unicode code points"},{name:"ord",kind:"function",params:[S("text")],section:"Lists and strings",doc:"The first character's Unicode code point"},{name:"upper",kind:"function",params:[S("text")],section:"Lists and strings",doc:"Text in capitals"},{name:"lower",kind:"function",params:[S("text")],section:"Lists and strings",doc:"Text in small letters"},{name:"split",kind:"function",params:[S("text"),S("separator",void 0,'" "')],section:"Lists and strings",doc:"Text split into a list of strings"},{name:"join",kind:"function",params:[S("values"),S("separator",void 0,'""')],section:"Lists and strings",doc:"Values joined into one string"},{name:"search",kind:"function",params:[S("value"),S("list","A list or string")],section:"Lists and strings",doc:"Index of the first equal item, or undef"},{name:"contains",kind:"function",params:[S("value","A list or string"),S("item")],section:"Lists and strings",doc:"Whether a list contains an item or a string contains a substring"},{name:"lookup",kind:"function",params:[S("x"),S("table","A list of [x, y] pairs")],section:"Lists and strings",doc:"Interpolate in a table; outside it, the nearest end"},Rt("is_num","a number other than NaN"),Rt("is_string","a string"),Rt("is_bool","true or false"),Rt("is_list","a list"),Rt("is_undef","undef"),Rt("is_function","a function"),{name:"type_of",kind:"function",params:Hn,section:"Types",doc:"The type name: number, string, boolean, undef, list, range or function"},{name:"rands",kind:"function",params:[S("min"),S("max"),S("count"),S("seed","The same seed gives the same list","1")],section:"Random values",doc:"A list of count numbers between min and max"},si("text_width","The advance width of the text, including spacing"),si("text_metrics","The text as [advance, [[x0, y0], [x1, y1]], ascent, descent]"),{name:"finger_count",kind:"function",params:[S("length","Edge length"),S("finger","Finger width",Fr)],section:"Joint dimensions",doc:"The odd number of fingers finger_rect() puts on an edge of that length"}],$a=new Map(ii.map(t=>[t.name,t])),sn=t=>$a.get(t);function Dr(t){let e=t.params.map(n=>n.default===void 0?n.name:`${n.name} = ${n.default}`);return t.rest&&e.push("..."),`${t.name}(${e.join(", ")})`}var on={"kerf/box":`// kerf/box: finger-jointed boxes.
|
|
10
|
+
`,s-1)+1,s));r.push({text:t.slice(s+2,p).trim(),line:i,block:!1,own:d,start:s,end:p}),s=p;continue}if(u==="/"&&t[s+1]==="*"){let h=a(),p=t.indexOf("*/",s+2);if(p<0)throw new ne("Unclosed block comment",h);r.push({text:t.slice(s+2,p).trim(),line:h.line,block:!0,own:!0,start:s,end:p+2}),l(p+2-s);continue}let c=a();if(/[0-9]/.test(u)||u==="."&&/[0-9]/.test(t[s+1]??"")){let h=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(t.slice(s));n.push({type:"num",value:h[0],pos:c,end:s+h[0].length}),l(h[0].length);continue}if(/[A-Za-z_$]/.test(u)){let h=/^[A-Za-z_$][A-Za-z0-9_]*/.exec(t.slice(s));n.push({type:"id",value:h[0],pos:c,end:s+h[0].length}),l(h[0].length);continue}if(u==='"'){let h="";for(l(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 ne("Bad \\u escape",a());h+=String.fromCharCode(parseInt(d,16)),l(4)}else h+=p;l(2);continue}if(t[s]===`
|
|
12
|
+
`)throw new ne("Unclosed string",c);h+=t[s],l(1)}if(s>=t.length)throw new ne("Unclosed string",c);l(1),n.push({type:"str",value:h,pos:c,end:s});continue}if(u==="<"&&/^<[A-Za-z0-9_./-]+>/.test(t.slice(s))){let h=n[n.length-1];if(h&&h.type==="id"&&(h.value==="use"||h.value==="include")){let p=/^<([A-Za-z0-9_./-]+)>/.exec(t.slice(s));n.push({type:"str",value:p[1],pos:c,end:s+p[0].length}),l(p[0].length);continue}}let f=mu.find(h=>t.startsWith(h,s));if(!f)throw new ne(`Unexpected character "${u}"`,c);n.push({type:"punct",value:f,pos:c,end:s+f.length}),l(f.length)}return n.push({type:"eof",value:"",pos:a(),end:s}),{tokens:n,comments:r}}var Us=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]);function mt(t,e){let{tokens:n,comments:r}=Jn(t,e),s=new Ns(n),i=[];for(;!s.at("eof");)i.push(...s.statement());return{program:{body:i},comments:r}}var Qn=class Qn{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,n,r=0){let s=this.peek(r);return s.type===e&&(n===void 0||s.value===n)}isP(e,n=0){return this.at("punct",e,n)}isK(e,n=0){return this.at("id",e,n)}next(){return this.tokens[this.i++]}fail(e,n=this.peek()){let r=n.type==="eof"?"end of file":`"${n.value}"`;throw new ne(`${e}, found ${r}`,n.pos)}expectP(e){return this.isP(e)||this.fail(`Expected "${e}"`),this.next()}separator(e){this.isP(e)||(this.isP(",")||this.fail(`Expected "," or "${e}"`),this.next())}ident(){let e=this.peek();return(e.type!=="id"||Us.has(e.value))&&this.fail("Expected a name"),this.next()}last(){return this.tokens[this.i-1].end}statement(){let e=this.stmt();for(let n of e)n.end=this.last();return e}stmt(){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(),a=this.params();return[{kind:"module",name:o.value,params:a,body:this.body(),pos:e.pos,namePos:o.pos}]}if(this.isK("function")&&this.at("id",void 0,1)){this.next();let o=this.ident(),a=this.params();this.expectP("=");let l=this.expr();return this.expectP(";"),[{kind:"function",name:o.value,params:a,body:l,pos:e.pos,namePos:o.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(),l=[];return this.isK("else")&&(this.next(),l=this.body()),[{kind:"if",cond:o,then:a,else:l,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,l=this.expr(),u=this.expectP(";").pos.offset;return[{kind:"assign",name:o,value:l,span:[a,u],pos:e.pos}]}let n=null;(this.isP("*")||this.isP("!")||this.isP("#")||this.isP("%"))&&(n=this.next().value);let r=this.peek();(r.type!=="id"||Us.has(r.value))&&this.fail("Expected a statement"),this.next();let s=this.args(),i=this.body();return[{kind:"call",name:r.value,args:s,children:i,modifier:n,pos:r.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 n=this.ident(),r=null;this.isP("=")&&(this.next(),r=this.expr()),e.push({name:n.value,default:r,pos:n.pos}),this.separator(")")}return this.next(),e}args(){this.expectP("(");let e=[];for(;!this.isP(")");){if(this.at("id")&&this.isP("=",1)){let n=this.next();this.next(),e.push({name:n.value,value:this.expr(),pos:n.pos})}else e.push({name:null,value:this.expr()});this.separator(")")}return this.next(),e}assigns(){this.expectP("(");let e=[];for(;!this.isP(")");){let n=this.ident();this.expectP("="),e.push({name:n.value,value:this.expr(),pos:n.pos}),this.separator(")")}return this.next(),e}expr(){let e=this.peek();if(this.isK("function")&&this.isP("(",1)){this.next();let r=this.params(),s=this.expr();return{kind:"lambda",params:r,body:s,pos:e.pos,end:this.last()}}if(this.isK("let")&&this.isP("(",1)){this.next();let r=this.assigns(),s=this.expr();return{kind:"let",assigns:r,body:s,pos:e.pos,end:this.last()}}let n=this.binary(0);if(this.isP("?")){this.next();let r=this.expr();this.expectP(":");let s=this.expr();return{kind:"ternary",cond:n,then:r,else:s,pos:e.pos}}return n}binary(e){if(e>=Qn.LEVELS.length)return this.unary();let n=this.binary(e+1);for(;this.at("punct")&&Qn.LEVELS[e].includes(this.peek().value);){let r=this.next(),s=this.binary(e+1);n={kind:"binary",op:r.value,left:n,right:s,pos:r.pos}}return n}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 n=this.next();return{kind:"binary",op:"^",left:e,right:this.unary(),pos:n.pos}}return e}postfix(){let e=this.primary();for(;;){let n=this.peek();if(this.isP("("))e={kind:"call",callee:e,args:this.args(),pos:e.pos};else if(this.isP("[")){this.next();let r=this.expr();this.expectP("]"),e={kind:"index",target:e,index:r,pos:n.pos}}else if(this.isP("."))this.next(),e={kind:"member",target:e,name:this.ident().value,pos:n.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}):(Us.has(e.value)&&this.fail("Expected a value"),this.next(),{kind:"var",name:e.value,pos:e.pos});if(this.isP("(")){this.next();let n=this.expr();return this.expectP(")"),n}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))&&!(this.isP("(")&&(this.isK("for",1)||this.isK("if",1)))){let n=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:n,step:s,end:i,pos:e.pos}}let r=[{kind:"item",expr:n}];return this.listRest(r,e.pos)}return this.listRest([],e.pos)}listRest(e,n){if(e.length){if(this.isP("]"))return this.next(),{kind:"list",items:e,pos:n};this.separator("]")}for(;!this.isP("]");)e.push(this.listItem()),this.separator("]");return this.next(),{kind:"list",items:e,pos:n}}listItem(){let e=this.peek();if(this.isK("for")&&this.isP("(",1)){this.next();let n=this.assigns(),r=this.listItem();return{kind:"for",assigns:n,body:r,pos:e.pos,end:this.last()}}if(this.isK("if")&&this.isP("(",1)){this.next(),this.expectP("(");let n=this.expr();this.expectP(")");let r=this.listItem(),s=null;return this.isK("else")&&(this.next(),s=this.listItem()),{kind:"if",cond:n,then:r,else:s}}if(this.isK("let")&&this.isP("(",1)){this.next();let n=this.assigns(),r=this.listItem();return{kind:"let",assigns:n,body:r,pos:e.pos,end:this.last()}}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 n=this.listItem();return this.expectP(")"),n}return{kind:"item",expr:this.expr()}}};Qn.LEVELS=[["||"],["&&"],["==","!="],["<","<=",">",">="],["+","-"],["*","/","%"]];var Ns=Qn;var N=(t,e,n)=>({name:t,...n!==void 0&&{default:n},...e&&{doc:e}}),Je=(t,e,n)=>({...N(t,e,n),named:!0}),Bs="max(3 * $thickness, 6)",Br=[N("value")],xu=[N("x")],nt=(t,e)=>({name:t,kind:"function",params:xu,section:"Numbers and vectors",doc:e}),kn=(t,e)=>({name:t,kind:"function",params:Br,section:"Types",doc:`Whether the value is ${e}`}),xo=(t,e)=>({name:t,kind:"function",params:[N("text","The text to measure",'""'),N("size","Font size in millimetres","10"),N("font","Font name","$font"),Je("halign","left, center or right",'"left"'),Je("valign","baseline, top, center or bottom",'"baseline"'),Je("spacing","Letter spacing factor","1")],section:"Text measurements",doc:e}),yo=[{name:"rect",kind:"module",params:[N("size","A number, or [width, height]","1"),N("center","Centre the rectangle on the origin instead of its corner","false"),Je("r","Corner radius","0")],section:"Shapes",doc:"A rectangle with its corner at the origin"},{name:"square",kind:"module",params:[N("size","A number, or [width, height]","1"),N("center","Centre the square on the origin instead of its corner","false"),Je("r","Corner radius","0")],section:"Shapes",doc:"Another name for rect()"},{name:"circle",kind:"module",params:[N("r","Radius","1"),Je("d","Diameter, instead of r")],section:"Shapes",doc:"A circle centred on the origin"},{name:"ellipse",kind:"module",params:[N("r","[rx, ry], or one radius for both","1")],section:"Shapes",doc:"An ellipse centred on the origin"},{name:"regular_polygon",kind:"module",params:[N("n","Number of corners","6"),N("r","Distance to the corners","10")],section:"Shapes",doc:"A regular polygon centred on the origin"},{name:"star",kind:"module",params:[N("n","Number of points","5"),N("r","Radius of the points","10"),N("inner","Radius between the points","r * 0.45")],section:"Shapes",doc:"A star centred on the origin"},{name:"polygon",kind:"module",params:[N("points","A list of [x, y] points"),N("paths","Lists of point indexes, one per outline; holes come from even-odd fill")],section:"Shapes",doc:"A shape from a list of points"},{name:"path",kind:"module",params:[N("d",'SVG path data, as "M0 0 L10 0 L5 8 Z"'),Je("fill",'"evenodd" or "nonzero"','"evenodd"')],section:"Shapes",doc:"Shapes from SVG path data: closed subpaths become areas, open ones lines"},{name:"text",kind:"module",params:[N("text","The text",'""'),N("size","Font size in millimetres","10"),N("font","Font name","$font"),Je("halign","left, center or right",'"left"'),Je("valign","baseline, top, center or bottom",'"baseline"'),Je("spacing","Letter spacing factor","1")],section:"Shapes",doc:"Text as shapes; the font must be available to the renderer"},{name:"line",kind:"module",params:[N("from","Start point","[0, 0]"),N("to","End point","[10, 0]")],section:"Shapes",doc:"A straight line, not an area"},{name:"polyline",kind:"module",params:[N("points","A list of [x, y] points"),N("closed","Join the last point to the first","false")],section:"Shapes",doc:"Lines through a list of points"},{name:"arc",kind:"module",params:[N("r","Radius","10"),N("start","Start angle in degrees","0"),N("end","End angle in degrees","90")],section:"Shapes",doc:"An arc line around the origin"},{name:"translate",kind:"module",params:[N("v","[x, y]","[0, 0]")],children:!0,section:"Transforms",doc:"Move the children by x and y"},{name:"rotate",kind:"module",params:[N("a","Angle in degrees, anticlockwise","0"),Je("center","The point to turn around, [x, y]")],children:!0,section:"Transforms",doc:"Rotate the children around the origin or a point"},{name:"scale",kind:"module",params:[N("v","One factor, or [sx, sy]","1")],children:!0,section:"Transforms",doc:"Scale the children"},{name:"mirror",kind:"module",params:[N("v","[nx, ny], perpendicular to the mirror line","[1, 0]")],children:!0,section:"Transforms",doc:"Reflect the children across a line through the origin"},{name:"multmatrix",kind:"module",params:[N("m","A 2 \xD7 3 or 3 \xD7 3 matrix")],children:!0,section:"Transforms",doc:"Apply a transformation matrix to the children"},{name:"union",kind:"module",params:[],children:!0,section:"Combining",doc:"Join the children"},{name:"group",kind:"module",params:[],children:!0,section:"Combining",doc:"Another name for union()"},{name:"difference",kind:"module",params:[],children:!0,section:"Combining",doc:"Remove every later child's area from every layer of the first child"},{name:"intersection",kind:"module",params:[],children:!0,section:"Combining",doc:"Keep only the area common to all children"},{name:"hull",kind:"module",params:[],children:!0,section:"Combining",doc:"The convex hull of the children; each part inside gets its own"},{name:"offset",kind:"module",params:[N("r","Grow (positive) or shrink areas with rounded corners"),Je("delta","Grow or shrink areas with sharp corners","0"),Je("chamfer","Cut the corners off when growing by delta","false")],children:!0,section:"Combining",doc:"Grow or shrink the areas of the children"},{name:"stroke",kind:"module",params:[N("width","Width of the area around each line","1")],children:!0,section:"Combining",doc:"Turn lines into areas, for cutting single-line art"},{name:"outline",kind:"module",params:[],children:!0,section:"Combining",doc:"Turn areas into their outline lines"},{name:"cut",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the cut layer"},{name:"score",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the score layer: lines marked without cutting through"},{name:"engrave",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the engrave layer: areas filled in"},{name:"guide",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the guide layer, which is not cut"},{name:"layer",kind:"module",params:[N("name","Layer name"),N("mode",'"cut", "line", "fill" or "guide"'),N("color",'Colour in the output, as "#00aa00"')],children:!0,section:"Layers",doc:"Put the children on a layer, defining it on first use"},{name:"part",kind:"module",params:[N("name","Part name",'"part"'),N("qty","Number of copies to cut","1"),Je("at","Where the part goes in the assembled view, [x, y, z]"),Je("rotate","How the part is turned in the assembled view, [x, y, z] in degrees")],children:!0,section:"Parts and sheets",doc:"A named part, with its thickness, kerf and material"},{name:"material",kind:"module",params:[N("thickness","Sets $thickness"),N("kerf","Sets $kerf"),N("name","Sets $material")],children:!0,section:"Parts and sheets",doc:"Set the thickness, kerf and material name for the children"},{name:"finger_rect",kind:"module",params:[N("size","[width, height]"),N("edges",'"out", "in" or "flat", or [bottom, right, top, left]','"out"'),N("finger","Finger width",Bs)],section:"Joinery",doc:"A rectangle with finger joints, notched $thickness deep"},{name:"finger_holes",kind:"module",params:[N("length","Length of the edge that plugs in"),N("edge",'"out" or "in", the kind of edge that plugs in','"out"'),N("finger","Finger width",Bs)],section:"Joinery",doc:"A row of slots along x for a finger edge to plug into"},{name:"tslot",kind:"module",params:[N("d","Screw diameter","3"),N("length","Screw length into the panel","12"),N("nut","Nut size, [width, height]","[d * 1.85, d * 0.8]"),N("nut_at","Distance of the nut from the edge","length / 2")],section:"Joinery",doc:"A T-slot for a screw and nut, opening at y = 0; subtract it from a panel edge"},{name:"living_hinge",kind:"module",params:[N("size","[width, height]"),N("spacing","Distance between the rows of cuts","1.5"),N("bridge","Uncut length between cuts","3"),N("cut","Length of each cut","max(bridge * 2, (height - 3 * bridge) / 2)")],section:"Joinery",doc:"A straight-line flex pattern of cut lines filling [width, height]"},{name:"children",kind:"module",params:[N("index","Which child, from 0, or a list of them")],section:"Other",doc:"Run the child statements passed to the current module"},{name:"echo",kind:"both",params:[],rest:!0,anyNamed:!0,section:"Other",doc:"Write values to the output without making shapes"},{name:"assert",kind:"both",params:[N("condition","Stops the program when false"),N("message","Says why")],section:"Other",doc:"Stop with an error when the condition is false"},nt("abs","Absolute value"),nt("sign","Sign as -1, 0 or 1"),nt("floor","Round down"),nt("ceil","Round up"),nt("round","Round to the nearest integer, halves away from zero"),nt("sqrt","Square root"),nt("exp","e raised to x"),nt("ln","Natural logarithm"),{name:"log",kind:"function",params:[N("x"),N("base",void 0,"10")],forms:["log(x)","log(base, x)"],section:"Numbers and vectors",doc:"Logarithm, base 10 or a chosen base; with two values the base comes first"},nt("sin","Sine of an angle in degrees"),nt("cos","Cosine of an angle in degrees"),nt("tan","Tangent of an angle in degrees"),nt("asin","Inverse sine, in degrees"),nt("acos","Inverse cosine, in degrees"),nt("atan","Inverse tangent, in degrees"),{name:"atan2",kind:"function",params:[N("y"),N("x")],section:"Numbers and vectors",doc:"The angle of the point [x, y] from the x axis, in degrees"},{name:"pow",kind:"function",params:[N("x"),N("y")],section:"Numbers and vectors",doc:"x raised to y"},{name:"min",kind:"function",params:[N("values","A list, or the first of several values")],rest:!0,section:"Numbers and vectors",doc:"The smallest of a list, or of several values"},{name:"max",kind:"function",params:[N("values","A list, or the first of several values")],rest:!0,section:"Numbers and vectors",doc:"The largest of a list, or of several values"},{name:"clamp",kind:"function",params:[N("x"),N("low"),N("high")],section:"Numbers and vectors",doc:"x limited to the interval from low to high"},{name:"lerp",kind:"function",params:[N("a"),N("b"),N("t","0 gives a, 1 gives b")],section:"Numbers and vectors",doc:"Interpolate between numbers or vectors"},{name:"norm",kind:"function",params:[N("v")],section:"Numbers and vectors",doc:"The length of a vector"},{name:"cross",kind:"function",params:[N("a"),N("b")],section:"Numbers and vectors",doc:"Cross product: a number for 2D vectors, a vector for 3D ones"},{name:"len",kind:"function",params:Br,section:"Lists and strings",doc:"Number of items in a list or characters in a string"},{name:"concat",kind:"function",params:[],rest:!0,section:"Lists and strings",doc:"Join lists and single values into one list"},{name:"reverse",kind:"function",params:Br,section:"Lists and strings",doc:"A list or string in reverse order"},{name:"sum",kind:"function",params:[N("values","A list of numbers")],section:"Lists and strings",doc:"The sum of a list of numbers"},{name:"slice",kind:"function",params:[N("value","A list or string"),N("start","First index","0"),N("end","Index after the last; the length when left out")],section:"Lists and strings",doc:"Part of a list or string"},{name:"str",kind:"function",params:[],rest:!0,section:"Lists and strings",doc:"Values as text, joined"},{name:"chr",kind:"function",params:[],rest:!0,section:"Lists and strings",doc:"Text from Unicode code points"},{name:"ord",kind:"function",params:[N("text")],section:"Lists and strings",doc:"The first character's Unicode code point"},{name:"upper",kind:"function",params:[N("text")],section:"Lists and strings",doc:"Text in capitals"},{name:"lower",kind:"function",params:[N("text")],section:"Lists and strings",doc:"Text in small letters"},{name:"split",kind:"function",params:[N("text"),N("separator",void 0,'" "')],section:"Lists and strings",doc:"Text split into a list of strings"},{name:"join",kind:"function",params:[N("values"),N("separator",void 0,'""')],section:"Lists and strings",doc:"Values joined into one string"},{name:"search",kind:"function",params:[N("value"),N("list","A list or string")],section:"Lists and strings",doc:"Index of the first equal item, or undef"},{name:"contains",kind:"function",params:[N("value","A list or string"),N("item")],section:"Lists and strings",doc:"Whether a list contains an item or a string contains a substring"},{name:"lookup",kind:"function",params:[N("x"),N("table","A list of [x, y] pairs")],section:"Lists and strings",doc:"Interpolate in a table; outside it, the nearest end"},kn("is_num","a number other than NaN"),kn("is_string","a string"),kn("is_bool","true or false"),kn("is_list","a list"),kn("is_undef","undef"),kn("is_function","a function"),{name:"type_of",kind:"function",params:Br,section:"Types",doc:"The type name: number, string, boolean, undef, list, range or function"},{name:"rands",kind:"function",params:[N("min"),N("max"),N("count"),N("seed","The same seed gives the same list","1")],section:"Random values",doc:"A list of count numbers between min and max"},xo("text_width","The advance width of the text, including spacing"),xo("text_metrics","The text as [advance, [[x0, y0], [x1, y1]], ascent, descent]"),{name:"finger_count",kind:"function",params:[N("length","Edge length"),N("finger","Finger width",Bs)],section:"Joint dimensions",doc:"The odd number of fingers finger_rect() puts on an edge of that length"}],yu=new Map(yo.map(t=>[t.name,t])),er=t=>yu.get(t);function $s(t){let e=t.params.map(n=>n.default===void 0?n.name:`${n.name} = ${n.default}`);return t.rest&&e.push("..."),`${t.name}(${e.join(", ")})`}var tr={"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.
|
|
@@ -375,17 +375,51 @@ module tab_rect(size, edges = true, count = undef, width = undef) {
|
|
|
375
375
|
if (e[2]) translate([w, h]) rotate(180) tabs(w, count, width);
|
|
376
376
|
if (e[3]) translate([0, h]) rotate(270) tabs(h, count, width);
|
|
377
377
|
}
|
|
378
|
-
`};function Vn(t,e=.02){let n=[],r=[],s=[],i=[0,0],o=[0,0],a=u=>{s.length>=2&&(u?n:r).push(s),s=[]},l=u=>Math.max(2,Math.min(256,Math.ceil(Math.sqrt(u/e))));for(let u of t)if(u.type==="M")a(!1),i=o=[u.x,u.y],s=[o];else if(u.type==="L")o=[u.x,u.y],s.push(o);else if(u.type==="Q"){let[c,f]=o,h=l(Math.hypot(u.x1-c,u.y1-f)+Math.hypot(u.x-u.x1,u.y-u.y1));for(let p=1;p<=h;p++){let d=p/h,g=1-d;s.push([g*g*c+2*g*d*u.x1+d*d*u.x,g*g*f+2*g*d*u.y1+d*d*u.y])}o=[u.x,u.y]}else if(u.type==="C"){let[c,f]=o,h=l(Math.hypot(u.x1-c,u.y1-f)+Math.hypot(u.x2-u.x1,u.y2-u.y1)+Math.hypot(u.x-u.x2,u.y-u.y2));for(let p=1;p<=h;p++){let d=p/h,g=1-d;s.push([g*g*g*c+3*g*g*d*u.x1+3*g*d*d*u.x2+d*d*d*u.x,g*g*g*f+3*g*g*d*u.y1+3*g*d*d*u.y2+d*d*d*u.y])}o=[u.x,u.y]}else a(!0),o=i,s=[i];return a(!1),{closed:n,open:r}}function oi(t){let e=x=>/^[a-zA-Z]$/.test(x),n=t.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g)??[],r=[],s=0,i="",o=0,a=0,l=0,u=0,c=0,f=0,h=0,p=0,d="",g=()=>{let x=n[s++];if(x===void 0||e(x))throw new Error(`Bad path data near "${x??"end"}"`);return Number(x)},y=()=>{let x=n[s];if(x===void 0)throw new Error("Bad path data: missing arc flag");return x.length>1&&(x[0]==="0"||x[0]==="1")&&!x.includes(".")?(n[s]=x.slice(1),Number(x[0])):(s++,Number(x))};for(;s<n.length;){if(e(n[s]))i=n[s++];else if(i){if(i==="Z"||i==="z")throw new Error(`Bad path data near "${n[s]}": Z takes no numbers`)}else throw new Error("Path data must start with a command");let x=i===i.toLowerCase(),L=i.toUpperCase(),w=x?o:0,A=x?a:0;if(L==="M")o=w+g(),a=A+g(),l=o,u=a,r.push({type:"M",x:o,y:a}),i=x?"l":"L";else if(L==="L")o=w+g(),a=A+g(),r.push({type:"L",x:o,y:a});else if(L==="H")o=w+g(),r.push({type:"L",x:o,y:a});else if(L==="V")a=A+g(),r.push({type:"L",x:o,y:a});else if(L==="C"||L==="S"){let T,U;if(L==="C")T=w+g(),U=A+g();else{let F=d==="C"||d==="S";T=F?2*o-c:o,U=F?2*a-f:a}let E=w+g(),P=A+g();o=w+g(),a=A+g(),c=E,f=P,r.push({type:"C",x1:T,y1:U,x2:E,y2:P,x:o,y:a})}else if(L==="Q"||L==="T"){let T,U;if(L==="Q")T=w+g(),U=A+g();else{let E=d==="Q"||d==="T";T=E?2*o-h:o,U=E?2*a-p:a}o=w+g(),a=A+g(),h=T,p=U,r.push({type:"Q",x1:T,y1:U,x:o,y:a})}else if(L==="A"){let T=g(),U=g(),E=g(),P=y(),F=y(),z=w+g(),R=A+g();r.push(...Xa(o,a,T,U,E,P,F,z,R)),o=z,a=R}else if(L==="Z")r.push({type:"Z"}),o=l,a=u;else throw new Error(`Unknown path command "${i}"`);d=L}return r}function Xa(t,e,n,r,s,i,o,a,l){if(n===0||r===0||t===a&&e===l)return[{type:"L",x:a,y:l}];n=Math.abs(n),r=Math.abs(r);let u=s*Math.PI/180,c=Math.cos(u),f=Math.sin(u),h=(t-a)/2,p=(e-l)/2,d=c*h+f*p,g=-f*h+c*p,y=d*d/(n*n)+g*g/(r*r);y>1&&(n*=Math.sqrt(y),r*=Math.sqrt(y));let x=n*n*r*r-n*n*g*g-r*r*d*d,L=n*n*g*g+r*r*d*d,w=Math.sqrt(Math.max(0,x/L));i===o&&(w=-w);let A=w*n*g/r,T=-w*r*d/n,U=c*A-f*T+(t+a)/2,E=f*A+c*T+(e+l)/2,P=($,Z,ne,te)=>Math.atan2($*te-Z*ne,$*ne+Z*te),F=P(1,0,(d-A)/n,(g-T)/r),z=P((d-A)/n,(g-T)/r,(-d-A)/n,(-g-T)/r);!o&&z>0&&(z-=2*Math.PI),o&&z<0&&(z+=2*Math.PI);let R=Math.ceil(Math.abs(z)/(Math.PI/2)),he=[],V=$=>[U+n*Math.cos($)*c-r*Math.sin($)*f,E+n*Math.cos($)*f+r*Math.sin($)*c],W=$=>[-n*Math.sin($)*c-r*Math.cos($)*f,-n*Math.sin($)*f+r*Math.cos($)*c];for(let $=0;$<R;$++){let Z=F+z*$/R,ne=F+z*($+1)/R,te=4/3*Math.tan((ne-Z)/4),oe=V(Z),fe=V(ne),Q=W(Z),k=W(ne);he.push({type:"C",x1:oe[0]+te*Q[0],y1:oe[1]+te*Q[1],x2:fe[0]-te*k[0],y2:fe[1]-te*k[1],x:fe[0],y:fe[1]})}return he}String.prototype.codePointAt||(function(){var t=(function(){try{var n={},r=Object.defineProperty,s=r(n,n,n)&&r}catch{}return s})(),e=function(n){if(this==null)throw TypeError();var r=String(this),s=r.length,i=n?Number(n):0;if(i!=i&&(i=0),!(i<0||i>=s)){var o=r.charCodeAt(i),a;return o>=55296&&o<=56319&&s>i+1&&(a=r.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 Qr=0,Zi=-3;function un(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function qa(t,e){this.source=t,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new un,this.dtree=new un}var ji=new un,Yi=new un,es=new Uint8Array(30),ts=new Uint16Array(30),Ki=new Uint8Array(30),Ji=new Uint16Array(30),Wa=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ui=new un,Ke=new Uint8Array(320);function Qi(t,e,n,r){var s,i;for(s=0;s<n;++s)t[s]=0;for(s=0;s<30-n;++s)t[s+n]=s/n|0;for(i=r,s=0;s<30;++s)e[s]=i,i+=1<<t[s]}function _a(t,e){var n;for(n=0;n<7;++n)t.table[n]=0;for(t.table[7]=24,t.table[8]=152,t.table[9]=112,n=0;n<24;++n)t.trans[n]=256+n;for(n=0;n<144;++n)t.trans[24+n]=n;for(n=0;n<8;++n)t.trans[168+n]=280+n;for(n=0;n<112;++n)t.trans[176+n]=144+n;for(n=0;n<5;++n)e.table[n]=0;for(e.table[5]=32,n=0;n<32;++n)e.trans[n]=n}var ci=new Uint16Array(16);function Rr(t,e,n,r){var s,i;for(s=0;s<16;++s)t.table[s]=0;for(s=0;s<r;++s)t.table[e[n+s]]++;for(t.table[0]=0,i=0,s=0;s<16;++s)ci[s]=i,i+=t.table[s];for(s=0;s<r;++s)e[n+s]&&(t.trans[ci[e[n+s]]++]=s)}function Za(t){t.bitcount--||(t.tag=t.source[t.sourceIndex++],t.bitcount=7);var e=t.tag&1;return t.tag>>>=1,e}function Je(t,e,n){if(!e)return n;for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var r=t.tag&65535>>>16-e;return t.tag>>>=e,t.bitcount-=e,r+n}function Xr(t,e){for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var n=0,r=0,s=0,i=t.tag;do r=2*r+(i&1),i>>>=1,++s,n+=e.table[s],r-=e.table[s];while(r>=0);return t.tag=i,t.bitcount-=s,e.trans[n+r]}function ja(t,e,n){var r,s,i,o,a,l;for(r=Je(t,5,257),s=Je(t,5,1),i=Je(t,4,4),o=0;o<19;++o)Ke[o]=0;for(o=0;o<i;++o){var u=Je(t,3,0);Ke[Wa[o]]=u}for(Rr(ui,Ke,0,19),a=0;a<r+s;){var c=Xr(t,ui);switch(c){case 16:var f=Ke[a-1];for(l=Je(t,2,3);l;--l)Ke[a++]=f;break;case 17:for(l=Je(t,3,3);l;--l)Ke[a++]=0;break;case 18:for(l=Je(t,7,11);l;--l)Ke[a++]=0;break;default:Ke[a++]=c;break}}Rr(e,Ke,0,r),Rr(n,Ke,r,s)}function hi(t,e,n){for(;;){var r=Xr(t,e);if(r===256)return Qr;if(r<256)t.dest[t.destLen++]=r;else{var s,i,o,a;for(r-=257,s=Je(t,es[r],ts[r]),i=Xr(t,n),o=t.destLen-Je(t,Ki[i],Ji[i]),a=o;a<o+s;++a)t.dest[t.destLen++]=t.dest[a]}}}function Ya(t){for(var e,n,r;t.bitcount>8;)t.sourceIndex--,t.bitcount-=8;if(e=t.source[t.sourceIndex+1],e=256*e+t.source[t.sourceIndex],n=t.source[t.sourceIndex+3],n=256*n+t.source[t.sourceIndex+2],e!==(~n&65535))return Zi;for(t.sourceIndex+=4,r=e;r;--r)t.dest[t.destLen++]=t.source[t.sourceIndex++];return t.bitcount=0,Qr}function Ka(t,e){var n=new qa(t,e),r,s,i;do{switch(r=Za(n),s=Je(n,2,0),s){case 0:i=Ya(n);break;case 1:i=hi(n,ji,Yi);break;case 2:ja(n,n.ltree,n.dtree),i=hi(n,n.ltree,n.dtree);break;default:i=Zi}if(i!==Qr)throw new Error("Data error")}while(!r);return n.destLen<n.dest.length?typeof n.dest.slice=="function"?n.dest.slice(0,n.destLen):n.dest.subarray(0,n.destLen):n.dest}_a(ji,Yi);Qi(es,ts,4,3);Qi(Ki,Ji,2,1);es[28]=0;ts[28]=258;var Ja=Ka;function Ut(t,e,n,r,s){return Math.pow(1-s,3)*t+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*n+Math.pow(s,3)*r}function gt(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}gt.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)};gt.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))};gt.prototype.addX=function(t){this.addPoint(t,null)};gt.prototype.addY=function(t){this.addPoint(null,t)};gt.prototype.addBezier=function(t,e,n,r,s,i,o,a){var l=[t,e],u=[n,r],c=[s,i],f=[o,a];this.addPoint(t,e),this.addPoint(o,a);for(var h=0;h<=1;h++){var p=6*l[h]-12*u[h]+6*c[h],d=-3*l[h]+9*u[h]-9*c[h]+3*f[h],g=3*u[h]-3*l[h];if(d===0){if(p===0)continue;var y=-g/p;0<y&&y<1&&(h===0&&this.addX(Ut(l[h],u[h],c[h],f[h],y)),h===1&&this.addY(Ut(l[h],u[h],c[h],f[h],y)));continue}var x=Math.pow(p,2)-4*g*d;if(!(x<0)){var L=(-p+Math.sqrt(x))/(2*d);0<L&&L<1&&(h===0&&this.addX(Ut(l[h],u[h],c[h],f[h],L)),h===1&&this.addY(Ut(l[h],u[h],c[h],f[h],L)));var w=(-p-Math.sqrt(x))/(2*d);0<w&&w<1&&(h===0&&this.addX(Ut(l[h],u[h],c[h],f[h],w)),h===1&&this.addY(Ut(l[h],u[h],c[h],f[h],w)))}}};gt.prototype.addQuad=function(t,e,n,r,s,i){var o=t+.6666666666666666*(n-t),a=e+2/3*(r-e),l=o+1/3*(s-t),u=a+1/3*(i-e);this.addBezier(t,e,o,a,l,u,s,i)};function ye(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}ye.prototype.moveTo=function(t,e){this.commands.push({type:"M",x:t,y:e})};ye.prototype.lineTo=function(t,e){this.commands.push({type:"L",x:t,y:e})};ye.prototype.curveTo=ye.prototype.bezierCurveTo=function(t,e,n,r,s,i){this.commands.push({type:"C",x1:t,y1:e,x2:n,y2:r,x:s,y:i})};ye.prototype.quadTo=ye.prototype.quadraticCurveTo=function(t,e,n,r){this.commands.push({type:"Q",x1:t,y1:e,x:n,y:r})};ye.prototype.close=ye.prototype.closePath=function(){this.commands.push({type:"Z"})};ye.prototype.extend=function(t){if(t.commands)t=t.commands;else if(t instanceof gt){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)};ye.prototype.getBoundingBox=function(){for(var t=new gt,e=0,n=0,r=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=r=o.x,n=s=o.y;break;case"L":t.addPoint(o.x,o.y),r=o.x,s=o.y;break;case"Q":t.addQuad(r,s,o.x1,o.y1,o.x,o.y),r=o.x,s=o.y;break;case"C":t.addBezier(r,s,o.x1,o.y1,o.x2,o.y2,o.x,o.y),r=o.x,s=o.y;break;case"Z":r=e,s=n;break;default:throw new Error("Unexpected path command "+o.type)}}return t.isEmpty()&&t.addPoint(0,0),t};ye.prototype.draw=function(t){t.beginPath();for(var e=0;e<this.commands.length;e+=1){var n=this.commands[e];n.type==="M"?t.moveTo(n.x,n.y):n.type==="L"?t.lineTo(n.x,n.y):n.type==="C"?t.bezierCurveTo(n.x1,n.y1,n.x2,n.y2,n.x,n.y):n.type==="Q"?t.quadraticCurveTo(n.x1,n.y1,n.x,n.y):n.type==="Z"&&t.closePath()}this.fill&&(t.fillStyle=this.fill,t.fill()),this.stroke&&(t.strokeStyle=this.stroke,t.lineWidth=this.strokeWidth,t.stroke())};ye.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 n(){for(var o=arguments,a="",l=0;l<arguments.length;l+=1){var u=o[l];u>=0&&l>0&&(a+=" "),a+=e(u)}return a}for(var r="",s=0;s<this.commands.length;s+=1){var i=this.commands[s];i.type==="M"?r+="M"+n(i.x,i.y):i.type==="L"?r+="L"+n(i.x,i.y):i.type==="C"?r+="C"+n(i.x1,i.y1,i.x2,i.y2,i.x,i.y):i.type==="Q"?r+="Q"+n(i.x1,i.y1,i.x,i.y):i.type==="Z"&&(r+="Z")}return r};ye.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};ye.prototype.toDOMElement=function(t){var e=this.toPathData(t),n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",e),n};function eo(t){throw new Error(t)}function fi(t,e){t||eo(e)}var N={fail:eo,argument:fi,assert:fi},pi=32768,di=2147483648,Bt={},I={},G={};function _e(t){return function(){return t}}I.BYTE=function(t){return N.argument(t>=0&&t<=255,"Byte value should be between 0 and 255."),[t]};G.BYTE=_e(1);I.CHAR=function(t){return[t.charCodeAt(0)]};G.CHAR=_e(1);I.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=[],n=0;n<t.length;n+=1)e[n]=t.charCodeAt(n);return e};G.CHARARRAY=function(t){return typeof t>"u"?0:t.length};I.USHORT=function(t){return[t>>8&255,t&255]};G.USHORT=_e(2);I.SHORT=function(t){return t>=pi&&(t=-(2*pi-t)),[t>>8&255,t&255]};G.SHORT=_e(2);I.UINT24=function(t){return[t>>16&255,t>>8&255,t&255]};G.UINT24=_e(3);I.ULONG=function(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]};G.ULONG=_e(4);I.LONG=function(t){return t>=di&&(t=-(2*di-t)),[t>>24&255,t>>16&255,t>>8&255,t&255]};G.LONG=_e(4);I.FIXED=I.ULONG;G.FIXED=G.ULONG;I.FWORD=I.SHORT;G.FWORD=G.SHORT;I.UFWORD=I.USHORT;G.UFWORD=G.USHORT;I.LONGDATETIME=function(t){return[0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255]};G.LONGDATETIME=_e(8);I.TAG=function(t){return N.argument(t.length===4,"Tag should be exactly 4 ASCII characters."),[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]};G.TAG=_e(4);I.Card8=I.BYTE;G.Card8=G.BYTE;I.Card16=I.USHORT;G.Card16=G.USHORT;I.OffSize=I.BYTE;G.OffSize=G.BYTE;I.SID=I.USHORT;G.SID=G.USHORT;I.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?I.NUMBER16(t):I.NUMBER32(t)};G.NUMBER=function(t){return I.NUMBER(t).length};I.NUMBER16=function(t){return[28,t>>8&255,t&255]};G.NUMBER16=_e(3);I.NUMBER32=function(t){return[29,t>>24&255,t>>16&255,t>>8&255,t&255]};G.NUMBER32=_e(5);I.REAL=function(t){var e=t.toString(),n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(n){var r=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));e=(Math.round(t*r)/r).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 l=[30],u=0,c=s.length;u<c;u+=2)l.push(parseInt(s.substr(u,2),16));return l};G.REAL=function(t){return I.REAL(t).length};I.NAME=I.CHARARRAY;G.NAME=G.CHARARRAY;I.STRING=I.CHARARRAY;G.STRING=G.CHARARRAY;Bt.UTF8=function(t,e,n){for(var r=[],s=n,i=0;i<s;i++,e+=1)r[i]=t.getUint8(e);return String.fromCharCode.apply(null,r)};Bt.UTF16=function(t,e,n){for(var r=[],s=n/2,i=0;i<s;i++,e+=2)r[i]=t.getUint16(e);return String.fromCharCode.apply(null,r)};I.UTF16=function(t){for(var e=[],n=0;n<t.length;n+=1){var r=t.charCodeAt(n);e[e.length]=r>>8&255,e[e.length]=r&255}return e};G.UTF16=function(t){return t.length*2};var qr={"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"};Bt.MACSTRING=function(t,e,n,r){var s=qr[r];if(s!==void 0){for(var i="",o=0;o<n;o++){var a=t.getUint8(e+o);a<=127?i+=String.fromCharCode(a):i+=s[a&127]}return i}};var $n=typeof WeakMap=="function"&&new WeakMap,Xn,Qa=function(t){if(!Xn){Xn={};for(var e in qr)Xn[e]=new String(e)}var n=Xn[t];if(n!==void 0){if($n){var r=$n.get(n);if(r!==void 0)return r}var s=qr[t];if(s!==void 0){for(var i={},o=0;o<s.length;o++)i[s.charCodeAt(o)]=o+128;return $n&&$n.set(n,i),i}}};I.MACSTRING=function(t,e){var n=Qa(e);if(n!==void 0){for(var r=[],s=0;s<t.length;s++){var i=t.charCodeAt(s);if(i>=128&&(i=n[i],i===void 0))return;r[s]=i}return r}};G.MACSTRING=function(t,e){var n=I.MACSTRING(t,e);return n!==void 0?n.length:0};function Wr(t){return t>=-128&&t<=127}function el(t,e,n){for(var r=0,s=t.length;e<s&&r<64&&t[e]===0;)++e,++r;return n.push(128|r-1),e}function tl(t,e,n){for(var r=0,s=t.length,i=e;i<s&&r<64;){var o=t[i];if(!Wr(o)||o===0&&i+1<s&&t[i+1]===0)break;++i,++r}n.push(r-1);for(var a=e;a<i;++a)n.push(t[a]+256&255);return i}function nl(t,e,n){for(var r=0,s=t.length,i=e;i<s&&r<64;){var o=t[i];if(o===0||Wr(o)&&i+1<s&&Wr(t[i+1]))break;++i,++r}n.push(64|r-1);for(var a=e;a<i;++a){var l=t[a];n.push(l+65536>>8&255,l+256&255)}return i}I.VARDELTAS=function(t){for(var e=0,n=[];e<t.length;){var r=t[e];r===0?e=el(t,e,n):r>=-128&&r<=127?e=tl(t,e,n):e=nl(t,e,n)}return n};I.INDEX=function(t){for(var e=1,n=[e],r=[],s=0;s<t.length;s+=1){var i=I.OBJECT(t[s]);Array.prototype.push.apply(r,i),e+=i.length,n.push(e)}if(r.length===0)return[0,0];for(var o=[],a=1+Math.floor(Math.log(e)/Math.log(2))/8|0,l=[void 0,I.BYTE,I.USHORT,I.UINT24,I.ULONG][a],u=0;u<n.length;u+=1){var c=l(n[u]);Array.prototype.push.apply(o,c)}return Array.prototype.concat(I.Card16(t.length),I.OffSize(a),o,r)};G.INDEX=function(t){return I.INDEX(t).length};I.DICT=function(t){for(var e=[],n=Object.keys(t),r=n.length,s=0;s<r;s+=1){var i=parseInt(n[s],0),o=t[i];e=e.concat(I.OPERAND(o.value,o.type)),e=e.concat(I.OPERATOR(i))}return e};G.DICT=function(t){return I.DICT(t).length};I.OPERATOR=function(t){return t<1200?[t]:[12,t-1200]};I.OPERAND=function(t,e){var n=[];if(Array.isArray(e))for(var r=0;r<e.length;r+=1)N.argument(t.length===e.length,"Not enough arguments given for type"+e),n=n.concat(I.OPERAND(t[r],e[r]));else if(e==="SID")n=n.concat(I.NUMBER(t));else if(e==="offset")n=n.concat(I.NUMBER32(t));else if(e==="number")n=n.concat(I.NUMBER(t));else if(e==="real")n=n.concat(I.REAL(t));else throw new Error("Unknown operand type "+e);return n};I.OP=I.BYTE;G.OP=G.BYTE;var qn=typeof WeakMap=="function"&&new WeakMap;I.CHARSTRING=function(t){if(qn){var e=qn.get(t);if(e!==void 0)return e}for(var n=[],r=t.length,s=0;s<r;s+=1){var i=t[s];n=n.concat(I[i.type](i.value))}return qn&&qn.set(t,n),n};G.CHARSTRING=function(t){return I.CHARSTRING(t).length};I.OBJECT=function(t){var e=I[t.type];return N.argument(e!==void 0,"No encoding function for type "+t.type),e(t.value)};G.OBJECT=function(t){var e=G[t.type];return N.argument(e!==void 0,"No sizeOf function for type "+t.type),e(t.value)};I.TABLE=function(t){for(var e=[],n=t.fields.length,r=[],s=[],i=0;i<n;i+=1){var o=t.fields[i],a=I[o.type];N.argument(a!==void 0,"No encoding function for field type "+o.type+" ("+o.name+")");var l=t[o.name];l===void 0&&(l=o.value);var u=a(l);o.type==="TABLE"?(s.push(e.length),e=e.concat([0,0]),r.push(u)):e=e.concat(u)}for(var c=0;c<r.length;c+=1){var f=s[c],h=e.length;N.argument(h<65536,"Table "+t.tableName+" too big."),e[f]=h>>8,e[f+1]=h&255,e=e.concat(r[c])}return e};G.TABLE=function(t){for(var e=0,n=t.fields.length,r=0;r<n;r+=1){var s=t.fields[r],i=G[s.type];N.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};I.RECORD=I.TABLE;G.RECORD=G.TABLE;I.LITERAL=function(t){return t};G.LITERAL=function(t){return t.length};function Se(t,e,n){if(e.length&&(e[0].name!=="coverageFormat"||e[0].value===1))for(var r=0;r<e.length;r+=1){var s=e[r];this[s.name]=s.value}if(this.tableName=t,this.fields=e,n)for(var i=Object.keys(n),o=0;o<i.length;o+=1){var a=i[o],l=n[a];this[a]!==void 0&&(this[a]=l)}}Se.prototype.encode=function(){return I.TABLE(this)};Se.prototype.sizeOf=function(){return G.TABLE(this)};function cn(t,e,n){n===void 0&&(n=e.length);var r=new Array(e.length+1);r[0]={name:t+"Count",type:"USHORT",value:n};for(var s=0;s<e.length;s++)r[s+1]={name:t+s,type:"USHORT",value:e[s]};return r}function _r(t,e,n){var r=e.length,s=new Array(r+1);s[0]={name:t+"Count",type:"USHORT",value:r};for(var i=0;i<r;i++)s[i+1]={name:t+i,type:"TABLE",value:n(e[i],i)};return s}function hn(t,e,n){var r=e.length,s=[];s[0]={name:t+"Count",type:"USHORT",value:r};for(var i=0;i<r;i++)s=s.concat(n(e[i],i));return s}function Yn(t){t.format===1?Se.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(cn("glyph",t.glyphs))):t.format===2?Se.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(hn("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}]}))):N.assert(!1,"Coverage format must be 1 or 2.")}Yn.prototype=Object.create(Se.prototype);Yn.prototype.constructor=Yn;function Kn(t){Se.call(this,"scriptListTable",hn("scriptRecord",t,function(e,n){var r=e.script,s=r.defaultLangSys;return N.assert(!!s,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+n,type:"TAG",value:e.tag},{name:"script"+n,type:"TABLE",value:new Se("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Se("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(cn("featureIndex",s.featureIndexes)))}].concat(hn("langSys",r.langSysRecords,function(i,o){var a=i.langSys;return[{name:"langSysTag"+o,type:"TAG",value:i.tag},{name:"langSys"+o,type:"TABLE",value:new Se("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat(cn("featureIndex",a.featureIndexes)))}]})))}]}))}Kn.prototype=Object.create(Se.prototype);Kn.prototype.constructor=Kn;function Jn(t){Se.call(this,"featureListTable",hn("featureRecord",t,function(e,n){var r=e.feature;return[{name:"featureTag"+n,type:"TAG",value:e.tag},{name:"feature"+n,type:"TABLE",value:new Se("featureTable",[{name:"featureParams",type:"USHORT",value:r.featureParams}].concat(cn("lookupListIndex",r.lookupListIndexes)))}]}))}Jn.prototype=Object.create(Se.prototype);Jn.prototype.constructor=Jn;function Qn(t,e){Se.call(this,"lookupListTable",_r("lookup",t,function(n){var r=e[n.lookupType];return N.assert(!!r,"Unable to write GSUB lookup type "+n.lookupType+" tables."),new Se("lookupTable",[{name:"lookupType",type:"USHORT",value:n.lookupType},{name:"lookupFlag",type:"USHORT",value:n.lookupFlag}].concat(_r("subtable",n.subtables,r)))}))}Qn.prototype=Object.create(Se.prototype);Qn.prototype.constructor=Qn;var C={Table:Se,Record:Se,Coverage:Yn,ScriptList:Kn,FeatureList:Jn,LookupList:Qn,ushortList:cn,tableList:_r,recordList:hn};function gi(t,e){return t.getUint8(e)}function er(t,e){return t.getUint16(e,!1)}function rl(t,e){return t.getInt16(e,!1)}function ns(t,e){return t.getUint32(e,!1)}function to(t,e){var n=t.getInt16(e,!1),r=t.getUint16(e+2,!1);return n+r/65535}function sl(t,e){for(var n="",r=e;r<e+4;r+=1)n+=String.fromCharCode(t.getInt8(r));return n}function il(t,e,n){for(var r=0,s=0;s<n;s+=1)r<<=8,r+=t.getUint8(e+s);return r}function ol(t,e,n){for(var r=[],s=e;s<n;s+=1)r.push(t.getUint8(s));return r}function al(t){for(var e="",n=0;n<t.length;n+=1)e+=String.fromCharCode(t[n]);return e}var ll={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=ns(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t};v.prototype.parseOffset32=v.prototype.parseULong;v.prototype.parseFixed=function(){var t=to(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t};v.prototype.parseString=function(t){var e=this.data,n=this.offset+this.relativeOffset,r="";this.relativeOffset+=t;for(var s=0;s<t;s++)r+=String.fromCharCode(e.getUint8(n+s));return r};v.prototype.parseTag=function(){return this.parseString(4)};v.prototype.parseLongDateTime=function(){var t=ns(this.data,this.offset+this.relativeOffset+4);return t-=2082844800,this.relativeOffset+=8,t};v.prototype.parseVersion=function(t){var e=er(this.data,this.offset+this.relativeOffset),n=er(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,t===void 0&&(t=4096),e+n/t/10};v.prototype.skip=function(t,e){e===void 0&&(e=1),this.relativeOffset+=ll[t]*e};v.prototype.parseULongList=function(t){t===void 0&&(t=this.parseULong());for(var e=new Array(t),n=this.data,r=this.offset+this.relativeOffset,s=0;s<t;s++)e[s]=n.getUint32(r),r+=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),n=this.data,r=this.offset+this.relativeOffset,s=0;s<t;s++)e[s]=n.getUint16(r),r+=2;return this.relativeOffset+=t*2,e};v.prototype.parseShortList=function(t){for(var e=new Array(t),n=this.data,r=this.offset+this.relativeOffset,s=0;s<t;s++)e[s]=n.getInt16(r),r+=2;return this.relativeOffset+=t*2,e};v.prototype.parseByteList=function(t){for(var e=new Array(t),n=this.data,r=this.offset+this.relativeOffset,s=0;s<t;s++)e[s]=n.getUint8(r++);return this.relativeOffset+=t,e};v.prototype.parseList=function(t,e){e||(e=t,t=this.parseUShort());for(var n=new Array(t),r=0;r<t;r++)n[r]=e.call(this);return n};v.prototype.parseList32=function(t,e){e||(e=t,t=this.parseULong());for(var n=new Array(t),r=0;r<t;r++)n[r]=e.call(this);return n};v.prototype.parseRecordList=function(t,e){e||(e=t,t=this.parseUShort());for(var n=new Array(t),r=Object.keys(e),s=0;s<t;s++){for(var i={},o=0;o<r.length;o++){var a=r[o],l=e[a];i[a]=l.call(this)}n[s]=i}return n};v.prototype.parseRecordList32=function(t,e){e||(e=t,t=this.parseULong());for(var n=new Array(t),r=Object.keys(e),s=0;s<t;s++){for(var i={},o=0;o<r.length;o++){var a=r[o],l=e[a];i[a]=l.call(this)}n[s]=i}return n};v.prototype.parseStruct=function(t){if(typeof t=="function")return t.call(this);for(var e=Object.keys(t),n={},r=0;r<e.length;r++){var s=e[r],i=t[s];n[s]=i.call(this)}return n};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(),n=new Array(e),r=0;r<e;r++)n[r]=this.parseValueRecord(t);return n};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(),n=e.length,r=this.relativeOffset,s=new Array(n),i=0;i<n;i++){var o=e[i];if(o===0){s[i]=void 0;continue}if(this.relativeOffset=o,t){for(var a=this.parseOffset16List(),l=new Array(a.length),u=0;u<a.length;u++)this.relativeOffset=o+a[u],l[u]=t.call(this);s[i]=l}else s[i]=this.parseUShortList()}return this.relativeOffset=r,s};v.prototype.parseCoverage=function(){var t=this.offset+this.relativeOffset,e=this.parseUShort(),n=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(n)};if(e===2){for(var r=new Array(n),s=0;s<n;s++)r[s]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:r}}throw new Error("0x"+t.toString(16)+": Coverage format must be 1 or 2.")};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 mi={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(mi),langSysRecords:v.recordList({tag:v.tag,langSys:v.pointer(mi)})})}))||[]};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();N.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");var n=this.parseUShort(),r=n&16;return{lookupType:e,lookupFlag:n,subtables:this.parseList(v.pointer(t[e])),markFilteringSet:r?this.parseUShort():void 0}})))||[]};v.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){var t=this.parseUShort(),e=this.parseUShort();N.argument(t===1&&e<1,"GPOS/GSUB feature variations table unknown.");var n=this.parseRecordList32({conditionSetOffset:v.offset32,featureTableSubstitutionOffset:v.offset32});return n})||[]};var O={getByte:gi,getCard8:gi,getUShort:er,getCard16:er,getShort:rl,getULong:ns,getFixed:to,getTag:sl,getOffset:il,getBytes:ol,bytesToString:al,Parser:v};function ul(t,e){e.parseUShort(),t.length=e.parseULong(),t.language=e.parseULong();var n;t.groupCount=n=e.parseULong(),t.glyphIndexMap={};for(var r=0;r<n;r+=1)for(var s=e.parseULong(),i=e.parseULong(),o=e.parseULong(),a=s;a<=i;a+=1)t.glyphIndexMap[a]=o,o++}function cl(t,e,n,r,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 O.Parser(n,r+s+14),a=new O.Parser(n,r+s+16+i*2),l=new O.Parser(n,r+s+16+i*4),u=new O.Parser(n,r+s+16+i*6),c=r+s+16+i*8,f=0;f<i-1;f+=1)for(var h=void 0,p=o.parseUShort(),d=a.parseUShort(),g=l.parseShort(),y=u.parseUShort(),x=d;x<=p;x+=1)y!==0?(c=u.offset+u.relativeOffset-2,c+=y,c+=(x-d)*2,h=O.getUShort(n,c),h!==0&&(h=h+g&65535)):h=x+g&65535,t.glyphIndexMap[x]=h}function hl(t,e){var n={};n.version=O.getUShort(t,e),N.argument(n.version===0,"cmap table version should be 0."),n.numTables=O.getUShort(t,e+2);for(var r=-1,s=n.numTables-1;s>=0;s-=1){var i=O.getUShort(t,e+4+s*8),o=O.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)){r=O.getULong(t,e+4+s*8+4);break}}if(r===-1)throw new Error("No valid cmap sub-tables found.");var a=new O.Parser(t,e+r);if(n.format=a.parseUShort(),n.format===12)ul(n,a);else if(n.format===4)cl(n,a,t,e,r);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+n.format+").");return n}function fl(t,e,n){t.segments.push({end:e,start:e,delta:-(e-n),offset:0,glyphIndex:n})}function pl(t){t.segments.push({end:65535,start:65535,delta:1,offset:0})}function dl(t){var e=!0,n;for(n=t.length-1;n>0;n-=1){var r=t.get(n);if(r.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 C.Table("cmap",s);for(i.segments=[],n=0;n<t.length;n+=1){for(var o=t.get(n),a=0;a<o.unicodes.length;a+=1)fl(i,o.unicodes[a],n);i.segments=i.segments.sort(function(L,w){return L.start-w.start})}pl(i);var l=i.segments.length,u=0,c=[],f=[],h=[],p=[],d=[],g=[];for(n=0;n<l;n+=1){var y=i.segments[n];y.end<=65535&&y.start<=65535?(c=c.concat({name:"end_"+n,type:"USHORT",value:y.end}),f=f.concat({name:"start_"+n,type:"USHORT",value:y.start}),h=h.concat({name:"idDelta_"+n,type:"SHORT",value:y.delta}),p=p.concat({name:"idRangeOffset_"+n,type:"USHORT",value:y.offset}),y.glyphId!==void 0&&(d=d.concat({name:"glyph_"+n,type:"USHORT",value:y.glyphId}))):u+=1,!e&&y.glyphIndex!==void 0&&(g=g.concat({name:"cmap12Start_"+n,type:"ULONG",value:y.start}),g=g.concat({name:"cmap12End_"+n,type:"ULONG",value:y.end}),g=g.concat({name:"cmap12Glyph_"+n,type:"ULONG",value:y.glyphIndex}))}if(i.segCountX2=(l-u)*2,i.searchRange=Math.pow(2,Math.floor(Math.log(l-u)/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(c),i.fields.push({name:"reservedPad",type:"USHORT",value:0}),i.fields=i.fields.concat(f),i.fields=i.fields.concat(h),i.fields=i.fields.concat(p),i.fields=i.fields.concat(d),i.cmap4Length=14+c.length*2+2+f.length*2+h.length*2+p.length*2+d.length*2,!e){var x=16+g.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:x},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:g.length/3}]),i.fields=i.fields.concat(g)}return i}var no={parse:hl,make:dl},Zn=[".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"],gl=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],ml=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],kt=[".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 ro(t){this.font=t}ro.prototype.charToGlyphIndex=function(t){var e=t.codePointAt(0),n=this.font.glyphs;if(n){for(var r=0;r<n.length;r+=1)for(var s=n.get(r),i=0;i<s.unicodes.length;i+=1)if(s.unicodes[i]===e)return r}return null};function so(t){this.cmap=t}so.prototype.charToGlyphIndex=function(t){return this.cmap.glyphIndexMap[t.codePointAt(0)]||0};function tr(t,e){this.encoding=t,this.charset=e}tr.prototype.charToGlyphIndex=function(t){var e=t.codePointAt(0),n=this.encoding[e];return this.charset.indexOf(n)};function rs(t){switch(t.version){case 1:this.names=kt.slice();break;case 2:this.names=new Array(t.numberOfGlyphs);for(var e=0;e<t.numberOfGlyphs;e++)t.glyphNameIndex[e]<kt.length?this.names[e]=kt[t.glyphNameIndex[e]]:this.names[e]=t.names[t.glyphNameIndex[e]-kt.length];break;case 2.5:this.names=new Array(t.numberOfGlyphs);for(var n=0;n<t.numberOfGlyphs;n++)this.names[n]=kt[n+t.glyphNameIndex[n]];break;case 3:this.names=[];break;default:this.names=[];break}}rs.prototype.nameToGlyphIndex=function(t){return this.names.indexOf(t)};rs.prototype.glyphIndexToName=function(t){return this.names[t]};function vl(t){for(var e,n=t.tables.cmap.glyphIndexMap,r=Object.keys(n),s=0;s<r.length;s+=1){var i=r[s],o=n[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 xl(t){t._IndexToUnicodeMap={};for(var e=t.tables.cmap.glyphIndexMap,n=Object.keys(e),r=0;r<n.length;r+=1){var s=n[r],i=e[s];t._IndexToUnicodeMap[i]===void 0?t._IndexToUnicodeMap[i]={unicodes:[parseInt(s)]}:t._IndexToUnicodeMap[i].unicodes.push(parseInt(s))}}function yl(t,e){e.lowMemory?xl(t):vl(t)}function bl(t,e,n,r,s){t.beginPath(),t.moveTo(e,n),t.lineTo(r,s),t.stroke()}var wt={line:bl};function Sl(t,e){var n=e||new ye;return{configurable:!0,get:function(){return typeof n=="function"&&(n=n()),n},set:function(r){n=r}}}function ze(t){this.bindConstructorValues(t)}ze.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",Sl(this,t.path))};ze.prototype.addUnicode=function(t){this.unicodes.length===0&&(this.unicode=t),this.unicodes.push(t)};ze.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};ze.prototype.getPath=function(t,e,n,r,s){t=t!==void 0?t:0,e=e!==void 0?e:0,n=n!==void 0?n:72;var i,o;r||(r={});var a=r.xScale,l=r.yScale;if(r.hinting&&s&&s.hinting&&(o=this.path&&s.hinting.exec(this,n)),o)i=s.hinting.getCommands(o),t=Math.round(t),e=Math.round(e),a=l=1;else{i=this.path.commands;var u=1/(this.path.unitsPerEm||1e3)*n;a===void 0&&(a=u),l===void 0&&(l=u)}for(var c=new ye,f=0;f<i.length;f+=1){var h=i[f];h.type==="M"?c.moveTo(t+h.x*a,e+-h.y*l):h.type==="L"?c.lineTo(t+h.x*a,e+-h.y*l):h.type==="Q"?c.quadraticCurveTo(t+h.x1*a,e+-h.y1*l,t+h.x*a,e+-h.y*l):h.type==="C"?c.curveTo(t+h.x1*a,e+-h.y1*l,t+h.x2*a,e+-h.y2*l,t+h.x*a,e+-h.y*l):h.type==="Z"&&c.closePath()}return c};ze.prototype.getContours=function(){if(this.points===void 0)return[];for(var t=[],e=[],n=0;n<this.points.length;n+=1){var r=this.points[n];e.push(r),r.lastPointOfContour&&(t.push(e),e=[])}return N.argument(e.length===0,"There are still points left in the current contour."),t};ze.prototype.getMetrics=function(){for(var t=this.path.commands,e=[],n=[],r=0;r<t.length;r+=1){var s=t[r];s.type!=="Z"&&(e.push(s.x),n.push(s.y)),(s.type==="Q"||s.type==="C")&&(e.push(s.x1),n.push(s.y1)),s.type==="C"&&(e.push(s.x2),n.push(s.y2))}var i={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,e),yMax:Math.max.apply(null,n),leftSideBearing:this.leftSideBearing};return isFinite(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};ze.prototype.draw=function(t,e,n,r,s){this.getPath(e,n,r,s).draw(t)};ze.prototype.drawPoints=function(t,e,n,r){function s(f,h,p,d){t.beginPath();for(var g=0;g<f.length;g+=1)t.moveTo(h+f[g].x*d,p+f[g].y*d),t.arc(h+f[g].x*d,p+f[g].y*d,2,0,Math.PI*2,!1);t.closePath(),t.fill()}e=e!==void 0?e:0,n=n!==void 0?n:0,r=r!==void 0?r:24;for(var i=1/this.path.unitsPerEm*r,o=[],a=[],l=this.path,u=0;u<l.commands.length;u+=1){var c=l.commands[u];c.x!==void 0&&o.push({x:c.x,y:-c.y}),c.x1!==void 0&&a.push({x:c.x1,y:-c.y1}),c.x2!==void 0&&a.push({x:c.x2,y:-c.y2})}t.fillStyle="blue",s(o,e,n,i),t.fillStyle="red",s(a,e,n,i)};ze.prototype.drawMetrics=function(t,e,n,r){var s;e=e!==void 0?e:0,n=n!==void 0?n:0,r=r!==void 0?r:24,s=1/this.path.unitsPerEm*r,t.lineWidth=1,t.strokeStyle="black",wt.line(t,e,-1e4,e,1e4),wt.line(t,-1e4,n,1e4,n);var i=this.xMin||0,o=this.yMin||0,a=this.xMax||0,l=this.yMax||0,u=this.advanceWidth||0;t.strokeStyle="blue",wt.line(t,e+i*s,-1e4,e+i*s,1e4),wt.line(t,e+a*s,-1e4,e+a*s,1e4),wt.line(t,-1e4,n+-o*s,1e4,n+-o*s),wt.line(t,-1e4,n+-l*s,1e4,n+-l*s),t.strokeStyle="green",wt.line(t,e+u*s,-1e4,e+u*s,1e4)};function Wn(t,e,n){Object.defineProperty(t,e,{get:function(){return t.path,t[n]},set:function(r){t[n]=r},enumerable:!0,configurable:!0})}function ss(t,e){if(this.font=t,this.glyphs={},Array.isArray(e))for(var n=0;n<e.length;n++){var r=e[n];r.path.unitsPerEm=t.unitsPerEm,this.glyphs[n]=r}this.length=e&&e.length||0}ss.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],n=this.font._IndexToUnicodeMap[t];if(n)for(var r=0;r<n.unicodes.length;r++)e.addUnicode(n.unicodes[r]);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]};ss.prototype.push=function(t,e){this.glyphs[t]=e,this.length++};function wl(t,e){return new ze({index:e,font:t})}function kl(t,e,n,r,s,i){return function(){var o=new ze({index:e,font:t});return o.path=function(){n(o,r,s);var a=i(t.glyphs,o);return a.unitsPerEm=t.unitsPerEm,a},Wn(o,"xMin","_xMin"),Wn(o,"xMax","_xMax"),Wn(o,"yMin","_yMin"),Wn(o,"yMax","_yMax"),o}}function El(t,e,n,r){return function(){var s=new ze({index:e,font:t});return s.path=function(){var i=n(t,s,r);return i.unitsPerEm=t.unitsPerEm,i},s}}var et={GlyphSet:ss,glyphLoader:wl,ttfGlyphLoader:kl,cffGlyphLoader:El};function io(t,e){if(t===e)return!0;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n+=1)if(!io(t[n],e[n]))return!1;return!0}else return!1}function Zr(t){var e;return t.length<1240?e=107:t.length<33900?e=1131:e=32768,e}function ht(t,e,n){var r=[],s=[],i=O.getCard16(t,e),o,a;if(i!==0){var l=O.getByte(t,e+2);o=e+(i+1)*l+2;for(var u=e+3,c=0;c<i+1;c+=1)r.push(O.getOffset(t,u,l)),u+=l;a=o+r[i]}else a=e+2;for(var f=0;f<r.length-1;f+=1){var h=O.getBytes(t,o+r[f],o+r[f+1]);n&&(h=n(h)),s.push(h)}return{objects:s,startOffset:e,endOffset:a}}function Pl(t,e){var n=[],r=O.getCard16(t,e),s,i;if(r!==0){var o=O.getByte(t,e+2);s=e+(r+1)*o+2;for(var a=e+3,l=0;l<r+1;l+=1)n.push(O.getOffset(t,a,o)),a+=o;i=s+n[r]}else i=e+2;return{offsets:n,startOffset:e,endOffset:i}}function Ll(t,e,n,r,s){var i=O.getCard16(n,r),o=0;if(i!==0){var a=O.getByte(n,r+2);o=r+(i+1)*a+2}var l=O.getBytes(n,o+e[t],o+e[t+1]);return s&&(l=s(l)),l}function Tl(t){for(var e="",n=15,r=["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===n||(e+=r[i],o===n))break;e+=r[o]}return parseFloat(e)}function Il(t,e){var n,r,s,i;if(e===28)return n=t.parseByte(),r=t.parseByte(),n<<8|r;if(e===29)return n=t.parseByte(),r=t.parseByte(),s=t.parseByte(),i=t.parseByte(),n<<24|r<<16|s<<8|i;if(e===30)return Tl(t);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return n=t.parseByte(),(e-247)*256+n+108;if(e>=251&&e<=254)return n=t.parseByte(),-(e-251)*256-n-108;throw new Error("Invalid b0 "+e)}function Cl(t){for(var e={},n=0;n<t.length;n+=1){var r=t[n][0],s=t[n][1],i=void 0;if(s.length===1?i=s[0]:i=s,e.hasOwnProperty(r)&&!isNaN(e[r]))throw new Error("Object "+e+" already has key "+r);e[r]=i}return e}function oo(t,e,n){e=e!==void 0?e:0;var r=new O.Parser(t,e),s=[],i=[];for(n=n!==void 0?n:t.length;r.relativeOffset<n;){var o=r.parseByte();o<=21?(o===12&&(o=1200+r.parseByte()),s.push([o,i]),i=[]):i.push(Il(r,o))}return Cl(s)}function ln(t,e){return e<=390?e=Zn[e]:e=t[e-391],e}function ao(t,e,n){for(var r={},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 l=0;l<o.type.length;l++)s=t[o.op]!==void 0?t[o.op][l]:void 0,s===void 0&&(s=o.value!==void 0&&o.value[l]!==void 0?o.value[l]:null),o.type[l]==="SID"&&(s=ln(n,s)),a[l]=s;r[o.name]=a}else s=t[o.op],s===void 0&&(s=o.value!==void 0?o.value:null),o.type==="SID"&&(s=ln(n,s)),r[o.name]=s}return r}function Ml(t,e){var n={};return n.formatMajor=O.getCard8(t,e),n.formatMinor=O.getCard8(t,e+1),n.size=O.getCard8(t,e+2),n.offsetSize=O.getCard8(t,e+3),n.startOffset=e,n.endOffset=e+4,n}var lo=[{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"}],uo=[{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 Al(t,e){var n=oo(t,0,t.byteLength);return ao(n,lo,e)}function co(t,e,n,r){var s=oo(t,e,n);return ao(s,uo,r)}function vi(t,e,n,r){for(var s=[],i=0;i<n.length;i+=1){var o=new DataView(new Uint8Array(n[i]).buffer),a=Al(o,r);a._subrs=[],a._subrsBias=0,a._defaultWidthX=0,a._nominalWidthX=0;var l=a.private[0],u=a.private[1];if(l!==0&&u!==0){var c=co(t,u+e,l,r);if(a._defaultWidthX=c.defaultWidthX,a._nominalWidthX=c.nominalWidthX,c.subrs!==0){var f=u+c.subrs,h=ht(t,f+e);a._subrs=h.objects,a._subrsBias=Zr(a._subrs)}a._privateDict=c}s.push(a)}return s}function Ol(t,e,n,r){var s,i,o=new O.Parser(t,e);n-=1;var a=[".notdef"],l=o.parseCard8();if(l===0)for(var u=0;u<n;u+=1)s=o.parseSID(),a.push(ln(r,s));else if(l===1)for(;a.length<=n;){s=o.parseSID(),i=o.parseCard8();for(var c=0;c<=i;c+=1)a.push(ln(r,s)),s+=1}else if(l===2)for(;a.length<=n;){s=o.parseSID(),i=o.parseCard16();for(var f=0;f<=i;f+=1)a.push(ln(r,s)),s+=1}else throw new Error("Unknown charset format "+l);return a}function Fl(t,e,n){var r,s={},i=new O.Parser(t,e),o=i.parseCard8();if(o===0)for(var a=i.parseCard8(),l=0;l<a;l+=1)r=i.parseCard8(),s[r]=l;else if(o===1){var u=i.parseCard8();r=1;for(var c=0;c<u;c+=1)for(var f=i.parseCard8(),h=i.parseCard8(),p=f;p<=f+h;p+=1)s[p]=r,r+=1}else throw new Error("Unknown encoding format "+o);return new tr(s,n)}function xi(t,e,n){var r,s,i,o,a=new ye,l=[],u=0,c=!1,f=!1,h=0,p=0,d,g,y,x;if(t.isCIDFont){var L=t.tables.cff.topDict._fdSelect[e.index],w=t.tables.cff.topDict._fdArray[L];d=w._subrs,g=w._subrsBias,y=w._defaultWidthX,x=w._nominalWidthX}else d=t.tables.cff.topDict._subrs,g=t.tables.cff.topDict._subrsBias,y=t.tables.cff.topDict._defaultWidthX,x=t.tables.cff.topDict._nominalWidthX;var A=y;function T(P,F){f&&a.closePath(),a.moveTo(P,F),f=!0}function U(){var P;P=l.length%2!==0,P&&!c&&(A=l.shift()+x),u+=l.length>>1,l.length=0,c=!0}function E(P){for(var F,z,R,he,V,W,$,Z,ne,te,oe,fe,Q=0;Q<P.length;){var k=P[Q];switch(Q+=1,k){case 1:U();break;case 3:U();break;case 4:l.length>1&&!c&&(A=l.shift()+x,c=!0),p+=l.pop(),T(h,p);break;case 5:for(;l.length>0;)h+=l.shift(),p+=l.shift(),a.lineTo(h,p);break;case 6:for(;l.length>0&&(h+=l.shift(),a.lineTo(h,p),l.length!==0);)p+=l.shift(),a.lineTo(h,p);break;case 7:for(;l.length>0&&(p+=l.shift(),a.lineTo(h,p),l.length!==0);)h+=l.shift(),a.lineTo(h,p);break;case 8:for(;l.length>0;)r=h+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),h=i+l.shift(),p=o+l.shift(),a.curveTo(r,s,i,o,h,p);break;case 10:V=l.pop()+g,W=d[V],W&&E(W);break;case 11:return;case 12:switch(k=P[Q],Q+=1,k){case 35:r=h+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),$=i+l.shift(),Z=o+l.shift(),ne=$+l.shift(),te=Z+l.shift(),oe=ne+l.shift(),fe=te+l.shift(),h=oe+l.shift(),p=fe+l.shift(),l.shift(),a.curveTo(r,s,i,o,$,Z),a.curveTo(ne,te,oe,fe,h,p);break;case 34:r=h+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),$=i+l.shift(),Z=o,ne=$+l.shift(),te=o,oe=ne+l.shift(),fe=p,h=oe+l.shift(),a.curveTo(r,s,i,o,$,Z),a.curveTo(ne,te,oe,fe,h,p);break;case 36:r=h+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),$=i+l.shift(),Z=o,ne=$+l.shift(),te=o,oe=ne+l.shift(),fe=te+l.shift(),h=oe+l.shift(),a.curveTo(r,s,i,o,$,Z),a.curveTo(ne,te,oe,fe,h,p);break;case 37:r=h+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),$=i+l.shift(),Z=o+l.shift(),ne=$+l.shift(),te=Z+l.shift(),oe=ne+l.shift(),fe=te+l.shift(),Math.abs(oe-h)>Math.abs(fe-p)?h=oe+l.shift():p=fe+l.shift(),a.curveTo(r,s,i,o,$,Z),a.curveTo(ne,te,oe,fe,h,p);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+k),l.length=0}break;case 14:l.length>0&&!c&&(A=l.shift()+x,c=!0),f&&(a.closePath(),f=!1);break;case 18:U();break;case 19:case 20:U(),Q+=u+7>>3;break;case 21:l.length>2&&!c&&(A=l.shift()+x,c=!0),p+=l.pop(),h+=l.pop(),T(h,p);break;case 22:l.length>1&&!c&&(A=l.shift()+x,c=!0),h+=l.pop(),T(h,p);break;case 23:U();break;case 24:for(;l.length>2;)r=h+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),h=i+l.shift(),p=o+l.shift(),a.curveTo(r,s,i,o,h,p);h+=l.shift(),p+=l.shift(),a.lineTo(h,p);break;case 25:for(;l.length>6;)h+=l.shift(),p+=l.shift(),a.lineTo(h,p);r=h+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),h=i+l.shift(),p=o+l.shift(),a.curveTo(r,s,i,o,h,p);break;case 26:for(l.length%2&&(h+=l.shift());l.length>0;)r=h,s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),h=i,p=o+l.shift(),a.curveTo(r,s,i,o,h,p);break;case 27:for(l.length%2&&(p+=l.shift());l.length>0;)r=h+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),h=i+l.shift(),p=o,a.curveTo(r,s,i,o,h,p);break;case 28:F=P[Q],z=P[Q+1],l.push((F<<24|z<<16)>>16),Q+=2;break;case 29:V=l.pop()+t.gsubrsBias,W=t.gsubrs[V],W&&E(W);break;case 30:for(;l.length>0&&(r=h,s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),h=i+l.shift(),p=o+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,h,p),l.length!==0);)r=h+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),p=o+l.shift(),h=i+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,h,p);break;case 31:for(;l.length>0&&(r=h+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),p=o+l.shift(),h=i+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,h,p),l.length!==0);)r=h,s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),h=i+l.shift(),p=o+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,h,p);break;default:k<32?console.log("Glyph "+e.index+": unknown operator "+k):k<247?l.push(k-139):k<251?(F=P[Q],Q+=1,l.push((k-247)*256+F+108)):k<255?(F=P[Q],Q+=1,l.push(-(k-251)*256-F-108)):(F=P[Q],z=P[Q+1],R=P[Q+2],he=P[Q+3],Q+=4,l.push((F<<24|z<<16|R<<8|he)/65536))}}}return E(n),e.advanceWidth=A,a}function Dl(t,e,n,r){var s=[],i,o=new O.Parser(t,e),a=o.parseCard8();if(a===0)for(var l=0;l<n;l++){if(i=o.parseCard8(),i>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+r+")");s.push(i)}else if(a===3){var u=o.parseCard16(),c=o.parseCard16();if(c!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+c);for(var f,h=0;h<u;h++){if(i=o.parseCard8(),f=o.parseCard16(),i>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+r+")");if(f>n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+f);for(;c<f;c++)s.push(i);c=f}if(f!==n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+f)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+a);return s}function Rl(t,e,n,r){n.tables.cff={};var s=Ml(t,e),i=ht(t,s.endOffset,O.bytesToString),o=ht(t,i.endOffset),a=ht(t,o.endOffset,O.bytesToString),l=ht(t,a.endOffset);n.gsubrs=l.objects,n.gsubrsBias=Zr(n.gsubrs);var u=vi(t,e,o.objects,a.objects);if(u.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+u.length);var c=u[0];if(n.tables.cff.topDict=c,c._privateDict&&(n.defaultWidthX=c._privateDict.defaultWidthX,n.nominalWidthX=c._privateDict.nominalWidthX),c.ros[0]!==void 0&&c.ros[1]!==void 0&&(n.isCIDFont=!0),n.isCIDFont){var f=c.fdArray,h=c.fdSelect;if(f===0||h===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");f+=e;var p=ht(t,f),d=vi(t,e,p.objects,a.objects);c._fdArray=d,h+=e,c._fdSelect=Dl(t,h,n.numGlyphs,d.length)}var g=e+c.private[1],y=co(t,g,c.private[0],a.objects);if(n.defaultWidthX=y.defaultWidthX,n.nominalWidthX=y.nominalWidthX,y.subrs!==0){var x=g+y.subrs,L=ht(t,x);n.subrs=L.objects,n.subrsBias=Zr(n.subrs)}else n.subrs=[],n.subrsBias=0;var w;r.lowMemory?(w=Pl(t,e+c.charStrings),n.nGlyphs=w.offsets.length):(w=ht(t,e+c.charStrings),n.nGlyphs=w.objects.length);var A=Ol(t,e+c.charset,n.nGlyphs,a.objects);if(c.encoding===0?n.cffEncoding=new tr(gl,A):c.encoding===1?n.cffEncoding=new tr(ml,A):n.cffEncoding=Fl(t,e+c.encoding,A),n.encoding=n.encoding||n.cffEncoding,n.glyphs=new et.GlyphSet(n),r.lowMemory)n._push=function(E){var P=Ll(E,w.offsets,t,e+c.charStrings);n.glyphs.push(E,et.cffGlyphLoader(n,E,xi,P))};else for(var T=0;T<n.nGlyphs;T+=1){var U=w.objects[T];n.glyphs.push(T,et.cffGlyphLoader(n,T,xi,U))}}function ho(t,e){var n,r=Zn.indexOf(t);return r>=0&&(n=r),r=e.indexOf(t),r>=0?n=r+Zn.length:(n=Zn.length+e.length,e.push(t)),n}function Ul(){return new C.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 Nl(t){var e=new C.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(var n=0;n<t.length;n+=1)e.names.push({name:"name_"+n,type:"NAME",value:t[n]});return e}function fo(t,e,n){for(var r={},s=0;s<t.length;s+=1){var i=t[s],o=e[i.name];o!==void 0&&!io(o,i.value)&&(i.type==="SID"&&(o=ho(o,n)),r[i.op]={name:i.name,type:i.type,value:o})}return r}function yi(t,e){var n=new C.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return n.dict=fo(lo,t,e),n}function bi(t){var e=new C.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:t}],e}function Bl(t){var e=new C.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(var n=0;n<t.length;n+=1)e.strings.push({name:"string_"+n,type:"STRING",value:t[n]});return e}function Gl(){return new C.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function zl(t,e){for(var n=new C.Record("Charsets",[{name:"format",type:"Card8",value:0}]),r=0;r<t.length;r+=1){var s=t[r],i=ho(s,e);n.fields.push({name:"glyph_"+r,type:"SID",value:i})}return n}function Hl(t){var e=[],n=t.path;e.push({name:"width",type:"NUMBER",value:t.advanceWidth});for(var r=0,s=0,i=0;i<n.commands.length;i+=1){var o=void 0,a=void 0,l=n.commands[i];if(l.type==="Q"){var u=.3333333333333333,c=2/3;l={type:"C",x:l.x,y:l.y,x1:Math.round(u*r+c*l.x1),y1:Math.round(u*s+c*l.y1),x2:Math.round(u*l.x+c*l.x1),y2:Math.round(u*l.y+c*l.y1)}}if(l.type==="M")o=Math.round(l.x-r),a=Math.round(l.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}),r=Math.round(l.x),s=Math.round(l.y);else if(l.type==="L")o=Math.round(l.x-r),a=Math.round(l.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}),r=Math.round(l.x),s=Math.round(l.y);else if(l.type==="C"){var f=Math.round(l.x1-r),h=Math.round(l.y1-s),p=Math.round(l.x2-l.x1),d=Math.round(l.y2-l.y1);o=Math.round(l.x-l.x2),a=Math.round(l.y-l.y2),e.push({name:"dx1",type:"NUMBER",value:f}),e.push({name:"dy1",type:"NUMBER",value:h}),e.push({name:"dx2",type:"NUMBER",value:p}),e.push({name:"dy2",type:"NUMBER",value:d}),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rrcurveto",type:"OP",value:8}),r=Math.round(l.x),s=Math.round(l.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function Vl(t){for(var e=new C.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),n=0;n<t.length;n+=1){var r=t.get(n),s=Hl(r);e.charStrings.push({name:r.name,type:"CHARSTRING",value:s})}return e}function $l(t,e){var n=new C.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return n.dict=fo(uo,t,e),n}function Xl(t,e){for(var n=new C.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),r=1/e.unitsPerEm,s={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[r,0,0,r,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},i={},o=[],a,l=1;l<t.length;l+=1)a=t.get(l),o.push(a.name);var u=[];n.header=Ul(),n.nameIndex=Nl([e.postScriptName]);var c=yi(s,u);n.topDictIndex=bi(c),n.globalSubrIndex=Gl(),n.charsets=zl(o,u),n.charStringsIndex=Vl(t),n.privateDict=$l(i,u),n.stringIndex=Bl(u);var f=n.header.sizeOf()+n.nameIndex.sizeOf()+n.topDictIndex.sizeOf()+n.stringIndex.sizeOf()+n.globalSubrIndex.sizeOf();return s.charset=f,s.encoding=0,s.charStrings=s.charset+n.charsets.sizeOf(),s.private[1]=s.charStrings+n.charStringsIndex.sizeOf(),c=yi(s,u),n.topDictIndex=bi(c),n}var po={parse:Rl,make:Xl};function ql(t,e){var n={},r=new O.Parser(t,e);return n.version=r.parseVersion(),n.fontRevision=Math.round(r.parseFixed()*1e3)/1e3,n.checkSumAdjustment=r.parseULong(),n.magicNumber=r.parseULong(),N.argument(n.magicNumber===1594834165,"Font header has wrong magic number."),n.flags=r.parseUShort(),n.unitsPerEm=r.parseUShort(),n.created=r.parseLongDateTime(),n.modified=r.parseLongDateTime(),n.xMin=r.parseShort(),n.yMin=r.parseShort(),n.xMax=r.parseShort(),n.yMax=r.parseShort(),n.macStyle=r.parseUShort(),n.lowestRecPPEM=r.parseUShort(),n.fontDirectionHint=r.parseShort(),n.indexToLocFormat=r.parseShort(),n.glyphDataFormat=r.parseShort(),n}function Wl(t){var e=Math.round(new Date().getTime()/1e3)+2082844800,n=e;return t.createdTimestamp&&(n=t.createdTimestamp+2082844800),new C.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:n},{name:"modified",type:"LONGDATETIME",value:e},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value: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 go={parse:ql,make:Wl};function _l(t,e){var n={},r=new O.Parser(t,e);return n.version=r.parseVersion(),n.ascender=r.parseShort(),n.descender=r.parseShort(),n.lineGap=r.parseShort(),n.advanceWidthMax=r.parseUShort(),n.minLeftSideBearing=r.parseShort(),n.minRightSideBearing=r.parseShort(),n.xMaxExtent=r.parseShort(),n.caretSlopeRise=r.parseShort(),n.caretSlopeRun=r.parseShort(),n.caretOffset=r.parseShort(),r.relativeOffset+=8,n.metricDataFormat=r.parseShort(),n.numberOfHMetrics=r.parseUShort(),n}function Zl(t){return new C.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 mo={parse:_l,make:Zl};function jl(t,e,n,r,s){for(var i,o,a=new O.Parser(t,e),l=0;l<r;l+=1){l<n&&(i=a.parseUShort(),o=a.parseShort());var u=s.get(l);u.advanceWidth=i,u.leftSideBearing=o}}function Yl(t,e,n,r,s){t._hmtxTableData={};for(var i,o,a=new O.Parser(e,n),l=0;l<s;l+=1)l<r&&(i=a.parseUShort(),o=a.parseShort()),t._hmtxTableData[l]={advanceWidth:i,leftSideBearing:o}}function Kl(t,e,n,r,s,i,o){o.lowMemory?Yl(t,e,n,r,s):jl(e,n,r,s,i)}function Jl(t){for(var e=new C.Table("hmtx",[]),n=0;n<t.length;n+=1){var r=t.get(n),s=r.advanceWidth||0,i=r.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+n,type:"USHORT",value:s}),e.fields.push({name:"leftSideBearing_"+n,type:"SHORT",value:i})}return e}var vo={parse:Kl,make:Jl};function Ql(t){for(var e=new C.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:t.length}]),n="",r=12+t.length*4,s=0;s<t.length;++s){var i=n.indexOf(t[s]);i<0&&(i=n.length,n+=t[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:r+i}),e.fields.push({name:"length "+s,type:"USHORT",value:t[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:n}),e}function eu(t,e){var n=new O.Parser(t,e),r=n.parseULong();N.argument(r===1,"Unsupported ltag table version."),n.skip("uLong",1);for(var s=n.parseULong(),i=[],o=0;o<s;o++){for(var a="",l=e+n.parseUShort(),u=n.parseUShort(),c=l;c<l+u;++c)a+=String.fromCharCode(t.getInt8(c));i.push(a)}return i}var xo={make:Ql,parse:eu};function tu(t,e){var n={},r=new O.Parser(t,e);return n.version=r.parseVersion(),n.numGlyphs=r.parseUShort(),n.version===1&&(n.maxPoints=r.parseUShort(),n.maxContours=r.parseUShort(),n.maxCompositePoints=r.parseUShort(),n.maxCompositeContours=r.parseUShort(),n.maxZones=r.parseUShort(),n.maxTwilightPoints=r.parseUShort(),n.maxStorage=r.parseUShort(),n.maxFunctionDefs=r.parseUShort(),n.maxInstructionDefs=r.parseUShort(),n.maxStackElements=r.parseUShort(),n.maxSizeOfInstructions=r.parseUShort(),n.maxComponentElements=r.parseUShort(),n.maxComponentDepth=r.parseUShort()),n}function nu(t){return new C.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:t}])}var yo={parse:tu,make:nu},bo=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],So={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"},ru={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},wo={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 su(t,e,n){switch(t){case 0:if(e===65535)return"und";if(n)return n[e];break;case 1:return So[e];case 3:return wo[e]}}var jr="utf-16",iu={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"},ou={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 ko(t,e,n){switch(t){case 0:return jr;case 1:return ou[n]||iu[e];case 3:if(e===1||e===10)return jr;break}}function au(t,e,n){for(var r={},s=new O.Parser(t,e),i=s.parseUShort(),o=s.parseUShort(),a=s.offset+s.parseUShort(),l=0;l<o;l++){var u=s.parseUShort(),c=s.parseUShort(),f=s.parseUShort(),h=s.parseUShort(),p=bo[h]||h,d=s.parseUShort(),g=s.parseUShort(),y=su(u,f,n),x=ko(u,c,f);if(x!==void 0&&y!==void 0){var L=void 0;if(x===jr?L=Bt.UTF16(t,a+g,d):L=Bt.MACSTRING(t,a+g,d,x),L){var w=r[p];w===void 0&&(w=r[p]={}),w[y]=L}}}var A=0;return i===1&&(A=s.parseUShort()),r}function Ur(t){var e={};for(var n in t)e[t[n]]=parseInt(n);return e}function Si(t,e,n,r,s,i){return new C.Record("NameRecord",[{name:"platformID",type:"USHORT",value:t},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:n},{name:"nameID",type:"USHORT",value:r},{name:"length",type:"USHORT",value:s},{name:"offset",type:"USHORT",value:i}])}function lu(t,e){var n=t.length,r=e.length-n+1;e:for(var s=0;s<r;s++)for(;s<r;s++){for(var i=0;i<n;i++)if(e[s+i]!==t[i])continue e;return s}return-1}function wi(t,e){var n=lu(t,e);if(n<0){n=e.length;for(var r=0,s=t.length;r<s;++r)e.push(t[r])}return n}function uu(t,e){var n,r=[],s={},i=Ur(bo);for(var o in t){var a=i[o];if(a===void 0&&(a=o),n=parseInt(a),isNaN(n))throw new Error('Name table entry "'+o+'" does not exist, see nameTableNames for complete list.');s[n]=t[o],r.push(n)}for(var l=Ur(So),u=Ur(wo),c=[],f=[],h=0;h<r.length;h++){n=r[h];var p=s[n];for(var d in p){var g=p[d],y=1,x=l[d],L=ru[x],w=ko(y,L,x),A=I.MACSTRING(g,w);A===void 0&&(y=0,x=e.indexOf(d),x<0&&(x=e.length,e.push(d)),L=4,A=I.UTF16(g));var T=wi(A,f);c.push(Si(y,L,x,n,A.length,T));var U=u[d];if(U!==void 0){var E=I.UTF16(g),P=wi(E,f);c.push(Si(3,1,U,n,E.length,P))}}}c.sort(function(R,he){return R.platformID-he.platformID||R.encodingID-he.encodingID||R.languageID-he.languageID||R.nameID-he.nameID});for(var F=new C.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:c.length},{name:"stringOffset",type:"USHORT",value:6+c.length*12}]),z=0;z<c.length;z++)F.fields.push({name:"record_"+z,type:"RECORD",value:c[z]});return F.fields.push({name:"strings",type:"LITERAL",value:f}),F}var Eo={parse:au,make:uu},Yr=[{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(t){for(var e=0;e<Yr.length;e+=1){var n=Yr[e];if(t>=n.begin&&t<n.end)return e}return-1}function hu(t,e){var n={},r=new O.Parser(t,e);n.version=r.parseUShort(),n.xAvgCharWidth=r.parseShort(),n.usWeightClass=r.parseUShort(),n.usWidthClass=r.parseUShort(),n.fsType=r.parseUShort(),n.ySubscriptXSize=r.parseShort(),n.ySubscriptYSize=r.parseShort(),n.ySubscriptXOffset=r.parseShort(),n.ySubscriptYOffset=r.parseShort(),n.ySuperscriptXSize=r.parseShort(),n.ySuperscriptYSize=r.parseShort(),n.ySuperscriptXOffset=r.parseShort(),n.ySuperscriptYOffset=r.parseShort(),n.yStrikeoutSize=r.parseShort(),n.yStrikeoutPosition=r.parseShort(),n.sFamilyClass=r.parseShort(),n.panose=[];for(var s=0;s<10;s++)n.panose[s]=r.parseByte();return n.ulUnicodeRange1=r.parseULong(),n.ulUnicodeRange2=r.parseULong(),n.ulUnicodeRange3=r.parseULong(),n.ulUnicodeRange4=r.parseULong(),n.achVendID=String.fromCharCode(r.parseByte(),r.parseByte(),r.parseByte(),r.parseByte()),n.fsSelection=r.parseUShort(),n.usFirstCharIndex=r.parseUShort(),n.usLastCharIndex=r.parseUShort(),n.sTypoAscender=r.parseShort(),n.sTypoDescender=r.parseShort(),n.sTypoLineGap=r.parseShort(),n.usWinAscent=r.parseUShort(),n.usWinDescent=r.parseUShort(),n.version>=1&&(n.ulCodePageRange1=r.parseULong(),n.ulCodePageRange2=r.parseULong()),n.version>=2&&(n.sxHeight=r.parseShort(),n.sCapHeight=r.parseShort(),n.usDefaultChar=r.parseUShort(),n.usBreakChar=r.parseUShort(),n.usMaxContent=r.parseUShort()),n}function fu(t){return new C.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 Kr={parse:hu,make:fu,unicodeRanges:Yr,getUnicodeRange:cu};function pu(t,e){var n={},r=new O.Parser(t,e);switch(n.version=r.parseVersion(),n.italicAngle=r.parseFixed(),n.underlinePosition=r.parseShort(),n.underlineThickness=r.parseShort(),n.isFixedPitch=r.parseULong(),n.minMemType42=r.parseULong(),n.maxMemType42=r.parseULong(),n.minMemType1=r.parseULong(),n.maxMemType1=r.parseULong(),n.version){case 1:n.names=kt.slice();break;case 2:n.numberOfGlyphs=r.parseUShort(),n.glyphNameIndex=new Array(n.numberOfGlyphs);for(var s=0;s<n.numberOfGlyphs;s++)n.glyphNameIndex[s]=r.parseUShort();n.names=[];for(var i=0;i<n.numberOfGlyphs;i++)if(n.glyphNameIndex[i]>=kt.length){var o=r.parseChar();n.names.push(r.parseString(o))}break;case 2.5:n.numberOfGlyphs=r.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(var a=0;a<n.numberOfGlyphs;a++)n.offset[a]=r.parseChar();break}return n}function du(){return new C.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 Po={parse:pu,make:du},Xe=new Array(9);Xe[1]=function(){var e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{substFormat:1,coverage:this.parsePointer(v.coverage),deltaGlyphId:this.parseUShort()};if(n===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.")};Xe[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()}};Xe[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()}};Xe[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 Nt={sequenceIndex:v.uShort,lookupListIndex:v.uShort};Xe[5]=function(){var e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{substFormat:n,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,Nt)}})};if(n===2)return{substFormat:n,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,Nt)}})};if(n===3){var r=this.parseUShort(),s=this.parseUShort();return{substFormat:n,coverages:this.parseList(r,v.pointer(v.coverage)),lookupRecords:this.parseRecordList(s,Nt)}}N.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")};Xe[6]=function(){var e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===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(Nt)}})};if(n===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(Nt)}})};if(n===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(Nt)};N.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")};Xe[7]=function(){var e=this.parseUShort();N.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");var n=this.parseUShort(),r=new v(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:n,extension:Xe[n].call(r)}};Xe[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 gu(t,e){e=e||0;var n=new v(t,e),r=n.parseVersion(1);return N.argument(r===1||r===1.1,"Unsupported GSUB table version."),r===1?{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(Xe)}:{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(Xe),variations:n.parseFeatureVariationsList()}}var Gt=new Array(9);Gt[1]=function(e){return e.substFormat===1?new C.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new C.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new C.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new C.Coverage(e.coverage)}].concat(C.ushortList("substitute",e.substitute)))};Gt[2]=function(e){return N.assert(e.substFormat===1,"Lookup type 2 substFormat must be 1."),new C.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new C.Coverage(e.coverage)}].concat(C.tableList("seqSet",e.sequences,function(n){return new C.Table("sequenceSetTable",C.ushortList("sequence",n))})))};Gt[3]=function(e){return N.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new C.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new C.Coverage(e.coverage)}].concat(C.tableList("altSet",e.alternateSets,function(n){return new C.Table("alternateSetTable",C.ushortList("alternate",n))})))};Gt[4]=function(e){return N.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new C.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new C.Coverage(e.coverage)}].concat(C.tableList("ligSet",e.ligatureSets,function(n){return new C.Table("ligatureSetTable",C.tableList("ligature",n,function(r){return new C.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:r.ligGlyph}].concat(C.ushortList("component",r.components,r.components.length+1)))}))})))};Gt[6]=function(e){if(e.substFormat===1){var n=new C.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new C.Coverage(e.coverage)}].concat(C.tableList("chainRuleSet",e.chainRuleSets,function(i){return new C.Table("chainRuleSetTable",C.tableList("chainRule",i,function(o){var a=C.ushortList("backtrackGlyph",o.backtrack,o.backtrack.length).concat(C.ushortList("inputGlyph",o.input,o.input.length+1)).concat(C.ushortList("lookaheadGlyph",o.lookahead,o.lookahead.length)).concat(C.ushortList("substitution",[],o.lookupRecords.length));return o.lookupRecords.forEach(function(l,u){a=a.concat({name:"sequenceIndex"+u,type:"USHORT",value:l.sequenceIndex}).concat({name:"lookupListIndex"+u,type:"USHORT",value:l.lookupListIndex})}),new C.Table("chainRuleTable",a)}))})));return n}else if(e.substFormat===2)N.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(e.substFormat===3){var r=[{name:"substFormat",type:"USHORT",value:e.substFormat}];r.push({name:"backtrackGlyphCount",type:"USHORT",value:e.backtrackCoverage.length}),e.backtrackCoverage.forEach(function(i,o){r.push({name:"backtrackCoverage"+o,type:"TABLE",value:new C.Coverage(i)})}),r.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length}),e.inputCoverage.forEach(function(i,o){r.push({name:"inputCoverage"+o,type:"TABLE",value:new C.Coverage(i)})}),r.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length}),e.lookaheadCoverage.forEach(function(i,o){r.push({name:"lookaheadCoverage"+o,type:"TABLE",value:new C.Coverage(i)})}),r.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length}),e.lookupRecords.forEach(function(i,o){r=r.concat({name:"sequenceIndex"+o,type:"USHORT",value:i.sequenceIndex}).concat({name:"lookupListIndex"+o,type:"USHORT",value:i.lookupListIndex})});var s=new C.Table("chainContextTable",r);return s}N.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function mu(t){return new C.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new C.ScriptList(t.scripts)},{name:"features",type:"TABLE",value:new C.FeatureList(t.features)},{name:"lookups",type:"TABLE",value:new C.LookupList(t.lookups,Gt)}])}var Lo={parse:gu,make:mu};function vu(t,e){var n=new O.Parser(t,e),r=n.parseULong();N.argument(r===1,"Unsupported META table version."),n.parseULong(),n.parseULong();for(var s=n.parseULong(),i={},o=0;o<s;o++){var a=n.parseTag(),l=n.parseULong(),u=n.parseULong(),c=Bt.UTF8(t,e+l,u);i[a]=c}return i}function xu(t){var e=Object.keys(t).length,n="",r=16+e*12,s=new C.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:r},{name:"numTags",type:"ULONG",value:e}]);for(var i in t){var o=n.length;n+=t[i],s.fields.push({name:"tag "+i,type:"TAG",value:i}),s.fields.push({name:"offset "+i,type:"ULONG",value:r+o}),s.fields.push({name:"length "+i,type:"ULONG",value:t[i].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:n}),s}var To={parse:vu,make:xu};function ki(t){return Math.log(t)/Math.log(2)|0}function is(t){for(;t.length%4!==0;)t.push(0);for(var e=0,n=0;n<t.length;n+=4)e+=(t[n]<<24)+(t[n+1]<<16)+(t[n+2]<<8)+t[n+3];return e%=Math.pow(2,32),e}function Ei(t,e,n,r){return new C.Record("Table Record",[{name:"tag",type:"TAG",value:t!==void 0?t:""},{name:"checkSum",type:"ULONG",value:e!==void 0?e:0},{name:"offset",type:"ULONG",value:n!==void 0?n:0},{name:"length",type:"ULONG",value:r!==void 0?r:0}])}function Io(t){var e=new C.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 n=Math.pow(2,ki(e.numTables));e.searchRange=16*n,e.entrySelector=ki(n),e.rangeShift=e.numTables*16-e.searchRange;for(var r=[],s=[],i=e.sizeOf()+Ei().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];N.argument(a.tableName.length===4,"Table name"+a.tableName+" is invalid.");var l=a.sizeOf(),u=Ei(a.tableName,is(a.encode()),i,l);for(r.push({name:u.tag+" Table Record",type:"RECORD",value:u}),s.push({name:a.tableName+" table",type:"RECORD",value:a}),i+=l,N.argument(!isNaN(i),"Something went wrong calculating the offset.");i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0})}return r.sort(function(c,f){return c.value.tag>f.value.tag?1:-1}),e.fields=e.fields.concat(r),e.fields=e.fields.concat(s),e}function Pi(t,e,n){for(var r=0;r<e.length;r+=1){var s=t.charToGlyphIndex(e[r]);if(s>0){var i=t.glyphs.get(s);return i.getMetrics()}}return n}function yu(t){for(var e=0,n=0;n<t.length;n+=1)e+=t[n];return e/t.length}function bu(t){for(var e=[],n=[],r=[],s=[],i=[],o=[],a=[],l,u=0,c=0,f=0,h=0,p=0,d=0;d<t.glyphs.length;d+=1){var g=t.glyphs.get(d),y=g.unicode|0;if(isNaN(g.advanceWidth))throw new Error("Glyph "+g.name+" ("+d+"): advanceWidth is not a number.");(l>y||l===void 0)&&y>0&&(l=y),u<y&&(u=y);var x=Kr.getUnicodeRange(y);if(x<32)c|=1<<x;else if(x<64)f|=1<<x-32;else if(x<96)h|=1<<x-64;else if(x<123)p|=1<<x-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(g.name!==".notdef"){var L=g.getMetrics();e.push(L.xMin),n.push(L.yMin),r.push(L.xMax),s.push(L.yMax),o.push(L.leftSideBearing),a.push(L.rightSideBearing),i.push(g.advanceWidth)}}var w={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,r),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,i),advanceWidthAvg:yu(i),minLeftSideBearing:Math.min.apply(null,o),maxLeftSideBearing:Math.max.apply(null,o),minRightSideBearing:Math.min.apply(null,a)};w.ascender=t.ascender,w.descender=t.descender;var A=go.make({flags:3,unitsPerEm:t.unitsPerEm,xMin:w.xMin,yMin:w.yMin,xMax:w.xMax,yMax:w.yMax,lowestRecPPEM:3,createdTimestamp:t.createdTimestamp}),T=mo.make({ascender:w.ascender,descender:w.descender,advanceWidthMax:w.advanceWidthMax,minLeftSideBearing:w.minLeftSideBearing,minRightSideBearing:w.minRightSideBearing,xMaxExtent:w.maxLeftSideBearing+(w.xMax-w.xMin),numberOfHMetrics:t.glyphs.length}),U=yo.make(t.glyphs.length),E=Kr.make(Object.assign({xAvgCharWidth:Math.round(w.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:u,ulUnicodeRange1:c,ulUnicodeRange2:f,ulUnicodeRange3:h,ulUnicodeRange4:p,sTypoAscender:w.ascender,sTypoDescender:w.descender,sTypoLineGap:0,usWinAscent:w.yMax,usWinDescent:Math.abs(w.yMin),ulCodePageRange1:1,sxHeight:Pi(t,"xyvw",{yMax:Math.round(w.ascender/2)}).yMax,sCapHeight:Pi(t,"HIKLEFJMNTZBDPRAGOQSUVWXY",w).yMax,usDefaultChar:t.hasChar(" ")?32:0,usBreakChar:t.hasChar(" ")?32:0},t.tables.os2)),P=vo.make(t.glyphs),F=no.make(t.glyphs),z=t.getEnglishName("fontFamily"),R=t.getEnglishName("fontSubfamily"),he=z+" "+R,V=t.getEnglishName("postScriptName");V||(V=z.replace(/\s/g,"")+"-"+R);var W={};for(var $ in t.names)W[$]=t.names[$];W.uniqueID||(W.uniqueID={en:t.getEnglishName("manufacturer")+":"+he}),W.postScriptName||(W.postScriptName={en:V}),W.preferredFamily||(W.preferredFamily=t.names.fontFamily),W.preferredSubfamily||(W.preferredSubfamily=t.names.fontSubfamily);var Z=[],ne=Eo.make(W,Z),te=Z.length>0?xo.make(Z):void 0,oe=Po.make(),fe=po.make(t.glyphs,{version:t.getEnglishName("version"),fullName:he,familyName:z,weightName:R,postScriptName:V,unitsPerEm:t.unitsPerEm,fontBBox:[0,w.yMin,w.ascender,w.advanceWidthMax]}),Q=t.metas&&Object.keys(t.metas).length>0?To.make(t.metas):void 0,k=[A,T,U,E,ne,F,oe,fe,P];te&&k.push(te),t.tables.gsub&&k.push(Lo.make(t.tables.gsub)),Q&&k.push(Q);for(var B=Io(k),j=B.encode(),ae=is(j),ie=B.fields,le=!1,pe=0;pe<ie.length;pe+=1)if(ie[pe].name==="head table"){ie[pe].value.checkSumAdjustment=2981146554-ae,le=!0;break}if(!le)throw new Error("Could not find head table with checkSum to adjust.");return B}var Su={make:Io,fontToTable:bu,computeCheckSum:is};function Nr(t,e){for(var n=0,r=t.length-1;n<=r;){var s=n+r>>>1,i=t[s].tag;if(i===e)return s;i<e?n=s+1:r=s-1}return-n-1}function Li(t,e){for(var n=0,r=t.length-1;n<=r;){var s=n+r>>>1,i=t[s];if(i===e)return s;i<e?n=s+1:r=s-1}return-n-1}function Ti(t,e){for(var n,r=0,s=t.length-1;r<=s;){var i=r+s>>>1;n=t[i];var o=n.start;if(o===e)return n;o<e?r=i+1:s=i-1}if(r>0)return n=t[r-1],e>n.end?0:n}function pn(t,e){this.font=t,this.tableName=e}pn.prototype={searchTag:Nr,binSearch:Li,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,n=0;n<t.scripts.length;n++){var r=t.scripts[n].tag;if(r==="DFLT")return r;r==="latn"&&(e=!0)}if(e)return"latn"}},getScriptTable:function(t,e){var n=this.getTable(e);if(n){t=t||"DFLT";var r=n.scripts,s=Nr(n.scripts,t);if(s>=0)return r[s].script;if(e){var i={tag:t,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return r.splice(-1-s,0,i),i.script}}},getLangSysTable:function(t,e,n){var r=this.getScriptTable(t,n);if(r){if(!e||e==="dflt"||e==="DFLT")return r.defaultLangSys;var s=Nr(r.langSysRecords,e);if(s>=0)return r.langSysRecords[s].langSys;if(n){var i={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return r.langSysRecords.splice(-1-s,0,i),i.langSys}}},getFeatureTable:function(t,e,n,r){var s=this.getLangSysTable(t,e,r);if(s){for(var i,o=s.featureIndexes,a=this.font.tables[this.tableName].features,l=0;l<o.length;l++)if(i=a[o[l]],i.tag===n)return i.feature;if(r){var u=a.length;return N.assert(u===0||n>=a[u-1].tag,"Features must be added in alphabetical order."),i={tag:n,feature:{params:0,lookupListIndexes:[]}},a.push(i),o.push(u),i.feature}}},getLookupTables:function(t,e,n,r,s){var i=this.getFeatureTable(t,e,n,s),o=[];if(i){for(var a,l=i.lookupListIndexes,u=this.font.tables[this.tableName].lookups,c=0;c<l.length;c++)a=u[l[c]],a.lookupType===r&&o.push(a);if(o.length===0&&s){a={lookupType:r,lookupFlag:0,subtables:[],markFilteringSet:void 0};var f=u.length;return u.push(a),l.push(f),[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 n=Ti(t.ranges,e);return n?n.classId:0}},getCoverageIndex:function(t,e){switch(t.format){case 1:var n=Li(t.glyphs,e);return n>=0?n:-1;case 2:var r=Ti(t.ranges,e);return r?r.index+e-r.start:-1}},expandCoverage:function(t){if(t.format===1)return t.glyphs;for(var e=[],n=t.ranges,r=0;r<n.length;r++)for(var s=n[r],i=s.start,o=s.end,a=i;a<=o;a++)e.push(a);return e}};function dn(t){pn.call(this,t,"gpos")}dn.prototype=pn.prototype;dn.prototype.init=function(){var t=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(t)};dn.prototype.getKerningValue=function(t,e,n){for(var r=0;r<t.length;r++)for(var s=t[r].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 l=o.pairSets[a],u=0;u<l.length;u++){var c=l[u];if(c.secondGlyph===n)return c.value1&&c.value1.xAdvance||0}break;case 2:var f=this.getGlyphClass(o.classDef1,e),h=this.getGlyphClass(o.classDef2,n),p=o.classRecords[f][h];return p.value1&&p.value1.xAdvance||0}}return 0};dn.prototype.getKerningTables=function(t,e){if(this.font.tables.gpos)return this.getLookupTables(t,e,"kern",2)};function De(t){pn.call(this,t,"gsub")}function wu(t,e){var n=t.length;if(n!==e.length)return!1;for(var r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function os(t,e,n){for(var r=t.subtables,s=0;s<r.length;s++){var i=r[s];if(i.substFormat===e)return i}if(n)return r.push(n),n}De.prototype=pn.prototype;De.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}};De.prototype.getSingle=function(t,e,n){for(var r=[],s=this.getLookupTables(e,n,t,1),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++){var l=o[a],u=this.expandCoverage(l.coverage),c=void 0;if(l.substFormat===1){var f=l.deltaGlyphId;for(c=0;c<u.length;c++){var h=u[c];r.push({sub:h,by:h+f})}}else{var p=l.substitute;for(c=0;c<u.length;c++)r.push({sub:u[c],by:p[c]})}}return r};De.prototype.getMultiple=function(t,e,n){for(var r=[],s=this.getLookupTables(e,n,t,2),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++){var l=o[a],u=this.expandCoverage(l.coverage),c=void 0;for(c=0;c<u.length;c++){var f=u[c],h=l.sequences[c];r.push({sub:f,by:h})}}return r};De.prototype.getAlternates=function(t,e,n){for(var r=[],s=this.getLookupTables(e,n,t,3),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++)for(var l=o[a],u=this.expandCoverage(l.coverage),c=l.alternateSets,f=0;f<u.length;f++)r.push({sub:u[f],by:c[f]});return r};De.prototype.getLigatures=function(t,e,n){for(var r=[],s=this.getLookupTables(e,n,t,4),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++)for(var l=o[a],u=this.expandCoverage(l.coverage),c=l.ligatureSets,f=0;f<u.length;f++)for(var h=u[f],p=c[f],d=0;d<p.length;d++){var g=p[d];r.push({sub:[h].concat(g.components),by:g.ligGlyph})}return r};De.prototype.addSingle=function(t,e,n,r){var s=this.getLookupTables(n,r,t,1,!0)[0],i=os(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};De.prototype.addMultiple=function(t,e,n,r){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(n,r,t,2,!0)[0],i=os(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};De.prototype.addAlternate=function(t,e,n,r){var s=this.getLookupTables(n,r,t,3,!0)[0],i=os(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};De.prototype.addLigature=function(t,e,n,r){var s=this.getLookupTables(n,r,t,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),l={ligGlyph:e.by,components:a},u=this.binSearch(i.coverage.glyphs,o);if(u>=0){for(var c=i.ligatureSets[u],f=0;f<c.length;f++)if(wu(c[f].components,a))return;c.push(l)}else u=-1-u,i.coverage.glyphs.splice(u,0,o),i.ligatureSets.splice(u,0,[l])};De.prototype.getFeature=function(t,e,n){if(/ss\d\d/.test(t))return this.getSingle(t,e,n);switch(t){case"aalt":case"salt":return this.getSingle(t,e,n).concat(this.getAlternates(t,e,n));case"dlig":case"liga":case"rlig":return this.getLigatures(t,e,n);case"ccmp":return this.getMultiple(t,e,n).concat(this.getLigatures(t,e,n));case"stch":return this.getMultiple(t,e,n)}};De.prototype.add=function(t,e,n,r){if(/ss\d\d/.test(t))return this.addSingle(t,e,n,r);switch(t){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(t,e,n,r):this.addAlternate(t,e,n,r);case"dlig":case"liga":case"rlig":return this.addLigature(t,e,n,r);case"ccmp":return e.by instanceof Array?this.addMultiple(t,e,n,r):this.addLigature(t,e,n,r)}};function ku(){return typeof window<"u"}function Eu(t){for(var e=new Buffer(t.byteLength),n=new Uint8Array(t),r=0;r<e.length;++r)e[r]=n[r];return e}function an(t,e){if(!t)throw e}function Ii(t,e,n,r,s){var i;return(e&r)>0?(i=t.parseByte(),(e&s)===0&&(i=-i),i=n+i):(e&s)>0?i=n:i=n+t.parseShort(),i}function Co(t,e,n){var r=new O.Parser(e,n);t.numberOfContours=r.parseShort(),t._xMin=r.parseShort(),t._yMin=r.parseShort(),t._xMax=r.parseShort(),t._yMax=r.parseShort();var s,i;if(t.numberOfContours>0){for(var o=t.endPointIndices=[],a=0;a<t.numberOfContours;a+=1)o.push(r.parseUShort());t.instructionLength=r.parseUShort(),t.instructions=[];for(var l=0;l<t.instructionLength;l+=1)t.instructions.push(r.parseByte());var u=o[o.length-1]+1;s=[];for(var c=0;c<u;c+=1)if(i=r.parseByte(),s.push(i),(i&8)>0)for(var f=r.parseByte(),h=0;h<f;h+=1)s.push(i),c+=1;if(N.argument(s.length===u,"Bad flags."),o.length>0){var p=[],d;if(u>0){for(var g=0;g<u;g+=1)i=s[g],d={},d.onCurve=!!(i&1),d.lastPointOfContour=o.indexOf(g)>=0,p.push(d);for(var y=0,x=0;x<u;x+=1)i=s[x],d=p[x],d.x=Ii(r,i,y,2,16),y=d.x;for(var L=0,w=0;w<u;w+=1)i=s[w],d=p[w],d.y=Ii(r,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=r.parseUShort();var T={glyphIndex:r.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(T.dx=r.parseShort(),T.dy=r.parseShort()):T.matchedPoints=[r.parseUShort(),r.parseUShort()]:(s&2)>0?(T.dx=r.parseChar(),T.dy=r.parseChar()):T.matchedPoints=[r.parseByte(),r.parseByte()],(s&8)>0?T.xScale=T.yScale=r.parseF2Dot14():(s&64)>0?(T.xScale=r.parseF2Dot14(),T.yScale=r.parseF2Dot14()):(s&128)>0&&(T.xScale=r.parseF2Dot14(),T.scale01=r.parseF2Dot14(),T.scale10=r.parseF2Dot14(),T.yScale=r.parseF2Dot14()),t.components.push(T),A=!!(s&32)}if(s&256){t.instructionLength=r.parseUShort(),t.instructions=[];for(var U=0;U<t.instructionLength;U+=1)t.instructions.push(r.parseByte())}}}function Br(t,e){for(var n=[],r=0;r<t.length;r+=1){var s=t[r],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};n.push(i)}return n}function Pu(t){for(var e=[],n=[],r=0;r<t.length;r+=1){var s=t[r];n.push(s),s.lastPointOfContour&&(e.push(n),n=[])}return N.argument(n.length===0,"There are still points left in the current contour."),e}function Mo(t){var e=new ye;if(!t)return e;for(var n=Pu(t),r=0;r<n.length;++r){var s=n[r],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 l={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5};e.moveTo(l.x,l.y)}for(var u=0;u<s.length;++u)if(i=o,o=a,a=s[(u+1)%s.length],o.onCurve)e.lineTo(o.x,o.y);else{var c=i,f=a;i.onCurve||(c={x:(o.x+i.x)*.5,y:(o.y+i.y)*.5}),a.onCurve||(f={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5}),e.quadraticCurveTo(o.x,o.y,f.x,f.y)}e.closePath()}return e}function Ao(t,e){if(e.isComposite)for(var n=0;n<e.components.length;n+=1){var r=e.components[n],s=t.get(r.glyphIndex);if(s.getPath(),s.points){var i=void 0;if(r.matchedPoints===void 0)i=Br(s.points,r);else{if(r.matchedPoints[0]>e.points.length-1||r.matchedPoints[1]>s.points.length-1)throw Error("Matched points out of range in "+e.name);var o=e.points[r.matchedPoints[0]],a=s.points[r.matchedPoints[1]],l={xScale:r.xScale,scale01:r.scale01,scale10:r.scale10,yScale:r.yScale,dx:0,dy:0};a=Br([a],l)[0],l.dx=o.x-a.x,l.dy=o.y-a.y,i=Br(s.points,l)}e.points=e.points.concat(i)}}return Mo(e.points)}function Lu(t,e,n,r){for(var s=new et.GlyphSet(r),i=0;i<n.length-1;i+=1){var o=n[i],a=n[i+1];o!==a?s.push(i,et.ttfGlyphLoader(r,i,Co,t,e+o,Ao)):s.push(i,et.glyphLoader(r,i))}return s}function Tu(t,e,n,r){var s=new et.GlyphSet(r);return r._push=function(i){var o=n[i],a=n[i+1];o!==a?s.push(i,et.ttfGlyphLoader(r,i,Co,t,e+o,Ao)):s.push(i,et.glyphLoader(r,i))},s}function Iu(t,e,n,r,s){return s.lowMemory?Tu(t,e,n,r):Lu(t,e,n,r)}var Oo={getPath:Mo,parse:Iu},Fo,Pt,Do,Jr;function Ro(t){this.font=t,this.getCommands=function(e){return Oo.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Cu(t){return t}function Uo(t){return Math.sign(t)*Math.round(Math.abs(t))}function Mu(t){return Math.sign(t)*Math.round(Math.abs(t*2))/2}function Au(t){return Math.sign(t)*(Math.round(Math.abs(t)+.5)-.5)}function Ou(t){return Math.sign(t)*Math.ceil(Math.abs(t))}function Fu(t){return Math.sign(t)*Math.floor(Math.abs(t))}var No=function(t){var e=this.srPeriod,n=this.srPhase,r=this.srThreshold,s=1;return t<0&&(t=-t,s=-1),t+=r-n,t=Math.trunc(t/e)*e,t+=n,t<0?n*s:t*s},Qe={x:1,y:0,axis:"x",distance:function(t,e,n,r){return(n?t.xo:t.x)-(r?e.xo:e.x)},interpolate:function(t,e,n,r){var s,i,o,a,l,u,c;if(!r||r===this){if(s=t.xo-e.xo,i=t.xo-n.xo,l=e.x-e.xo,u=n.x-n.xo,o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){t.x=t.xo+(l+u)/2;return}t.x=t.xo+(l*a+u*o)/c;return}if(s=r.distance(t,e,!0,!0),i=r.distance(t,n,!0,!0),l=r.distance(e,e,!1,!0),u=r.distance(n,n,!1,!0),o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){Qe.setRelative(t,t,(l+u)/2,r,!0);return}Qe.setRelative(t,t,(l*a+u*o)/c,r,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(t,e,n,r,s){if(!r||r===this){t.x=(s?e.xo:e.x)+n;return}var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+n*r.x,l=o+n*r.y;t.x=a+(t.y-l)/r.normalSlope},slope:0,touch:function(t){t.xTouched=!0},touched:function(t){return t.xTouched},untouch:function(t){t.xTouched=!1}},rt={x:0,y:1,axis:"y",distance:function(t,e,n,r){return(n?t.yo:t.y)-(r?e.yo:e.y)},interpolate:function(t,e,n,r){var s,i,o,a,l,u,c;if(!r||r===this){if(s=t.yo-e.yo,i=t.yo-n.yo,l=e.y-e.yo,u=n.y-n.yo,o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){t.y=t.yo+(l+u)/2;return}t.y=t.yo+(l*a+u*o)/c;return}if(s=r.distance(t,e,!0,!0),i=r.distance(t,n,!0,!0),l=r.distance(e,e,!1,!0),u=r.distance(n,n,!1,!0),o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){rt.setRelative(t,t,(l+u)/2,r,!0);return}rt.setRelative(t,t,(l*a+u*o)/c,r,!0)},normalSlope:0,setRelative:function(t,e,n,r,s){if(!r||r===this){t.y=(s?e.yo:e.y)+n;return}var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+n*r.x,l=o+n*r.y;t.y=l+r.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(Qe);Object.freeze(rt);function gn(t,e){this.x=t,this.y=e,this.axis=void 0,this.slope=e/t,this.normalSlope=-t/e,Object.freeze(this)}gn.prototype.distance=function(t,e,n,r){return this.x*Qe.distance(t,e,n,r)+this.y*rt.distance(t,e,n,r)};gn.prototype.interpolate=function(t,e,n,r){var s,i,o,a,l,u,c;if(o=r.distance(t,e,!0,!0),a=r.distance(t,n,!0,!0),s=r.distance(e,e,!1,!0),i=r.distance(n,n,!1,!0),l=Math.abs(o),u=Math.abs(a),c=l+u,c===0){this.setRelative(t,t,(s+i)/2,r,!0);return}this.setRelative(t,t,(s*u+i*l)/c,r,!0)};gn.prototype.setRelative=function(t,e,n,r,s){r=r||this;var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+n*r.x,l=o+n*r.y,u=r.normalSlope,c=this.slope,f=t.x,h=t.y;t.x=(c*f-u*a+l-h)/(c-u),t.y=c*(t.x-f)+h};gn.prototype.touch=function(t){t.xTouched=!0,t.yTouched=!0};function mn(t,e){var n=Math.sqrt(t*t+e*e);return t/=n,e/=n,t===1&&e===0?Qe:t===0&&e===1?rt:new gn(t,e)}function st(t,e,n,r){this.x=this.xo=Math.round(t*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=n,this.onCurve=r,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}st.prototype.nextTouched=function(t){for(var e=this.nextPointOnContour;!t.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};st.prototype.prevTouched=function(t){for(var e=this.prevPointOnContour;!t.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var fn=Object.freeze(new st(0,0)),Du={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function ft(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=Qe,this.round=Uo}}Ro.prototype.exec=function(t,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(!(this._errorState>2)){var n=this.font,r=this._prepState;if(!r||r.ppem!==e){var s=this._fpgmState;if(!s){ft.prototype=Du,s=this._fpgmState=new ft("fpgm",n.tables.fpgm),s.funcs=[],s.font=n,exports.DEBUG&&(console.log("---EXEC FPGM---"),s.step=-1);try{Pt(s)}catch(u){console.log("Hinting error in FPGM:"+u),this._errorState=3;return}}ft.prototype=s,r=this._prepState=new ft("prep",n.tables.prep),r.ppem=e;var i=n.tables.cvt;if(i)for(var o=r.cvt=new Array(i.length),a=e/n.unitsPerEm,l=0;l<i.length;l++)o[l]=i[l]*a;else r.cvt=[];exports.DEBUG&&(console.log("---EXEC PREP---"),r.step=-1);try{Pt(r)}catch(u){this._errorState<2&&console.log("Hinting error in PREP:"+u),this._errorState=2}}if(!(this._errorState>1))try{return Do(t,r)}catch(u){this._errorState<1&&(console.log("Hinting error:"+u),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}}};Do=function(t,e){var n=e.ppem/e.font.unitsPerEm,r=n,s=t.components,i,o,a;if(ft.prototype=e,!s)a=new ft("glyf",t.instructions),exports.DEBUG&&(console.log("---EXEC GLYPH---"),a.step=-1),Jr(t,a,n,r),o=a.gZone;else{var l=e.font;o=[],i=[];for(var u=0;u<s.length;u++){var c=s[u],f=l.glyphs.get(c.glyphIndex);a=new ft("glyf",f.instructions),exports.DEBUG&&(console.log("---EXEC COMP "+u+"---"),a.step=-1),Jr(f,a,n,r);for(var h=Math.round(c.dx*n),p=Math.round(c.dy*r),d=a.gZone,g=a.contours,y=0;y<d.length;y++){var x=d[y];x.xTouched=x.yTouched=!1,x.xo=x.x=x.x+h,x.yo=x.y=x.y+p}var L=o.length;o.push.apply(o,d);for(var w=0;w<g.length;w++)i.push(g[w]+L)}t.instructions&&!a.inhibitGridFit&&(a=new ft("glyf",t.instructions),a.gZone=a.z0=a.z1=a.z2=o,a.contours=i,o.push(new st(0,0),new st(Math.round(t.advanceWidth*n),0)),exports.DEBUG&&(console.log("---EXEC COMPOSITE---"),a.step=-1),Pt(a),o.length-=2)}return o};Jr=function(t,e,n,r){for(var s=t.points||[],i=s.length,o=e.gZone=e.z0=e.z1=e.z2=[],a=e.contours=[],l,u=0;u<i;u++)l=s[u],o[u]=new st(l.x*n,l.y*r,l.lastPointOfContour,l.onCurve);for(var c,f,h=0;h<i;h++)l=o[h],c||(c=l,a.push(h)),l.lastPointOfContour?(l.nextPointOnContour=c,c.prevPointOnContour=l,c=void 0):(f=o[h+1],l.nextPointOnContour=f,f.prevPointOnContour=l);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 st(0,0),new st(Math.round(t.advanceWidth*n),0)),Pt(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)}}};Pt=function(t){var e=t.prog;if(e){var n=e.length,r;for(t.ip=0;t.ip<n;t.ip++){if(exports.DEBUG&&t.step++,r=Fo[e[t.ip]],!r)throw new Error("unknown instruction: 0x"+Number(e[t.ip]).toString(16));r(t)}}};function nr(t){for(var e=t.tZone=new Array(t.gZone.length),n=0;n<e.length;n++)e[n]=new st(0,0)}function Bo(t,e){var n=t.prog,r=t.ip,s=1,i;do if(i=n[++r],i===88)s++;else if(i===89)s--;else if(i===64)r+=n[r+1]+1;else if(i===65)r+=2*n[r+1]+1;else if(i>=176&&i<=183)r+=i-176+1;else if(i>=184&&i<=191)r+=(i-184+1)*2;else if(e&&s===1&&i===27)break;while(s>0);t.ip=r}function Ci(t,e){exports.DEBUG&&console.log(e.step,"SVTCA["+t.axis+"]"),e.fv=e.pv=e.dpv=t}function Mi(t,e){exports.DEBUG&&console.log(e.step,"SPVTCA["+t.axis+"]"),e.pv=e.dpv=t}function Ai(t,e){exports.DEBUG&&console.log(e.step,"SFVTCA["+t.axis+"]"),e.fv=t}function Oi(t,e){var n=e.stack,r=n.pop(),s=n.pop(),i=e.z2[r],o=e.z1[s];exports.DEBUG&&console.log("SPVTL["+t+"]",r,s);var a,l;t?(a=i.y-o.y,l=o.x-i.x):(a=o.x-i.x,l=o.y-i.y),e.pv=e.dpv=mn(a,l)}function Fi(t,e){var n=e.stack,r=n.pop(),s=n.pop(),i=e.z2[r],o=e.z1[s];exports.DEBUG&&console.log("SFVTL["+t+"]",r,s);var a,l;t?(a=i.y-o.y,l=o.x-i.x):(a=o.x-i.x,l=o.y-i.y),e.fv=mn(a,l)}function Ru(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"SPVFS[]",n,r),t.pv=t.dpv=mn(r,n)}function Uu(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"SPVFS[]",n,r),t.fv=mn(r,n)}function Nu(t){var e=t.stack,n=t.pv;exports.DEBUG&&console.log(t.step,"GPV[]"),e.push(n.x*16384),e.push(n.y*16384)}function Bu(t){var e=t.stack,n=t.fv;exports.DEBUG&&console.log(t.step,"GFV[]"),e.push(n.x*16384),e.push(n.y*16384)}function Gu(t){t.fv=t.pv,exports.DEBUG&&console.log(t.step,"SFVTPV[]")}function zu(t){var e=t.stack,n=e.pop(),r=e.pop(),s=e.pop(),i=e.pop(),o=e.pop(),a=t.z0,l=t.z1,u=a[n],c=a[r],f=l[s],h=l[i],p=t.z2[o];exports.DEBUG&&console.log("ISECT[], ",n,r,s,i,o);var d=u.x,g=u.y,y=c.x,x=c.y,L=f.x,w=f.y,A=h.x,T=h.y,U=(d-y)*(w-T)-(g-x)*(L-A),E=d*x-g*y,P=L*T-w*A;p.x=(E*(L-A)-P*(d-y))/U,p.y=(E*(w-T)-P*(g-x))/U}function Hu(t){t.rp0=t.stack.pop(),exports.DEBUG&&console.log(t.step,"SRP0[]",t.rp0)}function Vu(t){t.rp1=t.stack.pop(),exports.DEBUG&&console.log(t.step,"SRP1[]",t.rp1)}function $u(t){t.rp2=t.stack.pop(),exports.DEBUG&&console.log(t.step,"SRP2[]",t.rp2)}function Xu(t){var e=t.stack.pop();switch(exports.DEBUG&&console.log(t.step,"SZP0[]",e),t.zp0=e,e){case 0:t.tZone||nr(t),t.z0=t.tZone;break;case 1:t.z0=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function qu(t){var e=t.stack.pop();switch(exports.DEBUG&&console.log(t.step,"SZP1[]",e),t.zp1=e,e){case 0:t.tZone||nr(t),t.z1=t.tZone;break;case 1:t.z1=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Wu(t){var e=t.stack.pop();switch(exports.DEBUG&&console.log(t.step,"SZP2[]",e),t.zp2=e,e){case 0:t.tZone||nr(t),t.z2=t.tZone;break;case 1:t.z2=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function _u(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||nr(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 Zu(t){t.loop=t.stack.pop(),exports.DEBUG&&console.log(t.step,"SLOOP[]",t.loop)}function ju(t){exports.DEBUG&&console.log(t.step,"RTG[]"),t.round=Uo}function Yu(t){exports.DEBUG&&console.log(t.step,"RTHG[]"),t.round=Au}function Ku(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SMD[]",e),t.minDis=e/64}function Ju(t){exports.DEBUG&&console.log(t.step,"ELSE[]"),Bo(t,!1)}function Qu(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"JMPR[]",e),t.ip+=e-1}function ec(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SCVTCI[]",e),t.cvCutIn=e/64}function tc(t){var e=t.stack;exports.DEBUG&&console.log(t.step,"DUP[]"),e.push(e[e.length-1])}function Gr(t){exports.DEBUG&&console.log(t.step,"POP[]"),t.stack.pop()}function nc(t){exports.DEBUG&&console.log(t.step,"CLEAR[]"),t.stack.length=0}function rc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"SWAP[]"),e.push(n),e.push(r)}function sc(t){var e=t.stack;exports.DEBUG&&console.log(t.step,"DEPTH[]"),e.push(e.length)}function ic(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"LOOPCALL[]",n,r);var s=t.ip,i=t.prog;t.prog=t.funcs[n];for(var o=0;o<r;o++)Pt(t),exports.DEBUG&&console.log(++t.step,o+1<r?"next loopcall":"done loopcall",o);t.ip=s,t.prog=i}function oc(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"CALL[]",e);var n=t.ip,r=t.prog;t.prog=t.funcs[e],Pt(t),t.ip=n,t.prog=r,exports.DEBUG&&console.log(++t.step,"returning from",e)}function ac(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"CINDEX[]",n),e.push(e[e.length-n])}function lc(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"MINDEX[]",n),e.push(e.splice(e.length-n,1)[0])}function uc(t){if(t.env!=="fpgm")throw new Error("FDEF not allowed here");var e=t.stack,n=t.prog,r=t.ip,s=e.pop(),i=r;for(exports.DEBUG&&console.log(t.step,"FDEF[]",s);n[++r]!==45;);t.ip=r,t.funcs[s]=n.slice(i+1,r)}function Di(t,e){var n=e.stack.pop(),r=e.z0[n],s=e.fv,i=e.pv;exports.DEBUG&&console.log(e.step,"MDAP["+t+"]",n);var o=i.distance(r,fn);t&&(o=e.round(o)),s.setRelative(r,fn,o,i),s.touch(r),e.rp0=e.rp1=n}function Ri(t,e){var n=e.z2,r=n.length-2,s,i,o;exports.DEBUG&&console.log(e.step,"IUP["+t.axis+"]");for(var a=0;a<r;a++)s=n[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 Ui(t,e){for(var n=e.stack,r=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[r],i=e.fv,o=e.pv,a=e.loop,l=e.z2;a--;){var u=n.pop(),c=l[u],f=o.distance(s,s,!1,!0);i.setRelative(c,c,f,o),i.touch(c),exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-a)+": ":"")+"SHP["+(t?"rp1":"rp2")+"]",u)}e.loop=1}function Ni(t,e){var n=e.stack,r=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[r],i=e.fv,o=e.pv,a=n.pop(),l=e.z2[e.contours[a]],u=l;exports.DEBUG&&console.log(e.step,"SHC["+t+"]",a);var c=o.distance(s,s,!1,!0);do u!==s&&i.setRelative(u,u,c,o),u=u.nextPointOnContour;while(u!==l)}function Bi(t,e){var n=e.stack,r=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[r],i=e.fv,o=e.pv,a=n.pop();exports.DEBUG&&console.log(e.step,"SHZ["+t+"]",a);var l;switch(a){case 0:l=e.tZone;break;case 1:l=e.gZone;break;default:throw new Error("Invalid zone")}for(var u,c=o.distance(s,s,!1,!0),f=l.length-2,h=0;h<f;h++)u=l[h],i.setRelative(u,u,c,o)}function cc(t){for(var e=t.stack,n=t.loop,r=t.fv,s=e.pop()/64,i=t.z2;n--;){var o=e.pop(),a=i[o];exports.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-n)+": ":"")+"SHPIX[]",o,s),r.setRelative(a,a,s),r.touch(a)}t.loop=1}function hc(t){for(var e=t.stack,n=t.rp1,r=t.rp2,s=t.loop,i=t.z0[n],o=t.z1[r],a=t.fv,l=t.dpv,u=t.z2;s--;){var c=e.pop(),f=u[c];exports.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-s)+": ":"")+"IP[]",c,n,"<->",r),a.interpolate(f,i,o,l),a.touch(f)}t.loop=1}function Gi(t,e){var n=e.stack,r=n.pop()/64,s=n.pop(),i=e.z1[s],o=e.z0[e.rp0],a=e.fv,l=e.pv;a.setRelative(i,o,r,l),a.touch(i),exports.DEBUG&&console.log(e.step,"MSIRP["+t+"]",r,s),e.rp1=e.rp0,e.rp2=s,t&&(e.rp0=s)}function fc(t){for(var e=t.stack,n=t.rp0,r=t.z0[n],s=t.loop,i=t.fv,o=t.pv,a=t.z1;s--;){var l=e.pop(),u=a[l];exports.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-s)+": ":"")+"ALIGNRP[]",l),i.setRelative(u,r,0,o),i.touch(u)}t.loop=1}function pc(t){exports.DEBUG&&console.log(t.step,"RTDG[]"),t.round=Mu}function zi(t,e){var n=e.stack,r=n.pop(),s=n.pop(),i=e.z0[s],o=e.fv,a=e.pv,l=e.cvt[r];exports.DEBUG&&console.log(e.step,"MIAP["+t+"]",r,"(",l,")",s);var u=a.distance(i,fn);t&&(Math.abs(u-l)<e.cvCutIn&&(u=l),u=e.round(u)),o.setRelative(i,fn,u,a),e.zp0===0&&(i.xo=i.x,i.yo=i.y),o.touch(i),e.rp0=e.rp1=s}function dc(t){var e=t.prog,n=t.ip,r=t.stack,s=e[++n];exports.DEBUG&&console.log(t.step,"NPUSHB[]",s);for(var i=0;i<s;i++)r.push(e[++n]);t.ip=n}function gc(t){var e=t.ip,n=t.prog,r=t.stack,s=n[++e];exports.DEBUG&&console.log(t.step,"NPUSHW[]",s);for(var i=0;i<s;i++){var o=n[++e]<<8|n[++e];o&32768&&(o=-((o^65535)+1)),r.push(o)}t.ip=e}function mc(t){var e=t.stack,n=t.store;n||(n=t.store=[]);var r=e.pop(),s=e.pop();exports.DEBUG&&console.log(t.step,"WS",r,s),n[s]=r}function vc(t){var e=t.stack,n=t.store,r=e.pop();exports.DEBUG&&console.log(t.step,"RS",r);var s=n&&n[r]||0;e.push(s)}function xc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"WCVTP",n,r),t.cvt[r]=n/64}function yc(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"RCVT",n),e.push(t.cvt[n]*64)}function Hi(t,e){var n=e.stack,r=n.pop(),s=e.z2[r];exports.DEBUG&&console.log(e.step,"GC["+t+"]",r),n.push(e.dpv.distance(s,fn,t,!1)*64)}function Vi(t,e){var n=e.stack,r=n.pop(),s=n.pop(),i=e.z1[r],o=e.z0[s],a=e.dpv.distance(o,i,t,t);exports.DEBUG&&console.log(e.step,"MD["+t+"]",r,s,"->",a),e.stack.push(Math.round(a*64))}function bc(t){exports.DEBUG&&console.log(t.step,"MPPEM[]"),t.stack.push(t.ppem)}function Sc(t){exports.DEBUG&&console.log(t.step,"FLIPON[]"),t.autoFlip=!0}function wc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"LT[]",n,r),e.push(r<n?1:0)}function kc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"LTEQ[]",n,r),e.push(r<=n?1:0)}function Ec(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"GT[]",n,r),e.push(r>n?1:0)}function Pc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"GTEQ[]",n,r),e.push(r>=n?1:0)}function Lc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"EQ[]",n,r),e.push(n===r?1:0)}function Tc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"NEQ[]",n,r),e.push(n!==r?1:0)}function Ic(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"ODD[]",n),e.push(Math.trunc(n)%2?1:0)}function Cc(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"EVEN[]",n),e.push(Math.trunc(n)%2?0:1)}function Mc(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"IF[]",e),e||(Bo(t,!0),exports.DEBUG&&console.log(t.step,"EIF[]"))}function Ac(t){exports.DEBUG&&console.log(t.step,"EIF[]")}function Oc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"AND[]",n,r),e.push(n&&r?1:0)}function Fc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"OR[]",n,r),e.push(n||r?1:0)}function Dc(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"NOT[]",n),e.push(n?0:1)}function zr(t,e){var n=e.stack,r=n.pop(),s=e.fv,i=e.pv,o=e.ppem,a=e.deltaBase+(t-1)*16,l=e.deltaShift,u=e.z0;exports.DEBUG&&console.log(e.step,"DELTAP["+t+"]",r,n);for(var c=0;c<r;c++){var f=n.pop(),h=n.pop(),p=a+((h&240)>>4);if(p===o){var d=(h&15)-8;d>=0&&d++,exports.DEBUG&&console.log(e.step,"DELTAPFIX",f,"by",d*l);var g=u[f];s.setRelative(g,g,d*l,i)}}}function Rc(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"SDB[]",n),t.deltaBase=n}function Uc(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"SDS[]",n),t.deltaShift=Math.pow(.5,n)}function Nc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"ADD[]",n,r),e.push(r+n)}function Bc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"SUB[]",n,r),e.push(r-n)}function Gc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"DIV[]",n,r),e.push(r*64/n)}function zc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"MUL[]",n,r),e.push(r*n/64)}function Hc(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"ABS[]",n),e.push(Math.abs(n))}function Vc(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"NEG[]",n),e.push(-n)}function $c(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"FLOOR[]",n),e.push(Math.floor(n/64)*64)}function Xc(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"CEILING[]",n),e.push(Math.ceil(n/64)*64)}function _n(t,e){var n=e.stack,r=n.pop();exports.DEBUG&&console.log(e.step,"ROUND[]"),n.push(e.round(r/64)*64)}function qc(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"WCVTF[]",n,r),t.cvt[r]=n*t.ppem/t.font.unitsPerEm}function Hr(t,e){var n=e.stack,r=n.pop(),s=e.ppem,i=e.deltaBase+(t-1)*16,o=e.deltaShift;exports.DEBUG&&console.log(e.step,"DELTAC["+t+"]",r,n);for(var a=0;a<r;a++){var l=n.pop(),u=n.pop(),c=i+((u&240)>>4);if(c===s){var f=(u&15)-8;f>=0&&f++;var h=f*o;exports.DEBUG&&console.log(e.step,"DELTACFIX",l,"by",h),e.cvt[l]+=h}}}function Wc(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SROUND[]",e),t.round=No;var n;switch(e&192){case 0:n=.5;break;case 64:n=1;break;case 128:n=2;break;default:throw new Error("invalid SROUND value")}switch(t.srPeriod=n,e&48){case 0:t.srPhase=0;break;case 16:t.srPhase=.25*n;break;case 32:t.srPhase=.5*n;break;case 48:t.srPhase=.75*n;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?t.srThreshold=0:t.srThreshold=(e/8-.5)*n}function _c(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"S45ROUND[]",e),t.round=No;var n;switch(e&192){case 0:n=Math.sqrt(2)/2;break;case 64:n=Math.sqrt(2);break;case 128:n=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(t.srPeriod=n,e&48){case 0:t.srPhase=0;break;case 16:t.srPhase=.25*n;break;case 32:t.srPhase=.5*n;break;case 48:t.srPhase=.75*n;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?t.srThreshold=0:t.srThreshold=(e/8-.5)*n}function Zc(t){exports.DEBUG&&console.log(t.step,"ROFF[]"),t.round=Cu}function jc(t){exports.DEBUG&&console.log(t.step,"RUTG[]"),t.round=Ou}function Yc(t){exports.DEBUG&&console.log(t.step,"RDTG[]"),t.round=Fu}function Kc(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SCANCTRL[]",e)}function $i(t,e){var n=e.stack,r=n.pop(),s=n.pop(),i=e.z2[r],o=e.z1[s];exports.DEBUG&&console.log(e.step,"SDPVTL["+t+"]",r,s);var a,l;t?(a=i.y-o.y,l=o.x-i.x):(a=o.x-i.x,l=o.y-i.y),e.dpv=mn(a,l)}function Jc(t){var e=t.stack,n=e.pop(),r=0;exports.DEBUG&&console.log(t.step,"GETINFO[]",n),n&1&&(r=35),n&32&&(r|=4096),e.push(r)}function Qc(t){var e=t.stack,n=e.pop(),r=e.pop(),s=e.pop();exports.DEBUG&&console.log(t.step,"ROLL[]"),e.push(r),e.push(n),e.push(s)}function eh(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"MAX[]",n,r),e.push(Math.max(r,n))}function th(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"MIN[]",n,r),e.push(Math.min(r,n))}function nh(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SCANTYPE[]",e)}function rh(t){var e=t.stack.pop(),n=t.stack.pop();switch(exports.DEBUG&&console.log(t.step,"INSTCTRL[]",e,n),e){case 1:t.inhibitGridFit=!!n;return;case 2:t.ignoreCvt=!!n;return;default:throw new Error("invalid INSTCTRL[] selector")}}function ut(t,e){var n=e.stack,r=e.prog,s=e.ip;exports.DEBUG&&console.log(e.step,"PUSHB["+t+"]");for(var i=0;i<t;i++)n.push(r[++s]);e.ip=s}function ct(t,e){var n=e.ip,r=e.prog,s=e.stack;exports.DEBUG&&console.log(e.ip,"PUSHW["+t+"]");for(var i=0;i<t;i++){var o=r[++n]<<8|r[++n];o&32768&&(o=-((o^65535)+1)),s.push(o)}e.ip=n}function M(t,e,n,r,s,i){var o=i.stack,a=t&&o.pop(),l=o.pop(),u=i.rp0,c=i.z0[u],f=i.z1[l],h=i.minDis,p=i.fv,d=i.dpv,g,y,x,L;y=g=d.distance(f,c,!0,!0),x=y>=0?1:-1,y=Math.abs(y),t&&(L=i.cvt[a],r&&Math.abs(y-L)<i.cvCutIn&&(y=L)),n&&y<h&&(y=h),r&&(y=i.round(y)),p.setRelative(f,c,x*y,d),p.touch(f),exports.DEBUG&&console.log(i.step,(t?"MIRP[":"MDRP[")+(e?"M":"m")+(n?">":"_")+(r?"R":"_")+(s===0?"Gr":s===1?"Bl":s===2?"Wh":"")+"]",t?a+"("+i.cvt[a]+","+L+")":"",l,"(d =",g,"->",x*y,")"),i.rp1=i.rp0,i.rp2=l,e&&(i.rp0=l)}Fo=[Ci.bind(void 0,rt),Ci.bind(void 0,Qe),Mi.bind(void 0,rt),Mi.bind(void 0,Qe),Ai.bind(void 0,rt),Ai.bind(void 0,Qe),Oi.bind(void 0,0),Oi.bind(void 0,1),Fi.bind(void 0,0),Fi.bind(void 0,1),Ru,Uu,Nu,Bu,Gu,zu,Hu,Vu,$u,Xu,qu,Wu,_u,Zu,ju,Yu,Ku,Ju,Qu,ec,void 0,void 0,tc,Gr,nc,rc,sc,ac,lc,void 0,void 0,void 0,ic,oc,uc,void 0,Di.bind(void 0,0),Di.bind(void 0,1),Ri.bind(void 0,rt),Ri.bind(void 0,Qe),Ui.bind(void 0,0),Ui.bind(void 0,1),Ni.bind(void 0,0),Ni.bind(void 0,1),Bi.bind(void 0,0),Bi.bind(void 0,1),cc,hc,Gi.bind(void 0,0),Gi.bind(void 0,1),fc,pc,zi.bind(void 0,0),zi.bind(void 0,1),dc,gc,mc,vc,xc,yc,Hi.bind(void 0,0),Hi.bind(void 0,1),void 0,Vi.bind(void 0,0),Vi.bind(void 0,1),bc,void 0,Sc,void 0,void 0,wc,kc,Ec,Pc,Lc,Tc,Ic,Cc,Mc,Ac,Oc,Fc,Dc,zr.bind(void 0,1),Rc,Uc,Nc,Bc,Gc,zc,Hc,Vc,$c,Xc,_n.bind(void 0,0),_n.bind(void 0,1),_n.bind(void 0,2),_n.bind(void 0,3),void 0,void 0,void 0,void 0,qc,zr.bind(void 0,2),zr.bind(void 0,3),Hr.bind(void 0,1),Hr.bind(void 0,2),Hr.bind(void 0,3),Wc,_c,void 0,void 0,Zc,void 0,jc,Yc,Gr,Gr,void 0,void 0,void 0,void 0,void 0,Kc,$i.bind(void 0,0),$i.bind(void 0,1),Jc,void 0,Qc,eh,th,nh,rh,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ut.bind(void 0,1),ut.bind(void 0,2),ut.bind(void 0,3),ut.bind(void 0,4),ut.bind(void 0,5),ut.bind(void 0,6),ut.bind(void 0,7),ut.bind(void 0,8),ct.bind(void 0,1),ct.bind(void 0,2),ct.bind(void 0,3),ct.bind(void 0,4),ct.bind(void 0,5),ct.bind(void 0,6),ct.bind(void 0,7),ct.bind(void 0,8),M.bind(void 0,0,0,0,0,0),M.bind(void 0,0,0,0,0,1),M.bind(void 0,0,0,0,0,2),M.bind(void 0,0,0,0,0,3),M.bind(void 0,0,0,0,1,0),M.bind(void 0,0,0,0,1,1),M.bind(void 0,0,0,0,1,2),M.bind(void 0,0,0,0,1,3),M.bind(void 0,0,0,1,0,0),M.bind(void 0,0,0,1,0,1),M.bind(void 0,0,0,1,0,2),M.bind(void 0,0,0,1,0,3),M.bind(void 0,0,0,1,1,0),M.bind(void 0,0,0,1,1,1),M.bind(void 0,0,0,1,1,2),M.bind(void 0,0,0,1,1,3),M.bind(void 0,0,1,0,0,0),M.bind(void 0,0,1,0,0,1),M.bind(void 0,0,1,0,0,2),M.bind(void 0,0,1,0,0,3),M.bind(void 0,0,1,0,1,0),M.bind(void 0,0,1,0,1,1),M.bind(void 0,0,1,0,1,2),M.bind(void 0,0,1,0,1,3),M.bind(void 0,0,1,1,0,0),M.bind(void 0,0,1,1,0,1),M.bind(void 0,0,1,1,0,2),M.bind(void 0,0,1,1,0,3),M.bind(void 0,0,1,1,1,0),M.bind(void 0,0,1,1,1,1),M.bind(void 0,0,1,1,1,2),M.bind(void 0,0,1,1,1,3),M.bind(void 0,1,0,0,0,0),M.bind(void 0,1,0,0,0,1),M.bind(void 0,1,0,0,0,2),M.bind(void 0,1,0,0,0,3),M.bind(void 0,1,0,0,1,0),M.bind(void 0,1,0,0,1,1),M.bind(void 0,1,0,0,1,2),M.bind(void 0,1,0,0,1,3),M.bind(void 0,1,0,1,0,0),M.bind(void 0,1,0,1,0,1),M.bind(void 0,1,0,1,0,2),M.bind(void 0,1,0,1,0,3),M.bind(void 0,1,0,1,1,0),M.bind(void 0,1,0,1,1,1),M.bind(void 0,1,0,1,1,2),M.bind(void 0,1,0,1,1,3),M.bind(void 0,1,1,0,0,0),M.bind(void 0,1,1,0,0,1),M.bind(void 0,1,1,0,0,2),M.bind(void 0,1,1,0,0,3),M.bind(void 0,1,1,0,1,0),M.bind(void 0,1,1,0,1,1),M.bind(void 0,1,1,0,1,2),M.bind(void 0,1,1,0,1,3),M.bind(void 0,1,1,1,0,0),M.bind(void 0,1,1,1,0,1),M.bind(void 0,1,1,1,0,2),M.bind(void 0,1,1,1,0,3),M.bind(void 0,1,1,1,1,0),M.bind(void 0,1,1,1,1,1),M.bind(void 0,1,1,1,1,2),M.bind(void 0,1,1,1,1,3)];function zt(t){this.char=t,this.state={},this.activeState=null}function as(t,e,n){this.contextName=n,this.startIndex=t,this.endOffset=e}function sh(t,e,n){this.contextName=t,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=n}function qe(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 rr(t){this.eventId=t,this.subscribers=[]}function ih(t){var e=this,n=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];n.forEach(function(s){Object.defineProperty(e.events,s,{value:new rr(s)})}),t&&n.forEach(function(s){var i=t[s];typeof i=="function"&&e.events[s].subscribe(i)});var r=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];r.forEach(function(s){e.events[s].subscribe(e.updateContextsRanges)})}function ge(t){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],ih.call(this,t)}zt.prototype.setState=function(t,e){return this.state[t]=e,this.activeState={key:t,value:this.state[t]},this.activeState};zt.prototype.getState=function(t){return this.state[t]||null};ge.prototype.inboundIndex=function(t){return t>=0&&t<this.tokens.length};ge.prototype.composeRUD=function(t){var e=this,n=!0,r=t.map(function(i){return e[i[0]].apply(e,i.slice(1).concat(n))}),s=function(i){return typeof i=="object"&&i.hasOwnProperty("FAIL")};if(r.every(s))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:r.filter(s)};this.dispatch("composeRUD",[r.filter(function(i){return!s(i)})])};ge.prototype.replaceRange=function(t,e,n,r){e=e!==null?e:this.tokens.length;var s=n.every(function(o){return o instanceof zt});if(!isNaN(t)&&this.inboundIndex(t)&&s){var i=this.tokens.splice.apply(this.tokens,[t,e].concat(n));return r||this.dispatch("replaceToken",[t,e,n]),[i,n]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};ge.prototype.replaceToken=function(t,e,n){if(!isNaN(t)&&this.inboundIndex(t)&&e instanceof zt){var r=this.tokens.splice(t,1,e);return n||this.dispatch("replaceToken",[t,e]),[r[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};ge.prototype.removeRange=function(t,e,n){e=isNaN(e)?this.tokens.length:e;var r=this.tokens.splice(t,e);return n||this.dispatch("removeRange",[r,t,e]),r};ge.prototype.removeToken=function(t,e){if(!isNaN(t)&&this.inboundIndex(t)){var n=this.tokens.splice(t,1);return e||this.dispatch("removeToken",[n,t]),n}else return{FAIL:"removeToken: invalid token index."}};ge.prototype.insertToken=function(t,e,n){var r=t.every(function(s){return s instanceof zt});return r?(this.tokens.splice.apply(this.tokens,[e,0].concat(t)),n||this.dispatch("insertToken",[t,e]),t):{FAIL:"insertToken: invalid token(s)."}};ge.prototype.registerModifier=function(t,e,n){this.events.newToken.subscribe(function(r,s){var i=[r,s],o=e===null||e.apply(this,i)===!0,a=[r,s];if(o){var l=n.apply(this,a);r.setState(t,l)}}),this.registeredModifiers.push(t)};rr.prototype.subscribe=function(t){return typeof t=="function"?this.subscribers.push(t)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}};rr.prototype.unsubscribe=function(t){this.subscribers.splice(t,1)};qe.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)};qe.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}};ge.prototype.rangeToText=function(t){if(t instanceof as)return this.getRangeTokens(t).map(function(e){return e.char}).join("")};ge.prototype.getText=function(){return this.tokens.map(function(t){return t.char}).join("")};ge.prototype.getContext=function(t){var e=this.registeredContexts[t];return e||null};ge.prototype.on=function(t,e){var n=this.events[t];return n?n.subscribe(e):null};ge.prototype.dispatch=function(t,e){var n=this,r=this.events[t];r instanceof rr&&r.subscribers.forEach(function(s){s.apply(n,e||[])})};ge.prototype.registerContextChecker=function(t,e,n){if(this.getContext(t))return{FAIL:"context name '"+t+"' is already registered."};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof n!="function")return{FAIL:"missing context end check."};var r=new sh(t,e,n);return this.registeredContexts[t]=r,this.contextCheckers.push(r),r};ge.prototype.getRangeTokens=function(t){var e=t.startIndex+t.endOffset;return[].concat(this.tokens.slice(t.startIndex,e))};ge.prototype.getContextRanges=function(t){var e=this.getContext(t);return e?e.ranges:{FAIL:"context checker '"+t+"' is not registered."}};ge.prototype.resetContextsRanges=function(){var t=this.registeredContexts;for(var e in t)if(t.hasOwnProperty(e)){var n=t[e];n.ranges=[]}};ge.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var t=this.tokens.map(function(r){return r.char}),e=0;e<t.length;e++){var n=new qe(t,e);this.runContextCheck(n)}this.dispatch("updateContextsRanges",[this.registeredContexts])};ge.prototype.setEndOffset=function(t,e){var n=this.getContext(e).openRange.startIndex,r=new as(n,t,e),s=this.getContext(e).ranges;return r.rangeId=e+"."+s.length,s.push(r),this.getContext(e).openRange=null,r};ge.prototype.runContextCheck=function(t){var e=this,n=t.index;this.contextCheckers.forEach(function(r){var s=r.contextName,i=e.getContext(s).openRange;if(!i&&r.checkStart(t)&&(i=new as(n,null,s),e.getContext(s).openRange=i,e.dispatch("contextStart",[s,n])),i&&r.checkEnd(t)){var o=n-i.startIndex+1,a=e.setEndOffset(o,s);e.dispatch("contextEnd",[s,a])}})};ge.prototype.tokenize=function(t){this.tokens=[],this.resetContextsRanges();var e=Array.from(t);this.dispatch("start");for(var n=0;n<e.length;n++){var r=e[n],s=new qe(e,n);this.dispatch("next",[s]),this.runContextCheck(s);var i=new zt(r);this.tokens.push(i),this.dispatch("newToken",[i,s])}return this.dispatch("end",[this.tokens]),this.tokens};function pt(t){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(t)}function Go(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 dt(t){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(t)}function jn(t){return/[A-z]/.test(t)}function oh(t){return/\s/.test(t)}function Re(t){this.font=t,this.features={}}function Et(t){this.id=t.id,this.tag=t.tag,this.substitution=t.substitution}function vn(t,e){if(!t)return-1;switch(e.format){case 1:return e.glyphs.indexOf(t);case 2:for(var n=e.ranges,r=0;r<n.length;r++){var s=n[r];if(t>=s.start&&t<=s.end){var i=t-s.start;return s.index+i}}break;default:return-1}return-1}function ah(t,e){var n=vn(t,e.coverage);return n===-1?null:t+e.deltaGlyphId}function lh(t,e){var n=vn(t,e.coverage);return n===-1?null:e.substitute[n]}function Vr(t,e){for(var n=[],r=0;r<t.length;r++){var s=t[r],i=e.current;i=Array.isArray(i)?i[0]:i;var o=vn(i,s);o!==-1&&n.push(o)}return n.length!==t.length?-1:n}function uh(t,e){var n=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(t.context.length<n)return[];var r=Vr(e.inputCoverage,t);if(r===-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&&dt(i[0].char);)i.shift();var o=new qe(i,0),a=Vr(e.lookaheadCoverage,o),l=[].concat(t.backtrack);for(l.reverse();l.length&&dt(l[0].char);)l.shift();if(l.length<e.backtrackCoverage.length)return[];var u=new qe(l,0),c=Vr(e.backtrackCoverage,u),f=r.length===e.inputCoverage.length&&a.length===e.lookaheadCoverage.length&&c.length===e.backtrackCoverage.length,h=[];if(f)for(var p=0;p<e.lookupRecords.length;p++)for(var d=e.lookupRecords[p],g=d.lookupListIndex,y=this.getLookupByIndex(g),x=0;x<y.subtables.length;x++){var L=y.subtables[x],w=this.getLookupMethod(y,L),A=this.getSubstitutionType(y,L);if(A==="12")for(var T=0;T<r.length;T++){var U=t.get(T),E=w(U);E&&h.push(E)}}return h}function ch(t,e){var n=t.current,r=vn(n,e.coverage);if(r===-1)return null;for(var s,i=e.ligatureSets[r],o=0;o<i.length;o++){s=i[o];for(var a=0;a<s.components.length;a++){var l=t.lookahead[a],u=s.components[a];if(l!==u)break;if(a===s.components.length-1)return s}}return null}function hh(t,e){var n=vn(t,e.coverage);return n===-1?null:e.sequences[n]}Re.prototype.getDefaultScriptFeaturesIndexes=function(){for(var t=this.font.tables.gsub.scripts,e=0;e<t.length;e++){var n=t[e];if(n.tag==="DFLT")return n.script.defaultLangSys.featureIndexes}return[]};Re.prototype.getScriptFeaturesIndexes=function(t){var e=this.font.tables;if(!e.gsub)return[];if(!t)return this.getDefaultScriptFeaturesIndexes();for(var n=this.font.tables.gsub.scripts,r=0;r<n.length;r++){var s=n[r];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 l=a.langSys;return l.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()};Re.prototype.mapTagsToFeatures=function(t,e){for(var n={},r=0;r<t.length;r++){var s=t[r].tag,i=t[r].feature;n[s]=i}this.features[e].tags=n};Re.prototype.getScriptFeatures=function(t){var e=this.features[t];if(this.features.hasOwnProperty(t))return e;var n=this.getScriptFeaturesIndexes(t);if(!n)return null;var r=this.font.tables.gsub;return e=n.map(function(s){return r.features[s]}),this.features[t]=e,this.mapTagsToFeatures(e,t),e};Re.prototype.getSubstitutionType=function(t,e){var n=t.lookupType.toString(),r=e.substFormat.toString();return n+r};Re.prototype.getLookupMethod=function(t,e){var n=this,r=this.getSubstitutionType(t,e);switch(r){case"11":return function(s){return ah.apply(n,[s,e])};case"12":return function(s){return lh.apply(n,[s,e])};case"63":return function(s){return uh.apply(n,[s,e])};case"41":return function(s){return ch.apply(n,[s,e])};case"21":return function(s){return hh.apply(n,[s,e])};default:throw new Error("lookupType: "+t.lookupType+" - substFormat: "+e.substFormat+" is not yet supported")}};Re.prototype.lookupFeature=function(t){var e=t.contextParams,n=e.index,r=this.getFeature({tag:t.tag,script:t.script});if(!r)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+t.tag+"' for script '"+t.script+"'.");for(var s=this.getFeatureLookups(r),i=[].concat(e.context),o=0;o<s.length;o++)for(var a=s[o],l=this.getLookupSubtables(a),u=0;u<l.length;u++){var c=l[u],f=this.getSubstitutionType(a,c),h=this.getLookupMethod(a,c),p=void 0;switch(f){case"11":p=h(e.current),p&&i.splice(n,1,new Et({id:11,tag:t.tag,substitution:p}));break;case"12":p=h(e.current),p&&i.splice(n,1,new Et({id:12,tag:t.tag,substitution:p}));break;case"63":p=h(e),Array.isArray(p)&&p.length&&i.splice(n,1,new Et({id:63,tag:t.tag,substitution:p}));break;case"41":p=h(e),p&&i.splice(n,1,new Et({id:41,tag:t.tag,substitution:p}));break;case"21":p=h(e.current),p&&i.splice(n,1,new Et({id:21,tag:t.tag,substitution:p}));break}e=new qe(i,n),!(Array.isArray(p)&&!p.length)&&(p=null)}return i.length?i:null};Re.prototype.supports=function(t){if(!t.script)return!1;this.getScriptFeatures(t.script);var e=this.features.hasOwnProperty(t.script);if(!t.tag)return e;var n=this.features[t.script].some(function(r){return r.tag===t.tag});return e&&n};Re.prototype.getLookupSubtables=function(t){return t.subtables||null};Re.prototype.getLookupByIndex=function(t){var e=this.font.tables.gsub.lookups;return e[t]||null};Re.prototype.getFeatureLookups=function(t){return t.lookupListIndexes.map(this.getLookupByIndex.bind(this))};Re.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};this.features.hasOwnProperty(e.script)||this.getScriptFeatures(e.script);var n=this.features[e.script];return n?n.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:"No feature for script "+e.script}};function fh(t){var e=t.current,n=t.get(-1);return n===null&&pt(e)||!pt(n)&&pt(e)}function ph(t){var e=t.get(1);return e===null||!pt(e)}var dh={startCheck:fh,endCheck:ph};function gh(t){var e=t.current,n=t.get(-1);return(pt(e)||dt(e))&&!pt(n)}function mh(t){var e=t.get(1);switch(!0){case e===null:return!0;case(!pt(e)&&!dt(e)):var n=oh(e);if(!n)return!0;if(n){var r=!1;if(r=t.lookahead.some(function(s){return pt(s)||dt(s)}),!r)return!0}break;default:return!1}}var vh={startCheck:gh,endCheck:mh};function xh(t,e,n){e[n].setState(t.tag,t.substitution)}function yh(t,e,n){e[n].setState(t.tag,t.substitution)}function bh(t,e,n){t.substitution.forEach(function(r,s){var i=e[n+s];i.setState(t.tag,r)})}function Sh(t,e,n){var r=e[n];r.setState(t.tag,t.substitution.ligGlyph);for(var s=t.substitution.components.length,i=0;i<s;i++)r=e[n+i+1],r.setState("deleted",!0)}var Xi={11:xh,12:yh,63:bh,41:Sh};function ls(t,e,n){t instanceof Et&&Xi[t.id]&&Xi[t.id](t,e,n)}function wh(t){for(var e=[].concat(t.backtrack),n=e.length-1;n>=0;n--){var r=e[n],s=Go(r),i=dt(r);if(!s&&!i)return!0;if(s)return!1}return!1}function kh(t){if(Go(t.current))return!1;for(var e=0;e<t.lookahead.length;e++){var n=t.lookahead[e],r=dt(n);if(!r)return!0}return!1}function Eh(t){var e=this,n="arab",r=this.featuresTags[n],s=this.tokenizer.getRangeTokens(t);if(s.length!==1){var i=new qe(s.map(function(a){return a.getState("glyphIndex")}),0),o=new qe(s.map(function(a){return a.char}),0);s.forEach(function(a,l){if(!dt(a.char)){i.setCurrentIndex(l),o.setCurrentIndex(l);var u=0;wh(o)&&(u|=1),kh(o)&&(u|=2);var c;switch(u){case 1:c="fina";break;case 2:c="init";break;case 3:c="medi";break}if(r.indexOf(c)!==-1){var f=e.query.lookupFeature({tag:c,script:n,contextParams:i});if(f instanceof Error)return console.info(f.message);f.forEach(function(h,p){h instanceof Et&&(ls(h,s,p),i.context[p]=h.substitution)})}}})}}function qi(t,e){var n=t.map(function(r){return r.activeState.value});return new qe(n,e||0)}function Ph(t){var e=this,n="arab",r=this.tokenizer.getRangeTokens(t),s=qi(r);s.context.forEach(function(i,o){s.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"rlig",script:n,contextParams:s});a.length&&(a.forEach(function(l){return ls(l,r,o)}),s=qi(r))})}function Lh(t){var e=t.current,n=t.get(-1);return n===null&&jn(e)||!jn(n)&&jn(e)}function Th(t){var e=t.get(1);return e===null||!jn(e)}var Ih={startCheck:Lh,endCheck:Th};function Wi(t,e){var n=t.map(function(r){return r.activeState.value});return new qe(n,e||0)}function Ch(t){var e=this,n="latn",r=this.tokenizer.getRangeTokens(t),s=Wi(r);s.context.forEach(function(i,o){s.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"liga",script:n,contextParams:s});a.length&&(a.forEach(function(l){return ls(l,r,o)}),s=Wi(r))})}function Ze(t){this.baseDir=t||"ltr",this.tokenizer=new ge,this.featuresTags={}}Ze.prototype.setText=function(t){this.text=t};Ze.prototype.contextChecks={latinWordCheck:Ih,arabicWordCheck:dh,arabicSentenceCheck:vh};function $r(t){var e=this.contextChecks[t+"Check"];return this.tokenizer.registerContextChecker(t,e.startCheck,e.endCheck)}function Mh(){return $r.call(this,"latinWord"),$r.call(this,"arabicWord"),$r.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function Ah(){var t=this,e=this.tokenizer.getContextRanges("arabicSentence");e.forEach(function(n){var r=t.tokenizer.getRangeTokens(n);t.tokenizer.replaceRange(n.startIndex,n.endOffset,r.reverse())})}Ze.prototype.registerFeatures=function(t,e){var n=this,r=e.filter(function(s){return n.query.supports({script:t,tag:s})});this.featuresTags.hasOwnProperty(t)?this.featuresTags[t]=this.featuresTags[t].concat(r):this.featuresTags[t]=r};Ze.prototype.applyFeatures=function(t,e){if(!t)throw new Error("No valid font was provided to apply features");this.query||(this.query=new Re(t));for(var n=0;n<e.length;n++){var r=e[n];this.query.supports({script:r.script})&&this.registerFeatures(r.script,r.tags)}};Ze.prototype.registerModifier=function(t,e,n){this.tokenizer.registerModifier(t,e,n)};function us(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function Oh(){var t=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){us.call(this);var n=this.tokenizer.getContextRanges("arabicWord");n.forEach(function(r){Eh.call(t,r)})}}function Fh(){var t=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){var n=this.featuresTags[e];if(n.indexOf("rlig")!==-1){us.call(this);var r=this.tokenizer.getContextRanges("arabicWord");r.forEach(function(s){Ph.call(t,s)})}}}function Dh(){var t=this,e="latn";if(this.featuresTags.hasOwnProperty(e)){var n=this.featuresTags[e];if(n.indexOf("liga")!==-1){us.call(this);var r=this.tokenizer.getContextRanges("latinWord");r.forEach(function(s){Ch.call(t,s)})}}}Ze.prototype.checkContextReady=function(t){return!!this.tokenizer.getContext(t)};Ze.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(Oh.call(this),Fh.call(this)),this.checkContextReady("latinWord")&&Dh.call(this),this.checkContextReady("arabicSentence")&&Ah.call(this)};Ze.prototype.processText=function(t){(!this.text||this.text!==t)&&(this.setText(t),Mh.call(this),this.applyFeaturesToContexts())};Ze.prototype.getBidiText=function(t){return this.processText(t),this.tokenizer.getText()};Ze.prototype.getTextGlyphs=function(t){this.processText(t);for(var e=[],n=0;n<this.tokenizer.tokens.length;n++){var r=this.tokenizer.tokens[n];if(!r.state.deleted){var s=r.activeState.value;e.push(Array.isArray(s)?s[0]:s)}}return e};function se(t){t=t||{},t.tables=t.tables||{},t.empty||(an(t.familyName,"When creating a new Font object, familyName is required."),an(t.styleName,"When creating a new Font object, styleName is required."),an(t.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),an(t.ascender,"When creating a new Font object, ascender is required."),an(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 et.GlyphSet(this,t.glyphs||[]),this.encoding=new ro(this),this.position=new dn(this),this.substitution=new De(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 Ro(this)}})}se.prototype.hasChar=function(t){return this.encoding.charToGlyphIndex(t)!==null};se.prototype.charToGlyphIndex=function(t){return this.encoding.charToGlyphIndex(t)};se.prototype.charToGlyph=function(t){var e=this.charToGlyphIndex(t),n=this.glyphs.get(e);return n||(n=this.glyphs.get(0)),n};se.prototype.updateFeatures=function(t){return this.defaultRenderOptions.features.map(function(e){return e.script==="latn"?{script:"latn",tags:e.tags.filter(function(n){return t[n]})}:e})};se.prototype.stringToGlyphs=function(t,e){var n=this,r=new Ze,s=function(f){return n.charToGlyphIndex(f.char)};r.registerModifier("glyphIndex",null,s);var i=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;r.applyFeatures(this,i);for(var o=r.getTextGlyphs(t),a=o.length,l=new Array(a),u=this.glyphs.get(0),c=0;c<a;c+=1)l[c]=this.glyphs.get(o[c])||u;return l};se.prototype.nameToGlyphIndex=function(t){return this.glyphNames.nameToGlyphIndex(t)};se.prototype.nameToGlyph=function(t){var e=this.nameToGlyphIndex(t),n=this.glyphs.get(e);return n||(n=this.glyphs.get(0)),n};se.prototype.glyphIndexToName=function(t){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(t):""};se.prototype.getKerningValue=function(t,e){t=t.index||t,e=e.index||e;var n=this.position.defaultKerningTables;return n?this.position.getKerningValue(n,t,e):this.kerningPairs[t+","+e]||0};se.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]};se.prototype.forEachGlyph=function(t,e,n,r,s,i){e=e!==void 0?e:0,n=n!==void 0?n:0,r=r!==void 0?r:72,s=Object.assign({},this.defaultRenderOptions,s);var o=1/this.unitsPerEm*r,a=this.stringToGlyphs(t,s),l;if(s.kerning){var u=s.script||this.position.getDefaultScriptName();l=this.position.getKerningTables(u,s.language)}for(var c=0;c<a.length;c+=1){var f=a[c];if(i.call(this,f,e,n,r,s),f.advanceWidth&&(e+=f.advanceWidth*o),s.kerning&&c<a.length-1){var h=l?this.position.getKerningValue(l,f.index,a[c+1].index):this.getKerningValue(f,a[c+1]);e+=h*o}s.letterSpacing?e+=s.letterSpacing*r:s.tracking&&(e+=s.tracking/1e3*r)}return e};se.prototype.getPath=function(t,e,n,r,s){var i=new ye;return this.forEachGlyph(t,e,n,r,s,function(o,a,l,u){var c=o.getPath(a,l,u,s,this);i.extend(c)}),i};se.prototype.getPaths=function(t,e,n,r,s){var i=[];return this.forEachGlyph(t,e,n,r,s,function(o,a,l,u){var c=o.getPath(a,l,u,s,this);i.push(c)}),i};se.prototype.getAdvanceWidth=function(t,e,n){return this.forEachGlyph(t,0,0,e,n,function(){})};se.prototype.draw=function(t,e,n,r,s,i){this.getPath(e,n,r,s,i).draw(t)};se.prototype.drawPoints=function(t,e,n,r,s,i){this.forEachGlyph(e,n,r,s,i,function(o,a,l,u){o.drawPoints(t,a,l,u)})};se.prototype.drawMetrics=function(t,e,n,r,s,i){this.forEachGlyph(e,n,r,s,i,function(o,a,l,u){o.drawMetrics(t,a,l,u)})};se.prototype.getEnglishName=function(t){var e=this.names[t];if(e)return e.en};se.prototype.validate=function(){var t=this;function e(r,s){}function n(r){var s=t.getEnglishName(r);s&&s.trim().length>0}n("fontFamily"),n("weightName"),n("manufacturer"),n("copyright"),n("version"),this.unitsPerEm>0};se.prototype.toTables=function(){return Su.fontToTable(this)};se.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};se.prototype.toArrayBuffer=function(){for(var t=this.toTables(),e=t.encode(),n=new ArrayBuffer(e.length),r=new Uint8Array(n),s=0;s<e.length;s++)r[s]=e[s];return n};se.prototype.download=function(t){var e=this.getEnglishName("fontFamily"),n=this.getEnglishName("fontSubfamily");t=t||e.replace(/\s/g,"")+"-"+n+".otf";var r=this.toArrayBuffer();if(ku())if(window.URL=window.URL||window.webkitURL,window.URL){var s=new DataView(r),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 l=li(),u=Eu(r);l.writeFileSync(t,u)}};se.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512};se.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};se.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function zo(t,e){var n=JSON.stringify(t),r=256;for(var s in e){var i=parseInt(s);if(!(!i||i<256)){if(JSON.stringify(e[s])===n)return i;r<=i&&(r=i+1)}}return e[r]=t,r}function Rh(t,e,n){var r=zo(e.name,n);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:r}]}function Uh(t,e,n){var r={},s=new O.Parser(t,e);return r.tag=s.parseTag(),r.minValue=s.parseFixed(),r.defaultValue=s.parseFixed(),r.maxValue=s.parseFixed(),s.skip("uShort",1),r.name=n[s.parseUShort()]||{},r}function Nh(t,e,n,r){for(var s=zo(e.name,r),i=[{name:"nameID_"+t,type:"USHORT",value:s},{name:"flags_"+t,type:"USHORT",value:0}],o=0;o<n.length;++o){var a=n[o].tag;i.push({name:"axis_"+t+" "+a,type:"FIXED",value:e.coordinates[a]<<16})}return i}function Bh(t,e,n,r){var s={},i=new O.Parser(t,e);s.name=r[i.parseUShort()]||{},i.skip("uShort",1),s.coordinates={};for(var o=0;o<n.length;++o)s.coordinates[n[o].tag]=i.parseFixed();return s}function Gh(t,e){var n=new C.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:t.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:t.instances.length},{name:"instanceSize",type:"USHORT",value:4+t.axes.length*4}]);n.offsetToData=n.sizeOf();for(var r=0;r<t.axes.length;r++)n.fields=n.fields.concat(Rh(r,t.axes[r],e));for(var s=0;s<t.instances.length;s++)n.fields=n.fields.concat(Nh(s,t.instances[s],t.axes,e));return n}function zh(t,e,n){var r=new O.Parser(t,e),s=r.parseULong();N.argument(s===65536,"Unsupported fvar table version.");var i=r.parseOffset16();r.skip("uShort",1);for(var o=r.parseUShort(),a=r.parseUShort(),l=r.parseUShort(),u=r.parseUShort(),c=[],f=0;f<o;f++)c.push(Uh(t,e+i+f*a,n));for(var h=[],p=e+i+o*a,d=0;d<l;d++)h.push(Bh(t,p+d*u,c,n));return{axes:c,instances:h}}var Hh={make:Gh,parse:zh},Vh=function(){return{coverage:this.parsePointer(v.coverage),attachPoints:this.parseList(v.pointer(v.uShortList))}},$h=function(){var t=this.parseUShort();if(N.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()}},Xh=function(){return this.parseList(v.pointer($h))},qh=function(){return{coverage:this.parsePointer(v.coverage),ligGlyphs:this.parseList(v.pointer(Xh))}},Wh=function(){return this.parseUShort(),this.parseList(v.pointer(v.coverage))};function _h(t,e){e=e||0;var n=new v(t,e),r=n.parseVersion(1);N.argument(r===1||r===1.2||r===1.3,"Unsupported GDEF table version.");var s={version:r,classDef:n.parsePointer(v.classDef),attachList:n.parsePointer(Vh),ligCaretList:n.parsePointer(qh),markAttachClassDef:n.parsePointer(v.classDef)};return r>=1.2&&(s.markGlyphSets=n.parsePointer(Wh)),s}var Zh={parse:_h},We=new Array(10);We[1]=function(){var e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{posFormat:1,coverage:this.parsePointer(v.coverage),value:this.parseValueRecord()};if(n===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.")};We[2]=function(){var e=this.offset+this.relativeOffset,n=this.parseUShort();N.assert(n===1||n===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var r=this.parsePointer(v.coverage),s=this.parseUShort(),i=this.parseUShort();if(n===1)return{posFormat:n,coverage:r,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(n===2){var o=this.parsePointer(v.classDef),a=this.parsePointer(v.classDef),l=this.parseUShort(),u=this.parseUShort();return{posFormat:n,coverage:r,valueFormat1:s,valueFormat2:i,classDef1:o,classDef2:a,class1Count:l,class2Count:u,classRecords:this.parseList(l,v.list(u,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}}))}}};We[3]=function(){return{error:"GPOS Lookup 3 not supported"}};We[4]=function(){return{error:"GPOS Lookup 4 not supported"}};We[5]=function(){return{error:"GPOS Lookup 5 not supported"}};We[6]=function(){return{error:"GPOS Lookup 6 not supported"}};We[7]=function(){return{error:"GPOS Lookup 7 not supported"}};We[8]=function(){return{error:"GPOS Lookup 8 not supported"}};We[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function jh(t,e){e=e||0;var n=new v(t,e),r=n.parseVersion(1);return N.argument(r===1||r===1.1,"Unsupported GPOS table version "+r),r===1?{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(We)}:{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(We),variations:n.parseFeatureVariationsList()}}var Yh=new Array(10);function Kh(t){return new C.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new C.ScriptList(t.scripts)},{name:"features",type:"TABLE",value:new C.FeatureList(t.features)},{name:"lookups",type:"TABLE",value:new C.LookupList(t.lookups,Yh)}])}var Jh={parse:jh,make:Kh};function Qh(t){var e={};t.skip("uShort");var n=t.parseUShort();N.argument(n===0,"Unsupported kern sub-table version."),t.skip("uShort",2);var r=t.parseUShort();t.skip("uShort",3);for(var s=0;s<r;s+=1){var i=t.parseUShort(),o=t.parseUShort(),a=t.parseShort();e[i+","+o]=a}return e}function ef(t){var e={};t.skip("uShort");var n=t.parseULong();n>1&&console.warn("Only the first kern subtable is supported."),t.skip("uLong");var r=t.parseUShort(),s=r&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(),l=t.parseUShort(),u=t.parseShort();e[a+","+l]=u}}return e}function tf(t,e){var n=new O.Parser(t,e),r=n.parseUShort();if(r===0)return Qh(n);if(r===1)return ef(n);throw new Error("Unsupported kern table version ("+r+").")}var nf={parse:tf};function rf(t,e,n,r){for(var s=new O.Parser(t,e),i=r?s.parseUShort:s.parseULong,o=[],a=0;a<n+1;a+=1){var l=i.call(s);r&&(l*=2),o.push(l)}return o}var sf={parse:rf};function _i(t,e){for(var n=[],r=12,s=0;s<e;s+=1){var i=O.getTag(t,r),o=O.getULong(t,r+4),a=O.getULong(t,r+8),l=O.getULong(t,r+12);n.push({tag:i,checksum:o,offset:a,length:l,compression:!1}),r+=16}return n}function of(t,e){for(var n=[],r=44,s=0;s<e;s+=1){var i=O.getTag(t,r),o=O.getULong(t,r+4),a=O.getULong(t,r+8),l=O.getULong(t,r+12),u=void 0;a<l?u="WOFF":u=!1,n.push({tag:i,offset:o,compression:u,compressedLength:a,length:l}),r+=20}return n}function ve(t,e){if(e.compression==="WOFF"){var n=new Uint8Array(t.buffer,e.offset+2,e.compressedLength-2),r=new Uint8Array(e.length);if(Ja(n,r),r.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");var s=new DataView(r.buffer,0);return{data:s,offset:0}}else return{data:t,offset:e.offset}}function Ho(t,e){e=e??{};var n,r,s=new se({empty:!0}),i=new DataView(t,0),o,a=[],l=O.getTag(i,0);if(l==="\0\0\0"||l==="true"||l==="typ1")s.outlinesFormat="truetype",o=O.getUShort(i,4),a=_i(i,o);else if(l==="OTTO")s.outlinesFormat="cff",o=O.getUShort(i,4),a=_i(i,o);else if(l==="wOFF"){var u=O.getTag(i,4);if(u==="\0\0\0")s.outlinesFormat="truetype";else if(u==="OTTO")s.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+l);o=O.getUShort(i,12),a=of(i,o)}else throw new Error("Unsupported OpenType signature "+l);for(var c,f,h,p,d,g,y,x,L,w,A,T,U=0;U<o;U+=1){var E=a[U],P=void 0;switch(E.tag){case"cmap":P=ve(i,E),s.tables.cmap=no.parse(P.data,P.offset),s.encoding=new so(s.tables.cmap);break;case"cvt ":P=ve(i,E),T=new O.Parser(P.data,P.offset),s.tables.cvt=T.parseShortList(E.length/2);break;case"fvar":f=E;break;case"fpgm":P=ve(i,E),T=new O.Parser(P.data,P.offset),s.tables.fpgm=T.parseByteList(E.length);break;case"head":P=ve(i,E),s.tables.head=go.parse(P.data,P.offset),s.unitsPerEm=s.tables.head.unitsPerEm,n=s.tables.head.indexToLocFormat;break;case"hhea":P=ve(i,E),s.tables.hhea=mo.parse(P.data,P.offset),s.ascender=s.tables.hhea.ascender,s.descender=s.tables.hhea.descender,s.numberOfHMetrics=s.tables.hhea.numberOfHMetrics;break;case"hmtx":y=E;break;case"ltag":P=ve(i,E),r=xo.parse(P.data,P.offset);break;case"maxp":P=ve(i,E),s.tables.maxp=yo.parse(P.data,P.offset),s.numGlyphs=s.tables.maxp.numGlyphs;break;case"name":w=E;break;case"OS/2":P=ve(i,E),s.tables.os2=Kr.parse(P.data,P.offset);break;case"post":P=ve(i,E),s.tables.post=Po.parse(P.data,P.offset),s.glyphNames=new rs(s.tables.post);break;case"prep":P=ve(i,E),T=new O.Parser(P.data,P.offset),s.tables.prep=T.parseByteList(E.length);break;case"glyf":h=E;break;case"loca":L=E;break;case"CFF ":c=E;break;case"kern":x=E;break;case"GDEF":p=E;break;case"GPOS":d=E;break;case"GSUB":g=E;break;case"meta":A=E;break}}var F=ve(i,w);if(s.tables.name=Eo.parse(F.data,F.offset,r),s.names=s.tables.name,h&&L){var z=n===0,R=ve(i,L),he=sf.parse(R.data,R.offset,s.numGlyphs,z),V=ve(i,h);s.glyphs=Oo.parse(V.data,V.offset,he,s,e)}else if(c){var W=ve(i,c);po.parse(W.data,W.offset,s,e)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");var $=ve(i,y);if(vo.parse(s,$.data,$.offset,s.numberOfHMetrics,s.numGlyphs,s.glyphs,e),yl(s,e),x){var Z=ve(i,x);s.kerningPairs=nf.parse(Z.data,Z.offset)}else s.kerningPairs={};if(p){var ne=ve(i,p);s.tables.gdef=Zh.parse(ne.data,ne.offset)}if(d){var te=ve(i,d);s.tables.gpos=Jh.parse(te.data,te.offset),s.position.init()}if(g){var oe=ve(i,g);s.tables.gsub=Lo.parse(oe.data,oe.offset)}if(f){var fe=ve(i,f);s.tables.fvar=Hh.parse(fe.data,fe.offset,s.names)}if(A){var Q=ve(i,A);s.tables.meta=To.parse(Q.data,Q.offset),s.metas=s.tables.meta}return s}var sr=class{constructor(e,n){this.sources=e;this.fallback=n;this.parsed=new Map;this.missing=new Set}names(){return Object.keys(this.sources)}get(e){let n=e||this.fallback||Object.keys(this.sources)[0];if(!n)throw this.missing.add(""),new Error("text() needs a font. Pass fonts to render(), or --font on the command line.");let r=this.parsed.get(n);if(r)return r;let s=Ct(this.sources,n);if(!s)throw this.missing.add(n),new Error(`Font "${n}" 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=Ho(i);return this.parsed.set(n,o),o}};function af(t,e,n){let r={kerning:!0};if(n.spacing===1)return{cmds:t.getPath(e,0,0,n.size,r).commands,advance:t.getAdvanceWidth(e,n.size,r)};let s=[],i=0,o=[...e];return o.forEach((a,l)=>{s.push(...t.getPath(a,i,0,n.size,r).commands),i+=t.getAdvanceWidth(a,n.size,r)*(l<o.length-1?n.spacing:1)}),{cmds:s,advance:i}}function Vo(t,e,n){let{cmds:r,advance:s}=af(t,e,n),i=r.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=Vn(i,Math.max(.005,n.size/2e3));return{polys:[...o.closed,...o.open.filter(a=>a.length>=3)],advance:s}}function $o(t,e,n){if(!e)return[];let r=t.get(n.font),{polys:s,advance:i}=Vo(r,e,n),o=be(s),a=Bn(o);if(!a)return[];let l=n.halign==="center"?-i/2:n.halign==="right"?-i:0,u=n.valign==="top"?-a[3]:n.valign==="center"?-(a[1]+a[3])/2:n.valign==="bottom"?-a[1]:0;return o.map(c=>c.map(([f,h])=>[f+l,h+u]))}function Xo(t,e,n){let r=t.get(n.font),{polys:s,advance:i}=Vo(r,e,n),o=Bn(s)??[0,0,0,0];return{advance:i,bounds:[[o[0],o[1]],[o[2],o[3]]],ascent:r.ascender/r.unitsPerEm*n.size,descent:r.descender/r.unitsPerEm*n.size}}var ar=[{name:"engrave",mode:"fill",color:"#000000"},{name:"score",mode:"line",color:"#0000ff"},{name:"cut",mode:"cut",color:"#ff0000"},{name:"guide",mode:"guide",color:"#00a0ff"}],Wo={maxParts:1e4,maxSegments:1e4,maxListLength:1e6,maxListItems:3e6,maxTextLength:2e3,maxPoints:2e6,maxOutputPoints:1e6,maxSheets:200,maxCollisionPairs:2e4},lf=100,Ht=4,qo=8,uf=t=>{let e=lf,n=r=>{for(let s of r.values()){for(let i of s.regions)e+=i.length;for(let i of s.lines)e+=i.length}};n(t.layers);for(let r of t.parts)n(r.layers);return e},we=class{constructor(e,n){this.parent=e;this.caller=n;this.vars=new Map;this.fns=new Map;this.mods=new Map}get(e){let n=this,r=e.startsWith("$");for(;n;){if(n.vars.has(e))return{found:!0,value:n.vars.get(e)};n=r?n.caller??n.parent:n.parent}return{found:!1}}fn(e){for(let n=this;n;n=n.parent){let r=n.fns.get(e);if(r)return r}}mod(e){for(let n=this;n;n=n.parent){let r=n.mods.get(e);if(r)return r}}childCtx(){for(let e=this;e;e=e.parent)if(e.children)return e.children}names(e){let n=[];for(let r=this;r;r=r.parent)n.push(...r[e].keys());return n}},cs=t=>t?`.${t}`:"",cf=["echo","assert","text_width","text_metrics","finger_count"];function ir(t,e){let n="",r=Math.min(2,Math.floor(t.length/3))+.5;for(let s of new Set(e)){if(s===t)continue;let i=s.toLowerCase()===t.toLowerCase()?0:hf(t,s);i<r&&([n,r]=[s,i])}return n?` Did you mean "${n}"?`:""}function hf(t,e){if(Math.abs(t.length-e.length)>2)return 3;let n=Array.from({length:t.length+1},(r,s)=>[s,...Array(e.length).fill(0)]);for(let r=1;r<=e.length;r++)n[0][r]=r;for(let r=1;r<=t.length;r++)for(let s=1;s<=e.length;s++)n[r][s]=Math.min(n[r-1][s]+1,n[r][s-1]+1,n[r-1][s-1]+(t[r-1]===e[s-1]?0:1)),r>1&&s>1&&t[r-1]===e[s-2]&&t[r-2]===e[s-1]&&(n[r][s]=Math.min(n[r][s],n[r-2][s-2]+1));return n[t.length][e.length]}var ff=on,or=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(ar.map(e=>[e.name,e]));this.loaded=new Map;this.using=[];this.including=[];this.maxSteps=e.maxSteps??5e6,this.limits={...Wo,...e.limits},this.builtins=this.makeBuiltins()}run(e){let n=new we,r={$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(r))n.vars.set(o,a);let s=new we(n);return{shape:this.block(e.body,s,!0),globals:s,layers:this.layers,echoes:this.echoes,warnings:this.warnings}}tick(e,n=1){if(!((this.steps+=n)<=this.maxSteps))throw new D(`Stopped after ${this.maxSteps} steps. Is there an endless loop?`,e)}load(e,n){let r=this.loaded.get(e);if(r)return r;let s=Ct(ff,e)??this.opts.resolve?.(e);if(typeof s!="string")throw new D(`Library <${e}> not found`,n);this.loaded.set(e,{body:[]});let{program:i}=nt(s,e);return this.loaded.set(e,i),i}hoist(e,n){for(let r of e)if(r.kind==="module")n.mods.set(r.name,{params:r.params,body:r.body,env:n});else if(r.kind==="function")n.fns.set(r.name,{params:r.params,body:r.body,env:n});else if(r.kind==="use"&&!r.include){this.enter(this.using,r.path,r.pos,"use");try{let s=this.included(this.load(r.path,r.pos).body,new Set([r.path])),i=new we(n);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)n.mods.set(o,a);for(let[o,a]of i.fns)n.fns.set(o,a)}finally{this.using.pop()}}}enter(e,n,r,s){if(e.includes(n)){let i=[...e.slice(e.indexOf(n)),n].map(o=>`<${o}>`);throw new D(i.length===2?`Library ${i[0]} ${s}s itself`:`Libraries ${s} each other in a loop: ${i.join(" \u2192 ")}`,r)}e.push(n)}included(e,n){let r=[];for(let s of e)if(s.kind!=="use"||!s.include)r.push(s);else if(!n.has(s.path)){n.add(s.path);for(let i of this.included(this.load(s.path,s.pos).body,n))r.push(i)}return r}assign(e,n,r){r.vars.set(e,n)}block(e,n,r=!1){this.hoist(e,n);let s=[];for(let i of e){let o=this.stmt(i,n,r);o&&!_s(o)&&s.push(o)}return s.length===1?s[0]:Qt(s)}stmt(e,n,r=!1){switch(this.tick(e.pos),e.kind){case"assign":{let s=this.opts.overrides,i=r&&s&&Object.prototype.hasOwnProperty.call(s,e.name)?s[e.name]:this.expr(e.value,n);return this.assign(e.name,i,n),null}case"module":case"function":return null;case"use":{if(!e.include)return null;this.enter(this.including,e.path,e.pos,"include");try{return this.block(this.load(e.path,e.pos).body,n)}finally{this.including.pop()}}case"block":return this.block(e.body,new we(n));case"if":return Fe(this.expr(e.cond,n))?this.block(e.then,new we(n)):this.block(e.else,new we(n));case"let":{let s=new we(n);return this.bindSeq(e.assigns,s),this.block(e.body,s)}case"for":{let s=[];return this.loop(e.assigns,n,i=>s.push(this.block(e.body,i))),Qt(s)}case"call":if(e.modifier==="*")return null;{let s=this.callModule(e,n);return e.modifier==="#"||e.modifier==="%"?Nn(s,"guide"):s}}}bindSeq(e,n){for(let r of e)this.assign(r.name,this.expr(r.value,n),n)}iterable(e,n){if(He(e))try{return kn(e,this.limits.maxListLength)}catch(r){throw new D(r.message,n)}return Array.isArray(e)?e:typeof e=="string"?[...e]:e===void 0?[]:[e]}loop(e,n,r,s=0,i=new we(n)){if(s===e.length)return r(i);let o=e[s];for(let a of this.iterable(this.expr(o.value,i),o.pos)){this.tick(o.pos);let l=new we(i);l.vars.set(o.name,a),this.loop(e,n,r,s+1,l)}}evalArgs(e,n,r){let s=[],i=new Map,o=[];for(let a of e){let l=this.expr(a.value,n);a.name===null?s.push(l):i.set(a.name,l),o.push({name:a.name,value:l})}return{pos:s,named:i,all:o,at:r}}bindParams(e,n,r,s,i){let o=e.map(a=>a.name);e.forEach((a,l)=>{let u;n.named.has(a.name)?u=n.named.get(a.name):l<n.pos.length?u=n.pos[l]:u=a.default?this.expr(a.default,r):void 0,r.vars.set(a.name,u)});for(let a of n.named.keys())a.startsWith("$")?r.vars.set(a,n.named.get(a)):o.includes(a)||this.unknownArg(i,a,n.at,o);this.checkCount(i,e.length,n)}checkArgs(e,n){let r=sn(e);if(!r)return;let s=r.params.map(i=>i.name);if(!r.anyNamed)for(let i of n.named.keys())!i.startsWith("$")&&!s.includes(i)&&this.unknownArg(`${e}()`,i,n.at,s);r.rest||this.checkCount(`${e}()`,r.params.filter(i=>!i.named).length,n)}checkCount(e,n,r){r.pos.length>n&&this.warn(`${e}: takes ${n===0?"no":`at most ${n}`} positional argument${n===1?"":"s"}, got ${r.pos.length}; the rest are ignored (${tn(r.at,!1)})`)}unknownArg(e,n,r,s){this.warn(`${e}: unknown argument "${n}"${cs(ir(n,s))} (${tn(r,!1)})`)}warn(e){this.warnings.includes(e)||this.warnings.push(e)}callModule(e,n){let r=this.evalArgs(e.args,n,e.pos),s=n.mod(e.name);if(s){if(++this.depth>1e3)throw new D(`Recursion too deep in module ${e.name}(): it calls itself without stopping`,e.pos);try{let f=new we(s.env,n);return this.bindParams(s.params,r,f,s.env,`${e.name}()`),f.children={stmts:e.children,env:n},f.vars.set("$children",this.childStmts(e.children).length),this.block(s.body,f)}catch(f){throw this.inCall(f,"module",e.name,e.pos)}finally{this.depth--}}let i=Ct(this.builtins,e.name);if(!i){let f=e.name==="color"?" Use layer(), cut(), score() or engrave() instead.":ir(e.name,[...n.names("mods"),...Object.keys(this.builtins)]);throw new D(`Unknown module ${e.name}().${f}`,e.pos)}this.checkArgs(e.name,r);let o=new we(n,n);for(let[f,h]of r.named)f.startsWith("$")&&o.vars.set(f,h);let a=this.childStmts(e.children),l=()=>new we(n,o),u={args:r,env:o,children:()=>e.children.length?this.block(e.children,l()):St(),childList:()=>{let f=l();this.hoist(e.children,f);let h=[];for(let p of e.children){let d=this.stmt(p,f);a.includes(p)&&h.push(d??St())}return h}},c;try{c=i(u)}catch(f){if(f instanceof D||f instanceof RangeError)throw f;let h=new D(`${e.name}(): ${f.message}`,e.pos);throw h.call=e.name,h}if(this.pointCount+=uf(c),this.pointCount>this.limits.maxPoints)throw new D(`The shapes have more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes, or a lower $fn.`,e.pos);return c}childStmts(e){return e.filter(n=>n.kind!=="assign"&&n.kind!=="module"&&n.kind!=="function"&&n.kind!=="use")}callFunction(e,n,r,s){if(++this.depth>2e3)throw new D(`Recursion too deep in ${s}(): it calls itself without stopping`,n.at);try{this.tick(n.at);let i=it(e)?e.scope:e.env,o=new we(i,r);return this.bindParams(e.params,n,o,i,`${s}()`),this.expr(e.body,o)}catch(i){throw this.inCall(i,"function",s,n.at)}finally{this.depth--}}inCall(e,n,r,s){return e instanceof Error&&!(e instanceof D)&&e.message.includes("call stack")?new D(`Recursion too deep in ${n==="module"?"module ":""}${r}(): it calls itself without stopping`,s):(e instanceof D&&e.addFrame(n,r,s),e)}expr(e,n){switch(e.kind){case"num":case"str":case"bool":return e.value;case"undef":return;case"var":{let r=n.get(e.name);if(r.found)return r.value;let s=n.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 D(`Unknown variable "${e.name}"${cs(ir(e.name,[...n.names("vars"),...n.names("fns")]))}`,e.pos)}case"list":{let r=[];for(let s of e.items)this.listItem(s,n,r,e.pos);return this.charge(Ht,e.pos),r}case"range":{let r=this.expr(e.start,n),s=this.expr(e.end,n),i=e.step?this.expr(e.step,n):1;if(typeof r!="number"||typeof s!="number"||typeof i!="number")throw new D("Range values must be numbers",e.pos);return{type:"range",start:r,step:i,end:s}}case"unary":{let r=this.expr(e.arg,n);return e.op==="!"?!Fe(r):e.op==="+"?r:this.arith("*",-1,r,e.pos)}case"binary":{if(e.op==="&&")return Fe(this.expr(e.left,n))&&Fe(this.expr(e.right,n));if(e.op==="||")return Fe(this.expr(e.left,n))||Fe(this.expr(e.right,n));let r=this.expr(e.left,n),s=this.expr(e.right,n);if(e.op==="=="||e.op==="!=")return Xt(r,s,()=>this.tick(e.pos))===(e.op==="==");if(e.op==="<"||e.op==="<="||e.op===">"||e.op===">="){if(!(typeof r=="number"&&typeof s=="number"||typeof r=="string"&&typeof s=="string"))throw new D(`Can't compare ${Ne(r)} ${e.op} ${Ne(s)}`,e.pos);return e.op==="<"?r<s:e.op==="<="?r<=s:e.op===">"?r>s:r>=s}return this.arith(e.op,r,s,e.pos)}case"ternary":return Fe(this.expr(e.cond,n))?this.expr(e.then,n):this.expr(e.else,n);case"index":{let r=this.expr(e.target,n),s=this.expr(e.index,n);if(typeof s!="number")throw new D(`List index must be a number, got ${Ne(s)}`,e.pos);return Array.isArray(r)?r[Math.floor(s)]:typeof r=="string"?[...r][Math.floor(s)]:He(r)?[r.start,r.step,r.end][Math.floor(s)]:void 0}case"member":{let r=this.expr(e.target,n),s={x:0,y:1,z:2}[e.name];return Array.isArray(r)&&s!==void 0?r[s]:He(r)&&(e.name==="begin"||e.name==="step"||e.name==="end")?e.name==="begin"?r.start:e.name==="step"?r.step:r.end:void 0}case"call":return this.call(e,n);case"lambda":return{type:"function",params:e.params,body:e.body,scope:n};case"let":{let r=new we(n);return this.bindSeq(e.assigns,r),this.expr(e.body,r)}}}listItem(e,n,r,s){switch(e.kind){case"item":{let i=this.expr(e.expr,n);this.grow(r,1,s),r.push(i);return}case"each":{let i=this.iterable(this.expr(e.expr,n),s);this.grow(r,i.length,s);for(let o of i)r.push(o);return}case"for":this.loop(e.assigns,n,i=>this.listItem(e.body,i,r,s));return;case"if":Fe(this.expr(e.cond,n))?this.listItem(e.then,n,r,s):e.else&&this.listItem(e.else,n,r,s);return;case"let":{let i=new we(n);this.bindSeq(e.assigns,i),this.listItem(e.body,i,r,s)}}}grow(e,n,r){if(e.length+n>this.limits.maxListLength)throw new D(`a list of ${e.length+n} items is more than the limit of ${this.limits.maxListLength}`,r);this.charge(n,r)}charge(e,n){if(this.itemCount+=e,!(this.itemCount<=this.limits.maxListItems))throw new D(`The lists and strings hold more than ${this.limits.maxListItems} items in all, the limit. Is a loop building more than it needs?`,n)}call(e,n){if(e.callee.kind==="var"){let s=e.callee.name,i=n.get(s);if(!i.found){let o=n.fn(s);if(o)return this.callFunction(o,this.evalArgs(e.args,n,e.pos),n,s);let a=this.specialFunction(s,e,n);if(a.handled)return a.value;let l=Ct(mr,s);if(l){let u=this.evalArgs(e.args,n,e.pos);this.checkArgs(s,u);for(let p of Os(l,u.pos,u.named))this.warn(`${s}(): "${p}" is given by position and by name; the named value is used (${tn(e.pos,!1)})`);let c={maxLength:this.limits.maxListLength,step:p=>this.tick(e.pos,p),given:u.pos.length+l.params.filter(p=>u.named.has(p)).length},f=Fs(l,u.pos,u.named);this.tick(e.pos,Ds(s,f,this.limits.maxListLength));let h;try{h=l.run(f,c)}catch(p){if(p instanceof D)throw p;let d=new D(p instanceof RangeError?`${s}(): the result is too large`:p.message,e.pos);throw d.call=s,d}return this.checkValue(h,e.pos,s),h}throw new D(`Unknown function ${s}()${cs(ir(s,[...n.names("fns"),...n.names("vars"),...Object.keys(mr),...cf]))}`,e.pos)}if(!it(i.value))throw new D(`"${s}" is a ${Ne(i.value)}, not a function`,e.pos);return this.callFunction(i.value,this.evalArgs(e.args,n,e.pos),n,s)}let r=this.expr(e.callee,n);if(!it(r))throw new D(`Can't call a ${Ne(r)}`,e.pos);return this.callFunction(r,this.evalArgs(e.args,n,e.pos),n,"function")}specialFunction(e,n,r){if(e==="echo"){let s=this.evalArgs(n.args,r,n.pos);return this.echo(this.echoText(s),n.pos),{handled:!0,value:void 0}}if(e==="assert"){let s=this.evalArgs(n.args,r,n.pos);return this.checkArgs(e,s),this.assert(s),{handled:!0,value:!0}}if(e==="text_width"||e==="text_metrics"){let s=this.evalArgs(n.args,r,n.pos);this.checkArgs(e,s);let i=this.measure(s,r);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(n.args,r,n.pos);this.checkArgs(e,s);let i=this.num(this.arg(s,"length",0),"finger_count","length");return{handled:!0,value:zn(i,this.fingerWidth(s,r,1))}}return{handled:!1}}assert(e){if(Fe(this.arg(e,"condition",0)))return;let n=this.arg(e,"message",1);throw new D(`Assertion failed${n===void 0?"":": "+Ve(n)}`,e.at)}echo(e,n){this.charge(Math.ceil(e.length/qo),n),this.echoes.push(e)}echoText(e){let n=this.limits.maxListLength,r=[],s=0,i=(o,a,l)=>{r.length&&(s+=2);let u=Mt(a,n-s-o.length,l);if(s+=o.length+u.text.length,!u.whole)throw new D(`echo(): the text would be longer than the limit of ${n} characters`,e.at);r.push(o+u.text)};for(let{name:o,value:a}of e.all)o===null?i("",a,!1):i(`${o} = `,a,!0);return r.join(", ")}arith(e,n,r,s){if(typeof n=="number"&&typeof r=="number")switch(e){case"+":return n+r;case"-":return n-r;case"*":return n*r;case"/":return n/r;case"%":return n%r;case"^":return Math.pow(n,r)}if(e==="+"&&typeof n=="string"&&typeof r=="string")return this.checkSize(n.length+r.length,!0,s),n+r;if(Array.isArray(n)&&Array.isArray(r)){if(e==="+"||e==="-"){if(n.length!==r.length)throw new D(`Can't ${e==="+"?"add":"subtract"} lists of length ${n.length} and ${r.length}`,s);return this.charge(n.length+Ht,s),n.map((o,a)=>this.arith(e,o,r[a],s))}if(e==="*"){if(Array.isArray(n[0]))return this.charge(n.length+Ht,s),n.map(a=>this.arith("*",a,r,s));let o=(a,l)=>{let u=this.arith("*",a,l,s);if(typeof u!="number")throw new D("Can't multiply these lists: an item times an item is not a number",s);return u};if(Array.isArray(r[0])){let a=r[0].length;if(n.length!==r.length||r.some(l=>!Array.isArray(l)||l.length!==a))throw new D(`Can't multiply a list of length ${n.length} by a matrix: it needs ${n.length} rows of the same length`,s);return this.checkSize(a,!1,s),this.tick(s,a*n.length),Array.from({length:a},(l,u)=>n.reduce((c,f,h)=>c+o(f,r[h][u]),0))}if(n.length!==r.length)throw new D(`Can't multiply lists of length ${n.length} and ${r.length}`,s);return this.tick(s,n.length),n.reduce((a,l,u)=>a+o(l,r[u]),0)}}if(Array.isArray(n)&&typeof r=="number"&&(e==="*"||e==="/"))return this.charge(n.length+Ht,s),n.map(o=>this.arith(e,o,r,s));if(typeof n=="number"&&Array.isArray(r)&&e==="*")return this.charge(r.length+Ht,s),r.map(o=>this.arith(e,n,o,s));let i={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"take remainder of","^":"raise"};throw new D(`Can't ${i[e]??e} ${Ne(n)} and ${Ne(r)}`,s)}arg(e,n,r,s){return e.named.has(n)?e.named.get(n):r>=0&&r<e.pos.length?e.pos[r]:s}num(e,n,r){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${r} must be a finite number, got ${vt(e)}`);return e}vec2(e,n,r=!0){let s=i=>typeof i=="number"&&Number.isFinite(i);if(s(e)&&r)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(`${n} must be a number or [x, y], got ${vt(e)}`)}vec3(e,n){let r=s=>typeof s=="number"&&Number.isFinite(s);if(Array.isArray(e)&&(e.length===2||e.length===3)&&e.every(r))return[e[0],e[1],e[2]??0];throw new Error(`${n} must be [x, y, z], got ${vt(e)}`)}placements(e,n,r){let s=(a,l)=>a===void 0?[[0,0,0]]:Array.isArray(a)&&a.length>0&&Array.isArray(a[0])?a.map((u,c)=>this.vec3(u,`${l}[${c}]`)):[this.vec3(a,l)],i=s(e,"at"),o=s(n,"rotate");for(let[a,l]of[[i,"at"],[o,"rotate"]])if(a.length!==1&&a.length!==r)throw new Error(`${l} needs one placement per copy: qty is ${r} but ${l} has ${a.length}`);return Array.from({length:r},(a,l)=>({at:i[i.length===1?0:l],rotate:o[o.length===1?0:l]}))}points(e,n){if(!Array.isArray(e))throw new Error(`${n} must be a list of [x, y] points`);return e.map((r,s)=>{if(!Array.isArray(r)||!Number.isFinite(r[0])||!Number.isFinite(r[1]))throw new Error(`${n}[${s}] must be an [x, y] point, got ${vt(r)}`);return[r[0],r[1]]})}dyn(e,n){return e.get(n).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,n,r){(Array.isArray(e)||typeof e=="string")&&this.checkSize(e.length,typeof e=="string",n,r)}checkSize(e,n,r,s){if(e>this.limits.maxListLength)throw new D(`${s?`${s}(): `:""}${n?`a string of ${e} characters`:`a list of ${e} items`} is more than the limit of ${this.limits.maxListLength}`,r);this.charge(n?Math.ceil(e/qo):e+Ht,r)}segs(e){let n=Ee(this.dyn(e,"$fn"))||0,r=Ee(this.dyn(e,"$fa"))||2,s=Ee(this.dyn(e,"$fs"))||.2,i=this.limits.maxSegments;return o=>{let a=Js(o,n,r,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 n=this.dyn(e,"$thickness");if(typeof n!="number"||n<=0)throw new Error("$thickness must be a positive number");return n}fingerWidth(e,n,r){let s=this.arg(e,"finger",r);return typeof s=="number"&&s>0?s:Math.max(3*this.thickness(n),6)}measure(e,n){if(!this.opts.fonts)throw new D("text needs a font. Pass fonts to render(), or --font on the command line.",e.at);let r=Mt(this.arg(e,"text",0,""),this.limits.maxTextLength);if(!r.whole)throw new D(`the text is more than ${this.limits.maxTextLength} characters, the limit for one text()`,e.at);this.tick(e.at,r.text.length);try{return Xo(this.opts.fonts,r.text,this.textOpts(e,n))}catch(s){throw s instanceof D?s:new D(s.message,e.at)}}textOpts(e,n){return{size:this.num(this.arg(e,"size",1,10),"text","size"),font:Ve(this.arg(e,"font",2,this.dyn(n,"$font")??"")),halign:Ve(this.arg(e,"halign",-1,"left")),valign:Ve(this.arg(e,"valign",-1,"baseline")),spacing:Ee(this.arg(e,"spacing",-1,1))}}edges(e){let n=r=>{if(r==="out"||r==="in"||r==="flat")return r;throw new Error(`edges must be "out", "in" or "flat", got ${vt(r)}`)};if(typeof e=="string")return[n(e),n(e),n(e),n(e)];if(Array.isArray(e)&&e.length===4)return e.map(n);throw new Error("edges must be one value or a list of 4: [bottom, right, top, left]")}makeBuiltins(){let e=(i,o)=>Un(i.children(),o),n=i=>o=>Nn(o.children(),i);return{rect:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0,1),"size"),l=Ee(this.arg(i.args,"r",-1,0))||0,u=Fe(this.arg(i.args,"center",1,!1)),c=Qs(o,a,l,this.segs(i.env));return Ge(be([u?c.map(([f,h])=>[f-o/2,h-a/2]):c]))},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 Ge([Gn(a,a,this.segs(i.env)(a))])},ellipse:i=>{let[o,a]=this.vec2(this.arg(i.args,"r",0,1),"r");return Ge([Gn(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 Ge([Gn(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"),l=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 u=[];for(let c=0;c<o*2;c++){let f=Math.PI/2+Math.PI*c/o,h=c%2?l:a;u.push([h*Math.cos(f),h*Math.sin(f)])}return Ge(be([u]))},polygon:i=>{let o=this.points(this.arg(i.args,"points",0),"points"),a=this.arg(i.args,"paths",1),l=Array.isArray(a)?a.map(u=>(Array.isArray(u)?u:[]).map(c=>o[Ee(c)]).filter(Boolean)):[o];return Ge(be(l,"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=Vn(oi(o),.01),l=this.arg(i.args,"fill",-1,"evenodd")==="nonzero"?"nonzero":"evenodd";return Qt([Ge(be(a.closed,l)),Ft(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 Ft([[o,a]])},polyline:i=>{let o=this.points(this.arg(i.args,"points",0),"points"),a=Fe(this.arg(i.args,"closed",1,!1));return Ft([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"),l=this.num(this.arg(i.args,"end",2,90),"arc","end"),u=Math.max(2,Math.ceil(this.segs(i.env)(o)*Math.abs(l-a)/360));if(!(u<=this.limits.maxSegments))throw new Error(`an arc with ${u} segments is more than the limit of ${this.limits.maxSegments}`);let c=[];for(let f=0;f<=u;f++){let h=(a+(l-a)*f/u)*Math.PI/180;c.push([o*Math.cos(h),o*Math.sin(h)])}return Ft([c])},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=Mt(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),Ge($o(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),l=(Array.isArray(o)?Ee(o[2]??0):this.num(o,"rotate","a"))*Math.PI/180,u=Math.cos(l),c=Math.sin(l),f=this.arg(i.args,"center",-1),h=[u,c,-c,u,0,0];if(f!==void 0){let[p,d]=this.vec2(f,"center",!1);h=[u,c,-c,u,p-u*p+c*d,d-c*p-u*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),l=Math.hypot(o,a)||1,u=o/l,c=a/l;return e(i,[1-2*u*u,-2*u*c,-2*u*c,1-2*c*c,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],l=o[1];return e(i,[a[0],l[0],a[1],l[1],a[2]??0,l[2]??0])},union:i=>i.children(),group:i=>i.children(),difference:i=>{let[o,...a]=i.childList();if(!o)return St();let l=r(a,"difference");return s(o,u=>({regions:Fn(u.regions,l.regions),lines:Jt(u.lines,be(l.regions),"outside")}))},intersection:i=>{let[o,...a]=i.childList();if(!o)return St();let l=o;for(let u of a){let c=be(r([u],"intersection").regions);l=s(l,f=>({regions:Dn(f.regions,c),lines:Jt(f.lines,c,"inside")}))}return l},hull:i=>{let o=i.children(),a=l=>{let u=[],c="cut",f=!0;for(let[p,d]of l){f&&(d.regions.length||d.lines.length)&&(c=p,f=!1);for(let g of[...d.regions,...d.lines])for(let y of g)u.push(y)}let h=Ks(u);return new Map([[c,{regions:h.length>=3?[h]:[],lines:[]}]])};return{layers:a(o.layers),parts:o.parts.map(l=>({...l,layers:a(l.layers)}))}},offset:i=>{let o=this.arg(i.args,"r",0),a=this.arg(i.args,"delta",-1),l=Fe(this.arg(i.args,"chamfer",-1,!1)),u=o!==void 0?this.num(o,"offset","r"):this.num(a??0,"offset","delta"),c=o!==void 0?"round":l?"square":"miter";return s(i.children(),f=>({regions:Rn(f.regions,u,c),lines:f.lines}))},stroke:i=>{let o=this.num(this.arg(i.args,"width",0,1),"stroke","width");return s(i.children(),a=>({regions:be([...a.regions,...js(a.lines,o)]),lines:[]}))},outline:i=>s(i.children(),o=>({regions:[],lines:[...o.lines,...be(o.regions).map(a=>[...a,a[0]])]})),cut:n("cut"),score:n("score"),engrave:n("engrave"),guide:n("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),l=this.arg(i.args,"color",2),u=this.layers.get(o);if(a!==void 0||l!==void 0||!u){let c=a??u?.mode??"line";if(!["cut","line","fill","guide"].includes(c))throw new Error('mode must be "cut", "line", "fill" or "guide"');let f=Ve(l??u?.color??"#00aa00");if(!/^#[0-9a-fA-F]{6}$/.test(f))throw new Error('color must look like "#00aa00"');this.layers.set(o,{name:o,mode:c,color:f})}return Nn(i.children(),o)},part:i=>{let o=Ve(this.arg(i.args,"name",0,"part")),a=Math.max(1,Math.floor(Ee(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 l=this.arg(i.args,"at",-1),u=this.arg(i.args,"rotate",-1),c=l===void 0&&u===void 0?void 0:this.placements(l,u,a),f=i.children();return{layers:new Map,parts:[...f.parts,{name:o,qty:a,layers:f.layers,thickness:this.thickness(i.env),kerf:Ee(this.dyn(i.env,"$kerf"))||0,material:Ve(this.dyn(i.env,"$material")??"material"),...c?{placements:c}:{}}]}},material:i=>{let o=this.arg(i.args,"thickness",0),a=this.arg(i.args,"kerf",1),l=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")),l!==void 0&&i.env.vars.set("$material",Ve(l)),i.children()},children:i=>{let o=i.env.childCtx();if(!o)return St();let a=this.childStmts(o.stmts),l=this.arg(i.args,"index",0),u=new we(o.env,i.env);this.hoist(o.stmts,u);let c=new Set;if(l===void 0)a.forEach(h=>c.add(h));else for(let h of this.iterable(l,i.args.at))a[Ee(h)]&&c.add(a[Ee(h)]);let f=[];for(let h of o.stmts)if(h.kind==="assign")this.stmt(h,u);else if(c.has(h)){let p=this.stmt(h,u);p&&f.push(p)}return Qt(f)},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"),l=this.edges(this.arg(i.args,"edges",1,"out")),u=this.thickness(i.env),c=this.fingerWidth(i.args,i.env,2);return this.spend(2*(Math.abs(o)+Math.abs(a))/c*4),Ge(ei(o,a,l,u,c))},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 l=this.fingerWidth(i.args,i.env,2);return this.spend(Math.abs(o)/l*4),Ge(ti(o,a,this.thickness(i.env),l))},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"),[l,u]=this.vec2(this.arg(i.args,"nut",2,[o*1.85,o*.8]),"nut",!1),c=this.num(this.arg(i.args,"nut_at",3,a/2),"tslot","nut_at");return Ge(be(ni(o,a,l,u,c)))},living_hinge:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0),"size"),l=this.num(this.arg(i.args,"spacing",1,1.5),"living_hinge","spacing"),u=this.num(this.arg(i.args,"bridge",2,3),"living_hinge","bridge"),c=this.num(this.arg(i.args,"cut",3,Math.max(u*2,(a-3*u)/2)),"living_hinge","cut");if(l<=0||u<=0||c<=0)throw new Error("spacing, bridge and cut must be positive");return this.spend((Math.abs(o)/l+1)*(Math.abs(a)/(c+u)+2)*2),Ft(ri(o,a,l,u,c))}};function r(i,o){let a={regions:[],lines:[]};for(let l of i){if(l.parts.length)throw new Error(`part() can only be the first child of ${o}()`);for(let u of l.layers.values())for(let c of u.regions)a.regions.push(c)}return a}function s(i,o){let a=l=>{let u=new Map;for(let[c,f]of l)u.set(c,o(f));return u};return{layers:a(i.layers),parts:i.parts.map(l=>({...l,layers:a(l.layers)}))}}}};var Vt=t=>{let e=Math.round(t*1e3)/1e3;return Object.is(e,-0)?"0":String(e)},hs=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,""");function fs(t,e){let n=[];for(let[r,s]of t){let i=[Vt(r),Vt(s)],o=n[n.length-1];(!o||o[0]!==i[0]||o[1]!==i[1])&&n.push(i)}for(;e&&n.length>1&&n[0][0]===n[n.length-1][0]&&n[0][1]===n[n.length-1][1];)n.pop();return n}var $t=(t,e)=>`M${fs(t,e).map(([n,r])=>`${n} ${r}`).join("L")}${e?"Z":""}`;function ps(t,e){let n=[];for(let r of e){let s=[],i=[],o=[];for(let a of t){let l=a.layers.get(r.name);if(l){for(let u of l.lines)s.push($t(u,!1));for(let u of l.regions)(lt(u)<0?i:o).push($t(u,!0))}}(s.length||i.length||o.length)&&n.push({name:r.name,mode:r.mode,color:r.color,d:[...s,...i,...o].join(""),regions:[...i,...o].join(""),lines:s.join("")})}return n}function ds(t,e,n,r){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="${Vt(e)}mm" height="${Vt(n)}mm" viewBox="0 0 ${Vt(e)} ${Vt(n)}">`];for(let i of r){let o=[],a=[];for(let u of t){let c=u.layers.get(i.name);if(!c)continue;let f=` data-part="${hs(u.part)}"`;if(i.mode==="fill"){c.regions.length&&a.push(`<path${f} d="${c.regions.map(h=>$t(h,!0)).join("")}"/>`);for(let h of c.lines)a.push(`<path${f} fill="none" stroke="${i.color}" stroke-width="0.1" d="${$t(h,!1)}"/>`);continue}for(let h of c.lines)o.push(`<path${f} d="${$t(h,!1)}"/>`);for(let h of c.regions)(lt(h)<0?o:a).push(`<path${f} d="${$t(h,!0)}"/>`)}if(!o.length&&!a.length)continue;let l=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="${hs(i.name)}" inkscape:groupmode="layer" inkscape:label="${hs(i.name)}" data-mode="${i.mode}" ${l}>`,...o,...a,"</g>")}return s.push("</svg>",""),s.join(`
|
|
379
|
-
`)}var
|
|
378
|
+
`};function $r(t,e=.02){let n=[],r=[],s=[],i=[0,0],o=[0,0],a=u=>{s.length>=2&&(u?n:r).push(s),s=[]},l=u=>Math.max(2,Math.min(256,Math.ceil(Math.sqrt(u/e))));for(let u of t)if(u.type==="M")a(!1),i=o=[u.x,u.y],s=[o];else if(u.type==="L")o=[u.x,u.y],s.push(o);else if(u.type==="Q"){let[c,f]=o,h=l(Math.hypot(u.x1-c,u.y1-f)+Math.hypot(u.x-u.x1,u.y-u.y1));for(let p=1;p<=h;p++){let d=p/h,g=1-d;s.push([g*g*c+2*g*d*u.x1+d*d*u.x,g*g*f+2*g*d*u.y1+d*d*u.y])}o=[u.x,u.y]}else if(u.type==="C"){let[c,f]=o,h=l(Math.hypot(u.x1-c,u.y1-f)+Math.hypot(u.x2-u.x1,u.y2-u.y1)+Math.hypot(u.x-u.x2,u.y-u.y2));for(let p=1;p<=h;p++){let d=p/h,g=1-d;s.push([g*g*g*c+3*g*g*d*u.x1+3*g*d*d*u.x2+d*d*d*u.x,g*g*g*f+3*g*g*d*u.y1+3*g*d*d*u.y2+d*d*d*u.y])}o=[u.x,u.y]}else a(!0),o=i,s=[i];return a(!1),{closed:n,open:r}}function Gr(t,e=Math.PI/2,n){let r=T=>/^[a-zA-Z]$/.test(T),s=t.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g)??[],i=[],o=0,a="",l=0,u=0,c=0,f=0,h=0,p=0,d=0,g=0,m="",x=()=>{let T=s[o++];if(T===void 0||r(T))throw new Error(`Bad path data near "${T??"end"}"`);return Number(T)},w=()=>{let T=s[o];if(T===void 0)throw new Error("Bad path data: missing arc flag");return T.length>1&&(T[0]==="0"||T[0]==="1")&&!T.includes(".")?(s[o]=T.slice(1),Number(T[0])):(o++,Number(T))};try{v()}catch(T){if(!n)throw T;n(T.message)}return i;function v(){for(;o<s.length;){if(r(s[o]))a=s[o++];else if(a){if(a==="Z"||a==="z")throw new Error(`Bad path data near "${s[o]}": Z takes no numbers`)}else throw new Error("Path data must start with a command");let T=a===a.toLowerCase(),P=a.toUpperCase(),O=T?l:0,C=T?u:0;if(P==="M")l=O+x(),u=C+x(),c=l,f=u,i.push({type:"M",x:l,y:u}),a=T?"l":"L";else if(P==="L")l=O+x(),u=C+x(),i.push({type:"L",x:l,y:u});else if(P==="H")l=O+x(),i.push({type:"L",x:l,y:u});else if(P==="V")u=C+x(),i.push({type:"L",x:l,y:u});else if(P==="C"||P==="S"){let L,B;if(P==="C")L=O+x(),B=C+x();else{let te=m==="C"||m==="S";L=te?2*l-h:l,B=te?2*u-p:u}let A=O+x(),F=C+x();l=O+x(),u=C+x(),h=A,p=F,i.push({type:"C",x1:L,y1:B,x2:A,y2:F,x:l,y:u})}else if(P==="Q"||P==="T"){let L,B;if(P==="Q")L=O+x(),B=C+x();else{let A=m==="Q"||m==="T";L=A?2*l-d:l,B=A?2*u-g:u}l=O+x(),u=C+x(),d=L,g=B,i.push({type:"Q",x1:L,y1:B,x:l,y:u})}else if(P==="A"){let L=x(),B=x(),A=x(),F=w(),te=w(),V=O+x(),q=C+x();i.push(...vu(l,u,L,B,A,F,te,V,q,e)),l=V,u=q}else if(P==="Z")i.push({type:"Z"}),l=c,u=f;else throw new Error(`Unknown path command "${a}"`);m=P}}}function vu(t,e,n,r,s,i,o,a,l,u=Math.PI/2){if(n===0||r===0||t===a&&e===l)return[{type:"L",x:a,y:l}];n=Math.abs(n),r=Math.abs(r);let c=s*Math.PI/180,f=Math.cos(c),h=Math.sin(c),p=(t-a)/2,d=(e-l)/2,g=f*p+h*d,m=-h*p+f*d,x=g*g/(n*n)+m*m/(r*r);x>1&&(n*=Math.sqrt(x),r*=Math.sqrt(x));let w=n*n*r*r-n*n*m*m-r*r*g*g,v=n*n*m*m+r*r*g*g,T=Math.sqrt(Math.max(0,w/v));i===o&&(T=-T);let P=T*n*m/r,O=-T*r*g/n,C=f*P-h*O+(t+a)/2,L=h*P+f*O+(e+l)/2,B=(U,ae,de,me)=>Math.atan2(U*me-ae*de,U*de+ae*me),A=B(1,0,(g-P)/n,(m-O)/r),F=B((g-P)/n,(m-O)/r,(-g-P)/n,(-m-O)/r);!o&&F>0&&(F-=2*Math.PI),o&&F<0&&(F+=2*Math.PI);let te=Math.ceil(Math.abs(F)/u),V=[],q=U=>[C+n*Math.cos(U)*f-r*Math.sin(U)*h,L+n*Math.cos(U)*h+r*Math.sin(U)*f],re=U=>[-n*Math.sin(U)*f-r*Math.cos(U)*h,-n*Math.sin(U)*h+r*Math.cos(U)*f];for(let U=0;U<te;U++){let ae=A+F*U/te,de=A+F*(U+1)/te,me=4/3*Math.tan((de-ae)/4),we=q(ae),E=q(de),S=re(ae),D=re(de);V.push({type:"C",x1:we[0]+me*S[0],y1:we[1]+me*S[1],x2:E[0]-me*D[0],y2:E[1]-me*D[1],x:E[0],y:E[1]})}return V}String.prototype.codePointAt||(function(){var t=(function(){try{var n={},r=Object.defineProperty,s=r(n,n,n)&&r}catch{}return s})(),e=function(n){if(this==null)throw TypeError();var r=String(this),s=r.length,i=n?Number(n):0;if(i!=i&&(i=0),!(i<0||i>=s)){var o=r.charCodeAt(i),a;return o>=55296&&o<=56319&&s>i+1&&(a=r.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 si=0,oa=-3;function sr(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function bu(t,e){this.source=t,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new sr,this.dtree=new sr}var aa=new sr,la=new sr,ii=new Uint8Array(30),oi=new Uint16Array(30),ua=new Uint8Array(30),ca=new Uint16Array(30),wu=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),wo=new sr,It=new Uint8Array(320);function fa(t,e,n,r){var s,i;for(s=0;s<n;++s)t[s]=0;for(s=0;s<30-n;++s)t[s+n]=s/n|0;for(i=r,s=0;s<30;++s)e[s]=i,i+=1<<t[s]}function Su(t,e){var n;for(n=0;n<7;++n)t.table[n]=0;for(t.table[7]=24,t.table[8]=152,t.table[9]=112,n=0;n<24;++n)t.trans[n]=256+n;for(n=0;n<144;++n)t.trans[24+n]=n;for(n=0;n<8;++n)t.trans[168+n]=280+n;for(n=0;n<112;++n)t.trans[176+n]=144+n;for(n=0;n<5;++n)e.table[n]=0;for(e.table[5]=32,n=0;n<32;++n)e.trans[n]=n}var So=new Uint16Array(16);function Gs(t,e,n,r){var s,i;for(s=0;s<16;++s)t.table[s]=0;for(s=0;s<r;++s)t.table[e[n+s]]++;for(t.table[0]=0,i=0,s=0;s<16;++s)So[s]=i,i+=t.table[s];for(s=0;s<r;++s)e[n+s]&&(t.trans[So[e[n+s]]++]=s)}function ku(t){t.bitcount--||(t.tag=t.source[t.sourceIndex++],t.bitcount=7);var e=t.tag&1;return t.tag>>>=1,e}function Ct(t,e,n){if(!e)return n;for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var r=t.tag&65535>>>16-e;return t.tag>>>=e,t.bitcount-=e,r+n}function Zs(t,e){for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var n=0,r=0,s=0,i=t.tag;do r=2*r+(i&1),i>>>=1,++s,n+=e.table[s],r-=e.table[s];while(r>=0);return t.tag=i,t.bitcount-=s,e.trans[n+r]}function Pu(t,e,n){var r,s,i,o,a,l;for(r=Ct(t,5,257),s=Ct(t,5,1),i=Ct(t,4,4),o=0;o<19;++o)It[o]=0;for(o=0;o<i;++o){var u=Ct(t,3,0);It[wu[o]]=u}for(Gs(wo,It,0,19),a=0;a<r+s;){var c=Zs(t,wo);switch(c){case 16:var f=It[a-1];for(l=Ct(t,2,3);l;--l)It[a++]=f;break;case 17:for(l=Ct(t,3,3);l;--l)It[a++]=0;break;case 18:for(l=Ct(t,7,11);l;--l)It[a++]=0;break;default:It[a++]=c;break}}Gs(e,It,0,r),Gs(n,It,r,s)}function ko(t,e,n){for(;;){var r=Zs(t,e);if(r===256)return si;if(r<256)t.dest[t.destLen++]=r;else{var s,i,o,a;for(r-=257,s=Ct(t,ii[r],oi[r]),i=Zs(t,n),o=t.destLen-Ct(t,ua[i],ca[i]),a=o;a<o+s;++a)t.dest[t.destLen++]=t.dest[a]}}}function Mu(t){for(var e,n,r;t.bitcount>8;)t.sourceIndex--,t.bitcount-=8;if(e=t.source[t.sourceIndex+1],e=256*e+t.source[t.sourceIndex],n=t.source[t.sourceIndex+3],n=256*n+t.source[t.sourceIndex+2],e!==(~n&65535))return oa;for(t.sourceIndex+=4,r=e;r;--r)t.dest[t.destLen++]=t.source[t.sourceIndex++];return t.bitcount=0,si}function Eu(t,e){var n=new bu(t,e),r,s,i;do{switch(r=ku(n),s=Ct(n,2,0),s){case 0:i=Mu(n);break;case 1:i=ko(n,aa,la);break;case 2:Pu(n,n.ltree,n.dtree),i=ko(n,n.ltree,n.dtree);break;default:i=oa}if(i!==si)throw new Error("Data error")}while(!r);return n.destLen<n.dest.length?typeof n.dest.slice=="function"?n.dest.slice(0,n.destLen):n.dest.subarray(0,n.destLen):n.dest}Su(aa,la);fa(ii,oi,4,3);fa(ua,ca,2,1);ii[28]=0;oi[28]=258;var Lu=Eu;function Pn(t,e,n,r,s){return Math.pow(1-s,3)*t+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*n+Math.pow(s,3)*r}function jt(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}jt.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)};jt.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))};jt.prototype.addX=function(t){this.addPoint(t,null)};jt.prototype.addY=function(t){this.addPoint(null,t)};jt.prototype.addBezier=function(t,e,n,r,s,i,o,a){var l=[t,e],u=[n,r],c=[s,i],f=[o,a];this.addPoint(t,e),this.addPoint(o,a);for(var h=0;h<=1;h++){var p=6*l[h]-12*u[h]+6*c[h],d=-3*l[h]+9*u[h]-9*c[h]+3*f[h],g=3*u[h]-3*l[h];if(d===0){if(p===0)continue;var m=-g/p;0<m&&m<1&&(h===0&&this.addX(Pn(l[h],u[h],c[h],f[h],m)),h===1&&this.addY(Pn(l[h],u[h],c[h],f[h],m)));continue}var x=Math.pow(p,2)-4*g*d;if(!(x<0)){var w=(-p+Math.sqrt(x))/(2*d);0<w&&w<1&&(h===0&&this.addX(Pn(l[h],u[h],c[h],f[h],w)),h===1&&this.addY(Pn(l[h],u[h],c[h],f[h],w)));var v=(-p-Math.sqrt(x))/(2*d);0<v&&v<1&&(h===0&&this.addX(Pn(l[h],u[h],c[h],f[h],v)),h===1&&this.addY(Pn(l[h],u[h],c[h],f[h],v)))}}};jt.prototype.addQuad=function(t,e,n,r,s,i){var o=t+.6666666666666666*(n-t),a=e+2/3*(r-e),l=o+1/3*(s-t),u=a+1/3*(i-e);this.addBezier(t,e,o,a,l,u,s,i)};function ze(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}ze.prototype.moveTo=function(t,e){this.commands.push({type:"M",x:t,y:e})};ze.prototype.lineTo=function(t,e){this.commands.push({type:"L",x:t,y:e})};ze.prototype.curveTo=ze.prototype.bezierCurveTo=function(t,e,n,r,s,i){this.commands.push({type:"C",x1:t,y1:e,x2:n,y2:r,x:s,y:i})};ze.prototype.quadTo=ze.prototype.quadraticCurveTo=function(t,e,n,r){this.commands.push({type:"Q",x1:t,y1:e,x:n,y:r})};ze.prototype.close=ze.prototype.closePath=function(){this.commands.push({type:"Z"})};ze.prototype.extend=function(t){if(t.commands)t=t.commands;else if(t instanceof jt){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)};ze.prototype.getBoundingBox=function(){for(var t=new jt,e=0,n=0,r=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=r=o.x,n=s=o.y;break;case"L":t.addPoint(o.x,o.y),r=o.x,s=o.y;break;case"Q":t.addQuad(r,s,o.x1,o.y1,o.x,o.y),r=o.x,s=o.y;break;case"C":t.addBezier(r,s,o.x1,o.y1,o.x2,o.y2,o.x,o.y),r=o.x,s=o.y;break;case"Z":r=e,s=n;break;default:throw new Error("Unexpected path command "+o.type)}}return t.isEmpty()&&t.addPoint(0,0),t};ze.prototype.draw=function(t){t.beginPath();for(var e=0;e<this.commands.length;e+=1){var n=this.commands[e];n.type==="M"?t.moveTo(n.x,n.y):n.type==="L"?t.lineTo(n.x,n.y):n.type==="C"?t.bezierCurveTo(n.x1,n.y1,n.x2,n.y2,n.x,n.y):n.type==="Q"?t.quadraticCurveTo(n.x1,n.y1,n.x,n.y):n.type==="Z"&&t.closePath()}this.fill&&(t.fillStyle=this.fill,t.fill()),this.stroke&&(t.strokeStyle=this.stroke,t.lineWidth=this.strokeWidth,t.stroke())};ze.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 n(){for(var o=arguments,a="",l=0;l<arguments.length;l+=1){var u=o[l];u>=0&&l>0&&(a+=" "),a+=e(u)}return a}for(var r="",s=0;s<this.commands.length;s+=1){var i=this.commands[s];i.type==="M"?r+="M"+n(i.x,i.y):i.type==="L"?r+="L"+n(i.x,i.y):i.type==="C"?r+="C"+n(i.x1,i.y1,i.x2,i.y2,i.x,i.y):i.type==="Q"?r+="Q"+n(i.x1,i.y1,i.x,i.y):i.type==="Z"&&(r+="Z")}return r};ze.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};ze.prototype.toDOMElement=function(t){var e=this.toPathData(t),n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",e),n};function ha(t){throw new Error(t)}function Po(t,e){t||ha(e)}var ue={fail:ha,argument:Po,assert:Po},Mo=32768,Eo=2147483648,En={},X={},fe={};function bt(t){return function(){return t}}X.BYTE=function(t){return ue.argument(t>=0&&t<=255,"Byte value should be between 0 and 255."),[t]};fe.BYTE=bt(1);X.CHAR=function(t){return[t.charCodeAt(0)]};fe.CHAR=bt(1);X.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=[],n=0;n<t.length;n+=1)e[n]=t.charCodeAt(n);return e};fe.CHARARRAY=function(t){return typeof t>"u"?0:t.length};X.USHORT=function(t){return[t>>8&255,t&255]};fe.USHORT=bt(2);X.SHORT=function(t){return t>=Mo&&(t=-(2*Mo-t)),[t>>8&255,t&255]};fe.SHORT=bt(2);X.UINT24=function(t){return[t>>16&255,t>>8&255,t&255]};fe.UINT24=bt(3);X.ULONG=function(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]};fe.ULONG=bt(4);X.LONG=function(t){return t>=Eo&&(t=-(2*Eo-t)),[t>>24&255,t>>16&255,t>>8&255,t&255]};fe.LONG=bt(4);X.FIXED=X.ULONG;fe.FIXED=fe.ULONG;X.FWORD=X.SHORT;fe.FWORD=fe.SHORT;X.UFWORD=X.USHORT;fe.UFWORD=fe.USHORT;X.LONGDATETIME=function(t){return[0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255]};fe.LONGDATETIME=bt(8);X.TAG=function(t){return ue.argument(t.length===4,"Tag should be exactly 4 ASCII characters."),[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]};fe.TAG=bt(4);X.Card8=X.BYTE;fe.Card8=fe.BYTE;X.Card16=X.USHORT;fe.Card16=fe.USHORT;X.OffSize=X.BYTE;fe.OffSize=fe.BYTE;X.SID=X.USHORT;fe.SID=fe.USHORT;X.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?X.NUMBER16(t):X.NUMBER32(t)};fe.NUMBER=function(t){return X.NUMBER(t).length};X.NUMBER16=function(t){return[28,t>>8&255,t&255]};fe.NUMBER16=bt(3);X.NUMBER32=function(t){return[29,t>>24&255,t>>16&255,t>>8&255,t&255]};fe.NUMBER32=bt(5);X.REAL=function(t){var e=t.toString(),n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(n){var r=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));e=(Math.round(t*r)/r).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 l=[30],u=0,c=s.length;u<c;u+=2)l.push(parseInt(s.substr(u,2),16));return l};fe.REAL=function(t){return X.REAL(t).length};X.NAME=X.CHARARRAY;fe.NAME=fe.CHARARRAY;X.STRING=X.CHARARRAY;fe.STRING=fe.CHARARRAY;En.UTF8=function(t,e,n){for(var r=[],s=n,i=0;i<s;i++,e+=1)r[i]=t.getUint8(e);return String.fromCharCode.apply(null,r)};En.UTF16=function(t,e,n){for(var r=[],s=n/2,i=0;i<s;i++,e+=2)r[i]=t.getUint16(e);return String.fromCharCode.apply(null,r)};X.UTF16=function(t){for(var e=[],n=0;n<t.length;n+=1){var r=t.charCodeAt(n);e[e.length]=r>>8&255,e[e.length]=r&255}return e};fe.UTF16=function(t){return t.length*2};var Ys={"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"};En.MACSTRING=function(t,e,n,r){var s=Ys[r];if(s!==void 0){for(var i="",o=0;o<n;o++){var a=t.getUint8(e+o);a<=127?i+=String.fromCharCode(a):i+=s[a&127]}return i}};var zr=typeof WeakMap=="function"&&new WeakMap,Hr,Tu=function(t){if(!Hr){Hr={};for(var e in Ys)Hr[e]=new String(e)}var n=Hr[t];if(n!==void 0){if(zr){var r=zr.get(n);if(r!==void 0)return r}var s=Ys[t];if(s!==void 0){for(var i={},o=0;o<s.length;o++)i[s.charCodeAt(o)]=o+128;return zr&&zr.set(n,i),i}}};X.MACSTRING=function(t,e){var n=Tu(e);if(n!==void 0){for(var r=[],s=0;s<t.length;s++){var i=t.charCodeAt(s);if(i>=128&&(i=n[i],i===void 0))return;r[s]=i}return r}};fe.MACSTRING=function(t,e){var n=X.MACSTRING(t,e);return n!==void 0?n.length:0};function Ks(t){return t>=-128&&t<=127}function Iu(t,e,n){for(var r=0,s=t.length;e<s&&r<64&&t[e]===0;)++e,++r;return n.push(128|r-1),e}function Cu(t,e,n){for(var r=0,s=t.length,i=e;i<s&&r<64;){var o=t[i];if(!Ks(o)||o===0&&i+1<s&&t[i+1]===0)break;++i,++r}n.push(r-1);for(var a=e;a<i;++a)n.push(t[a]+256&255);return i}function Au(t,e,n){for(var r=0,s=t.length,i=e;i<s&&r<64;){var o=t[i];if(o===0||Ks(o)&&i+1<s&&Ks(t[i+1]))break;++i,++r}n.push(64|r-1);for(var a=e;a<i;++a){var l=t[a];n.push(l+65536>>8&255,l+256&255)}return i}X.VARDELTAS=function(t){for(var e=0,n=[];e<t.length;){var r=t[e];r===0?e=Iu(t,e,n):r>=-128&&r<=127?e=Cu(t,e,n):e=Au(t,e,n)}return n};X.INDEX=function(t){for(var e=1,n=[e],r=[],s=0;s<t.length;s+=1){var i=X.OBJECT(t[s]);Array.prototype.push.apply(r,i),e+=i.length,n.push(e)}if(r.length===0)return[0,0];for(var o=[],a=1+Math.floor(Math.log(e)/Math.log(2))/8|0,l=[void 0,X.BYTE,X.USHORT,X.UINT24,X.ULONG][a],u=0;u<n.length;u+=1){var c=l(n[u]);Array.prototype.push.apply(o,c)}return Array.prototype.concat(X.Card16(t.length),X.OffSize(a),o,r)};fe.INDEX=function(t){return X.INDEX(t).length};X.DICT=function(t){for(var e=[],n=Object.keys(t),r=n.length,s=0;s<r;s+=1){var i=parseInt(n[s],0),o=t[i];e=e.concat(X.OPERAND(o.value,o.type)),e=e.concat(X.OPERATOR(i))}return e};fe.DICT=function(t){return X.DICT(t).length};X.OPERATOR=function(t){return t<1200?[t]:[12,t-1200]};X.OPERAND=function(t,e){var n=[];if(Array.isArray(e))for(var r=0;r<e.length;r+=1)ue.argument(t.length===e.length,"Not enough arguments given for type"+e),n=n.concat(X.OPERAND(t[r],e[r]));else if(e==="SID")n=n.concat(X.NUMBER(t));else if(e==="offset")n=n.concat(X.NUMBER32(t));else if(e==="number")n=n.concat(X.NUMBER(t));else if(e==="real")n=n.concat(X.REAL(t));else throw new Error("Unknown operand type "+e);return n};X.OP=X.BYTE;fe.OP=fe.BYTE;var Vr=typeof WeakMap=="function"&&new WeakMap;X.CHARSTRING=function(t){if(Vr){var e=Vr.get(t);if(e!==void 0)return e}for(var n=[],r=t.length,s=0;s<r;s+=1){var i=t[s];n=n.concat(X[i.type](i.value))}return Vr&&Vr.set(t,n),n};fe.CHARSTRING=function(t){return X.CHARSTRING(t).length};X.OBJECT=function(t){var e=X[t.type];return ue.argument(e!==void 0,"No encoding function for type "+t.type),e(t.value)};fe.OBJECT=function(t){var e=fe[t.type];return ue.argument(e!==void 0,"No sizeOf function for type "+t.type),e(t.value)};X.TABLE=function(t){for(var e=[],n=t.fields.length,r=[],s=[],i=0;i<n;i+=1){var o=t.fields[i],a=X[o.type];ue.argument(a!==void 0,"No encoding function for field type "+o.type+" ("+o.name+")");var l=t[o.name];l===void 0&&(l=o.value);var u=a(l);o.type==="TABLE"?(s.push(e.length),e=e.concat([0,0]),r.push(u)):e=e.concat(u)}for(var c=0;c<r.length;c+=1){var f=s[c],h=e.length;ue.argument(h<65536,"Table "+t.tableName+" too big."),e[f]=h>>8,e[f+1]=h&255,e=e.concat(r[c])}return e};fe.TABLE=function(t){for(var e=0,n=t.fields.length,r=0;r<n;r+=1){var s=t.fields[r],i=fe[s.type];ue.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};X.RECORD=X.TABLE;fe.RECORD=fe.TABLE;X.LITERAL=function(t){return t};fe.LITERAL=function(t){return t.length};function Ve(t,e,n){if(e.length&&(e[0].name!=="coverageFormat"||e[0].value===1))for(var r=0;r<e.length;r+=1){var s=e[r];this[s.name]=s.value}if(this.tableName=t,this.fields=e,n)for(var i=Object.keys(n),o=0;o<i.length;o+=1){var a=i[o],l=n[a];this[a]!==void 0&&(this[a]=l)}}Ve.prototype.encode=function(){return X.TABLE(this)};Ve.prototype.sizeOf=function(){return fe.TABLE(this)};function ir(t,e,n){n===void 0&&(n=e.length);var r=new Array(e.length+1);r[0]={name:t+"Count",type:"USHORT",value:n};for(var s=0;s<e.length;s++)r[s+1]={name:t+s,type:"USHORT",value:e[s]};return r}function Js(t,e,n){var r=e.length,s=new Array(r+1);s[0]={name:t+"Count",type:"USHORT",value:r};for(var i=0;i<r;i++)s[i+1]={name:t+i,type:"TABLE",value:n(e[i],i)};return s}function or(t,e,n){var r=e.length,s=[];s[0]={name:t+"Count",type:"USHORT",value:r};for(var i=0;i<r;i++)s=s.concat(n(e[i],i));return s}function jr(t){t.format===1?Ve.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(ir("glyph",t.glyphs))):t.format===2?Ve.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(or("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}]}))):ue.assert(!1,"Coverage format must be 1 or 2.")}jr.prototype=Object.create(Ve.prototype);jr.prototype.constructor=jr;function Zr(t){Ve.call(this,"scriptListTable",or("scriptRecord",t,function(e,n){var r=e.script,s=r.defaultLangSys;return ue.assert(!!s,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+n,type:"TAG",value:e.tag},{name:"script"+n,type:"TABLE",value:new Ve("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Ve("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(ir("featureIndex",s.featureIndexes)))}].concat(or("langSys",r.langSysRecords,function(i,o){var a=i.langSys;return[{name:"langSysTag"+o,type:"TAG",value:i.tag},{name:"langSys"+o,type:"TABLE",value:new Ve("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat(ir("featureIndex",a.featureIndexes)))}]})))}]}))}Zr.prototype=Object.create(Ve.prototype);Zr.prototype.constructor=Zr;function Yr(t){Ve.call(this,"featureListTable",or("featureRecord",t,function(e,n){var r=e.feature;return[{name:"featureTag"+n,type:"TAG",value:e.tag},{name:"feature"+n,type:"TABLE",value:new Ve("featureTable",[{name:"featureParams",type:"USHORT",value:r.featureParams}].concat(ir("lookupListIndex",r.lookupListIndexes)))}]}))}Yr.prototype=Object.create(Ve.prototype);Yr.prototype.constructor=Yr;function Kr(t,e){Ve.call(this,"lookupListTable",Js("lookup",t,function(n){var r=e[n.lookupType];return ue.assert(!!r,"Unable to write GSUB lookup type "+n.lookupType+" tables."),new Ve("lookupTable",[{name:"lookupType",type:"USHORT",value:n.lookupType},{name:"lookupFlag",type:"USHORT",value:n.lookupFlag}].concat(Js("subtable",n.subtables,r)))}))}Kr.prototype=Object.create(Ve.prototype);Kr.prototype.constructor=Kr;var Z={Table:Ve,Record:Ve,Coverage:jr,ScriptList:Zr,FeatureList:Yr,LookupList:Kr,ushortList:ir,tableList:Js,recordList:or};function Lo(t,e){return t.getUint8(e)}function Jr(t,e){return t.getUint16(e,!1)}function Ou(t,e){return t.getInt16(e,!1)}function ai(t,e){return t.getUint32(e,!1)}function pa(t,e){var n=t.getInt16(e,!1),r=t.getUint16(e+2,!1);return n+r/65535}function Fu(t,e){for(var n="",r=e;r<e+4;r+=1)n+=String.fromCharCode(t.getInt8(r));return n}function Du(t,e,n){for(var r=0,s=0;s<n;s+=1)r<<=8,r+=t.getUint8(e+s);return r}function Ru(t,e,n){for(var r=[],s=e;s<n;s+=1)r.push(t.getUint8(s));return r}function Uu(t){for(var e="",n=0;n<t.length;n+=1)e+=String.fromCharCode(t[n]);return e}var Nu={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function M(t,e){this.data=t,this.offset=e,this.relativeOffset=0}M.prototype.parseByte=function(){var t=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,t};M.prototype.parseChar=function(){var t=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,t};M.prototype.parseCard8=M.prototype.parseByte;M.prototype.parseUShort=function(){var t=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,t};M.prototype.parseCard16=M.prototype.parseUShort;M.prototype.parseSID=M.prototype.parseUShort;M.prototype.parseOffset16=M.prototype.parseUShort;M.prototype.parseShort=function(){var t=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,t};M.prototype.parseF2Dot14=function(){var t=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,t};M.prototype.parseULong=function(){var t=ai(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t};M.prototype.parseOffset32=M.prototype.parseULong;M.prototype.parseFixed=function(){var t=pa(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t};M.prototype.parseString=function(t){var e=this.data,n=this.offset+this.relativeOffset,r="";this.relativeOffset+=t;for(var s=0;s<t;s++)r+=String.fromCharCode(e.getUint8(n+s));return r};M.prototype.parseTag=function(){return this.parseString(4)};M.prototype.parseLongDateTime=function(){var t=ai(this.data,this.offset+this.relativeOffset+4);return t-=2082844800,this.relativeOffset+=8,t};M.prototype.parseVersion=function(t){var e=Jr(this.data,this.offset+this.relativeOffset),n=Jr(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,t===void 0&&(t=4096),e+n/t/10};M.prototype.skip=function(t,e){e===void 0&&(e=1),this.relativeOffset+=Nu[t]*e};M.prototype.parseULongList=function(t){t===void 0&&(t=this.parseULong());for(var e=new Array(t),n=this.data,r=this.offset+this.relativeOffset,s=0;s<t;s++)e[s]=n.getUint32(r),r+=4;return this.relativeOffset+=t*4,e};M.prototype.parseOffset16List=M.prototype.parseUShortList=function(t){t===void 0&&(t=this.parseUShort());for(var e=new Array(t),n=this.data,r=this.offset+this.relativeOffset,s=0;s<t;s++)e[s]=n.getUint16(r),r+=2;return this.relativeOffset+=t*2,e};M.prototype.parseShortList=function(t){for(var e=new Array(t),n=this.data,r=this.offset+this.relativeOffset,s=0;s<t;s++)e[s]=n.getInt16(r),r+=2;return this.relativeOffset+=t*2,e};M.prototype.parseByteList=function(t){for(var e=new Array(t),n=this.data,r=this.offset+this.relativeOffset,s=0;s<t;s++)e[s]=n.getUint8(r++);return this.relativeOffset+=t,e};M.prototype.parseList=function(t,e){e||(e=t,t=this.parseUShort());for(var n=new Array(t),r=0;r<t;r++)n[r]=e.call(this);return n};M.prototype.parseList32=function(t,e){e||(e=t,t=this.parseULong());for(var n=new Array(t),r=0;r<t;r++)n[r]=e.call(this);return n};M.prototype.parseRecordList=function(t,e){e||(e=t,t=this.parseUShort());for(var n=new Array(t),r=Object.keys(e),s=0;s<t;s++){for(var i={},o=0;o<r.length;o++){var a=r[o],l=e[a];i[a]=l.call(this)}n[s]=i}return n};M.prototype.parseRecordList32=function(t,e){e||(e=t,t=this.parseULong());for(var n=new Array(t),r=Object.keys(e),s=0;s<t;s++){for(var i={},o=0;o<r.length;o++){var a=r[o],l=e[a];i[a]=l.call(this)}n[s]=i}return n};M.prototype.parseStruct=function(t){if(typeof t=="function")return t.call(this);for(var e=Object.keys(t),n={},r=0;r<e.length;r++){var s=e[r],i=t[s];n[s]=i.call(this)}return n};M.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}};M.prototype.parseValueRecordList=function(){for(var t=this.parseUShort(),e=this.parseUShort(),n=new Array(e),r=0;r<e;r++)n[r]=this.parseValueRecord(t);return n};M.prototype.parsePointer=function(t){var e=this.parseOffset16();if(e>0)return new M(this.data,this.offset+e).parseStruct(t)};M.prototype.parsePointer32=function(t){var e=this.parseOffset32();if(e>0)return new M(this.data,this.offset+e).parseStruct(t)};M.prototype.parseListOfLists=function(t){for(var e=this.parseOffset16List(),n=e.length,r=this.relativeOffset,s=new Array(n),i=0;i<n;i++){var o=e[i];if(o===0){s[i]=void 0;continue}if(this.relativeOffset=o,t){for(var a=this.parseOffset16List(),l=new Array(a.length),u=0;u<a.length;u++)this.relativeOffset=o+a[u],l[u]=t.call(this);s[i]=l}else s[i]=this.parseUShortList()}return this.relativeOffset=r,s};M.prototype.parseCoverage=function(){var t=this.offset+this.relativeOffset,e=this.parseUShort(),n=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(n)};if(e===2){for(var r=new Array(n),s=0;s<n;s++)r[s]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:r}}throw new Error("0x"+t.toString(16)+": Coverage format must be 1 or 2.")};M.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:M.uShort,end:M.uShort,classId:M.uShort})};throw new Error("0x"+t.toString(16)+": ClassDef format must be 1 or 2.")};M.list=function(t,e){return function(){return this.parseList(t,e)}};M.list32=function(t,e){return function(){return this.parseList32(t,e)}};M.recordList=function(t,e){return function(){return this.parseRecordList(t,e)}};M.recordList32=function(t,e){return function(){return this.parseRecordList32(t,e)}};M.pointer=function(t){return function(){return this.parsePointer(t)}};M.pointer32=function(t){return function(){return this.parsePointer32(t)}};M.tag=M.prototype.parseTag;M.byte=M.prototype.parseByte;M.uShort=M.offset16=M.prototype.parseUShort;M.uShortList=M.prototype.parseUShortList;M.uLong=M.offset32=M.prototype.parseULong;M.uLongList=M.prototype.parseULongList;M.struct=M.prototype.parseStruct;M.coverage=M.prototype.parseCoverage;M.classDef=M.prototype.parseClassDef;var To={reserved:M.uShort,reqFeatureIndex:M.uShort,featureIndexes:M.uShortList};M.prototype.parseScriptList=function(){return this.parsePointer(M.recordList({tag:M.tag,script:M.pointer({defaultLangSys:M.pointer(To),langSysRecords:M.recordList({tag:M.tag,langSys:M.pointer(To)})})}))||[]};M.prototype.parseFeatureList=function(){return this.parsePointer(M.recordList({tag:M.tag,feature:M.pointer({featureParams:M.offset16,lookupListIndexes:M.uShortList})}))||[]};M.prototype.parseLookupList=function(t){return this.parsePointer(M.list(M.pointer(function(){var e=this.parseUShort();ue.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");var n=this.parseUShort(),r=n&16;return{lookupType:e,lookupFlag:n,subtables:this.parseList(M.pointer(t[e])),markFilteringSet:r?this.parseUShort():void 0}})))||[]};M.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){var t=this.parseUShort(),e=this.parseUShort();ue.argument(t===1&&e<1,"GPOS/GSUB feature variations table unknown.");var n=this.parseRecordList32({conditionSetOffset:M.offset32,featureTableSubstitutionOffset:M.offset32});return n})||[]};var ee={getByte:Lo,getCard8:Lo,getUShort:Jr,getCard16:Jr,getShort:Ou,getULong:ai,getFixed:pa,getTag:Fu,getOffset:Du,getBytes:Ru,bytesToString:Uu,Parser:M};function Bu(t,e){e.parseUShort(),t.length=e.parseULong(),t.language=e.parseULong();var n;t.groupCount=n=e.parseULong(),t.glyphIndexMap={};for(var r=0;r<n;r+=1)for(var s=e.parseULong(),i=e.parseULong(),o=e.parseULong(),a=s;a<=i;a+=1)t.glyphIndexMap[a]=o,o++}function $u(t,e,n,r,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 ee.Parser(n,r+s+14),a=new ee.Parser(n,r+s+16+i*2),l=new ee.Parser(n,r+s+16+i*4),u=new ee.Parser(n,r+s+16+i*6),c=r+s+16+i*8,f=0;f<i-1;f+=1)for(var h=void 0,p=o.parseUShort(),d=a.parseUShort(),g=l.parseShort(),m=u.parseUShort(),x=d;x<=p;x+=1)m!==0?(c=u.offset+u.relativeOffset-2,c+=m,c+=(x-d)*2,h=ee.getUShort(n,c),h!==0&&(h=h+g&65535)):h=x+g&65535,t.glyphIndexMap[x]=h}function Gu(t,e){var n={};n.version=ee.getUShort(t,e),ue.argument(n.version===0,"cmap table version should be 0."),n.numTables=ee.getUShort(t,e+2);for(var r=-1,s=n.numTables-1;s>=0;s-=1){var i=ee.getUShort(t,e+4+s*8),o=ee.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)){r=ee.getULong(t,e+4+s*8+4);break}}if(r===-1)throw new Error("No valid cmap sub-tables found.");var a=new ee.Parser(t,e+r);if(n.format=a.parseUShort(),n.format===12)Bu(n,a);else if(n.format===4)$u(n,a,t,e,r);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+n.format+").");return n}function zu(t,e,n){t.segments.push({end:e,start:e,delta:-(e-n),offset:0,glyphIndex:n})}function Hu(t){t.segments.push({end:65535,start:65535,delta:1,offset:0})}function Vu(t){var e=!0,n;for(n=t.length-1;n>0;n-=1){var r=t.get(n);if(r.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 Z.Table("cmap",s);for(i.segments=[],n=0;n<t.length;n+=1){for(var o=t.get(n),a=0;a<o.unicodes.length;a+=1)zu(i,o.unicodes[a],n);i.segments=i.segments.sort(function(w,v){return w.start-v.start})}Hu(i);var l=i.segments.length,u=0,c=[],f=[],h=[],p=[],d=[],g=[];for(n=0;n<l;n+=1){var m=i.segments[n];m.end<=65535&&m.start<=65535?(c=c.concat({name:"end_"+n,type:"USHORT",value:m.end}),f=f.concat({name:"start_"+n,type:"USHORT",value:m.start}),h=h.concat({name:"idDelta_"+n,type:"SHORT",value:m.delta}),p=p.concat({name:"idRangeOffset_"+n,type:"USHORT",value:m.offset}),m.glyphId!==void 0&&(d=d.concat({name:"glyph_"+n,type:"USHORT",value:m.glyphId}))):u+=1,!e&&m.glyphIndex!==void 0&&(g=g.concat({name:"cmap12Start_"+n,type:"ULONG",value:m.start}),g=g.concat({name:"cmap12End_"+n,type:"ULONG",value:m.end}),g=g.concat({name:"cmap12Glyph_"+n,type:"ULONG",value:m.glyphIndex}))}if(i.segCountX2=(l-u)*2,i.searchRange=Math.pow(2,Math.floor(Math.log(l-u)/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(c),i.fields.push({name:"reservedPad",type:"USHORT",value:0}),i.fields=i.fields.concat(f),i.fields=i.fields.concat(h),i.fields=i.fields.concat(p),i.fields=i.fields.concat(d),i.cmap4Length=14+c.length*2+2+f.length*2+h.length*2+p.length*2+d.length*2,!e){var x=16+g.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:x},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:g.length/3}]),i.fields=i.fields.concat(g)}return i}var da={parse:Gu,make:Vu},Wr=[".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"],Xu=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],qu=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],an=[".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 ga(t){this.font=t}ga.prototype.charToGlyphIndex=function(t){var e=t.codePointAt(0),n=this.font.glyphs;if(n){for(var r=0;r<n.length;r+=1)for(var s=n.get(r),i=0;i<s.unicodes.length;i+=1)if(s.unicodes[i]===e)return r}return null};function ma(t){this.cmap=t}ma.prototype.charToGlyphIndex=function(t){return this.cmap.glyphIndexMap[t.codePointAt(0)]||0};function Qr(t,e){this.encoding=t,this.charset=e}Qr.prototype.charToGlyphIndex=function(t){var e=t.codePointAt(0),n=this.encoding[e];return this.charset.indexOf(n)};function li(t){switch(t.version){case 1:this.names=an.slice();break;case 2:this.names=new Array(t.numberOfGlyphs);for(var e=0;e<t.numberOfGlyphs;e++)t.glyphNameIndex[e]<an.length?this.names[e]=an[t.glyphNameIndex[e]]:this.names[e]=t.names[t.glyphNameIndex[e]-an.length];break;case 2.5:this.names=new Array(t.numberOfGlyphs);for(var n=0;n<t.numberOfGlyphs;n++)this.names[n]=an[n+t.glyphNameIndex[n]];break;case 3:this.names=[];break;default:this.names=[];break}}li.prototype.nameToGlyphIndex=function(t){return this.names.indexOf(t)};li.prototype.glyphIndexToName=function(t){return this.names[t]};function Wu(t){for(var e,n=t.tables.cmap.glyphIndexMap,r=Object.keys(n),s=0;s<r.length;s+=1){var i=r[s],o=n[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 _u(t){t._IndexToUnicodeMap={};for(var e=t.tables.cmap.glyphIndexMap,n=Object.keys(e),r=0;r<n.length;r+=1){var s=n[r],i=e[s];t._IndexToUnicodeMap[i]===void 0?t._IndexToUnicodeMap[i]={unicodes:[parseInt(s)]}:t._IndexToUnicodeMap[i].unicodes.push(parseInt(s))}}function ju(t,e){e.lowMemory?_u(t):Wu(t)}function Zu(t,e,n,r,s){t.beginPath(),t.moveTo(e,n),t.lineTo(r,s),t.stroke()}var on={line:Zu};function Yu(t,e){var n=e||new ze;return{configurable:!0,get:function(){return typeof n=="function"&&(n=n()),n},set:function(r){n=r}}}function ct(t){this.bindConstructorValues(t)}ct.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",Yu(this,t.path))};ct.prototype.addUnicode=function(t){this.unicodes.length===0&&(this.unicode=t),this.unicodes.push(t)};ct.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};ct.prototype.getPath=function(t,e,n,r,s){t=t!==void 0?t:0,e=e!==void 0?e:0,n=n!==void 0?n:72;var i,o;r||(r={});var a=r.xScale,l=r.yScale;if(r.hinting&&s&&s.hinting&&(o=this.path&&s.hinting.exec(this,n)),o)i=s.hinting.getCommands(o),t=Math.round(t),e=Math.round(e),a=l=1;else{i=this.path.commands;var u=1/(this.path.unitsPerEm||1e3)*n;a===void 0&&(a=u),l===void 0&&(l=u)}for(var c=new ze,f=0;f<i.length;f+=1){var h=i[f];h.type==="M"?c.moveTo(t+h.x*a,e+-h.y*l):h.type==="L"?c.lineTo(t+h.x*a,e+-h.y*l):h.type==="Q"?c.quadraticCurveTo(t+h.x1*a,e+-h.y1*l,t+h.x*a,e+-h.y*l):h.type==="C"?c.curveTo(t+h.x1*a,e+-h.y1*l,t+h.x2*a,e+-h.y2*l,t+h.x*a,e+-h.y*l):h.type==="Z"&&c.closePath()}return c};ct.prototype.getContours=function(){if(this.points===void 0)return[];for(var t=[],e=[],n=0;n<this.points.length;n+=1){var r=this.points[n];e.push(r),r.lastPointOfContour&&(t.push(e),e=[])}return ue.argument(e.length===0,"There are still points left in the current contour."),t};ct.prototype.getMetrics=function(){for(var t=this.path.commands,e=[],n=[],r=0;r<t.length;r+=1){var s=t[r];s.type!=="Z"&&(e.push(s.x),n.push(s.y)),(s.type==="Q"||s.type==="C")&&(e.push(s.x1),n.push(s.y1)),s.type==="C"&&(e.push(s.x2),n.push(s.y2))}var i={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,e),yMax:Math.max.apply(null,n),leftSideBearing:this.leftSideBearing};return isFinite(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};ct.prototype.draw=function(t,e,n,r,s){this.getPath(e,n,r,s).draw(t)};ct.prototype.drawPoints=function(t,e,n,r){function s(f,h,p,d){t.beginPath();for(var g=0;g<f.length;g+=1)t.moveTo(h+f[g].x*d,p+f[g].y*d),t.arc(h+f[g].x*d,p+f[g].y*d,2,0,Math.PI*2,!1);t.closePath(),t.fill()}e=e!==void 0?e:0,n=n!==void 0?n:0,r=r!==void 0?r:24;for(var i=1/this.path.unitsPerEm*r,o=[],a=[],l=this.path,u=0;u<l.commands.length;u+=1){var c=l.commands[u];c.x!==void 0&&o.push({x:c.x,y:-c.y}),c.x1!==void 0&&a.push({x:c.x1,y:-c.y1}),c.x2!==void 0&&a.push({x:c.x2,y:-c.y2})}t.fillStyle="blue",s(o,e,n,i),t.fillStyle="red",s(a,e,n,i)};ct.prototype.drawMetrics=function(t,e,n,r){var s;e=e!==void 0?e:0,n=n!==void 0?n:0,r=r!==void 0?r:24,s=1/this.path.unitsPerEm*r,t.lineWidth=1,t.strokeStyle="black",on.line(t,e,-1e4,e,1e4),on.line(t,-1e4,n,1e4,n);var i=this.xMin||0,o=this.yMin||0,a=this.xMax||0,l=this.yMax||0,u=this.advanceWidth||0;t.strokeStyle="blue",on.line(t,e+i*s,-1e4,e+i*s,1e4),on.line(t,e+a*s,-1e4,e+a*s,1e4),on.line(t,-1e4,n+-o*s,1e4,n+-o*s),on.line(t,-1e4,n+-l*s,1e4,n+-l*s),t.strokeStyle="green",on.line(t,e+u*s,-1e4,e+u*s,1e4)};function Xr(t,e,n){Object.defineProperty(t,e,{get:function(){return t.path,t[n]},set:function(r){t[n]=r},enumerable:!0,configurable:!0})}function ui(t,e){if(this.font=t,this.glyphs={},Array.isArray(e))for(var n=0;n<e.length;n++){var r=e[n];r.path.unitsPerEm=t.unitsPerEm,this.glyphs[n]=r}this.length=e&&e.length||0}ui.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],n=this.font._IndexToUnicodeMap[t];if(n)for(var r=0;r<n.unicodes.length;r++)e.addUnicode(n.unicodes[r]);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]};ui.prototype.push=function(t,e){this.glyphs[t]=e,this.length++};function Ku(t,e){return new ct({index:e,font:t})}function Ju(t,e,n,r,s,i){return function(){var o=new ct({index:e,font:t});return o.path=function(){n(o,r,s);var a=i(t.glyphs,o);return a.unitsPerEm=t.unitsPerEm,a},Xr(o,"xMin","_xMin"),Xr(o,"xMax","_xMax"),Xr(o,"yMin","_yMin"),Xr(o,"yMax","_yMax"),o}}function Qu(t,e,n,r){return function(){var s=new ct({index:e,font:t});return s.path=function(){var i=n(t,s,r);return i.unitsPerEm=t.unitsPerEm,i},s}}var Ot={GlyphSet:ui,glyphLoader:Ku,ttfGlyphLoader:Ju,cffGlyphLoader:Qu};function xa(t,e){if(t===e)return!0;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n+=1)if(!xa(t[n],e[n]))return!1;return!0}else return!1}function Qs(t){var e;return t.length<1240?e=107:t.length<33900?e=1131:e=32768,e}function Xt(t,e,n){var r=[],s=[],i=ee.getCard16(t,e),o,a;if(i!==0){var l=ee.getByte(t,e+2);o=e+(i+1)*l+2;for(var u=e+3,c=0;c<i+1;c+=1)r.push(ee.getOffset(t,u,l)),u+=l;a=o+r[i]}else a=e+2;for(var f=0;f<r.length-1;f+=1){var h=ee.getBytes(t,o+r[f],o+r[f+1]);n&&(h=n(h)),s.push(h)}return{objects:s,startOffset:e,endOffset:a}}function ec(t,e){var n=[],r=ee.getCard16(t,e),s,i;if(r!==0){var o=ee.getByte(t,e+2);s=e+(r+1)*o+2;for(var a=e+3,l=0;l<r+1;l+=1)n.push(ee.getOffset(t,a,o)),a+=o;i=s+n[r]}else i=e+2;return{offsets:n,startOffset:e,endOffset:i}}function tc(t,e,n,r,s){var i=ee.getCard16(n,r),o=0;if(i!==0){var a=ee.getByte(n,r+2);o=r+(i+1)*a+2}var l=ee.getBytes(n,o+e[t],o+e[t+1]);return s&&(l=s(l)),l}function nc(t){for(var e="",n=15,r=["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===n||(e+=r[i],o===n))break;e+=r[o]}return parseFloat(e)}function rc(t,e){var n,r,s,i;if(e===28)return n=t.parseByte(),r=t.parseByte(),n<<8|r;if(e===29)return n=t.parseByte(),r=t.parseByte(),s=t.parseByte(),i=t.parseByte(),n<<24|r<<16|s<<8|i;if(e===30)return nc(t);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return n=t.parseByte(),(e-247)*256+n+108;if(e>=251&&e<=254)return n=t.parseByte(),-(e-251)*256-n-108;throw new Error("Invalid b0 "+e)}function sc(t){for(var e={},n=0;n<t.length;n+=1){var r=t[n][0],s=t[n][1],i=void 0;if(s.length===1?i=s[0]:i=s,e.hasOwnProperty(r)&&!isNaN(e[r]))throw new Error("Object "+e+" already has key "+r);e[r]=i}return e}function ya(t,e,n){e=e!==void 0?e:0;var r=new ee.Parser(t,e),s=[],i=[];for(n=n!==void 0?n:t.length;r.relativeOffset<n;){var o=r.parseByte();o<=21?(o===12&&(o=1200+r.parseByte()),s.push([o,i]),i=[]):i.push(rc(r,o))}return sc(s)}function rr(t,e){return e<=390?e=Wr[e]:e=t[e-391],e}function va(t,e,n){for(var r={},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 l=0;l<o.type.length;l++)s=t[o.op]!==void 0?t[o.op][l]:void 0,s===void 0&&(s=o.value!==void 0&&o.value[l]!==void 0?o.value[l]:null),o.type[l]==="SID"&&(s=rr(n,s)),a[l]=s;r[o.name]=a}else s=t[o.op],s===void 0&&(s=o.value!==void 0?o.value:null),o.type==="SID"&&(s=rr(n,s)),r[o.name]=s}return r}function ic(t,e){var n={};return n.formatMajor=ee.getCard8(t,e),n.formatMinor=ee.getCard8(t,e+1),n.size=ee.getCard8(t,e+2),n.offsetSize=ee.getCard8(t,e+3),n.startOffset=e,n.endOffset=e+4,n}var ba=[{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"}],wa=[{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 oc(t,e){var n=ya(t,0,t.byteLength);return va(n,ba,e)}function Sa(t,e,n,r){var s=ya(t,e,n);return va(s,wa,r)}function Io(t,e,n,r){for(var s=[],i=0;i<n.length;i+=1){var o=new DataView(new Uint8Array(n[i]).buffer),a=oc(o,r);a._subrs=[],a._subrsBias=0,a._defaultWidthX=0,a._nominalWidthX=0;var l=a.private[0],u=a.private[1];if(l!==0&&u!==0){var c=Sa(t,u+e,l,r);if(a._defaultWidthX=c.defaultWidthX,a._nominalWidthX=c.nominalWidthX,c.subrs!==0){var f=u+c.subrs,h=Xt(t,f+e);a._subrs=h.objects,a._subrsBias=Qs(a._subrs)}a._privateDict=c}s.push(a)}return s}function ac(t,e,n,r){var s,i,o=new ee.Parser(t,e);n-=1;var a=[".notdef"],l=o.parseCard8();if(l===0)for(var u=0;u<n;u+=1)s=o.parseSID(),a.push(rr(r,s));else if(l===1)for(;a.length<=n;){s=o.parseSID(),i=o.parseCard8();for(var c=0;c<=i;c+=1)a.push(rr(r,s)),s+=1}else if(l===2)for(;a.length<=n;){s=o.parseSID(),i=o.parseCard16();for(var f=0;f<=i;f+=1)a.push(rr(r,s)),s+=1}else throw new Error("Unknown charset format "+l);return a}function lc(t,e,n){var r,s={},i=new ee.Parser(t,e),o=i.parseCard8();if(o===0)for(var a=i.parseCard8(),l=0;l<a;l+=1)r=i.parseCard8(),s[r]=l;else if(o===1){var u=i.parseCard8();r=1;for(var c=0;c<u;c+=1)for(var f=i.parseCard8(),h=i.parseCard8(),p=f;p<=f+h;p+=1)s[p]=r,r+=1}else throw new Error("Unknown encoding format "+o);return new Qr(s,n)}function Co(t,e,n){var r,s,i,o,a=new ze,l=[],u=0,c=!1,f=!1,h=0,p=0,d,g,m,x;if(t.isCIDFont){var w=t.tables.cff.topDict._fdSelect[e.index],v=t.tables.cff.topDict._fdArray[w];d=v._subrs,g=v._subrsBias,m=v._defaultWidthX,x=v._nominalWidthX}else d=t.tables.cff.topDict._subrs,g=t.tables.cff.topDict._subrsBias,m=t.tables.cff.topDict._defaultWidthX,x=t.tables.cff.topDict._nominalWidthX;var T=m;function P(L,B){f&&a.closePath(),a.moveTo(L,B),f=!0}function O(){var L;L=l.length%2!==0,L&&!c&&(T=l.shift()+x),u+=l.length>>1,l.length=0,c=!0}function C(L){for(var B,A,F,te,V,q,re,U,ae,de,me,we,E=0;E<L.length;){var S=L[E];switch(E+=1,S){case 1:O();break;case 3:O();break;case 4:l.length>1&&!c&&(T=l.shift()+x,c=!0),p+=l.pop(),P(h,p);break;case 5:for(;l.length>0;)h+=l.shift(),p+=l.shift(),a.lineTo(h,p);break;case 6:for(;l.length>0&&(h+=l.shift(),a.lineTo(h,p),l.length!==0);)p+=l.shift(),a.lineTo(h,p);break;case 7:for(;l.length>0&&(p+=l.shift(),a.lineTo(h,p),l.length!==0);)h+=l.shift(),a.lineTo(h,p);break;case 8:for(;l.length>0;)r=h+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),h=i+l.shift(),p=o+l.shift(),a.curveTo(r,s,i,o,h,p);break;case 10:V=l.pop()+g,q=d[V],q&&C(q);break;case 11:return;case 12:switch(S=L[E],E+=1,S){case 35:r=h+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),re=i+l.shift(),U=o+l.shift(),ae=re+l.shift(),de=U+l.shift(),me=ae+l.shift(),we=de+l.shift(),h=me+l.shift(),p=we+l.shift(),l.shift(),a.curveTo(r,s,i,o,re,U),a.curveTo(ae,de,me,we,h,p);break;case 34:r=h+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),re=i+l.shift(),U=o,ae=re+l.shift(),de=o,me=ae+l.shift(),we=p,h=me+l.shift(),a.curveTo(r,s,i,o,re,U),a.curveTo(ae,de,me,we,h,p);break;case 36:r=h+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),re=i+l.shift(),U=o,ae=re+l.shift(),de=o,me=ae+l.shift(),we=de+l.shift(),h=me+l.shift(),a.curveTo(r,s,i,o,re,U),a.curveTo(ae,de,me,we,h,p);break;case 37:r=h+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),re=i+l.shift(),U=o+l.shift(),ae=re+l.shift(),de=U+l.shift(),me=ae+l.shift(),we=de+l.shift(),Math.abs(me-h)>Math.abs(we-p)?h=me+l.shift():p=we+l.shift(),a.curveTo(r,s,i,o,re,U),a.curveTo(ae,de,me,we,h,p);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+S),l.length=0}break;case 14:l.length>0&&!c&&(T=l.shift()+x,c=!0),f&&(a.closePath(),f=!1);break;case 18:O();break;case 19:case 20:O(),E+=u+7>>3;break;case 21:l.length>2&&!c&&(T=l.shift()+x,c=!0),p+=l.pop(),h+=l.pop(),P(h,p);break;case 22:l.length>1&&!c&&(T=l.shift()+x,c=!0),h+=l.pop(),P(h,p);break;case 23:O();break;case 24:for(;l.length>2;)r=h+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),h=i+l.shift(),p=o+l.shift(),a.curveTo(r,s,i,o,h,p);h+=l.shift(),p+=l.shift(),a.lineTo(h,p);break;case 25:for(;l.length>6;)h+=l.shift(),p+=l.shift(),a.lineTo(h,p);r=h+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),h=i+l.shift(),p=o+l.shift(),a.curveTo(r,s,i,o,h,p);break;case 26:for(l.length%2&&(h+=l.shift());l.length>0;)r=h,s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),h=i,p=o+l.shift(),a.curveTo(r,s,i,o,h,p);break;case 27:for(l.length%2&&(p+=l.shift());l.length>0;)r=h+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),h=i+l.shift(),p=o,a.curveTo(r,s,i,o,h,p);break;case 28:B=L[E],A=L[E+1],l.push((B<<24|A<<16)>>16),E+=2;break;case 29:V=l.pop()+t.gsubrsBias,q=t.gsubrs[V],q&&C(q);break;case 30:for(;l.length>0&&(r=h,s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),h=i+l.shift(),p=o+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,h,p),l.length!==0);)r=h+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),p=o+l.shift(),h=i+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,h,p);break;case 31:for(;l.length>0&&(r=h+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),p=o+l.shift(),h=i+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,h,p),l.length!==0);)r=h,s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),h=i+l.shift(),p=o+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,h,p);break;default:S<32?console.log("Glyph "+e.index+": unknown operator "+S):S<247?l.push(S-139):S<251?(B=L[E],E+=1,l.push((S-247)*256+B+108)):S<255?(B=L[E],E+=1,l.push(-(S-251)*256-B-108)):(B=L[E],A=L[E+1],F=L[E+2],te=L[E+3],E+=4,l.push((B<<24|A<<16|F<<8|te)/65536))}}}return C(n),e.advanceWidth=T,a}function uc(t,e,n,r){var s=[],i,o=new ee.Parser(t,e),a=o.parseCard8();if(a===0)for(var l=0;l<n;l++){if(i=o.parseCard8(),i>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+r+")");s.push(i)}else if(a===3){var u=o.parseCard16(),c=o.parseCard16();if(c!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+c);for(var f,h=0;h<u;h++){if(i=o.parseCard8(),f=o.parseCard16(),i>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+r+")");if(f>n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+f);for(;c<f;c++)s.push(i);c=f}if(f!==n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+f)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+a);return s}function cc(t,e,n,r){n.tables.cff={};var s=ic(t,e),i=Xt(t,s.endOffset,ee.bytesToString),o=Xt(t,i.endOffset),a=Xt(t,o.endOffset,ee.bytesToString),l=Xt(t,a.endOffset);n.gsubrs=l.objects,n.gsubrsBias=Qs(n.gsubrs);var u=Io(t,e,o.objects,a.objects);if(u.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+u.length);var c=u[0];if(n.tables.cff.topDict=c,c._privateDict&&(n.defaultWidthX=c._privateDict.defaultWidthX,n.nominalWidthX=c._privateDict.nominalWidthX),c.ros[0]!==void 0&&c.ros[1]!==void 0&&(n.isCIDFont=!0),n.isCIDFont){var f=c.fdArray,h=c.fdSelect;if(f===0||h===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");f+=e;var p=Xt(t,f),d=Io(t,e,p.objects,a.objects);c._fdArray=d,h+=e,c._fdSelect=uc(t,h,n.numGlyphs,d.length)}var g=e+c.private[1],m=Sa(t,g,c.private[0],a.objects);if(n.defaultWidthX=m.defaultWidthX,n.nominalWidthX=m.nominalWidthX,m.subrs!==0){var x=g+m.subrs,w=Xt(t,x);n.subrs=w.objects,n.subrsBias=Qs(n.subrs)}else n.subrs=[],n.subrsBias=0;var v;r.lowMemory?(v=ec(t,e+c.charStrings),n.nGlyphs=v.offsets.length):(v=Xt(t,e+c.charStrings),n.nGlyphs=v.objects.length);var T=ac(t,e+c.charset,n.nGlyphs,a.objects);if(c.encoding===0?n.cffEncoding=new Qr(Xu,T):c.encoding===1?n.cffEncoding=new Qr(qu,T):n.cffEncoding=lc(t,e+c.encoding,T),n.encoding=n.encoding||n.cffEncoding,n.glyphs=new Ot.GlyphSet(n),r.lowMemory)n._push=function(C){var L=tc(C,v.offsets,t,e+c.charStrings);n.glyphs.push(C,Ot.cffGlyphLoader(n,C,Co,L))};else for(var P=0;P<n.nGlyphs;P+=1){var O=v.objects[P];n.glyphs.push(P,Ot.cffGlyphLoader(n,P,Co,O))}}function ka(t,e){var n,r=Wr.indexOf(t);return r>=0&&(n=r),r=e.indexOf(t),r>=0?n=r+Wr.length:(n=Wr.length+e.length,e.push(t)),n}function fc(){return new Z.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 hc(t){var e=new Z.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(var n=0;n<t.length;n+=1)e.names.push({name:"name_"+n,type:"NAME",value:t[n]});return e}function Pa(t,e,n){for(var r={},s=0;s<t.length;s+=1){var i=t[s],o=e[i.name];o!==void 0&&!xa(o,i.value)&&(i.type==="SID"&&(o=ka(o,n)),r[i.op]={name:i.name,type:i.type,value:o})}return r}function Ao(t,e){var n=new Z.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return n.dict=Pa(ba,t,e),n}function Oo(t){var e=new Z.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:t}],e}function pc(t){var e=new Z.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(var n=0;n<t.length;n+=1)e.strings.push({name:"string_"+n,type:"STRING",value:t[n]});return e}function dc(){return new Z.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function gc(t,e){for(var n=new Z.Record("Charsets",[{name:"format",type:"Card8",value:0}]),r=0;r<t.length;r+=1){var s=t[r],i=ka(s,e);n.fields.push({name:"glyph_"+r,type:"SID",value:i})}return n}function mc(t){var e=[],n=t.path;e.push({name:"width",type:"NUMBER",value:t.advanceWidth});for(var r=0,s=0,i=0;i<n.commands.length;i+=1){var o=void 0,a=void 0,l=n.commands[i];if(l.type==="Q"){var u=.3333333333333333,c=2/3;l={type:"C",x:l.x,y:l.y,x1:Math.round(u*r+c*l.x1),y1:Math.round(u*s+c*l.y1),x2:Math.round(u*l.x+c*l.x1),y2:Math.round(u*l.y+c*l.y1)}}if(l.type==="M")o=Math.round(l.x-r),a=Math.round(l.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}),r=Math.round(l.x),s=Math.round(l.y);else if(l.type==="L")o=Math.round(l.x-r),a=Math.round(l.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}),r=Math.round(l.x),s=Math.round(l.y);else if(l.type==="C"){var f=Math.round(l.x1-r),h=Math.round(l.y1-s),p=Math.round(l.x2-l.x1),d=Math.round(l.y2-l.y1);o=Math.round(l.x-l.x2),a=Math.round(l.y-l.y2),e.push({name:"dx1",type:"NUMBER",value:f}),e.push({name:"dy1",type:"NUMBER",value:h}),e.push({name:"dx2",type:"NUMBER",value:p}),e.push({name:"dy2",type:"NUMBER",value:d}),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rrcurveto",type:"OP",value:8}),r=Math.round(l.x),s=Math.round(l.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function xc(t){for(var e=new Z.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),n=0;n<t.length;n+=1){var r=t.get(n),s=mc(r);e.charStrings.push({name:r.name,type:"CHARSTRING",value:s})}return e}function yc(t,e){var n=new Z.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return n.dict=Pa(wa,t,e),n}function vc(t,e){for(var n=new Z.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),r=1/e.unitsPerEm,s={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[r,0,0,r,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},i={},o=[],a,l=1;l<t.length;l+=1)a=t.get(l),o.push(a.name);var u=[];n.header=fc(),n.nameIndex=hc([e.postScriptName]);var c=Ao(s,u);n.topDictIndex=Oo(c),n.globalSubrIndex=dc(),n.charsets=gc(o,u),n.charStringsIndex=xc(t),n.privateDict=yc(i,u),n.stringIndex=pc(u);var f=n.header.sizeOf()+n.nameIndex.sizeOf()+n.topDictIndex.sizeOf()+n.stringIndex.sizeOf()+n.globalSubrIndex.sizeOf();return s.charset=f,s.encoding=0,s.charStrings=s.charset+n.charsets.sizeOf(),s.private[1]=s.charStrings+n.charStringsIndex.sizeOf(),c=Ao(s,u),n.topDictIndex=Oo(c),n}var Ma={parse:cc,make:vc};function bc(t,e){var n={},r=new ee.Parser(t,e);return n.version=r.parseVersion(),n.fontRevision=Math.round(r.parseFixed()*1e3)/1e3,n.checkSumAdjustment=r.parseULong(),n.magicNumber=r.parseULong(),ue.argument(n.magicNumber===1594834165,"Font header has wrong magic number."),n.flags=r.parseUShort(),n.unitsPerEm=r.parseUShort(),n.created=r.parseLongDateTime(),n.modified=r.parseLongDateTime(),n.xMin=r.parseShort(),n.yMin=r.parseShort(),n.xMax=r.parseShort(),n.yMax=r.parseShort(),n.macStyle=r.parseUShort(),n.lowestRecPPEM=r.parseUShort(),n.fontDirectionHint=r.parseShort(),n.indexToLocFormat=r.parseShort(),n.glyphDataFormat=r.parseShort(),n}function wc(t){var e=Math.round(new Date().getTime()/1e3)+2082844800,n=e;return t.createdTimestamp&&(n=t.createdTimestamp+2082844800),new Z.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:n},{name:"modified",type:"LONGDATETIME",value:e},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value: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 Ea={parse:bc,make:wc};function Sc(t,e){var n={},r=new ee.Parser(t,e);return n.version=r.parseVersion(),n.ascender=r.parseShort(),n.descender=r.parseShort(),n.lineGap=r.parseShort(),n.advanceWidthMax=r.parseUShort(),n.minLeftSideBearing=r.parseShort(),n.minRightSideBearing=r.parseShort(),n.xMaxExtent=r.parseShort(),n.caretSlopeRise=r.parseShort(),n.caretSlopeRun=r.parseShort(),n.caretOffset=r.parseShort(),r.relativeOffset+=8,n.metricDataFormat=r.parseShort(),n.numberOfHMetrics=r.parseUShort(),n}function kc(t){return new Z.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 La={parse:Sc,make:kc};function Pc(t,e,n,r,s){for(var i,o,a=new ee.Parser(t,e),l=0;l<r;l+=1){l<n&&(i=a.parseUShort(),o=a.parseShort());var u=s.get(l);u.advanceWidth=i,u.leftSideBearing=o}}function Mc(t,e,n,r,s){t._hmtxTableData={};for(var i,o,a=new ee.Parser(e,n),l=0;l<s;l+=1)l<r&&(i=a.parseUShort(),o=a.parseShort()),t._hmtxTableData[l]={advanceWidth:i,leftSideBearing:o}}function Ec(t,e,n,r,s,i,o){o.lowMemory?Mc(t,e,n,r,s):Pc(e,n,r,s,i)}function Lc(t){for(var e=new Z.Table("hmtx",[]),n=0;n<t.length;n+=1){var r=t.get(n),s=r.advanceWidth||0,i=r.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+n,type:"USHORT",value:s}),e.fields.push({name:"leftSideBearing_"+n,type:"SHORT",value:i})}return e}var Ta={parse:Ec,make:Lc};function Tc(t){for(var e=new Z.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:t.length}]),n="",r=12+t.length*4,s=0;s<t.length;++s){var i=n.indexOf(t[s]);i<0&&(i=n.length,n+=t[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:r+i}),e.fields.push({name:"length "+s,type:"USHORT",value:t[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:n}),e}function Ic(t,e){var n=new ee.Parser(t,e),r=n.parseULong();ue.argument(r===1,"Unsupported ltag table version."),n.skip("uLong",1);for(var s=n.parseULong(),i=[],o=0;o<s;o++){for(var a="",l=e+n.parseUShort(),u=n.parseUShort(),c=l;c<l+u;++c)a+=String.fromCharCode(t.getInt8(c));i.push(a)}return i}var Ia={make:Tc,parse:Ic};function Cc(t,e){var n={},r=new ee.Parser(t,e);return n.version=r.parseVersion(),n.numGlyphs=r.parseUShort(),n.version===1&&(n.maxPoints=r.parseUShort(),n.maxContours=r.parseUShort(),n.maxCompositePoints=r.parseUShort(),n.maxCompositeContours=r.parseUShort(),n.maxZones=r.parseUShort(),n.maxTwilightPoints=r.parseUShort(),n.maxStorage=r.parseUShort(),n.maxFunctionDefs=r.parseUShort(),n.maxInstructionDefs=r.parseUShort(),n.maxStackElements=r.parseUShort(),n.maxSizeOfInstructions=r.parseUShort(),n.maxComponentElements=r.parseUShort(),n.maxComponentDepth=r.parseUShort()),n}function Ac(t){return new Z.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:t}])}var Ca={parse:Cc,make:Ac},Aa=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Oa={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"},Oc={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},Fa={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 Fc(t,e,n){switch(t){case 0:if(e===65535)return"und";if(n)return n[e];break;case 1:return Oa[e];case 3:return Fa[e]}}var ei="utf-16",Dc={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"},Rc={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 Da(t,e,n){switch(t){case 0:return ei;case 1:return Rc[n]||Dc[e];case 3:if(e===1||e===10)return ei;break}}function Uc(t,e,n){for(var r={},s=new ee.Parser(t,e),i=s.parseUShort(),o=s.parseUShort(),a=s.offset+s.parseUShort(),l=0;l<o;l++){var u=s.parseUShort(),c=s.parseUShort(),f=s.parseUShort(),h=s.parseUShort(),p=Aa[h]||h,d=s.parseUShort(),g=s.parseUShort(),m=Fc(u,f,n),x=Da(u,c,f);if(x!==void 0&&m!==void 0){var w=void 0;if(x===ei?w=En.UTF16(t,a+g,d):w=En.MACSTRING(t,a+g,d,x),w){var v=r[p];v===void 0&&(v=r[p]={}),v[m]=w}}}var T=0;return i===1&&(T=s.parseUShort()),r}function zs(t){var e={};for(var n in t)e[t[n]]=parseInt(n);return e}function Fo(t,e,n,r,s,i){return new Z.Record("NameRecord",[{name:"platformID",type:"USHORT",value:t},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:n},{name:"nameID",type:"USHORT",value:r},{name:"length",type:"USHORT",value:s},{name:"offset",type:"USHORT",value:i}])}function Nc(t,e){var n=t.length,r=e.length-n+1;e:for(var s=0;s<r;s++)for(;s<r;s++){for(var i=0;i<n;i++)if(e[s+i]!==t[i])continue e;return s}return-1}function Do(t,e){var n=Nc(t,e);if(n<0){n=e.length;for(var r=0,s=t.length;r<s;++r)e.push(t[r])}return n}function Bc(t,e){var n,r=[],s={},i=zs(Aa);for(var o in t){var a=i[o];if(a===void 0&&(a=o),n=parseInt(a),isNaN(n))throw new Error('Name table entry "'+o+'" does not exist, see nameTableNames for complete list.');s[n]=t[o],r.push(n)}for(var l=zs(Oa),u=zs(Fa),c=[],f=[],h=0;h<r.length;h++){n=r[h];var p=s[n];for(var d in p){var g=p[d],m=1,x=l[d],w=Oc[x],v=Da(m,w,x),T=X.MACSTRING(g,v);T===void 0&&(m=0,x=e.indexOf(d),x<0&&(x=e.length,e.push(d)),w=4,T=X.UTF16(g));var P=Do(T,f);c.push(Fo(m,w,x,n,T.length,P));var O=u[d];if(O!==void 0){var C=X.UTF16(g),L=Do(C,f);c.push(Fo(3,1,O,n,C.length,L))}}}c.sort(function(F,te){return F.platformID-te.platformID||F.encodingID-te.encodingID||F.languageID-te.languageID||F.nameID-te.nameID});for(var B=new Z.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:c.length},{name:"stringOffset",type:"USHORT",value:6+c.length*12}]),A=0;A<c.length;A++)B.fields.push({name:"record_"+A,type:"RECORD",value:c[A]});return B.fields.push({name:"strings",type:"LITERAL",value:f}),B}var Ra={parse:Uc,make:Bc},ti=[{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 $c(t){for(var e=0;e<ti.length;e+=1){var n=ti[e];if(t>=n.begin&&t<n.end)return e}return-1}function Gc(t,e){var n={},r=new ee.Parser(t,e);n.version=r.parseUShort(),n.xAvgCharWidth=r.parseShort(),n.usWeightClass=r.parseUShort(),n.usWidthClass=r.parseUShort(),n.fsType=r.parseUShort(),n.ySubscriptXSize=r.parseShort(),n.ySubscriptYSize=r.parseShort(),n.ySubscriptXOffset=r.parseShort(),n.ySubscriptYOffset=r.parseShort(),n.ySuperscriptXSize=r.parseShort(),n.ySuperscriptYSize=r.parseShort(),n.ySuperscriptXOffset=r.parseShort(),n.ySuperscriptYOffset=r.parseShort(),n.yStrikeoutSize=r.parseShort(),n.yStrikeoutPosition=r.parseShort(),n.sFamilyClass=r.parseShort(),n.panose=[];for(var s=0;s<10;s++)n.panose[s]=r.parseByte();return n.ulUnicodeRange1=r.parseULong(),n.ulUnicodeRange2=r.parseULong(),n.ulUnicodeRange3=r.parseULong(),n.ulUnicodeRange4=r.parseULong(),n.achVendID=String.fromCharCode(r.parseByte(),r.parseByte(),r.parseByte(),r.parseByte()),n.fsSelection=r.parseUShort(),n.usFirstCharIndex=r.parseUShort(),n.usLastCharIndex=r.parseUShort(),n.sTypoAscender=r.parseShort(),n.sTypoDescender=r.parseShort(),n.sTypoLineGap=r.parseShort(),n.usWinAscent=r.parseUShort(),n.usWinDescent=r.parseUShort(),n.version>=1&&(n.ulCodePageRange1=r.parseULong(),n.ulCodePageRange2=r.parseULong()),n.version>=2&&(n.sxHeight=r.parseShort(),n.sCapHeight=r.parseShort(),n.usDefaultChar=r.parseUShort(),n.usBreakChar=r.parseUShort(),n.usMaxContent=r.parseUShort()),n}function zc(t){return new Z.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 ni={parse:Gc,make:zc,unicodeRanges:ti,getUnicodeRange:$c};function Hc(t,e){var n={},r=new ee.Parser(t,e);switch(n.version=r.parseVersion(),n.italicAngle=r.parseFixed(),n.underlinePosition=r.parseShort(),n.underlineThickness=r.parseShort(),n.isFixedPitch=r.parseULong(),n.minMemType42=r.parseULong(),n.maxMemType42=r.parseULong(),n.minMemType1=r.parseULong(),n.maxMemType1=r.parseULong(),n.version){case 1:n.names=an.slice();break;case 2:n.numberOfGlyphs=r.parseUShort(),n.glyphNameIndex=new Array(n.numberOfGlyphs);for(var s=0;s<n.numberOfGlyphs;s++)n.glyphNameIndex[s]=r.parseUShort();n.names=[];for(var i=0;i<n.numberOfGlyphs;i++)if(n.glyphNameIndex[i]>=an.length){var o=r.parseChar();n.names.push(r.parseString(o))}break;case 2.5:n.numberOfGlyphs=r.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(var a=0;a<n.numberOfGlyphs;a++)n.offset[a]=r.parseChar();break}return n}function Vc(){return new Z.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 Ua={parse:Hc,make:Vc},xt=new Array(9);xt[1]=function(){var e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{substFormat:1,coverage:this.parsePointer(M.coverage),deltaGlyphId:this.parseUShort()};if(n===2)return{substFormat:2,coverage:this.parsePointer(M.coverage),substitute:this.parseOffset16List()};ue.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")};xt[2]=function(){var e=this.parseUShort();return ue.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(M.coverage),sequences:this.parseListOfLists()}};xt[3]=function(){var e=this.parseUShort();return ue.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(M.coverage),alternateSets:this.parseListOfLists()}};xt[4]=function(){var e=this.parseUShort();return ue.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(M.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Mn={sequenceIndex:M.uShort,lookupListIndex:M.uShort};xt[5]=function(){var e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{substFormat:n,coverage:this.parsePointer(M.coverage),ruleSets:this.parseListOfLists(function(){var i=this.parseUShort(),o=this.parseUShort();return{input:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(o,Mn)}})};if(n===2)return{substFormat:n,coverage:this.parsePointer(M.coverage),classDef:this.parsePointer(M.classDef),classSets:this.parseListOfLists(function(){var i=this.parseUShort(),o=this.parseUShort();return{classes:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(o,Mn)}})};if(n===3){var r=this.parseUShort(),s=this.parseUShort();return{substFormat:n,coverages:this.parseList(r,M.pointer(M.coverage)),lookupRecords:this.parseRecordList(s,Mn)}}ue.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")};xt[6]=function(){var e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{substFormat:1,coverage:this.parsePointer(M.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Mn)}})};if(n===2)return{substFormat:2,coverage:this.parsePointer(M.coverage),backtrackClassDef:this.parsePointer(M.classDef),inputClassDef:this.parsePointer(M.classDef),lookaheadClassDef:this.parsePointer(M.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Mn)}})};if(n===3)return{substFormat:3,backtrackCoverage:this.parseList(M.pointer(M.coverage)),inputCoverage:this.parseList(M.pointer(M.coverage)),lookaheadCoverage:this.parseList(M.pointer(M.coverage)),lookupRecords:this.parseRecordList(Mn)};ue.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")};xt[7]=function(){var e=this.parseUShort();ue.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");var n=this.parseUShort(),r=new M(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:n,extension:xt[n].call(r)}};xt[8]=function(){var e=this.parseUShort();return ue.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(M.coverage),backtrackCoverage:this.parseList(M.pointer(M.coverage)),lookaheadCoverage:this.parseList(M.pointer(M.coverage)),substitutes:this.parseUShortList()}};function Xc(t,e){e=e||0;var n=new M(t,e),r=n.parseVersion(1);return ue.argument(r===1||r===1.1,"Unsupported GSUB table version."),r===1?{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(xt)}:{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(xt),variations:n.parseFeatureVariationsList()}}var Ln=new Array(9);Ln[1]=function(e){return e.substFormat===1?new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)}].concat(Z.ushortList("substitute",e.substitute)))};Ln[2]=function(e){return ue.assert(e.substFormat===1,"Lookup type 2 substFormat must be 1."),new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)}].concat(Z.tableList("seqSet",e.sequences,function(n){return new Z.Table("sequenceSetTable",Z.ushortList("sequence",n))})))};Ln[3]=function(e){return ue.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)}].concat(Z.tableList("altSet",e.alternateSets,function(n){return new Z.Table("alternateSetTable",Z.ushortList("alternate",n))})))};Ln[4]=function(e){return ue.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new Z.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)}].concat(Z.tableList("ligSet",e.ligatureSets,function(n){return new Z.Table("ligatureSetTable",Z.tableList("ligature",n,function(r){return new Z.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:r.ligGlyph}].concat(Z.ushortList("component",r.components,r.components.length+1)))}))})))};Ln[6]=function(e){if(e.substFormat===1){var n=new Z.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new Z.Coverage(e.coverage)}].concat(Z.tableList("chainRuleSet",e.chainRuleSets,function(i){return new Z.Table("chainRuleSetTable",Z.tableList("chainRule",i,function(o){var a=Z.ushortList("backtrackGlyph",o.backtrack,o.backtrack.length).concat(Z.ushortList("inputGlyph",o.input,o.input.length+1)).concat(Z.ushortList("lookaheadGlyph",o.lookahead,o.lookahead.length)).concat(Z.ushortList("substitution",[],o.lookupRecords.length));return o.lookupRecords.forEach(function(l,u){a=a.concat({name:"sequenceIndex"+u,type:"USHORT",value:l.sequenceIndex}).concat({name:"lookupListIndex"+u,type:"USHORT",value:l.lookupListIndex})}),new Z.Table("chainRuleTable",a)}))})));return n}else if(e.substFormat===2)ue.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(e.substFormat===3){var r=[{name:"substFormat",type:"USHORT",value:e.substFormat}];r.push({name:"backtrackGlyphCount",type:"USHORT",value:e.backtrackCoverage.length}),e.backtrackCoverage.forEach(function(i,o){r.push({name:"backtrackCoverage"+o,type:"TABLE",value:new Z.Coverage(i)})}),r.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length}),e.inputCoverage.forEach(function(i,o){r.push({name:"inputCoverage"+o,type:"TABLE",value:new Z.Coverage(i)})}),r.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length}),e.lookaheadCoverage.forEach(function(i,o){r.push({name:"lookaheadCoverage"+o,type:"TABLE",value:new Z.Coverage(i)})}),r.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length}),e.lookupRecords.forEach(function(i,o){r=r.concat({name:"sequenceIndex"+o,type:"USHORT",value:i.sequenceIndex}).concat({name:"lookupListIndex"+o,type:"USHORT",value:i.lookupListIndex})});var s=new Z.Table("chainContextTable",r);return s}ue.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function qc(t){return new Z.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new Z.ScriptList(t.scripts)},{name:"features",type:"TABLE",value:new Z.FeatureList(t.features)},{name:"lookups",type:"TABLE",value:new Z.LookupList(t.lookups,Ln)}])}var Na={parse:Xc,make:qc};function Wc(t,e){var n=new ee.Parser(t,e),r=n.parseULong();ue.argument(r===1,"Unsupported META table version."),n.parseULong(),n.parseULong();for(var s=n.parseULong(),i={},o=0;o<s;o++){var a=n.parseTag(),l=n.parseULong(),u=n.parseULong(),c=En.UTF8(t,e+l,u);i[a]=c}return i}function _c(t){var e=Object.keys(t).length,n="",r=16+e*12,s=new Z.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:r},{name:"numTags",type:"ULONG",value:e}]);for(var i in t){var o=n.length;n+=t[i],s.fields.push({name:"tag "+i,type:"TAG",value:i}),s.fields.push({name:"offset "+i,type:"ULONG",value:r+o}),s.fields.push({name:"length "+i,type:"ULONG",value:t[i].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:n}),s}var Ba={parse:Wc,make:_c};function Ro(t){return Math.log(t)/Math.log(2)|0}function ci(t){for(;t.length%4!==0;)t.push(0);for(var e=0,n=0;n<t.length;n+=4)e+=(t[n]<<24)+(t[n+1]<<16)+(t[n+2]<<8)+t[n+3];return e%=Math.pow(2,32),e}function Uo(t,e,n,r){return new Z.Record("Table Record",[{name:"tag",type:"TAG",value:t!==void 0?t:""},{name:"checkSum",type:"ULONG",value:e!==void 0?e:0},{name:"offset",type:"ULONG",value:n!==void 0?n:0},{name:"length",type:"ULONG",value:r!==void 0?r:0}])}function $a(t){var e=new Z.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 n=Math.pow(2,Ro(e.numTables));e.searchRange=16*n,e.entrySelector=Ro(n),e.rangeShift=e.numTables*16-e.searchRange;for(var r=[],s=[],i=e.sizeOf()+Uo().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];ue.argument(a.tableName.length===4,"Table name"+a.tableName+" is invalid.");var l=a.sizeOf(),u=Uo(a.tableName,ci(a.encode()),i,l);for(r.push({name:u.tag+" Table Record",type:"RECORD",value:u}),s.push({name:a.tableName+" table",type:"RECORD",value:a}),i+=l,ue.argument(!isNaN(i),"Something went wrong calculating the offset.");i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0})}return r.sort(function(c,f){return c.value.tag>f.value.tag?1:-1}),e.fields=e.fields.concat(r),e.fields=e.fields.concat(s),e}function No(t,e,n){for(var r=0;r<e.length;r+=1){var s=t.charToGlyphIndex(e[r]);if(s>0){var i=t.glyphs.get(s);return i.getMetrics()}}return n}function jc(t){for(var e=0,n=0;n<t.length;n+=1)e+=t[n];return e/t.length}function Zc(t){for(var e=[],n=[],r=[],s=[],i=[],o=[],a=[],l,u=0,c=0,f=0,h=0,p=0,d=0;d<t.glyphs.length;d+=1){var g=t.glyphs.get(d),m=g.unicode|0;if(isNaN(g.advanceWidth))throw new Error("Glyph "+g.name+" ("+d+"): advanceWidth is not a number.");(l>m||l===void 0)&&m>0&&(l=m),u<m&&(u=m);var x=ni.getUnicodeRange(m);if(x<32)c|=1<<x;else if(x<64)f|=1<<x-32;else if(x<96)h|=1<<x-64;else if(x<123)p|=1<<x-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(g.name!==".notdef"){var w=g.getMetrics();e.push(w.xMin),n.push(w.yMin),r.push(w.xMax),s.push(w.yMax),o.push(w.leftSideBearing),a.push(w.rightSideBearing),i.push(g.advanceWidth)}}var v={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,r),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,i),advanceWidthAvg:jc(i),minLeftSideBearing:Math.min.apply(null,o),maxLeftSideBearing:Math.max.apply(null,o),minRightSideBearing:Math.min.apply(null,a)};v.ascender=t.ascender,v.descender=t.descender;var T=Ea.make({flags:3,unitsPerEm:t.unitsPerEm,xMin:v.xMin,yMin:v.yMin,xMax:v.xMax,yMax:v.yMax,lowestRecPPEM:3,createdTimestamp:t.createdTimestamp}),P=La.make({ascender:v.ascender,descender:v.descender,advanceWidthMax:v.advanceWidthMax,minLeftSideBearing:v.minLeftSideBearing,minRightSideBearing:v.minRightSideBearing,xMaxExtent:v.maxLeftSideBearing+(v.xMax-v.xMin),numberOfHMetrics:t.glyphs.length}),O=Ca.make(t.glyphs.length),C=ni.make(Object.assign({xAvgCharWidth:Math.round(v.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:u,ulUnicodeRange1:c,ulUnicodeRange2:f,ulUnicodeRange3:h,ulUnicodeRange4:p,sTypoAscender:v.ascender,sTypoDescender:v.descender,sTypoLineGap:0,usWinAscent:v.yMax,usWinDescent:Math.abs(v.yMin),ulCodePageRange1:1,sxHeight:No(t,"xyvw",{yMax:Math.round(v.ascender/2)}).yMax,sCapHeight:No(t,"HIKLEFJMNTZBDPRAGOQSUVWXY",v).yMax,usDefaultChar:t.hasChar(" ")?32:0,usBreakChar:t.hasChar(" ")?32:0},t.tables.os2)),L=Ta.make(t.glyphs),B=da.make(t.glyphs),A=t.getEnglishName("fontFamily"),F=t.getEnglishName("fontSubfamily"),te=A+" "+F,V=t.getEnglishName("postScriptName");V||(V=A.replace(/\s/g,"")+"-"+F);var q={};for(var re in t.names)q[re]=t.names[re];q.uniqueID||(q.uniqueID={en:t.getEnglishName("manufacturer")+":"+te}),q.postScriptName||(q.postScriptName={en:V}),q.preferredFamily||(q.preferredFamily=t.names.fontFamily),q.preferredSubfamily||(q.preferredSubfamily=t.names.fontSubfamily);var U=[],ae=Ra.make(q,U),de=U.length>0?Ia.make(U):void 0,me=Ua.make(),we=Ma.make(t.glyphs,{version:t.getEnglishName("version"),fullName:te,familyName:A,weightName:F,postScriptName:V,unitsPerEm:t.unitsPerEm,fontBBox:[0,v.yMin,v.ascender,v.advanceWidthMax]}),E=t.metas&&Object.keys(t.metas).length>0?Ba.make(t.metas):void 0,S=[T,P,O,C,ae,B,me,we,L];de&&S.push(de),t.tables.gsub&&S.push(Na.make(t.tables.gsub)),E&&S.push(E);for(var D=$a(S),$=D.encode(),_=ci($),ie=D.fields,J=!1,he=0;he<ie.length;he+=1)if(ie[he].name==="head table"){ie[he].value.checkSumAdjustment=2981146554-_,J=!0;break}if(!J)throw new Error("Could not find head table with checkSum to adjust.");return D}var Yc={make:$a,fontToTable:Zc,computeCheckSum:ci};function Hs(t,e){for(var n=0,r=t.length-1;n<=r;){var s=n+r>>>1,i=t[s].tag;if(i===e)return s;i<e?n=s+1:r=s-1}return-n-1}function Bo(t,e){for(var n=0,r=t.length-1;n<=r;){var s=n+r>>>1,i=t[s];if(i===e)return s;i<e?n=s+1:r=s-1}return-n-1}function $o(t,e){for(var n,r=0,s=t.length-1;r<=s;){var i=r+s>>>1;n=t[i];var o=n.start;if(o===e)return n;o<e?r=i+1:s=i-1}if(r>0)return n=t[r-1],e>n.end?0:n}function lr(t,e){this.font=t,this.tableName=e}lr.prototype={searchTag:Hs,binSearch:Bo,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,n=0;n<t.scripts.length;n++){var r=t.scripts[n].tag;if(r==="DFLT")return r;r==="latn"&&(e=!0)}if(e)return"latn"}},getScriptTable:function(t,e){var n=this.getTable(e);if(n){t=t||"DFLT";var r=n.scripts,s=Hs(n.scripts,t);if(s>=0)return r[s].script;if(e){var i={tag:t,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return r.splice(-1-s,0,i),i.script}}},getLangSysTable:function(t,e,n){var r=this.getScriptTable(t,n);if(r){if(!e||e==="dflt"||e==="DFLT")return r.defaultLangSys;var s=Hs(r.langSysRecords,e);if(s>=0)return r.langSysRecords[s].langSys;if(n){var i={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return r.langSysRecords.splice(-1-s,0,i),i.langSys}}},getFeatureTable:function(t,e,n,r){var s=this.getLangSysTable(t,e,r);if(s){for(var i,o=s.featureIndexes,a=this.font.tables[this.tableName].features,l=0;l<o.length;l++)if(i=a[o[l]],i.tag===n)return i.feature;if(r){var u=a.length;return ue.assert(u===0||n>=a[u-1].tag,"Features must be added in alphabetical order."),i={tag:n,feature:{params:0,lookupListIndexes:[]}},a.push(i),o.push(u),i.feature}}},getLookupTables:function(t,e,n,r,s){var i=this.getFeatureTable(t,e,n,s),o=[];if(i){for(var a,l=i.lookupListIndexes,u=this.font.tables[this.tableName].lookups,c=0;c<l.length;c++)a=u[l[c]],a.lookupType===r&&o.push(a);if(o.length===0&&s){a={lookupType:r,lookupFlag:0,subtables:[],markFilteringSet:void 0};var f=u.length;return u.push(a),l.push(f),[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 n=$o(t.ranges,e);return n?n.classId:0}},getCoverageIndex:function(t,e){switch(t.format){case 1:var n=Bo(t.glyphs,e);return n>=0?n:-1;case 2:var r=$o(t.ranges,e);return r?r.index+e-r.start:-1}},expandCoverage:function(t){if(t.format===1)return t.glyphs;for(var e=[],n=t.ranges,r=0;r<n.length;r++)for(var s=n[r],i=s.start,o=s.end,a=i;a<=o;a++)e.push(a);return e}};function ur(t){lr.call(this,t,"gpos")}ur.prototype=lr.prototype;ur.prototype.init=function(){var t=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(t)};ur.prototype.getKerningValue=function(t,e,n){for(var r=0;r<t.length;r++)for(var s=t[r].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 l=o.pairSets[a],u=0;u<l.length;u++){var c=l[u];if(c.secondGlyph===n)return c.value1&&c.value1.xAdvance||0}break;case 2:var f=this.getGlyphClass(o.classDef1,e),h=this.getGlyphClass(o.classDef2,n),p=o.classRecords[f][h];return p.value1&&p.value1.xAdvance||0}}return 0};ur.prototype.getKerningTables=function(t,e){if(this.font.tables.gpos)return this.getLookupTables(t,e,"kern",2)};function it(t){lr.call(this,t,"gsub")}function Kc(t,e){var n=t.length;if(n!==e.length)return!1;for(var r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function fi(t,e,n){for(var r=t.subtables,s=0;s<r.length;s++){var i=r[s];if(i.substFormat===e)return i}if(n)return r.push(n),n}it.prototype=lr.prototype;it.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}};it.prototype.getSingle=function(t,e,n){for(var r=[],s=this.getLookupTables(e,n,t,1),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++){var l=o[a],u=this.expandCoverage(l.coverage),c=void 0;if(l.substFormat===1){var f=l.deltaGlyphId;for(c=0;c<u.length;c++){var h=u[c];r.push({sub:h,by:h+f})}}else{var p=l.substitute;for(c=0;c<u.length;c++)r.push({sub:u[c],by:p[c]})}}return r};it.prototype.getMultiple=function(t,e,n){for(var r=[],s=this.getLookupTables(e,n,t,2),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++){var l=o[a],u=this.expandCoverage(l.coverage),c=void 0;for(c=0;c<u.length;c++){var f=u[c],h=l.sequences[c];r.push({sub:f,by:h})}}return r};it.prototype.getAlternates=function(t,e,n){for(var r=[],s=this.getLookupTables(e,n,t,3),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++)for(var l=o[a],u=this.expandCoverage(l.coverage),c=l.alternateSets,f=0;f<u.length;f++)r.push({sub:u[f],by:c[f]});return r};it.prototype.getLigatures=function(t,e,n){for(var r=[],s=this.getLookupTables(e,n,t,4),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++)for(var l=o[a],u=this.expandCoverage(l.coverage),c=l.ligatureSets,f=0;f<u.length;f++)for(var h=u[f],p=c[f],d=0;d<p.length;d++){var g=p[d];r.push({sub:[h].concat(g.components),by:g.ligGlyph})}return r};it.prototype.addSingle=function(t,e,n,r){var s=this.getLookupTables(n,r,t,1,!0)[0],i=fi(s,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});ue.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};it.prototype.addMultiple=function(t,e,n,r){ue.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');var s=this.getLookupTables(n,r,t,2,!0)[0],i=fi(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});ue.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};it.prototype.addAlternate=function(t,e,n,r){var s=this.getLookupTables(n,r,t,3,!0)[0],i=fi(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ue.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};it.prototype.addLigature=function(t,e,n,r){var s=this.getLookupTables(n,r,t,4,!0)[0],i=s.subtables[0];i||(i={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=i),ue.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),l={ligGlyph:e.by,components:a},u=this.binSearch(i.coverage.glyphs,o);if(u>=0){for(var c=i.ligatureSets[u],f=0;f<c.length;f++)if(Kc(c[f].components,a))return;c.push(l)}else u=-1-u,i.coverage.glyphs.splice(u,0,o),i.ligatureSets.splice(u,0,[l])};it.prototype.getFeature=function(t,e,n){if(/ss\d\d/.test(t))return this.getSingle(t,e,n);switch(t){case"aalt":case"salt":return this.getSingle(t,e,n).concat(this.getAlternates(t,e,n));case"dlig":case"liga":case"rlig":return this.getLigatures(t,e,n);case"ccmp":return this.getMultiple(t,e,n).concat(this.getLigatures(t,e,n));case"stch":return this.getMultiple(t,e,n)}};it.prototype.add=function(t,e,n,r){if(/ss\d\d/.test(t))return this.addSingle(t,e,n,r);switch(t){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(t,e,n,r):this.addAlternate(t,e,n,r);case"dlig":case"liga":case"rlig":return this.addLigature(t,e,n,r);case"ccmp":return e.by instanceof Array?this.addMultiple(t,e,n,r):this.addLigature(t,e,n,r)}};function Jc(){return typeof window<"u"}function Qc(t){for(var e=new Buffer(t.byteLength),n=new Uint8Array(t),r=0;r<e.length;++r)e[r]=n[r];return e}function nr(t,e){if(!t)throw e}function Go(t,e,n,r,s){var i;return(e&r)>0?(i=t.parseByte(),(e&s)===0&&(i=-i),i=n+i):(e&s)>0?i=n:i=n+t.parseShort(),i}function Ga(t,e,n){var r=new ee.Parser(e,n);t.numberOfContours=r.parseShort(),t._xMin=r.parseShort(),t._yMin=r.parseShort(),t._xMax=r.parseShort(),t._yMax=r.parseShort();var s,i;if(t.numberOfContours>0){for(var o=t.endPointIndices=[],a=0;a<t.numberOfContours;a+=1)o.push(r.parseUShort());t.instructionLength=r.parseUShort(),t.instructions=[];for(var l=0;l<t.instructionLength;l+=1)t.instructions.push(r.parseByte());var u=o[o.length-1]+1;s=[];for(var c=0;c<u;c+=1)if(i=r.parseByte(),s.push(i),(i&8)>0)for(var f=r.parseByte(),h=0;h<f;h+=1)s.push(i),c+=1;if(ue.argument(s.length===u,"Bad flags."),o.length>0){var p=[],d;if(u>0){for(var g=0;g<u;g+=1)i=s[g],d={},d.onCurve=!!(i&1),d.lastPointOfContour=o.indexOf(g)>=0,p.push(d);for(var m=0,x=0;x<u;x+=1)i=s[x],d=p[x],d.x=Go(r,i,m,2,16),m=d.x;for(var w=0,v=0;v<u;v+=1)i=s[v],d=p[v],d.y=Go(r,i,w,4,32),w=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 T=!0;T;){s=r.parseUShort();var P={glyphIndex:r.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(P.dx=r.parseShort(),P.dy=r.parseShort()):P.matchedPoints=[r.parseUShort(),r.parseUShort()]:(s&2)>0?(P.dx=r.parseChar(),P.dy=r.parseChar()):P.matchedPoints=[r.parseByte(),r.parseByte()],(s&8)>0?P.xScale=P.yScale=r.parseF2Dot14():(s&64)>0?(P.xScale=r.parseF2Dot14(),P.yScale=r.parseF2Dot14()):(s&128)>0&&(P.xScale=r.parseF2Dot14(),P.scale01=r.parseF2Dot14(),P.scale10=r.parseF2Dot14(),P.yScale=r.parseF2Dot14()),t.components.push(P),T=!!(s&32)}if(s&256){t.instructionLength=r.parseUShort(),t.instructions=[];for(var O=0;O<t.instructionLength;O+=1)t.instructions.push(r.parseByte())}}}function Vs(t,e){for(var n=[],r=0;r<t.length;r+=1){var s=t[r],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};n.push(i)}return n}function ef(t){for(var e=[],n=[],r=0;r<t.length;r+=1){var s=t[r];n.push(s),s.lastPointOfContour&&(e.push(n),n=[])}return ue.argument(n.length===0,"There are still points left in the current contour."),e}function za(t){var e=new ze;if(!t)return e;for(var n=ef(t),r=0;r<n.length;++r){var s=n[r],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 l={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5};e.moveTo(l.x,l.y)}for(var u=0;u<s.length;++u)if(i=o,o=a,a=s[(u+1)%s.length],o.onCurve)e.lineTo(o.x,o.y);else{var c=i,f=a;i.onCurve||(c={x:(o.x+i.x)*.5,y:(o.y+i.y)*.5}),a.onCurve||(f={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5}),e.quadraticCurveTo(o.x,o.y,f.x,f.y)}e.closePath()}return e}function Ha(t,e){if(e.isComposite)for(var n=0;n<e.components.length;n+=1){var r=e.components[n],s=t.get(r.glyphIndex);if(s.getPath(),s.points){var i=void 0;if(r.matchedPoints===void 0)i=Vs(s.points,r);else{if(r.matchedPoints[0]>e.points.length-1||r.matchedPoints[1]>s.points.length-1)throw Error("Matched points out of range in "+e.name);var o=e.points[r.matchedPoints[0]],a=s.points[r.matchedPoints[1]],l={xScale:r.xScale,scale01:r.scale01,scale10:r.scale10,yScale:r.yScale,dx:0,dy:0};a=Vs([a],l)[0],l.dx=o.x-a.x,l.dy=o.y-a.y,i=Vs(s.points,l)}e.points=e.points.concat(i)}}return za(e.points)}function tf(t,e,n,r){for(var s=new Ot.GlyphSet(r),i=0;i<n.length-1;i+=1){var o=n[i],a=n[i+1];o!==a?s.push(i,Ot.ttfGlyphLoader(r,i,Ga,t,e+o,Ha)):s.push(i,Ot.glyphLoader(r,i))}return s}function nf(t,e,n,r){var s=new Ot.GlyphSet(r);return r._push=function(i){var o=n[i],a=n[i+1];o!==a?s.push(i,Ot.ttfGlyphLoader(r,i,Ga,t,e+o,Ha)):s.push(i,Ot.glyphLoader(r,i))},s}function rf(t,e,n,r,s){return s.lowMemory?nf(t,e,n,r):tf(t,e,n,r)}var Va={getPath:za,parse:rf},Xa,un,qa,ri;function Wa(t){this.font=t,this.getCommands=function(e){return Va.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function sf(t){return t}function _a(t){return Math.sign(t)*Math.round(Math.abs(t))}function of(t){return Math.sign(t)*Math.round(Math.abs(t*2))/2}function af(t){return Math.sign(t)*(Math.round(Math.abs(t)+.5)-.5)}function lf(t){return Math.sign(t)*Math.ceil(Math.abs(t))}function uf(t){return Math.sign(t)*Math.floor(Math.abs(t))}var ja=function(t){var e=this.srPeriod,n=this.srPhase,r=this.srThreshold,s=1;return t<0&&(t=-t,s=-1),t+=r-n,t=Math.trunc(t/e)*e,t+=n,t<0?n*s:t*s},At={x:1,y:0,axis:"x",distance:function(t,e,n,r){return(n?t.xo:t.x)-(r?e.xo:e.x)},interpolate:function(t,e,n,r){var s,i,o,a,l,u,c;if(!r||r===this){if(s=t.xo-e.xo,i=t.xo-n.xo,l=e.x-e.xo,u=n.x-n.xo,o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){t.x=t.xo+(l+u)/2;return}t.x=t.xo+(l*a+u*o)/c;return}if(s=r.distance(t,e,!0,!0),i=r.distance(t,n,!0,!0),l=r.distance(e,e,!1,!0),u=r.distance(n,n,!1,!0),o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){At.setRelative(t,t,(l+u)/2,r,!0);return}At.setRelative(t,t,(l*a+u*o)/c,r,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(t,e,n,r,s){if(!r||r===this){t.x=(s?e.xo:e.x)+n;return}var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+n*r.x,l=o+n*r.y;t.x=a+(t.y-l)/r.normalSlope},slope:0,touch:function(t){t.xTouched=!0},touched:function(t){return t.xTouched},untouch:function(t){t.xTouched=!1}},Ut={x:0,y:1,axis:"y",distance:function(t,e,n,r){return(n?t.yo:t.y)-(r?e.yo:e.y)},interpolate:function(t,e,n,r){var s,i,o,a,l,u,c;if(!r||r===this){if(s=t.yo-e.yo,i=t.yo-n.yo,l=e.y-e.yo,u=n.y-n.yo,o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){t.y=t.yo+(l+u)/2;return}t.y=t.yo+(l*a+u*o)/c;return}if(s=r.distance(t,e,!0,!0),i=r.distance(t,n,!0,!0),l=r.distance(e,e,!1,!0),u=r.distance(n,n,!1,!0),o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){Ut.setRelative(t,t,(l+u)/2,r,!0);return}Ut.setRelative(t,t,(l*a+u*o)/c,r,!0)},normalSlope:0,setRelative:function(t,e,n,r,s){if(!r||r===this){t.y=(s?e.yo:e.y)+n;return}var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+n*r.x,l=o+n*r.y;t.y=l+r.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(At);Object.freeze(Ut);function cr(t,e){this.x=t,this.y=e,this.axis=void 0,this.slope=e/t,this.normalSlope=-t/e,Object.freeze(this)}cr.prototype.distance=function(t,e,n,r){return this.x*At.distance(t,e,n,r)+this.y*Ut.distance(t,e,n,r)};cr.prototype.interpolate=function(t,e,n,r){var s,i,o,a,l,u,c;if(o=r.distance(t,e,!0,!0),a=r.distance(t,n,!0,!0),s=r.distance(e,e,!1,!0),i=r.distance(n,n,!1,!0),l=Math.abs(o),u=Math.abs(a),c=l+u,c===0){this.setRelative(t,t,(s+i)/2,r,!0);return}this.setRelative(t,t,(s*u+i*l)/c,r,!0)};cr.prototype.setRelative=function(t,e,n,r,s){r=r||this;var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+n*r.x,l=o+n*r.y,u=r.normalSlope,c=this.slope,f=t.x,h=t.y;t.x=(c*f-u*a+l-h)/(c-u),t.y=c*(t.x-f)+h};cr.prototype.touch=function(t){t.xTouched=!0,t.yTouched=!0};function fr(t,e){var n=Math.sqrt(t*t+e*e);return t/=n,e/=n,t===1&&e===0?At:t===0&&e===1?Ut:new cr(t,e)}function Nt(t,e,n,r){this.x=this.xo=Math.round(t*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=n,this.onCurve=r,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Nt.prototype.nextTouched=function(t){for(var e=this.nextPointOnContour;!t.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};Nt.prototype.prevTouched=function(t){for(var e=this.prevPointOnContour;!t.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var ar=Object.freeze(new Nt(0,0)),cf={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function qt(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=At,this.round=_a}}Wa.prototype.exec=function(t,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(!(this._errorState>2)){var n=this.font,r=this._prepState;if(!r||r.ppem!==e){var s=this._fpgmState;if(!s){qt.prototype=cf,s=this._fpgmState=new qt("fpgm",n.tables.fpgm),s.funcs=[],s.font=n,exports.DEBUG&&(console.log("---EXEC FPGM---"),s.step=-1);try{un(s)}catch(u){console.log("Hinting error in FPGM:"+u),this._errorState=3;return}}qt.prototype=s,r=this._prepState=new qt("prep",n.tables.prep),r.ppem=e;var i=n.tables.cvt;if(i)for(var o=r.cvt=new Array(i.length),a=e/n.unitsPerEm,l=0;l<i.length;l++)o[l]=i[l]*a;else r.cvt=[];exports.DEBUG&&(console.log("---EXEC PREP---"),r.step=-1);try{un(r)}catch(u){this._errorState<2&&console.log("Hinting error in PREP:"+u),this._errorState=2}}if(!(this._errorState>1))try{return qa(t,r)}catch(u){this._errorState<1&&(console.log("Hinting error:"+u),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}}};qa=function(t,e){var n=e.ppem/e.font.unitsPerEm,r=n,s=t.components,i,o,a;if(qt.prototype=e,!s)a=new qt("glyf",t.instructions),exports.DEBUG&&(console.log("---EXEC GLYPH---"),a.step=-1),ri(t,a,n,r),o=a.gZone;else{var l=e.font;o=[],i=[];for(var u=0;u<s.length;u++){var c=s[u],f=l.glyphs.get(c.glyphIndex);a=new qt("glyf",f.instructions),exports.DEBUG&&(console.log("---EXEC COMP "+u+"---"),a.step=-1),ri(f,a,n,r);for(var h=Math.round(c.dx*n),p=Math.round(c.dy*r),d=a.gZone,g=a.contours,m=0;m<d.length;m++){var x=d[m];x.xTouched=x.yTouched=!1,x.xo=x.x=x.x+h,x.yo=x.y=x.y+p}var w=o.length;o.push.apply(o,d);for(var v=0;v<g.length;v++)i.push(g[v]+w)}t.instructions&&!a.inhibitGridFit&&(a=new qt("glyf",t.instructions),a.gZone=a.z0=a.z1=a.z2=o,a.contours=i,o.push(new Nt(0,0),new Nt(Math.round(t.advanceWidth*n),0)),exports.DEBUG&&(console.log("---EXEC COMPOSITE---"),a.step=-1),un(a),o.length-=2)}return o};ri=function(t,e,n,r){for(var s=t.points||[],i=s.length,o=e.gZone=e.z0=e.z1=e.z2=[],a=e.contours=[],l,u=0;u<i;u++)l=s[u],o[u]=new Nt(l.x*n,l.y*r,l.lastPointOfContour,l.onCurve);for(var c,f,h=0;h<i;h++)l=o[h],c||(c=l,a.push(h)),l.lastPointOfContour?(l.nextPointOnContour=c,c.prevPointOnContour=l,c=void 0):(f=o[h+1],l.nextPointOnContour=f,f.prevPointOnContour=l);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 Nt(0,0),new Nt(Math.round(t.advanceWidth*n),0)),un(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)}}};un=function(t){var e=t.prog;if(e){var n=e.length,r;for(t.ip=0;t.ip<n;t.ip++){if(exports.DEBUG&&t.step++,r=Xa[e[t.ip]],!r)throw new Error("unknown instruction: 0x"+Number(e[t.ip]).toString(16));r(t)}}};function es(t){for(var e=t.tZone=new Array(t.gZone.length),n=0;n<e.length;n++)e[n]=new Nt(0,0)}function Za(t,e){var n=t.prog,r=t.ip,s=1,i;do if(i=n[++r],i===88)s++;else if(i===89)s--;else if(i===64)r+=n[r+1]+1;else if(i===65)r+=2*n[r+1]+1;else if(i>=176&&i<=183)r+=i-176+1;else if(i>=184&&i<=191)r+=(i-184+1)*2;else if(e&&s===1&&i===27)break;while(s>0);t.ip=r}function zo(t,e){exports.DEBUG&&console.log(e.step,"SVTCA["+t.axis+"]"),e.fv=e.pv=e.dpv=t}function Ho(t,e){exports.DEBUG&&console.log(e.step,"SPVTCA["+t.axis+"]"),e.pv=e.dpv=t}function Vo(t,e){exports.DEBUG&&console.log(e.step,"SFVTCA["+t.axis+"]"),e.fv=t}function Xo(t,e){var n=e.stack,r=n.pop(),s=n.pop(),i=e.z2[r],o=e.z1[s];exports.DEBUG&&console.log("SPVTL["+t+"]",r,s);var a,l;t?(a=i.y-o.y,l=o.x-i.x):(a=o.x-i.x,l=o.y-i.y),e.pv=e.dpv=fr(a,l)}function qo(t,e){var n=e.stack,r=n.pop(),s=n.pop(),i=e.z2[r],o=e.z1[s];exports.DEBUG&&console.log("SFVTL["+t+"]",r,s);var a,l;t?(a=i.y-o.y,l=o.x-i.x):(a=o.x-i.x,l=o.y-i.y),e.fv=fr(a,l)}function ff(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"SPVFS[]",n,r),t.pv=t.dpv=fr(r,n)}function hf(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"SPVFS[]",n,r),t.fv=fr(r,n)}function pf(t){var e=t.stack,n=t.pv;exports.DEBUG&&console.log(t.step,"GPV[]"),e.push(n.x*16384),e.push(n.y*16384)}function df(t){var e=t.stack,n=t.fv;exports.DEBUG&&console.log(t.step,"GFV[]"),e.push(n.x*16384),e.push(n.y*16384)}function gf(t){t.fv=t.pv,exports.DEBUG&&console.log(t.step,"SFVTPV[]")}function mf(t){var e=t.stack,n=e.pop(),r=e.pop(),s=e.pop(),i=e.pop(),o=e.pop(),a=t.z0,l=t.z1,u=a[n],c=a[r],f=l[s],h=l[i],p=t.z2[o];exports.DEBUG&&console.log("ISECT[], ",n,r,s,i,o);var d=u.x,g=u.y,m=c.x,x=c.y,w=f.x,v=f.y,T=h.x,P=h.y,O=(d-m)*(v-P)-(g-x)*(w-T),C=d*x-g*m,L=w*P-v*T;p.x=(C*(w-T)-L*(d-m))/O,p.y=(C*(v-P)-L*(g-x))/O}function xf(t){t.rp0=t.stack.pop(),exports.DEBUG&&console.log(t.step,"SRP0[]",t.rp0)}function yf(t){t.rp1=t.stack.pop(),exports.DEBUG&&console.log(t.step,"SRP1[]",t.rp1)}function vf(t){t.rp2=t.stack.pop(),exports.DEBUG&&console.log(t.step,"SRP2[]",t.rp2)}function bf(t){var e=t.stack.pop();switch(exports.DEBUG&&console.log(t.step,"SZP0[]",e),t.zp0=e,e){case 0:t.tZone||es(t),t.z0=t.tZone;break;case 1:t.z0=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function wf(t){var e=t.stack.pop();switch(exports.DEBUG&&console.log(t.step,"SZP1[]",e),t.zp1=e,e){case 0:t.tZone||es(t),t.z1=t.tZone;break;case 1:t.z1=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Sf(t){var e=t.stack.pop();switch(exports.DEBUG&&console.log(t.step,"SZP2[]",e),t.zp2=e,e){case 0:t.tZone||es(t),t.z2=t.tZone;break;case 1:t.z2=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function kf(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||es(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 Pf(t){t.loop=t.stack.pop(),exports.DEBUG&&console.log(t.step,"SLOOP[]",t.loop)}function Mf(t){exports.DEBUG&&console.log(t.step,"RTG[]"),t.round=_a}function Ef(t){exports.DEBUG&&console.log(t.step,"RTHG[]"),t.round=af}function Lf(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SMD[]",e),t.minDis=e/64}function Tf(t){exports.DEBUG&&console.log(t.step,"ELSE[]"),Za(t,!1)}function If(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"JMPR[]",e),t.ip+=e-1}function Cf(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SCVTCI[]",e),t.cvCutIn=e/64}function Af(t){var e=t.stack;exports.DEBUG&&console.log(t.step,"DUP[]"),e.push(e[e.length-1])}function Xs(t){exports.DEBUG&&console.log(t.step,"POP[]"),t.stack.pop()}function Of(t){exports.DEBUG&&console.log(t.step,"CLEAR[]"),t.stack.length=0}function Ff(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"SWAP[]"),e.push(n),e.push(r)}function Df(t){var e=t.stack;exports.DEBUG&&console.log(t.step,"DEPTH[]"),e.push(e.length)}function Rf(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"LOOPCALL[]",n,r);var s=t.ip,i=t.prog;t.prog=t.funcs[n];for(var o=0;o<r;o++)un(t),exports.DEBUG&&console.log(++t.step,o+1<r?"next loopcall":"done loopcall",o);t.ip=s,t.prog=i}function Uf(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"CALL[]",e);var n=t.ip,r=t.prog;t.prog=t.funcs[e],un(t),t.ip=n,t.prog=r,exports.DEBUG&&console.log(++t.step,"returning from",e)}function Nf(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"CINDEX[]",n),e.push(e[e.length-n])}function Bf(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"MINDEX[]",n),e.push(e.splice(e.length-n,1)[0])}function $f(t){if(t.env!=="fpgm")throw new Error("FDEF not allowed here");var e=t.stack,n=t.prog,r=t.ip,s=e.pop(),i=r;for(exports.DEBUG&&console.log(t.step,"FDEF[]",s);n[++r]!==45;);t.ip=r,t.funcs[s]=n.slice(i+1,r)}function Wo(t,e){var n=e.stack.pop(),r=e.z0[n],s=e.fv,i=e.pv;exports.DEBUG&&console.log(e.step,"MDAP["+t+"]",n);var o=i.distance(r,ar);t&&(o=e.round(o)),s.setRelative(r,ar,o,i),s.touch(r),e.rp0=e.rp1=n}function _o(t,e){var n=e.z2,r=n.length-2,s,i,o;exports.DEBUG&&console.log(e.step,"IUP["+t.axis+"]");for(var a=0;a<r;a++)s=n[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 jo(t,e){for(var n=e.stack,r=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[r],i=e.fv,o=e.pv,a=e.loop,l=e.z2;a--;){var u=n.pop(),c=l[u],f=o.distance(s,s,!1,!0);i.setRelative(c,c,f,o),i.touch(c),exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-a)+": ":"")+"SHP["+(t?"rp1":"rp2")+"]",u)}e.loop=1}function Zo(t,e){var n=e.stack,r=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[r],i=e.fv,o=e.pv,a=n.pop(),l=e.z2[e.contours[a]],u=l;exports.DEBUG&&console.log(e.step,"SHC["+t+"]",a);var c=o.distance(s,s,!1,!0);do u!==s&&i.setRelative(u,u,c,o),u=u.nextPointOnContour;while(u!==l)}function Yo(t,e){var n=e.stack,r=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[r],i=e.fv,o=e.pv,a=n.pop();exports.DEBUG&&console.log(e.step,"SHZ["+t+"]",a);var l;switch(a){case 0:l=e.tZone;break;case 1:l=e.gZone;break;default:throw new Error("Invalid zone")}for(var u,c=o.distance(s,s,!1,!0),f=l.length-2,h=0;h<f;h++)u=l[h],i.setRelative(u,u,c,o)}function Gf(t){for(var e=t.stack,n=t.loop,r=t.fv,s=e.pop()/64,i=t.z2;n--;){var o=e.pop(),a=i[o];exports.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-n)+": ":"")+"SHPIX[]",o,s),r.setRelative(a,a,s),r.touch(a)}t.loop=1}function zf(t){for(var e=t.stack,n=t.rp1,r=t.rp2,s=t.loop,i=t.z0[n],o=t.z1[r],a=t.fv,l=t.dpv,u=t.z2;s--;){var c=e.pop(),f=u[c];exports.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-s)+": ":"")+"IP[]",c,n,"<->",r),a.interpolate(f,i,o,l),a.touch(f)}t.loop=1}function Ko(t,e){var n=e.stack,r=n.pop()/64,s=n.pop(),i=e.z1[s],o=e.z0[e.rp0],a=e.fv,l=e.pv;a.setRelative(i,o,r,l),a.touch(i),exports.DEBUG&&console.log(e.step,"MSIRP["+t+"]",r,s),e.rp1=e.rp0,e.rp2=s,t&&(e.rp0=s)}function Hf(t){for(var e=t.stack,n=t.rp0,r=t.z0[n],s=t.loop,i=t.fv,o=t.pv,a=t.z1;s--;){var l=e.pop(),u=a[l];exports.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-s)+": ":"")+"ALIGNRP[]",l),i.setRelative(u,r,0,o),i.touch(u)}t.loop=1}function Vf(t){exports.DEBUG&&console.log(t.step,"RTDG[]"),t.round=of}function Jo(t,e){var n=e.stack,r=n.pop(),s=n.pop(),i=e.z0[s],o=e.fv,a=e.pv,l=e.cvt[r];exports.DEBUG&&console.log(e.step,"MIAP["+t+"]",r,"(",l,")",s);var u=a.distance(i,ar);t&&(Math.abs(u-l)<e.cvCutIn&&(u=l),u=e.round(u)),o.setRelative(i,ar,u,a),e.zp0===0&&(i.xo=i.x,i.yo=i.y),o.touch(i),e.rp0=e.rp1=s}function Xf(t){var e=t.prog,n=t.ip,r=t.stack,s=e[++n];exports.DEBUG&&console.log(t.step,"NPUSHB[]",s);for(var i=0;i<s;i++)r.push(e[++n]);t.ip=n}function qf(t){var e=t.ip,n=t.prog,r=t.stack,s=n[++e];exports.DEBUG&&console.log(t.step,"NPUSHW[]",s);for(var i=0;i<s;i++){var o=n[++e]<<8|n[++e];o&32768&&(o=-((o^65535)+1)),r.push(o)}t.ip=e}function Wf(t){var e=t.stack,n=t.store;n||(n=t.store=[]);var r=e.pop(),s=e.pop();exports.DEBUG&&console.log(t.step,"WS",r,s),n[s]=r}function _f(t){var e=t.stack,n=t.store,r=e.pop();exports.DEBUG&&console.log(t.step,"RS",r);var s=n&&n[r]||0;e.push(s)}function jf(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"WCVTP",n,r),t.cvt[r]=n/64}function Zf(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"RCVT",n),e.push(t.cvt[n]*64)}function Qo(t,e){var n=e.stack,r=n.pop(),s=e.z2[r];exports.DEBUG&&console.log(e.step,"GC["+t+"]",r),n.push(e.dpv.distance(s,ar,t,!1)*64)}function ea(t,e){var n=e.stack,r=n.pop(),s=n.pop(),i=e.z1[r],o=e.z0[s],a=e.dpv.distance(o,i,t,t);exports.DEBUG&&console.log(e.step,"MD["+t+"]",r,s,"->",a),e.stack.push(Math.round(a*64))}function Yf(t){exports.DEBUG&&console.log(t.step,"MPPEM[]"),t.stack.push(t.ppem)}function Kf(t){exports.DEBUG&&console.log(t.step,"FLIPON[]"),t.autoFlip=!0}function Jf(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"LT[]",n,r),e.push(r<n?1:0)}function Qf(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"LTEQ[]",n,r),e.push(r<=n?1:0)}function eh(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"GT[]",n,r),e.push(r>n?1:0)}function th(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"GTEQ[]",n,r),e.push(r>=n?1:0)}function nh(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"EQ[]",n,r),e.push(n===r?1:0)}function rh(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"NEQ[]",n,r),e.push(n!==r?1:0)}function sh(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"ODD[]",n),e.push(Math.trunc(n)%2?1:0)}function ih(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"EVEN[]",n),e.push(Math.trunc(n)%2?0:1)}function oh(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"IF[]",e),e||(Za(t,!0),exports.DEBUG&&console.log(t.step,"EIF[]"))}function ah(t){exports.DEBUG&&console.log(t.step,"EIF[]")}function lh(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"AND[]",n,r),e.push(n&&r?1:0)}function uh(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"OR[]",n,r),e.push(n||r?1:0)}function ch(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"NOT[]",n),e.push(n?0:1)}function qs(t,e){var n=e.stack,r=n.pop(),s=e.fv,i=e.pv,o=e.ppem,a=e.deltaBase+(t-1)*16,l=e.deltaShift,u=e.z0;exports.DEBUG&&console.log(e.step,"DELTAP["+t+"]",r,n);for(var c=0;c<r;c++){var f=n.pop(),h=n.pop(),p=a+((h&240)>>4);if(p===o){var d=(h&15)-8;d>=0&&d++,exports.DEBUG&&console.log(e.step,"DELTAPFIX",f,"by",d*l);var g=u[f];s.setRelative(g,g,d*l,i)}}}function fh(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"SDB[]",n),t.deltaBase=n}function hh(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"SDS[]",n),t.deltaShift=Math.pow(.5,n)}function ph(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"ADD[]",n,r),e.push(r+n)}function dh(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"SUB[]",n,r),e.push(r-n)}function gh(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"DIV[]",n,r),e.push(r*64/n)}function mh(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"MUL[]",n,r),e.push(r*n/64)}function xh(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"ABS[]",n),e.push(Math.abs(n))}function yh(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"NEG[]",n),e.push(-n)}function vh(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"FLOOR[]",n),e.push(Math.floor(n/64)*64)}function bh(t){var e=t.stack,n=e.pop();exports.DEBUG&&console.log(t.step,"CEILING[]",n),e.push(Math.ceil(n/64)*64)}function qr(t,e){var n=e.stack,r=n.pop();exports.DEBUG&&console.log(e.step,"ROUND[]"),n.push(e.round(r/64)*64)}function wh(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"WCVTF[]",n,r),t.cvt[r]=n*t.ppem/t.font.unitsPerEm}function Ws(t,e){var n=e.stack,r=n.pop(),s=e.ppem,i=e.deltaBase+(t-1)*16,o=e.deltaShift;exports.DEBUG&&console.log(e.step,"DELTAC["+t+"]",r,n);for(var a=0;a<r;a++){var l=n.pop(),u=n.pop(),c=i+((u&240)>>4);if(c===s){var f=(u&15)-8;f>=0&&f++;var h=f*o;exports.DEBUG&&console.log(e.step,"DELTACFIX",l,"by",h),e.cvt[l]+=h}}}function Sh(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SROUND[]",e),t.round=ja;var n;switch(e&192){case 0:n=.5;break;case 64:n=1;break;case 128:n=2;break;default:throw new Error("invalid SROUND value")}switch(t.srPeriod=n,e&48){case 0:t.srPhase=0;break;case 16:t.srPhase=.25*n;break;case 32:t.srPhase=.5*n;break;case 48:t.srPhase=.75*n;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?t.srThreshold=0:t.srThreshold=(e/8-.5)*n}function kh(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"S45ROUND[]",e),t.round=ja;var n;switch(e&192){case 0:n=Math.sqrt(2)/2;break;case 64:n=Math.sqrt(2);break;case 128:n=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(t.srPeriod=n,e&48){case 0:t.srPhase=0;break;case 16:t.srPhase=.25*n;break;case 32:t.srPhase=.5*n;break;case 48:t.srPhase=.75*n;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?t.srThreshold=0:t.srThreshold=(e/8-.5)*n}function Ph(t){exports.DEBUG&&console.log(t.step,"ROFF[]"),t.round=sf}function Mh(t){exports.DEBUG&&console.log(t.step,"RUTG[]"),t.round=lf}function Eh(t){exports.DEBUG&&console.log(t.step,"RDTG[]"),t.round=uf}function Lh(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SCANCTRL[]",e)}function ta(t,e){var n=e.stack,r=n.pop(),s=n.pop(),i=e.z2[r],o=e.z1[s];exports.DEBUG&&console.log(e.step,"SDPVTL["+t+"]",r,s);var a,l;t?(a=i.y-o.y,l=o.x-i.x):(a=o.x-i.x,l=o.y-i.y),e.dpv=fr(a,l)}function Th(t){var e=t.stack,n=e.pop(),r=0;exports.DEBUG&&console.log(t.step,"GETINFO[]",n),n&1&&(r=35),n&32&&(r|=4096),e.push(r)}function Ih(t){var e=t.stack,n=e.pop(),r=e.pop(),s=e.pop();exports.DEBUG&&console.log(t.step,"ROLL[]"),e.push(r),e.push(n),e.push(s)}function Ch(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"MAX[]",n,r),e.push(Math.max(r,n))}function Ah(t){var e=t.stack,n=e.pop(),r=e.pop();exports.DEBUG&&console.log(t.step,"MIN[]",n,r),e.push(Math.min(r,n))}function Oh(t){var e=t.stack.pop();exports.DEBUG&&console.log(t.step,"SCANTYPE[]",e)}function Fh(t){var e=t.stack.pop(),n=t.stack.pop();switch(exports.DEBUG&&console.log(t.step,"INSTCTRL[]",e,n),e){case 1:t.inhibitGridFit=!!n;return;case 2:t.ignoreCvt=!!n;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Ht(t,e){var n=e.stack,r=e.prog,s=e.ip;exports.DEBUG&&console.log(e.step,"PUSHB["+t+"]");for(var i=0;i<t;i++)n.push(r[++s]);e.ip=s}function Vt(t,e){var n=e.ip,r=e.prog,s=e.stack;exports.DEBUG&&console.log(e.ip,"PUSHW["+t+"]");for(var i=0;i<t;i++){var o=r[++n]<<8|r[++n];o&32768&&(o=-((o^65535)+1)),s.push(o)}e.ip=n}function Q(t,e,n,r,s,i){var o=i.stack,a=t&&o.pop(),l=o.pop(),u=i.rp0,c=i.z0[u],f=i.z1[l],h=i.minDis,p=i.fv,d=i.dpv,g,m,x,w;m=g=d.distance(f,c,!0,!0),x=m>=0?1:-1,m=Math.abs(m),t&&(w=i.cvt[a],r&&Math.abs(m-w)<i.cvCutIn&&(m=w)),n&&m<h&&(m=h),r&&(m=i.round(m)),p.setRelative(f,c,x*m,d),p.touch(f),exports.DEBUG&&console.log(i.step,(t?"MIRP[":"MDRP[")+(e?"M":"m")+(n?">":"_")+(r?"R":"_")+(s===0?"Gr":s===1?"Bl":s===2?"Wh":"")+"]",t?a+"("+i.cvt[a]+","+w+")":"",l,"(d =",g,"->",x*m,")"),i.rp1=i.rp0,i.rp2=l,e&&(i.rp0=l)}Xa=[zo.bind(void 0,Ut),zo.bind(void 0,At),Ho.bind(void 0,Ut),Ho.bind(void 0,At),Vo.bind(void 0,Ut),Vo.bind(void 0,At),Xo.bind(void 0,0),Xo.bind(void 0,1),qo.bind(void 0,0),qo.bind(void 0,1),ff,hf,pf,df,gf,mf,xf,yf,vf,bf,wf,Sf,kf,Pf,Mf,Ef,Lf,Tf,If,Cf,void 0,void 0,Af,Xs,Of,Ff,Df,Nf,Bf,void 0,void 0,void 0,Rf,Uf,$f,void 0,Wo.bind(void 0,0),Wo.bind(void 0,1),_o.bind(void 0,Ut),_o.bind(void 0,At),jo.bind(void 0,0),jo.bind(void 0,1),Zo.bind(void 0,0),Zo.bind(void 0,1),Yo.bind(void 0,0),Yo.bind(void 0,1),Gf,zf,Ko.bind(void 0,0),Ko.bind(void 0,1),Hf,Vf,Jo.bind(void 0,0),Jo.bind(void 0,1),Xf,qf,Wf,_f,jf,Zf,Qo.bind(void 0,0),Qo.bind(void 0,1),void 0,ea.bind(void 0,0),ea.bind(void 0,1),Yf,void 0,Kf,void 0,void 0,Jf,Qf,eh,th,nh,rh,sh,ih,oh,ah,lh,uh,ch,qs.bind(void 0,1),fh,hh,ph,dh,gh,mh,xh,yh,vh,bh,qr.bind(void 0,0),qr.bind(void 0,1),qr.bind(void 0,2),qr.bind(void 0,3),void 0,void 0,void 0,void 0,wh,qs.bind(void 0,2),qs.bind(void 0,3),Ws.bind(void 0,1),Ws.bind(void 0,2),Ws.bind(void 0,3),Sh,kh,void 0,void 0,Ph,void 0,Mh,Eh,Xs,Xs,void 0,void 0,void 0,void 0,void 0,Lh,ta.bind(void 0,0),ta.bind(void 0,1),Th,void 0,Ih,Ch,Ah,Oh,Fh,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,Ht.bind(void 0,1),Ht.bind(void 0,2),Ht.bind(void 0,3),Ht.bind(void 0,4),Ht.bind(void 0,5),Ht.bind(void 0,6),Ht.bind(void 0,7),Ht.bind(void 0,8),Vt.bind(void 0,1),Vt.bind(void 0,2),Vt.bind(void 0,3),Vt.bind(void 0,4),Vt.bind(void 0,5),Vt.bind(void 0,6),Vt.bind(void 0,7),Vt.bind(void 0,8),Q.bind(void 0,0,0,0,0,0),Q.bind(void 0,0,0,0,0,1),Q.bind(void 0,0,0,0,0,2),Q.bind(void 0,0,0,0,0,3),Q.bind(void 0,0,0,0,1,0),Q.bind(void 0,0,0,0,1,1),Q.bind(void 0,0,0,0,1,2),Q.bind(void 0,0,0,0,1,3),Q.bind(void 0,0,0,1,0,0),Q.bind(void 0,0,0,1,0,1),Q.bind(void 0,0,0,1,0,2),Q.bind(void 0,0,0,1,0,3),Q.bind(void 0,0,0,1,1,0),Q.bind(void 0,0,0,1,1,1),Q.bind(void 0,0,0,1,1,2),Q.bind(void 0,0,0,1,1,3),Q.bind(void 0,0,1,0,0,0),Q.bind(void 0,0,1,0,0,1),Q.bind(void 0,0,1,0,0,2),Q.bind(void 0,0,1,0,0,3),Q.bind(void 0,0,1,0,1,0),Q.bind(void 0,0,1,0,1,1),Q.bind(void 0,0,1,0,1,2),Q.bind(void 0,0,1,0,1,3),Q.bind(void 0,0,1,1,0,0),Q.bind(void 0,0,1,1,0,1),Q.bind(void 0,0,1,1,0,2),Q.bind(void 0,0,1,1,0,3),Q.bind(void 0,0,1,1,1,0),Q.bind(void 0,0,1,1,1,1),Q.bind(void 0,0,1,1,1,2),Q.bind(void 0,0,1,1,1,3),Q.bind(void 0,1,0,0,0,0),Q.bind(void 0,1,0,0,0,1),Q.bind(void 0,1,0,0,0,2),Q.bind(void 0,1,0,0,0,3),Q.bind(void 0,1,0,0,1,0),Q.bind(void 0,1,0,0,1,1),Q.bind(void 0,1,0,0,1,2),Q.bind(void 0,1,0,0,1,3),Q.bind(void 0,1,0,1,0,0),Q.bind(void 0,1,0,1,0,1),Q.bind(void 0,1,0,1,0,2),Q.bind(void 0,1,0,1,0,3),Q.bind(void 0,1,0,1,1,0),Q.bind(void 0,1,0,1,1,1),Q.bind(void 0,1,0,1,1,2),Q.bind(void 0,1,0,1,1,3),Q.bind(void 0,1,1,0,0,0),Q.bind(void 0,1,1,0,0,1),Q.bind(void 0,1,1,0,0,2),Q.bind(void 0,1,1,0,0,3),Q.bind(void 0,1,1,0,1,0),Q.bind(void 0,1,1,0,1,1),Q.bind(void 0,1,1,0,1,2),Q.bind(void 0,1,1,0,1,3),Q.bind(void 0,1,1,1,0,0),Q.bind(void 0,1,1,1,0,1),Q.bind(void 0,1,1,1,0,2),Q.bind(void 0,1,1,1,0,3),Q.bind(void 0,1,1,1,1,0),Q.bind(void 0,1,1,1,1,1),Q.bind(void 0,1,1,1,1,2),Q.bind(void 0,1,1,1,1,3)];function Tn(t){this.char=t,this.state={},this.activeState=null}function hi(t,e,n){this.contextName=n,this.startIndex=t,this.endOffset=e}function Dh(t,e,n){this.contextName=t,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=n}function yt(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 ts(t){this.eventId=t,this.subscribers=[]}function Rh(t){var e=this,n=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];n.forEach(function(s){Object.defineProperty(e.events,s,{value:new ts(s)})}),t&&n.forEach(function(s){var i=t[s];typeof i=="function"&&e.events[s].subscribe(i)});var r=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];r.forEach(function(s){e.events[s].subscribe(e.updateContextsRanges)})}function Ue(t){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Rh.call(this,t)}Tn.prototype.setState=function(t,e){return this.state[t]=e,this.activeState={key:t,value:this.state[t]},this.activeState};Tn.prototype.getState=function(t){return this.state[t]||null};Ue.prototype.inboundIndex=function(t){return t>=0&&t<this.tokens.length};Ue.prototype.composeRUD=function(t){var e=this,n=!0,r=t.map(function(i){return e[i[0]].apply(e,i.slice(1).concat(n))}),s=function(i){return typeof i=="object"&&i.hasOwnProperty("FAIL")};if(r.every(s))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:r.filter(s)};this.dispatch("composeRUD",[r.filter(function(i){return!s(i)})])};Ue.prototype.replaceRange=function(t,e,n,r){e=e!==null?e:this.tokens.length;var s=n.every(function(o){return o instanceof Tn});if(!isNaN(t)&&this.inboundIndex(t)&&s){var i=this.tokens.splice.apply(this.tokens,[t,e].concat(n));return r||this.dispatch("replaceToken",[t,e,n]),[i,n]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};Ue.prototype.replaceToken=function(t,e,n){if(!isNaN(t)&&this.inboundIndex(t)&&e instanceof Tn){var r=this.tokens.splice(t,1,e);return n||this.dispatch("replaceToken",[t,e]),[r[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};Ue.prototype.removeRange=function(t,e,n){e=isNaN(e)?this.tokens.length:e;var r=this.tokens.splice(t,e);return n||this.dispatch("removeRange",[r,t,e]),r};Ue.prototype.removeToken=function(t,e){if(!isNaN(t)&&this.inboundIndex(t)){var n=this.tokens.splice(t,1);return e||this.dispatch("removeToken",[n,t]),n}else return{FAIL:"removeToken: invalid token index."}};Ue.prototype.insertToken=function(t,e,n){var r=t.every(function(s){return s instanceof Tn});return r?(this.tokens.splice.apply(this.tokens,[e,0].concat(t)),n||this.dispatch("insertToken",[t,e]),t):{FAIL:"insertToken: invalid token(s)."}};Ue.prototype.registerModifier=function(t,e,n){this.events.newToken.subscribe(function(r,s){var i=[r,s],o=e===null||e.apply(this,i)===!0,a=[r,s];if(o){var l=n.apply(this,a);r.setState(t,l)}}),this.registeredModifiers.push(t)};ts.prototype.subscribe=function(t){return typeof t=="function"?this.subscribers.push(t)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}};ts.prototype.unsubscribe=function(t){this.subscribers.splice(t,1)};yt.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)};yt.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}};Ue.prototype.rangeToText=function(t){if(t instanceof hi)return this.getRangeTokens(t).map(function(e){return e.char}).join("")};Ue.prototype.getText=function(){return this.tokens.map(function(t){return t.char}).join("")};Ue.prototype.getContext=function(t){var e=this.registeredContexts[t];return e||null};Ue.prototype.on=function(t,e){var n=this.events[t];return n?n.subscribe(e):null};Ue.prototype.dispatch=function(t,e){var n=this,r=this.events[t];r instanceof ts&&r.subscribers.forEach(function(s){s.apply(n,e||[])})};Ue.prototype.registerContextChecker=function(t,e,n){if(this.getContext(t))return{FAIL:"context name '"+t+"' is already registered."};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof n!="function")return{FAIL:"missing context end check."};var r=new Dh(t,e,n);return this.registeredContexts[t]=r,this.contextCheckers.push(r),r};Ue.prototype.getRangeTokens=function(t){var e=t.startIndex+t.endOffset;return[].concat(this.tokens.slice(t.startIndex,e))};Ue.prototype.getContextRanges=function(t){var e=this.getContext(t);return e?e.ranges:{FAIL:"context checker '"+t+"' is not registered."}};Ue.prototype.resetContextsRanges=function(){var t=this.registeredContexts;for(var e in t)if(t.hasOwnProperty(e)){var n=t[e];n.ranges=[]}};Ue.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var t=this.tokens.map(function(r){return r.char}),e=0;e<t.length;e++){var n=new yt(t,e);this.runContextCheck(n)}this.dispatch("updateContextsRanges",[this.registeredContexts])};Ue.prototype.setEndOffset=function(t,e){var n=this.getContext(e).openRange.startIndex,r=new hi(n,t,e),s=this.getContext(e).ranges;return r.rangeId=e+"."+s.length,s.push(r),this.getContext(e).openRange=null,r};Ue.prototype.runContextCheck=function(t){var e=this,n=t.index;this.contextCheckers.forEach(function(r){var s=r.contextName,i=e.getContext(s).openRange;if(!i&&r.checkStart(t)&&(i=new hi(n,null,s),e.getContext(s).openRange=i,e.dispatch("contextStart",[s,n])),i&&r.checkEnd(t)){var o=n-i.startIndex+1,a=e.setEndOffset(o,s);e.dispatch("contextEnd",[s,a])}})};Ue.prototype.tokenize=function(t){this.tokens=[],this.resetContextsRanges();var e=Array.from(t);this.dispatch("start");for(var n=0;n<e.length;n++){var r=e[n],s=new yt(e,n);this.dispatch("next",[s]),this.runContextCheck(s);var i=new Tn(r);this.tokens.push(i),this.dispatch("newToken",[i,s])}return this.dispatch("end",[this.tokens]),this.tokens};function Wt(t){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(t)}function Ya(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 _t(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 Uh(t){return/\s/.test(t)}function ot(t){this.font=t,this.features={}}function ln(t){this.id=t.id,this.tag=t.tag,this.substitution=t.substitution}function hr(t,e){if(!t)return-1;switch(e.format){case 1:return e.glyphs.indexOf(t);case 2:for(var n=e.ranges,r=0;r<n.length;r++){var s=n[r];if(t>=s.start&&t<=s.end){var i=t-s.start;return s.index+i}}break;default:return-1}return-1}function Nh(t,e){var n=hr(t,e.coverage);return n===-1?null:t+e.deltaGlyphId}function Bh(t,e){var n=hr(t,e.coverage);return n===-1?null:e.substitute[n]}function _s(t,e){for(var n=[],r=0;r<t.length;r++){var s=t[r],i=e.current;i=Array.isArray(i)?i[0]:i;var o=hr(i,s);o!==-1&&n.push(o)}return n.length!==t.length?-1:n}function $h(t,e){var n=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(t.context.length<n)return[];var r=_s(e.inputCoverage,t);if(r===-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&&_t(i[0].char);)i.shift();var o=new yt(i,0),a=_s(e.lookaheadCoverage,o),l=[].concat(t.backtrack);for(l.reverse();l.length&&_t(l[0].char);)l.shift();if(l.length<e.backtrackCoverage.length)return[];var u=new yt(l,0),c=_s(e.backtrackCoverage,u),f=r.length===e.inputCoverage.length&&a.length===e.lookaheadCoverage.length&&c.length===e.backtrackCoverage.length,h=[];if(f)for(var p=0;p<e.lookupRecords.length;p++)for(var d=e.lookupRecords[p],g=d.lookupListIndex,m=this.getLookupByIndex(g),x=0;x<m.subtables.length;x++){var w=m.subtables[x],v=this.getLookupMethod(m,w),T=this.getSubstitutionType(m,w);if(T==="12")for(var P=0;P<r.length;P++){var O=t.get(P),C=v(O);C&&h.push(C)}}return h}function Gh(t,e){var n=t.current,r=hr(n,e.coverage);if(r===-1)return null;for(var s,i=e.ligatureSets[r],o=0;o<i.length;o++){s=i[o];for(var a=0;a<s.components.length;a++){var l=t.lookahead[a],u=s.components[a];if(l!==u)break;if(a===s.components.length-1)return s}}return null}function zh(t,e){var n=hr(t,e.coverage);return n===-1?null:e.sequences[n]}ot.prototype.getDefaultScriptFeaturesIndexes=function(){for(var t=this.font.tables.gsub.scripts,e=0;e<t.length;e++){var n=t[e];if(n.tag==="DFLT")return n.script.defaultLangSys.featureIndexes}return[]};ot.prototype.getScriptFeaturesIndexes=function(t){var e=this.font.tables;if(!e.gsub)return[];if(!t)return this.getDefaultScriptFeaturesIndexes();for(var n=this.font.tables.gsub.scripts,r=0;r<n.length;r++){var s=n[r];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 l=a.langSys;return l.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()};ot.prototype.mapTagsToFeatures=function(t,e){for(var n={},r=0;r<t.length;r++){var s=t[r].tag,i=t[r].feature;n[s]=i}this.features[e].tags=n};ot.prototype.getScriptFeatures=function(t){var e=this.features[t];if(this.features.hasOwnProperty(t))return e;var n=this.getScriptFeaturesIndexes(t);if(!n)return null;var r=this.font.tables.gsub;return e=n.map(function(s){return r.features[s]}),this.features[t]=e,this.mapTagsToFeatures(e,t),e};ot.prototype.getSubstitutionType=function(t,e){var n=t.lookupType.toString(),r=e.substFormat.toString();return n+r};ot.prototype.getLookupMethod=function(t,e){var n=this,r=this.getSubstitutionType(t,e);switch(r){case"11":return function(s){return Nh.apply(n,[s,e])};case"12":return function(s){return Bh.apply(n,[s,e])};case"63":return function(s){return $h.apply(n,[s,e])};case"41":return function(s){return Gh.apply(n,[s,e])};case"21":return function(s){return zh.apply(n,[s,e])};default:throw new Error("lookupType: "+t.lookupType+" - substFormat: "+e.substFormat+" is not yet supported")}};ot.prototype.lookupFeature=function(t){var e=t.contextParams,n=e.index,r=this.getFeature({tag:t.tag,script:t.script});if(!r)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+t.tag+"' for script '"+t.script+"'.");for(var s=this.getFeatureLookups(r),i=[].concat(e.context),o=0;o<s.length;o++)for(var a=s[o],l=this.getLookupSubtables(a),u=0;u<l.length;u++){var c=l[u],f=this.getSubstitutionType(a,c),h=this.getLookupMethod(a,c),p=void 0;switch(f){case"11":p=h(e.current),p&&i.splice(n,1,new ln({id:11,tag:t.tag,substitution:p}));break;case"12":p=h(e.current),p&&i.splice(n,1,new ln({id:12,tag:t.tag,substitution:p}));break;case"63":p=h(e),Array.isArray(p)&&p.length&&i.splice(n,1,new ln({id:63,tag:t.tag,substitution:p}));break;case"41":p=h(e),p&&i.splice(n,1,new ln({id:41,tag:t.tag,substitution:p}));break;case"21":p=h(e.current),p&&i.splice(n,1,new ln({id:21,tag:t.tag,substitution:p}));break}e=new yt(i,n),!(Array.isArray(p)&&!p.length)&&(p=null)}return i.length?i:null};ot.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 n=this.features[t.script].some(function(r){return r.tag===t.tag});return e&&n};ot.prototype.getLookupSubtables=function(t){return t.subtables||null};ot.prototype.getLookupByIndex=function(t){var e=this.font.tables.gsub.lookups;return e[t]||null};ot.prototype.getFeatureLookups=function(t){return t.lookupListIndexes.map(this.getLookupByIndex.bind(this))};ot.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};this.features.hasOwnProperty(e.script)||this.getScriptFeatures(e.script);var n=this.features[e.script];return n?n.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:"No feature for script "+e.script}};function Hh(t){var e=t.current,n=t.get(-1);return n===null&&Wt(e)||!Wt(n)&&Wt(e)}function Vh(t){var e=t.get(1);return e===null||!Wt(e)}var Xh={startCheck:Hh,endCheck:Vh};function qh(t){var e=t.current,n=t.get(-1);return(Wt(e)||_t(e))&&!Wt(n)}function Wh(t){var e=t.get(1);switch(!0){case e===null:return!0;case(!Wt(e)&&!_t(e)):var n=Uh(e);if(!n)return!0;if(n){var r=!1;if(r=t.lookahead.some(function(s){return Wt(s)||_t(s)}),!r)return!0}break;default:return!1}}var _h={startCheck:qh,endCheck:Wh};function jh(t,e,n){e[n].setState(t.tag,t.substitution)}function Zh(t,e,n){e[n].setState(t.tag,t.substitution)}function Yh(t,e,n){t.substitution.forEach(function(r,s){var i=e[n+s];i.setState(t.tag,r)})}function Kh(t,e,n){var r=e[n];r.setState(t.tag,t.substitution.ligGlyph);for(var s=t.substitution.components.length,i=0;i<s;i++)r=e[n+i+1],r.setState("deleted",!0)}var na={11:jh,12:Zh,63:Yh,41:Kh};function pi(t,e,n){t instanceof ln&&na[t.id]&&na[t.id](t,e,n)}function Jh(t){for(var e=[].concat(t.backtrack),n=e.length-1;n>=0;n--){var r=e[n],s=Ya(r),i=_t(r);if(!s&&!i)return!0;if(s)return!1}return!1}function Qh(t){if(Ya(t.current))return!1;for(var e=0;e<t.lookahead.length;e++){var n=t.lookahead[e],r=_t(n);if(!r)return!0}return!1}function ep(t){var e=this,n="arab",r=this.featuresTags[n],s=this.tokenizer.getRangeTokens(t);if(s.length!==1){var i=new yt(s.map(function(a){return a.getState("glyphIndex")}),0),o=new yt(s.map(function(a){return a.char}),0);s.forEach(function(a,l){if(!_t(a.char)){i.setCurrentIndex(l),o.setCurrentIndex(l);var u=0;Jh(o)&&(u|=1),Qh(o)&&(u|=2);var c;switch(u){case 1:c="fina";break;case 2:c="init";break;case 3:c="medi";break}if(r.indexOf(c)!==-1){var f=e.query.lookupFeature({tag:c,script:n,contextParams:i});if(f instanceof Error)return console.info(f.message);f.forEach(function(h,p){h instanceof ln&&(pi(h,s,p),i.context[p]=h.substitution)})}}})}}function ra(t,e){var n=t.map(function(r){return r.activeState.value});return new yt(n,e||0)}function tp(t){var e=this,n="arab",r=this.tokenizer.getRangeTokens(t),s=ra(r);s.context.forEach(function(i,o){s.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"rlig",script:n,contextParams:s});a.length&&(a.forEach(function(l){return pi(l,r,o)}),s=ra(r))})}function np(t){var e=t.current,n=t.get(-1);return n===null&&_r(e)||!_r(n)&&_r(e)}function rp(t){var e=t.get(1);return e===null||!_r(e)}var sp={startCheck:np,endCheck:rp};function sa(t,e){var n=t.map(function(r){return r.activeState.value});return new yt(n,e||0)}function ip(t){var e=this,n="latn",r=this.tokenizer.getRangeTokens(t),s=sa(r);s.context.forEach(function(i,o){s.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"liga",script:n,contextParams:s});a.length&&(a.forEach(function(l){return pi(l,r,o)}),s=sa(r))})}function wt(t){this.baseDir=t||"ltr",this.tokenizer=new Ue,this.featuresTags={}}wt.prototype.setText=function(t){this.text=t};wt.prototype.contextChecks={latinWordCheck:sp,arabicWordCheck:Xh,arabicSentenceCheck:_h};function js(t){var e=this.contextChecks[t+"Check"];return this.tokenizer.registerContextChecker(t,e.startCheck,e.endCheck)}function op(){return js.call(this,"latinWord"),js.call(this,"arabicWord"),js.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function ap(){var t=this,e=this.tokenizer.getContextRanges("arabicSentence");e.forEach(function(n){var r=t.tokenizer.getRangeTokens(n);t.tokenizer.replaceRange(n.startIndex,n.endOffset,r.reverse())})}wt.prototype.registerFeatures=function(t,e){var n=this,r=e.filter(function(s){return n.query.supports({script:t,tag:s})});this.featuresTags.hasOwnProperty(t)?this.featuresTags[t]=this.featuresTags[t].concat(r):this.featuresTags[t]=r};wt.prototype.applyFeatures=function(t,e){if(!t)throw new Error("No valid font was provided to apply features");this.query||(this.query=new ot(t));for(var n=0;n<e.length;n++){var r=e[n];this.query.supports({script:r.script})&&this.registerFeatures(r.script,r.tags)}};wt.prototype.registerModifier=function(t,e,n){this.tokenizer.registerModifier(t,e,n)};function di(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function lp(){var t=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){di.call(this);var n=this.tokenizer.getContextRanges("arabicWord");n.forEach(function(r){ep.call(t,r)})}}function up(){var t=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){var n=this.featuresTags[e];if(n.indexOf("rlig")!==-1){di.call(this);var r=this.tokenizer.getContextRanges("arabicWord");r.forEach(function(s){tp.call(t,s)})}}}function cp(){var t=this,e="latn";if(this.featuresTags.hasOwnProperty(e)){var n=this.featuresTags[e];if(n.indexOf("liga")!==-1){di.call(this);var r=this.tokenizer.getContextRanges("latinWord");r.forEach(function(s){ip.call(t,s)})}}}wt.prototype.checkContextReady=function(t){return!!this.tokenizer.getContext(t)};wt.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(lp.call(this),up.call(this)),this.checkContextReady("latinWord")&&cp.call(this),this.checkContextReady("arabicSentence")&&ap.call(this)};wt.prototype.processText=function(t){(!this.text||this.text!==t)&&(this.setText(t),op.call(this),this.applyFeaturesToContexts())};wt.prototype.getBidiText=function(t){return this.processText(t),this.tokenizer.getText()};wt.prototype.getTextGlyphs=function(t){this.processText(t);for(var e=[],n=0;n<this.tokenizer.tokens.length;n++){var r=this.tokenizer.tokens[n];if(!r.state.deleted){var s=r.activeState.value;e.push(Array.isArray(s)?s[0]:s)}}return e};function Ce(t){t=t||{},t.tables=t.tables||{},t.empty||(nr(t.familyName,"When creating a new Font object, familyName is required."),nr(t.styleName,"When creating a new Font object, styleName is required."),nr(t.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),nr(t.ascender,"When creating a new Font object, ascender is required."),nr(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 Ot.GlyphSet(this,t.glyphs||[]),this.encoding=new ga(this),this.position=new ur(this),this.substitution=new it(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 Wa(this)}})}Ce.prototype.hasChar=function(t){return this.encoding.charToGlyphIndex(t)!==null};Ce.prototype.charToGlyphIndex=function(t){return this.encoding.charToGlyphIndex(t)};Ce.prototype.charToGlyph=function(t){var e=this.charToGlyphIndex(t),n=this.glyphs.get(e);return n||(n=this.glyphs.get(0)),n};Ce.prototype.updateFeatures=function(t){return this.defaultRenderOptions.features.map(function(e){return e.script==="latn"?{script:"latn",tags:e.tags.filter(function(n){return t[n]})}:e})};Ce.prototype.stringToGlyphs=function(t,e){var n=this,r=new wt,s=function(f){return n.charToGlyphIndex(f.char)};r.registerModifier("glyphIndex",null,s);var i=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;r.applyFeatures(this,i);for(var o=r.getTextGlyphs(t),a=o.length,l=new Array(a),u=this.glyphs.get(0),c=0;c<a;c+=1)l[c]=this.glyphs.get(o[c])||u;return l};Ce.prototype.nameToGlyphIndex=function(t){return this.glyphNames.nameToGlyphIndex(t)};Ce.prototype.nameToGlyph=function(t){var e=this.nameToGlyphIndex(t),n=this.glyphs.get(e);return n||(n=this.glyphs.get(0)),n};Ce.prototype.glyphIndexToName=function(t){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(t):""};Ce.prototype.getKerningValue=function(t,e){t=t.index||t,e=e.index||e;var n=this.position.defaultKerningTables;return n?this.position.getKerningValue(n,t,e):this.kerningPairs[t+","+e]||0};Ce.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]};Ce.prototype.forEachGlyph=function(t,e,n,r,s,i){e=e!==void 0?e:0,n=n!==void 0?n:0,r=r!==void 0?r:72,s=Object.assign({},this.defaultRenderOptions,s);var o=1/this.unitsPerEm*r,a=this.stringToGlyphs(t,s),l;if(s.kerning){var u=s.script||this.position.getDefaultScriptName();l=this.position.getKerningTables(u,s.language)}for(var c=0;c<a.length;c+=1){var f=a[c];if(i.call(this,f,e,n,r,s),f.advanceWidth&&(e+=f.advanceWidth*o),s.kerning&&c<a.length-1){var h=l?this.position.getKerningValue(l,f.index,a[c+1].index):this.getKerningValue(f,a[c+1]);e+=h*o}s.letterSpacing?e+=s.letterSpacing*r:s.tracking&&(e+=s.tracking/1e3*r)}return e};Ce.prototype.getPath=function(t,e,n,r,s){var i=new ze;return this.forEachGlyph(t,e,n,r,s,function(o,a,l,u){var c=o.getPath(a,l,u,s,this);i.extend(c)}),i};Ce.prototype.getPaths=function(t,e,n,r,s){var i=[];return this.forEachGlyph(t,e,n,r,s,function(o,a,l,u){var c=o.getPath(a,l,u,s,this);i.push(c)}),i};Ce.prototype.getAdvanceWidth=function(t,e,n){return this.forEachGlyph(t,0,0,e,n,function(){})};Ce.prototype.draw=function(t,e,n,r,s,i){this.getPath(e,n,r,s,i).draw(t)};Ce.prototype.drawPoints=function(t,e,n,r,s,i){this.forEachGlyph(e,n,r,s,i,function(o,a,l,u){o.drawPoints(t,a,l,u)})};Ce.prototype.drawMetrics=function(t,e,n,r,s,i){this.forEachGlyph(e,n,r,s,i,function(o,a,l,u){o.drawMetrics(t,a,l,u)})};Ce.prototype.getEnglishName=function(t){var e=this.names[t];if(e)return e.en};Ce.prototype.validate=function(){var t=this;function e(r,s){}function n(r){var s=t.getEnglishName(r);s&&s.trim().length>0}n("fontFamily"),n("weightName"),n("manufacturer"),n("copyright"),n("version"),this.unitsPerEm>0};Ce.prototype.toTables=function(){return Yc.fontToTable(this)};Ce.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};Ce.prototype.toArrayBuffer=function(){for(var t=this.toTables(),e=t.encode(),n=new ArrayBuffer(e.length),r=new Uint8Array(n),s=0;s<e.length;s++)r[s]=e[s];return n};Ce.prototype.download=function(t){var e=this.getEnglishName("fontFamily"),n=this.getEnglishName("fontSubfamily");t=t||e.replace(/\s/g,"")+"-"+n+".otf";var r=this.toArrayBuffer();if(Jc())if(window.URL=window.URL||window.webkitURL,window.URL){var s=new DataView(r),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 l=bo(),u=Qc(r);l.writeFileSync(t,u)}};Ce.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512};Ce.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};Ce.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function Ka(t,e){var n=JSON.stringify(t),r=256;for(var s in e){var i=parseInt(s);if(!(!i||i<256)){if(JSON.stringify(e[s])===n)return i;r<=i&&(r=i+1)}}return e[r]=t,r}function fp(t,e,n){var r=Ka(e.name,n);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:r}]}function hp(t,e,n){var r={},s=new ee.Parser(t,e);return r.tag=s.parseTag(),r.minValue=s.parseFixed(),r.defaultValue=s.parseFixed(),r.maxValue=s.parseFixed(),s.skip("uShort",1),r.name=n[s.parseUShort()]||{},r}function pp(t,e,n,r){for(var s=Ka(e.name,r),i=[{name:"nameID_"+t,type:"USHORT",value:s},{name:"flags_"+t,type:"USHORT",value:0}],o=0;o<n.length;++o){var a=n[o].tag;i.push({name:"axis_"+t+" "+a,type:"FIXED",value:e.coordinates[a]<<16})}return i}function dp(t,e,n,r){var s={},i=new ee.Parser(t,e);s.name=r[i.parseUShort()]||{},i.skip("uShort",1),s.coordinates={};for(var o=0;o<n.length;++o)s.coordinates[n[o].tag]=i.parseFixed();return s}function gp(t,e){var n=new Z.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:t.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:t.instances.length},{name:"instanceSize",type:"USHORT",value:4+t.axes.length*4}]);n.offsetToData=n.sizeOf();for(var r=0;r<t.axes.length;r++)n.fields=n.fields.concat(fp(r,t.axes[r],e));for(var s=0;s<t.instances.length;s++)n.fields=n.fields.concat(pp(s,t.instances[s],t.axes,e));return n}function mp(t,e,n){var r=new ee.Parser(t,e),s=r.parseULong();ue.argument(s===65536,"Unsupported fvar table version.");var i=r.parseOffset16();r.skip("uShort",1);for(var o=r.parseUShort(),a=r.parseUShort(),l=r.parseUShort(),u=r.parseUShort(),c=[],f=0;f<o;f++)c.push(hp(t,e+i+f*a,n));for(var h=[],p=e+i+o*a,d=0;d<l;d++)h.push(dp(t,p+d*u,c,n));return{axes:c,instances:h}}var xp={make:gp,parse:mp},yp=function(){return{coverage:this.parsePointer(M.coverage),attachPoints:this.parseList(M.pointer(M.uShortList))}},vp=function(){var t=this.parseUShort();if(ue.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()}},bp=function(){return this.parseList(M.pointer(vp))},wp=function(){return{coverage:this.parsePointer(M.coverage),ligGlyphs:this.parseList(M.pointer(bp))}},Sp=function(){return this.parseUShort(),this.parseList(M.pointer(M.coverage))};function kp(t,e){e=e||0;var n=new M(t,e),r=n.parseVersion(1);ue.argument(r===1||r===1.2||r===1.3,"Unsupported GDEF table version.");var s={version:r,classDef:n.parsePointer(M.classDef),attachList:n.parsePointer(yp),ligCaretList:n.parsePointer(wp),markAttachClassDef:n.parsePointer(M.classDef)};return r>=1.2&&(s.markGlyphSets=n.parsePointer(Sp)),s}var Pp={parse:kp},vt=new Array(10);vt[1]=function(){var e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{posFormat:1,coverage:this.parsePointer(M.coverage),value:this.parseValueRecord()};if(n===2)return{posFormat:2,coverage:this.parsePointer(M.coverage),values:this.parseValueRecordList()};ue.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};vt[2]=function(){var e=this.offset+this.relativeOffset,n=this.parseUShort();ue.assert(n===1||n===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var r=this.parsePointer(M.coverage),s=this.parseUShort(),i=this.parseUShort();if(n===1)return{posFormat:n,coverage:r,valueFormat1:s,valueFormat2:i,pairSets:this.parseList(M.pointer(M.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}})))};if(n===2){var o=this.parsePointer(M.classDef),a=this.parsePointer(M.classDef),l=this.parseUShort(),u=this.parseUShort();return{posFormat:n,coverage:r,valueFormat1:s,valueFormat2:i,classDef1:o,classDef2:a,class1Count:l,class2Count:u,classRecords:this.parseList(l,M.list(u,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}}))}}};vt[3]=function(){return{error:"GPOS Lookup 3 not supported"}};vt[4]=function(){return{error:"GPOS Lookup 4 not supported"}};vt[5]=function(){return{error:"GPOS Lookup 5 not supported"}};vt[6]=function(){return{error:"GPOS Lookup 6 not supported"}};vt[7]=function(){return{error:"GPOS Lookup 7 not supported"}};vt[8]=function(){return{error:"GPOS Lookup 8 not supported"}};vt[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Mp(t,e){e=e||0;var n=new M(t,e),r=n.parseVersion(1);return ue.argument(r===1||r===1.1,"Unsupported GPOS table version "+r),r===1?{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(vt)}:{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(vt),variations:n.parseFeatureVariationsList()}}var Ep=new Array(10);function Lp(t){return new Z.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new Z.ScriptList(t.scripts)},{name:"features",type:"TABLE",value:new Z.FeatureList(t.features)},{name:"lookups",type:"TABLE",value:new Z.LookupList(t.lookups,Ep)}])}var Tp={parse:Mp,make:Lp};function Ip(t){var e={};t.skip("uShort");var n=t.parseUShort();ue.argument(n===0,"Unsupported kern sub-table version."),t.skip("uShort",2);var r=t.parseUShort();t.skip("uShort",3);for(var s=0;s<r;s+=1){var i=t.parseUShort(),o=t.parseUShort(),a=t.parseShort();e[i+","+o]=a}return e}function Cp(t){var e={};t.skip("uShort");var n=t.parseULong();n>1&&console.warn("Only the first kern subtable is supported."),t.skip("uLong");var r=t.parseUShort(),s=r&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(),l=t.parseUShort(),u=t.parseShort();e[a+","+l]=u}}return e}function Ap(t,e){var n=new ee.Parser(t,e),r=n.parseUShort();if(r===0)return Ip(n);if(r===1)return Cp(n);throw new Error("Unsupported kern table version ("+r+").")}var Op={parse:Ap};function Fp(t,e,n,r){for(var s=new ee.Parser(t,e),i=r?s.parseUShort:s.parseULong,o=[],a=0;a<n+1;a+=1){var l=i.call(s);r&&(l*=2),o.push(l)}return o}var Dp={parse:Fp};function ia(t,e){for(var n=[],r=12,s=0;s<e;s+=1){var i=ee.getTag(t,r),o=ee.getULong(t,r+4),a=ee.getULong(t,r+8),l=ee.getULong(t,r+12);n.push({tag:i,checksum:o,offset:a,length:l,compression:!1}),r+=16}return n}function Rp(t,e){for(var n=[],r=44,s=0;s<e;s+=1){var i=ee.getTag(t,r),o=ee.getULong(t,r+4),a=ee.getULong(t,r+8),l=ee.getULong(t,r+12),u=void 0;a<l?u="WOFF":u=!1,n.push({tag:i,offset:o,compression:u,compressedLength:a,length:l}),r+=20}return n}function $e(t,e){if(e.compression==="WOFF"){var n=new Uint8Array(t.buffer,e.offset+2,e.compressedLength-2),r=new Uint8Array(e.length);if(Lu(n,r),r.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");var s=new DataView(r.buffer,0);return{data:s,offset:0}}else return{data:t,offset:e.offset}}function Ja(t,e){e=e??{};var n,r,s=new Ce({empty:!0}),i=new DataView(t,0),o,a=[],l=ee.getTag(i,0);if(l==="\0\0\0"||l==="true"||l==="typ1")s.outlinesFormat="truetype",o=ee.getUShort(i,4),a=ia(i,o);else if(l==="OTTO")s.outlinesFormat="cff",o=ee.getUShort(i,4),a=ia(i,o);else if(l==="wOFF"){var u=ee.getTag(i,4);if(u==="\0\0\0")s.outlinesFormat="truetype";else if(u==="OTTO")s.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+l);o=ee.getUShort(i,12),a=Rp(i,o)}else throw new Error("Unsupported OpenType signature "+l);for(var c,f,h,p,d,g,m,x,w,v,T,P,O=0;O<o;O+=1){var C=a[O],L=void 0;switch(C.tag){case"cmap":L=$e(i,C),s.tables.cmap=da.parse(L.data,L.offset),s.encoding=new ma(s.tables.cmap);break;case"cvt ":L=$e(i,C),P=new ee.Parser(L.data,L.offset),s.tables.cvt=P.parseShortList(C.length/2);break;case"fvar":f=C;break;case"fpgm":L=$e(i,C),P=new ee.Parser(L.data,L.offset),s.tables.fpgm=P.parseByteList(C.length);break;case"head":L=$e(i,C),s.tables.head=Ea.parse(L.data,L.offset),s.unitsPerEm=s.tables.head.unitsPerEm,n=s.tables.head.indexToLocFormat;break;case"hhea":L=$e(i,C),s.tables.hhea=La.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":m=C;break;case"ltag":L=$e(i,C),r=Ia.parse(L.data,L.offset);break;case"maxp":L=$e(i,C),s.tables.maxp=Ca.parse(L.data,L.offset),s.numGlyphs=s.tables.maxp.numGlyphs;break;case"name":v=C;break;case"OS/2":L=$e(i,C),s.tables.os2=ni.parse(L.data,L.offset);break;case"post":L=$e(i,C),s.tables.post=Ua.parse(L.data,L.offset),s.glyphNames=new li(s.tables.post);break;case"prep":L=$e(i,C),P=new ee.Parser(L.data,L.offset),s.tables.prep=P.parseByteList(C.length);break;case"glyf":h=C;break;case"loca":w=C;break;case"CFF ":c=C;break;case"kern":x=C;break;case"GDEF":p=C;break;case"GPOS":d=C;break;case"GSUB":g=C;break;case"meta":T=C;break}}var B=$e(i,v);if(s.tables.name=Ra.parse(B.data,B.offset,r),s.names=s.tables.name,h&&w){var A=n===0,F=$e(i,w),te=Dp.parse(F.data,F.offset,s.numGlyphs,A),V=$e(i,h);s.glyphs=Va.parse(V.data,V.offset,te,s,e)}else if(c){var q=$e(i,c);Ma.parse(q.data,q.offset,s,e)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");var re=$e(i,m);if(Ta.parse(s,re.data,re.offset,s.numberOfHMetrics,s.numGlyphs,s.glyphs,e),ju(s,e),x){var U=$e(i,x);s.kerningPairs=Op.parse(U.data,U.offset)}else s.kerningPairs={};if(p){var ae=$e(i,p);s.tables.gdef=Pp.parse(ae.data,ae.offset)}if(d){var de=$e(i,d);s.tables.gpos=Tp.parse(de.data,de.offset),s.position.init()}if(g){var me=$e(i,g);s.tables.gsub=Na.parse(me.data,me.offset)}if(f){var we=$e(i,f);s.tables.fvar=xp.parse(we.data,we.offset,s.names)}if(T){var E=$e(i,T);s.tables.meta=Ba.parse(E.data,E.offset),s.metas=s.tables.meta}return s}var ns=class{constructor(e,n){this.sources=e;this.fallback=n;this.parsed=new Map;this.missing=new Set}names(){return Object.keys(this.sources)}get(e){let n=e||this.fallback||Object.keys(this.sources)[0];if(!n)throw this.missing.add(""),new Error("text() needs a font. Pass fonts to render(), or --font on the command line.");let r=this.parsed.get(n);if(r)return r;let s=mn(this.sources,n);if(!s)throw this.missing.add(n),new Error(`Font "${n}" 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=Ja(i);return this.parsed.set(n,o),o}};function Up(t,e,n){let r={kerning:!0};if(n.spacing===1)return{cmds:t.getPath(e,0,0,n.size,r).commands,advance:t.getAdvanceWidth(e,n.size,r)};let s=[],i=0,o=[...e];return o.forEach((a,l)=>{s.push(...t.getPath(a,i,0,n.size,r).commands),i+=t.getAdvanceWidth(a,n.size,r)*(l<o.length-1?n.spacing:1)}),{cmds:s,advance:i}}function Qa(t,e,n){let{cmds:r,advance:s}=Up(t,e,n),i=r.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=$r(i,Math.max(.005,n.size/2e3));return{polys:[...o.closed,...o.open.filter(a=>a.length>=3)],advance:s}}function el(t,e,n){if(!e)return[];let r=t.get(n.font),{polys:s,advance:i}=Qa(r,e,n),o=Ie(s),a=st(o);if(!a)return[];let l=n.halign==="center"?-i/2:n.halign==="right"?-i:0,u=n.valign==="top"?-a[3]:n.valign==="center"?-(a[1]+a[3])/2:n.valign==="bottom"?-a[1]:0;return o.map(c=>c.map(([f,h])=>[f+l,h+u]))}function tl(t,e,n){let r=t.get(n.font),{polys:s,advance:i}=Qa(r,e,n),o=st(s)??[0,0,0,0];return{advance:i,bounds:[[o[0],o[1]],[o[2],o[3]]],ascent:r.ascender/r.unitsPerEm*n.size,descent:r.descender/r.unitsPerEm*n.size}}var ss=[{name:"engrave",mode:"fill",color:"#000000"},{name:"score",mode:"line",color:"#0000ff"},{name:"cut",mode:"cut",color:"#ff0000"},{name:"guide",mode:"guide",color:"#00a0ff"}],rl={maxParts:1e4,maxSegments:1e4,maxListLength:1e6,maxListItems:3e6,maxTextLength:2e3,maxPoints:2e6,maxOutputPoints:1e6,maxSheets:200,maxCollisionPairs:2e4},Np=100,In=4,nl=8,Bp=t=>{let e=Np,n=r=>{for(let s of r.values()){for(let i of s.regions)e+=i.length;for(let i of s.lines)e+=i.length}};n(t.layers);for(let r of t.parts)n(r.layers);return e},Xe=class{constructor(e,n){this.parent=e;this.caller=n;this.vars=new Map;this.fns=new Map;this.mods=new Map}get(e){let n=this,r=e.startsWith("$");for(;n;){if(n.vars.has(e))return{found:!0,value:n.vars.get(e)};n=r?n.caller??n.parent:n.parent}return{found:!1}}fn(e){for(let n=this;n;n=n.parent){let r=n.fns.get(e);if(r)return r}}mod(e){for(let n=this;n;n=n.parent){let r=n.mods.get(e);if(r)return r}}childCtx(){for(let e=this;e;e=e.parent)if(e.children)return e.children}names(e){let n=[];for(let r=this;r;r=r.parent)n.push(...r[e].keys());return n}},gi=t=>t?`.${t}`:"",$p=["echo","assert","text_width","text_metrics","finger_count"];function rs(t,e){let n="",r=Math.min(2,Math.floor(t.length/3))+.5;for(let s of new Set(e)){if(s===t)continue;let i=s.toLowerCase()===t.toLowerCase()?0:Gp(t,s);i<r&&([n,r]=[s,i])}return n?` Did you mean "${n}"?`:""}function Gp(t,e){if(Math.abs(t.length-e.length)>2)return 3;let n=Array.from({length:t.length+1},(r,s)=>[s,...Array(e.length).fill(0)]);for(let r=1;r<=e.length;r++)n[0][r]=r;for(let r=1;r<=t.length;r++)for(let s=1;s<=e.length;s++)n[r][s]=Math.min(n[r-1][s]+1,n[r][s-1]+1,n[r-1][s-1]+(t[r-1]===e[s-1]?0:1)),r>1&&s>1&&t[r-1]===e[s-2]&&t[r-2]===e[s-1]&&(n[r][s]=Math.min(n[r][s],n[r-2][s-2]+1));return n[t.length][e.length]}var zp=tr,Cn=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(ss.map(e=>[e.name,e]));this.loaded=new Map;this.using=[];this.including=[];this.maxSteps=e.maxSteps??5e6,this.limits={...rl,...e.limits},this.builtins=this.makeBuiltins()}run(e){let n=new Xe,r={$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(r))n.vars.set(o,a);let s=new Xe(n);return{shape:this.block(e.body,s,!0),globals:s,layers:this.layers,echoes:this.echoes,warnings:this.warnings}}tick(e,n=1){if(!((this.steps+=n)<=this.maxSteps))throw new ne(`Stopped after ${this.maxSteps} steps. Is there an endless loop?`,e)}load(e,n){let r=this.loaded.get(e);if(r)return r;let s=mn(zp,e)??this.opts.resolve?.(e);if(typeof s!="string")throw new ne(`Library <${e}> not found`,n);this.loaded.set(e,{body:[]});let{program:i}=mt(s,e);return this.loaded.set(e,i),i}hoist(e,n){for(let r of e)if(r.kind==="module")n.mods.set(r.name,{params:r.params,body:r.body,env:n});else if(r.kind==="function")n.fns.set(r.name,{params:r.params,body:r.body,env:n});else if(r.kind==="use"&&!r.include){this.enter(this.using,r.path,r.pos,"use");try{let s=this.included(this.load(r.path,r.pos).body,new Set([r.path])),i=new Xe(n);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)n.mods.set(o,a);for(let[o,a]of i.fns)n.fns.set(o,a)}finally{this.using.pop()}}}enter(e,n,r,s){if(e.includes(n)){let i=[...e.slice(e.indexOf(n)),n].map(o=>`<${o}>`);throw new ne(i.length===2?`Library ${i[0]} ${s}s itself`:`Libraries ${s} each other in a loop: ${i.join(" \u2192 ")}`,r)}e.push(n)}included(e,n){let r=[];for(let s of e)if(s.kind!=="use"||!s.include)r.push(s);else if(!n.has(s.path)){n.add(s.path);for(let i of this.included(this.load(s.path,s.pos).body,n))r.push(i)}return r}assign(e,n,r){r.vars.set(e,n)}block(e,n,r=!1){this.hoist(e,n);let s=[];for(let i of e){let o=this.stmt(i,n,r);o&&!oo(o)&&s.push(o)}return s.length===1?s[0]:Zn(s)}stmt(e,n,r=!1){switch(this.tick(e.pos),e.kind){case"assign":{let s=this.opts.overrides,i=r&&s&&Object.prototype.hasOwnProperty.call(s,e.name)?s[e.name]:this.expr(e.value,n);return this.assign(e.name,i,n),null}case"module":case"function":return null;case"use":{if(!e.include)return null;this.enter(this.including,e.path,e.pos,"include");try{return this.block(this.load(e.path,e.pos).body,n)}finally{this.including.pop()}}case"block":return this.block(e.body,new Xe(n));case"if":return rt(this.expr(e.cond,n))?this.block(e.then,new Xe(n)):this.block(e.else,new Xe(n));case"let":{let s=new Xe(n);return this.bindSeq(e.assigns,s),this.block(e.body,s)}case"for":{let s=[];return this.loop(e.assigns,n,i=>s.push(this.block(e.body,i))),Zn(s)}case"call":if(e.modifier==="*")return null;{let s=this.callModule(e,n);return e.modifier==="#"||e.modifier==="%"?Ur(s,"guide"):s}}}bindSeq(e,n){for(let r of e)this.assign(r.name,this.expr(r.value,n),n)}iterable(e,n){if(pt(e))try{return kr(e,this.limits.maxListLength)}catch(r){throw new ne(r.message,n)}return Array.isArray(e)?e:typeof e=="string"?[...e]:e===void 0?[]:[e]}loop(e,n,r,s=0,i=new Xe(n)){if(s===e.length)return r(i);let o=e[s];for(let a of this.iterable(this.expr(o.value,i),o.pos)){this.tick(o.pos);let l=new Xe(i);l.vars.set(o.name,a),this.loop(e,n,r,s+1,l)}}evalArgs(e,n,r){let s=[],i=new Map,o=[];for(let a of e){let l=this.expr(a.value,n);a.name===null?s.push(l):i.set(a.name,l),o.push({name:a.name,value:l})}return{pos:s,named:i,all:o,at:r}}bindParams(e,n,r,s,i){let o=e.map(a=>a.name);e.forEach((a,l)=>{let u;n.named.has(a.name)?u=n.named.get(a.name):l<n.pos.length?u=n.pos[l]:u=a.default?this.expr(a.default,r):void 0,r.vars.set(a.name,u)});for(let a of n.named.keys())a.startsWith("$")?r.vars.set(a,n.named.get(a)):o.includes(a)||this.unknownArg(i,a,n.at,o);this.checkCount(i,e.length,n)}checkArgs(e,n){let r=er(e);if(!r)return;let s=r.params.map(i=>i.name);if(!r.anyNamed)for(let i of n.named.keys())!i.startsWith("$")&&!s.includes(i)&&this.unknownArg(`${e}()`,i,n.at,s);r.rest||this.checkCount(`${e}()`,r.params.filter(i=>!i.named).length,n)}checkCount(e,n,r){r.pos.length>n&&this.warn(`${e}: takes ${n===0?"no":`at most ${n}`} positional argument${n===1?"":"s"}, got ${r.pos.length}; the rest are ignored (${Kn(r.at,!1)})`)}unknownArg(e,n,r,s){this.warn(`${e}: unknown argument "${n}"${gi(rs(n,s))} (${Kn(r,!1)})`)}warn(e){this.warnings.includes(e)||this.warnings.push(e)}callModule(e,n){let r=this.evalArgs(e.args,n,e.pos),s=n.mod(e.name);if(s){if(++this.depth>1e3)throw new ne(`Recursion too deep in module ${e.name}(): it calls itself without stopping`,e.pos);try{let f=new Xe(s.env,n);return this.bindParams(s.params,r,f,s.env,`${e.name}()`),f.children={stmts:e.children,env:n},f.vars.set("$children",this.childStmts(e.children).length),this.block(s.body,f)}catch(f){throw this.inCall(f,"module",e.name,e.pos)}finally{this.depth--}}let i=mn(this.builtins,e.name);if(!i){let f=e.name==="color"?" Use layer(), cut(), score() or engrave() instead.":rs(e.name,[...n.names("mods"),...Object.keys(this.builtins)]);throw new ne(`Unknown module ${e.name}().${f}`,e.pos)}this.checkArgs(e.name,r);let o=new Xe(n,n);for(let[f,h]of r.named)f.startsWith("$")&&o.vars.set(f,h);let a=this.childStmts(e.children),l=()=>new Xe(n,o),u={args:r,env:o,children:()=>e.children.length?this.block(e.children,l()):nn(),childList:()=>{let f=l();this.hoist(e.children,f);let h=[];for(let p of e.children){let d=this.stmt(p,f);a.includes(p)&&h.push(d??nn())}return h}},c;try{c=i(u)}catch(f){if(f instanceof ne||f instanceof RangeError)throw f;let h=new ne(`${e.name}(): ${f.message}`,e.pos);throw h.call=e.name,h}if(this.pointCount+=Bp(c),this.pointCount>this.limits.maxPoints)throw new ne(`The shapes have more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes, or a lower $fn.`,e.pos);return c}childStmts(e){return e.filter(n=>n.kind!=="assign"&&n.kind!=="module"&&n.kind!=="function"&&n.kind!=="use")}callFunction(e,n,r,s){if(++this.depth>2e3)throw new ne(`Recursion too deep in ${s}(): it calls itself without stopping`,n.at);try{this.tick(n.at);let i=zt(e)?e.scope:e.env,o=new Xe(i,r);return this.bindParams(e.params,n,o,i,`${s}()`),this.expr(e.body,o)}catch(i){throw this.inCall(i,"function",s,n.at)}finally{this.depth--}}inCall(e,n,r,s){return e instanceof Error&&!(e instanceof ne)&&e.message.includes("call stack")?new ne(`Recursion too deep in ${n==="module"?"module ":""}${r}(): it calls itself without stopping`,s):(e instanceof ne&&e.addFrame(n,r,s),e)}expr(e,n){switch(e.kind){case"num":case"str":case"bool":return e.value;case"undef":return;case"var":{let r=n.get(e.name);if(r.found)return r.value;let s=n.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 ne(`Unknown variable "${e.name}"${gi(rs(e.name,[...n.names("vars"),...n.names("fns")]))}`,e.pos)}case"list":{let r=[];for(let s of e.items)this.listItem(s,n,r,e.pos);return this.charge(In,e.pos),r}case"range":{let r=this.expr(e.start,n),s=this.expr(e.end,n),i=e.step?this.expr(e.step,n):1;if(typeof r!="number"||typeof s!="number"||typeof i!="number")throw new ne("Range values must be numbers",e.pos);return{type:"range",start:r,step:i,end:s}}case"unary":{let r=this.expr(e.arg,n);return e.op==="!"?!rt(r):e.op==="+"?r:this.arith("*",-1,r,e.pos)}case"binary":{if(e.op==="&&")return rt(this.expr(e.left,n))&&rt(this.expr(e.right,n));if(e.op==="||")return rt(this.expr(e.left,n))||rt(this.expr(e.right,n));let r=this.expr(e.left,n),s=this.expr(e.right,n);if(e.op==="=="||e.op==="!=")return Nn(r,s,()=>this.tick(e.pos))===(e.op==="==");if(e.op==="<"||e.op==="<="||e.op===">"||e.op===">="){if(!(typeof r=="number"&&typeof s=="number"||typeof r=="string"&&typeof s=="string"))throw new ne(`Can't compare ${at(r)} ${e.op} ${at(s)}`,e.pos);return e.op==="<"?r<s:e.op==="<="?r<=s:e.op===">"?r>s:r>=s}return this.arith(e.op,r,s,e.pos)}case"ternary":return rt(this.expr(e.cond,n))?this.expr(e.then,n):this.expr(e.else,n);case"index":{let r=this.expr(e.target,n),s=this.expr(e.index,n);if(typeof s!="number")throw new ne(`List index must be a number, got ${at(s)}`,e.pos);return Array.isArray(r)?r[Math.floor(s)]:typeof r=="string"?[...r][Math.floor(s)]:pt(r)?[r.start,r.step,r.end][Math.floor(s)]:void 0}case"member":{let r=this.expr(e.target,n),s={x:0,y:1,z:2}[e.name];return Array.isArray(r)&&s!==void 0?r[s]:pt(r)&&(e.name==="begin"||e.name==="step"||e.name==="end")?e.name==="begin"?r.start:e.name==="step"?r.step:r.end:void 0}case"call":return this.call(e,n);case"lambda":return{type:"function",params:e.params,body:e.body,scope:n};case"let":{let r=new Xe(n);return this.bindSeq(e.assigns,r),this.expr(e.body,r)}}}listItem(e,n,r,s){switch(e.kind){case"item":{let i=this.expr(e.expr,n);this.grow(r,1,s),r.push(i);return}case"each":{let i=this.iterable(this.expr(e.expr,n),s);this.grow(r,i.length,s);for(let o of i)r.push(o);return}case"for":this.loop(e.assigns,n,i=>this.listItem(e.body,i,r,s));return;case"if":rt(this.expr(e.cond,n))?this.listItem(e.then,n,r,s):e.else&&this.listItem(e.else,n,r,s);return;case"let":{let i=new Xe(n);this.bindSeq(e.assigns,i),this.listItem(e.body,i,r,s)}}}grow(e,n,r){if(e.length+n>this.limits.maxListLength)throw new ne(`a list of ${e.length+n} items is more than the limit of ${this.limits.maxListLength}`,r);this.charge(n,r)}charge(e,n){if(this.itemCount+=e,!(this.itemCount<=this.limits.maxListItems))throw new ne(`The lists and strings hold more than ${this.limits.maxListItems} items in all, the limit. Is a loop building more than it needs?`,n)}call(e,n){if(e.callee.kind==="var"){let s=e.callee.name,i=n.get(s);if(!i.found){let o=n.fn(s);if(o)return this.callFunction(o,this.evalArgs(e.args,n,e.pos),n,s);let a=this.specialFunction(s,e,n);if(a.handled)return a.value;let l=mn(bs,s);if(l){let u=this.evalArgs(e.args,n,e.pos);this.checkArgs(s,u);for(let p of Wi(l,u.pos,u.named))this.warn(`${s}(): "${p}" is given by position and by name; the named value is used (${Kn(e.pos,!1)})`);let c={maxLength:this.limits.maxListLength,step:p=>this.tick(e.pos,p),given:u.pos.length+l.params.filter(p=>u.named.has(p)).length},f=_i(l,u.pos,u.named);this.tick(e.pos,ji(s,f,this.limits.maxListLength));let h;try{h=l.run(f,c)}catch(p){if(p instanceof ne)throw p;let d=new ne(p instanceof RangeError?`${s}(): the result is too large`:p.message,e.pos);throw d.call=s,d}return this.checkValue(h,e.pos,s),h}throw new ne(`Unknown function ${s}()${gi(rs(s,[...n.names("fns"),...n.names("vars"),...Object.keys(bs),...$p]))}`,e.pos)}if(!zt(i.value))throw new ne(`"${s}" is a ${at(i.value)}, not a function`,e.pos);return this.callFunction(i.value,this.evalArgs(e.args,n,e.pos),n,s)}let r=this.expr(e.callee,n);if(!zt(r))throw new ne(`Can't call a ${at(r)}`,e.pos);return this.callFunction(r,this.evalArgs(e.args,n,e.pos),n,"function")}specialFunction(e,n,r){if(e==="echo"){let s=this.evalArgs(n.args,r,n.pos);return this.echo(this.echoText(s),n.pos),{handled:!0,value:void 0}}if(e==="assert"){let s=this.evalArgs(n.args,r,n.pos);return this.checkArgs(e,s),this.assert(s),{handled:!0,value:!0}}if(e==="text_width"||e==="text_metrics"){let s=this.evalArgs(n.args,r,n.pos);this.checkArgs(e,s);let i=this.measure(s,r);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(n.args,r,n.pos);this.checkArgs(e,s);let i=this.num(this.arg(s,"length",0),"finger_count","length");return{handled:!0,value:sn(i,this.fingerWidth(s,r,1))}}return{handled:!1}}assert(e){if(rt(this.arg(e,"condition",0)))return;let n=this.arg(e,"message",1);throw new ne(`Assertion failed${n===void 0?"":": "+dt(n)}`,e.at)}echo(e,n){this.charge(Math.ceil(e.length/nl),n),this.echoes.push(e)}echoText(e){let n=this.limits.maxListLength,r=[],s=0,i=(o,a,l)=>{r.length&&(s+=2);let u=xn(a,n-s-o.length,l);if(s+=o.length+u.text.length,!u.whole)throw new ne(`echo(): the text would be longer than the limit of ${n} characters`,e.at);r.push(o+u.text)};for(let{name:o,value:a}of e.all)o===null?i("",a,!1):i(`${o} = `,a,!0);return r.join(", ")}arith(e,n,r,s){if(typeof n=="number"&&typeof r=="number")switch(e){case"+":return n+r;case"-":return n-r;case"*":return n*r;case"/":return n/r;case"%":return n%r;case"^":return Math.pow(n,r)}if(e==="+"&&typeof n=="string"&&typeof r=="string")return this.checkSize(n.length+r.length,!0,s),n+r;if(Array.isArray(n)&&Array.isArray(r)){if(e==="+"||e==="-"){if(n.length!==r.length)throw new ne(`Can't ${e==="+"?"add":"subtract"} lists of length ${n.length} and ${r.length}`,s);return this.charge(n.length+In,s),n.map((o,a)=>this.arith(e,o,r[a],s))}if(e==="*"){if(Array.isArray(n[0]))return this.charge(n.length+In,s),n.map(a=>this.arith("*",a,r,s));let o=(a,l)=>{let u=this.arith("*",a,l,s);if(typeof u!="number")throw new ne("Can't multiply these lists: an item times an item is not a number",s);return u};if(Array.isArray(r[0])){let a=r[0].length;if(n.length!==r.length||r.some(l=>!Array.isArray(l)||l.length!==a))throw new ne(`Can't multiply a list of length ${n.length} by a matrix: it needs ${n.length} rows of the same length`,s);return this.checkSize(a,!1,s),this.tick(s,a*n.length),Array.from({length:a},(l,u)=>n.reduce((c,f,h)=>c+o(f,r[h][u]),0))}if(n.length!==r.length)throw new ne(`Can't multiply lists of length ${n.length} and ${r.length}`,s);return this.tick(s,n.length),n.reduce((a,l,u)=>a+o(l,r[u]),0)}}if(Array.isArray(n)&&typeof r=="number"&&(e==="*"||e==="/"))return this.charge(n.length+In,s),n.map(o=>this.arith(e,o,r,s));if(typeof n=="number"&&Array.isArray(r)&&e==="*")return this.charge(r.length+In,s),r.map(o=>this.arith(e,n,o,s));let i={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"take remainder of","^":"raise"};throw new ne(`Can't ${i[e]??e} ${at(n)} and ${at(r)}`,s)}arg(e,n,r,s){return e.named.has(n)?e.named.get(n):r>=0&&r<e.pos.length?e.pos[r]:s}num(e,n,r){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${r} must be a finite number, got ${Jt(e)}`);return e}vec2(e,n,r=!0){let s=i=>typeof i=="number"&&Number.isFinite(i);if(s(e)&&r)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(`${n} must be a number or [x, y], got ${Jt(e)}`)}vec3(e,n){let r=s=>typeof s=="number"&&Number.isFinite(s);if(Array.isArray(e)&&(e.length===2||e.length===3)&&e.every(r))return[e[0],e[1],e[2]??0];throw new Error(`${n} must be [x, y, z], got ${Jt(e)}`)}placements(e,n,r){let s=(a,l)=>a===void 0?[[0,0,0]]:Array.isArray(a)&&a.length>0&&Array.isArray(a[0])?a.map((u,c)=>this.vec3(u,`${l}[${c}]`)):[this.vec3(a,l)],i=s(e,"at"),o=s(n,"rotate");for(let[a,l]of[[i,"at"],[o,"rotate"]])if(a.length!==1&&a.length!==r)throw new Error(`${l} needs one placement per copy: qty is ${r} but ${l} has ${a.length}`);return Array.from({length:r},(a,l)=>({at:i[i.length===1?0:l],rotate:o[o.length===1?0:l]}))}points(e,n){if(!Array.isArray(e))throw new Error(`${n} must be a list of [x, y] points`);return e.map((r,s)=>{if(!Array.isArray(r)||!Number.isFinite(r[0])||!Number.isFinite(r[1]))throw new Error(`${n}[${s}] must be an [x, y] point, got ${Jt(r)}`);return[r[0],r[1]]})}dyn(e,n){return e.get(n).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,n,r){(Array.isArray(e)||typeof e=="string")&&this.checkSize(e.length,typeof e=="string",n,r)}checkSize(e,n,r,s){if(e>this.limits.maxListLength)throw new ne(`${s?`${s}(): `:""}${n?`a string of ${e} characters`:`a list of ${e} items`} is more than the limit of ${this.limits.maxListLength}`,r);this.charge(n?Math.ceil(e/nl):e+In,r)}segs(e){let n=je(this.dyn(e,"$fn"))||0,r=je(this.dyn(e,"$fa"))||2,s=je(this.dyn(e,"$fs"))||.2,i=this.limits.maxSegments;return o=>{let a=fo(o,n,r,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 n=this.dyn(e,"$thickness");if(typeof n!="number"||n<=0)throw new Error("$thickness must be a positive number");return n}fingerWidth(e,n,r){let s=this.arg(e,"finger",r);return typeof s=="number"&&s>0?s:Math.max(3*this.thickness(n),6)}measure(e,n){if(!this.opts.fonts)throw new ne("text needs a font. Pass fonts to render(), or --font on the command line.",e.at);let r=xn(this.arg(e,"text",0,""),this.limits.maxTextLength);if(!r.whole)throw new ne(`the text is more than ${this.limits.maxTextLength} characters, the limit for one text()`,e.at);this.tick(e.at,r.text.length);try{return tl(this.opts.fonts,r.text,this.textOpts(e,n))}catch(s){throw s instanceof ne?s:new ne(s.message,e.at)}}textOpts(e,n){return{size:this.num(this.arg(e,"size",1,10),"text","size"),font:dt(this.arg(e,"font",2,this.dyn(n,"$font")??"")),halign:dt(this.arg(e,"halign",-1,"left")),valign:dt(this.arg(e,"valign",-1,"baseline")),spacing:je(this.arg(e,"spacing",-1,1))}}edges(e){let n=r=>{if(r==="out"||r==="in"||r==="flat")return r;throw new Error(`edges must be "out", "in" or "flat", got ${Jt(r)}`)};if(typeof e=="string")return[n(e),n(e),n(e),n(e)];if(Array.isArray(e)&&e.length===4)return e.map(n);throw new Error("edges must be one value or a list of 4: [bottom, right, top, left]")}makeBuiltins(){let e=(i,o)=>Rr(i.children(),o),n=i=>o=>Ur(o.children(),i);return{rect:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0,1),"size"),l=je(this.arg(i.args,"r",-1,0))||0,u=rt(this.arg(i.args,"center",1,!1)),c=ho(o,a,l,this.segs(i.env));return ut(Ie([u?c.map(([f,h])=>[f-o/2,h-a/2]):c]))},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 ut([Sn(a,a,this.segs(i.env)(a))])},ellipse:i=>{let[o,a]=this.vec2(this.arg(i.args,"r",0,1),"r");return ut([Sn(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 ut([Sn(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"),l=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 u=[];for(let c=0;c<o*2;c++){let f=Math.PI/2+Math.PI*c/o,h=c%2?l:a;u.push([h*Math.cos(f),h*Math.sin(f)])}return ut(Ie([u]))},polygon:i=>{let o=this.points(this.arg(i.args,"points",0),"points"),a=this.arg(i.args,"paths",1),l=Array.isArray(a)?a.map(u=>(Array.isArray(u)?u:[]).map(c=>o[je(c)]).filter(Boolean)):[o];return ut(Ie(l,"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=$r(Gr(o),.01),l=this.arg(i.args,"fill",-1,"evenodd")==="nonzero"?"nonzero":"evenodd";return Zn([ut(Ie(a.closed,l)),bn(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 bn([[o,a]])},polyline:i=>{let o=this.points(this.arg(i.args,"points",0),"points"),a=rt(this.arg(i.args,"closed",1,!1));return bn([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"),l=this.num(this.arg(i.args,"end",2,90),"arc","end"),u=Math.max(2,Math.ceil(this.segs(i.env)(o)*Math.abs(l-a)/360));if(!(u<=this.limits.maxSegments))throw new Error(`an arc with ${u} segments is more than the limit of ${this.limits.maxSegments}`);let c=[];for(let f=0;f<=u;f++){let h=(a+(l-a)*f/u)*Math.PI/180;c.push([o*Math.cos(h),o*Math.sin(h)])}return bn([c])},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=xn(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),ut(el(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),l=(Array.isArray(o)?je(o[2]??0):this.num(o,"rotate","a"))*Math.PI/180,u=Math.cos(l),c=Math.sin(l),f=this.arg(i.args,"center",-1),h=[u,c,-c,u,0,0];if(f!==void 0){let[p,d]=this.vec2(f,"center",!1);h=[u,c,-c,u,p-u*p+c*d,d-c*p-u*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),l=Math.hypot(o,a)||1,u=o/l,c=a/l;return e(i,[1-2*u*u,-2*u*c,-2*u*c,1-2*c*c,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],l=o[1];return e(i,[a[0],l[0],a[1],l[1],a[2]??0,l[2]??0])},union:i=>i.children(),group:i=>i.children(),difference:i=>{let[o,...a]=i.childList();if(!o)return nn();let l=r(a,"difference");return s(o,u=>({regions:Tt(u.regions,l.regions),lines:jn(u.lines,Ie(l.regions),"outside")}))},intersection:i=>{let[o,...a]=i.childList();if(!o)return nn();let l=o;for(let u of a){let c=Ie(r([u],"intersection").regions);l=s(l,f=>({regions:Fr(f.regions,c),lines:jn(f.lines,c,"inside")}))}return l},hull:i=>{let o=i.children(),a=l=>{let u=[],c="cut",f=!0;for(let[p,d]of l){f&&(d.regions.length||d.lines.length)&&(c=p,f=!1);for(let g of[...d.regions,...d.lines])for(let m of g)u.push(m)}let h=co(u);return new Map([[c,{regions:h.length>=3?[h]:[],lines:[]}]])};return{layers:a(o.layers),parts:o.parts.map(l=>({...l,layers:a(l.layers)}))}},offset:i=>{let o=this.arg(i.args,"r",0),a=this.arg(i.args,"delta",-1),l=rt(this.arg(i.args,"chamfer",-1,!1)),u=o!==void 0?this.num(o,"offset","r"):this.num(a??0,"offset","delta"),c=o!==void 0?"round":l?"square":"miter";return s(i.children(),f=>({regions:rn(f.regions,u,c),lines:f.lines}))},stroke:i=>{let o=this.num(this.arg(i.args,"width",0,1),"stroke","width");return s(i.children(),a=>({regions:Ie([...a.regions,...uo(a.lines,o)]),lines:[]}))},outline:i=>s(i.children(),o=>({regions:[],lines:[...o.lines,...Ie(o.regions).map(a=>[...a,a[0]])]})),cut:n("cut"),score:n("score"),engrave:n("engrave"),guide:n("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),l=this.arg(i.args,"color",2),u=this.layers.get(o);if(a!==void 0||l!==void 0||!u){let c=a??u?.mode??"line";if(!["cut","line","fill","guide"].includes(c))throw new Error('mode must be "cut", "line", "fill" or "guide"');let f=dt(l??u?.color??"#00aa00");if(!/^#[0-9a-fA-F]{6}$/.test(f))throw new Error('color must look like "#00aa00"');this.layers.set(o,{name:o,mode:c,color:f})}return Ur(i.children(),o)},part:i=>{let o=dt(this.arg(i.args,"name",0,"part")),a=Math.max(1,Math.floor(je(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 l=this.arg(i.args,"at",-1),u=this.arg(i.args,"rotate",-1),c=l===void 0&&u===void 0?void 0:this.placements(l,u,a),f=i.children();return{layers:new Map,parts:[...f.parts,{name:o,qty:a,layers:f.layers,thickness:this.thickness(i.env),kerf:je(this.dyn(i.env,"$kerf"))||0,material:dt(this.dyn(i.env,"$material")??"material"),...c?{placements:c}:{}}]}},material:i=>{let o=this.arg(i.args,"thickness",0),a=this.arg(i.args,"kerf",1),l=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")),l!==void 0&&i.env.vars.set("$material",dt(l)),i.children()},children:i=>{let o=i.env.childCtx();if(!o)return nn();let a=this.childStmts(o.stmts),l=this.arg(i.args,"index",0),u=new Xe(o.env,i.env);this.hoist(o.stmts,u);let c=new Set;if(l===void 0)a.forEach(h=>c.add(h));else for(let h of this.iterable(l,i.args.at))a[je(h)]&&c.add(a[je(h)]);let f=[];for(let h of o.stmts)if(h.kind==="assign")this.stmt(h,u);else if(c.has(h)){let p=this.stmt(h,u);p&&f.push(p)}return Zn(f)},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"),l=this.edges(this.arg(i.args,"edges",1,"out")),u=this.thickness(i.env),c=this.fingerWidth(i.args,i.env,2);return this.spend(2*(Math.abs(o)+Math.abs(a))/c*4),ut(Nr(o,a,l,u,c))},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 l=this.fingerWidth(i.args,i.env,2);return this.spend(Math.abs(o)/l*4),ut(po(o,a,this.thickness(i.env),l))},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"),[l,u]=this.vec2(this.arg(i.args,"nut",2,[o*1.85,o*.8]),"nut",!1),c=this.num(this.arg(i.args,"nut_at",3,a/2),"tslot","nut_at");return ut(Ie(go(o,a,l,u,c)))},living_hinge:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0),"size"),l=this.num(this.arg(i.args,"spacing",1,1.5),"living_hinge","spacing"),u=this.num(this.arg(i.args,"bridge",2,3),"living_hinge","bridge"),c=this.num(this.arg(i.args,"cut",3,Math.max(u*2,(a-3*u)/2)),"living_hinge","cut");if(l<=0||u<=0||c<=0)throw new Error("spacing, bridge and cut must be positive");return this.spend((Math.abs(o)/l+1)*(Math.abs(a)/(c+u)+2)*2),bn(mo(o,a,l,u,c))}};function r(i,o){let a={regions:[],lines:[]};for(let l of i){if(l.parts.length)throw new Error(`part() can only be the first child of ${o}()`);for(let u of l.layers.values())for(let c of u.regions)a.regions.push(c)}return a}function s(i,o){let a=l=>{let u=new Map;for(let[c,f]of l)u.set(c,o(f));return u};return{layers:a(i.layers),parts:i.parts.map(l=>({...l,layers:a(l.layers)}))}}}};var An=t=>{let e=Math.round(t*1e3)/1e3;return Object.is(e,-0)?"0":String(e)},mi=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,""");function xi(t,e){let n=[];for(let[r,s]of t){let i=[An(r),An(s)],o=n[n.length-1];(!o||o[0]!==i[0]||o[1]!==i[1])&&n.push(i)}for(;e&&n.length>1&&n[0][0]===n[n.length-1][0]&&n[0][1]===n[n.length-1][1];)n.pop();return n}var On=(t,e)=>`M${xi(t,e).map(([n,r])=>`${n} ${r}`).join("L")}${e?"Z":""}`;function yi(t,e){let n=[];for(let r of e){let s=[],i=[],o=[];for(let a of t){let l=a.layers.get(r.name);if(l){for(let u of l.lines)s.push(On(u,!1));for(let u of l.regions)(Ze(u)<0?i:o).push(On(u,!0))}}(s.length||i.length||o.length)&&n.push({name:r.name,mode:r.mode,color:r.color,d:[...s,...i,...o].join(""),regions:[...i,...o].join(""),lines:s.join("")})}return n}function vi(t,e,n,r){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="${An(e)}mm" height="${An(n)}mm" viewBox="0 0 ${An(e)} ${An(n)}">`];for(let i of r){let o=[],a=[];for(let u of t){let c=u.layers.get(i.name);if(!c)continue;let f=` data-part="${mi(u.part)}"`;if(i.mode==="fill"){c.regions.length&&a.push(`<path${f} d="${c.regions.map(h=>On(h,!0)).join("")}"/>`);for(let h of c.lines)a.push(`<path${f} fill="none" stroke="${i.color}" stroke-width="0.1" d="${On(h,!1)}"/>`);continue}for(let h of c.lines)o.push(`<path${f} d="${On(h,!1)}"/>`);for(let h of c.regions)(Ze(h)<0?o:a).push(`<path${f} d="${On(h,!0)}"/>`)}if(!o.length&&!a.length)continue;let l=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="${mi(i.name)}" inkscape:groupmode="layer" inkscape:label="${mi(i.name)}" data-mode="${i.mode}" ${l}>`,...o,...a,"</g>")}return s.push("</svg>",""),s.join(`
|
|
379
|
+
`)}var Hp={"#ff0000":1,"#ffff00":2,"#00ff00":3,"#00ffff":4,"#0000ff":5,"#ff00ff":6,"#000000":7},Vp=t=>{let e=Hp[t.toLowerCase()];if(e)return e;let[n,r,s]=[1,3,5].map(i=>parseInt(t.slice(i,i+2),16));return n>r&&n>s?1:r>n&&r>s?3:s>n&&s>r?5:7};function Xp(t){let e=a=>a.toUpperCase().replace(/[^A-Z0-9_-]/g,"_"),n=new Set(ss.map(a=>a.name)),r=new Set(t.map(a=>e(a.name))),s=new Set,i=new Map,o=[...t.filter(a=>n.has(a.name)),...t.filter(a=>!n.has(a.name))];for(let a of o){let l=e(a.name);if(s.has(l)){let u=2;for(;r.has(`${l}_${u}`)||s.has(`${l}_${u}`);)u++;l=`${l}_${u}`}s.add(l),i.set(a.name,l)}return i}function sl(t,e,n,r){let s=[],i=(l,u)=>s.push(String(l),String(u)),o=Xp(r);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,r.length);for(let l of r)i(0,"LAYER"),i(2,o.get(l.name)),i(70,0),i(62,Vp(l.color)),i(6,"CONTINUOUS");i(0,"ENDTAB"),i(0,"ENDSEC"),i(0,"SECTION"),i(2,"ENTITIES");let a=(l,u,c)=>{i(0,"POLYLINE"),i(8,l),i(66,1),i(10,0),i(20,0),i(30,0),i(70,c?1:0);for(let[f,h]of xi(u.map(([p,d])=>[p,n-d]),c))i(0,"VERTEX"),i(8,l),i(10,f),i(20,h),i(30,0);i(0,"SEQEND"),i(8,l)};for(let l of r){let u=o.get(l.name),c=[];for(let f of t){let h=f.layers.get(l.name);if(h){for(let p of h.lines)a(u,p,!1);for(let p of h.regions)Ze(p)<0?a(u,p,!0):c.push(p)}}for(let f of c)a(u,f,!0)}return i(0,"ENDSEC"),i(0,"EOF"),s.join(`
|
|
380
380
|
`)+`
|
|
381
|
-
`}var
|
|
382
|
-
`)?.[t.line-1]?.replace(/\r$/,"");if(u!==void 0){let c=String(t.line),f=" ".repeat(c.length),h=u.slice(0,t.col-1),p=
|
|
383
|
-
`)}function
|
|
381
|
+
`}var il=(t,e)=>{let n=0;for(let r=1;r<t.length;r++)n+=Math.hypot(t[r][0]-t[r-1][0],t[r][1]-t[r-1][1]);return e&&t.length>2&&(n+=Math.hypot(t[0][0]-t[t.length-1][0],t[0][1]-t[t.length-1][1])),n},Zt=t=>Math.round(t*100)/100;function qp(t,e={}){for(let[S,D]of Object.entries(e.params??{}))try{xs(S,D)}catch($){throw new ne($.message)}let{program:n}=mt(t),r=e.fonts?new ns(e.fonts,e.defaultFont):void 0,s=new Cn({overrides:e.params,resolve:e.resolve,fonts:r,maxSteps:e.maxSteps,limits:e.limits}),i=s.limits,o;try{o=s.run(n)}catch(S){let D=S instanceof RangeError?new ne(/call stack/i.test(S.message)?"Recursion too deep: the program calls itself without stopping":"A value grew too large. Is a list or string doubling without end?"):S;throw D instanceof ne&&(D.echoes=s.echoes,D.warnings=[...s.warnings],r?.missing.size&&(D.missingFonts=[...r.missing])),D}let a=S=>o.globals.get(S).value,l=o.warnings,u=o.layers,c=S=>u.get(S)?.mode??"line",f=[...o.shape.parts];[...o.shape.layers.values()].some(S=>S.regions.length||S.lines.length)&&f.unshift({name:"part",qty:1,layers:o.shape.layers,thickness:je(a("$thickness"))||3,kerf:je(a("$kerf"))||0,material:dt(a("$material")??"material")}),f.length||l.push("Nothing to cut: the program made no shapes.");let p=[],d=[],g=[],m=new Set,x=[];for(let S of f){let D=Ie([...S.layers].filter(([le])=>c(le)==="cut").flatMap(([,le])=>le.regions)),$=new Map;for(let[le,y]of S.layers){if(c(le)==="guide"&&!e.guides)continue;let I=Ie(y.regions),H=y.lines.filter(G=>G.length>=2);(c(le)==="line"||c(le)==="guide")&&(H=[...H,...I.map(G=>[...G,G[0]])],I=[]),D.length&&c(le)!=="guide"&&(c(le)!=="cut"&&(I=Fr(I,D)),H=jn(H,D,"inside")),(I.length||H.length)&&$.set(le,{regions:I,lines:H})}if(D.length){let le={name:S.name,thickness:S.thickness,outline:D};if(S.placements){let y=new Set;S.placements.forEach((I,H)=>{let G={...le,copy:H+1,matrix:ms(I),placed:!0};d.push(G);let Y=G.matrix.map(b=>b.toFixed(6)).join(",");y.has(Y)&&m.add(G),y.add(Y)}),y.size<S.placements.length&&l.push(`Copies of part "${S.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 y=0;y<S.qty;y++)g.push({...le,copy:y+1,matrix:ms({at:[0,0,0],rotate:[0,0,0]}),placed:!1})}let _=Dr(D).length;_>1&&l.push(`Part "${S.name}" cuts into ${_} separate pieces. Join them, or make them separate parts.`);let ie=0;for(let[le,y]of $)if(c(le)==="cut"){for(let I of y.regions)ie+=il(I,!0);for(let I of y.lines)ie+=il(I,!1)}let J=Rs($)??[0,0,0,0],he=e.kerf??S.kerf;if(!(Number.isFinite(he)&&he>=0))throw new ne("$kerf must be a number, 0 or more");let Me={name:S.name,qty:S.qty,width:Zt(J[2]-J[0]),height:Zt(J[3]-J[1]),pieces:_,cutLength:Math.round(ie),thickness:S.thickness,kerf:he,material:S.material};if(he>0){for(let[le,y]of $)if(c(le)==="cut"){let I=y.regions.filter(G=>Ze(G)<0).length;y.regions=rn(y.regions,he/2,"round",Math.min(.01,he/20));let H=I-y.regions.filter(G=>Ze(G)<0).length;H>0&&l.push(`Part "${S.name}": ${H} hole${H===1?" is":"s are"} narrower than the ${he} mm kerf and will not be cut.`)}}p.push(Me),x.push({info:Me,layers:$})}let{found:w,complete:v}=zi(d.filter(S=>!m.has(S)),i.maxCollisionPairs);v||l.push(`The assembly has more than ${i.maxCollisionPairs} pairs of touching parts, the limit, so only those were checked for collisions.`);for(let[S,D]of w.slice(0,5))l.push(`Parts "${S.name}"${S.copy>1?` (copy ${S.copy})`:""} and "${D.name}"${D.copy>1?` (copy ${D.copy})`:""} collide in the assembly. Check their edges and where they are placed.`);if(w.length>5&&l.push(`${w.length-5} more pairs of parts collide in the assembly.`),d.length&&g.length){let S=[...new Set(g.map(D=>`"${D.name}"`))];l.push(`${S.length===1?"Part":"Parts"} ${S.slice(0,5).join(", ")}${S.length>5?` and ${S.length-5} more`:""} ${S.length===1?"has":"have"} no at or rotate, so ${S.length===1?"it lies":"they lie"} flat beside the assembly.`),d.push(...Gi(d,g))}let T=0;for(let S of x){let D=0;for(let $ of S.layers.values()){for(let _ of $.regions)D+=_.length;for(let _ of $.lines)D+=_.length}T+=D*S.info.qty}if(T>i.maxOutputPoints)throw new ne(`The files would have ${T} points, more than the limit of ${i.maxOutputPoints}. Use fewer copies or simpler shapes.`);let P=e.sheet??a("$sheet");if(!Array.isArray(P)||!(Number.isFinite(P[0])&&P[0]>0)||!(Number.isFinite(P[1])&&P[1]>0))throw new ne("$sheet must be [width, height], both more than 0");let O=e.gap??je(a("$gap")??3),C=e.margin??O;if(!(Number.isFinite(O)&&O>=0))throw new ne("$gap must be a number, 0 or more");if(!(Number.isFinite(C)&&C>=0))throw new ne("margin must be a number, 0 or more");let L=e.layout??(a("$layout")==="none"?"none":"pack"),A=["engrave",...[...u.keys()].filter(S=>!["engrave","score","cut","guide"].includes(S)),"score","cut","guide"].map(S=>u.get(S)).filter(Boolean),F=[],te=[1,0,0,-1,0,0],V=S=>Rs(S)??[0,0,0,0],q=(S,D)=>Rr({layers:S,parts:[]},D).layers;if(L==="none"){let S=[];for(let ie of x)for(let J=0;J<ie.info.qty;J++)S.push({part:ie.info.name,copy:J+1,layers:q(ie.layers,te),rotated:!1});let D=new Map;for(let ie of S)for(let[J,he]of ie.layers){let Me=D.get(J)??{regions:[],lines:[]};for(let le of he.regions)Me.regions.push(le);for(let le of he.lines)Me.lines.push(le);D.set(J,Me)}let $=V(D),_=[1,0,0,1,C-$[0],C-$[1]];for(let ie of S)ie.layers=q(ie.layers,_);F.push(re(S,$[2]-$[0]+2*C,$[3]-$[1]+2*C,x[0]?.info))}else{let S=new Map;for(let D of x){let $=`${D.info.material}|${D.info.thickness}`;S.set($,[...S.get($)??[],D])}for(let D of S.values()){let[$,_]=P,ie=[];for(let G of D){let Y=q(G.layers,te),b=V(Y),W=b[2]-b[0],z=b[3]-b[1],oe=!1;(W>$-2*C||z>_-2*C)&&z<=$-2*C&&W<=_-2*C&&(Y=q(Y,[0,1,-1,0,0,0]),b=V(Y),W=b[2]-b[0],z=b[3]-b[1],oe=!0),(W>$-2*C||z>_-2*C)&&l.push(`Part "${G.info.name}" (${Zt(W)} x ${Zt(z)} mm) is bigger than the ${$} x ${_} mm sheet.`),Y=q(Y,[1,0,0,1,-b[0],-b[1]]);for(let K=0;K<G.info.qty;K++)ie.push({info:G.info,layers:Y,w:W,h:z,copy:K+1,rotated:oe})}ie.sort((G,Y)=>Y.h-G.h||Y.w-G.w);let J=[],he=C,Me=C,le=0,y=0,I=0,H=()=>{if(J.length&&F.length>=i.maxSheets)throw new ne(`The parts need more than ${i.maxSheets} sheets, the limit. Use fewer copies or a bigger $sheet.`);J.length&&F.push(re(J,Math.max(y+C,1),Math.max(I+C,1),D[0].info)),J=[],he=C,Me=C,le=0,y=0,I=0};for(let G of ie)he>C&&he+G.w>$-C&&(he=C,Me+=le+O,le=0),J.length&&Me+G.h>_-C&&H(),J.push({part:G.info.name,copy:G.copy,layers:q(G.layers,[1,0,0,1,he,Me]),rotated:G.rotated}),y=Math.max(y,he+G.w),I=Math.max(I,Me+G.h),he+=G.w+O,le=Math.max(le,G.h);H()}}function re(S,D,$,_){let ie=Zt(D),J=Zt($);return{width:ie,height:J,material:_?.material??"material",thickness:_?.thickness??0,items:S,paths:yi(S,A),svg:vi(S,ie,J,A),dxf:sl(S,ie,J,A)}}let U=F.length===1?F[0]:void 0,ae=U?[]:F.flatMap((S,D)=>{let $=F.slice(0,D).reduce((_,ie)=>_+ie.height+10,0);return S.items.map(_=>({..._,layers:q(_.layers,[1,0,0,1,0,$])}))}),de=Zt(Math.max(1,...F.map(S=>S.width))),me=Zt(Math.max(1,F.reduce((S,D)=>S+D.height,0)+10*Math.max(0,F.length-1))),we=U?U.svg:vi(ae,de,me,A),E=U?U.paths:yi(ae,A);return{sheets:F,width:U?.width??de,height:U?.height??me,paths:E,svg:we,parts:p,assembly:d,layers:A,warnings:l,echoes:o.echoes}}function al(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 n of t.items){if(n.kind!=="item")return{ok:!1};let r=al(n.expr);if(!r.ok||typeof r.value!="number")return{ok:!1};e.push(r.value)}return{ok:!0,value:e}}default:return{ok:!1}}}function ol(t){let e=Number(t.trim());return t.trim()!==""&&Number.isFinite(e)?e:void 0}function Wp(t){let{program:e,comments:n}=mt(t),r=n.filter(a=>a.block&&/^\[[^\]]+\]$/.test(a.text)),s=new Map(n.filter(a=>!a.block&&!a.own).map(a=>[a.line,a.text])),i=new Map(n.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 l=al(a.value);if(!l.ok)continue;let u=r.filter(g=>g.line<=a.pos.line).pop()?.text.slice(1,-1).trim()??"Parameters";if(u.toLowerCase()==="hidden")continue;let c=s.get(a.pos.line),f=i.get(a.pos.line-1)??"",h=l.value,p={name:a.name,caption:f,group:u,type:typeof h=="number"||Array.isArray(h)?"number":typeof h=="boolean"?"boolean":"string",initial:h,span:a.span},d=c?/^\[(.*)\]$/.exec(c.trim()):null;if(d){let g=d[1];if(g.includes(",")||/[a-zA-Z"]/.test(g)&&!/^-?[\d.]+(:-?[\d.]+){0,2}$/.test(g))p.options=g.split(",").map(m=>{let[x,w]=m.split(":").map(P=>P.trim().replace(/^"|"$/g,"")),v=ol(x),T=p.type==="number"&&v!==void 0?v:x;return{name:w??x,value:T}});else{let m=g.split(":").map(ol);m.every(x=>x!==void 0)&&(m.length===1?p.max=m[0]:m.length===2?(p.min=m[0],p.max=m[1]):(p.min=m[0],p.step=m[1],p.max=m[2]))}}o.push(p)}return{parameters:o}}var _p=8,jp=/^(?:[A-Za-z_$][A-Za-z0-9_]*|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?|"(?:[^"\\]|\\.)*"?|<=|>=|==|!=|&&|\|\|)/,Zp=(t,e)=>Math.max(1,jp.exec(t.slice(e-1))?.[0].length??1);function Yp(t,e,n={}){if(!(t instanceof ne))return`error: ${t instanceof Error?t.message:String(t)}`;let r=n.file??"design.kerf",s=(l,u,c)=>`${l?`<${l}>`:r}:${u}:${c}`,i=l=>l===void 0?e:(Object.prototype.hasOwnProperty.call(tr,l)?tr[l]:void 0)??n.resolve?.(l),o=[`error: ${t.reason}`];if(t.line!==void 0&&t.col!==void 0){o.push(` --> ${s(t.file,t.line,t.col)}`);let u=i(t.file)?.split(`
|
|
382
|
+
`)?.[t.line-1]?.replace(/\r$/,"");if(u!==void 0){let c=String(t.line),f=" ".repeat(c.length),h=u.slice(0,t.col-1),p=Zp(u,t.col),d=h.replace(/[^\t]/g," ");o.push(`${f} |`,`${c} | ${u}`,`${f} | ${d}${"^".repeat(p)}`)}}for(let l of Kp(t,s))o.push(` = ${l}`);let a=t.call?er(t.call):void 0;return a&&o.push(` = ${$s(a)}: ${a.doc}`),o.join(`
|
|
383
|
+
`)}function Kp(t,e){let n=i=>`in ${i.kind==="module"?"module ":""}${i.name}(), called at ${e(i.file,i.line,i.col)}${i.count>1?` (${i.count} times)`:""}`,r=t.trace.slice(0,_p).map(n),s=t.trace.length-r.length+t.traceMore;return s&&r.push(`and ${s} more call${s===1?"":"s"}`),r}var ll=new Set(["module","function","if","else","for","let","each","use","include"]),Jp=new Set(["true","false","undef"]),Qp=new Set(["for","if","let","function"]),bi={"(":")","[":"]","{":"}"},ed=new Set(["+","-","*","/","%","^","==","!=","<","<=",">",">=","&&","||","=","?",":"]);function td(t,e){let n=e.pos.offset;if(e.type==="str"&&t[n]==="<")return`<${e.value}>`;if(e.type!=="str")return e.value;let r=n+1;for(;t[r]!=='"';)r+=t[r]==="\\"?2:1;return t.slice(n,r+1)}function wi(t){let{tokens:e}=Jn(t),n=[],r=0,s=0,i=o=>{for(;r<o;)if(t[r]===`
|
|
384
384
|
`)s++,r++;else if(t.startsWith("//",r)){let a=t.indexOf(`
|
|
385
385
|
`,r),l=a<0?t.length:a;n.push({kind:"line",text:t.slice(r,l).trimEnd(),breaks:s}),[s,r]=[0,l]}else if(t.startsWith("/*",r)){let a=t.indexOf("*/",r+2)+2,l=t.slice(r,a).replace(/[ \t\r]+\n/g,`
|
|
386
|
-
`);n.push({kind:"block",text:l,breaks:s}),[s,r]=[0,a]}else r++};for(let o of e){if(i(o.pos.offset),o.type==="eof")break;let a=
|
|
386
|
+
`);n.push({kind:"block",text:l,breaks:s}),[s,r]=[0,a]}else r++};for(let o of e){if(i(o.pos.offset),o.type==="eof")break;let a=td(t,o);n.push({kind:"token",text:a,token:o,breaks:s}),s=0,r=o.pos.offset+a.length}return n}function Si(t,e={}){mt(t);let n=" ".repeat(e.indent??2),r=wi(t),s=[],i=null,o=-1,a=0,l=[],u=0,c=!0,f=0,h=!1,p=0,d=0,g,m,x=()=>l[l.length-1],w=()=>!x()||x().open==="{",v=L=>L.kind==="token"&&!!x()&&L.text===bi[x().open],T=(L,B)=>{i!==null&&s.push(i.trimEnd()),B&&s.length&&s[s.length-1]!==""&&s.push(""),o++,a=L,i=n.repeat(L),m=void 0},P=L=>{if(v(L))return x().outer;if(!w())return!g||g.text===","||bi[g.text]?x().inner:g.role==="header"?d+1:x().inner+1;let B=x()?x().inner:0;return c?B:h?f+1:p+1},O=L=>r.slice(L).find(B=>B.kind==="token");for(let L=0;L<r.length;L++){let B=r[L],A=o<0||B.breaks>0;if(B.kind!=="token"){if(A){let V=O(L),q=V?v(V)?x().inner:P(V):0;T(q,B.breaks>1&&o>=0)}else i+=" ";i+=B.text,m=B;continue}let F=B.text,te=B.token.type;if("*!#%".includes(F)&&w()&&!h&&(c||g?.text===")"||g?.text==="else")?B.role="modifier":(F==="!"||(F==="-"||F==="+")&&(!g||nd(g)))&&(B.role="unary"),F===":"){let V=x();(V?V.ternaries:u)?V?V.ternaries--:u--:V?.open==="["&&(B.role="range")}if(A){let V=P(B);T(V,B.breaks>1&&o>=0),w()&&!v(B)&&(p=V)}else m&&rd(m,B)&&(i+=" ");if(w()&&c&&!v(B)&&(f=a,h=te==="id"&&r[L+1]?.kind==="token"&&r[L+1].text==="="||F==="function",c=!1),i+=F,bi[F]){let V=x(),q=V&&V.line===o&&V.open!=="{"&&F!=="{";l.push({open:F,outer:a,inner:q?V.inner:a+1,line:o,ternaries:0,header:F==="("&&!!g&&Qp.has(g.text)&&g.token?.type==="id"}),F==="{"&&(c=!0)}else if(v(B)){let V=l.pop();V.header&&(B.role="header",d=V.outer),F==="}"&&(c=!0)}else F===";"&&w()||te==="str"&&F.startsWith("<")&&w()?c=!0:F==="?"&&(x()?x().ternaries++:u++);g=B,m=B}for(i!==null&&s.push(i.trimEnd());s.length&&s[s.length-1]==="";)s.pop();let C=s.length?s.join(`
|
|
387
387
|
`)+`
|
|
388
|
-
`:"";return
|
|
388
|
+
`:"";return sd(t,C),C}var nd=t=>ed.has(t.text)||["(","[",",","{",";","}"].includes(t.text)||t.token?.type==="id"&&ll.has(t.text)||t.role==="unary"||t.role==="modifier";function rd(t,e){if(t.kind!=="token"||e.kind!=="token")return!0;let n=t.text,r=e.text;if(r===","||r===";"||r===")"||r==="]"||n==="("||n==="["||n==="{"&&r==="}"||n==="."||r==="."||t.role==="unary"||t.role==="modifier"||t.role==="range"||e.role==="range")return!1;let s=t.token,i=s.type==="num"||s.type==="str"&&!n.startsWith("<")||s.type==="id"&&(!ll.has(n)||Jp.has(n))||n===")"&&t.role!=="header"||n==="]";return r==="("?n==="for"||n==="if"||n==="let"||!i&&n!=="function":r==="["?!i:!0}function sd(t,e){let n=wi(t),r=wi(e);if(!(n.length===r.length&&n.every((i,o)=>i.kind===r[o].kind&&i.text===r[o].text)))throw new ne("The formatter would change the program, so it was left as it is")}var id={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};function ul(t,e={}){return t.replace(/&(#x[0-9a-fA-F]+|#\d+|[A-Za-z_][\w.-]*);/g,(n,r)=>{if(r[0]==="#"){let s=r[1]==="x"?parseInt(r.slice(2),16):parseInt(r.slice(1),10);return Number.isFinite(s)&&s<=1114111?String.fromCodePoint(s):n}return id[r]??e[r]??n})}function cl(t){let e=[],n={},r={name:"#document",attrs:{},children:[],text:""},s=[r],i=0,o=l=>{let u=t.slice(0,i).split(`
|
|
389
|
+
`).length;throw new Error(`${l} (line ${u})`)};for(;i<t.length;){let l=t.indexOf("<",i),u=l<0?t.length:l;if(u>i&&(s[s.length-1].text+=ul(t.slice(i,u),n)),l<0)break;if(i=l,t.startsWith("<!--",i)){let c=t.indexOf("-->",i+4);c<0&&o("Unclosed comment"),e.push(t.slice(i+4,c)),i=c+3}else if(t.startsWith("<![CDATA[",i)){let c=t.indexOf("]]>",i+9);c<0&&o("Unclosed CDATA section"),s[s.length-1].text+=t.slice(i+9,c),i=c+3}else if(t.startsWith("<?",i)){let c=t.indexOf("?>",i+2);c<0&&o("Unclosed processing instruction"),i=c+2}else if(t.startsWith("<!",i)){let c=0,f=i+2;for(;f<t.length;f++){let p=t[f];if(p==="[")c++;else if(p==="]")c--;else if(p===">"&&c<=0)break}let h=t.slice(i,f);for(let p of h.matchAll(/<!ENTITY\s+([\w.-]+)\s+(["'])([\s\S]*?)\2\s*>/g))n[p[1]]=p[3];i=f+1}else if(t[i+1]==="/"){let c=t.indexOf(">",i);c<0&&o("Unclosed end tag");let f=t.slice(i+2,c).trim(),h=s.pop();(!h||h===r||h.name!==f)&&o(`</${f}> does not match <${h?.name??"nothing"}>`),i=c+1}else{let c=/^<([^\s/>]+)/.exec(t.slice(i,i+256));c||o("Bad tag");let f={name:c[1],attrs:{},children:[],text:""};i+=c[0].length;let h=/\s*([^\s=/>]+)\s*=\s*("([^"]*)"|'([^']*)')|\s*(\/?>)/y;for(;;){h.lastIndex=i;let p=h.exec(t);if(p||o(`Bad attribute in <${f.name}>`),i=h.lastIndex,p[5]){s[s.length-1].children.push(f),p[5]===">"&&s.push(f);break}f.attrs[p[1]]=ul(p[3]??p[4]??"",n)}}}s.length>1&&o(`<${s[s.length-1].name}> is not closed`);let a=r.children[0];if(!a)throw new Error("The file has no elements");return{root:a,comments:e}}var ft={cut:{name:"cut",mode:"cut",color:"#ff0000"},score:{name:"score",mode:"line",color:"#0000ff"},engrave:{name:"engrave",mode:"fill",color:"#000000"},guide:{name:"guide",mode:"guide",color:"#00a0ff"}},Pi={black:"#000000",white:"#ffffff",red:"#ff0000",lime:"#00ff00",green:"#008000",blue:"#0000ff",yellow:"#ffff00",cyan:"#00ffff",aqua:"#00ffff",magenta:"#ff00ff",fuchsia:"#ff00ff",gray:"#808080",grey:"#808080",silver:"#c0c0c0",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",teal:"#008080",orange:"#ffa500"},od=Object.fromEntries(Object.entries(Pi).reverse().map(([t,e])=>[e,t]));function pr(t,e){if(t===void 0)return;if(t=t.trim().toLowerCase(),t==="none"||t==="transparent")return"none";if(t==="currentcolor")return e;if(t.startsWith("url("))return"paint";if(Pi[t])return Pi[t];let n=/^#([0-9a-f]{3,8})$/.exec(t);if(n){let r=n[1];if(r.length===3||r.length===4)return"#"+[...r.slice(0,3)].map(s=>s+s).join("");if(r.length===6||r.length===8)return"#"+r.slice(0,6)}if(n=/^rgba?\(([^)]*)\)$/.exec(t),n){let r=n[1].split(/[\s,/]+/).filter(Boolean);if(r.length>=3){let s=r.slice(0,3).map(i=>{let o=i.endsWith("%")?parseFloat(i)*255/100:parseFloat(i);return Math.max(0,Math.min(255,Math.round(o||0)))});return r[3]!==void 0&&parseFloat(r[3])===0?"none":"#"+s.map(i=>i.toString(16).padStart(2,"0")).join("")}}return"#000000"}var Fn=(t,e)=>Gr(t,Math.PI/12,e),dr=t=>(t.match(/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g)??[]).map(Number);function ad(t){let e=Ds;if(!t)return e;for(let[,n,r]of t.matchAll(/(\w+)\s*\(([^)]*)\)/g)){let s=dr(r),i=(s[0]??0)*Math.PI/180,o=Ds;if(n==="matrix"&&s.length===6)o=s;else if(n==="translate")o=[1,0,0,1,s[0]??0,s[1]??0];else if(n==="scale")o=[s[0]??1,0,0,s[1]??s[0]??1,0,0];else if(n==="rotate"){let a=Math.cos(i),l=Math.sin(i),[u,c]=[s[1]??0,s[2]??0];o=[a,l,-l,a,u-a*u+l*c,c-l*u-a*c]}else n==="skewX"?o=[1,0,Math.tan(i),1,0,0]:n==="skewY"&&(o=[1,Math.tan(i),0,1,0,0]);e=wn(e,o)}return e}function ld(t,e){let n=[],r=[],s=[0,0],i=[0,0],o=(u,c)=>Wn(e,[u,c]),a=(u,c)=>Math.abs(u[0]-c[0])<1e-9&&Math.abs(u[1]-c[1])<1e-9,l=u=>{r.length&&n.push({segs:r,closed:u}),r=[]};for(let u of t)if(u.type==="M")l(!1),s=i=o(u.x,u.y);else if(u.type==="L"){let c=o(u.x,u.y);a(i,c)||r.push({c:"L",a:i,b:c}),i=c}else if(u.type==="Q"){let c=o(u.x1,u.y1),f=o(u.x,u.y);r.push({c:"C",a:i,p1:[i[0]+2/3*(c[0]-i[0]),i[1]+2/3*(c[1]-i[1])],p2:[f[0]+2/3*(c[0]-f[0]),f[1]+2/3*(c[1]-f[1])],b:f}),i=f}else if(u.type==="C"){let c=o(u.x,u.y);r.push({c:"C",a:i,p1:o(u.x1,u.y1),p2:o(u.x2,u.y2),b:c}),i=c}else r.length&&!a(i,s)&&r.push({c:"L",a:i,b:s}),l(!0),i=s;return l(!1),n}var ud=["fill","stroke","stroke-width","fill-rule","display","visibility","opacity","fill-opacity","stroke-opacity","color","font-size","font-family","text-anchor"],cd=new Set(["fill","stroke","stroke-width","fill-rule","visibility","fill-opacity","stroke-opacity","color","font-size","font-family","text-anchor"]);function fl(t){let e={};for(let n of t.split(";")){let r=n.indexOf(":");if(r<0)continue;let s=n.slice(0,r).trim().toLowerCase(),i=n.slice(r+1).replace(/!important/i,"").trim();s&&i&&(e[s]=i)}return e}function fd(t){let e=[];t=t.replace(/\/\*[\s\S]*?\*\//g,"");for(let[,n,r]of t.matchAll(/([^{}@]+)\{([^}]*)\}/g)){let s=fl(r);for(let i of n.split(",")){let o=i.trim(),a=/^([a-zA-Z][\w-]*|\*)?((?:[.#][\w-]+)*)$/.exec(o);if(!a)continue;let l=[],u;for(let[,c,f]of a[2].matchAll(/([.#])([\w-]+)/g))c==="."?l.push(f):u=f;e.push({tag:a[1]&&a[1]!=="*"?a[1]:void 0,id:u,classes:l,decls:s})}}return e}function hd(t,e){switch(t){case"mm":return 1;case"cm":return 10;case"in":return 25.4;case"pt":return 25.4/72;case"pc":return 25.4/6;case"q":return .25;default:return 25.4/e}}function ki(t,e){if(!t)return;let n=/^\s*([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)\s*([a-zA-Z%]*)\s*$/.exec(t);if(!(!n||n[2]==="%"))return Number(n[1])*hd(n[2].toLowerCase(),e)}var pd=/^(path|g|rect|circle|ellipse|line|polyline|polygon|layer|svg|use|text|tspan|group|shape|cls|clip|mask|defs|_?x?\d|Layer_\d|Ebene|Calque|Capa|Livello|Laag|Warstwa)[-_ ]*[\d-]*$/i;function dd(t){for(let e of["data-part","inkscape:label","data-name","id"]){let n=t.attrs[e]?.trim();if(n&&!pd.test(n)&&!/^[\d_-]+$/.test(n))return n.replace(/_x5F_|_/g," ").trim()}}function gd(t){if(!t)return;let e=t.toLowerCase();if(/\bscor|\bscoring/.test(e))return ft.score;if(/engrav|raster|etch/.test(e))return ft.engrave;if(/\bguide/.test(e))return ft.guide;if(/^cut|\bcut\b|cutting|\bcuts\b/.test(e))return ft.cut}function hl(t,e={}){if(t=t.replace(/^\uFEFF/,""),!/^\s*</.test(t)||t.includes("\0"))throw new Error("This is not an SVG file: it does not start with a tag");let n=cl(t),r=n.root;if(r.name.replace(/^.*:/,"")!=="svg")throw new Error("This is not an SVG file");let s=[],i=n.comments.some(b=>/Adobe Illustrator/i.test(b)),o=e.dpi??(i?72:96);e.dpi===void 0&&i&&s.push("Adobe Illustrator file: px measured at 72 per inch.");let a=dr(r.attrs.viewBox??""),l=ki(r.attrs.width,o),u=ki(r.attrs.height,o),c=25.4/o,f=c,h=c,p=0,d=0;a.length===4&&a[2]>0&&a[3]>0&&(f=l!==void 0?l/a[2]:u!==void 0?u/a[3]:c,h=u!==void 0?u/a[3]:f,p=a[0],d=a[1]),l===void 0&&u===void 0&&e.dpi===void 0&&!i&&s.push(`The file gives no page size in mm or inches: px measured at ${o} per inch.`);let g=u??(a.length===4?a[3]*h:0),m=wn([1,0,0,-1,0,g],[f,0,0,h,-p*f,-d*h]),x=[],w=new Map,v=b=>{b.name==="style"&&x.push(...fd(b.text)),b.attrs.id&&w.set(b.attrs.id,b),b.children.forEach(v)};v(r);let T=(b,W)=>{let z={};for(let K of Object.keys(W))cd.has(K)&&(z[K]=W[K]);for(let K of ud)b.attrs[K]!==void 0&&(z[K]=b.attrs[K]);let oe=(b.attrs.class??"").split(/\s+/).filter(Boolean);for(let K of x)(!K.tag||K.tag===b.name)&&(!K.id||K.id===b.attrs.id)&&K.classes.every(ke=>oe.includes(ke))&&Object.assign(z,K.decls);return b.attrs.style&&Object.assign(z,fl(b.attrs.style)),z},P=[],O=[],C=0,L=0,B=0,A=0,F=0,te=0,V=2e4,q=[],re=b=>Number.isFinite(b[0])&&Number.isFinite(b[1]),U=["x","y","width","height","rx","ry","cx","cy","r"],ae=b=>[...U,"x1","y1","x2","y2","points"].some(W=>b.attrs[W]!==void 0&&dr(b.attrs[W]).some(z=>!Number.isFinite(z))),de=new Set(["defs","clipPath","mask","pattern","marker","symbol","metadata","title","desc","style","script","linearGradient","radialGradient","filter","sodipodi:namedview","foreignObject"]),me=new Set(["path","rect","circle","ellipse","line","polyline","polygon"]),we=b=>{let W=z=>parseFloat(b.attrs[z]??"0")||0;switch(b.name){case"path":return Fn(b.attrs.d??"",()=>B++);case"rect":{let[z,oe,K,ke]=[W("x"),W("y"),W("width"),W("height")];if(K<=0||ke<=0)return[];let j=b.attrs.rx!==void 0?W("rx"):b.attrs.ry!==void 0?W("ry"):0,xe=b.attrs.ry!==void 0?W("ry"):j;return j=Math.min(Math.abs(j),K/2),xe=Math.min(Math.abs(xe),ke/2),j<=0||xe<=0?Fn(`M${z} ${oe}H${z+K}V${oe+ke}H${z}Z`):Fn(`M${z+j} ${oe}H${z+K-j}A${j} ${xe} 0 0 1 ${z+K} ${oe+xe}V${oe+ke-xe}A${j} ${xe} 0 0 1 ${z+K-j} ${oe+ke}H${z+j}A${j} ${xe} 0 0 1 ${z} ${oe+ke-xe}V${oe+xe}A${j} ${xe} 0 0 1 ${z+j} ${oe}Z`)}case"circle":case"ellipse":{let[z,oe]=[W("cx"),W("cy")],K=b.name==="circle"?W("r"):W("rx"),ke=b.name==="circle"?W("r"):b.attrs.ry!==void 0?W("ry"):K;return K<=0||ke<=0?[]:Fn(`M${z+K} ${oe}A${K} ${ke} 0 0 1 ${z} ${oe+ke}A${K} ${ke} 0 0 1 ${z-K} ${oe}A${K} ${ke} 0 0 1 ${z} ${oe-ke}A${K} ${ke} 0 0 1 ${z+K} ${oe}Z`)}case"line":return Fn(`M${W("x1")} ${W("y1")}L${W("x2")} ${W("y2")}`);case"polyline":case"polygon":{let z=dr(b.attrs.points??"");if(z.length<4)return[];let oe=`M${z[0]} ${z[1]}`;for(let K=2;K+1<z.length;K+=2)oe+=`L${z[K]} ${z[K+1]}`;return Fn(b.name==="polygon"?oe+"Z":oe)}}},E=b=>(b.text+b.children.map(W=>W.name==="tspan"?" "+E(W):"").join("")).replace(/\s+/g," ").trim(),S=(b,W,z,oe,K,ke)=>{if(ke>64||de.has(b.name)||F&&++te>V)return;let j=T(b,z);if(j.display==="none"||j.visibility==="hidden"||j.opacity==="0"){(b.children.length||me.has(b.name))&&L++;return}let xe=wn(W,ad(b.attrs.transform));if(!xe.every(Number.isFinite)){A++;return}let Re=dd(b),Ne=b.attrs["inkscape:groupmode"]==="layer",_e=oe;if(b.name==="g"||b.name==="svg"||b.name==="a"||b.name==="switch"){let Ge=b.attrs["inkscape:label"]??b.attrs["data-name"]??b.attrs.id,et=gd(Ge);if(b.attrs["data-mode"]&&Ge&&/^(cut|line|fill|guide)$/.test(b.attrs["data-mode"])){let ht=pr(j.stroke,"#000000"),Gt=pr(j.fill,"#000000"),dn=b.attrs["data-mode"]==="fill"?Gt:ht;_e=ft[Ge]??{name:Ge,mode:b.attrs["data-mode"],color:dn&&dn.startsWith("#")?dn:"#00aa00"}}else et&&(_e=et);if(b!==r&&b.name==="svg"){let ht=Gt=>parseFloat(b.attrs[Gt]??"0")||0;xe=wn(xe,[1,0,0,1,ht("x"),ht("y")])}let pn=Ne||et||b===r||!Re?K:[Re,...K];q.push(b);for(let ht of b.children)S(ht,xe,j,_e,pn,ke+1);q.pop();return}if(b.name==="use"){let Ge=w.get((b.attrs.href??b.attrs["xlink:href"]??"").replace(/^#/,""));if(!Ge||q.includes(Ge))return;let et=Gt=>parseFloat(b.attrs[Gt]??"0")||0,pn=wn(xe,[1,0,0,1,et("x"),et("y")]),ht=Ge.name==="symbol"?{...Ge,name:"g"}:Ge;q.push(Ge),F++,S(ht,pn,j,_e,Re?[Re,...K]:K,ke+1),F--,q.pop();return}if(b.name==="image"){C++;return}let se=pr(j.color,"#000000")??"#000000",De=parseFloat(j["stroke-width"]??"1"),ye=pr(j.stroke,se);ye&&(De===0||j["stroke-opacity"]==="0")&&(ye="none");let He=pr(j.fill??"black",se);if(j["fill-opacity"]==="0"&&(He="none"),b.name==="text"){let Ge=E(b);if(!Ge)return;let et=b.children.find(xr=>xr.name==="tspan"),pn=xr=>dr(b.attrs[xr]??et?.attrs[xr]??"0")[0]??0,ht=Wn(xe,[pn("x"),pn("y")]),Gt=Math.sqrt(Math.abs(xe[0]*xe[3]-xe[1]*xe[2])),dn=(ki(j["font-size"],96)??16*c)/c;if(!re(ht)||!Number.isFinite(dn*Gt)){A++;return}let Ai=j["text-anchor"];O.push({text:Ge,at:ht,size:dn*Gt,angle:Math.atan2(-xe[1],xe[0])*180/Math.PI,font:(j["font-family"]??"").split(",")[0].replace(/['"]/g,"").trim(),anchor:Ai==="middle"?"center":Ai==="end"?"right":"left",stroke:ye,fill:He,layer:_e});return}if(b.name!=="path"&&ae(b)){A++;return}let Pt=we(b);if(!Pt){for(let Ge of b.children)S(Ge,xe,j,_e,K,ke+1);return}let Kt=ld(Pt,xe),Qe=Kt.filter(Ge=>Ge.segs.every(et=>re(et.a)&&re(et.b)&&(et.c==="L"||re(et.p1)&&re(et.p2))));Qe.length<Kt.length&&A++,Qe.length&&P.push({subs:Qe,stroke:ye,fill:b.name==="line"||b.name==="polyline"?"none":He,fillRule:j["fill-rule"]==="evenodd"?"evenodd":"nonzero",layer:_e,names:Re?[Re,...K]:K})};S(r,m,{},void 0,[],0),C&&s.push(`${C} embedded image${C===1?" was":"s were"} left out: trace ${C===1?"it":"them"} to paths first.`),L&&s.push(`${L} hidden element${L===1?" was":"s were"} left out.`),B&&s.push(`${B} path${B===1?" has":"s have"} bad data: read up to the error, as browsers draw ${B===1?"it":"them"}.`),A&&s.push(`${A} element${A===1?" was":"s were"} left out: ${A===1?"its":"their"} numbers are too large to draw.`),te>V&&s.push(`The drawing repeats its elements with <use> more than ${V.toLocaleString("en")} times: only the first ${V.toLocaleString("en")} copies were read.`);let D=b=>{let[W,z,oe]=[1,3,5].map(K=>parseInt(b.slice(K,K+2),16));return W>=200&&z<=80&&oe<=80},$=b=>{let[W,z,oe]=[1,3,5].map(K=>parseInt(b.slice(K,K+2),16));return oe>=200&&W<=80&&z<=80},_=b=>!!b.stroke&&b.stroke!=="none",ie=P.filter(b=>!b.layer),J=new Map;for(let b of ie)_(b)&&b.stroke.startsWith("#")&&J.set(b.stroke,(J.get(b.stroke)??0)+b.subs.length);let he=[...J.keys()],Me=he.filter(D),le=new Set(Me.length?Me:he.length?[he.reduce((b,W)=>(J.get(W)??0)>(J.get(b)??0)?W:b)]:[]),y=P.some(b=>_(b)&&!b.layer)||P.some(b=>b.layer),I=new Map,H=(b,W)=>{if(b&&b!=="none"){let z=b.startsWith("#")?b:"#000000";if(le.has(z))return ft.cut;if(z==="#00a0ff")return ft.guide;if($(z))return ft.score;if(!I.has(z)){let oe=od[z]??"color_"+z.slice(1);I.set(z,{name:oe,mode:"line",color:z})}return I.get(z)}if(W&&W!=="none")return y?ft.engrave:ft.cut};!y&&P.some(b=>b.fill&&b.fill!=="none")?s.push("The file has filled shapes and no strokes: the shapes are cut out."):!Me.length&&le.size&&s.push(`No red lines: ${[...le][0]} lines, the most common colour, are cut.`),I.size&&s.push(`Lines in ${[...I.values()].map(b=>b.color).join(", ")} went on their own layer${I.size===1?"":"s"}, set to mark, not cut.`);let G=[];for(let b of P){let W=b.layer??H(b.stroke,b.fill);if(!W)continue;let z=!b.layer&&W===ft.cut&&!_(b);G.push({subs:b.subs,layer:W,fillRule:b.fillRule,names:b.names,filled:z})}let Y=[];for(let b of O){let W=b.layer??H(b.fill!=="none"?void 0:b.stroke,b.fill);W&&Y.push({...b,layer:W.mode==="cut"&&y?ft.engrave:W})}return{items:G,texts:Y,notes:s}}var ve=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]),St=([t,e],n)=>{let r=n*Math.PI/180,s=Math.cos(r),i=Math.sin(r);return[t*s-e*i,t*i+e*s]},Ei=(t,e)=>[t[0]+e[0],t[1]+e[1]],kt=(t,e)=>[t[0]-e[0],t[1]-e[1]];function fn(t,e=.005){let n=[t.segs[0].a];for(let r of t.segs)if(r.c==="L")n.push(r.b);else{let s=ve(r.a,r.p1)+ve(r.p1,r.p2)+ve(r.p2,r.b),i=Math.max(2,Math.min(512,Math.ceil(Math.sqrt(s/e))));for(let o=1;o<=i;o++){let a=o/i,l=1-a;n.push([l*l*l*r.a[0]+3*l*l*a*r.p1[0]+3*l*a*a*r.p2[0]+a*a*a*r.b[0],l*l*l*r.a[1]+3*l*l*a*r.p1[1]+3*l*a*a*r.p2[1]+a*a*a*r.b[1]])}}return t.closed&&n.length>1&&ve(n[0],n[n.length-1])<1e-9&&n.pop(),n}function Ft(t,e=!0){let n=0;for(let r=1;r<t.length;r++)n+=ve(t[r-1],t[r]);return e&&t.length>2?n+ve(t[t.length-1],t[0]):n}function $t(t,e,n){let r=[],s=e?t.length:t.length-1;for(let i=0;i<s;i++){let o=t[i],a=t[(i+1)%t.length];r.push(o);let l=Math.floor(ve(o,a)/n);for(let u=1;u<l;u++)r.push([o[0]+(a[0]-o[0])*u/l,o[1]+(a[1]-o[1])*u/l])}return!e&&t.length&&r.push(t[t.length-1]),r}function Yt(t,e,n){let r=n[0]-e[0],s=n[1]-e[1],i=r*r+s*s,o=i?((t[0]-e[0])*r+(t[1]-e[1])*s)/i:0;return o=Math.max(0,Math.min(1,o)),Math.hypot(t[0]-e[0]-o*r,t[1]-e[1]-o*s)}var cn=class{constructor(e,n,r){this.size=r;this.cells=new Map;for(let s of e){let i=n?s.length:s.length-1;for(let o=0;o<i;o++){let a=s[o],l=s[(o+1)%s.length],u=Math.max(1,Math.ceil(ve(a,l)/(r*2)));for(let c=0;c<u;c++){let f=[a[0]+(l[0]-a[0])*c/u,a[1]+(l[1]-a[1])*c/u],h=[a[0]+(l[0]-a[0])*(c+1)/u,a[1]+(l[1]-a[1])*(c+1)/u],p=Math.floor(Math.min(f[0],h[0])/r),d=Math.floor(Math.max(f[0],h[0])/r),g=Math.floor(Math.min(f[1],h[1])/r),m=Math.floor(Math.max(f[1],h[1])/r);for(let x=p;x<=d;x++)for(let w=g;w<=m;w++){let v=`${x},${w}`,T=this.cells.get(v);T?T.push([f,h]):this.cells.set(v,[[f,h]])}}}}}near(e,n){let r=Math.floor((e[0]-n)/this.size),s=Math.floor((e[0]+n)/this.size),i=Math.floor((e[1]-n)/this.size),o=Math.floor((e[1]+n)/this.size);for(let a=r;a<=s;a++)for(let l=i;l<=o;l++)for(let[u,c]of this.cells.get(`${a},${l}`)??[])if(Yt(e,u,c)<=n)return!0;return!1}meets(e,n,r){let s=Math.max(1,Math.ceil(ve(e,n)/(this.size*2)));for(let i=0;i<s;i++){let o=[e[0]+(n[0]-e[0])*i/s,e[1]+(n[1]-e[1])*i/s],a=[e[0]+(n[0]-e[0])*(i+1)/s,e[1]+(n[1]-e[1])*(i+1)/s],l=Math.floor((Math.min(o[0],a[0])-r)/this.size),u=Math.floor((Math.max(o[0],a[0])+r)/this.size),c=Math.floor((Math.min(o[1],a[1])-r)/this.size),f=Math.floor((Math.max(o[1],a[1])+r)/this.size);for(let h=l;h<=u;h++)for(let p=c;p<=f;p++)for(let[d,g]of this.cells.get(`${h},${p}`)??[])if(dl(o,a,d,g)<=r)return!0}return!1}};function dl(t,e,n,r){let s=(u,c,f)=>(c[0]-u[0])*(f[1]-u[1])-(c[1]-u[1])*(f[0]-u[0]),i=s(n,r,t),o=s(n,r,e),a=s(t,e,n),l=s(t,e,r);return i*o<0&&a*l<0?0:Math.min(Yt(t,n,r),Yt(e,n,r),Yt(n,t,e),Yt(r,t,e))}function md(t,e,n=.2){let r=t.length;if(r<4)return!1;let s=[0];for(let c=1;c<=r;c++)s.push(s[c-1]+ve(t[c-1],t[c%r]));let i=s[r],o=st([t]),a=Math.max(o[2]-o[0],o[3]-o[1],e)/Math.max(1,Math.sqrt(r)),l=new Map,u=(c,f)=>{let h=[],p=Math.floor((Math.min(c[0],f[0])-e)/a),d=Math.floor((Math.max(c[0],f[0])+e)/a),g=Math.floor((Math.min(c[1],f[1])-e)/a),m=Math.floor((Math.max(c[1],f[1])+e)/a);if((d-p+1)*(m-g+1)>4096)return null;for(let x=p;x<=d;x++)for(let w=g;w<=m;w++)h.push(`${x},${w}`);return h};for(let c=0;c<r;c++){let f=t[c],h=t[(c+1)%r],p=u(f,h);if(!p)return!1;for(let d of p)for(let g of l.get(d)??[]){let m=Math.abs(s[c]-s[g]);if(!(Math.min(m,i-m)-ve(f,h)-ve(t[g],t[(g+1)%r])<n)&&dl(f,h,t[g],t[(g+1)%r])<=e)return!0}for(let d of p){let g=l.get(d);g?g.push(c):l.set(d,[c])}}return!1}function gl(t,e){let n=t.map(()=>!1),r=[],s=t.map(u=>st([u]));t.forEach((u,c)=>{let f=Ie([u]),h=f.reduce((g,m)=>g+Ze(m),0),p=Ft(u),d=f.reduce((g,m)=>g+Ft(m),0);(f.length!==1||Math.abs(h-Math.abs(Ze(u)))>p*.001+1e-6||Math.abs(d-p)>p*.001+.05||md(u,e))&&(n[c]=!0)});let i=new Map,o=u=>{let c=i.get(u);return c||i.set(u,c=new cn([t[u]],!0,Math.max(e*4,1))),c},a=t.map((u,c)=>c).sort((u,c)=>s[u][0]-s[c][0]),l=[];for(let u of a){let[c,f,h,p]=s[u];for(let d=l.length-1;d>=0;d--)s[l[d]][2]<c-e&&l.splice(d,1);for(let d of l){let g=s[d];if(g[1]>p+e||g[3]<f-e)continue;let[m,x]=t[u].length<=t[d].length?[u,d]:[d,u],w=t[m],v=o(x);for(let T=0;T<w.length;T++)if(v.meets(w[T],w[(T+1)%w.length],e)){r.push([u,d]);break}}l.push(u)}return{self:n,pairs:r}}function hn(t,e,n,r=!0){if(!t.length||!e.length)return t.length===e.length;let s=Math.max(n*2,.2),i=new cn(t,r,Math.max(n*4,1)),o=new cn(e,r,Math.max(n*4,1));for(let a of t)for(let l of $t(a,r,s))if(!o.near(l,n))return!1;for(let a of e)for(let l of $t(a,r,s))if(!i.near(l,n))return!1;return!0}function ml(t,e,n){let r=new cn([t,...e],!0,Math.max(n*4,1)),s=i=>Bt(i,t)&&!e.some(o=>Bt(i,o));return(i,o)=>{let a=o?i.length:i.length-1;if(a<1)return!1;let l;for(let u=0;u<a;u++){let c=i[u],f=i[(u+1)%i.length];if(!r.meets(c,f,n)){l??(l=[(c[0]+f[0])/2,(c[1]+f[1])/2]);continue}if(o||u!==0&&u!==a-1)return!1;let h=ve(c,f),p=Math.min(n*3,h/3)/h,d=u===0?[c[0]+(f[0]-c[0])*p,c[1]+(f[1]-c[1])*p]:c,g=u===a-1?[f[0]-(f[0]-c[0])*p,f[1]-(f[1]-c[1])*p]:f;if(r.meets(d,g,n))return!1;l??(l=[(c[0]+f[0])/2,(c[1]+f[1])/2])}return l?s(l):!0}}function xl(t,e,n){if(!t.length)return!1;let r=new cn([e],!0,Math.max(n*4,1));return t.some(s=>$t(s,!1,Math.max(n*2,.2)).some(i=>r.near(i,n)))}function Bt(t,e){let n=!1;for(let r=0,s=e.length-1;r<e.length;s=r++){let[i,o]=e[r],[a,l]=e[s];o>t[1]!=l>t[1]&&t[0]<(a-i)*(t[1]-o)/(l-o)+i&&(n=!n)}return n}function ls(t){let e=t.length;if(e<3)return null;let n=0,r=0;for(let[m,x]of t)n+=m,r+=x;n/=e,r/=e;let s=0,i=0,o=0,a=0,l=0,u=0,c=0;for(let[m,x]of t){let w=m-n,v=x-r;s+=w*w,i+=w*v,o+=v*v,a+=w*w*w,l+=v*v*v,u+=w*v*v,c+=v*w*w}let f=s*o-i*i;if(Math.abs(f)<1e-12)return null;let h=(a+u)/2,p=(l+c)/2,d=(h*o-p*i)/f,g=(p*s-h*i)/f;return{c:[d+n,g+r],r:Math.sqrt(d*d+g*g+(s+o)/e)}}function Dn(t,e=.01){if(t.length<4)return t;let n=0;for(let l=1;l<t.length;l++)ve(t[0],t[l])>ve(t[0],t[n])&&(n=l);let r=l=>{if(l.length<3)return l;let u=0,c=0;for(let h=1;h<l.length-1;h++){let p=Yt(l[h],l[0],l[l.length-1]);p>u&&(u=p,c=h)}return u<=e?[l[0],l[l.length-1]]:[...r(l.slice(0,c+1)).slice(0,-1),...r(l.slice(c))]},s=r(t.slice(0,n+1)),i=r([...t.slice(n),t[0]]),o=[...s.slice(0,-1),...i.slice(0,-1)],a=[];for(let l=0;l<o.length;l++){let u=o[(l-1+o.length)%o.length],c=o[(l+1)%o.length];Yt(o[l],u,c)>e&&a.push(o[l])}return a.length>=3?a:o}function yl(t){let e=[],n=[];for(let i of t.slice(0,300)){let o=Dn(i,.002),a=o.length,l=o.findIndex((f,h)=>ve(f,o[(h+1)%a])>=.5);if(a<4||l<0)continue;let u=Ze(i)>0,c=[];for(let f=1;f<=a;f++){let h=(l+f)%a,p=o[h],d=o[(h+1)%a];if(ve(p,d)<.3){c.length||c.push(p),c.push(d);continue}if(c.length>=3){let g=ls(c),[m,x,w]=[c[0],c[1],c[c.length-1]],v=(x[0]-m[0])*(w[1]-m[1])-(x[1]-m[1])*(w[0]-m[0]);g&&g.r>.005&&g.r<.6&&(v>0===u?e:n).push(g.r)}c=[]}}if(e.length<4)return;e.sort((i,o)=>i-o);let r=e[Math.floor(e.length/2)],s=i=>Math.abs(i-r)<=Math.max(.005,r*.1);if(!(r>.2||n.filter(s).length>e.length*.2))return e.filter(s).length>=e.length*.8?r:void 0}function Li(t,e){let n=t.length,r=a=>ve(t[a],t[(a+1)%n])<e*1.5,s=t.findIndex((a,l)=>!r(l));if(s<0)return t;let i=[],o=s;do{let a=(o+1)%n;for(;r(a)&&a!==o;)a=(a+1)%n;let l=(a-o-1+n)%n,u=t[o],c=t[(o+1)%n],f=t[a],h=t[(a+1)%n],p;if(l>0){let d=(c[0]-u[0])*(h[1]-f[1])-(c[1]-u[1])*(h[0]-f[0]);if(Math.abs(d)>1e-12){let g=((f[0]-u[0])*(h[1]-f[1])-(f[1]-u[1])*(h[0]-f[0]))/d,m=[u[0]+g*(c[0]-u[0]),u[1]+g*(c[1]-u[1])],x=t[(o+1+Math.floor(l/2))%n],w=[];for(let P=1;P<=l+1;P++)w.push(t[(o+P)%n]);let v=w.length>=3?ls(w):{c:m,r:e};!!v&&Math.abs(v.r-e)<=e*.3&&ve(m,x)<=e*2&&g>=1-1e-9&&(p=m)}}if(i.push(u),p)i.push(p);else for(let d=1;d<=l;d++)i.push(t[(o+d)%n]);o=a}while(o!==s);return i}function pe(t){for(let r of[0,1,2]){let s=10**r,i=Math.round(t*s)/s;if(Math.abs(t-i)<=.003)return Object.is(i,-0)?0:i}let n=Math.round(t*1e3)/1e3;return Object.is(n,-0)?0:n}var ce=t=>String(pe(t)),Ae=t=>`[${ce(t[0])}, ${ce(t[1])}]`;function xd(t){t=(t%360+540)%360-180;let e=Math.round(t*100)/100;return Math.abs(e-Math.round(e))<.02?Math.round(e):e}function Dt(t,e,n){let r=[];(pe(t[0])!==0||pe(t[1])!==0)&&r.push(`translate(${Ae(t)})`);let s=xd(e);return s!==0&&r.push(`rotate(${s})`),[...r,n].join(" ")}function gr(t,e){return{poly:t,area:Math.abs(Ze(t)),box:st([t]),ends:e?.segs.map(n=>n.a)}}var as=(t,e,n,r)=>[[t,e],[n,e],[n,r],[t,r]];function us(t,e){let n=Ft(t.poly),r=$t(t.poly,!0,Math.min(.5,n/256)),s=ls(t.ends&&t.ends.length>=3?t.ends:t.poly.length>=8?t.poly:r);if(!s||s.r<.05)return;let i=Math.min(e*.6,Math.max(e/2,s.r*3e-4));for(let a of t.poly)if(Math.abs(ve(a,s.c)-s.r)>i)return;let o=i+s.r*2e-4;for(let a of r)if(Math.abs(ve(a,s.c)-s.r)>o)return;if(!(Math.abs(t.area-Math.PI*s.r*s.r)>n*i*2))return{kind:"circle",body:`circle(d = ${ce(s.r*2)})`,at:s.c,angle:0,center:s.c,circle:s,radius:s.r}}function vl(t){let e=0,n=0;for(let[o,a]of t)e+=o,n+=a;e/=t.length,n/=t.length;let r=0,s=0,i=0;for(let[o,a]of t)r+=(o-e)**2,s+=(a-n)**2,i+=(o-e)*(a-n);return .5*Math.atan2(2*i,r-s)*180/Math.PI}function cs(t,e){let n=Ft(t.poly),r=$t(t.poly,!0,Math.min(.5,n/256)),s=vl(r),i=r.map(g=>St(g,-s)),[o,a,l,u]=st([i]),c=(l-o)/2,f=(u-a)/2;if(c<.05||f<.05||Math.abs(c-f)<=e)return;let h=[(o+l)/2,(a+u)/2],p=Math.min(e*.6,Math.max(e/2,Math.max(c,f)*3e-4))+Math.max(c,f)*2e-4;for(let[g,m]of i){let x=Math.hypot((g-h[0])/c,(m-h[1])/f);if(Math.abs(x-1)*Math.min(c,f)>p)return}if(Math.abs(t.area-Math.PI*c*f)>n*p*2)return;let d=St(h,s);return{kind:"ellipse",radius:Math.max(c,f),body:`ellipse(${Ae([c,f])})`,at:d,angle:s,center:d}}function bl(t){let e=0,n=0;for(let r=0;r<t.length;r++){let s=t[r],i=t[(r+1)%t.length],o=ve(s,i);o>e&&(e=o,n=Math.atan2(i[1]-s[1],i[0]-s[0])*180/Math.PI)}return n=(n%90+90)%90,n>45?n-90:n}function fs(t,e){let n=Dn(t.poly,e/4),r=bl(n),s=Ft(t.poly),i=$t(t.poly,!0,Math.min(.5,s/256)).map(w=>St(w,-r)),[o,a,l,u]=st([i]),c=l-o,f=u-a;if(c<.05||f<.05)return;let h=Math.SQRT2+1,p=[[o,a],[l,a],[l,u],[o,u]].map(w=>Math.min(...i.map(v=>ve(v,w)))*h),d=p.reduce((w,v)=>w+v,0)/4;if(Math.max(...p)-Math.min(...p)>e*h)return;d<e&&(d=0),d=Math.min(d,c/2,f/2);let g=[(o+l)/2,(a+u)/2];for(let[w,v]of i){let T=Math.abs(w-g[0])-(c/2-d),P=Math.abs(v-g[1])-(f/2-d),O=Math.hypot(Math.max(T,0),Math.max(P,0))+Math.min(Math.max(T,P),0)-d;if(Math.abs(O)>e/2)return}if(Math.abs(t.area-(c*f-(4-Math.PI)*d*d))>s*e)return;let m=St(g,r),x=pe(d)>0?`, r = ${ce(d)}`:"";return{kind:"rect",radius:d,body:`rect(${Ae([c,f])}, center = true${x})`,at:m,angle:r,center:m,rect:{w:c,h:f,r:d}}}function hs(t,e){let n=Dn(t.poly,e/4),r=n.length;if(r<3||r>48)return;let s=0,i=0;for(let[f,h]of n)s+=f/r,i+=h/r;let o=[s,i],a=n.map(f=>ve(f,o)),l=n.map((f,h)=>ve(f,n[(h+1)%r])),u=f=>Math.max(...f)-Math.min(...f),c=n.map(f=>Math.atan2(f[1]-i,f[0]-s)*180/Math.PI);if(u(l)<=e&&u(a)<=e&&r<=24){let f=a.reduce((d,g)=>d+g,0)/r,h=360/r,p=(c[0]%h+h)%h;return h-p<.01&&(p=0),{kind:"polygon",body:`regular_polygon(${r}, ${ce(f)})`,at:o,angle:p,center:o}}if(r%2===0&&r>=4&&u(l)<=e){let f=a.filter((T,P)=>P%2===0),h=a.filter((T,P)=>P%2===1);if(u(f)>e||u(h)>e)return;let p=f.reduce((T,P)=>T+P,0)/f.length,d=h.reduce((T,P)=>T+P,0)/h.length,g=c[0];if(d>p&&([p,d]=[d,p],g=c[1]),p-d<e)return;let m=r/2,x=360/m,w=((g-90)%x+x)%x;x-w<.01&&(w=0);let v=pe(d)===pe(p*.45);return{kind:"star",body:`star(${m}, ${ce(p)}${v?"":`, ${ce(d)}`})`,at:o,angle:w,center:o}}}function yd(t,e,n){let[r,s,i,o]=e,a=[[],[],[],[]],l=[[],[],[],[]];for(let f=0;f<t.length;f++){let h=t[f],p=t[(f+1)%t.length];if(Math.abs(h[1]-p[1])<=n){let d=h[1];Math.abs(d-s)<=n?a[0].push(is(h[0]-r,p[0]-r)):Math.abs(d-o)<=n?a[2].push(is(i-h[0],i-p[0])):(l[0].push(d-s),l[2].push(o-d))}else{let d=h[0];Math.abs(d-i)<=n?a[1].push(is(h[1]-s,p[1]-s)):Math.abs(d-r)<=n?a[3].push(is(o-h[1],o-p[1])):(l[1].push(i-d),l[3].push(d-r))}}let u=[i-r,o-s,i-r,o-s],c=l.map(f=>f.length?Math.min(...f.filter(h=>h>n)):void 0);return{outer:a.map(f=>vd(f,n)),depth:c,length:u}}var is=(t,e)=>t<e?[t,e]:[e,t];function vd(t,e){t.sort((r,s)=>r[0]-s[0]);let n=[];for(let[r,s]of t){let i=n[n.length-1];i&&r<=i[1]+e?i[1]=Math.max(i[1],s):n.push([r,s])}return n}var Mi=t=>t.reduce((e,[n,r])=>e+r-n,0);function bd(t,e,n,r,s,i){let o=[as(0,0,t,e)],a=[([u,c])=>[u,c],([u,c])=>[t-c,u],([u,c])=>[t-u,e-c],([u,c])=>[c,e-u]],l=[t,e,t,e];return n.forEach((u,c)=>{if(!u)return;let f=l[c];for(let h=0;h<r[c];h++){let p=f*(h+.5)/r[c];o.push(as(p-s[c]/2,-i,p+s[c]/2,0).map(a[c]))}}),Ie(o)}function Ti(t,e,n){let r=Dn(t.poly,e/4);if(r.length<8)return;let s=bl(r),i=r.map(E=>St(E,-s)),o=e/2;for(let E=0;E<i.length;E++){let S=i[E],D=i[(E+1)%i.length];if(Math.abs(S[0]-D[0])>o&&Math.abs(S[1]-D[1])>o)return}let a=st([i]),l=yd(i,a,o),u=(E,S)=>E.map(D=>D.map($=>Ei($,S))),c=(E,S)=>hn([i],u(E,S),e),f=(E,S,D)=>{let $=St(E,s);return{kind:"tabs",body:S,at:$,angle:s,center:St([(a[0]+a[2])/2,(a[1]+a[3])/2],s),...D}},h=Ft(t.poly),p=[0,1,2,3].filter(E=>Mi(l.outer[E])<l.length[E]-o);if(!p.length)return;let d=p.map(E=>l.depth[E]).filter(E=>E!==void 0);if(!d.length)return;let g=[...new Set([n,...d].filter(E=>!!E).map(pe))];for(let E of g){let S=pe(a[2]-a[0]),D=pe(a[3]-a[1]),$=[[]];for(let se=0;se<4;se++){let ye=Mi(l.outer[se])>=l.length[se]-2*E-o?["flat"]:["out","in"],He=[];for(let Pt of $)for(let Kt of ye)He.push([...Pt,Kt]);$.splice(0,$.length,...He)}let _=Math.max(3*E,6),ie=new Set([_]);for(let se of p){let De=l.outer[se].length;for(let ye of[2*De-1,2*De+1,2*De-3,2*De+3])ye>=3&&ie.add(pe(l.length[se]/ye))}for(let se of ie)for(let De of $){if(De.every(Qe=>Qe==="flat"))continue;let ye=Nr(S,D,De,E,se);if(Math.abs(Math.abs(ye.reduce((Qe,Ge)=>Qe+Ze(Ge),0))-t.area)>h*e||!c(ye,[a[0],a[1]]))continue;let Pt=De.every(Qe=>Qe===De[0])?`"${De[0]}"`:`[${De.map(Qe=>`"${Qe}"`).join(", ")}]`,Kt=se===_||[0,1].every(Qe=>sn(l.length[Qe],se)===sn(l.length[Qe],_));return f([a[0],a[1]],`finger_rect(${Ae([S,D])}, ${Pt}${Kt?"":`, finger = ${ce(se)}`})`,{kind:"fingers",thickness:E,edges:De,finger:Kt?_:se})}let J=[0,1,2,3].map(se=>p.includes(se)&&l.depth[se]!==void 0&&Math.abs(l.depth[se]-E)<=o);if(!J.some(Boolean))continue;let he=a[0]+(J[3]?E:0),Me=a[1]+(J[0]?E:0),le=pe(a[2]-(J[1]?E:0)-he),y=pe(a[3]-(J[2]?E:0)-Me),I=[le,y,le,y],H=[J[3]?E:0,J[0]?E:0,J[1]?E:0,J[2]?E:0],G=[0,0,0,0],Y=[0,0,0,0],b=!0;for(let se=0;se<4&&b;se++){if(!J[se])continue;let De=l.outer[se].map(([ye,He])=>[ye-H[se],He-H[se]]);G[se]=De.length,Y[se]=De.length?pe(De.reduce((ye,[He,Pt])=>ye+Pt-He,0)/De.length):0,De.forEach(([ye,He],Pt)=>{(Math.abs((ye+He)/2-I[se]*(Pt+.5)/G[se])>o||Math.abs(He-ye-Y[se])>o)&&(b=!1)})}if(!b||!c(bd(le,y,J,G,Y,E),[he,Me]))continue;let W=J.every(Boolean)?"":`[${J.join(", ")}]`,z=[0,1,2,3].filter(se=>J[se]),oe=se=>Math.max(1,Math.round(I[se]/50)),K=z.every(se=>G[se]===oe(se)),ke=z.every(se=>G[se]===G[z[0]]),j=K?void 0:ke?G[z[0]]:null,xe=z.every(se=>Math.abs(Y[se]-I[se]/(2*G[se]))<=o),Re=z.every(se=>Math.abs(Y[se]-Y[z[0]])<=o),Ne=xe?void 0:Re?Y[z[0]]:null,_e;if(j!==null&&Ne!==null){let se=[Ae([le,y])];W?se.push(W):(j!==void 0||Ne!==void 0)&&se.push("true"),j!==void 0&&se.push(`count = ${j}`),Ne!==void 0&&se.push(`width = ${ce(Ne)}`),_e=`tab_rect(${se.join(", ")})`}else{let se=[ye=>ye,ye=>`translate(${Ae([le,0])}) rotate(90) ${ye}`,ye=>`translate(${Ae([le,y])}) rotate(180) ${ye}`,ye=>`translate(${Ae([0,y])}) rotate(270) ${ye}`],De=[`rect(${Ae([le,y])});`];for(let ye of z){let He=[ce(I[ye])];G[ye]!==oe(ye)&&He.push(`count = ${G[ye]}`),Math.abs(Y[ye]-I[ye]/(2*G[ye]))>o&&He.push(`width = ${ce(Y[ye])}`),De.push(se[ye](`tabs(${He.join(", ")});`))}_e=`{
|
|
390
|
+
${De.map(ye=>" "+ye).join(`
|
|
391
|
+
`)}
|
|
392
|
+
}`}return f([he,Me],_e,{kind:"tabs",thickness:E,library:"tabs",label:`tabs ${ce(E)} mm deep`})}let m=l.depth;if(p.some(E=>m[E]===void 0))return;let x=[0,1,2,3].map(E=>p.includes(E)&&Mi(l.outer[E])<l.length[E]*.4),w=a[0]+(x[3]?m[3]:0),v=a[1]+(x[0]?m[0]:0),T=a[2]-(x[1]?m[1]:0)-w,P=a[3]-(x[2]?m[2]:0)-v,O=(E,S,D,$,_)=>E===0?[a[0]+S-w,$,D-S,_-$]:E===1?[T-_,a[1]+S-v,_-$,D-S]:E===2?[a[2]-D-w,P-_,D-S,_-$]:[$,a[3]-D-v,_-$,D-S],C=[[],[],[],[]],L=[[],[],[],[]],B=[],A=[[w-a[0],w-a[0]+T],[v-a[1],v-a[1]+P],[a[2]-(w+T),a[2]-w],[a[3]-(v+P),a[3]-v]];for(let E of p)if(x[E])for(let[S,D]of l.outer[E])C[E].push(O(E,S,D,-m[E],0));else{let S=A[E][0];for(let[D,$]of[...l.outer[E],[A[E][1],A[E][1]]]){let[_,ie]=[Math.max(S,A[E][0]),Math.min(D,A[E][1])];ie-_>o&&((_-A[E][0]<=o||A[E][1]-ie<=o)&&B.push([E,L[E].length]),L[E].push(O(E,_,ie,-1,m[E]))),S=Math.max(S,$)}}let F=([E,S,D,$])=>as(E,S,E+D,S+$),te=Ie([as(0,0,T,P),...C.flat().map(F)]),V=()=>c(Tt(te,L.flat().map(F)),[w,v]);if(!V())return;for(let[E,S]of B.reverse()){let[D]=L[E].splice(S,1);V()||L[E].splice(S,0,D)}let q=(E,S)=>{let D=S%2===0,$=y=>D?y[0]:y[1];E.sort((y,I)=>$(y)-$(I));let _=E.every(y=>Math.abs(y[2]-E[0][2])<=o&&Math.abs(y[3]-E[0][3])<=o),ie=E.length>1?$(E[1])-$(E[0]):0,J=E.every((y,I)=>Math.abs($(y)-$(E[0])-I*ie)<=o),he=pe(ie),Me=pe($(E[0])),le=pe(Me+he*(E.length-1));if(E.length>=3&&_&&J&&he>0&&Math.floor((le-Me)/he+1e-9)+1===E.length){let[,,y,I]=E[0],H=D?`[x, ${ce(E[0][1])}]`:`[${ce(E[0][0])}, y]`;return[`for (${D?"x":"y"} = [${ce(Me)}:${ce(he)}:${ce(le)}]) translate(${H}) rect(${Ae([y,I])});`]}return E.map(([y,I,H,G])=>`translate(${Ae([y,I])}) rect(${Ae([H,G])});`)},re=[0,1,2,3].flatMap(E=>C[E].length?q(C[E],E):[]),U=[0,1,2,3].flatMap(E=>L[E].length?q(L[E],E):[]),ae=re.length?`union() {
|
|
393
|
+
${[`rect(${Ae([T,P])});`,...re].join(`
|
|
394
|
+
`)}
|
|
395
|
+
}`:`rect(${Ae([T,P])})`,de=U.length?`difference() {
|
|
396
|
+
${[ae.endsWith("}")?ae:ae+";",...U].join(`
|
|
397
|
+
`)}
|
|
398
|
+
}`:ae,me=p.map(E=>pe(m[E])),we=me.sort((E,S)=>me.filter(D=>D===S).length-me.filter(D=>D===E).length)[0];return f([w,v],de,{kind:U.length?"fingers":"tabs",thickness:we,generic:!0,label:`${U.length?"finger joints":"tabs"} ${ce(we)} mm deep`})}function wd(t){let[e,n,r,s]=st([t]),i=c=>{let f=1/0;for(let h=0,p=t.length-1;h<t.length;p=h++)f=Math.min(f,Yt(c,t[p],t[h]));return f},o=[(e+r)/2,(n+s)/2],a=Bt(o,t)?i(o):0,l=24;for(let c=0;c<=l;c++)for(let f=0;f<=l;f++){let h=[e+(r-e)*c/l,n+(s-n)*f/l];if(!Bt(h,t))continue;let p=i(h);p>a&&(o=h,a=p)}let u=Math.max(r-e,s-n)/l;for(;u>1e-4;){let c=!1;for(let[f,h]of[[1,0],[-1,0],[0,1],[0,-1]]){let p=[o[0]+f*u,o[1]+h*u];if(!Bt(p,t))continue;let d=i(p);d>a&&(o=p,a=d,c=!0)}c||(u/=2)}return{c:o,r:a}}function Sd(t,e,n){let s=Math.atan2(e[1]-t[1],e[0]-t[0]),i=[];for(let o=0;o<=64;o++){let a=s+Math.PI/2+Math.PI*o/64;i.push([t[0]+n*Math.cos(a),t[1]+n*Math.sin(a)])}for(let o=0;o<=64;o++){let a=s-Math.PI/2+Math.PI*o/64;i.push([e[0]+n*Math.cos(a),e[1]+n*Math.sin(a)])}return i}function wl(t,e){let[n,r,s,i]=t.box;if(Math.max(s-n,i-r)>80)return;let o=Ft(t.poly),a=$t(t.poly,!0,Math.min(.25,o/400)),l=wd(t.poly),u=a.filter(U=>Math.abs(ve(U,l.c)-l.r)<=e),c=ls(u);if(!c||u.length<8)return;let f=a[0];for(let U of a)ve(U,c.c)>ve(f,c.c)&&(f=U);let h=ve(f,c.c),p=[(f[0]-c.c[0])/h,(f[1]-c.c[1])/h],d=U=>(U[0]-c.c[0])*p[0]+(U[1]-c.c[1])*p[1],g=U=>-(U[0]-c.c[0])*p[1]+(U[1]-c.c[1])*p[0],m=a.filter(U=>d(U)>c.r+e&&d(U)<h-c.r);if(m.length<4)return;let x=[m.filter(U=>g(U)>0),m.filter(U=>g(U)<0)];if(x.some(U=>U.length<2))return;let w=x.map(U=>St([1,0],vl(U))).map(U=>U[0]*p[0]+U[1]*p[1]<0?[-U[0],-U[1]]:U),v=[w[0][0]+w[1][0],w[0][1]+w[1][1]],T=Math.hypot(v[0],v[1]);if(p=[v[0]/T,v[1]/T],m=a.filter(U=>d(U)>c.r+e&&d(U)<h-c.r),m.length<4||Math.abs(m.reduce((U,ae)=>U+g(ae),0)/m.length)>e)return;let P=m.map(U=>Math.abs(g(U))).sort((U,ae)=>U-ae),O=P[Math.floor(P.length/2)]*2;if(O>=c.r*2-e||O<.3)return;let C=Math.max(...a.map(d)),L=Ei(c.c,[p[0]*(C-O/2),p[1]*(C-O/2)]),B=Ie([Sn(c.r,c.r,256).map(U=>Ei(U,c.c)),Sd(c.c,L,O/2)]);if(!hn([t.poly],B,e))return;let A=C-O/2,F=c.r*2,te=Math.atan2(p[1],p[0])*180/Math.PI-90,V=[];pe(F)!==9&&V.push(`head = ${ce(F)}`),pe(O)!==4.5&&V.push(`shank = ${ce(O)}`),pe(A)!==10&&V.push(`drop = ${ce(A)}`);let q=A>=(F+O)/2-1e-9,re=q?`keyhole(${V.join(", ")})`:`{ translate(${Ae([0,-A])}) circle(d = ${ce(F)}); hull() { circle(d = ${ce(O)}); translate(${Ae([0,-A])}) circle(d = ${ce(O)}); } }`;return{kind:"keyhole",radius:F/2,body:re,at:L,angle:te,center:L,label:"keyhole",keyhole:{head:F,shank:O,drop:A,top:L},library:q?"hanging":void 0}}var pl=.0025,os=(t,e)=>Math.abs(t[0]-e[0])>pl||Math.abs(t[1]-e[1])>pl;function Rn(t,e){if(t.segs.every(n=>n.c==="L")&&t.segs.length<400){let n=t.segs.map(i=>i.a);t.closed||n.push(t.segs[t.segs.length-1].b);let r=[n[0]];for(let i of n.slice(1))os(i,r[r.length-1])&&r.push(i);!t.closed&&r.length<2&&r.push(n[n.length-1]);let s=`[${r.map(i=>Ae(kt(i,e))).join(", ")}]`;return t.closed?`polygon(${s})`:r.length===2?`line(${Ae(kt(r[0],e))}, ${Ae(kt(r[1],e))})`:`polyline(${s})`}return`path("${Ii([t],e)}")`}function Ii(t,e){let n=r=>`${ce(r[0]-e[0])} ${ce(r[1]-e[1])}`;return t.map(r=>{let s=`M${n(r.segs[0].a)}`,i=r.segs[0].a;for(let o of r.segs)!os(o.b,i)&&(o.c==="L"||!os(o.p1,i)&&!os(o.p2,i))||(s+=o.c==="L"?`L${n(o.b)}`:`C${n(o.p1)} ${n(o.p2)} ${n(o.b)}`,i=o.b);return r.closed?s+"Z":s}).join("")}var We=.01;function Sl(t){return{closed:t.closed,segs:t.segs.slice().reverse().map(e=>e.c==="L"?{c:"L",a:e.b,b:e.a}:{c:"C",a:e.b,p1:e.p2,p2:e.p1,b:e.a})}}var Un=t=>t.segs[0].a,kl=t=>t.segs[t.segs.length-1].b;function kd(t){let e=new Set,n=[],r=o=>`${Math.round(o[0]/We)},${Math.round(o[1]/We)}`,s=new Map;t.forEach((o,a)=>{for(let l of[Un(o),kl(o)]){let u=r(l);s.set(u,[...s.get(u)??[],a])}});let i=o=>{let[a,l]=[Math.round(o[0]/We),Math.round(o[1]/We)];for(let u=-1;u<=1;u++)for(let c=-1;c<=1;c++)for(let f of s.get(`${a+u},${l+c}`)??[])if(!e.has(f)&&(ve(Un(t[f]),o)<=We||ve(kl(t[f]),o)<=We))return f};for(let o=0;o<t.length;o++){if(e.has(o))continue;e.add(o);let a=t[o].segs.slice();for(let u=0;u<2;u++){for(;;){let c=a[a.length-1].b;if(ve(c,a[0].a)<=We&&a.length>1)break;let f=i(c);if(f===void 0)break;e.add(f);let h=ve(Un(t[f]),c)<=We?t[f]:Sl(t[f]);a=a.concat(h.segs)}a=Sl({segs:a,closed:!1}).segs}let l=a.length>1&&ve(a[a.length-1].b,a[0].a)<=We;n.push({sub:{segs:a,closed:l},from:t[o]})}return n}var Ml=.05;function Pd(t){let e=t instanceof Uint8Array?t:new Uint8Array(t),n=e[0]===255&&e[1]===254||e[0]===60&&e[1]===0?"utf-16le":e[0]===254&&e[1]===255||e[0]===0&&e[1]===60?"utf-16be":"utf-8";return new TextDecoder(n).decode(e)}function Md(t,e={}){let n=e.tolerance??Ml,r=typeof t=="string"?t:Pd(t),s=hl(r,{dpi:e.dpi}),i=[...s.notes],o={},a=(y,I=1)=>o[y]=(o[y]??0)+I,l=[],u=[],c=new Map;for(let y of s.items)if(y.layer.mode==="cut")for(let I of y.subs)I.closed?l.push({sub:I,names:y.names,group:y.filled?y:void 0}):(u.push(I),c.set(I,y.names));let f=kd(u);u=[];for(let{sub:y,from:I}of f)y.closed?l.push({sub:y,names:c.get(I)??[],line:{segs:y.segs,closed:!1}}):u.push(y);let h=l.map(y=>({...y,outline:gr(fn(y.sub),y.sub)})),p=h.filter(y=>y.outline.poly.length>=3&&y.outline.area>Ft(y.outline.poly)*We);for(let y of h)p.includes(y)||u.push(y.line??{segs:y.sub.segs,closed:!1});let d=(y,I,H,G)=>{if(H!==G)return!1;let[Y,b,W,z]=y.box,[oe,K,ke,j]=I.box;if(Y<oe-We||b<K-We||W>ke+We||z>j+We)return!1;let xe=y.poly.length;return[0,Math.floor(xe/3),Math.floor(2*xe/3)].filter(Ne=>Bt(y.poly[Ne],I.poly)).length>=2},g=y=>{let I=p.map((Y,b)=>b).filter(Y=>!y.has(Y)).sort((Y,b)=>p[b].outline.area-p[Y].outline.area),H=new Map,G=new Map;return I.forEach((Y,b)=>{let W=-1;for(let z=b-1;z>=0;z--){let oe=I[z];if(p[oe].outline.area>p[Y].outline.area&&d(p[Y].outline,p[oe].outline,p[Y].group,p[oe].group)){W=oe;break}}H.set(Y,W),G.set(Y,W<0?0:G.get(W)+1)}),{order:I,parent:H,depth:G}},m=gl(p.map(y=>y.outline.poly),We*2),x=g(new Set),{parent:w,depth:v}=x,T=y=>v.get(y)%2===0?y:w.get(y),P=new Set(p.map((y,I)=>I).filter(y=>m.self[y]));for(let[y,I]of m.pairs)T(y)===T(I)&&P.add(y).add(I);for(let y of x.order)v.get(y)%2===1&&P.has(w.get(y))&&P.add(y);for(let y of P)u.push(p[y].line??{segs:p[y].sub.segs,closed:!1});P.size&&i.push(`${P.size} outline${P.size===1?" touches or crosses":"s touch or cross"} a hole or ${P.size===1?"itself":"themselves"}, so ${P.size===1?"it is":"they are"} kept as cut lines.`);let O=[],C=new Map;for(let y of x.order){if(P.has(y))continue;let I=p[y];if(v.get(y)%2===0){let H={sub:I.sub,outline:I.outline,names:I.names,holes:[],lines:[],marks:new Map,texts:[]};O.push(H),C.set(y,H)}else C.get(w.get(y)).holes.push({sub:I.sub,outline:I.outline,line:I.line})}let L=e.kerf!==void 0?e.kerf/2:yl(O.map(y=>y.outline.poly)),B=0;if(L&&L>0){let y=I=>({closed:!0,segs:I.map((H,G)=>({c:"L",a:H,b:I[(G+1)%I.length]}))});for(let I of O){let H=Tt([Li(I.outline.poly,L)],I.holes.map(j=>Li(j.outline.poly,L))),G=Dr(rn(H,-L,"miter")),Y=rn(G.flat(),L,"round",Math.min(.01,L/10)),b=Tt([I.outline.poly],I.holes.map(j=>j.outline.poly)),W=j=>Math.abs(Ze(j))<=Ft(j)*We;if(G.length!==1||G[0].length!==I.holes.length+1||G[0].some(W)||!hn(Y,b,n)){I.noKerf=!0;continue}I.drawn=[I.sub,...I.holes.map(j=>j.sub)];let[z,...oe]=G[0].map(j=>Dn(j,.001));I.outline=gr(z),I.sub=y(z);let K=j=>[(j.box[0]+j.box[2])/2,(j.box[1]+j.box[3])/2],ke=oe.map(j=>gr(j));for(let j of I.holes){let xe=K(j.outline),Re=ke.reduce((Ne,_e)=>ve(K(_e),xe)<ve(K(Ne),xe)?_e:Ne);ke.splice(ke.indexOf(Re),1),j.outline=Re,j.sub=y(Re.poly),j.line=void 0}}B=L*2,e.kerf===void 0&&i.push(`The cut outlines are offset for a ${ce(B)} mm kerf: they are moved back, and $kerf is set.`)}let A=y=>{let I;for(let H of O){let[G,Y,b,W]=H.outline.box;y[0]<G||y[0]>b||y[1]<Y||y[1]>W||Bt(y,H.outline.poly)&&(!I||H.outline.area<I.outline.area)&&(I=H)}return I},F={lines:[],marks:new Map,texts:[]},te=new Map,V=y=>{let I=A(Un(y));if(!I)return;let H=te.get(I);return H||(H=ml(I.outline.poly,I.holes.map(G=>G.outline.poly),n),te.set(I,H)),H(fn(y,.02),y.closed)?I:void 0};for(let y of u){let I=V(y);(I?I.lines:F.lines).push(y)}for(let y of s.items)if(y.layer.mode!=="cut")for(let I of y.subs){let H=(V(I)??F).marks;H.set(y,[...H.get(y)??[],I])}for(let y of s.texts)(A(y.at)??F).texts.push(y);s.texts.some(y=>y.layer.mode==="cut")&&i.push("Text to cut is written with the built-in font, so its letters are not the drawing's: convert the text to paths in your editor to cut it as drawn.");for(let y of O){let I=y.lines.map(H=>fn(H));y.holes=y.holes.filter(H=>{if(!H.line)return!0;let G=b=>Bt(b,H.outline.poly),Y=xl(I,H.outline.poly,We*2)||y.lines.some(b=>G(Un(b)))||[...y.marks.values()].some(b=>b.some(W=>G(Un(W))))||y.texts.some(b=>G(b.at))||O.some(b=>b!==y&&b.outline.area<H.outline.area&&G(b.outline.poly[0]));return Y&&y.lines.push(H.line),!Y})}let q=y=>us(y,n)??fs(y,n)??cs(y,n)??hs(y,n)??wl(y,n),re=new Map;for(let y of O){let I=us(y.outline,n)??fs(y.outline,n)??cs(y.outline,n)??hs(y.outline,n)??Ti(y.outline,n);re.set(y,I);for(let H of y.holes)H.found=q(H.outline)}let U=new Map,ae=[...re.values()].some(y=>y?.thickness&&!y.generic);for(let y of re.values())y?.thickness&&y.thickness<=10&&(!ae||!y.generic)&&U.set(y.thickness,(U.get(y.thickness)??0)+1);let de=[...U.entries()].sort((y,I)=>I[1]-y[1])[0]?.[0];if(de!==void 0)for(let y of O){let I=re.get(y);if(I?.thickness!==void 0&&I.thickness!==de){let H=Ti(y.outline,n,de);H&&H.thickness===de&&re.set(y,H)}}let me=new Set;for(let y of re.values())y?.kind==="fingers"&&y.finger&&me.add(pe(y.finger));O.sort((y,I)=>{let H=I.outline.box[3]-y.outline.box[3];return Math.abs(H)>1?H:y.outline.box[0]-I.outline.box[0]});let we=new Set,E=new Map,S=[];for(let[y,I]of O.entries()){let H=I.names[0]??`part ${y+1}`,G=(E.get(H)??0)+1;E.set(H,G);let Y=G>1?`${H} ${G}`:H,b;for(let Re of[2,1,0]){let Ne=Ld(I,re.get(I),Re,de,me,n);if(Cd(Ne,I,n)){b=Ne,Re<2&&i.push(Re===1?`Part "${Y}": its holes are written one by one; grouping them did not match the drawing.`:`Part "${Y}" is written as drawn: no recognised shape matched it closely enough.`);break}}if(!b){let Re=I.drawn??[I.sub,...I.holes.map(Ne=>Ne.sub)];F.lines.push(...Re.map(Ne=>({segs:Ne.segs,closed:!1})),...I.lines);for(let[Ne,_e]of I.marks)F.marks.set(Ne,[...F.marks.get(Ne)??[],..._e]);F.texts.push(...I.texts),i.push(`Part "${Y}" is cut as lines: no shape reproduces its outline exactly.`);continue}for(let Re of b.found)a(Re);for(let Re of b.libraries)we.add(Re);let W=Pl(I.marks,[],I.texts,b.origin),z=[...b.cut,...W],oe=b.thickness,K=[...oe!==void 0&&(de===void 0||pe(oe)!==pe(de))?[`thickness = ${ce(oe)}`]:[],...I.noKerf&&B>0?["kerf = 0"]:[]],ke=K.length?`material(${K.join(", ")}) `:"",j=`part("${Y.replace(/["\\]/g,"")}")`,xe=z.length===1&&!z[0].includes(`
|
|
399
|
+
`)?`${ke}${j} ${z[0]}`:`${ke}${j} {
|
|
400
|
+
${z.join(`
|
|
401
|
+
`)}
|
|
402
|
+
}`;S.push({name:Y,code:Dt(b.origin,0,xe),local:xe,thickness:oe})}let D=Pl(F.marks,F.lines,F.texts,[0,0]);D.length&&O.length&&i.push("Some lines or marks are outside every part; they are kept on their own.");let $;if(e.pack){let y=new Map;for(let H of S){let G=H.local.replace(/part\("[^"]*"\)/,"part()"),Y=y.get(G);Y?Y.qty++:y.set(G,{name:H.name,qty:1})}$=[...y.entries()].map(([H,G])=>H.replace("part()",`part("${G.name.replace(/["\\]/g,"")}"${G.qty>1?`, qty = ${G.qty}`:""})`));let I=S.length-y.size;I&&i.push(`${I} part${I===1?" is":"s are"} the same as another and became a quantity.`)}else $=S.map(y=>y.code);let _=Object.entries(o).filter(([y])=>y!=="outline").map(([y,I])=>`${I} ${y}${I===1?"":Ed[y]??"s"}`).join(", "),ie=`${S.length} part${S.length===1?"":"s"}${_?`; found ${_}`:""}.`,J=[`// ${e.name?e.name+": ":""}imported from an SVG drawing.`,`// ${ie}`,...i.map(y=>`// ${y}`),"",...[...we].sort().map(y=>`use <kerf/${y}>`),...we.size?[""]:[]],he=[];de!==void 0&&he.push(`$thickness = ${ce(de)}; // from the joints`),B>0&&he.push(`$kerf = ${ce(B)}; // the drawing's outlines were offset by half of this`),!e.pack&&S.length&&he.push('$layout = "none"; // keep the parts where the drawing has them');let le=[J.join(`
|
|
403
|
+
`),he.join(`
|
|
404
|
+
`),$.join(`
|
|
405
|
+
|
|
406
|
+
`),D.join(`
|
|
407
|
+
`)].filter(Boolean).join(`
|
|
408
|
+
|
|
409
|
+
`).replace(/\n{3,}/g,`
|
|
410
|
+
|
|
411
|
+
`)+`
|
|
412
|
+
`;try{le=Si(le)}catch{}return{source:le,parts:S.length,found:o,summary:ie,notes:i}}var Ed={"finger jointed panel":"s","hanger hole":"s","slot row":"s","hanging loop":"s","hole pattern":"s"},mr=t=>t.trimEnd().endsWith("}")?t:t+";";function Ld(t,e,n,r,s,i){let o=[],a=new Set,l=n>0?e:void 0,u=t.outline.box,c,f;if(l?.kind==="rect"){let{w:A,h:F,r:te}=l.rect;c=kt(l.center,St([A/2,F/2],l.angle)),c=[pe(c[0]),pe(c[1])],f=Dt([0,0],l.angle,`rect(${Ae([A,F])}${pe(te)>0?`, r = ${ce(te)}`:""})`),o.push("rectangle")}else l?(c=[pe(l.at[0]),pe(l.at[1])],f=Dt(kt(l.at,c),l.angle,l.body),o.push(Ci[l.kind]),l.library&&a.add(l.library)):(c=[pe(u[0]),pe(u[1])],f=Rn(t.sub,c),o.push("outline"));let h=t.holes.map(A=>({...A,found:n>0?A.found:void 0})),p=[],d=A=>kt(A,c),g=A=>A,m=0,x=new Set(h);if(n===2&&!l)for(let A of h){let F=A.found?.circle;if(!F||F.r*2>15)continue;let te=$t(t.outline.poly,!0,.25),V=Math.min(...te.map(ae=>ve(ae,F.c))),q=V-F.r;if(q<.5||te.filter(ae=>Math.abs(ve(ae,F.c)-V)<=i).length*.25<V*Math.PI*.8)continue;let U=[Ae(d(F.c))];pe(F.r*2)!==4&&U.push(`d = ${ce(F.r*2)}`),pe(q)!==3&&U.push(`wall = ${ce(q)}`),g=ae=>`hanging_loop(${U.join(", ")}) ${ae}`,m=V,a.add("hanging"),o.push("hanging loop"),x.delete(A);break}if(n===2){let[A,F,te,V]=u,q=(A+te)/2,re=te-A,U=V-F,ae=S=>S[1]>=F+U*.66,de=S=>[...x].filter(D=>D.found?.circle&&pe(D.found.circle.r)===pe(S.found.circle.r)).length,me=[...x].filter(S=>S.found?.circle&&S.found.circle.r*2>=1.5&&S.found.circle.r*2<=15&&ae(S.found.circle.c)&&de(S)<=2),we=!1;for(let S of me){let D=S.found.circle;if(Math.abs(D.c[0]-q)>Math.max(.5,re*.02))continue;let $=D.r*2;p.push(`hanging_hole(${Ae(d(D.c))}${pe($)!==5?`, d = ${ce($)}`:""})`),x.delete(S),we=!0;break}if(!we)for(let S of me)for(let D of me){if(we||S===D)continue;let[$,_]=[S.found.circle,D.found.circle];if(Math.abs($.r-_.r)>i||Math.abs($.c[1]-_.c[1])>i||$.c[0]>=_.c[0])continue;let ie=[($.c[0]+_.c[0])/2,$.c[1]];if(Math.abs(ie[0]-q)>Math.max(1,re*.02))continue;let J=$.r*2;p.push(`hanging_hole(${Ae(d(ie))}${pe(J)!==5?`, d = ${ce(J)}`:""}, spacing = ${ce(_.c[0]-$.c[0])})`),x.delete(S),x.delete(D),we=!0}we&&(a.add("hanging"),o.push("hanger hole"));let E=[...x].filter(S=>S.found?.kind==="keyhole"&&S.found.library&&Math.abs(S.found.angle)<.01);for(let S of E)for(let D of E){if(!x.has(S)||!x.has(D)||S===D)continue;let[$,_]=[S.found,D.found];if($.body!==_.body||Math.abs($.at[1]-_.at[1])>i||$.at[0]>=_.at[0])continue;let ie=[ce(_.at[0]-$.at[0])],J=d([($.at[0]+_.at[0])/2,$.at[1]]),he=$.body.slice(8,-1);ie.push(pe(J[0])||pe(J[1])?`at = ${Ae(J)}`:""),he&&ie.push(he),p.push(`keyholes(${ie.filter(Boolean).join(", ")})`),x.delete(S),x.delete(D),a.add("hanging"),o.push("keyhole","keyhole")}if(r!==void 0){let S=[...x].filter(D=>D.found?.kind==="rect"&&pe(D.found.rect.r)===0);for(let D of Td(S,i)){let{items:$,dir:_,spacing:ie,along:J,across:he}=D,Me=$.length,le=r,y=he-le,I=kt($[0].found.center,[_[0]*ie/2,_[1]*ie/2]),H=Math.atan2(_[1],_[0])*180/Math.PI,G=Me*ie;if(Math.abs(y)<=i&&Math.abs(J-ie/2)<=i&&Me>=2){let Y=2*Me-1,b=Y*J,W=Math.max(3*le,6),z=(ke,j)=>{let xe=Math.round(ke/j);return xe%2===0&&(xe+=ke/j>xe?1:-1),Math.max(3,xe)};if(z(b,W)!==Y&&z(b,J)!==Y)continue;let oe=kt($[0].found.center,[_[0]*J/2,_[1]*J/2]),K=z(b,W)===Y?"":`, finger = ${ce(J)}`;p.push(Dt(d(oe),H,`finger_holes(${ce(b)}${K})`)),o.push("finger joint slot row")}else if(y>=-i&&y<=1){let Y=[ce(G)];Me!==Math.max(1,Math.round(G/50))&&Y.push(`count = ${Me}`);let b=J-y;Math.abs(b-G/(2*Me))>i&&Y.push(`width = ${ce(b)}`),Math.abs(y-.1)>.001&&Y.push(`clearance = ${ce(y)}`),p.push(Dt(d(I),H,`slots(${Y.join(", ")})`)),a.add("tabs"),o.push("slot row")}else continue;for(let Y of $)x.delete(Y)}}}let w=[...x].filter(A=>A.found),v=[...x].filter(A=>!A.found);if(n===2){let A=new Map;for(let F of w){let te=Dt([0,0],F.found.angle,F.found.body);A.set(te,[...A.get(te)??[],F])}for(let[F,te]of A){let V=Id(te.map(q=>d(q.found.at)),i);if(V){p.push(`${V} ${F}`);for(let q of te)o.push(Ci[q.found.kind]),q.found.library&&a.add(q.found.library);o.push("hole pattern");for(let q of te)x.delete(q)}}}for(let A of x)A.found&&(p.push(Dt(d(A.found.at),A.found.angle,A.found.body)),o.push(Ci[A.found.kind]),A.found.library&&a.add(A.found.library));for(let A of v)p.push(Rn(A.sub,c)),o.push("outline");let T=g(f),P=p.length?[`difference() {
|
|
413
|
+
${[T,...p].map(mr).join(`
|
|
414
|
+
`)}
|
|
415
|
+
}`]:[mr(T)],O=t.lines.map(A=>mr(Rn(A,c))),C=e?.thickness??r,L=[...[...a].map(A=>`use <kerf/${A}>`),`$thickness = ${C??3};`,`translate(${Ae(c)}) {
|
|
416
|
+
${[...P,...O].join(`
|
|
417
|
+
`)}
|
|
418
|
+
}`].join(`
|
|
419
|
+
`),B=Math.max(0,m,l?.radius??0,...h.map(A=>n>0?A.found?.radius??0:0));return{origin:c,round:B,cut:[...P,...O],check:L,found:o,libraries:a,thickness:l?.thickness}}var Ci={circle:"circle",ellipse:"ellipse",rect:"rectangle",polygon:"polygon",star:"star",tabs:"tabbed panel",fingers:"finger jointed panel",keyhole:"keyhole",outline:"outline"};function Td(t,e){let n=[],r=new Set,s=o=>{let a=o.found.rect;return`${Math.round((o.found.angle%180+180)%180)}|${pe(a.w)}|${pe(a.h)}`},i=new Map;for(let o of t)i.set(s(o),[...i.get(s(o))??[],o]);for(let o of i.values()){if(o.length<2)continue;let{w:a,h:l}=o[0].found.rect,u=o[0].found.angle;for(let[c,f,h]of[[u,a,l],[u+90,l,a]]){let p=St([1,0],c),d=[-p[1],p[0]],g=o.filter(x=>!r.has(x)),m=new Map;for(let x of g){let w=x.found.center,v=Math.round((w[0]*d[0]+w[1]*d[1])/e),T=[...m.keys()].find(P=>Math.abs(P-v)<=1)??v;m.set(T,[...m.get(T)??[],x])}for(let x of m.values()){let w=T=>T.found.center[0]*p[0]+T.found.center[1]*p[1];x.sort((T,P)=>w(T)-w(P));let v=0;for(;v<x.length-1;){let T=w(x[v+1])-w(x[v]),P=v+1;for(;P+1<x.length&&Math.abs(w(x[P+1])-w(x[P])-T)<=e;)P++;if(P>v&&T>f){let O=x.slice(v,P+1);for(let C of O)r.add(C);n.push({items:O,dir:p,spacing:T,along:f,across:h})}v=P}}}}return n}function Id(t,e){if(t.length<3)return;let n=c=>{let f=[];for(let g of[...c].sort((m,x)=>m-x))(!f.length||g-f[f.length-1]>e*2)&&f.push(g);if(f.length===1)return;let[h,p]=[pe(f[0]),pe((f[f.length-1]-f[0])/(f.length-1))],d=pe(h+p*(f.length-1));if(!(p<=0||Math.floor((d-h)/p+1e-9)+1!==f.length)&&!f.some((g,m)=>Math.abs(g-(h+m*p))>e))return`[${ce(h)}:${ce(p)}:${ce(d)}]`},r=t.map(c=>c[0]),s=t.map(c=>c[1]),i=c=>new Set(c.map(f=>Math.round(f/(e*2)))).size,o=i(r),a=i(s);if(a===1||o===1){let c=a===1?r:s;if(i(c)!==t.length)return;let f=n(c);return f?a===1?`for (x = ${f}) translate([x, ${ce(s[0])}])`:`for (y = ${f}) translate([${ce(r[0])}, y])`:void 0}if(o*a!==t.length)return;let l=n(r),u=n(s);if(!(!l||!u))return`for (x = ${l}, y = ${u}) translate([x, y])`}function Pl(t,e,n,r){let s=[];for(let a of e)s.push(mr(Rn(a,r)));let i=new Map,o=(a,l,u)=>{let c=a.name,f=i.get(c)??{layer:a,code:[]};f.code.push(mr(l)+(u?` // ${u}`:"")),i.set(c,f)};for(let[a,l]of t){let u=Ml;if(l.length===1&&l[0].closed){let p=gr(fn(l[0]),l[0]),d=p.area>1e-6?us(p,u)??fs(p,u)??cs(p,u)??hs(p,u):void 0;if(d){o(a.layer,Dt(kt(d.at,r),d.angle,d.body));continue}}if(a.layer.mode!=="fill"||l.every(p=>!p.closed)){for(let p of l)o(a.layer,Rn(p,r));continue}let c=Ii(l,r),f=l.filter(p=>p.closed).map(p=>fn(p)),h=a.fillRule==="evenodd"||hn(Ie(f,"nonzero"),Ie(f,"evenodd"),.01);o(a.layer,`path("${c}"${h?"":', fill = "nonzero"'})`)}for(let a of n){let l=[JSON.stringify(a.text),`size = ${ce(a.size)}`];a.anchor!=="left"&&l.push(`halign = "${a.anchor}"`),o(a.layer,Dt(kt(a.at,r),a.angle,`text(${l.join(", ")})`),a.font?`${a.font} in the drawing`:void 0)}for(let{layer:a,code:l}of i.values()){let u=["cut","score","engrave","guide"].includes(a.name)?`${a.name}()`:`layer("${a.name}", mode = "${a.mode}", color = "${a.color}")`;s.push(l.length===1&&!l[0].includes("//")?`${u} ${l[0]}`:`${u} {
|
|
420
|
+
${l.join(`
|
|
421
|
+
`)}
|
|
422
|
+
}`)}return s}function Cd(t,e,n){let r;try{r=new Cn({maxSteps:2e6}).run(mt(t.check).program).shape}catch{return!1}let s=r.layers.get("cut");if(!s)return!1;let i=Tt([e.outline.poly],e.holes.map(u=>u.outline.poly)),o=Ie(s.regions),a=n+t.round*16e-5;if(!hn(i,o,a))return!1;let l=e.lines.map(u=>fn(u));return!(l.length&&!hn(l,s.lines,a,!1))}var Mm="0.6.0",Em="0.2";export{ss as DEFAULT_LAYERS,rl as DEFAULT_LIMITS,ne as KerfError,Em as LANGUAGE_VERSION,yo as SIGNATURES,Mm as VERSION,Si as format,Yp as formatError,$s as formatSignature,Md as importSvg,Wp as parameters,mt as parse,qp as render,er as signature,Jn as tokenize};
|
|
389
423
|
/*! Bundled license information:
|
|
390
424
|
|
|
391
425
|
opentype.js/dist/opentype.module.js:
|