@xeokit/xeokit-sdk 2.6.97 → 2.6.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xeokit-sdk.cjs.js +11 -8
- package/dist/xeokit-sdk.es.js +11 -8
- package/dist/xeokit-sdk.es5.js +10 -8
- package/dist/xeokit-sdk.min.cjs.js +5 -5
- package/dist/xeokit-sdk.min.es.js +5 -5
- package/dist/xeokit-sdk.min.es5.js +5 -5
- package/package.json +1 -1
- package/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js +1 -0
- package/src/plugins/GLTFLoaderPlugin/GLTFSceneModelLoader.js +1 -0
- package/src/viewer/scene/Component.js +1 -0
- package/src/viewer/scene/math/math.js +3 -3
- package/src/viewer/scene/model/layer/programs/SnapProgram.js +1 -1
- package/types/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.d.ts +2 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* xeokit-sdk v2.6.
|
|
3
|
-
* Commit:
|
|
4
|
-
* Built: 2025-12-
|
|
2
|
+
* xeokit-sdk v2.6.99
|
|
3
|
+
* Commit: 916f60d2984c01eda311e05589b978ba8b5ad37c
|
|
4
|
+
* Built: 2025-12-09T13:35:43.419Z
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
"undefined"!=typeof window&&(window.__XEOKIT__={version:"2.6.97",commit:"fd8731b8272e4958c8231a6794a98a1874564a08",built:"2025-12-03T17:04:45.022Z"}),Object.defineProperty(exports,"__esModule",{value:!0});class e{constructor(e,t){this.items=e||[],this._lastUniqueId=(t||0)+1}addItem(){let e;if(2===arguments.length){const t=arguments[0];if(e=arguments[1],this.items[t])throw"ID clash: '"+t+"'";return this.items[t]=e,t}for(e=arguments[0]||{};;){const t=this._lastUniqueId++;if(!this.items[t])return this.items[t]=e,t}}removeItem(e){const t=this.items[e];return delete this.items[e],t}}const t=new e;class s{constructor(e){this.id=e,this.parentItem=null,this.groups=[],this.menuElement=null,this.shown=!1,this.mouseOver=0}}class i{constructor(){this.items=[]}}class r{constructor(e,t,s,i,r){this.id=e,this.getTitle=t,this.doAction=s,this.getEnabled=i,this.getShown=r,this.itemElement=null,this.subMenu=null,this.enabled=!0}}function n(e,t,s=2){const i=t&&t.length,r=i?t[0]*s:e.length;let n=A(e,0,r,s,!0);const o=[];if(!n||n.next===n.prev)return o;let l,c,h;if(i&&(n=function(e,t,s,i){const r=[];for(let s=0,n=t.length;s<n;s++){const o=A(e,t[s]*i,s<n-1?t[s+1]*i:e.length,i,!1);o===o.next&&(o.steiner=!0),r.push(m(o))}r.sort(d);for(let e=0;e<r.length;e++)s=p(r[e],s);return s}(e,t,n,s)),e.length>80*s){l=1/0,c=1/0;let t=-1/0,i=-1/0;for(let n=s;n<r;n+=s){const s=e[n],r=e[n+1];s<l&&(l=s),r<c&&(c=r),s>t&&(t=s),r>i&&(i=r)}h=Math.max(t-l,i-c),h=0!==h?32767/h:0}return a(n,o,s,l,c,h,0),o}function A(e,t,s,i,r){let n;if(r===function(e,t,s,i){let r=0;for(let n=t,A=s-i;n<s;n+=i)r+=(e[A]-e[n])*(e[n+1]+e[A+1]),A=n;return r}(e,t,s,i)>0)for(let r=t;r<s;r+=i)n=x(r/i|0,e[r],e[r+1],n);else for(let r=s-i;r>=t;r-=i)n=x(r/i|0,e[r],e[r+1],n);return n&&w(n,n.next)&&(U(n),n=n.next),n}function o(e,t){if(!e)return e;t||(t=e);let s,i=e;do{if(s=!1,i.steiner||!w(i,i.next)&&0!==y(i.prev,i,i.next))i=i.next;else{if(U(i),i=t=i.prev,i===i.next)break;s=!0}}while(s||i!==t);return t}function a(e,t,s,i,r,n,A){if(!e)return;!A&&n&&function(e,t,s,i){let r=e;do{0===r.z&&(r.z=g(r.x,r.y,t,s,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,s=1;do{let i,r=e;e=null;let n=null;for(t=0;r;){t++;let A=r,o=0;for(let e=0;e<s&&(o++,A=A.nextZ,A);e++);let a=s;for(;o>0||a>0&&A;)0!==o&&(0===a||!A||r.z<=A.z)?(i=r,r=r.nextZ,o--):(i=A,A=A.nextZ,a--),n?n.nextZ=i:e=i,i.prevZ=n,n=i;r=A}n.nextZ=null,s*=2}while(t>1)}(r)}(e,i,r,n);let d=e;for(;e.prev!==e.next;){const p=e.prev,f=e.next;if(n?c(e,i,r,n):l(e))t.push(p.i,e.i,f.i),U(e),e=f.next,d=f.next;else if((e=f)===d){A?1===A?a(e=h(o(e),t),t,s,i,r,n,2):2===A&&u(e,t,s,i,r,n):a(o(e),t,s,i,r,n,1);break}}}function l(e){const t=e.prev,s=e,i=e.next;if(y(t,s,i)>=0)return!1;const r=t.x,n=s.x,A=i.x,o=t.y,a=s.y,l=i.y,c=Math.min(r,n,A),h=Math.min(o,a,l),u=Math.max(r,n,A),d=Math.max(o,a,l);let p=i.next;for(;p!==t;){if(p.x>=c&&p.x<=u&&p.y>=h&&p.y<=d&&b(r,o,n,a,A,l,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function c(e,t,s,i){const r=e.prev,n=e,A=e.next;if(y(r,n,A)>=0)return!1;const o=r.x,a=n.x,l=A.x,c=r.y,h=n.y,u=A.y,d=Math.min(o,a,l),p=Math.min(c,h,u),f=Math.max(o,a,l),m=Math.max(c,h,u),_=g(d,p,t,s,i),B=g(f,m,t,s,i);let w=e.prevZ,v=e.nextZ;for(;w&&w.z>=_&&v&&v.z<=B;){if(w.x>=d&&w.x<=f&&w.y>=p&&w.y<=m&&w!==r&&w!==A&&b(o,c,a,h,l,u,w.x,w.y)&&y(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,v.x>=d&&v.x<=f&&v.y>=p&&v.y<=m&&v!==r&&v!==A&&b(o,c,a,h,l,u,v.x,v.y)&&y(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;w&&w.z>=_;){if(w.x>=d&&w.x<=f&&w.y>=p&&w.y<=m&&w!==r&&w!==A&&b(o,c,a,h,l,u,w.x,w.y)&&y(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;v&&v.z<=B;){if(v.x>=d&&v.x<=f&&v.y>=p&&v.y<=m&&v!==r&&v!==A&&b(o,c,a,h,l,u,v.x,v.y)&&y(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function h(e,t){let s=e;do{const i=s.prev,r=s.next.next;!w(i,r)&&v(i,s,s.next,r)&&E(i,r)&&E(r,i)&&(t.push(i.i,s.i,r.i),U(s),U(s.next),s=e=r),s=s.next}while(s!==e);return o(s)}function u(e,t,s,i,r,n){let A=e;do{let e=A.next.next;for(;e!==A.prev;){if(A.i!==e.i&&B(A,e)){let l=F(A,e);return A=o(A,A.next),l=o(l,l.next),a(A,t,s,i,r,n,0),void a(l,t,s,i,r,n,0)}e=e.next}A=A.next}while(A!==e)}function d(e,t){let s=e.x-t.x;if(0===s&&(s=e.y-t.y,0===s)){s=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return s}function p(e,t){const s=function(e,t){let s=t;const i=e.x,r=e.y;let n,A=-1/0;if(w(e,s))return s;do{if(w(e,s.next))return s.next;if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){const e=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(e<=i&&e>A&&(A=e,n=s.x<s.next.x?s:s.next,e===i))return n}s=s.next}while(s!==t);if(!n)return null;const o=n,a=n.x,l=n.y;let c=1/0;s=n;do{if(i>=s.x&&s.x>=a&&i!==s.x&&_(r<l?i:A,r,a,l,r<l?A:i,r,s.x,s.y)){const t=Math.abs(r-s.y)/(i-s.x);E(s,e)&&(t<c||t===c&&(s.x>n.x||s.x===n.x&&f(n,s)))&&(n=s,c=t)}s=s.next}while(s!==o);return n}(e,t);if(!s)return t;const i=F(s,e);return o(i,i.next),o(s,s.next)}function f(e,t){return y(e.prev,e,t.prev)<0&&y(t.next,e,e.next)<0}function g(e,t,s,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function m(e){let t=e,s=e;do{(t.x<s.x||t.x===s.x&&t.y<s.y)&&(s=t),t=t.next}while(t!==e);return s}function _(e,t,s,i,r,n,A,o){return(r-A)*(t-o)>=(e-A)*(n-o)&&(e-A)*(i-o)>=(s-A)*(t-o)&&(s-A)*(n-o)>=(r-A)*(i-o)}function b(e,t,s,i,r,n,A,o){return!(e===A&&t===o)&&_(e,t,s,i,r,n,A,o)}function B(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let s=e;do{if(s.i!==e.i&&s.next.i!==e.i&&s.i!==t.i&&s.next.i!==t.i&&v(s,s.next,e,t))return!0;s=s.next}while(s!==e);return!1}(e,t)&&(E(e,t)&&E(t,e)&&function(e,t){let s=e,i=!1;const r=(e.x+t.x)/2,n=(e.y+t.y)/2;do{s.y>n!=s.next.y>n&&s.next.y!==s.y&&r<(s.next.x-s.x)*(n-s.y)/(s.next.y-s.y)+s.x&&(i=!i),s=s.next}while(s!==e);return i}(e,t)&&(y(e.prev,e,t.prev)||y(e,t.prev,t))||w(e,t)&&y(e.prev,e,e.next)>0&&y(t.prev,t,t.next)>0)}function y(e,t,s){return(t.y-e.y)*(s.x-t.x)-(t.x-e.x)*(s.y-t.y)}function w(e,t){return e.x===t.x&&e.y===t.y}function v(e,t,s,i){const r=M(y(e,t,s)),n=M(y(e,t,i)),A=M(y(s,i,e)),o=M(y(s,i,t));return r!==n&&A!==o||(!(0!==r||!C(e,s,t))||(!(0!==n||!C(e,i,t))||(!(0!==A||!C(s,e,i))||!(0!==o||!C(s,t,i)))))}function C(e,t,s){return t.x<=Math.max(e.x,s.x)&&t.x>=Math.min(e.x,s.x)&&t.y<=Math.max(e.y,s.y)&&t.y>=Math.min(e.y,s.y)}function M(e){return e>0?1:e<0?-1:0}function E(e,t){return y(e.prev,e,e.next)<0?y(e,t,e.next)>=0&&y(e,e.prev,t)>=0:y(e,t,e.prev)<0||y(e,e.next,t)<0}function F(e,t){const s=I(e.i,e.x,e.y),i=I(t.i,t.x,t.y),r=e.next,n=t.prev;return e.next=t,t.prev=e,s.next=r,r.prev=s,i.next=s,s.prev=i,n.next=i,i.prev=n,i}function x(e,t,s,i){const r=I(e,t,s);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function U(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function I(e,t,s){return{i:e,x:t,y:s,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}let T=!0,P=T?Float64Array:Float32Array;const S=new P(3),D=new P(16),k=new P(16),Q=new P(4),R={setDoublePrecisionEnabled(e){T=e,P=T?Float64Array:Float32Array},getDoublePrecisionEnabled:()=>T,MIN_DOUBLE:-Number.MAX_SAFE_INTEGER,MAX_DOUBLE:Number.MAX_SAFE_INTEGER,MAX_INT:1e7,DEGTORAD:.0174532925,RADTODEG:57.295779513,unglobalizeObjectId(e,t){const s=t.indexOf("#");return s===e.length&&t.startsWith(e)?t.substring(s+1):t},globalizeObjectId:(e,t)=>e+"#"+t,safeInv(e){const t=1/e;return isNaN(t)||!isFinite(t)?1:t},vec2:e=>new P(e||2),vec3:e=>new P(e||3),vec4:e=>new P(e||4),mat3:e=>new P(e||9),mat3ToMat4:(e,t=new P(16))=>(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=0,t[4]=e[3],t[5]=e[4],t[6]=e[5],t[7]=0,t[8]=e[6],t[9]=e[7],t[10]=e[8],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t),mat4:e=>new P(e||16),mat4ToMat3:(e,t=new P(9))=>(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t),doublesToFloats(e,t,s){const i=new P(2);for(let r=0,n=e.length;r<n;r++)R.splitDouble(e[r],i),t[r]=i[0],s[r]=i[1]},splitDouble(e,t){const s=P.from([e])[0],i=e-s;t[0]=s,t[1]=i},createUUID:(()=>{const e=[];for(let t=0;t<256;t++)e[t]=(t<16?"0":"")+t.toString(16);return()=>{const t=4294967295*Math.random()|0,s=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return`${e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]}-${e[255&s]}${e[s>>8&255]}-${e[s>>16&15|64]}${e[s>>24&255]}-${e[63&i|128]}${e[i>>8&255]}-${e[i>>16&255]}${e[i>>24&255]}${e[255&r]}${e[r>>8&255]}${e[r>>16&255]}${e[r>>24&255]}`}})(),clamp:(e,t,s)=>Math.max(t,Math.min(s,e)),fmod(e,t){if(e<t)return console.error("math.fmod : Attempting to find modulus within negative range - would be infinite loop - ignoring"),e;for(;t<=e;)e-=t;return e},compareVec3:(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2],compareVec4:(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3],negateVec3:(e,t)=>(t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t),negateVec4:(e,t)=>(t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t),addVec4:(e,t,s)=>(s||(s=e),s[0]=e[0]+t[0],s[1]=e[1]+t[1],s[2]=e[2]+t[2],s[3]=e[3]+t[3],s),addVec4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]+t,s[1]=e[1]+t,s[2]=e[2]+t,s[3]=e[3]+t,s),addVec3:(e,t,s)=>(s||(s=e),s[0]=e[0]+t[0],s[1]=e[1]+t[1],s[2]=e[2]+t[2],s),addVec3Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]+t,s[1]=e[1]+t,s[2]=e[2]+t,s),subVec4:(e,t,s)=>(s||(s=e),s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],s[3]=e[3]-t[3],s),subVec3:(e,t,s)=>(s||(s=e),s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],s),subVec2:(e,t,s)=>(s||(s=e),s[0]=e[0]-t[0],s[1]=e[1]-t[1],s),geometricMeanVec2(...e){const t=new P(e[0]);for(let s=1;s<e.length;s++)t[0]+=e[s][0],t[1]+=e[s][1];return t[0]/=e.length,t[1]/=e.length,t},subVec4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]-t,s[1]=e[1]-t,s[2]=e[2]-t,s[3]=e[3]-t,s),subScalarVec4:(e,t,s)=>(s||(s=e),s[0]=t-e[0],s[1]=t-e[1],s[2]=t-e[2],s[3]=t-e[3],s),mulVec4:(e,t,s)=>(s||(s=e),s[0]=e[0]*t[0],s[1]=e[1]*t[1],s[2]=e[2]*t[2],s[3]=e[3]*t[3],s),mulVec4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]*t,s[1]=e[1]*t,s[2]=e[2]*t,s[3]=e[3]*t,s),mulVec3Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]*t,s[1]=e[1]*t,s[2]=e[2]*t,s),mulVec2Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]*t,s[1]=e[1]*t,s),divVec3:(e,t,s)=>(s||(s=e),s[0]=e[0]/t[0],s[1]=e[1]/t[1],s[2]=e[2]/t[2],s),divVec4:(e,t,s)=>(s||(s=e),s[0]=e[0]/t[0],s[1]=e[1]/t[1],s[2]=e[2]/t[2],s[3]=e[3]/t[3],s),divScalarVec3:(e,t,s)=>(s||(s=t),s[0]=e/t[0],s[1]=e/t[1],s[2]=e/t[2],s),divVec3Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]/t,s[1]=e[1]/t,s[2]=e[2]/t,s),divVec4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]/t,s[1]=e[1]/t,s[2]=e[2]/t,s[3]=e[3]/t,s),divScalarVec4:(e,t,s)=>(s||(s=t),s[0]=e/t[0],s[1]=e/t[1],s[2]=e/t[2],s[3]=e/t[3],s),dotVec4:(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],cross3Vec4(e,t){const s=e[0],i=e[1],r=e[2],n=t[0],A=t[1],o=t[2];return[i*o-r*A,r*n-s*o,s*A-i*n,0]},cross3Vec3(e,t,s){s||(s=e);const i=e[0],r=e[1],n=e[2],A=t[0],o=t[1],a=t[2];return s[0]=r*a-n*o,s[1]=n*A-i*a,s[2]=i*o-r*A,s},sqLenVec4:e=>R.dotVec4(e,e),lenVec4:e=>Math.sqrt(R.sqLenVec4(e)),dotVec3:(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],dotVec2:(e,t)=>e[0]*t[0]+e[1]*t[1],sqLenVec3:e=>R.dotVec3(e,e),sqLenVec2:e=>R.dotVec2(e,e),lenVec3:e=>Math.sqrt(R.sqLenVec3(e)),distVec3:(()=>{const e=new P(3);return(t,s)=>R.lenVec3(R.subVec3(t,s,e))})(),lenVec2:e=>Math.sqrt(R.sqLenVec2(e)),distVec2:(()=>{const e=new P(2);return(t,s)=>R.lenVec2(R.subVec2(t,s,e))})(),rcpVec3:(e,t)=>R.divScalarVec3(1,e,t),normalizeVec4(e,t){const s=1/R.lenVec4(e);return R.mulVec4Scalar(e,s,t)},normalizeVec3(e,t){const s=1/R.lenVec3(e);return R.mulVec3Scalar(e,s,t)},normalizeVec2(e,t){const s=1/R.lenVec2(e);return R.mulVec2Scalar(e,s,t)},angleVec3(e,t){let s=R.dotVec3(e,t)/Math.sqrt(R.sqLenVec3(e)*R.sqLenVec3(t));return s=s<-1?-1:s>1?1:s,Math.acos(s)},vec3FromMat4Scale:(()=>{const e=new P(3);return(t,s)=>(e[0]=t[0],e[1]=t[1],e[2]=t[2],s[0]=R.lenVec3(e),e[0]=t[4],e[1]=t[5],e[2]=t[6],s[1]=R.lenVec3(e),e[0]=t[8],e[1]=t[9],e[2]=t[10],s[2]=R.lenVec3(e),s)})(),vecToArray:(()=>{function e(e){return Math.round(1e5*e)/1e5}return t=>{for(let s=0,i=(t=Array.prototype.slice.call(t)).length;s<i;s++)t[s]=e(t[s]);return t}})(),xyzArrayToObject:e=>({x:e[0],y:e[1],z:e[2]}),xyzObjectToArray:(e,t)=>((t=t||R.vec3())[0]=e.x,t[1]=e.y,t[2]=e.z,t),dupMat4:e=>e.slice(0,16),mat4To3:e=>[e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]],m4s:e=>[e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e],setMat4ToZeroes:()=>R.m4s(0),setMat4ToOnes:()=>R.m4s(1),diagonalMat4v:e=>new P([e[0],0,0,0,0,e[1],0,0,0,0,e[2],0,0,0,0,e[3]]),diagonalMat4c:(e,t,s,i)=>R.diagonalMat4v([e,t,s,i]),diagonalMat4s:e=>R.diagonalMat4c(e,e,e,e),identityMat4:(e=new P(16))=>(e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e),identityMat3:(e=new P(9))=>(e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e),isIdentityMat4:e=>1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15],negateMat4:(e,t)=>(t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t[4]=-e[4],t[5]=-e[5],t[6]=-e[6],t[7]=-e[7],t[8]=-e[8],t[9]=-e[9],t[10]=-e[10],t[11]=-e[11],t[12]=-e[12],t[13]=-e[13],t[14]=-e[14],t[15]=-e[15],t),addMat4:(e,t,s)=>(s||(s=e),s[0]=e[0]+t[0],s[1]=e[1]+t[1],s[2]=e[2]+t[2],s[3]=e[3]+t[3],s[4]=e[4]+t[4],s[5]=e[5]+t[5],s[6]=e[6]+t[6],s[7]=e[7]+t[7],s[8]=e[8]+t[8],s[9]=e[9]+t[9],s[10]=e[10]+t[10],s[11]=e[11]+t[11],s[12]=e[12]+t[12],s[13]=e[13]+t[13],s[14]=e[14]+t[14],s[15]=e[15]+t[15],s),addMat4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]+t,s[1]=e[1]+t,s[2]=e[2]+t,s[3]=e[3]+t,s[4]=e[4]+t,s[5]=e[5]+t,s[6]=e[6]+t,s[7]=e[7]+t,s[8]=e[8]+t,s[9]=e[9]+t,s[10]=e[10]+t,s[11]=e[11]+t,s[12]=e[12]+t,s[13]=e[13]+t,s[14]=e[14]+t,s[15]=e[15]+t,s),addScalarMat4:(e,t,s)=>R.addMat4Scalar(t,e,s),subMat4:(e,t,s)=>(s||(s=e),s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],s[3]=e[3]-t[3],s[4]=e[4]-t[4],s[5]=e[5]-t[5],s[6]=e[6]-t[6],s[7]=e[7]-t[7],s[8]=e[8]-t[8],s[9]=e[9]-t[9],s[10]=e[10]-t[10],s[11]=e[11]-t[11],s[12]=e[12]-t[12],s[13]=e[13]-t[13],s[14]=e[14]-t[14],s[15]=e[15]-t[15],s),subMat4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]-t,s[1]=e[1]-t,s[2]=e[2]-t,s[3]=e[3]-t,s[4]=e[4]-t,s[5]=e[5]-t,s[6]=e[6]-t,s[7]=e[7]-t,s[8]=e[8]-t,s[9]=e[9]-t,s[10]=e[10]-t,s[11]=e[11]-t,s[12]=e[12]-t,s[13]=e[13]-t,s[14]=e[14]-t,s[15]=e[15]-t,s),subScalarMat4:(e,t,s)=>(s||(s=t),s[0]=e-t[0],s[1]=e-t[1],s[2]=e-t[2],s[3]=e-t[3],s[4]=e-t[4],s[5]=e-t[5],s[6]=e-t[6],s[7]=e-t[7],s[8]=e-t[8],s[9]=e-t[9],s[10]=e-t[10],s[11]=e-t[11],s[12]=e-t[12],s[13]=e-t[13],s[14]=e-t[14],s[15]=e-t[15],s),mulMat4(e,t,s){s||(s=e);const i=e[0],r=e[1],n=e[2],A=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],p=e[11],f=e[12],g=e[13],m=e[14],_=e[15],b=t[0],B=t[1],y=t[2],w=t[3],v=t[4],C=t[5],M=t[6],E=t[7],F=t[8],x=t[9],U=t[10],I=t[11],T=t[12],P=t[13],S=t[14],D=t[15];return s[0]=b*i+B*o+y*h+w*f,s[1]=b*r+B*a+y*u+w*g,s[2]=b*n+B*l+y*d+w*m,s[3]=b*A+B*c+y*p+w*_,s[4]=v*i+C*o+M*h+E*f,s[5]=v*r+C*a+M*u+E*g,s[6]=v*n+C*l+M*d+E*m,s[7]=v*A+C*c+M*p+E*_,s[8]=F*i+x*o+U*h+I*f,s[9]=F*r+x*a+U*u+I*g,s[10]=F*n+x*l+U*d+I*m,s[11]=F*A+x*c+U*p+I*_,s[12]=T*i+P*o+S*h+D*f,s[13]=T*r+P*a+S*u+D*g,s[14]=T*n+P*l+S*d+D*m,s[15]=T*A+P*c+S*p+D*_,s},mulMat3(e,t,s){s||(s=new P(9));const i=e[0],r=e[3],n=e[6],A=e[1],o=e[4],a=e[7],l=e[2],c=e[5],h=e[8],u=t[0],d=t[3],p=t[6],f=t[1],g=t[4],m=t[7],_=t[2],b=t[5],B=t[8];return s[0]=i*u+r*f+n*_,s[3]=i*d+r*g+n*b,s[6]=i*p+r*m+n*B,s[1]=A*u+o*f+a*_,s[4]=A*d+o*g+a*b,s[7]=A*p+o*m+a*B,s[2]=l*u+c*f+h*_,s[5]=l*d+c*g+h*b,s[8]=l*p+c*m+h*B,s},mulMat4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]*t,s[1]=e[1]*t,s[2]=e[2]*t,s[3]=e[3]*t,s[4]=e[4]*t,s[5]=e[5]*t,s[6]=e[6]*t,s[7]=e[7]*t,s[8]=e[8]*t,s[9]=e[9]*t,s[10]=e[10]*t,s[11]=e[11]*t,s[12]=e[12]*t,s[13]=e[13]*t,s[14]=e[14]*t,s[15]=e[15]*t,s),mulMat4v4(e,t,s=R.vec4()){const i=t[0],r=t[1],n=t[2],A=t[3];return s[0]=e[0]*i+e[4]*r+e[8]*n+e[12]*A,s[1]=e[1]*i+e[5]*r+e[9]*n+e[13]*A,s[2]=e[2]*i+e[6]*r+e[10]*n+e[14]*A,s[3]=e[3]*i+e[7]*r+e[11]*n+e[15]*A,s},transposeMat4(e,t){const s=e[4],i=e[14],r=e[8],n=e[13],A=e[12],o=e[9];if(!t||e===t){const t=e[1],a=e[2],l=e[3],c=e[6],h=e[7],u=e[11];return e[1]=s,e[2]=r,e[3]=A,e[4]=t,e[6]=o,e[7]=n,e[8]=a,e[9]=c,e[11]=i,e[12]=l,e[13]=h,e[14]=u,e}return t[0]=e[0],t[1]=s,t[2]=r,t[3]=A,t[4]=e[1],t[5]=e[5],t[6]=o,t[7]=n,t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=i,t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15],t},transposeMat3(e,t){if(t===e){const s=e[1],i=e[2],r=e[5];t[1]=e[3],t[2]=e[6],t[3]=s,t[5]=e[7],t[6]=i,t[7]=r}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},determinantMat4(e){const t=e[0],s=e[1],i=e[2],r=e[3],n=e[4],A=e[5],o=e[6],a=e[7],l=e[8],c=e[9],h=e[10],u=e[11],d=e[12],p=e[13],f=e[14],g=e[15];return d*c*o*r-l*p*o*r-d*A*h*r+n*p*h*r+l*A*f*r-n*c*f*r-d*c*i*a+l*p*i*a+d*s*h*a-t*p*h*a-l*s*f*a+t*c*f*a+d*A*i*u-n*p*i*u-d*s*o*u+t*p*o*u+n*s*f*u-t*A*f*u-l*A*i*g+n*c*i*g+l*s*o*g-t*c*o*g-n*s*h*g+t*A*h*g},inverseMat4(e,t){t||(t=e);const s=e[0],i=e[1],r=e[2],n=e[3],A=e[4],o=e[5],a=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11],p=e[12],f=e[13],g=e[14],m=e[15],_=s*o-i*A,b=s*a-r*A,B=s*l-n*A,y=i*a-r*o,w=i*l-n*o,v=r*l-n*a,C=c*f-h*p,M=c*g-u*p,E=c*m-d*p,F=h*g-u*f,x=h*m-d*f,U=u*m-d*g,I=1/(_*U-b*x+B*F+y*E-w*M+v*C);return t[0]=(o*U-a*x+l*F)*I,t[1]=(-i*U+r*x-n*F)*I,t[2]=(f*v-g*w+m*y)*I,t[3]=(-h*v+u*w-d*y)*I,t[4]=(-A*U+a*E-l*M)*I,t[5]=(s*U-r*E+n*M)*I,t[6]=(-p*v+g*B-m*b)*I,t[7]=(c*v-u*B+d*b)*I,t[8]=(A*x-o*E+l*C)*I,t[9]=(-s*x+i*E-n*C)*I,t[10]=(p*w-f*B+m*_)*I,t[11]=(-c*w+h*B-d*_)*I,t[12]=(-A*F+o*M-a*C)*I,t[13]=(s*F-i*M+r*C)*I,t[14]=(-p*y+f*b-g*_)*I,t[15]=(c*y-h*b+u*_)*I,t},traceMat4:e=>e[0]+e[5]+e[10]+e[15],translationMat4v(e,t){const s=t||R.identityMat4();return s[12]=e[0],s[13]=e[1],s[14]=e[2],s},translationMat3v(e,t){const s=t||R.identityMat3();return s[6]=e[0],s[7]=e[1],s},translationMat4c:(()=>{const e=new P(3);return(t,s,i,r)=>(e[0]=t,e[1]=s,e[2]=i,R.translationMat4v(e,r))})(),translationMat4s:(e,t)=>R.translationMat4c(e,e,e,t),translateMat4v:(e,t)=>R.translateMat4c(e[0],e[1],e[2],t),translateMat4c(e,t,s,i){const r=i[3];i[0]+=r*e,i[1]+=r*t,i[2]+=r*s;const n=i[7];i[4]+=n*e,i[5]+=n*t,i[6]+=n*s;const A=i[11];i[8]+=A*e,i[9]+=A*t,i[10]+=A*s;const o=i[15];return i[12]+=o*e,i[13]+=o*t,i[14]+=o*s,i},setMat4Translation:(e,t,s)=>(s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s[6]=e[6],s[7]=e[7],s[8]=e[8],s[9]=e[9],s[10]=e[10],s[11]=e[11],s[12]=t[0],s[13]=t[1],s[14]=t[2],s[15]=e[15],s),rotationMat4v(e,t,s){const i=R.normalizeVec4([t[0],t[1],t[2],0],[]),r=Math.sin(e),n=Math.cos(e),A=1-n,o=i[0],a=i[1],l=i[2];let c,h,u,d,p,f;return c=o*a,h=a*l,u=l*o,d=o*r,p=a*r,f=l*r,(s=s||R.mat4())[0]=A*o*o+n,s[1]=A*c+f,s[2]=A*u-p,s[3]=0,s[4]=A*c-f,s[5]=A*a*a+n,s[6]=A*h+d,s[7]=0,s[8]=A*u+p,s[9]=A*h-d,s[10]=A*l*l+n,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s},rotationMat4c:(e,t,s,i,r)=>R.rotationMat4v(e,[t,s,i],r),scalingMat4v:(e,t=R.identityMat4())=>(t[0]=e[0],t[5]=e[1],t[10]=e[2],t),scalingMat3v:(e,t=R.identityMat3())=>(t[0]=e[0],t[4]=e[1],t),scalingMat4c:(()=>{const e=new P(3);return(t,s,i,r)=>(e[0]=t,e[1]=s,e[2]=i,R.scalingMat4v(e,r))})(),scaleMat4c:(e,t,s,i)=>(i[0]*=e,i[4]*=t,i[8]*=s,i[1]*=e,i[5]*=t,i[9]*=s,i[2]*=e,i[6]*=t,i[10]*=s,i[3]*=e,i[7]*=t,i[11]*=s,i),scaleMat4v(e,t){const s=e[0],i=e[1],r=e[2];return t[0]*=s,t[4]*=i,t[8]*=r,t[1]*=s,t[5]*=i,t[9]*=r,t[2]*=s,t[6]*=i,t[10]*=r,t[3]*=s,t[7]*=i,t[11]*=r,t},scalingMat4s:e=>R.scalingMat4c(e,e,e),rotationTranslationMat4(e,t,s=R.mat4()){const i=e[0],r=e[1],n=e[2],A=e[3],o=i+i,a=r+r,l=n+n,c=i*o,h=i*a,u=i*l,d=r*a,p=r*l,f=n*l,g=A*o,m=A*a,_=A*l;return s[0]=1-(d+f),s[1]=h+_,s[2]=u-m,s[3]=0,s[4]=h-_,s[5]=1-(c+f),s[6]=p+g,s[7]=0,s[8]=u+m,s[9]=p-g,s[10]=1-(c+d),s[11]=0,s[12]=t[0],s[13]=t[1],s[14]=t[2],s[15]=1,s},mat4ToEuler(e,t,s=R.vec4()){const i=R.clamp,r=e[0],n=e[4],A=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],u=e[10];return"XYZ"===t?(s[1]=Math.asin(i(A,-1,1)),Math.abs(A)<.99999?(s[0]=Math.atan2(-l,u),s[2]=Math.atan2(-n,r)):(s[0]=Math.atan2(h,a),s[2]=0)):"YXZ"===t?(s[0]=Math.asin(-i(l,-1,1)),Math.abs(l)<.99999?(s[1]=Math.atan2(A,u),s[2]=Math.atan2(o,a)):(s[1]=Math.atan2(-c,r),s[2]=0)):"ZXY"===t?(s[0]=Math.asin(i(h,-1,1)),Math.abs(h)<.99999?(s[1]=Math.atan2(-c,u),s[2]=Math.atan2(-n,a)):(s[1]=0,s[2]=Math.atan2(o,r))):"ZYX"===t?(s[1]=Math.asin(-i(c,-1,1)),Math.abs(c)<.99999?(s[0]=Math.atan2(h,u),s[2]=Math.atan2(o,r)):(s[0]=0,s[2]=Math.atan2(-n,a))):"YZX"===t?(s[2]=Math.asin(i(o,-1,1)),Math.abs(o)<.99999?(s[0]=Math.atan2(-l,a),s[1]=Math.atan2(-c,r)):(s[0]=0,s[1]=Math.atan2(A,u))):"XZY"===t&&(s[2]=Math.asin(-i(n,-1,1)),Math.abs(n)<.99999?(s[0]=Math.atan2(h,a),s[1]=Math.atan2(A,r)):(s[0]=Math.atan2(-l,u),s[1]=0)),s[0]*=R.RADTODEG,s[1]*=R.RADTODEG,s[2]*=R.RADTODEG,s},composeMat4:(e,t,s,i=R.mat4())=>(R.quaternionToRotationMat4(t,i),R.scaleMat4v(s,i),R.translateMat4v(e,i),i),decomposeMat4:(()=>{const e=new P(3),t=new P(16);return function(s,i,r,n){e[0]=s[0],e[1]=s[1],e[2]=s[2];let A=R.lenVec3(e);e[0]=s[4],e[1]=s[5],e[2]=s[6];const o=R.lenVec3(e);e[8]=s[8],e[9]=s[9],e[10]=s[10];const a=R.lenVec3(e);R.determinantMat4(s)<0&&(A=-A),i[0]=s[12],i[1]=s[13],i[2]=s[14],t.set(s);const l=1/A,c=1/o,h=1/a;return t[0]*=l,t[1]*=l,t[2]*=l,t[4]*=c,t[5]*=c,t[6]*=c,t[8]*=h,t[9]*=h,t[10]*=h,R.mat4ToQuaternion(t,r),n[0]=A,n[1]=o,n[2]=a,this}})(),getColMat4(e,t){const s=4*t;return[e[s],e[s+1],e[s+2],e[s+3]]},setRowMat4(e,t,s){e[t]=s[0],e[t+4]=s[1],e[t+8]=s[2],e[t+12]=s[3]},lookAtMat4v(e,t,s,i){i||(i=R.mat4());const r=e[0],n=e[1],A=e[2],o=s[0],a=s[1],l=s[2],c=t[0],h=t[1],u=t[2];if(r===c&&n===h&&A===u)return R.identityMat4();let d,p,f,g,m,_,b,B,y,w;return d=r-c,p=n-h,f=A-u,w=1/Math.sqrt(d*d+p*p+f*f),d*=w,p*=w,f*=w,g=a*f-l*p,m=l*d-o*f,_=o*p-a*d,w=Math.sqrt(g*g+m*m+_*_),w?(w=1/w,g*=w,m*=w,_*=w):(g=0,m=0,_=0),b=p*_-f*m,B=f*g-d*_,y=d*m-p*g,w=Math.sqrt(b*b+B*B+y*y),w?(w=1/w,b*=w,B*=w,y*=w):(b=0,B=0,y=0),i[0]=g,i[1]=b,i[2]=d,i[3]=0,i[4]=m,i[5]=B,i[6]=p,i[7]=0,i[8]=_,i[9]=y,i[10]=f,i[11]=0,i[12]=-(g*r+m*n+_*A),i[13]=-(b*r+B*n+y*A),i[14]=-(d*r+p*n+f*A),i[15]=1,i},lookAtMat4c:(e,t,s,i,r,n,A,o,a)=>R.lookAtMat4v([e,t,s],[i,r,n],[A,o,a],[]),orthoMat4c(e,t,s,i,r,n,A){A||(A=R.mat4());const o=t-e,a=i-s,l=n-r;return A[0]=2/o,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=2/a,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[10]=-2/l,A[11]=0,A[12]=-(e+t)/o,A[13]=-(i+s)/a,A[14]=-(n+r)/l,A[15]=1,A},frustumMat4v(e,t,s){s||(s=R.mat4());const i=[e[0],e[1],e[2],0],r=[t[0],t[1],t[2],0];R.addVec4(r,i,D),R.subVec4(r,i,k);const n=2*i[2],A=k[0],o=k[1],a=k[2];return s[0]=n/A,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=n/o,s[6]=0,s[7]=0,s[8]=D[0]/A,s[9]=D[1]/o,s[10]=-D[2]/a,s[11]=-1,s[12]=0,s[13]=0,s[14]=-n*r[2]/a,s[15]=0,s},frustumMat4(e,t,s,i,r,n,A){A||(A=R.mat4());const o=t-e,a=i-s,l=n-r;return A[0]=2*r/o,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=2*r/a,A[6]=0,A[7]=0,A[8]=(t+e)/o,A[9]=(i+s)/a,A[10]=-(n+r)/l,A[11]=-1,A[12]=0,A[13]=0,A[14]=-n*r*2/l,A[15]=0,A},perspectiveMat4(e,t,s,i,r){const n=[],A=[];return n[2]=s,A[2]=i,A[1]=n[2]*Math.tan(e/2),n[1]=-A[1],A[0]=A[1]*t,n[0]=-A[0],R.frustumMat4v(n,A,r)},compareMat4:(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15],transformPoint3(e,t,s=R.vec3()){const i=t[0],r=t[1],n=t[2];return s[0]=e[0]*i+e[4]*r+e[8]*n+e[12],s[1]=e[1]*i+e[5]*r+e[9]*n+e[13],s[2]=e[2]*i+e[6]*r+e[10]*n+e[14],s},transformPoint4:(e,t,s=R.vec4())=>(s[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],s[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],s[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],s[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3],s),transformPoints3(e,t,s){const i=s||[],r=t.length;let n,A,o,a;const l=e[0],c=e[1],h=e[2],u=e[3],d=e[4],p=e[5],f=e[6],g=e[7],m=e[8],_=e[9],b=e[10],B=e[11],y=e[12],w=e[13],v=e[14],C=e[15];let M;for(let e=0;e<r;++e)a=t[e],n=a[0],A=a[1],o=a[2],M=i[e]||(i[e]=[0,0,0]),M[0]=l*n+d*A+m*o+y,M[1]=c*n+p*A+_*o+w,M[2]=h*n+f*A+b*o+v,M[3]=u*n+g*A+B*o+C;return i.length=r,i},transformPositions3(e,t,s=t){let i;const r=t.length;let n,A,o;const a=e[0],l=e[1],c=e[2];e[3];const h=e[4],u=e[5],d=e[6];e[7];const p=e[8],f=e[9],g=e[10];e[11];const m=e[12],_=e[13],b=e[14];for(e[15],i=0;i<r;i+=3)n=t[i+0],A=t[i+1],o=t[i+2],s[i+0]=a*n+h*A+p*o+m,s[i+1]=l*n+u*A+f*o+_,s[i+2]=c*n+d*A+g*o+b;return s},transformPositions4(e,t,s=t){let i;const r=t.length;let n,A,o;const a=e[0],l=e[1],c=e[2],h=e[3],u=e[4],d=e[5],p=e[6],f=e[7],g=e[8],m=e[9],_=e[10],b=e[11],B=e[12],y=e[13],w=e[14],v=e[15];for(i=0;i<r;i+=4)n=t[i+0],A=t[i+1],o=t[i+2],s[i+0]=a*n+u*A+g*o+B,s[i+1]=l*n+d*A+m*o+y,s[i+2]=c*n+p*A+_*o+w,s[i+3]=h*n+f*A+b*o+v;return s},transformVec3(e,t,s){const i=t[0],r=t[1],n=t[2];return(s=s||this.vec3())[0]=e[0]*i+e[4]*r+e[8]*n,s[1]=e[1]*i+e[5]*r+e[9]*n,s[2]=e[2]*i+e[6]*r+e[10]*n,s},transformVec4(e,t,s){const i=t[0],r=t[1],n=t[2],A=t[3];return(s=s||R.vec4())[0]=e[0]*i+e[4]*r+e[8]*n+e[12]*A,s[1]=e[1]*i+e[5]*r+e[9]*n+e[13]*A,s[2]=e[2]*i+e[6]*r+e[10]*n+e[14]*A,s[3]=e[3]*i+e[7]*r+e[11]*n+e[15]*A,s},rotateVec2(e,t,s,i=e){const r=Math.cos(s),n=Math.sin(s),A=e[0]-t[0],o=e[1]-t[1];return i[0]=A*r-o*n+t[0],i[1]=A*n+o*r+t[1],e},rotateVec3X(e,t,s,i){const r=[],n=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],n[0]=r[0],n[1]=r[1]*Math.cos(s)-r[2]*Math.sin(s),n[2]=r[1]*Math.sin(s)+r[2]*Math.cos(s),i[0]=n[0]+t[0],i[1]=n[1]+t[1],i[2]=n[2]+t[2],i},rotateVec3Y(e,t,s,i){const r=[],n=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],n[0]=r[2]*Math.sin(s)+r[0]*Math.cos(s),n[1]=r[1],n[2]=r[2]*Math.cos(s)-r[0]*Math.sin(s),i[0]=n[0]+t[0],i[1]=n[1]+t[1],i[2]=n[2]+t[2],i},rotateVec3Z(e,t,s,i){const r=[],n=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],n[0]=r[0]*Math.cos(s)-r[1]*Math.sin(s),n[1]=r[0]*Math.sin(s)+r[1]*Math.cos(s),n[2]=r[2],i[0]=n[0]+t[0],i[1]=n[1]+t[1],i[2]=n[2]+t[2],i},projectVec4(e,t){const s=1/e[3];return(t=t||R.vec2())[0]=e[0]*s,t[1]=e[1]*s,t},unprojectVec3:(()=>{const e=new P(16),t=new P(16),s=new P(16);return function(i,r,n,A){return this.transformVec3(this.mulMat4(this.inverseMat4(r,e),this.inverseMat4(n,t),s),i,A)}})(),lerpVec3(e,t,s,i,r,n){const A=n||R.vec3(),o=(e-t)/(s-t);return A[0]=i[0]+o*(r[0]-i[0]),A[1]=i[1]+o*(r[1]-i[1]),A[2]=i[2]+o*(r[2]-i[2]),A},lerpMat4(e,t,s,i,r,n){const A=n||R.mat4(),o=(e-t)/(s-t);return A[0]=i[0]+o*(r[0]-i[0]),A[1]=i[1]+o*(r[1]-i[1]),A[2]=i[2]+o*(r[2]-i[2]),A[3]=i[3]+o*(r[3]-i[3]),A[4]=i[4]+o*(r[4]-i[4]),A[5]=i[5]+o*(r[5]-i[5]),A[6]=i[6]+o*(r[6]-i[6]),A[7]=i[7]+o*(r[7]-i[7]),A[8]=i[8]+o*(r[8]-i[8]),A[9]=i[9]+o*(r[9]-i[9]),A[10]=i[10]+o*(r[10]-i[10]),A[11]=i[11]+o*(r[11]-i[11]),A[12]=i[12]+o*(r[12]-i[12]),A[13]=i[13]+o*(r[13]-i[13]),A[14]=i[14]+o*(r[14]-i[14]),A[15]=i[15]+o*(r[15]-i[15]),A},flatten(e){const t=[];let s,i,r,n,A;for(s=0,i=e.length;s<i;s++)for(A=e[s],r=0,n=A.length;r<n;r++)t.push(A[r]);return t},identityQuaternion:(e=R.vec4())=>(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e),eulerToQuaternion(e,t,s=R.vec4()){const i=e[0]*R.DEGTORAD/2,r=e[1]*R.DEGTORAD/2,n=e[2]*R.DEGTORAD/2,A=Math.cos(i),o=Math.cos(r),a=Math.cos(n),l=Math.sin(i),c=Math.sin(r),h=Math.sin(n);return"XYZ"===t?(s[0]=l*o*a+A*c*h,s[1]=A*c*a-l*o*h,s[2]=A*o*h+l*c*a,s[3]=A*o*a-l*c*h):"YXZ"===t?(s[0]=l*o*a+A*c*h,s[1]=A*c*a-l*o*h,s[2]=A*o*h-l*c*a,s[3]=A*o*a+l*c*h):"ZXY"===t?(s[0]=l*o*a-A*c*h,s[1]=A*c*a+l*o*h,s[2]=A*o*h+l*c*a,s[3]=A*o*a-l*c*h):"ZYX"===t?(s[0]=l*o*a-A*c*h,s[1]=A*c*a+l*o*h,s[2]=A*o*h-l*c*a,s[3]=A*o*a+l*c*h):"YZX"===t?(s[0]=l*o*a+A*c*h,s[1]=A*c*a+l*o*h,s[2]=A*o*h-l*c*a,s[3]=A*o*a-l*c*h):"XZY"===t&&(s[0]=l*o*a-A*c*h,s[1]=A*c*a-l*o*h,s[2]=A*o*h+l*c*a,s[3]=A*o*a+l*c*h),s},mat4ToQuaternion(e,t=R.vec4()){const s=e[0],i=e[4],r=e[8],n=e[1],A=e[5],o=e[9],a=e[2],l=e[6],c=e[10];let h;const u=s+A+c;return u>0?(h=.5/Math.sqrt(u+1),t[3]=.25/h,t[0]=(l-o)*h,t[1]=(r-a)*h,t[2]=(n-i)*h):s>A&&s>c?(h=2*Math.sqrt(1+s-A-c),t[3]=(l-o)/h,t[0]=.25*h,t[1]=(i+n)/h,t[2]=(r+a)/h):A>c?(h=2*Math.sqrt(1+A-s-c),t[3]=(r-a)/h,t[0]=(i+n)/h,t[1]=.25*h,t[2]=(o+l)/h):(h=2*Math.sqrt(1+c-s-A),t[3]=(n-i)/h,t[0]=(r+a)/h,t[1]=(o+l)/h,t[2]=.25*h),t},vec3PairToQuaternion(e,t,s=R.vec4()){const i=Math.sqrt(R.dotVec3(e,e)*R.dotVec3(t,t));let r=i+R.dotVec3(e,t);return r<1e-8*i?(r=0,Math.abs(e[0])>Math.abs(e[2])?(s[0]=-e[1],s[1]=e[0],s[2]=0):(s[0]=0,s[1]=-e[2],s[2]=e[1])):R.cross3Vec3(e,t,s),s[3]=r,R.normalizeQuaternion(s)},angleAxisToQuaternion(e,t=R.vec4()){const s=e[3]/2,i=Math.sin(s);return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=Math.cos(s),t},quaternionToEuler:(()=>{const e=new P(16);return(t,s,i)=>(i=i||R.vec3(),R.quaternionToRotationMat4(t,e),R.mat4ToEuler(e,s,i),i)})(),mulQuaternions(e,t,s=R.vec4()){const i=e[0],r=e[1],n=e[2],A=e[3],o=t[0],a=t[1],l=t[2],c=t[3];return s[0]=A*o+i*c+r*l-n*a,s[1]=A*a+r*c+n*o-i*l,s[2]=A*l+n*c+i*a-r*o,s[3]=A*c-i*o-r*a-n*l,s},vec3ApplyQuaternion(e,t,s=R.vec3()){const i=t[0],r=t[1],n=t[2],A=e[0],o=e[1],a=e[2],l=e[3],c=l*i+o*n-a*r,h=l*r+a*i-A*n,u=l*n+A*r-o*i,d=-A*i-o*r-a*n;return s[0]=c*l+d*-A+h*-a-u*-o,s[1]=h*l+d*-o+u*-A-c*-a,s[2]=u*l+d*-a+c*-o-h*-A,s},quaternionToMat4(e,t){t=R.identityMat4(t);const s=e[0],i=e[1],r=e[2],n=e[3],A=2*s,o=2*i,a=2*r,l=A*n,c=o*n,h=a*n,u=A*s,d=o*s,p=a*s,f=o*i,g=a*i,m=a*r;return t[0]=1-(f+m),t[1]=d+h,t[2]=p-c,t[4]=d-h,t[5]=1-(u+m),t[6]=g+l,t[8]=p+c,t[9]=g-l,t[10]=1-(u+f),t},quaternionToRotationMat4(e,t){const s=e[0],i=e[1],r=e[2],n=e[3],A=s+s,o=i+i,a=r+r,l=s*A,c=s*o,h=s*a,u=i*o,d=i*a,p=r*a,f=n*A,g=n*o,m=n*a;return t[0]=1-(u+p),t[4]=c-m,t[8]=h+g,t[1]=c+m,t[5]=1-(l+p),t[9]=d-f,t[2]=h-g,t[6]=d+f,t[10]=1-(l+u),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},normalizeQuaternion(e,t=e){const s=R.lenVec4([e[0],e[1],e[2],e[3]]);return t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s,t[3]=e[3]/s,t},conjugateQuaternion:(e,t=e)=>(t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t),inverseQuaternion:(e,t)=>R.normalizeQuaternion(R.conjugateQuaternion(e,t)),quaternionToAngleAxis(e,t=R.vec4()){const s=(e=R.normalizeQuaternion(e,Q))[3],i=2*Math.acos(s),r=Math.sqrt(1-s*s);return r<.001?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=e[0]/r,t[1]=e[1]/r,t[2]=e[2]/r),t[3]=i,t},AABB3:e=>new P(e||6),AABB2:e=>new P(e||4),OBB3:e=>new P(e||32),OBB2:e=>new P(e||16),Sphere3:(e,t,s,i)=>new P([e,t,s,i]),transformOBB3(e,t,s=t){let i;const r=t.length;let n,A,o;const a=e[0],l=e[1],c=e[2],h=e[3],u=e[4],d=e[5],p=e[6],f=e[7],g=e[8],m=e[9],_=e[10],b=e[11],B=e[12],y=e[13],w=e[14],v=e[15];for(i=0;i<r;i+=4)n=t[i+0],A=t[i+1],o=t[i+2],s[i+0]=a*n+u*A+g*o+B,s[i+1]=l*n+d*A+m*o+y,s[i+2]=c*n+p*A+_*o+w,s[i+3]=h*n+f*A+b*o+v;return s},containsAABB3:function(e,t){return e[0]<=t[0]&&t[3]<=e[3]&&e[1]<=t[1]&&t[4]<=e[4]&&e[2]<=t[2]&&t[5]<=e[5]},getAABB3Diag:(()=>{const e=new P(3),t=new P(3),s=new P(3);return i=>(e[0]=i[0],e[1]=i[1],e[2]=i[2],t[0]=i[3],t[1]=i[4],t[2]=i[5],R.subVec3(t,e,s),Math.abs(R.lenVec3(s)))})(),getAABB3DiagPoint:(()=>{const e=new P(3),t=new P(3),s=new P(3);return(i,r)=>{e[0]=i[0],e[1]=i[1],e[2]=i[2],t[0]=i[3],t[1]=i[4],t[2]=i[5];const n=R.subVec3(t,e,s),A=r[0]-i[0],o=i[3]-r[0],a=r[1]-i[1],l=i[4]-r[1],c=r[2]-i[2],h=i[5]-r[2];return n[0]+=A>o?A:o,n[1]+=a>l?a:l,n[2]+=c>h?c:h,Math.abs(R.lenVec3(n))}})(),getAABB3Area:e=>(e[3]-e[0])*(e[4]-e[1])*(e[5]-e[2]),getAABB3Center(e,t){const s=t||R.vec3();return s[0]=(e[0]+e[3])/2,s[1]=(e[1]+e[4])/2,s[2]=(e[2]+e[5])/2,s},getAABB2Center(e,t){const s=t||R.vec2();return s[0]=(e[2]+e[0])/2,s[1]=(e[3]+e[1])/2,s},collapseAABB3:(e=R.AABB3())=>(e[0]=R.MAX_DOUBLE,e[1]=R.MAX_DOUBLE,e[2]=R.MAX_DOUBLE,e[3]=R.MIN_DOUBLE,e[4]=R.MIN_DOUBLE,e[5]=R.MIN_DOUBLE,e),AABB3ToOBB3:(e,t=R.OBB3())=>(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t[4]=e[3],t[5]=e[1],t[6]=e[2],t[7]=1,t[8]=e[3],t[9]=e[4],t[10]=e[2],t[11]=1,t[12]=e[0],t[13]=e[4],t[14]=e[2],t[15]=1,t[16]=e[0],t[17]=e[1],t[18]=e[5],t[19]=1,t[20]=e[3],t[21]=e[1],t[22]=e[5],t[23]=1,t[24]=e[3],t[25]=e[4],t[26]=e[5],t[27]=1,t[28]=e[0],t[29]=e[4],t[30]=e[5],t[31]=1,t),positions3ToAABB3:(()=>{const e=new P(3);return(t,s,i)=>{s=s||R.AABB3();let r,n,A,o=R.MAX_DOUBLE,a=R.MAX_DOUBLE,l=R.MAX_DOUBLE,c=R.MIN_DOUBLE,h=R.MIN_DOUBLE,u=R.MIN_DOUBLE;for(let s=0,d=t.length;s<d;s+=3)i?(e[0]=t[s+0],e[1]=t[s+1],e[2]=t[s+2],R.decompressPosition(e,i,e),r=e[0],n=e[1],A=e[2]):(r=t[s+0],n=t[s+1],A=t[s+2]),r<o&&(o=r),n<a&&(a=n),A<l&&(l=A),r>c&&(c=r),n>h&&(h=n),A>u&&(u=A);return s[0]=o,s[1]=a,s[2]=l,s[3]=c,s[4]=h,s[5]=u,s}})(),OBB3ToAABB3(e,t=R.AABB3()){let s,i,r,n=R.MAX_DOUBLE,A=R.MAX_DOUBLE,o=R.MAX_DOUBLE,a=R.MIN_DOUBLE,l=R.MIN_DOUBLE,c=R.MIN_DOUBLE;for(let t=0,h=e.length;t<h;t+=4)s=e[t+0],i=e[t+1],r=e[t+2],s<n&&(n=s),i<A&&(A=i),r<o&&(o=r),s>a&&(a=s),i>l&&(l=i),r>c&&(c=r);return t[0]=n,t[1]=A,t[2]=o,t[3]=a,t[4]=l,t[5]=c,t},points3ToAABB3(e,t=R.AABB3()){let s,i,r,n=R.MAX_DOUBLE,A=R.MAX_DOUBLE,o=R.MAX_DOUBLE,a=R.MIN_DOUBLE,l=R.MIN_DOUBLE,c=R.MIN_DOUBLE;for(let t=0,h=e.length;t<h;t++)s=e[t][0],i=e[t][1],r=e[t][2],s<n&&(n=s),i<A&&(A=i),r<o&&(o=r),s>a&&(a=s),i>l&&(l=i),r>c&&(c=r);return t[0]=n,t[1]=A,t[2]=o,t[3]=a,t[4]=l,t[5]=c,t},points3ToSphere3:(()=>{const e=new P(3);return(t,s)=>{s=s||R.vec4();let i,r=0,n=0,A=0;const o=t.length;for(i=0;i<o;i++)r+=t[i][0],n+=t[i][1],A+=t[i][2];s[0]=r/o,s[1]=n/o,s[2]=A/o;let a,l=0;for(i=0;i<o;i++)a=Math.abs(R.lenVec3(R.subVec3(t[i],s,e))),a>l&&(l=a);return s[3]=l,s}})(),positions3ToSphere3:(()=>{const e=new P(3),t=new P(3);return(s,i)=>{i=i||R.vec4();let r,n=0,A=0,o=0;const a=s.length;let l=0;for(r=0;r<a;r+=3)n+=s[r],A+=s[r+1],o+=s[r+2];const c=a/3;let h;for(i[0]=n/c,i[1]=A/c,i[2]=o/c,r=0;r<a;r+=3)e[0]=s[r],e[1]=s[r+1],e[2]=s[r+2],h=Math.abs(R.lenVec3(R.subVec3(e,i,t))),h>l&&(l=h);return i[3]=l,i}})(),OBB3ToSphere3:(()=>{const e=new P(3),t=new P(3);return(s,i)=>{i=i||R.vec4();let r,n=0,A=0,o=0;const a=s.length,l=a/4;for(r=0;r<a;r+=4)n+=s[r+0],A+=s[r+1],o+=s[r+2];i[0]=n/l,i[1]=A/l,i[2]=o/l;let c,h=0;for(r=0;r<a;r+=4)e[0]=s[r+0],e[1]=s[r+1],e[2]=s[r+2],c=Math.abs(R.lenVec3(R.subVec3(e,i,t))),c>h&&(h=c);return i[3]=h,i}})(),getSphere3Center:(e,t=R.vec3())=>(t[0]=e[0],t[1]=e[1],t[2]=e[2],t),getPositionsCenter(e,t=R.vec3()){let s=0,i=0,r=0;for(var n=0,A=e.length;n<A;n+=3)s+=e[n+0],i+=e[n+1],r+=e[n+2];const o=e.length/3;return t[0]=s/o,t[1]=i/o,t[2]=r/o,t},expandAABB3:(e,t)=>(e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]>t[2]&&(e[2]=t[2]),e[3]<t[3]&&(e[3]=t[3]),e[4]<t[4]&&(e[4]=t[4]),e[5]<t[5]&&(e[5]=t[5]),e),expandAABB3Point3:(e,t)=>(e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]>t[2]&&(e[2]=t[2]),e[3]<t[0]&&(e[3]=t[0]),e[4]<t[1]&&(e[4]=t[1]),e[5]<t[2]&&(e[5]=t[2]),e),expandAABB3Points3(e,t){for(var s,i,r,n=0,A=t.length;n<A;n+=3)s=t[n],i=t[n+1],r=t[n+2],e[0]>s&&(e[0]=s),e[1]>i&&(e[1]=i),e[2]>r&&(e[2]=r),e[3]<s&&(e[3]=s),e[4]<i&&(e[4]=i),e[5]<r&&(e[5]=r);return e},collapseAABB2:(e=R.AABB2())=>(e[0]=R.MAX_DOUBLE,e[1]=R.MAX_DOUBLE,e[2]=R.MIN_DOUBLE,e[3]=R.MIN_DOUBLE,e),point3AABB3Intersect:(e,t)=>e[0]>t[0]||e[3]<t[0]||e[1]>t[1]||e[4]<t[1]||e[2]>t[2]||e[5]<t[2],point3AABB3AbsoluteIntersect:(e,t)=>e[0]<=t[0]&&e[3]>=t[0]&&e[1]<=t[1]&&e[4]>=t[1]&&e[2]<=t[2]&&e[5]>=t[2],planeAABB3Intersect(e,t,s){let i,r;e[0]>0?(i=e[0]*s[0],r=e[0]*s[3]):(i=e[0]*s[3],r=e[0]*s[0]),e[1]>0?(i+=e[1]*s[1],r+=e[1]*s[4]):(i+=e[1]*s[4],r+=e[1]*s[1]),e[2]>0?(i+=e[2]*s[2],r+=e[2]*s[5]):(i+=e[2]*s[5],r+=e[2]*s[2]);if(i<=-t&&r<=-t)return-1;return i>=-t&&r>=-t?1:0},OBB3ToAABB2(e,t=R.AABB2()){let s,i,r,n,A=R.MAX_DOUBLE,o=R.MAX_DOUBLE,a=R.MIN_DOUBLE,l=R.MIN_DOUBLE;for(let t=0,c=e.length;t<c;t+=4)s=e[t+0],i=e[t+1],r=e[t+3]||1,n=1/r,s*=n,i*=n,s<A&&(A=s),i<o&&(o=i),s>a&&(a=s),i>l&&(l=i);return t[0]=A,t[1]=o,t[2]=a,t[3]=l,t},expandAABB2:(e,t)=>(e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]<t[2]&&(e[2]=t[2]),e[3]<t[3]&&(e[3]=t[3]),e),expandAABB2Point2:(e,t)=>(e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]<t[0]&&(e[2]=t[0]),e[3]<t[1]&&(e[3]=t[1]),e),AABB2ToCanvas(e,t,s,i=e){const r=.5*(e[0]+1),n=.5*(e[1]+1),A=.5*(e[2]+1),o=.5*(e[3]+1);return i[0]=Math.floor(r*t),i[1]=s-Math.floor(o*s),i[2]=Math.floor(A*t),i[3]=s-Math.floor(n*s),i},tangentQuadraticBezier:(e,t,s,i)=>2*(1-e)*(s-t)+2*e*(i-s),tangentQuadraticBezier3:(e,t,s,i,r)=>-3*t*(1-e)*(1-e)+3*s*(1-e)*(1-e)-6*e*s*(1-e)+6*e*i*(1-e)-3*e*e*i+3*e*e*r,tangentSpline:e=>6*e*e-6*e+(3*e*e-4*e+1)+(-6*e*e+6*e)+(3*e*e-2*e),catmullRomInterpolate(e,t,s,i,r){const n=.5*(s-e),A=.5*(i-t),o=r*r;return(2*t-2*s+n+A)*(r*o)+(-3*t+3*s-2*n-A)*o+n*r+t},b2p0(e,t){const s=1-e;return s*s*t},b2p1:(e,t)=>2*(1-e)*e*t,b2p2:(e,t)=>e*e*t,b2(e,t,s,i){return this.b2p0(e,t)+this.b2p1(e,s)+this.b2p2(e,i)},b3p0(e,t){const s=1-e;return s*s*s*t},b3p1(e,t){const s=1-e;return 3*s*s*e*t},b3p2:(e,t)=>3*(1-e)*e*e*t,b3p3:(e,t)=>e*e*e*t,b3(e,t,s,i,r){return this.b3p0(e,t)+this.b3p1(e,s)+this.b3p2(e,i)+this.b3p3(e,r)},triangleNormal(e,t,s,i=R.vec3()){const r=t[0]-e[0],n=t[1]-e[1],A=t[2]-e[2],o=s[0]-e[0],a=s[1]-e[1],l=s[2]-e[2],c=n*l-A*a,h=A*o-r*l,u=r*a-n*o,d=Math.sqrt(c*c+h*h+u*u);return 0===d?(i[0]=0,i[1]=0,i[2]=0):(i[0]=c/d,i[1]=h/d,i[2]=u/d),i},rayTriangleIntersect:(()=>{const e=new P(3),t=new P(3),s=new P(3),i=new P(3),r=new P(3);return(n,A,o,a,l,c)=>{c=c||R.vec3();const h=R.subVec3(a,o,e),u=R.subVec3(l,o,t),d=R.cross3Vec3(A,u,s),p=R.dotVec3(h,d);if(p<1e-6)return null;const f=R.subVec3(n,o,i),g=R.dotVec3(f,d);if(g<0||g>p)return null;const m=R.cross3Vec3(f,h,r),_=R.dotVec3(A,m);if(_<0||g+_>p)return null;const b=R.dotVec3(u,m)/p;return c[0]=n[0]+b*A[0],c[1]=n[1]+b*A[1],c[2]=n[2]+b*A[2],c}})(),rayPlaneIntersect:(()=>{const e=new P(3),t=new P(3),s=new P(3),i=new P(3);return(r,n,A,o,a,l)=>{l=l||R.vec3(),n=R.normalizeVec3(n,e);const c=R.subVec3(o,A,t),h=R.subVec3(a,A,s),u=R.cross3Vec3(c,h,i);R.normalizeVec3(u,u);const d=-R.dotVec3(A,u),p=-(R.dotVec3(r,u)+d)/R.dotVec3(n,u);return l[0]=r[0]+p*n[0],l[1]=r[1]+p*n[1],l[2]=r[2]+p*n[2],l}})(),cartesianToBarycentric:(()=>{const e=new P(3),t=new P(3),s=new P(3);return(i,r,n,A,o)=>{const a=R.subVec3(A,r,e),l=R.subVec3(n,r,t),c=R.subVec3(i,r,s),h=R.dotVec3(a,a),u=R.dotVec3(a,l),d=R.dotVec3(a,c),p=R.dotVec3(l,l),f=R.dotVec3(l,c),g=h*p-u*u;if(0===g)return null;const m=1/g,_=(p*d-u*f)*m,b=(h*f-u*d)*m;return o[0]=1-_-b,o[1]=b,o[2]=_,o}})(),barycentricInsideTriangle(e){const t=e[1],s=e[2];return s>=0&&t>=0&&s+t<1},barycentricToCartesian(e,t,s,i,r=R.vec3()){const n=e[0],A=e[1],o=e[2];return r[0]=t[0]*n+s[0]*A+i[0]*o,r[1]=t[1]*n+s[1]*A+i[1]*o,r[2]=t[2]*n+s[2]*A+i[2]*o,r},mergeVertices(e,t,s,i){const r={},n=[],A=[],o=t?[]:null,a=s?[]:null,l=[];let c,h,u,d;const p=1e4;let f,g,m=0;for(f=0,g=e.length;f<g;f+=3)c=e[f],h=e[f+1],u=e[f+2],d=`${Math.round(c*p)}_${Math.round(h*p)}_${Math.round(u*p)}`,void 0===r[d]&&(r[d]=A.length/3,A.push(c),A.push(h),A.push(u),t&&(o.push(t[f]),o.push(t[f+1]),o.push(t[f+2])),s&&(a.push(s[m]),a.push(s[m+1]))),n[f/3]=r[d],m+=2;for(f=0,g=i.length;f<g;f++)l[f]=n[i[f]];const _={positions:A,indices:l};return o&&(_.normals=o),a&&(_.uv=a),_},buildNormals:(()=>{const e=new P(3),t=new P(3),s=new P(3),i=new P(3),r=new P(3),n=new P(3);return(A,o,a)=>{let l,c;const h=new Array(A.length/3);let u,d,p,f,g,m,_;for(l=0,c=o.length;l<c;l+=3){u=o[l],d=o[l+1],p=o[l+2],e[0]=A[3*u],e[1]=A[3*u+1],e[2]=A[3*u+2],t[0]=A[3*d],t[1]=A[3*d+1],t[2]=A[3*d+2],s[0]=A[3*p],s[1]=A[3*p+1],s[2]=A[3*p+2],R.subVec3(t,e,i),R.subVec3(s,e,r);const a=R.vec3();R.normalizeVec3(R.cross3Vec3(i,r,n),a),h[u]||(h[u]=[]),h[d]||(h[d]=[]),h[p]||(h[p]=[]),h[u].push(a),h[d].push(a),h[p].push(a)}for(a=a&&a.length===A.length?a:new Float32Array(A.length),l=0,c=h.length;l<c;l++){f=h[l].length,g=0,m=0,_=0;for(let e=0;e<f;e++)g+=h[l][e][0],m+=h[l][e][1],_+=h[l][e][2];a[3*l]=g/f,a[3*l+1]=m/f,a[3*l+2]=_/f}return a}})(),buildTangents:(()=>{const e=new P(3),t=new P(3),s=new P(3),i=new P(3),r=new P(3),n=new P(3),A=new P(3);return(o,a,l)=>{const c=new Float32Array(o.length);for(let h=0;h<a.length;h+=3){let u=a[h];const d=o.subarray(3*u,3*u+3),p=l.subarray(2*u,2*u+2);u=a[h+1];const f=o.subarray(3*u,3*u+3),g=l.subarray(2*u,2*u+2);u=a[h+2];const m=o.subarray(3*u,3*u+3),_=l.subarray(2*u,2*u+2),b=R.subVec3(f,d,e),B=R.subVec3(m,d,t),y=R.subVec2(g,p,s),w=R.subVec2(_,p,i),v=1/(y[0]*w[1]-y[1]*w[0]),C=R.mulVec3Scalar(R.subVec3(R.mulVec3Scalar(b,w[1],r),R.mulVec3Scalar(B,y[1],n),A),v,n);let M;for(let e=0;e<3;e++)M=3*a[h+e],c[M]+=C[0],c[M+1]+=C[1],c[M+2]+=C[2]}return c}})(),buildPickTriangles(e,t,s){const i=t.length,r=s?new Uint16Array(9*i):new Float32Array(9*i),n=new Uint8Array(12*i);let A,o,a,l,c,h,u=0,d=0,p=0;for(let s=0;s<i;s+=3)h=u>>24&255,c=u>>16&255,l=u>>8&255,a=255&u,o=t[s],A=3*o,r[d++]=e[A],r[d++]=e[A+1],r[d++]=e[A+2],n[p++]=a,n[p++]=l,n[p++]=c,n[p++]=h,o=t[s+1],A=3*o,r[d++]=e[A],r[d++]=e[A+1],r[d++]=e[A+2],n[p++]=a,n[p++]=l,n[p++]=c,n[p++]=h,o=t[s+2],A=3*o,r[d++]=e[A],r[d++]=e[A+1],r[d++]=e[A+2],n[p++]=a,n[p++]=l,n[p++]=c,n[p++]=h,u++;return{positions:r,colors:n}},faceToVertexNormals(e,t,s={}){const i=s.smoothNormalsAngleThreshold||20,r={},n=[],A={};let o,a,l,c,h;const u=1e4;let d,p,f,g,m,_;for(p=0,g=e.length;p<g;p+=3){d=p/3,a=e[p],l=e[p+1],c=e[p+2],h=`${Math.round(a*u)}_${Math.round(l*u)}_${Math.round(c*u)}`,void 0===r[h]?r[h]=[d]:r[h].push(d);const s=R.normalizeVec3([t[p],t[p+1],t[p+2]]);n[d]=s,o=R.vec4([s[0],s[1],s[2],1]),A[d]=o}for(h in r)if(r.hasOwnProperty(h)){const e=r[h],t=e.length;for(p=0;p<t;p++){const s=e[p];for(o=A[s],f=0;f<t;f++){if(p===f)continue;const t=e[f];m=n[s],_=n[t];Math.abs(R.angleVec3(m,_)/R.DEGTORAD)<i&&(o[0]+=_[0],o[1]+=_[1],o[2]+=_[2],o[3]+=1)}}}for(p=0,g=t.length;p<g;p+=3)o=A[p/3],t[p+0]=o[0]/o[3],t[p+1]=o[1]/o[3],t[p+2]=o[2]/o[3]},transformRay:(()=>{const e=new P(4),t=new P(4);return(s,i,r,n,A)=>{e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=1,R.transformVec4(s,e,t),n[0]=t[0],n[1]=t[1],n[2]=t[2],e[0]=r[0],e[1]=r[1],e[2]=r[2],R.transformVec3(s,e,t),R.normalizeVec3(t),A[0]=t[0],A[1]=t[1],A[2]=t[2]}})(),canvasPosToWorldRay:(()=>{const e=new P(16),t=new P(4),s=new P(4),i=(t,s,i,r,n)=>{n[0]=t,n[1]=s,n[2]=i,n[3]=1,R.transformVec4(e,n,n),r||R.mulVec4Scalar(n,1/n[3])};return(r,n,A,o,a,l,c)=>{const h="ortho"===o;R.mulMat4(A,n,e),R.inverseMat4(e,e);const u=2*a[0]/r.clientWidth-1,d=1-2*a[1]/r.clientHeight;i(u,d,-1,h,t),i(u,d,1,h,s),l[0]=t[0],l[1]=t[1],l[2]=t[2],R.subVec3(s,t,c),R.normalizeVec3(c)}})(),canvasPosToLocalRay:(()=>{const e=new P(3),t=new P(3);return(s,i,r,n,A,o,a,l)=>{R.canvasPosToWorldRay(s,i,r,n,o,e,t),R.worldRayToLocalRay(A,e,t,a,l)}})(),worldRayToLocalRay:(()=>{const e=new P(16),t=new P(4),s=new P(4);return(i,r,n,A,o)=>{const a=R.inverseMat4(i,e);t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=1,R.transformVec4(a,t,s),A[0]=s[0],A[1]=s[1],A[2]=s[2],R.transformVec3(a,n,o)}})(),buildKDTree:(()=>{const e=new Float32Array;function t(s,i,r,n){const A=new P(6),o={triangles:null,left:null,right:null,leaf:!1,splitDim:0,aabb:A};let a,l;for(A[0]=A[1]=A[2]=Number.POSITIVE_INFINITY,A[3]=A[4]=A[5]=Number.NEGATIVE_INFINITY,a=0,l=s.length;a<l;++a){var c=3*s[a];for(let e=0;e<3;++e){const t=3*i[c+e];r[t]<A[0]&&(A[0]=r[t]),r[t]>A[3]&&(A[3]=r[t]),r[t+1]<A[1]&&(A[1]=r[t+1]),r[t+1]>A[4]&&(A[4]=r[t+1]),r[t+2]<A[2]&&(A[2]=r[t+2]),r[t+2]>A[5]&&(A[5]=r[t+2])}}if(s.length<20||n>10)return o.triangles=s,o.leaf=!0,o;e[0]=A[3]-A[0],e[1]=A[4]-A[1],e[2]=A[5]-A[2];let h=0;e[1]>e[h]&&(h=1),e[2]>e[h]&&(h=2),o.splitDim=h;const u=(A[h]+A[h+3])/2,d=new Array(s.length);let p=0;const f=new Array(s.length);let g=0;for(a=0,l=s.length;a<l;++a){const e=i[c=3*s[a]],t=3*i[c+1],n=3*i[c+2];r[3*e+h]<=u||r[t+h]<=u||r[n+h]<=u?d[p++]=s[a]:f[g++]=s[a]}return d.length=p,f.length=g,o.left=t(d,i,r,n+1),o.right=t(f,i,r,n+1),o}return(e,s)=>{const i=e.length/3,r=new Array(i);for(let e=0;e<i;++e)r[e]=e;return t(r,e,s,0)}})(),decompressPosition(e,t,s){(s=s||e)[0]=e[0]*t[0]+t[12],s[1]=e[1]*t[5]+t[13],s[2]=e[2]*t[10]+t[14]},decompressPositions(e,t,s=new Float32Array(e.length)){for(let i=0,r=e.length;i<r;i+=3)s[i+0]=e[i+0]*t[0]+t[12],s[i+1]=e[i+1]*t[5]+t[13],s[i+2]=e[i+2]*t[10]+t[14];return s},decompressUV(e,t,s){s[0]=e[0]*t[0]+t[6],s[1]=e[1]*t[4]+t[7]},decompressUVs(e,t,s=new Float32Array(e.length)){for(let i=0,r=e.length;i<r;i+=3)s[i+0]=e[i+0]*t[0]+t[6],s[i+1]=e[i+1]*t[4]+t[7];return s},octDecodeVec2(e,t){let s=e[0],i=e[1];s=(2*s+1)/255,i=(2*i+1)/255;const r=1-Math.abs(s)-Math.abs(i);r<0&&(s=(1-Math.abs(i))*(s>=0?1:-1),i=(1-Math.abs(s))*(i>=0?1:-1));const n=Math.sqrt(s*s+i*i+r*r);return t[0]=s/n,t[1]=i/n,t[2]=r/n,t},octDecodeVec2s(e,t){for(let s=0,i=0,r=e.length;s<r;s+=2){let r=e[s+0],n=e[s+1];r=(2*r+1)/255,n=(2*n+1)/255;const A=1-Math.abs(r)-Math.abs(n);A<0&&(r=(1-Math.abs(n))*(r>=0?1:-1),n=(1-Math.abs(r))*(n>=0?1:-1));const o=Math.sqrt(r*r+n*n+A*A);t[i+0]=r/o,t[i+1]=n/o,t[i+2]=A/o,i+=3}return t}};R.buildEdgeIndices=function(){const e=[],t=[],s=[],i=[],r=[];let n=0;const A=new Uint16Array(3),o=new Uint16Array(3),a=new Uint16Array(3),l=R.vec3(),c=R.vec3(),h=R.vec3(),u=R.vec3(),d=R.vec3(),p=R.vec3(),f=R.vec3();return function(g,m,_,b){!function(r,n){const A={};let o,a,l,c;const h=Math.pow(10,4);let u,d,p=0;for(u=0,d=r.length;u<d;u+=3)o=r[u],a=r[u+1],l=r[u+2],c=Math.round(o*h)+"_"+Math.round(a*h)+"_"+Math.round(l*h),void 0===A[c]&&(A[c]=p/3,e[p++]=o,e[p++]=a,e[p++]=l),t[u/3]=A[c];for(u=0,d=n.length;u<d;u++)i[u]=t[n[u]],s[i[u]]=n[u]}(g,m),function(t,s){n=0;for(let g=0,m=t;g<m;g+=3){const t=3*i[g],m=3*i[g+1],_=3*i[g+2];s?(A[0]=e[t],A[1]=e[t+1],A[2]=e[t+2],o[0]=e[m],o[1]=e[m+1],o[2]=e[m+2],a[0]=e[_],a[1]=e[_+1],a[2]=e[_+2],R.decompressPosition(A,s,l),R.decompressPosition(o,s,c),R.decompressPosition(a,s,h)):(l[0]=e[t],l[1]=e[t+1],l[2]=e[t+2],c[0]=e[m],c[1]=e[m+1],c[2]=e[m+2],h[0]=e[_],h[1]=e[_+1],h[2]=e[_+2]),R.subVec3(h,c,u),R.subVec3(l,c,d),R.cross3Vec3(u,d,p),R.normalizeVec3(p,f);const b=r[n]||(r[n]={normal:R.vec3()});b.normal[0]=f[0],b.normal[1]=f[1],b.normal[2]=f[2],n++}}(m.length,_);const B=[],y=Math.cos(R.DEGTORAD*b),w={};let v,C,M,E,F,x,U,I,T,P,S,D=!1;for(let e=0,t=m.length;e<t;e+=3){const t=e/3;for(let s=0;s<3;s++)v=i[e+s],C=i[e+(s+1)%3],M=Math.min(v,C),E=Math.max(v,C),F=M+","+E,void 0===w[F]?w[F]={index1:M,index2:E,face1:t,face2:void 0}:w[F].face2=t}for(F in w)x=w[F],void 0!==x.face2&&(U=r[x.face1].normal,I=r[x.face2].normal,T=R.dotVec3(U,I),T>y)||(P=s[x.index1],S=s[x.index2],(!D&&P>65535||S>65535)&&(D=!0),B.push(P),B.push(S));return D?new Uint32Array(B):new Uint16Array(B)}}(),R.planeClipsPositions3=function(e,t,s,i=3){for(let r=0,n=s.length;r<n;r+=i){if(S[0]=s[r+0]-e[0],S[1]=s[r+1]-e[1],S[2]=s[r+2]-e[2],S[0]*t[0]+S[1]*t[1]+S[2]*t[2]<0)return!0}return!1},R.planeIntersectsAABB3=(e,t)=>{const s=[t[0],t[1],t[2]],i=[t[3],t[4],t[5]],r=[[s[0],s[1],s[2]],[i[0],s[1],s[2]],[s[0],i[1],s[2]],[i[0],i[1],s[2]],[s[0],s[1],i[2]],[i[0],s[1],i[2]],[s[0],i[1],i[2]],[i[0],i[1],i[2]]];let n=!1,A=!1;for(const t of r){const s=e.dist+R.dotVec3(e.dir,t);if(s>0&&(n=!0),s<0&&(A=!0),n&&A)return!0}return!1},R.makeSectionPlaneSlicer=function(){const e=R.vec2(),t=R.vec2(),s=R.vec2(),i=R.vec2(),r=R.vec3(),A=R.vec3(),o=R.vec3();R.vec3();const a=[R.vec3(),R.vec3(),R.vec3()],l=[null,null,null],c=[null,null,null],h=[null,null,null],u=[1,0,0],d=[0,1,0],p=[0,0,1],f=function(){const e=R.vec3();return(t,s)=>R.sqLenVec3(R.subVec3(t,s,e))}(),g=e=>{const t=[];for(let s=0;s<e;++s)t.push(s);return t},m=(e,t,s)=>(s[1]-e[1])*(t[0]-e[0])>(t[1]-e[1])*(s[0]-e[0]);return function(_){const b=R.vec3ApplyQuaternion(_.quaternion,u,R.vec3()),B=R.vec3ApplyQuaternion(_.quaternion,d,R.vec3()),y=R.vec3ApplyQuaternion(_.quaternion,p,R.vec3());return function(u,d={}){const p=R.subVec3(u.origin,_.pos,R.vec3()),w=R.dotVec3(y,p),v=[],C=[null],M=(e,t)=>{const s=C.length,i=new Float64Array(5);return i.set(e),t&&(R.addVec3(p,e,r),i[3]=-R.dotVec3(b,r),i[4]=R.dotVec3(B,r)),C.push(i),s},E=(e,t)=>{const s=C[e];return t[0]=s[3],t[1]=s[4],t},F=(r,n)=>{const A=r.boundingBox,o=n.boundingBox;if(A[0]<o[0]||A[1]<o[1]||A[2]>o[2]||A[3]>o[3])return!1;const a=r.endPoints,l=n.endPoints;for(let r=0,n=a.length-1;r<a.length;n=r++){const A=E(a[r],e),[o,c]=A,h=E(a[n],t);let u=!1;for(let e=0,t=l.length-1;e<l.length;t=e++){const r=E(l[e],s),n=E(l[t],i);if(m(A,r,n)!==m(h,r,n)&&m(A,h,r)!==m(A,h,n))return!1;const[a,d]=r,[p,f]=n,g=o-a,_=c-d,b=p-a,B=f-d,y=(0!==b||0!==B)&&Math.abs(b*_-B*g)<1e-10?g*b+_*B:-1;if(y>=0&&y<=Math.pow(b,2)+Math.pow(B,2))return!1;d>c!=f>c&&g<_*b/B&&(u=!u)}if(!u)return!1}return!0},x={indices:[],normals:[]},U=!d.onlyPosSliceWithUV&&{indices:[],normals:[]},I=(e,t,s)=>{if(e){const i=C[t[0]];s||=R.normalizeVec3(R.cross3Vec3(R.subVec3(C[t[1]],i,r),R.subVec3(C[t[2]],i,A),r),r);for(let i=0;i<3;++i)e.indices.push(t[i]),e.normals.push(s[0],s[1],s[2])}},T=(e,t)=>{const s=3*u.indices[e];return t[0]=u.positions[s+0],t[1]=u.positions[s+1],t[2]=u.positions[s+2],t};for(let e=0;e<u.indices.length;e+=3){const t=T(e+0,a[0]),s=T(e+1,a[1]),i=T(e+2,a[2]);if(R.compareVec3(t,s)||R.compareVec3(s,i)||R.compareVec3(i,t))continue;const n=w+R.dotVec3(y,t),A=w+R.dotVec3(y,s),o=w+R.dotVec3(y,i);if(0!==n||0!==A||0!==o){const e=n*A<=0&&M(R.lerpVec3(n/(n-A),0,1,t,s,r),!0),a=A*o<=0&&M(R.lerpVec3(A/(A-o),0,1,s,i,r),!0),u=o*n<=0&&M(R.lerpVec3(o/(o-n),0,1,i,t,r),!0),p=!d.onlyPosSliceWithUV&&c;if(p&&(p[0]=M(t),p[1]=M(s),p[2]=M(i)),e?a||u:a&&u){if(v.push(e?[e,a||u]:[a,u]),p)if(0===n&&0===A)I(o>0?x:U,p);else if(0===n&&0===o)I(A>0?x:U,p);else if(0===A&&0===o)I(n>0?x:U,p);else{const t=(e?n:A)>0,s=t?x:U,i=t?U:x,r=l;r[0]=e,r[1]=a,r[2]=u;const o=h;e?(o[0]=0,o[1]=1,o[2]=2):(o[0]=1,o[1]=2,o[2]=0),r[o[1]]?(I(s,[p[o[0]],r[o[0]],p[o[2]]]),I(s,[r[o[0]],r[o[1]],p[o[2]]]),I(i,[r[o[0]],p[o[1]],r[o[1]]])):(I(s,[p[o[0]],r[o[0]],r[o[2]]]),I(i,[r[o[0]],p[o[1]],p[o[2]]]),I(i,[r[o[0]],p[o[2]],r[o[2]]]))}}else p&&(n>=0&&A>=0&&o>=0?I(x,p):n<=0&&A<=0&&o<=0&&I(U,p))}}const P=[];for(;v.length>0;){P.push([v[0][0],v[0][1]]);const e=P[P.length-1];for(v.splice(0,1);v.length>0;){const t=C[e[e.length-1]],s={distSq:f(C[e[0]],t),idx:-1,side:-1};if(v.forEach(((e,i)=>{const r=f(C[e[0]],t),n=f(C[e[1]],t),A=Math.min(r,n);s.distSq>A&&(s.distSq=A,s.idx=i,s.side=n<r?1:0)})),!(s.distSq<1e-20)){P.pop();break}{const i=s.idx>=0&&v[s.idx];if(C[i?i[s.side]:e[0]]=t,!i)break;{v.splice(s.idx,1);const t=i[1-s.side];if(!(f(C[t],C[e[0]])>1e-20))break;e.push(t)}}}}const S=P.filter((e=>e.length>2)).map(((s,i)=>{let r=0;const n=R.collapseAABB2(R.AABB2());for(let i=0;i<s.length;i++)E(s[i],e),R.expandAABB2Point2(n,e),E(s[(i+1)%s.length],t),r+=e[0]*t[1]-t[0]*e[1];return{boundingBox:n,doubleArea:Math.abs(r),endPoints:s}})).sort(((e,t)=>t.doubleArea-e.doubleArea));for(;S.length>0;){const t=[],s=[],i=i=>i.endPoints.forEach((i=>{E(i,e),t.push(e[0],e[1]),s.push(i)})),r=S.shift();i(r);const a=[];let c=0;for(;c<S.length;){const e=S[c];F(e,r)&&a.every((t=>!F(e,t)))?(e.index=t.length/2,i(e),a.push(e),S.splice(c,1)):++c}const h=n(t,a.map((e=>e.index)));for(let e=0;e<h.length;e+=3){const t=l;t[0]=s[h[e+0]],t[1]=s[h[e+1]],t[2]=s[h[e+2]];const i=C[t[0]];R.subVec3(C[t[1]],i,A),R.subVec3(C[t[2]],i,o),R.normalizeVec3(R.cross3Vec3(A,o,o),o);const r=R.dotVec3(o,y)<=0;I(r?x:U,t,o);const n=t[0];t[0]=t[2],t[2]=n,I(r?U:x,t,R.negateVec3(o,o))}}const D=e=>e&&e.indices.length>0&&function(){const t=[],s=d.onlyPosSliceWithUV&&[];return e.indices.forEach((e=>{const i=C[e];t.push(i[0],i[1],i[2]),s&&s.push(i[3],i[4])})),{indices:g(e.indices.length),positions:t,normals:e.normals,uv:s}}();return{pos:D(x),neg:D(U)}}}}();const O=new Float32Array(3);class V{constructor(){this._head=[],this._headLength=0,this._tail=[],this._index=0,this._length=0}get length(){return this._length}shift(){if(this._index>=this._headLength){const e=this._head;if(e.length=0,this._head=this._tail,this._tail=e,this._index=0,this._headLength=this._head.length,!this._headLength)return}const e=this._head[this._index];return this._index<0?delete this._head[this._index++]:this._head[this._index++]=void 0,this._length--,e}push(e){return this._length++,this._tail.push(e),this}unshift(e){return this._head[--this._index]=e,this._length++,this}}const L={build:{version:"0.8"},client:{browser:navigator&&navigator.userAgent?navigator.userAgent:"n/a"},components:{scenes:0,models:0,meshes:0,objects:0},memory:{meshes:0,positions:0,colors:0,normals:0,uvs:0,indices:0,textures:0,transforms:0,materials:0,programs:0},frame:{frameCount:0,fps:0,useProgram:0,bindTexture:0,bindArray:0,drawElements:0,drawArrays:0,tasksRun:0,tasksScheduled:0}};var H=[["0",10],["A",26],["a",26],["_",1],["$",1]].map((function(e){for(var t=[],s=e[0].charCodeAt(0),i=s+e[1],r=s;r<i;++r)t.push(r);return String.fromCharCode.apply(null,t)})).join("");function N(e,t){return(t&&4!==t?[0,6]:[0,6,12,18]).map((function(t){return H.substr(parseInt(e/(1<<t))%64,1)})).reverse().join("")}const G=function(){for(var e={},t=window.location.search.substring(1).split("&"),s=0;s<t.length;s++){var i=t[s].split("=");if(void 0===e[i[0]])e[i[0]]=decodeURIComponent(i[1]);else if("string"==typeof e[i[0]]){var r=[e[i[0]],decodeURIComponent(i[1])];e[i[0]]=r}else e[i[0]].push(decodeURIComponent(i[1]))}return e}();const j={xmlToJson:function e(t,s){if(t.nodeType===t.TEXT_NODE){var i=t.nodeValue;if(null===i.match(/^\s+$/))return i}else if(t.nodeType===t.ELEMENT_NODE||t.nodeType===t.DOCUMENT_NODE){var r={type:t.nodeName,children:[]};if(t.nodeType===t.ELEMENT_NODE)for(var n=0;n<t.attributes.length;n++){var A=t.attributes[n];r[s[A.nodeName]||A.nodeName]=A.nodeValue}for(var o=0;o<t.childNodes.length;o++){(n=e(t.childNodes[o],s))&&r.children.push(n)}return r}},clone:function(e){return JSON.parse(JSON.stringify(e))},compressGuid:function(e){var t=[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30].map((function(t){return parseInt(e.substr(t,2),16)}));return N(t[0],2)+[1,4,7,10,13].map((function(e){return N((t[e]<<16)+(t[e+1]<<8)+t[e+2])})).join("")},findNodeOfType:function(e,t){var s=[],i=function(e){e.type===t&&s.push(e),(e.children||[]).forEach((function(e){i(e)}))};return i(e),s},timeout:function(e){return new Promise((function(t,s){setTimeout(t,e)}))},httpRequest:function(e){return new Promise((function(t,s){var i=new XMLHttpRequest;i.open(e.method||"GET",e.url,!0),i.onload=function(e){4===i.readyState&&(200===i.status?t(i.responseXML):s(i.statusText))},i.send(null)}))},loadJSON:function(e,t,s){var i=e=>{};t=t||i,s=s||i;var r=new XMLHttpRequest;r.overrideMimeType("application/json"),r.open("GET",e,!0),r.addEventListener("load",(function(e){var i=e.target.response;if(200===this.status){var r;try{r=JSON.parse(i)}catch(e){s(`utils.loadJSON(): Failed to parse JSON response - ${e}`)}t(r)}else if(0===this.status){console.warn("loadFile: HTTP Status 0 received.");try{t(JSON.parse(i))}catch(e){s(`utils.loadJSON(): Failed to parse JSON response - ${e}`)}}else s(e)}),!1),r.addEventListener("error",(function(e){s(e)}),!1),r.send(null)},loadArraybuffer:function(e,t,s){var i=e=>{};t=t||i,s=s||i;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var n=r[3];n=window.decodeURIComponent(n),e&&(n=window.atob(n));try{const e=new ArrayBuffer(n.length),s=new Uint8Array(e);for(var A=0;A<n.length;A++)s[A]=n.charCodeAt(A);q.scheduleTask((()=>{t(e)}))}catch(e){q.scheduleTask((()=>{s(e)}))}}else{const i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onreadystatechange=function(){4===i.readyState&&(200===i.status?t(i.response):s("loadArrayBuffer error : "+i.response))},i.send(null)}},queryString:G,isArray:function(e){return e&&!e.propertyIsEnumerable("length")&&"object"==typeof e&&"number"==typeof e.length},isString:function(e){return"string"==typeof e||e instanceof String},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},isID:function(e){return j.isString(e)||j.isNumeric(e)},isSameComponent:function(e,t){return!(!e||!t)&&(j.isNumeric(e)||j.isString(e)?`${e}`:e.id)===(j.isNumeric(t)||j.isString(t)?`${t}`:t.id)},isFunction:function(e){return"function"==typeof e},isObject:function(e){const t={}.constructor;return!!e&&e.constructor===t},copy:function(e){return j.apply(e,{})},apply:function(e,t){for(const s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t},apply2:function(e,t){for(const s in e)e.hasOwnProperty(s)&&void 0!==e[s]&&null!==e[s]&&(t[s]=e[s]);return t},applyIf:function(e,t){for(const s in e)e.hasOwnProperty(s)&&(void 0!==t[s]&&null!==t[s]||(t[s]=e[s]));return t},isEmptyObject:function(e){for(const t in e)if(e.hasOwnProperty(t))return!1;return!0},inQuotes:function(e){return j.isNumeric(e)?`${e}`:`'${e}'`},concat:function(e,t){const s=new e.constructor(e.length+t.length);return s.set(e),s.set(t,e.length),s},flattenParentChildHierarchy:function(e){var t=[];return function e(s){s.id=s.uuid,delete s.oid,t.push(s);var i=s.children;if(i)for(var r=0,n=i.length;r<n;r++){i[r].parent=s.id,e(i[r])}s.children=[]}(e),t}},W={},z=new e,X=new V,K={sceneId:null,time:null,startTime:null,prevTime:null,deltaTime:null},Z=[];let J,Y=0,$=0;const q=new function(){this.version="1.0.0",this.scenes={},this._superTypes={},this._addScene=function(e){if(e.id){if(q.scenes[e.id])return void console.error(`[ERROR] Scene ${j.inQuotes(e.id)} already exists`)}else e.id=z.addItem({});q.scenes[e.id]=e;const t=e.ticksPerOcclusionTest,s=e.ticksPerRender;W[e.id]={ticksPerOcclusionTest:t,ticksPerRender:s,renderCountdown:s},L.components.scenes++,e.once("destroyed",(()=>{z.removeItem(e.id),delete q.scenes[e.id],delete W[e.id],L.components.scenes--}))},this.clear=function(){let e;for(const t in q.scenes)q.scenes.hasOwnProperty(t)&&(e=q.scenes[t],"default.scene"===t?e.clear():(e.destroy(),delete q.scenes[e.id]))},this.scheduleTask=function(e,t=null){X.push(e),X.push(t)},this.runTasks=function(e=-1){let t,s,i=(new Date).getTime(),r=0;for(;X.length>0&&(e<0||i<e);)t=X.shift(),s=X.shift(),s?t.call(s):t(),i=(new Date).getTime(),r++;return r},this.getNumTasks=function(){return X.length}},ee=function(){let e=Date.now();if(J=e-Y,Y>0&&J>0){var t=1e3/J;$+=t,Z.push(t),Z.length>=30&&($-=Z.shift()),L.frame.fps=Math.round($/Z.length)}for(let e in q.scenes)q.scenes[e].compile();se(e),Y=e};!function(e,t){let s=Date.now()+t;(function i(){const r=Date.now()-s;e(),s+=t,setTimeout(i,Math.max(0,t-r))})()}((()=>{ee()}),100);const te=function(){let e=Date.now();if(J=e-Y,Y>0&&J>0){var t=1e3/J;$+=t,Z.push(t),Z.length>=30&&($-=Z.shift()),L.frame.fps=Math.round($/Z.length)}se(e),function(e){for(var t in K.time=e,q.scenes)if(q.scenes.hasOwnProperty(t)){var s=q.scenes[t];K.sceneId=t,K.startTime=s.startTime,K.deltaTime=null!=K.prevTime?K.time-K.prevTime:0,s.fire("tick",K,!0)}K.prevTime=e}(e),function(){const e=q.scenes,t=!1;let s,i,r,n,A;for(A in e)e.hasOwnProperty(A)&&(s=e[A],i=W[A],i||(i=W[A]={}),r=s.ticksPerOcclusionTest,i.ticksPerOcclusionTest!==r&&(i.ticksPerOcclusionTest=r,i.renderCountdown=r),--s.occlusionTestCountdown<=0&&(s.doOcclusionTest(),s.occlusionTestCountdown=r),n=s.ticksPerRender,i.ticksPerRender!==n&&(i.ticksPerRender=n,i.renderCountdown=n),0==--i.renderCountdown&&(s.render(t),i.renderCountdown=n))}(),void 0!==window.requestPostAnimationFrame?window.requestPostAnimationFrame(ee):requestAnimationFrame(te)};function se(e){const t=q.runTasks(e+10),s=q.getNumTasks();L.frame.tasksRun=t,L.frame.tasksScheduled=s,L.frame.tasksBudget=10}te();class ie{get type(){return"Component"}get isComponent(){return!0}constructor(e=null,t={}){if(this.scene=null,"Scene"===this.type)this.scene=this,this.viewer=t.viewer;else{if("Scene"===e.type)this.scene=e;else{if(!(e instanceof ie))throw"Invalid param: owner must be a Component";this.scene=e.scene}this._owner=e}this._dontClear=!!t.dontClear,this._renderer=this.scene._renderer,this.meta=t.meta||{},this.id=t.id,this.destroyed=!1,this._attached={},this._attachments=null,this._subIdMap=null,this._subIdEvents=null,this._eventSubs=null,this._eventSubsNum=null,this._events=null,this._eventCallDepth=0,this._ownedComponents=null,this!==this.scene&&this.scene._addComponent(this),this._updateScheduled=!1,e&&e._own(this)}glRedraw(){this._renderer&&(this._renderer.imageDirty(),this.castsShadow&&this._renderer.shadowsDirty())}glResort(){this._renderer&&this._renderer.needStateSort()}get owner(){return this._owner}isType(e){return this.type===e}fire(e,t,s){this._events||(this._events={}),this._eventSubs||(this._eventSubs={},this._eventSubsNum={}),!0!==s&&(this._events[e]=t||!0);const i=this._eventSubs[e];let r;if(i)for(const s in i)i.hasOwnProperty(s)&&(r=i[s],this._eventCallDepth++,this._eventCallDepth<300?r.callback.call(r.scope,t):this.error("fire: potential stack overflow from recursive event '"+e+"' - dropping this event"),this._eventCallDepth--)}on(t,s,i){this._events||(this._events={}),this._subIdMap||(this._subIdMap=new e),this._subIdEvents||(this._subIdEvents={}),this._eventSubs||(this._eventSubs={}),this._eventSubsNum||(this._eventSubsNum={});let r=this._eventSubs[t];r?this._eventSubsNum[t]++:(r={},this._eventSubs[t]=r,this._eventSubsNum[t]=1);const n=this._subIdMap.addItem();r[n]={callback:s,scope:i||this},this._subIdEvents[n]=t;const A=this._events[t];return void 0!==A&&s.call(i||this,A),n}off(e){if(null==e)return;if(!this._subIdEvents)return;const t=this._subIdEvents[e];if(t){delete this._subIdEvents[e];const s=this._eventSubs[t];s&&(delete s[e],this._eventSubsNum[t]--),this._subIdMap.removeItem(e)}}once(e,t,s){const i=this,r=this.on(e,(function(e){i.off(r),t.call(s||this,e)}),s)}hasSubs(e){return this._eventSubsNum&&this._eventSubsNum[e]>0}log(e){e="[LOG]"+this._message(e),window.console.log(e),this.scene.fire("log",e)}_message(e){return" ["+this.type+" "+j.inQuotes(this.id)+"]: "+e}warn(e){e="[WARN]"+this._message(e),window.console.warn(e),this.scene.fire("warn",e)}error(e){e="[ERROR]"+this._message(e),window.console.error(e),this.scene.fire("error",e)}_attach(e){const t=e.name;if(!t)return void this.error("Component 'name' expected");let s=e.component;const i=e.sceneDefault,r=e.sceneSingleton,n=e.type,A=e.on,o=!1!==e.recompiles;if(s&&(j.isNumeric(s)||j.isString(s))){const e=s;if(s=this.scene.components[e],!s)return void this.error("Component not found: "+j.inQuotes(e))}if(!s)if(!0===r){const e=this.scene.types[n];for(const t in e)if(e.hasOwnProperty){s=e[t];break}if(!s)return this.error("Scene has no default component for '"+t+"'"),null}else if(!0===i&&(s=this.scene[t],!s))return this.error("Scene has no default component for '"+t+"'"),null;if(s){if(s.scene.id!==this.scene.id)return void this.error("Not in same scene: "+s.type+" "+j.inQuotes(s.id));if(n&&!s.isType(n))return void this.error("Expected a "+n+" type or subtype: "+s.type+" "+j.inQuotes(s.id))}this._attachments||(this._attachments={});const a=this._attached[t];let l,c,h;if(a){if(s&&a.id===s.id)return;const e=this._attachments[a.id];for(l=e.subs,c=0,h=l.length;c<h;c++)a.off(l[c]);delete this._attached[t],delete this._attachments[a.id];const i=e.params.onDetached;i&&(j.isFunction(i)?i(a):i.scope?i.callback.call(i.scope,a):i.callback(a)),e.managingLifecycle&&a.destroy()}if(s){const i={params:e,component:s,subs:[],managingLifecycle:false};i.subs.push(s.once("destroyed",(function(){i.params.component=null,this._attach(i.params)}),this)),o&&i.subs.push(s.on("dirty",(function(){this.fire("dirty",this)}),this)),this._attached[t]=s,this._attachments[s.id]=i;const r=e.onAttached;if(r&&(j.isFunction(r)?r(s):r.scope?r.callback.call(r.scope,s):r.callback(s)),A){let e,t,r,n;for(e in A)if(A.hasOwnProperty(e)){if(t=A[e],j.isFunction(t)?(r=t,n=null):(r=t.callback,n=t.scope),!r)continue;i.subs.push(s.on(e,r,n))}}}return o&&this.fire("dirty",this),this.fire(t,s),s}_checkComponent(e,t){if(!t.isComponent){if(!j.isID(t))return void this.error("Expected a Component or ID");{const e=t;if(!(t=this.scene.components[e]))return void this.error("Component not found: "+e)}}if(e===t.type){if(t.scene.id===this.scene.id)return t;this.error("Not in same scene: "+t.type)}else this.error("Expected a "+e+" Component")}_checkComponent2(e,t){if(!t.isComponent){if(!j.isID(t))return void this.error("Expected a Component or ID");{const e=t;if(!(t=this.scene.components[e]))return void this.error("Component not found: "+e)}}if(t.scene.id===this.scene.id){for(var s=0,i=e.length;s<i;s++)if(e[s]===t.type)return t;return this.error("Expected component types: "+e),null}this.error("Not in same scene: "+t.type)}_own(e){this._ownedComponents||(this._ownedComponents={}),this._ownedComponents[e.id]||(this._ownedComponents[e.id]=e),e.once("destroyed",(()=>{delete this._ownedComponents[e.id]}),this)}_needUpdate(e){this._updateScheduled||(this._updateScheduled=!0,0===e?this._doUpdate():q.scheduleTask(this._doUpdate,this))}_doUpdate(){this._updateScheduled&&(this._updateScheduled=!1,this._update&&this._update())}scheduleTask(e){q.scheduleTask(e,null)}_update(){}clear(){if(this._ownedComponents)for(var e in this._ownedComponents)if(this._ownedComponents.hasOwnProperty(e)){this._ownedComponents[e].destroy(),delete this._ownedComponents[e]}}destroy(){if(this.destroyed)return;let e,t,s,i,r,n;if(this.fire("destroyed",this.destroyed=!0),this._attachments)for(e in this._attachments)if(this._attachments.hasOwnProperty(e)){for(t=this._attachments[e],s=t.component,i=t.subs,r=0,n=i.length;r<n;r++)s.off(i[r]);t.managingLifecycle&&s.destroy()}if(this._ownedComponents)for(e in this._ownedComponents)this._ownedComponents.hasOwnProperty(e)&&(s=this._ownedComponents[e],s.destroy(),delete this._ownedComponents[e]);this.scene._removeComponent(this),this._attached={},this._attachments=null,this._subIdMap=null,this._subIdEvents=null,this._eventSubs=null,this._events=null,this._eventCallDepth=0,this._ownedComponents=null,this._updateScheduled=!1}}const re=R.vec3(),ne=R.vec3(),Ae=R.mat4();class oe{constructor(){this.normal=R.vec3(),this.offset=0,this.testVertex=R.vec3()}set(e,t,s,i){const r=1/Math.sqrt(e*e+t*t+s*s);this.normal[0]=e*r,this.normal[1]=t*r,this.normal[2]=s*r,this.offset=i*r,this.testVertex[0]=this.normal[0]>=0?1:0,this.testVertex[1]=this.normal[1]>=0?1:0,this.testVertex[2]=this.normal[2]>=0?1:0}}class ae{constructor(){this.planes=[new oe,new oe,new oe,new oe,new oe,new oe]}}function le(e,t,s){const i=R.mulMat4(s,t,Ae),r=i[0],n=i[1],A=i[2],o=i[3],a=i[4],l=i[5],c=i[6],h=i[7],u=i[8],d=i[9],p=i[10],f=i[11],g=i[12],m=i[13],_=i[14],b=i[15];e.planes[0].set(o-r,h-a,f-u,b-g),e.planes[1].set(o+r,h+a,f+u,b+g),e.planes[2].set(o-n,h-l,f-d,b-m),e.planes[3].set(o+n,h+l,f+d,b+m),e.planes[4].set(o-A,h-c,f-p,b-_),e.planes[5].set(o+A,h+c,f+p,b+_)}function ce(e,t){let s=ae.INSIDE;const i=re,r=ne;i[0]=t[0],i[1]=t[1],i[2]=t[2],r[0]=t[3],r[1]=t[4],r[2]=t[5];const n=[i,r];for(let t=0;t<6;++t){const i=e.planes[t];if(i.normal[0]*n[i.testVertex[0]][0]+i.normal[1]*n[i.testVertex[1]][1]+i.normal[2]*n[i.testVertex[2]][2]+i.offset<0)return ae.OUTSIDE;i.normal[0]*n[1-i.testVertex[0]][0]+i.normal[1]*n[1-i.testVertex[1]][1]+i.normal[2]*n[1-i.testVertex[2]][2]+i.offset<0&&(s=ae.INTERSECT)}return s}ae.INSIDE=0,ae.INTERSECT=1,ae.OUTSIDE=2;class he extends ie{constructor(e={}){if(!e.viewer)throw"[MarqueePicker] Missing config: viewer";if(!e.objectsKdTree3)throw"[MarqueePicker] Missing config: objectsKdTree3";super(e.viewer.scene,e),this.viewer=e.viewer,this._objectsKdTree3=e.objectsKdTree3,this._canvasMarqueeCorner1=R.vec2(),this._canvasMarqueeCorner2=R.vec2(),this._canvasMarquee=R.AABB2(),this._marqueeFrustum=new ae,this._marqueeFrustumProjMat=R.mat4(),this._pickMode=!1,this._marqueeElement=document.createElement("div"),document.body.appendChild(this._marqueeElement),this._marqueeElement.style.position="absolute",this._marqueeElement.style["z-index"]="40000005",this._marqueeElement.style.width="8px",this._marqueeElement.style.height="8px",this._marqueeElement.style.visibility="hidden",this._marqueeElement.style.top="0px",this._marqueeElement.style.left="0px",this._marqueeElement.style["box-shadow"]="0 2px 5px 0 #182A3D;",this._marqueeElement.style.opacity=1,this._marqueeElement.style["pointer-events"]="none"}setMarqueeCorner1(e){this._canvasMarqueeCorner1.set(e),this._canvasMarqueeCorner2.set(e),this._updateMarquee()}setMarqueeCorner2(e){this._canvasMarqueeCorner2.set(e),this._updateMarquee()}setMarquee(e,t){this._canvasMarqueeCorner1.set(e),this._canvasMarqueeCorner2.set(t),this._updateMarquee()}setMarqueeVisible(e){this._marqueVisible=e,this._marqueeElement.style.visibility=e?"visible":"hidden"}getMarqueeVisible(){return this._marqueVisible}setPickMode(e){if(e!==he.PICK_MODE_INSIDE&&e!==he.PICK_MODE_INTERSECTS)throw"Illegal MarqueePicker pickMode: must be MarqueePicker.PICK_MODE_INSIDE or MarqueePicker.PICK_MODE_INTERSECTS";e!==this._pickMode&&(this._marqueeElement.style["background-image"]=e===he.PICK_MODE_INSIDE?"url(\"data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='6' ry='6' stroke='%23333' stroke-width='4'/%3e%3c/svg%3e\")":"url(\"data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='6' ry='6' stroke='%23333' stroke-width='4' stroke-dasharray='6%2c 14' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e\")",this._pickMode=e)}getPickMode(){return this._pickMode}clear(){this.fire("clear",{})}pick(){this._updateMarquee(),this._buildMarqueeFrustum();const e=[],t=(s,i=ae.INTERSECT)=>{if(i===ae.INTERSECT&&(i=ce(this._marqueeFrustum,s.aabb)),i!==ae.OUTSIDE){if(s.entities){const t=s.entities;for(let s=0,i=t.length;s<i;s++){const i=t[s];if(!i.visible)continue;const r=i.aabb;if(this._pickMode===he.PICK_MODE_INSIDE){ce(this._marqueeFrustum,r)===ae.INSIDE&&e.push(i.id)}else{ce(this._marqueeFrustum,r)!==ae.OUTSIDE&&e.push(i.id)}}}s.left&&t(s.left,i),s.right&&t(s.right,i)}};return(this._canvasMarquee[2]-this._canvasMarquee[0]>3||this._canvasMarquee[3]-this._canvasMarquee[1]>3)&&t(this._objectsKdTree3.root),this.fire("picked",e),e}_updateMarquee(){this._canvasMarquee[0]=Math.min(this._canvasMarqueeCorner1[0],this._canvasMarqueeCorner2[0]),this._canvasMarquee[1]=Math.min(this._canvasMarqueeCorner1[1],this._canvasMarqueeCorner2[1]),this._canvasMarquee[2]=Math.max(this._canvasMarqueeCorner1[0],this._canvasMarqueeCorner2[0]),this._canvasMarquee[3]=Math.max(this._canvasMarqueeCorner1[1],this._canvasMarqueeCorner2[1]),this._marqueeElement.style.width=this._canvasMarquee[2]-this._canvasMarquee[0]+"px",this._marqueeElement.style.height=this._canvasMarquee[3]-this._canvasMarquee[1]+"px",this._marqueeElement.style.left=`${this._canvasMarquee[0]}px`,this._marqueeElement.style.top=`${this._canvasMarquee[1]}px`}_buildMarqueeFrustum(){const e=this.viewer.scene.canvas.canvas,t=e.clientWidth,s=e.clientHeight,i=e.clientLeft,r=e.clientTop,n=2/t,A=2/s,o=e.clientHeight/e.clientWidth,a=(this._canvasMarquee[0]-i)*n-1,l=(this._canvasMarquee[2]-i)*n-1,c=-(this._canvasMarquee[3]-r)*A+1,h=-(this._canvasMarquee[1]-r)*A+1,u=this.viewer.scene.camera.frustum.near*(17*o);R.frustumMat4(a,l,c*o,h*o,u,1e4,this._marqueeFrustumProjMat),le(this._marqueeFrustum,this.viewer.scene.camera.viewMatrix,this._marqueeFrustumProjMat)}destroy(){super.destroy(),this._marqueeElement.parentElement&&(this._marqueeElement.parentElement.removeChild(this._marqueeElement),this._marqueeElement=null,this._objectsKdTree3=null)}}he.PICK_MODE_INTERSECTS=0,he.PICK_MODE_INSIDE=1;class ue{constructor(e,t={}){this.viewer=e,this.scene=this.viewer.scene,this._circleDiv=document.createElement("div"),this.viewer.scene.canvas.canvas.parentNode.insertBefore(this._circleDiv,this.viewer.scene.canvas.canvas),this._circleDiv.style.backgroundColor="transparent",this._circleDiv.style.border="2px solid green",this._circleDiv.style.borderRadius="50px",this._circleDiv.style.width="50px",this._circleDiv.style.height="50px",this._circleDiv.style.margin="-200px -200px",this._circleDiv.style.zIndex="100000",this._circleDiv.style.position="absolute",this._circleDiv.style.pointerEvents="none",this._circlePos=null,this._circleMaxRadius=200,this._circleMinRadius=2,this._active=!1!==t.active,this._visible=!1,this._running=!1,this._destroyed=!1}start(e){if(this._destroyed)return;this._circlePos=e,this._running=!1,this._circleRadius=this._circleMaxRadius,this._circleDiv.style.borderRadius=`${this._circleRadius}px`,this._circleDiv.style.marginLeft=this._circlePos[0]-this._circleRadius+"px",this._circleDiv.style.marginTop=this._circlePos[1]-this._circleRadius+"px";const t=this._circleMaxRadius;let s;const i=e=>{if(!this._running)return;s||(s=e);const r=e-s,n=Math.min(r/300,1),A=t+(2-t)*n;this._circleRadius=A,this._circleDiv.style.width=`${this._circleRadius}px`,this._circleDiv.style.height=`${this._circleRadius}px`,this._circleDiv.style.marginLeft=this._circlePos[0]-this._circleRadius/2+"px",this._circleDiv.style.marginTop=this._circlePos[1]-this._circleRadius/2+"px",n<1&&requestAnimationFrame(i)};this._running=!0,requestAnimationFrame(i),this._circleDiv.style.visibility="visible"}stop(){this._destroyed||(this._running=!1,this._circleRadius=this._circleMaxRadius,this._circleDiv.style.borderRadius=`${this._circleRadius}px`,this._circleDiv.style.visibility="hidden")}set durationMs(e){this.stop(),this._durationMs=e}get durationMs(){return this._durationMs}destroy(){this._destroyed||(this.stop(),this._circleDiv.parentElement.removeChild(this._circleDiv),this._destroyed=!0)}}class de{constructor(e={}){this._eventSubIDMap=null,this._eventSubEvents=null,this._eventSubs=null,this._events=null,this._locale="en",this._messages={},this._locales=[],this._locale="en",this.messages=e.messages,this.locale=e.locale}set messages(e){this._messages=e||{},this._locales=Object.keys(this._messages),this.fire("updated",this)}loadMessages(e={}){for(let t in e)this._messages[t]=e[t];this.messages=this._messages}clearMessages(){this.messages={}}get locales(){return this._locales}set locale(e){e=e||"de",this._locale!==e&&(this._locale=e,this.fire("updated",e))}get locale(){return this._locale}translate(e,t){const s=this._messages[this._locale];if(!s)return null;const i=pe(e,s);return i?t?fe(i,t):i:null}translatePlurals(e,t,s){const i=this._messages[this._locale];if(!i)return null;let r=pe(e,i);return r=0===(t=parseInt(""+t,10))?r.zero:t>1?r.other:r.one,r?(r=fe(r,[t]),s&&(r=fe(r,s)),r):null}fire(e,t,s){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==s&&(this._events[e]=t||!0);const i=this._eventSubs[e];if(i)for(const e in i)if(i.hasOwnProperty(e)){i[e].callback(t)}}on(t,s){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new e),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});let i=this._eventSubs[t];i||(i={},this._eventSubs[t]=i);const r=this._eventSubIDMap.addItem();i[r]={callback:s},this._eventSubEvents[r]=t;const n=this._events[t];return void 0!==n&&s(n),r}off(e){if(null==e)return;if(!this._eventSubEvents)return;const t=this._eventSubEvents[e];if(t){delete this._eventSubEvents[e];const s=this._eventSubs[t];s&&delete s[e],this._eventSubIDMap.removeItem(e)}}}function pe(e,t){if(t[e])return t[e];const s=e.split(".");let i=t;for(let e=0,t=s.length;i&&e<t;e++){i=i[s[e]]}return i}function fe(e,t=[]){return e.replace(/\{\{|\}\}|\{(\d+)\}/g,(function(e,s){return"{{"===e?"{":"}}"===e?"}":t[s]}))}class ge extends ie{constructor(e,t={}){super(e,t),this.t=t.t}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get tangent(){return this.getTangent(this._t)}get length(){var e=this._getLengths();return e[e.length-1]}getTangent(e){var t=1e-4;void 0===e&&(e=this._t);var s=e-t,i=e+t;s<0&&(s=0),i>1&&(i=1);var r=this.getPoint(s),n=this.getPoint(i),A=R.subVec3(n,r,[]);return R.normalizeVec3(A,[])}getPointAt(e){var t=this.getUToTMapping(e);return this.getPoint(t)}getPoints(e){e||(e=5);var t,s=[];for(t=0;t<=e;t++)s.push(this.getPoint(t/e));return s}_getLengths(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,s,i=[],r=this.getPoint(0),n=0;for(i.push(0),s=1;s<=e;s++)t=this.getPoint(s/e),n+=R.lenVec3(R.subVec3(t,r,[])),i.push(n),r=t;return this.cacheArcLengths=i,i}_updateArcLengths(){this.needsUpdate=!0,this._getLengths()}getUToTMapping(e,t){var s,i=this._getLengths(),r=0,n=i.length;s=t||e*i[n-1];for(var A,o=0,a=n-1;o<=a;)if((A=i[r=Math.floor(o+(a-o)/2)]-s)<0)o=r+1;else{if(!(A>0)){a=r;break}a=r-1}if(i[r=a]===s)return r/(n-1);var l=i[r];return(r+(s-l)/(i[r+1]-l))/(n-1)}}class me extends ge{constructor(e,t={}){super(e,t),this.points=t.points,this.t=t.t}set points(e){this._points=e||[]}get points(){return this._points}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=this.points;if(!(t.length<3)){var s=(t.length-1)*e,i=Math.floor(s),r=s-i,n=t[0===i?i:i-1],A=t[i],o=t[i>t.length-2?t.length-1:i+1],a=t[i>t.length-3?t.length-1:i+2],l=R.vec3();return l[0]=R.catmullRomInterpolate(n[0],A[0],o[0],a[0],r),l[1]=R.catmullRomInterpolate(n[1],A[1],o[1],a[1],r),l[2]=R.catmullRomInterpolate(n[2],A[2],o[2],a[2],r),l}this.error("Can't sample point from SplineCurve - not enough points on curve - returning [0,0,0].")}getJSON(){return{points:points,t:this._t}}}const _e=R.vec3();const be=R.vec3(),Be=R.vec3(),ye=R.vec3(),we=R.vec3(),ve=R.vec3();class Ce extends ie{get type(){return"CameraFlightAnimation"}constructor(e,t={}){super(e,t),this._look1=R.vec3(),this._eye1=R.vec3(),this._up1=R.vec3(),this._look2=R.vec3(),this._eye2=R.vec3(),this._up2=R.vec3(),this._orthoScale1=1,this._orthoScale2=1,this._flying=!1,this._flyEyeLookUp=!1,this._flyingEye=!1,this._flyingLook=!1,this._callback=null,this._callbackScope=null,this._time1=null,this._time2=null,this.easing=!1!==t.easing,this.duration=t.duration,this.fit=t.fit,this.fitFOV=t.fitFOV,this.trail=t.trail}flyTo(e,t,s){e=e||this.scene,this._flying&&this.stop(),this._flying=!1,this._flyingEye=!1,this._flyingLook=!1,this._flyingEyeLookUp=!1,this._callback=t,this._callbackScope=s;const i=this.scene.camera,r=!!e.projection&&e.projection!==i.projection;let n,A,o,a,l;if(this._eye1[0]=i.eye[0],this._eye1[1]=i.eye[1],this._eye1[2]=i.eye[2],this._look1[0]=i.look[0],this._look1[1]=i.look[1],this._look1[2]=i.look[2],this._up1[0]=i.up[0],this._up1[1]=i.up[1],this._up1[2]=i.up[2],this._orthoScale1=i.ortho.scale,this._orthoScale2=e.orthoScale||this._orthoScale1,e.aabb)n=e.aabb;else if(6===e.length)n=e;else if(e.eye&&e.look||e.up)A=e.eye,o=e.look,a=e.up;else if(e.eye)A=e.eye;else if(e.look)o=e.look;else{let i=e;if((j.isNumeric(i)||j.isString(i))&&(l=i,i=this.scene.components[l],!i))return this.error("Component not found: "+j.inQuotes(l)),void(t&&(s?t.call(s):t()));r||(n=i.aabb||this.scene.aabb)}const c=e.poi;if(n){if(n[3]<n[0]||n[4]<n[1]||n[5]<n[2])return;if(n[3]===n[0]&&n[4]===n[1]&&n[5]===n[2])return;n=n.slice();const t=R.getAABB3Center(n);this._look2=c||t;const s=R.subVec3(this._eye1,this._look1,be),i=R.normalizeVec3(s),r=c?R.getAABB3DiagPoint(n,c):R.getAABB3Diag(n),A=e.fitFOV||this._fitFOV,o=Math.abs(r/Math.tan(A*R.DEGTORAD));this._orthoScale2=1.1*r,this._eye2[0]=this._look2[0]+i[0]*o,this._eye2[1]=this._look2[1]+i[1]*o,this._eye2[2]=this._look2[2]+i[2]*o,this._up2[0]=this._up1[0],this._up2[1]=this._up1[1],this._up2[2]=this._up1[2],this._flyingEyeLookUp=!0}else(A||o||a)&&(this._flyingEyeLookUp=!!A&&!!o&&!!a,this._flyingEye=!!A&&!o,this._flyingLook=!!o&&!A,A&&(this._eye2[0]=A[0],this._eye2[1]=A[1],this._eye2[2]=A[2]),o&&(this._look2[0]=o[0],this._look2[1]=o[1],this._look2[2]=o[2]),a&&(this._up2[0]=a[0],this._up2[1]=a[1],this._up2[2]=a[2]));r?("ortho"===e.projection&&"ortho"!==i.projection&&(this._projection2="ortho",this._projMatrix1=i.projMatrix.slice(),this._projMatrix2=i.ortho.matrix.slice(),i.projection="customProjection"),"perspective"===e.projection&&"perspective"!==i.projection&&(this._projection2="perspective",this._projMatrix1=i.projMatrix.slice(),this._projMatrix2=i.perspective.matrix.slice(),i.projection="customProjection")):this._projection2=null,this.fire("started",e,!0),this._time1=Date.now(),this._time2=this._time1+(Number.isFinite(e.duration)?1e3*e.duration:this._duration),this._flying=!0,q.scheduleTask(this._update,this)}jumpTo(e){this._jumpTo(e)}_jumpTo(e){this._flying&&this.stop();const t=this.scene.camera;var s,i,r,n,A;if(e.aabb)s=e.aabb;else if(6===e.length)s=e;else if(e.eye||e.look||e.up)r=e.eye,n=e.look,A=e.up;else{let t=e;if((j.isNumeric(t)||j.isString(t))&&(i=t,t=this.scene.components[i],!t))return void this.error("Component not found: "+j.inQuotes(i));s=t.aabb||this.scene.aabb}const o=e.poi;if(s){if(s[3]<=s[0]||s[4]<=s[1]||s[5]<=s[2])return;var a=o?R.getAABB3DiagPoint(s,o):R.getAABB3Diag(s);let i;n=o||R.getAABB3Center(s,n),this._trail?R.subVec3(t.look,n,ve):R.subVec3(t.eye,t.look,ve),R.normalizeVec3(ve);i=(void 0!==e.fit?e.fit:this._fit)?Math.abs(a/Math.tan((e.fitFOV||this._fitFOV)*R.DEGTORAD)):R.lenVec3(R.subVec3(t.eye,t.look,be)),R.mulVec3Scalar(ve,i),t.eye=R.addVec3(n,ve,be),t.look=n,this.scene.camera.ortho.scale=1.1*a}else(r||n||A)&&(r&&(t.eye=r),n&&(t.look=n),A&&(t.up=A));e.projection&&(t.projection=e.projection)}_update(){if(!this._flying)return;let e=(Date.now()-this._time1)/(this._time2-this._time1);const t=e>=1;e>1&&(e=1);const s=this.easing?Ce._ease(e,0,1,1):e,i=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?(R.subVec3(i.eye,i.look,ve),i.eye=R.lerpVec3(s,0,1,this._eye1,this._eye2,ye),i.look=R.subVec3(ye,ve,Be)):this._flyingLook&&(i.look=R.lerpVec3(s,0,1,this._look1,this._look2,Be),i.up=R.lerpVec3(s,0,1,this._up1,this._up2,we)):this._flyingEyeLookUp&&(i.eye=R.lerpVec3(s,0,1,this._eye1,this._eye2,ye),i.look=R.lerpVec3(s,0,1,this._look1,this._look2,Be),i.up=R.lerpVec3(s,0,1,this._up1,this._up2,we)),this._projection2){const t="ortho"===this._projection2?Ce._easeOutExpo(e,0,1,1):Ce._easeInCubic(e,0,1,1);i.customProjection.matrix=R.lerpMat4(t,0,1,this._projMatrix1,this._projMatrix2)}else i.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return i.ortho.scale=this._orthoScale2,void this.stop();q.scheduleTask(this._update,this)}static _ease(e,t,s,i){return-s*(e/=i)*(e-2)+t}static _easeInCubic(e,t,s,i){return s*(e/=i)*e*e+t}static _easeOutExpo(e,t,s,i){return s*(1-Math.pow(2,-10*e/i))+t}stop(){if(!this._flying)return;this._flying=!1,this._time1=null,this._time2=null,this._projection2&&(this.scene.camera.projection=this._projection2);const e=this._callback;e&&(this._callback=null,this._callbackScope?e.call(this._callbackScope):e()),this.fire("stopped",!0,!0)}cancel(){this._flying&&(this._flying=!1,this._time1=null,this._time2=null,this._callback&&(this._callback=null),this.fire("canceled",!0,!0))}set duration(e){this._duration=Number.isFinite(e)?1e3*e:500,this.stop()}get duration(){return this._duration/1e3}set fit(e){this._fit=!1!==e}get fit(){return this._fit}set fitFOV(e){this._fitFOV=e||45}get fitFOV(){return this._fitFOV}set trail(e){this._trail=!!e}get trail(){return this._trail}destroy(){this.stop(),super.destroy()}}class Me extends ie{get type(){return"CameraPathAnimation"}constructor(e,t={}){super(e,t),this._cameraFlightAnimation=new Ce(this),this._t=0,this.state=Me.SCRUBBING,this._playingFromT=0,this._playingToT=0,this._playingRate=t.playingRate||1,this._playingDir=1,this._lastTime=null,this.cameraPath=t.cameraPath,this._tick=this.scene.on("tick",this._updateT,this)}_updateT(){const e=this._cameraPath;if(!e)return;let t,s;const i=performance.now(),r=this._lastTime?.001*(i-this._lastTime):0;if(this._lastTime=i,0!==r)switch(this.state){case Me.SCRUBBING:return;case Me.PLAYING:if(this._t+=this._playingRate*r,t=this._cameraPath.frames.length,0===t||this._playingDir<0&&this._t<=0||this._playingDir>0&&this._t>=this._cameraPath.frames[t-1].t)return this.state=Me.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case Me.PLAYING_TO:s=this._t+this._playingRate*r*this._playingDir,(this._playingDir<0&&s<=this._playingToT||this._playingDir>0&&s>=this._playingToT)&&(s=this._playingToT,this.state=Me.SCRUBBING,this.fire("stopped")),this._t=s,e.loadFrame(this._t)}}_ease(e,t,s,i){return-s*(e/=i)*(e-2)+t}set cameraPath(e){this._cameraPath=e}get cameraPath(){return this._cameraPath}set rate(e){this._playingRate=e}get rate(){return this._playingRate}play(){this._cameraPath&&(this._lastTime=null,this.state=Me.PLAYING)}playToT(e){this._cameraPath&&(this._playingFromT=this._t,this._playingToT=e,this._playingDir=this._playingToT-this._playingFromT<0?-1:1,this._lastTime=null,this.state=Me.PLAYING_TO)}playToFrame(e){const t=this._cameraPath;if(!t)return;const s=t.frames[e];s?this.playToT(s.t):this.error("playToFrame - frame index out of range: "+e)}flyToFrame(e,t){const s=this._cameraPath;if(!s)return;const i=s.frames[e];i?(this.state=Me.SCRUBBING,this._cameraFlightAnimation.flyTo(i,t)):this.error("flyToFrame - frame index out of range: "+e)}scrubToT(e){const t=this._cameraPath;if(!t)return;this.scene.camera&&(this._t=e,t.loadFrame(this._t),this.state=Me.SCRUBBING)}scrubToFrame(e){const t=this._cameraPath;if(!t)return;if(!this.scene.camera)return;t.frames[e]?(t.loadFrame(this._t),this.state=Me.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)}stop(){this.state=Me.SCRUBBING,this.fire("stopped")}destroy(){super.destroy(),this.scene.off(this._tick)}}Me.STOPPED=0,Me.SCRUBBING=1,Me.PLAYING=2,Me.PLAYING_TO=3;class Ee extends ie{get type(){return"Geometry"}get isGeometry(){return!0}constructor(e,t={}){super(e,t),L.memory.meshes++}destroy(){super.destroy(),L.memory.meshes--}}const Fe=new e({});class xe{constructor(e){this.id=Fe.addItem({});for(const t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}destroy(){Fe.removeItem(this.id)}}class Ue{constructor(e,t,s,i,r,n,A,o,a){switch(this._gl=e,this.type=t,this.allocated=!1,s.constructor){case Uint8Array:this.itemType=e.UNSIGNED_BYTE,this.itemByteSize=1;break;case Int8Array:this.itemType=e.BYTE,this.itemByteSize=1;break;case Uint16Array:this.itemType=e.UNSIGNED_SHORT,this.itemByteSize=2;break;case Int16Array:this.itemType=e.SHORT,this.itemByteSize=2;break;case Uint32Array:this.itemType=e.UNSIGNED_INT,this.itemByteSize=4;break;case Int32Array:this.itemType=e.INT,this.itemByteSize=4;break;default:this.itemType=e.FLOAT,this.itemByteSize=4}this.usage=n,this.length=0,this.dataLength=i,this.numItems=0,this.itemSize=r,this.normalized=!!A,this.stride=o||0,this.offset=a||0,this._allocate(s)}_allocate(e){if(this.allocated=!1,this._handle=this._gl.createBuffer(),!this._handle)throw"Failed to allocate WebGL ArrayBuffer";this._handle&&(this._gl.bindBuffer(this.type,this._handle),this._gl.bufferData(this.type,e.length>this.dataLength?e.slice(0,this.dataLength):e,this.usage),this._gl.bindBuffer(this.type,null),this.length=e.length,this.numItems=this.length/this.itemSize,this.allocated=!0)}setData(e,t){this.allocated&&(e.length+(t||0)>this.length?(this.destroy(),this._allocate(e)):(this._gl.bindBuffer(this.type,this._handle),t||0===t?this._gl.bufferSubData(this.type,t*this.itemByteSize,e):this._gl.bufferData(this.type,e,this.usage),this._gl.bindBuffer(this.type,null)))}bind(){this.allocated&&this._gl.bindBuffer(this.type,this._handle)}unbind(){this.allocated&&this._gl.bindBuffer(this.type,null)}bindAtLocation(e){this.bind(),this._gl.vertexAttribPointer(e,this.itemSize,this.itemType,this.normalized,0,0)}destroy(){this.allocated&&(this._gl.deleteBuffer(this._handle),this._handle=null,this.allocated=!1)}}var Ie=function(){const e=[],t=[],s=[],i=[],r=[];let n=0;const A=new Uint16Array(3),o=new Uint16Array(3),a=new Uint16Array(3),l=R.vec3(),c=R.vec3(),h=R.vec3(),u=R.vec3(),d=R.vec3(),p=R.vec3(),f=R.vec3();return function(g,m,_,b){!function(r,n){const A={};let o,a,l,c;const h=Math.pow(10,4);let u,d,p=0;for(u=0,d=r.length;u<d;u+=3)o=r[u],a=r[u+1],l=r[u+2],c=Math.round(o*h)+"_"+Math.round(a*h)+"_"+Math.round(l*h),void 0===A[c]&&(A[c]=p/3,e[p++]=o,e[p++]=a,e[p++]=l),t[u/3]=A[c];for(u=0,d=n.length;u<d;u++)i[u]=t[n[u]],s[i[u]]=n[u]}(g,m),function(t,s){n=0;for(let g=0,m=t;g<m;g+=3){const t=3*i[g],m=3*i[g+1],_=3*i[g+2];s?(A[0]=e[t],A[1]=e[t+1],A[2]=e[t+2],o[0]=e[m],o[1]=e[m+1],o[2]=e[m+2],a[0]=e[_],a[1]=e[_+1],a[2]=e[_+2],R.decompressPosition(A,s,l),R.decompressPosition(o,s,c),R.decompressPosition(a,s,h)):(l[0]=e[t],l[1]=e[t+1],l[2]=e[t+2],c[0]=e[m],c[1]=e[m+1],c[2]=e[m+2],h[0]=e[_],h[1]=e[_+1],h[2]=e[_+2]),R.subVec3(h,c,u),R.subVec3(l,c,d),R.cross3Vec3(u,d,p),R.normalizeVec3(p,f);const b=r[n]||(r[n]={normal:R.vec3()});b.normal[0]=f[0],b.normal[1]=f[1],b.normal[2]=f[2],n++}}(m.length,_);const B=[],y=Math.cos(R.DEGTORAD*b),w={};let v,C,M,E,F,x,U,I,T,P,S,D=!1;for(let e=0,t=m.length;e<t;e+=3){const t=e/3;for(let s=0;s<3;s++)v=i[e+s],C=i[e+(s+1)%3],M=Math.min(v,C),E=Math.max(v,C),F=M+","+E,void 0===w[F]?w[F]={index1:M,index2:E,face1:t,face2:void 0}:w[F].face2=t}for(F in w)x=w[F],void 0!==x.face2&&(U=r[x.face1].normal,I=r[x.face2].normal,T=R.dotVec3(U,I),T>y)||(P=s[x.index1],S=s[x.index2],(!D&&P>65535||S>65535)&&(D=!0),B.push(P),B.push(S));return D?new Uint32Array(B):new Uint16Array(B)}}();const Te=function(){const e=R.mat4(),t=R.mat4();return function(s,i){i=i||R.mat4();const r=s[0],n=s[1],A=s[2],o=s[3]-r,a=s[4]-n,l=s[5]-A,c=65535;return R.identityMat4(e),R.translationMat4v(s,e),R.identityMat4(t),R.scalingMat4v([o/c,a/c,l/c],t),R.mulMat4(e,t,i),i}}();var Pe=function(){const e=R.mat4(),t=R.mat4();return function(s,i,r){const n=new Uint16Array(s.length),A=new Float32Array([r[0]!==i[0]?65535/(r[0]-i[0]):0,r[1]!==i[1]?65535/(r[1]-i[1]):0,r[2]!==i[2]?65535/(r[2]-i[2]):0]);let o;for(o=0;o<s.length;o+=3)n[o+0]=Math.max(0,Math.min(65535,Math.floor((s[o+0]-i[0])*A[0]))),n[o+1]=Math.max(0,Math.min(65535,Math.floor((s[o+1]-i[1])*A[1]))),n[o+2]=Math.max(0,Math.min(65535,Math.floor((s[o+2]-i[2])*A[2])));R.identityMat4(e),R.translationMat4v(i,e),R.identityMat4(t),R.scalingMat4v([(r[0]-i[0])/65535,(r[1]-i[1])/65535,(r[2]-i[2])/65535],t);return{quantized:n,decodeMatrix:R.mulMat4(e,t,R.identityMat4())}}}();var Se=function(){const e=R.mat3(),t=R.mat3();return function(s,i,r){const n=new Uint16Array(s.length),A=new Float32Array([65535/(r[0]-i[0]),65535/(r[1]-i[1])]);let o;for(o=0;o<s.length;o+=2)n[o+0]=Math.max(0,Math.min(65535,Math.floor((s[o+0]-i[0])*A[0]))),n[o+1]=Math.max(0,Math.min(65535,Math.floor((s[o+1]-i[1])*A[1])));R.identityMat3(e),R.translationMat3v(i,e),R.identityMat3(t),R.scalingMat3v([(r[0]-i[0])/65535,(r[1]-i[1])/65535],t);return{quantized:n,decodeMatrix:R.mulMat3(e,t,R.identityMat3())}}}();function De(e,t,s,i){let r=e[t]/(Math.abs(e[t])+Math.abs(e[t+1])+Math.abs(e[t+2])),n=e[t+1]/(Math.abs(e[t])+Math.abs(e[t+1])+Math.abs(e[t+2]));if(e[t+2]<0){let e=(1-Math.abs(n))*(r>=0?1:-1),t=(1-Math.abs(r))*(n>=0?1:-1);r=e,n=t}return new Int8Array([Math[s](127.5*r+(r<0?-1:0)),Math[i](127.5*n+(n<0?-1:0))])}function ke(e){let t=e[0],s=e[1];t/=t<0?127:128,s/=s<0?127:128;const i=1-Math.abs(t)-Math.abs(s);i<0&&(t=(1-Math.abs(s))*(t>=0?1:-1),s=(1-Math.abs(t))*(s>=0?1:-1));const r=Math.sqrt(t*t+s*s+i*i);return[t/r,s/r,i/r]}function Qe(e,t,s){return e[t]*s[0]+e[t+1]*s[1]+e[t+2]*s[2]}const Re={getPositionsBounds:function(e){const t=new Float32Array(3),s=new Float32Array(3);let i,r;for(i=0;i<3;i++)t[i]=Number.MAX_VALUE,s[i]=-Number.MAX_VALUE;for(i=0;i<e.length;i+=3)for(r=0;r<3;r++)t[r]=Math.min(t[r],e[i+r]),s[r]=Math.max(s[r],e[i+r]);return{min:t,max:s}},createPositionsDecodeMatrix:Te,compressPositions:Pe,compressPosition:function(e,t,s){const i=new Float32Array([t[3]!==t[0]?65535/(t[3]-t[0]):0,t[4]!==t[1]?65535/(t[4]-t[1]):0,t[5]!==t[2]?65535/(t[5]-t[2]):0]);s[0]=Math.max(0,Math.min(65535,Math.floor((e[0]-t[0])*i[0]))),s[1]=Math.max(0,Math.min(65535,Math.floor((e[1]-t[1])*i[1]))),s[2]=Math.max(0,Math.min(65535,Math.floor((e[2]-t[2])*i[2])))},decompressPositions:function(e,t,s=new Float32Array(e.length)){for(let i=0,r=e.length;i<r;i+=3)s[i+0]=e[i+0]*t[0]+t[12],s[i+1]=e[i+1]*t[5]+t[13],s[i+2]=e[i+2]*t[10]+t[14];return s},decompressPosition:function(e,t,s){return s[0]=e[0]*t[0]+t[12],s[1]=e[1]*t[5]+t[13],s[2]=e[2]*t[10]+t[14],s},decompressAABB:function(e,t,s=e){return s[0]=e[0]*t[0]+t[12],s[1]=e[1]*t[5]+t[13],s[2]=e[2]*t[10]+t[14],s[3]=e[3]*t[0]+t[12],s[4]=e[4]*t[5]+t[13],s[5]=e[5]*t[10]+t[14],s},getUVBounds:function(e){const t=new Float32Array(2),s=new Float32Array(2);let i,r;for(i=0;i<2;i++)t[i]=Number.MAX_VALUE,s[i]=-Number.MAX_VALUE;for(i=0;i<e.length;i+=2)for(r=0;r<2;r++)t[r]=Math.min(t[r],e[i+r]),s[r]=Math.max(s[r],e[i+r]);return{min:t,max:s}},compressUVs:Se,decompressUVs:function(e,t,s=new Float32Array(e.length)){for(let i=0,r=e.length;i<r;i+=3)s[i+0]=e[i+0]*t[0]+t[6],s[i+1]=e[i+1]*t[4]+t[7];return s},decompressUV:function(e,t,s){s[0]=e[0]*t[0]+t[6],s[1]=e[1]*t[4]+t[7]},compressNormals:function(e){const t=new Int8Array(e.length);let s,i,r,n,A;for(let o=0;o<e.length;o+=3)r=s=De(e,o,"floor","floor"),i=ke(s),n=A=Qe(e,o,i),s=De(e,o,"ceil","floor"),i=ke(s),n=Qe(e,o,i),n>A&&(r=s,A=n),s=De(e,o,"floor","ceil"),i=ke(s),n=Qe(e,o,i),n>A&&(r=s,A=n),s=De(e,o,"ceil","ceil"),i=ke(s),n=Qe(e,o,i),n>A&&(r=s,A=n),t[o]=r[0],t[o+1]=r[1];return t},decompressNormals:function(e,t){for(let s=0,i=0,r=e.length;s<r;s+=2){let r=e[s+0],n=e[s+1];r=(2*r+1)/255,n=(2*n+1)/255;const A=1-Math.abs(r)-Math.abs(n);A<0&&(r=(1-Math.abs(n))*(r>=0?1:-1),n=(1-Math.abs(r))*(n>=0?1:-1));const o=Math.sqrt(r*r+n*n+A*A);t[i+0]=r/o,t[i+1]=n/o,t[i+2]=A/o,i+=3}return t},decompressNormal:function(e,t){let s=e[0],i=e[1];s=(2*s+1)/255,i=(2*i+1)/255;const r=1-Math.abs(s)-Math.abs(i);r<0&&(s=(1-Math.abs(i))*(s>=0?1:-1),i=(1-Math.abs(s))*(i>=0?1:-1));const n=Math.sqrt(s*s+i*i+r*r);return t[0]=s/n,t[1]=i/n,t[2]=r/n,t}},Oe=L.memory,Ve=R.AABB3();class Le extends Ee{get type(){return"ReadableGeometry"}get isReadableGeometry(){return!0}constructor(e,t={}){super(e,t),this._state=new xe({compressGeometry:!!t.compressGeometry,primitive:null,primitiveName:null,positions:null,normals:null,colors:null,uv:null,indices:null,positionsDecodeMatrix:null,uvDecodeMatrix:null,positionsBuf:null,normalsBuf:null,colorsbuf:null,uvBuf:null,indicesBuf:null,hash:""}),this._numTriangles=0,this._edgeThreshold=t.edgeThreshold||10,this._edgeIndicesBuf=null,this._pickTrianglePositionsBuf=null,this._pickTriangleColorsBuf=null,this._aabbDirty=!0,this._boundingSphere=!0,this._aabb=null,this._aabbDirty=!0,this._obb=null,this._obbDirty=!0;const s=this._state,i=this.scene.canvas.gl;switch(t.primitive=t.primitive||"triangles",t.primitive){case"points":s.primitive=i.POINTS,s.primitiveName=t.primitive;break;case"lines":s.primitive=i.LINES,s.primitiveName=t.primitive;break;case"line-loop":s.primitive=i.LINE_LOOP,s.primitiveName=t.primitive;break;case"line-strip":s.primitive=i.LINE_STRIP,s.primitiveName=t.primitive;break;case"triangles":s.primitive=i.TRIANGLES,s.primitiveName=t.primitive;break;case"triangle-strip":s.primitive=i.TRIANGLE_STRIP,s.primitiveName=t.primitive;break;case"triangle-fan":s.primitive=i.TRIANGLE_FAN,s.primitiveName=t.primitive;break;default:this.error("Unsupported value for 'primitive': '"+t.primitive+"' - supported values are 'points', 'lines', 'line-loop', 'line-strip', 'triangles', 'triangle-strip' and 'triangle-fan'. Defaulting to 'triangles'."),s.primitive=i.TRIANGLES,s.primitiveName=t.primitive}if(t.positions)if(this._state.compressGeometry){const e=Re.getPositionsBounds(t.positions),i=Re.compressPositions(t.positions,e.min,e.max);s.positions=i.quantized,s.positionsDecodeMatrix=i.decodeMatrix}else s.positions=t.positions.constructor===Float32Array?t.positions:new Float32Array(t.positions);if(t.colors&&(s.colors=t.colors.constructor===Float32Array?t.colors:new Float32Array(t.colors)),t.uv)if(this._state.compressGeometry){const e=Re.getUVBounds(t.uv),i=Re.compressUVs(t.uv,e.min,e.max);s.uv=i.quantized,s.uvDecodeMatrix=i.decodeMatrix}else s.uv=t.uv.constructor===Float32Array?t.uv:new Float32Array(t.uv);if(t.normals&&(this._state.compressGeometry?s.normals=Re.compressNormals(t.normals):s.normals=t.normals.constructor===Float32Array?t.normals:new Float32Array(t.normals)),t.indices&&(s.indices=t.indices.constructor===Uint32Array||t.indices.constructor===Uint16Array?t.indices:new Uint32Array(t.indices),"triangles"===this._state.primitiveName&&(this._numTriangles=t.indices.length/3)),this._buildHash(),Oe.meshes++,s.indices&&(s.indicesBuf=new Ue(i,i.ELEMENT_ARRAY_BUFFER,s.indices,s.indices.length,1,i.STATIC_DRAW),Oe.indices+=s.indicesBuf.numItems),s.positions&&(s.positionsBuf=new Ue(i,i.ARRAY_BUFFER,s.positions,s.positions.length,3,i.STATIC_DRAW),Oe.positions+=s.positionsBuf.numItems),s.normals){let e=s.compressGeometry;s.normalsBuf=new Ue(i,i.ARRAY_BUFFER,s.normals,s.normals.length,3,i.STATIC_DRAW,e),Oe.normals+=s.normalsBuf.numItems}s.colors&&(s.colorsBuf=new Ue(i,i.ARRAY_BUFFER,s.colors,s.colors.length,4,i.STATIC_DRAW),Oe.colors+=s.colorsBuf.numItems),s.uv&&(s.uvBuf=new Ue(i,i.ARRAY_BUFFER,s.uv,s.uv.length,2,i.STATIC_DRAW),Oe.uvs+=s.uvBuf.numItems)}_buildHash(){const e=this._state,t=["/g"];t.push("/"+e.primitive+";"),e.positions&&t.push("p"),e.colors&&t.push("c"),(e.normals||e.autoVertexNormals)&&t.push("n"),e.uv&&t.push("u"),e.compressGeometry&&t.push("cp"),t.push(";"),e.hash=t.join("")}_getEdgeIndices(){return this._edgeIndicesBuf||this._buildEdgeIndices(),this._edgeIndicesBuf}_getPickTrianglePositions(){return this._pickTrianglePositionsBuf||this._buildPickTriangleVBOs(),this._pickTrianglePositionsBuf}_getPickTriangleColors(){return this._pickTriangleColorsBuf||this._buildPickTriangleVBOs(),this._pickTriangleColorsBuf}_buildEdgeIndices(){const e=this._state;if(!e.positions||!e.indices)return;const t=this.scene.canvas.gl,s=Ie(e.positions,e.indices,e.positionsDecodeMatrix,this._edgeThreshold);this._edgeIndicesBuf=new Ue(t,t.ELEMENT_ARRAY_BUFFER,s,s.length,1,t.STATIC_DRAW),Oe.indices+=this._edgeIndicesBuf.numItems}_buildPickTriangleVBOs(){const e=this._state;if(!e.positions||!e.indices)return;const t=this.scene.canvas.gl,s=R.buildPickTriangles(e.positions,e.indices,e.compressGeometry),i=s.positions,r=s.colors;this._pickTrianglePositionsBuf=new Ue(t,t.ARRAY_BUFFER,i,i.length,3,t.STATIC_DRAW),this._pickTriangleColorsBuf=new Ue(t,t.ARRAY_BUFFER,r,r.length,4,t.STATIC_DRAW,!0),Oe.positions+=this._pickTrianglePositionsBuf.numItems,Oe.colors+=this._pickTriangleColorsBuf.numItems}_buildPickVertexVBOs(){}get primitive(){return this._state.primitiveName}get compressGeometry(){return this._state.compressGeometry}get positions(){return this._state.positions?this._state.compressGeometry?(this._decompressedPositions||(this._decompressedPositions=new Float32Array(this._state.positions.length),Re.decompressPositions(this._state.positions,this._state.positionsDecodeMatrix,this._decompressedPositions)),this._decompressedPositions):this._state.positions:null}set positions(e){const t=this._state,s=t.positions;if(s)if(s.length===e.length){if(this._state.compressGeometry){const s=Re.getPositionsBounds(e),i=Re.compressPositions(e,s.min,s.max);e=i.quantized,t.positionsDecodeMatrix=i.decodeMatrix}s.set(e),t.positionsBuf&&t.positionsBuf.setData(s),this._setAABBDirty(),this.glRedraw()}else this.error("can't update geometry positions - new positions are wrong length");else this.error("can't update geometry positions - geometry has no positions")}get normals(){if(this._state.normals){if(!this._state.compressGeometry)return this._state.normals;if(!this._decompressedNormals){const e=this._state.normals.length,t=e+e/2;this._decompressedNormals=new Float32Array(t),Re.decompressNormals(this._state.normals,this._decompressedNormals)}return this._decompressedNormals}}set normals(e){if(this._state.compressGeometry)return void this.error("can't update geometry normals - quantized geometry is immutable");const t=this._state,s=t.normals;s?s.length===e.length?(s.set(e),t.normalsBuf&&t.normalsBuf.setData(s),this.glRedraw()):this.error("can't update geometry normals - new normals are wrong length"):this.error("can't update geometry normals - geometry has no normals")}get uv(){return this._state.uv?this._state.compressGeometry?(this._decompressedUV||(this._decompressedUV=new Float32Array(this._state.uv.length),Re.decompressUVs(this._state.uv,this._state.uvDecodeMatrix,this._decompressedUV)),this._decompressedUV):this._state.uv:null}set uv(e){if(this._state.compressGeometry)return void this.error("can't update geometry UVs - quantized geometry is immutable");const t=this._state,s=t.uv;s?s.length===e.length?(s.set(e),t.uvBuf&&t.uvBuf.setData(s),this.glRedraw()):this.error("can't update geometry UVs - new UVs are wrong length"):this.error("can't update geometry UVs - geometry has no UVs")}get colors(){return this._state.colors}set colors(e){if(this._state.compressGeometry)return void this.error("can't update geometry colors - quantized geometry is immutable");const t=this._state,s=t.colors;s?s.length===e.length?(s.set(e),t.colorsBuf&&t.colorsBuf.setData(s),this.glRedraw()):this.error("can't update geometry colors - new colors are wrong length"):this.error("can't update geometry colors - geometry has no colors")}get indices(){return this._state.indices}get aabb(){return this._aabbDirty&&(this._aabb||(this._aabb=R.AABB3()),R.positions3ToAABB3(this._state.positions,this._aabb,this._state.positionsDecodeMatrix),this._aabbDirty=!1),this._aabb}get obb(){return this._obbDirty&&(this._obb||(this._obb=R.OBB3()),R.positions3ToAABB3(this._state.positions,Ve,this._state.positionsDecodeMatrix),R.AABB3ToOBB3(Ve,this._obb),this._obbDirty=!1),this._obb}_getMetrics(){if(!("_metrics"in this))switch(this._state.primitiveName){case"solid":case"surface":case"triangles":{const e=this._state.indices,t=this._state.positions,s=(s,i)=>{const r=3*e[s];for(let e=0;e<3;++e)i[e]=t[r+e];return i},i=[R.vec3(),R.vec3(),R.vec3(),R.vec3()];let r=0;const n=R.vec3([0,0,0]);for(let t=0;t<e.length;t+=3){const e=s(t,i[0]),A=s(t+1,i[1]),o=s(t+2,i[2]);R.addVec3(e,A,i[3]),R.addVec3(o,i[3],i[3]);const a=R.lenVec3(R.cross3Vec3(R.subVec3(A,e,i[1]),R.subVec3(o,e,i[2]),i[0]))/2;r+=a,R.mulVec3Scalar(i[3],a,i[3]),R.addVec3(n,i[3],n)}this._metrics={surfaceArea:r,centroid:R.mulVec3Scalar(n,1/r/3,n)};break}default:this._metrics={surfaceArea:0}}return this._metrics}get surfaceArea(){return this._getMetrics().surfaceArea}get centroid(){return this._getMetrics().centroid}get numTriangles(){return this._numTriangles}_setAABBDirty(){this._aabbDirty||(this._aabbDirty=!0,this._aabbDirty=!0,this._obbDirty=!0)}_getState(){return this._state}destroy(){super.destroy();const e=this._state;e.indicesBuf&&e.indicesBuf.destroy(),e.positionsBuf&&e.positionsBuf.destroy(),e.normalsBuf&&e.normalsBuf.destroy(),e.uvBuf&&e.uvBuf.destroy(),e.colorsBuf&&e.colorsBuf.destroy(),this._edgeIndicesBuf&&this._edgeIndicesBuf.destroy(),this._pickTrianglePositionsBuf&&this._pickTrianglePositionsBuf.destroy(),this._pickTriangleColorsBuf&&this._pickTriangleColorsBuf.destroy(),this._pickVertexPositionsBuf&&this._pickVertexPositionsBuf.destroy(),this._pickVertexColorsBuf&&this._pickVertexColorsBuf.destroy(),e.destroy(),Oe.meshes--}}const He=L.memory,Ne=R.AABB3();class Ge extends Ee{get type(){return"VBOGeometry"}get isVBOGeometry(){return!0}constructor(e,t={}){super(e,t),this._state=new xe({compressGeometry:!0,primitive:null,primitiveName:null,positionsDecodeMatrix:null,uvDecodeMatrix:null,positionsBuf:null,normalsBuf:null,colorsbuf:null,uvBuf:null,indicesBuf:null,hash:""}),this._numTriangles=0,this._edgeThreshold=t.edgeThreshold||10,this._aabb=null,this._obb=R.OBB3();const s=this._state,i=this.scene.canvas.gl;switch(t.primitive=t.primitive||"triangles",t.primitive){case"points":s.primitive=i.POINTS,s.primitiveName=t.primitive;break;case"lines":s.primitive=i.LINES,s.primitiveName=t.primitive;break;case"line-loop":s.primitive=i.LINE_LOOP,s.primitiveName=t.primitive;break;case"line-strip":s.primitive=i.LINE_STRIP,s.primitiveName=t.primitive;break;case"triangles":s.primitive=i.TRIANGLES,s.primitiveName=t.primitive;break;case"triangle-strip":s.primitive=i.TRIANGLE_STRIP,s.primitiveName=t.primitive;break;case"triangle-fan":s.primitive=i.TRIANGLE_FAN,s.primitiveName=t.primitive;break;default:this.error("Unsupported value for 'primitive': '"+t.primitive+"' - supported values are 'points', 'lines', 'line-loop', 'line-strip', 'triangles', 'triangle-strip' and 'triangle-fan'. Defaulting to 'triangles'."),s.primitive=i.TRIANGLES,s.primitiveName=t.primitive}if(t.positions)if(t.indices){var r;if(t.positionsDecodeMatrix);else{const e=Re.getPositionsBounds(t.positions),n=Re.compressPositions(t.positions,e.min,e.max);r=n.quantized,s.positionsDecodeMatrix=n.decodeMatrix,s.positionsBuf=new Ue(i,i.ARRAY_BUFFER,r,r.length,3,i.STATIC_DRAW),He.positions+=s.positionsBuf.numItems,R.positions3ToAABB3(t.positions,this._aabb),R.positions3ToAABB3(r,Ne,s.positionsDecodeMatrix),R.AABB3ToOBB3(Ne,this._obb)}if(t.colors){const e=t.colors.constructor===Float32Array?t.colors:new Float32Array(t.colors);s.colorsBuf=new Ue(i,i.ARRAY_BUFFER,e,e.length,4,i.STATIC_DRAW),He.colors+=s.colorsBuf.numItems}if(t.uv){const e=Re.getUVBounds(t.uv),r=Re.compressUVs(t.uv,e.min,e.max),n=r.quantized;s.uvDecodeMatrix=r.decodeMatrix,s.uvBuf=new Ue(i,i.ARRAY_BUFFER,n,n.length,2,i.STATIC_DRAW),He.uvs+=s.uvBuf.numItems}if(t.normals){const e=Re.compressNormals(t.normals);let r=s.compressGeometry;s.normalsBuf=new Ue(i,i.ARRAY_BUFFER,e,e.length,3,i.STATIC_DRAW,r),He.normals+=s.normalsBuf.numItems}{const e=t.indices.constructor===Uint32Array||t.indices.constructor===Uint16Array?t.indices:new Uint32Array(t.indices);s.indicesBuf=new Ue(i,i.ELEMENT_ARRAY_BUFFER,e,e.length,1,i.STATIC_DRAW),He.indices+=s.indicesBuf.numItems;const n=Ie(r,e,s.positionsDecodeMatrix,this._edgeThreshold);this._edgeIndicesBuf=new Ue(i,i.ELEMENT_ARRAY_BUFFER,n,n.length,1,i.STATIC_DRAW),"triangles"===this._state.primitiveName&&(this._numTriangles=t.indices.length/3)}this._buildHash(),He.meshes++}else this.error("Config expected: indices");else this.error("Config expected: positions")}_buildHash(){const e=this._state,t=["/g"];t.push("/"+e.primitive+";"),e.positionsBuf&&t.push("p"),e.colorsBuf&&t.push("c"),(e.normalsBuf||e.autoVertexNormals)&&t.push("n"),e.uvBuf&&t.push("u"),t.push("cp"),t.push(";"),e.hash=t.join("")}_getEdgeIndices(){return this._edgeIndicesBuf}get primitive(){return this._state.primitiveName}get aabb(){return this._aabb}get obb(){return this._obb}get numTriangles(){return this._numTriangles}_getState(){return this._state}destroy(){super.destroy();const e=this._state;e.indicesBuf&&e.indicesBuf.destroy(),e.positionsBuf&&e.positionsBuf.destroy(),e.normalsBuf&&e.normalsBuf.destroy(),e.uvBuf&&e.uvBuf.destroy(),e.colorsBuf&&e.colorsBuf.destroy(),this._edgeIndicesBuf&&this._edgeIndicesBuf.destroy(),e.destroy(),He.meshes--}}var je={};function We(e={}){let t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);let s=e.ySize||1;s<0&&(console.error("negative ySize not allowed - will invert"),s*=-1);let i=e.zSize||1;i<0&&(console.error("negative zSize not allowed - will invert"),i*=-1);const r=e.center,n=r?r[0]:0,A=r?r[1]:0,o=r?r[2]:0,a=-t+n,l=-s+A,c=-i+o,h=t+n,u=s+A,d=i+o;return j.apply(e,{positions:[h,u,d,a,u,d,a,l,d,h,l,d,h,u,d,h,l,d,h,l,c,h,u,c,h,u,d,h,u,c,a,u,c,a,u,d,a,u,d,a,u,c,a,l,c,a,l,d,a,l,c,h,l,c,h,l,d,a,l,d,h,l,c,a,l,c,a,u,c,h,u,c],normals:[0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1],uv:[1,0,0,0,0,1,1,1,0,0,0,1,1,1,1,0,1,1,1,0,0,0,0,1,1,0,0,0,0,1,1,1,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]})}function ze(e={}){let t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);let s=e.ySize||1;s<0&&(console.error("negative ySize not allowed - will invert"),s*=-1);let i=e.zSize||1;i<0&&(console.error("negative zSize not allowed - will invert"),i*=-1);const r=e.center,n=r?r[0]:0,A=r?r[1]:0,o=r?r[2]:0,a=-t+n,l=-s+A,c=-i+o,h=t+n,u=s+A,d=i+o;return j.apply(e,{primitive:"lines",positions:[a,l,c,a,l,d,a,u,c,a,u,d,h,l,c,h,l,d,h,u,c,h,u,d],indices:[0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,4,1,5,2,6,3,7]})}function Xe(e={}){let t=e.radiusTop||1;t<0&&(console.error("negative radiusTop not allowed - will invert"),t*=-1);let s=e.radiusBottom||1;s<0&&(console.error("negative radiusBottom not allowed - will invert"),s*=-1);let i=e.height||1;i<0&&(console.error("negative height not allowed - will invert"),i*=-1);let r=e.radialSegments||32;r<0&&(console.error("negative radialSegments not allowed - will invert"),r*=-1),r<3&&(r=3);let n=e.heightSegments||1;n<0&&(console.error("negative heightSegments not allowed - will invert"),n*=-1),n<1&&(n=1);const A=!!e.openEnded;let o=e.center;const a=o?o[0]:0,l=o?o[1]:0,c=o?o[2]:0,h=i/2,u=i/n,d=2*Math.PI/r,p=1/r,f=(t-s)/n,g=[],m=[],_=[],b=[];let B,y,w,v,C,M,E,F,x,U,I;const T=(90-180*Math.atan(i/(s-t))/Math.PI)/90;for(B=0;B<=n;B++)for(C=t-B*f,M=h-B*u,y=0;y<=r;y++)w=Math.sin(y*d),v=Math.cos(y*d),m.push(C*w),m.push(T),m.push(C*v),_.push(y*p),_.push(1*B/n),g.push(C*w+a),g.push(M+l),g.push(C*v+c);for(B=0;B<n;B++)for(y=0;y<=r;y++)E=B*(r+1)+y,F=E+r,b.push(E),b.push(F),b.push(F+1),b.push(E),b.push(F+1),b.push(E+1);if(!A&&t>0){for(x=g.length/3,m.push(0),m.push(1),m.push(0),_.push(.5),_.push(.5),g.push(0+a),g.push(h+l),g.push(0+c),y=0;y<=r;y++)w=Math.sin(y*d),v=Math.cos(y*d),U=.5*Math.sin(y*d)+.5,I=.5*Math.cos(y*d)+.5,m.push(t*w),m.push(1),m.push(t*v),_.push(U),_.push(I),g.push(t*w+a),g.push(h+l),g.push(t*v+c);for(y=0;y<r;y++)o=x,E=x+1+y,b.push(E),b.push(E+1),b.push(o)}if(!A&&s>0){for(x=g.length/3,m.push(0),m.push(-1),m.push(0),_.push(.5),_.push(.5),g.push(0+a),g.push(0-h+l),g.push(0+c),y=0;y<=r;y++)w=Math.sin(y*d),v=Math.cos(y*d),U=.5*Math.sin(y*d)+.5,I=.5*Math.cos(y*d)+.5,m.push(s*w),m.push(-1),m.push(s*v),_.push(U),_.push(I),g.push(s*w+a),g.push(0-h+l),g.push(s*v+c);for(y=0;y<r;y++)o=x,E=x+1+y,b.push(o),b.push(E+1),b.push(E)}return j.apply(e,{positions:g,normals:m,uv:_,indices:b})}function Ke(e={}){let t=e.size||1;t<0&&(console.error("negative size not allowed - will invert"),t*=-1);let s=e.divisions||1;s<0&&(console.error("negative divisions not allowed - will invert"),s*=-1),s<1&&(s=1),t=t||10,s=s||10;const i=t/s,r=t/2,n=[],A=[];let o=0;for(let e=0,t=-r;e<=s;e++,t+=i)n.push(-r),n.push(0),n.push(t),n.push(r),n.push(0),n.push(t),n.push(t),n.push(0),n.push(-r),n.push(t),n.push(0),n.push(r),A.push(o++),A.push(o++),A.push(o++),A.push(o++);return j.apply(e,{primitive:"lines",positions:n,indices:A})}function Ze(e={}){let t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);let s=e.zSize||1;s<0&&(console.error("negative zSize not allowed - will invert"),s*=-1);let i=e.xSegments||1;i<0&&(console.error("negative xSegments not allowed - will invert"),i*=-1),i<1&&(i=1);let r=e.xSegments||1;r<0&&(console.error("negative zSegments not allowed - will invert"),r*=-1),r<1&&(r=1);const n=e.center,A=n?n[0]:0,o=n?n[1]:0,a=n?n[2]:0,l=t/2,c=s/2,h=Math.floor(i)||1,u=Math.floor(r)||1,d=h+1,p=u+1,f=t/h,g=s/u,m=new Float32Array(d*p*3),_=new Float32Array(d*p*3),b=new Float32Array(d*p*2);let B,y,w,v,C,M,E,F=0,x=0;for(B=0;B<p;B++){const e=B*g-c;for(y=0;y<d;y++)w=y*f-l,m[F]=w+A,m[F+1]=o,m[F+2]=-e+a,_[F+1]=1,b[x]=y/h,b[x+1]=(u-B)/u,F+=3,x+=2}F=0;const U=new(m.length/3>65535?Uint32Array:Uint16Array)(h*u*6);for(B=0;B<u;B++)for(y=0;y<h;y++)v=y+d*B,C=y+d*(B+1),M=y+1+d*(B+1),E=y+1+d*B,U[F]=E,U[F+1]=C,U[F+2]=v,U[F+3]=E,U[F+4]=M,U[F+5]=C,F+=6;return j.apply(e,{positions:m,normals:_,uv:b,indices:U})}function Je(e={}){const t=e.lod||1,s=e.center?e.center[0]:0,i=e.center?e.center[1]:0,r=e.center?e.center[2]:0;let n=e.radius||1;n<0&&(console.error("negative radius not allowed - will invert"),n*=-1);let A=e.heightSegments||18;A<0&&(console.error("negative heightSegments not allowed - will invert"),A*=-1),A=Math.floor(t*A),A<18&&(A=18);let o=e.widthSegments||18;o<0&&(console.error("negative widthSegments not allowed - will invert"),o*=-1),o=Math.floor(t*o),o<18&&(o=18);const a=[],l=[],c=[],h=[];let u,d,p,f,g,m,_,b,B,y,w,v,C,M,E;for(u=0;u<=A;u++)for(p=u*Math.PI/A,f=Math.sin(p),g=Math.cos(p),d=0;d<=o;d++)m=2*d*Math.PI/o,_=Math.sin(m),b=Math.cos(m),B=b*f,y=g,w=_*f,v=1-d/o,C=u/A,l.push(B),l.push(y),l.push(w),c.push(v),c.push(C),a.push(s+n*B),a.push(i+n*y),a.push(r+n*w);for(u=0;u<A;u++)for(d=0;d<o;d++)M=u*(o+1)+d,E=M+o+1,h.push(M+1),h.push(E+1),h.push(E),h.push(M+1),h.push(E),h.push(M);return j.apply(e,{positions:a,normals:l,uv:c,indices:h})}function Ye(e={}){let t=e.radius||1;t<0&&(console.error("negative radius not allowed - will invert"),t*=-1),t*=.5;let s=e.tube||.3;s<0&&(console.error("negative tube not allowed - will invert"),s*=-1);let i=e.radialSegments||32;i<0&&(console.error("negative radialSegments not allowed - will invert"),i*=-1),i<4&&(i=4);let r=e.tubeSegments||24;r<0&&(console.error("negative tubeSegments not allowed - will invert"),r*=-1),r<4&&(r=4);let n=e.arc||2*Math.PI;n<0&&(console.warn("negative arc not allowed - will invert"),n*=-1),n>360&&(n=360);const A=e.center;let o=A?A[0]:0,a=A?A[1]:0;const l=A?A[2]:0,c=[],h=[],u=[],d=[];let p,f,g,m,_,b,B,y,w,v,C,M;for(y=0;y<=r;y++)for(B=0;B<=i;B++)p=B/i*n,f=.785398+y/r*Math.PI*2,o=t*Math.cos(p),a=t*Math.sin(p),g=(t+s*Math.cos(f))*Math.cos(p),m=(t+s*Math.cos(f))*Math.sin(p),_=s*Math.sin(f),c.push(g+o),c.push(m+a),c.push(_+l),u.push(1-B/i),u.push(y/r),b=R.normalizeVec3(R.subVec3([g,m,_],[o,a,l],[]),[]),h.push(b[0]),h.push(b[1]),h.push(b[2]);for(y=1;y<=r;y++)for(B=1;B<=i;B++)w=(i+1)*y+B-1,v=(i+1)*(y-1)+B-1,C=(i+1)*(y-1)+B,M=(i+1)*y+B,d.push(w),d.push(v),d.push(C),d.push(C),d.push(M),d.push(w);return j.apply(e,{positions:c,normals:h,uv:u,indices:d})}je.load=function(e,t){var s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="arraybuffer",s.onload=function(e){t(e.target.response)},s.send()},je.save=function(e,t){var s="data:application/octet-stream;base64,"+btoa(je.parse._buffToStr(e));window.location.href=s},je.clone=function(e){return JSON.parse(JSON.stringify(e))},je.bin={},je.bin.f=new Float32Array(1),je.bin.fb=new Uint8Array(je.bin.f.buffer),je.bin.rf=function(e,t){for(var s=je.bin.f,i=je.bin.fb,r=0;r<4;r++)i[r]=e[t+r];return s[0]},je.bin.rsl=function(e,t){return e[t]|e[t+1]<<8},je.bin.ril=function(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},je.bin.rASCII0=function(e,t){for(var s="";0!=e[t];)s+=String.fromCharCode(e[t++]);return s},je.bin.wf=function(e,t,s){new Float32Array(e.buffer,t,1)[0]=s},je.bin.wsl=function(e,t,s){e[t]=s,e[t+1]=s>>8},je.bin.wil=function(e,t,s){e[t]=s,e[t+1]=s>>8,e[t+2]=s>>16,e[t+3]},je.parse={},je.parse._buffToStr=function(e){for(var t=new Uint8Array(e),s="",i=0;i<t.length;i++)s=s.concat(String.fromCharCode(t[i]));return s},je.parse._strToBuff=function(e){for(var t=new ArrayBuffer(e.length),s=new Uint8Array(t),i=0;i<e.length;i++)s[i]=e.charCodeAt(i);return t},je.parse._readLine=function(e,t){for(var s="";10!=e[t];)s+=String.fromCharCode(e[t++]);return s},je.parse.fromJSON=function(e){return JSON.parse(je.parse._buffToStr(e))},je.parse.toJSON=function(e){var t=JSON.stringify(e);return je.parse._strToBuff(t)},je.parse.fromOBJ=function(e){for(var t={groups:{},c_verts:[],c_uvt:[],c_norms:[],i_verts:[],i_uvt:[],i_norms:[]},s={from:0,to:0},i=0,r=new Uint8Array(e);i<r.length;){var n=je.parse._readLine(r,i);i+=n.length+1;var A=(n=(n=n.replace(/ +(?= )/g,"")).replace(/(^\s+|\s+$)/g,"")).split(" ");if("g"==A[0]&&(s.to=t.i_verts.length,null==t.groups[A[1]]&&(t.groups[A[1]]={from:t.i_verts.length,to:0}),s=t.groups[A[1]]),"v"==A[0]){var o=parseFloat(A[1]),a=parseFloat(A[2]),l=parseFloat(A[3]);t.c_verts.push(o,a,l)}if("vt"==A[0]){o=parseFloat(A[1]),a=1-parseFloat(A[2]);t.c_uvt.push(o,a)}if("vn"==A[0]){o=parseFloat(A[1]),a=parseFloat(A[2]),l=parseFloat(A[3]);t.c_norms.push(o,a,l)}if("f"==A[0]){var c=A[1].split("/"),h=A[2].split("/"),u=A[3].split("/"),d=parseInt(c[0])-1,p=parseInt(h[0])-1,f=parseInt(u[0])-1,g=parseInt(c[1])-1,m=parseInt(h[1])-1,_=parseInt(u[1])-1,b=parseInt(c[2])-1,B=parseInt(h[2])-1,y=parseInt(u[2])-1,w=t.c_verts.length/3,v=t.c_uvt.length/2,C=t.c_norms.length/3;if(d<0&&(d=w+d+1),p<0&&(p=w+p+1),f<0&&(f=w+f+1),g<0&&(g=v+g+1),m<0&&(m=v+m+1),_<0&&(_=v+_+1),b<0&&(b=C+b+1),B<0&&(B=C+B+1),y<0&&(y=C+y+1),t.i_verts.push(d,p,f),t.i_uvt.push(g,m,_),t.i_norms.push(b,B,y),5==A.length){var M=A[4].split("/"),E=parseInt(M[0])-1,F=parseInt(M[1])-1,x=parseInt(M[2])-1;E<0&&(E=w+E+1),F<0&&(F=v+F+1),x<0&&(x=C+x+1),t.i_verts.push(d,f,E),t.i_uvt.push(g,_,F),t.i_norms.push(b,y,x)}}}return s.to=t.i_verts.length,t},je.parse.fromMD2=function(e){e=new Uint8Array(e);var t={},s={};s.ident=je.bin.ril(e,0),s.version=je.bin.ril(e,4),s.skinwidth=je.bin.ril(e,8),s.skinheight=je.bin.ril(e,12),s.framesize=je.bin.ril(e,16),s.num_skins=je.bin.ril(e,20),s.num_vertices=je.bin.ril(e,24),s.num_st=je.bin.ril(e,28),s.num_tris=je.bin.ril(e,32),s.num_glcmds=je.bin.ril(e,36),s.num_frames=je.bin.ril(e,40),s.offset_skins=je.bin.ril(e,44),s.offset_st=je.bin.ril(e,48),s.offset_tris=je.bin.ril(e,52),s.offset_frames=je.bin.ril(e,56),s.offset_glcmds=je.bin.ril(e,60),s.offset_end=je.bin.ril(e,64);var i=s.offset_st;t.c_uvt=[];for(var r=0;r<s.num_st;r++){var n=je.bin.rsl(e,i)/s.skinwidth,A=je.bin.rsl(e,i+2)/s.skinheight;t.c_uvt.push(n,A),i+=4}i=s.offset_tris;var o=[],a=[];t.i_verts=o,t.i_uvt=a;for(r=0;r<s.num_tris;r++)o.push(je.bin.rsl(e,i),je.bin.rsl(e,i+2),je.bin.rsl(e,i+4)),a.push(je.bin.rsl(e,i+6),je.bin.rsl(e,i+8),je.bin.rsl(e,i+10)),i+=12;i=s.offset_skins;t.skins=[];for(r=0;r<s.num_skins;r++)t.skins.push(je.bin.rASCII0(e,i)),i+=64;i=s.offset_frames;t.frames=[];var l=je.parse.fromMD2._normals;for(r=0;r<s.num_frames;r++){var c={},h=je.bin.rf(e,i),u=je.bin.rf(e,i+4),d=je.bin.rf(e,i+8);i+=12;var p=je.bin.rf(e,i),f=je.bin.rf(e,i+4),g=je.bin.rf(e,i+8);i+=12,c.name=je.bin.rASCII0(e,i),i+=16,c.verts=[],c.norms=[];for(var m=0;m<s.num_vertices;m++)c.verts.push(e[i]*h+p,e[i+1]*u+f,e[i+2]*d+g),c.norms.push(l[3*e[i+3]],l[3*e[i+3]+1],l[3*e[i+3]+2]),i+=4;t.frames.push(c)}return t},je.parse.fromMD2._normals=[-.525731,0,.850651,-.442863,.238856,.864188,-.295242,0,.955423,-.309017,.5,.809017,-.16246,.262866,.951056,0,0,1,0,.850651,.525731,-.147621,.716567,.681718,.147621,.716567,.681718,0,.525731,.850651,.309017,.5,.809017,.525731,0,.850651,.295242,0,.955423,.442863,.238856,.864188,.16246,.262866,.951056,-.681718,.147621,.716567,-.809017,.309017,.5,-.587785,.425325,.688191,-.850651,.525731,0,-.864188,.442863,.238856,-.716567,.681718,.147621,-.688191,.587785,.425325,-.5,.809017,.309017,-.238856,.864188,.442863,-.425325,.688191,.587785,-.716567,.681718,-.147621,-.5,.809017,-.309017,-.525731,.850651,0,0,.850651,-.525731,-.238856,.864188,-.442863,0,.955423,-.295242,-.262866,.951056,-.16246,0,1,0,0,.955423,.295242,-.262866,.951056,.16246,.238856,.864188,.442863,.262866,.951056,.16246,.5,.809017,.309017,.238856,.864188,-.442863,.262866,.951056,-.16246,.5,.809017,-.309017,.850651,.525731,0,.716567,.681718,.147621,.716567,.681718,-.147621,.525731,.850651,0,.425325,.688191,.587785,.864188,.442863,.238856,.688191,.587785,.425325,.809017,.309017,.5,.681718,.147621,.716567,.587785,.425325,.688191,.955423,.295242,0,1,0,0,.951056,.16246,.262866,.850651,-.525731,0,.955423,-.295242,0,.864188,-.442863,.238856,.951056,-.16246,.262866,.809017,-.309017,.5,.681718,-.147621,.716567,.850651,0,.525731,.864188,.442863,-.238856,.809017,.309017,-.5,.951056,.16246,-.262866,.525731,0,-.850651,.681718,.147621,-.716567,.681718,-.147621,-.716567,.850651,0,-.525731,.809017,-.309017,-.5,.864188,-.442863,-.238856,.951056,-.16246,-.262866,.147621,.716567,-.681718,.309017,.5,-.809017,.425325,.688191,-.587785,.442863,.238856,-.864188,.587785,.425325,-.688191,.688191,.587785,-.425325,-.147621,.716567,-.681718,-.309017,.5,-.809017,0,.525731,-.850651,-.525731,0,-.850651,-.442863,.238856,-.864188,-.295242,0,-.955423,-.16246,.262866,-.951056,0,0,-1,.295242,0,-.955423,.16246,.262866,-.951056,-.442863,-.238856,-.864188,-.309017,-.5,-.809017,-.16246,-.262866,-.951056,0,-.850651,-.525731,-.147621,-.716567,-.681718,.147621,-.716567,-.681718,0,-.525731,-.850651,.309017,-.5,-.809017,.442863,-.238856,-.864188,.16246,-.262866,-.951056,.238856,-.864188,-.442863,.5,-.809017,-.309017,.425325,-.688191,-.587785,.716567,-.681718,-.147621,.688191,-.587785,-.425325,.587785,-.425325,-.688191,0,-.955423,-.295242,0,-1,0,.262866,-.951056,-.16246,0,-.850651,.525731,0,-.955423,.295242,.238856,-.864188,.442863,.262866,-.951056,.16246,.5,-.809017,.309017,.716567,-.681718,.147621,.525731,-.850651,0,-.238856,-.864188,-.442863,-.5,-.809017,-.309017,-.262866,-.951056,-.16246,-.850651,-.525731,0,-.716567,-.681718,-.147621,-.716567,-.681718,.147621,-.525731,-.850651,0,-.5,-.809017,.309017,-.238856,-.864188,.442863,-.262866,-.951056,.16246,-.864188,-.442863,.238856,-.809017,-.309017,.5,-.688191,-.587785,.425325,-.681718,-.147621,.716567,-.442863,-.238856,.864188,-.587785,-.425325,.688191,-.309017,-.5,.809017,-.147621,-.716567,.681718,-.425325,-.688191,.587785,-.16246,-.262866,.951056,.442863,-.238856,.864188,.16246,-.262866,.951056,.309017,-.5,.809017,.147621,-.716567,.681718,0,-.525731,.850651,.425325,-.688191,.587785,.587785,-.425325,.688191,.688191,-.587785,.425325,-.955423,.295242,0,-.951056,.16246,.262866,-1,0,0,-.850651,0,.525731,-.955423,-.295242,0,-.951056,-.16246,.262866,-.864188,.442863,-.238856,-.951056,.16246,-.262866,-.809017,.309017,-.5,-.864188,-.442863,-.238856,-.951056,-.16246,-.262866,-.809017,-.309017,-.5,-.681718,.147621,-.716567,-.681718,-.147621,-.716567,-.850651,0,-.525731,-.688191,.587785,-.425325,-.587785,.425325,-.688191,-.425325,.688191,-.587785,-.425325,-.688191,-.587785,-.587785,-.425325,-.688191,-.688191,-.587785,-.425325],je.parse.fromCollada=function(e){var t=je.parse._buffToStr(e),s=(new DOMParser).parseFromString(t,"text/xml"),i={},r=(s=s.childNodes[0]).getElementsByTagName("asset")[0],n=s.getElementsByTagName("library_geometries")[0],A=s.getElementsByTagName("library_images")[0],o=s.getElementsByTagName("library_materials")[0],a=s.getElementsByTagName("library_effects")[0];return r&&(i.asset=je.parse.fromCollada._asset(r)),n&&(i.geometries=je.parse.fromCollada._libGeometries(n)),A&&(i.images=je.parse.fromCollada._libImages(A)),o&&(i.materials=je.parse.fromCollada._libMaterials(o)),a&&(i.effects=je.parse.fromCollada._libEffects(a)),i},je.parse.fromCollada._asset=function(e){return{created:e.getElementsByTagName("created")[0].textContent,modified:e.getElementsByTagName("modified")[0].textContent,up_axis:e.getElementsByTagName("up_axis")[0].textContent}},je.parse.fromCollada._libGeometries=function(e){e=e.getElementsByTagName("geometry");for(var t=[],s=0;s<e.length;s++){var i=e[s],r=je.parse.fromCollada._getMesh(i.getElementsByTagName("mesh")[0]);t.push(r)}return t},je.parse.fromCollada._getMesh=function(e){for(var t={},s=e.getElementsByTagName("source"),i=t.sources={},r=0;r<s.length;r++){for(var n=s[r].getElementsByTagName("float_array")[0].textContent.split(" "),A=n.length-(""==n[n.length-1]?1:0),o=new Array(A),a=0;a<A;a++)o[a]=parseFloat(n[a]);i[s[r].getAttribute("id")]=o}t.triangles=[];var l=e.getElementsByTagName("triangles");if(null==l)return t;for(r=0;r<l.length;r++){var c={},h=l[r];c.material=h.getAttribute("material");var u=h.getElementsByTagName("input"),d=[];for(a=0;a<u.length;a++){var p=u[a];o=[];d[parseInt(p.getAttribute("offset"))]=o;var f=p.getAttribute("semantic");c["s_"+f]="VERTEX"==f?e.getElementsByTagName("vertices")[0].getElementsByTagName("input")[0].getAttribute("source").substring(1):p.getAttribute("source").substring(1),c["i_"+f]=o,i[c["s_"+f]]}var g=h.getElementsByTagName("p")[0].textContent.split(" "),m=3*Math.floor(g.length/3);for(a=0;a<m;a++)d[a%u.length].push(parseInt(g[a]));t.triangles.push(c)}return t},je.parse.fromCollada._libImages=function(e){e=e.getElementsByTagName("image");for(var t={},s=0;s<e.length;s++)t[e[s].getAttribute("id")]=e[s].getElementsByTagName("init_from")[0].textContent;return t},je.parse.fromCollada._libMaterials=function(e){e=e.getElementsByTagName("material");for(var t={},s=0;s<e.length;s++)t[e[s].getAttribute("name")]=e[s].getElementsByTagName("instance_effect")[0].getAttribute("url").substring(1);return t},je.parse.fromCollada._libEffects=function(e){e=e.getElementsByTagName("effect");for(var t={},s=0;s<e.length;s++){for(var i={},r=e[s].getElementsByTagName("newparam"),n=0;n<r.length;n++){var A=r[n].getElementsByTagName("surface")[0];A&&(i.surface=A.getElementsByTagName("init_from")[0].textContent)}t[e[s].getAttribute("id")]=i}return t},je.parse.from3DS=function(e){e=new Uint8Array(e);var t={};if(19789!=je.bin.rsl(e,0))return null;for(var s=je.bin.ril(e,2),i=6;i<s;){var r=je.bin.rsl(e,i),n=je.bin.ril(e,i+2);15677==r&&(t.edit=je.parse.from3DS._edit3ds(e,i,n)),45056==r&&(t.keyf=je.parse.from3DS._keyf3ds(e,i,n)),i+=n}return t},je.parse.from3DS._edit3ds=function(e,t,s){for(var i={},r=t+6;r<t+s;){var n=je.bin.rsl(e,r),A=je.bin.ril(e,r+2);16384==n&&(null==i.objects&&(i.objects=[]),i.objects.push(je.parse.from3DS._edit_object(e,r,A))),r+=A}return i},je.parse.from3DS._keyf3ds=function(e,t,s){for(var i={},r=t+6;r<t+s;){var n=je.bin.rsl(e,r),A=je.bin.ril(e,r+2);45058==n&&(null==i.desc&&(i.desc=[]),i.desc.push(je.parse.from3DS._keyf_objdes(e,r,A))),r+=A}return i},je.parse.from3DS._keyf_objdes=function(e,t,s){for(var i={},r=t+6;r<t+s;){var n=je.bin.rsl(e,r),A=je.bin.ril(e,r+2);45072==n&&(i.hierarchy=je.parse.from3DS._keyf_objhierarch(e,r,A)),45073==n&&(i.dummy_name=je.bin.rASCII0(e,r+6)),r+=A}return i},je.parse.from3DS._keyf_objhierarch=function(e,t,s){var i={},r=t+6;return i.name=je.bin.rASCII0(e,r),r+=i.name.length+1,i.hierarchy=je.bin.rsl(e,r+4),i},je.parse.from3DS._edit_object=function(e,t,s){var i={},r=t+6;for(i.name=je.bin.rASCII0(e,r),r+=i.name.length+1;r<t+s;){var n=je.bin.rsl(e,r),A=je.bin.ril(e,r+2);16640==n&&(i.mesh=je.parse.from3DS._obj_trimesh(e,r,A)),r+=A}return i},je.parse.from3DS._obj_trimesh=function(e,t,s){for(var i={},r=t+6;r<t+s;){var n=je.bin.rsl(e,r),A=je.bin.ril(e,r+2);16656==n&&(i.vertices=je.parse.from3DS._tri_vertexl(e,r,A)),16672==n&&(i.indices=je.parse.from3DS._tri_facel1(e,r,A)),16704==n&&(i.uvt=je.parse.from3DS._tri_mappingcoors(e,r,A)),16736==n&&(i.local=je.parse.from3DS._tri_local(e,r,A)),r+=A}return i},je.parse.from3DS._tri_vertexl=function(e,t,s){var i=[],r=t+6,n=je.bin.rsl(e,r);r+=2;for(var A=0;A<n;A++)i.push(je.bin.rf(e,r)),i.push(je.bin.rf(e,r+4)),i.push(je.bin.rf(e,r+8)),r+=12;return i},je.parse.from3DS._tri_facel1=function(e,t,s){var i=[],r=t+6,n=je.bin.rsl(e,r);r+=2;for(var A=0;A<n;A++)i.push(je.bin.rsl(e,r)),i.push(je.bin.rsl(e,r+2)),i.push(je.bin.rsl(e,r+4)),r+=8;return i},je.parse.from3DS._tri_mappingcoors=function(e,t,s){var i=[],r=t+6,n=je.bin.rsl(e,r);r+=2;for(var A=0;A<n;A++)i.push(je.bin.rf(e,r)),i.push(1-je.bin.rf(e,r+4)),r+=8;return i},je.parse.from3DS._tri_local=function(e,t,s){var i={},r=t+6;return i.X=[je.bin.rf(e,r),je.bin.rf(e,r+4),je.bin.rf(e,r+8)],r+=12,i.Y=[je.bin.rf(e,r),je.bin.rf(e,r+4),je.bin.rf(e,r+8)],r+=12,i.Z=[je.bin.rf(e,r),je.bin.rf(e,r+4),je.bin.rf(e,r+8)],r+=12,i.C=[je.bin.rf(e,r),je.bin.rf(e,r+4),je.bin.rf(e,r+8)],r+=12,i},je.parse.fromBIV=function(e){e=new Uint8Array(e);var t={},s={};return s.id=je.bin.ril(e,0),s.verS=je.bin.ril(e,4),s.texS=je.bin.ril(e,8),s.indS=je.bin.ril(e,12),s.verO=je.bin.ril(e,16),s.verL=je.bin.ril(e,20),s.texO=je.bin.ril(e,24),s.texL=je.bin.ril(e,28),s.indO=je.bin.ril(e,32),s.indL=je.bin.ril(e,36),0!=s.verO&&(t.vertices=je.parse.fromBIV._readFloats(e,s.verO,s.verL)),0!=s.texO&&(t.uvt=je.parse.fromBIV._readFloats(e,s.texO,s.texL)),0!=s.indO&&(t.indices=je.parse.fromBIV._readInts(e,s.indO,s.indL,s.indS)),t},je.parse.toBIV=function(e){for(var t=0,s=0;s<e.indices.length;s++)t=Math.max(t,e.indices[s]);var i=32;t<=65535&&(i=16);var r=40;e.vertices&&(r+=4*e.vertices.length),e.uvt&&(r+=4*e.uvt.length),e.indices&&(r+=e.indices.length*i/8);var n=new Uint8Array(r);je.bin.wil(n,0,1769365870),je.bin.wil(n,4,32),je.bin.wil(n,8,32),je.bin.wil(n,12,i);var A=40;return e.vertices&&(je.bin.wil(n,16,A),je.bin.wil(n,20,4*e.vertices.length),je.parse.fromBIV._writeFloats(n,A,e.vertices),A+=4*e.vertices.length),e.uvt&&(je.bin.wil(n,24,A),je.bin.wil(n,28,4*e.uvt.length),je.parse.fromBIV._writeFloats(n,A,e.uvt),A+=4*e.uvt.length),e.indices&&(je.bin.wil(n,32,A),je.bin.wil(n,36,4*e.indices.length),je.parse.fromBIV._writeInts(n,A,e.indices,i)),n.buffer},je.parse.fromBIV._readFloats=function(e,t,s){for(var i=[],r=0;r<s/4;r++)i.push(je.bin.rf(e,t+4*r));return i},je.parse.fromBIV._writeFloats=function(e,t,s){for(var i=0;i<s.length;i++)je.bin.wf(e,t+4*i,s[i])},je.parse.fromBIV._readInts=function(e,t,s,i){for(var r=[],n=0;n<s/4;n++)16==i&&r.push(je.bin.rsl(e,t+2*n)),32==i&&r.push(je.bin.ril(e,t+4*n));return r},je.parse.fromBIV._writeInts=function(e,t,s,i){for(var r=0;r<s.length;r++)16==i&&je.bin.wsl(e,t+2*r,s[r]),32==i&&je.bin.wil(e,t+4*r,s[r])},je.gen={},je.gen.Plane=function(e,t,s,i){s||(s=1),i||(i=1);for(var r={verts:[],inds:[],uvt:[]},n=e+1,A=t+1,o=0;o<A;o++)for(var a=0;a<n;a++){var l=a*(2/e)-1,c=o*(2/t)-1;r.verts.push(l,c,0),r.uvt.push(s*a/e,i*o/t),o<t&&a<e&&r.inds.push(o*n+a,o*n+a+1,(o+1)*n+a,o*n+a+1,(o+1)*n+a,(o+1)*n+a+1)}return r},je.gen.Cube=function(){return{verts:[-1,1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,1,-1,1,1,-1,-1,-1,1,-1,1,1,-1,-1,1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,-1,1,1,-1,1],inds:[0,1,2,1,2,3,4,5,6,5,6,7,8,9,10,9,10,11,12,13,14,13,14,15,16,17,18,17,18,19,20,21,22,21,22,23],uvt:[1/4,1/4,.5,1/4,1/4,.5,.5,.5,1,1/4,3/4,1/4,1,.5,3/4,.5,0,1/4,1/4,1/4,0,.5,1/4,.5,3/4,1/4,.5,1/4,3/4,.5,.5,.5,1/4,1/4,.5,1/4,1/4,0,.5,0,1/4,.5,.5,.5,1/4,3/4,.5,3/4]}},je.gen.Sphere=function(e,t){for(var s={verts:[],inds:[],uvt:[]},i=e+1,r=t+1,n=0;n<r;n++)for(var A=0;A<i;A++){var o=-Math.PI/2+n*Math.PI/t,a=2*A*Math.PI/e,l=Math.cos(o)*Math.cos(a),c=Math.sin(o),h=Math.cos(o)*Math.sin(a);s.verts.push(l,c,h),s.uvt.push(A/e,n/t),n<t&&A<e&&s.inds.push(i*n+A,i*n+A+1,i*(n+1)+A,i*n+A+1,i*(n+1)+A,i*(n+1)+A+1)}return s},je.mat={},je.mat.scale=function(e,t,s){return[e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1]},je.mat.translate=function(e,t,s){return[1,0,0,0,0,1,0,0,0,0,1,0,e,t,s,1]},je.mat.rotateDeg=function(e,t,s){var i=Math.PI/180;return je.mat.rotate(e*i,t*i,s*i)},je.mat.rotate=function(e,t,s){var i=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r=e,n=t,A=s,o=Math.cos(r),a=Math.cos(n),l=Math.cos(A),c=Math.sin(r),h=Math.sin(n),u=Math.sin(A);return i[0]=a*l,i[1]=-a*u,i[2]=h,i[4]=o*u+c*h*l,i[5]=o*l-c*h*u,i[6]=-c*a,i[8]=c*u-o*h*l,i[9]=c*l+o*h*u,i[10]=o*a,i},je.edit={},je.edit.interpolate=function(e,t,s,i){for(var r=0;r<e.length;r++)s[r]=e[r]+i*(t[r]-e[r])},je.edit.transform=function(e,t){for(var s=0;s<e.length;s+=3){var i=e[s],r=e[s+1],n=e[s+2];e[s+0]=t[0]*i+t[4]*r+t[8]*n+t[12],e[s+1]=t[1]*i+t[5]*r+t[9]*n+t[13],e[s+2]=t[2]*i+t[6]*r+t[10]*n+t[14]}},je.edit.unwrap=function(e,t,s){for(var i=new Array(Math.floor(e.length/3)*s),r=0;r<e.length;r++)for(var n=0;n<s;n++)i[r*s+n]=t[e[r]*s+n];return i},je.edit.remap=function(e,t,s,i){for(var r=new Array(s.length),n=0;n<e.length;n++)for(var A=0;A<i;A++)r[t[n]*i+A]=s[e[n]*i+A];return r},je.utils={},je.utils.getAABB=function(e){var t,s,i,r,n,A;r=n=A=-(t=s=i=999999999);for(var o=0;o<e.length;o+=3){var a=e[o+0],l=e[o+1],c=e[o+2];a<t&&(t=a),a>r&&(r=a),l<s&&(s=l),l>n&&(n=l),c<i&&(i=c),l>A&&(A=c)}return{min:{x:t,y:s,z:i},max:{x:r,y:n,z:A}}};const $e={" ":{width:16,points:[]},"!":{width:10,points:[[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},'"':{width:16,points:[[4,21],[4,14],[-1,-1],[12,21],[12,14]]},"#":{width:21,points:[[11,25],[4,-7],[-1,-1],[17,25],[10,-7],[-1,-1],[4,12],[18,12],[-1,-1],[3,6],[17,6]]},$:{width:20,points:[[8,25],[8,-4],[-1,-1],[12,25],[12,-4],[-1,-1],[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},"%":{width:24,points:[[21,21],[3,0],[-1,-1],[8,21],[10,19],[10,17],[9,15],[7,14],[5,14],[3,16],[3,18],[4,20],[6,21],[8,21],[10,20],[13,19],[16,19],[19,20],[21,21],[-1,-1],[17,7],[15,6],[14,4],[14,2],[16,0],[18,0],[20,1],[21,3],[21,5],[19,7],[17,7]]},"&":{width:26,points:[[23,12],[23,13],[22,14],[21,14],[20,13],[19,11],[17,6],[15,3],[13,1],[11,0],[7,0],[5,1],[4,2],[3,4],[3,6],[4,8],[5,9],[12,13],[13,14],[14,16],[14,18],[13,20],[11,21],[9,20],[8,18],[8,16],[9,13],[11,10],[16,3],[18,1],[20,0],[22,0],[23,1],[23,2]]},"'":{width:10,points:[[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]]},"(":{width:14,points:[[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]]},")":{width:14,points:[[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]]},"*":{width:16,points:[[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]]},"+":{width:26,points:[[13,18],[13,0],[-1,-1],[4,9],[22,9]]},",":{width:10,points:[[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"-":{width:26,points:[[4,9],[22,9]]},".":{width:10,points:[[5,2],[4,1],[5,0],[6,1],[5,2]]},"/":{width:22,points:[[20,25],[2,-7]]},0:{width:20,points:[[9,21],[6,20],[4,17],[3,12],[3,9],[4,4],[6,1],[9,0],[11,0],[14,1],[16,4],[17,9],[17,12],[16,17],[14,20],[11,21],[9,21]]},1:{width:20,points:[[6,17],[8,18],[11,21],[11,0]]},2:{width:20,points:[[4,16],[4,17],[5,19],[6,20],[8,21],[12,21],[14,20],[15,19],[16,17],[16,15],[15,13],[13,10],[3,0],[17,0]]},3:{width:20,points:[[5,21],[16,21],[10,13],[13,13],[15,12],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},4:{width:20,points:[[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]]},5:{width:20,points:[[15,21],[5,21],[4,12],[5,13],[8,14],[11,14],[14,13],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},6:{width:20,points:[[16,18],[15,20],[12,21],[10,21],[7,20],[5,17],[4,12],[4,7],[5,3],[7,1],[10,0],[11,0],[14,1],[16,3],[17,6],[17,7],[16,10],[14,12],[11,13],[10,13],[7,12],[5,10],[4,7]]},7:{width:20,points:[[17,21],[7,0],[-1,-1],[3,21],[17,21]]},8:{width:20,points:[[8,21],[5,20],[4,18],[4,16],[5,14],[7,13],[11,12],[14,11],[16,9],[17,7],[17,4],[16,2],[15,1],[12,0],[8,0],[5,1],[4,2],[3,4],[3,7],[4,9],[6,11],[9,12],[13,13],[15,14],[16,16],[16,18],[15,20],[12,21],[8,21]]},9:{width:20,points:[[16,14],[15,11],[13,9],[10,8],[9,8],[6,9],[4,11],[3,14],[3,15],[4,18],[6,20],[9,21],[10,21],[13,20],[15,18],[16,14],[16,9],[15,4],[13,1],[10,0],[8,0],[5,1],[4,3]]},":":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},";":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"<":{width:24,points:[[20,18],[4,9],[20,0]]},"=":{width:26,points:[[4,12],[22,12],[-1,-1],[4,6],[22,6]]},">":{width:24,points:[[4,18],[20,9],[4,0]]},"?":{width:18,points:[[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]]},"@":{width:27,points:[[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]]},A:{width:18,points:[[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]]},B:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]]},C:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]]},D:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]]},E:{width:19,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]]},F:{width:18,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]]},G:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]]},H:{width:22,points:[[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]]},I:{width:8,points:[[4,21],[4,0]]},J:{width:16,points:[[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]]},K:{width:21,points:[[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]]},L:{width:17,points:[[4,21],[4,0],[-1,-1],[4,0],[16,0]]},M:{width:24,points:[[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]]},N:{width:22,points:[[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]]},O:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]]},P:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]]},Q:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]]},R:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]]},S:{width:20,points:[[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},T:{width:16,points:[[8,21],[8,0],[-1,-1],[1,21],[15,21]]},U:{width:22,points:[[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]]},V:{width:18,points:[[1,21],[9,0],[-1,-1],[17,21],[9,0]]},W:{width:24,points:[[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]]},X:{width:20,points:[[3,21],[17,0],[-1,-1],[17,21],[3,0]]},Y:{width:18,points:[[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]]},Z:{width:20,points:[[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]]},"[":{width:14,points:[[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]]},"\\":{width:14,points:[[0,21],[14,-3]]},"]":{width:14,points:[[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]]},"^":{width:16,points:[[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]]},_:{width:16,points:[[0,-2],[16,-2]]},"`":{width:10,points:[[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]]},a:{width:19,points:[[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},b:{width:19,points:[[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},c:{width:18,points:[[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},d:{width:19,points:[[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},e:{width:18,points:[[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},f:{width:12,points:[[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]]},g:{width:19,points:[[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},h:{width:19,points:[[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},i:{width:8,points:[[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]]},j:{width:10,points:[[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]]},k:{width:17,points:[[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]]},l:{width:8,points:[[4,21],[4,0]]},m:{width:30,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]]},n:{width:19,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},o:{width:19,points:[[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]]},p:{width:19,points:[[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},q:{width:19,points:[[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},r:{width:13,points:[[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]]},s:{width:17,points:[[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]]},t:{width:12,points:[[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]]},u:{width:19,points:[[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]]},v:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0]]},w:{width:22,points:[[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]]},x:{width:17,points:[[3,14],[14,0],[-1,-1],[14,14],[3,0]]},y:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]]},z:{width:17,points:[[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]]},"{":{width:14,points:[[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]]},"|":{width:8,points:[[4,25],[4,-7]]},"}":{width:14,points:[[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]]},"~":{width:24,points:[[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]]}};function qe(e={}){var t=e.origin||[0,0,0],s=t[0],i=t[1],r=t[2],n=e.size||1,A=[],o=[],a=e.text;j.isNumeric(a)&&(a=""+a);for(var l,c,h,u,d,p,f,g,m,_=(a||"").split("\n"),b=0,B=0,y=.04,w=0;w<_.length;w++){l=0,h=(c=_[w]).length;for(var v=0;v<h;v++)if(u=$e[c.charAt(v)]){d=1,p=-1,f=-1,g=u.points.length;for(var C=0;C<g;C++)-1!==(m=u.points[C])[0]||-1!==m[1]?(A.push(l+m[0]*n*y+s),A.push(B+m[1]*n*y+i),A.push(0+r),-1===p?p=b:(-1===f||(p=f),f=b),b++,d?d=!1:(o.push(p),o.push(f))):d=1;l+=u.width*y*n}B-=35*y*n}return j.apply(e,{primitive:"lines",positions:A,indices:o})}function et(e={}){if(e.points.length%3!=0)throw"Size of points array for given polyline should be divisible by 3";let t=e.points.length/3;if(t<2)throw"There should be at least 2 points to create a polyline";let s=[];for(let e=0;e<t-1;e++)s.push(e),s.push(e+1);return j.apply(e,{primitive:"lines",positions:e.points,indices:s})}const tt=R.vec4(4),st=R.vec4(),it=R.vec4(),rt=R.vec3([1,0,0]),nt=R.vec3([0,1,0]),At=R.vec3([0,0,1]),ot=R.vec3(3),at=R.vec3(3),lt=R.identityMat4();class ct extends ie{constructor(e,t={}){if(super(e,t),this._parentNode=null,this._children=[],this._aabb=null,this._aabbDirty=!0,this.scene._aabbDirty=!0,this._numTriangles=0,this._scale=R.vec3(),this._quaternion=R.identityQuaternion(),this._rotation=R.vec3(),this._position=R.vec3(),this._offset=R.vec3(),this._localMatrix=R.identityMat4(),this._worldMatrix=R.identityMat4(),this._localMatrixDirty=!0,this._worldMatrixDirty=!0,t.matrix?this.matrix=t.matrix:(this.scale=t.scale,this.position=t.position,t.quaternion||(this.rotation=t.rotation)),this._isModel=t.isModel,this._isModel&&this.scene._registerModel(this),this._isObject=t.isObject,this._isObject&&this.scene._registerObject(this),this.origin=t.origin,this.visible=t.visible,this.culled=t.culled,this.pickable=t.pickable,this.clippable=t.clippable,this.collidable=t.collidable,this.castsShadow=t.castsShadow,this.receivesShadow=t.receivesShadow,this.xrayed=t.xrayed,this.highlighted=t.highlighted,this.selected=t.selected,this.edges=t.edges,this.colorize=t.colorize,this.opacity=t.opacity,this.offset=t.offset,t.children){const e=t.children;for(let s=0,i=e.length;s<i;s++)this.addChild(e[s],t.inheritStates)}if(t.parentId){const e=this.scene.components[t.parentId];e?e.isNode?e.addChild(this):this.error("Parent is not a Node: '"+t.parentId+"'"):this.error("Parent not found: '"+t.parentId+"'")}else t.parent&&(t.parent.isNode||this.error("Parent is not a Node"),t.parent.addChild(this))}get isEntity(){return!0}get isModel(){return this._isModel}get isObject(){return this._isObject}get aabb(){return this._aabbDirty&&this._updateAABB(),this._aabb}set origin(e){e?(this._origin||(this._origin=R.vec3()),this._origin.set(e)):this._origin&&(this._origin=null);for(let t=0,s=this._children.length;t<s;t++)this._children[t].origin=e;this.glRedraw()}get origin(){return this._origin}set rtcCenter(e){this.origin=e}get rtcCenter(){return this.origin}get numTriangles(){return this._numTriangles}set visible(e){e=!1!==e,this._visible=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].visible=e;this._isObject&&this.scene._objectVisibilityUpdated(this,e)}get visible(){return this._visible}set xrayed(e){e=!!e,this._xrayed=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].xrayed=e;this._isObject&&this.scene._objectXRayedUpdated(this,e)}get xrayed(){return this._xrayed}set highlighted(e){e=!!e,this._highlighted=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].highlighted=e;this._isObject&&this.scene._objectHighlightedUpdated(this,e)}get highlighted(){return this._highlighted}set selected(e){e=!!e,this._selected=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].selected=e;this._isObject&&this.scene._objectSelectedUpdated(this,e)}get selected(){return this._selected}set edges(e){e=!!e,this._edges=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].edges=e}get edges(){return this._edges}set culled(e){e=!!e,this._culled=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].culled=e}get culled(){return this._culled}set clippable(e){e=!1!==e,this._clippable=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].clippable=e}get clippable(){return this._clippable}set collidable(e){e=!1!==e,this._collidable=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].collidable=e}get collidable(){return this._collidable}set pickable(e){e=!1!==e,this._pickable=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].pickable=e}get pickable(){return this._pickable}set colorize(e){let t=this._colorize;t||(t=this._colorize=new Float32Array(4),t[3]=1),e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1);for(let e=0,s=this._children.length;e<s;e++)this._children[e].colorize=t;if(this._isObject){const t=!!e;this.scene._objectColorizeUpdated(this,t)}}get colorize(){return this._colorize.slice(0,3)}set opacity(e){let t=this._colorize;t||(t=this._colorize=new Float32Array(4),t[0]=1,t[1]=1,t[2]=1),t[3]=null!=e?e:1;for(let t=0,s=this._children.length;t<s;t++)this._children[t].opacity=e;if(this._isObject){const t=null!=e;this.scene._objectOpacityUpdated(this,t)}}get opacity(){return this._colorize[3]}set castsShadow(e){e=!!e,this._castsShadow=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].castsShadow=e}get castsShadow(){return this._castsShadow}set receivesShadow(e){e=!!e,this._receivesShadow=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].receivesShadow=e}get receivesShadow(){return this._receivesShadow}get saoEnabled(){return!1}set offset(e){e?(this._offset[0]=e[0],this._offset[1]=e[1],this._offset[2]=e[2]):(this._offset[0]=0,this._offset[1]=0,this._offset[2]=0);for(let e=0,t=this._children.length;e<t;e++)this._children[e].offset=this._offset;this._isObject&&this.scene._objectOffsetUpdated(this,e)}get offset(){return this._offset}get isNode(){return!0}_setLocalMatrixDirty(){this._localMatrixDirty=!0,this._setWorldMatrixDirty()}_setWorldMatrixDirty(){this._worldMatrixDirty=!0;for(let e=0,t=this._children.length;e<t;e++)this._children[e]._setWorldMatrixDirty()}_buildWorldMatrix(){const e=this.matrix;if(this._parentNode)R.mulMat4(this._parentNode.worldMatrix,e,this._worldMatrix);else for(let t=0,s=e.length;t<s;t++)this._worldMatrix[t]=e[t];this._worldMatrixDirty=!1}_setSubtreeAABBsDirty(e){if(e._aabbDirty=!0,e._children)for(let t=0,s=e._children.length;t<s;t++)this._setSubtreeAABBsDirty(e._children[t])}_setAABBDirty(){if(this._setSubtreeAABBsDirty(this),this.collidable)for(let e=this;e;e=e._parentNode)e._aabbDirty=!0}_updateAABB(){if(this.scene._aabbDirty=!0,this._aabb||(this._aabb=R.AABB3()),this._buildAABB)this._buildAABB(this.worldMatrix,this._aabb);else{let e;R.collapseAABB3(this._aabb);for(let t=0,s=this._children.length;t<s;t++)e=this._children[t],e.collidable&&R.expandAABB3(this._aabb,e.aabb)}this._aabbDirty=!1}addChild(e,t){if(j.isNumeric(e)||j.isString(e)){const t=e;if(!(e=this.scene.component[t]))return void this.warn("Component not found: "+j.inQuotes(t));if(!e.isNode&&!e.isMesh)return void this.error("Not a Node or Mesh: "+t)}else{if(!e.isNode&&!e.isMesh)return void this.error("Not a Node or Mesh: "+e.id);if(e._parentNode){if(e._parentNode.id===this.id)return void this.warn("Already a child: "+e.id);e._parentNode.removeChild(e)}}if(e.id,e.scene.id===this.scene.id)return this._children.push(e),e._parentNode=this,t&&(e.visible=this.visible,e.culled=this.culled,e.xrayed=this.xrayed,e.highlited=this.highlighted,e.selected=this.selected,e.edges=this.edges,e.clippable=this.clippable,e.pickable=this.pickable,e.collidable=this.collidable,e.castsShadow=this.castsShadow,e.receivesShadow=this.receivesShadow,e.colorize=this.colorize,e.opacity=this.opacity,e.offset=this.offset),e._setWorldMatrixDirty(),e._setAABBDirty(),this._numTriangles+=e.numTriangles,e;this.error("Child not in same Scene: "+e.id)}removeChild(e){for(let t=0,s=this._children.length;t<s;t++)if(this._children[t].id===e.id)return e._parentNode=null,this._children=this._children.splice(t,1),e._setWorldMatrixDirty(),e._setAABBDirty(),this._setAABBDirty(),void(this._numTriangles-=e.numTriangles)}removeChildren(){let e;for(let t=0,s=this._children.length;t<s;t++)e=this._children[t],e._parentNode=null,e._setWorldMatrixDirty(),e._setAABBDirty(),this._numTriangles-=e.numTriangles;this._children=[],this._setAABBDirty()}get numChildren(){return this._children.length}get children(){return this._children}set parent(e){if(j.isNumeric(e)||j.isString(e)){const t=e;if(!(e=this.scene.components[t]))return void this.warn("Node not found: "+j.inQuotes(t));if(!e.isNode)return void this.error("Not a Node: "+e.id)}e.scene.id===this.scene.id?this._parentNode&&this._parentNode.id===e.id?this.warn("Already a child of Node: "+e.id):e.addChild(this):this.error("Node not in same Scene: "+e.id)}get parent(){return this._parentNode}set position(e){this._position.set(e||[0,0,0]),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get position(){return this._position}set rotation(e){this._rotation.set(e||[0,0,0]),R.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get rotation(){return this._rotation}set quaternion(e){this._quaternion.set(e||[0,0,0,1]),R.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get quaternion(){return this._quaternion}set scale(e){this._scale.set(e||[1,1,1]),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get scale(){return this._scale}set matrix(e){this._localMatrix||(this._localMatrix=R.identityMat4()),this._localMatrix.set(e||lt),R.decomposeMat4(this._localMatrix,this._position,this._quaternion,this._scale),this._localMatrixDirty=!1,this._setWorldMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get matrix(){return this._localMatrixDirty&&(this._localMatrix||(this._localMatrix=R.identityMat4()),R.composeMat4(this._position,this._quaternion,this._scale,this._localMatrix),this._localMatrixDirty=!1),this._localMatrix}get worldMatrix(){return this._worldMatrixDirty&&this._buildWorldMatrix(),this._worldMatrix}rotate(e,t){return tt[0]=e[0],tt[1]=e[1],tt[2]=e[2],tt[3]=t*R.DEGTORAD,R.angleAxisToQuaternion(tt,st),R.mulQuaternions(this.quaternion,st,it),this.quaternion=it,this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}rotateOnWorldAxis(e,t){return tt[0]=e[0],tt[1]=e[1],tt[2]=e[2],tt[3]=t*R.DEGTORAD,R.angleAxisToQuaternion(tt,st),R.mulQuaternions(st,this.quaternion,st),this}rotateX(e){return this.rotate(rt,e)}rotateY(e){return this.rotate(nt,e)}rotateZ(e){return this.rotate(At,e)}translate(e,t){return R.vec3ApplyQuaternion(this.quaternion,e,ot),R.mulVec3Scalar(ot,t,at),R.addVec3(this.position,at,this.position),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}translateX(e){return this.translate(rt,e)}translateY(e){return this.translate(nt,e)}translateZ(e){return this.translate(At,e)}get type(){return"Node"}destroy(){if(super.destroy(),this._parentNode&&this._parentNode.removeChild(this),this._isObject&&(this.scene._deregisterObject(this),this._visible&&this.scene._objectVisibilityUpdated(this,!1,!1),this._xrayed&&this.scene._objectXRayedUpdated(this,!1,!1),this._selected&&this.scene._objectSelectedUpdated(this,!1,!1),this._highlighted&&this.scene._objectHighlightedUpdated(this,!1,!1),this.scene._objectColorizeUpdated(this,!1),this.scene._objectOpacityUpdated(this,!1),this.offset.some((e=>0!==e))&&this.scene._objectOffsetUpdated(this,!1)),this._isModel&&this.scene._deregisterModel(this),this._children.length){const e=this._children.splice(0);let t;for(let s=0,i=e.length;s<i;s++)t=e[s],t.destroy()}this._children=[],this._setAABBDirty(),this.scene._aabbDirty=!0}}const ht=R.vec3(),ut=function(){const e=new Float64Array(16),t=new Float64Array(4),s=new Float64Array(4);return function(i,r,n){return n=n||e,t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=1,R.transformVec4(i,t,s),R.setMat4Translation(i,s,n),n.slice()}}();function dt(e,t,s){const i=Float32Array.from([e[0]])[0],r=e[0]-i,n=Float32Array.from([e[1]])[0],A=e[1]-n,o=Float32Array.from([e[2]])[0],a=e[2]-o;t[0]=i,t[1]=n,t[2]=o,s[0]=r,s[1]=A,s[2]=a}function pt(e,t,s,i=1e3){const r=R.getPositionsCenter(e,ht),n=Math.round(r[0]/i)*i,A=Math.round(r[1]/i)*i,o=Math.round(r[2]/i)*i;s[0]=n,s[1]=A,s[2]=o;const a=0!==s[0]||0!==s[1]||0!==s[2];if(a)for(let s=0,i=e.length;s<i;s+=3)t[s+0]=e[s+0]-n,t[s+1]=e[s+1]-A,t[s+2]=e[s+2]-o;return a}const ft=new e({}),gt=R.vec3(),mt=R.vec4(),_t={3001:"sRGBToLinear"},bt=function(){const e=[],t=[],s=[],i=[],r=[],n=[],A=[],o=(t,s)=>{let i=!1;return e.push((e=>i&&s(t,e))),{toString:()=>(i=!0,t)}},a={createAttribute:function(t,s){let i=!1;e.push((e=>i&&e.push(`in ${t} ${s};`)));const A={toString:()=>(i=!0,s)};return r.push((e=>{const t=i&&e(s);return t&&n.push(t.attributeHash),A.setInputValue=t,null})),A},createFragmentDefinition:(e,t)=>{let s=!1;return i.push((i=>s&&t(e,i))),{toString:()=>(s=!0,e)}},createOutput:(e,t,i)=>{let r=!1;return s.push((s=>r&&s.push(`layout(location = ${i||0}) out ${e} ${t};`))),{toString:()=>(r=!0,t)}},createUniform:(t,i,r)=>{let n=!1;const o=e=>n&&e.push(`uniform ${t} ${i};`);e.push(o),s.push(o);const a={toString:()=>(n=!0,i)};return A.push((e=>{const t=n&&e(i);return r?t&&(e=>r(t,e)):(a.setInputValue=t,null)})),a},createUniformArray:(t,i,r)=>{let n=!1;const o=e=>n&&e.push(`uniform ${t} ${i}[${r}];`);e.push(o),s.push(o);const a={toString:()=>(n=!0,i)};return A.push((e=>(a.setInputValue=n&&e(i),null))),a},createUniformBlock:(t,i,r)=>{let n=!1;const o=Object.keys(i),a=e=>{n&&(e.push(`uniform ${t} {`),o.forEach((t=>e.push(` ${i[t]} ${t};`))),e.push("};"))};e.push(a),s.push(a);const l={};return o.forEach((e=>l[e]={toString:()=>(n=!0,e)})),A.push((e=>{const s=n&&e(t);return r?s&&(e=>r(s,e)):(l.setInputValue=s,null)})),l},createVarying:(i,r,n,A)=>{let o=!1;const a=A?A+" ":"";return e.push((e=>o&&e.push(`${a}out ${i} ${r};`))),t.push((e=>o&&e.push(`${r} = ${n()};`))),s.push((e=>o&&e.push(`${a}in ${i} ${r};`))),{toString:()=>(o=!0,r)}},createVertexDefinition:o,commonLibrary:{octDecode:o("octDecode",((e,t)=>{t.push(`vec3 ${e}(vec2 oct) {`),t.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));"),t.push(" if (v.z < 0.0) {"),t.push(" v.xy = (1.0 - abs(v.yx)) * vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);"),t.push(" }"),t.push(" return normalize(v);"),t.push("}")}))}};return{programVariables:a,buildProgram:(o,l,c)=>{const h=c.getLogDepth,u=c.clipPos,d=c.usePickClipPos&&function(){const e=a.createUniform("vec2","pickClipPos"),t=a.createUniform("vec2","pickClipPosInv");return{setClipPosInputValue:s=>{e.setInputValue(s.pickClipPos),t.setInputValue(s.pickClipPosInv)},transformedClipPos:()=>`vec4((${u}.xy / ${u}.w - ${e}) * ${t} * ${u}.w, ${u}.zw)`}}(),p=d?d.transformedClipPos():u,f=[],g=a.createVarying("float","isPerspective",(()=>`(${c.projMatrix}[2][3] == -1.0) ? 1.0 : 0.0`)),m=a.createUniform("float","logDepthBufFC",((e,t)=>e(2/(Math.log(t.view.far+1)/Math.LN2)))),_=a.createVarying("float","vFragDepth",(()=>"1.0 + clipPos.w"));h?f.push(`gl_FragDepth = ${c.testPerspectiveForGl_FragDepth?`${g} == 0.0 ? gl_FragCoord.z : `:""}log2(${h(_)}) * ${m} * 0.5;`):c.cleanerEdges&&f.push("gl_FragDepth = gl_FragCoord.z + length(vec2(dFdx(gl_FragCoord.z), dFdy(gl_FragCoord.z)));");const b=a.createFragmentDefinition("linearToGamma",((e,t)=>{t.push(`vec4 ${e}(in vec4 value, in float gammaFactor) {`),t.push(" return vec4(pow(value.xyz, vec3(1.0 / gammaFactor)), value.w);"),t.push("}")})),B=c.sectionPlanesState,y=B&&function(){const e=function(e){const t=[];for(let s=0;s<e;++s)t.push(s);return t}(B.getNumAllocatedSectionPlanes()).map((e=>{const t=(t,s,i)=>a.createUniform(t,`sectionPlane${s}${e}`,((t,s)=>{const r=B.sectionPlanes,n=r.length,A=(s.mesh.layerIndex||0)*n,o=e<n&&s.mesh.renderFlags.sectionPlanesActivePerLayer[A+e];return i(t,o,r[e],s.mesh.origin)}));return{act:t("bool","Active",((e,t)=>e(t?1:0))),dir:t("vec3","Dir",((e,t,s)=>t&&e(s.dir))),pos:t("vec3","Pos",((e,t,s,i)=>t&&e(i?R.mulVec3Scalar(R.normalizeVec3(s.dir,gt),-(R.dotVec3(s.dir,i)+s.dist),gt):s.pos)))}}));return e.length>0&&(t=>e.map((e=>`(${e.act} ? clamp(dot(-${e.dir}, ${t} - ${e.pos}), 0.0, 1000.0) : 0.0)`)).join(" + "))}(),w=c.crossSections,v=y?function(){const e=a.createUniform("vec4","sliceColor",(e=>e(w.sliceColor))),t=s=>(t.needed=!0,`(sliced ? ${e} : ${s})`);return t}():e=>e,C=c.getGammaFactor,M=a.createUniform("float","gammaFactor",(e=>e(C())));c.appendFragmentOutputs(f,C&&(e=>`${b}(${e}, ${M})`),"gl_FragCoord",v);const E=function(){const e=[],t=a.createUniform("float","sliceThickness",(e=>e(w.sliceThickness)));if(y){v.needed&&e.push(" bool sliced = false;"),e.push(` if (${c.clippableTest()}) {`);const s=a.createVarying("highp vec3","vHighpWorldPosition",(()=>`${c.worldPositionAttribute}.xyz`));if(e.push(` float dist = ${y(s)};`),c.clippingCaps){const t=a.createVarying("float","vClipPositionW",(()=>"gl_Position.w"));e.push(` if (dist > (0.002 * ${t})) { discard; }`),e.push(" if (dist > 0.0) { "),e.push(` ${c.clippingCaps} = vec4(1.0, 0.0, 0.0, 1.0);`),h&&e.push(` gl_FragDepth = log2(${h(_)}) * ${m} * 0.5;`),e.push(" return;"),e.push(" }")}else e.push(` if (dist > ${v.needed?t:"0.0"}) { discard; }`);v.needed&&e.push(" sliced = dist > 0.0;"),e.push(" }")}return e}(),F=function(){const e=[];return i.forEach((t=>t(e))),e}(),x=[...function(){const e=[];return s.forEach((t=>t(e))),e}(),...F,"void main(void) {",...c.discardPoints?[" vec2 cxy = 2.0 * gl_PointCoord - 1.0;"," if (dot(cxy, cxy) > 1.0) { discard; }"]:[],...E,...f,"}"],U=[`gl_Position = ${p};`,...c.getPointSize?[`gl_PointSize = ${c.getPointSize()};`]:[],...function(){const e=[];return t.forEach((t=>t(e))),e}()],I=c.getVertexData?c.getVertexData():[],T=[...function(){const t=[];return e.forEach((e=>e(t))),t}(),"void main(void) {",...I,...U,"}"],P=e=>["#version 300 es","// "+l+" "+e+" shader","#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","precision highp int;","precision highp usampler2D;","precision highp isampler2D;","precision highp sampler2D;","#else","precision mediump float;","precision mediump int;","precision mediump usampler2D;","precision mediump isampler2D;","precision mediump sampler2D;","#endif"],S=P("vertex").concat(T),D=P("fragment").concat(["vec4 sRGBToLinear(in vec4 value) {"," return vec4(mix(pow(value.rgb * 0.9478672986 + 0.0521327014, vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.w);","}"]).concat(x),k=(e,t)=>{const s=t.join("\n"),i=o.createShader(e);return o.shaderSource(i,s),o.compileShader(i),o.getShaderParameter(i,o.COMPILE_STATUS)?[i]:[null,["Failed to compile",o.getShaderInfoLog(i),s.split("\n").map(((e,t)=>t+1+": "+e+"\n")).join("")]]},[Q,O]=k(o.VERTEX_SHADER,S),[V,L]=k(o.FRAGMENT_SHADER,D),H=e=>(console.error(e.join("\n")),[null,e]);if(O)return H(["Vertex shader error"].concat(O));if(L)return H(["Fragment shader error"].concat(L));{const e=o.createProgram();if(e){if(o.attachShader(e,Q),o.attachShader(e,V),o.linkProgram(e),o.getProgramParameter(e,o.LINK_STATUS)){const t=wt(o,e);r.forEach((e=>e(t)));const s=A.map((e=>e(t))).filter((e=>e)),i=ft.addItem({});return[{id:i,bind:()=>o.useProgram(e),inputSetters:{attributesHash:n.sort().join(", "),setUniforms:(e,t)=>{d&&d.setClipPosInputValue(e),s.forEach((e=>e(t)))}},destroy:()=>{ft.removeItem(i),o.deleteProgram(e),o.deleteShader(Q),o.deleteShader(V)}}]}return H(["",o.getProgramInfoLog(this.program),"","Vertex shader:","",...S,"","Fragment shader:","",...D])}return H(["Failed to allocate program"])}}}},Bt=function(e,t){const s=e.createUniform("vec4","lightAmbient",(e=>e(t.getAmbientColorAndIntensity()))),i=t.lights,r=i.map(((t,s)=>{const r={color:e.createUniform("vec4",`lightColor${s}`,(e=>{const t=i[s];mt[0]=t.color[0],mt[1]=t.color[1],mt[2]=t.color[2],mt[3]=t.intensity,e(mt)})),position:e.createUniform("vec3",`lightPos${s}`,(e=>e(i[s].pos))),direction:e.createUniform("vec3",`lightDir${s}`,(e=>e(i[s].dir))),shadowProjMatrix:e.createUniform("mat4",`shadowProjMatrix${s}`,(e=>e(i[s].getShadowViewMatrix()))),shadowViewMatrix:e.createUniform("mat4",`shadowViewMatrix${s}`,(e=>e(i[s].getShadowViewMatrix()))),shadowMap:e.createUniform("sampler2D",`shadowMap${s}`,(e=>e(i[s].getShadowRenderBuf().colorTextures[0])))},n=e=>({glslLight:{isViewSpace:"view"===t.space,getColor:()=>`${r.color}.rgb * ${r.color}.a`,getDirection:(t,s)=>`normalize(${e(t,s)})`,shadowParameters:t.castsShadow&&{getShadowProjMatrix:()=>r.shadowProjMatrix,getShadowViewMatrix:()=>r.shadowViewMatrix,getShadowMap:()=>r.shadowMap}},setupLightsInputs:()=>{const e=Object.values(r).map((e=>e.setupLightsInputs())).filter((e=>e));return()=>e.forEach((e=>e()))}});return"dir"===t.type?"view"===t.space?n(((e,t)=>`-${r.direction}`)):n(((e,t)=>`-(${e} * vec4(${r.direction}, 0.0)).xyz`)):"point"===t.type?"view"===t.space?n(((e,t)=>`${r.position} - ${t}`)):n(((e,t)=>`(${e} * vec4(${r.position}, 1.0)).xyz - ${t}`)):null})).filter((e=>e)),n=(t,s)=>{const i=()=>{const e=s();return e.length>0&&e[0]},r=i();return r&&yt(e,"samplerCube",t,r.encoding,(e=>{const t=i();t&&e(t.texture)}))},A=n("light",(()=>t.lightMaps)),o=n("reflection",(()=>t.reflectionMaps));return{getHash:()=>t.getHash(),getAmbientColor:()=>`${s}.rgb * ${s}.a`,directionalLights:r.map((e=>e.glslLight)),getIrradiance:A&&(e=>`${A(e)}.rgb`),getReflection:o&&((e,t)=>`${o(e,t)}.rgb`)}},yt=(e,t,s,i,r)=>{const n=e.createUniform(t,s+"Map",r);return(e,t)=>{const s=t?`texture(${n}, ${e}, ${t})`:`texture(${n}, ${e})`;return 3e3!==i?`${_t[i]}(${s})`:s}},wt=function(e,t){const s={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;++r){const n=e.getActiveAttrib(t,r),A=e.getAttribLocation(t,n.name);s[n.name]=function(t){t.bindAtLocation(A),e.enableVertexAttribArray(A);const s=t.attributeDivisor;s&&e.vertexAttribDivisor(A,s)},s[n.name].attributeHash=`${A.toString().padStart(1+Math.floor(Math.log10(i)),"0")}:${n.name}`}const r=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let i=0;i<r;++i){const r=e.getActiveUniformBlockName(t,i),n=e.getUniformBlockIndex(t,r),A=i;e.uniformBlockBinding(t,n,A);const o=e.createBuffer();s[r]=function(t){e.bindBuffer(e.UNIFORM_BUFFER,o),e.bufferData(e.UNIFORM_BUFFER,t,e.DYNAMIC_DRAW),e.bindBufferBase(e.UNIFORM_BUFFER,A,o)}}const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);let A=0;for(let i=0;i<n;++i){const r=e.getActiveUniform(t,i);let n=r.name;n.endsWith("[0]")&&(n=n.substr(0,n.length-3)),"\0"===n[n.length-1]&&(n=n.substr(0,n.length-1));const o=e.getUniformLocation(t,n);if(function(){for(let t in e)if(r.type===e[t])return t}(),r.type===e.SAMPLER_2D||r.type===e.SAMPLER_CUBE||r.type===e.SAMPLER_2D_SHADOW||e instanceof window.WebGL2RenderingContext&&(r.type===e.UNSIGNED_INT_SAMPLER_2D||r.type===e.INT_SAMPLER_2D)){const t=A++;s[n]=function(s){const i=s.bind(t);return i&&e.uniform1i(o,t),i}}else s[n]=function(){if(1===r.size)switch(r.type){case e.BOOL:case e.INT:return t=>e.uniform1i(o,t);case e.FLOAT:return t=>e.uniform1f(o,t);case e.FLOAT_VEC2:return t=>e.uniform2fv(o,t);case e.FLOAT_VEC3:return t=>e.uniform3fv(o,t);case e.FLOAT_VEC4:return t=>e.uniform4fv(o,t);case e.FLOAT_MAT3:return t=>e.uniformMatrix3fv(o,!1,t);case e.FLOAT_MAT4:return t=>e.uniformMatrix4fv(o,!1,t)}else if(r.size>1)switch(r.type){case e.FLOAT:return t=>e.uniform1fv(o,t);case e.FLOAT_VEC2:return t=>e.uniform2fv(o,t);case e.FLOAT_VEC3:return t=>e.uniform3fv(o,t);case e.FLOAT_VEC4:return t=>e.uniform4fv(o,t)}throw`Unhandled uniform ${n}`}()}return function(e){const t=s[e];if(!t)throw`Missing input "${e}"`;return t}},vt=R.vec4(),Ct=R.vec4();class Mt{constructor(){this.visibleLayers=[],this.sectionPlanesActivePerLayer=[],this.reset()}reset(){this.culled=!1,this.sectioned=!1,this.numLayers=0,this.numVisibleLayers=0,this.colorOpaque=!1,this.colorTransparent=!1,this.edgesOpaque=!1,this.edgesTransparent=!1,this.xrayedSilhouetteOpaque=!1,this.xrayedEdgesOpaque=!1,this.xrayedSilhouetteTransparent=!1,this.xrayedEdgesTransparent=!1,this.highlightedSilhouetteOpaque=!1,this.highlightedEdgesOpaque=!1,this.highlightedSilhouetteTransparent=!1,this.highlightedEdgesTransparent=!1,this.selectedSilhouetteOpaque=!1,this.selectedEdgesOpaque=!1,this.selectedSilhouetteTransparent=!1,this.selectedEdgesTransparent=!1}}const Et=R.OBB3(),Ft=R.vec4(),xt=R.vec4(),Ut=R.vec4(),It=R.vec3([1,0,0]),Tt=R.vec3([0,1,0]),Pt=R.vec3([0,0,1]),St=R.vec3(3),Dt=R.vec3(3),kt=R.identityMat4(),Qt=new e({}),Rt={};class Ot extends ie{constructor(e,t={}){super(e,t),this.renderOrder=t.renderOrder||0,this.originalSystemId=t.originalSystemId||this.id,this.renderFlags=new Mt,this._state=new xe({visible:!0,culled:!1,pickable:null,clippable:null,collidable:null,occluder:!1!==t.occluder,castsShadow:null,receivesShadow:null,xrayed:!1,highlighted:!1,selected:!1,edges:!1,stationary:!!t.stationary,background:!!t.background,billboard:this._checkBillboard(t.billboard),layer:null,colorize:null,pickID:this.scene._renderer.getPickID(this),drawHash:"",pickOcclusionHash:"",offset:R.vec3(),origin:null,originHash:null,isUI:t.isUI});const s=t.material?this._checkComponent2(["PhongMaterial","MetallicMaterial","SpecularMaterial","LambertMaterial"],t.material):this.scene.material,i=this,r=e=>{let t=null;const s=()=>{if(!t){const s=bt(),r=s.programVariables.createAttribute,n=i._geometry._state,A={position:r("vec3","position"),color:n.colorsBuf&&r("vec4","color"),pickColor:r("vec4","pickColor"),uv:n.uvBuf&&r("vec2","uv"),normal:(n.autoVertexNormals||n.normalsBuf)&&["triangles","triangle-strip","triangle-fan"].includes(n.primitiveName)&&r("vec3","normal")},o=function(e){const t={toString:()=>(t.needed=!0,e)};return t},a=A.normal&&o("worldNormal"),l=a&&o("viewNormal"),c=A.uv&&o("decodedUv"),h=e(s.programVariables,{attributes:{position:{world:"worldPosition",view:"viewPosition"},color:A.color,pickColor:A.pickColor,uv:c,normal:A.normal&&{world:a,view:l}},viewMatrix:"viewMatrix2"}),u=[h.programName,i.scene.canvas.canvas.id,i.scene._sectionPlanesState.getHash(),i._geometry._state.hash].concat(h.getHash()).join(";");if(!(u in Rt)){const e=Lt(i,A,{decodedUv:c,worldNormal:a,viewNormal:l},h,s);if(e.errors)return void console.log(e.errors.join("\n"));const t=Qt.addItem({});Rt[u]={drawMesh:e.drawMesh,id:t,useCount:0,delete:()=>{Qt.removeItem(t),e.destroy(),delete Rt[u],L.memory.programs--}},L.memory.programs++}t=Rt[u],t.useCount++}};return{get:s,getId:()=>t.id,put:()=>{t&&(0==--t.useCount&&t.delete(),t=null)},drawMesh:(e,i,r)=>{s(),t&&t.drawMesh(e,i,r)}}},n=i.scene,A=e=>(t,s)=>function(e,t,s,i,r){const n=r&&Bt(t,i._lightsState),A=t.createUniform("vec3","uColor",((e,t)=>e(r?t.material.fillColor:t.material.edgeColor))),o=t.createUniform("float","uAlpha",((e,t)=>e(r?t.material.fillAlpha:t.material.edgeAlpha))),a=t.createVarying("vec4","vColor",(()=>{const e=s.attributes,t=r&&[n.getAmbientColor()].concat(e.normal?n.directionalLights.map((t=>`(max(dot(${e.normal.view}, ${t.getDirection(s.viewMatrix,e.position.view)}), 0.0) * ${t.getColor()})`)):[]);return`vec4(${A}${t?` * (${t.join(" + ")})`:""}, ${o})`})),l=t.createOutput("vec4","outColor");return{getHash:()=>[e,i.gammaOutput?"go":"",n&&n.getHash()],programName:r?"EmphasisFill":"EmphasisEdges",dontSetFrontFace:!0,discardPoints:r,drawEdges:!r,appendFragmentOutputs:(e,t)=>e.push(`${l} = ${t?t(a):a};`)}}(i._state.hash,t,s,n,e);this._renderers={_drawRenderer:r(((e,t)=>"LambertMaterial"===s.type?function(e,t,s,i,r){const n=Bt(t,r._lightsState),A=t.createUniform("vec4","colorize",((e,t)=>e(t.meshColorize))),o=t.createUniform("float","materialAlpha",((e,t)=>e(t.material.alpha))),a=t.createUniform("vec3","materialColor",((e,t)=>e(t.material.color))),l=t.createUniform("vec3","materialEmissive",((e,t)=>e(t.material.emissive))),c=t.createVarying("vec4","vColor",(()=>{const e=s.attributes,t=[n.getAmbientColor()].concat(e.normal?n.directionalLights.map((t=>`(max(dot(${e.normal.view}, ${t.getDirection(s.viewMatrix,e.position.view)}), 0.0) * ${t.getColor()})`)):[]);return`${A} * vec4((${t.join(" + ")}) * ${a} + ${l}, ${o});`})),h=t.createOutput("vec4","outColor");return{getHash:()=>[e,r.gammaOutput?"go":"",n.getHash(),i._state.hash],programName:"Lambert",canActAsBackground:!0,discardPoints:!0,setupPointSize:!0,setsLineWidth:!0,appendFragmentOutputs:(e,t)=>e.push(`${h} = ${t?t(c):c};`)}}(i._state.drawHash,e,t,s,n):function(e,t,s,i,r){const n=i._state,A="PhongMaterial"===n.type,o="MetallicMaterial"===n.type,a="SpecularMaterial"===n.type,l=s.attributes,c=Bt(t,r._lightsState),h=t.createUniform("vec4","colorize",((e,t)=>e(t.meshColorize))),u=t.createFragmentDefinition("fresnel",((e,t)=>{t.push(`float ${e}(vec3 eyeDir, vec3 normal, float edgeBias, float centerBias, float power) {`),t.push(" float fr = abs(dot(eyeDir, normal));"),t.push(" float finalFr = clamp((fr - edgeBias) / (centerBias - edgeBias), 0.0, 1.0);"),t.push(" return pow(finalFr, power);"),t.push("}")})),d=(e,s,r)=>{const n=(s,i,n)=>t.createUniform(s,e+"Fresnel"+i,((e,t)=>e(n(r(t.material))))),A=n("float","EdgeBias",(e=>e.edgeBias)),o=n("float","CenterBias",(e=>e.centerBias)),a=n("float","Power",(e=>e.power)),l=n("vec3","EdgeColor",(e=>e.edgeColor)),c=n("vec3","CenterColor",(e=>e.centerColor));return r(i)&&((e,t)=>`mix(${l+s}, ${c+s}, ${u}(${e}, ${t}, ${A}, ${o}, ${a}))`)},p=d("diffuse","",(e=>e._diffuseFresnel)),f=d("specular","",(e=>e._specularFresnel)),g=d("emissive","",(e=>e._emissiveFresnel)),m=d("alpha",".r",(e=>e._alphaFresnel)),_=(e,s)=>{const r=l.uv&&s(i),n=r&&yt(t,"sampler2D",e,r.encoding,((e,t)=>e(s(t.material)._state.texture)));return n&&function(){const i=r._state.matrix&&t.createUniform("mat4",e+"MapMatrix",((e,t)=>e(s(t.material)._state.matrix))),A=i?e=>`(${i} * ${e}).st`:e=>`${e}.st`,o=(e,t)=>n(A(e));return o.getTexCoordExpression=A,o}()},b=_("ambient",(e=>e._ambientMap)),B=_("baseColor",(e=>e._baseColorMap)),y=_("diffuse",(e=>e._diffuseMap)),w=_("emissive",(e=>e._emissiveMap)),v=_("occlusion",(e=>e._occlusionMap)),C=_("alpha",(e=>e._alphaMap)),M=_("metallic",(e=>e._metallicMap)),E=_("roughness",(e=>e._roughnessMap)),F=_("metallicRoughness",(e=>e._metallicRoughnessMap)),x=_("specular",(e=>e._specularMap)),U=_("glossiness",(e=>e._glossinessMap)),I=_("specularGlossiness",(e=>e._specularGlossinessMap)),T=_("normal",(e=>e._normalMap)),P=(e,s,r)=>{const n=r(i);return("float"===s?null!=n:n)&&t.createUniform(s,e,((e,t)=>e(r(t.material))))},S=P("materialAmbient","vec3",(e=>e.ambient)),D=P("materialDiffuse","vec3",(e=>e.diffuse)),k=P("materialBaseColor","vec3",(e=>e.baseColor)),Q=P("materialEmissive","vec3",(e=>e.emissive)),R=P("materialSpecular","vec3",(e=>e.specular)),O=P("materialGlossiness","float",(e=>e.glossiness)),V=P("materialMetallic","float",(e=>e.metallic)),L=P("materialRoughness","float",(e=>e.roughness)),H=P("materialShininess","float",(e=>e.shininess)),N=P("materialSpecularF0","float",(e=>e.specularF0)),G=P("materialAlphaModeCutoff","vec4",(e=>{const t=e.alpha;return null!=t?(vt[0]=t,vt[1]=1===e.alphaMode?1:0,vt[2]=e.alphaCutoff,vt):null})),j=t.createVarying("vec3","vViewPosition",(()=>`${l.position.view}.xyz`)),W=t.createVarying("vec4","texturePos",(()=>`vec4(${l.uv}, 1.0, 1.0)`)),z=l.color&&t.createVarying("vec4","vColor",(()=>l.color)),X=t.createVarying("vec3","vViewNormal",(()=>l.normal.view)),K=c.directionalLights.map(((e,i)=>({vViewLightReverseDir:t.createVarying("vec3",`vViewLightReverseDir${i}`,(()=>e.getDirection(s.viewMatrix,null))),vShadowPosFromLight:t.createVarying("vec3",`vShadowPosFromLight${i}`,(()=>`(mat4(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0) * ${e.shadowParameters.getShadowProjMatrix()} * (${e.shadowParameters.getShadowViewMatrix()} * ${l.position.world})).xyz`))}))),Z=t.createVarying("vec3","vWorldNormal",(()=>l.normal.world)),J=t.createOutput("vec4","outColor"),Y=t.createFragmentDefinition("saturate",((e,t)=>t.push(`float ${e}(const in float a) { return clamp(a, 0.0, 1.0); }`))),$=t.createFragmentDefinition("BRDF_Specular_GGX",((e,t)=>{t.push("vec3 F_Schlick(const in vec3 specularColor, const in float dotLH) {"),t.push(" float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );"),t.push(" return ( 1.0 - specularColor ) * fresnel + specularColor;"),t.push("}"),t.push("float G_GGX_Smith(const in float alpha, const in float dotNL, const in float dotNV) {"),t.push(" float a2 = ( alpha * alpha );"),t.push(" float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );"),t.push(" float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );"),t.push(" return 1.0 / ( gl * gv );"),t.push("}"),t.push("float G_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {"),t.push(" float a2 = ( alpha * alpha );"),t.push(" float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );"),t.push(" float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );"),t.push(" return 0.5 / max( gv + gl, 1e-6 );"),t.push("}"),t.push("float D_GGX(const in float alpha, const in float dotNH) {"),t.push(" float a2 = ( alpha * alpha );"),t.push(" float denom = ( dotNH * dotNH) * ( a2 - 1.0 ) + 1.0;"),t.push(" return 0.31830988618 * a2 / ( denom * denom);"),t.push("}"),t.push(`vec3 ${e}(const in vec3 incidentLightDirection, const in vec3 viewNormal, const in vec3 viewEyeDir, const in vec3 specularColor, const in float roughness) {`),t.push(" float alpha = ( roughness * roughness );"),t.push(" vec3 halfDir = normalize( incidentLightDirection + viewEyeDir );"),t.push(` float dotNL = ${Y}( dot( viewNormal, incidentLightDirection ) );`),t.push(` float dotNV = ${Y}( dot( viewNormal, viewEyeDir ) );`),t.push(` float dotNH = ${Y}( dot( viewNormal, halfDir ) );`),t.push(` float dotLH = ${Y}( dot( incidentLightDirection, halfDir ) );`),t.push(" vec3 F = F_Schlick( specularColor, dotLH );"),t.push(" float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );"),t.push(" float D = D_GGX( alpha, dotNH );"),t.push(" return F * (G * D);"),t.push("}")})),q=t.createFragmentDefinition("BRDF_Specular_GGX_Environment",((e,t)=>{t.push(`vec3 ${e}(const in vec3 viewNormal, const in vec3 viewEyeDir, const in vec3 specularColor, const in float roughness) {`),t.push(` float dotNV = ${Y}(dot(viewNormal, viewEyeDir));`),t.push(" const vec4 c0 = vec4( -1, -0.0275, -0.572, 0.022);"),t.push(" const vec4 c1 = vec4( 1, 0.0425, 1.04, -0.04);"),t.push(" vec4 r = roughness * c0 + c1;"),t.push(" float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y;"),t.push(" vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;"),t.push(" return specularColor * AB.x + AB.y;"),t.push("}")})),ee=t.createFragmentDefinition("perturbNormal2Arb",((e,t)=>{t.push(`vec3 ${e}( vec3 eye_pos, vec3 surf_norm, vec2 uv, vec4 texel ) {`),t.push(" vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );"),t.push(" vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );"),t.push(" vec2 st0 = dFdx( uv.st );"),t.push(" vec2 st1 = dFdy( uv.st );"),t.push(" vec3 S = normalize( q0 * st1.t - q1 * st0.t );"),t.push(" vec3 T = normalize( -q0 * st1.s + q1 * st0.s );"),t.push(" vec3 N = normalize( surf_norm );"),t.push(" vec3 mapN = texel.xyz * 2.0 - 1.0;"),t.push(" mat3 tsn = mat3( S, T, N );"),t.push(" return normalize( tsn * mapN );"),t.push("}")}));return{getHash:()=>[e,r.gammaOutput?"go":"",c.getHash(),i._state.hash],programName:"Draw",canActAsBackground:!0,discardPoints:!0,setupPointSize:!0,setsLineWidth:!0,appendFragmentOutputs:(e,t,i)=>{const r=l.normal&&(c.directionalLights.length>0||c.getIrradiance||c.getReflection);if(e.push(`vec3 diffuseColor = ${r&&(A||a)&&D||o&&k||"vec3(1.0)"};`),e.push(`vec4 alphaModeCutoff = ${(A||o||a)&&G||"vec4(1.0, 0.0, 0.0, 0.0)"};`),e.push("float alpha = alphaModeCutoff[0];"),(A||o||a)&&C&&e.push(`alpha *= ${C(W)}.r;`),z&&(e.push(`diffuseColor *= ${z}.rgb;`),e.push(`alpha *= ${z}.a;`)),o&&B&&(e.push("vec4 baseColorTexel = "+B(W)+";"),e.push("diffuseColor *= baseColorTexel.rgb;"),e.push("alpha *= baseColorTexel.a;")),(A||a)&&y&&(e.push("vec4 diffuseTexel = "+y(W)+";"),e.push("diffuseColor *= diffuseTexel.rgb;"),e.push("alpha *= diffuseTexel.a;")),e.push(`vec3 emissiveColor = ${(A||o||a)&&Q||"vec3(0.0)"};`),(A||o||a)&&w&&e.push(`emissiveColor = ${w(W)}.rgb;`),r){e.push(`vec3 specular = ${(A||a)&&R||"vec3(1.0)"};`),e.push(`float glossiness = ${a&&O||"1.0"};`),e.push(`float metallic = ${o&&V||"1.0"};`),e.push(`float roughness = ${(o||a)&&L||"1.0"};`),e.push(`float shininess = ${A&&H||"1.0"};`),e.push(`float specularF0 = ${o&&N||"1.0"};`),e.push(`float occlusion = ${(A||o||a)&&v?`${v(W)}.r`:"1.0"};`),o&&M&&e.push(`metallic *= ${M(W)}.r;`),o&&E&&e.push(`roughness *= ${E(W)}.r;`),o&&F&&(e.push("vec4 metalRoughTexel = "+F(W)+";"),e.push("metallic *= metalRoughTexel.b;"),e.push("roughness *= metalRoughTexel.g;")),(A||a)&&x&&e.push(`specular *= ${x(W)}.rgb;`),a&&U&&e.push(`glossiness *= ${U(W)}.r;`),a&&I&&(e.push("vec4 specGlossTexel = "+I(W)+";"),e.push("specular *= specGlossTexel.rgb;"),e.push("glossiness *= specGlossTexel.a;"));const t=`normalize(${X})`,i=(A||o||a)&&T?`${ee}(${j}, ${t}, ${T.getTexCoordExpression(W)}, ${T(W)})`:t;if(e.push(`vec3 viewNormal = ${i};`),e.push(`vec3 viewEyeDir = normalize(-${j});`),p&&e.push(`diffuseColor *= ${p("viewEyeDir","viewNormal")};`),f&&e.push(`specular *= ${f("viewEyeDir","viewNormal")};`),g&&e.push(`emissiveColor *= ${g("viewEyeDir","viewNormal")};`),m&&e.push(`alpha *= ${m("viewEyeDir","viewNormal")};`),e.push("if (alphaModeCutoff[1] == 1.0 && alpha < alphaModeCutoff[2]) {"),e.push(" discard;"),e.push("}"),e.push("vec3 material_diffuseColor;"),A&&(e.push("material_diffuseColor = diffuseColor;"),e.push("roughness = 0.0;")),a&&(e.push("float oneMinusSpecularStrength = 1.0 - max(max(specular.r, specular.g ),specular.b);"),e.push("material_diffuseColor = diffuseColor * oneMinusSpecularStrength;"),e.push("roughness = clamp(1.0 - glossiness, 0.04, 1.0);")),o&&(e.push("float dielectricSpecular = 0.16 * specularF0 * specularF0;"),e.push("material_diffuseColor = diffuseColor * (1.0 - dielectricSpecular) * (1.0 - metallic);"),e.push("roughness = clamp(roughness, 0.04, 1.0);"),e.push("specular = mix(vec3(dielectricSpecular), diffuseColor, metallic);")),A||o||a){if(e.push("const float PI = 3.14159265359;"),e.push("vec3 reflDiff = vec3(0.0);"),e.push("vec3 reflSpec = vec3(0.0);"),c.getIrradiance&&e.push(`reflDiff += ${c.getIrradiance(`normalize(${Z})`)};`),c.getReflection){const t="reflect(-viewEyeDir, viewNormal)",i=A?`0.2 * PI * ${c.getReflection(t)}`:function(){const e=`${q}(viewNormal, viewEyeDir, specular, roughness)`,i=`normalize((vec4(${t}, 0.0) * ${s.viewMatrix}).xyz)`;return`${e} * ${c.getReflection(i,"clamp(4.0 - 0.39624 - 0.25 * log2(pow(2.0 / pow(roughness + 0.0001, 2.0) - 2.0, 2.0) + 1.0), 0.0, 4.0)")}`}();e.push(`reflSpec += ${i};`)}c.directionalLights.some((e=>e.shadowParameters))&&(e.push("const vec4 bitShift = vec4(1.0, 1.0/256.0, 1.0/(256.0 * 256.0), 1.0/(256.0*256.0*256.0));"),e.push("const float texelSize = 1.0 / 1024.0;"),e.push("float shadow;"),e.push("float fragmentDepth;")),c.directionalLights.forEach(((t,s)=>{if(t.shadowParameters){const i="0.007";e.push(`fragmentDepth = ${K[s].vShadowPosFromLight}.z - ${i};`),e.push("shadow = 0.0;"),e.push("for (int x = -3; x <= 3; x++) {"),e.push(" for (int y = -3; y <= 3; y++) {"),e.push(` float texelDepth = dot(texture(${t.getShadowMap()}, ${K[s].vShadowPosFromLight}.xy + vec2(x, y) * texelSize), bitShift);`),e.push(" if (fragmentDepth < texelDepth) {"),e.push(" shadow += 1.0;"),e.push(" }"),e.push(" }"),e.push("}"),e.push("shadow /= 9.0;")}e.push(`vec3 lightColor${s} = ${t.getColor()}${t.shadowParameters?" * shadow":""};`),e.push(`vec3 lightDirection${s} = ${t.isViewSpace?t.getDirection(null,j):K[s].vViewLightReverseDir};`);const i=`${Y}(dot(viewNormal, lightDirection${s}))`;e.push(`vec3 irradiance${s} = ${i} * lightColor${s};`),e.push(`reflDiff += irradiance${s};`);const r=A?`lightColor${s} * specular * pow(max(dot(reflect(-lightDirection${s}, -viewNormal), viewEyeDir), 0.0), shininess)`:`irradiance${s} * PI * ${$}(lightDirection${s}, viewNormal, viewEyeDir, specular, roughness)`;e.push(`reflSpec += ${r};`)}))}const r=A&&`${c.getAmbientColor()} * diffuseColor`;e.push("vec3 outgoingLight = emissiveColor + occlusion * (reflDiff * material_diffuseColor + reflSpec)"+(r?" + "+r:"")+";")}else e.push(`vec3 ambientColor = ${A&&S||"vec3(1.0)"};`),A&&b&&e.push(`ambientColor *= ${b(W)}.rgb;`),e.push(`ambientColor *= ${c.getAmbientColor()};`),e.push("vec3 outgoingLight = emissiveColor + ambientColor;");e.push(`vec4 fragColor = ${h} * vec4(outgoingLight, alpha);`),e.push(`${J} = ${t?t("fragColor"):"fragColor"};`)}}}(i._state.drawHash,e,t,s,n))),_shadowRenderer:r((e=>function(e,t){const s=t.createFragmentDefinition("encodeFloat",((e,t)=>{t.push(`vec4 ${e}( const in float depth ) {`),t.push(" const vec4 bitShift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0);"),t.push(" const vec4 bitMask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);"),t.push(" vec4 comp = fract(depth * bitShift);"),t.push(" comp -= comp.xxyz * bitMask;"),t.push(" return comp;"),t.push("}")})),i=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"Shadow",setsLineWidth:!0,useShadowView:!0,dontBillboardAnything:!0,dontGetLogDepth:!0,appendFragmentOutputs:(e,t,r)=>e.push(`${i} = ${s}(${r}.z);`)}}(i._state.hash,e))),_emphasisEdgesRenderer:r(A(!1)),_emphasisFillRenderer:r(A(!0)),_pickMeshRenderer:r((e=>function(e,t){const s=t.createUniform("vec4","pickColor",((e,t)=>{var s=t.meshPickID;Ct[0]=255&s,Ct[1]=s>>8&255,Ct[2]=s>>16&255,Ct[3]=s>>24&255,R.mulVec4Scalar(Ct,1/255,Ct),e(Ct)})),i=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"PickMesh",isPick:!0,dontBillboardAnything:!0,appendFragmentOutputs:e=>e.push(`${i} = ${s};`)}}(i._state.hash,e))),_pickTriangleRenderer:r(((e,t)=>function(e,t,s){const i=t.createVarying("vec4","vColor",(()=>s.attributes.pickColor)),r=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"PickTriangle",isPick:!0,trianglePick:!0,dontBillboardAnything:!0,appendFragmentOutputs:e=>e.push(`${r} = ${i};`)}}(i._state.hash,e,t))),_occlusionRenderer:r((e=>function(e,t){const s=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"Occlusion",skipIfTransparent:!0,appendFragmentOutputs:e=>e.push(`${s} = vec4(0.0, 0.0, 1.0, 1.0);`)}}(i._state.pickOcclusionHash,e)))},this._geometry=t.geometry?this._checkComponent2(["ReadableGeometry","VBOGeometry"],t.geometry):this.scene.geometry,this._material=s,this._xrayMaterial=t.xrayMaterial?this._checkComponent("EmphasisMaterial",t.xrayMaterial):this.scene.xrayMaterial,this._highlightMaterial=t.highlightMaterial?this._checkComponent("EmphasisMaterial",t.highlightMaterial):this.scene.highlightMaterial,this._selectedMaterial=t.selectedMaterial?this._checkComponent("EmphasisMaterial",t.selectedMaterial):this.scene.selectedMaterial,this._edgeMaterial=t.edgeMaterial?this._checkComponent("EdgeMaterial",t.edgeMaterial):this.scene.edgeMaterial,this._parentNode=null,this._aabb=null,this._aabbDirty=!0,this._numTriangles=this._geometry?this._geometry.numTriangles:0,this.scene._aabbDirty=!0,this._scale=R.vec3(),this._quaternion=R.identityQuaternion(),this._rotation=R.vec3(),this._position=R.vec3(),this._worldMatrix=R.identityMat4(),this._worldNormalMatrix=R.identityMat4(),this._localMatrixDirty=!0,this._worldMatrixDirty=!0,this._worldNormalMatrixDirty=!0;const o=t.origin||t.rtcCenter;if(o&&(this._state.origin=R.vec3(o),this._state.originHash=o.join()),t.matrix?this.matrix=t.matrix:(this.scale=t.scale,this.position=t.position,t.quaternion||(this.rotation=t.rotation)),this._isObject=t.isObject,this._isObject&&this.scene._registerObject(this),this._isModel=t.isModel,this._isModel&&this.scene._registerModel(this),this.visible=t.visible,this.culled=t.culled,this.pickable=t.pickable,this.clippable=t.clippable,this.collidable=t.collidable,this.castsShadow=t.castsShadow,this.receivesShadow=t.receivesShadow,this.xrayed=t.xrayed,this.highlighted=t.highlighted,this.selected=t.selected,this.edges=t.edges,this.layer=t.layer,this.colorize=t.colorize,this.opacity=t.opacity,this.offset=t.offset,t.parentId){const e=this.scene.components[t.parentId];e?e.isNode?e.addChild(this):this.error("Parent is not a Node: '"+t.parentId+"'"):this.error("Parent not found: '"+t.parentId+"'"),this._parentNode=e}else t.parent&&(t.parent.isNode||this.error("Parent is not a Node"),t.parent.addChild(this),this._parentNode=t.parent);this.compile()}get type(){return"Mesh"}get isMesh(){return!0}get parent(){return this._parentNode}get geometry(){return this._geometry}get material(){return this._material}get position(){return this._position}set position(e){this._position.set(e||[0,0,0]),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get rotation(){return this._rotation}set rotation(e){this._rotation.set(e||[0,0,0]),R.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get quaternion(){return this._quaternion}set quaternion(e){this._quaternion.set(e||[0,0,0,1]),R.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get scale(){return this._scale}set scale(e){this._scale.set(e||[1,1,1]),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get matrix(){return this._localMatrixDirty&&(this.__localMatrix||(this.__localMatrix=R.identityMat4()),R.composeMat4(this._position,this._quaternion,this._scale,this.__localMatrix),this._localMatrixDirty=!1),this.__localMatrix}set matrix(e){this.__localMatrix||(this.__localMatrix=R.identityMat4()),this.__localMatrix.set(e||kt),R.decomposeMat4(this.__localMatrix,this._position,this._quaternion,this._scale),this._localMatrixDirty=!1,this._setWorldMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get worldMatrix(){return this._worldMatrixDirty&&this._buildWorldMatrix(),this._worldMatrix}get worldNormalMatrix(){return this._worldNormalMatrixDirty&&this._buildWorldNormalMatrix(),this._worldNormalMatrix}get isEntity(){return!0}get isModel(){return this._isModel}get isObject(){return this._isObject}get isUI(){return this._state.isUI}get aabb(){return this._aabbDirty&&this._updateAABB(),this._aabb}get origin(){return this._state.origin}set origin(e){e?(this._state.origin||(this._state.origin=R.vec3()),this._state.origin.set(e),this._state.originHash=e.join(),this._setAABBDirty(),this.scene._aabbDirty=!0):this._state.origin&&(this._state.origin=null,this._state.originHash=null,this._setAABBDirty(),this.scene._aabbDirty=!0)}get rtcCenter(){return this.origin}set rtcCenter(e){this.origin=e}get numTriangles(){return this._numTriangles}get visible(){return this._state.visible}set visible(e){e=!1!==e,this._state.visible=e,this._isObject&&this.scene._objectVisibilityUpdated(this,e),this.glRedraw()}get xrayed(){return this._state.xrayed}set xrayed(e){e=!!e,this._state.xrayed!==e&&(this._state.xrayed=e,this._isObject&&this.scene._objectXRayedUpdated(this,e),this.glRedraw())}get highlighted(){return this._state.highlighted}set highlighted(e){(e=!!e)!==this._state.highlighted&&(this._state.highlighted=e,this._isObject&&this.scene._objectHighlightedUpdated(this,e),this.glRedraw())}get selected(){return this._state.selected}set selected(e){(e=!!e)!==this._state.selected&&(this._state.selected=e,this._isObject&&this.scene._objectSelectedUpdated(this,e),this.glRedraw())}get edges(){return this._state.edges}set edges(e){(e=!!e)!==this._state.edges&&(this._state.edges=e,this.glRedraw())}get culled(){return this._state.culled}set culled(e){this._state.culled=!!e,this.glRedraw()}get clippable(){return this._state.clippable}set clippable(e){e=!1!==e,this._state.clippable!==e&&(this._state.clippable=e,this.glRedraw())}get collidable(){return this._state.collidable}set collidable(e){(e=!1!==e)!==this._state.collidable&&(this._state.collidable=e,this._setAABBDirty(),this.scene._aabbDirty=!0)}get pickable(){return this._state.pickable}set pickable(e){e=!1!==e,this._state.pickable!==e&&(this._state.pickable=e)}get castsShadow(){return this._state.castsShadow}set castsShadow(e){(e=!1!==e)!==this._state.castsShadow&&(this._state.castsShadow=e,this.glRedraw())}get receivesShadow(){return this._state.receivesShadow}set receivesShadow(e){(e=!1!==e)!==this._state.receivesShadow&&(this._state.receivesShadow=e,this._state.hash=e?"/mod/rs;":"/mod;",this.fire("dirty",this))}get saoEnabled(){return!1}get colorize(){return this._state.colorize}set colorize(e){let t=this._state.colorize;t||(t=this._state.colorize=new Float32Array(4),t[3]=1),e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1);const s=!!e;this.scene._objectColorizeUpdated(this,s),this.glRedraw()}get opacity(){return this._state.colorize[3]}set opacity(e){let t=this._state.colorize;t||(t=this._state.colorize=new Float32Array(4),t[0]=1,t[1]=1,t[2]=1);const s=null!=e;t[3]=s?e:1,this.scene._objectOpacityUpdated(this,s),this.glRedraw()}get transparent(){return 2===this._material.alphaMode||this._state.colorize[3]<1}get layer(){return this._state.layer}set layer(e){e=e||0,(e=Math.round(e))!==this._state.layer&&(this._state.layer=e,this._renderer.needStateSort())}get stationary(){return this._state.stationary}get billboard(){return this._state.billboard}get offset(){return this._state.offset}set offset(e){this._state.offset.set(e||[0,0,0]),this._setAABBDirty(),this.glRedraw()}get isDrawable(){return!0}get isStateSortable(){return!0}get xrayMaterial(){return this._xrayMaterial}get highlightMaterial(){return this._highlightMaterial}get selectedMaterial(){return this._selectedMaterial}get edgeMaterial(){return this._edgeMaterial}_checkBillboard(e){return"spherical"!==(e=e||"none")&&"cylindrical"!==e&&"none"!==e&&(this.error("Unsupported value for 'billboard': "+e+" - accepted values are 'spherical', 'cylindrical' and 'none' - defaulting to 'none'."),e="none"),e}compile(){const e=this.scene,t=this._state,s=[e.canvas.canvas.id,e._sectionPlanesState.getHash()];t.stationary&&s.push("/s"),"none"===t.billboard?s.push("/n"):"spherical"===t.billboard?s.push("/s"):"cylindrical"===t.billboard&&s.push("/c"),s.push(";");const i=s.concat([e.gammaOutput?"go":"",e._lightsState.getHash(),t.receivesShadow?"/rs":""]).join("");this._state.drawHash!==i&&(this._state.drawHash=i,this._renderers._drawRenderer.put(),this._renderers._shadowRenderer.put(),this._renderers._emphasisFillRenderer.put(),this._renderers._emphasisEdgesRenderer.put(),this._renderers._drawRenderer.get(),this._renderers._emphasisFillRenderer.get(),this._renderers._emphasisEdgesRenderer.get());const r=s.join("");this._state.pickOcclusionHash!==r&&(this._state.pickOcclusionHash=r,this._renderers._pickMeshRenderer.put(),this._renderers._pickTriangleRenderer.put(),this._renderers._pickMeshRenderer.get(),this._state.occluder&&(this._renderers._occlusionRenderer.put(),this._renderers._occlusionRenderer.get()))}_setLocalMatrixDirty(){this._localMatrixDirty=!0,this._setWorldMatrixDirty()}_setWorldMatrixDirty(){this._worldMatrixDirty=!0,this._worldNormalMatrixDirty=!0}_buildWorldMatrix(){const e=this.matrix;if(this._parentNode)R.mulMat4(this._parentNode.worldMatrix,e,this._worldMatrix);else for(let t=0,s=e.length;t<s;t++)this._worldMatrix[t]=e[t];this._worldMatrixDirty=!1}_buildWorldNormalMatrix(){this._worldMatrixDirty&&this._buildWorldMatrix(),this._worldNormalMatrix||(this._worldNormalMatrix=R.mat4()),R.transposeMat4(this._worldMatrix,this._worldNormalMatrix),R.inverseMat4(this._worldNormalMatrix),this._worldNormalMatrixDirty=!1}_setAABBDirty(){if(this.collidable)for(let e=this;e;e=e._parentNode)e._aabbDirty=!0}_updateAABB(){this.scene._aabbDirty=!0,this._aabb||(this._aabb=R.AABB3()),this._buildAABB(this.worldMatrix,this._aabb),this._aabbDirty=!1}_buildAABB(e,t){R.transformOBB3(e,this._geometry.obb,Et),R.OBB3ToAABB3(Et,t);const s=this._state.offset;if(t[0]+=s[0],t[1]+=s[1],t[2]+=s[2],t[3]+=s[0],t[4]+=s[1],t[5]+=s[2],this._state.origin){const e=this._state.origin;t[0]+=e[0],t[1]+=e[1],t[2]+=e[2],t[3]+=e[0],t[4]+=e[1],t[5]+=e[2]}}rotate(e,t){return Ft[0]=e[0],Ft[1]=e[1],Ft[2]=e[2],Ft[3]=t*R.DEGTORAD,R.angleAxisToQuaternion(Ft,xt),R.mulQuaternions(this.quaternion,xt,Ut),this.quaternion=Ut,this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}rotateOnWorldAxis(e,t){return Ft[0]=e[0],Ft[1]=e[1],Ft[2]=e[2],Ft[3]=t*R.DEGTORAD,R.angleAxisToQuaternion(Ft,xt),R.mulQuaternions(xt,this.quaternion,xt),this}rotateX(e){return this.rotate(It,e)}rotateY(e){return this.rotate(Tt,e)}rotateZ(e){return this.rotate(Pt,e)}translate(e,t){return R.vec3ApplyQuaternion(this.quaternion,e,St),R.mulVec3Scalar(St,t,Dt),R.addVec3(this.position,Dt,this.position),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}translateX(e){return this.translate(It,e)}translateY(e){return this.translate(Tt,e)}translateZ(e){return this.translate(Pt,e)}stateSortCompare(e,t){return e._state.layer-t._state.layer||e._renderers._drawRenderer.getId()-t._renderers._drawRenderer.getId()||e._material._state.id-t._material._state.id||e._geometry._state.id-t._geometry._state.id}rebuildRenderFlags(){this.renderFlags.reset(),this._getActiveSectionPlanes()?(this.renderFlags.numLayers=1,this.renderFlags.numVisibleLayers=1,this.renderFlags.visibleLayers[0]=0,this._updateRenderFlags()):this.renderFlags.culled=!0}_updateRenderFlags(){const e=this.renderFlags,t=this._state;if(t.xrayed){const t=this._xrayMaterial._state;t.fill&&(t.fillAlpha<1?e.xrayedSilhouetteTransparent=!0:e.xrayedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.xrayedEdgesTransparent=!0:e.xrayedEdgesOpaque=!0)}else{if(this._material._state.alpha<1||t.colorize[3]<1?e.colorTransparent=!0:e.colorOpaque=!0,t.edges){this._edgeMaterial._state.alpha<1?e.edgesTransparent=!0:e.edgesOpaque=!0}if(t.selected){const t=this._selectedMaterial._state;t.fill&&(t.fillAlpha<1?e.selectedSilhouetteTransparent=!0:e.selectedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.selectedEdgesTransparent=!0:e.selectedEdgesOpaque=!0)}else if(t.highlighted){const t=this._highlightMaterial._state;t.fill&&(t.fillAlpha<1?e.highlightedSilhouetteTransparent=!0:e.highlightedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.highlightedEdgesTransparent=!0:e.highlightedEdgesOpaque=!0)}}}_getActiveSectionPlanes(){if(this._state.clippable){const e=this.scene._sectionPlanesState.sectionPlanes,t=e.length;if(t>0)for(let s=0;s<t;s++){const t=e[s],i=this.renderFlags;if(t.active)if(this._state.origin){const e=R.planeAABB3Intersect(t.dir,t.dist,this.aabb);if(-1===e)return!1;const r=0===e;i.sectionPlanesActivePerLayer[s]=r}else i.sectionPlanesActivePerLayer[s]=!0;else i.sectionPlanesActivePerLayer[s]=!1}}return!0}drawColorOpaque(e){this._renderers._drawRenderer.drawMesh(e,this,this._material)}drawColorTransparent(e){this._renderers._drawRenderer.drawMesh(e,this,this._material)}drawSilhouetteXRayed(e){this._renderers._emphasisFillRenderer.drawMesh(e,this,this._xrayMaterial)}drawSilhouetteHighlighted(e){this._renderers._emphasisFillRenderer.drawMesh(e,this,this._highlightMaterial)}drawSilhouetteSelected(e){this._renderers._emphasisFillRenderer.drawMesh(e,this,this._selectedMaterial)}drawEdgesColorOpaque(e){this._renderers._emphasisEdgesRenderer.drawMesh(e,this,this._edgeMaterial)}drawEdgesColorTransparent(e){this._renderers._emphasisEdgesRenderer.drawMesh(e,this,this._edgeMaterial)}drawEdgesXRayed(e){this._renderers._emphasisEdgesRenderer.drawMesh(e,this,this._xrayMaterial)}drawEdgesHighlighted(e){this._renderers._emphasisEdgesRenderer.drawMesh(e,this,this._highlightMaterial)}drawEdgesSelected(e){this._renderers._emphasisEdgesRenderer.drawMesh(e,this,this._selectedMaterial)}drawOcclusion(e){this._renderers._occlusionRenderer.drawMesh(e,this,this._material)}drawShadow(e){this._renderers._shadowRenderer.drawMesh(e,this,this._material)}drawPickMesh(e){this._renderers._pickMeshRenderer.drawMesh(e,this,this._material)}canPickTriangle(){return this._geometry.isReadableGeometry}drawPickTriangles(e){this._renderers._pickTriangleRenderer.drawMesh(e,this,this._material)}pickTriangleSurface(e,t,s,i){Vt(this,e,t,s,i)}drawPickVertices(e){}delegatePickedEntity(){return this}destroy(){super.destroy(),Object.values(this._renderers).forEach((e=>e.put())),this.scene._renderer.putPickID(this._state.pickID),this._isObject&&(this.scene._deregisterObject(this),this._visible&&this.scene._objectVisibilityUpdated(this,!1,!1),this._xrayed&&this.scene._objectXRayedUpdated(this,!1,!1),this._selected&&this.scene._objectSelectedUpdated(this,!1,!1),this._highlighted&&this.scene._objectHighlightedUpdated(this,!1,!1),this.scene._objectColorizeUpdated(this,!1),this.scene._objectOpacityUpdated(this,!1),this.offset.some((e=>0!==e))&&this.scene._objectOffsetUpdated(this,!1)),this._isModel&&this.scene._deregisterModel(this),this.glRedraw()}}const Vt=function(){const e=R.vec3(),t=R.vec3(),s=R.vec3(),i=R.vec3(),r=R.vec3(),n=R.vec3(),A=R.vec4(),o=R.vec3(),a=R.vec3(),l=R.vec3(),c=R.vec3(),h=R.vec3(),u=R.vec3(),d=R.vec3(),p=R.vec3(),f=R.vec3(),g=R.vec4(),m=R.vec4(),_=R.vec4(),b=R.vec3(),B=R.vec3(),y=R.vec3(),w=R.vec3(),v=R.vec3(),C=R.vec3(),M=R.vec3(),E=R.vec3(),F=R.vec3(),x=R.vec3(),U=R.vec3();return function(I,T,P,S,D){var k=D.primIndex;if(null!=k&&k>-1){const L=I.geometry._state,H=I.scene,N=H.camera,G=H.canvas;if("triangles"===L.primitiveName){D.primitive="triangle";const H=k,j=L.indices,W=L.positions;let z,X,K;if(j){var Q=j[H+0],O=j[H+1],V=j[H+2];n[0]=Q,n[1]=O,n[2]=V,D.indices=n,z=3*Q,X=3*O,K=3*V}else z=3*H,X=z+3,K=X+3;if(s[0]=W[z+0],s[1]=W[z+1],s[2]=W[z+2],i[0]=W[X+0],i[1]=W[X+1],i[2]=W[X+2],r[0]=W[K+0],r[1]=W[K+1],r[2]=W[K+2],L.compressGeometry){const e=L.positionsDecodeMatrix;e&&(Re.decompressPosition(s,e,s),Re.decompressPosition(i,e,i),Re.decompressPosition(r,e,r))}D.canvasPos?R.canvasPosToLocalRay(G.canvas,I.origin?ut(T,I.origin):T,P,S,I.worldMatrix,D.canvasPos,e,t):D.origin&&D.direction&&R.worldRayToLocalRay(I.worldMatrix,D.origin,D.direction,e,t),R.normalizeVec3(t),R.rayPlaneIntersect(e,t,s,i,r,A),D.localPos=A,D.position=A,g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=1,R.transformVec4(I.worldMatrix,g,m),o[0]=m[0],o[1]=m[1],o[2]=m[2],D.canvasPos&&I.origin&&(o[0]+=I.origin[0],o[1]+=I.origin[1],o[2]+=I.origin[2]),D.worldPos=o,R.transformVec4(N.matrix,m,_),a[0]=_[0],a[1]=_[1],a[2]=_[2],D.viewPos=a,R.cartesianToBarycentric(A,s,i,r,l),D.bary=l;const Z=L.normals;if(Z){if(L.compressGeometry){const e=3*Q,t=3*O,s=3*V;Re.decompressNormal(Z.subarray(e,e+2),c),Re.decompressNormal(Z.subarray(t,t+2),h),Re.decompressNormal(Z.subarray(s,s+2),u)}else c[0]=Z[z],c[1]=Z[z+1],c[2]=Z[z+2],h[0]=Z[X],h[1]=Z[X+1],h[2]=Z[X+2],u[0]=Z[K],u[1]=Z[K+1],u[2]=Z[K+2];const e=R.addVec3(R.addVec3(R.mulVec3Scalar(c,l[0],b),R.mulVec3Scalar(h,l[1],B),y),R.mulVec3Scalar(u,l[2],w),v);D.worldNormal=R.normalizeVec3(R.transformVec3(I.worldNormalMatrix,e,C))}const J=L.uv;if(J){if(d[0]=J[2*Q],d[1]=J[2*Q+1],p[0]=J[2*O],p[1]=J[2*O+1],f[0]=J[2*V],f[1]=J[2*V+1],L.compressGeometry){const e=L.uvDecodeMatrix;e&&(Re.decompressUV(d,e,d),Re.decompressUV(p,e,p),Re.decompressUV(f,e,f))}D.uv=R.addVec3(R.addVec3(R.mulVec2Scalar(d,l[0],M),R.mulVec2Scalar(p,l[1],E),F),R.mulVec2Scalar(f,l[2],x),U)}}}}}(),Lt=(e,t,s,i,r)=>{const n=r.programVariables,A=s.decodedUv,o=s.worldNormal,a=s.viewNormal,l=e.scene,c=l.canvas.gl,h=e._state.background,u=e._geometry._state,d=u.compressGeometry,p="points"===u.primitiveName,f=n.createUniform("float","pointSize"),g=n.createUniform("mat4","modelMatrix"),m=n.createUniform("mat4","modelNormalMatrix"),_=n.createUniform("vec3","offset"),b=n.createUniform("vec3","scale"),B=n.createUniform("mat4","positionsDecodeMatrix"),y=n.createUniform("mat3","uvDecodeMatrix"),w=n.createUniform("mat4","viewMatrix"),v=n.createUniform("mat4","viewNormalMatrix"),C=n.createUniform("mat4","projMatrix"),M=e.billboard,E=!i.dontBillboardAnything&&("spherical"===M||"cylindrical"===M),F=e.stationary,x=E&&((e,t)=>[`mat4 ${e}(in mat4 matIn) {`," mat4 mat = matIn;",` mat[0].xyz = vec3(${b}[0], 0.0, 0.0);`,..."spherical"===M?[` mat[1].xyz = vec3(0.0, ${b}[1], 0.0);`]:[]," mat[2].xyz = vec3(0.0, 0.0, 1.0);"," return mat;","}"].forEach((e=>t.push(e)))),U=function(){const e=x&&n.createVertexDefinition("billboard",x);return t=>e?`${e}(${t})`:t}(),I=function(){const e=x&&n.createFragmentDefinition("billboard",x);return t=>e?`${e}(${t})`:t}(),T=[];i.dontBillboardAnything?T.push(`mat4 viewMatrix2 = ${w};`):(T.push(`mat4 viewMatrix1 = ${w};`),F?T.push("viewMatrix1[3].xyz = vec3(0.0, 0.0, 0.0);"):h&&T.push("viewMatrix1[3] = vec4(0.0, 0.0, 0.0, 1.0);"),T.push(`mat4 viewMatrix2 = ${I("viewMatrix1")};`));const P="clipPos",S=n.createUniform("bool","clippable"),[D,k]=r.buildProgram(c,i.programName,{appendFragmentOutputs:(e,t,s,r)=>{T.forEach((t=>e.push(t))),i.appendFragmentOutputs(e,t,s,r)},clippableTest:()=>S,clippingCaps:i.clippingCaps,clipPos:h?"clipPos.xyww":P,crossSections:l.crossSections,discardPoints:p&&i.discardPoints,getGammaFactor:l.gammaOutput&&(()=>l.gammaFactor),getLogDepth:!i.dontGetLogDepth&&l.logarithmicDepthBufferEnabled&&(e=>e),getPointSize:i.setupPointSize&&p&&(()=>f),getVertexData:function(){const e=a&&a.needed&&`vec3 ${a} = normalize((${U(v)} * vec4(${o}, 0.0)).xyz);`,s=[];if(s.push(`vec4 localPosition = vec4(${t.position}, 1.0);`),d&&s.push(`localPosition = ${B} * localPosition;`),s.push(`vec4 worldPosition = ${U(g)} * localPosition;`),s.push(`worldPosition.xyz = worldPosition.xyz + ${_};`),i.dontBillboardAnything?s.push(`vec4 viewPosition = ${w} * worldPosition;`):(s.push(`mat4 viewMatrix1 = ${w};`),F?s.push("viewMatrix1[3].xyz = vec3(0.0, 0.0, 0.0);"):h&&s.push("viewMatrix1[3] = vec4(0.0, 0.0, 0.0, 1.0);"),s.push(`mat4 viewMatrix2 = ${U("viewMatrix1")};`),s.push(`vec4 viewPosition = ${E?`${U(`viewMatrix1 * ${g}`)} * localPosition`:"viewMatrix2 * worldPosition"};`)),A&&A.needed&&s.push(`vec2 ${A} = ${d?`(${y} * vec3(${t.uv}, 1.0)).xy`:t.uv};`),o&&o.needed){const e=d?`${n.commonLibrary.octDecode}(${t.normal}.xy)`:t.normal;s.push(`vec3 ${o} = (${U(m)} * vec4(${e}, 0.0)).xyz;`)}return e&&s.push(e),s.push(`vec4 clipPos = ${C} * viewPosition;`),s},projMatrix:C,sectionPlanesState:l._sectionPlanesState,testPerspectiveForGl_FragDepth:!0,usePickClipPos:i.isPick,worldPositionAttribute:"worldPosition"});if(k)return{errors:k};{const e=D.inputSetters;let s=null,r=null;return{destroy:()=>D.destroy(),drawMesh:(n,A,o)=>{if(i.skipIfTransparent&&o.alpha<1)return;const a=o._state,l=A._state,u=A._geometry,d=u._state,p=n.viewParams,M=i.canActAsBackground&&h;n.lastProgramId!==D.id&&(n.lastProgramId=D.id,D.bind(),n.useProgram++,s=null,r=null,M&&c.depthFunc(c.LEQUAL)),a.id!==s&&(n.backfaces!==a.backfaces&&(a.backfaces?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE),n.backfaces=a.backfaces),i.dontSetFrontFace||n.frontface===a.frontface||(c.frontFace(a.frontface?c.CCW:c.CW),n.frontface=a.frontface),i.drawEdges&&n.lineWidth!==a.edgeWidth&&(c.lineWidth(a.edgeWidth),n.lineWidth=a.edgeWidth),i.setsLineWidth&&n.lineWidth!==a.lineWidth&&(c.lineWidth(a.lineWidth),n.lineWidth=a.lineWidth),s=a.id);const E=!i.useShadowView&&A.origin;((t,s)=>{const i=(e,t)=>e.setInputValue&&e.setInputValue(t);i(f,o.pointSize),i(g,A.worldMatrix),i(m,A.worldNormalMatrix),i(_,A.offset),i(b,A.scale),i(B,d.positionsDecodeMatrix),i(y,d.uvDecodeMatrix),i(w,s),i(v,p.viewNormalMatrix),i(C,t),i(S,A.clippable),e.setUniforms(n,{material:o,meshColorize:A.colorize,meshPickID:A._state.pickID,mesh:{origin:A.origin,renderFlags:{sectionPlanesActivePerLayer:A.renderFlags.sectionPlanesActivePerLayer}},view:{far:p.far}})})(p.projMatrix,E?n.getRTCViewMatrix(l.originHash,E):p.viewMatrix);const F=e=>{const s=(e,t)=>{e&&e.setInputValue&&t&&(e.setInputValue(t),n.bindArray++)};s(t.position,(e||d).positionsBuf),s(t.color,d.colorsBuf),s(t.pickColor,e&&e.pickColorsBuf),s(t.uv,d.uvBuf),s(t.normal,d.normalsBuf)};if(i.trianglePick){const e=u._getPickTrianglePositions();d.id!==r&&(F({positionsBuf:e,pickColorsBuf:u._getPickTriangleColors()}),r=d.id),c.drawArrays(d.primitive,0,e.numItems/3)}else if(i.drawEdges){const e=d.primitive===c.TRIANGLES?u._getEdgeIndices():d.primitive===c.LINES&&d.indicesBuf;e&&(d.id!==r&&(F(),e.bind(),n.bindArray++,r=d.id),c.drawElements(c.LINES,e.numItems,e.itemType,0),n.drawElements++)}else d.id!==r&&(F(),d.indicesBuf&&(d.indicesBuf.bind(),n.bindArray++),r=d.id),d.indicesBuf?(c.drawElements(d.primitive,d.indicesBuf.numItems,d.indicesBuf.itemType,0),n.drawElements++):d.positionsBuf&&(c.drawArrays(c.TRIANGLES,0,d.positionsBuf.numItems),n.drawArrays++);M&&c.depthFunc(c.LESS)}}}};class Ht extends ie{get type(){return"Material"}constructor(e,t={}){super(e,t),L.memory.materials++}destroy(){super.destroy(),L.memory.materials--}}const Nt={opaque:0,mask:1,blend:2},Gt=["opaque","mask","blend"];class jt extends Ht{get type(){return"PhongMaterial"}constructor(e,t={}){super(e,t),this._state=new xe({type:"PhongMaterial",ambient:R.vec3([1,1,1]),diffuse:R.vec3([1,1,1]),specular:R.vec3([1,1,1]),emissive:R.vec3([0,0,0]),alpha:null,shininess:null,reflectivity:null,alphaMode:null,alphaCutoff:null,lineWidth:null,pointSize:null,backfaces:null,frontface:null,hash:null}),this.ambient=t.ambient,this.diffuse=t.diffuse,this.specular=t.specular,this.emissive=t.emissive,this.alpha=t.alpha,this.shininess=t.shininess,this.reflectivity=t.reflectivity,this.lineWidth=t.lineWidth,this.pointSize=t.pointSize,t.ambientMap&&(this._ambientMap=this._checkComponent("Texture",t.ambientMap)),t.diffuseMap&&(this._diffuseMap=this._checkComponent("Texture",t.diffuseMap)),t.specularMap&&(this._specularMap=this._checkComponent("Texture",t.specularMap)),t.emissiveMap&&(this._emissiveMap=this._checkComponent("Texture",t.emissiveMap)),t.alphaMap&&(this._alphaMap=this._checkComponent("Texture",t.alphaMap)),t.reflectivityMap&&(this._reflectivityMap=this._checkComponent("Texture",t.reflectivityMap)),t.normalMap&&(this._normalMap=this._checkComponent("Texture",t.normalMap)),t.occlusionMap&&(this._occlusionMap=this._checkComponent("Texture",t.occlusionMap)),t.diffuseFresnel&&(this._diffuseFresnel=this._checkComponent("Fresnel",t.diffuseFresnel)),t.specularFresnel&&(this._specularFresnel=this._checkComponent("Fresnel",t.specularFresnel)),t.emissiveFresnel&&(this._emissiveFresnel=this._checkComponent("Fresnel",t.emissiveFresnel)),t.alphaFresnel&&(this._alphaFresnel=this._checkComponent("Fresnel",t.alphaFresnel)),t.reflectivityFresnel&&(this._reflectivityFresnel=this._checkComponent("Fresnel",t.reflectivityFresnel)),this.alphaMode=t.alphaMode,this.alphaCutoff=t.alphaCutoff,this.backfaces=t.backfaces,this.frontface=t.frontface,this._makeHash()}_makeHash(){const e=this._state,t=["/p"];this._normalMap&&(t.push("/nm"),this._normalMap.hasMatrix&&t.push("/mat")),this._ambientMap&&(t.push("/am"),this._ambientMap.hasMatrix&&t.push("/mat"),t.push("/"+this._ambientMap.encoding)),this._diffuseMap&&(t.push("/dm"),this._diffuseMap.hasMatrix&&t.push("/mat"),t.push("/"+this._diffuseMap.encoding)),this._specularMap&&(t.push("/sm"),this._specularMap.hasMatrix&&t.push("/mat")),this._emissiveMap&&(t.push("/em"),this._emissiveMap.hasMatrix&&t.push("/mat"),t.push("/"+this._emissiveMap.encoding)),this._alphaMap&&(t.push("/opm"),this._alphaMap.hasMatrix&&t.push("/mat")),this._reflectivityMap&&(t.push("/rm"),this._reflectivityMap.hasMatrix&&t.push("/mat")),this._occlusionMap&&(t.push("/ocm"),this._occlusionMap.hasMatrix&&t.push("/mat")),this._diffuseFresnel&&t.push("/df"),this._specularFresnel&&t.push("/sf"),this._emissiveFresnel&&t.push("/ef"),this._alphaFresnel&&t.push("/of"),this._reflectivityFresnel&&t.push("/rf"),t.push(";"),e.hash=t.join("")}set ambient(e){let t=this._state.ambient;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.ambient=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=.2,t[1]=.2,t[2]=.2),this.glRedraw()}get ambient(){return this._state.ambient}set diffuse(e){let t=this._state.diffuse;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.diffuse=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1),this.glRedraw()}get diffuse(){return this._state.diffuse}set specular(e){let t=this._state.specular;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.specular=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1),this.glRedraw()}get specular(){return this._state.specular}set emissive(e){let t=this._state.emissive;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.emissive=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=0,t[1]=0,t[2]=0),this.glRedraw()}get emissive(){return this._state.emissive}set alpha(e){e=null!=e?e:1,this._state.alpha!==e&&(this._state.alpha=e,this.glRedraw())}get alpha(){return this._state.alpha}set shininess(e){this._state.shininess=void 0!==e?e:80,this.glRedraw()}get shininess(){return this._state.shininess}set lineWidth(e){this._state.lineWidth=e||1,this.glRedraw()}get lineWidth(){return this._state.lineWidth}set pointSize(e){this._state.pointSize=e||1,this.glRedraw()}get pointSize(){return this._state.pointSize}set reflectivity(e){this._state.reflectivity=void 0!==e?e:1,this.glRedraw()}get reflectivity(){return this._state.reflectivity}get normalMap(){return this._normalMap}get ambientMap(){return this._ambientMap}get diffuseMap(){return this._diffuseMap}get specularMap(){return this._specularMap}get emissiveMap(){return this._emissiveMap}get alphaMap(){return this._alphaMap}get reflectivityMap(){return this._reflectivityMap}get occlusionMap(){return this._occlusionMap}get diffuseFresnel(){return this._diffuseFresnel}get specularFresnel(){return this._specularFresnel}get emissiveFresnel(){return this._emissiveFresnel}get alphaFresnel(){return this._alphaFresnel}get reflectivityFresnel(){return this._reflectivityFresnel}set alphaMode(e){let t=Nt[e=e||"opaque"];void 0===t&&(this.error("Unsupported value for 'alphaMode': "+e+" - defaulting to 'opaque'"),t="opaque"),this._state.alphaMode!==t&&(this._state.alphaMode=t,this.glRedraw())}get alphaMode(){return Gt[this._state.alphaMode]}set alphaCutoff(e){null==e&&(e=.5),this._state.alphaCutoff!==e&&(this._state.alphaCutoff=e)}get alphaCutoff(){return this._state.alphaCutoff}set backfaces(e){e=!!e,this._state.backfaces!==e&&(this._state.backfaces=e,this.glRedraw())}get backfaces(){return this._state.backfaces}set frontface(e){e="cw"!==e,this._state.frontface!==e&&(this._state.frontface=e,this.glRedraw())}get frontface(){return this._state.frontface?"ccw":"cw"}destroy(){super.destroy(),this._state.destroy()}}function Wt(e,t){if(void 0===e._cachedExtensions&&(e._cachedExtensions={}),void 0!==e._cachedExtensions[t])return e._cachedExtensions[t];let s;switch(t){case"WEBGL_depth_texture":s=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=e.getExtension(t)}return e._cachedExtensions[t]=s,s}function zt(e,t,s=null){let i;const r=t;if(1009===r)return e.UNSIGNED_BYTE;if(1017===r)return e.UNSIGNED_SHORT_4_4_4_4;if(1018===r)return e.UNSIGNED_SHORT_5_5_5_1;if(1010===r)return e.BYTE;if(1011===r)return e.SHORT;if(1012===r)return e.UNSIGNED_SHORT;if(1013===r)return e.INT;if(1014===r)return e.UNSIGNED_INT;if(1015===r)return e.FLOAT;if(1016===r)return e.HALF_FLOAT;if(1021===r)return e.ALPHA;if(1023===r)return e.RGBA;if(1024===r)return e.LUMINANCE;if(1025===r)return e.LUMINANCE_ALPHA;if(1026===r)return e.DEPTH_COMPONENT;if(1027===r)return e.DEPTH_STENCIL;if(1028===r)return e.RED;if(1022===r)return e.RGBA;if(1029===r)return e.RED_INTEGER;if(1030===r)return e.RG;if(1031===r)return e.RG_INTEGER;if(1033===r)return e.RGBA_INTEGER;if(33776===r||33777===r||33778===r||33779===r)if(3001===s){const t=Wt(e,"WEBGL_compressed_texture_s3tc_srgb");if(null===t)return null;if(33776===r)return t.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(33777===r)return t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(33778===r)return t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(33779===r)return t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(i=Wt(e,"WEBGL_compressed_texture_s3tc"),null===i)return null;if(33776===r)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===r)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===r)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===r)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===r||35841===r||35842===r||35843===r){const t=Wt(e,"WEBGL_compressed_texture_pvrtc");if(null===t)return null;if(35840===r)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===r)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===r)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===r)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===r){const t=Wt(e,"WEBGL_compressed_texture_etc1");return null!==t?t.COMPRESSED_RGB_ETC1_WEBGL:null}if(37492===r||37496===r){const t=Wt(e,"WEBGL_compressed_texture_etc");if(null===t)return null;if(37492===r)return 3001===s?t.COMPRESSED_SRGB8_ETC2:t.COMPRESSED_RGB8_ETC2;if(37496===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:t.COMPRESSED_RGBA8_ETC2_EAC}if(37808===r||37809===r||37810===r||37811===r||37812===r||37813===r||37814===r||37815===r||37816===r||37817===r||37818===r||37819===r||37820===r||37821===r){const t=Wt(e,"WEBGL_compressed_texture_astc");if(null===t)return null;if(37808===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:t.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:t.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:t.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:t.COMPRESSED_RGBA_ASTC_6x5_KHR;if(37812===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:t.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:t.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:t.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:t.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:t.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:t.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:t.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:t.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:t.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:t.COMPRESSED_RGBA_ASTC_12x12_KHR}if(36492===r){const t=Wt(e,"EXT_texture_compression_bptc");if(null===t)return null;if(36492===r)return 3001===s?t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:t.COMPRESSED_RGBA_BPTC_UNORM_EXT}return 1020===r?e.UNSIGNED_INT_24_8:1e3===r?e.REPEAT:1001===r?e.CLAMP_TO_EDGE:1004===r||1005===r?e.NEAREST_MIPMAP_LINEAR:1007===r?e.LINEAR_MIPMAP_NEAREST:1008===r?e.LINEAR_MIPMAP_LINEAR:1003===r?e.NEAREST:1006===r?e.LINEAR:null}const Xt=new Uint8Array([0,0,0,1]);class Kt{constructor({gl:e,target:t,format:s,type:i,wrapS:r,wrapT:n,wrapR:A,encoding:o,preloadColor:a,premultiplyAlpha:l,flipY:c}){this.gl=e,this.target=t||e.TEXTURE_2D,this.format=s||1023,this.type=i||1009,this.internalFormat=null,this.premultiplyAlpha=!!l,this.flipY=!!c,this.unpackAlignment=4,this.wrapS=r||1e3,this.wrapT=n||1e3,this.wrapR=A||1e3,this.encoding=o||3001,this.texture=e.createTexture(),a&&this.setPreloadColor(a),this.allocated=!0}setPreloadColor(e){e?(Xt[0]=Math.floor(255*e[0]),Xt[1]=Math.floor(255*e[1]),Xt[2]=Math.floor(255*e[2]),Xt[3]=Math.floor(255*(void 0!==e[3]?e[3]:1))):(Xt[0]=0,Xt[1]=0,Xt[2]=0,Xt[3]=255);const t=this.gl;if(t.bindTexture(this.target,this.texture),this.target===t.TEXTURE_CUBE_MAP){const e=[t.TEXTURE_CUBE_MAP_POSITIVE_X,t.TEXTURE_CUBE_MAP_NEGATIVE_X,t.TEXTURE_CUBE_MAP_POSITIVE_Y,t.TEXTURE_CUBE_MAP_NEGATIVE_Y,t.TEXTURE_CUBE_MAP_POSITIVE_Z,t.TEXTURE_CUBE_MAP_NEGATIVE_Z];for(let s=0,i=e.length;s<i;s++)t.texImage2D(e[s],0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Xt)}else t.texImage2D(this.target,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Xt);t.bindTexture(this.target,null)}setTarget(e){this.target=e||this.gl.TEXTURE_2D}setImage(e,t={}){const s=this.gl;void 0!==t.format&&(this.format=t.format),void 0!==t.internalFormat&&(this.internalFormat=t.internalFormat),void 0!==t.encoding&&(this.encoding=t.encoding),void 0!==t.type&&(this.type=t.type),void 0!==t.flipY&&(this.flipY=t.flipY),void 0!==t.premultiplyAlpha&&(this.premultiplyAlpha=t.premultiplyAlpha),void 0!==t.unpackAlignment&&(this.unpackAlignment=t.unpackAlignment),void 0!==t.minFilter&&(this.minFilter=t.minFilter),void 0!==t.magFilter&&(this.magFilter=t.magFilter),void 0!==t.wrapS&&(this.wrapS=t.wrapS),void 0!==t.wrapT&&(this.wrapT=t.wrapT),void 0!==t.wrapR&&(this.wrapR=t.wrapR);let i=!1;s.bindTexture(this.target,this.texture);const r=s.getParameter(s.UNPACK_FLIP_Y_WEBGL);s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,this.flipY);const n=s.getParameter(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL);s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha);const A=s.getParameter(s.UNPACK_ALIGNMENT);s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment);const o=s.getParameter(s.UNPACK_COLORSPACE_CONVERSION_WEBGL);s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE);const a=zt(s,this.minFilter);s.texParameteri(this.target,s.TEXTURE_MIN_FILTER,a),a!==s.NEAREST_MIPMAP_NEAREST&&a!==s.LINEAR_MIPMAP_NEAREST&&a!==s.NEAREST_MIPMAP_LINEAR&&a!==s.LINEAR_MIPMAP_LINEAR||(i=!0);const l=zt(s,this.magFilter);l&&s.texParameteri(this.target,s.TEXTURE_MAG_FILTER,l);const c=zt(s,this.wrapS);c&&s.texParameteri(this.target,s.TEXTURE_WRAP_S,c);const h=zt(s,this.wrapT);h&&s.texParameteri(this.target,s.TEXTURE_WRAP_T,h);const u=zt(s,this.format,this.encoding),d=zt(s,this.type),p=Zt(s,this.internalFormat,u,d,this.encoding,!1);if(this.target===s.TEXTURE_CUBE_MAP){if(j.isArray(e)){const t=e,i=[s.TEXTURE_CUBE_MAP_POSITIVE_X,s.TEXTURE_CUBE_MAP_NEGATIVE_X,s.TEXTURE_CUBE_MAP_POSITIVE_Y,s.TEXTURE_CUBE_MAP_NEGATIVE_Y,s.TEXTURE_CUBE_MAP_POSITIVE_Z,s.TEXTURE_CUBE_MAP_NEGATIVE_Z];for(let e=0,r=i.length;e<r;e++)s.texImage2D(i[e],0,p,u,d,t[e])}}else s.texImage2D(s.TEXTURE_2D,0,p,u,d,e);i&&s.generateMipmap(this.target),s.bindTexture(this.target,null),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,r),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n),s.pixelStorei(s.UNPACK_ALIGNMENT,A),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,o)}setCompressedData({mipmaps:e,props:t={}}){const s=this.gl,i=e.length;void 0!==t.format&&(this.format=t.format),void 0!==t.internalFormat&&(this.internalFormat=t.internalFormat),void 0!==t.encoding&&(this.encoding=t.encoding),void 0!==t.type&&(this.type=t.type),void 0!==t.flipY&&(this.flipY=t.flipY),void 0!==t.premultiplyAlpha&&(this.premultiplyAlpha=t.premultiplyAlpha),void 0!==t.unpackAlignment&&(this.unpackAlignment=t.unpackAlignment),void 0!==t.minFilter&&(this.minFilter=t.minFilter),void 0!==t.magFilter&&(this.magFilter=t.magFilter),void 0!==t.wrapS&&(this.wrapS=t.wrapS),void 0!==t.wrapT&&(this.wrapT=t.wrapT),void 0!==t.wrapR&&(this.wrapR=t.wrapR),s.activeTexture(s.TEXTURE0+0),s.bindTexture(this.target,this.texture);let r=e.length>1;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,this.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE);const n=zt(s,this.wrapS);n&&s.texParameteri(this.target,s.TEXTURE_WRAP_S,n);const A=zt(s,this.wrapT);if(A&&s.texParameteri(this.target,s.TEXTURE_WRAP_T,A),this.type===s.TEXTURE_3D||this.type===s.TEXTURE_2D_ARRAY){const e=zt(s,this.wrapR);e&&s.texParameteri(this.target,s.TEXTURE_WRAP_R,e),s.texParameteri(this.type,s.TEXTURE_WRAP_R,e)}r?(s.texParameteri(this.target,s.TEXTURE_MIN_FILTER,Jt(s,this.minFilter)),s.texParameteri(this.target,s.TEXTURE_MAG_FILTER,Jt(s,this.magFilter))):(s.texParameteri(this.target,s.TEXTURE_MIN_FILTER,zt(s,this.minFilter)),s.texParameteri(this.target,s.TEXTURE_MAG_FILTER,zt(s,this.magFilter)));const o=zt(s,this.format,this.encoding),a=zt(s,this.type),l=Zt(s,this.internalFormat,o,a,this.encoding,!1);s.texStorage2D(s.TEXTURE_2D,i,l,e[0].width,e[0].height);for(let t=0,i=e.length;t<i;t++){const i=e[t];1023!==this.format?null!==o?s.compressedTexSubImage2D(s.TEXTURE_2D,t,0,0,i.width,i.height,o,i.data):console.warn("Attempt to load unsupported compressed texture format in .setCompressedData()"):s.texSubImage2D(s.TEXTURE_2D,t,0,0,i.width,i.height,o,a,i.data)}s.bindTexture(this.target,null)}setProps(e){const t=this.gl;t.bindTexture(this.target,this.texture),this._uploadProps(e),t.bindTexture(this.target,null)}_uploadProps(e){const t=this.gl;if(void 0!==e.format&&(this.format=e.format),void 0!==e.internalFormat&&(this.internalFormat=e.internalFormat),void 0!==e.encoding&&(this.encoding=e.encoding),void 0!==e.type&&(this.type=e.type),void 0!==e.minFilter){const s=zt(t,e.minFilter);s&&(this.minFilter=e.minFilter,t.texParameteri(this.target,t.TEXTURE_MIN_FILTER,s),s!==t.NEAREST_MIPMAP_NEAREST&&s!==t.LINEAR_MIPMAP_NEAREST&&s!==t.NEAREST_MIPMAP_LINEAR&&s!==t.LINEAR_MIPMAP_LINEAR||t.generateMipmap(this.target))}if(void 0!==e.magFilter){const s=zt(t,e.magFilter);s&&(this.magFilter=e.magFilter,t.texParameteri(this.target,t.TEXTURE_MAG_FILTER,s))}if(void 0!==e.wrapS){const s=zt(t,e.wrapS);s&&(this.wrapS=e.wrapS,t.texParameteri(this.target,t.TEXTURE_WRAP_S,s))}if(void 0!==e.wrapT){const s=zt(t,e.wrapT);s&&(this.wrapT=e.wrapT,t.texParameteri(this.target,t.TEXTURE_WRAP_T,s))}}bind(e){if(this.allocated){if(this.texture){const t=this.gl;return t.activeTexture(t["TEXTURE"+e]),t.bindTexture(this.target,this.texture),!0}return!1}}unbind(e){if(this.allocated&&this.texture){const t=this.gl;t.activeTexture(t["TEXTURE"+e]),t.bindTexture(this.target,null)}}destroy(){this.allocated&&this.texture&&(this.gl.deleteTexture(this.texture),this.texture=null)}}function Zt(e,t,s,i,r,n=!1){if(null!==t){if(void 0!==e[t])return e[t];console.warn("Attempt to use non-existing WebGL internal format '"+t+"'")}let A=s;return s===e.RED&&(i===e.FLOAT&&(A=e.R32F),i===e.HALF_FLOAT&&(A=e.R16F),i===e.UNSIGNED_BYTE&&(A=e.R8)),s===e.RG&&(i===e.FLOAT&&(A=e.RG32F),i===e.HALF_FLOAT&&(A=e.RG16F),i===e.UNSIGNED_BYTE&&(A=e.RG8)),s===e.RGBA&&(i===e.FLOAT&&(A=e.RGBA32F),i===e.HALF_FLOAT&&(A=e.RGBA16F),i===e.UNSIGNED_BYTE&&(A=3001===r&&!1===n?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT_4_4_4_4&&(A=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(A=e.RGB5_A1)),A!==e.R16F&&A!==e.R32F&&A!==e.RG16F&&A!==e.RG32F&&A!==e.RGBA16F&&A!==e.RGBA32F||Wt(e,"EXT_color_buffer_float"),A}function Jt(e,t){return 1003===t||1004===t||1005===t?e.NEAREST:e.LINEAR}function Yt(e){if(!$t(e.width)||!$t(e.height)){const t=document.createElement("canvas");t.width=qt(e.width),t.height=qt(e.height);t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),e=t}return e}function $t(e){return 0==(e&e-1)}function qt(e){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1}class es extends ie{get type(){return"Texture"}constructor(e,t={}){super(e,t),this._state=new xe({texture:new Kt({gl:this.scene.canvas.gl}),matrix:R.identityMat4(),hasMatrix:t.translate&&(0!==t.translate[0]||0!==t.translate[1])||!!t.rotate||t.scale&&(0!==t.scale[0]||0!==t.scale[1]),minFilter:this._checkMinFilter(t.minFilter),magFilter:this._checkMagFilter(t.magFilter),wrapS:this._checkWrapS(t.wrapS),wrapT:this._checkWrapT(t.wrapT),flipY:this._checkFlipY(t.flipY),encoding:this._checkEncoding(t.encoding)}),this._src=null,this._image=null,this._translate=R.vec2([0,0]),this._scale=R.vec2([1,1]),this._rotate=R.vec2([0,0]),this._matrixDirty=!1,this.translate=t.translate,this.scale=t.scale,this.rotate=t.rotate,t.src?this.src=t.src:t.image&&(this.image=t.image),L.memory.textures++}_checkMinFilter(e){return 1006!==(e=e||1008)&&1007!==e&&1008!==e&&1005!==e&&1004!==e&&(this.error("Unsupported value for 'minFilter' - supported values are LinearFilter, LinearMipMapNearestFilter, NearestMipMapNearestFilter, NearestMipMapLinearFilter and LinearMipMapLinearFilter. Defaulting to LinearMipMapLinearFilter."),e=1008),e}_checkMagFilter(e){return 1006!==(e=e||1006)&&1003!==e&&(this.error("Unsupported value for 'magFilter' - supported values are LinearFilter and NearestFilter. Defaulting to LinearFilter."),e=1006),e}_checkWrapS(e){return 1001!==(e=e||1e3)&&1002!==e&&1e3!==e&&(this.error("Unsupported value for 'wrapS' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),e=1e3),e}_checkWrapT(e){return 1001!==(e=e||1e3)&&1002!==e&&1e3!==e&&(this.error("Unsupported value for 'wrapT' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),e=1e3),e}_checkFlipY(e){return!!e}_checkEncoding(e){return 3e3!==(e=e||3e3)&&3001!==e&&(this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),e=3e3),e}_update(){const e=this._state;if(this._matrixDirty){let t,s;0===this._translate[0]&&0===this._translate[1]||(t=R.translationMat4v([this._translate[0],this._translate[1],0],this._state.matrix)),1===this._scale[0]&&1===this._scale[1]||(s=R.scalingMat4v([this._scale[0],this._scale[1],1]),t=t?R.mulMat4(t,s):s),0!==this._rotate&&(s=R.rotationMat4v(.0174532925*this._rotate,[0,0,1]),t=t?R.mulMat4(t,s):s),t&&(e.matrix=t),this._matrixDirty=!1}this.glRedraw()}set image(e){this._image=Yt(e),this._image.crossOrigin="Anonymous",this._state.texture.setImage(this._image,this._state),this._src=null,this.glRedraw()}get image(){return this._image}set src(e){this.scene.loading++,this.scene.canvas.spinner.processes++;const t=this;let s=new Image;s.onload=function(){s=Yt(s),t._state.texture.setImage(s,t._state),t.scene.loading--,t.glRedraw(),t.scene.canvas.spinner.processes--},s.src=e,this._src=e,this._image=null}get src(){return this._src}set translate(e){this._translate.set(e||[0,0]),this._matrixDirty=!0,this._needUpdate()}get translate(){return this._translate}set scale(e){this._scale.set(e||[1,1]),this._matrixDirty=!0,this._needUpdate()}get scale(){return this._scale}set rotate(e){e=e||0,this._rotate!==e&&(this._rotate=e,this._matrixDirty=!0,this._needUpdate())}get rotate(){return this._rotate}get minFilter(){return this._state.minFilter}get magFilter(){return this._state.magFilter}get wrapS(){return this._state.wrapS}get wrapT(){return this._state.wrapT}get flipY(){return this._state.flipY}get encoding(){return this._state.encoding}destroy(){super.destroy(),this._state.texture&&this._state.texture.destroy(),this._state.destroy(),L.memory.textures--}}const ts=R.vec3(),ss=R.vec3();R.vec3();const is=R.vec3([0,-1,0]),rs=R.vec4([0,0,0,1]);class ns extends Ht{get type(){return"LambertMaterial"}constructor(e,t={}){super(e,t),this._state=new xe({type:"LambertMaterial",ambient:R.vec3([1,1,1]),color:R.vec3([1,1,1]),emissive:R.vec3([0,0,0]),alpha:null,alphaMode:0,lineWidth:null,pointSize:null,backfaces:null,frontface:null,hash:"/lam;"}),this.ambient=t.ambient,this.color=t.color,this.emissive=t.emissive,this.alpha=t.alpha,this.lineWidth=t.lineWidth,this.pointSize=t.pointSize,this.backfaces=t.backfaces,this.frontface=t.frontface}set ambient(e){let t=this._state.ambient;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.ambient=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=.2,t[1]=.2,t[2]=.2),this.glRedraw()}get ambient(){return this._state.ambient}set color(e){let t=this._state.color;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.color=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1),this.glRedraw()}get color(){return this._state.color}set emissive(e){let t=this._state.emissive;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.emissive=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=0,t[1]=0,t[2]=0),this.glRedraw()}get emissive(){return this._state.emissive}set alpha(e){e=null!=e?e:1,this._state.alpha!==e&&(this._state.alpha=e,this._state.alphaMode=e<1?2:0,this.glRedraw())}get alpha(){return this._state.alpha}set lineWidth(e){this._state.lineWidth=e||1,this.glRedraw()}get lineWidth(){return this._state.lineWidth}set pointSize(e){this._state.pointSize=e||1,this.glRedraw()}get pointSize(){return this._state.pointSize}set backfaces(e){e=!!e,this._state.backfaces!==e&&(this._state.backfaces=e,this.glRedraw())}get backfaces(){return this._state.backfaces}set frontface(e){e="cw"!==e,this._state.frontface!==e&&(this._state.frontface=e,this.glRedraw())}get frontface(){return this._state.frontface?"ccw":"cw"}_getState(){return this._state}destroy(){super.destroy(),this._state.destroy()}}const As={opaque:0,mask:1,blend:2},os=["opaque","mask","blend"];class as extends Ht{get type(){return"MetallicMaterial"}constructor(e,t={}){super(e,t),this._state=new xe({type:"MetallicMaterial",baseColor:R.vec4([1,1,1]),emissive:R.vec4([0,0,0]),metallic:null,roughness:null,specularF0:null,alpha:null,alphaMode:null,alphaCutoff:null,lineWidth:null,pointSize:null,backfaces:null,frontface:null,hash:null}),this.baseColor=t.baseColor,this.metallic=t.metallic,this.roughness=t.roughness,this.specularF0=t.specularF0,this.emissive=t.emissive,this.alpha=t.alpha,t.baseColorMap&&(this._baseColorMap=this._checkComponent("Texture",t.baseColorMap)),t.metallicMap&&(this._metallicMap=this._checkComponent("Texture",t.metallicMap)),t.roughnessMap&&(this._roughnessMap=this._checkComponent("Texture",t.roughnessMap)),t.metallicRoughnessMap&&(this._metallicRoughnessMap=this._checkComponent("Texture",t.metallicRoughnessMap)),t.emissiveMap&&(this._emissiveMap=this._checkComponent("Texture",t.emissiveMap)),t.occlusionMap&&(this._occlusionMap=this._checkComponent("Texture",t.occlusionMap)),t.alphaMap&&(this._alphaMap=this._checkComponent("Texture",t.alphaMap)),t.normalMap&&(this._normalMap=this._checkComponent("Texture",t.normalMap)),this.alphaMode=t.alphaMode,this.alphaCutoff=t.alphaCutoff,this.backfaces=t.backfaces,this.frontface=t.frontface,this.lineWidth=t.lineWidth,this.pointSize=t.pointSize,this._makeHash()}_makeHash(){const e=this._state,t=["/met"];this._baseColorMap&&(t.push("/bm"),this._baseColorMap._state.hasMatrix&&t.push("/mat"),t.push("/"+this._baseColorMap._state.encoding)),this._metallicMap&&(t.push("/mm"),this._metallicMap._state.hasMatrix&&t.push("/mat")),this._roughnessMap&&(t.push("/rm"),this._roughnessMap._state.hasMatrix&&t.push("/mat")),this._metallicRoughnessMap&&(t.push("/mrm"),this._metallicRoughnessMap._state.hasMatrix&&t.push("/mat")),this._emissiveMap&&(t.push("/em"),this._emissiveMap._state.hasMatrix&&t.push("/mat")),this._occlusionMap&&(t.push("/ocm"),this._occlusionMap._state.hasMatrix&&t.push("/mat")),this._alphaMap&&(t.push("/am"),this._alphaMap._state.hasMatrix&&t.push("/mat")),this._normalMap&&(t.push("/nm"),this._normalMap._state.hasMatrix&&t.push("/mat")),t.push(";"),e.hash=t.join("")}set baseColor(e){let t=this._state.baseColor;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.baseColor=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1),this.glRedraw()}get baseColor(){return this._state.baseColor}get baseColorMap(){return this._baseColorMap}set metallic(e){e=null!=e?e:1,this._state.metallic!==e&&(this._state.metallic=e,this.glRedraw())}get metallic(){return this._state.metallic}get metallicMap(){return this._attached.metallicMap}set roughness(e){e=null!=e?e:1,this._state.roughness!==e&&(this._state.roughness=e,this.glRedraw())}get roughness(){return this._state.roughness}get roughnessMap(){return this._attached.roughnessMap}get metallicRoughnessMap(){return this._attached.metallicRoughnessMap}set specularF0(e){e=null!=e?e:0,this._state.specularF0!==e&&(this._state.specularF0=e,this.glRedraw())}get specularF0(){return this._state.specularF0}set emissive(e){let t=this._state.emissive;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.emissive=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=0,t[1]=0,t[2]=0),this.glRedraw()}get emissive(){return this._state.emissive}get emissiveMap(){return this._attached.emissiveMap}get occlusionMap(){return this._attached.occlusionMap}set alpha(e){e=null!=e?e:1,this._state.alpha!==e&&(this._state.alpha=e,this.glRedraw())}get alpha(){return this._state.alpha}get alphaMap(){return this._attached.alphaMap}get normalMap(){return this._attached.normalMap}set alphaMode(e){let t=As[e=e||"opaque"];void 0===t&&(this.error("Unsupported value for 'alphaMode': "+e+" defaulting to 'opaque'"),t="opaque"),this._state.alphaMode!==t&&(this._state.alphaMode=t,this.glRedraw())}get alphaMode(){return os[this._state.alphaMode]}set alphaCutoff(e){null==e&&(e=.5),this._state.alphaCutoff!==e&&(this._state.alphaCutoff=e)}get alphaCutoff(){return this._state.alphaCutoff}set backfaces(e){e=!!e,this._state.backfaces!==e&&(this._state.backfaces=e,this.glRedraw())}get backfaces(){return this._state.backfaces}set frontface(e){e="cw"!==e,this._state.frontface!==e&&(this._state.frontface=e,this.glRedraw())}get frontface(){return this._state.frontface?"ccw":"cw"}set lineWidth(e){this._state.lineWidth=e||1,this.glRedraw()}get lineWidth(){return this._state.lineWidth}set pointSize(e){this._state.pointSize=e||1,this.glRedraw()}get pointSize(){return this._state.pointSize}destroy(){super.destroy(),this._state.destroy()}}const ls={opaque:0,mask:1,blend:2},cs=["opaque","mask","blend"];class hs extends Ht{get type(){return"SpecularMaterial"}constructor(e,t={}){super(e,t),this._state=new xe({type:"SpecularMaterial",diffuse:R.vec3([1,1,1]),emissive:R.vec3([0,0,0]),specular:R.vec3([1,1,1]),glossiness:null,specularF0:null,alpha:null,alphaMode:null,alphaCutoff:null,lineWidth:null,pointSize:null,backfaces:null,frontface:null,hash:null}),this.diffuse=t.diffuse,this.specular=t.specular,this.glossiness=t.glossiness,this.specularF0=t.specularF0,this.emissive=t.emissive,this.alpha=t.alpha,t.diffuseMap&&(this._diffuseMap=this._checkComponent("Texture",t.diffuseMap)),t.emissiveMap&&(this._emissiveMap=this._checkComponent("Texture",t.emissiveMap)),t.specularMap&&(this._specularMap=this._checkComponent("Texture",t.specularMap)),t.glossinessMap&&(this._glossinessMap=this._checkComponent("Texture",t.glossinessMap)),t.specularGlossinessMap&&(this._specularGlossinessMap=this._checkComponent("Texture",t.specularGlossinessMap)),t.occlusionMap&&(this._occlusionMap=this._checkComponent("Texture",t.occlusionMap)),t.alphaMap&&(this._alphaMap=this._checkComponent("Texture",t.alphaMap)),t.normalMap&&(this._normalMap=this._checkComponent("Texture",t.normalMap)),this.alphaMode=t.alphaMode,this.alphaCutoff=t.alphaCutoff,this.backfaces=t.backfaces,this.frontface=t.frontface,this.lineWidth=t.lineWidth,this.pointSize=t.pointSize,this._makeHash()}_makeHash(){const e=this._state,t=["/spe"];this._diffuseMap&&(t.push("/dm"),this._diffuseMap.hasMatrix&&t.push("/mat"),t.push("/"+this._diffuseMap.encoding)),this._emissiveMap&&(t.push("/em"),this._emissiveMap.hasMatrix&&t.push("/mat")),this._glossinessMap&&(t.push("/gm"),this._glossinessMap.hasMatrix&&t.push("/mat")),this._specularMap&&(t.push("/sm"),this._specularMap.hasMatrix&&t.push("/mat")),this._specularGlossinessMap&&(t.push("/sgm"),this._specularGlossinessMap.hasMatrix&&t.push("/mat")),this._occlusionMap&&(t.push("/ocm"),this._occlusionMap.hasMatrix&&t.push("/mat")),this._normalMap&&(t.push("/nm"),this._normalMap.hasMatrix&&t.push("/mat")),this._alphaMap&&(t.push("/opm"),this._alphaMap.hasMatrix&&t.push("/mat")),t.push(";"),e.hash=t.join("")}set diffuse(e){let t=this._state.diffuse;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.diffuse=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1),this.glRedraw()}get diffuse(){return this._state.diffuse}get diffuseMap(){return this._diffuseMap}set specular(e){let t=this._state.specular;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.specular=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1),this.glRedraw()}get specular(){return this._state.specular}get specularMap(){return this._specularMap}get specularGlossinessMap(){return this._specularGlossinessMap}set glossiness(e){e=null!=e?e:1,this._state.glossiness!==e&&(this._state.glossiness=e,this.glRedraw())}get glossiness(){return this._state.glossiness}get glossinessMap(){return this._glossinessMap}set specularF0(e){e=null!=e?e:0,this._state.specularF0!==e&&(this._state.specularF0=e,this.glRedraw())}get specularF0(){return this._state.specularF0}set emissive(e){let t=this._state.emissive;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.emissive=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=0,t[1]=0,t[2]=0),this.glRedraw()}get emissive(){return this._state.emissive}get emissiveMap(){return this._emissiveMap}set alpha(e){e=null!=e?e:1,this._state.alpha!==e&&(this._state.alpha=e,this.glRedraw())}get alpha(){return this._state.alpha}get alphaMap(){return this._alphaMap}get normalMap(){return this._normalMap}get occlusionMap(){return this._occlusionMap}set alphaMode(e){let t=ls[e=e||"opaque"];void 0===t&&(this.error("Unsupported value for 'alphaMode': "+e+" defaulting to 'opaque'"),t="opaque"),this._state.alphaMode!==t&&(this._state.alphaMode=t,this.glRedraw())}get alphaMode(){return cs[this._state.alphaMode]}set alphaCutoff(e){null==e&&(e=.5),this._state.alphaCutoff!==e&&(this._state.alphaCutoff=e)}get alphaCutoff(){return this._state.alphaCutoff}set backfaces(e){e=!!e,this._state.backfaces!==e&&(this._state.backfaces=e,this.glRedraw())}get backfaces(){return this._state.backfaces}set frontface(e){e="cw"!==e,this._state.frontface!==e&&(this._state.frontface=e,this.glRedraw())}get frontface(){return this._state.frontface?"ccw":"cw"}set lineWidth(e){this._state.lineWidth=e||1,this.glRedraw()}get lineWidth(){return this._state.lineWidth}set pointSize(e){this._state.pointSize=e||1,this.glRedraw()}get pointSize(){return this._state.pointSize}destroy(){super.destroy(),this._state.destroy()}}const us={default:{fill:!0,fillColor:[.4,.4,.4],fillAlpha:.2,edges:!0,edgeColor:[.2,.2,.2],edgeAlpha:.5,edgeWidth:1},defaultWhiteBG:{fill:!0,fillColor:[1,1,1],fillAlpha:.6,edgeColor:[.2,.2,.2],edgeAlpha:1,edgeWidth:1},defaultLightBG:{fill:!0,fillColor:[.4,.4,.4],fillAlpha:.2,edges:!0,edgeColor:[.2,.2,.2],edgeAlpha:.5,edgeWidth:1},defaultDarkBG:{fill:!0,fillColor:[.4,.4,.4],fillAlpha:.2,edges:!0,edgeColor:[.5,.5,.5],edgeAlpha:.5,edgeWidth:1},phosphorous:{fill:!0,fillColor:[0,0,0],fillAlpha:.4,edges:!0,edgeColor:[.9,.9,.9],edgeAlpha:.5,edgeWidth:2},sunset:{fill:!0,fillColor:[.9,.9,.6],fillAlpha:.2,edges:!0,edgeColor:[.9,.9,.9],edgeAlpha:.5,edgeWidth:1},vectorscope:{fill:!0,fillColor:[0,0,0],fillAlpha:.7,edges:!0,edgeColor:[.2,1,.2],edgeAlpha:1,edgeWidth:2},battlezone:{fill:!0,fillColor:[0,0,0],fillAlpha:1,edges:!0,edgeColor:[.2,1,.2],edgeAlpha:1,edgeWidth:3},sepia:{fill:!0,fillColor:[.970588207244873,.7965892553329468,.6660899519920349],fillAlpha:.4,edges:!0,edgeColor:[.529411792755127,.4577854573726654,.4100345969200134],edgeAlpha:1,edgeWidth:1},yellowHighlight:{fill:!0,fillColor:[1,1,0],fillAlpha:.5,edges:!0,edgeColor:[1,1,1],edgeAlpha:1,edgeWidth:1},greenSelected:{fill:!0,fillColor:[0,1,0],fillAlpha:.5,edges:!0,edgeColor:[1,1,1],edgeAlpha:1,edgeWidth:1},gamegrid:{fill:!0,fillColor:[.2,.2,.7],fillAlpha:.9,edges:!0,edgeColor:[.4,.4,1.6],edgeAlpha:.8,edgeWidth:3}};class ds extends Ht{get type(){return"EmphasisMaterial"}get presets(){return us}constructor(e,t={}){super(e,t),this._state=new xe({type:"EmphasisMaterial",fill:null,fillColor:null,fillAlpha:null,edges:null,edgeColor:null,edgeAlpha:null,edgeWidth:null,backfaces:!0,glowThrough:!0}),this._preset="default",t.preset?(this.preset=t.preset,void 0!==t.fill&&(this.fill=t.fill),t.fillColor&&(this.fillColor=t.fillColor),void 0!==t.fillAlpha&&(this.fillAlpha=t.fillAlpha),void 0!==t.edges&&(this.edges=t.edges),t.edgeColor&&(this.edgeColor=t.edgeColor),void 0!==t.edgeAlpha&&(this.edgeAlpha=t.edgeAlpha),void 0!==t.edgeWidth&&(this.edgeWidth=t.edgeWidth),void 0!==t.backfaces&&(this.backfaces=t.backfaces),void 0!==t.glowThrough&&(this.glowThrough=t.glowThrough)):(this.fill=t.fill,this.fillColor=t.fillColor,this.fillAlpha=t.fillAlpha,this.edges=t.edges,this.edgeColor=t.edgeColor,this.edgeAlpha=t.edgeAlpha,this.edgeWidth=t.edgeWidth,this.backfaces=t.backfaces,this.glowThrough=t.glowThrough)}set fill(e){e=!1!==e,this._state.fill!==e&&(this._state.fill=e,this.glRedraw())}get fill(){return this._state.fill}set fillColor(e){let t=this._state.fillColor;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.fillColor=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=.4,t[1]=.4,t[2]=.4),this.glRedraw()}get fillColor(){return this._state.fillColor}set fillAlpha(e){e=null!=e?e:.2,this._state.fillAlpha!==e&&(this._state.fillAlpha=e,this.glRedraw())}get fillAlpha(){return this._state.fillAlpha}set edges(e){e=!1!==e,this._state.edges!==e&&(this._state.edges=e,this.glRedraw())}get edges(){return this._state.edges}set edgeColor(e){let t=this._state.edgeColor;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.edgeColor=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=.2,t[1]=.2,t[2]=.2),this.glRedraw()}get edgeColor(){return this._state.edgeColor}set edgeAlpha(e){e=null!=e?e:.5,this._state.edgeAlpha!==e&&(this._state.edgeAlpha=e,this.glRedraw())}get edgeAlpha(){return this._state.edgeAlpha}set edgeWidth(e){this._state.edgeWidth=e||1,this.glRedraw()}get edgeWidth(){return this._state.edgeWidth}set backfaces(e){e=!!e,this._state.backfaces!==e&&(this._state.backfaces=e,this.glRedraw())}get backfaces(){return this._state.backfaces}set glowThrough(e){e=!1!==e,this._state.glowThrough!==e&&(this._state.glowThrough=e,this.glRedraw())}get glowThrough(){return this._state.glowThrough}set preset(e){if(console.warn("EmphasisMaterial.preset is deprecated and will be removed in future versions."),e=e||"default",this._preset===e)return;const t=us[e];t?(this.fill=t.fill,this.fillColor=t.fillColor,this.fillAlpha=t.fillAlpha,this.edges=t.edges,this.edgeColor=t.edgeColor,this.edgeAlpha=t.edgeAlpha,this.edgeWidth=t.edgeWidth,this.glowThrough=t.glowThrough,this._preset=e):this.error("unsupported preset: '"+e+"' - supported values are "+Object.keys(us).join(", "))}get preset(){return console.warn("EmphasisMaterial.preset is deprecated and will be removed in future versions."),this._preset}destroy(){super.destroy(),this._state.destroy()}}const ps={default:{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1},defaultWhiteBG:{edgeColor:[.2,.2,.2],edgeAlpha:1,edgeWidth:1},defaultLightBG:{edgeColor:[.2,.2,.2],edgeAlpha:1,edgeWidth:1},defaultDarkBG:{edgeColor:[.5,.5,.5],edgeAlpha:1,edgeWidth:1}};class fs extends Ht{get type(){return"EdgeMaterial"}get presets(){return ps}constructor(e,t={}){super(e,t),this._state=new xe({type:"EdgeMaterial",edges:null,edgeColor:null,edgeAlpha:null,edgeWidth:null}),this._preset="default",t.preset?(this.preset=t.preset,t.edgeColor&&(this.edgeColor=t.edgeColor),void 0!==t.edgeAlpha&&(this.edgeAlpha=t.edgeAlpha),void 0!==t.edgeWidth&&(this.edgeWidth=t.edgeWidth)):(this.edgeColor=t.edgeColor,this.edgeAlpha=t.edgeAlpha,this.edgeWidth=t.edgeWidth),this.edges=!1!==t.edges}set edges(e){e=!1!==e,this._state.edges!==e&&(this._state.edges=e,this.glRedraw())}get edges(){return this._state.edges}set edgeColor(e){let t=this._state.edgeColor;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.edgeColor=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=.2,t[1]=.2,t[2]=.2),this.glRedraw()}get edgeColor(){return this._state.edgeColor}set edgeAlpha(e){e=null!=e?e:1,this._state.edgeAlpha!==e&&(this._state.edgeAlpha=e,this.glRedraw())}get edgeAlpha(){return this._state.edgeAlpha}set edgeWidth(e){this._state.edgeWidth=e||1,this.glRedraw()}get edgeWidth(){return this._state.edgeWidth}set preset(e){if(e=e||"default",this._preset===e)return;const t=ps[e];t?(this.edgeColor=t.edgeColor,this.edgeAlpha=t.edgeAlpha,this.edgeWidth=t.edgeWidth,this._preset=e):this.error("unsupported preset: '"+e+"' - supported values are "+Object.keys(ps).join(", "))}get preset(){return this._preset}destroy(){super.destroy(),this._state.destroy()}}class gs extends ie{constructor(e,t={}){super(e,t),this._type=t.type||(t.src?t.src.split(".").pop():null)||"jpg",this._pos=R.vec3(t.pos||[0,0,0]),this._up=R.vec3(t.up||[0,1,0]),this._normal=R.vec3(t.normal||[0,0,1]),this._height=t.height||1,this._origin=R.vec3(),this._rtcPos=R.vec3(),this._imageSize=R.vec2(),this._texture=new es(this,{flipY:!0}),this._image=new Image,"jpg"!==this._type&&"png"!==this._type&&(this.error('Unsupported type - defaulting to "jpg"'),this._type="jpg"),this._node=new ct(this,{matrix:R.inverseMat4(R.lookAtMat4v(this._pos,R.subVec3(this._pos,this._normal,R.mat4()),this._up,R.mat4())),children:[this._bitmapMesh=new Ot(this,{scale:[1,1,1],rotation:[-90,0,0],collidable:t.collidable,pickable:t.pickable,opacity:t.opacity,clippable:t.clippable,geometry:new Le(this,Ze({center:[0,0,0],xSize:1,zSize:1,xSegments:2,zSegments:2})),material:new jt(this,{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:this._texture,emissiveMap:this._texture,backfaces:!0})})]}),t.image?this.image=t.image:t.src?this.src=t.src:t.imageData&&(this.imageData=t.imageData),this.scene._bitmapCreated(this)}set visible(e){this._bitmapMesh.visible=e}get visible(){return this._bitmapMesh.visible}set image(e){this._image=e,this._image&&(this._texture.image=this._image,this._imageSize[0]=this._image.width,this._imageSize[1]=this._image.height,this._updateBitmapMeshScale())}get image(){return this._image}set src(e){if(e){this._image.onload=()=>{this._texture.image=this._image,this._imageSize[0]=this._image.width,this._imageSize[1]=this._image.height,this._updateBitmapMeshScale()},this._image.src=e;switch(e.split(".").pop()){case"jpeg":case"jpg":this._type="jpg";break;case"png":this._type="png"}}}get src(){return this._image.src}set imageData(e){this._image.onload=()=>{this._texture.image=image,this._imageSize[0]=image.width,this._imageSize[1]=image.height,this._updateBitmapMeshScale()},this._image.src=e}get imageData(){const e=document.createElement("canvas"),t=e.getContext("2d");return e.width=this._image.width,e.height=this._image.height,t.drawImage(this._image,0,0),e.toDataURL("jpg"===this._type?"image/jpeg":"image/png")}set type(e){"png"===(e=e||"jpg")&&"jpg"===e||(this.error("Unsupported value for `type` - supported types are `jpg` and `png` - defaulting to `jpg`"),e="jpg"),this._type=e}get type(){return this._type}get pos(){return this._pos}get normal(){return this._normal}get up(){return this._up}set height(e){this._height=null==e?1:e,this._image&&this._updateBitmapMeshScale()}get height(){return this._height}set collidable(e){this._bitmapMesh.collidable=!1!==e}get collidable(){return this._bitmapMesh.collidable}set clippable(e){this._bitmapMesh.clippable=!1!==e}get clippable(){return this._bitmapMesh.clippable}set pickable(e){this._bitmapMesh.pickable=!1!==e}get pickable(){return this._bitmapMesh.pickable}set opacity(e){this._bitmapMesh.opacity=e}get opacity(){return this._bitmapMesh.opacity}destroy(){super.destroy(),this.scene._bitmapDestroyed(this)}_updateBitmapMeshScale(){const e=this._imageSize[1]/this._imageSize[0];this._bitmapMesh.scale=[this._height/e,1,this._height]}}const ms=(e,t)=>{const s=[];let i=[];function r(e,s){let i,r;for(let n=0;n<3;n++)if(i=t[3*e+n],r=t[3*s+n],i!==r)return r-i;return 0}let n=e.slice().sort(r),A=null;for(let e=0,t=n.length;e<t;e++)0!==e&&0===r(n[e],n[e-1])||(A=n[e]),s[n[e]]=A;for(let t=0,r=e.length;t<r;t+=3){const r=s[e[t]],n=s[e[t+1]],A=s[e[t+2]];let o=r,a=n,l=A;if(r>n&&r>A?n>A?(o=r,a=n,l=A):(o=r,a=A,l=n):n>r&&n>A?r>A?(o=n,a=r,l=A):(o=n,a=A,l=r):A>r&&A>n&&(r>n?(o=A,a=r,l=n):(o=A,a=n,l=r)),i[t+0]=[o,a],i[t+1]=[a,l],o>l){const e=l;l=o,o=e}i[t+2]=[l,o]}function o(e,t){let s,i;for(let r=0;r<2;r++)if(s=e[r],i=t[r],i!==s)return i-s;return 0}i=i.slice(0,e.length),i.sort(o);let a=0;for(let e=0;e<i.length;e++)if(0===e||0!==o(i[e],i[e-1])){if(0!==e&&2!==a)return!1;a=1}else a++;return!(i.length>0&&2!==a)},_s=R.vec3(),bs=R.vec3(),Bs=R.vec3();class ys{constructor(){this.vertices=[],this.indices=[],this.reset()}reset(){this.lenVertices=0,this.lenIndices=0,this.primitive=null}setPrimitive(e){this.primitive=e}addVertex(e){this.vertices[this.lenVertices++]=e[0],this.vertices[this.lenVertices++]=e[1],this.vertices[this.lenVertices++]=e[2]}addIndex(e){this.indices[this.lenIndices++]=e}get volume(){const e=this.vertices,t=this.indices;if("solid"!==this.primitive&&"surface"!==this.primitive&&"triangles"!==this.primitive)return-1;if("solid"!==this.primitive&&!ms(t,e))return-1;let s=0;for(let i=0;i<this.lenIndices;i+=3){const r=3*t[i],n=3*t[i+1],A=3*t[i+2];_s[0]=e[r],_s[1]=e[r+1],_s[2]=e[r+2],bs[0]=e[n],bs[1]=e[n+1],bs[2]=e[n+2],Bs[0]=e[A],Bs[1]=e[A+1],Bs[2]=e[A+2],R.cross3Vec3(_s,bs,_s),s+=R.dotVec3(_s,Bs)}return s/6}}const ws=new ys,vs=R.vec3(),Cs=R.vec3(),Ms=R.vec3(),Es=R.vec3(),Fs=R.vec3(),xs=R.vec3();class Us{constructor(){this.vertices=[],this.indices=[],this.reset()}reset(){this.lenVertices=0,this.lenIndices=0}addVertex(e){this.vertices[this.lenVertices++]=e[0],this.vertices[this.lenVertices++]=e[1],this.vertices[this.lenVertices++]=e[2]}addIndex(e){this.indices[this.lenIndices++]=e}get surfaceArea(){const e=this.vertices,t=this.indices;let s=0;for(let i=0;i<this.lenIndices;i+=3){const r=3*t[i],n=3*t[i+1],A=3*t[i+2];vs[0]=e[r],vs[1]=e[r+1],vs[2]=e[r+2],Cs[0]=e[n],Cs[1]=e[n+1],Cs[2]=e[n+2],Ms[0]=e[A],Ms[1]=e[A+1],Ms[2]=e[A+2],R.subVec3(vs,Cs,Es),R.subVec3(Ms,Cs,Fs),s+=.5*R.lenVec3(R.cross3Vec3(Es,Fs,xs))}return s}}const Is=new Us,Ts=R.OBB3(),Ps=R.OBB3(),Ss=R.OBB3();class Ds{constructor(e,t,s,i,r,n,A=null,o=0){this.model=e,this.object=null,this.parent=null,this.transform=r,this.textureSet=n,this._matrixDirty=!1,this._matrixUpdateScheduled=!1,this.id=t,this.obb=null,this._aabbLocal=null,this._aabbWorld=R.AABB3(),this._aabbWorldDirty=!1,this.layer=A,this.portionId=o,this._color=new Uint8Array([s[0],s[1],s[2],i]),this._colorize=new Uint8Array([s[0],s[1],s[2],i]),this._colorizing=!1,this._transparent=i<255,this.numTriangles=0,this.origin=null,this.entity=null,r&&r._addMesh(this),this._volume=null,this._surfaceArea=null}_sceneModelDirty(){this._aabbWorldDirty=!0,this.layer.aabbChanged()}_transformDirty(){this._matrixDirty||this._matrixUpdateScheduled||(this.model._meshMatrixDirty(this),this._matrixDirty=!0,this._matrixUpdateScheduled=!0),this._aabbWorldDirty=!0,this.layer.aabbChanged(),this.entity&&this.entity._transformDirty()}_updateMatrix(){this.transform&&this._matrixDirty&&this.layer.setMatrix(this.portionId,this.transform.worldMatrix),this._matrixDirty=!1,this._matrixUpdateScheduled=!1}_finalize(e){this.layer.initFlags(this.portionId,e,this._transparent)}_finalize2(){this.layer.flushInitFlags&&this.layer.flushInitFlags()}_setVisible(e){this.layer.setVisible(this.portionId,e,this._transparent)}_setColor(e){this._color[0]=e[0],this._color[1]=e[1],this._color[2]=e[2],this._colorizing||this.layer.setColor(this.portionId,this._color,!1)}_setColorize(e){e?(this._colorize[0]=e[0],this._colorize[1]=e[1],this._colorize[2]=e[2],this.layer.setColor(this.portionId,this._colorize,false),this._colorizing=!0):(this.layer.setColor(this.portionId,this._color,false),this._colorizing=!1)}_setOpacity(e,t){const s=e<255,i=this._transparent!==s;this._color[3]=e,this._colorize[3]=e,this._transparent=s,this._colorizing?this.layer.setColor(this.portionId,this._colorize):this.layer.setColor(this.portionId,this._color),i&&this.layer.setTransparent(this.portionId,t,s)}_setOffset(e){this.layer.setOffset(this.portionId,e)}_setHighlighted(e){this.layer.setHighlighted(this.portionId,e,this._transparent)}_setXRayed(e){this.layer.setXRayed(this.portionId,e,this._transparent)}_setSelected(e){this.layer.setSelected(this.portionId,e,this._transparent)}_setEdges(e){this.layer.setEdges(this.portionId,e,this._transparent)}_setClippable(e){this.layer.setClippable(this.portionId,e,this._transparent)}_setCollidable(e){this.layer.setCollidable(this.portionId,e)}_setPickable(e){this.layer.setPickable(this.portionId,e,this._transparent)}_setCulled(e){this.layer.setCulled(this.portionId,e,this._transparent)}canPickTriangle(){return!1}drawPickTriangles(e,t){}pickTriangleSurface(e){}precisionRayPickSurface(e,t,s,i){return this.layer.precisionRayPickSurface(this.portionId,e,t,s,i)}canPickWorldPos(){return!0}drawPickDepths(e){this.model.drawPickDepths(e)}drawPickNormals(e){this.model.drawPickNormals(e)}delegatePickedEntity(){return this.parent}getEachVertex(e){this.layer.getEachVertex&&this.layer.getEachVertex(this.portionId,e)}getEachIndex(e){this.layer.getEachIndex&&this.layer.getEachIndex(this.portionId,e)}isSolid(){return this.layer.solid}get volume(){if(null!==this._volume)return this._volume;switch(this.layer.primitive){case"solid":case"surface":case"triangles":ws.reset(),ws.setPrimitive(this.layer.primitive),this.getEachVertex((e=>{ws.addVertex(e)})),this.getEachIndex((e=>{ws.addIndex(e)})),this._volume=ws.volume;break;default:this._volume=0}return this._volume}get surfaceArea(){if(null!==this._surfaceArea)return this._surfaceArea;switch(this.layer.primitive){case"solid":case"surface":case"triangles":Is.reset(),this.getEachVertex((e=>{Is.addVertex(e)})),this.getEachIndex((e=>{Is.addIndex(e)})),this._surfaceArea=Is.surfaceArea;break;default:this._surfaceArea=0}return this._surfaceArea}set aabb(e){if(this._aabbLocal=e,this.origin){this._aabbLocal=e.slice(0);const t=this.origin;this._aabbLocal[0]+=t[0],this._aabbLocal[1]+=t[1],this._aabbLocal[2]+=t[2],this._aabbLocal[3]+=t[0],this._aabbLocal[4]+=t[1],this._aabbLocal[5]+=t[2]}}get aabb(){return this._aabbWorldDirty&&(R.AABB3ToOBB3(this._aabbLocal,Ts),this.transform?(R.transformOBB3(this.transform.worldMatrix,Ts,Ps),R.transformOBB3(this.model.worldMatrix,Ps,Ss),R.OBB3ToAABB3(Ss,this._aabbWorld)):(R.transformOBB3(this.model.worldMatrix,Ts,Ps),R.OBB3ToAABB3(Ps,this._aabbWorld)),this._aabbWorldDirty=!1),this._aabbWorld}_destroy(){this.model.scene._renderer.putPickID(this.pickId),this.layer=null}}const ks=1,Qs=4,Rs=8,Os=16,Vs=32,Ls=256,Hs=512,Ns=1024,Gs=2048,js=function(e,t,s,i){const r=i&&e.createUniform("vec4","edgeColor",((e,t)=>e(t.legacyFrameCtx.programColor))),n=t.attributes.color,A=!i&&e.createVarying("vec4","vColor",(()=>`vec4(${n}.rgb * 0.5, ${n}.a)`)),o=e.createOutput("vec4","outColor");return{programName:i?"Edges":"EdgesColor",getLogDepth:s&&(e=>e),renderPassFlag:2,appendFragmentOutputs:e=>e.push(`${o} = ${r||A};`)}},Ws=function(e,t){const s=e.createOutput("vec4","outColor");return{programName:"Occlusion",getLogDepth:!1,renderPassFlag:0,appendFragmentOutputs:e=>e.push(`${s} = vec4(0.0, 0.0, 1.0, 1.0);`)}},zs=function(e,t,s,i){const r=e.createUniform("vec4","silhouetteColor",((e,t)=>e(t.legacyFrameCtx.programColor))),n=e.createVarying("float","vAlpha",(()=>`${t.attributes.color}.a`)),A=e.createOutput("vec4","outColor");return{programName:"Silhouette",getLogDepth:s&&(e=>e),renderPassFlag:1,appendFragmentOutputs:(e,t,s,o)=>{e.push(`${A} = ${i?r:o(`vec4(${r}.rgb, min(${r}.a, ${n}))`)};`)}}},Xs=R.vec2(),Ks=R.vec3(),Zs=R.vec4(),Js=R.mat4(),Ys=R.vec3([0,0,0]),$s=0,qs=1,ei=2,ti=3,si=4,ii=5,ri=6,ni=7,Ai=8,oi=9,ai=10,li=11,ci=e=>[R.safeInv(e[0]),R.safeInv(e[1]),R.safeInv(e[2])],hi=(e,t,s,i,r)=>{const n=!!(e&ks),A=!!(e&Ls),o=!!(e&Hs),a=!!(e&Ns),l=!!(e&Gs),c=!!(e&Rs),h=!!(e&Qs);let u,d;u=!n||h||A||o&&!i.highlightMaterial.glowThrough||a&&!i.selectedMaterial.glowThrough?$s:t?ei:qs,d=!n||h?$s:a?si:o?ti:A?ii:$s;let p=0;p=s&&n&&!h?a?oi:o?Ai:A?ai:l?t?ni:ri:$s:$s;const f=n&&!h&&c?li:$s;r[0]=u,r[1]=d,r[2]=p,r[3]=f},ui=function(){const e={};return function(t,s,i,r,n,A,o,a){const l=[s,"points"===i||"lines"===i?i:"triangles",!!r,!!n,!!A,!!o].join(":");l in e||(e[l]={});const c=e[l],h=t.id;if(!(h in c)){const e=t.canvas.gl,l=function(r,n,A){const o=function(){const A=bt(),o=A.programVariables,l=a(o,n);return r(o,l.geometryParameters,(function(r,a){const c=t.pointsMaterial,h="points"===i&&!n,u=()=>[t._sectionPlanesState.getHash()].concat(h?[c.hash]:[]).concat(r.getHash?r.getHash():[]).join(";"),d=u(),p=()=>d===u(),f=l.geometryParameters,g=r.incrementDrawState,m=r.isShadowProgram,_=f.attributes,b=_.position.world,B="clipPos",[y,w]=A.buildProgram(e,s+" "+i+" "+r.programName,{appendFragmentOutputs:r.appendFragmentOutputs,cleanerEdges:r.cleanerEdges,clipPos:B,clippableTest:l.clippableTest,clippingCaps:r.clippingCaps,crossSections:t.crossSections,discardPoints:h&&c.roundPoints,getGammaFactor:t.gammaOutput&&(()=>t.gammaFactor),getLogDepth:r.getLogDepth,getPointSize:function(){const e=[];if(h){const t=o.createUniform("float","pointSize",(e=>e(c.pointSize)));if(c.perspectivePoints){const s=o.createUniform("float","nearPlaneHeight",((e,t)=>e(t.legacyFrameCtx.nearPlaneHeight))),i=`${Math.floor(c.minPerspectivePointSize)}.0`,r=`${Math.floor(c.maxPerspectivePointSize)}.0`;e.push(`clamp((${s} * ${t}) / gl_Position.w, ${i}, ${r})`)}else e.push(t)}else n&&n.vertices&&e.push("1.0");return r.incPointSizeBy10&&"points"===i&&e.push("10.0"),e.length>0&&(()=>e.join(" + "))}(),getVertexData:()=>{const e=_.color,t=_.flags[r.renderPassFlag],s=o.createUniform("int","renderPass",((e,t)=>e(t.renderPass))),n=[`if (${m?`(${t} <= 0) || (${e}.a < 1.0)`:`${t} != ${s}`}) {`,` gl_Position = vec4(${r.vertexCullX||0}, 0.0, 0.0, 0.0);`," return;","}"].concat(l.dontCullOnAlphaZero||r.dontCullOnAlphaZero?[]:[`if (${e}.a == 0.0) {`," gl_Position = vec4(3.0, 3.0, 3.0, 1.0);"," return;","}"]).concat(r.filterIntensityRange&&"points"===i&&c.filterIntensity?function(){const t=o.createUniform("vec2","intensityRange",(e=>{Xs[0]=c.minIntensity,Xs[1]=c.maxIntensity,e(Xs)}));return[`if ((${e}.a < ${t}[0]) || (${e}.a > ${t}[1])) {`," gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"," return;","}"]}():[]),A=[];l.ensureColorAndFlagAvailable&&l.ensureColorAndFlagAvailable(A),n.forEach((e=>A.push(e))),l.appendVertexData(A);const a=f.attributes.position.view;return A.push(`vec4 ${a} = ${f.viewMatrix} * ${b};`),A.push(`vec4 clipPos = ${f.projMatrix} * ${a};`),A},projMatrix:f.projMatrix,sectionPlanesState:t._sectionPlanesState,testPerspectiveForGl_FragDepth:"points"!==i&&"lines"!==i||n,usePickClipPos:a,worldPositionAttribute:b});return w?(console.error(w),{getValid:p,destroy:()=>{},drawLayer:(e,t,s)=>{}}):{getValid:p,destroy:()=>y.destroy(),drawLayer:(e,t,s)=>{e.lastProgramId!==y.id&&(e.lastProgramId=y.id,y.bind());const i=t.origin,r=t.model,A=e.viewParams,o=Ks;R.transformPoint3(r.matrix,i,o);const a=A.viewMatrix,c=A.projMatrix;e.snapPickOrigin&&(e.snapPickOrigin[0]=o[0],e.snapPickOrigin[1]=o[1],e.snapPickOrigin[2]=o[2]);const h={legacyFrameCtx:e,layerTextureSet:t.layerTextureSet,mesh:{layerIndex:t.layerIndex,origin:o,renderFlags:{sectionPlanesActivePerLayer:r.renderFlags.sectionPlanesActivePerLayer}},renderPass:s,view:{eye:A.eye,far:A.far,projMatrix:c,viewMatrix:R.compareVec3(o,Ys)?a:ut(a,o,Js),viewNormalMatrix:A.viewNormalMatrix}};y.inputSetters.setUniforms(e,h),t.drawCalls[n?n.vertices?"drawVertices":"drawEdges":"drawSurface"](y.inputSetters.attributesHash,l.layerTypeInputs,{projMatrix:c,viewMatrix:R.compareVec3(o,Ys)?a:ut(a,o,Js),viewNormalMatrix:A.viewNormalMatrix,eye:A.eye}),g&&e.drawElements++}}}))};let l=A&&o();return{drawLayer:(e,t,s)=>{l||(l=o()),l.drawLayer(e,t,s)},revalidate:e=>{!l||!e&&l.getValid()||(l.destroy(),l=A&&o())}}},u=(e,t)=>l(e,t,!0),d=(e,t)=>l(e,t,!1),p=(e,s,r,n)=>function(e,t,s,i,r,n){const A=e.createVarying("vec4","vColor",(()=>{const e=t.attributes,s="points"===n?`vec4(${e.color}.rgb, 1.0)`:`${e.color}`;return i?`vec4(${[i.getAmbientColor()].concat(i.directionalLights.map((s=>`max(dot(${e.normal.view}, ${s.getDirection(t.viewMatrix,e.position.view)}), 0.0) * ${s.getColor()}`))).join(" + ")}, 1) * ${s}`:s})),o=e.createOutput("vec4","outColor");return{programName:"Color",getHash:()=>[i?i.getHash():"-",r?"sao":"nosao"],cleanerEdges:!0,getLogDepth:s&&(e=>"points"!==n&&"lines"!==n?`${e} + length(vec2(dFdx(${e}), dFdy(${e})))`:e),renderPassFlag:0,appendFragmentOutputs:(e,t,s,i)=>{"points"===n||"lines"===n?e.push(`${o} = ${A};`):(e.push(`vec4 fragColor = ${i(A)};`),e.push(`${o} = ${r?`vec4(fragColor.rgb * ${r.getAmbient(s)}, fragColor.a)`:"fragColor"};`))},filterIntensityRange:!0,incrementDrawState:!0}}(e,s,t.logarithmicDepthBufferEnabled,r,n,i),f=(e,s,i)=>i(function(e,t,s){const i=e.createUniform("float","far",((e,t)=>e(t.legacyFrameCtx.viewParams.far))),r=e.createUniform("float","near",((e,t)=>e(t.legacyFrameCtx.viewParams.near))),n=e.createVarying("vec3","vViewPosition",(()=>`${t.attributes.position.view}.xyz`)),A=e.createOutput("vec4","outPackedDepth"),o=e.createFragmentDefinition("packDepth",((e,t)=>{t.push(`vec4 ${e}(const in float depth) {`),t.push(" const vec4 bitShift = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);"),t.push(" const vec4 bitMask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);"),t.push(" vec4 res = fract(depth * bitShift);"),t.push(" res -= res.xxyz * bitMask;"),t.push(" return res;"),t.push("}")}));return{programName:"PickDepth",getLogDepth:s&&(e=>e),renderPassFlag:3,incPointSizeBy10:!0,appendFragmentOutputs:e=>{e.push(`float zNormalizedDepth = abs((${r} + ${n}.z) / (${i} - ${r}));`),e.push(`${A} = ${o}(zNormalizedDepth);`)}}}(e,s,t.logarithmicDepthBufferEnabled),!0),g=(e,s,i)=>i(function(e,t,s){const i=e.createVarying("vec4","vPickColor",(()=>`${t.attributes.pickColor} / 255.0`)),r=e.createOutput("vec4","outPickColor");return{programName:"PickMesh",getLogDepth:s&&(e=>e),renderPassFlag:3,incPointSizeBy10:!0,dontCullOnAlphaZero:!0,appendFragmentOutputs:e=>e.push(`${r} = ${i};`)}}(e,s,t.logarithmicDepthBufferEnabled),!0),m=(e,s,i,r)=>i(function(e,t,s,i){const r=e.createVarying("vec3","vWorldPosition",(()=>`${t.attributes.position.world}.xyz`)),n=e.createVarying("vec3","vWorldNormal",(()=>t.attributes.normal.world)),A=e.createOutput("highp ivec4","outNormal");return{programName:i?"PickNormalsFlat":"PickNormals",getLogDepth:s&&(e=>e),renderPassFlag:3,appendFragmentOutputs:e=>{const t=i?`normalize(cross(dFdx(${r}), dFdy(${r})))`:n;e.push(`${A} = ivec4(${t} * float(${R.MAX_INT}), 1.0);`)}}}(e,s,t.logarithmicDepthBufferEnabled,r),!0),_=(e,t,s,i,r)=>s(function(e,t,s,i){const r=e.createUniform("int","layerNumber",((e,t)=>e(t.legacyFrameCtx.snapPickLayerParams.length))),n=e.createUniform("vec3","coordinateScaler",((e,t)=>e(t.legacyFrameCtx.snapPickCoordinateScale))),A=e.createVarying("vec3","vWorldPosition",(()=>`${t.attributes.position.world}.xyz`)),o=e.createVarying("vec4","vPickColor",(()=>t.attributes.pickColor),"flat"),a=e.createOutput("highp ivec4","outCoords",0),l=e.createOutput("highp ivec4","outNormal",1),c=e.createOutput("lowp uvec4","outPickColor",2);return{programName:s?"SnapInit":"Snap",getLogDepth:e=>s?`${e} + length(vec2(dFdx(${e}), dFdy(${e})))`:e,renderPassFlag:3,vertexCullX:!s&&"2.0",dontCullOnAlphaZero:!s,appendFragmentOutputs:e=>{e.push(`${a} = ivec4(${A} * ${n}.xyz, ${s?"-":""}${r});`),s&&(e.push(`${l} = ${i?"ivec4(1.0)":`ivec4(normalize(cross(dFdx(${A}), dFdy(${A}))) * float(${R.MAX_INT}), 1.0)`};`),e.push(`${c} = uvec4(${o});`))}}}(e,t,i,r),!0);c[h]="points"===i?{colorRenderers:{"sao-":{vertex:d(((e,t,s)=>s(p(e,t,null,null))))}},occlusionRenderer:d(((e,s,i)=>i(Ws(e,t.logarithmicDepthBufferEnabled)))),pickDepthRenderer:d(f),pickMeshRenderer:d(g),silhouetteRenderer:d(((e,s,i)=>i(zs(e,s,t.logarithmicDepthBufferEnabled,!0)))),snapInitRenderer:d(((e,t,s)=>_(e,t,s,!0,!0))),snapVertexRenderer:d(((e,t,s)=>_(e,t,s,!1,!0)),{vertices:!0})}:"lines"===i?{colorRenderers:{"sao-":{vertex:d(((e,t,s)=>s(p(e,t,null,null))))}},silhouetteRenderer:d(((e,s,i)=>i(zs(e,s,t.logarithmicDepthBufferEnabled,!0)))),snapInitRenderer:d(((e,t,s)=>_(e,t,s,!0,!1))),snapEdgeRenderer:d(((e,t,s)=>_(e,t,s,!1,!1)),{vertices:!1}),snapVertexRenderer:d(((e,t,s)=>_(e,t,s,!1,!1)),{vertices:!0})}:{colorRenderers:function(){const e=e=>Bt(e,t._lightsState),s=e=>{const t=e.createUniform("vec4","uSAOParams",((e,t)=>e(t.legacyFrameCtx.saoParams))),s=yt(e,"sampler2D","uOcclusionTexture",3e3,((e,t)=>e(t.legacyFrameCtx.occlusionTexture)));return{getAmbient:e=>{const i=`${t}.w`;return`(smoothstep(${`${t}.z`}, 1.0, dot(${s(`${e}.xy / ${t}.xy`)}, (255. / 256.) / vec4(256. * 256. * 256., 256. * 256., 256., 1.))) * ${i})`}}},i=function(i){const r=(r,n,A)=>function(e,t,s,i,r,n,A){const o=yt(e,"sampler2D","uColorMap",3001,((e,t)=>{const s=t.layerTextureSet.colorTexture;s&&e(s.texture)})),a=n&&e.createUniform("float","materialAlphaCutoff",((e,t)=>e(t.layerTextureSet.alphaCutoff))),l=t.attributes,c=e.createVarying("vec3","vViewPosition",(()=>`${l.position.view}.xyz`)),h=e.createVarying("vec2","vUV",(()=>l.uv)),u=e.createVarying("vec4","vColor",(()=>l.color)),d=e.createOutput("vec4","outColor");return{programName:"ColorTexture",getHash:()=>[i.getHash(),r?"sao":"nosao",!!A,n?"alphaCutoffYes":"alphaCutoffNo"],getLogDepth:s.logarithmicDepthBufferEnabled&&(e=>e),renderPassFlag:0,appendFragmentOutputs:(e,s,n,A)=>{e.push(`vec3 viewNormal = normalize(cross(dFdx(${c}), dFdy(${c})));`),e.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);"),i.directionalLights.forEach((s=>{e.push(`reflectedColor += max(dot(viewNormal, ${s.getDirection(t.viewMatrix,c)}), 0.0) * ${s.getColor()};`)})),e.push(`vec4 color = vec4(${i.getAmbientColor()} + reflectedColor, 1) * ${A(u)};`),e.push(`vec4 sampleColor = ${o(h)};`),a&&e.push(`if (sampleColor.a < ${a}) { discard; }`),e.push("vec4 colorTexel = color * sampleColor;"),e.push(`${d} = vec4(colorTexel.rgb${r?" * "+r.getAmbient(n):""}, color.a);`),s&&e.push(`${d} = ${s(d)};`)},incrementDrawState:!0}}(r,n,t,e(r),i&&s(r),A,t.gammaOutput);return{PBR:n&&d(((r,n,A)=>A(function(e,t,s,i,r){const n=(t,s,i)=>yt(e,"sampler2D",t,s?3001:3e3,((e,t)=>{const s=i(t.layerTextureSet);s&&e(s.texture)})),A=t.attributes,o=i.getIrradiance,a=n("uColorMap",!0,(e=>e.colorTexture)),l=n("uMetallicRoughMap",!1,(e=>e.metallicRoughnessTexture)),c=n("uEmissiveMap",!0,(e=>e.emissiveTexture)),h=n("uNormalMap",!1,(e=>e.normalsTexture)),u=n("uAOMap",!1,(e=>e.occlusionTexture)),d=e.createVarying("vec3","vViewPosition",(()=>`${A.position.view}.xyz`)),p=e.createVarying("vec3","vViewNormal",(()=>A.normal.view)),f=e.createVarying("vec4","vColor",(()=>A.color)),g=e.createVarying("vec2","vUV",(()=>A.uv)),m=e.createVarying("vec2","vMetallicRoughness",(()=>A.metallicRoughness)),_=e.createVarying("vec3","vWorldNormal",(()=>`${A.normal.world}.xyz`)),b=e.createOutput("vec4","outColor"),B=e.createFragmentDefinition("saturate",((e,t)=>t.push(`float ${e}(const in float a) { return clamp(a, 0.0, 1.0); }`))),y=e.createFragmentDefinition("BRDF_Specular_GGX",((e,t)=>{t.push("vec3 F_Schlick(const in vec3 specularColor, const in float dotLH) {"),t.push(" float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );"),t.push(" return ( 1.0 - specularColor ) * fresnel + specularColor;"),t.push("}"),t.push("float G_GGX_Smith(const in float alpha, const in float dotNL, const in float dotNV) {"),t.push(" float a2 = ( alpha * alpha );"),t.push(" float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );"),t.push(" float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );"),t.push(" return 1.0 / ( gl * gv );"),t.push("}"),t.push("float G_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {"),t.push(" float a2 = ( alpha * alpha );"),t.push(" float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );"),t.push(" float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );"),t.push(" return 0.5 / max( gv + gl, 1e-6 );"),t.push("}"),t.push("float D_GGX(const in float alpha, const in float dotNH) {"),t.push(" float a2 = ( alpha * alpha );"),t.push(" float denom = ( dotNH * dotNH) * ( a2 - 1.0 ) + 1.0;"),t.push(" return 0.31830988618 * a2 / ( denom * denom);"),t.push("}"),t.push(`vec3 ${e}(const in vec3 incidentLightDirection, const in vec3 viewNormal, const in vec3 viewEyeDir, const in vec3 specularColor, const in float roughness) {`),t.push(" float alpha = ( roughness * roughness );"),t.push(" vec3 halfDir = normalize( incidentLightDirection + viewEyeDir );"),t.push(` float dotNL = ${B}( dot( viewNormal, incidentLightDirection ) );`),t.push(` float dotNV = ${B}( dot( viewNormal, viewEyeDir ) );`),t.push(` float dotNH = ${B}( dot( viewNormal, halfDir ) );`),t.push(` float dotLH = ${B}( dot( incidentLightDirection, halfDir ) );`),t.push(" vec3 F = F_Schlick( specularColor, dotLH );"),t.push(" float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );"),t.push(" float D = D_GGX( alpha, dotNH );"),t.push(" return F * (G * D);"),t.push("}")})),w=e.createFragmentDefinition("BRDF_Specular_GGX_Environment",((e,t)=>{t.push(`vec3 ${e}(const in vec3 viewNormal, const in vec3 viewEyeDir, const in vec3 specularColor, const in float roughness) {`),t.push(` float dotNV = ${B}(dot(viewNormal, viewEyeDir));`),t.push(" const vec4 c0 = vec4( -1, -0.0275, -0.572, 0.022);"),t.push(" const vec4 c1 = vec4( 1, 0.0425, 1.04, -0.04);"),t.push(" vec4 r = roughness * c0 + c1;"),t.push(" float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y;"),t.push(" vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;"),t.push(" return specularColor * AB.x + AB.y;"),t.push("}")})),v=e.createFragmentDefinition("perturbNormal2Arb",((e,t)=>{t.push(`vec3 ${e}( vec3 eye_pos, vec3 surf_norm, vec2 uv, vec4 texel ) {`),t.push(" if (texel.r == 0.0 && texel.g == 0.0 && texel.b == 0.0) {"),t.push(" return surf_norm;"),t.push(" }"),t.push(" vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );"),t.push(" vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );"),t.push(" vec2 st0 = dFdx( uv.st );"),t.push(" vec2 st1 = dFdy( uv.st );"),t.push(" vec3 S = normalize( q0 * st1.t - q1 * st0.t );"),t.push(" vec3 T = normalize( -q0 * st1.s + q1 * st0.s );"),t.push(" vec3 N = normalize( surf_norm );"),t.push(" vec3 mapN = texel.xyz * 2.0 - 1.0;"),t.push(" mat3 tsn = mat3( S, T, N );"),t.push(" return normalize( tsn * mapN );"),t.push("}")}));return{programName:"PBR",getHash:()=>[i.getHash(),r?"sao":"nosao",!!s.gammaOutput],getLogDepth:s.logarithmicDepthBufferEnabled&&(e=>e),renderPassFlag:0,clippingCaps:s._sectionPlanesState.clippingCaps&&b,incrementDrawState:!0,appendFragmentOutputs:(e,s,n)=>{if(e.push("const float PI = 3.14159265359;"),e.push("vec3 reflDiff = vec3(0.0);"),e.push("vec3 reflSpec = vec3(0.0);"),e.push(`vec3 rgb = ${f}.rgb;`),e.push(`float opacity = ${f}.a;`),e.push("vec3 baseColor = rgb;"),e.push("float specularF0 = 1.0;"),e.push(`float metallic = float(${m}.r) / 255.0;`),e.push(`float roughness = float(${m}.g) / 255.0;`),e.push("float dielectricSpecular = 0.16 * specularF0 * specularF0;"),e.push(`vec4 colorTexel = ${a(g)};`),e.push("baseColor *= colorTexel.rgb;"),e.push(`vec3 metalRoughTexel = ${l(g)}.rgb;`),e.push("metallic *= metalRoughTexel.b;"),e.push("roughness *= metalRoughTexel.g;"),e.push("vec3 diffuseColor = baseColor * (1.0 - dielectricSpecular) * (1.0 - metallic);"),e.push("float specularRoughness = clamp(roughness, 0.04, 1.0);"),e.push("vec3 specularColor = mix(vec3(dielectricSpecular), baseColor, metallic);"),e.push(`vec3 viewNormal = -${v}(${d}, normalize(${p}), ${g}, ${h(g)});`),e.push(`vec3 viewEyeDir = normalize(${d});`),o&&e.push(`reflDiff += ${o(`normalize(${_})`)};`),i.getReflection){const s=`normalize((vec4(reflect(viewEyeDir, viewNormal), 0.0) * ${t.viewMatrix}).xyz)`,r="8.0",n=`0.5 * clamp(${r} - 0.79248 - 0.5 * log2(pow((2.0 / pow(specularRoughness + 0.0001, 2.0) - 2.0), 2.0) + 1.0), 0.0, ${r})`,A=i.getReflection(s,n),o=`${w}(viewNormal, viewEyeDir, specularColor, specularRoughness)`;e.push(`reflSpec += ${A} * ${o};`)}i.directionalLights.forEach(((s,i)=>{e.push(`vec3 lightDirection${i} = -${s.getDirection(t.viewMatrix,d)};`);const r=`${B}(dot(viewNormal, lightDirection${i}))`;e.push(`vec3 irradiance${i} = ${r} * ${s.getColor()};`),e.push(`reflDiff += irradiance${i};`),e.push(`reflSpec += irradiance${i} * PI * ${y}(lightDirection${i}, viewNormal, viewEyeDir, specularColor, specularRoughness);`)})),e.push(`vec3 emissiveColor = ${c(g)}.rgb;`),e.push(`float aoFactor = ${u(g)}.r;`);const A=`${i.getAmbientColor()} * baseColor * opacity * rgb`;e.push(`vec3 outgoingLight = emissiveColor + reflDiff * diffuseColor + reflSpec + ${A};`),e.push(`${b} = vec4(outgoingLight * aoFactor${r?` * ${r.getAmbient(n)}`:""}, opacity);`),s&&e.push(`${b} = ${s(b)};`)}}}(r,n,t,e(r),i&&s(r))))),texture:A&&{"alphaCutoff-":d(((e,t,s)=>s(r(e,t,!1)))),"alphaCutoff+":d(((e,t,s)=>s(r(e,t,!0))))},vertex:d(o?(t,r,n)=>n(p(t,r,e(t),i&&s(t))):(r,n,A)=>A(function(e,t,s,i,r){const n=t.attributes,A=e.createVarying("vec3","vViewPosition",(()=>`${n.position.view}.xyz`)),o=e.createVarying("vec4","vColor",(()=>n.color)),a=e.createOutput("vec4","outColor");return{programName:"FlatColor",getHash:()=>[i.getHash(),r?"sao":"nosao"],cleanerEdges:!0,getLogDepth:s&&(e=>e),renderPassFlag:0,appendFragmentOutputs:(e,s,n,l)=>{e.push(`vec3 viewNormal = normalize(cross(dFdx(${A}), dFdy(${A})));`);const c=[i.getAmbientColor()].concat(i.directionalLights.map((e=>`max(dot(viewNormal, ${e.getDirection(t.viewMatrix,A)}), 0.0) * ${e.getColor()}`)));e.push(`vec4 fragColor = vec4(${c.join(" + ")}, 1) * ${l(o)};`),e.push(`${a} = ${r?`vec4(fragColor.rgb * ${r.getAmbient(n)}, fragColor.a)`:"fragColor"};`)}}}(r,n,t.logarithmicDepthBufferEnabled,e(r),i&&s(r))))}};return{"sao-":i(!1),"sao+":r&&i(!0)}}(),depthRenderer:d(((e,s,i)=>i(function(e,t,s){const i=e.createVarying("highp vec2","vHighPrecisionZW",(()=>`${t.attributes.position.clip}.zw`)),r=e.createOutput("vec4","outColor");return{programName:"Depth",getLogDepth:s&&(e=>e),renderPassFlag:0,appendFragmentOutputs:e=>e.push(`${r} = vec4(vec3((1.0 - ${i}[0] / ${i}[1]) / 2.0), 1.0);`)}}(e,s,t.logarithmicDepthBufferEnabled)))),edgesRenderers:{uniform:d(((e,s,i)=>i(js(e,s,t.logarithmicDepthBufferEnabled,!0))),{vertices:!1}),vertex:d(((e,s,i)=>i(js(e,s,t.logarithmicDepthBufferEnabled,!1))),{vertices:!1})},occlusionRenderer:d(((e,s,i)=>i(Ws(e,t.logarithmicDepthBufferEnabled)))),pickDepthRenderer:u(f),pickMeshRenderer:u(g),pickNormalsFlatRenderer:u(((e,t,s)=>m(e,t,s,!0))),pickNormalsRenderer:u(((e,t,s)=>m(e,t,s,!1))),shadowRenderer:d(((e,s,i)=>i(function(e,t){const s=e.createOutput("vec4","outColor"),i=e.createFragmentDefinition("encodeFloat",((e,t)=>{t.push(`vec4 ${e}(const in float v) {`),t.push(" const vec4 bitShift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0);"),t.push(" const vec4 bitMask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);"),t.push(" vec4 comp = fract(v * bitShift);"),t.push(" comp -= comp.xxyz * bitMask;"),t.push(" return comp;"),t.push("}")}));return{programName:"Shadow",getLogDepth:t&&(e=>e),renderPassFlag:0,isShadowProgram:!0,appendFragmentOutputs:(e,t,r)=>e.push(`${s} = ${i}(${r}.z);`)}}(e,t)))),silhouetteRenderer:u(((e,s,i)=>i(zs(e,s,t.logarithmicDepthBufferEnabled,!1)))),snapInitRenderer:u(((e,t,s)=>_(e,t,s,!0,!1))),snapEdgeRenderer:u(((e,t,s)=>_(e,t,s,!1,!1)),{vertices:!1}),snapVertexRenderer:u(((e,t,s)=>_(e,t,s,!1,!1)),{vertices:!0})};const b=e=>{!function t(s){s.revalidate?s.revalidate(e):Object.values(s).forEach((e=>e&&t(e)))}(c[h])},B=()=>b(!1);B(),t.on("compile",B),t.on("destroyed",(()=>{delete c[h]}))}return c[h]}}();class di{constructor(e,t,s){this.model=e,this.primitive=t,this.origin=s,this._meshes=[],this._aabb=R.collapseAABB3(),this._aabbDirty=!0}finalize(){if(!this._compiledPortions){this._compiledPortions=this.compilePortions(),this.solid=this._compiledPortions.solid,this.sortId=this._compiledPortions.sortId,this.layerTextureSet=this._compiledPortions.layerTextureSet,this.drawCalls=this._compiledPortions.drawCalls,this._renderers=this._compiledPortions.renderers,this._setFlags=this._compiledPortions.setFlags,this.setColor=this._compiledPortions.setColor,this.setMatrix=this._compiledPortions.setMatrix,this.setOffset=this._compiledPortions.setOffset,this.getEachIndex=this._compiledPortions.getEachIndex,this.getEachVertex=this._compiledPortions.getEachVertex,this.readGeometryData=this._compiledPortions.readGeometryData,this.precisionRayPickSurface=this._compiledPortions.precisionRayPickSurface,this._countsByFlag={};const e=(e,t)=>{const s={count:0,fromFlags:(i,r)=>{i&e?(s.count++,this.model[t]++):r||(s.count--,this.model[t]--)}};this._countsByFlag[e]=s};e(ks,"numVisibleLayerPortions"),e(Qs,"numCulledLayerPortions"),e(Rs,"numPickableLayerPortions"),e(Os,"numClippableLayerPortions"),e(Ls,"numXRayedLayerPortions"),e(Hs,"numHighlightedLayerPortions"),e(Ns,"numSelectedLayerPortions"),this._renderers.edgesRenderers&&e(Gs,"numEdgesLayerPortions"),this._countsByFlagArr=Object.values(this._countsByFlag),this._numTransparentLayerPortions=0}}aabbChanged(){this._aabbDirty=!0}getAABB(){return this._aabbDirty&&(R.collapseAABB3(this._aabb),this._meshes.forEach((e=>R.expandAABB3(this._aabb,e.aabb))),this._aabbDirty=!1),this._aabb}__drawLayer(e,t,s,i){if(this._countsByFlag[Qs].count<this._portions.length&&this._countsByFlag[ks].count>0){const e="points"!==this.primitive&&"lines"!==this.primitive&&[qs,ei,li,ti,si,ii];if(e&&e.includes(i)){const e=!0;if(t.backfaces!==e){const s=this.model.scene.canvas.gl;s.disable(s.CULL_FACE),t.backfaces=e}}t.textureUnit=0,s.drawLayer(t,this,i)}}__setVec4FromMaterialColorAlpha(e,t,s){return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=t,s}__drawColor(e,t,s){if((s?this._numTransparentLayerPortions<this._portions.length:this._numTransparentLayerPortions>0)&&this._countsByFlag[Ls].count<this._portions.length){const i=s&&t.withSAO&&this._renderers.colorRenderers["sao+"]||this._renderers.colorRenderers["sao-"],r=t.pbrEnabled&&i.PBR?i.PBR:t.colorTextureEnabled&&i.texture?i.texture[this.layerTextureSet&&"number"==typeof this.layerTextureSet.alphaCutoff?"alphaCutoff+":"alphaCutoff-"]:i.vertex,n=s?qs:ei;this.__drawLayer(e,t,r,n)}}drawColorOpaque(e,t){this.__drawColor(e,t,!0)}drawColorTransparent(e,t){this.__drawColor(e,t,!1)}drawDepth(e,t){const s=this._renderers.depthRenderer;s&&this._numTransparentLayerPortions<this._portions.length&&this._countsByFlag[Ls].count<this._portions.length&&this.__drawLayer(e,t,s,qs)}__drawSilhouette(e,t,s,i){t.programColor=this.__setVec4FromMaterialColorAlpha(s.fillColor,s.fillAlpha,Zs),this.__drawLayer(e,t,this._renderers.silhouetteRenderer,i)}drawSilhouetteXRayed(e,t){this._countsByFlag[Ls].count>0&&this.__drawSilhouette(e,t,this.model.scene.xrayMaterial,ii)}drawSilhouetteHighlighted(e,t){this._countsByFlag[Hs].count>0&&this.__drawSilhouette(e,t,this.model.scene.highlightMaterial,ti)}drawSilhouetteSelected(e,t){this._countsByFlag[Ns].count>0&&this.__drawSilhouette(e,t,this.model.scene.selectedMaterial,si)}__drawVertexEdges(e,t,s){const i=this._renderers.edgesRenderers&&this._renderers.edgesRenderers.vertex;i&&this._countsByFlag[Gs].count>0&&this.__drawLayer(e,t,i,s)}drawEdgesColorOpaque(e,t){this._compiledPortions.edgesColorOpaqueAllowed()&&this.__drawVertexEdges(e,t,ri)}drawEdgesColorTransparent(e,t){this._numTransparentLayerPortions>0&&this.__drawVertexEdges(e,t,ni)}__drawUniformEdges(e,t,s,i){const r=this._renderers.edgesRenderers&&this._renderers.edgesRenderers.uniform;r&&(t.programColor=this.__setVec4FromMaterialColorAlpha(s.edgeColor,s.edgeAlpha,Zs),this.__drawLayer(e,t,r,i))}drawEdgesHighlighted(e,t){this._countsByFlag[Hs].count>0&&this.__drawUniformEdges(e,t,this.model.scene.highlightMaterial,Ai)}drawEdgesSelected(e,t){this._countsByFlag[Ns].count>0&&this.__drawUniformEdges(e,t,this.model.scene.selectedMaterial,oi)}drawEdgesXRayed(e,t){this._countsByFlag[Ls].count>0&&this.__drawUniformEdges(e,t,this.model.scene.xrayMaterial,ai)}__drawPick(e,t,s){s&&this.__drawLayer(e,t,s,li)}drawPickMesh(e,t){this.__drawPick(e,t,this._renderers.pickMeshRenderer)}drawPickDepths(e,t){this.__drawPick(e,t,this._renderers.pickDepthRenderer)}drawPickNormals(e,t){const s=this._renderers.pickNormalsFlatRenderer;this.__drawPick(e,t,s)}drawSnap(e,t,s){t.snapPickOrigin=[0,0,0];const i=this.getAABB();t.snapPickCoordinateScale=R.mulVec3Scalar(ci([i[3]-i[0],i[4]-i[1],i[5]-i[2]]),R.MAX_INT);const r=s?this._renderers.snapInitRenderer:"edge"===t.snapMode?this._renderers.snapEdgeRenderer:this._renderers.snapVertexRenderer;this.__drawPick(e,t,r),t.snapPickLayerParams.push({origin:t.snapPickOrigin.slice(),coordinateScale:ci(t.snapPickCoordinateScale)})}drawOcclusion(e,t){const s=this._renderers.occlusionRenderer;s&&this.__drawLayer(e,t,s,qs)}drawShadow(e,t){const s=this._renderers.shadowRenderer;s&&this.__drawLayer(e,t,s,qs)}initFlags(e,t,s){this._countsByFlagArr.forEach((e=>e.fromFlags(t,!0))),s&&(this._numTransparentLayerPortions++,this.model.numTransparentLayerPortions++);const i="points"!==this.primitive;this._setFlags(e,t,s,i),this._compiledPortions.setFlags2(e,t,i)}flushInitFlags(){this._compiledPortions.setDeferredFlags()}setVisible(e,t,s){this._countsByFlag[ks].fromFlags(t),this._setFlags(e,t,s)}setCulled(e,t,s){this._countsByFlag[Qs].fromFlags(t),this._setFlags(e,t,s)}setPickable(e,t,s){this._countsByFlag[Rs].fromFlags(t),this._setFlags(e,t,s)}setClippable(e,t){this._countsByFlag[Os].fromFlags(t),this._compiledPortions.setClippableFlags(e,t)}setCollidable(e,t){}setXRayed(e,t,s){this._countsByFlag[Ls].fromFlags(t),this._setFlags(e,t,s)}setHighlighted(e,t,s){this._countsByFlag[Hs].fromFlags(t),this._setFlags(e,t,s)}setSelected(e,t,s){this._countsByFlag[Ns].fromFlags(t),this._setFlags(e,t,s)}setEdges(e,t,s){this._countsByFlag[Gs]&&(this._countsByFlag[Gs].fromFlags(t),this._setFlags(e,t,s))}setTransparent(e,t,s){s?(this._numTransparentLayerPortions++,this.model.numTransparentLayerPortions++):(this._numTransparentLayerPortions--,this.model.numTransparentLayerPortions--),this._setFlags(e,t,s)}destroy(){this._compiledPortions&&this._compiledPortions.destroy()}}let pi=65536,fi=5e6;class gi{constructor(){}set doublePrecisionEnabled(e){R.setDoublePrecisionEnabled(e)}get doublePrecisionEnabled(){return R.getDoublePrecisionEnabled()}set maxDataTextureHeight(e){(e=1024*Math.ceil(e/1024))>4096?e=4096:e<1024&&(e=1024),pi=e}get maxDataTextureHeight(){return pi}set maxGeometryBatchSize(e){e<1e5?e=1e5:e>5e6&&(e=5e6),fi=e}get maxGeometryBatchSize(){return fi}}const mi=e=>{const t=[];for(let s=0;s<e;++s)t.push(s);return t},_i={sizeDataColorsAndFlags:0,sizeDataInstancesMatrices:0,sizeDataPositionDecodeMatrices:0,sizeDataTextureOffsets:0,sizeDataTexturePositions:0,sizeDataTextureIndices:0,sizeDataTextureEdgeIndices:0,sizeDataTexturePortionIds:0,numberOfGeometries:0,numberOfPortions:0,numberOfLayers:0,numberOfTextures:0,totalPolygons:0,totalPolygons8Bits:0,totalPolygons16Bits:0,totalPolygons32Bits:0,totalEdges:0,totalEdges8Bits:0,totalEdges16Bits:0,totalEdges32Bits:0,cannotCreatePortion:{because10BitsObjectId:0,becauseTextureSize:0},overheadSizeAlignementIndices:0,overheadSizeAlignementEdgeIndices:0};window.printDataTextureRamStats=function(){console.log(JSON.stringify(_i,null,4));let e=0;Object.keys(_i).forEach((t=>{t.startsWith("size")&&(e+=_i[t])})),console.log(`Total size ${e} bytes (${(e/1e3/1e3).toFixed(2)} MB)`),console.log(`Avg bytes / triangle: ${(e/_i.totalPolygons).toFixed(2)}`);let t={};Object.keys(_i).forEach((s=>{s.startsWith("size")&&(t[s]=`${(_i[s]/e*100).toFixed(2)} % of total`)})),console.log(JSON.stringify({percentualRamUsage:t},null,4))};const bi=new gi,Bi=bi.maxDataTextureHeight,yi=R.vec3(),wi=R.vec3(),vi=R.vec4();R.vec4();const Ci=new Float32Array(16),Mi=new Uint8Array(4),Ei=R.identityMat4();class Fi extends di{constructor(e,t,s){super(e,t,s),_i.numberOfLayers++,this._sortId=`TriDTX-${_i.numberOfLayers}`;const i=e.scene.canvas.gl,r=(e,t)=>{const s=[];let r=0;const A=[];let o=0;const a=[];let l=0;const c=[];let h=0;return{len:()=>o,accumulateIndices:(i,u)=>{const d=i&&i.length>0&&function(){const t=r/3;r+=i.length,s.push(i);const a=i.length/3;return s=>{const i=o;o+=3*a,n.perObjectIndexBaseOffsets.push(i/3-t);for(let e=0;e<a;e+=8)A.push(s);_i[e]+=a,_i.totalPolygons+=a}}(),p=u&&function(){const e=l/2;l+=u.length,a.push(u);const s=u.length/2;return i=>{const r=h;h+=2*s,n.perObjectEdgeIndexBaseOffsets.push(r/2-e);for(let e=0;e<s;e+=8)c.push(i);_i[t]+=s,_i.totalEdges+=s}}();return _i.numberOfGeometries++,{numTriangles:i?i.length/3:0,accumulateSubPortionId:e=>{d&&d(e),p&&p(e)}}},createDrawers:(e,t)=>{const n=function(t,s){return t.length>0?e([t],t.length,1,i.UNSIGNED_SHORT,"sizeDataTexturePortionIds"):s},u=n(A,{texture:null}),d=r>0&&e(s,r,3,t,"sizeDataTextureIndices"),p=n(c),f=l>0&&e(a,l,2,t,"sizeDataTextureEdgeIndices");return{indices:function(e,t){o>0&&(e.perPrimIndices.setInputValue(d),e.perPrimIdPorIds.setInputValue(u),i.drawArrays(t,0,o))},edges:function(e,t){h>0&&(e.perPrimIndices.setInputValue(f),e.perPrimIdPorIds.setInputValue(p),i.drawArrays(t,0,h))}}}}},n=this._buffer={positionsCompressed:[],lenPositionsCompressed:0,geometry8Bits:r("totalPolygons8Bits","totalEdges8Bits"),geometry16Bits:r("totalPolygons16Bits","totalEdges16Bits"),geometry32Bits:r("totalPolygons32Bits","totalEdges32Bits"),perObjectColors:[],perObjectPickColors:[],perObjectSolid:[],perObjectPositionsDecodeMatrices:[],perObjectInstancePositioningMatrices:[],perObjectVertexBases:[],perObjectIndexBaseOffsets:[],perObjectEdgeIndexBaseOffsets:[]};this._numVertices=0,this._portions=[],this._subPortionReadableGeometries=this.model.scene.readableGeometryEnabled&&{},this._portionToSubPortionsMap=[],this._bucketGeometries={},this._primitive=t}canCreatePortion(e){const t=e.buckets.length;this._portions.length+t>65536&&_i.cannotCreatePortion.because10BitsObjectId++;let s=this._portions.length+t<=65536;const i=void 0!==e.geometryId&&null!==e.geometryId?`${e.geometryId}#0`:`${e.id}#0`;if(!this._bucketGeometries[i]){const t=this._buffer,i=Math.max(t.geometry8Bits.len(),t.geometry16Bits.len(),t.geometry32Bits.len());let r=0,n=0;e.buckets.forEach((e=>{r+=e.positionsCompressed.length/3,n+=e.indices.length/3})),(this._numVertices+r>4096*Bi||i+n>4096*Bi)&&_i.cannotCreatePortion.becauseTextureSize++,s&&=this._numVertices+r<=4096*Bi&&i+n<=4096*Bi}return s}createPortion(e,t){const s=this._buffer,i=t.buckets.map(((e,i)=>{const r=(t.geometryId??t.id)+"#"+i;if(!(r in this._bucketGeometries)){const t=(e,t,s)=>{if(e){const i=8*Math.ceil(e.length/t/8)*t,r=new Uint32Array(i);return r.set(e),_i[s]+=2*(r.length-e.length),r}return e};e.indices=t(e.indices,3,"overheadSizeAlignementIndices"),e.edgeIndices=t(e.edgeIndices,2,"overheadSizeAlignementEdgeIndices");const i=e.positionsCompressed;s.positionsCompressed.push(i);const n=i.length/3;this._numVertices+=n;const A=s.lenPositionsCompressed/3;s.lenPositionsCompressed+=i.length,this._bucketGeometries[r]={vertexBase:A,geometryData:function(){const t=e.indices,i=e.edgeIndices;return n<=256?s.geometry8Bits.accumulateIndices(t,i):n<=65536?s.geometry16Bits.accumulateIndices(t,i):s.geometry32Bits.accumulateIndices(t,i)}()}}const n=this._bucketGeometries[r];s.perObjectPositionsDecodeMatrices.push(t.positionsDecodeMatrix),s.perObjectInstancePositioningMatrices.push(t.meshMatrix||Ei),s.perObjectSolid.push(!!t.solid),s.perObjectPickColors.push(t.pickColor),s.perObjectVertexBases.push(n.vertexBase);const A=t.colors,o=t.color;s.perObjectColors.push(A?[255*A[0],255*A[1],255*A[2],255]:[o[0],o[1],o[2],t.opacity]);const a=this._portions.length;return this._portions.push({}),n.geometryData.accumulateSubPortionId(a),this._subPortionReadableGeometries&&(this._subPortionReadableGeometries[a]={indices:e.indices,positionsCompressed:e.positionsCompressed,positionsDecodeMatrix:t.positionsDecodeMatrix}),_i.numberOfPortions++,a})),r=this._portionToSubPortionsMap.length;return this._portionToSubPortionsMap.push(i),this.model.numPortions++,this._meshes.push(e),r}compilePortions(){const e=this._buffer,t=this.model,s=this._portions.length,i=this.origin,r=this._portionToSubPortionsMap,n=this._primitive,A=this._sortId,o=this._subPortionReadableGeometries,a=t.scene,l=a.canvas.gl,c=xi(l,s,32,l.UNSIGNED_BYTE,512,(t=>{const i=e=>[e>>24&255,e>>16&255,e>>8&255,255&e];for(let r=0;r<s;r++)t.set(e.perObjectColors[r],32*r+0),t.set(e.perObjectPickColors[r],32*r+4),t.set([0,0,0,0],32*r+8),t.set([0,0,0,0],32*r+12),t.set(i(e.perObjectVertexBases[r]),32*r+16),t.set(i(e.perObjectIndexBaseOffsets[r]),32*r+20),t.set(i(e.perObjectEdgeIndexBaseOffsets[r]),32*r+24),t.set([e.perObjectSolid[r]?1:0,0,0,0],32*r+28)}),"sizeDataColorsAndFlags",!0),h=c.textureData,u=function(e,t,s,i,r,n,A){return xi(l,t,s,i,r,(t=>{for(let s=0,i=0,r=e.length;s<r;s++){const r=e[s];t.set(r,i),i+=r.length}}),n,A)},d=function(e,t,s){const i=e.length;if(0===i)throw"num "+t+" matrices===0";return u(e,i,16,l.FLOAT,512,t,s)},p=d(e.perObjectInstancePositioningMatrices,"sizeDataInstancesMatrices",!0),f=p.textureData,g=d(e.perObjectPositionsDecodeMatrices,"sizeDataPositionDecodeMatrices",!1),m=function(e,t,s,i,r){return u(e,t/s,s,i,4096,r,!1)},_=m(e.positionsCompressed,e.lenPositionsCompressed,3,l.UNSIGNED_SHORT,"sizeDataTexturePositions"),b=e.geometry8Bits.createDrawers(m,l.UNSIGNED_BYTE),B=e.geometry16Bits.createDrawers(m,l.UNSIGNED_SHORT),y=e.geometry32Bits.createDrawers(m,l.UNSIGNED_INT);this._buffer=null;let w=!1,v=!1,C=!1,M=0;const E=()=>{w=!0},F=a.on("rendering",(()=>{v&&(w=!1,v=!1,h.reloadData()),M=0})),x=(e,s)=>{const i=r[e];if(i)for(let e=0,t=i.length;e<t;e++)s(i[e]);else t.error("portion not found: "+e)},U=(e,t,s,i)=>{const r=w||i;r?v=!0:++M>=10&&E(),h.setData(s,e,t,!r)},I=(e,t,s=!1)=>{Mi.set([t&Os?255:0,0,1,2]),x(e,(e=>U(e,3,Mi,s)))};return{edgesColorOpaqueAllowed:()=>!a.logarithmicDepthBufferEnabled||(a._loggedWarning||(console.log("Edge enhancement for SceneModel data texture layers currently disabled with logarithmic depth buffer"),a._loggedWarning=!0),!1),sortId:A,setClippableFlags:I,setFlags:(e,t,s,i=!1)=>{hi(t,s,!0,a,Mi),x(e,(e=>U(e,2,Mi,i)))},setFlags2:I,setDeferredFlags:()=>{},setColor:(e,t)=>{Mi.set(t),x(e,(e=>U(e,0,Mi,!1)))},setMatrix:(e,t)=>{x(e,(e=>{const s=w;s?v=!0:++M>=10&&E(),Ci.set(t),f.setData(Ci,e,0,!s)}))},setOffset:(e,t)=>{},getEachIndex:(e,t)=>{o&&x(e,(e=>o[e].indices.forEach((e=>t(e)))))},getEachVertex:(e,s)=>{o&&x(e,(e=>{const r=o[e],n=r.positionsCompressed,A=r.positionsDecodeMatrix,a=vi;for(let e=0,r=n.length;e<r;e+=3)a[0]=n[e],a[1]=n[e+1],a[2]=n[e+2],a[3]=1,R.decompressPosition(a,A),R.mulMat4v4(t.worldMatrix,a,a),R.addVec3(i,a,a),s(a)}))},precisionRayPickSurface:(e,t,s,i,r)=>!1,renderers:ui(a,"dtx",n,t.saoEnabled,!1,!1,!0,((e,t)=>Ui(e,!t))),drawCalls:function(){const e=function(e){const s=(e,t)=>e.setInputValue&&e.setInputValue(t);return(r,n,A)=>{s(n.worldMatrix,t.rotationMatrix),s(n.viewMatrix,A.viewMatrix),s(n.projMatrix,A.projMatrix);const o=R.transformPoint3(t.matrix,i,yi);s(n.uCameraEyeRtc,R.subVec3(A.eye,o,wi)),s(n.perObjPosDecode,g),s(n.perVertIdCoords,_),s(n.perObjColsFlags,c),s(n.perObjectMatrix,p),e(n)}},s=function(t){return e((e=>{b.edges(e,t),B.edges(e,t),y.edges(e,t)}))};return{drawVertices:s(l.POINTS),drawEdges:s(l.LINES),drawSurface:e((e=>{const t=l.TRIANGLES;b.indices(e,t),B.indices(e,t),y.indices(e,t)}))}}(),destroy:()=>{C||(a.off(F),C=!0)}}}}const xi=function(e,t,s,i,r,n,A,o){if(s>4&&s%4>0)throw"Unhandled data size "+s;const a=Math.ceil(s/4),l=s/a,[c,h,u]=function(){switch(i){case e.UNSIGNED_BYTE:return[Uint8Array,...1===l?[e.R8UI,e.RED_INTEGER]:2===l?[e.RG8UI,e.RG_INTEGER]:3===l?[e.RGB8UI,e.RGB_INTEGER]:[e.RGBA8UI,e.RGBA_INTEGER]];case e.UNSIGNED_SHORT:return[Uint16Array,...1===l?[e.R16UI,e.RED_INTEGER]:2===l?[e.RG16UI,e.RG_INTEGER]:3===l?[e.RGB16UI,e.RGB_INTEGER]:[e.RGBA16UI,e.RGBA_INTEGER]];case e.UNSIGNED_INT:return[Uint32Array,...1===l?[e.R32UI,e.RED_INTEGER]:2===l?[e.RG32UI,e.RG_INTEGER]:3===l?[e.RGB32UI,e.RGB_INTEGER]:[e.RGBA32UI,e.RGBA_INTEGER]];case e.FLOAT:return[Float32Array,...1===l?[e.R32F,e.RED]:2===l?[e.RG32F,e.RG]:3===l?[e.RGB32F,e.RGB]:[e.RGBA32F,e.RGBA]];default:throw"Unhandled data type "+i}}(),d=r*a,p=Math.ceil(t/r);if(0===p)throw"texture height===0";const f=new c(d*p*l);_i[A]+=f.byteLength,_i.numberOfTextures++,n(f);const g=e.createTexture();return e.bindTexture(e.TEXTURE_2D,g),e.texStorage2D(e.TEXTURE_2D,1,h,d,p),e.texSubImage2D(e.TEXTURE_2D,0,0,0,d,p,u,i,f),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null),{bind:t=>(e.activeTexture(e["TEXTURE"+t]),e.bindTexture(e.TEXTURE_2D,g),!0),unbind(e){},textureData:o&&{setData(t,n,A=0,o=!1){if(f.set(t,n*s+A*l),o){e.bindTexture(e.TEXTURE_2D,g);const s=n%r*a+A,o=Math.floor(n/r),c=t.length/l;e.texSubImage2D(e.TEXTURE_2D,0,s,o,c,1,u,i,t)}},reloadData(){e.bindTexture(e.TEXTURE_2D,g),e.texSubImage2D(e.TEXTURE_2D,0,0,0,d,p,u,i,f)}}}},Ui=function(e,t){const s=(t,s)=>{const i=e.createUniform(t,s),r=e=>`texelFetch(${i}, ${e}, 0)`;return r.map=i,r},i=s("highp usampler2D","perPrimIndices"),r=s("mediump usampler2D","perPrimIdPorIds"),n=s("highp sampler2D","perObjPosDecode"),A=s("mediump usampler2D","perVertIdCoords"),o=s("lowp usampler2D","perObjColsFlags"),a=s("highp sampler2D","perObjectMatrix"),l=e.createUniform("mat4","worldMatrix"),c=e.createUniform("mat4","viewMatrix"),h=e.createUniform("mat4","projMatrix"),u=e.createUniform("vec3","uCameraEyeRtc"),d=function(e){const t={toString:()=>(t.needed=!0,e)};return t},p=d("colorA"),f=d("pickColor"),g=d("worldNormal"),m=d("viewNormal"),_=e=>o(`ivec2(objectIndexCoords.x*8+${e}, objectIndexCoords.y)`);return{clippableTest:function(){const t=e.createVarying("uint","vClippable",(()=>"flags2.r"),"flat");return()=>`${t} > 0u`}(),geometryParameters:{attributes:{color:p,flags:mi(4).map((e=>`int(flags[${e}])`)),metallicRoughness:null,normal:{view:m,world:g},pickColor:f,position:{clip:"gl_Position",view:"viewPosition",world:"worldPosition"},uv:null},projMatrix:h,viewMatrix:c},ensureColorAndFlagAvailable:e=>{e.push("int primitiveIndex = gl_VertexID / "+(t?3:2)+";"),e.push("int h_packed_object_id_index = (primitiveIndex >> 3) & 4095;"),e.push("int v_packed_object_id_index = (primitiveIndex >> 3) >> 12;"),e.push(`int objectIndex = int(${r("ivec2(h_packed_object_id_index, v_packed_object_id_index)")}.r);`),e.push("ivec2 objectIndexCoords = ivec2(objectIndex % 512, objectIndex / 512);"),e.push(`uvec4 flags = ${_(2)};`),e.push(`uvec4 flags2 = ${_(3)};`),p.needed&&e.push(`vec4 ${p} = vec4(${_(0)}) / 255.0;`)},appendVertexData:e=>{const s=e=>a(`ivec2(objectIndexCoords.x*4+${e}, objectIndexCoords.y)`);e.push(`mat4 objectInstanceMatrix = mat4(${s(0)}, ${s(1)}, ${s(2)}, ${s(3)});`);const r=e=>n(`ivec2(objectIndexCoords.x*4+${e}, objectIndexCoords.y)`);if(e.push(`mat4 objectDecodeAndInstanceMatrix = objectInstanceMatrix * mat4(${r(0)}, ${r(1)}, ${r(2)}, ${r(3)});`),e.push(`ivec4 packedVertexBase = ivec4(${_(4)});`),e.push(`ivec4 packedIndexBaseOffset = ivec4(${_(t?5:6)});`),e.push("int indexBaseOffset = (packedIndexBaseOffset.r << 24) + (packedIndexBaseOffset.g << 16) + (packedIndexBaseOffset.b << 8) + packedIndexBaseOffset.a;"),e.push("int h_index = (primitiveIndex - indexBaseOffset) & 4095;"),e.push("int v_index = (primitiveIndex - indexBaseOffset) >> 12;"),e.push(`ivec3 vertexIndices = ivec3(${i("ivec2(h_index, v_index)")});`),e.push("ivec3 uniqueVertexIndexes = vertexIndices + (packedVertexBase.r << 24) + (packedVertexBase.g << 16) + (packedVertexBase.b << 8) + packedVertexBase.a;"),t){e.push("ivec3 indexPositionH = uniqueVertexIndexes & 4095;"),e.push("ivec3 indexPositionV = uniqueVertexIndexes >> 12;"),e.push(`uint solid = ${_(7)}.r;`);const t=e=>`vec3(${A(`ivec2(indexPositionH[${e}], indexPositionV[${e}])`)})`;e.push(`vec3 positions[] = vec3[](${t(0)}, ${t(1)}, ${t(2)});`),e.push("vec3 normal = normalize(cross(positions[2] - positions[0], positions[1] - positions[0]));"),e.push("vec3 position = positions[gl_VertexID % 3];"),g.needed&&e.push(`vec3 worldNormal = -normalize((transpose(inverse(${l} * objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);`),m.needed&&e.push(`vec3 viewNormal = -normalize((transpose(inverse(${c} * objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);`),e.push("if (solid != 1u) {"),e.push(` if (${o=h,`(${o}[2][3] == - 1.0)`}) {`),e.push(` vec3 uCameraEyeRtcInQuantizedSpace = (inverse(${l} * objectDecodeAndInstanceMatrix) * vec4(${u}, 1)).xyz;`),e.push(" if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {"),e.push(" position = positions[2 - (gl_VertexID % 3)];"),g.needed&&e.push(" worldNormal = -worldNormal;"),m.needed&&e.push(" viewNormal = -viewNormal;"),e.push(" }"),e.push(" } else {"),m.needed||e.push(` vec3 viewNormal = -normalize((transpose(inverse(${c} * objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);`),e.push(" if (viewNormal.z < 0.0) {"),e.push(" position = positions[2 - (gl_VertexID % 3)];"),g.needed&&e.push(" worldNormal = -worldNormal;"),m.needed&&e.push(" viewNormal = -viewNormal;"),e.push(" }"),e.push(" }"),e.push("}")}else e.push("int indexPositionH = uniqueVertexIndexes[gl_VertexID % 2] & 4095;"),e.push("int indexPositionV = uniqueVertexIndexes[gl_VertexID % 2] >> 12;"),e.push(`vec3 position = vec3(${A("ivec2(indexPositionH, indexPositionV)")});`);var o;f.needed&&e.push(`vec4 pickColor = vec4(${_(1)});`),e.push(`vec4 worldPosition = ${l} * (objectDecodeAndInstanceMatrix * vec4(position, 1.0));`)},layerTypeInputs:{perPrimIndices:i.map,perPrimIdPorIds:r.map,perObjPosDecode:n.map,perVertIdCoords:A.map,perObjColsFlags:o.map,perObjectMatrix:a.map,worldMatrix:l,viewMatrix:c,projMatrix:h,uCameraEyeRtc:u}}},Ii=R.mat4(),Ti=R.mat4();function Pi(e,t,s){const i=e.length,r=new Uint16Array(i),n=t[0],A=t[1],o=t[2],a=t[3]-n||1,l=t[4]-A||1,c=t[5]-o||1,h=65525,u=h/a,d=h/l,p=h/c,f=e=>e>=0?e:0;for(let t=0;t<i;t+=3)r[t+0]=Math.floor(f(e[t+0]-n)*u),r[t+1]=Math.floor(f(e[t+1]-A)*d),r[t+2]=Math.floor(f(e[t+2]-o)*p);return R.identityMat4(Ii),R.translationMat4v(t,Ii),R.identityMat4(Ti),R.scalingMat4v([a/h,l/h,c/h],Ti),R.mulMat4(Ii,Ti,s),r}function Si(e,t){const s=e[0],i=e[1],r=e[2],n=e[3]-s||1,A=e[4]-i||1,o=e[5]-r||1,a=65525;return R.identityMat4(Ii),R.translationMat4v(e,Ii),R.identityMat4(Ti),R.scalingMat4v([n/a,A/a,o/a],Ti),R.mulMat4(Ii,Ti,t),t}function Di(e,t,s){let i=e[0]/(Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2])),r=e[1]/(Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2]));if(e[2]<0){let e=i,t=r;e=(1-Math.abs(r))*(i>=0?1:-1),t=(1-Math.abs(i))*(r>=0?1:-1),i=e,r=t}return new Int8Array([Math[t](127.5*i+(i<0?-1:0)),Math[s](127.5*r+(r<0?-1:0))])}function ki(e){let t=e[0],s=e[1];t/=t<0?127:128,s/=s<0?127:128;const i=1-Math.abs(t)-Math.abs(s);i<0&&(t=(1-Math.abs(s))*(t>=0?1:-1),s=(1-Math.abs(t))*(s>=0?1:-1));const r=Math.sqrt(t*t+s*s+i*i);return[t/r,s/r,i/r]}const Qi=new Float32Array(1),Ri=new Float32Array(4),Oi=new Float32Array(3),Vi=R.mat4(),Li=R.vec4([0,0,0,1]),Hi=R.vec4(),Ni=R.vec3(),Gi=R.vec3(),ji=R.vec3(),Wi=R.vec3(),zi=R.vec3(),Xi=R.vec3(),Ki=R.vec3(),Zi=new Uint8Array(4),Ji=new Float32Array(96),Yi=function(e){const t=[];for(let s=0;s<e;++s)t.push(s);return t},$i=function(e,t){e.set(t);let s=t.length;const i=e.length;for(;s<i;){const t=Math.min(s,i-s);e.set(e.subarray(0,t),s),s+=t}},qi=function(){let e=0;const t=new Map;return{acquire:()=>e++,release:()=>{e--,0===e&&t.clear()},getTypeArray:function(e,s){t.has(e)||t.set(e,{});const i=t.get(e);return s in i||(i[s]=new e(s)),i[s]}}}();class er extends di{constructor(e,t,s,i){super(e,t,s);const r=!!i.geometry;this._maxVerts=i.maxGeometryBatchSize;const n=r?i.geometry.positionsDecodeMatrix:i.positionsDecodeMatrix;this._positionsDecodeMatrix=n&&R.mat4(n),this._cfgUvDecodeMatrix=i.uvDecodeMatrix&&R.mat3(i.uvDecodeMatrix),this._instancedGeometry=i.geometry,this._textureSet=i.textureSet,this._modelAABB=!r&&R.collapseAABB3(),this._portions=[];const A=function(){let e=0;const t=[];return{length:()=>e,append:function(s,i=1,r=1,n=0){e+=i*s.length,t.push({data:s,times:i,denormalizeScale:r,increment:n})},compileBuffer:function(e){let s=0;t.forEach((e=>{s+=e.times*e.data.length}));const i=new e(s);let r=0;return t.forEach((e=>{const t=e.data,s=e.denormalizeScale,n=e.increment,A=i.subarray(r);if(1===s&&0===n)A.set(t);else for(let e=0;e<t.length;++e)A[e]=n+t[e]*s;let o=t.length;const a=e.times*t.length;for(;o<a;){const e=Math.min(o,a-o);A.set(A.subarray(0,e),o),o+=e}r+=o})),i}}};this._buffer={colors:A(),metallicRoughness:A(),pickColors:A(),...r?{modelMatrixCol:[A(),A(),A()],modelNormalMatrixCol:[A(),A(),A()]}:{positions:A(),indices:A(),uv:A(),normals:A(),edgeIndices:A()}}}canCreatePortion(e,t){return this._instancedGeometry||this._buffer.positions.length()+e<=3*this._maxVerts&&this._buffer.indices.length()+t<=3*this._maxVerts}createPortion(e,t){const s=this._buffer,i=this._instancedGeometry,r=this.model,n=this._portions.length,A=this.primitive,o=!!this._positionsDecodeMatrix,a=r.scene,l=t.meshMatrix,c=(i,o,l,c,h)=>{const u=this._portions.length>0&&this._portions[this._portions.length-1],d={indicesBaseIndex:u?u.indicesBaseIndex+u.numIndices:0,numIndices:l?l.length:0,portionBase:i,portionSize:o,retainedGeometry:a.readableGeometryEnabled&&"points"!==A&&"lines"!==A&&{indices:l,quantizedPositions:c,offset:a.entityOffsetsEnabled&&R.vec3(),matrix:h&&h.slice(),inverseMatrix:null,normalMatrix:null}};return"points"!==A&&"lines"!==A&&s.metallicRoughness.append([t.metallic??0,t.roughness??255],o),"lines"!==A&&s.pickColors.append(t.pickColor.slice(0,4),o),this._portions.push(d),r.numPortions++,this._meshes.push(e),n};if(i){if(s.modelMatrixCol.forEach(((e,t)=>e.append([l[t+0],l[t+4],l[t+8],l[t+12]]))),"points"!==A){const e=t.color;s.colors.append([e[0],e[1],e[2],t.opacity??255])}if("points"!==A&&"lines"!==A&&i.normals){const e=R.inverseMat4(R.transposeMat4(l,R.mat4()));s.modelNormalMatrixCol.forEach(((t,s)=>t.append([e[s+0],e[s+4],e[s+8],e[s+12]])))}return c(n,1,i.indices,i.positionsCompressed,l)}{const e=s.positions.length()/3,i=o?t.positionsCompressed:t.positions;if(!i)throw(o?"positionsCompressed":"positions")+" expected";s.positions.append(i);const r=i.length/3,n=t.indices;n&&s.indices.append(n,1,1,e);const a=t.normalsCompressed,h=t.normals;if(a&&a.length>0)s.normals.append(a);else if(h&&h.length>0){const e=Vi;l?(R.transposeMat4(l,e),R.inverseMat4(e,e)):R.identityMat4(e);const t=[];!function(e,t,s,i,r){function n(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}let A,o,a,l,c,h,u=new Float32Array([0,0,0,0]),d=new Float32Array([0,0,0,0]);for(h=0;h<s;h+=3)u[0]=t[h],u[1]=t[h+1],u[2]=t[h+2],R.transformVec3(e,u,d),R.normalizeVec3(d,d),a=A=Di(d,"floor","floor"),o=ki(A),l=c=n(d,o),A=Di(d,"ceil","floor"),o=ki(A),l=n(d,o),l>c&&(a=A,c=l),A=Di(d,"floor","ceil"),o=ki(A),l=n(d,o),l>c&&(a=A,c=l),A=Di(d,"ceil","ceil"),o=ki(A),l=n(d,o),l>c&&(a=A,c=l),i[r+h+0]=a[0],i[r+h+1]=a[1],i[r+h+2]=0}(e,h,h.length,t,0),s.normals.append(t)}const u=t.colors,d=t.colorsCompressed,p=t.color;if(u)if("points"===A)s.colors.append(u,1,255);else{const e=[];for(let t=0,s=u.length;t<s;t+=3)e.push(255*u[t]),e.push(255*u[t+1]),e.push(255*u[t+2]),e.push(255);s.colors.append(e)}else if(d)if("points"===A)s.colors.append(d);else{const e=[];for(let t=0,s=d.length;t<s;t+=3)e.push(d[t]),e.push(d[t+1]),e.push(d[t+2]),e.push(255);s.colors.append(e)}else p&&s.colors.append([p[0],p[1],p[2],"points"===A?1:t.opacity],r);const f=e=>e&&e.length>0&&e,g=f(t.uv)||f(t.uvCompressed);g&&s.uv.append(g);const m=t.edgeIndices;return m&&s.edgeIndices.append(m,1,1,e),R.expandAABB3(this._modelAABB,t.aabb),c(e,r,n)}}compilePortions(){const e=this._buffer,t=this._instancedGeometry,s=this.model,i=this._modelAABB,r=this.origin,n=this._portions,A=this.primitive,o=this._textureSet;let a=this._positionsDecodeMatrix;const l=this._cfgUvDecodeMatrix,c=s.scene,h=c.canvas.gl,u=!!t,d=[],p=(e,t,s,i)=>{if(t.length>0){const r=t.constructor,[n,A]={[Uint8Array]:[1,h.UNSIGNED_BYTE],[Int8Array]:[1,h.BYTE],[Uint16Array]:[2,h.UNSIGNED_SHORT],[Int16Array]:[2,h.SHORT],[Uint32Array]:[4,h.UNSIGNED_INT],[Int32Array]:[4,h.INT],[Float32Array]:[4,h.FLOAT]}[r],o=h.createBuffer();d.push((()=>h.deleteBuffer(o)));const a=()=>h.bindBuffer(e,o),l=t=>{a(),h.bufferData(e,t,i)};l(t);const c=t.BYTES_PER_ELEMENT,u=t.length/s;return{bindBuffer:a,getData:(t=0,i=u-t)=>{a();const A=new r(i*s);return h.getBufferSubData(e,t*n*s,A,0,i*s),A},numItems:u,setData:l,setSubData:(t,s)=>{a(),h.bufferSubData(e,s*c,t)},type:A}}return null},f=(e,t,s,i=!1,r=!1)=>{const n=p(h.ARRAY_BUFFER,e,t,s);return n&&{getData:n.getData,numItems:n.numItems,setData:n.setData,setSubData:n.setSubData,attributeDivisor:i&&1,bindAtLocation:e=>{n.bindBuffer(),h.vertexAttribPointer(e,t,n.type,!!r,0,0)}}},g=e=>{const t=p(h.ELEMENT_ARRAY_BUFFER,e,1,h.STATIC_DRAW);return t&&{getData:t.getData,bindIndicesBuffer:t.bindBuffer,indicesCount:e.length,indicesType:t.type}},m=n.reduce(((e,t)=>e+t.portionSize),0),_=f(new Float32Array(m),1,h.DYNAMIC_DRAW,u),b=(e,t)=>f(e,4,t,u&&"points"!==A,!0),B=u&&t.colorsCompressed?b(new Uint8Array(t.colorsCompressed),h.STATIC_DRAW):b(e.colors.compileBuffer(Uint8Array),h.DYNAMIC_DRAW),y=c.entityOffsetsEnabled&&f(new Float32Array(3*m),3,h.DYNAMIC_DRAW,u),w=f(e.metallicRoughness.compileBuffer(Uint8Array),2,h.STATIC_DRAW,u),v=f(e.pickColors.compileBuffer(Uint8Array),4,h.STATIC_DRAW,u),C=g(u?new Uint32Array(t.edgeIndices):e.edgeIndices.compileBuffer(Uint32Array)),M=u?"points"!==A&&t.indices&&new Uint32Array(t.indices):e.indices.compileBuffer(Uint32Array),E=M&&g(M),F=u?t.positionsCompressed:a?e.positions.compileBuffer(Uint16Array):Pi(e.positions.compileBuffer(Float64Array),i,a=R.mat4()),x=F&&f(F,3,h.STATIC_DRAW);u||n.forEach((e=>{if(e.retainedGeometry){const t=3*e.portionBase;e.retainedGeometry.quantizedPositions=F.subarray(t,t+3*e.portionSize)}}));const U=u&&e.modelMatrixCol.map((e=>f(e.compileBuffer(Float32Array),4,h.STATIC_DRAW,!0))),I=!u&&e.normals.compileBuffer(Int8Array),T=I&&f(I,3,h.STATIC_DRAW,!1,!0),P=U&&T&&e.modelNormalMatrixCol.map((e=>f(e.compileBuffer(Float32Array),4,h.STATIC_DRAW,!0))),S=u?"points"!==A&&"lines"!==A&&t.uvCompressed&&{buf:f(t.uvCompressed,2,h.STATIC_DRAW),mat:t.uvDecodeMatrix}:function(){const t=e.uv.compileBuffer(Float32Array);if(0===t.length)return null;if(l)return{buf:f(t,2,h.STATIC_DRAW),mat:l};{const e=Re.getUVBounds(t),s=Re.compressUVs(t,e.min,e.max);return{buf:f(s.quantized,2,h.STATIC_DRAW),mat:R.mat3(s.decodeMatrix)}}}();this._buffer=null,qi.acquire(),d.push((()=>qi.release()));let D=null;const k=(e,s,i,r=!1)=>{hi(s,i,"points"!==A&&"lines"!==A,c,Zi);const o=s&Os?1:0;let a=0;a|=Zi[0],a|=Zi[1]<<4,a|=Zi[2]<<8,a|=Zi[3]<<12,a|=o<<16,Qi[0]=a;const l=n[e],h=l.portionBase,u=l.portionSize;if(r&&!t)D||(D=new Float32Array(m)),$i(D.subarray(h,h+u),Qi);else if(_){const e=qi.getTypeArray(Float32Array,u);$i(e,Qi),_.setSubData(e,h)}},Q="solid"===A;return{edgesColorOpaqueAllowed:()=>!0,solid:Q,sortId:("points"===A?"Points":"lines"===A?"Lines":"Triangles")+(u?"Instancing":"Batching")+"Layer"+("points"!==A&&"lines"!==A?(Q?"-solid":"-surface")+"-autoNormals"+(u?"":(o&&o.colorTexture?"-colorTexture":"")+(o&&o.metallicRoughnessTexture?"-metallicRoughnessTexture":"")):""),setClippableFlags:k,setFlags:k,setFlags2:(e,t,s)=>{},setDeferredFlags:()=>{D&&(_.setData(D),D=null)},setColor:(e,t)=>{if(B){const s=n[e],i=qi.getTypeArray(Uint8Array,4*s.portionSize);$i(i,t.slice(0,4)),B.setSubData(i,4*s.portionBase)}},setMatrix:(e,t)=>{U&&U.forEach(((s,i)=>{Ri[0]=t[i+0],Ri[1]=t[i+4],Ri[2]=t[i+8],Ri[3]=t[i+12],s.setSubData(Ri,4*e)}))},setOffset:(e,t)=>{if(c.entityOffsetsEnabled){const s=n[e];if(y){Oi.set(t);const e=qi.getTypeArray(Float32Array,3*s.portionSize);$i(e,Oi),y.setSubData(e,3*s.portionBase)}s.retainedGeometry&&s.retainedGeometry.offset.set(t)}else s.error("Entity#offset not enabled for this Viewer")},getEachIndex:(e,t)=>{const s=n[e].retainedGeometry;s&&s.indices.forEach((e=>t(e)))},getEachVertex:(e,t)=>{const i=n[e].retainedGeometry;if(i){const e=Hi;r?e.set(r,0):e[0]=e[1]=e[2]=0,e[3]=1;const n=s.matrix;R.mulMat4v4(n,e,e);const A=i.quantizedPositions,o=Li;for(let s=0,r=A.length;s<r;s+=3)o[0]=A[s],o[1]=A[s+1],o[2]=A[s+2],R.decompressPosition(o,a),i.matrix&&R.transformPoint3(i.matrix,o,o),o[3]=1,R.mulMat4v4(n,o,o),R.addVec3(e,o,o),t(o)}},readGeometryData:"points"!==A&&"lines"!==A&&(e=>{const t=!u&&n[e],i=t?E.getData(t.indicesBaseIndex,t.numIndices).map((e=>e-t.portionBase)):E.getData(),A=s.matrix,o=R.vec4();o.set(r,0),o[3]=1,R.mulMat4v4(A,o,o);const l=U&&R.mat4();if(l){const t=U[0].getData(e,1),s=U[1].getData(e,1),i=U[2].getData(e,1);l.set([t[0],s[0],i[0],0,t[1],s[1],i[1],0,t[2],s[2],i[2],0,t[3],s[3],i[3],1])}const c=R.mat4();R.mulMat4(A,l?R.mulMat4(l,a,c):a,c),c[12]+=o[0],c[13]+=o[1],c[14]+=o[2];const h=t?x.getData(t.portionBase,t.portionSize):x.getData();return{indices:i,positions:R.transformPositions3(c,h,new Float64Array(h.length))}}),precisionRayPickSurface:(e,t,i,A,o)=>{const l=n[e].retainedGeometry;if(l){l.matrix&&!l.inverseMatrix&&(l.inverseMatrix=R.inverseMat4(l.matrix,R.mat4())),o&&l.inverseMatrix&&!l.normalMatrix&&(l.normalMatrix=R.transposeMat4(l.inverseMatrix,R.mat4()));const e=l.quantizedPositions,n=l.indices,c=l.offset,h=Ni,u=Gi;h.set(r?R.subVec3(t,r,ji):t),u.set(i),c&&R.subVec3(h,c),R.transformRay(s.worldNormalMatrix,h,u,h,u),l.inverseMatrix&&R.transformRay(l.inverseMatrix,h,u,h,u);const d=Wi,p=zi,f=Xi;let g=!1,m=0;const _=Ki;for(let i=0,b=n.length;i<b;i+=3){const b=3*n[i],B=3*n[i+1],y=3*n[i+2];if(d[0]=e[b],d[1]=e[b+1],d[2]=e[b+2],p[0]=e[B],p[1]=e[B+1],p[2]=e[B+2],f[0]=e[y],f[1]=e[y+1],f[2]=e[y+2],R.decompressPosition(d,a),R.decompressPosition(p,a),R.decompressPosition(f,a),R.rayTriangleIntersect(h,u,d,p,f,_)){l.matrix&&R.transformPoint3(l.matrix,_,_),R.transformPoint3(s.worldMatrix,_,_),c&&R.addVec3(_,c),r&&R.addVec3(_,r);const e=Math.abs(R.lenVec3(R.subVec3(_,t,[])));(!g||e>m)&&(m=e,A.set(_),o&&R.triangleNormal(d,p,f,o),g=!0)}}return g&&o&&(l.normalMatrix&&R.transformVec3(l.normalMatrix,o,o),R.transformVec3(s.worldNormalMatrix,o,o),R.normalizeVec3(o)),g}return!1},layerTextureSet:o,renderers:ui(c,u?"instancing":"batching",A,s.saoEnabled,s.pbrEnabled&&S&&o&&o.colorTexture&&T&&w&&o.metallicRoughnessTexture,s.colorTextureEnabled&&S&&o&&o.colorTexture,!!T,(e=>sr(e,u&&{hasModelNormalMat:!!P},c.entityOffsetsEnabled))),drawCalls:function(){const e={},t=t=>(i,r,o)=>{let l=0;Ji.set(s.rotationMatrix,0),Ji.set(o.viewMatrix,l+=16),Ji.set(o.projMatrix,l+=16),Ji.set(a,l+=16),r.needNormal()&&(Ji.set(s.worldNormalMatrix,l+=16),Ji.set(o.viewNormalMatrix,l+=16)),r.matrices.setInputValue(Ji),r.uvDecodeMatrix.setInputValue&&r.uvDecodeMatrix.setInputValue(S.mat),i in e||(e[i]=[null,null,null]);const c=e[i],p=t?t.vertices?0:1:2;if(!c[p]){const e=h.createVertexArray();h.bindVertexArray(e);const s=(e,t)=>{e&&e.setInputValue&&t&&e.setInputValue(t)},i=r.attributes;s(i.position,x),s(i.normal,T),s(i.color,B),s(i.pickColor,v),s(i.uV,S&&S.buf),s(i.metallicRoughness,w),s(i.flags,_),s(i.offset,y),i.modelMatrixCol&&i.modelMatrixCol.forEach(((e,t)=>s(e,U[t]))),i.modelNormalMatrixCol&&i.modelNormalMatrixCol.forEach(((e,t)=>s(e,P[t])));const o=function(){const e=()=>{u?h.drawArraysInstanced(h.POINTS,0,x.numItems,n.length):h.drawArrays(h.POINTS,0,x.numItems)},s=(e,t)=>{t.bindIndicesBuffer();const s=t.indicesCount,i=t.indicesType;return()=>{u?h.drawElementsInstanced(e,s,i,0,n.length):h.drawElements(e,s,i,0)}};return"points"===A?e:"lines"===A?t&&t.vertices?e:s(h.LINES,E):t&&t.vertices?e:t?C?s(h.LINES,C):()=>{}:s(h.TRIANGLES,E)}();h.bindVertexArray(null),d.push((()=>h.deleteVertexArray(e))),c[p]=()=>{h.bindVertexArray(e),o(),h.bindVertexArray(null)}}c[p]()};return{drawVertices:t({vertices:!0}),drawEdges:t({}),drawSurface:t(null)}}(),destroy:()=>{d.forEach((e=>e())),d.length=0}}}}const tr=function(e){const t={toString:()=>(t.needed=!0,e)};return t},sr=function(e,t,s){const i=e.createAttribute,r={position:i("vec3","positionA"),normal:i("vec3","normalA"),color:i("vec4","colorA"),pickColor:i("vec4","pickColor"),uV:i("vec2","uvApremul"),metallicRoughness:i("vec2","metallicRoughness"),flags:i("float","flagsA"),offset:s&&i("vec3","offset"),modelMatrixCol:t&&Yi(3).map((e=>i("vec4","modelMatrixCol"+e))),modelNormalMatrixCol:t&&t.hasModelNormalMat&&Yi(3).map((e=>i("vec4","modelNormalMatrixCol"+e)))},n=tr("aUv"),A=tr("viewNormal"),o=tr("worldNormal"),a=e.createUniform("mat3","uvDecodeMatrix"),l=()=>A.needed||o.needed,c=e.createUniformBlock("Matrices",{worldMatrix:"mat4",viewMatrix:"mat4",projMatrix:"mat4",positionsDecodeMatrix:"mat4",worldNormalMatrix:"mat4",viewNormalMatrix:"mat4"});return{dontCullOnAlphaZero:!0,clippableTest:function(){const t=e.createVarying("float","vClippable",(()=>`((int(${r.flags}) >> 16 & 0xF) == 1) ? 1.0 : 0.0`));return()=>`${t} != 0.0`}(),geometryParameters:{attributes:{color:r.color,flags:Yi(4).map((e=>({toString:()=>`(int(${r.flags}) >> ${4*e} & 0xF)`}))),metallicRoughness:r.metallicRoughness,normal:{view:A,world:o},pickColor:r.pickColor,position:{clip:"gl_Position",view:"viewPosition",world:"worldPosition"},uv:n},projMatrix:c.projMatrix,viewMatrix:c.viewMatrix},appendVertexData:t=>{n.needed&&t.push(`vec2 ${n} = (${a} * vec3(${r.uV}, 1.0)).xy;`);const s=r.modelMatrixCol&&`mat4(${r.modelMatrixCol[0]}, ${r.modelMatrixCol[1]}, ${r.modelMatrixCol[2]}, vec4(0.0,0.0,0.0,1.0))`;if(t.push(`vec4 worldPosition = ${c.worldMatrix} * (${c.positionsDecodeMatrix} * vec4(${r.position}, 1.0)${s?" * "+s:""});`),r.offset&&t.push(`worldPosition.xyz = worldPosition.xyz + ${r.offset};`),l()){const s=r.modelNormalMatrixCol&&`* mat4(${r.modelNormalMatrixCol[0]}, ${r.modelNormalMatrixCol[1]}, ${r.modelNormalMatrixCol[2]}, vec4(0.0,0.0,0.0,1.0))`;t.push(`vec4 modelNormal = vec4(${e.commonLibrary.octDecode}(${r.normal}.xy), 0.0)${s||""};`),t.push(`vec3 ${o} = (${c.worldNormalMatrix} * modelNormal).xyz;`),A.needed&&t.push(`vec3 ${A} = normalize((${c.viewNormalMatrix} * vec4(${o}, 0.0)).xyz);`)}},layerTypeInputs:{attributes:r,matrices:c,uvDecodeMatrix:a,needNormal:l}}};class ir{constructor(e){this.id=e.id,this.colorTexture=e.colorTexture,this.alphaCutoff=e.alphaCutoff,this.metallicRoughnessTexture=e.metallicRoughnessTexture,this.normalsTexture=e.normalsTexture,this.emissiveTexture=e.emissiveTexture,this.occlusionTexture=e.occlusionTexture}destroy(){}}class rr{constructor(e){this.id=e.id,this.texture=e.texture}destroy(){this.texture&&(this.texture.destroy(),this.texture=null)}}const nr={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class Ar{constructor(e,t,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=s}itemStart(e){this.itemsTotal++,!1===this.isLoading&&void 0!==this.onStart&&this.onStart(e,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(e){this.itemsLoaded++,void 0!==this.onProgress&&this.onProgress(e,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,void 0!==this.onLoad&&this.onLoad())}itemError(e){void 0!==this.onError&&this.onError(e)}resolveURL(e){return this.urlModifier?this.urlModifier(e):e}setURLModifier(e){return this.urlModifier=e,this}addHandler(e,t){return this.handlers.push(e,t),this}removeHandler(e){const t=this.handlers.indexOf(e);return-1!==t&&this.handlers.splice(t,2),this}getHandler(e){for(let t=0,s=this.handlers.length;t<s;t+=2){const s=this.handlers[t],i=this.handlers[t+1];if(s.global&&(s.lastIndex=0),s.test(e))return i}return null}}const or=new Ar;class ar{constructor(e){this.manager=void 0!==e?e:or,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const s=this;return new Promise((function(i,r){s.load(e,i,t,r)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const lr={};class cr extends ar{constructor(e){super(e)}load(e,t,s,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=nr.get(e);if(void 0!==r)return this.manager.itemStart(e),q.scheduleTask((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==lr[e])return void lr[e].push({onLoad:t,onProgress:s,onError:i});lr[e]=[],lr[e].push({onLoad:t,onProgress:s,onError:i});const n=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),A=this.mimeType,o=this.responseType;fetch(n).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body.getReader)return t;const s=lr[e],i=t.body.getReader(),r=t.headers.get("Content-Length"),n=r?parseInt(r):0,A=0!==n;let o=0;const a=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:A,loaded:o,total:n});for(let e=0,t=s.length;e<t;e++){const t=s[e];t.onProgress&&t.onProgress(i)}e.enqueue(r),t()}}))}()}});return new Response(a)}throw Error(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`)})).then((e=>{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,A)));case"json":return e.json();default:if(void 0===A)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(A),s=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(s);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{nr.add(e,t);const s=lr[e];delete lr[e];for(let e=0,i=s.length;e<i;e++){const i=s[e];i.onLoad&&i.onLoad(t)}})).catch((t=>{const s=lr[e];if(void 0===s)throw this.manager.itemError(e),t;delete lr[e];for(let e=0,i=s.length;e<i;e++){const i=s[e];i.onError&&i.onError(t)}this.manager.itemError(e)})).finally((()=>{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class hr{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const s=this.workersResolve[e];if(s&&s(t),this.queue.length){const{resolve:t,msg:s,transfer:i}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(s,i)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((s=>{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=s,this.workers[i].postMessage(e,t)):this.queue.push({resolve:s,msg:e,transfer:t})}))}destroy(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}let ur=0;class dr{constructor({viewer:e,transcoderPath:t,workerLimit:s}){this._transcoderPath=t||"https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/basis/",this._transcoderBinary=null,this._transcoderPending=null,this._workerPool=new hr,this._workerSourceURL="",s&&this._workerPool.setWorkerLimit(s);const i=e.capabilities;this._workerConfig={astcSupported:i.astcSupported,etc1Supported:i.etc1Supported,etc2Supported:i.etc2Supported,dxtSupported:i.dxtSupported,bptcSupported:i.bptcSupported,pvrtcSupported:i.pvrtcSupported},this._supportedFileTypes=["xkt2"]}_init(){if(!this._transcoderPending){const e=new cr;e.setPath(this._transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),s=new cr;s.setPath(this._transcoderPath),s.setResponseType("arraybuffer"),s.setWithCredentials(this.withCredentials);const i=s.loadAsync("basis_transcoder.wasm");this._transcoderPending=Promise.all([t,i]).then((([e,t])=>{const s=dr.BasisWorker.toString(),i=["/* constants */","let _EngineFormat = "+JSON.stringify(dr.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(dr.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(dr.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n");this._workerSourceURL=URL.createObjectURL(new Blob([i])),this._transcoderBinary=t,this._workerPool.setWorkerCreator((()=>{const e=new Worker(this._workerSourceURL),t=this._transcoderBinary.slice(0);return e.postMessage({type:"init",config:this._workerConfig,transcoderBinary:t},[t]),e}))})),ur>0&&console.warn("KTX2TextureTranscoder: Multiple active KTX2TextureTranscoder may cause performance issues. Use a single KTX2TextureTranscoder instance, or call .dispose() on old instances."),ur++}return this._transcoderPending}transcode(e,t,s={}){return new Promise(((i,r)=>{const n=s;this._init().then((()=>this._workerPool.postMessage({type:"transcode",buffers:e,taskConfig:n},e))).then((e=>{const s=e.data,{mipmaps:n,width:A,height:o,format:a,type:l,error:c,dfdTransferFn:h,dfdFlags:u}=s;if("error"===l)return r(c);t.setCompressedData({mipmaps:n,props:{format:a,minFilter:1===n.length?1006:1008,magFilter:1===n.length?1006:1008,encoding:2===h?3001:3e3,premultiplyAlpha:!!(1&u)}}),i()}))}))}destroy(){URL.revokeObjectURL(this._workerSourceURL),this._workerPool.destroy(),ur--}}dr.BasisFormat={ETC1S:0,UASTC_4x4:1},dr.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},dr.EngineFormat={RGBAFormat:1023,RGBA_ASTC_4x4_Format:37808,RGBA_BPTC_Format:36492,RGBA_ETC2_EAC_Format:37496,RGBA_PVRTC_4BPPV1_Format:35842,RGBA_S3TC_DXT5_Format:33779,RGB_ETC1_Format:36196,RGB_ETC2_Format:37492,RGB_PVRTC_4BPPV1_Format:35840,RGB_S3TC_DXT1_Format:33776},dr.BasisWorker=function(){let e,t,s;const i=_EngineFormat,r=_TranscoderFormat,n=_BasisFormat;self.addEventListener("message",(function(A){const c=A.data;switch(c.type){case"init":e=c.config,h=c.transcoderBinary,t=new Promise((e=>{s={wasmBinary:h,onRuntimeInitialized:e},BASIS(s)})).then((()=>{s.initializeBasis(),void 0===s.KTX2File&&console.warn("KTX2TextureTranscoder: Please update Basis Universal transcoder.")}));break;case"transcode":t.then((()=>{try{const{width:t,height:A,hasAlpha:h,mipmaps:u,format:d,dfdTransferFn:p,dfdFlags:f}=function(t){const A=new s.KTX2File(new Uint8Array(t));function c(){A.close(),A.delete()}if(!A.isValid())throw c(),new Error("KTX2TextureTranscoder: Invalid or unsupported .ktx2 file");const h=A.isUASTC()?n.UASTC_4x4:n.ETC1S,u=A.getWidth(),d=A.getHeight(),p=A.getLevels(),f=A.getHasAlpha(),g=A.getDFDTransferFunc(),m=A.getDFDFlags(),{transcoderFormat:_,engineFormat:b}=function(t,s,A,c){let h,u;const d=t===n.ETC1S?o:a;for(let i=0;i<d.length;i++){const r=d[i];if(e[r.if]&&(r.basisFormat.includes(t)&&!(c&&r.transcoderFormat.length<2)&&(!r.needsPowerOfTwo||l(s)&&l(A))))return h=r.transcoderFormat[c?1:0],u=r.engineFormat[c?1:0],{transcoderFormat:h,engineFormat:u}}return console.warn("KTX2TextureTranscoder: No suitable compressed texture format found. Decoding to RGBA32."),h=r.RGBA32,u=i.RGBAFormat,{transcoderFormat:h,engineFormat:u}}(h,u,d,f);if(!u||!d||!p)throw c(),new Error("KTX2TextureTranscoder: Invalid texture");if(!A.startTranscoding())throw c(),new Error("KTX2TextureTranscoder: .startTranscoding failed");const B=[];for(let e=0;e<p;e++){const t=A.getImageLevelInfo(e,0,0),s=t.origWidth,i=t.origHeight,r=new Uint8Array(A.getImageTranscodedSizeInBytes(e,0,0,_));if(!A.transcodeImage(r,e,0,0,_,0,-1,-1))throw c(),new Error("KTX2TextureTranscoder: .transcodeImage failed.");B.push({data:r,width:s,height:i})}return c(),{width:u,height:d,hasAlpha:f,mipmaps:B,format:b,dfdTransferFn:g,dfdFlags:m}}(c.buffers[0]),g=[];for(let e=0;e<u.length;++e)g.push(u[e].data.buffer);self.postMessage({type:"transcode",id:c.id,width:t,height:A,hasAlpha:h,mipmaps:u,format:d,dfdTransferFn:p,dfdFlags:f},g)}catch(e){console.error(`[KTX2TextureTranscoder.BasisWorker]: ${e}`),self.postMessage({type:"error",id:c.id,error:e.message})}}))}var h}));const A=[{if:"astcSupported",basisFormat:[n.UASTC_4x4],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.BC1,r.BC3],engineFormat:[i.RGB_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.ETC1],engineFormat:[i.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],o=A.sort((function(e,t){return e.priorityETC1S-t.priorityETC1S})),a=A.sort((function(e,t){return e.priorityUASTC-t.priorityUASTC}));function l(e){return e<=2||0==(e&e-1)&&0!==e}};const pr={};function fr(e){const t=e.scene.id;let s=pr[t];return s||(s=new dr({viewer:e}),pr[t]=s,e.scene.on("destroyed",(()=>{delete pr[t],s.destroy()}))),s}
|
|
7
|
+
"undefined"!=typeof window&&(window.__XEOKIT__={version:"2.6.99",commit:"916f60d2984c01eda311e05589b978ba8b5ad37c",built:"2025-12-09T13:35:43.419Z"}),Object.defineProperty(exports,"__esModule",{value:!0});class e{constructor(e,t){this.items=e||[],this._lastUniqueId=(t||0)+1}addItem(){let e;if(2===arguments.length){const t=arguments[0];if(e=arguments[1],this.items[t])throw"ID clash: '"+t+"'";return this.items[t]=e,t}for(e=arguments[0]||{};;){const t=this._lastUniqueId++;if(!this.items[t])return this.items[t]=e,t}}removeItem(e){const t=this.items[e];return delete this.items[e],t}}const t=new e;class s{constructor(e){this.id=e,this.parentItem=null,this.groups=[],this.menuElement=null,this.shown=!1,this.mouseOver=0}}class i{constructor(){this.items=[]}}class r{constructor(e,t,s,i,r){this.id=e,this.getTitle=t,this.doAction=s,this.getEnabled=i,this.getShown=r,this.itemElement=null,this.subMenu=null,this.enabled=!0}}function n(e,t,s=2){const i=t&&t.length,r=i?t[0]*s:e.length;let n=A(e,0,r,s,!0);const o=[];if(!n||n.next===n.prev)return o;let l,c,h;if(i&&(n=function(e,t,s,i){const r=[];for(let s=0,n=t.length;s<n;s++){const o=A(e,t[s]*i,s<n-1?t[s+1]*i:e.length,i,!1);o===o.next&&(o.steiner=!0),r.push(m(o))}r.sort(d);for(let e=0;e<r.length;e++)s=p(r[e],s);return s}(e,t,n,s)),e.length>80*s){l=1/0,c=1/0;let t=-1/0,i=-1/0;for(let n=s;n<r;n+=s){const s=e[n],r=e[n+1];s<l&&(l=s),r<c&&(c=r),s>t&&(t=s),r>i&&(i=r)}h=Math.max(t-l,i-c),h=0!==h?32767/h:0}return a(n,o,s,l,c,h,0),o}function A(e,t,s,i,r){let n;if(r===function(e,t,s,i){let r=0;for(let n=t,A=s-i;n<s;n+=i)r+=(e[A]-e[n])*(e[n+1]+e[A+1]),A=n;return r}(e,t,s,i)>0)for(let r=t;r<s;r+=i)n=x(r/i|0,e[r],e[r+1],n);else for(let r=s-i;r>=t;r-=i)n=x(r/i|0,e[r],e[r+1],n);return n&&w(n,n.next)&&(U(n),n=n.next),n}function o(e,t){if(!e)return e;t||(t=e);let s,i=e;do{if(s=!1,i.steiner||!w(i,i.next)&&0!==y(i.prev,i,i.next))i=i.next;else{if(U(i),i=t=i.prev,i===i.next)break;s=!0}}while(s||i!==t);return t}function a(e,t,s,i,r,n,A){if(!e)return;!A&&n&&function(e,t,s,i){let r=e;do{0===r.z&&(r.z=g(r.x,r.y,t,s,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,s=1;do{let i,r=e;e=null;let n=null;for(t=0;r;){t++;let A=r,o=0;for(let e=0;e<s&&(o++,A=A.nextZ,A);e++);let a=s;for(;o>0||a>0&&A;)0!==o&&(0===a||!A||r.z<=A.z)?(i=r,r=r.nextZ,o--):(i=A,A=A.nextZ,a--),n?n.nextZ=i:e=i,i.prevZ=n,n=i;r=A}n.nextZ=null,s*=2}while(t>1)}(r)}(e,i,r,n);let d=e;for(;e.prev!==e.next;){const p=e.prev,f=e.next;if(n?c(e,i,r,n):l(e))t.push(p.i,e.i,f.i),U(e),e=f.next,d=f.next;else if((e=f)===d){A?1===A?a(e=h(o(e),t),t,s,i,r,n,2):2===A&&u(e,t,s,i,r,n):a(o(e),t,s,i,r,n,1);break}}}function l(e){const t=e.prev,s=e,i=e.next;if(y(t,s,i)>=0)return!1;const r=t.x,n=s.x,A=i.x,o=t.y,a=s.y,l=i.y,c=Math.min(r,n,A),h=Math.min(o,a,l),u=Math.max(r,n,A),d=Math.max(o,a,l);let p=i.next;for(;p!==t;){if(p.x>=c&&p.x<=u&&p.y>=h&&p.y<=d&&b(r,o,n,a,A,l,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function c(e,t,s,i){const r=e.prev,n=e,A=e.next;if(y(r,n,A)>=0)return!1;const o=r.x,a=n.x,l=A.x,c=r.y,h=n.y,u=A.y,d=Math.min(o,a,l),p=Math.min(c,h,u),f=Math.max(o,a,l),m=Math.max(c,h,u),_=g(d,p,t,s,i),B=g(f,m,t,s,i);let w=e.prevZ,v=e.nextZ;for(;w&&w.z>=_&&v&&v.z<=B;){if(w.x>=d&&w.x<=f&&w.y>=p&&w.y<=m&&w!==r&&w!==A&&b(o,c,a,h,l,u,w.x,w.y)&&y(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,v.x>=d&&v.x<=f&&v.y>=p&&v.y<=m&&v!==r&&v!==A&&b(o,c,a,h,l,u,v.x,v.y)&&y(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;w&&w.z>=_;){if(w.x>=d&&w.x<=f&&w.y>=p&&w.y<=m&&w!==r&&w!==A&&b(o,c,a,h,l,u,w.x,w.y)&&y(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;v&&v.z<=B;){if(v.x>=d&&v.x<=f&&v.y>=p&&v.y<=m&&v!==r&&v!==A&&b(o,c,a,h,l,u,v.x,v.y)&&y(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function h(e,t){let s=e;do{const i=s.prev,r=s.next.next;!w(i,r)&&v(i,s,s.next,r)&&E(i,r)&&E(r,i)&&(t.push(i.i,s.i,r.i),U(s),U(s.next),s=e=r),s=s.next}while(s!==e);return o(s)}function u(e,t,s,i,r,n){let A=e;do{let e=A.next.next;for(;e!==A.prev;){if(A.i!==e.i&&B(A,e)){let l=F(A,e);return A=o(A,A.next),l=o(l,l.next),a(A,t,s,i,r,n,0),void a(l,t,s,i,r,n,0)}e=e.next}A=A.next}while(A!==e)}function d(e,t){let s=e.x-t.x;if(0===s&&(s=e.y-t.y,0===s)){s=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return s}function p(e,t){const s=function(e,t){let s=t;const i=e.x,r=e.y;let n,A=-1/0;if(w(e,s))return s;do{if(w(e,s.next))return s.next;if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){const e=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(e<=i&&e>A&&(A=e,n=s.x<s.next.x?s:s.next,e===i))return n}s=s.next}while(s!==t);if(!n)return null;const o=n,a=n.x,l=n.y;let c=1/0;s=n;do{if(i>=s.x&&s.x>=a&&i!==s.x&&_(r<l?i:A,r,a,l,r<l?A:i,r,s.x,s.y)){const t=Math.abs(r-s.y)/(i-s.x);E(s,e)&&(t<c||t===c&&(s.x>n.x||s.x===n.x&&f(n,s)))&&(n=s,c=t)}s=s.next}while(s!==o);return n}(e,t);if(!s)return t;const i=F(s,e);return o(i,i.next),o(s,s.next)}function f(e,t){return y(e.prev,e,t.prev)<0&&y(t.next,e,e.next)<0}function g(e,t,s,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function m(e){let t=e,s=e;do{(t.x<s.x||t.x===s.x&&t.y<s.y)&&(s=t),t=t.next}while(t!==e);return s}function _(e,t,s,i,r,n,A,o){return(r-A)*(t-o)>=(e-A)*(n-o)&&(e-A)*(i-o)>=(s-A)*(t-o)&&(s-A)*(n-o)>=(r-A)*(i-o)}function b(e,t,s,i,r,n,A,o){return!(e===A&&t===o)&&_(e,t,s,i,r,n,A,o)}function B(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let s=e;do{if(s.i!==e.i&&s.next.i!==e.i&&s.i!==t.i&&s.next.i!==t.i&&v(s,s.next,e,t))return!0;s=s.next}while(s!==e);return!1}(e,t)&&(E(e,t)&&E(t,e)&&function(e,t){let s=e,i=!1;const r=(e.x+t.x)/2,n=(e.y+t.y)/2;do{s.y>n!=s.next.y>n&&s.next.y!==s.y&&r<(s.next.x-s.x)*(n-s.y)/(s.next.y-s.y)+s.x&&(i=!i),s=s.next}while(s!==e);return i}(e,t)&&(y(e.prev,e,t.prev)||y(e,t.prev,t))||w(e,t)&&y(e.prev,e,e.next)>0&&y(t.prev,t,t.next)>0)}function y(e,t,s){return(t.y-e.y)*(s.x-t.x)-(t.x-e.x)*(s.y-t.y)}function w(e,t){return e.x===t.x&&e.y===t.y}function v(e,t,s,i){const r=M(y(e,t,s)),n=M(y(e,t,i)),A=M(y(s,i,e)),o=M(y(s,i,t));return r!==n&&A!==o||(!(0!==r||!C(e,s,t))||(!(0!==n||!C(e,i,t))||(!(0!==A||!C(s,e,i))||!(0!==o||!C(s,t,i)))))}function C(e,t,s){return t.x<=Math.max(e.x,s.x)&&t.x>=Math.min(e.x,s.x)&&t.y<=Math.max(e.y,s.y)&&t.y>=Math.min(e.y,s.y)}function M(e){return e>0?1:e<0?-1:0}function E(e,t){return y(e.prev,e,e.next)<0?y(e,t,e.next)>=0&&y(e,e.prev,t)>=0:y(e,t,e.prev)<0||y(e,e.next,t)<0}function F(e,t){const s=I(e.i,e.x,e.y),i=I(t.i,t.x,t.y),r=e.next,n=t.prev;return e.next=t,t.prev=e,s.next=r,r.prev=s,i.next=s,s.prev=i,n.next=i,i.prev=n,i}function x(e,t,s,i){const r=I(e,t,s);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function U(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function I(e,t,s){return{i:e,x:t,y:s,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}let T=!0,P=T?Float64Array:Float32Array;const S=new P(3),D=new P(16),k=new P(16),Q=new P(4),R={setDoublePrecisionEnabled(e){T=e,P=T?Float64Array:Float32Array},getDoublePrecisionEnabled:()=>T,MIN_DOUBLE:-Number.MAX_SAFE_INTEGER,MAX_DOUBLE:Number.MAX_SAFE_INTEGER,MAX_INT:1e7,DEGTORAD:.0174532925,RADTODEG:57.295779513,unglobalizeObjectId(e,t){const s=t.indexOf("#");return s===e.length&&t.startsWith(e)?t.substring(s+1):t},globalizeObjectId:(e,t)=>e+"#"+t,safeInv(e){const t=1/e;return isNaN(t)||!isFinite(t)?1:t},vec2:e=>new P(e||2),vec3:e=>new P(e||3),vec4:e=>new P(e||4),mat3:e=>new P(e||9),mat3ToMat4:(e,t=new P(16))=>(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=0,t[4]=e[3],t[5]=e[4],t[6]=e[5],t[7]=0,t[8]=e[6],t[9]=e[7],t[10]=e[8],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t),mat4:e=>new P(e||16),mat4ToMat3:(e,t=new P(9))=>(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t),doublesToFloats(e,t,s){const i=new P(2);for(let r=0,n=e.length;r<n;r++)R.splitDouble(e[r],i),t[r]=i[0],s[r]=i[1]},splitDouble(e,t){const s=P.from([e])[0],i=e-s;t[0]=s,t[1]=i},createUUID:(()=>{const e=[];for(let t=0;t<256;t++)e[t]=(t<16?"0":"")+t.toString(16);return()=>{const t=4294967295*Math.random()|0,s=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return`${e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]}-${e[255&s]}${e[s>>8&255]}-${e[s>>16&15|64]}${e[s>>24&255]}-${e[63&i|128]}${e[i>>8&255]}-${e[i>>16&255]}${e[i>>24&255]}${e[255&r]}${e[r>>8&255]}${e[r>>16&255]}${e[r>>24&255]}`}})(),clamp:(e,t,s)=>Math.max(t,Math.min(s,e)),fmod(e,t){if(e<t)return console.error("math.fmod : Attempting to find modulus within negative range - would be infinite loop - ignoring"),e;for(;t<=e;)e-=t;return e},compareVec3:(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2],compareVec4:(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3],negateVec3:(e,t)=>(t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t),negateVec4:(e,t)=>(t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t),addVec4:(e,t,s)=>(s||(s=e),s[0]=e[0]+t[0],s[1]=e[1]+t[1],s[2]=e[2]+t[2],s[3]=e[3]+t[3],s),addVec4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]+t,s[1]=e[1]+t,s[2]=e[2]+t,s[3]=e[3]+t,s),addVec3:(e,t,s)=>(s||(s=e),s[0]=e[0]+t[0],s[1]=e[1]+t[1],s[2]=e[2]+t[2],s),addVec3Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]+t,s[1]=e[1]+t,s[2]=e[2]+t,s),subVec4:(e,t,s)=>(s||(s=e),s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],s[3]=e[3]-t[3],s),subVec3:(e,t,s)=>(s||(s=e),s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],s),subVec2:(e,t,s)=>(s||(s=e),s[0]=e[0]-t[0],s[1]=e[1]-t[1],s),geometricMeanVec2(...e){const t=new P(e[0]);for(let s=1;s<e.length;s++)t[0]+=e[s][0],t[1]+=e[s][1];return t[0]/=e.length,t[1]/=e.length,t},subVec4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]-t,s[1]=e[1]-t,s[2]=e[2]-t,s[3]=e[3]-t,s),subScalarVec4:(e,t,s)=>(s||(s=e),s[0]=t-e[0],s[1]=t-e[1],s[2]=t-e[2],s[3]=t-e[3],s),mulVec4:(e,t,s)=>(s||(s=e),s[0]=e[0]*t[0],s[1]=e[1]*t[1],s[2]=e[2]*t[2],s[3]=e[3]*t[3],s),mulVec4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]*t,s[1]=e[1]*t,s[2]=e[2]*t,s[3]=e[3]*t,s),mulVec3Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]*t,s[1]=e[1]*t,s[2]=e[2]*t,s),mulVec2Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]*t,s[1]=e[1]*t,s),divVec3:(e,t,s)=>(s||(s=e),s[0]=e[0]/t[0],s[1]=e[1]/t[1],s[2]=e[2]/t[2],s),divVec4:(e,t,s)=>(s||(s=e),s[0]=e[0]/t[0],s[1]=e[1]/t[1],s[2]=e[2]/t[2],s[3]=e[3]/t[3],s),divScalarVec3:(e,t,s)=>(s||(s=t),s[0]=e/t[0],s[1]=e/t[1],s[2]=e/t[2],s),divVec3Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]/t,s[1]=e[1]/t,s[2]=e[2]/t,s),divVec4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]/t,s[1]=e[1]/t,s[2]=e[2]/t,s[3]=e[3]/t,s),divScalarVec4:(e,t,s)=>(s||(s=t),s[0]=e/t[0],s[1]=e/t[1],s[2]=e/t[2],s[3]=e/t[3],s),dotVec4:(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],cross3Vec4(e,t){const s=e[0],i=e[1],r=e[2],n=t[0],A=t[1],o=t[2];return[i*o-r*A,r*n-s*o,s*A-i*n,0]},cross3Vec3(e,t,s){s||(s=e);const i=e[0],r=e[1],n=e[2],A=t[0],o=t[1],a=t[2];return s[0]=r*a-n*o,s[1]=n*A-i*a,s[2]=i*o-r*A,s},sqLenVec4:e=>R.dotVec4(e,e),lenVec4:e=>Math.sqrt(R.sqLenVec4(e)),dotVec3:(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],dotVec2:(e,t)=>e[0]*t[0]+e[1]*t[1],sqLenVec3:e=>R.dotVec3(e,e),sqLenVec2:e=>R.dotVec2(e,e),lenVec3:e=>Math.sqrt(R.sqLenVec3(e)),distVec3:(()=>{const e=new P(3);return(t,s)=>R.lenVec3(R.subVec3(t,s,e))})(),lenVec2:e=>Math.sqrt(R.sqLenVec2(e)),distVec2:(()=>{const e=new P(2);return(t,s)=>R.lenVec2(R.subVec2(t,s,e))})(),rcpVec3:(e,t)=>R.divScalarVec3(1,e,t),normalizeVec4(e,t){const s=1/R.lenVec4(e);return R.mulVec4Scalar(e,s,t)},normalizeVec3(e,t){const s=1/R.lenVec3(e);return R.mulVec3Scalar(e,s,t)},normalizeVec2(e,t){const s=1/R.lenVec2(e);return R.mulVec2Scalar(e,s,t)},angleVec3(e,t){let s=R.dotVec3(e,t)/Math.sqrt(R.sqLenVec3(e)*R.sqLenVec3(t));return s=s<-1?-1:s>1?1:s,Math.acos(s)},vec3FromMat4Scale:(()=>{const e=new P(3);return(t,s)=>(e[0]=t[0],e[1]=t[1],e[2]=t[2],s[0]=R.lenVec3(e),e[0]=t[4],e[1]=t[5],e[2]=t[6],s[1]=R.lenVec3(e),e[0]=t[8],e[1]=t[9],e[2]=t[10],s[2]=R.lenVec3(e),s)})(),vecToArray:(()=>{function e(e){return Math.round(1e5*e)/1e5}return t=>{for(let s=0,i=(t=Array.prototype.slice.call(t)).length;s<i;s++)t[s]=e(t[s]);return t}})(),xyzArrayToObject:e=>({x:e[0],y:e[1],z:e[2]}),xyzObjectToArray:(e,t)=>((t=t||R.vec3())[0]=e.x,t[1]=e.y,t[2]=e.z,t),dupMat4:e=>e.slice(0,16),mat4To3:e=>[e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]],m4s:e=>[e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e],setMat4ToZeroes:()=>R.m4s(0),setMat4ToOnes:()=>R.m4s(1),diagonalMat4v:e=>new P([e[0],0,0,0,0,e[1],0,0,0,0,e[2],0,0,0,0,e[3]]),diagonalMat4c:(e,t,s,i)=>R.diagonalMat4v([e,t,s,i]),diagonalMat4s:e=>R.diagonalMat4c(e,e,e,e),identityMat4:(e=new P(16))=>(e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e),identityMat3:(e=new P(9))=>(e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e),isIdentityMat4:e=>1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15],negateMat4:(e,t)=>(t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t[4]=-e[4],t[5]=-e[5],t[6]=-e[6],t[7]=-e[7],t[8]=-e[8],t[9]=-e[9],t[10]=-e[10],t[11]=-e[11],t[12]=-e[12],t[13]=-e[13],t[14]=-e[14],t[15]=-e[15],t),addMat4:(e,t,s)=>(s||(s=e),s[0]=e[0]+t[0],s[1]=e[1]+t[1],s[2]=e[2]+t[2],s[3]=e[3]+t[3],s[4]=e[4]+t[4],s[5]=e[5]+t[5],s[6]=e[6]+t[6],s[7]=e[7]+t[7],s[8]=e[8]+t[8],s[9]=e[9]+t[9],s[10]=e[10]+t[10],s[11]=e[11]+t[11],s[12]=e[12]+t[12],s[13]=e[13]+t[13],s[14]=e[14]+t[14],s[15]=e[15]+t[15],s),addMat4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]+t,s[1]=e[1]+t,s[2]=e[2]+t,s[3]=e[3]+t,s[4]=e[4]+t,s[5]=e[5]+t,s[6]=e[6]+t,s[7]=e[7]+t,s[8]=e[8]+t,s[9]=e[9]+t,s[10]=e[10]+t,s[11]=e[11]+t,s[12]=e[12]+t,s[13]=e[13]+t,s[14]=e[14]+t,s[15]=e[15]+t,s),addScalarMat4:(e,t,s)=>R.addMat4Scalar(t,e,s),subMat4:(e,t,s)=>(s||(s=e),s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],s[3]=e[3]-t[3],s[4]=e[4]-t[4],s[5]=e[5]-t[5],s[6]=e[6]-t[6],s[7]=e[7]-t[7],s[8]=e[8]-t[8],s[9]=e[9]-t[9],s[10]=e[10]-t[10],s[11]=e[11]-t[11],s[12]=e[12]-t[12],s[13]=e[13]-t[13],s[14]=e[14]-t[14],s[15]=e[15]-t[15],s),subMat4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]-t,s[1]=e[1]-t,s[2]=e[2]-t,s[3]=e[3]-t,s[4]=e[4]-t,s[5]=e[5]-t,s[6]=e[6]-t,s[7]=e[7]-t,s[8]=e[8]-t,s[9]=e[9]-t,s[10]=e[10]-t,s[11]=e[11]-t,s[12]=e[12]-t,s[13]=e[13]-t,s[14]=e[14]-t,s[15]=e[15]-t,s),subScalarMat4:(e,t,s)=>(s||(s=t),s[0]=e-t[0],s[1]=e-t[1],s[2]=e-t[2],s[3]=e-t[3],s[4]=e-t[4],s[5]=e-t[5],s[6]=e-t[6],s[7]=e-t[7],s[8]=e-t[8],s[9]=e-t[9],s[10]=e-t[10],s[11]=e-t[11],s[12]=e-t[12],s[13]=e-t[13],s[14]=e-t[14],s[15]=e-t[15],s),mulMat4(e,t,s){s||(s=e);const i=e[0],r=e[1],n=e[2],A=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],p=e[11],f=e[12],g=e[13],m=e[14],_=e[15],b=t[0],B=t[1],y=t[2],w=t[3],v=t[4],C=t[5],M=t[6],E=t[7],F=t[8],x=t[9],U=t[10],I=t[11],T=t[12],P=t[13],S=t[14],D=t[15];return s[0]=b*i+B*o+y*h+w*f,s[1]=b*r+B*a+y*u+w*g,s[2]=b*n+B*l+y*d+w*m,s[3]=b*A+B*c+y*p+w*_,s[4]=v*i+C*o+M*h+E*f,s[5]=v*r+C*a+M*u+E*g,s[6]=v*n+C*l+M*d+E*m,s[7]=v*A+C*c+M*p+E*_,s[8]=F*i+x*o+U*h+I*f,s[9]=F*r+x*a+U*u+I*g,s[10]=F*n+x*l+U*d+I*m,s[11]=F*A+x*c+U*p+I*_,s[12]=T*i+P*o+S*h+D*f,s[13]=T*r+P*a+S*u+D*g,s[14]=T*n+P*l+S*d+D*m,s[15]=T*A+P*c+S*p+D*_,s},mulMat3(e,t,s){s||(s=new P(9));const i=e[0],r=e[3],n=e[6],A=e[1],o=e[4],a=e[7],l=e[2],c=e[5],h=e[8],u=t[0],d=t[3],p=t[6],f=t[1],g=t[4],m=t[7],_=t[2],b=t[5],B=t[8];return s[0]=i*u+r*f+n*_,s[3]=i*d+r*g+n*b,s[6]=i*p+r*m+n*B,s[1]=A*u+o*f+a*_,s[4]=A*d+o*g+a*b,s[7]=A*p+o*m+a*B,s[2]=l*u+c*f+h*_,s[5]=l*d+c*g+h*b,s[8]=l*p+c*m+h*B,s},mulMat4Scalar:(e,t,s)=>(s||(s=e),s[0]=e[0]*t,s[1]=e[1]*t,s[2]=e[2]*t,s[3]=e[3]*t,s[4]=e[4]*t,s[5]=e[5]*t,s[6]=e[6]*t,s[7]=e[7]*t,s[8]=e[8]*t,s[9]=e[9]*t,s[10]=e[10]*t,s[11]=e[11]*t,s[12]=e[12]*t,s[13]=e[13]*t,s[14]=e[14]*t,s[15]=e[15]*t,s),mulMat4v4(e,t,s=R.vec4()){const i=t[0],r=t[1],n=t[2],A=t[3];return s[0]=e[0]*i+e[4]*r+e[8]*n+e[12]*A,s[1]=e[1]*i+e[5]*r+e[9]*n+e[13]*A,s[2]=e[2]*i+e[6]*r+e[10]*n+e[14]*A,s[3]=e[3]*i+e[7]*r+e[11]*n+e[15]*A,s},transposeMat4(e,t){const s=e[4],i=e[14],r=e[8],n=e[13],A=e[12],o=e[9];if(!t||e===t){const t=e[1],a=e[2],l=e[3],c=e[6],h=e[7],u=e[11];return e[1]=s,e[2]=r,e[3]=A,e[4]=t,e[6]=o,e[7]=n,e[8]=a,e[9]=c,e[11]=i,e[12]=l,e[13]=h,e[14]=u,e}return t[0]=e[0],t[1]=s,t[2]=r,t[3]=A,t[4]=e[1],t[5]=e[5],t[6]=o,t[7]=n,t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=i,t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15],t},transposeMat3(e,t){if(t===e){const s=e[1],i=e[2],r=e[5];t[1]=e[3],t[2]=e[6],t[3]=s,t[5]=e[7],t[6]=i,t[7]=r}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},determinantMat4(e){const t=e[0],s=e[1],i=e[2],r=e[3],n=e[4],A=e[5],o=e[6],a=e[7],l=e[8],c=e[9],h=e[10],u=e[11],d=e[12],p=e[13],f=e[14],g=e[15];return d*c*o*r-l*p*o*r-d*A*h*r+n*p*h*r+l*A*f*r-n*c*f*r-d*c*i*a+l*p*i*a+d*s*h*a-t*p*h*a-l*s*f*a+t*c*f*a+d*A*i*u-n*p*i*u-d*s*o*u+t*p*o*u+n*s*f*u-t*A*f*u-l*A*i*g+n*c*i*g+l*s*o*g-t*c*o*g-n*s*h*g+t*A*h*g},inverseMat4(e,t){t||(t=e);const s=e[0],i=e[1],r=e[2],n=e[3],A=e[4],o=e[5],a=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11],p=e[12],f=e[13],g=e[14],m=e[15],_=s*o-i*A,b=s*a-r*A,B=s*l-n*A,y=i*a-r*o,w=i*l-n*o,v=r*l-n*a,C=c*f-h*p,M=c*g-u*p,E=c*m-d*p,F=h*g-u*f,x=h*m-d*f,U=u*m-d*g,I=1/(_*U-b*x+B*F+y*E-w*M+v*C);return t[0]=(o*U-a*x+l*F)*I,t[1]=(-i*U+r*x-n*F)*I,t[2]=(f*v-g*w+m*y)*I,t[3]=(-h*v+u*w-d*y)*I,t[4]=(-A*U+a*E-l*M)*I,t[5]=(s*U-r*E+n*M)*I,t[6]=(-p*v+g*B-m*b)*I,t[7]=(c*v-u*B+d*b)*I,t[8]=(A*x-o*E+l*C)*I,t[9]=(-s*x+i*E-n*C)*I,t[10]=(p*w-f*B+m*_)*I,t[11]=(-c*w+h*B-d*_)*I,t[12]=(-A*F+o*M-a*C)*I,t[13]=(s*F-i*M+r*C)*I,t[14]=(-p*y+f*b-g*_)*I,t[15]=(c*y-h*b+u*_)*I,t},traceMat4:e=>e[0]+e[5]+e[10]+e[15],translationMat4v(e,t){const s=t||R.identityMat4();return s[12]=e[0],s[13]=e[1],s[14]=e[2],s},translationMat3v(e,t){const s=t||R.identityMat3();return s[6]=e[0],s[7]=e[1],s},translationMat4c:(()=>{const e=new P(3);return(t,s,i,r)=>(e[0]=t,e[1]=s,e[2]=i,R.translationMat4v(e,r))})(),translationMat4s:(e,t)=>R.translationMat4c(e,e,e,t),translateMat4v:(e,t)=>R.translateMat4c(e[0],e[1],e[2],t),translateMat4c(e,t,s,i){const r=i[3];i[0]+=r*e,i[1]+=r*t,i[2]+=r*s;const n=i[7];i[4]+=n*e,i[5]+=n*t,i[6]+=n*s;const A=i[11];i[8]+=A*e,i[9]+=A*t,i[10]+=A*s;const o=i[15];return i[12]+=o*e,i[13]+=o*t,i[14]+=o*s,i},setMat4Translation:(e,t,s)=>(s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s[6]=e[6],s[7]=e[7],s[8]=e[8],s[9]=e[9],s[10]=e[10],s[11]=e[11],s[12]=t[0],s[13]=t[1],s[14]=t[2],s[15]=e[15],s),rotationMat4v(e,t,s){const i=R.normalizeVec4([t[0],t[1],t[2],0],[]),r=Math.sin(e),n=Math.cos(e),A=1-n,o=i[0],a=i[1],l=i[2];let c,h,u,d,p,f;return c=o*a,h=a*l,u=l*o,d=o*r,p=a*r,f=l*r,(s=s||R.mat4())[0]=A*o*o+n,s[1]=A*c+f,s[2]=A*u-p,s[3]=0,s[4]=A*c-f,s[5]=A*a*a+n,s[6]=A*h+d,s[7]=0,s[8]=A*u+p,s[9]=A*h-d,s[10]=A*l*l+n,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s},rotationMat4c:(e,t,s,i,r)=>R.rotationMat4v(e,[t,s,i],r),scalingMat4v:(e,t=R.identityMat4())=>(t[0]=e[0],t[5]=e[1],t[10]=e[2],t),scalingMat3v:(e,t=R.identityMat3())=>(t[0]=e[0],t[4]=e[1],t),scalingMat4c:(()=>{const e=new P(3);return(t,s,i,r)=>(e[0]=t,e[1]=s,e[2]=i,R.scalingMat4v(e,r))})(),scaleMat4c:(e,t,s,i)=>(i[0]*=e,i[4]*=t,i[8]*=s,i[1]*=e,i[5]*=t,i[9]*=s,i[2]*=e,i[6]*=t,i[10]*=s,i[3]*=e,i[7]*=t,i[11]*=s,i),scaleMat4v(e,t){const s=e[0],i=e[1],r=e[2];return t[0]*=s,t[4]*=i,t[8]*=r,t[1]*=s,t[5]*=i,t[9]*=r,t[2]*=s,t[6]*=i,t[10]*=r,t[3]*=s,t[7]*=i,t[11]*=r,t},scalingMat4s:e=>R.scalingMat4c(e,e,e),rotationTranslationMat4(e,t,s=R.mat4()){const i=e[0],r=e[1],n=e[2],A=e[3],o=i+i,a=r+r,l=n+n,c=i*o,h=i*a,u=i*l,d=r*a,p=r*l,f=n*l,g=A*o,m=A*a,_=A*l;return s[0]=1-(d+f),s[1]=h+_,s[2]=u-m,s[3]=0,s[4]=h-_,s[5]=1-(c+f),s[6]=p+g,s[7]=0,s[8]=u+m,s[9]=p-g,s[10]=1-(c+d),s[11]=0,s[12]=t[0],s[13]=t[1],s[14]=t[2],s[15]=1,s},mat4ToEuler(e,t,s=R.vec4()){const i=R.clamp,r=e[0],n=e[4],A=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],u=e[10];return"XYZ"===t?(s[1]=Math.asin(i(A,-1,1)),Math.abs(A)<.99999?(s[0]=Math.atan2(-l,u),s[2]=Math.atan2(-n,r)):(s[0]=Math.atan2(h,a),s[2]=0)):"YXZ"===t?(s[0]=Math.asin(-i(l,-1,1)),Math.abs(l)<.99999?(s[1]=Math.atan2(A,u),s[2]=Math.atan2(o,a)):(s[1]=Math.atan2(-c,r),s[2]=0)):"ZXY"===t?(s[0]=Math.asin(i(h,-1,1)),Math.abs(h)<.99999?(s[1]=Math.atan2(-c,u),s[2]=Math.atan2(-n,a)):(s[1]=0,s[2]=Math.atan2(o,r))):"ZYX"===t?(s[1]=Math.asin(-i(c,-1,1)),Math.abs(c)<.99999?(s[0]=Math.atan2(h,u),s[2]=Math.atan2(o,r)):(s[0]=0,s[2]=Math.atan2(-n,a))):"YZX"===t?(s[2]=Math.asin(i(o,-1,1)),Math.abs(o)<.99999?(s[0]=Math.atan2(-l,a),s[1]=Math.atan2(-c,r)):(s[0]=0,s[1]=Math.atan2(A,u))):"XZY"===t&&(s[2]=Math.asin(-i(n,-1,1)),Math.abs(n)<.99999?(s[0]=Math.atan2(h,a),s[1]=Math.atan2(A,r)):(s[0]=Math.atan2(-l,u),s[1]=0)),s[0]*=R.RADTODEG,s[1]*=R.RADTODEG,s[2]*=R.RADTODEG,s},composeMat4:(e,t,s,i=R.mat4())=>(R.quaternionToRotationMat4(t,i),R.scaleMat4v(s,i),R.translateMat4v(e,i),i),decomposeMat4:(()=>{const e=new P(3),t=new P(16);return function(s,i,r,n){e[0]=s[0],e[1]=s[1],e[2]=s[2];let A=R.lenVec3(e);e[0]=s[4],e[1]=s[5],e[2]=s[6];const o=R.lenVec3(e);e[0]=s[8],e[1]=s[9],e[2]=s[10];const a=R.lenVec3(e);R.determinantMat4(s)<0&&(A=-A),i[0]=s[12],i[1]=s[13],i[2]=s[14],t.set(s);const l=1/A,c=1/o,h=1/a;return t[0]*=l,t[1]*=l,t[2]*=l,t[4]*=c,t[5]*=c,t[6]*=c,t[8]*=h,t[9]*=h,t[10]*=h,R.mat4ToQuaternion(t,r),n[0]=A,n[1]=o,n[2]=a,this}})(),getColMat4(e,t){const s=4*t;return[e[s],e[s+1],e[s+2],e[s+3]]},setRowMat4(e,t,s){e[t]=s[0],e[t+4]=s[1],e[t+8]=s[2],e[t+12]=s[3]},lookAtMat4v(e,t,s,i){i||(i=R.mat4());const r=e[0],n=e[1],A=e[2],o=s[0],a=s[1],l=s[2],c=t[0],h=t[1],u=t[2];if(r===c&&n===h&&A===u)return R.identityMat4();let d,p,f,g,m,_,b,B,y,w;return d=r-c,p=n-h,f=A-u,w=1/Math.sqrt(d*d+p*p+f*f),d*=w,p*=w,f*=w,g=a*f-l*p,m=l*d-o*f,_=o*p-a*d,w=Math.sqrt(g*g+m*m+_*_),w?(w=1/w,g*=w,m*=w,_*=w):(g=0,m=0,_=0),b=p*_-f*m,B=f*g-d*_,y=d*m-p*g,w=Math.sqrt(b*b+B*B+y*y),w?(w=1/w,b*=w,B*=w,y*=w):(b=0,B=0,y=0),i[0]=g,i[1]=b,i[2]=d,i[3]=0,i[4]=m,i[5]=B,i[6]=p,i[7]=0,i[8]=_,i[9]=y,i[10]=f,i[11]=0,i[12]=-(g*r+m*n+_*A),i[13]=-(b*r+B*n+y*A),i[14]=-(d*r+p*n+f*A),i[15]=1,i},lookAtMat4c:(e,t,s,i,r,n,A,o,a)=>R.lookAtMat4v([e,t,s],[i,r,n],[A,o,a],[]),orthoMat4c(e,t,s,i,r,n,A){A||(A=R.mat4());const o=t-e,a=i-s,l=n-r;return A[0]=2/o,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=2/a,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[10]=-2/l,A[11]=0,A[12]=-(e+t)/o,A[13]=-(i+s)/a,A[14]=-(n+r)/l,A[15]=1,A},frustumMat4v(e,t,s){s||(s=R.mat4());const i=[e[0],e[1],e[2],0],r=[t[0],t[1],t[2],0];R.addVec4(r,i,D),R.subVec4(r,i,k);const n=2*i[2],A=k[0],o=k[1],a=k[2];return s[0]=n/A,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=n/o,s[6]=0,s[7]=0,s[8]=D[0]/A,s[9]=D[1]/o,s[10]=-D[2]/a,s[11]=-1,s[12]=0,s[13]=0,s[14]=-n*r[2]/a,s[15]=0,s},frustumMat4(e,t,s,i,r,n,A){A||(A=R.mat4());const o=t-e,a=i-s,l=n-r;return A[0]=2*r/o,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=2*r/a,A[6]=0,A[7]=0,A[8]=(t+e)/o,A[9]=(i+s)/a,A[10]=-(n+r)/l,A[11]=-1,A[12]=0,A[13]=0,A[14]=-n*r*2/l,A[15]=0,A},perspectiveMat4(e,t,s,i,r){const n=[],A=[];return n[2]=s,A[2]=i,A[1]=n[2]*Math.tan(e/2),n[1]=-A[1],A[0]=A[1]*t,n[0]=-A[0],R.frustumMat4v(n,A,r)},compareMat4:(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15],transformPoint3(e,t,s=R.vec3()){const i=t[0],r=t[1],n=t[2];return s[0]=e[0]*i+e[4]*r+e[8]*n+e[12],s[1]=e[1]*i+e[5]*r+e[9]*n+e[13],s[2]=e[2]*i+e[6]*r+e[10]*n+e[14],s},transformPoint4:(e,t,s=R.vec4())=>(s[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],s[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],s[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],s[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3],s),transformPoints3(e,t,s){const i=s||[],r=t.length;let n,A,o,a;const l=e[0],c=e[1],h=e[2],u=e[3],d=e[4],p=e[5],f=e[6],g=e[7],m=e[8],_=e[9],b=e[10],B=e[11],y=e[12],w=e[13],v=e[14],C=e[15];let M;for(let e=0;e<r;++e)a=t[e],n=a[0],A=a[1],o=a[2],M=i[e]||(i[e]=[0,0,0]),M[0]=l*n+d*A+m*o+y,M[1]=c*n+p*A+_*o+w,M[2]=h*n+f*A+b*o+v,M[3]=u*n+g*A+B*o+C;return i.length=r,i},transformPositions3(e,t,s=t){let i;const r=t.length;let n,A,o;const a=e[0],l=e[1],c=e[2];e[3];const h=e[4],u=e[5],d=e[6];e[7];const p=e[8],f=e[9],g=e[10];e[11];const m=e[12],_=e[13],b=e[14];for(e[15],i=0;i<r;i+=3)n=t[i+0],A=t[i+1],o=t[i+2],s[i+0]=a*n+h*A+p*o+m,s[i+1]=l*n+u*A+f*o+_,s[i+2]=c*n+d*A+g*o+b;return s},transformPositions4(e,t,s=t){let i;const r=t.length;let n,A,o;const a=e[0],l=e[1],c=e[2],h=e[3],u=e[4],d=e[5],p=e[6],f=e[7],g=e[8],m=e[9],_=e[10],b=e[11],B=e[12],y=e[13],w=e[14],v=e[15];for(i=0;i<r;i+=4)n=t[i+0],A=t[i+1],o=t[i+2],s[i+0]=a*n+u*A+g*o+B,s[i+1]=l*n+d*A+m*o+y,s[i+2]=c*n+p*A+_*o+w,s[i+3]=h*n+f*A+b*o+v;return s},transformVec3(e,t,s){const i=t[0],r=t[1],n=t[2];return(s=s||this.vec3())[0]=e[0]*i+e[4]*r+e[8]*n,s[1]=e[1]*i+e[5]*r+e[9]*n,s[2]=e[2]*i+e[6]*r+e[10]*n,s},transformVec4(e,t,s){const i=t[0],r=t[1],n=t[2],A=t[3];return(s=s||R.vec4())[0]=e[0]*i+e[4]*r+e[8]*n+e[12]*A,s[1]=e[1]*i+e[5]*r+e[9]*n+e[13]*A,s[2]=e[2]*i+e[6]*r+e[10]*n+e[14]*A,s[3]=e[3]*i+e[7]*r+e[11]*n+e[15]*A,s},rotateVec2(e,t,s,i=e){const r=Math.cos(s),n=Math.sin(s),A=e[0]-t[0],o=e[1]-t[1];return i[0]=A*r-o*n+t[0],i[1]=A*n+o*r+t[1],e},rotateVec3X(e,t,s,i){const r=[],n=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],n[0]=r[0],n[1]=r[1]*Math.cos(s)-r[2]*Math.sin(s),n[2]=r[1]*Math.sin(s)+r[2]*Math.cos(s),i[0]=n[0]+t[0],i[1]=n[1]+t[1],i[2]=n[2]+t[2],i},rotateVec3Y(e,t,s,i){const r=[],n=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],n[0]=r[2]*Math.sin(s)+r[0]*Math.cos(s),n[1]=r[1],n[2]=r[2]*Math.cos(s)-r[0]*Math.sin(s),i[0]=n[0]+t[0],i[1]=n[1]+t[1],i[2]=n[2]+t[2],i},rotateVec3Z(e,t,s,i){const r=[],n=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],n[0]=r[0]*Math.cos(s)-r[1]*Math.sin(s),n[1]=r[0]*Math.sin(s)+r[1]*Math.cos(s),n[2]=r[2],i[0]=n[0]+t[0],i[1]=n[1]+t[1],i[2]=n[2]+t[2],i},projectVec4(e,t){const s=1/e[3];return(t=t||R.vec2())[0]=e[0]*s,t[1]=e[1]*s,t},unprojectVec3:(()=>{const e=new P(16),t=new P(16),s=new P(16);return function(i,r,n,A){return this.transformVec3(this.mulMat4(this.inverseMat4(r,e),this.inverseMat4(n,t),s),i,A)}})(),lerpVec3(e,t,s,i,r,n){const A=n||R.vec3(),o=(e-t)/(s-t);return A[0]=i[0]+o*(r[0]-i[0]),A[1]=i[1]+o*(r[1]-i[1]),A[2]=i[2]+o*(r[2]-i[2]),A},lerpMat4(e,t,s,i,r,n){const A=n||R.mat4(),o=(e-t)/(s-t);return A[0]=i[0]+o*(r[0]-i[0]),A[1]=i[1]+o*(r[1]-i[1]),A[2]=i[2]+o*(r[2]-i[2]),A[3]=i[3]+o*(r[3]-i[3]),A[4]=i[4]+o*(r[4]-i[4]),A[5]=i[5]+o*(r[5]-i[5]),A[6]=i[6]+o*(r[6]-i[6]),A[7]=i[7]+o*(r[7]-i[7]),A[8]=i[8]+o*(r[8]-i[8]),A[9]=i[9]+o*(r[9]-i[9]),A[10]=i[10]+o*(r[10]-i[10]),A[11]=i[11]+o*(r[11]-i[11]),A[12]=i[12]+o*(r[12]-i[12]),A[13]=i[13]+o*(r[13]-i[13]),A[14]=i[14]+o*(r[14]-i[14]),A[15]=i[15]+o*(r[15]-i[15]),A},flatten(e){const t=[];let s,i,r,n,A;for(s=0,i=e.length;s<i;s++)for(A=e[s],r=0,n=A.length;r<n;r++)t.push(A[r]);return t},identityQuaternion:(e=R.vec4())=>(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e),eulerToQuaternion(e,t,s=R.vec4()){const i=e[0]*R.DEGTORAD/2,r=e[1]*R.DEGTORAD/2,n=e[2]*R.DEGTORAD/2,A=Math.cos(i),o=Math.cos(r),a=Math.cos(n),l=Math.sin(i),c=Math.sin(r),h=Math.sin(n);return"XYZ"===t?(s[0]=l*o*a+A*c*h,s[1]=A*c*a-l*o*h,s[2]=A*o*h+l*c*a,s[3]=A*o*a-l*c*h):"YXZ"===t?(s[0]=l*o*a+A*c*h,s[1]=A*c*a-l*o*h,s[2]=A*o*h-l*c*a,s[3]=A*o*a+l*c*h):"ZXY"===t?(s[0]=l*o*a-A*c*h,s[1]=A*c*a+l*o*h,s[2]=A*o*h+l*c*a,s[3]=A*o*a-l*c*h):"ZYX"===t?(s[0]=l*o*a-A*c*h,s[1]=A*c*a+l*o*h,s[2]=A*o*h-l*c*a,s[3]=A*o*a+l*c*h):"YZX"===t?(s[0]=l*o*a+A*c*h,s[1]=A*c*a+l*o*h,s[2]=A*o*h-l*c*a,s[3]=A*o*a-l*c*h):"XZY"===t&&(s[0]=l*o*a-A*c*h,s[1]=A*c*a-l*o*h,s[2]=A*o*h+l*c*a,s[3]=A*o*a+l*c*h),s},mat4ToQuaternion(e,t=R.vec4()){const s=e[0],i=e[4],r=e[8],n=e[1],A=e[5],o=e[9],a=e[2],l=e[6],c=e[10];let h;const u=s+A+c;return u>0?(h=.5/Math.sqrt(u+1),t[3]=.25/h,t[0]=(l-o)*h,t[1]=(r-a)*h,t[2]=(n-i)*h):s>A&&s>c?(h=2*Math.sqrt(1+s-A-c),t[3]=(l-o)/h,t[0]=.25*h,t[1]=(i+n)/h,t[2]=(r+a)/h):A>c?(h=2*Math.sqrt(1+A-s-c),t[3]=(r-a)/h,t[0]=(i+n)/h,t[1]=.25*h,t[2]=(o+l)/h):(h=2*Math.sqrt(1+c-s-A),t[3]=(n-i)/h,t[0]=(r+a)/h,t[1]=(o+l)/h,t[2]=.25*h),t},vec3PairToQuaternion(e,t,s=R.vec4()){const i=Math.sqrt(R.dotVec3(e,e)*R.dotVec3(t,t));let r=i+R.dotVec3(e,t);return r<1e-8*i?(r=0,Math.abs(e[0])>Math.abs(e[2])?(s[0]=-e[1],s[1]=e[0],s[2]=0):(s[0]=0,s[1]=-e[2],s[2]=e[1])):R.cross3Vec3(e,t,s),s[3]=r,R.normalizeQuaternion(s)},angleAxisToQuaternion(e,t=R.vec4()){const s=e[3]/2,i=Math.sin(s);return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=Math.cos(s),t},quaternionToEuler:(()=>{const e=new P(16);return(t,s,i)=>(i=i||R.vec3(),R.quaternionToRotationMat4(t,e),R.mat4ToEuler(e,s,i),i)})(),mulQuaternions(e,t,s=R.vec4()){const i=e[0],r=e[1],n=e[2],A=e[3],o=t[0],a=t[1],l=t[2],c=t[3];return s[0]=A*o+i*c+r*l-n*a,s[1]=A*a+r*c+n*o-i*l,s[2]=A*l+n*c+i*a-r*o,s[3]=A*c-i*o-r*a-n*l,s},vec3ApplyQuaternion(e,t,s=R.vec3()){const i=t[0],r=t[1],n=t[2],A=e[0],o=e[1],a=e[2],l=e[3],c=l*i+o*n-a*r,h=l*r+a*i-A*n,u=l*n+A*r-o*i,d=-A*i-o*r-a*n;return s[0]=c*l+d*-A+h*-a-u*-o,s[1]=h*l+d*-o+u*-A-c*-a,s[2]=u*l+d*-a+c*-o-h*-A,s},quaternionToMat4(e,t){t=R.identityMat4(t);const s=e[0],i=e[1],r=e[2],n=e[3],A=2*s,o=2*i,a=2*r,l=A*n,c=o*n,h=a*n,u=A*s,d=o*s,p=a*s,f=o*i,g=a*i,m=a*r;return t[0]=1-(f+m),t[1]=d+h,t[2]=p-c,t[4]=d-h,t[5]=1-(u+m),t[6]=g+l,t[8]=p+c,t[9]=g-l,t[10]=1-(u+f),t},quaternionToRotationMat4(e,t){const s=e[0],i=e[1],r=e[2],n=e[3],A=s+s,o=i+i,a=r+r,l=s*A,c=s*o,h=s*a,u=i*o,d=i*a,p=r*a,f=n*A,g=n*o,m=n*a;return t[0]=1-(u+p),t[4]=c-m,t[8]=h+g,t[1]=c+m,t[5]=1-(l+p),t[9]=d-f,t[2]=h-g,t[6]=d+f,t[10]=1-(l+u),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},normalizeQuaternion(e,t=e){const s=R.lenVec4([e[0],e[1],e[2],e[3]]);return t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s,t[3]=e[3]/s,t},conjugateQuaternion:(e,t=e)=>(t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t),inverseQuaternion:(e,t)=>R.normalizeQuaternion(R.conjugateQuaternion(e,t)),quaternionToAngleAxis(e,t=R.vec4()){const s=(e=R.normalizeQuaternion(e,Q))[3],i=2*Math.acos(s),r=Math.sqrt(1-s*s);return r<.001?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=e[0]/r,t[1]=e[1]/r,t[2]=e[2]/r),t[3]=i,t},AABB3:e=>new P(e||6),AABB2:e=>new P(e||4),OBB3:e=>new P(e||32),OBB2:e=>new P(e||16),Sphere3:(e,t,s,i)=>new P([e,t,s,i]),transformOBB3(e,t,s=t){let i;const r=t.length;let n,A,o;const a=e[0],l=e[1],c=e[2],h=e[3],u=e[4],d=e[5],p=e[6],f=e[7],g=e[8],m=e[9],_=e[10],b=e[11],B=e[12],y=e[13],w=e[14],v=e[15];for(i=0;i<r;i+=4)n=t[i+0],A=t[i+1],o=t[i+2],s[i+0]=a*n+u*A+g*o+B,s[i+1]=l*n+d*A+m*o+y,s[i+2]=c*n+p*A+_*o+w,s[i+3]=h*n+f*A+b*o+v;return s},containsAABB3:function(e,t){return e[0]<=t[0]&&t[3]<=e[3]&&e[1]<=t[1]&&t[4]<=e[4]&&e[2]<=t[2]&&t[5]<=e[5]},getAABB3Diag:(()=>{const e=new P(3),t=new P(3),s=new P(3);return i=>(e[0]=i[0],e[1]=i[1],e[2]=i[2],t[0]=i[3],t[1]=i[4],t[2]=i[5],R.subVec3(t,e,s),Math.abs(R.lenVec3(s)))})(),getAABB3DiagPoint:(()=>{const e=new P(3),t=new P(3),s=new P(3);return(i,r)=>{e[0]=i[0],e[1]=i[1],e[2]=i[2],t[0]=i[3],t[1]=i[4],t[2]=i[5];const n=R.subVec3(t,e,s),A=r[0]-i[0],o=i[3]-r[0],a=r[1]-i[1],l=i[4]-r[1],c=r[2]-i[2],h=i[5]-r[2];return n[0]+=A>o?A:o,n[1]+=a>l?a:l,n[2]+=c>h?c:h,Math.abs(R.lenVec3(n))}})(),getAABB3Area:e=>(e[3]-e[0])*(e[4]-e[1])*(e[5]-e[2]),getAABB3Center(e,t){const s=t||R.vec3();return s[0]=(e[0]+e[3])/2,s[1]=(e[1]+e[4])/2,s[2]=(e[2]+e[5])/2,s},getAABB2Center(e,t){const s=t||R.vec2();return s[0]=(e[2]+e[0])/2,s[1]=(e[3]+e[1])/2,s},collapseAABB3:(e=R.AABB3())=>(e[0]=R.MAX_DOUBLE,e[1]=R.MAX_DOUBLE,e[2]=R.MAX_DOUBLE,e[3]=R.MIN_DOUBLE,e[4]=R.MIN_DOUBLE,e[5]=R.MIN_DOUBLE,e),AABB3ToOBB3:(e,t=R.OBB3())=>(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t[4]=e[3],t[5]=e[1],t[6]=e[2],t[7]=1,t[8]=e[3],t[9]=e[4],t[10]=e[2],t[11]=1,t[12]=e[0],t[13]=e[4],t[14]=e[2],t[15]=1,t[16]=e[0],t[17]=e[1],t[18]=e[5],t[19]=1,t[20]=e[3],t[21]=e[1],t[22]=e[5],t[23]=1,t[24]=e[3],t[25]=e[4],t[26]=e[5],t[27]=1,t[28]=e[0],t[29]=e[4],t[30]=e[5],t[31]=1,t),positions3ToAABB3:(()=>{const e=new P(3);return(t,s,i)=>{s=s||R.AABB3();let r,n,A,o=R.MAX_DOUBLE,a=R.MAX_DOUBLE,l=R.MAX_DOUBLE,c=R.MIN_DOUBLE,h=R.MIN_DOUBLE,u=R.MIN_DOUBLE;for(let s=0,d=t.length;s<d;s+=3)i?(e[0]=t[s+0],e[1]=t[s+1],e[2]=t[s+2],R.decompressPosition(e,i,e),r=e[0],n=e[1],A=e[2]):(r=t[s+0],n=t[s+1],A=t[s+2]),r<o&&(o=r),n<a&&(a=n),A<l&&(l=A),r>c&&(c=r),n>h&&(h=n),A>u&&(u=A);return s[0]=o,s[1]=a,s[2]=l,s[3]=c,s[4]=h,s[5]=u,s}})(),OBB3ToAABB3(e,t=R.AABB3()){let s,i,r,n=R.MAX_DOUBLE,A=R.MAX_DOUBLE,o=R.MAX_DOUBLE,a=R.MIN_DOUBLE,l=R.MIN_DOUBLE,c=R.MIN_DOUBLE;for(let t=0,h=e.length;t<h;t+=4)s=e[t+0],i=e[t+1],r=e[t+2],s<n&&(n=s),i<A&&(A=i),r<o&&(o=r),s>a&&(a=s),i>l&&(l=i),r>c&&(c=r);return t[0]=n,t[1]=A,t[2]=o,t[3]=a,t[4]=l,t[5]=c,t},points3ToAABB3(e,t=R.AABB3()){let s,i,r,n=R.MAX_DOUBLE,A=R.MAX_DOUBLE,o=R.MAX_DOUBLE,a=R.MIN_DOUBLE,l=R.MIN_DOUBLE,c=R.MIN_DOUBLE;for(let t=0,h=e.length;t<h;t++)s=e[t][0],i=e[t][1],r=e[t][2],s<n&&(n=s),i<A&&(A=i),r<o&&(o=r),s>a&&(a=s),i>l&&(l=i),r>c&&(c=r);return t[0]=n,t[1]=A,t[2]=o,t[3]=a,t[4]=l,t[5]=c,t},points3ToSphere3:(()=>{const e=new P(3);return(t,s)=>{s=s||R.vec4();let i,r=0,n=0,A=0;const o=t.length;for(i=0;i<o;i++)r+=t[i][0],n+=t[i][1],A+=t[i][2];s[0]=r/o,s[1]=n/o,s[2]=A/o;let a,l=0;for(i=0;i<o;i++)a=Math.abs(R.lenVec3(R.subVec3(t[i],s,e))),a>l&&(l=a);return s[3]=l,s}})(),positions3ToSphere3:(()=>{const e=new P(3),t=new P(3);return(s,i)=>{i=i||R.vec4();let r,n=0,A=0,o=0;const a=s.length;let l=0;for(r=0;r<a;r+=3)n+=s[r],A+=s[r+1],o+=s[r+2];const c=a/3;let h;for(i[0]=n/c,i[1]=A/c,i[2]=o/c,r=0;r<a;r+=3)e[0]=s[r],e[1]=s[r+1],e[2]=s[r+2],h=Math.abs(R.lenVec3(R.subVec3(e,i,t))),h>l&&(l=h);return i[3]=l,i}})(),OBB3ToSphere3:(()=>{const e=new P(3),t=new P(3);return(s,i)=>{i=i||R.vec4();let r,n=0,A=0,o=0;const a=s.length,l=a/4;for(r=0;r<a;r+=4)n+=s[r+0],A+=s[r+1],o+=s[r+2];i[0]=n/l,i[1]=A/l,i[2]=o/l;let c,h=0;for(r=0;r<a;r+=4)e[0]=s[r+0],e[1]=s[r+1],e[2]=s[r+2],c=Math.abs(R.lenVec3(R.subVec3(e,i,t))),c>h&&(h=c);return i[3]=h,i}})(),getSphere3Center:(e,t=R.vec3())=>(t[0]=e[0],t[1]=e[1],t[2]=e[2],t),getPositionsCenter(e,t=R.vec3()){let s=0,i=0,r=0;for(var n=0,A=e.length;n<A;n+=3)s+=e[n+0],i+=e[n+1],r+=e[n+2];const o=e.length/3;return t[0]=s/o,t[1]=i/o,t[2]=r/o,t},expandAABB3:(e,t)=>(e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]>t[2]&&(e[2]=t[2]),e[3]<t[3]&&(e[3]=t[3]),e[4]<t[4]&&(e[4]=t[4]),e[5]<t[5]&&(e[5]=t[5]),e),expandAABB3Point3:(e,t)=>(e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]>t[2]&&(e[2]=t[2]),e[3]<t[0]&&(e[3]=t[0]),e[4]<t[1]&&(e[4]=t[1]),e[5]<t[2]&&(e[5]=t[2]),e),expandAABB3Points3(e,t){for(var s,i,r,n=0,A=t.length;n<A;n+=3)s=t[n],i=t[n+1],r=t[n+2],e[0]>s&&(e[0]=s),e[1]>i&&(e[1]=i),e[2]>r&&(e[2]=r),e[3]<s&&(e[3]=s),e[4]<i&&(e[4]=i),e[5]<r&&(e[5]=r);return e},collapseAABB2:(e=R.AABB2())=>(e[0]=R.MAX_DOUBLE,e[1]=R.MAX_DOUBLE,e[2]=R.MIN_DOUBLE,e[3]=R.MIN_DOUBLE,e),point3AABB3Intersect:(e,t)=>e[0]>t[0]||e[3]<t[0]||e[1]>t[1]||e[4]<t[1]||e[2]>t[2]||e[5]<t[2],point3AABB3AbsoluteIntersect:(e,t)=>e[0]<=t[0]&&e[3]>=t[0]&&e[1]<=t[1]&&e[4]>=t[1]&&e[2]<=t[2]&&e[5]>=t[2],planeAABB3Intersect(e,t,s){let i,r;e[0]>0?(i=e[0]*s[0],r=e[0]*s[3]):(i=e[0]*s[3],r=e[0]*s[0]),e[1]>0?(i+=e[1]*s[1],r+=e[1]*s[4]):(i+=e[1]*s[4],r+=e[1]*s[1]),e[2]>0?(i+=e[2]*s[2],r+=e[2]*s[5]):(i+=e[2]*s[5],r+=e[2]*s[2]);if(i<=-t&&r<=-t)return-1;return i>=-t&&r>=-t?1:0},OBB3ToAABB2(e,t=R.AABB2()){let s,i,r,n,A=R.MAX_DOUBLE,o=R.MAX_DOUBLE,a=R.MIN_DOUBLE,l=R.MIN_DOUBLE;for(let t=0,c=e.length;t<c;t+=4)s=e[t+0],i=e[t+1],r=e[t+3]||1,n=1/r,s*=n,i*=n,s<A&&(A=s),i<o&&(o=i),s>a&&(a=s),i>l&&(l=i);return t[0]=A,t[1]=o,t[2]=a,t[3]=l,t},expandAABB2:(e,t)=>(e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]<t[2]&&(e[2]=t[2]),e[3]<t[3]&&(e[3]=t[3]),e),expandAABB2Point2:(e,t)=>(e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]<t[0]&&(e[2]=t[0]),e[3]<t[1]&&(e[3]=t[1]),e),AABB2ToCanvas(e,t,s,i=e){const r=.5*(e[0]+1),n=.5*(e[1]+1),A=.5*(e[2]+1),o=.5*(e[3]+1);return i[0]=Math.floor(r*t),i[1]=s-Math.floor(o*s),i[2]=Math.floor(A*t),i[3]=s-Math.floor(n*s),i},tangentQuadraticBezier:(e,t,s,i)=>2*(1-e)*(s-t)+2*e*(i-s),tangentQuadraticBezier3:(e,t,s,i,r)=>-3*t*(1-e)*(1-e)+3*s*(1-e)*(1-e)-6*e*s*(1-e)+6*e*i*(1-e)-3*e*e*i+3*e*e*r,tangentSpline:e=>6*e*e-6*e+(3*e*e-4*e+1)+(-6*e*e+6*e)+(3*e*e-2*e),catmullRomInterpolate(e,t,s,i,r){const n=.5*(s-e),A=.5*(i-t),o=r*r;return(2*t-2*s+n+A)*(r*o)+(-3*t+3*s-2*n-A)*o+n*r+t},b2p0(e,t){const s=1-e;return s*s*t},b2p1:(e,t)=>2*(1-e)*e*t,b2p2:(e,t)=>e*e*t,b2(e,t,s,i){return this.b2p0(e,t)+this.b2p1(e,s)+this.b2p2(e,i)},b3p0(e,t){const s=1-e;return s*s*s*t},b3p1(e,t){const s=1-e;return 3*s*s*e*t},b3p2:(e,t)=>3*(1-e)*e*e*t,b3p3:(e,t)=>e*e*e*t,b3(e,t,s,i,r){return this.b3p0(e,t)+this.b3p1(e,s)+this.b3p2(e,i)+this.b3p3(e,r)},triangleNormal(e,t,s,i=R.vec3()){const r=t[0]-e[0],n=t[1]-e[1],A=t[2]-e[2],o=s[0]-e[0],a=s[1]-e[1],l=s[2]-e[2],c=n*l-A*a,h=A*o-r*l,u=r*a-n*o,d=Math.sqrt(c*c+h*h+u*u);return 0===d?(i[0]=0,i[1]=0,i[2]=0):(i[0]=c/d,i[1]=h/d,i[2]=u/d),i},rayTriangleIntersect:(()=>{const e=new P(3),t=new P(3),s=new P(3),i=new P(3),r=new P(3);return(n,A,o,a,l,c)=>{c=c||R.vec3();const h=R.subVec3(a,o,e),u=R.subVec3(l,o,t),d=R.cross3Vec3(A,u,s),p=R.dotVec3(h,d);if(p<1e-6)return null;const f=R.subVec3(n,o,i),g=R.dotVec3(f,d);if(g<0||g>p)return null;const m=R.cross3Vec3(f,h,r),_=R.dotVec3(A,m);if(_<0||g+_>p)return null;const b=R.dotVec3(u,m)/p;return c[0]=n[0]+b*A[0],c[1]=n[1]+b*A[1],c[2]=n[2]+b*A[2],c}})(),rayPlaneIntersect:(()=>{const e=new P(3),t=new P(3),s=new P(3),i=new P(3);return(r,n,A,o,a,l)=>{l=l||R.vec3(),n=R.normalizeVec3(n,e);const c=R.subVec3(o,A,t),h=R.subVec3(a,A,s),u=R.cross3Vec3(c,h,i);R.normalizeVec3(u,u);const d=-R.dotVec3(A,u),p=-(R.dotVec3(r,u)+d)/R.dotVec3(n,u);return l[0]=r[0]+p*n[0],l[1]=r[1]+p*n[1],l[2]=r[2]+p*n[2],l}})(),cartesianToBarycentric:(()=>{const e=new P(3),t=new P(3),s=new P(3);return(i,r,n,A,o)=>{const a=R.subVec3(A,r,e),l=R.subVec3(n,r,t),c=R.subVec3(i,r,s),h=R.dotVec3(a,a),u=R.dotVec3(a,l),d=R.dotVec3(a,c),p=R.dotVec3(l,l),f=R.dotVec3(l,c),g=h*p-u*u;if(0===g)return null;const m=1/g,_=(p*d-u*f)*m,b=(h*f-u*d)*m;return o[0]=1-_-b,o[1]=b,o[2]=_,o}})(),barycentricInsideTriangle(e){const t=e[1],s=e[2];return s>=0&&t>=0&&s+t<1},barycentricToCartesian(e,t,s,i,r=R.vec3()){const n=e[0],A=e[1],o=e[2];return r[0]=t[0]*n+s[0]*A+i[0]*o,r[1]=t[1]*n+s[1]*A+i[1]*o,r[2]=t[2]*n+s[2]*A+i[2]*o,r},mergeVertices(e,t,s,i){const r={},n=[],A=[],o=t?[]:null,a=s?[]:null,l=[];let c,h,u,d;const p=1e4;let f,g,m=0;for(f=0,g=e.length;f<g;f+=3)c=e[f],h=e[f+1],u=e[f+2],d=`${Math.round(c*p)}_${Math.round(h*p)}_${Math.round(u*p)}`,void 0===r[d]&&(r[d]=A.length/3,A.push(c),A.push(h),A.push(u),t&&(o.push(t[f]),o.push(t[f+1]),o.push(t[f+2])),s&&(a.push(s[m]),a.push(s[m+1]))),n[f/3]=r[d],m+=2;for(f=0,g=i.length;f<g;f++)l[f]=n[i[f]];const _={positions:A,indices:l};return o&&(_.normals=o),a&&(_.uv=a),_},buildNormals:(()=>{const e=new P(3),t=new P(3),s=new P(3),i=new P(3),r=new P(3),n=new P(3);return(A,o,a)=>{let l,c;const h=new Array(A.length/3);let u,d,p,f,g,m,_;for(l=0,c=o.length;l<c;l+=3){u=o[l],d=o[l+1],p=o[l+2],e[0]=A[3*u],e[1]=A[3*u+1],e[2]=A[3*u+2],t[0]=A[3*d],t[1]=A[3*d+1],t[2]=A[3*d+2],s[0]=A[3*p],s[1]=A[3*p+1],s[2]=A[3*p+2],R.subVec3(t,e,i),R.subVec3(s,e,r);const a=R.vec3();R.normalizeVec3(R.cross3Vec3(i,r,n),a),h[u]||(h[u]=[]),h[d]||(h[d]=[]),h[p]||(h[p]=[]),h[u].push(a),h[d].push(a),h[p].push(a)}for(a=a&&a.length===A.length?a:new Float32Array(A.length),l=0,c=h.length;l<c;l++){f=h[l].length,g=0,m=0,_=0;for(let e=0;e<f;e++)g+=h[l][e][0],m+=h[l][e][1],_+=h[l][e][2];a[3*l]=g/f,a[3*l+1]=m/f,a[3*l+2]=_/f}return a}})(),buildTangents:(()=>{const e=new P(3),t=new P(3),s=new P(3),i=new P(3),r=new P(3),n=new P(3),A=new P(3);return(o,a,l)=>{const c=new Float32Array(o.length);for(let h=0;h<a.length;h+=3){let u=a[h];const d=o.subarray(3*u,3*u+3),p=l.subarray(2*u,2*u+2);u=a[h+1];const f=o.subarray(3*u,3*u+3),g=l.subarray(2*u,2*u+2);u=a[h+2];const m=o.subarray(3*u,3*u+3),_=l.subarray(2*u,2*u+2),b=R.subVec3(f,d,e),B=R.subVec3(m,d,t),y=R.subVec2(g,p,s),w=R.subVec2(_,p,i),v=1/(y[0]*w[1]-y[1]*w[0]),C=R.mulVec3Scalar(R.subVec3(R.mulVec3Scalar(b,w[1],r),R.mulVec3Scalar(B,y[1],n),A),v,n);let M;for(let e=0;e<3;e++)M=3*a[h+e],c[M]+=C[0],c[M+1]+=C[1],c[M+2]+=C[2]}return c}})(),buildPickTriangles(e,t,s){const i=t.length,r=s?new Uint16Array(9*i):new Float32Array(9*i),n=new Uint8Array(12*i);let A,o,a,l,c,h,u=0,d=0,p=0;for(let s=0;s<i;s+=3)h=u>>24&255,c=u>>16&255,l=u>>8&255,a=255&u,o=t[s],A=3*o,r[d++]=e[A],r[d++]=e[A+1],r[d++]=e[A+2],n[p++]=a,n[p++]=l,n[p++]=c,n[p++]=h,o=t[s+1],A=3*o,r[d++]=e[A],r[d++]=e[A+1],r[d++]=e[A+2],n[p++]=a,n[p++]=l,n[p++]=c,n[p++]=h,o=t[s+2],A=3*o,r[d++]=e[A],r[d++]=e[A+1],r[d++]=e[A+2],n[p++]=a,n[p++]=l,n[p++]=c,n[p++]=h,u++;return{positions:r,colors:n}},faceToVertexNormals(e,t,s={}){const i=s.smoothNormalsAngleThreshold||20,r={},n=[],A={};let o,a,l,c,h;const u=1e4;let d,p,f,g,m,_;for(p=0,g=e.length;p<g;p+=3){d=p/3,a=e[p],l=e[p+1],c=e[p+2],h=`${Math.round(a*u)}_${Math.round(l*u)}_${Math.round(c*u)}`,void 0===r[h]?r[h]=[d]:r[h].push(d);const s=R.normalizeVec3([t[p],t[p+1],t[p+2]]);n[d]=s,o=R.vec4([s[0],s[1],s[2],1]),A[d]=o}for(h in r)if(r.hasOwnProperty(h)){const e=r[h],t=e.length;for(p=0;p<t;p++){const s=e[p];for(o=A[s],f=0;f<t;f++){if(p===f)continue;const t=e[f];m=n[s],_=n[t];Math.abs(R.angleVec3(m,_)/R.DEGTORAD)<i&&(o[0]+=_[0],o[1]+=_[1],o[2]+=_[2],o[3]+=1)}}}for(p=0,g=t.length;p<g;p+=3)o=A[p/3],t[p+0]=o[0]/o[3],t[p+1]=o[1]/o[3],t[p+2]=o[2]/o[3]},transformRay:(()=>{const e=new P(4),t=new P(4);return(s,i,r,n,A)=>{e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=1,R.transformVec4(s,e,t),n[0]=t[0],n[1]=t[1],n[2]=t[2],e[0]=r[0],e[1]=r[1],e[2]=r[2],R.transformVec3(s,e,t),R.normalizeVec3(t),A[0]=t[0],A[1]=t[1],A[2]=t[2]}})(),canvasPosToWorldRay:(()=>{const e=new P(16),t=new P(4),s=new P(4),i=(t,s,i,r,n)=>{n[0]=t,n[1]=s,n[2]=i,n[3]=1,R.transformVec4(e,n,n),r||R.mulVec4Scalar(n,1/n[3])};return(r,n,A,o,a,l,c)=>{const h="ortho"===o;R.mulMat4(A,n,e),R.inverseMat4(e,e);const u=2*a[0]/r.clientWidth-1,d=1-2*a[1]/r.clientHeight;i(u,d,-1,h,t),i(u,d,1,h,s),l[0]=t[0],l[1]=t[1],l[2]=t[2],R.subVec3(s,t,c),R.normalizeVec3(c)}})(),canvasPosToLocalRay:(()=>{const e=new P(3),t=new P(3);return(s,i,r,n,A,o,a,l)=>{R.canvasPosToWorldRay(s,i,r,n,o,e,t),R.worldRayToLocalRay(A,e,t,a,l)}})(),worldRayToLocalRay:(()=>{const e=new P(16),t=new P(4),s=new P(4);return(i,r,n,A,o)=>{const a=R.inverseMat4(i,e);t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=1,R.transformVec4(a,t,s),A[0]=s[0],A[1]=s[1],A[2]=s[2],R.transformVec3(a,n,o)}})(),buildKDTree:(()=>{const e=new Float32Array;function t(s,i,r,n){const A=new P(6),o={triangles:null,left:null,right:null,leaf:!1,splitDim:0,aabb:A};let a,l;for(A[0]=A[1]=A[2]=Number.POSITIVE_INFINITY,A[3]=A[4]=A[5]=Number.NEGATIVE_INFINITY,a=0,l=s.length;a<l;++a){var c=3*s[a];for(let e=0;e<3;++e){const t=3*i[c+e];r[t]<A[0]&&(A[0]=r[t]),r[t]>A[3]&&(A[3]=r[t]),r[t+1]<A[1]&&(A[1]=r[t+1]),r[t+1]>A[4]&&(A[4]=r[t+1]),r[t+2]<A[2]&&(A[2]=r[t+2]),r[t+2]>A[5]&&(A[5]=r[t+2])}}if(s.length<20||n>10)return o.triangles=s,o.leaf=!0,o;e[0]=A[3]-A[0],e[1]=A[4]-A[1],e[2]=A[5]-A[2];let h=0;e[1]>e[h]&&(h=1),e[2]>e[h]&&(h=2),o.splitDim=h;const u=(A[h]+A[h+3])/2,d=new Array(s.length);let p=0;const f=new Array(s.length);let g=0;for(a=0,l=s.length;a<l;++a){const e=i[c=3*s[a]],t=3*i[c+1],n=3*i[c+2];r[3*e+h]<=u||r[t+h]<=u||r[n+h]<=u?d[p++]=s[a]:f[g++]=s[a]}return d.length=p,f.length=g,o.left=t(d,i,r,n+1),o.right=t(f,i,r,n+1),o}return(e,s)=>{const i=e.length/3,r=new Array(i);for(let e=0;e<i;++e)r[e]=e;return t(r,e,s,0)}})(),decompressPosition(e,t,s){(s=s||e)[0]=e[0]*t[0]+t[12],s[1]=e[1]*t[5]+t[13],s[2]=e[2]*t[10]+t[14]},decompressPositions(e,t,s=new Float32Array(e.length)){for(let i=0,r=e.length;i<r;i+=3)s[i+0]=e[i+0]*t[0]+t[12],s[i+1]=e[i+1]*t[5]+t[13],s[i+2]=e[i+2]*t[10]+t[14];return s},decompressUV(e,t,s){s[0]=e[0]*t[0]+t[6],s[1]=e[1]*t[4]+t[7]},decompressUVs(e,t,s=new Float32Array(e.length)){for(let i=0,r=e.length;i<r;i+=3)s[i+0]=e[i+0]*t[0]+t[6],s[i+1]=e[i+1]*t[4]+t[7];return s},octDecodeVec2(e,t){let s=e[0],i=e[1];s=(2*s+1)/255,i=(2*i+1)/255;const r=1-Math.abs(s)-Math.abs(i);r<0&&(s=(1-Math.abs(i))*(s>=0?1:-1),i=(1-Math.abs(s))*(i>=0?1:-1));const n=Math.sqrt(s*s+i*i+r*r);return t[0]=s/n,t[1]=i/n,t[2]=r/n,t},octDecodeVec2s(e,t){for(let s=0,i=0,r=e.length;s<r;s+=2){let r=e[s+0],n=e[s+1];r=(2*r+1)/255,n=(2*n+1)/255;const A=1-Math.abs(r)-Math.abs(n);A<0&&(r=(1-Math.abs(n))*(r>=0?1:-1),n=(1-Math.abs(r))*(n>=0?1:-1));const o=Math.sqrt(r*r+n*n+A*A);t[i+0]=r/o,t[i+1]=n/o,t[i+2]=A/o,i+=3}return t}};R.buildEdgeIndices=function(){const e=[],t=[],s=[],i=[],r=[];let n=0;const A=new Uint16Array(3),o=new Uint16Array(3),a=new Uint16Array(3),l=R.vec3(),c=R.vec3(),h=R.vec3(),u=R.vec3(),d=R.vec3(),p=R.vec3(),f=R.vec3();return function(g,m,_,b){!function(r,n){const A={};let o,a,l,c;const h=Math.pow(10,4);let u,d,p=0;for(u=0,d=r.length;u<d;u+=3)o=r[u],a=r[u+1],l=r[u+2],c=Math.round(o*h)+"_"+Math.round(a*h)+"_"+Math.round(l*h),void 0===A[c]&&(A[c]=p/3,e[p++]=o,e[p++]=a,e[p++]=l),t[u/3]=A[c];for(u=0,d=n.length;u<d;u++)i[u]=t[n[u]],s[i[u]]=n[u]}(g,m),function(t,s){n=0;for(let g=0,m=t;g<m;g+=3){const t=3*i[g],m=3*i[g+1],_=3*i[g+2];s?(A[0]=e[t],A[1]=e[t+1],A[2]=e[t+2],o[0]=e[m],o[1]=e[m+1],o[2]=e[m+2],a[0]=e[_],a[1]=e[_+1],a[2]=e[_+2],R.decompressPosition(A,s,l),R.decompressPosition(o,s,c),R.decompressPosition(a,s,h)):(l[0]=e[t],l[1]=e[t+1],l[2]=e[t+2],c[0]=e[m],c[1]=e[m+1],c[2]=e[m+2],h[0]=e[_],h[1]=e[_+1],h[2]=e[_+2]),R.subVec3(h,c,u),R.subVec3(l,c,d),R.cross3Vec3(u,d,p),R.normalizeVec3(p,f);const b=r[n]||(r[n]={normal:R.vec3()});b.normal[0]=f[0],b.normal[1]=f[1],b.normal[2]=f[2],n++}}(m.length,_);const B=[],y=Math.cos(R.DEGTORAD*b),w={};let v,C,M,E,F,x,U,I,T,P,S,D=!1;for(let e=0,t=m.length;e<t;e+=3){const t=e/3;for(let s=0;s<3;s++)v=i[e+s],C=i[e+(s+1)%3],M=Math.min(v,C),E=Math.max(v,C),F=M+","+E,void 0===w[F]?w[F]={index1:M,index2:E,face1:t,face2:void 0}:w[F].face2=t}for(F in w)x=w[F],void 0!==x.face2&&(U=r[x.face1].normal,I=r[x.face2].normal,T=R.dotVec3(U,I),T>y)||(P=s[x.index1],S=s[x.index2],(!D&&P>65535||S>65535)&&(D=!0),B.push(P),B.push(S));return D?new Uint32Array(B):new Uint16Array(B)}}(),R.planeClipsPositions3=function(e,t,s,i=3){for(let r=0,n=s.length;r<n;r+=i){if(S[0]=s[r+0]-e[0],S[1]=s[r+1]-e[1],S[2]=s[r+2]-e[2],S[0]*t[0]+S[1]*t[1]+S[2]*t[2]<0)return!0}return!1},R.planeIntersectsAABB3=(e,t)=>{const s=[t[0],t[1],t[2]],i=[t[3],t[4],t[5]],r=[[s[0],s[1],s[2]],[i[0],s[1],s[2]],[s[0],i[1],s[2]],[i[0],i[1],s[2]],[s[0],s[1],i[2]],[i[0],s[1],i[2]],[s[0],i[1],i[2]],[i[0],i[1],i[2]]];let n=!1,A=!1;for(const t of r){const s=e.dist+R.dotVec3(e.dir,t);if(s>0&&(n=!0),s<0&&(A=!0),n&&A)return!0}return!1},R.makeSectionPlaneSlicer=function(){const e=R.vec2(),t=R.vec2(),s=R.vec2(),i=R.vec2(),r=R.vec3(),A=R.vec3(),o=R.vec3();R.vec3();const a=[R.vec3(),R.vec3(),R.vec3()],l=[null,null,null],c=[null,null,null],h=[null,null,null],u=[1,0,0],d=[0,1,0],p=[0,0,1],f=function(){const e=R.vec3();return(t,s)=>R.sqLenVec3(R.subVec3(t,s,e))}(),g=e=>{const t=[];for(let s=0;s<e;++s)t.push(s);return t},m=(e,t,s)=>(s[1]-e[1])*(t[0]-e[0])>(t[1]-e[1])*(s[0]-e[0]);return function(_){const b=R.vec3ApplyQuaternion(_.quaternion,u,R.vec3()),B=R.vec3ApplyQuaternion(_.quaternion,d,R.vec3()),y=R.vec3ApplyQuaternion(_.quaternion,p,R.vec3());return function(u,d={}){const p=R.subVec3(u.origin,_.pos,R.vec3()),w=R.dotVec3(y,p),v=[],C=[null],M=(e,t)=>{const s=C.length,i=new Float64Array(5);return i.set(e),t&&(R.addVec3(p,e,r),i[3]=-R.dotVec3(b,r),i[4]=R.dotVec3(B,r)),C.push(i),s},E=(e,t)=>{const s=C[e];return t[0]=s[3],t[1]=s[4],t},F=(r,n)=>{const A=r.boundingBox,o=n.boundingBox;if(A[0]<o[0]||A[1]<o[1]||A[2]>o[2]||A[3]>o[3])return!1;const a=r.endPoints,l=n.endPoints;for(let r=0,n=a.length-1;r<a.length;n=r++){const A=E(a[r],e),[o,c]=A,h=E(a[n],t);let u=!1;for(let e=0,t=l.length-1;e<l.length;t=e++){const r=E(l[e],s),n=E(l[t],i);if(m(A,r,n)!==m(h,r,n)&&m(A,h,r)!==m(A,h,n))return!1;const[a,d]=r,[p,f]=n,g=o-a,_=c-d,b=p-a,B=f-d,y=(0!==b||0!==B)&&Math.abs(b*_-B*g)<1e-10?g*b+_*B:-1;if(y>=0&&y<=Math.pow(b,2)+Math.pow(B,2))return!1;d>c!=f>c&&g<_*b/B&&(u=!u)}if(!u)return!1}return!0},x={indices:[],normals:[]},U=!d.onlyPosSliceWithUV&&{indices:[],normals:[]},I=(e,t,s)=>{if(e){const i=C[t[0]];s||=R.normalizeVec3(R.cross3Vec3(R.subVec3(C[t[1]],i,r),R.subVec3(C[t[2]],i,A),r),r);for(let i=0;i<3;++i)e.indices.push(t[i]),e.normals.push(s[0],s[1],s[2])}},T=(e,t)=>{const s=3*u.indices[e];return t[0]=u.positions[s+0],t[1]=u.positions[s+1],t[2]=u.positions[s+2],t};for(let e=0;e<u.indices.length;e+=3){const t=T(e+0,a[0]),s=T(e+1,a[1]),i=T(e+2,a[2]);if(R.compareVec3(t,s)||R.compareVec3(s,i)||R.compareVec3(i,t))continue;const n=w+R.dotVec3(y,t),A=w+R.dotVec3(y,s),o=w+R.dotVec3(y,i);if(0!==n||0!==A||0!==o){const e=n*A<=0&&M(R.lerpVec3(n/(n-A),0,1,t,s,r),!0),a=A*o<=0&&M(R.lerpVec3(A/(A-o),0,1,s,i,r),!0),u=o*n<=0&&M(R.lerpVec3(o/(o-n),0,1,i,t,r),!0),p=!d.onlyPosSliceWithUV&&c;if(p&&(p[0]=M(t),p[1]=M(s),p[2]=M(i)),e?a||u:a&&u){if(v.push(e?[e,a||u]:[a,u]),p)if(0===n&&0===A)I(o>0?x:U,p);else if(0===n&&0===o)I(A>0?x:U,p);else if(0===A&&0===o)I(n>0?x:U,p);else{const t=(e?n:A)>0,s=t?x:U,i=t?U:x,r=l;r[0]=e,r[1]=a,r[2]=u;const o=h;e?(o[0]=0,o[1]=1,o[2]=2):(o[0]=1,o[1]=2,o[2]=0),r[o[1]]?(I(s,[p[o[0]],r[o[0]],p[o[2]]]),I(s,[r[o[0]],r[o[1]],p[o[2]]]),I(i,[r[o[0]],p[o[1]],r[o[1]]])):(I(s,[p[o[0]],r[o[0]],r[o[2]]]),I(i,[r[o[0]],p[o[1]],p[o[2]]]),I(i,[r[o[0]],p[o[2]],r[o[2]]]))}}else p&&(n>=0&&A>=0&&o>=0?I(x,p):n<=0&&A<=0&&o<=0&&I(U,p))}}const P=[];for(;v.length>0;){P.push([v[0][0],v[0][1]]);const e=P[P.length-1];for(v.splice(0,1);v.length>0;){const t=C[e[e.length-1]],s={distSq:f(C[e[0]],t),idx:-1,side:-1};if(v.forEach(((e,i)=>{const r=f(C[e[0]],t),n=f(C[e[1]],t),A=Math.min(r,n);s.distSq>A&&(s.distSq=A,s.idx=i,s.side=n<r?1:0)})),!(s.distSq<1e-20)){P.pop();break}{const i=s.idx>=0&&v[s.idx];if(C[i?i[s.side]:e[0]]=t,!i)break;{v.splice(s.idx,1);const t=i[1-s.side];if(!(f(C[t],C[e[0]])>1e-20))break;e.push(t)}}}}const S=P.filter((e=>e.length>2)).map(((s,i)=>{let r=0;const n=R.collapseAABB2(R.AABB2());for(let i=0;i<s.length;i++)E(s[i],e),R.expandAABB2Point2(n,e),E(s[(i+1)%s.length],t),r+=e[0]*t[1]-t[0]*e[1];return{boundingBox:n,doubleArea:Math.abs(r),endPoints:s}})).sort(((e,t)=>t.doubleArea-e.doubleArea));for(;S.length>0;){const t=[],s=[],i=i=>i.endPoints.forEach((i=>{E(i,e),t.push(e[0],e[1]),s.push(i)})),r=S.shift();i(r);const a=[];let c=0;for(;c<S.length;){const e=S[c];F(e,r)&&a.every((t=>!F(e,t)))?(e.index=t.length/2,i(e),a.push(e),S.splice(c,1)):++c}const h=n(t,a.map((e=>e.index)));for(let e=0;e<h.length;e+=3){const t=l;t[0]=s[h[e+0]],t[1]=s[h[e+1]],t[2]=s[h[e+2]];const i=C[t[0]];R.subVec3(C[t[1]],i,A),R.subVec3(C[t[2]],i,o),R.normalizeVec3(R.cross3Vec3(A,o,o),o);const r=R.dotVec3(o,y)<=0;I(r?x:U,t,o);const n=t[0];t[0]=t[2],t[2]=n,I(r?U:x,t,R.negateVec3(o,o))}}const D=e=>e&&e.indices.length>0&&function(){const t=[],s=d.onlyPosSliceWithUV&&[];return e.indices.forEach((e=>{const i=C[e];t.push(i[0],i[1],i[2]),s&&s.push(i[3],i[4])})),{indices:g(e.indices.length),positions:t,normals:e.normals,uv:s}}();return{pos:D(x),neg:D(U)}}}}();const O=new Float32Array(3);class V{constructor(){this._head=[],this._headLength=0,this._tail=[],this._index=0,this._length=0}get length(){return this._length}shift(){if(this._index>=this._headLength){const e=this._head;if(e.length=0,this._head=this._tail,this._tail=e,this._index=0,this._headLength=this._head.length,!this._headLength)return}const e=this._head[this._index];return this._index<0?delete this._head[this._index++]:this._head[this._index++]=void 0,this._length--,e}push(e){return this._length++,this._tail.push(e),this}unshift(e){return this._head[--this._index]=e,this._length++,this}}const L={build:{version:"0.8"},client:{browser:navigator&&navigator.userAgent?navigator.userAgent:"n/a"},components:{scenes:0,models:0,meshes:0,objects:0},memory:{meshes:0,positions:0,colors:0,normals:0,uvs:0,indices:0,textures:0,transforms:0,materials:0,programs:0},frame:{frameCount:0,fps:0,useProgram:0,bindTexture:0,bindArray:0,drawElements:0,drawArrays:0,tasksRun:0,tasksScheduled:0}};var H=[["0",10],["A",26],["a",26],["_",1],["$",1]].map((function(e){for(var t=[],s=e[0].charCodeAt(0),i=s+e[1],r=s;r<i;++r)t.push(r);return String.fromCharCode.apply(null,t)})).join("");function N(e,t){return(t&&4!==t?[0,6]:[0,6,12,18]).map((function(t){return H.substr(parseInt(e/(1<<t))%64,1)})).reverse().join("")}const G=function(){for(var e={},t=window.location.search.substring(1).split("&"),s=0;s<t.length;s++){var i=t[s].split("=");if(void 0===e[i[0]])e[i[0]]=decodeURIComponent(i[1]);else if("string"==typeof e[i[0]]){var r=[e[i[0]],decodeURIComponent(i[1])];e[i[0]]=r}else e[i[0]].push(decodeURIComponent(i[1]))}return e}();const j={xmlToJson:function e(t,s){if(t.nodeType===t.TEXT_NODE){var i=t.nodeValue;if(null===i.match(/^\s+$/))return i}else if(t.nodeType===t.ELEMENT_NODE||t.nodeType===t.DOCUMENT_NODE){var r={type:t.nodeName,children:[]};if(t.nodeType===t.ELEMENT_NODE)for(var n=0;n<t.attributes.length;n++){var A=t.attributes[n];r[s[A.nodeName]||A.nodeName]=A.nodeValue}for(var o=0;o<t.childNodes.length;o++){(n=e(t.childNodes[o],s))&&r.children.push(n)}return r}},clone:function(e){return JSON.parse(JSON.stringify(e))},compressGuid:function(e){var t=[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30].map((function(t){return parseInt(e.substr(t,2),16)}));return N(t[0],2)+[1,4,7,10,13].map((function(e){return N((t[e]<<16)+(t[e+1]<<8)+t[e+2])})).join("")},findNodeOfType:function(e,t){var s=[],i=function(e){e.type===t&&s.push(e),(e.children||[]).forEach((function(e){i(e)}))};return i(e),s},timeout:function(e){return new Promise((function(t,s){setTimeout(t,e)}))},httpRequest:function(e){return new Promise((function(t,s){var i=new XMLHttpRequest;i.open(e.method||"GET",e.url,!0),i.onload=function(e){4===i.readyState&&(200===i.status?t(i.responseXML):s(i.statusText))},i.send(null)}))},loadJSON:function(e,t,s){var i=e=>{};t=t||i,s=s||i;var r=new XMLHttpRequest;r.overrideMimeType("application/json"),r.open("GET",e,!0),r.addEventListener("load",(function(e){var i=e.target.response;if(200===this.status){var r;try{r=JSON.parse(i)}catch(e){s(`utils.loadJSON(): Failed to parse JSON response - ${e}`)}t(r)}else if(0===this.status){console.warn("loadFile: HTTP Status 0 received.");try{t(JSON.parse(i))}catch(e){s(`utils.loadJSON(): Failed to parse JSON response - ${e}`)}}else s(e)}),!1),r.addEventListener("error",(function(e){s(e)}),!1),r.send(null)},loadArraybuffer:function(e,t,s){var i=e=>{};t=t||i,s=s||i;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var n=r[3];n=window.decodeURIComponent(n),e&&(n=window.atob(n));try{const e=new ArrayBuffer(n.length),s=new Uint8Array(e);for(var A=0;A<n.length;A++)s[A]=n.charCodeAt(A);q.scheduleTask((()=>{t(e)}))}catch(e){q.scheduleTask((()=>{s(e)}))}}else{const i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onreadystatechange=function(){4===i.readyState&&(200===i.status?t(i.response):s("loadArrayBuffer error : "+i.response))},i.send(null)}},queryString:G,isArray:function(e){return e&&!e.propertyIsEnumerable("length")&&"object"==typeof e&&"number"==typeof e.length},isString:function(e){return"string"==typeof e||e instanceof String},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},isID:function(e){return j.isString(e)||j.isNumeric(e)},isSameComponent:function(e,t){return!(!e||!t)&&(j.isNumeric(e)||j.isString(e)?`${e}`:e.id)===(j.isNumeric(t)||j.isString(t)?`${t}`:t.id)},isFunction:function(e){return"function"==typeof e},isObject:function(e){const t={}.constructor;return!!e&&e.constructor===t},copy:function(e){return j.apply(e,{})},apply:function(e,t){for(const s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t},apply2:function(e,t){for(const s in e)e.hasOwnProperty(s)&&void 0!==e[s]&&null!==e[s]&&(t[s]=e[s]);return t},applyIf:function(e,t){for(const s in e)e.hasOwnProperty(s)&&(void 0!==t[s]&&null!==t[s]||(t[s]=e[s]));return t},isEmptyObject:function(e){for(const t in e)if(e.hasOwnProperty(t))return!1;return!0},inQuotes:function(e){return j.isNumeric(e)?`${e}`:`'${e}'`},concat:function(e,t){const s=new e.constructor(e.length+t.length);return s.set(e),s.set(t,e.length),s},flattenParentChildHierarchy:function(e){var t=[];return function e(s){s.id=s.uuid,delete s.oid,t.push(s);var i=s.children;if(i)for(var r=0,n=i.length;r<n;r++){i[r].parent=s.id,e(i[r])}s.children=[]}(e),t}},W={},z=new e,X=new V,K={sceneId:null,time:null,startTime:null,prevTime:null,deltaTime:null},Z=[];let J,Y=0,$=0;const q=new function(){this.version="1.0.0",this.scenes={},this._superTypes={},this._addScene=function(e){if(e.id){if(q.scenes[e.id])return void console.error(`[ERROR] Scene ${j.inQuotes(e.id)} already exists`)}else e.id=z.addItem({});q.scenes[e.id]=e;const t=e.ticksPerOcclusionTest,s=e.ticksPerRender;W[e.id]={ticksPerOcclusionTest:t,ticksPerRender:s,renderCountdown:s},L.components.scenes++,e.once("destroyed",(()=>{z.removeItem(e.id),delete q.scenes[e.id],delete W[e.id],L.components.scenes--}))},this.clear=function(){let e;for(const t in q.scenes)q.scenes.hasOwnProperty(t)&&(e=q.scenes[t],"default.scene"===t?e.clear():(e.destroy(),delete q.scenes[e.id]))},this.scheduleTask=function(e,t=null){X.push(e),X.push(t)},this.runTasks=function(e=-1){let t,s,i=(new Date).getTime(),r=0;for(;X.length>0&&(e<0||i<e);)t=X.shift(),s=X.shift(),s?t.call(s):t(),i=(new Date).getTime(),r++;return r},this.getNumTasks=function(){return X.length}},ee=function(){let e=Date.now();if(J=e-Y,Y>0&&J>0){var t=1e3/J;$+=t,Z.push(t),Z.length>=30&&($-=Z.shift()),L.frame.fps=Math.round($/Z.length)}for(let e in q.scenes)q.scenes[e].compile();se(e),Y=e};!function(e,t){let s=Date.now()+t;(function i(){const r=Date.now()-s;e(),s+=t,setTimeout(i,Math.max(0,t-r))})()}((()=>{ee()}),100);const te=function(){let e=Date.now();if(J=e-Y,Y>0&&J>0){var t=1e3/J;$+=t,Z.push(t),Z.length>=30&&($-=Z.shift()),L.frame.fps=Math.round($/Z.length)}se(e),function(e){for(var t in K.time=e,q.scenes)if(q.scenes.hasOwnProperty(t)){var s=q.scenes[t];K.sceneId=t,K.startTime=s.startTime,K.deltaTime=null!=K.prevTime?K.time-K.prevTime:0,s.fire("tick",K,!0)}K.prevTime=e}(e),function(){const e=q.scenes,t=!1;let s,i,r,n,A;for(A in e)e.hasOwnProperty(A)&&(s=e[A],i=W[A],i||(i=W[A]={}),r=s.ticksPerOcclusionTest,i.ticksPerOcclusionTest!==r&&(i.ticksPerOcclusionTest=r,i.renderCountdown=r),--s.occlusionTestCountdown<=0&&(s.doOcclusionTest(),s.occlusionTestCountdown=r),n=s.ticksPerRender,i.ticksPerRender!==n&&(i.ticksPerRender=n,i.renderCountdown=n),0==--i.renderCountdown&&(s.render(t),i.renderCountdown=n))}(),void 0!==window.requestPostAnimationFrame?window.requestPostAnimationFrame(ee):requestAnimationFrame(te)};function se(e){const t=q.runTasks(e+10),s=q.getNumTasks();L.frame.tasksRun=t,L.frame.tasksScheduled=s,L.frame.tasksBudget=10}te();class ie{get type(){return"Component"}get isComponent(){return!0}constructor(e=null,t={}){if(this.scene=null,"Scene"===this.type)this.scene=this,this.viewer=t.viewer;else{if("Scene"===e.type)this.scene=e;else{if(!(e instanceof ie))throw"Invalid param: owner must be a Component";this.scene=e.scene}this._owner=e}this._dontClear=!!t.dontClear,this._renderer=this.scene._renderer,this.meta=t.meta||{},this.id=t.id,this.destroyed=!1,this._attached={},this._attachments=null,this._subIdMap=null,this._subIdEvents=null,this._eventSubs=null,this._eventSubsNum=null,this._events=null,this._eventCallDepth=0,this._ownedComponents=null,this!==this.scene&&this.scene._addComponent(this),this._updateScheduled=!1,e&&e._own(this)}glRedraw(){this._renderer&&(this._renderer.imageDirty(),this.castsShadow&&this._renderer.shadowsDirty())}glResort(){this._renderer&&this._renderer.needStateSort()}get owner(){return this._owner}isType(e){return this.type===e}fire(e,t,s){this._events||(this._events={}),this._eventSubs||(this._eventSubs={},this._eventSubsNum={}),!0!==s&&(this._events[e]=t||!0);const i=this._eventSubs[e];let r;if(i)for(const s in i)i.hasOwnProperty(s)&&(r=i[s],this._eventCallDepth++,this._eventCallDepth<300?r.callback.call(r.scope,t):this.error("fire: potential stack overflow from recursive event '"+e+"' - dropping this event"),this._eventCallDepth--)}on(t,s,i){this._events||(this._events={}),this._subIdMap||(this._subIdMap=new e),this._subIdEvents||(this._subIdEvents={}),this._eventSubs||(this._eventSubs={}),this._eventSubsNum||(this._eventSubsNum={});let r=this._eventSubs[t];r?this._eventSubsNum[t]++:(r={},this._eventSubs[t]=r,this._eventSubsNum[t]=1);const n=this._subIdMap.addItem();r[n]={callback:s,scope:i||this},this._subIdEvents[n]=t;const A=this._events[t];return void 0!==A&&s.call(i||this,A),n}off(e){if(null==e)return;if(!this._subIdEvents)return;const t=this._subIdEvents[e];if(t){delete this._subIdEvents[e];const s=this._eventSubs[t];s&&(delete s[e],this._eventSubsNum[t]--),this._subIdMap.removeItem(e)}}once(e,t,s){const i=this,r=this.on(e,(function(e){i.off(r),t.call(s||this,e)}),s)}hasSubs(e){return this._eventSubsNum&&this._eventSubsNum[e]>0}log(e){e="[LOG]"+this._message(e),window.console.log(e),this.scene.fire("log",e)}_message(e){return" ["+this.type+" "+j.inQuotes(this.id)+"]: "+e}warn(e){e="[WARN]"+this._message(e),window.console.warn(e),this.scene.fire("warn",e)}error(e){e="[ERROR]"+this._message(e),window.console.error(e),this.scene.fire("error",e)}_attach(e){const t=e.name;if(!t)return void this.error("Component 'name' expected");let s=e.component;const i=e.sceneDefault,r=e.sceneSingleton,n=e.type,A=e.on,o=!1!==e.recompiles;if(s&&(j.isNumeric(s)||j.isString(s))){const e=s;if(s=this.scene.components[e],!s)return void this.error("Component not found: "+j.inQuotes(e))}if(!s)if(!0===r){const e=this.scene.types[n];for(const t in e)if(e.hasOwnProperty){s=e[t];break}if(!s)return this.error("Scene has no default component for '"+t+"'"),null}else if(!0===i&&(s=this.scene[t],!s))return this.error("Scene has no default component for '"+t+"'"),null;if(s){if(s.scene.id!==this.scene.id)return void this.error("Not in same scene: "+s.type+" "+j.inQuotes(s.id));if(n&&!s.isType(n))return void this.error("Expected a "+n+" type or subtype: "+s.type+" "+j.inQuotes(s.id))}this._attachments||(this._attachments={});const a=this._attached[t];let l,c,h;if(a){if(s&&a.id===s.id)return;const e=this._attachments[a.id];for(l=e.subs,c=0,h=l.length;c<h;c++)a.off(l[c]);delete this._attached[t],delete this._attachments[a.id];const i=e.params.onDetached;i&&(j.isFunction(i)?i(a):i.scope?i.callback.call(i.scope,a):i.callback(a)),e.managingLifecycle&&a.destroy()}if(s){const i={params:e,component:s,subs:[],managingLifecycle:false};i.subs.push(s.once("destroyed",(function(){i.params.component=null,this._attach(i.params)}),this)),o&&i.subs.push(s.on("dirty",(function(){this.fire("dirty",this)}),this)),this._attached[t]=s,this._attachments[s.id]=i;const r=e.onAttached;if(r&&(j.isFunction(r)?r(s):r.scope?r.callback.call(r.scope,s):r.callback(s)),A){let e,t,r,n;for(e in A)if(A.hasOwnProperty(e)){if(t=A[e],j.isFunction(t)?(r=t,n=null):(r=t.callback,n=t.scope),!r)continue;i.subs.push(s.on(e,r,n))}}}return o&&this.fire("dirty",this),this.fire(t,s),s}_checkComponent(e,t){if(!t.isComponent){if(!j.isID(t))return void this.error("Expected a Component or ID");{const e=t;if(!(t=this.scene.components[e]))return void this.error("Component not found: "+e)}}if(e===t.type){if(t.scene.id===this.scene.id)return t;this.error("Not in same scene: "+t.type)}else this.error("Expected a "+e+" Component")}_checkComponent2(e,t){if(!t.isComponent){if(!j.isID(t))return void this.error("Expected a Component or ID");{const e=t;if(!(t=this.scene.components[e]))return void this.error("Component not found: "+e)}}if(t.scene.id===this.scene.id){for(var s=0,i=e.length;s<i;s++)if(e[s]===t.type)return t;return this.error("Expected component types: "+e),null}this.error("Not in same scene: "+t.type)}_own(e){this._ownedComponents||(this._ownedComponents={}),this._ownedComponents[e.id]||(this._ownedComponents[e.id]=e),e.once("destroyed",(()=>{delete this._ownedComponents[e.id]}),this)}_needUpdate(e){this._updateScheduled||(this._updateScheduled=!0,0===e?this._doUpdate():q.scheduleTask(this._doUpdate,this))}_doUpdate(){this._updateScheduled&&(this._updateScheduled=!1,this._update&&this._update())}scheduleTask(e){q.scheduleTask(e,null)}_update(){}clear(){if(this._ownedComponents)for(var e in this._ownedComponents)if(this._ownedComponents.hasOwnProperty(e)){this._ownedComponents[e].destroy(),delete this._ownedComponents[e]}}destroy(){if(this.destroyed)return;let e,t,s,i,r,n;if(this.fire("destroyed",this.destroyed=!0),this._attachments)for(e in this._attachments)if(this._attachments.hasOwnProperty(e)){for(t=this._attachments[e],s=t.component,i=t.subs,r=0,n=i.length;r<n;r++)s.off(i[r]);t.managingLifecycle&&s.destroy()}if(this._ownedComponents)for(e in this._ownedComponents)this._ownedComponents.hasOwnProperty(e)&&(s=this._ownedComponents[e],s.destroy(),delete this._ownedComponents[e]);this.scene._removeComponent(this),this._attached={},this._attachments=null,this._subIdMap=null,this._subIdEvents=null,this._eventSubs=null,this._events=null,this._eventCallDepth=0,this._ownedComponents=null,this._updateScheduled=!1,this._renderer=null}}const re=R.vec3(),ne=R.vec3(),Ae=R.mat4();class oe{constructor(){this.normal=R.vec3(),this.offset=0,this.testVertex=R.vec3()}set(e,t,s,i){const r=1/Math.sqrt(e*e+t*t+s*s);this.normal[0]=e*r,this.normal[1]=t*r,this.normal[2]=s*r,this.offset=i*r,this.testVertex[0]=this.normal[0]>=0?1:0,this.testVertex[1]=this.normal[1]>=0?1:0,this.testVertex[2]=this.normal[2]>=0?1:0}}class ae{constructor(){this.planes=[new oe,new oe,new oe,new oe,new oe,new oe]}}function le(e,t,s){const i=R.mulMat4(s,t,Ae),r=i[0],n=i[1],A=i[2],o=i[3],a=i[4],l=i[5],c=i[6],h=i[7],u=i[8],d=i[9],p=i[10],f=i[11],g=i[12],m=i[13],_=i[14],b=i[15];e.planes[0].set(o-r,h-a,f-u,b-g),e.planes[1].set(o+r,h+a,f+u,b+g),e.planes[2].set(o-n,h-l,f-d,b-m),e.planes[3].set(o+n,h+l,f+d,b+m),e.planes[4].set(o-A,h-c,f-p,b-_),e.planes[5].set(o+A,h+c,f+p,b+_)}function ce(e,t){let s=ae.INSIDE;const i=re,r=ne;i[0]=t[0],i[1]=t[1],i[2]=t[2],r[0]=t[3],r[1]=t[4],r[2]=t[5];const n=[i,r];for(let t=0;t<6;++t){const i=e.planes[t];if(i.normal[0]*n[i.testVertex[0]][0]+i.normal[1]*n[i.testVertex[1]][1]+i.normal[2]*n[i.testVertex[2]][2]+i.offset<0)return ae.OUTSIDE;i.normal[0]*n[1-i.testVertex[0]][0]+i.normal[1]*n[1-i.testVertex[1]][1]+i.normal[2]*n[1-i.testVertex[2]][2]+i.offset<0&&(s=ae.INTERSECT)}return s}ae.INSIDE=0,ae.INTERSECT=1,ae.OUTSIDE=2;class he extends ie{constructor(e={}){if(!e.viewer)throw"[MarqueePicker] Missing config: viewer";if(!e.objectsKdTree3)throw"[MarqueePicker] Missing config: objectsKdTree3";super(e.viewer.scene,e),this.viewer=e.viewer,this._objectsKdTree3=e.objectsKdTree3,this._canvasMarqueeCorner1=R.vec2(),this._canvasMarqueeCorner2=R.vec2(),this._canvasMarquee=R.AABB2(),this._marqueeFrustum=new ae,this._marqueeFrustumProjMat=R.mat4(),this._pickMode=!1,this._marqueeElement=document.createElement("div"),document.body.appendChild(this._marqueeElement),this._marqueeElement.style.position="absolute",this._marqueeElement.style["z-index"]="40000005",this._marqueeElement.style.width="8px",this._marqueeElement.style.height="8px",this._marqueeElement.style.visibility="hidden",this._marqueeElement.style.top="0px",this._marqueeElement.style.left="0px",this._marqueeElement.style["box-shadow"]="0 2px 5px 0 #182A3D;",this._marqueeElement.style.opacity=1,this._marqueeElement.style["pointer-events"]="none"}setMarqueeCorner1(e){this._canvasMarqueeCorner1.set(e),this._canvasMarqueeCorner2.set(e),this._updateMarquee()}setMarqueeCorner2(e){this._canvasMarqueeCorner2.set(e),this._updateMarquee()}setMarquee(e,t){this._canvasMarqueeCorner1.set(e),this._canvasMarqueeCorner2.set(t),this._updateMarquee()}setMarqueeVisible(e){this._marqueVisible=e,this._marqueeElement.style.visibility=e?"visible":"hidden"}getMarqueeVisible(){return this._marqueVisible}setPickMode(e){if(e!==he.PICK_MODE_INSIDE&&e!==he.PICK_MODE_INTERSECTS)throw"Illegal MarqueePicker pickMode: must be MarqueePicker.PICK_MODE_INSIDE or MarqueePicker.PICK_MODE_INTERSECTS";e!==this._pickMode&&(this._marqueeElement.style["background-image"]=e===he.PICK_MODE_INSIDE?"url(\"data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='6' ry='6' stroke='%23333' stroke-width='4'/%3e%3c/svg%3e\")":"url(\"data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='6' ry='6' stroke='%23333' stroke-width='4' stroke-dasharray='6%2c 14' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e\")",this._pickMode=e)}getPickMode(){return this._pickMode}clear(){this.fire("clear",{})}pick(){this._updateMarquee(),this._buildMarqueeFrustum();const e=[],t=(s,i=ae.INTERSECT)=>{if(i===ae.INTERSECT&&(i=ce(this._marqueeFrustum,s.aabb)),i!==ae.OUTSIDE){if(s.entities){const t=s.entities;for(let s=0,i=t.length;s<i;s++){const i=t[s];if(!i.visible)continue;const r=i.aabb;if(this._pickMode===he.PICK_MODE_INSIDE){ce(this._marqueeFrustum,r)===ae.INSIDE&&e.push(i.id)}else{ce(this._marqueeFrustum,r)!==ae.OUTSIDE&&e.push(i.id)}}}s.left&&t(s.left,i),s.right&&t(s.right,i)}};return(this._canvasMarquee[2]-this._canvasMarquee[0]>3||this._canvasMarquee[3]-this._canvasMarquee[1]>3)&&t(this._objectsKdTree3.root),this.fire("picked",e),e}_updateMarquee(){this._canvasMarquee[0]=Math.min(this._canvasMarqueeCorner1[0],this._canvasMarqueeCorner2[0]),this._canvasMarquee[1]=Math.min(this._canvasMarqueeCorner1[1],this._canvasMarqueeCorner2[1]),this._canvasMarquee[2]=Math.max(this._canvasMarqueeCorner1[0],this._canvasMarqueeCorner2[0]),this._canvasMarquee[3]=Math.max(this._canvasMarqueeCorner1[1],this._canvasMarqueeCorner2[1]),this._marqueeElement.style.width=this._canvasMarquee[2]-this._canvasMarquee[0]+"px",this._marqueeElement.style.height=this._canvasMarquee[3]-this._canvasMarquee[1]+"px",this._marqueeElement.style.left=`${this._canvasMarquee[0]}px`,this._marqueeElement.style.top=`${this._canvasMarquee[1]}px`}_buildMarqueeFrustum(){const e=this.viewer.scene.canvas.canvas,t=e.clientWidth,s=e.clientHeight,i=e.clientLeft,r=e.clientTop,n=2/t,A=2/s,o=e.clientHeight/e.clientWidth,a=(this._canvasMarquee[0]-i)*n-1,l=(this._canvasMarquee[2]-i)*n-1,c=-(this._canvasMarquee[3]-r)*A+1,h=-(this._canvasMarquee[1]-r)*A+1,u=this.viewer.scene.camera.frustum.near*(17*o);R.frustumMat4(a,l,c*o,h*o,u,1e4,this._marqueeFrustumProjMat),le(this._marqueeFrustum,this.viewer.scene.camera.viewMatrix,this._marqueeFrustumProjMat)}destroy(){super.destroy(),this._marqueeElement.parentElement&&(this._marqueeElement.parentElement.removeChild(this._marqueeElement),this._marqueeElement=null,this._objectsKdTree3=null)}}he.PICK_MODE_INTERSECTS=0,he.PICK_MODE_INSIDE=1;class ue{constructor(e,t={}){this.viewer=e,this.scene=this.viewer.scene,this._circleDiv=document.createElement("div"),this.viewer.scene.canvas.canvas.parentNode.insertBefore(this._circleDiv,this.viewer.scene.canvas.canvas),this._circleDiv.style.backgroundColor="transparent",this._circleDiv.style.border="2px solid green",this._circleDiv.style.borderRadius="50px",this._circleDiv.style.width="50px",this._circleDiv.style.height="50px",this._circleDiv.style.margin="-200px -200px",this._circleDiv.style.zIndex="100000",this._circleDiv.style.position="absolute",this._circleDiv.style.pointerEvents="none",this._circlePos=null,this._circleMaxRadius=200,this._circleMinRadius=2,this._active=!1!==t.active,this._visible=!1,this._running=!1,this._destroyed=!1}start(e){if(this._destroyed)return;this._circlePos=e,this._running=!1,this._circleRadius=this._circleMaxRadius,this._circleDiv.style.borderRadius=`${this._circleRadius}px`,this._circleDiv.style.marginLeft=this._circlePos[0]-this._circleRadius+"px",this._circleDiv.style.marginTop=this._circlePos[1]-this._circleRadius+"px";const t=this._circleMaxRadius;let s;const i=e=>{if(!this._running)return;s||(s=e);const r=e-s,n=Math.min(r/300,1),A=t+(2-t)*n;this._circleRadius=A,this._circleDiv.style.width=`${this._circleRadius}px`,this._circleDiv.style.height=`${this._circleRadius}px`,this._circleDiv.style.marginLeft=this._circlePos[0]-this._circleRadius/2+"px",this._circleDiv.style.marginTop=this._circlePos[1]-this._circleRadius/2+"px",n<1&&requestAnimationFrame(i)};this._running=!0,requestAnimationFrame(i),this._circleDiv.style.visibility="visible"}stop(){this._destroyed||(this._running=!1,this._circleRadius=this._circleMaxRadius,this._circleDiv.style.borderRadius=`${this._circleRadius}px`,this._circleDiv.style.visibility="hidden")}set durationMs(e){this.stop(),this._durationMs=e}get durationMs(){return this._durationMs}destroy(){this._destroyed||(this.stop(),this._circleDiv.parentElement.removeChild(this._circleDiv),this._destroyed=!0)}}class de{constructor(e={}){this._eventSubIDMap=null,this._eventSubEvents=null,this._eventSubs=null,this._events=null,this._locale="en",this._messages={},this._locales=[],this._locale="en",this.messages=e.messages,this.locale=e.locale}set messages(e){this._messages=e||{},this._locales=Object.keys(this._messages),this.fire("updated",this)}loadMessages(e={}){for(let t in e)this._messages[t]=e[t];this.messages=this._messages}clearMessages(){this.messages={}}get locales(){return this._locales}set locale(e){e=e||"de",this._locale!==e&&(this._locale=e,this.fire("updated",e))}get locale(){return this._locale}translate(e,t){const s=this._messages[this._locale];if(!s)return null;const i=pe(e,s);return i?t?fe(i,t):i:null}translatePlurals(e,t,s){const i=this._messages[this._locale];if(!i)return null;let r=pe(e,i);return r=0===(t=parseInt(""+t,10))?r.zero:t>1?r.other:r.one,r?(r=fe(r,[t]),s&&(r=fe(r,s)),r):null}fire(e,t,s){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==s&&(this._events[e]=t||!0);const i=this._eventSubs[e];if(i)for(const e in i)if(i.hasOwnProperty(e)){i[e].callback(t)}}on(t,s){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new e),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});let i=this._eventSubs[t];i||(i={},this._eventSubs[t]=i);const r=this._eventSubIDMap.addItem();i[r]={callback:s},this._eventSubEvents[r]=t;const n=this._events[t];return void 0!==n&&s(n),r}off(e){if(null==e)return;if(!this._eventSubEvents)return;const t=this._eventSubEvents[e];if(t){delete this._eventSubEvents[e];const s=this._eventSubs[t];s&&delete s[e],this._eventSubIDMap.removeItem(e)}}}function pe(e,t){if(t[e])return t[e];const s=e.split(".");let i=t;for(let e=0,t=s.length;i&&e<t;e++){i=i[s[e]]}return i}function fe(e,t=[]){return e.replace(/\{\{|\}\}|\{(\d+)\}/g,(function(e,s){return"{{"===e?"{":"}}"===e?"}":t[s]}))}class ge extends ie{constructor(e,t={}){super(e,t),this.t=t.t}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get tangent(){return this.getTangent(this._t)}get length(){var e=this._getLengths();return e[e.length-1]}getTangent(e){var t=1e-4;void 0===e&&(e=this._t);var s=e-t,i=e+t;s<0&&(s=0),i>1&&(i=1);var r=this.getPoint(s),n=this.getPoint(i),A=R.subVec3(n,r,[]);return R.normalizeVec3(A,[])}getPointAt(e){var t=this.getUToTMapping(e);return this.getPoint(t)}getPoints(e){e||(e=5);var t,s=[];for(t=0;t<=e;t++)s.push(this.getPoint(t/e));return s}_getLengths(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,s,i=[],r=this.getPoint(0),n=0;for(i.push(0),s=1;s<=e;s++)t=this.getPoint(s/e),n+=R.lenVec3(R.subVec3(t,r,[])),i.push(n),r=t;return this.cacheArcLengths=i,i}_updateArcLengths(){this.needsUpdate=!0,this._getLengths()}getUToTMapping(e,t){var s,i=this._getLengths(),r=0,n=i.length;s=t||e*i[n-1];for(var A,o=0,a=n-1;o<=a;)if((A=i[r=Math.floor(o+(a-o)/2)]-s)<0)o=r+1;else{if(!(A>0)){a=r;break}a=r-1}if(i[r=a]===s)return r/(n-1);var l=i[r];return(r+(s-l)/(i[r+1]-l))/(n-1)}}class me extends ge{constructor(e,t={}){super(e,t),this.points=t.points,this.t=t.t}set points(e){this._points=e||[]}get points(){return this._points}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=this.points;if(!(t.length<3)){var s=(t.length-1)*e,i=Math.floor(s),r=s-i,n=t[0===i?i:i-1],A=t[i],o=t[i>t.length-2?t.length-1:i+1],a=t[i>t.length-3?t.length-1:i+2],l=R.vec3();return l[0]=R.catmullRomInterpolate(n[0],A[0],o[0],a[0],r),l[1]=R.catmullRomInterpolate(n[1],A[1],o[1],a[1],r),l[2]=R.catmullRomInterpolate(n[2],A[2],o[2],a[2],r),l}this.error("Can't sample point from SplineCurve - not enough points on curve - returning [0,0,0].")}getJSON(){return{points:points,t:this._t}}}const _e=R.vec3();const be=R.vec3(),Be=R.vec3(),ye=R.vec3(),we=R.vec3(),ve=R.vec3();class Ce extends ie{get type(){return"CameraFlightAnimation"}constructor(e,t={}){super(e,t),this._look1=R.vec3(),this._eye1=R.vec3(),this._up1=R.vec3(),this._look2=R.vec3(),this._eye2=R.vec3(),this._up2=R.vec3(),this._orthoScale1=1,this._orthoScale2=1,this._flying=!1,this._flyEyeLookUp=!1,this._flyingEye=!1,this._flyingLook=!1,this._callback=null,this._callbackScope=null,this._time1=null,this._time2=null,this.easing=!1!==t.easing,this.duration=t.duration,this.fit=t.fit,this.fitFOV=t.fitFOV,this.trail=t.trail}flyTo(e,t,s){e=e||this.scene,this._flying&&this.stop(),this._flying=!1,this._flyingEye=!1,this._flyingLook=!1,this._flyingEyeLookUp=!1,this._callback=t,this._callbackScope=s;const i=this.scene.camera,r=!!e.projection&&e.projection!==i.projection;let n,A,o,a,l;if(this._eye1[0]=i.eye[0],this._eye1[1]=i.eye[1],this._eye1[2]=i.eye[2],this._look1[0]=i.look[0],this._look1[1]=i.look[1],this._look1[2]=i.look[2],this._up1[0]=i.up[0],this._up1[1]=i.up[1],this._up1[2]=i.up[2],this._orthoScale1=i.ortho.scale,this._orthoScale2=e.orthoScale||this._orthoScale1,e.aabb)n=e.aabb;else if(6===e.length)n=e;else if(e.eye&&e.look||e.up)A=e.eye,o=e.look,a=e.up;else if(e.eye)A=e.eye;else if(e.look)o=e.look;else{let i=e;if((j.isNumeric(i)||j.isString(i))&&(l=i,i=this.scene.components[l],!i))return this.error("Component not found: "+j.inQuotes(l)),void(t&&(s?t.call(s):t()));r||(n=i.aabb||this.scene.aabb)}const c=e.poi;if(n){if(n[3]<n[0]||n[4]<n[1]||n[5]<n[2])return;if(n[3]===n[0]&&n[4]===n[1]&&n[5]===n[2])return;n=n.slice();const t=R.getAABB3Center(n);this._look2=c||t;const s=R.subVec3(this._eye1,this._look1,be),i=R.normalizeVec3(s),r=c?R.getAABB3DiagPoint(n,c):R.getAABB3Diag(n),A=e.fitFOV||this._fitFOV,o=Math.abs(r/Math.tan(A*R.DEGTORAD));this._orthoScale2=1.1*r,this._eye2[0]=this._look2[0]+i[0]*o,this._eye2[1]=this._look2[1]+i[1]*o,this._eye2[2]=this._look2[2]+i[2]*o,this._up2[0]=this._up1[0],this._up2[1]=this._up1[1],this._up2[2]=this._up1[2],this._flyingEyeLookUp=!0}else(A||o||a)&&(this._flyingEyeLookUp=!!A&&!!o&&!!a,this._flyingEye=!!A&&!o,this._flyingLook=!!o&&!A,A&&(this._eye2[0]=A[0],this._eye2[1]=A[1],this._eye2[2]=A[2]),o&&(this._look2[0]=o[0],this._look2[1]=o[1],this._look2[2]=o[2]),a&&(this._up2[0]=a[0],this._up2[1]=a[1],this._up2[2]=a[2]));r?("ortho"===e.projection&&"ortho"!==i.projection&&(this._projection2="ortho",this._projMatrix1=i.projMatrix.slice(),this._projMatrix2=i.ortho.matrix.slice(),i.projection="customProjection"),"perspective"===e.projection&&"perspective"!==i.projection&&(this._projection2="perspective",this._projMatrix1=i.projMatrix.slice(),this._projMatrix2=i.perspective.matrix.slice(),i.projection="customProjection")):this._projection2=null,this.fire("started",e,!0),this._time1=Date.now(),this._time2=this._time1+(Number.isFinite(e.duration)?1e3*e.duration:this._duration),this._flying=!0,q.scheduleTask(this._update,this)}jumpTo(e){this._jumpTo(e)}_jumpTo(e){this._flying&&this.stop();const t=this.scene.camera;var s,i,r,n,A;if(e.aabb)s=e.aabb;else if(6===e.length)s=e;else if(e.eye||e.look||e.up)r=e.eye,n=e.look,A=e.up;else{let t=e;if((j.isNumeric(t)||j.isString(t))&&(i=t,t=this.scene.components[i],!t))return void this.error("Component not found: "+j.inQuotes(i));s=t.aabb||this.scene.aabb}const o=e.poi;if(s){if(s[3]<=s[0]||s[4]<=s[1]||s[5]<=s[2])return;var a=o?R.getAABB3DiagPoint(s,o):R.getAABB3Diag(s);let i;n=o||R.getAABB3Center(s,n),this._trail?R.subVec3(t.look,n,ve):R.subVec3(t.eye,t.look,ve),R.normalizeVec3(ve);i=(void 0!==e.fit?e.fit:this._fit)?Math.abs(a/Math.tan((e.fitFOV||this._fitFOV)*R.DEGTORAD)):R.lenVec3(R.subVec3(t.eye,t.look,be)),R.mulVec3Scalar(ve,i),t.eye=R.addVec3(n,ve,be),t.look=n,this.scene.camera.ortho.scale=1.1*a}else(r||n||A)&&(r&&(t.eye=r),n&&(t.look=n),A&&(t.up=A));e.projection&&(t.projection=e.projection)}_update(){if(!this._flying)return;let e=(Date.now()-this._time1)/(this._time2-this._time1);const t=e>=1;e>1&&(e=1);const s=this.easing?Ce._ease(e,0,1,1):e,i=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?(R.subVec3(i.eye,i.look,ve),i.eye=R.lerpVec3(s,0,1,this._eye1,this._eye2,ye),i.look=R.subVec3(ye,ve,Be)):this._flyingLook&&(i.look=R.lerpVec3(s,0,1,this._look1,this._look2,Be),i.up=R.lerpVec3(s,0,1,this._up1,this._up2,we)):this._flyingEyeLookUp&&(i.eye=R.lerpVec3(s,0,1,this._eye1,this._eye2,ye),i.look=R.lerpVec3(s,0,1,this._look1,this._look2,Be),i.up=R.lerpVec3(s,0,1,this._up1,this._up2,we)),this._projection2){const t="ortho"===this._projection2?Ce._easeOutExpo(e,0,1,1):Ce._easeInCubic(e,0,1,1);i.customProjection.matrix=R.lerpMat4(t,0,1,this._projMatrix1,this._projMatrix2)}else i.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return i.ortho.scale=this._orthoScale2,void this.stop();q.scheduleTask(this._update,this)}static _ease(e,t,s,i){return-s*(e/=i)*(e-2)+t}static _easeInCubic(e,t,s,i){return s*(e/=i)*e*e+t}static _easeOutExpo(e,t,s,i){return s*(1-Math.pow(2,-10*e/i))+t}stop(){if(!this._flying)return;this._flying=!1,this._time1=null,this._time2=null,this._projection2&&(this.scene.camera.projection=this._projection2);const e=this._callback;e&&(this._callback=null,this._callbackScope?e.call(this._callbackScope):e()),this.fire("stopped",!0,!0)}cancel(){this._flying&&(this._flying=!1,this._time1=null,this._time2=null,this._callback&&(this._callback=null),this.fire("canceled",!0,!0))}set duration(e){this._duration=Number.isFinite(e)?1e3*e:500,this.stop()}get duration(){return this._duration/1e3}set fit(e){this._fit=!1!==e}get fit(){return this._fit}set fitFOV(e){this._fitFOV=e||45}get fitFOV(){return this._fitFOV}set trail(e){this._trail=!!e}get trail(){return this._trail}destroy(){this.stop(),super.destroy()}}class Me extends ie{get type(){return"CameraPathAnimation"}constructor(e,t={}){super(e,t),this._cameraFlightAnimation=new Ce(this),this._t=0,this.state=Me.SCRUBBING,this._playingFromT=0,this._playingToT=0,this._playingRate=t.playingRate||1,this._playingDir=1,this._lastTime=null,this.cameraPath=t.cameraPath,this._tick=this.scene.on("tick",this._updateT,this)}_updateT(){const e=this._cameraPath;if(!e)return;let t,s;const i=performance.now(),r=this._lastTime?.001*(i-this._lastTime):0;if(this._lastTime=i,0!==r)switch(this.state){case Me.SCRUBBING:return;case Me.PLAYING:if(this._t+=this._playingRate*r,t=this._cameraPath.frames.length,0===t||this._playingDir<0&&this._t<=0||this._playingDir>0&&this._t>=this._cameraPath.frames[t-1].t)return this.state=Me.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case Me.PLAYING_TO:s=this._t+this._playingRate*r*this._playingDir,(this._playingDir<0&&s<=this._playingToT||this._playingDir>0&&s>=this._playingToT)&&(s=this._playingToT,this.state=Me.SCRUBBING,this.fire("stopped")),this._t=s,e.loadFrame(this._t)}}_ease(e,t,s,i){return-s*(e/=i)*(e-2)+t}set cameraPath(e){this._cameraPath=e}get cameraPath(){return this._cameraPath}set rate(e){this._playingRate=e}get rate(){return this._playingRate}play(){this._cameraPath&&(this._lastTime=null,this.state=Me.PLAYING)}playToT(e){this._cameraPath&&(this._playingFromT=this._t,this._playingToT=e,this._playingDir=this._playingToT-this._playingFromT<0?-1:1,this._lastTime=null,this.state=Me.PLAYING_TO)}playToFrame(e){const t=this._cameraPath;if(!t)return;const s=t.frames[e];s?this.playToT(s.t):this.error("playToFrame - frame index out of range: "+e)}flyToFrame(e,t){const s=this._cameraPath;if(!s)return;const i=s.frames[e];i?(this.state=Me.SCRUBBING,this._cameraFlightAnimation.flyTo(i,t)):this.error("flyToFrame - frame index out of range: "+e)}scrubToT(e){const t=this._cameraPath;if(!t)return;this.scene.camera&&(this._t=e,t.loadFrame(this._t),this.state=Me.SCRUBBING)}scrubToFrame(e){const t=this._cameraPath;if(!t)return;if(!this.scene.camera)return;t.frames[e]?(t.loadFrame(this._t),this.state=Me.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)}stop(){this.state=Me.SCRUBBING,this.fire("stopped")}destroy(){super.destroy(),this.scene.off(this._tick)}}Me.STOPPED=0,Me.SCRUBBING=1,Me.PLAYING=2,Me.PLAYING_TO=3;class Ee extends ie{get type(){return"Geometry"}get isGeometry(){return!0}constructor(e,t={}){super(e,t),L.memory.meshes++}destroy(){super.destroy(),L.memory.meshes--}}const Fe=new e({});class xe{constructor(e){this.id=Fe.addItem({});for(const t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}destroy(){Fe.removeItem(this.id)}}class Ue{constructor(e,t,s,i,r,n,A,o,a){switch(this._gl=e,this.type=t,this.allocated=!1,s.constructor){case Uint8Array:this.itemType=e.UNSIGNED_BYTE,this.itemByteSize=1;break;case Int8Array:this.itemType=e.BYTE,this.itemByteSize=1;break;case Uint16Array:this.itemType=e.UNSIGNED_SHORT,this.itemByteSize=2;break;case Int16Array:this.itemType=e.SHORT,this.itemByteSize=2;break;case Uint32Array:this.itemType=e.UNSIGNED_INT,this.itemByteSize=4;break;case Int32Array:this.itemType=e.INT,this.itemByteSize=4;break;default:this.itemType=e.FLOAT,this.itemByteSize=4}this.usage=n,this.length=0,this.dataLength=i,this.numItems=0,this.itemSize=r,this.normalized=!!A,this.stride=o||0,this.offset=a||0,this._allocate(s)}_allocate(e){if(this.allocated=!1,this._handle=this._gl.createBuffer(),!this._handle)throw"Failed to allocate WebGL ArrayBuffer";this._handle&&(this._gl.bindBuffer(this.type,this._handle),this._gl.bufferData(this.type,e.length>this.dataLength?e.slice(0,this.dataLength):e,this.usage),this._gl.bindBuffer(this.type,null),this.length=e.length,this.numItems=this.length/this.itemSize,this.allocated=!0)}setData(e,t){this.allocated&&(e.length+(t||0)>this.length?(this.destroy(),this._allocate(e)):(this._gl.bindBuffer(this.type,this._handle),t||0===t?this._gl.bufferSubData(this.type,t*this.itemByteSize,e):this._gl.bufferData(this.type,e,this.usage),this._gl.bindBuffer(this.type,null)))}bind(){this.allocated&&this._gl.bindBuffer(this.type,this._handle)}unbind(){this.allocated&&this._gl.bindBuffer(this.type,null)}bindAtLocation(e){this.bind(),this._gl.vertexAttribPointer(e,this.itemSize,this.itemType,this.normalized,0,0)}destroy(){this.allocated&&(this._gl.deleteBuffer(this._handle),this._handle=null,this.allocated=!1)}}var Ie=function(){const e=[],t=[],s=[],i=[],r=[];let n=0;const A=new Uint16Array(3),o=new Uint16Array(3),a=new Uint16Array(3),l=R.vec3(),c=R.vec3(),h=R.vec3(),u=R.vec3(),d=R.vec3(),p=R.vec3(),f=R.vec3();return function(g,m,_,b){!function(r,n){const A={};let o,a,l,c;const h=Math.pow(10,4);let u,d,p=0;for(u=0,d=r.length;u<d;u+=3)o=r[u],a=r[u+1],l=r[u+2],c=Math.round(o*h)+"_"+Math.round(a*h)+"_"+Math.round(l*h),void 0===A[c]&&(A[c]=p/3,e[p++]=o,e[p++]=a,e[p++]=l),t[u/3]=A[c];for(u=0,d=n.length;u<d;u++)i[u]=t[n[u]],s[i[u]]=n[u]}(g,m),function(t,s){n=0;for(let g=0,m=t;g<m;g+=3){const t=3*i[g],m=3*i[g+1],_=3*i[g+2];s?(A[0]=e[t],A[1]=e[t+1],A[2]=e[t+2],o[0]=e[m],o[1]=e[m+1],o[2]=e[m+2],a[0]=e[_],a[1]=e[_+1],a[2]=e[_+2],R.decompressPosition(A,s,l),R.decompressPosition(o,s,c),R.decompressPosition(a,s,h)):(l[0]=e[t],l[1]=e[t+1],l[2]=e[t+2],c[0]=e[m],c[1]=e[m+1],c[2]=e[m+2],h[0]=e[_],h[1]=e[_+1],h[2]=e[_+2]),R.subVec3(h,c,u),R.subVec3(l,c,d),R.cross3Vec3(u,d,p),R.normalizeVec3(p,f);const b=r[n]||(r[n]={normal:R.vec3()});b.normal[0]=f[0],b.normal[1]=f[1],b.normal[2]=f[2],n++}}(m.length,_);const B=[],y=Math.cos(R.DEGTORAD*b),w={};let v,C,M,E,F,x,U,I,T,P,S,D=!1;for(let e=0,t=m.length;e<t;e+=3){const t=e/3;for(let s=0;s<3;s++)v=i[e+s],C=i[e+(s+1)%3],M=Math.min(v,C),E=Math.max(v,C),F=M+","+E,void 0===w[F]?w[F]={index1:M,index2:E,face1:t,face2:void 0}:w[F].face2=t}for(F in w)x=w[F],void 0!==x.face2&&(U=r[x.face1].normal,I=r[x.face2].normal,T=R.dotVec3(U,I),T>y)||(P=s[x.index1],S=s[x.index2],(!D&&P>65535||S>65535)&&(D=!0),B.push(P),B.push(S));return D?new Uint32Array(B):new Uint16Array(B)}}();const Te=function(){const e=R.mat4(),t=R.mat4();return function(s,i){i=i||R.mat4();const r=s[0],n=s[1],A=s[2],o=s[3]-r,a=s[4]-n,l=s[5]-A,c=65535;return R.identityMat4(e),R.translationMat4v(s,e),R.identityMat4(t),R.scalingMat4v([o/c,a/c,l/c],t),R.mulMat4(e,t,i),i}}();var Pe=function(){const e=R.mat4(),t=R.mat4();return function(s,i,r){const n=new Uint16Array(s.length),A=new Float32Array([r[0]!==i[0]?65535/(r[0]-i[0]):0,r[1]!==i[1]?65535/(r[1]-i[1]):0,r[2]!==i[2]?65535/(r[2]-i[2]):0]);let o;for(o=0;o<s.length;o+=3)n[o+0]=Math.max(0,Math.min(65535,Math.floor((s[o+0]-i[0])*A[0]))),n[o+1]=Math.max(0,Math.min(65535,Math.floor((s[o+1]-i[1])*A[1]))),n[o+2]=Math.max(0,Math.min(65535,Math.floor((s[o+2]-i[2])*A[2])));R.identityMat4(e),R.translationMat4v(i,e),R.identityMat4(t),R.scalingMat4v([(r[0]-i[0])/65535,(r[1]-i[1])/65535,(r[2]-i[2])/65535],t);return{quantized:n,decodeMatrix:R.mulMat4(e,t,R.identityMat4())}}}();var Se=function(){const e=R.mat3(),t=R.mat3();return function(s,i,r){const n=new Uint16Array(s.length),A=new Float32Array([65535/(r[0]-i[0]),65535/(r[1]-i[1])]);let o;for(o=0;o<s.length;o+=2)n[o+0]=Math.max(0,Math.min(65535,Math.floor((s[o+0]-i[0])*A[0]))),n[o+1]=Math.max(0,Math.min(65535,Math.floor((s[o+1]-i[1])*A[1])));R.identityMat3(e),R.translationMat3v(i,e),R.identityMat3(t),R.scalingMat3v([(r[0]-i[0])/65535,(r[1]-i[1])/65535],t);return{quantized:n,decodeMatrix:R.mulMat3(e,t,R.identityMat3())}}}();function De(e,t,s,i){let r=e[t]/(Math.abs(e[t])+Math.abs(e[t+1])+Math.abs(e[t+2])),n=e[t+1]/(Math.abs(e[t])+Math.abs(e[t+1])+Math.abs(e[t+2]));if(e[t+2]<0){let e=(1-Math.abs(n))*(r>=0?1:-1),t=(1-Math.abs(r))*(n>=0?1:-1);r=e,n=t}return new Int8Array([Math[s](127.5*r+(r<0?-1:0)),Math[i](127.5*n+(n<0?-1:0))])}function ke(e){let t=e[0],s=e[1];t/=t<0?127:128,s/=s<0?127:128;const i=1-Math.abs(t)-Math.abs(s);i<0&&(t=(1-Math.abs(s))*(t>=0?1:-1),s=(1-Math.abs(t))*(s>=0?1:-1));const r=Math.sqrt(t*t+s*s+i*i);return[t/r,s/r,i/r]}function Qe(e,t,s){return e[t]*s[0]+e[t+1]*s[1]+e[t+2]*s[2]}const Re={getPositionsBounds:function(e){const t=new Float32Array(3),s=new Float32Array(3);let i,r;for(i=0;i<3;i++)t[i]=Number.MAX_VALUE,s[i]=-Number.MAX_VALUE;for(i=0;i<e.length;i+=3)for(r=0;r<3;r++)t[r]=Math.min(t[r],e[i+r]),s[r]=Math.max(s[r],e[i+r]);return{min:t,max:s}},createPositionsDecodeMatrix:Te,compressPositions:Pe,compressPosition:function(e,t,s){const i=new Float32Array([t[3]!==t[0]?65535/(t[3]-t[0]):0,t[4]!==t[1]?65535/(t[4]-t[1]):0,t[5]!==t[2]?65535/(t[5]-t[2]):0]);s[0]=Math.max(0,Math.min(65535,Math.floor((e[0]-t[0])*i[0]))),s[1]=Math.max(0,Math.min(65535,Math.floor((e[1]-t[1])*i[1]))),s[2]=Math.max(0,Math.min(65535,Math.floor((e[2]-t[2])*i[2])))},decompressPositions:function(e,t,s=new Float32Array(e.length)){for(let i=0,r=e.length;i<r;i+=3)s[i+0]=e[i+0]*t[0]+t[12],s[i+1]=e[i+1]*t[5]+t[13],s[i+2]=e[i+2]*t[10]+t[14];return s},decompressPosition:function(e,t,s){return s[0]=e[0]*t[0]+t[12],s[1]=e[1]*t[5]+t[13],s[2]=e[2]*t[10]+t[14],s},decompressAABB:function(e,t,s=e){return s[0]=e[0]*t[0]+t[12],s[1]=e[1]*t[5]+t[13],s[2]=e[2]*t[10]+t[14],s[3]=e[3]*t[0]+t[12],s[4]=e[4]*t[5]+t[13],s[5]=e[5]*t[10]+t[14],s},getUVBounds:function(e){const t=new Float32Array(2),s=new Float32Array(2);let i,r;for(i=0;i<2;i++)t[i]=Number.MAX_VALUE,s[i]=-Number.MAX_VALUE;for(i=0;i<e.length;i+=2)for(r=0;r<2;r++)t[r]=Math.min(t[r],e[i+r]),s[r]=Math.max(s[r],e[i+r]);return{min:t,max:s}},compressUVs:Se,decompressUVs:function(e,t,s=new Float32Array(e.length)){for(let i=0,r=e.length;i<r;i+=3)s[i+0]=e[i+0]*t[0]+t[6],s[i+1]=e[i+1]*t[4]+t[7];return s},decompressUV:function(e,t,s){s[0]=e[0]*t[0]+t[6],s[1]=e[1]*t[4]+t[7]},compressNormals:function(e){const t=new Int8Array(e.length);let s,i,r,n,A;for(let o=0;o<e.length;o+=3)r=s=De(e,o,"floor","floor"),i=ke(s),n=A=Qe(e,o,i),s=De(e,o,"ceil","floor"),i=ke(s),n=Qe(e,o,i),n>A&&(r=s,A=n),s=De(e,o,"floor","ceil"),i=ke(s),n=Qe(e,o,i),n>A&&(r=s,A=n),s=De(e,o,"ceil","ceil"),i=ke(s),n=Qe(e,o,i),n>A&&(r=s,A=n),t[o]=r[0],t[o+1]=r[1];return t},decompressNormals:function(e,t){for(let s=0,i=0,r=e.length;s<r;s+=2){let r=e[s+0],n=e[s+1];r=(2*r+1)/255,n=(2*n+1)/255;const A=1-Math.abs(r)-Math.abs(n);A<0&&(r=(1-Math.abs(n))*(r>=0?1:-1),n=(1-Math.abs(r))*(n>=0?1:-1));const o=Math.sqrt(r*r+n*n+A*A);t[i+0]=r/o,t[i+1]=n/o,t[i+2]=A/o,i+=3}return t},decompressNormal:function(e,t){let s=e[0],i=e[1];s=(2*s+1)/255,i=(2*i+1)/255;const r=1-Math.abs(s)-Math.abs(i);r<0&&(s=(1-Math.abs(i))*(s>=0?1:-1),i=(1-Math.abs(s))*(i>=0?1:-1));const n=Math.sqrt(s*s+i*i+r*r);return t[0]=s/n,t[1]=i/n,t[2]=r/n,t}},Oe=L.memory,Ve=R.AABB3();class Le extends Ee{get type(){return"ReadableGeometry"}get isReadableGeometry(){return!0}constructor(e,t={}){super(e,t),this._state=new xe({compressGeometry:!!t.compressGeometry,primitive:null,primitiveName:null,positions:null,normals:null,colors:null,uv:null,indices:null,positionsDecodeMatrix:null,uvDecodeMatrix:null,positionsBuf:null,normalsBuf:null,colorsbuf:null,uvBuf:null,indicesBuf:null,hash:""}),this._numTriangles=0,this._edgeThreshold=t.edgeThreshold||10,this._edgeIndicesBuf=null,this._pickTrianglePositionsBuf=null,this._pickTriangleColorsBuf=null,this._aabbDirty=!0,this._boundingSphere=!0,this._aabb=null,this._aabbDirty=!0,this._obb=null,this._obbDirty=!0;const s=this._state,i=this.scene.canvas.gl;switch(t.primitive=t.primitive||"triangles",t.primitive){case"points":s.primitive=i.POINTS,s.primitiveName=t.primitive;break;case"lines":s.primitive=i.LINES,s.primitiveName=t.primitive;break;case"line-loop":s.primitive=i.LINE_LOOP,s.primitiveName=t.primitive;break;case"line-strip":s.primitive=i.LINE_STRIP,s.primitiveName=t.primitive;break;case"triangles":s.primitive=i.TRIANGLES,s.primitiveName=t.primitive;break;case"triangle-strip":s.primitive=i.TRIANGLE_STRIP,s.primitiveName=t.primitive;break;case"triangle-fan":s.primitive=i.TRIANGLE_FAN,s.primitiveName=t.primitive;break;default:this.error("Unsupported value for 'primitive': '"+t.primitive+"' - supported values are 'points', 'lines', 'line-loop', 'line-strip', 'triangles', 'triangle-strip' and 'triangle-fan'. Defaulting to 'triangles'."),s.primitive=i.TRIANGLES,s.primitiveName=t.primitive}if(t.positions)if(this._state.compressGeometry){const e=Re.getPositionsBounds(t.positions),i=Re.compressPositions(t.positions,e.min,e.max);s.positions=i.quantized,s.positionsDecodeMatrix=i.decodeMatrix}else s.positions=t.positions.constructor===Float32Array?t.positions:new Float32Array(t.positions);if(t.colors&&(s.colors=t.colors.constructor===Float32Array?t.colors:new Float32Array(t.colors)),t.uv)if(this._state.compressGeometry){const e=Re.getUVBounds(t.uv),i=Re.compressUVs(t.uv,e.min,e.max);s.uv=i.quantized,s.uvDecodeMatrix=i.decodeMatrix}else s.uv=t.uv.constructor===Float32Array?t.uv:new Float32Array(t.uv);if(t.normals&&(this._state.compressGeometry?s.normals=Re.compressNormals(t.normals):s.normals=t.normals.constructor===Float32Array?t.normals:new Float32Array(t.normals)),t.indices&&(s.indices=t.indices.constructor===Uint32Array||t.indices.constructor===Uint16Array?t.indices:new Uint32Array(t.indices),"triangles"===this._state.primitiveName&&(this._numTriangles=t.indices.length/3)),this._buildHash(),Oe.meshes++,s.indices&&(s.indicesBuf=new Ue(i,i.ELEMENT_ARRAY_BUFFER,s.indices,s.indices.length,1,i.STATIC_DRAW),Oe.indices+=s.indicesBuf.numItems),s.positions&&(s.positionsBuf=new Ue(i,i.ARRAY_BUFFER,s.positions,s.positions.length,3,i.STATIC_DRAW),Oe.positions+=s.positionsBuf.numItems),s.normals){let e=s.compressGeometry;s.normalsBuf=new Ue(i,i.ARRAY_BUFFER,s.normals,s.normals.length,3,i.STATIC_DRAW,e),Oe.normals+=s.normalsBuf.numItems}s.colors&&(s.colorsBuf=new Ue(i,i.ARRAY_BUFFER,s.colors,s.colors.length,4,i.STATIC_DRAW),Oe.colors+=s.colorsBuf.numItems),s.uv&&(s.uvBuf=new Ue(i,i.ARRAY_BUFFER,s.uv,s.uv.length,2,i.STATIC_DRAW),Oe.uvs+=s.uvBuf.numItems)}_buildHash(){const e=this._state,t=["/g"];t.push("/"+e.primitive+";"),e.positions&&t.push("p"),e.colors&&t.push("c"),(e.normals||e.autoVertexNormals)&&t.push("n"),e.uv&&t.push("u"),e.compressGeometry&&t.push("cp"),t.push(";"),e.hash=t.join("")}_getEdgeIndices(){return this._edgeIndicesBuf||this._buildEdgeIndices(),this._edgeIndicesBuf}_getPickTrianglePositions(){return this._pickTrianglePositionsBuf||this._buildPickTriangleVBOs(),this._pickTrianglePositionsBuf}_getPickTriangleColors(){return this._pickTriangleColorsBuf||this._buildPickTriangleVBOs(),this._pickTriangleColorsBuf}_buildEdgeIndices(){const e=this._state;if(!e.positions||!e.indices)return;const t=this.scene.canvas.gl,s=Ie(e.positions,e.indices,e.positionsDecodeMatrix,this._edgeThreshold);this._edgeIndicesBuf=new Ue(t,t.ELEMENT_ARRAY_BUFFER,s,s.length,1,t.STATIC_DRAW),Oe.indices+=this._edgeIndicesBuf.numItems}_buildPickTriangleVBOs(){const e=this._state;if(!e.positions||!e.indices)return;const t=this.scene.canvas.gl,s=R.buildPickTriangles(e.positions,e.indices,e.compressGeometry),i=s.positions,r=s.colors;this._pickTrianglePositionsBuf=new Ue(t,t.ARRAY_BUFFER,i,i.length,3,t.STATIC_DRAW),this._pickTriangleColorsBuf=new Ue(t,t.ARRAY_BUFFER,r,r.length,4,t.STATIC_DRAW,!0),Oe.positions+=this._pickTrianglePositionsBuf.numItems,Oe.colors+=this._pickTriangleColorsBuf.numItems}_buildPickVertexVBOs(){}get primitive(){return this._state.primitiveName}get compressGeometry(){return this._state.compressGeometry}get positions(){return this._state.positions?this._state.compressGeometry?(this._decompressedPositions||(this._decompressedPositions=new Float32Array(this._state.positions.length),Re.decompressPositions(this._state.positions,this._state.positionsDecodeMatrix,this._decompressedPositions)),this._decompressedPositions):this._state.positions:null}set positions(e){const t=this._state,s=t.positions;if(s)if(s.length===e.length){if(this._state.compressGeometry){const s=Re.getPositionsBounds(e),i=Re.compressPositions(e,s.min,s.max);e=i.quantized,t.positionsDecodeMatrix=i.decodeMatrix}s.set(e),t.positionsBuf&&t.positionsBuf.setData(s),this._setAABBDirty(),this.glRedraw()}else this.error("can't update geometry positions - new positions are wrong length");else this.error("can't update geometry positions - geometry has no positions")}get normals(){if(this._state.normals){if(!this._state.compressGeometry)return this._state.normals;if(!this._decompressedNormals){const e=this._state.normals.length,t=e+e/2;this._decompressedNormals=new Float32Array(t),Re.decompressNormals(this._state.normals,this._decompressedNormals)}return this._decompressedNormals}}set normals(e){if(this._state.compressGeometry)return void this.error("can't update geometry normals - quantized geometry is immutable");const t=this._state,s=t.normals;s?s.length===e.length?(s.set(e),t.normalsBuf&&t.normalsBuf.setData(s),this.glRedraw()):this.error("can't update geometry normals - new normals are wrong length"):this.error("can't update geometry normals - geometry has no normals")}get uv(){return this._state.uv?this._state.compressGeometry?(this._decompressedUV||(this._decompressedUV=new Float32Array(this._state.uv.length),Re.decompressUVs(this._state.uv,this._state.uvDecodeMatrix,this._decompressedUV)),this._decompressedUV):this._state.uv:null}set uv(e){if(this._state.compressGeometry)return void this.error("can't update geometry UVs - quantized geometry is immutable");const t=this._state,s=t.uv;s?s.length===e.length?(s.set(e),t.uvBuf&&t.uvBuf.setData(s),this.glRedraw()):this.error("can't update geometry UVs - new UVs are wrong length"):this.error("can't update geometry UVs - geometry has no UVs")}get colors(){return this._state.colors}set colors(e){if(this._state.compressGeometry)return void this.error("can't update geometry colors - quantized geometry is immutable");const t=this._state,s=t.colors;s?s.length===e.length?(s.set(e),t.colorsBuf&&t.colorsBuf.setData(s),this.glRedraw()):this.error("can't update geometry colors - new colors are wrong length"):this.error("can't update geometry colors - geometry has no colors")}get indices(){return this._state.indices}get aabb(){return this._aabbDirty&&(this._aabb||(this._aabb=R.AABB3()),R.positions3ToAABB3(this._state.positions,this._aabb,this._state.positionsDecodeMatrix),this._aabbDirty=!1),this._aabb}get obb(){return this._obbDirty&&(this._obb||(this._obb=R.OBB3()),R.positions3ToAABB3(this._state.positions,Ve,this._state.positionsDecodeMatrix),R.AABB3ToOBB3(Ve,this._obb),this._obbDirty=!1),this._obb}_getMetrics(){if(!("_metrics"in this))switch(this._state.primitiveName){case"solid":case"surface":case"triangles":{const e=this._state.indices,t=this._state.positions,s=(s,i)=>{const r=3*e[s];for(let e=0;e<3;++e)i[e]=t[r+e];return i},i=[R.vec3(),R.vec3(),R.vec3(),R.vec3()];let r=0;const n=R.vec3([0,0,0]);for(let t=0;t<e.length;t+=3){const e=s(t,i[0]),A=s(t+1,i[1]),o=s(t+2,i[2]);R.addVec3(e,A,i[3]),R.addVec3(o,i[3],i[3]);const a=R.lenVec3(R.cross3Vec3(R.subVec3(A,e,i[1]),R.subVec3(o,e,i[2]),i[0]))/2;r+=a,R.mulVec3Scalar(i[3],a,i[3]),R.addVec3(n,i[3],n)}this._metrics={surfaceArea:r,centroid:R.mulVec3Scalar(n,1/r/3,n)};break}default:this._metrics={surfaceArea:0}}return this._metrics}get surfaceArea(){return this._getMetrics().surfaceArea}get centroid(){return this._getMetrics().centroid}get numTriangles(){return this._numTriangles}_setAABBDirty(){this._aabbDirty||(this._aabbDirty=!0,this._aabbDirty=!0,this._obbDirty=!0)}_getState(){return this._state}destroy(){super.destroy();const e=this._state;e.indicesBuf&&e.indicesBuf.destroy(),e.positionsBuf&&e.positionsBuf.destroy(),e.normalsBuf&&e.normalsBuf.destroy(),e.uvBuf&&e.uvBuf.destroy(),e.colorsBuf&&e.colorsBuf.destroy(),this._edgeIndicesBuf&&this._edgeIndicesBuf.destroy(),this._pickTrianglePositionsBuf&&this._pickTrianglePositionsBuf.destroy(),this._pickTriangleColorsBuf&&this._pickTriangleColorsBuf.destroy(),this._pickVertexPositionsBuf&&this._pickVertexPositionsBuf.destroy(),this._pickVertexColorsBuf&&this._pickVertexColorsBuf.destroy(),e.destroy(),Oe.meshes--}}const He=L.memory,Ne=R.AABB3();class Ge extends Ee{get type(){return"VBOGeometry"}get isVBOGeometry(){return!0}constructor(e,t={}){super(e,t),this._state=new xe({compressGeometry:!0,primitive:null,primitiveName:null,positionsDecodeMatrix:null,uvDecodeMatrix:null,positionsBuf:null,normalsBuf:null,colorsbuf:null,uvBuf:null,indicesBuf:null,hash:""}),this._numTriangles=0,this._edgeThreshold=t.edgeThreshold||10,this._aabb=null,this._obb=R.OBB3();const s=this._state,i=this.scene.canvas.gl;switch(t.primitive=t.primitive||"triangles",t.primitive){case"points":s.primitive=i.POINTS,s.primitiveName=t.primitive;break;case"lines":s.primitive=i.LINES,s.primitiveName=t.primitive;break;case"line-loop":s.primitive=i.LINE_LOOP,s.primitiveName=t.primitive;break;case"line-strip":s.primitive=i.LINE_STRIP,s.primitiveName=t.primitive;break;case"triangles":s.primitive=i.TRIANGLES,s.primitiveName=t.primitive;break;case"triangle-strip":s.primitive=i.TRIANGLE_STRIP,s.primitiveName=t.primitive;break;case"triangle-fan":s.primitive=i.TRIANGLE_FAN,s.primitiveName=t.primitive;break;default:this.error("Unsupported value for 'primitive': '"+t.primitive+"' - supported values are 'points', 'lines', 'line-loop', 'line-strip', 'triangles', 'triangle-strip' and 'triangle-fan'. Defaulting to 'triangles'."),s.primitive=i.TRIANGLES,s.primitiveName=t.primitive}if(t.positions)if(t.indices){var r;if(t.positionsDecodeMatrix);else{const e=Re.getPositionsBounds(t.positions),n=Re.compressPositions(t.positions,e.min,e.max);r=n.quantized,s.positionsDecodeMatrix=n.decodeMatrix,s.positionsBuf=new Ue(i,i.ARRAY_BUFFER,r,r.length,3,i.STATIC_DRAW),He.positions+=s.positionsBuf.numItems,R.positions3ToAABB3(t.positions,this._aabb),R.positions3ToAABB3(r,Ne,s.positionsDecodeMatrix),R.AABB3ToOBB3(Ne,this._obb)}if(t.colors){const e=t.colors.constructor===Float32Array?t.colors:new Float32Array(t.colors);s.colorsBuf=new Ue(i,i.ARRAY_BUFFER,e,e.length,4,i.STATIC_DRAW),He.colors+=s.colorsBuf.numItems}if(t.uv){const e=Re.getUVBounds(t.uv),r=Re.compressUVs(t.uv,e.min,e.max),n=r.quantized;s.uvDecodeMatrix=r.decodeMatrix,s.uvBuf=new Ue(i,i.ARRAY_BUFFER,n,n.length,2,i.STATIC_DRAW),He.uvs+=s.uvBuf.numItems}if(t.normals){const e=Re.compressNormals(t.normals);let r=s.compressGeometry;s.normalsBuf=new Ue(i,i.ARRAY_BUFFER,e,e.length,3,i.STATIC_DRAW,r),He.normals+=s.normalsBuf.numItems}{const e=t.indices.constructor===Uint32Array||t.indices.constructor===Uint16Array?t.indices:new Uint32Array(t.indices);s.indicesBuf=new Ue(i,i.ELEMENT_ARRAY_BUFFER,e,e.length,1,i.STATIC_DRAW),He.indices+=s.indicesBuf.numItems;const n=Ie(r,e,s.positionsDecodeMatrix,this._edgeThreshold);this._edgeIndicesBuf=new Ue(i,i.ELEMENT_ARRAY_BUFFER,n,n.length,1,i.STATIC_DRAW),"triangles"===this._state.primitiveName&&(this._numTriangles=t.indices.length/3)}this._buildHash(),He.meshes++}else this.error("Config expected: indices");else this.error("Config expected: positions")}_buildHash(){const e=this._state,t=["/g"];t.push("/"+e.primitive+";"),e.positionsBuf&&t.push("p"),e.colorsBuf&&t.push("c"),(e.normalsBuf||e.autoVertexNormals)&&t.push("n"),e.uvBuf&&t.push("u"),t.push("cp"),t.push(";"),e.hash=t.join("")}_getEdgeIndices(){return this._edgeIndicesBuf}get primitive(){return this._state.primitiveName}get aabb(){return this._aabb}get obb(){return this._obb}get numTriangles(){return this._numTriangles}_getState(){return this._state}destroy(){super.destroy();const e=this._state;e.indicesBuf&&e.indicesBuf.destroy(),e.positionsBuf&&e.positionsBuf.destroy(),e.normalsBuf&&e.normalsBuf.destroy(),e.uvBuf&&e.uvBuf.destroy(),e.colorsBuf&&e.colorsBuf.destroy(),this._edgeIndicesBuf&&this._edgeIndicesBuf.destroy(),e.destroy(),He.meshes--}}var je={};function We(e={}){let t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);let s=e.ySize||1;s<0&&(console.error("negative ySize not allowed - will invert"),s*=-1);let i=e.zSize||1;i<0&&(console.error("negative zSize not allowed - will invert"),i*=-1);const r=e.center,n=r?r[0]:0,A=r?r[1]:0,o=r?r[2]:0,a=-t+n,l=-s+A,c=-i+o,h=t+n,u=s+A,d=i+o;return j.apply(e,{positions:[h,u,d,a,u,d,a,l,d,h,l,d,h,u,d,h,l,d,h,l,c,h,u,c,h,u,d,h,u,c,a,u,c,a,u,d,a,u,d,a,u,c,a,l,c,a,l,d,a,l,c,h,l,c,h,l,d,a,l,d,h,l,c,a,l,c,a,u,c,h,u,c],normals:[0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1],uv:[1,0,0,0,0,1,1,1,0,0,0,1,1,1,1,0,1,1,1,0,0,0,0,1,1,0,0,0,0,1,1,1,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]})}function ze(e={}){let t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);let s=e.ySize||1;s<0&&(console.error("negative ySize not allowed - will invert"),s*=-1);let i=e.zSize||1;i<0&&(console.error("negative zSize not allowed - will invert"),i*=-1);const r=e.center,n=r?r[0]:0,A=r?r[1]:0,o=r?r[2]:0,a=-t+n,l=-s+A,c=-i+o,h=t+n,u=s+A,d=i+o;return j.apply(e,{primitive:"lines",positions:[a,l,c,a,l,d,a,u,c,a,u,d,h,l,c,h,l,d,h,u,c,h,u,d],indices:[0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,4,1,5,2,6,3,7]})}function Xe(e={}){let t=e.radiusTop||1;t<0&&(console.error("negative radiusTop not allowed - will invert"),t*=-1);let s=e.radiusBottom||1;s<0&&(console.error("negative radiusBottom not allowed - will invert"),s*=-1);let i=e.height||1;i<0&&(console.error("negative height not allowed - will invert"),i*=-1);let r=e.radialSegments||32;r<0&&(console.error("negative radialSegments not allowed - will invert"),r*=-1),r<3&&(r=3);let n=e.heightSegments||1;n<0&&(console.error("negative heightSegments not allowed - will invert"),n*=-1),n<1&&(n=1);const A=!!e.openEnded;let o=e.center;const a=o?o[0]:0,l=o?o[1]:0,c=o?o[2]:0,h=i/2,u=i/n,d=2*Math.PI/r,p=1/r,f=(t-s)/n,g=[],m=[],_=[],b=[];let B,y,w,v,C,M,E,F,x,U,I;const T=(90-180*Math.atan(i/(s-t))/Math.PI)/90;for(B=0;B<=n;B++)for(C=t-B*f,M=h-B*u,y=0;y<=r;y++)w=Math.sin(y*d),v=Math.cos(y*d),m.push(C*w),m.push(T),m.push(C*v),_.push(y*p),_.push(1*B/n),g.push(C*w+a),g.push(M+l),g.push(C*v+c);for(B=0;B<n;B++)for(y=0;y<=r;y++)E=B*(r+1)+y,F=E+r,b.push(E),b.push(F),b.push(F+1),b.push(E),b.push(F+1),b.push(E+1);if(!A&&t>0){for(x=g.length/3,m.push(0),m.push(1),m.push(0),_.push(.5),_.push(.5),g.push(0+a),g.push(h+l),g.push(0+c),y=0;y<=r;y++)w=Math.sin(y*d),v=Math.cos(y*d),U=.5*Math.sin(y*d)+.5,I=.5*Math.cos(y*d)+.5,m.push(t*w),m.push(1),m.push(t*v),_.push(U),_.push(I),g.push(t*w+a),g.push(h+l),g.push(t*v+c);for(y=0;y<r;y++)o=x,E=x+1+y,b.push(E),b.push(E+1),b.push(o)}if(!A&&s>0){for(x=g.length/3,m.push(0),m.push(-1),m.push(0),_.push(.5),_.push(.5),g.push(0+a),g.push(0-h+l),g.push(0+c),y=0;y<=r;y++)w=Math.sin(y*d),v=Math.cos(y*d),U=.5*Math.sin(y*d)+.5,I=.5*Math.cos(y*d)+.5,m.push(s*w),m.push(-1),m.push(s*v),_.push(U),_.push(I),g.push(s*w+a),g.push(0-h+l),g.push(s*v+c);for(y=0;y<r;y++)o=x,E=x+1+y,b.push(o),b.push(E+1),b.push(E)}return j.apply(e,{positions:g,normals:m,uv:_,indices:b})}function Ke(e={}){let t=e.size||1;t<0&&(console.error("negative size not allowed - will invert"),t*=-1);let s=e.divisions||1;s<0&&(console.error("negative divisions not allowed - will invert"),s*=-1),s<1&&(s=1),t=t||10,s=s||10;const i=t/s,r=t/2,n=[],A=[];let o=0;for(let e=0,t=-r;e<=s;e++,t+=i)n.push(-r),n.push(0),n.push(t),n.push(r),n.push(0),n.push(t),n.push(t),n.push(0),n.push(-r),n.push(t),n.push(0),n.push(r),A.push(o++),A.push(o++),A.push(o++),A.push(o++);return j.apply(e,{primitive:"lines",positions:n,indices:A})}function Ze(e={}){let t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);let s=e.zSize||1;s<0&&(console.error("negative zSize not allowed - will invert"),s*=-1);let i=e.xSegments||1;i<0&&(console.error("negative xSegments not allowed - will invert"),i*=-1),i<1&&(i=1);let r=e.xSegments||1;r<0&&(console.error("negative zSegments not allowed - will invert"),r*=-1),r<1&&(r=1);const n=e.center,A=n?n[0]:0,o=n?n[1]:0,a=n?n[2]:0,l=t/2,c=s/2,h=Math.floor(i)||1,u=Math.floor(r)||1,d=h+1,p=u+1,f=t/h,g=s/u,m=new Float32Array(d*p*3),_=new Float32Array(d*p*3),b=new Float32Array(d*p*2);let B,y,w,v,C,M,E,F=0,x=0;for(B=0;B<p;B++){const e=B*g-c;for(y=0;y<d;y++)w=y*f-l,m[F]=w+A,m[F+1]=o,m[F+2]=-e+a,_[F+1]=1,b[x]=y/h,b[x+1]=(u-B)/u,F+=3,x+=2}F=0;const U=new(m.length/3>65535?Uint32Array:Uint16Array)(h*u*6);for(B=0;B<u;B++)for(y=0;y<h;y++)v=y+d*B,C=y+d*(B+1),M=y+1+d*(B+1),E=y+1+d*B,U[F]=E,U[F+1]=C,U[F+2]=v,U[F+3]=E,U[F+4]=M,U[F+5]=C,F+=6;return j.apply(e,{positions:m,normals:_,uv:b,indices:U})}function Je(e={}){const t=e.lod||1,s=e.center?e.center[0]:0,i=e.center?e.center[1]:0,r=e.center?e.center[2]:0;let n=e.radius||1;n<0&&(console.error("negative radius not allowed - will invert"),n*=-1);let A=e.heightSegments||18;A<0&&(console.error("negative heightSegments not allowed - will invert"),A*=-1),A=Math.floor(t*A),A<18&&(A=18);let o=e.widthSegments||18;o<0&&(console.error("negative widthSegments not allowed - will invert"),o*=-1),o=Math.floor(t*o),o<18&&(o=18);const a=[],l=[],c=[],h=[];let u,d,p,f,g,m,_,b,B,y,w,v,C,M,E;for(u=0;u<=A;u++)for(p=u*Math.PI/A,f=Math.sin(p),g=Math.cos(p),d=0;d<=o;d++)m=2*d*Math.PI/o,_=Math.sin(m),b=Math.cos(m),B=b*f,y=g,w=_*f,v=1-d/o,C=u/A,l.push(B),l.push(y),l.push(w),c.push(v),c.push(C),a.push(s+n*B),a.push(i+n*y),a.push(r+n*w);for(u=0;u<A;u++)for(d=0;d<o;d++)M=u*(o+1)+d,E=M+o+1,h.push(M+1),h.push(E+1),h.push(E),h.push(M+1),h.push(E),h.push(M);return j.apply(e,{positions:a,normals:l,uv:c,indices:h})}function Ye(e={}){let t=e.radius||1;t<0&&(console.error("negative radius not allowed - will invert"),t*=-1),t*=.5;let s=e.tube||.3;s<0&&(console.error("negative tube not allowed - will invert"),s*=-1);let i=e.radialSegments||32;i<0&&(console.error("negative radialSegments not allowed - will invert"),i*=-1),i<4&&(i=4);let r=e.tubeSegments||24;r<0&&(console.error("negative tubeSegments not allowed - will invert"),r*=-1),r<4&&(r=4);let n=e.arc||2*Math.PI;n<0&&(console.warn("negative arc not allowed - will invert"),n*=-1),n>360&&(n=360);const A=e.center;let o=A?A[0]:0,a=A?A[1]:0;const l=A?A[2]:0,c=[],h=[],u=[],d=[];let p,f,g,m,_,b,B,y,w,v,C,M;for(y=0;y<=r;y++)for(B=0;B<=i;B++)p=B/i*n,f=.785398+y/r*Math.PI*2,o=t*Math.cos(p),a=t*Math.sin(p),g=(t+s*Math.cos(f))*Math.cos(p),m=(t+s*Math.cos(f))*Math.sin(p),_=s*Math.sin(f),c.push(g+o),c.push(m+a),c.push(_+l),u.push(1-B/i),u.push(y/r),b=R.normalizeVec3(R.subVec3([g,m,_],[o,a,l],[]),[]),h.push(b[0]),h.push(b[1]),h.push(b[2]);for(y=1;y<=r;y++)for(B=1;B<=i;B++)w=(i+1)*y+B-1,v=(i+1)*(y-1)+B-1,C=(i+1)*(y-1)+B,M=(i+1)*y+B,d.push(w),d.push(v),d.push(C),d.push(C),d.push(M),d.push(w);return j.apply(e,{positions:c,normals:h,uv:u,indices:d})}je.load=function(e,t){var s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="arraybuffer",s.onload=function(e){t(e.target.response)},s.send()},je.save=function(e,t){var s="data:application/octet-stream;base64,"+btoa(je.parse._buffToStr(e));window.location.href=s},je.clone=function(e){return JSON.parse(JSON.stringify(e))},je.bin={},je.bin.f=new Float32Array(1),je.bin.fb=new Uint8Array(je.bin.f.buffer),je.bin.rf=function(e,t){for(var s=je.bin.f,i=je.bin.fb,r=0;r<4;r++)i[r]=e[t+r];return s[0]},je.bin.rsl=function(e,t){return e[t]|e[t+1]<<8},je.bin.ril=function(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},je.bin.rASCII0=function(e,t){for(var s="";0!=e[t];)s+=String.fromCharCode(e[t++]);return s},je.bin.wf=function(e,t,s){new Float32Array(e.buffer,t,1)[0]=s},je.bin.wsl=function(e,t,s){e[t]=s,e[t+1]=s>>8},je.bin.wil=function(e,t,s){e[t]=s,e[t+1]=s>>8,e[t+2]=s>>16,e[t+3]},je.parse={},je.parse._buffToStr=function(e){for(var t=new Uint8Array(e),s="",i=0;i<t.length;i++)s=s.concat(String.fromCharCode(t[i]));return s},je.parse._strToBuff=function(e){for(var t=new ArrayBuffer(e.length),s=new Uint8Array(t),i=0;i<e.length;i++)s[i]=e.charCodeAt(i);return t},je.parse._readLine=function(e,t){for(var s="";10!=e[t];)s+=String.fromCharCode(e[t++]);return s},je.parse.fromJSON=function(e){return JSON.parse(je.parse._buffToStr(e))},je.parse.toJSON=function(e){var t=JSON.stringify(e);return je.parse._strToBuff(t)},je.parse.fromOBJ=function(e){for(var t={groups:{},c_verts:[],c_uvt:[],c_norms:[],i_verts:[],i_uvt:[],i_norms:[]},s={from:0,to:0},i=0,r=new Uint8Array(e);i<r.length;){var n=je.parse._readLine(r,i);i+=n.length+1;var A=(n=(n=n.replace(/ +(?= )/g,"")).replace(/(^\s+|\s+$)/g,"")).split(" ");if("g"==A[0]&&(s.to=t.i_verts.length,null==t.groups[A[1]]&&(t.groups[A[1]]={from:t.i_verts.length,to:0}),s=t.groups[A[1]]),"v"==A[0]){var o=parseFloat(A[1]),a=parseFloat(A[2]),l=parseFloat(A[3]);t.c_verts.push(o,a,l)}if("vt"==A[0]){o=parseFloat(A[1]),a=1-parseFloat(A[2]);t.c_uvt.push(o,a)}if("vn"==A[0]){o=parseFloat(A[1]),a=parseFloat(A[2]),l=parseFloat(A[3]);t.c_norms.push(o,a,l)}if("f"==A[0]){var c=A[1].split("/"),h=A[2].split("/"),u=A[3].split("/"),d=parseInt(c[0])-1,p=parseInt(h[0])-1,f=parseInt(u[0])-1,g=parseInt(c[1])-1,m=parseInt(h[1])-1,_=parseInt(u[1])-1,b=parseInt(c[2])-1,B=parseInt(h[2])-1,y=parseInt(u[2])-1,w=t.c_verts.length/3,v=t.c_uvt.length/2,C=t.c_norms.length/3;if(d<0&&(d=w+d+1),p<0&&(p=w+p+1),f<0&&(f=w+f+1),g<0&&(g=v+g+1),m<0&&(m=v+m+1),_<0&&(_=v+_+1),b<0&&(b=C+b+1),B<0&&(B=C+B+1),y<0&&(y=C+y+1),t.i_verts.push(d,p,f),t.i_uvt.push(g,m,_),t.i_norms.push(b,B,y),5==A.length){var M=A[4].split("/"),E=parseInt(M[0])-1,F=parseInt(M[1])-1,x=parseInt(M[2])-1;E<0&&(E=w+E+1),F<0&&(F=v+F+1),x<0&&(x=C+x+1),t.i_verts.push(d,f,E),t.i_uvt.push(g,_,F),t.i_norms.push(b,y,x)}}}return s.to=t.i_verts.length,t},je.parse.fromMD2=function(e){e=new Uint8Array(e);var t={},s={};s.ident=je.bin.ril(e,0),s.version=je.bin.ril(e,4),s.skinwidth=je.bin.ril(e,8),s.skinheight=je.bin.ril(e,12),s.framesize=je.bin.ril(e,16),s.num_skins=je.bin.ril(e,20),s.num_vertices=je.bin.ril(e,24),s.num_st=je.bin.ril(e,28),s.num_tris=je.bin.ril(e,32),s.num_glcmds=je.bin.ril(e,36),s.num_frames=je.bin.ril(e,40),s.offset_skins=je.bin.ril(e,44),s.offset_st=je.bin.ril(e,48),s.offset_tris=je.bin.ril(e,52),s.offset_frames=je.bin.ril(e,56),s.offset_glcmds=je.bin.ril(e,60),s.offset_end=je.bin.ril(e,64);var i=s.offset_st;t.c_uvt=[];for(var r=0;r<s.num_st;r++){var n=je.bin.rsl(e,i)/s.skinwidth,A=je.bin.rsl(e,i+2)/s.skinheight;t.c_uvt.push(n,A),i+=4}i=s.offset_tris;var o=[],a=[];t.i_verts=o,t.i_uvt=a;for(r=0;r<s.num_tris;r++)o.push(je.bin.rsl(e,i),je.bin.rsl(e,i+2),je.bin.rsl(e,i+4)),a.push(je.bin.rsl(e,i+6),je.bin.rsl(e,i+8),je.bin.rsl(e,i+10)),i+=12;i=s.offset_skins;t.skins=[];for(r=0;r<s.num_skins;r++)t.skins.push(je.bin.rASCII0(e,i)),i+=64;i=s.offset_frames;t.frames=[];var l=je.parse.fromMD2._normals;for(r=0;r<s.num_frames;r++){var c={},h=je.bin.rf(e,i),u=je.bin.rf(e,i+4),d=je.bin.rf(e,i+8);i+=12;var p=je.bin.rf(e,i),f=je.bin.rf(e,i+4),g=je.bin.rf(e,i+8);i+=12,c.name=je.bin.rASCII0(e,i),i+=16,c.verts=[],c.norms=[];for(var m=0;m<s.num_vertices;m++)c.verts.push(e[i]*h+p,e[i+1]*u+f,e[i+2]*d+g),c.norms.push(l[3*e[i+3]],l[3*e[i+3]+1],l[3*e[i+3]+2]),i+=4;t.frames.push(c)}return t},je.parse.fromMD2._normals=[-.525731,0,.850651,-.442863,.238856,.864188,-.295242,0,.955423,-.309017,.5,.809017,-.16246,.262866,.951056,0,0,1,0,.850651,.525731,-.147621,.716567,.681718,.147621,.716567,.681718,0,.525731,.850651,.309017,.5,.809017,.525731,0,.850651,.295242,0,.955423,.442863,.238856,.864188,.16246,.262866,.951056,-.681718,.147621,.716567,-.809017,.309017,.5,-.587785,.425325,.688191,-.850651,.525731,0,-.864188,.442863,.238856,-.716567,.681718,.147621,-.688191,.587785,.425325,-.5,.809017,.309017,-.238856,.864188,.442863,-.425325,.688191,.587785,-.716567,.681718,-.147621,-.5,.809017,-.309017,-.525731,.850651,0,0,.850651,-.525731,-.238856,.864188,-.442863,0,.955423,-.295242,-.262866,.951056,-.16246,0,1,0,0,.955423,.295242,-.262866,.951056,.16246,.238856,.864188,.442863,.262866,.951056,.16246,.5,.809017,.309017,.238856,.864188,-.442863,.262866,.951056,-.16246,.5,.809017,-.309017,.850651,.525731,0,.716567,.681718,.147621,.716567,.681718,-.147621,.525731,.850651,0,.425325,.688191,.587785,.864188,.442863,.238856,.688191,.587785,.425325,.809017,.309017,.5,.681718,.147621,.716567,.587785,.425325,.688191,.955423,.295242,0,1,0,0,.951056,.16246,.262866,.850651,-.525731,0,.955423,-.295242,0,.864188,-.442863,.238856,.951056,-.16246,.262866,.809017,-.309017,.5,.681718,-.147621,.716567,.850651,0,.525731,.864188,.442863,-.238856,.809017,.309017,-.5,.951056,.16246,-.262866,.525731,0,-.850651,.681718,.147621,-.716567,.681718,-.147621,-.716567,.850651,0,-.525731,.809017,-.309017,-.5,.864188,-.442863,-.238856,.951056,-.16246,-.262866,.147621,.716567,-.681718,.309017,.5,-.809017,.425325,.688191,-.587785,.442863,.238856,-.864188,.587785,.425325,-.688191,.688191,.587785,-.425325,-.147621,.716567,-.681718,-.309017,.5,-.809017,0,.525731,-.850651,-.525731,0,-.850651,-.442863,.238856,-.864188,-.295242,0,-.955423,-.16246,.262866,-.951056,0,0,-1,.295242,0,-.955423,.16246,.262866,-.951056,-.442863,-.238856,-.864188,-.309017,-.5,-.809017,-.16246,-.262866,-.951056,0,-.850651,-.525731,-.147621,-.716567,-.681718,.147621,-.716567,-.681718,0,-.525731,-.850651,.309017,-.5,-.809017,.442863,-.238856,-.864188,.16246,-.262866,-.951056,.238856,-.864188,-.442863,.5,-.809017,-.309017,.425325,-.688191,-.587785,.716567,-.681718,-.147621,.688191,-.587785,-.425325,.587785,-.425325,-.688191,0,-.955423,-.295242,0,-1,0,.262866,-.951056,-.16246,0,-.850651,.525731,0,-.955423,.295242,.238856,-.864188,.442863,.262866,-.951056,.16246,.5,-.809017,.309017,.716567,-.681718,.147621,.525731,-.850651,0,-.238856,-.864188,-.442863,-.5,-.809017,-.309017,-.262866,-.951056,-.16246,-.850651,-.525731,0,-.716567,-.681718,-.147621,-.716567,-.681718,.147621,-.525731,-.850651,0,-.5,-.809017,.309017,-.238856,-.864188,.442863,-.262866,-.951056,.16246,-.864188,-.442863,.238856,-.809017,-.309017,.5,-.688191,-.587785,.425325,-.681718,-.147621,.716567,-.442863,-.238856,.864188,-.587785,-.425325,.688191,-.309017,-.5,.809017,-.147621,-.716567,.681718,-.425325,-.688191,.587785,-.16246,-.262866,.951056,.442863,-.238856,.864188,.16246,-.262866,.951056,.309017,-.5,.809017,.147621,-.716567,.681718,0,-.525731,.850651,.425325,-.688191,.587785,.587785,-.425325,.688191,.688191,-.587785,.425325,-.955423,.295242,0,-.951056,.16246,.262866,-1,0,0,-.850651,0,.525731,-.955423,-.295242,0,-.951056,-.16246,.262866,-.864188,.442863,-.238856,-.951056,.16246,-.262866,-.809017,.309017,-.5,-.864188,-.442863,-.238856,-.951056,-.16246,-.262866,-.809017,-.309017,-.5,-.681718,.147621,-.716567,-.681718,-.147621,-.716567,-.850651,0,-.525731,-.688191,.587785,-.425325,-.587785,.425325,-.688191,-.425325,.688191,-.587785,-.425325,-.688191,-.587785,-.587785,-.425325,-.688191,-.688191,-.587785,-.425325],je.parse.fromCollada=function(e){var t=je.parse._buffToStr(e),s=(new DOMParser).parseFromString(t,"text/xml"),i={},r=(s=s.childNodes[0]).getElementsByTagName("asset")[0],n=s.getElementsByTagName("library_geometries")[0],A=s.getElementsByTagName("library_images")[0],o=s.getElementsByTagName("library_materials")[0],a=s.getElementsByTagName("library_effects")[0];return r&&(i.asset=je.parse.fromCollada._asset(r)),n&&(i.geometries=je.parse.fromCollada._libGeometries(n)),A&&(i.images=je.parse.fromCollada._libImages(A)),o&&(i.materials=je.parse.fromCollada._libMaterials(o)),a&&(i.effects=je.parse.fromCollada._libEffects(a)),i},je.parse.fromCollada._asset=function(e){return{created:e.getElementsByTagName("created")[0].textContent,modified:e.getElementsByTagName("modified")[0].textContent,up_axis:e.getElementsByTagName("up_axis")[0].textContent}},je.parse.fromCollada._libGeometries=function(e){e=e.getElementsByTagName("geometry");for(var t=[],s=0;s<e.length;s++){var i=e[s],r=je.parse.fromCollada._getMesh(i.getElementsByTagName("mesh")[0]);t.push(r)}return t},je.parse.fromCollada._getMesh=function(e){for(var t={},s=e.getElementsByTagName("source"),i=t.sources={},r=0;r<s.length;r++){for(var n=s[r].getElementsByTagName("float_array")[0].textContent.split(" "),A=n.length-(""==n[n.length-1]?1:0),o=new Array(A),a=0;a<A;a++)o[a]=parseFloat(n[a]);i[s[r].getAttribute("id")]=o}t.triangles=[];var l=e.getElementsByTagName("triangles");if(null==l)return t;for(r=0;r<l.length;r++){var c={},h=l[r];c.material=h.getAttribute("material");var u=h.getElementsByTagName("input"),d=[];for(a=0;a<u.length;a++){var p=u[a];o=[];d[parseInt(p.getAttribute("offset"))]=o;var f=p.getAttribute("semantic");c["s_"+f]="VERTEX"==f?e.getElementsByTagName("vertices")[0].getElementsByTagName("input")[0].getAttribute("source").substring(1):p.getAttribute("source").substring(1),c["i_"+f]=o,i[c["s_"+f]]}var g=h.getElementsByTagName("p")[0].textContent.split(" "),m=3*Math.floor(g.length/3);for(a=0;a<m;a++)d[a%u.length].push(parseInt(g[a]));t.triangles.push(c)}return t},je.parse.fromCollada._libImages=function(e){e=e.getElementsByTagName("image");for(var t={},s=0;s<e.length;s++)t[e[s].getAttribute("id")]=e[s].getElementsByTagName("init_from")[0].textContent;return t},je.parse.fromCollada._libMaterials=function(e){e=e.getElementsByTagName("material");for(var t={},s=0;s<e.length;s++)t[e[s].getAttribute("name")]=e[s].getElementsByTagName("instance_effect")[0].getAttribute("url").substring(1);return t},je.parse.fromCollada._libEffects=function(e){e=e.getElementsByTagName("effect");for(var t={},s=0;s<e.length;s++){for(var i={},r=e[s].getElementsByTagName("newparam"),n=0;n<r.length;n++){var A=r[n].getElementsByTagName("surface")[0];A&&(i.surface=A.getElementsByTagName("init_from")[0].textContent)}t[e[s].getAttribute("id")]=i}return t},je.parse.from3DS=function(e){e=new Uint8Array(e);var t={};if(19789!=je.bin.rsl(e,0))return null;for(var s=je.bin.ril(e,2),i=6;i<s;){var r=je.bin.rsl(e,i),n=je.bin.ril(e,i+2);15677==r&&(t.edit=je.parse.from3DS._edit3ds(e,i,n)),45056==r&&(t.keyf=je.parse.from3DS._keyf3ds(e,i,n)),i+=n}return t},je.parse.from3DS._edit3ds=function(e,t,s){for(var i={},r=t+6;r<t+s;){var n=je.bin.rsl(e,r),A=je.bin.ril(e,r+2);16384==n&&(null==i.objects&&(i.objects=[]),i.objects.push(je.parse.from3DS._edit_object(e,r,A))),r+=A}return i},je.parse.from3DS._keyf3ds=function(e,t,s){for(var i={},r=t+6;r<t+s;){var n=je.bin.rsl(e,r),A=je.bin.ril(e,r+2);45058==n&&(null==i.desc&&(i.desc=[]),i.desc.push(je.parse.from3DS._keyf_objdes(e,r,A))),r+=A}return i},je.parse.from3DS._keyf_objdes=function(e,t,s){for(var i={},r=t+6;r<t+s;){var n=je.bin.rsl(e,r),A=je.bin.ril(e,r+2);45072==n&&(i.hierarchy=je.parse.from3DS._keyf_objhierarch(e,r,A)),45073==n&&(i.dummy_name=je.bin.rASCII0(e,r+6)),r+=A}return i},je.parse.from3DS._keyf_objhierarch=function(e,t,s){var i={},r=t+6;return i.name=je.bin.rASCII0(e,r),r+=i.name.length+1,i.hierarchy=je.bin.rsl(e,r+4),i},je.parse.from3DS._edit_object=function(e,t,s){var i={},r=t+6;for(i.name=je.bin.rASCII0(e,r),r+=i.name.length+1;r<t+s;){var n=je.bin.rsl(e,r),A=je.bin.ril(e,r+2);16640==n&&(i.mesh=je.parse.from3DS._obj_trimesh(e,r,A)),r+=A}return i},je.parse.from3DS._obj_trimesh=function(e,t,s){for(var i={},r=t+6;r<t+s;){var n=je.bin.rsl(e,r),A=je.bin.ril(e,r+2);16656==n&&(i.vertices=je.parse.from3DS._tri_vertexl(e,r,A)),16672==n&&(i.indices=je.parse.from3DS._tri_facel1(e,r,A)),16704==n&&(i.uvt=je.parse.from3DS._tri_mappingcoors(e,r,A)),16736==n&&(i.local=je.parse.from3DS._tri_local(e,r,A)),r+=A}return i},je.parse.from3DS._tri_vertexl=function(e,t,s){var i=[],r=t+6,n=je.bin.rsl(e,r);r+=2;for(var A=0;A<n;A++)i.push(je.bin.rf(e,r)),i.push(je.bin.rf(e,r+4)),i.push(je.bin.rf(e,r+8)),r+=12;return i},je.parse.from3DS._tri_facel1=function(e,t,s){var i=[],r=t+6,n=je.bin.rsl(e,r);r+=2;for(var A=0;A<n;A++)i.push(je.bin.rsl(e,r)),i.push(je.bin.rsl(e,r+2)),i.push(je.bin.rsl(e,r+4)),r+=8;return i},je.parse.from3DS._tri_mappingcoors=function(e,t,s){var i=[],r=t+6,n=je.bin.rsl(e,r);r+=2;for(var A=0;A<n;A++)i.push(je.bin.rf(e,r)),i.push(1-je.bin.rf(e,r+4)),r+=8;return i},je.parse.from3DS._tri_local=function(e,t,s){var i={},r=t+6;return i.X=[je.bin.rf(e,r),je.bin.rf(e,r+4),je.bin.rf(e,r+8)],r+=12,i.Y=[je.bin.rf(e,r),je.bin.rf(e,r+4),je.bin.rf(e,r+8)],r+=12,i.Z=[je.bin.rf(e,r),je.bin.rf(e,r+4),je.bin.rf(e,r+8)],r+=12,i.C=[je.bin.rf(e,r),je.bin.rf(e,r+4),je.bin.rf(e,r+8)],r+=12,i},je.parse.fromBIV=function(e){e=new Uint8Array(e);var t={},s={};return s.id=je.bin.ril(e,0),s.verS=je.bin.ril(e,4),s.texS=je.bin.ril(e,8),s.indS=je.bin.ril(e,12),s.verO=je.bin.ril(e,16),s.verL=je.bin.ril(e,20),s.texO=je.bin.ril(e,24),s.texL=je.bin.ril(e,28),s.indO=je.bin.ril(e,32),s.indL=je.bin.ril(e,36),0!=s.verO&&(t.vertices=je.parse.fromBIV._readFloats(e,s.verO,s.verL)),0!=s.texO&&(t.uvt=je.parse.fromBIV._readFloats(e,s.texO,s.texL)),0!=s.indO&&(t.indices=je.parse.fromBIV._readInts(e,s.indO,s.indL,s.indS)),t},je.parse.toBIV=function(e){for(var t=0,s=0;s<e.indices.length;s++)t=Math.max(t,e.indices[s]);var i=32;t<=65535&&(i=16);var r=40;e.vertices&&(r+=4*e.vertices.length),e.uvt&&(r+=4*e.uvt.length),e.indices&&(r+=e.indices.length*i/8);var n=new Uint8Array(r);je.bin.wil(n,0,1769365870),je.bin.wil(n,4,32),je.bin.wil(n,8,32),je.bin.wil(n,12,i);var A=40;return e.vertices&&(je.bin.wil(n,16,A),je.bin.wil(n,20,4*e.vertices.length),je.parse.fromBIV._writeFloats(n,A,e.vertices),A+=4*e.vertices.length),e.uvt&&(je.bin.wil(n,24,A),je.bin.wil(n,28,4*e.uvt.length),je.parse.fromBIV._writeFloats(n,A,e.uvt),A+=4*e.uvt.length),e.indices&&(je.bin.wil(n,32,A),je.bin.wil(n,36,4*e.indices.length),je.parse.fromBIV._writeInts(n,A,e.indices,i)),n.buffer},je.parse.fromBIV._readFloats=function(e,t,s){for(var i=[],r=0;r<s/4;r++)i.push(je.bin.rf(e,t+4*r));return i},je.parse.fromBIV._writeFloats=function(e,t,s){for(var i=0;i<s.length;i++)je.bin.wf(e,t+4*i,s[i])},je.parse.fromBIV._readInts=function(e,t,s,i){for(var r=[],n=0;n<s/4;n++)16==i&&r.push(je.bin.rsl(e,t+2*n)),32==i&&r.push(je.bin.ril(e,t+4*n));return r},je.parse.fromBIV._writeInts=function(e,t,s,i){for(var r=0;r<s.length;r++)16==i&&je.bin.wsl(e,t+2*r,s[r]),32==i&&je.bin.wil(e,t+4*r,s[r])},je.gen={},je.gen.Plane=function(e,t,s,i){s||(s=1),i||(i=1);for(var r={verts:[],inds:[],uvt:[]},n=e+1,A=t+1,o=0;o<A;o++)for(var a=0;a<n;a++){var l=a*(2/e)-1,c=o*(2/t)-1;r.verts.push(l,c,0),r.uvt.push(s*a/e,i*o/t),o<t&&a<e&&r.inds.push(o*n+a,o*n+a+1,(o+1)*n+a,o*n+a+1,(o+1)*n+a,(o+1)*n+a+1)}return r},je.gen.Cube=function(){return{verts:[-1,1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,1,-1,1,1,-1,-1,-1,1,-1,1,1,-1,-1,1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,-1,1,1,-1,1],inds:[0,1,2,1,2,3,4,5,6,5,6,7,8,9,10,9,10,11,12,13,14,13,14,15,16,17,18,17,18,19,20,21,22,21,22,23],uvt:[1/4,1/4,.5,1/4,1/4,.5,.5,.5,1,1/4,3/4,1/4,1,.5,3/4,.5,0,1/4,1/4,1/4,0,.5,1/4,.5,3/4,1/4,.5,1/4,3/4,.5,.5,.5,1/4,1/4,.5,1/4,1/4,0,.5,0,1/4,.5,.5,.5,1/4,3/4,.5,3/4]}},je.gen.Sphere=function(e,t){for(var s={verts:[],inds:[],uvt:[]},i=e+1,r=t+1,n=0;n<r;n++)for(var A=0;A<i;A++){var o=-Math.PI/2+n*Math.PI/t,a=2*A*Math.PI/e,l=Math.cos(o)*Math.cos(a),c=Math.sin(o),h=Math.cos(o)*Math.sin(a);s.verts.push(l,c,h),s.uvt.push(A/e,n/t),n<t&&A<e&&s.inds.push(i*n+A,i*n+A+1,i*(n+1)+A,i*n+A+1,i*(n+1)+A,i*(n+1)+A+1)}return s},je.mat={},je.mat.scale=function(e,t,s){return[e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1]},je.mat.translate=function(e,t,s){return[1,0,0,0,0,1,0,0,0,0,1,0,e,t,s,1]},je.mat.rotateDeg=function(e,t,s){var i=Math.PI/180;return je.mat.rotate(e*i,t*i,s*i)},je.mat.rotate=function(e,t,s){var i=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r=e,n=t,A=s,o=Math.cos(r),a=Math.cos(n),l=Math.cos(A),c=Math.sin(r),h=Math.sin(n),u=Math.sin(A);return i[0]=a*l,i[1]=-a*u,i[2]=h,i[4]=o*u+c*h*l,i[5]=o*l-c*h*u,i[6]=-c*a,i[8]=c*u-o*h*l,i[9]=c*l+o*h*u,i[10]=o*a,i},je.edit={},je.edit.interpolate=function(e,t,s,i){for(var r=0;r<e.length;r++)s[r]=e[r]+i*(t[r]-e[r])},je.edit.transform=function(e,t){for(var s=0;s<e.length;s+=3){var i=e[s],r=e[s+1],n=e[s+2];e[s+0]=t[0]*i+t[4]*r+t[8]*n+t[12],e[s+1]=t[1]*i+t[5]*r+t[9]*n+t[13],e[s+2]=t[2]*i+t[6]*r+t[10]*n+t[14]}},je.edit.unwrap=function(e,t,s){for(var i=new Array(Math.floor(e.length/3)*s),r=0;r<e.length;r++)for(var n=0;n<s;n++)i[r*s+n]=t[e[r]*s+n];return i},je.edit.remap=function(e,t,s,i){for(var r=new Array(s.length),n=0;n<e.length;n++)for(var A=0;A<i;A++)r[t[n]*i+A]=s[e[n]*i+A];return r},je.utils={},je.utils.getAABB=function(e){var t,s,i,r,n,A;r=n=A=-(t=s=i=999999999);for(var o=0;o<e.length;o+=3){var a=e[o+0],l=e[o+1],c=e[o+2];a<t&&(t=a),a>r&&(r=a),l<s&&(s=l),l>n&&(n=l),c<i&&(i=c),l>A&&(A=c)}return{min:{x:t,y:s,z:i},max:{x:r,y:n,z:A}}};const $e={" ":{width:16,points:[]},"!":{width:10,points:[[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},'"':{width:16,points:[[4,21],[4,14],[-1,-1],[12,21],[12,14]]},"#":{width:21,points:[[11,25],[4,-7],[-1,-1],[17,25],[10,-7],[-1,-1],[4,12],[18,12],[-1,-1],[3,6],[17,6]]},$:{width:20,points:[[8,25],[8,-4],[-1,-1],[12,25],[12,-4],[-1,-1],[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},"%":{width:24,points:[[21,21],[3,0],[-1,-1],[8,21],[10,19],[10,17],[9,15],[7,14],[5,14],[3,16],[3,18],[4,20],[6,21],[8,21],[10,20],[13,19],[16,19],[19,20],[21,21],[-1,-1],[17,7],[15,6],[14,4],[14,2],[16,0],[18,0],[20,1],[21,3],[21,5],[19,7],[17,7]]},"&":{width:26,points:[[23,12],[23,13],[22,14],[21,14],[20,13],[19,11],[17,6],[15,3],[13,1],[11,0],[7,0],[5,1],[4,2],[3,4],[3,6],[4,8],[5,9],[12,13],[13,14],[14,16],[14,18],[13,20],[11,21],[9,20],[8,18],[8,16],[9,13],[11,10],[16,3],[18,1],[20,0],[22,0],[23,1],[23,2]]},"'":{width:10,points:[[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]]},"(":{width:14,points:[[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]]},")":{width:14,points:[[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]]},"*":{width:16,points:[[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]]},"+":{width:26,points:[[13,18],[13,0],[-1,-1],[4,9],[22,9]]},",":{width:10,points:[[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"-":{width:26,points:[[4,9],[22,9]]},".":{width:10,points:[[5,2],[4,1],[5,0],[6,1],[5,2]]},"/":{width:22,points:[[20,25],[2,-7]]},0:{width:20,points:[[9,21],[6,20],[4,17],[3,12],[3,9],[4,4],[6,1],[9,0],[11,0],[14,1],[16,4],[17,9],[17,12],[16,17],[14,20],[11,21],[9,21]]},1:{width:20,points:[[6,17],[8,18],[11,21],[11,0]]},2:{width:20,points:[[4,16],[4,17],[5,19],[6,20],[8,21],[12,21],[14,20],[15,19],[16,17],[16,15],[15,13],[13,10],[3,0],[17,0]]},3:{width:20,points:[[5,21],[16,21],[10,13],[13,13],[15,12],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},4:{width:20,points:[[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]]},5:{width:20,points:[[15,21],[5,21],[4,12],[5,13],[8,14],[11,14],[14,13],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},6:{width:20,points:[[16,18],[15,20],[12,21],[10,21],[7,20],[5,17],[4,12],[4,7],[5,3],[7,1],[10,0],[11,0],[14,1],[16,3],[17,6],[17,7],[16,10],[14,12],[11,13],[10,13],[7,12],[5,10],[4,7]]},7:{width:20,points:[[17,21],[7,0],[-1,-1],[3,21],[17,21]]},8:{width:20,points:[[8,21],[5,20],[4,18],[4,16],[5,14],[7,13],[11,12],[14,11],[16,9],[17,7],[17,4],[16,2],[15,1],[12,0],[8,0],[5,1],[4,2],[3,4],[3,7],[4,9],[6,11],[9,12],[13,13],[15,14],[16,16],[16,18],[15,20],[12,21],[8,21]]},9:{width:20,points:[[16,14],[15,11],[13,9],[10,8],[9,8],[6,9],[4,11],[3,14],[3,15],[4,18],[6,20],[9,21],[10,21],[13,20],[15,18],[16,14],[16,9],[15,4],[13,1],[10,0],[8,0],[5,1],[4,3]]},":":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},";":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"<":{width:24,points:[[20,18],[4,9],[20,0]]},"=":{width:26,points:[[4,12],[22,12],[-1,-1],[4,6],[22,6]]},">":{width:24,points:[[4,18],[20,9],[4,0]]},"?":{width:18,points:[[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]]},"@":{width:27,points:[[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]]},A:{width:18,points:[[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]]},B:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]]},C:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]]},D:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]]},E:{width:19,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]]},F:{width:18,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]]},G:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]]},H:{width:22,points:[[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]]},I:{width:8,points:[[4,21],[4,0]]},J:{width:16,points:[[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]]},K:{width:21,points:[[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]]},L:{width:17,points:[[4,21],[4,0],[-1,-1],[4,0],[16,0]]},M:{width:24,points:[[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]]},N:{width:22,points:[[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]]},O:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]]},P:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]]},Q:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]]},R:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]]},S:{width:20,points:[[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},T:{width:16,points:[[8,21],[8,0],[-1,-1],[1,21],[15,21]]},U:{width:22,points:[[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]]},V:{width:18,points:[[1,21],[9,0],[-1,-1],[17,21],[9,0]]},W:{width:24,points:[[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]]},X:{width:20,points:[[3,21],[17,0],[-1,-1],[17,21],[3,0]]},Y:{width:18,points:[[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]]},Z:{width:20,points:[[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]]},"[":{width:14,points:[[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]]},"\\":{width:14,points:[[0,21],[14,-3]]},"]":{width:14,points:[[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]]},"^":{width:16,points:[[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]]},_:{width:16,points:[[0,-2],[16,-2]]},"`":{width:10,points:[[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]]},a:{width:19,points:[[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},b:{width:19,points:[[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},c:{width:18,points:[[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},d:{width:19,points:[[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},e:{width:18,points:[[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},f:{width:12,points:[[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]]},g:{width:19,points:[[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},h:{width:19,points:[[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},i:{width:8,points:[[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]]},j:{width:10,points:[[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]]},k:{width:17,points:[[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]]},l:{width:8,points:[[4,21],[4,0]]},m:{width:30,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]]},n:{width:19,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},o:{width:19,points:[[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]]},p:{width:19,points:[[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},q:{width:19,points:[[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},r:{width:13,points:[[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]]},s:{width:17,points:[[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]]},t:{width:12,points:[[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]]},u:{width:19,points:[[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]]},v:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0]]},w:{width:22,points:[[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]]},x:{width:17,points:[[3,14],[14,0],[-1,-1],[14,14],[3,0]]},y:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]]},z:{width:17,points:[[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]]},"{":{width:14,points:[[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]]},"|":{width:8,points:[[4,25],[4,-7]]},"}":{width:14,points:[[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]]},"~":{width:24,points:[[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]]}};function qe(e={}){var t=e.origin||[0,0,0],s=t[0],i=t[1],r=t[2],n=e.size||1,A=[],o=[],a=e.text;j.isNumeric(a)&&(a=""+a);for(var l,c,h,u,d,p,f,g,m,_=(a||"").split("\n"),b=0,B=0,y=.04,w=0;w<_.length;w++){l=0,h=(c=_[w]).length;for(var v=0;v<h;v++)if(u=$e[c.charAt(v)]){d=1,p=-1,f=-1,g=u.points.length;for(var C=0;C<g;C++)-1!==(m=u.points[C])[0]||-1!==m[1]?(A.push(l+m[0]*n*y+s),A.push(B+m[1]*n*y+i),A.push(0+r),-1===p?p=b:(-1===f||(p=f),f=b),b++,d?d=!1:(o.push(p),o.push(f))):d=1;l+=u.width*y*n}B-=35*y*n}return j.apply(e,{primitive:"lines",positions:A,indices:o})}function et(e={}){if(e.points.length%3!=0)throw"Size of points array for given polyline should be divisible by 3";let t=e.points.length/3;if(t<2)throw"There should be at least 2 points to create a polyline";let s=[];for(let e=0;e<t-1;e++)s.push(e),s.push(e+1);return j.apply(e,{primitive:"lines",positions:e.points,indices:s})}const tt=R.vec4(4),st=R.vec4(),it=R.vec4(),rt=R.vec3([1,0,0]),nt=R.vec3([0,1,0]),At=R.vec3([0,0,1]),ot=R.vec3(3),at=R.vec3(3),lt=R.identityMat4();class ct extends ie{constructor(e,t={}){if(super(e,t),this._parentNode=null,this._children=[],this._aabb=null,this._aabbDirty=!0,this.scene._aabbDirty=!0,this._numTriangles=0,this._scale=R.vec3(),this._quaternion=R.identityQuaternion(),this._rotation=R.vec3(),this._position=R.vec3(),this._offset=R.vec3(),this._localMatrix=R.identityMat4(),this._worldMatrix=R.identityMat4(),this._localMatrixDirty=!0,this._worldMatrixDirty=!0,t.matrix?this.matrix=t.matrix:(this.scale=t.scale,this.position=t.position,t.quaternion||(this.rotation=t.rotation)),this._isModel=t.isModel,this._isModel&&this.scene._registerModel(this),this._isObject=t.isObject,this._isObject&&this.scene._registerObject(this),this.origin=t.origin,this.visible=t.visible,this.culled=t.culled,this.pickable=t.pickable,this.clippable=t.clippable,this.collidable=t.collidable,this.castsShadow=t.castsShadow,this.receivesShadow=t.receivesShadow,this.xrayed=t.xrayed,this.highlighted=t.highlighted,this.selected=t.selected,this.edges=t.edges,this.colorize=t.colorize,this.opacity=t.opacity,this.offset=t.offset,t.children){const e=t.children;for(let s=0,i=e.length;s<i;s++)this.addChild(e[s],t.inheritStates)}if(t.parentId){const e=this.scene.components[t.parentId];e?e.isNode?e.addChild(this):this.error("Parent is not a Node: '"+t.parentId+"'"):this.error("Parent not found: '"+t.parentId+"'")}else t.parent&&(t.parent.isNode||this.error("Parent is not a Node"),t.parent.addChild(this))}get isEntity(){return!0}get isModel(){return this._isModel}get isObject(){return this._isObject}get aabb(){return this._aabbDirty&&this._updateAABB(),this._aabb}set origin(e){e?(this._origin||(this._origin=R.vec3()),this._origin.set(e)):this._origin&&(this._origin=null);for(let t=0,s=this._children.length;t<s;t++)this._children[t].origin=e;this.glRedraw()}get origin(){return this._origin}set rtcCenter(e){this.origin=e}get rtcCenter(){return this.origin}get numTriangles(){return this._numTriangles}set visible(e){e=!1!==e,this._visible=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].visible=e;this._isObject&&this.scene._objectVisibilityUpdated(this,e)}get visible(){return this._visible}set xrayed(e){e=!!e,this._xrayed=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].xrayed=e;this._isObject&&this.scene._objectXRayedUpdated(this,e)}get xrayed(){return this._xrayed}set highlighted(e){e=!!e,this._highlighted=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].highlighted=e;this._isObject&&this.scene._objectHighlightedUpdated(this,e)}get highlighted(){return this._highlighted}set selected(e){e=!!e,this._selected=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].selected=e;this._isObject&&this.scene._objectSelectedUpdated(this,e)}get selected(){return this._selected}set edges(e){e=!!e,this._edges=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].edges=e}get edges(){return this._edges}set culled(e){e=!!e,this._culled=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].culled=e}get culled(){return this._culled}set clippable(e){e=!1!==e,this._clippable=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].clippable=e}get clippable(){return this._clippable}set collidable(e){e=!1!==e,this._collidable=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].collidable=e}get collidable(){return this._collidable}set pickable(e){e=!1!==e,this._pickable=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].pickable=e}get pickable(){return this._pickable}set colorize(e){let t=this._colorize;t||(t=this._colorize=new Float32Array(4),t[3]=1),e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1);for(let e=0,s=this._children.length;e<s;e++)this._children[e].colorize=t;if(this._isObject){const t=!!e;this.scene._objectColorizeUpdated(this,t)}}get colorize(){return this._colorize.slice(0,3)}set opacity(e){let t=this._colorize;t||(t=this._colorize=new Float32Array(4),t[0]=1,t[1]=1,t[2]=1),t[3]=null!=e?e:1;for(let t=0,s=this._children.length;t<s;t++)this._children[t].opacity=e;if(this._isObject){const t=null!=e;this.scene._objectOpacityUpdated(this,t)}}get opacity(){return this._colorize[3]}set castsShadow(e){e=!!e,this._castsShadow=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].castsShadow=e}get castsShadow(){return this._castsShadow}set receivesShadow(e){e=!!e,this._receivesShadow=e;for(let t=0,s=this._children.length;t<s;t++)this._children[t].receivesShadow=e}get receivesShadow(){return this._receivesShadow}get saoEnabled(){return!1}set offset(e){e?(this._offset[0]=e[0],this._offset[1]=e[1],this._offset[2]=e[2]):(this._offset[0]=0,this._offset[1]=0,this._offset[2]=0);for(let e=0,t=this._children.length;e<t;e++)this._children[e].offset=this._offset;this._isObject&&this.scene._objectOffsetUpdated(this,e)}get offset(){return this._offset}get isNode(){return!0}_setLocalMatrixDirty(){this._localMatrixDirty=!0,this._setWorldMatrixDirty()}_setWorldMatrixDirty(){this._worldMatrixDirty=!0;for(let e=0,t=this._children.length;e<t;e++)this._children[e]._setWorldMatrixDirty()}_buildWorldMatrix(){const e=this.matrix;if(this._parentNode)R.mulMat4(this._parentNode.worldMatrix,e,this._worldMatrix);else for(let t=0,s=e.length;t<s;t++)this._worldMatrix[t]=e[t];this._worldMatrixDirty=!1}_setSubtreeAABBsDirty(e){if(e._aabbDirty=!0,e._children)for(let t=0,s=e._children.length;t<s;t++)this._setSubtreeAABBsDirty(e._children[t])}_setAABBDirty(){if(this._setSubtreeAABBsDirty(this),this.collidable)for(let e=this;e;e=e._parentNode)e._aabbDirty=!0}_updateAABB(){if(this.scene._aabbDirty=!0,this._aabb||(this._aabb=R.AABB3()),this._buildAABB)this._buildAABB(this.worldMatrix,this._aabb);else{let e;R.collapseAABB3(this._aabb);for(let t=0,s=this._children.length;t<s;t++)e=this._children[t],e.collidable&&R.expandAABB3(this._aabb,e.aabb)}this._aabbDirty=!1}addChild(e,t){if(j.isNumeric(e)||j.isString(e)){const t=e;if(!(e=this.scene.component[t]))return void this.warn("Component not found: "+j.inQuotes(t));if(!e.isNode&&!e.isMesh)return void this.error("Not a Node or Mesh: "+t)}else{if(!e.isNode&&!e.isMesh)return void this.error("Not a Node or Mesh: "+e.id);if(e._parentNode){if(e._parentNode.id===this.id)return void this.warn("Already a child: "+e.id);e._parentNode.removeChild(e)}}if(e.id,e.scene.id===this.scene.id)return this._children.push(e),e._parentNode=this,t&&(e.visible=this.visible,e.culled=this.culled,e.xrayed=this.xrayed,e.highlited=this.highlighted,e.selected=this.selected,e.edges=this.edges,e.clippable=this.clippable,e.pickable=this.pickable,e.collidable=this.collidable,e.castsShadow=this.castsShadow,e.receivesShadow=this.receivesShadow,e.colorize=this.colorize,e.opacity=this.opacity,e.offset=this.offset),e._setWorldMatrixDirty(),e._setAABBDirty(),this._numTriangles+=e.numTriangles,e;this.error("Child not in same Scene: "+e.id)}removeChild(e){for(let t=0,s=this._children.length;t<s;t++)if(this._children[t].id===e.id)return e._parentNode=null,this._children=this._children.splice(t,1),e._setWorldMatrixDirty(),e._setAABBDirty(),this._setAABBDirty(),void(this._numTriangles-=e.numTriangles)}removeChildren(){let e;for(let t=0,s=this._children.length;t<s;t++)e=this._children[t],e._parentNode=null,e._setWorldMatrixDirty(),e._setAABBDirty(),this._numTriangles-=e.numTriangles;this._children=[],this._setAABBDirty()}get numChildren(){return this._children.length}get children(){return this._children}set parent(e){if(j.isNumeric(e)||j.isString(e)){const t=e;if(!(e=this.scene.components[t]))return void this.warn("Node not found: "+j.inQuotes(t));if(!e.isNode)return void this.error("Not a Node: "+e.id)}e.scene.id===this.scene.id?this._parentNode&&this._parentNode.id===e.id?this.warn("Already a child of Node: "+e.id):e.addChild(this):this.error("Node not in same Scene: "+e.id)}get parent(){return this._parentNode}set position(e){this._position.set(e||[0,0,0]),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get position(){return this._position}set rotation(e){this._rotation.set(e||[0,0,0]),R.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get rotation(){return this._rotation}set quaternion(e){this._quaternion.set(e||[0,0,0,1]),R.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get quaternion(){return this._quaternion}set scale(e){this._scale.set(e||[1,1,1]),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get scale(){return this._scale}set matrix(e){this._localMatrix||(this._localMatrix=R.identityMat4()),this._localMatrix.set(e||lt),R.decomposeMat4(this._localMatrix,this._position,this._quaternion,this._scale),this._localMatrixDirty=!1,this._setWorldMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get matrix(){return this._localMatrixDirty&&(this._localMatrix||(this._localMatrix=R.identityMat4()),R.composeMat4(this._position,this._quaternion,this._scale,this._localMatrix),this._localMatrixDirty=!1),this._localMatrix}get worldMatrix(){return this._worldMatrixDirty&&this._buildWorldMatrix(),this._worldMatrix}rotate(e,t){return tt[0]=e[0],tt[1]=e[1],tt[2]=e[2],tt[3]=t*R.DEGTORAD,R.angleAxisToQuaternion(tt,st),R.mulQuaternions(this.quaternion,st,it),this.quaternion=it,this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}rotateOnWorldAxis(e,t){return tt[0]=e[0],tt[1]=e[1],tt[2]=e[2],tt[3]=t*R.DEGTORAD,R.angleAxisToQuaternion(tt,st),R.mulQuaternions(st,this.quaternion,st),this}rotateX(e){return this.rotate(rt,e)}rotateY(e){return this.rotate(nt,e)}rotateZ(e){return this.rotate(At,e)}translate(e,t){return R.vec3ApplyQuaternion(this.quaternion,e,ot),R.mulVec3Scalar(ot,t,at),R.addVec3(this.position,at,this.position),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}translateX(e){return this.translate(rt,e)}translateY(e){return this.translate(nt,e)}translateZ(e){return this.translate(At,e)}get type(){return"Node"}destroy(){if(super.destroy(),this._parentNode&&this._parentNode.removeChild(this),this._isObject&&(this.scene._deregisterObject(this),this._visible&&this.scene._objectVisibilityUpdated(this,!1,!1),this._xrayed&&this.scene._objectXRayedUpdated(this,!1,!1),this._selected&&this.scene._objectSelectedUpdated(this,!1,!1),this._highlighted&&this.scene._objectHighlightedUpdated(this,!1,!1),this.scene._objectColorizeUpdated(this,!1),this.scene._objectOpacityUpdated(this,!1),this.offset.some((e=>0!==e))&&this.scene._objectOffsetUpdated(this,!1)),this._isModel&&this.scene._deregisterModel(this),this._children.length){const e=this._children.splice(0);let t;for(let s=0,i=e.length;s<i;s++)t=e[s],t.destroy()}this._children=[],this._setAABBDirty(),this.scene._aabbDirty=!0}}const ht=R.vec3(),ut=function(){const e=new Float64Array(16),t=new Float64Array(4),s=new Float64Array(4);return function(i,r,n){return n=n||e,t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=1,R.transformVec4(i,t,s),R.setMat4Translation(i,s,n),n.slice()}}();function dt(e,t,s){const i=Float32Array.from([e[0]])[0],r=e[0]-i,n=Float32Array.from([e[1]])[0],A=e[1]-n,o=Float32Array.from([e[2]])[0],a=e[2]-o;t[0]=i,t[1]=n,t[2]=o,s[0]=r,s[1]=A,s[2]=a}function pt(e,t,s,i=1e3){const r=R.getPositionsCenter(e,ht),n=Math.round(r[0]/i)*i,A=Math.round(r[1]/i)*i,o=Math.round(r[2]/i)*i;s[0]=n,s[1]=A,s[2]=o;const a=0!==s[0]||0!==s[1]||0!==s[2];if(a)for(let s=0,i=e.length;s<i;s+=3)t[s+0]=e[s+0]-n,t[s+1]=e[s+1]-A,t[s+2]=e[s+2]-o;return a}const ft=new e({}),gt=R.vec3(),mt=R.vec4(),_t={3001:"sRGBToLinear"},bt=function(){const e=[],t=[],s=[],i=[],r=[],n=[],A=[],o=(t,s)=>{let i=!1;return e.push((e=>i&&s(t,e))),{toString:()=>(i=!0,t)}},a={createAttribute:function(t,s){let i=!1;e.push((e=>i&&e.push(`in ${t} ${s};`)));const A={toString:()=>(i=!0,s)};return r.push((e=>{const t=i&&e(s);return t&&n.push(t.attributeHash),A.setInputValue=t,null})),A},createFragmentDefinition:(e,t)=>{let s=!1;return i.push((i=>s&&t(e,i))),{toString:()=>(s=!0,e)}},createOutput:(e,t,i)=>{let r=!1;return s.push((s=>r&&s.push(`layout(location = ${i||0}) out ${e} ${t};`))),{toString:()=>(r=!0,t)}},createUniform:(t,i,r)=>{let n=!1;const o=e=>n&&e.push(`uniform ${t} ${i};`);e.push(o),s.push(o);const a={toString:()=>(n=!0,i)};return A.push((e=>{const t=n&&e(i);return r?t&&(e=>r(t,e)):(a.setInputValue=t,null)})),a},createUniformArray:(t,i,r)=>{let n=!1;const o=e=>n&&e.push(`uniform ${t} ${i}[${r}];`);e.push(o),s.push(o);const a={toString:()=>(n=!0,i)};return A.push((e=>(a.setInputValue=n&&e(i),null))),a},createUniformBlock:(t,i,r)=>{let n=!1;const o=Object.keys(i),a=e=>{n&&(e.push(`uniform ${t} {`),o.forEach((t=>e.push(` ${i[t]} ${t};`))),e.push("};"))};e.push(a),s.push(a);const l={};return o.forEach((e=>l[e]={toString:()=>(n=!0,e)})),A.push((e=>{const s=n&&e(t);return r?s&&(e=>r(s,e)):(l.setInputValue=s,null)})),l},createVarying:(i,r,n,A)=>{let o=!1;const a=A?A+" ":"";return e.push((e=>o&&e.push(`${a}out ${i} ${r};`))),t.push((e=>o&&e.push(`${r} = ${n()};`))),s.push((e=>o&&e.push(`${a}in ${i} ${r};`))),{toString:()=>(o=!0,r)}},createVertexDefinition:o,commonLibrary:{octDecode:o("octDecode",((e,t)=>{t.push(`vec3 ${e}(vec2 oct) {`),t.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));"),t.push(" if (v.z < 0.0) {"),t.push(" v.xy = (1.0 - abs(v.yx)) * vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);"),t.push(" }"),t.push(" return normalize(v);"),t.push("}")}))}};return{programVariables:a,buildProgram:(o,l,c)=>{const h=c.getLogDepth,u=c.clipPos,d=c.usePickClipPos&&function(){const e=a.createUniform("vec2","pickClipPos"),t=a.createUniform("vec2","pickClipPosInv");return{setClipPosInputValue:s=>{e.setInputValue(s.pickClipPos),t.setInputValue(s.pickClipPosInv)},transformedClipPos:()=>`vec4((${u}.xy / ${u}.w - ${e}) * ${t} * ${u}.w, ${u}.zw)`}}(),p=d?d.transformedClipPos():u,f=[],g=a.createVarying("float","isPerspective",(()=>`(${c.projMatrix}[2][3] == -1.0) ? 1.0 : 0.0`)),m=a.createUniform("float","logDepthBufFC",((e,t)=>e(2/(Math.log(t.view.far+1)/Math.LN2)))),_=a.createVarying("float","vFragDepth",(()=>"1.0 + clipPos.w"));h?f.push(`gl_FragDepth = ${c.testPerspectiveForGl_FragDepth?`${g} == 0.0 ? gl_FragCoord.z : `:""}log2(${h(_)}) * ${m} * 0.5;`):c.cleanerEdges&&f.push("gl_FragDepth = gl_FragCoord.z + length(vec2(dFdx(gl_FragCoord.z), dFdy(gl_FragCoord.z)));");const b=a.createFragmentDefinition("linearToGamma",((e,t)=>{t.push(`vec4 ${e}(in vec4 value, in float gammaFactor) {`),t.push(" return vec4(pow(value.xyz, vec3(1.0 / gammaFactor)), value.w);"),t.push("}")})),B=c.sectionPlanesState,y=B&&function(){const e=function(e){const t=[];for(let s=0;s<e;++s)t.push(s);return t}(B.getNumAllocatedSectionPlanes()).map((e=>{const t=(t,s,i)=>a.createUniform(t,`sectionPlane${s}${e}`,((t,s)=>{const r=B.sectionPlanes,n=r.length,A=(s.mesh.layerIndex||0)*n,o=e<n&&s.mesh.renderFlags.sectionPlanesActivePerLayer[A+e];return i(t,o,r[e],s.mesh.origin)}));return{act:t("bool","Active",((e,t)=>e(t?1:0))),dir:t("vec3","Dir",((e,t,s)=>t&&e(s.dir))),pos:t("vec3","Pos",((e,t,s,i)=>t&&e(i?R.mulVec3Scalar(R.normalizeVec3(s.dir,gt),-(R.dotVec3(s.dir,i)+s.dist),gt):s.pos)))}}));return e.length>0&&(t=>e.map((e=>`(${e.act} ? clamp(dot(-${e.dir}, ${t} - ${e.pos}), 0.0, 1000.0) : 0.0)`)).join(" + "))}(),w=c.crossSections,v=y?function(){const e=a.createUniform("vec4","sliceColor",(e=>e(w.sliceColor))),t=s=>(t.needed=!0,`(sliced ? ${e} : ${s})`);return t}():e=>e,C=c.getGammaFactor,M=a.createUniform("float","gammaFactor",(e=>e(C())));c.appendFragmentOutputs(f,C&&(e=>`${b}(${e}, ${M})`),"gl_FragCoord",v);const E=function(){const e=[],t=a.createUniform("float","sliceThickness",(e=>e(w.sliceThickness)));if(y){v.needed&&e.push(" bool sliced = false;"),e.push(` if (${c.clippableTest()}) {`);const s=a.createVarying("highp vec3","vHighpWorldPosition",(()=>`${c.worldPositionAttribute}.xyz`));if(e.push(` float dist = ${y(s)};`),c.clippingCaps){const t=a.createVarying("float","vClipPositionW",(()=>"gl_Position.w"));e.push(` if (dist > (0.002 * ${t})) { discard; }`),e.push(" if (dist > 0.0) { "),e.push(` ${c.clippingCaps} = vec4(1.0, 0.0, 0.0, 1.0);`),h&&e.push(` gl_FragDepth = log2(${h(_)}) * ${m} * 0.5;`),e.push(" return;"),e.push(" }")}else e.push(` if (dist > ${v.needed?t:"0.0"}) { discard; }`);v.needed&&e.push(" sliced = dist > 0.0;"),e.push(" }")}return e}(),F=function(){const e=[];return i.forEach((t=>t(e))),e}(),x=[...function(){const e=[];return s.forEach((t=>t(e))),e}(),...F,"void main(void) {",...c.discardPoints?[" vec2 cxy = 2.0 * gl_PointCoord - 1.0;"," if (dot(cxy, cxy) > 1.0) { discard; }"]:[],...E,...f,"}"],U=[`gl_Position = ${p};`,...c.getPointSize?[`gl_PointSize = ${c.getPointSize()};`]:[],...function(){const e=[];return t.forEach((t=>t(e))),e}()],I=c.getVertexData?c.getVertexData():[],T=[...function(){const t=[];return e.forEach((e=>e(t))),t}(),"void main(void) {",...I,...U,"}"],P=e=>["#version 300 es","// "+l+" "+e+" shader","#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","precision highp int;","precision highp usampler2D;","precision highp isampler2D;","precision highp sampler2D;","#else","precision mediump float;","precision mediump int;","precision mediump usampler2D;","precision mediump isampler2D;","precision mediump sampler2D;","#endif"],S=P("vertex").concat(T),D=P("fragment").concat(["vec4 sRGBToLinear(in vec4 value) {"," return vec4(mix(pow(value.rgb * 0.9478672986 + 0.0521327014, vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.w);","}"]).concat(x),k=(e,t)=>{const s=t.join("\n"),i=o.createShader(e);return o.shaderSource(i,s),o.compileShader(i),o.getShaderParameter(i,o.COMPILE_STATUS)?[i]:[null,["Failed to compile",o.getShaderInfoLog(i),s.split("\n").map(((e,t)=>t+1+": "+e+"\n")).join("")]]},[Q,O]=k(o.VERTEX_SHADER,S),[V,L]=k(o.FRAGMENT_SHADER,D),H=e=>(console.error(e.join("\n")),[null,e]);if(O)return H(["Vertex shader error"].concat(O));if(L)return H(["Fragment shader error"].concat(L));{const e=o.createProgram();if(e){if(o.attachShader(e,Q),o.attachShader(e,V),o.linkProgram(e),o.getProgramParameter(e,o.LINK_STATUS)){const t=wt(o,e);r.forEach((e=>e(t)));const s=A.map((e=>e(t))).filter((e=>e)),i=ft.addItem({});return[{id:i,bind:()=>o.useProgram(e),inputSetters:{attributesHash:n.sort().join(", "),setUniforms:(e,t)=>{d&&d.setClipPosInputValue(e),s.forEach((e=>e(t)))}},destroy:()=>{ft.removeItem(i),o.deleteProgram(e),o.deleteShader(Q),o.deleteShader(V)}}]}return H(["",o.getProgramInfoLog(this.program),"","Vertex shader:","",...S,"","Fragment shader:","",...D])}return H(["Failed to allocate program"])}}}},Bt=function(e,t){const s=e.createUniform("vec4","lightAmbient",(e=>e(t.getAmbientColorAndIntensity()))),i=t.lights,r=i.map(((t,s)=>{const r={color:e.createUniform("vec4",`lightColor${s}`,(e=>{const t=i[s];mt[0]=t.color[0],mt[1]=t.color[1],mt[2]=t.color[2],mt[3]=t.intensity,e(mt)})),position:e.createUniform("vec3",`lightPos${s}`,(e=>e(i[s].pos))),direction:e.createUniform("vec3",`lightDir${s}`,(e=>e(i[s].dir))),shadowProjMatrix:e.createUniform("mat4",`shadowProjMatrix${s}`,(e=>e(i[s].getShadowViewMatrix()))),shadowViewMatrix:e.createUniform("mat4",`shadowViewMatrix${s}`,(e=>e(i[s].getShadowViewMatrix()))),shadowMap:e.createUniform("sampler2D",`shadowMap${s}`,(e=>e(i[s].getShadowRenderBuf().colorTextures[0])))},n=e=>({glslLight:{isViewSpace:"view"===t.space,getColor:()=>`${r.color}.rgb * ${r.color}.a`,getDirection:(t,s)=>`normalize(${e(t,s)})`,shadowParameters:t.castsShadow&&{getShadowProjMatrix:()=>r.shadowProjMatrix,getShadowViewMatrix:()=>r.shadowViewMatrix,getShadowMap:()=>r.shadowMap}},setupLightsInputs:()=>{const e=Object.values(r).map((e=>e.setupLightsInputs())).filter((e=>e));return()=>e.forEach((e=>e()))}});return"dir"===t.type?"view"===t.space?n(((e,t)=>`-${r.direction}`)):n(((e,t)=>`-(${e} * vec4(${r.direction}, 0.0)).xyz`)):"point"===t.type?"view"===t.space?n(((e,t)=>`${r.position} - ${t}`)):n(((e,t)=>`(${e} * vec4(${r.position}, 1.0)).xyz - ${t}`)):null})).filter((e=>e)),n=(t,s)=>{const i=()=>{const e=s();return e.length>0&&e[0]},r=i();return r&&yt(e,"samplerCube",t,r.encoding,(e=>{const t=i();t&&e(t.texture)}))},A=n("light",(()=>t.lightMaps)),o=n("reflection",(()=>t.reflectionMaps));return{getHash:()=>t.getHash(),getAmbientColor:()=>`${s}.rgb * ${s}.a`,directionalLights:r.map((e=>e.glslLight)),getIrradiance:A&&(e=>`${A(e)}.rgb`),getReflection:o&&((e,t)=>`${o(e,t)}.rgb`)}},yt=(e,t,s,i,r)=>{const n=e.createUniform(t,s+"Map",r);return(e,t)=>{const s=t?`texture(${n}, ${e}, ${t})`:`texture(${n}, ${e})`;return 3e3!==i?`${_t[i]}(${s})`:s}},wt=function(e,t){const s={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;++r){const n=e.getActiveAttrib(t,r),A=e.getAttribLocation(t,n.name);s[n.name]=function(t){t.bindAtLocation(A),e.enableVertexAttribArray(A);const s=t.attributeDivisor;s&&e.vertexAttribDivisor(A,s)},s[n.name].attributeHash=`${A.toString().padStart(1+Math.floor(Math.log10(i)),"0")}:${n.name}`}const r=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let i=0;i<r;++i){const r=e.getActiveUniformBlockName(t,i),n=e.getUniformBlockIndex(t,r),A=i;e.uniformBlockBinding(t,n,A);const o=e.createBuffer();s[r]=function(t){e.bindBuffer(e.UNIFORM_BUFFER,o),e.bufferData(e.UNIFORM_BUFFER,t,e.DYNAMIC_DRAW),e.bindBufferBase(e.UNIFORM_BUFFER,A,o)}}const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);let A=0;for(let i=0;i<n;++i){const r=e.getActiveUniform(t,i);let n=r.name;n.endsWith("[0]")&&(n=n.substr(0,n.length-3)),"\0"===n[n.length-1]&&(n=n.substr(0,n.length-1));const o=e.getUniformLocation(t,n);if(function(){for(let t in e)if(r.type===e[t])return t}(),r.type===e.SAMPLER_2D||r.type===e.SAMPLER_CUBE||r.type===e.SAMPLER_2D_SHADOW||e instanceof window.WebGL2RenderingContext&&(r.type===e.UNSIGNED_INT_SAMPLER_2D||r.type===e.INT_SAMPLER_2D)){const t=A++;s[n]=function(s){const i=s.bind(t);return i&&e.uniform1i(o,t),i}}else s[n]=function(){if(1===r.size)switch(r.type){case e.BOOL:case e.INT:return t=>e.uniform1i(o,t);case e.FLOAT:return t=>e.uniform1f(o,t);case e.FLOAT_VEC2:return t=>e.uniform2fv(o,t);case e.FLOAT_VEC3:return t=>e.uniform3fv(o,t);case e.FLOAT_VEC4:return t=>e.uniform4fv(o,t);case e.FLOAT_MAT3:return t=>e.uniformMatrix3fv(o,!1,t);case e.FLOAT_MAT4:return t=>e.uniformMatrix4fv(o,!1,t)}else if(r.size>1)switch(r.type){case e.FLOAT:return t=>e.uniform1fv(o,t);case e.FLOAT_VEC2:return t=>e.uniform2fv(o,t);case e.FLOAT_VEC3:return t=>e.uniform3fv(o,t);case e.FLOAT_VEC4:return t=>e.uniform4fv(o,t)}throw`Unhandled uniform ${n}`}()}return function(e){const t=s[e];if(!t)throw`Missing input "${e}"`;return t}},vt=R.vec4(),Ct=R.vec4();class Mt{constructor(){this.visibleLayers=[],this.sectionPlanesActivePerLayer=[],this.reset()}reset(){this.culled=!1,this.sectioned=!1,this.numLayers=0,this.numVisibleLayers=0,this.colorOpaque=!1,this.colorTransparent=!1,this.edgesOpaque=!1,this.edgesTransparent=!1,this.xrayedSilhouetteOpaque=!1,this.xrayedEdgesOpaque=!1,this.xrayedSilhouetteTransparent=!1,this.xrayedEdgesTransparent=!1,this.highlightedSilhouetteOpaque=!1,this.highlightedEdgesOpaque=!1,this.highlightedSilhouetteTransparent=!1,this.highlightedEdgesTransparent=!1,this.selectedSilhouetteOpaque=!1,this.selectedEdgesOpaque=!1,this.selectedSilhouetteTransparent=!1,this.selectedEdgesTransparent=!1}}const Et=R.OBB3(),Ft=R.vec4(),xt=R.vec4(),Ut=R.vec4(),It=R.vec3([1,0,0]),Tt=R.vec3([0,1,0]),Pt=R.vec3([0,0,1]),St=R.vec3(3),Dt=R.vec3(3),kt=R.identityMat4(),Qt=new e({}),Rt={};class Ot extends ie{constructor(e,t={}){super(e,t),this.renderOrder=t.renderOrder||0,this.originalSystemId=t.originalSystemId||this.id,this.renderFlags=new Mt,this._state=new xe({visible:!0,culled:!1,pickable:null,clippable:null,collidable:null,occluder:!1!==t.occluder,castsShadow:null,receivesShadow:null,xrayed:!1,highlighted:!1,selected:!1,edges:!1,stationary:!!t.stationary,background:!!t.background,billboard:this._checkBillboard(t.billboard),layer:null,colorize:null,pickID:this.scene._renderer.getPickID(this),drawHash:"",pickOcclusionHash:"",offset:R.vec3(),origin:null,originHash:null,isUI:t.isUI});const s=t.material?this._checkComponent2(["PhongMaterial","MetallicMaterial","SpecularMaterial","LambertMaterial"],t.material):this.scene.material,i=this,r=e=>{let t=null;const s=()=>{if(!t){const s=bt(),r=s.programVariables.createAttribute,n=i._geometry._state,A={position:r("vec3","position"),color:n.colorsBuf&&r("vec4","color"),pickColor:r("vec4","pickColor"),uv:n.uvBuf&&r("vec2","uv"),normal:(n.autoVertexNormals||n.normalsBuf)&&["triangles","triangle-strip","triangle-fan"].includes(n.primitiveName)&&r("vec3","normal")},o=function(e){const t={toString:()=>(t.needed=!0,e)};return t},a=A.normal&&o("worldNormal"),l=a&&o("viewNormal"),c=A.uv&&o("decodedUv"),h=e(s.programVariables,{attributes:{position:{world:"worldPosition",view:"viewPosition"},color:A.color,pickColor:A.pickColor,uv:c,normal:A.normal&&{world:a,view:l}},viewMatrix:"viewMatrix2"}),u=[h.programName,i.scene.canvas.canvas.id,i.scene._sectionPlanesState.getHash(),i._geometry._state.hash].concat(h.getHash()).join(";");if(!(u in Rt)){const e=Lt(i,A,{decodedUv:c,worldNormal:a,viewNormal:l},h,s);if(e.errors)return void console.log(e.errors.join("\n"));const t=Qt.addItem({});Rt[u]={drawMesh:e.drawMesh,id:t,useCount:0,delete:()=>{Qt.removeItem(t),e.destroy(),delete Rt[u],L.memory.programs--}},L.memory.programs++}t=Rt[u],t.useCount++}};return{get:s,getId:()=>t.id,put:()=>{t&&(0==--t.useCount&&t.delete(),t=null)},drawMesh:(e,i,r)=>{s(),t&&t.drawMesh(e,i,r)}}},n=i.scene,A=e=>(t,s)=>function(e,t,s,i,r){const n=r&&Bt(t,i._lightsState),A=t.createUniform("vec3","uColor",((e,t)=>e(r?t.material.fillColor:t.material.edgeColor))),o=t.createUniform("float","uAlpha",((e,t)=>e(r?t.material.fillAlpha:t.material.edgeAlpha))),a=t.createVarying("vec4","vColor",(()=>{const e=s.attributes,t=r&&[n.getAmbientColor()].concat(e.normal?n.directionalLights.map((t=>`(max(dot(${e.normal.view}, ${t.getDirection(s.viewMatrix,e.position.view)}), 0.0) * ${t.getColor()})`)):[]);return`vec4(${A}${t?` * (${t.join(" + ")})`:""}, ${o})`})),l=t.createOutput("vec4","outColor");return{getHash:()=>[e,i.gammaOutput?"go":"",n&&n.getHash()],programName:r?"EmphasisFill":"EmphasisEdges",dontSetFrontFace:!0,discardPoints:r,drawEdges:!r,appendFragmentOutputs:(e,t)=>e.push(`${l} = ${t?t(a):a};`)}}(i._state.hash,t,s,n,e);this._renderers={_drawRenderer:r(((e,t)=>"LambertMaterial"===s.type?function(e,t,s,i,r){const n=Bt(t,r._lightsState),A=t.createUniform("vec4","colorize",((e,t)=>e(t.meshColorize))),o=t.createUniform("float","materialAlpha",((e,t)=>e(t.material.alpha))),a=t.createUniform("vec3","materialColor",((e,t)=>e(t.material.color))),l=t.createUniform("vec3","materialEmissive",((e,t)=>e(t.material.emissive))),c=t.createVarying("vec4","vColor",(()=>{const e=s.attributes,t=[n.getAmbientColor()].concat(e.normal?n.directionalLights.map((t=>`(max(dot(${e.normal.view}, ${t.getDirection(s.viewMatrix,e.position.view)}), 0.0) * ${t.getColor()})`)):[]);return`${A} * vec4((${t.join(" + ")}) * ${a} + ${l}, ${o});`})),h=t.createOutput("vec4","outColor");return{getHash:()=>[e,r.gammaOutput?"go":"",n.getHash(),i._state.hash],programName:"Lambert",canActAsBackground:!0,discardPoints:!0,setupPointSize:!0,setsLineWidth:!0,appendFragmentOutputs:(e,t)=>e.push(`${h} = ${t?t(c):c};`)}}(i._state.drawHash,e,t,s,n):function(e,t,s,i,r){const n=i._state,A="PhongMaterial"===n.type,o="MetallicMaterial"===n.type,a="SpecularMaterial"===n.type,l=s.attributes,c=Bt(t,r._lightsState),h=t.createUniform("vec4","colorize",((e,t)=>e(t.meshColorize))),u=t.createFragmentDefinition("fresnel",((e,t)=>{t.push(`float ${e}(vec3 eyeDir, vec3 normal, float edgeBias, float centerBias, float power) {`),t.push(" float fr = abs(dot(eyeDir, normal));"),t.push(" float finalFr = clamp((fr - edgeBias) / (centerBias - edgeBias), 0.0, 1.0);"),t.push(" return pow(finalFr, power);"),t.push("}")})),d=(e,s,r)=>{const n=(s,i,n)=>t.createUniform(s,e+"Fresnel"+i,((e,t)=>e(n(r(t.material))))),A=n("float","EdgeBias",(e=>e.edgeBias)),o=n("float","CenterBias",(e=>e.centerBias)),a=n("float","Power",(e=>e.power)),l=n("vec3","EdgeColor",(e=>e.edgeColor)),c=n("vec3","CenterColor",(e=>e.centerColor));return r(i)&&((e,t)=>`mix(${l+s}, ${c+s}, ${u}(${e}, ${t}, ${A}, ${o}, ${a}))`)},p=d("diffuse","",(e=>e._diffuseFresnel)),f=d("specular","",(e=>e._specularFresnel)),g=d("emissive","",(e=>e._emissiveFresnel)),m=d("alpha",".r",(e=>e._alphaFresnel)),_=(e,s)=>{const r=l.uv&&s(i),n=r&&yt(t,"sampler2D",e,r.encoding,((e,t)=>e(s(t.material)._state.texture)));return n&&function(){const i=r._state.matrix&&t.createUniform("mat4",e+"MapMatrix",((e,t)=>e(s(t.material)._state.matrix))),A=i?e=>`(${i} * ${e}).st`:e=>`${e}.st`,o=(e,t)=>n(A(e));return o.getTexCoordExpression=A,o}()},b=_("ambient",(e=>e._ambientMap)),B=_("baseColor",(e=>e._baseColorMap)),y=_("diffuse",(e=>e._diffuseMap)),w=_("emissive",(e=>e._emissiveMap)),v=_("occlusion",(e=>e._occlusionMap)),C=_("alpha",(e=>e._alphaMap)),M=_("metallic",(e=>e._metallicMap)),E=_("roughness",(e=>e._roughnessMap)),F=_("metallicRoughness",(e=>e._metallicRoughnessMap)),x=_("specular",(e=>e._specularMap)),U=_("glossiness",(e=>e._glossinessMap)),I=_("specularGlossiness",(e=>e._specularGlossinessMap)),T=_("normal",(e=>e._normalMap)),P=(e,s,r)=>{const n=r(i);return("float"===s?null!=n:n)&&t.createUniform(s,e,((e,t)=>e(r(t.material))))},S=P("materialAmbient","vec3",(e=>e.ambient)),D=P("materialDiffuse","vec3",(e=>e.diffuse)),k=P("materialBaseColor","vec3",(e=>e.baseColor)),Q=P("materialEmissive","vec3",(e=>e.emissive)),R=P("materialSpecular","vec3",(e=>e.specular)),O=P("materialGlossiness","float",(e=>e.glossiness)),V=P("materialMetallic","float",(e=>e.metallic)),L=P("materialRoughness","float",(e=>e.roughness)),H=P("materialShininess","float",(e=>e.shininess)),N=P("materialSpecularF0","float",(e=>e.specularF0)),G=P("materialAlphaModeCutoff","vec4",(e=>{const t=e.alpha;return null!=t?(vt[0]=t,vt[1]=1===e.alphaMode?1:0,vt[2]=e.alphaCutoff,vt):null})),j=t.createVarying("vec3","vViewPosition",(()=>`${l.position.view}.xyz`)),W=t.createVarying("vec4","texturePos",(()=>`vec4(${l.uv}, 1.0, 1.0)`)),z=l.color&&t.createVarying("vec4","vColor",(()=>l.color)),X=t.createVarying("vec3","vViewNormal",(()=>l.normal.view)),K=c.directionalLights.map(((e,i)=>({vViewLightReverseDir:t.createVarying("vec3",`vViewLightReverseDir${i}`,(()=>e.getDirection(s.viewMatrix,null))),vShadowPosFromLight:t.createVarying("vec3",`vShadowPosFromLight${i}`,(()=>`(mat4(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0) * ${e.shadowParameters.getShadowProjMatrix()} * (${e.shadowParameters.getShadowViewMatrix()} * ${l.position.world})).xyz`))}))),Z=t.createVarying("vec3","vWorldNormal",(()=>l.normal.world)),J=t.createOutput("vec4","outColor"),Y=t.createFragmentDefinition("saturate",((e,t)=>t.push(`float ${e}(const in float a) { return clamp(a, 0.0, 1.0); }`))),$=t.createFragmentDefinition("BRDF_Specular_GGX",((e,t)=>{t.push("vec3 F_Schlick(const in vec3 specularColor, const in float dotLH) {"),t.push(" float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );"),t.push(" return ( 1.0 - specularColor ) * fresnel + specularColor;"),t.push("}"),t.push("float G_GGX_Smith(const in float alpha, const in float dotNL, const in float dotNV) {"),t.push(" float a2 = ( alpha * alpha );"),t.push(" float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );"),t.push(" float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );"),t.push(" return 1.0 / ( gl * gv );"),t.push("}"),t.push("float G_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {"),t.push(" float a2 = ( alpha * alpha );"),t.push(" float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );"),t.push(" float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );"),t.push(" return 0.5 / max( gv + gl, 1e-6 );"),t.push("}"),t.push("float D_GGX(const in float alpha, const in float dotNH) {"),t.push(" float a2 = ( alpha * alpha );"),t.push(" float denom = ( dotNH * dotNH) * ( a2 - 1.0 ) + 1.0;"),t.push(" return 0.31830988618 * a2 / ( denom * denom);"),t.push("}"),t.push(`vec3 ${e}(const in vec3 incidentLightDirection, const in vec3 viewNormal, const in vec3 viewEyeDir, const in vec3 specularColor, const in float roughness) {`),t.push(" float alpha = ( roughness * roughness );"),t.push(" vec3 halfDir = normalize( incidentLightDirection + viewEyeDir );"),t.push(` float dotNL = ${Y}( dot( viewNormal, incidentLightDirection ) );`),t.push(` float dotNV = ${Y}( dot( viewNormal, viewEyeDir ) );`),t.push(` float dotNH = ${Y}( dot( viewNormal, halfDir ) );`),t.push(` float dotLH = ${Y}( dot( incidentLightDirection, halfDir ) );`),t.push(" vec3 F = F_Schlick( specularColor, dotLH );"),t.push(" float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );"),t.push(" float D = D_GGX( alpha, dotNH );"),t.push(" return F * (G * D);"),t.push("}")})),q=t.createFragmentDefinition("BRDF_Specular_GGX_Environment",((e,t)=>{t.push(`vec3 ${e}(const in vec3 viewNormal, const in vec3 viewEyeDir, const in vec3 specularColor, const in float roughness) {`),t.push(` float dotNV = ${Y}(dot(viewNormal, viewEyeDir));`),t.push(" const vec4 c0 = vec4( -1, -0.0275, -0.572, 0.022);"),t.push(" const vec4 c1 = vec4( 1, 0.0425, 1.04, -0.04);"),t.push(" vec4 r = roughness * c0 + c1;"),t.push(" float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y;"),t.push(" vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;"),t.push(" return specularColor * AB.x + AB.y;"),t.push("}")})),ee=t.createFragmentDefinition("perturbNormal2Arb",((e,t)=>{t.push(`vec3 ${e}( vec3 eye_pos, vec3 surf_norm, vec2 uv, vec4 texel ) {`),t.push(" vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );"),t.push(" vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );"),t.push(" vec2 st0 = dFdx( uv.st );"),t.push(" vec2 st1 = dFdy( uv.st );"),t.push(" vec3 S = normalize( q0 * st1.t - q1 * st0.t );"),t.push(" vec3 T = normalize( -q0 * st1.s + q1 * st0.s );"),t.push(" vec3 N = normalize( surf_norm );"),t.push(" vec3 mapN = texel.xyz * 2.0 - 1.0;"),t.push(" mat3 tsn = mat3( S, T, N );"),t.push(" return normalize( tsn * mapN );"),t.push("}")}));return{getHash:()=>[e,r.gammaOutput?"go":"",c.getHash(),i._state.hash],programName:"Draw",canActAsBackground:!0,discardPoints:!0,setupPointSize:!0,setsLineWidth:!0,appendFragmentOutputs:(e,t,i)=>{const r=l.normal&&(c.directionalLights.length>0||c.getIrradiance||c.getReflection);if(e.push(`vec3 diffuseColor = ${r&&(A||a)&&D||o&&k||"vec3(1.0)"};`),e.push(`vec4 alphaModeCutoff = ${(A||o||a)&&G||"vec4(1.0, 0.0, 0.0, 0.0)"};`),e.push("float alpha = alphaModeCutoff[0];"),(A||o||a)&&C&&e.push(`alpha *= ${C(W)}.r;`),z&&(e.push(`diffuseColor *= ${z}.rgb;`),e.push(`alpha *= ${z}.a;`)),o&&B&&(e.push("vec4 baseColorTexel = "+B(W)+";"),e.push("diffuseColor *= baseColorTexel.rgb;"),e.push("alpha *= baseColorTexel.a;")),(A||a)&&y&&(e.push("vec4 diffuseTexel = "+y(W)+";"),e.push("diffuseColor *= diffuseTexel.rgb;"),e.push("alpha *= diffuseTexel.a;")),e.push(`vec3 emissiveColor = ${(A||o||a)&&Q||"vec3(0.0)"};`),(A||o||a)&&w&&e.push(`emissiveColor = ${w(W)}.rgb;`),r){e.push(`vec3 specular = ${(A||a)&&R||"vec3(1.0)"};`),e.push(`float glossiness = ${a&&O||"1.0"};`),e.push(`float metallic = ${o&&V||"1.0"};`),e.push(`float roughness = ${(o||a)&&L||"1.0"};`),e.push(`float shininess = ${A&&H||"1.0"};`),e.push(`float specularF0 = ${o&&N||"1.0"};`),e.push(`float occlusion = ${(A||o||a)&&v?`${v(W)}.r`:"1.0"};`),o&&M&&e.push(`metallic *= ${M(W)}.r;`),o&&E&&e.push(`roughness *= ${E(W)}.r;`),o&&F&&(e.push("vec4 metalRoughTexel = "+F(W)+";"),e.push("metallic *= metalRoughTexel.b;"),e.push("roughness *= metalRoughTexel.g;")),(A||a)&&x&&e.push(`specular *= ${x(W)}.rgb;`),a&&U&&e.push(`glossiness *= ${U(W)}.r;`),a&&I&&(e.push("vec4 specGlossTexel = "+I(W)+";"),e.push("specular *= specGlossTexel.rgb;"),e.push("glossiness *= specGlossTexel.a;"));const t=`normalize(${X})`,i=(A||o||a)&&T?`${ee}(${j}, ${t}, ${T.getTexCoordExpression(W)}, ${T(W)})`:t;if(e.push(`vec3 viewNormal = ${i};`),e.push(`vec3 viewEyeDir = normalize(-${j});`),p&&e.push(`diffuseColor *= ${p("viewEyeDir","viewNormal")};`),f&&e.push(`specular *= ${f("viewEyeDir","viewNormal")};`),g&&e.push(`emissiveColor *= ${g("viewEyeDir","viewNormal")};`),m&&e.push(`alpha *= ${m("viewEyeDir","viewNormal")};`),e.push("if (alphaModeCutoff[1] == 1.0 && alpha < alphaModeCutoff[2]) {"),e.push(" discard;"),e.push("}"),e.push("vec3 material_diffuseColor;"),A&&(e.push("material_diffuseColor = diffuseColor;"),e.push("roughness = 0.0;")),a&&(e.push("float oneMinusSpecularStrength = 1.0 - max(max(specular.r, specular.g ),specular.b);"),e.push("material_diffuseColor = diffuseColor * oneMinusSpecularStrength;"),e.push("roughness = clamp(1.0 - glossiness, 0.04, 1.0);")),o&&(e.push("float dielectricSpecular = 0.16 * specularF0 * specularF0;"),e.push("material_diffuseColor = diffuseColor * (1.0 - dielectricSpecular) * (1.0 - metallic);"),e.push("roughness = clamp(roughness, 0.04, 1.0);"),e.push("specular = mix(vec3(dielectricSpecular), diffuseColor, metallic);")),A||o||a){if(e.push("const float PI = 3.14159265359;"),e.push("vec3 reflDiff = vec3(0.0);"),e.push("vec3 reflSpec = vec3(0.0);"),c.getIrradiance&&e.push(`reflDiff += ${c.getIrradiance(`normalize(${Z})`)};`),c.getReflection){const t="reflect(-viewEyeDir, viewNormal)",i=A?`0.2 * PI * ${c.getReflection(t)}`:function(){const e=`${q}(viewNormal, viewEyeDir, specular, roughness)`,i=`normalize((vec4(${t}, 0.0) * ${s.viewMatrix}).xyz)`;return`${e} * ${c.getReflection(i,"clamp(4.0 - 0.39624 - 0.25 * log2(pow(2.0 / pow(roughness + 0.0001, 2.0) - 2.0, 2.0) + 1.0), 0.0, 4.0)")}`}();e.push(`reflSpec += ${i};`)}c.directionalLights.some((e=>e.shadowParameters))&&(e.push("const vec4 bitShift = vec4(1.0, 1.0/256.0, 1.0/(256.0 * 256.0), 1.0/(256.0*256.0*256.0));"),e.push("const float texelSize = 1.0 / 1024.0;"),e.push("float shadow;"),e.push("float fragmentDepth;")),c.directionalLights.forEach(((t,s)=>{if(t.shadowParameters){const i="0.007";e.push(`fragmentDepth = ${K[s].vShadowPosFromLight}.z - ${i};`),e.push("shadow = 0.0;"),e.push("for (int x = -3; x <= 3; x++) {"),e.push(" for (int y = -3; y <= 3; y++) {"),e.push(` float texelDepth = dot(texture(${t.getShadowMap()}, ${K[s].vShadowPosFromLight}.xy + vec2(x, y) * texelSize), bitShift);`),e.push(" if (fragmentDepth < texelDepth) {"),e.push(" shadow += 1.0;"),e.push(" }"),e.push(" }"),e.push("}"),e.push("shadow /= 9.0;")}e.push(`vec3 lightColor${s} = ${t.getColor()}${t.shadowParameters?" * shadow":""};`),e.push(`vec3 lightDirection${s} = ${t.isViewSpace?t.getDirection(null,j):K[s].vViewLightReverseDir};`);const i=`${Y}(dot(viewNormal, lightDirection${s}))`;e.push(`vec3 irradiance${s} = ${i} * lightColor${s};`),e.push(`reflDiff += irradiance${s};`);const r=A?`lightColor${s} * specular * pow(max(dot(reflect(-lightDirection${s}, -viewNormal), viewEyeDir), 0.0), shininess)`:`irradiance${s} * PI * ${$}(lightDirection${s}, viewNormal, viewEyeDir, specular, roughness)`;e.push(`reflSpec += ${r};`)}))}const r=A&&`${c.getAmbientColor()} * diffuseColor`;e.push("vec3 outgoingLight = emissiveColor + occlusion * (reflDiff * material_diffuseColor + reflSpec)"+(r?" + "+r:"")+";")}else e.push(`vec3 ambientColor = ${A&&S||"vec3(1.0)"};`),A&&b&&e.push(`ambientColor *= ${b(W)}.rgb;`),e.push(`ambientColor *= ${c.getAmbientColor()};`),e.push("vec3 outgoingLight = emissiveColor + ambientColor;");e.push(`vec4 fragColor = ${h} * vec4(outgoingLight, alpha);`),e.push(`${J} = ${t?t("fragColor"):"fragColor"};`)}}}(i._state.drawHash,e,t,s,n))),_shadowRenderer:r((e=>function(e,t){const s=t.createFragmentDefinition("encodeFloat",((e,t)=>{t.push(`vec4 ${e}( const in float depth ) {`),t.push(" const vec4 bitShift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0);"),t.push(" const vec4 bitMask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);"),t.push(" vec4 comp = fract(depth * bitShift);"),t.push(" comp -= comp.xxyz * bitMask;"),t.push(" return comp;"),t.push("}")})),i=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"Shadow",setsLineWidth:!0,useShadowView:!0,dontBillboardAnything:!0,dontGetLogDepth:!0,appendFragmentOutputs:(e,t,r)=>e.push(`${i} = ${s}(${r}.z);`)}}(i._state.hash,e))),_emphasisEdgesRenderer:r(A(!1)),_emphasisFillRenderer:r(A(!0)),_pickMeshRenderer:r((e=>function(e,t){const s=t.createUniform("vec4","pickColor",((e,t)=>{var s=t.meshPickID;Ct[0]=255&s,Ct[1]=s>>8&255,Ct[2]=s>>16&255,Ct[3]=s>>24&255,R.mulVec4Scalar(Ct,1/255,Ct),e(Ct)})),i=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"PickMesh",isPick:!0,dontBillboardAnything:!0,appendFragmentOutputs:e=>e.push(`${i} = ${s};`)}}(i._state.hash,e))),_pickTriangleRenderer:r(((e,t)=>function(e,t,s){const i=t.createVarying("vec4","vColor",(()=>s.attributes.pickColor)),r=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"PickTriangle",isPick:!0,trianglePick:!0,dontBillboardAnything:!0,appendFragmentOutputs:e=>e.push(`${r} = ${i};`)}}(i._state.hash,e,t))),_occlusionRenderer:r((e=>function(e,t){const s=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"Occlusion",skipIfTransparent:!0,appendFragmentOutputs:e=>e.push(`${s} = vec4(0.0, 0.0, 1.0, 1.0);`)}}(i._state.pickOcclusionHash,e)))},this._geometry=t.geometry?this._checkComponent2(["ReadableGeometry","VBOGeometry"],t.geometry):this.scene.geometry,this._material=s,this._xrayMaterial=t.xrayMaterial?this._checkComponent("EmphasisMaterial",t.xrayMaterial):this.scene.xrayMaterial,this._highlightMaterial=t.highlightMaterial?this._checkComponent("EmphasisMaterial",t.highlightMaterial):this.scene.highlightMaterial,this._selectedMaterial=t.selectedMaterial?this._checkComponent("EmphasisMaterial",t.selectedMaterial):this.scene.selectedMaterial,this._edgeMaterial=t.edgeMaterial?this._checkComponent("EdgeMaterial",t.edgeMaterial):this.scene.edgeMaterial,this._parentNode=null,this._aabb=null,this._aabbDirty=!0,this._numTriangles=this._geometry?this._geometry.numTriangles:0,this.scene._aabbDirty=!0,this._scale=R.vec3(),this._quaternion=R.identityQuaternion(),this._rotation=R.vec3(),this._position=R.vec3(),this._worldMatrix=R.identityMat4(),this._worldNormalMatrix=R.identityMat4(),this._localMatrixDirty=!0,this._worldMatrixDirty=!0,this._worldNormalMatrixDirty=!0;const o=t.origin||t.rtcCenter;if(o&&(this._state.origin=R.vec3(o),this._state.originHash=o.join()),t.matrix?this.matrix=t.matrix:(this.scale=t.scale,this.position=t.position,t.quaternion||(this.rotation=t.rotation)),this._isObject=t.isObject,this._isObject&&this.scene._registerObject(this),this._isModel=t.isModel,this._isModel&&this.scene._registerModel(this),this.visible=t.visible,this.culled=t.culled,this.pickable=t.pickable,this.clippable=t.clippable,this.collidable=t.collidable,this.castsShadow=t.castsShadow,this.receivesShadow=t.receivesShadow,this.xrayed=t.xrayed,this.highlighted=t.highlighted,this.selected=t.selected,this.edges=t.edges,this.layer=t.layer,this.colorize=t.colorize,this.opacity=t.opacity,this.offset=t.offset,t.parentId){const e=this.scene.components[t.parentId];e?e.isNode?e.addChild(this):this.error("Parent is not a Node: '"+t.parentId+"'"):this.error("Parent not found: '"+t.parentId+"'"),this._parentNode=e}else t.parent&&(t.parent.isNode||this.error("Parent is not a Node"),t.parent.addChild(this),this._parentNode=t.parent);this.compile()}get type(){return"Mesh"}get isMesh(){return!0}get parent(){return this._parentNode}get geometry(){return this._geometry}get material(){return this._material}get position(){return this._position}set position(e){this._position.set(e||[0,0,0]),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get rotation(){return this._rotation}set rotation(e){this._rotation.set(e||[0,0,0]),R.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get quaternion(){return this._quaternion}set quaternion(e){this._quaternion.set(e||[0,0,0,1]),R.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get scale(){return this._scale}set scale(e){this._scale.set(e||[1,1,1]),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get matrix(){return this._localMatrixDirty&&(this.__localMatrix||(this.__localMatrix=R.identityMat4()),R.composeMat4(this._position,this._quaternion,this._scale,this.__localMatrix),this._localMatrixDirty=!1),this.__localMatrix}set matrix(e){this.__localMatrix||(this.__localMatrix=R.identityMat4()),this.__localMatrix.set(e||kt),R.decomposeMat4(this.__localMatrix,this._position,this._quaternion,this._scale),this._localMatrixDirty=!1,this._setWorldMatrixDirty(),this._setAABBDirty(),this.glRedraw()}get worldMatrix(){return this._worldMatrixDirty&&this._buildWorldMatrix(),this._worldMatrix}get worldNormalMatrix(){return this._worldNormalMatrixDirty&&this._buildWorldNormalMatrix(),this._worldNormalMatrix}get isEntity(){return!0}get isModel(){return this._isModel}get isObject(){return this._isObject}get isUI(){return this._state.isUI}get aabb(){return this._aabbDirty&&this._updateAABB(),this._aabb}get origin(){return this._state.origin}set origin(e){e?(this._state.origin||(this._state.origin=R.vec3()),this._state.origin.set(e),this._state.originHash=e.join(),this._setAABBDirty(),this.scene._aabbDirty=!0):this._state.origin&&(this._state.origin=null,this._state.originHash=null,this._setAABBDirty(),this.scene._aabbDirty=!0)}get rtcCenter(){return this.origin}set rtcCenter(e){this.origin=e}get numTriangles(){return this._numTriangles}get visible(){return this._state.visible}set visible(e){e=!1!==e,this._state.visible=e,this._isObject&&this.scene._objectVisibilityUpdated(this,e),this.glRedraw()}get xrayed(){return this._state.xrayed}set xrayed(e){e=!!e,this._state.xrayed!==e&&(this._state.xrayed=e,this._isObject&&this.scene._objectXRayedUpdated(this,e),this.glRedraw())}get highlighted(){return this._state.highlighted}set highlighted(e){(e=!!e)!==this._state.highlighted&&(this._state.highlighted=e,this._isObject&&this.scene._objectHighlightedUpdated(this,e),this.glRedraw())}get selected(){return this._state.selected}set selected(e){(e=!!e)!==this._state.selected&&(this._state.selected=e,this._isObject&&this.scene._objectSelectedUpdated(this,e),this.glRedraw())}get edges(){return this._state.edges}set edges(e){(e=!!e)!==this._state.edges&&(this._state.edges=e,this.glRedraw())}get culled(){return this._state.culled}set culled(e){this._state.culled=!!e,this.glRedraw()}get clippable(){return this._state.clippable}set clippable(e){e=!1!==e,this._state.clippable!==e&&(this._state.clippable=e,this.glRedraw())}get collidable(){return this._state.collidable}set collidable(e){(e=!1!==e)!==this._state.collidable&&(this._state.collidable=e,this._setAABBDirty(),this.scene._aabbDirty=!0)}get pickable(){return this._state.pickable}set pickable(e){e=!1!==e,this._state.pickable!==e&&(this._state.pickable=e)}get castsShadow(){return this._state.castsShadow}set castsShadow(e){(e=!1!==e)!==this._state.castsShadow&&(this._state.castsShadow=e,this.glRedraw())}get receivesShadow(){return this._state.receivesShadow}set receivesShadow(e){(e=!1!==e)!==this._state.receivesShadow&&(this._state.receivesShadow=e,this._state.hash=e?"/mod/rs;":"/mod;",this.fire("dirty",this))}get saoEnabled(){return!1}get colorize(){return this._state.colorize}set colorize(e){let t=this._state.colorize;t||(t=this._state.colorize=new Float32Array(4),t[3]=1),e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1);const s=!!e;this.scene._objectColorizeUpdated(this,s),this.glRedraw()}get opacity(){return this._state.colorize[3]}set opacity(e){let t=this._state.colorize;t||(t=this._state.colorize=new Float32Array(4),t[0]=1,t[1]=1,t[2]=1);const s=null!=e;t[3]=s?e:1,this.scene._objectOpacityUpdated(this,s),this.glRedraw()}get transparent(){return 2===this._material.alphaMode||this._state.colorize[3]<1}get layer(){return this._state.layer}set layer(e){e=e||0,(e=Math.round(e))!==this._state.layer&&(this._state.layer=e,this._renderer.needStateSort())}get stationary(){return this._state.stationary}get billboard(){return this._state.billboard}get offset(){return this._state.offset}set offset(e){this._state.offset.set(e||[0,0,0]),this._setAABBDirty(),this.glRedraw()}get isDrawable(){return!0}get isStateSortable(){return!0}get xrayMaterial(){return this._xrayMaterial}get highlightMaterial(){return this._highlightMaterial}get selectedMaterial(){return this._selectedMaterial}get edgeMaterial(){return this._edgeMaterial}_checkBillboard(e){return"spherical"!==(e=e||"none")&&"cylindrical"!==e&&"none"!==e&&(this.error("Unsupported value for 'billboard': "+e+" - accepted values are 'spherical', 'cylindrical' and 'none' - defaulting to 'none'."),e="none"),e}compile(){const e=this.scene,t=this._state,s=[e.canvas.canvas.id,e._sectionPlanesState.getHash()];t.stationary&&s.push("/s"),"none"===t.billboard?s.push("/n"):"spherical"===t.billboard?s.push("/s"):"cylindrical"===t.billboard&&s.push("/c"),s.push(";");const i=s.concat([e.gammaOutput?"go":"",e._lightsState.getHash(),t.receivesShadow?"/rs":""]).join("");this._state.drawHash!==i&&(this._state.drawHash=i,this._renderers._drawRenderer.put(),this._renderers._shadowRenderer.put(),this._renderers._emphasisFillRenderer.put(),this._renderers._emphasisEdgesRenderer.put(),this._renderers._drawRenderer.get(),this._renderers._emphasisFillRenderer.get(),this._renderers._emphasisEdgesRenderer.get());const r=s.join("");this._state.pickOcclusionHash!==r&&(this._state.pickOcclusionHash=r,this._renderers._pickMeshRenderer.put(),this._renderers._pickTriangleRenderer.put(),this._renderers._pickMeshRenderer.get(),this._state.occluder&&(this._renderers._occlusionRenderer.put(),this._renderers._occlusionRenderer.get()))}_setLocalMatrixDirty(){this._localMatrixDirty=!0,this._setWorldMatrixDirty()}_setWorldMatrixDirty(){this._worldMatrixDirty=!0,this._worldNormalMatrixDirty=!0}_buildWorldMatrix(){const e=this.matrix;if(this._parentNode)R.mulMat4(this._parentNode.worldMatrix,e,this._worldMatrix);else for(let t=0,s=e.length;t<s;t++)this._worldMatrix[t]=e[t];this._worldMatrixDirty=!1}_buildWorldNormalMatrix(){this._worldMatrixDirty&&this._buildWorldMatrix(),this._worldNormalMatrix||(this._worldNormalMatrix=R.mat4()),R.transposeMat4(this._worldMatrix,this._worldNormalMatrix),R.inverseMat4(this._worldNormalMatrix),this._worldNormalMatrixDirty=!1}_setAABBDirty(){if(this.collidable)for(let e=this;e;e=e._parentNode)e._aabbDirty=!0}_updateAABB(){this.scene._aabbDirty=!0,this._aabb||(this._aabb=R.AABB3()),this._buildAABB(this.worldMatrix,this._aabb),this._aabbDirty=!1}_buildAABB(e,t){R.transformOBB3(e,this._geometry.obb,Et),R.OBB3ToAABB3(Et,t);const s=this._state.offset;if(t[0]+=s[0],t[1]+=s[1],t[2]+=s[2],t[3]+=s[0],t[4]+=s[1],t[5]+=s[2],this._state.origin){const e=this._state.origin;t[0]+=e[0],t[1]+=e[1],t[2]+=e[2],t[3]+=e[0],t[4]+=e[1],t[5]+=e[2]}}rotate(e,t){return Ft[0]=e[0],Ft[1]=e[1],Ft[2]=e[2],Ft[3]=t*R.DEGTORAD,R.angleAxisToQuaternion(Ft,xt),R.mulQuaternions(this.quaternion,xt,Ut),this.quaternion=Ut,this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}rotateOnWorldAxis(e,t){return Ft[0]=e[0],Ft[1]=e[1],Ft[2]=e[2],Ft[3]=t*R.DEGTORAD,R.angleAxisToQuaternion(Ft,xt),R.mulQuaternions(xt,this.quaternion,xt),this}rotateX(e){return this.rotate(It,e)}rotateY(e){return this.rotate(Tt,e)}rotateZ(e){return this.rotate(Pt,e)}translate(e,t){return R.vec3ApplyQuaternion(this.quaternion,e,St),R.mulVec3Scalar(St,t,Dt),R.addVec3(this.position,Dt,this.position),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}translateX(e){return this.translate(It,e)}translateY(e){return this.translate(Tt,e)}translateZ(e){return this.translate(Pt,e)}stateSortCompare(e,t){return e._state.layer-t._state.layer||e._renderers._drawRenderer.getId()-t._renderers._drawRenderer.getId()||e._material._state.id-t._material._state.id||e._geometry._state.id-t._geometry._state.id}rebuildRenderFlags(){this.renderFlags.reset(),this._getActiveSectionPlanes()?(this.renderFlags.numLayers=1,this.renderFlags.numVisibleLayers=1,this.renderFlags.visibleLayers[0]=0,this._updateRenderFlags()):this.renderFlags.culled=!0}_updateRenderFlags(){const e=this.renderFlags,t=this._state;if(t.xrayed){const t=this._xrayMaterial._state;t.fill&&(t.fillAlpha<1?e.xrayedSilhouetteTransparent=!0:e.xrayedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.xrayedEdgesTransparent=!0:e.xrayedEdgesOpaque=!0)}else{if(this._material._state.alpha<1||t.colorize[3]<1?e.colorTransparent=!0:e.colorOpaque=!0,t.edges){this._edgeMaterial._state.alpha<1?e.edgesTransparent=!0:e.edgesOpaque=!0}if(t.selected){const t=this._selectedMaterial._state;t.fill&&(t.fillAlpha<1?e.selectedSilhouetteTransparent=!0:e.selectedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.selectedEdgesTransparent=!0:e.selectedEdgesOpaque=!0)}else if(t.highlighted){const t=this._highlightMaterial._state;t.fill&&(t.fillAlpha<1?e.highlightedSilhouetteTransparent=!0:e.highlightedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.highlightedEdgesTransparent=!0:e.highlightedEdgesOpaque=!0)}}}_getActiveSectionPlanes(){if(this._state.clippable){const e=this.scene._sectionPlanesState.sectionPlanes,t=e.length;if(t>0)for(let s=0;s<t;s++){const t=e[s],i=this.renderFlags;if(t.active)if(this._state.origin){const e=R.planeAABB3Intersect(t.dir,t.dist,this.aabb);if(-1===e)return!1;const r=0===e;i.sectionPlanesActivePerLayer[s]=r}else i.sectionPlanesActivePerLayer[s]=!0;else i.sectionPlanesActivePerLayer[s]=!1}}return!0}drawColorOpaque(e){this._renderers._drawRenderer.drawMesh(e,this,this._material)}drawColorTransparent(e){this._renderers._drawRenderer.drawMesh(e,this,this._material)}drawSilhouetteXRayed(e){this._renderers._emphasisFillRenderer.drawMesh(e,this,this._xrayMaterial)}drawSilhouetteHighlighted(e){this._renderers._emphasisFillRenderer.drawMesh(e,this,this._highlightMaterial)}drawSilhouetteSelected(e){this._renderers._emphasisFillRenderer.drawMesh(e,this,this._selectedMaterial)}drawEdgesColorOpaque(e){this._renderers._emphasisEdgesRenderer.drawMesh(e,this,this._edgeMaterial)}drawEdgesColorTransparent(e){this._renderers._emphasisEdgesRenderer.drawMesh(e,this,this._edgeMaterial)}drawEdgesXRayed(e){this._renderers._emphasisEdgesRenderer.drawMesh(e,this,this._xrayMaterial)}drawEdgesHighlighted(e){this._renderers._emphasisEdgesRenderer.drawMesh(e,this,this._highlightMaterial)}drawEdgesSelected(e){this._renderers._emphasisEdgesRenderer.drawMesh(e,this,this._selectedMaterial)}drawOcclusion(e){this._renderers._occlusionRenderer.drawMesh(e,this,this._material)}drawShadow(e){this._renderers._shadowRenderer.drawMesh(e,this,this._material)}drawPickMesh(e){this._renderers._pickMeshRenderer.drawMesh(e,this,this._material)}canPickTriangle(){return this._geometry.isReadableGeometry}drawPickTriangles(e){this._renderers._pickTriangleRenderer.drawMesh(e,this,this._material)}pickTriangleSurface(e,t,s,i){Vt(this,e,t,s,i)}drawPickVertices(e){}delegatePickedEntity(){return this}destroy(){super.destroy(),Object.values(this._renderers).forEach((e=>e.put())),this.scene._renderer.putPickID(this._state.pickID),this._isObject&&(this.scene._deregisterObject(this),this._visible&&this.scene._objectVisibilityUpdated(this,!1,!1),this._xrayed&&this.scene._objectXRayedUpdated(this,!1,!1),this._selected&&this.scene._objectSelectedUpdated(this,!1,!1),this._highlighted&&this.scene._objectHighlightedUpdated(this,!1,!1),this.scene._objectColorizeUpdated(this,!1),this.scene._objectOpacityUpdated(this,!1),this.offset.some((e=>0!==e))&&this.scene._objectOffsetUpdated(this,!1)),this._isModel&&this.scene._deregisterModel(this),this.glRedraw()}}const Vt=function(){const e=R.vec3(),t=R.vec3(),s=R.vec3(),i=R.vec3(),r=R.vec3(),n=R.vec3(),A=R.vec4(),o=R.vec3(),a=R.vec3(),l=R.vec3(),c=R.vec3(),h=R.vec3(),u=R.vec3(),d=R.vec3(),p=R.vec3(),f=R.vec3(),g=R.vec4(),m=R.vec4(),_=R.vec4(),b=R.vec3(),B=R.vec3(),y=R.vec3(),w=R.vec3(),v=R.vec3(),C=R.vec3(),M=R.vec3(),E=R.vec3(),F=R.vec3(),x=R.vec3(),U=R.vec3();return function(I,T,P,S,D){var k=D.primIndex;if(null!=k&&k>-1){const L=I.geometry._state,H=I.scene,N=H.camera,G=H.canvas;if("triangles"===L.primitiveName){D.primitive="triangle";const H=k,j=L.indices,W=L.positions;let z,X,K;if(j){var Q=j[H+0],O=j[H+1],V=j[H+2];n[0]=Q,n[1]=O,n[2]=V,D.indices=n,z=3*Q,X=3*O,K=3*V}else z=3*H,X=z+3,K=X+3;if(s[0]=W[z+0],s[1]=W[z+1],s[2]=W[z+2],i[0]=W[X+0],i[1]=W[X+1],i[2]=W[X+2],r[0]=W[K+0],r[1]=W[K+1],r[2]=W[K+2],L.compressGeometry){const e=L.positionsDecodeMatrix;e&&(Re.decompressPosition(s,e,s),Re.decompressPosition(i,e,i),Re.decompressPosition(r,e,r))}D.canvasPos?R.canvasPosToLocalRay(G.canvas,I.origin?ut(T,I.origin):T,P,S,I.worldMatrix,D.canvasPos,e,t):D.origin&&D.direction&&R.worldRayToLocalRay(I.worldMatrix,D.origin,D.direction,e,t),R.normalizeVec3(t),R.rayPlaneIntersect(e,t,s,i,r,A),D.localPos=A,D.position=A,g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=1,R.transformVec4(I.worldMatrix,g,m),o[0]=m[0],o[1]=m[1],o[2]=m[2],D.canvasPos&&I.origin&&(o[0]+=I.origin[0],o[1]+=I.origin[1],o[2]+=I.origin[2]),D.worldPos=o,R.transformVec4(N.matrix,m,_),a[0]=_[0],a[1]=_[1],a[2]=_[2],D.viewPos=a,R.cartesianToBarycentric(A,s,i,r,l),D.bary=l;const Z=L.normals;if(Z){if(L.compressGeometry){const e=3*Q,t=3*O,s=3*V;Re.decompressNormal(Z.subarray(e,e+2),c),Re.decompressNormal(Z.subarray(t,t+2),h),Re.decompressNormal(Z.subarray(s,s+2),u)}else c[0]=Z[z],c[1]=Z[z+1],c[2]=Z[z+2],h[0]=Z[X],h[1]=Z[X+1],h[2]=Z[X+2],u[0]=Z[K],u[1]=Z[K+1],u[2]=Z[K+2];const e=R.addVec3(R.addVec3(R.mulVec3Scalar(c,l[0],b),R.mulVec3Scalar(h,l[1],B),y),R.mulVec3Scalar(u,l[2],w),v);D.worldNormal=R.normalizeVec3(R.transformVec3(I.worldNormalMatrix,e,C))}const J=L.uv;if(J){if(d[0]=J[2*Q],d[1]=J[2*Q+1],p[0]=J[2*O],p[1]=J[2*O+1],f[0]=J[2*V],f[1]=J[2*V+1],L.compressGeometry){const e=L.uvDecodeMatrix;e&&(Re.decompressUV(d,e,d),Re.decompressUV(p,e,p),Re.decompressUV(f,e,f))}D.uv=R.addVec3(R.addVec3(R.mulVec2Scalar(d,l[0],M),R.mulVec2Scalar(p,l[1],E),F),R.mulVec2Scalar(f,l[2],x),U)}}}}}(),Lt=(e,t,s,i,r)=>{const n=r.programVariables,A=s.decodedUv,o=s.worldNormal,a=s.viewNormal,l=e.scene,c=l.canvas.gl,h=e._state.background,u=e._geometry._state,d=u.compressGeometry,p="points"===u.primitiveName,f=n.createUniform("float","pointSize"),g=n.createUniform("mat4","modelMatrix"),m=n.createUniform("mat4","modelNormalMatrix"),_=n.createUniform("vec3","offset"),b=n.createUniform("vec3","scale"),B=n.createUniform("mat4","positionsDecodeMatrix"),y=n.createUniform("mat3","uvDecodeMatrix"),w=n.createUniform("mat4","viewMatrix"),v=n.createUniform("mat4","viewNormalMatrix"),C=n.createUniform("mat4","projMatrix"),M=e.billboard,E=!i.dontBillboardAnything&&("spherical"===M||"cylindrical"===M),F=e.stationary,x=E&&((e,t)=>[`mat4 ${e}(in mat4 matIn) {`," mat4 mat = matIn;",` mat[0].xyz = vec3(${b}[0], 0.0, 0.0);`,..."spherical"===M?[` mat[1].xyz = vec3(0.0, ${b}[1], 0.0);`]:[]," mat[2].xyz = vec3(0.0, 0.0, 1.0);"," return mat;","}"].forEach((e=>t.push(e)))),U=function(){const e=x&&n.createVertexDefinition("billboard",x);return t=>e?`${e}(${t})`:t}(),I=function(){const e=x&&n.createFragmentDefinition("billboard",x);return t=>e?`${e}(${t})`:t}(),T=[];i.dontBillboardAnything?T.push(`mat4 viewMatrix2 = ${w};`):(T.push(`mat4 viewMatrix1 = ${w};`),F?T.push("viewMatrix1[3].xyz = vec3(0.0, 0.0, 0.0);"):h&&T.push("viewMatrix1[3] = vec4(0.0, 0.0, 0.0, 1.0);"),T.push(`mat4 viewMatrix2 = ${I("viewMatrix1")};`));const P="clipPos",S=n.createUniform("bool","clippable"),[D,k]=r.buildProgram(c,i.programName,{appendFragmentOutputs:(e,t,s,r)=>{T.forEach((t=>e.push(t))),i.appendFragmentOutputs(e,t,s,r)},clippableTest:()=>S,clippingCaps:i.clippingCaps,clipPos:h?"clipPos.xyww":P,crossSections:l.crossSections,discardPoints:p&&i.discardPoints,getGammaFactor:l.gammaOutput&&(()=>l.gammaFactor),getLogDepth:!i.dontGetLogDepth&&l.logarithmicDepthBufferEnabled&&(e=>e),getPointSize:i.setupPointSize&&p&&(()=>f),getVertexData:function(){const e=a&&a.needed&&`vec3 ${a} = normalize((${U(v)} * vec4(${o}, 0.0)).xyz);`,s=[];if(s.push(`vec4 localPosition = vec4(${t.position}, 1.0);`),d&&s.push(`localPosition = ${B} * localPosition;`),s.push(`vec4 worldPosition = ${U(g)} * localPosition;`),s.push(`worldPosition.xyz = worldPosition.xyz + ${_};`),i.dontBillboardAnything?s.push(`vec4 viewPosition = ${w} * worldPosition;`):(s.push(`mat4 viewMatrix1 = ${w};`),F?s.push("viewMatrix1[3].xyz = vec3(0.0, 0.0, 0.0);"):h&&s.push("viewMatrix1[3] = vec4(0.0, 0.0, 0.0, 1.0);"),s.push(`mat4 viewMatrix2 = ${U("viewMatrix1")};`),s.push(`vec4 viewPosition = ${E?`${U(`viewMatrix1 * ${g}`)} * localPosition`:"viewMatrix2 * worldPosition"};`)),A&&A.needed&&s.push(`vec2 ${A} = ${d?`(${y} * vec3(${t.uv}, 1.0)).xy`:t.uv};`),o&&o.needed){const e=d?`${n.commonLibrary.octDecode}(${t.normal}.xy)`:t.normal;s.push(`vec3 ${o} = (${U(m)} * vec4(${e}, 0.0)).xyz;`)}return e&&s.push(e),s.push(`vec4 clipPos = ${C} * viewPosition;`),s},projMatrix:C,sectionPlanesState:l._sectionPlanesState,testPerspectiveForGl_FragDepth:!0,usePickClipPos:i.isPick,worldPositionAttribute:"worldPosition"});if(k)return{errors:k};{const e=D.inputSetters;let s=null,r=null;return{destroy:()=>D.destroy(),drawMesh:(n,A,o)=>{if(i.skipIfTransparent&&o.alpha<1)return;const a=o._state,l=A._state,u=A._geometry,d=u._state,p=n.viewParams,M=i.canActAsBackground&&h;n.lastProgramId!==D.id&&(n.lastProgramId=D.id,D.bind(),n.useProgram++,s=null,r=null,M&&c.depthFunc(c.LEQUAL)),a.id!==s&&(n.backfaces!==a.backfaces&&(a.backfaces?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE),n.backfaces=a.backfaces),i.dontSetFrontFace||n.frontface===a.frontface||(c.frontFace(a.frontface?c.CCW:c.CW),n.frontface=a.frontface),i.drawEdges&&n.lineWidth!==a.edgeWidth&&(c.lineWidth(a.edgeWidth),n.lineWidth=a.edgeWidth),i.setsLineWidth&&n.lineWidth!==a.lineWidth&&(c.lineWidth(a.lineWidth),n.lineWidth=a.lineWidth),s=a.id);const E=!i.useShadowView&&A.origin;((t,s)=>{const i=(e,t)=>e.setInputValue&&e.setInputValue(t);i(f,o.pointSize),i(g,A.worldMatrix),i(m,A.worldNormalMatrix),i(_,A.offset),i(b,A.scale),i(B,d.positionsDecodeMatrix),i(y,d.uvDecodeMatrix),i(w,s),i(v,p.viewNormalMatrix),i(C,t),i(S,A.clippable),e.setUniforms(n,{material:o,meshColorize:A.colorize,meshPickID:A._state.pickID,mesh:{origin:A.origin,renderFlags:{sectionPlanesActivePerLayer:A.renderFlags.sectionPlanesActivePerLayer}},view:{far:p.far}})})(p.projMatrix,E?n.getRTCViewMatrix(l.originHash,E):p.viewMatrix);const F=e=>{const s=(e,t)=>{e&&e.setInputValue&&t&&(e.setInputValue(t),n.bindArray++)};s(t.position,(e||d).positionsBuf),s(t.color,d.colorsBuf),s(t.pickColor,e&&e.pickColorsBuf),s(t.uv,d.uvBuf),s(t.normal,d.normalsBuf)};if(i.trianglePick){const e=u._getPickTrianglePositions();d.id!==r&&(F({positionsBuf:e,pickColorsBuf:u._getPickTriangleColors()}),r=d.id),c.drawArrays(d.primitive,0,e.numItems/3)}else if(i.drawEdges){const e=d.primitive===c.TRIANGLES?u._getEdgeIndices():d.primitive===c.LINES&&d.indicesBuf;e&&(d.id!==r&&(F(),e.bind(),n.bindArray++,r=d.id),c.drawElements(c.LINES,e.numItems,e.itemType,0),n.drawElements++)}else d.id!==r&&(F(),d.indicesBuf&&(d.indicesBuf.bind(),n.bindArray++),r=d.id),d.indicesBuf?(c.drawElements(d.primitive,d.indicesBuf.numItems,d.indicesBuf.itemType,0),n.drawElements++):d.positionsBuf&&(c.drawArrays(c.TRIANGLES,0,d.positionsBuf.numItems),n.drawArrays++);M&&c.depthFunc(c.LESS)}}}};class Ht extends ie{get type(){return"Material"}constructor(e,t={}){super(e,t),L.memory.materials++}destroy(){super.destroy(),L.memory.materials--}}const Nt={opaque:0,mask:1,blend:2},Gt=["opaque","mask","blend"];class jt extends Ht{get type(){return"PhongMaterial"}constructor(e,t={}){super(e,t),this._state=new xe({type:"PhongMaterial",ambient:R.vec3([1,1,1]),diffuse:R.vec3([1,1,1]),specular:R.vec3([1,1,1]),emissive:R.vec3([0,0,0]),alpha:null,shininess:null,reflectivity:null,alphaMode:null,alphaCutoff:null,lineWidth:null,pointSize:null,backfaces:null,frontface:null,hash:null}),this.ambient=t.ambient,this.diffuse=t.diffuse,this.specular=t.specular,this.emissive=t.emissive,this.alpha=t.alpha,this.shininess=t.shininess,this.reflectivity=t.reflectivity,this.lineWidth=t.lineWidth,this.pointSize=t.pointSize,t.ambientMap&&(this._ambientMap=this._checkComponent("Texture",t.ambientMap)),t.diffuseMap&&(this._diffuseMap=this._checkComponent("Texture",t.diffuseMap)),t.specularMap&&(this._specularMap=this._checkComponent("Texture",t.specularMap)),t.emissiveMap&&(this._emissiveMap=this._checkComponent("Texture",t.emissiveMap)),t.alphaMap&&(this._alphaMap=this._checkComponent("Texture",t.alphaMap)),t.reflectivityMap&&(this._reflectivityMap=this._checkComponent("Texture",t.reflectivityMap)),t.normalMap&&(this._normalMap=this._checkComponent("Texture",t.normalMap)),t.occlusionMap&&(this._occlusionMap=this._checkComponent("Texture",t.occlusionMap)),t.diffuseFresnel&&(this._diffuseFresnel=this._checkComponent("Fresnel",t.diffuseFresnel)),t.specularFresnel&&(this._specularFresnel=this._checkComponent("Fresnel",t.specularFresnel)),t.emissiveFresnel&&(this._emissiveFresnel=this._checkComponent("Fresnel",t.emissiveFresnel)),t.alphaFresnel&&(this._alphaFresnel=this._checkComponent("Fresnel",t.alphaFresnel)),t.reflectivityFresnel&&(this._reflectivityFresnel=this._checkComponent("Fresnel",t.reflectivityFresnel)),this.alphaMode=t.alphaMode,this.alphaCutoff=t.alphaCutoff,this.backfaces=t.backfaces,this.frontface=t.frontface,this._makeHash()}_makeHash(){const e=this._state,t=["/p"];this._normalMap&&(t.push("/nm"),this._normalMap.hasMatrix&&t.push("/mat")),this._ambientMap&&(t.push("/am"),this._ambientMap.hasMatrix&&t.push("/mat"),t.push("/"+this._ambientMap.encoding)),this._diffuseMap&&(t.push("/dm"),this._diffuseMap.hasMatrix&&t.push("/mat"),t.push("/"+this._diffuseMap.encoding)),this._specularMap&&(t.push("/sm"),this._specularMap.hasMatrix&&t.push("/mat")),this._emissiveMap&&(t.push("/em"),this._emissiveMap.hasMatrix&&t.push("/mat"),t.push("/"+this._emissiveMap.encoding)),this._alphaMap&&(t.push("/opm"),this._alphaMap.hasMatrix&&t.push("/mat")),this._reflectivityMap&&(t.push("/rm"),this._reflectivityMap.hasMatrix&&t.push("/mat")),this._occlusionMap&&(t.push("/ocm"),this._occlusionMap.hasMatrix&&t.push("/mat")),this._diffuseFresnel&&t.push("/df"),this._specularFresnel&&t.push("/sf"),this._emissiveFresnel&&t.push("/ef"),this._alphaFresnel&&t.push("/of"),this._reflectivityFresnel&&t.push("/rf"),t.push(";"),e.hash=t.join("")}set ambient(e){let t=this._state.ambient;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.ambient=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=.2,t[1]=.2,t[2]=.2),this.glRedraw()}get ambient(){return this._state.ambient}set diffuse(e){let t=this._state.diffuse;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.diffuse=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1),this.glRedraw()}get diffuse(){return this._state.diffuse}set specular(e){let t=this._state.specular;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.specular=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1),this.glRedraw()}get specular(){return this._state.specular}set emissive(e){let t=this._state.emissive;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.emissive=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=0,t[1]=0,t[2]=0),this.glRedraw()}get emissive(){return this._state.emissive}set alpha(e){e=null!=e?e:1,this._state.alpha!==e&&(this._state.alpha=e,this.glRedraw())}get alpha(){return this._state.alpha}set shininess(e){this._state.shininess=void 0!==e?e:80,this.glRedraw()}get shininess(){return this._state.shininess}set lineWidth(e){this._state.lineWidth=e||1,this.glRedraw()}get lineWidth(){return this._state.lineWidth}set pointSize(e){this._state.pointSize=e||1,this.glRedraw()}get pointSize(){return this._state.pointSize}set reflectivity(e){this._state.reflectivity=void 0!==e?e:1,this.glRedraw()}get reflectivity(){return this._state.reflectivity}get normalMap(){return this._normalMap}get ambientMap(){return this._ambientMap}get diffuseMap(){return this._diffuseMap}get specularMap(){return this._specularMap}get emissiveMap(){return this._emissiveMap}get alphaMap(){return this._alphaMap}get reflectivityMap(){return this._reflectivityMap}get occlusionMap(){return this._occlusionMap}get diffuseFresnel(){return this._diffuseFresnel}get specularFresnel(){return this._specularFresnel}get emissiveFresnel(){return this._emissiveFresnel}get alphaFresnel(){return this._alphaFresnel}get reflectivityFresnel(){return this._reflectivityFresnel}set alphaMode(e){let t=Nt[e=e||"opaque"];void 0===t&&(this.error("Unsupported value for 'alphaMode': "+e+" - defaulting to 'opaque'"),t="opaque"),this._state.alphaMode!==t&&(this._state.alphaMode=t,this.glRedraw())}get alphaMode(){return Gt[this._state.alphaMode]}set alphaCutoff(e){null==e&&(e=.5),this._state.alphaCutoff!==e&&(this._state.alphaCutoff=e)}get alphaCutoff(){return this._state.alphaCutoff}set backfaces(e){e=!!e,this._state.backfaces!==e&&(this._state.backfaces=e,this.glRedraw())}get backfaces(){return this._state.backfaces}set frontface(e){e="cw"!==e,this._state.frontface!==e&&(this._state.frontface=e,this.glRedraw())}get frontface(){return this._state.frontface?"ccw":"cw"}destroy(){super.destroy(),this._state.destroy()}}function Wt(e,t){if(void 0===e._cachedExtensions&&(e._cachedExtensions={}),void 0!==e._cachedExtensions[t])return e._cachedExtensions[t];let s;switch(t){case"WEBGL_depth_texture":s=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=e.getExtension(t)}return e._cachedExtensions[t]=s,s}function zt(e,t,s=null){let i;const r=t;if(1009===r)return e.UNSIGNED_BYTE;if(1017===r)return e.UNSIGNED_SHORT_4_4_4_4;if(1018===r)return e.UNSIGNED_SHORT_5_5_5_1;if(1010===r)return e.BYTE;if(1011===r)return e.SHORT;if(1012===r)return e.UNSIGNED_SHORT;if(1013===r)return e.INT;if(1014===r)return e.UNSIGNED_INT;if(1015===r)return e.FLOAT;if(1016===r)return e.HALF_FLOAT;if(1021===r)return e.ALPHA;if(1023===r)return e.RGBA;if(1024===r)return e.LUMINANCE;if(1025===r)return e.LUMINANCE_ALPHA;if(1026===r)return e.DEPTH_COMPONENT;if(1027===r)return e.DEPTH_STENCIL;if(1028===r)return e.RED;if(1022===r)return e.RGBA;if(1029===r)return e.RED_INTEGER;if(1030===r)return e.RG;if(1031===r)return e.RG_INTEGER;if(1033===r)return e.RGBA_INTEGER;if(33776===r||33777===r||33778===r||33779===r)if(3001===s){const t=Wt(e,"WEBGL_compressed_texture_s3tc_srgb");if(null===t)return null;if(33776===r)return t.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(33777===r)return t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(33778===r)return t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(33779===r)return t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(i=Wt(e,"WEBGL_compressed_texture_s3tc"),null===i)return null;if(33776===r)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===r)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===r)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===r)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===r||35841===r||35842===r||35843===r){const t=Wt(e,"WEBGL_compressed_texture_pvrtc");if(null===t)return null;if(35840===r)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===r)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===r)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===r)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===r){const t=Wt(e,"WEBGL_compressed_texture_etc1");return null!==t?t.COMPRESSED_RGB_ETC1_WEBGL:null}if(37492===r||37496===r){const t=Wt(e,"WEBGL_compressed_texture_etc");if(null===t)return null;if(37492===r)return 3001===s?t.COMPRESSED_SRGB8_ETC2:t.COMPRESSED_RGB8_ETC2;if(37496===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:t.COMPRESSED_RGBA8_ETC2_EAC}if(37808===r||37809===r||37810===r||37811===r||37812===r||37813===r||37814===r||37815===r||37816===r||37817===r||37818===r||37819===r||37820===r||37821===r){const t=Wt(e,"WEBGL_compressed_texture_astc");if(null===t)return null;if(37808===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:t.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:t.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:t.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:t.COMPRESSED_RGBA_ASTC_6x5_KHR;if(37812===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:t.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:t.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:t.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:t.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:t.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:t.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:t.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:t.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:t.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===r)return 3001===s?t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:t.COMPRESSED_RGBA_ASTC_12x12_KHR}if(36492===r){const t=Wt(e,"EXT_texture_compression_bptc");if(null===t)return null;if(36492===r)return 3001===s?t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:t.COMPRESSED_RGBA_BPTC_UNORM_EXT}return 1020===r?e.UNSIGNED_INT_24_8:1e3===r?e.REPEAT:1001===r?e.CLAMP_TO_EDGE:1004===r||1005===r?e.NEAREST_MIPMAP_LINEAR:1007===r?e.LINEAR_MIPMAP_NEAREST:1008===r?e.LINEAR_MIPMAP_LINEAR:1003===r?e.NEAREST:1006===r?e.LINEAR:null}const Xt=new Uint8Array([0,0,0,1]);class Kt{constructor({gl:e,target:t,format:s,type:i,wrapS:r,wrapT:n,wrapR:A,encoding:o,preloadColor:a,premultiplyAlpha:l,flipY:c}){this.gl=e,this.target=t||e.TEXTURE_2D,this.format=s||1023,this.type=i||1009,this.internalFormat=null,this.premultiplyAlpha=!!l,this.flipY=!!c,this.unpackAlignment=4,this.wrapS=r||1e3,this.wrapT=n||1e3,this.wrapR=A||1e3,this.encoding=o||3001,this.texture=e.createTexture(),a&&this.setPreloadColor(a),this.allocated=!0}setPreloadColor(e){e?(Xt[0]=Math.floor(255*e[0]),Xt[1]=Math.floor(255*e[1]),Xt[2]=Math.floor(255*e[2]),Xt[3]=Math.floor(255*(void 0!==e[3]?e[3]:1))):(Xt[0]=0,Xt[1]=0,Xt[2]=0,Xt[3]=255);const t=this.gl;if(t.bindTexture(this.target,this.texture),this.target===t.TEXTURE_CUBE_MAP){const e=[t.TEXTURE_CUBE_MAP_POSITIVE_X,t.TEXTURE_CUBE_MAP_NEGATIVE_X,t.TEXTURE_CUBE_MAP_POSITIVE_Y,t.TEXTURE_CUBE_MAP_NEGATIVE_Y,t.TEXTURE_CUBE_MAP_POSITIVE_Z,t.TEXTURE_CUBE_MAP_NEGATIVE_Z];for(let s=0,i=e.length;s<i;s++)t.texImage2D(e[s],0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Xt)}else t.texImage2D(this.target,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Xt);t.bindTexture(this.target,null)}setTarget(e){this.target=e||this.gl.TEXTURE_2D}setImage(e,t={}){const s=this.gl;void 0!==t.format&&(this.format=t.format),void 0!==t.internalFormat&&(this.internalFormat=t.internalFormat),void 0!==t.encoding&&(this.encoding=t.encoding),void 0!==t.type&&(this.type=t.type),void 0!==t.flipY&&(this.flipY=t.flipY),void 0!==t.premultiplyAlpha&&(this.premultiplyAlpha=t.premultiplyAlpha),void 0!==t.unpackAlignment&&(this.unpackAlignment=t.unpackAlignment),void 0!==t.minFilter&&(this.minFilter=t.minFilter),void 0!==t.magFilter&&(this.magFilter=t.magFilter),void 0!==t.wrapS&&(this.wrapS=t.wrapS),void 0!==t.wrapT&&(this.wrapT=t.wrapT),void 0!==t.wrapR&&(this.wrapR=t.wrapR);let i=!1;s.bindTexture(this.target,this.texture);const r=s.getParameter(s.UNPACK_FLIP_Y_WEBGL);s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,this.flipY);const n=s.getParameter(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL);s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha);const A=s.getParameter(s.UNPACK_ALIGNMENT);s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment);const o=s.getParameter(s.UNPACK_COLORSPACE_CONVERSION_WEBGL);s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE);const a=zt(s,this.minFilter);s.texParameteri(this.target,s.TEXTURE_MIN_FILTER,a),a!==s.NEAREST_MIPMAP_NEAREST&&a!==s.LINEAR_MIPMAP_NEAREST&&a!==s.NEAREST_MIPMAP_LINEAR&&a!==s.LINEAR_MIPMAP_LINEAR||(i=!0);const l=zt(s,this.magFilter);l&&s.texParameteri(this.target,s.TEXTURE_MAG_FILTER,l);const c=zt(s,this.wrapS);c&&s.texParameteri(this.target,s.TEXTURE_WRAP_S,c);const h=zt(s,this.wrapT);h&&s.texParameteri(this.target,s.TEXTURE_WRAP_T,h);const u=zt(s,this.format,this.encoding),d=zt(s,this.type),p=Zt(s,this.internalFormat,u,d,this.encoding,!1);if(this.target===s.TEXTURE_CUBE_MAP){if(j.isArray(e)){const t=e,i=[s.TEXTURE_CUBE_MAP_POSITIVE_X,s.TEXTURE_CUBE_MAP_NEGATIVE_X,s.TEXTURE_CUBE_MAP_POSITIVE_Y,s.TEXTURE_CUBE_MAP_NEGATIVE_Y,s.TEXTURE_CUBE_MAP_POSITIVE_Z,s.TEXTURE_CUBE_MAP_NEGATIVE_Z];for(let e=0,r=i.length;e<r;e++)s.texImage2D(i[e],0,p,u,d,t[e])}}else s.texImage2D(s.TEXTURE_2D,0,p,u,d,e);i&&s.generateMipmap(this.target),s.bindTexture(this.target,null),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,r),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n),s.pixelStorei(s.UNPACK_ALIGNMENT,A),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,o)}setCompressedData({mipmaps:e,props:t={}}){const s=this.gl,i=e.length;void 0!==t.format&&(this.format=t.format),void 0!==t.internalFormat&&(this.internalFormat=t.internalFormat),void 0!==t.encoding&&(this.encoding=t.encoding),void 0!==t.type&&(this.type=t.type),void 0!==t.flipY&&(this.flipY=t.flipY),void 0!==t.premultiplyAlpha&&(this.premultiplyAlpha=t.premultiplyAlpha),void 0!==t.unpackAlignment&&(this.unpackAlignment=t.unpackAlignment),void 0!==t.minFilter&&(this.minFilter=t.minFilter),void 0!==t.magFilter&&(this.magFilter=t.magFilter),void 0!==t.wrapS&&(this.wrapS=t.wrapS),void 0!==t.wrapT&&(this.wrapT=t.wrapT),void 0!==t.wrapR&&(this.wrapR=t.wrapR),s.activeTexture(s.TEXTURE0+0),s.bindTexture(this.target,this.texture);let r=e.length>1;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,this.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE);const n=zt(s,this.wrapS);n&&s.texParameteri(this.target,s.TEXTURE_WRAP_S,n);const A=zt(s,this.wrapT);if(A&&s.texParameteri(this.target,s.TEXTURE_WRAP_T,A),this.type===s.TEXTURE_3D||this.type===s.TEXTURE_2D_ARRAY){const e=zt(s,this.wrapR);e&&s.texParameteri(this.target,s.TEXTURE_WRAP_R,e),s.texParameteri(this.type,s.TEXTURE_WRAP_R,e)}r?(s.texParameteri(this.target,s.TEXTURE_MIN_FILTER,Jt(s,this.minFilter)),s.texParameteri(this.target,s.TEXTURE_MAG_FILTER,Jt(s,this.magFilter))):(s.texParameteri(this.target,s.TEXTURE_MIN_FILTER,zt(s,this.minFilter)),s.texParameteri(this.target,s.TEXTURE_MAG_FILTER,zt(s,this.magFilter)));const o=zt(s,this.format,this.encoding),a=zt(s,this.type),l=Zt(s,this.internalFormat,o,a,this.encoding,!1);s.texStorage2D(s.TEXTURE_2D,i,l,e[0].width,e[0].height);for(let t=0,i=e.length;t<i;t++){const i=e[t];1023!==this.format?null!==o?s.compressedTexSubImage2D(s.TEXTURE_2D,t,0,0,i.width,i.height,o,i.data):console.warn("Attempt to load unsupported compressed texture format in .setCompressedData()"):s.texSubImage2D(s.TEXTURE_2D,t,0,0,i.width,i.height,o,a,i.data)}s.bindTexture(this.target,null)}setProps(e){const t=this.gl;t.bindTexture(this.target,this.texture),this._uploadProps(e),t.bindTexture(this.target,null)}_uploadProps(e){const t=this.gl;if(void 0!==e.format&&(this.format=e.format),void 0!==e.internalFormat&&(this.internalFormat=e.internalFormat),void 0!==e.encoding&&(this.encoding=e.encoding),void 0!==e.type&&(this.type=e.type),void 0!==e.minFilter){const s=zt(t,e.minFilter);s&&(this.minFilter=e.minFilter,t.texParameteri(this.target,t.TEXTURE_MIN_FILTER,s),s!==t.NEAREST_MIPMAP_NEAREST&&s!==t.LINEAR_MIPMAP_NEAREST&&s!==t.NEAREST_MIPMAP_LINEAR&&s!==t.LINEAR_MIPMAP_LINEAR||t.generateMipmap(this.target))}if(void 0!==e.magFilter){const s=zt(t,e.magFilter);s&&(this.magFilter=e.magFilter,t.texParameteri(this.target,t.TEXTURE_MAG_FILTER,s))}if(void 0!==e.wrapS){const s=zt(t,e.wrapS);s&&(this.wrapS=e.wrapS,t.texParameteri(this.target,t.TEXTURE_WRAP_S,s))}if(void 0!==e.wrapT){const s=zt(t,e.wrapT);s&&(this.wrapT=e.wrapT,t.texParameteri(this.target,t.TEXTURE_WRAP_T,s))}}bind(e){if(this.allocated){if(this.texture){const t=this.gl;return t.activeTexture(t["TEXTURE"+e]),t.bindTexture(this.target,this.texture),!0}return!1}}unbind(e){if(this.allocated&&this.texture){const t=this.gl;t.activeTexture(t["TEXTURE"+e]),t.bindTexture(this.target,null)}}destroy(){this.allocated&&this.texture&&(this.gl.deleteTexture(this.texture),this.texture=null)}}function Zt(e,t,s,i,r,n=!1){if(null!==t){if(void 0!==e[t])return e[t];console.warn("Attempt to use non-existing WebGL internal format '"+t+"'")}let A=s;return s===e.RED&&(i===e.FLOAT&&(A=e.R32F),i===e.HALF_FLOAT&&(A=e.R16F),i===e.UNSIGNED_BYTE&&(A=e.R8)),s===e.RG&&(i===e.FLOAT&&(A=e.RG32F),i===e.HALF_FLOAT&&(A=e.RG16F),i===e.UNSIGNED_BYTE&&(A=e.RG8)),s===e.RGBA&&(i===e.FLOAT&&(A=e.RGBA32F),i===e.HALF_FLOAT&&(A=e.RGBA16F),i===e.UNSIGNED_BYTE&&(A=3001===r&&!1===n?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT_4_4_4_4&&(A=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(A=e.RGB5_A1)),A!==e.R16F&&A!==e.R32F&&A!==e.RG16F&&A!==e.RG32F&&A!==e.RGBA16F&&A!==e.RGBA32F||Wt(e,"EXT_color_buffer_float"),A}function Jt(e,t){return 1003===t||1004===t||1005===t?e.NEAREST:e.LINEAR}function Yt(e){if(!$t(e.width)||!$t(e.height)){const t=document.createElement("canvas");t.width=qt(e.width),t.height=qt(e.height);t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),e=t}return e}function $t(e){return 0==(e&e-1)}function qt(e){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1}class es extends ie{get type(){return"Texture"}constructor(e,t={}){super(e,t),this._state=new xe({texture:new Kt({gl:this.scene.canvas.gl}),matrix:R.identityMat4(),hasMatrix:t.translate&&(0!==t.translate[0]||0!==t.translate[1])||!!t.rotate||t.scale&&(0!==t.scale[0]||0!==t.scale[1]),minFilter:this._checkMinFilter(t.minFilter),magFilter:this._checkMagFilter(t.magFilter),wrapS:this._checkWrapS(t.wrapS),wrapT:this._checkWrapT(t.wrapT),flipY:this._checkFlipY(t.flipY),encoding:this._checkEncoding(t.encoding)}),this._src=null,this._image=null,this._translate=R.vec2([0,0]),this._scale=R.vec2([1,1]),this._rotate=R.vec2([0,0]),this._matrixDirty=!1,this.translate=t.translate,this.scale=t.scale,this.rotate=t.rotate,t.src?this.src=t.src:t.image&&(this.image=t.image),L.memory.textures++}_checkMinFilter(e){return 1006!==(e=e||1008)&&1007!==e&&1008!==e&&1005!==e&&1004!==e&&(this.error("Unsupported value for 'minFilter' - supported values are LinearFilter, LinearMipMapNearestFilter, NearestMipMapNearestFilter, NearestMipMapLinearFilter and LinearMipMapLinearFilter. Defaulting to LinearMipMapLinearFilter."),e=1008),e}_checkMagFilter(e){return 1006!==(e=e||1006)&&1003!==e&&(this.error("Unsupported value for 'magFilter' - supported values are LinearFilter and NearestFilter. Defaulting to LinearFilter."),e=1006),e}_checkWrapS(e){return 1001!==(e=e||1e3)&&1002!==e&&1e3!==e&&(this.error("Unsupported value for 'wrapS' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),e=1e3),e}_checkWrapT(e){return 1001!==(e=e||1e3)&&1002!==e&&1e3!==e&&(this.error("Unsupported value for 'wrapT' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),e=1e3),e}_checkFlipY(e){return!!e}_checkEncoding(e){return 3e3!==(e=e||3e3)&&3001!==e&&(this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),e=3e3),e}_update(){const e=this._state;if(this._matrixDirty){let t,s;0===this._translate[0]&&0===this._translate[1]||(t=R.translationMat4v([this._translate[0],this._translate[1],0],this._state.matrix)),1===this._scale[0]&&1===this._scale[1]||(s=R.scalingMat4v([this._scale[0],this._scale[1],1]),t=t?R.mulMat4(t,s):s),0!==this._rotate&&(s=R.rotationMat4v(.0174532925*this._rotate,[0,0,1]),t=t?R.mulMat4(t,s):s),t&&(e.matrix=t),this._matrixDirty=!1}this.glRedraw()}set image(e){this._image=Yt(e),this._image.crossOrigin="Anonymous",this._state.texture.setImage(this._image,this._state),this._src=null,this.glRedraw()}get image(){return this._image}set src(e){this.scene.loading++,this.scene.canvas.spinner.processes++;const t=this;let s=new Image;s.onload=function(){s=Yt(s),t._state.texture.setImage(s,t._state),t.scene.loading--,t.glRedraw(),t.scene.canvas.spinner.processes--},s.src=e,this._src=e,this._image=null}get src(){return this._src}set translate(e){this._translate.set(e||[0,0]),this._matrixDirty=!0,this._needUpdate()}get translate(){return this._translate}set scale(e){this._scale.set(e||[1,1]),this._matrixDirty=!0,this._needUpdate()}get scale(){return this._scale}set rotate(e){e=e||0,this._rotate!==e&&(this._rotate=e,this._matrixDirty=!0,this._needUpdate())}get rotate(){return this._rotate}get minFilter(){return this._state.minFilter}get magFilter(){return this._state.magFilter}get wrapS(){return this._state.wrapS}get wrapT(){return this._state.wrapT}get flipY(){return this._state.flipY}get encoding(){return this._state.encoding}destroy(){super.destroy(),this._state.texture&&this._state.texture.destroy(),this._state.destroy(),L.memory.textures--}}const ts=R.vec3(),ss=R.vec3();R.vec3();const is=R.vec3([0,-1,0]),rs=R.vec4([0,0,0,1]);class ns extends Ht{get type(){return"LambertMaterial"}constructor(e,t={}){super(e,t),this._state=new xe({type:"LambertMaterial",ambient:R.vec3([1,1,1]),color:R.vec3([1,1,1]),emissive:R.vec3([0,0,0]),alpha:null,alphaMode:0,lineWidth:null,pointSize:null,backfaces:null,frontface:null,hash:"/lam;"}),this.ambient=t.ambient,this.color=t.color,this.emissive=t.emissive,this.alpha=t.alpha,this.lineWidth=t.lineWidth,this.pointSize=t.pointSize,this.backfaces=t.backfaces,this.frontface=t.frontface}set ambient(e){let t=this._state.ambient;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.ambient=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=.2,t[1]=.2,t[2]=.2),this.glRedraw()}get ambient(){return this._state.ambient}set color(e){let t=this._state.color;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.color=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1),this.glRedraw()}get color(){return this._state.color}set emissive(e){let t=this._state.emissive;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.emissive=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=0,t[1]=0,t[2]=0),this.glRedraw()}get emissive(){return this._state.emissive}set alpha(e){e=null!=e?e:1,this._state.alpha!==e&&(this._state.alpha=e,this._state.alphaMode=e<1?2:0,this.glRedraw())}get alpha(){return this._state.alpha}set lineWidth(e){this._state.lineWidth=e||1,this.glRedraw()}get lineWidth(){return this._state.lineWidth}set pointSize(e){this._state.pointSize=e||1,this.glRedraw()}get pointSize(){return this._state.pointSize}set backfaces(e){e=!!e,this._state.backfaces!==e&&(this._state.backfaces=e,this.glRedraw())}get backfaces(){return this._state.backfaces}set frontface(e){e="cw"!==e,this._state.frontface!==e&&(this._state.frontface=e,this.glRedraw())}get frontface(){return this._state.frontface?"ccw":"cw"}_getState(){return this._state}destroy(){super.destroy(),this._state.destroy()}}const As={opaque:0,mask:1,blend:2},os=["opaque","mask","blend"];class as extends Ht{get type(){return"MetallicMaterial"}constructor(e,t={}){super(e,t),this._state=new xe({type:"MetallicMaterial",baseColor:R.vec4([1,1,1]),emissive:R.vec4([0,0,0]),metallic:null,roughness:null,specularF0:null,alpha:null,alphaMode:null,alphaCutoff:null,lineWidth:null,pointSize:null,backfaces:null,frontface:null,hash:null}),this.baseColor=t.baseColor,this.metallic=t.metallic,this.roughness=t.roughness,this.specularF0=t.specularF0,this.emissive=t.emissive,this.alpha=t.alpha,t.baseColorMap&&(this._baseColorMap=this._checkComponent("Texture",t.baseColorMap)),t.metallicMap&&(this._metallicMap=this._checkComponent("Texture",t.metallicMap)),t.roughnessMap&&(this._roughnessMap=this._checkComponent("Texture",t.roughnessMap)),t.metallicRoughnessMap&&(this._metallicRoughnessMap=this._checkComponent("Texture",t.metallicRoughnessMap)),t.emissiveMap&&(this._emissiveMap=this._checkComponent("Texture",t.emissiveMap)),t.occlusionMap&&(this._occlusionMap=this._checkComponent("Texture",t.occlusionMap)),t.alphaMap&&(this._alphaMap=this._checkComponent("Texture",t.alphaMap)),t.normalMap&&(this._normalMap=this._checkComponent("Texture",t.normalMap)),this.alphaMode=t.alphaMode,this.alphaCutoff=t.alphaCutoff,this.backfaces=t.backfaces,this.frontface=t.frontface,this.lineWidth=t.lineWidth,this.pointSize=t.pointSize,this._makeHash()}_makeHash(){const e=this._state,t=["/met"];this._baseColorMap&&(t.push("/bm"),this._baseColorMap._state.hasMatrix&&t.push("/mat"),t.push("/"+this._baseColorMap._state.encoding)),this._metallicMap&&(t.push("/mm"),this._metallicMap._state.hasMatrix&&t.push("/mat")),this._roughnessMap&&(t.push("/rm"),this._roughnessMap._state.hasMatrix&&t.push("/mat")),this._metallicRoughnessMap&&(t.push("/mrm"),this._metallicRoughnessMap._state.hasMatrix&&t.push("/mat")),this._emissiveMap&&(t.push("/em"),this._emissiveMap._state.hasMatrix&&t.push("/mat")),this._occlusionMap&&(t.push("/ocm"),this._occlusionMap._state.hasMatrix&&t.push("/mat")),this._alphaMap&&(t.push("/am"),this._alphaMap._state.hasMatrix&&t.push("/mat")),this._normalMap&&(t.push("/nm"),this._normalMap._state.hasMatrix&&t.push("/mat")),t.push(";"),e.hash=t.join("")}set baseColor(e){let t=this._state.baseColor;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.baseColor=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1),this.glRedraw()}get baseColor(){return this._state.baseColor}get baseColorMap(){return this._baseColorMap}set metallic(e){e=null!=e?e:1,this._state.metallic!==e&&(this._state.metallic=e,this.glRedraw())}get metallic(){return this._state.metallic}get metallicMap(){return this._attached.metallicMap}set roughness(e){e=null!=e?e:1,this._state.roughness!==e&&(this._state.roughness=e,this.glRedraw())}get roughness(){return this._state.roughness}get roughnessMap(){return this._attached.roughnessMap}get metallicRoughnessMap(){return this._attached.metallicRoughnessMap}set specularF0(e){e=null!=e?e:0,this._state.specularF0!==e&&(this._state.specularF0=e,this.glRedraw())}get specularF0(){return this._state.specularF0}set emissive(e){let t=this._state.emissive;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.emissive=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=0,t[1]=0,t[2]=0),this.glRedraw()}get emissive(){return this._state.emissive}get emissiveMap(){return this._attached.emissiveMap}get occlusionMap(){return this._attached.occlusionMap}set alpha(e){e=null!=e?e:1,this._state.alpha!==e&&(this._state.alpha=e,this.glRedraw())}get alpha(){return this._state.alpha}get alphaMap(){return this._attached.alphaMap}get normalMap(){return this._attached.normalMap}set alphaMode(e){let t=As[e=e||"opaque"];void 0===t&&(this.error("Unsupported value for 'alphaMode': "+e+" defaulting to 'opaque'"),t="opaque"),this._state.alphaMode!==t&&(this._state.alphaMode=t,this.glRedraw())}get alphaMode(){return os[this._state.alphaMode]}set alphaCutoff(e){null==e&&(e=.5),this._state.alphaCutoff!==e&&(this._state.alphaCutoff=e)}get alphaCutoff(){return this._state.alphaCutoff}set backfaces(e){e=!!e,this._state.backfaces!==e&&(this._state.backfaces=e,this.glRedraw())}get backfaces(){return this._state.backfaces}set frontface(e){e="cw"!==e,this._state.frontface!==e&&(this._state.frontface=e,this.glRedraw())}get frontface(){return this._state.frontface?"ccw":"cw"}set lineWidth(e){this._state.lineWidth=e||1,this.glRedraw()}get lineWidth(){return this._state.lineWidth}set pointSize(e){this._state.pointSize=e||1,this.glRedraw()}get pointSize(){return this._state.pointSize}destroy(){super.destroy(),this._state.destroy()}}const ls={opaque:0,mask:1,blend:2},cs=["opaque","mask","blend"];class hs extends Ht{get type(){return"SpecularMaterial"}constructor(e,t={}){super(e,t),this._state=new xe({type:"SpecularMaterial",diffuse:R.vec3([1,1,1]),emissive:R.vec3([0,0,0]),specular:R.vec3([1,1,1]),glossiness:null,specularF0:null,alpha:null,alphaMode:null,alphaCutoff:null,lineWidth:null,pointSize:null,backfaces:null,frontface:null,hash:null}),this.diffuse=t.diffuse,this.specular=t.specular,this.glossiness=t.glossiness,this.specularF0=t.specularF0,this.emissive=t.emissive,this.alpha=t.alpha,t.diffuseMap&&(this._diffuseMap=this._checkComponent("Texture",t.diffuseMap)),t.emissiveMap&&(this._emissiveMap=this._checkComponent("Texture",t.emissiveMap)),t.specularMap&&(this._specularMap=this._checkComponent("Texture",t.specularMap)),t.glossinessMap&&(this._glossinessMap=this._checkComponent("Texture",t.glossinessMap)),t.specularGlossinessMap&&(this._specularGlossinessMap=this._checkComponent("Texture",t.specularGlossinessMap)),t.occlusionMap&&(this._occlusionMap=this._checkComponent("Texture",t.occlusionMap)),t.alphaMap&&(this._alphaMap=this._checkComponent("Texture",t.alphaMap)),t.normalMap&&(this._normalMap=this._checkComponent("Texture",t.normalMap)),this.alphaMode=t.alphaMode,this.alphaCutoff=t.alphaCutoff,this.backfaces=t.backfaces,this.frontface=t.frontface,this.lineWidth=t.lineWidth,this.pointSize=t.pointSize,this._makeHash()}_makeHash(){const e=this._state,t=["/spe"];this._diffuseMap&&(t.push("/dm"),this._diffuseMap.hasMatrix&&t.push("/mat"),t.push("/"+this._diffuseMap.encoding)),this._emissiveMap&&(t.push("/em"),this._emissiveMap.hasMatrix&&t.push("/mat")),this._glossinessMap&&(t.push("/gm"),this._glossinessMap.hasMatrix&&t.push("/mat")),this._specularMap&&(t.push("/sm"),this._specularMap.hasMatrix&&t.push("/mat")),this._specularGlossinessMap&&(t.push("/sgm"),this._specularGlossinessMap.hasMatrix&&t.push("/mat")),this._occlusionMap&&(t.push("/ocm"),this._occlusionMap.hasMatrix&&t.push("/mat")),this._normalMap&&(t.push("/nm"),this._normalMap.hasMatrix&&t.push("/mat")),this._alphaMap&&(t.push("/opm"),this._alphaMap.hasMatrix&&t.push("/mat")),t.push(";"),e.hash=t.join("")}set diffuse(e){let t=this._state.diffuse;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.diffuse=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1),this.glRedraw()}get diffuse(){return this._state.diffuse}get diffuseMap(){return this._diffuseMap}set specular(e){let t=this._state.specular;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.specular=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=1,t[1]=1,t[2]=1),this.glRedraw()}get specular(){return this._state.specular}get specularMap(){return this._specularMap}get specularGlossinessMap(){return this._specularGlossinessMap}set glossiness(e){e=null!=e?e:1,this._state.glossiness!==e&&(this._state.glossiness=e,this.glRedraw())}get glossiness(){return this._state.glossiness}get glossinessMap(){return this._glossinessMap}set specularF0(e){e=null!=e?e:0,this._state.specularF0!==e&&(this._state.specularF0=e,this.glRedraw())}get specularF0(){return this._state.specularF0}set emissive(e){let t=this._state.emissive;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.emissive=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=0,t[1]=0,t[2]=0),this.glRedraw()}get emissive(){return this._state.emissive}get emissiveMap(){return this._emissiveMap}set alpha(e){e=null!=e?e:1,this._state.alpha!==e&&(this._state.alpha=e,this.glRedraw())}get alpha(){return this._state.alpha}get alphaMap(){return this._alphaMap}get normalMap(){return this._normalMap}get occlusionMap(){return this._occlusionMap}set alphaMode(e){let t=ls[e=e||"opaque"];void 0===t&&(this.error("Unsupported value for 'alphaMode': "+e+" defaulting to 'opaque'"),t="opaque"),this._state.alphaMode!==t&&(this._state.alphaMode=t,this.glRedraw())}get alphaMode(){return cs[this._state.alphaMode]}set alphaCutoff(e){null==e&&(e=.5),this._state.alphaCutoff!==e&&(this._state.alphaCutoff=e)}get alphaCutoff(){return this._state.alphaCutoff}set backfaces(e){e=!!e,this._state.backfaces!==e&&(this._state.backfaces=e,this.glRedraw())}get backfaces(){return this._state.backfaces}set frontface(e){e="cw"!==e,this._state.frontface!==e&&(this._state.frontface=e,this.glRedraw())}get frontface(){return this._state.frontface?"ccw":"cw"}set lineWidth(e){this._state.lineWidth=e||1,this.glRedraw()}get lineWidth(){return this._state.lineWidth}set pointSize(e){this._state.pointSize=e||1,this.glRedraw()}get pointSize(){return this._state.pointSize}destroy(){super.destroy(),this._state.destroy()}}const us={default:{fill:!0,fillColor:[.4,.4,.4],fillAlpha:.2,edges:!0,edgeColor:[.2,.2,.2],edgeAlpha:.5,edgeWidth:1},defaultWhiteBG:{fill:!0,fillColor:[1,1,1],fillAlpha:.6,edgeColor:[.2,.2,.2],edgeAlpha:1,edgeWidth:1},defaultLightBG:{fill:!0,fillColor:[.4,.4,.4],fillAlpha:.2,edges:!0,edgeColor:[.2,.2,.2],edgeAlpha:.5,edgeWidth:1},defaultDarkBG:{fill:!0,fillColor:[.4,.4,.4],fillAlpha:.2,edges:!0,edgeColor:[.5,.5,.5],edgeAlpha:.5,edgeWidth:1},phosphorous:{fill:!0,fillColor:[0,0,0],fillAlpha:.4,edges:!0,edgeColor:[.9,.9,.9],edgeAlpha:.5,edgeWidth:2},sunset:{fill:!0,fillColor:[.9,.9,.6],fillAlpha:.2,edges:!0,edgeColor:[.9,.9,.9],edgeAlpha:.5,edgeWidth:1},vectorscope:{fill:!0,fillColor:[0,0,0],fillAlpha:.7,edges:!0,edgeColor:[.2,1,.2],edgeAlpha:1,edgeWidth:2},battlezone:{fill:!0,fillColor:[0,0,0],fillAlpha:1,edges:!0,edgeColor:[.2,1,.2],edgeAlpha:1,edgeWidth:3},sepia:{fill:!0,fillColor:[.970588207244873,.7965892553329468,.6660899519920349],fillAlpha:.4,edges:!0,edgeColor:[.529411792755127,.4577854573726654,.4100345969200134],edgeAlpha:1,edgeWidth:1},yellowHighlight:{fill:!0,fillColor:[1,1,0],fillAlpha:.5,edges:!0,edgeColor:[1,1,1],edgeAlpha:1,edgeWidth:1},greenSelected:{fill:!0,fillColor:[0,1,0],fillAlpha:.5,edges:!0,edgeColor:[1,1,1],edgeAlpha:1,edgeWidth:1},gamegrid:{fill:!0,fillColor:[.2,.2,.7],fillAlpha:.9,edges:!0,edgeColor:[.4,.4,1.6],edgeAlpha:.8,edgeWidth:3}};class ds extends Ht{get type(){return"EmphasisMaterial"}get presets(){return us}constructor(e,t={}){super(e,t),this._state=new xe({type:"EmphasisMaterial",fill:null,fillColor:null,fillAlpha:null,edges:null,edgeColor:null,edgeAlpha:null,edgeWidth:null,backfaces:!0,glowThrough:!0}),this._preset="default",t.preset?(this.preset=t.preset,void 0!==t.fill&&(this.fill=t.fill),t.fillColor&&(this.fillColor=t.fillColor),void 0!==t.fillAlpha&&(this.fillAlpha=t.fillAlpha),void 0!==t.edges&&(this.edges=t.edges),t.edgeColor&&(this.edgeColor=t.edgeColor),void 0!==t.edgeAlpha&&(this.edgeAlpha=t.edgeAlpha),void 0!==t.edgeWidth&&(this.edgeWidth=t.edgeWidth),void 0!==t.backfaces&&(this.backfaces=t.backfaces),void 0!==t.glowThrough&&(this.glowThrough=t.glowThrough)):(this.fill=t.fill,this.fillColor=t.fillColor,this.fillAlpha=t.fillAlpha,this.edges=t.edges,this.edgeColor=t.edgeColor,this.edgeAlpha=t.edgeAlpha,this.edgeWidth=t.edgeWidth,this.backfaces=t.backfaces,this.glowThrough=t.glowThrough)}set fill(e){e=!1!==e,this._state.fill!==e&&(this._state.fill=e,this.glRedraw())}get fill(){return this._state.fill}set fillColor(e){let t=this._state.fillColor;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.fillColor=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=.4,t[1]=.4,t[2]=.4),this.glRedraw()}get fillColor(){return this._state.fillColor}set fillAlpha(e){e=null!=e?e:.2,this._state.fillAlpha!==e&&(this._state.fillAlpha=e,this.glRedraw())}get fillAlpha(){return this._state.fillAlpha}set edges(e){e=!1!==e,this._state.edges!==e&&(this._state.edges=e,this.glRedraw())}get edges(){return this._state.edges}set edgeColor(e){let t=this._state.edgeColor;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.edgeColor=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=.2,t[1]=.2,t[2]=.2),this.glRedraw()}get edgeColor(){return this._state.edgeColor}set edgeAlpha(e){e=null!=e?e:.5,this._state.edgeAlpha!==e&&(this._state.edgeAlpha=e,this.glRedraw())}get edgeAlpha(){return this._state.edgeAlpha}set edgeWidth(e){this._state.edgeWidth=e||1,this.glRedraw()}get edgeWidth(){return this._state.edgeWidth}set backfaces(e){e=!!e,this._state.backfaces!==e&&(this._state.backfaces=e,this.glRedraw())}get backfaces(){return this._state.backfaces}set glowThrough(e){e=!1!==e,this._state.glowThrough!==e&&(this._state.glowThrough=e,this.glRedraw())}get glowThrough(){return this._state.glowThrough}set preset(e){if(console.warn("EmphasisMaterial.preset is deprecated and will be removed in future versions."),e=e||"default",this._preset===e)return;const t=us[e];t?(this.fill=t.fill,this.fillColor=t.fillColor,this.fillAlpha=t.fillAlpha,this.edges=t.edges,this.edgeColor=t.edgeColor,this.edgeAlpha=t.edgeAlpha,this.edgeWidth=t.edgeWidth,this.glowThrough=t.glowThrough,this._preset=e):this.error("unsupported preset: '"+e+"' - supported values are "+Object.keys(us).join(", "))}get preset(){return console.warn("EmphasisMaterial.preset is deprecated and will be removed in future versions."),this._preset}destroy(){super.destroy(),this._state.destroy()}}const ps={default:{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1},defaultWhiteBG:{edgeColor:[.2,.2,.2],edgeAlpha:1,edgeWidth:1},defaultLightBG:{edgeColor:[.2,.2,.2],edgeAlpha:1,edgeWidth:1},defaultDarkBG:{edgeColor:[.5,.5,.5],edgeAlpha:1,edgeWidth:1}};class fs extends Ht{get type(){return"EdgeMaterial"}get presets(){return ps}constructor(e,t={}){super(e,t),this._state=new xe({type:"EdgeMaterial",edges:null,edgeColor:null,edgeAlpha:null,edgeWidth:null}),this._preset="default",t.preset?(this.preset=t.preset,t.edgeColor&&(this.edgeColor=t.edgeColor),void 0!==t.edgeAlpha&&(this.edgeAlpha=t.edgeAlpha),void 0!==t.edgeWidth&&(this.edgeWidth=t.edgeWidth)):(this.edgeColor=t.edgeColor,this.edgeAlpha=t.edgeAlpha,this.edgeWidth=t.edgeWidth),this.edges=!1!==t.edges}set edges(e){e=!1!==e,this._state.edges!==e&&(this._state.edges=e,this.glRedraw())}get edges(){return this._state.edges}set edgeColor(e){let t=this._state.edgeColor;if(t){if(e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return}else t=this._state.edgeColor=new Float32Array(3);e?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=.2,t[1]=.2,t[2]=.2),this.glRedraw()}get edgeColor(){return this._state.edgeColor}set edgeAlpha(e){e=null!=e?e:1,this._state.edgeAlpha!==e&&(this._state.edgeAlpha=e,this.glRedraw())}get edgeAlpha(){return this._state.edgeAlpha}set edgeWidth(e){this._state.edgeWidth=e||1,this.glRedraw()}get edgeWidth(){return this._state.edgeWidth}set preset(e){if(e=e||"default",this._preset===e)return;const t=ps[e];t?(this.edgeColor=t.edgeColor,this.edgeAlpha=t.edgeAlpha,this.edgeWidth=t.edgeWidth,this._preset=e):this.error("unsupported preset: '"+e+"' - supported values are "+Object.keys(ps).join(", "))}get preset(){return this._preset}destroy(){super.destroy(),this._state.destroy()}}class gs extends ie{constructor(e,t={}){super(e,t),this._type=t.type||(t.src?t.src.split(".").pop():null)||"jpg",this._pos=R.vec3(t.pos||[0,0,0]),this._up=R.vec3(t.up||[0,1,0]),this._normal=R.vec3(t.normal||[0,0,1]),this._height=t.height||1,this._origin=R.vec3(),this._rtcPos=R.vec3(),this._imageSize=R.vec2(),this._texture=new es(this,{flipY:!0}),this._image=new Image,"jpg"!==this._type&&"png"!==this._type&&(this.error('Unsupported type - defaulting to "jpg"'),this._type="jpg"),this._node=new ct(this,{matrix:R.inverseMat4(R.lookAtMat4v(this._pos,R.subVec3(this._pos,this._normal,R.mat4()),this._up,R.mat4())),children:[this._bitmapMesh=new Ot(this,{scale:[1,1,1],rotation:[-90,0,0],collidable:t.collidable,pickable:t.pickable,opacity:t.opacity,clippable:t.clippable,geometry:new Le(this,Ze({center:[0,0,0],xSize:1,zSize:1,xSegments:2,zSegments:2})),material:new jt(this,{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:this._texture,emissiveMap:this._texture,backfaces:!0})})]}),t.image?this.image=t.image:t.src?this.src=t.src:t.imageData&&(this.imageData=t.imageData),this.scene._bitmapCreated(this)}set visible(e){this._bitmapMesh.visible=e}get visible(){return this._bitmapMesh.visible}set image(e){this._image=e,this._image&&(this._texture.image=this._image,this._imageSize[0]=this._image.width,this._imageSize[1]=this._image.height,this._updateBitmapMeshScale())}get image(){return this._image}set src(e){if(e){this._image.onload=()=>{this._texture.image=this._image,this._imageSize[0]=this._image.width,this._imageSize[1]=this._image.height,this._updateBitmapMeshScale()},this._image.src=e;switch(e.split(".").pop()){case"jpeg":case"jpg":this._type="jpg";break;case"png":this._type="png"}}}get src(){return this._image.src}set imageData(e){this._image.onload=()=>{this._texture.image=image,this._imageSize[0]=image.width,this._imageSize[1]=image.height,this._updateBitmapMeshScale()},this._image.src=e}get imageData(){const e=document.createElement("canvas"),t=e.getContext("2d");return e.width=this._image.width,e.height=this._image.height,t.drawImage(this._image,0,0),e.toDataURL("jpg"===this._type?"image/jpeg":"image/png")}set type(e){"png"===(e=e||"jpg")&&"jpg"===e||(this.error("Unsupported value for `type` - supported types are `jpg` and `png` - defaulting to `jpg`"),e="jpg"),this._type=e}get type(){return this._type}get pos(){return this._pos}get normal(){return this._normal}get up(){return this._up}set height(e){this._height=null==e?1:e,this._image&&this._updateBitmapMeshScale()}get height(){return this._height}set collidable(e){this._bitmapMesh.collidable=!1!==e}get collidable(){return this._bitmapMesh.collidable}set clippable(e){this._bitmapMesh.clippable=!1!==e}get clippable(){return this._bitmapMesh.clippable}set pickable(e){this._bitmapMesh.pickable=!1!==e}get pickable(){return this._bitmapMesh.pickable}set opacity(e){this._bitmapMesh.opacity=e}get opacity(){return this._bitmapMesh.opacity}destroy(){super.destroy(),this.scene._bitmapDestroyed(this)}_updateBitmapMeshScale(){const e=this._imageSize[1]/this._imageSize[0];this._bitmapMesh.scale=[this._height/e,1,this._height]}}const ms=(e,t)=>{const s=[];let i=[];function r(e,s){let i,r;for(let n=0;n<3;n++)if(i=t[3*e+n],r=t[3*s+n],i!==r)return r-i;return 0}let n=e.slice().sort(r),A=null;for(let e=0,t=n.length;e<t;e++)0!==e&&0===r(n[e],n[e-1])||(A=n[e]),s[n[e]]=A;for(let t=0,r=e.length;t<r;t+=3){const r=s[e[t]],n=s[e[t+1]],A=s[e[t+2]];let o=r,a=n,l=A;if(r>n&&r>A?n>A?(o=r,a=n,l=A):(o=r,a=A,l=n):n>r&&n>A?r>A?(o=n,a=r,l=A):(o=n,a=A,l=r):A>r&&A>n&&(r>n?(o=A,a=r,l=n):(o=A,a=n,l=r)),i[t+0]=[o,a],i[t+1]=[a,l],o>l){const e=l;l=o,o=e}i[t+2]=[l,o]}function o(e,t){let s,i;for(let r=0;r<2;r++)if(s=e[r],i=t[r],i!==s)return i-s;return 0}i=i.slice(0,e.length),i.sort(o);let a=0;for(let e=0;e<i.length;e++)if(0===e||0!==o(i[e],i[e-1])){if(0!==e&&2!==a)return!1;a=1}else a++;return!(i.length>0&&2!==a)},_s=R.vec3(),bs=R.vec3(),Bs=R.vec3();class ys{constructor(){this.vertices=[],this.indices=[],this.reset()}reset(){this.lenVertices=0,this.lenIndices=0,this.primitive=null}setPrimitive(e){this.primitive=e}addVertex(e){this.vertices[this.lenVertices++]=e[0],this.vertices[this.lenVertices++]=e[1],this.vertices[this.lenVertices++]=e[2]}addIndex(e){this.indices[this.lenIndices++]=e}get volume(){const e=this.vertices,t=this.indices;if("solid"!==this.primitive&&"surface"!==this.primitive&&"triangles"!==this.primitive)return-1;if("solid"!==this.primitive&&!ms(t,e))return-1;let s=0;for(let i=0;i<this.lenIndices;i+=3){const r=3*t[i],n=3*t[i+1],A=3*t[i+2];_s[0]=e[r],_s[1]=e[r+1],_s[2]=e[r+2],bs[0]=e[n],bs[1]=e[n+1],bs[2]=e[n+2],Bs[0]=e[A],Bs[1]=e[A+1],Bs[2]=e[A+2],R.cross3Vec3(_s,bs,_s),s+=R.dotVec3(_s,Bs)}return s/6}}const ws=new ys,vs=R.vec3(),Cs=R.vec3(),Ms=R.vec3(),Es=R.vec3(),Fs=R.vec3(),xs=R.vec3();class Us{constructor(){this.vertices=[],this.indices=[],this.reset()}reset(){this.lenVertices=0,this.lenIndices=0}addVertex(e){this.vertices[this.lenVertices++]=e[0],this.vertices[this.lenVertices++]=e[1],this.vertices[this.lenVertices++]=e[2]}addIndex(e){this.indices[this.lenIndices++]=e}get surfaceArea(){const e=this.vertices,t=this.indices;let s=0;for(let i=0;i<this.lenIndices;i+=3){const r=3*t[i],n=3*t[i+1],A=3*t[i+2];vs[0]=e[r],vs[1]=e[r+1],vs[2]=e[r+2],Cs[0]=e[n],Cs[1]=e[n+1],Cs[2]=e[n+2],Ms[0]=e[A],Ms[1]=e[A+1],Ms[2]=e[A+2],R.subVec3(vs,Cs,Es),R.subVec3(Ms,Cs,Fs),s+=.5*R.lenVec3(R.cross3Vec3(Es,Fs,xs))}return s}}const Is=new Us,Ts=R.OBB3(),Ps=R.OBB3(),Ss=R.OBB3();class Ds{constructor(e,t,s,i,r,n,A=null,o=0){this.model=e,this.object=null,this.parent=null,this.transform=r,this.textureSet=n,this._matrixDirty=!1,this._matrixUpdateScheduled=!1,this.id=t,this.obb=null,this._aabbLocal=null,this._aabbWorld=R.AABB3(),this._aabbWorldDirty=!1,this.layer=A,this.portionId=o,this._color=new Uint8Array([s[0],s[1],s[2],i]),this._colorize=new Uint8Array([s[0],s[1],s[2],i]),this._colorizing=!1,this._transparent=i<255,this.numTriangles=0,this.origin=null,this.entity=null,r&&r._addMesh(this),this._volume=null,this._surfaceArea=null}_sceneModelDirty(){this._aabbWorldDirty=!0,this.layer.aabbChanged()}_transformDirty(){this._matrixDirty||this._matrixUpdateScheduled||(this.model._meshMatrixDirty(this),this._matrixDirty=!0,this._matrixUpdateScheduled=!0),this._aabbWorldDirty=!0,this.layer.aabbChanged(),this.entity&&this.entity._transformDirty()}_updateMatrix(){this.transform&&this._matrixDirty&&this.layer.setMatrix(this.portionId,this.transform.worldMatrix),this._matrixDirty=!1,this._matrixUpdateScheduled=!1}_finalize(e){this.layer.initFlags(this.portionId,e,this._transparent)}_finalize2(){this.layer.flushInitFlags&&this.layer.flushInitFlags()}_setVisible(e){this.layer.setVisible(this.portionId,e,this._transparent)}_setColor(e){this._color[0]=e[0],this._color[1]=e[1],this._color[2]=e[2],this._colorizing||this.layer.setColor(this.portionId,this._color,!1)}_setColorize(e){e?(this._colorize[0]=e[0],this._colorize[1]=e[1],this._colorize[2]=e[2],this.layer.setColor(this.portionId,this._colorize,false),this._colorizing=!0):(this.layer.setColor(this.portionId,this._color,false),this._colorizing=!1)}_setOpacity(e,t){const s=e<255,i=this._transparent!==s;this._color[3]=e,this._colorize[3]=e,this._transparent=s,this._colorizing?this.layer.setColor(this.portionId,this._colorize):this.layer.setColor(this.portionId,this._color),i&&this.layer.setTransparent(this.portionId,t,s)}_setOffset(e){this.layer.setOffset(this.portionId,e)}_setHighlighted(e){this.layer.setHighlighted(this.portionId,e,this._transparent)}_setXRayed(e){this.layer.setXRayed(this.portionId,e,this._transparent)}_setSelected(e){this.layer.setSelected(this.portionId,e,this._transparent)}_setEdges(e){this.layer.setEdges(this.portionId,e,this._transparent)}_setClippable(e){this.layer.setClippable(this.portionId,e,this._transparent)}_setCollidable(e){this.layer.setCollidable(this.portionId,e)}_setPickable(e){this.layer.setPickable(this.portionId,e,this._transparent)}_setCulled(e){this.layer.setCulled(this.portionId,e,this._transparent)}canPickTriangle(){return!1}drawPickTriangles(e,t){}pickTriangleSurface(e){}precisionRayPickSurface(e,t,s,i){return this.layer.precisionRayPickSurface(this.portionId,e,t,s,i)}canPickWorldPos(){return!0}drawPickDepths(e){this.model.drawPickDepths(e)}drawPickNormals(e){this.model.drawPickNormals(e)}delegatePickedEntity(){return this.parent}getEachVertex(e){this.layer.getEachVertex&&this.layer.getEachVertex(this.portionId,e)}getEachIndex(e){this.layer.getEachIndex&&this.layer.getEachIndex(this.portionId,e)}isSolid(){return this.layer.solid}get volume(){if(null!==this._volume)return this._volume;switch(this.layer.primitive){case"solid":case"surface":case"triangles":ws.reset(),ws.setPrimitive(this.layer.primitive),this.getEachVertex((e=>{ws.addVertex(e)})),this.getEachIndex((e=>{ws.addIndex(e)})),this._volume=ws.volume;break;default:this._volume=0}return this._volume}get surfaceArea(){if(null!==this._surfaceArea)return this._surfaceArea;switch(this.layer.primitive){case"solid":case"surface":case"triangles":Is.reset(),this.getEachVertex((e=>{Is.addVertex(e)})),this.getEachIndex((e=>{Is.addIndex(e)})),this._surfaceArea=Is.surfaceArea;break;default:this._surfaceArea=0}return this._surfaceArea}set aabb(e){if(this._aabbLocal=e,this.origin){this._aabbLocal=e.slice(0);const t=this.origin;this._aabbLocal[0]+=t[0],this._aabbLocal[1]+=t[1],this._aabbLocal[2]+=t[2],this._aabbLocal[3]+=t[0],this._aabbLocal[4]+=t[1],this._aabbLocal[5]+=t[2]}}get aabb(){return this._aabbWorldDirty&&(R.AABB3ToOBB3(this._aabbLocal,Ts),this.transform?(R.transformOBB3(this.transform.worldMatrix,Ts,Ps),R.transformOBB3(this.model.worldMatrix,Ps,Ss),R.OBB3ToAABB3(Ss,this._aabbWorld)):(R.transformOBB3(this.model.worldMatrix,Ts,Ps),R.OBB3ToAABB3(Ps,this._aabbWorld)),this._aabbWorldDirty=!1),this._aabbWorld}_destroy(){this.model.scene._renderer.putPickID(this.pickId),this.layer=null}}const ks=1,Qs=4,Rs=8,Os=16,Vs=32,Ls=256,Hs=512,Ns=1024,Gs=2048,js=function(e,t,s,i){const r=i&&e.createUniform("vec4","edgeColor",((e,t)=>e(t.legacyFrameCtx.programColor))),n=t.attributes.color,A=!i&&e.createVarying("vec4","vColor",(()=>`vec4(${n}.rgb * 0.5, ${n}.a)`)),o=e.createOutput("vec4","outColor");return{programName:i?"Edges":"EdgesColor",getLogDepth:s&&(e=>e),renderPassFlag:2,appendFragmentOutputs:e=>e.push(`${o} = ${r||A};`)}},Ws=function(e,t){const s=e.createOutput("vec4","outColor");return{programName:"Occlusion",getLogDepth:!1,renderPassFlag:0,appendFragmentOutputs:e=>e.push(`${s} = vec4(0.0, 0.0, 1.0, 1.0);`)}},zs=function(e,t,s,i){const r=e.createUniform("vec4","silhouetteColor",((e,t)=>e(t.legacyFrameCtx.programColor))),n=e.createVarying("float","vAlpha",(()=>`${t.attributes.color}.a`)),A=e.createOutput("vec4","outColor");return{programName:"Silhouette",getLogDepth:s&&(e=>e),renderPassFlag:1,appendFragmentOutputs:(e,t,s,o)=>{e.push(`${A} = ${i?r:o(`vec4(${r}.rgb, min(${r}.a, ${n}))`)};`)}}},Xs=R.vec2(),Ks=R.vec3(),Zs=R.vec4(),Js=R.mat4(),Ys=R.vec3([0,0,0]),$s=0,qs=1,ei=2,ti=3,si=4,ii=5,ri=6,ni=7,Ai=8,oi=9,ai=10,li=11,ci=e=>[R.safeInv(e[0]),R.safeInv(e[1]),R.safeInv(e[2])],hi=(e,t,s,i,r)=>{const n=!!(e&ks),A=!!(e&Ls),o=!!(e&Hs),a=!!(e&Ns),l=!!(e&Gs),c=!!(e&Rs),h=!!(e&Qs);let u,d;u=!n||h||A||o&&!i.highlightMaterial.glowThrough||a&&!i.selectedMaterial.glowThrough?$s:t?ei:qs,d=!n||h?$s:a?si:o?ti:A?ii:$s;let p=0;p=s&&n&&!h?a?oi:o?Ai:A?ai:l?t?ni:ri:$s:$s;const f=n&&!h&&c?li:$s;r[0]=u,r[1]=d,r[2]=p,r[3]=f},ui=function(){const e={};return function(t,s,i,r,n,A,o,a){const l=[s,"points"===i||"lines"===i?i:"triangles",!!r,!!n,!!A,!!o].join(":");l in e||(e[l]={});const c=e[l],h=t.id;if(!(h in c)){const e=t.canvas.gl,l=function(r,n,A){const o=function(){const A=bt(),o=A.programVariables,l=a(o,n);return r(o,l.geometryParameters,(function(r,a){const c=t.pointsMaterial,h="points"===i&&!n,u=()=>[t._sectionPlanesState.getHash()].concat(h?[c.hash]:[]).concat(r.getHash?r.getHash():[]).join(";"),d=u(),p=()=>d===u(),f=l.geometryParameters,g=r.incrementDrawState,m=r.isShadowProgram,_=f.attributes,b=_.position.world,B="clipPos",[y,w]=A.buildProgram(e,s+" "+i+" "+r.programName,{appendFragmentOutputs:r.appendFragmentOutputs,cleanerEdges:r.cleanerEdges,clipPos:B,clippableTest:l.clippableTest,clippingCaps:r.clippingCaps,crossSections:t.crossSections,discardPoints:h&&c.roundPoints,getGammaFactor:t.gammaOutput&&(()=>t.gammaFactor),getLogDepth:r.getLogDepth,getPointSize:function(){const e=[];if(h){const t=o.createUniform("float","pointSize",(e=>e(c.pointSize)));if(c.perspectivePoints){const s=o.createUniform("float","nearPlaneHeight",((e,t)=>e(t.legacyFrameCtx.nearPlaneHeight))),i=`${Math.floor(c.minPerspectivePointSize)}.0`,r=`${Math.floor(c.maxPerspectivePointSize)}.0`;e.push(`clamp((${s} * ${t}) / gl_Position.w, ${i}, ${r})`)}else e.push(t)}else n&&n.vertices&&e.push("1.0");return r.incPointSizeBy10&&"points"===i&&e.push("10.0"),e.length>0&&(()=>e.join(" + "))}(),getVertexData:()=>{const e=_.color,t=_.flags[r.renderPassFlag],s=o.createUniform("int","renderPass",((e,t)=>e(t.renderPass))),n=[`if (${m?`(${t} <= 0) || (${e}.a < 1.0)`:`${t} != ${s}`}) {`,` gl_Position = vec4(${r.vertexCullX||0}, 0.0, 0.0, 0.0);`," return;","}"].concat(l.dontCullOnAlphaZero||r.dontCullOnAlphaZero?[]:[`if (${e}.a == 0.0) {`," gl_Position = vec4(3.0, 3.0, 3.0, 1.0);"," return;","}"]).concat(r.filterIntensityRange&&"points"===i&&c.filterIntensity?function(){const t=o.createUniform("vec2","intensityRange",(e=>{Xs[0]=c.minIntensity,Xs[1]=c.maxIntensity,e(Xs)}));return[`if ((${e}.a < ${t}[0]) || (${e}.a > ${t}[1])) {`," gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"," return;","}"]}():[]),A=[];l.ensureColorAndFlagAvailable&&l.ensureColorAndFlagAvailable(A),n.forEach((e=>A.push(e))),l.appendVertexData(A);const a=f.attributes.position.view;return A.push(`vec4 ${a} = ${f.viewMatrix} * ${b};`),A.push(`vec4 clipPos = ${f.projMatrix} * ${a};`),A},projMatrix:f.projMatrix,sectionPlanesState:t._sectionPlanesState,testPerspectiveForGl_FragDepth:"points"!==i&&"lines"!==i||n,usePickClipPos:a,worldPositionAttribute:b});return w?(console.error(w),{getValid:p,destroy:()=>{},drawLayer:(e,t,s)=>{}}):{getValid:p,destroy:()=>y.destroy(),drawLayer:(e,t,s)=>{e.lastProgramId!==y.id&&(e.lastProgramId=y.id,y.bind());const i=t.origin,r=t.model,A=e.viewParams,o=Ks;R.transformPoint3(r.matrix,i,o);const a=A.viewMatrix,c=A.projMatrix;e.snapPickOrigin&&(e.snapPickOrigin[0]=o[0],e.snapPickOrigin[1]=o[1],e.snapPickOrigin[2]=o[2]);const h={legacyFrameCtx:e,layerTextureSet:t.layerTextureSet,mesh:{layerIndex:t.layerIndex,origin:o,renderFlags:{sectionPlanesActivePerLayer:r.renderFlags.sectionPlanesActivePerLayer}},renderPass:s,view:{eye:A.eye,far:A.far,projMatrix:c,viewMatrix:R.compareVec3(o,Ys)?a:ut(a,o,Js),viewNormalMatrix:A.viewNormalMatrix}};y.inputSetters.setUniforms(e,h),t.drawCalls[n?n.vertices?"drawVertices":"drawEdges":"drawSurface"](y.inputSetters.attributesHash,l.layerTypeInputs,{projMatrix:c,viewMatrix:R.compareVec3(o,Ys)?a:ut(a,o,Js),viewNormalMatrix:A.viewNormalMatrix,eye:A.eye}),g&&e.drawElements++}}}))};let l=A&&o();return{drawLayer:(e,t,s)=>{l||(l=o()),l.drawLayer(e,t,s)},revalidate:e=>{!l||!e&&l.getValid()||(l.destroy(),l=A&&o())}}},u=(e,t)=>l(e,t,!0),d=(e,t)=>l(e,t,!1),p=(e,s,r,n)=>function(e,t,s,i,r,n){const A=e.createVarying("vec4","vColor",(()=>{const e=t.attributes,s="points"===n?`vec4(${e.color}.rgb, 1.0)`:`${e.color}`;return i?`vec4(${[i.getAmbientColor()].concat(i.directionalLights.map((s=>`max(dot(${e.normal.view}, ${s.getDirection(t.viewMatrix,e.position.view)}), 0.0) * ${s.getColor()}`))).join(" + ")}, 1) * ${s}`:s})),o=e.createOutput("vec4","outColor");return{programName:"Color",getHash:()=>[i?i.getHash():"-",r?"sao":"nosao"],cleanerEdges:!0,getLogDepth:s&&(e=>"points"!==n&&"lines"!==n?`${e} + length(vec2(dFdx(${e}), dFdy(${e})))`:e),renderPassFlag:0,appendFragmentOutputs:(e,t,s,i)=>{"points"===n||"lines"===n?e.push(`${o} = ${A};`):(e.push(`vec4 fragColor = ${i(A)};`),e.push(`${o} = ${r?`vec4(fragColor.rgb * ${r.getAmbient(s)}, fragColor.a)`:"fragColor"};`))},filterIntensityRange:!0,incrementDrawState:!0}}(e,s,t.logarithmicDepthBufferEnabled,r,n,i),f=(e,s,i)=>i(function(e,t,s){const i=e.createUniform("float","far",((e,t)=>e(t.legacyFrameCtx.viewParams.far))),r=e.createUniform("float","near",((e,t)=>e(t.legacyFrameCtx.viewParams.near))),n=e.createVarying("vec3","vViewPosition",(()=>`${t.attributes.position.view}.xyz`)),A=e.createOutput("vec4","outPackedDepth"),o=e.createFragmentDefinition("packDepth",((e,t)=>{t.push(`vec4 ${e}(const in float depth) {`),t.push(" const vec4 bitShift = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);"),t.push(" const vec4 bitMask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);"),t.push(" vec4 res = fract(depth * bitShift);"),t.push(" res -= res.xxyz * bitMask;"),t.push(" return res;"),t.push("}")}));return{programName:"PickDepth",getLogDepth:s&&(e=>e),renderPassFlag:3,incPointSizeBy10:!0,appendFragmentOutputs:e=>{e.push(`float zNormalizedDepth = abs((${r} + ${n}.z) / (${i} - ${r}));`),e.push(`${A} = ${o}(zNormalizedDepth);`)}}}(e,s,t.logarithmicDepthBufferEnabled),!0),g=(e,s,i)=>i(function(e,t,s){const i=e.createVarying("vec4","vPickColor",(()=>`${t.attributes.pickColor} / 255.0`)),r=e.createOutput("vec4","outPickColor");return{programName:"PickMesh",getLogDepth:s&&(e=>e),renderPassFlag:3,incPointSizeBy10:!0,dontCullOnAlphaZero:!0,appendFragmentOutputs:e=>e.push(`${r} = ${i};`)}}(e,s,t.logarithmicDepthBufferEnabled),!0),m=(e,s,i,r)=>i(function(e,t,s,i){const r=e.createVarying("vec3","vWorldPosition",(()=>`${t.attributes.position.world}.xyz`)),n=e.createVarying("vec3","vWorldNormal",(()=>t.attributes.normal.world)),A=e.createOutput("highp ivec4","outNormal");return{programName:i?"PickNormalsFlat":"PickNormals",getLogDepth:s&&(e=>e),renderPassFlag:3,appendFragmentOutputs:e=>{const t=i?`normalize(cross(dFdx(${r}), dFdy(${r})))`:n;e.push(`${A} = ivec4(${t} * float(${R.MAX_INT}), 1.0);`)}}}(e,s,t.logarithmicDepthBufferEnabled,r),!0),_=(e,t,s,i,r)=>s(function(e,t,s,i){const r=e.createUniform("int","layerNumber",((e,t)=>e(t.legacyFrameCtx.snapPickLayerParams.length))),n=e.createUniform("vec3","coordinateScaler",((e,t)=>e(t.legacyFrameCtx.snapPickCoordinateScale))),A=e.createVarying("vec3","vWorldPosition",(()=>`${t.attributes.position.world}.xyz`)),o=e.createVarying("vec4","vPickColor",(()=>t.attributes.pickColor)),a=e.createOutput("highp ivec4","outCoords",0),l=e.createOutput("highp ivec4","outNormal",1),c=e.createOutput("lowp uvec4","outPickColor",2);return{programName:s?"SnapInit":"Snap",getLogDepth:e=>s?`${e} + length(vec2(dFdx(${e}), dFdy(${e})))`:e,renderPassFlag:3,vertexCullX:!s&&"2.0",dontCullOnAlphaZero:!s,appendFragmentOutputs:e=>{e.push(`${a} = ivec4(${A} * ${n}.xyz, ${s?"-":""}${r});`),s&&(e.push(`${l} = ${i?"ivec4(1.0)":`ivec4(normalize(cross(dFdx(${A}), dFdy(${A}))) * float(${R.MAX_INT}), 1.0)`};`),e.push(`${c} = uvec4(${o});`))}}}(e,t,i,r),!0);c[h]="points"===i?{colorRenderers:{"sao-":{vertex:d(((e,t,s)=>s(p(e,t,null,null))))}},occlusionRenderer:d(((e,s,i)=>i(Ws(e,t.logarithmicDepthBufferEnabled)))),pickDepthRenderer:d(f),pickMeshRenderer:d(g),silhouetteRenderer:d(((e,s,i)=>i(zs(e,s,t.logarithmicDepthBufferEnabled,!0)))),snapInitRenderer:d(((e,t,s)=>_(e,t,s,!0,!0))),snapVertexRenderer:d(((e,t,s)=>_(e,t,s,!1,!0)),{vertices:!0})}:"lines"===i?{colorRenderers:{"sao-":{vertex:d(((e,t,s)=>s(p(e,t,null,null))))}},silhouetteRenderer:d(((e,s,i)=>i(zs(e,s,t.logarithmicDepthBufferEnabled,!0)))),snapInitRenderer:d(((e,t,s)=>_(e,t,s,!0,!1))),snapEdgeRenderer:d(((e,t,s)=>_(e,t,s,!1,!1)),{vertices:!1}),snapVertexRenderer:d(((e,t,s)=>_(e,t,s,!1,!1)),{vertices:!0})}:{colorRenderers:function(){const e=e=>Bt(e,t._lightsState),s=e=>{const t=e.createUniform("vec4","uSAOParams",((e,t)=>e(t.legacyFrameCtx.saoParams))),s=yt(e,"sampler2D","uOcclusionTexture",3e3,((e,t)=>e(t.legacyFrameCtx.occlusionTexture)));return{getAmbient:e=>{const i=`${t}.w`;return`(smoothstep(${`${t}.z`}, 1.0, dot(${s(`${e}.xy / ${t}.xy`)}, (255. / 256.) / vec4(256. * 256. * 256., 256. * 256., 256., 1.))) * ${i})`}}},i=function(i){const r=(r,n,A)=>function(e,t,s,i,r,n,A){const o=yt(e,"sampler2D","uColorMap",3001,((e,t)=>{const s=t.layerTextureSet.colorTexture;s&&e(s.texture)})),a=n&&e.createUniform("float","materialAlphaCutoff",((e,t)=>e(t.layerTextureSet.alphaCutoff))),l=t.attributes,c=e.createVarying("vec3","vViewPosition",(()=>`${l.position.view}.xyz`)),h=e.createVarying("vec2","vUV",(()=>l.uv)),u=e.createVarying("vec4","vColor",(()=>l.color)),d=e.createOutput("vec4","outColor");return{programName:"ColorTexture",getHash:()=>[i.getHash(),r?"sao":"nosao",!!A,n?"alphaCutoffYes":"alphaCutoffNo"],getLogDepth:s.logarithmicDepthBufferEnabled&&(e=>e),renderPassFlag:0,appendFragmentOutputs:(e,s,n,A)=>{e.push(`vec3 viewNormal = normalize(cross(dFdx(${c}), dFdy(${c})));`),e.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);"),i.directionalLights.forEach((s=>{e.push(`reflectedColor += max(dot(viewNormal, ${s.getDirection(t.viewMatrix,c)}), 0.0) * ${s.getColor()};`)})),e.push(`vec4 color = vec4(${i.getAmbientColor()} + reflectedColor, 1) * ${A(u)};`),e.push(`vec4 sampleColor = ${o(h)};`),a&&e.push(`if (sampleColor.a < ${a}) { discard; }`),e.push("vec4 colorTexel = color * sampleColor;"),e.push(`${d} = vec4(colorTexel.rgb${r?" * "+r.getAmbient(n):""}, color.a);`),s&&e.push(`${d} = ${s(d)};`)},incrementDrawState:!0}}(r,n,t,e(r),i&&s(r),A,t.gammaOutput);return{PBR:n&&d(((r,n,A)=>A(function(e,t,s,i,r){const n=(t,s,i)=>yt(e,"sampler2D",t,s?3001:3e3,((e,t)=>{const s=i(t.layerTextureSet);s&&e(s.texture)})),A=t.attributes,o=i.getIrradiance,a=n("uColorMap",!0,(e=>e.colorTexture)),l=n("uMetallicRoughMap",!1,(e=>e.metallicRoughnessTexture)),c=n("uEmissiveMap",!0,(e=>e.emissiveTexture)),h=n("uNormalMap",!1,(e=>e.normalsTexture)),u=n("uAOMap",!1,(e=>e.occlusionTexture)),d=e.createVarying("vec3","vViewPosition",(()=>`${A.position.view}.xyz`)),p=e.createVarying("vec3","vViewNormal",(()=>A.normal.view)),f=e.createVarying("vec4","vColor",(()=>A.color)),g=e.createVarying("vec2","vUV",(()=>A.uv)),m=e.createVarying("vec2","vMetallicRoughness",(()=>A.metallicRoughness)),_=e.createVarying("vec3","vWorldNormal",(()=>`${A.normal.world}.xyz`)),b=e.createOutput("vec4","outColor"),B=e.createFragmentDefinition("saturate",((e,t)=>t.push(`float ${e}(const in float a) { return clamp(a, 0.0, 1.0); }`))),y=e.createFragmentDefinition("BRDF_Specular_GGX",((e,t)=>{t.push("vec3 F_Schlick(const in vec3 specularColor, const in float dotLH) {"),t.push(" float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );"),t.push(" return ( 1.0 - specularColor ) * fresnel + specularColor;"),t.push("}"),t.push("float G_GGX_Smith(const in float alpha, const in float dotNL, const in float dotNV) {"),t.push(" float a2 = ( alpha * alpha );"),t.push(" float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );"),t.push(" float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );"),t.push(" return 1.0 / ( gl * gv );"),t.push("}"),t.push("float G_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {"),t.push(" float a2 = ( alpha * alpha );"),t.push(" float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );"),t.push(" float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );"),t.push(" return 0.5 / max( gv + gl, 1e-6 );"),t.push("}"),t.push("float D_GGX(const in float alpha, const in float dotNH) {"),t.push(" float a2 = ( alpha * alpha );"),t.push(" float denom = ( dotNH * dotNH) * ( a2 - 1.0 ) + 1.0;"),t.push(" return 0.31830988618 * a2 / ( denom * denom);"),t.push("}"),t.push(`vec3 ${e}(const in vec3 incidentLightDirection, const in vec3 viewNormal, const in vec3 viewEyeDir, const in vec3 specularColor, const in float roughness) {`),t.push(" float alpha = ( roughness * roughness );"),t.push(" vec3 halfDir = normalize( incidentLightDirection + viewEyeDir );"),t.push(` float dotNL = ${B}( dot( viewNormal, incidentLightDirection ) );`),t.push(` float dotNV = ${B}( dot( viewNormal, viewEyeDir ) );`),t.push(` float dotNH = ${B}( dot( viewNormal, halfDir ) );`),t.push(` float dotLH = ${B}( dot( incidentLightDirection, halfDir ) );`),t.push(" vec3 F = F_Schlick( specularColor, dotLH );"),t.push(" float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );"),t.push(" float D = D_GGX( alpha, dotNH );"),t.push(" return F * (G * D);"),t.push("}")})),w=e.createFragmentDefinition("BRDF_Specular_GGX_Environment",((e,t)=>{t.push(`vec3 ${e}(const in vec3 viewNormal, const in vec3 viewEyeDir, const in vec3 specularColor, const in float roughness) {`),t.push(` float dotNV = ${B}(dot(viewNormal, viewEyeDir));`),t.push(" const vec4 c0 = vec4( -1, -0.0275, -0.572, 0.022);"),t.push(" const vec4 c1 = vec4( 1, 0.0425, 1.04, -0.04);"),t.push(" vec4 r = roughness * c0 + c1;"),t.push(" float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y;"),t.push(" vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;"),t.push(" return specularColor * AB.x + AB.y;"),t.push("}")})),v=e.createFragmentDefinition("perturbNormal2Arb",((e,t)=>{t.push(`vec3 ${e}( vec3 eye_pos, vec3 surf_norm, vec2 uv, vec4 texel ) {`),t.push(" if (texel.r == 0.0 && texel.g == 0.0 && texel.b == 0.0) {"),t.push(" return surf_norm;"),t.push(" }"),t.push(" vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );"),t.push(" vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );"),t.push(" vec2 st0 = dFdx( uv.st );"),t.push(" vec2 st1 = dFdy( uv.st );"),t.push(" vec3 S = normalize( q0 * st1.t - q1 * st0.t );"),t.push(" vec3 T = normalize( -q0 * st1.s + q1 * st0.s );"),t.push(" vec3 N = normalize( surf_norm );"),t.push(" vec3 mapN = texel.xyz * 2.0 - 1.0;"),t.push(" mat3 tsn = mat3( S, T, N );"),t.push(" return normalize( tsn * mapN );"),t.push("}")}));return{programName:"PBR",getHash:()=>[i.getHash(),r?"sao":"nosao",!!s.gammaOutput],getLogDepth:s.logarithmicDepthBufferEnabled&&(e=>e),renderPassFlag:0,clippingCaps:s._sectionPlanesState.clippingCaps&&b,incrementDrawState:!0,appendFragmentOutputs:(e,s,n)=>{if(e.push("const float PI = 3.14159265359;"),e.push("vec3 reflDiff = vec3(0.0);"),e.push("vec3 reflSpec = vec3(0.0);"),e.push(`vec3 rgb = ${f}.rgb;`),e.push(`float opacity = ${f}.a;`),e.push("vec3 baseColor = rgb;"),e.push("float specularF0 = 1.0;"),e.push(`float metallic = float(${m}.r) / 255.0;`),e.push(`float roughness = float(${m}.g) / 255.0;`),e.push("float dielectricSpecular = 0.16 * specularF0 * specularF0;"),e.push(`vec4 colorTexel = ${a(g)};`),e.push("baseColor *= colorTexel.rgb;"),e.push(`vec3 metalRoughTexel = ${l(g)}.rgb;`),e.push("metallic *= metalRoughTexel.b;"),e.push("roughness *= metalRoughTexel.g;"),e.push("vec3 diffuseColor = baseColor * (1.0 - dielectricSpecular) * (1.0 - metallic);"),e.push("float specularRoughness = clamp(roughness, 0.04, 1.0);"),e.push("vec3 specularColor = mix(vec3(dielectricSpecular), baseColor, metallic);"),e.push(`vec3 viewNormal = -${v}(${d}, normalize(${p}), ${g}, ${h(g)});`),e.push(`vec3 viewEyeDir = normalize(${d});`),o&&e.push(`reflDiff += ${o(`normalize(${_})`)};`),i.getReflection){const s=`normalize((vec4(reflect(viewEyeDir, viewNormal), 0.0) * ${t.viewMatrix}).xyz)`,r="8.0",n=`0.5 * clamp(${r} - 0.79248 - 0.5 * log2(pow((2.0 / pow(specularRoughness + 0.0001, 2.0) - 2.0), 2.0) + 1.0), 0.0, ${r})`,A=i.getReflection(s,n),o=`${w}(viewNormal, viewEyeDir, specularColor, specularRoughness)`;e.push(`reflSpec += ${A} * ${o};`)}i.directionalLights.forEach(((s,i)=>{e.push(`vec3 lightDirection${i} = -${s.getDirection(t.viewMatrix,d)};`);const r=`${B}(dot(viewNormal, lightDirection${i}))`;e.push(`vec3 irradiance${i} = ${r} * ${s.getColor()};`),e.push(`reflDiff += irradiance${i};`),e.push(`reflSpec += irradiance${i} * PI * ${y}(lightDirection${i}, viewNormal, viewEyeDir, specularColor, specularRoughness);`)})),e.push(`vec3 emissiveColor = ${c(g)}.rgb;`),e.push(`float aoFactor = ${u(g)}.r;`);const A=`${i.getAmbientColor()} * baseColor * opacity * rgb`;e.push(`vec3 outgoingLight = emissiveColor + reflDiff * diffuseColor + reflSpec + ${A};`),e.push(`${b} = vec4(outgoingLight * aoFactor${r?` * ${r.getAmbient(n)}`:""}, opacity);`),s&&e.push(`${b} = ${s(b)};`)}}}(r,n,t,e(r),i&&s(r))))),texture:A&&{"alphaCutoff-":d(((e,t,s)=>s(r(e,t,!1)))),"alphaCutoff+":d(((e,t,s)=>s(r(e,t,!0))))},vertex:d(o?(t,r,n)=>n(p(t,r,e(t),i&&s(t))):(r,n,A)=>A(function(e,t,s,i,r){const n=t.attributes,A=e.createVarying("vec3","vViewPosition",(()=>`${n.position.view}.xyz`)),o=e.createVarying("vec4","vColor",(()=>n.color)),a=e.createOutput("vec4","outColor");return{programName:"FlatColor",getHash:()=>[i.getHash(),r?"sao":"nosao"],cleanerEdges:!0,getLogDepth:s&&(e=>e),renderPassFlag:0,appendFragmentOutputs:(e,s,n,l)=>{e.push(`vec3 viewNormal = normalize(cross(dFdx(${A}), dFdy(${A})));`);const c=[i.getAmbientColor()].concat(i.directionalLights.map((e=>`max(dot(viewNormal, ${e.getDirection(t.viewMatrix,A)}), 0.0) * ${e.getColor()}`)));e.push(`vec4 fragColor = vec4(${c.join(" + ")}, 1) * ${l(o)};`),e.push(`${a} = ${r?`vec4(fragColor.rgb * ${r.getAmbient(n)}, fragColor.a)`:"fragColor"};`)}}}(r,n,t.logarithmicDepthBufferEnabled,e(r),i&&s(r))))}};return{"sao-":i(!1),"sao+":r&&i(!0)}}(),depthRenderer:d(((e,s,i)=>i(function(e,t,s){const i=e.createVarying("highp vec2","vHighPrecisionZW",(()=>`${t.attributes.position.clip}.zw`)),r=e.createOutput("vec4","outColor");return{programName:"Depth",getLogDepth:s&&(e=>e),renderPassFlag:0,appendFragmentOutputs:e=>e.push(`${r} = vec4(vec3((1.0 - ${i}[0] / ${i}[1]) / 2.0), 1.0);`)}}(e,s,t.logarithmicDepthBufferEnabled)))),edgesRenderers:{uniform:d(((e,s,i)=>i(js(e,s,t.logarithmicDepthBufferEnabled,!0))),{vertices:!1}),vertex:d(((e,s,i)=>i(js(e,s,t.logarithmicDepthBufferEnabled,!1))),{vertices:!1})},occlusionRenderer:d(((e,s,i)=>i(Ws(e,t.logarithmicDepthBufferEnabled)))),pickDepthRenderer:u(f),pickMeshRenderer:u(g),pickNormalsFlatRenderer:u(((e,t,s)=>m(e,t,s,!0))),pickNormalsRenderer:u(((e,t,s)=>m(e,t,s,!1))),shadowRenderer:d(((e,s,i)=>i(function(e,t){const s=e.createOutput("vec4","outColor"),i=e.createFragmentDefinition("encodeFloat",((e,t)=>{t.push(`vec4 ${e}(const in float v) {`),t.push(" const vec4 bitShift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0);"),t.push(" const vec4 bitMask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);"),t.push(" vec4 comp = fract(v * bitShift);"),t.push(" comp -= comp.xxyz * bitMask;"),t.push(" return comp;"),t.push("}")}));return{programName:"Shadow",getLogDepth:t&&(e=>e),renderPassFlag:0,isShadowProgram:!0,appendFragmentOutputs:(e,t,r)=>e.push(`${s} = ${i}(${r}.z);`)}}(e,t)))),silhouetteRenderer:u(((e,s,i)=>i(zs(e,s,t.logarithmicDepthBufferEnabled,!1)))),snapInitRenderer:u(((e,t,s)=>_(e,t,s,!0,!1))),snapEdgeRenderer:u(((e,t,s)=>_(e,t,s,!1,!1)),{vertices:!1}),snapVertexRenderer:u(((e,t,s)=>_(e,t,s,!1,!1)),{vertices:!0})};const b=e=>{!function t(s){s.revalidate?s.revalidate(e):Object.values(s).forEach((e=>e&&t(e)))}(c[h])},B=()=>b(!1);B(),t.on("compile",B),t.on("destroyed",(()=>{delete c[h]}))}return c[h]}}();class di{constructor(e,t,s){this.model=e,this.primitive=t,this.origin=s,this._meshes=[],this._aabb=R.collapseAABB3(),this._aabbDirty=!0}finalize(){if(!this._compiledPortions){this._compiledPortions=this.compilePortions(),this.solid=this._compiledPortions.solid,this.sortId=this._compiledPortions.sortId,this.layerTextureSet=this._compiledPortions.layerTextureSet,this.drawCalls=this._compiledPortions.drawCalls,this._renderers=this._compiledPortions.renderers,this._setFlags=this._compiledPortions.setFlags,this.setColor=this._compiledPortions.setColor,this.setMatrix=this._compiledPortions.setMatrix,this.setOffset=this._compiledPortions.setOffset,this.getEachIndex=this._compiledPortions.getEachIndex,this.getEachVertex=this._compiledPortions.getEachVertex,this.readGeometryData=this._compiledPortions.readGeometryData,this.precisionRayPickSurface=this._compiledPortions.precisionRayPickSurface,this._countsByFlag={};const e=(e,t)=>{const s={count:0,fromFlags:(i,r)=>{i&e?(s.count++,this.model[t]++):r||(s.count--,this.model[t]--)}};this._countsByFlag[e]=s};e(ks,"numVisibleLayerPortions"),e(Qs,"numCulledLayerPortions"),e(Rs,"numPickableLayerPortions"),e(Os,"numClippableLayerPortions"),e(Ls,"numXRayedLayerPortions"),e(Hs,"numHighlightedLayerPortions"),e(Ns,"numSelectedLayerPortions"),this._renderers.edgesRenderers&&e(Gs,"numEdgesLayerPortions"),this._countsByFlagArr=Object.values(this._countsByFlag),this._numTransparentLayerPortions=0}}aabbChanged(){this._aabbDirty=!0}getAABB(){return this._aabbDirty&&(R.collapseAABB3(this._aabb),this._meshes.forEach((e=>R.expandAABB3(this._aabb,e.aabb))),this._aabbDirty=!1),this._aabb}__drawLayer(e,t,s,i){if(this._countsByFlag[Qs].count<this._portions.length&&this._countsByFlag[ks].count>0){const e="points"!==this.primitive&&"lines"!==this.primitive&&[qs,ei,li,ti,si,ii];if(e&&e.includes(i)){const e=!0;if(t.backfaces!==e){const s=this.model.scene.canvas.gl;s.disable(s.CULL_FACE),t.backfaces=e}}t.textureUnit=0,s.drawLayer(t,this,i)}}__setVec4FromMaterialColorAlpha(e,t,s){return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=t,s}__drawColor(e,t,s){if((s?this._numTransparentLayerPortions<this._portions.length:this._numTransparentLayerPortions>0)&&this._countsByFlag[Ls].count<this._portions.length){const i=s&&t.withSAO&&this._renderers.colorRenderers["sao+"]||this._renderers.colorRenderers["sao-"],r=t.pbrEnabled&&i.PBR?i.PBR:t.colorTextureEnabled&&i.texture?i.texture[this.layerTextureSet&&"number"==typeof this.layerTextureSet.alphaCutoff?"alphaCutoff+":"alphaCutoff-"]:i.vertex,n=s?qs:ei;this.__drawLayer(e,t,r,n)}}drawColorOpaque(e,t){this.__drawColor(e,t,!0)}drawColorTransparent(e,t){this.__drawColor(e,t,!1)}drawDepth(e,t){const s=this._renderers.depthRenderer;s&&this._numTransparentLayerPortions<this._portions.length&&this._countsByFlag[Ls].count<this._portions.length&&this.__drawLayer(e,t,s,qs)}__drawSilhouette(e,t,s,i){t.programColor=this.__setVec4FromMaterialColorAlpha(s.fillColor,s.fillAlpha,Zs),this.__drawLayer(e,t,this._renderers.silhouetteRenderer,i)}drawSilhouetteXRayed(e,t){this._countsByFlag[Ls].count>0&&this.__drawSilhouette(e,t,this.model.scene.xrayMaterial,ii)}drawSilhouetteHighlighted(e,t){this._countsByFlag[Hs].count>0&&this.__drawSilhouette(e,t,this.model.scene.highlightMaterial,ti)}drawSilhouetteSelected(e,t){this._countsByFlag[Ns].count>0&&this.__drawSilhouette(e,t,this.model.scene.selectedMaterial,si)}__drawVertexEdges(e,t,s){const i=this._renderers.edgesRenderers&&this._renderers.edgesRenderers.vertex;i&&this._countsByFlag[Gs].count>0&&this.__drawLayer(e,t,i,s)}drawEdgesColorOpaque(e,t){this._compiledPortions.edgesColorOpaqueAllowed()&&this.__drawVertexEdges(e,t,ri)}drawEdgesColorTransparent(e,t){this._numTransparentLayerPortions>0&&this.__drawVertexEdges(e,t,ni)}__drawUniformEdges(e,t,s,i){const r=this._renderers.edgesRenderers&&this._renderers.edgesRenderers.uniform;r&&(t.programColor=this.__setVec4FromMaterialColorAlpha(s.edgeColor,s.edgeAlpha,Zs),this.__drawLayer(e,t,r,i))}drawEdgesHighlighted(e,t){this._countsByFlag[Hs].count>0&&this.__drawUniformEdges(e,t,this.model.scene.highlightMaterial,Ai)}drawEdgesSelected(e,t){this._countsByFlag[Ns].count>0&&this.__drawUniformEdges(e,t,this.model.scene.selectedMaterial,oi)}drawEdgesXRayed(e,t){this._countsByFlag[Ls].count>0&&this.__drawUniformEdges(e,t,this.model.scene.xrayMaterial,ai)}__drawPick(e,t,s){s&&this.__drawLayer(e,t,s,li)}drawPickMesh(e,t){this.__drawPick(e,t,this._renderers.pickMeshRenderer)}drawPickDepths(e,t){this.__drawPick(e,t,this._renderers.pickDepthRenderer)}drawPickNormals(e,t){const s=this._renderers.pickNormalsFlatRenderer;this.__drawPick(e,t,s)}drawSnap(e,t,s){t.snapPickOrigin=[0,0,0];const i=this.getAABB();t.snapPickCoordinateScale=R.mulVec3Scalar(ci([i[3]-i[0],i[4]-i[1],i[5]-i[2]]),R.MAX_INT);const r=s?this._renderers.snapInitRenderer:"edge"===t.snapMode?this._renderers.snapEdgeRenderer:this._renderers.snapVertexRenderer;this.__drawPick(e,t,r),t.snapPickLayerParams.push({origin:t.snapPickOrigin.slice(),coordinateScale:ci(t.snapPickCoordinateScale)})}drawOcclusion(e,t){const s=this._renderers.occlusionRenderer;s&&this.__drawLayer(e,t,s,qs)}drawShadow(e,t){const s=this._renderers.shadowRenderer;s&&this.__drawLayer(e,t,s,qs)}initFlags(e,t,s){this._countsByFlagArr.forEach((e=>e.fromFlags(t,!0))),s&&(this._numTransparentLayerPortions++,this.model.numTransparentLayerPortions++);const i="points"!==this.primitive;this._setFlags(e,t,s,i),this._compiledPortions.setFlags2(e,t,i)}flushInitFlags(){this._compiledPortions.setDeferredFlags()}setVisible(e,t,s){this._countsByFlag[ks].fromFlags(t),this._setFlags(e,t,s)}setCulled(e,t,s){this._countsByFlag[Qs].fromFlags(t),this._setFlags(e,t,s)}setPickable(e,t,s){this._countsByFlag[Rs].fromFlags(t),this._setFlags(e,t,s)}setClippable(e,t){this._countsByFlag[Os].fromFlags(t),this._compiledPortions.setClippableFlags(e,t)}setCollidable(e,t){}setXRayed(e,t,s){this._countsByFlag[Ls].fromFlags(t),this._setFlags(e,t,s)}setHighlighted(e,t,s){this._countsByFlag[Hs].fromFlags(t),this._setFlags(e,t,s)}setSelected(e,t,s){this._countsByFlag[Ns].fromFlags(t),this._setFlags(e,t,s)}setEdges(e,t,s){this._countsByFlag[Gs]&&(this._countsByFlag[Gs].fromFlags(t),this._setFlags(e,t,s))}setTransparent(e,t,s){s?(this._numTransparentLayerPortions++,this.model.numTransparentLayerPortions++):(this._numTransparentLayerPortions--,this.model.numTransparentLayerPortions--),this._setFlags(e,t,s)}destroy(){this._compiledPortions&&this._compiledPortions.destroy()}}let pi=65536,fi=5e6;class gi{constructor(){}set doublePrecisionEnabled(e){R.setDoublePrecisionEnabled(e)}get doublePrecisionEnabled(){return R.getDoublePrecisionEnabled()}set maxDataTextureHeight(e){(e=1024*Math.ceil(e/1024))>4096?e=4096:e<1024&&(e=1024),pi=e}get maxDataTextureHeight(){return pi}set maxGeometryBatchSize(e){e<1e5?e=1e5:e>5e6&&(e=5e6),fi=e}get maxGeometryBatchSize(){return fi}}const mi=e=>{const t=[];for(let s=0;s<e;++s)t.push(s);return t},_i={sizeDataColorsAndFlags:0,sizeDataInstancesMatrices:0,sizeDataPositionDecodeMatrices:0,sizeDataTextureOffsets:0,sizeDataTexturePositions:0,sizeDataTextureIndices:0,sizeDataTextureEdgeIndices:0,sizeDataTexturePortionIds:0,numberOfGeometries:0,numberOfPortions:0,numberOfLayers:0,numberOfTextures:0,totalPolygons:0,totalPolygons8Bits:0,totalPolygons16Bits:0,totalPolygons32Bits:0,totalEdges:0,totalEdges8Bits:0,totalEdges16Bits:0,totalEdges32Bits:0,cannotCreatePortion:{because10BitsObjectId:0,becauseTextureSize:0},overheadSizeAlignementIndices:0,overheadSizeAlignementEdgeIndices:0};window.printDataTextureRamStats=function(){console.log(JSON.stringify(_i,null,4));let e=0;Object.keys(_i).forEach((t=>{t.startsWith("size")&&(e+=_i[t])})),console.log(`Total size ${e} bytes (${(e/1e3/1e3).toFixed(2)} MB)`),console.log(`Avg bytes / triangle: ${(e/_i.totalPolygons).toFixed(2)}`);let t={};Object.keys(_i).forEach((s=>{s.startsWith("size")&&(t[s]=`${(_i[s]/e*100).toFixed(2)} % of total`)})),console.log(JSON.stringify({percentualRamUsage:t},null,4))};const bi=new gi,Bi=bi.maxDataTextureHeight,yi=R.vec3(),wi=R.vec3(),vi=R.vec4();R.vec4();const Ci=new Float32Array(16),Mi=new Uint8Array(4),Ei=R.identityMat4();class Fi extends di{constructor(e,t,s){super(e,t,s),_i.numberOfLayers++,this._sortId=`TriDTX-${_i.numberOfLayers}`;const i=e.scene.canvas.gl,r=(e,t)=>{const s=[];let r=0;const A=[];let o=0;const a=[];let l=0;const c=[];let h=0;return{len:()=>o,accumulateIndices:(i,u)=>{const d=i&&i.length>0&&function(){const t=r/3;r+=i.length,s.push(i);const a=i.length/3;return s=>{const i=o;o+=3*a,n.perObjectIndexBaseOffsets.push(i/3-t);for(let e=0;e<a;e+=8)A.push(s);_i[e]+=a,_i.totalPolygons+=a}}(),p=u&&function(){const e=l/2;l+=u.length,a.push(u);const s=u.length/2;return i=>{const r=h;h+=2*s,n.perObjectEdgeIndexBaseOffsets.push(r/2-e);for(let e=0;e<s;e+=8)c.push(i);_i[t]+=s,_i.totalEdges+=s}}();return _i.numberOfGeometries++,{numTriangles:i?i.length/3:0,accumulateSubPortionId:e=>{d&&d(e),p&&p(e)}}},createDrawers:(e,t)=>{const n=function(t,s){return t.length>0?e([t],t.length,1,i.UNSIGNED_SHORT,"sizeDataTexturePortionIds"):s},u=n(A,{texture:null}),d=r>0&&e(s,r,3,t,"sizeDataTextureIndices"),p=n(c),f=l>0&&e(a,l,2,t,"sizeDataTextureEdgeIndices");return{indices:function(e,t){o>0&&(e.perPrimIndices.setInputValue(d),e.perPrimIdPorIds.setInputValue(u),i.drawArrays(t,0,o))},edges:function(e,t){h>0&&(e.perPrimIndices.setInputValue(f),e.perPrimIdPorIds.setInputValue(p),i.drawArrays(t,0,h))}}}}},n=this._buffer={positionsCompressed:[],lenPositionsCompressed:0,geometry8Bits:r("totalPolygons8Bits","totalEdges8Bits"),geometry16Bits:r("totalPolygons16Bits","totalEdges16Bits"),geometry32Bits:r("totalPolygons32Bits","totalEdges32Bits"),perObjectColors:[],perObjectPickColors:[],perObjectSolid:[],perObjectPositionsDecodeMatrices:[],perObjectInstancePositioningMatrices:[],perObjectVertexBases:[],perObjectIndexBaseOffsets:[],perObjectEdgeIndexBaseOffsets:[]};this._numVertices=0,this._portions=[],this._subPortionReadableGeometries=this.model.scene.readableGeometryEnabled&&{},this._portionToSubPortionsMap=[],this._bucketGeometries={},this._primitive=t}canCreatePortion(e){const t=e.buckets.length;this._portions.length+t>65536&&_i.cannotCreatePortion.because10BitsObjectId++;let s=this._portions.length+t<=65536;const i=void 0!==e.geometryId&&null!==e.geometryId?`${e.geometryId}#0`:`${e.id}#0`;if(!this._bucketGeometries[i]){const t=this._buffer,i=Math.max(t.geometry8Bits.len(),t.geometry16Bits.len(),t.geometry32Bits.len());let r=0,n=0;e.buckets.forEach((e=>{r+=e.positionsCompressed.length/3,n+=e.indices.length/3})),(this._numVertices+r>4096*Bi||i+n>4096*Bi)&&_i.cannotCreatePortion.becauseTextureSize++,s&&=this._numVertices+r<=4096*Bi&&i+n<=4096*Bi}return s}createPortion(e,t){const s=this._buffer,i=t.buckets.map(((e,i)=>{const r=(t.geometryId??t.id)+"#"+i;if(!(r in this._bucketGeometries)){const t=(e,t,s)=>{if(e){const i=8*Math.ceil(e.length/t/8)*t,r=new Uint32Array(i);return r.set(e),_i[s]+=2*(r.length-e.length),r}return e};e.indices=t(e.indices,3,"overheadSizeAlignementIndices"),e.edgeIndices=t(e.edgeIndices,2,"overheadSizeAlignementEdgeIndices");const i=e.positionsCompressed;s.positionsCompressed.push(i);const n=i.length/3;this._numVertices+=n;const A=s.lenPositionsCompressed/3;s.lenPositionsCompressed+=i.length,this._bucketGeometries[r]={vertexBase:A,geometryData:function(){const t=e.indices,i=e.edgeIndices;return n<=256?s.geometry8Bits.accumulateIndices(t,i):n<=65536?s.geometry16Bits.accumulateIndices(t,i):s.geometry32Bits.accumulateIndices(t,i)}()}}const n=this._bucketGeometries[r];s.perObjectPositionsDecodeMatrices.push(t.positionsDecodeMatrix),s.perObjectInstancePositioningMatrices.push(t.meshMatrix||Ei),s.perObjectSolid.push(!!t.solid),s.perObjectPickColors.push(t.pickColor),s.perObjectVertexBases.push(n.vertexBase);const A=t.colors,o=t.color;s.perObjectColors.push(A?[255*A[0],255*A[1],255*A[2],255]:[o[0],o[1],o[2],t.opacity]);const a=this._portions.length;return this._portions.push({}),n.geometryData.accumulateSubPortionId(a),this._subPortionReadableGeometries&&(this._subPortionReadableGeometries[a]={indices:e.indices,positionsCompressed:e.positionsCompressed,positionsDecodeMatrix:t.positionsDecodeMatrix}),_i.numberOfPortions++,a})),r=this._portionToSubPortionsMap.length;return this._portionToSubPortionsMap.push(i),this.model.numPortions++,this._meshes.push(e),r}compilePortions(){const e=this._buffer,t=this.model,s=this._portions.length,i=this.origin,r=this._portionToSubPortionsMap,n=this._primitive,A=this._sortId,o=this._subPortionReadableGeometries,a=t.scene,l=a.canvas.gl,c=xi(l,s,32,l.UNSIGNED_BYTE,512,(t=>{const i=e=>[e>>24&255,e>>16&255,e>>8&255,255&e];for(let r=0;r<s;r++)t.set(e.perObjectColors[r],32*r+0),t.set(e.perObjectPickColors[r],32*r+4),t.set([0,0,0,0],32*r+8),t.set([0,0,0,0],32*r+12),t.set(i(e.perObjectVertexBases[r]),32*r+16),t.set(i(e.perObjectIndexBaseOffsets[r]),32*r+20),t.set(i(e.perObjectEdgeIndexBaseOffsets[r]),32*r+24),t.set([e.perObjectSolid[r]?1:0,0,0,0],32*r+28)}),"sizeDataColorsAndFlags",!0),h=c.textureData,u=function(e,t,s,i,r,n,A){return xi(l,t,s,i,r,(t=>{for(let s=0,i=0,r=e.length;s<r;s++){const r=e[s];t.set(r,i),i+=r.length}}),n,A)},d=function(e,t,s){const i=e.length;if(0===i)throw"num "+t+" matrices===0";return u(e,i,16,l.FLOAT,512,t,s)},p=d(e.perObjectInstancePositioningMatrices,"sizeDataInstancesMatrices",!0),f=p.textureData,g=d(e.perObjectPositionsDecodeMatrices,"sizeDataPositionDecodeMatrices",!1),m=function(e,t,s,i,r){return u(e,t/s,s,i,4096,r,!1)},_=m(e.positionsCompressed,e.lenPositionsCompressed,3,l.UNSIGNED_SHORT,"sizeDataTexturePositions"),b=e.geometry8Bits.createDrawers(m,l.UNSIGNED_BYTE),B=e.geometry16Bits.createDrawers(m,l.UNSIGNED_SHORT),y=e.geometry32Bits.createDrawers(m,l.UNSIGNED_INT);this._buffer=null;let w=!1,v=!1,C=!1,M=0;const E=()=>{w=!0},F=a.on("rendering",(()=>{v&&(w=!1,v=!1,h.reloadData()),M=0})),x=(e,s)=>{const i=r[e];if(i)for(let e=0,t=i.length;e<t;e++)s(i[e]);else t.error("portion not found: "+e)},U=(e,t,s,i)=>{const r=w||i;r?v=!0:++M>=10&&E(),h.setData(s,e,t,!r)},I=(e,t,s=!1)=>{Mi.set([t&Os?255:0,0,1,2]),x(e,(e=>U(e,3,Mi,s)))};return{edgesColorOpaqueAllowed:()=>!a.logarithmicDepthBufferEnabled||(a._loggedWarning||(console.log("Edge enhancement for SceneModel data texture layers currently disabled with logarithmic depth buffer"),a._loggedWarning=!0),!1),sortId:A,setClippableFlags:I,setFlags:(e,t,s,i=!1)=>{hi(t,s,!0,a,Mi),x(e,(e=>U(e,2,Mi,i)))},setFlags2:I,setDeferredFlags:()=>{},setColor:(e,t)=>{Mi.set(t),x(e,(e=>U(e,0,Mi,!1)))},setMatrix:(e,t)=>{x(e,(e=>{const s=w;s?v=!0:++M>=10&&E(),Ci.set(t),f.setData(Ci,e,0,!s)}))},setOffset:(e,t)=>{},getEachIndex:(e,t)=>{o&&x(e,(e=>o[e].indices.forEach((e=>t(e)))))},getEachVertex:(e,s)=>{o&&x(e,(e=>{const r=o[e],n=r.positionsCompressed,A=r.positionsDecodeMatrix,a=vi;for(let e=0,r=n.length;e<r;e+=3)a[0]=n[e],a[1]=n[e+1],a[2]=n[e+2],a[3]=1,R.decompressPosition(a,A),R.mulMat4v4(t.worldMatrix,a,a),R.addVec3(i,a,a),s(a)}))},precisionRayPickSurface:(e,t,s,i,r)=>!1,renderers:ui(a,"dtx",n,t.saoEnabled,!1,!1,!0,((e,t)=>Ui(e,!t))),drawCalls:function(){const e=function(e){const s=(e,t)=>e.setInputValue&&e.setInputValue(t);return(r,n,A)=>{s(n.worldMatrix,t.rotationMatrix),s(n.viewMatrix,A.viewMatrix),s(n.projMatrix,A.projMatrix);const o=R.transformPoint3(t.matrix,i,yi);s(n.uCameraEyeRtc,R.subVec3(A.eye,o,wi)),s(n.perObjPosDecode,g),s(n.perVertIdCoords,_),s(n.perObjColsFlags,c),s(n.perObjectMatrix,p),e(n)}},s=function(t){return e((e=>{b.edges(e,t),B.edges(e,t),y.edges(e,t)}))};return{drawVertices:s(l.POINTS),drawEdges:s(l.LINES),drawSurface:e((e=>{const t=l.TRIANGLES;b.indices(e,t),B.indices(e,t),y.indices(e,t)}))}}(),destroy:()=>{C||(a.off(F),C=!0)}}}}const xi=function(e,t,s,i,r,n,A,o){if(s>4&&s%4>0)throw"Unhandled data size "+s;const a=Math.ceil(s/4),l=s/a,[c,h,u]=function(){switch(i){case e.UNSIGNED_BYTE:return[Uint8Array,...1===l?[e.R8UI,e.RED_INTEGER]:2===l?[e.RG8UI,e.RG_INTEGER]:3===l?[e.RGB8UI,e.RGB_INTEGER]:[e.RGBA8UI,e.RGBA_INTEGER]];case e.UNSIGNED_SHORT:return[Uint16Array,...1===l?[e.R16UI,e.RED_INTEGER]:2===l?[e.RG16UI,e.RG_INTEGER]:3===l?[e.RGB16UI,e.RGB_INTEGER]:[e.RGBA16UI,e.RGBA_INTEGER]];case e.UNSIGNED_INT:return[Uint32Array,...1===l?[e.R32UI,e.RED_INTEGER]:2===l?[e.RG32UI,e.RG_INTEGER]:3===l?[e.RGB32UI,e.RGB_INTEGER]:[e.RGBA32UI,e.RGBA_INTEGER]];case e.FLOAT:return[Float32Array,...1===l?[e.R32F,e.RED]:2===l?[e.RG32F,e.RG]:3===l?[e.RGB32F,e.RGB]:[e.RGBA32F,e.RGBA]];default:throw"Unhandled data type "+i}}(),d=r*a,p=Math.ceil(t/r);if(0===p)throw"texture height===0";const f=new c(d*p*l);_i[A]+=f.byteLength,_i.numberOfTextures++,n(f);const g=e.createTexture();return e.bindTexture(e.TEXTURE_2D,g),e.texStorage2D(e.TEXTURE_2D,1,h,d,p),e.texSubImage2D(e.TEXTURE_2D,0,0,0,d,p,u,i,f),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null),{bind:t=>(e.activeTexture(e["TEXTURE"+t]),e.bindTexture(e.TEXTURE_2D,g),!0),unbind(e){},textureData:o&&{setData(t,n,A=0,o=!1){if(f.set(t,n*s+A*l),o){e.bindTexture(e.TEXTURE_2D,g);const s=n%r*a+A,o=Math.floor(n/r),c=t.length/l;e.texSubImage2D(e.TEXTURE_2D,0,s,o,c,1,u,i,t)}},reloadData(){e.bindTexture(e.TEXTURE_2D,g),e.texSubImage2D(e.TEXTURE_2D,0,0,0,d,p,u,i,f)}}}},Ui=function(e,t){const s=(t,s)=>{const i=e.createUniform(t,s),r=e=>`texelFetch(${i}, ${e}, 0)`;return r.map=i,r},i=s("highp usampler2D","perPrimIndices"),r=s("mediump usampler2D","perPrimIdPorIds"),n=s("highp sampler2D","perObjPosDecode"),A=s("mediump usampler2D","perVertIdCoords"),o=s("lowp usampler2D","perObjColsFlags"),a=s("highp sampler2D","perObjectMatrix"),l=e.createUniform("mat4","worldMatrix"),c=e.createUniform("mat4","viewMatrix"),h=e.createUniform("mat4","projMatrix"),u=e.createUniform("vec3","uCameraEyeRtc"),d=function(e){const t={toString:()=>(t.needed=!0,e)};return t},p=d("colorA"),f=d("pickColor"),g=d("worldNormal"),m=d("viewNormal"),_=e=>o(`ivec2(objectIndexCoords.x*8+${e}, objectIndexCoords.y)`);return{clippableTest:function(){const t=e.createVarying("uint","vClippable",(()=>"flags2.r"),"flat");return()=>`${t} > 0u`}(),geometryParameters:{attributes:{color:p,flags:mi(4).map((e=>`int(flags[${e}])`)),metallicRoughness:null,normal:{view:m,world:g},pickColor:f,position:{clip:"gl_Position",view:"viewPosition",world:"worldPosition"},uv:null},projMatrix:h,viewMatrix:c},ensureColorAndFlagAvailable:e=>{e.push("int primitiveIndex = gl_VertexID / "+(t?3:2)+";"),e.push("int h_packed_object_id_index = (primitiveIndex >> 3) & 4095;"),e.push("int v_packed_object_id_index = (primitiveIndex >> 3) >> 12;"),e.push(`int objectIndex = int(${r("ivec2(h_packed_object_id_index, v_packed_object_id_index)")}.r);`),e.push("ivec2 objectIndexCoords = ivec2(objectIndex % 512, objectIndex / 512);"),e.push(`uvec4 flags = ${_(2)};`),e.push(`uvec4 flags2 = ${_(3)};`),p.needed&&e.push(`vec4 ${p} = vec4(${_(0)}) / 255.0;`)},appendVertexData:e=>{const s=e=>a(`ivec2(objectIndexCoords.x*4+${e}, objectIndexCoords.y)`);e.push(`mat4 objectInstanceMatrix = mat4(${s(0)}, ${s(1)}, ${s(2)}, ${s(3)});`);const r=e=>n(`ivec2(objectIndexCoords.x*4+${e}, objectIndexCoords.y)`);if(e.push(`mat4 objectDecodeAndInstanceMatrix = objectInstanceMatrix * mat4(${r(0)}, ${r(1)}, ${r(2)}, ${r(3)});`),e.push(`ivec4 packedVertexBase = ivec4(${_(4)});`),e.push(`ivec4 packedIndexBaseOffset = ivec4(${_(t?5:6)});`),e.push("int indexBaseOffset = (packedIndexBaseOffset.r << 24) + (packedIndexBaseOffset.g << 16) + (packedIndexBaseOffset.b << 8) + packedIndexBaseOffset.a;"),e.push("int h_index = (primitiveIndex - indexBaseOffset) & 4095;"),e.push("int v_index = (primitiveIndex - indexBaseOffset) >> 12;"),e.push(`ivec3 vertexIndices = ivec3(${i("ivec2(h_index, v_index)")});`),e.push("ivec3 uniqueVertexIndexes = vertexIndices + (packedVertexBase.r << 24) + (packedVertexBase.g << 16) + (packedVertexBase.b << 8) + packedVertexBase.a;"),t){e.push("ivec3 indexPositionH = uniqueVertexIndexes & 4095;"),e.push("ivec3 indexPositionV = uniqueVertexIndexes >> 12;"),e.push(`uint solid = ${_(7)}.r;`);const t=e=>`vec3(${A(`ivec2(indexPositionH[${e}], indexPositionV[${e}])`)})`;e.push(`vec3 positions[] = vec3[](${t(0)}, ${t(1)}, ${t(2)});`),e.push("vec3 normal = normalize(cross(positions[2] - positions[0], positions[1] - positions[0]));"),e.push("vec3 position = positions[gl_VertexID % 3];"),g.needed&&e.push(`vec3 worldNormal = -normalize((transpose(inverse(${l} * objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);`),m.needed&&e.push(`vec3 viewNormal = -normalize((transpose(inverse(${c} * objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);`),e.push("if (solid != 1u) {"),e.push(` if (${o=h,`(${o}[2][3] == - 1.0)`}) {`),e.push(` vec3 uCameraEyeRtcInQuantizedSpace = (inverse(${l} * objectDecodeAndInstanceMatrix) * vec4(${u}, 1)).xyz;`),e.push(" if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {"),e.push(" position = positions[2 - (gl_VertexID % 3)];"),g.needed&&e.push(" worldNormal = -worldNormal;"),m.needed&&e.push(" viewNormal = -viewNormal;"),e.push(" }"),e.push(" } else {"),m.needed||e.push(` vec3 viewNormal = -normalize((transpose(inverse(${c} * objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);`),e.push(" if (viewNormal.z < 0.0) {"),e.push(" position = positions[2 - (gl_VertexID % 3)];"),g.needed&&e.push(" worldNormal = -worldNormal;"),m.needed&&e.push(" viewNormal = -viewNormal;"),e.push(" }"),e.push(" }"),e.push("}")}else e.push("int indexPositionH = uniqueVertexIndexes[gl_VertexID % 2] & 4095;"),e.push("int indexPositionV = uniqueVertexIndexes[gl_VertexID % 2] >> 12;"),e.push(`vec3 position = vec3(${A("ivec2(indexPositionH, indexPositionV)")});`);var o;f.needed&&e.push(`vec4 pickColor = vec4(${_(1)});`),e.push(`vec4 worldPosition = ${l} * (objectDecodeAndInstanceMatrix * vec4(position, 1.0));`)},layerTypeInputs:{perPrimIndices:i.map,perPrimIdPorIds:r.map,perObjPosDecode:n.map,perVertIdCoords:A.map,perObjColsFlags:o.map,perObjectMatrix:a.map,worldMatrix:l,viewMatrix:c,projMatrix:h,uCameraEyeRtc:u}}},Ii=R.mat4(),Ti=R.mat4();function Pi(e,t,s){const i=e.length,r=new Uint16Array(i),n=t[0],A=t[1],o=t[2],a=t[3]-n||1,l=t[4]-A||1,c=t[5]-o||1,h=65525,u=h/a,d=h/l,p=h/c,f=e=>e>=0?e:0;for(let t=0;t<i;t+=3)r[t+0]=Math.floor(f(e[t+0]-n)*u),r[t+1]=Math.floor(f(e[t+1]-A)*d),r[t+2]=Math.floor(f(e[t+2]-o)*p);return R.identityMat4(Ii),R.translationMat4v(t,Ii),R.identityMat4(Ti),R.scalingMat4v([a/h,l/h,c/h],Ti),R.mulMat4(Ii,Ti,s),r}function Si(e,t){const s=e[0],i=e[1],r=e[2],n=e[3]-s||1,A=e[4]-i||1,o=e[5]-r||1,a=65525;return R.identityMat4(Ii),R.translationMat4v(e,Ii),R.identityMat4(Ti),R.scalingMat4v([n/a,A/a,o/a],Ti),R.mulMat4(Ii,Ti,t),t}function Di(e,t,s){let i=e[0]/(Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2])),r=e[1]/(Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2]));if(e[2]<0){let e=i,t=r;e=(1-Math.abs(r))*(i>=0?1:-1),t=(1-Math.abs(i))*(r>=0?1:-1),i=e,r=t}return new Int8Array([Math[t](127.5*i+(i<0?-1:0)),Math[s](127.5*r+(r<0?-1:0))])}function ki(e){let t=e[0],s=e[1];t/=t<0?127:128,s/=s<0?127:128;const i=1-Math.abs(t)-Math.abs(s);i<0&&(t=(1-Math.abs(s))*(t>=0?1:-1),s=(1-Math.abs(t))*(s>=0?1:-1));const r=Math.sqrt(t*t+s*s+i*i);return[t/r,s/r,i/r]}const Qi=new Float32Array(1),Ri=new Float32Array(4),Oi=new Float32Array(3),Vi=R.mat4(),Li=R.vec4([0,0,0,1]),Hi=R.vec4(),Ni=R.vec3(),Gi=R.vec3(),ji=R.vec3(),Wi=R.vec3(),zi=R.vec3(),Xi=R.vec3(),Ki=R.vec3(),Zi=new Uint8Array(4),Ji=new Float32Array(96),Yi=function(e){const t=[];for(let s=0;s<e;++s)t.push(s);return t},$i=function(e,t){e.set(t);let s=t.length;const i=e.length;for(;s<i;){const t=Math.min(s,i-s);e.set(e.subarray(0,t),s),s+=t}},qi=function(){let e=0;const t=new Map;return{acquire:()=>e++,release:()=>{e--,0===e&&t.clear()},getTypeArray:function(e,s){t.has(e)||t.set(e,{});const i=t.get(e);return s in i||(i[s]=new e(s)),i[s]}}}();class er extends di{constructor(e,t,s,i){super(e,t,s);const r=!!i.geometry;this._maxVerts=i.maxGeometryBatchSize;const n=r?i.geometry.positionsDecodeMatrix:i.positionsDecodeMatrix;this._positionsDecodeMatrix=n&&R.mat4(n),this._cfgUvDecodeMatrix=i.uvDecodeMatrix&&R.mat3(i.uvDecodeMatrix),this._instancedGeometry=i.geometry,this._textureSet=i.textureSet,this._modelAABB=!r&&R.collapseAABB3(),this._portions=[];const A=function(){let e=0;const t=[];return{length:()=>e,append:function(s,i=1,r=1,n=0){e+=i*s.length,t.push({data:s,times:i,denormalizeScale:r,increment:n})},compileBuffer:function(e){let s=0;t.forEach((e=>{s+=e.times*e.data.length}));const i=new e(s);let r=0;return t.forEach((e=>{const t=e.data,s=e.denormalizeScale,n=e.increment,A=i.subarray(r);if(1===s&&0===n)A.set(t);else for(let e=0;e<t.length;++e)A[e]=n+t[e]*s;let o=t.length;const a=e.times*t.length;for(;o<a;){const e=Math.min(o,a-o);A.set(A.subarray(0,e),o),o+=e}r+=o})),i}}};this._buffer={colors:A(),metallicRoughness:A(),pickColors:A(),...r?{modelMatrixCol:[A(),A(),A()],modelNormalMatrixCol:[A(),A(),A()]}:{positions:A(),indices:A(),uv:A(),normals:A(),edgeIndices:A()}}}canCreatePortion(e,t){return this._instancedGeometry||this._buffer.positions.length()+e<=3*this._maxVerts&&this._buffer.indices.length()+t<=3*this._maxVerts}createPortion(e,t){const s=this._buffer,i=this._instancedGeometry,r=this.model,n=this._portions.length,A=this.primitive,o=!!this._positionsDecodeMatrix,a=r.scene,l=t.meshMatrix,c=(i,o,l,c,h)=>{const u=this._portions.length>0&&this._portions[this._portions.length-1],d={indicesBaseIndex:u?u.indicesBaseIndex+u.numIndices:0,numIndices:l?l.length:0,portionBase:i,portionSize:o,retainedGeometry:a.readableGeometryEnabled&&"points"!==A&&"lines"!==A&&{indices:l,quantizedPositions:c,offset:a.entityOffsetsEnabled&&R.vec3(),matrix:h&&h.slice(),inverseMatrix:null,normalMatrix:null}};return"points"!==A&&"lines"!==A&&s.metallicRoughness.append([t.metallic??0,t.roughness??255],o),"lines"!==A&&s.pickColors.append(t.pickColor.slice(0,4),o),this._portions.push(d),r.numPortions++,this._meshes.push(e),n};if(i){if(s.modelMatrixCol.forEach(((e,t)=>e.append([l[t+0],l[t+4],l[t+8],l[t+12]]))),"points"!==A){const e=t.color;s.colors.append([e[0],e[1],e[2],t.opacity??255])}if("points"!==A&&"lines"!==A&&i.normals){const e=R.inverseMat4(R.transposeMat4(l,R.mat4()));s.modelNormalMatrixCol.forEach(((t,s)=>t.append([e[s+0],e[s+4],e[s+8],e[s+12]])))}return c(n,1,i.indices,i.positionsCompressed,l)}{const e=s.positions.length()/3,i=o?t.positionsCompressed:t.positions;if(!i)throw(o?"positionsCompressed":"positions")+" expected";s.positions.append(i);const r=i.length/3,n=t.indices;n&&s.indices.append(n,1,1,e);const a=t.normalsCompressed,h=t.normals;if(a&&a.length>0)s.normals.append(a);else if(h&&h.length>0){const e=Vi;l?(R.transposeMat4(l,e),R.inverseMat4(e,e)):R.identityMat4(e);const t=[];!function(e,t,s,i,r){function n(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}let A,o,a,l,c,h,u=new Float32Array([0,0,0,0]),d=new Float32Array([0,0,0,0]);for(h=0;h<s;h+=3)u[0]=t[h],u[1]=t[h+1],u[2]=t[h+2],R.transformVec3(e,u,d),R.normalizeVec3(d,d),a=A=Di(d,"floor","floor"),o=ki(A),l=c=n(d,o),A=Di(d,"ceil","floor"),o=ki(A),l=n(d,o),l>c&&(a=A,c=l),A=Di(d,"floor","ceil"),o=ki(A),l=n(d,o),l>c&&(a=A,c=l),A=Di(d,"ceil","ceil"),o=ki(A),l=n(d,o),l>c&&(a=A,c=l),i[r+h+0]=a[0],i[r+h+1]=a[1],i[r+h+2]=0}(e,h,h.length,t,0),s.normals.append(t)}const u=t.colors,d=t.colorsCompressed,p=t.color;if(u)if("points"===A)s.colors.append(u,1,255);else{const e=[];for(let t=0,s=u.length;t<s;t+=3)e.push(255*u[t]),e.push(255*u[t+1]),e.push(255*u[t+2]),e.push(255);s.colors.append(e)}else if(d)if("points"===A)s.colors.append(d);else{const e=[];for(let t=0,s=d.length;t<s;t+=3)e.push(d[t]),e.push(d[t+1]),e.push(d[t+2]),e.push(255);s.colors.append(e)}else p&&s.colors.append([p[0],p[1],p[2],"points"===A?1:t.opacity],r);const f=e=>e&&e.length>0&&e,g=f(t.uv)||f(t.uvCompressed);g&&s.uv.append(g);const m=t.edgeIndices;return m&&s.edgeIndices.append(m,1,1,e),R.expandAABB3(this._modelAABB,t.aabb),c(e,r,n)}}compilePortions(){const e=this._buffer,t=this._instancedGeometry,s=this.model,i=this._modelAABB,r=this.origin,n=this._portions,A=this.primitive,o=this._textureSet;let a=this._positionsDecodeMatrix;const l=this._cfgUvDecodeMatrix,c=s.scene,h=c.canvas.gl,u=!!t,d=[],p=(e,t,s,i)=>{if(t.length>0){const r=t.constructor,[n,A]={[Uint8Array]:[1,h.UNSIGNED_BYTE],[Int8Array]:[1,h.BYTE],[Uint16Array]:[2,h.UNSIGNED_SHORT],[Int16Array]:[2,h.SHORT],[Uint32Array]:[4,h.UNSIGNED_INT],[Int32Array]:[4,h.INT],[Float32Array]:[4,h.FLOAT]}[r],o=h.createBuffer();d.push((()=>h.deleteBuffer(o)));const a=()=>h.bindBuffer(e,o),l=t=>{a(),h.bufferData(e,t,i)};l(t);const c=t.BYTES_PER_ELEMENT,u=t.length/s;return{bindBuffer:a,getData:(t=0,i=u-t)=>{a();const A=new r(i*s);return h.getBufferSubData(e,t*n*s,A,0,i*s),A},numItems:u,setData:l,setSubData:(t,s)=>{a(),h.bufferSubData(e,s*c,t)},type:A}}return null},f=(e,t,s,i=!1,r=!1)=>{const n=p(h.ARRAY_BUFFER,e,t,s);return n&&{getData:n.getData,numItems:n.numItems,setData:n.setData,setSubData:n.setSubData,attributeDivisor:i&&1,bindAtLocation:e=>{n.bindBuffer(),h.vertexAttribPointer(e,t,n.type,!!r,0,0)}}},g=e=>{const t=p(h.ELEMENT_ARRAY_BUFFER,e,1,h.STATIC_DRAW);return t&&{getData:t.getData,bindIndicesBuffer:t.bindBuffer,indicesCount:e.length,indicesType:t.type}},m=n.reduce(((e,t)=>e+t.portionSize),0),_=f(new Float32Array(m),1,h.DYNAMIC_DRAW,u),b=(e,t)=>f(e,4,t,u&&"points"!==A,!0),B=u&&t.colorsCompressed?b(new Uint8Array(t.colorsCompressed),h.STATIC_DRAW):b(e.colors.compileBuffer(Uint8Array),h.DYNAMIC_DRAW),y=c.entityOffsetsEnabled&&f(new Float32Array(3*m),3,h.DYNAMIC_DRAW,u),w=f(e.metallicRoughness.compileBuffer(Uint8Array),2,h.STATIC_DRAW,u),v=f(e.pickColors.compileBuffer(Uint8Array),4,h.STATIC_DRAW,u),C=g(u?new Uint32Array(t.edgeIndices):e.edgeIndices.compileBuffer(Uint32Array)),M=u?"points"!==A&&t.indices&&new Uint32Array(t.indices):e.indices.compileBuffer(Uint32Array),E=M&&g(M),F=u?t.positionsCompressed:a?e.positions.compileBuffer(Uint16Array):Pi(e.positions.compileBuffer(Float64Array),i,a=R.mat4()),x=F&&f(F,3,h.STATIC_DRAW);u||n.forEach((e=>{if(e.retainedGeometry){const t=3*e.portionBase;e.retainedGeometry.quantizedPositions=F.subarray(t,t+3*e.portionSize)}}));const U=u&&e.modelMatrixCol.map((e=>f(e.compileBuffer(Float32Array),4,h.STATIC_DRAW,!0))),I=!u&&e.normals.compileBuffer(Int8Array),T=I&&f(I,3,h.STATIC_DRAW,!1,!0),P=U&&T&&e.modelNormalMatrixCol.map((e=>f(e.compileBuffer(Float32Array),4,h.STATIC_DRAW,!0))),S=u?"points"!==A&&"lines"!==A&&t.uvCompressed&&{buf:f(t.uvCompressed,2,h.STATIC_DRAW),mat:t.uvDecodeMatrix}:function(){const t=e.uv.compileBuffer(Float32Array);if(0===t.length)return null;if(l)return{buf:f(t,2,h.STATIC_DRAW),mat:l};{const e=Re.getUVBounds(t),s=Re.compressUVs(t,e.min,e.max);return{buf:f(s.quantized,2,h.STATIC_DRAW),mat:R.mat3(s.decodeMatrix)}}}();this._buffer=null,qi.acquire(),d.push((()=>qi.release()));let D=null;const k=(e,s,i,r=!1)=>{hi(s,i,"points"!==A&&"lines"!==A,c,Zi);const o=s&Os?1:0;let a=0;a|=Zi[0],a|=Zi[1]<<4,a|=Zi[2]<<8,a|=Zi[3]<<12,a|=o<<16,Qi[0]=a;const l=n[e],h=l.portionBase,u=l.portionSize;if(r&&!t)D||(D=new Float32Array(m)),$i(D.subarray(h,h+u),Qi);else if(_){const e=qi.getTypeArray(Float32Array,u);$i(e,Qi),_.setSubData(e,h)}},Q="solid"===A;return{edgesColorOpaqueAllowed:()=>!0,solid:Q,sortId:("points"===A?"Points":"lines"===A?"Lines":"Triangles")+(u?"Instancing":"Batching")+"Layer"+("points"!==A&&"lines"!==A?(Q?"-solid":"-surface")+"-autoNormals"+(u?"":(o&&o.colorTexture?"-colorTexture":"")+(o&&o.metallicRoughnessTexture?"-metallicRoughnessTexture":"")):""),setClippableFlags:k,setFlags:k,setFlags2:(e,t,s)=>{},setDeferredFlags:()=>{D&&(_.setData(D),D=null)},setColor:(e,t)=>{if(B){const s=n[e],i=qi.getTypeArray(Uint8Array,4*s.portionSize);$i(i,t.slice(0,4)),B.setSubData(i,4*s.portionBase)}},setMatrix:(e,t)=>{U&&U.forEach(((s,i)=>{Ri[0]=t[i+0],Ri[1]=t[i+4],Ri[2]=t[i+8],Ri[3]=t[i+12],s.setSubData(Ri,4*e)}))},setOffset:(e,t)=>{if(c.entityOffsetsEnabled){const s=n[e];if(y){Oi.set(t);const e=qi.getTypeArray(Float32Array,3*s.portionSize);$i(e,Oi),y.setSubData(e,3*s.portionBase)}s.retainedGeometry&&s.retainedGeometry.offset.set(t)}else s.error("Entity#offset not enabled for this Viewer")},getEachIndex:(e,t)=>{const s=n[e].retainedGeometry;s&&s.indices.forEach((e=>t(e)))},getEachVertex:(e,t)=>{const i=n[e].retainedGeometry;if(i){const e=Hi;r?e.set(r,0):e[0]=e[1]=e[2]=0,e[3]=1;const n=s.matrix;R.mulMat4v4(n,e,e);const A=i.quantizedPositions,o=Li;for(let s=0,r=A.length;s<r;s+=3)o[0]=A[s],o[1]=A[s+1],o[2]=A[s+2],R.decompressPosition(o,a),i.matrix&&R.transformPoint3(i.matrix,o,o),o[3]=1,R.mulMat4v4(n,o,o),R.addVec3(e,o,o),t(o)}},readGeometryData:"points"!==A&&"lines"!==A&&(e=>{const t=!u&&n[e],i=t?E.getData(t.indicesBaseIndex,t.numIndices).map((e=>e-t.portionBase)):E.getData(),A=s.matrix,o=R.vec4();o.set(r,0),o[3]=1,R.mulMat4v4(A,o,o);const l=U&&R.mat4();if(l){const t=U[0].getData(e,1),s=U[1].getData(e,1),i=U[2].getData(e,1);l.set([t[0],s[0],i[0],0,t[1],s[1],i[1],0,t[2],s[2],i[2],0,t[3],s[3],i[3],1])}const c=R.mat4();R.mulMat4(A,l?R.mulMat4(l,a,c):a,c),c[12]+=o[0],c[13]+=o[1],c[14]+=o[2];const h=t?x.getData(t.portionBase,t.portionSize):x.getData();return{indices:i,positions:R.transformPositions3(c,h,new Float64Array(h.length))}}),precisionRayPickSurface:(e,t,i,A,o)=>{const l=n[e].retainedGeometry;if(l){l.matrix&&!l.inverseMatrix&&(l.inverseMatrix=R.inverseMat4(l.matrix,R.mat4())),o&&l.inverseMatrix&&!l.normalMatrix&&(l.normalMatrix=R.transposeMat4(l.inverseMatrix,R.mat4()));const e=l.quantizedPositions,n=l.indices,c=l.offset,h=Ni,u=Gi;h.set(r?R.subVec3(t,r,ji):t),u.set(i),c&&R.subVec3(h,c),R.transformRay(s.worldNormalMatrix,h,u,h,u),l.inverseMatrix&&R.transformRay(l.inverseMatrix,h,u,h,u);const d=Wi,p=zi,f=Xi;let g=!1,m=0;const _=Ki;for(let i=0,b=n.length;i<b;i+=3){const b=3*n[i],B=3*n[i+1],y=3*n[i+2];if(d[0]=e[b],d[1]=e[b+1],d[2]=e[b+2],p[0]=e[B],p[1]=e[B+1],p[2]=e[B+2],f[0]=e[y],f[1]=e[y+1],f[2]=e[y+2],R.decompressPosition(d,a),R.decompressPosition(p,a),R.decompressPosition(f,a),R.rayTriangleIntersect(h,u,d,p,f,_)){l.matrix&&R.transformPoint3(l.matrix,_,_),R.transformPoint3(s.worldMatrix,_,_),c&&R.addVec3(_,c),r&&R.addVec3(_,r);const e=Math.abs(R.lenVec3(R.subVec3(_,t,[])));(!g||e>m)&&(m=e,A.set(_),o&&R.triangleNormal(d,p,f,o),g=!0)}}return g&&o&&(l.normalMatrix&&R.transformVec3(l.normalMatrix,o,o),R.transformVec3(s.worldNormalMatrix,o,o),R.normalizeVec3(o)),g}return!1},layerTextureSet:o,renderers:ui(c,u?"instancing":"batching",A,s.saoEnabled,s.pbrEnabled&&S&&o&&o.colorTexture&&T&&w&&o.metallicRoughnessTexture,s.colorTextureEnabled&&S&&o&&o.colorTexture,!!T,(e=>sr(e,u&&{hasModelNormalMat:!!P},c.entityOffsetsEnabled))),drawCalls:function(){const e={},t=t=>(i,r,o)=>{let l=0;Ji.set(s.rotationMatrix,0),Ji.set(o.viewMatrix,l+=16),Ji.set(o.projMatrix,l+=16),Ji.set(a,l+=16),r.needNormal()&&(Ji.set(s.worldNormalMatrix,l+=16),Ji.set(o.viewNormalMatrix,l+=16)),r.matrices.setInputValue(Ji),r.uvDecodeMatrix.setInputValue&&r.uvDecodeMatrix.setInputValue(S.mat),i in e||(e[i]=[null,null,null]);const c=e[i],p=t?t.vertices?0:1:2;if(!c[p]){const e=h.createVertexArray();h.bindVertexArray(e);const s=(e,t)=>{e&&e.setInputValue&&t&&e.setInputValue(t)},i=r.attributes;s(i.position,x),s(i.normal,T),s(i.color,B),s(i.pickColor,v),s(i.uV,S&&S.buf),s(i.metallicRoughness,w),s(i.flags,_),s(i.offset,y),i.modelMatrixCol&&i.modelMatrixCol.forEach(((e,t)=>s(e,U[t]))),i.modelNormalMatrixCol&&i.modelNormalMatrixCol.forEach(((e,t)=>s(e,P[t])));const o=function(){const e=()=>{u?h.drawArraysInstanced(h.POINTS,0,x.numItems,n.length):h.drawArrays(h.POINTS,0,x.numItems)},s=(e,t)=>{t.bindIndicesBuffer();const s=t.indicesCount,i=t.indicesType;return()=>{u?h.drawElementsInstanced(e,s,i,0,n.length):h.drawElements(e,s,i,0)}};return"points"===A?e:"lines"===A?t&&t.vertices?e:s(h.LINES,E):t&&t.vertices?e:t?C?s(h.LINES,C):()=>{}:s(h.TRIANGLES,E)}();h.bindVertexArray(null),d.push((()=>h.deleteVertexArray(e))),c[p]=()=>{h.bindVertexArray(e),o(),h.bindVertexArray(null)}}c[p]()};return{drawVertices:t({vertices:!0}),drawEdges:t({}),drawSurface:t(null)}}(),destroy:()=>{d.forEach((e=>e())),d.length=0}}}}const tr=function(e){const t={toString:()=>(t.needed=!0,e)};return t},sr=function(e,t,s){const i=e.createAttribute,r={position:i("vec3","positionA"),normal:i("vec3","normalA"),color:i("vec4","colorA"),pickColor:i("vec4","pickColor"),uV:i("vec2","uvApremul"),metallicRoughness:i("vec2","metallicRoughness"),flags:i("float","flagsA"),offset:s&&i("vec3","offset"),modelMatrixCol:t&&Yi(3).map((e=>i("vec4","modelMatrixCol"+e))),modelNormalMatrixCol:t&&t.hasModelNormalMat&&Yi(3).map((e=>i("vec4","modelNormalMatrixCol"+e)))},n=tr("aUv"),A=tr("viewNormal"),o=tr("worldNormal"),a=e.createUniform("mat3","uvDecodeMatrix"),l=()=>A.needed||o.needed,c=e.createUniformBlock("Matrices",{worldMatrix:"mat4",viewMatrix:"mat4",projMatrix:"mat4",positionsDecodeMatrix:"mat4",worldNormalMatrix:"mat4",viewNormalMatrix:"mat4"});return{dontCullOnAlphaZero:!0,clippableTest:function(){const t=e.createVarying("float","vClippable",(()=>`((int(${r.flags}) >> 16 & 0xF) == 1) ? 1.0 : 0.0`));return()=>`${t} != 0.0`}(),geometryParameters:{attributes:{color:r.color,flags:Yi(4).map((e=>({toString:()=>`(int(${r.flags}) >> ${4*e} & 0xF)`}))),metallicRoughness:r.metallicRoughness,normal:{view:A,world:o},pickColor:r.pickColor,position:{clip:"gl_Position",view:"viewPosition",world:"worldPosition"},uv:n},projMatrix:c.projMatrix,viewMatrix:c.viewMatrix},appendVertexData:t=>{n.needed&&t.push(`vec2 ${n} = (${a} * vec3(${r.uV}, 1.0)).xy;`);const s=r.modelMatrixCol&&`mat4(${r.modelMatrixCol[0]}, ${r.modelMatrixCol[1]}, ${r.modelMatrixCol[2]}, vec4(0.0,0.0,0.0,1.0))`;if(t.push(`vec4 worldPosition = ${c.worldMatrix} * (${c.positionsDecodeMatrix} * vec4(${r.position}, 1.0)${s?" * "+s:""});`),r.offset&&t.push(`worldPosition.xyz = worldPosition.xyz + ${r.offset};`),l()){const s=r.modelNormalMatrixCol&&`* mat4(${r.modelNormalMatrixCol[0]}, ${r.modelNormalMatrixCol[1]}, ${r.modelNormalMatrixCol[2]}, vec4(0.0,0.0,0.0,1.0))`;t.push(`vec4 modelNormal = vec4(${e.commonLibrary.octDecode}(${r.normal}.xy), 0.0)${s||""};`),t.push(`vec3 ${o} = (${c.worldNormalMatrix} * modelNormal).xyz;`),A.needed&&t.push(`vec3 ${A} = normalize((${c.viewNormalMatrix} * vec4(${o}, 0.0)).xyz);`)}},layerTypeInputs:{attributes:r,matrices:c,uvDecodeMatrix:a,needNormal:l}}};class ir{constructor(e){this.id=e.id,this.colorTexture=e.colorTexture,this.alphaCutoff=e.alphaCutoff,this.metallicRoughnessTexture=e.metallicRoughnessTexture,this.normalsTexture=e.normalsTexture,this.emissiveTexture=e.emissiveTexture,this.occlusionTexture=e.occlusionTexture}destroy(){}}class rr{constructor(e){this.id=e.id,this.texture=e.texture}destroy(){this.texture&&(this.texture.destroy(),this.texture=null)}}const nr={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class Ar{constructor(e,t,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=s}itemStart(e){this.itemsTotal++,!1===this.isLoading&&void 0!==this.onStart&&this.onStart(e,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(e){this.itemsLoaded++,void 0!==this.onProgress&&this.onProgress(e,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,void 0!==this.onLoad&&this.onLoad())}itemError(e){void 0!==this.onError&&this.onError(e)}resolveURL(e){return this.urlModifier?this.urlModifier(e):e}setURLModifier(e){return this.urlModifier=e,this}addHandler(e,t){return this.handlers.push(e,t),this}removeHandler(e){const t=this.handlers.indexOf(e);return-1!==t&&this.handlers.splice(t,2),this}getHandler(e){for(let t=0,s=this.handlers.length;t<s;t+=2){const s=this.handlers[t],i=this.handlers[t+1];if(s.global&&(s.lastIndex=0),s.test(e))return i}return null}}const or=new Ar;class ar{constructor(e){this.manager=void 0!==e?e:or,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const s=this;return new Promise((function(i,r){s.load(e,i,t,r)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const lr={};class cr extends ar{constructor(e){super(e)}load(e,t,s,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=nr.get(e);if(void 0!==r)return this.manager.itemStart(e),q.scheduleTask((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==lr[e])return void lr[e].push({onLoad:t,onProgress:s,onError:i});lr[e]=[],lr[e].push({onLoad:t,onProgress:s,onError:i});const n=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),A=this.mimeType,o=this.responseType;fetch(n).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body.getReader)return t;const s=lr[e],i=t.body.getReader(),r=t.headers.get("Content-Length"),n=r?parseInt(r):0,A=0!==n;let o=0;const a=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:A,loaded:o,total:n});for(let e=0,t=s.length;e<t;e++){const t=s[e];t.onProgress&&t.onProgress(i)}e.enqueue(r),t()}}))}()}});return new Response(a)}throw Error(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`)})).then((e=>{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,A)));case"json":return e.json();default:if(void 0===A)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(A),s=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(s);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{nr.add(e,t);const s=lr[e];delete lr[e];for(let e=0,i=s.length;e<i;e++){const i=s[e];i.onLoad&&i.onLoad(t)}})).catch((t=>{const s=lr[e];if(void 0===s)throw this.manager.itemError(e),t;delete lr[e];for(let e=0,i=s.length;e<i;e++){const i=s[e];i.onError&&i.onError(t)}this.manager.itemError(e)})).finally((()=>{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class hr{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const s=this.workersResolve[e];if(s&&s(t),this.queue.length){const{resolve:t,msg:s,transfer:i}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(s,i)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((s=>{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=s,this.workers[i].postMessage(e,t)):this.queue.push({resolve:s,msg:e,transfer:t})}))}destroy(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}let ur=0;class dr{constructor({viewer:e,transcoderPath:t,workerLimit:s}){this._transcoderPath=t||"https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/basis/",this._transcoderBinary=null,this._transcoderPending=null,this._workerPool=new hr,this._workerSourceURL="",s&&this._workerPool.setWorkerLimit(s);const i=e.capabilities;this._workerConfig={astcSupported:i.astcSupported,etc1Supported:i.etc1Supported,etc2Supported:i.etc2Supported,dxtSupported:i.dxtSupported,bptcSupported:i.bptcSupported,pvrtcSupported:i.pvrtcSupported},this._supportedFileTypes=["xkt2"]}_init(){if(!this._transcoderPending){const e=new cr;e.setPath(this._transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),s=new cr;s.setPath(this._transcoderPath),s.setResponseType("arraybuffer"),s.setWithCredentials(this.withCredentials);const i=s.loadAsync("basis_transcoder.wasm");this._transcoderPending=Promise.all([t,i]).then((([e,t])=>{const s=dr.BasisWorker.toString(),i=["/* constants */","let _EngineFormat = "+JSON.stringify(dr.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(dr.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(dr.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n");this._workerSourceURL=URL.createObjectURL(new Blob([i])),this._transcoderBinary=t,this._workerPool.setWorkerCreator((()=>{const e=new Worker(this._workerSourceURL),t=this._transcoderBinary.slice(0);return e.postMessage({type:"init",config:this._workerConfig,transcoderBinary:t},[t]),e}))})),ur>0&&console.warn("KTX2TextureTranscoder: Multiple active KTX2TextureTranscoder may cause performance issues. Use a single KTX2TextureTranscoder instance, or call .dispose() on old instances."),ur++}return this._transcoderPending}transcode(e,t,s={}){return new Promise(((i,r)=>{const n=s;this._init().then((()=>this._workerPool.postMessage({type:"transcode",buffers:e,taskConfig:n},e))).then((e=>{const s=e.data,{mipmaps:n,width:A,height:o,format:a,type:l,error:c,dfdTransferFn:h,dfdFlags:u}=s;if("error"===l)return r(c);t.setCompressedData({mipmaps:n,props:{format:a,minFilter:1===n.length?1006:1008,magFilter:1===n.length?1006:1008,encoding:2===h?3001:3e3,premultiplyAlpha:!!(1&u)}}),i()}))}))}destroy(){URL.revokeObjectURL(this._workerSourceURL),this._workerPool.destroy(),ur--}}dr.BasisFormat={ETC1S:0,UASTC_4x4:1},dr.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},dr.EngineFormat={RGBAFormat:1023,RGBA_ASTC_4x4_Format:37808,RGBA_BPTC_Format:36492,RGBA_ETC2_EAC_Format:37496,RGBA_PVRTC_4BPPV1_Format:35842,RGBA_S3TC_DXT5_Format:33779,RGB_ETC1_Format:36196,RGB_ETC2_Format:37492,RGB_PVRTC_4BPPV1_Format:35840,RGB_S3TC_DXT1_Format:33776},dr.BasisWorker=function(){let e,t,s;const i=_EngineFormat,r=_TranscoderFormat,n=_BasisFormat;self.addEventListener("message",(function(A){const c=A.data;switch(c.type){case"init":e=c.config,h=c.transcoderBinary,t=new Promise((e=>{s={wasmBinary:h,onRuntimeInitialized:e},BASIS(s)})).then((()=>{s.initializeBasis(),void 0===s.KTX2File&&console.warn("KTX2TextureTranscoder: Please update Basis Universal transcoder.")}));break;case"transcode":t.then((()=>{try{const{width:t,height:A,hasAlpha:h,mipmaps:u,format:d,dfdTransferFn:p,dfdFlags:f}=function(t){const A=new s.KTX2File(new Uint8Array(t));function c(){A.close(),A.delete()}if(!A.isValid())throw c(),new Error("KTX2TextureTranscoder: Invalid or unsupported .ktx2 file");const h=A.isUASTC()?n.UASTC_4x4:n.ETC1S,u=A.getWidth(),d=A.getHeight(),p=A.getLevels(),f=A.getHasAlpha(),g=A.getDFDTransferFunc(),m=A.getDFDFlags(),{transcoderFormat:_,engineFormat:b}=function(t,s,A,c){let h,u;const d=t===n.ETC1S?o:a;for(let i=0;i<d.length;i++){const r=d[i];if(e[r.if]&&(r.basisFormat.includes(t)&&!(c&&r.transcoderFormat.length<2)&&(!r.needsPowerOfTwo||l(s)&&l(A))))return h=r.transcoderFormat[c?1:0],u=r.engineFormat[c?1:0],{transcoderFormat:h,engineFormat:u}}return console.warn("KTX2TextureTranscoder: No suitable compressed texture format found. Decoding to RGBA32."),h=r.RGBA32,u=i.RGBAFormat,{transcoderFormat:h,engineFormat:u}}(h,u,d,f);if(!u||!d||!p)throw c(),new Error("KTX2TextureTranscoder: Invalid texture");if(!A.startTranscoding())throw c(),new Error("KTX2TextureTranscoder: .startTranscoding failed");const B=[];for(let e=0;e<p;e++){const t=A.getImageLevelInfo(e,0,0),s=t.origWidth,i=t.origHeight,r=new Uint8Array(A.getImageTranscodedSizeInBytes(e,0,0,_));if(!A.transcodeImage(r,e,0,0,_,0,-1,-1))throw c(),new Error("KTX2TextureTranscoder: .transcodeImage failed.");B.push({data:r,width:s,height:i})}return c(),{width:u,height:d,hasAlpha:f,mipmaps:B,format:b,dfdTransferFn:g,dfdFlags:m}}(c.buffers[0]),g=[];for(let e=0;e<u.length;++e)g.push(u[e].data.buffer);self.postMessage({type:"transcode",id:c.id,width:t,height:A,hasAlpha:h,mipmaps:u,format:d,dfdTransferFn:p,dfdFlags:f},g)}catch(e){console.error(`[KTX2TextureTranscoder.BasisWorker]: ${e}`),self.postMessage({type:"error",id:c.id,error:e.message})}}))}var h}));const A=[{if:"astcSupported",basisFormat:[n.UASTC_4x4],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.BC1,r.BC3],engineFormat:[i.RGB_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.ETC1],engineFormat:[i.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],o=A.sort((function(e,t){return e.priorityETC1S-t.priorityETC1S})),a=A.sort((function(e,t){return e.priorityUASTC-t.priorityUASTC}));function l(e){return e<=2||0==(e&e-1)&&0!==e}};const pr={};function fr(e){const t=e.scene.id;let s=pr[t];return s||(s=new dr({viewer:e}),pr[t]=s,e.scene.on("destroyed",(()=>{delete pr[t],s.destroy()}))),s}
|
|
8
8
|
/**
|
|
9
9
|
* @author https://github.com/tmarti, with support from https://tribia.com/
|
|
10
10
|
* @license MIT
|
|
@@ -39,5 +39,5 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
39
39
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
40
40
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
41
41
|
PERFORMANCE OF THIS SOFTWARE.
|
|
42
|
-
***************************************************************************** */var ku=function(e,t){return ku=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])},ku(e,t)};function Qu(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function s(){this.constructor=e}ku(e,t),e.prototype=null===t?Object.create(t):(s.prototype=t.prototype,new s)}var Ru=function(){return Ru=Object.assign||function(e){for(var t,s=1,i=arguments.length;s<i;s++)for(var r in t=arguments[s])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Ru.apply(this,arguments)};function Ou(e,t,s,i){return new(s||(s=Promise))((function(r,n){function A(e){try{a(i.next(e))}catch(e){n(e)}}function o(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(A,o)}a((i=i.apply(e,t||[])).next())}))}function Vu(e,t){var s,i,r,n,A={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return n={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function o(n){return function(o){return function(n){if(s)throw new TypeError("Generator is already executing.");for(;A;)try{if(s=1,i&&(r=2&n[0]?i.return:n[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,n[1])).done)return r;switch(i=0,r&&(n=[2&n[0],r.value]),n[0]){case 0:case 1:r=n;break;case 4:return A.label++,{value:n[1],done:!1};case 5:A.label++,i=n[1],n=[0];continue;case 7:n=A.ops.pop(),A.trys.pop();continue;default:if(!(r=A.trys,(r=r.length>0&&r[r.length-1])||6!==n[0]&&2!==n[0])){A=0;continue}if(3===n[0]&&(!r||n[1]>r[0]&&n[1]<r[3])){A.label=n[1];break}if(6===n[0]&&A.label<r[1]){A.label=r[1],r=n;break}if(r&&A.label<r[2]){A.label=r[2],A.ops.push(n);break}r[2]&&A.ops.pop(),A.trys.pop();continue}n=t.call(e,A)}catch(e){n=[6,e],i=0}finally{s=r=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,o])}}}function Lu(e,t,s){if(s||2===arguments.length)for(var i,r=0,n=t.length;r<n;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||t)}for(var Hu=function(){function e(e,t,s,i){this.left=e,this.top=t,this.width=s,this.height=i}return e.prototype.add=function(t,s,i,r){return new e(this.left+t,this.top+s,this.width+i,this.height+r)},e.fromClientRect=function(t,s){return new e(s.left+t.windowBounds.left,s.top+t.windowBounds.top,s.width,s.height)},e.fromDOMRectList=function(t,s){var i=Array.from(s).find((function(e){return 0!==e.width}));return i?new e(i.left+t.windowBounds.left,i.top+t.windowBounds.top,i.width,i.height):e.EMPTY},e.EMPTY=new e(0,0,0,0),e}(),Nu=function(e,t){return Hu.fromClientRect(e,t.getBoundingClientRect())},Gu=function(e){for(var t=[],s=0,i=e.length;s<i;){var r=e.charCodeAt(s++);if(r>=55296&&r<=56319&&s<i){var n=e.charCodeAt(s++);56320==(64512&n)?t.push(((1023&r)<<10)+(1023&n)+65536):(t.push(r),s--)}else t.push(r)}return t},ju=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(String.fromCodePoint)return String.fromCodePoint.apply(String,e);var s=e.length;if(!s)return"";for(var i=[],r=-1,n="";++r<s;){var A=e[r];A<=65535?i.push(A):(A-=65536,i.push(55296+(A>>10),A%1024+56320)),(r+1===s||i.length>16384)&&(n+=String.fromCharCode.apply(String,i),i.length=0)}return n},Wu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",zu="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Xu=0;Xu<Wu.length;Xu++)zu[Wu.charCodeAt(Xu)]=Xu;for(var Ku="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zu="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Ju=0;Ju<Ku.length;Ju++)Zu[Ku.charCodeAt(Ju)]=Ju;for(var Yu=function(e,t,s){return e.slice?e.slice(t,s):new Uint16Array(Array.prototype.slice.call(e,t,s))},$u=function(){function e(e,t,s,i,r,n){this.initialValue=e,this.errorValue=t,this.highStart=s,this.highValueIndex=i,this.index=r,this.data=n}return e.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e<this.highStart)return t=2080+(e>>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),qu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ed="undefined"==typeof Uint8Array?[]:new Uint8Array(256),td=0;td<qu.length;td++)ed[qu.charCodeAt(td)]=td;var sd=10,id=13,rd=15,nd=17,Ad=18,od=19,ad=20,ld=21,cd=22,hd=24,ud=25,dd=26,pd=27,fd=28,gd=30,md=32,_d=33,bd=34,Bd=35,yd=37,wd=38,vd=39,Cd=40,Md=42,Ed=[9001,65288],Fd=function(e,t){var s,i,r,n=function(e){var t,s,i,r,n,A=.75*e.length,o=e.length,a=0;"="===e[e.length-1]&&(A--,"="===e[e.length-2]&&A--);var l="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(A):new Array(A),c=Array.isArray(l)?l:new Uint8Array(l);for(t=0;t<o;t+=4)s=Zu[e.charCodeAt(t)],i=Zu[e.charCodeAt(t+1)],r=Zu[e.charCodeAt(t+2)],n=Zu[e.charCodeAt(t+3)],c[a++]=s<<2|i>>4,c[a++]=(15&i)<<4|r>>2,c[a++]=(3&r)<<6|63&n;return l}(e),A=Array.isArray(n)?function(e){for(var t=e.length,s=[],i=0;i<t;i+=4)s.push(e[i+3]<<24|e[i+2]<<16|e[i+1]<<8|e[i]);return s}(n):new Uint32Array(n),o=Array.isArray(n)?function(e){for(var t=e.length,s=[],i=0;i<t;i+=2)s.push(e[i+1]<<8|e[i]);return s}(n):new Uint16Array(n),a=Yu(o,12,A[4]/2),l=2===A[5]?Yu(o,(24+A[4])/2):(s=A,i=Math.ceil((24+A[4])/4),s.slice?s.slice(i,r):new Uint32Array(Array.prototype.slice.call(s,i,r)));return new $u(A[0],A[1],A[2],A[3],a,l)}("KwAAAAAAAAAACA4AUD0AADAgAAACAAAAAAAIABAAGABAAEgAUABYAGAAaABgAGgAYgBqAF8AZwBgAGgAcQB5AHUAfQCFAI0AlQCdAKIAqgCyALoAYABoAGAAaABgAGgAwgDKAGAAaADGAM4A0wDbAOEA6QDxAPkAAQEJAQ8BFwF1AH0AHAEkASwBNAE6AUIBQQFJAVEBWQFhAWgBcAF4ATAAgAGGAY4BlQGXAZ8BpwGvAbUBvQHFAc0B0wHbAeMB6wHxAfkBAQIJAvEBEQIZAiECKQIxAjgCQAJGAk4CVgJeAmQCbAJ0AnwCgQKJApECmQKgAqgCsAK4ArwCxAIwAMwC0wLbAjAA4wLrAvMC+AIAAwcDDwMwABcDHQMlAy0DNQN1AD0DQQNJA0kDSQNRA1EDVwNZA1kDdQB1AGEDdQBpA20DdQN1AHsDdQCBA4kDkQN1AHUAmQOhA3UAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AKYDrgN1AHUAtgO+A8YDzgPWAxcD3gPjA+sD8wN1AHUA+wMDBAkEdQANBBUEHQQlBCoEFwMyBDgEYABABBcDSARQBFgEYARoBDAAcAQzAXgEgASIBJAEdQCXBHUAnwSnBK4EtgS6BMIEyAR1AHUAdQB1AHUAdQCVANAEYABgAGAAYABgAGAAYABgANgEYADcBOQEYADsBPQE/AQEBQwFFAUcBSQFLAU0BWQEPAVEBUsFUwVbBWAAYgVgAGoFcgV6BYIFigWRBWAAmQWfBaYFYABgAGAAYABgAKoFYACxBbAFuQW6BcEFwQXHBcEFwQXPBdMF2wXjBeoF8gX6BQIGCgYSBhoGIgYqBjIGOgZgAD4GRgZMBmAAUwZaBmAAYABgAGAAYABgAGAAYABgAGAAYABgAGIGYABpBnAGYABgAGAAYABgAGAAYABgAGAAYAB4Bn8GhQZgAGAAYAB1AHcDFQSLBmAAYABgAJMGdQA9A3UAmwajBqsGqwaVALMGuwbDBjAAywbSBtIG1QbSBtIG0gbSBtIG0gbdBuMG6wbzBvsGAwcLBxMHAwcbByMHJwcsBywHMQcsB9IGOAdAB0gHTgfSBkgHVgfSBtIG0gbSBtIG0gbSBtIG0gbSBiwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdgAGAALAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdbB2MHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB2kH0gZwB64EdQB1AHUAdQB1AHUAdQB1AHUHfQdgAIUHjQd1AHUAlQedB2AAYAClB6sHYACzB7YHvgfGB3UAzgfWBzMB3gfmB1EB7gf1B/0HlQENAQUIDQh1ABUIHQglCBcDLQg1CD0IRQhNCEEDUwh1AHUAdQBbCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIcAh3CHoIMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIgggwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAALAcsBywHLAcsBywHLAcsBywHLAcsB4oILAcsB44I0gaWCJ4Ipgh1AHUAqgiyCHUAdQB1AHUAdQB1AHUAdQB1AHUAtwh8AXUAvwh1AMUIyQjRCNkI4AjoCHUAdQB1AO4I9gj+CAYJDgkTCS0HGwkjCYIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiAAIAAAAFAAYABgAGIAXwBgAHEAdQBFAJUAogCyAKAAYABgAEIA4ABGANMA4QDxAMEBDwE1AFwBLAE6AQEBUQF4QkhCmEKoQrhCgAHIQsAB0MLAAcABwAHAAeDC6ABoAHDCwMMAAcABwAHAAdDDGMMAAcAB6MM4wwjDWMNow3jDaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAEjDqABWw6bDqABpg6gAaABoAHcDvwOPA+gAaABfA/8DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DpcPAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcAB9cPKwkyCToJMAB1AHUAdQBCCUoJTQl1AFUJXAljCWcJawkwADAAMAAwAHMJdQB2CX4JdQCECYoJjgmWCXUAngkwAGAAYABxAHUApgn3A64JtAl1ALkJdQDACTAAMAAwADAAdQB1AHUAdQB1AHUAdQB1AHUAowYNBMUIMAAwADAAMADICcsJ0wnZCRUE4QkwAOkJ8An4CTAAMAB1AAAKvwh1AAgKDwoXCh8KdQAwACcKLgp1ADYKqAmICT4KRgowADAAdQB1AE4KMAB1AFYKdQBeCnUAZQowADAAMAAwADAAMAAwADAAMAAVBHUAbQowADAAdQC5CXUKMAAwAHwBxAijBogEMgF9CoQKiASMCpQKmgqIBKIKqgquCogEDQG2Cr4KxgrLCjAAMADTCtsKCgHjCusK8Qr5CgELMAAwADAAMAB1AIsECQsRC3UANAEZCzAAMAAwADAAMAB1ACELKQswAHUANAExCzkLdQBBC0kLMABRC1kLMAAwADAAMAAwADAAdQBhCzAAMAAwAGAAYABpC3ELdwt/CzAAMACHC4sLkwubC58Lpwt1AK4Ltgt1APsDMAAwADAAMAAwADAAMAAwAL4LwwvLC9IL1wvdCzAAMADlC+kL8Qv5C/8LSQswADAAMAAwADAAMAAwADAAMAAHDDAAMAAwADAAMAAODBYMHgx1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1ACYMMAAwADAAdQB1AHUALgx1AHUAdQB1AHUAdQA2DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AD4MdQBGDHUAdQB1AHUAdQB1AEkMdQB1AHUAdQB1AFAMMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQBYDHUAdQB1AF8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUA+wMVBGcMMAAwAHwBbwx1AHcMfwyHDI8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAYABgAJcMMAAwADAAdQB1AJ8MlQClDDAAMACtDCwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB7UMLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AA0EMAC9DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAsBywHLAcsBywHLAcsBywHLQcwAMEMyAwsBywHLAcsBywHLAcsBywHLAcsBywHzAwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1ANQM2QzhDDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMABgAGAAYABgAGAAYABgAOkMYADxDGAA+AwADQYNYABhCWAAYAAODTAAMAAwADAAFg1gAGAAHg37AzAAMAAwADAAYABgACYNYAAsDTQNPA1gAEMNPg1LDWAAYABgAGAAYABgAGAAYABgAGAAUg1aDYsGVglhDV0NcQBnDW0NdQ15DWAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAlQCBDZUAiA2PDZcNMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAnw2nDTAAMAAwADAAMAAwAHUArw23DTAAMAAwADAAMAAwADAAMAAwADAAMAB1AL8NMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQDHDTAAYABgAM8NMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAA1w11ANwNMAAwAD0B5A0wADAAMAAwADAAMADsDfQN/A0EDgwOFA4wABsOMAAwADAAMAAwADAAMAAwANIG0gbSBtIG0gbSBtIG0gYjDigOwQUuDsEFMw7SBjoO0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGQg5KDlIOVg7SBtIGXg5lDm0OdQ7SBtIGfQ6EDooOjQ6UDtIGmg6hDtIG0gaoDqwO0ga0DrwO0gZgAGAAYADEDmAAYAAkBtIGzA5gANIOYADaDokO0gbSBt8O5w7SBu8O0gb1DvwO0gZgAGAAxA7SBtIG0gbSBtIGYABgAGAAYAAED2AAsAUMD9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGFA8sBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAccD9IGLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHJA8sBywHLAcsBywHLAccDywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywPLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAc0D9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAccD9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGFA8sBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHPA/SBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gYUD0QPlQCVAJUAMAAwADAAMACVAJUAlQCVAJUAlQCVAEwPMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAA//8EAAQABAAEAAQABAAEAAQABAANAAMAAQABAAIABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQACgATABcAHgAbABoAHgAXABYAEgAeABsAGAAPABgAHABLAEsASwBLAEsASwBLAEsASwBLABgAGAAeAB4AHgATAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABYAGwASAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWAA0AEQAeAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAFAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJABYAGgAbABsAGwAeAB0AHQAeAE8AFwAeAA0AHgAeABoAGwBPAE8ADgBQAB0AHQAdAE8ATwAXAE8ATwBPABYAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAFAATwBAAE8ATwBPAEAATwBQAFAATwBQAB4AHgAeAB4AHgAeAB0AHQAdAB0AHgAdAB4ADgBQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgBQAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAkACQAJAAkACQAJAAkABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAFAAHgAeAB4AKwArAFAAUABQAFAAGABQACsAKwArACsAHgAeAFAAHgBQAFAAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUAAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAYAA0AKwArAB4AHgAbACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAB4ABAAEAB4ABAAEABMABAArACsAKwArACsAKwArACsAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAKwArACsAKwBWAFYAVgBWAB4AHgArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AGgAaABoAGAAYAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQAEwAEACsAEwATAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABLAEsASwBLAEsASwBLAEsASwBLABoAGQAZAB4AUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABMAUAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABABQAFAABAAEAB4ABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUAAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAFAABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQAUABQAB4AHgAYABMAUAArACsABAAbABsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAFAABAAEAAQABAAEAFAABAAEAAQAUAAEAAQABAAEAAQAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArACsAHgArAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAUAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEAA0ADQBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUAArACsAKwBQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABABQACsAKwArACsAKwArACsAKwAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUAAaABoAUABQAFAAUABQAEwAHgAbAFAAHgAEACsAKwAEAAQABAArAFAAUABQAFAAUABQACsAKwArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQACsAUABQACsAKwAEACsABAAEAAQABAAEACsAKwArACsABAAEACsAKwAEAAQABAArACsAKwAEACsAKwArACsAKwArACsAUABQAFAAUAArAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLAAQABABQAFAAUAAEAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAArACsAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AGwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAKwArACsAKwArAAQABAAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAAQAUAArAFAAUABQAFAAUABQACsAKwArAFAAUABQACsAUABQAFAAUAArACsAKwBQAFAAKwBQACsAUABQACsAKwArAFAAUAArACsAKwBQAFAAUAArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAAQABAAEAAQABAArACsAKwAEAAQABAArAAQABAAEAAQAKwArAFAAKwArACsAKwArACsABAArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAHgAeAB4AHgAeAB4AGwAeACsAKwArACsAKwAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAUABQAFAAKwArACsAKwArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwAOAFAAUABQAFAAUABQAFAAHgBQAAQABAAEAA4AUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAKwArAAQAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAKwArACsAKwArACsAUAArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABABQAB4AKwArACsAKwBQAFAAUAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQABoAUABQAFAAUABQAFAAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQACsAUAArACsAUABQAFAAUABQAFAAUAArACsAKwAEACsAKwArACsABAAEAAQABAAEAAQAKwAEACsABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgAqACsAKwArACsAGwBcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAeAEsASwBLAEsASwBLAEsASwBLAEsADQANACsAKwArACsAKwBcAFwAKwBcACsAXABcAFwAXABcACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAXAArAFwAXABcAFwAXABcAFwAXABcAFwAKgBcAFwAKgAqACoAKgAqACoAKgAqACoAXAArACsAXABcAFwAXABcACsAXAArACoAKgAqACoAKgAqACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwBcAFwAXABcAFAADgAOAA4ADgAeAA4ADgAJAA4ADgANAAkAEwATABMAEwATAAkAHgATAB4AHgAeAAQABAAeAB4AHgAeAB4AHgBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQAFAADQAEAB4ABAAeAAQAFgARABYAEQAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAAQABAAEAAQADQAEAAQAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAA0ADQAeAB4AHgAeAB4AHgAEAB4AHgAeAB4AHgAeACsAHgAeAA4ADgANAA4AHgAeAB4AHgAeAAkACQArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgBcAEsASwBLAEsASwBLAEsASwBLAEsADQANAB4AHgAeAB4AXABcAFwAXABcAFwAKgAqACoAKgBcAFwAXABcACoAKgAqAFwAKgAqACoAXABcACoAKgAqACoAKgAqACoAXABcAFwAKgAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqAFwAKgBLAEsASwBLAEsASwBLAEsASwBLACoAKgAqACoAKgAqAFAAUABQAFAAUABQACsAUAArACsAKwArACsAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAKwBQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsABAAEAAQAHgANAB4AHgAeAB4AHgAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUAArACsADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWABEAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQANAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAANAA0AKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUAArAAQABAArACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqAA0ADQAVAFwADQAeAA0AGwBcACoAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwAeAB4AEwATAA0ADQAOAB4AEwATAB4ABAAEAAQACQArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAHgArACsAKwATABMASwBLAEsASwBLAEsASwBLAEsASwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAXABcAFwAXABcACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAXAArACsAKwAqACoAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsAHgAeAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKwAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKwArAAQASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACoAKgAqACoAKgAqACoAXAAqACoAKgAqACoAKgArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABABQAFAAUABQAFAAUABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwANAA0AHgANAA0ADQANAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwAeAB4AHgAeAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArAA0ADQANAA0ADQBLAEsASwBLAEsASwBLAEsASwBLACsAKwArAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUAAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAAQAUABQAFAAUABQAFAABABQAFAABAAEAAQAUAArACsAKwArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAKwBQACsAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAFAAUABQACsAHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQACsAKwAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQACsAHgAeAB4AHgAeAB4AHgAOAB4AKwANAA0ADQANAA0ADQANAAkADQANAA0ACAAEAAsABAAEAA0ACQANAA0ADAAdAB0AHgAXABcAFgAXABcAFwAWABcAHQAdAB4AHgAUABQAFAANAAEAAQAEAAQABAAEAAQACQAaABoAGgAaABoAGgAaABoAHgAXABcAHQAVABUAHgAeAB4AHgAeAB4AGAAWABEAFQAVABUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ADQAeAA0ADQANAA0AHgANAA0ADQAHAB4AHgAeAB4AKwAEAAQABAAEAAQABAAEAAQABAAEAFAAUAArACsATwBQAFAAUABQAFAAHgAeAB4AFgARAE8AUABPAE8ATwBPAFAAUABQAFAAUAAeAB4AHgAWABEAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArABsAGwAbABsAGwAbABsAGgAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGgAbABsAGwAbABoAGwAbABoAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAHgAeAFAAGgAeAB0AHgBQAB4AGgAeAB4AHgAeAB4AHgAeAB4AHgBPAB4AUAAbAB4AHgBQAFAAUABQAFAAHgAeAB4AHQAdAB4AUAAeAFAAHgBQAB4AUABPAFAAUAAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAHgBQAFAAUABQAE8ATwBQAFAAUABQAFAATwBQAFAATwBQAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAFAAUABQAFAATwBPAE8ATwBPAE8ATwBPAE8ATwBQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABPAB4AHgArACsAKwArAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHQAdAB4AHgAeAB0AHQAeAB4AHQAeAB4AHgAdAB4AHQAbABsAHgAdAB4AHgAeAB4AHQAeAB4AHQAdAB0AHQAeAB4AHQAeAB0AHgAdAB0AHQAdAB0AHQAeAB0AHgAeAB4AHgAeAB0AHQAdAB0AHgAeAB4AHgAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeAB0AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAeAB0AHQAdAB0AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAWABEAHgAeAB4AHgAeAB4AHQAeAB4AHgAeAB4AHgAeACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAWABEAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAFAAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeAB4AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AHQAdAB0AHgAeAB0AHgAeAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlAB4AHQAdAB4AHgAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AJQAlAB0AHQAlAB4AJQAlACUAIAAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAeAB4AHgAeAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAdAB0AHQAeAB0AJQAdAB0AHgAdAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAdAB0AHQAdACUAHgAlACUAJQAdACUAJQAdAB0AHQAlACUAHQAdACUAHQAdACUAJQAlAB4AHQAeAB4AHgAeAB0AHQAlAB0AHQAdAB0AHQAdACUAJQAlACUAJQAdACUAJQAgACUAHQAdACUAJQAlACUAJQAlACUAJQAeAB4AHgAlACUAIAAgACAAIAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AFwAXABcAFwAXABcAHgATABMAJQAeAB4AHgAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARABYAEQAWABEAFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAEAAQABAAeAB4AKwArACsAKwArABMADQANAA0AUAATAA0AUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUAANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAA0ADQANAA0ADQANAA0ADQAeAA0AFgANAB4AHgAXABcAHgAeABcAFwAWABEAFgARABYAEQAWABEADQANAA0ADQATAFAADQANAB4ADQANAB4AHgAeAB4AHgAMAAwADQANAA0AHgANAA0AFgANAA0ADQANAA0ADQANAA0AHgANAB4ADQANAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArAA0AEQARACUAJQBHAFcAVwAWABEAFgARABYAEQAWABEAFgARACUAJQAWABEAFgARABYAEQAWABEAFQAWABEAEQAlAFcAVwBXAFcAVwBXAFcAVwBXAAQABAAEAAQABAAEACUAVwBXAFcAVwA2ACUAJQBXAFcAVwBHAEcAJQAlACUAKwBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBRAFcAUQBXAFEAVwBXAFcAVwBXAFcAUQBXAFcAVwBXAFcAVwBRAFEAKwArAAQABAAVABUARwBHAFcAFQBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBRAFcAVwBXAFcAVwBXAFEAUQBXAFcAVwBXABUAUQBHAEcAVwArACsAKwArACsAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwAlACUAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACsAKwArACsAKwArACsAKwArACsAKwArAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBPAE8ATwBPAE8ATwBPAE8AJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADQATAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABLAEsASwBLAEsASwBLAEsASwBLAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAABAAEAAQABAAeAAQABAAEAAQABAAEAAQABAAEAAQAHgBQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAeAA0ADQANAA0ADQArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAAQAUABQAFAABABQAFAAUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAeAB4AHgAeAAQAKwArACsAUABQAFAAUABQAFAAHgAeABoAHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADgAOABMAEwArACsAKwArACsAKwArACsABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUAAeAB4AHgBQAA4AUABQAAQAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAB4AWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYACsAKwArAAQAHgAeAB4AHgAeAB4ADQANAA0AHgAeAB4AHgArAFAASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArAB4AHgBcAFwAXABcAFwAKgBcAFwAXABcAFwAXABcAFwAXABcAEsASwBLAEsASwBLAEsASwBLAEsAXABcAFwAXABcACsAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAFAAUABQAAQAUABQAFAAUABQAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAHgANAA0ADQBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAKgAqACoAXABcACoAKgBcAFwAXABcAFwAKgAqAFwAKgBcACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAA0ADQBQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQADQAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAVABVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBUAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVACsAKwArACsAKwArACsAKwArACsAKwArAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAKwArACsAKwBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAKwArACsAKwAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArACsAKwArAFYABABWAFYAVgBWAFYAVgBWAFYAVgBWAB4AVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgArAFYAVgBWAFYAVgArAFYAKwBWAFYAKwBWAFYAKwBWAFYAVgBWAFYAVgBWAFYAVgBWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAEQAWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAaAB4AKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAGAARABEAGAAYABMAEwAWABEAFAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACUAJQAlACUAJQAWABEAFgARABYAEQAWABEAFgARABYAEQAlACUAFgARACUAJQAlACUAJQAlACUAEQAlABEAKwAVABUAEwATACUAFgARABYAEQAWABEAJQAlACUAJQAlACUAJQAlACsAJQAbABoAJQArACsAKwArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAcAKwATACUAJQAbABoAJQAlABYAEQAlACUAEQAlABEAJQBXAFcAVwBXAFcAVwBXAFcAVwBXABUAFQAlACUAJQATACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXABYAJQARACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAWACUAEQAlABYAEQARABYAEQARABUAVwBRAFEAUQBRAFEAUQBRAFEAUQBRAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcARwArACsAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXACsAKwBXAFcAVwBXAFcAVwArACsAVwBXAFcAKwArACsAGgAbACUAJQAlABsAGwArAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAAQAB0AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsADQANAA0AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAA0AUABQAFAAUAArACsAKwArAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwBQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAUABQAFAAUABQAAQABAAEACsABAAEACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAKwBQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAA0ADQANAA0ADQANAA0ADQAeACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAArACsAKwArAFAAUABQAFAAUAANAA0ADQANAA0ADQAUACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsADQANAA0ADQANAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArAAQABAANACsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAB4AHgAeAB4AHgArACsAKwArACsAKwAEAAQABAAEAAQABAAEAA0ADQAeAB4AHgAeAB4AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsASwBLAEsASwBLAEsASwBLAEsASwANAA0ADQANAFAABAAEAFAAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAeAA4AUAArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAADQANAB4ADQAEAAQABAAEAB4ABAAEAEsASwBLAEsASwBLAEsASwBLAEsAUAAOAFAADQANAA0AKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAA0AHgANAA0AHgAEACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAA0AKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsABAAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAUAArACsAKwArACsAKwAEACsAKwArACsAKwBQAFAAUABQAFAABAAEACsAKwAEAAQABAAEAAQABAAEACsAKwArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABABQAFAAUABQAA0ADQANAA0AHgBLAEsASwBLAEsASwBLAEsASwBLAA0ADQArAB4ABABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUAAeAFAAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABAAEAAQADgANAA0AEwATAB4AHgAeAA0ADQANAA0ADQANAA0ADQANAA0ADQANAA0ADQANAFAAUABQAFAABAAEACsAKwAEAA0ADQAeAFAAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKwArACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBcAFwADQANAA0AKgBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQAKwAEAAQAKwArAAQABAAEAAQAUAAEAFAABAAEAA0ADQANACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABABQAA4AUAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAOAB4ADQANAA0ADQAOAB4ABAArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAA0ADQANAFAADgAOAA4ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAFAADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAOABMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAArACsAKwAEACsABAAEACsABAAEAAQABAAEAAQABABQAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAaABoAGgAaAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABIAEgAQwBDAEMAUABQAFAAUABDAFAAUABQAEgAQwBIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABDAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAJAAkACQAJAAkACQAJABYAEQArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwANAA0AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAANACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQANAB4AHgAeAB4AHgAeAFAAUABQAFAADQAeACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAA0AHgAeACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAARwBHABUARwAJACsAKwArACsAKwArACsAKwArACsAKwAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUQBRAFEAKwArACsAKwArACsAKwArACsAKwArACsAKwBRAFEAUQBRACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAHgAEAAQADQAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQABAAEAAQABAAeAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQAHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAKwArAFAAKwArAFAAUAArACsAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUAArAFAAUABQAFAAUABQAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAHgAeAFAAUABQAFAAUAArAFAAKwArACsAUABQAFAAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeACsAKwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4ABAAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAHgAeAA0ADQANAA0AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArAAQABAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwBQAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArABsAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAB4AHgAeAB4ABAAEAAQABAAEAAQABABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArABYAFgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAGgBQAFAAUAAaAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUAArACsAKwArACsAKwBQACsAKwArACsAUAArAFAAKwBQACsAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUAArAFAAKwBQACsAUAArAFAAUAArAFAAKwArAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAKwBQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AJQAlACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeACUAJQAlAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAlACUAJQAlACUAHgAlACUAJQAlACUAIAAgACAAJQAlACAAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACEAIQAhACEAIQAlACUAIAAgACUAJQAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAIAAlACUAJQAlACAAIAAgACUAIAAgACAAJQAlACUAJQAlACUAJQAgACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAlAB4AJQAeACUAJQAlACUAJQAgACUAJQAlACUAHgAlAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACAAIAAgACUAJQAlACAAIAAgACAAIAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABcAFwAXABUAFQAVAB4AHgAeAB4AJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAgACUAJQAgACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAIAAgACUAJQAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACAAIAAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACAAIAAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAA=="),xd=[gd,36],Ud=[1,2,3,5],Id=[sd,8],Td=[pd,dd],Pd=Ud.concat(Id),Sd=[wd,vd,Cd,bd,Bd],Dd=[rd,id],kd=function(e,t,s,i){var r=i[s];if(Array.isArray(e)?-1!==e.indexOf(r):e===r)for(var n=s;n<=i.length;){if((a=i[++n])===t)return!0;if(a!==sd)break}if(r===sd)for(n=s;n>0;){var A=i[--n];if(Array.isArray(e)?-1!==e.indexOf(A):e===A)for(var o=s;o<=i.length;){var a;if((a=i[++o])===t)return!0;if(a!==sd)break}if(A!==sd)break}return!1},Qd=function(e,t){for(var s=e;s>=0;){var i=t[s];if(i!==sd)return i;s--}return 0},Rd=function(e,t,s,i,r){if(0===s[i])return"×";var n=i-1;if(Array.isArray(r)&&!0===r[n])return"×";var A=n-1,o=n+1,a=t[n],l=A>=0?t[A]:0,c=t[o];if(2===a&&3===c)return"×";if(-1!==Ud.indexOf(a))return"!";if(-1!==Ud.indexOf(c))return"×";if(-1!==Id.indexOf(c))return"×";if(8===Qd(n,t))return"÷";if(11===Fd.get(e[n]))return"×";if((a===md||a===_d)&&11===Fd.get(e[o]))return"×";if(7===a||7===c)return"×";if(9===a)return"×";if(-1===[sd,id,rd].indexOf(a)&&9===c)return"×";if(-1!==[nd,Ad,od,hd,fd].indexOf(c))return"×";if(Qd(n,t)===cd)return"×";if(kd(23,cd,n,t))return"×";if(kd([nd,Ad],ld,n,t))return"×";if(kd(12,12,n,t))return"×";if(a===sd)return"÷";if(23===a||23===c)return"×";if(16===c||16===a)return"÷";if(-1!==[id,rd,ld].indexOf(c)||14===a)return"×";if(36===l&&-1!==Dd.indexOf(a))return"×";if(a===fd&&36===c)return"×";if(c===ad)return"×";if(-1!==xd.indexOf(c)&&a===ud||-1!==xd.indexOf(a)&&c===ud)return"×";if(a===pd&&-1!==[yd,md,_d].indexOf(c)||-1!==[yd,md,_d].indexOf(a)&&c===dd)return"×";if(-1!==xd.indexOf(a)&&-1!==Td.indexOf(c)||-1!==Td.indexOf(a)&&-1!==xd.indexOf(c))return"×";if(-1!==[pd,dd].indexOf(a)&&(c===ud||-1!==[cd,rd].indexOf(c)&&t[o+1]===ud)||-1!==[cd,rd].indexOf(a)&&c===ud||a===ud&&-1!==[ud,fd,hd].indexOf(c))return"×";if(-1!==[ud,fd,hd,nd,Ad].indexOf(c))for(var h=n;h>=0;){if((u=t[h])===ud)return"×";if(-1===[fd,hd].indexOf(u))break;h--}if(-1!==[pd,dd].indexOf(c))for(h=-1!==[nd,Ad].indexOf(a)?A:n;h>=0;){var u;if((u=t[h])===ud)return"×";if(-1===[fd,hd].indexOf(u))break;h--}if(wd===a&&-1!==[wd,vd,bd,Bd].indexOf(c)||-1!==[vd,bd].indexOf(a)&&-1!==[vd,Cd].indexOf(c)||-1!==[Cd,Bd].indexOf(a)&&c===Cd)return"×";if(-1!==Sd.indexOf(a)&&-1!==[ad,dd].indexOf(c)||-1!==Sd.indexOf(c)&&a===pd)return"×";if(-1!==xd.indexOf(a)&&-1!==xd.indexOf(c))return"×";if(a===hd&&-1!==xd.indexOf(c))return"×";if(-1!==xd.concat(ud).indexOf(a)&&c===cd&&-1===Ed.indexOf(e[o])||-1!==xd.concat(ud).indexOf(c)&&a===Ad)return"×";if(41===a&&41===c){for(var d=s[n],p=1;d>0&&41===t[--d];)p++;if(p%2!=0)return"×"}return a===md&&c===_d?"×":"÷"},Od=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var s=function(e,t){void 0===t&&(t="strict");var s=[],i=[],r=[];return e.forEach((function(e,n){var A=Fd.get(e);if(A>50?(r.push(!0),A-=50):r.push(!1),-1!==["normal","auto","loose"].indexOf(t)&&-1!==[8208,8211,12316,12448].indexOf(e))return i.push(n),s.push(16);if(4===A||11===A){if(0===n)return i.push(n),s.push(gd);var o=s[n-1];return-1===Pd.indexOf(o)?(i.push(i[n-1]),s.push(o)):(i.push(n),s.push(gd))}return i.push(n),31===A?s.push("strict"===t?ld:yd):A===Md||29===A?s.push(gd):43===A?e>=131072&&e<=196605||e>=196608&&e<=262141?s.push(yd):s.push(gd):void s.push(A)})),[i,s,r]}(e,t.lineBreak),i=s[0],r=s[1],n=s[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map((function(e){return-1!==[ud,gd,Md].indexOf(e)?yd:e})));var A="keep-all"===t.wordBreak?n.map((function(t,s){return t&&e[s]>=19968&&e[s]<=40959})):void 0;return[i,r,A]},Vd=function(){function e(e,t,s,i){this.codePoints=e,this.required="!"===t,this.start=s,this.end=i}return e.prototype.slice=function(){return ju.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),Ld=function(e){return e>=48&&e<=57},Hd=function(e){return Ld(e)||e>=65&&e<=70||e>=97&&e<=102},Nd=function(e){return 10===e||9===e||32===e},Gd=function(e){return function(e){return function(e){return e>=97&&e<=122}(e)||function(e){return e>=65&&e<=90}(e)}(e)||function(e){return e>=128}(e)||95===e},jd=function(e){return Gd(e)||Ld(e)||45===e},Wd=function(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e},zd=function(e,t){return 92===e&&10!==t},Xd=function(e,t,s){return 45===e?Gd(t)||zd(t,s):!!Gd(e)||!(92!==e||!zd(e,t))},Kd=function(e,t,s){return 43===e||45===e?!!Ld(t)||46===t&&Ld(s):Ld(46===e?t:e)},Zd=function(e){var t=0,s=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(s=-1),t++);for(var i=[];Ld(e[t]);)i.push(e[t++]);var r=i.length?parseInt(ju.apply(void 0,i),10):0;46===e[t]&&t++;for(var n=[];Ld(e[t]);)n.push(e[t++]);var A=n.length,o=A?parseInt(ju.apply(void 0,n),10):0;69!==e[t]&&101!==e[t]||t++;var a=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(a=-1),t++);for(var l=[];Ld(e[t]);)l.push(e[t++]);var c=l.length?parseInt(ju.apply(void 0,l),10):0;return s*(r+o*Math.pow(10,-A))*Math.pow(10,a*c)},Jd={type:2},Yd={type:3},$d={type:4},qd={type:13},ep={type:8},tp={type:21},sp={type:9},ip={type:10},rp={type:11},np={type:12},Ap={type:14},op={type:23},ap={type:1},lp={type:25},cp={type:24},hp={type:26},up={type:27},dp={type:28},pp={type:29},fp={type:31},gp={type:32},mp=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(Gu(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==gp;)e.push(t),t=this.consumeToken();return e},e.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case 34:return this.consumeStringToken(34);case 35:var t=this.peekCodePoint(0),s=this.peekCodePoint(1),i=this.peekCodePoint(2);if(jd(t)||zd(s,i)){var r=Xd(t,s,i)?2:1;return{type:5,value:this.consumeName(),flags:r}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),qd;break;case 39:return this.consumeStringToken(39);case 40:return Jd;case 41:return Yd;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Ap;break;case 43:if(Kd(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return $d;case 45:var n=e,A=this.peekCodePoint(0),o=this.peekCodePoint(1);if(Kd(n,A,o))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(Xd(n,A,o))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(45===A&&62===o)return this.consumeCodePoint(),this.consumeCodePoint(),cp;break;case 46:if(Kd(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 47:if(42===this.peekCodePoint(0))for(this.consumeCodePoint();;){var a=this.consumeCodePoint();if(42===a&&47===(a=this.consumeCodePoint()))return this.consumeToken();if(-1===a)return this.consumeToken()}break;case 58:return hp;case 59:return up;case 60:if(33===this.peekCodePoint(0)&&45===this.peekCodePoint(1)&&45===this.peekCodePoint(2))return this.consumeCodePoint(),this.consumeCodePoint(),lp;break;case 64:var l=this.peekCodePoint(0),c=this.peekCodePoint(1),h=this.peekCodePoint(2);if(Xd(l,c,h))return{type:7,value:this.consumeName()};break;case 91:return dp;case 92:if(zd(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return pp;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),ep;break;case 123:return rp;case 125:return np;case 117:case 85:var u=this.peekCodePoint(0),d=this.peekCodePoint(1);return 43!==u||!Hd(d)&&63!==d||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),sp;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),tp;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),ip;break;case-1:return gp}return Nd(e)?(this.consumeWhiteSpace(),fp):Ld(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):Gd(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:ju(e)}},e.prototype.consumeCodePoint=function(){var e=this._value.shift();return void 0===e?-1:e},e.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},e.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},e.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();Hd(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var s=!1;63===t&&e.length<6;)e.push(t),t=this.consumeCodePoint(),s=!0;if(s)return{type:30,start:parseInt(ju.apply(void 0,e.map((function(e){return 63===e?48:e}))),16),end:parseInt(ju.apply(void 0,e.map((function(e){return 63===e?70:e}))),16)};var i=parseInt(ju.apply(void 0,e),16);if(45===this.peekCodePoint(0)&&Hd(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];Hd(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:i,end:parseInt(ju.apply(void 0,r),16)}}return{type:30,start:i,end:i}},e.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return"url"===e.toLowerCase()&&40===this.peekCodePoint(0)?(this.consumeCodePoint(),this.consumeUrlToken()):40===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},e.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),-1===this.peekCodePoint(0))return{type:22,value:""};var t=this.peekCodePoint(0);if(39===t||34===t){var s=this.consumeStringToken(this.consumeCodePoint());return 0===s.type&&(this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:s.value}):(this.consumeBadUrlRemnants(),op)}for(;;){var i=this.consumeCodePoint();if(-1===i||41===i)return{type:22,value:ju.apply(void 0,e)};if(Nd(i))return this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:ju.apply(void 0,e)}):(this.consumeBadUrlRemnants(),op);if(34===i||39===i||40===i||Wd(i))return this.consumeBadUrlRemnants(),op;if(92===i){if(!zd(i,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),op;e.push(this.consumeEscapedCodePoint())}else e.push(i)}},e.prototype.consumeWhiteSpace=function(){for(;Nd(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(41===e||-1===e)return;zd(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t="";e>0;){var s=Math.min(5e4,e);t+=ju.apply(void 0,this._value.splice(0,s)),e-=s}return this._value.shift(),t},e.prototype.consumeStringToken=function(e){for(var t="",s=0;;){var i=this._value[s];if(-1===i||void 0===i||i===e)return{type:0,value:t+=this.consumeStringSlice(s)};if(10===i)return this._value.splice(0,s),ap;if(92===i){var r=this._value[s+1];-1!==r&&void 0!==r&&(10===r?(t+=this.consumeStringSlice(s),s=-1,this._value.shift()):zd(i,r)&&(t+=this.consumeStringSlice(s),t+=ju(this.consumeEscapedCodePoint()),s=-1))}s++}},e.prototype.consumeNumber=function(){var e=[],t=4,s=this.peekCodePoint(0);for(43!==s&&45!==s||e.push(this.consumeCodePoint());Ld(this.peekCodePoint(0));)e.push(this.consumeCodePoint());s=this.peekCodePoint(0);var i=this.peekCodePoint(1);if(46===s&&Ld(i))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;Ld(this.peekCodePoint(0));)e.push(this.consumeCodePoint());s=this.peekCodePoint(0),i=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((69===s||101===s)&&((43===i||45===i)&&Ld(r)||Ld(i)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;Ld(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[Zd(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],s=e[1],i=this.peekCodePoint(0),r=this.peekCodePoint(1),n=this.peekCodePoint(2);return Xd(i,r,n)?{type:15,number:t,flags:s,unit:this.consumeName()}:37===i?(this.consumeCodePoint(),{type:16,number:t,flags:s}):{type:17,number:t,flags:s}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(Hd(e)){for(var t=ju(e);Hd(this.peekCodePoint(0))&&t.length<6;)t+=ju(this.consumeCodePoint());Nd(this.peekCodePoint(0))&&this.consumeCodePoint();var s=parseInt(t,16);return 0===s||function(e){return e>=55296&&e<=57343}(s)||s>1114111?65533:s}return-1===e?65533:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(jd(t))e+=ju(t);else{if(!zd(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=ju(this.consumeEscapedCodePoint())}}},e}(),_p=function(){function e(e){this._tokens=e}return e.create=function(t){var s=new mp;return s.write(t),new e(s.read())},e.parseValue=function(t){return e.create(t).parseComponentValue()},e.parseValues=function(t){return e.create(t).parseComponentValues()},e.prototype.parseComponentValue=function(){for(var e=this.consumeToken();31===e.type;)e=this.consumeToken();if(32===e.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do{e=this.consumeToken()}while(31===e.type);if(32===e.type)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},e.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(32===t.type)return e;e.push(t),e.push()}},e.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},e.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},s=this.consumeToken();;){if(32===s.type||Fp(s,e))return t;this.reconsumeToken(s),t.values.push(this.consumeComponentValue()),s=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var s=this.consumeToken();if(32===s.type||3===s.type)return t;this.reconsumeToken(s),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?gp:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),bp=function(e){return 15===e.type},Bp=function(e){return 17===e.type},yp=function(e){return 20===e.type},wp=function(e){return 0===e.type},vp=function(e,t){return yp(e)&&e.value===t},Cp=function(e){return 31!==e.type},Mp=function(e){return 31!==e.type&&4!==e.type},Ep=function(e){var t=[],s=[];return e.forEach((function(e){if(4===e.type){if(0===s.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(s),void(s=[])}31!==e.type&&s.push(e)})),s.length&&t.push(s),t},Fp=function(e,t){return 11===t&&12===e.type||(28===t&&29===e.type||2===t&&3===e.type)},xp=function(e){return 17===e.type||15===e.type},Up=function(e){return 16===e.type||xp(e)},Ip=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},Tp={type:17,number:0,flags:4},Pp={type:16,number:50,flags:4},Sp={type:16,number:100,flags:4},Dp=function(e,t,s){var i=e[0],r=e[1];return[kp(i,t),kp(void 0!==r?r:i,s)]},kp=function(e,t){if(16===e.type)return e.number/100*t;if(bp(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},Qp=function(e,t){if(15===t.type)switch(t.unit){case"deg":return Math.PI*t.number/180;case"grad":return Math.PI/200*t.number;case"rad":return t.number;case"turn":return 2*Math.PI*t.number}throw new Error("Unsupported angle type")},Rp=function(e){return 15===e.type&&("deg"===e.unit||"grad"===e.unit||"rad"===e.unit||"turn"===e.unit)},Op=function(e){switch(e.filter(yp).map((function(e){return e.value})).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[Tp,Tp];case"to top":case"bottom":return Vp(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[Tp,Sp];case"to right":case"left":return Vp(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[Sp,Sp];case"to bottom":case"top":return Vp(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[Sp,Tp];case"to left":case"right":return Vp(270)}return 0},Vp=function(e){return Math.PI*e/180},Lp=function(e,t){if(18===t.type){var s=Kp[t.name];if(void 0===s)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return s(e,t.values)}if(5===t.type){if(3===t.value.length){var i=t.value.substring(0,1),r=t.value.substring(1,2),n=t.value.substring(2,3);return Gp(parseInt(i+i,16),parseInt(r+r,16),parseInt(n+n,16),1)}if(4===t.value.length){i=t.value.substring(0,1),r=t.value.substring(1,2),n=t.value.substring(2,3);var A=t.value.substring(3,4);return Gp(parseInt(i+i,16),parseInt(r+r,16),parseInt(n+n,16),parseInt(A+A,16)/255)}if(6===t.value.length){i=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6);return Gp(parseInt(i,16),parseInt(r,16),parseInt(n,16),1)}if(8===t.value.length){i=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6),A=t.value.substring(6,8);return Gp(parseInt(i,16),parseInt(r,16),parseInt(n,16),parseInt(A,16)/255)}}if(20===t.type){var o=Jp[t.value.toUpperCase()];if(void 0!==o)return o}return Jp.TRANSPARENT},Hp=function(e){return 0==(255&e)},Np=function(e){var t=255&e,s=255&e>>8,i=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+i+","+s+","+t/255+")":"rgb("+r+","+i+","+s+")"},Gp=function(e,t,s,i){return(e<<24|t<<16|s<<8|Math.round(255*i)<<0)>>>0},jp=function(e,t){if(17===e.type)return e.number;if(16===e.type){var s=3===t?1:255;return 3===t?e.number/100*s:Math.round(e.number/100*s)}return 0},Wp=function(e,t){var s=t.filter(Mp);if(3===s.length){var i=s.map(jp),r=i[0],n=i[1],A=i[2];return Gp(r,n,A,1)}if(4===s.length){var o=s.map(jp),a=(r=o[0],n=o[1],A=o[2],o[3]);return Gp(r,n,A,a)}return 0};function zp(e,t,s){return s<0&&(s+=1),s>=1&&(s-=1),s<1/6?(t-e)*s*6+e:s<.5?t:s<2/3?6*(t-e)*(2/3-s)+e:e}var Xp=function(e,t){var s=t.filter(Mp),i=s[0],r=s[1],n=s[2],A=s[3],o=(17===i.type?Vp(i.number):Qp(e,i))/(2*Math.PI),a=Up(r)?r.number/100:0,l=Up(n)?n.number/100:0,c=void 0!==A&&Up(A)?kp(A,1):1;if(0===a)return Gp(255*l,255*l,255*l,1);var h=l<=.5?l*(a+1):l+a-l*a,u=2*l-h,d=zp(u,h,o+1/3),p=zp(u,h,o),f=zp(u,h,o-1/3);return Gp(255*d,255*p,255*f,c)},Kp={hsl:Xp,hsla:Xp,rgb:Wp,rgba:Wp},Zp=function(e,t){return Lp(e,_p.create(t).parseComponentValue())},Jp={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Yp={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(yp(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},$p={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},qp=function(e,t){var s=Lp(e,t[0]),i=t[1];return i&&Up(i)?{color:s,stop:i}:{color:s,stop:null}},ef=function(e,t){var s=e[0],i=e[e.length-1];null===s.stop&&(s.stop=Tp),null===i.stop&&(i.stop=Sp);for(var r=[],n=0,A=0;A<e.length;A++){var o=e[A].stop;if(null!==o){var a=kp(o,t);a>n?r.push(a):r.push(n),n=a}else r.push(null)}var l=null;for(A=0;A<r.length;A++){var c=r[A];if(null===c)null===l&&(l=A);else if(null!==l){for(var h=A-l,u=(c-r[l-1])/(h+1),d=1;d<=h;d++)r[l+d-1]=u*d;l=null}}return e.map((function(e,s){return{color:e.color,stop:Math.max(Math.min(1,r[s]/t),0)}}))},tf=function(e,t,s){var i="number"==typeof e?e:function(e,t,s){var i=t/2,r=s/2,n=kp(e[0],t)-i,A=r-kp(e[1],s);return(Math.atan2(A,n)+2*Math.PI)%(2*Math.PI)}(e,t,s),r=Math.abs(t*Math.sin(i))+Math.abs(s*Math.cos(i)),n=t/2,A=s/2,o=r/2,a=Math.sin(i-Math.PI/2)*o,l=Math.cos(i-Math.PI/2)*o;return[r,n-l,n+l,A-a,A+a]},sf=function(e,t){return Math.sqrt(e*e+t*t)},rf=function(e,t,s,i,r){return[[0,0],[0,t],[e,0],[e,t]].reduce((function(e,t){var n=t[0],A=t[1],o=sf(s-n,i-A);return(r?o<e.optimumDistance:o>e.optimumDistance)?{optimumCorner:t,optimumDistance:o}:e}),{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},nf=function(e,t){var s=Vp(180),i=[];return Ep(t).forEach((function(t,r){if(0===r){var n=t[0];if(20===n.type&&-1!==["top","left","right","bottom"].indexOf(n.value))return void(s=Op(t));if(Rp(n))return void(s=(Qp(e,n)+Vp(270))%Vp(360))}var A=qp(e,t);i.push(A)})),{angle:s,stops:i,type:1}},Af=function(e,t){var s=0,i=3,r=[],n=[];return Ep(t).forEach((function(t,A){var o=!0;if(0===A?o=t.reduce((function(e,t){if(yp(t))switch(t.value){case"center":return n.push(Pp),!1;case"top":case"left":return n.push(Tp),!1;case"right":case"bottom":return n.push(Sp),!1}else if(Up(t)||xp(t))return n.push(t),!1;return e}),o):1===A&&(o=t.reduce((function(e,t){if(yp(t))switch(t.value){case"circle":return s=0,!1;case"ellipse":return s=1,!1;case"contain":case"closest-side":return i=0,!1;case"farthest-side":return i=1,!1;case"closest-corner":return i=2,!1;case"cover":case"farthest-corner":return i=3,!1}else if(xp(t)||Up(t))return Array.isArray(i)||(i=[]),i.push(t),!1;return e}),o)),o){var a=qp(e,t);r.push(a)}})),{size:i,shape:s,stops:r,position:n,type:2}},of=function(e,t){if(22===t.type){var s={url:t.value,type:0};return e.cache.addImage(t.value),s}if(18===t.type){var i=lf[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return i(e,t.values)}throw new Error("Unsupported image type "+t.type)};var af,lf={"linear-gradient":function(e,t){var s=Vp(180),i=[];return Ep(t).forEach((function(t,r){if(0===r){var n=t[0];if(20===n.type&&"to"===n.value)return void(s=Op(t));if(Rp(n))return void(s=Qp(e,n))}var A=qp(e,t);i.push(A)})),{angle:s,stops:i,type:1}},"-moz-linear-gradient":nf,"-ms-linear-gradient":nf,"-o-linear-gradient":nf,"-webkit-linear-gradient":nf,"radial-gradient":function(e,t){var s=0,i=3,r=[],n=[];return Ep(t).forEach((function(t,A){var o=!0;if(0===A){var a=!1;o=t.reduce((function(e,t){if(a)if(yp(t))switch(t.value){case"center":return n.push(Pp),e;case"top":case"left":return n.push(Tp),e;case"right":case"bottom":return n.push(Sp),e}else(Up(t)||xp(t))&&n.push(t);else if(yp(t))switch(t.value){case"circle":return s=0,!1;case"ellipse":return s=1,!1;case"at":return a=!0,!1;case"closest-side":return i=0,!1;case"cover":case"farthest-side":return i=1,!1;case"contain":case"closest-corner":return i=2,!1;case"farthest-corner":return i=3,!1}else if(xp(t)||Up(t))return Array.isArray(i)||(i=[]),i.push(t),!1;return e}),o)}if(o){var l=qp(e,t);r.push(l)}})),{size:i,shape:s,stops:r,position:n,type:2}},"-moz-radial-gradient":Af,"-ms-radial-gradient":Af,"-o-radial-gradient":Af,"-webkit-radial-gradient":Af,"-webkit-gradient":function(e,t){var s=Vp(180),i=[],r=1;return Ep(t).forEach((function(t,s){var n=t[0];if(0===s){if(yp(n)&&"linear"===n.value)return void(r=1);if(yp(n)&&"radial"===n.value)return void(r=2)}if(18===n.type)if("from"===n.name){var A=Lp(e,n.values[0]);i.push({stop:Tp,color:A})}else if("to"===n.name){A=Lp(e,n.values[0]);i.push({stop:Sp,color:A})}else if("color-stop"===n.name){var o=n.values.filter(Mp);if(2===o.length){A=Lp(e,o[1]);var a=o[0];Bp(a)&&i.push({stop:{type:16,number:100*a.number,flags:a.flags},color:A})}}})),1===r?{angle:(s+Vp(180))%Vp(360),stops:i,type:r}:{size:3,shape:0,stops:i,position:[],type:r}}},cf={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var s=t[0];return 20===s.type&&"none"===s.value?[]:t.filter((function(e){return Mp(e)&&function(e){return!(20===e.type&&"none"===e.value||18===e.type&&!lf[e.name])}(e)})).map((function(t){return of(e,t)}))}},hf={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(yp(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},uf={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return Ep(t).map((function(e){return e.filter(Up)})).map(Ip)}},df={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return Ep(t).map((function(e){return e.filter(yp).map((function(e){return e.value})).join(" ")})).map(pf)}},pf=function(e){switch(e){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(e){e.AUTO="auto",e.CONTAIN="contain",e.COVER="cover"}(af||(af={}));var ff,gf={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return Ep(t).map((function(e){return e.filter(mf)}))}},mf=function(e){return yp(e)||Up(e)},_f=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},bf=_f("top"),Bf=_f("right"),yf=_f("bottom"),wf=_f("left"),vf=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return Ip(t.filter(Up))}}},Cf=vf("top-left"),Mf=vf("top-right"),Ef=vf("bottom-right"),Ff=vf("bottom-left"),xf=function(e){return{name:"border-"+e+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},Uf=xf("top"),If=xf("right"),Tf=xf("bottom"),Pf=xf("left"),Sf=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return bp(t)?t.number:0}}},Df=Sf("top"),kf=Sf("right"),Qf=Sf("bottom"),Rf=Sf("left"),Of={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Vf={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},Lf={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(yp).reduce((function(e,t){return e|Hf(t.value)}),0)}},Hf=function(e){switch(e){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},Nf={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},Gf={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(e,t){return 20===t.type&&"normal"===t.value?0:17===t.type||15===t.type?t.number:0}};!function(e){e.NORMAL="normal",e.STRICT="strict"}(ff||(ff={}));var jf,Wf={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?ff.STRICT:ff.NORMAL}},zf={name:"line-height",initialValue:"normal",prefix:!1,type:4},Xf=function(e,t){return yp(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:Up(e)?kp(e,t):t},Kf={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:of(e,t)}},Zf={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},Jf={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},Yf=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},$f=Yf("top"),qf=Yf("right"),eg=Yf("bottom"),tg=Yf("left"),sg={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(yp).map((function(e){switch(e.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}}))}},ig={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},rg=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},ng=rg("top"),Ag=rg("right"),og=rg("bottom"),ag=rg("left"),lg={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(e,t){switch(t){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},cg={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(e,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},hg={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&vp(t[0],"none")?[]:Ep(t).map((function(t){for(var s={color:Jp.TRANSPARENT,offsetX:Tp,offsetY:Tp,blur:Tp},i=0,r=0;r<t.length;r++){var n=t[r];xp(n)?(0===i?s.offsetX=n:1===i?s.offsetY=n:s.blur=n,i++):s.color=Lp(e,n)}return s}))}},ug={name:"text-transform",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"uppercase":return 2;case"lowercase":return 1;case"capitalize":return 3}return 0}},dg={name:"transform",initialValue:"none",prefix:!0,type:0,parse:function(e,t){if(20===t.type&&"none"===t.value)return null;if(18===t.type){var s=pg[t.name];if(void 0===s)throw new Error('Attempting to parse an unsupported transform function "'+t.name+'"');return s(t.values)}return null}},pg={matrix:function(e){var t=e.filter((function(e){return 17===e.type})).map((function(e){return e.number}));return 6===t.length?t:null},matrix3d:function(e){var t=e.filter((function(e){return 17===e.type})).map((function(e){return e.number})),s=t[0],i=t[1];t[2],t[3];var r=t[4],n=t[5];t[6],t[7],t[8],t[9],t[10],t[11];var A=t[12],o=t[13];return t[14],t[15],16===t.length?[s,i,r,n,A,o]:null}},fg={type:16,number:50,flags:4},gg=[fg,fg],mg={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(e,t){var s=t.filter(Up);return 2!==s.length?gg:[s[0],s[1]]}},_g={name:"visible",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"hidden":return 1;case"collapse":return 2;default:return 0}}};!function(e){e.NORMAL="normal",e.BREAK_ALL="break-all",e.KEEP_ALL="keep-all"}(jf||(jf={}));for(var bg={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){switch(t){case"break-all":return jf.BREAK_ALL;case"keep-all":return jf.KEEP_ALL;default:return jf.NORMAL}}},Bg={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(e,t){if(20===t.type)return{auto:!0,order:0};if(Bp(t))return{auto:!1,order:t.number};throw new Error("Invalid z-index number parsed")}},yg=function(e,t){if(15===t.type)switch(t.unit.toLowerCase()){case"s":return 1e3*t.number;case"ms":return t.number}throw new Error("Unsupported time type")},wg={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(e,t){return Bp(t)?t.number:1}},vg={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Cg={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(e,t){return t.filter(yp).map((function(e){switch(e.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0})).filter((function(e){return 0!==e}))}},Mg={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(e,t){var s=[],i=[];return t.forEach((function(e){switch(e.type){case 20:case 0:s.push(e.value);break;case 17:s.push(e.number.toString());break;case 4:i.push(s.join(" ")),s.length=0}})),s.length&&i.push(s.join(" ")),i.map((function(e){return-1===e.indexOf(" ")?e:"'"+e+"'"}))}},Eg={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},Fg={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(e,t){return Bp(t)?t.number:yp(t)&&"bold"===t.value?700:400}},xg={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return t.filter(yp).map((function(e){return e.value}))}},Ug={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){switch(t){case"oblique":return"oblique";case"italic":return"italic";default:return"normal"}}},Ig=function(e,t){return 0!=(e&t)},Tg={name:"content",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var s=t[0];return 20===s.type&&"none"===s.value?[]:t}},Pg={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:function(e,t){if(0===t.length)return null;var s=t[0];if(20===s.type&&"none"===s.value)return null;for(var i=[],r=t.filter(Cp),n=0;n<r.length;n++){var A=r[n],o=r[n+1];if(20===A.type){var a=o&&Bp(o)?o.number:1;i.push({counter:A.value,increment:a})}}return i}},Sg={name:"counter-reset",initialValue:"none",prefix:!0,type:1,parse:function(e,t){if(0===t.length)return[];for(var s=[],i=t.filter(Cp),r=0;r<i.length;r++){var n=i[r],A=i[r+1];if(yp(n)&&"none"!==n.value){var o=A&&Bp(A)?A.number:0;s.push({counter:n.value,reset:o})}}return s}},Dg={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:function(e,t){return t.filter(bp).map((function(t){return yg(e,t)}))}},kg={name:"quotes",initialValue:"none",prefix:!0,type:1,parse:function(e,t){if(0===t.length)return null;var s=t[0];if(20===s.type&&"none"===s.value)return null;var i=[],r=t.filter(wp);if(r.length%2!=0)return null;for(var n=0;n<r.length;n+=2){var A=r[n].value,o=r[n+1].value;i.push({open:A,close:o})}return i}},Qg=function(e,t,s){if(!e)return"";var i=e[Math.min(t,e.length-1)];return i?s?i.open:i.close:""},Rg={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&vp(t[0],"none")?[]:Ep(t).map((function(t){for(var s={color:255,offsetX:Tp,offsetY:Tp,blur:Tp,spread:Tp,inset:!1},i=0,r=0;r<t.length;r++){var n=t[r];vp(n,"inset")?s.inset=!0:xp(n)?(0===i?s.offsetX=n:1===i?s.offsetY=n:2===i?s.blur=n:s.spread=n,i++):s.color=Lp(e,n)}return s}))}},Og={name:"paint-order",initialValue:"normal",prefix:!1,type:1,parse:function(e,t){var s=[];return t.filter(yp).forEach((function(e){switch(e.value){case"stroke":s.push(1);break;case"fill":s.push(0);break;case"markers":s.push(2)}})),[0,1,2].forEach((function(e){-1===s.indexOf(e)&&s.push(e)})),s}},Vg={name:"-webkit-text-stroke-color",initialValue:"currentcolor",prefix:!1,type:3,format:"color"},Lg={name:"-webkit-text-stroke-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return bp(t)?t.number:0}},Hg=function(){function e(e,t){var s,i;this.animationDuration=jg(e,Dg,t.animationDuration),this.backgroundClip=jg(e,Yp,t.backgroundClip),this.backgroundColor=jg(e,$p,t.backgroundColor),this.backgroundImage=jg(e,cf,t.backgroundImage),this.backgroundOrigin=jg(e,hf,t.backgroundOrigin),this.backgroundPosition=jg(e,uf,t.backgroundPosition),this.backgroundRepeat=jg(e,df,t.backgroundRepeat),this.backgroundSize=jg(e,gf,t.backgroundSize),this.borderTopColor=jg(e,bf,t.borderTopColor),this.borderRightColor=jg(e,Bf,t.borderRightColor),this.borderBottomColor=jg(e,yf,t.borderBottomColor),this.borderLeftColor=jg(e,wf,t.borderLeftColor),this.borderTopLeftRadius=jg(e,Cf,t.borderTopLeftRadius),this.borderTopRightRadius=jg(e,Mf,t.borderTopRightRadius),this.borderBottomRightRadius=jg(e,Ef,t.borderBottomRightRadius),this.borderBottomLeftRadius=jg(e,Ff,t.borderBottomLeftRadius),this.borderTopStyle=jg(e,Uf,t.borderTopStyle),this.borderRightStyle=jg(e,If,t.borderRightStyle),this.borderBottomStyle=jg(e,Tf,t.borderBottomStyle),this.borderLeftStyle=jg(e,Pf,t.borderLeftStyle),this.borderTopWidth=jg(e,Df,t.borderTopWidth),this.borderRightWidth=jg(e,kf,t.borderRightWidth),this.borderBottomWidth=jg(e,Qf,t.borderBottomWidth),this.borderLeftWidth=jg(e,Rf,t.borderLeftWidth),this.boxShadow=jg(e,Rg,t.boxShadow),this.color=jg(e,Of,t.color),this.direction=jg(e,Vf,t.direction),this.display=jg(e,Lf,t.display),this.float=jg(e,Nf,t.cssFloat),this.fontFamily=jg(e,Mg,t.fontFamily),this.fontSize=jg(e,Eg,t.fontSize),this.fontStyle=jg(e,Ug,t.fontStyle),this.fontVariant=jg(e,xg,t.fontVariant),this.fontWeight=jg(e,Fg,t.fontWeight),this.letterSpacing=jg(e,Gf,t.letterSpacing),this.lineBreak=jg(e,Wf,t.lineBreak),this.lineHeight=jg(e,zf,t.lineHeight),this.listStyleImage=jg(e,Kf,t.listStyleImage),this.listStylePosition=jg(e,Zf,t.listStylePosition),this.listStyleType=jg(e,Jf,t.listStyleType),this.marginTop=jg(e,$f,t.marginTop),this.marginRight=jg(e,qf,t.marginRight),this.marginBottom=jg(e,eg,t.marginBottom),this.marginLeft=jg(e,tg,t.marginLeft),this.opacity=jg(e,wg,t.opacity);var r=jg(e,sg,t.overflow);this.overflowX=r[0],this.overflowY=r[r.length>1?1:0],this.overflowWrap=jg(e,ig,t.overflowWrap),this.paddingTop=jg(e,ng,t.paddingTop),this.paddingRight=jg(e,Ag,t.paddingRight),this.paddingBottom=jg(e,og,t.paddingBottom),this.paddingLeft=jg(e,ag,t.paddingLeft),this.paintOrder=jg(e,Og,t.paintOrder),this.position=jg(e,cg,t.position),this.textAlign=jg(e,lg,t.textAlign),this.textDecorationColor=jg(e,vg,null!==(s=t.textDecorationColor)&&void 0!==s?s:t.color),this.textDecorationLine=jg(e,Cg,null!==(i=t.textDecorationLine)&&void 0!==i?i:t.textDecoration),this.textShadow=jg(e,hg,t.textShadow),this.textTransform=jg(e,ug,t.textTransform),this.transform=jg(e,dg,t.transform),this.transformOrigin=jg(e,mg,t.transformOrigin),this.visibility=jg(e,_g,t.visibility),this.webkitTextStrokeColor=jg(e,Vg,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=jg(e,Lg,t.webkitTextStrokeWidth),this.wordBreak=jg(e,bg,t.wordBreak),this.zIndex=jg(e,Bg,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return Hp(this.backgroundColor)},e.prototype.isTransformed=function(){return null!==this.transform},e.prototype.isPositioned=function(){return 0!==this.position},e.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},e.prototype.isFloating=function(){return 0!==this.float},e.prototype.isInlineLevel=function(){return Ig(this.display,4)||Ig(this.display,33554432)||Ig(this.display,268435456)||Ig(this.display,536870912)||Ig(this.display,67108864)||Ig(this.display,134217728)},e}(),Ng=function(e,t){this.content=jg(e,Tg,t.content),this.quotes=jg(e,kg,t.quotes)},Gg=function(e,t){this.counterIncrement=jg(e,Pg,t.counterIncrement),this.counterReset=jg(e,Sg,t.counterReset)},jg=function(e,t,s){var i=new mp,r=null!=s?s.toString():t.initialValue;i.write(r);var n=new _p(i.read());switch(t.type){case 2:var A=n.parseComponentValue();return t.parse(e,yp(A)?A.value:t.initialValue);case 0:return t.parse(e,n.parseComponentValue());case 1:return t.parse(e,n.parseComponentValues());case 4:return n.parseComponentValue();case 3:switch(t.format){case"angle":return Qp(e,n.parseComponentValue());case"color":return Lp(e,n.parseComponentValue());case"image":return of(e,n.parseComponentValue());case"length":var o=n.parseComponentValue();return xp(o)?o:Tp;case"length-percentage":var a=n.parseComponentValue();return Up(a)?a:Tp;case"time":return yg(e,n.parseComponentValue())}}},Wg=function(e,t){var s=function(e){switch(e.getAttribute("data-html2canvas-debug")){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}}(e);return 1===s||t===s},zg=function(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,Wg(t,3),this.styles=new Hg(e,window.getComputedStyle(t,null)),zm(t)&&(this.styles.animationDuration.some((function(e){return e>0}))&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=Nu(this.context,t),Wg(t,4)&&(this.flags|=16)},Xg="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Kg="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Zg=0;Zg<Xg.length;Zg++)Kg[Xg.charCodeAt(Zg)]=Zg;for(var Jg=function(e,t,s){return e.slice?e.slice(t,s):new Uint16Array(Array.prototype.slice.call(e,t,s))},Yg=function(){function e(e,t,s,i,r,n){this.initialValue=e,this.errorValue=t,this.highStart=s,this.highValueIndex=i,this.index=r,this.data=n}return e.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e<this.highStart)return t=2080+(e>>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),$g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qg="undefined"==typeof Uint8Array?[]:new Uint8Array(256),em=0;em<$g.length;em++)qg[$g.charCodeAt(em)]=em;var tm,sm=8,im=9,rm=11,nm=12,Am=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(String.fromCodePoint)return String.fromCodePoint.apply(String,e);var s=e.length;if(!s)return"";for(var i=[],r=-1,n="";++r<s;){var A=e[r];A<=65535?i.push(A):(A-=65536,i.push(55296+(A>>10),A%1024+56320)),(r+1===s||i.length>16384)&&(n+=String.fromCharCode.apply(String,i),i.length=0)}return n},om=function(e,t){var s,i,r,n=function(e){var t,s,i,r,n,A=.75*e.length,o=e.length,a=0;"="===e[e.length-1]&&(A--,"="===e[e.length-2]&&A--);var l="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(A):new Array(A),c=Array.isArray(l)?l:new Uint8Array(l);for(t=0;t<o;t+=4)s=Kg[e.charCodeAt(t)],i=Kg[e.charCodeAt(t+1)],r=Kg[e.charCodeAt(t+2)],n=Kg[e.charCodeAt(t+3)],c[a++]=s<<2|i>>4,c[a++]=(15&i)<<4|r>>2,c[a++]=(3&r)<<6|63&n;return l}(e),A=Array.isArray(n)?function(e){for(var t=e.length,s=[],i=0;i<t;i+=4)s.push(e[i+3]<<24|e[i+2]<<16|e[i+1]<<8|e[i]);return s}(n):new Uint32Array(n),o=Array.isArray(n)?function(e){for(var t=e.length,s=[],i=0;i<t;i+=2)s.push(e[i+1]<<8|e[i]);return s}(n):new Uint16Array(n),a=Jg(o,12,A[4]/2),l=2===A[5]?Jg(o,(24+A[4])/2):(s=A,i=Math.ceil((24+A[4])/4),s.slice?s.slice(i,r):new Uint32Array(Array.prototype.slice.call(s,i,r)));return new Yg(A[0],A[1],A[2],A[3],a,l)}("AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA="),am=function(e){return om.get(e)},lm=function(e,t,s){var i=s-2,r=t[i],n=t[s-1],A=t[s];if(2===n&&3===A)return"×";if(2===n||3===n||4===n)return"÷";if(2===A||3===A||4===A)return"÷";if(n===sm&&-1!==[sm,im,rm,nm].indexOf(A))return"×";if(!(n!==rm&&n!==im||A!==im&&10!==A))return"×";if((n===nm||10===n)&&10===A)return"×";if(13===A||5===A)return"×";if(7===A)return"×";if(1===n)return"×";if(13===n&&14===A){for(;5===r;)r=t[--i];if(14===r)return"×"}if(15===n&&15===A){for(var o=0;15===r;)o++,r=t[--i];if(o%2==0)return"×"}return"÷"},cm=function(e){var t=function(e){for(var t=[],s=0,i=e.length;s<i;){var r=e.charCodeAt(s++);if(r>=55296&&r<=56319&&s<i){var n=e.charCodeAt(s++);56320==(64512&n)?t.push(((1023&r)<<10)+(1023&n)+65536):(t.push(r),s--)}else t.push(r)}return t}(e),s=t.length,i=0,r=0,n=t.map(am);return{next:function(){if(i>=s)return{done:!0,value:null};for(var e="×";i<s&&"×"===(e=lm(0,n,++i)););if("×"!==e||i===s){var A=Am.apply(null,t.slice(r,i));return r=i,{value:A,done:!1}}return{done:!0,value:null}}}},hm=function(e){return 0===e[0]&&255===e[1]&&0===e[2]&&255===e[3]},um=function(e,t,s,i,r){var n="http://www.w3.org/2000/svg",A=document.createElementNS(n,"svg"),o=document.createElementNS(n,"foreignObject");return A.setAttributeNS(null,"width",e.toString()),A.setAttributeNS(null,"height",t.toString()),o.setAttributeNS(null,"width","100%"),o.setAttributeNS(null,"height","100%"),o.setAttributeNS(null,"x",s.toString()),o.setAttributeNS(null,"y",i.toString()),o.setAttributeNS(null,"externalResourcesRequired","true"),A.appendChild(o),o.appendChild(r),A},dm=function(e){return new Promise((function(t,s){var i=new Image;i.onload=function(){return t(i)},i.onerror=s,i.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(e))}))},pm={get SUPPORT_RANGE_BOUNDS(){var e=function(e){if(e.createRange){var t=e.createRange();if(t.getBoundingClientRect){var s=e.createElement("boundtest");s.style.height="123px",s.style.display="block",e.body.appendChild(s),t.selectNode(s);var i=t.getBoundingClientRect(),r=Math.round(i.height);if(e.body.removeChild(s),123===r)return!0}}return!1}(document);return Object.defineProperty(pm,"SUPPORT_RANGE_BOUNDS",{value:e}),e},get SUPPORT_WORD_BREAKING(){var e=pm.SUPPORT_RANGE_BOUNDS&&function(e){var t=e.createElement("boundtest");t.style.width="50px",t.style.display="block",t.style.fontSize="12px",t.style.letterSpacing="0px",t.style.wordSpacing="0px",e.body.appendChild(t);var s=e.createRange();t.innerHTML="function"==typeof"".repeat?"👨".repeat(10):"";var i=t.firstChild,r=Gu(i.data).map((function(e){return ju(e)})),n=0,A={},o=r.every((function(e,t){s.setStart(i,n),s.setEnd(i,n+e.length);var r=s.getBoundingClientRect();n+=e.length;var o=r.x>A.x||r.y>A.y;return A=r,0===t||o}));return e.body.removeChild(t),o}(document);return Object.defineProperty(pm,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=function(e){var t=new Image,s=e.createElement("canvas"),i=s.getContext("2d");if(!i)return!1;t.src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";try{i.drawImage(t,0,0),s.toDataURL()}catch(e){return!1}return!0}(document);return Object.defineProperty(pm,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){var e="function"==typeof Array.from&&"function"==typeof window.fetch?function(e){var t=e.createElement("canvas"),s=100;t.width=s,t.height=s;var i=t.getContext("2d");if(!i)return Promise.reject(!1);i.fillStyle="rgb(0, 255, 0)",i.fillRect(0,0,s,s);var r=new Image,n=t.toDataURL();r.src=n;var A=um(s,s,0,0,r);return i.fillStyle="red",i.fillRect(0,0,s,s),dm(A).then((function(t){i.drawImage(t,0,0);var r=i.getImageData(0,0,s,s).data;i.fillStyle="red",i.fillRect(0,0,s,s);var A=e.createElement("div");return A.style.backgroundImage="url("+n+")",A.style.height="100px",hm(r)?dm(um(s,s,0,0,A)):Promise.reject(!1)})).then((function(e){return i.drawImage(e,0,0),hm(i.getImageData(0,0,s,s).data)})).catch((function(){return!1}))}(document):Promise.resolve(!1);return Object.defineProperty(pm,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=void 0!==(new Image).crossOrigin;return Object.defineProperty(pm,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(pm,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(pm,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(pm,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},fm=function(e,t){this.text=e,this.bounds=t},gm=function(e,t){var s=t.ownerDocument;if(s){var i=s.createElement("html2canvaswrapper");i.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(i,t);var n=Nu(e,i);return i.firstChild&&r.replaceChild(i.firstChild,i),n}}return Hu.EMPTY},mm=function(e,t,s){var i=e.ownerDocument;if(!i)throw new Error("Node has no owner document");var r=i.createRange();return r.setStart(e,t),r.setEnd(e,t+s),r},_m=function(e){if(pm.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e)).map((function(e){return e.segment}))}return function(e){for(var t,s=cm(e),i=[];!(t=s.next()).done;)t.value&&i.push(t.value.slice());return i}(e)},bm=function(e,t){return 0!==t.letterSpacing?_m(e):function(e,t){if(pm.SUPPORT_NATIVE_TEXT_SEGMENTATION){var s=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(s.segment(e)).map((function(e){return e.segment}))}return ym(e,t)}(e,t)},Bm=[32,160,4961,65792,65793,4153,4241],ym=function(e,t){for(var s,i=function(e,t){var s=Gu(e),i=Od(s,t),r=i[0],n=i[1],A=i[2],o=s.length,a=0,l=0;return{next:function(){if(l>=o)return{done:!0,value:null};for(var e="×";l<o&&"×"===(e=Rd(s,n,r,++l,A)););if("×"!==e||l===o){var t=new Vd(s,e,a,l);return a=l,{value:t,done:!1}}return{done:!0,value:null}}}}(e,{lineBreak:t.lineBreak,wordBreak:"break-word"===t.overflowWrap?"break-word":t.wordBreak}),r=[],n=function(){if(s.value){var e=s.value.slice(),t=Gu(e),i="";t.forEach((function(e){-1===Bm.indexOf(e)?i+=ju(e):(i.length&&r.push(i),r.push(ju(e)),i="")})),i.length&&r.push(i)}};!(s=i.next()).done;)n();return r},wm=function(e,t,s){this.text=vm(t.data,s.textTransform),this.textBounds=function(e,t,s,i){var r=bm(t,s),n=[],A=0;return r.forEach((function(t){if(s.textDecorationLine.length||t.trim().length>0)if(pm.SUPPORT_RANGE_BOUNDS){var r=mm(i,A,t.length).getClientRects();if(r.length>1){var o=_m(t),a=0;o.forEach((function(t){n.push(new fm(t,Hu.fromDOMRectList(e,mm(i,a+A,t.length).getClientRects()))),a+=t.length}))}else n.push(new fm(t,Hu.fromDOMRectList(e,r)))}else{var l=i.splitText(t.length);n.push(new fm(t,gm(e,i))),i=l}else pm.SUPPORT_RANGE_BOUNDS||(i=i.splitText(t.length));A+=t.length})),n}(e,this.text,s,t)},vm=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(Cm,Mm);case 2:return e.toUpperCase();default:return e}},Cm=/(^|\s|:|-|\(|\))([a-z])/g,Mm=function(e,t,s){return e.length>0?t+s.toUpperCase():e},Em=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i.src=s.currentSrc||s.src,i.intrinsicWidth=s.naturalWidth,i.intrinsicHeight=s.naturalHeight,i.context.cache.addImage(i.src),i}return Qu(t,e),t}(zg),Fm=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i.canvas=s,i.intrinsicWidth=s.width,i.intrinsicHeight=s.height,i}return Qu(t,e),t}(zg),xm=function(e){function t(t,s){var i=e.call(this,t,s)||this,r=new XMLSerializer,n=Nu(t,s);return s.setAttribute("width",n.width+"px"),s.setAttribute("height",n.height+"px"),i.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(s)),i.intrinsicWidth=s.width.baseVal.value,i.intrinsicHeight=s.height.baseVal.value,i.context.cache.addImage(i.svg),i}return Qu(t,e),t}(zg),Um=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i.value=s.value,i}return Qu(t,e),t}(zg),Im=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i.start=s.start,i.reversed="boolean"==typeof s.reversed&&!0===s.reversed,i}return Qu(t,e),t}(zg),Tm=[{type:15,flags:0,unit:"px",number:3}],Pm=[{type:16,flags:0,number:50}],Sm="password",Dm=function(e){function t(t,s){var i,r,n,A=e.call(this,t,s)||this;switch(A.type=s.type.toLowerCase(),A.checked=s.checked,A.value=0===(r=(i=s).type===Sm?new Array(i.value.length+1).join("•"):i.value).length?i.placeholder||"":r,"checkbox"!==A.type&&"radio"!==A.type||(A.styles.backgroundColor=3739148031,A.styles.borderTopColor=A.styles.borderRightColor=A.styles.borderBottomColor=A.styles.borderLeftColor=2779096575,A.styles.borderTopWidth=A.styles.borderRightWidth=A.styles.borderBottomWidth=A.styles.borderLeftWidth=1,A.styles.borderTopStyle=A.styles.borderRightStyle=A.styles.borderBottomStyle=A.styles.borderLeftStyle=1,A.styles.backgroundClip=[0],A.styles.backgroundOrigin=[0],A.bounds=(n=A.bounds).width>n.height?new Hu(n.left+(n.width-n.height)/2,n.top,n.height,n.height):n.width<n.height?new Hu(n.left,n.top+(n.height-n.width)/2,n.width,n.width):n),A.type){case"checkbox":A.styles.borderTopRightRadius=A.styles.borderTopLeftRadius=A.styles.borderBottomRightRadius=A.styles.borderBottomLeftRadius=Tm;break;case"radio":A.styles.borderTopRightRadius=A.styles.borderTopLeftRadius=A.styles.borderBottomRightRadius=A.styles.borderBottomLeftRadius=Pm}return A}return Qu(t,e),t}(zg),km=function(e){function t(t,s){var i=e.call(this,t,s)||this,r=s.options[s.selectedIndex||0];return i.value=r&&r.text||"",i}return Qu(t,e),t}(zg),Qm=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i.value=s.value,i}return Qu(t,e),t}(zg),Rm=function(e){function t(t,s){var i=e.call(this,t,s)||this;i.src=s.src,i.width=parseInt(s.width,10)||0,i.height=parseInt(s.height,10)||0,i.backgroundColor=i.styles.backgroundColor;try{if(s.contentWindow&&s.contentWindow.document&&s.contentWindow.document.documentElement){i.tree=Hm(t,s.contentWindow.document.documentElement);var r=s.contentWindow.document.documentElement?Zp(t,getComputedStyle(s.contentWindow.document.documentElement).backgroundColor):Jp.TRANSPARENT,n=s.contentWindow.document.body?Zp(t,getComputedStyle(s.contentWindow.document.body).backgroundColor):Jp.TRANSPARENT;i.backgroundColor=Hp(r)?Hp(n)?i.styles.backgroundColor:n:r}}catch(e){}return i}return Qu(t,e),t}(zg),Om=["OL","UL","MENU"],Vm=function(e,t,s,i){for(var r=t.firstChild,n=void 0;r;r=n)if(n=r.nextSibling,jm(r)&&r.data.trim().length>0)s.textNodes.push(new wm(e,r,s.styles));else if(Wm(r))if(A_(r)&&r.assignedNodes)r.assignedNodes().forEach((function(t){return Vm(e,t,s,i)}));else{var A=Lm(e,r);A.styles.isVisible()&&(Nm(r,A,i)?A.flags|=4:Gm(A.styles)&&(A.flags|=2),-1!==Om.indexOf(r.tagName)&&(A.flags|=8),s.elements.push(A),r.slot,r.shadowRoot?Vm(e,r.shadowRoot,A,i):r_(r)||Ym(r)||n_(r)||Vm(e,r,A,i))}},Lm=function(e,t){return t_(t)?new Em(e,t):qm(t)?new Fm(e,t):Ym(t)?new xm(e,t):Km(t)?new Um(e,t):Zm(t)?new Im(e,t):Jm(t)?new Dm(e,t):n_(t)?new km(e,t):r_(t)?new Qm(e,t):s_(t)?new Rm(e,t):new zg(e,t)},Hm=function(e,t){var s=Lm(e,t);return s.flags|=4,Vm(e,t,s,s),s},Nm=function(e,t,s){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||$m(e)&&s.styles.isTransparent()},Gm=function(e){return e.isPositioned()||e.isFloating()},jm=function(e){return e.nodeType===Node.TEXT_NODE},Wm=function(e){return e.nodeType===Node.ELEMENT_NODE},zm=function(e){return Wm(e)&&void 0!==e.style&&!Xm(e)},Xm=function(e){return"object"==typeof e.className},Km=function(e){return"LI"===e.tagName},Zm=function(e){return"OL"===e.tagName},Jm=function(e){return"INPUT"===e.tagName},Ym=function(e){return"svg"===e.tagName},$m=function(e){return"BODY"===e.tagName},qm=function(e){return"CANVAS"===e.tagName},e_=function(e){return"VIDEO"===e.tagName},t_=function(e){return"IMG"===e.tagName},s_=function(e){return"IFRAME"===e.tagName},i_=function(e){return"STYLE"===e.tagName},r_=function(e){return"TEXTAREA"===e.tagName},n_=function(e){return"SELECT"===e.tagName},A_=function(e){return"SLOT"===e.tagName},o_=function(e){return e.tagName.indexOf("-")>0},a_=function(){function e(){this.counters={}}return e.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},e.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},e.prototype.pop=function(e){var t=this;e.forEach((function(e){return t.counters[e].pop()}))},e.prototype.parse=function(e){var t=this,s=e.counterIncrement,i=e.counterReset,r=!0;null!==s&&s.forEach((function(e){var s=t.counters[e.counter];s&&0!==e.increment&&(r=!1,s.length||s.push(1),s[Math.max(0,s.length-1)]+=e.increment)}));var n=[];return r&&i.forEach((function(e){var s=t.counters[e.counter];n.push(e.counter),s||(s=t.counters[e.counter]=[]),s.push(e.reset)})),n},e}(),l_={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},c_={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},h_={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},u_={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},d_=function(e,t,s,i,r,n){return e<t||e>s?__(e,r,n.length>0):i.integers.reduce((function(t,s,r){for(;e>=s;)e-=s,t+=i.values[r];return t}),"")+n},p_=function(e,t,s,i){var r="";do{s||e--,r=i(e)+r,e/=t}while(e*t>=t);return r},f_=function(e,t,s,i,r){var n=s-t+1;return(e<0?"-":"")+(p_(Math.abs(e),n,i,(function(e){return ju(Math.floor(e%n)+t)}))+r)},g_=function(e,t,s){void 0===s&&(s=". ");var i=t.length;return p_(Math.abs(e),i,!1,(function(e){return t[Math.floor(e%i)]}))+s},m_=function(e,t,s,i,r,n){if(e<-9999||e>9999)return __(e,4,r.length>0);var A=Math.abs(e),o=r;if(0===A)return t[0]+o;for(var a=0;A>0&&a<=4;a++){var l=A%10;0===l&&Ig(n,1)&&""!==o?o=t[l]+o:l>1||1===l&&0===a||1===l&&1===a&&Ig(n,2)||1===l&&1===a&&Ig(n,4)&&e>100||1===l&&a>1&&Ig(n,8)?o=t[l]+(a>0?s[a-1]:"")+o:1===l&&a>0&&(o=s[a-1]+o),A=Math.floor(A/10)}return(e<0?i:"")+o},__=function(e,t,s){var i=s?". ":"",r=s?"、":"",n=s?", ":"",A=s?" ":"";switch(t){case 0:return"•"+A;case 1:return"◦"+A;case 2:return"◾"+A;case 5:var o=f_(e,48,57,!0,i);return o.length<4?"0"+o:o;case 4:return g_(e,"〇一二三四五六七八九",r);case 6:return d_(e,1,3999,l_,3,i).toLowerCase();case 7:return d_(e,1,3999,l_,3,i);case 8:return f_(e,945,969,!1,i);case 9:return f_(e,97,122,!1,i);case 10:return f_(e,65,90,!1,i);case 11:return f_(e,1632,1641,!0,i);case 12:case 49:return d_(e,1,9999,c_,3,i);case 35:return d_(e,1,9999,c_,3,i).toLowerCase();case 13:return f_(e,2534,2543,!0,i);case 14:case 30:return f_(e,6112,6121,!0,i);case 15:return g_(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return g_(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return m_(e,"零一二三四五六七八九","十百千萬","負",r,14);case 47:return m_(e,"零壹貳參肆伍陸柒捌玖","拾佰仟萬","負",r,15);case 42:return m_(e,"零一二三四五六七八九","十百千萬","负",r,14);case 41:return m_(e,"零壹贰叁肆伍陆柒捌玖","拾佰仟萬","负",r,15);case 26:return m_(e,"〇一二三四五六七八九","十百千万","マイナス",r,0);case 25:return m_(e,"零壱弐参四伍六七八九","拾百千万","マイナス",r,7);case 31:return m_(e,"영일이삼사오육칠팔구","십백천만","마이너스",n,7);case 33:return m_(e,"零一二三四五六七八九","十百千萬","마이너스",n,0);case 32:return m_(e,"零壹貳參四五六七八九","拾百千","마이너스",n,7);case 18:return f_(e,2406,2415,!0,i);case 20:return d_(e,1,19999,u_,3,i);case 21:return f_(e,2790,2799,!0,i);case 22:return f_(e,2662,2671,!0,i);case 22:return d_(e,1,10999,h_,3,i);case 23:return g_(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return g_(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return f_(e,3302,3311,!0,i);case 28:return g_(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return g_(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return f_(e,3792,3801,!0,i);case 37:return f_(e,6160,6169,!0,i);case 38:return f_(e,4160,4169,!0,i);case 39:return f_(e,2918,2927,!0,i);case 40:return f_(e,1776,1785,!0,i);case 43:return f_(e,3046,3055,!0,i);case 44:return f_(e,3174,3183,!0,i);case 45:return f_(e,3664,3673,!0,i);case 46:return f_(e,3872,3881,!0,i);default:return f_(e,48,57,!0,i)}},b_=function(){function e(e,t,s){if(this.context=e,this.options=s,this.scrolledElements=[],this.referenceElement=t,this.counters=new a_,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return e.prototype.toIFrame=function(e,t){var s=this,i=y_(e,t);if(!i.contentWindow)return Promise.reject("Unable to find iframe window");var r=e.defaultView.pageXOffset,n=e.defaultView.pageYOffset,A=i.contentWindow,o=A.document,a=C_(i).then((function(){return Ou(s,void 0,void 0,(function(){var e,s;return Vu(this,(function(r){switch(r.label){case 0:return this.scrolledElements.forEach(U_),A&&(A.scrollTo(t.left,t.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||A.scrollY===t.top&&A.scrollX===t.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(A.scrollX-t.left,A.scrollY-t.top,0,0))),e=this.options.onclone,void 0===(s=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:o.fonts&&o.fonts.ready?[4,o.fonts.ready]:[3,2];case 1:r.sent(),r.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,v_(o)]:[3,4];case 3:r.sent(),r.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then((function(){return e(o,s)})).then((function(){return i}))]:[2,i]}}))}))}));return o.open(),o.write(F_(document.doctype)+"<html></html>"),x_(this.referenceElement.ownerDocument,r,n),o.replaceChild(o.adoptNode(this.documentElement),o.documentElement),o.close(),a},e.prototype.createElementClone=function(e){if(Wg(e,2),qm(e))return this.createCanvasClone(e);if(e_(e))return this.createVideoClone(e);if(i_(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return t_(t)&&(t_(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),o_(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return E_(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var s=[].slice.call(t.cssRules,0).reduce((function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e}),""),i=e.cloneNode(!1);return i.textContent=s,i}}catch(e){if(this.context.logger.error("Unable to access cssRules property",e),"SecurityError"!==e.name)throw e}return e.cloneNode(!1)},e.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var s=e.ownerDocument.createElement("img");try{return s.src=e.toDataURL(),s}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var i=e.cloneNode(!1);try{i.width=e.width,i.height=e.height;var r=e.getContext("2d"),n=i.getContext("2d");if(n)if(!this.options.allowTaint&&r)n.putImageData(r.getImageData(0,0,e.width,e.height),0,0);else{var A=null!==(t=e.getContext("webgl2"))&&void 0!==t?t:e.getContext("webgl");if(A){var o=A.getContextAttributes();!1===(null==o?void 0:o.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}n.drawImage(e,0,0)}return i}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return i},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var s=t.getContext("2d");try{return s&&(s.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||s.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var i=e.ownerDocument.createElement("canvas");return i.width=e.offsetWidth,i.height=e.offsetHeight,i},e.prototype.appendChildNode=function(e,t,s){Wm(t)&&("SCRIPT"===t.tagName||t.hasAttribute("data-html2canvas-ignore")||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&Wm(t)&&i_(t)||e.appendChild(this.cloneNode(t,s))},e.prototype.cloneChildNodes=function(e,t,s){for(var i=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(Wm(r)&&A_(r)&&"function"==typeof r.assignedNodes){var n=r.assignedNodes();n.length&&n.forEach((function(e){return i.appendChildNode(t,e,s)}))}else this.appendChildNode(t,r,s)},e.prototype.cloneNode=function(e,t){if(jm(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var s=e.ownerDocument.defaultView;if(s&&Wm(e)&&(zm(e)||Xm(e))){var i=this.createElementClone(e);i.style.transitionProperty="none";var r=s.getComputedStyle(e),n=s.getComputedStyle(e,":before"),A=s.getComputedStyle(e,":after");this.referenceElement===e&&zm(i)&&(this.clonedReferenceElement=i),$m(i)&&P_(i);var o=this.counters.parse(new Gg(this.context,r)),a=this.resolvePseudoContent(e,i,n,tm.BEFORE);o_(e)&&(t=!0),e_(e)||this.cloneChildNodes(e,i,t),a&&i.insertBefore(a,i.firstChild);var l=this.resolvePseudoContent(e,i,A,tm.AFTER);return l&&i.appendChild(l),this.counters.pop(o),(r&&(this.options.copyStyles||Xm(e))&&!s_(e)||t)&&E_(r,i),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([i,e.scrollLeft,e.scrollTop]),(r_(e)||n_(e))&&(r_(i)||n_(i))&&(i.value=e.value),i}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,s,i){var r=this;if(s){var n=s.content,A=t.ownerDocument;if(A&&n&&"none"!==n&&"-moz-alt-content"!==n&&"none"!==s.display){this.counters.parse(new Gg(this.context,s));var o=new Ng(this.context,s),a=A.createElement("html2canvaspseudoelement");E_(s,a),o.content.forEach((function(t){if(0===t.type)a.appendChild(A.createTextNode(t.value));else if(22===t.type){var s=A.createElement("img");s.src=t.value,s.style.opacity="1",a.appendChild(s)}else if(18===t.type){if("attr"===t.name){var i=t.values.filter(yp);i.length&&a.appendChild(A.createTextNode(e.getAttribute(i[0].value)||""))}else if("counter"===t.name){var n=t.values.filter(Mp),l=n[0],c=n[1];if(l&&yp(l)){var h=r.counters.getCounterValue(l.value),u=c&&yp(c)?Jf.parse(r.context,c.value):3;a.appendChild(A.createTextNode(__(h,u,!1)))}}else if("counters"===t.name){var d=t.values.filter(Mp),p=(l=d[0],d[1]);c=d[2];if(l&&yp(l)){var f=r.counters.getCounterValues(l.value),g=c&&yp(c)?Jf.parse(r.context,c.value):3,m=p&&0===p.type?p.value:"",_=f.map((function(e){return __(e,g,!1)})).join(m);a.appendChild(A.createTextNode(_))}}}else if(20===t.type)switch(t.value){case"open-quote":a.appendChild(A.createTextNode(Qg(o.quotes,r.quoteDepth++,!0)));break;case"close-quote":a.appendChild(A.createTextNode(Qg(o.quotes,--r.quoteDepth,!1)));break;default:a.appendChild(A.createTextNode(t.value))}})),a.className=I_+" "+T_;var l=i===tm.BEFORE?" "+I_:" "+T_;return Xm(t)?t.className.baseValue+=l:t.className+=l,a}}},e.destroy=function(e){return!!e.parentNode&&(e.parentNode.removeChild(e),!0)},e}();!function(e){e[e.BEFORE=0]="BEFORE",e[e.AFTER=1]="AFTER"}(tm||(tm={}));var B_,y_=function(e,t){var s=e.createElement("iframe");return s.className="html2canvas-container",s.style.visibility="hidden",s.style.position="fixed",s.style.left="-10000px",s.style.top="0px",s.style.border="0",s.width=t.width.toString(),s.height=t.height.toString(),s.scrolling="no",s.setAttribute("data-html2canvas-ignore","true"),e.body.appendChild(s),s},w_=function(e){return new Promise((function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}))},v_=function(e){return Promise.all([].slice.call(e.images,0).map(w_))},C_=function(e){return new Promise((function(t,s){var i=e.contentWindow;if(!i)return s("No window assigned for iframe");var r=i.document;i.onload=e.onload=function(){i.onload=e.onload=null;var s=setInterval((function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(s),t(e))}),50)}}))},M_=["all","d","content"],E_=function(e,t){for(var s=e.length-1;s>=0;s--){var i=e.item(s);-1===M_.indexOf(i)&&t.style.setProperty(i,e.getPropertyValue(i))}return t},F_=function(e){var t="";return e&&(t+="<!DOCTYPE ",e.name&&(t+=e.name),e.internalSubset&&(t+=e.internalSubset),e.publicId&&(t+='"'+e.publicId+'"'),e.systemId&&(t+='"'+e.systemId+'"'),t+=">"),t},x_=function(e,t,s){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||s!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,s)},U_=function(e){var t=e[0],s=e[1],i=e[2];t.scrollLeft=s,t.scrollTop=i},I_="___html2canvas___pseudoelement_before",T_="___html2canvas___pseudoelement_after",P_=function(e){S_(e,"."+I_+':before{\n content: "" !important;\n display: none !important;\n}\n .'+T_+':after{\n content: "" !important;\n display: none !important;\n}')},S_=function(e,t){var s=e.ownerDocument;if(s){var i=s.createElement("style");i.textContent=t,e.appendChild(i)}},D_=function(){function e(){}return e.getOrigin=function(t){var s=e._link;return s?(s.href=t,s.href=s.href,s.protocol+s.hostname+s.port):"about:blank"},e.isSameOrigin=function(t){return e.getOrigin(t)===e._origin},e.setContext=function(t){e._link=t.document.createElement("a"),e._origin=e.getOrigin(t.location.href)},e._origin="about:blank",e}(),k_=function(){function e(e,t){this.context=e,this._options=t,this._cache={}}return e.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)?t:N_(e)||V_(e)?((this._cache[e]=this.loadImage(e)).catch((function(){})),t):t},e.prototype.match=function(e){return this._cache[e]},e.prototype.loadImage=function(e){return Ou(this,void 0,void 0,(function(){var t,s,i,r,n=this;return Vu(this,(function(A){switch(A.label){case 0:return t=D_.isSameOrigin(e),s=!L_(e)&&!0===this._options.useCORS&&pm.SUPPORT_CORS_IMAGES&&!t,i=!L_(e)&&!t&&!N_(e)&&"string"==typeof this._options.proxy&&pm.SUPPORT_CORS_XHR&&!s,t||!1!==this._options.allowTaint||L_(e)||N_(e)||i||s?(r=e,i?[4,this.proxy(r)]:[3,2]):[2];case 1:r=A.sent(),A.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise((function(e,t){var i=new Image;i.onload=function(){return e(i)},i.onerror=t,(H_(r)||s)&&(i.crossOrigin="anonymous"),i.src=r,!0===i.complete&&setTimeout((function(){return e(i)}),500),n._options.imageTimeout>0&&setTimeout((function(){return t("Timed out ("+n._options.imageTimeout+"ms) loading image")}),n._options.imageTimeout)}))];case 3:return[2,A.sent()]}}))}))},e.prototype.has=function(e){return void 0!==this._cache[e]},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(e){var t=this,s=this._options.proxy;if(!s)throw new Error("No proxy defined");var i=e.substring(0,256);return new Promise((function(r,n){var A=pm.SUPPORT_RESPONSE_TYPE?"blob":"text",o=new XMLHttpRequest;o.onload=function(){if(200===o.status)if("text"===A)r(o.response);else{var e=new FileReader;e.addEventListener("load",(function(){return r(e.result)}),!1),e.addEventListener("error",(function(e){return n(e)}),!1),e.readAsDataURL(o.response)}else n("Failed to proxy resource "+i+" with status code "+o.status)},o.onerror=n;var a=s.indexOf("?")>-1?"&":"?";if(o.open("GET",""+s+a+"url="+encodeURIComponent(e)+"&responseType="+A),"text"!==A&&o instanceof XMLHttpRequest&&(o.responseType=A),t._options.imageTimeout){var l=t._options.imageTimeout;o.timeout=l,o.ontimeout=function(){return n("Timed out ("+l+"ms) proxying "+i)}}o.send()}))},e}(),Q_=/^data:image\/svg\+xml/i,R_=/^data:image\/.*;base64,/i,O_=/^data:image\/.*/i,V_=function(e){return pm.SUPPORT_SVG_DRAWING||!G_(e)},L_=function(e){return O_.test(e)},H_=function(e){return R_.test(e)},N_=function(e){return"blob"===e.substr(0,4)},G_=function(e){return"svg"===e.substr(-3).toLowerCase()||Q_.test(e)},j_=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,s){return new e(this.x+t,this.y+s)},e}(),W_=function(e,t,s){return new j_(e.x+(t.x-e.x)*s,e.y+(t.y-e.y)*s)},z_=function(){function e(e,t,s,i){this.type=1,this.start=e,this.startControl=t,this.endControl=s,this.end=i}return e.prototype.subdivide=function(t,s){var i=W_(this.start,this.startControl,t),r=W_(this.startControl,this.endControl,t),n=W_(this.endControl,this.end,t),A=W_(i,r,t),o=W_(r,n,t),a=W_(A,o,t);return s?new e(this.start,i,A,a):new e(a,o,n,this.end)},e.prototype.add=function(t,s){return new e(this.start.add(t,s),this.startControl.add(t,s),this.endControl.add(t,s),this.end.add(t,s))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),X_=function(e){return 1===e.type},K_=function(e){var t=e.styles,s=e.bounds,i=Dp(t.borderTopLeftRadius,s.width,s.height),r=i[0],n=i[1],A=Dp(t.borderTopRightRadius,s.width,s.height),o=A[0],a=A[1],l=Dp(t.borderBottomRightRadius,s.width,s.height),c=l[0],h=l[1],u=Dp(t.borderBottomLeftRadius,s.width,s.height),d=u[0],p=u[1],f=[];f.push((r+o)/s.width),f.push((d+c)/s.width),f.push((n+p)/s.height),f.push((a+h)/s.height);var g=Math.max.apply(Math,f);g>1&&(r/=g,n/=g,o/=g,a/=g,c/=g,h/=g,d/=g,p/=g);var m=s.width-o,_=s.height-h,b=s.width-c,B=s.height-p,y=t.borderTopWidth,w=t.borderRightWidth,v=t.borderBottomWidth,C=t.borderLeftWidth,M=kp(t.paddingTop,e.bounds.width),E=kp(t.paddingRight,e.bounds.width),F=kp(t.paddingBottom,e.bounds.width),x=kp(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||n>0?Z_(s.left+C/3,s.top+y/3,r-C/3,n-y/3,B_.TOP_LEFT):new j_(s.left+C/3,s.top+y/3),this.topRightBorderDoubleOuterBox=r>0||n>0?Z_(s.left+m,s.top+y/3,o-w/3,a-y/3,B_.TOP_RIGHT):new j_(s.left+s.width-w/3,s.top+y/3),this.bottomRightBorderDoubleOuterBox=c>0||h>0?Z_(s.left+b,s.top+_,c-w/3,h-v/3,B_.BOTTOM_RIGHT):new j_(s.left+s.width-w/3,s.top+s.height-v/3),this.bottomLeftBorderDoubleOuterBox=d>0||p>0?Z_(s.left+C/3,s.top+B,d-C/3,p-v/3,B_.BOTTOM_LEFT):new j_(s.left+C/3,s.top+s.height-v/3),this.topLeftBorderDoubleInnerBox=r>0||n>0?Z_(s.left+2*C/3,s.top+2*y/3,r-2*C/3,n-2*y/3,B_.TOP_LEFT):new j_(s.left+2*C/3,s.top+2*y/3),this.topRightBorderDoubleInnerBox=r>0||n>0?Z_(s.left+m,s.top+2*y/3,o-2*w/3,a-2*y/3,B_.TOP_RIGHT):new j_(s.left+s.width-2*w/3,s.top+2*y/3),this.bottomRightBorderDoubleInnerBox=c>0||h>0?Z_(s.left+b,s.top+_,c-2*w/3,h-2*v/3,B_.BOTTOM_RIGHT):new j_(s.left+s.width-2*w/3,s.top+s.height-2*v/3),this.bottomLeftBorderDoubleInnerBox=d>0||p>0?Z_(s.left+2*C/3,s.top+B,d-2*C/3,p-2*v/3,B_.BOTTOM_LEFT):new j_(s.left+2*C/3,s.top+s.height-2*v/3),this.topLeftBorderStroke=r>0||n>0?Z_(s.left+C/2,s.top+y/2,r-C/2,n-y/2,B_.TOP_LEFT):new j_(s.left+C/2,s.top+y/2),this.topRightBorderStroke=r>0||n>0?Z_(s.left+m,s.top+y/2,o-w/2,a-y/2,B_.TOP_RIGHT):new j_(s.left+s.width-w/2,s.top+y/2),this.bottomRightBorderStroke=c>0||h>0?Z_(s.left+b,s.top+_,c-w/2,h-v/2,B_.BOTTOM_RIGHT):new j_(s.left+s.width-w/2,s.top+s.height-v/2),this.bottomLeftBorderStroke=d>0||p>0?Z_(s.left+C/2,s.top+B,d-C/2,p-v/2,B_.BOTTOM_LEFT):new j_(s.left+C/2,s.top+s.height-v/2),this.topLeftBorderBox=r>0||n>0?Z_(s.left,s.top,r,n,B_.TOP_LEFT):new j_(s.left,s.top),this.topRightBorderBox=o>0||a>0?Z_(s.left+m,s.top,o,a,B_.TOP_RIGHT):new j_(s.left+s.width,s.top),this.bottomRightBorderBox=c>0||h>0?Z_(s.left+b,s.top+_,c,h,B_.BOTTOM_RIGHT):new j_(s.left+s.width,s.top+s.height),this.bottomLeftBorderBox=d>0||p>0?Z_(s.left,s.top+B,d,p,B_.BOTTOM_LEFT):new j_(s.left,s.top+s.height),this.topLeftPaddingBox=r>0||n>0?Z_(s.left+C,s.top+y,Math.max(0,r-C),Math.max(0,n-y),B_.TOP_LEFT):new j_(s.left+C,s.top+y),this.topRightPaddingBox=o>0||a>0?Z_(s.left+Math.min(m,s.width-w),s.top+y,m>s.width+w?0:Math.max(0,o-w),Math.max(0,a-y),B_.TOP_RIGHT):new j_(s.left+s.width-w,s.top+y),this.bottomRightPaddingBox=c>0||h>0?Z_(s.left+Math.min(b,s.width-C),s.top+Math.min(_,s.height-v),Math.max(0,c-w),Math.max(0,h-v),B_.BOTTOM_RIGHT):new j_(s.left+s.width-w,s.top+s.height-v),this.bottomLeftPaddingBox=d>0||p>0?Z_(s.left+C,s.top+Math.min(B,s.height-v),Math.max(0,d-C),Math.max(0,p-v),B_.BOTTOM_LEFT):new j_(s.left+C,s.top+s.height-v),this.topLeftContentBox=r>0||n>0?Z_(s.left+C+x,s.top+y+M,Math.max(0,r-(C+x)),Math.max(0,n-(y+M)),B_.TOP_LEFT):new j_(s.left+C+x,s.top+y+M),this.topRightContentBox=o>0||a>0?Z_(s.left+Math.min(m,s.width+C+x),s.top+y+M,m>s.width+C+x?0:o-C+x,a-(y+M),B_.TOP_RIGHT):new j_(s.left+s.width-(w+E),s.top+y+M),this.bottomRightContentBox=c>0||h>0?Z_(s.left+Math.min(b,s.width-(C+x)),s.top+Math.min(_,s.height+y+M),Math.max(0,c-(w+E)),h-(v+F),B_.BOTTOM_RIGHT):new j_(s.left+s.width-(w+E),s.top+s.height-(v+F)),this.bottomLeftContentBox=d>0||p>0?Z_(s.left+C+x,s.top+B,Math.max(0,d-(C+x)),p-(v+F),B_.BOTTOM_LEFT):new j_(s.left+C+x,s.top+s.height-(v+F))};!function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(B_||(B_={}));var Z_=function(e,t,s,i,r){var n=(Math.sqrt(2)-1)/3*4,A=s*n,o=i*n,a=e+s,l=t+i;switch(r){case B_.TOP_LEFT:return new z_(new j_(e,l),new j_(e,l-o),new j_(a-A,t),new j_(a,t));case B_.TOP_RIGHT:return new z_(new j_(e,t),new j_(e+A,t),new j_(a,l-o),new j_(a,l));case B_.BOTTOM_RIGHT:return new z_(new j_(a,t),new j_(a,t+o),new j_(e+A,l),new j_(e,l));case B_.BOTTOM_LEFT:default:return new z_(new j_(a,l),new j_(a-A,l),new j_(e,t+o),new j_(e,t))}},J_=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},Y_=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},$_=function(e,t,s){this.offsetX=e,this.offsetY=t,this.matrix=s,this.type=0,this.target=6},q_=function(e,t){this.path=e,this.target=t,this.type=1},eb=function(e){this.opacity=e,this.type=2,this.target=6},tb=function(e){return 1===e.type},sb=function(e,t){return e.length===t.length&&e.some((function(e,s){return e===t[s]}))},ib=function(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},rb=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new K_(this.container),this.container.styles.opacity<1&&this.effects.push(new eb(this.container.styles.opacity)),null!==this.container.styles.transform){var s=this.container.bounds.left+this.container.styles.transformOrigin[0].number,i=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new $_(s,i,r))}if(0!==this.container.styles.overflowX){var n=J_(this.curves),A=Y_(this.curves);sb(n,A)?this.effects.push(new q_(n,6)):(this.effects.push(new q_(n,2)),this.effects.push(new q_(A,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),s=this.parent,i=this.effects.slice(0);s;){var r=s.effects.filter((function(e){return!tb(e)}));if(t||0!==s.container.styles.position||!s.parent){if(i.unshift.apply(i,r),t=-1===[2,3].indexOf(s.container.styles.position),0!==s.container.styles.overflowX){var n=J_(s.curves),A=Y_(s.curves);sb(n,A)||i.unshift(new q_(A,6))}}else i.unshift.apply(i,r);s=s.parent}return i.filter((function(t){return Ig(t.target,e)}))},e}(),nb=function(e,t,s,i){e.container.elements.forEach((function(r){var n=Ig(r.flags,4),A=Ig(r.flags,2),o=new rb(r,e);Ig(r.styles.display,2048)&&i.push(o);var a=Ig(r.flags,8)?[]:i;if(n||A){var l=n||r.styles.isPositioned()?s:t,c=new ib(o);if(r.styles.isPositioned()||r.styles.opacity<1||r.styles.isTransformed()){var h=r.styles.zIndex.order;if(h<0){var u=0;l.negativeZIndex.some((function(e,t){return h>e.element.container.styles.zIndex.order?(u=t,!1):u>0})),l.negativeZIndex.splice(u,0,c)}else if(h>0){var d=0;l.positiveZIndex.some((function(e,t){return h>=e.element.container.styles.zIndex.order?(d=t+1,!1):d>0})),l.positiveZIndex.splice(d,0,c)}else l.zeroOrAutoZIndexOrTransformedOrOpacity.push(c)}else r.styles.isFloating()?l.nonPositionedFloats.push(c):l.nonPositionedInlineLevel.push(c);nb(o,c,n?c:s,a)}else r.styles.isInlineLevel()?t.inlineLevel.push(o):t.nonInlineLevel.push(o),nb(o,t,s,a);Ig(r.flags,8)&&Ab(r,a)}))},Ab=function(e,t){for(var s=e instanceof Im?e.start:1,i=e instanceof Im&&e.reversed,r=0;r<t.length;r++){var n=t[r];n.container instanceof Um&&"number"==typeof n.container.value&&0!==n.container.value&&(s=n.container.value),n.listValue=__(s,n.container.styles.listStyleType,!0),s+=i?-1:1}},ob=function(e,t){switch(t){case 0:return lb(e.topLeftBorderBox,e.topLeftPaddingBox,e.topRightBorderBox,e.topRightPaddingBox);case 1:return lb(e.topRightBorderBox,e.topRightPaddingBox,e.bottomRightBorderBox,e.bottomRightPaddingBox);case 2:return lb(e.bottomRightBorderBox,e.bottomRightPaddingBox,e.bottomLeftBorderBox,e.bottomLeftPaddingBox);default:return lb(e.bottomLeftBorderBox,e.bottomLeftPaddingBox,e.topLeftBorderBox,e.topLeftPaddingBox)}},ab=function(e,t){var s=[];return X_(e)?s.push(e.subdivide(.5,!1)):s.push(e),X_(t)?s.push(t.subdivide(.5,!0)):s.push(t),s},lb=function(e,t,s,i){var r=[];return X_(e)?r.push(e.subdivide(.5,!1)):r.push(e),X_(s)?r.push(s.subdivide(.5,!0)):r.push(s),X_(i)?r.push(i.subdivide(.5,!0).reverse()):r.push(i),X_(t)?r.push(t.subdivide(.5,!1).reverse()):r.push(t),r},cb=function(e){var t=e.bounds,s=e.styles;return t.add(s.borderLeftWidth,s.borderTopWidth,-(s.borderRightWidth+s.borderLeftWidth),-(s.borderTopWidth+s.borderBottomWidth))},hb=function(e){var t=e.styles,s=e.bounds,i=kp(t.paddingLeft,s.width),r=kp(t.paddingRight,s.width),n=kp(t.paddingTop,s.width),A=kp(t.paddingBottom,s.width);return s.add(i+t.borderLeftWidth,n+t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth+i+r),-(t.borderTopWidth+t.borderBottomWidth+n+A))},ub=function(e,t,s){var i=function(e,t){return 0===e?t.bounds:2===e?hb(t):cb(t)}(gb(e.styles.backgroundOrigin,t),e),r=function(e,t){return 0===e?t.bounds:2===e?hb(t):cb(t)}(gb(e.styles.backgroundClip,t),e),n=fb(gb(e.styles.backgroundSize,t),s,i),A=n[0],o=n[1],a=Dp(gb(e.styles.backgroundPosition,t),i.width-A,i.height-o);return[mb(gb(e.styles.backgroundRepeat,t),a,n,i,r),Math.round(i.left+a[0]),Math.round(i.top+a[1]),A,o]},db=function(e){return yp(e)&&e.value===af.AUTO},pb=function(e){return"number"==typeof e},fb=function(e,t,s){var i=t[0],r=t[1],n=t[2],A=e[0],o=e[1];if(!A)return[0,0];if(Up(A)&&o&&Up(o))return[kp(A,s.width),kp(o,s.height)];var a=pb(n);if(yp(A)&&(A.value===af.CONTAIN||A.value===af.COVER))return pb(n)?s.width/s.height<n!=(A.value===af.COVER)?[s.width,s.width/n]:[s.height*n,s.height]:[s.width,s.height];var l=pb(i),c=pb(r),h=l||c;if(db(A)&&(!o||db(o)))return l&&c?[i,r]:a||h?h&&a?[l?i:r*n,c?r:i/n]:[l?i:s.width,c?r:s.height]:[s.width,s.height];if(a){var u=0,d=0;return Up(A)?u=kp(A,s.width):Up(o)&&(d=kp(o,s.height)),db(A)?u=d*n:o&&!db(o)||(d=u/n),[u,d]}var p=null,f=null;if(Up(A)?p=kp(A,s.width):o&&Up(o)&&(f=kp(o,s.height)),null===p||o&&!db(o)||(f=l&&c?p/i*r:s.height),null!==f&&db(A)&&(p=l&&c?f/r*i:s.width),null!==p&&null!==f)return[p,f];throw new Error("Unable to calculate background-size for element")},gb=function(e,t){var s=e[t];return void 0===s?e[0]:s},mb=function(e,t,s,i,r){var n=t[0],A=t[1],o=s[0],a=s[1];switch(e){case 2:return[new j_(Math.round(i.left),Math.round(i.top+A)),new j_(Math.round(i.left+i.width),Math.round(i.top+A)),new j_(Math.round(i.left+i.width),Math.round(a+i.top+A)),new j_(Math.round(i.left),Math.round(a+i.top+A))];case 3:return[new j_(Math.round(i.left+n),Math.round(i.top)),new j_(Math.round(i.left+n+o),Math.round(i.top)),new j_(Math.round(i.left+n+o),Math.round(i.height+i.top)),new j_(Math.round(i.left+n),Math.round(i.height+i.top))];case 1:return[new j_(Math.round(i.left+n),Math.round(i.top+A)),new j_(Math.round(i.left+n+o),Math.round(i.top+A)),new j_(Math.round(i.left+n+o),Math.round(i.top+A+a)),new j_(Math.round(i.left+n),Math.round(i.top+A+a))];default:return[new j_(Math.round(r.left),Math.round(r.top)),new j_(Math.round(r.left+r.width),Math.round(r.top)),new j_(Math.round(r.left+r.width),Math.round(r.height+r.top)),new j_(Math.round(r.left),Math.round(r.height+r.top))]}},_b=function(){function e(e){this._data={},this._document=e}return e.prototype.parseMetrics=function(e,t){var s=this._document.createElement("div"),i=this._document.createElement("img"),r=this._document.createElement("span"),n=this._document.body;s.style.visibility="hidden",s.style.fontFamily=e,s.style.fontSize=t,s.style.margin="0",s.style.padding="0",s.style.whiteSpace="nowrap",n.appendChild(s),i.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",i.width=1,i.height=1,i.style.margin="0",i.style.padding="0",i.style.verticalAlign="baseline",r.style.fontFamily=e,r.style.fontSize=t,r.style.margin="0",r.style.padding="0",r.appendChild(this._document.createTextNode("Hidden Text")),s.appendChild(r),s.appendChild(i);var A=i.offsetTop-r.offsetTop+2;s.removeChild(r),s.appendChild(this._document.createTextNode("Hidden Text")),s.style.lineHeight="normal",i.style.verticalAlign="super";var o=i.offsetTop-s.offsetTop+2;return n.removeChild(s),{baseline:A,middle:o}},e.prototype.getMetrics=function(e,t){var s=e+" "+t;return void 0===this._data[s]&&(this._data[s]=this.parseMetrics(e,t)),this._data[s]},e}(),bb=function(e,t){this.context=e,this.options=t},Bb=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i._activeEffects=[],i.canvas=s.canvas?s.canvas:document.createElement("canvas"),i.ctx=i.canvas.getContext("2d"),s.canvas||(i.canvas.width=Math.floor(s.width*s.scale),i.canvas.height=Math.floor(s.height*s.scale),i.canvas.style.width=s.width+"px",i.canvas.style.height=s.height+"px"),i.fontMetrics=new _b(document),i.ctx.scale(i.options.scale,i.options.scale),i.ctx.translate(-s.x,-s.y),i.ctx.textBaseline="bottom",i._activeEffects=[],i.context.logger.debug("Canvas renderer initialized ("+s.width+"x"+s.height+") with scale "+s.scale),i}return Qu(t,e),t.prototype.applyEffects=function(e){for(var t=this;this._activeEffects.length;)this.popEffect();e.forEach((function(e){return t.applyEffect(e)}))},t.prototype.applyEffect=function(e){this.ctx.save(),function(e){return 2===e.type}(e)&&(this.ctx.globalAlpha=e.opacity),function(e){return 0===e.type}(e)&&(this.ctx.translate(e.offsetX,e.offsetY),this.ctx.transform(e.matrix[0],e.matrix[1],e.matrix[2],e.matrix[3],e.matrix[4],e.matrix[5]),this.ctx.translate(-e.offsetX,-e.offsetY)),tb(e)&&(this.path(e.path),this.ctx.clip()),this._activeEffects.push(e)},t.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},t.prototype.renderStack=function(e){return Ou(this,void 0,void 0,(function(){return Vu(this,(function(t){switch(t.label){case 0:return e.element.container.styles.isVisible()?[4,this.renderStackContent(e)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.renderNode=function(e){return Ou(this,void 0,void 0,(function(){return Vu(this,(function(t){switch(t.label){case 0:return Ig(e.container.flags,16),e.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(e)]:[3,3];case 1:return t.sent(),[4,this.renderNodeContent(e)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},t.prototype.renderTextWithLetterSpacing=function(e,t,s){var i=this;0===t?this.ctx.fillText(e.text,e.bounds.left,e.bounds.top+s):_m(e.text).reduce((function(t,r){return i.ctx.fillText(r,t,e.bounds.top+s),t+i.ctx.measureText(r).width}),e.bounds.left)},t.prototype.createFontStyle=function(e){var t=e.fontVariant.filter((function(e){return"normal"===e||"small-caps"===e})).join(""),s=Mb(e.fontFamily).join(", "),i=bp(e.fontSize)?""+e.fontSize.number+e.fontSize.unit:e.fontSize.number+"px";return[[e.fontStyle,t,e.fontWeight,i,s].join(" "),s,i]},t.prototype.renderTextNode=function(e,t){return Ou(this,void 0,void 0,(function(){var s,i,r,n,A,o,a,l,c=this;return Vu(this,(function(h){return s=this.createFontStyle(t),i=s[0],r=s[1],n=s[2],this.ctx.font=i,this.ctx.direction=1===t.direction?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",A=this.fontMetrics.getMetrics(r,n),o=A.baseline,a=A.middle,l=t.paintOrder,e.textBounds.forEach((function(e){l.forEach((function(s){switch(s){case 0:c.ctx.fillStyle=Np(t.color),c.renderTextWithLetterSpacing(e,t.letterSpacing,o);var i=t.textShadow;i.length&&e.text.trim().length&&(i.slice(0).reverse().forEach((function(s){c.ctx.shadowColor=Np(s.color),c.ctx.shadowOffsetX=s.offsetX.number*c.options.scale,c.ctx.shadowOffsetY=s.offsetY.number*c.options.scale,c.ctx.shadowBlur=s.blur.number,c.renderTextWithLetterSpacing(e,t.letterSpacing,o)})),c.ctx.shadowColor="",c.ctx.shadowOffsetX=0,c.ctx.shadowOffsetY=0,c.ctx.shadowBlur=0),t.textDecorationLine.length&&(c.ctx.fillStyle=Np(t.textDecorationColor||t.color),t.textDecorationLine.forEach((function(t){switch(t){case 1:c.ctx.fillRect(e.bounds.left,Math.round(e.bounds.top+o),e.bounds.width,1);break;case 2:c.ctx.fillRect(e.bounds.left,Math.round(e.bounds.top),e.bounds.width,1);break;case 3:c.ctx.fillRect(e.bounds.left,Math.ceil(e.bounds.top+a),e.bounds.width,1)}})));break;case 1:t.webkitTextStrokeWidth&&e.text.trim().length&&(c.ctx.strokeStyle=Np(t.webkitTextStrokeColor),c.ctx.lineWidth=t.webkitTextStrokeWidth,c.ctx.lineJoin=window.chrome?"miter":"round",c.ctx.strokeText(e.text,e.bounds.left,e.bounds.top+o)),c.ctx.strokeStyle="",c.ctx.lineWidth=0,c.ctx.lineJoin="miter"}}))})),[2]}))}))},t.prototype.renderReplacedElement=function(e,t,s){if(s&&e.intrinsicWidth>0&&e.intrinsicHeight>0){var i=hb(e),r=Y_(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(s,0,0,e.intrinsicWidth,e.intrinsicHeight,i.left,i.top,i.width,i.height),this.ctx.restore()}},t.prototype.renderNodeContent=function(e){return Ou(this,void 0,void 0,(function(){var s,i,r,n,A,o,a,l,c,h,u,d,p,f,g,m,_,b;return Vu(this,(function(B){switch(B.label){case 0:this.applyEffects(e.getEffects(4)),s=e.container,i=e.curves,r=s.styles,n=0,A=s.textNodes,B.label=1;case 1:return n<A.length?(o=A[n],[4,this.renderTextNode(o,r)]):[3,4];case 2:B.sent(),B.label=3;case 3:return n++,[3,1];case 4:if(!(s instanceof Em))return[3,8];B.label=5;case 5:return B.trys.push([5,7,,8]),[4,this.context.cache.match(s.src)];case 6:return g=B.sent(),this.renderReplacedElement(s,i,g),[3,8];case 7:return B.sent(),this.context.logger.error("Error loading image "+s.src),[3,8];case 8:if(s instanceof Fm&&this.renderReplacedElement(s,i,s.canvas),!(s instanceof xm))return[3,12];B.label=9;case 9:return B.trys.push([9,11,,12]),[4,this.context.cache.match(s.svg)];case 10:return g=B.sent(),this.renderReplacedElement(s,i,g),[3,12];case 11:return B.sent(),this.context.logger.error("Error loading svg "+s.svg.substring(0,255)),[3,12];case 12:return s instanceof Rm&&s.tree?[4,new t(this.context,{scale:this.options.scale,backgroundColor:s.backgroundColor,x:0,y:0,width:s.width,height:s.height}).render(s.tree)]:[3,14];case 13:a=B.sent(),s.width&&s.height&&this.ctx.drawImage(a,0,0,s.width,s.height,s.bounds.left,s.bounds.top,s.bounds.width,s.bounds.height),B.label=14;case 14:if(s instanceof Dm&&(l=Math.min(s.bounds.width,s.bounds.height),"checkbox"===s.type?s.checked&&(this.ctx.save(),this.path([new j_(s.bounds.left+.39363*l,s.bounds.top+.79*l),new j_(s.bounds.left+.16*l,s.bounds.top+.5549*l),new j_(s.bounds.left+.27347*l,s.bounds.top+.44071*l),new j_(s.bounds.left+.39694*l,s.bounds.top+.5649*l),new j_(s.bounds.left+.72983*l,s.bounds.top+.23*l),new j_(s.bounds.left+.84*l,s.bounds.top+.34085*l),new j_(s.bounds.left+.39363*l,s.bounds.top+.79*l)]),this.ctx.fillStyle=Np(707406591),this.ctx.fill(),this.ctx.restore()):"radio"===s.type&&s.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(s.bounds.left+l/2,s.bounds.top+l/2,l/4,0,2*Math.PI,!0),this.ctx.fillStyle=Np(707406591),this.ctx.fill(),this.ctx.restore())),yb(s)&&s.value.length){switch(c=this.createFontStyle(r),_=c[0],h=c[1],u=this.fontMetrics.getMetrics(_,h).baseline,this.ctx.font=_,this.ctx.fillStyle=Np(r.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=vb(s.styles.textAlign),b=hb(s),d=0,s.styles.textAlign){case 1:d+=b.width/2;break;case 2:d+=b.width}p=b.add(d,0,0,-b.height/2+1),this.ctx.save(),this.path([new j_(b.left,b.top),new j_(b.left+b.width,b.top),new j_(b.left+b.width,b.top+b.height),new j_(b.left,b.top+b.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new fm(s.value,p),r.letterSpacing,u),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!Ig(s.styles.display,2048))return[3,20];if(null===s.styles.listStyleImage)return[3,19];if(0!==(f=s.styles.listStyleImage).type)return[3,18];g=void 0,m=f.url,B.label=15;case 15:return B.trys.push([15,17,,18]),[4,this.context.cache.match(m)];case 16:return g=B.sent(),this.ctx.drawImage(g,s.bounds.left-(g.width+10),s.bounds.top),[3,18];case 17:return B.sent(),this.context.logger.error("Error loading list-style-image "+m),[3,18];case 18:return[3,20];case 19:e.listValue&&-1!==s.styles.listStyleType&&(_=this.createFontStyle(r)[0],this.ctx.font=_,this.ctx.fillStyle=Np(r.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",b=new Hu(s.bounds.left,s.bounds.top+kp(s.styles.paddingTop,s.bounds.width),s.bounds.width,Xf(r.lineHeight,r.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new fm(e.listValue,b),r.letterSpacing,Xf(r.lineHeight,r.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"),B.label=20;case 20:return[2]}}))}))},t.prototype.renderStackContent=function(e){return Ou(this,void 0,void 0,(function(){var t,s,i,r,n,A,o,a,l,c,h,u,d,p,f;return Vu(this,(function(g){switch(g.label){case 0:return Ig(e.element.container.flags,16),[4,this.renderNodeBackgroundAndBorders(e.element)];case 1:g.sent(),t=0,s=e.negativeZIndex,g.label=2;case 2:return t<s.length?(f=s[t],[4,this.renderStack(f)]):[3,5];case 3:g.sent(),g.label=4;case 4:return t++,[3,2];case 5:return[4,this.renderNodeContent(e.element)];case 6:g.sent(),i=0,r=e.nonInlineLevel,g.label=7;case 7:return i<r.length?(f=r[i],[4,this.renderNode(f)]):[3,10];case 8:g.sent(),g.label=9;case 9:return i++,[3,7];case 10:n=0,A=e.nonPositionedFloats,g.label=11;case 11:return n<A.length?(f=A[n],[4,this.renderStack(f)]):[3,14];case 12:g.sent(),g.label=13;case 13:return n++,[3,11];case 14:o=0,a=e.nonPositionedInlineLevel,g.label=15;case 15:return o<a.length?(f=a[o],[4,this.renderStack(f)]):[3,18];case 16:g.sent(),g.label=17;case 17:return o++,[3,15];case 18:l=0,c=e.inlineLevel,g.label=19;case 19:return l<c.length?(f=c[l],[4,this.renderNode(f)]):[3,22];case 20:g.sent(),g.label=21;case 21:return l++,[3,19];case 22:h=0,u=e.zeroOrAutoZIndexOrTransformedOrOpacity,g.label=23;case 23:return h<u.length?(f=u[h],[4,this.renderStack(f)]):[3,26];case 24:g.sent(),g.label=25;case 25:return h++,[3,23];case 26:d=0,p=e.positiveZIndex,g.label=27;case 27:return d<p.length?(f=p[d],[4,this.renderStack(f)]):[3,30];case 28:g.sent(),g.label=29;case 29:return d++,[3,27];case 30:return[2]}}))}))},t.prototype.mask=function(e){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.canvas.width,0),this.ctx.lineTo(this.canvas.width,this.canvas.height),this.ctx.lineTo(0,this.canvas.height),this.ctx.lineTo(0,0),this.formatPath(e.slice(0).reverse()),this.ctx.closePath()},t.prototype.path=function(e){this.ctx.beginPath(),this.formatPath(e),this.ctx.closePath()},t.prototype.formatPath=function(e){var t=this;e.forEach((function(e,s){var i=X_(e)?e.start:e;0===s?t.ctx.moveTo(i.x,i.y):t.ctx.lineTo(i.x,i.y),X_(e)&&t.ctx.bezierCurveTo(e.startControl.x,e.startControl.y,e.endControl.x,e.endControl.y,e.end.x,e.end.y)}))},t.prototype.renderRepeat=function(e,t,s,i){this.path(e),this.ctx.fillStyle=t,this.ctx.translate(s,i),this.ctx.fill(),this.ctx.translate(-s,-i)},t.prototype.resizeImage=function(e,t,s){var i;if(e.width===t&&e.height===s)return e;var r=(null!==(i=this.canvas.ownerDocument)&&void 0!==i?i:document).createElement("canvas");return r.width=Math.max(1,t),r.height=Math.max(1,s),r.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t,s),r},t.prototype.renderBackgroundImage=function(e){return Ou(this,void 0,void 0,(function(){var t,s,i,r,n,A;return Vu(this,(function(o){switch(o.label){case 0:t=e.styles.backgroundImage.length-1,s=function(s){var r,n,A,o,a,l,c,h,u,d,p,f,g,m,_,b,B,y,w,v,C,M,E,F,x,U,I,T,P,S,D;return Vu(this,(function(k){switch(k.label){case 0:if(0!==s.type)return[3,5];r=void 0,n=s.url,k.label=1;case 1:return k.trys.push([1,3,,4]),[4,i.context.cache.match(n)];case 2:return r=k.sent(),[3,4];case 3:return k.sent(),i.context.logger.error("Error loading background-image "+n),[3,4];case 4:return r&&(A=ub(e,t,[r.width,r.height,r.width/r.height]),b=A[0],M=A[1],E=A[2],w=A[3],v=A[4],m=i.ctx.createPattern(i.resizeImage(r,w,v),"repeat"),i.renderRepeat(b,m,M,E)),[3,6];case 5:1===s.type?(o=ub(e,t,[null,null,null]),b=o[0],M=o[1],E=o[2],w=o[3],v=o[4],a=tf(s.angle,w,v),l=a[0],c=a[1],h=a[2],u=a[3],d=a[4],(p=document.createElement("canvas")).width=w,p.height=v,f=p.getContext("2d"),g=f.createLinearGradient(c,u,h,d),ef(s.stops,l).forEach((function(e){return g.addColorStop(e.stop,Np(e.color))})),f.fillStyle=g,f.fillRect(0,0,w,v),w>0&&v>0&&(m=i.ctx.createPattern(p,"repeat"),i.renderRepeat(b,m,M,E))):function(e){return 2===e.type}(s)&&(_=ub(e,t,[null,null,null]),b=_[0],B=_[1],y=_[2],w=_[3],v=_[4],C=0===s.position.length?[Pp]:s.position,M=kp(C[0],w),E=kp(C[C.length-1],v),F=function(e,t,s,i,r){var n=0,A=0;switch(e.size){case 0:0===e.shape?n=A=Math.min(Math.abs(t),Math.abs(t-i),Math.abs(s),Math.abs(s-r)):1===e.shape&&(n=Math.min(Math.abs(t),Math.abs(t-i)),A=Math.min(Math.abs(s),Math.abs(s-r)));break;case 2:if(0===e.shape)n=A=Math.min(sf(t,s),sf(t,s-r),sf(t-i,s),sf(t-i,s-r));else if(1===e.shape){var o=Math.min(Math.abs(s),Math.abs(s-r))/Math.min(Math.abs(t),Math.abs(t-i)),a=rf(i,r,t,s,!0),l=a[0],c=a[1];A=o*(n=sf(l-t,(c-s)/o))}break;case 1:0===e.shape?n=A=Math.max(Math.abs(t),Math.abs(t-i),Math.abs(s),Math.abs(s-r)):1===e.shape&&(n=Math.max(Math.abs(t),Math.abs(t-i)),A=Math.max(Math.abs(s),Math.abs(s-r)));break;case 3:if(0===e.shape)n=A=Math.max(sf(t,s),sf(t,s-r),sf(t-i,s),sf(t-i,s-r));else if(1===e.shape){o=Math.max(Math.abs(s),Math.abs(s-r))/Math.max(Math.abs(t),Math.abs(t-i));var h=rf(i,r,t,s,!1);l=h[0],c=h[1],A=o*(n=sf(l-t,(c-s)/o))}}return Array.isArray(e.size)&&(n=kp(e.size[0],i),A=2===e.size.length?kp(e.size[1],r):n),[n,A]}(s,M,E,w,v),x=F[0],U=F[1],x>0&&U>0&&(I=i.ctx.createRadialGradient(B+M,y+E,0,B+M,y+E,x),ef(s.stops,2*x).forEach((function(e){return I.addColorStop(e.stop,Np(e.color))})),i.path(b),i.ctx.fillStyle=I,x!==U?(T=e.bounds.left+.5*e.bounds.width,P=e.bounds.top+.5*e.bounds.height,D=1/(S=U/x),i.ctx.save(),i.ctx.translate(T,P),i.ctx.transform(1,0,0,S,0,0),i.ctx.translate(-T,-P),i.ctx.fillRect(B,D*(y-P)+P,w,v*D),i.ctx.restore()):i.ctx.fill())),k.label=6;case 6:return t--,[2]}}))},i=this,r=0,n=e.styles.backgroundImage.slice(0).reverse(),o.label=1;case 1:return r<n.length?(A=n[r],[5,s(A)]):[3,4];case 2:o.sent(),o.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}))},t.prototype.renderSolidBorder=function(e,t,s){return Ou(this,void 0,void 0,(function(){return Vu(this,(function(i){return this.path(ob(s,t)),this.ctx.fillStyle=Np(e),this.ctx.fill(),[2]}))}))},t.prototype.renderDoubleBorder=function(e,t,s,i){return Ou(this,void 0,void 0,(function(){var r,n;return Vu(this,(function(A){switch(A.label){case 0:return t<3?[4,this.renderSolidBorder(e,s,i)]:[3,2];case 1:return A.sent(),[2];case 2:return r=function(e,t){switch(t){case 0:return lb(e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox,e.topRightBorderBox,e.topRightBorderDoubleOuterBox);case 1:return lb(e.topRightBorderBox,e.topRightBorderDoubleOuterBox,e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox);case 2:return lb(e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox,e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox);default:return lb(e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox,e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox)}}(i,s),this.path(r),this.ctx.fillStyle=Np(e),this.ctx.fill(),n=function(e,t){switch(t){case 0:return lb(e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox,e.topRightBorderDoubleInnerBox,e.topRightPaddingBox);case 1:return lb(e.topRightBorderDoubleInnerBox,e.topRightPaddingBox,e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox);case 2:return lb(e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox,e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox);default:return lb(e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox,e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox)}}(i,s),this.path(n),this.ctx.fill(),[2]}}))}))},t.prototype.renderNodeBackgroundAndBorders=function(e){return Ou(this,void 0,void 0,(function(){var t,s,i,r,n,A,o,a,l=this;return Vu(this,(function(c){switch(c.label){case 0:return this.applyEffects(e.getEffects(2)),t=e.container.styles,s=!Hp(t.backgroundColor)||t.backgroundImage.length,i=[{style:t.borderTopStyle,color:t.borderTopColor,width:t.borderTopWidth},{style:t.borderRightStyle,color:t.borderRightColor,width:t.borderRightWidth},{style:t.borderBottomStyle,color:t.borderBottomColor,width:t.borderBottomWidth},{style:t.borderLeftStyle,color:t.borderLeftColor,width:t.borderLeftWidth}],r=wb(gb(t.backgroundClip,0),e.curves),s||t.boxShadow.length?(this.ctx.save(),this.path(r),this.ctx.clip(),Hp(t.backgroundColor)||(this.ctx.fillStyle=Np(t.backgroundColor),this.ctx.fill()),[4,this.renderBackgroundImage(e.container)]):[3,2];case 1:c.sent(),this.ctx.restore(),t.boxShadow.slice(0).reverse().forEach((function(t){l.ctx.save();var s,i,r,n,A,o=J_(e.curves),a=t.inset?0:1e4,c=(s=o,i=-a+(t.inset?1:-1)*t.spread.number,r=(t.inset?1:-1)*t.spread.number,n=t.spread.number*(t.inset?-2:2),A=t.spread.number*(t.inset?-2:2),s.map((function(e,t){switch(t){case 0:return e.add(i,r);case 1:return e.add(i+n,r);case 2:return e.add(i+n,r+A);case 3:return e.add(i,r+A)}return e})));t.inset?(l.path(o),l.ctx.clip(),l.mask(c)):(l.mask(o),l.ctx.clip(),l.path(c)),l.ctx.shadowOffsetX=t.offsetX.number+a,l.ctx.shadowOffsetY=t.offsetY.number,l.ctx.shadowColor=Np(t.color),l.ctx.shadowBlur=t.blur.number,l.ctx.fillStyle=t.inset?Np(t.color):"rgba(0,0,0,1)",l.ctx.fill(),l.ctx.restore()})),c.label=2;case 2:n=0,A=0,o=i,c.label=3;case 3:return A<o.length?0!==(a=o[A]).style&&!Hp(a.color)&&a.width>0?2!==a.style?[3,5]:[4,this.renderDashedDottedBorder(a.color,a.width,n,e.curves,2)]:[3,11]:[3,13];case 4:return c.sent(),[3,11];case 5:return 3!==a.style?[3,7]:[4,this.renderDashedDottedBorder(a.color,a.width,n,e.curves,3)];case 6:return c.sent(),[3,11];case 7:return 4!==a.style?[3,9]:[4,this.renderDoubleBorder(a.color,a.width,n,e.curves)];case 8:return c.sent(),[3,11];case 9:return[4,this.renderSolidBorder(a.color,n,e.curves)];case 10:c.sent(),c.label=11;case 11:n++,c.label=12;case 12:return A++,[3,3];case 13:return[2]}}))}))},t.prototype.renderDashedDottedBorder=function(e,t,s,i,r){return Ou(this,void 0,void 0,(function(){var n,A,o,a,l,c,h,u,d,p,f,g,m,_,b,B;return Vu(this,(function(y){return this.ctx.save(),n=function(e,t){switch(t){case 0:return ab(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return ab(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return ab(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return ab(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}}(i,s),A=ob(i,s),2===r&&(this.path(A),this.ctx.clip()),X_(A[0])?(o=A[0].start.x,a=A[0].start.y):(o=A[0].x,a=A[0].y),X_(A[1])?(l=A[1].end.x,c=A[1].end.y):(l=A[1].x,c=A[1].y),h=0===s||2===s?Math.abs(o-l):Math.abs(a-c),this.ctx.beginPath(),3===r?this.formatPath(n):this.formatPath(A.slice(0,2)),u=t<3?3*t:2*t,d=t<3?2*t:t,3===r&&(u=t,d=t),p=!0,h<=2*u?p=!1:h<=2*u+d?(u*=f=h/(2*u+d),d*=f):(g=Math.floor((h+d)/(u+d)),m=(h-g*u)/(g-1),d=(_=(h-(g+1)*u)/g)<=0||Math.abs(d-m)<Math.abs(d-_)?m:_),p&&(3===r?this.ctx.setLineDash([0,u+d]):this.ctx.setLineDash([u,d])),3===r?(this.ctx.lineCap="round",this.ctx.lineWidth=t):this.ctx.lineWidth=2*t+1.1,this.ctx.strokeStyle=Np(e),this.ctx.stroke(),this.ctx.setLineDash([]),2===r&&(X_(A[0])&&(b=A[3],B=A[0],this.ctx.beginPath(),this.formatPath([new j_(b.end.x,b.end.y),new j_(B.start.x,B.start.y)]),this.ctx.stroke()),X_(A[1])&&(b=A[1],B=A[2],this.ctx.beginPath(),this.formatPath([new j_(b.end.x,b.end.y),new j_(B.start.x,B.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]}))}))},t.prototype.render=function(e){return Ou(this,void 0,void 0,(function(){var t;return Vu(this,(function(s){switch(s.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=Np(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),i=new rb(e,null),r=new ib(i),nb(i,r,r,n=[]),Ab(i.container,n),t=r,[4,this.renderStack(t)];case 1:return s.sent(),this.applyEffects([]),[2,this.canvas]}var i,r,n}))}))},t}(bb),yb=function(e){return e instanceof Qm||(e instanceof km||e instanceof Dm&&"radio"!==e.type&&"checkbox"!==e.type)},wb=function(e,t){switch(e){case 0:return J_(t);case 2:return function(e){return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox]}(t);default:return Y_(t)}},vb=function(e){switch(e){case 1:return"center";case 2:return"right";default:return"left"}},Cb=["-apple-system","system-ui"],Mb=function(e){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?e.filter((function(e){return-1===Cb.indexOf(e)})):e},Eb=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i.canvas=s.canvas?s.canvas:document.createElement("canvas"),i.ctx=i.canvas.getContext("2d"),i.options=s,i.canvas.width=Math.floor(s.width*s.scale),i.canvas.height=Math.floor(s.height*s.scale),i.canvas.style.width=s.width+"px",i.canvas.style.height=s.height+"px",i.ctx.scale(i.options.scale,i.options.scale),i.ctx.translate(-s.x,-s.y),i.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized ("+s.width+"x"+s.height+" at "+s.x+","+s.y+") with scale "+s.scale),i}return Qu(t,e),t.prototype.render=function(e){return Ou(this,void 0,void 0,(function(){var t,s;return Vu(this,(function(i){switch(i.label){case 0:return t=um(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,e),[4,Fb(t)];case 1:return s=i.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=Np(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(s,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}}))}))},t}(bb),Fb=function(e){return new Promise((function(t,s){var i=new Image;i.onload=function(){t(i)},i.onerror=s,i.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(e))}))},xb=function(){function e(e){var t=e.id,s=e.enabled;this.id=t,this.enabled=s,this.start=Date.now()}return e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.debug?console.debug.apply(console,Lu([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},e.prototype.getTime=function(){return Date.now()-this.start},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&"undefined"!=typeof window&&window.console&&"function"==typeof console.info&&console.info.apply(console,Lu([this.id,this.getTime()+"ms"],e))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.warn?console.warn.apply(console,Lu([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.error?console.error.apply(console,Lu([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},e.instances={},e}(),Ub=function(){function e(t,s){var i;this.windowBounds=s,this.instanceName="#"+e.instanceCount++,this.logger=new xb({id:this.instanceName,enabled:t.logging}),this.cache=null!==(i=t.cache)&&void 0!==i?i:new k_(this,t)}return e.instanceCount=1,e}();"undefined"!=typeof window&&D_.setContext(window);var Ib=function(e,t){return Ou(void 0,void 0,void 0,(function(){var s,i,r,n,A,o,a,l,c,h,u,d,p,f,g,m,_,b,B,y,w,v,C,M,E,F,x,U,I,T,P,S,D,k,Q,R,O,V;return Vu(this,(function(L){switch(L.label){case 0:if(!e||"object"!=typeof e)return[2,Promise.reject("Invalid element provided as first argument")];if(!(s=e.ownerDocument))throw new Error("Element is not attached to a Document");if(!(i=s.defaultView))throw new Error("Document is not attached to a Window");return r={allowTaint:null!==(v=t.allowTaint)&&void 0!==v&&v,imageTimeout:null!==(C=t.imageTimeout)&&void 0!==C?C:15e3,proxy:t.proxy,useCORS:null!==(M=t.useCORS)&&void 0!==M&&M},n=Ru({logging:null===(E=t.logging)||void 0===E||E,cache:t.cache},r),A={windowWidth:null!==(F=t.windowWidth)&&void 0!==F?F:i.innerWidth,windowHeight:null!==(x=t.windowHeight)&&void 0!==x?x:i.innerHeight,scrollX:null!==(U=t.scrollX)&&void 0!==U?U:i.pageXOffset,scrollY:null!==(I=t.scrollY)&&void 0!==I?I:i.pageYOffset},o=new Hu(A.scrollX,A.scrollY,A.windowWidth,A.windowHeight),a=new Ub(n,o),l=null!==(T=t.foreignObjectRendering)&&void 0!==T&&T,c={allowTaint:null!==(P=t.allowTaint)&&void 0!==P&&P,onclone:t.onclone,ignoreElements:t.ignoreElements,inlineImages:l,copyStyles:l},a.logger.debug("Starting document clone with size "+o.width+"x"+o.height+" scrolled to "+-o.left+","+-o.top),h=new b_(a,e,c),(u=h.clonedReferenceElement)?[4,h.toIFrame(s,o)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return d=L.sent(),p=$m(u)||"HTML"===u.tagName?function(e){var t=e.body,s=e.documentElement;if(!t||!s)throw new Error("Unable to get document size");var i=Math.max(Math.max(t.scrollWidth,s.scrollWidth),Math.max(t.offsetWidth,s.offsetWidth),Math.max(t.clientWidth,s.clientWidth)),r=Math.max(Math.max(t.scrollHeight,s.scrollHeight),Math.max(t.offsetHeight,s.offsetHeight),Math.max(t.clientHeight,s.clientHeight));return new Hu(0,0,i,r)}(u.ownerDocument):Nu(a,u),f=p.width,g=p.height,m=p.left,_=p.top,b=Tb(a,u,t.backgroundColor),B={canvas:t.canvas,backgroundColor:b,scale:null!==(D=null!==(S=t.scale)&&void 0!==S?S:i.devicePixelRatio)&&void 0!==D?D:1,x:(null!==(k=t.x)&&void 0!==k?k:0)+m,y:(null!==(Q=t.y)&&void 0!==Q?Q:0)+_,width:null!==(R=t.width)&&void 0!==R?R:Math.ceil(f),height:null!==(O=t.height)&&void 0!==O?O:Math.ceil(g)},l?(a.logger.debug("Document cloned, using foreign object rendering"),[4,new Eb(a,B).render(u)]):[3,3];case 2:return y=L.sent(),[3,5];case 3:return a.logger.debug("Document cloned, element located at "+m+","+_+" with size "+f+"x"+g+" using computed rendering"),a.logger.debug("Starting DOM parsing"),w=Hm(a,u),b===w.styles.backgroundColor&&(w.styles.backgroundColor=Jp.TRANSPARENT),a.logger.debug("Starting renderer for element at "+B.x+","+B.y+" with size "+B.width+"x"+B.height),[4,new Bb(a,B).render(w)];case 4:y=L.sent(),L.label=5;case 5:return(null===(V=t.removeContainer)||void 0===V||V)&&(b_.destroy(d)||a.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),a.logger.debug("Finished rendering"),[2,y]}}))}))},Tb=function(e,t,s){var i=t.ownerDocument,r=i.documentElement?Zp(e,getComputedStyle(i.documentElement).backgroundColor):Jp.TRANSPARENT,n=i.body?Zp(e,getComputedStyle(i.body).backgroundColor):Jp.TRANSPARENT,A="string"==typeof s?Zp(e,s):null===s?Jp.TRANSPARENT:4294967295;return t===i.documentElement?Hp(r)?Hp(n)?A:n:r:A};function Pb(e,t,s=(()=>{})){if(!e||!t)return;let i=null;let r,n;const A=e=>{if(e.preventDefault(),i&&(clearTimeout(i),i=null),e.touches.length>1)return;const s=e.touches[0];r=s.clientX,n=s.clientY,i=setTimeout((()=>{e.clientX=s.clientX,e.clientY=s.clientY,t(e),clearTimeout(i),i=null}),500)},o=e=>{e.touches.length>1&&i&&(clearTimeout(i),i=null)},a=e=>{if(!i)return;const t=e.touches[0],s=Math.abs(t.clientX-r),A=Math.abs(t.clientY-n);(s>3||A>3)&&(clearTimeout(i),i=null)},l=e=>{e.preventDefault(),i&&(s(e),clearTimeout(i),i=null)},c=e=>{t(e),e.preventDefault(),e.stopPropagation()};return gn.isIphoneOrIpadSafari()?(e.addEventListener("touchstart",A),e.addEventListener("touchmove",a),e.addEventListener("touchend",l),window.addEventListener("touchstart",o)):e.addEventListener("contextmenu",c),function(){gn.isIphoneOrIpadSafari()?(e.removeEventListener("touchstart",A),e.removeEventListener("touchmove",a),e.removeEventListener("touchend",l),window.removeEventListener("touchstart",o)):e.removeEventListener("contextmenu",c)}}class Sb{constructor(e,t={}){this._highlightClass="viewer-ruler-dot-highlighted",this._x=0,this._y=0,this._dot=document.createElement("div"),this._dot.className+=this._dot.className?" viewer-ruler-dot":"viewer-ruler-dot",this._dotClickable=document.createElement("div"),this._dotClickable.className+=this._dotClickable.className?" viewer-ruler-dot-clickable":"viewer-ruler-dot-clickable",this._visible=!1!==t.visible,this._culled=!1;var s=this._dot,i=s.style;i["border-radius"]="25px",i.border="solid 2px white",i.background="lightgreen",i.position="absolute",i["z-index"]=void 0===t.zIndex?"40000005":t.zIndex,i.width="8px",i.height="8px",i.visibility=this._visible?"visible":"hidden",i.top="0px",i.left="0px",i["box-shadow"]="0 2px 5px 0 #182A3D;",i.opacity=1,i["pointer-events"]="none",t.onContextMenu,e.appendChild(s);var r=this._dotClickable,n=r.style;if(n["border-radius"]="35px",n.border="solid 10px white",n.position="absolute",n["z-index"]=void 0===t.zIndex?"40000007":t.zIndex+1,n.width="8px",n.height="8px",n.visibility="visible",n.top="0px",n.left="0px",n.opacity=0,n["pointer-events"]="none",t.onContextMenu,e.appendChild(r),r.addEventListener("click",(t=>{e.dispatchEvent(new MouseEvent("mouseover",t))})),t.onMouseOver&&r.addEventListener("mouseover",(s=>{t.onMouseOver(s,this),e.dispatchEvent(new MouseEvent("mouseover",s))})),t.onMouseLeave&&r.addEventListener("mouseleave",(e=>{t.onMouseLeave(e,this)})),t.onMouseWheel&&r.addEventListener("wheel",(e=>{t.onMouseWheel(e,this)})),t.onMouseDown&&r.addEventListener("mousedown",(e=>{t.onMouseDown(e,this)})),t.onMouseUp&&r.addEventListener("mouseup",(e=>{t.onMouseUp(e,this)})),t.onMouseMove&&r.addEventListener("mousemove",(e=>{t.onMouseMove(e,this)})),t.onTouchstart&&r.addEventListener("touchstart",(e=>{t.onTouchstart(e,this)})),t.onTouchmove&&r.addEventListener("touchmove",(e=>{t.onTouchmove(e,this)})),t.onTouchend&&r.addEventListener("touchend",(e=>{t.onTouchend(e,this)})),t.onContextMenu){Pb(r,(e=>{t.onContextMenu(e,this)}))}this.setPos(t.x||0,t.y||0),this.setFillColor(t.fillColor),this.setBorderColor(t.borderColor)}setPos(e,t){this._x=e,this._y=t;var s=this._dot.style;s.left=Math.round(e)-6+"px",s.top=Math.round(t)-6+"px";var i=this._dotClickable.style;i.left=Math.round(e)-14+"px",i.top=Math.round(t)-14+"px"}setFillColor(e){this._dot.style.background=e||"lightgreen"}setBorderColor(e){this._dot.style.border="solid 2px"+(e||"black")}setOpacity(e){this._dot.style.opacity=e}_updateVisibility(){this._dot.style.visibility=this._dotClickable.style.visibility=this._visible&&!this._culled?"visible":"hidden"}setVisible(e){this._visible!==e&&(this._visible=!!e,this._updateVisibility())}setCulled(e){this._culled!==e&&(this._culled=!!e,this._updateVisibility())}setClickable(e){this._dotClickable.style["pointer-events"]=e?"all":"none"}setHighlighted(e){this._highlighted!==e&&(this._highlighted=!!e,this._highlighted?this._dot.classList.add(this._highlightClass):this._dot.classList.remove(this._highlightClass))}destroy(){this.setVisible(!1),this._dot.parentElement&&this._dot.parentElement.removeChild(this._dot),this._dotClickable.parentElement&&this._dotClickable.parentElement.removeChild(this._dotClickable)}}class Db{constructor(e,t={}){this._highlightClass="viewer-ruler-label-highlighted",this._prefix=t.prefix||"",this._x=0,this._y=0,this._visible=!0,this._culled=!1,this._label=document.createElement("div"),this._label.className+=this._label.className?" viewer-ruler-label":"viewer-ruler-label",this._timeout=null;var s=this._label,i=s.style;if(i["border-radius"]="5px",i.color="white",i.padding="4px",i.border="solid 1px",i.background="lightgreen",i.position="absolute",i["z-index"]=void 0===t.zIndex?"5000005":t.zIndex,i.width="auto",i.height="auto",i.visibility="visible",i.top="0px",i.left="0px",i["pointer-events"]="all",i.opacity=1,t.onContextMenu,s.innerText="",e.appendChild(s),this.setPos(t.x||0,t.y||0),this.setFillColor(t.fillColor),this.setBorderColor(t.fillColor),this.setText(t.text),t.onMouseOver&&s.addEventListener("mouseover",(e=>{t.onMouseOver(e,this),e.preventDefault()})),t.onMouseLeave&&s.addEventListener("mouseleave",(e=>{t.onMouseLeave(e,this),e.preventDefault()})),t.onMouseWheel&&s.addEventListener("wheel",(e=>{t.onMouseWheel(e,this)})),t.onMouseDown&&s.addEventListener("mousedown",(e=>{t.onMouseDown(e,this),e.stopPropagation()})),t.onMouseUp&&s.addEventListener("mouseup",(e=>{t.onMouseUp(e,this),e.stopPropagation()})),t.onMouseMove&&s.addEventListener("mousemove",(e=>{t.onMouseMove(e,this)})),t.onContextMenu){Pb(s,(e=>{t.onContextMenu(e,this)}))}}setPos(e,t){this._x=e,this._y=t;var s=this._label.style;s.left=Math.round(e)-20+"px",s.top=Math.round(t)-12+"px"}setPosOnWire(e,t,s,i){var r=e+.5*(s-e),n=t+.5*(i-t),A=this._label.style;A.left=Math.round(r)-20+"px",A.top=Math.round(n)-12+"px"}setPosBetweenWires(e,t,s,i,r,n){var A=(e+s+r)/3,o=(t+i+n)/3,a=this._label.style;a.left=Math.round(A)-20+"px",a.top=Math.round(o)-12+"px"}setText(e){this._label.innerHTML=this._prefix+(e||"")}setFillColor(e){this._fillColor=e||"lightgreen",this._label.style.background=this._fillColor}setBorderColor(e){this._borderColor=e||"black",this._label.style.border="solid 1px "+this._borderColor}setOpacity(e){this._label.style.opacity=e}_updateVisibility(){this._label.style.visibility=this._visible&&!this._culled?"visible":"hidden"}setVisible(e){this._visible!==e&&(this._visible=!!e,this._updateVisibility())}setCulled(e){this._culled!==e&&(this._culled=!!e,this._updateVisibility())}setHighlighted(e){this._highlighted!==e&&(this._highlighted=!!e,this._highlighted?this._label.classList.add(this._highlightClass):this._label.classList.remove(this._highlightClass))}setClickable(e){this._label.style["pointer-events"]=e?"all":"none"}setPrefix(e){this._prefix!==e&&(this._prefix=e)}destroy(){this._label.parentElement&&this._label.parentElement.removeChild(this._label)}}class kb{constructor(e,t={}){this._color=t.color||"black",this._highlightClass="viewer-ruler-wire-highlighted",this._wire=document.createElement("div"),this._wire.className+=this._wire.className?" viewer-ruler-wire":"viewer-ruler-wire",this._wireClickable=document.createElement("div"),this._wireClickable.className+=this._wireClickable.className?" viewer-ruler-wire-clickable":"viewer-ruler-wire-clickable",this._thickness=t.thickness||1,this._thicknessClickable=t.thicknessClickable||6,this._visible=!0,this._culled=!1;var s=this._wire,i=s.style;i.border="solid "+this._thickness+"px "+this._color,i.position="absolute",i["z-index"]=void 0===t.zIndex?"2000001":t.zIndex,i.width="0px",i.height="0px",i.visibility="visible",i.top="0px",i.left="0px",i["-webkit-transform-origin"]="0 0",i["-moz-transform-origin"]="0 0",i["-ms-transform-origin"]="0 0",i["-o-transform-origin"]="0 0",i["transform-origin"]="0 0",i["-webkit-transform"]="rotate(0deg)",i["-moz-transform"]="rotate(0deg)",i["-ms-transform"]="rotate(0deg)",i["-o-transform"]="rotate(0deg)",i.transform="rotate(0deg)",i.opacity=1,i["pointer-events"]="none",t.onContextMenu,e.appendChild(s);var r=this._wireClickable,n=r.style;if(n.border="solid "+this._thicknessClickable+"px "+this._color,n.position="absolute",n["z-index"]=void 0===t.zIndex?"2000002":t.zIndex+1,n.width="0px",n.height="0px",n.visibility="visible",n.top="0px",n.left="0px",n["-webkit-transform-origin"]="0 0",n["-moz-transform-origin"]="0 0",n["-ms-transform-origin"]="0 0",n["-o-transform-origin"]="0 0",n["transform-origin"]="0 0",n["-webkit-transform"]="rotate(0deg)",n["-moz-transform"]="rotate(0deg)",n["-ms-transform"]="rotate(0deg)",n["-o-transform"]="rotate(0deg)",n.transform="rotate(0deg)",n.opacity=0,n["pointer-events"]="none",t.onContextMenu,e.appendChild(r),t.onMouseOver&&r.addEventListener("mouseover",(e=>{t.onMouseOver(e,this)})),t.onMouseLeave&&r.addEventListener("mouseleave",(e=>{t.onMouseLeave(e,this)})),t.onMouseWheel&&r.addEventListener("wheel",(e=>{t.onMouseWheel(e,this)})),t.onMouseDown&&r.addEventListener("mousedown",(e=>{t.onMouseDown(e,this)})),t.onMouseUp&&r.addEventListener("mouseup",(e=>{t.onMouseUp(e,this)})),t.onMouseMove&&r.addEventListener("mousemove",(e=>{t.onMouseMove(e,this)})),t.onContextMenu){Pb(r,(e=>{t.onContextMenu(e,this)}))}this._x1=0,this._y1=0,this._x2=0,this._y2=0,this._update()}get visible(){return"visible"===this._wire.style.visibility}_update(){var e=Math.abs(Math.sqrt((this._x1-this._x2)*(this._x1-this._x2)+(this._y1-this._y2)*(this._y1-this._y2))),t=180*Math.atan2(this._y2-this._y1,this._x2-this._x1)/Math.PI,s=this._wire.style;s.width=Math.round(e)+"px",s.left=Math.round(this._x1)+"px",s.top=Math.round(this._y1)+"px",s["-webkit-transform"]=s["-moz-transform"]=s["-ms-transform"]=s["-o-transform"]=s.transform="rotate("+t+"deg) translate(-"+this._thickness+"px, -"+this._thickness+"px)";var i=this._wireClickable.style;i.width=Math.round(e)+"px",i.left=Math.round(this._x1)+"px",i.top=Math.round(this._y1)+"px",i["-webkit-transform"]=i["-moz-transform"]=i["-ms-transform"]=i["-o-transform"]=i.transform="rotate("+t+"deg) translate(-"+this._thicknessClickable+"px, -"+this._thicknessClickable+"px)"}setStartAndEnd(e,t,s,i){this._x1=e,this._y1=t,this._x2=s,this._y2=i,this._update()}setColor(e){this._color=e||"black",this._wire.style.border="solid "+this._thickness+"px "+this._color}setOpacity(e){this._wire.style.opacity=e}_updateVisibility(){this._wire.style.visibility=this._wireClickable.style.visibility=this._visible&&!this._culled?"visible":"hidden"}setVisible(e){this._visible!==e&&(this._visible=!!e,this._updateVisibility())}setCulled(e){this._culled!==e&&(this._culled=!!e,this._updateVisibility())}setClickable(e){this._wireClickable.style["pointer-events"]=e?"all":"none"}setHighlighted(e){this._highlighted!==e&&(this._highlighted=!!e,this._highlighted?this._wire.classList.add(this._highlightClass):this._wire.classList.remove(this._highlightClass))}destroy(e){this._wire.parentElement&&this._wire.parentElement.removeChild(this._wire),this._wireClickable.parentElement&&this._wireClickable.parentElement.removeChild(this._wireClickable)}}const Qb=R.vec2(),Rb=R.vec2(),Ob=R.vec2(),Vb=R.vec2(),Lb=R.vec3(),Hb=R.vec3(),Nb=R.vec4(),Gb=R.vec4(),jb=R.vec4(),Wb=R.vec4(),zb=R.mat4(),Xb={origin:R.vec3(),direction:R.vec3()},Kb=()=>{},Zb=function(e,t,s,i){const r=(e-R.dotVec3(s,t))/R.dotVec3(i,t);if(r<0)return null;{const e=R.vec3();return R.mulVec3Scalar(i,r,e),R.addVec3(s,e,e),e}};function Jb(e,t,s){const i=e.getBoundingClientRect(),r=t.getBoundingClientRect();s[0]+=i.left-r.left,s[1]+=i.top-r.top}const Yb=(e,t,s)=>{zb.set(e.viewMatrix),zb.set(e.projMatrix),s.set(t),s[3]=1,R.mulMat4v4(e.viewMatrix,s,s),R.mulMat4v4(e.projMatrix,s,s)},$b=(e,t,s,i)=>{i[0]=.5*(1+s[0])*e.offsetWidth,i[1]=.5*(1-s[1])*e.offsetHeight,Jb(e,t,i)},qb=(e,t,s,i,r,n)=>{const A=e.camera,o=e.canvas.canvas;if(R.distVec3(s,i)<.001)return!1;const a=R.subVec3(i,s,Lb);let l=0,c=1;for(let t of e._sectionPlanesState.sectionPlanes){const e=R.dotVec3(t.dir,R.subVec3(t.pos,i,Hb)),r=R.dotVec3(t.dir,R.subVec3(t.pos,s,Hb));if(r>0&&e>0)return!1;if(r>0||e>0){const e=R.dotVec3(t.dir,a);if(Math.abs(e)>=1e-6){const s=R.dotVec3(t.dir,Hb)/e;r>0?l=Math.max(l,s):c=Math.min(c,s)}}}const h=Nb,u=Gb;Yb(A,l>0?R.addVec3(s,R.mulVec3Scalar(a,l,Hb),Hb):s,h),Yb(A,c<1?R.addVec3(s,R.mulVec3Scalar(a,c,Hb),Hb):i,u);const d=h[2]/h[3]<-1||h[3]<0,p=u[2]/u[3]<-1||u[3]<0;if(d&&p)return!1;const f=(h[3]+h[2])/(h[3]+h[2]-(u[3]+u[2]));if(f>0&&f<1){const e=R.subVec4(u,h,jb);R.mulVec4Scalar(e,f,e),R.addVec4(h,e,d?h:u)}R.mulVec4Scalar(h,1/h[3]),R.mulVec4Scalar(u,1/u[3]);let g=0,m=1;for(let e=0;e<2;++e){const t=u[e]-h[e],s=(-1-h[e])/t,i=(1-h[e])/t;t>0?(g=Math.max(g,s),m=Math.min(m,i)):t<0?(g=Math.max(g,i),m=Math.min(m,s)):h[0]<-1?g=-window.Infinity:h[0]>1&&(m=window.Infinity)}if(g>=m)return!1;const _=R.subVec4(u,h,jb);return R.addVec4(h,R.mulVec4Scalar(_,m,Wb),u),R.addVec4(h,R.mulVec4Scalar(_,g,Wb),h),R.mulVec4Scalar(h,1/h[3]),R.mulVec4Scalar(u,1/u[3]),$b(o,t,h,r),$b(o,t,u,n),!0};class eB extends sn{constructor(e,t,s,i={}){const r=e.camera;super(e,t),this.__visible=!0;const n=(e,t)=>s=>{e&&e(s),this.fire(t,s,!0)};this._dot=new Sb(s,{borderColor:i.borderColor,fillColor:i.fillColor,zIndex:i.zIndex,onMouseOver:n(i.onMouseOver,"mouseover"),onMouseLeave:n(i.onMouseLeave,"mouseleave"),onMouseWheel:n(i.onMouseWheel,"wheel"),onMouseDown:n(i.onMouseDown,"mousedown"),onMouseUp:n(i.onMouseUp,"mouseup"),onMouseMove:n(i.onMouseMove,"mousemove"),onTouchstart:n(i.onTouchstart,"touchstart"),onTouchmove:n(i.onTouchmove,"touchmove"),onTouchend:n(i.onTouchend,"touchend"),onContextMenu:n(i.onContextMenu,"contextmenu")});const A=()=>{if(!this.__visible)return;const t=jb;((e,t)=>{t.set(e),t[3]=1,R.mulMat4v4(r.viewMatrix,t,t),R.mulMat4v4(r.projMatrix,t,t)})(this.worldPos,t),R.mulVec3Scalar(t,1/t[3]);const i=t[3]<0||t[0]<-1||t[0]>1||t[1]<-1||t[1]>1||t[2]<-1||t[2]>1||e._sectionPlanesState.sectionPlanes.some((e=>R.dotVec3(e.dir,R.subVec3(e.pos,this.worldPos,Lb))>0));this._dot.setCulled(i),i||((t=>{const i=e.canvas.canvas;t[0]=.5*(1+t[0])*i.offsetWidth,t[1]=.5*(1-t[1])*i.offsetHeight,Jb(i,s,t)})(t),this._dot.setPos(t[0],t[1]))};this.on("worldPos",A);const o=r.on("viewMatrix",A),a=r.on("projMatrix",A),l=e.canvas.on("boundary",A),c=e.on("sectionPlaneUpdated",A),h=e.on("sectionPlaneCreated",A),u=e.on("sectionPlaneDestroyed",A);this._updatePosition=A,this._cleanup=()=>{r.off(o),r.off(a),e.canvas.off(l),e.off(c),e.off(h),e.off(u),this._dot.destroy()}}setClickable(e){this._dot.setClickable(e)}setFillColor(e){this._dot.setFillColor(e)}setBorderColor(e){this._dot.setBorderColor(e)}setHighlighted(e){this._dot.setHighlighted(e)}setOpacity(e){this._dot.setOpacity(e)}setVisible(e){this.__visible!=e&&(this.__visible=e,this._updatePosition(),this._dot.setVisible(e))}destroy(){this._cleanup(),super.destroy()}}class tB{constructor(e,t,s){const i=e.camera;this._label=new Db(t,s),this._start=R.vec3(),this._mid=R.vec3(),this._end=R.vec3(),this._yOff=0,this.__visible=!0,this._updatePos=()=>{Yb(i,this._start,Nb),R.mulVec4Scalar(Nb,1/Nb[3]),$b(e.canvas.canvas,t,Nb,Qb),this._label.setPos(Qb[0],Qb[1])};const r=(e,t,s)=>{e[0]+=t[0],e[1]+=t[1],R.mulVec2Scalar(e,.5),this._label.setPos(e[0],e[1]+s)};this._updatePosBetween=()=>{const s=qb(e,t,this._start,this._mid,Qb,Rb),i=qb(e,t,this._end,this._mid,Ob,Vb);this._label.setCulled(!(s||i)),s&&i?(Rb[0]+=Vb[0],Rb[1]+=Vb[1],R.mulVec2Scalar(Rb,.5),Rb[0]+=Qb[0]+Ob[0],Rb[1]+=Qb[1]+Ob[1],R.mulVec2Scalar(Rb,1/3),this._label.setPos(Rb[0],Rb[1])):s?r(Qb,Rb,0):i&&r(Ob,Vb,0)},this._updatePosOnWire=()=>{const s=qb(e,t,this._start,this._end,Qb,Rb)&&R.distVec2(Qb,Rb)>=this._labelMinAxisLength;this._label.setCulled(!s),s&&r(Qb,Rb,this._yOff)};let n=()=>{};this._setUpdatePositions=e=>{n=e,this._updatePositions()},this._updatePositions=()=>{this.__visible&&n()};const A=i.on("viewMatrix",this._updatePositions),o=i.on("projMatrix",this._updatePositions),a=e.canvas.on("boundary",this._updatePositions),l=e.on("sectionPlaneUpdated",this._updatePositions),c=e.on("sectionPlaneCreated",this._updatePositions),h=e.on("sectionPlaneDestroyed",this._updatePositions);this._cleanup=()=>{i.off(A),i.off(o),e.canvas.off(a),e.off(l),e.off(c),e.off(h),this._label.destroy()}}setPos(e){this._start.set(e),this._setUpdatePositions(this._updatePos)}setPosOnWire(e,t,s,i){this._start.set(e),this._end.set(t),this._yOff=s,this._labelMinAxisLength=i,this._setUpdatePositions(this._updatePosOnWire)}setPosBetween(e,t,s){this._start.set(e),this._mid.set(t),this._end.set(s),this._setUpdatePositions(this._updatePosBetween)}setFillColor(e){this._label.setFillColor(e)}setHighlighted(e){this._label.setHighlighted(e)}setText(e){this._label.setText(e)}setClickable(e){this._label.setClickable(e)}setVisible(e){this.__visible!=e&&(this.__visible=e,this._updatePositions(),this._label.setVisible(e))}destroy(){this._cleanup()}}class sB{constructor(e,t,s){const i=e.camera;this._wire=new kb(t,s),this._start=R.vec3(),this._end=R.vec3(),this.__visible=!0,this._updatePositions=()=>{if(!this.__visible)return;const s=qb(e,t,this._start,this._end,Qb,Rb);this._wire.setCulled(!s),s&&this._wire.setStartAndEnd(Qb[0],Qb[1],Rb[0],Rb[1])};const r=i.on("viewMatrix",this._updatePositions),n=i.on("projMatrix",this._updatePositions),A=e.canvas.on("boundary",this._updatePositions),o=e.on("sectionPlaneUpdated",this._updatePositions),a=e.on("sectionPlaneCreated",this._updatePositions),l=e.on("sectionPlaneDestroyed",this._updatePositions);this._cleanup=()=>{i.off(r),i.off(n),e.canvas.off(A),e.off(o),e.off(a),e.off(l),this._wire.destroy()}}setEnds(e,t){this._start.set(e),this._end.set(t),this._updatePositions()}setClickable(e){this._wire.setClickable(e)}setColor(e){this._wire.setColor(e)}setHighlighted(e){this._wire.setHighlighted(e)}setOpacity(e){this._wire.setOpacity(e)}setVisible(e){this.__visible!=e&&(this.__visible=e,this._updatePositions(),this._wire.setVisible(e))}destroy(){this._cleanup()}}const iB=function(e,t){const s=new eB(e,{},e.canvas.canvas.parentNode,{borderColor:"white",fillColor:t,zIndex:100});return{update:function(e){e&&(s.worldPos=e),s.setVisible(!!e)},setFillColor:e=>s.setFillColor(e),setHighlighted:e=>s.setHighlighted(e),getCanvasPos:()=>s.canvasPos,getWorldPos:()=>s.worldPos,destroy:()=>s.destroy()}},rB=function(e,t){const s=new sB(e,e.canvas.canvas.ownerDocument.body,{color:t,thickness:1,thicknessClickable:6});return s.setVisible(!1),{update:(e,t)=>{t&&s.setEnds(e,t),s.setVisible(!!t)},setColor:e=>s.setColor(e),destroy:()=>s.destroy()}};function nB(e,t){const s=function(e,s){if(e in t)return t[e];if(void 0!==s)return s;throw"config missing: "+e},i=s("viewer"),r=s("ray2WorldPos"),n=s("handleMouseEvents",!1),A=s("handleTouchEvents",!1),o=s("onStart",Kb),a=s("onMove",Kb),l=s("onEnd",Kb),c=i.scene,h=c.canvas.canvas,u=e=>{const t=R.vec2([e.clientX,e.clientY]);Jb(h.ownerDocument.documentElement,h,t),a(t,(e=>{const t=R.vec3(),s=R.vec3();return R.canvasPosToWorldRay(h,c.camera.viewMatrix,c.camera.projMatrix,c.camera.projection,e,t,s),r(t,s,e)})(t))};let d=null;const p=function(e){const t=d.matchesEvent(e);t&&u(t)},f=function(t){const s=d.matchesEvent(t);s&&(e.setOpacity(b),d.cleanup(),u(s),l())},g=function(t,s){d&&d.cleanup(),e.setOpacity(1),e.setClickable(!1),i.cameraControl.active=!1,d={matchesEvent:t,cleanup:function(){d=null,e.setClickable(!0),i.cameraControl.active=!0,s()}},o()},m=[],_=function(t,s){const i=e.on(t,s);m.push((()=>e.off(i)))};if(n&&(_("mouseover",(()=>!d&&e.setOpacity(1))),_("mouseleave",(()=>!d&&e.setOpacity(b))),_("mousedown",(e=>{1===e.which&&(h.addEventListener("mousemove",p),h.addEventListener("mouseup",f),g((e=>1===e.which&&e),(()=>{h.removeEventListener("mousemove",p),h.removeEventListener("mouseup",f)})))}))),A){let e;_("touchstart",(t=>{t.preventDefault(),1===t.touches.length&&(e=t.touches[0].identifier,g((t=>[...t.changedTouches].find((t=>t.identifier===e))),(()=>{e=null})))})),_("touchmove",(e=>{e.preventDefault(),p(e)})),_("touchend",(e=>{e.preventDefault(),f(e)}))}const b=.8;return e.setOpacity(b),function(){d&&d.cleanup(),m.forEach((e=>e())),e.setOpacity(1)}}function AB(e){const t=function(t,s){if(t in e)return e[t];if(void 0!==s)return s;throw"config missing: "+t},s=t("viewer"),i=t("handleMouseEvents",!1),r=t("handleTouchEvents",!1),n=t("pointerLens",null),A=t("dots"),o=t("ray2WorldPos"),a=t("onEnd",Kb),l=n?function(e){n.visible=!!e,e&&(n.canvasPos=e)}:()=>{},c=A.map((e=>{let t;return nB(e,{handleMouseEvents:i,handleTouchEvents:r,viewer:s,ray2WorldPos:(e,s,i)=>o(e,s,i)||t,onStart:()=>{t=e.worldPos.slice(),h(!1,e)},onMove:(t,s)=>{l(t),e.worldPos=s},onEnd:()=>{a(t,e)||(e.worldPos=t),l(null),h(!0,e)}})})),h=(e,t)=>A.forEach((s=>s!==t&&s.setClickable(e)));return h(!0),function(){c.forEach((e=>e())),l(null)}}const oB=function(e,t,s){return function(i,r,n){const A=e.scene,o=A.canvas.canvas,a=(e,t)=>(t[0]=e.clientX,t[1]=e.clientY,Jb(o.ownerDocument.documentElement,o,t),t),l=e=>{const t=R.vec3(),i=R.vec3();return R.canvasPosToWorldRay(o,A.camera.viewMatrix,A.camera.projMatrix,A.camera.projection,e,t,i),s(t,i)};let c=null;const h=()=>{};let u,d=h;const p=function(){t.stop(),clearTimeout(c),e.cameraControl.active=!0,d=h,u=null},f=function(){p(),o.removeEventListener("touchstart",g),o.removeEventListener("touchmove",m),o.removeEventListener("touchend",_)},g=function(s){const n=s.touches;if(1!==n.length)p(),i();else{const s=n[0],i=a(s,R.vec2());l(i)&&(u=s.identifier,d=e=>{R.distVec2(i,e)>20&&p()},c=setTimeout((function(){t.start(i),c=setTimeout((function(){t.stop(),e.cameraControl.active=!1,d=e=>{r(e,l(e))},d(i)}),300)}),250))}};o.addEventListener("touchstart",g,{passive:!0});const m=function(e){const t=[...e.changedTouches].find((e=>e.identifier===u));t&&d(a(t,R.vec2()))};o.addEventListener("touchmove",m,{passive:!0});const _=function(e){const t=[...e.changedTouches].find((e=>e.identifier===u));if(t){f();const e=a(t,R.vec2());n(e,l(e))}};return o.addEventListener("touchend",_,{passive:!0}),f}},aB=function(e){const t=[];for(let s=0;s<e.length;++s)t.push(s);const s=function(){const s=R.vec2(),i=R.vec2();let r=0;for(let n=0;n<t.length;++n){const A=e[t[n]],o=e[t[(n+1)%t.length]],a=e[t[(n+2)%t.length]];R.subVec2(A,o,s),R.subVec2(a,o,i);const l=R.dotVec2(s,i)/Math.sqrt(R.sqLenVec2(s)*R.sqLenVec2(i)),c=Math.acos(Math.max(-1,Math.min(l,1)));r+=s[0]*i[1]-s[1]*i[0]>=0?c:2*Math.PI-c}return r<t.length*Math.PI}(),i=function(){const e=(e,t,s)=>(e[0]-s[0])*(t[1]-s[1])-(t[0]-s[0])*(e[1]-s[1]);return(t,s,i,r)=>{const n=e(t,s,i),A=e(t,i,r),o=e(t,r,s);return!((n<0||A<0||o<0)&&(n>0||A>0||o>0))}}(),r=[],n=(s?t:t.slice(0).reverse()).map((e=>({idx:e})));n.forEach(((e,t)=>{e.prev=n[(t-1+n.length)%n.length],e.next=n[(t+1)%n.length]}));const A=R.vec2(),o=R.vec2();for(;n.length>2;){let t=0;for(;;){if(t>=n.length)throw`isCCW = ${s}; earIdx = ${t}; len = ${n.length}`;const r=n[t],a=e[r.prev.idx],l=e[r.idx],c=e[r.next.idx];if(R.subVec2(a,l,A),R.subVec2(c,l,o),A[0]*o[1]-A[1]*o[0]>=0&&n.every((t=>t===r||t===r.prev||t===r.next||!i(e[t.idx],a,l,c))))break;++t}const a=n[t];n.splice(t,1),r.push([a.idx,a.next.idx,a.prev.idx]);a.prev.next=a.next;a.next.prev=a.prev}return[e,r,s]};const lB=R.vec3(),cB=R.vec3();class hB extends ie{constructor(e,t={}){const s=e.viewer.scene;super(s,t),this.plugin=e;const i=t.container;if(!i)throw"config missing: container";this._color=t.color||e.defaultColor;const r=function(e){const t=[];let s=!1!==e;return{reg:e=>t.push(e),get:()=>s,set:e=>{s=!1!==e,t.forEach((e=>e(s)))}}};this._visible=r(t.visible),this._originVisible=r(t.originVisible),this._cornerVisible=r(t.cornerVisible),this._targetVisible=r(t.targetVisible),this._originWireVisible=r(t.originWireVisible),this._targetWireVisible=r(t.targetWireVisible),this._angleVisible=r(t.angleVisible),this._labelsVisible=r(),this.labelsVisible=t.labelsVisible,this._clickable=r(!1),this.approximate=t.approximate,this._labelStringFormat=e=>(this._approximate?" ~ ":" = ")+e.toFixed(2)+"°";const n=s.canvas.canvas,A=t.onMouseOver?e=>{t.onMouseOver(e,this),n.dispatchEvent(new MouseEvent("mouseover",e))}:null,o=t.onMouseLeave?e=>{t.onMouseLeave(e,this),n.dispatchEvent(new MouseEvent("mouseleave",e))}:null,a=t.onContextMenu?e=>{t.onContextMenu(e,this)}:null,l=e=>n.dispatchEvent(new MouseEvent("mousedown",e)),c=e=>n.dispatchEvent(new MouseEvent("mouseup",e)),h=e=>n.dispatchEvent(new MouseEvent("mousemove",e)),u=e=>n.dispatchEvent(new WheelEvent("wheel",e));this._cleanups=[],this._drawables=[];const d=(e,t)=>{const s=()=>e.setVisible(t.every((e=>e.get())));t.forEach((e=>e.reg(s))),this._drawables.push(e),this._cleanups.push((()=>e.destroy()))},p=(t,r,n)=>{const p=new sB(s,i,{color:t,thickness:r,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return d(p,n),{setEnds:(e,t)=>p.setEnds(e,t),setColor:e=>p.setColor(e)}};this._originWire=p(this._color||"blue",1,[this._visible,this._originWireVisible]),this._targetWire=p(this._color||"red",1,[this._visible,this._targetWireVisible]);this._angleLabel=((t,r,n)=>{const p=new tB(s,i,{fillColor:t,zIndex:e.zIndex+r,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return d(p,n),{setFillColor:e=>p.setFillColor(e),setPosOnWire:(e,t,s)=>p.setPosOnWire(e,t,s),setPosBetween:(e,t,s)=>p.setPosBetween(e,t,s),setText:e=>p.setText(e)}})(this._color||"#00BBFF",2,[this._visible,this._angleVisible,this._labelsVisible]);const f=(t,r)=>{const n=new eB(s,t,i,{fillColor:this._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return n.on("worldPos",(()=>this._update())),d(n,r),n};this._originDot=f(t.origin,[this._visible,this._originVisible]),this._cornerDot=f(t.corner,[this._visible,this._cornerVisible]),this._targetDot=f(t.target,[this._visible,this._targetVisible]),this._update()}_update(){if(!this._targetDot)return;const e=this._originDot.worldPos,t=this._cornerDot.worldPos,s=this._targetDot.worldPos;this._originWire.setEnds(e,t),this._targetWire.setEnds(t,s),this._angleLabel.setPosBetween(e,t,s),R.subVec3(e,t,lB),R.subVec3(s,t,cB),R.lenVec3(lB)>0&&R.lenVec3(cB)>0?(R.normalizeVec3(lB),R.normalizeVec3(cB),this._angle=Math.abs(R.angleVec3(lB,cB))*R.RADTODEG,this._angleLabel.setText(this._labelStringFormat(this._angle))):(this._angle=void 0,this._angleLabel.setText(""))}set approximate(e){e=!1!==e,this._approximate!==e&&(this._approximate=e,this._update())}get approximate(){return this._approximate}get origin(){return this._originDot}get corner(){return this._cornerDot}get target(){return this._targetDot}get angle(){return this._angle}get color(){return this._color}set color(e){this._color=e,this._originDot.setFillColor(e),this._cornerDot.setFillColor(e),this._targetDot.setFillColor(e),this._originWire.setColor(e||"blue"),this._targetWire.setColor(e||"red"),this._angleLabel.setFillColor(e||"#00BBFF")}set visible(e){this._visible.set(e)}get visible(){return this._visible.get()}set originVisible(e){this._originVisible.set(e)}get originVisible(){return this._originVisible.get()}set cornerVisible(e){this._cornerVisible.set(e)}get cornerVisible(){return this._cornerVisible.get()}set targetVisible(e){this._targetVisible.set(e)}get targetVisible(){return this._targetVisible.get()}set originWireVisible(e){this._originWireVisible.set(e)}get originWireVisible(){return this._originWireVisible.get()}set targetWireVisible(e){this._targetWireVisible.set(e)}get targetWireVisible(){return this._targetWireVisible.get()}set angleVisible(e){this._angleVisible.set(e)}get angleVisible(){return this._angleVisible.get()}set labelsVisible(e){this._labelsVisible.set(void 0!==e?Boolean(e):this.plugin.defaultLabelsVisible)}get labelsVisible(){return this._labelsVisible.get()}setHighlighted(e){this._drawables.forEach((t=>t.setHighlighted(e)))}set clickable(e){this._clickable.set(!!e),this._drawables.forEach((e=>e.setClickable(this._clickable.get())))}get labelStringFormat(){return this._labelStringFormat}set labelStringFormat(e){this._labelStringFormat=e,this._update()}get clickable(){return this._clickable.get()}destroy(){this._cleanups.forEach((e=>e())),super.destroy()}}class uB extends ie{get active(){}set snapping(e){}get snapping(){return!0}activate(){}deactivate(){}reset(){}get currentMeasurement(){return null}destroy(){}}class dB extends uB{constructor(e,t={}){super(e.viewer.scene),this._canvasToPagePos=t.canvasToPagePos,this.pointerLens=t.pointerLens,this._active=!1,this._currentAngleMeasurement=null,this._initMarkerDiv(),this._snapping=!1!==t.snapping,this._mouseState=0,this._attachPlugin(e,t)}_initMarkerDiv(){const e=document.createElement("div"),t=this.scene.canvas.canvas;t.parentNode.insertBefore(e,t),e.style.background="black",e.style.border="2px solid blue",e.style.borderRadius="10px",e.style.width="5px",e.style.height="5px",e.style.top="-200px",e.style.left="-200px",e.style.margin="0 0",e.style.zIndex="100",e.style.position="absolute",e.style.pointerEvents="none",this.markerDiv=e}_destroyMarkerDiv(){this.markerDiv&&(this.markerDiv.parentNode.removeChild(this.markerDiv),this.markerDiv=null)}_attachPlugin(e,t={}){this.angleMeasurementsPlugin=e,this.plugin=e}get active(){return this._active}set snapping(e){this._snapping=e}get snapping(){return this._snapping}activate(){if(this._active)return;this.markerDiv||this._initMarkerDiv(),this.angleMeasurementsPlugin;const e=this.scene;e.input;const t=e.canvas.canvas,s=this.angleMeasurementsPlugin.viewer.cameraControl,i=this.pointerLens;let r=!1,n=null,A=0,o=0;const a=R.vec3(),l=R.vec2();this._currentAngleMeasurement=null;const c=R.vec2(),h=e=>{e.snappedToVertex||e.snappedToEdge?(i&&(i.visible=!0,i.canvasPos=e.canvasPos,i.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,i.snapped=!0),this.markerDiv.style.background="greenyellow",this.markerDiv.style.border="2px solid green"):(i&&(i.visible=!0,i.canvasPos=e.canvasPos,i.snappedCanvasPos=e.canvasPos,i.snapped=!1),this.markerDiv.style.background="pink",this.markerDiv.style.border="2px solid red");const s=e.snappedCanvasPos||e.canvasPos;switch(r=!0,n=e.entity,a.set(e.worldPos),l.set(s),this._mouseState){case 0:if(this._canvasToPagePos)this._canvasToPagePos(t,s,c),this.markerDiv.style.left=c[0]-5+"px",this.markerDiv.style.top=c[1]-5+"px";else{const e=R.vec2(s);Jb(t,this.markerDiv.parentNode,e),this.markerDiv.style.left=e[0]-5+"px",this.markerDiv.style.top=e[1]-5+"px"}break;case 1:this._currentAngleMeasurement&&(this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.angleVisible=!1,this._currentAngleMeasurement.corner.worldPos=e.worldPos,this._currentAngleMeasurement.corner.entity=e.entity),this.markerDiv.style.left="-10000px",this.markerDiv.style.top="-10000px",t.style.cursor="pointer";break;case 2:this._currentAngleMeasurement&&(this._currentAngleMeasurement.targetWireVisible=!0,this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.angleVisible=!0,this._currentAngleMeasurement.target.worldPos=e.worldPos,this._currentAngleMeasurement.target.entity=e.entity),this.markerDiv.style.left="-10000px",this.markerDiv.style.top="-10000px",t.style.cursor="pointer"}};this._onHoverSnapOrSurface=s.on("hoverSnapOrSurface",(e=>{this._snapping&&h(e)})),this._onHoverSurface=s.on("hoverSurface",(e=>{this._snapping||h(e)})),t.addEventListener("mousedown",this._onMouseDown=e=>{1===e.which&&(A=e.clientX,o=e.clientY)}),t.addEventListener("mouseup",this._onMouseUp=e=>{if(1===e.which&&!(e.clientX>A+20||e.clientX<A-20||e.clientY>o+20||e.clientY<o-20))switch(this._mouseState){case 0:r&&(this._currentAngleMeasurement=this.angleMeasurementsPlugin.createMeasurement({id:R.createUUID(),origin:{worldPos:a,entity:n},corner:{worldPos:a,entity:n},target:{worldPos:a,entity:n},approximate:!0}),this._currentAngleMeasurement.clickable=!1,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.angleVisible=!1,this._currentAngleMeasurement.origin.entity=n,this._mouseState=1,this.angleMeasurementsPlugin.fire("measurementStart",this._currentAngleMeasurement));break;case 1:r?(this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.angleVisible=!0,this._currentAngleMeasurement.corner.entity=n,this._mouseState=2):this._currentAngleMeasurement&&(this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null,n=null,this._mouseState=0,this.angleMeasurementsPlugin.fire("measurementCancel",this._currentAngleMeasurement));break;case 2:r?(this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.angleVisible=!0,this._currentAngleMeasurement.target.entity=n,this._currentAngleMeasurement.clickable=!0,n=null,this.angleMeasurementsPlugin.fire("measurementEnd",this._currentAngleMeasurement),this._currentAngleMeasurement=null,this._mouseState=0):this._currentAngleMeasurement&&(this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null,n=null,this._mouseState=0,this.angleMeasurementsPlugin.fire("measurementCancel",this._currentAngleMeasurement))}});const u=e=>{if(r=!1,i&&(i.visible=!0,i.canvasPos=e.canvasPos,i.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,i.snapped=!1),this.markerDiv.style.left="-100px",this.markerDiv.style.top="-100px",this._currentAngleMeasurement){switch(this._mouseState){case 0:this._currentAngleMeasurement.originVisible=!1;break;case 1:this._currentAngleMeasurement.cornerVisible=!1,this._currentAngleMeasurement.originWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1;break;case 2:this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1}t.style.cursor="default"}};this._onHoverSnapOrSurfaceOff=s.on("hoverSnapOrSurfaceOff",(e=>{this._snapping&&u(e)})),this._onHoverOff=s.on("hoverOff",(e=>{this._snapping||u(e)})),this._active=!0}deactivate(){if(!this._active)return;this.pointerLens&&(this.pointerLens.visible=!1),this.reset();const e=this.scene.canvas.canvas;e.removeEventListener("mousedown",this._onMouseDown),e.removeEventListener("mouseup",this._onMouseUp);const t=this.angleMeasurementsPlugin.viewer.cameraControl;t.off(this._onHoverSnapOrSurface),t.off(this._onHoverSurface),t.off(this._onHoverSnapOrSurfaceOff),t.off(this._onHoverOff),this._active=!1}reset(){this._active&&(this._destroyMarkerDiv(),this._initMarkerDiv(),this._currentAngleMeasurement&&(this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null),this._mouseState=0)}get currentMeasurement(){return this._currentAngleMeasurement}destroy(){this.deactivate(),super.destroy()}}const pB=R.vec2();class fB extends ie{constructor(e,t,s,i){const r=e.plugin.viewer;super(r.scene);const n=AB({viewer:r,handleMouseEvents:s,handleTouchEvents:i,pointerLens:t.pointerLens,dots:[e.origin,e.corner,e.target],ray2WorldPos:(e,s,i)=>{const n=e=>{const t=r.scene.pick({canvasPos:i,snapToEdge:e,snapToVertex:e,pickSurface:!0});return t&&t.worldPos?t.worldPos:e&&n(!1)};return n(!!t.snapping)},onEnd:(e,t)=>{const s=!R.compareVec3(e,t.worldPos);return s&&this.fire("edited"),s}}),A=e.on("destroyed",n);this._deactivate=function(){e.off("destroyed",A),n()}}deactivate(){this._deactivate(),super.destroy()}}const gB=R.vec3(),mB=R.vec3(),_B=R.vec3(),bB=e=>e+"px";class BB extends sn{constructor(e,t){if(super(e,t),this.plugin=t.plugin,this._container=t.container,!this._container)throw"config missing: container";if(!t.markerElement&&!t.markerHTML)throw"config missing: need either markerElement or markerHTML";if(!t.labelElement&&!t.labelHTML)throw"config missing: need either labelElement or labelHTML";this._htmlDirty=!1,this._curMarkerWidth=void 0,this._curLabelWidth=0,t.markerElement?(this._marker=t.markerElement,this._marker.addEventListener("click",this._onMouseClickedExternalMarker=()=>{this.plugin.fire("markerClicked",this)}),this._onContextMenuExternalMarker=()=>{this.plugin.fire("contextmenu",this)},this._onContextMenuExternalMarkerRemover=Pb(this._marker,this._onContextMenuExternalMarker),this._marker.addEventListener("mouseenter",this._onMouseEnterExternalMarker=()=>{this.plugin.fire("markerMouseEnter",this)}),this._marker.addEventListener("mouseleave",this._onMouseLeaveExternalMarker=()=>{this.plugin.fire("markerMouseLeave",this)}),this._markerExternal=!0):(this._markerHTML=t.markerHTML,this._htmlDirty=!0,this._markerExternal=!1),t.labelElement?(this._label=t.labelElement,this._labelExternal=!0):(this._labelHTML=t.labelHTML,this._htmlDirty=!0,this._labelExternal=!1),this._markerShown=!!t.markerShown,this._labelShown=!!t.labelShown,this._values=t.values||{},this._layoutDirty=!0,this._visibilityDirty=!0,this._labelPosition=24,this._buildHTML(),this._onTick=this.scene.on("tick",(()=>{this._htmlDirty&&(this._buildHTML(),this._htmlDirty=!1,this._layoutDirty=!0,this._visibilityDirty=!0),(this._layoutDirty||this._visibilityDirty)&&(this._markerShown||this._labelShown)&&(this._updatePosition(),this._layoutDirty=!1),this._visibilityDirty&&(this._marker.style.visibility=this.visible&&this._markerShown?"visible":"hidden",this._label.style.visibility=this.visible&&this._markerShown&&this._labelShown?"visible":"hidden",this._visibilityDirty=!1)})),this.on("canvasPos",(()=>{this._layoutDirty=!0})),this.on("visible",(()=>{this._visibilityDirty=!0})),this.setMarkerShown(!1!==t.markerShown),this.setLabelShown(t.labelShown),this.eye=t.eye?t.eye.slice():null,this.look=t.look?t.look.slice():null,this.up=t.up?t.up.slice():null,this.projection=t.projection}_buildHTML(){if(!this._markerExternal){this._marker&&(this._container.removeChild(this._marker),this._marker=null);let e=this._markerHTML||"<p></p>";j.isArray(e)&&(e=e.join("")),e=this._renderTemplate(e.trim());const t=document.createRange().createContextualFragment(e);this._marker=t.firstChild,this._container.appendChild(this._marker),this._marker.style.visibility=this._markerShown?"visible":"hidden",this._marker.addEventListener("click",(()=>{this.plugin.fire("markerClicked",this)})),Pb(this._marker,(e=>{e.preventDefault(),this.plugin.fire("contextmenu",this)}),(e=>{e.preventDefault(),this.plugin.fire("markerClicked",this)})),this._marker.addEventListener("mouseenter",(()=>{this.plugin.fire("markerMouseEnter",this)})),this._marker.addEventListener("mouseleave",(()=>{this.plugin.fire("markerMouseLeave",this)})),this._marker.addEventListener("wheel",(e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))}))}if(!this._labelExternal){this._label&&(this._container.removeChild(this._label),this._label=null);let e=this._labelHTML||"<p></p>";j.isArray(e)&&(e=e.join("")),e=this._renderTemplate(e.trim());const t=document.createRange().createContextualFragment(e);this._label=t.firstChild,this._container.appendChild(this._label),this._label.style.visibility=this._markerShown&&this._labelShown?"visible":"hidden",this._label.addEventListener("wheel",(e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))}))}}_updateWithCurWidths(){const e=this.scene.canvas.boundary,t=e[0]+this.canvasPos[0],s=e[1]+this.canvasPos[1];if(this._marker.style.top=bB(s-12),this._label.style.top=bB(s-17),"legacy"===this._markerAlign)this._marker.style.left=bB(t-12),this._label.style.left=bB(t+40);else{const e=this._curMarkerWidth,s=t+("right"===this._markerAlign?-1:"center"===this._markerAlign?0:1)*(e/2-12);this._marker.style.left=bB(s-e/2);const i=this._curLabelWidth,r=Math.sign(this._labelPosition);this._label.style.left=bB(s+r*(e/2+Math.abs(this._labelPosition)+i/2)-i/2)}const i=90005+Math.floor(this._viewPos[2])+1;this._marker.style["z-index"]=i,this._label.style["z-index"]=i}_updateIfWidthsChanged(){let e=!1;const t=this._marker.getBoundingClientRect().width;this._curMarkerWidth!==t&&(this._curMarkerWidth=t,e=!0);if(1!==Math.sign(this._labelPosition)){const t=this._label.getBoundingClientRect().width;this._curLabelWidth!==t&&(this._curLabelWidth=t,e=!0)}e&&this._updateWithCurWidths()}_updatePosition(){const e="legacy"===this._markerAlign;e||void 0!==this._curMarkerWidth?(this._updateWithCurWidths(),window.clearTimeout(this._widthTimeout),e||(this._widthTimeout=window.setTimeout((()=>this._updateIfWidthsChanged()),500))):this._updateIfWidthsChanged()}_renderTemplate(e){for(var t in this._values)if(this._values.hasOwnProperty(t)){const s=this._values[t];e=e.replace(new RegExp("{{"+t+"}}","g"),s)}return e}setFromPickResult(e){if(e.worldPos&&e.worldNormal){const t=R.normalizeVec3(e.worldNormal,gB),s=this.plugin&&this.plugin.surfaceOffset||0,i=R.mulVec3Scalar(t,s,mB),r=R.addVec3(e.worldPos,i,_B);this.entity=e.entity,this.worldPos=r}else this.error("Param 'pickResult' does not have both worldPos and worldNormal")}setMarkerAlign(e){const t=["left","center","right","legacy"];t.includes(e)?(this._markerAlign=e,this._updatePosition()):this.error("Param 'align' should be one of: "+JSON.stringify(t))}setLabelPosition(e){"number"!=typeof e?this.error("Param 'position' is not a number"):0===e?this.error("Param 'position' is zero"):(this._labelPosition=e,this._updatePosition())}setMarkerShown(e){e=!!e,this._markerShown!==e&&(this._markerShown=e,this._visibilityDirty=!0)}getMarkerShown(){return this._markerShown}setLabelShown(e){e=!!e,this._labelShown!==e&&(this._labelShown=e,this._visibilityDirty=!0)}getLabelShown(){return this._labelShown}setField(e,t){this._values[e]=t||"",this._htmlDirty=!0}getField(e){return this._values[e]}setValues(e){for(var t in e)if(e.hasOwnProperty(t)){const s=e[t];this.setField(t,s)}}getValues(){return this._values}destroy(){window.clearTimeout(this._widthTimeout),this._marker&&(this._markerExternal?(this._marker.removeEventListener("click",this._onMouseClickedExternalMarker),this._onContextMenuExternalMarkerRemover(),this._marker.removeEventListener("mouseenter",this._onMouseEnterExternalMarker),this._marker.removeEventListener("mouseleave",this._onMouseLeaveExternalMarker),this._marker=null):(this._marker.parentNode.removeChild(this._marker),this._marker=null)),this._label&&(this._labelExternal||this._label.parentNode.removeChild(this._label),this._label=null),this.scene.off(this._onTick),super.destroy()}}const yB=R.vec3(),wB=R.vec3(),vB=R.vec3(),CB=R.vec3();function MB(e){return{x:e[0],y:e[1],z:e[2]}}function EB(e,t){return(t=new Float64Array(3))[0]=e.x,t[1]=e.y,t[2]=e.z,t}function FB(e){return new Float64Array([e[0],-e[2],e[1]])}function xB(e){return new Float64Array([e[0],e[2],-e[1]])}const UB=R.vec3(),IB=R.vec3(),TB=R.vec3();R.vec4(),R.vec4(),R.vec4();class PB extends ie{constructor(e,t={}){const s=e.viewer.scene;super(s,t),this.plugin=e;const i=t.container;if(!i)throw"config missing: container";this._color=t.color||e.defaultColor;const r=function(e,t){const s=[];let i=void 0!==e?Boolean(e):t;return{reg:e=>s.push(e),get:()=>i,set:e=>{i=void 0!==e?Boolean(e):t,s.forEach((e=>e(i)))}}};this._visible=r(t.visible,e.defaultVisible),this._originVisible=r(t.originVisible,e.defaultOriginVisible),this._targetVisible=r(t.targetVisible,e.defaultTargetVisible),this._axisVisible=r(t.axisVisible,e.defaultAxisVisible),this._xAxisVisible=r(t.xAxisVisible,e.defaultAxisVisible),this._yAxisVisible=r(t.yAxisVisible,e.defaultAxisVisible),this._zAxisVisible=r(t.zAxisVisible,e.defaultAxisVisible),this._axisEnabled=r(!0,e.defaultAxisVisible),this._wireVisible=r(t.wireVisible,e.defaultWireVisible),this._xLabelEnabled=r(t.xLabelEnabled,e.defaultXLabelEnabled),this._yLabelEnabled=r(t.yLabelEnabled,e.defaultYLabelEnabled),this._zLabelEnabled=r(t.zLabelEnabled,e.defaultZLabelEnabled),this._lengthLabelEnabled=r(t.lengthLabelEnabled,e.defaultLengthLabelEnabled),this._labelsVisible=r(t.labelsVisible,e.defaultLabelsVisible),this._clickable=r(!1,!1),this._labelsOnWires=r(t.labelsOnWires,e.defaultLabelsOnWires),this._useRotationAdjustment=r(t.useRotationAdjustment,e.useRotationAdjustment),this._axesBasis=R.identityMat4(),this.approximate=t.approximate,this._labelStringFormat=e=>{const t=this.plugin.viewer.scene.metrics,s=t.scale,i=t.unitsInfo[t.units].abbrev;return(this.approximate?" ~ ":" = ")+(e*s).toFixed(2)+i};const n=s.canvas.canvas,A=t.onMouseOver?e=>{t.onMouseOver(e,this),n.dispatchEvent(new MouseEvent("mouseover",e))}:null,o=t.onMouseLeave?e=>{t.onMouseLeave(e,this),n.dispatchEvent(new MouseEvent("mouseleave",e))}:null,a=t.onContextMenu?e=>{t.onContextMenu(e,this)}:null,l=e=>n.dispatchEvent(new MouseEvent("mousedown",e)),c=e=>n.dispatchEvent(new MouseEvent("mouseup",e)),h=e=>n.dispatchEvent(new MouseEvent("mousemove",e)),u=e=>n.dispatchEvent(new WheelEvent("wheel",e));this._cleanups=[],["units","scale"].forEach((e=>{const t=s.metrics.on("units",(()=>this._update()));this._cleanups.push((()=>s.metrics.off(t)))})),this._drawables=[];const d=(e,t)=>{const s=()=>e.setVisible(t.every((e=>e.get())));t.forEach((e=>e.reg(s))),this._drawables.push(e),this._cleanups.push((()=>e.destroy()))},p=(t,r,n)=>{const p=new sB(s,i,{color:t,thickness:r,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return d(p,n),{setEnds:(e,t)=>p.setEnds(e,t),setColor:e=>p.setColor(e)}};this._lengthWire=p(this._color,2,[this._visible,this._wireVisible]),this._xAxisWire=p("red",1,[this._visible,this._axisEnabled,this._axisVisible,this._xAxisVisible]),this._yAxisWire=p("green",1,[this._visible,this._axisEnabled,this._axisVisible,this._yAxisVisible]),this._zAxisWire=p("blue",1,[this._visible,this._axisEnabled,this._axisVisible,this._zAxisVisible]);const f=(t,r,n)=>{const p=new tB(s,i,{fillColor:t,zIndex:void 0!==e.zIndex?e.zIndex+r:void 0,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return d(p,n),{setFillColor:e=>p.setFillColor(e),setPosOnWire:(e,t,s,i)=>p.setPosOnWire(e,t,s,i),setPosBetween:(e,t,s)=>p.setPosBetween(e,t,s),setText:e=>p.setText(e.replace(/ /g," "))}};this._lengthLabel=f(this._color,4,[this._visible,this._wireVisible,this._labelsVisible,this._clickable,this._axisEnabled,this._lengthLabelEnabled]),this._xAxisLabel=f("red",3,[this._visible,this._axisEnabled,this._axisVisible,this._xAxisVisible,this._labelsVisible,this._clickable,this._xLabelEnabled]),this._yAxisLabel=f("green",3,[this._visible,this._axisEnabled,this._axisVisible,this._yAxisVisible,this._labelsVisible,this._clickable,this._yLabelEnabled]),this._zAxisLabel=f("blue",3,[this._visible,this._axisEnabled,this._axisVisible,this._zAxisVisible,this._labelsVisible,this._clickable,this._zLabelEnabled]);const g=(t,r)=>{const n=new eB(s,t,i,{fillColor:this._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return n.on("worldPos",(()=>this._update())),d(n,r),n};this._originDot=g(t.origin,[this._visible,this._originVisible]),this._targetDot=g(t.target,[this._visible,this._targetVisible]),this._update()}_update(){if(!this._targetDot)return;const e=this._originDot.worldPos,t=this._targetDot.worldPos,s=this._axesBasis,i=R.subVec3(t,e,UB),r=R.transformVec3(s,i,i),n=this._useRotationAdjustment.get()&&Math.abs(i[1])>0,A=(s,i)=>{const r=this.plugin.viewer.scene.metrics,A=r.scale;r.unitsInfo[r.units].abbrev;const o=(s,i,r,n)=>{this._labelsOnWires.get()?s.setPosOnWire(i,r,0,this.plugin.labelMinAxisLength):s.setPosOnWire(e,t,35*n,0)};this._xAxisWire.setEnds(e,s),o(this._xAxisLabel,e,s,1),this._xAxisLabel.setText("X"+this._labelStringFormat(R.distVec3(e,s))),this._yAxisWire.setEnds(s,i),o(this._yAxisLabel,s,i,2),this._yAxisLabel.setText("Y"+this._labelStringFormat(R.distVec3(s,i))),this._zAxisWire.setEnds(i,t),o(this._zAxisLabel,i,t,3),this._zAxisLabel.setText((n?"":"Z")+this._labelStringFormat(R.distVec3(i,t))),this._lengthWire.setEnds(e,t),o(this._lengthLabel,e,t,0);const a=R.distVec3(e,t);this._length=a*A,this._lengthLabel.setText(this._labelStringFormat(a))};n?(TB[0]=e[0],TB[1]=t[1],TB[2]=e[2],A(e,TB)):(IB[0]=e[0]+s[0]*r[0],IB[1]=e[1]+s[4]*r[0],IB[2]=e[2]+s[8]*r[0],TB[0]=IB[0]+s[1]*r[1],TB[1]=IB[1]+s[5]*r[1],TB[2]=IB[2]+s[9]*r[1],A(IB,TB))}set axesBasis(e){this._axesBasis.set(e),this._update()}get axesBasis(){return this._axesBasis}set approximate(e){e=!1!==e,this._approximate!==e&&(this._approximate=e,this._update())}get approximate(){return this._approximate}get origin(){return this._originDot}get target(){return this._targetDot}get length(){return this._length}get color(){return this._color}set color(e){this._color=e,this._originDot.setFillColor(e),this._targetDot.setFillColor(e),this._lengthWire.setColor(e),this._lengthLabel.setFillColor(e)}set visible(e){this._visible.set(e)}get visible(){return this._visible.get()}set originVisible(e){this._originVisible.set(e)}get originVisible(){return this._originVisible.get()}set targetVisible(e){this._targetVisible.set(e)}get targetVisible(){return this._targetVisible.get()}set useRotationAdjustment(e){this._useRotationAdjustment.set(e),this._update()}get useRotationAdjustment(){return this._useRotationAdjustment.get()}set axisEnabled(e){this._axisEnabled.set(e)}get axisEnabled(){return this._axisEnabled.get()}set axisVisible(e){this._axisVisible.set(e)}get axisVisible(){return this._axisVisible.get()}set xAxisVisible(e){this._xAxisVisible.set(e)}get xAxisVisible(){return this._xAxisVisible.get()}set yAxisVisible(e){this._yAxisVisible.set(e)}get yAxisVisible(){return this._yAxisVisible.get()}set zAxisVisible(e){this._zAxisVisible.set(e)}get zAxisVisible(){return this._zAxisVisible.get()}set wireVisible(e){this._wireVisible.set(e)}get wireVisible(){return this._wireVisible.get()}set labelsVisible(e){this._labelsVisible.set(e)}get labelsVisible(){return this._labelsVisible.get()}set xLabelEnabled(e){this._xLabelEnabled.set(e)}get xLabelEnabled(){return this._xLabelEnabled.get()}set yLabelEnabled(e){this._yLabelEnabled.set(e)}get yLabelEnabled(){return this._yLabelEnabled.get()}set zLabelEnabled(e){this._zLabelEnabled.set(e)}get zLabelEnabled(){return this._zLabelEnabled.get()}set lengthLabelEnabled(e){this._lengthLabelEnabled.set(e)}get lengthLabelEnabled(){return this._lengthLabelEnabled.get()}set labelsOnWires(e){this._labelsOnWires.set(e),this._update()}get labelsOnWires(){return this._labelsOnWires.get()}setHighlighted(e){this._drawables.forEach((t=>t.setHighlighted(e)))}set clickable(e){this._clickable.set(!!e),this._drawables.forEach((e=>e.setClickable(this._clickable.get())))}get clickable(){return this._clickable.get()}set labelStringFormat(e){this._labelStringFormat=e,this._update()}get labelStringFormat(){return this._labelStringFormat}destroy(){this._cleanups.forEach((e=>e())),super.destroy()}}class SB extends ie{get active(){}set snapping(e){}get snapping(){return!0}activate(){}deactivate(){}reset(){}get currentMeasurement(){return null}destroy(){}}class DB extends SB{constructor(e,t={}){super(e.viewer.scene),this._canvasToPagePos=t.canvasToPagePos,this.pointerLens=t.pointerLens,this._active=!1,this._currentDistanceMeasurement=null,this._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},this._initMarkerDiv(),this._snapping=!1!==t.snapping,this._mouseState=0,this._attachPlugin(e,t)}_initMarkerDiv(){const e=document.createElement("div"),t=this.scene.canvas.canvas;t.parentNode.insertBefore(e,t),e.style.background="black",e.style.border="2px solid blue",e.style.borderRadius="10px",e.style.width="5px",e.style.height="5px",e.style.top="-200px",e.style.left="-200px",e.style.margin="0 0",e.style.zIndex="100",e.style.position="absolute",e.style.pointerEvents="none",this._markerDiv=e}_destroyMarkerDiv(){this._markerDiv&&(this._markerDiv.parentNode.removeChild(this._markerDiv),this._markerDiv=null)}_attachPlugin(e,t={}){this.distanceMeasurementsPlugin=e,this.plugin=e}get active(){return this._active}set snapping(e){this._snapping=e}get snapping(){return this._snapping}activate(){if(this._active)return;this._markerDiv||this._initMarkerDiv(),this.fire("activated",!0);const e=this.distanceMeasurementsPlugin,t=this.scene,s=e.viewer.cameraControl,i=t.canvas.canvas;t.input;let r=!1;const n=R.vec3(),A=R.vec2();let o,a;let l=null;this._mouseState=0;const c=R.vec2(),h=e=>{const t=e.snappedCanvasPos||e.canvasPos;if(r=!0,n.set(e.worldPos),A.set(e.canvasPos),0===this._mouseState){if(this._canvasToPagePos)this._canvasToPagePos(i,t,c),this._markerDiv.style.left=c[0]-5+"px",this._markerDiv.style.top=c[1]-5+"px";else{const e=R.vec2(t);Jb(i,this._markerDiv.parentNode,e),this._markerDiv.style.left=e[0]-5+"px",this._markerDiv.style.top=e[1]-5+"px"}this._markerDiv.style.background="pink",e.snappedToVertex||e.snappedToEdge?(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,this.pointerLens.snapped=!0),this._markerDiv.style.background="greenyellow",this._markerDiv.style.border="2px solid green"):(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.canvasPos,this.pointerLens.snapped=!1),this._markerDiv.style.background="pink",this._markerDiv.style.border="2px solid red"),l=e.entity}else this._markerDiv.style.left="-10000px",this._markerDiv.style.top="-10000px";i.style.cursor="pointer",this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.wireVisible=this._currentDistanceMeasurementInitState.wireVisible,this._currentDistanceMeasurement.axisVisible=this._currentDistanceMeasurementInitState.axisVisible&&this.distanceMeasurementsPlugin.defaultAxisVisible,this._currentDistanceMeasurement.xAxisVisible=this._currentDistanceMeasurementInitState.xAxisVisible&&this.distanceMeasurementsPlugin.defaultXAxisVisible,this._currentDistanceMeasurement.yAxisVisible=this._currentDistanceMeasurementInitState.yAxisVisible&&this.distanceMeasurementsPlugin.defaultYAxisVisible,this._currentDistanceMeasurement.zAxisVisible=this._currentDistanceMeasurementInitState.zAxisVisible&&this.distanceMeasurementsPlugin.defaultZAxisVisible,this._currentDistanceMeasurement.targetVisible=this._currentDistanceMeasurementInitState.targetVisible,this._currentDistanceMeasurement.target.worldPos=n.slice(),this._markerDiv.style.left="-10000px",this._markerDiv.style.top="-10000px")};this._onHoverSnapOrSurface=s.on("hoverSnapOrSurface",(e=>{this._snapping&&h(e)})),this._onHoverSurface=s.on("hoverSurface",(e=>{this._snapping||h(e)})),i.addEventListener("mousedown",this._onMouseDown=e=>{1===e.which&&(o=e.clientX,a=e.clientY)}),i.addEventListener("mouseup",this._onMouseUp=t=>{1===t.which&&(t.clientX>o+20||t.clientX<o-20||t.clientY>a+20||t.clientY<a-20||(this._currentDistanceMeasurement?r?(this._currentDistanceMeasurement.target.entity=l,l=null,this._currentDistanceMeasurement.clickable=!0,this.distanceMeasurementsPlugin.fire("measurementEnd",this._currentDistanceMeasurement),this._currentDistanceMeasurement=null):(this._currentDistanceMeasurement.destroy(),this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement=null,l=null):r&&(this._currentDistanceMeasurement=e.createMeasurement({id:R.createUUID(),origin:{worldPos:n.slice(),entity:l},target:{worldPos:n.slice(),entity:l},approximate:!0}),this._currentDistanceMeasurementInitState.axisVisible=this._currentDistanceMeasurement.axisVisible&&this.distanceMeasurementsPlugin.defaultAxisVisible,this._currentDistanceMeasurementInitState.xAxisVisible=this._currentDistanceMeasurement.xAxisVisible&&this.distanceMeasurementsPlugin.defaultXAxisVisible,this._currentDistanceMeasurementInitState.yAxisVisible=this._currentDistanceMeasurement.yAxisVisible&&this.distanceMeasurementsPlugin.defaultYAxisVisible,this._currentDistanceMeasurementInitState.zAxisVisible=this._currentDistanceMeasurement.zAxisVisible&&this.distanceMeasurementsPlugin.defaultZAxisVisible,this._currentDistanceMeasurementInitState.wireVisible=this._currentDistanceMeasurement.wireVisible,this._currentDistanceMeasurementInitState.targetVisible=this._currentDistanceMeasurement.targetVisible,this._currentDistanceMeasurement.clickable=!1,this._currentDistanceMeasurement.origin.entity=l,l=null,this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement))))});const u=e=>{this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos),r=!1,this._markerDiv.style.left="-100px",this._markerDiv.style.top="-100px",this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.axisVisible=!1),i.style.cursor="default"};this._onHoverSnapOrSurfaceOff=s.on("hoverSnapOrSurfaceOff",(e=>{this._snapping&&u(e)})),this._onHoverOff=s.on("hoverOff",(e=>{this._snapping||u(e)})),this._active=!0}deactivate(){if(!this._active)return;this.fire("activated",!1),this.pointerLens&&(this.pointerLens.visible=!1),this.reset();const e=this.scene.canvas.canvas;e.removeEventListener("mousedown",this._onMouseDown),e.removeEventListener("mouseup",this._onMouseUp);const t=this.distanceMeasurementsPlugin.viewer.cameraControl;t.off(this._onHoverSnapOrSurface),t.off(this._onHoverSurface),t.off(this._onHoverSnapOrSurfaceOff),t.off(this._onHoverOff),this._active=!1}reset(){this._active&&(this._destroyMarkerDiv(),this._initMarkerDiv(),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._mouseState=0)}get currentMeasurement(){return this._currentDistanceMeasurement}destroy(){this.deactivate(),super.destroy()}}const kB=R.vec2();class QB extends ie{constructor(e,t,s,i){const r=e.plugin.viewer;super(r.scene);const n=AB({viewer:r,handleMouseEvents:s,handleTouchEvents:i,pointerLens:t.pointerLens,dots:[e.origin,e.target],ray2WorldPos:(e,s,i)=>{const n=e=>{const t=r.scene.pick({canvasPos:i,snapToEdge:e,snapToVertex:e,pickSurface:!0});return t&&t.worldPos?t.worldPos:e&&n(!1)};return n(!!t.snapping)},onEnd:(e,t)=>{const s=!R.compareVec3(e,t.worldPos);return s&&this.fire("edited"),s}}),A=e.on("destroyed",n);this._deactivate=function(){e.off("destroyed",A),n()}}deactivate(){this._deactivate(),super.destroy()}}class RB{constructor(e={}){this.cacheBuster=!1!==e.cacheBuster}_cacheBusterURL(e){if(!this.cacheBuster)return e;const t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}getMetaModel(e,t,s){j.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}getGLTF(e,t,s){j.loadArraybuffer(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}getGLB(e,t,s){j.loadArraybuffer(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}getArrayBuffer(e,t,s,i){!function(e,t,s,i){var r=()=>{};s=s||r,i=i||r;const n=/^data:(.*?)(;base64)?,(.*)$/,A=t.match(n);if(A){const e=!!A[2];var o=A[3];o=window.decodeURIComponent(o),e&&(o=window.atob(o));try{const e=new ArrayBuffer(o.length),t=new Uint8Array(e);for(var a=0;a<o.length;a++)t[a]=o.charCodeAt(a);q.scheduleTask((function(){s(e)}))}catch(e){q.scheduleTask((function(){i(e)}))}}else{const r=function(e){var t=e.lastIndexOf("/");return 0!==t?e.substring(0,t+1):""}(e),n=r+t,A=new XMLHttpRequest;A.open("GET",n,!0),A.responseType="arraybuffer",A.onreadystatechange=function(){4===A.readyState&&(200===A.status?s(A.response):i("loadArrayBuffer error : "+A.response))},A.send(null)}}(this._cacheBusterURL(e),t,(e=>{s(e)}),(function(e){i(e)}))}}class OB{constructor(e){}load(e,t,s,i,r,n,A){!function(e,t,s,i,r,n,A){const o=e.viewer.scene.canvas.spinner;o.processes++;"glb"===t.split(".").pop()?e.dataSource.getGLB(t,(a=>{i.basePath=VB(t),LB(e,t,a,s,i,r,n,A),o.processes--}),(e=>{o.processes--,A(e)})):e.dataSource.getGLTF(t,(a=>{i.basePath=VB(t),LB(e,t,a,s,i,r,n,A),o.processes--}),(e=>{o.processes--,A(e)}))}(e,t,s,i=i||{},r,(function(){q.scheduleTask((function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1)})),n&&n()}),(function(t){e.error(t),A&&A(t),r.fire("error",t)}))}parse(e,t,s,i,r,n,A){LB(e,"",t,s,i=i||{},r,(function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1),n&&n()}),(function(e){r.error(e),r.fire("error",e),A&&A(e)}))}}function VB(e){const t=e.lastIndexOf("/");return 0!==t?e.substring(0,t+1):""}function LB(e,t,s,i,r,n,A,o){const a=e.viewer.scene.canvas.spinner;a.processes++,rl(s,hu,{baseUri:r.basePath}).then((s=>{const o=function(e,t){return(new yu).postProcess(e,t)}(s),l={src:t,entityId:r.entityId,metaModelJSON:i,autoMetaModel:r.autoMetaModel,globalizeObjectIds:r.globalizeObjectIds,metaObjects:[],loadBuffer:r.loadBuffer,basePath:r.basePath,handlenode:r.handlenode,backfaces:!!r.backfaces,gltfData:o,scene:n.scene,plugin:e,sceneModel:n,numObjects:0,nodes:[],nextId:0,log:t=>{e.log(t)}};!function(e){const t=e.gltfData.textures;if(t)for(let s=0,i=t.length;s<i;s++)HB(e,t[s])}(l),function(e){const t=e.gltfData.materials;if(t)for(let s=0,i=t.length;s<i;s++){const i=t[s];i._textureSetId=NB(e,i),i._attributes=GB(e,i)}}(l),r.autoMetaModel&&l.metaObjects.push({id:n.id,type:"Default",name:n.id}),jB(l),n.finalize(),r.autoMetaModel&&e.viewer.metaScene.createMetaModel(n.id,{metaObjects:l.metaObjects}),a.processes--,A()})).catch((e=>{o&&o(e)}))}function HB(e,t){if(!t.source||!t.source.image)return;const s="texture-"+e.nextId++;let i=1005;switch(t.sampler.minFilter){case 9728:i=1003;break;case 9729:i=1006;break;case 9984:i=1004;break;case 9985:i=1007;break;case 9986:i=1005;break;case 9987:i=1008}let r=1006;switch(t.sampler.magFilter){case 9728:r=1003;break;case 9729:r=1006}let n=1e3;switch(t.sampler.wrapS){case 33071:n=1001;break;case 33648:n=1002;break;case 10497:n=1e3}let A=1e3;switch(t.sampler.wrapT){case 33071:A=1001;break;case 33648:A=1002;break;case 10497:A=1e3}let o=1e3;switch(t.sampler.wrapR){case 33071:o=1001;break;case 33648:o=1002;break;case 10497:o=1e3}e.sceneModel.createTexture({id:s,image:t.source.image,flipY:!!t.flipY,minFilter:i,magFilter:r,wrapS:n,wrapT:A,wrapR:o,encoding:3001}),t._textureId=s}function NB(e,t){const s={};switch(t.normalTexture&&(s.normalTextureId=t.normalTexture.texture._textureId),t.occlusionTexture&&(s.occlusionTextureId=t.occlusionTexture.texture._textureId),t.emissiveTexture&&(s.emissiveTextureId=t.emissiveTexture.texture._textureId),t.alphaMode){case"OPAQUE":break;case"MASK":const e=t.alphaCutoff;s.alphaCutoff=void 0!==e?e:.5}const i=t.pbrMetallicRoughness;if(t.pbrMetallicRoughness){const r=t.pbrMetallicRoughness,n=r.baseColorTexture||r.colorTexture;n&&(n.texture?s.colorTextureId=n.texture._textureId:s.colorTextureId=e.gltfData.textures[n.index]._textureId),i.metallicRoughnessTexture&&(s.metallicRoughnessTextureId=i.metallicRoughnessTexture.texture._textureId)}const r=t.extensions;if(r){const t=r.KHR_materials_pbrSpecularGlossiness;if(t){t.specularTexture;const i=t.specularColorTexture;null!=i&&(s.colorTextureId=e.gltfData.textures[i.index]._textureId)}}return void 0!==s.normalTextureId||void 0!==s.occlusionTextureId||void 0!==s.emissiveTextureId||void 0!==s.colorTextureId||void 0!==s.metallicRoughnessTextureId?(s.id=`textureSet-${e.nextId++};`,e.sceneModel.createTextureSet(s),s.id):null}function GB(e,t){const s=t.extensions,i={color:new Float32Array([1,1,1,1]),opacity:1,metallic:0,roughness:1,doubleSided:!0};if(s){const e=s.KHR_materials_pbrSpecularGlossiness;if(e){const t=e.diffuseFactor;null!=t&&i.color.set(t)}const t=s.KHR_materials_common;if(t){const e=t.technique,s=t.values||{},r="BLINN"===e,n="PHONG"===e,A="LAMBERT"===e,o=s.diffuse;o&&(r||n||A)&&(j.isString(o)||i.color.set(o));const a=s.transparency;null!=a&&(i.opacity=a);const l=s.transparent;null!=l&&(i.opacity=l)}}const r=t.pbrMetallicRoughness;if(r){const e=r.baseColorFactor;e&&(i.color[0]=e[0],i.color[1]=e[1],i.color[2]=e[2],i.opacity=e[3]);const t=r.metallicFactor;null!=t&&(i.metallic=t);const s=r.roughnessFactor;null!=s&&(i.roughness=s)}return i.doubleSided=!1!==t.doubleSided,i}function jB(e){const t=e.gltfData,s=t.scene||t.scenes[0];if(!s)return void function(e,t){e.plugin.error(t)}(e,"glTF has no default scene");const i=s.nodes;if(!i)return;!function e(t){t.forEach((t=>{const s=t.mesh;s&&(s.instances||=0,s.instances+=1),t.children&&e(t.children)}))}(i);const r=[];let n=null;!function t(s,i,A){s.forEach((s=>{const o=s.name;let a=null!=o&&o||0===i&&"entity-"+e.nextId++;if(a){for(;e.sceneModel.objects[a];)a="entity-"+e.nextId++;r.push(n),n=[]}const l=function(e,t){let s;e.matrix&&(s=e.matrix,t=t?R.mulMat4(t,s,R.mat4()):s);e.translation&&(s=R.translationMat4v(e.translation),t=t?R.mulMat4(t,s,R.mat4()):s);e.rotation&&(s=R.quaternionToMat4(e.rotation),t=t?R.mulMat4(t,s,R.mat4()):s);e.scale&&(s=R.scalingMat4v(e.scale),t=t?R.mulMat4(t,s,R.mat4()):s);return t}(s,A);if(s.mesh&&function(e,t,s,i){const r=e.mesh;if(!r)return;const n=r.primitives.length;if(n>0)for(let e=0;e<n;e++){const n=r.primitives[e];if(n.mode<4)continue;const A={id:t.sceneModel.id+"."+t.numObjects++},o=n.material;o?(A.textureSetId=o._textureSetId,A.color=o._attributes.color,A.opacity=o._attributes.opacity,A.metallic=o._attributes.metallic,A.roughness=o._attributes.roughness):(A.color=new Float32Array([1,1,1]),A.opacity=1);const a=!1!==t.backfaces||o&&!1!==o.doubleSided;switch(n.mode){case 0:A.primitive="points";break;case 1:case 2:case 3:A.primitive="lines";break;default:A.primitive=a?"triangles":"solid"}const l=n.attributes.POSITION;if(!l)continue;A.localPositions=l.value,A.positions=new Float64Array(A.localPositions.length),n.attributes.NORMAL&&(A.normals=n.attributes.NORMAL.value),n.attributes.TEXCOORD_0&&(A.uv=n.attributes.TEXCOORD_0.value),n.indices&&(A.indices=n.indices.value),s?R.transformPositions3(s,A.localPositions,A.positions):A.positions.set(A.localPositions);const c=R.vec3();pt(A.positions,A.positions,c)&&(A.origin=c),t.sceneModel.createMesh(A),i.push(A.id)}}(s,e,l,n),s.children&&t(s.children,i+1,l),a){if(n.length>0){const t=e.globalizeObjectIds?R.globalizeObjectId(e.sceneModel.id,a):a;e.sceneModel.createEntity({id:t,meshIds:n,isObject:!0}),e.autoMetaModel&&e.metaObjects.push({id:t,type:"Default",name:t,parent:e.sceneModel.id})}n=r.pop()}}))}(i,0,null)}const WB={DEFAULT:{}};class zB extends mn{constructor(e,t={}){super("GLTFLoader",e,t),this._sceneModelLoader=new OB(this,t),this.dataSource=t.dataSource,this.objectDefaults=t.objectDefaults}set dataSource(e){this._dataSource=e||new RB}get dataSource(){return this._dataSource}set objectDefaults(e){this._objectDefaults=e||WB}get objectDefaults(){return this._objectDefaults}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new jr(this.viewer.scene,j.apply(e,{isModel:!0,dtxEnabled:e.dtxEnabled})),s=t.id;if(!e.src&&!e.gltf)return this.error("load() param expected: src or gltf"),t;if(e.metaModelSrc||e.metaModelJSON){const i=i=>{this.viewer.metaScene.createMetaModel(s,i,{}),this.viewer.scene.canvas.spinner.processes--,e.src?this._sceneModelLoader.load(this,e.src,i,e,t):this._sceneModelLoader.parse(this,e.gltf,i,e,t)};if(e.metaModelSrc){const t=e.metaModelSrc;this.viewer.scene.canvas.spinner.processes++,this._dataSource.getMetaModel(t,(e=>{this.viewer.scene.canvas.spinner.processes--,i(e)}),(e=>{this.error(`load(): Failed to load model metadata for model '${s} from '${t}' - ${e}`),this.viewer.scene.canvas.spinner.processes--}))}else e.metaModelJSON&&i(e.metaModelJSON)}else e.src?this._sceneModelLoader.load(this,e.src,null,e,t):this._sceneModelLoader.parse(this,e.gltf,null,e,t);return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(s)})),t}destroy(){super.destroy()}}function XB(e,t,s={}){const i="lightgrey",r=s.hoverColor||"rgba(0,0,0,0.4)",n=s.textColor||"black",A=s.canvasElement||document.body,o=500,a=o+o/3,l=a/24,c=[{boundary:[6,6,6,6],color:s.frontColor||s.color||"#55FF55"},{boundary:[18,6,6,6],color:s.backColor||s.color||"#55FF55"},{boundary:[12,6,6,6],color:s.rightColor||s.color||"#FF5555"},{boundary:[0,6,6,6],color:s.leftColor||s.color||"#FF5555"},{boundary:[6,0,6,6],color:s.topColor||s.color||"#7777FF"},{boundary:[6,12,6,6],color:s.bottomColor||s.color||"#7777FF"}],h=[{label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,1,0],up:[0,0,1]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,-1,0],up:[0,0,1]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,0,1]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,0,1]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,0,1],up:[0,-1,0]},{boundaries:[[7,5,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,0,-1],up:[1,0,1]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-1,-1],up:[0,-1,1]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,0,-1],up:[-1,0,1]},{boundaries:[[7,11,4,2]],dir:[0,1,1],up:[0,-1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,0,1],up:[-1,0,1]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,-1,1],up:[0,1,1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,0,1],up:[1,0,1]},{boundaries:[[5,7,2,4]],dir:[1,1,0],up:[0,0,1]},{boundaries:[[11,7,2,4]],dir:[-1,1,0],up:[0,0,1]},{boundaries:[[17,7,2,4]],dir:[-1,-1,0],up:[0,0,1]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,-1,0],up:[0,0,1]},{boundaries:[[5,11,2,2]],dir:[1,1,1],up:[-1,-1,1]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[1,-1,1],up:[-1,1,1]},{boundaries:[[5,5,2,2]],dir:[1,1,-1],up:[1,1,1]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-1,-1,1],up:[1,1,1]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-1,-1,-1],up:[-1,-1,1]},{boundaries:[[11,11,2,2]],dir:[-1,1,1],up:[1,-1,1]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[1,-1,-1],up:[1,-1,1]},{boundaries:[[11,5,2,2]],dir:[-1,1,-1],up:[-1,1,1]}];s.frontColor||s.color,s.backColor||s.color,s.rightColor||s.color,s.leftColor||s.color,s.topColor||s.color,s.bottomColor||s.color;const u=[{yUp:"",label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,0,1],up:[0,1,0]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,1,0]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,1,0]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,-1,0],up:[0,0,-1]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,1,0],up:[0,0,1]},{boundaries:[[7,5,4,2]],dir:[0,-.7071,-.7071],up:[0,.7071,-.7071]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,-1,0],up:[1,1,0]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-.7071,.7071],up:[0,.7071,.7071]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,-1,0],up:[-1,1,0]},{boundaries:[[7,11,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,1,0],up:[-1,1,0]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,1,1],up:[0,1,-1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,1,0],up:[1,1,0]},{boundaries:[[5,7,2,4]],dir:[1,0,-1],up:[0,1,0]},{boundaries:[[11,7,2,4]],dir:[-1,0,-1],up:[0,1,0]},{boundaries:[[17,7,2,4]],dir:[-1,0,1],up:[0,1,0]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,0,1],up:[0,1,0]},{boundaries:[[5,11,2,2]],dir:[.5,.7071,-.5],up:[-.5,.7071,.5]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[.5,.7071,.5],up:[-.5,.7071,-.5]},{boundaries:[[5,5,2,2]],dir:[.5,-.7071,-.5],up:[.5,.7071,-.5]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-.5,.7071,.5],up:[.5,.7071,-.5]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-.5,-.7071,.5],up:[-.5,.7071,.5]},{boundaries:[[11,11,2,2]],dir:[-.5,.7071,-.5],up:[.5,.7071,.5]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[.5,-.7071,.5],up:[.5,.7071,.5]},{boundaries:[[11,5,2,2]],dir:[-.5,-.7071,-.5],up:[-.5,.7071,-.5]}];for(let e=0,t=h.length;e<t;e++)R.normalizeVec3(h[e].dir,h[e].dir),R.normalizeVec3(h[e].up,h[e].up);for(let e=0,t=u.length;e<t;e++)R.normalizeVec3(u[e].dir,u[e].dir),R.normalizeVec3(u[e].up,u[e].up);var d=u;this._textureCanvas=document.createElement("canvas"),this._textureCanvas.width=a,this._textureCanvas.height=o,this._textureCanvas.style.width=a+"px",this._textureCanvas.style.height="500px",this._textureCanvas.style.padding="0",this._textureCanvas.style.margin="0",this._textureCanvas.style.top="0",this._textureCanvas.style.background=i,this._textureCanvas.style.position="absolute",this._textureCanvas.style.opacity="1.0",this._textureCanvas.style.visibility="hidden",this._textureCanvas.style["z-index"]=2e6,A.appendChild(this._textureCanvas);const p=this._textureCanvas.getContext("2d");let f=!1;function g(){for(let e=0,t=c.length;e<t;e++){const t=c[e],s=t.boundary,i=Math.round(s[0]*l),r=Math.round(s[1]*l),n=Math.round(s[2]*l),A=Math.round(s[3]*l);p.fillStyle=t.color,p.fillRect(i,r,n,A)}for(let t=0,a=d.length;t<a;t++){let a,c,h,u;const f=d[t],g=f.boundaries;for(var e=0,s=g.length;e<s;e++){const t=g[e];a=Math.round(t[0]*l),c=Math.round(t[1]*l),h=Math.round(t[2]*l),u=Math.round(t[3]*l),f.highlighted&&(p.fillStyle=f.highlighted?r:f.color||i,p.fillRect(a,c,h,u))}if(f.label){p.fillStyle=n,p.font="60px sans-serif",p.textAlign="center";var A=a+.5*h,o=c+.7*u;p.fillText(m(f.label),A,o,80)}}t.glRedraw()}const m=function(){const t={"NavCube.front":"NavCube.front","NavCube.back":"NavCube.back","NavCube.right":"NavCube.right","NavCube.left":"NavCube.left","NavCube.top":"NavCube.top","NavCube.bottom":"NavCube.bottom"},s={"NavCube.front":"NavCube.front","NavCube.back":"NavCube.back","NavCube.right":"NavCube.right","NavCube.left":"NavCube.left","NavCube.top":"NavCube.top","NavCube.bottom":"NavCube.bottom"},i={"NavCube.front":"FRONT","NavCube.back":"BACK","NavCube.right":"RIGHT","NavCube.left":"LEFT","NavCube.top":"TOP","NavCube.bottom":"BOTTOM"};return function(r){const n=f?s:t,A=n?n[r]:null;return A?e.localeService.translate(A)||i[A]||A:r}}();this.setZUp=function(){f=!0,d=h,this.clear()},this.setYUp=function(){f=!1,d=u,this.clear()},this.clear=function(){p.fillStyle=i,p.fillRect(0,0,a,o);for(var e=0,t=d.length;e<t;e++){d[e].highlighted=!1}g()},this.getArea=function(e){const t=e[0]*a,s=o-e[1]*o;for(var i=0,r=d.length;i<r;i++){const e=d[i].boundaries;for(var n=0,A=e.length;n<A;n++){const r=e[n];if(t>=r[0]*l&&t<=(r[0]+r[2])*l&&s>=r[1]*l&&s<=(r[1]+r[3])*l)return i}}return-1},this.setAreaHighlighted=function(e,t){var s=d[e];if(!s)throw"Area not found: "+e;s.highlighted=!!t,g()},this.getAreaDir=function(e){var t=d[e];if(!t)throw"Unknown area: "+e;return t.dir},this.getAreaUp=function(e){var t=d[e];if(!t)throw"Unknown area: "+e;return t.up},this.getImage=function(){return this._textureCanvas},this.destroy=function(){this._textureCanvas&&(this._textureCanvas.parentNode.removeChild(this._textureCanvas),this._textureCanvas=null)}}const KB=R.vec3(),ZB=R.vec3();R.mat4();const JB=R.vec3();class YB{load(e,t,s={}){var i=e.scene.canvas.spinner;i.processes++,$B(e,t,(function(t){!function(e,t,s){for(var i=t.basePath,r=Object.keys(t.materialLibraries),n=r.length,A=0,o=n;A<o;A++)ey(e,i,i+r[A],(function(){0==--n&&s()}))}(e,t,(function(){sy(e,t),i.processes--,q.scheduleTask((function(){e.fire("loaded",!0,!1)}))}))}))}parse(e,t,s,i){if(t){var r=qB(e,t,null);s&&ty(e,s,i),sy(e,r),e.src=null,e.fire("loaded",!0,!1)}else this.warn("load() param expected: objText")}}var $B=function(e,t,s){iy(t,(function(i){var r=qB(e,i,t);s(r)}),(function(t){e.error(t)}))},qB=function(){const e={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /};return function(s,i,r){var n,A,o={src:r=r||"",basePath:(n=r,A=n.lastIndexOf("/"),-1===A?n:n.substring(0,A+1)),objects:[],object:{},positions:[],normals:[],uv:[],materialLibraries:{}};t(o,"",!1),-1!==i.indexOf("\r\n")&&(i=i.replace("\r\n","\n"));for(var a=i.split("\n"),l="",u="",d="",p=[],f="function"==typeof"".trimLeft,g=0,m=a.length;g<m;g++)if(l=a[g],0!==(l=f?l.trimLeft():l.trim()).length&&"#"!==(u=l.charAt(0)))if("v"===u)if(" "===(d=l.charAt(1))&&null!==(p=e.vertex_pattern.exec(l)))o.positions.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3]));else if("n"===d&&null!==(p=e.normal_pattern.exec(l)))o.normals.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3]));else{if("t"!==d||null===(p=e.uv_pattern.exec(l)))return void s.error("Unexpected vertex/normal/uv line: '"+l+"'");o.uv.push(parseFloat(p[1]),parseFloat(p[2]))}else if("f"===u)if(null!==(p=e.face_vertex_uv_normal.exec(l)))c(o,p[1],p[4],p[7],p[10],p[2],p[5],p[8],p[11],p[3],p[6],p[9],p[12]);else if(null!==(p=e.face_vertex_uv.exec(l)))c(o,p[1],p[3],p[5],p[7],p[2],p[4],p[6],p[8]);else if(null!==(p=e.face_vertex_normal.exec(l)))c(o,p[1],p[3],p[5],p[7],void 0,void 0,void 0,void 0,p[2],p[4],p[6],p[8]);else{if(null===(p=e.face_vertex.exec(l)))return void s.error("Unexpected face line: '"+l+"'");c(o,p[1],p[2],p[3],p[4])}else if("l"===u){var _=l.substring(1).trim().split(" "),b=[],B=[];if(-1===l.indexOf("/"))b=_;else for(var y=0,w=_.length;y<w;y++){var v=_[y].split("/");""!==v[0]&&b.push(v[0]),""!==v[1]&&B.push(v[1])}h(o,b,B)}else if(null!==(p=e.object_pattern.exec(l))){t(o,C=p[0].substr(1).trim(),!0)}else if(e.material_use_pattern.test(l)){var C=l.substring(7).trim();o.object.material.id=C}else if(e.material_library_pattern.test(l))o.materialLibraries[l.substring(7).trim()]=!0;else{if(null===(p=e.smoothing_pattern.exec(l))){if("\0"===l)continue;return void s.error("Unexpected line: '"+l+"'")}var M=p[1].trim().toLowerCase();o.object.material.smooth="1"===M||"on"===M}return o};function t(e,t,s){if(e.object&&!1===e.object.fromDeclaration)return e.object.id=t,void(e.object.fromDeclaration=!1!==s);e.object={id:t||"",geometry:{positions:[],normals:[],uv:[]},material:{id:"",smooth:!0},fromDeclaration:!1!==s},e.objects.push(e.object)}function s(e,t){var s=parseInt(e,10);return 3*(s>=0?s-1:s+t/3)}function i(e,t){var s=parseInt(e,10);return 3*(s>=0?s-1:s+t/3)}function r(e,t){var s=parseInt(e,10);return 2*(s>=0?s-1:s+t/2)}function n(e,t,s,i){var r=e.positions,n=e.object.geometry.positions;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[s+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2])}function A(e,t){var s=e.positions,i=e.object.geometry.positions;i.push(s[t+0]),i.push(s[t+1]),i.push(s[t+2])}function o(e,t,s,i){var r=e.normals,n=e.object.geometry.normals;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[s+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2])}function a(e,t,s,i){var r=e.uv,n=e.object.geometry.uv;n.push(r[t+0]),n.push(r[t+1]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[i+0]),n.push(r[i+1])}function l(e,t){var s=e.uv,i=e.object.geometry.uv;i.push(s[t+0]),i.push(s[t+1])}function c(e,t,A,l,c,h,u,d,p,f,g,m,_){var b,B=e.positions.length,y=s(t,B),w=s(A,B),v=s(l,B);if(void 0===c?n(e,y,w,v):(n(e,y,w,b=s(c,B)),n(e,w,v,b)),void 0!==h){var C=e.uv.length;y=r(h,C),w=r(u,C),v=r(d,C),void 0===c?a(e,y,w,v):(a(e,y,w,b=r(p,C)),a(e,w,v,b))}if(void 0!==f){var M=e.normals.length;y=i(f,M),w=f===g?y:i(g,M),v=f===m?y:i(m,M),void 0===c?o(e,y,w,v):(o(e,y,w,b=i(_,M)),o(e,w,v,b))}}function h(e,t,i){e.object.geometry.type="Line";for(var n=e.positions.length,o=e.uv.length,a=0,c=t.length;a<c;a++)A(e,s(t[a],n));for(var h=0,u=i.length;h<u;h++)l(e,r(i[h],o))}}();var ey=function(e,t,s,i){iy(s,(function(s){ty(e,s,t),i()}),(function(t){e.error(t),i()}))},ty=function(){var e=/\s+/;return function(e,r,n){var A,o,a,l,c,h=r.split("\n"),u={id:"Default"},d=!1;n=n||"";for(var p=0;p<h.length;p++)if(0!==(A=h[p].trim()).length&&"#"!==A.charAt(0))switch(a=(a=(o=A.indexOf(" "))>=0?A.substring(0,o):A).toLowerCase(),l=(l=o>=0?A.substring(o+1):"").trim(),a.toLowerCase()){case"newmtl":s(e,u),u={id:l},d=!0;break;case"ka":u.ambient=i(l);break;case"kd":u.diffuse=i(l);break;case"ks":u.specular=i(l);break;case"map_kd":u.diffuseMap||(u.diffuseMap=t(e,n,l,"sRGB"));break;case"map_ks":u.specularMap||(u.specularMap=t(e,n,l,"linear"));break;case"map_bump":case"bump":u.normalMap||(u.normalMap=t(e,n,l));break;case"ns":u.shininess=parseFloat(l);break;case"d":(c=parseFloat(l))<1&&(u.alpha=c,u.alphaMode="blend");break;case"tr":(c=parseFloat(l))>0&&(u.alpha=1-c,u.alphaMode="blend")}d&&s(e,u)};function t(e,t,s,i){var r={},n=s.split(/\s+/),A=n.indexOf("-bm");return A>=0&&n.splice(A,2),(A=n.indexOf("-s"))>=0&&(r.scale=[parseFloat(n[A+1]),parseFloat(n[A+2])],n.splice(A,4)),(A=n.indexOf("-o"))>=0&&(r.translate=[parseFloat(n[A+1]),parseFloat(n[A+2])],n.splice(A,4)),r.src=t+n.join(" ").trim(),r.flipY=!0,r.encoding=i||"linear",new es(e,r).id}function s(e,t){new jt(e,t)}function i(t){var s=t.split(e,3);return[parseFloat(s[0]),parseFloat(s[1]),parseFloat(s[2])]}}();function sy(e,t){for(var s=0,i=t.objects.length;s<i;s++){var r=t.objects[s],n=r.geometry;if(n.type,0===n.positions.length)continue;var A={primitive:"triangles",compressGeometry:!1};A.positions=n.positions,n.normals.length>0&&(A.normals=n.normals),n.uv.length>0&&(A.uv=n.uv);for(var o=new Array(A.positions.length/3),a=0;a<o.length;a++)o[a]=a;A.indices=o;const i=JB;pt(n.positions,n.positions,i);var l,c=new Le(e,A),h=r.material.id;h&&""!==h?(l=e.scene.components[h])||e.error("Material not found: "+h):l=new jt(e,{diffuse:[.6,.6,.6],backfaces:!0});var u=new Ot(e,{id:e.id+"#"+r.id,origin:0!==i[0]||0!==i[1]||0!==i[2]?i:null,isObject:!0,geometry:c,material:l,pickable:!0});e.addChild(u)}}function iy(e,t,s){var i=new XMLHttpRequest;i.open("GET",e,!0),i.addEventListener("load",(function(e){var i=e.target.response;200===this.status?t&&t(i):0===this.status?(console.warn("loadFile: HTTP Status 0 received."),t&&t(i)):s&&s(e)}),!1),i.addEventListener("error",(function(e){s&&s(e)}),!1),i.send(null)}class ry{constructor(e){const t=e.cameraControl,s=e.scene,i=s.canvas.canvas,r=!1,n=.09,A=.01,o=new ct(s,{position:[0,0,0],scale:[5,5,5],isObject:!1}),a=R.vec3();this._setPosition=function(){const e=R.vec3(),t=R.vec3();return function(s){a.set(s),dt(s,e,t),o.origin=e,o.position=t}}(),this._setQuaternion=e=>{o.quaternion=e};const l=(e,t)=>new Le(o,Xe({radiusTop:.001,radiusBottom:e,radialSegments:32,heightSegments:1,height:t,openEnded:!1})),c=(e,t,s)=>new Le(o,Xe({radiusTop:e,radiusBottom:e,radialSegments:s,heightSegments:1,height:t,openEnded:!1})),h=(e,t,s)=>new Le(o,Ye({radius:.8,tube:e,radialSegments:64,tubeSegments:s,arc:2*Math.PI*t})),u={curve:h(A,.25,14),curveHandle:h(n,.25,14),hoop:h(A,1,8),arrowHead:l(.07,.2),arrowHeadBig:l(.09,.25),arrowHeadHandle:c(n,.37,8),axis:c(A,1,20),axisHandle:c(n,1,20)},d=(e,t)=>new ds(o,{edges:!1,fill:!0,fillColor:e,fillAlpha:t}),p=new jt(o,{diffuse:[1,1,0],alpha:0,alphaMode:"blend"}),f={},g=(e,t)=>{R.mulVec3Scalar(e,-1,R.vec3());const n=(e=>new jt(o,{diffuse:e,emissive:e,ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}))(e),A=R.quaternionToRotationMat4(t,R.identityMat4());R.mulMat4(R.rotationMat4v(Math.PI,[0,1,0],R.mat4()),A,A);const l=R.scaleMat4v([.6,.6,.6],R.identityMat4()),c=(e,t)=>{const s=R.translateMat4v(e,R.identityMat4()),i=R.identityMat4();return R.mulMat4(s,t,i),R.mulMat4(A,i,i),R.mulMat4(i,l,R.identityMat4())},h=o.addChild(new Ot(o,{geometry:u.curve,material:n,matrix:A,pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isUI:!0,isObject:!1}),r),g=o.addChild(new Ot(o,{geometry:u.curveHandle,material:p,matrix:A,pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isUI:!0,isObject:!1}),r),m=o.addChild(new Ot(o,{geometry:u.arrowHead,material:n,matrix:c([.8,.07,0],R.rotationMat4v(180*R.DEGTORAD,[0,0,1],R.identityMat4())),pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),_=o.addChild(new Ot(o,{geometry:u.arrowHead,material:n,matrix:c([.07,.8,0],R.rotationMat4v(90*R.DEGTORAD,[0,0,1],R.identityMat4())),pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),b=o.addChild(new Ot(o,{geometry:u.hoop,material:n,highlighted:!0,highlightMaterial:d(e,.6),matrix:A,pickable:!1,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),B=R.quaternionToRotationMat4(R.vec3PairToQuaternion([0,1,0],e),R.identityMat4());R.mulMat4(R.rotationMat4v(Math.PI,[0,1,0],R.mat4()),B,B);const y=e=>R.mulMat4(B,R.translateMat4c(0,e,0,R.identityMat4()),R.identityMat4()),w=y(1.1),v=y(.5),C=o.addChild(new Ot(o,{geometry:u.arrowHead,material:n,matrix:w,pickable:!1,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),M=o.addChild(new Ot(o,{geometry:u.arrowHeadHandle,material:p,matrix:w,pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),E=o.addChild(new Ot(o,{geometry:u.axis,material:n,matrix:v,pickable:!1,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),F=o.addChild(new Ot(o,{geometry:u.axisHandle,material:p,matrix:v,pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),x=o.addChild(new Ot(o,{geometry:u.arrowHeadBig,material:n,matrix:w,pickable:!1,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),U=(e,t)=>R.vec3ApplyQuaternion(o.quaternion,e,t),I=function(){const t=R.vec3(),r=R.vec3(),n=R.vec3();return(A,o)=>{U(e,t);const l=a,c=t;R.canvasPosToWorldRay(i,s.camera.viewMatrix,s.camera.projMatrix,s.camera.projection,A,r,n);const h=R.dotVec3(c,n),u=R.subVec3(r,l,o),d=R.dotVec3(u,c),p=R.dotVec3(u,n),f=1-h*h;if(Math.abs(f)>1e-10){const e=(d-h*p)/f;return R.addVec3(l,R.mulVec3Scalar(c,e,o),o),!0}return!1}}(),T=R.vec3(),P=R.vec3();f[M.id]=f[F.id]={setActivated:e=>x.visible=e,initDragAction:e=>I(e,T)&&R.subVec3(T,a,T)&&(e=>{I(e,P)&&(R.subVec3(P,T,P),this._setPosition(P),this._handlers&&this._handlers.onPosition(P))})},f[g.id]={setActivated:e=>b.visible=e,initDragAction:t=>{const i=function(){const t=s.camera.projectWorldPos(a);U(e,P),R.transformVec3(s.camera.normalMatrix,P,P);const i=Math.sign(P[2]);return e=>{const s=e[0]-t[0],r=e[1]-t[1];return i*Math.atan2(-r,s)}}();let r=i(t);return t=>{const s=i(t);o.rotate(e,180*(s-r)/Math.PI),this._handlers&&this._handlers.onQuaternion(o.quaternion),r=s}}};let S=!1,D=!1,k=!1;const Q=()=>{const e=k&&S;M.visible=F.visible=C.visible=E.visible=!!e,e||(x.visible=!1)},O=()=>{const e=k&&D;g.visible=h.visible=m.visible=_.visible=!!e,e||(b.visible=!1)};return{setPositionActive:e=>{S=e,Q()},setRotationActive:e=>{D=e,O()},set visible(e){k=e,Q(),O()}}};this._displayMeshes={center:o.addChild(new Ot(o,{geometry:new Le(o,Je({radius:.05})),material:new jt(o,{diffuse:[0,0,0],emissive:[0,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80}),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),r),x:g([1,0,0],R.vec3PairToQuaternion([1,0,0],[0,0,1])),y:g([0,1,0],R.eulerToQuaternion([90,0,0],"XYZ")),z:g([0,0,1],R.identityQuaternion())};const m=[];{let e=-1;const t=e=>{o.scale[0]!==e&&(o.scale=[e,e,e],this._handlers&&this._handlers.onScreenScale&&this._handlers.onScreenScale(o.scale))},i=s.on("tick",(()=>{const i=s.camera,r=Math.abs(R.distVec3(i.eye,a));"perspective"===i.projection?r!==e&&t(.07*r*Math.tan(i.perspective.fov*R.DEGTORAD)):"ortho"===i.projection&&t(i.ortho.scale/10),e=r}));m.push((()=>s.off(i)))}{let e=null,r=null;m.push((()=>{r&&r.cleanup()}));const n=R.vec2(),A=(e,t)=>{t[0]=e.pageX,t[1]=e.pageY,Jb(i.ownerDocument.documentElement,i,t)},o=e=>{A(e,n);const t=s.pick({canvasPos:n}),i=t&&t.entity,r=i&&i.id;return r in f&&f[r]},a=(e,s)=>{const i=o(s(e));if(i){r&&r.cleanup();const e=i.initDragAction(n);return e&&(t.pointerEnabled=!1,i.setActivated(!0),r={onChange:t=>{const i=s(t);i&&(A(i,n),e(n))},cleanup:function(){r=null,t.pointerEnabled=!0,i.setActivated(!1)}}),!!e}return!1},l=(e,t)=>{i.addEventListener(e,t),m.push((()=>i.removeEventListener(e,t)))},c=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()};l("mousedown",(e=>{1===e.which&&a(e,(e=>1===e.which&&e))&&c(e)})),l("mousemove",(t=>{if(r)r.onChange(t),c(t);else{e&&e();const s=o(t);s?(s.setActivated(!0),e=()=>s.setActivated(!1)):e=null}})),l("mouseup",(e=>{r&&(r.onChange(e),r.cleanup())})),l("touchstart",(e=>{if(e.preventDefault(),1===e.touches.length){const t=e.touches[0].identifier;a(e,(e=>[...e.changedTouches].find((e=>e.identifier===t))))&&c(e)}})),l("touchmove",(e=>{r&&(r.onChange(e),c(e))})),l("touchend",(e=>{r&&(r.onChange(e),r.cleanup())}))}this.__destroy=()=>{m.forEach((e=>e())),o.destroy();for(let e in f)delete f[e]}}destroy(){this.__destroy()}setHandlers(e){Object.values(this._displayMeshes).forEach((t=>t.visible=!!e)),this._handlers=e,this._displayMeshes.x.setPositionActive(e&&e.onPosition),this._displayMeshes.y.setPositionActive(e&&e.onPosition),this._displayMeshes.z.setPositionActive(e&&e.onPosition),this._displayMeshes.x.setRotationActive(e&&e.onQuaternion),this._displayMeshes.y.setRotationActive(e&&e.onQuaternion),this._displayMeshes.z.setRotationActive(e&&e.onQuaternion)}setPosition(e){this._setPosition(e)}setQuaternion(e){this._setQuaternion(e)}}class ny{constructor(e,t,s){this.id=s.id,this._sectionPlane=s,this._mesh=new Ot(t,{id:s.id,geometry:new Le(t,We({xSize:.5,ySize:.5,zSize:.001})),material:new jt(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new fs(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new ds(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new ds(t,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});{const e=R.vec3([0,0,0]),t=R.vec3(),s=R.vec3([0,0,1]),i=R.vec4(4),r=R.vec3(),n=()=>{const n=this._sectionPlane.scene.center,A=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];R.subVec3(n,this._sectionPlane.pos,e);const o=-R.dotVec3(A,e);R.normalizeVec3(A),R.mulVec3Scalar(A,o,t);const a=R.vec3PairToQuaternion(s,this._sectionPlane.dir,i);r[0]=.1*t[0],r[1]=.1*t[1],r[2]=.1*t[2],this._mesh.quaternion=a,this._mesh.position=r};this._onSectionPlanePos=this._sectionPlane.on("pos",n),this._onSectionPlaneDir=this._sectionPlane.on("dir",n)}this._highlighted=!1,this._selected=!1}setHighlighted(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}getHighlighted(){return this._highlighted}setSelected(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}getSelected(){return this._selected}destroy(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}class Ay{constructor(e,t){if(!(t.onHoverEnterPlane&&t.onHoverLeavePlane&&t.onClickedNothing&&t.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=e,this._viewer=e.viewer,this._onHoverEnterPlane=t.onHoverEnterPlane,this._onHoverLeavePlane=t.onHoverLeavePlane,this._onClickedNothing=t.onClickedNothing,this._onClickedPlane=t.onClickedPlane,this._visible=!0,this._planes={},this._canvas=t.overviewCanvas,this._scene=new gA(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new Zr(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Zr(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Zr(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;{const e=this._scene.camera,t=R.rotationMat4c(-90*R.DEGTORAD,1,0,0),s=R.vec3(),i=R.vec3(),r=R.vec3();this._synchCamera=()=>{const n=this._viewer.camera.eye,A=this._viewer.camera.look,o=this._viewer.camera.up;R.mulVec3Scalar(R.normalizeVec3(R.subVec3(n,A,s)),7),this._zUp?(R.transformVec3(t,s,i),R.transformVec3(t,o,r),e.look=[0,0,0],e.eye=R.transformVec3(t,s,i),e.up=R.transformPoint3(t,o,r)):(e.look=[0,0,0],e.eye=s,e.up=o)}}this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(e=>{this._scene.camera.perspective.fov=e}));var s=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!s||t.entity.id!==s.id){if(s){this._planes[s.id]&&this._onHoverLeavePlane(s.id)}s=t.entity;this._planes[s.id]&&this._onHoverEnterPlane(s.id)}}else s&&(this._onHoverLeavePlane(s.id),s=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(s){this._planes[s.id]&&this._onClickedPlane(s.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{s&&(this._onHoverLeavePlane(s.id),s=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new ny(this,this._scene,e)}setPlaneHighlighted(e,t){const s=this._planes[e];s&&s.setHighlighted(t)}setPlaneSelected(e,t){const s=this._planes[e];s&&s.setSelected(t)}removeSectionPlane(e){const t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}setVisible(e=!0){this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}getVisible(){return this._visible}destroy(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}const oy=R.AABB3(),ay=R.vec3();class ly{constructor(e,t,s,i,r,n){this.plugin=e,this.storeyId=r,this.modelId=i,this.storeyAABB=s.slice(),this.aabb=this.storeyAABB,this.modelAABB=t.slice(),this.numObjects=n}}class cy{constructor(e,t,s,i,r,n){this.storeyId=e,this.imageData=t,this.format=s,this.width=i,this.height=r}}const hy=R.vec3(),uy=R.mat4();const dy=new Float64Array([0,0,1]),py=new Float64Array(4);class fy{constructor(e){this.id=null,this._viewer=e.viewer,this._plugin=e,this._visible=!1,this._pos=R.vec3(),this._origin=R.vec3(),this._rtcPos=R.vec3(),this._baseDir=R.vec3(),this._rootNode=null,this._displayMeshes=null,this._affordanceMeshes=null,this._ignoreNextSectionPlaneDirUpdate=!1,this._createNodes(),this._bindEvents()}_setSectionPlane(e){this._sectionPlane&&(this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._onSectionPlanePos=null,this._onSectionPlaneDir=null,this._sectionPlane=null),e&&(this.id=e.id,this._setPos(e.pos),this._setDir(e.dir),this._sectionPlane=e,this._onSectionPlanePos=e.on("pos",(()=>{this._setPos(this._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(()=>{this._ignoreNextSectionPlaneDirUpdate?this._ignoreNextSectionPlaneDirUpdate=!1:this._setDir(this._sectionPlane.dir)})))}get sectionPlane(){return this._sectionPlane}_setPos(e){this._pos.set(e),dt(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}_setDir(e){this._baseDir.set(e),this._rootNode.quaternion=R.vec3PairToQuaternion(dy,e,py)}_setSectionPlaneDir(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}setVisible(e=!0){if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}getVisible(){return this._visible}setCulled(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}_createNodes(){const e=!1,t=this._viewer.scene,s=.01;this._rootNode=new ct(t,{position:[0,0,0],scale:[5,5,5]});const i=this._rootNode,r={arrowHead:new Le(i,Xe({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Le(i,Xe({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),axis:new Le(i,Xe({radiusTop:s,radiusBottom:s,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},n={red:new jt(i,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),green:new jt(i,{diffuse:[0,1,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),blue:new jt(i,{diffuse:[0,0,1],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new ds(i,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6})};this._displayMeshes={plane:i.addChild(new Ot(i,{geometry:new Le(i,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new jt(i,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1]}),e),planeFrame:i.addChild(new Ot(i,{geometry:new Le(i,Ye({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new jt(i,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45]}),e),center:i.addChild(new Ot(i,{geometry:new Le(i,Je({radius:.05})),material:n.center,pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zAxisArrow:i.addChild(new Ot(i,{geometry:r.arrowHead,material:n.blue,matrix:function(){const e=R.translateMat4c(0,1.1,0,R.identityMat4()),t=R.rotationMat4v(-90*R.DEGTORAD,[.8,0,0],R.identityMat4());return R.mulMat4(t,e,R.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zShaft:i.addChild(new Ot(i,{geometry:r.axis,material:n.blue,matrix:function(){const e=R.translateMat4c(0,.5,0,R.identityMat4()),t=R.rotationMat4v(-90*R.DEGTORAD,[1,0,0],R.identityMat4());return R.mulMat4(t,e,R.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1}),e)},this._affordanceMeshes={planeFrame:i.addChild(new Ot(i,{geometry:new Le(i,Ye({center:[0,0,0],radius:2,tube:s,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new jt(i,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new ds(i,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45]}),e),zAxisArrow:i.addChild(new Ot(i,{geometry:r.arrowHeadBig,material:n.blue,matrix:function(){const e=R.translateMat4c(0,1.1,0,R.identityMat4()),t=R.rotationMat4v(-90*R.DEGTORAD,[.8,0,0],R.identityMat4());return R.mulMat4(t,e,R.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e)}}_bindEvents(){const e=this._rootNode,t=R.vec2(),s=this._viewer.camera,i=this._viewer.scene;let r=0,n=!1;{const t=R.vec3([0,0,0]);let A=-1;this._onCameraViewMatrix=i.camera.on("viewMatrix",(()=>{})),this._onCameraProjMatrix=i.camera.on("projMatrix",(()=>{})),this._onSceneTick=i.on("tick",(()=>{n=!1;const a=Math.abs(R.lenVec3(R.subVec3(i.camera.eye,this._pos,t)));if(a!==A&&"perspective"===s.projection){const t=.07*(Math.tan(s.perspective.fov*R.DEGTORAD)*a);e.scale=[t,t,t],A=a}if("ortho"===s.projection){const t=s.ortho.scale/10;e.scale=[t,t,t],A=a}0!==r&&(o(r),r=0)}))}const A=function(){const e=new Float64Array(2);return function(t){if(t){for(var s=t.target,i=0,r=0;s.offsetParent;)i+=s.offsetLeft,r+=s.offsetTop,s=s.offsetParent;e[0]=t.pageX-i,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),o=e=>{const t=this._sectionPlane.pos,s=this._sectionPlane.dir;R.addVec3(t,R.mulVec3Scalar(s,.1*e*this._plugin.getDragSensitivity(),R.vec3())),this._sectionPlane.pos=t};{let e=!1;this._plugin._controlElement.addEventListener("mousedown",this._canvasMouseDownListener=s=>{if(s.preventDefault(),this._visible&&(this._viewer.cameraControl.pointerEnabled=!1,1===s.which)){e=!0;var i=A(s);t[0]=i[0],t[1]=i[1]}}),this._plugin._controlElement.addEventListener("mousemove",this._canvasMouseMoveListener=s=>{if(!this._visible)return;if(!e)return;if(n)return;var i=A(s);const r=i[0],a=i[1];o(a-t[1]),t[0]=r,t[1]=a}),this._plugin._controlElement.addEventListener("mouseup",this._canvasMouseUpListener=t=>{this._visible&&(this._viewer.cameraControl.pointerEnabled=!0,e&&(t.which,e=!1))}),this._plugin._controlElement.addEventListener("wheel",this._canvasWheelListener=e=>{this._visible&&(r+=Math.max(-1,Math.min(1,40*-e.deltaY)))})}{let e,t,s=null;this._plugin._controlElement.addEventListener("touchstart",this._handleTouchStart=t=>{t.stopPropagation(),t.preventDefault(),this._visible&&(e=t.touches[0].clientY,s=e,r=0)}),this._plugin._controlElement.addEventListener("touchmove",this._handleTouchMove=e=>{e.stopPropagation(),e.preventDefault(),this._visible&&(n||(n=!0,t=e.touches[0].clientY,null!==s&&(r+=t-s),s=t))}),this._plugin._controlElement.addEventListener("touchend",this._handleTouchEnd=s=>{s.stopPropagation(),s.preventDefault(),this._visible&&(e=null,t=null,r=0)})}}_destroy(){this._unbindEvents(),this._destroyNodes()}_unbindEvents(){const e=this._viewer,t=e.scene,s=t.canvas.canvas,i=e.camera,r=this._plugin._controlElement;t.off(this._onSceneTick),s.removeEventListener("mousedown",this._canvasMouseDownListener),s.removeEventListener("mousemove",this._canvasMouseMoveListener),s.removeEventListener("mouseup",this._canvasMouseUpListener),s.removeEventListener("wheel",this._canvasWheelListener),r.removeEventListener("touchstart",this._handleTouchStart),r.removeEventListener("touchmove",this._handleTouchMove),r.removeEventListener("touchend",this._handleTouchEnd),i.off(this._onCameraViewMatrix),i.off(this._onCameraProjMatrix)}_destroyNodes(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}class gy{constructor(e,t,s){this.id=s.id,this._sectionPlane=s,this._mesh=new Ot(t,{id:s.id,geometry:new Le(t,We({xSize:.5,ySize:.5,zSize:.001})),material:new jt(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new fs(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new ds(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new ds(t,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});{const e=R.vec3([0,0,0]),t=R.vec3(),s=R.vec3([0,0,1]),i=R.vec4(4),r=R.vec3(),n=()=>{const n=this._sectionPlane.scene.center,A=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];R.subVec3(n,this._sectionPlane.pos,e);const o=-R.dotVec3(A,e);R.normalizeVec3(A),R.mulVec3Scalar(A,o,t);const a=R.vec3PairToQuaternion(s,this._sectionPlane.dir,i);r[0]=.1*t[0],r[1]=.1*t[1],r[2]=.1*t[2],this._mesh.quaternion=a,this._mesh.position=r};this._onSectionPlanePos=this._sectionPlane.on("pos",n),this._onSectionPlaneDir=this._sectionPlane.on("dir",n)}this._highlighted=!1,this._selected=!1}setHighlighted(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}getHighlighted(){return this._highlighted}setSelected(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}getSelected(){return this._selected}destroy(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}class my{constructor(e,t){if(!(t.onHoverEnterPlane&&t.onHoverLeavePlane&&t.onClickedNothing&&t.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=e,this._viewer=e.viewer,this._onHoverEnterPlane=t.onHoverEnterPlane,this._onHoverLeavePlane=t.onHoverLeavePlane,this._onClickedNothing=t.onClickedNothing,this._onClickedPlane=t.onClickedPlane,this._visible=!0,this._planes={},this._canvas=t.overviewCanvas,this._scene=new gA(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new Zr(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Zr(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Zr(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;{const e=this._scene.camera,t=R.rotationMat4c(-90*R.DEGTORAD,1,0,0),s=R.vec3(),i=R.vec3(),r=R.vec3();this._synchCamera=()=>{const n=this._viewer.camera.eye,A=this._viewer.camera.look,o=this._viewer.camera.up;R.mulVec3Scalar(R.normalizeVec3(R.subVec3(n,A,s)),7),this._zUp?(R.transformVec3(t,s,i),R.transformVec3(t,o,r),e.look=[0,0,0],e.eye=R.transformVec3(t,s,i),e.up=R.transformPoint3(t,o,r)):(e.look=[0,0,0],e.eye=s,e.up=o)}}this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(e=>{this._scene.camera.perspective.fov=e}));var s=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!s||t.entity.id!==s.id){if(s){this._planes[s.id]&&this._onHoverLeavePlane(s.id)}s=t.entity;this._planes[s.id]&&this._onHoverEnterPlane(s.id)}}else s&&(this._onHoverLeavePlane(s.id),s=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(s){this._planes[s.id]&&this._onClickedPlane(s.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{s&&(this._onHoverLeavePlane(s.id),s=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new gy(this,this._scene,e)}setPlaneHighlighted(e,t){const s=this._planes[e];s&&s.setHighlighted(t)}setPlaneSelected(e,t){const s=this._planes[e];s&&s.setSelected(t)}removeSectionPlane(e){const t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}setVisible(e=!0){this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}getVisible(){return this._visible}destroy(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}const _y=R.AABB3(),by=R.vec3();class By{constructor(e={}){this.cacheBuster=!1!==e.cacheBuster}_cacheBusterURL(e){if(!this.cacheBuster)return e;const t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}getSTL(e,t,s){e=this._cacheBusterURL(e);const i=new XMLHttpRequest;i.overrideMimeType("application/json"),i.open("GET",e,!0),i.responseType="arraybuffer",i.onreadystatechange=function(){4===i.readyState&&(200===i.status?t(i.response):s(i.statusText))},i.send(null)}}const yy=R.vec3();class wy{load(e,t,s,i,r,n){i=i||{};const A=e.viewer.scene.canvas.spinner;A.processes++,e.dataSource.getSTL(s,(function(s){!function(e,t,s,i){try{const r=xy(s);vy(r)?Cy(e,r,t,i):My(e,Fy(s),t,i)}catch(e){t.fire("error",e)}}(e,t,s,i);try{const n=xy(s);vy(n)?Cy(e,n,t,i):My(e,Fy(s),t,i),A.processes--,q.scheduleTask((function(){t.fire("loaded",!0,!1)})),r&&r()}catch(s){A.processes--,e.error(s),n&&n(s),t.fire("error",s)}}),(function(s){A.processes--,e.error(s),n&&n(s),t.fire("error",s)}))}parse(e,t,s,i){const r=e.viewer.scene.canvas.spinner;r.processes++;try{const n=xy(s);vy(n)?Cy(e,n,t,i):My(e,Fy(s),t,i),r.processes--,q.scheduleTask((function(){t.fire("loaded",!0,!1)}))}catch(e){r.processes--,t.fire("error",e)}}}function vy(e){const t=new DataView(e);if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;const s=[115,111,108,105,100];for(var i=0;i<5;i++)if(s[i]!==t.getUint8(i,!1))return!0;return!1}function Cy(e,t,s,i){const r=new DataView(t),n=r.getUint32(80,!0);let A,o,a,l,c,h,u,d=!1,p=null,f=null,g=null,m=!1;for(let e=0;e<70;e++)1129270351===r.getUint32(e,!1)&&82===r.getUint8(e+4)&&61===r.getUint8(e+5)&&(d=!0,l=[],c=r.getUint8(e+6)/255,h=r.getUint8(e+7)/255,u=r.getUint8(e+8)/255,r.getUint8(e+9));const _=new as(s,{roughness:.5});let b=[],B=[],y=i.splitMeshes;for(let e=0;e<n;e++){let t=84+50*e,n=r.getFloat32(t,!0),w=r.getFloat32(t+4,!0),v=r.getFloat32(t+8,!0);if(d){let e=r.getUint16(t+48,!0);0==(32768&e)?(A=(31&e)/31,o=(e>>5&31)/31,a=(e>>10&31)/31):(A=c,o=h,a=u),(y&&A!==p||o!==f||a!==g)&&(null!==p&&(m=!0),p=A,f=o,g=a)}for(let e=1;e<=3;e++){let s=t+12*e;b.push(r.getFloat32(s,!0)),b.push(r.getFloat32(s+4,!0)),b.push(r.getFloat32(s+8,!0)),B.push(n,w,v),d&&l.push(A,o,a,1)}y&&m&&(Ey(s,b,B,l,_,i),b=[],B=[],l=l?[]:null,m=!1)}b.length>0&&Ey(s,b,B,l,_,i)}function My(e,t,s,i){const r=/facet([\s\S]*?)endfacet/g;let n=0;const A=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,o=new RegExp("vertex"+A+A+A,"g"),a=new RegExp("normal"+A+A+A,"g"),l=[],c=[];let h,u,d,p,f,g,m;for(;null!==(p=r.exec(t));){for(f=0,g=0,m=p[0];null!==(p=a.exec(m));)h=parseFloat(p[1]),u=parseFloat(p[2]),d=parseFloat(p[3]),g++;for(;null!==(p=o.exec(m));)l.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),c.push(h,u,d),f++;1!==g&&e.error("Error in normal of face "+n),3!==f&&e.error("Error in positions of face "+n),n++}Ey(s,l,c,null,new as(s,{roughness:.5}),i)}function Ey(e,t,s,i,r,n){const A=new Int32Array(t.length/3);for(let e=0,t=A.length;e<t;e++)A[e]=e;s=s&&s.length>0?s:null,i=i&&i.length>0?i:null,n.smoothNormals&&R.faceToVertexNormals(t,s,n);const o=yy;pt(t,t,o);const a=new Le(e,{primitive:"triangles",positions:t,normals:s,colors:i,indices:A}),l=new Ot(e,{origin:0!==o[0]||0!==o[1]||0!==o[2]?o:null,geometry:a,material:r,edges:n.edges});e.addChild(l)}function Fy(e){return"string"!=typeof e?function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let s=0,i=e.length;s<i;s++)t+=String.fromCharCode(e[s]);return decodeURIComponent(escape(t))}(new Uint8Array(e)):e}function xy(e){if("string"==typeof e){const t=new Uint8Array(e.length);for(let s=0;s<e.length;s++)t[s]=255&e.charCodeAt(s);return t.buffer||t}return e}class Uy{constructor(e){this._treeViewContainer=e}createRootNode(){return document.createElement("ul")}createNodeElement(e,t,s,i,r){const n=document.createElement("li");if(n.id=e.nodeId,e.xrayed&&n.classList.add("xrayed-node"),e.children.length>0){const s=document.createElement("a");s.href="#",s.id=`switch-${e.nodeId}`,s.textContent="+",s.classList.add("plus"),t&&s.addEventListener("click",t),n.appendChild(s)}const A=document.createElement("input");A.id=`checkbox-${e.nodeId}`,A.type="checkbox",A.checked=e.checked,A.style["pointer-events"]="all",s&&A.addEventListener("change",s),n.appendChild(A);const o=document.createElement("span");return o.textContent=e.title,n.appendChild(o),i&&Pb(o,i),r&&(o.onclick=r),n}createDisabledNodeElement(e){const t=document.createElement("li"),s=document.createElement("a");s.href="#",s.textContent="!",s.classList.add("warn"),s.classList.add("warning"),t.appendChild(s);const i=document.createElement("span");return i.textContent=e,t.appendChild(i),t}addChildren(e,t){const s=document.createElement("ul");t.forEach((e=>{s.appendChild(e)})),e.parentElement.appendChild(s)}expand(e,t,s){e.classList.remove("plus"),e.classList.add("minus"),e.textContent="-",e.removeEventListener("click",t),e.addEventListener("click",s)}collapse(e,t,s){if(!e)return;const i=e.parentElement;if(!i)return;const r=i.querySelector("ul");r&&(i.removeChild(r),e.classList.remove("minus"),e.classList.add("plus"),e.textContent="+",e.removeEventListener("click",s),e.addEventListener("click",t))}isExpanded(e){return void 0!==e.parentElement.getElementsByTagName("li")[0]}getId(e){return e.parentElement.id}getIdFromCheckbox(e){return e.id.replace("checkbox-","")}getSwitchElement(e){return this._treeViewContainer.querySelector(`[id="switch-${e}"]`)}isChecked(e){return e.checked}setCheckbox(e,t,s=!1){const i=this._treeViewContainer.querySelector(`[id="checkbox-${e}"]`);i&&(t!==i.checked&&(i.checked=t),s!==i.indeterminate&&(i.indeterminate=s,s&&(i.checked=!1)))}setXRayed(e,t){const s=this._treeViewContainer.querySelector(`[id="${e}"]`);s&&(t?s.classList.add("xrayed-node"):s.classList.remove("xrayed-node"))}setHighlighted(e,t){const s=this._treeViewContainer.querySelector(`[id="${e}"]`);s&&(t?(s.scrollIntoView({block:"center"}),s.classList.add("highlighted-node")):s.classList.remove("highlighted-node"))}}const Iy=[];class Ty{constructor(e){this._scene=e,this._objects=[],this._objectsViewCulled=[],this._objectsDetailCulled=[],this._objectsChanged=[],this._objectsChangedList=[],this._modelInfos={},this._numObjects=0,this._lenObjectsChangedList=0,this._dirty=!0,this._onModelLoaded=e.on("modelLoaded",(t=>{const s=e.models[t];s&&this._addModel(s)})),this._onTick=e.on("tick",(()=>{this._dirty&&this._build(),this._applyChanges()}))}_addModel(e){const t={model:e,onDestroyed:e.on("destroyed",(()=>{this._removeModel(e)}))};this._modelInfos[e.id]=t,this._dirty=!0}_removeModel(e){const t=this._modelInfos[e.id];t&&(t.model.off(t.onDestroyed),delete this._modelInfos[e.id],this._dirty=!0)}_build(){if(!this._dirty)return;this._applyChanges();const e=this._scene.objects;for(let e=0;e<this._numObjects;e++)this._objects[e]=null;this._numObjects=0;for(let t in e){const s=e[t];this._objects[this._numObjects++]=s}this._lenObjectsChangedList=0,this._dirty=!1}_applyChanges(){if(this._lenObjectsChangedList>0){for(let e=0;e<this._lenObjectsChangedList;e++){const t=this._objectsChangedList[e],s=this._objects[t],i=this._objectsViewCulled[t],r=this._objectsDetailCulled[t],n=i||r;s.culled=n,this._objectsChanged[t]=!1}this._lenObjectsChangedList=0}}get objects(){return this._dirty&&this._build(),this._objects}get numObjects(){return this._dirty&&this._build(),this._numObjects}setObjectViewCulled(e,t){this._dirty&&this._build(),this._objectsViewCulled[e]!==t&&(this._objectsViewCulled[e]=t,this._objectsChanged[e]||(this._objectsChanged[e]=!0,this._objectsChangedList[this._lenObjectsChangedList++]=e))}setObjectDetailCulled(e,t){this._dirty&&this._build(),this._objectsDetailCulled[e]!==t&&(this._objectsDetailCulled[e]=t,this._objectsChanged[e]||(this._objectsChanged[e]=!0,this._objectsChangedList[this._lenObjectsChangedList++]=e))}_destroy(){this._clear(),this._scene.off(this._onModelLoaded),this._scene.off(this._onTick)}_clear(){for(let e in this._modelInfos){const t=this._modelInfos[e];t.model.off(t.onDestroyed)}this._modelInfos={},this._dirty=!0}}const Py={};const Sy=new Float32Array(3);class Dy{constructor(e={}){this.cacheBuster=!1!==e.cacheBuster}_cacheBusterURL(e){if(!this.cacheBuster)return e;const t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}getManifest(e,t,s){j.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}getMetaModel(e,t,s){j.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}getXKT(e,t,s){var i=()=>{};t=t||i,s=s||i;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var n=r[3];n=window.decodeURIComponent(n),e&&(n=window.atob(n));try{const e=new ArrayBuffer(n.length),s=new Uint8Array(e);for(var A=0;A<n.length;A++)s[A]=n.charCodeAt(A);t(e)}catch(e){s(e)}}else{const i=new XMLHttpRequest;i.open("GET",this._cacheBusterURL(e),!0),i.responseType="arraybuffer",i.onreadystatechange=function(){4===i.readyState&&(200===i.status?t(i.response):s("getXKT error : "+i.response))},i.send(null)}}}
|
|
42
|
+
***************************************************************************** */var ku=function(e,t){return ku=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])},ku(e,t)};function Qu(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function s(){this.constructor=e}ku(e,t),e.prototype=null===t?Object.create(t):(s.prototype=t.prototype,new s)}var Ru=function(){return Ru=Object.assign||function(e){for(var t,s=1,i=arguments.length;s<i;s++)for(var r in t=arguments[s])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Ru.apply(this,arguments)};function Ou(e,t,s,i){return new(s||(s=Promise))((function(r,n){function A(e){try{a(i.next(e))}catch(e){n(e)}}function o(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(A,o)}a((i=i.apply(e,t||[])).next())}))}function Vu(e,t){var s,i,r,n,A={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return n={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function o(n){return function(o){return function(n){if(s)throw new TypeError("Generator is already executing.");for(;A;)try{if(s=1,i&&(r=2&n[0]?i.return:n[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,n[1])).done)return r;switch(i=0,r&&(n=[2&n[0],r.value]),n[0]){case 0:case 1:r=n;break;case 4:return A.label++,{value:n[1],done:!1};case 5:A.label++,i=n[1],n=[0];continue;case 7:n=A.ops.pop(),A.trys.pop();continue;default:if(!(r=A.trys,(r=r.length>0&&r[r.length-1])||6!==n[0]&&2!==n[0])){A=0;continue}if(3===n[0]&&(!r||n[1]>r[0]&&n[1]<r[3])){A.label=n[1];break}if(6===n[0]&&A.label<r[1]){A.label=r[1],r=n;break}if(r&&A.label<r[2]){A.label=r[2],A.ops.push(n);break}r[2]&&A.ops.pop(),A.trys.pop();continue}n=t.call(e,A)}catch(e){n=[6,e],i=0}finally{s=r=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,o])}}}function Lu(e,t,s){if(s||2===arguments.length)for(var i,r=0,n=t.length;r<n;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||t)}for(var Hu=function(){function e(e,t,s,i){this.left=e,this.top=t,this.width=s,this.height=i}return e.prototype.add=function(t,s,i,r){return new e(this.left+t,this.top+s,this.width+i,this.height+r)},e.fromClientRect=function(t,s){return new e(s.left+t.windowBounds.left,s.top+t.windowBounds.top,s.width,s.height)},e.fromDOMRectList=function(t,s){var i=Array.from(s).find((function(e){return 0!==e.width}));return i?new e(i.left+t.windowBounds.left,i.top+t.windowBounds.top,i.width,i.height):e.EMPTY},e.EMPTY=new e(0,0,0,0),e}(),Nu=function(e,t){return Hu.fromClientRect(e,t.getBoundingClientRect())},Gu=function(e){for(var t=[],s=0,i=e.length;s<i;){var r=e.charCodeAt(s++);if(r>=55296&&r<=56319&&s<i){var n=e.charCodeAt(s++);56320==(64512&n)?t.push(((1023&r)<<10)+(1023&n)+65536):(t.push(r),s--)}else t.push(r)}return t},ju=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(String.fromCodePoint)return String.fromCodePoint.apply(String,e);var s=e.length;if(!s)return"";for(var i=[],r=-1,n="";++r<s;){var A=e[r];A<=65535?i.push(A):(A-=65536,i.push(55296+(A>>10),A%1024+56320)),(r+1===s||i.length>16384)&&(n+=String.fromCharCode.apply(String,i),i.length=0)}return n},Wu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",zu="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Xu=0;Xu<Wu.length;Xu++)zu[Wu.charCodeAt(Xu)]=Xu;for(var Ku="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zu="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Ju=0;Ju<Ku.length;Ju++)Zu[Ku.charCodeAt(Ju)]=Ju;for(var Yu=function(e,t,s){return e.slice?e.slice(t,s):new Uint16Array(Array.prototype.slice.call(e,t,s))},$u=function(){function e(e,t,s,i,r,n){this.initialValue=e,this.errorValue=t,this.highStart=s,this.highValueIndex=i,this.index=r,this.data=n}return e.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e<this.highStart)return t=2080+(e>>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),qu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ed="undefined"==typeof Uint8Array?[]:new Uint8Array(256),td=0;td<qu.length;td++)ed[qu.charCodeAt(td)]=td;var sd=10,id=13,rd=15,nd=17,Ad=18,od=19,ad=20,ld=21,cd=22,hd=24,ud=25,dd=26,pd=27,fd=28,gd=30,md=32,_d=33,bd=34,Bd=35,yd=37,wd=38,vd=39,Cd=40,Md=42,Ed=[9001,65288],Fd=function(e,t){var s,i,r,n=function(e){var t,s,i,r,n,A=.75*e.length,o=e.length,a=0;"="===e[e.length-1]&&(A--,"="===e[e.length-2]&&A--);var l="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(A):new Array(A),c=Array.isArray(l)?l:new Uint8Array(l);for(t=0;t<o;t+=4)s=Zu[e.charCodeAt(t)],i=Zu[e.charCodeAt(t+1)],r=Zu[e.charCodeAt(t+2)],n=Zu[e.charCodeAt(t+3)],c[a++]=s<<2|i>>4,c[a++]=(15&i)<<4|r>>2,c[a++]=(3&r)<<6|63&n;return l}(e),A=Array.isArray(n)?function(e){for(var t=e.length,s=[],i=0;i<t;i+=4)s.push(e[i+3]<<24|e[i+2]<<16|e[i+1]<<8|e[i]);return s}(n):new Uint32Array(n),o=Array.isArray(n)?function(e){for(var t=e.length,s=[],i=0;i<t;i+=2)s.push(e[i+1]<<8|e[i]);return s}(n):new Uint16Array(n),a=Yu(o,12,A[4]/2),l=2===A[5]?Yu(o,(24+A[4])/2):(s=A,i=Math.ceil((24+A[4])/4),s.slice?s.slice(i,r):new Uint32Array(Array.prototype.slice.call(s,i,r)));return new $u(A[0],A[1],A[2],A[3],a,l)}("KwAAAAAAAAAACA4AUD0AADAgAAACAAAAAAAIABAAGABAAEgAUABYAGAAaABgAGgAYgBqAF8AZwBgAGgAcQB5AHUAfQCFAI0AlQCdAKIAqgCyALoAYABoAGAAaABgAGgAwgDKAGAAaADGAM4A0wDbAOEA6QDxAPkAAQEJAQ8BFwF1AH0AHAEkASwBNAE6AUIBQQFJAVEBWQFhAWgBcAF4ATAAgAGGAY4BlQGXAZ8BpwGvAbUBvQHFAc0B0wHbAeMB6wHxAfkBAQIJAvEBEQIZAiECKQIxAjgCQAJGAk4CVgJeAmQCbAJ0AnwCgQKJApECmQKgAqgCsAK4ArwCxAIwAMwC0wLbAjAA4wLrAvMC+AIAAwcDDwMwABcDHQMlAy0DNQN1AD0DQQNJA0kDSQNRA1EDVwNZA1kDdQB1AGEDdQBpA20DdQN1AHsDdQCBA4kDkQN1AHUAmQOhA3UAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AKYDrgN1AHUAtgO+A8YDzgPWAxcD3gPjA+sD8wN1AHUA+wMDBAkEdQANBBUEHQQlBCoEFwMyBDgEYABABBcDSARQBFgEYARoBDAAcAQzAXgEgASIBJAEdQCXBHUAnwSnBK4EtgS6BMIEyAR1AHUAdQB1AHUAdQCVANAEYABgAGAAYABgAGAAYABgANgEYADcBOQEYADsBPQE/AQEBQwFFAUcBSQFLAU0BWQEPAVEBUsFUwVbBWAAYgVgAGoFcgV6BYIFigWRBWAAmQWfBaYFYABgAGAAYABgAKoFYACxBbAFuQW6BcEFwQXHBcEFwQXPBdMF2wXjBeoF8gX6BQIGCgYSBhoGIgYqBjIGOgZgAD4GRgZMBmAAUwZaBmAAYABgAGAAYABgAGAAYABgAGAAYABgAGIGYABpBnAGYABgAGAAYABgAGAAYABgAGAAYAB4Bn8GhQZgAGAAYAB1AHcDFQSLBmAAYABgAJMGdQA9A3UAmwajBqsGqwaVALMGuwbDBjAAywbSBtIG1QbSBtIG0gbSBtIG0gbdBuMG6wbzBvsGAwcLBxMHAwcbByMHJwcsBywHMQcsB9IGOAdAB0gHTgfSBkgHVgfSBtIG0gbSBtIG0gbSBtIG0gbSBiwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdgAGAALAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdbB2MHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB2kH0gZwB64EdQB1AHUAdQB1AHUAdQB1AHUHfQdgAIUHjQd1AHUAlQedB2AAYAClB6sHYACzB7YHvgfGB3UAzgfWBzMB3gfmB1EB7gf1B/0HlQENAQUIDQh1ABUIHQglCBcDLQg1CD0IRQhNCEEDUwh1AHUAdQBbCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIcAh3CHoIMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIgggwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAALAcsBywHLAcsBywHLAcsBywHLAcsB4oILAcsB44I0gaWCJ4Ipgh1AHUAqgiyCHUAdQB1AHUAdQB1AHUAdQB1AHUAtwh8AXUAvwh1AMUIyQjRCNkI4AjoCHUAdQB1AO4I9gj+CAYJDgkTCS0HGwkjCYIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiAAIAAAAFAAYABgAGIAXwBgAHEAdQBFAJUAogCyAKAAYABgAEIA4ABGANMA4QDxAMEBDwE1AFwBLAE6AQEBUQF4QkhCmEKoQrhCgAHIQsAB0MLAAcABwAHAAeDC6ABoAHDCwMMAAcABwAHAAdDDGMMAAcAB6MM4wwjDWMNow3jDaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAEjDqABWw6bDqABpg6gAaABoAHcDvwOPA+gAaABfA/8DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DpcPAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcAB9cPKwkyCToJMAB1AHUAdQBCCUoJTQl1AFUJXAljCWcJawkwADAAMAAwAHMJdQB2CX4JdQCECYoJjgmWCXUAngkwAGAAYABxAHUApgn3A64JtAl1ALkJdQDACTAAMAAwADAAdQB1AHUAdQB1AHUAdQB1AHUAowYNBMUIMAAwADAAMADICcsJ0wnZCRUE4QkwAOkJ8An4CTAAMAB1AAAKvwh1AAgKDwoXCh8KdQAwACcKLgp1ADYKqAmICT4KRgowADAAdQB1AE4KMAB1AFYKdQBeCnUAZQowADAAMAAwADAAMAAwADAAMAAVBHUAbQowADAAdQC5CXUKMAAwAHwBxAijBogEMgF9CoQKiASMCpQKmgqIBKIKqgquCogEDQG2Cr4KxgrLCjAAMADTCtsKCgHjCusK8Qr5CgELMAAwADAAMAB1AIsECQsRC3UANAEZCzAAMAAwADAAMAB1ACELKQswAHUANAExCzkLdQBBC0kLMABRC1kLMAAwADAAMAAwADAAdQBhCzAAMAAwAGAAYABpC3ELdwt/CzAAMACHC4sLkwubC58Lpwt1AK4Ltgt1APsDMAAwADAAMAAwADAAMAAwAL4LwwvLC9IL1wvdCzAAMADlC+kL8Qv5C/8LSQswADAAMAAwADAAMAAwADAAMAAHDDAAMAAwADAAMAAODBYMHgx1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1ACYMMAAwADAAdQB1AHUALgx1AHUAdQB1AHUAdQA2DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AD4MdQBGDHUAdQB1AHUAdQB1AEkMdQB1AHUAdQB1AFAMMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQBYDHUAdQB1AF8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUA+wMVBGcMMAAwAHwBbwx1AHcMfwyHDI8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAYABgAJcMMAAwADAAdQB1AJ8MlQClDDAAMACtDCwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB7UMLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AA0EMAC9DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAsBywHLAcsBywHLAcsBywHLQcwAMEMyAwsBywHLAcsBywHLAcsBywHLAcsBywHzAwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1ANQM2QzhDDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMABgAGAAYABgAGAAYABgAOkMYADxDGAA+AwADQYNYABhCWAAYAAODTAAMAAwADAAFg1gAGAAHg37AzAAMAAwADAAYABgACYNYAAsDTQNPA1gAEMNPg1LDWAAYABgAGAAYABgAGAAYABgAGAAUg1aDYsGVglhDV0NcQBnDW0NdQ15DWAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAlQCBDZUAiA2PDZcNMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAnw2nDTAAMAAwADAAMAAwAHUArw23DTAAMAAwADAAMAAwADAAMAAwADAAMAB1AL8NMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQDHDTAAYABgAM8NMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAA1w11ANwNMAAwAD0B5A0wADAAMAAwADAAMADsDfQN/A0EDgwOFA4wABsOMAAwADAAMAAwADAAMAAwANIG0gbSBtIG0gbSBtIG0gYjDigOwQUuDsEFMw7SBjoO0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGQg5KDlIOVg7SBtIGXg5lDm0OdQ7SBtIGfQ6EDooOjQ6UDtIGmg6hDtIG0gaoDqwO0ga0DrwO0gZgAGAAYADEDmAAYAAkBtIGzA5gANIOYADaDokO0gbSBt8O5w7SBu8O0gb1DvwO0gZgAGAAxA7SBtIG0gbSBtIGYABgAGAAYAAED2AAsAUMD9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGFA8sBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAccD9IGLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHJA8sBywHLAcsBywHLAccDywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywPLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAc0D9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAccD9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGFA8sBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHPA/SBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gYUD0QPlQCVAJUAMAAwADAAMACVAJUAlQCVAJUAlQCVAEwPMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAA//8EAAQABAAEAAQABAAEAAQABAANAAMAAQABAAIABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQACgATABcAHgAbABoAHgAXABYAEgAeABsAGAAPABgAHABLAEsASwBLAEsASwBLAEsASwBLABgAGAAeAB4AHgATAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABYAGwASAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWAA0AEQAeAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAFAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJABYAGgAbABsAGwAeAB0AHQAeAE8AFwAeAA0AHgAeABoAGwBPAE8ADgBQAB0AHQAdAE8ATwAXAE8ATwBPABYAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAFAATwBAAE8ATwBPAEAATwBQAFAATwBQAB4AHgAeAB4AHgAeAB0AHQAdAB0AHgAdAB4ADgBQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgBQAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAkACQAJAAkACQAJAAkABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAFAAHgAeAB4AKwArAFAAUABQAFAAGABQACsAKwArACsAHgAeAFAAHgBQAFAAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUAAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAYAA0AKwArAB4AHgAbACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAB4ABAAEAB4ABAAEABMABAArACsAKwArACsAKwArACsAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAKwArACsAKwBWAFYAVgBWAB4AHgArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AGgAaABoAGAAYAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQAEwAEACsAEwATAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABLAEsASwBLAEsASwBLAEsASwBLABoAGQAZAB4AUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABMAUAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABABQAFAABAAEAB4ABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUAAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAFAABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQAUABQAB4AHgAYABMAUAArACsABAAbABsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAFAABAAEAAQABAAEAFAABAAEAAQAUAAEAAQABAAEAAQAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArACsAHgArAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAUAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEAA0ADQBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUAArACsAKwBQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABABQACsAKwArACsAKwArACsAKwAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUAAaABoAUABQAFAAUABQAEwAHgAbAFAAHgAEACsAKwAEAAQABAArAFAAUABQAFAAUABQACsAKwArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQACsAUABQACsAKwAEACsABAAEAAQABAAEACsAKwArACsABAAEACsAKwAEAAQABAArACsAKwAEACsAKwArACsAKwArACsAUABQAFAAUAArAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLAAQABABQAFAAUAAEAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAArACsAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AGwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAKwArACsAKwArAAQABAAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAAQAUAArAFAAUABQAFAAUABQACsAKwArAFAAUABQACsAUABQAFAAUAArACsAKwBQAFAAKwBQACsAUABQACsAKwArAFAAUAArACsAKwBQAFAAUAArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAAQABAAEAAQABAArACsAKwAEAAQABAArAAQABAAEAAQAKwArAFAAKwArACsAKwArACsABAArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAHgAeAB4AHgAeAB4AGwAeACsAKwArACsAKwAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAUABQAFAAKwArACsAKwArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwAOAFAAUABQAFAAUABQAFAAHgBQAAQABAAEAA4AUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAKwArAAQAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAKwArACsAKwArACsAUAArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABABQAB4AKwArACsAKwBQAFAAUAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQABoAUABQAFAAUABQAFAAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQACsAUAArACsAUABQAFAAUABQAFAAUAArACsAKwAEACsAKwArACsABAAEAAQABAAEAAQAKwAEACsABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgAqACsAKwArACsAGwBcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAeAEsASwBLAEsASwBLAEsASwBLAEsADQANACsAKwArACsAKwBcAFwAKwBcACsAXABcAFwAXABcACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAXAArAFwAXABcAFwAXABcAFwAXABcAFwAKgBcAFwAKgAqACoAKgAqACoAKgAqACoAXAArACsAXABcAFwAXABcACsAXAArACoAKgAqACoAKgAqACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwBcAFwAXABcAFAADgAOAA4ADgAeAA4ADgAJAA4ADgANAAkAEwATABMAEwATAAkAHgATAB4AHgAeAAQABAAeAB4AHgAeAB4AHgBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQAFAADQAEAB4ABAAeAAQAFgARABYAEQAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAAQABAAEAAQADQAEAAQAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAA0ADQAeAB4AHgAeAB4AHgAEAB4AHgAeAB4AHgAeACsAHgAeAA4ADgANAA4AHgAeAB4AHgAeAAkACQArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgBcAEsASwBLAEsASwBLAEsASwBLAEsADQANAB4AHgAeAB4AXABcAFwAXABcAFwAKgAqACoAKgBcAFwAXABcACoAKgAqAFwAKgAqACoAXABcACoAKgAqACoAKgAqACoAXABcAFwAKgAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqAFwAKgBLAEsASwBLAEsASwBLAEsASwBLACoAKgAqACoAKgAqAFAAUABQAFAAUABQACsAUAArACsAKwArACsAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAKwBQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsABAAEAAQAHgANAB4AHgAeAB4AHgAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUAArACsADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWABEAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQANAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAANAA0AKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUAArAAQABAArACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqAA0ADQAVAFwADQAeAA0AGwBcACoAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwAeAB4AEwATAA0ADQAOAB4AEwATAB4ABAAEAAQACQArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAHgArACsAKwATABMASwBLAEsASwBLAEsASwBLAEsASwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAXABcAFwAXABcACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAXAArACsAKwAqACoAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsAHgAeAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKwAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKwArAAQASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACoAKgAqACoAKgAqACoAXAAqACoAKgAqACoAKgArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABABQAFAAUABQAFAAUABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwANAA0AHgANAA0ADQANAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwAeAB4AHgAeAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArAA0ADQANAA0ADQBLAEsASwBLAEsASwBLAEsASwBLACsAKwArAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUAAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAAQAUABQAFAAUABQAFAABABQAFAABAAEAAQAUAArACsAKwArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAKwBQACsAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAFAAUABQACsAHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQACsAKwAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQACsAHgAeAB4AHgAeAB4AHgAOAB4AKwANAA0ADQANAA0ADQANAAkADQANAA0ACAAEAAsABAAEAA0ACQANAA0ADAAdAB0AHgAXABcAFgAXABcAFwAWABcAHQAdAB4AHgAUABQAFAANAAEAAQAEAAQABAAEAAQACQAaABoAGgAaABoAGgAaABoAHgAXABcAHQAVABUAHgAeAB4AHgAeAB4AGAAWABEAFQAVABUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ADQAeAA0ADQANAA0AHgANAA0ADQAHAB4AHgAeAB4AKwAEAAQABAAEAAQABAAEAAQABAAEAFAAUAArACsATwBQAFAAUABQAFAAHgAeAB4AFgARAE8AUABPAE8ATwBPAFAAUABQAFAAUAAeAB4AHgAWABEAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArABsAGwAbABsAGwAbABsAGgAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGgAbABsAGwAbABoAGwAbABoAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAHgAeAFAAGgAeAB0AHgBQAB4AGgAeAB4AHgAeAB4AHgAeAB4AHgBPAB4AUAAbAB4AHgBQAFAAUABQAFAAHgAeAB4AHQAdAB4AUAAeAFAAHgBQAB4AUABPAFAAUAAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAHgBQAFAAUABQAE8ATwBQAFAAUABQAFAATwBQAFAATwBQAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAFAAUABQAFAATwBPAE8ATwBPAE8ATwBPAE8ATwBQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABPAB4AHgArACsAKwArAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHQAdAB4AHgAeAB0AHQAeAB4AHQAeAB4AHgAdAB4AHQAbABsAHgAdAB4AHgAeAB4AHQAeAB4AHQAdAB0AHQAeAB4AHQAeAB0AHgAdAB0AHQAdAB0AHQAeAB0AHgAeAB4AHgAeAB0AHQAdAB0AHgAeAB4AHgAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeAB0AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAeAB0AHQAdAB0AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAWABEAHgAeAB4AHgAeAB4AHQAeAB4AHgAeAB4AHgAeACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAWABEAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAFAAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeAB4AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AHQAdAB0AHgAeAB0AHgAeAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlAB4AHQAdAB4AHgAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AJQAlAB0AHQAlAB4AJQAlACUAIAAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAeAB4AHgAeAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAdAB0AHQAeAB0AJQAdAB0AHgAdAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAdAB0AHQAdACUAHgAlACUAJQAdACUAJQAdAB0AHQAlACUAHQAdACUAHQAdACUAJQAlAB4AHQAeAB4AHgAeAB0AHQAlAB0AHQAdAB0AHQAdACUAJQAlACUAJQAdACUAJQAgACUAHQAdACUAJQAlACUAJQAlACUAJQAeAB4AHgAlACUAIAAgACAAIAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AFwAXABcAFwAXABcAHgATABMAJQAeAB4AHgAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARABYAEQAWABEAFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAEAAQABAAeAB4AKwArACsAKwArABMADQANAA0AUAATAA0AUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUAANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAA0ADQANAA0ADQANAA0ADQAeAA0AFgANAB4AHgAXABcAHgAeABcAFwAWABEAFgARABYAEQAWABEADQANAA0ADQATAFAADQANAB4ADQANAB4AHgAeAB4AHgAMAAwADQANAA0AHgANAA0AFgANAA0ADQANAA0ADQANAA0AHgANAB4ADQANAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArAA0AEQARACUAJQBHAFcAVwAWABEAFgARABYAEQAWABEAFgARACUAJQAWABEAFgARABYAEQAWABEAFQAWABEAEQAlAFcAVwBXAFcAVwBXAFcAVwBXAAQABAAEAAQABAAEACUAVwBXAFcAVwA2ACUAJQBXAFcAVwBHAEcAJQAlACUAKwBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBRAFcAUQBXAFEAVwBXAFcAVwBXAFcAUQBXAFcAVwBXAFcAVwBRAFEAKwArAAQABAAVABUARwBHAFcAFQBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBRAFcAVwBXAFcAVwBXAFEAUQBXAFcAVwBXABUAUQBHAEcAVwArACsAKwArACsAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwAlACUAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACsAKwArACsAKwArACsAKwArACsAKwArAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBPAE8ATwBPAE8ATwBPAE8AJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADQATAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABLAEsASwBLAEsASwBLAEsASwBLAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAABAAEAAQABAAeAAQABAAEAAQABAAEAAQABAAEAAQAHgBQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAeAA0ADQANAA0ADQArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAAQAUABQAFAABABQAFAAUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAeAB4AHgAeAAQAKwArACsAUABQAFAAUABQAFAAHgAeABoAHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADgAOABMAEwArACsAKwArACsAKwArACsABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUAAeAB4AHgBQAA4AUABQAAQAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAB4AWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYACsAKwArAAQAHgAeAB4AHgAeAB4ADQANAA0AHgAeAB4AHgArAFAASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArAB4AHgBcAFwAXABcAFwAKgBcAFwAXABcAFwAXABcAFwAXABcAEsASwBLAEsASwBLAEsASwBLAEsAXABcAFwAXABcACsAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAFAAUABQAAQAUABQAFAAUABQAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAHgANAA0ADQBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAKgAqACoAXABcACoAKgBcAFwAXABcAFwAKgAqAFwAKgBcACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAA0ADQBQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQADQAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAVABVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBUAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVACsAKwArACsAKwArACsAKwArACsAKwArAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAKwArACsAKwBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAKwArACsAKwAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArACsAKwArAFYABABWAFYAVgBWAFYAVgBWAFYAVgBWAB4AVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgArAFYAVgBWAFYAVgArAFYAKwBWAFYAKwBWAFYAKwBWAFYAVgBWAFYAVgBWAFYAVgBWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAEQAWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAaAB4AKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAGAARABEAGAAYABMAEwAWABEAFAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACUAJQAlACUAJQAWABEAFgARABYAEQAWABEAFgARABYAEQAlACUAFgARACUAJQAlACUAJQAlACUAEQAlABEAKwAVABUAEwATACUAFgARABYAEQAWABEAJQAlACUAJQAlACUAJQAlACsAJQAbABoAJQArACsAKwArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAcAKwATACUAJQAbABoAJQAlABYAEQAlACUAEQAlABEAJQBXAFcAVwBXAFcAVwBXAFcAVwBXABUAFQAlACUAJQATACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXABYAJQARACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAWACUAEQAlABYAEQARABYAEQARABUAVwBRAFEAUQBRAFEAUQBRAFEAUQBRAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcARwArACsAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXACsAKwBXAFcAVwBXAFcAVwArACsAVwBXAFcAKwArACsAGgAbACUAJQAlABsAGwArAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAAQAB0AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsADQANAA0AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAA0AUABQAFAAUAArACsAKwArAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwBQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAUABQAFAAUABQAAQABAAEACsABAAEACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAKwBQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAA0ADQANAA0ADQANAA0ADQAeACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAArACsAKwArAFAAUABQAFAAUAANAA0ADQANAA0ADQAUACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsADQANAA0ADQANAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArAAQABAANACsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAB4AHgAeAB4AHgArACsAKwArACsAKwAEAAQABAAEAAQABAAEAA0ADQAeAB4AHgAeAB4AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsASwBLAEsASwBLAEsASwBLAEsASwANAA0ADQANAFAABAAEAFAAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAeAA4AUAArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAADQANAB4ADQAEAAQABAAEAB4ABAAEAEsASwBLAEsASwBLAEsASwBLAEsAUAAOAFAADQANAA0AKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAA0AHgANAA0AHgAEACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAA0AKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsABAAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAUAArACsAKwArACsAKwAEACsAKwArACsAKwBQAFAAUABQAFAABAAEACsAKwAEAAQABAAEAAQABAAEACsAKwArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABABQAFAAUABQAA0ADQANAA0AHgBLAEsASwBLAEsASwBLAEsASwBLAA0ADQArAB4ABABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUAAeAFAAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABAAEAAQADgANAA0AEwATAB4AHgAeAA0ADQANAA0ADQANAA0ADQANAA0ADQANAA0ADQANAFAAUABQAFAABAAEACsAKwAEAA0ADQAeAFAAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKwArACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBcAFwADQANAA0AKgBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQAKwAEAAQAKwArAAQABAAEAAQAUAAEAFAABAAEAA0ADQANACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABABQAA4AUAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAOAB4ADQANAA0ADQAOAB4ABAArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAA0ADQANAFAADgAOAA4ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAFAADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAOABMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAArACsAKwAEACsABAAEACsABAAEAAQABAAEAAQABABQAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAaABoAGgAaAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABIAEgAQwBDAEMAUABQAFAAUABDAFAAUABQAEgAQwBIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABDAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAJAAkACQAJAAkACQAJABYAEQArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwANAA0AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAANACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQANAB4AHgAeAB4AHgAeAFAAUABQAFAADQAeACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAA0AHgAeACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAARwBHABUARwAJACsAKwArACsAKwArACsAKwArACsAKwAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUQBRAFEAKwArACsAKwArACsAKwArACsAKwArACsAKwBRAFEAUQBRACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAHgAEAAQADQAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQABAAEAAQABAAeAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQAHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAKwArAFAAKwArAFAAUAArACsAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUAArAFAAUABQAFAAUABQAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAHgAeAFAAUABQAFAAUAArAFAAKwArACsAUABQAFAAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeACsAKwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4ABAAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAHgAeAA0ADQANAA0AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArAAQABAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwBQAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArABsAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAB4AHgAeAB4ABAAEAAQABAAEAAQABABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArABYAFgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAGgBQAFAAUAAaAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUAArACsAKwArACsAKwBQACsAKwArACsAUAArAFAAKwBQACsAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUAArAFAAKwBQACsAUAArAFAAUAArAFAAKwArAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAKwBQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AJQAlACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeACUAJQAlAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAlACUAJQAlACUAHgAlACUAJQAlACUAIAAgACAAJQAlACAAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACEAIQAhACEAIQAlACUAIAAgACUAJQAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAIAAlACUAJQAlACAAIAAgACUAIAAgACAAJQAlACUAJQAlACUAJQAgACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAlAB4AJQAeACUAJQAlACUAJQAgACUAJQAlACUAHgAlAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACAAIAAgACUAJQAlACAAIAAgACAAIAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABcAFwAXABUAFQAVAB4AHgAeAB4AJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAgACUAJQAgACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAIAAgACUAJQAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACAAIAAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACAAIAAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAA=="),xd=[gd,36],Ud=[1,2,3,5],Id=[sd,8],Td=[pd,dd],Pd=Ud.concat(Id),Sd=[wd,vd,Cd,bd,Bd],Dd=[rd,id],kd=function(e,t,s,i){var r=i[s];if(Array.isArray(e)?-1!==e.indexOf(r):e===r)for(var n=s;n<=i.length;){if((a=i[++n])===t)return!0;if(a!==sd)break}if(r===sd)for(n=s;n>0;){var A=i[--n];if(Array.isArray(e)?-1!==e.indexOf(A):e===A)for(var o=s;o<=i.length;){var a;if((a=i[++o])===t)return!0;if(a!==sd)break}if(A!==sd)break}return!1},Qd=function(e,t){for(var s=e;s>=0;){var i=t[s];if(i!==sd)return i;s--}return 0},Rd=function(e,t,s,i,r){if(0===s[i])return"×";var n=i-1;if(Array.isArray(r)&&!0===r[n])return"×";var A=n-1,o=n+1,a=t[n],l=A>=0?t[A]:0,c=t[o];if(2===a&&3===c)return"×";if(-1!==Ud.indexOf(a))return"!";if(-1!==Ud.indexOf(c))return"×";if(-1!==Id.indexOf(c))return"×";if(8===Qd(n,t))return"÷";if(11===Fd.get(e[n]))return"×";if((a===md||a===_d)&&11===Fd.get(e[o]))return"×";if(7===a||7===c)return"×";if(9===a)return"×";if(-1===[sd,id,rd].indexOf(a)&&9===c)return"×";if(-1!==[nd,Ad,od,hd,fd].indexOf(c))return"×";if(Qd(n,t)===cd)return"×";if(kd(23,cd,n,t))return"×";if(kd([nd,Ad],ld,n,t))return"×";if(kd(12,12,n,t))return"×";if(a===sd)return"÷";if(23===a||23===c)return"×";if(16===c||16===a)return"÷";if(-1!==[id,rd,ld].indexOf(c)||14===a)return"×";if(36===l&&-1!==Dd.indexOf(a))return"×";if(a===fd&&36===c)return"×";if(c===ad)return"×";if(-1!==xd.indexOf(c)&&a===ud||-1!==xd.indexOf(a)&&c===ud)return"×";if(a===pd&&-1!==[yd,md,_d].indexOf(c)||-1!==[yd,md,_d].indexOf(a)&&c===dd)return"×";if(-1!==xd.indexOf(a)&&-1!==Td.indexOf(c)||-1!==Td.indexOf(a)&&-1!==xd.indexOf(c))return"×";if(-1!==[pd,dd].indexOf(a)&&(c===ud||-1!==[cd,rd].indexOf(c)&&t[o+1]===ud)||-1!==[cd,rd].indexOf(a)&&c===ud||a===ud&&-1!==[ud,fd,hd].indexOf(c))return"×";if(-1!==[ud,fd,hd,nd,Ad].indexOf(c))for(var h=n;h>=0;){if((u=t[h])===ud)return"×";if(-1===[fd,hd].indexOf(u))break;h--}if(-1!==[pd,dd].indexOf(c))for(h=-1!==[nd,Ad].indexOf(a)?A:n;h>=0;){var u;if((u=t[h])===ud)return"×";if(-1===[fd,hd].indexOf(u))break;h--}if(wd===a&&-1!==[wd,vd,bd,Bd].indexOf(c)||-1!==[vd,bd].indexOf(a)&&-1!==[vd,Cd].indexOf(c)||-1!==[Cd,Bd].indexOf(a)&&c===Cd)return"×";if(-1!==Sd.indexOf(a)&&-1!==[ad,dd].indexOf(c)||-1!==Sd.indexOf(c)&&a===pd)return"×";if(-1!==xd.indexOf(a)&&-1!==xd.indexOf(c))return"×";if(a===hd&&-1!==xd.indexOf(c))return"×";if(-1!==xd.concat(ud).indexOf(a)&&c===cd&&-1===Ed.indexOf(e[o])||-1!==xd.concat(ud).indexOf(c)&&a===Ad)return"×";if(41===a&&41===c){for(var d=s[n],p=1;d>0&&41===t[--d];)p++;if(p%2!=0)return"×"}return a===md&&c===_d?"×":"÷"},Od=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var s=function(e,t){void 0===t&&(t="strict");var s=[],i=[],r=[];return e.forEach((function(e,n){var A=Fd.get(e);if(A>50?(r.push(!0),A-=50):r.push(!1),-1!==["normal","auto","loose"].indexOf(t)&&-1!==[8208,8211,12316,12448].indexOf(e))return i.push(n),s.push(16);if(4===A||11===A){if(0===n)return i.push(n),s.push(gd);var o=s[n-1];return-1===Pd.indexOf(o)?(i.push(i[n-1]),s.push(o)):(i.push(n),s.push(gd))}return i.push(n),31===A?s.push("strict"===t?ld:yd):A===Md||29===A?s.push(gd):43===A?e>=131072&&e<=196605||e>=196608&&e<=262141?s.push(yd):s.push(gd):void s.push(A)})),[i,s,r]}(e,t.lineBreak),i=s[0],r=s[1],n=s[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map((function(e){return-1!==[ud,gd,Md].indexOf(e)?yd:e})));var A="keep-all"===t.wordBreak?n.map((function(t,s){return t&&e[s]>=19968&&e[s]<=40959})):void 0;return[i,r,A]},Vd=function(){function e(e,t,s,i){this.codePoints=e,this.required="!"===t,this.start=s,this.end=i}return e.prototype.slice=function(){return ju.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),Ld=function(e){return e>=48&&e<=57},Hd=function(e){return Ld(e)||e>=65&&e<=70||e>=97&&e<=102},Nd=function(e){return 10===e||9===e||32===e},Gd=function(e){return function(e){return function(e){return e>=97&&e<=122}(e)||function(e){return e>=65&&e<=90}(e)}(e)||function(e){return e>=128}(e)||95===e},jd=function(e){return Gd(e)||Ld(e)||45===e},Wd=function(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e},zd=function(e,t){return 92===e&&10!==t},Xd=function(e,t,s){return 45===e?Gd(t)||zd(t,s):!!Gd(e)||!(92!==e||!zd(e,t))},Kd=function(e,t,s){return 43===e||45===e?!!Ld(t)||46===t&&Ld(s):Ld(46===e?t:e)},Zd=function(e){var t=0,s=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(s=-1),t++);for(var i=[];Ld(e[t]);)i.push(e[t++]);var r=i.length?parseInt(ju.apply(void 0,i),10):0;46===e[t]&&t++;for(var n=[];Ld(e[t]);)n.push(e[t++]);var A=n.length,o=A?parseInt(ju.apply(void 0,n),10):0;69!==e[t]&&101!==e[t]||t++;var a=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(a=-1),t++);for(var l=[];Ld(e[t]);)l.push(e[t++]);var c=l.length?parseInt(ju.apply(void 0,l),10):0;return s*(r+o*Math.pow(10,-A))*Math.pow(10,a*c)},Jd={type:2},Yd={type:3},$d={type:4},qd={type:13},ep={type:8},tp={type:21},sp={type:9},ip={type:10},rp={type:11},np={type:12},Ap={type:14},op={type:23},ap={type:1},lp={type:25},cp={type:24},hp={type:26},up={type:27},dp={type:28},pp={type:29},fp={type:31},gp={type:32},mp=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(Gu(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==gp;)e.push(t),t=this.consumeToken();return e},e.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case 34:return this.consumeStringToken(34);case 35:var t=this.peekCodePoint(0),s=this.peekCodePoint(1),i=this.peekCodePoint(2);if(jd(t)||zd(s,i)){var r=Xd(t,s,i)?2:1;return{type:5,value:this.consumeName(),flags:r}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),qd;break;case 39:return this.consumeStringToken(39);case 40:return Jd;case 41:return Yd;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Ap;break;case 43:if(Kd(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return $d;case 45:var n=e,A=this.peekCodePoint(0),o=this.peekCodePoint(1);if(Kd(n,A,o))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(Xd(n,A,o))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(45===A&&62===o)return this.consumeCodePoint(),this.consumeCodePoint(),cp;break;case 46:if(Kd(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 47:if(42===this.peekCodePoint(0))for(this.consumeCodePoint();;){var a=this.consumeCodePoint();if(42===a&&47===(a=this.consumeCodePoint()))return this.consumeToken();if(-1===a)return this.consumeToken()}break;case 58:return hp;case 59:return up;case 60:if(33===this.peekCodePoint(0)&&45===this.peekCodePoint(1)&&45===this.peekCodePoint(2))return this.consumeCodePoint(),this.consumeCodePoint(),lp;break;case 64:var l=this.peekCodePoint(0),c=this.peekCodePoint(1),h=this.peekCodePoint(2);if(Xd(l,c,h))return{type:7,value:this.consumeName()};break;case 91:return dp;case 92:if(zd(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return pp;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),ep;break;case 123:return rp;case 125:return np;case 117:case 85:var u=this.peekCodePoint(0),d=this.peekCodePoint(1);return 43!==u||!Hd(d)&&63!==d||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),sp;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),tp;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),ip;break;case-1:return gp}return Nd(e)?(this.consumeWhiteSpace(),fp):Ld(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):Gd(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:ju(e)}},e.prototype.consumeCodePoint=function(){var e=this._value.shift();return void 0===e?-1:e},e.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},e.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},e.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();Hd(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var s=!1;63===t&&e.length<6;)e.push(t),t=this.consumeCodePoint(),s=!0;if(s)return{type:30,start:parseInt(ju.apply(void 0,e.map((function(e){return 63===e?48:e}))),16),end:parseInt(ju.apply(void 0,e.map((function(e){return 63===e?70:e}))),16)};var i=parseInt(ju.apply(void 0,e),16);if(45===this.peekCodePoint(0)&&Hd(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];Hd(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:i,end:parseInt(ju.apply(void 0,r),16)}}return{type:30,start:i,end:i}},e.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return"url"===e.toLowerCase()&&40===this.peekCodePoint(0)?(this.consumeCodePoint(),this.consumeUrlToken()):40===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},e.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),-1===this.peekCodePoint(0))return{type:22,value:""};var t=this.peekCodePoint(0);if(39===t||34===t){var s=this.consumeStringToken(this.consumeCodePoint());return 0===s.type&&(this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:s.value}):(this.consumeBadUrlRemnants(),op)}for(;;){var i=this.consumeCodePoint();if(-1===i||41===i)return{type:22,value:ju.apply(void 0,e)};if(Nd(i))return this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:ju.apply(void 0,e)}):(this.consumeBadUrlRemnants(),op);if(34===i||39===i||40===i||Wd(i))return this.consumeBadUrlRemnants(),op;if(92===i){if(!zd(i,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),op;e.push(this.consumeEscapedCodePoint())}else e.push(i)}},e.prototype.consumeWhiteSpace=function(){for(;Nd(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(41===e||-1===e)return;zd(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t="";e>0;){var s=Math.min(5e4,e);t+=ju.apply(void 0,this._value.splice(0,s)),e-=s}return this._value.shift(),t},e.prototype.consumeStringToken=function(e){for(var t="",s=0;;){var i=this._value[s];if(-1===i||void 0===i||i===e)return{type:0,value:t+=this.consumeStringSlice(s)};if(10===i)return this._value.splice(0,s),ap;if(92===i){var r=this._value[s+1];-1!==r&&void 0!==r&&(10===r?(t+=this.consumeStringSlice(s),s=-1,this._value.shift()):zd(i,r)&&(t+=this.consumeStringSlice(s),t+=ju(this.consumeEscapedCodePoint()),s=-1))}s++}},e.prototype.consumeNumber=function(){var e=[],t=4,s=this.peekCodePoint(0);for(43!==s&&45!==s||e.push(this.consumeCodePoint());Ld(this.peekCodePoint(0));)e.push(this.consumeCodePoint());s=this.peekCodePoint(0);var i=this.peekCodePoint(1);if(46===s&&Ld(i))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;Ld(this.peekCodePoint(0));)e.push(this.consumeCodePoint());s=this.peekCodePoint(0),i=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((69===s||101===s)&&((43===i||45===i)&&Ld(r)||Ld(i)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;Ld(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[Zd(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],s=e[1],i=this.peekCodePoint(0),r=this.peekCodePoint(1),n=this.peekCodePoint(2);return Xd(i,r,n)?{type:15,number:t,flags:s,unit:this.consumeName()}:37===i?(this.consumeCodePoint(),{type:16,number:t,flags:s}):{type:17,number:t,flags:s}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(Hd(e)){for(var t=ju(e);Hd(this.peekCodePoint(0))&&t.length<6;)t+=ju(this.consumeCodePoint());Nd(this.peekCodePoint(0))&&this.consumeCodePoint();var s=parseInt(t,16);return 0===s||function(e){return e>=55296&&e<=57343}(s)||s>1114111?65533:s}return-1===e?65533:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(jd(t))e+=ju(t);else{if(!zd(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=ju(this.consumeEscapedCodePoint())}}},e}(),_p=function(){function e(e){this._tokens=e}return e.create=function(t){var s=new mp;return s.write(t),new e(s.read())},e.parseValue=function(t){return e.create(t).parseComponentValue()},e.parseValues=function(t){return e.create(t).parseComponentValues()},e.prototype.parseComponentValue=function(){for(var e=this.consumeToken();31===e.type;)e=this.consumeToken();if(32===e.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do{e=this.consumeToken()}while(31===e.type);if(32===e.type)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},e.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(32===t.type)return e;e.push(t),e.push()}},e.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},e.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},s=this.consumeToken();;){if(32===s.type||Fp(s,e))return t;this.reconsumeToken(s),t.values.push(this.consumeComponentValue()),s=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var s=this.consumeToken();if(32===s.type||3===s.type)return t;this.reconsumeToken(s),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?gp:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),bp=function(e){return 15===e.type},Bp=function(e){return 17===e.type},yp=function(e){return 20===e.type},wp=function(e){return 0===e.type},vp=function(e,t){return yp(e)&&e.value===t},Cp=function(e){return 31!==e.type},Mp=function(e){return 31!==e.type&&4!==e.type},Ep=function(e){var t=[],s=[];return e.forEach((function(e){if(4===e.type){if(0===s.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(s),void(s=[])}31!==e.type&&s.push(e)})),s.length&&t.push(s),t},Fp=function(e,t){return 11===t&&12===e.type||(28===t&&29===e.type||2===t&&3===e.type)},xp=function(e){return 17===e.type||15===e.type},Up=function(e){return 16===e.type||xp(e)},Ip=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},Tp={type:17,number:0,flags:4},Pp={type:16,number:50,flags:4},Sp={type:16,number:100,flags:4},Dp=function(e,t,s){var i=e[0],r=e[1];return[kp(i,t),kp(void 0!==r?r:i,s)]},kp=function(e,t){if(16===e.type)return e.number/100*t;if(bp(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},Qp=function(e,t){if(15===t.type)switch(t.unit){case"deg":return Math.PI*t.number/180;case"grad":return Math.PI/200*t.number;case"rad":return t.number;case"turn":return 2*Math.PI*t.number}throw new Error("Unsupported angle type")},Rp=function(e){return 15===e.type&&("deg"===e.unit||"grad"===e.unit||"rad"===e.unit||"turn"===e.unit)},Op=function(e){switch(e.filter(yp).map((function(e){return e.value})).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[Tp,Tp];case"to top":case"bottom":return Vp(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[Tp,Sp];case"to right":case"left":return Vp(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[Sp,Sp];case"to bottom":case"top":return Vp(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[Sp,Tp];case"to left":case"right":return Vp(270)}return 0},Vp=function(e){return Math.PI*e/180},Lp=function(e,t){if(18===t.type){var s=Kp[t.name];if(void 0===s)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return s(e,t.values)}if(5===t.type){if(3===t.value.length){var i=t.value.substring(0,1),r=t.value.substring(1,2),n=t.value.substring(2,3);return Gp(parseInt(i+i,16),parseInt(r+r,16),parseInt(n+n,16),1)}if(4===t.value.length){i=t.value.substring(0,1),r=t.value.substring(1,2),n=t.value.substring(2,3);var A=t.value.substring(3,4);return Gp(parseInt(i+i,16),parseInt(r+r,16),parseInt(n+n,16),parseInt(A+A,16)/255)}if(6===t.value.length){i=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6);return Gp(parseInt(i,16),parseInt(r,16),parseInt(n,16),1)}if(8===t.value.length){i=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6),A=t.value.substring(6,8);return Gp(parseInt(i,16),parseInt(r,16),parseInt(n,16),parseInt(A,16)/255)}}if(20===t.type){var o=Jp[t.value.toUpperCase()];if(void 0!==o)return o}return Jp.TRANSPARENT},Hp=function(e){return 0==(255&e)},Np=function(e){var t=255&e,s=255&e>>8,i=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+i+","+s+","+t/255+")":"rgb("+r+","+i+","+s+")"},Gp=function(e,t,s,i){return(e<<24|t<<16|s<<8|Math.round(255*i)<<0)>>>0},jp=function(e,t){if(17===e.type)return e.number;if(16===e.type){var s=3===t?1:255;return 3===t?e.number/100*s:Math.round(e.number/100*s)}return 0},Wp=function(e,t){var s=t.filter(Mp);if(3===s.length){var i=s.map(jp),r=i[0],n=i[1],A=i[2];return Gp(r,n,A,1)}if(4===s.length){var o=s.map(jp),a=(r=o[0],n=o[1],A=o[2],o[3]);return Gp(r,n,A,a)}return 0};function zp(e,t,s){return s<0&&(s+=1),s>=1&&(s-=1),s<1/6?(t-e)*s*6+e:s<.5?t:s<2/3?6*(t-e)*(2/3-s)+e:e}var Xp=function(e,t){var s=t.filter(Mp),i=s[0],r=s[1],n=s[2],A=s[3],o=(17===i.type?Vp(i.number):Qp(e,i))/(2*Math.PI),a=Up(r)?r.number/100:0,l=Up(n)?n.number/100:0,c=void 0!==A&&Up(A)?kp(A,1):1;if(0===a)return Gp(255*l,255*l,255*l,1);var h=l<=.5?l*(a+1):l+a-l*a,u=2*l-h,d=zp(u,h,o+1/3),p=zp(u,h,o),f=zp(u,h,o-1/3);return Gp(255*d,255*p,255*f,c)},Kp={hsl:Xp,hsla:Xp,rgb:Wp,rgba:Wp},Zp=function(e,t){return Lp(e,_p.create(t).parseComponentValue())},Jp={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Yp={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(yp(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},$p={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},qp=function(e,t){var s=Lp(e,t[0]),i=t[1];return i&&Up(i)?{color:s,stop:i}:{color:s,stop:null}},ef=function(e,t){var s=e[0],i=e[e.length-1];null===s.stop&&(s.stop=Tp),null===i.stop&&(i.stop=Sp);for(var r=[],n=0,A=0;A<e.length;A++){var o=e[A].stop;if(null!==o){var a=kp(o,t);a>n?r.push(a):r.push(n),n=a}else r.push(null)}var l=null;for(A=0;A<r.length;A++){var c=r[A];if(null===c)null===l&&(l=A);else if(null!==l){for(var h=A-l,u=(c-r[l-1])/(h+1),d=1;d<=h;d++)r[l+d-1]=u*d;l=null}}return e.map((function(e,s){return{color:e.color,stop:Math.max(Math.min(1,r[s]/t),0)}}))},tf=function(e,t,s){var i="number"==typeof e?e:function(e,t,s){var i=t/2,r=s/2,n=kp(e[0],t)-i,A=r-kp(e[1],s);return(Math.atan2(A,n)+2*Math.PI)%(2*Math.PI)}(e,t,s),r=Math.abs(t*Math.sin(i))+Math.abs(s*Math.cos(i)),n=t/2,A=s/2,o=r/2,a=Math.sin(i-Math.PI/2)*o,l=Math.cos(i-Math.PI/2)*o;return[r,n-l,n+l,A-a,A+a]},sf=function(e,t){return Math.sqrt(e*e+t*t)},rf=function(e,t,s,i,r){return[[0,0],[0,t],[e,0],[e,t]].reduce((function(e,t){var n=t[0],A=t[1],o=sf(s-n,i-A);return(r?o<e.optimumDistance:o>e.optimumDistance)?{optimumCorner:t,optimumDistance:o}:e}),{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},nf=function(e,t){var s=Vp(180),i=[];return Ep(t).forEach((function(t,r){if(0===r){var n=t[0];if(20===n.type&&-1!==["top","left","right","bottom"].indexOf(n.value))return void(s=Op(t));if(Rp(n))return void(s=(Qp(e,n)+Vp(270))%Vp(360))}var A=qp(e,t);i.push(A)})),{angle:s,stops:i,type:1}},Af=function(e,t){var s=0,i=3,r=[],n=[];return Ep(t).forEach((function(t,A){var o=!0;if(0===A?o=t.reduce((function(e,t){if(yp(t))switch(t.value){case"center":return n.push(Pp),!1;case"top":case"left":return n.push(Tp),!1;case"right":case"bottom":return n.push(Sp),!1}else if(Up(t)||xp(t))return n.push(t),!1;return e}),o):1===A&&(o=t.reduce((function(e,t){if(yp(t))switch(t.value){case"circle":return s=0,!1;case"ellipse":return s=1,!1;case"contain":case"closest-side":return i=0,!1;case"farthest-side":return i=1,!1;case"closest-corner":return i=2,!1;case"cover":case"farthest-corner":return i=3,!1}else if(xp(t)||Up(t))return Array.isArray(i)||(i=[]),i.push(t),!1;return e}),o)),o){var a=qp(e,t);r.push(a)}})),{size:i,shape:s,stops:r,position:n,type:2}},of=function(e,t){if(22===t.type){var s={url:t.value,type:0};return e.cache.addImage(t.value),s}if(18===t.type){var i=lf[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return i(e,t.values)}throw new Error("Unsupported image type "+t.type)};var af,lf={"linear-gradient":function(e,t){var s=Vp(180),i=[];return Ep(t).forEach((function(t,r){if(0===r){var n=t[0];if(20===n.type&&"to"===n.value)return void(s=Op(t));if(Rp(n))return void(s=Qp(e,n))}var A=qp(e,t);i.push(A)})),{angle:s,stops:i,type:1}},"-moz-linear-gradient":nf,"-ms-linear-gradient":nf,"-o-linear-gradient":nf,"-webkit-linear-gradient":nf,"radial-gradient":function(e,t){var s=0,i=3,r=[],n=[];return Ep(t).forEach((function(t,A){var o=!0;if(0===A){var a=!1;o=t.reduce((function(e,t){if(a)if(yp(t))switch(t.value){case"center":return n.push(Pp),e;case"top":case"left":return n.push(Tp),e;case"right":case"bottom":return n.push(Sp),e}else(Up(t)||xp(t))&&n.push(t);else if(yp(t))switch(t.value){case"circle":return s=0,!1;case"ellipse":return s=1,!1;case"at":return a=!0,!1;case"closest-side":return i=0,!1;case"cover":case"farthest-side":return i=1,!1;case"contain":case"closest-corner":return i=2,!1;case"farthest-corner":return i=3,!1}else if(xp(t)||Up(t))return Array.isArray(i)||(i=[]),i.push(t),!1;return e}),o)}if(o){var l=qp(e,t);r.push(l)}})),{size:i,shape:s,stops:r,position:n,type:2}},"-moz-radial-gradient":Af,"-ms-radial-gradient":Af,"-o-radial-gradient":Af,"-webkit-radial-gradient":Af,"-webkit-gradient":function(e,t){var s=Vp(180),i=[],r=1;return Ep(t).forEach((function(t,s){var n=t[0];if(0===s){if(yp(n)&&"linear"===n.value)return void(r=1);if(yp(n)&&"radial"===n.value)return void(r=2)}if(18===n.type)if("from"===n.name){var A=Lp(e,n.values[0]);i.push({stop:Tp,color:A})}else if("to"===n.name){A=Lp(e,n.values[0]);i.push({stop:Sp,color:A})}else if("color-stop"===n.name){var o=n.values.filter(Mp);if(2===o.length){A=Lp(e,o[1]);var a=o[0];Bp(a)&&i.push({stop:{type:16,number:100*a.number,flags:a.flags},color:A})}}})),1===r?{angle:(s+Vp(180))%Vp(360),stops:i,type:r}:{size:3,shape:0,stops:i,position:[],type:r}}},cf={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var s=t[0];return 20===s.type&&"none"===s.value?[]:t.filter((function(e){return Mp(e)&&function(e){return!(20===e.type&&"none"===e.value||18===e.type&&!lf[e.name])}(e)})).map((function(t){return of(e,t)}))}},hf={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(yp(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},uf={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return Ep(t).map((function(e){return e.filter(Up)})).map(Ip)}},df={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return Ep(t).map((function(e){return e.filter(yp).map((function(e){return e.value})).join(" ")})).map(pf)}},pf=function(e){switch(e){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(e){e.AUTO="auto",e.CONTAIN="contain",e.COVER="cover"}(af||(af={}));var ff,gf={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return Ep(t).map((function(e){return e.filter(mf)}))}},mf=function(e){return yp(e)||Up(e)},_f=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},bf=_f("top"),Bf=_f("right"),yf=_f("bottom"),wf=_f("left"),vf=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return Ip(t.filter(Up))}}},Cf=vf("top-left"),Mf=vf("top-right"),Ef=vf("bottom-right"),Ff=vf("bottom-left"),xf=function(e){return{name:"border-"+e+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},Uf=xf("top"),If=xf("right"),Tf=xf("bottom"),Pf=xf("left"),Sf=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return bp(t)?t.number:0}}},Df=Sf("top"),kf=Sf("right"),Qf=Sf("bottom"),Rf=Sf("left"),Of={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Vf={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},Lf={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(yp).reduce((function(e,t){return e|Hf(t.value)}),0)}},Hf=function(e){switch(e){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},Nf={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},Gf={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(e,t){return 20===t.type&&"normal"===t.value?0:17===t.type||15===t.type?t.number:0}};!function(e){e.NORMAL="normal",e.STRICT="strict"}(ff||(ff={}));var jf,Wf={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?ff.STRICT:ff.NORMAL}},zf={name:"line-height",initialValue:"normal",prefix:!1,type:4},Xf=function(e,t){return yp(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:Up(e)?kp(e,t):t},Kf={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:of(e,t)}},Zf={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},Jf={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},Yf=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},$f=Yf("top"),qf=Yf("right"),eg=Yf("bottom"),tg=Yf("left"),sg={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(yp).map((function(e){switch(e.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}}))}},ig={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},rg=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},ng=rg("top"),Ag=rg("right"),og=rg("bottom"),ag=rg("left"),lg={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(e,t){switch(t){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},cg={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(e,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},hg={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&vp(t[0],"none")?[]:Ep(t).map((function(t){for(var s={color:Jp.TRANSPARENT,offsetX:Tp,offsetY:Tp,blur:Tp},i=0,r=0;r<t.length;r++){var n=t[r];xp(n)?(0===i?s.offsetX=n:1===i?s.offsetY=n:s.blur=n,i++):s.color=Lp(e,n)}return s}))}},ug={name:"text-transform",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"uppercase":return 2;case"lowercase":return 1;case"capitalize":return 3}return 0}},dg={name:"transform",initialValue:"none",prefix:!0,type:0,parse:function(e,t){if(20===t.type&&"none"===t.value)return null;if(18===t.type){var s=pg[t.name];if(void 0===s)throw new Error('Attempting to parse an unsupported transform function "'+t.name+'"');return s(t.values)}return null}},pg={matrix:function(e){var t=e.filter((function(e){return 17===e.type})).map((function(e){return e.number}));return 6===t.length?t:null},matrix3d:function(e){var t=e.filter((function(e){return 17===e.type})).map((function(e){return e.number})),s=t[0],i=t[1];t[2],t[3];var r=t[4],n=t[5];t[6],t[7],t[8],t[9],t[10],t[11];var A=t[12],o=t[13];return t[14],t[15],16===t.length?[s,i,r,n,A,o]:null}},fg={type:16,number:50,flags:4},gg=[fg,fg],mg={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(e,t){var s=t.filter(Up);return 2!==s.length?gg:[s[0],s[1]]}},_g={name:"visible",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"hidden":return 1;case"collapse":return 2;default:return 0}}};!function(e){e.NORMAL="normal",e.BREAK_ALL="break-all",e.KEEP_ALL="keep-all"}(jf||(jf={}));for(var bg={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){switch(t){case"break-all":return jf.BREAK_ALL;case"keep-all":return jf.KEEP_ALL;default:return jf.NORMAL}}},Bg={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(e,t){if(20===t.type)return{auto:!0,order:0};if(Bp(t))return{auto:!1,order:t.number};throw new Error("Invalid z-index number parsed")}},yg=function(e,t){if(15===t.type)switch(t.unit.toLowerCase()){case"s":return 1e3*t.number;case"ms":return t.number}throw new Error("Unsupported time type")},wg={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(e,t){return Bp(t)?t.number:1}},vg={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Cg={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(e,t){return t.filter(yp).map((function(e){switch(e.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0})).filter((function(e){return 0!==e}))}},Mg={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(e,t){var s=[],i=[];return t.forEach((function(e){switch(e.type){case 20:case 0:s.push(e.value);break;case 17:s.push(e.number.toString());break;case 4:i.push(s.join(" ")),s.length=0}})),s.length&&i.push(s.join(" ")),i.map((function(e){return-1===e.indexOf(" ")?e:"'"+e+"'"}))}},Eg={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},Fg={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(e,t){return Bp(t)?t.number:yp(t)&&"bold"===t.value?700:400}},xg={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return t.filter(yp).map((function(e){return e.value}))}},Ug={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){switch(t){case"oblique":return"oblique";case"italic":return"italic";default:return"normal"}}},Ig=function(e,t){return 0!=(e&t)},Tg={name:"content",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var s=t[0];return 20===s.type&&"none"===s.value?[]:t}},Pg={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:function(e,t){if(0===t.length)return null;var s=t[0];if(20===s.type&&"none"===s.value)return null;for(var i=[],r=t.filter(Cp),n=0;n<r.length;n++){var A=r[n],o=r[n+1];if(20===A.type){var a=o&&Bp(o)?o.number:1;i.push({counter:A.value,increment:a})}}return i}},Sg={name:"counter-reset",initialValue:"none",prefix:!0,type:1,parse:function(e,t){if(0===t.length)return[];for(var s=[],i=t.filter(Cp),r=0;r<i.length;r++){var n=i[r],A=i[r+1];if(yp(n)&&"none"!==n.value){var o=A&&Bp(A)?A.number:0;s.push({counter:n.value,reset:o})}}return s}},Dg={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:function(e,t){return t.filter(bp).map((function(t){return yg(e,t)}))}},kg={name:"quotes",initialValue:"none",prefix:!0,type:1,parse:function(e,t){if(0===t.length)return null;var s=t[0];if(20===s.type&&"none"===s.value)return null;var i=[],r=t.filter(wp);if(r.length%2!=0)return null;for(var n=0;n<r.length;n+=2){var A=r[n].value,o=r[n+1].value;i.push({open:A,close:o})}return i}},Qg=function(e,t,s){if(!e)return"";var i=e[Math.min(t,e.length-1)];return i?s?i.open:i.close:""},Rg={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&vp(t[0],"none")?[]:Ep(t).map((function(t){for(var s={color:255,offsetX:Tp,offsetY:Tp,blur:Tp,spread:Tp,inset:!1},i=0,r=0;r<t.length;r++){var n=t[r];vp(n,"inset")?s.inset=!0:xp(n)?(0===i?s.offsetX=n:1===i?s.offsetY=n:2===i?s.blur=n:s.spread=n,i++):s.color=Lp(e,n)}return s}))}},Og={name:"paint-order",initialValue:"normal",prefix:!1,type:1,parse:function(e,t){var s=[];return t.filter(yp).forEach((function(e){switch(e.value){case"stroke":s.push(1);break;case"fill":s.push(0);break;case"markers":s.push(2)}})),[0,1,2].forEach((function(e){-1===s.indexOf(e)&&s.push(e)})),s}},Vg={name:"-webkit-text-stroke-color",initialValue:"currentcolor",prefix:!1,type:3,format:"color"},Lg={name:"-webkit-text-stroke-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return bp(t)?t.number:0}},Hg=function(){function e(e,t){var s,i;this.animationDuration=jg(e,Dg,t.animationDuration),this.backgroundClip=jg(e,Yp,t.backgroundClip),this.backgroundColor=jg(e,$p,t.backgroundColor),this.backgroundImage=jg(e,cf,t.backgroundImage),this.backgroundOrigin=jg(e,hf,t.backgroundOrigin),this.backgroundPosition=jg(e,uf,t.backgroundPosition),this.backgroundRepeat=jg(e,df,t.backgroundRepeat),this.backgroundSize=jg(e,gf,t.backgroundSize),this.borderTopColor=jg(e,bf,t.borderTopColor),this.borderRightColor=jg(e,Bf,t.borderRightColor),this.borderBottomColor=jg(e,yf,t.borderBottomColor),this.borderLeftColor=jg(e,wf,t.borderLeftColor),this.borderTopLeftRadius=jg(e,Cf,t.borderTopLeftRadius),this.borderTopRightRadius=jg(e,Mf,t.borderTopRightRadius),this.borderBottomRightRadius=jg(e,Ef,t.borderBottomRightRadius),this.borderBottomLeftRadius=jg(e,Ff,t.borderBottomLeftRadius),this.borderTopStyle=jg(e,Uf,t.borderTopStyle),this.borderRightStyle=jg(e,If,t.borderRightStyle),this.borderBottomStyle=jg(e,Tf,t.borderBottomStyle),this.borderLeftStyle=jg(e,Pf,t.borderLeftStyle),this.borderTopWidth=jg(e,Df,t.borderTopWidth),this.borderRightWidth=jg(e,kf,t.borderRightWidth),this.borderBottomWidth=jg(e,Qf,t.borderBottomWidth),this.borderLeftWidth=jg(e,Rf,t.borderLeftWidth),this.boxShadow=jg(e,Rg,t.boxShadow),this.color=jg(e,Of,t.color),this.direction=jg(e,Vf,t.direction),this.display=jg(e,Lf,t.display),this.float=jg(e,Nf,t.cssFloat),this.fontFamily=jg(e,Mg,t.fontFamily),this.fontSize=jg(e,Eg,t.fontSize),this.fontStyle=jg(e,Ug,t.fontStyle),this.fontVariant=jg(e,xg,t.fontVariant),this.fontWeight=jg(e,Fg,t.fontWeight),this.letterSpacing=jg(e,Gf,t.letterSpacing),this.lineBreak=jg(e,Wf,t.lineBreak),this.lineHeight=jg(e,zf,t.lineHeight),this.listStyleImage=jg(e,Kf,t.listStyleImage),this.listStylePosition=jg(e,Zf,t.listStylePosition),this.listStyleType=jg(e,Jf,t.listStyleType),this.marginTop=jg(e,$f,t.marginTop),this.marginRight=jg(e,qf,t.marginRight),this.marginBottom=jg(e,eg,t.marginBottom),this.marginLeft=jg(e,tg,t.marginLeft),this.opacity=jg(e,wg,t.opacity);var r=jg(e,sg,t.overflow);this.overflowX=r[0],this.overflowY=r[r.length>1?1:0],this.overflowWrap=jg(e,ig,t.overflowWrap),this.paddingTop=jg(e,ng,t.paddingTop),this.paddingRight=jg(e,Ag,t.paddingRight),this.paddingBottom=jg(e,og,t.paddingBottom),this.paddingLeft=jg(e,ag,t.paddingLeft),this.paintOrder=jg(e,Og,t.paintOrder),this.position=jg(e,cg,t.position),this.textAlign=jg(e,lg,t.textAlign),this.textDecorationColor=jg(e,vg,null!==(s=t.textDecorationColor)&&void 0!==s?s:t.color),this.textDecorationLine=jg(e,Cg,null!==(i=t.textDecorationLine)&&void 0!==i?i:t.textDecoration),this.textShadow=jg(e,hg,t.textShadow),this.textTransform=jg(e,ug,t.textTransform),this.transform=jg(e,dg,t.transform),this.transformOrigin=jg(e,mg,t.transformOrigin),this.visibility=jg(e,_g,t.visibility),this.webkitTextStrokeColor=jg(e,Vg,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=jg(e,Lg,t.webkitTextStrokeWidth),this.wordBreak=jg(e,bg,t.wordBreak),this.zIndex=jg(e,Bg,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return Hp(this.backgroundColor)},e.prototype.isTransformed=function(){return null!==this.transform},e.prototype.isPositioned=function(){return 0!==this.position},e.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},e.prototype.isFloating=function(){return 0!==this.float},e.prototype.isInlineLevel=function(){return Ig(this.display,4)||Ig(this.display,33554432)||Ig(this.display,268435456)||Ig(this.display,536870912)||Ig(this.display,67108864)||Ig(this.display,134217728)},e}(),Ng=function(e,t){this.content=jg(e,Tg,t.content),this.quotes=jg(e,kg,t.quotes)},Gg=function(e,t){this.counterIncrement=jg(e,Pg,t.counterIncrement),this.counterReset=jg(e,Sg,t.counterReset)},jg=function(e,t,s){var i=new mp,r=null!=s?s.toString():t.initialValue;i.write(r);var n=new _p(i.read());switch(t.type){case 2:var A=n.parseComponentValue();return t.parse(e,yp(A)?A.value:t.initialValue);case 0:return t.parse(e,n.parseComponentValue());case 1:return t.parse(e,n.parseComponentValues());case 4:return n.parseComponentValue();case 3:switch(t.format){case"angle":return Qp(e,n.parseComponentValue());case"color":return Lp(e,n.parseComponentValue());case"image":return of(e,n.parseComponentValue());case"length":var o=n.parseComponentValue();return xp(o)?o:Tp;case"length-percentage":var a=n.parseComponentValue();return Up(a)?a:Tp;case"time":return yg(e,n.parseComponentValue())}}},Wg=function(e,t){var s=function(e){switch(e.getAttribute("data-html2canvas-debug")){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}}(e);return 1===s||t===s},zg=function(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,Wg(t,3),this.styles=new Hg(e,window.getComputedStyle(t,null)),zm(t)&&(this.styles.animationDuration.some((function(e){return e>0}))&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=Nu(this.context,t),Wg(t,4)&&(this.flags|=16)},Xg="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Kg="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Zg=0;Zg<Xg.length;Zg++)Kg[Xg.charCodeAt(Zg)]=Zg;for(var Jg=function(e,t,s){return e.slice?e.slice(t,s):new Uint16Array(Array.prototype.slice.call(e,t,s))},Yg=function(){function e(e,t,s,i,r,n){this.initialValue=e,this.errorValue=t,this.highStart=s,this.highValueIndex=i,this.index=r,this.data=n}return e.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e<this.highStart)return t=2080+(e>>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),$g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qg="undefined"==typeof Uint8Array?[]:new Uint8Array(256),em=0;em<$g.length;em++)qg[$g.charCodeAt(em)]=em;var tm,sm=8,im=9,rm=11,nm=12,Am=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(String.fromCodePoint)return String.fromCodePoint.apply(String,e);var s=e.length;if(!s)return"";for(var i=[],r=-1,n="";++r<s;){var A=e[r];A<=65535?i.push(A):(A-=65536,i.push(55296+(A>>10),A%1024+56320)),(r+1===s||i.length>16384)&&(n+=String.fromCharCode.apply(String,i),i.length=0)}return n},om=function(e,t){var s,i,r,n=function(e){var t,s,i,r,n,A=.75*e.length,o=e.length,a=0;"="===e[e.length-1]&&(A--,"="===e[e.length-2]&&A--);var l="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(A):new Array(A),c=Array.isArray(l)?l:new Uint8Array(l);for(t=0;t<o;t+=4)s=Kg[e.charCodeAt(t)],i=Kg[e.charCodeAt(t+1)],r=Kg[e.charCodeAt(t+2)],n=Kg[e.charCodeAt(t+3)],c[a++]=s<<2|i>>4,c[a++]=(15&i)<<4|r>>2,c[a++]=(3&r)<<6|63&n;return l}(e),A=Array.isArray(n)?function(e){for(var t=e.length,s=[],i=0;i<t;i+=4)s.push(e[i+3]<<24|e[i+2]<<16|e[i+1]<<8|e[i]);return s}(n):new Uint32Array(n),o=Array.isArray(n)?function(e){for(var t=e.length,s=[],i=0;i<t;i+=2)s.push(e[i+1]<<8|e[i]);return s}(n):new Uint16Array(n),a=Jg(o,12,A[4]/2),l=2===A[5]?Jg(o,(24+A[4])/2):(s=A,i=Math.ceil((24+A[4])/4),s.slice?s.slice(i,r):new Uint32Array(Array.prototype.slice.call(s,i,r)));return new Yg(A[0],A[1],A[2],A[3],a,l)}("AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA="),am=function(e){return om.get(e)},lm=function(e,t,s){var i=s-2,r=t[i],n=t[s-1],A=t[s];if(2===n&&3===A)return"×";if(2===n||3===n||4===n)return"÷";if(2===A||3===A||4===A)return"÷";if(n===sm&&-1!==[sm,im,rm,nm].indexOf(A))return"×";if(!(n!==rm&&n!==im||A!==im&&10!==A))return"×";if((n===nm||10===n)&&10===A)return"×";if(13===A||5===A)return"×";if(7===A)return"×";if(1===n)return"×";if(13===n&&14===A){for(;5===r;)r=t[--i];if(14===r)return"×"}if(15===n&&15===A){for(var o=0;15===r;)o++,r=t[--i];if(o%2==0)return"×"}return"÷"},cm=function(e){var t=function(e){for(var t=[],s=0,i=e.length;s<i;){var r=e.charCodeAt(s++);if(r>=55296&&r<=56319&&s<i){var n=e.charCodeAt(s++);56320==(64512&n)?t.push(((1023&r)<<10)+(1023&n)+65536):(t.push(r),s--)}else t.push(r)}return t}(e),s=t.length,i=0,r=0,n=t.map(am);return{next:function(){if(i>=s)return{done:!0,value:null};for(var e="×";i<s&&"×"===(e=lm(0,n,++i)););if("×"!==e||i===s){var A=Am.apply(null,t.slice(r,i));return r=i,{value:A,done:!1}}return{done:!0,value:null}}}},hm=function(e){return 0===e[0]&&255===e[1]&&0===e[2]&&255===e[3]},um=function(e,t,s,i,r){var n="http://www.w3.org/2000/svg",A=document.createElementNS(n,"svg"),o=document.createElementNS(n,"foreignObject");return A.setAttributeNS(null,"width",e.toString()),A.setAttributeNS(null,"height",t.toString()),o.setAttributeNS(null,"width","100%"),o.setAttributeNS(null,"height","100%"),o.setAttributeNS(null,"x",s.toString()),o.setAttributeNS(null,"y",i.toString()),o.setAttributeNS(null,"externalResourcesRequired","true"),A.appendChild(o),o.appendChild(r),A},dm=function(e){return new Promise((function(t,s){var i=new Image;i.onload=function(){return t(i)},i.onerror=s,i.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(e))}))},pm={get SUPPORT_RANGE_BOUNDS(){var e=function(e){if(e.createRange){var t=e.createRange();if(t.getBoundingClientRect){var s=e.createElement("boundtest");s.style.height="123px",s.style.display="block",e.body.appendChild(s),t.selectNode(s);var i=t.getBoundingClientRect(),r=Math.round(i.height);if(e.body.removeChild(s),123===r)return!0}}return!1}(document);return Object.defineProperty(pm,"SUPPORT_RANGE_BOUNDS",{value:e}),e},get SUPPORT_WORD_BREAKING(){var e=pm.SUPPORT_RANGE_BOUNDS&&function(e){var t=e.createElement("boundtest");t.style.width="50px",t.style.display="block",t.style.fontSize="12px",t.style.letterSpacing="0px",t.style.wordSpacing="0px",e.body.appendChild(t);var s=e.createRange();t.innerHTML="function"==typeof"".repeat?"👨".repeat(10):"";var i=t.firstChild,r=Gu(i.data).map((function(e){return ju(e)})),n=0,A={},o=r.every((function(e,t){s.setStart(i,n),s.setEnd(i,n+e.length);var r=s.getBoundingClientRect();n+=e.length;var o=r.x>A.x||r.y>A.y;return A=r,0===t||o}));return e.body.removeChild(t),o}(document);return Object.defineProperty(pm,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=function(e){var t=new Image,s=e.createElement("canvas"),i=s.getContext("2d");if(!i)return!1;t.src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";try{i.drawImage(t,0,0),s.toDataURL()}catch(e){return!1}return!0}(document);return Object.defineProperty(pm,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){var e="function"==typeof Array.from&&"function"==typeof window.fetch?function(e){var t=e.createElement("canvas"),s=100;t.width=s,t.height=s;var i=t.getContext("2d");if(!i)return Promise.reject(!1);i.fillStyle="rgb(0, 255, 0)",i.fillRect(0,0,s,s);var r=new Image,n=t.toDataURL();r.src=n;var A=um(s,s,0,0,r);return i.fillStyle="red",i.fillRect(0,0,s,s),dm(A).then((function(t){i.drawImage(t,0,0);var r=i.getImageData(0,0,s,s).data;i.fillStyle="red",i.fillRect(0,0,s,s);var A=e.createElement("div");return A.style.backgroundImage="url("+n+")",A.style.height="100px",hm(r)?dm(um(s,s,0,0,A)):Promise.reject(!1)})).then((function(e){return i.drawImage(e,0,0),hm(i.getImageData(0,0,s,s).data)})).catch((function(){return!1}))}(document):Promise.resolve(!1);return Object.defineProperty(pm,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=void 0!==(new Image).crossOrigin;return Object.defineProperty(pm,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(pm,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(pm,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(pm,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},fm=function(e,t){this.text=e,this.bounds=t},gm=function(e,t){var s=t.ownerDocument;if(s){var i=s.createElement("html2canvaswrapper");i.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(i,t);var n=Nu(e,i);return i.firstChild&&r.replaceChild(i.firstChild,i),n}}return Hu.EMPTY},mm=function(e,t,s){var i=e.ownerDocument;if(!i)throw new Error("Node has no owner document");var r=i.createRange();return r.setStart(e,t),r.setEnd(e,t+s),r},_m=function(e){if(pm.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e)).map((function(e){return e.segment}))}return function(e){for(var t,s=cm(e),i=[];!(t=s.next()).done;)t.value&&i.push(t.value.slice());return i}(e)},bm=function(e,t){return 0!==t.letterSpacing?_m(e):function(e,t){if(pm.SUPPORT_NATIVE_TEXT_SEGMENTATION){var s=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(s.segment(e)).map((function(e){return e.segment}))}return ym(e,t)}(e,t)},Bm=[32,160,4961,65792,65793,4153,4241],ym=function(e,t){for(var s,i=function(e,t){var s=Gu(e),i=Od(s,t),r=i[0],n=i[1],A=i[2],o=s.length,a=0,l=0;return{next:function(){if(l>=o)return{done:!0,value:null};for(var e="×";l<o&&"×"===(e=Rd(s,n,r,++l,A)););if("×"!==e||l===o){var t=new Vd(s,e,a,l);return a=l,{value:t,done:!1}}return{done:!0,value:null}}}}(e,{lineBreak:t.lineBreak,wordBreak:"break-word"===t.overflowWrap?"break-word":t.wordBreak}),r=[],n=function(){if(s.value){var e=s.value.slice(),t=Gu(e),i="";t.forEach((function(e){-1===Bm.indexOf(e)?i+=ju(e):(i.length&&r.push(i),r.push(ju(e)),i="")})),i.length&&r.push(i)}};!(s=i.next()).done;)n();return r},wm=function(e,t,s){this.text=vm(t.data,s.textTransform),this.textBounds=function(e,t,s,i){var r=bm(t,s),n=[],A=0;return r.forEach((function(t){if(s.textDecorationLine.length||t.trim().length>0)if(pm.SUPPORT_RANGE_BOUNDS){var r=mm(i,A,t.length).getClientRects();if(r.length>1){var o=_m(t),a=0;o.forEach((function(t){n.push(new fm(t,Hu.fromDOMRectList(e,mm(i,a+A,t.length).getClientRects()))),a+=t.length}))}else n.push(new fm(t,Hu.fromDOMRectList(e,r)))}else{var l=i.splitText(t.length);n.push(new fm(t,gm(e,i))),i=l}else pm.SUPPORT_RANGE_BOUNDS||(i=i.splitText(t.length));A+=t.length})),n}(e,this.text,s,t)},vm=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(Cm,Mm);case 2:return e.toUpperCase();default:return e}},Cm=/(^|\s|:|-|\(|\))([a-z])/g,Mm=function(e,t,s){return e.length>0?t+s.toUpperCase():e},Em=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i.src=s.currentSrc||s.src,i.intrinsicWidth=s.naturalWidth,i.intrinsicHeight=s.naturalHeight,i.context.cache.addImage(i.src),i}return Qu(t,e),t}(zg),Fm=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i.canvas=s,i.intrinsicWidth=s.width,i.intrinsicHeight=s.height,i}return Qu(t,e),t}(zg),xm=function(e){function t(t,s){var i=e.call(this,t,s)||this,r=new XMLSerializer,n=Nu(t,s);return s.setAttribute("width",n.width+"px"),s.setAttribute("height",n.height+"px"),i.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(s)),i.intrinsicWidth=s.width.baseVal.value,i.intrinsicHeight=s.height.baseVal.value,i.context.cache.addImage(i.svg),i}return Qu(t,e),t}(zg),Um=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i.value=s.value,i}return Qu(t,e),t}(zg),Im=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i.start=s.start,i.reversed="boolean"==typeof s.reversed&&!0===s.reversed,i}return Qu(t,e),t}(zg),Tm=[{type:15,flags:0,unit:"px",number:3}],Pm=[{type:16,flags:0,number:50}],Sm="password",Dm=function(e){function t(t,s){var i,r,n,A=e.call(this,t,s)||this;switch(A.type=s.type.toLowerCase(),A.checked=s.checked,A.value=0===(r=(i=s).type===Sm?new Array(i.value.length+1).join("•"):i.value).length?i.placeholder||"":r,"checkbox"!==A.type&&"radio"!==A.type||(A.styles.backgroundColor=3739148031,A.styles.borderTopColor=A.styles.borderRightColor=A.styles.borderBottomColor=A.styles.borderLeftColor=2779096575,A.styles.borderTopWidth=A.styles.borderRightWidth=A.styles.borderBottomWidth=A.styles.borderLeftWidth=1,A.styles.borderTopStyle=A.styles.borderRightStyle=A.styles.borderBottomStyle=A.styles.borderLeftStyle=1,A.styles.backgroundClip=[0],A.styles.backgroundOrigin=[0],A.bounds=(n=A.bounds).width>n.height?new Hu(n.left+(n.width-n.height)/2,n.top,n.height,n.height):n.width<n.height?new Hu(n.left,n.top+(n.height-n.width)/2,n.width,n.width):n),A.type){case"checkbox":A.styles.borderTopRightRadius=A.styles.borderTopLeftRadius=A.styles.borderBottomRightRadius=A.styles.borderBottomLeftRadius=Tm;break;case"radio":A.styles.borderTopRightRadius=A.styles.borderTopLeftRadius=A.styles.borderBottomRightRadius=A.styles.borderBottomLeftRadius=Pm}return A}return Qu(t,e),t}(zg),km=function(e){function t(t,s){var i=e.call(this,t,s)||this,r=s.options[s.selectedIndex||0];return i.value=r&&r.text||"",i}return Qu(t,e),t}(zg),Qm=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i.value=s.value,i}return Qu(t,e),t}(zg),Rm=function(e){function t(t,s){var i=e.call(this,t,s)||this;i.src=s.src,i.width=parseInt(s.width,10)||0,i.height=parseInt(s.height,10)||0,i.backgroundColor=i.styles.backgroundColor;try{if(s.contentWindow&&s.contentWindow.document&&s.contentWindow.document.documentElement){i.tree=Hm(t,s.contentWindow.document.documentElement);var r=s.contentWindow.document.documentElement?Zp(t,getComputedStyle(s.contentWindow.document.documentElement).backgroundColor):Jp.TRANSPARENT,n=s.contentWindow.document.body?Zp(t,getComputedStyle(s.contentWindow.document.body).backgroundColor):Jp.TRANSPARENT;i.backgroundColor=Hp(r)?Hp(n)?i.styles.backgroundColor:n:r}}catch(e){}return i}return Qu(t,e),t}(zg),Om=["OL","UL","MENU"],Vm=function(e,t,s,i){for(var r=t.firstChild,n=void 0;r;r=n)if(n=r.nextSibling,jm(r)&&r.data.trim().length>0)s.textNodes.push(new wm(e,r,s.styles));else if(Wm(r))if(A_(r)&&r.assignedNodes)r.assignedNodes().forEach((function(t){return Vm(e,t,s,i)}));else{var A=Lm(e,r);A.styles.isVisible()&&(Nm(r,A,i)?A.flags|=4:Gm(A.styles)&&(A.flags|=2),-1!==Om.indexOf(r.tagName)&&(A.flags|=8),s.elements.push(A),r.slot,r.shadowRoot?Vm(e,r.shadowRoot,A,i):r_(r)||Ym(r)||n_(r)||Vm(e,r,A,i))}},Lm=function(e,t){return t_(t)?new Em(e,t):qm(t)?new Fm(e,t):Ym(t)?new xm(e,t):Km(t)?new Um(e,t):Zm(t)?new Im(e,t):Jm(t)?new Dm(e,t):n_(t)?new km(e,t):r_(t)?new Qm(e,t):s_(t)?new Rm(e,t):new zg(e,t)},Hm=function(e,t){var s=Lm(e,t);return s.flags|=4,Vm(e,t,s,s),s},Nm=function(e,t,s){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||$m(e)&&s.styles.isTransparent()},Gm=function(e){return e.isPositioned()||e.isFloating()},jm=function(e){return e.nodeType===Node.TEXT_NODE},Wm=function(e){return e.nodeType===Node.ELEMENT_NODE},zm=function(e){return Wm(e)&&void 0!==e.style&&!Xm(e)},Xm=function(e){return"object"==typeof e.className},Km=function(e){return"LI"===e.tagName},Zm=function(e){return"OL"===e.tagName},Jm=function(e){return"INPUT"===e.tagName},Ym=function(e){return"svg"===e.tagName},$m=function(e){return"BODY"===e.tagName},qm=function(e){return"CANVAS"===e.tagName},e_=function(e){return"VIDEO"===e.tagName},t_=function(e){return"IMG"===e.tagName},s_=function(e){return"IFRAME"===e.tagName},i_=function(e){return"STYLE"===e.tagName},r_=function(e){return"TEXTAREA"===e.tagName},n_=function(e){return"SELECT"===e.tagName},A_=function(e){return"SLOT"===e.tagName},o_=function(e){return e.tagName.indexOf("-")>0},a_=function(){function e(){this.counters={}}return e.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},e.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},e.prototype.pop=function(e){var t=this;e.forEach((function(e){return t.counters[e].pop()}))},e.prototype.parse=function(e){var t=this,s=e.counterIncrement,i=e.counterReset,r=!0;null!==s&&s.forEach((function(e){var s=t.counters[e.counter];s&&0!==e.increment&&(r=!1,s.length||s.push(1),s[Math.max(0,s.length-1)]+=e.increment)}));var n=[];return r&&i.forEach((function(e){var s=t.counters[e.counter];n.push(e.counter),s||(s=t.counters[e.counter]=[]),s.push(e.reset)})),n},e}(),l_={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},c_={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},h_={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},u_={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},d_=function(e,t,s,i,r,n){return e<t||e>s?__(e,r,n.length>0):i.integers.reduce((function(t,s,r){for(;e>=s;)e-=s,t+=i.values[r];return t}),"")+n},p_=function(e,t,s,i){var r="";do{s||e--,r=i(e)+r,e/=t}while(e*t>=t);return r},f_=function(e,t,s,i,r){var n=s-t+1;return(e<0?"-":"")+(p_(Math.abs(e),n,i,(function(e){return ju(Math.floor(e%n)+t)}))+r)},g_=function(e,t,s){void 0===s&&(s=". ");var i=t.length;return p_(Math.abs(e),i,!1,(function(e){return t[Math.floor(e%i)]}))+s},m_=function(e,t,s,i,r,n){if(e<-9999||e>9999)return __(e,4,r.length>0);var A=Math.abs(e),o=r;if(0===A)return t[0]+o;for(var a=0;A>0&&a<=4;a++){var l=A%10;0===l&&Ig(n,1)&&""!==o?o=t[l]+o:l>1||1===l&&0===a||1===l&&1===a&&Ig(n,2)||1===l&&1===a&&Ig(n,4)&&e>100||1===l&&a>1&&Ig(n,8)?o=t[l]+(a>0?s[a-1]:"")+o:1===l&&a>0&&(o=s[a-1]+o),A=Math.floor(A/10)}return(e<0?i:"")+o},__=function(e,t,s){var i=s?". ":"",r=s?"、":"",n=s?", ":"",A=s?" ":"";switch(t){case 0:return"•"+A;case 1:return"◦"+A;case 2:return"◾"+A;case 5:var o=f_(e,48,57,!0,i);return o.length<4?"0"+o:o;case 4:return g_(e,"〇一二三四五六七八九",r);case 6:return d_(e,1,3999,l_,3,i).toLowerCase();case 7:return d_(e,1,3999,l_,3,i);case 8:return f_(e,945,969,!1,i);case 9:return f_(e,97,122,!1,i);case 10:return f_(e,65,90,!1,i);case 11:return f_(e,1632,1641,!0,i);case 12:case 49:return d_(e,1,9999,c_,3,i);case 35:return d_(e,1,9999,c_,3,i).toLowerCase();case 13:return f_(e,2534,2543,!0,i);case 14:case 30:return f_(e,6112,6121,!0,i);case 15:return g_(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return g_(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return m_(e,"零一二三四五六七八九","十百千萬","負",r,14);case 47:return m_(e,"零壹貳參肆伍陸柒捌玖","拾佰仟萬","負",r,15);case 42:return m_(e,"零一二三四五六七八九","十百千萬","负",r,14);case 41:return m_(e,"零壹贰叁肆伍陆柒捌玖","拾佰仟萬","负",r,15);case 26:return m_(e,"〇一二三四五六七八九","十百千万","マイナス",r,0);case 25:return m_(e,"零壱弐参四伍六七八九","拾百千万","マイナス",r,7);case 31:return m_(e,"영일이삼사오육칠팔구","십백천만","마이너스",n,7);case 33:return m_(e,"零一二三四五六七八九","十百千萬","마이너스",n,0);case 32:return m_(e,"零壹貳參四五六七八九","拾百千","마이너스",n,7);case 18:return f_(e,2406,2415,!0,i);case 20:return d_(e,1,19999,u_,3,i);case 21:return f_(e,2790,2799,!0,i);case 22:return f_(e,2662,2671,!0,i);case 22:return d_(e,1,10999,h_,3,i);case 23:return g_(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return g_(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return f_(e,3302,3311,!0,i);case 28:return g_(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return g_(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return f_(e,3792,3801,!0,i);case 37:return f_(e,6160,6169,!0,i);case 38:return f_(e,4160,4169,!0,i);case 39:return f_(e,2918,2927,!0,i);case 40:return f_(e,1776,1785,!0,i);case 43:return f_(e,3046,3055,!0,i);case 44:return f_(e,3174,3183,!0,i);case 45:return f_(e,3664,3673,!0,i);case 46:return f_(e,3872,3881,!0,i);default:return f_(e,48,57,!0,i)}},b_=function(){function e(e,t,s){if(this.context=e,this.options=s,this.scrolledElements=[],this.referenceElement=t,this.counters=new a_,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return e.prototype.toIFrame=function(e,t){var s=this,i=y_(e,t);if(!i.contentWindow)return Promise.reject("Unable to find iframe window");var r=e.defaultView.pageXOffset,n=e.defaultView.pageYOffset,A=i.contentWindow,o=A.document,a=C_(i).then((function(){return Ou(s,void 0,void 0,(function(){var e,s;return Vu(this,(function(r){switch(r.label){case 0:return this.scrolledElements.forEach(U_),A&&(A.scrollTo(t.left,t.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||A.scrollY===t.top&&A.scrollX===t.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(A.scrollX-t.left,A.scrollY-t.top,0,0))),e=this.options.onclone,void 0===(s=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:o.fonts&&o.fonts.ready?[4,o.fonts.ready]:[3,2];case 1:r.sent(),r.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,v_(o)]:[3,4];case 3:r.sent(),r.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then((function(){return e(o,s)})).then((function(){return i}))]:[2,i]}}))}))}));return o.open(),o.write(F_(document.doctype)+"<html></html>"),x_(this.referenceElement.ownerDocument,r,n),o.replaceChild(o.adoptNode(this.documentElement),o.documentElement),o.close(),a},e.prototype.createElementClone=function(e){if(Wg(e,2),qm(e))return this.createCanvasClone(e);if(e_(e))return this.createVideoClone(e);if(i_(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return t_(t)&&(t_(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),o_(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return E_(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var s=[].slice.call(t.cssRules,0).reduce((function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e}),""),i=e.cloneNode(!1);return i.textContent=s,i}}catch(e){if(this.context.logger.error("Unable to access cssRules property",e),"SecurityError"!==e.name)throw e}return e.cloneNode(!1)},e.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var s=e.ownerDocument.createElement("img");try{return s.src=e.toDataURL(),s}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var i=e.cloneNode(!1);try{i.width=e.width,i.height=e.height;var r=e.getContext("2d"),n=i.getContext("2d");if(n)if(!this.options.allowTaint&&r)n.putImageData(r.getImageData(0,0,e.width,e.height),0,0);else{var A=null!==(t=e.getContext("webgl2"))&&void 0!==t?t:e.getContext("webgl");if(A){var o=A.getContextAttributes();!1===(null==o?void 0:o.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}n.drawImage(e,0,0)}return i}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return i},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var s=t.getContext("2d");try{return s&&(s.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||s.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var i=e.ownerDocument.createElement("canvas");return i.width=e.offsetWidth,i.height=e.offsetHeight,i},e.prototype.appendChildNode=function(e,t,s){Wm(t)&&("SCRIPT"===t.tagName||t.hasAttribute("data-html2canvas-ignore")||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&Wm(t)&&i_(t)||e.appendChild(this.cloneNode(t,s))},e.prototype.cloneChildNodes=function(e,t,s){for(var i=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(Wm(r)&&A_(r)&&"function"==typeof r.assignedNodes){var n=r.assignedNodes();n.length&&n.forEach((function(e){return i.appendChildNode(t,e,s)}))}else this.appendChildNode(t,r,s)},e.prototype.cloneNode=function(e,t){if(jm(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var s=e.ownerDocument.defaultView;if(s&&Wm(e)&&(zm(e)||Xm(e))){var i=this.createElementClone(e);i.style.transitionProperty="none";var r=s.getComputedStyle(e),n=s.getComputedStyle(e,":before"),A=s.getComputedStyle(e,":after");this.referenceElement===e&&zm(i)&&(this.clonedReferenceElement=i),$m(i)&&P_(i);var o=this.counters.parse(new Gg(this.context,r)),a=this.resolvePseudoContent(e,i,n,tm.BEFORE);o_(e)&&(t=!0),e_(e)||this.cloneChildNodes(e,i,t),a&&i.insertBefore(a,i.firstChild);var l=this.resolvePseudoContent(e,i,A,tm.AFTER);return l&&i.appendChild(l),this.counters.pop(o),(r&&(this.options.copyStyles||Xm(e))&&!s_(e)||t)&&E_(r,i),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([i,e.scrollLeft,e.scrollTop]),(r_(e)||n_(e))&&(r_(i)||n_(i))&&(i.value=e.value),i}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,s,i){var r=this;if(s){var n=s.content,A=t.ownerDocument;if(A&&n&&"none"!==n&&"-moz-alt-content"!==n&&"none"!==s.display){this.counters.parse(new Gg(this.context,s));var o=new Ng(this.context,s),a=A.createElement("html2canvaspseudoelement");E_(s,a),o.content.forEach((function(t){if(0===t.type)a.appendChild(A.createTextNode(t.value));else if(22===t.type){var s=A.createElement("img");s.src=t.value,s.style.opacity="1",a.appendChild(s)}else if(18===t.type){if("attr"===t.name){var i=t.values.filter(yp);i.length&&a.appendChild(A.createTextNode(e.getAttribute(i[0].value)||""))}else if("counter"===t.name){var n=t.values.filter(Mp),l=n[0],c=n[1];if(l&&yp(l)){var h=r.counters.getCounterValue(l.value),u=c&&yp(c)?Jf.parse(r.context,c.value):3;a.appendChild(A.createTextNode(__(h,u,!1)))}}else if("counters"===t.name){var d=t.values.filter(Mp),p=(l=d[0],d[1]);c=d[2];if(l&&yp(l)){var f=r.counters.getCounterValues(l.value),g=c&&yp(c)?Jf.parse(r.context,c.value):3,m=p&&0===p.type?p.value:"",_=f.map((function(e){return __(e,g,!1)})).join(m);a.appendChild(A.createTextNode(_))}}}else if(20===t.type)switch(t.value){case"open-quote":a.appendChild(A.createTextNode(Qg(o.quotes,r.quoteDepth++,!0)));break;case"close-quote":a.appendChild(A.createTextNode(Qg(o.quotes,--r.quoteDepth,!1)));break;default:a.appendChild(A.createTextNode(t.value))}})),a.className=I_+" "+T_;var l=i===tm.BEFORE?" "+I_:" "+T_;return Xm(t)?t.className.baseValue+=l:t.className+=l,a}}},e.destroy=function(e){return!!e.parentNode&&(e.parentNode.removeChild(e),!0)},e}();!function(e){e[e.BEFORE=0]="BEFORE",e[e.AFTER=1]="AFTER"}(tm||(tm={}));var B_,y_=function(e,t){var s=e.createElement("iframe");return s.className="html2canvas-container",s.style.visibility="hidden",s.style.position="fixed",s.style.left="-10000px",s.style.top="0px",s.style.border="0",s.width=t.width.toString(),s.height=t.height.toString(),s.scrolling="no",s.setAttribute("data-html2canvas-ignore","true"),e.body.appendChild(s),s},w_=function(e){return new Promise((function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}))},v_=function(e){return Promise.all([].slice.call(e.images,0).map(w_))},C_=function(e){return new Promise((function(t,s){var i=e.contentWindow;if(!i)return s("No window assigned for iframe");var r=i.document;i.onload=e.onload=function(){i.onload=e.onload=null;var s=setInterval((function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(s),t(e))}),50)}}))},M_=["all","d","content"],E_=function(e,t){for(var s=e.length-1;s>=0;s--){var i=e.item(s);-1===M_.indexOf(i)&&t.style.setProperty(i,e.getPropertyValue(i))}return t},F_=function(e){var t="";return e&&(t+="<!DOCTYPE ",e.name&&(t+=e.name),e.internalSubset&&(t+=e.internalSubset),e.publicId&&(t+='"'+e.publicId+'"'),e.systemId&&(t+='"'+e.systemId+'"'),t+=">"),t},x_=function(e,t,s){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||s!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,s)},U_=function(e){var t=e[0],s=e[1],i=e[2];t.scrollLeft=s,t.scrollTop=i},I_="___html2canvas___pseudoelement_before",T_="___html2canvas___pseudoelement_after",P_=function(e){S_(e,"."+I_+':before{\n content: "" !important;\n display: none !important;\n}\n .'+T_+':after{\n content: "" !important;\n display: none !important;\n}')},S_=function(e,t){var s=e.ownerDocument;if(s){var i=s.createElement("style");i.textContent=t,e.appendChild(i)}},D_=function(){function e(){}return e.getOrigin=function(t){var s=e._link;return s?(s.href=t,s.href=s.href,s.protocol+s.hostname+s.port):"about:blank"},e.isSameOrigin=function(t){return e.getOrigin(t)===e._origin},e.setContext=function(t){e._link=t.document.createElement("a"),e._origin=e.getOrigin(t.location.href)},e._origin="about:blank",e}(),k_=function(){function e(e,t){this.context=e,this._options=t,this._cache={}}return e.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)?t:N_(e)||V_(e)?((this._cache[e]=this.loadImage(e)).catch((function(){})),t):t},e.prototype.match=function(e){return this._cache[e]},e.prototype.loadImage=function(e){return Ou(this,void 0,void 0,(function(){var t,s,i,r,n=this;return Vu(this,(function(A){switch(A.label){case 0:return t=D_.isSameOrigin(e),s=!L_(e)&&!0===this._options.useCORS&&pm.SUPPORT_CORS_IMAGES&&!t,i=!L_(e)&&!t&&!N_(e)&&"string"==typeof this._options.proxy&&pm.SUPPORT_CORS_XHR&&!s,t||!1!==this._options.allowTaint||L_(e)||N_(e)||i||s?(r=e,i?[4,this.proxy(r)]:[3,2]):[2];case 1:r=A.sent(),A.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise((function(e,t){var i=new Image;i.onload=function(){return e(i)},i.onerror=t,(H_(r)||s)&&(i.crossOrigin="anonymous"),i.src=r,!0===i.complete&&setTimeout((function(){return e(i)}),500),n._options.imageTimeout>0&&setTimeout((function(){return t("Timed out ("+n._options.imageTimeout+"ms) loading image")}),n._options.imageTimeout)}))];case 3:return[2,A.sent()]}}))}))},e.prototype.has=function(e){return void 0!==this._cache[e]},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(e){var t=this,s=this._options.proxy;if(!s)throw new Error("No proxy defined");var i=e.substring(0,256);return new Promise((function(r,n){var A=pm.SUPPORT_RESPONSE_TYPE?"blob":"text",o=new XMLHttpRequest;o.onload=function(){if(200===o.status)if("text"===A)r(o.response);else{var e=new FileReader;e.addEventListener("load",(function(){return r(e.result)}),!1),e.addEventListener("error",(function(e){return n(e)}),!1),e.readAsDataURL(o.response)}else n("Failed to proxy resource "+i+" with status code "+o.status)},o.onerror=n;var a=s.indexOf("?")>-1?"&":"?";if(o.open("GET",""+s+a+"url="+encodeURIComponent(e)+"&responseType="+A),"text"!==A&&o instanceof XMLHttpRequest&&(o.responseType=A),t._options.imageTimeout){var l=t._options.imageTimeout;o.timeout=l,o.ontimeout=function(){return n("Timed out ("+l+"ms) proxying "+i)}}o.send()}))},e}(),Q_=/^data:image\/svg\+xml/i,R_=/^data:image\/.*;base64,/i,O_=/^data:image\/.*/i,V_=function(e){return pm.SUPPORT_SVG_DRAWING||!G_(e)},L_=function(e){return O_.test(e)},H_=function(e){return R_.test(e)},N_=function(e){return"blob"===e.substr(0,4)},G_=function(e){return"svg"===e.substr(-3).toLowerCase()||Q_.test(e)},j_=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,s){return new e(this.x+t,this.y+s)},e}(),W_=function(e,t,s){return new j_(e.x+(t.x-e.x)*s,e.y+(t.y-e.y)*s)},z_=function(){function e(e,t,s,i){this.type=1,this.start=e,this.startControl=t,this.endControl=s,this.end=i}return e.prototype.subdivide=function(t,s){var i=W_(this.start,this.startControl,t),r=W_(this.startControl,this.endControl,t),n=W_(this.endControl,this.end,t),A=W_(i,r,t),o=W_(r,n,t),a=W_(A,o,t);return s?new e(this.start,i,A,a):new e(a,o,n,this.end)},e.prototype.add=function(t,s){return new e(this.start.add(t,s),this.startControl.add(t,s),this.endControl.add(t,s),this.end.add(t,s))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),X_=function(e){return 1===e.type},K_=function(e){var t=e.styles,s=e.bounds,i=Dp(t.borderTopLeftRadius,s.width,s.height),r=i[0],n=i[1],A=Dp(t.borderTopRightRadius,s.width,s.height),o=A[0],a=A[1],l=Dp(t.borderBottomRightRadius,s.width,s.height),c=l[0],h=l[1],u=Dp(t.borderBottomLeftRadius,s.width,s.height),d=u[0],p=u[1],f=[];f.push((r+o)/s.width),f.push((d+c)/s.width),f.push((n+p)/s.height),f.push((a+h)/s.height);var g=Math.max.apply(Math,f);g>1&&(r/=g,n/=g,o/=g,a/=g,c/=g,h/=g,d/=g,p/=g);var m=s.width-o,_=s.height-h,b=s.width-c,B=s.height-p,y=t.borderTopWidth,w=t.borderRightWidth,v=t.borderBottomWidth,C=t.borderLeftWidth,M=kp(t.paddingTop,e.bounds.width),E=kp(t.paddingRight,e.bounds.width),F=kp(t.paddingBottom,e.bounds.width),x=kp(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||n>0?Z_(s.left+C/3,s.top+y/3,r-C/3,n-y/3,B_.TOP_LEFT):new j_(s.left+C/3,s.top+y/3),this.topRightBorderDoubleOuterBox=r>0||n>0?Z_(s.left+m,s.top+y/3,o-w/3,a-y/3,B_.TOP_RIGHT):new j_(s.left+s.width-w/3,s.top+y/3),this.bottomRightBorderDoubleOuterBox=c>0||h>0?Z_(s.left+b,s.top+_,c-w/3,h-v/3,B_.BOTTOM_RIGHT):new j_(s.left+s.width-w/3,s.top+s.height-v/3),this.bottomLeftBorderDoubleOuterBox=d>0||p>0?Z_(s.left+C/3,s.top+B,d-C/3,p-v/3,B_.BOTTOM_LEFT):new j_(s.left+C/3,s.top+s.height-v/3),this.topLeftBorderDoubleInnerBox=r>0||n>0?Z_(s.left+2*C/3,s.top+2*y/3,r-2*C/3,n-2*y/3,B_.TOP_LEFT):new j_(s.left+2*C/3,s.top+2*y/3),this.topRightBorderDoubleInnerBox=r>0||n>0?Z_(s.left+m,s.top+2*y/3,o-2*w/3,a-2*y/3,B_.TOP_RIGHT):new j_(s.left+s.width-2*w/3,s.top+2*y/3),this.bottomRightBorderDoubleInnerBox=c>0||h>0?Z_(s.left+b,s.top+_,c-2*w/3,h-2*v/3,B_.BOTTOM_RIGHT):new j_(s.left+s.width-2*w/3,s.top+s.height-2*v/3),this.bottomLeftBorderDoubleInnerBox=d>0||p>0?Z_(s.left+2*C/3,s.top+B,d-2*C/3,p-2*v/3,B_.BOTTOM_LEFT):new j_(s.left+2*C/3,s.top+s.height-2*v/3),this.topLeftBorderStroke=r>0||n>0?Z_(s.left+C/2,s.top+y/2,r-C/2,n-y/2,B_.TOP_LEFT):new j_(s.left+C/2,s.top+y/2),this.topRightBorderStroke=r>0||n>0?Z_(s.left+m,s.top+y/2,o-w/2,a-y/2,B_.TOP_RIGHT):new j_(s.left+s.width-w/2,s.top+y/2),this.bottomRightBorderStroke=c>0||h>0?Z_(s.left+b,s.top+_,c-w/2,h-v/2,B_.BOTTOM_RIGHT):new j_(s.left+s.width-w/2,s.top+s.height-v/2),this.bottomLeftBorderStroke=d>0||p>0?Z_(s.left+C/2,s.top+B,d-C/2,p-v/2,B_.BOTTOM_LEFT):new j_(s.left+C/2,s.top+s.height-v/2),this.topLeftBorderBox=r>0||n>0?Z_(s.left,s.top,r,n,B_.TOP_LEFT):new j_(s.left,s.top),this.topRightBorderBox=o>0||a>0?Z_(s.left+m,s.top,o,a,B_.TOP_RIGHT):new j_(s.left+s.width,s.top),this.bottomRightBorderBox=c>0||h>0?Z_(s.left+b,s.top+_,c,h,B_.BOTTOM_RIGHT):new j_(s.left+s.width,s.top+s.height),this.bottomLeftBorderBox=d>0||p>0?Z_(s.left,s.top+B,d,p,B_.BOTTOM_LEFT):new j_(s.left,s.top+s.height),this.topLeftPaddingBox=r>0||n>0?Z_(s.left+C,s.top+y,Math.max(0,r-C),Math.max(0,n-y),B_.TOP_LEFT):new j_(s.left+C,s.top+y),this.topRightPaddingBox=o>0||a>0?Z_(s.left+Math.min(m,s.width-w),s.top+y,m>s.width+w?0:Math.max(0,o-w),Math.max(0,a-y),B_.TOP_RIGHT):new j_(s.left+s.width-w,s.top+y),this.bottomRightPaddingBox=c>0||h>0?Z_(s.left+Math.min(b,s.width-C),s.top+Math.min(_,s.height-v),Math.max(0,c-w),Math.max(0,h-v),B_.BOTTOM_RIGHT):new j_(s.left+s.width-w,s.top+s.height-v),this.bottomLeftPaddingBox=d>0||p>0?Z_(s.left+C,s.top+Math.min(B,s.height-v),Math.max(0,d-C),Math.max(0,p-v),B_.BOTTOM_LEFT):new j_(s.left+C,s.top+s.height-v),this.topLeftContentBox=r>0||n>0?Z_(s.left+C+x,s.top+y+M,Math.max(0,r-(C+x)),Math.max(0,n-(y+M)),B_.TOP_LEFT):new j_(s.left+C+x,s.top+y+M),this.topRightContentBox=o>0||a>0?Z_(s.left+Math.min(m,s.width+C+x),s.top+y+M,m>s.width+C+x?0:o-C+x,a-(y+M),B_.TOP_RIGHT):new j_(s.left+s.width-(w+E),s.top+y+M),this.bottomRightContentBox=c>0||h>0?Z_(s.left+Math.min(b,s.width-(C+x)),s.top+Math.min(_,s.height+y+M),Math.max(0,c-(w+E)),h-(v+F),B_.BOTTOM_RIGHT):new j_(s.left+s.width-(w+E),s.top+s.height-(v+F)),this.bottomLeftContentBox=d>0||p>0?Z_(s.left+C+x,s.top+B,Math.max(0,d-(C+x)),p-(v+F),B_.BOTTOM_LEFT):new j_(s.left+C+x,s.top+s.height-(v+F))};!function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(B_||(B_={}));var Z_=function(e,t,s,i,r){var n=(Math.sqrt(2)-1)/3*4,A=s*n,o=i*n,a=e+s,l=t+i;switch(r){case B_.TOP_LEFT:return new z_(new j_(e,l),new j_(e,l-o),new j_(a-A,t),new j_(a,t));case B_.TOP_RIGHT:return new z_(new j_(e,t),new j_(e+A,t),new j_(a,l-o),new j_(a,l));case B_.BOTTOM_RIGHT:return new z_(new j_(a,t),new j_(a,t+o),new j_(e+A,l),new j_(e,l));case B_.BOTTOM_LEFT:default:return new z_(new j_(a,l),new j_(a-A,l),new j_(e,t+o),new j_(e,t))}},J_=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},Y_=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},$_=function(e,t,s){this.offsetX=e,this.offsetY=t,this.matrix=s,this.type=0,this.target=6},q_=function(e,t){this.path=e,this.target=t,this.type=1},eb=function(e){this.opacity=e,this.type=2,this.target=6},tb=function(e){return 1===e.type},sb=function(e,t){return e.length===t.length&&e.some((function(e,s){return e===t[s]}))},ib=function(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},rb=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new K_(this.container),this.container.styles.opacity<1&&this.effects.push(new eb(this.container.styles.opacity)),null!==this.container.styles.transform){var s=this.container.bounds.left+this.container.styles.transformOrigin[0].number,i=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new $_(s,i,r))}if(0!==this.container.styles.overflowX){var n=J_(this.curves),A=Y_(this.curves);sb(n,A)?this.effects.push(new q_(n,6)):(this.effects.push(new q_(n,2)),this.effects.push(new q_(A,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),s=this.parent,i=this.effects.slice(0);s;){var r=s.effects.filter((function(e){return!tb(e)}));if(t||0!==s.container.styles.position||!s.parent){if(i.unshift.apply(i,r),t=-1===[2,3].indexOf(s.container.styles.position),0!==s.container.styles.overflowX){var n=J_(s.curves),A=Y_(s.curves);sb(n,A)||i.unshift(new q_(A,6))}}else i.unshift.apply(i,r);s=s.parent}return i.filter((function(t){return Ig(t.target,e)}))},e}(),nb=function(e,t,s,i){e.container.elements.forEach((function(r){var n=Ig(r.flags,4),A=Ig(r.flags,2),o=new rb(r,e);Ig(r.styles.display,2048)&&i.push(o);var a=Ig(r.flags,8)?[]:i;if(n||A){var l=n||r.styles.isPositioned()?s:t,c=new ib(o);if(r.styles.isPositioned()||r.styles.opacity<1||r.styles.isTransformed()){var h=r.styles.zIndex.order;if(h<0){var u=0;l.negativeZIndex.some((function(e,t){return h>e.element.container.styles.zIndex.order?(u=t,!1):u>0})),l.negativeZIndex.splice(u,0,c)}else if(h>0){var d=0;l.positiveZIndex.some((function(e,t){return h>=e.element.container.styles.zIndex.order?(d=t+1,!1):d>0})),l.positiveZIndex.splice(d,0,c)}else l.zeroOrAutoZIndexOrTransformedOrOpacity.push(c)}else r.styles.isFloating()?l.nonPositionedFloats.push(c):l.nonPositionedInlineLevel.push(c);nb(o,c,n?c:s,a)}else r.styles.isInlineLevel()?t.inlineLevel.push(o):t.nonInlineLevel.push(o),nb(o,t,s,a);Ig(r.flags,8)&&Ab(r,a)}))},Ab=function(e,t){for(var s=e instanceof Im?e.start:1,i=e instanceof Im&&e.reversed,r=0;r<t.length;r++){var n=t[r];n.container instanceof Um&&"number"==typeof n.container.value&&0!==n.container.value&&(s=n.container.value),n.listValue=__(s,n.container.styles.listStyleType,!0),s+=i?-1:1}},ob=function(e,t){switch(t){case 0:return lb(e.topLeftBorderBox,e.topLeftPaddingBox,e.topRightBorderBox,e.topRightPaddingBox);case 1:return lb(e.topRightBorderBox,e.topRightPaddingBox,e.bottomRightBorderBox,e.bottomRightPaddingBox);case 2:return lb(e.bottomRightBorderBox,e.bottomRightPaddingBox,e.bottomLeftBorderBox,e.bottomLeftPaddingBox);default:return lb(e.bottomLeftBorderBox,e.bottomLeftPaddingBox,e.topLeftBorderBox,e.topLeftPaddingBox)}},ab=function(e,t){var s=[];return X_(e)?s.push(e.subdivide(.5,!1)):s.push(e),X_(t)?s.push(t.subdivide(.5,!0)):s.push(t),s},lb=function(e,t,s,i){var r=[];return X_(e)?r.push(e.subdivide(.5,!1)):r.push(e),X_(s)?r.push(s.subdivide(.5,!0)):r.push(s),X_(i)?r.push(i.subdivide(.5,!0).reverse()):r.push(i),X_(t)?r.push(t.subdivide(.5,!1).reverse()):r.push(t),r},cb=function(e){var t=e.bounds,s=e.styles;return t.add(s.borderLeftWidth,s.borderTopWidth,-(s.borderRightWidth+s.borderLeftWidth),-(s.borderTopWidth+s.borderBottomWidth))},hb=function(e){var t=e.styles,s=e.bounds,i=kp(t.paddingLeft,s.width),r=kp(t.paddingRight,s.width),n=kp(t.paddingTop,s.width),A=kp(t.paddingBottom,s.width);return s.add(i+t.borderLeftWidth,n+t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth+i+r),-(t.borderTopWidth+t.borderBottomWidth+n+A))},ub=function(e,t,s){var i=function(e,t){return 0===e?t.bounds:2===e?hb(t):cb(t)}(gb(e.styles.backgroundOrigin,t),e),r=function(e,t){return 0===e?t.bounds:2===e?hb(t):cb(t)}(gb(e.styles.backgroundClip,t),e),n=fb(gb(e.styles.backgroundSize,t),s,i),A=n[0],o=n[1],a=Dp(gb(e.styles.backgroundPosition,t),i.width-A,i.height-o);return[mb(gb(e.styles.backgroundRepeat,t),a,n,i,r),Math.round(i.left+a[0]),Math.round(i.top+a[1]),A,o]},db=function(e){return yp(e)&&e.value===af.AUTO},pb=function(e){return"number"==typeof e},fb=function(e,t,s){var i=t[0],r=t[1],n=t[2],A=e[0],o=e[1];if(!A)return[0,0];if(Up(A)&&o&&Up(o))return[kp(A,s.width),kp(o,s.height)];var a=pb(n);if(yp(A)&&(A.value===af.CONTAIN||A.value===af.COVER))return pb(n)?s.width/s.height<n!=(A.value===af.COVER)?[s.width,s.width/n]:[s.height*n,s.height]:[s.width,s.height];var l=pb(i),c=pb(r),h=l||c;if(db(A)&&(!o||db(o)))return l&&c?[i,r]:a||h?h&&a?[l?i:r*n,c?r:i/n]:[l?i:s.width,c?r:s.height]:[s.width,s.height];if(a){var u=0,d=0;return Up(A)?u=kp(A,s.width):Up(o)&&(d=kp(o,s.height)),db(A)?u=d*n:o&&!db(o)||(d=u/n),[u,d]}var p=null,f=null;if(Up(A)?p=kp(A,s.width):o&&Up(o)&&(f=kp(o,s.height)),null===p||o&&!db(o)||(f=l&&c?p/i*r:s.height),null!==f&&db(A)&&(p=l&&c?f/r*i:s.width),null!==p&&null!==f)return[p,f];throw new Error("Unable to calculate background-size for element")},gb=function(e,t){var s=e[t];return void 0===s?e[0]:s},mb=function(e,t,s,i,r){var n=t[0],A=t[1],o=s[0],a=s[1];switch(e){case 2:return[new j_(Math.round(i.left),Math.round(i.top+A)),new j_(Math.round(i.left+i.width),Math.round(i.top+A)),new j_(Math.round(i.left+i.width),Math.round(a+i.top+A)),new j_(Math.round(i.left),Math.round(a+i.top+A))];case 3:return[new j_(Math.round(i.left+n),Math.round(i.top)),new j_(Math.round(i.left+n+o),Math.round(i.top)),new j_(Math.round(i.left+n+o),Math.round(i.height+i.top)),new j_(Math.round(i.left+n),Math.round(i.height+i.top))];case 1:return[new j_(Math.round(i.left+n),Math.round(i.top+A)),new j_(Math.round(i.left+n+o),Math.round(i.top+A)),new j_(Math.round(i.left+n+o),Math.round(i.top+A+a)),new j_(Math.round(i.left+n),Math.round(i.top+A+a))];default:return[new j_(Math.round(r.left),Math.round(r.top)),new j_(Math.round(r.left+r.width),Math.round(r.top)),new j_(Math.round(r.left+r.width),Math.round(r.height+r.top)),new j_(Math.round(r.left),Math.round(r.height+r.top))]}},_b=function(){function e(e){this._data={},this._document=e}return e.prototype.parseMetrics=function(e,t){var s=this._document.createElement("div"),i=this._document.createElement("img"),r=this._document.createElement("span"),n=this._document.body;s.style.visibility="hidden",s.style.fontFamily=e,s.style.fontSize=t,s.style.margin="0",s.style.padding="0",s.style.whiteSpace="nowrap",n.appendChild(s),i.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",i.width=1,i.height=1,i.style.margin="0",i.style.padding="0",i.style.verticalAlign="baseline",r.style.fontFamily=e,r.style.fontSize=t,r.style.margin="0",r.style.padding="0",r.appendChild(this._document.createTextNode("Hidden Text")),s.appendChild(r),s.appendChild(i);var A=i.offsetTop-r.offsetTop+2;s.removeChild(r),s.appendChild(this._document.createTextNode("Hidden Text")),s.style.lineHeight="normal",i.style.verticalAlign="super";var o=i.offsetTop-s.offsetTop+2;return n.removeChild(s),{baseline:A,middle:o}},e.prototype.getMetrics=function(e,t){var s=e+" "+t;return void 0===this._data[s]&&(this._data[s]=this.parseMetrics(e,t)),this._data[s]},e}(),bb=function(e,t){this.context=e,this.options=t},Bb=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i._activeEffects=[],i.canvas=s.canvas?s.canvas:document.createElement("canvas"),i.ctx=i.canvas.getContext("2d"),s.canvas||(i.canvas.width=Math.floor(s.width*s.scale),i.canvas.height=Math.floor(s.height*s.scale),i.canvas.style.width=s.width+"px",i.canvas.style.height=s.height+"px"),i.fontMetrics=new _b(document),i.ctx.scale(i.options.scale,i.options.scale),i.ctx.translate(-s.x,-s.y),i.ctx.textBaseline="bottom",i._activeEffects=[],i.context.logger.debug("Canvas renderer initialized ("+s.width+"x"+s.height+") with scale "+s.scale),i}return Qu(t,e),t.prototype.applyEffects=function(e){for(var t=this;this._activeEffects.length;)this.popEffect();e.forEach((function(e){return t.applyEffect(e)}))},t.prototype.applyEffect=function(e){this.ctx.save(),function(e){return 2===e.type}(e)&&(this.ctx.globalAlpha=e.opacity),function(e){return 0===e.type}(e)&&(this.ctx.translate(e.offsetX,e.offsetY),this.ctx.transform(e.matrix[0],e.matrix[1],e.matrix[2],e.matrix[3],e.matrix[4],e.matrix[5]),this.ctx.translate(-e.offsetX,-e.offsetY)),tb(e)&&(this.path(e.path),this.ctx.clip()),this._activeEffects.push(e)},t.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},t.prototype.renderStack=function(e){return Ou(this,void 0,void 0,(function(){return Vu(this,(function(t){switch(t.label){case 0:return e.element.container.styles.isVisible()?[4,this.renderStackContent(e)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.renderNode=function(e){return Ou(this,void 0,void 0,(function(){return Vu(this,(function(t){switch(t.label){case 0:return Ig(e.container.flags,16),e.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(e)]:[3,3];case 1:return t.sent(),[4,this.renderNodeContent(e)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},t.prototype.renderTextWithLetterSpacing=function(e,t,s){var i=this;0===t?this.ctx.fillText(e.text,e.bounds.left,e.bounds.top+s):_m(e.text).reduce((function(t,r){return i.ctx.fillText(r,t,e.bounds.top+s),t+i.ctx.measureText(r).width}),e.bounds.left)},t.prototype.createFontStyle=function(e){var t=e.fontVariant.filter((function(e){return"normal"===e||"small-caps"===e})).join(""),s=Mb(e.fontFamily).join(", "),i=bp(e.fontSize)?""+e.fontSize.number+e.fontSize.unit:e.fontSize.number+"px";return[[e.fontStyle,t,e.fontWeight,i,s].join(" "),s,i]},t.prototype.renderTextNode=function(e,t){return Ou(this,void 0,void 0,(function(){var s,i,r,n,A,o,a,l,c=this;return Vu(this,(function(h){return s=this.createFontStyle(t),i=s[0],r=s[1],n=s[2],this.ctx.font=i,this.ctx.direction=1===t.direction?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",A=this.fontMetrics.getMetrics(r,n),o=A.baseline,a=A.middle,l=t.paintOrder,e.textBounds.forEach((function(e){l.forEach((function(s){switch(s){case 0:c.ctx.fillStyle=Np(t.color),c.renderTextWithLetterSpacing(e,t.letterSpacing,o);var i=t.textShadow;i.length&&e.text.trim().length&&(i.slice(0).reverse().forEach((function(s){c.ctx.shadowColor=Np(s.color),c.ctx.shadowOffsetX=s.offsetX.number*c.options.scale,c.ctx.shadowOffsetY=s.offsetY.number*c.options.scale,c.ctx.shadowBlur=s.blur.number,c.renderTextWithLetterSpacing(e,t.letterSpacing,o)})),c.ctx.shadowColor="",c.ctx.shadowOffsetX=0,c.ctx.shadowOffsetY=0,c.ctx.shadowBlur=0),t.textDecorationLine.length&&(c.ctx.fillStyle=Np(t.textDecorationColor||t.color),t.textDecorationLine.forEach((function(t){switch(t){case 1:c.ctx.fillRect(e.bounds.left,Math.round(e.bounds.top+o),e.bounds.width,1);break;case 2:c.ctx.fillRect(e.bounds.left,Math.round(e.bounds.top),e.bounds.width,1);break;case 3:c.ctx.fillRect(e.bounds.left,Math.ceil(e.bounds.top+a),e.bounds.width,1)}})));break;case 1:t.webkitTextStrokeWidth&&e.text.trim().length&&(c.ctx.strokeStyle=Np(t.webkitTextStrokeColor),c.ctx.lineWidth=t.webkitTextStrokeWidth,c.ctx.lineJoin=window.chrome?"miter":"round",c.ctx.strokeText(e.text,e.bounds.left,e.bounds.top+o)),c.ctx.strokeStyle="",c.ctx.lineWidth=0,c.ctx.lineJoin="miter"}}))})),[2]}))}))},t.prototype.renderReplacedElement=function(e,t,s){if(s&&e.intrinsicWidth>0&&e.intrinsicHeight>0){var i=hb(e),r=Y_(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(s,0,0,e.intrinsicWidth,e.intrinsicHeight,i.left,i.top,i.width,i.height),this.ctx.restore()}},t.prototype.renderNodeContent=function(e){return Ou(this,void 0,void 0,(function(){var s,i,r,n,A,o,a,l,c,h,u,d,p,f,g,m,_,b;return Vu(this,(function(B){switch(B.label){case 0:this.applyEffects(e.getEffects(4)),s=e.container,i=e.curves,r=s.styles,n=0,A=s.textNodes,B.label=1;case 1:return n<A.length?(o=A[n],[4,this.renderTextNode(o,r)]):[3,4];case 2:B.sent(),B.label=3;case 3:return n++,[3,1];case 4:if(!(s instanceof Em))return[3,8];B.label=5;case 5:return B.trys.push([5,7,,8]),[4,this.context.cache.match(s.src)];case 6:return g=B.sent(),this.renderReplacedElement(s,i,g),[3,8];case 7:return B.sent(),this.context.logger.error("Error loading image "+s.src),[3,8];case 8:if(s instanceof Fm&&this.renderReplacedElement(s,i,s.canvas),!(s instanceof xm))return[3,12];B.label=9;case 9:return B.trys.push([9,11,,12]),[4,this.context.cache.match(s.svg)];case 10:return g=B.sent(),this.renderReplacedElement(s,i,g),[3,12];case 11:return B.sent(),this.context.logger.error("Error loading svg "+s.svg.substring(0,255)),[3,12];case 12:return s instanceof Rm&&s.tree?[4,new t(this.context,{scale:this.options.scale,backgroundColor:s.backgroundColor,x:0,y:0,width:s.width,height:s.height}).render(s.tree)]:[3,14];case 13:a=B.sent(),s.width&&s.height&&this.ctx.drawImage(a,0,0,s.width,s.height,s.bounds.left,s.bounds.top,s.bounds.width,s.bounds.height),B.label=14;case 14:if(s instanceof Dm&&(l=Math.min(s.bounds.width,s.bounds.height),"checkbox"===s.type?s.checked&&(this.ctx.save(),this.path([new j_(s.bounds.left+.39363*l,s.bounds.top+.79*l),new j_(s.bounds.left+.16*l,s.bounds.top+.5549*l),new j_(s.bounds.left+.27347*l,s.bounds.top+.44071*l),new j_(s.bounds.left+.39694*l,s.bounds.top+.5649*l),new j_(s.bounds.left+.72983*l,s.bounds.top+.23*l),new j_(s.bounds.left+.84*l,s.bounds.top+.34085*l),new j_(s.bounds.left+.39363*l,s.bounds.top+.79*l)]),this.ctx.fillStyle=Np(707406591),this.ctx.fill(),this.ctx.restore()):"radio"===s.type&&s.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(s.bounds.left+l/2,s.bounds.top+l/2,l/4,0,2*Math.PI,!0),this.ctx.fillStyle=Np(707406591),this.ctx.fill(),this.ctx.restore())),yb(s)&&s.value.length){switch(c=this.createFontStyle(r),_=c[0],h=c[1],u=this.fontMetrics.getMetrics(_,h).baseline,this.ctx.font=_,this.ctx.fillStyle=Np(r.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=vb(s.styles.textAlign),b=hb(s),d=0,s.styles.textAlign){case 1:d+=b.width/2;break;case 2:d+=b.width}p=b.add(d,0,0,-b.height/2+1),this.ctx.save(),this.path([new j_(b.left,b.top),new j_(b.left+b.width,b.top),new j_(b.left+b.width,b.top+b.height),new j_(b.left,b.top+b.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new fm(s.value,p),r.letterSpacing,u),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!Ig(s.styles.display,2048))return[3,20];if(null===s.styles.listStyleImage)return[3,19];if(0!==(f=s.styles.listStyleImage).type)return[3,18];g=void 0,m=f.url,B.label=15;case 15:return B.trys.push([15,17,,18]),[4,this.context.cache.match(m)];case 16:return g=B.sent(),this.ctx.drawImage(g,s.bounds.left-(g.width+10),s.bounds.top),[3,18];case 17:return B.sent(),this.context.logger.error("Error loading list-style-image "+m),[3,18];case 18:return[3,20];case 19:e.listValue&&-1!==s.styles.listStyleType&&(_=this.createFontStyle(r)[0],this.ctx.font=_,this.ctx.fillStyle=Np(r.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",b=new Hu(s.bounds.left,s.bounds.top+kp(s.styles.paddingTop,s.bounds.width),s.bounds.width,Xf(r.lineHeight,r.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new fm(e.listValue,b),r.letterSpacing,Xf(r.lineHeight,r.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"),B.label=20;case 20:return[2]}}))}))},t.prototype.renderStackContent=function(e){return Ou(this,void 0,void 0,(function(){var t,s,i,r,n,A,o,a,l,c,h,u,d,p,f;return Vu(this,(function(g){switch(g.label){case 0:return Ig(e.element.container.flags,16),[4,this.renderNodeBackgroundAndBorders(e.element)];case 1:g.sent(),t=0,s=e.negativeZIndex,g.label=2;case 2:return t<s.length?(f=s[t],[4,this.renderStack(f)]):[3,5];case 3:g.sent(),g.label=4;case 4:return t++,[3,2];case 5:return[4,this.renderNodeContent(e.element)];case 6:g.sent(),i=0,r=e.nonInlineLevel,g.label=7;case 7:return i<r.length?(f=r[i],[4,this.renderNode(f)]):[3,10];case 8:g.sent(),g.label=9;case 9:return i++,[3,7];case 10:n=0,A=e.nonPositionedFloats,g.label=11;case 11:return n<A.length?(f=A[n],[4,this.renderStack(f)]):[3,14];case 12:g.sent(),g.label=13;case 13:return n++,[3,11];case 14:o=0,a=e.nonPositionedInlineLevel,g.label=15;case 15:return o<a.length?(f=a[o],[4,this.renderStack(f)]):[3,18];case 16:g.sent(),g.label=17;case 17:return o++,[3,15];case 18:l=0,c=e.inlineLevel,g.label=19;case 19:return l<c.length?(f=c[l],[4,this.renderNode(f)]):[3,22];case 20:g.sent(),g.label=21;case 21:return l++,[3,19];case 22:h=0,u=e.zeroOrAutoZIndexOrTransformedOrOpacity,g.label=23;case 23:return h<u.length?(f=u[h],[4,this.renderStack(f)]):[3,26];case 24:g.sent(),g.label=25;case 25:return h++,[3,23];case 26:d=0,p=e.positiveZIndex,g.label=27;case 27:return d<p.length?(f=p[d],[4,this.renderStack(f)]):[3,30];case 28:g.sent(),g.label=29;case 29:return d++,[3,27];case 30:return[2]}}))}))},t.prototype.mask=function(e){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.canvas.width,0),this.ctx.lineTo(this.canvas.width,this.canvas.height),this.ctx.lineTo(0,this.canvas.height),this.ctx.lineTo(0,0),this.formatPath(e.slice(0).reverse()),this.ctx.closePath()},t.prototype.path=function(e){this.ctx.beginPath(),this.formatPath(e),this.ctx.closePath()},t.prototype.formatPath=function(e){var t=this;e.forEach((function(e,s){var i=X_(e)?e.start:e;0===s?t.ctx.moveTo(i.x,i.y):t.ctx.lineTo(i.x,i.y),X_(e)&&t.ctx.bezierCurveTo(e.startControl.x,e.startControl.y,e.endControl.x,e.endControl.y,e.end.x,e.end.y)}))},t.prototype.renderRepeat=function(e,t,s,i){this.path(e),this.ctx.fillStyle=t,this.ctx.translate(s,i),this.ctx.fill(),this.ctx.translate(-s,-i)},t.prototype.resizeImage=function(e,t,s){var i;if(e.width===t&&e.height===s)return e;var r=(null!==(i=this.canvas.ownerDocument)&&void 0!==i?i:document).createElement("canvas");return r.width=Math.max(1,t),r.height=Math.max(1,s),r.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t,s),r},t.prototype.renderBackgroundImage=function(e){return Ou(this,void 0,void 0,(function(){var t,s,i,r,n,A;return Vu(this,(function(o){switch(o.label){case 0:t=e.styles.backgroundImage.length-1,s=function(s){var r,n,A,o,a,l,c,h,u,d,p,f,g,m,_,b,B,y,w,v,C,M,E,F,x,U,I,T,P,S,D;return Vu(this,(function(k){switch(k.label){case 0:if(0!==s.type)return[3,5];r=void 0,n=s.url,k.label=1;case 1:return k.trys.push([1,3,,4]),[4,i.context.cache.match(n)];case 2:return r=k.sent(),[3,4];case 3:return k.sent(),i.context.logger.error("Error loading background-image "+n),[3,4];case 4:return r&&(A=ub(e,t,[r.width,r.height,r.width/r.height]),b=A[0],M=A[1],E=A[2],w=A[3],v=A[4],m=i.ctx.createPattern(i.resizeImage(r,w,v),"repeat"),i.renderRepeat(b,m,M,E)),[3,6];case 5:1===s.type?(o=ub(e,t,[null,null,null]),b=o[0],M=o[1],E=o[2],w=o[3],v=o[4],a=tf(s.angle,w,v),l=a[0],c=a[1],h=a[2],u=a[3],d=a[4],(p=document.createElement("canvas")).width=w,p.height=v,f=p.getContext("2d"),g=f.createLinearGradient(c,u,h,d),ef(s.stops,l).forEach((function(e){return g.addColorStop(e.stop,Np(e.color))})),f.fillStyle=g,f.fillRect(0,0,w,v),w>0&&v>0&&(m=i.ctx.createPattern(p,"repeat"),i.renderRepeat(b,m,M,E))):function(e){return 2===e.type}(s)&&(_=ub(e,t,[null,null,null]),b=_[0],B=_[1],y=_[2],w=_[3],v=_[4],C=0===s.position.length?[Pp]:s.position,M=kp(C[0],w),E=kp(C[C.length-1],v),F=function(e,t,s,i,r){var n=0,A=0;switch(e.size){case 0:0===e.shape?n=A=Math.min(Math.abs(t),Math.abs(t-i),Math.abs(s),Math.abs(s-r)):1===e.shape&&(n=Math.min(Math.abs(t),Math.abs(t-i)),A=Math.min(Math.abs(s),Math.abs(s-r)));break;case 2:if(0===e.shape)n=A=Math.min(sf(t,s),sf(t,s-r),sf(t-i,s),sf(t-i,s-r));else if(1===e.shape){var o=Math.min(Math.abs(s),Math.abs(s-r))/Math.min(Math.abs(t),Math.abs(t-i)),a=rf(i,r,t,s,!0),l=a[0],c=a[1];A=o*(n=sf(l-t,(c-s)/o))}break;case 1:0===e.shape?n=A=Math.max(Math.abs(t),Math.abs(t-i),Math.abs(s),Math.abs(s-r)):1===e.shape&&(n=Math.max(Math.abs(t),Math.abs(t-i)),A=Math.max(Math.abs(s),Math.abs(s-r)));break;case 3:if(0===e.shape)n=A=Math.max(sf(t,s),sf(t,s-r),sf(t-i,s),sf(t-i,s-r));else if(1===e.shape){o=Math.max(Math.abs(s),Math.abs(s-r))/Math.max(Math.abs(t),Math.abs(t-i));var h=rf(i,r,t,s,!1);l=h[0],c=h[1],A=o*(n=sf(l-t,(c-s)/o))}}return Array.isArray(e.size)&&(n=kp(e.size[0],i),A=2===e.size.length?kp(e.size[1],r):n),[n,A]}(s,M,E,w,v),x=F[0],U=F[1],x>0&&U>0&&(I=i.ctx.createRadialGradient(B+M,y+E,0,B+M,y+E,x),ef(s.stops,2*x).forEach((function(e){return I.addColorStop(e.stop,Np(e.color))})),i.path(b),i.ctx.fillStyle=I,x!==U?(T=e.bounds.left+.5*e.bounds.width,P=e.bounds.top+.5*e.bounds.height,D=1/(S=U/x),i.ctx.save(),i.ctx.translate(T,P),i.ctx.transform(1,0,0,S,0,0),i.ctx.translate(-T,-P),i.ctx.fillRect(B,D*(y-P)+P,w,v*D),i.ctx.restore()):i.ctx.fill())),k.label=6;case 6:return t--,[2]}}))},i=this,r=0,n=e.styles.backgroundImage.slice(0).reverse(),o.label=1;case 1:return r<n.length?(A=n[r],[5,s(A)]):[3,4];case 2:o.sent(),o.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}))},t.prototype.renderSolidBorder=function(e,t,s){return Ou(this,void 0,void 0,(function(){return Vu(this,(function(i){return this.path(ob(s,t)),this.ctx.fillStyle=Np(e),this.ctx.fill(),[2]}))}))},t.prototype.renderDoubleBorder=function(e,t,s,i){return Ou(this,void 0,void 0,(function(){var r,n;return Vu(this,(function(A){switch(A.label){case 0:return t<3?[4,this.renderSolidBorder(e,s,i)]:[3,2];case 1:return A.sent(),[2];case 2:return r=function(e,t){switch(t){case 0:return lb(e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox,e.topRightBorderBox,e.topRightBorderDoubleOuterBox);case 1:return lb(e.topRightBorderBox,e.topRightBorderDoubleOuterBox,e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox);case 2:return lb(e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox,e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox);default:return lb(e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox,e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox)}}(i,s),this.path(r),this.ctx.fillStyle=Np(e),this.ctx.fill(),n=function(e,t){switch(t){case 0:return lb(e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox,e.topRightBorderDoubleInnerBox,e.topRightPaddingBox);case 1:return lb(e.topRightBorderDoubleInnerBox,e.topRightPaddingBox,e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox);case 2:return lb(e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox,e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox);default:return lb(e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox,e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox)}}(i,s),this.path(n),this.ctx.fill(),[2]}}))}))},t.prototype.renderNodeBackgroundAndBorders=function(e){return Ou(this,void 0,void 0,(function(){var t,s,i,r,n,A,o,a,l=this;return Vu(this,(function(c){switch(c.label){case 0:return this.applyEffects(e.getEffects(2)),t=e.container.styles,s=!Hp(t.backgroundColor)||t.backgroundImage.length,i=[{style:t.borderTopStyle,color:t.borderTopColor,width:t.borderTopWidth},{style:t.borderRightStyle,color:t.borderRightColor,width:t.borderRightWidth},{style:t.borderBottomStyle,color:t.borderBottomColor,width:t.borderBottomWidth},{style:t.borderLeftStyle,color:t.borderLeftColor,width:t.borderLeftWidth}],r=wb(gb(t.backgroundClip,0),e.curves),s||t.boxShadow.length?(this.ctx.save(),this.path(r),this.ctx.clip(),Hp(t.backgroundColor)||(this.ctx.fillStyle=Np(t.backgroundColor),this.ctx.fill()),[4,this.renderBackgroundImage(e.container)]):[3,2];case 1:c.sent(),this.ctx.restore(),t.boxShadow.slice(0).reverse().forEach((function(t){l.ctx.save();var s,i,r,n,A,o=J_(e.curves),a=t.inset?0:1e4,c=(s=o,i=-a+(t.inset?1:-1)*t.spread.number,r=(t.inset?1:-1)*t.spread.number,n=t.spread.number*(t.inset?-2:2),A=t.spread.number*(t.inset?-2:2),s.map((function(e,t){switch(t){case 0:return e.add(i,r);case 1:return e.add(i+n,r);case 2:return e.add(i+n,r+A);case 3:return e.add(i,r+A)}return e})));t.inset?(l.path(o),l.ctx.clip(),l.mask(c)):(l.mask(o),l.ctx.clip(),l.path(c)),l.ctx.shadowOffsetX=t.offsetX.number+a,l.ctx.shadowOffsetY=t.offsetY.number,l.ctx.shadowColor=Np(t.color),l.ctx.shadowBlur=t.blur.number,l.ctx.fillStyle=t.inset?Np(t.color):"rgba(0,0,0,1)",l.ctx.fill(),l.ctx.restore()})),c.label=2;case 2:n=0,A=0,o=i,c.label=3;case 3:return A<o.length?0!==(a=o[A]).style&&!Hp(a.color)&&a.width>0?2!==a.style?[3,5]:[4,this.renderDashedDottedBorder(a.color,a.width,n,e.curves,2)]:[3,11]:[3,13];case 4:return c.sent(),[3,11];case 5:return 3!==a.style?[3,7]:[4,this.renderDashedDottedBorder(a.color,a.width,n,e.curves,3)];case 6:return c.sent(),[3,11];case 7:return 4!==a.style?[3,9]:[4,this.renderDoubleBorder(a.color,a.width,n,e.curves)];case 8:return c.sent(),[3,11];case 9:return[4,this.renderSolidBorder(a.color,n,e.curves)];case 10:c.sent(),c.label=11;case 11:n++,c.label=12;case 12:return A++,[3,3];case 13:return[2]}}))}))},t.prototype.renderDashedDottedBorder=function(e,t,s,i,r){return Ou(this,void 0,void 0,(function(){var n,A,o,a,l,c,h,u,d,p,f,g,m,_,b,B;return Vu(this,(function(y){return this.ctx.save(),n=function(e,t){switch(t){case 0:return ab(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return ab(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return ab(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return ab(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}}(i,s),A=ob(i,s),2===r&&(this.path(A),this.ctx.clip()),X_(A[0])?(o=A[0].start.x,a=A[0].start.y):(o=A[0].x,a=A[0].y),X_(A[1])?(l=A[1].end.x,c=A[1].end.y):(l=A[1].x,c=A[1].y),h=0===s||2===s?Math.abs(o-l):Math.abs(a-c),this.ctx.beginPath(),3===r?this.formatPath(n):this.formatPath(A.slice(0,2)),u=t<3?3*t:2*t,d=t<3?2*t:t,3===r&&(u=t,d=t),p=!0,h<=2*u?p=!1:h<=2*u+d?(u*=f=h/(2*u+d),d*=f):(g=Math.floor((h+d)/(u+d)),m=(h-g*u)/(g-1),d=(_=(h-(g+1)*u)/g)<=0||Math.abs(d-m)<Math.abs(d-_)?m:_),p&&(3===r?this.ctx.setLineDash([0,u+d]):this.ctx.setLineDash([u,d])),3===r?(this.ctx.lineCap="round",this.ctx.lineWidth=t):this.ctx.lineWidth=2*t+1.1,this.ctx.strokeStyle=Np(e),this.ctx.stroke(),this.ctx.setLineDash([]),2===r&&(X_(A[0])&&(b=A[3],B=A[0],this.ctx.beginPath(),this.formatPath([new j_(b.end.x,b.end.y),new j_(B.start.x,B.start.y)]),this.ctx.stroke()),X_(A[1])&&(b=A[1],B=A[2],this.ctx.beginPath(),this.formatPath([new j_(b.end.x,b.end.y),new j_(B.start.x,B.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]}))}))},t.prototype.render=function(e){return Ou(this,void 0,void 0,(function(){var t;return Vu(this,(function(s){switch(s.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=Np(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),i=new rb(e,null),r=new ib(i),nb(i,r,r,n=[]),Ab(i.container,n),t=r,[4,this.renderStack(t)];case 1:return s.sent(),this.applyEffects([]),[2,this.canvas]}var i,r,n}))}))},t}(bb),yb=function(e){return e instanceof Qm||(e instanceof km||e instanceof Dm&&"radio"!==e.type&&"checkbox"!==e.type)},wb=function(e,t){switch(e){case 0:return J_(t);case 2:return function(e){return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox]}(t);default:return Y_(t)}},vb=function(e){switch(e){case 1:return"center";case 2:return"right";default:return"left"}},Cb=["-apple-system","system-ui"],Mb=function(e){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?e.filter((function(e){return-1===Cb.indexOf(e)})):e},Eb=function(e){function t(t,s){var i=e.call(this,t,s)||this;return i.canvas=s.canvas?s.canvas:document.createElement("canvas"),i.ctx=i.canvas.getContext("2d"),i.options=s,i.canvas.width=Math.floor(s.width*s.scale),i.canvas.height=Math.floor(s.height*s.scale),i.canvas.style.width=s.width+"px",i.canvas.style.height=s.height+"px",i.ctx.scale(i.options.scale,i.options.scale),i.ctx.translate(-s.x,-s.y),i.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized ("+s.width+"x"+s.height+" at "+s.x+","+s.y+") with scale "+s.scale),i}return Qu(t,e),t.prototype.render=function(e){return Ou(this,void 0,void 0,(function(){var t,s;return Vu(this,(function(i){switch(i.label){case 0:return t=um(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,e),[4,Fb(t)];case 1:return s=i.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=Np(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(s,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}}))}))},t}(bb),Fb=function(e){return new Promise((function(t,s){var i=new Image;i.onload=function(){t(i)},i.onerror=s,i.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(e))}))},xb=function(){function e(e){var t=e.id,s=e.enabled;this.id=t,this.enabled=s,this.start=Date.now()}return e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.debug?console.debug.apply(console,Lu([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},e.prototype.getTime=function(){return Date.now()-this.start},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&"undefined"!=typeof window&&window.console&&"function"==typeof console.info&&console.info.apply(console,Lu([this.id,this.getTime()+"ms"],e))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.warn?console.warn.apply(console,Lu([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.error?console.error.apply(console,Lu([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},e.instances={},e}(),Ub=function(){function e(t,s){var i;this.windowBounds=s,this.instanceName="#"+e.instanceCount++,this.logger=new xb({id:this.instanceName,enabled:t.logging}),this.cache=null!==(i=t.cache)&&void 0!==i?i:new k_(this,t)}return e.instanceCount=1,e}();"undefined"!=typeof window&&D_.setContext(window);var Ib=function(e,t){return Ou(void 0,void 0,void 0,(function(){var s,i,r,n,A,o,a,l,c,h,u,d,p,f,g,m,_,b,B,y,w,v,C,M,E,F,x,U,I,T,P,S,D,k,Q,R,O,V;return Vu(this,(function(L){switch(L.label){case 0:if(!e||"object"!=typeof e)return[2,Promise.reject("Invalid element provided as first argument")];if(!(s=e.ownerDocument))throw new Error("Element is not attached to a Document");if(!(i=s.defaultView))throw new Error("Document is not attached to a Window");return r={allowTaint:null!==(v=t.allowTaint)&&void 0!==v&&v,imageTimeout:null!==(C=t.imageTimeout)&&void 0!==C?C:15e3,proxy:t.proxy,useCORS:null!==(M=t.useCORS)&&void 0!==M&&M},n=Ru({logging:null===(E=t.logging)||void 0===E||E,cache:t.cache},r),A={windowWidth:null!==(F=t.windowWidth)&&void 0!==F?F:i.innerWidth,windowHeight:null!==(x=t.windowHeight)&&void 0!==x?x:i.innerHeight,scrollX:null!==(U=t.scrollX)&&void 0!==U?U:i.pageXOffset,scrollY:null!==(I=t.scrollY)&&void 0!==I?I:i.pageYOffset},o=new Hu(A.scrollX,A.scrollY,A.windowWidth,A.windowHeight),a=new Ub(n,o),l=null!==(T=t.foreignObjectRendering)&&void 0!==T&&T,c={allowTaint:null!==(P=t.allowTaint)&&void 0!==P&&P,onclone:t.onclone,ignoreElements:t.ignoreElements,inlineImages:l,copyStyles:l},a.logger.debug("Starting document clone with size "+o.width+"x"+o.height+" scrolled to "+-o.left+","+-o.top),h=new b_(a,e,c),(u=h.clonedReferenceElement)?[4,h.toIFrame(s,o)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return d=L.sent(),p=$m(u)||"HTML"===u.tagName?function(e){var t=e.body,s=e.documentElement;if(!t||!s)throw new Error("Unable to get document size");var i=Math.max(Math.max(t.scrollWidth,s.scrollWidth),Math.max(t.offsetWidth,s.offsetWidth),Math.max(t.clientWidth,s.clientWidth)),r=Math.max(Math.max(t.scrollHeight,s.scrollHeight),Math.max(t.offsetHeight,s.offsetHeight),Math.max(t.clientHeight,s.clientHeight));return new Hu(0,0,i,r)}(u.ownerDocument):Nu(a,u),f=p.width,g=p.height,m=p.left,_=p.top,b=Tb(a,u,t.backgroundColor),B={canvas:t.canvas,backgroundColor:b,scale:null!==(D=null!==(S=t.scale)&&void 0!==S?S:i.devicePixelRatio)&&void 0!==D?D:1,x:(null!==(k=t.x)&&void 0!==k?k:0)+m,y:(null!==(Q=t.y)&&void 0!==Q?Q:0)+_,width:null!==(R=t.width)&&void 0!==R?R:Math.ceil(f),height:null!==(O=t.height)&&void 0!==O?O:Math.ceil(g)},l?(a.logger.debug("Document cloned, using foreign object rendering"),[4,new Eb(a,B).render(u)]):[3,3];case 2:return y=L.sent(),[3,5];case 3:return a.logger.debug("Document cloned, element located at "+m+","+_+" with size "+f+"x"+g+" using computed rendering"),a.logger.debug("Starting DOM parsing"),w=Hm(a,u),b===w.styles.backgroundColor&&(w.styles.backgroundColor=Jp.TRANSPARENT),a.logger.debug("Starting renderer for element at "+B.x+","+B.y+" with size "+B.width+"x"+B.height),[4,new Bb(a,B).render(w)];case 4:y=L.sent(),L.label=5;case 5:return(null===(V=t.removeContainer)||void 0===V||V)&&(b_.destroy(d)||a.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),a.logger.debug("Finished rendering"),[2,y]}}))}))},Tb=function(e,t,s){var i=t.ownerDocument,r=i.documentElement?Zp(e,getComputedStyle(i.documentElement).backgroundColor):Jp.TRANSPARENT,n=i.body?Zp(e,getComputedStyle(i.body).backgroundColor):Jp.TRANSPARENT,A="string"==typeof s?Zp(e,s):null===s?Jp.TRANSPARENT:4294967295;return t===i.documentElement?Hp(r)?Hp(n)?A:n:r:A};function Pb(e,t,s=(()=>{})){if(!e||!t)return;let i=null;let r,n;const A=e=>{if(e.preventDefault(),i&&(clearTimeout(i),i=null),e.touches.length>1)return;const s=e.touches[0];r=s.clientX,n=s.clientY,i=setTimeout((()=>{e.clientX=s.clientX,e.clientY=s.clientY,t(e),clearTimeout(i),i=null}),500)},o=e=>{e.touches.length>1&&i&&(clearTimeout(i),i=null)},a=e=>{if(!i)return;const t=e.touches[0],s=Math.abs(t.clientX-r),A=Math.abs(t.clientY-n);(s>3||A>3)&&(clearTimeout(i),i=null)},l=e=>{e.preventDefault(),i&&(s(e),clearTimeout(i),i=null)},c=e=>{t(e),e.preventDefault(),e.stopPropagation()};return gn.isIphoneOrIpadSafari()?(e.addEventListener("touchstart",A),e.addEventListener("touchmove",a),e.addEventListener("touchend",l),window.addEventListener("touchstart",o)):e.addEventListener("contextmenu",c),function(){gn.isIphoneOrIpadSafari()?(e.removeEventListener("touchstart",A),e.removeEventListener("touchmove",a),e.removeEventListener("touchend",l),window.removeEventListener("touchstart",o)):e.removeEventListener("contextmenu",c)}}class Sb{constructor(e,t={}){this._highlightClass="viewer-ruler-dot-highlighted",this._x=0,this._y=0,this._dot=document.createElement("div"),this._dot.className+=this._dot.className?" viewer-ruler-dot":"viewer-ruler-dot",this._dotClickable=document.createElement("div"),this._dotClickable.className+=this._dotClickable.className?" viewer-ruler-dot-clickable":"viewer-ruler-dot-clickable",this._visible=!1!==t.visible,this._culled=!1;var s=this._dot,i=s.style;i["border-radius"]="25px",i.border="solid 2px white",i.background="lightgreen",i.position="absolute",i["z-index"]=void 0===t.zIndex?"40000005":t.zIndex,i.width="8px",i.height="8px",i.visibility=this._visible?"visible":"hidden",i.top="0px",i.left="0px",i["box-shadow"]="0 2px 5px 0 #182A3D;",i.opacity=1,i["pointer-events"]="none",t.onContextMenu,e.appendChild(s);var r=this._dotClickable,n=r.style;if(n["border-radius"]="35px",n.border="solid 10px white",n.position="absolute",n["z-index"]=void 0===t.zIndex?"40000007":t.zIndex+1,n.width="8px",n.height="8px",n.visibility="visible",n.top="0px",n.left="0px",n.opacity=0,n["pointer-events"]="none",t.onContextMenu,e.appendChild(r),r.addEventListener("click",(t=>{e.dispatchEvent(new MouseEvent("mouseover",t))})),t.onMouseOver&&r.addEventListener("mouseover",(s=>{t.onMouseOver(s,this),e.dispatchEvent(new MouseEvent("mouseover",s))})),t.onMouseLeave&&r.addEventListener("mouseleave",(e=>{t.onMouseLeave(e,this)})),t.onMouseWheel&&r.addEventListener("wheel",(e=>{t.onMouseWheel(e,this)})),t.onMouseDown&&r.addEventListener("mousedown",(e=>{t.onMouseDown(e,this)})),t.onMouseUp&&r.addEventListener("mouseup",(e=>{t.onMouseUp(e,this)})),t.onMouseMove&&r.addEventListener("mousemove",(e=>{t.onMouseMove(e,this)})),t.onTouchstart&&r.addEventListener("touchstart",(e=>{t.onTouchstart(e,this)})),t.onTouchmove&&r.addEventListener("touchmove",(e=>{t.onTouchmove(e,this)})),t.onTouchend&&r.addEventListener("touchend",(e=>{t.onTouchend(e,this)})),t.onContextMenu){Pb(r,(e=>{t.onContextMenu(e,this)}))}this.setPos(t.x||0,t.y||0),this.setFillColor(t.fillColor),this.setBorderColor(t.borderColor)}setPos(e,t){this._x=e,this._y=t;var s=this._dot.style;s.left=Math.round(e)-6+"px",s.top=Math.round(t)-6+"px";var i=this._dotClickable.style;i.left=Math.round(e)-14+"px",i.top=Math.round(t)-14+"px"}setFillColor(e){this._dot.style.background=e||"lightgreen"}setBorderColor(e){this._dot.style.border="solid 2px"+(e||"black")}setOpacity(e){this._dot.style.opacity=e}_updateVisibility(){this._dot.style.visibility=this._dotClickable.style.visibility=this._visible&&!this._culled?"visible":"hidden"}setVisible(e){this._visible!==e&&(this._visible=!!e,this._updateVisibility())}setCulled(e){this._culled!==e&&(this._culled=!!e,this._updateVisibility())}setClickable(e){this._dotClickable.style["pointer-events"]=e?"all":"none"}setHighlighted(e){this._highlighted!==e&&(this._highlighted=!!e,this._highlighted?this._dot.classList.add(this._highlightClass):this._dot.classList.remove(this._highlightClass))}destroy(){this.setVisible(!1),this._dot.parentElement&&this._dot.parentElement.removeChild(this._dot),this._dotClickable.parentElement&&this._dotClickable.parentElement.removeChild(this._dotClickable)}}class Db{constructor(e,t={}){this._highlightClass="viewer-ruler-label-highlighted",this._prefix=t.prefix||"",this._x=0,this._y=0,this._visible=!0,this._culled=!1,this._label=document.createElement("div"),this._label.className+=this._label.className?" viewer-ruler-label":"viewer-ruler-label",this._timeout=null;var s=this._label,i=s.style;if(i["border-radius"]="5px",i.color="white",i.padding="4px",i.border="solid 1px",i.background="lightgreen",i.position="absolute",i["z-index"]=void 0===t.zIndex?"5000005":t.zIndex,i.width="auto",i.height="auto",i.visibility="visible",i.top="0px",i.left="0px",i["pointer-events"]="all",i.opacity=1,t.onContextMenu,s.innerText="",e.appendChild(s),this.setPos(t.x||0,t.y||0),this.setFillColor(t.fillColor),this.setBorderColor(t.fillColor),this.setText(t.text),t.onMouseOver&&s.addEventListener("mouseover",(e=>{t.onMouseOver(e,this),e.preventDefault()})),t.onMouseLeave&&s.addEventListener("mouseleave",(e=>{t.onMouseLeave(e,this),e.preventDefault()})),t.onMouseWheel&&s.addEventListener("wheel",(e=>{t.onMouseWheel(e,this)})),t.onMouseDown&&s.addEventListener("mousedown",(e=>{t.onMouseDown(e,this),e.stopPropagation()})),t.onMouseUp&&s.addEventListener("mouseup",(e=>{t.onMouseUp(e,this),e.stopPropagation()})),t.onMouseMove&&s.addEventListener("mousemove",(e=>{t.onMouseMove(e,this)})),t.onContextMenu){Pb(s,(e=>{t.onContextMenu(e,this)}))}}setPos(e,t){this._x=e,this._y=t;var s=this._label.style;s.left=Math.round(e)-20+"px",s.top=Math.round(t)-12+"px"}setPosOnWire(e,t,s,i){var r=e+.5*(s-e),n=t+.5*(i-t),A=this._label.style;A.left=Math.round(r)-20+"px",A.top=Math.round(n)-12+"px"}setPosBetweenWires(e,t,s,i,r,n){var A=(e+s+r)/3,o=(t+i+n)/3,a=this._label.style;a.left=Math.round(A)-20+"px",a.top=Math.round(o)-12+"px"}setText(e){this._label.innerHTML=this._prefix+(e||"")}setFillColor(e){this._fillColor=e||"lightgreen",this._label.style.background=this._fillColor}setBorderColor(e){this._borderColor=e||"black",this._label.style.border="solid 1px "+this._borderColor}setOpacity(e){this._label.style.opacity=e}_updateVisibility(){this._label.style.visibility=this._visible&&!this._culled?"visible":"hidden"}setVisible(e){this._visible!==e&&(this._visible=!!e,this._updateVisibility())}setCulled(e){this._culled!==e&&(this._culled=!!e,this._updateVisibility())}setHighlighted(e){this._highlighted!==e&&(this._highlighted=!!e,this._highlighted?this._label.classList.add(this._highlightClass):this._label.classList.remove(this._highlightClass))}setClickable(e){this._label.style["pointer-events"]=e?"all":"none"}setPrefix(e){this._prefix!==e&&(this._prefix=e)}destroy(){this._label.parentElement&&this._label.parentElement.removeChild(this._label)}}class kb{constructor(e,t={}){this._color=t.color||"black",this._highlightClass="viewer-ruler-wire-highlighted",this._wire=document.createElement("div"),this._wire.className+=this._wire.className?" viewer-ruler-wire":"viewer-ruler-wire",this._wireClickable=document.createElement("div"),this._wireClickable.className+=this._wireClickable.className?" viewer-ruler-wire-clickable":"viewer-ruler-wire-clickable",this._thickness=t.thickness||1,this._thicknessClickable=t.thicknessClickable||6,this._visible=!0,this._culled=!1;var s=this._wire,i=s.style;i.border="solid "+this._thickness+"px "+this._color,i.position="absolute",i["z-index"]=void 0===t.zIndex?"2000001":t.zIndex,i.width="0px",i.height="0px",i.visibility="visible",i.top="0px",i.left="0px",i["-webkit-transform-origin"]="0 0",i["-moz-transform-origin"]="0 0",i["-ms-transform-origin"]="0 0",i["-o-transform-origin"]="0 0",i["transform-origin"]="0 0",i["-webkit-transform"]="rotate(0deg)",i["-moz-transform"]="rotate(0deg)",i["-ms-transform"]="rotate(0deg)",i["-o-transform"]="rotate(0deg)",i.transform="rotate(0deg)",i.opacity=1,i["pointer-events"]="none",t.onContextMenu,e.appendChild(s);var r=this._wireClickable,n=r.style;if(n.border="solid "+this._thicknessClickable+"px "+this._color,n.position="absolute",n["z-index"]=void 0===t.zIndex?"2000002":t.zIndex+1,n.width="0px",n.height="0px",n.visibility="visible",n.top="0px",n.left="0px",n["-webkit-transform-origin"]="0 0",n["-moz-transform-origin"]="0 0",n["-ms-transform-origin"]="0 0",n["-o-transform-origin"]="0 0",n["transform-origin"]="0 0",n["-webkit-transform"]="rotate(0deg)",n["-moz-transform"]="rotate(0deg)",n["-ms-transform"]="rotate(0deg)",n["-o-transform"]="rotate(0deg)",n.transform="rotate(0deg)",n.opacity=0,n["pointer-events"]="none",t.onContextMenu,e.appendChild(r),t.onMouseOver&&r.addEventListener("mouseover",(e=>{t.onMouseOver(e,this)})),t.onMouseLeave&&r.addEventListener("mouseleave",(e=>{t.onMouseLeave(e,this)})),t.onMouseWheel&&r.addEventListener("wheel",(e=>{t.onMouseWheel(e,this)})),t.onMouseDown&&r.addEventListener("mousedown",(e=>{t.onMouseDown(e,this)})),t.onMouseUp&&r.addEventListener("mouseup",(e=>{t.onMouseUp(e,this)})),t.onMouseMove&&r.addEventListener("mousemove",(e=>{t.onMouseMove(e,this)})),t.onContextMenu){Pb(r,(e=>{t.onContextMenu(e,this)}))}this._x1=0,this._y1=0,this._x2=0,this._y2=0,this._update()}get visible(){return"visible"===this._wire.style.visibility}_update(){var e=Math.abs(Math.sqrt((this._x1-this._x2)*(this._x1-this._x2)+(this._y1-this._y2)*(this._y1-this._y2))),t=180*Math.atan2(this._y2-this._y1,this._x2-this._x1)/Math.PI,s=this._wire.style;s.width=Math.round(e)+"px",s.left=Math.round(this._x1)+"px",s.top=Math.round(this._y1)+"px",s["-webkit-transform"]=s["-moz-transform"]=s["-ms-transform"]=s["-o-transform"]=s.transform="rotate("+t+"deg) translate(-"+this._thickness+"px, -"+this._thickness+"px)";var i=this._wireClickable.style;i.width=Math.round(e)+"px",i.left=Math.round(this._x1)+"px",i.top=Math.round(this._y1)+"px",i["-webkit-transform"]=i["-moz-transform"]=i["-ms-transform"]=i["-o-transform"]=i.transform="rotate("+t+"deg) translate(-"+this._thicknessClickable+"px, -"+this._thicknessClickable+"px)"}setStartAndEnd(e,t,s,i){this._x1=e,this._y1=t,this._x2=s,this._y2=i,this._update()}setColor(e){this._color=e||"black",this._wire.style.border="solid "+this._thickness+"px "+this._color}setOpacity(e){this._wire.style.opacity=e}_updateVisibility(){this._wire.style.visibility=this._wireClickable.style.visibility=this._visible&&!this._culled?"visible":"hidden"}setVisible(e){this._visible!==e&&(this._visible=!!e,this._updateVisibility())}setCulled(e){this._culled!==e&&(this._culled=!!e,this._updateVisibility())}setClickable(e){this._wireClickable.style["pointer-events"]=e?"all":"none"}setHighlighted(e){this._highlighted!==e&&(this._highlighted=!!e,this._highlighted?this._wire.classList.add(this._highlightClass):this._wire.classList.remove(this._highlightClass))}destroy(e){this._wire.parentElement&&this._wire.parentElement.removeChild(this._wire),this._wireClickable.parentElement&&this._wireClickable.parentElement.removeChild(this._wireClickable)}}const Qb=R.vec2(),Rb=R.vec2(),Ob=R.vec2(),Vb=R.vec2(),Lb=R.vec3(),Hb=R.vec3(),Nb=R.vec4(),Gb=R.vec4(),jb=R.vec4(),Wb=R.vec4(),zb=R.mat4(),Xb={origin:R.vec3(),direction:R.vec3()},Kb=()=>{},Zb=function(e,t,s,i){const r=(e-R.dotVec3(s,t))/R.dotVec3(i,t);if(r<0)return null;{const e=R.vec3();return R.mulVec3Scalar(i,r,e),R.addVec3(s,e,e),e}};function Jb(e,t,s){const i=e.getBoundingClientRect(),r=t.getBoundingClientRect();s[0]+=i.left-r.left,s[1]+=i.top-r.top}const Yb=(e,t,s)=>{zb.set(e.viewMatrix),zb.set(e.projMatrix),s.set(t),s[3]=1,R.mulMat4v4(e.viewMatrix,s,s),R.mulMat4v4(e.projMatrix,s,s)},$b=(e,t,s,i)=>{i[0]=.5*(1+s[0])*e.offsetWidth,i[1]=.5*(1-s[1])*e.offsetHeight,Jb(e,t,i)},qb=(e,t,s,i,r,n)=>{const A=e.camera,o=e.canvas.canvas;if(R.distVec3(s,i)<.001)return!1;const a=R.subVec3(i,s,Lb);let l=0,c=1;for(let t of e._sectionPlanesState.sectionPlanes){const e=R.dotVec3(t.dir,R.subVec3(t.pos,i,Hb)),r=R.dotVec3(t.dir,R.subVec3(t.pos,s,Hb));if(r>0&&e>0)return!1;if(r>0||e>0){const e=R.dotVec3(t.dir,a);if(Math.abs(e)>=1e-6){const s=R.dotVec3(t.dir,Hb)/e;r>0?l=Math.max(l,s):c=Math.min(c,s)}}}const h=Nb,u=Gb;Yb(A,l>0?R.addVec3(s,R.mulVec3Scalar(a,l,Hb),Hb):s,h),Yb(A,c<1?R.addVec3(s,R.mulVec3Scalar(a,c,Hb),Hb):i,u);const d=h[2]/h[3]<-1||h[3]<0,p=u[2]/u[3]<-1||u[3]<0;if(d&&p)return!1;const f=(h[3]+h[2])/(h[3]+h[2]-(u[3]+u[2]));if(f>0&&f<1){const e=R.subVec4(u,h,jb);R.mulVec4Scalar(e,f,e),R.addVec4(h,e,d?h:u)}R.mulVec4Scalar(h,1/h[3]),R.mulVec4Scalar(u,1/u[3]);let g=0,m=1;for(let e=0;e<2;++e){const t=u[e]-h[e],s=(-1-h[e])/t,i=(1-h[e])/t;t>0?(g=Math.max(g,s),m=Math.min(m,i)):t<0?(g=Math.max(g,i),m=Math.min(m,s)):h[0]<-1?g=-window.Infinity:h[0]>1&&(m=window.Infinity)}if(g>=m)return!1;const _=R.subVec4(u,h,jb);return R.addVec4(h,R.mulVec4Scalar(_,m,Wb),u),R.addVec4(h,R.mulVec4Scalar(_,g,Wb),h),R.mulVec4Scalar(h,1/h[3]),R.mulVec4Scalar(u,1/u[3]),$b(o,t,h,r),$b(o,t,u,n),!0};class eB extends sn{constructor(e,t,s,i={}){const r=e.camera;super(e,t),this.__visible=!0;const n=(e,t)=>s=>{e&&e(s),this.fire(t,s,!0)};this._dot=new Sb(s,{borderColor:i.borderColor,fillColor:i.fillColor,zIndex:i.zIndex,onMouseOver:n(i.onMouseOver,"mouseover"),onMouseLeave:n(i.onMouseLeave,"mouseleave"),onMouseWheel:n(i.onMouseWheel,"wheel"),onMouseDown:n(i.onMouseDown,"mousedown"),onMouseUp:n(i.onMouseUp,"mouseup"),onMouseMove:n(i.onMouseMove,"mousemove"),onTouchstart:n(i.onTouchstart,"touchstart"),onTouchmove:n(i.onTouchmove,"touchmove"),onTouchend:n(i.onTouchend,"touchend"),onContextMenu:n(i.onContextMenu,"contextmenu")});const A=()=>{if(!this.__visible)return;const t=jb;((e,t)=>{t.set(e),t[3]=1,R.mulMat4v4(r.viewMatrix,t,t),R.mulMat4v4(r.projMatrix,t,t)})(this.worldPos,t),R.mulVec3Scalar(t,1/t[3]);const i=t[3]<0||t[0]<-1||t[0]>1||t[1]<-1||t[1]>1||t[2]<-1||t[2]>1||e._sectionPlanesState.sectionPlanes.some((e=>R.dotVec3(e.dir,R.subVec3(e.pos,this.worldPos,Lb))>0));this._dot.setCulled(i),i||((t=>{const i=e.canvas.canvas;t[0]=.5*(1+t[0])*i.offsetWidth,t[1]=.5*(1-t[1])*i.offsetHeight,Jb(i,s,t)})(t),this._dot.setPos(t[0],t[1]))};this.on("worldPos",A);const o=r.on("viewMatrix",A),a=r.on("projMatrix",A),l=e.canvas.on("boundary",A),c=e.on("sectionPlaneUpdated",A),h=e.on("sectionPlaneCreated",A),u=e.on("sectionPlaneDestroyed",A);this._updatePosition=A,this._cleanup=()=>{r.off(o),r.off(a),e.canvas.off(l),e.off(c),e.off(h),e.off(u),this._dot.destroy()}}setClickable(e){this._dot.setClickable(e)}setFillColor(e){this._dot.setFillColor(e)}setBorderColor(e){this._dot.setBorderColor(e)}setHighlighted(e){this._dot.setHighlighted(e)}setOpacity(e){this._dot.setOpacity(e)}setVisible(e){this.__visible!=e&&(this.__visible=e,this._updatePosition(),this._dot.setVisible(e))}destroy(){this._cleanup(),super.destroy()}}class tB{constructor(e,t,s){const i=e.camera;this._label=new Db(t,s),this._start=R.vec3(),this._mid=R.vec3(),this._end=R.vec3(),this._yOff=0,this.__visible=!0,this._updatePos=()=>{Yb(i,this._start,Nb),R.mulVec4Scalar(Nb,1/Nb[3]),$b(e.canvas.canvas,t,Nb,Qb),this._label.setPos(Qb[0],Qb[1])};const r=(e,t,s)=>{e[0]+=t[0],e[1]+=t[1],R.mulVec2Scalar(e,.5),this._label.setPos(e[0],e[1]+s)};this._updatePosBetween=()=>{const s=qb(e,t,this._start,this._mid,Qb,Rb),i=qb(e,t,this._end,this._mid,Ob,Vb);this._label.setCulled(!(s||i)),s&&i?(Rb[0]+=Vb[0],Rb[1]+=Vb[1],R.mulVec2Scalar(Rb,.5),Rb[0]+=Qb[0]+Ob[0],Rb[1]+=Qb[1]+Ob[1],R.mulVec2Scalar(Rb,1/3),this._label.setPos(Rb[0],Rb[1])):s?r(Qb,Rb,0):i&&r(Ob,Vb,0)},this._updatePosOnWire=()=>{const s=qb(e,t,this._start,this._end,Qb,Rb)&&R.distVec2(Qb,Rb)>=this._labelMinAxisLength;this._label.setCulled(!s),s&&r(Qb,Rb,this._yOff)};let n=()=>{};this._setUpdatePositions=e=>{n=e,this._updatePositions()},this._updatePositions=()=>{this.__visible&&n()};const A=i.on("viewMatrix",this._updatePositions),o=i.on("projMatrix",this._updatePositions),a=e.canvas.on("boundary",this._updatePositions),l=e.on("sectionPlaneUpdated",this._updatePositions),c=e.on("sectionPlaneCreated",this._updatePositions),h=e.on("sectionPlaneDestroyed",this._updatePositions);this._cleanup=()=>{i.off(A),i.off(o),e.canvas.off(a),e.off(l),e.off(c),e.off(h),this._label.destroy()}}setPos(e){this._start.set(e),this._setUpdatePositions(this._updatePos)}setPosOnWire(e,t,s,i){this._start.set(e),this._end.set(t),this._yOff=s,this._labelMinAxisLength=i,this._setUpdatePositions(this._updatePosOnWire)}setPosBetween(e,t,s){this._start.set(e),this._mid.set(t),this._end.set(s),this._setUpdatePositions(this._updatePosBetween)}setFillColor(e){this._label.setFillColor(e)}setHighlighted(e){this._label.setHighlighted(e)}setText(e){this._label.setText(e)}setClickable(e){this._label.setClickable(e)}setVisible(e){this.__visible!=e&&(this.__visible=e,this._updatePositions(),this._label.setVisible(e))}destroy(){this._cleanup()}}class sB{constructor(e,t,s){const i=e.camera;this._wire=new kb(t,s),this._start=R.vec3(),this._end=R.vec3(),this.__visible=!0,this._updatePositions=()=>{if(!this.__visible)return;const s=qb(e,t,this._start,this._end,Qb,Rb);this._wire.setCulled(!s),s&&this._wire.setStartAndEnd(Qb[0],Qb[1],Rb[0],Rb[1])};const r=i.on("viewMatrix",this._updatePositions),n=i.on("projMatrix",this._updatePositions),A=e.canvas.on("boundary",this._updatePositions),o=e.on("sectionPlaneUpdated",this._updatePositions),a=e.on("sectionPlaneCreated",this._updatePositions),l=e.on("sectionPlaneDestroyed",this._updatePositions);this._cleanup=()=>{i.off(r),i.off(n),e.canvas.off(A),e.off(o),e.off(a),e.off(l),this._wire.destroy()}}setEnds(e,t){this._start.set(e),this._end.set(t),this._updatePositions()}setClickable(e){this._wire.setClickable(e)}setColor(e){this._wire.setColor(e)}setHighlighted(e){this._wire.setHighlighted(e)}setOpacity(e){this._wire.setOpacity(e)}setVisible(e){this.__visible!=e&&(this.__visible=e,this._updatePositions(),this._wire.setVisible(e))}destroy(){this._cleanup()}}const iB=function(e,t){const s=new eB(e,{},e.canvas.canvas.parentNode,{borderColor:"white",fillColor:t,zIndex:100});return{update:function(e){e&&(s.worldPos=e),s.setVisible(!!e)},setFillColor:e=>s.setFillColor(e),setHighlighted:e=>s.setHighlighted(e),getCanvasPos:()=>s.canvasPos,getWorldPos:()=>s.worldPos,destroy:()=>s.destroy()}},rB=function(e,t){const s=new sB(e,e.canvas.canvas.ownerDocument.body,{color:t,thickness:1,thicknessClickable:6});return s.setVisible(!1),{update:(e,t)=>{t&&s.setEnds(e,t),s.setVisible(!!t)},setColor:e=>s.setColor(e),destroy:()=>s.destroy()}};function nB(e,t){const s=function(e,s){if(e in t)return t[e];if(void 0!==s)return s;throw"config missing: "+e},i=s("viewer"),r=s("ray2WorldPos"),n=s("handleMouseEvents",!1),A=s("handleTouchEvents",!1),o=s("onStart",Kb),a=s("onMove",Kb),l=s("onEnd",Kb),c=i.scene,h=c.canvas.canvas,u=e=>{const t=R.vec2([e.clientX,e.clientY]);Jb(h.ownerDocument.documentElement,h,t),a(t,(e=>{const t=R.vec3(),s=R.vec3();return R.canvasPosToWorldRay(h,c.camera.viewMatrix,c.camera.projMatrix,c.camera.projection,e,t,s),r(t,s,e)})(t))};let d=null;const p=function(e){const t=d.matchesEvent(e);t&&u(t)},f=function(t){const s=d.matchesEvent(t);s&&(e.setOpacity(b),d.cleanup(),u(s),l())},g=function(t,s){d&&d.cleanup(),e.setOpacity(1),e.setClickable(!1),i.cameraControl.active=!1,d={matchesEvent:t,cleanup:function(){d=null,e.setClickable(!0),i.cameraControl.active=!0,s()}},o()},m=[],_=function(t,s){const i=e.on(t,s);m.push((()=>e.off(i)))};if(n&&(_("mouseover",(()=>!d&&e.setOpacity(1))),_("mouseleave",(()=>!d&&e.setOpacity(b))),_("mousedown",(e=>{1===e.which&&(h.addEventListener("mousemove",p),h.addEventListener("mouseup",f),g((e=>1===e.which&&e),(()=>{h.removeEventListener("mousemove",p),h.removeEventListener("mouseup",f)})))}))),A){let e;_("touchstart",(t=>{t.preventDefault(),1===t.touches.length&&(e=t.touches[0].identifier,g((t=>[...t.changedTouches].find((t=>t.identifier===e))),(()=>{e=null})))})),_("touchmove",(e=>{e.preventDefault(),p(e)})),_("touchend",(e=>{e.preventDefault(),f(e)}))}const b=.8;return e.setOpacity(b),function(){d&&d.cleanup(),m.forEach((e=>e())),e.setOpacity(1)}}function AB(e){const t=function(t,s){if(t in e)return e[t];if(void 0!==s)return s;throw"config missing: "+t},s=t("viewer"),i=t("handleMouseEvents",!1),r=t("handleTouchEvents",!1),n=t("pointerLens",null),A=t("dots"),o=t("ray2WorldPos"),a=t("onEnd",Kb),l=n?function(e){n.visible=!!e,e&&(n.canvasPos=e)}:()=>{},c=A.map((e=>{let t;return nB(e,{handleMouseEvents:i,handleTouchEvents:r,viewer:s,ray2WorldPos:(e,s,i)=>o(e,s,i)||t,onStart:()=>{t=e.worldPos.slice(),h(!1,e)},onMove:(t,s)=>{l(t),e.worldPos=s},onEnd:()=>{a(t,e)||(e.worldPos=t),l(null),h(!0,e)}})})),h=(e,t)=>A.forEach((s=>s!==t&&s.setClickable(e)));return h(!0),function(){c.forEach((e=>e())),l(null)}}const oB=function(e,t,s){return function(i,r,n){const A=e.scene,o=A.canvas.canvas,a=(e,t)=>(t[0]=e.clientX,t[1]=e.clientY,Jb(o.ownerDocument.documentElement,o,t),t),l=e=>{const t=R.vec3(),i=R.vec3();return R.canvasPosToWorldRay(o,A.camera.viewMatrix,A.camera.projMatrix,A.camera.projection,e,t,i),s(t,i)};let c=null;const h=()=>{};let u,d=h;const p=function(){t.stop(),clearTimeout(c),e.cameraControl.active=!0,d=h,u=null},f=function(){p(),o.removeEventListener("touchstart",g),o.removeEventListener("touchmove",m),o.removeEventListener("touchend",_)},g=function(s){const n=s.touches;if(1!==n.length)p(),i();else{const s=n[0],i=a(s,R.vec2());l(i)&&(u=s.identifier,d=e=>{R.distVec2(i,e)>20&&p()},c=setTimeout((function(){t.start(i),c=setTimeout((function(){t.stop(),e.cameraControl.active=!1,d=e=>{r(e,l(e))},d(i)}),300)}),250))}};o.addEventListener("touchstart",g,{passive:!0});const m=function(e){const t=[...e.changedTouches].find((e=>e.identifier===u));t&&d(a(t,R.vec2()))};o.addEventListener("touchmove",m,{passive:!0});const _=function(e){const t=[...e.changedTouches].find((e=>e.identifier===u));if(t){f();const e=a(t,R.vec2());n(e,l(e))}};return o.addEventListener("touchend",_,{passive:!0}),f}},aB=function(e){const t=[];for(let s=0;s<e.length;++s)t.push(s);const s=function(){const s=R.vec2(),i=R.vec2();let r=0;for(let n=0;n<t.length;++n){const A=e[t[n]],o=e[t[(n+1)%t.length]],a=e[t[(n+2)%t.length]];R.subVec2(A,o,s),R.subVec2(a,o,i);const l=R.dotVec2(s,i)/Math.sqrt(R.sqLenVec2(s)*R.sqLenVec2(i)),c=Math.acos(Math.max(-1,Math.min(l,1)));r+=s[0]*i[1]-s[1]*i[0]>=0?c:2*Math.PI-c}return r<t.length*Math.PI}(),i=function(){const e=(e,t,s)=>(e[0]-s[0])*(t[1]-s[1])-(t[0]-s[0])*(e[1]-s[1]);return(t,s,i,r)=>{const n=e(t,s,i),A=e(t,i,r),o=e(t,r,s);return!((n<0||A<0||o<0)&&(n>0||A>0||o>0))}}(),r=[],n=(s?t:t.slice(0).reverse()).map((e=>({idx:e})));n.forEach(((e,t)=>{e.prev=n[(t-1+n.length)%n.length],e.next=n[(t+1)%n.length]}));const A=R.vec2(),o=R.vec2();for(;n.length>2;){let t=0;for(;;){if(t>=n.length)throw`isCCW = ${s}; earIdx = ${t}; len = ${n.length}`;const r=n[t],a=e[r.prev.idx],l=e[r.idx],c=e[r.next.idx];if(R.subVec2(a,l,A),R.subVec2(c,l,o),A[0]*o[1]-A[1]*o[0]>=0&&n.every((t=>t===r||t===r.prev||t===r.next||!i(e[t.idx],a,l,c))))break;++t}const a=n[t];n.splice(t,1),r.push([a.idx,a.next.idx,a.prev.idx]);a.prev.next=a.next;a.next.prev=a.prev}return[e,r,s]};const lB=R.vec3(),cB=R.vec3();class hB extends ie{constructor(e,t={}){const s=e.viewer.scene;super(s,t),this.plugin=e;const i=t.container;if(!i)throw"config missing: container";this._color=t.color||e.defaultColor;const r=function(e){const t=[];let s=!1!==e;return{reg:e=>t.push(e),get:()=>s,set:e=>{s=!1!==e,t.forEach((e=>e(s)))}}};this._visible=r(t.visible),this._originVisible=r(t.originVisible),this._cornerVisible=r(t.cornerVisible),this._targetVisible=r(t.targetVisible),this._originWireVisible=r(t.originWireVisible),this._targetWireVisible=r(t.targetWireVisible),this._angleVisible=r(t.angleVisible),this._labelsVisible=r(),this.labelsVisible=t.labelsVisible,this._clickable=r(!1),this.approximate=t.approximate,this._labelStringFormat=e=>(this._approximate?" ~ ":" = ")+e.toFixed(2)+"°";const n=s.canvas.canvas,A=t.onMouseOver?e=>{t.onMouseOver(e,this),n.dispatchEvent(new MouseEvent("mouseover",e))}:null,o=t.onMouseLeave?e=>{t.onMouseLeave(e,this),n.dispatchEvent(new MouseEvent("mouseleave",e))}:null,a=t.onContextMenu?e=>{t.onContextMenu(e,this)}:null,l=e=>n.dispatchEvent(new MouseEvent("mousedown",e)),c=e=>n.dispatchEvent(new MouseEvent("mouseup",e)),h=e=>n.dispatchEvent(new MouseEvent("mousemove",e)),u=e=>n.dispatchEvent(new WheelEvent("wheel",e));this._cleanups=[],this._drawables=[];const d=(e,t)=>{const s=()=>e.setVisible(t.every((e=>e.get())));t.forEach((e=>e.reg(s))),this._drawables.push(e),this._cleanups.push((()=>e.destroy()))},p=(t,r,n)=>{const p=new sB(s,i,{color:t,thickness:r,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return d(p,n),{setEnds:(e,t)=>p.setEnds(e,t),setColor:e=>p.setColor(e)}};this._originWire=p(this._color||"blue",1,[this._visible,this._originWireVisible]),this._targetWire=p(this._color||"red",1,[this._visible,this._targetWireVisible]);this._angleLabel=((t,r,n)=>{const p=new tB(s,i,{fillColor:t,zIndex:e.zIndex+r,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return d(p,n),{setFillColor:e=>p.setFillColor(e),setPosOnWire:(e,t,s)=>p.setPosOnWire(e,t,s),setPosBetween:(e,t,s)=>p.setPosBetween(e,t,s),setText:e=>p.setText(e)}})(this._color||"#00BBFF",2,[this._visible,this._angleVisible,this._labelsVisible]);const f=(t,r)=>{const n=new eB(s,t,i,{fillColor:this._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return n.on("worldPos",(()=>this._update())),d(n,r),n};this._originDot=f(t.origin,[this._visible,this._originVisible]),this._cornerDot=f(t.corner,[this._visible,this._cornerVisible]),this._targetDot=f(t.target,[this._visible,this._targetVisible]),this._update()}_update(){if(!this._targetDot)return;const e=this._originDot.worldPos,t=this._cornerDot.worldPos,s=this._targetDot.worldPos;this._originWire.setEnds(e,t),this._targetWire.setEnds(t,s),this._angleLabel.setPosBetween(e,t,s),R.subVec3(e,t,lB),R.subVec3(s,t,cB),R.lenVec3(lB)>0&&R.lenVec3(cB)>0?(R.normalizeVec3(lB),R.normalizeVec3(cB),this._angle=Math.abs(R.angleVec3(lB,cB))*R.RADTODEG,this._angleLabel.setText(this._labelStringFormat(this._angle))):(this._angle=void 0,this._angleLabel.setText(""))}set approximate(e){e=!1!==e,this._approximate!==e&&(this._approximate=e,this._update())}get approximate(){return this._approximate}get origin(){return this._originDot}get corner(){return this._cornerDot}get target(){return this._targetDot}get angle(){return this._angle}get color(){return this._color}set color(e){this._color=e,this._originDot.setFillColor(e),this._cornerDot.setFillColor(e),this._targetDot.setFillColor(e),this._originWire.setColor(e||"blue"),this._targetWire.setColor(e||"red"),this._angleLabel.setFillColor(e||"#00BBFF")}set visible(e){this._visible.set(e)}get visible(){return this._visible.get()}set originVisible(e){this._originVisible.set(e)}get originVisible(){return this._originVisible.get()}set cornerVisible(e){this._cornerVisible.set(e)}get cornerVisible(){return this._cornerVisible.get()}set targetVisible(e){this._targetVisible.set(e)}get targetVisible(){return this._targetVisible.get()}set originWireVisible(e){this._originWireVisible.set(e)}get originWireVisible(){return this._originWireVisible.get()}set targetWireVisible(e){this._targetWireVisible.set(e)}get targetWireVisible(){return this._targetWireVisible.get()}set angleVisible(e){this._angleVisible.set(e)}get angleVisible(){return this._angleVisible.get()}set labelsVisible(e){this._labelsVisible.set(void 0!==e?Boolean(e):this.plugin.defaultLabelsVisible)}get labelsVisible(){return this._labelsVisible.get()}setHighlighted(e){this._drawables.forEach((t=>t.setHighlighted(e)))}set clickable(e){this._clickable.set(!!e),this._drawables.forEach((e=>e.setClickable(this._clickable.get())))}get labelStringFormat(){return this._labelStringFormat}set labelStringFormat(e){this._labelStringFormat=e,this._update()}get clickable(){return this._clickable.get()}destroy(){this._cleanups.forEach((e=>e())),super.destroy()}}class uB extends ie{get active(){}set snapping(e){}get snapping(){return!0}activate(){}deactivate(){}reset(){}get currentMeasurement(){return null}destroy(){}}class dB extends uB{constructor(e,t={}){super(e.viewer.scene),this._canvasToPagePos=t.canvasToPagePos,this.pointerLens=t.pointerLens,this._active=!1,this._currentAngleMeasurement=null,this._initMarkerDiv(),this._snapping=!1!==t.snapping,this._mouseState=0,this._attachPlugin(e,t)}_initMarkerDiv(){const e=document.createElement("div"),t=this.scene.canvas.canvas;t.parentNode.insertBefore(e,t),e.style.background="black",e.style.border="2px solid blue",e.style.borderRadius="10px",e.style.width="5px",e.style.height="5px",e.style.top="-200px",e.style.left="-200px",e.style.margin="0 0",e.style.zIndex="100",e.style.position="absolute",e.style.pointerEvents="none",this.markerDiv=e}_destroyMarkerDiv(){this.markerDiv&&(this.markerDiv.parentNode.removeChild(this.markerDiv),this.markerDiv=null)}_attachPlugin(e,t={}){this.angleMeasurementsPlugin=e,this.plugin=e}get active(){return this._active}set snapping(e){this._snapping=e}get snapping(){return this._snapping}activate(){if(this._active)return;this.markerDiv||this._initMarkerDiv(),this.angleMeasurementsPlugin;const e=this.scene;e.input;const t=e.canvas.canvas,s=this.angleMeasurementsPlugin.viewer.cameraControl,i=this.pointerLens;let r=!1,n=null,A=0,o=0;const a=R.vec3(),l=R.vec2();this._currentAngleMeasurement=null;const c=R.vec2(),h=e=>{e.snappedToVertex||e.snappedToEdge?(i&&(i.visible=!0,i.canvasPos=e.canvasPos,i.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,i.snapped=!0),this.markerDiv.style.background="greenyellow",this.markerDiv.style.border="2px solid green"):(i&&(i.visible=!0,i.canvasPos=e.canvasPos,i.snappedCanvasPos=e.canvasPos,i.snapped=!1),this.markerDiv.style.background="pink",this.markerDiv.style.border="2px solid red");const s=e.snappedCanvasPos||e.canvasPos;switch(r=!0,n=e.entity,a.set(e.worldPos),l.set(s),this._mouseState){case 0:if(this._canvasToPagePos)this._canvasToPagePos(t,s,c),this.markerDiv.style.left=c[0]-5+"px",this.markerDiv.style.top=c[1]-5+"px";else{const e=R.vec2(s);Jb(t,this.markerDiv.parentNode,e),this.markerDiv.style.left=e[0]-5+"px",this.markerDiv.style.top=e[1]-5+"px"}break;case 1:this._currentAngleMeasurement&&(this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.angleVisible=!1,this._currentAngleMeasurement.corner.worldPos=e.worldPos,this._currentAngleMeasurement.corner.entity=e.entity),this.markerDiv.style.left="-10000px",this.markerDiv.style.top="-10000px",t.style.cursor="pointer";break;case 2:this._currentAngleMeasurement&&(this._currentAngleMeasurement.targetWireVisible=!0,this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.angleVisible=!0,this._currentAngleMeasurement.target.worldPos=e.worldPos,this._currentAngleMeasurement.target.entity=e.entity),this.markerDiv.style.left="-10000px",this.markerDiv.style.top="-10000px",t.style.cursor="pointer"}};this._onHoverSnapOrSurface=s.on("hoverSnapOrSurface",(e=>{this._snapping&&h(e)})),this._onHoverSurface=s.on("hoverSurface",(e=>{this._snapping||h(e)})),t.addEventListener("mousedown",this._onMouseDown=e=>{1===e.which&&(A=e.clientX,o=e.clientY)}),t.addEventListener("mouseup",this._onMouseUp=e=>{if(1===e.which&&!(e.clientX>A+20||e.clientX<A-20||e.clientY>o+20||e.clientY<o-20))switch(this._mouseState){case 0:r&&(this._currentAngleMeasurement=this.angleMeasurementsPlugin.createMeasurement({id:R.createUUID(),origin:{worldPos:a,entity:n},corner:{worldPos:a,entity:n},target:{worldPos:a,entity:n},approximate:!0}),this._currentAngleMeasurement.clickable=!1,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.angleVisible=!1,this._currentAngleMeasurement.origin.entity=n,this._mouseState=1,this.angleMeasurementsPlugin.fire("measurementStart",this._currentAngleMeasurement));break;case 1:r?(this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.angleVisible=!0,this._currentAngleMeasurement.corner.entity=n,this._mouseState=2):this._currentAngleMeasurement&&(this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null,n=null,this._mouseState=0,this.angleMeasurementsPlugin.fire("measurementCancel",this._currentAngleMeasurement));break;case 2:r?(this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.angleVisible=!0,this._currentAngleMeasurement.target.entity=n,this._currentAngleMeasurement.clickable=!0,n=null,this.angleMeasurementsPlugin.fire("measurementEnd",this._currentAngleMeasurement),this._currentAngleMeasurement=null,this._mouseState=0):this._currentAngleMeasurement&&(this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null,n=null,this._mouseState=0,this.angleMeasurementsPlugin.fire("measurementCancel",this._currentAngleMeasurement))}});const u=e=>{if(r=!1,i&&(i.visible=!0,i.canvasPos=e.canvasPos,i.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,i.snapped=!1),this.markerDiv.style.left="-100px",this.markerDiv.style.top="-100px",this._currentAngleMeasurement){switch(this._mouseState){case 0:this._currentAngleMeasurement.originVisible=!1;break;case 1:this._currentAngleMeasurement.cornerVisible=!1,this._currentAngleMeasurement.originWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1;break;case 2:this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1}t.style.cursor="default"}};this._onHoverSnapOrSurfaceOff=s.on("hoverSnapOrSurfaceOff",(e=>{this._snapping&&u(e)})),this._onHoverOff=s.on("hoverOff",(e=>{this._snapping||u(e)})),this._active=!0}deactivate(){if(!this._active)return;this.pointerLens&&(this.pointerLens.visible=!1),this.reset();const e=this.scene.canvas.canvas;e.removeEventListener("mousedown",this._onMouseDown),e.removeEventListener("mouseup",this._onMouseUp);const t=this.angleMeasurementsPlugin.viewer.cameraControl;t.off(this._onHoverSnapOrSurface),t.off(this._onHoverSurface),t.off(this._onHoverSnapOrSurfaceOff),t.off(this._onHoverOff),this._active=!1}reset(){this._active&&(this._destroyMarkerDiv(),this._initMarkerDiv(),this._currentAngleMeasurement&&(this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null),this._mouseState=0)}get currentMeasurement(){return this._currentAngleMeasurement}destroy(){this.deactivate(),super.destroy()}}const pB=R.vec2();class fB extends ie{constructor(e,t,s,i){const r=e.plugin.viewer;super(r.scene);const n=AB({viewer:r,handleMouseEvents:s,handleTouchEvents:i,pointerLens:t.pointerLens,dots:[e.origin,e.corner,e.target],ray2WorldPos:(e,s,i)=>{const n=e=>{const t=r.scene.pick({canvasPos:i,snapToEdge:e,snapToVertex:e,pickSurface:!0});return t&&t.worldPos?t.worldPos:e&&n(!1)};return n(!!t.snapping)},onEnd:(e,t)=>{const s=!R.compareVec3(e,t.worldPos);return s&&this.fire("edited"),s}}),A=e.on("destroyed",n);this._deactivate=function(){e.off("destroyed",A),n()}}deactivate(){this._deactivate(),super.destroy()}}const gB=R.vec3(),mB=R.vec3(),_B=R.vec3(),bB=e=>e+"px";class BB extends sn{constructor(e,t){if(super(e,t),this.plugin=t.plugin,this._container=t.container,!this._container)throw"config missing: container";if(!t.markerElement&&!t.markerHTML)throw"config missing: need either markerElement or markerHTML";if(!t.labelElement&&!t.labelHTML)throw"config missing: need either labelElement or labelHTML";this._htmlDirty=!1,this._curMarkerWidth=void 0,this._curLabelWidth=0,t.markerElement?(this._marker=t.markerElement,this._marker.addEventListener("click",this._onMouseClickedExternalMarker=()=>{this.plugin.fire("markerClicked",this)}),this._onContextMenuExternalMarker=()=>{this.plugin.fire("contextmenu",this)},this._onContextMenuExternalMarkerRemover=Pb(this._marker,this._onContextMenuExternalMarker),this._marker.addEventListener("mouseenter",this._onMouseEnterExternalMarker=()=>{this.plugin.fire("markerMouseEnter",this)}),this._marker.addEventListener("mouseleave",this._onMouseLeaveExternalMarker=()=>{this.plugin.fire("markerMouseLeave",this)}),this._markerExternal=!0):(this._markerHTML=t.markerHTML,this._htmlDirty=!0,this._markerExternal=!1),t.labelElement?(this._label=t.labelElement,this._labelExternal=!0):(this._labelHTML=t.labelHTML,this._htmlDirty=!0,this._labelExternal=!1),this._markerShown=!!t.markerShown,this._labelShown=!!t.labelShown,this._values=t.values||{},this._layoutDirty=!0,this._visibilityDirty=!0,this._labelPosition=24,this._buildHTML(),this._onTick=this.scene.on("tick",(()=>{this._htmlDirty&&(this._buildHTML(),this._htmlDirty=!1,this._layoutDirty=!0,this._visibilityDirty=!0),(this._layoutDirty||this._visibilityDirty)&&(this._markerShown||this._labelShown)&&(this._updatePosition(),this._layoutDirty=!1),this._visibilityDirty&&(this._marker.style.visibility=this.visible&&this._markerShown?"visible":"hidden",this._label.style.visibility=this.visible&&this._markerShown&&this._labelShown?"visible":"hidden",this._visibilityDirty=!1)})),this.on("canvasPos",(()=>{this._layoutDirty=!0})),this.on("visible",(()=>{this._visibilityDirty=!0})),this.setMarkerShown(!1!==t.markerShown),this.setLabelShown(t.labelShown),this.eye=t.eye?t.eye.slice():null,this.look=t.look?t.look.slice():null,this.up=t.up?t.up.slice():null,this.projection=t.projection}_buildHTML(){if(!this._markerExternal){this._marker&&(this._container.removeChild(this._marker),this._marker=null);let e=this._markerHTML||"<p></p>";j.isArray(e)&&(e=e.join("")),e=this._renderTemplate(e.trim());const t=document.createRange().createContextualFragment(e);this._marker=t.firstChild,this._container.appendChild(this._marker),this._marker.style.visibility=this._markerShown?"visible":"hidden",this._marker.addEventListener("click",(()=>{this.plugin.fire("markerClicked",this)})),Pb(this._marker,(e=>{e.preventDefault(),this.plugin.fire("contextmenu",this)}),(e=>{e.preventDefault(),this.plugin.fire("markerClicked",this)})),this._marker.addEventListener("mouseenter",(()=>{this.plugin.fire("markerMouseEnter",this)})),this._marker.addEventListener("mouseleave",(()=>{this.plugin.fire("markerMouseLeave",this)})),this._marker.addEventListener("wheel",(e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))}))}if(!this._labelExternal){this._label&&(this._container.removeChild(this._label),this._label=null);let e=this._labelHTML||"<p></p>";j.isArray(e)&&(e=e.join("")),e=this._renderTemplate(e.trim());const t=document.createRange().createContextualFragment(e);this._label=t.firstChild,this._container.appendChild(this._label),this._label.style.visibility=this._markerShown&&this._labelShown?"visible":"hidden",this._label.addEventListener("wheel",(e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))}))}}_updateWithCurWidths(){const e=this.scene.canvas.boundary,t=e[0]+this.canvasPos[0],s=e[1]+this.canvasPos[1];if(this._marker.style.top=bB(s-12),this._label.style.top=bB(s-17),"legacy"===this._markerAlign)this._marker.style.left=bB(t-12),this._label.style.left=bB(t+40);else{const e=this._curMarkerWidth,s=t+("right"===this._markerAlign?-1:"center"===this._markerAlign?0:1)*(e/2-12);this._marker.style.left=bB(s-e/2);const i=this._curLabelWidth,r=Math.sign(this._labelPosition);this._label.style.left=bB(s+r*(e/2+Math.abs(this._labelPosition)+i/2)-i/2)}const i=90005+Math.floor(this._viewPos[2])+1;this._marker.style["z-index"]=i,this._label.style["z-index"]=i}_updateIfWidthsChanged(){let e=!1;const t=this._marker.getBoundingClientRect().width;this._curMarkerWidth!==t&&(this._curMarkerWidth=t,e=!0);if(1!==Math.sign(this._labelPosition)){const t=this._label.getBoundingClientRect().width;this._curLabelWidth!==t&&(this._curLabelWidth=t,e=!0)}e&&this._updateWithCurWidths()}_updatePosition(){const e="legacy"===this._markerAlign;e||void 0!==this._curMarkerWidth?(this._updateWithCurWidths(),window.clearTimeout(this._widthTimeout),e||(this._widthTimeout=window.setTimeout((()=>this._updateIfWidthsChanged()),500))):this._updateIfWidthsChanged()}_renderTemplate(e){for(var t in this._values)if(this._values.hasOwnProperty(t)){const s=this._values[t];e=e.replace(new RegExp("{{"+t+"}}","g"),s)}return e}setFromPickResult(e){if(e.worldPos&&e.worldNormal){const t=R.normalizeVec3(e.worldNormal,gB),s=this.plugin&&this.plugin.surfaceOffset||0,i=R.mulVec3Scalar(t,s,mB),r=R.addVec3(e.worldPos,i,_B);this.entity=e.entity,this.worldPos=r}else this.error("Param 'pickResult' does not have both worldPos and worldNormal")}setMarkerAlign(e){const t=["left","center","right","legacy"];t.includes(e)?(this._markerAlign=e,this._updatePosition()):this.error("Param 'align' should be one of: "+JSON.stringify(t))}setLabelPosition(e){"number"!=typeof e?this.error("Param 'position' is not a number"):0===e?this.error("Param 'position' is zero"):(this._labelPosition=e,this._updatePosition())}setMarkerShown(e){e=!!e,this._markerShown!==e&&(this._markerShown=e,this._visibilityDirty=!0)}getMarkerShown(){return this._markerShown}setLabelShown(e){e=!!e,this._labelShown!==e&&(this._labelShown=e,this._visibilityDirty=!0)}getLabelShown(){return this._labelShown}setField(e,t){this._values[e]=t||"",this._htmlDirty=!0}getField(e){return this._values[e]}setValues(e){for(var t in e)if(e.hasOwnProperty(t)){const s=e[t];this.setField(t,s)}}getValues(){return this._values}destroy(){window.clearTimeout(this._widthTimeout),this._marker&&(this._markerExternal?(this._marker.removeEventListener("click",this._onMouseClickedExternalMarker),this._onContextMenuExternalMarkerRemover(),this._marker.removeEventListener("mouseenter",this._onMouseEnterExternalMarker),this._marker.removeEventListener("mouseleave",this._onMouseLeaveExternalMarker),this._marker=null):(this._marker.parentNode.removeChild(this._marker),this._marker=null)),this._label&&(this._labelExternal||this._label.parentNode.removeChild(this._label),this._label=null),this.scene.off(this._onTick),super.destroy()}}const yB=R.vec3(),wB=R.vec3(),vB=R.vec3(),CB=R.vec3();function MB(e){return{x:e[0],y:e[1],z:e[2]}}function EB(e,t){return(t=new Float64Array(3))[0]=e.x,t[1]=e.y,t[2]=e.z,t}function FB(e){return new Float64Array([e[0],-e[2],e[1]])}function xB(e){return new Float64Array([e[0],e[2],-e[1]])}const UB=R.vec3(),IB=R.vec3(),TB=R.vec3();R.vec4(),R.vec4(),R.vec4();class PB extends ie{constructor(e,t={}){const s=e.viewer.scene;super(s,t),this.plugin=e;const i=t.container;if(!i)throw"config missing: container";this._color=t.color||e.defaultColor;const r=function(e,t){const s=[];let i=void 0!==e?Boolean(e):t;return{reg:e=>s.push(e),get:()=>i,set:e=>{i=void 0!==e?Boolean(e):t,s.forEach((e=>e(i)))}}};this._visible=r(t.visible,e.defaultVisible),this._originVisible=r(t.originVisible,e.defaultOriginVisible),this._targetVisible=r(t.targetVisible,e.defaultTargetVisible),this._axisVisible=r(t.axisVisible,e.defaultAxisVisible),this._xAxisVisible=r(t.xAxisVisible,e.defaultAxisVisible),this._yAxisVisible=r(t.yAxisVisible,e.defaultAxisVisible),this._zAxisVisible=r(t.zAxisVisible,e.defaultAxisVisible),this._axisEnabled=r(!0,e.defaultAxisVisible),this._wireVisible=r(t.wireVisible,e.defaultWireVisible),this._xLabelEnabled=r(t.xLabelEnabled,e.defaultXLabelEnabled),this._yLabelEnabled=r(t.yLabelEnabled,e.defaultYLabelEnabled),this._zLabelEnabled=r(t.zLabelEnabled,e.defaultZLabelEnabled),this._lengthLabelEnabled=r(t.lengthLabelEnabled,e.defaultLengthLabelEnabled),this._labelsVisible=r(t.labelsVisible,e.defaultLabelsVisible),this._clickable=r(!1,!1),this._labelsOnWires=r(t.labelsOnWires,e.defaultLabelsOnWires),this._useRotationAdjustment=r(t.useRotationAdjustment,e.useRotationAdjustment),this._axesBasis=R.identityMat4(),this.approximate=t.approximate,this._labelStringFormat=e=>{const t=this.plugin.viewer.scene.metrics,s=t.scale,i=t.unitsInfo[t.units].abbrev;return(this.approximate?" ~ ":" = ")+(e*s).toFixed(2)+i};const n=s.canvas.canvas,A=t.onMouseOver?e=>{t.onMouseOver(e,this),n.dispatchEvent(new MouseEvent("mouseover",e))}:null,o=t.onMouseLeave?e=>{t.onMouseLeave(e,this),n.dispatchEvent(new MouseEvent("mouseleave",e))}:null,a=t.onContextMenu?e=>{t.onContextMenu(e,this)}:null,l=e=>n.dispatchEvent(new MouseEvent("mousedown",e)),c=e=>n.dispatchEvent(new MouseEvent("mouseup",e)),h=e=>n.dispatchEvent(new MouseEvent("mousemove",e)),u=e=>n.dispatchEvent(new WheelEvent("wheel",e));this._cleanups=[],["units","scale"].forEach((e=>{const t=s.metrics.on("units",(()=>this._update()));this._cleanups.push((()=>s.metrics.off(t)))})),this._drawables=[];const d=(e,t)=>{const s=()=>e.setVisible(t.every((e=>e.get())));t.forEach((e=>e.reg(s))),this._drawables.push(e),this._cleanups.push((()=>e.destroy()))},p=(t,r,n)=>{const p=new sB(s,i,{color:t,thickness:r,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return d(p,n),{setEnds:(e,t)=>p.setEnds(e,t),setColor:e=>p.setColor(e)}};this._lengthWire=p(this._color,2,[this._visible,this._wireVisible]),this._xAxisWire=p("red",1,[this._visible,this._axisEnabled,this._axisVisible,this._xAxisVisible]),this._yAxisWire=p("green",1,[this._visible,this._axisEnabled,this._axisVisible,this._yAxisVisible]),this._zAxisWire=p("blue",1,[this._visible,this._axisEnabled,this._axisVisible,this._zAxisVisible]);const f=(t,r,n)=>{const p=new tB(s,i,{fillColor:t,zIndex:void 0!==e.zIndex?e.zIndex+r:void 0,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return d(p,n),{setFillColor:e=>p.setFillColor(e),setPosOnWire:(e,t,s,i)=>p.setPosOnWire(e,t,s,i),setPosBetween:(e,t,s)=>p.setPosBetween(e,t,s),setText:e=>p.setText(e.replace(/ /g," "))}};this._lengthLabel=f(this._color,4,[this._visible,this._wireVisible,this._labelsVisible,this._clickable,this._axisEnabled,this._lengthLabelEnabled]),this._xAxisLabel=f("red",3,[this._visible,this._axisEnabled,this._axisVisible,this._xAxisVisible,this._labelsVisible,this._clickable,this._xLabelEnabled]),this._yAxisLabel=f("green",3,[this._visible,this._axisEnabled,this._axisVisible,this._yAxisVisible,this._labelsVisible,this._clickable,this._yLabelEnabled]),this._zAxisLabel=f("blue",3,[this._visible,this._axisEnabled,this._axisVisible,this._zAxisVisible,this._labelsVisible,this._clickable,this._zLabelEnabled]);const g=(t,r)=>{const n=new eB(s,t,i,{fillColor:this._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return n.on("worldPos",(()=>this._update())),d(n,r),n};this._originDot=g(t.origin,[this._visible,this._originVisible]),this._targetDot=g(t.target,[this._visible,this._targetVisible]),this._update()}_update(){if(!this._targetDot)return;const e=this._originDot.worldPos,t=this._targetDot.worldPos,s=this._axesBasis,i=R.subVec3(t,e,UB),r=R.transformVec3(s,i,i),n=this._useRotationAdjustment.get()&&Math.abs(i[1])>0,A=(s,i)=>{const r=this.plugin.viewer.scene.metrics,A=r.scale;r.unitsInfo[r.units].abbrev;const o=(s,i,r,n)=>{this._labelsOnWires.get()?s.setPosOnWire(i,r,0,this.plugin.labelMinAxisLength):s.setPosOnWire(e,t,35*n,0)};this._xAxisWire.setEnds(e,s),o(this._xAxisLabel,e,s,1),this._xAxisLabel.setText("X"+this._labelStringFormat(R.distVec3(e,s))),this._yAxisWire.setEnds(s,i),o(this._yAxisLabel,s,i,2),this._yAxisLabel.setText("Y"+this._labelStringFormat(R.distVec3(s,i))),this._zAxisWire.setEnds(i,t),o(this._zAxisLabel,i,t,3),this._zAxisLabel.setText((n?"":"Z")+this._labelStringFormat(R.distVec3(i,t))),this._lengthWire.setEnds(e,t),o(this._lengthLabel,e,t,0);const a=R.distVec3(e,t);this._length=a*A,this._lengthLabel.setText(this._labelStringFormat(a))};n?(TB[0]=e[0],TB[1]=t[1],TB[2]=e[2],A(e,TB)):(IB[0]=e[0]+s[0]*r[0],IB[1]=e[1]+s[4]*r[0],IB[2]=e[2]+s[8]*r[0],TB[0]=IB[0]+s[1]*r[1],TB[1]=IB[1]+s[5]*r[1],TB[2]=IB[2]+s[9]*r[1],A(IB,TB))}set axesBasis(e){this._axesBasis.set(e),this._update()}get axesBasis(){return this._axesBasis}set approximate(e){e=!1!==e,this._approximate!==e&&(this._approximate=e,this._update())}get approximate(){return this._approximate}get origin(){return this._originDot}get target(){return this._targetDot}get length(){return this._length}get color(){return this._color}set color(e){this._color=e,this._originDot.setFillColor(e),this._targetDot.setFillColor(e),this._lengthWire.setColor(e),this._lengthLabel.setFillColor(e)}set visible(e){this._visible.set(e)}get visible(){return this._visible.get()}set originVisible(e){this._originVisible.set(e)}get originVisible(){return this._originVisible.get()}set targetVisible(e){this._targetVisible.set(e)}get targetVisible(){return this._targetVisible.get()}set useRotationAdjustment(e){this._useRotationAdjustment.set(e),this._update()}get useRotationAdjustment(){return this._useRotationAdjustment.get()}set axisEnabled(e){this._axisEnabled.set(e)}get axisEnabled(){return this._axisEnabled.get()}set axisVisible(e){this._axisVisible.set(e)}get axisVisible(){return this._axisVisible.get()}set xAxisVisible(e){this._xAxisVisible.set(e)}get xAxisVisible(){return this._xAxisVisible.get()}set yAxisVisible(e){this._yAxisVisible.set(e)}get yAxisVisible(){return this._yAxisVisible.get()}set zAxisVisible(e){this._zAxisVisible.set(e)}get zAxisVisible(){return this._zAxisVisible.get()}set wireVisible(e){this._wireVisible.set(e)}get wireVisible(){return this._wireVisible.get()}set labelsVisible(e){this._labelsVisible.set(e)}get labelsVisible(){return this._labelsVisible.get()}set xLabelEnabled(e){this._xLabelEnabled.set(e)}get xLabelEnabled(){return this._xLabelEnabled.get()}set yLabelEnabled(e){this._yLabelEnabled.set(e)}get yLabelEnabled(){return this._yLabelEnabled.get()}set zLabelEnabled(e){this._zLabelEnabled.set(e)}get zLabelEnabled(){return this._zLabelEnabled.get()}set lengthLabelEnabled(e){this._lengthLabelEnabled.set(e)}get lengthLabelEnabled(){return this._lengthLabelEnabled.get()}set labelsOnWires(e){this._labelsOnWires.set(e),this._update()}get labelsOnWires(){return this._labelsOnWires.get()}setHighlighted(e){this._drawables.forEach((t=>t.setHighlighted(e)))}set clickable(e){this._clickable.set(!!e),this._drawables.forEach((e=>e.setClickable(this._clickable.get())))}get clickable(){return this._clickable.get()}set labelStringFormat(e){this._labelStringFormat=e,this._update()}get labelStringFormat(){return this._labelStringFormat}destroy(){this._cleanups.forEach((e=>e())),super.destroy()}}class SB extends ie{get active(){}set snapping(e){}get snapping(){return!0}activate(){}deactivate(){}reset(){}get currentMeasurement(){return null}destroy(){}}class DB extends SB{constructor(e,t={}){super(e.viewer.scene),this._canvasToPagePos=t.canvasToPagePos,this.pointerLens=t.pointerLens,this._active=!1,this._currentDistanceMeasurement=null,this._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},this._initMarkerDiv(),this._snapping=!1!==t.snapping,this._mouseState=0,this._attachPlugin(e,t)}_initMarkerDiv(){const e=document.createElement("div"),t=this.scene.canvas.canvas;t.parentNode.insertBefore(e,t),e.style.background="black",e.style.border="2px solid blue",e.style.borderRadius="10px",e.style.width="5px",e.style.height="5px",e.style.top="-200px",e.style.left="-200px",e.style.margin="0 0",e.style.zIndex="100",e.style.position="absolute",e.style.pointerEvents="none",this._markerDiv=e}_destroyMarkerDiv(){this._markerDiv&&(this._markerDiv.parentNode.removeChild(this._markerDiv),this._markerDiv=null)}_attachPlugin(e,t={}){this.distanceMeasurementsPlugin=e,this.plugin=e}get active(){return this._active}set snapping(e){this._snapping=e}get snapping(){return this._snapping}activate(){if(this._active)return;this._markerDiv||this._initMarkerDiv(),this.fire("activated",!0);const e=this.distanceMeasurementsPlugin,t=this.scene,s=e.viewer.cameraControl,i=t.canvas.canvas;t.input;let r=!1;const n=R.vec3(),A=R.vec2();let o,a;let l=null;this._mouseState=0;const c=R.vec2(),h=e=>{const t=e.snappedCanvasPos||e.canvasPos;if(r=!0,n.set(e.worldPos),A.set(e.canvasPos),0===this._mouseState){if(this._canvasToPagePos)this._canvasToPagePos(i,t,c),this._markerDiv.style.left=c[0]-5+"px",this._markerDiv.style.top=c[1]-5+"px";else{const e=R.vec2(t);Jb(i,this._markerDiv.parentNode,e),this._markerDiv.style.left=e[0]-5+"px",this._markerDiv.style.top=e[1]-5+"px"}this._markerDiv.style.background="pink",e.snappedToVertex||e.snappedToEdge?(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,this.pointerLens.snapped=!0),this._markerDiv.style.background="greenyellow",this._markerDiv.style.border="2px solid green"):(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.canvasPos,this.pointerLens.snapped=!1),this._markerDiv.style.background="pink",this._markerDiv.style.border="2px solid red"),l=e.entity}else this._markerDiv.style.left="-10000px",this._markerDiv.style.top="-10000px";i.style.cursor="pointer",this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.wireVisible=this._currentDistanceMeasurementInitState.wireVisible,this._currentDistanceMeasurement.axisVisible=this._currentDistanceMeasurementInitState.axisVisible&&this.distanceMeasurementsPlugin.defaultAxisVisible,this._currentDistanceMeasurement.xAxisVisible=this._currentDistanceMeasurementInitState.xAxisVisible&&this.distanceMeasurementsPlugin.defaultXAxisVisible,this._currentDistanceMeasurement.yAxisVisible=this._currentDistanceMeasurementInitState.yAxisVisible&&this.distanceMeasurementsPlugin.defaultYAxisVisible,this._currentDistanceMeasurement.zAxisVisible=this._currentDistanceMeasurementInitState.zAxisVisible&&this.distanceMeasurementsPlugin.defaultZAxisVisible,this._currentDistanceMeasurement.targetVisible=this._currentDistanceMeasurementInitState.targetVisible,this._currentDistanceMeasurement.target.worldPos=n.slice(),this._markerDiv.style.left="-10000px",this._markerDiv.style.top="-10000px")};this._onHoverSnapOrSurface=s.on("hoverSnapOrSurface",(e=>{this._snapping&&h(e)})),this._onHoverSurface=s.on("hoverSurface",(e=>{this._snapping||h(e)})),i.addEventListener("mousedown",this._onMouseDown=e=>{1===e.which&&(o=e.clientX,a=e.clientY)}),i.addEventListener("mouseup",this._onMouseUp=t=>{1===t.which&&(t.clientX>o+20||t.clientX<o-20||t.clientY>a+20||t.clientY<a-20||(this._currentDistanceMeasurement?r?(this._currentDistanceMeasurement.target.entity=l,l=null,this._currentDistanceMeasurement.clickable=!0,this.distanceMeasurementsPlugin.fire("measurementEnd",this._currentDistanceMeasurement),this._currentDistanceMeasurement=null):(this._currentDistanceMeasurement.destroy(),this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement=null,l=null):r&&(this._currentDistanceMeasurement=e.createMeasurement({id:R.createUUID(),origin:{worldPos:n.slice(),entity:l},target:{worldPos:n.slice(),entity:l},approximate:!0}),this._currentDistanceMeasurementInitState.axisVisible=this._currentDistanceMeasurement.axisVisible&&this.distanceMeasurementsPlugin.defaultAxisVisible,this._currentDistanceMeasurementInitState.xAxisVisible=this._currentDistanceMeasurement.xAxisVisible&&this.distanceMeasurementsPlugin.defaultXAxisVisible,this._currentDistanceMeasurementInitState.yAxisVisible=this._currentDistanceMeasurement.yAxisVisible&&this.distanceMeasurementsPlugin.defaultYAxisVisible,this._currentDistanceMeasurementInitState.zAxisVisible=this._currentDistanceMeasurement.zAxisVisible&&this.distanceMeasurementsPlugin.defaultZAxisVisible,this._currentDistanceMeasurementInitState.wireVisible=this._currentDistanceMeasurement.wireVisible,this._currentDistanceMeasurementInitState.targetVisible=this._currentDistanceMeasurement.targetVisible,this._currentDistanceMeasurement.clickable=!1,this._currentDistanceMeasurement.origin.entity=l,l=null,this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement))))});const u=e=>{this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos),r=!1,this._markerDiv.style.left="-100px",this._markerDiv.style.top="-100px",this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.axisVisible=!1),i.style.cursor="default"};this._onHoverSnapOrSurfaceOff=s.on("hoverSnapOrSurfaceOff",(e=>{this._snapping&&u(e)})),this._onHoverOff=s.on("hoverOff",(e=>{this._snapping||u(e)})),this._active=!0}deactivate(){if(!this._active)return;this.fire("activated",!1),this.pointerLens&&(this.pointerLens.visible=!1),this.reset();const e=this.scene.canvas.canvas;e.removeEventListener("mousedown",this._onMouseDown),e.removeEventListener("mouseup",this._onMouseUp);const t=this.distanceMeasurementsPlugin.viewer.cameraControl;t.off(this._onHoverSnapOrSurface),t.off(this._onHoverSurface),t.off(this._onHoverSnapOrSurfaceOff),t.off(this._onHoverOff),this._active=!1}reset(){this._active&&(this._destroyMarkerDiv(),this._initMarkerDiv(),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._mouseState=0)}get currentMeasurement(){return this._currentDistanceMeasurement}destroy(){this.deactivate(),super.destroy()}}const kB=R.vec2();class QB extends ie{constructor(e,t,s,i){const r=e.plugin.viewer;super(r.scene);const n=AB({viewer:r,handleMouseEvents:s,handleTouchEvents:i,pointerLens:t.pointerLens,dots:[e.origin,e.target],ray2WorldPos:(e,s,i)=>{const n=e=>{const t=r.scene.pick({canvasPos:i,snapToEdge:e,snapToVertex:e,pickSurface:!0});return t&&t.worldPos?t.worldPos:e&&n(!1)};return n(!!t.snapping)},onEnd:(e,t)=>{const s=!R.compareVec3(e,t.worldPos);return s&&this.fire("edited"),s}}),A=e.on("destroyed",n);this._deactivate=function(){e.off("destroyed",A),n()}}deactivate(){this._deactivate(),super.destroy()}}class RB{constructor(e={}){this.cacheBuster=!1!==e.cacheBuster}_cacheBusterURL(e){if(!this.cacheBuster)return e;const t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}getMetaModel(e,t,s){j.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}getGLTF(e,t,s){j.loadArraybuffer(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}getGLB(e,t,s){j.loadArraybuffer(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}getArrayBuffer(e,t,s,i){!function(e,t,s,i){var r=()=>{};s=s||r,i=i||r;const n=/^data:(.*?)(;base64)?,(.*)$/,A=t.match(n);if(A){const e=!!A[2];var o=A[3];o=window.decodeURIComponent(o),e&&(o=window.atob(o));try{const e=new ArrayBuffer(o.length),t=new Uint8Array(e);for(var a=0;a<o.length;a++)t[a]=o.charCodeAt(a);q.scheduleTask((function(){s(e)}))}catch(e){q.scheduleTask((function(){i(e)}))}}else{const r=function(e){var t=e.lastIndexOf("/");return 0!==t?e.substring(0,t+1):""}(e),n=r+t,A=new XMLHttpRequest;A.open("GET",n,!0),A.responseType="arraybuffer",A.onreadystatechange=function(){4===A.readyState&&(200===A.status?s(A.response):i("loadArrayBuffer error : "+A.response))},A.send(null)}}(this._cacheBusterURL(e),t,(e=>{s(e)}),(function(e){i(e)}))}}class OB{constructor(e){}load(e,t,s,i,r,n,A){!function(e,t,s,i,r,n,A){const o=e.viewer.scene.canvas.spinner;o.processes++;"glb"===t.split(".").pop()?e.dataSource.getGLB(t,(a=>{i.basePath=VB(t),LB(e,t,a,s,i,r,n,A),o.processes--}),(e=>{o.processes--,A(e)})):e.dataSource.getGLTF(t,(a=>{i.basePath=VB(t),LB(e,t,a,s,i,r,n,A),o.processes--}),(e=>{o.processes--,A(e)}))}(e,t,s,i=i||{},r,(function(){q.scheduleTask((function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1)})),n&&n()}),(function(t){e.error(t),A&&A(t),r.fire("error",t)}))}parse(e,t,s,i,r,n,A){LB(e,"",t,s,i=i||{},r,(function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1),n&&n()}),(function(e){r.error(e),r.fire("error",e),A&&A(e)}))}}function VB(e){const t=e.lastIndexOf("/");return 0!==t?e.substring(0,t+1):""}function LB(e,t,s,i,r,n,A,o){const a=e.viewer.scene.canvas.spinner;a.processes++,rl(s,hu,{...r.parseOptions||{},baseUri:r.basePath}).then((s=>{const o=function(e,t){return(new yu).postProcess(e,t)}(s),l={src:t,entityId:r.entityId,metaModelJSON:i,autoMetaModel:r.autoMetaModel,globalizeObjectIds:r.globalizeObjectIds,metaObjects:[],loadBuffer:r.loadBuffer,basePath:r.basePath,handlenode:r.handlenode,backfaces:!!r.backfaces,gltfData:o,scene:n.scene,plugin:e,sceneModel:n,numObjects:0,nodes:[],nextId:0,log:t=>{e.log(t)}};!function(e){const t=e.gltfData.textures;if(t)for(let s=0,i=t.length;s<i;s++)HB(e,t[s])}(l),function(e){const t=e.gltfData.materials;if(t)for(let s=0,i=t.length;s<i;s++){const i=t[s];i._textureSetId=NB(e,i),i._attributes=GB(e,i)}}(l),r.autoMetaModel&&l.metaObjects.push({id:n.id,type:"Default",name:n.id}),jB(l),n.finalize(),r.autoMetaModel&&e.viewer.metaScene.createMetaModel(n.id,{metaObjects:l.metaObjects}),a.processes--,A()})).catch((e=>{o&&o(e)}))}function HB(e,t){if(!t.source||!t.source.image)return;const s="texture-"+e.nextId++;let i=1005;switch(t.sampler.minFilter){case 9728:i=1003;break;case 9729:i=1006;break;case 9984:i=1004;break;case 9985:i=1007;break;case 9986:i=1005;break;case 9987:i=1008}let r=1006;switch(t.sampler.magFilter){case 9728:r=1003;break;case 9729:r=1006}let n=1e3;switch(t.sampler.wrapS){case 33071:n=1001;break;case 33648:n=1002;break;case 10497:n=1e3}let A=1e3;switch(t.sampler.wrapT){case 33071:A=1001;break;case 33648:A=1002;break;case 10497:A=1e3}let o=1e3;switch(t.sampler.wrapR){case 33071:o=1001;break;case 33648:o=1002;break;case 10497:o=1e3}e.sceneModel.createTexture({id:s,image:t.source.image,flipY:!!t.flipY,minFilter:i,magFilter:r,wrapS:n,wrapT:A,wrapR:o,encoding:3001}),t._textureId=s}function NB(e,t){const s={};switch(t.normalTexture&&(s.normalTextureId=t.normalTexture.texture._textureId),t.occlusionTexture&&(s.occlusionTextureId=t.occlusionTexture.texture._textureId),t.emissiveTexture&&(s.emissiveTextureId=t.emissiveTexture.texture._textureId),t.alphaMode){case"OPAQUE":break;case"MASK":const e=t.alphaCutoff;s.alphaCutoff=void 0!==e?e:.5}const i=t.pbrMetallicRoughness;if(t.pbrMetallicRoughness){const r=t.pbrMetallicRoughness,n=r.baseColorTexture||r.colorTexture;n&&(n.texture?s.colorTextureId=n.texture._textureId:s.colorTextureId=e.gltfData.textures[n.index]._textureId),i.metallicRoughnessTexture&&(s.metallicRoughnessTextureId=i.metallicRoughnessTexture.texture._textureId)}const r=t.extensions;if(r){const t=r.KHR_materials_pbrSpecularGlossiness;if(t){t.specularTexture;const i=t.specularColorTexture;null!=i&&(s.colorTextureId=e.gltfData.textures[i.index]._textureId)}}return void 0!==s.normalTextureId||void 0!==s.occlusionTextureId||void 0!==s.emissiveTextureId||void 0!==s.colorTextureId||void 0!==s.metallicRoughnessTextureId?(s.id=`textureSet-${e.nextId++};`,e.sceneModel.createTextureSet(s),s.id):null}function GB(e,t){const s=t.extensions,i={color:new Float32Array([1,1,1,1]),opacity:1,metallic:0,roughness:1,doubleSided:!0};if(s){const e=s.KHR_materials_pbrSpecularGlossiness;if(e){const t=e.diffuseFactor;null!=t&&i.color.set(t)}const t=s.KHR_materials_common;if(t){const e=t.technique,s=t.values||{},r="BLINN"===e,n="PHONG"===e,A="LAMBERT"===e,o=s.diffuse;o&&(r||n||A)&&(j.isString(o)||i.color.set(o));const a=s.transparency;null!=a&&(i.opacity=a);const l=s.transparent;null!=l&&(i.opacity=l)}}const r=t.pbrMetallicRoughness;if(r){const e=r.baseColorFactor;e&&(i.color[0]=e[0],i.color[1]=e[1],i.color[2]=e[2],i.opacity=e[3]);const t=r.metallicFactor;null!=t&&(i.metallic=t);const s=r.roughnessFactor;null!=s&&(i.roughness=s)}return i.doubleSided=!1!==t.doubleSided,i}function jB(e){const t=e.gltfData,s=t.scene||t.scenes[0];if(!s)return void function(e,t){e.plugin.error(t)}(e,"glTF has no default scene");const i=s.nodes;if(!i)return;!function e(t){t.forEach((t=>{const s=t.mesh;s&&(s.instances||=0,s.instances+=1),t.children&&e(t.children)}))}(i);const r=[];let n=null;!function t(s,i,A){s.forEach((s=>{const o=s.name;let a=null!=o&&o||0===i&&"entity-"+e.nextId++;if(a){for(;e.sceneModel.objects[a];)a="entity-"+e.nextId++;r.push(n),n=[]}const l=function(e,t){let s;e.matrix&&(s=e.matrix,t=t?R.mulMat4(t,s,R.mat4()):s);e.translation&&(s=R.translationMat4v(e.translation),t=t?R.mulMat4(t,s,R.mat4()):s);e.rotation&&(s=R.quaternionToMat4(e.rotation),t=t?R.mulMat4(t,s,R.mat4()):s);e.scale&&(s=R.scalingMat4v(e.scale),t=t?R.mulMat4(t,s,R.mat4()):s);return t}(s,A);if(s.mesh&&function(e,t,s,i){const r=e.mesh;if(!r)return;const n=r.primitives.length;if(n>0)for(let e=0;e<n;e++){const n=r.primitives[e];if(n.mode<4)continue;const A={id:t.sceneModel.id+"."+t.numObjects++},o=n.material;o?(A.textureSetId=o._textureSetId,A.color=o._attributes.color,A.opacity=o._attributes.opacity,A.metallic=o._attributes.metallic,A.roughness=o._attributes.roughness):(A.color=new Float32Array([1,1,1]),A.opacity=1);const a=!1!==t.backfaces||o&&!1!==o.doubleSided;switch(n.mode){case 0:A.primitive="points";break;case 1:case 2:case 3:A.primitive="lines";break;default:A.primitive=a?"triangles":"solid"}const l=n.attributes.POSITION;if(!l)continue;A.localPositions=l.value,A.positions=new Float64Array(A.localPositions.length),n.attributes.NORMAL&&(A.normals=n.attributes.NORMAL.value),n.attributes.TEXCOORD_0&&(A.uv=n.attributes.TEXCOORD_0.value),n.indices&&(A.indices=n.indices.value),s?R.transformPositions3(s,A.localPositions,A.positions):A.positions.set(A.localPositions);const c=R.vec3();pt(A.positions,A.positions,c)&&(A.origin=c),t.sceneModel.createMesh(A),i.push(A.id)}}(s,e,l,n),s.children&&t(s.children,i+1,l),a){if(n.length>0){const t=e.globalizeObjectIds?R.globalizeObjectId(e.sceneModel.id,a):a;e.sceneModel.createEntity({id:t,meshIds:n,isObject:!0}),e.autoMetaModel&&e.metaObjects.push({id:t,type:"Default",name:t,parent:e.sceneModel.id})}n=r.pop()}}))}(i,0,null)}const WB={DEFAULT:{}};class zB extends mn{constructor(e,t={}){super("GLTFLoader",e,t),this._sceneModelLoader=new OB(this,t),this.dataSource=t.dataSource,this.objectDefaults=t.objectDefaults}set dataSource(e){this._dataSource=e||new RB}get dataSource(){return this._dataSource}set objectDefaults(e){this._objectDefaults=e||WB}get objectDefaults(){return this._objectDefaults}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new jr(this.viewer.scene,j.apply(e,{isModel:!0,dtxEnabled:e.dtxEnabled})),s=t.id;if(!e.src&&!e.gltf)return this.error("load() param expected: src or gltf"),t;if(e.metaModelSrc||e.metaModelJSON){const i=i=>{this.viewer.metaScene.createMetaModel(s,i,{}),this.viewer.scene.canvas.spinner.processes--,e.src?this._sceneModelLoader.load(this,e.src,i,e,t):this._sceneModelLoader.parse(this,e.gltf,i,e,t)};if(e.metaModelSrc){const t=e.metaModelSrc;this.viewer.scene.canvas.spinner.processes++,this._dataSource.getMetaModel(t,(e=>{this.viewer.scene.canvas.spinner.processes--,i(e)}),(e=>{this.error(`load(): Failed to load model metadata for model '${s} from '${t}' - ${e}`),this.viewer.scene.canvas.spinner.processes--}))}else e.metaModelJSON&&i(e.metaModelJSON)}else e.src?this._sceneModelLoader.load(this,e.src,null,e,t):this._sceneModelLoader.parse(this,e.gltf,null,e,t);return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(s)})),t}destroy(){super.destroy()}}function XB(e,t,s={}){const i="lightgrey",r=s.hoverColor||"rgba(0,0,0,0.4)",n=s.textColor||"black",A=s.canvasElement||document.body,o=500,a=o+o/3,l=a/24,c=[{boundary:[6,6,6,6],color:s.frontColor||s.color||"#55FF55"},{boundary:[18,6,6,6],color:s.backColor||s.color||"#55FF55"},{boundary:[12,6,6,6],color:s.rightColor||s.color||"#FF5555"},{boundary:[0,6,6,6],color:s.leftColor||s.color||"#FF5555"},{boundary:[6,0,6,6],color:s.topColor||s.color||"#7777FF"},{boundary:[6,12,6,6],color:s.bottomColor||s.color||"#7777FF"}],h=[{label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,1,0],up:[0,0,1]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,-1,0],up:[0,0,1]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,0,1]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,0,1]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,0,1],up:[0,-1,0]},{boundaries:[[7,5,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,0,-1],up:[1,0,1]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-1,-1],up:[0,-1,1]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,0,-1],up:[-1,0,1]},{boundaries:[[7,11,4,2]],dir:[0,1,1],up:[0,-1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,0,1],up:[-1,0,1]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,-1,1],up:[0,1,1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,0,1],up:[1,0,1]},{boundaries:[[5,7,2,4]],dir:[1,1,0],up:[0,0,1]},{boundaries:[[11,7,2,4]],dir:[-1,1,0],up:[0,0,1]},{boundaries:[[17,7,2,4]],dir:[-1,-1,0],up:[0,0,1]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,-1,0],up:[0,0,1]},{boundaries:[[5,11,2,2]],dir:[1,1,1],up:[-1,-1,1]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[1,-1,1],up:[-1,1,1]},{boundaries:[[5,5,2,2]],dir:[1,1,-1],up:[1,1,1]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-1,-1,1],up:[1,1,1]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-1,-1,-1],up:[-1,-1,1]},{boundaries:[[11,11,2,2]],dir:[-1,1,1],up:[1,-1,1]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[1,-1,-1],up:[1,-1,1]},{boundaries:[[11,5,2,2]],dir:[-1,1,-1],up:[-1,1,1]}];s.frontColor||s.color,s.backColor||s.color,s.rightColor||s.color,s.leftColor||s.color,s.topColor||s.color,s.bottomColor||s.color;const u=[{yUp:"",label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,0,1],up:[0,1,0]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,1,0]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,1,0]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,-1,0],up:[0,0,-1]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,1,0],up:[0,0,1]},{boundaries:[[7,5,4,2]],dir:[0,-.7071,-.7071],up:[0,.7071,-.7071]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,-1,0],up:[1,1,0]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-.7071,.7071],up:[0,.7071,.7071]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,-1,0],up:[-1,1,0]},{boundaries:[[7,11,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,1,0],up:[-1,1,0]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,1,1],up:[0,1,-1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,1,0],up:[1,1,0]},{boundaries:[[5,7,2,4]],dir:[1,0,-1],up:[0,1,0]},{boundaries:[[11,7,2,4]],dir:[-1,0,-1],up:[0,1,0]},{boundaries:[[17,7,2,4]],dir:[-1,0,1],up:[0,1,0]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,0,1],up:[0,1,0]},{boundaries:[[5,11,2,2]],dir:[.5,.7071,-.5],up:[-.5,.7071,.5]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[.5,.7071,.5],up:[-.5,.7071,-.5]},{boundaries:[[5,5,2,2]],dir:[.5,-.7071,-.5],up:[.5,.7071,-.5]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-.5,.7071,.5],up:[.5,.7071,-.5]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-.5,-.7071,.5],up:[-.5,.7071,.5]},{boundaries:[[11,11,2,2]],dir:[-.5,.7071,-.5],up:[.5,.7071,.5]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[.5,-.7071,.5],up:[.5,.7071,.5]},{boundaries:[[11,5,2,2]],dir:[-.5,-.7071,-.5],up:[-.5,.7071,-.5]}];for(let e=0,t=h.length;e<t;e++)R.normalizeVec3(h[e].dir,h[e].dir),R.normalizeVec3(h[e].up,h[e].up);for(let e=0,t=u.length;e<t;e++)R.normalizeVec3(u[e].dir,u[e].dir),R.normalizeVec3(u[e].up,u[e].up);var d=u;this._textureCanvas=document.createElement("canvas"),this._textureCanvas.width=a,this._textureCanvas.height=o,this._textureCanvas.style.width=a+"px",this._textureCanvas.style.height="500px",this._textureCanvas.style.padding="0",this._textureCanvas.style.margin="0",this._textureCanvas.style.top="0",this._textureCanvas.style.background=i,this._textureCanvas.style.position="absolute",this._textureCanvas.style.opacity="1.0",this._textureCanvas.style.visibility="hidden",this._textureCanvas.style["z-index"]=2e6,A.appendChild(this._textureCanvas);const p=this._textureCanvas.getContext("2d");let f=!1;function g(){for(let e=0,t=c.length;e<t;e++){const t=c[e],s=t.boundary,i=Math.round(s[0]*l),r=Math.round(s[1]*l),n=Math.round(s[2]*l),A=Math.round(s[3]*l);p.fillStyle=t.color,p.fillRect(i,r,n,A)}for(let t=0,a=d.length;t<a;t++){let a,c,h,u;const f=d[t],g=f.boundaries;for(var e=0,s=g.length;e<s;e++){const t=g[e];a=Math.round(t[0]*l),c=Math.round(t[1]*l),h=Math.round(t[2]*l),u=Math.round(t[3]*l),f.highlighted&&(p.fillStyle=f.highlighted?r:f.color||i,p.fillRect(a,c,h,u))}if(f.label){p.fillStyle=n,p.font="60px sans-serif",p.textAlign="center";var A=a+.5*h,o=c+.7*u;p.fillText(m(f.label),A,o,80)}}t.glRedraw()}const m=function(){const t={"NavCube.front":"NavCube.front","NavCube.back":"NavCube.back","NavCube.right":"NavCube.right","NavCube.left":"NavCube.left","NavCube.top":"NavCube.top","NavCube.bottom":"NavCube.bottom"},s={"NavCube.front":"NavCube.front","NavCube.back":"NavCube.back","NavCube.right":"NavCube.right","NavCube.left":"NavCube.left","NavCube.top":"NavCube.top","NavCube.bottom":"NavCube.bottom"},i={"NavCube.front":"FRONT","NavCube.back":"BACK","NavCube.right":"RIGHT","NavCube.left":"LEFT","NavCube.top":"TOP","NavCube.bottom":"BOTTOM"};return function(r){const n=f?s:t,A=n?n[r]:null;return A?e.localeService.translate(A)||i[A]||A:r}}();this.setZUp=function(){f=!0,d=h,this.clear()},this.setYUp=function(){f=!1,d=u,this.clear()},this.clear=function(){p.fillStyle=i,p.fillRect(0,0,a,o);for(var e=0,t=d.length;e<t;e++){d[e].highlighted=!1}g()},this.getArea=function(e){const t=e[0]*a,s=o-e[1]*o;for(var i=0,r=d.length;i<r;i++){const e=d[i].boundaries;for(var n=0,A=e.length;n<A;n++){const r=e[n];if(t>=r[0]*l&&t<=(r[0]+r[2])*l&&s>=r[1]*l&&s<=(r[1]+r[3])*l)return i}}return-1},this.setAreaHighlighted=function(e,t){var s=d[e];if(!s)throw"Area not found: "+e;s.highlighted=!!t,g()},this.getAreaDir=function(e){var t=d[e];if(!t)throw"Unknown area: "+e;return t.dir},this.getAreaUp=function(e){var t=d[e];if(!t)throw"Unknown area: "+e;return t.up},this.getImage=function(){return this._textureCanvas},this.destroy=function(){this._textureCanvas&&(this._textureCanvas.parentNode.removeChild(this._textureCanvas),this._textureCanvas=null)}}const KB=R.vec3(),ZB=R.vec3();R.mat4();const JB=R.vec3();class YB{load(e,t,s={}){var i=e.scene.canvas.spinner;i.processes++,$B(e,t,(function(t){!function(e,t,s){for(var i=t.basePath,r=Object.keys(t.materialLibraries),n=r.length,A=0,o=n;A<o;A++)ey(e,i,i+r[A],(function(){0==--n&&s()}))}(e,t,(function(){sy(e,t),i.processes--,q.scheduleTask((function(){e.fire("loaded",!0,!1)}))}))}))}parse(e,t,s,i){if(t){var r=qB(e,t,null);s&&ty(e,s,i),sy(e,r),e.src=null,e.fire("loaded",!0,!1)}else this.warn("load() param expected: objText")}}var $B=function(e,t,s){iy(t,(function(i){var r=qB(e,i,t);s(r)}),(function(t){e.error(t)}))},qB=function(){const e={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /};return function(s,i,r){var n,A,o={src:r=r||"",basePath:(n=r,A=n.lastIndexOf("/"),-1===A?n:n.substring(0,A+1)),objects:[],object:{},positions:[],normals:[],uv:[],materialLibraries:{}};t(o,"",!1),-1!==i.indexOf("\r\n")&&(i=i.replace("\r\n","\n"));for(var a=i.split("\n"),l="",u="",d="",p=[],f="function"==typeof"".trimLeft,g=0,m=a.length;g<m;g++)if(l=a[g],0!==(l=f?l.trimLeft():l.trim()).length&&"#"!==(u=l.charAt(0)))if("v"===u)if(" "===(d=l.charAt(1))&&null!==(p=e.vertex_pattern.exec(l)))o.positions.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3]));else if("n"===d&&null!==(p=e.normal_pattern.exec(l)))o.normals.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3]));else{if("t"!==d||null===(p=e.uv_pattern.exec(l)))return void s.error("Unexpected vertex/normal/uv line: '"+l+"'");o.uv.push(parseFloat(p[1]),parseFloat(p[2]))}else if("f"===u)if(null!==(p=e.face_vertex_uv_normal.exec(l)))c(o,p[1],p[4],p[7],p[10],p[2],p[5],p[8],p[11],p[3],p[6],p[9],p[12]);else if(null!==(p=e.face_vertex_uv.exec(l)))c(o,p[1],p[3],p[5],p[7],p[2],p[4],p[6],p[8]);else if(null!==(p=e.face_vertex_normal.exec(l)))c(o,p[1],p[3],p[5],p[7],void 0,void 0,void 0,void 0,p[2],p[4],p[6],p[8]);else{if(null===(p=e.face_vertex.exec(l)))return void s.error("Unexpected face line: '"+l+"'");c(o,p[1],p[2],p[3],p[4])}else if("l"===u){var _=l.substring(1).trim().split(" "),b=[],B=[];if(-1===l.indexOf("/"))b=_;else for(var y=0,w=_.length;y<w;y++){var v=_[y].split("/");""!==v[0]&&b.push(v[0]),""!==v[1]&&B.push(v[1])}h(o,b,B)}else if(null!==(p=e.object_pattern.exec(l))){t(o,C=p[0].substr(1).trim(),!0)}else if(e.material_use_pattern.test(l)){var C=l.substring(7).trim();o.object.material.id=C}else if(e.material_library_pattern.test(l))o.materialLibraries[l.substring(7).trim()]=!0;else{if(null===(p=e.smoothing_pattern.exec(l))){if("\0"===l)continue;return void s.error("Unexpected line: '"+l+"'")}var M=p[1].trim().toLowerCase();o.object.material.smooth="1"===M||"on"===M}return o};function t(e,t,s){if(e.object&&!1===e.object.fromDeclaration)return e.object.id=t,void(e.object.fromDeclaration=!1!==s);e.object={id:t||"",geometry:{positions:[],normals:[],uv:[]},material:{id:"",smooth:!0},fromDeclaration:!1!==s},e.objects.push(e.object)}function s(e,t){var s=parseInt(e,10);return 3*(s>=0?s-1:s+t/3)}function i(e,t){var s=parseInt(e,10);return 3*(s>=0?s-1:s+t/3)}function r(e,t){var s=parseInt(e,10);return 2*(s>=0?s-1:s+t/2)}function n(e,t,s,i){var r=e.positions,n=e.object.geometry.positions;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[s+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2])}function A(e,t){var s=e.positions,i=e.object.geometry.positions;i.push(s[t+0]),i.push(s[t+1]),i.push(s[t+2])}function o(e,t,s,i){var r=e.normals,n=e.object.geometry.normals;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[s+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2])}function a(e,t,s,i){var r=e.uv,n=e.object.geometry.uv;n.push(r[t+0]),n.push(r[t+1]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[i+0]),n.push(r[i+1])}function l(e,t){var s=e.uv,i=e.object.geometry.uv;i.push(s[t+0]),i.push(s[t+1])}function c(e,t,A,l,c,h,u,d,p,f,g,m,_){var b,B=e.positions.length,y=s(t,B),w=s(A,B),v=s(l,B);if(void 0===c?n(e,y,w,v):(n(e,y,w,b=s(c,B)),n(e,w,v,b)),void 0!==h){var C=e.uv.length;y=r(h,C),w=r(u,C),v=r(d,C),void 0===c?a(e,y,w,v):(a(e,y,w,b=r(p,C)),a(e,w,v,b))}if(void 0!==f){var M=e.normals.length;y=i(f,M),w=f===g?y:i(g,M),v=f===m?y:i(m,M),void 0===c?o(e,y,w,v):(o(e,y,w,b=i(_,M)),o(e,w,v,b))}}function h(e,t,i){e.object.geometry.type="Line";for(var n=e.positions.length,o=e.uv.length,a=0,c=t.length;a<c;a++)A(e,s(t[a],n));for(var h=0,u=i.length;h<u;h++)l(e,r(i[h],o))}}();var ey=function(e,t,s,i){iy(s,(function(s){ty(e,s,t),i()}),(function(t){e.error(t),i()}))},ty=function(){var e=/\s+/;return function(e,r,n){var A,o,a,l,c,h=r.split("\n"),u={id:"Default"},d=!1;n=n||"";for(var p=0;p<h.length;p++)if(0!==(A=h[p].trim()).length&&"#"!==A.charAt(0))switch(a=(a=(o=A.indexOf(" "))>=0?A.substring(0,o):A).toLowerCase(),l=(l=o>=0?A.substring(o+1):"").trim(),a.toLowerCase()){case"newmtl":s(e,u),u={id:l},d=!0;break;case"ka":u.ambient=i(l);break;case"kd":u.diffuse=i(l);break;case"ks":u.specular=i(l);break;case"map_kd":u.diffuseMap||(u.diffuseMap=t(e,n,l,"sRGB"));break;case"map_ks":u.specularMap||(u.specularMap=t(e,n,l,"linear"));break;case"map_bump":case"bump":u.normalMap||(u.normalMap=t(e,n,l));break;case"ns":u.shininess=parseFloat(l);break;case"d":(c=parseFloat(l))<1&&(u.alpha=c,u.alphaMode="blend");break;case"tr":(c=parseFloat(l))>0&&(u.alpha=1-c,u.alphaMode="blend")}d&&s(e,u)};function t(e,t,s,i){var r={},n=s.split(/\s+/),A=n.indexOf("-bm");return A>=0&&n.splice(A,2),(A=n.indexOf("-s"))>=0&&(r.scale=[parseFloat(n[A+1]),parseFloat(n[A+2])],n.splice(A,4)),(A=n.indexOf("-o"))>=0&&(r.translate=[parseFloat(n[A+1]),parseFloat(n[A+2])],n.splice(A,4)),r.src=t+n.join(" ").trim(),r.flipY=!0,r.encoding=i||"linear",new es(e,r).id}function s(e,t){new jt(e,t)}function i(t){var s=t.split(e,3);return[parseFloat(s[0]),parseFloat(s[1]),parseFloat(s[2])]}}();function sy(e,t){for(var s=0,i=t.objects.length;s<i;s++){var r=t.objects[s],n=r.geometry;if(n.type,0===n.positions.length)continue;var A={primitive:"triangles",compressGeometry:!1};A.positions=n.positions,n.normals.length>0&&(A.normals=n.normals),n.uv.length>0&&(A.uv=n.uv);for(var o=new Array(A.positions.length/3),a=0;a<o.length;a++)o[a]=a;A.indices=o;const i=JB;pt(n.positions,n.positions,i);var l,c=new Le(e,A),h=r.material.id;h&&""!==h?(l=e.scene.components[h])||e.error("Material not found: "+h):l=new jt(e,{diffuse:[.6,.6,.6],backfaces:!0});var u=new Ot(e,{id:e.id+"#"+r.id,origin:0!==i[0]||0!==i[1]||0!==i[2]?i:null,isObject:!0,geometry:c,material:l,pickable:!0});e.addChild(u)}}function iy(e,t,s){var i=new XMLHttpRequest;i.open("GET",e,!0),i.addEventListener("load",(function(e){var i=e.target.response;200===this.status?t&&t(i):0===this.status?(console.warn("loadFile: HTTP Status 0 received."),t&&t(i)):s&&s(e)}),!1),i.addEventListener("error",(function(e){s&&s(e)}),!1),i.send(null)}class ry{constructor(e){const t=e.cameraControl,s=e.scene,i=s.canvas.canvas,r=!1,n=.09,A=.01,o=new ct(s,{position:[0,0,0],scale:[5,5,5],isObject:!1}),a=R.vec3();this._setPosition=function(){const e=R.vec3(),t=R.vec3();return function(s){a.set(s),dt(s,e,t),o.origin=e,o.position=t}}(),this._setQuaternion=e=>{o.quaternion=e};const l=(e,t)=>new Le(o,Xe({radiusTop:.001,radiusBottom:e,radialSegments:32,heightSegments:1,height:t,openEnded:!1})),c=(e,t,s)=>new Le(o,Xe({radiusTop:e,radiusBottom:e,radialSegments:s,heightSegments:1,height:t,openEnded:!1})),h=(e,t,s)=>new Le(o,Ye({radius:.8,tube:e,radialSegments:64,tubeSegments:s,arc:2*Math.PI*t})),u={curve:h(A,.25,14),curveHandle:h(n,.25,14),hoop:h(A,1,8),arrowHead:l(.07,.2),arrowHeadBig:l(.09,.25),arrowHeadHandle:c(n,.37,8),axis:c(A,1,20),axisHandle:c(n,1,20)},d=(e,t)=>new ds(o,{edges:!1,fill:!0,fillColor:e,fillAlpha:t}),p=new jt(o,{diffuse:[1,1,0],alpha:0,alphaMode:"blend"}),f={},g=(e,t)=>{R.mulVec3Scalar(e,-1,R.vec3());const n=(e=>new jt(o,{diffuse:e,emissive:e,ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}))(e),A=R.quaternionToRotationMat4(t,R.identityMat4());R.mulMat4(R.rotationMat4v(Math.PI,[0,1,0],R.mat4()),A,A);const l=R.scaleMat4v([.6,.6,.6],R.identityMat4()),c=(e,t)=>{const s=R.translateMat4v(e,R.identityMat4()),i=R.identityMat4();return R.mulMat4(s,t,i),R.mulMat4(A,i,i),R.mulMat4(i,l,R.identityMat4())},h=o.addChild(new Ot(o,{geometry:u.curve,material:n,matrix:A,pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isUI:!0,isObject:!1}),r),g=o.addChild(new Ot(o,{geometry:u.curveHandle,material:p,matrix:A,pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isUI:!0,isObject:!1}),r),m=o.addChild(new Ot(o,{geometry:u.arrowHead,material:n,matrix:c([.8,.07,0],R.rotationMat4v(180*R.DEGTORAD,[0,0,1],R.identityMat4())),pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),_=o.addChild(new Ot(o,{geometry:u.arrowHead,material:n,matrix:c([.07,.8,0],R.rotationMat4v(90*R.DEGTORAD,[0,0,1],R.identityMat4())),pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),b=o.addChild(new Ot(o,{geometry:u.hoop,material:n,highlighted:!0,highlightMaterial:d(e,.6),matrix:A,pickable:!1,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),B=R.quaternionToRotationMat4(R.vec3PairToQuaternion([0,1,0],e),R.identityMat4());R.mulMat4(R.rotationMat4v(Math.PI,[0,1,0],R.mat4()),B,B);const y=e=>R.mulMat4(B,R.translateMat4c(0,e,0,R.identityMat4()),R.identityMat4()),w=y(1.1),v=y(.5),C=o.addChild(new Ot(o,{geometry:u.arrowHead,material:n,matrix:w,pickable:!1,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),M=o.addChild(new Ot(o,{geometry:u.arrowHeadHandle,material:p,matrix:w,pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),E=o.addChild(new Ot(o,{geometry:u.axis,material:n,matrix:v,pickable:!1,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),F=o.addChild(new Ot(o,{geometry:u.axisHandle,material:p,matrix:v,pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),x=o.addChild(new Ot(o,{geometry:u.arrowHeadBig,material:n,matrix:w,pickable:!1,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),U=(e,t)=>R.vec3ApplyQuaternion(o.quaternion,e,t),I=function(){const t=R.vec3(),r=R.vec3(),n=R.vec3();return(A,o)=>{U(e,t);const l=a,c=t;R.canvasPosToWorldRay(i,s.camera.viewMatrix,s.camera.projMatrix,s.camera.projection,A,r,n);const h=R.dotVec3(c,n),u=R.subVec3(r,l,o),d=R.dotVec3(u,c),p=R.dotVec3(u,n),f=1-h*h;if(Math.abs(f)>1e-10){const e=(d-h*p)/f;return R.addVec3(l,R.mulVec3Scalar(c,e,o),o),!0}return!1}}(),T=R.vec3(),P=R.vec3();f[M.id]=f[F.id]={setActivated:e=>x.visible=e,initDragAction:e=>I(e,T)&&R.subVec3(T,a,T)&&(e=>{I(e,P)&&(R.subVec3(P,T,P),this._setPosition(P),this._handlers&&this._handlers.onPosition(P))})},f[g.id]={setActivated:e=>b.visible=e,initDragAction:t=>{const i=function(){const t=s.camera.projectWorldPos(a);U(e,P),R.transformVec3(s.camera.normalMatrix,P,P);const i=Math.sign(P[2]);return e=>{const s=e[0]-t[0],r=e[1]-t[1];return i*Math.atan2(-r,s)}}();let r=i(t);return t=>{const s=i(t);o.rotate(e,180*(s-r)/Math.PI),this._handlers&&this._handlers.onQuaternion(o.quaternion),r=s}}};let S=!1,D=!1,k=!1;const Q=()=>{const e=k&&S;M.visible=F.visible=C.visible=E.visible=!!e,e||(x.visible=!1)},O=()=>{const e=k&&D;g.visible=h.visible=m.visible=_.visible=!!e,e||(b.visible=!1)};return{setPositionActive:e=>{S=e,Q()},setRotationActive:e=>{D=e,O()},set visible(e){k=e,Q(),O()}}};this._displayMeshes={center:o.addChild(new Ot(o,{geometry:new Le(o,Je({radius:.05})),material:new jt(o,{diffuse:[0,0,0],emissive:[0,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80}),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),r),x:g([1,0,0],R.vec3PairToQuaternion([1,0,0],[0,0,1])),y:g([0,1,0],R.eulerToQuaternion([90,0,0],"XYZ")),z:g([0,0,1],R.identityQuaternion())};const m=[];{let e=-1;const t=e=>{o.scale[0]!==e&&(o.scale=[e,e,e],this._handlers&&this._handlers.onScreenScale&&this._handlers.onScreenScale(o.scale))},i=s.on("tick",(()=>{const i=s.camera,r=Math.abs(R.distVec3(i.eye,a));"perspective"===i.projection?r!==e&&t(.07*r*Math.tan(i.perspective.fov*R.DEGTORAD)):"ortho"===i.projection&&t(i.ortho.scale/10),e=r}));m.push((()=>s.off(i)))}{let e=null,r=null;m.push((()=>{r&&r.cleanup()}));const n=R.vec2(),A=(e,t)=>{t[0]=e.pageX,t[1]=e.pageY,Jb(i.ownerDocument.documentElement,i,t)},o=e=>{A(e,n);const t=s.pick({canvasPos:n}),i=t&&t.entity,r=i&&i.id;return r in f&&f[r]},a=(e,s)=>{const i=o(s(e));if(i){r&&r.cleanup();const e=i.initDragAction(n);return e&&(t.pointerEnabled=!1,i.setActivated(!0),r={onChange:t=>{const i=s(t);i&&(A(i,n),e(n))},cleanup:function(){r=null,t.pointerEnabled=!0,i.setActivated(!1)}}),!!e}return!1},l=(e,t)=>{i.addEventListener(e,t),m.push((()=>i.removeEventListener(e,t)))},c=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()};l("mousedown",(e=>{1===e.which&&a(e,(e=>1===e.which&&e))&&c(e)})),l("mousemove",(t=>{if(r)r.onChange(t),c(t);else{e&&e();const s=o(t);s?(s.setActivated(!0),e=()=>s.setActivated(!1)):e=null}})),l("mouseup",(e=>{r&&(r.onChange(e),r.cleanup())})),l("touchstart",(e=>{if(e.preventDefault(),1===e.touches.length){const t=e.touches[0].identifier;a(e,(e=>[...e.changedTouches].find((e=>e.identifier===t))))&&c(e)}})),l("touchmove",(e=>{r&&(r.onChange(e),c(e))})),l("touchend",(e=>{r&&(r.onChange(e),r.cleanup())}))}this.__destroy=()=>{m.forEach((e=>e())),o.destroy();for(let e in f)delete f[e]}}destroy(){this.__destroy()}setHandlers(e){Object.values(this._displayMeshes).forEach((t=>t.visible=!!e)),this._handlers=e,this._displayMeshes.x.setPositionActive(e&&e.onPosition),this._displayMeshes.y.setPositionActive(e&&e.onPosition),this._displayMeshes.z.setPositionActive(e&&e.onPosition),this._displayMeshes.x.setRotationActive(e&&e.onQuaternion),this._displayMeshes.y.setRotationActive(e&&e.onQuaternion),this._displayMeshes.z.setRotationActive(e&&e.onQuaternion)}setPosition(e){this._setPosition(e)}setQuaternion(e){this._setQuaternion(e)}}class ny{constructor(e,t,s){this.id=s.id,this._sectionPlane=s,this._mesh=new Ot(t,{id:s.id,geometry:new Le(t,We({xSize:.5,ySize:.5,zSize:.001})),material:new jt(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new fs(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new ds(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new ds(t,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});{const e=R.vec3([0,0,0]),t=R.vec3(),s=R.vec3([0,0,1]),i=R.vec4(4),r=R.vec3(),n=()=>{const n=this._sectionPlane.scene.center,A=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];R.subVec3(n,this._sectionPlane.pos,e);const o=-R.dotVec3(A,e);R.normalizeVec3(A),R.mulVec3Scalar(A,o,t);const a=R.vec3PairToQuaternion(s,this._sectionPlane.dir,i);r[0]=.1*t[0],r[1]=.1*t[1],r[2]=.1*t[2],this._mesh.quaternion=a,this._mesh.position=r};this._onSectionPlanePos=this._sectionPlane.on("pos",n),this._onSectionPlaneDir=this._sectionPlane.on("dir",n)}this._highlighted=!1,this._selected=!1}setHighlighted(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}getHighlighted(){return this._highlighted}setSelected(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}getSelected(){return this._selected}destroy(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}class Ay{constructor(e,t){if(!(t.onHoverEnterPlane&&t.onHoverLeavePlane&&t.onClickedNothing&&t.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=e,this._viewer=e.viewer,this._onHoverEnterPlane=t.onHoverEnterPlane,this._onHoverLeavePlane=t.onHoverLeavePlane,this._onClickedNothing=t.onClickedNothing,this._onClickedPlane=t.onClickedPlane,this._visible=!0,this._planes={},this._canvas=t.overviewCanvas,this._scene=new gA(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new Zr(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Zr(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Zr(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;{const e=this._scene.camera,t=R.rotationMat4c(-90*R.DEGTORAD,1,0,0),s=R.vec3(),i=R.vec3(),r=R.vec3();this._synchCamera=()=>{const n=this._viewer.camera.eye,A=this._viewer.camera.look,o=this._viewer.camera.up;R.mulVec3Scalar(R.normalizeVec3(R.subVec3(n,A,s)),7),this._zUp?(R.transformVec3(t,s,i),R.transformVec3(t,o,r),e.look=[0,0,0],e.eye=R.transformVec3(t,s,i),e.up=R.transformPoint3(t,o,r)):(e.look=[0,0,0],e.eye=s,e.up=o)}}this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(e=>{this._scene.camera.perspective.fov=e}));var s=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!s||t.entity.id!==s.id){if(s){this._planes[s.id]&&this._onHoverLeavePlane(s.id)}s=t.entity;this._planes[s.id]&&this._onHoverEnterPlane(s.id)}}else s&&(this._onHoverLeavePlane(s.id),s=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(s){this._planes[s.id]&&this._onClickedPlane(s.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{s&&(this._onHoverLeavePlane(s.id),s=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new ny(this,this._scene,e)}setPlaneHighlighted(e,t){const s=this._planes[e];s&&s.setHighlighted(t)}setPlaneSelected(e,t){const s=this._planes[e];s&&s.setSelected(t)}removeSectionPlane(e){const t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}setVisible(e=!0){this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}getVisible(){return this._visible}destroy(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}const oy=R.AABB3(),ay=R.vec3();class ly{constructor(e,t,s,i,r,n){this.plugin=e,this.storeyId=r,this.modelId=i,this.storeyAABB=s.slice(),this.aabb=this.storeyAABB,this.modelAABB=t.slice(),this.numObjects=n}}class cy{constructor(e,t,s,i,r,n){this.storeyId=e,this.imageData=t,this.format=s,this.width=i,this.height=r}}const hy=R.vec3(),uy=R.mat4();const dy=new Float64Array([0,0,1]),py=new Float64Array(4);class fy{constructor(e){this.id=null,this._viewer=e.viewer,this._plugin=e,this._visible=!1,this._pos=R.vec3(),this._origin=R.vec3(),this._rtcPos=R.vec3(),this._baseDir=R.vec3(),this._rootNode=null,this._displayMeshes=null,this._affordanceMeshes=null,this._ignoreNextSectionPlaneDirUpdate=!1,this._createNodes(),this._bindEvents()}_setSectionPlane(e){this._sectionPlane&&(this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._onSectionPlanePos=null,this._onSectionPlaneDir=null,this._sectionPlane=null),e&&(this.id=e.id,this._setPos(e.pos),this._setDir(e.dir),this._sectionPlane=e,this._onSectionPlanePos=e.on("pos",(()=>{this._setPos(this._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(()=>{this._ignoreNextSectionPlaneDirUpdate?this._ignoreNextSectionPlaneDirUpdate=!1:this._setDir(this._sectionPlane.dir)})))}get sectionPlane(){return this._sectionPlane}_setPos(e){this._pos.set(e),dt(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}_setDir(e){this._baseDir.set(e),this._rootNode.quaternion=R.vec3PairToQuaternion(dy,e,py)}_setSectionPlaneDir(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}setVisible(e=!0){if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}getVisible(){return this._visible}setCulled(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}_createNodes(){const e=!1,t=this._viewer.scene,s=.01;this._rootNode=new ct(t,{position:[0,0,0],scale:[5,5,5]});const i=this._rootNode,r={arrowHead:new Le(i,Xe({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Le(i,Xe({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),axis:new Le(i,Xe({radiusTop:s,radiusBottom:s,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},n={red:new jt(i,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),green:new jt(i,{diffuse:[0,1,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),blue:new jt(i,{diffuse:[0,0,1],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new ds(i,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6})};this._displayMeshes={plane:i.addChild(new Ot(i,{geometry:new Le(i,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new jt(i,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1]}),e),planeFrame:i.addChild(new Ot(i,{geometry:new Le(i,Ye({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new jt(i,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45]}),e),center:i.addChild(new Ot(i,{geometry:new Le(i,Je({radius:.05})),material:n.center,pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zAxisArrow:i.addChild(new Ot(i,{geometry:r.arrowHead,material:n.blue,matrix:function(){const e=R.translateMat4c(0,1.1,0,R.identityMat4()),t=R.rotationMat4v(-90*R.DEGTORAD,[.8,0,0],R.identityMat4());return R.mulMat4(t,e,R.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zShaft:i.addChild(new Ot(i,{geometry:r.axis,material:n.blue,matrix:function(){const e=R.translateMat4c(0,.5,0,R.identityMat4()),t=R.rotationMat4v(-90*R.DEGTORAD,[1,0,0],R.identityMat4());return R.mulMat4(t,e,R.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1}),e)},this._affordanceMeshes={planeFrame:i.addChild(new Ot(i,{geometry:new Le(i,Ye({center:[0,0,0],radius:2,tube:s,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new jt(i,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new ds(i,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45]}),e),zAxisArrow:i.addChild(new Ot(i,{geometry:r.arrowHeadBig,material:n.blue,matrix:function(){const e=R.translateMat4c(0,1.1,0,R.identityMat4()),t=R.rotationMat4v(-90*R.DEGTORAD,[.8,0,0],R.identityMat4());return R.mulMat4(t,e,R.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e)}}_bindEvents(){const e=this._rootNode,t=R.vec2(),s=this._viewer.camera,i=this._viewer.scene;let r=0,n=!1;{const t=R.vec3([0,0,0]);let A=-1;this._onCameraViewMatrix=i.camera.on("viewMatrix",(()=>{})),this._onCameraProjMatrix=i.camera.on("projMatrix",(()=>{})),this._onSceneTick=i.on("tick",(()=>{n=!1;const a=Math.abs(R.lenVec3(R.subVec3(i.camera.eye,this._pos,t)));if(a!==A&&"perspective"===s.projection){const t=.07*(Math.tan(s.perspective.fov*R.DEGTORAD)*a);e.scale=[t,t,t],A=a}if("ortho"===s.projection){const t=s.ortho.scale/10;e.scale=[t,t,t],A=a}0!==r&&(o(r),r=0)}))}const A=function(){const e=new Float64Array(2);return function(t){if(t){for(var s=t.target,i=0,r=0;s.offsetParent;)i+=s.offsetLeft,r+=s.offsetTop,s=s.offsetParent;e[0]=t.pageX-i,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),o=e=>{const t=this._sectionPlane.pos,s=this._sectionPlane.dir;R.addVec3(t,R.mulVec3Scalar(s,.1*e*this._plugin.getDragSensitivity(),R.vec3())),this._sectionPlane.pos=t};{let e=!1;this._plugin._controlElement.addEventListener("mousedown",this._canvasMouseDownListener=s=>{if(s.preventDefault(),this._visible&&(this._viewer.cameraControl.pointerEnabled=!1,1===s.which)){e=!0;var i=A(s);t[0]=i[0],t[1]=i[1]}}),this._plugin._controlElement.addEventListener("mousemove",this._canvasMouseMoveListener=s=>{if(!this._visible)return;if(!e)return;if(n)return;var i=A(s);const r=i[0],a=i[1];o(a-t[1]),t[0]=r,t[1]=a}),this._plugin._controlElement.addEventListener("mouseup",this._canvasMouseUpListener=t=>{this._visible&&(this._viewer.cameraControl.pointerEnabled=!0,e&&(t.which,e=!1))}),this._plugin._controlElement.addEventListener("wheel",this._canvasWheelListener=e=>{this._visible&&(r+=Math.max(-1,Math.min(1,40*-e.deltaY)))})}{let e,t,s=null;this._plugin._controlElement.addEventListener("touchstart",this._handleTouchStart=t=>{t.stopPropagation(),t.preventDefault(),this._visible&&(e=t.touches[0].clientY,s=e,r=0)}),this._plugin._controlElement.addEventListener("touchmove",this._handleTouchMove=e=>{e.stopPropagation(),e.preventDefault(),this._visible&&(n||(n=!0,t=e.touches[0].clientY,null!==s&&(r+=t-s),s=t))}),this._plugin._controlElement.addEventListener("touchend",this._handleTouchEnd=s=>{s.stopPropagation(),s.preventDefault(),this._visible&&(e=null,t=null,r=0)})}}_destroy(){this._unbindEvents(),this._destroyNodes()}_unbindEvents(){const e=this._viewer,t=e.scene,s=t.canvas.canvas,i=e.camera,r=this._plugin._controlElement;t.off(this._onSceneTick),s.removeEventListener("mousedown",this._canvasMouseDownListener),s.removeEventListener("mousemove",this._canvasMouseMoveListener),s.removeEventListener("mouseup",this._canvasMouseUpListener),s.removeEventListener("wheel",this._canvasWheelListener),r.removeEventListener("touchstart",this._handleTouchStart),r.removeEventListener("touchmove",this._handleTouchMove),r.removeEventListener("touchend",this._handleTouchEnd),i.off(this._onCameraViewMatrix),i.off(this._onCameraProjMatrix)}_destroyNodes(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}class gy{constructor(e,t,s){this.id=s.id,this._sectionPlane=s,this._mesh=new Ot(t,{id:s.id,geometry:new Le(t,We({xSize:.5,ySize:.5,zSize:.001})),material:new jt(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new fs(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new ds(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new ds(t,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});{const e=R.vec3([0,0,0]),t=R.vec3(),s=R.vec3([0,0,1]),i=R.vec4(4),r=R.vec3(),n=()=>{const n=this._sectionPlane.scene.center,A=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];R.subVec3(n,this._sectionPlane.pos,e);const o=-R.dotVec3(A,e);R.normalizeVec3(A),R.mulVec3Scalar(A,o,t);const a=R.vec3PairToQuaternion(s,this._sectionPlane.dir,i);r[0]=.1*t[0],r[1]=.1*t[1],r[2]=.1*t[2],this._mesh.quaternion=a,this._mesh.position=r};this._onSectionPlanePos=this._sectionPlane.on("pos",n),this._onSectionPlaneDir=this._sectionPlane.on("dir",n)}this._highlighted=!1,this._selected=!1}setHighlighted(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}getHighlighted(){return this._highlighted}setSelected(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}getSelected(){return this._selected}destroy(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}class my{constructor(e,t){if(!(t.onHoverEnterPlane&&t.onHoverLeavePlane&&t.onClickedNothing&&t.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=e,this._viewer=e.viewer,this._onHoverEnterPlane=t.onHoverEnterPlane,this._onHoverLeavePlane=t.onHoverLeavePlane,this._onClickedNothing=t.onClickedNothing,this._onClickedPlane=t.onClickedPlane,this._visible=!0,this._planes={},this._canvas=t.overviewCanvas,this._scene=new gA(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new Zr(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Zr(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Zr(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;{const e=this._scene.camera,t=R.rotationMat4c(-90*R.DEGTORAD,1,0,0),s=R.vec3(),i=R.vec3(),r=R.vec3();this._synchCamera=()=>{const n=this._viewer.camera.eye,A=this._viewer.camera.look,o=this._viewer.camera.up;R.mulVec3Scalar(R.normalizeVec3(R.subVec3(n,A,s)),7),this._zUp?(R.transformVec3(t,s,i),R.transformVec3(t,o,r),e.look=[0,0,0],e.eye=R.transformVec3(t,s,i),e.up=R.transformPoint3(t,o,r)):(e.look=[0,0,0],e.eye=s,e.up=o)}}this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(e=>{this._scene.camera.perspective.fov=e}));var s=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!s||t.entity.id!==s.id){if(s){this._planes[s.id]&&this._onHoverLeavePlane(s.id)}s=t.entity;this._planes[s.id]&&this._onHoverEnterPlane(s.id)}}else s&&(this._onHoverLeavePlane(s.id),s=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(s){this._planes[s.id]&&this._onClickedPlane(s.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{s&&(this._onHoverLeavePlane(s.id),s=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new gy(this,this._scene,e)}setPlaneHighlighted(e,t){const s=this._planes[e];s&&s.setHighlighted(t)}setPlaneSelected(e,t){const s=this._planes[e];s&&s.setSelected(t)}removeSectionPlane(e){const t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}setVisible(e=!0){this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}getVisible(){return this._visible}destroy(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}const _y=R.AABB3(),by=R.vec3();class By{constructor(e={}){this.cacheBuster=!1!==e.cacheBuster}_cacheBusterURL(e){if(!this.cacheBuster)return e;const t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}getSTL(e,t,s){e=this._cacheBusterURL(e);const i=new XMLHttpRequest;i.overrideMimeType("application/json"),i.open("GET",e,!0),i.responseType="arraybuffer",i.onreadystatechange=function(){4===i.readyState&&(200===i.status?t(i.response):s(i.statusText))},i.send(null)}}const yy=R.vec3();class wy{load(e,t,s,i,r,n){i=i||{};const A=e.viewer.scene.canvas.spinner;A.processes++,e.dataSource.getSTL(s,(function(s){!function(e,t,s,i){try{const r=xy(s);vy(r)?Cy(e,r,t,i):My(e,Fy(s),t,i)}catch(e){t.fire("error",e)}}(e,t,s,i);try{const n=xy(s);vy(n)?Cy(e,n,t,i):My(e,Fy(s),t,i),A.processes--,q.scheduleTask((function(){t.fire("loaded",!0,!1)})),r&&r()}catch(s){A.processes--,e.error(s),n&&n(s),t.fire("error",s)}}),(function(s){A.processes--,e.error(s),n&&n(s),t.fire("error",s)}))}parse(e,t,s,i){const r=e.viewer.scene.canvas.spinner;r.processes++;try{const n=xy(s);vy(n)?Cy(e,n,t,i):My(e,Fy(s),t,i),r.processes--,q.scheduleTask((function(){t.fire("loaded",!0,!1)}))}catch(e){r.processes--,t.fire("error",e)}}}function vy(e){const t=new DataView(e);if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;const s=[115,111,108,105,100];for(var i=0;i<5;i++)if(s[i]!==t.getUint8(i,!1))return!0;return!1}function Cy(e,t,s,i){const r=new DataView(t),n=r.getUint32(80,!0);let A,o,a,l,c,h,u,d=!1,p=null,f=null,g=null,m=!1;for(let e=0;e<70;e++)1129270351===r.getUint32(e,!1)&&82===r.getUint8(e+4)&&61===r.getUint8(e+5)&&(d=!0,l=[],c=r.getUint8(e+6)/255,h=r.getUint8(e+7)/255,u=r.getUint8(e+8)/255,r.getUint8(e+9));const _=new as(s,{roughness:.5});let b=[],B=[],y=i.splitMeshes;for(let e=0;e<n;e++){let t=84+50*e,n=r.getFloat32(t,!0),w=r.getFloat32(t+4,!0),v=r.getFloat32(t+8,!0);if(d){let e=r.getUint16(t+48,!0);0==(32768&e)?(A=(31&e)/31,o=(e>>5&31)/31,a=(e>>10&31)/31):(A=c,o=h,a=u),(y&&A!==p||o!==f||a!==g)&&(null!==p&&(m=!0),p=A,f=o,g=a)}for(let e=1;e<=3;e++){let s=t+12*e;b.push(r.getFloat32(s,!0)),b.push(r.getFloat32(s+4,!0)),b.push(r.getFloat32(s+8,!0)),B.push(n,w,v),d&&l.push(A,o,a,1)}y&&m&&(Ey(s,b,B,l,_,i),b=[],B=[],l=l?[]:null,m=!1)}b.length>0&&Ey(s,b,B,l,_,i)}function My(e,t,s,i){const r=/facet([\s\S]*?)endfacet/g;let n=0;const A=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,o=new RegExp("vertex"+A+A+A,"g"),a=new RegExp("normal"+A+A+A,"g"),l=[],c=[];let h,u,d,p,f,g,m;for(;null!==(p=r.exec(t));){for(f=0,g=0,m=p[0];null!==(p=a.exec(m));)h=parseFloat(p[1]),u=parseFloat(p[2]),d=parseFloat(p[3]),g++;for(;null!==(p=o.exec(m));)l.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),c.push(h,u,d),f++;1!==g&&e.error("Error in normal of face "+n),3!==f&&e.error("Error in positions of face "+n),n++}Ey(s,l,c,null,new as(s,{roughness:.5}),i)}function Ey(e,t,s,i,r,n){const A=new Int32Array(t.length/3);for(let e=0,t=A.length;e<t;e++)A[e]=e;s=s&&s.length>0?s:null,i=i&&i.length>0?i:null,n.smoothNormals&&R.faceToVertexNormals(t,s,n);const o=yy;pt(t,t,o);const a=new Le(e,{primitive:"triangles",positions:t,normals:s,colors:i,indices:A}),l=new Ot(e,{origin:0!==o[0]||0!==o[1]||0!==o[2]?o:null,geometry:a,material:r,edges:n.edges});e.addChild(l)}function Fy(e){return"string"!=typeof e?function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let s=0,i=e.length;s<i;s++)t+=String.fromCharCode(e[s]);return decodeURIComponent(escape(t))}(new Uint8Array(e)):e}function xy(e){if("string"==typeof e){const t=new Uint8Array(e.length);for(let s=0;s<e.length;s++)t[s]=255&e.charCodeAt(s);return t.buffer||t}return e}class Uy{constructor(e){this._treeViewContainer=e}createRootNode(){return document.createElement("ul")}createNodeElement(e,t,s,i,r){const n=document.createElement("li");if(n.id=e.nodeId,e.xrayed&&n.classList.add("xrayed-node"),e.children.length>0){const s=document.createElement("a");s.href="#",s.id=`switch-${e.nodeId}`,s.textContent="+",s.classList.add("plus"),t&&s.addEventListener("click",t),n.appendChild(s)}const A=document.createElement("input");A.id=`checkbox-${e.nodeId}`,A.type="checkbox",A.checked=e.checked,A.style["pointer-events"]="all",s&&A.addEventListener("change",s),n.appendChild(A);const o=document.createElement("span");return o.textContent=e.title,n.appendChild(o),i&&Pb(o,i),r&&(o.onclick=r),n}createDisabledNodeElement(e){const t=document.createElement("li"),s=document.createElement("a");s.href="#",s.textContent="!",s.classList.add("warn"),s.classList.add("warning"),t.appendChild(s);const i=document.createElement("span");return i.textContent=e,t.appendChild(i),t}addChildren(e,t){const s=document.createElement("ul");t.forEach((e=>{s.appendChild(e)})),e.parentElement.appendChild(s)}expand(e,t,s){e.classList.remove("plus"),e.classList.add("minus"),e.textContent="-",e.removeEventListener("click",t),e.addEventListener("click",s)}collapse(e,t,s){if(!e)return;const i=e.parentElement;if(!i)return;const r=i.querySelector("ul");r&&(i.removeChild(r),e.classList.remove("minus"),e.classList.add("plus"),e.textContent="+",e.removeEventListener("click",s),e.addEventListener("click",t))}isExpanded(e){return void 0!==e.parentElement.getElementsByTagName("li")[0]}getId(e){return e.parentElement.id}getIdFromCheckbox(e){return e.id.replace("checkbox-","")}getSwitchElement(e){return this._treeViewContainer.querySelector(`[id="switch-${e}"]`)}isChecked(e){return e.checked}setCheckbox(e,t,s=!1){const i=this._treeViewContainer.querySelector(`[id="checkbox-${e}"]`);i&&(t!==i.checked&&(i.checked=t),s!==i.indeterminate&&(i.indeterminate=s,s&&(i.checked=!1)))}setXRayed(e,t){const s=this._treeViewContainer.querySelector(`[id="${e}"]`);s&&(t?s.classList.add("xrayed-node"):s.classList.remove("xrayed-node"))}setHighlighted(e,t){const s=this._treeViewContainer.querySelector(`[id="${e}"]`);s&&(t?(s.scrollIntoView({block:"center"}),s.classList.add("highlighted-node")):s.classList.remove("highlighted-node"))}}const Iy=[];class Ty{constructor(e){this._scene=e,this._objects=[],this._objectsViewCulled=[],this._objectsDetailCulled=[],this._objectsChanged=[],this._objectsChangedList=[],this._modelInfos={},this._numObjects=0,this._lenObjectsChangedList=0,this._dirty=!0,this._onModelLoaded=e.on("modelLoaded",(t=>{const s=e.models[t];s&&this._addModel(s)})),this._onTick=e.on("tick",(()=>{this._dirty&&this._build(),this._applyChanges()}))}_addModel(e){const t={model:e,onDestroyed:e.on("destroyed",(()=>{this._removeModel(e)}))};this._modelInfos[e.id]=t,this._dirty=!0}_removeModel(e){const t=this._modelInfos[e.id];t&&(t.model.off(t.onDestroyed),delete this._modelInfos[e.id],this._dirty=!0)}_build(){if(!this._dirty)return;this._applyChanges();const e=this._scene.objects;for(let e=0;e<this._numObjects;e++)this._objects[e]=null;this._numObjects=0;for(let t in e){const s=e[t];this._objects[this._numObjects++]=s}this._lenObjectsChangedList=0,this._dirty=!1}_applyChanges(){if(this._lenObjectsChangedList>0){for(let e=0;e<this._lenObjectsChangedList;e++){const t=this._objectsChangedList[e],s=this._objects[t],i=this._objectsViewCulled[t],r=this._objectsDetailCulled[t],n=i||r;s.culled=n,this._objectsChanged[t]=!1}this._lenObjectsChangedList=0}}get objects(){return this._dirty&&this._build(),this._objects}get numObjects(){return this._dirty&&this._build(),this._numObjects}setObjectViewCulled(e,t){this._dirty&&this._build(),this._objectsViewCulled[e]!==t&&(this._objectsViewCulled[e]=t,this._objectsChanged[e]||(this._objectsChanged[e]=!0,this._objectsChangedList[this._lenObjectsChangedList++]=e))}setObjectDetailCulled(e,t){this._dirty&&this._build(),this._objectsDetailCulled[e]!==t&&(this._objectsDetailCulled[e]=t,this._objectsChanged[e]||(this._objectsChanged[e]=!0,this._objectsChangedList[this._lenObjectsChangedList++]=e))}_destroy(){this._clear(),this._scene.off(this._onModelLoaded),this._scene.off(this._onTick)}_clear(){for(let e in this._modelInfos){const t=this._modelInfos[e];t.model.off(t.onDestroyed)}this._modelInfos={},this._dirty=!0}}const Py={};const Sy=new Float32Array(3);class Dy{constructor(e={}){this.cacheBuster=!1!==e.cacheBuster}_cacheBusterURL(e){if(!this.cacheBuster)return e;const t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}getManifest(e,t,s){j.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}getMetaModel(e,t,s){j.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}getXKT(e,t,s){var i=()=>{};t=t||i,s=s||i;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var n=r[3];n=window.decodeURIComponent(n),e&&(n=window.atob(n));try{const e=new ArrayBuffer(n.length),s=new Uint8Array(e);for(var A=0;A<n.length;A++)s[A]=n.charCodeAt(A);t(e)}catch(e){s(e)}}else{const i=new XMLHttpRequest;i.open("GET",this._cacheBusterURL(e),!0),i.responseType="arraybuffer",i.onreadystatechange=function(){4===i.readyState&&(200===i.status?t(i.response):s("getXKT error : "+i.response))},i.send(null)}}}
|
|
43
43
|
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).pako={})}(void 0,(function(e){function t(e){let t=e.length;for(;--t>=0;)e[t]=0}const s=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),i=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),r=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),n=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),A=new Array(576);t(A);const o=new Array(60);t(o);const a=new Array(512);t(a);const l=new Array(256);t(l);const c=new Array(29);t(c);const h=new Array(30);function u(e,t,s,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=s,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}let d,p,f;function g(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}t(h);const m=e=>e<256?a[e]:a[256+(e>>>7)],_=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},b=(e,t,s)=>{e.bi_valid>16-s?(e.bi_buf|=t<<e.bi_valid&65535,_(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=s-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=s)},B=(e,t,s)=>{b(e,s[2*t],s[2*t+1])},y=(e,t)=>{let s=0;do{s|=1&e,e>>>=1,s<<=1}while(--t>0);return s>>>1},w=(e,t,s)=>{const i=new Array(16);let r,n,A=0;for(r=1;r<=15;r++)A=A+s[r-1]<<1,i[r]=A;for(n=0;n<=t;n++){let t=e[2*n+1];0!==t&&(e[2*n]=y(i[t]++,t))}},v=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},C=e=>{e.bi_valid>8?_(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},M=(e,t,s,i)=>{const r=2*t,n=2*s;return e[r]<e[n]||e[r]===e[n]&&i[t]<=i[s]},E=(e,t,s)=>{const i=e.heap[s];let r=s<<1;for(;r<=e.heap_len&&(r<e.heap_len&&M(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!M(t,i,e.heap[r],e.depth));)e.heap[s]=e.heap[r],s=r,r<<=1;e.heap[s]=i},F=(e,t,r)=>{let n,A,o,a,u=0;if(0!==e.sym_next)do{n=255&e.pending_buf[e.sym_buf+u++],n+=(255&e.pending_buf[e.sym_buf+u++])<<8,A=e.pending_buf[e.sym_buf+u++],0===n?B(e,A,t):(o=l[A],B(e,o+256+1,t),a=s[o],0!==a&&(A-=c[o],b(e,A,a)),n--,o=m(n),B(e,o,r),a=i[o],0!==a&&(n-=h[o],b(e,n,a)))}while(u<e.sym_next);B(e,256,t)},x=(e,t)=>{const s=t.dyn_tree,i=t.stat_desc.static_tree,r=t.stat_desc.has_stree,n=t.stat_desc.elems;let A,o,a,l=-1;for(e.heap_len=0,e.heap_max=573,A=0;A<n;A++)0!==s[2*A]?(e.heap[++e.heap_len]=l=A,e.depth[A]=0):s[2*A+1]=0;for(;e.heap_len<2;)a=e.heap[++e.heap_len]=l<2?++l:0,s[2*a]=1,e.depth[a]=0,e.opt_len--,r&&(e.static_len-=i[2*a+1]);for(t.max_code=l,A=e.heap_len>>1;A>=1;A--)E(e,s,A);a=n;do{A=e.heap[1],e.heap[1]=e.heap[e.heap_len--],E(e,s,1),o=e.heap[1],e.heap[--e.heap_max]=A,e.heap[--e.heap_max]=o,s[2*a]=s[2*A]+s[2*o],e.depth[a]=(e.depth[A]>=e.depth[o]?e.depth[A]:e.depth[o])+1,s[2*A+1]=s[2*o+1]=a,e.heap[1]=a++,E(e,s,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const s=t.dyn_tree,i=t.max_code,r=t.stat_desc.static_tree,n=t.stat_desc.has_stree,A=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,a=t.stat_desc.max_length;let l,c,h,u,d,p,f=0;for(u=0;u<=15;u++)e.bl_count[u]=0;for(s[2*e.heap[e.heap_max]+1]=0,l=e.heap_max+1;l<573;l++)c=e.heap[l],u=s[2*s[2*c+1]+1]+1,u>a&&(u=a,f++),s[2*c+1]=u,c>i||(e.bl_count[u]++,d=0,c>=o&&(d=A[c-o]),p=s[2*c],e.opt_len+=p*(u+d),n&&(e.static_len+=p*(r[2*c+1]+d)));if(0!==f){do{for(u=a-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[a]--,f-=2}while(f>0);for(u=a;0!==u;u--)for(c=e.bl_count[u];0!==c;)h=e.heap[--l],h>i||(s[2*h+1]!==u&&(e.opt_len+=(u-s[2*h+1])*s[2*h],s[2*h+1]=u),c--)}})(e,t),w(s,l,e.bl_count)},U=(e,t,s)=>{let i,r,n=-1,A=t[1],o=0,a=7,l=4;for(0===A&&(a=138,l=3),t[2*(s+1)+1]=65535,i=0;i<=s;i++)r=A,A=t[2*(i+1)+1],++o<a&&r===A||(o<l?e.bl_tree[2*r]+=o:0!==r?(r!==n&&e.bl_tree[2*r]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,n=r,0===A?(a=138,l=3):r===A?(a=6,l=3):(a=7,l=4))},I=(e,t,s)=>{let i,r,n=-1,A=t[1],o=0,a=7,l=4;for(0===A&&(a=138,l=3),i=0;i<=s;i++)if(r=A,A=t[2*(i+1)+1],!(++o<a&&r===A)){if(o<l)do{B(e,r,e.bl_tree)}while(0!=--o);else 0!==r?(r!==n&&(B(e,r,e.bl_tree),o--),B(e,16,e.bl_tree),b(e,o-3,2)):o<=10?(B(e,17,e.bl_tree),b(e,o-3,3)):(B(e,18,e.bl_tree),b(e,o-11,7));o=0,n=r,0===A?(a=138,l=3):r===A?(a=6,l=3):(a=7,l=4)}};let T=!1;const P=(e,t,s,i)=>{b(e,0+(i?1:0),3),C(e),_(e,s),_(e,~s),s&&e.pending_buf.set(e.window.subarray(t,t+s),e.pending),e.pending+=s};var S={_tr_init:e=>{T||((()=>{let e,t,n,g,m;const _=new Array(16);for(n=0,g=0;g<28;g++)for(c[g]=n,e=0;e<1<<s[g];e++)l[n++]=g;for(l[n-1]=g,m=0,g=0;g<16;g++)for(h[g]=m,e=0;e<1<<i[g];e++)a[m++]=g;for(m>>=7;g<30;g++)for(h[g]=m<<7,e=0;e<1<<i[g]-7;e++)a[256+m++]=g;for(t=0;t<=15;t++)_[t]=0;for(e=0;e<=143;)A[2*e+1]=8,e++,_[8]++;for(;e<=255;)A[2*e+1]=9,e++,_[9]++;for(;e<=279;)A[2*e+1]=7,e++,_[7]++;for(;e<=287;)A[2*e+1]=8,e++,_[8]++;for(w(A,287,_),e=0;e<30;e++)o[2*e+1]=5,o[2*e]=y(e,5);d=new u(A,s,257,286,15),p=new u(o,i,0,30,15),f=new u(new Array(0),r,0,19,7)})(),T=!0),e.l_desc=new g(e.dyn_ltree,d),e.d_desc=new g(e.dyn_dtree,p),e.bl_desc=new g(e.bl_tree,f),e.bi_buf=0,e.bi_valid=0,v(e)},_tr_stored_block:P,_tr_flush_block:(e,t,s,i)=>{let r,a,l=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,s=4093624447;for(t=0;t<=31;t++,s>>>=1)if(1&s&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),x(e,e.l_desc),x(e,e.d_desc),l=(e=>{let t;for(U(e,e.dyn_ltree,e.l_desc.max_code),U(e,e.dyn_dtree,e.d_desc.max_code),x(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*n[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=r&&(r=a)):r=a=s+5,s+4<=r&&-1!==t?P(e,t,s,i):4===e.strategy||a===r?(b(e,2+(i?1:0),3),F(e,A,o)):(b(e,4+(i?1:0),3),((e,t,s,i)=>{let r;for(b(e,t-257,5),b(e,s-1,5),b(e,i-4,4),r=0;r<i;r++)b(e,e.bl_tree[2*n[r]+1],3);I(e,e.dyn_ltree,t-1),I(e,e.dyn_dtree,s-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,l+1),F(e,e.dyn_ltree,e.dyn_dtree)),v(e),i&&C(e)},_tr_tally:(e,t,s)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=s,0===t?e.dyn_ltree[2*s]++:(e.matches++,t--,e.dyn_ltree[2*(l[s]+256+1)]++,e.dyn_dtree[2*m(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{b(e,2,3),B(e,256,A),(e=>{16===e.bi_valid?(_(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}},D=(e,t,s,i)=>{let r=65535&e|0,n=e>>>16&65535|0,A=0;for(;0!==s;){A=s>2e3?2e3:s,s-=A;do{r=r+t[i++]|0,n=n+r|0}while(--A);r%=65521,n%=65521}return r|n<<16|0};const k=new Uint32Array((()=>{let e,t=[];for(var s=0;s<256;s++){e=s;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t})());var Q=(e,t,s,i)=>{const r=k,n=i+s;e^=-1;for(let s=i;s<n;s++)e=e>>>8^r[255&(e^t[s])];return-1^e},R={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},O={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:V,_tr_stored_block:L,_tr_flush_block:H,_tr_tally:N,_tr_align:G}=S,{Z_NO_FLUSH:j,Z_PARTIAL_FLUSH:W,Z_FULL_FLUSH:z,Z_FINISH:X,Z_BLOCK:K,Z_OK:Z,Z_STREAM_END:J,Z_STREAM_ERROR:Y,Z_DATA_ERROR:$,Z_BUF_ERROR:q,Z_DEFAULT_COMPRESSION:ee,Z_FILTERED:te,Z_HUFFMAN_ONLY:se,Z_RLE:ie,Z_FIXED:re,Z_DEFAULT_STRATEGY:ne,Z_UNKNOWN:Ae,Z_DEFLATED:oe}=O,ae=258,le=262,ce=42,he=113,ue=666,de=(e,t)=>(e.msg=R[t],t),pe=e=>2*e-(e>4?9:0),fe=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ge=e=>{let t,s,i,r=e.w_size;t=e.hash_size,i=t;do{s=e.head[--i],e.head[i]=s>=r?s-r:0}while(--t);t=r,i=t;do{s=e.prev[--i],e.prev[i]=s>=r?s-r:0}while(--t)};let me=(e,t,s)=>(t<<e.hash_shift^s)&e.hash_mask;const _e=e=>{const t=e.state;let s=t.pending;s>e.avail_out&&(s=e.avail_out),0!==s&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+s),e.next_out),e.next_out+=s,t.pending_out+=s,e.total_out+=s,e.avail_out-=s,t.pending-=s,0===t.pending&&(t.pending_out=0))},be=(e,t)=>{H(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,_e(e.strm)},Be=(e,t)=>{e.pending_buf[e.pending++]=t},ye=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},we=(e,t,s,i)=>{let r=e.avail_in;return r>i&&(r=i),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),s),1===e.state.wrap?e.adler=D(e.adler,t,r,s):2===e.state.wrap&&(e.adler=Q(e.adler,t,r,s)),e.next_in+=r,e.total_in+=r,r)},ve=(e,t)=>{let s,i,r=e.max_chain_length,n=e.strstart,A=e.prev_length,o=e.nice_match;const a=e.strstart>e.w_size-le?e.strstart-(e.w_size-le):0,l=e.window,c=e.w_mask,h=e.prev,u=e.strstart+ae;let d=l[n+A-1],p=l[n+A];e.prev_length>=e.good_match&&(r>>=2),o>e.lookahead&&(o=e.lookahead);do{if(s=t,l[s+A]===p&&l[s+A-1]===d&&l[s]===l[n]&&l[++s]===l[n+1]){n+=2,s++;do{}while(l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&n<u);if(i=ae-(u-n),n=u-ae,i>A){if(e.match_start=t,A=i,i>=o)break;d=l[n+A-1],p=l[n+A]}}}while((t=h[t&c])>a&&0!=--r);return A<=e.lookahead?A:e.lookahead},Ce=e=>{const t=e.w_size;let s,i,r;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-le)&&(e.window.set(e.window.subarray(t,t+t-i),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),ge(e),i+=t),0===e.strm.avail_in)break;if(s=we(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=s,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=me(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=me(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<le&&0!==e.strm.avail_in)},Me=(e,t)=>{let s,i,r,n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,A=0,o=e.strm.avail_in;do{if(s=65535,r=e.bi_valid+42>>3,e.strm.avail_out<r)break;if(r=e.strm.avail_out-r,i=e.strstart-e.block_start,s>i+e.strm.avail_in&&(s=i+e.strm.avail_in),s>r&&(s=r),s<n&&(0===s&&t!==X||t===j||s!==i+e.strm.avail_in))break;A=t===X&&s===i+e.strm.avail_in?1:0,L(e,0,0,A),e.pending_buf[e.pending-4]=s,e.pending_buf[e.pending-3]=s>>8,e.pending_buf[e.pending-2]=~s,e.pending_buf[e.pending-1]=~s>>8,_e(e.strm),i&&(i>s&&(i=s),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,s-=i),s&&(we(e.strm,e.strm.output,e.strm.next_out,s),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s)}while(0===A);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),A?4:t!==j&&t!==X&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(r=e.window_size-e.strstart,e.strm.avail_in>r&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(we(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water<e.strstart&&(e.high_water=e.strstart),r=e.bi_valid+42>>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,n=r>e.w_size?e.w_size:r,i=e.strstart-e.block_start,(i>=n||(i||t===X)&&t!==j&&0===e.strm.avail_in&&i<=r)&&(s=i>r?r:i,A=t===X&&0===e.strm.avail_in&&s===i?1:0,L(e,e.block_start,s,A),e.block_start+=s,_e(e.strm)),A?3:1)},Ee=(e,t)=>{let s,i;for(;;){if(e.lookahead<le){if(Ce(e),e.lookahead<le&&t===j)return 1;if(0===e.lookahead)break}if(s=0,e.lookahead>=3&&(e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==s&&e.strstart-s<=e.w_size-le&&(e.match_length=ve(e,s)),e.match_length>=3)if(i=N(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=me(e,e.ins_h,e.window[e.strstart+1]);else i=N(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(be(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===X?(be(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(be(e,!1),0===e.strm.avail_out)?1:2},Fe=(e,t)=>{let s,i,r;for(;;){if(e.lookahead<le){if(Ce(e),e.lookahead<le&&t===j)return 1;if(0===e.lookahead)break}if(s=0,e.lookahead>=3&&(e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==s&&e.prev_length<e.max_lazy_match&&e.strstart-s<=e.w_size-le&&(e.match_length=ve(e,s),e.match_length<=5&&(e.strategy===te||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,i=N(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,i&&(be(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=N(e,0,e.window[e.strstart-1]),i&&be(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=N(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===X?(be(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(be(e,!1),0===e.strm.avail_out)?1:2};function xe(e,t,s,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=s,this.max_chain=i,this.func=r}const Ue=[new xe(0,0,0,0,Me),new xe(4,4,8,4,Ee),new xe(4,5,16,8,Ee),new xe(4,6,32,32,Ee),new xe(4,4,16,16,Fe),new xe(8,16,32,32,Fe),new xe(8,16,128,128,Fe),new xe(8,32,128,256,Fe),new xe(32,128,258,1024,Fe),new xe(32,258,258,4096,Fe)];function Ie(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=oe,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),fe(this.dyn_ltree),fe(this.dyn_dtree),fe(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),fe(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),fe(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Te=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==ce&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==he&&t.status!==ue?1:0},Pe=e=>{if(Te(e))return de(e,Y);e.total_in=e.total_out=0,e.data_type=Ae;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?ce:he,e.adler=2===t.wrap?0:1,t.last_flush=-2,V(t),Z},Se=e=>{const t=Pe(e);var s;return t===Z&&((s=e.state).window_size=2*s.w_size,fe(s.head),s.max_lazy_match=Ue[s.level].max_lazy,s.good_match=Ue[s.level].good_length,s.nice_match=Ue[s.level].nice_length,s.max_chain_length=Ue[s.level].max_chain,s.strstart=0,s.block_start=0,s.lookahead=0,s.insert=0,s.match_length=s.prev_length=2,s.match_available=0,s.ins_h=0),t},De=(e,t,s,i,r,n)=>{if(!e)return Y;let A=1;if(t===ee&&(t=6),i<0?(A=0,i=-i):i>15&&(A=2,i-=16),r<1||r>9||s!==oe||i<8||i>15||t<0||t>9||n<0||n>re||8===i&&1!==A)return de(e,Y);8===i&&(i=9);const o=new Ie;return e.state=o,o.strm=e,o.status=ce,o.wrap=A,o.gzhead=null,o.w_bits=i,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=r+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<r+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=t,o.strategy=n,o.method=s,Se(e)};var ke=De,Qe=(e,t)=>Te(e)||2!==e.state.wrap?Y:(e.state.gzhead=t,Z),Re=(e,t)=>{if(Te(e)||t>K||t<0)return e?de(e,Y):Y;const s=e.state;if(!e.output||0!==e.avail_in&&!e.input||s.status===ue&&t!==X)return de(e,0===e.avail_out?q:Y);const i=s.last_flush;if(s.last_flush=t,0!==s.pending){if(_e(e),0===e.avail_out)return s.last_flush=-1,Z}else if(0===e.avail_in&&pe(t)<=pe(i)&&t!==X)return de(e,q);if(s.status===ue&&0!==e.avail_in)return de(e,q);if(s.status===ce&&0===s.wrap&&(s.status=he),s.status===ce){let t=oe+(s.w_bits-8<<4)<<8,i=-1;if(i=s.strategy>=se||s.level<2?0:s.level<6?1:6===s.level?2:3,t|=i<<6,0!==s.strstart&&(t|=32),t+=31-t%31,ye(s,t),0!==s.strstart&&(ye(s,e.adler>>>16),ye(s,65535&e.adler)),e.adler=1,s.status=he,_e(e),0!==s.pending)return s.last_flush=-1,Z}if(57===s.status)if(e.adler=0,Be(s,31),Be(s,139),Be(s,8),s.gzhead)Be(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),Be(s,255&s.gzhead.time),Be(s,s.gzhead.time>>8&255),Be(s,s.gzhead.time>>16&255),Be(s,s.gzhead.time>>24&255),Be(s,9===s.level?2:s.strategy>=se||s.level<2?4:0),Be(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(Be(s,255&s.gzhead.extra.length),Be(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=Q(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69;else if(Be(s,0),Be(s,0),Be(s,0),Be(s,0),Be(s,0),Be(s,9===s.level?2:s.strategy>=se||s.level<2?4:0),Be(s,3),s.status=he,_e(e),0!==s.pending)return s.last_flush=-1,Z;if(69===s.status){if(s.gzhead.extra){let t=s.pending,i=(65535&s.gzhead.extra.length)-s.gzindex;for(;s.pending+i>s.pending_buf_size;){let r=s.pending_buf_size-s.pending;if(s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex,s.gzindex+r),s.pending),s.pending=s.pending_buf_size,s.gzhead.hcrc&&s.pending>t&&(e.adler=Q(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex+=r,_e(e),0!==s.pending)return s.last_flush=-1,Z;t=0,i-=r}let r=new Uint8Array(s.gzhead.extra);s.pending_buf.set(r.subarray(s.gzindex,s.gzindex+i),s.pending),s.pending+=i,s.gzhead.hcrc&&s.pending>t&&(e.adler=Q(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex=0}s.status=73}if(73===s.status){if(s.gzhead.name){let t,i=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>i&&(e.adler=Q(e.adler,s.pending_buf,s.pending-i,i)),_e(e),0!==s.pending)return s.last_flush=-1,Z;i=0}t=s.gzindex<s.gzhead.name.length?255&s.gzhead.name.charCodeAt(s.gzindex++):0,Be(s,t)}while(0!==t);s.gzhead.hcrc&&s.pending>i&&(e.adler=Q(e.adler,s.pending_buf,s.pending-i,i)),s.gzindex=0}s.status=91}if(91===s.status){if(s.gzhead.comment){let t,i=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>i&&(e.adler=Q(e.adler,s.pending_buf,s.pending-i,i)),_e(e),0!==s.pending)return s.last_flush=-1,Z;i=0}t=s.gzindex<s.gzhead.comment.length?255&s.gzhead.comment.charCodeAt(s.gzindex++):0,Be(s,t)}while(0!==t);s.gzhead.hcrc&&s.pending>i&&(e.adler=Q(e.adler,s.pending_buf,s.pending-i,i))}s.status=103}if(103===s.status){if(s.gzhead.hcrc){if(s.pending+2>s.pending_buf_size&&(_e(e),0!==s.pending))return s.last_flush=-1,Z;Be(s,255&e.adler),Be(s,e.adler>>8&255),e.adler=0}if(s.status=he,_e(e),0!==s.pending)return s.last_flush=-1,Z}if(0!==e.avail_in||0!==s.lookahead||t!==j&&s.status!==ue){let i=0===s.level?Me(s,t):s.strategy===se?((e,t)=>{let s;for(;;){if(0===e.lookahead&&(Ce(e),0===e.lookahead)){if(t===j)return 1;break}if(e.match_length=0,s=N(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(be(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===X?(be(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(be(e,!1),0===e.strm.avail_out)?1:2})(s,t):s.strategy===ie?((e,t)=>{let s,i,r,n;const A=e.window;for(;;){if(e.lookahead<=ae){if(Ce(e),e.lookahead<=ae&&t===j)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,i=A[r],i===A[++r]&&i===A[++r]&&i===A[++r])){n=e.strstart+ae;do{}while(i===A[++r]&&i===A[++r]&&i===A[++r]&&i===A[++r]&&i===A[++r]&&i===A[++r]&&i===A[++r]&&i===A[++r]&&r<n);e.match_length=ae-(n-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(s=N(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=N(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(be(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===X?(be(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(be(e,!1),0===e.strm.avail_out)?1:2})(s,t):Ue[s.level].func(s,t);if(3!==i&&4!==i||(s.status=ue),1===i||3===i)return 0===e.avail_out&&(s.last_flush=-1),Z;if(2===i&&(t===W?G(s):t!==K&&(L(s,0,0,!1),t===z&&(fe(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),_e(e),0===e.avail_out))return s.last_flush=-1,Z}return t!==X?Z:s.wrap<=0?J:(2===s.wrap?(Be(s,255&e.adler),Be(s,e.adler>>8&255),Be(s,e.adler>>16&255),Be(s,e.adler>>24&255),Be(s,255&e.total_in),Be(s,e.total_in>>8&255),Be(s,e.total_in>>16&255),Be(s,e.total_in>>24&255)):(ye(s,e.adler>>>16),ye(s,65535&e.adler)),_e(e),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?Z:J)},Oe=e=>{if(Te(e))return Y;const t=e.state.status;return e.state=null,t===he?de(e,$):Z},Ve=(e,t)=>{let s=t.length;if(Te(e))return Y;const i=e.state,r=i.wrap;if(2===r||1===r&&i.status!==ce||i.lookahead)return Y;if(1===r&&(e.adler=D(e.adler,t,s,0)),i.wrap=0,s>=i.w_size){0===r&&(fe(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(s-i.w_size,s),0),t=e,s=i.w_size}const n=e.avail_in,A=e.next_in,o=e.input;for(e.avail_in=s,e.next_in=0,e.input=t,Ce(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=me(i,i.ins_h,i.window[e+3-1]),i.prev[e&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=e,e++}while(--t);i.strstart=e,i.lookahead=2,Ce(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,e.next_in=A,e.input=o,e.avail_in=n,i.wrap=r,Z};const Le=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var He=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const s=t.shift();if(s){if("object"!=typeof s)throw new TypeError(s+"must be non-object");for(const t in s)Le(s,t)&&(e[t]=s[t])}}return e},Ne=e=>{let t=0;for(let s=0,i=e.length;s<i;s++)t+=e[s].length;const s=new Uint8Array(t);for(let t=0,i=0,r=e.length;t<r;t++){let r=e[t];s.set(r,i),i+=r.length}return s};let Ge=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){Ge=!1}const je=new Uint8Array(256);for(let e=0;e<256;e++)je[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;je[254]=je[254]=1;var We=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,s,i,r,n,A=e.length,o=0;for(r=0;r<A;r++)s=e.charCodeAt(r),55296==(64512&s)&&r+1<A&&(i=e.charCodeAt(r+1),56320==(64512&i)&&(s=65536+(s-55296<<10)+(i-56320),r++)),o+=s<128?1:s<2048?2:s<65536?3:4;for(t=new Uint8Array(o),n=0,r=0;n<o;r++)s=e.charCodeAt(r),55296==(64512&s)&&r+1<A&&(i=e.charCodeAt(r+1),56320==(64512&i)&&(s=65536+(s-55296<<10)+(i-56320),r++)),s<128?t[n++]=s:s<2048?(t[n++]=192|s>>>6,t[n++]=128|63&s):s<65536?(t[n++]=224|s>>>12,t[n++]=128|s>>>6&63,t[n++]=128|63&s):(t[n++]=240|s>>>18,t[n++]=128|s>>>12&63,t[n++]=128|s>>>6&63,t[n++]=128|63&s);return t},ze=(e,t)=>{const s=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let i,r;const n=new Array(2*s);for(r=0,i=0;i<s;){let t=e[i++];if(t<128){n[r++]=t;continue}let A=je[t];if(A>4)n[r++]=65533,i+=A-1;else{for(t&=2===A?31:3===A?15:7;A>1&&i<s;)t=t<<6|63&e[i++],A--;A>1?n[r++]=65533:t<65536?n[r++]=t:(t-=65536,n[r++]=55296|t>>10&1023,n[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Ge)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let s="";for(let i=0;i<t;i++)s+=String.fromCharCode(e[i]);return s})(n,r)},Xe=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let s=t-1;for(;s>=0&&128==(192&e[s]);)s--;return s<0||0===s?t:s+je[e[s]]>t?s:t},Ke=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ze=Object.prototype.toString,{Z_NO_FLUSH:Je,Z_SYNC_FLUSH:Ye,Z_FULL_FLUSH:$e,Z_FINISH:qe,Z_OK:et,Z_STREAM_END:tt,Z_DEFAULT_COMPRESSION:st,Z_DEFAULT_STRATEGY:it,Z_DEFLATED:rt}=O;function nt(e){this.options=He({level:st,method:rt,chunkSize:16384,windowBits:15,memLevel:8,strategy:it},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ke,this.strm.avail_out=0;let s=ke(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(s!==et)throw new Error(R[s]);if(t.header&&Qe(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?We(t.dictionary):"[object ArrayBuffer]"===Ze.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,s=Ve(this.strm,e),s!==et)throw new Error(R[s]);this._dict_set=!0}}function At(e,t){const s=new nt(t);if(s.push(e,!0),s.err)throw s.msg||R[s.err];return s.result}nt.prototype.push=function(e,t){const s=this.strm,i=this.options.chunkSize;let r,n;if(this.ended)return!1;for(n=t===~~t?t:!0===t?qe:Je,"string"==typeof e?s.input=We(e):"[object ArrayBuffer]"===Ze.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;;)if(0===s.avail_out&&(s.output=new Uint8Array(i),s.next_out=0,s.avail_out=i),(n===Ye||n===$e)&&s.avail_out<=6)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else{if(r=Re(s,n),r===tt)return s.next_out>0&&this.onData(s.output.subarray(0,s.next_out)),r=Oe(this.strm),this.onEnd(r),this.ended=!0,r===et;if(0!==s.avail_out){if(n>0&&s.next_out>0)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else if(0===s.avail_in)break}else this.onData(s.output)}return!0},nt.prototype.onData=function(e){this.chunks.push(e)},nt.prototype.onEnd=function(e){e===et&&(this.result=Ne(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ot={Deflate:nt,deflate:At,deflateRaw:function(e,t){return(t=t||{}).raw=!0,At(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,At(e,t)},constants:O};const at=16209;var lt=function(e,t){let s,i,r,n,A,o,a,l,c,h,u,d,p,f,g,m,_,b,B,y,w,v,C,M;const E=e.state;s=e.next_in,C=e.input,i=s+(e.avail_in-5),r=e.next_out,M=e.output,n=r-(t-e.avail_out),A=r+(e.avail_out-257),o=E.dmax,a=E.wsize,l=E.whave,c=E.wnext,h=E.window,u=E.hold,d=E.bits,p=E.lencode,f=E.distcode,g=(1<<E.lenbits)-1,m=(1<<E.distbits)-1;e:do{d<15&&(u+=C[s++]<<d,d+=8,u+=C[s++]<<d,d+=8),_=p[u&g];t:for(;;){if(b=_>>>24,u>>>=b,d-=b,b=_>>>16&255,0===b)M[r++]=65535&_;else{if(!(16&b)){if(0==(64&b)){_=p[(65535&_)+(u&(1<<b)-1)];continue t}if(32&b){E.mode=16191;break e}e.msg="invalid literal/length code",E.mode=at;break e}B=65535&_,b&=15,b&&(d<b&&(u+=C[s++]<<d,d+=8),B+=u&(1<<b)-1,u>>>=b,d-=b),d<15&&(u+=C[s++]<<d,d+=8,u+=C[s++]<<d,d+=8),_=f[u&m];s:for(;;){if(b=_>>>24,u>>>=b,d-=b,b=_>>>16&255,!(16&b)){if(0==(64&b)){_=f[(65535&_)+(u&(1<<b)-1)];continue s}e.msg="invalid distance code",E.mode=at;break e}if(y=65535&_,b&=15,d<b&&(u+=C[s++]<<d,d+=8,d<b&&(u+=C[s++]<<d,d+=8)),y+=u&(1<<b)-1,y>o){e.msg="invalid distance too far back",E.mode=at;break e}if(u>>>=b,d-=b,b=r-n,y>b){if(b=y-b,b>l&&E.sane){e.msg="invalid distance too far back",E.mode=at;break e}if(w=0,v=h,0===c){if(w+=a-b,b<B){B-=b;do{M[r++]=h[w++]}while(--b);w=r-y,v=M}}else if(c<b){if(w+=a+c-b,b-=c,b<B){B-=b;do{M[r++]=h[w++]}while(--b);if(w=0,c<B){b=c,B-=b;do{M[r++]=h[w++]}while(--b);w=r-y,v=M}}}else if(w+=c-b,b<B){B-=b;do{M[r++]=h[w++]}while(--b);w=r-y,v=M}for(;B>2;)M[r++]=v[w++],M[r++]=v[w++],M[r++]=v[w++],B-=3;B&&(M[r++]=v[w++],B>1&&(M[r++]=v[w++]))}else{w=r-y;do{M[r++]=M[w++],M[r++]=M[w++],M[r++]=M[w++],B-=3}while(B>2);B&&(M[r++]=M[w++],B>1&&(M[r++]=M[w++]))}break}}break}}while(s<i&&r<A);B=d>>3,s-=B,d-=B<<3,u&=(1<<d)-1,e.next_in=s,e.next_out=r,e.avail_in=s<i?i-s+5:5-(s-i),e.avail_out=r<A?A-r+257:257-(r-A),E.hold=u,E.bits=d};const ct=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),ht=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),ut=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),dt=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var pt=(e,t,s,i,r,n,A,o)=>{const a=o.bits;let l,c,h,u,d,p,f=0,g=0,m=0,_=0,b=0,B=0,y=0,w=0,v=0,C=0,M=null;const E=new Uint16Array(16),F=new Uint16Array(16);let x,U,I,T=null;for(f=0;f<=15;f++)E[f]=0;for(g=0;g<i;g++)E[t[s+g]]++;for(b=a,_=15;_>=1&&0===E[_];_--);if(b>_&&(b=_),0===_)return r[n++]=20971520,r[n++]=20971520,o.bits=1,0;for(m=1;m<_&&0===E[m];m++);for(b<m&&(b=m),w=1,f=1;f<=15;f++)if(w<<=1,w-=E[f],w<0)return-1;if(w>0&&(0===e||1!==_))return-1;for(F[1]=0,f=1;f<15;f++)F[f+1]=F[f]+E[f];for(g=0;g<i;g++)0!==t[s+g]&&(A[F[t[s+g]]++]=g);if(0===e?(M=T=A,p=20):1===e?(M=ct,T=ht,p=257):(M=ut,T=dt,p=0),C=0,g=0,f=m,d=n,B=b,y=0,h=-1,v=1<<b,u=v-1,1===e&&v>852||2===e&&v>592)return 1;for(;;){x=f-y,A[g]+1<p?(U=0,I=A[g]):A[g]>=p?(U=T[A[g]-p],I=M[A[g]-p]):(U=96,I=0),l=1<<f-y,c=1<<B,m=c;do{c-=l,r[d+(C>>y)+c]=x<<24|U<<16|I|0}while(0!==c);for(l=1<<f-1;C&l;)l>>=1;if(0!==l?(C&=l-1,C+=l):C=0,g++,0==--E[f]){if(f===_)break;f=t[s+A[g]]}if(f>b&&(C&u)!==h){for(0===y&&(y=b),d+=m,B=f-y,w=1<<B;B+y<_&&(w-=E[B+y],!(w<=0));)B++,w<<=1;if(v+=1<<B,1===e&&v>852||2===e&&v>592)return 1;h=C&u,r[h]=b<<24|B<<16|d-n|0}}return 0!==C&&(r[d+C]=f-y<<24|64<<16|0),o.bits=b,0};const{Z_FINISH:ft,Z_BLOCK:gt,Z_TREES:mt,Z_OK:_t,Z_STREAM_END:bt,Z_NEED_DICT:Bt,Z_STREAM_ERROR:yt,Z_DATA_ERROR:wt,Z_MEM_ERROR:vt,Z_BUF_ERROR:Ct,Z_DEFLATED:Mt}=O,Et=16180,Ft=16190,xt=16191,Ut=16192,It=16194,Tt=16199,Pt=16200,St=16206,Dt=16209,kt=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Qt(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Rt=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<Et||t.mode>16211?1:0},Ot=e=>{if(Rt(e))return yt;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Et,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,_t},Vt=e=>{if(Rt(e))return yt;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ot(e)},Lt=(e,t)=>{let s;if(Rt(e))return yt;const i=e.state;return t<0?(s=0,t=-t):(s=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?yt:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=s,i.wbits=t,Vt(e))},Ht=(e,t)=>{if(!e)return yt;const s=new Qt;e.state=s,s.strm=e,s.window=null,s.mode=Et;const i=Lt(e,t);return i!==_t&&(e.state=null),i};let Nt,Gt,jt=!0;const Wt=e=>{if(jt){Nt=new Int32Array(512),Gt=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(pt(1,e.lens,0,288,Nt,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;pt(2,e.lens,0,32,Gt,0,e.work,{bits:5}),jt=!1}e.lencode=Nt,e.lenbits=9,e.distcode=Gt,e.distbits=5},zt=(e,t,s,i)=>{let r;const n=e.state;return null===n.window&&(n.wsize=1<<n.wbits,n.wnext=0,n.whave=0,n.window=new Uint8Array(n.wsize)),i>=n.wsize?(n.window.set(t.subarray(s-n.wsize,s),0),n.wnext=0,n.whave=n.wsize):(r=n.wsize-n.wnext,r>i&&(r=i),n.window.set(t.subarray(s-i,s-i+r),n.wnext),(i-=r)?(n.window.set(t.subarray(s-i,s),0),n.wnext=i,n.whave=n.wsize):(n.wnext+=r,n.wnext===n.wsize&&(n.wnext=0),n.whave<n.wsize&&(n.whave+=r))),0};var Xt=Vt,Kt=Ht,Zt=(e,t)=>{let s,i,r,n,A,o,a,l,c,h,u,d,p,f,g,m,_,b,B,y,w,v,C=0;const M=new Uint8Array(4);let E,F;const x=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Rt(e)||!e.output||!e.input&&0!==e.avail_in)return yt;s=e.state,s.mode===xt&&(s.mode=Ut),A=e.next_out,r=e.output,a=e.avail_out,n=e.next_in,i=e.input,o=e.avail_in,l=s.hold,c=s.bits,h=o,u=a,v=_t;e:for(;;)switch(s.mode){case Et:if(0===s.wrap){s.mode=Ut;break}for(;c<16;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}if(2&s.wrap&&35615===l){0===s.wbits&&(s.wbits=15),s.check=0,M[0]=255&l,M[1]=l>>>8&255,s.check=Q(s.check,M,2,0),l=0,c=0,s.mode=16181;break}if(s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",s.mode=Dt;break}if((15&l)!==Mt){e.msg="unknown compression method",s.mode=Dt;break}if(l>>>=4,c-=4,w=8+(15&l),0===s.wbits&&(s.wbits=w),w>15||w>s.wbits){e.msg="invalid window size",s.mode=Dt;break}s.dmax=1<<s.wbits,s.flags=0,e.adler=s.check=1,s.mode=512&l?16189:xt,l=0,c=0;break;case 16181:for(;c<16;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}if(s.flags=l,(255&s.flags)!==Mt){e.msg="unknown compression method",s.mode=Dt;break}if(57344&s.flags){e.msg="unknown header flags set",s.mode=Dt;break}s.head&&(s.head.text=l>>8&1),512&s.flags&&4&s.wrap&&(M[0]=255&l,M[1]=l>>>8&255,s.check=Q(s.check,M,2,0)),l=0,c=0,s.mode=16182;case 16182:for(;c<32;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}s.head&&(s.head.time=l),512&s.flags&&4&s.wrap&&(M[0]=255&l,M[1]=l>>>8&255,M[2]=l>>>16&255,M[3]=l>>>24&255,s.check=Q(s.check,M,4,0)),l=0,c=0,s.mode=16183;case 16183:for(;c<16;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}s.head&&(s.head.xflags=255&l,s.head.os=l>>8),512&s.flags&&4&s.wrap&&(M[0]=255&l,M[1]=l>>>8&255,s.check=Q(s.check,M,2,0)),l=0,c=0,s.mode=16184;case 16184:if(1024&s.flags){for(;c<16;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}s.length=l,s.head&&(s.head.extra_len=l),512&s.flags&&4&s.wrap&&(M[0]=255&l,M[1]=l>>>8&255,s.check=Q(s.check,M,2,0)),l=0,c=0}else s.head&&(s.head.extra=null);s.mode=16185;case 16185:if(1024&s.flags&&(d=s.length,d>o&&(d=o),d&&(s.head&&(w=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Uint8Array(s.head.extra_len)),s.head.extra.set(i.subarray(n,n+d),w)),512&s.flags&&4&s.wrap&&(s.check=Q(s.check,i,d,n)),o-=d,n+=d,s.length-=d),s.length))break e;s.length=0,s.mode=16186;case 16186:if(2048&s.flags){if(0===o)break e;d=0;do{w=i[n+d++],s.head&&w&&s.length<65536&&(s.head.name+=String.fromCharCode(w))}while(w&&d<o);if(512&s.flags&&4&s.wrap&&(s.check=Q(s.check,i,d,n)),o-=d,n+=d,w)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=16187;case 16187:if(4096&s.flags){if(0===o)break e;d=0;do{w=i[n+d++],s.head&&w&&s.length<65536&&(s.head.comment+=String.fromCharCode(w))}while(w&&d<o);if(512&s.flags&&4&s.wrap&&(s.check=Q(s.check,i,d,n)),o-=d,n+=d,w)break e}else s.head&&(s.head.comment=null);s.mode=16188;case 16188:if(512&s.flags){for(;c<16;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}if(4&s.wrap&&l!==(65535&s.check)){e.msg="header crc mismatch",s.mode=Dt;break}l=0,c=0}s.head&&(s.head.hcrc=s.flags>>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=xt;break;case 16189:for(;c<32;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}e.adler=s.check=kt(l),l=0,c=0,s.mode=Ft;case Ft:if(0===s.havedict)return e.next_out=A,e.avail_out=a,e.next_in=n,e.avail_in=o,s.hold=l,s.bits=c,Bt;e.adler=s.check=1,s.mode=xt;case xt:if(t===gt||t===mt)break e;case Ut:if(s.last){l>>>=7&c,c-=7&c,s.mode=St;break}for(;c<3;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}switch(s.last=1&l,l>>>=1,c-=1,3&l){case 0:s.mode=16193;break;case 1:if(Wt(s),s.mode=Tt,t===mt){l>>>=2,c-=2;break e}break;case 2:s.mode=16196;break;case 3:e.msg="invalid block type",s.mode=Dt}l>>>=2,c-=2;break;case 16193:for(l>>>=7&c,c-=7&c;c<32;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",s.mode=Dt;break}if(s.length=65535&l,l=0,c=0,s.mode=It,t===mt)break e;case It:s.mode=16195;case 16195:if(d=s.length,d){if(d>o&&(d=o),d>a&&(d=a),0===d)break e;r.set(i.subarray(n,n+d),A),o-=d,n+=d,a-=d,A+=d,s.length-=d;break}s.mode=xt;break;case 16196:for(;c<14;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}if(s.nlen=257+(31&l),l>>>=5,c-=5,s.ndist=1+(31&l),l>>>=5,c-=5,s.ncode=4+(15&l),l>>>=4,c-=4,s.nlen>286||s.ndist>30){e.msg="too many length or distance symbols",s.mode=Dt;break}s.have=0,s.mode=16197;case 16197:for(;s.have<s.ncode;){for(;c<3;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}s.lens[x[s.have++]]=7&l,l>>>=3,c-=3}for(;s.have<19;)s.lens[x[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,E={bits:s.lenbits},v=pt(0,s.lens,0,19,s.lencode,0,s.work,E),s.lenbits=E.bits,v){e.msg="invalid code lengths set",s.mode=Dt;break}s.have=0,s.mode=16198;case 16198:for(;s.have<s.nlen+s.ndist;){for(;C=s.lencode[l&(1<<s.lenbits)-1],g=C>>>24,m=C>>>16&255,_=65535&C,!(g<=c);){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}if(_<16)l>>>=g,c-=g,s.lens[s.have++]=_;else{if(16===_){for(F=g+2;c<F;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}if(l>>>=g,c-=g,0===s.have){e.msg="invalid bit length repeat",s.mode=Dt;break}w=s.lens[s.have-1],d=3+(3&l),l>>>=2,c-=2}else if(17===_){for(F=g+3;c<F;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}l>>>=g,c-=g,w=0,d=3+(7&l),l>>>=3,c-=3}else{for(F=g+7;c<F;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}l>>>=g,c-=g,w=0,d=11+(127&l),l>>>=7,c-=7}if(s.have+d>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=Dt;break}for(;d--;)s.lens[s.have++]=w}}if(s.mode===Dt)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=Dt;break}if(s.lenbits=9,E={bits:s.lenbits},v=pt(1,s.lens,0,s.nlen,s.lencode,0,s.work,E),s.lenbits=E.bits,v){e.msg="invalid literal/lengths set",s.mode=Dt;break}if(s.distbits=6,s.distcode=s.distdyn,E={bits:s.distbits},v=pt(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,E),s.distbits=E.bits,v){e.msg="invalid distances set",s.mode=Dt;break}if(s.mode=Tt,t===mt)break e;case Tt:s.mode=Pt;case Pt:if(o>=6&&a>=258){e.next_out=A,e.avail_out=a,e.next_in=n,e.avail_in=o,s.hold=l,s.bits=c,lt(e,u),A=e.next_out,r=e.output,a=e.avail_out,n=e.next_in,i=e.input,o=e.avail_in,l=s.hold,c=s.bits,s.mode===xt&&(s.back=-1);break}for(s.back=0;C=s.lencode[l&(1<<s.lenbits)-1],g=C>>>24,m=C>>>16&255,_=65535&C,!(g<=c);){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}if(m&&0==(240&m)){for(b=g,B=m,y=_;C=s.lencode[y+((l&(1<<b+B)-1)>>b)],g=C>>>24,m=C>>>16&255,_=65535&C,!(b+g<=c);){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}l>>>=b,c-=b,s.back+=b}if(l>>>=g,c-=g,s.back+=g,s.length=_,0===m){s.mode=16205;break}if(32&m){s.back=-1,s.mode=xt;break}if(64&m){e.msg="invalid literal/length code",s.mode=Dt;break}s.extra=15&m,s.mode=16201;case 16201:if(s.extra){for(F=s.extra;c<F;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}s.length+=l&(1<<s.extra)-1,l>>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=16202;case 16202:for(;C=s.distcode[l&(1<<s.distbits)-1],g=C>>>24,m=C>>>16&255,_=65535&C,!(g<=c);){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}if(0==(240&m)){for(b=g,B=m,y=_;C=s.distcode[y+((l&(1<<b+B)-1)>>b)],g=C>>>24,m=C>>>16&255,_=65535&C,!(b+g<=c);){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}l>>>=b,c-=b,s.back+=b}if(l>>>=g,c-=g,s.back+=g,64&m){e.msg="invalid distance code",s.mode=Dt;break}s.offset=_,s.extra=15&m,s.mode=16203;case 16203:if(s.extra){for(F=s.extra;c<F;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}s.offset+=l&(1<<s.extra)-1,l>>>=s.extra,c-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=Dt;break}s.mode=16204;case 16204:if(0===a)break e;if(d=u-a,s.offset>d){if(d=s.offset-d,d>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=Dt;break}d>s.wnext?(d-=s.wnext,p=s.wsize-d):p=s.wnext-d,d>s.length&&(d=s.length),f=s.window}else f=r,p=A-s.offset,d=s.length;d>a&&(d=a),a-=d,s.length-=d;do{r[A++]=f[p++]}while(--d);0===s.length&&(s.mode=Pt);break;case 16205:if(0===a)break e;r[A++]=s.length,a--,s.mode=Pt;break;case St:if(s.wrap){for(;c<32;){if(0===o)break e;o--,l|=i[n++]<<c,c+=8}if(u-=a,e.total_out+=u,s.total+=u,4&s.wrap&&u&&(e.adler=s.check=s.flags?Q(s.check,r,u,A-u):D(s.check,r,u,A-u)),u=a,4&s.wrap&&(s.flags?l:kt(l))!==s.check){e.msg="incorrect data check",s.mode=Dt;break}l=0,c=0}s.mode=16207;case 16207:if(s.wrap&&s.flags){for(;c<32;){if(0===o)break e;o--,l+=i[n++]<<c,c+=8}if(4&s.wrap&&l!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=Dt;break}l=0,c=0}s.mode=16208;case 16208:v=bt;break e;case Dt:v=wt;break e;case 16210:return vt;default:return yt}return e.next_out=A,e.avail_out=a,e.next_in=n,e.avail_in=o,s.hold=l,s.bits=c,(s.wsize||u!==e.avail_out&&s.mode<Dt&&(s.mode<St||t!==ft))&&zt(e,e.output,e.next_out,u-e.avail_out),h-=e.avail_in,u-=e.avail_out,e.total_in+=h,e.total_out+=u,s.total+=u,4&s.wrap&&u&&(e.adler=s.check=s.flags?Q(s.check,r,u,e.next_out-u):D(s.check,r,u,e.next_out-u)),e.data_type=s.bits+(s.last?64:0)+(s.mode===xt?128:0)+(s.mode===Tt||s.mode===It?256:0),(0===h&&0===u||t===ft)&&v===_t&&(v=Ct),v},Jt=e=>{if(Rt(e))return yt;let t=e.state;return t.window&&(t.window=null),e.state=null,_t},Yt=(e,t)=>{if(Rt(e))return yt;const s=e.state;return 0==(2&s.wrap)?yt:(s.head=t,t.done=!1,_t)},$t=(e,t)=>{const s=t.length;let i,r,n;return Rt(e)?yt:(i=e.state,0!==i.wrap&&i.mode!==Ft?yt:i.mode===Ft&&(r=1,r=D(r,t,s,0),r!==i.check)?wt:(n=zt(e,t,s,s),n?(i.mode=16210,vt):(i.havedict=1,_t)))},qt=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const es=Object.prototype.toString,{Z_NO_FLUSH:ts,Z_FINISH:ss,Z_OK:is,Z_STREAM_END:rs,Z_NEED_DICT:ns,Z_STREAM_ERROR:As,Z_DATA_ERROR:os,Z_MEM_ERROR:as}=O;function ls(e){this.options=He({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ke,this.strm.avail_out=0;let s=Kt(this.strm,t.windowBits);if(s!==is)throw new Error(R[s]);if(this.header=new qt,Yt(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=We(t.dictionary):"[object ArrayBuffer]"===es.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=$t(this.strm,t.dictionary),s!==is)))throw new Error(R[s])}function cs(e,t){const s=new ls(t);if(s.push(e),s.err)throw s.msg||R[s.err];return s.result}ls.prototype.push=function(e,t){const s=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let n,A,o;if(this.ended)return!1;for(A=t===~~t?t:!0===t?ss:ts,"[object ArrayBuffer]"===es.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;;){for(0===s.avail_out&&(s.output=new Uint8Array(i),s.next_out=0,s.avail_out=i),n=Zt(s,A),n===ns&&r&&(n=$t(s,r),n===is?n=Zt(s,A):n===os&&(n=ns));s.avail_in>0&&n===rs&&s.state.wrap>0&&0!==e[s.next_in];)Xt(s),n=Zt(s,A);switch(n){case As:case os:case ns:case as:return this.onEnd(n),this.ended=!0,!1}if(o=s.avail_out,s.next_out&&(0===s.avail_out||n===rs))if("string"===this.options.to){let e=Xe(s.output,s.next_out),t=s.next_out-e,r=ze(s.output,e);s.next_out=t,s.avail_out=i-t,t&&s.output.set(s.output.subarray(e,e+t),0),this.onData(r)}else this.onData(s.output.length===s.next_out?s.output:s.output.subarray(0,s.next_out));if(n!==is||0!==o){if(n===rs)return n=Jt(this.strm),this.onEnd(n),this.ended=!0,!0;if(0===s.avail_in)break}}return!0},ls.prototype.onData=function(e){this.chunks.push(e)},ls.prototype.onEnd=function(e){e===is&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ne(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var hs={Inflate:ls,inflate:cs,inflateRaw:function(e,t){return(t=t||{}).raw=!0,cs(e,t)},ungzip:cs,constants:O};const{Deflate:us,deflate:ds,deflateRaw:ps,gzip:fs}=ot,{Inflate:gs,inflate:ms,inflateRaw:_s,ungzip:bs}=hs;var Bs=us,ys=ds,ws=ps,vs=fs,Cs=gs,Ms=ms,Es=_s,Fs=bs,xs=O,Us={Deflate:Bs,deflate:ys,deflateRaw:ws,gzip:vs,Inflate:Cs,inflate:Ms,inflateRaw:Es,ungzip:Fs,constants:xs};e.Deflate=Bs,e.Inflate=Cs,e.constants=xs,e.default=Us,e.deflate=ys,e.deflateRaw=ws,e.gzip=vs,e.inflate=Ms,e.inflateRaw=Es,e.ungzip=Fs,Object.defineProperty(e,"__esModule",{value:!0})}));var ky=Object.freeze({__proto__:null});let Qy=window.pako||ky;Qy.inflate||(Qy=Qy.default);const Ry=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const Oy={version:1,parse:function(e,t,s,i,r,n){const A=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],meshPositions:e[4],meshIndices:e[5],meshEdgesIndices:e[6],meshColors:e[7],entityIDs:e[8],entityMeshes:e[9],entityIsObjects:e[10],positionsDecodeMatrix:e[11]}}(s),o=function(e){return{positions:new Uint16Array(Qy.inflate(e.positions).buffer),normals:new Int8Array(Qy.inflate(e.normals).buffer),indices:new Uint32Array(Qy.inflate(e.indices).buffer),edgeIndices:new Uint32Array(Qy.inflate(e.edgeIndices).buffer),meshPositions:new Uint32Array(Qy.inflate(e.meshPositions).buffer),meshIndices:new Uint32Array(Qy.inflate(e.meshIndices).buffer),meshEdgesIndices:new Uint32Array(Qy.inflate(e.meshEdgesIndices).buffer),meshColors:new Uint8Array(Qy.inflate(e.meshColors).buffer),entityIDs:Qy.inflate(e.entityIDs,{to:"string"}),entityMeshes:new Uint32Array(Qy.inflate(e.entityMeshes).buffer),entityIsObjects:new Uint8Array(Qy.inflate(e.entityIsObjects).buffer),positionsDecodeMatrix:new Float32Array(Qy.inflate(e.positionsDecodeMatrix).buffer)}}(A);!function(e,t,s,i,r,n){n.getNextId(),i.positionsCompression="precompressed",i.normalsCompression="precompressed";const A=s.positions,o=s.normals,a=s.indices,l=s.edgeIndices,c=s.meshPositions,h=s.meshIndices,u=s.meshEdgesIndices,d=s.meshColors,p=JSON.parse(s.entityIDs),f=s.entityMeshes,g=s.entityIsObjects,m=c.length,_=f.length;for(let r=0;r<_;r++){const n=p[r],b=t.globalizeObjectIds?R.globalizeObjectId(i.id,n):n,B=e.metaScene.metaObjects[b],y={},w={};if(B){if(t.excludeTypesMap&&B.type&&t.excludeTypesMap[B.type])continue;if(t.includeTypesMap&&B.type&&!t.includeTypesMap[B.type])continue;const e=t.objectDefaults?t.objectDefaults[B.type]||t.objectDefaults.DEFAULT:null;e&&(!1===e.visible&&(y.visible=!1),!1===e.pickable&&(y.pickable=!1),e.colorize&&(w.color=e.colorize),void 0!==e.opacity&&null!==e.opacity&&(w.opacity=e.opacity))}else if(t.excludeUnclassifiedObjects)continue;const v=r===_-1,C=[];for(let e=f[r],t=v?f.length:f[r+1];e<t;e++){const t=e===m-1,r=b+".mesh."+e,n=Ry(d.subarray(4*e,4*e+3)),p=d[4*e+3]/255;i.createMesh(j.apply(w,{id:r,primitive:"triangles",positionsCompressed:A.subarray(c[e],t?A.length:c[e+1]),normalsCompressed:o.subarray(c[e],t?A.length:c[e+1]),indices:a.subarray(h[e],t?a.length:h[e+1]),edgeIndices:l.subarray(u[e],t?l.length:u[e+1]),positionsDecodeMatrix:s.positionsDecodeMatrix,color:n,opacity:p})),C.push(r)}i.createEntity(j.apply(y,{id:b,isObject:1===g[r],meshIds:C}))}}(e,t,o,i,0,n)}};let Vy=window.pako||ky;Vy.inflate||(Vy=Vy.default);const Ly=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const Hy={version:2,parse:function(e,t,s,i,r,n){const A=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],meshPositions:e[4],meshIndices:e[5],meshEdgesIndices:e[6],meshColors:e[7],entityIDs:e[8],entityMeshes:e[9],entityIsObjects:e[10],positionsDecodeMatrix:e[11],entityMeshIds:e[12],entityMatrices:e[13],entityUsesInstancing:e[14]}}(s),o=function(e){return{positions:new Uint16Array(Vy.inflate(e.positions).buffer),normals:new Int8Array(Vy.inflate(e.normals).buffer),indices:new Uint32Array(Vy.inflate(e.indices).buffer),edgeIndices:new Uint32Array(Vy.inflate(e.edgeIndices).buffer),meshPositions:new Uint32Array(Vy.inflate(e.meshPositions).buffer),meshIndices:new Uint32Array(Vy.inflate(e.meshIndices).buffer),meshEdgesIndices:new Uint32Array(Vy.inflate(e.meshEdgesIndices).buffer),meshColors:new Uint8Array(Vy.inflate(e.meshColors).buffer),entityIDs:Vy.inflate(e.entityIDs,{to:"string"}),entityMeshes:new Uint32Array(Vy.inflate(e.entityMeshes).buffer),entityIsObjects:new Uint8Array(Vy.inflate(e.entityIsObjects).buffer),positionsDecodeMatrix:new Float32Array(Vy.inflate(e.positionsDecodeMatrix).buffer),entityMeshIds:new Uint32Array(Vy.inflate(e.entityMeshIds).buffer),entityMatrices:new Float32Array(Vy.inflate(e.entityMatrices).buffer),entityUsesInstancing:new Uint8Array(Vy.inflate(e.entityUsesInstancing).buffer)}}(A);!function(e,t,s,i,r,n){const A=n.getNextId();i.positionsCompression="precompressed",i.normalsCompression="precompressed";const o=s.positions,a=s.normals,l=s.indices,c=s.edgeIndices,h=s.meshPositions,u=s.meshIndices,d=s.meshEdgesIndices,p=s.meshColors,f=JSON.parse(s.entityIDs),g=s.entityMeshes,m=s.entityIsObjects,_=s.entityMeshIds,b=s.entityMatrices,B=s.entityUsesInstancing,y=h.length,w=g.length,v={};for(let r=0;r<w;r++){const C=f[r],M=t.globalizeObjectIds?R.globalizeObjectId(i.id,C):C,E=e.metaScene.metaObjects[M],F={},x={},U=b.subarray(16*r,16*r+16);if(E){if(t.excludeTypesMap&&E.type&&t.excludeTypesMap[E.type])continue;if(t.includeTypesMap&&E.type&&!t.includeTypesMap[E.type])continue;const e=t.objectDefaults?t.objectDefaults[E.type]||t.objectDefaults.DEFAULT:null;e&&(!1===e.visible&&(F.visible=!1),!1===e.pickable&&(F.pickable=!1),e.colorize&&(x.color=e.colorize),void 0!==e.opacity&&null!==e.opacity&&(x.opacity=e.opacity))}else if(t.excludeUnclassifiedObjects)continue;const I=r===w-1,T=[];for(let e=g[r],t=I?_.length:g[r+1];e<t;e++){const t=_[e],f=t===y-1,g=n.getNextId(),m=Ly(p.subarray(4*t,4*t+3)),b=p[4*t+3]/255,w=o.subarray(h[t],f?o.length:h[t+1]),C=a.subarray(h[t],f?o.length:h[t+1]),M=l.subarray(u[t],f?l.length:u[t+1]),E=c.subarray(d[t],f?c.length:d[t+1]);if(1===B[r]){const e=`${A}.geometry.${g}.${t}`;e in v||(i.createGeometry({id:e,positionsCompressed:w,normalsCompressed:C,indices:M,edgeIndices:E,primitive:"triangles",positionsDecodeMatrix:s.positionsDecodeMatrix}),v[e]=!0),i.createMesh(j.apply(x,{id:g,color:m,opacity:b,matrix:U,geometryId:e})),T.push(g)}else i.createMesh(j.apply(x,{id:g,primitive:"triangles",positionsCompressed:w,normalsCompressed:C,indices:M,edgeIndices:E,positionsDecodeMatrix:s.positionsDecodeMatrix,color:m,opacity:b})),T.push(g)}T.length&&i.createEntity(j.apply(F,{id:M,isObject:1===m[r],meshIds:T}))}}(e,t,o,i,0,n)}};let Ny=window.pako||ky;Ny.inflate||(Ny=Ny.default);const Gy=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const jy={version:3,parse:function(e,t,s,i,r,n){const A=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],meshPositions:e[4],meshIndices:e[5],meshEdgesIndices:e[6],meshColors:e[7],entityIDs:e[8],entityMeshes:e[9],entityIsObjects:e[10],instancedPositionsDecodeMatrix:e[11],batchedPositionsDecodeMatrix:e[12],entityMeshIds:e[13],entityMatrices:e[14],entityUsesInstancing:e[15]}}(s),o=function(e){return{positions:new Uint16Array(Ny.inflate(e.positions).buffer),normals:new Int8Array(Ny.inflate(e.normals).buffer),indices:new Uint32Array(Ny.inflate(e.indices).buffer),edgeIndices:new Uint32Array(Ny.inflate(e.edgeIndices).buffer),meshPositions:new Uint32Array(Ny.inflate(e.meshPositions).buffer),meshIndices:new Uint32Array(Ny.inflate(e.meshIndices).buffer),meshEdgesIndices:new Uint32Array(Ny.inflate(e.meshEdgesIndices).buffer),meshColors:new Uint8Array(Ny.inflate(e.meshColors).buffer),entityIDs:Ny.inflate(e.entityIDs,{to:"string"}),entityMeshes:new Uint32Array(Ny.inflate(e.entityMeshes).buffer),entityIsObjects:new Uint8Array(Ny.inflate(e.entityIsObjects).buffer),instancedPositionsDecodeMatrix:new Float32Array(Ny.inflate(e.instancedPositionsDecodeMatrix).buffer),batchedPositionsDecodeMatrix:new Float32Array(Ny.inflate(e.batchedPositionsDecodeMatrix).buffer),entityMeshIds:new Uint32Array(Ny.inflate(e.entityMeshIds).buffer),entityMatrices:new Float32Array(Ny.inflate(e.entityMatrices).buffer),entityUsesInstancing:new Uint8Array(Ny.inflate(e.entityUsesInstancing).buffer)}}(A);!function(e,t,s,i,r,n){const A=n.getNextId();i.positionsCompression="precompressed",i.normalsCompression="precompressed";const o=s.positions,a=s.normals,l=s.indices,c=s.edgeIndices,h=s.meshPositions,u=s.meshIndices,d=s.meshEdgesIndices,p=s.meshColors,f=JSON.parse(s.entityIDs),g=s.entityMeshes,m=s.entityIsObjects,_=s.entityMeshIds,b=s.entityMatrices,B=s.entityUsesInstancing,y=h.length,w=g.length,v={};for(let r=0;r<w;r++){const n=f[r],U=t.globalizeObjectIds?R.globalizeObjectId(i.id,n):n,I=e.metaScene.metaObjects[U],T={},P={},S=b.subarray(16*r,16*r+16);if(I){if(t.excludeTypesMap&&I.type&&t.excludeTypesMap[I.type])continue;if(t.includeTypesMap&&I.type&&!t.includeTypesMap[I.type])continue;const e=t.objectDefaults?t.objectDefaults[I.type]||t.objectDefaults.DEFAULT:null;e&&(!1===e.visible&&(T.visible=!1),!1===e.pickable&&(T.pickable=!1),e.colorize&&(P.color=e.colorize),void 0!==e.opacity&&null!==e.opacity&&(P.opacity=e.opacity))}else if(t.excludeUnclassifiedObjects)continue;const D=r===w-1,k=[];for(let e=g[r],t=D?_.length:g[r+1];e<t;e++){var C=_[e];const t=C===y-1,n=`${A}.${U}.mesh.${C}`,f=Gy(p.subarray(4*C,4*C+3)),g=p[4*C+3]/255;var M=o.subarray(h[C],t?o.length:h[C+1]),E=a.subarray(h[C],t?o.length:h[C+1]),F=l.subarray(u[C],t?l.length:u[C+1]),x=c.subarray(d[C],t?c.length:d[C+1]);if(1===B[r]){const e=`${A}.geometry.${n}.${C}`;e in v||(i.createGeometry({id:e,positionsCompressed:M,normalsCompressed:E,indices:F,edgeIndices:x,primitive:"triangles",positionsDecodeMatrix:s.instancedPositionsDecodeMatrix}),v[e]=!0),i.createMesh(j.apply(P,{id:n,color:f,opacity:g,matrix:S,geometryId:e})),k.push(n)}else i.createMesh(j.apply(P,{id:n,primitive:"triangles",positionsCompressed:M,normalsCompressed:E,indices:F,edgeIndices:x,positionsDecodeMatrix:s.batchedPositionsDecodeMatrix,color:f,opacity:g})),k.push(n)}k.length&&i.createEntity(j.apply(T,{id:U,isObject:1===m[r],meshIds:k}))}}(e,t,o,i,0,n)}};let Wy=window.pako||ky;Wy.inflate||(Wy=Wy.default);const zy=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const Xy={version:4,parse:function(e,t,s,i,r,n){const A=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],decodeMatrices:e[4],matrices:e[5],eachPrimitivePositionsAndNormalsPortion:e[6],eachPrimitiveIndicesPortion:e[7],eachPrimitiveEdgeIndicesPortion:e[8],eachPrimitiveDecodeMatricesPortion:e[9],eachPrimitiveColor:e[10],primitiveInstances:e[11],eachEntityId:e[12],eachEntityPrimitiveInstancesPortion:e[13],eachEntityMatricesPortion:e[14],eachEntityMatrix:e[15]}}(s),o=function(e){return{positions:new Uint16Array(Wy.inflate(e.positions).buffer),normals:new Int8Array(Wy.inflate(e.normals).buffer),indices:new Uint32Array(Wy.inflate(e.indices).buffer),edgeIndices:new Uint32Array(Wy.inflate(e.edgeIndices).buffer),decodeMatrices:new Float32Array(Wy.inflate(e.decodeMatrices).buffer),matrices:new Float32Array(Wy.inflate(e.matrices).buffer),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(Wy.inflate(e.eachPrimitivePositionsAndNormalsPortion).buffer),eachPrimitiveIndicesPortion:new Uint32Array(Wy.inflate(e.eachPrimitiveIndicesPortion).buffer),eachPrimitiveEdgeIndicesPortion:new Uint32Array(Wy.inflate(e.eachPrimitiveEdgeIndicesPortion).buffer),eachPrimitiveDecodeMatricesPortion:new Uint32Array(Wy.inflate(e.eachPrimitiveDecodeMatricesPortion).buffer),eachPrimitiveColor:new Uint8Array(Wy.inflate(e.eachPrimitiveColor).buffer),primitiveInstances:new Uint32Array(Wy.inflate(e.primitiveInstances).buffer),eachEntityId:Wy.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(Wy.inflate(e.eachEntityPrimitiveInstancesPortion).buffer),eachEntityMatricesPortion:new Uint32Array(Wy.inflate(e.eachEntityMatricesPortion).buffer)}}(A);!function(e,t,s,i,r,n){const A=n.getNextId();i.positionsCompression="precompressed",i.normalsCompression="precompressed";const o=s.positions,a=s.normals,l=s.indices,c=s.edgeIndices,h=s.decodeMatrices,u=s.matrices,d=s.eachPrimitivePositionsAndNormalsPortion,p=s.eachPrimitiveIndicesPortion,f=s.eachPrimitiveEdgeIndicesPortion,g=s.eachPrimitiveDecodeMatricesPortion,m=s.eachPrimitiveColor,_=s.primitiveInstances,b=JSON.parse(s.eachEntityId),B=s.eachEntityPrimitiveInstancesPortion,y=s.eachEntityMatricesPortion,w=d.length,v=_.length,C=new Uint8Array(w),M=new Uint32Array(w),E=b.length;for(let e=0;e<w;e++)M[e]=e;M.sort(((e,t)=>g[e]<g[t]?-1:g[e]>g[t]?1:0));for(let e=0;e<v;e++)C[_[e]]++;const F={};for(let e=0;e<E;e++){const t=E-1,s=e===t,i=B[e],r=s?B[t]:B[e+1];for(let t=i;t<r;t++){const s=_[t];C[s]>1||(F[s]=e)}}for(let e=0;e<w;e++){const t=M[e],s=t===w-1,r=C[t]>1,n=zy(m.subarray(4*t,4*t+3)),u=m[4*t+3]/255,_=o.subarray(d[t],s?o.length:d[t+1]),B=a.subarray(d[t],s?a.length:d[t+1]),y=l.subarray(p[t],s?l.length:p[t+1]),v=c.subarray(f[t],s?c.length:f[t+1]),E=h.subarray(g[t],g[t]+16);if(r){const e=`${A}-geometry.${t}`;i.createGeometry({id:e,primitive:"triangles",positionsCompressed:_,normalsCompressed:B,indices:y,edgeIndices:v,positionsDecodeMatrix:E})}else{const e=`${A}-${t}`;b[F[t]];const s={};i.createMesh(j.apply(s,{id:e,primitive:"triangles",positionsCompressed:_,normalsCompressed:B,indices:y,edgeIndices:v,positionsDecodeMatrix:E,color:n,opacity:u}))}}let x=0;for(let e=0;e<E;e++){const t=E-1,s=e===t,r=b[e],n=B[e],o=s?B[t]:B[e+1],a=[];for(let t=n;t<o;t++){const s=_[t];if(C[s]>1){const t={},r=`${A}-instance.${x++}`,n=`${A}-geometry.${s}`,o=16*y[e],l=u.subarray(o,o+16);i.createMesh(j.apply(t,{id:r,geometryId:n,matrix:l})),a.push(r)}else a.push(s)}if(a.length>0){const e={};i.createEntity(j.apply(e,{id:r,isObject:!0,meshIds:a}))}}}(0,0,o,i,0,n)}};let Ky=window.pako||ky;Ky.inflate||(Ky=Ky.default);const Zy=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const Jy={version:5,parse:function(e,t,s,i,r,n){const A=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],matrices:e[4],eachPrimitivePositionsAndNormalsPortion:e[5],eachPrimitiveIndicesPortion:e[6],eachPrimitiveEdgeIndicesPortion:e[7],eachPrimitiveColor:e[8],primitiveInstances:e[9],eachEntityId:e[10],eachEntityPrimitiveInstancesPortion:e[11],eachEntityMatricesPortion:e[12]}}(s),o=function(e){return{positions:new Float32Array(Ky.inflate(e.positions).buffer),normals:new Int8Array(Ky.inflate(e.normals).buffer),indices:new Uint32Array(Ky.inflate(e.indices).buffer),edgeIndices:new Uint32Array(Ky.inflate(e.edgeIndices).buffer),matrices:new Float32Array(Ky.inflate(e.matrices).buffer),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(Ky.inflate(e.eachPrimitivePositionsAndNormalsPortion).buffer),eachPrimitiveIndicesPortion:new Uint32Array(Ky.inflate(e.eachPrimitiveIndicesPortion).buffer),eachPrimitiveEdgeIndicesPortion:new Uint32Array(Ky.inflate(e.eachPrimitiveEdgeIndicesPortion).buffer),eachPrimitiveColor:new Uint8Array(Ky.inflate(e.eachPrimitiveColor).buffer),primitiveInstances:new Uint32Array(Ky.inflate(e.primitiveInstances).buffer),eachEntityId:Ky.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(Ky.inflate(e.eachEntityPrimitiveInstancesPortion).buffer),eachEntityMatricesPortion:new Uint32Array(Ky.inflate(e.eachEntityMatricesPortion).buffer)}}(A);!function(e,t,s,i,r,n){const A=n.getNextId();i.positionsCompression="disabled",i.normalsCompression="precompressed";const o=s.positions,a=s.normals,l=s.indices,c=s.edgeIndices,h=s.matrices,u=s.eachPrimitivePositionsAndNormalsPortion,d=s.eachPrimitiveIndicesPortion,p=s.eachPrimitiveEdgeIndicesPortion,f=s.eachPrimitiveColor,g=s.primitiveInstances,m=JSON.parse(s.eachEntityId),_=s.eachEntityPrimitiveInstancesPortion,b=s.eachEntityMatricesPortion,B=u.length,y=g.length,w=new Uint8Array(B),v=m.length;for(let e=0;e<y;e++)w[g[e]]++;const C={};for(let e=0;e<v;e++){const t=v-1,s=e===t,i=_[e],r=s?_[t]:_[e+1];for(let t=i;t<r;t++){const s=g[t];w[s]>1||(C[s]=e)}}for(let e=0;e<B;e++){const t=e===B-1,s=w[e]>1,r=Zy(f.subarray(4*e,4*e+3)),n=f[4*e+3]/255,h=o.subarray(u[e],t?o.length:u[e+1]),g=a.subarray(u[e],t?a.length:u[e+1]),_=l.subarray(d[e],t?l.length:d[e+1]),b=c.subarray(p[e],t?c.length:p[e+1]);if(s){const t=`${A}-geometry.${e}`;i.createGeometry({id:t,primitive:"triangles",positionsCompressed:h,normalsCompressed:g,indices:_,edgeIndices:b})}else{const t=e;m[C[e]];const s={};i.createMesh(j.apply(s,{id:t,primitive:"triangles",positionsCompressed:h,normalsCompressed:g,indices:_,edgeIndices:b,color:r,opacity:n}))}}let M=0;for(let e=0;e<v;e++){const t=v-1,s=e===t,r=m[e],n=_[e],A=s?_[t]:_[e+1],o=[];for(let t=n;t<A;t++){const s=g[t];if(w[s]>1){const t={},r="instance."+M++,n="geometry"+s,A=16*b[e],a=h.subarray(A,A+16);i.createMesh(j.apply(t,{id:r,geometryId:n,matrix:a})),o.push(r)}else o.push(s)}if(o.length>0){const e={};i.createEntity(j.apply(e,{id:r,isObject:!0,meshIds:o}))}}}(0,0,o,i,0,n)}};let Yy=window.pako||ky;Yy.inflate||(Yy=Yy.default);const $y=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const qy={version:6,parse:function(e,t,s,i,r,n){const A=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],matrices:e[4],reusedPrimitivesDecodeMatrix:e[5],eachPrimitivePositionsAndNormalsPortion:e[6],eachPrimitiveIndicesPortion:e[7],eachPrimitiveEdgeIndicesPortion:e[8],eachPrimitiveColorAndOpacity:e[9],primitiveInstances:e[10],eachEntityId:e[11],eachEntityPrimitiveInstancesPortion:e[12],eachEntityMatricesPortion:e[13],eachTileAABB:e[14],eachTileEntitiesPortion:e[15]}}(s),o=function(e){function t(e,t){return 0===e.length?[]:Yy.inflate(e,t).buffer}return{positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),matrices:new Float32Array(t(e.matrices)),reusedPrimitivesDecodeMatrix:new Float32Array(t(e.reusedPrimitivesDecodeMatrix)),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(t(e.eachPrimitivePositionsAndNormalsPortion)),eachPrimitiveIndicesPortion:new Uint32Array(t(e.eachPrimitiveIndicesPortion)),eachPrimitiveEdgeIndicesPortion:new Uint32Array(t(e.eachPrimitiveEdgeIndicesPortion)),eachPrimitiveColorAndOpacity:new Uint8Array(t(e.eachPrimitiveColorAndOpacity)),primitiveInstances:new Uint32Array(t(e.primitiveInstances)),eachEntityId:Yy.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(t(e.eachEntityPrimitiveInstancesPortion)),eachEntityMatricesPortion:new Uint32Array(t(e.eachEntityMatricesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(A);!function(e,t,s,i,r,n){const A=n.getNextId(),o=s.positions,a=s.normals,l=s.indices,c=s.edgeIndices,h=s.matrices,u=s.reusedPrimitivesDecodeMatrix,d=s.eachPrimitivePositionsAndNormalsPortion,p=s.eachPrimitiveIndicesPortion,f=s.eachPrimitiveEdgeIndicesPortion,g=s.eachPrimitiveColorAndOpacity,m=s.primitiveInstances,_=JSON.parse(s.eachEntityId),b=s.eachEntityPrimitiveInstancesPortion,B=s.eachEntityMatricesPortion,y=s.eachTileAABB,w=s.eachTileEntitiesPortion,v=d.length,C=m.length,M=_.length,E=w.length,F=new Uint32Array(v);for(let e=0;e<C;e++){const t=m[e];void 0!==F[t]?F[t]++:F[t]=1}const x=R.vec3(),U=R.AABB3();for(let s=0;s<E;s++){const r=s===E-1,C=w[s],I=r?M:w[s+1],T=6*s,P=y.subarray(T,T+6);R.getAABB3Center(P,x),U[0]=P[0]-x[0],U[1]=P[1]-x[1],U[2]=P[2]-x[2],U[3]=P[3]-x[0],U[4]=P[4]-x[1],U[5]=P[5]-x[2];const S=Re.createPositionsDecodeMatrix(U),D={};for(let r=C;r<I;r++){const y=_[r],w=t.globalizeObjectIds?R.globalizeObjectId(i.id,y):y,C=B[r],E=h.slice(C,C+16),U=r===M-1,I=b[r],T=U?m.length:b[r+1],P=[],k=e.metaScene.metaObjects[w],Q={},O={};if(k){if(t.excludeTypesMap&&k.type&&t.excludeTypesMap[k.type])continue;if(t.includeTypesMap&&k.type&&!t.includeTypesMap[k.type])continue;if(t.includeIdsMap&&k.id&&!t.includeIdsMap[k.id])continue;const e=t.objectDefaults?t.objectDefaults[k.type]||t.objectDefaults.DEFAULT:null;e&&(!1===e.visible&&(Q.visible=!1),!1===e.pickable&&(Q.pickable=!1),e.colorize&&(O.color=e.colorize),void 0!==e.opacity&&null!==e.opacity&&(O.opacity=e.opacity))}else if(t.excludeUnclassifiedObjects)continue;for(let e=I;e<T;e++){const t=m[e],r=F[t]>1,h=t===v-1,_=o.subarray(d[t],h?o.length:d[t+1]),b=a.subarray(d[t],h?a.length:d[t+1]),B=l.subarray(p[t],h?l.length:p[t+1]),y=c.subarray(f[t],h?c.length:f[t+1]),w=$y(g.subarray(4*t,4*t+3)),C=g[4*t+3]/255,M=n.getNextId();if(r){const e=`${A}-geometry.${s}.${t}`;D[e]||(i.createGeometry({id:e,primitive:"triangles",positionsCompressed:_,indices:B,edgeIndices:y,positionsDecodeMatrix:u}),D[e]=!0),i.createMesh(j.apply(O,{id:M,geometryId:e,origin:x,matrix:E,color:w,opacity:C})),P.push(M)}else i.createMesh(j.apply(O,{id:M,origin:x,primitive:"triangles",positionsCompressed:_,normalsCompressed:b,indices:B,edgeIndices:y,positionsDecodeMatrix:S,color:w,opacity:C})),P.push(M)}P.length>0&&i.createEntity(j.apply(Q,{id:w,isObject:!0,meshIds:P}))}}}(e,t,o,i,0,n)}};let ew=window.pako||ky;ew.inflate||(ew=ew.default);const tw=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function sw(e){const t=[];for(let s=0,i=e.length;s<i;s+=3)t.push(e[s]),t.push(e[s+1]),t.push(e[s+2]),t.push(1);return t}const iw={version:7,parse:function(e,t,s,i,r,n){const A=function(e){return{positions:e[0],normals:e[1],colors:e[2],indices:e[3],edgeIndices:e[4],matrices:e[5],reusedGeometriesDecodeMatrix:e[6],eachGeometryPrimitiveType:e[7],eachGeometryPositionsPortion:e[8],eachGeometryNormalsPortion:e[9],eachGeometryColorsPortion:e[10],eachGeometryIndicesPortion:e[11],eachGeometryEdgeIndicesPortion:e[12],eachMeshGeometriesPortion:e[13],eachMeshMatricesPortion:e[14],eachMeshMaterial:e[15],eachEntityId:e[16],eachEntityMeshesPortion:e[17],eachTileAABB:e[18],eachTileEntitiesPortion:e[19]}}(s),o=function(e){function t(e,t){return 0===e.length?[]:ew.inflate(e,t).buffer}return{positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),colors:new Uint8Array(t(e.colors)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),matrices:new Float32Array(t(e.matrices)),reusedGeometriesDecodeMatrix:new Float32Array(t(e.reusedGeometriesDecodeMatrix)),eachGeometryPrimitiveType:new Uint8Array(t(e.eachGeometryPrimitiveType)),eachGeometryPositionsPortion:new Uint32Array(t(e.eachGeometryPositionsPortion)),eachGeometryNormalsPortion:new Uint32Array(t(e.eachGeometryNormalsPortion)),eachGeometryColorsPortion:new Uint32Array(t(e.eachGeometryColorsPortion)),eachGeometryIndicesPortion:new Uint32Array(t(e.eachGeometryIndicesPortion)),eachGeometryEdgeIndicesPortion:new Uint32Array(t(e.eachGeometryEdgeIndicesPortion)),eachMeshGeometriesPortion:new Uint32Array(t(e.eachMeshGeometriesPortion)),eachMeshMatricesPortion:new Uint32Array(t(e.eachMeshMatricesPortion)),eachMeshMaterial:new Uint8Array(t(e.eachMeshMaterial)),eachEntityId:ew.inflate(e.eachEntityId,{to:"string"}),eachEntityMeshesPortion:new Uint32Array(t(e.eachEntityMeshesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(A);!function(e,t,s,i,r,n){const A=n.getNextId(),o=s.positions,a=s.normals,l=s.colors,c=s.indices,h=s.edgeIndices,u=s.matrices,d=s.reusedGeometriesDecodeMatrix,p=s.eachGeometryPrimitiveType,f=s.eachGeometryPositionsPortion,g=s.eachGeometryNormalsPortion,m=s.eachGeometryColorsPortion,_=s.eachGeometryIndicesPortion,b=s.eachGeometryEdgeIndicesPortion,B=s.eachMeshGeometriesPortion,y=s.eachMeshMatricesPortion,w=s.eachMeshMaterial,v=JSON.parse(s.eachEntityId),C=s.eachEntityMeshesPortion,M=s.eachTileAABB,E=s.eachTileEntitiesPortion,F=f.length,x=B.length,U=v.length,I=E.length,T=new Uint32Array(F);for(let e=0;e<x;e++){const t=B[e];void 0!==T[t]?T[t]++:T[t]=1}const P=R.vec3(),S=R.AABB3();for(let s=0;s<I;s++){const r=s===I-1,x=E[s],D=r?U:E[s+1],k=6*s,Q=M.subarray(k,k+6);R.getAABB3Center(Q,P),S[0]=Q[0]-P[0],S[1]=Q[1]-P[1],S[2]=Q[2]-P[2],S[3]=Q[3]-P[0],S[4]=Q[4]-P[1],S[5]=Q[5]-P[2];const O=Re.createPositionsDecodeMatrix(S),V={};for(let r=x;r<D;r++){const M=v[r],E=t.globalizeObjectIds?R.globalizeObjectId(i.id,M):M,x=r===U-1,I=C[r],S=x?B.length:C[r+1],D=[],k=e.metaScene.metaObjects[E],Q={},L={};if(k){if(t.excludeTypesMap&&k.type&&t.excludeTypesMap[k.type])continue;if(t.includeTypesMap&&k.type&&!t.includeTypesMap[k.type])continue;if(t.includeIdsMap&&k.id&&!t.includeIdsMap[k.id])continue;const e=t.objectDefaults?t.objectDefaults[k.type]||t.objectDefaults.DEFAULT:null;e&&(!1===e.visible&&(Q.visible=!1),!1===e.pickable&&(Q.pickable=!1),e.colorize&&(L.color=e.colorize),void 0!==e.opacity&&null!==e.opacity&&(L.opacity=e.opacity),void 0!==e.metallic&&null!==e.metallic&&(L.metallic=e.metallic),void 0!==e.roughness&&null!==e.roughness&&(L.roughness=e.roughness))}else if(t.excludeUnclassifiedObjects)continue;for(let e=I;e<S;e++){const t=B[e],r=T[t]>1,v=t===F-1,C=tw(w.subarray(6*e,6*e+3)),M=w[6*e+3]/255,E=w[6*e+4]/255,x=w[6*e+5]/255,U=n.getNextId();if(r){const r=y[e],n=u.slice(r,r+16),B=`${A}-geometry.${s}.${t}`;if(!V[B]){let e,s,r,n,A,u;switch(p[t]){case 0:e="solid",s=o.subarray(f[t],v?o.length:f[t+1]),r=a.subarray(g[t],v?a.length:g[t+1]),A=c.subarray(_[t],v?c.length:_[t+1]),u=h.subarray(b[t],v?h.length:b[t+1]);break;case 1:e="surface",s=o.subarray(f[t],v?o.length:f[t+1]),r=a.subarray(g[t],v?a.length:g[t+1]),A=c.subarray(_[t],v?c.length:_[t+1]),u=h.subarray(b[t],v?h.length:b[t+1]);break;case 2:e="points",s=o.subarray(f[t],v?o.length:f[t+1]),n=sw(l.subarray(m[t],v?l.length:m[t+1]));break;case 3:e="lines",s=o.subarray(f[t],v?o.length:f[t+1]),A=c.subarray(_[t],v?c.length:_[t+1]);break;default:continue}i.createGeometry({id:B,primitive:e,positionsCompressed:s,normalsCompressed:r,colors:n,indices:A,edgeIndices:u,positionsDecodeMatrix:d}),V[B]=!0}i.createMesh(j.apply(L,{id:U,geometryId:B,origin:P,matrix:n,color:C,metallic:E,roughness:x,opacity:M})),D.push(U)}else{let e,s,r,n,A,u;switch(p[t]){case 0:e="solid",s=o.subarray(f[t],v?o.length:f[t+1]),r=a.subarray(g[t],v?a.length:g[t+1]),A=c.subarray(_[t],v?c.length:_[t+1]),u=h.subarray(b[t],v?h.length:b[t+1]);break;case 1:e="surface",s=o.subarray(f[t],v?o.length:f[t+1]),r=a.subarray(g[t],v?a.length:g[t+1]),A=c.subarray(_[t],v?c.length:_[t+1]),u=h.subarray(b[t],v?h.length:b[t+1]);break;case 2:e="points",s=o.subarray(f[t],v?o.length:f[t+1]),n=sw(l.subarray(m[t],v?l.length:m[t+1]));break;case 3:e="lines",s=o.subarray(f[t],v?o.length:f[t+1]),A=c.subarray(_[t],v?c.length:_[t+1]);break;default:continue}i.createMesh(j.apply(L,{id:U,origin:P,primitive:e,positionsCompressed:s,normalsCompressed:r,colors:n,indices:A,edgeIndices:u,positionsDecodeMatrix:O,color:C,metallic:E,roughness:x,opacity:M})),D.push(U)}}D.length>0&&i.createEntity(j.apply(Q,{id:E,isObject:!0,meshIds:D}))}}}(e,t,o,i,0,n)}};let rw=window.pako||ky;rw.inflate||(rw=rw.default);const nw=R.vec4(),Aw=R.vec4();const ow=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function aw(e){const t=[];for(let s=0,i=e.length;s<i;s+=3)t.push(e[s]),t.push(e[s+1]),t.push(e[s+2]),t.push(1);return t}const lw={version:8,parse:function(e,t,s,i,r,n){const A=function(e){return{types:e[0],eachMetaObjectId:e[1],eachMetaObjectType:e[2],eachMetaObjectName:e[3],eachMetaObjectParent:e[4],positions:e[5],normals:e[6],colors:e[7],indices:e[8],edgeIndices:e[9],matrices:e[10],reusedGeometriesDecodeMatrix:e[11],eachGeometryPrimitiveType:e[12],eachGeometryPositionsPortion:e[13],eachGeometryNormalsPortion:e[14],eachGeometryColorsPortion:e[15],eachGeometryIndicesPortion:e[16],eachGeometryEdgeIndicesPortion:e[17],eachMeshGeometriesPortion:e[18],eachMeshMatricesPortion:e[19],eachMeshMaterial:e[20],eachEntityMetaObject:e[21],eachEntityMeshesPortion:e[22],eachTileAABB:e[23],eachTileEntitiesPortion:e[24]}}(s),o=function(e){function t(e,t){return 0===e.length?[]:rw.inflate(e,t).buffer}return{types:rw.inflate(e.types,{to:"string"}),eachMetaObjectId:rw.inflate(e.eachMetaObjectId,{to:"string"}),eachMetaObjectType:new Uint32Array(t(e.eachMetaObjectType)),eachMetaObjectName:rw.inflate(e.eachMetaObjectName,{to:"string"}),eachMetaObjectParent:new Uint32Array(t(e.eachMetaObjectParent)),positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),colors:new Uint8Array(t(e.colors)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),matrices:new Float32Array(t(e.matrices)),reusedGeometriesDecodeMatrix:new Float32Array(t(e.reusedGeometriesDecodeMatrix)),eachGeometryPrimitiveType:new Uint8Array(t(e.eachGeometryPrimitiveType)),eachGeometryPositionsPortion:new Uint32Array(t(e.eachGeometryPositionsPortion)),eachGeometryNormalsPortion:new Uint32Array(t(e.eachGeometryNormalsPortion)),eachGeometryColorsPortion:new Uint32Array(t(e.eachGeometryColorsPortion)),eachGeometryIndicesPortion:new Uint32Array(t(e.eachGeometryIndicesPortion)),eachGeometryEdgeIndicesPortion:new Uint32Array(t(e.eachGeometryEdgeIndicesPortion)),eachMeshGeometriesPortion:new Uint32Array(t(e.eachMeshGeometriesPortion)),eachMeshMatricesPortion:new Uint32Array(t(e.eachMeshMatricesPortion)),eachMeshMaterial:new Uint8Array(t(e.eachMeshMaterial)),eachEntityMetaObject:new Uint32Array(t(e.eachEntityMetaObject)),eachEntityMeshesPortion:new Uint32Array(t(e.eachEntityMeshesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(A);!function(e,t,s,i,r,n){const A=n.getNextId(),o=JSON.parse(s.types),a=JSON.parse(s.eachMetaObjectId),l=s.eachMetaObjectType,c=JSON.parse(s.eachMetaObjectName),h=s.eachMetaObjectParent,u=s.positions,d=s.normals,p=s.colors,f=s.indices,g=s.edgeIndices,m=s.matrices,_=s.reusedGeometriesDecodeMatrix,b=s.eachGeometryPrimitiveType,B=s.eachGeometryPositionsPortion,y=s.eachGeometryNormalsPortion,w=s.eachGeometryColorsPortion,v=s.eachGeometryIndicesPortion,C=s.eachGeometryEdgeIndicesPortion,M=s.eachMeshGeometriesPortion,E=s.eachMeshMatricesPortion,F=s.eachMeshMaterial,x=s.eachEntityMetaObject,U=s.eachEntityMeshesPortion,I=s.eachTileAABB,T=s.eachTileEntitiesPortion,P=a.length,S=B.length,D=M.length,k=x.length,Q=T.length;if(r){const e={metaObjects:[]};for(let t=0;t<P;t++){const s=a[t],i=o[l[t]]||"default",r=c[t],n=h[t],A=n!==t?a[n]:null;e.metaObjects.push({id:s,type:i,name:r,parent:A})}r.loadData(e,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes,globalizeObjectIds:t.globalizeObjectIds})}const O=new Uint32Array(S);for(let e=0;e<D;e++){const t=M[e];void 0!==O[t]?O[t]++:O[t]=1}const V=R.vec3(),L=R.AABB3(),H={};for(let s=0;s<Q;s++){const r=s===Q-1,o=T[s],l=r?k:T[s+1],c=6*s,h=I.subarray(c,c+6);R.getAABB3Center(h,V),L[0]=h[0]-V[0],L[1]=h[1]-V[1],L[2]=h[2]-V[2],L[3]=h[3]-V[0],L[4]=h[4]-V[1],L[5]=h[5]-V[2];const P=Re.createPositionsDecodeMatrix(L),D={};for(let r=o;r<l;r++){const o=a[x[r]],l=t.globalizeObjectIds?R.globalizeObjectId(i.id,o):o,c=r===k-1,h=U[r],I=c?M.length:U[r+1],T=[],Q=e.metaScene.metaObjects[l],N={},G={};if(Q){if(t.excludeTypesMap&&Q.type&&t.excludeTypesMap[Q.type])continue;if(t.includeTypesMap&&Q.type&&!t.includeTypesMap[Q.type])continue;if(t.includeIdsMap&&Q.id&&!t.includeIdsMap[Q.id])continue;const e=t.objectDefaults?t.objectDefaults[Q.type]||t.objectDefaults.DEFAULT:null;e&&(!1===e.visible&&(N.visible=!1),!1===e.pickable&&(N.pickable=!1),e.colorize&&(G.color=e.colorize),void 0!==e.opacity&&null!==e.opacity&&(G.opacity=e.opacity),void 0!==e.metallic&&null!==e.metallic&&(G.metallic=e.metallic),void 0!==e.roughness&&null!==e.roughness&&(G.roughness=e.roughness))}else if(t.excludeUnclassifiedObjects)continue;for(let e=h;e<I;e++){const r=M[e],o=O[r]>1,a=r===S-1,l=ow(F.subarray(6*e,6*e+3)),c=F[6*e+3]/255,h=F[6*e+4]/255,x=F[6*e+5]/255,U=n.getNextId();if(o){const n=E[e],o=m.slice(n,n+16),M=`${A}-geometry.${s}.${r}`;let F=H[M];if(!F){F={batchThisMesh:!t.reuseGeometries};let e=!1;switch(b[r]){case 0:F.primitiveName="solid",F.geometryPositions=u.subarray(B[r],a?u.length:B[r+1]),F.geometryNormals=d.subarray(y[r],a?d.length:y[r+1]),F.geometryIndices=f.subarray(v[r],a?f.length:v[r+1]),F.geometryEdgeIndices=g.subarray(C[r],a?g.length:C[r+1]),e=F.geometryPositions.length>0&&F.geometryIndices.length>0;break;case 1:F.primitiveName="surface",F.geometryPositions=u.subarray(B[r],a?u.length:B[r+1]),F.geometryNormals=d.subarray(y[r],a?d.length:y[r+1]),F.geometryIndices=f.subarray(v[r],a?f.length:v[r+1]),F.geometryEdgeIndices=g.subarray(C[r],a?g.length:C[r+1]),e=F.geometryPositions.length>0&&F.geometryIndices.length>0;break;case 2:F.primitiveName="points",F.geometryPositions=u.subarray(B[r],a?u.length:B[r+1]),F.geometryColors=aw(p.subarray(w[r],a?p.length:w[r+1])),e=F.geometryPositions.length>0;break;case 3:F.primitiveName="lines",F.geometryPositions=u.subarray(B[r],a?u.length:B[r+1]),F.geometryIndices=f.subarray(v[r],a?f.length:v[r+1]),e=F.geometryPositions.length>0&&F.geometryIndices.length>0;break;default:continue}if(e||(F=null),F&&(F.geometryPositions.length,F.batchThisMesh)){F.decompressedPositions=new Float32Array(F.geometryPositions.length);const e=F.geometryPositions,t=F.decompressedPositions;for(let s=0,i=e.length;s<i;s+=3)t[s+0]=e[s+0]*_[0]+_[12],t[s+1]=e[s+1]*_[5]+_[13],t[s+2]=e[s+2]*_[10]+_[14];F.geometryPositions=null,H[M]=F}}if(F)if(F.batchThisMesh){const e=F.decompressedPositions,t=new Uint16Array(e.length);for(let s=0,i=e.length;s<i;s+=3)nw[0]=e[s+0],nw[1]=e[s+1],nw[2]=e[s+2],nw[3]=1,R.transformVec4(o,nw,Aw),Re.compressPosition(Aw,L,nw),t[s+0]=nw[0],t[s+1]=nw[1],t[s+2]=nw[2];i.createMesh(j.apply(G,{id:U,origin:V,primitive:F.primitiveName,positionsCompressed:t,normalsCompressed:F.geometryNormals,colorsCompressed:F.geometryColors,indices:F.geometryIndices,edgeIndices:F.geometryEdgeIndices,positionsDecodeMatrix:P,color:l,metallic:h,roughness:x,opacity:c})),T.push(U)}else D[M]||(i.createGeometry({id:M,primitive:F.primitiveName,positionsCompressed:F.geometryPositions,normalsCompressed:F.geometryNormals,colorsCompressed:F.geometryColors,indices:F.geometryIndices,edgeIndices:F.geometryEdgeIndices,positionsDecodeMatrix:_}),D[M]=!0),i.createMesh(j.apply(G,{id:U,geometryId:M,origin:V,matrix:o,color:l,metallic:h,roughness:x,opacity:c})),T.push(U)}else{let e,t,s,n,A,o,m=!1;switch(b[r]){case 0:e="solid",t=u.subarray(B[r],a?u.length:B[r+1]),s=d.subarray(y[r],a?d.length:y[r+1]),A=f.subarray(v[r],a?f.length:v[r+1]),o=g.subarray(C[r],a?g.length:C[r+1]),m=t.length>0&&A.length>0;break;case 1:e="surface",t=u.subarray(B[r],a?u.length:B[r+1]),s=d.subarray(y[r],a?d.length:y[r+1]),A=f.subarray(v[r],a?f.length:v[r+1]),o=g.subarray(C[r],a?g.length:C[r+1]),m=t.length>0&&A.length>0;break;case 2:e="points",t=u.subarray(B[r],a?u.length:B[r+1]),n=aw(p.subarray(w[r],a?p.length:w[r+1])),m=t.length>0;break;case 3:e="lines",t=u.subarray(B[r],a?u.length:B[r+1]),A=f.subarray(v[r],a?f.length:v[r+1]),m=t.length>0&&A.length>0;break;default:continue}m&&(i.createMesh(j.apply(G,{id:U,origin:V,primitive:e,positionsCompressed:t,normalsCompressed:s,colorsCompressed:n,indices:A,edgeIndices:o,positionsDecodeMatrix:P,color:l,metallic:h,roughness:x,opacity:c})),T.push(U))}}T.length>0&&i.createEntity(j.apply(N,{id:l,isObject:!0,meshIds:T}))}}}(e,t,o,i,r,n)}};let cw=window.pako||ky;cw.inflate||(cw=cw.default);const hw=R.vec4(),uw=R.vec4();const dw=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const pw={version:9,parse:function(e,t,s,i,r,n){const A=function(e){return{metadata:e[0],positions:e[1],normals:e[2],colors:e[3],indices:e[4],edgeIndices:e[5],matrices:e[6],reusedGeometriesDecodeMatrix:e[7],eachGeometryPrimitiveType:e[8],eachGeometryPositionsPortion:e[9],eachGeometryNormalsPortion:e[10],eachGeometryColorsPortion:e[11],eachGeometryIndicesPortion:e[12],eachGeometryEdgeIndicesPortion:e[13],eachMeshGeometriesPortion:e[14],eachMeshMatricesPortion:e[15],eachMeshMaterial:e[16],eachEntityId:e[17],eachEntityMeshesPortion:e[18],eachTileAABB:e[19],eachTileEntitiesPortion:e[20]}}(s),o=function(e){function t(e,t){return 0===e.length?[]:cw.inflate(e,t).buffer}return{metadata:JSON.parse(cw.inflate(e.metadata,{to:"string"})),positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),colors:new Uint8Array(t(e.colors)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),matrices:new Float32Array(t(e.matrices)),reusedGeometriesDecodeMatrix:new Float32Array(t(e.reusedGeometriesDecodeMatrix)),eachGeometryPrimitiveType:new Uint8Array(t(e.eachGeometryPrimitiveType)),eachGeometryPositionsPortion:new Uint32Array(t(e.eachGeometryPositionsPortion)),eachGeometryNormalsPortion:new Uint32Array(t(e.eachGeometryNormalsPortion)),eachGeometryColorsPortion:new Uint32Array(t(e.eachGeometryColorsPortion)),eachGeometryIndicesPortion:new Uint32Array(t(e.eachGeometryIndicesPortion)),eachGeometryEdgeIndicesPortion:new Uint32Array(t(e.eachGeometryEdgeIndicesPortion)),eachMeshGeometriesPortion:new Uint32Array(t(e.eachMeshGeometriesPortion)),eachMeshMatricesPortion:new Uint32Array(t(e.eachMeshMatricesPortion)),eachMeshMaterial:new Uint8Array(t(e.eachMeshMaterial)),eachEntityId:JSON.parse(cw.inflate(e.eachEntityId,{to:"string"})),eachEntityMeshesPortion:new Uint32Array(t(e.eachEntityMeshesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(A);!function(e,t,s,i,r,n){const A=n.getNextId(),o=s.metadata,a=s.positions,l=s.normals,c=s.colors,h=s.indices,u=s.edgeIndices,d=s.matrices,p=s.reusedGeometriesDecodeMatrix,f=s.eachGeometryPrimitiveType,g=s.eachGeometryPositionsPortion,m=s.eachGeometryNormalsPortion,_=s.eachGeometryColorsPortion,b=s.eachGeometryIndicesPortion,B=s.eachGeometryEdgeIndicesPortion,y=s.eachMeshGeometriesPortion,w=s.eachMeshMatricesPortion,v=s.eachMeshMaterial,C=s.eachEntityId,M=s.eachEntityMeshesPortion,E=s.eachTileAABB,F=s.eachTileEntitiesPortion,x=g.length,U=y.length,I=M.length,T=F.length;r&&r.loadData(o,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes,globalizeObjectIds:t.globalizeObjectIds});const P=new Uint32Array(x);for(let e=0;e<U;e++){const t=y[e];void 0!==P[t]?P[t]++:P[t]=1}const S=R.vec3(),D=R.AABB3(),k={};for(let s=0;s<T;s++){const r=s===T-1,o=F[s],U=r?I-1:F[s+1]-1,Q=6*s,O=E.subarray(Q,Q+6);R.getAABB3Center(O,S),D[0]=O[0]-S[0],D[1]=O[1]-S[1],D[2]=O[2]-S[2],D[3]=O[3]-S[0],D[4]=O[4]-S[1],D[5]=O[5]-S[2];const V=Re.createPositionsDecodeMatrix(D),L={};for(let r=o;r<=U;r++){const o=C[r],E=t.globalizeObjectIds?R.globalizeObjectId(i.id,o):o,F=r===I-1,U=M[r],T=F?y.length-1:M[r+1]-1,Q=[],O=e.metaScene.metaObjects[E],H={},N={};if(O){if(t.excludeTypesMap&&O.type&&t.excludeTypesMap[O.type])continue;if(t.includeTypesMap&&O.type&&!t.includeTypesMap[O.type])continue;if(t.includeIdsMap&&O.id&&!t.includeIdsMap[O.id])continue;const e=t.objectDefaults?t.objectDefaults[O.type]||t.objectDefaults.DEFAULT:null;e&&(!1===e.visible&&(H.visible=!1),!1===e.pickable&&(H.pickable=!1),e.colorize&&(N.color=e.colorize),void 0!==e.opacity&&null!==e.opacity&&(N.opacity=e.opacity),void 0!==e.metallic&&null!==e.metallic&&(N.metallic=e.metallic),void 0!==e.roughness&&null!==e.roughness&&(N.roughness=e.roughness))}else if(t.excludeUnclassifiedObjects)continue;for(let e=U;e<=T;e++){const r=y[e],o=P[r]>1,C=r===x-1,M=dw(v.subarray(6*e,6*e+3)),E=v[6*e+3]/255,F=v[6*e+4]/255,U=v[6*e+5]/255,I=n.getNextId();if(o){const n=w[e],o=d.slice(n,n+16),y=`${A}-geometry.${s}.${r}`;let v=k[y];if(!v){v={batchThisMesh:!t.reuseGeometries};let e=!1;switch(f[r]){case 0:v.primitiveName="solid",v.geometryPositions=a.subarray(g[r],C?a.length:g[r+1]),v.geometryNormals=l.subarray(m[r],C?l.length:m[r+1]),v.geometryIndices=h.subarray(b[r],C?h.length:b[r+1]),v.geometryEdgeIndices=u.subarray(B[r],C?u.length:B[r+1]),e=v.geometryPositions.length>0&&v.geometryIndices.length>0;break;case 1:v.primitiveName="surface",v.geometryPositions=a.subarray(g[r],C?a.length:g[r+1]),v.geometryNormals=l.subarray(m[r],C?l.length:m[r+1]),v.geometryIndices=h.subarray(b[r],C?h.length:b[r+1]),v.geometryEdgeIndices=u.subarray(B[r],C?u.length:B[r+1]),e=v.geometryPositions.length>0&&v.geometryIndices.length>0;break;case 2:v.primitiveName="points",v.geometryPositions=a.subarray(g[r],C?a.length:g[r+1]),v.geometryColors=c.subarray(_[r],C?c.length:_[r+1]),e=v.geometryPositions.length>0;break;case 3:v.primitiveName="lines",v.geometryPositions=a.subarray(g[r],C?a.length:g[r+1]),v.geometryIndices=h.subarray(b[r],C?h.length:b[r+1]),e=v.geometryPositions.length>0&&v.geometryIndices.length>0;break;default:continue}if(e||(v=null),v&&(v.geometryPositions.length,v.batchThisMesh)){v.decompressedPositions=new Float32Array(v.geometryPositions.length),v.transformedAndRecompressedPositions=new Uint16Array(v.geometryPositions.length);const e=v.geometryPositions,t=v.decompressedPositions;for(let s=0,i=e.length;s<i;s+=3)t[s+0]=e[s+0]*p[0]+p[12],t[s+1]=e[s+1]*p[5]+p[13],t[s+2]=e[s+2]*p[10]+p[14];v.geometryPositions=null,k[y]=v}}if(v)if(v.batchThisMesh){const e=v.decompressedPositions,t=v.transformedAndRecompressedPositions;for(let s=0,i=e.length;s<i;s+=3)hw[0]=e[s+0],hw[1]=e[s+1],hw[2]=e[s+2],hw[3]=1,R.transformVec4(o,hw,uw),Re.compressPosition(uw,D,hw),t[s+0]=hw[0],t[s+1]=hw[1],t[s+2]=hw[2];i.createMesh(j.apply(N,{id:I,origin:S,primitive:v.primitiveName,positionsCompressed:t,normalsCompressed:v.geometryNormals,colorsCompressed:v.geometryColors,indices:v.geometryIndices,edgeIndices:v.geometryEdgeIndices,positionsDecodeMatrix:V,color:M,metallic:F,roughness:U,opacity:E})),Q.push(I)}else L[y]||(i.createGeometry({id:y,primitive:v.primitiveName,positionsCompressed:v.geometryPositions,normalsCompressed:v.geometryNormals,colorsCompressed:v.geometryColors,indices:v.geometryIndices,edgeIndices:v.geometryEdgeIndices,positionsDecodeMatrix:p}),L[y]=!0),i.createMesh(j.apply(N,{id:I,geometryId:y,origin:S,matrix:o,color:M,metallic:F,roughness:U,opacity:E})),Q.push(I)}else{let e,t,s,n,A,o,d=!1;switch(f[r]){case 0:e="solid",t=a.subarray(g[r],C?a.length:g[r+1]),s=l.subarray(m[r],C?l.length:m[r+1]),A=h.subarray(b[r],C?h.length:b[r+1]),o=u.subarray(B[r],C?u.length:B[r+1]),d=t.length>0&&A.length>0;break;case 1:e="surface",t=a.subarray(g[r],C?a.length:g[r+1]),s=l.subarray(m[r],C?l.length:m[r+1]),A=h.subarray(b[r],C?h.length:b[r+1]),o=u.subarray(B[r],C?u.length:B[r+1]),d=t.length>0&&A.length>0;break;case 2:e="points",t=a.subarray(g[r],C?a.length:g[r+1]),n=c.subarray(_[r],C?c.length:_[r+1]),d=t.length>0;break;case 3:e="lines",t=a.subarray(g[r],C?a.length:g[r+1]),A=h.subarray(b[r],C?h.length:b[r+1]),d=t.length>0&&A.length>0;break;default:continue}d&&(i.createMesh(j.apply(N,{id:I,origin:S,primitive:e,positionsCompressed:t,normalsCompressed:s,colorsCompressed:n,indices:A,edgeIndices:o,positionsDecodeMatrix:V,color:M,metallic:F,roughness:U,opacity:E})),Q.push(I))}}Q.length>0&&i.createEntity(j.apply(H,{id:E,isObject:!0,meshIds:Q}))}}}(e,t,o,i,r,n)}};let fw=window.pako||ky;fw.inflate||(fw=fw.default);const gw=R.vec4(),mw=R.vec4();const _w=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function bw(e,t){const s=[];if(t.length>1)for(let e=0,i=t.length-1;e<i;e++)s.push(t[e]),s.push(t[e+1]);else if(e.length>1)for(let t=0,i=e.length/3-1;t<i;t++)s.push(t),s.push(t+1);return s}!function(){const e=document.createElement("canvas"),t=e.getContext("2d")}();const Bw={version:10,parse:function(e,t,s,i,r,n){const A=function(e){let t=0;return{metadata:e[t++],textureData:e[t++],eachTextureDataPortion:e[t++],eachTextureAttributes:e[t++],positions:e[t++],normals:e[t++],colors:e[t++],uvs:e[t++],indices:e[t++],edgeIndices:e[t++],eachTextureSetTextures:e[t++],matrices:e[t++],reusedGeometriesDecodeMatrix:e[t++],eachGeometryPrimitiveType:e[t++],eachGeometryPositionsPortion:e[t++],eachGeometryNormalsPortion:e[t++],eachGeometryColorsPortion:e[t++],eachGeometryUVsPortion:e[t++],eachGeometryIndicesPortion:e[t++],eachGeometryEdgeIndicesPortion:e[t++],eachMeshGeometriesPortion:e[t++],eachMeshMatricesPortion:e[t++],eachMeshTextureSet:e[t++],eachMeshMaterialAttributes:e[t++],eachEntityId:e[t++],eachEntityMeshesPortion:e[t++],eachTileAABB:e[t++],eachTileEntitiesPortion:e[t++]}}(s),o=function(e){function t(e,t){return 0===e.length?[]:fw.inflate(e,t).buffer}return{metadata:JSON.parse(fw.inflate(e.metadata,{to:"string"})),textureData:new Uint8Array(t(e.textureData)),eachTextureDataPortion:new Uint32Array(t(e.eachTextureDataPortion)),eachTextureAttributes:new Uint16Array(t(e.eachTextureAttributes)),positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),colors:new Uint8Array(t(e.colors)),uvs:new Float32Array(t(e.uvs)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),eachTextureSetTextures:new Int32Array(t(e.eachTextureSetTextures)),matrices:new Float32Array(t(e.matrices)),reusedGeometriesDecodeMatrix:new Float32Array(t(e.reusedGeometriesDecodeMatrix)),eachGeometryPrimitiveType:new Uint8Array(t(e.eachGeometryPrimitiveType)),eachGeometryPositionsPortion:new Uint32Array(t(e.eachGeometryPositionsPortion)),eachGeometryNormalsPortion:new Uint32Array(t(e.eachGeometryNormalsPortion)),eachGeometryColorsPortion:new Uint32Array(t(e.eachGeometryColorsPortion)),eachGeometryUVsPortion:new Uint32Array(t(e.eachGeometryUVsPortion)),eachGeometryIndicesPortion:new Uint32Array(t(e.eachGeometryIndicesPortion)),eachGeometryEdgeIndicesPortion:new Uint32Array(t(e.eachGeometryEdgeIndicesPortion)),eachMeshGeometriesPortion:new Uint32Array(t(e.eachMeshGeometriesPortion)),eachMeshMatricesPortion:new Uint32Array(t(e.eachMeshMatricesPortion)),eachMeshTextureSet:new Int32Array(t(e.eachMeshTextureSet)),eachMeshMaterialAttributes:new Uint8Array(t(e.eachMeshMaterialAttributes)),eachEntityId:JSON.parse(fw.inflate(e.eachEntityId,{to:"string"})),eachEntityMeshesPortion:new Uint32Array(t(e.eachEntityMeshesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(A);!function(e,t,s,i,r,n){const A=n.getNextId(),o=s.metadata,a=s.textureData,l=s.eachTextureDataPortion,c=s.eachTextureAttributes,h=s.positions,u=s.normals,d=s.colors,p=s.uvs,f=s.indices,g=s.edgeIndices,m=s.eachTextureSetTextures,_=s.matrices,b=s.reusedGeometriesDecodeMatrix,B=s.eachGeometryPrimitiveType,y=s.eachGeometryPositionsPortion,w=s.eachGeometryNormalsPortion,v=s.eachGeometryColorsPortion,C=s.eachGeometryUVsPortion,M=s.eachGeometryIndicesPortion,E=s.eachGeometryEdgeIndicesPortion,F=s.eachMeshGeometriesPortion,x=s.eachMeshMatricesPortion,U=s.eachMeshTextureSet,I=s.eachMeshMaterialAttributes,T=s.eachEntityId,P=s.eachEntityMeshesPortion,S=s.eachTileAABB,D=s.eachTileEntitiesPortion,k=l.length,Q=m.length/5,O=y.length,V=F.length,L=P.length,H=D.length;r&&r.loadData(o,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes,globalizeObjectIds:t.globalizeObjectIds});for(let e=0;e<k;e++){const t=e===k-1,s=l[e],r=t?a.length:l[e+1],n=r-s>0,o=9*e,h=1===c[o+0],u=c[o+1];c[o+2],c[o+3];const d=c[o+4],p=c[o+5],f=c[o+6],g=c[o+7],m=c[o+8];if(n){const t=new Uint8Array(a.subarray(s,r)).buffer,n=`${A}-texture-${e}`;if(h)i.createTexture({id:n,buffers:[t],minFilter:d,magFilter:p,wrapS:f,wrapT:g,wrapR:m});else{const e=new Blob([t],{type:10001===u?"image/jpeg":10002===u?"image/png":"image/gif"}),s=(window.URL||window.webkitURL).createObjectURL(e),r=document.createElement("img");r.src=s,i.createTexture({id:n,image:r,minFilter:d,magFilter:p,wrapS:f,wrapT:g,wrapR:m})}}}for(let e=0;e<Q;e++){const t=5*e,s=`${A}-textureSet-${e}`,r=m[t+0],n=m[t+1],o=m[t+2],a=m[t+3],l=m[t+4];i.createTextureSet({id:s,colorTextureId:r>=0?`${A}-texture-${r}`:null,normalsTextureId:o>=0?`${A}-texture-${o}`:null,metallicRoughnessTextureId:n>=0?`${A}-texture-${n}`:null,emissiveTextureId:a>=0?`${A}-texture-${a}`:null,occlusionTextureId:l>=0?`${A}-texture-${l}`:null})}const N=new Uint32Array(O);for(let e=0;e<V;e++){const t=F[e];void 0!==N[t]?N[t]++:N[t]=1}const G=R.vec3(),W=R.AABB3(),z={};for(let s=0;s<H;s++){const r=s===H-1,o=D[s],a=r?L-1:D[s+1]-1,l=6*s,c=S.subarray(l,l+6);R.getAABB3Center(c,G),W[0]=c[0]-G[0],W[1]=c[1]-G[1],W[2]=c[2]-G[2],W[3]=c[3]-G[0],W[4]=c[4]-G[1],W[5]=c[5]-G[2];const m=Re.createPositionsDecodeMatrix(W),k={};for(let r=o;r<=a;r++){const o=T[r],a=t.globalizeObjectIds?R.globalizeObjectId(i.id,o):o,l=r===L-1,c=P[r],S=l?F.length-1:P[r+1]-1,D=[],Q=e.metaScene.metaObjects[a],V={},H={};if(Q){if(t.excludeTypesMap&&Q.type&&t.excludeTypesMap[Q.type])continue;if(t.includeTypesMap&&Q.type&&!t.includeTypesMap[Q.type])continue;if(t.includeIdsMap&&Q.id&&!t.includeIdsMap[Q.id])continue;const e=t.objectDefaults?t.objectDefaults[Q.type]||t.objectDefaults.DEFAULT:null;e&&(!1===e.visible&&(V.visible=!1),!1===e.pickable&&(V.pickable=!1),e.colorize&&(H.color=e.colorize),void 0!==e.opacity&&null!==e.opacity&&(H.opacity=e.opacity),void 0!==e.metallic&&null!==e.metallic&&(H.metallic=e.metallic),void 0!==e.roughness&&null!==e.roughness&&(H.roughness=e.roughness))}else if(t.excludeUnclassifiedObjects)continue;for(let e=c;e<=S;e++){const r=F[e],o=N[r]>1,a=r===O-1,l=U[e],c=l>=0?`${A}-textureSet-${l}`:null,T=_w(I.subarray(6*e,6*e+3)),P=I[6*e+3]/255,S=I[6*e+4]/255,Q=I[6*e+5]/255,V=n.getNextId();if(o){const n=x[e],o=_.slice(n,n+16),l=`${A}-geometry.${s}.${r}`;let F=z[l];if(!F){F={batchThisMesh:!t.reuseGeometries};let e=!1;switch(B[r]){case 0:F.primitiveName="solid",F.geometryPositions=h.subarray(y[r],a?h.length:y[r+1]),F.geometryNormals=u.subarray(w[r],a?u.length:w[r+1]),F.geometryUVs=p.subarray(C[r],a?p.length:C[r+1]),F.geometryIndices=f.subarray(M[r],a?f.length:M[r+1]),F.geometryEdgeIndices=g.subarray(E[r],a?g.length:E[r+1]),e=F.geometryPositions.length>0&&F.geometryIndices.length>0;break;case 1:F.primitiveName="surface",F.geometryPositions=h.subarray(y[r],a?h.length:y[r+1]),F.geometryNormals=u.subarray(w[r],a?u.length:w[r+1]),F.geometryUVs=p.subarray(C[r],a?p.length:C[r+1]),F.geometryIndices=f.subarray(M[r],a?f.length:M[r+1]),F.geometryEdgeIndices=g.subarray(E[r],a?g.length:E[r+1]),e=F.geometryPositions.length>0&&F.geometryIndices.length>0;break;case 2:F.primitiveName="points",F.geometryPositions=h.subarray(y[r],a?h.length:y[r+1]),F.geometryColors=d.subarray(v[r],a?d.length:v[r+1]),e=F.geometryPositions.length>0;break;case 3:F.primitiveName="lines",F.geometryPositions=h.subarray(y[r],a?h.length:y[r+1]),F.geometryIndices=f.subarray(M[r],a?f.length:M[r+1]),e=F.geometryPositions.length>0&&F.geometryIndices.length>0;break;case 4:F.primitiveName="lines",F.geometryPositions=h.subarray(y[r],a?h.length:y[r+1]),F.geometryIndices=bw(F.geometryPositions,f.subarray(M[r],a?f.length:M[r+1])),e=F.geometryPositions.length>0&&F.geometryIndices.length>0;break;default:continue}if(e||(F=null),F&&(F.geometryPositions.length,F.batchThisMesh)){F.decompressedPositions=new Float32Array(F.geometryPositions.length),F.transformedAndRecompressedPositions=new Uint16Array(F.geometryPositions.length);const e=F.geometryPositions,t=F.decompressedPositions;for(let s=0,i=e.length;s<i;s+=3)t[s+0]=e[s+0]*b[0]+b[12],t[s+1]=e[s+1]*b[5]+b[13],t[s+2]=e[s+2]*b[10]+b[14];F.geometryPositions=null,z[l]=F}}if(F)if(F.batchThisMesh){const e=F.decompressedPositions,t=F.transformedAndRecompressedPositions;for(let s=0,i=e.length;s<i;s+=3)gw[0]=e[s+0],gw[1]=e[s+1],gw[2]=e[s+2],gw[3]=1,R.transformVec4(o,gw,mw),Re.compressPosition(mw,W,gw),t[s+0]=gw[0],t[s+1]=gw[1],t[s+2]=gw[2];i.createMesh(j.apply(H,{id:V,textureSetId:c,origin:G,primitive:F.primitiveName,positionsCompressed:t,normalsCompressed:F.geometryNormals,uv:F.geometryUVs,colorsCompressed:F.geometryColors,indices:F.geometryIndices,edgeIndices:F.geometryEdgeIndices,positionsDecodeMatrix:m,color:T,metallic:S,roughness:Q,opacity:P})),D.push(V)}else k[l]||(i.createGeometry({id:l,primitive:F.primitiveName,positionsCompressed:F.geometryPositions,normalsCompressed:F.geometryNormals,uv:F.geometryUVs,colorsCompressed:F.geometryColors,indices:F.geometryIndices,edgeIndices:F.geometryEdgeIndices,positionsDecodeMatrix:b}),k[l]=!0),i.createMesh(j.apply(H,{id:V,geometryId:l,textureSetId:c,matrix:o,color:T,metallic:S,roughness:Q,opacity:P,origin:G})),D.push(V)}else{let e,t,s,n,A,o,l,_=!1;switch(B[r]){case 0:e="solid",t=h.subarray(y[r],a?h.length:y[r+1]),s=u.subarray(w[r],a?u.length:w[r+1]),n=p.subarray(C[r],a?p.length:C[r+1]),o=f.subarray(M[r],a?f.length:M[r+1]),l=g.subarray(E[r],a?g.length:E[r+1]),_=t.length>0&&o.length>0;break;case 1:e="surface",t=h.subarray(y[r],a?h.length:y[r+1]),s=u.subarray(w[r],a?u.length:w[r+1]),n=p.subarray(C[r],a?p.length:C[r+1]),o=f.subarray(M[r],a?f.length:M[r+1]),l=g.subarray(E[r],a?g.length:E[r+1]),_=t.length>0&&o.length>0;break;case 2:e="points",t=h.subarray(y[r],a?h.length:y[r+1]),A=d.subarray(v[r],a?d.length:v[r+1]),_=t.length>0;break;case 3:e="lines",t=h.subarray(y[r],a?h.length:y[r+1]),o=f.subarray(M[r],a?f.length:M[r+1]),_=t.length>0&&o.length>0;break;case 4:e="lines",t=h.subarray(y[r],a?h.length:y[r+1]),o=bw(t,f.subarray(M[r],a?f.length:M[r+1])),_=t.length>0&&o.length>0;break;default:continue}_&&(i.createMesh(j.apply(H,{id:V,textureSetId:c,origin:G,primitive:e,positionsCompressed:t,normalsCompressed:s,uv:n&&n.length>0?n:null,colorsCompressed:A,indices:o,edgeIndices:l,positionsDecodeMatrix:m,color:T,metallic:S,roughness:Q,opacity:P})),D.push(V))}}D.length>0&&i.createEntity(j.apply(V,{id:a,isObject:!0,meshIds:D}))}}}(e,t,o,i,r,n)}},yw=R.vec4(),ww=R.vec4();const vw=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function Cw(e,t){const s=[];if(t.length>1)for(let e=0,i=t.length-1;e<i;e++)s.push(t[e]),s.push(t[e+1]);else if(e.length>1)for(let t=0,i=e.length/3-1;t<i;t++)s.push(t),s.push(t+1);return s}!function(){const e=document.createElement("canvas"),t=e.getContext("2d")}();const Mw={version:11,parseArrayBuffer:function(e,t,s,i,r,n){const A=function(e){const t=function(){const e=new ArrayBuffer(2);return new Uint16Array(e)[0]=1,1!==new Uint8Array(e)[0]}(),s=function(){let s=0;const i=new DataView(e);return function(r){const n=1+2*s++,A=i.getUint32(4*n,!0),o=i.getUint32(4*(n+1),!0),a=r.BYTES_PER_ELEMENT;if(t&&a>1){const t=new Uint8Array(e,A,o),s=a/2,i=t.length/a;for(let e=0;e<i;e++){const i=e*a;for(let e=0;e<s;e++){const s=i+e,r=i-e+a-1,n=t[s];t[s]=t[r],t[r]=n}}}return new r(e,A,o/a)}}(),i=function(){const e=new TextDecoder;return()=>JSON.parse(e.decode(s(Uint8Array)))}();return{metadata:i(),textureData:s(Uint8Array),eachTextureDataPortion:s(Uint32Array),eachTextureAttributes:s(Uint16Array),positions:s(Uint16Array),normals:s(Int8Array),colors:s(Uint8Array),uvs:s(Float32Array),indices:s(Uint32Array),edgeIndices:s(Uint32Array),eachTextureSetTextures:s(Int32Array),matrices:s(Float32Array),reusedGeometriesDecodeMatrix:s(Float32Array),eachGeometryPrimitiveType:s(Uint8Array),eachGeometryPositionsPortion:s(Uint32Array),eachGeometryNormalsPortion:s(Uint32Array),eachGeometryColorsPortion:s(Uint32Array),eachGeometryUVsPortion:s(Uint32Array),eachGeometryIndicesPortion:s(Uint32Array),eachGeometryEdgeIndicesPortion:s(Uint32Array),eachMeshGeometriesPortion:s(Uint32Array),eachMeshMatricesPortion:s(Uint32Array),eachMeshTextureSet:s(Int32Array),eachMeshMaterialAttributes:s(Uint8Array),eachEntityId:i(),eachEntityMeshesPortion:s(Uint32Array),eachTileAABB:s(Float64Array),eachTileEntitiesPortion:s(Uint32Array)}}(s);!function(e,t,s,i,r,n){const A=n.getNextId(),o=s.metadata,a=s.textureData,l=s.eachTextureDataPortion,c=s.eachTextureAttributes,h=s.positions,u=s.normals,d=s.colors,p=s.uvs,f=s.indices,g=s.edgeIndices,m=s.eachTextureSetTextures,_=s.matrices,b=s.reusedGeometriesDecodeMatrix,B=s.eachGeometryPrimitiveType,y=s.eachGeometryPositionsPortion,w=s.eachGeometryNormalsPortion,v=s.eachGeometryColorsPortion,C=s.eachGeometryUVsPortion,M=s.eachGeometryIndicesPortion,E=s.eachGeometryEdgeIndicesPortion,F=s.eachMeshGeometriesPortion,x=s.eachMeshMatricesPortion,U=s.eachMeshTextureSet,I=s.eachMeshMaterialAttributes,T=s.eachEntityId,P=s.eachEntityMeshesPortion,S=s.eachTileAABB,D=s.eachTileEntitiesPortion,k=l.length,Q=m.length/5,O=y.length,V=F.length,L=P.length,H=D.length;r&&r.loadData(o,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes,globalizeObjectIds:t.globalizeObjectIds});for(let e=0;e<k;e++){const t=e===k-1,s=l[e],r=t?a.length:l[e+1],n=r-s>0,o=9*e,h=1===c[o+0],u=c[o+1];c[o+2],c[o+3];const d=c[o+4],p=c[o+5],f=c[o+6],g=c[o+7],m=c[o+8];if(n){const t=new Uint8Array(a.subarray(s,r)).buffer,n=`${A}-texture-${e}`;if(h)i.createTexture({id:n,buffers:[t],minFilter:d,magFilter:p,wrapS:f,wrapT:g,wrapR:m});else{const e=new Blob([t],{type:10001===u?"image/jpeg":10002===u?"image/png":"image/gif"}),s=(window.URL||window.webkitURL).createObjectURL(e),r=document.createElement("img");r.src=s,i.createTexture({id:n,image:r,minFilter:d,magFilter:p,wrapS:f,wrapT:g,wrapR:m})}}}for(let e=0;e<Q;e++){const t=5*e,s=`${A}-textureSet-${e}`,r=m[t+0],n=m[t+1],o=m[t+2],a=m[t+3],l=m[t+4];i.createTextureSet({id:s,colorTextureId:r>=0?`${A}-texture-${r}`:null,normalsTextureId:o>=0?`${A}-texture-${o}`:null,metallicRoughnessTextureId:n>=0?`${A}-texture-${n}`:null,emissiveTextureId:a>=0?`${A}-texture-${a}`:null,occlusionTextureId:l>=0?`${A}-texture-${l}`:null})}const N=new Uint32Array(O);for(let e=0;e<V;e++){const t=F[e];void 0!==N[t]?N[t]++:N[t]=1}const G=R.vec3(),W=R.AABB3(),z={};for(let s=0;s<H;s++){const r=s===H-1,o=D[s],a=r?L-1:D[s+1]-1,l=6*s,c=S.subarray(l,l+6);R.getAABB3Center(c,G),W[0]=c[0]-G[0],W[1]=c[1]-G[1],W[2]=c[2]-G[2],W[3]=c[3]-G[0],W[4]=c[4]-G[1],W[5]=c[5]-G[2];const m=Re.createPositionsDecodeMatrix(W),k={};for(let r=o;r<=a;r++){const o=T[r],a=t.globalizeObjectIds?R.globalizeObjectId(i.id,o):o,l=r===L-1,c=P[r],S=l?F.length-1:P[r+1]-1,D=[],Q=e.metaScene.metaObjects[a],V={},H={};if(Q){if(t.excludeTypesMap&&Q.type&&t.excludeTypesMap[Q.type])continue;if(t.includeTypesMap&&Q.type&&!t.includeTypesMap[Q.type])continue;if(t.includeIdsMap&&Q.id&&!t.includeIdsMap[Q.id])continue;const e=t.objectDefaults?t.objectDefaults[Q.type]||t.objectDefaults.DEFAULT:null;e&&(!1===e.visible&&(V.visible=!1),!1===e.pickable&&(V.pickable=!1),e.colorize&&(H.color=e.colorize),void 0!==e.opacity&&null!==e.opacity&&(H.opacity=e.opacity),void 0!==e.metallic&&null!==e.metallic&&(H.metallic=e.metallic),void 0!==e.roughness&&null!==e.roughness&&(H.roughness=e.roughness))}else if(t.excludeUnclassifiedObjects)continue;for(let e=c;e<=S;e++){const r=F[e],o=N[r]>1,a=r===O-1,l=U[e],c=l>=0?`${A}-textureSet-${l}`:null,T=vw(I.subarray(6*e,6*e+3)),P=I[6*e+3]/255,S=I[6*e+4]/255,Q=I[6*e+5]/255,V=n.getNextId();if(o){const n=x[e],o=_.slice(n,n+16),l=`${A}-geometry.${s}.${r}`;let F=z[l];if(!F){F={batchThisMesh:!t.reuseGeometries};let e=!1;switch(B[r]){case 0:F.primitiveName="solid",F.geometryPositions=h.subarray(y[r],a?h.length:y[r+1]),F.geometryNormals=u.subarray(w[r],a?u.length:w[r+1]),F.geometryUVs=p.subarray(C[r],a?p.length:C[r+1]),F.geometryIndices=f.subarray(M[r],a?f.length:M[r+1]),F.geometryEdgeIndices=g.subarray(E[r],a?g.length:E[r+1]),e=F.geometryPositions.length>0&&F.geometryIndices.length>0;break;case 1:F.primitiveName="surface",F.geometryPositions=h.subarray(y[r],a?h.length:y[r+1]),F.geometryNormals=u.subarray(w[r],a?u.length:w[r+1]),F.geometryUVs=p.subarray(C[r],a?p.length:C[r+1]),F.geometryIndices=f.subarray(M[r],a?f.length:M[r+1]),F.geometryEdgeIndices=g.subarray(E[r],a?g.length:E[r+1]),e=F.geometryPositions.length>0&&F.geometryIndices.length>0;break;case 2:F.primitiveName="points",F.geometryPositions=h.subarray(y[r],a?h.length:y[r+1]),F.geometryColors=d.subarray(v[r],a?d.length:v[r+1]),e=F.geometryPositions.length>0;break;case 3:F.primitiveName="lines",F.geometryPositions=h.subarray(y[r],a?h.length:y[r+1]),F.geometryIndices=f.subarray(M[r],a?f.length:M[r+1]),e=F.geometryPositions.length>0&&F.geometryIndices.length>0;break;case 4:F.primitiveName="lines",F.geometryPositions=h.subarray(y[r],a?h.length:y[r+1]),F.geometryIndices=Cw(F.geometryPositions,f.subarray(M[r],a?f.length:M[r+1])),e=F.geometryPositions.length>0&&F.geometryIndices.length>0;break;default:continue}if(e||(F=null),F&&(F.geometryPositions.length,F.batchThisMesh)){F.decompressedPositions=new Float32Array(F.geometryPositions.length),F.transformedAndRecompressedPositions=new Uint16Array(F.geometryPositions.length);const e=F.geometryPositions,t=F.decompressedPositions;for(let s=0,i=e.length;s<i;s+=3)t[s+0]=e[s+0]*b[0]+b[12],t[s+1]=e[s+1]*b[5]+b[13],t[s+2]=e[s+2]*b[10]+b[14];F.geometryPositions=null,z[l]=F}}if(F)if(F.batchThisMesh){const e=F.decompressedPositions,t=F.transformedAndRecompressedPositions;for(let s=0,i=e.length;s<i;s+=3)yw[0]=e[s+0],yw[1]=e[s+1],yw[2]=e[s+2],yw[3]=1,R.transformVec4(o,yw,ww),Re.compressPosition(ww,W,yw),t[s+0]=yw[0],t[s+1]=yw[1],t[s+2]=yw[2];i.createMesh(j.apply(H,{id:V,textureSetId:c,origin:G,primitive:F.primitiveName,positionsCompressed:t,normalsCompressed:F.geometryNormals,uv:F.geometryUVs,colorsCompressed:F.geometryColors,indices:F.geometryIndices,edgeIndices:F.geometryEdgeIndices,positionsDecodeMatrix:m,color:T,metallic:S,roughness:Q,opacity:P})),D.push(V)}else k[l]||(i.createGeometry({id:l,primitive:F.primitiveName,positionsCompressed:F.geometryPositions,normalsCompressed:F.geometryNormals,uv:F.geometryUVs,colorsCompressed:F.geometryColors,indices:F.geometryIndices,edgeIndices:F.geometryEdgeIndices,positionsDecodeMatrix:b}),k[l]=!0),i.createMesh(j.apply(H,{id:V,geometryId:l,textureSetId:c,matrix:o,color:T,metallic:S,roughness:Q,opacity:P,origin:G})),D.push(V)}else{let e,t,s,n,A,o,l,_=!1;switch(B[r]){case 0:e="solid",t=h.subarray(y[r],a?h.length:y[r+1]),s=u.subarray(w[r],a?u.length:w[r+1]),n=p.subarray(C[r],a?p.length:C[r+1]),o=f.subarray(M[r],a?f.length:M[r+1]),l=g.subarray(E[r],a?g.length:E[r+1]),_=t.length>0&&o.length>0;break;case 1:e="surface",t=h.subarray(y[r],a?h.length:y[r+1]),s=u.subarray(w[r],a?u.length:w[r+1]),n=p.subarray(C[r],a?p.length:C[r+1]),o=f.subarray(M[r],a?f.length:M[r+1]),l=g.subarray(E[r],a?g.length:E[r+1]),_=t.length>0&&o.length>0;break;case 2:e="points",t=h.subarray(y[r],a?h.length:y[r+1]),A=d.subarray(v[r],a?d.length:v[r+1]),_=t.length>0;break;case 3:e="lines",t=h.subarray(y[r],a?h.length:y[r+1]),o=f.subarray(M[r],a?f.length:M[r+1]),_=t.length>0&&o.length>0;break;case 4:e="lines",t=h.subarray(y[r],a?h.length:y[r+1]),o=Cw(t,f.subarray(M[r],a?f.length:M[r+1])),_=t.length>0&&o.length>0;break;default:continue}_&&(i.createMesh(j.apply(H,{id:V,textureSetId:c,origin:G,primitive:e,positionsCompressed:t,normalsCompressed:s,uv:n&&n.length>0?n:null,colorsCompressed:A,indices:o,edgeIndices:l,positionsDecodeMatrix:m,color:T,metallic:S,roughness:Q,opacity:P})),D.push(V))}}D.length>0&&i.createEntity(j.apply(V,{id:a,isObject:!0,meshIds:D}))}}}(e,t,A,i,r,n)}};let Ew=window.pako||ky;Ew.inflate||(Ew=Ew.default);const Fw=R.vec4(),xw=R.vec4();const Uw=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function Iw(e,t,s,i,r,n){const A=n.getNextId(),o=s.metadata,a=s.textureData,l=s.eachTextureDataPortion,c=s.eachTextureAttributes,h=s.positions,u=s.normals,d=s.colors,p=s.uvs,f=s.indices,g=s.edgeIndices,m=s.eachTextureSetTextures,_=s.matrices,b=s.reusedGeometriesDecodeMatrix,B=s.eachGeometryPrimitiveType,y=s.eachGeometryAxisLabel,w=s.eachGeometryPositionsPortion,v=s.eachGeometryNormalsPortion,C=s.eachGeometryColorsPortion,M=s.eachGeometryUVsPortion,E=s.eachGeometryIndicesPortion,F=s.eachGeometryEdgeIndicesPortion,x=s.eachMeshGeometriesPortion,U=s.eachMeshMatricesPortion,I=s.eachMeshTextureSet,T=s.eachMeshMaterialAttributes,P=s.eachEntityId,S=s.eachEntityMeshesPortion,D=s.eachTileAABB,k=s.eachTileEntitiesPortion,Q=l.length,O=m.length/5,V=w.length,L=x.length,H=S.length,N=k.length;r&&r.loadData(o,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes,globalizeObjectIds:t.globalizeObjectIds});for(let e=0;e<Q;e++){const t=e===Q-1,s=l[e],r=t?a.length:l[e+1],n=r-s>0,o=9*e,h=1===c[o+0],u=c[o+1];c[o+2],c[o+3];const d=c[o+4],p=c[o+5],f=c[o+6],g=c[o+7],m=c[o+8];if(n){const t=new Uint8Array(a.subarray(s,r)).buffer,n=`${A}-texture-${e}`;if(h)i.createTexture({id:n,buffers:[t],minFilter:d,magFilter:p,wrapS:f,wrapT:g,wrapR:m});else{const e=new Blob([t],{type:10001===u?"image/jpeg":10002===u?"image/png":"image/gif"}),s=(window.URL||window.webkitURL).createObjectURL(e),r=document.createElement("img");r.src=s,i.createTexture({id:n,image:r,minFilter:d,magFilter:p,wrapS:f,wrapT:g,wrapR:m})}}}for(let e=0;e<O;e++){const t=5*e,s=`${A}-textureSet-${e}`,r=m[t+0],n=m[t+1],o=m[t+2],a=m[t+3],l=m[t+4];i.createTextureSet({id:s,colorTextureId:r>=0?`${A}-texture-${r}`:null,normalsTextureId:o>=0?`${A}-texture-${o}`:null,metallicRoughnessTextureId:n>=0?`${A}-texture-${n}`:null,emissiveTextureId:a>=0?`${A}-texture-${a}`:null,occlusionTextureId:l>=0?`${A}-texture-${l}`:null})}const G=new Uint32Array(V);for(let e=0;e<L;e++){const t=x[e];void 0!==G[t]?G[t]++:G[t]=1}const W=R.vec3(),z=R.AABB3(),X={};for(let s=0;s<N;s++){const r=s===N-1,o=k[s],a=r?H-1:k[s+1]-1,l=6*s,c=D.subarray(l,l+6);R.getAABB3Center(c,W),z[0]=c[0]-W[0],z[1]=c[1]-W[1],z[2]=c[2]-W[2],z[3]=c[3]-W[0],z[4]=c[4]-W[1],z[5]=c[5]-W[2];const m=Re.createPositionsDecodeMatrix(z),Q={};for(let r=o;r<=a;r++){const o=P[r],a=t.globalizeObjectIds?R.globalizeObjectId(i.id,o):o,l=r===H-1,c=S[r],D=l?x.length-1:S[r+1]-1,k=[],O=e.metaScene.metaObjects[a],L={},N={};if(O){if(t.excludeTypesMap&&O.type&&t.excludeTypesMap[O.type])continue;if(t.includeTypesMap&&O.type&&!t.includeTypesMap[O.type])continue;if(t.includeIdsMap&&O.id&&!t.includeIdsMap[O.id])continue;const e=t.objectDefaults?t.objectDefaults[O.type]||t.objectDefaults.DEFAULT:null;e&&(!1===e.visible&&(L.visible=!1),!1===e.pickable&&(L.pickable=!1),e.colorize&&(N.color=e.colorize),void 0!==e.opacity&&null!==e.opacity&&(N.opacity=e.opacity),void 0!==e.metallic&&null!==e.metallic&&(N.metallic=e.metallic),void 0!==e.roughness&&null!==e.roughness&&(N.roughness=e.roughness))}else if(t.excludeUnclassifiedObjects)continue;for(let e=c;e<=D;e++){const r=x[e],o=G[r]>1,a=r===V-1,l=I[e],c=l>=0?`${A}-textureSet-${l}`:null,P=Uw(T.subarray(6*e,6*e+3)),S=T[6*e+3]/255,D=T[6*e+4]/255,O=T[6*e+5]/255,L=n.getNextId();if(o){const n=U[e],o=_.slice(n,n+16),l=`${A}-geometry.${s}.${r}`;let x=X[l];if(!x){x={batchThisMesh:!t.reuseGeometries};const e=B[r],s=y[r];let i,n=!1;switch(e){case 0:x.primitiveName="solid",x.geometryPositions=h.subarray(w[r],a?h.length:w[r+1]),x.geometryNormals=u.subarray(v[r],a?u.length:v[r+1]),x.geometryUVs=p.subarray(M[r],a?p.length:M[r+1]),x.geometryIndices=f.subarray(E[r],a?f.length:E[r+1]),x.geometryEdgeIndices=g.subarray(F[r],a?g.length:F[r+1]),n=x.geometryPositions.length>0&&x.geometryIndices.length>0;break;case 1:x.primitiveName="surface",x.geometryPositions=h.subarray(w[r],a?h.length:w[r+1]),x.geometryNormals=u.subarray(v[r],a?u.length:v[r+1]),x.geometryUVs=p.subarray(M[r],a?p.length:M[r+1]),x.geometryIndices=f.subarray(E[r],a?f.length:E[r+1]),x.geometryEdgeIndices=g.subarray(F[r],a?g.length:F[r+1]),n=x.geometryPositions.length>0&&x.geometryIndices.length>0;break;case 2:x.primitiveName="points",x.geometryPositions=h.subarray(w[r],a?h.length:w[r+1]),x.geometryColors=d.subarray(C[r],a?d.length:C[r+1]),n=x.geometryPositions.length>0;break;case 3:x.primitiveName="lines",x.geometryPositions=h.subarray(w[r],a?h.length:w[r+1]),x.geometryIndices=f.subarray(E[r],a?f.length:E[r+1]),n=x.geometryPositions.length>0&&x.geometryIndices.length>0;break;case 4:x.primitiveName="lines",x.geometryPositions=h.subarray(w[r],a?h.length:w[r+1]),x.geometryIndices=Tw(x.geometryPositions,f.subarray(E[r],a?f.length:E[r+1])),n=x.geometryPositions.length>0&&x.geometryIndices.length>0;break;case 7:x.primitiveName="lines",x.geometryPositions=h.subarray(w[r],a?h.length:w[r+1]),x.decompressedPositions=Re.decompressPositions(x.geometryPositions,b),i=qe({origin:x.decompressedPositions,text:s,size:2}),x.decompressedPositions=i.positions,x.geometryIndices=i.indices,x.geometryPositions=null,n=x.decompressedPositions.length>0&&x.geometryIndices.length>0;break;default:continue}if(n||(x=null),x&&(x.geometryPositions&&x.geometryPositions.length,x.batchThisMesh)){if(7===e)x.transformedAndRecompressedPositions=new Uint16Array(x.decompressedPositions.length);else{x.decompressedPositions=new Float32Array(x.geometryPositions.length),x.transformedAndRecompressedPositions=new Uint16Array(x.geometryPositions.length);const e=x.geometryPositions,t=x.decompressedPositions;for(let s=0,i=e.length;s<i;s+=3)t[s+0]=e[s+0]*b[0]+b[12],t[s+1]=e[s+1]*b[5]+b[13],t[s+2]=e[s+2]*b[10]+b[14];x.geometryPositions=null}X[l]=x}}if(x)if(x.batchThisMesh){const e=x.decompressedPositions,t=x.transformedAndRecompressedPositions;for(let s=0,i=e.length;s<i;s+=3)Fw[0]=e[s+0],Fw[1]=e[s+1],Fw[2]=e[s+2],Fw[3]=1,R.transformVec4(o,Fw,xw),Re.compressPosition(xw,z,Fw),t[s+0]=Fw[0],t[s+1]=Fw[1],t[s+2]=Fw[2];i.createMesh(j.apply(N,{id:L,textureSetId:c,origin:W,primitive:x.primitiveName,positionsCompressed:t,normalsCompressed:x.geometryNormals,uv:x.geometryUVs,colorsCompressed:x.geometryColors,indices:x.geometryIndices,edgeIndices:x.geometryEdgeIndices,positionsDecodeMatrix:m,color:P,metallic:D,roughness:O,opacity:S})),k.push(L)}else{if(!Q[l]){let e={id:l,primitive:x.primitiveName,normalsCompressed:x.geometryNormals,uv:x.geometryUVs,colorsCompressed:x.geometryColors,indices:x.geometryIndices,edgeIndices:x.geometryEdgeIndices};e=x.geometryPositions?{...e,positionsCompressed:x.geometryPositions,positionsDecodeMatrix:b}:{...e,positions:x.decompressedPositions},i.createGeometry(e),Q[l]=!0}i.createMesh(j.apply(N,{id:L,geometryId:l,textureSetId:c,matrix:o,color:P,metallic:D,roughness:O,opacity:S,origin:W})),k.push(L)}}else{const e=B[r],t=y[r];let s,n,A,o,l,_,b,x,U=!1;switch(e){case 0:s="solid",n=h.subarray(w[r],a?h.length:w[r+1]),A=u.subarray(v[r],a?u.length:v[r+1]),o=p.subarray(M[r],a?p.length:M[r+1]),_=f.subarray(E[r],a?f.length:E[r+1]),b=g.subarray(F[r],a?g.length:F[r+1]),U=n.length>0&&_.length>0;break;case 1:s="surface",n=h.subarray(w[r],a?h.length:w[r+1]),A=u.subarray(v[r],a?u.length:v[r+1]),o=p.subarray(M[r],a?p.length:M[r+1]),_=f.subarray(E[r],a?f.length:E[r+1]),b=g.subarray(F[r],a?g.length:F[r+1]),U=n.length>0&&_.length>0;break;case 2:s="points",n=h.subarray(w[r],a?h.length:w[r+1]),l=d.subarray(C[r],a?d.length:C[r+1]),U=n.length>0;break;case 3:s="lines",n=h.subarray(w[r],a?h.length:w[r+1]),_=f.subarray(E[r],a?f.length:E[r+1]),U=n.length>0&&_.length>0;break;case 4:s="lines",n=h.subarray(w[r],a?h.length:w[r+1]),_=Tw(n,f.subarray(E[r],a?f.length:E[r+1])),U=n.length>0&&_.length>0;break;case 7:s="lines",n=h.subarray(w[r],a?h.length:w[r+1]),n=Re.decompressPositions(n,m),x=qe({origin:n,text:t,size:2}),n=x.positions,_=x.indices,U=n.length>0&&_.length>0;break;default:continue}if(U){let t=j.apply(N,{id:L,textureSetId:c,origin:W,primitive:s,normalsCompressed:A,uv:o&&o.length>0?o:null,colorsCompressed:l,indices:_,edgeIndices:b,color:P,metallic:D,roughness:O,opacity:S});t=7!==e?{...t,positionsCompressed:n,positionsDecodeMatrix:m}:{...t,positions:n},i.createMesh(t),k.push(L)}}}k.length>0&&i.createEntity(j.apply(L,{id:a,isObject:!0,meshIds:k}))}}}function Tw(e,t){const s=[];if(t.length>1)for(let e=0,i=t.length-1;e<i;e++)s.push(t[e]),s.push(t[e+1]);else if(e.length>1)for(let t=0,i=e.length/3-1;t<i;t++)s.push(t),s.push(t+1);return s}!function(){const e=document.createElement("canvas"),t=e.getContext("2d")}();const Pw={version:12,parseArrayBuffer:function(e,t,s,i,r,n){const A=function(e){const t=function(){const e=new ArrayBuffer(2);return new Uint16Array(e)[0]=1,1!==new Uint8Array(e)[0]}(),s=function(){let s=0;const i=new DataView(e);return function(r){const n=1+2*s++,A=i.getUint32(4*n,!0),o=i.getUint32(4*(n+1),!0),a=r.BYTES_PER_ELEMENT;if(t&&a>1){const t=new Uint8Array(e,A,o),s=a/2,i=t.length/a;for(let e=0;e<i;e++){const i=e*a;for(let e=0;e<s;e++){const s=i+e,r=i-e+a-1,n=t[s];t[s]=t[r],t[r]=n}}}return new r(e,A,o/a)}}(),i=function(){const e=new TextDecoder;return()=>JSON.parse(e.decode(s(Uint8Array)))}();return{metadata:i(),textureData:s(Uint8Array),eachTextureDataPortion:s(Uint32Array),eachTextureAttributes:s(Uint16Array),positions:s(Uint16Array),normals:s(Int8Array),colors:s(Uint8Array),uvs:s(Float32Array),indices:s(Uint32Array),edgeIndices:s(Uint32Array),eachTextureSetTextures:s(Int32Array),matrices:s(Float32Array),reusedGeometriesDecodeMatrix:s(Float32Array),eachGeometryPrimitiveType:s(Uint8Array),eachGeometryAxisLabel:i(),eachGeometryPositionsPortion:s(Uint32Array),eachGeometryNormalsPortion:s(Uint32Array),eachGeometryColorsPortion:s(Uint32Array),eachGeometryUVsPortion:s(Uint32Array),eachGeometryIndicesPortion:s(Uint32Array),eachGeometryEdgeIndicesPortion:s(Uint32Array),eachMeshGeometriesPortion:s(Uint32Array),eachMeshMatricesPortion:s(Uint32Array),eachMeshTextureSet:s(Int32Array),eachMeshMaterialAttributes:s(Uint8Array),eachEntityId:i(),eachEntityMeshesPortion:s(Uint32Array),eachTileAABB:s(Float64Array),eachTileEntitiesPortion:s(Uint32Array)}}(s);Iw(e,t,A,i,r,n)},parse:function(e,t,s,i,r,n){const A=function(e){let t=0;return{metadata:e[t++],textureData:e[t++],eachTextureDataPortion:e[t++],eachTextureAttributes:e[t++],positions:e[t++],normals:e[t++],colors:e[t++],uvs:e[t++],indices:e[t++],edgeIndices:e[t++],eachTextureSetTextures:e[t++],matrices:e[t++],reusedGeometriesDecodeMatrix:e[t++],eachGeometryPrimitiveType:e[t++],eachGeometryAxisLabel:e[t++],eachGeometryPositionsPortion:e[t++],eachGeometryNormalsPortion:e[t++],eachGeometryColorsPortion:e[t++],eachGeometryUVsPortion:e[t++],eachGeometryIndicesPortion:e[t++],eachGeometryEdgeIndicesPortion:e[t++],eachMeshGeometriesPortion:e[t++],eachMeshMatricesPortion:e[t++],eachMeshTextureSet:e[t++],eachMeshMaterialAttributes:e[t++],eachEntityId:e[t++],eachEntityMeshesPortion:e[t++],eachTileAABB:e[t++],eachTileEntitiesPortion:e[t++]}}(s),o=function(e){function t(e,t){return 0===e.length?[]:Ew.inflate(e,t).buffer}return{metadata:JSON.parse(Ew.inflate(e.metadata,{to:"string"})),textureData:new Uint8Array(t(e.textureData)),eachTextureDataPortion:new Uint32Array(t(e.eachTextureDataPortion)),eachTextureAttributes:new Uint16Array(t(e.eachTextureAttributes)),positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),colors:new Uint8Array(t(e.colors)),uvs:new Float32Array(t(e.uvs)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),eachTextureSetTextures:new Int32Array(t(e.eachTextureSetTextures)),matrices:new Float32Array(t(e.matrices)),reusedGeometriesDecodeMatrix:new Float32Array(t(e.reusedGeometriesDecodeMatrix)),eachGeometryPrimitiveType:new Uint8Array(t(e.eachGeometryPrimitiveType)),eachGeometryAxisLabel:JSON.parse(Ew.inflate(e.eachGeometryAxisLabel,{to:"string"})),eachGeometryPositionsPortion:new Uint32Array(t(e.eachGeometryPositionsPortion)),eachGeometryNormalsPortion:new Uint32Array(t(e.eachGeometryNormalsPortion)),eachGeometryColorsPortion:new Uint32Array(t(e.eachGeometryColorsPortion)),eachGeometryUVsPortion:new Uint32Array(t(e.eachGeometryUVsPortion)),eachGeometryIndicesPortion:new Uint32Array(t(e.eachGeometryIndicesPortion)),eachGeometryEdgeIndicesPortion:new Uint32Array(t(e.eachGeometryEdgeIndicesPortion)),eachMeshGeometriesPortion:new Uint32Array(t(e.eachMeshGeometriesPortion)),eachMeshMatricesPortion:new Uint32Array(t(e.eachMeshMatricesPortion)),eachMeshTextureSet:new Int32Array(t(e.eachMeshTextureSet)),eachMeshMaterialAttributes:new Uint8Array(t(e.eachMeshMaterialAttributes)),eachEntityId:JSON.parse(Ew.inflate(e.eachEntityId,{to:"string"})),eachEntityMeshesPortion:new Uint32Array(t(e.eachEntityMeshesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(A);Iw(e,t,o,i,r,n)}},Sw={};Sw[Oy.version]=Oy,Sw[Hy.version]=Hy,Sw[jy.version]=jy,Sw[Xy.version]=Xy,Sw[Jy.version]=Jy,Sw[qy.version]=qy,Sw[iw.version]=iw,Sw[lw.version]=lw,Sw[pw.version]=pw,Sw[Bw.version]=Bw,Sw[Mw.version]=Mw,Sw[Pw.version]=Pw;var Dw={};!function(e){var t,s="File format is not recognized.",i="Error while reading zip file.",r="Error while reading file data.",n=524288,A="text/plain";try{t=0===new Blob([new DataView(new ArrayBuffer(0))]).size}catch(e){}function o(){this.crc=-1}function a(){}function l(e,t){var s,i;return s=new ArrayBuffer(e),i=new Uint8Array(s),t&&i.set(t,0),{buffer:s,array:i,view:new DataView(s)}}function c(){}function h(e){var t,s=this;s.size=0,s.init=function(i,r){var n=new Blob([e],{type:A});(t=new d(n)).init((function(){s.size=t.size,i()}),r)},s.readUint8Array=function(e,s,i,r){t.readUint8Array(e,s,i,r)}}function u(t){var s,i=this;i.size=0,i.init=function(e){for(var r=t.length;"="==t.charAt(r-1);)r--;s=t.indexOf(",")+1,i.size=Math.floor(.75*(r-s)),e()},i.readUint8Array=function(i,r,n){var A,o=l(r),a=4*Math.floor(i/3),c=4*Math.ceil((i+r)/3),h=e.atob(t.substring(a+s,c+s)),u=i-3*Math.floor(a/4);for(A=u;A<u+r;A++)o.array[A-u]=h.charCodeAt(A);n(o.array)}}function d(e){var t=this;t.size=0,t.init=function(s){t.size=e.size,s()},t.readUint8Array=function(t,s,i,r){var n=new FileReader;n.onload=function(e){i(new Uint8Array(e.target.result))},n.onerror=r;try{n.readAsArrayBuffer(function(e,t,s){if(t<0||s<0||t+s>e.size)throw new RangeError("offset:"+t+", length:"+s+", size:"+e.size);return e.slice?e.slice(t,t+s):e.webkitSlice?e.webkitSlice(t,t+s):e.mozSlice?e.mozSlice(t,t+s):e.msSlice?e.msSlice(t,t+s):void 0}(e,t,s))}catch(e){r(e)}}}function p(){}function f(e){var s,i=this;i.init=function(e){s=new Blob([],{type:A}),e()},i.writeUint8Array=function(e,i){s=new Blob([s,t?e:e.buffer],{type:A}),i()},i.getData=function(t,i){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onerror=i,r.readAsText(s,e)}}function g(t){var s=this,i="",r="";s.init=function(e){i+="data:"+(t||"")+";base64,",e()},s.writeUint8Array=function(t,s){var n,A=r.length,o=r;for(r="",n=0;n<3*Math.floor((A+t.length)/3)-A;n++)o+=String.fromCharCode(t[n]);for(;n<t.length;n++)r+=String.fromCharCode(t[n]);o.length>2?i+=e.btoa(o):r=o,s()},s.getData=function(t){t(i+e.btoa(r))}}function m(e){var s,i=this;i.init=function(t){s=new Blob([],{type:e}),t()},i.writeUint8Array=function(i,r){s=new Blob([s,t?i:i.buffer],{type:e}),r()},i.getData=function(e){e(s)}}function _(e,t,s,i,r,A,o,a,l,c){var h,u,d,p=0,f=t.sn;function g(){e.removeEventListener("message",m,!1),a(u,d)}function m(t){var s=t.data,r=s.data,n=s.error;if(n)return n.toString=function(){return"Error: "+this.message},void l(n);if(s.sn===f)switch("number"==typeof s.codecTime&&(e.codecTime+=s.codecTime),"number"==typeof s.crcTime&&(e.crcTime+=s.crcTime),s.type){case"append":r?(u+=r.length,i.writeUint8Array(r,(function(){_()}),c)):_();break;case"flush":d=s.crc,r?(u+=r.length,i.writeUint8Array(r,(function(){g()}),c)):g();break;case"progress":o&&o(h+s.loaded,A);break;case"importScripts":case"newTask":case"echo":break;default:console.warn("zip.js:launchWorkerProcess: unknown message: ",s)}}function _(){(h=p*n)<=A?s.readUint8Array(r+h,Math.min(n,A-h),(function(s){o&&o(h,A);var i=0===h?t:{sn:f};i.type="append",i.data=s;try{e.postMessage(i,[s.buffer])}catch(t){e.postMessage(i)}p++}),l):e.postMessage({sn:f,type:"flush"})}u=0,e.addEventListener("message",m,!1),_()}function b(e,t,s,i,r,A,a,l,c,h){var u,d=0,p=0,f="input"===A,g="output"===A,m=new o;!function A(){var o;if((u=d*n)<r)t.readUint8Array(i+u,Math.min(n,r-u),(function(t){var i;try{i=e.append(t,(function(e){a&&a(u+e,r)}))}catch(e){return void c(e)}i?(p+=i.length,s.writeUint8Array(i,(function(){d++,setTimeout(A,1)}),h),g&&m.append(i)):(d++,setTimeout(A,1)),f&&m.append(t),a&&a(u,r)}),c);else{try{o=e.flush()}catch(e){return void c(e)}o?(g&&m.append(o),p+=o.length,s.writeUint8Array(o,(function(){l(p,m.get())}),h)):l(p,m.get())}}()}function B(t,s,i,r,n,A,o,l,c,h,u){var d="input";e.zip.useWebWorkers&&o?_(t,{sn:s,codecClass:"NOOP",crcType:d},i,r,n,A,c,l,h,u):b(new a,i,r,n,A,d,c,l,h,u)}function y(e){var t,s,i="",r=["Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","ø","£","Ø","×","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","®","¬","½","¼","¡","«","»","_","_","_","¦","¦","Á","Â","À","©","¦","¦","+","+","¢","¥","+","+","-","-","+","-","+","ã","Ã","+","+","-","-","¦","-","+","¤","ð","Ð","Ê","Ë","È","i","Í","Î","Ï","+","+","_","_","¦","Ì","_","Ó","ß","Ô","Ò","õ","Õ","µ","þ","Þ","Ú","Û","Ù","ý","Ý","¯","´","","±","_","¾","¶","§","÷","¸","°","¨","·","¹","³","²","_"," "];for(t=0;t<e.length;t++)i+=(s=255&e.charCodeAt(t))>127?r[s-128]:String.fromCharCode(s);return i}function w(e){return decodeURIComponent(escape(e))}function v(e){var t,s="";for(t=0;t<e.length;t++)s+=String.fromCharCode(e[t]);return s}function C(e,t,s,i,r){e.version=t.view.getUint16(s,!0),e.bitFlag=t.view.getUint16(s+2,!0),e.compressionMethod=t.view.getUint16(s+4,!0),e.lastModDateRaw=t.view.getUint32(s+6,!0),e.lastModDate=function(e){var t=(4294901760&e)>>16,s=65535&e;try{return new Date(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&s)>>11,(2016&s)>>5,2*(31&s),0)}catch(e){}}(e.lastModDateRaw),1!=(1&e.bitFlag)?((i||8!=(8&e.bitFlag))&&(e.crc32=t.view.getUint32(s+10,!0),e.compressedSize=t.view.getUint32(s+14,!0),e.uncompressedSize=t.view.getUint32(s+18,!0)),4294967295!==e.compressedSize&&4294967295!==e.uncompressedSize?(e.filenameLength=t.view.getUint16(s+22,!0),e.extraFieldLength=t.view.getUint16(s+24,!0)):r("File is using Zip64 (4gb+ file size).")):r("File contains encrypted entry.")}function M(t,n,A){var o=0;function a(){}a.prototype.getData=function(i,n,a,c){var h=this;function u(e,t){c&&!function(e){var t=l(4);return t.view.setUint32(0,e),h.crc32==t.view.getUint32(0)}(t)?A("CRC failed."):i.getData((function(e){n(e)}))}function d(e){A(e||r)}function p(e){A(e||"Error while writing file data.")}t.readUint8Array(h.offset,30,(function(r){var n,f=l(r.length,r);1347093252==f.view.getUint32(0)?(C(h,f,4,!1,A),n=h.offset+30+h.filenameLength+h.extraFieldLength,i.init((function(){0===h.compressionMethod?B(h._worker,o++,t,i,n,h.compressedSize,c,u,a,d,p):function(t,s,i,r,n,A,o,a,l,c,h){var u=o?"output":"none";e.zip.useWebWorkers?_(t,{sn:s,codecClass:"Inflater",crcType:u},i,r,n,A,l,a,c,h):b(new e.zip.Inflater,i,r,n,A,u,l,a,c,h)}(h._worker,o++,t,i,n,h.compressedSize,c,u,a,d,p)}),p)):A(s)}),d)};var c={getEntries:function(e){var r=this._worker;!function(e){t.size<22?A(s):r(22,(function(){r(Math.min(65558,t.size),(function(){A(s)}))}));function r(s,r){t.readUint8Array(t.size-s,s,(function(t){for(var s=t.length-22;s>=0;s--)if(80===t[s]&&75===t[s+1]&&5===t[s+2]&&6===t[s+3])return void e(new DataView(t.buffer,s,22));r()}),(function(){A(i)}))}}((function(n){var o,c;o=n.getUint32(16,!0),c=n.getUint16(8,!0),o<0||o>=t.size?A(s):t.readUint8Array(o,t.size-o,(function(t){var i,n,o,h,u=0,d=[],p=l(t.length,t);for(i=0;i<c;i++){if((n=new a)._worker=r,1347092738!=p.view.getUint32(u))return void A(s);C(n,p,u+6,!0,A),n.commentLength=p.view.getUint16(u+32,!0),n.directory=16==(16&p.view.getUint8(u+38)),n.offset=p.view.getUint32(u+42,!0),o=v(p.array.subarray(u+46,u+46+n.filenameLength)),n.filename=2048==(2048&n.bitFlag)?w(o):y(o),n.directory||"/"!=n.filename.charAt(n.filename.length-1)||(n.directory=!0),h=v(p.array.subarray(u+46+n.filenameLength+n.extraFieldLength,u+46+n.filenameLength+n.extraFieldLength+n.commentLength)),n.comment=2048==(2048&n.bitFlag)?w(h):y(h),d.push(n),u+=46+n.filenameLength+n.extraFieldLength+n.commentLength}e(d)}),(function(){A(i)}))}))},close:function(e){this._worker&&(this._worker.terminate(),this._worker=null),e&&e()},_worker:null};e.zip.useWebWorkers?I("inflater",(function(e){c._worker=e,n(c)}),(function(e){A(e)})):n(c)}function E(e){return unescape(encodeURIComponent(e))}function F(e){var t,s=[];for(t=0;t<e.length;t++)s.push(e.charCodeAt(t));return s}function x(t,s,i,n){var A={},o=[],a=0,c=0;function h(e){i(e||"Error while writing zip file.")}function u(e){i(e||r)}var d={add:function(s,r,d,p,f){var g,m,y,w=this._worker;function v(e,s){var i=l(16);a+=e||0,i.view.setUint32(0,1347094280),void 0!==s&&(g.view.setUint32(10,s,!0),i.view.setUint32(4,s,!0)),r&&(i.view.setUint32(8,e,!0),g.view.setUint32(14,e,!0),i.view.setUint32(12,r.size,!0),g.view.setUint32(18,r.size,!0)),t.writeUint8Array(i.array,(function(){a+=16,d()}),h)}function C(){f=f||{},s=s.trim(),f.directory&&"/"!=s.charAt(s.length-1)&&(s+="/"),A.hasOwnProperty(s)?i("File already exists."):(m=F(E(s)),o.push(s),function(e){var i;y=f.lastModDate||new Date,g=l(26),A[s]={headerArray:g.array,directory:f.directory,filename:m,offset:a,comment:F(E(f.comment||""))},g.view.setUint32(0,335546376),f.version&&g.view.setUint8(0,f.version),n||0===f.level||f.directory||g.view.setUint16(4,2048),g.view.setUint16(6,(y.getHours()<<6|y.getMinutes())<<5|y.getSeconds()/2,!0),g.view.setUint16(8,(y.getFullYear()-1980<<4|y.getMonth()+1)<<5|y.getDate(),!0),g.view.setUint16(22,m.length,!0),(i=l(30+m.length)).view.setUint32(0,1347093252),i.array.set(g.array,4),i.array.set(m,30),a+=i.array.length,t.writeUint8Array(i.array,e,h)}((function(){r?n||0===f.level?B(w,c++,r,t,0,r.size,!0,v,p,u,h):function(t,s,i,r,n,A,o,a,l){var c="input";e.zip.useWebWorkers?_(t,{sn:s,options:{level:n},codecClass:"Deflater",crcType:c},i,r,0,i.size,o,A,a,l):b(new e.zip.Deflater,i,r,0,i.size,c,o,A,a,l)}(w,c++,r,t,f.level,v,p,u,h):v()})))}r?r.init(C,u):C()},close:function(e){this._worker&&(this._worker.terminate(),this._worker=null);var s,i,r,n=0,c=0;for(i=0;i<o.length;i++)n+=46+(r=A[o[i]]).filename.length+r.comment.length;for(s=l(n+22),i=0;i<o.length;i++)r=A[o[i]],s.view.setUint32(c,1347092738),s.view.setUint16(c+4,5120),s.array.set(r.headerArray,c+6),s.view.setUint16(c+32,r.comment.length,!0),r.directory&&s.view.setUint8(c+38,16),s.view.setUint32(c+42,r.offset,!0),s.array.set(r.filename,c+46),s.array.set(r.comment,c+46+r.filename.length),c+=46+r.filename.length+r.comment.length;s.view.setUint32(c,1347093766),s.view.setUint16(c+8,o.length,!0),s.view.setUint16(c+10,o.length,!0),s.view.setUint32(c+12,n,!0),s.view.setUint32(c+16,a,!0),t.writeUint8Array(s.array,(function(){t.getData(e)}),h)},_worker:null};e.zip.useWebWorkers?I("deflater",(function(e){d._worker=e,s(d)}),(function(e){i(e)})):s(d)}o.prototype.append=function(e){for(var t=0|this.crc,s=this.table,i=0,r=0|e.length;i<r;i++)t=t>>>8^s[255&(t^e[i])];this.crc=t},o.prototype.get=function(){return~this.crc},o.prototype.table=function(){var e,t,s,i=[];for(e=0;e<256;e++){for(s=e,t=0;t<8;t++)1&s?s=s>>>1^3988292384:s>>>=1;i[e]=s}return i}(),a.prototype.append=function(e,t){return e},a.prototype.flush=function(){},h.prototype=new c,h.prototype.constructor=h,u.prototype=new c,u.prototype.constructor=u,d.prototype=new c,d.prototype.constructor=d,p.prototype.getData=function(e){e(this.data)},f.prototype=new p,f.prototype.constructor=f,g.prototype=new p,g.prototype.constructor=g,m.prototype=new p,m.prototype.constructor=m;var U={deflater:["z-worker.js","deflate.js"],inflater:["z-worker.js","inflate.js"]};function I(t,s,i){if(null===e.zip.workerScripts||null===e.zip.workerScriptsPath){var r;if(e.zip.workerScripts){if(r=e.zip.workerScripts[t],!Array.isArray(r))return void i(new Error("zip.workerScripts."+t+" is not an array!"));r=function(e){var t=document.createElement("a");return e.map((function(e){return t.href=e,t.href}))}(r)}else(r=U[t].slice(0))[0]=(e.zip.workerScriptsPath||"")+r[0];var n=new Worker(r[0]);n.codecTime=n.crcTime=0,n.postMessage({type:"importScripts",scripts:r.slice(1)}),n.addEventListener("message",(function e(t){var r=t.data;if(r.error)return n.terminate(),void i(r.error);"importScripts"===r.type&&(n.removeEventListener("message",e),n.removeEventListener("error",A),s(n))})),n.addEventListener("error",A)}else i(new Error("Either zip.workerScripts or zip.workerScriptsPath may be set, not both."));function A(e){n.terminate(),i(e)}}function T(e){console.error(e)}e.zip={Reader:c,Writer:p,BlobReader:d,Data64URIReader:u,TextReader:h,BlobWriter:m,Data64URIWriter:g,TextWriter:f,createReader:function(e,t,s){s=s||T,e.init((function(){M(e,t,s)}),s)},createWriter:function(e,t,s,i){s=s||T,i=!!i,e.init((function(){x(e,t,s,i)}),s)},useWebWorkers:!0,workerScriptsPath:null,workerScripts:null}}(Dw);const kw=Dw.zip;!function(e){var t,s,i=e.Reader,r=e.Writer;try{s=0===new Blob([new DataView(new ArrayBuffer(0))]).size}catch(e){}function n(e){var t=this;function s(s,i){var r;t.data?s():((r=new XMLHttpRequest).addEventListener("load",(function(){t.size||(t.size=Number(r.getResponseHeader("Content-Length"))||Number(r.response.byteLength)),t.data=new Uint8Array(r.response),s()}),!1),r.addEventListener("error",i,!1),r.open("GET",e),r.responseType="arraybuffer",r.send())}t.size=0,t.init=function(i,r){if(function(e){var t=document.createElement("a");return t.href=e,"http:"===t.protocol||"https:"===t.protocol}(e)){var n=new XMLHttpRequest;n.addEventListener("load",(function(){t.size=Number(n.getResponseHeader("Content-Length")),t.size?i():s(i,r)}),!1),n.addEventListener("error",r,!1),n.open("HEAD",e),n.send()}else s(i,r)},t.readUint8Array=function(e,i,r,n){s((function(){r(new Uint8Array(t.data.subarray(e,e+i)))}),n)}}function A(e){var t=this;t.size=0,t.init=function(s,i){var r=new XMLHttpRequest;r.addEventListener("load",(function(){t.size=Number(r.getResponseHeader("Content-Length")),"bytes"==r.getResponseHeader("Accept-Ranges")?s():i("HTTP Range not supported.")}),!1),r.addEventListener("error",i,!1),r.open("HEAD",e),r.send()},t.readUint8Array=function(t,s,i,r){!function(t,s,i,r){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="arraybuffer",n.setRequestHeader("Range","bytes="+t+"-"+(t+s-1)),n.addEventListener("load",(function(){i(n.response)}),!1),n.addEventListener("error",r,!1),n.send()}(t,s,(function(e){i(new Uint8Array(e))}),r)}}function o(e){var t=this;t.size=0,t.init=function(s,i){t.size=e.byteLength,s()},t.readUint8Array=function(t,s,i,r){i(new Uint8Array(e.slice(t,t+s)))}}function a(){var e,t=this;t.init=function(t,s){e=new Uint8Array,t()},t.writeUint8Array=function(t,s,i){var r=new Uint8Array(e.length+t.length);r.set(e),r.set(t,e.length),e=r,s()},t.getData=function(t){t(e.buffer)}}function l(e,t){var i,r=this;r.init=function(t,s){e.createWriter((function(e){i=e,t()}),s)},r.writeUint8Array=function(e,r,n){var A=new Blob([s?e:e.buffer],{type:t});i.onwrite=function(){i.onwrite=null,r()},i.onerror=n,i.write(A)},r.getData=function(t){e.file(t)}}n.prototype=new i,n.prototype.constructor=n,A.prototype=new i,A.prototype.constructor=A,o.prototype=new i,o.prototype.constructor=o,a.prototype=new r,a.prototype.constructor=a,l.prototype=new r,l.prototype.constructor=l,e.FileWriter=l,e.HttpReader=n,e.HttpRangeReader=A,e.ArrayBufferReader=o,e.ArrayBufferWriter=a,e.fs&&((t=e.fs.ZipDirectoryEntry).prototype.addHttpContent=function(s,i,r){return function(s,i,r,n){if(s.directory)return n?new t(s.fs,i,r,s):new e.fs.ZipFileEntry(s.fs,i,r,s);throw"Parent entry is not a directory."}(this,s,{data:i,Reader:r?A:n})},t.prototype.importHttpContent=function(e,t,s,i){this.importZip(t?new A(e):new n(e),s,i)},e.fs.FS.prototype.importHttpContent=function(e,s,i,r){this.entries=[],this.root=new t(this),this.root.importHttpContent(e,s,i,r)})}(kw);const Qw=["4.2"];class Rw{constructor(e,t={}){this.supportedSchemas=Qw,this._xrayOpacity=.7,this._src=null,this._options=t,this.viewpoint=null,t.workerScriptsPath?(kw.workerScriptsPath=t.workerScriptsPath,this.src=t.src,this.xrayOpacity=.7,this.displayEffect=t.displayEffect,this.createMetaModel=t.createMetaModel):e.error("Config expected: workerScriptsPath")}load(e,t,s,i,r,n){switch(i.materialType){case"MetallicMaterial":t._defaultMaterial=new as(t,{baseColor:[1,1,1],metallic:.6,roughness:.6});break;case"SpecularMaterial":t._defaultMaterial=new hs(t,{diffuse:[1,1,1],specular:R.vec3([1,1,1]),glossiness:.5});break;default:t._defaultMaterial=new jt(t,{reflectivity:.75,shiness:100,diffuse:[1,1,1]})}t._wireframeMaterial=new ns(t,{color:[0,0,0],lineWidth:2});var A=t.scene.canvas.spinner;A.processes++,Ow(e,t,s,i,(function(){A.processes--,r&&r(),t.fire("loaded",!0,!1)}),(function(e){A.processes--,t.error(e),n&&n(e),t.fire("error",e)}),(function(e){console.log("Error, Will Robinson: "+e)}))}}var Ow=function(e,t,s,i,r,n){!function(e,t,s){var i=new zw;i.load(e,(function(){t(i)}),(function(e){s("Error loading ZIP archive: "+e)}))}(s,(function(s){Vw(e,s,i,t,r,n)}),n)},Vw=function(){return function(t,s,i,r,n){var A={plugin:t,zip:s,edgeThreshold:30,materialType:i.materialType,scene:r.scene,modelNode:r,info:{references:{}},materials:{}};i.createMetaModel&&(A.metaModelData={modelId:r.id,metaObjects:[{name:r.id,type:"Default",id:r.id}]}),r.scene.loading++,function(t,s){t.zip.getFile("Manifest.xml",(function(i,r){for(var n=r.children,A=0,o=n.length;A<o;A++){var a=n[A];if("Manifest"===a.type)e(t,a,s)}}))}(A,(function(){A.metaModelData&&t.viewer.metaScene.createMetaModel(r.id,A.metaModelData),r.scene.loading--,n()}))};function e(e,s,i){for(var r=s.children,n=0,A=r.length;n<A;n++){var o=r[n];if("Root"===o.type){var a=o.children[0];e.zip.getFile(a,(function(s,r){t(e,r,i)}))}}}function t(e,t,i){for(var r=t.children,n=0,A=r.length;n<A;n++){var o=r[n];if("Model_3dxml"===o.type)s(e,o,i)}}function s(e,t,s){for(var r=t.children,o=0,a=r.length;o<a;o++){var l=r[o];switch(l.type){case"Header":i(e,l);break;case"ProductStructure":n(e,l,s);break;case"DefaultView":A(e,l)}}}function i(e,t){for(var s=t.children,i={},n=0,A=s.length;n<A;n++){var o=s[n];switch(o.type){case"SchemaVersion":i.schemaVersion=o.children[0],r(e,i.schemaVersion)||e.plugin.error("Schema version not supported: "+i.schemaVersion+" - supported versions are: "+Qw.join(","));break;case"Title":i.title=o.children[0];break;case"Author":i.author=o.children[0];break;case"Created":i.created=o.children[0]}}e.modelNode.meta=i}function r(e,t){for(var s=0,i=Qw.length;s<i;s++)if(t===Qw[s])return!0;return!1}function n(e,t,s){!function(e,t,s){for(var i={},r=t.children,n=0,A=0,a=r.length;A<a;A++){"ReferenceRep"===(l=r[A]).type&&n++}for(A=0,a=r.length;A<a;A++){var l;if("ReferenceRep"===(l=r[A]).type)if(l.associatedFile){var c=Xw(l.associatedFile);!function(){var t=l.id;e.zip.getFile(c,(function(r,A){var a=r.getElementsByTagName("MaterialId");Lw(e,a,(function(){var r={id:t};o(e,A,r),i[t]=r,0==--n&&s(i)}))}),(function(e){}))}()}}}(e,t,(function(i){for(var r=t.children,n={},A={},o={},a=0,l=r.length;a<l;a++){var c=r[a];switch(c.type){case"Reference3D":n[c.id]={type:"Reference3D",id:c.id,name:c.name,instance3Ds:{},instanceReps:{}};break;case"InstanceRep":for(var h=0,u=c.children.length;h<u;h++){switch((m=c.children[h]).type){case"IsAggregatedBy":d=m.children[0];break;case"IsInstanceOf":p=m.children[0]}}A[c.id]={type:"InstanceRep",id:c.id,name:c.name,isAggregatedBy:d,isInstanceOf:p,referenceReps:{}};break;case"Instance3D":var d,p,g;for(h=0,u=c.children.length;h<u;h++){var m;switch((m=c.children[h]).type){case"IsAggregatedBy":d=m.children[0];break;case"IsInstanceOf":p=m.children[0];break;case"RelativeMatrix":g=m.children[0]}}o[c.id]={type:"Instance3D",id:c.id,name:c.name,isAggregatedBy:d,isInstanceOf:p,relativeMatrix:g,reference3Ds:{}}}}for(var _ in o){(B=n[(b=o[_]).isAggregatedBy])?B.instance3Ds[b.id]=b:alert("foo")}for(var _ in o){var b,B=n[(b=o[_]).isInstanceOf];b.reference3Ds[B.id]=B,B.instance3D=b}for(var _ in A){var y=i[(w=A[_]).isInstanceOf];y&&(w.referenceReps[y.id]=y)}for(var _ in A){var w;(B=n[(w=A[_]).isAggregatedBy])&&(B.instanceReps[w.id]=w)}function v(e,t,s){for(var i in t.instance3Ds)C(e,t.instance3Ds[i],s);for(var i in t.instanceReps)M(e,t.instanceReps[i],s)}function C(e,t,s){if(t.relativeMatrix){var i=f(t.relativeMatrix,12),r=[i[9],i[10],i[11]],n=i.slice(0,9),A=R.mat3ToMat4(n,R.identityMat4()),o=new ct(e.modelNode,{position:r});e.metaModelData&&e.metaModelData.metaObjects.push({id:o.id,type:"Default",name:t.name,parent:s?s.id:e.modelNode.id}),s?s.addChild(o,!0):e.modelNode.addChild(o,!0),s=o,o=new ct(e.modelNode,{matrix:A}),e.metaModelData&&e.metaModelData.metaObjects.push({id:o.id,type:"Default",name:t.name,parent:s?s.id:e.modelNode.id}),s.addChild(o,!0),s=o}else{o=new ct(e.modelNode,{});e.metaModelData&&e.metaModelData.metaObjects.push({id:o.id,type:"Default",name:t.name,parent:s?s.id:e.modelNode.id}),s?s.addChild(o,!0):e.modelNode.addChild(o,!0),s=o}for(var a in t.reference3Ds)v(e,t.reference3Ds[a],s)}function M(e,t,s){if(t.referenceReps)for(var i in t.referenceReps){var r=t.referenceReps[i];for(var n in r)if("id"!==n){var A=r[n],o="lines"===A.geometry.primitive?e.modelNode._wireframeMaterial:A.materialId?e.materials[A.materialId]:null,a=A.color,l=new Ot(e.modelNode,{isObject:!0,geometry:A.geometry,material:o||e.modelNode._defaultMaterial,colorize:a,backfaces:!1});e.metaModelData&&e.metaModelData.metaObjects.push({id:l.id,type:"Default",name:t.name,parent:s?s.id:e.modelNode.id}),s?s.addChild(l,!0):e.modelNode.addChild(l,!0),l.colorize=a}}}for(var _ in n){if(!(B=n[_]).instance3D)return v(e,B,null),void s()}alert("No root Reference3D element found in this modelNode - can't load."),s()}))}function A(e,t){for(var s=t.children,i=0,r=s.length;i<r;i++){var n=s[i];if("Viewpoint"===n.type){var A=n.children;e.modelNode.viewpoint={};for(var o=0,a=A.length;o<a;o++){var l=A[i];switch(l.type){case"Position":e.modelNode.viewpoint.eye=f(l.children[0],3);break;case"Sight":e.modelNode.viewpoint.look=f(l.children[0],3);break;case"Up":e.modelNode.viewpoint.up=f(l.children[0],3)}}}}}function o(e,t,s){for(var i=t.children,r=0,n=i.length;r<n;r++){var A=i[r];if("XMLRepresentation"===A.type)a(e,A,s)}}function a(e,t,s){for(var i=t.children,r=0,n=i.length;r<n;r++){var A=i[r];if("Root"===A.type)l(e,A,s)}}function l(e,t,s){t["xsi:type"];for(var i=t.children,r=0,n=i.length;r<n;r++){var A=i[r];if("Rep"===A.type)c(e,A,s)}}function c(e,t,s){t["xsi:type"];for(var i={edgeThreshold:e.edgeThreshold||30,compressGeometry:!0},r=t.children,n=0,A=r.length;n<A;n++){var o=r[n];switch(o.type){case"Rep":c(e,o,s);break;case"Edges":break;case"Faces":i.primitive="triangles",h(e,o,i);break;case"VertexBuffer":p(e,o,i);break;case"SurfaceAttributes":g(e,o,i)}}if(i.positions){var a=new Le(e.modelNode,i);s[a.id]={geometry:a,color:i.color||[1,1,1,1],materialId:i.materialId}}}function h(e,t,s){for(var i=t.children,r=0,n=i.length;r<n;r++){var A=i[r];if("Face"===A.type)u(e,A,s)}}function u(e,t,s){var i=t.strips;if(i){var r=function(e){for(var t=e.split(","),s=[],i=0,r=t.length;i<r;i++){var n=t[i].trim();if(n.length>0){for(var A=n.trim().split(" "),o=new Int16Array(A.length),a=0,l=0,c=A.length;l<c;l++)""!==A[l]&&(o[a++]=parseInt(A[l]));s.push(o)}}return s}(i);if(r.length>0){s.primitive="triangles";for(var n=[],A=0,o=r.length;A<o;A++)for(var a=d(r[A]),l=0,c=a.length;l<c;l++)n.push(a[l]);s.indices=n}}else{var h=t.triangles;h&&(s.primitive="triangles",s.indices=function(e){e=e.trim().split(" ");for(var t=new Int32Array(e.length),s=0,i=e.length;s<i;s++){var r=e[s];t[s]=parseInt(r)}return t}(h))}var u=t.children;for(A=0,o=u.length;A<o;A++){var p=u[A];if("SurfaceAttributes"===p.type)g(e,p,s)}}function d(e){for(var t=[],s=0,i=e.length;s<i-2;s++)1&s?(t.push(e[s]),t.push(e[s+2]),t.push(e[s+1])):(t.push(e[s]),t.push(e[s+1]),t.push(e[s+2]));return t}function p(e,t,s){for(var i=t.children,r=0,n=i.length;r<n;r++){var A=i[r];switch(A.type){case"Positions":s.positions=f(A.children[0],3);break;case"Normals":s.normals=f(A.children[0],3);break;case"TextureCoordinates":s.uv=f(A.children[0],2)}}}function f(e,t){e=e.split(",");for(var s=new Float32Array(e.length*t),i=0,r=0,n=e.length;r<n;r++)for(var A=e[r],o=0,a=(A=A.split(" ")).length;o<a;o++)""!==A[o]&&(s[i++]=parseFloat(A[o]));return s}function g(e,t,s){s.color=[1,1,1,1];for(var i,r,n=t.children,A=0,o=n.length;A<o;A++){var a=n[A];switch(a.type){case"Color":s.color[0]=a.red,s.color[1]=a.green,s.color[2]=a.blue,s.color[3]=a.alpha;break;case"MaterialApplication":for(var l=a.children,c=0,h=l.length;c<h;c++){var u=l[c];if("MaterialId"===u.type){var d=(i=u.id,r=void 0,-1!==(r=i.lastIndexOf("#"))?i.substring(r+1):i);e.materials[d]||e.plugin.error("material not found: "+d),s.materialId=d}}}}}}();function Lw(e,t,s){var i={};!function r(n,A){if(n>=t.length)s();else{var o=t[n].id,a=o.lastIndexOf(":");a>0&&(o=o.substring(a+1));var l=o.lastIndexOf("#");l>0&&(o=o.substring(0,l)),i[o]?r(n+1):function(e,t,s){e.zip.getFile(t,(function(t,i){!function(e,t,s){for(var i,r=t.children,n=0,A=r.length;n<A;n++)"Model_3dxml"===(i=r[n]).type&&Hw(e,i,s)}(e,i,s)}))}(e,o,(function(){i[o]=!0,r(n+1)}))}}(0)}function Hw(e,t,s){for(var i,r=t.children,n=0,A=r.length;n<A;n++)"CATMaterialRef"===(i=r[n]).type&&Nw(e,i,s)}function Nw(e,t,s){for(var i={},r=t.children,n=0,A=0,o=r.length;A<o;A++){if("MaterialDomainInstance"===(d=r[A]).type){for(var a,l,c=0,h=d.children.length;c<h;c++){var u=d.children[c];switch(u.type){case"IsAggregatedBy":a=u.children[0];break;case"IsInstanceOf":l=u.children[0]}}i[l]=a}}for(A=0,o=r.length;A<o;A++){if("MaterialDomain"===(d=r[A]).type)n++}for(A=0,o=r.length;A<o;A++){var d;if("MaterialDomain"===(d=r[A]).type)d.associatedFile&&function(){var t=d.id,r=Xw(d.associatedFile);e.zip.getFile(r,(function(r,A){e.materials[i[t]]=Gw(e,A),0==--n&&s()}),(function(e){}))}()}}function Gw(e,t){for(var s=t.children,i=0,r=s.length;i<r;i++){var n=s[i];if("Osm"===n.type)return jw(e,n)}}function jw(e,t){for(var s=t.children,i=0,r=s.length;i<r;i++){var n=s[i];switch(n.type){case"RenderingRootFeature":break;case"Feature":if("RenderingFeature"===n.Alias){var A,o,a,l,c={},h={},u=n.children;for(A=0,o=u.length;A<o;A++)switch((a=u[A]).Name){case"AmbientCoef":c.ambient=parseFloat(a.Value);break;case"DiffuseCoef":c.diffuse=parseFloat(a.Value);break;case"EmissiveCoef":c.emissive=parseFloat(a.Value);break;case"SpecularExponent":c.specular=parseFloat(a.Value)}for(A=0,o=u.length;A<o;A++)switch((a=u[A]).Name){case"AmbientColor":h.ambient=Ww(a.Value,c.ambient);break;case"DiffuseColor":h.diffuse=Ww(a.Value,c.diffuse);break;case"EmissiveColor":h.emissive=Ww(a.Value,c.emissive);break;case"SpecularColor":h.specular=Ww(a.Value,c.specular);break;case"Transparency":var d=1-parseFloat(a.Value);d<1&&(h.alpha=d,h.alphaMode="blend")}switch(e.materialType){case"MetallicMaterial":l=new as(e.modelNode,{baseColor:h.diffuse,metallic:.7,roughness:.5,emissive:h.emissive,alpha:h.alpha,alphaMode:h.alphaMode});break;case"SpecularMaterial":l=new hs(e.modelNode,{diffuse:h.diffuse,specular:h.specular,glossiness:.5,emissive:h.emissive,alpha:h.alpha,alphaMode:h.alphaMode});break;default:l=new jt(e.modelNode,{reflectivity:.5,ambient:h.ambient,diffuse:h.diffuse,specular:h.specular,emissive:h.emissive,alphaMode:h.alphaMode,alpha:t.alpha})}return l}}}}function Ww(e,t){t=void 0!==t?t:.5;var s=e.indexOf("["),i=e.indexOf("]");e=(e=e.substring(s+1,i-s)).split(",");for(var r=new Float32Array(e.length),n=0,A=0,o=e.length;A<o;A++)for(var a=e[A],l=0,c=(a=a.trim().split(" ")).length;l<c;l++)""!==a[l]&&(r[n++]=parseFloat(a[l])*t);return r}var zw=function(){var e={};function t(e,s){if(e.nodeType===e.TEXT_NODE){var i=e.nodeValue;if(null===i.match(/^\s+$/))return i}else if(e.nodeType===e.ELEMENT_NODE||e.nodeType===e.DOCUMENT_NODE){var r={type:e.nodeName,children:[]};if(e.nodeType===e.ELEMENT_NODE)for(var n=0;n<e.attributes.length;n++){var A=e.attributes[n];r[s[A.nodeName]||A.nodeName]=A.nodeValue}for(var o=0;o<e.childNodes.length;o++){(n=t(e.childNodes[o],s))&&r.children.push(n)}return r}}this.load=function(t,s,i){kw.createReader(new kw.HttpReader(t),(function(t){t.getEntries((function(t){if(t.length>0)for(var i=0,r=t.length;i<r;i++){var n=t[i];e[n.filename]=n}s()}))}),i)},this.getFile=function(s,i,r){var n=e[s];if(!n){var A="ZIP entry not found: "+s;return console.error(A),void(r&&r(A))}n.getData(new kw.TextWriter,(function(e){var s=(new DOMParser).parseFromString(e,"text/xml"),r=t(s,{});i(s,r)}))},this.destroy=function(){undefined.close((function(){}))}};function Xw(e){var t="urn:3DXML:";return 0===e.indexOf(t)?e.substring(t.length):e}class Kw{constructor(e={}){this.cacheBuster=!1!==e.cacheBuster}_cacheBusterURL(e){if(!this.cacheBuster)return e;const t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}getIFC(e,t,s){e=this._cacheBusterURL(e);var i=()=>{};t=t||i,s=s||i;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var n=r[3];n=window.decodeURIComponent(n),e&&(n=window.atob(n));try{const e=new ArrayBuffer(n.length),s=new Uint8Array(e);for(var A=0;A<n.length;A++)s[A]=n.charCodeAt(A);t(e)}catch(e){s(e)}}else{const i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onreadystatechange=function(){4===i.readyState&&(200===i.status?t(i.response):s("getXKT error : "+i.response))},i.send(null)}}}class Zw{constructor(e={}){this.cacheBuster=!1!==e.cacheBuster}_cacheBusterURL(e){if(!this.cacheBuster)return e;const t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}getIFC(e,t,s){e=this._cacheBusterURL(e);var i=()=>{};t=t||i,s=s||i;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var n=r[3];n=window.decodeURIComponent(n),e&&(n=window.atob(n));try{const e=new ArrayBuffer(n.length),s=new Uint8Array(e);for(var A=0;A<n.length;A++)s[A]=n.charCodeAt(A);t(e)}catch(e){s(e)}}else{const i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="text",i.onreadystatechange=function(){4===i.readyState&&(200===i.status?t(i.response):s("getIFC error : "+i.response))},i.send(null)}}}function Jw(e,t){return`${e}:${t}#geom`}function Yw(e,t){const s=new Uint32Array(3*e.length);let i=0;for(const r of e){const e=3*r;s[i++]=t[e+0],s[i++]=t[e+1],s[i++]=t[e+2]}return s}class $w{constructor(e={}){this.cacheBuster=!1!==e.cacheBuster}_cacheBusterURL(e){if(!this.cacheBuster)return e;const t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}getLAS(e,t,s){e=this._cacheBusterURL(e);var i=()=>{};t=t||i,s=s||i;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var n=r[3];n=window.decodeURIComponent(n),e&&(n=window.atob(n));try{const e=new ArrayBuffer(n.length),s=new Uint8Array(e);for(var A=0;A<n.length;A++)s[A]=n.charCodeAt(A);t(e)}catch(e){s(e)}}else{const i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onreadystatechange=function(){4===i.readyState&&(200===i.status?t(i.response):s("getLAS error : "+i.response))},i.send(null)}}getManifest(e,t,s){j.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}}const qw=[{item:"FileSignature",format:"char",size:4},{item:"FileSoureceID",format:"uShort",size:2},{item:"GlobalEncoding",format:"uShort",size:2},{item:"ProjectID1",format:"notUsed",size:4},{item:"ProjectID2",format:"notUsed",size:2},{item:"ProjectID3",format:"notUsed",size:2},{item:"ProjectID4",format:"notUsed",size:8},{item:"VersionMajor",format:"uChar",size:1},{item:"VersionMinor",format:"uChar",size:1},{item:"SystemIdentifier",format:"char",size:32},{item:"GeneratingSoftware",format:"char",size:32},{item:"CreationDay",format:"uShort",size:2},{item:"CreationYear",format:"uShort",size:2},{item:"HeaderSize",format:"uShort",size:2},{item:"OffsetToPointData",format:"uLong",size:4},{item:"NumberOfVariableLengthRecords",format:"uLong",size:4},{item:"PointDataFormatID",format:"uChar",size:1},{item:"PointDataRecordLength",format:"uShort",size:2},{item:"NumberOfPoints",format:"uLong",size:4},{item:"NumberOfPointByReturn",format:"uLong",size:20},{item:"ScaleFactorX",format:"double",size:8},{item:"ScaleFactorY",format:"double",size:8},{item:"ScaleFactorZ",format:"double",size:8},{item:"OffsetX",format:"double",size:8},{item:"OffsetY",format:"double",size:8},{item:"OffsetZ",format:"double",size:8},{item:"MaxX",format:"double",size:8},{item:"MinX",format:"double",size:8},{item:"MaxY",format:"double",size:8},{item:"MinY",format:"double",size:8},{item:"MaxZ",format:"double",size:8},{item:"MinZ",format:"double",size:8}],ev=[{item:"Reserved",format:"uShort",size:2},{item:"UserId",format:"char",size:16},{item:"RecordId",format:"uShort",size:2},{item:"RecordLengthAfterHeader",format:"uShort",size:2},{item:"Description",format:"char",size:32}],tv=e=>{let t=0,s=0,i=0;const r=new DataView(e),n=new Uint8Array(6e3),A=({item:i,format:n,size:A})=>{let o,a;switch(n){case"char":return a=new Uint8Array(e,t,A),t+=A,o=iv(a),[i,o];case"uShort":return o=r.getUint16(t,!0),t+=A,[i,o];case"uLong":return o=r.getUint32(t,!0),"NumberOfVariableLengthRecords"===i&&(s=o),t+=A,[i,o];case"uChar":return o=r.getUint8(t),t+=A,[i,o];case"double":return o=r.getFloat64(t,!0),t+=A,[i,o];default:t+=A}};return(()=>{const e={};qw.forEach((t=>{const s=A({...t});if(void 0!==s){if("FileSignature"===s[0]&&"LASF"!==s[1])throw new Error("Ivalid FileSignature. Is this a LAS/LAZ file");e[s[0]]=s[1]}}));const r=[];let o=s;for(;o--;){const e={};ev.forEach((s=>{const r=A({...s});e[r[0]]=r[1],"UserId"===r[0]&&"LASF_Projection"===r[1]&&(i=t-18+54)})),r.push(e)}const a=(e=>{if(void 0===e)return;const t=i+e.RecordLengthAfterHeader,s=n.slice(i,t),r=sv(s),A=new DataView(r);let o=6,a=Number(A.getUint16(o,!0));const l=[];for(;a--;){const e={};e.key=A.getUint16(o+=2,!0),e.tiffTagLocation=A.getUint16(o+=2,!0),e.count=A.getUint16(o+=2,!0),e.valueOffset=A.getUint16(o+=2,!0),l.push(e)}const c=l.find((e=>3072===e.key));if(c&&c.hasOwnProperty("valueOffset"))return c.valueOffset})(r.find((e=>"LASF_Projection"===e.UserId)));return a&&(e.epsg=a),e})()},sv=e=>{let t=new ArrayBuffer(e.length),s=new Uint8Array(t);for(let t=0;t<e.length;++t)s[t]=e[t];return t},iv=e=>{let t="";return e.forEach((e=>{let s=String.fromCharCode(e);"\0"!==s&&(t+=s)})),t.trim()};function rv(e,t){if(t>=e.length)return[e];let s=[];for(let i=0;i<e.length;i+=t)s.push(e.slice(i,i+t));return s}class nv{constructor(e={}){this.cacheBuster=!1!==e.cacheBuster}_cacheBusterURL(e){if(!this.cacheBuster)return e;const t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}getCityJSON(e,t,s){j.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}}const Av=R.vec2(),ov=R.vec3(),av=R.vec3(),lv=R.vec3();class cv{constructor(e={}){this.cacheBuster=!1!==e.cacheBuster}_cacheBusterURL(e){if(!this.cacheBuster)return e;const t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}getDotBIM(e,t,s){j.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){s(e)}))}}const hv=function(e){const t=t=>parseInt(e.substr(t+1,2),16)/255;return[t(0),t(2),t(4)]},uv=function(e,t,s){let i=null;const r=r=>{if(r){i&&i.destroy();try{const[n,A]=aB(r.map((e=>[e[0],e[2]]))),o=[].concat(...n.map((e=>[e[0],r[0][1],e[1]]))),a=[].concat(...A);i=new Ot(e,{pickable:!1,geometry:new Le(e,{positions:o,indices:a,normals:R.buildNormals(o,a)}),material:new jt(e,{alpha:void 0!==s?s:.5,backfaces:!0,diffuse:hv(t)})})}catch(e){i=null}}i&&(i.visible=!!r)};return r(null),{updateBase:r,destroy:()=>i&&i.destroy()}},dv=function(e,t){return function(s,i,r){const n=e.scene,A=n.canvas.canvas,o=(e,t)=>(t[0]=e.clientX,t[1]=e.clientY,Jb(A.ownerDocument.documentElement,A,t),t),a=e=>{const s=R.vec3(),i=R.vec3();return R.canvasPosToWorldRay(A,n.camera.viewMatrix,n.camera.projMatrix,n.camera.projection,e,s,i),t(s,i)};let l=!1;const c=function(){l=!1},h=function(){c(),A.removeEventListener("mousedown",d),A.removeEventListener("mousemove",p),e.cameraControl.off(f),A.removeEventListener("mouseup",g)},u=R.vec2(),d=function(e){1===e.which&&(o(e,u),l=!0)};A.addEventListener("mousedown",d);const p=function(e){const t=o(e,R.vec2());l&&R.distVec2(u,t)>20&&(c(),s())};A.addEventListener("mousemove",p);const f=e.cameraControl.on("rayMove",(e=>{const t=e.canvasPos;i(t,a(t))})),g=function(e){if(1===e.which&&l){h();const t=o(e,R.vec2());r(t,a(t))}};return A.addEventListener("mouseup",g),h}},pv=function(e,t,s,i){const r=-(R.dotVec3(s,t)-e)/R.dotVec3(i,t);{const e=R.vec3();return R.mulVec3Scalar(i,r,e),R.addVec3(s,e,e),e}};class fv extends ie{constructor(e,t={}){if(super(e.viewer.scene,t),this.plugin=e,this._container=t.container,!this._container)throw"config missing: container";this._eventSubs={},this.plugin.viewer.scene,this._geometry=t.geometry,t.onMouseOver,t.onMouseLeave,t.onContextMenu,this._alpha="alpha"in t&&void 0!==t.alpha?t.alpha:.5,this.color=t.color,this._visible=!0,this._rebuildMesh()}_rebuildMesh(){const e=this.plugin.viewer.scene,t=this._geometry.planeCoordinates.slice(),s=this._geometry.height<0,i=this._geometry.altitude+(s?this._geometry.height:0),r=this._geometry.height*(s?-1:1),[n,A,o]=aB(t),a=[],l=[],c=e=>{const t=a.length;for(let t of n)a.push([t[0],i+(e?r:0),t[1]]);for(let s of A)l.push(...(e?s:s.slice(0).reverse()).map((e=>e+t)))};c(!1),c(!0);for(let e=0;e<n.length;++e){const t=n[e],s=n[(n.length+e+(o?1:-1))%n.length],A=i,c=i+r,h=a.length;a.push([t[0],A,t[1]],[s[0],A,s[1]],[s[0],c,s[1]],[t[0],c,t[1]]),l.push(...[0,1,2,0,2,3].map((e=>e+h)))}this._zoneMesh&&this._zoneMesh.destroy();const h=e=>Math.min(...a.map((t=>t[e]))),u=e=>Math.max(...a.map((t=>t[e]))),d=h(0),p=h(1),f=h(2),g=u(0),m=u(1),_=u(2);this._center=R.vec3([(d+g)/2,(p+m)/2,(f+_)/2]);const b=[].concat(...a.map((e=>R.subVec3(e,this._center,e))));this._zoneMesh=new Ot(e,{origin:this._center,edges:this._edges,geometry:new Le(e,{positions:b,indices:l,normals:R.buildNormals(b,l)}),material:new jt(e,{alpha:this._alpha,backfaces:!0,diffuse:hv(this._color)}),visible:this._visible}),this._zoneMesh.highlighted=this._highlighted,this._zoneMesh.zone=this;{const e=R.vec2(),t=R.vec2();let s=0;for(let i of A){const r=n[i[0]],A=n[i[1]],o=n[i[2]];R.subVec2(A,r,e),R.subVec2(o,r,t),s+=Math.abs(e[0]*t[1]-e[1]*t[0])}this._baseArea=s/2}this._metrics=null}get baseArea(){return this._baseArea}get area(){return this._getMetrics().area}get volume(){return this._getMetrics().volume}_getMetrics(){if(null===this._metrics){let e=0,t=0;const s=this._zoneMesh.geometry,i=[R.vec3(),R.vec3(),R.vec3()],r=R.vec3();for(let n=0;n<s.indices.length;n+=3){for(let e=0;e<3;++e){const t=i[e],r=3*s.indices[n+e];for(let e=0;e<3;++e)t[e]=s.positions[r+e]}e+=R.dotVec3(i[0],R.cross3Vec3(i[1],i[2],r)),R.subVec3(i[1],i[0],i[1]),R.subVec3(i[2],i[0],i[2]),t+=R.lenVec3(R.cross3Vec3(i[1],i[2],r))}this._metrics={area:t/2,volume:e/6}}return this._metrics}sectionedAverage(e){const t=this._geometry.planeCoordinates.slice();let s=[];{const e=this._geometry.height,i=this._geometry.altitude,r=i+Math.max(0,e),n=i+Math.min(0,e),A=e=>{const i=t.map((t=>[t[0],e?r:n,t[1]]));s.push(e?i:i.slice(0).reverse())};A(!0),A(!1);const o=(e,s)=>[t[e][0],s,t[e][1]];for(let e=0;e<t.length;++e){const i=(e+1)%t.length;s.push([o(e,n),o(i,n),o(i,r),o(e,r)])}}for(const t of e){const e=t.dir,r=t.dist,n=[];for(const t of s){const s=1e-5,A=0,o=1,a=2,l=3;let c=0;const h=[];for(let i=0;i<t.length;i++){const n=R.dotVec3(e,t[i])+r,l=n<-s?a:n>s?o:A;c|=l,h.push(l)}switch(c){case A:case o:n.push(t);break;case a:break;case l:const s=[];for(let n=0;n<t.length;n++){var i=(n+1)%t.length;const A=h[n],o=h[i],c=t[n],u=t[i];if(A!==a&&s.push(c),(A|o)===l){const t=R.vec3();R.subVec3(u,c,t);const i=-(r+R.dotVec3(e,c))/R.dotVec3(e,t),n=[0,0,0];R.lerpVec3(i,0,1,c,u,n),s.push(n)}}s.length>=3&&n.push(s)}}s=n}if(0===s.length)return null;{const e=R.vec3([0,0,0]),t=new Set;for(const i of s)for(const s of i){const i=s.map((e=>e.toFixed(3))).join(":");t.has(i)||(t.add(i),R.addVec3(e,s,e))}return R.mulVec3Scalar(e,1/t.size,e),e}}get center(){return this._center}get altitude(){return this._geometry.altitude}set altitude(e){this._geometry.altitude=e,this._rebuildMesh()}get height(){return this._geometry.height}set height(e){this._geometry.height=e,this._rebuildMesh()}get highlighted(){return this._highlighted}set highlighted(e){this._highlighted=e,this._zoneMesh&&(this._zoneMesh.highlighted=e)}set color(e){this._color=e,this._zoneMesh&&(this._zoneMesh.material.diffuse=hv(this._color))}get color(){return this._color}set alpha(e){this._alpha=e,this._zoneMesh&&(this._zoneMesh.material.alpha=this._alpha)}get alpha(){return this._alpha}get edges(){return this._edges}set edges(e){this._edges=e,this._zoneMesh&&(this._zoneMesh.edges=this._edges)}set visible(e){this._visible=!!e,this._zoneMesh.visible=this._visible,this._needUpdate()}get visible(){return this._visible}getJSON(){return{id:this.id,geometry:this._geometry,alpha:this._alpha,color:this._color}}duplicate(){return this.plugin.createZone({id:R.createUUID(),geometry:{planeCoordinates:this._geometry.planeCoordinates.map((e=>e.slice())),altitude:this._geometry.altitude,height:this._geometry.height},alpha:this._alpha,color:this._color})}destroy(){this._zoneMesh.destroy(),super.destroy()}}class gv extends ie{constructor(e,t,s){super(e.viewer.scene),this.zonesPlugin=e,this.pointerLens=t.pointerLens,this.createSelect3dPoint=s,this._deactivate=null}get active(){return!!this._deactivate}activate(e,t,s,i){if(this._deactivate)return;if("object"==typeof e&&null!==e){const r=e,n=(e,t)=>{if(e in r)return r[e];if(void 0!==t)return t;throw"config missing: "+e};e=n("altitude"),t=n("height"),s=n("color","#008000"),i=n("alpha",.5)}const r=this.zonesPlugin,n=r.viewer,A=n.scene,o=this,a=this.createSelect3dPoint(n,((t,s)=>pv(e,R.vec3([0,1,0]),t,s)));!function n(){const l=uv(A,s,i),c=function(e,t,s,i,r,n){const A=iB(e,t),o=iB(e,t),a=s?function(e){s.visible=!!e,e&&(s.canvasPos=e)}:()=>{};let l=i((()=>{a(null),A.update(null)}),((e,t)=>{a(e),A.update(t)}),(function(e,t){A.update(t),l=i((function(){a(null),o.update(null),r(null)}),(function(e,s){a(e),o.update(s),r(R.distVec3(t,s)>.01&&[t,s])}),(function(e,s){o.update(s),A.destroy(),o.destroy(),a(null),n([t,s])}))}));return{deactivate:function(){l(),A.destroy(),o.destroy(),a(null)}}}(A,s,o.pointerLens,a,(e=>{if(e){const t=e[0],s=e[1],i=e=>Math.min(t[e],s[e]),r=e=>Math.max(t[e],s[e]),n=i(0),A=i(1),o=i(2),a=r(0);r(1);const c=r(2);l.updateBase([[n,A,c],[a,A,c],[a,A,o],[n,A,o]])}else l.updateBase(null)}),(A=>{l.destroy();const a=function(e,t,s,i,r,n,A){const o=s=>Math.min(e[s],t[s]),a=s=>Math.max(e[s],t[s]),l=o(0),c=o(2),h=a(0),u=a(2);return A.createZone({id:R.createUUID(),geometry:{planeCoordinates:[[l,u],[h,u],[h,c],[l,c]],altitude:s,height:i},alpha:n,color:r})}(A[0],A[1],e,t,s,i,r);let c=!0;o._deactivate=()=>{c=!1},o.fire("zoneEnd",a),c&&n()})).deactivate;o._deactivate=()=>{c(),l.destroy()}}()}deactivate(){this._deactivate&&(this._deactivate(),this._deactivate=null)}destroy(){this.deactivate(),super.destroy()}}const mv=function(e,t,s,i,r,n,A,o,a){const l=n?function(e){n.visible=!!e,e&&(n.canvasPos=e)}:()=>{};let c;const h=[()=>l(null)],u=uv(e,i,r);return h.push((()=>u.destroy())),function n(d){const p=iB(e,i),f=d.length>0&&rB(e,i),g=f&&d[d.length-1].getWorldPos();h.push((()=>{p.destroy(),f&&f.destroy()}));const m=d.length>0&&d[0],_=function(e){const t=m&&m.getCanvasPos();return t&&R.distVec2(t,e)<10&&{canvasPos:t,worldPos:m.getWorldPos()}},b=function(){const e=(e,t,s)=>t[0]<=Math.max(e[0],s[0])&&t[0]>=Math.min(e[0],s[0])&&t[1]<=Math.max(e[1],s[1])&&t[1]>=Math.min(e[1],s[1]),t=(e,t,s)=>{const i=(t[1]-e[1])*(s[0]-t[0])-(t[0]-e[0])*(s[1]-t[1]);return 0===i?0:i>0?1:2};return function(s,i){const r=s[s.length-2],n=s[s.length-1];for(let A=i?1:0;A<s.length-2-1;++A){const i=s[A],o=s[A+1],a=t(r,n,i),l=t(r,n,o),c=t(i,o,r),h=t(i,o,n);if(a!==l&&c!==h||0===a&&e(r,i,n)||0===l&&e(r,o,n)||0===c&&e(i,r,o)||0===h&&e(i,n,o))return!0}return!1}}();c=o((()=>{l(null),p.update(null),f&&f.update(g,null),u.updateBase(d.length>2?d.map((e=>e.getWorldPos())):null)}),((e,t)=>{const s=d.length>2&&_(e);if(m&&m.setHighlighted(!!s),l(s?s.canvasPos:e),p.update(!s&&t),f&&f.update(g,s?s.worldPos:t),d.length>=2){const e=d.map((e=>e.getWorldPos())).concat(s?[]:[t]),i=b(e.map((e=>[e[0],e[2]])),s);u.updateBase(i?null:e)}else u.updateBase(null)}),(function(e,o){const l=d.length>2&&_(e),c=d.map((e=>e.getWorldPos())).concat(l?[]:[o]);u.updateBase(c);const m=c.map((e=>[e[0],e[2]]));d.length>2&&b(m,l)?(h.pop()(),n(d)):l?(p.update(o),h.forEach((e=>e())),a(A.createZone({id:R.createUUID(),geometry:{planeCoordinates:m,altitude:t,height:s},alpha:r,color:i}))):(p.update(o),f&&f.update(g,o),n(d.concat(p)))}))}([]),{closeSurface:function(){throw"TODO"},deactivate:function(){c(),h.forEach((e=>e()))}}};class _v extends ie{constructor(e,t,s,i){const r=e.plugin.viewer,n=r.scene;super(n);const A=e._geometry.altitude,o=e._geometry.planeCoordinates.map((t=>{const s=n.canvas.canvas.ownerDocument.body,i=new eB(n,{},s,{fillColor:e._color});return i.worldPos=R.vec3([t[0],A,t[1]]),i.on("worldPos",(function(){t[0]=i.worldPos[0],t[1]=i.worldPos[2];try{e._rebuildMesh()}catch(t){e._zoneMesh&&(e._zoneMesh.destroy(),e._zoneMesh=null)}})),i})),a=AB({viewer:r,handleMouseEvents:s,handleTouchEvents:i,pointerLens:t&&t.pointerLens,dots:o,ray2WorldPos:(e,t)=>pv(A,R.vec3([0,1,0]),e,t),onEnd:(t,s)=>(e._zoneMesh&&this.fire("edited"),!!e._zoneMesh)}),l=function(){a(),o.forEach((e=>e.destroy()))},c=e.on("destroyed",l);this._deactivate=function(){e.off("destroyed",c),l()}}deactivate(){this._deactivate(),super.destroy()}}class bv extends ie{constructor(e,t,s,i){const r=e.plugin.viewer,n=r.scene,A=n.canvas.canvas;super(n);const o=this,a=e._geometry.altitude,l=t&&t.pointerLens,c=l?function(e){l.visible=!!e,e&&(l.canvasPos=e)}:()=>{},h=e=>{const t=R.vec3(),s=R.vec3();return R.canvasPosToWorldRay(A,n.camera.viewMatrix,n.camera.projMatrix,n.camera.projection,e,t,s),i=t,r=s,pv(a,R.vec3([0,1,0]),i,r);var i,r},u=(e,t)=>(t[0]=e.clientX,t[1]=e.clientY,Jb(A.ownerDocument.documentElement,A,t),t),d=function(e,t){const s=e=>{e.preventDefault(),t(e)};return A.addEventListener(e,s),()=>A.removeEventListener(e,s)};let p=()=>{};const f=function(t,s,i,n){const a=n(t),l=u(a,R.vec2()),f=r.scene.pick({canvasPos:l,includeEntities:[e._zoneMesh.id]});if((f&&f.entity&&f.entity.zone)===e){p(),A.style.cursor="move",r.cameraControl.active=!1;const t=function(){const t=e._geometry.planeCoordinates.map((e=>e.slice())),s=h(l),i=R.vec2([s[0],s[2]]),r=R.vec2();return function(s){const n=h(s);r[0]=n[0],r[1]=n[2],R.subVec2(i,r,r),e._geometry.planeCoordinates.forEach(((e,s)=>{R.subVec2(t[s],r,e)}));try{e._rebuildMesh()}catch(t){e._zoneMesh&&(e._zoneMesh.destroy(),e._zoneMesh=null)}}}(),a=d(s,(function(e){const s=n(e);if(s){const e=u(s,R.vec2());t(e),c(e)}})),f=d(i,(function(e){const s=n(e);if(s){const e=u(s,R.vec2());t(e),c(null),p(),o.fire("translated")}}));p=function(){p=()=>{},A.style.cursor="default",r.cameraControl.active=!0,a(),f()}}},g=[];s&&g.push(d("mousedown",(e=>{1===e.which&&f(e,"mousemove","mouseup",(e=>1===e.which&&e))}))),i&&g.push(d("touchstart",(e=>{if(1===e.touches.length){const t=e.touches[0].identifier;f(e,"touchmove","touchend",(e=>[...e.changedTouches].find((e=>e.identifier===t))))}})));const m=function(){p(),g.forEach((e=>e())),c(null)},_=e.on("destroyed",m);this._deactivate=function(){e.off("destroyed",_),m()}}deactivate(){this._deactivate(),super.destroy()}}exports.AlphaFormat=1021,exports.AmbientLight=Xr,exports.AngleMeasurementEditMouseControl=class extends fB{constructor(e,t){super(e,t,!0,!1)}},exports.AngleMeasurementEditTouchControl=class extends fB{constructor(e,t){super(e,t,!1,!0)}},exports.AngleMeasurementsControl=uB,exports.AngleMeasurementsMouseControl=dB,exports.AngleMeasurementsPlugin=class extends mn{constructor(e,t={}){super("AngleMeasurements",e),this._container=t.container||document.body,this._defaultControl=null,this._measurements={},this.defaultColor=void 0!==t.defaultColor?t.defaultColor:"#00BBFF",this.defaultLabelsVisible=!1!==t.defaultLabelsVisible,this.zIndex=t.zIndex||1e4,this._onMouseOver=(e,t)=>{this.fire("mouseOver",{plugin:this,angleMeasurement:t,measurement:t,event:e})},this._onMouseLeave=(e,t)=>{this.fire("mouseLeave",{plugin:this,angleMeasurement:t,measurement:t,event:e})},this._onContextMenu=(e,t)=>{this.fire("contextMenu",{plugin:this,angleMeasurement:t,measurement:t,event:e})}}getContainerElement(){return this._container}send(e,t){}get control(){return this._defaultControl||(this._defaultControl=new dB(this,{})),this._defaultControl}get measurements(){return this._measurements}createMeasurement(e={}){this.viewer.scene.components[e.id]&&(this.error("Viewer scene component with this ID already exists: "+e.id),delete e.id);const t=e.origin,s=e.corner,i=e.target,r=new hB(this,{id:e.id,plugin:this,container:this._container,origin:{entity:t.entity,worldPos:t.worldPos},corner:{entity:s.entity,worldPos:s.worldPos},target:{entity:i.entity,worldPos:i.worldPos},visible:e.visible,originVisible:!0,originWireVisible:!0,cornerVisible:!0,targetWireVisible:!0,targetVisible:!0,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onContextMenu:this._onContextMenu});return this._measurements[r.id]=r,r.on("destroyed",(()=>{delete this._measurements[r.id]})),r.clickable=!0,this.fire("measurementCreated",r),r}destroyMeasurement(e){const t=this._measurements[e];t?(t.destroy(),this.fire("measurementDestroyed",t)):this.log("AngleMeasurement not found: "+e)}setLabelsShown(e){for(const[t,s]of Object.entries(this.measurements))s.labelShown=e}clear(){const e=Object.keys(this._measurements);for(var t=0,s=e.length;t<s;t++)this.destroyMeasurement(e[t])}destroy(){this.clear(),super.destroy()}},exports.AngleMeasurementsTouchControl=class extends uB{constructor(e,t={}){super(e.viewer.scene),this.pointerLens=t.pointerLens,this.pointerCircle=new ue(e.viewer),this._active=!1;const s=document.createElement("div"),i=this.scene.canvas.canvas;i.parentNode.insertBefore(s,i),s.style.background="black",s.style.border="2px solid blue",s.style.borderRadius="10px",s.style.width="5px",s.style.height="5px",s.style.margin="-200px -200px",s.style.zIndex="100",s.style.position="absolute",s.style.pointerEvents="none",this.markerDiv=s,this._currentAngleMeasurement=null,this._longTouchTimeoutMs=300,this._snapping=!1!==t.snapping,this._touchState=0,this._attachPlugin(e,t)}_attachPlugin(e){this.angleMeasurementsPlugin=e,this.plugin=e}get active(){return this._active}set snapping(e){this._snapping=e}get snapping(){return this._snapping}activate(){if(this._active)return;const e=this.plugin,t=this.scene,s=t.canvas.canvas;e.pointerLens;const i=R.vec3(),r=20;let n=null;this._touchState=0;const A=R.vec2(),o=R.vec2(),a=R.vec2();let l=null;const c=()=>{this.plugin.viewer.cameraControl.active=!1},h=()=>{this.plugin.viewer.cameraControl.active=!0},u=()=>{n&&(clearTimeout(n),n=null),this._currentAngleMeasurement&&(this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null),h(),this._touchState=0},d=(e,t)=>(t[0]=e.clientX,t[1]=e.clientY,Jb(s.ownerDocument.documentElement,s,t),t),p=(e,t)=>(t.set(e),Jb(s,s.ownerDocument.documentElement,t),t);s.addEventListener("touchstart",this._onCanvasTouchStart=s=>{const a=s.touches.length;if(1!==a)return void(n&&(clearTimeout(n),n=null));const h=s.touches[0];switch(d(h,A),o.set(A),this._touchState){case 0:if(1!==a&&null!==n)return void u();const s=t.pick({canvasPos:o,snapToVertex:this._snapping,snapToEdge:this._snapping});if(s&&s.snapped)i.set(s.worldPos),this.pointerCircle.start(p(s.snappedCanvasPos,pB));else{const e=t.pick({canvasPos:o,pickSurface:!0});if(!e||!e.worldPos)return;i.set(e.worldPos),this.pointerCircle.start(p(e.canvasPos,pB))}n=setTimeout((()=>{1!==a||o[0]>A[0]+r||o[0]<A[0]-r||o[1]>A[1]+r||o[1]<A[1]-r||(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=A,this.pointerLens.cursorPos=A),this.pointerLens&&(this.pointerLens.canvasPos=o,this.pointerLens.snapped=!1),this.pointerLens&&(this.pointerLens.cursorPos=s.canvasPos,this.pointerLens.snapped=!0),this._currentAngleMeasurement?this._currentAngleMeasurement.origin.worldPos=i:(this._currentAngleMeasurement=e.createMeasurement({id:R.createUUID(),origin:{worldPos:s.worldPos,entity:s.entity},corner:{worldPos:s.worldPos,entity:s.entity},target:{worldPos:s.worldPos,entity:s.entity}}),this._currentAngleMeasurement.clickable=!1,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!1,this._currentAngleMeasurement.cornerVisible=!1,this._currentAngleMeasurement.cornerWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1),this.angleMeasurementsPlugin.fire("measurementStart",this._currentAngleMeasurement),this._touchState=2,c())}),this._longTouchTimeoutMs),this._touchState=1,l=h.identifier;break;case 3:if(1!==a&&null!==n)return clearTimeout(n),void(n=null);1===a&&(n=setTimeout((()=>{if(n=null,1!==a||o[0]>A[0]+r||o[0]<A[0]-r||o[1]>A[1]+r||o[1]<A[1]-r)return;this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=A,this.pointerLens.snapped=!1);const e=t.pick({canvasPos:o,snapToVertex:this._snapping,snapToEdge:this._snapping});if(e&&e.snapped)this.pointerLens&&(this.pointerLens.cursorPos=e.snappedCanvasPos,this.pointerLens.snapped=!0),this.pointerCircle.start(p(e.snappedCanvasPos,pB)),i.set(e.worldPos),this._currentAngleMeasurement.corner.worldPos=e.worldPos,this._currentAngleMeasurement.corner.entity=e.entity,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1,this.angleMeasurementsPlugin.fire("measurementStart",this._currentAngleMeasurement);else{const e=t.pick({canvasPos:o,pickSurface:!0});e&&e.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=e.canvasPos,this.pointerLens.snapped=!1),this.pointerCircle.start(p(e.canvasPos,pB)),i.set(e.worldPos),this._currentAngleMeasurement.corner.worldPos=e.worldPos,this._currentAngleMeasurement.corner.entity=e.entity,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1,this.angleMeasurementsPlugin.fire("measurementStart",this._currentAngleMeasurement)):this.pointerLens&&(this.pointerLens.cursorPos=null,this.pointerLens.snapped=!1)}this._touchState=5,c()}),this._longTouchTimeoutMs),this._touchState=4),l=h.identifier;break;case 6:if(1!==a&&null!==n)return clearTimeout(n),void(n=null);1===a&&(n=setTimeout((()=>{if(n=null,1!==a||o[0]>A[0]+r||o[0]<A[0]-r||o[1]>A[1]+r||o[1]<A[1]-r)return;this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=A,this.pointerLens.snapped=!1);const e=t.pick({canvasPos:o,snapToVertex:this._snapping,snapToEdge:this._snapping});if(e&&e.snapped)this.pointerLens&&(this.pointerLens.cursorPos=e.snappedCanvasPos,this.pointerLens.snapped=!0),this.pointerCircle.start(p(e.snappedCanvasPos,pB)),i.set(e.worldPos),this._currentAngleMeasurement.target.worldPos=e.worldPos,this._currentAngleMeasurement.target.entity=e.entity,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!0,this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.targetWireVisible=!0,this._currentAngleMeasurement.angleVisible=!0,this.angleMeasurementsPlugin.fire("measurementStart",this._currentAngleMeasurement);else{const e=t.pick({canvasPos:o,pickSurface:!0});e&&e.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=e.canvasPos,this.pointerLens.snapped=!1),this.pointerCircle.start(p(e.canvasPos,pB)),i.set(e.worldPos),this._currentAngleMeasurement.target.worldPos=e.worldPos,this._currentAngleMeasurement.target.entity=e.entity,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!0,this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.targetWireVisible=!0,this._currentAngleMeasurement.angleVisible=!0,this.angleMeasurementsPlugin.fire("measurementStart",this._currentAngleMeasurement)):this.pointerLens&&(this.pointerLens.cursorPos=null,this.pointerLens.snapped=!1)}this._touchState=8,c()}),this._longTouchTimeoutMs),this._touchState=7),l=h.identifier;break;default:return null!==n&&(clearTimeout(n),n=null),void(this._touchState=7)}},{passive:!0}),s.addEventListener("touchmove",(e=>{this.pointerCircle.stop();const s=e.touches.length;if(1!==s||1!==e.changedTouches.length)return void(n&&(clearTimeout(n),n=null));const r=e.touches[0];if(r.identifier!==l)return;let A,a;switch(d(r,o),this._touchState){case 2:this.pointerLens&&(this.pointerLens.canvasPos=o),A=t.pick({canvasPos:o,snapToVertex:this._snapping,snapToEdge:this._snapping}),A&&A.snapped?(this.pointerLens&&(this.pointerLens.snappedCanvasPos=A.snappedCanvasPos,this.pointerLens.snapped=!0),i.set(A.worldPos),this._currentAngleMeasurement.origin.worldPos=A.worldPos):(a=t.pick({canvasPos:o,pickSurface:!0}),a&&a.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=a.canvasPos,this.pointerLens.snapped=!1),i.set(a.worldPos),this._currentAngleMeasurement.origin.worldPos=a.worldPos):this.pointerLens&&(this.pointerLens.cursorPos=null,this.pointerLens.snapped=!1)),this._touchState=2;break;case 5:if(1!==s&&null!==n)return clearTimeout(n),n=null,this.pointerLens&&(this.pointerLens.visible=!1),void(this._touchState=7);this.pointerLens&&(this.pointerLens.canvasPos=o),A=t.pick({canvasPos:o,snapToVertex:this._snapping,snapToEdge:this._snapping}),A&&A.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=A.snappedCanvasPos,this.pointerLens.snapped=!0),this._currentAngleMeasurement.corner.worldPos=A.worldPos,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1):(a=t.pick({canvasPos:o,pickSurface:!0}),a&&a.worldPos&&(this.pointerLens&&(this.pointerLens.cursorPos=a.canvasPos,this.pointerLens.snapped=!1),this._currentAngleMeasurement.corner.worldPos=a.worldPos,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1)),this._touchState=5;break;case 8:if(1!==s&&null!==n)return clearTimeout(n),n=null,this.pointerLens&&(this.pointerLens.visible=!1),void(this._touchState=7);this.pointerLens&&(this.pointerLens.canvasPos=o),A=t.pick({canvasPos:o,snapToVertex:this._snapping,snapToEdge:this._snapping}),A&&A.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=A.snappedCanvasPos,this.pointerLens.snapped=!0),this._currentAngleMeasurement.target.worldPos=A.worldPos,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!0,this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.targetWireVisible=!0,this._currentAngleMeasurement.angleVisible=!0):(a=t.pick({canvasPos:o,pickSurface:!0}),a&&a.worldPos&&(this.pointerLens&&(this.pointerLens.cursorPos=a.canvasPos,this.pointerLens.snapped=!1),this._currentAngleMeasurement.target.worldPos=a.worldPos,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!0,this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.targetWireVisible=!0,this._currentAngleMeasurement.angleVisible=!0)),this._touchState=8}}),{passive:!0}),s.addEventListener("touchend",this._onCanvasTouchEnd=s=>{this.pointerCircle.stop();const i=s.changedTouches.length;if(1!==i)return;const c=s.changedTouches[0];if(c.identifier!==l)return;n&&(clearTimeout(n),n=null),d(c,a);const u=a[0],p=a[1];switch(this._touchState){case 1:{if(1!==i||u>A[0]+r||u<A[0]-r||p>A[1]+r||p<A[1]-r)return void(this._touchState=0);const s=t.pick({canvasPos:o,pickSurface:!0});s&&s.worldPos?(this._currentAngleMeasurement=e.createMeasurement({id:R.createUUID(),origin:{worldPos:s.worldPos},corner:{worldPos:s.worldPos},target:{worldPos:s.worldPos}}),this._currentAngleMeasurement.clickable=!1,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!1,this._currentAngleMeasurement.cornerVisible=!1,this._currentAngleMeasurement.cornerWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1,this._touchState=3):(this._currentAngleMeasurement&&(this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null),this._touchState=0)}h();break;case 2:this.pointerLens&&(this.pointerLens.visible=!1),this._currentAngleMeasurement?this._touchState=3:(this.pointerLens&&(this.pointerLens.snapped=!1,this.pointerLens.visible=!1),this._touchState=0),h();break;case 4:{if(1!==i||u>A[0]+r||u<A[0]-r||p>A[1]+r||p<A[1]-r)return void(this._touchState=3);const e=t.pick({canvasPos:o,pickSurface:!0});e&&e.worldPos?(this._currentAngleMeasurement.corner.worldPos=e.worldPos,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1,this._touchState=6):(this._currentAngleMeasurement&&(this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null),this._touchState=0)}h();break;case 5:this.pointerLens&&(this.pointerLens.visible=!1),this._touchState=6,h();break;case 7:{if(1!==i||u>A[0]+r||u<A[0]-r||p>A[1]+r||p<A[1]-r)return void(this._touchState=6);const e=t.pick({canvasPos:o,pickSurface:!0});e&&e.worldPos?(this._currentAngleMeasurement.target.worldPos=e.worldPos,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!0,this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.targetWireVisible=!0,this._currentAngleMeasurement.angleVisible=!0,this.angleMeasurementsPlugin.fire("measurementEnd",this._currentAngleMeasurement),this._currentAngleMeasurement=null):this._currentAngleMeasurement&&(this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null),this._touchState=0}h();break;case 8:this.pointerLens&&(this.pointerLens.visible=!1),this._currentAngleMeasurement&&this._currentAngleMeasurement.targetVisible?(this._currentAngleMeasurement.clickable=!0,this.angleMeasurementsPlugin.fire("measurementEnd",this._currentAngleMeasurement),this._currentAngleMeasurement=null,this._touchState=0):(this._currentAngleMeasurement&&(this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null),this._touchState=0),h()}},{passive:!0}),this._active=!0}deactivate(){if(!this._active)return;this.plugin.pointerLens&&(this.plugin.pointerLens.visible=!1),this.reset();const e=this.plugin.viewer.scene.canvas.canvas;e.removeEventListener("touchstart",this._onCanvasTouchStart),e.removeEventListener("touchend",this._onCanvasTouchEnd),this._active=!1,this.plugin.viewer.cameraControl.active=!0}reset(){this._active&&this._currentAngleMeasurement&&(this.angleMeasurementsPlugin.fire("measurementCancel",this._currentAngleMeasurement),this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null)}get currentMeasurement(){return this._currentAngleMeasurement}destroy(){this.deactivate(),super.destroy()}},exports.AnnotationsPlugin=class extends mn{constructor(e,t){super("Annotations",e),this._labelHTML=t.labelHTML||"<div></div>",this._markerHTML=t.markerHTML||"<div></div>",this._container=t.container||document.body,this._values=t.values||{},this.annotations={},this.surfaceOffset=t.surfaceOffset}getContainerElement(){return this._container}send(e,t){if("clearAnnotations"===e)this.clear()}set surfaceOffset(e){null==e&&(e=.3),this._surfaceOffset=e}get surfaceOffset(){return this._surfaceOffset}createAnnotation(e){this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);var t=null;e.markerElementId&&((t=document.getElementById(e.markerElementId))||this.error("Can't find DOM element for 'markerElementId' value '"+e.markerElementId+"' - defaulting to internally-generated empty DIV"));var s=null;e.labelElementId&&((s=document.getElementById(e.labelElementId))||this.error("Can't find DOM element for 'labelElementId' value '"+e.labelElementId+"' - defaulting to internally-generated empty DIV"));const i=new BB(this.viewer.scene,{id:e.id,plugin:this,container:this._container,markerElement:t,labelElement:s,markerHTML:e.markerHTML||this._markerHTML,labelHTML:e.labelHTML||this._labelHTML,occludable:e.occludable,values:j.apply(e.values,j.apply(this._values,{})),markerShown:e.markerShown,labelShown:e.labelShown,eye:e.eye,look:e.look,up:e.up,projection:e.projection,visible:!1!==e.visible});return e.pickResult=e.pickResult||e.pickRecord,e.pickResult?i.setFromPickResult(e.pickResult):(i.entity=e.entity,i.worldPos=e.worldPos),this.annotations[i.id]=i,i.on("destroyed",(()=>{delete this.annotations[i.id],this.fire("annotationDestroyed",i.id)})),this.fire("annotationCreated",i.id),i}destroyAnnotation(e){var t=this.annotations[e];t?t.destroy():this.log("Annotation not found: "+e)}clear(){const e=Object.keys(this.annotations);for(var t=0,s=e.length;t<s;t++)this.destroyAnnotation(e[t])}destroy(){this.clear(),super.destroy()}},exports.AxisGizmoPlugin=class extends mn{constructor(e,t){super("AxisGizmo",e,t=t||{});const s=e.scene.camera;t.canvasId||t.canvasElement||this.error("Config expected: either 'canvasId' or 'canvasElement'");try{this._axisGizmoScene=new gA(e,{canvasId:t.canvasId,canvasElement:t.canvasElement,transparent:!0})}catch(e){return void this.error(e)}const i=this._axisGizmoScene;i.clearLights(),new Xr(i,{color:[.45,.45,.5],intensity:.9}),new Zr(i,{dir:[-.5,.5,-.6],color:[.8,.8,.7],intensity:1,space:"view"}),new Zr(i,{dir:[.5,-.5,-.6],color:[.8,.8,.8],intensity:1,space:"view"});const r=i.camera;s.on("matrix",(function(){const e=s.eye,t=s.look,i=s.up,n=R.mulVec3Scalar(R.normalizeVec3(R.subVec3(e,t,[])),22);r.look=[0,0,0],r.eye=n,r.up=i}));const n=new Le(i,Xe({radiusTop:.01,radiusBottom:.6,height:1.7,radialSegments:20,heightSegments:1,openEnded:!1})),A=new Le(i,Xe({radiusTop:.2,radiusBottom:.2,height:4.5,radialSegments:20,heightSegments:1,openEnded:!1})),o=new jt(i,{diffuse:[1,.3,.3],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),a=new jt(i,{emissive:[1,.3,.3],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),l=new jt(i,{diffuse:[.3,1,.3],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),c=new jt(i,{emissive:[.3,1,.3],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),h=new jt(i,{diffuse:[.3,.3,1],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),u=new jt(i,{emissive:[.3,.3,1],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),d=new jt(i,{diffuse:[.5,.5,.5],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2});this._meshes=[new Ot(i,{geometry:new Le(i,Je({radius:9,heightSegments:60,widthSegments:60})),material:new jt(i,{diffuse:[0,0,0],emissive:[.1,.1,.1],ambient:[.1,.1,.2],specular:[0,0,0],alpha:.4,alphaMode:"blend",frontface:"cw"}),pickable:!1,collidable:!1,visible:!1!==t.visible}),new Ot(i,{geometry:new Le(i,Je({radius:1})),material:d,pickable:!1,collidable:!1,visible:!1!==t.visible}),new Ot(i,{geometry:n,material:o,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[5,0,0],rotation:[0,0,-90]}),new Ot(i,{geometry:A,material:o,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[2,0,0],rotation:[0,0,90]}),new Ot(i,{geometry:new Le(i,qe({text:"X",size:1.5})),material:a,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[7,0,0],billboard:"spherical"}),new Ot(i,{geometry:n,material:l,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,5,0]}),new Ot(i,{geometry:A,material:l,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,2,0]}),new Ot(i,{geometry:new Le(i,qe({text:"Y",size:1.5})),material:c,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,7,0],billboard:"spherical"}),new Ot(i,{geometry:n,material:h,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,0,5],rotation:[90,0,0]}),new Ot(i,{geometry:A,material:h,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,0,2],rotation:[90,0,0]}),new Ot(i,{geometry:new Le(i,qe({text:"Z",size:1.5})),material:u,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,0,7],billboard:"spherical"})]}setVisible(e){for(let t=0;t<this._meshes.length;t++)this._meshes[t].visible=e}destroy(){this._axisGizmoCanvas=null,this._axisGizmoScene.destroy(),this._axisGizmoScene=null,super.destroy()}},exports.BCFViewpointsPlugin=class extends mn{constructor(e,t={}){super("BCFViewpoints",e,t),this.originatingSystem=t.originatingSystem||"xeokit.io",this.authoringTool=t.authoringTool||"xeokit.io"}getViewpoint(e={}){const t=this.viewer.scene,s=t.camera,i=t.realWorldOffset,r=!0===e.reverseClippingPlanes;let n={},A=R.normalizeVec3(R.subVec3(s.look,s.eye,R.vec3())),o=s.eye,a=s.up;s.yUp&&(A=FB(A),o=FB(o),a=FB(a));const l=MB(R.addVec3(o,i));"ortho"===s.projection?n.orthogonal_camera={camera_view_point:l,camera_direction:MB(A),camera_up_vector:MB(a),view_to_world_scale:s.ortho.scale}:n.perspective_camera={camera_view_point:l,camera_direction:MB(A),camera_up_vector:MB(a),field_of_view:s.perspective.fov};const c=t.sectionPlanes;for(let e in c)if(c.hasOwnProperty(e)){let t=c[e];if(!t.active)continue;let A,o=t.pos;A=r?R.negateVec3(t.dir,R.vec3()):t.dir,s.yUp&&(o=FB(o),A=FB(A)),R.addVec3(o,i),o=MB(o),A=MB(A),n.clipping_planes||(n.clipping_planes=[]),n.clipping_planes.push({location:o,direction:A})}const h=t.lineSets;for(let e in h)if(h.hasOwnProperty(e)){const t=h[e];n.lines||(n.lines=[]);const s=t.positions,i=t.indices;for(let e=0,t=i.length/2;e<t;e++){const t=i[2*e],r=i[2*e+1];n.lines.push({start_point:{x:s[3*t+0],y:s[3*t+1],z:s[3*t+2]},end_point:{x:s[3*r+0],y:s[3*r+1],z:s[3*r+2]}})}}const u=t.bitmaps;for(let e in u)if(u.hasOwnProperty(e)){let t=u[e],r=t.pos,A=t.normal,o=t.up;s.yUp&&(r=FB(r),A=FB(A),o=FB(o)),R.addVec3(r,i),n.bitmaps||(n.bitmaps=[]),n.bitmaps.push({bitmap_type:t.type,bitmap_data:t.imageData,location:MB(r),normal:MB(A),up:MB(o),height:t.height})}n.components={visibility:{view_setup_hints:{spaces_visible:!!e.spacesVisible,space_boundaries_visible:!!e.spaceBoundariesVisible,openings_visible:!!e.openingsVisible,spaces_translucent:!!e.spaces_translucent,space_boundaries_translucent:!!e.space_boundaries_translucent,openings_translucent:!!e.openings_translucent}}};const d=new Set(t.opacityObjectIds),p=new Set(t.xrayedObjectIds),f=new Set(t.colorizedObjectIds),g=Object.values(t.objects).filter((e=>d.has(e.id)||f.has(e.id)||p.has(e.id))).reduce(((e,s)=>{let i,r=function(e){let t="";return t+=Math.round(255*e[0]).toString(16).padStart(2,"0"),t+=Math.round(255*e[1]).toString(16).padStart(2,"0"),t+=Math.round(255*e[2]).toString(16).padStart(2,"0"),t}(s.colorize);s.xrayed?(i=0===t.xrayMaterial.fillAlpha&&0!==t.xrayMaterial.edgeAlpha?.1:t.xrayMaterial.fillAlpha,i=Math.round(255*i).toString(16).padStart(2,"0"),r=i+r):d.has(s.id)&&(i=Math.round(255*s.opacity).toString(16).padStart(2,"0"),r=i+r),e[r]||(e[r]=[]);const n=s.id,A=s.originalSystemId,o={ifc_guid:A,originating_system:this.originatingSystem};return A!==n&&(o.authoring_tool_id=n),e[r].push(o),e}),{}),m=Object.entries(g).map((([e,t])=>({color:e,components:t})));n.components.coloring=m;const _=t.objectIds,b=t.visibleObjects,B=t.visibleObjectIds,y=_.filter((e=>!b[e])),w=t.selectedObjectIds;return e.defaultInvisible||B.length<y.length?(n.components.visibility.exceptions=this._createBCFComponents(B),n.components.visibility.default_visibility=!1):(n.components.visibility.exceptions=this._createBCFComponents(y),n.components.visibility.default_visibility=!0),n.components.selection=this._createBCFComponents(w),n.components.translucency=this._createBCFComponents(t.xrayedObjectIds),!1!==e.snapshot&&(n.snapshot={snapshot_type:"png",snapshot_data:this.viewer.getSnapshot({format:"png"})}),n}_createBCFComponents(e){const t=this.viewer.scene,s=[];for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.objects[r];if(n){const e={ifc_guid:n.originalSystemId,originating_system:this.originatingSystem};n.originalSystemId!==r&&(e.authoring_tool_id=r),s.push(e)}}return s}setViewpoint(e,t={}){if(!e)return;const s=this.viewer,i=s.scene,r=i.camera,n=!1!==t.rayCast,A=!1!==t.immediate,o=!1!==t.reset,a=i.realWorldOffset,l=!0===t.reverseClippingPlanes;if(i.clearSectionPlanes(),e.clipping_planes&&e.clipping_planes.length>0&&e.clipping_planes.forEach((function(e){let t=EB(e.location,yB),s=EB(e.direction,yB);l&&R.negateVec3(s),R.subVec3(t,a),r.yUp&&(t=xB(t),s=xB(s)),new pn(i,{pos:t,dir:s})})),i.clearLines(),e.lines&&e.lines.length>0){const t=[],s=[];let r=0;e.lines.forEach((e=>{e.start_point&&e.end_point&&(t.push(e.start_point.x),t.push(e.start_point.y),t.push(e.start_point.z),t.push(e.end_point.x),t.push(e.end_point.y),t.push(e.end_point.z),s.push(r++),s.push(r++))})),new Wr(i,{positions:t,indices:s,clippable:!1,collidable:!0})}if(i.clearBitmaps(),e.bitmaps&&e.bitmaps.length>0&&e.bitmaps.forEach((function(e){const t=e.bitmap_type||"jpg",s=e.bitmap_data;let n=EB(e.location,wB),A=EB(e.normal,vB),o=EB(e.up,CB),a=e.height||1;t&&s&&n&&A&&o&&(r.yUp&&(n=xB(n),A=xB(A),o=xB(o)),new gs(i,{src:s,type:t,pos:n,normal:A,up:o,clippable:!1,collidable:!0,height:a}))})),o&&(i.setObjectsXRayed(i.xrayedObjectIds,!1),i.setObjectsHighlighted(i.highlightedObjectIds,!1),i.setObjectsSelected(i.selectedObjectIds,!1)),e.components){if(e.components.visibility){e.components.visibility.default_visibility?(i.setObjectsVisible(i.objectIds,!0),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((e=>this._withBCFComponent(t,e,(e=>e.visible=!1))))):(i.setObjectsVisible(i.objectIds,!1),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((e=>this._withBCFComponent(t,e,(e=>e.visible=!0)))));const r=e.components.visibility.view_setup_hints;r&&(!1===r.spaces_visible&&i.setObjectsVisible(s.metaScene.getObjectIDsByType("IfcSpace"),!1),void 0!==r.spaces_translucent&&i.setObjectsXRayed(s.metaScene.getObjectIDsByType("IfcSpace"),!0),r.space_boundaries_visible,!1===r.openings_visible&&i.setObjectsVisible(s.metaScene.getObjectIDsByType("IfcOpening"),!0),r.space_boundaries_translucent,void 0!==r.openings_translucent&&i.setObjectsXRayed(s.metaScene.getObjectIDsByType("IfcOpening"),!0))}e.components.selection&&(i.setObjectsSelected(i.selectedObjectIds,!1),e.components.selection.forEach((e=>this._withBCFComponent(t,e,(e=>e.selected=!0))))),e.components.translucency&&(i.setObjectsXRayed(i.xrayedObjectIds,!1),e.components.translucency.forEach((e=>this._withBCFComponent(t,e,(e=>e.xrayed=!0))))),e.components.coloring&&(i.setObjectsColorized(i.colorizedObjectIds,null),e.components.coloring.forEach((e=>{let s=e.color,i=0,r=!1;8===s.length&&(i=parseInt(s.substring(0,2),16)/255,i<=1&&i>=.95&&(i=1),s=s.substring(2),r=!0);const n=[parseInt(s.substring(0,2),16)/255,parseInt(s.substring(2,4),16)/255,parseInt(s.substring(4,6),16)/255];e.components.map((e=>this._withBCFComponent(t,e,(e=>{e.colorize=n,r&&(e.opacity=i)}))))})))}if(e.perspective_camera||e.orthogonal_camera){let o,l,c,h;if(e.perspective_camera?(o=EB(e.perspective_camera.camera_view_point,yB),l=EB(e.perspective_camera.camera_direction,yB),c=EB(e.perspective_camera.camera_up_vector,yB),r.perspective.fov=e.perspective_camera.field_of_view,h="perspective"):(o=EB(e.orthogonal_camera.camera_view_point,yB),l=EB(e.orthogonal_camera.camera_direction,yB),c=EB(e.orthogonal_camera.camera_up_vector,yB),r.ortho.scale=e.orthogonal_camera.view_to_world_scale,h="ortho"),R.subVec3(o,a),r.yUp&&(o=xB(o),l=xB(l),c=xB(c)),n){const e=i.pick({pickSurface:!0,origin:o,direction:l});l=e?e.worldPos:R.addVec3(o,l,yB)}else l=R.addVec3(o,l,yB);A?(r.eye=o,r.look=l,r.up=c,r.projection=h):s.cameraFlight.flyTo({eye:o,look:l,up:c,duration:t.duration,projection:h})}}_withBCFComponent(e,t,s){const i=this.viewer,r=i.scene;if(t.authoring_tool_id&&t.originating_system===this.originatingSystem){const n=t.authoring_tool_id,A=r.objects[n];if(A)return void s(A);if(e.updateCompositeObjects){if(i.metaScene.metaObjects[n])return void r.withObjects(i.metaScene.getObjectIDsInSubtree(n),s)}}if(t.ifc_guid){const n=t.ifc_guid,A=r.objects[n];if(A)return void s(A);if(e.updateCompositeObjects){if(i.metaScene.metaObjects[n])return void r.withObjects(i.metaScene.getObjectIDsInSubtree(n),s)}Object.keys(r.models).forEach((t=>{const A=R.globalizeObjectId(t,n),o=r.objects[A];if(o)s(o);else if(e.updateCompositeObjects){i.metaScene.metaObjects[A]&&r.withObjects(i.metaScene.getObjectIDsInSubtree(A),s)}}))}}destroy(){super.destroy()}},exports.Bitmap=gs,exports.ByteType=1010,exports.CameraMemento=rn,exports.CameraPath=class extends ie{get type(){return"CameraPath"}constructor(e,t={}){super(e,t),this._frames=[],this._eyeCurve=new me(this),this._lookCurve=new me(this),this._upCurve=new me(this),t.frames&&(this.addFrames(t.frames),this.smoothFrameTimes(1))}get frames(){return this._frames}get eyeCurve(){return this._eyeCurve}get lookCurve(){return this._lookCurve}get upCurve(){return this._upCurve}saveFrame(e){const t=this.scene.camera;this.addFrame(e,t.eye,t.look,t.up)}addFrame(e,t,s,i){const r={t:e,eye:t.slice(0),look:s.slice(0),up:i.slice(0)};this._frames.push(r),this._eyeCurve.points.push(r.eye),this._lookCurve.points.push(r.look),this._upCurve.points.push(r.up)}addFrames(e){let t;for(let s=0,i=e.length;s<i;s++)t=e[s],this.addFrame(t.t||0,t.eye,t.look,t.up)}loadFrame(e){const t=this.scene.camera;e=(e/=this._frames[this._frames.length-1].t-this._frames[0].t)<0?0:e>1?1:e,t.eye=this._eyeCurve.getPoint(e,_e),t.look=this._lookCurve.getPoint(e,_e),t.up=this._upCurve.getPoint(e,_e)}sampleFrame(e,t,s,i){e=e<0?0:e>1?1:e,this._eyeCurve.getPoint(e,t),this._lookCurve.getPoint(e,s),this._upCurve.getPoint(e,i)}smoothFrameTimes(e){if(0===this._frames.length)return;const t=R.vec3();var s=0;this._frames[0].t=0;const i=[];for(let e=1,n=this._frames.length;e<n;e++){var r=R.lenVec3(R.subVec3(this._frames[e].eye,this._frames[e-1].eye,t));i[e]=r,s+=r}for(let t=1,r=this._frames.length;t<r;t++){const r=i[t]/s*e;this._frames[t].t=this._frames[t-1].t+r}}clearFrames(){this._frames=[],this._eyeCurve.points=[],this._lookCurve.points=[],this._upCurve.points=[]}},exports.CameraPathAnimation=Me,exports.CityJSONLoaderPlugin=class extends mn{constructor(e,t={}){super("cityJSONLoader",e,t),this.dataSource=t.dataSource}get dataSource(){return this._dataSource}set dataSource(e){this._dataSource=e||new nv}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new jr(this.viewer.scene,j.apply(e,{isModel:!0,edges:!0}));if(!e.src&&!e.cityJSON)return this.error("load() param expected: src or cityJSON"),t;const s={};if(e.src)this._loadModel(e.src,e,s,t);else{const i=this.viewer.scene.canvas.spinner;i.processes++,this._parseModel(e.cityJSON,e,s,t),i.processes--}return t}_loadModel(e,t,s,i){const r=this.viewer.scene.canvas.spinner;r.processes++,this._dataSource.getCityJSON(t.src,(e=>{this._parseModel(e,t,s,i),r.processes--}),(e=>{r.processes--,this.error(e),i.fire("error",e)}))}_parseModel(e,t,s,i){if(i.destroyed)return;const r=e.transform?this._transformVertices(e.vertices,e.transform,s.rotateX):e.vertices,n=t.stats||{};n.sourceFormat=e.type||"CityJSON",n.schemaVersion=e.version||"",n.title="",n.author="",n.created="",n.numMetaObjects=0,n.numPropertySets=0,n.numObjects=0,n.numGeometries=0,n.numTriangles=0,n.numVertices=0;const A=!1!==t.loadMetadata,o=A?{id:R.createUUID(),name:"Model",type:"Model"}:null,a=A?{id:"",projectId:"",author:"",createdAt:"",schema:e.version||"",creatingApplication:"",metaObjects:[o],propertySets:[]}:null,l={data:e,vertices:r,sceneModel:i,loadMetadata:A,metadata:a,rootMetaObject:o,nextId:0,stats:n};if(this._parseCityJSON(l),i.finalize(),A){const e=i.id;this.viewer.metaScene.createMetaModel(e,l.metadata,s)}i.scene.once("tick",(()=>{i.destroyed||(i.scene.fire("modelLoaded",i.id),i.fire("loaded",!0,!1))}))}_transformVertices(e,t,s){const i=[],r=t.scale||R.vec3([1,1,1]),n=t.translate||R.vec3([0,0,0]);for(let t=0,A=0;t<e.length;t++,A+=3){const A=e[t][0]*r[0]+n[0],o=e[t][1]*r[1]+n[1],a=e[t][2]*r[2]+n[2];s?i.push([A,a,o]):i.push([A,o,a])}return i}_parseCityJSON(e){const t=e.data.CityObjects;for(const s in t)if(t.hasOwnProperty(s)){const i=t[s];this._parseCityObject(e,i,s)}}_parseCityObject(e,t,s){const i=e.sceneModel,r=e.data;if(e.loadMetadata){const i=s,r=t.type,n=r+" : "+s,A=t.parents?t.parents[0]:e.rootMetaObject.id;e.metadata.metaObjects.push({id:i,name:n,type:r,parent:A})}if(e.stats.numMetaObjects++,!(t.geometry&&t.geometry.length>0))return;const n=[];for(let s=0,i=t.geometry.length;s<i;s++){const i=t.geometry[s];let A,o;const a=r.appearance;if(a){const e=a.materials;if(e){const t=i.material;if(t){const i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(void 0!==r.value)A=e[r.value];else{const t=r.values;if(t){o=[];for(let i=0,r=t.length;i<r;i++){const i=e[t[s]];o.push(i)}}}}}}}o?this._parseGeometrySurfacesWithOwnMaterials(e,i,o,n):this._parseGeometrySurfacesWithSharedMaterial(e,i,A,n)}n.length>0&&(i.createEntity({id:s,meshIds:n,isObject:!0}),e.stats.numObjects++)}_parseGeometrySurfacesWithOwnMaterials(e,t,s,i){switch(t.type){case"MultiPoint":case"MultiLineString":break;case"MultiSurface":case"CompositeSurface":const r=t.boundaries;this._parseSurfacesWithOwnMaterials(e,s,r,i);break;case"Solid":const n=t.boundaries;for(let t=0;t<n.length;t++){const r=n[t];this._parseSurfacesWithOwnMaterials(e,s,r,i)}break;case"MultiSolid":case"CompositeSolid":const A=t.boundaries;for(let t=0;t<A.length;t++)for(let r=0;r<A[t].length;r++){const n=A[t][r];this._parseSurfacesWithOwnMaterials(e,s,n,i)}}}_parseSurfacesWithOwnMaterials(e,t,s,i){const r=e.vertices,A=e.sceneModel;for(let o=0;o<s.length;o++){const a=s[o],l=t[o]||{diffuseColor:[.8,.8,.8],transparency:1},c=[],h=[],u=[],d={positions:[],indices:[]};for(let t=0;t<a.length;t++){c.length>0&&h.push(c.length);const s=this._extractLocalIndices(e,a[t],u,d);c.push(...s)}if(3===c.length)d.indices.push(c[0]),d.indices.push(c[1]),d.indices.push(c[2]);else if(c.length>3){const e=[];for(let t=0;t<c.length;t++)e.push({x:r[u[c[t]]][0],y:r[u[c[t]]][1],z:r[u[c[t]]][2]});const t=this._getNormalOfPositions(e,R.vec3());let s=[];for(let i=0;i<e.length;i++)this._to2D(e[i],t,Av),s.unshift(Av[0]),s.unshift(Av[1]);const i=n(s,h,2);for(let e=0;e<i.length;e+=3)d.indices.unshift(c[i[e]]),d.indices.unshift(c[i[e+1]]),d.indices.unshift(c[i[e+2]])}const p=""+e.nextId++;A.createMesh({id:p,primitive:"triangles",positions:d.positions,indices:d.indices,color:l&&l.diffuseColor?l.diffuseColor:[.8,.8,.8],opacity:l&&void 0!==l.transparency?1-l.transparency:1}),i.push(p),e.stats.numGeometries++,e.stats.numVertices+=d.positions.length/3,e.stats.numTriangles+=d.indices.length/3}}_parseGeometrySurfacesWithSharedMaterial(e,t,s,i){const r=e.sceneModel,n=[],A={positions:[],indices:[]};switch(t.type){case"MultiPoint":case"MultiLineString":break;case"MultiSurface":case"CompositeSurface":const s=t.boundaries;this._parseSurfacesWithSharedMaterial(e,s,n,A);break;case"Solid":const i=t.boundaries;for(let t=0;t<i.length;t++){const s=i[t];this._parseSurfacesWithSharedMaterial(e,s,n,A)}break;case"MultiSolid":case"CompositeSolid":const r=t.boundaries;for(let t=0;t<r.length;t++)for(let s=0;s<r[t].length;s++){const i=r[t][s];this._parseSurfacesWithSharedMaterial(e,i,n,A)}}if(A.positions.length>0&&A.indices.length>0){const t=""+e.nextId++;r.createMesh({id:t,primitive:"triangles",positions:A.positions,indices:A.indices,color:s&&s.diffuseColor?s.diffuseColor:[.8,.8,.8],opacity:1}),i.push(t),e.stats.numGeometries++,e.stats.numVertices+=A.positions.length/3,e.stats.numTriangles+=A.indices.length/3}}_parseSurfacesWithSharedMaterial(e,t,s,i){const r=e.vertices;for(let A=0;A<t.length;A++){let o=[],a=[];for(let r=0;r<t[A].length;r++){o.length>0&&a.push(o.length);const n=this._extractLocalIndices(e,t[A][r],s,i);o.push(...n)}if(3===o.length)i.indices.push(o[0]),i.indices.push(o[1]),i.indices.push(o[2]);else if(o.length>3){let e=[];for(let t=0;t<o.length;t++)e.push({x:r[s[o[t]]][0],y:r[s[o[t]]][1],z:r[s[o[t]]][2]});const t=this._getNormalOfPositions(e,R.vec3());let A=[];for(let s=0;s<e.length;s++)this._to2D(e[s],t,Av),A.unshift(Av[0]),A.unshift(Av[1]);const l=n(A,a,2);for(let e=0;e<l.length;e+=3)i.indices.unshift(o[l[e]]),i.indices.unshift(o[l[e+1]]),i.indices.unshift(o[l[e+2]])}}}_extractLocalIndices(e,t,s,i){const r=e.vertices,n=[];for(let e=0,A=t.length;e<A;e++){const A=t[e];if(s.includes(A)){const e=s.indexOf(A);n.push(e)}else i.positions.push(r[A][0]),i.positions.push(r[A][1]),i.positions.push(r[A][2]),n.push(s.length),s.push(A)}return n}_getNormalOfPositions(e,t){for(let s=0;s<e.length;s++){let i=s+1;i===e.length&&(i=0),t[0]+=(e[s].y-e[i].y)*(e[s].z+e[i].z),t[1]+=(e[s].z-e[i].z)*(e[s].x+e[i].x),t[2]+=(e[s].x-e[i].x)*(e[s].y+e[i].y)}return R.normalizeVec3(t)}_to2D(e,t,s){const i=ov,r=av,n=lv;i[0]=e.x,i[1]=e.y,i[2]=e.z,r[0]=t.x,r[1]=t.y,r[2]=t.z,n[0]=1.1,n[1]=1.1,n[2]=1.1;R.lenVec3(R.subVec3(n,r))<.01&&(n[0]+=1,n[1]+=2,n[2]+=3);const A=R.dotVec3(n,r),o=R.mulVec3Scalar(r,A,R.vec3());n[0]-=o[0],n[1]-=o[1],n[2]-=o[2],R.normalizeVec3(n);const a=R.cross3Vec3(r,n,R.vec3()),l=R.dotVec3(i,n),c=R.dotVec3(i,a);s[0]=l,s[1]=c}},exports.ClampToEdgeWrapping=1001,exports.Component=ie,exports.CompressedMediaType=10003,exports.Configs=gi,exports.ContextMenu=class{constructor(e={}){this._id=t.addItem(),this._context=null,this._enabled=!1,this._itemsCfg=[],this._rootMenu=null,this._menuList=[],this._menuMap={},this._itemList=[],this._itemMap={},this._shown=!1,this._nextId=0,this._parentNode=e.parentNode||document.body,this._offsetParent=this._parentNode instanceof ShadowRoot?this._parentNode.host:this._parentNode,this._eventSubs={},!1!==e.hideOnMouseDown&&(this._parentNode.addEventListener("mousedown",(e=>{e.target.classList.contains("xeokit-context-menu-item")||this.hide()})),this._parentNode.addEventListener("touchstart",this._canvasTouchStartHandler=e=>{e.target.classList.contains("xeokit-context-menu-item")||this.hide()})),e.items&&(this.items=e.items),this._hideOnAction=!1!==e.hideOnAction,this.context=e.context,this.enabled=!1!==e.enabled,this.hide()}on(e,t){let s=this._eventSubs[e];s||(s=[],this._eventSubs[e]=s),s.push(t)}fire(e,t){const s=this._eventSubs[e];if(s)for(let e=0,i=s.length;e<i;e++)s[e](t)}set items(e){this._clear(),this._itemsCfg=e||[],this._parseItems(e),this._createUI()}get items(){return this._itemsCfg}set enabled(e){(e=!!e)!==this._enabled&&(this._enabled=e,this._enabled||this.hide())}get enabled(){return this._enabled}set context(e){this._context=e}get context(){return this._context}show(e,t){this._context?this._enabled&&(this._shown||(this._hideAllMenus(),this._updateItemsTitles(),this._updateItemsEnabledStatus(),this._showMenu(this._rootMenu.id,e,t),this._updateSubMenuInfo(),this._shown=!0,this.fire("shown",{}))):console.error("ContextMenu cannot be shown without a context - set context first")}get shown(){return this._shown}hide(){this._enabled&&this._shown&&(this._hideAllMenus(),this._shown=!1,this.fire("hidden",{}))}destroy(){this._context=null,this._clear(),null!==this._id&&(t.removeItem(this._id),this._id=null)}_clear(){for(let e=0,t=this._menuList.length;e<t;e++){this._menuList[e].menuElement.remove()}this._itemsCfg=[],this._rootMenu=null,this._menuList=[],this._menuMap={},this._itemList=[],this._itemMap={}}_parseItems(e){const t=e=>{const n=this._getNextId(),A=new s(n);for(let s=0,n=e.length;s<n;s++){const n=e[s],o=new i;A.groups.push(o);for(let e=0,s=n.length;e<s;e++){const s=n[e],i=s.items,a=i&&i.length>0,l=this._getNextId(),c=s.getTitle||(()=>s.title||""),h=s.doAction||s.callback||(()=>{}),u=s.getEnabled||(()=>!0),d=s.getShown||(()=>!0),p=new r(l,c,h,u,d);if(p.parentMenu=A,o.items.push(p),a){const e=t(i);p.subMenu=e,e.parentItem=p}this._itemList.push(p),this._itemMap[p.id]=p}}return this._menuList.push(A),this._menuMap[A.id]=A,A};this._rootMenu=t(e)}_getNextId(){return"ContextMenu_"+this._id+"_"+this._nextId++}_createUI(){const e=t=>{this._createMenuUI(t);const s=t.groups;for(let t=0,i=s.length;t<i;t++){const i=s[t].items;for(let t=0,s=i.length;t<s;t++){const s=i[t].subMenu;s&&e(s)}}};e(this._rootMenu)}_createMenuUI(e){const t=e.groups,s=[],i=document.createElement("div");if(i.classList.add("xeokit-context-menu",e.id),i.style.zIndex=3e5,i.style.position="absolute",s.push("<ul>"),t)for(let e=0,i=t.length;e<i;e++){const r=e,n=i,A=t[e].items;if(A)for(let e=0,t=A.length;e<t;e++){const i=A[e],o=i.subMenu,a=i.title||"";o?(s.push('<li id="'+i.id+'" class="xeokit-context-menu-item xeokit-context-menu-submenu">'+a+"</li>"),r===n-1||e<t-1||s.push('<li id="'+i.id+'" class="xeokit-context-menu-item-separator"></li>')):(s.push('<li id="'+i.id+'" class="xeokit-context-menu-item">'+a+"</li>"),r===n-1||e<t-1||s.push('<li id="'+i.id+'" class="xeokit-context-menu-item-separator"></li>'))}}s.push("</ul>");const r=s.join("");i.innerHTML=r,this._parentNode.appendChild(i),e.menuElement=i,i.style["border-radius"]="4px",i.style.display="none",i.style["z-index"]=3e5,i.style.background="white",i.style.border="1px solid black",i.style["box-shadow"]="0 4px 5px 0 gray",i.oncontextmenu=e=>{e.preventDefault()};const n=this;let A=null;if(t)for(let e=0,s=t.length;e<s;e++){const s=t[e].items;if(s)for(let e=0,t=s.length;e<t;e++){const t=s[e],i=t.subMenu;t.itemElement=this._parentNode.querySelector(`#${t.id}`),t.itemElement?(t.itemElement.addEventListener("mouseenter",(e=>{e.preventDefault();const s=t.subMenu;if(!s)return void(A&&(n._hideMenu(A.id),A=null));if(A&&A.id!==s.id&&(n._hideMenu(A.id),A=null),!1===t.enabled)return;const i=t.itemElement,r=s.menuElement,o=i.getBoundingClientRect();r.getBoundingClientRect();const a=n._offsetParent.getBoundingClientRect(),l=200,c=o.right+l<a.right,h=o.left-l>a.left;if(c)n._showMenu(s.id,o.right+window.scrollX-5,o.top+window.scrollY-1);else if(h)n._showMenu(s.id,o.left-l+window.scrollX,o.top+window.scrollY-1);else{const e=o.left-a.left,t=a.right-o.right;t>e?n._showMenu(s.id,o.right-5-(l-t),o.top+window.scrollY-1):n._showMenu(s.id,o.left-e,o.top+window.scrollY-1)}A=s})),i||(t.itemElement.addEventListener("click",(e=>{e.preventDefault(),n._context&&!1!==t.enabled&&(t.doAction&&t.doAction(n._context),this._hideOnAction?n.hide():(n._updateItemsTitles(),n._updateItemsEnabledStatus()))})),t.itemElement.addEventListener("mouseup",(e=>{3===e.which&&(e.preventDefault(),n._context&&!1!==t.enabled&&(t.doAction&&t.doAction(n._context),this._hideOnAction?n.hide():(n._updateItemsTitles(),n._updateItemsEnabledStatus())))})),t.itemElement.addEventListener("mouseenter",(e=>{e.preventDefault(),!1!==t.enabled&&t.doHover&&t.doHover(n._context)})))):console.error("ContextMenu item element not found: "+t.id)}}}_updateItemsTitles(){if(this._context)for(let e=0,t=this._itemList.length;e<t;e++){const t=this._itemList[e],s=t.itemElement;if(!s)continue;const i=t.getShown;if(!i||!i(this._context))continue;const r=t.getTitle(this._context);t.subMenu,s.innerText=r}}_updateItemsEnabledStatus(){if(this._context)for(let e=0,t=this._itemList.length;e<t;e++){const t=this._itemList[e],s=t.itemElement;if(!s)continue;const i=t.getEnabled;if(!i)continue;const r=t.getShown;if(!r)continue;const n=r(this._context);if(t.shown=n,!n){s.style.display="none";continue}s.style.display="";const A=i(this._context);t.enabled=A,A?s.classList.remove("disabled"):s.classList.add("disabled")}}_updateSubMenuInfo(){if(!this._context)return;let e,t,s,i,r,n;this._itemList.forEach((A=>{A.subMenu&&(e=A.itemElement,t=e.getBoundingClientRect(),s=A.subMenu.menuElement,i={visibility:s.style.visibility,display:s.style.display},s.style.display="block",s.style.visibility="hidden",n=A.subMenu.menuElement.getBoundingClientRect().width,s.style.visibility=i.visibility,s.style.display=i.display,r=t.right+n>window.innerWidth,e.setAttribute("data-submenuposition",r?"left":"right"))}))}_showMenu(e,t,s){const i=this._menuMap[e];if(!i)return void console.error("Menu not found: "+e);if(i.shown)return;const r=i.menuElement;r&&(this._showMenuElement(r,t,s),i.shown=!0)}_hideMenu(e){const t=this._menuMap[e];if(!t)return void console.error("Menu not found: "+e);if(!t.shown)return;const s=t.menuElement;s&&(this._hideMenuElement(s),t.shown=!1)}_hideAllMenus(){for(let e=0,t=this._menuList.length;e<t;e++){const t=this._menuList[e];this._hideMenu(t.id)}}_showMenuElement(e,t,s){e.style.display="block";const i=e.offsetHeight,r=e.offsetWidth,n=this._offsetParent.getBoundingClientRect(),A=this._offsetParent===window.document.body&&0===n.bottom?window.innerHeight:n.bottom+window.scrollY,o=n.right+window.scrollX;s+i>A&&(s=A-i),t+r>o&&(t=o-r),e.style.left=t-n.left-window.scrollX+"px",e.style.top=s-n.top-window.scrollY+"px"}_hideMenuElement(e){e.style.display="none"}},exports.CubicBezierCurve=class extends ge{constructor(e,t={}){super(e,t),this.v0=t.v0,this.v1=t.v1,this.v2=t.v2,this.v3=t.v3,this.t=t.t}set v0(e){this._v0=e||R.vec3([0,0,0])}get v0(){return this._v0}set v1(e){this._v1=e||R.vec3([0,0,0])}get v1(){return this._v1}set v2(e){this._v2=e||R.vec3([0,0,0])}get v2(){return this._v2}set v3(e){this.fire("v3",this._v3=e||R.vec3([0,0,0]))}get v3(){return this._v3}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=R.vec3();return t[0]=R.b3(e,this._v0[0],this._v1[0],this._v2[0],this._v3[0]),t[1]=R.b3(e,this._v0[1],this._v1[1],this._v2[1],this._v3[1]),t[2]=R.b3(e,this._v0[2],this._v1[2],this._v2[2],this._v3[2]),t}getJSON(){return{v0:this._v0,v1:this._v1,v2:this._v2,v3:this._v3,t:this._t}}},exports.Curve=ge,exports.CxConverterIFCLoaderPlugin=class extends mn{constructor(e,t={}){super("ifcLoader",e,t),this.gltfLoader=new zB(this.viewer),this.cxConverterModule=null}setCxConverterModule(e){this.cxConverterModule=e}async load(e={}){if(!this.cxConverterModule)throw new Error("CxConverter module is not set. Use setCxConverterModule() to set it.");e.src||this.error("load() param expected: src");const t=await async function(e){try{const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return t.text()}catch(e){console.error("Error fetching file:",e)}}(e.src),{gltf:s,metaData:i}=await this.cxConverterModule.ifc2gltf(t,{remote:!0,progressCallback:e.progressCallback,progressTextCallback:e.progressTextCallback});return this.gltfLoader.load({id:"myModel",gltf:s,metaModelJSON:i})}},exports.DefaultLoadingManager=or,exports.DepthFormat=1026,exports.DepthStencilFormat=1027,exports.DirLight=Zr,exports.DistanceMeasurementEditControl=QB,exports.DistanceMeasurementEditMouseControl=class extends QB{constructor(e,t){super(e,t,!0,!1)}},exports.DistanceMeasurementEditTouchControl=class extends QB{constructor(e,t){super(e,t,!1,!0)}},exports.DistanceMeasurementsControl=SB,exports.DistanceMeasurementsMouseControl=DB,exports.DistanceMeasurementsPlugin=class extends mn{constructor(e,t={}){super("DistanceMeasurements",e),this._pointerLens=t.pointerLens,this._container=t.container||document.body,this._defaultControl=null,this._measurements={},this.labelMinAxisLength=t.labelMinAxisLength,this.defaultVisible=!1!==t.defaultVisible,this.defaultOriginVisible=!1!==t.defaultOriginVisible,this.defaultTargetVisible=!1!==t.defaultTargetVisible,this.defaultWireVisible=!1!==t.defaultWireVisible,this.defaultXLabelEnabled=!1!==t.defaultXLabelEnabled,this.defaultYLabelEnabled=!1!==t.defaultYLabelEnabled,this.defaultZLabelEnabled=!1!==t.defaultZLabelEnabled,this.defaultLengthLabelEnabled=!1!==t.defaultLengthLabelEnabled,this.defaultLabelsVisible=!1!==t.defaultLabelsVisible,this.defaultAxisVisible=!1!==t.defaultAxisVisible,this.defaultXAxisVisible=!1!==t.defaultXAxisVisible,this.defaultYAxisVisible=!1!==t.defaultYAxisVisible,this.defaultZAxisVisible=!1!==t.defaultZAxisVisible,this.defaultColor=void 0!==t.defaultColor?t.defaultColor:"#00BBFF",this.zIndex=t.zIndex||1e4,this.defaultLabelsOnWires=!1!==t.defaultLabelsOnWires,this.useRotationAdjustment=void 0!==t.useRotationAdjustment&&!1!==t.useRotationAdjustment,this._onMouseOver=(e,t)=>{this.fire("mouseOver",{plugin:this,distanceMeasurement:t,measurement:t,event:e})},this._onMouseLeave=(e,t)=>{this.fire("mouseLeave",{plugin:this,distanceMeasurement:t,measurement:t,event:e})},this._onContextMenu=(e,t)=>{this.fire("contextMenu",{plugin:this,distanceMeasurement:t,measurement:t,event:e})}}getContainerElement(){return this._container}send(e,t){}get pointerLens(){return this._pointerLens}get control(){return this._defaultControl||(this._defaultControl=new DB(this,{})),this._defaultControl}get measurements(){return this._measurements}set labelMinAxisLength(e){e<1&&(this.error("labelMinAxisLength must be >= 1; defaulting to 25"),e=25),this._labelMinAxisLength=e||25}get labelMinAxisLength(){return this._labelMinAxisLength}set useRotationAdjustment(e){e=void 0!==e&&Boolean(e),this._useRotationAdjustment=e}get useRotationAdjustment(){return this._useRotationAdjustment}createMeasurement(e={}){this.viewer.scene.components[e.id]&&(this.error("Viewer scene component with this ID already exists: "+e.id),delete e.id);const t=e.origin,s=e.target,i=new PB(this,{id:e.id,plugin:this,container:this._container,origin:{entity:t.entity,worldPos:t.worldPos},target:{entity:s.entity,worldPos:s.worldPos},visible:e.visible,wireVisible:e.wireVisible,axisVisible:!1!==e.axisVisible&&!1!==this.defaultAxisVisible,xAxisVisible:!1!==e.xAxisVisible&&!1!==this.defaultXAxisVisible,yAxisVisible:!1!==e.yAxisVisible&&!1!==this.defaultYAxisVisible,zAxisVisible:!1!==e.zAxisVisible&&!1!==this.defaultZAxisVisible,xLabelEnabled:!1!==e.xLabelEnabled&&!1!==this.defaultXLabelEnabled,yLabelEnabled:!1!==e.yLabelEnabled&&!1!==this.defaultYLabelEnabled,zLabelEnabled:!1!==e.zLabelEnabled&&!1!==this.defaultZLabelEnabled,lengthLabelEnabled:!1!==e.lengthLabelEnabled&&!1!==this.defaultLengthLabelEnabled,labelsVisible:!1!==e.labelsVisible&&!1!==this.defaultLabelsVisible,useRotationAdjustment:this.useRotationAdjustment,originVisible:e.originVisible,targetVisible:e.targetVisible,color:e.color,labelsOnWires:!1!==e.labelsOnWires&&!1!==this.defaultLabelsOnWires,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onContextMenu:this._onContextMenu});return this._measurements[i.id]=i,i.clickable=!0,i.on("destroyed",(()=>{delete this._measurements[i.id]})),this.fire("measurementCreated",i),i}destroyMeasurement(e){const t=this._measurements[e];t?(t.destroy(),this.fire("measurementDestroyed",t)):this.log("DistanceMeasurement not found: "+e)}setLabelsShown(e){for(const[t,s]of Object.entries(this.measurements))s.labelShown=e}setAxisVisible(e){for(const[t,s]of Object.entries(this.measurements))s.axisVisible=e;this.defaultAxisVisible=e}getAxisVisible(){return this.defaultAxisVisible}clear(){const e=Object.keys(this._measurements);for(var t=0,s=e.length;t<s;t++)this.destroyMeasurement(e[t])}destroy(){this.clear(),super.destroy()}},exports.DistanceMeasurementsTouchControl=class extends SB{constructor(e,t={}){super(e.viewer.scene),this.pointerLens=t.pointerLens,this.pointerCircle=new ue(e.viewer),this._active=!1;const s=document.createElement("div"),i=this.scene.canvas.canvas;i.parentNode.insertBefore(s,i),s.style.background="black",s.style.border="2px solid blue",s.style.borderRadius="10px",s.style.width="5px",s.style.height="5px",s.style.margin="-200px -200px",s.style.zIndex="100",s.style.position="absolute",s.style.pointerEvents="none",this.markerDiv=s,this._currentDistanceMeasurement=null,this._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},this._longTouchTimeoutMs=300,this._snapping=!1!==t.snapping,this._attachPlugin(e,t)}_attachPlugin(e){this.distanceMeasurementsPlugin=e,this.plugin=e}get active(){return this._active}set snapping(e){this._snapping=e}get snapping(){return this._snapping}activate(){if(this._active)return;const e=this.plugin,t=this.scene,s=t.canvas.canvas;e.pointerLens;const i=R.vec3(),r=20;let n=null;this._touchState=0;const A=R.vec2(),o=R.vec2(),a=R.vec2();let l=null;const c=()=>{this.plugin.viewer.cameraControl.active=!1},h=()=>{this.plugin.viewer.cameraControl.active=!0},u=()=>{n&&(clearTimeout(n),n=null),this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),h(),this._touchState=0},d=(e,t)=>(t[0]=e.clientX,t[1]=e.clientY,Jb(s.ownerDocument.documentElement,s,t),t),p=(e,t)=>(t.set(e),Jb(s,s.ownerDocument.documentElement,t),t);s.addEventListener("touchstart",this._onCanvasTouchStart=s=>{const a=s.touches.length;if(1!==a)return void(n&&(clearTimeout(n),n=null));const h=s.touches[0];switch(d(h,A),o.set(A),this._touchState){case 0:if(1!==a&&null!==n)return void u();const s=t.pick({canvasPos:o,snapping:this._snapping,snapToEdge:this._snapping});if(s&&s.snapped)i.set(s.worldPos),this.pointerCircle.start(p(s.snappedCanvasPos,kB));else{const e=t.pick({canvasPos:o,pickSurface:!0});if(!e||!e.worldPos)return;i.set(e.worldPos),this.pointerCircle.start(p(e.canvasPos,kB))}n=setTimeout((()=>{1!==a||o[0]>A[0]+r||o[0]<A[0]-r||o[1]>A[1]+r||o[1]<A[1]-r||(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=A,this.pointerLens.cursorPos=A),this.pointerLens&&(this.pointerLens.canvasPos=o,this.pointerLens.snapped=!1),this.pointerLens&&(this.pointerLens.cursorPos=s.canvasPos,this.pointerLens.snapped=!0),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=i:(this._currentDistanceMeasurement=e.createMeasurement({id:R.createUUID(),origin:{worldPos:i,entity:s.entity},target:{worldPos:i,entity:s.entity}}),this._currentDistanceMeasurement.labelsVisible=!1,this._currentDistanceMeasurement.xAxisVisible=!1,this._currentDistanceMeasurement.yAxisVisible=!1,this._currentDistanceMeasurement.zAxisVisible=!1,this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.originVisible=!0,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.clickable=!1),this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement),this._touchState=2,c())}),this._longTouchTimeoutMs),this._touchState=1,l=h.identifier;break;case 3:if(1!==a&&null!==n)return clearTimeout(n),void(n=null);1===a&&(n=setTimeout((()=>{if(n=null,1!==a||o[0]>A[0]+r||o[0]<A[0]-r||o[1]>A[1]+r||o[1]<A[1]-r)return;this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=A,this.pointerLens.snapped=!1);const e=t.pick({canvasPos:o,snapToVertex:this._snapping,snapToEdge:this._snapping});if(e&&e.snapped)this.pointerLens&&(this.pointerLens.cursorPos=e.snappedCanvasPos,this.pointerLens.snapped=!0),this.pointerCircle.start(p(e.snappedCanvasPos,kB)),i.set(e.worldPos),this._currentDistanceMeasurement.target.worldPos=e.worldPos,this._currentDistanceMeasurement.target.entity=e.entity,this._currentDistanceMeasurement.targetVisible=!0,this._currentDistanceMeasurement.wireVisible=!0,this._currentDistanceMeasurement.labelsVisible=!0,this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement);else{const e=t.pick({canvasPos:o,pickSurface:!0});e&&e.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=e.canvasPos,this.pointerLens.snapped=!1),this.pointerCircle.start(p(e.canvasPos,kB)),i.set(e.worldPos),this._currentDistanceMeasurement.target.worldPos=e.worldPos,this._currentDistanceMeasurement.target.entity=e.entity,this._currentDistanceMeasurement.targetVisible=!0,this._currentDistanceMeasurement.wireVisible=!0,this._currentDistanceMeasurement.labelsVisible=!0,this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement)):this.pointerLens&&(this.pointerLens.cursorPos=null,this.pointerLens.snapped=!1)}this._touchState=5,c()}),this._longTouchTimeoutMs),this._touchState=4),l=h.identifier;break;default:return null!==n&&(clearTimeout(n),n=null),void(this._touchState=7)}},{passive:!0}),s.addEventListener("touchmove",(s=>{this.pointerCircle.stop();const r=s.touches.length;if(1!==r||1!==s.changedTouches.length)return void(n&&(clearTimeout(n),n=null));const A=s.touches[0];if(A.identifier!==l)return;let a,c;switch(d(A,o),this._touchState){case 2:this.pointerLens&&(this.pointerLens.canvasPos=o),a=t.pick({canvasPos:o,snapToVertex:this._snapping,snapToEdge:this._snapping}),a&&a.snapped?(this.pointerLens&&(this.pointerLens.snappedCanvasPos=a.snappedCanvasPos,this.pointerLens.snapped=!0),i.set(a.worldPos),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=a.worldPos:(this._currentDistanceMeasurement=e.createMeasurement({id:R.createUUID(),origin:{worldPos:a.worldPos,entity:a.entity},target:{worldPos:a.worldPos,entity:a.entity}}),this._currentDistanceMeasurement.labelsVisible=!1,this._currentDistanceMeasurement.xAxisVisible=!1,this._currentDistanceMeasurement.yAxisVisible=!1,this._currentDistanceMeasurement.zAxisVisible=!1,this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.originVisible=!0,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.clickable=!1),this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement)):(c=t.pick({canvasPos:o,pickSurface:!0}),c&&c.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=c.canvasPos,this.pointerLens.snapped=!1),i.set(c.worldPos),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=c.worldPos:(this._currentDistanceMeasurement=e.createMeasurement({id:R.createUUID(),origin:{worldPos:c.worldPos,entity:c.entity},target:{worldPos:c.worldPos,entity:c.entity}}),this._currentDistanceMeasurement.labelsVisible=!1,this._currentDistanceMeasurement.xAxisVisible=!1,this._currentDistanceMeasurement.yAxisVisible=!1,this._currentDistanceMeasurement.zAxisVisible=!1,this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.originVisible=!0,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.clickable=!1),this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement)):this.pointerLens&&(this.pointerLens.cursorPos=null,this.pointerLens.snapped=!1)),this._touchState=2;break;case 5:if(1!==r&&null!==n)return clearTimeout(n),n=null,this.pointerLens&&(this.pointerLens.visible=!1),void(this._touchState=7);this.pointerLens&&(this.pointerLens.canvasPos=o),a=t.pick({canvasPos:o,snapToVertex:this._snapping,snapToEdge:this._snapping}),a&&a.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=a.snappedCanvasPos,this.pointerLens.snapped=!0),this._currentDistanceMeasurement.target.worldPos=a.worldPos,this._currentDistanceMeasurement.target.entity=a.entity,this._currentDistanceMeasurement.targetVisible=!0,this._currentDistanceMeasurement.wireVisible=!0,this._currentDistanceMeasurement.labelsVisible=!0):(c=t.pick({canvasPos:o,pickSurface:!0}),c&&c.worldPos&&(this.pointerLens&&(this.pointerLens.cursorPos=c.canvasPos,this.pointerLens.snapped=!1),this._currentDistanceMeasurement.target.worldPos=c.worldPos,this._currentDistanceMeasurement.target.entity=c.entity,this._currentDistanceMeasurement.targetVisible=!0,this._currentDistanceMeasurement.wireVisible=!0,this._currentDistanceMeasurement.labelsVisible=!0)),this._touchState=5}}),{passive:!0}),s.addEventListener("touchend",this._onCanvasTouchEnd=s=>{this.pointerCircle.stop();const i=s.changedTouches.length;if(1!==i)return;const c=s.changedTouches[0];if(c.identifier!==l)return;n&&(clearTimeout(n),n=null),d(c,a);const u=a[0],p=a[1];switch(this._touchState){case 1:{if(1!==i||u>A[0]+r||u<A[0]-r||p>A[1]+r||p<A[1]-r)return void(this._touchState=0);const s=t.pick({canvasPos:o,pickSurface:!0});s&&s.worldPos?(this._currentDistanceMeasurement=e.createMeasurement({id:R.createUUID(),origin:{worldPos:s.worldPos,entity:s.entity},target:{worldPos:s.worldPos,entity:s.entity}}),this._currentDistanceMeasurement.labelsVisible=!1,this._currentDistanceMeasurement.xAxisVisible=!1,this._currentDistanceMeasurement.yAxisVisible=!1,this._currentDistanceMeasurement.zAxisVisible=!1,this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.originVisible=!0,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.clickable=!1,this._touchState=3,this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement)):(this._currentDistanceMeasurement&&this._currentDistanceMeasurement.destroy(),this._touchState=0)}h();break;case 2:this.pointerLens&&(this.pointerLens.visible=!1),this._currentDistanceMeasurement?this._touchState=3:(this.pointerLens&&(this.pointerLens.snapped=!1,this.pointerLens.visible=!1),this._touchState=0),h();break;case 4:{if(1!==i||u>A[0]+r||u<A[0]-r||p>A[1]+r||p<A[1]-r)return void(this._touchState=3);const e=t.pick({canvasPos:o,pickSurface:!0});e&&e.worldPos?(this._currentDistanceMeasurement.target.worldPos=e.worldPos,this._currentDistanceMeasurement.target.entity=e.entity,this._currentDistanceMeasurement.targetVisible=!0,this._currentDistanceMeasurement.wireVisible=!0,this._currentDistanceMeasurement.labelsVisible=!0,this._currentDistanceMeasurement.xAxisVisible=!0,this._currentDistanceMeasurement.yAxisVisible=!0,this._currentDistanceMeasurement.zAxisVisible=!0,this._currentDistanceMeasurement.clickable=!0,this.distanceMeasurementsPlugin.fire("measurementEnd",this._currentDistanceMeasurement),this._currentDistanceMeasurement=null):this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._touchState=0}h();break;case 5:console.log("long touch"),this.pointerLens&&(this.pointerLens.visible=!1),this._currentDistanceMeasurement&&this._currentDistanceMeasurement.targetVisible?(this._currentDistanceMeasurement.clickable=!0,this.distanceMeasurementsPlugin.fire("measurementEnd",this._currentDistanceMeasurement),this._currentDistanceMeasurement=null,this._touchState=0):(this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._touchState=0),h()}},{passive:!0}),this._active=!0}deactivate(){if(!this._active)return;this.plugin.pointerLens&&(this.plugin.pointerLens.visible=!1),this.reset();const e=this.plugin.viewer.scene.canvas.canvas;e.removeEventListener("touchstart",this._onCanvasTouchStart),e.removeEventListener("touchend",this._onCanvasTouchEnd),this._active=!1,this.plugin.viewer.cameraControl.active=!0}reset(){this._active&&this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null)}get currentMeasurement(){return this._currentDistanceMeasurement}destroy(){this.deactivate(),super.destroy()}},exports.Dot3D=eB,exports.DotBIMDefaultDataSource=cv,exports.DotBIMLoaderPlugin=class extends mn{constructor(e,t={}){super("DotBIMLoader",e,t),this.dataSource=t.dataSource,this.objectDefaults=t.objectDefaults}set dataSource(e){this._dataSource=e||new cv}get dataSource(){return this._dataSource}set objectDefaults(e){this._objectDefaults=e||WB}get objectDefaults(){return this._objectDefaults}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new jr(this.viewer.scene,j.apply(e,{isModel:!0,backfaces:e.backfaces,dtxEnabled:e.dtxEnabled,rotation:e.rotation,origin:e.origin})),s=t.id;if(!e.src&&!e.dotBIM)return this.error("load() param expected: src or dotBIM"),t;const i=e.objectDefaults||this._objectDefaults||WB;let r,n;if(e.includeTypes){r={};for(let t=0,s=e.includeTypes.length;t<s;t++)r[e.includeTypes[t]]=!0}if(e.excludeTypes){n={},r||(r={});for(let t=0,s=e.excludeTypes.length;t<s;t++)r[e.excludeTypes[t]]=!0}const A=e=>{const t=e.fileData,A=e.sceneModel,o={},a=R.createUUID(),l=R.createUUID(),c=R.createUUID(),h=R.createUUID(),u={metaObjects:[{id:a,name:"Project",type:"Project",parent:null},{id:l,name:"Site",type:"Site",parent:a},{id:c,name:"Building",type:"Building",parent:l},{id:h,name:"BuildingStorey",type:"BuildingStorey",parent:c}],propertySets:[]},d=(e,s)=>{if(o[e])return;const i=t.meshes.find((e=>e.mesh_id===s.mesh_id));A.createGeometry({id:e,primitive:"triangles",positions:i.coordinates,indices:i.indices}),o[e]=!0},p=t.elements;for(let e=0,s=p.length;e<s;e++){const s=p[e],o=s.type;if(n&&n[o])continue;if(r&&!r[o])continue;const a=s.info,l=void 0!==s.guid?`${s.guid}`:void 0!==a&&void 0!==a.id?a.id:e,c=s.mesh_id,f=s.vector,g=s.rotation,m=i?i[o]||i.DEFAULT:null;let _=!0,b=!0;if(void 0===s.face_colors){d(c,s);const e=`${l}-mesh-${c}`;let t=s.color?[s.color.r/255,s.color.g/255,s.color.b/255]:[1,1,1],i=s.color?s.color.a/255:1;m&&(!1===m.visible&&(_=!1),!1===m.pickable&&(b=!1),m.colorize&&(t=m.colorize),void 0!==m.opacity&&null!==m.opacity&&(i=m.opacity)),A.createMesh({id:e,geometryId:c,color:t,opacity:i,quaternion:!g||0===g.qz&&0===g.qy&&0===g.qx&&1===g.qw?void 0:[g.qx,g.qy,g.qz,g.qw],position:f?[f.x,f.y,f.z]:void 0}),A.createEntity({id:l,meshIds:[e],visible:_,pickable:b,isObject:!0})}else{let e=s.face_colors,i={},r=0,n=t.meshes.find((e=>e.mesh_id===s.mesh_id));for(let t=0,s=e.length;t<s;t+=4){let s=[e[t],e[t+1],e[t+2],e[t+3]];void 0===i[s]&&(i[s]=[]);let A=n.indices[r],o=n.coordinates[3*A],a=n.coordinates[3*A+1],l=n.coordinates[3*A+2],c=n.indices[r+1],h=n.coordinates[3*c],u=n.coordinates[3*c+1],d=n.coordinates[3*c+2],p=n.indices[r+2],f=n.coordinates[3*p],g=n.coordinates[3*p+1],m=n.coordinates[3*p+2];i[s].push(o,a,l,h,u,d,f,g,m),r+=3}let o=[];for(const[e,t]of Object.entries(i)){A.createGeometry({id:`${c}-${e}`,primitive:"triangles",positions:t,indices:[...Array(t.length/3).keys()]});const s=`${l}-mesh-${c}-${e}`,i=e.split(",").map(Number);let r=[i[0]/255,i[1]/255,i[2]/255],n=i[3]/255;m&&(!1===m.visible&&(_=!1),!1===m.pickable&&(b=!1),m.colorize&&(r=m.colorize),void 0!==m.opacity&&null!==m.opacity&&(n=m.opacity)),A.createMesh({id:s,geometryId:`${c}-${e}`,color:r,opacity:n,quaternion:!g||0===g.qz&&0===g.qy&&0===g.qx&&1===g.qw?void 0:[g.qx,g.qy,g.qz,g.qw],position:f?[f.x,f.y,f.z]:void 0}),o.push(s)}A.createEntity({id:l,meshIds:o,visible:_,pickable:b,isObject:!0})}let B=[];for(let e in a)B.push({name:e,value:a[e]});u.propertySets.push({id:l,name:"Properties",properties:B}),u.metaObjects.push({id:l,name:a&&a.Name&&"None"!==a.Name?a.Name:`${s.type} ${l}`,type:s.type,parent:h,propertySetIds:[l]})}A.finalize(),this.viewer.metaScene.createMetaModel(s,u),A.scene.once("tick",(()=>{A.destroyed||(A.scene.fire("modelLoaded",A.id),A.fire("loaded",!0,!1))}))};if(e.src){const s=e.src;this.viewer.scene.canvas.spinner.processes++,this._dataSource.getDotBIM(s,(e=>{A({fileData:e,sceneModel:t,nextId:0,error:function(e){}}),this.viewer.scene.canvas.spinner.processes--}),(e=>{this.viewer.scene.canvas.spinner.processes--,this.error(e)}))}else if(e.dotBIM){const s={fileData:e.dotBIM,sceneModel:t,nextId:0,error:function(e){}};A(s)}return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(s)})),t}destroy(){super.destroy()}},exports.EdgeMaterial=fs,exports.EmphasisMaterial=ds,exports.FaceAlignedSectionPlanesPlugin=class extends mn{constructor(e,t={}){if(super("FaceAlignedSectionPlanesPlugin",e),this._freeControls=[],this._sectionPlanes=e.scene.sectionPlanes,this._controls={},this._shownControlId=null,this._dragSensitivity=t.dragSensitivity||1,null!==t.overviewCanvasId&&void 0!==t.overviewCanvasId){const e=document.getElementById(t.overviewCanvasId);e?this._overview=new my(this,{overviewCanvas:e,visible:t.overviewVisible,onHoverEnterPlane:e=>{this._overview.setPlaneHighlighted(e,!0)},onHoverLeavePlane:e=>{this._overview.setPlaneHighlighted(e,!1)},onClickedPlane:e=>{if(this.getShownControl()===e)return void this.hideControl();this.showControl(e);const t=this.sectionPlanes[e].pos;_y.set(this.viewer.scene.aabb),R.getAABB3Center(_y,by),_y[0]+=t[0]-by[0],_y[1]+=t[1]-by[1],_y[2]+=t[2]-by[2],_y[3]+=t[0]-by[0],_y[4]+=t[1]-by[1],_y[5]+=t[2]-by[2],this.viewer.cameraFlight.flyTo({aabb:_y,fitFOV:65})},onClickedNothing:()=>{this.hideControl()}}):this.warn("Can't find overview canvas: '"+t.overviewCanvasId+"' - will create plugin without overview")}null===t.controlElementId||void 0===t.controlElementId?this.error("Parameter expected: controlElementId"):(this._controlElement=document.getElementById(t.controlElementId),this._controlElement||this.warn("Can't find control element: '"+t.controlElementId+"' - will create plugin without control element")),this._onSceneSectionPlaneCreated=e.scene.on("sectionPlaneCreated",(e=>{this._sectionPlaneCreated(e)}))}setDragSensitivity(e){this._dragSensitivity=e||1}getDragSensitivity(){return this._dragSensitivity}setOverviewVisible(e){this._overview&&this._overview.setVisible(e)}getOverviewVisible(){if(this._overview)return this._overview.getVisible()}get sectionPlanes(){return this._sectionPlanes}createSectionPlane(e={}){void 0!==e.id&&null!==e.id&&this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);return new pn(this.viewer.scene,{id:e.id,pos:e.pos,dir:e.dir,active:!0})}_sectionPlaneCreated(e){const t=this._freeControls.length>0?this._freeControls.pop():new fy(this);t._setSectionPlane(e),t.setVisible(!1),this._controls[e.id]=t,this._overview&&this._overview.addSectionPlane(e),e.once("destroyed",(()=>{this._sectionPlaneDestroyed(e)}))}flipSectionPlanes(){const e=this.viewer.scene.sectionPlanes;for(let t in e){e[t].flipDir()}}showControl(e){const t=this._controls[e];t?(this.hideControl(),t.setVisible(!0),this._overview&&this._overview.setPlaneSelected(e,!0),this._shownControlId=e):this.error("Control not found: "+e)}getShownControl(){return this._shownControlId}hideControl(){for(let e in this._controls)this._controls.hasOwnProperty(e)&&(this._controls[e].setVisible(!1),this._overview&&this._overview.setPlaneSelected(e,!1));this._shownControlId=null}destroySectionPlane(e){let t=this.viewer.scene.sectionPlanes[e];t?(this._sectionPlaneDestroyed(t),t.destroy(),e===this._shownControlId&&(this._shownControlId=null)):this.error("SectionPlane not found: "+e)}_sectionPlaneDestroyed(e){this._overview&&this._overview.removeSectionPlane(e);const t=this._controls[e.id];t&&(t.setVisible(!1),t._setSectionPlane(null),delete this._controls[e.id],this._freeControls.push(t))}clear(){const e=Object.keys(this._sectionPlanes);for(let t=0,s=e.length;t<s;t++)this.destroySectionPlane(e[t])}send(e,t){switch(e){case"snapshotStarting":for(let e in this._controls)this._controls.hasOwnProperty(e)&&this._controls[e].setCulled(!0);break;case"snapshotFinished":for(let e in this._controls)this._controls.hasOwnProperty(e)&&this._controls[e].setCulled(!1);break;case"clearSectionPlanes":this.clear()}}destroy(){this.clear(),this._overview&&this._overview.destroy(),this._destroyFreeControls(),super.destroy()}_destroyFreeControls(){let e=this._freeControls.pop();for(;e;)e._destroy(),e=this._freeControls.pop();this.viewer.scene.off(this._onSceneSectionPlaneCreated)}},exports.FastNavPlugin=class extends mn{constructor(e,t={}){super("FastNav",e),this._hideColorTexture=!1!==t.hideColorTexture,this._hidePBR=!1!==t.hidePBR,this._hideSAO=!1!==t.hideSAO,this._hideEdges=!1!==t.hideEdges,this._hideTransparentObjects=!!t.hideTransparentObjects,this._scaleCanvasResolution=!!t.scaleCanvasResolution,this._defaultScaleCanvasResolutionFactor=t.defaultScaleCanvasResolutionFactor,this._scaleCanvasResolutionFactor=t.scaleCanvasResolutionFactor||.6,this._delayBeforeRestore=!1!==t.delayBeforeRestore,this._delayBeforeRestoreSeconds=t.delayBeforeRestoreSeconds||.5,this._onMoved=t.onMoved,this._onStopped=null;let s=1e3*this._delayBeforeRestoreSeconds,i=!1;const r=()=>{e.scene.canvas.resolutionScale=this._defaultScaleCanvasResolutionFactor||this._originalCanvasResolutionScale||1,e.scene._renderer.setEdgesEnabled(!0),e.scene._renderer.setColorTextureEnabled(!0),e.scene._renderer.setPBREnabled(!0),e.scene._renderer.setSAOEnabled(!0),e.scene._renderer.setTransparentEnabled(!0),this._onStopped&&this._onStopped(),i=!1};this._onCameraMatrix=e.scene.camera.on("matrix",(()=>{s=1e3*this._delayBeforeRestoreSeconds,i||(e.scene._renderer.setColorTextureEnabled(!this._hideColorTexture),e.scene._renderer.setPBREnabled(!this._hidePBR),e.scene._renderer.setSAOEnabled(!this._hideSAO),e.scene._renderer.setTransparentEnabled(!this._hideTransparentObjects),e.scene._renderer.setEdgesEnabled(!this._hideEdges),this._originalCanvasResolutionScale=e.scene.canvas.resolutionScale,this._scaleCanvasResolution?e.scene.canvas.resolutionScale=this._scaleCanvasResolutionFactor:e.scene.canvas.resolutionScale=this._defaultScaleCanvasResolutionFactor,this._onMoved&&(this._onStopped=this._onMoved()),i=!0)})),this._onSceneTick=e.scene.on("tick",(e=>{i&&(s-=e.deltaTime,(!this._delayBeforeRestore||s<=0)&&r())}))}get hideColorTexture(){return this._hideColorTexture}set hideColorTexture(e){this._hideColorTexture=e}get hidePBR(){return this._hidePBR}set hidePBR(e){this._hidePBR=e}get hideSAO(){return this._hideSAO}set hideSAO(e){this._hideSAO=e}get hideEdges(){return this._hideEdges}set hideEdges(e){this._hideEdges=e}get hideTransparentObjects(){return this._hideTransparentObjects}set hideTransparentObjects(e){this._hideTransparentObjects=!1!==e}get scaleCanvasResolution(){return this._scaleCanvasResolution}set scaleCanvasResolution(e){this._scaleCanvasResolution=e}get defaultScaleCanvasResolutionFactor(){return this._defaultScaleCanvasResolutionFactor}set defaultScaleCanvasResolutionFactor(e){this._defaultScaleCanvasResolutionFactor=e}get scaleCanvasResolutionFactor(){return this._scaleCanvasResolutionFactor}set scaleCanvasResolutionFactor(e){this._scaleCanvasResolutionFactor=e||.6}get delayBeforeRestore(){return this._delayBeforeRestore}set delayBeforeRestore(e){this._delayBeforeRestore=e}get delayBeforeRestoreSeconds(){return this._delayBeforeRestoreSeconds}set delayBeforeRestoreSeconds(e){this._delayBeforeRestoreSeconds=null!=e?e:.5}send(e,t){}destroy(){this.viewer.scene.camera.off(this._onCameraMatrix),this.viewer.scene.canvas.off(this._onCanvasBoundary),this.viewer.scene.input.off(this._onSceneMouseDown),this.viewer.scene.input.off(this._onSceneMouseUp),this.viewer.scene.input.off(this._onSceneMouseMove),this.viewer.scene.off(this._onSceneTick),super.destroy()}},exports.FloatType=1015,exports.Fresnel=class extends ie{get type(){return"Fresnel"}constructor(e,t={}){super(e,t),this._state=new xe({edgeColor:R.vec3([0,0,0]),centerColor:R.vec3([1,1,1]),edgeBias:0,centerBias:1,power:1}),this.edgeColor=t.edgeColor,this.centerColor=t.centerColor,this.edgeBias=t.edgeBias,this.centerBias=t.centerBias,this.power=t.power}set edgeColor(e){this._state.edgeColor.set(e||[0,0,0]),this.glRedraw()}get edgeColor(){return this._state.edgeColor}set centerColor(e){this._state.centerColor.set(e||[1,1,1]),this.glRedraw()}get centerColor(){return this._state.centerColor}set edgeBias(e){this._state.edgeBias=e||0,this.glRedraw()}get edgeBias(){return this._state.edgeBias}set centerBias(e){this._state.centerBias=null!=e?e:1,this.glRedraw()}get centerBias(){return this._state.centerBias}set power(e){this._state.power=null!=e?e:1,this.glRedraw()}get power(){return this._state.power}destroy(){super.destroy(),this._state.destroy()}},exports.Frustum=ae,exports.FrustumPlane=oe,exports.GIFMediaType=1e4,exports.GLTFDefaultDataSource=RB,exports.GLTFLoaderPlugin=zB,exports.HalfFloatType=1016,exports.IFCOpenShellDefaultDataSource=Zw,exports.IFCOpenShellLoaderPlugin=class extends mn{constructor(e,t){if(super("IFCOpenShellLoader",e,t),!t)throw new Error("IFCOpenShellLoaderPlugin: No configuration given");if(!t.ifcopenshell)throw new Error("IFCOpenShellLoaderPlugin: No ifcopenshell given");if(!t.ifcopenshell_geom)throw new Error("IFCOpenShellLoaderPlugin: No ifcopenshell_geom given");this.ifcopenshell=t.ifcopenshell,this.ifcopenshell_geom=t.ifcopenshell_geom,this.dataSource=t.dataSource}set dataSource(e){this._dataSource=e||new Zw}get dataSource(){return this._dataSource}get globalizeObjectIds(){return this._globalizeObjectIds}set globalizeObjectIds(e){this._globalizeObjectIds=!!e}async load(e={}){let{id:t,backfaces:s=!0,dtxEnabled:i=!0,position:r,rotation:n,origin:A,loadMetadata:o,loadMetadataPropertySets:a,edges:l,saoEnabled:c,globalizeObjectIds:h,excludeTypes:u}=e;t&&this.viewer.scene.components[t]&&(this.error(`Component with this ID already exists: ${t} - autogenerating SceneModel ID`),t=null);const d=new jr(this.viewer.scene,{id:t,isModel:!0,globalizeObjectIds:h,backfaces:s,dtxEnabled:i,position:r,rotation:n,origin:A,edges:l,saoEnabled:c}),p=d.id;if(!e.src&&!e.text)return this.error("load() expected 'src' or 'text'"),d;this.viewer.scene.canvas.spinner.processes++;const f=e=>{const t=this.ifcopenshell.file.from_string(e),s={loadMetadataPropertySets:!1!==a,globalizeObjectIds:h||this._globalizeObjectIds,geometryCache:new Map,ifc:t,sceneModel:d};if(u&&(s.excludeTypes=u),this._loadIFCGeometry(s),!1!==o){const e=this._loadIFCMetaModel(s,t);this.viewer.metaScene.createMetaModel(p,e)}this.viewer.scene.canvas.spinner.processes--};return e.src?(this.viewer.scene.canvas.spinner.processes++,this._dataSource.getIFC(e.src,(e=>{f(e),this.viewer.scene.canvas.spinner.processes--}),(e=>{this.viewer.scene.canvas.spinner.processes--,this.error(e)}))):f(e.text),d.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(p)})),d}_loadIFCGeometry(e){const{ifc:t,sceneModel:s}=e,{ifcopenshell_geom:i}=this,r=i.settings();r.set(r.WELD_VERTICES,!1);const n=i.iterator.callKwargs({settings:r,file_or_filename:t,exclude:e.excludeTypes,geometry_library:"hybrid-cgal-simple-opencascade"});if(n.initialize())do{const s=n.get();if(s){const i=t.by_id(s.id);this._parseIFCEntity(e,s,i)}}while(n.next());s.finalize(),s.scene.once("tick",(()=>{s.destroyed||(s.scene.fire("modelLoaded",s.id),s.fire("loaded",!0,!1))}))}_parseIFCEntity(e,t,s){const{sceneModel:i,geometryCache:r}=e,n=t.geometry.id,A=t.transformation.data().components.toJs(),{origin:o,matrix:a}=function(e){const t=(r=e,new Float64Array([r[0][0],r[2][0],-r[1][0],r[3][0],r[0][1],r[2][1],-r[1][1],r[3][1],r[0][2],r[2][2],-r[1][2],r[3][2],r[0][3],r[2][3],-r[1][3],r[3][3]])),s=[],i=t.slice(12,15);var r;return pt(i,i,s),t.set(i,12),{origin:s,matrix:t}}(A);if(!r.get(n)){const e=t.geometry.materials.toJs().map((e=>({diffuse:e.diffuse.components.toJs(),transparency:e.transparency&&!isNaN(e.transparency)?e.transparency:0}))),s=function(e){const t={};for(let s=0;s<e.length;s++){const i=e[s];null==i||i<0||(t[i]||=[]).push(s)}return t}(new Int32Array(t.geometry.material_ids.toJs())),A=new Map;for(const[e,r]of Object.entries(s)){if(!r||0===r.length)continue;const s=new Float32Array(t.geometry.verts.toJs()),o=new Uint32Array(t.geometry.edges.toJs()),a=new Uint32Array(t.geometry.faces.toJs()),l=Number(e),c=Yw(r,a),h=Jw(n,l);i.createGeometry({id:h,primitive:"triangles",positions:s,indices:c,edgeIndices:o}),A.set(l,h)}r.set(n,{subGeoms:A,materials:e,mapping:new Map(Object.entries(s).map((([e,t])=>[Number(e),new Uint32Array(t)])))})}const l=r.get(n),c=[];for(const[e,t]of l.subGeoms.entries()){const s=l.materials[e]||{diffuse:[.6,.6,.6],transparency:0},r=Math.random().toString(36).substr(2,9),n=s.diffuse;i.createMesh({id:r,geometryId:t,origin:o,matrix:a,color:[n[0],n[1],n[2]],opacity:1-s.transparency}),c.push(r)}i.createEntity({id:e.globalizeObjectIds?R.globalizeObjectId(e.sceneModel.id,s.GlobalId):s.GlobalId,isObject:!0,meshIds:c})}_loadIFCMetaModel(e,t){const s=new Set,i=[],r=[],n=e=>null==e?"":String(e);function A(e){try{return String(e.GlobalId)}catch{return null}}function o(t,n=null){if(!t)return;if(!function(t,n){const o=A(t);if(!o||s.has(o))return!1;s.add(o);const a=e.globalizeObjectIds,l=e.sceneModel.id,c=[];if(e.loadMetadataPropertySets){const e=["HasAssociations","IsDefinedBy","IsDecomposedBy","ContainsElements"];for(const s of e){const e=t[s];if(e&&e.length>0){for(let t=0;t<e.length;t++){const s=e.get(t);if(s.is_a&&"IfcRelDefinesByProperties"===s.is_a()){const e=s.RelatingPropertyDefinition;if(e&&e.is_a&&["IfcPropertySet","IfcElementQuantity"].includes(e.is_a())){const t=e.GlobalId?String(e.GlobalId):null,s=e.Name?String(e.Name):"",i=e.is_a?String(e.is_a()):"",n=[],A=e.HasProperties||e.Quantities;if(A&&A.length>0){for(let e=0;e<A.length;e++){const t=A.get(e),s=t.Name?String(t.Name):"";let i="",r=t.is_a?String(t.is_a()):"";if(t.is_a&&"IfcPropertySingleValue"===t.is_a())try{i=t.NominalValue?String(t.NominalValue.wrappedValue):""}catch{i=""}else if(t.is_a&&"IfcPropertyEnumeratedValue"===t.is_a())try{const e=t.EnumerationValues;if(e&&e.length>0){const t=[];for(let s=0;s<e.length;s++)t.push(String(e.get(s).wrappedValue));i=t.join(", ")}}catch{i=""}else if(t.is_a&&"IfcQuantityArea"===t.is_a())i=t.AreaValue?String(t.AreaValue):"";else if(t.is_a&&"IfcQuantityLength"===t.is_a())i=t.LengthValue?String(t.LengthValue):"";else if(t.is_a&&"IfcQuantityVolume"===t.is_a())i=t.VolumeValue?String(t.VolumeValue):"";else try{i=t.NominalValue?String(t.NominalValue):""}catch{i=""}n.push({name:s,value:i,type:r}),t.destroy?.()}A.destroy?.()}r.push({id:t,name:s,type:i,properties:n}),c.push(t),e.destroy?.()}s.destroy?.()}}e.destroy?.()}}}return i.push({id:a?R.globalizeObjectId(l,o):o,type:String(t.is_a()),parent:n?a?R.globalizeObjectId(l,A(n)):A(n):null,propertySetIds:c}),!0}(t,n))return void t.destroy?.();const a=t.IsDecomposedBy;if(a)for(let e=0;e<a.length;e++){const s=a.get(e),i=s.RelatedObjects;if(i){for(let e=0;e<i.length;e++){const s=i.get(e);o(s,t),s.destroy?.()}i.destroy?.()}s.destroy?.()}const l=t.ContainsElements;if(l)for(let e=0;e<l.length;e++){const s=l.get(e),i=s.RelatedElements;if(i){for(let e=0;e<i.length;e++){const s=i.get(e);o(s,t),s.destroy?.()}i.destroy?.()}s.destroy?.()}t.destroy?.()}let a="",l="",c="",h="",u="";try{h=n(t.schema)}catch{}if(!h)try{const e=t.wrapped_data.header.file_schema.schema_identifiers;e&&e.length>0&&(h=n(e.get(0)))}catch{}const d=t.by_type("IfcProject");if(d&&d.length>0){const e=d.get(0);a=n(e.GlobalId);try{const t=e.OwnerHistory;if(t){try{const e=t.OwningUser,s=e?.ThePerson,i=e?.TheOrganization,r=s?.GivenName?n(s.GivenName):"",A=s?.FamilyName?n(s.FamilyName):"",o=r||A?[r,A].filter(Boolean).join(" "):"";l=[o,i?.Name?n(i.Name):""].filter(Boolean).join(" / ")}catch{}try{const e=t?.CreationDate;"number"==typeof e&&isFinite(e)&&e>0&&(c=new Date(1e3*e).toISOString())}catch{}try{const e=t?.OwningApplication,s=e?.ApplicationFullName?n(e.ApplicationFullName):e?.ApplicationIdentifier?n(e.ApplicationIdentifier):"";u=[s,e?.Version?n(e.Version):""].filter(Boolean).join(" ")}catch{}}}catch{}e.destroy?.()}try{const e=t.wrapped_data.header.file_name;if(!l)try{const t=e.author;if(t&&t.length>0){const e=[];for(let s=0;s<t.length;s++)e.push(n(t.get(s)));l=e.filter(Boolean).join(", ")}}catch{}if(!c){const t=n(e.time_stamp);if(t){const e=new Date(t);isNaN(e.getTime())||(c=e.toISOString())}}if(!u){const t=n(e.originating_system);u=[t,n(e.preprocessor_version)].filter(Boolean).join(" / ")}}catch{}if(!c)try{let e=1/0;const s=t.by_type("IfcRoot");for(let t=0;t<s.length;t++){const i=s.get(t),r=i?.OwnerHistory,n=r?.CreationDate;"number"==typeof n&&isFinite(n)&&n>0&&n<e&&(e=n),i.destroy?.()}s.destroy?.(),isFinite(e)&&(c=new Date(1e3*e).toISOString())}catch{}const p=t.by_type("IfcProject");for(let e=0;e<p.length;e++){const t=p.get(e);o(t,null),t.destroy?.()}return p.destroy?.(),{id:"",projectId:a,author:l,createdAt:c,schema:h,creatingApplication:u,metaObjects:i,propertySets:r}}destroy(){super.destroy()}},exports.ImagePlane=class extends ie{constructor(e,t={}){super(e,t),this._src=null,this._image=null,this._pos=R.vec3(),this._origin=R.vec3(),this._rtcPos=R.vec3(),this._dir=R.vec3(),this._size=1,this._imageSize=R.vec2(),this._texture=new es(this),this._plane=new Ot(this,{geometry:new Le(this,Ze({center:[0,0,0],xSize:1,zSize:1,xSegments:10,zSegments:10})),material:new jt(this,{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:this._texture,emissiveMap:this._texture,backfaces:!0}),clippable:t.clippable}),this._grid=new Ot(this,{geometry:new Le(this,Ke({size:1,divisions:10})),material:new jt(this,{diffuse:[0,0,0],ambient:[0,0,0],emissive:[.2,.8,.2]}),position:[0,.001,0],clippable:t.clippable}),this._node=new ct(this,{rotation:[0,0,0],position:[0,0,0],scale:[1,1,1],clippable:!1,children:[this._plane,this._grid]}),this._gridVisible=!1,this.visible=!0,this.gridVisible=t.gridVisible,this.position=t.position,this.rotation=t.rotation,this.dir=t.dir,this.size=t.size,this.collidable=t.collidable,this.clippable=t.clippable,this.pickable=t.pickable,this.opacity=t.opacity,t.image?this.image=t.image:this.src=t.src}set visible(e){this._plane.visible=e,this._grid.visible=this._gridVisible&&e}get visible(){return this._plane.visible}set gridVisible(e){e=!1!==e,this._gridVisible=e,this._grid.visible=this._gridVisible&&this.visible}get gridVisible(){return this._gridVisible}set image(e){this._image=e,this._image&&(this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}get image(){return this._image}set src(e){if(this._src=e,this._src){this._image=null;const e=new Image;e.onload=()=>{this._texture.image=e,this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage()},e.src=this._src}}get src(){return this._src}set position(e){this._pos.set(e||[0,0,0]),dt(this._pos,this._origin,this._rtcPos),this._node.origin=this._origin,this._node.position=this._rtcPos}get position(){return this._pos}set rotation(e){this._node.rotation=e}get rotation(){return this._node.rotation}set size(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}get size(){return this._size}set dir(e){if(this._dir.set(e||[0,0,-1]),e){const t=this.scene.center,s=[-this._dir[0],-this._dir[1],-this._dir[2]];R.subVec3(t,this.position,ts);const i=-R.dotVec3(s,ts);R.normalizeVec3(s),R.mulVec3Scalar(s,i,ss),R.vec3PairToQuaternion(is,e,rs),this._node.quaternion=rs}}get dir(){return this._dir}set collidable(e){this._node.collidable=!1!==e}get collidable(){return this._node.collidable}set clippable(e){this._node.clippable=!1!==e}get clippable(){return this._node.clippable}set pickable(e){this._node.pickable=!1!==e}get pickable(){return this._node.pickable}set opacity(e){this._node.opacity=e}get opacity(){return this._node.opacity}destroy(){super.destroy()}_updatePlaneSizeFromImage(){const e=this._size,t=this._imageSize[0],s=this._imageSize[1];if(t>s){const i=s/t;this._node.scale=[e,1,e*i]}else{const i=t/s;this._node.scale=[e*i,1,e]}}},exports.IntType=1013,exports.JPEGMediaType=10001,exports.KTX2TextureTranscoder=dr,exports.LASLoaderPlugin=class extends mn{constructor(e,t={}){super("lasLoader",e,t),this.dataSource=t.dataSource,this.skip=t.skip,this.fp64=t.fp64,this.colorDepth=t.colorDepth,this.center=t.center,this.rotate=t.rotate,this.rotateX=t.rotateX,this.transform=t.transform}get dataSource(){return this._dataSource}set dataSource(e){this._dataSource=e||new $w}get skip(){return this._skip}set skip(e){this._skip=e||1}get fp64(){return this._fp64}set fp64(e){this._fp64=!!e}get colorDepth(){return this._colorDepth}set colorDepth(e){this._colorDepth=e||"auto"}get center(){return this._center}set center(e){this._center=!!e}get transform(){return this._transform}set transform(e){this._transform=e}get rotate(){return this._rotate}set rotate(e){this._rotate=e}get rotateX(){return this._rotateX}set rotateX(e){this._rotateX=e}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new jr(this.viewer.scene,j.apply(e,{maxGeometryBatchSize:5e5,isModel:!0}));if(!(e.src||e.las||e.manifest||e.manifestSrc))return this.error("load() param expected: src or las"),t;const s={las:{skip:this._skip,fp64:this._fp64,colorDepth:this._colorDepth}},i=this.viewer.scene.canvas.spinner,r=()=>{t.scene.once("tick",(()=>{t.destroyed||(t.scene.fire("modelLoaded",t.id),t.fire("loaded",!0,!1))})),i.processes--},n=e=>{i.processes--,this.error(e),t.fire("error",e)};if(e.src)this._loadModel(e.src,e,s,t);else if(e.las)i.processes++,this._parseModel(e.las,e,s,t).then(r,n);else if(e.manifest||e.manifestSrc){const i=e.manifestSrc?function(e){e.indexOf("?")>-1&&(e=e.split("?")[0]);const t=e.split("/");return t.pop(),t.join("/")+"/"}(e.manifestSrc):"",A=A=>{let o=0;const a=new Array(A.length),l=()=>{if(t.destroyed)r();else{if(o>=A.length)return;a[o]=!1,this._dataSource.getLAS(`${i}${A[o]}`,(i=>{const n=j.apply(e,{isManifest:!0,index:o});this._parseModel(i,n,s,t).then((()=>{a[n.index]=!0;let e=!0;a.forEach((t=>{t||(e=!1)})),e&&r()})),o++,this.scheduleTask(l,200)}),n)}};l()},o=e=>{if(t.destroyed)return;const s=e.lasFiles||e.lazFiles;!s||s.length<=0?this.error("load(): Failed to load model manifest - manifest not valid"):A(s)};if(e.manifestSrc)this._dataSource.getManifest(e.manifestSrc,(e=>{o(e)}),(e=>{this.error(e),t.fire("error",e)}));else{const t=e.manifest;o(t)}}return t}_loadModel(e,t,s,i){const r=this.viewer.scene.canvas.spinner;r.processes++,this._dataSource.getLAS(t.src,(e=>{this._parseModel(e,t,s,i).then((()=>{i.scene.once("tick",(()=>{i.destroyed||(i.scene.fire("modelLoaded",i.id),i.fire("loaded",!0,!1))})),r.processes--}),(e=>{r.processes--,this.error(e),i.fire("error",e)}))}),(e=>{r.processes--,this.error(e),i.fire("error",e)}))}_parseModel(e,t,s,i){const r=e=>{const t=e.value;if(this._center){const e=R.vec3(),s=t.length;for(let s=0,i=t.length;s<i;s+=3)e[0]+=t[s+0],e[1]+=t[s+1],e[2]+=t[s+2];e[0]/=s,e[1]/=s,e[2]/=s;for(let s=0,i=t.length;s<i;s+=3)t[s+0]-=e[0],t[s+1]-=e[1],t[s+2]-=e[2]}if(this._rotateX&&t)for(let e=0,s=t.length;e<s;e+=3){const s=t[e+1];t[e+1]=t[e+2],t[e+2]=s}if(this._rotate){const e=R.identityQuaternion(),s=R.mat4();R.eulerToQuaternion(this._rotate,"XYZ",e),R.quaternionToRotationMat4(e,s);const i=R.vec3();for(let e=0,r=t.length;e<r;e+=3)i[0]=t[e+0],i[1]=t[e+1],i[2]=t[e+2],R.transformPoint3(s,i,i),t[e+0]=i[0],t[e+1]=i[1],t[e+2]=i[2]}if(this._transform){const e=R.mat4(this._transform),s=R.vec3();for(let i=0,r=t.length;i<r;i+=3)s[0]=t[i+0],s[1]=t[i+1],s[2]=t[i+2],R.transformPoint3(e,s,s),t[i+0]=s[0],t[i+1]=s[1],t[i+2]=s[2]}return t};function n(e,t){const s=e.value,i=e.size,r=t.value,n=4*r.length,A=new Uint8Array(n);for(let e=0,t=0,n=0,o=r.length;e<o;e++,n+=i,t+=4)A[t+0]=s[n+0],A[t+1]=s[n+1],A[t+2]=s[n+2],A[t+3]=Math.round(r[e]/65536*255);return A}function A(e){const t=e.value,s=4*t.length,i=new Uint8Array(s);for(let e=0,s=0,r=t.length;e<r;e++,s+=4)i[s+0]=0,i[s+1]=0,i[s+2]=0,i[s+3]=Math.round(t[e]/65536*255);return i}return new Promise(((o,a)=>{if(i.destroyed)return void a();const l=t.stats||{};l.sourceFormat="LAS",l.schemaVersion="",l.title="",l.author="",l.created="",l.numMetaObjects=0,l.numPropertySets=0,l.numObjects=0,l.numGeometries=0,l.numTriangles=0,l.numVertices=0;try{const l=tv(e);rl(e,Du,s).then((e=>{const c=e.attributes,h=e.loaderData,u=void 0!==h.pointsFormatId?h.pointsFormatId:-1;if(!c.POSITION)return i.finalize(),void a("No positions found in file");let d,p;switch(u){case 0:d=r(c.POSITION),p=A(c.intensity);break;case 1:if(!c.intensity)return i.finalize(),void a("No positions found in file");d=r(c.POSITION),p=A(c.intensity);break;case 2:case 3:if(!c.intensity)return i.finalize(),void a("No positions found in file");d=r(c.POSITION),p=n(c.COLOR_0,c.intensity)}const f=rv(d,15e5),g=rv(p,2e6),m=[];for(let e=0,s=f.length;e<s;e++){const s=`${t.isManifest?"model"+t.index:""}pointsMesh${e}`;m.push(s),i.createMesh({id:s,primitive:"points",positions:f[e],colorsCompressed:e<g.length?g[e]:null})}const _=t.entityId||R.createUUID();if(i.createEntity({id:_,meshIds:m,isObject:!0}),i.finalize(),t.metaModelJSON){const e=i.id;this.viewer.metaScene.createMetaModel(e,t.metaModelJSON,s)}else if(!1!==t.loadMetadata){const e=R.createUUID(),t={projectId:"",author:"",createdAt:"",schema:"",creatingApplication:"",metaObjects:[{id:e,name:"Model",type:"Model"},{id:_,name:"PointCloud (LAS)",type:"PointCloud",parent:e,attributes:l||{}}],propertySets:[]},r=i.id;this.viewer.metaScene.createMetaModel(r,t,s)}o()}))}catch(e){i.finalize(),a(e)}}))}},exports.Label3D=tB,exports.LambertMaterial=ns,exports.LightMap=class extends qr{get type(){return"LightMap"}constructor(e,t={}){super(e,t),this.scene._lightMapCreated(this)}destroy(){super.destroy(),this.scene._lightMapDestroyed(this)}},exports.LineSet=Wr,exports.LinearEncoding=3e3,exports.LinearFilter=1006,exports.LinearMipMapLinearFilter=1008,exports.LinearMipMapNearestFilter=1007,exports.LinearMipmapLinearFilter=1008,exports.LinearMipmapNearestFilter=1007,exports.Loader=ar,exports.LoadingManager=Ar,exports.LocaleService=de,exports.LuminanceAlphaFormat=1025,exports.LuminanceFormat=1024,exports.Map=e,exports.Marker=sn,exports.MarqueePicker=he,exports.MarqueePickerMouseControl=class extends ie{constructor(e){super(e.marqueePicker,e);const t=e.marqueePicker,s=t.viewer.scene.canvas.canvas;let i,r,n,A,o,a,l,c=!1,h=!1,u=!1;s.addEventListener("mousedown",(e=>{this.getActive()&&0===e.button&&(l=setTimeout((function(){const n=t.viewer.scene.input;n.keyDown[n.KEY_CTRL]||t.clear(),i=e.pageX,r=e.pageY,o=e.offsetX,t.setMarqueeCorner1([i,r]),c=!0,t.viewer.cameraControl.pointerEnabled=!1,t.setMarqueeVisible(!0),s.style.cursor="crosshair"}),400),h=!0)})),s.addEventListener("mouseup",(e=>{if(!this.getActive())return;if(!c&&!u)return;if(0!==e.button)return;clearTimeout(l),n=e.pageX,A=e.pageY;const s=Math.abs(n-i),o=Math.abs(A-r);c=!1,t.viewer.cameraControl.pointerEnabled=!0,u&&(u=!1),(s>3||o>3)&&t.pick()})),document.addEventListener("mouseup",(e=>{this.getActive()&&0===e.button&&(clearTimeout(l),c&&(t.setMarqueeVisible(!1),c=!1,h=!1,u=!0,t.viewer.cameraControl.pointerEnabled=!0))}),!0),s.addEventListener("mousemove",(e=>{this.getActive()&&0===e.button&&h&&(clearTimeout(l),c&&(n=e.pageX,A=e.pageY,a=e.offsetX,t.setMarqueeVisible(!0),t.setMarqueeCorner2([n,A]),t.setPickMode(o<a?he.PICK_MODE_INSIDE:he.PICK_MODE_INTERSECTS)))}))}setActive(e){this._active!==e&&(this._active=e,this.fire("active",this._active))}getActive(){return this._active}destroy(){}},exports.Mesh=Ot,exports.MeshSurfaceArea=Us,exports.MeshVolume=ys,exports.MetallicMaterial=as,exports.MirroredRepeatWrapping=1002,exports.ModelMemento=class{constructor(e){if(this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsOpacity=[],this.numObjects=0,e){const t=e.metaScene.scene;this.saveObjects(t,e)}}saveObjects(e,t,s){this.numObjects=0,this._mask=s?j.apply(s,{}):null;const i=!s||s.visible,r=!s||s.edges,n=!s||s.xrayed,A=!s||s.highlighted,o=!s||s.selected,a=!s||s.clippable,l=!s||s.pickable,c=!s||s.colorize,h=!s||s.opacity,u=t.metaObjects,d=e.objects;for(let e=0,t=u.length;e<t;e++){const t=d[u[e].id];if(t){if(i&&(this.objectsVisible[e]=t.visible),r&&(this.objectsEdges[e]=t.edges),n&&(this.objectsXrayed[e]=t.xrayed),A&&(this.objectsHighlighted[e]=t.highlighted),o&&(this.objectsSelected[e]=t.selected),a&&(this.objectsClippable[e]=t.clippable),l&&(this.objectsPickable[e]=t.pickable),c){const s=t.colorize;this.objectsColorize[3*e+0]=s[0],this.objectsColorize[3*e+1]=s[1],this.objectsColorize[3*e+2]=s[2]}h&&(this.objectsOpacity[e]=t.opacity),this.numObjects++}}}restoreObjects(e,t){const s=this._mask,i=!s||s.visible,r=!s||s.edges,n=!s||s.xrayed,A=!s||s.highlighted,o=!s||s.selected,a=!s||s.clippable,l=!s||s.pickable,c=!s||s.colorize,h=!s||s.opacity,u=t.metaObjects,d=e.objects;for(let e=0,t=u.length;e<t;e++){const t=d[u[e].id];t&&(i&&(t.visible=this.objectsVisible[e]),r&&(t.edges=this.objectsEdges[e]),n&&(t.xrayed=this.objectsXrayed[e]),A&&(t.highlighted=this.objectsHighlighted[e]),o&&(t.selected=this.objectsSelected[e]),a&&(t.clippable=this.objectsClippable[e]),l&&(t.pickable=this.objectsPickable[e]),c&&(nn[0]=this.objectsColorize[3*e+0],nn[1]=this.objectsColorize[3*e+1],nn[2]=this.objectsColorize[3*e+2],t.colorize=nn),h&&(t.opacity=this.objectsOpacity[e]))}}},exports.NavCubePlugin=class extends mn{constructor(e,t={}){super("NavCube",e,t),e.navCube=this;try{this._navCubeScene=new gA(e,{canvasId:t.canvasId,canvasElement:t.canvasElement,transparent:!0}),this._navCubeCanvas=this._navCubeScene.canvas.canvas,this._navCubeScene.input.keyboardEnabled=!1}catch(e){return void this.error(e)}const s=this._navCubeScene;s.clearLights(),new Zr(s,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Zr(s,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Zr(s,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._navCubeCamera=s.camera,this._navCubeCamera.ortho.scale=7,this._navCubeCamera.ortho.near=.1,this._navCubeCamera.ortho.far=2e3,s.edgeMaterial.edgeColor=[.2,.2,.2],s.edgeMaterial.edgeAlpha=.6,this._zUp=Boolean(e.camera.zUp);var i=this;this.setIsProjectNorth(t.isProjectNorth),this.setProjectNorthOffsetAngle(t.projectNorthOffsetAngle);const r=function(){const e=R.mat4();return function(t,s,r){return R.identityMat4(e),R.rotationMat4v(t*i._projectNorthOffsetAngle*R.DEGTORAD,[0,1,0],e),R.transformVec3(e,s,r)}}();this._synchCamera=function(){var t=R.rotationMat4c(-90*R.DEGTORAD,1,0,0),s=R.vec3(),n=R.vec3(),A=R.vec3();return function(){var o=e.camera.eye,a=e.camera.look,l=e.camera.up;s=R.mulVec3Scalar(R.normalizeVec3(R.subVec3(o,a,s)),5),i._isProjectNorth&&i._projectNorthOffsetAngle&&(s=r(-1,s,KB),l=r(-1,l,ZB)),i._zUp?(R.transformVec3(t,s,n),R.transformVec3(t,l,A),i._navCubeCamera.look=[0,0,0],i._navCubeCamera.eye=R.transformVec3(t,s,n),i._navCubeCamera.up=R.transformPoint3(t,l,A)):(i._navCubeCamera.look=[0,0,0],i._navCubeCamera.eye=s,i._navCubeCamera.up=l)}}(),this._cubeTextureCanvas=new XB(e,s,t),this._cubeSampler=new es(s,{image:this._cubeTextureCanvas.getImage(),flipY:!0,wrapS:1001,wrapT:1001}),this._cubeMesh=new Ot(s,{geometry:new Le(s,{primitive:"triangles",normals:[0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1],positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),material:new jt(s,{diffuse:[.4,.4,.4],specular:[.4,.4,.4],emissive:[.6,.6,.6],diffuseMap:this._cubeSampler,emissiveMap:this._cubeSampler}),visible:!0,edges:!0}),this._shadow=!1===t.shadowVisible?null:new Ot(s,{geometry:new Le(s,Xe({center:[0,0,0],radiusTop:.001,radiusBottom:1.4,height:.01,radialSegments:20,heightSegments:1,openEnded:!0})),material:new jt(s,{diffuse:[0,0,0],specular:[0,0,0],emissive:[0,0,0],alpha:.5}),position:[0,-1.5,0],visible:!0,pickable:!1,backfaces:!1}),this._onCameraMatrix=e.camera.on("matrix",this._synchCamera),this._onCameraWorldAxis=e.camera.on("worldAxis",(()=>{e.camera.zUp?(this._zUp=!0,this._cubeTextureCanvas.setZUp(),this._repaint(),this._synchCamera()):e.camera.yUp&&(this._zUp=!1,this._cubeTextureCanvas.setYUp(),this._repaint(),this._synchCamera())})),this._onCameraFOV=e.camera.perspective.on("fov",(e=>{this._synchProjection&&(this._navCubeCamera.perspective.fov=e)})),this._onCameraProjection=e.camera.on("projection",(e=>{this._synchProjection&&(this._navCubeCamera.projection="ortho"===e||"perspective"===e?e:"perspective")}));var n=-1;function A(t,s){var i=(t-a)*-p,r=(s-l)*-p;e.camera.orbitYaw(i),e.camera.orbitPitch(-r),a=t,l=s}function o(e){const{left:t,top:s}=i._navCubeCanvas.getBoundingClientRect();return[e.clientX-t,e.clientY-s]}var a,l,c=null,h=null,u=!1,d=!1,p=.5;i._navCubeCanvas.addEventListener("mouseenter",i._onMouseEnter=function(e){d=!0}),i._navCubeCanvas.addEventListener("mouseleave",i._onMouseLeave=function(e){d=!1}),i._navCubeCanvas.addEventListener("mousedown",i._onMouseDown=function(e){if(1===e.which){c=e.x,h=e.y,a=e.clientX,l=e.clientY;var t=o({clientX:e.clientX,clientY:e.clientY}),i=s.pick({canvasPos:t});u=!!i}}),i._navCubeCanvas.addEventListener("mouseup",i._onMouseUp=function(e){if(1===e.which&&(u=!1,null!==c)){var t=o({clientX:e.clientX,clientY:e.clientY}),A=s.pick({canvasPos:t,pickSurface:!0});if(A&&A.uv){var a=i._cubeTextureCanvas.getArea(A.uv);if(a>=0&&(i._navCubeCanvas.style.cursor="pointer",n>=0&&(i._cubeTextureCanvas.setAreaHighlighted(n,!1),i._repaint(),n=-1),a>=0)){if(i._cubeTextureCanvas.setAreaHighlighted(a,!0),n=a,i._repaint(),e.x<c-3||e.x>c+3||e.y<h-3||e.y>h+3)return;var l=i._cubeTextureCanvas.getAreaDir(a);if(l){var d=i._cubeTextureCanvas.getAreaUp(a);i._isProjectNorth&&i._projectNorthOffsetAngle&&(l=r(1,l,KB),d=r(1,d,ZB)),f(l,d,(function(){n>=0&&(i._cubeTextureCanvas.setAreaHighlighted(n,!1),i._repaint(),n=-1),i._navCubeCanvas.style.cursor="pointer",n>=0&&(i._cubeTextureCanvas.setAreaHighlighted(n,!1),i._repaint(),n=-1),a>=0&&(i._cubeTextureCanvas.setAreaHighlighted(a,!1),n=-1,i._repaint())}))}}}}}),i._navCubeCanvas.addEventListener("mousemove",i._onMouseMove=function(e){if(n>=0&&(i._cubeTextureCanvas.setAreaHighlighted(n,!1),i._repaint(),n=-1),1!==e.buttons||u){if(u){var t=e.clientX,r=e.clientY;return i._navCubeCanvas.style.cursor="move",void A(t,r)}if(d){var a=o({clientX:e.clientX,clientY:e.clientY}),l=s.pick({canvasPos:a,pickSurface:!0});if(l){if(l.uv){i._navCubeCanvas.style.cursor="pointer";var c=i._cubeTextureCanvas.getArea(l.uv);if(c===n)return;n>=0&&i._cubeTextureCanvas.setAreaHighlighted(n,!1),c>=0&&(i._cubeTextureCanvas.setAreaHighlighted(c,!0),i._repaint(),n=c)}}else i._navCubeCanvas.style.cursor="default",n>=0&&(i._cubeTextureCanvas.setAreaHighlighted(n,!1),i._repaint(),n=-1)}}}),i._navCubeCanvas.addEventListener("touchstart",i._onTouchStart=function(e){if(e.touches.length>0){c=e.touches[0].clientX,h=e.touches[0].clientY,a=e.touches[0].clientX,l=e.touches[0].clientY;var t=o({clientX:e.touches[0].clientX,clientY:e.touches[0].clientY}),i=s.pick({canvasPos:t});u=!!i}},{passive:!1}),i._navCubeCanvas.addEventListener("touchmove",i._onTouchMove=function(e){e.preventDefault();var t=e.touches[0],s=t.clientX,r=t.clientY,n=document.elementFromPoint(s,r);(d=i._navCubeCanvas===n)&&u&&A(s,r)},{passive:!1}),i._navCubeCanvas.addEventListener("touchend",i._onTouchEnd=function(e){u=!1});var f=function(){var t=R.vec3();return function(s,r,n){var A=i._fitVisible?e.scene.getAABB(e.scene.visibleObjectIds):e.scene.aabb,o=R.getAABB3Diag(A);R.getAABB3Center(A,t);var a=Math.abs(o/Math.tan(i._cameraFitFOV*R.DEGTORAD));e.cameraControl.pivotPos=t,i._cameraFly?e.cameraFlight.flyTo({look:t,eye:[t[0]-a*s[0],t[1]-a*s[1],t[2]-a*s[2]],up:r||[0,1,0],orthoScale:1.1*o,fitFOV:i._cameraFitFOV,duration:i._cameraFlyDuration},n):e.cameraFlight.jumpTo({look:t,eye:[t[0]-a*s[0],t[1]-a*s[1],t[2]-a*s[2]],up:r||[0,1,0],orthoScale:1.1*o,fitFOV:i._cameraFitFOV},n)}}();this._onUpdated=e.localeService.on("updated",(()=>{this._cubeTextureCanvas.clear(),this._repaint()})),this.setVisible(t.visible),this.setCameraFitFOV(t.cameraFitFOV),this.setCameraFly(t.cameraFly),this.setCameraFlyDuration(t.cameraFlyDuration),this.setFitVisible(t.fitVisible),this.setSynchProjection(t.synchProjection)}send(e,t){if("language"===e)this._cubeTextureCanvas.clear(),this._repaint()}_repaint(){const e=this._cubeTextureCanvas.getImage();this._cubeMesh.material.diffuseMap.image=e,this._cubeMesh.material.emissiveMap.image=e}setVisible(e=!0){this._navCubeCanvas&&(this._cubeMesh.visible=e,this._shadow&&(this._shadow.visible=e),this._navCubeCanvas.style.visibility=e?"visible":"hidden")}getVisible(){return!!this._navCubeCanvas&&this._cubeMesh.visible}setFitVisible(e=!1){this._fitVisible=e}getFitVisible(){return this._fitVisible}setCameraFly(e=!0){this._cameraFly=e}getCameraFly(){return this._cameraFly}setCameraFitFOV(e=45){this._cameraFitFOV=e}getCameraFitFOV(){return this._cameraFitFOV}setCameraFlyDuration(e=.5){this._cameraFlyDuration=e}getCameraFlyDuration(){return this._cameraFlyDuration}setSynchProjection(e=!1){this._synchProjection=e}getSynchProjection(){return this._synchProjection}setIsProjectNorth(e=!1){this._isProjectNorth=e}getIsProjectNorth(){return this._isProjectNorth}setProjectNorthOffsetAngle(e){this._projectNorthOffsetAngle=e}getProjectNorthOffsetAngle(){return this._projectNorthOffsetAngle}destroy(){this._navCubeCanvas&&(this.viewer.localeService.off(this._onUpdated),this.viewer.camera.off(this._onCameraMatrix),this.viewer.camera.off(this._onCameraWorldAxis),this.viewer.camera.perspective.off(this._onCameraFOV),this.viewer.camera.off(this._onCameraProjection),this._navCubeCanvas.removeEventListener("mouseenter",this._onMouseEnter),this._navCubeCanvas.removeEventListener("mouseleave",this._onMouseLeave),this._navCubeCanvas.removeEventListener("mousedown",this._onMouseDown),this._navCubeCanvas.removeEventListener("mousemove",this._onMouseMove),this._navCubeCanvas.removeEventListener("mouseup",this._onMouseUp),this._navCubeCanvas.removeEventListener("touchstart",this._onTouchStart),this._navCubeCanvas.removeEventListener("touchmove",this._onTouchMove),this._navCubeCanvas.removeEventListener("touchend",this._onTouchEnd),this._navCubeCanvas=null,this._cubeTextureCanvas.destroy(),this._cubeTextureCanvas=null,this._onMouseEnter=null,this._onMouseLeave=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null),this._navCubeScene.destroy(),this._navCubeScene=null,this._cubeMesh=null,this._shadow=null,super.destroy()}},exports.NearestFilter=1003,exports.NearestMipMapLinearFilter=1005,exports.NearestMipMapNearestFilter=1004,exports.NearestMipmapLinearFilter=1005,exports.NearestMipmapNearestFilter=1004,exports.Node=ct,exports.OBJLoaderPlugin=class extends mn{constructor(e,t){super("OBJLoader",e,t),this._sceneGraphLoader=new YB}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);var t=new ct(this.viewer.scene,j.apply(e,{isModel:!0}));const s=t.id,i=e.src;if(!i)return this.error("load() param expected: src"),t;if(e.metaModelSrc){const r=e.metaModelSrc;j.loadJSON(r,(r=>{this.viewer.metaScene.createMetaModel(s,r),this._sceneGraphLoader.load(t,i,e)}),(e=>{this.error(`load(): Failed to load model modelMetadata for model '${s} from '${r}' - ${e}`)}))}else this._sceneGraphLoader.load(t,i,e);return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(s)})),t}destroy(){super.destroy()}},exports.ObjectsKdTree3=class{constructor(e){if(!e)throw"Parameter expected: cfg";if(!e.viewer)throw"Parameter expected: cfg.viewer";this.viewer=e.viewer,this._maxTreeDepth=e.maxTreeDepth||15,this._root=null,this._needsRebuild=!0,this._onModelLoaded=this.viewer.scene.on("modelLoaded",(e=>{this._needsRebuild=!0})),this._onModelUnloaded=this.viewer.scene.on("modelUnloaded",(e=>{this._needsRebuild=!0}))}get root(){return this._needsRebuild&&this._rebuild(),this._root}_rebuild(){const e=this.viewer.scene;this._root={aabb:e.getAABB()};for(let t in e.objects){const s=e.objects[t];this._insertEntity(this._root,s,1)}this._needsRebuild=!1}_insertEntity(e,t,s){const i=t.aabb;if(s>=this._maxTreeDepth)return e.entities=e.entities||[],void e.entities.push(t);if(e.left&&R.containsAABB3(e.left.aabb,i))return void this._insertEntity(e.left,t,s+1);if(e.right&&R.containsAABB3(e.right.aabb,i))return void this._insertEntity(e.right,t,s+1);const r=e.aabb;O[0]=r[3]-r[0],O[1]=r[4]-r[1],O[2]=r[5]-r[2];let n=0;if(O[1]>O[n]&&(n=1),O[2]>O[n]&&(n=2),!e.left){const A=r.slice();if(A[n+3]=(r[n]+r[n+3])/2,e.left={aabb:A},R.containsAABB3(A,i))return void this._insertEntity(e.left,t,s+1)}if(!e.right){const A=r.slice();if(A[n]=(r[n]+r[n+3])/2,e.right={aabb:A},R.containsAABB3(A,i))return void this._insertEntity(e.right,t,s+1)}e.entities=e.entities||[],e.entities.push(t)}destroy(){const e=this.viewer.scene;e.off(this._onModelLoaded),e.off(this._onModelUnloaded),this._root=null,this._needsRebuild=!0}},exports.ObjectsMemento=on,exports.PNGMediaType=10002,exports.Path=class extends ge{constructor(e,t={}){super(e,t),this._cachedLengths=[],this._dirty=!0,this._curves=[],this._t=0,this._dirtySubs=[],this._destroyedSubs=[],this.curves=t.curves||[],this.t=t.t}addCurve(e){this._curves.push(e),this._dirty=!0}set curves(e){var t,s,i;for(e=e||[],s=0,i=this._curves.length;s<i;s++)(t=this._curves[s]).off(this._dirtySubs[s]),t.off(this._destroyedSubs[s]);this._curves=[],this._dirtySubs=[],this._destroyedSubs=[];var r=this;function n(){r._dirty=!0}function A(){var e=this.id;for(s=0,i=r._curves.length;s<i;s++)if(r._curves[s].id===e)return r._curves=r._curves.slice(s,s+1),r._dirtySubs=r._dirtySubs.slice(s,s+1),r._destroyedSubs=r._destroyedSubs.slice(s,s+1),void(r._dirty=!0)}for(s=0,i=e.length;s<i;s++){if(t=e[s],j.isNumeric(t)||j.isString(t)){var o=t;if(!(t=this.scene.components[o])){this.error("Component not found: "+_inQuotes(o));continue}}var a=t.type;"xeokit.SplineCurve"===a||"xeokit.Path"===a||"xeokit.CubicBezierCurve"===a||"xeokit.QuadraticBezierCurve"===a?(this._curves.push(t),this._dirtySubs.push(t.on("dirty",n)),this._destroyedSubs.push(t.once("destroyed",A))):this.error("Component "+_inQuotes(t.id)+" is not a xeokit.SplineCurve, xeokit.Path or xeokit.QuadraticBezierCurve")}this._dirty=!0}get curves(){return this._curves}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}get length(){var e=this._getCurveLengths();return e[e.length-1]}getPoint(e){for(var t,s=e*this.length,i=this._getCurveLengths(),r=0;r<i.length;){if(i[r]>=s){var n=1-(i[r]-s)/(t=this._curves[r]).length;return t.getPointAt(n)}r++}return null}_getCurveLengths(){if(!this._dirty)return this._cachedLengths;var e,t=[],s=0,i=this._curves.length;for(e=0;e<i;e++)s+=this._curves[e].length,t.push(s);return this._cachedLengths=t,this._dirty=!1,t}_getJSON(){for(var e=[],t=0,s=this._curves.length;t<s;t++)e.push(this._curves[t].id);return{curves:e,t:this._t}}destroy(){var e,t,s;for(super.destroy(),e=0,t=this._curves.length;e<t;e++)(s=this._curves[e]).off(this._dirtySubs[e]),s.off(this._destroyedSubs[e])}},exports.PerformanceModel=class extends jr{constructor(e,t={}){super(e,t)}},exports.PhongMaterial=jt,exports.PickResult=fn,exports.Plugin=mn,exports.PointLight=class extends zr{get type(){return"PointLight"}constructor(e,t={}){super(e,t);const s=this;this._shadowRenderBuf=null,this._shadowViewMatrix=null,this._shadowProjMatrix=null,this._shadowViewMatrixDirty=!0,this._shadowProjMatrixDirty=!0;const i=this.scene.camera,r=this.scene.canvas;this._onCameraViewMatrix=i.on("viewMatrix",(()=>{this._shadowViewMatrixDirty=!0})),this._onCameraProjMatrix=i.on("projMatrix",(()=>{this._shadowProjMatrixDirty=!0})),this._onCanvasBoundary=r.on("boundary",(()=>{this._shadowProjMatrixDirty=!0})),this._state=new xe({type:"point",pos:R.vec3([1,1,1]),color:R.vec3([.7,.7,.8]),intensity:1,attenuation:[0,0,0],space:t.space||"view",castsShadow:!1,getShadowViewMatrix:()=>{if(s._shadowViewMatrixDirty){s._shadowViewMatrix||(s._shadowViewMatrix=R.identityMat4());const e=s._state.pos,t=i.look,r=i.up;R.lookAtMat4v(e,t,r,s._shadowViewMatrix),s._shadowViewMatrixDirty=!1}return s._shadowViewMatrix},getShadowProjMatrix:()=>{if(s._shadowProjMatrixDirty){s._shadowProjMatrix||(s._shadowProjMatrix=R.identityMat4());const e=s.scene.canvas.canvas;R.perspectiveMat4(Math.PI/180*70,e.clientWidth/e.clientHeight,.1,500,s._shadowProjMatrix),s._shadowProjMatrixDirty=!1}return s._shadowProjMatrix},getShadowRenderBuf:()=>(s._shadowRenderBuf||(s._shadowRenderBuf=new Kr(s.scene.canvas.gl),s._shadowRenderBuf.setSize([1024,1024])),s._shadowRenderBuf)}),this.pos=t.pos,this.color=t.color,this.intensity=t.intensity,this.constantAttenuation=t.constantAttenuation,this.linearAttenuation=t.linearAttenuation,this.quadraticAttenuation=t.quadraticAttenuation,this.castsShadow=t.castsShadow,this.scene._lightCreated(this)}set pos(e){this._state.pos.set(e||[1,1,1]),this._shadowViewMatrixDirty=!0,this.glRedraw()}get pos(){return this._state.pos}set color(e){this._state.color.set(e||[.7,.7,.8]),this.glRedraw()}get color(){return this._state.color}set intensity(e){e=void 0!==e?e:1,this._state.intensity=e,this.glRedraw()}get intensity(){return this._state.intensity}set constantAttenuation(e){this._state.attenuation[0]=e||0,this.glRedraw()}get constantAttenuation(){return this._state.attenuation[0]}set linearAttenuation(e){this._state.attenuation[1]=e||0,this.glRedraw()}get linearAttenuation(){return this._state.attenuation[1]}set quadraticAttenuation(e){this._state.attenuation[2]=e||0,this.glRedraw()}get quadraticAttenuation(){return this._state.attenuation[2]}set castsShadow(e){e=!!e,this._state.castsShadow!==e&&(this._state.castsShadow=e,this._shadowViewMatrixDirty=!0,this.glRedraw())}get castsShadow(){return this._state.castsShadow}destroy(){const e=this.scene.camera,t=this.scene.canvas;e.off(this._onCameraViewMatrix),e.off(this._onCameraProjMatrix),t.off(this._onCanvasBoundary),super.destroy(),this._state.destroy(),this._shadowRenderBuf&&this._shadowRenderBuf.destroy(),this.scene._lightDestroyed(this),this.glRedraw()}},exports.PointerCircle=ue,exports.PointerLens=class{constructor(e,t={}){this.viewer=e,this.scene=this.viewer.scene,this._lensCursorDiv=document.createElement("div"),this._lensParams={canvasSize:300,cursorBorder:2,cursorSize:10},this._lensCursorDiv.style.borderRadius="50%",this._lensCursorDiv.style.width=this._lensParams.cursorSize+"px",this._lensCursorDiv.style.height=this._lensParams.cursorSize+"px",this._lensCursorDiv.style.zIndex="100000",this._lensCursorDiv.style.position="absolute",this._lensCursorDiv.style.pointerEvents="none",this._lensContainer=document.createElement("div"),this._lensContainerId=t.containerId||"xeokit-lens",this._lensContainer.setAttribute("id",this._lensContainerId),this._lensContainer.style.border="1px solid black",this._lensContainer.style.background="white",this._lensContainer.style.borderRadius="50%",this._lensContainer.style.width=this._lensParams.canvasSize+"px",this._lensContainer.style.height=this._lensParams.canvasSize+"px",this._lensContainer.style.zIndex="15000",this._lensContainer.style.position="absolute",this._lensContainer.style.pointerEvents="none",this._lensContainer.style.visibility="hidden",this._lensCanvas=document.createElement("canvas"),this._lensCanvas.id=`${this._lensContainerId}-canvas`,this._lensCanvas.style.borderRadius="50%",this._lensCanvas.style.width=this._lensParams.canvasSize+"px",this._lensCanvas.style.height=this._lensParams.canvasSize+"px",this._lensCanvas.style.zIndex="15000",this._lensCanvas.style.pointerEvents="none",document.body.appendChild(this._lensContainer),this._lensContainer.appendChild(this._lensCanvas),this._lensContainer.appendChild(this._lensCursorDiv),this._lensCanvasContext=this._lensCanvas.getContext("2d"),this._canvasElement=this.viewer.scene.canvas.canvas,this._canvasPos=null,this._snappedCanvasPos=null,this._lensPosToggle=t.lensPosToggle||!0,this._lensPosToggleAmount=t.lensPosToggleAmount||85,this._lensPosMarginLeft=t.lensPosMarginLeft||85,this._lensPosMarginTop=t.lensPosMarginTop||25,this._lensContainer.style.marginTop=`${this._lensPosMarginTop}px`,this._lensContainer.style.marginLeft=`${this._lensPosMarginLeft}px`,this._zoomLevel=t.zoomLevel||2,this._active=!1!==t.active,this._visible=!1,this.snapped=!1,this._onViewerRendering=this.viewer.scene.on("rendering",(()=>{this._active&&this._visible&&this.update()}))}update(){if(!this._active||!this._visible)return;if(!this._canvasPos)return;const e=this._lensContainer.getBoundingClientRect(),t=this._canvasElement.getBoundingClientRect(),s=this._canvasPos[0]<e.right&&this._canvasPos[0]>e.left&&this._canvasPos[1]<e.bottom&&this._canvasPos[1]>e.top;this._lensContainer.style.marginLeft=`${this._lensPosMarginLeft}px`,s&&(this._lensPosToggle?this._lensContainer.style.marginTop=t.bottom-t.top-this._lensCanvas.height-this._lensPosToggleAmount+"px":this._lensContainer.style.marginTop=`${this._lensPosMarginTop}px`,this._lensPosToggle=!this._lensPosToggle),this._lensCanvasContext.clearRect(0,0,this._lensCanvas.width,this._lensCanvas.height);const i=Math.max(this._lensCanvas.width,this._lensCanvas.height)/this._zoomLevel;this._lensCanvasContext.drawImage(this._canvasElement,this._canvasPos[0]-i/2,this._canvasPos[1]-i/2,i,i,0,0,this._lensCanvas.width,this._lensCanvas.height);const r=this._lensParams.canvasSize/2-this._lensParams.cursorSize/2-this._lensParams.cursorBorder,n=this._snappedCanvasPos?this._snappedCanvasPos[0]-this._canvasPos[0]:0,A=this._snappedCanvasPos?this._snappedCanvasPos[1]-this._canvasPos[1]:0;this._lensCursorDiv.style.left=`${r+n*this._zoomLevel}px`,this._lensCursorDiv.style.top=`${r+A*this._zoomLevel}px`}set zoomFactor(e){this._zoomFactor=e,this.update()}get zoomFactor(){return this._zoomFactor}set canvasPos(e){this._canvasPos=e,this.update()}get canvasPos(){return this._canvasPos}set snappedCanvasPos(e){this._snappedCanvasPos=e,this.update()}get snappedCanvasPos(){return this._snappedCanvasPos}set snapped(e){this._snapped=e;const[t,s]=e?["greenyellow","green"]:["pink","red"];this._lensCursorDiv.style.background=t,this._lensCursorDiv.style.border=this._lensParams.cursorBorder+"px solid "+s}get snapped(){return this._snapped}_updateActiveVisible(){this._lensContainer.style.visibility=this._active&&this._visible?"visible":"hidden",this.update()}set active(e){this._active=e,this._updateActiveVisible()}get active(){return this._active}set visible(e){this._visible=e,this._updateActiveVisible()}get visible(){return this._visible}destroy(){this._destroyed||(this.viewer.scene.off(this._onViewerRendering),this._lensContainer.removeChild(this._lensCanvas),document.body.removeChild(this._lensContainer),this._destroyed=!0)}},exports.QuadraticBezierCurve=class extends ge{constructor(e,t={}){super(e,t),this.v0=t.v0,this.v1=t.v1,this.v2=t.v2,this.t=t.t}set v0(e){this._v0=e||R.vec3([0,0,0])}get v0(){return this._v0}set v1(e){this._v1=e||R.vec3([0,0,0])}get v1(){return this._v1}set v2(e){this._v2=e||R.vec3([0,0,0])}get v2(){return this._v2}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=R.vec3();return t[0]=R.b2(e,this._v0[0],this._v1[0],this._v2[0]),t[1]=R.b2(e,this._v0[1],this._v1[1],this._v2[1]),t[2]=R.b2(e,this._v0[2],this._v1[2],this._v2[2]),t}getJSON(){return{v0:this._v0,v1:this._v1,v2:this._v2,t:this._t}}},exports.Queue=V,exports.RGBAFormat=1023,exports.RGBAIntegerFormat=1033,exports.RGBA_ASTC_10x10_Format=37819,exports.RGBA_ASTC_10x5_Format=37816,exports.RGBA_ASTC_10x6_Format=37817,exports.RGBA_ASTC_10x8_Format=37818,exports.RGBA_ASTC_12x10_Format=37820,exports.RGBA_ASTC_12x12_Format=37821,exports.RGBA_ASTC_4x4_Format=37808,exports.RGBA_ASTC_5x4_Format=37809,exports.RGBA_ASTC_5x5_Format=37810,exports.RGBA_ASTC_6x5_Format=37811,exports.RGBA_ASTC_6x6_Format=37812,exports.RGBA_ASTC_8x5_Format=37813,exports.RGBA_ASTC_8x6_Format=37814,exports.RGBA_ASTC_8x8_Format=37815,exports.RGBA_BPTC_Format=36492,exports.RGBA_ETC2_EAC_Format=37496,exports.RGBA_PVRTC_2BPPV1_Format=35843,exports.RGBA_PVRTC_4BPPV1_Format=35842,exports.RGBA_S3TC_DXT1_Format=33777,exports.RGBA_S3TC_DXT3_Format=33778,exports.RGBA_S3TC_DXT5_Format=33779,exports.RGBFormat=1022,exports.RGB_ETC1_Format=36196,exports.RGB_ETC2_Format=37492,exports.RGB_PVRTC_2BPPV1_Format=35841,exports.RGB_PVRTC_4BPPV1_Format=35840,exports.RGB_S3TC_DXT1_Format=33776,exports.RGFormat=1030,exports.RGIntegerFormat=1031,exports.ReadableGeometry=Le,exports.RedFormat=1028,exports.RedIntegerFormat=1029,exports.ReflectionMap=class extends qr{get type(){return"ReflectionMap"}constructor(e,t={}){super(e,t),this.scene._lightsState.addReflectionMap(this._state),this.scene._reflectionMapCreated(this)}destroy(){super.destroy(),this.scene._reflectionMapDestroyed(this)}},exports.RepeatWrapping=1e3,exports.STLDefaultDataSource=By,exports.STLLoaderPlugin=class extends mn{constructor(e,t={}){super("STLLoader",e,t),this._sceneGraphLoader=new wy,this.dataSource=t.dataSource}set dataSource(e){this._dataSource=e||new By}get dataSource(){return this._dataSource}load(e){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new ct(this.viewer.scene,j.apply(e,{isModel:!0})),s=e.src,i=e.stl;return s||i?(s?this._sceneGraphLoader.load(this,t,s,e):this._sceneGraphLoader.parse(this,t,i,e),t):(this.error("load() param expected: either 'src' or 'stl'"),t)}},exports.SceneModel=jr,exports.SceneModelMesh=Ds,exports.SceneModelTransform=kr,exports.SectionPlane=pn,exports.SectionPlanesPlugin=class extends mn{constructor(e,t={}){if(super("SectionPlanes",e),this._freeControls=[],this._sectionPlanes=e.scene.sectionPlanes,this._controls={},this._shownControlId=null,null!==t.overviewCanvasId&&void 0!==t.overviewCanvasId){const e=document.getElementById(t.overviewCanvasId);e?this._overview=new Ay(this,{overviewCanvas:e,visible:t.overviewVisible,onHoverEnterPlane:e=>{this._overview.setPlaneHighlighted(e,!0)},onHoverLeavePlane:e=>{this._overview.setPlaneHighlighted(e,!1)},onClickedPlane:e=>{if(this.getShownControl()===e)return void this.hideControl();this.showControl(e);const t=this.sectionPlanes[e].pos;oy.set(this.viewer.scene.aabb),R.getAABB3Center(oy,ay),oy[0]+=t[0]-ay[0],oy[1]+=t[1]-ay[1],oy[2]+=t[2]-ay[2],oy[3]+=t[0]-ay[0],oy[4]+=t[1]-ay[1],oy[5]+=t[2]-ay[2],this.viewer.cameraFlight.flyTo({aabb:oy,fitFOV:65})},onClickedNothing:()=>{this.hideControl()}}):this.warn("Can't find overview canvas: '"+t.overviewCanvasId+"' - will create plugin without overview")}this._onSceneSectionPlaneCreated=e.scene.on("sectionPlaneCreated",(e=>{this._sectionPlaneCreated(e)}))}setOverviewVisible(e){this._overview&&this._overview.setVisible(e)}getOverviewVisible(){if(this._overview)return this._overview.getVisible()}get sectionPlanes(){return this._sectionPlanes}createSectionPlane(e={}){void 0!==e.id&&null!==e.id&&this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);return new pn(this.viewer.scene,{id:e.id,pos:e.pos,dir:e.dir,active:!0})}_sectionPlaneCreated(e){const t=this._freeControls.length>0?this._freeControls.pop():(()=>{const e=this.viewer.scene,t=function(){const t=new ct(e,{isObject:!1});return t.addChild(new Ot(t,{geometry:new Le(t,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new jt(t,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,ghostMaterial:new ds(t,{edges:!1,filled:!0,fillColor:[1,1,0],edgeColor:[0,0,0],fillAlpha:.1,backfaces:!0}),pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1],isObject:!1})),t.addChild(new Ot(t,{geometry:new Le(t,Ye({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new jt(t,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),highlightMaterial:new ds(t,{edges:!1,edgeColor:[0,0,0],filled:!0,fillColor:[.8,.8,.8],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45],isObject:!1})),{setPosition:function(){const e=R.vec3(),s=R.vec3();return function(i){dt(i,e,s),t.origin=e,t.position=s}}(),setQuaternion:e=>{t.quaternion=e},setScale:e=>{t.scale=e},setVisible:e=>{t.visible=e},destroy:()=>{t.destroy()}}}();let s=()=>{};const i=new ry(this.viewer);let r=!1,n=!1,A=null;const o=()=>{const e=n&&!r;t.setVisible(e),i.setHandlers(e&&A)};return{_destroy:()=>{s(),i.destroy(),t.destroy()},setCulled:e=>{r=e,o()},setVisible:e=>{n=e,o()},_setSectionPlane:e=>{if(s(),e){let r=!1;A={onPosition:s=>{t.setPosition(s),e.pos=s},onQuaternion:s=>{t.setQuaternion(s),r=!0,e.quaternion=s},onScreenScale:e=>{t.setScale(e)}};const n=()=>{t.setPosition(e.pos),i.setPosition(e.pos)},o=()=>{t.setQuaternion(e.quaternion),i.setQuaternion(e.quaternion)};n(),o();const a=e.on("pos",n),l=e.on("dir",(()=>{r?r=!1:o()}));s=()=>{e.off(a),e.off(l),s=()=>{}}}}}})();t._setSectionPlane(e),t.setVisible(!1),this._controls[e.id]=t,this._overview&&this._overview.addSectionPlane(e),e.once("destroyed",(()=>{this._sectionPlaneDestroyed(e)}))}flipSectionPlanes(){const e=this.viewer.scene.sectionPlanes;for(let t in e){e[t].flipDir()}}showControl(e){const t=this._controls[e];t?(this.hideControl(),t.setVisible(!0),this._overview&&this._overview.setPlaneSelected(e,!0),this._shownControlId=e):this.error("Control not found: "+e)}getShownControl(){return this._shownControlId}hideControl(){for(var e in this._controls)this._controls.hasOwnProperty(e)&&(this._controls[e].setVisible(!1),this._overview&&this._overview.setPlaneSelected(e,!1));this._shownControlId=null}destroySectionPlane(e){var t=this.viewer.scene.sectionPlanes[e];t?(this._sectionPlaneDestroyed(t),t.destroy(),e===this._shownControlId&&(this._shownControlId=null)):this.error("SectionPlane not found: "+e)}_sectionPlaneDestroyed(e){this._overview&&this._overview.removeSectionPlane(e);const t=this._controls[e.id];t&&(t.setVisible(!1),t._setSectionPlane(null),delete this._controls[e.id],this._freeControls.push(t))}clear(){const e=Object.keys(this._sectionPlanes);for(var t=0,s=e.length;t<s;t++)this.destroySectionPlane(e[t])}send(e,t){switch(e){case"snapshotStarting":for(let e in this._controls)this._controls.hasOwnProperty(e)&&this._controls[e].setCulled(!0);break;case"snapshotFinished":for(let e in this._controls)this._controls.hasOwnProperty(e)&&this._controls[e].setCulled(!1);break;case"clearSectionPlanes":this.clear()}}destroy(){this.clear(),this._overview&&this._overview.destroy(),this._destroyFreeControls(),super.destroy()}_destroyFreeControls(){for(var e=this._freeControls.pop();e;)e._destroy(),e=this._freeControls.pop();this.viewer.scene.off(this._onSceneSectionPlaneCreated)}},exports.ShortType=1011,exports.SpecularMaterial=hs,exports.SplineCurve=me,exports.SpriteMarker=class extends sn{constructor(e,t={}){super(e,{entity:t.entity,occludable:t.occludable,worldPos:t.worldPos}),this._occluded=!1,this._visible=!0,this._src=null,this._image=null,this._pos=R.vec3(),this._origin=R.vec3(),this._rtcPos=R.vec3(),this._dir=R.vec3(),this._size=1,this._imageSize=R.vec2(),this._texture=new es(this,{src:t.src}),this._geometry=new Le(this,{primitive:"triangles",positions:[3,3,0,-3,3,0,-3,-3,0,3,-3,0],normals:[-1,0,0,-1,0,0,-1,0,0,-1,0,0],uv:[1,-1,0,-1,0,0,1,0],indices:[0,1,2,0,2,3]}),this._mesh=new Ot(this,{geometry:this._geometry,material:new jt(this,{ambient:[.9,.3,.9],shininess:30,diffuseMap:this._texture,backfaces:!0}),scale:[1,1,1],position:t.worldPos,rotation:[90,0,0],billboard:"spherical",occluder:!1}),this.visible=!0,this.collidable=t.collidable,this.clippable=t.clippable,this.pickable=t.pickable,this.opacity=t.opacity,this.size=t.size,t.image?this.image=t.image:this.src=t.src}_setVisible(e){this._occluded=!e,this._mesh.visible=this._visible&&!this._occluded,super._setVisible(e)}set visible(e){this._visible=null==e||e,this._mesh.visible=this._visible&&!this._occluded}get visible(){return this._visible}set image(e){this._image=e,this._image&&(this._imageSize[0]=this._image.width,this._imageSize[1]=this._image.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}get image(){return this._image}set src(e){if(this._src=e,this._src){this._image=null;const e=new Image;e.onload=()=>{this._texture.image=e,this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage()},e.src=this._src}}get src(){return this._src}set size(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}get size(){return this._size}set collidable(e){this._mesh.collidable=!1!==e}get collidable(){return this._mesh.collidable}set clippable(e){this._mesh.clippable=!1!==e}get clippable(){return this._mesh.clippable}set pickable(e){this._mesh.pickable=!1!==e}get pickable(){return this._mesh.pickable}set opacity(e){this._mesh.opacity=e}get opacity(){return this._mesh.opacity}_updatePlaneSizeFromImage(){const e=.5*this._size,t=this._imageSize[0],s=this._imageSize[1],i=s/t;this._geometry.positions=t>s?[e,e*i,0,-e,e*i,0,-e,-e*i,0,e,-e*i,0]:[e/i,e,0,-e/i,e,0,-e/i,-e,0,e/i,-e,0]}},exports.StoreyViewsPlugin=class extends mn{constructor(e,t={}){super("StoreyViews",e),this._objectsMemento=new on,this._cameraMemento=new rn,this.storeys={},this._storeysList=null,this.modelStoreys={},this._fitStoreyMaps=!!t.fitStoreyMaps,this._onModelLoaded=this.viewer.scene.on("modelLoaded",(e=>{this._registerModelStoreys(e),this.fire("storeys",this.storeys)}))}_registerModelStoreys(e){const t=this.viewer,s=t.scene,i=t.metaScene,r=i.metaModels[e],n=s.models[e];if(!r||!r.rootMetaObjects)return;const A=r.rootMetaObjects;for(let t=0,r=A.length;t<r;t++){const r=A[t].getObjectIDsInSubtreeByType(["IfcBuildingStorey"]);for(let t=0,A=r.length;t<A;t++){const A=r[t],o=i.metaObjects[A].getObjectIDsInSubtree(),a=s.getAABB(o),l=Math.random()>.5?o.length:0,c=new ly(this,n.aabb,a,e,A,l);c._onModelDestroyed=n.once("destroyed",(()=>{this._deregisterModelStoreys(e),this.fire("storeys",this.storeys)})),this.storeys[A]=c,this._storeysList=null,this.modelStoreys[e]||(this.modelStoreys[e]={}),this.modelStoreys[e][A]=c}}this._clipBoundingBoxes()}_clipBoundingBoxes(){const e=this.storeysList,t=this.viewer.metaScene,s=this.viewer.camera.worldUp,i=s[0]>s[1]&&s[0]>s[2],r=!i&&s[1]>s[0]&&s[1]>s[2];let n;!i&&!r&&s[2]>s[0]&&(s[2],s[1]),n=i?0:r?1:2;for(let s=0,i=e.length;s<i;s++){const i=t.metaObjects[e[s].storeyId].attributes.elevation;if(isNaN(i))return;const r=e[s].storeyAABB;if(r[n]=Math.max(r[1],parseFloat(i)),s>0){const i=t.metaObjects[e[s-1].storeyId].attributes.elevation;r[4]=Math.min(r[n+3],parseFloat(i))}this.storeys[e[s].storeyId].storeyAABB=r}}_deregisterModelStoreys(e){const t=this.modelStoreys[e];if(t){const s=this.viewer.scene;for(let e in t)if(t.hasOwnProperty(e)){const i=t[e],r=s.models[i.modelId];r&&r.off(i._onModelDestroyed),delete this.storeys[e],this._storeysList=null}delete this.modelStoreys[e]}}get fitStoreyMaps(){return this._fitStoreyMaps}gotoStoreyCamera(e,t={}){const s=this.storeys[e];if(!s)return this.error("IfcBuildingStorey not found with this ID: "+e),void(t.done&&t.done());const i=this.viewer,r=i.scene.camera,n=s.storeyAABB;if(n[3]<n[0]||n[4]<n[1]||n[5]<n[2])return void(t.done&&t.done());if(n[3]===n[0]&&n[4]===n[1]&&n[5]===n[2])return void(t.done&&t.done());const A=R.getAABB3Center(n),o=R.getAABB3Diag(n),a=Math.abs(o/Math.tan(45*R.DEGTORAD)),l=1.3*o,c=hy;c[0]=A[0]+r.worldUp[0]*a,c[1]=A[1]+r.worldUp[1]*a,c[2]=A[2]+r.worldUp[2]*a;const h=r.worldForward;t.done?i.cameraFlight.flyTo(j.apply(t,{eye:c,look:A,up:h,orthoScale:l}),(()=>{t.done()})):(i.cameraFlight.jumpTo(j.apply(t,{eye:c,look:A,up:h,orthoScale:l})),i.camera.ortho.scale=l)}showStoreyObjects(e,t={}){if(!this.storeys[e])return void this.error("IfcBuildingStorey not found with this ID: "+e);const s=this.viewer,i=s.scene;s.metaScene.metaObjects[e]&&(t.hideOthers&&i.setObjectsVisible(s.scene.visibleObjectIds,!1),this.withStoreyObjects(e,((e,t)=>{e&&(e.visible=!0)})))}withStoreyObjects(e,t){const s=this.viewer,i=s.scene,r=s.metaScene,n=r.metaObjects[e];if(!n)return;const A=n.getObjectIDsInSubtree();for(var o=0,a=A.length;o<a;o++){const e=A[o],s=r.metaObjects[e],n=i.objects[e];n&&t(n,s)}}createStoreyMap(e,t={}){const s=this.storeys[e];if(!s)return this.error("IfcBuildingStorey not found with this ID: "+e),"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==";const i=this.viewer,r=i.scene,n=t.format||"png",A=this._fitStoreyMaps?s.storeyAABB:s.modelAABB,o=Math.abs((A[5]-A[2])/(A[3]-A[0])),a=t.padding||0,l=!!t.captureSectionPlanes;let c,h;t.width&&t.height?(c=t.width,h=t.height):t.height?(h=t.height,c=Math.round(h/o)):t.width?(c=t.width,h=Math.round(c*o)):(c=300,h=Math.round(c*o));const u={visible:!0};this._objectsMemento.saveObjects(r,u),this._cameraMemento.saveCamera(r),this.showStoreyObjects(e,j.apply(t,{hideOthers:!0})),l&&this._toggleSectionPlanes(!1),this._arrangeStoreyMapCamera(s);const d=i.getSnapshot({width:c,height:h,format:n});return this._objectsMemento.restoreObjects(r,u),this._cameraMemento.restoreCamera(r),l&&this._toggleSectionPlanes(!0),new cy(e,d,n,c,h,a)}_toggleSectionPlanes(e){const t=this.viewer.scene.sectionPlanes;for(const s in t)t[s].active=e}_arrangeStoreyMapCamera(e){const t=this.viewer,s=t.scene.camera,i=this._fitStoreyMaps?e.storeyAABB:e.modelAABB,r=R.getAABB3Center(i),n=hy;n[0]=r[0]+.5*s.worldUp[0],n[1]=r[1]+.5*s.worldUp[1],n[2]=r[2]+.5*s.worldUp[2];const A=s.worldForward;t.cameraFlight.jumpTo({eye:n,look:r,up:A});const o=(i[3]-i[0])/2,a=(i[4]-i[1])/2,l=(i[5]-i[2])/2,c=-o,h=+o,u=-a,d=+a,p=-l,f=+l;t.camera.customProjection.matrix=R.orthoMat4c(c,h,p,f,u,d,uy),t.camera.projection="customProjection"}pickStoreyMap(e,t,s={}){const i=e.storeyId,r=this.storeys[i];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+i),null;const n=1-t[0]/e.width,A=1-t[1]/e.height,o=this._fitStoreyMaps?r.storeyAABB:r.modelAABB,a=o[0],l=o[1],c=o[2],h=o[3]-a,u=o[4]-l,d=o[5]-c,p=R.vec3([a+h*n,l+.5*u,c+d*A]),f=R.vec3([0,-1,0]),g=R.addVec3(p,f,hy),m=this.viewer.camera.worldForward,_=R.lookAtMat4v(p,g,m,uy);return this.viewer.scene.pick({pickSurface:s.pickSurface,pickInvisible:!0,matrix:_})}storeyMapToWorldPos(e,t,s={}){const i=e.storeyId,r=this.storeys[i];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+i),null;const n=1-t[0]/e.width,A=1-t[1]/e.height,o=this._fitStoreyMaps?r.storeyAABB:r.modelAABB,a=o[0],l=o[1],c=o[2],h=o[3]-a,u=o[4]-l,d=o[5]-c;return R.vec3([a+h*n,l+.5*u,c+d*A])}getStoreyContainingWorldPos(e,t=null){const s=t?this._filterStoreys(t):this.storeys;for(let t in s){const i=s[t];if(R.point3AABB3AbsoluteIntersect(i.storeyAABB,e))return t}return null}getStoreyInVerticalRange(e,t=null){const s=t?this._filterStoreys(t):this.storeys;for(let t in s){const i=s[t],r=[0,0,0,0,0,0],n=[0,0,0];if(r[1]=i.storeyAABB[1],r[4]=i.storeyAABB[4],n[1]=e[1],R.point3AABB3AbsoluteIntersect(r,n))return t}return null}isPositionAboveOrBelowBuilding(e,t=null){const s=t?this._filterStoreys(t):this.storeys,i=Object.keys(s);if(i.length<=0)return null;const r=[i[0],i[i.length-1]];return e[1]<s[r[0]].storeyAABB[1]?r[0]:e[1]>s[r[1]].storeyAABB[4]?r[1]:null}worldPosToStoreyMap(e,t,s){const i=e.storeyId,r=this.storeys[i];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+i),!1;const n=this._fitStoreyMaps?r.storeyAABB:r.modelAABB,A=n[0],o=n[1],a=n[2],l=n[3]-A,c=n[4]-o,h=n[5]-a,u=this.viewer.camera.worldUp,d=u[0]>u[1]&&u[0]>u[2],p=!d&&u[1]>u[0]&&u[1]>u[2];!d&&!p&&u[2]>u[0]&&(u[2],u[1]);const f=e.width/l,g=p?e.height/h:e.height/c;return s[0]=Math.floor(e.width-(t[0]-A)*f),s[1]=Math.floor(e.height-(t[2]-a)*g),s[0]>=0&&s[0]<e.width&&s[1]>=0&&s[1]<=e.height}worldDirToStoreyMap(e,t,s){const i=this.viewer.camera,r=i.eye,n=i.look,A=R.subVec3(n,r,hy),o=i.worldUp,a=o[0]>o[1]&&o[0]>o[2],l=!a&&o[1]>o[0]&&o[1]>o[2];!a&&!l&&o[2]>o[0]&&(o[2],o[1]),a?(s[0]=A[1],s[1]=A[2]):l?(s[0]=A[0],s[1]=A[2]):(s[0]=A[0],s[1]=A[1]),R.normalizeVec2(s)}destroy(){this.viewer.scene.off(this._onModelLoaded),super.destroy()}get storeysList(){return this._storeysList||(this._storeysList=Object.values(this.storeys),this._storeysList.sort(this._getSpatialSortFunc())),this._storeysList}_getSpatialSortFunc(){const e=this.viewer.scene.camera;return this._spatialSortFunc||(this._spatialSortFunc=(t,s)=>{let i=0;i=e.xUp?0:e.yUp?1:2;const r=this.viewer.metaScene,n=r.metaObjects[t.storeyId],A=r.metaObjects[s.storeyId];if(n&&n.attributes&&void 0!==n.attributes.elevation&&A&&A.attributes&&void 0!==A.attributes.elevation){const e=Number.parseFloat(n.attributes.elevation),t=Number.parseFloat(A.attributes.elevation);return e>t?-1:e<t?1:0}return t.aabb[i]>s.aabb[i]?-1:t.aabb[i]<s.aabb[i]?1:0})}_filterStoreys(e){return Object.fromEntries(Object.entries(this.storeys).filter((([t,s])=>s.modelId===e)))}},exports.Texture=es,exports.TextureTranscoder=class{transcode(e,t,s={}){}destroy(){}},exports.TransformControl=ry,exports.TreeViewPlugin=class extends mn{constructor(e,t={}){super("TreeViewPlugin",e),this.errors=[],this.valid=!0;const s=t.containerElement||document.getElementById(t.containerElementId);if(s instanceof HTMLElement){for(let e=0;;e++)if(!Iy[e]){Iy[e]=this,this._index=e,this._id=`tree-${e}`;break}if(this._containerElement=s,this._metaModels={},this._autoAddModels=!1!==t.autoAddModels,this._autoExpandDepth=t.autoExpandDepth||0,this._sortNodes=!1!==t.sortNodes,this._viewer=e,this._rootElement=null,this._muteSceneEvents=!1,this._muteTreeEvents=!1,this._rootNodes=[],this._objectNodes={},this._nodeNodes={},this._rootNames={},this._sortNodes=t.sortNodes,this._pruneEmptyNodes=t.pruneEmptyNodes,this._showListItemElementId=null,this._renderService=t.renderService||new Uy(this._containerElement),this._showIndeterminate=t.showIndeterminate??!1,this._showProjectNode=t.showProjectNode??!1,this._elevationSortFunction=t.elevationSortFunction??void 0,this._defaultSortFunction=t.defaultSortFunction??void 0,!this._renderService)throw new Error("TreeViewPlugin: no render service set");if(this._containerElement.oncontextmenu=e=>{e.preventDefault()},this._onObjectVisibility=this._viewer.scene.on("objectVisibility",(e=>{if(this._muteSceneEvents)return;const t=e.id,s=this._objectNodes[t];if(!s)return;const i=e.visible;if(!(i!==s.checked))return;this._muteTreeEvents=!0,s.checked=i,i?s.numVisibleEntities++:s.numVisibleEntities--,this._renderService.setCheckbox(s.nodeId,i);let r=s.parent;for(;r;){r.checked=i,i?r.numVisibleEntities++:r.numVisibleEntities--;const e=this._showIndeterminate&&r.numVisibleEntities>0&&r.numVisibleEntities<r.numEntities;r.checked=r.numVisibleEntities>0,this._renderService.setCheckbox(r.nodeId,r.checked,e),r=r.parent}this._muteTreeEvents=!1})),this._onObjectXrayed=this._viewer.scene.on("objectXRayed",(e=>{if(this._muteSceneEvents)return;const t=e.id,s=this._objectNodes[t];if(!s)return;this._muteTreeEvents=!0;const i=e.xrayed;i!==s.xrayed&&(s.xrayed=i,this._renderService.setXRayed(s.nodeId,i),this._muteTreeEvents=!1)})),this._switchExpandHandler=e=>{e.preventDefault(),e.stopPropagation();const t=e.target;this._expandSwitchElement(t)},this._switchCollapseHandler=e=>{e.preventDefault(),e.stopPropagation();const t=e.target;this._collapseSwitchElement(t)},this._checkboxChangeHandler=e=>{if(this._muteTreeEvents)return;this._muteSceneEvents=!0;const t=e.target,s=this._renderService.isChecked(t),i=this._renderService.getIdFromCheckbox(t),r=this._nodeNodes[i],n=this._viewer.scene.objects;let A=0;this._withNodeTree(r,(e=>{const t=e.objectId,i=n[t],r=0===e.children.length;e.numVisibleEntities=s?e.numEntities:0,r&&s!==e.checked&&A++,e.checked=s,this._renderService.setCheckbox(e.nodeId,s),i&&(i.visible=s)}));let o=r.parent;for(;o;){s?o.numVisibleEntities+=A:o.numVisibleEntities-=A;const e=this._showIndeterminate&&o.numVisibleEntities>0&&o.numVisibleEntities<o.numEntities;o.checked=o.numVisibleEntities>0,this._renderService.setCheckbox(o.nodeId,o.checked,e),o=o.parent}this._muteSceneEvents=!1},this._hierarchy=t.hierarchy||"containment",this._autoExpandDepth=t.autoExpandDepth||0,this._autoAddModels){const e=Object.keys(this.viewer.metaScene.metaModels);for(let t=0,s=e.length;t<s;t++){const s=e[t];this.viewer.metaScene.metaModels[s].finalized&&this.addModel(s)}this.viewer.scene.on("modelLoaded",(e=>{this.viewer.metaScene.metaModels[e]&&this.addModel(e)}))}this.hierarchy=t.hierarchy}else this.error("Mandatory config expected: valid containerElementId or containerElement")}set hierarchy(e){"containment"!==(e=e||"containment")&&"storeys"!==e&&"types"!==e&&(this.error("Unsupported value for `hierarchy' - defaulting to 'containment'"),e="containment"),this._hierarchy!==e&&(this._hierarchy=e,this._createNodes())}get hierarchy(){return this._hierarchy}addModel(e,t={}){if(!this._containerElement)return;const s=this.viewer.scene.models[e];if(!s)throw"Model not found: "+e;const i=this.viewer.metaScene.metaModels[e];i?this._metaModels[e]?this.warn("Model already added: "+e):(this._metaModels[e]=i,t&&t.rootName&&(this._rootNames[e]=t.rootName),s.on("destroyed",(()=>{this.removeModel(s.id)})),this._createNodes()):this.error("MetaModel not found: "+e)}removeModel(e){if(!this._containerElement)return;this._metaModels[e]&&(this._rootNames[e]&&delete this._rootNames[e],delete this._metaModels[e],this._createNodes())}showNode(e){this.unShowNode();const t=this._objectNodes[e];if(!t)return;this.collapse();const s=t.nodeId,i=this._renderService.getSwitchElement(s);if(i)return this._expandSwitchElement(i),i.scrollIntoView(),!0;const r=[];r.unshift(t);let n=t.parent;for(;n;)r.unshift(n),n=n.parent;for(let e=0,t=r.length;e<t;e++){const t=this._renderService.getSwitchElement(r[e].nodeId);t&&this._expandSwitchElement(t)}this._renderService.setHighlighted(s,!0),this._showListItemElementId=s}unShowNode(){this._showListItemElementId&&(this._renderService.setHighlighted(this._showListItemElementId,!1),this._showListItemElementId=null)}expandToDepth(e){this.collapse();const t=(s,i)=>{if(i===e)return;const r=this._renderService.getSwitchElement(s.nodeId);if(r){this._expandSwitchElement(r);const e=s.children;for(var n=0,A=e.length;n<A;n++){const s=e[n];t(s,i+1)}}};for(let e=0,s=this._rootNodes.length;e<s;e++){const s=this._rootNodes[e];t(s,0)}}collapse(){for(let e=0,t=this._rootNodes.length;e<t;e++){const t=this._rootNodes[e].nodeId;this._collapseNode(t)}}withNodeTree(e,t){t(e);const s=e.children;if(s)for(let e=0,i=s.length;e<i;e++)this.withNodeTree(s[e],t)}destroy(){this._containerElement&&(this._metaModels={},this._rootElement&&!this._destroyed&&(this._rootElement.parentNode.removeChild(this._rootElement),this._viewer.scene.off(this._onObjectVisibility),this._destroyed=!0),delete Iy[this._index],super.destroy())}_createNodes(){this._rootElement&&(this._rootElement.parentNode.removeChild(this._rootElement),this._rootElement=null),this._rootNodes=[],this._objectNodes={},this._nodeNodes={},this._validate(),this.valid||"storeys"!==this._hierarchy?this._createEnabledNodes():this._createDisabledNodes()}_validate(){if(this.errors=[],"storeys"===this._hierarchy)this.valid=this._validateMetaModelForStoreysHierarchy();else this.valid=this._rootNodes.length>0;return this.valid}_validateMetaModelForStoreysHierarchy(e=0,t,s){return!0}_createEnabledNodes(){switch(this._pruneEmptyNodes&&this._findEmptyNodes(),this._hierarchy){case"storeys":this._createStoreysNodes(),0===this._rootNodes.length&&this.error("Failed to build storeys hierarchy");break;case"types":this._createTypesNodes();break;default:this._createContainmentNodes()}this._sortNodes&&this._doSortNodes(),this._synchNodesToEntities(),this._createTrees(),this.expandToDepth(this._autoExpandDepth)}_createDisabledNodes(){const e=this._renderService.createRootNode();this._rootElement=e,this._containerElement.appendChild(e);const t=this._viewer.metaScene.rootMetaObjects;for(let s in t){const i=t[s],r=i.type,n=i.name,A=n&&""!==n&&"Undefined"!==n&&"Default"!==n?n:r,o=this._renderService.createDisabledNodeElement(A);e.appendChild(o)}}_findEmptyNodes(){const e=this._viewer.metaScene.rootMetaObjects;for(let t in e)this._findEmptyNodes2(e[t])}_findEmptyNodes2(e,t=0){const s=this.viewer.scene,i=e.children,r=e.id,n=s.objects[r];if(e._countEntities=0,n&&e._countEntities++,i)for(let t=0,s=i.length;t<s;t++){const s=i[t];s._countEntities=this._findEmptyNodes2(s),e._countEntities+=s._countEntities}return e._countEntities}_createStoreysNodes(){const e=this._viewer.metaScene.rootMetaObjects;for(let t in e)this._createStoreysNodes2(e[t],null,null,null,null)}_createStoreysNodes2(e,t,s,i,r){if(this._pruneEmptyNodes&&0===e._countEntities)return;const n=e.type,A=e.name,o=e.children,a=e.id;if(this._showProjectNode&&"IfcProject"===n)t={nodeId:`${this._id}-${a}`,objectId:a,title:0===e.metaModels.length?A:this._rootNames[e.metaModels[0].id]||(A&&""!==A&&"Undefined"!==A&&"Default"!==A?A:n),type:n,parent:null,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]},this._rootNodes.push(t),this._objectNodes[t.objectId]=t,this._nodeNodes[t.nodeId]=t;else if("IfcBuilding"===n)s={nodeId:`${this._id}-${a}`,objectId:a,title:0===e.metaModels.length?A:this._rootNames[e.metaModels[0].id]||(A&&""!==A&&"Undefined"!==A&&"Default"!==A?A:n),type:n,parent:t,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]},t?t.children.push(s):this._rootNodes.push(s),this._objectNodes[s.objectId]=s,this._nodeNodes[s.nodeId]=s;else if("IfcBuildingStorey"===n){if(!s)return void this.error("Failed to build storeys hierarchy for model - model does not have an IfcBuilding object, or is not an IFC model");i={nodeId:`${this._id}-${a}`,objectId:a,title:A&&""!==A&&"Undefined"!==A&&"Default"!==A?A:n,type:n,parent:s,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]},s.children.push(i),this._objectNodes[i.objectId]=i,this._nodeNodes[i.nodeId]=i,r={}}else if(i){if(this._viewer.scene.objects[a]){let e=(r=r||{})[n];e||(e={nodeId:`${this._id}-${i.objectId}-${n}`,objectId:`${i.objectId}-${n}`,title:n,type:n,parent:i,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]},i.children.push(e),this._objectNodes[e.objectId]=e,this._nodeNodes[e.nodeId]=e,r[n]=e);const t={nodeId:`${this._id}-${a}`,objectId:a,title:A&&""!==A&&"Undefined"!==A&&"Default"!==A?A:n,type:n,parent:e,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]};e.children.push(t),this._objectNodes[t.objectId]=t,this._nodeNodes[t.nodeId]=t}}if(o)for(let e=0,n=o.length;e<n;e++){const n=o[e];this._createStoreysNodes2(n,t,s,i,r)}}_createTypesNodes(){const e=this._viewer.metaScene.rootMetaObjects;for(let t in e)this._createTypesNodes2(e[t],null,null)}_createTypesNodes2(e,t,s){if(this._pruneEmptyNodes&&0===e._countEntities)return;const i=e.type,r=e.name,n=e.children,A=e.id;if(e.parent){if(t){if(this._viewer.scene.objects[A]){let e=s[i];e||(e={nodeId:`${this._id}-${t.objectId}-${i}`,objectId:`${t.objectId}-${i}`,title:i,type:i,parent:t,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]},t.children.push(e),this._objectNodes[e.objectId]=e,this._nodeNodes[e.nodeId]=e,s[i]=e);const n={nodeId:`${this._id}-${A}`,objectId:A,title:r&&""!==r&&"Default"!==r?r:i,type:i,parent:e,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]};e.children.push(n),this._objectNodes[n.objectId]=n,this._nodeNodes[n.nodeId]=n}}}else t={nodeId:`${this._id}-${A}`,objectId:A,title:0===e.metaModels.length?r:this._rootNames[e.metaModels[0].id]||(r&&""!==r&&"Undefined"!==r&&"Default"!==r?r:i),type:i,parent:null,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]},this._rootNodes.push(t),this._objectNodes[t.objectId]=t,this._nodeNodes[t.nodeId]=t,s={};if(n)for(let e=0,i=n.length;e<i;e++){const i=n[e];this._createTypesNodes2(i,t,s)}}_createContainmentNodes(){const e=this._viewer.metaScene.rootMetaObjects;for(let t in e)this._createContainmentNodes2(e[t],null)}_createContainmentNodes2(e,t){if(this._pruneEmptyNodes&&0===e._countEntities)return;const s=e.type,i=e.name||s,r=e.children,n=e.id,A={nodeId:`${this._id}-${n}`,objectId:n,title:t?i&&""!==i&&"Undefined"!==i&&"Default"!==i?i:s:0===e.metaModels.length?i:this._rootNames[e.metaModels[0].id]||i,type:s,parent:t,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]};if(t?t.children.push(A):this._rootNodes.push(A),this._objectNodes[A.objectId]=A,this._nodeNodes[A.nodeId]=A,r)for(let e=0,t=r.length;e<t;e++){const t=r[e];this._createContainmentNodes2(t,A)}}_doSortNodes(){for(let e=0,t=this._rootNodes.length;e<t;e++){const t=this._rootNodes[e];this._sortChildren(t)}}_sortChildren(e){const t=e.children;if(!t||0===t.length)return;const s=t[0];"storeys"!==this._hierarchy&&"containment"!==this._hierarchy||"IfcBuildingStorey"!==s.type?this._defaultSortFunction?t.sort(this._defaultSortFunction):t.sort(this._alphaSortFunc):this._elevationSortFunction?t.sort(this._elevationSortFunction):t.sort(this._getSpatialSortFunc());for(let e=0,s=t.length;e<s;e++){const s=t[e];this._sortChildren(s)}}_getSpatialSortFunc(){const e=this.viewer.scene.camera;return this._spatialSortFunc||(this._spatialSortFunc=(t,s)=>{e.xUp||e.yUp;const i=this.viewer.metaScene,r=i.metaObjects[t.objectId],n=i.metaObjects[s.objectId];if(r&&r.attributes&&void 0!==r.attributes.elevation&&n&&n.attributes&&void 0!==n.attributes.elevation){const e=Number.parseFloat(r.attributes.elevation),t=Number.parseFloat(n.attributes.elevation);return e>t?-1:e<t?1:0}return 0})}_alphaSortFunc(e,t){const s=e.title.toUpperCase(),i=t.title.toUpperCase();return s<i?-1:s>i?1:0}_synchNodesToEntities(){const e=Object.keys(this.viewer.metaScene.metaObjects),t=this._viewer.metaScene.metaObjects,s=this._viewer.scene.objects;for(let i=0,r=e.length;i<r;i++){const r=e[i];if(t[r]){const e=this._objectNodes[r];if(e){const t=s[r];if(t){const s=t.visible;e.numEntities=1,e.xrayed=t.xrayed,s?(e.numVisibleEntities=1,e.checked=!0):(e.numVisibleEntities=0,e.checked=!1);let i=e.parent;for(;i;)i.numEntities++,s&&(i.numVisibleEntities++,i.checked=!0),i=i.parent}}}}}_withNodeTree(e,t){t(e);const s=e.children;if(s)for(let e=0,i=s.length;e<i;e++)this._withNodeTree(s[e],t)}_createTrees(){if(0===this._rootNodes.length)return;const e=this._rootNodes.map((e=>this._createNodeElement(e))),t=this._renderService.createRootNode();e.forEach((e=>{t.appendChild(e)})),this._containerElement.appendChild(t),this._rootElement=t}_createNodeElement(e){return this._renderService.createNodeElement(e,this._switchExpandHandler,this._checkboxChangeHandler,(t=>{this.fire("contextmenu",{event:t,viewer:this._viewer,treeViewPlugin:this,treeViewNode:e}),t.preventDefault()}),(t=>{this.fire("nodeTitleClicked",{event:t,viewer:this._viewer,treeViewPlugin:this,treeViewNode:e}),t.preventDefault()}))}_expandSwitchElement(e){if(this._renderService.isExpanded(e))return;const t=this._renderService.getId(e),s=this._nodeNodes[t].children.map((e=>this._createNodeElement(e)));this._renderService.addChildren(e,s),this._renderService.expand(e,this._switchExpandHandler,this._switchCollapseHandler)}_collapseNode(e){const t=this._renderService.getSwitchElement(e);this._collapseSwitchElement(t)}_collapseSwitchElement(e){this._renderService.collapse(e,this._switchExpandHandler,this._switchCollapseHandler)}},exports.UnsignedByteType=1009,exports.UnsignedInt248Type=1020,exports.UnsignedIntType=1014,exports.UnsignedShort4444Type=1017,exports.UnsignedShort5551Type=1018,exports.UnsignedShortType=1012,exports.VBOGeometry=Ge,exports.ViewCullPlugin=class extends mn{constructor(e,t={}){super("ViewCull",e),this._objectCullStates=function(e){const t=e.id;let s=Py[t];return s||(s=new Ty(e),Py[t]=s,e.on("destroyed",(()=>{delete Py[t],s._destroy()}))),s}(e.scene),this._maxTreeDepth=t.maxTreeDepth||8,this._modelInfos={},this._frustum=new ae,this._kdRoot=null,this._frustumDirty=!1,this._kdTreeDirty=!1,this._onViewMatrix=e.scene.camera.on("viewMatrix",(()=>{this._frustumDirty=!0})),this._onProjMatrix=e.scene.camera.on("projMatMatrix",(()=>{this._frustumDirty=!0})),this._onModelLoaded=e.scene.on("modelLoaded",(e=>{const t=this.viewer.scene.models[e];t&&this._addModel(t)})),this._onSceneTick=e.scene.on("tick",(()=>{this._doCull()}))}set enabled(e){this._enabled=e}get enabled(){return this._enabled}_addModel(e){const t={model:e,onDestroyed:e.on("destroyed",(()=>{this._removeModel(e)}))};this._modelInfos[e.id]=t,this._kdTreeDirty=!0}_removeModel(e){const t=this._modelInfos[e.id];t&&(t.model.off(t.onDestroyed),delete this._modelInfos[e.id],this._kdTreeDirty=!0)}_doCull(){const e=this._frustumDirty||this._kdTreeDirty;if(this._frustumDirty&&this._buildFrustum(),this._kdTreeDirty&&this._buildKDTree(),e){const e=this._kdRoot;e&&this._visitKDNode(e)}}_buildFrustum(){const e=this.viewer.scene.camera;le(this._frustum,e.viewMatrix,e.projMatrix),this._frustumDirty=!1}_buildKDTree(){const e=this.viewer.scene;this._kdRoot,this._kdRoot={aabb:e.getAABB(),intersection:ae.INTERSECT};for(let e=0,t=this._objectCullStates.numObjects;e<t;e++){const t=this._objectCullStates.objects[e];this._insertEntityIntoKDTree(this._kdRoot,t,e,1)}this._kdTreeDirty=!1}_insertEntityIntoKDTree(e,t,s,i){const r=t.aabb;if(i>=this._maxTreeDepth)return e.objects=e.objects||[],e.objects.push(s),void R.expandAABB3(e.aabb,r);if(e.left&&R.containsAABB3(e.left.aabb,r))return void this._insertEntityIntoKDTree(e.left,t,s,i+1);if(e.right&&R.containsAABB3(e.right.aabb,r))return void this._insertEntityIntoKDTree(e.right,t,s,i+1);const n=e.aabb;Sy[0]=n[3]-n[0],Sy[1]=n[4]-n[1],Sy[2]=n[5]-n[2];let A=0;if(Sy[1]>Sy[A]&&(A=1),Sy[2]>Sy[A]&&(A=2),!e.left){const o=n.slice();if(o[A+3]=(n[A]+n[A+3])/2,e.left={aabb:o,intersection:ae.INTERSECT},R.containsAABB3(o,r))return void this._insertEntityIntoKDTree(e.left,t,s,i+1)}if(!e.right){const o=n.slice();if(o[A]=(n[A]+n[A+3])/2,e.right={aabb:o,intersection:ae.INTERSECT},R.containsAABB3(o,r))return void this._insertEntityIntoKDTree(e.right,t,s,i+1)}e.objects=e.objects||[],e.objects.push(s),R.expandAABB3(e.aabb,r)}_visitKDNode(e,t=ae.INTERSECT){if(t!==ae.INTERSECT&&e.intersects===t)return;t===ae.INTERSECT&&(t=ce(this._frustum,e.aabb),e.intersects=t);const s=t===ae.OUTSIDE,i=e.objects;if(i&&i.length>0)for(let e=0,t=i.length;e<t;e++){const t=i[e];this._objectCullStates.setObjectViewCulled(t,s)}e.left&&this._visitKDNode(e.left,t),e.right&&this._visitKDNode(e.right,t)}send(e,t){}destroy(){super.destroy(),this._clear();const e=this.viewer.scene,t=e.camera;e.off(this._onModelLoaded),e.off(this._onSceneTick),t.off(this._onViewMatrix),t.off(this._onProjMatrix)}_clear(){for(let e in this._modelInfos){const t=this._modelInfos[e];t.model.off(t.onDestroyed)}this._modelInfos={},this._kdRoot=null,this._kdTreeDirty=!0}},exports.Viewer=class{constructor(e){this.language="en",this.localeService=e.localeService||new de,this.scene=new gA(this,{canvasId:e.canvasId,canvasElement:e.canvasElement,keyboardEventsElement:e.keyboardEventsElement,contextAttr:{preserveDrawingBuffer:!1!==e.preserveDrawingBuffer,premultipliedAlpha:!!e.premultipliedAlpha,antialias:!1!==e.antialias},spinnerElementId:e.spinnerElementId,transparent:!1!==e.transparent,gammaInput:!0,gammaOutput:!1,backgroundColor:e.backgroundColor,backgroundColorFromAmbientLight:e.backgroundColorFromAmbientLight,ticksPerRender:1,ticksPerOcclusionTest:20,units:e.units,scale:e.scale,origin:e.origin,saoEnabled:e.saoEnabled,alphaDepthMask:!1!==e.alphaDepthMask,entityOffsetsEnabled:!!e.entityOffsetsEnabled,readableGeometryEnabled:!!e.readableGeometryEnabled,logarithmicDepthBufferEnabled:!!e.logarithmicDepthBufferEnabled,pbrEnabled:!!e.pbrEnabled,colorTextureEnabled:!1!==e.colorTextureEnabled,dtxEnabled:!!e.dtxEnabled,markerZOffset:e.markerZOffset,numCachedSectionPlanes:e.numCachedSectionPlanes}),this.metaScene=new Ao(this,this.scene),this.id=e.id||this.scene.id,this.camera=this.scene.camera,this.cameraFlight=new Ce(this.scene,{duration:.5}),this.cameraControl=new to(this.scene,{doublePickFlyTo:!0}),this._plugins=[],this._eventSubs={}}get capabilities(){return this.scene.capabilities}on(e,t){let s=this._eventSubs[e];s||(s=[],this._eventSubs[e]=s),s.push(t)}fire(e,t){const s=this._eventSubs[e];if(s)for(let e=0,i=s.length;e<i;e++)s[e](t)}off(e){}log(e){console.log(`[xeokit viewer ${this.id}]: ${e}`)}error(e){console.error(`[xeokit viewer ${this.id}]: ${e}`)}addPlugin(e){this._plugins.push(e)}removePlugin(e){for(let t=0,s=this._plugins.length;t<s;t++){const s=this._plugins[t];if(s===e)return s.clear&&s.clear(),void this._plugins.splice(t,1)}}sendToPlugins(e,t){for(let s=0,i=this._plugins.length;s<i;s++){const i=this._plugins[s];i.send&&i.send(e,t)}}clear(){throw'Viewer#clear() no longer implemented - use \'#sendToPlugins("clear") instead'}resetView(){throw"Viewer#resetView() no longer implemented - use CameraMemento & ObjectsMemento classes instead"}beginSnapshot(){this._snapshotBegun||(this.scene._renderer.snapshot.beginSnapshot(),this._snapshotBegun=!0)}_renderSnapshotToCanvas(e){const t=void 0!==e.width&&void 0!==e.height,s=this.scene.canvas.canvas,i=s.clientWidth,r=s.clientHeight,n=!e.includeGizmos;t&&(s.width=e.width?Math.floor(e.width):s.width,s.height=e.height?Math.floor(e.height):s.height),this.beginSnapshot(),n&&this.sendToPlugins("snapshotStarting");const A=this.scene._renderer.snapshot.renderSnapshotToCanvas();return t&&(s.width=i,s.height=r,this.scene.glRedraw()),{canvas:A,toDataURL:()=>{n&&this.sendToPlugins("snapshotFinished"),this.endSnapshot();let t=e.format||"png";return"jpeg"!==t&&"png"!==t&&"bmp"!==t&&(console.error("Unsupported image format: '"+t+"' - supported types are 'jpeg', 'bmp' and 'png' - defaulting to 'png'"),t="png"),A.toDataURL(`image/${t}`)}}}getSnapshot(e={}){return this.scene.fire("rendering",{},!0),this._renderSnapshotToCanvas(e).toDataURL()}async getSnapshotWithPlugins(e={}){const t=this._renderSnapshotToCanvas(e),s={},i=[];for(let e=0,t=this._plugins.length;e<t;e++){const t=this._plugins[e];if(t.getContainerElement){const e=t.getContainerElement();e!==document.body&&(s[e.id]||(s[e.id]=!0,i.push(e)))}}const r=document.createElement("style");document.head.appendChild(r),r.sheet?.insertRule("body > div:last-child img { display: inline-block; }");const n=t.canvas;for(let e=0,t=i.length;e<t;e++){const t=i[e];await(A=t,o={canvas:n,backgroundColor:null,scale:n.width/t.clientWidth},void 0===o&&(o={}),Ib(A,o)),n.getContext("2d").resetTransform()}var A,o;return r.remove(),t.toDataURL()}endSnapshot(){this._snapshotBegun&&(this.scene._renderer.snapshot.endSnapshot(),this._snapshotBegun=!1)}destroy(){const e=this._plugins.slice();for(let t=0,s=e.length;t<s;t++){e[t].destroy()}this.scene.destroy()}},exports.WebIFCLoaderPlugin=class extends mn{constructor(e,t={}){if(super("ifcLoader",e,t),this.dataSource=t.dataSource,this.objectDefaults=t.objectDefaults,this.includeTypes=t.includeTypes,this.excludeTypes=t.excludeTypes,this.excludeUnclassifiedObjects=t.excludeUnclassifiedObjects,!t.WebIFC)throw"Parameter expected: WebIFC";if(!t.IfcAPI)throw"Parameter expected: IfcAPI";this._webIFC=t.WebIFC,this._ifcAPI=t.IfcAPI}get supportedVersions(){return["2x3","4"]}get dataSource(){return this._dataSource}set dataSource(e){this._dataSource=e||new Kw}get objectDefaults(){return this._objectDefaults}set objectDefaults(e){this._objectDefaults=e||WB}get includeTypes(){return this._includeTypes}set includeTypes(e){this._includeTypes=e}get excludeTypes(){return this._excludeTypes}set excludeTypes(e){this._excludeTypes=e}get excludeUnclassifiedObjects(){return this._excludeUnclassifiedObjects}set excludeUnclassifiedObjects(e){this._excludeUnclassifiedObjects=!!e}get globalizeObjectIds(){return this._globalizeObjectIds}set globalizeObjectIds(e){this._globalizeObjectIds=!!e}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new jr(this.viewer.scene,j.apply(e,{isModel:!0}));if(!e.src&&!e.ifc)return this.error("load() param expected: src or IFC"),t;const s={autoNormals:!0};if(!1!==e.loadMetadata){const t=e.includeTypes||this._includeTypes,i=e.excludeTypes||this._excludeTypes,r=e.objectDefaults||this._objectDefaults;if(t){s.includeTypesMap={};for(let e=0,i=t.length;e<i;e++)s.includeTypesMap[t[e]]=!0}if(i){s.excludeTypesMap={};for(let e=0,t=i.length;e<t;e++)s.excludeTypesMap[i[e]]=!0}r&&(s.objectDefaults=r),s.excludeUnclassifiedObjects=void 0!==e.excludeUnclassifiedObjects?!!e.excludeUnclassifiedObjects:this._excludeUnclassifiedObjects,s.globalizeObjectIds=void 0!==e.globalizeObjectIds?!!e.globalizeObjectIds:this._globalizeObjectIds}try{e.src?this._loadModel(e.src,e,s,t):this._parseModel(e.ifc,e,s,t)}catch(e){this.error(e),t.fire("error",e)}return t}_loadModel(e,t,s,i){const r=this.viewer.scene.canvas.spinner;r.processes++,this._dataSource.getIFC(t.src,(e=>{this._parseModel(e,t,s,i),r.processes--}),(e=>{r.processes--,this.error(e),i.fire("error",e)}))}_parseModel(e,t,s,i){if(i.destroyed)return;const r=t.stats||{};if(r.sourceFormat="IFC",r.schemaVersion="",r.title="",r.author="",r.created="",r.numMetaObjects=0,r.numPropertySets=0,r.numObjects=0,r.numGeometries=0,r.numTriangles=0,r.numVertices=0,!this._ifcAPI)throw"WebIFCLoaderPlugin has no WebIFC instance configured - please inject via WebIFCLoaderPlugin constructor";const n=new Uint8Array(e),A=this._ifcAPI.OpenModel(n),o=this._ifcAPI.GetModelSchema(A),a=this._ifcAPI.GetLineIDsWithType(A,this._webIFC.IFCPROJECT).get(0),l=!1!==t.loadMetadata,c={modelID:A,modelSchema:o,sceneModel:i,loadMetadata:l,metadata:l?{id:"",projectId:""+a,author:"",createdAt:"",schema:"",creatingApplication:"",metaObjects:[],propertySets:[]}:null,metaObjects:{},options:s,log:function(e){},nextId:0,stats:r};if(l){if(s.includeTypes){c.includeTypes={};for(let e=0,t=s.includeTypes.length;e<t;e++)c.includeTypes[s.includeTypes[e]]=!0}if(s.excludeTypes){c.excludeTypes={};for(let e=0,t=s.excludeTypes.length;e<t;e++)c.excludeTypes[s.excludeTypes[e]]=!0}this._parseMetaObjects(c),this._parsePropertySets(c)}if(this._parseGeometry(c),i.finalize(),l){const e=i.id;this.viewer.metaScene.createMetaModel(e,c.metadata,s)}i.scene.once("tick",(()=>{i.destroyed||(i.scene.fire("modelLoaded",i.id),i.fire("loaded",!0,!1))}))}_parseMetaObjects(e){const t=this._ifcAPI.GetLineIDsWithType(e.modelID,this._webIFC.IFCPROJECT).get(0),s=this._ifcAPI.GetLine(e.modelID,t);this._parseSpatialChildren(e,s)}_parseSpatialChildren(e,t,s){const i=this._ifcAPI.GetNameFromTypeCode(t.type);if(e.includeTypes&&!e.includeTypes[i])return;if(e.excludeTypes&&e.excludeTypes[i])return;this._createMetaObject(e,t,s);const r=t.GlobalId.value;this._parseRelatedItemsOfType(e,t.expressID,"RelatingObject","RelatedObjects",this._webIFC.IFCRELAGGREGATES,r),this._parseRelatedItemsOfType(e,t.expressID,"RelatingStructure","RelatedElements",this._webIFC.IFCRELCONTAINEDINSPATIALSTRUCTURE,r)}_createMetaObject(e,t,s){const i=t.GlobalId.value,r=this._ifcAPI.GetNameFromTypeCode(t.type),n={id:i,name:t.Name&&""!==t.Name.value?t.Name.value:r,type:r,parent:s};e.metadata.metaObjects.push(n),e.metaObjects[i]=n,e.stats.numMetaObjects++}_parseRelatedItemsOfType(e,t,s,i,r,n){const A=this._ifcAPI.GetLineIDsWithType(e.modelID,r);for(let r=0;r<A.size();r++){const o=A.get(r),a=this._ifcAPI.GetLine(e.modelID,o),l=a[s];let c=!1;if(Array.isArray(l)){c=l.map((e=>e.value)).includes(t)}else c=l.value===t;if(c){const t=a[i];if(Array.isArray(t))t.forEach((t=>{const s=this._ifcAPI.GetLine(e.modelID,t.value);this._parseSpatialChildren(e,s,n)}));else{const s=this._ifcAPI.GetLine(e.modelID,t.value);this._parseSpatialChildren(e,s,n)}}}}_parsePropertySets(e){const t=this._ifcAPI.GetLineIDsWithType(e.modelID,this._webIFC.IFCRELDEFINESBYPROPERTIES);for(let s=0;s<t.size();s++){let i=t.get(s),r=this._ifcAPI.GetLine(e.modelID,i,!0);if(r){const t=r.RelatingPropertyDefinition;if(!t)continue;const s=t.GlobalId.value,i=t.HasProperties;if(i&&i.length>0){const n="Default",A=t.Name.value,o=[];for(let e=0,t=i.length;e<t;e++){const t=i[e],s=t.Name,r=t.NominalValue;if(s&&r){const e={name:s.value,type:r.type,value:r.value,valueType:r.valueType};t.Description?e.description=t.Description.value:r.description&&(e.description=r.description),o.push(e)}}const a={id:s,type:n,name:A,properties:o};e.metadata.propertySets.push(a),e.stats.numPropertySets++;const l=r.RelatedObjects;if(!l||0===l.length)return;for(let t=0,i=l.length;t<i;t++){const i=l[t].GlobalId.value,r=e.metaObjects[i];r&&(r.propertySetIds||(r.propertySetIds=[]),r.propertySetIds.push(s))}}}}}_parseGeometry(e){this._ifcAPI.StreamAllMeshes(e.modelID,(t=>{const s=t.expressID,i=t.geometries,r=[],n=this._ifcAPI.GetLine(e.modelID,s).GlobalId.value;if(e.loadMetadata){const t=n,s=e.metaObjects[t];if(e.includeTypes&&(!s||!e.includeTypes[s.type]))return;if(e.excludeTypes&&(!s||e.excludeTypes[s.type]))return}const A=R.mat4(),o=R.vec3();for(let t=0,s=i.size();t<s;t++){const s=i.get(t),n=this._ifcAPI.GetGeometry(e.modelID,s.geometryExpressID),a=this._ifcAPI.GetVertexArray(n.GetVertexData(),n.GetVertexDataSize()),l=this._ifcAPI.GetIndexArray(n.GetIndexData(),n.GetIndexDataSize()),c=new Float64Array(a.length/2),h=new Float32Array(a.length/2);for(let e=0,t=0,s=a.length/6;e<s;e++,t+=3)c[t+0]=a[6*e+0],c[t+1]=a[6*e+1],c[t+2]=a[6*e+2];A.set(s.flatTransformation),R.transformPositions3(A,c);const u=pt(c,c,o);if(!e.options.autoNormals)for(let e=0,t=0,s=a.length/6;e<s;e++,t+=3)h[t+0]=a[6*e+3],h[t+1]=a[6*e+4],h[t+2]=a[6*e+5];e.stats.numGeometries++,e.stats.numVertices+=c.length/3,e.stats.numTriangles+=l.length/3;const d="mesh"+e.nextId++;e.sceneModel.createMesh({id:d,primitive:"triangles",origin:u?o:null,positions:c,normals:e.options.autoNormals?null:h,indices:l,color:[s.color.x,s.color.y,s.color.z],opacity:s.color.w}),r.push(d)}const a=e.options.globalizeObjectIds?R.globalizeObjectId(e.sceneModel.id,n):n;e.sceneModel.createEntity({id:a,meshIds:r,isObject:!0}),e.stats.numObjects++}))}},exports.Wire3D=sB,exports.WorkerPool=hr,exports.XKTDefaultDataSource=Dy,exports.XKTLoaderPlugin=class extends mn{constructor(e,t={}){super("XKTLoader",e,t),this._maxGeometryBatchSize=t.maxGeometryBatchSize,this.textureTranscoder=t.textureTranscoder,this.dataSource=t.dataSource,this.objectDefaults=t.objectDefaults,this.includeTypes=t.includeTypes,this.excludeTypes=t.excludeTypes,this.excludeUnclassifiedObjects=t.excludeUnclassifiedObjects,this.reuseGeometries=t.reuseGeometries}get supportedVersions(){return Object.keys(Sw)}get textureTranscoder(){return this._textureTranscoder}set textureTranscoder(e){this._textureTranscoder=e}get dataSource(){return this._dataSource}set dataSource(e){this._dataSource=e||new Dy}get objectDefaults(){return this._objectDefaults}set objectDefaults(e){this._objectDefaults=e||WB}get includeTypes(){return this._includeTypes}set includeTypes(e){this._includeTypes=e}get excludeTypes(){return this._excludeTypes}set excludeTypes(e){this._excludeTypes=e}get includeIds(){return this._includeIds}set includeIds(e){this._includeIds=e}get excludeUnclassifiedObjects(){return this._excludeUnclassifiedObjects}set excludeUnclassifiedObjects(e){this._excludeUnclassifiedObjects=!!e}get globalizeObjectIds(){return this._globalizeObjectIds}set globalizeObjectIds(e){this._globalizeObjectIds=!!e}get reuseGeometries(){return this._reuseGeometries}set reuseGeometries(e){this._reuseGeometries=!1!==e}load(e={}){if(e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id),!(e.src||e.xkt||e.manifestSrc||e.manifest))throw new Error("XKTLoaderPlugin: load() param expected: src, xkt, manifestSrc or manifestData");const t={},s=e.includeTypes||this._includeTypes,i=e.excludeTypes||this._excludeTypes,r=e.includeIds||this._includeIds,n=e.objectDefaults||this._objectDefaults;if(t.reuseGeometries=null!==e.reuseGeometries&&void 0!==e.reuseGeometries?e.reuseGeometries:!1!==this._reuseGeometries,s){t.includeTypesMap={};for(let e=0,i=s.length;e<i;e++)t.includeTypesMap[s[e]]=!0}if(i){t.excludeTypesMap={};for(let e=0,s=i.length;e<s;e++)t.excludeTypesMap[i[e]]=!0}if(r){t.includeIdsMap={};for(let e=0,s=r.length;e<s;e++)t.includeIdsMap[r[e]]=!0}n&&(t.objectDefaults=n),t.excludeUnclassifiedObjects=void 0!==e.excludeUnclassifiedObjects?!!e.excludeUnclassifiedObjects:this._excludeUnclassifiedObjects,t.globalizeObjectIds=void 0!==e.globalizeObjectIds&&null!==e.globalizeObjectIds?!!e.globalizeObjectIds:this._globalizeObjectIds;const A=new jr(this.viewer.scene,j.apply(e,{isModel:!0,textureTranscoder:this._textureTranscoder,maxGeometryBatchSize:this._maxGeometryBatchSize,origin:e.origin,disableVertexWelding:e.disableVertexWelding||!1,disableIndexRebucketing:e.disableIndexRebucketing||!1,dtxEnabled:e.dtxEnabled,renderOrder:e.renderOrder})),o=A.id,a=new no({metaScene:this.viewer.metaScene,id:o});this.viewer.scene.canvas.spinner.processes++;const l=()=>{A.destroyed||(A.finalize(),a.finalize(),this.viewer.scene.canvas.spinner.processes--,A.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(a.id)})),this.scheduleTask((()=>{A.destroyed||(A.scene.fire("modelLoaded",A.id),A.fire("loaded",!0,!1))})))},c=e=>{this.viewer.scene.canvas.spinner.processes--,this.error(e),A.fire("error",e)};let h=0;const u={getNextId:()=>`${o}.${h++}`};if(e.metaModelSrc||e.metaModelData)if(e.metaModelSrc){const r=e.metaModelSrc;this._dataSource.getMetaModel(r,(r=>{A.destroyed||(a.loadData(r,{includeTypes:s,excludeTypes:i,globalizeObjectIds:t.globalizeObjectIds}),e.src?this._loadModel(e.src,t,A,null,u,l,c):(this._parseModel(e.xkt,t,A,null,u),l()))}),(e=>{c(`load(): Failed to load model metadata for model '${o} from '${r}' - ${e}`)}))}else e.metaModelData&&(a.loadData(e.metaModelData,{includeTypes:s,excludeTypes:i,globalizeObjectIds:t.globalizeObjectIds}),e.src?this._loadModel(e.src,t,A,null,u,l,c):(this._parseModel(e.xkt,t,A,null,u),l()));else if(e.src)this._loadModel(e.src,t,A,a,u,l,c);else if(e.xkt)this._parseModel(e.xkt,t,A,a,u),l();else if(e.manifestSrc||e.manifest){const r=e.manifestSrc?function(e){e.indexOf("?")>-1&&(e=e.split("?")[0]);const t=e.split("/");return t.pop(),t.join("/")+"/"}(e.manifestSrc):"",n=(e,n,o)=>{let l=0;const c=()=>{A.destroyed||l>=e.length?n():this._dataSource.getMetaModel(`${r}${e[l]}`,(e=>{a.loadData(e,{includeTypes:s,excludeTypes:i,globalizeObjectIds:t.globalizeObjectIds}),l++,this.scheduleTask(c,200)}),o)};c()},o=(e,s,i)=>{let n=0;const o=()=>{A.destroyed||n>=e.length?s():this._dataSource.getXKT(`${r}${e[n]}`,(e=>{this._parseModel(e,t,A,null,u),A.preFinalize(),n++,this.scheduleTask(o,200)}),i)};o()},h=(e,s,i)=>{let n=0;const o=()=>{A.destroyed||n>=e.length?s():this._dataSource.getXKT(`${r}${e[n]}`,(e=>{this._parseModel(e,t,A,a,u),A.preFinalize(),n++,this.scheduleTask(o,200)}),i)};o()};if(e.manifest){const t=e.manifest,s=t.xktFiles;if(!s||0===s.length)return void c("load(): Failed to load model manifest - manifest not valid");const i=t.metaModelFiles;i?n(i,(()=>{o(s,l,c)}),c):h(s,l,c)}else this._dataSource.getManifest(e.manifestSrc,(e=>{if(A.destroyed)return;const t=e.xktFiles;if(!t||0===t.length)return void c("load(): Failed to load model manifest - manifest not valid");const s=e.metaModelFiles;s?n(s,(()=>{o(t,l,c)}),c):h(t,l,c)}),c)}return A}_loadModel(e,t,s,i,r,n,A){this._dataSource.getXKT(e,(e=>{this._parseModel(e,t,s,i,r),s.preFinalize(),n()}),A)}async _parseModel(e,t,s,i,r){if(s.destroyed)return;const n=new DataView(e),A=new Uint8Array(e),o=n.getUint32(0,!0),a=2147483647&o,l=a<11||a>=12&&o>>>31,c=Sw[a];if(!c)return void this.error("Unsupported .XKT file version: "+a+" - this XKTLoaderPlugin supports versions "+Object.keys(Sw));if(!l)return void c.parseArrayBuffer(this.viewer,t,e,s,i,r);const h=n.getUint32(4,!0),u=[];let d=4*(h+2);for(let e=0;e<h;e++){const t=n.getUint32(4*(e+2),!0);u.push(A.subarray(d,d+t)),d+=t}c.parse(this.viewer,t,u,s,i,r)}},exports.XML3DLoaderPlugin=class extends mn{constructor(e,t={}){super("XML3DLoader",e,t),t.workerScriptsPath?(this._workerScriptsPath=t.workerScriptsPath,this._loader=new Rw(this,t),this.supportedSchemas=this._loader.supportedSchemas):this.error("Config expected: workerScriptsPath")}load(e={}){e.workerScriptsPath=this._workerScriptsPath,e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new ct(this.viewer.scene,j.apply(e,{isModel:!0})),s=e.src;return s?(this._loader.load(this,t,s,e),t):(this.error("load() param expected: src"),t)}},exports.ZoneEditControl=_v,exports.ZoneEditMouseControl=class extends _v{constructor(e,t){super(e,t,!0,!1)}},exports.ZoneEditTouchControl=class extends _v{constructor(e,t){super(e,t,!1,!0)}},exports.ZoneTranslateControl=bv,exports.ZoneTranslateMouseControl=class extends bv{constructor(e,t){super(e,t,!0,!1)}},exports.ZoneTranslateTouchControl=class extends bv{constructor(e,t){super(e,t,!1,!0)}},exports.ZonesMouseControl=class extends gv{constructor(e,t={}){super(e,t,((e,t)=>dv(e,t)))}},exports.ZonesPlugin=class extends mn{constructor(e,t={}){super("Zones",e),this._pointerLens=t.pointerLens,this._container=t.container||document.body,this._zones=[],this.defaultColor=void 0!==t.defaultColor?t.defaultColor:"#00BBFF",this.zIndex=t.zIndex||1e4,this._onMouseOver=(e,t)=>{this.fire("mouseOver",{plugin:this,zone:t,event:e})},this._onMouseLeave=(e,t)=>{this.fire("mouseLeave",{plugin:this,zone:t,event:e})},this._onContextMenu=(e,t)=>{this.fire("contextMenu",{plugin:this,zone:t,event:e})}}createZone(e={}){this.viewer.scene.components[e.id]&&(this.error("Viewer scene component with this ID already exists: "+e.id),delete e.id);const t=new fv(this,{id:e.id,plugin:this,container:this._container,geometry:e.geometry,alpha:e.alpha,color:e.color,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onContextMenu:this._onContextMenu});return this._zones.push(t),t.on("destroyed",(()=>{const e=this._zones.indexOf(t);e>=0&&this._zones.splice(e,1)})),this.fire("zoneCreated",t),t}get zones(){return this._zones}destroy(){super.destroy()}},exports.ZonesPolysurfaceMouseControl=class extends ie{constructor(e,t={}){super(e.viewer.scene),this.zonesPlugin=e,this.pointerLens=t.pointerLens,this._action=null}get active(){return!!this._action}activate(e,t,s,i){if("object"==typeof e&&null!==e){const r=e,n=(e,t)=>{if(e in r)return r[e];if(void 0!==t)return t;throw"config missing: "+e};e=n("altitude"),t=n("height"),s=n("color","#008000"),i=n("alpha",.5)}if(this._action)return;const r=this.zonesPlugin,n=r.viewer,A=n.scene,o=this,a=dv(n,(function(t,s){return pv(e,R.vec3([0,1,0]),t,s)}));!function n(){o._action=mv(A,e,t,s,i,o.pointerLens,r,a,(e=>{let t=!0;o._action={deactivate:()=>{t=!1}},o.fire("zoneEnd",e),t&&n()}))}()}deactivate(){this._action&&(this._action.deactivate(),this._action=null)}destroy(){this.deactivate(),super.destroy()}},exports.ZonesPolysurfaceTouchControl=class extends ie{constructor(e,t={}){super(e.viewer.scene),this.zonesPlugin=e,this.pointerLens=t.pointerLens,this.pointerCircle=new ue(e.viewer),this._action=null}get active(){return!!this._action}activate(e,t,s,i){if("object"==typeof e&&null!==e){const r=e,n=(e,t)=>{if(e in r)return r[e];if(void 0!==t)return t;throw"config missing: "+e};e=n("altitude"),t=n("height"),s=n("color","#008000"),i=n("alpha",.5)}if(this._action)return;const r=this.zonesPlugin,n=r.viewer,A=n.scene,o=this,a=oB(n,this.pointerCircle,(function(t,s){return pv(e,R.vec3([0,1,0]),t,s)}));!function n(){o._action=mv(A,e,t,s,i,o.pointerLens,r,a,(e=>{let t=!0;o._action={deactivate:()=>{t=!1}},o.fire("zoneEnd",e),t&&n()}))}()}deactivate(){this._action&&(this._action.deactivate(),this._action=null)}destroy(){this.deactivate(),super.destroy()}},exports.ZonesTouchControl=class extends gv{constructor(e,t={}){const s=new ue(e.viewer);super(e,t,((e,t)=>oB(e,s,t))),this.pointerCircle=s}destroy(){this.pointerCircle.destroy(),super.destroy()}},exports.activateDraggableDot=nB,exports.activateDraggableDots=AB,exports.addMousePressListener=function(e,t){const s=(t,s)=>(s[0]=t.clientX,s[1]=t.clientY,Jb(e.ownerDocument.documentElement,e,s),s);let i=!1;const r=[],n=()=>r.forEach((e=>e())),A=(t,s)=>{e.addEventListener(t,s),r.push((()=>e.removeEventListener(t,s)))},o=R.vec2();return A("mousedown",(function(e){1===e.which&&(i=!0,t(s(e,o)))})),A("mousemove",(function(e){s(e,Qb),i&&R.distVec2(o,Qb)>4&&(i=!1),(i||1&!e.buttons)&&t(Qb)})),A("mouseup",(function(e){if(1===e.which&&i){const i=t(s(e,Qb));i&&(n(),i())}})),n},exports.addTouchPressListener=function(e,t,s,i){const r=R.vec2(),n=(t,s)=>(s[0]=t.clientX,s[1]=t.clientY,Jb(e.ownerDocument.documentElement,e,s),s);let A,o=null,a=Kb;const l=function(){clearTimeout(o),s.stop(),t.active=!0,a=Kb,A=null},c=[],h=()=>c.forEach((e=>e())),u=(t,s)=>{e.addEventListener(t,s,{passive:!0}),c.push((()=>e.removeEventListener(t,s)))};return u("touchstart",(function(e){const c=e.touches;if(1!==c.length)l(),i(null);else{const e=c[0];n(e,r),A=e.identifier,a=e=>{R.distVec2(r,e)>20&&l()},o=setTimeout((function(){s.start(r),o=setTimeout((function(){s.stop(),t.active=!1,a=i,a(r)}),300)}),250)}})),u("touchmove",(function(e){const t=[...e.changedTouches].find((e=>e.identifier===A));t&&a(n(t,Qb))})),u("touchend",(function(e){const t=[...e.changedTouches].find((e=>e.identifier===A));if(t){const e=i(n(t,Qb));l(),e?(h(),e()):i(null)}})),()=>{l(),h()}},exports.buildBoxGeometry=We,exports.buildBoxLinesGeometry=ze,exports.buildBoxLinesGeometryFromAABB=function(e={}){return ze({id:e.id,center:[(e.aabb[0]+e.aabb[3])/2,(e.aabb[1]+e.aabb[4])/2,(e.aabb[2]+e.aabb[5])/2],xSize:Math.abs(e.aabb[3]-e.aabb[0])/2,ySize:Math.abs(e.aabb[4]-e.aabb[1])/2,zSize:Math.abs(e.aabb[5]-e.aabb[2])/2})},exports.buildCylinderGeometry=Xe,exports.buildGridGeometry=Ke,exports.buildLineGeometry=function(e={}){if(3!==e.startPoint.length)throw"Start point should contain 3 elements in array: x, y and z";if(3!==e.endPoint.length)throw"End point should contain 3 elements in array: x, y and z";let t=[],s=[],i=e.startPoint[0],r=e.startPoint[1],n=e.startPoint[2],A=e.endPoint[0],o=e.endPoint[1],a=e.endPoint[2],l=Math.sqrt((A-i)**2+(o-r)**2+(a-n)**2),c=[(A-i)/l,(o-r)/l,(a-n)/l];if(e.pattern){let h=e.pattern.length,u=!1,d=0,p=0,f=0,g=[i,r,n],m=e.pattern[p];for(s.push(g[0],g[1],g[2]);m<=l-d;){let i=[c[0]*m,c[1]*m,c[2]*m],r=[g[0]+i[0],g[1]+i[1],g[2]+i[2]];s.push(r[0],r[1],r[2]),u||(t.push(f),t.push(f+1)),u=!u,f+=1,g=r,p+=1,p>=h&&(p=0),d+=m,m=e.pattern[p]}e.extendToEnd&&(s.push(A,o,a),t.push(t.length-2),t.push(t.length-1))}else t.push(0),t.push(1),s.push(i,r,n,A,o,a);return j.apply(e,{primitive:"lines",positions:s,indices:t})},exports.buildPlaneGeometry=Ze,exports.buildPolylineGeometry=et,exports.buildPolylineGeometryFromCurve=function(e={}){let t=e.curve.getPoints(e.divisions).map((e=>[...e])).flat();return et({id:e.id,points:t})},exports.buildSphereGeometry=Je,exports.buildTorusGeometry=Ye,exports.buildVectorTextGeometry=qe,exports.createCombinedTexture=async function(e,t){if(!t.src||!Array.isArray(t.src)||6!==t.src.length)throw new Error("src requires path to 6 images");const[s,i,r,n,A,o]=t.src;if(!(s&&i&&r&&n&&A&&o))throw new Error("All six images must be provided");const a=document.createElement("canvas"),l=a.getContext("2d"),c=e=>new Promise(((t,s)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>t(i),i.onerror=()=>s(new Error(`Failed to load image: ${e}`)),i.src=e}));try{const[h,u,d,p,f,g]=await Promise.all([c(s),c(i),c(r),c(n),c(A),c(o)]),m=h.width;if(u.width!==m||d.width!==m||p.width!==m||f.width!==m||g.width!==m)throw new Error("All skybox textures must have the same dimensions");a.width=4*m,a.height=3*m,l.fillStyle="black",l.fillRect(0,0,a.width,a.height),l.drawImage(u,0*m,1*m,m,m),l.drawImage(h,2*m,1*m,m,m),l.drawImage(d,1*m,0*m,m,m),l.drawImage(p,1*m,2*m,m,m),l.drawImage(f,1*m,1*m,m,m),l.drawImage(g,3*m,1*m,m,m);return new es(e,{image:a,flipY:!0,wrapS:1001,wrapT:1001,encoding:t.encoding||3e3})}catch(e){throw console.error("Error creating combined skybox texture:",e),e}},exports.createRTCViewMat=ut,exports.createSkyboxMesh=function(e,t){return new Ot(e,{geometry:new Le(e,{primitive:"triangles",positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),background:!0,scale:[1e3,1e3,1e3],rotation:[0,-90,0],material:new jt(e,{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:t,backfaces:!0}),visible:!0,pickable:!1,clippable:!1,collidable:!1})},exports.createSphereMapMesh=function(e,t){const s=new Le(e,Je({center:[0,0,0],radius:1,heightSegments:60,widthSegments:60})),i=new jt(e,{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:t,backfaces:!0});return new Ot(e,{geometry:s,background:!0,rotation:[0,0,180],material:i,visible:!0,pickable:!1,clippable:!1,collidable:!1})},exports.frustumIntersectsAABB3=ce,exports.getKTX2TextureTranscoder=fr,exports.isTriangleMeshSolid=ms,exports.load3DSGeometry=function(e,t={}){return new Promise((function(s,i){t.src||(console.error("load3DSGeometry: Parameter expected: src"),i());var r=e.canvas.spinner;r.processes++,j.loadArraybuffer(t.src,(function(e){e.byteLength||(console.error("load3DSGeometry: no data loaded"),r.processes--,i());var n=je.parse.from3DS(e).edit.objects[0].mesh,A=n.vertices,o=n.uvt,a=n.indices;r.processes--,s(j.apply(t,{primitive:"triangles",positions:A,normals:null,uv:o,indices:a}))}),(function(e){console.error("load3DSGeometry: "+e),r.processes--,i()}))}))},exports.loadOBJGeometry=function(e,t={}){return new Promise((function(s,i){t.src||(console.error("loadOBJGeometry: Parameter expected: src"),i());var r=e.canvas.spinner;r.processes++,j.loadArraybuffer(t.src,(function(e){e.byteLength||(console.error("loadOBJGeometry: no data loaded"),r.processes--,i());for(var n=je.parse.fromOBJ(e),A=je.edit.unwrap(n.i_verts,n.c_verts,3),o=je.edit.unwrap(n.i_norms,n.c_norms,3),a=je.edit.unwrap(n.i_uvt,n.c_uvt,2),l=new Int32Array(n.i_verts.length),c=0;c<n.i_verts.length;c++)l[c]=c;r.processes--,s(j.apply(t,{primitive:"triangles",positions:A,normals:o.length>0?o:null,autoNormals:0===o.length,uv:a,indices:l}))}),(function(e){console.error("loadOBJGeometry: "+e),r.processes--,i()}))}))},exports.marker3D=iB,exports.math=R,exports.meshSurfaceArea=Is,exports.meshVolume=ws,exports.os=gn,exports.sRGBEncoding=3001,exports.setFrustum=le,exports.startPolygonCreate=function(e,t,s,i,r,n){const A=e.canvas.canvas,o=t?function(e,s){t.visible=!!e,e&&(t.canvasPos=e,t.snapped=!!s)}:()=>{},a=function(){const e=(e,t,s)=>t[0]<=Math.max(e[0],s[0])&&t[0]>=Math.min(e[0],s[0])&&t[1]<=Math.max(e[1],s[1])&&t[1]>=Math.min(e[1],s[1]),t=(e,t,s)=>{const i=(t[1]-e[1])*(s[0]-t[0])-(t[0]-e[0])*(s[1]-t[1]);return 0===i?0:i>0?1:2};return function(s,i){const r=i?1:0,n=s[(s.length-2+r)%s.length],A=s[(s.length-1+r)%s.length];for(let i=r;i<s.length-2-1+r;++i){const r=s[i],o=s[i+1],a=t(n,A,r),l=t(n,A,o),c=t(r,o,n),h=t(r,o,A);if(a!==l&&c!==h||0===a&&e(n,r,A)||0===l&&e(n,o,A)||0===c&&e(r,n,o)||0===h&&e(r,A,o))return!0}return!1}}(),l=e=>e.length>=3&&function(){const t=R.normalizeVec3(R.subVec3(e[1],e[0],R.vec3())),s=R.normalizeVec3(R.subVec3(e[2],e[0],Lb)),i=R.normalizeVec3(R.cross3Vec3(t,s,R.vec3())),r=R.normalizeVec3(R.cross3Vec3(i,t,R.vec3()));return{normal:i,origin:R.vec3(e[0]),u:t,v:r}}(),c=[];let h;return function t(){const u=l(c);let d=!1;const p=s((t=>{const s=t&&(e=>{const t=i(e),s=t&&t.entity&&(!u||t.snapped)&&t.worldPos;if(u){const t=R.dotVec3(u.normal,u.origin),i=s?t-R.dotVec3(s,u.normal):window.Infinity;if(Math.abs(i)<1e-4){const e=R.vec3();return{worldPos:R.addVec3(s,R.mulVec3Scalar(u.normal,i,e),e),snapped:!0}}return{worldPos:Zb(t,u.normal,e.origin,e.direction),snapped:!1}}return{worldPos:s,snapped:t&&t.snapped}})(((t,s)=>(R.canvasPosToWorldRay(A,e.camera.viewMatrix,e.camera.projMatrix,e.camera.projection,t,s.origin,s.direction),s))(t,Xb)),r=s&&s.worldPos;return f(r,t,s&&s.snapped)})),f=(s,i,A)=>{const h=s?e.camera.projectWorldPos(s):i,p=c.length>0&&function(){const t=c[0];return{canvasPos:e.camera.projectWorldPos(t),worldPos:t}}(),f=c.length>=3&&(h&&R.distVec2(h,p.canvasPos)<10||s&&R.compareVec3(s,p.worldPos));o(f?p.canvasPos:h,f||A);const g=i&&(!s||(c.length<3?c.some((e=>R.compareVec3(e,s))):R.compareVec3(c[c.length-1],s))),m=c.concat(f||!s||g?[]:[s]),_=!g&&(u||l(m)),b=_&&m.map((e=>(R.subVec3(e,_.origin,Lb),R.vec2([R.dotVec3(Lb,_.u),R.dotVec3(Lb,_.v)])))),B=!(g||b&&a(b,f)),y=B&&b&&(f||!a(b,!0))&&function(){try{const[e,t,s]=aB(b);return{faces:t,vertices:e.map((e=>R.addVec3(_.origin,R.addVec3(R.mulVec3Scalar(_.u,e[0],Lb),R.mulVec3Scalar(_.v,e[1],Hb),Lb),R.vec3())))}}catch(e){return console.warn("e",e),!1}}();return r(m,f,B,y),d=B&&(f?()=>{o(null),n()}:()=>{c.push(R.vec3(s)),o(null),t()})};h={closePolygon:()=>{const e=c.length>=3&&f(c[0]);return e&&(p(),e()),!!e},placeVertex:()=>(d&&(p(),d()),!!d),popVertex:()=>c.length>0&&(p(),c.pop(),t(),!0),removePressListener:p,updateOnChange:()=>f()}}(),{cancel:()=>{h.removePressListener(),o(null)},closePolygon:()=>h.closePolygon(),placeVertex:()=>h.placeVertex(),popVertex:()=>h.popVertex(),updateOnChange:()=>h.updateOnChange()}},exports.stats=L,exports.touchPointSelector=oB,exports.transformToNode=Jb,exports.triangulateEarClipping=aB,exports.utils=j,exports.wire3D=rB,exports.worldToRTCPos=dt,exports.worldToRTCPositions=pt;
|