Profectus-Demo/assets/earcut.17d42416.js

2 lines
6.9 KiB
JavaScript
Raw Normal View History

var N=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function m(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function a(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach(function(n){var x=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,x.get?x:{enumerable:!0,get:function(){return e[n]}})}),t}var E={exports:{}};E.exports=P;E.exports.default=P;function P(e,t,n){n=n||2;var x=t&&t.length,r=x?t[0]*n:e.length,u=A(e,0,r,n,!0),f=[];if(!u||u.next===u.prev)return f;var i,l,y,c,h,p,v;if(x&&(u=V(e,t,u,n)),e.length>80*n){i=y=e[0],l=c=e[1];for(var o=n;o<r;o+=n)h=e[o],p=e[o+1],h<i&&(i=h),p<l&&(l=p),h>y&&(y=h),p>c&&(c=p);v=Math.max(y-i,c-l),v=v!==0?1/v:0}return w(u,f,n,i,l,v),f}function A(e,t,n,x,r){var u,f;if(r===k(e,t,n,x)>0)for(u=t;u<n;u+=x)f=z(u,e[u],e[u+1],f);else for(u=n-x;u>=t;u-=x)f=z(u,e[u],e[u+1],f);return f&&T(f,f.next)&&(M(f),f=f.next),f}function g(e,t){if(!e)return e;t||(t=e);var n=e,x;do if(x=!1,!n.steiner&&(T(n,n.next)||s(n.prev,n,n.next)===0)){if(M(n),n=t=n.prev,n===n.next)break;x=!0}else n=n.next;while(x||n!==t);return t}function w(e,t,n,x,r,u,f){if(!!e){!f&&u&&U(e,x,r,u);for(var i=e,l,y;e.prev!==e.next;){if(l=e.prev,y=e.next,u?B(e,x,r,u):D(e)){t.push(l.i/n),t.push(e.i/n),t.push(y.i/n),M(e),e=y.next,i=y.next;continue}if(e=y,e===i){f?f===1?(e=G(g(e),t,n),w(e,t,n,x,r,u,2)):f===2&&R(e,t,n,x,r,u):w(g(e),t,n,x,r,u,1);break}}}}function D(e){var t=e.prev,n=e,x=e.next;if(s(t,n,x)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(Z(t.x,t.y,n.x,n.y,x.x,x.y,r.x,r.y)&&s(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function B(e,t,n,x){var r=e.prev,u=e,f=e.next;if(s(r,u,f)>=0)return!1;for(var i=r.x<u.x?r.x<f.x?r.x:f.x:u.x<f.x?u.x:f.x,l=r.y<u.y?r.y<f.y?r.y:f.y:u.y<f.y?u.y:f.y,y=r.x>u.x?r.x>f.x?r.x:f.x:u.x>f.x?u.x:f.x,c=r.y>u.y?r.y>f.y?r.y:f.y:u.y>f.y?u.y:f.y,h=H(i,l,t,n,x),p=H(y,c,t,n,x),v=e.prevZ,o=e.nextZ;v&&v.z>=h&&o&&o.z<=p;){if(v!==e.prev&&v!==e.next&&Z(r.x,r.y,u.x,u.y,f.x,f.y,v.x,v.y)&&s(v.prev,v,v.next)>=0||(v=v.prevZ,o!==e.prev&&o!==e.next&&Z(r.x,r.y,u.x,u.y,f.x,f.y,o.x,o.y)&&s(o.prev,o,o.next)>=0))return!1;o=o.nextZ}for(;v&&v.z>=h;){if(v!==e.prev&&v!==e.next&&Z(r.x,r.y,u.x,u.y,f.x,f.y,v.x,v.y)&&s(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;o&&o.z<=p;){if(o!==e.prev&&o!==e.next&&Z(r.x,r.y,u.x,u.y,f.x,f.y,o.x,o.y)&&s(o.prev,o,o.next)>=0)return!1;o=o.nextZ}return!0}function G(e,t,n){var x=e;do{var r=x.prev,u=x.next.next;!T(r,u)&&j(r,x,x.next,u)&&F(r,u)&&F(u,r)&&(t.push(r.i/n),t.push(x.i/n),t.push(u.i/n),M(x),M(x.next),x=e=u),x=x.next}while(x!==e);return g(x)}function R(e,t,n,x,r,u){var f=e;do{for(var i=f.next.next;i!==f.prev;){if(f.i!==i.i&&Y(f,i)){var l=C(f,i);f=g(f,f.next),l=g(l,l.next),w(f,t,n,x,r,u),w(l,t,n,x,r,u);return}i=i.next}f=f.next}while(f!==e)}function V(e,t,n,x){var r=[],u,f,i,l,y;for(u=0,f=t.length;u<f;u++)i=t[u]*x,l=u<f-1?t[u+1]*x:e.length,y=A(e,i,l,x,!1),y===y.next&&(y.steiner=!0),r.push(X(y));for(r.sort($),u=0;u<r.length;u++)n=J(r[u],n),n=g(n,n.next);return n}function $(e,t){return e.x-t.x}function J(e,t){var n=K(e,t);if(!n)return t;var x=C(n,e),r=g(n,n.next);return g(x,x.next),t===n?r:t}function K(e,t){var n=t,x=e.x,r=e.y,u=-1/0,f;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){var i=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(i<=x&&i>u){if(u=i,i===x){if(r===n.y)return n;if(r===n.next.y)return n.next}f=n.x<n.next.x?n:n.next}}n=n.next}while(n!==t);if(!f)return null;if(x===u)return f;var l=f,y=f.x,c=f.y,h=1/0,p;n=f;do x>=n.x&&n.x>=y&&x!==n.x&&Z(r<c?x:u,r,y,c,r<c?u:x,r,n.x,n.y)&&(p=Math.abs(r-n.y)/(x-n.x),F(n,e)&&(p<h||p===h&&(n.x>f.x||n.x===f.x&&Q(f,n)))&&(f=n,h=p)),n=n.next;while(n!==l);return f}function Q(e,t){return s(e.prev,e,t.prev)<0&&s(t.next,e,e.next)<0}function U(e,t,n,x){var r=e;do r.z===null&&(r.z=H(r.x,r.y,t,n,x)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,W(r)}function W(e){var t,n,x,r,u,f,i,l,y=1;do{for(n=e,e=null,u=null,f=0;n;){for(f++,x=n,i=0,