(()=>{var si=Object.create;var bt=Object.defineProperty;var ai=Object.getOwnPropertyDescriptor;var li=Object.getOwnPropertyNames;var ui=Object.getPrototypeOf,ci=Object.prototype.hasOwnProperty;var fi=(t,s,f)=>s in t?bt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:f}):t[s]=f;var tt=(t,s)=>()=>(t&&(s=t(t=0)),s);var hi=(t,s)=>()=>(s||t((s={exports:{}}).exports,s),s.exports);var pi=(t,s,f,a)=>{if(s&&typeof s=="object"||typeof s=="function")for(let u of li(s))!ci.call(t,u)&&u!==f&&bt(t,u,{get:()=>s[u],enumerable:!(a=ai(s,u))||a.enumerable});return t};var Ve=(t,s,f)=>(f=t!=null?si(ui(t)):{},pi(s||!t||!t.__esModule?bt(f,"default",{value:t,enumerable:!0}):f,t));var Pt=(t,s,f)=>fi(t,typeof s!="symbol"?s+"":s,f);function _(t,s){return jt+t+(s?Wt+JSON.stringify(s):"")+Vt}function xt(t){let s=[],f=0;for(;f<t.length;){let a=t.indexOf(jt,f);if(a<0){s.push(t.slice(f));break}a>f&&s.push(t.slice(f,a));let u=t.indexOf(Vt,a),p=t.slice(a+1,u<0?t.length:u),d=p.indexOf(Wt);if(d<0)s.push({de:p});else{let g=JSON.parse(p.slice(d+1)),c={};for(let[b,w]of Object.entries(g))c[b]=typeof w=="number"?w:xt(String(w));s.push({de:p.slice(0,d),values:c})}f=u<0?t.length:u+1}return s}var jt,Wt,Vt,ye,oe=tt(()=>{"use strict";jt="",Wt="",Vt="";ye=t=>typeof t=="string"?t:""});var Xe=hi((oo,nt)=>{(function(){"use strict";var t={};t.version="6.4.2.2",t.use_lines=!0,t.use_xyz=!1;var s=!1;typeof nt<"u"&&nt.exports?(nt.exports=t,s=!0):(typeof define=="function"&&define.amd&&define(t),typeof document<"u"?window.ClipperLib=t:self.ClipperLib=t);var f;if(s){var a="chrome";f="Netscape"}else{var a=navigator.userAgent.toString().toLowerCase();f=navigator.appName}var u={};a.indexOf("chrome")!=-1&&a.indexOf("chromium")==-1?u.chrome=1:u.chrome=0,a.indexOf("chromium")!=-1?u.chromium=1:u.chromium=0,a.indexOf("safari")!=-1&&a.indexOf("chrome")==-1&&a.indexOf("chromium")==-1?u.safari=1:u.safari=0,a.indexOf("firefox")!=-1?u.firefox=1:u.firefox=0,a.indexOf("firefox/17")!=-1?u.firefox17=1:u.firefox17=0,a.indexOf("firefox/15")!=-1?u.firefox15=1:u.firefox15=0,a.indexOf("firefox/3")!=-1?u.firefox3=1:u.firefox3=0,a.indexOf("opera")!=-1?u.opera=1:u.opera=0,a.indexOf("msie 10")!=-1?u.msie10=1:u.msie10=0,a.indexOf("msie 9")!=-1?u.msie9=1:u.msie9=0,a.indexOf("msie 8")!=-1?u.msie8=1:u.msie8=0,a.indexOf("msie 7")!=-1?u.msie7=1:u.msie7=0,a.indexOf("msie ")!=-1?u.msie=1:u.msie=0,t.biginteger_used=null;var p,d=0xdeadbeefcafe,g=(d&16777215)==15715070;function c(e,n,r){t.biginteger_used=1,e!=null&&(typeof e=="number"&&typeof n>"u"?this.fromInt(e):typeof e=="number"?this.fromNumber(e,n,r):n==null&&typeof e!="string"?this.fromString(e,256):this.fromString(e,n))}function b(){return new c(null,void 0,void 0)}function w(e,n,r,i,o,l){for(;--l>=0;){var h=n*this[e++]+r[i]+o;o=Math.floor(h/67108864),r[i++]=h&67108863}return o}function k(e,n,r,i,o,l){for(var h=n&32767,m=n>>15;--l>=0;){var y=this[e]&32767,x=this[e++]>>15,A=m*y+x*h;y=h*y+((A&32767)<<15)+r[i]+(o&1073741823),o=(y>>>30)+(A>>>15)+m*x+(o>>>30),r[i++]=y&1073741823}return o}function M(e,n,r,i,o,l){for(var h=n&16383,m=n>>14;--l>=0;){var y=this[e]&16383,x=this[e++]>>14,A=m*y+x*h;y=h*y+((A&16383)<<14)+r[i]+o,o=(y>>28)+(A>>14)+m*x,r[i++]=y&268435455}return o}g&&f=="Microsoft Internet Explorer"?(c.prototype.am=k,p=30):g&&f!="Netscape"?(c.prototype.am=w,p=26):(c.prototype.am=M,p=28),c.prototype.DB=p,c.prototype.DM=(1<<p)-1,c.prototype.DV=1<<p;var T=52;c.prototype.FV=Math.pow(2,T),c.prototype.F1=T-p,c.prototype.F2=2*p-T;var C="0123456789abcdefghijklmnopqrstuvwxyz",P=new Array,v,S;for(v=48,S=0;S<=9;++S)P[v++]=S;for(v=97,S=10;S<36;++S)P[v++]=S;for(v=65,S=10;S<36;++S)P[v++]=S;function L(e){return C.charAt(e)}function O(e,n){var r=P[e.charCodeAt(n)];return r??-1}function V(e){for(var n=this.t-1;n>=0;--n)e[n]=this[n];e.t=this.t,e.s=this.s}function j(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}function U(e){var n=b();return n.fromInt(e),n}function N(e,n){var r;if(n==16)r=4;else if(n==8)r=3;else if(n==256)r=8;else if(n==2)r=1;else if(n==32)r=5;else if(n==4)r=2;else{this.fromRadix(e,n);return}this.t=0,this.s=0;for(var i=e.length,o=!1,l=0;--i>=0;){var h=r==8?e[i]&255:O(e,i);if(h<0){e.charAt(i)=="-"&&(o=!0);continue}o=!1,l==0?this[this.t++]=h:l+r>this.DB?(this[this.t-1]|=(h&(1<<this.DB-l)-1)<<l,this[this.t++]=h>>this.DB-l):this[this.t-1]|=h<<l,l+=r,l>=this.DB&&(l-=this.DB)}r==8&&e[0]&128&&(this.s=-1,l>0&&(this[this.t-1]|=(1<<this.DB-l)-1<<l)),this.clamp(),o&&c.ZERO.subTo(this,this)}function R(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t}function G(e){if(this.s<0)return"-"+this.negate().toString(e);var n;if(e==16)n=4;else if(e==8)n=3;else if(e==2)n=1;else if(e==32)n=5;else if(e==4)n=2;else return this.toRadix(e);var r=(1<<n)-1,i,o=!1,l="",h=this.t,m=this.DB-h*this.DB%n;if(h-- >0)for(m<this.DB&&(i=this[h]>>m)>0&&(o=!0,l=L(i));h>=0;)m<n?(i=(this[h]&(1<<m)-1)<<n-m,i|=this[--h]>>(m+=this.DB-n)):(i=this[h]>>(m-=n)&r,m<=0&&(m+=this.DB,--h)),i>0&&(o=!0),o&&(l+=L(i));return o?l:"0"}function H(){var e=b();return c.ZERO.subTo(this,e),e}function q(){return this.s<0?this.negate():this}function W(e){var n=this.s-e.s;if(n!=0)return n;var r=this.t;if(n=r-e.t,n!=0)return this.s<0?-n:n;for(;--r>=0;)if((n=this[r]-e[r])!=0)return n;return 0}function $(e){var n=1,r;return(r=e>>>16)!=0&&(e=r,n+=16),(r=e>>8)!=0&&(e=r,n+=8),(r=e>>4)!=0&&(e=r,n+=4),(r=e>>2)!=0&&(e=r,n+=2),(r=e>>1)!=0&&(e=r,n+=1),n}function z(){return this.t<=0?0:this.DB*(this.t-1)+$(this[this.t-1]^this.s&this.DM)}function D(e,n){var r;for(r=this.t-1;r>=0;--r)n[r+e]=this[r];for(r=e-1;r>=0;--r)n[r]=0;n.t=this.t+e,n.s=this.s}function K(e,n){for(var r=e;r<this.t;++r)n[r-e]=this[r];n.t=Math.max(this.t-e,0),n.s=this.s}function ee(e,n){var r=e%this.DB,i=this.DB-r,o=(1<<i)-1,l=Math.floor(e/this.DB),h=this.s<<r&this.DM,m;for(m=this.t-1;m>=0;--m)n[m+l+1]=this[m]>>i|h,h=(this[m]&o)<<r;for(m=l-1;m>=0;--m)n[m]=0;n[l]=h,n.t=this.t+l+1,n.s=this.s,n.clamp()}function re(e,n){n.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t){n.t=0;return}var i=e%this.DB,o=this.DB-i,l=(1<<i)-1;n[0]=this[r]>>i;for(var h=r+1;h<this.t;++h)n[h-r-1]|=(this[h]&l)<<o,n[h-r]=this[h]>>i;i>0&&(n[this.t-r-1]|=(this.s&l)<<o),n.t=this.t-r,n.clamp()}function ve(e,n){for(var r=0,i=0,o=Math.min(e.t,this.t);r<o;)i+=this[r]-e[r],n[r++]=i&this.DM,i>>=this.DB;if(e.t<this.t){for(i-=e.s;r<this.t;)i+=this[r],n[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<e.t;)i-=e[r],n[r++]=i&this.DM,i>>=this.DB;i-=e.s}n.s=i<0?-1:0,i<-1?n[r++]=this.DV+i:i>0&&(n[r++]=i),n.t=r,n.clamp()}function et(e,n){var r=this.abs(),i=e.abs(),o=r.t;for(n.t=o+i.t;--o>=0;)n[o]=0;for(o=0;o<i.t;++o)n[o+r.t]=r.am(0,i[o],n,o,0,r.t);n.s=0,n.clamp(),this.s!=e.s&&c.ZERO.subTo(n,n)}function Be(e){for(var n=this.abs(),r=e.t=2*n.t;--r>=0;)e[r]=0;for(r=0;r<n.t-1;++r){var i=n.am(r,n[r],e,2*r,0,1);(e[r+n.t]+=n.am(r+1,2*n[r],e,2*r+1,i,n.t-r-1))>=n.DV&&(e[r+n.t]-=n.DV,e[r+n.t+1]=1)}e.t>0&&(e[e.t-1]+=n.am(r,n[r],e,2*r,0,1)),e.s=0,e.clamp()}function Re(e,n,r){var i=e.abs();if(!(i.t<=0)){var o=this.abs();if(o.t<i.t){n?.fromInt(0),r!=null&&this.copyTo(r);return}r==null&&(r=b());var l=b(),h=this.s,m=e.s,y=this.DB-$(i[i.t-1]);y>0?(i.lShiftTo(y,l),o.lShiftTo(y,r)):(i.copyTo(l),o.copyTo(r));var x=l.t,A=l[x-1];if(A!=0){var I=A*(1<<this.F1)+(x>1?l[x-2]>>this.F2:0),E=this.FV/I,X=(1<<this.F1)/I,Y=1<<this.F2,B=r.t,J=B-x,ue=n??b();for(l.dlShiftTo(J,ue),r.compareTo(ue)>=0&&(r[r.t++]=1,r.subTo(ue,r)),c.ONE.dlShiftTo(x,ue),ue.subTo(l,l);l.t<x;)l[l.t++]=0;for(;--J>=0;){var me=r[--B]==A?this.DM:Math.floor(r[B]*E+(r[B-1]+Y)*X);if((r[B]+=l.am(0,me,r,J,0,x))<me)for(l.dlShiftTo(J,ue),r.subTo(ue,r);r[B]<--me;)r.subTo(ue,r)}n!=null&&(r.drShiftTo(x,n),h!=m&&c.ZERO.subTo(n,n)),r.t=x,r.clamp(),y>0&&r.rShiftTo(y,r),h<0&&c.ZERO.subTo(r,r)}}}function je(e){var n=b();return this.abs().divRemTo(e,null,n),this.s<0&&n.compareTo(c.ZERO)>0&&e.subTo(n,n),n}function de(e){this.m=e}function Le(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function _e(e){return e}function Yn(e){e.divRemTo(this.m,null,e)}function Bn(e,n,r){e.multiplyTo(n,r),this.reduce(r)}function Rn(e,n){e.squareTo(n),this.reduce(n)}de.prototype.convert=Le,de.prototype.revert=_e,de.prototype.reduce=Yn,de.prototype.mulTo=Bn,de.prototype.sqrTo=Rn;function jn(){if(this.t<1)return 0;var e=this[0];if(!(e&1))return 0;var n=e&3;return n=n*(2-(e&15)*n)&15,n=n*(2-(e&255)*n)&255,n=n*(2-((e&65535)*n&65535))&65535,n=n*(2-e*n%this.DV)%this.DV,n>0?this.DV-n:-n}function Te(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function Wn(e){var n=b();return e.abs().dlShiftTo(this.m.t,n),n.divRemTo(this.m,null,n),e.s<0&&n.compareTo(c.ZERO)>0&&this.m.subTo(n,n),n}function Vn(e){var n=b();return e.copyTo(n),this.reduce(n),n}function Gn(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var n=0;n<this.m.t;++n){var r=e[n]&32767,i=r*this.mpl+((r*this.mph+(e[n]>>15)*this.mpl&this.um)<<15)&e.DM;for(r=n+this.m.t,e[r]+=this.m.am(0,i,e,n,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function Un(e,n){e.squareTo(n),this.reduce(n)}function Zn(e,n,r){e.multiplyTo(n,r),this.reduce(r)}Te.prototype.convert=Wn,Te.prototype.revert=Vn,Te.prototype.reduce=Gn,Te.prototype.mulTo=Zn,Te.prototype.sqrTo=Un;function Jn(){return(this.t>0?this[0]&1:this.s)==0}function zn(e,n){if(e>4294967295||e<1)return c.ONE;var r=b(),i=b(),o=n.convert(this),l=$(e)-1;for(o.copyTo(r);--l>=0;)if(n.sqrTo(r,i),(e&1<<l)>0)n.mulTo(i,o,r);else{var h=r;r=i,i=h}return n.revert(r)}function Hn(e,n){var r;return e<256||n.isEven()?r=new de(n):r=new Te(n),this.exp(e,r)}c.prototype.copyTo=V,c.prototype.fromInt=j,c.prototype.fromString=N,c.prototype.clamp=R,c.prototype.dlShiftTo=D,c.prototype.drShiftTo=K,c.prototype.lShiftTo=ee,c.prototype.rShiftTo=re,c.prototype.subTo=ve,c.prototype.multiplyTo=et,c.prototype.squareTo=Be,c.prototype.divRemTo=Re,c.prototype.invDigit=jn,c.prototype.isEven=Jn,c.prototype.exp=zn,c.prototype.toString=G,c.prototype.negate=H,c.prototype.abs=q,c.prototype.compareTo=W,c.prototype.bitLength=z,c.prototype.mod=je,c.prototype.modPowInt=Hn,c.ZERO=U(0),c.ONE=U(1);function Kn(){var e=b();return this.copyTo(e),e}function qn(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function $n(){return this.t==0?this.s:this[0]<<24>>24}function Qn(){return this.t==0?this.s:this[0]<<16>>16}function er(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function tr(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function nr(e){if(e==null&&(e=10),this.signum()==0||e<2||e>36)return"0";var n=this.chunkSize(e),r=Math.pow(e,n),i=U(r),o=b(),l=b(),h="";for(this.divRemTo(i,o,l);o.signum()>0;)h=(r+l.intValue()).toString(e).substr(1)+h,o.divRemTo(i,o,l);return l.intValue().toString(e)+h}function rr(e,n){this.fromInt(0),n==null&&(n=10);for(var r=this.chunkSize(n),i=Math.pow(n,r),o=!1,l=0,h=0,m=0;m<e.length;++m){var y=O(e,m);if(y<0){e.charAt(m)=="-"&&this.signum()==0&&(o=!0);continue}h=n*h+y,++l>=r&&(this.dMultiply(i),this.dAddOffset(h,0),l=0,h=0)}l>0&&(this.dMultiply(Math.pow(n,l)),this.dAddOffset(h,0)),o&&c.ZERO.subTo(this,this)}function ir(e,n,r){if(typeof n=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(c.ONE.shiftLeft(e-1),gt,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(n);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(c.ONE.shiftLeft(e-1),this);else{var i=new Array,o=e&7;i.length=(e>>3)+1,n.nextBytes(i),o>0?i[0]&=(1<<o)-1:i[0]=0,this.fromString(i,256)}}function or(){var e=this.t,n=new Array;n[0]=this.s;var r=this.DB-e*this.DB%8,i,o=0;if(e-- >0)for(r<this.DB&&(i=this[e]>>r)!=(this.s&this.DM)>>r&&(n[o++]=i|this.s<<this.DB-r);e>=0;)r<8?(i=(this[e]&(1<<r)-1)<<8-r,i|=this[--e]>>(r+=this.DB-8)):(i=this[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),i&128&&(i|=-256),o==0&&(this.s&128)!=(i&128)&&++o,(o>0||i!=this.s)&&(n[o++]=i);return n}function sr(e){return this.compareTo(e)==0}function ar(e){return this.compareTo(e)<0?this:e}function lr(e){return this.compareTo(e)>0?this:e}function ur(e,n,r){var i,o,l=Math.min(e.t,this.t);for(i=0;i<l;++i)r[i]=n(this[i],e[i]);if(e.t<this.t){for(o=e.s&this.DM,i=l;i<this.t;++i)r[i]=n(this[i],o);r.t=this.t}else{for(o=this.s&this.DM,i=l;i<e.t;++i)r[i]=n(o,e[i]);r.t=e.t}r.s=n(this.s,e.s),r.clamp()}function cr(e,n){return e&n}function fr(e){var n=b();return this.bitwiseTo(e,cr,n),n}function gt(e,n){return e|n}function hr(e){var n=b();return this.bitwiseTo(e,gt,n),n}function Ft(e,n){return e^n}function pr(e){var n=b();return this.bitwiseTo(e,Ft,n),n}function Yt(e,n){return e&~n}function dr(e){var n=b();return this.bitwiseTo(e,Yt,n),n}function mr(){for(var e=b(),n=0;n<this.t;++n)e[n]=this.DM&~this[n];return e.t=this.t,e.s=~this.s,e}function yr(e){var n=b();return e<0?this.rShiftTo(-e,n):this.lShiftTo(e,n),n}function gr(e){var n=b();return e<0?this.lShiftTo(-e,n):this.rShiftTo(e,n),n}function br(e){if(e==0)return-1;var n=0;return e&65535||(e>>=16,n+=16),e&255||(e>>=8,n+=8),e&15||(e>>=4,n+=4),e&3||(e>>=2,n+=2),e&1||++n,n}function Pr(){for(var e=0;e<this.t;++e)if(this[e]!=0)return e*this.DB+br(this[e]);return this.s<0?this.t*this.DB:-1}function xr(e){for(var n=0;e!=0;)e&=e-1,++n;return n}function vr(){for(var e=0,n=this.s&this.DM,r=0;r<this.t;++r)e+=xr(this[r]^n);return e}function wr(e){var n=Math.floor(e/this.DB);return n>=this.t?this.s!=0:(this[n]&1<<e%this.DB)!=0}function Sr(e,n){var r=c.ONE.shiftLeft(e);return this.bitwiseTo(r,n,r),r}function Cr(e){return this.changeBit(e,gt)}function Ir(e){return this.changeBit(e,Yt)}function kr(e){return this.changeBit(e,Ft)}function Mr(e,n){for(var r=0,i=0,o=Math.min(e.t,this.t);r<o;)i+=this[r]+e[r],n[r++]=i&this.DM,i>>=this.DB;if(e.t<this.t){for(i+=e.s;r<this.t;)i+=this[r],n[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<e.t;)i+=e[r],n[r++]=i&this.DM,i>>=this.DB;i+=e.s}n.s=i<0?-1:0,i>0?n[r++]=i:i<-1&&(n[r++]=this.DV+i),n.t=r,n.clamp()}function Tr(e){var n=b();return this.addTo(e,n),n}function Ar(e){var n=b();return this.subTo(e,n),n}function Lr(e){var n=b();return this.multiplyTo(e,n),n}function _r(){var e=b();return this.squareTo(e),e}function Er(e){var n=b();return this.divRemTo(e,n,null),n}function Or(e){var n=b();return this.divRemTo(e,null,n),n}function Nr(e){var n=b(),r=b();return this.divRemTo(e,n,r),new Array(n,r)}function Xr(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function Dr(e,n){if(e!=0){for(;this.t<=n;)this[this.t++]=0;for(this[n]+=e;this[n]>=this.DV;)this[n]-=this.DV,++n>=this.t&&(this[this.t++]=0),++this[n]}}function We(){}function Bt(e){return e}function Fr(e,n,r){e.multiplyTo(n,r)}function Yr(e,n){e.squareTo(n)}We.prototype.convert=Bt,We.prototype.revert=Bt,We.prototype.mulTo=Fr,We.prototype.sqrTo=Yr;function Br(e){return this.exp(e,new We)}function Rr(e,n,r){var i=Math.min(this.t+e.t,n);for(r.s=0,r.t=i;i>0;)r[--i]=0;var o;for(o=r.t-this.t;i<o;++i)r[i+this.t]=this.am(0,e[i],r,i,0,this.t);for(o=Math.min(e.t,n);i<o;++i)this.am(0,e[i],r,i,0,n-i);r.clamp()}function jr(e,n,r){--n;var i=r.t=this.t+e.t-n;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(n-this.t,0);i<e.t;++i)r[this.t+i-n]=this.am(n-i,e[i],r,0,0,this.t+i-n);r.clamp(),r.drShiftTo(1,r)}function Ee(e){this.r2=b(),this.q3=b(),c.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}function Wr(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var n=b();return e.copyTo(n),this.reduce(n),n}function Vr(e){return e}function Gr(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)}function Ur(e,n){e.squareTo(n),this.reduce(n)}function Zr(e,n,r){e.multiplyTo(n,r),this.reduce(r)}Ee.prototype.convert=Wr,Ee.prototype.revert=Vr,Ee.prototype.reduce=Gr,Ee.prototype.mulTo=Zr,Ee.prototype.sqrTo=Ur;function Jr(e,n){var r=e.bitLength(),i,o=U(1),l;if(r<=0)return o;r<18?i=1:r<48?i=3:r<144?i=4:r<768?i=5:i=6,r<8?l=new de(n):n.isEven()?l=new Ee(n):l=new Te(n);var h=new Array,m=3,y=i-1,x=(1<<i)-1;if(h[1]=l.convert(this),i>1){var A=b();for(l.sqrTo(h[1],A);m<=x;)h[m]=b(),l.mulTo(A,h[m-2],h[m]),m+=2}var I=e.t-1,E,X=!0,Y=b(),B;for(r=$(e[I])-1;I>=0;){for(r>=y?E=e[I]>>r-y&x:(E=(e[I]&(1<<r+1)-1)<<y-r,I>0&&(E|=e[I-1]>>this.DB+r-y)),m=i;!(E&1);)E>>=1,--m;if((r-=m)<0&&(r+=this.DB,--I),X)h[E].copyTo(o),X=!1;else{for(;m>1;)l.sqrTo(o,Y),l.sqrTo(Y,o),m-=2;m>0?l.sqrTo(o,Y):(B=o,o=Y,Y=B),l.mulTo(Y,h[E],o)}for(;I>=0&&!(e[I]&1<<r);)l.sqrTo(o,Y),B=o,o=Y,Y=B,--r<0&&(r=this.DB-1,--I)}return l.revert(o)}function zr(e){var n=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(n.compareTo(r)<0){var i=n;n=r,r=i}var o=n.getLowestSetBit(),l=r.getLowestSetBit();if(l<0)return n;for(o<l&&(l=o),l>0&&(n.rShiftTo(l,n),r.rShiftTo(l,r));n.signum()>0;)(o=n.getLowestSetBit())>0&&n.rShiftTo(o,n),(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),n.compareTo(r)>=0?(n.subTo(r,n),n.rShiftTo(1,n)):(r.subTo(n,r),r.rShiftTo(1,r));return l>0&&r.lShiftTo(l,r),r}function Hr(e){if(e<=0)return 0;var n=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(n==0)r=this[0]%e;else for(var i=this.t-1;i>=0;--i)r=(n*r+this[i])%e;return r}function Kr(e){var n=e.isEven();if(this.isEven()&&n||e.signum()==0)return c.ZERO;for(var r=e.clone(),i=this.clone(),o=U(1),l=U(0),h=U(0),m=U(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),n?((!o.isEven()||!l.isEven())&&(o.addTo(this,o),l.subTo(e,l)),o.rShiftTo(1,o)):l.isEven()||l.subTo(e,l),l.rShiftTo(1,l);for(;i.isEven();)i.rShiftTo(1,i),n?((!h.isEven()||!m.isEven())&&(h.addTo(this,h),m.subTo(e,m)),h.rShiftTo(1,h)):m.isEven()||m.subTo(e,m),m.rShiftTo(1,m);r.compareTo(i)>=0?(r.subTo(i,r),n&&o.subTo(h,o),l.subTo(m,l)):(i.subTo(r,i),n&&h.subTo(o,h),m.subTo(l,m))}if(i.compareTo(c.ONE)!=0)return c.ZERO;if(m.compareTo(e)>=0)return m.subtract(e);if(m.signum()<0)m.addTo(e,m);else return m;return m.signum()<0?m.add(e):m}var ae=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],qr=(1<<26)/ae[ae.length-1];function $r(e){var n,r=this.abs();if(r.t==1&&r[0]<=ae[ae.length-1]){for(n=0;n<ae.length;++n)if(r[0]==ae[n])return!0;return!1}if(r.isEven())return!1;for(n=1;n<ae.length;){for(var i=ae[n],o=n+1;o<ae.length&&i<qr;)i*=ae[o++];for(i=r.modInt(i);n<o;)if(i%ae[n++]==0)return!1}return r.millerRabin(e)}function Qr(e){var n=this.subtract(c.ONE),r=n.getLowestSetBit();if(r<=0)return!1;var i=n.shiftRight(r);e=e+1>>1,e>ae.length&&(e=ae.length);for(var o=b(),l=0;l<e;++l){o.fromInt(ae[Math.floor(Math.random()*ae.length)]);var h=o.modPow(i,this);if(h.compareTo(c.ONE)!=0&&h.compareTo(n)!=0){for(var m=1;m++<r&&h.compareTo(n)!=0;)if(h=h.modPowInt(2,this),h.compareTo(c.ONE)==0)return!1;if(h.compareTo(n)!=0)return!1}}return!0}c.prototype.chunkSize=er,c.prototype.toRadix=nr,c.prototype.fromRadix=rr,c.prototype.fromNumber=ir,c.prototype.bitwiseTo=ur,c.prototype.changeBit=Sr,c.prototype.addTo=Mr,c.prototype.dMultiply=Xr,c.prototype.dAddOffset=Dr,c.prototype.multiplyLowerTo=Rr,c.prototype.multiplyUpperTo=jr,c.prototype.modInt=Hr,c.prototype.millerRabin=Qr,c.prototype.clone=Kn,c.prototype.intValue=qn,c.prototype.byteValue=$n,c.prototype.shortValue=Qn,c.prototype.signum=tr,c.prototype.toByteArray=or,c.prototype.equals=sr,c.prototype.min=ar,c.prototype.max=lr,c.prototype.and=fr,c.prototype.or=hr,c.prototype.xor=pr,c.prototype.andNot=dr,c.prototype.not=mr,c.prototype.shiftLeft=yr,c.prototype.shiftRight=gr,c.prototype.getLowestSetBit=Pr,c.prototype.bitCount=vr,c.prototype.testBit=wr,c.prototype.setBit=Cr,c.prototype.clearBit=Ir,c.prototype.flipBit=kr,c.prototype.add=Tr,c.prototype.subtract=Ar,c.prototype.multiply=Lr,c.prototype.divide=Er,c.prototype.remainder=Or,c.prototype.divideAndRemainder=Nr,c.prototype.modPow=Jr,c.prototype.modInverse=Kr,c.prototype.pow=Br,c.prototype.gcd=zr,c.prototype.isProbablePrime=$r,c.prototype.square=_r;var F=c;F.prototype.IsNegative=function(){return this.compareTo(F.ZERO)==-1},F.op_Equality=function(e,n){return e.compareTo(n)==0},F.op_Inequality=function(e,n){return e.compareTo(n)!=0},F.op_GreaterThan=function(e,n){return e.compareTo(n)>0},F.op_LessThan=function(e,n){return e.compareTo(n)<0},F.op_Addition=function(e,n){return new F(e,void 0,void 0).add(new F(n,void 0,void 0))},F.op_Subtraction=function(e,n){return new F(e,void 0,void 0).subtract(new F(n,void 0,void 0))},F.Int128Mul=function(e,n){return new F(e,void 0,void 0).multiply(new F(n,void 0,void 0))},F.op_Division=function(e,n){return e.divide(n)},F.prototype.ToDouble=function(){return parseFloat(this.toString())};var Rt=function(e,n){var r;if(typeof Object.getOwnPropertyNames>"u"){for(r in n.prototype)(typeof e.prototype[r]>"u"||e.prototype[r]===Object.prototype[r])&&(e.prototype[r]=n.prototype[r]);for(r in n)typeof e[r]>"u"&&(e[r]=n[r]);e.$baseCtor=n}else{for(var i=Object.getOwnPropertyNames(n.prototype),o=0;o<i.length;o++)typeof Object.getOwnPropertyDescriptor(e.prototype,i[o])>"u"&&Object.defineProperty(e.prototype,i[o],Object.getOwnPropertyDescriptor(n.prototype,i[o]));for(r in n)typeof e[r]>"u"&&(e[r]=n[r]);e.$baseCtor=n}};t.Path=function(){return[]},t.Path.prototype.push=Array.prototype.push,t.Paths=function(){return[]},t.Paths.prototype.push=Array.prototype.push,t.DoublePoint=function(){var e=arguments;this.X=0,this.Y=0,e.length===1?(this.X=e[0].X,this.Y=e[0].Y):e.length===2&&(this.X=e[0],this.Y=e[1])},t.DoublePoint0=function(){this.X=0,this.Y=0},t.DoublePoint0.prototype=t.DoublePoint.prototype,t.DoublePoint1=function(e){this.X=e.X,this.Y=e.Y},t.DoublePoint1.prototype=t.DoublePoint.prototype,t.DoublePoint2=function(e,n){this.X=e,this.Y=n},t.DoublePoint2.prototype=t.DoublePoint.prototype,t.PolyNode=function(){this.m_Parent=null,this.m_polygon=new t.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},t.PolyNode.prototype.IsHoleNode=function(){for(var e=!0,n=this.m_Parent;n!==null;)e=!e,n=n.m_Parent;return e},t.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},t.PolyNode.prototype.Contour=function(){return this.m_polygon},t.PolyNode.prototype.AddChild=function(e){var n=this.m_Childs.length;this.m_Childs.push(e),e.m_Parent=this,e.m_Index=n},t.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},t.PolyNode.prototype.GetNextSiblingUp=function(){return this.m_Parent===null?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},t.PolyNode.prototype.Childs=function(){return this.m_Childs},t.PolyNode.prototype.Parent=function(){return this.m_Parent},t.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},t.PolyTree=function(){this.m_AllPolys=[],t.PolyNode.call(this)},t.PolyTree.prototype.Clear=function(){for(var e=0,n=this.m_AllPolys.length;e<n;e++)this.m_AllPolys[e]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},t.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},t.PolyTree.prototype.Total=function(){var e=this.m_AllPolys.length;return e>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&e--,e},Rt(t.PolyTree,t.PolyNode),t.Math_Abs_Int64=t.Math_Abs_Int32=t.Math_Abs_Double=function(e){return Math.abs(e)},t.Math_Max_Int32_Int32=function(e,n){return Math.max(e,n)},u.msie||u.opera||u.safari?t.Cast_Int32=function(e){return e|0}:t.Cast_Int32=function(e){return~~e},typeof Number.toInteger>"u"&&(Number.toInteger=null),u.chrome?t.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):~~e}:u.firefox&&typeof Number.toInteger=="function"?t.Cast_Int64=function(e){return Number.toInteger(e)}:u.msie7||u.msie8?t.Cast_Int64=function(e){return parseInt(e,10)}:u.msie?t.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):e|0}:t.Cast_Int64=function(e){return e<0?Math.ceil(e):Math.floor(e)},t.Clear=function(e){e.length=0},t.PI=3.141592653589793,t.PI2=2*3.141592653589793,t.IntPoint=function(){var e=arguments,n=e.length;if(this.X=0,this.Y=0,t.use_xyz)if(this.Z=0,n===3)this.X=e[0],this.Y=e[1],this.Z=e[2];else if(n===2)this.X=e[0],this.Y=e[1],this.Z=0;else if(n===1)if(e[0]instanceof t.DoublePoint){var r=e[0];this.X=t.Clipper.Round(r.X),this.Y=t.Clipper.Round(r.Y),this.Z=0}else{var i=e[0];typeof i.Z>"u"&&(i.Z=0),this.X=i.X,this.Y=i.Y,this.Z=i.Z}else this.X=0,this.Y=0,this.Z=0;else if(n===2)this.X=e[0],this.Y=e[1];else if(n===1)if(e[0]instanceof t.DoublePoint){var r=e[0];this.X=t.Clipper.Round(r.X),this.Y=t.Clipper.Round(r.Y)}else{var i=e[0];this.X=i.X,this.Y=i.Y}else this.X=0,this.Y=0},t.IntPoint.op_Equality=function(e,n){return e.X===n.X&&e.Y===n.Y},t.IntPoint.op_Inequality=function(e,n){return e.X!==n.X||e.Y!==n.Y},t.IntPoint0=function(){this.X=0,this.Y=0,t.use_xyz&&(this.Z=0)},t.IntPoint0.prototype=t.IntPoint.prototype,t.IntPoint1=function(e){this.X=e.X,this.Y=e.Y,t.use_xyz&&(typeof e.Z>"u"?this.Z=0:this.Z=e.Z)},t.IntPoint1.prototype=t.IntPoint.prototype,t.IntPoint1dp=function(e){this.X=t.Clipper.Round(e.X),this.Y=t.Clipper.Round(e.Y),t.use_xyz&&(this.Z=0)},t.IntPoint1dp.prototype=t.IntPoint.prototype,t.IntPoint2=function(e,n,r){this.X=e,this.Y=n,t.use_xyz&&(typeof r>"u"?this.Z=0:this.Z=r)},t.IntPoint2.prototype=t.IntPoint.prototype,t.IntRect=function(){var e=arguments,n=e.length;if(n===4)this.left=e[0],this.top=e[1],this.right=e[2],this.bottom=e[3];else if(n===1){var r=e[0];this.left=r.left,this.top=r.top,this.right=r.right,this.bottom=r.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},t.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},t.IntRect0.prototype=t.IntRect.prototype,t.IntRect1=function(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom},t.IntRect1.prototype=t.IntRect.prototype,t.IntRect4=function(e,n,r,i){this.left=e,this.top=n,this.right=r,this.bottom=i},t.IntRect4.prototype=t.IntRect.prototype,t.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},t.PolyType={ptSubject:0,ptClip:1},t.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},t.JoinType={jtSquare:0,jtRound:1,jtMiter:2},t.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},t.EdgeSide={esLeft:0,esRight:1},t.Direction={dRightToLeft:0,dLeftToRight:1},t.TEdge=function(){this.Bot=new t.IntPoint0,this.Curr=new t.IntPoint0,this.Top=new t.IntPoint0,this.Delta=new t.IntPoint0,this.Dx=0,this.PolyTyp=t.PolyType.ptSubject,this.Side=t.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},t.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new t.IntPoint0},t.MyIntersectNodeSort=function(){},t.MyIntersectNodeSort.Compare=function(e,n){var r=n.Pt.Y-e.Pt.Y;return r>0?1:r<0?-1:0},t.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},t.Scanbeam=function(){this.Y=0,this.Next=null},t.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},t.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},t.OutPt=function(){this.Idx=0,this.Pt=new t.IntPoint0,this.Next=null,this.Prev=null},t.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new t.IntPoint0},t.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},t.ClipperBase.horizontal=-9007199254740992,t.ClipperBase.Skip=-2,t.ClipperBase.Unassigned=-1,t.ClipperBase.tolerance=1e-20,t.ClipperBase.loRange=47453132,t.ClipperBase.hiRange=0xfffffffffffff,t.ClipperBase.near_zero=function(e){return e>-t.ClipperBase.tolerance&&e<t.ClipperBase.tolerance},t.ClipperBase.IsHorizontal=function(e){return e.Delta.Y===0},t.ClipperBase.prototype.PointIsVertex=function(e,n){var r=n;do{if(t.IntPoint.op_Equality(r.Pt,e))return!0;r=r.Next}while(r!==n);return!1},t.ClipperBase.prototype.PointOnLineSegment=function(e,n,r,i){return i?e.X===n.X&&e.Y===n.Y||e.X===r.X&&e.Y===r.Y||e.X>n.X==e.X<r.X&&e.Y>n.Y==e.Y<r.Y&&F.op_Equality(F.Int128Mul(e.X-n.X,r.Y-n.Y),F.Int128Mul(r.X-n.X,e.Y-n.Y)):e.X===n.X&&e.Y===n.Y||e.X===r.X&&e.Y===r.Y||e.X>n.X==e.X<r.X&&e.Y>n.Y==e.Y<r.Y&&(e.X-n.X)*(r.Y-n.Y)===(r.X-n.X)*(e.Y-n.Y)},t.ClipperBase.prototype.PointOnPolygon=function(e,n,r){for(var i=n;;){if(this.PointOnLineSegment(e,i.Pt,i.Next.Pt,r))return!0;if(i=i.Next,i===n)break}return!1},t.ClipperBase.prototype.SlopesEqual=t.ClipperBase.SlopesEqual=function(){var e=arguments,n=e.length,r,i,o,l,h,m,y;return n===3?(r=e[0],i=e[1],y=e[2],y?F.op_Equality(F.Int128Mul(r.Delta.Y,i.Delta.X),F.Int128Mul(r.Delta.X,i.Delta.Y)):t.Cast_Int64(r.Delta.Y*i.Delta.X)===t.Cast_Int64(r.Delta.X*i.Delta.Y)):n===4?(o=e[0],l=e[1],h=e[2],y=e[3],y?F.op_Equality(F.Int128Mul(o.Y-l.Y,l.X-h.X),F.Int128Mul(o.X-l.X,l.Y-h.Y)):t.Cast_Int64((o.Y-l.Y)*(l.X-h.X))-t.Cast_Int64((o.X-l.X)*(l.Y-h.Y))===0):(o=e[0],l=e[1],h=e[2],m=e[3],y=e[4],y?F.op_Equality(F.Int128Mul(o.Y-l.Y,h.X-m.X),F.Int128Mul(o.X-l.X,h.Y-m.Y)):t.Cast_Int64((o.Y-l.Y)*(h.X-m.X))-t.Cast_Int64((o.X-l.X)*(h.Y-m.Y))===0)},t.ClipperBase.SlopesEqual3=function(e,n,r){return r?F.op_Equality(F.Int128Mul(e.Delta.Y,n.Delta.X),F.Int128Mul(e.Delta.X,n.Delta.Y)):t.Cast_Int64(e.Delta.Y*n.Delta.X)===t.Cast_Int64(e.Delta.X*n.Delta.Y)},t.ClipperBase.SlopesEqual4=function(e,n,r,i){return i?F.op_Equality(F.Int128Mul(e.Y-n.Y,n.X-r.X),F.Int128Mul(e.X-n.X,n.Y-r.Y)):t.Cast_Int64((e.Y-n.Y)*(n.X-r.X))-t.Cast_Int64((e.X-n.X)*(n.Y-r.Y))===0},t.ClipperBase.SlopesEqual5=function(e,n,r,i,o){return o?F.op_Equality(F.Int128Mul(e.Y-n.Y,r.X-i.X),F.Int128Mul(e.X-n.X,r.Y-i.Y)):t.Cast_Int64((e.Y-n.Y)*(r.X-i.X))-t.Cast_Int64((e.X-n.X)*(r.Y-i.Y))===0},t.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var e=0,n=this.m_edges.length;e<n;++e){for(var r=0,i=this.m_edges[e].length;r<i;++r)this.m_edges[e][r]=null;t.Clear(this.m_edges[e])}t.Clear(this.m_edges),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1},t.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;this.m_MinimaList!==null;){var e=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=e}this.m_CurrentLM=null},t.ClipperBase.prototype.RangeTest=function(e,n){n.Value?(e.X>t.ClipperBase.hiRange||e.Y>t.ClipperBase.hiRange||-e.X>t.ClipperBase.hiRange||-e.Y>t.ClipperBase.hiRange)&&t.Error("Coordinate outside allowed range in RangeTest()."):(e.X>t.ClipperBase.loRange||e.Y>t.ClipperBase.loRange||-e.X>t.ClipperBase.loRange||-e.Y>t.ClipperBase.loRange)&&(n.Value=!0,this.RangeTest(e,n))},t.ClipperBase.prototype.InitEdge=function(e,n,r,i){e.Next=n,e.Prev=r,e.Curr.X=i.X,e.Curr.Y=i.Y,t.use_xyz&&(e.Curr.Z=i.Z),e.OutIdx=-1},t.ClipperBase.prototype.InitEdge2=function(e,n){e.Curr.Y>=e.Next.Curr.Y?(e.Bot.X=e.Curr.X,e.Bot.Y=e.Curr.Y,t.use_xyz&&(e.Bot.Z=e.Curr.Z),e.Top.X=e.Next.Curr.X,e.Top.Y=e.Next.Curr.Y,t.use_xyz&&(e.Top.Z=e.Next.Curr.Z)):(e.Top.X=e.Curr.X,e.Top.Y=e.Curr.Y,t.use_xyz&&(e.Top.Z=e.Curr.Z),e.Bot.X=e.Next.Curr.X,e.Bot.Y=e.Next.Curr.Y,t.use_xyz&&(e.Bot.Z=e.Next.Curr.Z)),this.SetDx(e),e.PolyTyp=n},t.ClipperBase.prototype.FindNextLocMin=function(e){for(var n;;){for(;t.IntPoint.op_Inequality(e.Bot,e.Prev.Bot)||t.IntPoint.op_Equality(e.Curr,e.Top);)e=e.Next;if(e.Dx!==t.ClipperBase.horizontal&&e.Prev.Dx!==t.ClipperBase.horizontal)break;for(;e.Prev.Dx===t.ClipperBase.horizontal;)e=e.Prev;for(n=e;e.Dx===t.ClipperBase.horizontal;)e=e.Next;if(e.Top.Y!==e.Prev.Bot.Y){n.Prev.Bot.X<e.Bot.X&&(e=n);break}}return e},t.ClipperBase.prototype.ProcessBound=function(e,n){var r,i=e,o;if(i.OutIdx===t.ClipperBase.Skip){if(e=i,n){for(;e.Top.Y===e.Next.Bot.Y;)e=e.Next;for(;e!==i&&e.Dx===t.ClipperBase.horizontal;)e=e.Prev}else{for(;e.Top.Y===e.Prev.Bot.Y;)e=e.Prev;for(;e!==i&&e.Dx===t.ClipperBase.horizontal;)e=e.Next}if(e===i)n?i=e.Next:i=e.Prev;else{n?e=i.Next:e=i.Prev;var l=new t.LocalMinima;l.Next=null,l.Y=e.Bot.Y,l.LeftBound=null,l.RightBound=e,e.WindDelta=0,i=this.ProcessBound(e,n),this.InsertLocalMinima(l)}return i}if(e.Dx===t.ClipperBase.horizontal&&(n?r=e.Prev:r=e.Next,r.Dx===t.ClipperBase.horizontal?r.Bot.X!==e.Bot.X&&r.Top.X!==e.Bot.X&&this.ReverseHorizontal(e):r.Bot.X!==e.Bot.X&&this.ReverseHorizontal(e)),r=e,n){for(;i.Top.Y===i.Next.Bot.Y&&i.Next.OutIdx!==t.ClipperBase.Skip;)i=i.Next;if(i.Dx===t.ClipperBase.horizontal&&i.Next.OutIdx!==t.ClipperBase.Skip){for(o=i;o.Prev.Dx===t.ClipperBase.horizontal;)o=o.Prev;o.Prev.Top.X>i.Next.Top.X&&(i=o.Prev)}for(;e!==i;)e.NextInLML=e.Next,e.Dx===t.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),e=e.Next;e.Dx===t.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),i=i.Next}else{for(;i.Top.Y===i.Prev.Bot.Y&&i.Prev.OutIdx!==t.ClipperBase.Skip;)i=i.Prev;if(i.Dx===t.ClipperBase.horizontal&&i.Prev.OutIdx!==t.ClipperBase.Skip){for(o=i;o.Next.Dx===t.ClipperBase.horizontal;)o=o.Next;(o.Next.Top.X===i.Prev.Top.X||o.Next.Top.X>i.Prev.Top.X)&&(i=o.Next)}for(;e!==i;)e.NextInLML=e.Prev,e.Dx===t.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),e=e.Prev;e.Dx===t.ClipperBase.horizontal&&e!==r&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),i=i.Prev}return i},t.ClipperBase.prototype.AddPath=function(e,n,r){t.use_lines?!r&&n===t.PolyType.ptClip&&t.Error("AddPath: Open paths must be subject."):r||t.Error("AddPath: Open paths have been disabled.");var i=e.length-1;if(r)for(;i>0&&t.IntPoint.op_Equality(e[i],e[0]);)--i;for(;i>0&&t.IntPoint.op_Equality(e[i],e[i-1]);)--i;if(r&&i<2||!r&&i<1)return!1;for(var o=new Array,l=0;l<=i;l++)o.push(new t.TEdge);var h=!0;o[1].Curr.X=e[1].X,o[1].Curr.Y=e[1].Y,t.use_xyz&&(o[1].Curr.Z=e[1].Z);var m={Value:this.m_UseFullRange};this.RangeTest(e[0],m),this.m_UseFullRange=m.Value,m.Value=this.m_UseFullRange,this.RangeTest(e[i],m),this.m_UseFullRange=m.Value,this.InitEdge(o[0],o[1],o[i],e[0]),this.InitEdge(o[i],o[0],o[i-1],e[i]);for(var l=i-1;l>=1;--l)m.Value=this.m_UseFullRange,this.RangeTest(e[l],m),this.m_UseFullRange=m.Value,this.InitEdge(o[l],o[l+1],o[l-1],e[l]);for(var y=o[0],x=y,A=y;;){if(x.Curr===x.Next.Curr&&(r||x.Next!==y)){if(x===x.Next)break;x===y&&(y=x.Next),x=this.RemoveEdge(x),A=x;continue}if(x.Prev===x.Next)break;if(r&&t.ClipperBase.SlopesEqual4(x.Prev.Curr,x.Curr,x.Next.Curr,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(x.Prev.Curr,x.Curr,x.Next.Curr))){x===y&&(y=x.Next),x=this.RemoveEdge(x),x=x.Prev,A=x;continue}if(x=x.Next,x===A||!r&&x.Next===y)break}if(!r&&x===x.Next||r&&x.Prev===x.Next)return!1;r||(this.m_HasOpenPaths=!0,y.Prev.OutIdx=t.ClipperBase.Skip),x=y;do this.InitEdge2(x,n),x=x.Next,h&&x.Curr.Y!==y.Curr.Y&&(h=!1);while(x!==y);if(h){if(r)return!1;x.Prev.OutIdx=t.ClipperBase.Skip;var I=new t.LocalMinima;for(I.Next=null,I.Y=x.Bot.Y,I.LeftBound=null,I.RightBound=x,I.RightBound.Side=t.EdgeSide.esRight,I.RightBound.WindDelta=0;x.Bot.X!==x.Prev.Top.X&&this.ReverseHorizontal(x),x.Next.OutIdx!==t.ClipperBase.Skip;)x.NextInLML=x.Next,x=x.Next;return this.InsertLocalMinima(I),this.m_edges.push(o),!0}this.m_edges.push(o);var E,X=null;for(t.IntPoint.op_Equality(x.Prev.Bot,x.Prev.Top)&&(x=x.Next);x=this.FindNextLocMin(x),x!==X;){X===null&&(X=x);var I=new t.LocalMinima;I.Next=null,I.Y=x.Bot.Y,x.Dx<x.Prev.Dx?(I.LeftBound=x.Prev,I.RightBound=x,E=!1):(I.LeftBound=x,I.RightBound=x.Prev,E=!0),I.LeftBound.Side=t.EdgeSide.esLeft,I.RightBound.Side=t.EdgeSide.esRight,r?I.LeftBound.Next===I.RightBound?I.LeftBound.WindDelta=-1:I.LeftBound.WindDelta=1:I.LeftBound.WindDelta=0,I.RightBound.WindDelta=-I.LeftBound.WindDelta,x=this.ProcessBound(I.LeftBound,E),x.OutIdx===t.ClipperBase.Skip&&(x=this.ProcessBound(x,E));var Y=this.ProcessBound(I.RightBound,!E);Y.OutIdx===t.ClipperBase.Skip&&(Y=this.ProcessBound(Y,!E)),I.LeftBound.OutIdx===t.ClipperBase.Skip?I.LeftBound=null:I.RightBound.OutIdx===t.ClipperBase.Skip&&(I.RightBound=null),this.InsertLocalMinima(I),E||(x=Y)}return!0},t.ClipperBase.prototype.AddPaths=function(e,n,r){for(var i=!1,o=0,l=e.length;o<l;++o)this.AddPath(e[o],n,r)&&(i=!0);return i},t.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(e,n,r){return t.IntPoint.op_Equality(e,r)||t.IntPoint.op_Equality(e,n)||t.IntPoint.op_Equality(r,n)?!1:e.X!==r.X?n.X>e.X==n.X<r.X:n.Y>e.Y==n.Y<r.Y},t.ClipperBase.prototype.RemoveEdge=function(e){e.Prev.Next=e.Next,e.Next.Prev=e.Prev;var n=e.Next;return e.Prev=null,n},t.ClipperBase.prototype.SetDx=function(e){e.Delta.X=e.Top.X-e.Bot.X,e.Delta.Y=e.Top.Y-e.Bot.Y,e.Delta.Y===0?e.Dx=t.ClipperBase.horizontal:e.Dx=e.Delta.X/e.Delta.Y},t.ClipperBase.prototype.InsertLocalMinima=function(e){if(this.m_MinimaList===null)this.m_MinimaList=e;else if(e.Y>=this.m_MinimaList.Y)e.Next=this.m_MinimaList,this.m_MinimaList=e;else{for(var n=this.m_MinimaList;n.Next!==null&&e.Y<n.Next.Y;)n=n.Next;e.Next=n.Next,n.Next=e}},t.ClipperBase.prototype.PopLocalMinima=function(e,n){return n.v=this.m_CurrentLM,this.m_CurrentLM!==null&&this.m_CurrentLM.Y===e?(this.m_CurrentLM=this.m_CurrentLM.Next,!0):!1},t.ClipperBase.prototype.ReverseHorizontal=function(e){var n=e.Top.X;e.Top.X=e.Bot.X,e.Bot.X=n,t.use_xyz&&(n=e.Top.Z,e.Top.Z=e.Bot.Z,e.Bot.Z=n)},t.ClipperBase.prototype.Reset=function(){if(this.m_CurrentLM=this.m_MinimaList,this.m_CurrentLM!==null){this.m_Scanbeam=null;for(var e=this.m_MinimaList;e!==null;){this.InsertScanbeam(e.Y);var n=e.LeftBound;n!==null&&(n.Curr.X=n.Bot.X,n.Curr.Y=n.Bot.Y,t.use_xyz&&(n.Curr.Z=n.Bot.Z),n.OutIdx=t.ClipperBase.Unassigned),n=e.RightBound,n!==null&&(n.Curr.X=n.Bot.X,n.Curr.Y=n.Bot.Y,t.use_xyz&&(n.Curr.Z=n.Bot.Z),n.OutIdx=t.ClipperBase.Unassigned),e=e.Next}this.m_ActiveEdges=null}},t.ClipperBase.prototype.InsertScanbeam=function(e){if(this.m_Scanbeam===null)this.m_Scanbeam=new t.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=e;else if(e>this.m_Scanbeam.Y){var n=new t.Scanbeam;n.Y=e,n.Next=this.m_Scanbeam,this.m_Scanbeam=n}else{for(var r=this.m_Scanbeam;r.Next!==null&&e<=r.Next.Y;)r=r.Next;if(e===r.Y)return;var i=new t.Scanbeam;i.Y=e,i.Next=r.Next,r.Next=i}},t.ClipperBase.prototype.PopScanbeam=function(e){return this.m_Scanbeam===null?(e.v=0,!1):(e.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},t.ClipperBase.prototype.LocalMinimaPending=function(){return this.m_CurrentLM!==null},t.ClipperBase.prototype.CreateOutRec=function(){var e=new t.OutRec;return e.Idx=t.ClipperBase.Unassigned,e.IsHole=!1,e.IsOpen=!1,e.FirstLeft=null,e.Pts=null,e.BottomPt=null,e.PolyNode=null,this.m_PolyOuts.push(e),e.Idx=this.m_PolyOuts.length-1,e},t.ClipperBase.prototype.DisposeOutRec=function(e){var n=this.m_PolyOuts[e];n.Pts=null,n=null,this.m_PolyOuts[e]=null},t.ClipperBase.prototype.UpdateEdgeIntoAEL=function(e){e.NextInLML===null&&t.Error("UpdateEdgeIntoAEL: invalid call");var n=e.PrevInAEL,r=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,n!==null?n.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,r!==null&&(r.PrevInAEL=e.NextInLML),e.NextInLML.Side=e.Side,e.NextInLML.WindDelta=e.WindDelta,e.NextInLML.WindCnt=e.WindCnt,e.NextInLML.WindCnt2=e.WindCnt2,e=e.NextInLML,e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,e.PrevInAEL=n,e.NextInAEL=r,t.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e},t.ClipperBase.prototype.SwapPositionsInAEL=function(e,n){if(!(e.NextInAEL===e.PrevInAEL||n.NextInAEL===n.PrevInAEL)){if(e.NextInAEL===n){var r=n.NextInAEL;r!==null&&(r.PrevInAEL=e);var i=e.PrevInAEL;i!==null&&(i.NextInAEL=n),n.PrevInAEL=i,n.NextInAEL=e,e.PrevInAEL=n,e.NextInAEL=r}else if(n.NextInAEL===e){var o=e.NextInAEL;o!==null&&(o.PrevInAEL=n);var l=n.PrevInAEL;l!==null&&(l.NextInAEL=e),e.PrevInAEL=l,e.NextInAEL=n,n.PrevInAEL=e,n.NextInAEL=o}else{var h=e.NextInAEL,m=e.PrevInAEL;e.NextInAEL=n.NextInAEL,e.NextInAEL!==null&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=n.PrevInAEL,e.PrevInAEL!==null&&(e.PrevInAEL.NextInAEL=e),n.NextInAEL=h,n.NextInAEL!==null&&(n.NextInAEL.PrevInAEL=n),n.PrevInAEL=m,n.PrevInAEL!==null&&(n.PrevInAEL.NextInAEL=n)}e.PrevInAEL===null?this.m_ActiveEdges=e:n.PrevInAEL===null&&(this.m_ActiveEdges=n)}},t.ClipperBase.prototype.DeleteFromAEL=function(e){var n=e.PrevInAEL,r=e.NextInAEL;n===null&&r===null&&e!==this.m_ActiveEdges||(n!==null?n.NextInAEL=r:this.m_ActiveEdges=r,r!==null&&(r.PrevInAEL=n),e.NextInAEL=null,e.PrevInAEL=null)},t.Clipper=function(e){typeof e>"u"&&(e=0),this.m_PolyOuts=null,this.m_ClipType=t.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=t.PolyFillType.pftEvenOdd,this.m_SubjFillType=t.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,t.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=t.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array,this.m_Joins=new Array,this.m_GhostJoins=new Array,this.ReverseSolution=(1&e)!==0,this.StrictlySimple=(2&e)!==0,this.PreserveCollinear=(4&e)!==0,t.use_xyz&&(this.ZFillFunction=null)},t.Clipper.ioReverseSolution=1,t.Clipper.ioStrictlySimple=2,t.Clipper.ioPreserveCollinear=4,t.Clipper.prototype.Clear=function(){this.m_edges.length!==0&&(this.DisposeAllPolyPts(),t.ClipperBase.prototype.Clear.call(this))},t.Clipper.prototype.InsertMaxima=function(e){var n=new t.Maxima;if(n.X=e,this.m_Maxima===null)this.m_Maxima=n,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(e<this.m_Maxima.X)n.Next=this.m_Maxima,n.Prev=null,this.m_Maxima=n;else{for(var r=this.m_Maxima;r.Next!==null&&e>=r.Next.X;)r=r.Next;if(e===r.X)return;n.Next=r.Next,n.Prev=r,r.Next!==null&&(r.Next.Prev=n),r.Next=n}},t.Clipper.prototype.Execute=function(){var e=arguments,n=e.length,r=e[1]instanceof t.PolyTree;if(n===4&&!r){var i=e[0],o=e[1],l=e[2],h=e[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&t.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,t.Clear(o),this.m_SubjFillType=l,this.m_ClipFillType=h,this.m_ClipType=i,this.m_UsingPolyTree=!1;try{var m=this.ExecuteInternal();m&&this.BuildResult(o)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return m}else if(n===4&&r){var i=e[0],y=e[1],l=e[2],h=e[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=l,this.m_ClipFillType=h,this.m_ClipType=i,this.m_UsingPolyTree=!0;try{var m=this.ExecuteInternal();m&&this.BuildResult2(y)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return m}else if(n===2&&!r){var i=e[0],o=e[1];return this.Execute(i,o,t.PolyFillType.pftEvenOdd,t.PolyFillType.pftEvenOdd)}else if(n===2&&r){var i=e[0],y=e[1];return this.Execute(i,y,t.PolyFillType.pftEvenOdd,t.PolyFillType.pftEvenOdd)}},t.Clipper.prototype.FixHoleLinkage=function(e){if(!(e.FirstLeft===null||e.IsHole!==e.FirstLeft.IsHole&&e.FirstLeft.Pts!==null)){for(var n=e.FirstLeft;n!==null&&(n.IsHole===e.IsHole||n.Pts===null);)n=n.FirstLeft;e.FirstLeft=n}},t.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var e={},n={};if(!this.PopScanbeam(e))return!1;for(this.InsertLocalMinimaIntoAEL(e.v);this.PopScanbeam(n)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(n.v))return!1;this.ProcessEdgesAtTopOfScanbeam(n.v),e.v=n.v,this.InsertLocalMinimaIntoAEL(e.v)}var r,i,o;for(i=0,o=this.m_PolyOuts.length;i<o;i++)r=this.m_PolyOuts[i],!(r.Pts===null||r.IsOpen)&&(r.IsHole^this.ReverseSolution)==this.Area$1(r)>0&&this.ReversePolyPtLinks(r.Pts);for(this.JoinCommonEdges(),i=0,o=this.m_PolyOuts.length;i<o;i++)r=this.m_PolyOuts[i],r.Pts!==null&&(r.IsOpen?this.FixupOutPolyline(r):this.FixupOutPolygon(r));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}},t.Clipper.prototype.DisposeAllPolyPts=function(){for(var e=0,n=this.m_PolyOuts.length;e<n;++e)this.DisposeOutRec(e);t.Clear(this.m_PolyOuts)},t.Clipper.prototype.AddJoin=function(e,n,r){var i=new t.Join;i.OutPt1=e,i.OutPt2=n,i.OffPt.X=r.X,i.OffPt.Y=r.Y,t.use_xyz&&(i.OffPt.Z=r.Z),this.m_Joins.push(i)},t.Clipper.prototype.AddGhostJoin=function(e,n){var r=new t.Join;r.OutPt1=e,r.OffPt.X=n.X,r.OffPt.Y=n.Y,t.use_xyz&&(r.OffPt.Z=n.Z),this.m_GhostJoins.push(r)},t.Clipper.prototype.SetZ=function(e,n,r){if(this.ZFillFunction!==null){if(e.Z!==0||this.ZFillFunction===null)return;t.IntPoint.op_Equality(e,n.Bot)?e.Z=n.Bot.Z:t.IntPoint.op_Equality(e,n.Top)?e.Z=n.Top.Z:t.IntPoint.op_Equality(e,r.Bot)?e.Z=r.Bot.Z:t.IntPoint.op_Equality(e,r.Top)?e.Z=r.Top.Z:this.ZFillFunction(n.Bot,n.Top,r.Bot,r.Top,e)}},t.Clipper.prototype.InsertLocalMinimaIntoAEL=function(e){for(var n={},r,i;this.PopLocalMinima(e,n);){r=n.v.LeftBound,i=n.v.RightBound;var o=null;if(r===null?(this.InsertEdgeIntoAEL(i,null),this.SetWindingCount(i),this.IsContributing(i)&&(o=this.AddOutPt(i,i.Bot))):i===null?(this.InsertEdgeIntoAEL(r,null),this.SetWindingCount(r),this.IsContributing(r)&&(o=this.AddOutPt(r,r.Bot)),this.InsertScanbeam(r.Top.Y)):(this.InsertEdgeIntoAEL(r,null),this.InsertEdgeIntoAEL(i,r),this.SetWindingCount(r),i.WindCnt=r.WindCnt,i.WindCnt2=r.WindCnt2,this.IsContributing(r)&&(o=this.AddLocalMinPoly(r,i,r.Bot)),this.InsertScanbeam(r.Top.Y)),i!==null&&(t.ClipperBase.IsHorizontal(i)?(i.NextInLML!==null&&this.InsertScanbeam(i.NextInLML.Top.Y),this.AddEdgeToSEL(i)):this.InsertScanbeam(i.Top.Y)),!(r===null||i===null)){if(o!==null&&t.ClipperBase.IsHorizontal(i)&&this.m_GhostJoins.length>0&&i.WindDelta!==0)for(var l=0,h=this.m_GhostJoins.length;l<h;l++){var m=this.m_GhostJoins[l];this.HorzSegmentsOverlap(m.OutPt1.Pt.X,m.OffPt.X,i.Bot.X,i.Top.X)&&this.AddJoin(m.OutPt1,o,m.OffPt)}if(r.OutIdx>=0&&r.PrevInAEL!==null&&r.PrevInAEL.Curr.X===r.Bot.X&&r.PrevInAEL.OutIdx>=0&&t.ClipperBase.SlopesEqual5(r.PrevInAEL.Curr,r.PrevInAEL.Top,r.Curr,r.Top,this.m_UseFullRange)&&r.WindDelta!==0&&r.PrevInAEL.WindDelta!==0){var y=this.AddOutPt(r.PrevInAEL,r.Bot);this.AddJoin(o,y,r.Top)}if(r.NextInAEL!==i){if(i.OutIdx>=0&&i.PrevInAEL.OutIdx>=0&&t.ClipperBase.SlopesEqual5(i.PrevInAEL.Curr,i.PrevInAEL.Top,i.Curr,i.Top,this.m_UseFullRange)&&i.WindDelta!==0&&i.PrevInAEL.WindDelta!==0){var y=this.AddOutPt(i.PrevInAEL,i.Bot);this.AddJoin(o,y,i.Top)}var x=r.NextInAEL;if(x!==null)for(;x!==i;)this.IntersectEdges(i,x,r.Curr),x=x.NextInAEL}}}},t.Clipper.prototype.InsertEdgeIntoAEL=function(e,n){if(this.m_ActiveEdges===null)e.PrevInAEL=null,e.NextInAEL=null,this.m_ActiveEdges=e;else if(n===null&&this.E2InsertsBeforeE1(this.m_ActiveEdges,e))e.PrevInAEL=null,e.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=e,this.m_ActiveEdges=e;else{for(n===null&&(n=this.m_ActiveEdges);n.NextInAEL!==null&&!this.E2InsertsBeforeE1(n.NextInAEL,e);)n=n.NextInAEL;e.NextInAEL=n.NextInAEL,n.NextInAEL!==null&&(n.NextInAEL.PrevInAEL=e),e.PrevInAEL=n,n.NextInAEL=e}},t.Clipper.prototype.E2InsertsBeforeE1=function(e,n){return n.Curr.X===e.Curr.X?n.Top.Y>e.Top.Y?n.Top.X<t.Clipper.TopX(e,n.Top.Y):e.Top.X>t.Clipper.TopX(n,e.Top.Y):n.Curr.X<e.Curr.X},t.Clipper.prototype.IsEvenOddFillType=function(e){return e.PolyTyp===t.PolyType.ptSubject?this.m_SubjFillType===t.PolyFillType.pftEvenOdd:this.m_ClipFillType===t.PolyFillType.pftEvenOdd},t.Clipper.prototype.IsEvenOddAltFillType=function(e){return e.PolyTyp===t.PolyType.ptSubject?this.m_ClipFillType===t.PolyFillType.pftEvenOdd:this.m_SubjFillType===t.PolyFillType.pftEvenOdd},t.Clipper.prototype.IsContributing=function(e){var n,r;switch(e.PolyTyp===t.PolyType.ptSubject?(n=this.m_SubjFillType,r=this.m_ClipFillType):(n=this.m_ClipFillType,r=this.m_SubjFillType),n){case t.PolyFillType.pftEvenOdd:if(e.WindDelta===0&&e.WindCnt!==1)return!1;break;case t.PolyFillType.pftNonZero:if(Math.abs(e.WindCnt)!==1)return!1;break;case t.PolyFillType.pftPositive:if(e.WindCnt!==1)return!1;break;default:if(e.WindCnt!==-1)return!1;break}switch(this.m_ClipType){case t.ClipType.ctIntersection:switch(r){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return e.WindCnt2!==0;case t.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case t.ClipType.ctUnion:switch(r){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return e.WindCnt2===0;case t.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}case t.ClipType.ctDifference:if(e.PolyTyp===t.PolyType.ptSubject)switch(r){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return e.WindCnt2===0;case t.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else switch(r){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return e.WindCnt2!==0;case t.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case t.ClipType.ctXor:if(e.WindDelta===0)switch(r){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return e.WindCnt2===0;case t.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else return!0}return!0},t.Clipper.prototype.SetWindingCount=function(e){for(var n=e.PrevInAEL;n!==null&&(n.PolyTyp!==e.PolyTyp||n.WindDelta===0);)n=n.PrevInAEL;if(n===null){var r=e.PolyTyp===t.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;e.WindDelta===0?e.WindCnt=r===t.PolyFillType.pftNegative?-1:1:e.WindCnt=e.WindDelta,e.WindCnt2=0,n=this.m_ActiveEdges}else if(e.WindDelta===0&&this.m_ClipType!==t.ClipType.ctUnion)e.WindCnt=1,e.WindCnt2=n.WindCnt2,n=n.NextInAEL;else if(this.IsEvenOddFillType(e)){if(e.WindDelta===0){for(var i=!0,o=n.PrevInAEL;o!==null;)o.PolyTyp===n.PolyTyp&&o.WindDelta!==0&&(i=!i),o=o.PrevInAEL;e.WindCnt=i?0:1}else e.WindCnt=e.WindDelta;e.WindCnt2=n.WindCnt2,n=n.NextInAEL}else n.WindCnt*n.WindDelta<0?Math.abs(n.WindCnt)>1?n.WindDelta*e.WindDelta<0?e.WindCnt=n.WindCnt:e.WindCnt=n.WindCnt+e.WindDelta:e.WindCnt=e.WindDelta===0?1:e.WindDelta:e.WindDelta===0?e.WindCnt=n.WindCnt<0?n.WindCnt-1:n.WindCnt+1:n.WindDelta*e.WindDelta<0?e.WindCnt=n.WindCnt:e.WindCnt=n.WindCnt+e.WindDelta,e.WindCnt2=n.WindCnt2,n=n.NextInAEL;if(this.IsEvenOddAltFillType(e))for(;n!==e;)n.WindDelta!==0&&(e.WindCnt2=e.WindCnt2===0?1:0),n=n.NextInAEL;else for(;n!==e;)e.WindCnt2+=n.WindDelta,n=n.NextInAEL},t.Clipper.prototype.AddEdgeToSEL=function(e){this.m_SortedEdges===null?(this.m_SortedEdges=e,e.PrevInSEL=null,e.NextInSEL=null):(e.NextInSEL=this.m_SortedEdges,e.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=e,this.m_SortedEdges=e)},t.Clipper.prototype.PopEdgeFromSEL=function(e){if(e.v=this.m_SortedEdges,e.v===null)return!1;var n=e.v;return this.m_SortedEdges=e.v.NextInSEL,this.m_SortedEdges!==null&&(this.m_SortedEdges.PrevInSEL=null),n.NextInSEL=null,n.PrevInSEL=null,!0},t.Clipper.prototype.CopyAELToSEL=function(){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;e!==null;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e=e.NextInAEL},t.Clipper.prototype.SwapPositionsInSEL=function(e,n){if(!(e.NextInSEL===null&&e.PrevInSEL===null)&&!(n.NextInSEL===null&&n.PrevInSEL===null)){if(e.NextInSEL===n){var r=n.NextInSEL;r!==null&&(r.PrevInSEL=e);var i=e.PrevInSEL;i!==null&&(i.NextInSEL=n),n.PrevInSEL=i,n.NextInSEL=e,e.PrevInSEL=n,e.NextInSEL=r}else if(n.NextInSEL===e){var r=e.NextInSEL;r!==null&&(r.PrevInSEL=n);var i=n.PrevInSEL;i!==null&&(i.NextInSEL=e),e.PrevInSEL=i,e.NextInSEL=n,n.PrevInSEL=e,n.NextInSEL=r}else{var r=e.NextInSEL,i=e.PrevInSEL;e.NextInSEL=n.NextInSEL,e.NextInSEL!==null&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=n.PrevInSEL,e.PrevInSEL!==null&&(e.PrevInSEL.NextInSEL=e),n.NextInSEL=r,n.NextInSEL!==null&&(n.NextInSEL.PrevInSEL=n),n.PrevInSEL=i,n.PrevInSEL!==null&&(n.PrevInSEL.NextInSEL=n)}e.PrevInSEL===null?this.m_SortedEdges=e:n.PrevInSEL===null&&(this.m_SortedEdges=n)}},t.Clipper.prototype.AddLocalMaxPoly=function(e,n,r){this.AddOutPt(e,r),n.WindDelta===0&&this.AddOutPt(n,r),e.OutIdx===n.OutIdx?(e.OutIdx=-1,n.OutIdx=-1):e.OutIdx<n.OutIdx?this.AppendPolygon(e,n):this.AppendPolygon(n,e)},t.Clipper.prototype.AddLocalMinPoly=function(e,n,r){var i,o,l;if(t.ClipperBase.IsHorizontal(n)||e.Dx>n.Dx?(i=this.AddOutPt(e,r),n.OutIdx=e.OutIdx,e.Side=t.EdgeSide.esLeft,n.Side=t.EdgeSide.esRight,o=e,o.PrevInAEL===n?l=n.PrevInAEL:l=o.PrevInAEL):(i=this.AddOutPt(n,r),e.OutIdx=n.OutIdx,e.Side=t.EdgeSide.esRight,n.Side=t.EdgeSide.esLeft,o=n,o.PrevInAEL===e?l=e.PrevInAEL:l=o.PrevInAEL),l!==null&&l.OutIdx>=0&&l.Top.Y<r.Y&&o.Top.Y<r.Y){var h=t.Clipper.TopX(l,r.Y),m=t.Clipper.TopX(o,r.Y);if(h===m&&o.WindDelta!==0&&l.WindDelta!==0&&t.ClipperBase.SlopesEqual5(new t.IntPoint2(h,r.Y),l.Top,new t.IntPoint2(m,r.Y),o.Top,this.m_UseFullRange)){var y=this.AddOutPt(l,r);this.AddJoin(i,y,o.Top)}}return i},t.Clipper.prototype.AddOutPt=function(e,n){if(e.OutIdx<0){var r=this.CreateOutRec();r.IsOpen=e.WindDelta===0;var i=new t.OutPt;return r.Pts=i,i.Idx=r.Idx,i.Pt.X=n.X,i.Pt.Y=n.Y,t.use_xyz&&(i.Pt.Z=n.Z),i.Next=i,i.Prev=i,r.IsOpen||this.SetHoleState(e,r),e.OutIdx=r.Idx,i}else{var r=this.m_PolyOuts[e.OutIdx],o=r.Pts,l=e.Side===t.EdgeSide.esLeft;if(l&&t.IntPoint.op_Equality(n,o.Pt))return o;if(!l&&t.IntPoint.op_Equality(n,o.Prev.Pt))return o.Prev;var i=new t.OutPt;return i.Idx=r.Idx,i.Pt.X=n.X,i.Pt.Y=n.Y,t.use_xyz&&(i.Pt.Z=n.Z),i.Next=o,i.Prev=o.Prev,i.Prev.Next=i,o.Prev=i,l&&(r.Pts=i),i}},t.Clipper.prototype.GetLastOutPt=function(e){var n=this.m_PolyOuts[e.OutIdx];return e.Side===t.EdgeSide.esLeft?n.Pts:n.Pts.Prev},t.Clipper.prototype.SwapPoints=function(e,n){var r=new t.IntPoint1(e.Value);e.Value.X=n.Value.X,e.Value.Y=n.Value.Y,t.use_xyz&&(e.Value.Z=n.Value.Z),n.Value.X=r.X,n.Value.Y=r.Y,t.use_xyz&&(n.Value.Z=r.Z)},t.Clipper.prototype.HorzSegmentsOverlap=function(e,n,r,i){var o;return e>n&&(o=e,e=n,n=o),r>i&&(o=r,r=i,i=o),e<i&&r<n},t.Clipper.prototype.SetHoleState=function(e,n){for(var r=e.PrevInAEL,i=null;r!==null;)r.OutIdx>=0&&r.WindDelta!==0&&(i===null?i=r:i.OutIdx===r.OutIdx&&(i=null)),r=r.PrevInAEL;i===null?(n.FirstLeft=null,n.IsHole=!1):(n.FirstLeft=this.m_PolyOuts[i.OutIdx],n.IsHole=!n.FirstLeft.IsHole)},t.Clipper.prototype.GetDx=function(e,n){return e.Y===n.Y?t.ClipperBase.horizontal:(n.X-e.X)/(n.Y-e.Y)},t.Clipper.prototype.FirstIsBottomPt=function(e,n){for(var r=e.Prev;t.IntPoint.op_Equality(r.Pt,e.Pt)&&r!==e;)r=r.Prev;var i=Math.abs(this.GetDx(e.Pt,r.Pt));for(r=e.Next;t.IntPoint.op_Equality(r.Pt,e.Pt)&&r!==e;)r=r.Next;var o=Math.abs(this.GetDx(e.Pt,r.Pt));for(r=n.Prev;t.IntPoint.op_Equality(r.Pt,n.Pt)&&r!==n;)r=r.Prev;var l=Math.abs(this.GetDx(n.Pt,r.Pt));for(r=n.Next;t.IntPoint.op_Equality(r.Pt,n.Pt)&&r!==n;)r=r.Next;var h=Math.abs(this.GetDx(n.Pt,r.Pt));return Math.max(i,o)===Math.max(l,h)&&Math.min(i,o)===Math.min(l,h)?this.Area(e)>0:i>=l&&i>=h||o>=l&&o>=h},t.Clipper.prototype.GetBottomPt=function(e){for(var n=null,r=e.Next;r!==e;)r.Pt.Y>e.Pt.Y?(e=r,n=null):r.Pt.Y===e.Pt.Y&&r.Pt.X<=e.Pt.X&&(r.Pt.X<e.Pt.X?(n=null,e=r):r.Next!==e&&r.Prev!==e&&(n=r)),r=r.Next;if(n!==null)for(;n!==r;)for(this.FirstIsBottomPt(r,n)||(e=n),n=n.Next;t.IntPoint.op_Inequality(n.Pt,e.Pt);)n=n.Next;return e},t.Clipper.prototype.GetLowermostRec=function(e,n){e.BottomPt===null&&(e.BottomPt=this.GetBottomPt(e.Pts)),n.BottomPt===null&&(n.BottomPt=this.GetBottomPt(n.Pts));var r=e.BottomPt,i=n.BottomPt;return r.Pt.Y>i.Pt.Y?e:r.Pt.Y<i.Pt.Y?n:r.Pt.X<i.Pt.X?e:r.Pt.X>i.Pt.X||r.Next===r?n:i.Next===i||this.FirstIsBottomPt(r,i)?e:n},t.Clipper.prototype.OutRec1RightOfOutRec2=function(e,n){do if(e=e.FirstLeft,e===n)return!0;while(e!==null);return!1},t.Clipper.prototype.GetOutRec=function(e){for(var n=this.m_PolyOuts[e];n!==this.m_PolyOuts[n.Idx];)n=this.m_PolyOuts[n.Idx];return n},t.Clipper.prototype.AppendPolygon=function(e,n){var r=this.m_PolyOuts[e.OutIdx],i=this.m_PolyOuts[n.OutIdx],o;this.OutRec1RightOfOutRec2(r,i)?o=i:this.OutRec1RightOfOutRec2(i,r)?o=r:o=this.GetLowermostRec(r,i);var l=r.Pts,h=l.Prev,m=i.Pts,y=m.Prev;e.Side===t.EdgeSide.esLeft?n.Side===t.EdgeSide.esLeft?(this.ReversePolyPtLinks(m),m.Next=l,l.Prev=m,h.Next=y,y.Prev=h,r.Pts=y):(y.Next=l,l.Prev=y,m.Prev=h,h.Next=m,r.Pts=m):n.Side===t.EdgeSide.esRight?(this.ReversePolyPtLinks(m),h.Next=y,y.Prev=h,m.Next=l,l.Prev=m):(h.Next=m,m.Prev=h,l.Prev=y,y.Next=l),r.BottomPt=null,o===i&&(i.FirstLeft!==r&&(r.FirstLeft=i.FirstLeft),r.IsHole=i.IsHole),i.Pts=null,i.BottomPt=null,i.FirstLeft=r;var x=e.OutIdx,A=n.OutIdx;e.OutIdx=-1,n.OutIdx=-1;for(var I=this.m_ActiveEdges;I!==null;){if(I.OutIdx===A){I.OutIdx=x,I.Side=e.Side;break}I=I.NextInAEL}i.Idx=r.Idx},t.Clipper.prototype.ReversePolyPtLinks=function(e){if(e!==null){var n,r;n=e;do r=n.Next,n.Next=n.Prev,n.Prev=r,n=r;while(n!==e)}},t.Clipper.SwapSides=function(e,n){var r=e.Side;e.Side=n.Side,n.Side=r},t.Clipper.SwapPolyIndexes=function(e,n){var r=e.OutIdx;e.OutIdx=n.OutIdx,n.OutIdx=r},t.Clipper.prototype.IntersectEdges=function(e,n,r){var i=e.OutIdx>=0,o=n.OutIdx>=0;if(t.use_xyz&&this.SetZ(r,e,n),t.use_lines&&(e.WindDelta===0||n.WindDelta===0)){if(e.WindDelta===0&&n.WindDelta===0)return;e.PolyTyp===n.PolyTyp&&e.WindDelta!==n.WindDelta&&this.m_ClipType===t.ClipType.ctUnion?e.WindDelta===0?o&&(this.AddOutPt(e,r),i&&(e.OutIdx=-1)):i&&(this.AddOutPt(n,r),o&&(n.OutIdx=-1)):e.PolyTyp!==n.PolyTyp&&(e.WindDelta===0&&Math.abs(n.WindCnt)===1&&(this.m_ClipType!==t.ClipType.ctUnion||n.WindCnt2===0)?(this.AddOutPt(e,r),i&&(e.OutIdx=-1)):n.WindDelta===0&&Math.abs(e.WindCnt)===1&&(this.m_ClipType!==t.ClipType.ctUnion||e.WindCnt2===0)&&(this.AddOutPt(n,r),o&&(n.OutIdx=-1)));return}if(e.PolyTyp===n.PolyTyp)if(this.IsEvenOddFillType(e)){var l=e.WindCnt;e.WindCnt=n.WindCnt,n.WindCnt=l}else e.WindCnt+n.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt+=n.WindDelta,n.WindCnt-e.WindDelta===0?n.WindCnt=-n.WindCnt:n.WindCnt-=e.WindDelta;else this.IsEvenOddFillType(n)?e.WindCnt2=e.WindCnt2===0?1:0:e.WindCnt2+=n.WindDelta,this.IsEvenOddFillType(e)?n.WindCnt2=n.WindCnt2===0?1:0:n.WindCnt2-=e.WindDelta;var h,m,y,x;e.PolyTyp===t.PolyType.ptSubject?(h=this.m_SubjFillType,y=this.m_ClipFillType):(h=this.m_ClipFillType,y=this.m_SubjFillType),n.PolyTyp===t.PolyType.ptSubject?(m=this.m_SubjFillType,x=this.m_ClipFillType):(m=this.m_ClipFillType,x=this.m_SubjFillType);var A,I;switch(h){case t.PolyFillType.pftPositive:A=e.WindCnt;break;case t.PolyFillType.pftNegative:A=-e.WindCnt;break;default:A=Math.abs(e.WindCnt);break}switch(m){case t.PolyFillType.pftPositive:I=n.WindCnt;break;case t.PolyFillType.pftNegative:I=-n.WindCnt;break;default:I=Math.abs(n.WindCnt);break}if(i&&o)A!==0&&A!==1||I!==0&&I!==1||e.PolyTyp!==n.PolyTyp&&this.m_ClipType!==t.ClipType.ctXor?this.AddLocalMaxPoly(e,n,r):(this.AddOutPt(e,r),this.AddOutPt(n,r),t.Clipper.SwapSides(e,n),t.Clipper.SwapPolyIndexes(e,n));else if(i)(I===0||I===1)&&(this.AddOutPt(e,r),t.Clipper.SwapSides(e,n),t.Clipper.SwapPolyIndexes(e,n));else if(o)(A===0||A===1)&&(this.AddOutPt(n,r),t.Clipper.SwapSides(e,n),t.Clipper.SwapPolyIndexes(e,n));else if((A===0||A===1)&&(I===0||I===1)){var E,X;switch(y){case t.PolyFillType.pftPositive:E=e.WindCnt2;break;case t.PolyFillType.pftNegative:E=-e.WindCnt2;break;default:E=Math.abs(e.WindCnt2);break}switch(x){case t.PolyFillType.pftPositive:X=n.WindCnt2;break;case t.PolyFillType.pftNegative:X=-n.WindCnt2;break;default:X=Math.abs(n.WindCnt2);break}if(e.PolyTyp!==n.PolyTyp)this.AddLocalMinPoly(e,n,r);else if(A===1&&I===1)switch(this.m_ClipType){case t.ClipType.ctIntersection:E>0&&X>0&&this.AddLocalMinPoly(e,n,r);break;case t.ClipType.ctUnion:E<=0&&X<=0&&this.AddLocalMinPoly(e,n,r);break;case t.ClipType.ctDifference:(e.PolyTyp===t.PolyType.ptClip&&E>0&&X>0||e.PolyTyp===t.PolyType.ptSubject&&E<=0&&X<=0)&&this.AddLocalMinPoly(e,n,r);break;case t.ClipType.ctXor:this.AddLocalMinPoly(e,n,r);break}else t.Clipper.SwapSides(e,n)}},t.Clipper.prototype.DeleteFromSEL=function(e){var n=e.PrevInSEL,r=e.NextInSEL;n===null&&r===null&&e!==this.m_SortedEdges||(n!==null?n.NextInSEL=r:this.m_SortedEdges=r,r!==null&&(r.PrevInSEL=n),e.NextInSEL=null,e.PrevInSEL=null)},t.Clipper.prototype.ProcessHorizontals=function(){for(var e={};this.PopEdgeFromSEL(e);)this.ProcessHorizontal(e.v)},t.Clipper.prototype.GetHorzDirection=function(e,n){e.Bot.X<e.Top.X?(n.Left=e.Bot.X,n.Right=e.Top.X,n.Dir=t.Direction.dLeftToRight):(n.Left=e.Top.X,n.Right=e.Bot.X,n.Dir=t.Direction.dRightToLeft)},t.Clipper.prototype.ProcessHorizontal=function(e){var n={Dir:null,Left:null,Right:null};this.GetHorzDirection(e,n);for(var r=n.Dir,i=n.Left,o=n.Right,l=e.WindDelta===0,h=e,m=null;h.NextInLML!==null&&t.ClipperBase.IsHorizontal(h.NextInLML);)h=h.NextInLML;h.NextInLML===null&&(m=this.GetMaximaPair(h));var y=this.m_Maxima;if(y!==null)if(r===t.Direction.dLeftToRight){for(;y!==null&&y.X<=e.Bot.X;)y=y.Next;y!==null&&y.X>=h.Top.X&&(y=null)}else{for(;y.Next!==null&&y.Next.X<e.Bot.X;)y=y.Next;y.X<=h.Top.X&&(y=null)}for(var x=null;;){for(var A=e===h,I=this.GetNextInAEL(e,r);I!==null;){if(y!==null)if(r===t.Direction.dLeftToRight)for(;y!==null&&y.X<I.Curr.X;)e.OutIdx>=0&&!l&&this.AddOutPt(e,new t.IntPoint2(y.X,e.Bot.Y)),y=y.Next;else for(;y!==null&&y.X>I.Curr.X;)e.OutIdx>=0&&!l&&this.AddOutPt(e,new t.IntPoint2(y.X,e.Bot.Y)),y=y.Prev;if(r===t.Direction.dLeftToRight&&I.Curr.X>o||r===t.Direction.dRightToLeft&&I.Curr.X<i||I.Curr.X===e.Top.X&&e.NextInLML!==null&&I.Dx<e.NextInLML.Dx)break;if(e.OutIdx>=0&&!l){t.use_xyz&&(r===t.Direction.dLeftToRight?this.SetZ(I.Curr,e,I):this.SetZ(I.Curr,I,e)),x=this.AddOutPt(e,I.Curr);for(var E=this.m_SortedEdges;E!==null;){if(E.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,E.Bot.X,E.Top.X)){var X=this.GetLastOutPt(E);this.AddJoin(X,x,E.Top)}E=E.NextInSEL}this.AddGhostJoin(x,e.Bot)}if(I===m&&A){e.OutIdx>=0&&this.AddLocalMaxPoly(e,m,e.Top),this.DeleteFromAEL(e),this.DeleteFromAEL(m);return}if(r===t.Direction.dLeftToRight){var Y=new t.IntPoint2(I.Curr.X,e.Curr.Y);this.IntersectEdges(e,I,Y)}else{var Y=new t.IntPoint2(I.Curr.X,e.Curr.Y);this.IntersectEdges(I,e,Y)}var B=this.GetNextInAEL(I,r);this.SwapPositionsInAEL(e,I),I=B}if(e.NextInLML===null||!t.ClipperBase.IsHorizontal(e.NextInLML))break;e=this.UpdateEdgeIntoAEL(e),e.OutIdx>=0&&this.AddOutPt(e,e.Bot),n={Dir:r,Left:i,Right:o},this.GetHorzDirection(e,n),r=n.Dir,i=n.Left,o=n.Right}if(e.OutIdx>=0&&x===null){x=this.GetLastOutPt(e);for(var E=this.m_SortedEdges;E!==null;){if(E.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,E.Bot.X,E.Top.X)){var X=this.GetLastOutPt(E);this.AddJoin(X,x,E.Top)}E=E.NextInSEL}this.AddGhostJoin(x,e.Top)}if(e.NextInLML!==null)if(e.OutIdx>=0){if(x=this.AddOutPt(e,e.Top),e=this.UpdateEdgeIntoAEL(e),e.WindDelta===0)return;var J=e.PrevInAEL,B=e.NextInAEL;if(J!==null&&J.Curr.X===e.Bot.X&&J.Curr.Y===e.Bot.Y&&J.WindDelta===0&&J.OutIdx>=0&&J.Curr.Y>J.Top.Y&&t.ClipperBase.SlopesEqual3(e,J,this.m_UseFullRange)){var X=this.AddOutPt(J,e.Bot);this.AddJoin(x,X,e.Top)}else if(B!==null&&B.Curr.X===e.Bot.X&&B.Curr.Y===e.Bot.Y&&B.WindDelta!==0&&B.OutIdx>=0&&B.Curr.Y>B.Top.Y&&t.ClipperBase.SlopesEqual3(e,B,this.m_UseFullRange)){var X=this.AddOutPt(B,e.Bot);this.AddJoin(x,X,e.Top)}}else e=this.UpdateEdgeIntoAEL(e);else e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e)},t.Clipper.prototype.GetNextInAEL=function(e,n){return n===t.Direction.dLeftToRight?e.NextInAEL:e.PrevInAEL},t.Clipper.prototype.IsMinima=function(e){return e!==null&&e.Prev.NextInLML!==e&&e.Next.NextInLML!==e},t.Clipper.prototype.IsMaxima=function(e,n){return e!==null&&e.Top.Y===n&&e.NextInLML===null},t.Clipper.prototype.IsIntermediate=function(e,n){return e.Top.Y===n&&e.NextInLML!==null},t.Clipper.prototype.GetMaximaPair=function(e){return t.IntPoint.op_Equality(e.Next.Top,e.Top)&&e.Next.NextInLML===null?e.Next:t.IntPoint.op_Equality(e.Prev.Top,e.Top)&&e.Prev.NextInLML===null?e.Prev:null},t.Clipper.prototype.GetMaximaPairEx=function(e){var n=this.GetMaximaPair(e);return n===null||n.OutIdx===t.ClipperBase.Skip||n.NextInAEL===n.PrevInAEL&&!t.ClipperBase.IsHorizontal(n)?null:n},t.Clipper.prototype.ProcessIntersections=function(e){if(this.m_ActiveEdges===null)return!0;try{if(this.BuildIntersectList(e),this.m_IntersectList.length===0)return!0;if(this.m_IntersectList.length===1||this.FixupIntersectionOrder())this.ProcessIntersectList();else return!1}catch{this.m_SortedEdges=null,this.m_IntersectList.length=0,t.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},t.Clipper.prototype.BuildIntersectList=function(e){if(this.m_ActiveEdges!==null){var n=this.m_ActiveEdges;for(this.m_SortedEdges=n;n!==null;)n.PrevInSEL=n.PrevInAEL,n.NextInSEL=n.NextInAEL,n.Curr.X=t.Clipper.TopX(n,e),n=n.NextInAEL;for(var r=!0;r&&this.m_SortedEdges!==null;){for(r=!1,n=this.m_SortedEdges;n.NextInSEL!==null;){var i=n.NextInSEL,o=new t.IntPoint0;if(n.Curr.X>i.Curr.X){this.IntersectPoint(n,i,o),o.Y<e&&(o=new t.IntPoint2(t.Clipper.TopX(n,e),e));var l=new t.IntersectNode;l.Edge1=n,l.Edge2=i,l.Pt.X=o.X,l.Pt.Y=o.Y,t.use_xyz&&(l.Pt.Z=o.Z),this.m_IntersectList.push(l),this.SwapPositionsInSEL(n,i),r=!0}else n=i}if(n.PrevInSEL!==null)n.PrevInSEL.NextInSEL=null;else break}this.m_SortedEdges=null}},t.Clipper.prototype.EdgesAdjacent=function(e){return e.Edge1.NextInSEL===e.Edge2||e.Edge1.PrevInSEL===e.Edge2},t.Clipper.IntersectNodeSort=function(e,n){return n.Pt.Y-e.Pt.Y},t.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var e=this.m_IntersectList.length,n=0;n<e;n++){if(!this.EdgesAdjacent(this.m_IntersectList[n])){for(var r=n+1;r<e&&!this.EdgesAdjacent(this.m_IntersectList[r]);)r++;if(r===e)return!1;var i=this.m_IntersectList[n];this.m_IntersectList[n]=this.m_IntersectList[r],this.m_IntersectList[r]=i}this.SwapPositionsInSEL(this.m_IntersectList[n].Edge1,this.m_IntersectList[n].Edge2)}return!0},t.Clipper.prototype.ProcessIntersectList=function(){for(var e=0,n=this.m_IntersectList.length;e<n;e++){var r=this.m_IntersectList[e];this.IntersectEdges(r.Edge1,r.Edge2,r.Pt),this.SwapPositionsInAEL(r.Edge1,r.Edge2)}this.m_IntersectList.length=0};var ei=function(e){return e<0?Math.ceil(e-.5):Math.round(e)},ti=function(e){return e<0?Math.ceil(e-.5):Math.floor(e+.5)},ni=function(e){return e<0?-Math.round(Math.abs(e)):Math.round(e)},ri=function(e){return e<0?(e-=.5,e<-2147483648?Math.ceil(e):e|0):(e+=.5,e>2147483647?Math.floor(e):e|0)};u.msie?t.Clipper.Round=ei:u.chromium?t.Clipper.Round=ni:u.safari?t.Clipper.Round=ri:t.Clipper.Round=ti,t.Clipper.TopX=function(e,n){return n===e.Top.Y?e.Top.X:e.Bot.X+t.Clipper.Round(e.Dx*(n-e.Bot.Y))},t.Clipper.prototype.IntersectPoint=function(e,n,r){r.X=0,r.Y=0;var i,o;if(e.Dx===n.Dx){r.Y=e.Curr.Y,r.X=t.Clipper.TopX(e,r.Y);return}if(e.Delta.X===0)r.X=e.Bot.X,t.ClipperBase.IsHorizontal(n)?r.Y=n.Bot.Y:(o=n.Bot.Y-n.Bot.X/n.Dx,r.Y=t.Clipper.Round(r.X/n.Dx+o));else if(n.Delta.X===0)r.X=n.Bot.X,t.ClipperBase.IsHorizontal(e)?r.Y=e.Bot.Y:(i=e.Bot.Y-e.Bot.X/e.Dx,r.Y=t.Clipper.Round(r.X/e.Dx+i));else{i=e.Bot.X-e.Bot.Y*e.Dx,o=n.Bot.X-n.Bot.Y*n.Dx;var l=(o-i)/(e.Dx-n.Dx);r.Y=t.Clipper.Round(l),Math.abs(e.Dx)<Math.abs(n.Dx)?r.X=t.Clipper.Round(e.Dx*l+i):r.X=t.Clipper.Round(n.Dx*l+o)}if(r.Y<e.Top.Y||r.Y<n.Top.Y){if(e.Top.Y>n.Top.Y)return r.Y=e.Top.Y,r.X=t.Clipper.TopX(n,e.Top.Y),r.X<e.Top.X;r.Y=n.Top.Y,Math.abs(e.Dx)<Math.abs(n.Dx)?r.X=t.Clipper.TopX(e,r.Y):r.X=t.Clipper.TopX(n,r.Y)}r.Y>e.Curr.Y&&(r.Y=e.Curr.Y,Math.abs(e.Dx)>Math.abs(n.Dx)?r.X=t.Clipper.TopX(n,r.Y):r.X=t.Clipper.TopX(e,r.Y))},t.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(e){for(var n=this.m_ActiveEdges;n!==null;){var r=this.IsMaxima(n,e);if(r){var i=this.GetMaximaPairEx(n);r=i===null||!t.ClipperBase.IsHorizontal(i)}if(r){this.StrictlySimple&&this.InsertMaxima(n.Top.X);var o=n.PrevInAEL;this.DoMaxima(n),o===null?n=this.m_ActiveEdges:n=o.NextInAEL}else{if(this.IsIntermediate(n,e)&&t.ClipperBase.IsHorizontal(n.NextInLML)?(n=this.UpdateEdgeIntoAEL(n),n.OutIdx>=0&&this.AddOutPt(n,n.Bot),this.AddEdgeToSEL(n)):(n.Curr.X=t.Clipper.TopX(n,e),n.Curr.Y=e),t.use_xyz&&(n.Top.Y===e?n.Curr.Z=n.Top.Z:n.Bot.Y===e?n.Curr.Z=n.Bot.Z:n.Curr.Z=0),this.StrictlySimple){var o=n.PrevInAEL;if(n.OutIdx>=0&&n.WindDelta!==0&&o!==null&&o.OutIdx>=0&&o.Curr.X===n.Curr.X&&o.WindDelta!==0){var l=new t.IntPoint1(n.Curr);t.use_xyz&&this.SetZ(l,o,n);var h=this.AddOutPt(o,l),m=this.AddOutPt(n,l);this.AddJoin(h,m,l)}}n=n.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,n=this.m_ActiveEdges;n!==null;){if(this.IsIntermediate(n,e)){var h=null;n.OutIdx>=0&&(h=this.AddOutPt(n,n.Top)),n=this.UpdateEdgeIntoAEL(n);var o=n.PrevInAEL,y=n.NextInAEL;if(o!==null&&o.Curr.X===n.Bot.X&&o.Curr.Y===n.Bot.Y&&h!==null&&o.OutIdx>=0&&o.Curr.Y===o.Top.Y&&t.ClipperBase.SlopesEqual5(n.Curr,n.Top,o.Curr,o.Top,this.m_UseFullRange)&&n.WindDelta!==0&&o.WindDelta!==0){var m=this.AddOutPt(ePrev2,n.Bot);this.AddJoin(h,m,n.Top)}else if(y!==null&&y.Curr.X===n.Bot.X&&y.Curr.Y===n.Bot.Y&&h!==null&&y.OutIdx>=0&&y.Curr.Y===y.Top.Y&&t.ClipperBase.SlopesEqual5(n.Curr,n.Top,y.Curr,y.Top,this.m_UseFullRange)&&n.WindDelta!==0&&y.WindDelta!==0){var m=this.AddOutPt(y,n.Bot);this.AddJoin(h,m,n.Top)}}n=n.NextInAEL}},t.Clipper.prototype.DoMaxima=function(e){var n=this.GetMaximaPairEx(e);if(n===null){e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e);return}for(var r=e.NextInAEL;r!==null&&r!==n;)this.IntersectEdges(e,r,e.Top),this.SwapPositionsInAEL(e,r),r=e.NextInAEL;e.OutIdx===-1&&n.OutIdx===-1?(this.DeleteFromAEL(e),this.DeleteFromAEL(n)):e.OutIdx>=0&&n.OutIdx>=0?(e.OutIdx>=0&&this.AddLocalMaxPoly(e,n,e.Top),this.DeleteFromAEL(e),this.DeleteFromAEL(n)):t.use_lines&&e.WindDelta===0?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=t.ClipperBase.Unassigned),this.DeleteFromAEL(e),n.OutIdx>=0&&(this.AddOutPt(n,e.Top),n.OutIdx=t.ClipperBase.Unassigned),this.DeleteFromAEL(n)):t.Error("DoMaxima error")},t.Clipper.ReversePaths=function(e){for(var n=0,r=e.length;n<r;n++)e[n].reverse()},t.Clipper.Orientation=function(e){return t.Clipper.Area(e)>=0},t.Clipper.prototype.PointCount=function(e){if(e===null)return 0;var n=0,r=e;do n++,r=r.Next;while(r!==e);return n},t.Clipper.prototype.BuildResult=function(e){t.Clear(e);for(var n=0,r=this.m_PolyOuts.length;n<r;n++){var i=this.m_PolyOuts[n];if(i.Pts!==null){var o=i.Pts.Prev,l=this.PointCount(o);if(!(l<2)){for(var h=new Array(l),m=0;m<l;m++)h[m]=o.Pt,o=o.Prev;e.push(h)}}}},t.Clipper.prototype.BuildResult2=function(e){e.Clear();for(var n=0,r=this.m_PolyOuts.length;n<r;n++){var i=this.m_PolyOuts[n],o=this.PointCount(i.Pts);if(!(i.IsOpen&&o<2||!i.IsOpen&&o<3)){this.FixHoleLinkage(i);var l=new t.PolyNode;e.m_AllPolys.push(l),i.PolyNode=l,l.m_polygon.length=o;for(var h=i.Pts.Prev,m=0;m<o;m++)l.m_polygon[m]=h.Pt,h=h.Prev}}for(var n=0,r=this.m_PolyOuts.length;n<r;n++){var i=this.m_PolyOuts[n];i.PolyNode!==null&&(i.IsOpen?(i.PolyNode.IsOpen=!0,e.AddChild(i.PolyNode)):i.FirstLeft!==null&&i.FirstLeft.PolyNode!==null?i.FirstLeft.PolyNode.AddChild(i.PolyNode):e.AddChild(i.PolyNode))}},t.Clipper.prototype.FixupOutPolyline=function(e){for(var n=e.Pts,r=n.Prev;n!==r;)if(n=n.Next,t.IntPoint.op_Equality(n.Pt,n.Prev.Pt)){n===r&&(r=n.Prev);var i=n.Prev;i.Next=n.Next,n.Next.Prev=i,n=i}n===n.Prev&&(e.Pts=null)},t.Clipper.prototype.FixupOutPolygon=function(e){var n=null;e.BottomPt=null;for(var r=e.Pts,i=this.PreserveCollinear||this.StrictlySimple;;){if(r.Prev===r||r.Prev===r.Next){e.Pts=null;return}if(t.IntPoint.op_Equality(r.Pt,r.Next.Pt)||t.IntPoint.op_Equality(r.Pt,r.Prev.Pt)||t.ClipperBase.SlopesEqual4(r.Prev.Pt,r.Pt,r.Next.Pt,this.m_UseFullRange)&&(!i||!this.Pt2IsBetweenPt1AndPt3(r.Prev.Pt,r.Pt,r.Next.Pt)))n=null,r.Prev.Next=r.Next,r.Next.Prev=r.Prev,r=r.Prev;else{if(r===n)break;n===null&&(n=r),r=r.Next}}e.Pts=r},t.Clipper.prototype.DupOutPt=function(e,n){var r=new t.OutPt;return r.Pt.X=e.Pt.X,r.Pt.Y=e.Pt.Y,t.use_xyz&&(r.Pt.Z=e.Pt.Z),r.Idx=e.Idx,n?(r.Next=e.Next,r.Prev=e,e.Next.Prev=r,e.Next=r):(r.Prev=e.Prev,r.Next=e,e.Prev.Next=r,e.Prev=r),r},t.Clipper.prototype.GetOverlap=function(e,n,r,i,o){return e<n?r<i?(o.Left=Math.max(e,r),o.Right=Math.min(n,i)):(o.Left=Math.max(e,i),o.Right=Math.min(n,r)):r<i?(o.Left=Math.max(n,r),o.Right=Math.min(e,i)):(o.Left=Math.max(n,i),o.Right=Math.min(e,r)),o.Left<o.Right},t.Clipper.prototype.JoinHorz=function(e,n,r,i,o,l){var h=e.Pt.X>n.Pt.X?t.Direction.dRightToLeft:t.Direction.dLeftToRight,m=r.Pt.X>i.Pt.X?t.Direction.dRightToLeft:t.Direction.dLeftToRight;if(h===m)return!1;if(h===t.Direction.dLeftToRight){for(;e.Next.Pt.X<=o.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y===o.Y;)e=e.Next;l&&e.Pt.X!==o.X&&(e=e.Next),n=this.DupOutPt(e,!l),t.IntPoint.op_Inequality(n.Pt,o)&&(e=n,e.Pt.X=o.X,e.Pt.Y=o.Y,t.use_xyz&&(e.Pt.Z=o.Z),n=this.DupOutPt(e,!l))}else{for(;e.Next.Pt.X>=o.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y===o.Y;)e=e.Next;!l&&e.Pt.X!==o.X&&(e=e.Next),n=this.DupOutPt(e,l),t.IntPoint.op_Inequality(n.Pt,o)&&(e=n,e.Pt.X=o.X,e.Pt.Y=o.Y,t.use_xyz&&(e.Pt.Z=o.Z),n=this.DupOutPt(e,l))}if(m===t.Direction.dLeftToRight){for(;r.Next.Pt.X<=o.X&&r.Next.Pt.X>=r.Pt.X&&r.Next.Pt.Y===o.Y;)r=r.Next;l&&r.Pt.X!==o.X&&(r=r.Next),i=this.DupOutPt(r,!l),t.IntPoint.op_Inequality(i.Pt,o)&&(r=i,r.Pt.X=o.X,r.Pt.Y=o.Y,t.use_xyz&&(r.Pt.Z=o.Z),i=this.DupOutPt(r,!l))}else{for(;r.Next.Pt.X>=o.X&&r.Next.Pt.X<=r.Pt.X&&r.Next.Pt.Y===o.Y;)r=r.Next;!l&&r.Pt.X!==o.X&&(r=r.Next),i=this.DupOutPt(r,l),t.IntPoint.op_Inequality(i.Pt,o)&&(r=i,r.Pt.X=o.X,r.Pt.Y=o.Y,t.use_xyz&&(r.Pt.Z=o.Z),i=this.DupOutPt(r,l))}return h===t.Direction.dLeftToRight===l?(e.Prev=r,r.Next=e,n.Next=i,i.Prev=n):(e.Next=r,r.Prev=e,n.Prev=i,i.Next=n),!0},t.Clipper.prototype.JoinPoints=function(e,n,r){var i=e.OutPt1,o=new t.OutPt,l=e.OutPt2,h=new t.OutPt,m=e.OutPt1.Pt.Y===e.OffPt.Y;if(m&&t.IntPoint.op_Equality(e.OffPt,e.OutPt1.Pt)&&t.IntPoint.op_Equality(e.OffPt,e.OutPt2.Pt)){if(n!==r)return!1;for(o=e.OutPt1.Next;o!==i&&t.IntPoint.op_Equality(o.Pt,e.OffPt);)o=o.Next;var y=o.Pt.Y>e.OffPt.Y;for(h=e.OutPt2.Next;h!==l&&t.IntPoint.op_Equality(h.Pt,e.OffPt);)h=h.Next;var x=h.Pt.Y>e.OffPt.Y;return y===x?!1:y?(o=this.DupOutPt(i,!1),h=this.DupOutPt(l,!0),i.Prev=l,l.Next=i,o.Next=h,h.Prev=o,e.OutPt1=i,e.OutPt2=o,!0):(o=this.DupOutPt(i,!0),h=this.DupOutPt(l,!1),i.Next=l,l.Prev=i,o.Prev=h,h.Next=o,e.OutPt1=i,e.OutPt2=o,!0)}else if(m){for(o=i;i.Prev.Pt.Y===i.Pt.Y&&i.Prev!==o&&i.Prev!==l;)i=i.Prev;for(;o.Next.Pt.Y===o.Pt.Y&&o.Next!==i&&o.Next!==l;)o=o.Next;if(o.Next===i||o.Next===l)return!1;for(h=l;l.Prev.Pt.Y===l.Pt.Y&&l.Prev!==h&&l.Prev!==o;)l=l.Prev;for(;h.Next.Pt.Y===h.Pt.Y&&h.Next!==l&&h.Next!==i;)h=h.Next;if(h.Next===l||h.Next===i)return!1;var A={Left:null,Right:null};if(!this.GetOverlap(i.Pt.X,o.Pt.X,l.Pt.X,h.Pt.X,A))return!1;var I=A.Left,E=A.Right,X=new t.IntPoint0,Y;return i.Pt.X>=I&&i.Pt.X<=E?(X.X=i.Pt.X,X.Y=i.Pt.Y,t.use_xyz&&(X.Z=i.Pt.Z),Y=i.Pt.X>o.Pt.X):l.Pt.X>=I&&l.Pt.X<=E?(X.X=l.Pt.X,X.Y=l.Pt.Y,t.use_xyz&&(X.Z=l.Pt.Z),Y=l.Pt.X>h.Pt.X):o.Pt.X>=I&&o.Pt.X<=E?(X.X=o.Pt.X,X.Y=o.Pt.Y,t.use_xyz&&(X.Z=o.Pt.Z),Y=o.Pt.X>i.Pt.X):(X.X=h.Pt.X,X.Y=h.Pt.Y,t.use_xyz&&(X.Z=h.Pt.Z),Y=h.Pt.X>l.Pt.X),e.OutPt1=i,e.OutPt2=l,this.JoinHorz(i,o,l,h,X,Y)}else{for(o=i.Next;t.IntPoint.op_Equality(o.Pt,i.Pt)&&o!==i;)o=o.Next;var B=o.Pt.Y>i.Pt.Y||!t.ClipperBase.SlopesEqual4(i.Pt,o.Pt,e.OffPt,this.m_UseFullRange);if(B){for(o=i.Prev;t.IntPoint.op_Equality(o.Pt,i.Pt)&&o!==i;)o=o.Prev;if(o.Pt.Y>i.Pt.Y||!t.ClipperBase.SlopesEqual4(i.Pt,o.Pt,e.OffPt,this.m_UseFullRange))return!1}for(h=l.Next;t.IntPoint.op_Equality(h.Pt,l.Pt)&&h!==l;)h=h.Next;var J=h.Pt.Y>l.Pt.Y||!t.ClipperBase.SlopesEqual4(l.Pt,h.Pt,e.OffPt,this.m_UseFullRange);if(J){for(h=l.Prev;t.IntPoint.op_Equality(h.Pt,l.Pt)&&h!==l;)h=h.Prev;if(h.Pt.Y>l.Pt.Y||!t.ClipperBase.SlopesEqual4(l.Pt,h.Pt,e.OffPt,this.m_UseFullRange))return!1}return o===i||h===l||o===h||n===r&&B===J?!1:B?(o=this.DupOutPt(i,!1),h=this.DupOutPt(l,!0),i.Prev=l,l.Next=i,o.Next=h,h.Prev=o,e.OutPt1=i,e.OutPt2=o,!0):(o=this.DupOutPt(i,!0),h=this.DupOutPt(l,!1),i.Next=l,l.Prev=i,o.Prev=h,h.Next=o,e.OutPt1=i,e.OutPt2=o,!0)}},t.Clipper.GetBounds=function(e){for(var n=0,r=e.length;n<r&&e[n].length===0;)n++;if(n===r)return new t.IntRect(0,0,0,0);var i=new t.IntRect;for(i.left=e[n][0].X,i.right=i.left,i.top=e[n][0].Y,i.bottom=i.top;n<r;n++)for(var o=0,l=e[n].length;o<l;o++)e[n][o].X<i.left?i.left=e[n][o].X:e[n][o].X>i.right&&(i.right=e[n][o].X),e[n][o].Y<i.top?i.top=e[n][o].Y:e[n][o].Y>i.bottom&&(i.bottom=e[n][o].Y);return i},t.Clipper.prototype.GetBounds2=function(e){var n=e,r=new t.IntRect;for(r.left=e.Pt.X,r.right=e.Pt.X,r.top=e.Pt.Y,r.bottom=e.Pt.Y,e=e.Next;e!==n;)e.Pt.X<r.left&&(r.left=e.Pt.X),e.Pt.X>r.right&&(r.right=e.Pt.X),e.Pt.Y<r.top&&(r.top=e.Pt.Y),e.Pt.Y>r.bottom&&(r.bottom=e.Pt.Y),e=e.Next;return r},t.Clipper.PointInPolygon=function(e,n){var r=0,i=n.length;if(i<3)return 0;for(var o=n[0],l=1;l<=i;++l){var h=l===i?n[0]:n[l];if(h.Y===e.Y&&(h.X===e.X||o.Y===e.Y&&h.X>e.X==o.X<e.X))return-1;if(o.Y<e.Y!=h.Y<e.Y){if(o.X>=e.X)if(h.X>e.X)r=1-r;else{var m=(o.X-e.X)*(h.Y-e.Y)-(h.X-e.X)*(o.Y-e.Y);if(m===0)return-1;m>0==h.Y>o.Y&&(r=1-r)}else if(h.X>e.X){var m=(o.X-e.X)*(h.Y-e.Y)-(h.X-e.X)*(o.Y-e.Y);if(m===0)return-1;m>0==h.Y>o.Y&&(r=1-r)}}o=h}return r},t.Clipper.prototype.PointInPolygon=function(e,n){var r=0,i=n,o=e.X,l=e.Y,h=n.Pt.X,m=n.Pt.Y;do{n=n.Next;var y=n.Pt.X,x=n.Pt.Y;if(x===l&&(y===o||m===l&&y>o==h<o))return-1;if(m<l!=x<l){if(h>=o)if(y>o)r=1-r;else{var A=(h-o)*(x-l)-(y-o)*(m-l);if(A===0)return-1;A>0==x>m&&(r=1-r)}else if(y>o){var A=(h-o)*(x-l)-(y-o)*(m-l);if(A===0)return-1;A>0==x>m&&(r=1-r)}}h=y,m=x}while(i!==n);return r},t.Clipper.prototype.Poly2ContainsPoly1=function(e,n){var r=e;do{var i=this.PointInPolygon(r.Pt,n);if(i>=0)return i>0;r=r.Next}while(r!==e);return!0},t.Clipper.prototype.FixupFirstLefts1=function(e,n){for(var r,i,o=0,l=this.m_PolyOuts.length;o<l;o++)r=this.m_PolyOuts[o],i=t.Clipper.ParseFirstLeft(r.FirstLeft),r.Pts!==null&&i===e&&this.Poly2ContainsPoly1(r.Pts,n.Pts)&&(r.FirstLeft=n)},t.Clipper.prototype.FixupFirstLefts2=function(e,n){for(var r=n.FirstLeft,i,o,l=0,h=this.m_PolyOuts.length;l<h;l++)i=this.m_PolyOuts[l],!(i.Pts===null||i===n||i===e)&&(o=t.Clipper.ParseFirstLeft(i.FirstLeft),!(o!==r&&o!==e&&o!==n)&&(this.Poly2ContainsPoly1(i.Pts,e.Pts)?i.FirstLeft=e:this.Poly2ContainsPoly1(i.Pts,n.Pts)?i.FirstLeft=n:(i.FirstLeft===e||i.FirstLeft===n)&&(i.FirstLeft=r)))},t.Clipper.prototype.FixupFirstLefts3=function(e,n){for(var r,i,o=0,l=this.m_PolyOuts.length;o<l;o++)r=this.m_PolyOuts[o],i=t.Clipper.ParseFirstLeft(r.FirstLeft),r.Pts!==null&&i===e&&(r.FirstLeft=n)},t.Clipper.ParseFirstLeft=function(e){for(;e!==null&&e.Pts===null;)e=e.FirstLeft;return e},t.Clipper.prototype.JoinCommonEdges=function(){for(var e=0,n=this.m_Joins.length;e<n;e++){var r=this.m_Joins[e],i=this.GetOutRec(r.OutPt1.Idx),o=this.GetOutRec(r.OutPt2.Idx);if(!(i.Pts===null||o.Pts===null)&&!(i.IsOpen||o.IsOpen)){var l;i===o?l=i:this.OutRec1RightOfOutRec2(i,o)?l=o:this.OutRec1RightOfOutRec2(o,i)?l=i:l=this.GetLowermostRec(i,o),this.JoinPoints(r,i,o)&&(i===o?(i.Pts=r.OutPt1,i.BottomPt=null,o=this.CreateOutRec(),o.Pts=r.OutPt2,this.UpdateOutPtIdxs(o),this.Poly2ContainsPoly1(o.Pts,i.Pts)?(o.IsHole=!i.IsHole,o.FirstLeft=i,this.m_UsingPolyTree&&this.FixupFirstLefts2(o,i),(o.IsHole^this.ReverseSolution)==this.Area$1(o)>0&&this.ReversePolyPtLinks(o.Pts)):this.Poly2ContainsPoly1(i.Pts,o.Pts)?(o.IsHole=i.IsHole,i.IsHole=!o.IsHole,o.FirstLeft=i.FirstLeft,i.FirstLeft=o,this.m_UsingPolyTree&&this.FixupFirstLefts2(i,o),(i.IsHole^this.ReverseSolution)==this.Area$1(i)>0&&this.ReversePolyPtLinks(i.Pts)):(o.IsHole=i.IsHole,o.FirstLeft=i.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(i,o))):(o.Pts=null,o.BottomPt=null,o.Idx=i.Idx,i.IsHole=l.IsHole,l===o&&(i.FirstLeft=o.FirstLeft),o.FirstLeft=i,this.m_UsingPolyTree&&this.FixupFirstLefts3(o,i)))}}},t.Clipper.prototype.UpdateOutPtIdxs=function(e){var n=e.Pts;do n.Idx=e.Idx,n=n.Prev;while(n!==e.Pts)},t.Clipper.prototype.DoSimplePolygons=function(){for(var e=0;e<this.m_PolyOuts.length;){var n=this.m_PolyOuts[e++],r=n.Pts;if(!(r===null||n.IsOpen))do{for(var i=r.Next;i!==n.Pts;){if(t.IntPoint.op_Equality(r.Pt,i.Pt)&&i.Next!==r&&i.Prev!==r){var o=r.Prev,l=i.Prev;r.Prev=l,l.Next=r,i.Prev=o,o.Next=i,n.Pts=r;var h=this.CreateOutRec();h.Pts=i,this.UpdateOutPtIdxs(h),this.Poly2ContainsPoly1(h.Pts,n.Pts)?(h.IsHole=!n.IsHole,h.FirstLeft=n,this.m_UsingPolyTree&&this.FixupFirstLefts2(h,n)):this.Poly2ContainsPoly1(n.Pts,h.Pts)?(h.IsHole=n.IsHole,n.IsHole=!h.IsHole,h.FirstLeft=n.FirstLeft,n.FirstLeft=h,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,h)):(h.IsHole=n.IsHole,h.FirstLeft=n.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(n,h)),i=r}i=i.Next}r=r.Next}while(r!==n.Pts)}},t.Clipper.Area=function(e){if(!Array.isArray(e))return 0;var n=e.length;if(n<3)return 0;for(var r=0,i=0,o=n-1;i<n;++i)r+=(e[o].X+e[i].X)*(e[o].Y-e[i].Y),o=i;return-r*.5},t.Clipper.prototype.Area=function(e){var n=e;if(e===null)return 0;var r=0;do r=r+(e.Prev.Pt.X+e.Pt.X)*(e.Prev.Pt.Y-e.Pt.Y),e=e.Next;while(e!==n);return r*.5},t.Clipper.prototype.Area$1=function(e){return this.Area(e.Pts)},t.Clipper.SimplifyPolygon=function(e,n){var r=new Array,i=new t.Clipper(0);return i.StrictlySimple=!0,i.AddPath(e,t.PolyType.ptSubject,!0),i.Execute(t.ClipType.ctUnion,r,n,n),r},t.Clipper.SimplifyPolygons=function(e,n){typeof n>"u"&&(n=t.PolyFillType.pftEvenOdd);var r=new Array,i=new t.Clipper(0);return i.StrictlySimple=!0,i.AddPaths(e,t.PolyType.ptSubject,!0),i.Execute(t.ClipType.ctUnion,r,n,n),r},t.Clipper.DistanceSqrd=function(e,n){var r=e.X-n.X,i=e.Y-n.Y;return r*r+i*i},t.Clipper.DistanceFromLineSqrd=function(e,n,r){var i=n.Y-r.Y,o=r.X-n.X,l=i*n.X+o*n.Y;return l=i*e.X+o*e.Y-l,l*l/(i*i+o*o)},t.Clipper.SlopesNearCollinear=function(e,n,r,i){return Math.abs(e.X-n.X)>Math.abs(e.Y-n.Y)?e.X>n.X==e.X<r.X?t.Clipper.DistanceFromLineSqrd(e,n,r)<i:n.X>e.X==n.X<r.X?t.Clipper.DistanceFromLineSqrd(n,e,r)<i:t.Clipper.DistanceFromLineSqrd(r,e,n)<i:e.Y>n.Y==e.Y<r.Y?t.Clipper.DistanceFromLineSqrd(e,n,r)<i:n.Y>e.Y==n.Y<r.Y?t.Clipper.DistanceFromLineSqrd(n,e,r)<i:t.Clipper.DistanceFromLineSqrd(r,e,n)<i},t.Clipper.PointsAreClose=function(e,n,r){var i=e.X-n.X,o=e.Y-n.Y;return i*i+o*o<=r},t.Clipper.ExcludeOp=function(e){var n=e.Prev;return n.Next=e.Next,e.Next.Prev=n,n.Idx=0,n},t.Clipper.CleanPolygon=function(e,n){typeof n>"u"&&(n=1.415);var r=e.length;if(r===0)return new Array;for(var i=new Array(r),o=0;o<r;++o)i[o]=new t.OutPt;for(var o=0;o<r;++o)i[o].Pt=e[o],i[o].Next=i[(o+1)%r],i[o].Next.Prev=i[o],i[o].Idx=0;for(var l=n*n,h=i[0];h.Idx===0&&h.Next!==h.Prev;)t.Clipper.PointsAreClose(h.Pt,h.Prev.Pt,l)?(h=t.Clipper.ExcludeOp(h),r--):t.Clipper.PointsAreClose(h.Prev.Pt,h.Next.Pt,l)?(t.Clipper.ExcludeOp(h.Next),h=t.Clipper.ExcludeOp(h),r-=2):t.Clipper.SlopesNearCollinear(h.Prev.Pt,h.Pt,h.Next.Pt,l)?(h=t.Clipper.ExcludeOp(h),r--):(h.Idx=1,h=h.Next);r<3&&(r=0);for(var m=new Array(r),o=0;o<r;++o)m[o]=new t.IntPoint1(h.Pt),h=h.Next;return i=null,m},t.Clipper.CleanPolygons=function(e,n){for(var r=new Array(e.length),i=0,o=e.length;i<o;i++)r[i]=t.Clipper.CleanPolygon(e[i],n);return r},t.Clipper.Minkowski=function(e,n,r,i){var o=i?1:0,l=e.length,h=n.length,m=new Array;if(r)for(var y=0;y<h;y++){for(var x=new Array(l),A=0,I=e.length,E=e[A];A<I;A++,E=e[A])x[A]=new t.IntPoint2(n[y].X+E.X,n[y].Y+E.Y);m.push(x)}else for(var y=0;y<h;y++){for(var x=new Array(l),A=0,I=e.length,E=e[A];A<I;A++,E=e[A])x[A]=new t.IntPoint2(n[y].X-E.X,n[y].Y-E.Y);m.push(x)}for(var X=new Array,y=0;y<h-1+o;y++)for(var A=0;A<l;A++){var Y=new Array;Y.push(m[y%h][A%l]),Y.push(m[(y+1)%h][A%l]),Y.push(m[(y+1)%h][(A+1)%l]),Y.push(m[y%h][(A+1)%l]),t.Clipper.Orientation(Y)||Y.reverse(),X.push(Y)}return X},t.Clipper.MinkowskiSum=function(e,n,r){if(n[0]instanceof Array){for(var o=n,h=new t.Paths,l=new t.Clipper,m=0;m<o.length;++m){var y=t.Clipper.Minkowski(e,o[m],!0,r);if(l.AddPaths(y,t.PolyType.ptSubject,!0),r){var i=t.Clipper.TranslatePath(o[m],e[0]);l.AddPath(i,t.PolyType.ptClip,!0)}}return l.Execute(t.ClipType.ctUnion,h,t.PolyFillType.pftNonZero,t.PolyFillType.pftNonZero),h}else{var i=n,o=t.Clipper.Minkowski(e,i,!0,r),l=new t.Clipper;return l.AddPaths(o,t.PolyType.ptSubject,!0),l.Execute(t.ClipType.ctUnion,o,t.PolyFillType.pftNonZero,t.PolyFillType.pftNonZero),o}},t.Clipper.TranslatePath=function(e,n){for(var r=new t.Path,i=0;i<e.length;i++)r.push(new t.IntPoint2(e[i].X+n.X,e[i].Y+n.Y));return r},t.Clipper.MinkowskiDiff=function(e,n){var r=t.Clipper.Minkowski(e,n,!1,!0),i=new t.Clipper;return i.AddPaths(r,t.PolyType.ptSubject,!0),i.Execute(t.ClipType.ctUnion,r,t.PolyFillType.pftNonZero,t.PolyFillType.pftNonZero),r},t.Clipper.PolyTreeToPaths=function(e){var n=new Array;return t.Clipper.AddPolyNodeToPaths(e,t.Clipper.NodeType.ntAny,n),n},t.Clipper.AddPolyNodeToPaths=function(e,n,r){var i=!0;switch(n){case t.Clipper.NodeType.ntOpen:return;case t.Clipper.NodeType.ntClosed:i=!e.IsOpen;break;default:break}e.m_polygon.length>0&&i&&r.push(e.m_polygon);for(var o=0,l=e.Childs(),h=l.length,m=l[o];o<h;o++,m=l[o])t.Clipper.AddPolyNodeToPaths(m,n,r)},t.Clipper.OpenPathsFromPolyTree=function(e){for(var n=new t.Paths,r=0,i=e.ChildCount();r<i;r++)e.Childs()[r].IsOpen&&n.push(e.Childs()[r].m_polygon);return n},t.Clipper.ClosedPathsFromPolyTree=function(e){var n=new t.Paths;return t.Clipper.AddPolyNodeToPaths(e,t.Clipper.NodeType.ntClosed,n),n},Rt(t.Clipper,t.ClipperBase),t.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},t.ClipperOffset=function(e,n){typeof e>"u"&&(e=2),typeof n>"u"&&(n=t.ClipperOffset.def_arc_tolerance),this.m_destPolys=new t.Paths,this.m_srcPoly=new t.Path,this.m_destPoly=new t.Path,this.m_normals=new Array,this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new t.IntPoint0,this.m_polyNodes=new t.PolyNode,this.MiterLimit=e,this.ArcTolerance=n,this.m_lowest.X=-1},t.ClipperOffset.two_pi=6.28318530717959,t.ClipperOffset.def_arc_tolerance=.25,t.ClipperOffset.prototype.Clear=function(){t.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},t.ClipperOffset.Round=t.Clipper.Round,t.ClipperOffset.prototype.AddPath=function(e,n,r){var i=e.length-1;if(!(i<0)){var o=new t.PolyNode;if(o.m_jointype=n,o.m_endtype=r,r===t.EndType.etClosedLine||r===t.EndType.etClosedPolygon)for(;i>0&&t.IntPoint.op_Equality(e[0],e[i]);)i--;o.m_polygon.push(e[0]);for(var l=0,h=0,m=1;m<=i;m++)t.IntPoint.op_Inequality(o.m_polygon[l],e[m])&&(l++,o.m_polygon.push(e[m]),(e[m].Y>o.m_polygon[h].Y||e[m].Y===o.m_polygon[h].Y&&e[m].X<o.m_polygon[h].X)&&(h=l));if(!(r===t.EndType.etClosedPolygon&&l<2)&&(this.m_polyNodes.AddChild(o),r===t.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new t.IntPoint2(this.m_polyNodes.ChildCount()-1,h);else{var y=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(o.m_polygon[h].Y>y.Y||o.m_polygon[h].Y===y.Y&&o.m_polygon[h].X<y.X)&&(this.m_lowest=new t.IntPoint2(this.m_polyNodes.ChildCount()-1,h))}}},t.ClipperOffset.prototype.AddPaths=function(e,n,r){for(var i=0,o=e.length;i<o;i++)this.AddPath(e[i],n,r)},t.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!t.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var e=0;e<this.m_polyNodes.ChildCount();e++){var n=this.m_polyNodes.Childs()[e];(n.m_endtype===t.EndType.etClosedPolygon||n.m_endtype===t.EndType.etClosedLine&&t.Clipper.Orientation(n.m_polygon))&&n.m_polygon.reverse()}else for(var e=0;e<this.m_polyNodes.ChildCount();e++){var n=this.m_polyNodes.Childs()[e];n.m_endtype===t.EndType.etClosedLine&&!t.Clipper.Orientation(n.m_polygon)&&n.m_polygon.reverse()}},t.ClipperOffset.GetUnitNormal=function(e,n){var r=n.X-e.X,i=n.Y-e.Y;if(r===0&&i===0)return new t.DoublePoint2(0,0);var o=1/Math.sqrt(r*r+i*i);return r*=o,i*=o,new t.DoublePoint2(i,-r)},t.ClipperOffset.prototype.DoOffset=function(e){if(this.m_destPolys=new Array,this.m_delta=e,t.ClipperBase.near_zero(e)){for(var n=0;n<this.m_polyNodes.ChildCount();n++){var r=this.m_polyNodes.Childs()[n];r.m_endtype===t.EndType.etClosedPolygon&&this.m_destPolys.push(r.m_polygon)}return}this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5;var i;this.ArcTolerance<=0?i=t.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(e)*t.ClipperOffset.def_arc_tolerance?i=Math.abs(e)*t.ClipperOffset.def_arc_tolerance:i=this.ArcTolerance;var o=3.14159265358979/Math.acos(1-i/Math.abs(e));this.m_sin=Math.sin(t.ClipperOffset.two_pi/o),this.m_cos=Math.cos(t.ClipperOffset.two_pi/o),this.m_StepsPerRad=o/t.ClipperOffset.two_pi,e<0&&(this.m_sin=-this.m_sin);for(var n=0;n<this.m_polyNodes.ChildCount();n++){var r=this.m_polyNodes.Childs()[n];this.m_srcPoly=r.m_polygon;var l=this.m_srcPoly.length;if(!(l===0||e<=0&&(l<3||r.m_endtype!==t.EndType.etClosedPolygon))){if(this.m_destPoly=new Array,l===1){if(r.m_jointype===t.JoinType.jtRound)for(var h=1,m=0,y=1;y<=o;y++){this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X+h*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y+m*e)));var x=h;h=h*this.m_cos-this.m_sin*m,m=x*this.m_sin+m*this.m_cos}else for(var h=-1,m=-1,y=0;y<4;++y)this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X+h*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y+m*e))),h<0?h=1:m<0?m=1:h=-1;this.m_destPolys.push(this.m_destPoly);continue}this.m_normals.length=0;for(var y=0;y<l-1;y++)this.m_normals.push(t.ClipperOffset.GetUnitNormal(this.m_srcPoly[y],this.m_srcPoly[y+1]));if(r.m_endtype===t.EndType.etClosedLine||r.m_endtype===t.EndType.etClosedPolygon?this.m_normals.push(t.ClipperOffset.GetUnitNormal(this.m_srcPoly[l-1],this.m_srcPoly[0])):this.m_normals.push(new t.DoublePoint1(this.m_normals[l-2])),r.m_endtype===t.EndType.etClosedPolygon){for(var A=l-1,y=0;y<l;y++)A=this.OffsetPoint(y,A,r.m_jointype);this.m_destPolys.push(this.m_destPoly)}else if(r.m_endtype===t.EndType.etClosedLine){for(var A=l-1,y=0;y<l;y++)A=this.OffsetPoint(y,A,r.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array;for(var I=this.m_normals[l-1],y=l-1;y>0;y--)this.m_normals[y]=new t.DoublePoint2(-this.m_normals[y-1].X,-this.m_normals[y-1].Y);this.m_normals[0]=new t.DoublePoint2(-I.X,-I.Y),A=0;for(var y=l-1;y>=0;y--)A=this.OffsetPoint(y,A,r.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{for(var A=0,y=1;y<l-1;++y)A=this.OffsetPoint(y,A,r.m_jointype);var E;if(r.m_endtype===t.EndType.etOpenButt){var y=l-1;E=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[y].X+this.m_normals[y].X*e),t.ClipperOffset.Round(this.m_srcPoly[y].Y+this.m_normals[y].Y*e)),this.m_destPoly.push(E),E=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[y].X-this.m_normals[y].X*e),t.ClipperOffset.Round(this.m_srcPoly[y].Y-this.m_normals[y].Y*e)),this.m_destPoly.push(E)}else{var y=l-1;A=l-2,this.m_sinA=0,this.m_normals[y]=new t.DoublePoint2(-this.m_normals[y].X,-this.m_normals[y].Y),r.m_endtype===t.EndType.etOpenSquare?this.DoSquare(y,A):this.DoRound(y,A)}for(var y=l-1;y>0;y--)this.m_normals[y]=new t.DoublePoint2(-this.m_normals[y-1].X,-this.m_normals[y-1].Y);this.m_normals[0]=new t.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),A=l-1;for(var y=A-1;y>0;--y)A=this.OffsetPoint(y,A,r.m_jointype);r.m_endtype===t.EndType.etOpenButt?(E=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*e)),this.m_destPoly.push(E),E=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*e)),this.m_destPoly.push(E)):(A=1,this.m_sinA=0,r.m_endtype===t.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}}},t.ClipperOffset.prototype.Execute=function(){var e=arguments,n=e[0]instanceof t.PolyTree;if(n){var r=e[0],i=e[1];r.Clear(),this.FixOrientations(),this.DoOffset(i);var o=new t.Clipper(0);if(o.AddPaths(this.m_destPolys,t.PolyType.ptSubject,!0),i>0)o.Execute(t.ClipType.ctUnion,r,t.PolyFillType.pftPositive,t.PolyFillType.pftPositive);else{var l=t.Clipper.GetBounds(this.m_destPolys),h=new t.Path;if(h.push(new t.IntPoint2(l.left-10,l.bottom+10)),h.push(new t.IntPoint2(l.right+10,l.bottom+10)),h.push(new t.IntPoint2(l.right+10,l.top-10)),h.push(new t.IntPoint2(l.left-10,l.top-10)),o.AddPath(h,t.PolyType.ptSubject,!0),o.ReverseSolution=!0,o.Execute(t.ClipType.ctUnion,r,t.PolyFillType.pftNegative,t.PolyFillType.pftNegative),r.ChildCount()===1&&r.Childs()[0].ChildCount()>0){var m=r.Childs()[0];r.Childs()[0]=m.Childs()[0],r.Childs()[0].m_Parent=r;for(var y=1;y<m.ChildCount();y++)r.AddChild(m.Childs()[y])}else r.Clear()}}else{var r=e[0],i=e[1];t.Clear(r),this.FixOrientations(),this.DoOffset(i);var o=new t.Clipper(0);if(o.AddPaths(this.m_destPolys,t.PolyType.ptSubject,!0),i>0)o.Execute(t.ClipType.ctUnion,r,t.PolyFillType.pftPositive,t.PolyFillType.pftPositive);else{var l=t.Clipper.GetBounds(this.m_destPolys),h=new t.Path;h.push(new t.IntPoint2(l.left-10,l.bottom+10)),h.push(new t.IntPoint2(l.right+10,l.bottom+10)),h.push(new t.IntPoint2(l.right+10,l.top-10)),h.push(new t.IntPoint2(l.left-10,l.top-10)),o.AddPath(h,t.PolyType.ptSubject,!0),o.ReverseSolution=!0,o.Execute(t.ClipType.ctUnion,r,t.PolyFillType.pftNegative,t.PolyFillType.pftNegative),r.length>0&&r.splice(0,1)}}},t.ClipperOffset.prototype.OffsetPoint=function(e,n,r){if(this.m_sinA=this.m_normals[n].X*this.m_normals[e].Y-this.m_normals[e].X*this.m_normals[n].Y,Math.abs(this.m_sinA*this.m_delta)<1){var i=this.m_normals[n].X*this.m_normals[e].X+this.m_normals[e].Y*this.m_normals[n].Y;if(i>0)return this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[n].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[n].Y*this.m_delta))),n}else this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1);if(this.m_sinA*this.m_delta<0)this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[n].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[n].Y*this.m_delta))),this.m_destPoly.push(new t.IntPoint1(this.m_srcPoly[e])),this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)));else switch(r){case t.JoinType.jtMiter:{var o=1+(this.m_normals[e].X*this.m_normals[n].X+this.m_normals[e].Y*this.m_normals[n].Y);o>=this.m_miterLim?this.DoMiter(e,n,o):this.DoSquare(e,n);break}case t.JoinType.jtSquare:this.DoSquare(e,n);break;case t.JoinType.jtRound:this.DoRound(e,n);break}return n=e,n},t.ClipperOffset.prototype.DoSquare=function(e,n){var r=Math.tan(Math.atan2(this.m_sinA,this.m_normals[n].X*this.m_normals[e].X+this.m_normals[n].Y*this.m_normals[e].Y)/4);this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[n].X-this.m_normals[n].Y*r)),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[n].Y+this.m_normals[n].X*r)))),this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[e].X+this.m_normals[e].Y*r)),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[e].Y-this.m_normals[e].X*r))))},t.ClipperOffset.prototype.DoMiter=function(e,n,r){var i=this.m_delta/r;this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+(this.m_normals[n].X+this.m_normals[e].X)*i),t.ClipperOffset.Round(this.m_srcPoly[e].Y+(this.m_normals[n].Y+this.m_normals[e].Y)*i)))},t.ClipperOffset.prototype.DoRound=function(e,n){for(var r=Math.atan2(this.m_sinA,this.m_normals[n].X*this.m_normals[e].X+this.m_normals[n].Y*this.m_normals[e].Y),i=Math.max(t.Cast_Int32(t.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(r))),1),o=this.m_normals[n].X,l=this.m_normals[n].Y,h,m=0;m<i;++m)this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+o*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+l*this.m_delta))),h=o,o=o*this.m_cos-this.m_sin*l,l=h*this.m_sin+l*this.m_cos;this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)))},t.Error=function(e){try{throw new Error(e)}catch(n){alert(n.message)}},t.JS={},t.JS.AreaOfPolygon=function(e,n){return n||(n=1),t.Clipper.Area(e)/(n*n)},t.JS.AreaOfPolygons=function(e,n){n||(n=1);for(var r=0,i=0;i<e.length;i++)r+=t.Clipper.Area(e[i]);return r/(n*n)},t.JS.BoundsOfPath=function(e,n){return t.JS.BoundsOfPaths([e],n)},t.JS.BoundsOfPaths=function(e,n){n||(n=1);var r=t.Clipper.GetBounds(e);return r.left/=n,r.bottom/=n,r.right/=n,r.top/=n,r},t.JS.Clean=function(i,n){if(!(i instanceof Array))return[];var r=i[0]instanceof Array,i=t.JS.Clone(i);if(typeof n!="number"||n===null)return t.Error("Delta is not a number in Clean()."),i;if(i.length===0||i.length===1&&i[0].length===0||n<0)return i;r||(i=[i]);for(var o=i.length,l,h,m,y,x,A,I,E=[],X=0;X<o;X++)if(h=i[X],l=h.length,l!==0){if(l<3){m=h,E.push(m);continue}for(m=h,y=n*n,x=h[0],A=1,I=1;I<l;I++)(h[I].X-x.X)*(h[I].X-x.X)+(h[I].Y-x.Y)*(h[I].Y-x.Y)<=y||(m[A]=h[I],x=h[I],A++);x=h[A-1],(h[0].X-x.X)*(h[0].X-x.X)+(h[0].Y-x.Y)*(h[0].Y-x.Y)<=y&&A--,A<l&&m.splice(A,l-A),m.length&&E.push(m)}return!r&&E.length?E=E[0]:!r&&E.length===0?E=[]:r&&E.length===0&&(E=[[]]),E},t.JS.Clone=function(e){if(!(e instanceof Array))return[];if(e.length===0)return[];if(e.length===1&&e[0].length===0)return[[]];var n=e[0]instanceof Array;n||(e=[e]);var r=e.length,i,o,l,h,m=new Array(r);for(o=0;o<r;o++){for(i=e[o].length,h=new Array(i),l=0;l<i;l++)h[l]={X:e[o][l].X,Y:e[o][l].Y};m[o]=h}return n||(m=m[0]),m},t.JS.Lighten=function(e,n){if(!(e instanceof Array))return[];if(typeof n!="number"||n===null)return t.Error("Tolerance is not a number in Lighten()."),t.JS.Clone(e);if(e.length===0||e.length===1&&e[0].length===0||n<0)return t.JS.Clone(e);var r=e[0]instanceof Array;r||(e=[e]);var i,o,l,h,m,y,x,A,I,E,X,Y,B,J,ue,me,Oe,ii=e.length,oi=n*n,Ne=[];for(i=0;i<ii;i++)if(l=e[i],y=l.length,y!==0){for(h=0;h<1e6;h++){for(m=[],y=l.length,l[y-1].X!==l[0].X||l[y-1].Y!==l[0].Y?(Y=1,l.push({X:l[0].X,Y:l[0].Y}),y=l.length):Y=0,X=[],o=0;o<y-2;o++)x=l[o],I=l[o+1],A=l[o+2],me=x.X,Oe=x.Y,B=A.X-me,J=A.Y-Oe,(B!==0||J!==0)&&(ue=((I.X-me)*B+(I.Y-Oe)*J)/(B*B+J*J),ue>1?(me=A.X,Oe=A.Y):ue>0&&(me+=B*ue,Oe+=J*ue)),B=I.X-me,J=I.Y-Oe,E=B*B+J*J,E<=oi&&(X[o+1]=1,o++);for(m.push({X:l[0].X,Y:l[0].Y}),o=1;o<y-1;o++)X[o]||m.push({X:l[o].X,Y:l[o].Y});if(m.push({X:l[y-1].X,Y:l[y-1].Y}),Y&&l.pop(),X.length)l=m;else break}y=m.length,m[y-1].X===m[0].X&&m[y-1].Y===m[0].Y&&m.pop(),m.length>2&&Ne.push(m)}return r||(Ne=Ne[0]),typeof Ne>"u"&&(Ne=[]),Ne},t.JS.PerimeterOfPath=function(e,n,r){if(typeof e>"u")return 0;var i=Math.sqrt,o=0,l,h,m=0,y=0,x=0,A=0,I=e.length;if(I<2)return 0;for(n&&(e[I]=e[0],I++);--I;)l=e[I],m=l.X,y=l.Y,h=e[I-1],x=h.X,A=h.Y,o+=i((m-x)*(m-x)+(y-A)*(y-A));return n&&e.pop(),o/r},t.JS.PerimeterOfPaths=function(e,n,r){r||(r=1);for(var i=0,o=0;o<e.length;o++)i+=t.JS.PerimeterOfPath(e[o],n,r);return i},t.JS.ScaleDownPath=function(e,n){var r,i;for(n||(n=1),r=e.length;r--;)i=e[r],i.X=i.X/n,i.Y=i.Y/n},t.JS.ScaleDownPaths=function(e,n){var r,i,o;for(n||(n=1),r=e.length;r--;)for(i=e[r].length;i--;)o=e[r][i],o.X=o.X/n,o.Y=o.Y/n},t.JS.ScaleUpPath=function(e,n){var r,i,o=Math.round;for(n||(n=1),r=e.length;r--;)i=e[r],i.X=o(i.X*n),i.Y=o(i.Y*n)},t.JS.ScaleUpPaths=function(e,n){var r,i,o,l=Math.round;for(n||(n=1),r=e.length;r--;)for(i=e[r].length;i--;)o=e[r][i],o.X=l(o.X*n),o.Y=l(o.Y*n)},t.ExPolygons=function(){return[]},t.ExPolygon=function(){this.outer=null,this.holes=null},t.JS.AddOuterPolyNodeToExPolygons=function(e,n){var r=new t.ExPolygon;r.outer=e.Contour();var i=e.Childs(),o=i.length;r.holes=new Array(o);var l,h,m,y,x,A;for(m=0;m<o;m++)for(l=i[m],r.holes[m]=l.Contour(),y=0,x=l.Childs(),A=x.length;y<A;y++)h=x[y],t.JS.AddOuterPolyNodeToExPolygons(h,n);n.push(r)},t.JS.ExPolygonsToPaths=function(e){var n,r,i,o,l=new t.Paths;for(n=0,i=e.length;n<i;n++)for(l.push(e[n].outer),r=0,o=e[n].holes.length;r<o;r++)l.push(e[n].holes[r]);return l},t.JS.PolyTreeToExPolygons=function(e){var n=new t.ExPolygons,r,i,o,l;for(i=0,o=e.Childs(),l=o.length;i<l;i++)r=o[i],t.JS.AddOuterPolyNodeToExPolygons(r,n);return n}})()});function Qe(t){let s=new Uint8Array(128);for(let p=0;p<64;p++)s[Vi.charCodeAt(p)]=p;let f=t.replace(/=+$/,"").length,a=new Uint8ClampedArray(Math.floor(f*3/4)),u=0;for(let p=0;p<f;p+=4){let d=s[t.charCodeAt(p)]<<18|s[t.charCodeAt(p+1)]<<12|(p+2<f?s[t.charCodeAt(p+2)]:0)<<6|(p+3<f?s[t.charCodeAt(p+3)]:0);a[u++]=d>>16,u<a.length&&(a[u++]=d>>8&255),u<a.length&&(a[u++]=d&255)}return a}var Vi,mt=tt(()=>{"use strict";Vi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"});function kn(t){if(!t.startsWith("kzm1:"))return"format";let s=Qe(t.slice(5));if(s.length<8)return"damaged";let f=new DataView(s.buffer,s.byteOffset,s.byteLength),a=f.getUint32(0,!0),u=f.getUint32(4,!0);if(8+a*12+u*12!==s.length)return"damaged";let p=new Float32Array(a*3),d=new Uint32Array(u*3),g=8;for(let c=0;c<p.length;c++,g+=4)p[c]=f.getFloat32(g,!0);for(let c=0;c<d.length;c++,g+=4)d[c]=f.getUint32(g,!0);return d.some(c=>c>=a)?"damaged":{pos:p,tri:d}}var Mn=tt(()=>{"use strict";mt()});function Tn(t){let s=kn(t);if(s==="format")throw new yt(_("Unbekanntes Modellformat."));if(s==="damaged")throw new yt(_("Die Modelldaten sind besch\xE4digt."));return s}var yt,An=tt(()=>{"use strict";oe();mt();Mn();yt=class extends Error{}});oe();var Gt=(t,s)=>[t[1]*s[2]-t[2]*s[1],t[2]*s[0]-t[0]*s[2],t[0]*s[1]-t[1]*s[0]],vt=(t,s)=>t[0]*s[0]+t[1]*s[1]+t[2]*s[2];function Ut(t,s,f){let a=p=>[0,1,2].map(d=>s[0][d]*p[0]+s[1][d]*p[1]+s[2][d]*p[2]),u=a(t.o);return{o:[u[0]+f[0],u[1]+f[1],u[2]+f[2]],u:a(t.u),v:a(t.v),n:a(t.n)}}oe();oe();var eo=Math.PI/180;oe();var di={style:"burn",color:"#3a2210",alpha:.88},Q=t=>({contrast:.5,rough:.75,metal:0,clear:0,ior:1.5,edge:"#4a2e18",engrave:di,tile:120,...t}),ro=[Q({id:"poplar",name:"Sperrholz Pappel",group:"wood",tex:"ply",color:"#e2cfa4",contrast:.35,edge:"#5a3b20"}),Q({id:"birch",name:"Sperrholz Birke",group:"wood",tex:"ply",color:"#ecd9b4",contrast:.3,edge:"#5e3f22",engrave:{style:"burn",color:"#3f2512",alpha:.85}}),Q({id:"beech",name:"Buche",group:"wood",tex:"wood",color:"#d9a878",contrast:.4,edge:"#4f2f18"}),Q({id:"oak",name:"Eiche",group:"wood",tex:"wood",color:"#c99a62",contrast:.65,edge:"#45291a"}),Q({id:"walnut",name:"Nussbaum",group:"wood",tex:"wood",color:"#7a5034",contrast:.55,edge:"#2c1a0f",engrave:{style:"burn",color:"#1e120a",alpha:.85}}),Q({id:"cherry",name:"Kirsche",group:"wood",tex:"wood",color:"#b8744a",contrast:.45,edge:"#3e2414",engrave:{style:"burn",color:"#2a170c",alpha:.85}}),Q({id:"bamboo",name:"Bambus",group:"wood",tex:"wood",color:"#d8b77a",contrast:.3,edge:"#5a3a1c",tile:60}),Q({id:"mdf",name:"MDF",group:"board",tex:"mdf",color:"#b98e5f",contrast:.2,edge:"#3a2414",engrave:{style:"burn",color:"#2e1a0c",alpha:.9}}),Q({id:"cardboard",name:"Karton",group:"board",tex:"paper",color:"#c49a6a",contrast:.3,edge:"#5a3a20",tile:80}),Q({id:"paper",name:"Papier",group:"board",tex:"paper",color:"#f3f0e8",contrast:.12,edge:"#8a7458",rough:.9,tile:80}),Q({id:"cork",name:"Kork",group:"board",tex:"cork",color:"#b98a5a",contrast:.7,edge:"#4a2f18",rough:.95,tile:60}),Q({id:"leather",name:"Leder",group:"other",tex:"leather",color:"#8a5a36",contrast:.45,edge:"#3a2416",rough:.6,engrave:{style:"burn",color:"#2a170c",alpha:.8},tile:60}),Q({id:"slate",name:"Schiefer",group:"stone",tex:"slate",color:"#3b3f44",contrast:.5,edge:null,rough:.85,engrave:{style:"light",color:"#c9ccc9",alpha:.9}}),Q({id:"granite",name:"Granit",group:"stone",tex:"granite",color:"#2b2b2d",contrast:.6,edge:null,rough:.35,engrave:{style:"light",color:"#d6d6d2",alpha:.85},tile:80}),Q({id:"acrylic",name:"Acryl klar",group:"plastic",tex:"plain",color:"#e8f2f2",contrast:0,edge:"#9dbcbc",rough:.04,clear:.95,ior:1.49,engrave:{style:"frost",color:"#eef2f3",alpha:.9}}),Q({id:"acrylic-color",name:"Acryl farbig",group:"plastic",tex:"plain",color:"#d8333a",contrast:0,rough:.05,clear:.6,ior:1.49,edge:"#a0242a",engrave:{style:"frost",color:"#f4dede",alpha:.8}}),Q({id:"acrylic-opaque",name:"Acryl deckend",group:"plastic",tex:"plain",color:"#1d1f22",contrast:0,edge:null,rough:.08,engrave:{style:"frost",color:"#e8e8e8",alpha:.8}}),Q({id:"glass",name:"Glas",group:"plastic",tex:"plain",color:"#e2f0e8",contrast:0,edge:"#8fb8a4",rough:.02,clear:.95,ior:1.52,engrave:{style:"frost",color:"#eef2f0",alpha:.9}}),Q({id:"anodized",name:"Aluminium eloxiert",group:"metal",tex:"brushed",color:"#222428",contrast:.25,edge:"#b8bcc2",rough:.35,metal:.9,engrave:{style:"light",color:"#e4e6e8",alpha:.92}}),Q({id:"steel",name:"Edelstahl",group:"metal",tex:"brushed",color:"#b9bdc2",contrast:.3,edge:null,rough:.3,metal:1,engrave:{style:"burn",color:"#202226",alpha:.85}}),Q({id:"plain",name:"Einfarbig",group:"other",tex:"plain",color:"#cfc6b8",contrast:0,edge:null,rough:.7,engrave:{style:"burn",color:"#2a2622",alpha:.85}})];var Zt=Ve(Xe(),1);var{Clipper:so,ClipperOffset:ao,JoinType:lo,EndType:uo,PolyFillType:co,ClipType:fo,PolyType:ho}=Zt.default;oe();var vo=[["%#",_("Seriennummer")],["%4#",_("Seriennummer mit 4 Stellen (0042)")],["%0",_("CSV-Spalte 0 (%1, %2 \u2026 weitere Spalten)")],["%{Name}",_("CSV-Spalte nach \xDCberschrift")],["%d",_("Tag (01\u201331)")],["%m",_("Monat (01\u201312)")],["%b",_("Monatsname kurz")],["%B",_("Monatsname")],["%y",_("Jahr zweistellig")],["%Y",_("Jahr")],["%j",_("Tag im Jahr (001\u2013366)")],["%a",_("Wochentag kurz")],["%A",_("Wochentag")],["%H",_("Stunde (00\u201323)")],["%h",_("Stunde (01\u201312)")],["%p",_("AM/PM")],["%M",_("Minute")],["%S",_("Sekunde")],["%%",_("Prozentzeichen")]];var le=[1,0,0,1,0,0];function we(t,s,f){return{x:t[0]*s+t[2]*f+t[4],y:t[1]*s+t[3]*f+t[5]}}var hs=[["threshold",_("Schwellwert")],["ordered",_("Geordnet")],["atkinson",_("Atkinson")],["floyd",_("Dither (Floyd-Steinberg)")],["stucki",_("Stucki")],["jarvis",_("Jarvis")],["newsprint",_("Zeitungsdruck (Newsprint)")],["halftone",_("Halbton")],["sketch",_("Skizze (Sketch)")],["grayscale",_("Graustufen")]];var bi=["mode","speed","power","minPower","passes","air","kerf","tabs","fillStyle","interval","angle","crossHatch","bidirectional","overscan","perf","lead","ramp","dwell","dedup","dedupTol","zOffset","zStep","sub","look","galvo","layerType","kerfAxes","fillGrouping"],ps=bi.filter(t=>t!=="air"&&t!=="look"&&t!=="sub"&&t!=="layerType");function fe(t,s,f,a,u){let p=1-u;return{x:p*p*p*t.x+3*p*p*u*s.x+3*p*u*u*f.x+u*u*u*a.x,y:p*p*p*t.y+3*p*p*u*s.y+3*p*u*u*f.y+u*u*u*a.y}}function wt(t,s,f,a){let u=s-t,p=f-s,d=a-f,g=u-2*p+d,c=2*(p-u),b=u;if(g===0)return c===0?[]:[-b/c].filter(M=>M>0&&M<1);let w=c*c-4*g*b;if(w<0)return[];let k=-.5*(c+(c<0?-1:1)*Math.sqrt(w));return(k===0?[-c/(2*g)]:[k/g,b/k]).filter(M=>M>0&&M<1)}function rt(t){let s=[],f=t.nodes.length,a=t.closed?f:f-1;for(let u=0;u<a;u++){let p=t.nodes[u],d=t.nodes[(u+1)%f];s.push({a:p,b:d,c1:p.cout??p,c2:d.cin??d,curve:!!(p.cout||d.cin),ia:u,ib:(u+1)%f})}return s}var se=(t,s,f)=>({x:t.x+(s.x-t.x)*f,y:t.y+(s.y-t.y)*f});function Jt(t){return rt(t).map(s=>({a:s.a,c1:s.c1,c2:s.c2,b:s.b,curve:s.curve}))}function Se(t,s,f){if(!t.curve)return{a:se(t.a,t.b,s),c1:se(t.a,t.b,s),c2:se(t.a,t.b,f),b:se(t.a,t.b,f),curve:!1};let a=(d,g)=>{let c=se(d.a,d.c1,g),b=se(d.c1,d.c2,g),w=se(d.c2,d.b,g),k=se(c,b,g),M=se(b,w,g);return{a:d.a,c1:c,c2:k,b:se(k,M,g),curve:!0}},u=(d,g)=>{let c=se(d.a,d.c1,g),b=se(d.c1,d.c2,g),w=se(d.c2,d.b,g),k=se(c,b,g),M=se(b,w,g);return{a:se(k,M,g),c1:M,c2:w,b:d.b,curve:!0}},p=f<1?a(t,f):t;return s>0&&(p=u(p,f>0?s/f:0)),p}var te=1e-10,De=(t,s)=>Math.hypot(t.x-s.x,t.y-s.y),ot=t=>{throw Object.assign(new Error("contour-topology"),{cause:t})},St=t=>{++t.work>4e6&&ot("contour-topology-budget")},zt=t=>({x0:Math.min(...t.map(s=>s.x)),x1:Math.max(...t.map(s=>s.x)),y0:Math.min(...t.map(s=>s.y)),y1:Math.max(...t.map(s=>s.y))}),Ge=t=>{let s=t.curve?[t.a,t.c1,t.c2,t.b]:[t.a,t.b];return{piece:t,points:s,box:zt(s)}},Ht=(t,s)=>t.x0>s.x1+te||s.x0>t.x1+te||t.y0>s.y1+te||s.y0>t.y1+te,it=t=>Math.hypot(t.box.x1-t.box.x0,t.box.y1-t.box.y0);function ce(t,s=le,f={work:0}){(!t.closed||t.nodes.length<2)&&ot("contour-not-closed");let a={...t,nodes:t.nodes.map(c=>({...c,...we(s,c.x,c.y),...c.cin?{cin:we(s,c.cin.x,c.cin.y)}:{},...c.cout?{cout:we(s,c.cout.x,c.cout.y)}:{}}))};a.nodes.some(c=>[c,c.cin,c.cout].some(b=>b&&(!Number.isFinite(b.x)||!Number.isFinite(b.y)||Math.abs(b.x)>1e6||Math.abs(b.y)>1e6)))&&ot("contour-invalid");let u=[],p=0,d=0,g=a.nodes[0];for(let c of Jt(a)){if(St(f),(c.curve?[c.c1,c.c2,c.b]:[c.b]).every(w=>w.x===c.a.x&&w.y===c.a.y))continue;let b=c.curve?[...new Set([0,...wt(c.a.x,c.c1.x,c.c2.x,c.b.x),...wt(c.a.y,c.c1.y,c.c2.y,c.b.y),1])].sort((w,k)=>w-k):[0,1];for(let w=1;w<b.length;w++)if(b[w]>b[w-1]){let k=Ge(Se(c,b[w-1],b[w]));k.points.every(M=>M.x===k.points[0].x&&M.y===k.points[0].y)||u.push(k)}for(let[w,k]of[[.5-Math.sqrt(15)/10,5/18],[.5,4/9],[.5+Math.sqrt(15)/10,5/18]]){let M=c.curve?fe(c.a,c.c1,c.c2,c.b,w):{x:c.a.x+w*(c.b.x-c.a.x),y:c.a.y+w*(c.b.y-c.a.y)},T=c.curve?3*((1-w)**2*(c.c1.x-c.a.x)+2*(1-w)*w*(c.c2.x-c.c1.x)+w*w*(c.b.x-c.c2.x)):c.b.x-c.a.x,C=c.curve?3*((1-w)**2*(c.c1.y-c.a.y)+2*(1-w)*w*(c.c2.y-c.c1.y)+w*w*(c.b.y-c.c2.y)):c.b.y-c.a.y,P=(M.x-g.x)*C*k,v=(M.y-g.y)*T*k;p+=P-v,d+=Math.abs(P)+Math.abs(v)}}return(!u.length||Math.abs(p)<=64*Number.EPSILON*d)&&ot("contour-degenerate"),{spans:u,area:p/2,box:zt(u.flatMap(c=>c.points))}}function Pi(t,s,f){if(Ht(t.box,s.box))return!0;let a=[{x:1,y:0},{x:0,y:1}];for(let p of[t,s])for(let d=0;d<p.points.length;d++)for(let g=d+1;g<p.points.length;g++){let c=p.points[g].x-p.points[d].x,b=p.points[g].y-p.points[d].y,w=Math.hypot(c,b);w&&a.push({x:-b/w,y:c/w})}let u=t.points[0];for(let p of a){let d=T=>(T.x-u.x)*p.x+(T.y-u.y)*p.y,g=t.points.map(d),c=s.points.map(d),b=Math.min(...g),w=Math.max(...g),k=Math.min(...c),M=Math.max(...c);if(w<k-te||M<b-te)return!0;for(let T of f){let C=d(T),P=(v,S,L)=>v.points.every((O,V)=>Math.abs(S[V]-L)>te||De(O,T)<=te);if(Math.abs(w-k)<=te&&Math.abs(C-w)<=te&&(P(t,g,w)||P(s,c,k))||Math.abs(M-b)<=te&&Math.abs(C-b)<=te&&(P(t,g,b)||P(s,c,M)))return!0}}return!1}function Ue(t,s,f,a,u=0){if(St(a),Pi(t,s,f))return!1;if(!t.piece.curve&&!s.piece.curve){let p=t.piece,d=s.piece,g=p.b.x-p.a.x,c=p.b.y-p.a.y,b=d.b.x-d.a.x,w=d.b.y-d.a.y,k=g*w-c*b,M=d.a.x-p.a.x,T=d.a.y-p.a.y;if(k!==0){let C=(M*w-T*b)/k,P=(M*c-T*g)/k;if(C<0||C>1||P<0||P>1)return!1;let v={x:p.a.x+C*g,y:p.a.y+C*c};return!f.some(S=>De(v,S)<=te)}return!0}return u>=56||Math.max(it(t),it(s))<=te?!f.some(p=>t.points.every(d=>De(d,p)<=te)&&s.points.every(d=>De(d,p)<=te)):it(t)>=it(s)?Ue(Ge(Se(t.piece,0,.5)),s,f,a,u+1)||Ue(Ge(Se(t.piece,.5,1)),s,f,a,u+1):Ue(t,Ge(Se(s.piece,0,.5)),f,a,u+1)||Ue(t,Ge(Se(s.piece,.5,1)),f,a,u+1)}function Ce(t,s={work:0},f=!1){let a=t.flatMap((u,p)=>u.spans.map((d,g)=>({...d,r:p,i:g,n:u.spans.length}))).sort((u,p)=>u.box.x0-p.box.x0);for(let u=0;u<a.length;u++)for(let p=u+1;p<a.length&&a[p].box.x0<=a[u].box.x1+te;p++){St(s);let d=a[u],g=a[p];if(f&&d.r===g.r||Ht(d.box,g.box))continue;let c=[];if(d.r===g.r&&((d.i+1)%d.n===g.i||(g.i+1)%g.n===d.i)&&((d.i+1)%d.n===g.i&&De(d.piece.b,g.piece.a)<=te&&c.push(d.piece.b),(g.i+1)%g.n===d.i&&De(g.piece.b,d.piece.a)<=te&&c.push(g.piece.b)),Ue(d,g,c,s))throw Object.assign(new Error("contour-topology"),{cause:"contour-contact",details:{contours:[d.r,g.r],spans:[d.i,g.i],pieces:[d.piece,g.piece],allowed:c}})}}function he(t,s){if(s.x<t.box.x0||s.x>t.box.x1||s.y<t.box.y0||s.y>t.box.y1)return!1;let f=!1;for(let{piece:a}of t.spans){if(a.a.y>s.y==a.b.y>s.y)continue;let u;if(!a.curve)u=a.a.x+(a.b.x-a.a.x)*(s.y-a.a.y)/(a.b.y-a.a.y);else{let p=0,d=1;for(let g=0;g<48;g++){let c=(p+d)/2;fe(a.a,a.c1,a.c2,a.b,c).y<s.y==a.a.y<a.b.y?p=c:d=c}u=fe(a.a,a.c1,a.c2,a.b,(p+d)/2).x}u>s.x&&(f=!f)}return f}oe();function xi(t,s,f,a){let u=Math.abs(f-s)||1,p=c=>{let b=u*1e-5,w=t(c-b),k=t(c+b);return{x:(k.x-w.x)/(2*b),y:(k.y-w.y)/(2*b)}},d=[],g=(c,b,w)=>{let k=t(c),M=t(b),T=(b-c)/3,C=p(c),P=p(b),v={x:k.x+C.x*T,y:k.y+C.y*T},S={x:M.x-P.x*T,y:M.y-P.y*T},L=0;for(let O=1;O<8;O++){let V=O/8,j=fe(k,v,S,M,V),U=t(c+(b-c)*V);L=Math.max(L,Math.hypot(j.x-U.x,j.y-U.y))}if(L>a&&w<12){let O=(c+b)/2;g(c,O,w+1),g(O,b,w+1)}else d.push([v,S,M])};return g(s,f,0),d}var Ae=class{constructor(){Pt(this,"nodes",[])}get last(){return this.nodes[this.nodes.length-1]}same(s){let f=this.last;return!!f&&Math.hypot(f.x-s.x,f.y-s.y)<1e-7}line(s){this.same(s)||this.nodes.push({x:s.x,y:s.y})}cubic(s,f,a){if(!this.nodes.length)throw new Error("PathBuilder: kein Anfangspunkt");this.last.cout={x:s.x,y:s.y},this.nodes.push({x:a.x,y:a.y,cin:{x:f.x,y:f.y}})}curve(s,f,a,u){if(!(Math.abs(a-f)<1e-12)){this.line(s(f));for(let[p,d,g]of xi(s,f,a,u))this.cubic(p,d,g)}}arc(s,f,a,u,p){let d=w=>({x:s+a*Math.cos(w),y:f+a*Math.sin(w)});this.line(d(u));let g=Math.max(1,Math.ceil(Math.abs(p-u)/(Math.PI/2)-1e-9)),c=(p-u)/g,b=4/3*Math.tan(c/4)*a;for(let w=0;w<g;w++){let k=u+w*c,M=k+c,T=d(k),C=d(M);this.cubic({x:T.x-b*Math.sin(k),y:T.y+b*Math.cos(k)},{x:C.x+b*Math.sin(M),y:C.y-b*Math.cos(M)},C)}}close(){let s=this.nodes;if(s.length>1){let f=s[0],a=s[s.length-1];Math.hypot(f.x-a.x,f.y-a.y)<1e-6&&(a.cin&&(f.cin=a.cin),s.pop())}return{nodes:s,closed:!0}}};var ne=(t,s,f)=>ye({"pt-BR":t,en:s,de:f}),vi=["window","round-window","oval-window","triangle-window","polygon-window","hole-line","hole-arc","staggered-holes","strap-slots","double-ring"],wi=["round","slot","grid","bolt-circle","vents","corners","keyhole","hex",...vi],Ns={round:_("Rundbohrung"),slot:_("Langloch"),grid:_("Rechteckiges Bohrbild"),"bolt-circle":_("Lochkreis"),vents:_("L\xFCftungsgitter"),corners:_("Eckbefestigungen"),keyhole:_("Schl\xFCssellochaufh\xE4ngung"),hex:_("Sechskantaufnahme"),window:ne("Janela retangular","Rectangular opening","Rechteckiger Ausschnitt"),"round-window":ne("Janela de cantos arredondados","Rounded rectangular opening","Rechteck mit abgerundeten Ecken"),"oval-window":ne("Janela el\xEDptica","Elliptical opening","Elliptischer Ausschnitt"),"triangle-window":ne("Janela triangular","Triangular opening","Dreieckiger Ausschnitt"),"polygon-window":ne("Janela poligonal","Polygon opening","Vieleckiger Ausschnitt"),"hole-line":ne("Fileira de furos","Line of holes","Lochreihe"),"hole-arc":ne("Fura\xE7\xE3o em arco","Partial bolt arc","Bohrungen auf Teilbogen"),"staggered-holes":ne("Furos em zigue-zague","Staggered holes","Versetzte Lochreihe"),"strap-slots":ne("Rasgos para abra\xE7adeira","Cable tie slots","Kabelbinderschlitze"),"double-ring":ne("Anel duplo de furos","Double bolt ring","Doppelter Lochkreis")},Si={x:"X (mm)",y:"Y (mm)",diameter:_("Bohrdurchmesser (mm)"),angle:_("Drehung (\xB0)"),length:_("Gesamtl\xE4nge (mm)"),width:_("Schlitzbreite (mm)"),count:_("Anzahl"),columns:_("Spalten"),rows:_("Zeilen"),pitchX:_("Teilung X (mm)"),pitchY:_("Teilung Y (mm)"),circleDiameter:_("Lochkreisdurchmesser (mm)"),pitch:_("Schlitzabstand Mitte zu Mitte (mm)"),edgeX:_("Rand bis Bohrmitte X (mm)"),edgeY:_("Rand bis Bohrmitte Y (mm)"),head:_("Kopf\xF6ffnung \xD8 (mm)"),neck:_("Halsbreite (mm)"),rise:_("Abstand der \xD6ffnungsmittelpunkte (mm)"),across:_("Schl\xFCsselweite (mm)"),openingWidth:ne("Largura da janela (mm)","Opening width (mm)","Ausschnittbreite (mm)"),openingHeight:ne("Altura da janela (mm)","Opening height (mm)","Ausschnitth\xF6he (mm)"),radius:ne("Raio dos cantos (mm)","Corner radius (mm)","Eckenradius (mm)"),outerDiameter:ne("Di\xE2metro externo entre centros (mm)","Outer centerline diameter (mm)","\xC4u\xDFerer Mittelpunktsdurchmesser (mm)"),vertexDiameter:ne("Di\xE2metro do c\xEDrculo circunscrito (mm)","Circumcircle diameter (mm)","Umkreisdurchmesser (mm)"),sides:ne("N\xFAmero de lados","Number of sides","Seitenzahl"),sweep:ne("Abertura do arco (\xB0)","Arc sweep (\xB0)","Bogenwinkel (\xB0)"),spacing:ne("Dist\xE2ncia entre centros (mm)","Center spacing (mm)","Mittenabstand (mm)"),rowGap:ne("Dist\xE2ncia entre fileiras (mm)","Row separation (mm)","Reihenabstand (mm)")};var Kt={round:{x:0,y:0,diameter:5},slot:{x:0,y:0,length:24,width:5,angle:0},grid:{x:0,y:0,columns:3,rows:2,pitchX:12,pitchY:10,diameter:3},"bolt-circle":{x:0,y:0,count:6,circleDiameter:24,diameter:3,angle:0},vents:{x:0,y:0,count:4,length:24,width:3,pitch:6,angle:0},corners:{edgeX:6,edgeY:6,diameter:4},keyhole:{x:0,y:0,head:10,neck:4,rise:9,angle:0},hex:{x:0,y:0,across:7,angle:0},window:{x:0,y:0,openingWidth:24,openingHeight:14,angle:0},"round-window":{x:0,y:0,openingWidth:24,openingHeight:14,radius:3,angle:0},"oval-window":{x:0,y:0,openingWidth:26,openingHeight:14,angle:0},"triangle-window":{x:0,y:0,openingWidth:22,openingHeight:18,angle:0},"polygon-window":{x:0,y:0,sides:5,vertexDiameter:22,angle:0},"hole-line":{x:0,y:0,count:4,spacing:7,diameter:3,angle:0},"hole-arc":{x:0,y:0,count:5,circleDiameter:28,sweep:120,diameter:3,angle:0},"staggered-holes":{x:0,y:0,count:5,spacing:6,rowGap:7,diameter:3,angle:0},"strap-slots":{x:0,y:0,length:14,width:3,spacing:13,angle:0},"double-ring":{x:0,y:0,count:6,circleDiameter:14,outerDiameter:31,diameter:3,angle:0}},Ci=t=>Object.keys(Kt[t]);function Ct(t){if(!t||!wi.includes(t.kind)||typeof t.id!="string"||!/^c[0-9]{1,9}$/.test(t.id)||typeof t.name!="string"||!t.name.trim()||t.name.length>100||!t.values||typeof t.values!="object")throw Error(_("Ung\xFCltige Schnittoperation."));for(let a of Ci(t.kind)){let u=t.values[a],p=a==="rows"||a==="columns"||a==="count"||a==="sides",d=a==="x"||a==="y"||a==="angle";if(!Number.isFinite(u)||Math.abs(u)>1e5||!d&&u<=0||p&&(!Number.isInteger(u)||u>250))throw Error(_("\u201E{name}\u201C: \u201E{field}\u201C pr\xFCfen.",{name:t.name,field:Si[a]}))}let s=t.values;if((t.kind==="slot"||t.kind==="vents"||t.kind==="strap-slots")&&s.length<=s.width||t.kind==="grid"&&s.columns*s.rows>250||t.kind==="bolt-circle"&&s.count<2||t.kind==="round-window"&&2*s.radius>Math.min(s.openingWidth,s.openingHeight)||t.kind==="polygon-window"&&s.sides<3||["hole-line","hole-arc","staggered-holes","double-ring"].includes(t.kind)&&s.count<2||t.kind==="hole-arc"&&s.sweep>=360||t.kind==="double-ring"&&(s.count*2>250||s.outerDiameter<=s.circleDiameter)||t.kind==="keyhole"&&(s.neck>=s.head||s.rise<=Math.sqrt(s.head**2-s.neck**2)/2))throw Error(_("Ma\xDFe oder Anzahl f\xFCr \u201E{name}\u201C pr\xFCfen.",{name:t.name}))}var ge=Math.PI*2;function Ie(t,s,f){let a=new Ae;for(let u=0;u<8;u++)a.arc(t,s,f,-ge*u/8,-ge*(u+1)/8);return a.close()}function st(t,s,f){let a=(t-s)/2,u=s/2,p=new Ae;return p.arc(-a,f,u,-Math.PI/2,-3*Math.PI/2),p.arc(a,f,u,Math.PI/2,-Math.PI/2),p.close()}function qt(t,s,f){Ct(t);let a=t.values,u=[];switch(t.kind){case"round":u.push(Ie(0,0,a.diameter/2));break;case"slot":u.push(st(a.length,a.width,0));break;case"grid":for(let P=0;P<a.rows;P++)for(let v=0;v<a.columns;v++)u.push(Ie((v-(a.columns-1)/2)*a.pitchX,(P-(a.rows-1)/2)*a.pitchY,a.diameter/2));break;case"bolt-circle":for(let P=0;P<a.count;P++){let v=ge*P/a.count;u.push(Ie(a.circleDiameter/2*Math.cos(v),a.circleDiameter/2*Math.sin(v),a.diameter/2))}break;case"vents":for(let P=0;P<a.count;P++)u.push(st(a.length,a.width,(P-(a.count-1)/2)*a.pitch));break;case"corners":{let P=s/2-a.edgeX,v=f/2-a.edgeY;if(P<=0||v<=0)throw Error(_("Ma\xDFe oder Anzahl f\xFCr \u201E{name}\u201C pr\xFCfen.",{name:t.name}));for(let S of[-P,P])for(let L of[-v,v])u.push(Ie(S,L,a.diameter/2));break}case"keyhole":{let P=new Ae,v=a.head/2,S=a.neck/2,L=Math.acos(S/v);P.arc(0,0,v,-Math.PI+L,-Math.PI),P.arc(0,0,v,-Math.PI,-ge),P.arc(0,0,v,-ge,-ge-L),P.arc(0,-a.rise,S,0,-Math.PI),u.push(P.close());break}case"hex":{let P=a.across/Math.sqrt(3),v=Array.from({length:6},(S,L)=>({x:P*Math.cos(-ge*L/6),y:P*Math.sin(-ge*L/6)}));u.push({closed:!0,nodes:v});break}case"window":case"round-window":{let P=a.openingWidth/2,v=a.openingHeight/2,S=a.radius;if(t.kind==="window"){u.push({closed:!0,nodes:[{x:-P,y:-v},{x:-P,y:v},{x:P,y:v},{x:P,y:-v}]});break}let L=new Ae;L.arc(-P+S,-v+S,S,-Math.PI/2,-Math.PI),L.arc(-P+S,v-S,S,Math.PI,Math.PI/2),L.arc(P-S,v-S,S,Math.PI/2,0),L.arc(P-S,-v+S,S,0,-Math.PI/2),u.push(L.close());break}case"oval-window":u.push(Ie(0,0,1));break;case"triangle-window":{let P=a.openingWidth/2,v=a.openingHeight/2;u.push({closed:!0,nodes:[{x:0,y:-v},{x:-P,y:v},{x:P,y:v}]});break}case"polygon-window":{let P=a.vertexDiameter/2;u.push({closed:!0,nodes:Array.from({length:a.sides},(v,S)=>{let L=-Math.PI/2-ge*S/a.sides;return{x:P*Math.cos(L),y:P*Math.sin(L)}})});break}case"hole-line":case"staggered-holes":for(let P=0;P<a.count;P++)u.push(Ie((P-(a.count-1)/2)*a.spacing,t.kind==="hole-line"?0:(P%2-.5)*a.rowGap,a.diameter/2));break;case"hole-arc":case"double-ring":for(let P=0;P<a.count;P++){let v=t.kind==="hole-arc"?(P/(a.count-1)-.5)*a.sweep*Math.PI/180:ge*P/a.count;u.push(Ie(a.circleDiameter/2*Math.cos(v),a.circleDiameter/2*Math.sin(v),a.diameter/2)),t.kind==="double-ring"&&u.push(Ie(a.outerDiameter/2*Math.cos(v),a.outerDiameter/2*Math.sin(v),a.diameter/2))}break;case"strap-slots":u.push(st(a.length,a.width,-a.spacing/2),st(a.length,a.width,a.spacing/2));break}let p=Kt[t.kind],d=(p.angle===void 0?0:a.angle)*Math.PI/180,g=Math.cos(d),c=Math.sin(d),b=p.x===void 0?0:a.x,w=p.y===void 0?0:a.y,k=P=>Math.round(P*1e9)/1e9,M=t.kind==="oval-window"?a.openingWidth/2:1,T=t.kind==="oval-window"?a.openingHeight/2:1,C=P=>({x:k(b+g*P.x*M-c*P.y*T),y:k(w+c*P.x*M+g*P.y*T)});return u.map(P=>({closed:!0,nodes:P.nodes.map(v=>({...C(v),...v.cin&&{cin:C(v.cin)},...v.cout&&{cout:C(v.cout)}}))}))}oe();var It=()=>Error(_("Die referenzierte Kante oder Bearbeitung ist nicht verf\xFCgbar."));function Ii(t,s,f,a){let u=t.profile[0]?.nodes,p=u?.length??0;if(!Number.isInteger(s)||s<0||s>=p||!(f>=0&&f<=1)||!Number.isFinite(a)||a<0)throw It();let d=N=>({x:N.x*t.width,y:N.y*t.height}),g=u[s],c=u[(s+1)%p],b=d(g),w=d(g.cout??g),k=d(c.cin??c),M=d(c),T=f,C=1-T,P=!!(g.cout||c.cin),v=N=>P?C**3*b[N]+3*C*C*T*w[N]+3*C*T*T*k[N]+T**3*M[N]:C*b[N]+T*M[N],S=N=>P?3*C*C*(w[N]-b[N])+6*C*T*(k[N]-w[N])+3*T*T*(M[N]-k[N]):M[N]-b[N],L=S("x"),O=S("y");Math.hypot(L,O)<1e-9&&(L=M.x-b.x,O=M.y-b.y);let V=Math.hypot(L,O);if(V<1e-9)throw It();let j=0;for(let N=0;N<p;N++){let R=u[N],G=u[(N+1)%p],H=R.cout??R,q=G.cin??G,W=R;for(let $=1;$<=12;$++){let z=$/12,D=1-z,K={x:D*D*D*R.x+3*D*D*z*H.x+3*D*z*z*q.x+z*z*z*G.x,y:D*D*D*R.y+3*D*D*z*H.y+3*D*z*z*q.y+z*z*z*G.y};j+=W.x*K.y-K.x*W.y,W=K}}let U=Math.sign(j)*a/V;return{x:v("x")-U*O,y:v("y")+U*L}}function $t(t){let s=new Map;return(t.cuts??[]).map(f=>{let a=f.reference,u={x:f.values.x??0,y:f.values.y??0};if(a){if(f.kind==="corners")throw It();if("edge"in a)u=Ii(t,a.edge,a.fraction,a.inset);else{let p=s.get(a.parent);if(!p||!Number.isFinite(a.dx)||!Number.isFinite(a.dy))throw Error(_("\u201E{name}\u201C muss hinter ihrer Bezugsoperation liegen.",{name:f.name}));u={x:p.x+a.dx,y:p.y+a.dy}}}return s.set(f.id,u),a?{...f,values:{...f.values,...u}}:f})}oe();function Qt(t,s){let f=[];for(let a of t){let u=[],p=[],d=!1,g=()=>{p.length>1&&u.push({closed:!1,nodes:p}),p=[]},c=b=>b.x>=s.x&&b.x<=s.x+s.w&&b.y>=s.y&&b.y<=s.y+s.h;for(let b=0;b<a.nodes.length-(a.closed?0:1);b++){let w=a.nodes[b],k=a.nodes[(b+1)%a.nodes.length],M=k.x-w.x,T=k.y-w.y,C=v=>({x:w.x+v*M,y:w.y+v*T}),P=[0,1];for(let v of[(s.x-w.x)/M,(s.x+s.w-w.x)/M,(s.y-w.y)/T,(s.y+s.h-w.y)/T])v>0&&v<1&&P.push(v);P.sort((v,S)=>v-S);for(let v=1;v<P.length;v++)if(!(P[v]-P[v-1]<1e-10)){if(c(C((P[v]+P[v-1])/2))){d=!0,g();continue}p.length||p.push(C(P[v-1])),p.push(C(P[v]))}}g(),d?f.push(...u):f.push(a)}return f}function kt(t){if(t!==void 0&&(!t||typeof t!="object"||!["author","edition","reference"].every(s=>{let f=t[s];return typeof f=="string"&&f.length<=240})))throw Error("invalid-panels")}function en(t){let s=()=>Error("invalid-panels");if(!t||typeof t.name!="string"||!t.name.trim()||t.name.length>100||!Array.isArray(t.regions)||!t.regions.length||t.regions.length>100)throw s();kt(t.source);let f=0;for(let a of t.regions){if(!a||![a.x,a.y,a.width,a.height].every(Number.isFinite)||a.width<=0||a.height<=0||!Array.isArray(a.profile)||!a.profile.length)throw s();for(let u of a.profile){if(!u||u.closed!==!0||!Array.isArray(u.nodes)||u.nodes.length<3)throw s();for(let p of u.nodes)if(!p||!Number.isFinite(p.x)||!Number.isFinite(p.y)||Math.abs(p.x)>.500001||Math.abs(p.y)>.500001||p.cin||p.cout)throw s();f+=u.nodes.length}}if(f>8e3)throw s()}function tn(t){let s=t.photoEngraving?.regions.flatMap(f=>f.profile.map(a=>({closed:!0,nodes:a.nodes.map(u=>({x:(f.x+u.x*f.width)*t.width,y:(f.y+u.y*f.height)*t.height}))})))??[];return t.faceDesign?.reserve?Qt(s,t.faceDesign.reserve):s}function ki(t){let s=Math.min(...t.regions.map(p=>p.x-p.width/2)),f=Math.max(...t.regions.map(p=>p.x+p.width/2)),a=Math.min(...t.regions.map(p=>p.y-p.height/2)),u=Math.max(...t.regions.map(p=>p.y+p.height/2));return{x:(s+f)/2,y:(a+u)/2,width:f-s,height:u-a}}function nn(t,s){if(!t.photoEngraving)return;let f=ki(t.photoEngraving),a={closed:!0,nodes:[[-.5,-.5],[.5,-.5],[.5,.5],[-.5,.5]].map(([c,b])=>({x:(f.x+c*f.width)*t.width,y:(f.y+b*f.height)*t.height}))},u={work:0},p=s.map(c=>ce(c,void 0,u)),d=ce(a,void 0,u),g=()=>Error(_("Die Gravur passt an dieser Position nicht vollst\xE4ndig auf die gew\xE4hlte Fl\xE4che."));if(p.filter(c=>he(c,a.nodes[0])).length%2!==1||s.some(c=>he(d,c.nodes[0])))throw g();try{Ce([...p,d],u,!0)}catch{throw g()}}var Ze=t=>typeof t=="number"&&Number.isFinite(t)&&Math.abs(t)<=1e5,at=t=>t&&Ze(t.x)&&Ze(t.y);function rn(t){let s=()=>{throw Error("invalid-panels")};(!t||!["back","front"].includes(t.side)||!Ze(t.contrast)||t.contrast<.1||t.contrast>2||!Array.isArray(t.items)||t.items.length>100)&&s();let f=t.reserve;f&&(![f.x,f.y,f.w,f.h].every(Ze)||f.w<=0||f.h<=0)&&s();let a=new Set,u=0;for(let p of t.items){(!p||typeof p.id!="string"||p.id.length>120||a.has(p.id)||typeof p.name!="string"||p.name.length>100||!["text","route","plane","pin","hatch","borders"].includes(p.kind)||!["engrave","mark"].includes(p.op)||![p.x,p.y,p.size,p.arc,p.width,p.dash,p.gap,p.pitch,p.angle].every(Ze)||p.size<=0||p.width<=0||p.dash<=0||p.gap<=0||p.pitch<.05||typeof p.text!="string"||p.text.length>300||typeof p.font!="string"||p.font.length>160||!["left","center","right"].includes(p.align)||!Array.isArray(p.points)||p.points.length>1e3||!p.points.every(at)||!Array.isArray(p.paths))&&s(),a.add(p.id);for(let d of p.paths)(!d||typeof d.closed!="boolean"||!Array.isArray(d.nodes)||d.nodes.length<2||!d.nodes.every(g=>at(g)&&(!g.cin||at(g.cin))&&(!g.cout||at(g.cout))))&&s(),u+=d.nodes.length}u>12e3&&s()}var Fe=Ve(Xe(),1);var sn=Ve(Xe(),1);var Z=1e3,Mi=.01,Ti=1;var{Clipper:Ai,ClipType:Hs,PolyType:on,PolyFillType:Ks}=sn.default;function be(t,s,f){let a=[],u=(p,d)=>{let g=we(s,p.x,p.y),c=Math.round(g.x*Z),b=Math.round(g.y*Z),w=a[a.length-1];(!w||w.X!==c||w.Y!==b)&&(a.push({X:c,Y:b}),f?.push(d))};t.nodes.length&&u(t.nodes[0],0);for(let[p,d]of rt(t).entries()){if(!d.curve){u(d.b,p+1);continue}let g=[d.a,d.c1,d.c2,d.b].map(w=>we(s,w.x,w.y)),c=Math.hypot(g[1].x-g[0].x,g[1].y-g[0].y)+Math.hypot(g[2].x-g[1].x,g[2].y-g[1].y)+Math.hypot(g[3].x-g[2].x,g[3].y-g[2].y),b=Math.max(4,Math.min(2048,Math.max(Math.ceil(Math.sqrt(c/Mi)*.6),Math.ceil(c/Ti))));for(let w=1;w<=b;w++)u(fe(d.a,d.c1,d.c2,d.b,w/b),p+w/b)}if(t.closed&&a.length>1){let p=a[0],d=a[a.length-1];p.X===d.X&&p.Y===d.Y&&(a.pop(),f?.pop())}return a}function lt(t,s,f,a){let u=new Ai;u.AddPaths(s,on.ptSubject,!0),f.length&&u.AddPaths(f,on.ptClip,!0);let p=[];return u.Execute(t,p,a,a),p}oe();var pe=()=>{throw Error(_("Plattenma\xDFe, Ausschnitte und Profile pr\xFCfen."))},Je=t=>Number.isFinite(t)&&Math.abs(t)<=1e5,Mt=t=>Je(t)&&t>0,Ye=t=>t&&Je(t.x)&&Je(t.y),ut=(t,s)=>Math.hypot(s.x-t.x,s.y-t.y);function ln(t){(!t||typeof t.closed!="boolean"||!Array.isArray(t.nodes)||t.nodes.length<2||t.nodes.length>512)&&pe();let s=0;for(let[p,d]of t.nodes.entries())if((!Ye(d)||d.cin&&!Ye(d.cin)||d.cout&&!Ye(d.cout))&&pe(),p||t.closed){let g=t.nodes[(p+t.nodes.length-1)%t.nodes.length];Ye(g)||pe(),s+=ut(g,g.cout??g)+ut(g.cout??g,d.cin??d)+ut(d.cin??d,d)}s>0&&s<=5e4||pe();let f=be(t,le).map(p=>({x:p.X/Z,y:p.Y/Z}));(f.length<2||f.length>3e4)&&pe(),t.closed&&f.push({...f[0]});let a=[0];for(let p=1;p<f.length;p++)a.push(a[p-1]+ut(f[p],f[p-1]));let u=a[a.length-1];return u>.01&&u<=1e4||pe(),{points:f,arc:a,length:u}}function un(t){return ln(t).length}function ct(t){if((!t||![t.pitch,t.cut,t.bridge].every(Mt)||!Je(t.margin)||t.margin<0||t.axis!==void 0&&!["along-x","along-y"].includes(t.axis))&&pe(),t.region){let{x0:s,x1:f,y0:a,y1:u}=t.region;(!Object.values(t.region).every(Je)||s!==void 0&&f!==void 0&&s>=f||a!==void 0&&u!==void 0&&a>=u)&&pe()}t.reserve&&(!Ye(t.reserve)||!Mt(t.reserve.radius))&&pe()}function cn(t){(!t||!["XY","XZ","YZ"].includes(t.plane))&&pe();let s=un(t.guide);return t.pattern!==void 0&&ct(t.pattern),t.hole!==void 0&&(!Ye(t.hole)||!Mt(t.hole.diameter))&&pe(),s}function fn(t,s,f,a){if(!t)return[];ct(t);let u=t.axis==="along-x",p=t.region,d=Math.max(-f/2+t.margin,p?.x0??-1/0),g=Math.min(f/2-t.margin,p?.x1??1/0),c=Math.max(-a/2+t.margin,p?.y0??-1/0),b=Math.min(a/2-t.margin,p?.y1??1/0);if(d>=g||c>=b)return[];let[w,k,M,T]=u?[c,b,d,g]:[d,g,c,b],C=t.cut+t.bridge,P=Math.floor((k-w)/t.pitch)+1;P*(1+Math.ceil((T-M)/C))>2e4&&pe();let v=s.map(N=>be(N,le)),S=lt(Fe.default.ClipType.ctUnion,v,[],Fe.default.PolyFillType.pftEvenOdd),L=new Fe.default.ClipperOffset;L.AddPaths(S,Fe.default.JoinType.jtRound,Fe.default.EndType.etClosedPolygon);let O=[];L.Execute(O,-Math.max(.002,t.margin)*Z);let V=O.flatMap(N=>N.map((R,G)=>{let H=N[(G+1)%N.length];return u?[R.Y/Z,R.X/Z,H.Y/Z,H.X/Z]:[R.X/Z,R.Y/Z,H.X/Z,H.Y/Z]})),j=[],U=(k+w-(P-1)*t.pitch)/2;for(let N=0;N<P;N++){let R=U+N*t.pitch;R>=k-1e-8&&(R=k-.003),R<=w+1e-8&&(R=w+.003);let G=[];for(let[D,K,ee,re]of V)D<=R!=ee<=R&&G.push(K+(re-K)*(R-D)/(ee-D));G.sort((D,K)=>D-K);let H=[];for(let D=1;D<G.length;D+=2)H.push([Math.max(M,G[D-1]),Math.min(T,G[D])]);let q=t.reserve,W=q?R-(u?q.y:q.x):1/0,$=H;if(q&&Math.abs(W)<q.radius){let D=Math.sqrt(q.radius**2-W**2),K=u?q.x:q.y;$=H.flatMap(([ee,re])=>[[ee,Math.min(re,K-D)],[Math.max(ee,K+D),re]])}let z=M-N%2*C/2;for(let[D,K]of $)for(let ee=z+Math.floor((D-z)/C)*C;ee<K;ee+=C){let re=Math.max(D,ee),ve=Math.min(K,ee+t.cut);ve-re<.01||j.push({closed:!1,nodes:u?[{x:re,y:R},{x:ve,y:R}]:[{x:R,y:re},{x:R,y:ve}]})}}return j}function Li(t,s,f){let{points:a,arc:u,length:p}=ln(t.guide),d=s/p,g=(M,T)=>{let C=Math.hypot(M,T)||1;return{x:M/C,y:T/C}},c=a.map((M,T)=>{let C=a[T?T-1:t.guide.closed?a.length-2:0],P=a[T+1<a.length?T+1:t.guide.closed?1:T],v=g(M.x-C.x,M.y-C.y),S=g(P.x-M.x,P.y-M.y);return Math.hypot(v.x+S.x,v.y+S.y)<1e-8?S:g(v.x+S.x,v.y+S.y)}),b=[-s/2],w=0;for(let M=1;M<a.length-1;M++){let T=(u[M]-u[w])*d,C=c[w],P=c[M];(Math.abs(C.x*P.y-C.y*P.x)>.04||C.x*P.x+C.y*P.y<0||T>8)&&(b.push(u[M]*d-s/2),w=M)}b.push(s/2);function k(M,T,C){let P=Math.max(0,Math.min(p,(M+s/2)/d)),v=0,S=u.length-1;for(;S-v>1;){let H=S+v>>1;u[H]<=P?v=H:S=H}let L=(P-u[v])/(u[S]-u[v]),O=a[v],V=a[S],j=g(c[v].x*(1-L)+c[S].x*L,c[v].y*(1-L)+c[S].y*L),U=M+s/2-P*d,N=(O.x+(V.x-O.x)*L)*d+j.x*U,R=(O.y+(V.y-O.y)*L)*d+j.y*U,G=C-f/2;return t.plane==="XY"?[N+j.y*G,-R+j.x*G,-T]:t.plane==="YZ"?[T,-N+j.y*G,R+j.x*G]:[N-j.y*G,T,R+j.x*G]}return{stations:b,map:k}}var an=new WeakMap;function hn(t,s,f){let a=JSON.stringify([t.plane,s,f,t.guide]),u=an.get(t);if(u?.key===a)return u.surface;let p=Li(t,s,f);return an.set(t,{key:a,surface:p}),p}var ke=Ve(Xe(),1);var pn=t=>Math.cos(t.tilt*Math.PI/180)>1-1e-8,Tt=t=>t.flexible?.plane==="XY"&&t.flexible.guide.closed&&pn(t)&&!t.mount,At=t=>!t.flexible&&!t.mount&&pn(t);function Lt(t,s){if(!t||typeof t.base!="string"||!t.base||!Number.isInteger(t.count)||t.count<2||t.count>32||!Number.isFinite(t.tab)||t.tab<.3||!Number.isFinite(t.clearance)||t.clearance<.02||t.clearance>3||!Number.isFinite(t.scale)||t.scale<10||t.scale>120||!Number.isFinite(t.phase)||t.phase<=0||t.phase>=100)throw Error("Confira a quantidade, a largura, a folga, a fase e a escala da cinta.");let f=s/t.count,a=f*t.phase/100;if(t.tab+2*t.clearance>=f||a<=t.tab/2+t.clearance||f-a<=t.tab/2+t.clearance)throw Error("A lingueta alcan\xE7a a costura ou o encaixe vizinho. Reduza sua largura ou ajuste a fase.")}function dn(t){for(let s of t){let f=s.panel,a=f.bandJoint;if(!a)continue;let u=t.find(S=>S.panel.key===a.base);if(!u||!At(u.panel)||!Tt(f)||!f.flexible)throw Error("Confira o fundo e a cinta do encaixe.");Lt(a,f.width);let p=u.panel,d=p.thickness,g=f.height/2;s.pose.o[2]=u.pose.o[2]+d+g;let c=s.subs[0],b=c.nodes,w=f.width/2,k=b.findIndex((S,L)=>{let O=b[(L+1)%b.length];return!S.cout&&!O.cin&&Math.abs(S.y-g)<.001&&Math.abs(O.y-g)<.001&&Math.abs(Math.min(S.x,O.x)+w)<.001&&Math.abs(Math.max(S.x,O.x)-w)<.001});if(k<0)throw Error("A cinta precisa ter uma borda inferior reta de ponta a ponta no contorno desenvolvido.");let M=hn(f.flexible,f.width,f.thickness),T=[],C=f.width/a.count,P=(S,L)=>{let O=s.pose.o[0]-u.pose.o[0]+s.pose.u[0]*S+s.pose.v[0]*L,V=s.pose.o[1]-u.pose.o[1]+s.pose.u[1]*S+s.pose.v[1]*L;return{x:vt([O,V,0],u.pose.u),y:vt([O,V,0],u.pose.v)}},v=S=>{let L=S.map(O=>({X:Math.round(O.x*Z),Y:Math.round(O.y*Z)}));return ke.default.Clipper.Orientation(L)||L.reverse(),L};for(let S=0;S<a.count;S++){let L=-w+C*(S+a.phase/100),O=L-a.tab/2,V=L+a.tab/2;T.push({x:O,y:g},{x:O,y:g+d},{x:V,y:g+d},{x:V,y:g});let j=[O,...M.stations.filter(W=>W>O&&W<V),V],U=[...j];for(let W=O+.5;W<V;W+=.5)U.push(W);U.sort((W,$)=>W-$);let N=(W,$)=>{let[z,D]=M.map(W,0,$);return P(z,D)},R=[v([...U.map(W=>N(W,0)),...U.reverse().map(W=>N(W,f.thickness))])];for(let W=1;W<j.length;W++){let $=j[W-1],z=j[W],D=($+z)/2,K=f.thickness/2,ee=M.map($,0,K),re=M.map(z,0,K),ve=M.map(D,0,K),et=M.map(D,0,K+1),Be=re[0]-ee[0],Re=re[1]-ee[1],je=Math.hypot(Be,Re);if(je<1e-8)continue;let de=-Re*(et[0]-ve[0])+Be*(et[1]-ve[1])<0?-1:1,Le=-Re*K*de/je,_e=Be*K*de/je;R.push(v([P(ee[0]+Le,ee[1]+_e),P(re[0]+Le,re[1]+_e),P(re[0]-Le,re[1]-_e),P(ee[0]-Le,ee[1]-_e)]))}let G=lt(ke.default.ClipType.ctUnion,R,[],ke.default.PolyFillType.pftNonZero),H=new ke.default.ClipperOffset(2,.015*Z),q=[];if(H.AddPaths(G,ke.default.JoinType.jtRound,ke.default.EndType.etClosedPolygon),H.Execute(q,a.clearance*Z),q.length!==1||q[0].length<3)throw Error("A curvatura desta lingueta exige uma largura menor ou outra fase.");ke.default.Clipper.Orientation(q[0])&&q[0].reverse(),u.subs.push({closed:!0,nodes:q[0].map(W=>({x:W.X/Z,y:W.Y/Z}))})}b[(k+1)%b.length].x<b[k].x&&T.reverse(),c.nodes.splice(k+1,0,...T)}}oe();oe();var _i=(t,s)=>Math.hypot(s.x-t.x,s.y-t.y),ze=t=>({x:t.x,y:t.y}),mn=()=>Error(ye({"pt-BR":"A curva fecha demais para esta profundidade. Reduza a profundidade do dente ou aumente o raio da curva.",en:"The bend is too tight for this tooth depth. Reduce the depth or increase the radius.",de:"Der Radius ist f\xFCr diese Zinkentiefe zu klein. Tiefe verringern oder Radius vergr\xF6\xDFern."}));function yn(t,s){let f=[],a=be({closed:!1,nodes:[t,s]},le,f),u=[0];for(let g=1;g<a.length;g++)u.push(u[g-1]+Math.hypot(a[g].X-a[g-1].X,a[g].Y-a[g-1].Y)/Z);let p=u.at(-1);return{parameters:f,length:p,parameter:g=>{if(g<=0)return 0;if(g>=p)return 1;let c=0,b=u.length-1;for(;b-c>1;){let w=c+b>>1;u[w]<=g?c=w:b=w}return f[c]+(f[b]-f[c])*(g-u[c])/(u[b]-u[c])}}}function ft(t,s){return t.cout||s.cin?yn(t,s).length:_i(t,s)}function ht(t,s,f,a){let u=t.cout??t,p=s.cin??s,d={a:t,c1:u,c2:p,b:s,curve:!0},g=yn(t,s),c=f.depth*a*(f.side==="inside"?1:-1),b=g.length-f.start-f.end,w=P=>{let v=fe(t,u,p,s,P),S=Math.min(1-1e-8,Math.max(1e-8,P)),L=1-S,O=3*(L*L*(u.x-t.x)+2*L*S*(p.x-u.x)+S*S*(s.x-p.x)),V=3*(L*L*(u.y-t.y)+2*L*S*(p.y-u.y)+S*S*(s.y-p.y)),j=Math.hypot(O,V);if(j<1e-12)throw mn();let U=6*(L*(p.x-2*u.x+t.x)+S*(s.x-2*p.x+u.x)),N=6*(L*(p.y-2*u.y+t.y)+S*(s.y-2*p.y+u.y));if(1-c*(O*N-V*U)/j**3<=1e-7)throw mn();return{x:v.x-c*V/j,y:v.y+c*O/j}},k=[ze(t)],M=0;function T(P){if(P<=M)return;let v=Se(d,M,P);k.at(-1).cout=ze(v.c1),k.push({...ze(v.b),cin:ze(v.c2)})}let C=2*f.count+1;for(let P=f.phase==="middle"?1:0;P<C;P+=2){let v=g.parameter(f.start+b*P/C),S=g.parameter(f.start+b*(P+1)/C);T(v),k.push(w(v));for(let L of g.parameters)L>v+1e-8&&L<S-1e-8&&k.push(w(L));k.push(w(S),ze(fe(t,u,p,s,S))),M=S}return T(1),k}var _t=(t,s,f)=>ye({"pt-BR":t,en:s,de:f});function gn(t,s){let f=t.nodes.length,a=t.nodes[s.edge],u=t.nodes[(s.edge+1)%f];if(!t.closed||f<2||!a||!u)throw Error(_t("Selecione uma borda de um perfil fechado.","Select an edge of a closed profile.","Eine Kante eines geschlossenen Profils w\xE4hlen."));let p=ft(a,u),d=p-s.start-s.end;if(![s.depth,s.start,s.end,d].every(Number.isFinite)||s.start<0||s.end<0||d<=0||s.depth<=0||!Number.isInteger(s.count)||s.count<1||s.count>80)throw Error(_t("Confira profundidade, intervalo e n\xFAmero de dentes.","Check the depth, interval and tooth count.","Tiefe, Intervall und Zinkenanzahl pr\xFCfen."));if(a.cout||u.cin){let P=ht(a,u,s,Math.sign(ce(t).area)),v=structuredClone(t.nodes);v[s.edge].cout=P[0].cout,v[(s.edge+1)%f].cin=P.at(-1).cin,v.splice(s.edge+1,0,...P.slice(1,-1));let S={...t,nodes:v};try{Ce([ce(S)])}catch{throw Error(_t("Os dentes cruzam o contorno. Reduza a profundidade ou aumente o recuo.","The teeth cross the outline. Reduce the depth or increase the margin.","Die Zinken schneiden den Umriss. Tiefe reduzieren oder Abstand erh\xF6hen."))}return S}let c=(t.nodes.reduce((P,v,S)=>{let L=t.nodes[(S+1)%f];return P+v.x*L.y-v.y*L.x},0)<0?-1:1)*(s.side==="inside"?1:-1),b=(u.x-a.x)/p,w=(u.y-a.y)/p,k=(P,v=0)=>({x:a.x+P*b-v*w*c,y:a.y+P*w+v*b*c}),M=[],T=2*s.count+1;for(let P=s.phase==="middle"?1:0;P<T;P+=2){let v=s.start+P*d/T,S=s.start+(P+1)*d/T;v>1e-8&&M.push(k(v)),M.push(k(v,s.depth),k(S,s.depth)),S<p-1e-8&&M.push(k(S))}let C=structuredClone(t.nodes);C.splice(s.edge+1,0,...M);for(let P=C.length-1;P>=0&&C.length>2;P--){let v=C[(P+C.length-1)%C.length],S=C[P],L=C[(P+1)%C.length];if(v.cout||S.cin||S.cout||L.cin)continue;let O=(S.x-v.x)*(L.y-S.y)-(S.y-v.y)*(L.x-S.x);Math.abs(O)<=1e-8&&C.splice(P,1)}return{nodes:C,closed:!0}}oe();var Ke=(t,s,f)=>ye({"pt-BR":t,en:s,de:f}),He=()=>Error(Ke("Escolha uma borda no contorno externo de cada pe\xE7a.","Choose an outer edge on each part.","An jedem Teil eine Au\xDFenkante w\xE4hlen.")),Ei=()=>Error(Ke("Esta borda j\xE1 tem um par. Edite o encaixe existente ou remova-o antes de escolher outro.","This edge already has a mate. Edit or remove that joint first.","Diese Kante ist bereits verbunden. Zuerst die Verbindung bearbeiten oder entfernen."));var Oi=1e-7;function Ni(t){if(!t.profile.length||t.mount||t.bandJoint)return;let s=xe(t.profile,d=>({x:d.x*t.width,y:d.y*t.height})),f=s.map(d=>ce(d)),a=f.reduce((d,g,c)=>Math.abs(g.area)>Math.abs(f[d].area)?c:d,0),u=s[a],p=[];return u.nodes.forEach((d,g)=>{let c=u.nodes[(g+1)%u.nodes.length],b=ft(d,c);b>Oi&&p.push({index:g,a:d,b:c,length:b,curved:!!(d.cout||c.cin)})}),{outer:a,edges:p,winding:Math.sign(f[a].area)}}function bn(t){let s=new Map(t.map(g=>[g.key,g])),f=new Map,a=new Map,u=new Set(t.flatMap(g=>Object.values(g.studioBox?.roles??{})));function p(g,c){let b=s.get(g);if(!b||!Number.isInteger(c))throw He();if(u.has(g))throw Error(Ke("Esta parede pertence a uma caixa param\xE9trica. Escolha uma parede livre.","This wall belongs to a parametric box. Choose a free wall.","Diese Wand geh\xF6rt zu einer parametrischen Box. Eine freie Wand w\xE4hlen."));let w=f.get(g)??Ni(b),k=w?.edges.find(M=>M.index===c);if(!w||!k)throw He();return f.set(g,w),{p:b,edge:k}}function d(g,c){let b=a.get(g)??new Map;if(b.has(c.edge.index))throw Ei();b.set(c.edge.index,c),a.set(g,b)}for(let g of t)if(g.edgePairs!==void 0){if(!Array.isArray(g.edgePairs)||g.edgePairs.length>g.profile.reduce((c,b)=>c+b.nodes.length,0))throw He();for(let c of g.edgePairs){if(!c||c.aKey!==g.key||c.bKey===g.key)throw He();if(!Number.isInteger(c.count)||c.count<1||c.count>80)throw Error(Ke("Escolha de 1 a 80 dentes inteiros.","Choose 1 to 80 whole teeth.","Eine ganze Anzahl von 1 bis 80 Zinken w\xE4hlen."));let b=p(c.aKey,c.aEdge),w=p(c.bKey,c.bEdge),k=Math.min(b.edge.length,w.edge.length);d(b.p.key,{edge:b.edge,depth:w.p.thickness,span:k,count:c.count,tabs:!0}),d(w.p.key,{edge:w.edge,depth:b.p.thickness,span:k,count:c.count,tabs:!1})}}return{spec:a,outlines:f}}function Pn(t){t.some(s=>s.edgePairs!==void 0)&&bn(t)}function xn(t){if(!t.some(({panel:a})=>a.edgePairs!==void 0))return new Set;let{spec:s,outlines:f}=bn(t.map(({panel:a})=>a));for(let{panel:a,subs:u}of t){let p=s.get(a.key);if(!p)continue;let{outer:d,winding:g}=f.get(a.key),c=u[d],b=ce(c),w=u.map((C,P)=>P!==d&&he(b,C.nodes[0])),k=structuredClone(c.nodes),M=k.map(()=>[]);for(let[C,P]of p){let v=k[C],S=k[(C+1)%k.length],{edge:L,depth:O,span:V,count:j,tabs:U}=P,{a:N,b:R,length:G}=L,H=(G-V)/2;if(L.curved){let D=ht(N,R,{edge:C,count:j,depth:O,start:H,end:H,phase:"middle",side:U?"outside":"inside"},g);v.cout=D[0].cout,S.cin=D.at(-1).cin,M[C]=D.slice(1,-1);continue}let q={closed:!0,nodes:[{x:0,y:0},{x:G,y:0},{x:G,y:O+1},{x:0,y:O+1}]},W=gn(q,{edge:0,start:H,end:H,count:j,depth:O,phase:"middle",side:U?"outside":"inside"}),$=(R.x-N.x)/G,z=(R.y-N.y)/G;M[C]=W.nodes.filter(D=>D.x>0&&D.x<G).map(D=>({x:N.x+$*D.x-z*g*D.y,y:N.y+z*D.x+$*g*D.y}))}let T=k.flatMap((C,P)=>[C,...M[P]]);u[d]={...c,nodes:T};try{let C={work:0},P=u.map(v=>ce(v,void 0,C));if(Ce(P,C),P.some((v,S)=>S!==d&&w[S]!==he(P[d],u[S].nodes[0])))throw He()}catch{throw Error(a.name+" \xB7 "+Ke("Os dentes atingem outro recorte ou ultrapassam a parede. Escolha outra borda ou ajuste a espessura.","The teeth cross another cut or the wall boundary. Choose another edge or adjust the thickness.","Die Zinken treffen einen Ausschnitt oder den Rand. Andere Kante w\xE4hlen oder Dicke anpassen."))}}return new Set(s.keys())}var Pe=Ve(Xe(),1);oe();var vn=(t,s)=>({closed:!1,nodes:[t,s]}),Xi=(t,s,f,a)=>({closed:!0,nodes:[{x:t,y:s},{x:t+f,y:s},{x:t+f,y:s+a},{x:t,y:s+a}]}),wn=(t,s)=>Math.hypot(s.x-t.x,s.y-t.y);function Di(t,s,f){if(t.length<2||!(s>0&&f>0))throw Error("Confira os destinos, o tra\xE7o e o intervalo.");let a=[],u=0;for(let p=1;p<t.length;p++){let d=t[p-1],g=t[p],c=wn(d,g),b=0,w=k=>({x:d.x+(g.x-d.x)*k/c,y:d.y+(g.y-d.y)*k/c});for(;b<c-1e-8;){let k=u<s,M=Math.min(c-b,(k?s:s+f)-u);if(k&&M>1e-8&&a.push(vn(w(b),w(b+M))),b+=M,u+=M,u>=s+f-1e-8?u=0:Math.abs(u-s)<1e-8&&(u=s),a.length>4e3)throw Error("Use tra\xE7os mais longos para esta rota.")}}return a}function qe(t,s,f){if(!t.length||!s.length)return f?[]:t;let a=new Pe.default.Clipper,u=new Pe.default.PolyTree;for(let p of t){let d=be(p,le);d.length<2||(p.closed&&d.push(d[0]),a.AddPath(d,Pe.default.PolyType.ptSubject,!1))}return a.AddPaths(s.map(p=>be(p,le)),Pe.default.PolyType.ptClip,!0),a.Execute(f?Pe.default.ClipType.ctIntersection:Pe.default.ClipType.ctDifference,u,Pe.default.PolyFillType.pftEvenOdd,Pe.default.PolyFillType.pftEvenOdd),Pe.default.Clipper.OpenPathsFromPolyTree(u).filter(p=>p.length>=2).map(p=>({closed:!1,nodes:p.map(d=>({x:d.X/Z,y:d.Y/Z}))}))}function Fi(t,s,f){let a=f*Math.PI/180,u=Math.cos(a),p=Math.sin(a),d=t.flatMap(T=>be(T,le)).map(T=>({x:(T.X*u+T.Y*p)/Z,y:(-T.X*p+T.Y*u)/Z})),g=Math.min(...d.map(T=>T.y)),c=Math.max(...d.map(T=>T.y)),b=Math.min(...d.map(T=>T.x))-2,w=Math.max(...d.map(T=>T.x))+2;if(!(s>=.05)||!Number.isFinite(f)||(c-g)/s>3e3)throw Error("O passo da hachura precisa produzir entre 1 e 3.000 linhas.");let k=(T,C)=>({x:T*u-C*p,y:T*p+C*u}),M=[];for(let T=Math.ceil(g/s);T*s<=c;T++)M.push(vn(k(b,T*s),k(w,T*s)));return qe(M,t,!0)}function Yi(t,s){if(t.kind==="hatch")return Fi(s,t.pitch,t.angle);let f=t.kind==="route"?Di(t.points,t.dash,t.gap):t.paths,a=xe(f,u=>({x:u.x+t.x,y:u.y+t.y}));return t.kind==="borders"?a.flatMap(u=>qe([u],s,!1).length?qe([u],s,!0):[u]):a}function Sn(t,s,f=!1){let a=t.faceDesign;return a?a.items.map(u=>{let p=Yi(u,s);if(u.kind!=="hatch"&&u.kind!=="borders"&&qe(p,s,!1).some(d=>d.nodes.some((g,c)=>c>0&&wn(d.nodes[c-1],g)>.003)))throw Error(u.name+" \xB7 "+ye({de:"Gravur au\xDFerhalb der Platte oder \xFCber einem Ausschnitt.",en:"Engraving crosses the edge or a cutout.","pt-BR":"A arte cruza a borda da placa ou um recorte."}));if(a.reserve){let d=a.reserve;p=qe(p,[Xi(d.x,d.y,d.w,d.h)],!1)}return f&&a.side==="back"&&(p=xe(p,d=>({x:-d.x,y:d.y}))),{id:u.id,name:u.name,op:u.op,paths:p,side:a.side}}):[]}var Bi="free-assembly",Nt=()=>[{closed:!0,nodes:[{x:-.5,y:-.5},{x:.5,y:-.5},{x:.5,y:.5},{x:-.5,y:.5}]}];function Ri(t){return{key:t,name:_("Platte {n}",{n:t.slice(1)}),material:"MDF",thickness:3,width:80,height:60,profile:Nt(),position:[0,0,0],tilt:0,turn:0}}function xe(t,s){return t.map(f=>({closed:f.closed,nodes:f.nodes.map(a=>({...s(a),...a.cin&&{cin:s(a.cin)},...a.cout&&{cout:s(a.cout)}}))}))}function ji(t){let s=xe(t.profile,a=>({x:a.x*t.width,y:a.y*t.height})),f=t.hole;return f&&s.push(...xe(Nt(),a=>({x:f.x-a.x*f.width,y:f.y+a.y*f.height}))),s}function Ot(t){let s=t.tilt*Math.PI/180,f=t.turn*Math.PI/180,a=[Math.cos(f),Math.sin(f),0],u=[Math.sin(f)*Math.cos(s),-Math.cos(f)*Math.cos(s),-Math.sin(s)];return{o:[...t.position],u:a,v:u,n:Gt(u,a)}}function Wi(t,s,f=Ot(t),a=Ot(s)){let u=t.tilt*Math.PI/180,p=t.turn*Math.PI/180,d=t.height/2,g=[t.position[0]-Math.sin(p)*Math.cos(u)*d,t.position[1]+Math.cos(p)*Math.cos(u)*d,s.thickness+Math.sin(u)*d];return Ut({...f,o:g},[a.u,a.v.map(c=>-c),a.n],a.o)}function Et(t){let s=t.map(a=>({panel:a,subs:ji(a),slits:[],pose:Ot(a)}));for(let a of s){let u=a.panel,p=u.mount;if(!p)continue;let d=s.find(L=>L.panel.key===p.base);if(!d||d.panel.mount||!(p.tab>0&&p.tab<u.width)||u.tilt<10||u.tilt>90)throw Error("invalid-panels");let g=u.tilt*Math.PI/180,c=Math.sin(g),b=Math.cos(g),w=d.panel.thickness/c,k=(u.thickness+d.panel.thickness*b)/c,M=u.width/2,T=u.height/2,C=p.tab/2;a.subs[0]={closed:!0,nodes:[{x:-M,y:-T},{x:M,y:-T},{x:M,y:T},{x:C,y:T},{x:C,y:T+w},{x:-C,y:T+w},{x:-C,y:T},{x:-M,y:T}]};let P=u.turn*Math.PI/180,v=Math.cos(P),S=Math.sin(P);a.pose=Wi(u,d.panel,a.pose,d.pose),d.subs.push(...xe(Nt(),L=>{let O=p.allowance??0;if(!Number.isFinite(O)||O<=-Math.min(k,p.tab)||Math.abs(O)>Math.min(u.thickness,d.panel.thickness)/2)throw Error(_("Lokales Steckspiel pr\xFCfen."));let V=-L.x*(p.tab+O),j=-(L.y+.5)*k-L.y*O;return{x:u.position[0]+v*V-S*j,y:-(u.position[1]+S*V+v*j)}}))}dn(s);let f=xn(s);for(let{panel:a,subs:u}of s){let p=a.profile.length+(a.hole?1:0),d=$t(a),g=a.flexible?.hole;if(g&&d.push({id:"c0",name:_("Rundbohrung"),kind:"round",values:{...g}}),!d.length&&u.length===p)continue;let c=u.map(()=>a.name),b=u.length;for(let C of d){let P=qt(C,a.width,a.height);if(u.length+P.length>256)throw Error(_("Pro Platte sind h\xF6chstens 256 Konturen m\xF6glich."));u.push(...P),c.push(...P.map(()=>C.name))}let w={work:0},k=u.map(C=>ce(C,void 0,w)),M=k.reduce((C,P,v)=>Math.abs(P.area)>Math.abs(k[C].area)?v:C,0),T=C=>Error(_("\u201E{name}\u201C: Abstand zum Plattenrand, zu Ausschnitten und Steckverbindungen pr\xFCfen.",{name:c[C]??a.name}));if(M>=b)throw T(M);try{Ce(k,w)}catch(C){let P=C.details?.contours;throw T(P?.find(v=>v>=b)??b)}if(!d.length){for(let C=p;C<k.length;C++){let P=u[C].nodes[0];if(k.slice(0,p).filter(S=>he(S,P)).length%2!==1||k.some((S,L)=>L!==C&&(he(k[C],u[L].nodes[0])||L>=p&&he(S,P))))throw T(C)}continue}for(let C=0;C<k.length;C++){if(C===M)continue;let P=u[C].nodes[0];if(!he(k[M],P)||k.some((v,S)=>S!==M&&S!==C&&he(v,P))||C>=b&&a.mount&&k[C].box.y1>=a.height/2)throw T(C)}}for(let a of s){let{panel:u,subs:p}=a;nn(u,p),f.has(u.key)&&u.faceDesign&&Sn(u,p),a.slits=fn(u.flexible?.pattern??u.flatPattern,p,u.width,u.height)}return s}var $e=t=>typeof t=="number"&&Number.isFinite(t)&&t>0&&t<=1e4,Me=t=>typeof t=="number"&&Number.isFinite(t)&&Math.abs(t)<=1e5,pt=t=>!!t&&Me(t.x)&&Me(t.y);function dt(t){if(typeof t.panels!="string"||t.panels.length>2e5)throw Error("invalid-panels");let s=JSON.parse(t.panels);if(!Array.isArray(s)||!s.length||s.length>100)throw Error("invalid-panels");let f=new Set;for(let a of s){if(!a||!/^p[0-9]{1,9}$/.test(a.key)||f.has(a.key)||typeof a.name!="string"||!a.name.trim()||a.name.length>100||a.assemblyGroup!==void 0&&(typeof a.assemblyGroup!="string"||!a.assemblyGroup.trim()||a.assemblyGroup.length>80)||a.locked!==void 0&&typeof a.locked!="boolean"||typeof a.material!="string"||!a.material.trim()||a.material.length>100||![a.width,a.height,a.thickness].every($e)||a.nominalThickness!==void 0&&!$e(a.nominalThickness)||!Array.isArray(a.position)||a.position.length!==3||!a.position.every(Me)||!Me(a.tilt)||!Me(a.turn)||!Array.isArray(a.profile)||!a.profile.length||!a.profile.every(p=>p&&p.closed===!0&&Array.isArray(p.nodes)&&p.nodes.length>=2&&p.nodes.every(d=>pt(d)&&(!d.cin||pt(d.cin))&&(!d.cout||pt(d.cout))))||a.hole&&(!$e(a.hole.width)||!$e(a.hole.height)||!Me(a.hole.x)||!Me(a.hole.y)||Math.abs(a.hole.x)+a.hole.width/2>=a.width/2||Math.abs(a.hole.y)+a.hole.height/2>=a.height/2)||(a.photoEngraving!==void 0&&en(a.photoEngraving),a.manualDraft&&(!pt(a.manualDraft.center)||a.manualDraft.holeKey!==void 0&&!/^c[0-9]{1,9}$/.test(a.manualDraft.holeKey))))throw Error("invalid-panels");let u=a.manualDraft?.support;if(u&&(!/^p[0-9]{1,9}$/.test(u.part)||![0,1,2].includes(u.axis)||![1,-1].includes(u.sign)||!Me(u.last)))throw Error("invalid-panels");if(kt(a.photoSource),a.faceDesign!==void 0&&rn(a.faceDesign),a.flexible!==void 0&&cn(a.flexible),a.flatPattern!==void 0&&ct(a.flatPattern),a.cuts!==void 0){if(!Array.isArray(a.cuts)||a.cuts.length>64)throw Error(_("Pro Platte sind h\xF6chstens 64 Schnittoperationen m\xF6glich."));let p=new Set;for(let d of a.cuts){if(Ct(d),p.has(d.id))throw Error(_("Ung\xFCltige Schnittoperation."));p.add(d.id)}}f.add(a.key)}for(let a of s)if(a.mount&&(!f.has(a.mount.base)||a.mount.base===a.key||!$e(a.mount.tab)||a.mount.tab>=a.width||a.tilt<10||a.tilt>90||s.find(u=>u.key===a.mount.base)?.mount))throw Error("invalid-panels");for(let a of s)if(a.bandJoint!==void 0){Lt(a.bandJoint,a.width);let u=s.find(p=>p.key===a.bandJoint.base);if(!Tt(a)||!u||!At(u))throw Error("invalid-panels")}return Pn(s),s}var Cn={id:Bi,version:1,kind:"assembly",icon:"view3d",name:_("Freie Plattenmontage"),schema:[{key:"panels",type:"data",label:"",def:JSON.stringify([{...Ri("p1"),name:"A"}])},{key:"sheetPlan",type:"data",label:"",def:""},{key:"studioWorkshop",type:"data",label:"",def:""}],validate(t){try{return dt(t),[]}catch{return[{level:"error",msg:_("Plattenma\xDFe, Ausschnitte und Profile pr\xFCfen."),code:"invalid-panels"}]}},generate(t){let s=dt(t),f=Math.max(...s.map(c=>c.width),Math.sqrt(s.reduce((c,b)=>c+(b.width+5)*(b.height+5),0))),a=new Set(s.flatMap(c=>(c.edgePairs??[]).flatMap(b=>[b.aKey,b.bKey]))),u=0,p=0,d=0;return{parts:Et(s).map(({panel:c,subs:b,slits:w})=>{let k=-c.width/2,M=c.width/2,T=-c.height/2,C=b[0].nodes.reduce((S,L)=>Math.max(S,L.y),c.height/2);if(a.has(c.key)||c.profile.some(S=>S.nodes.some(L=>Math.abs(L.x)>.5||Math.abs(L.y)>.5))){let S=c.faceDesign?.side==="back";for(let L of b){let{box:O}=ce(L);k=Math.min(k,S?-O.x1:O.x0),M=Math.max(M,S?-O.x0:O.x1),T=Math.min(T,O.y0),C=Math.max(C,O.y1)}}u&&u+M-k>f&&(u=0,p+=d+5,d=0);let P={x:u-k,y:p-T};u+=M-k+5,d=Math.max(d,C-T);let v=S=>c.faceDesign?.side==="back"?xe(S,L=>({x:-L.x,y:L.y})):S;return{key:c.key,at:P,subs:v([...b,...w]),...c.photoEngraving&&{marks:v(tn(c))},stock:{material:c.material,thickness:c.thickness}}}),info:[]}},label(t,s){if(s)try{let f=dt(t).find(a=>a.key===s);if(f)return f.name}catch{}return _("Freie Plattenmontage")},poses(t){let s=Et(dt(t));return{poses:Object.fromEntries(s.map(f=>[f.panel.key,f.pose])),finishes:Object.fromEntries(s.filter(({panel:f})=>f.finish).map(({panel:f})=>[f.key,f.finish])),flexible:Object.fromEntries(s.filter(f=>f.panel.flexible).map(({panel:f})=>[f.key,{spec:f.flexible,width:f.width,flipped:f.faceDesign?.side==="back"}]))}}};mt();var Va={callMs:{validate:1e4,generate:3e4,view:2e3,onChange:2e3,onEvent:1e4,resource:2e4,draw:3e4,onSurface:5e3,open:3e4,close:2e3,apply:3e4,migrate:2e3},askOptions:3,memoryBytes:512*1024*1024,codeBytes:8*1024*1024,outputBytes:32*1024*1024,parts:2e3,nodes:5e5,issues:200,info:40,text:400,range:1e5,items:2e4,points:1e6,tris:2e6,layers:4,sideFields:8,highlight:64,regionCells:4e6,stateBytes:1024*1024,imagePixels:16e6,imageSide:8e3,objects:5e3};oe();function In(t){let s=2166136261;for(let f=0;f<t.length;f++)s^=t.charCodeAt(f),s=Math.imul(s,16777619)>>>0;return"t"+s.toString(16).padStart(8,"0")}An();var Ln=new Map;function En(t,s){if(Ln.has(t))return!0;try{Ln.set(t,{data:s,mesh:Tn(s)})}catch{return!1}return Ji(t,s),!0}var Ui=t=>`mesh:${t}`,_n=null;function Zi(){return _n??(_n=new Promise((t,s)=>{if(typeof indexedDB>"u")return s(new Error("no indexedDB"));let f=indexedDB.open("laserwerk",1);f.onupgradeneeded=()=>f.result.createObjectStore("assets"),f.onsuccess=()=>t(f.result),f.onerror=()=>s(f.error)})),_n}function Ji(t,s){Zi().then(f=>f.transaction("assets","readwrite").objectStore("assets").put(s,Ui(t))).catch(()=>{})}var Xt=t=>({width:t.width,height:t.height,data:Qe(t.data)});function zi(t){let s={};return t.selection&&(s.selection=t.selection),t.image&&(s.image={...Xt(t.image),name:String(t.image.name??"")}),t.camera&&(s.camera={...Xt(t.camera),bed:t.camera.bed,...t.camera.empty?{empty:Xt(t.camera.empty)}:{}}),s}var On=t=>{if(typeof t=="string")return t;let s={code:In(t.de)};return t.values&&(s.values=Object.fromEntries(Object.entries(t.values).map(([f,a])=>[f,typeof a=="number"?a:Dn(a)]))),s},Dn=t=>t.length===1?On(t[0]):t.map(On),ie=t=>Dn(xt(t)),Dt=globalThis;Dt.structuredClone??(Dt.structuredClone=t=>JSON.parse(JSON.stringify(t)));function Nn(t){return!t||t instanceof Promise?null:{...t.patch?{patch:t.patch}:{},...t.message!==void 0?{message:ie(t.message)}:{},...t.state!==void 0?{state:t.state}:{},...t.view!==void 0?{view:t.view}:{},...t.select?{select:t.select}:{}}}var Xn=t=>t.type==="text"?{...t,text:ie(t.text)}:t;function Fn(t){globalThis.plugin={...t.schema.some(s=>s.type==="data"&&s.resource)?{resource(s){if(s.kind==="model3d"&&!En(s.id,s.data))throw new Error("bad-model");return null}}:{},validate(s){return t.validate(s).map(f=>{let a=f.code?{code:f.code}:ie(f.msg),u=typeof a=="object"&&!Array.isArray(a)?a:{code:"plugin-text",values:{text:a}};return{...f.key?{key:f.key}:{},level:f.level,...u}})},generate(s){let f=t.generate(s),a=t.poses?.(s,Number(s.thickness)||3)??null,u={};if(t.kind==="assembly")for(let p of f.parts)u[p.key]=ie(t.label(s,p.key));return{parts:f.parts,info:f.info.map(([p,d])=>[ie(p),ie(d)]),label:ie(t.label(s)),...f.distribute?{distribute:f.distribute}:{},...f.plan?{plan:{title:ie(f.plan.title),lines:f.plan.lines,labels:f.plan.labels.map(p=>({...p,text:ie(p.text)})),steps:f.plan.steps.map(ie)}}:{},...t.kind==="assembly"?{labels:u}:{},...a?{poses:a}:{}}},...t.migrate?{migrate(s){return t.migrate(s.params,s.from)}}:{},...t.view?{view(s){let f=t.view(s);return{...f.autoText?{autoText:Object.fromEntries(Object.entries(f.autoText).map(([a,u])=>[a,ie(u)]))}:{},...f.rows?{rows:Object.fromEntries(Object.entries(f.rows).map(([a,u])=>[a,u.map(ie)]))}:{},...f.rowAuto?{rowAuto:Object.fromEntries(Object.entries(f.rowAuto).map(([a,u])=>[a,u.map(ie)]))}:{}}}}:{},...t.onEvent?{onEvent(s){let f={action:s.action,inputs:zi(s.inputs??{})};return s.row!==void 0&&(f.row=s.row),s.surface&&(f.surface=s.surface),Nn(t.onEvent(f,s.params))}}:{},...t.draw?{draw(s){let{params:f,...a}=s,u=t.draw(a,f);return u instanceof Promise?null:{...u,items:u.items.map(Xn),...u.fields?{fields:u.fields.map(p=>({...p,label:ie(p.label),...p.title?{title:ie(p.title)}:{}}))}:{},...u.layers?{layers:u.layers.map(p=>p.items?{...p,items:p.items.map(Xn)}:p)}:{}}}}:{},...t.onSurface?{onSurface(s){return Nn(t.onSurface(s.event,s.surface,s.params))}}:{},...t.onChange?{onChange(s){let f=t.onChange(s.key,s.old,s.params);return!f||f instanceof Promise?null:{...f.patch?{patch:f.patch}:{},...f.ask?{ask:{question:ie(f.ask.question),options:f.ask.options.map(a=>({label:ie(a.label),patch:a.patch}))}}:{}}}}:{}}}Fn(Cn);})();
